vgpu/scene2 symbolsView source ↗

Symbols in this topic

orbit

Builds a column-major model matrix that rotates and translates around the Y axis using explicit JavaScript time. Use it for deterministic examples, tests, and simple scene animation when you do not need a scene graph.

Import

TypeScript
1
import { orbit } from "vgpu/scene";

Signature

TypeScript
1
2
3
4
5
6
7
8
9
interface OrbitOptions {
  readonly radius?: number;
  readonly height?: number;
  readonly speed?: number;
}
 
type Mat4 = Float32Array;
 
declare function orbit(time: number, options?: OrbitOptions): Mat4;

Parameters

ParamTypeRequiredDefaultNotes
timenumberExplicit time value in seconds or any deterministic unit you choose. The helper computes angle = time * speed.
optionsOrbitOptions{}Optional transform controls. Omit it for a unit-radius orbit at Y=0 with speed 1.
options.radiusnumber1XZ orbit radius. Negative values are allowed by JavaScript math and mirror the translation through the origin.
options.heightnumber0Constant Y translation stored in matrix element 13.
options.speednumber1Angular multiplier. 0 freezes rotation; negative values orbit in the opposite direction.

Returns: Mat4 (Float32Array) — 16 column-major matrix values. The upper-left 3×3 rotates around Y; the translation is [cos(angle) * radius, height, sin(angle) * radius]. Throws: None.

Examples

TypeScript
1
2
3
4
import { orbit } from "vgpu/scene";
 
const model = orbit(1.5, { radius: 2, height: 0.5, speed: 0.4 });
console.log(model.length); // 16
TypeScript
1
2
3
4
import { orbit, type Mat4 } from "vgpu/scene";
 
const paused: Mat4 = orbit(10, { speed: 0 });
void paused;

Notes

  • orbit does not read global time. Pass clock(gpu).time from the main API (vgpu) or your own clock explicitly.
  • The matrix is column-major, matching WebGPU/WGSL matrix memory order and the scene camera helpers.
  • See also: Mat4, degToRad, perspectiveCamera.