copper3d / Modules / Controls/cameraTransitions
Module: Controls/cameraTransitions
Table of contents
Interfaces
Functions
- easeInOutCubic
- interpolateFlightPose
- orbitStepPose
- orbitSwingAngle
- poseDistance
- rotateAroundAxis
- viewPointToPose
- zoomPose
Functions
easeInOutCubic
▸ easeInOutCubic(t): number
Parameters
| Name | Type |
|---|---|
t | number |
Returns
number
Defined in
src/Controls/cameraTransitions.ts:26
interpolateFlightPose
▸ interpolateFlightPose(from, to, t): Pose
Interpolates a camera between two poses. t is expected already eased -- this has no timing concerns of its own, which is what makes it testable without a clock.
The pivot lerps from one target to the other, and the camera's ORIENTATION (both its direction from the pivot and its up vector) is carried by a single rotation built from the two poses' full orthonormal bases -- not by interpolating dir and up independently.
That is a correctness requirement, not a style choice. Real preset data routinely contains antipodal up vectors on the same view axis (two views of the same volume authored from opposite conventions). A plain lerp(upFrom, upTo, t) passes through the zero vector at t=0.5, where normalize has no correct answer: the camera holds upside-down, then snaps 180 degrees in one frame. Composing the two bases into a relative rotation makes that case a well-defined 180-degree roll about the shared axis -- a smooth roll through the midpoint. The same construction covers two antipodal camera positions about one target.
Reproduces from.position exactly at t=0 and to.position at t=1. up is likewise exact WHEN each pose's own up is already perpendicular to its own view direction; one that leans toward the view axis is silently squared up, which is by design -- it is not a meaningful camera roll.
Parameters
| Name | Type |
|---|---|
from | Pose |
to | Pose |
t | number |
Returns
Defined in
src/Controls/cameraTransitions.ts:264
orbitStepPose
▸ orbitStepPose(pose, yawRad, pitchRad): Pose
Orbits the camera around its own pivot by yawRad about its up vector, then by pitchRad about the RESULTING right vector. The pivot and the orbit radius are both untouched, so a run of steps can never walk the camera away from what it is looking at.
Pitch about the yawed right vector, not the original: rotating about a stale axis makes a diagonal (left+up) combination drift off the sphere instead of tracing it.
Parameters
| Name | Type |
|---|---|
pose | Pose |
yawRad | number |
pitchRad | number |
Returns
Defined in
src/Controls/cameraTransitions.ts:304
orbitSwingAngle
▸ orbitSwingAngle(t, turns): number
Swing angle for an entrance orbit. turns is a SWING AMPLITUDE, not a net rotation: sin(t*pi) goes out and comes back to zero, so the camera always ends exactly on the framed preset view (t=1 -> angle 0) however large turns is. Do not "fix" this into a net rotation; that ends the intro off-preset.
Parameters
| Name | Type |
|---|---|
t | number |
turns | number |
Returns
number
Defined in
src/Controls/cameraTransitions.ts:343
poseDistance
▸ poseDistance(pose): number
The camera's orbit radius: how far pose.position sits from the pivot it looks at. Lets a push-in be expressed as an absolute target distance (idempotent) rather than a repeated fractional step.
Parameters
| Name | Type |
|---|---|
pose | Pose |
Returns
number
Defined in
src/Controls/cameraTransitions.ts:290
rotateAroundAxis
▸ rotateAroundAxis(v, axis, angleRad): Vec3Tuple
Rodrigues' rotation formula: rotates v by angleRad around axis (which need not be pre-normalized). Unlike slerping between two vectors, this has no degeneracy at any angle including a half turn -- the axis is given, not derived from a dot product between vectors that might be antiparallel.
Parameters
| Name | Type |
|---|---|
v | Vec3Tuple |
axis | Vec3Tuple |
angleRad | number |
Returns
Vec3Tuple
Defined in
src/Controls/cameraTransitions.ts:105
viewPointToPose
▸ viewPointToPose(vp): Pose
Reads a view preset as a Pose, so a flight's destination is built from the same data an instant loadView would apply.
Parameters
| Name | Type |
|---|---|
vp | CameraViewPreset |
Returns
Defined in
src/Controls/cameraTransitions.ts:33
zoomPose
▸ zoomPose(pose, factor, minDistance?): Pose
Scales the camera's distance from its pivot by factor along the unchanged view direction. Clamped at minDistance because a zero radius has no direction to normalize -- a held zoom-in key would otherwise collapse the pose into NaN one frame after reaching the pivot.
Parameters
| Name | Type | Default value |
|---|---|---|
pose | Pose | undefined |
factor | number | undefined |
minDistance | number | 1e-3 |