Why loader.addEventListener is not a function

var loader = new THREE.VTKLoader();
loader.addEventListener( ‘load’, function ( event ) {})
console print loader.addEventListener is not a function

Loader in your case is not a DOM Element. Hence addEventListener is not the right thing to implement.

You can use the loader’s callback function instead.

var loader = new THREE.VTKLoader();
loader.load( url,  function ( result ) {
      console.log( result );

other question:
scope.dispatchEvent is not a function
geometry.computeCentroids is not a function

I think you are using a very old version of VTKLoader. The call to geometry.computeCentroids() was removed four years ago (see here).

Please use the current VTKLoader with latest version of three.js from the repo:

1 Like

thank you
I‘m using the latest version of VTKLoader
It is the same as that

I don’t believe that. geometry.computeCentroids is not called in the latest VTKLoader.


It would be a lot easier and quick to identify the problem if you can provide a jsfiddle sample for it.

tttt.zip (894.1 KB)
look it,please

vtk.html (2.6 KB)

The bunny loads fine. You just applied a bad scaling to your mesh and had wrong camera settings.


BTW: I did not see any of your mentioned error messages.


Sry, I’m unable to reproduce. It works fine on my machine.

Same here. Works fine.

var loader = new THREE.VTKLoader();

	var mesh = new THREE.Mesh( geometry, material );
	mesh.position.set( 0,0,0 );
	scene.add( mesh );


1 Like

Interesting, what explains the gremlins that mess up the app when the OP runs the same code?