【发布时间】:2020-12-02 12:29:09
【问题描述】:
有没有其他人尝试过将 A-Frame VR 与 Nuxt.js 混合使用?我收到错误“未定义窗口”。
目前为止
-
通过 NPM 安装 A-Frame
-
使用以下内容创建了一个插件“plugins/aframe.js”
import Vue from 'vue'
import aframe from 'aframe'
Vue.use(aframe)
- 更新了 nuxt.config.js
plugins: [
{ src: '@/plugins/aframe.js', ssr: false }
],
- 创建了一个组件“components/Aframe.vue”
<template>
<a-scene vr-mode-ui="enabled: false">
<a-entity position="0 0 0">
<a-camera></a-camera>
</a-entity>
<a-entity
geometry="primitive: torusKnot;"
scale="2 2 2"
position="0 1.5 -5"
rotation="0 45 0"
material="color:#BBBBBB"
wireframe
>
<a-animation easing="linear" attribute="rotation" repeat="indefinite" dur="30000" to="0 405 0"></a-animation>
</a-entity>
<a-sky color="#FDFDFD"></a-sky>
</a-scene>
</template>
if (process.client) {
Vue.use(require('aframe'))
}
export default {
created () {
aframe.registerComponent('wireframe', {
dependencies: ['material'],
init () {
this.el.components.material.material.wireframe = true
}
})
}
}
并将组件包含在我的默认布局中
<Aframe />
import Aframe from 'aframe'
export default {
components: {
Aframe
},
【问题讨论】:
标签: javascript vue.js nuxt.js aframe virtual-reality