[英]aframe look-controls stopped working when animate function of renderer is implemented
I am implementing animate function of renderer to extend some of the functionalities. 我正在实现渲染器的动画功能,以扩展某些功能。
this.scene = document.querySelector('a-scene').object3D;
this.renderer = document.querySelector('a-scene').renderer;
var comp = this;
this.scene.children.forEach(element => {
element.traverse(function (node) {
if(node.type === "PerspectiveCamera"){
comp.camera = node;
comp.renderer.animate( update )
}
});
});
function update(){
if(THREE.VRController){
THREE.VRController.update();
}
var scene = document.querySelector('a-scene').object3D;
var renderer = document.querySelector('a-scene').renderer;
scene.children.forEach(element => {
element.traverse(function (node) {
if(node.type === "PerspectiveCamera"){
var camera = node;
var lookcontrols = node.el.components['look-controls'];
if(lookcontrols){
lookcontrols.play();
}
renderer.render( scene, camera );
}
});
});
}
When I comment the line of code comp.renderer.animate( update ) look-controls starts working. 当我注释代码行comp.renderer.animate(update)时,外观控件开始工作。 I want to keep above implementation and also look-controls working.
我想保持上述实现,并且外观控件也能正常工作。 Please suggest a way.
请提出一种方法。
Here's A-Frame's render function: 这是A-Frame的渲染功能:
var renderer = this.renderer;
this.frame = frame;
this.delta = this.clock.getDelta() * 1000;
this.time = this.clock.elapsedTime * 1000;
if (this.isPlaying) { this.tick(this.time, this.delta); }
renderer.render(this.object3D, this.camera, this.renderTarget);
The component ticks are called on the tick
. 组件刻度在
tick
上被调用。 You should wrap the render call to extend it rather than replacing it completely like: 您应该包装render调用以扩展它,而不是像下面那样完全替换它:
sceneEl.prototype.render = {
value: function () {
// Your code here.
originalRender();
// More of your code here.
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.