Orbit

← prev index next →

Defines a spherical orbit around a pivot — a movable ring that other nodes can be made to revolve along.

Remarks

This is a SceneNode (a VisualizableSceneNode), not a constraint. Its job is to hold orbit parameters: its world position is the pivot, and its radius/azimuth/elevation describe a position on a sphere around that pivot. It does NOT move anything by itself — a separate sk-orbit-constraint reads this node and drives the constrained node's position (and orientation). This is the same split as SpatialField + sk-field-constraint: one node carries the data, another applies the effect.

Why a node. Because the pivot is a real scene node, you get animation for free (keyframe azimuth and the orbit position sweeps around, carrying whatever an sk-orbit-constraint binds to it), composition for free (parent it under a moving platform for an inherited pivot), and an optional on-canvas visualization.

Key attributes. radius is the pivot-to-orbit distance. azimuth is the angle around the +Y (up) axis, measured from +Z, positive turning toward +X. elevation is the angle above the XZ plane (positive toward +Y). All three are animatable. orient-toward-pivot also faces the riding node's orientation-axis back at the pivot. visualize draws the orbit ring and interactive markers.

Constructor

constructor(config?: { radius?: number; azimuth?: number; elevation?: number; minRadius?: number; orientTowardPivot?: boolean; orientationAxis?: AxisOrientation; visualize?: boolean; interactiveControls?: boolean; visualizationMarkerSize?: number; visualizationColor?: string; visualizationZeroWeightColor?: string; visualizationSplineThickness?: number; visualizationSplineOccludedOpacity?: number; visualizationMarkerOpacity?: number; id?: string; x?: number; y?: number; z?: number; h?: number; p?: number; b?: number; quaternion?: Quaternion; sx?: number; sy?: number; sz?: number; s?: number; class?: string; style?: string })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
radiusanimatable number 10 Orbit radius — distance from the pivot. Orbit
azimuthanimatable number 0 Azimuth angle (radians) around the pivot’s vertical axis. Orbit
elevationanimatable number 0 Elevation angle (radians) above the pivot’s horizontal plane. Orbit
minRadius number 0.1 Minimum orbit radius the controller will zoom to. Orbit
orientTowardPivot boolean false When true, the orbiting node faces the pivot. Orbit
orientationAxis AxisOrientation "-z" Which local axis points toward the pivot when orienting. Orbit
visualize boolean false Whether the visualization is visible (wireframe splines + center marker). VisualizableSceneNode
interactiveControlsconfig-only boolean Whether to show interactive controls (draggable markers). Requires visualize. Default: false VisualizableSceneNodeConfig
visualizationMarkerSizeconfig-only number Size of visualization markers in pixels. Default: 20 VisualizableSceneNodeConfig
visualizationColorconfig-only string Color for visualization geometry and markers (CSS color string). Default: VISUALIZATION_HIGHLIGHT_COLOR ('#FF8C00'). VisualizableSceneNodeConfig
visualizationZeroWeightColorconfig-only string Color for zero-weight boundary geometry (outer radius, origin plane, etc.). Default: VISUALIZATION_ZERO_WEIGHT_COLOR ('#888888'). VisualizableSceneNodeConfig
visualizationSplineThicknessconfig-only number Spline stroke thickness in pixels. Default varies by subclass. VisualizableSceneNodeConfig
visualizationSplineOccludedOpacityconfig-only number Opacity of visualization splines when occluded. Default: 0.5 VisualizableSceneNodeConfig
visualizationMarkerOpacityconfig-only number Opacity of visualization markers. Default: 0.9 VisualizableSceneNodeConfig
idconfig-only string Unique identifier for the node, reflected to the host id attribute. SceneNodeConfig
xanimatable number 0 Gets the X position component. SceneNode
yanimatable number 0 Gets the Y position component. SceneNode
zanimatable number 0 Gets the Z position component. SceneNode
hanimatable number 0 Gets the heading (Y-axis) rotation in radians. SceneNode
panimatable number 0 Gets the pitch (X-axis) rotation in radians. SceneNode
banimatable number 0 Gets the bank (Z-axis) rotation in radians. SceneNode
quaternionanimatable Quaternion Gets the rotation as a quaternion. SceneNode
sxanimatable number 1 Gets the X-axis scale factor. SceneNode
syanimatable number 1 Gets the Y-axis scale factor. SceneNode
szanimatable number 1 Gets the Z-axis scale factor. SceneNode
sconfig-only number Uniform scale factor for all axes (overrides sx, sy, sz if provided) SceneNodeConfig
classconfig-only string Standard HTML class applied to the node host at construction SceneNodeConfig
styleconfig-only string Standard inline style applied to the node host at construction SceneNodeConfig

Other Properties

PropertyTypeDefaultDescriptionDeclared by
radiusBasebase value number The base (non-animated) value of radius. Orbit
azimuthBasebase value number The base (non-animated) value of azimuth. Orbit
elevationBasebase value number The base (non-animated) value of elevation. Orbit
hRad number 0 Gets the heading (Y-axis) rotation in radians. SceneNode
pRad number 0 Gets the pitch (X-axis) rotation in radians. SceneNode
bRad number 0 Gets the bank (Z-axis) rotation in radians. SceneNode
hDeg number 0 Gets the heading (Y-axis) rotation in degrees. SceneNode
pDeg number 0 Gets the pitch (X-axis) rotation in degrees. SceneNode
bDeg number 0 Gets the bank (Z-axis) rotation in degrees. SceneNode
xBasebase value number Gets the base (non-animated) value of X position. SceneNode
yBasebase value number Gets the base (non-animated) value of Y position. SceneNode
zBasebase value number Gets the base (non-animated) value of Z position. SceneNode
hBasebase value number 0 Gets the base (non-animated) value of heading (Y-axis rotation). SceneNode
pBasebase value number 0 Gets the base (non-animated) value of pitch (X-axis rotation). SceneNode
bBasebase value number 0 Gets the base (non-animated) value of bank (Z-axis rotation). SceneNode
quaternionBasebase value Quaternion Gets the base (non-animated) quaternion rotation. SceneNode
sxBasebase value number Gets the base (non-animated) value of X-axis scale. SceneNode
syBasebase value number Gets the base (non-animated) value of Y-axis scale. SceneNode
szBasebase value number Gets the base (non-animated) value of Z-axis scale. SceneNode
draggable boolean false Gets whether this node can be dragged. SceneNode
parentread-only SceneNode | null The parent node in the scene graph, or null at the root. SceneNode
sceneread-only any Gets the Scene this node belongs to, if any. SceneNode
posread-only Point3D Gets the world-space position of this node. SceneNode
matrixread-only Float32Array<ArrayBufferLike> Gets the computed 4x4 transformation matrix. SceneNode
animationsread-only SkenraAnimation[] Public getter for the animations affecting this target. SkenraAnimatable

Methods

MethodDescriptionDeclared by
addMaterialPaint(material: Material, paintTarget: PaintTarget, options?: any): Paint Applies a material to this node for a specific paint target. SceneNode
getPaints(): ReadonlyMap<PaintTarget, Paint> SceneNode
getOwnPaints(): readonly Paint[] Gets only the paints directly applied to this node (not inherited). SceneNode
removePaint(paint: Paint): void Removes a paint from this node. SceneNode
getWorldPosition(): number[] Returns this node’s origin in world space. SceneNode
getWorldMatrix(): Float32Array<ArrayBufferLike> Returns this node’s world transform — its local transform composed with all ancestor transforms. SceneNode
setViewportPosition(camera: AbstractCamera, x: number, y: number, z: number = 0.5): boolean Sets the node's local translation so that it appears at the specified viewport position. SceneNode
getViewportPosition(camera?: AbstractCamera): [number, number, number] | null Returns the node's current world position projected to viewport CSS pixel coordinates. SceneNode
setNDCPosition(camera: AbstractCamera, ndcX: number, ndcY: number, ndcZ: number = 0.5): boolean Sets the node's local translation so that it appears at the specified NDC position in the viewport. SceneNode
getBoundsInSpace(targetSpaceMatrix: Float32Array): { minX: number; maxX: number; minY: number; maxY: number; minZ: number; maxZ: number; } | null Computes the axis-aligned bounding box (AABB) of this node and its descendants SceneNode
animate(firstArg: TypedKeyframe<this>[] | TypedPropertyIndexedKeyframes<this> | Record<string, any> | globalThis.Keyframe[] | globalThis.PropertyIndexedKeyframes | null, secondArg?: number | KeyframeAnimationOptions | globalThis.KeyframeAnimationOptions): SkenraAnimation & Animation Creates a new SkenraAnimation for this target per Web Animations API. SkenraAnimatable
removeAnimation(animation: SkenraAnimation): boolean Removes a specific animation from this object. SkenraAnimatable
constrain(type: K, config: ConstraintConfigMap[K]): ConstraintReturnMap[K] Creates a constraint on this Animatable using a fluent API. SkenraAnimatable

Example

// Create an orbit node (defines the orbit)
const orbitNode = new Orbit({ id: 'camera-orbit',
    radius: 15,
    azimuth: Math.PI / 4,
    elevation: Math.PI / 6,
    orientTowardPivot: true,
    orientationAxis: '-z',
    visualize: true,
});
scene.appendChild(orbitNode);

// Constrain camera to follow the orbit
camera.constrain('orbit', { source: orbitNode });

// Animate the orbit
orbitNode.animate([
    { offset: 0, azimuth: 0 },
    { offset: 1, azimuth: Math.PI * 2 },
], { duration: 10000, iterations: Infinity, id: 'spin' });