royibernthal Posted March 25, 2017 Share Posted March 25, 2017 I'm trying to center a 3D object in a scene (for the sake of this question). Calculating stage size simply according to canvas dimensions doesn't work, e.g. if in PG the canvas width is 960, then the x position of the sphere can be between around -10 to 10 meaning the "screen width" I can play with is around 20. I imagine I need to somehow take into account the camera z, and possibly other parameters. Here's a PG where you can see more or less what I'm trying to do: http://www.babylonjs-playground.com/#AURQY By the way I'm not looking for some workaround of setting the camera target to an object or something of the sort, I'd like to really understand how to calculate such a thing. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 26, 2017 Share Posted March 26, 2017 This is going to involve the camera.FOV since the value assigned affects how far away things look at the same position. In another thread I took snapshots of the effects of changing this. Here I was trying to get images of the same size, so I had to move the camera or they would not be. In your research, FOV plays into defining the frustrum. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted March 27, 2017 Author Share Posted March 27, 2017 Thanks, I'll look into it Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 27, 2017 Share Posted March 27, 2017 Hello I think you can use the scene.getWorldExtends() which returns an object with two properties: min and max which are vector3 representing the bounding box of the world royibernthal 1 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted March 27, 2017 Author Share Posted March 27, 2017 Sounds good Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.