提交 4ed370e3 编写于 作者: M Mr.doob

Improved draggable cubes example.

上级 51368ca6
......@@ -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,9 +182,11 @@
SELECTED = intersects[ 0 ].object;
}
var intersects = ray.intersectObject( plane );
offset.copy( intersects[ 0 ].point ).subSelf( plane.position );
}
}
function onDocumentMouseUp( event ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册