Improved draggable cubes example.

This commit is contained in:
Mr.doob
2011-09-04 01:14:16 +02:00
parent 51368ca6d6
commit 4ed370e362
@@ -25,7 +25,9 @@
var camera, scene, projector, renderer;
var objects = [], plane;
var mouse = { x: 0, y: 0 }, INTERSECTED, SELECTED;
var mouse = new THREE.Vector2(),
offset = new THREE.Vector3(),
INTERSECTED, SELECTED;
init();
animate();
@@ -133,7 +135,7 @@
if ( SELECTED ) {
var intersects = ray.intersectObject( plane );
SELECTED.position.copy( intersects[ 0 ].point );
SELECTED.position.copy( intersects[ 0 ].point.subSelf( offset ) );
return;
}
@@ -180,8 +182,10 @@
SELECTED = intersects[ 0 ].object;
}
var intersects = ray.intersectObject( plane );
offset.copy( intersects[ 0 ].point ).subSelf( plane.position );
}
}
function onDocumentMouseUp( event ) {