现在坐在研究项目上,用Aframe建立一些场景。如果用户进入一个门进入下一个场景,我会尝试在我的Aframe场景中的不同相机之间切换。我有以下两个Camera Rigs,每个场景一个:
<a-entity id="cameraRig" position="10 4 20">
<a-entity id="head" position="0 2 0" camera="" look-controls="pointerLockEnabled:true">
<a-cursor far="30"></a-cursor>
<a-entity position="0.1 -0.4 0"
raycaster="objects: .selectable; far: 2"
teleport-extras
teleport-controls=
"cameraRig: #cameraRig;
teleportOrigin: #head;
startEvents:starttouch;
endEvents:endtouch;
curveShootingSpeed:30;
hitCylinderRadius:0.3;
collisionEntities: #tele">
</a-entity>
</a-entity>
</a-entity>
这是我更改相机的脚本:
function Hell() {
document.getElementById('scene1').setAttribute('visible', 'false');
document.getElementById('hell').setAttribute('visible', 'true');
var standartCam = document.querySelector('#head');
standartCam.setAttribute('camera', 'active', false);
var hellCamera = document.querySelector('#head2');
hellCamera.setAttribute('camera', 'active', true);
}
交换机工作直到我进入VR模式,然后相机根本没有切换。
我试图为第一个CameraRig设置一个新的位置,但这导致了传送组件的错误,相机跳到它应传送到的对象下面。
我怎样才能让它发挥作用?谢谢你的帮助。
经过几个小时的尝试和错误,我找到了解决方案。我正在使用aframe.io/releases/0.8.0。我切换到0.7.0并且工作正常。它也适用于0.8.2。