Francesco1984
Francesco1984

Reputation: 531

Threejs and orbitcontrol

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

Answers (2)

Stefano Maglione
Stefano Maglione

Reputation: 4150

Try with this solution:

this.controls.addEventListener( 'change',  function(){ that.view.show()});

Upvotes: 1

Andy Ray
Andy Ray

Reputation: 32066

Unless that.view.show() returns a function, then it should just be

this.controls.addEventListener( 'change', that.view.show ); 

Upvotes: 1

Related Questions