tizzle / aframe-orbit-controls-component

An Orbit Controls Component for A-Frame VR
https://tizzle.github.io/aframe-orbit-controls-component/
MIT License
75 stars 25 forks source link

Issue when play is triggered after sceneEl renderstart event #35

Open jeromeetienne opened 6 years ago

jeromeetienne commented 6 years ago

Thanks for your work, really appreciated :)

in the component play function, one can find the following code

this.sceneEl.addEventListener('renderstart', this.onRenderTargetLoaded, false);
// ...
// and later ...
onRenderTargetLoaded: function () {
    console.log('component onRenderTargetLoaded')
    this.sceneEl.removeEventListener('renderstart', this.onRenderTargetLoaded, false);
    this.canvasEl = this.sceneEl.canvas;
    this.addEventListeners();
},

But if play is called after renderstart is triggered, then onRenderTargetLoaded is never called, and .addEventListeners either.

this.sceneEl.addEventListener('renderstart', this.onRenderTargetLoaded, false);
// test if renderstart has already been triggered
if( this.sceneEl.renderStarted ){
    this.onRenderTargetLoaded()
}

Thanks