提交 5b1b1973 编写于 作者: A Angelo Wang

Fix DragControls for containers not at (0,0)

If the container (renderer.domElement) is not at the top-left corner of the browser,
the hit-test will always fail.
The `TransformControl` is using the correct way, so it doesn't have such issue.
上级 3ae54a2a
......@@ -52,8 +52,10 @@ THREE.DragControls = function ( _objects, _camera, _domElement ) {
event.preventDefault();
_mouse.x = ( event.clientX / _domElement.clientWidth ) * 2 - 1;
_mouse.y = - ( event.clientY / _domElement.clientHeight ) * 2 + 1;
var rect = _domElement.getBoundingClientRect();
_mouse.x = ( (event.clientX - rect.left) / rect.width ) * 2 - 1;
_mouse.y = - ( (event.clientY - rect.top) / rect.height ) * 2 + 1;
_raycaster.setFromCamera( _mouse, _camera );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册