TypeError Object [object object] has no SubSelf method; TypeError Object [object object] has no intersectsPlane method

While working on a WebGL project using the excellent Sim.js and Three.js libraries, I came across the following problem:

Somewhere along the way, he uses the following constructor for THREE.Ray:

var ray = new THREE.Ray( this.camera.position, vector.subSelf( this.camera.position ).normalize() ); 

where vector is Vector3,

which causes the following error:

The TypeError object [object object] does not have a subSelf method.

I checked the documentation from the Three.js file that I am using and the method on vector3 which is most suitable for this,

 .sub( v ) Vector3 

I tried to change this, and a new error appears on this call:

 var intersects = ray.intersectScene( this.scene ); 

which throws an error again, because when I check, the ray has no intersectsPlane method

+7
source share
1 answer

I believe THREE.js api changed a while ago.

Vector3 subSelf() now just sub() as you discovered.

And Ray intersectsPlane() looks like intersectPlane() .

If you want a complex intersection of a scene, you probably want to use Raycaster . Docs: http://mrdoob.github.com/three.js/docs/56/#Reference/Core/Raycaster

Three.js documentation is not the best thing ever ... However, a lot of insight can be gleaned from a simple check of the source code .

+14
source

All Articles