4

I need to boot the entire model got completely into the viewport. enter image description here Because if the model has a large size, it does not got completely into the viewport, for example:

enter image description here

To solve this problem I need set the desired camera position:

camera.setPosition( new BABYLON.Vector3(216, 93, -17) );

for example: test page

How do I automatically calculate the coordinates of the camera in which the model will got completely into the viewport?

alex10
  • 2,726
  • 3
  • 22
  • 35
  • Possible duplicate of [Move camera to fit 3D scene](http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene) – A.J.Bauer Aug 15 '16 at 15:05

1 Answers1

2

You can set:

camera.parent = yourMesh;

Then you can change: camera.position like you want

But note that: the camera is parent so the position is relative to his parent!

So you can't simply use your vector: (216, 93, -17)

Ouroborus
  • 16,237
  • 4
  • 39
  • 62
TheLizard
  • 36
  • 3