Skip to content

Commit 925d679

Browse files
alitanmrdoobMugen87
authored
Update ViewHelper.js (#26067)
* Update ViewHelper.js I tried to embed the editor's ViewHelper and the mouse events did not translate properly. Instead of using a complex code to calc the mouse.x and mouse.y, i did use event.offsetX and event.offsetY This solved my problem and fixed any embedding issues. * Update ViewHelper.js Y axis should be inversed. * Update ViewHelper.js Reverting back to the original code with one fix. rect.width should be rect.right * Update ViewHelper.js * Update ViewHelper.js --------- Co-authored-by: mrdoob <[email protected]> Co-authored-by: Michael Herzog <[email protected]>
1 parent b980375 commit 925d679

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/jsm/helpers/ViewHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class ViewHelper extends Object3D {
167167
const rect = domElement.getBoundingClientRect();
168168
const offsetX = rect.left + ( domElement.offsetWidth - dim );
169169
const offsetY = rect.top + ( domElement.offsetHeight - dim );
170-
mouse.x = ( ( event.clientX - offsetX ) / ( rect.width - offsetX ) ) * 2 - 1;
170+
mouse.x = ( ( event.clientX - offsetX ) / ( rect.right - offsetX ) ) * 2 - 1;
171171
mouse.y = - ( ( event.clientY - offsetY ) / ( rect.bottom - offsetY ) ) * 2 + 1;
172172

173173
raycaster.setFromCamera( mouse, orthoCamera );

0 commit comments

Comments
 (0)