BabylonJS + its documentation + forum + team + playground is really amazing and great.
I am a newbie, but It took me really lots of efforts to setup a “simple” scene coming from a gltf import.
My question is :
Is there any way to use a simple feature like camera.fitAll();
Usually many samples are explaining:
scene.target = mesh;
But what if user has collection of meshes
For example the way I took is not that easy (2 days) to have https://playground.babylonjs.com/#U5SSCN#185 with a correct camera + light position by computing scene bbox and reacting in a “classic” way with mouse without inertia and stuff going out of my mouse or turning in a weird manner by default
Hopefully the library is so versatile that anything is possible. But its also very rich so finding how to tweak is not that easy for beginners
To conclude, that means the kind of sample (cleaned) would be very great to find for a beginner
Thank you. Yes it is much closer to what I’m looking for.
So fitAll() features exists somewhere inside BabylonJS viewer ?
And in your sample the framingBehavior seems to work.
It does not in my playground https://playground.babylonjs.com/#U5SSCN#187
Ok, to do what you are suggesting, I would also need to compute scene bbox and change the origin of model. Which is like setting camera (lookAt, lookFrom) from bbow. When you have scene bbox from meshes. That means fitAll() must be implemented by user.
I am sorry, I see no reason why an object should “stay” static when camera panning is done
Normally pannig is like a travelling operation in movies with a camera
So all objects should visually move, indeed the camera frustrum does
I hope panning does not affect the model position and it does a translation of model instead of moving camera frustrum
Did I miss a concept I’m not used too ?
Your sphere does not move because you set its position to lookAt (sphere.position = lookAt), which is also the target of the camera (camera.target = lookAt). So, sphere position and camera target are always the same, so the sphere does not move on screen. Set the position of the sphere to lookAt.clone() instead.
You also have a bug here var material = new BABYLON.StandardMaterial(scene); where you should pass the name of the material before scene: it makes the inspector crash when selecting the center mesh.