Why am I encountering a "function is undefined" error for vector.unproject even though it is clearly mentioned in the documentation? You can find it here: (one of the last items)
Even after console logging it, the function still returns as undefined, despite the rest of Threejs working perfectly fine. Is this function deprecated? If so, what is the alternative? I am trying to perform Raycasting and click detection on a loaded .obj file, and this function is stated as a method to achieve this.
Here is the code I am using, which makes use of RequireJS and Backbone for structuring the function:
click: function(event){
var vector = new THREE.Vector3();
vector.set(
( event.clientX / window.innerWidth ) * 2 - 1,
- ( event.clientY / window.innerHeight ) * 2 + 1,
0.5 );
console.log(vector.unproject); //returns undefined
vector.unproject( this.camera ); //execution stops here and returns "function is undefined"
var dir = vector.sub( this.camera.position ).normalize();
var distance = - this.camera.position.z / dir.z;
var pos = this.camera.position.clone().add( dir.multiplyScalar( distance ) );
},