ソースを参照

InteractiveGroup: Use getBoundingClientRect() when computing pointer. (#24586)

* Fixed issue with pointer location when placed within child HTML element, affecting pointer offset.

* Update InteractiveGroup.js

Co-authored-by: OllyJ918 <[email protected]>
Co-authored-by: Michael Herzog <[email protected]>
werto165 2 年 前
コミット
ce3236004e
1 ファイル変更4 行追加2 行削除
  1. 4 2
      examples/jsm/interactive/InteractiveGroup.js

+ 4 - 2
examples/jsm/interactive/InteractiveGroup.js

@@ -27,8 +27,10 @@ class InteractiveGroup extends Group {
 
 			event.stopPropagation();
 
-			_pointer.x = ( event.clientX / element.clientWidth ) * 2 - 1;
-			_pointer.y = - ( event.clientY / element.clientHeight ) * 2 + 1;
+			const rect = renderer.domElement.getBoundingClientRect();
+			
+			_pointer.x = ( event.clientX - rect.left ) / rect.width * 2 - 1;
+			_pointer.y = - ( event.clientY - rect.top ) / rect.height * 2 + 1;
 
 			raycaster.setFromCamera( _pointer, camera );