我不明白这是不是纯粹的javascript错误。在下面的类函数中,我添加了一个eventListener,它返回给我这个错误:
Uncaught TypeError: Cannot read property 'call' of undefined
我想澄清所有被调用的函数都已正确定义。
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);
}
答案 0 :(得分:1)
除非that.view.show()
返回一个函数,否则它应该只是
this.controls.addEventListener( 'change', that.view.show );
答案 1 :(得分:1)
尝试使用此解决方案:
this.controls.addEventListener( 'change', function(){ that.view.show()});