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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With