question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Raycaster.setFromCamera` Error in OrthographicCamera.

See original GitHub issue

https://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:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
WestLangleycommented, Aug 13, 2018

Closing. three.js only supports non-negative values for the near plane.

0reactions
Mugen87commented, May 28, 2018

AFAIK, Unity does not allow negative values for near. I would prefer a policy similar to other popular engines.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found