`Raycaster.setFromCamera` Error in OrthographicCamera.
See original GitHub issuehttps://github.com/mrdoob/three.js/blob/dev/src/core/Raycaster.js#L85:78
if ( ( camera && camera.isOrthographicCamera ) ) {
this.ray.origin.set( coords.x, coords.y, ( camera.near + camera.far ) / ( camera.near - camera.far ) ).unproject( camera ); // set origin in plane of camera
this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld );
}
when
camera.near + camera.far === 0
Ray initialization error.
I think the code should be
if ( ( camera && camera.isOrthographicCamera ) ) {
this.ray.origin.set( coords.x, coords.y, -1 ).unproject( camera ); // set origin in plane of camera
this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld );
}
Do not know if my understanding is wrong.
(sorry,My English is not good, these are from Google Translate.)
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
For OrthographicCamera Raycaster.SetFromCamera() sets ...
Setting it from the "near" clipping plane do make more sense. As any objects closer than the near clipping plane is not visible....
Read more >ThreeJS raycasting problem with an Orthographic camera in ...
Raycaster only detects objects in front of the camera, and your camera is located near the origin. Move the camera back.
Read more >Raycaster#setFromCamera – three.js docs
The camera to use when raycasting against view-dependent objects such as billboarded objects like Sprites. This field can be set manually or is...
Read more >Raycaster - Three.js Tutorials - sbcode.net
We can set up the raycaster position and direction using the set or setFromCamera methods and then call its intersectObject or intersectObjects methods...
Read more >THREE.js, Orthographic Camera, find x and z where y=0-three.js
clientX / renderer.domElement.width ) * 2 - 1; mouse.y = - ( event.clientY / renderer.domElement.height ) * 2 + 1; raycaster.setFromCamera( mouse, camera...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closing. three.js only supports non-negative values for the near plane.
AFAIK, Unity does not allow negative values for
near
. I would prefer a policy similar to other popular engines.