vgpu/scene5 symbolsView source ↗

Symbols in this topic

Camera

Type alias for scene cameras returned by perspectiveCamera() and orthographicCamera(). Use it when storing a camera without caring which helper produced it.

Import

TypeScript
1
import type { Camera } from "vgpu/scene";

Signature

TypeScript
1
type Camera = import("vgpu/scene").SceneCamera;

Parameters

ParamTypeRequiredDefaultNotes
CameraSceneCameraAlias that keeps helper and consumer types in sync.

Returns: Not a callable; this alias ensures perspectiveCamera() and orthographicCamera() share the same contract.

Throws: None.

Examples

TypeScript
1
2
3
4
5
6
7
8
9
import type { Camera } from "vgpu/scene";
import { perspectiveCamera } from "vgpu/scene";
 
const camera: Camera = perspectiveCamera({
  fov: 60,
  aspect: 16 / 9,
  position: [0, 2, 4],
  target: [0, 0, 0],
});

Notes


SceneCamera

Common contract of stateful camera nodes: column-major matrices plus the camera position, exposed as stable Float32Array identities that are updated in place by set() / lookAt().

Import

TypeScript
1
import type { SceneCamera } from "vgpu/scene";

Signature

TypeScript
1
2
3
4
5
6
7
8
interface SceneCamera {
  readonly viewProjection: Float32Array;
  readonly viewProjectionMatrix: Float32Array;
  readonly position: Float32Array;
  readonly view: Float32Array;
  readonly projection: Float32Array;
  readonly worldPosition: Float32Array;
}

Parameters

FieldTypeRequiredDefaultNotes
viewProjectionFloat32ArrayColumn-major projection × view matrix. Bind this to your WGSL uniforms.
viewProjectionMatrixFloat32ArrayAlias of viewProjection, kept for naming continuity.
positionFloat32ArrayLocal position (world position for unparented cameras). Mutate via set().
viewFloat32ArrayInverse of the camera node's world matrix.
projectionFloat32ArrayProjection matrix derived from the camera's parameters.
worldPositionFloat32ArrayWorld position used for specular highlights or parallax.

Returns: Not a callable — the interface describes what camera helpers return.

Throws: None.

Examples

TypeScript
1
2
3
4
5
6
7
8
9
10
import { perspectiveCamera } from "vgpu/scene";
 
const camera = perspectiveCamera({
  fov: 50,
  aspect: 4 / 3,
  position: [2, 2, 4],
  target: [0, 0, 0],
});
 
void camera.viewProjection;

Notes

  • Cameras are scene nodes: update them in place with set() / lookAt() instead of recreating them.
  • viewProjectionMatrix is a duplicate reference so existing consumer code keeps working.
  • See also: Camera, CameraVec3, perspectiveCamera, SceneNode.

CameraVec3

Input-friendly vector type accepted by camera helpers. Accepts tuple literals or typed arrays; helpers always clone into a Float32Array.

Import

TypeScript
1
import type { CameraVec3 } from "vgpu/scene";

Signature

TypeScript
1
type CameraVec3 = readonly [number, number, number] | Float32Array;

Parameters

ParamTypeRequiredDefaultNotes
tuple formreadonly [number, number, number]Pass literal XYZ coordinates without allocations.
typed array formFloat32ArrayUse when positions already live in typed arrays (e.g. math libraries).

Returns: Not a callable — this is the accepted input type for camera helpers.

Throws: None.

Examples

TypeScript
1
2
3
import type { CameraVec3 } from "vgpu/scene";
 
const orbitPos: CameraVec3 = new Float32Array([0, 3, 5]);

Notes


Vec3

Type-only re-export of the Vec3 alias from wgpu-matrix. Used internally by low-level camera helpers.

Import

TypeScript
1
import type { Vec3 } from "vgpu/scene";

Signature

TypeScript
1
type Vec3 = Float32Array;

Parameters

ParamTypeRequiredDefaultNotes
Vec3Float32ArrayColumn vector used by low-level helpers; provided for users wiring math utilities.

Returns: Not a callable.

Throws: None.

Examples

TypeScript
1
2
3
import type { Vec3 } from "vgpu/scene";
 
const up: Vec3 = new Float32Array([0, 1, 0]);

Notes

  • Prefer CameraVec3 when calling public helpers; Vec3 is useful when interoperating with @vgpu/wgsl math utilities.
  • See also: Mat4, CameraVec3.

Mat4

Type-only re-export of the column-major 4×4 matrix type from wgpu-matrix. Helpful when authoring math utilities that feed into scene helpers.

Import

TypeScript
1
import type { Mat4 } from "vgpu/scene";

Signature

TypeScript
1
type Mat4 = Float32Array;

Parameters

ParamTypeRequiredDefaultNotes
Mat4Float32ArrayColumn-major 4×4 matrix used across scene helpers.

Returns: Not a callable.

Throws: None.

Examples

TypeScript
1
2
3
4
5
6
7
8
import type { Mat4 } from "vgpu/scene";
 
const identity: Mat4 = new Float32Array([
  1, 0, 0, 0,
  0, 1, 0, 0,
  0, 0, 1, 0,
  0, 0, 0, 1,
]);

Notes

  • Use these aliases when building custom math helpers so your APIs stay aligned with vgpu’s scene entrypoints.
  • See also: Vec3, SceneCamera.