cannot pick successfully when the direction is [0,-1,0]
tornado96 opened this issue · 2 comments
when I use scene#pick method to pick surface. And the mesh is a box with size 1. and the origin =[0,0,0] , the direction is [0,-1,0] or [0,1,0] . And the pick result is undefined.
Is it an Issue? or is something wrong with my code?
scene.pick({pickSurface:true,origin:[0,0,0],direction:[0,-1,0]});
Nope nothing wrong with your code. The reason is because, internally, xeogl builds a "lookat" matrix, with which "eye" position is taken from origin
, "look" is taken from direction
, but "up" is just set to [0,1,0]
. Therefore, a ray pointing straight down or up will result in an eye->look vector parallel to "up".
I fixed this in xeokit by allowing the user to pass in that matrix, pre-made.
Code: https://github.com/xeokit/xeokit-sdk/blob/master/src/viewer/scene/webgl/Renderer.js#L667
Usage example: xeokit/xeokit-sdk@9c8c916#diff-81d67f18be38b8cf7722dedf57b4f28cR177
If anyone would like to add that to xeogl, a PR would be most welcome.
ok,thanks very much!