Hi everybody !
I need to do one simple thing … create a Ray from the camera target and going up, perpendicular to the camera forward ray.
I’ve read things about rotation, but I’m not able to use them for Vector3 or Rays…
So here is my attempt to do this : https://playground.babylonjs.com/#C0D5C5#5
I’m creating a “help” box, and a “helpUp” box attached to it (its child)
When the camera moves, the boxes follows.
But as you can see, creating the ray from “help” to “helpUp” isn’t working. The coordinates are OK in the console, but for a reason, the Ray isn’t doing it well.
Could someone help me by either telling the magic formula to turn a Ray, or having the right coordinates ?
If I understood your question, the
camera.getDirection(BABYLON.Vector3.Up())
does what you want.
Here:
Thanks @imerso but not really.
If you look at the picture I just uploaded, the Ray must always be perpendicular to the forwardRay.
With your solution, if I move the camera to the up, the yellow ray is not perpendicular
Are you sure? Maybe I’m not understanding your question, but check this update – it is the same thing, but I added a plane for you to see the ray with a plane:
If that is not what you want, then I really did not understand what you want.
1 Like
I see the plane, and its initialization is good !
But, move the camera, do you see the two transparent boxes ?
I want the yellow ray to stay at their centers.
Maybe I just forgot to update every frame?
2 Likes
YES !!!
This is it, getting a relative direction from the first !
Didn’t know about direction.set() and getDirection(localAxis). Definitively need to dive in this…
Thanks @imerso !
2 Likes