1var vec = new THREE.Vector3(); // create once and reuse
2var pos = new THREE.Vector3(); // create once and reuse
3
4vec.set(
5 ( event.clientX / window.innerWidth ) * 2 - 1,
6 - ( event.clientY / window.innerHeight ) * 2 + 1,
7 0.5 );
8
9vec.unproject( camera );
10
11vec.sub( camera.position ).normalize();
12
13var distance = - camera.position.z / vec.z;
14
15pos.copy( camera.position ).add( vec.multiplyScalar( distance ) );
16