I can add spheres on a plane using the Unproject function and scaling it, like I do in
Now I want to do the same for a camera but in orthografic mode, but I cannot figure out what scaling I need to do.
I can add spheres on a plane using the Unproject function and scaling it, like I do in
Now I want to do the same for a camera but in orthografic mode, but I cannot figure out what scaling I need to do.
Hello! Welcome to BJS!
You don’t need to unproject:
ORTHO:
You have to set isPickable
to true
if you want to use pickInfo
. Default for meshes created using builder functions is true
.
Yes thanks, that could perhaps be a solution. I cannot add outside of the ground plane however. But I guess I can create an invisible mesh that covers the view.
Found something like that in
I think I might use this solution for the actual application and I appreciate your answer and time to make it very much. But I don´t think I will mark it as solved for now, because now I also have the academic curiosity on how to do it with calculations
Yes, that’s the way I would choose. You have to add the spheres to something. If there is nothing to hit how could you determine the distance where to add the sphere?
No problem.
I wish everyone would think like that!
This uses the BabylonJS GUI. This is totally off…
This little debug helper might help you to see the values in realtime:
I found a solution that worked. My problem was with the engine size for some reason i needed the width/height from the canvas getRenderingCanvasClientRect to get the correct width / height
const mousePoint = BABYLON.Vector3.Unproject(
new BABYLON.Vector3(
scene.pointerX,
scene.pointerY,
0.5),
engine.getRenderingCanvasClientRect().width,
engine.getRenderingCanvasClientRect().height,
BABYLON.Matrix.Identity(),
scene.getViewMatrix(),
scene.getProjectionMatrix()
);