Fitting Things in View

You can fly or jump a xeometry viewer's camera to fit specified models, objects, types or boundaries in view.

Examples

Configuring the camera to fly for two seconds as it moves to each new target:

viewer.setViewFitDuration(2); // Seconds

When the duration greater than zero, the camera will fly, otherwise it will jump straight to each new target.

Flying camera to a given position:

// Eye, look and "up" vector
viewer.setEyeLookUp([0,0,-100],[0,0,0],[0,1,0], function() {
    // Camera arrived
});

Flying the camera to fit everything in view:

viewer.viewFit(function() {
    // Camera arrived
});

Fly the camera to fit a boundary in view (see Querying Boundaries):

viewer.viewFit([-50,-25,-50, 50, 25, 50], function() {
    // Camera arrived
});

A boundary is an axis-aligned bounding box (AABB) in World-space, given as an array of
values [xmin, ymin, zmin, xmax, ymax, zmax].

Flying the camera to fit a model in view:

viewer.viewFit("saw", function() {
    // Camera arrived
});

Flying the camera to fit two models in view:

viewer.viewFit(["saw", "gearbox"], function() {
    // Camera arrived
});

Flying the camera to fit all objects of the given types (see Assigning types to objects):

viewer.viewFit(["IfcFlowController", "IfcFlowFitting"], function() {
    // Camera arrived
});

Flying the camera to fit a model, two objects, and all objects of the given type:

viewer.viewFit(["gearbox", "saw#1", "saw#5", "IfcFlowFitting"], function() {
    // Camera arrived
});

Flying the camera to fit all objects of the given types, looking along the World-space -X axis:

viewer.viewFitLeft(["IfcFlowController", "IfcFlowFitting"], function() {
    // Camera arrived
});

Flying the camera to fit a model, two objects, and all objects of the given type, looking along the World-space -Y axis:

viewer.viewFitTop(["gearbox", "saw#1", "saw#5", "IfcFlowFitting"], function() {
    // Camera arrived
});

Configuring the camera to jump directly to each new position:

viewer.setViewFitDuration(0);

Jumping the camera to a given position:

viewer.setEyeLookUp([-100,0,0],[0,0,0],[0,1,0]);

Jumping the camera to fit two objects in view - note we don't need the callback anymore because camera is now jumping:

viewer.viewFit(["saw34", "saw5"]);

Jumping the camera to fit a model and two objects in view:

viewer.viewFit(["gearbox", "saw#2", "saw#5"]);

Setting how much of the field of view that a target boundary will occupy when flying the camera to fit models or objects to the view:

viewer.setViewFitFOV(20); // Degrees
var fitFOV = viewer.fitFOV();

results matching ""

    No results matching ""