There are two main ways to find the offsets of your canvas from the top of the screen.
The following code from West Langley illustrates: Method 1 To correctly use the following method, set the canvas position to static; margin> 0 and padding> 0 in order
mouse.x = ((event.clientX - renderer.domElement.offsetLeft) /renderer.domElement.width) * 2 - 1; mouse.y = - ((event.clientY - renderer.domElement.offsetTop) /renderer.domElement.height) * 2 + 1;
2 ; set top > 0, left > 0; 0; margin > 0
mouse.x = ((event.clientX - container.offsetLeft)/container.clientWidth) * 2 - 1;
mouse.y = - ((event.clientY - container.offsetTop)/container.clientHeight) * 2 + 1;
.
- , html iframe html.