2
我正在制作的组件需要默认相机,但this.el.sceneEl.camera
返回undefined
。如何从组件中访问默认相机?
AFRAME.registerComponent('test', {
init: function() {
console.log(this.el.sceneEl.camera)
}
});
我怎样才能取回相机?
我正在制作的组件需要默认相机,但this.el.sceneEl.camera
返回undefined
。如何从组件中访问默认相机?
AFRAME.registerComponent('test', {
init: function() {
console.log(this.el.sceneEl.camera)
}
});
我怎样才能取回相机?
可能需要等待摄像机设置?需要证明这一点,但有一个事件:
this.el.sceneEl.addEventListener('camera-set-active', function (evt) {
console.log(evt.detail.cameraEl);
});
是的,这工作!这是[更新的CodePen](https://codepen.io/bryik/pen/apoWox)。 – bryik