three.js icon indicating copy to clipboard operation
three.js copied to clipboard

intersectPlane bug

Open MKHenson opened this issue 13 years ago • 6 comments

Hi guys

I have come across a bug with intersect plane I think. The intersection point is incorrect when in orthographic mode, but fine otherwise. ( camera is a CombinedCamera )

plane = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3(0, 0, -1 ), pos );
var camera = viewport.camera;
var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
this.projector.pickingRay( vector, camera );
var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
var intersects = ray.intersectPlane( plane, intersectsPoint );

Perhaps im misunderstanding something...?

MKHenson avatar Jan 10 '13 17:01 MKHenson

Orthographic picking rays do not go through the origin (camera.position) because they are parallel to each other. Thus it is an error in your code above.

bhouston avatar Jan 10 '13 17:01 bhouston

See related issue #2453.

WestLangley avatar Jan 10 '13 17:01 WestLangley

Also, CombinedCamera does not have a position property. This has lead to some user confusion, BTW.

WestLangley avatar Jan 10 '13 18:01 WestLangley

ah... damned CombinedCamera...

mrdoob avatar Jan 10 '13 18:01 mrdoob

Cheers guys, I actually had a feeling it might be something to do with that. Out of curiosity though, how then would you position an object from say a left orthographic view? What I am currently doing, is whenever you click on an object a gizmo is added to the scene which allows you to translate said object. When you click down on one of the axes it creates a plane at the objects location and its normal faces the camera. The ray is fired from the mouse position and I am able to test for the intersection with the plane I am translating on. But how would I do it in orthographic view if the above is true?

Thanks for any help guys Mat

MKHenson avatar Jan 10 '13 23:01 MKHenson

Actually scratch that - i've managed to sort it out. Thanks guys.

MKHenson avatar Jan 11 '13 10:01 MKHenson