AbstractOptionalflyToOptions: FlyToOptionsAbstractaspectAbstractfarAbstractlookAbstractnearAbstractpositionAbstractupAbstractviewAligns the camera to the plane defined by the provided position and normal. This will place the camera at the provided position, set the up vector to the provided normal, and place the lookAt on the defined plane. The point chosen for the lookAt will be determined using the current view vector.
const viewer = document.querySelector("vertex-viewer");
viewer.addEventListener("tap", async (event) => {
const scene = await viewer.scene();
const raycaster = scene.raycaster();
const [hit] = await raycaster.hitItems(event.detail.position);
if (hit != null) {
const camera = scene.camera();
// Align to the plane represented by the hit result with an animation of 1 second
await camera
.alignTo(hit.hitPoint, hit.hitNormal)
.render({ animation: { milliseconds: 1000 } });
}
});
Updates the position of the camera such that the given bounding box will be contained within the camera's view.
The bounding box to position to.
Specifies that the next render of the camera will be repositioned to one of
the options specified in options.
An object or query describing how the camera should be positioned.
const viewer = document.querySelector("vertex-viewer");
const scene = await viewer.scene();
const camera = scene.camera();
// Fly to and fit to a specific item by ID with an animation of 1 second
await camera
.flyTo({ itemId: "item-id" })
.render({ animation: { milliseconds: 1000 } });
// Fly to and fit to a specific item by supplied ID with an animation of 1 second
await camera
.flyTo({ itemSuppliedId: "item-supplied-id" })
.render({ animation: { milliseconds: 1000 } });
// Fly to and fit to the bounding box of the current set of selected items
// with an animation of 1 second
await camera
.flyTo({
boundingBox:
viewer.frame.scene.sceneViewSummary.selectedVisibleSummary.boundingBox,
})
.render({ animation: { milliseconds: 1000 } });
// Fly to a specific camera
await camera
.flyTo({
camera: {
position: {
x: 1,
y: 2,
z: 3,
},
lookAt: {
x: 0,
y: 0,
z: 0,
},
up: {
x: 0,
y: 1,
z: 0,
},
},
})
.render({ animation: { milliseconds: 1000 } });
// Fly to scene items specified by a query
await camera
.flyTo({
sceneItemQueryExpression: {
operand: {
metadata: {
valueFilter: 'WheelHub',
keys: ['ProductName'],
},
},
},
})
AbstractmoveQueues the rendering for a new frame using this camera. The returned promise will resolve when a frame is received that contains this camera. Certain render loops, like dragging and zooming, can safely assume the updated camera is valid and skip revalidating it. For safety and backwards compatibility, validation remains enabled by default.
Repositions the camera by rotating its current position around an axis placed
at the lookAt point. This method internally will call Camera.rotateAroundAxisAtPoint
with the point parameter set to the current lookAt point.
Camera.rotateAroundAxisAtPoint for more information.
AbstractrotateRepositions the camera by rotating its current position around an axis defined at a specific world point.
const viewer = document.querySelector('vertex-viewer');
viewer.addEventListener('tap', async (event) => {
const scene = await viewer.scene();
const raycaster = scene.raycaster();
const [hit] = await raycaster.hitItems(event.detail.position);
if (hit != null) {
const camera = scene.camera();
// Using the current `up` vector of the camera, rotate 45 degrees
// about the hit position with an animation of 1 second
await camera.rotateAroundAxisAtPoint(
Angle.toRadians(45),
hit.hitPoint,
camera.up,
).render({ animation: { milliseconds: 1000 } });
}
});
Returns the distance from the camera's position to the center of the provided bounding box (or the scene's visible bounding box if not provided).
OptionalboundingBox: BoundingBox
The bounding box to determine distance from.
Updates the position and up vectors of the camera to the given standard
view, and sets the lookAt point to the origin.
The standard view to apply.
A new camera.
StandardView for the available standard views.
Updates the position and up vectors of the camera to the given standard
view, maintaining the existing lookAt point.
The standard view to apply.
A new camera.
StandardView for the available standard views.
AbstracttoReturns a FrameCameraBase representation.
AbstractupdateUpdates the position, lookAt and/or up vectors of the camera. Each
vector can be omitted in the payload, and the resulting camera will keep
the previous position, lookAt, or up vectors.
The values to update the camera to.
const viewer = document.querySelector("vertex-viewer");
const scene = await viewer.scene();
const camera = scene.camera();
// Update the camera to place it at the origin
await camera
.update({
position: {
x: 0,
y: 0,
z: 0,
},
})
.render({ animation: { milliseconds: 1000 } });
// Update the camera to look at the origin
await camera
.update({
lookAt: {
x: 0,
y: 0,
z: 0,
},
})
.render({ animation: { milliseconds: 1000 } });
Performs a flyTo operation with the current visible bounding box of
the scene.
The
Cameraclass contains properties that reflect a world space position, a view direction (lookAt), and normalized vector representing the up direction.It also provides utility methods to update orientation of the camera and rerender the scene.
This class in intended to be treated as an immutable type. Any mutations return a new instance of the class with the updated properties.