Reputation: 531
I don't understand if it is a pure javascript mistake or not. In the class function below I added an eventListener that return me this error:
Uncaught TypeError: Cannot read property 'call' of undefined
I want to clarify that all the function called are correctly defined.
function OrbitController(v){
var that = this;
this.view = v;
this.controls = new THREE.OrbitControls(this.view.getCamera(),this.view.renderer.domElement);
this.controls.addEventListener( 'change', that.view.show());// Uncaught TypeError: Cannot read property 'call' of undefined
this.controls.target = new THREE.Vector3(0, 0, 0);
}
Upvotes: 0
Views: 1175
Reputation: 4150
Try with this solution:
this.controls.addEventListener( 'change', function(){ that.view.show()});
Upvotes: 1
Reputation: 32066
Unless that.view.show()
returns a function, then it should just be
this.controls.addEventListener( 'change', that.view.show );
Upvotes: 1