A 型框架轨道控制重置相机位置

A-Frame orbit-controls reset camera position

我正在使用 superframe 的轨道控件 (https://github.com/supermedium/superframe/tree/master/components/orbit-controls),并且我有一个包含两个实体的场景,用户可以使用按钮切换 on/off。每当用户点击按钮时,我想将相机位置重置为初始状态。

我试过像往常一样不使用轨道控制来重置相机的世界位置,但到目前为止我还没有成功。 这是情况的 jsfiddle:https://jsfiddle.net/e7akdgf1/5/

<a-scene embedded class="box" vr-mode-ui="enabled: false" loading-screen="enabled: false">

<a-entity id="cam"
camera
orbit-controls="target: 0 0 0;
initialPosition: 0 0 5;
minDistance: 1;
maxDistance: 50;">

</a-entity>

<a-entity id="cube" position="0 0 0" rotation="45 30 0" geometry="primitive: box; height: 3; width: 3; depth: 3;" material="color: #167341; roughness: 1.0; metalness: 0.2;"></a-entity>

<a-cylinder id="cylinder" position="1 1.25 -1" radius="1" height="2.5" color="#FFC65D" visible="false"></a-cylinder>

</a-scene>

你可以这样改变位置

// check what setting the initial position does in the source code 
cam.getObject3D('camera').position.set(0, 0, 5)

fiddle here.


有一个

this.el.components['orbit-controls'].controls.reset()

在源代码中,但我没有运气。