Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 919
maxandonuts Avatar asked Mar 04 '13 21:03

maxandonuts


1 Answers

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.

like image 184
Alex Wayne Avatar answered Nov 11 '22 10:11

Alex Wayne