I’m currently using (and I’m new here) this library to create 3d objects, but unfortunately I cannot fit the object inside the canvas. It’s always overflowing outside the canvas if the object is a bit long.
Stackoverflow link
hofk
May 20, 2021, 7:29am
2
Change the camera position, e.g.
camera.position.z = 1.2 * boxWidth;
Try
camera.lookAt( , , );
1 Like
@hofk I tried, but I got the same result. Please see my update above.
Here are some functions to fit objects within a view using a few lines of trigonometry math:
In case it helps anyone, here’s how to fit an object (most likely a flat plane) on the screen so that it “fits” depending on aspect ratio. For example, if we have an object taller than it is wide we want the Y dimension (the tall dimension) to fit within the view, but if the object is wider than it is tall we want the X dimension (the width dimension) to fit within view.
The following distanceToFitObjectToView function will tell you at what distance to place the object so that it fits within vi…