maxandonuts
maxandonuts

Reputation: 595

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

While working on a WebGL project using the excellent Sim.js and Three.js libraries, i've stumbled upon the next problem:

Somewhere along the way, it uses the next constructor for THREE.Ray:

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

where vector is Vector3,

which triggers the following error:

TypeError Object[object object] has no method subSelf.

I checked the documentation from the Three.js that i'm using and the method on vector3 that approached the most this one is

.sub( v ) Vector3

i tried changing this and a new error shows up on this call:

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

which again throws an error because, when i check, ray doesn't have a intersectsPlane method

Upvotes: 7

Views: 4640

Answers (1)

Alex Wayne
Alex Wayne

Reputation: 187074

I believe the THREE.js api changed a while back.

Vector3's subSelf() is now simply sub(), as you discovered.

And Ray's intersectsPlane() looks like it should be intersectPlane().

If you want complex scene intersection, you probably want to use Raycaster instead. 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 simply inspecting the source code.

Upvotes: 14

Related Questions