Para un motor de juego que estoy haciendo con tres js, necesito ponerlo en una clase. Pero ahora, cuando lo pongo en la clase, todo funciona, excepto cuando le digo a requestAnimateFrame() que se vincule a sí mismo, dice "BEngine.js: 19 TypeError no detectado: no se pueden leer las propiedades de undefined (leyendo 'animado')".
export class BEngine { constructor(doc){ this.scene = new THREE.Scene(); this.camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); this.renderer = new THREE.WebGLRenderer({ antialias: true }); this.renderer.setSize(window.innerWidth, window.innerHeight); doc.body.appendChild(this.renderer.domElement); window.addEventListener("resize", this.onWindowResize, false); } animate() { requestAnimationFrame(this.animate); this.renderer.render(this.scene, this.camera); } onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); } }