Skip to content

Types

Located in src/lib/ts/types/Interfaces.ts. Two interfaces, both simple.

Projected

What you get after the projection pipeline spits out a vertex.

ts
interface Projected {
  x: number;  // screen X
  y: number;  // screen Y
  z: number;  // depth (NDC)
  w: number;  // clip space W (for culling)
}

Not a quaternion—same letters, different meaning. The w here is the divisor from perspective divide. We keep it to check if vertices are behind the camera (w < 0 → don't draw).

Intentionally not using Point for x, y. It's a pipeline-specific structure, not general geometry.

O_Scene

A thing in the scene graph that can be rendered.

ts
interface O_Scene {
  id: string;
  vertices: Point3[];
  edges: [number, number][];
  orientation: quat;
  position: vec3;
  scale: number;
  color: string;
  parent?: O_Scene;
}
FieldWhat it's for
idUnique identifier, auto-generated
vertices3D points defining geometry (Point3[])
edgesPairs of vertex indices to connect
orientationRotation as quaternion (gl-matrix quat)
positionTranslation in world/parent space (gl-matrix vec3)
scaleUniform scale factor
colorCSS color prefix, e.g. 'rgba(78, 205, 196,'
parentOptional parent for hierarchical transforms

Note: position stays as vec3 because it's passed directly to gl-matrix functions. vertices uses Point3 because it's just stored/iterated—no gl-matrix interop needed.


Coordinate Types

2D (from Coordinates.ts)

ClassWhat it's for
Point2D position (x, y)
Size2D dimensions (width, height)
Rect2D rectangle (origin + size)
PolarPolar coordinates (r, phi)

3D (from Coordinates.ts)

ClassWhat it's for
Point33D position (x, y, z)
Size33D dimensions (width, height, depth)
Block3D box (origin + size)

Usage in Managers

ManagerTypeField/Param
RenderSizesize (canvas dimensions)
RenderPoint3project_vertex(v)
CameraSizeinit(size)
InputPointlast_position, T_Handle_Drag(delta)
ScenePoint3[]create({ vertices })

Point and Size have useful methods (offsetBy, vector_to, dividedInHalf, etc.) that simplify coordinate math. The 3D equivalents follow the same patterns.