实现渲染器的动画功能后,aframe外观控件停止工作

时间:2019-01-13 13:57:21

标签: three.js aframe

我正在实现渲染器的动画功能,以扩展某些功能。

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 );
            }
        });
    });

}

当我注释代码行comp.renderer.animate(update)时,外观控件开始工作。我想保持上述实现,并且外观控件也能正常工作。请提出一种方法。

1 个答案:

答案 0 :(得分:0)

这是A-Frame的渲染功能:

my_list = ["Hello %s, nice to meet u",  
        "%s! what a wonderful name",
        "welcome %s"]
for m in my_list:
    print(randint(my_list)% user_name)

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); 上调用了组件刻度。您应该包装render调用以扩展它,而不是完全替换它:

tick