当我在原点放置一个块时,它离我的传感器很远。我希望将帧边距向前移动1米(-z方向1)。此外,我正在使用一个跟踪摄像机位置的组件,因此我不能将所有内容都包裹在<a-entity>
中并向前移动。如何更改原点的位置?
组件:
AFRAME.registerComponent('info-panel', {
tick: function() {
var el = this.el;
var camera = document.querySelector('a-camera');
var cpos = camera.getAttribute('position');
var x = cpos.x;
var z = cpos.z;
var angle;
if (z === 0) {
if (x === 0) {
angle = 0;
} else if (x > 0) {
angle = 90;
} else {
angle = -90;
}
} else {
angle = (z > 0 ? 0 : 180);
angle += 180 / Math.PI * Math.atan(x / z);
}
el.setAttribute('rotation', {x: 0, y: angle, z: 0});
}
});
场景:
<a-scene>
<a-camera></a-camera>
<a-panel info-panel></a-panel>
</a-scene>
答案 0 :(得分:1)
或者您可以使用包装器实体定位相机。
How do a place the camera first position
<a-entity position="0 0 5">
<a-camera></a-camera>
</a-entity>
答案 1 :(得分:0)
I'm not sure if there is such functionality,
I would wrap everything except the camera in <a-entity>
So You can position 'everything' except the camera.