Camera Framing Behvior

I’m trying to do some experimentation with framing behavior and even though I think I have duplicated the settings that sandbox uses, it doesn’t seem to be setting the initial radius and min radius values. Can anyone what see what I am missing? Also does anyone have any idea why the mouse wheel zooming is much smoother in sandbox then my PG even though the speed and wheel precision settings are identical?

Your PG seems ok to me, it is behaving like in the sandbox…

Just to be sure, here’s the PG with the exact same values than in the sandbox:

Sandbox has a min zoom value that the PG doesn’t have. Also the starting radius is not updated by framing behavior. if I set it to .05 in your PG, that is the value it uses. From what I can tell, based on the code in RenderingZone, sandbox uses framing behavior to set starting zoom, min zoom, and I think minz/maxz based on the models have been loaded.

There are several things:

  • the default environment get in the way when computing the minZ/maxZ and the world extends => I have removed it
  • you should create the camera after the meshes are loaded so that the camera is setup with sensible values
  • useFramingBehavior = true should be done when the scene has finished loading, else the camera will be attached to this behaviour later and the zoomOnBoundingInfo(...) call will do nothing

Awesome, thanks. This is exactly what I was looking for.

Is it safe to say that framing behavior should not be used when there is a skybox/ground plane as it will throw off bounds calculation? Is there away to use framing behavior with skybox/ground plane or even a scene with props? I.e. is there some way to exclude certain meshes from the bounds calc in the framing behavior?

It’s not the framing behaviour the problem, it is this code:

        var worldExtends = scene.getWorldExtends(function (mesh) {
            return mesh.isVisible && mesh.isEnabled();

You should change the predicate to exclude meshes that should not be taken into account in the world extends computation.

My bad. I forgot that the bounds determination was done outside the framing behavior. Is it better to determine world extents excluding meshes that we don’t want factored in, or use zoomOnMeshesHierarchy and specify the meshes we want to include?

I would say it’s up to you, it depends on if it’s easier for you to provide a predicate or directly a list of meshes.