我正在使用A-frame和Webpack结合使用10个不同的360图像进行虚拟导览,背景声音和配音有两种不同的语言:荷兰语和法语。
当我四处走动时,我会更改src
- a-sky
标记的所有内容,并添加和删除该场景中不需要的一些元素。
当我去3 th 房间的时候,导游会出现折痕,我收到了这个错误:
未捕获的TypeError:无法在
shaderSource
上执行WebGLRenderingContext
:参数1的类型不属于WebGLShader
。at Ft (three.js:16069) at new Zt (three.js:16596) at Jt.acquireProgram (three.js:17019) at b (three.js:21105) at M (three.js:21264) at ae.renderBufferDirect (three.js:20243) at _ (three.js:21034) at ae.render (three.js:20771) at THREE.VREffect.render (VREffect.js:394) at HTMLElement.value (a-scene.js:475)
我认为这是A帧的记忆问题。有没有办法处理它?这个问题How to mange memory used by A-Frame?中的答案,我不知道如何使用它,因为它使用了我不使用的纹理和材料。
如果我使用这行代码:
let aframe = require('aframe');
我在巡演开始时遇到了这个错误。
未捕获的TypeError:无法重新定义属性:
vrEnabled
at Function.defineProperty (<anonymous>) at WebVRPolyfill.enablePolyfill (bundle.js:76211) at new WebVRPolyfill (bundle.js:76143) at Object.14../util.js (bundle.js:74118) at s (bundle.js:68513) at e (bundle.js:68513) at bundle.js:68513 at i (bundle.js:68513) at Object.<anonymous> (bundle.js:68513) at Object.50 (bundle.js:76344)
由于营销原因,我无法显示完整的代码。你必须使用这个伪代码:
'use strict';
let childeren;
function init() {
// 1. Get all the data from an external file
// 2. Get important elements of the scene
}
function render() {
// 3. First remove all the childeren of the `childeren` variable
// 4. Loop over an array from the loaded data and make a new node with 1 or 2 images
// as child
// 5. Add a click event listener to the node and execute `click` when triggered
// 6. Add this node to the `childeren` variable
// 7. Append the `childeren` variable as child of the `a-scene` tag.
// 8. Change the `src`-attribute of the `a-sky` tag
// 9. Change if different the `backgroundsound`s `src`-attribute
// 10. Rotate the camera to the north of the image to avoid disorientation.
}
function click() {
// 11. Depended of witch element is clicked:
// - Execute `render` again with other data
// - Change the `voiceover` `src`-attribute
}
init();
render();
<script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script>
<a-scene id="scene">
<a-sky id="sky" src=""></a-sky>
<a-entity id="variables"></a-entity>
<a-sound id="voiceover" src="" autoplay="true"></a-sound>
<a-sound id="backgroundsound" src="" autoplay="true" volume="0.5" loop="true"></a-sound>
<a-sound id="effects" src="" autoplay="true" volume="0.5"></a-sound>
<a-entity id="camera">
<a-camera look-controls wasd-controls cursor="maxDistance: 30; fuse: true">
<!-- Here stands a cursor -->
</a-camera>
</a-entity>
</a-scene>
每个节点都有data
- 属性,以了解必须渲染的场景或必须播放的女声。
为什么要停止我的巡演并抛出这个错误?有没有办法解决这个错误?欢迎所有帮助。提前谢谢。