【发布时间】:2019-02-17 09:33:34
【问题描述】:
现在正在研究项目,使用 Aframe 构建一些场景。如果用户进入一个门以进入下一个场景,我会尝试在我的 Aframe 场景中的不同相机之间切换。我有两个以下相机装备,每个场景一个:
<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 模式之前,Switch 一直工作,然后相机根本不会切换。
我试图为第一个 CameraRig 设置一个新位置,但这会导致 Teleport 组件出现错误,即 Camera 会跳到它应该传送到的对象下方。
我怎样才能让它工作?感谢您的帮助。
【问题讨论】:
标签: javascript html aframe webvr