[英]How to use Troisjs in Nuxt 3 project
I would like to use TroisJS
( three.js
wrapper for Vue) with Nuxt.js
.我想将
TroisJS
(Vue 的three.js
包装器)与Nuxt.js
一起使用。 According to the TroisJS
documentation ( https://troisjs.github.io/guide/install.html#existing-vuejs-3-project ) I need to add it to my project like:根据
TroisJS
文档( https://troisjs.github.io/guide/install.html#existing-vuejs-3-project ),我需要将其添加到我的项目中,例如:
import { TroisJSVuePlugin } from 'troisjs';
app.use(TroisJSVuePlugin);
However, I don"t know how to figure out where I should put this code. I would expect the nuxt.config.js file, but I don't seem to quite get it where it should go.但是,我不知道如何弄清楚我应该把这段代码放在哪里。我希望 nuxt.config.js 文件,但我似乎不太明白它应该放在哪里。
I decided to use TroisJS
and not three.js
because I thought the former might be easier to import and use.我决定使用
TroisJS
而不是three.js
,因为我认为前者可能更容易导入和使用。 If importing three.js
directly is easier, I don't mind using it.如果直接导入
three.js
比较容易,我不介意用。
Thank you very much for any help!非常感谢您的帮助!
In /plugins
folder add new file named troisjs-plugin.js
with the following content :在
/plugins
文件夹中添加名为troisjs-plugin.js
的新文件,其内容如下:
import { TroisJSVuePlugin } from 'troisjs';
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(TroisJSVuePlugin )
})
I found a repo with some testing with Trois and Nuxt 3, probably outdated and maybe some apis have changed, but if you wanna check it out: alvarosabu/nuxt3-trois我发现了一个对 Trois 和 Nuxt 3 进行了一些测试的 repo,可能已经过时并且可能一些 api 已经改变,但是如果你想检查一下: alvarosabu/nuxt3-trois
Also, there's an official repo from the Trois author with a Nuxt 3 custom plugin (probably outdated too) here此外,还有来自 Trois 作者的官方 repo,带有 Nuxt 3 自定义插件(可能也已过时) here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.