Uzay

Items

3D scene items. Points, lines, curves, and more

Items are the visual elements that make up your 3D scene. Uzay provides several types of items for different purposes.

Creating Items

Use scene.create(kind, options) to add items to a scene:

const point = scene.create("point3d", {
  coords: vec3(1, 2, 3),
  color: "red",
  radius: 2,
});

The first argument is the item type, and the second is an options object where you configure the item's properties.

Reactive Properties

Every property can be either a plain value or an atom:

scene.create("point3d", { radius: 2 });

const r = scene.atom(2);
scene.create("point3d", { radius: r });

r.set(5);

You can also use derived atoms for computed properties:

const t = scene.atom(0);

scene.create("point3d", {
  coords: scene.atom((get) => {
    const time = get(t);
    return vec3(Math.cos(time), Math.sin(time), 0);
  }),
});

Available Items

ItemDescriptionCommon Use Cases
Point3DA sphere at a 3D positionMarkers, vertices, handles
Line3DA line segment between two pointsConnections, edges
Vector3DAn arrow with origin and directionForces, velocities, normals
ParametricFunction3DA curve defined by a parametric equationHelixes, spirals, paths
Surface3DA surface defined by a height functionTerrain, potential fields, function plots
Sphere3DA sphere with center and radiusVolumes, regions, atoms
Plane3DA rectangular surface with normal vectorSurfaces, walls, cross-sections
Overlay3DA 2D label anchored to a 3D positionLabels, equations, annotations
Axes3DCoordinate axesReference, orientation
Grid3DA grid on a planeReference planes, floors
Camera3DA viewpoint into the sceneRequired for rendering

Removing Items

Remove items from the scene with scene.remove():

const point = scene.create("point3d", { coords: vec3(1, 1, 1) });

// Later
scene.remove(point);

Tags

All items support a tags property for categorization:

const p1 = scene.create("point3d", {
  coords: vec3(0, 0, 0),
  tags: ["3d", "2d"],
});

const p2 = scene.create("point3d", {
  coords: vec3(1, 0, 0),
  tags: ["3d"],
});

Tags are currently unused. In the future, it'll be used for grouping items, and different views and cameras will be able to filter items by tag.

On this page