ember.js - three.js animations in ember js -


how should create render loop of three.js animations in ember js. code have till

import ember 'ember';  export default ember.controller.extend({   scene: new three.scene(),   camera: new three.perspectivecamera(75,     window.innerwidth/window.innerheight,1,500),   renderer: new three.webglrenderer(),   init: function() {     this.renderer.setsize(window.innerwidth, window.innerheight);     document.body.appendchild(this.renderer.domelement);     this.renderpreloader();   },   renderpreloader:function() {     var geometry = new three.boxgeometry( 1, 1, 1 );     var material = new three.meshbasicmaterial( { color: 0x00ff00 } );     var cube = new three.mesh(geometry,material);     this.scene.add(cube);     this.camera.position.set(2,2,2);     this.camera.lookat(cube.position);     this.renderer.render(this.scene,this.camera);     this.renderloop();   },   renderloop: function() {     requestanimationframe(this.renderloop);     this.camera.position.x = this.camera.position.x+0.01;     this.renderer.render(this.scene,this.camera);   } }); 

the error getting this not defined @ requestanimationframe. proper way through ?

to pass scope correctly, :

requestanimationframe(this.renderloop.bind(this));

or

requestanimationframe(() => {this.renderloop()});


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -