Jump to content

Calculating relative stage size


royibernthal
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...