OrbitControls
Camera controls for orbiting a perspective camera around a target.
Dragging with the left mouse button orbits, dragging with Shift held or with the middle button pans the target, and the scroll wheel zooms by changing the orbit radius. Input adds velocity that damping decays over time.
const camera = new PerspectiveCamera({ near: 1.0 });
const idetik = new Idetik({
canvas,
viewports: [{
camera,
layers: [volumeLayer],
cameraControls: new OrbitControls(camera, {
radius: 100,
target: [40, 40, 10],
}),
}],
});Implements CameraControls.
Constructor
Creates orbit controls and moves the camera to the initial pose.
new OrbitControls(camera, params?): OrbitControls;| Parameter | Description |
|---|---|
camera: PerspectiveCamera | The perspective camera to control. |
params?: OrbitControlsProps | Initialization properties. |
Types
OrbitControlsProps
Initialization properties for constructing orbit controls.
Accessors
radius number
The current distance from the target in world units.
get radius(): number;yaw number
The current azimuth angle in radians.
get yaw(): number;pitch number
The current elevation angle in radians.
get pitch(): number;target vec3
A copy of the point the camera orbits.
get target(): vec3;isMoving boolean
Whether any orbit, pan, or zoom velocity remains.
get isMoving(): boolean;Methods
onEvent() void
Handles a pointer or wheel event. Called automatically by the owning viewport unless a layer stops propagation.
onEvent(event): void;| Parameter | Description |
|---|---|
event: EventContext | The event with clip and world coordinates attached. |
onUpdate() void
Applies pending velocities to the camera and decays them toward zero. Called automatically by the render loop once per frame.
onUpdate(dt): void;| Parameter | Description |
|---|---|
dt: number | Time since the last frame in seconds. |