mirror of
https://github.com/wahyd4/three.js.git
synced 2026-08-09 04:56:01 +10:00
Improved draggable cubes example.
This commit is contained in:
@@ -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 ) {
|
||||
|
||||
Reference in New Issue
Block a user