Class OrbitCamera
The camera transforms the scene modelview directly inside
Scene.sceneRender(PGraphicsOpenGL). Because it operates
in scene space, the same pose works across Standard, domemaster, equirectangular, and skybox
views without changing spherical calibration controls.
Typical usage inside a Scene:
public void sceneRender(PGraphicsOpenGL pg) {
pg.pushMatrix();
services.camera().apply(pg);
// ... draw scene content ...
pg.popMatrix();
}
Rotations use unit quaternions (gimbal-lock free). Programmatic pose changes are smoothly interpolated (SLERP/LERP), while direct mouse manipulation is applied immediately so drag and wheel gestures remain attached to the pointer.
API stability: Advanced Stable.
- Since:
- 2.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an orbit camera with a default distance of 1500 units.OrbitCamera(float initialDistance) Creates an orbit camera looking at the origin from the given distance.OrbitCamera(processing.core.PVector initialTarget, float initialDistance) Creates an orbit camera looking at an initial target from the given distance. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(processing.opengl.PGraphicsOpenGL pg) Applies the camera transform to the given scene graphics.floatReturns the current (interpolated) orbit distance.Returns the current immutable, interpolated orientation quaternion.processing.core.PVectorReturns a copy of the current (interpolated) look-at target.voidgoTo(processing.core.PVector target, Quaternion orientation, float distance) Changes target, orientation, and distance as one smoothly interpolated pose.voidmouseEvent(processing.event.MouseEvent event) Handles mouse input: drag to orbit, wheel to fly in/out.voidreset(float d) Resets the camera to identity orientation, origin target and the given distance.voidClears transient pointer state without changing the camera pose.voidrotateAround(float ax, float ay, float az, float angle) Orbits the camera around a world-space axis (eases smoothly).voidrotateAround(processing.core.PVector axis, float angle) Orbits the camera around a world-space Processing vector (eases smoothly).voidrotateAroundImmediate(float ax, float ay, float az, float angle) Applies an orbit rotation immediately, keeping the interpolation goal synchronized.voidrotateAroundImmediate(processing.core.PVector axis, float angle) Applies an orbit rotation around a Processing vector immediately.voidsetCollapseGuard(float guard) Sets a collapse-guard dead zone around distance 0.voidsetDistance(float d) Sets the goal orbit distance (clamped, eased smoothly).voidsetDistanceImmediate(float distance) Immediately changes only the distance and synchronizes its interpolation goal.voidsetDistanceLimits(float min, float max) Sets the allowed distance range for zoom.voidsetDragSensitivity(float dragSensitivity) Sets drag sensitivity in radians per pixel.voidsetLerpFactor(float lerpFactor) Sets the interpolation amount per frame (0..1).voidSets the goal orientation (eased smoothly).voidsetOrientationImmediate(Quaternion orientation) Immediately changes only the orientation and synchronizes its interpolation goal.voidsetTarget(float x, float y, float z) Sets the goal look-at target (eased smoothly).voidsetTarget(processing.core.PVector target) Sets the goal look-at target from a Processing vector (eased smoothly).voidsetTargetImmediate(processing.core.PVector target) Immediately changes only the look-at target and synchronizes its interpolation goal.voidsetWheelSteps(float wheelStep, float wheelPadStep) Sets the wheel zoom step sizes.voidsnapTo(float tx, float ty, float tz, Quaternion q, float d) Immediately snaps the camera to the given pose with no interpolation.voidsnapTo(processing.core.PVector target, Quaternion orientation, float distance) Immediately snaps the camera to a pose described with a Processing target vector.voidupdate()Advances smooth interpolation toward the current goals by one step.voidzoom(float amount) Changes the goal distance by a signed amount (clamped to limits).voidzoomImmediate(float amount) Changes the current distance immediately and keeps its interpolation goal synchronized.
-
Constructor Details
-
OrbitCamera
public OrbitCamera(float initialDistance) Creates an orbit camera looking at the origin from the given distance.- Parameters:
initialDistance- initial distance from the target
-
OrbitCamera
public OrbitCamera(processing.core.PVector initialTarget, float initialDistance) Creates an orbit camera looking at an initial target from the given distance.- Parameters:
initialTarget- initial look-at target; must not benullinitialDistance- initial distance from the target
-
OrbitCamera
public OrbitCamera()Creates an orbit camera with a default distance of 1500 units.
-
-
Method Details
-
apply
public void apply(processing.opengl.PGraphicsOpenGL pg) Applies the camera transform to the given scene graphics. Call insidesceneRenderbetweenpushMatrix/popMatrix.This method reads camera state but does not advance interpolation.
- Parameters:
pg- non-null scene graphics to transform
-
update
public void update()Advances smooth interpolation toward the current goals by one step.The ziviDomeLive facade calls this exactly once per Processing frame for its shared camera; scenes using
SceneCameraServicemust not call it again. Code that constructs a standalone camera owns its update cadence. -
rotateAround
public void rotateAround(float ax, float ay, float az, float angle) Orbits the camera around a world-space axis (eases smoothly).- Parameters:
ax- axis x componentay- axis y componentaz- axis z componentangle- rotation angle in radians
-
rotateAround
public void rotateAround(processing.core.PVector axis, float angle) Orbits the camera around a world-space Processing vector (eases smoothly).- Parameters:
axis- world-space axis; must not benullangle- rotation angle in radians
-
rotateAroundImmediate
public void rotateAroundImmediate(float ax, float ay, float az, float angle) Applies an orbit rotation immediately, keeping the interpolation goal synchronized.- Parameters:
ax- axis x componentay- axis y componentaz- axis z componentangle- rotation angle in radians
-
rotateAroundImmediate
public void rotateAroundImmediate(processing.core.PVector axis, float angle) Applies an orbit rotation around a Processing vector immediately.- Parameters:
axis- world-space axis; must not benullangle- rotation angle in radians
-
zoom
public void zoom(float amount) Changes the goal distance by a signed amount (clamped to limits).- Parameters:
amount- distance delta (positive flies away, negative flies in)
-
zoomImmediate
public void zoomImmediate(float amount) Changes the current distance immediately and keeps its interpolation goal synchronized. This is intended for direct manipulation such as mouse-wheel navigation.- Parameters:
amount- distance delta (positive flies away, negative flies in)
-
mouseEvent
public void mouseEvent(processing.event.MouseEvent event) Handles mouse input: drag to orbit, wheel to fly in/out.- Parameters:
event- non-null Processing mouse event
-
resetInputState
public void resetInputState()Clears transient pointer state without changing the camera pose. The next drag starts from a fresh anchor instead of reusing stale coordinates. -
setTarget
public void setTarget(float x, float y, float z) Sets the goal look-at target (eased smoothly).- Parameters:
x- target xy- target yz- target z
-
setTarget
public void setTarget(processing.core.PVector target) Sets the goal look-at target from a Processing vector (eased smoothly).- Parameters:
target- desired target; must not benull
-
setDistance
public void setDistance(float d) Sets the goal orbit distance (clamped, eased smoothly).- Parameters:
d- desired distance
-
setOrientation
Sets the goal orientation (eased smoothly).- Parameters:
q- desired orientation quaternion
-
goTo
Changes target, orientation, and distance as one smoothly interpolated pose.- Parameters:
target- desired look-at target; must not benullorientation- desired orientation; must not benulldistance- desired orbit distance
-
snapTo
Immediately snaps the camera to the given pose with no interpolation.- Parameters:
tx- target xty- target ytz- target zq- orientation quaterniond- distance
-
snapTo
Immediately snaps the camera to a pose described with a Processing target vector.- Parameters:
target- look-at target; must not benullorientation- orientation quaternion; must not benulldistance- orbit distance
-
setTargetImmediate
public void setTargetImmediate(processing.core.PVector target) Immediately changes only the look-at target and synchronizes its interpolation goal.- Parameters:
target- desired target; must not benull
-
setOrientationImmediate
Immediately changes only the orientation and synchronizes its interpolation goal.- Parameters:
orientation- desired orientation; must not benull
-
setDistanceImmediate
public void setDistanceImmediate(float distance) Immediately changes only the distance and synchronizes its interpolation goal.- Parameters:
distance- desired orbit distance
-
reset
public void reset(float d) Resets the camera to identity orientation, origin target and the given distance.- Parameters:
d- distance to reset to
-
setDistanceLimits
public void setDistanceLimits(float min, float max) Sets the allowed distance range for zoom.- Parameters:
min- minimum distance; callers should supply a finite value no greater than maxmax- maximum distance; callers should supply a finite value no less than min
-
setCollapseGuard
public void setCollapseGuard(float guard) Sets a collapse-guard dead zone around distance 0. When positive, the orbit distance can never enter(-guard, +guard)nor flip sign through zero, which prevents the view from collapsing when the allowed distance range spans both negative and positive values. Set to 0 to disable.- Parameters:
guard- half-width of the forbidden zone around zero (>= 0)
-
setLerpFactor
public void setLerpFactor(float lerpFactor) Sets the interpolation amount per frame (0..1). Higher is snappier.- Parameters:
lerpFactor- easing factor
-
setDragSensitivity
public void setDragSensitivity(float dragSensitivity) Sets drag sensitivity in radians per pixel.- Parameters:
dragSensitivity- finite sensitivity value
-
setWheelSteps
public void setWheelSteps(float wheelStep, float wheelPadStep) Sets the wheel zoom step sizes.- Parameters:
wheelStep- finite distance change per standard notchwheelPadStep- finite distance change per fractional (trackpad) notch
-
getDistance
public float getDistance()Returns the current (interpolated) orbit distance.- Returns:
- current distance
-
getTarget
public processing.core.PVector getTarget()Returns a copy of the current (interpolated) look-at target.- Returns:
- current target as a new PVector
-
getOrientation
Returns the current immutable, interpolated orientation quaternion.- Returns:
- current orientation
-