vgpu/scene4 symbolsView source ↗

Symbols in this topic

orthographicCamera

Creates a stateful orthographic camera node that maps a box in world space directly into clip space. Use it for UI, CAD, or any scene where perspective foreshortening is undesirable.

Import

TypeScript
1
import { orthographicCamera, type OrthographicCameraOptions } from "vgpu/scene";

Signature

TypeScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
interface OrthographicCameraOptions {
  readonly left: number;
  readonly right: number;
  readonly bottom: number;
  readonly top: number;
  readonly near?: number;
  readonly far?: number;
  readonly position?: import("vgpu/scene").Vec3Like;
  readonly target?: import("vgpu/scene").CameraVec3;
  readonly up?: import("vgpu/scene").CameraVec3;
  readonly label?: string;
}
 
declare function orthographicCamera(options: OrthographicCameraOptions): import("vgpu/scene").OrthographicCamera;

Parameters

ParamTypeRequiredDefaultNotes
options.leftnumberLeft plane of the world-space box.
options.rightnumberRight plane. Must be greater than left.
options.bottomnumberBottom plane.
options.topnumberTop plane. Must be greater than bottom.
options.nearnumber0.1Near clip plane distance. Must be positive.
options.farnumber100Far clip plane distance. Must be greater than near.
options.positionVec3Like[0, 0, 0]Initial local position.
options.targetCameraVec3When given, the camera is oriented with lookAt(target, up).
options.upCameraVec3[0, 1, 0]Up vector used only with target.

Returns: OrthographicCamera — a scene node (kind: "orthographic-camera") with viewProjection, view, projection, position, and worldPosition. Throws: VGPU-SCENE-VALUE-INVALID for non-positive near or far <= near. Avoid left === right and bottom === top; they produce unusable matrices rather than a validation error.

Examples

TypeScript
1
2
3
4
5
6
7
8
9
10
11
12
import { orthographicCamera } from "vgpu/scene";
 
const cam = orthographicCamera({
  left: -2,
  right: 2,
  bottom: -2,
  top: 2,
  position: [0, 0, 5],
  target: [0, 0, 0],
});
 
cam.set({ left: -4, right: 4 }); // updates the projection in place

Notes

  • Orthographic cameras still use a real view matrix; set({ position }) and lookAt() orbit the box without perspective.
  • On canvas resize, call set({ left, right }) (or top/bottom) to keep pixel-perfect scaling.
  • See also: OrthographicCamera, perspectiveCamera, Camera, orbitControls.

OrthographicCamera

Class returned by orthographicCamera(). Extends SceneNode, implements SceneCamera.

Import

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

Signature

TypeScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
declare class OrthographicCamera {
  set(values: import("vgpu/scene").OrthographicCameraValues): this;
  lookAt(target: import("vgpu/scene").Vec3Like, up?: import("vgpu/scene").Vec3Like): this;
  readonly left: number;
  readonly right: number;
  readonly bottom: number;
  readonly top: number;
  readonly near: number;
  readonly far: number;
  readonly viewProjection: Float32Array;
  readonly view: Float32Array;
  readonly projection: Float32Array;
  readonly worldPosition: Float32Array;
}

Returns: Not a callable; construct with orthographicCamera(options). Throws: VGPU-SCENE-VALUE-INVALID from set() on invalid near/far planes.

Examples

TypeScript
1
2
3
4
import { orthographicCamera, type OrthographicCamera } from "vgpu/scene";
 
const cam: OrthographicCamera = orthographicCamera({ left: -1, right: 1, bottom: -1, top: 1 });
void cam.projection;

Notes


OrthographicCameraValues

Values accepted by OrthographicCamera.set(): projection planes plus node transform keys.

Import

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

Signature

TypeScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
interface OrthographicCameraValues {
  readonly left?: number;
  readonly right?: number;
  readonly bottom?: number;
  readonly top?: number;
  readonly near?: number;
  readonly far?: number;
  readonly position?: import("vgpu/scene").Vec3Like;
  readonly rotation?: import("vgpu/scene").Vec3Like;
  readonly quaternion?: import("vgpu/scene").QuatLike;
  readonly scale?: number | import("vgpu/scene").Vec3Like;
  readonly visible?: boolean;
  readonly label?: string;
}

Examples

TypeScript
1
2
3
import { orthographicCamera } from "vgpu/scene";
 
orthographicCamera({ left: -1, right: 1, bottom: -1, top: 1 }).set({ near: 0.01 });

Notes