Skip to content

scene

Scene nodes, components, and interaction.

11 functions / 49 types

Modules

Index

FunctionDescription
clearSkyboxRemove the scene’s skybox, so the background is black from the next frame. Cancels a setSkybox load still in progress, which then fails with Cancelled.
cloneClone a scene node with shared render assets and the same parent and local component values. The clone has no project association. Active pointer drags are not copied.
despawnDespawn a scene object and all its descendants.
getChildrenGet the children of a given NodeSchema
getClockRead the scene’s clock.
getParentGet the parent of a given scene object if it exists
getSkyboxRead the skybox drawn now, or nothing when there is none. A load in progress is not reported.
setClockSet the scene’s clock, and answer it as it now is. Each field left out keeps its value.
setParentSet the parent of a given NodeSchema
setSkyboxDraw one equirectangular image as the scene’s background, and answer the skybox drawn once it has loaded.
spawnSpawn a new blank scene object into the scene
TypeDescription
ArrowA 3D Arrow.
AttributeBasedAppearanceColours a model by one of its attributes, through a named colour ramp.
AttributeRangeNumeric range an attribute-driven color ramp is stretched across.
AttributeValueOne attribute value of a leaf, one arm per attribute type.
BlockModelA block model representation.
BlockModelAppearanceHow a block model is drawn.
BlockModelAttributeRampBlock model colored by a named attribute through a color ramp.
BlockModelColorBlock model drawn in one flat color.
BlockModelGradientBlock model colored by a ramp along a world-space axis.
BlockModelMatCapBlock model shaded with a named matcap texture.
CapsuleA 3D Capsule.
ClockThe scene’s clock at the moment it was read.
CubeA 3D Cube.
DragKindHow a drag moves the shape it is set on.
DragRotationAn axis through a point, which a DragKind.Rotation turns about.
Geometry
GradientExtentsKindWhether a gradient spans the object or the whole scene.
LeafDescriptionIdentifies a block or point in loaded scene geometry.
LeafInfoPosition, size, and attribute values of one leaf.
LineDash
LineJoin
LineRound
LineStyle
MeshA triangle mesh representation.
MeshAppearanceHow a mesh is drawn.
MeshAttributeRampMesh colored by its own vertex attributes.
MeshColorMesh drawn in one flat color.
MeshGradientMesh colored by a ramp along a world-space axis.
MeshMatCapMesh shaded with a named matcap texture.
NameA custom label for a node
NoFilterFilter that draws every element.
Node
PointCloudA point cloud representation.
PointCloudAppearanceHow a point cloud is drawn.
PointCloudAttributeRampPoint cloud colored by a named attribute through a color ramp.
PointCloudColorPoint cloud drawn in one flat color.
PointCloudGradientPoint cloud colored by a ramp along a world-space axis.
PointCloudMatCapPoint cloud shaded with a named matcap texture.
PolylineA polyline representation, carried inline rather than by handle.
PolylineAppearance
Shape
ShapeAppearanceHow a shape is drawn.
SkyboxThe scene’s skybox.
SphereA 3D Sphere.
TransformA translation, rotation, and scale in the scene.
ValueRangeFilterFilter keeping elements whose attribute falls inside [min, max].
VisibilityWhether an object is drawn.
VisibilityKindWhether an object is drawn, hidden, or follows its parent.
VolumetricFilterWhich elements of a model are drawn.

clearSkybox

clearSkybox(transactionId?: string): Promise<void>

Remove the scene’s skybox, so the background is black from the next frame. Cancels a setSkybox load still in progress, which then fails with Cancelled.

Returns Promise<void>.

transactionId optional : string

clone

clone(args: { deep?: boolean; node: SceneNode }, transactionId?: string): Promise<SceneNode>

Clone a scene node with shared render assets and the same parent and local component values. The clone has no project association. Active pointer drags are not copied.

Returns Promise<SceneNode>.

deep optional : boolean

Include descendant nodes. Defaults to true.

node : SceneNode

Node to clone.

transactionId optional : string

despawn

despawn(args: { node: SceneNode }, transactionId?: string): Promise<void>

Despawn a scene object and all its descendants.

Returns Promise<void>.

node : SceneNode

transactionId optional : string

getChildren

getChildren(args: { node: SceneNode }, transactionId?: string): Promise<Array<SceneNode>>

Get the children of a given NodeSchema

Returns Promise<Array<SceneNode>>.

node : SceneNode

transactionId optional : string

getClock

getClock(transactionId?: string): Promise<SceneClock>

Read the scene’s clock.

Returns: The scene’s clock at the moment it was read.

Returns Promise<SceneClock>.

transactionId optional : string

getParent

getParent(args: { node: SceneNode }, transactionId?: string): Promise<SceneNode | undefined>

Get the parent of a given scene object if it exists

Returns Promise<SceneNode | undefined>.

node : SceneNode

transactionId optional : string

getSkybox

getSkybox(transactionId?: string): Promise<SceneSkybox | undefined>

Read the skybox drawn now, or nothing when there is none. A load in progress is not reported.

Returns Promise<SceneSkybox | undefined>.

transactionId optional : string

setClock

setClock(args?: { rate?: number; timeUtc?: string }, transactionId?: string): Promise<SceneClock>

Set the scene’s clock, and answer it as it now is. Each field left out keeps its value.

The scene has one clock. It starts at the moment the engine starts, held still. Layers with a time axis show the date the clock reads, and the clock moves on by rate seconds for every real second. It stops at the years 0 and 9999. Nothing in the scene moves with the clock; the caller places objects for the moment it reads.

This is scene time, the moment the scene shows. It is separate from the project version being viewed, and setting one never moves the other.

Fails with InvalidArgument without changing anything when timeUtc is not an RFC 3339 date and time or rate is not finite.

Returns: The scene’s clock at the moment it was read.

Returns Promise<SceneClock>.

rate optional : number

Seconds of clock time that pass in each real second. 0 holds the clock still, and a negative rate runs it backward.

timeUtc optional : string

An RFC 3339 date and time, such as 2024-06-20T20:51:00Z.

transactionId optional : string

setParent

setParent(args: { node: SceneNode; parent?: SceneNode }, transactionId?: string): Promise<void>

Set the parent of a given NodeSchema

Returns Promise<void>.

node : SceneNode

parent optional : SceneNode

transactionId optional : string

setSkybox

setSkybox(args: { luminance?: number; orientation?: MathQuat; source: string }, transactionId?: string): Promise<SceneSkybox>

Draw one equirectangular image as the scene’s background, and answer the skybox drawn once it has loaded.

The image is twice as wide as it is tall. The pixel at column u and row v, both from 0 to 1 from the top left corner, shows the direction (cos Dec cos RA, cos Dec sin RA, sin Dec) in the image frame, where RA = (0.5 - u) * 360 degrees and Dec = (0.5 - v) * 180 degrees. The image frame is z-up, so a star map in celestial coordinates has right ascension 0h along +x and the north celestial pole along +z. orientation turns the image frame into scene axes.

A pixel’s linear value is drawn at that value times luminance, in cd/m^2, and each camera’s exposure applies to it. PNG, JPEG and WebP pixels are sRGB; Radiance HDR and OpenEXR pixels are linear. The image becomes a cubemap with faces a quarter of its width.

The source can instead be a KTX2 cubemap with its mips, in any texture format the GPU samples, and its faces show the same directions as the cubemap an image becomes. The engine uploads it as it is, so a large sky loads without the work of decoding and converting an image.

The current background stays drawn until the new image is ready. Given the source drawn now, only the luminance and orientation change and nothing is fetched. A later setSkybox or clearSkybox cancels a load still in progress, which then fails with Cancelled.

Fails with InvalidArgument when source is neither an absolute URL nor, outside a browser, an absolute file path, when luminance is negative or not finite, or when orientation is not finite or has zero length; with SourceUnavailable when the image cannot be fetched or read; and with UnsupportedFormat when it is not PNG, JPEG, WebP, Radiance HDR, OpenEXR or KTX2, cannot be decoded, is not twice as wide as it is tall, or is a KTX2 file that is not one cubemap or is in a texture format the GPU cannot sample.

Returns: The scene’s skybox.

Returns Promise<SceneSkybox>.

luminance optional : number

cd/m^2 drawn for a linear pixel value of 1. Absent, 1.

orientation optional : MathQuat

The turn from the image frame to scene axes. Absent, the identity. Normalized before use.

source : string

The absolute URL of the image. An engine running outside a browser also reads an absolute file path or a file: URL from its own disk.

transactionId optional : string

spawn

spawn(transactionId?: string): Promise<SceneNode>

Spawn a new blank scene object into the scene

Returns Promise<SceneNode>.

transactionId optional : string

Arrow

A 3D Arrow.

length : number

Length of the arrow

AttributeBasedAppearance

Colours a model by one of its attributes, through a named colour ramp.

attribute : string

Name of the attribute driving the color.

ramp optional : string

Name of the color ramp. When absent, the viewer’s default is used.

range optional : SceneAttributeRange

Range the ramp is stretched across. When absent, the attribute’s own range is used.

AttributeRange

Numeric range an attribute-driven color ramp is stretched across.

max : number

Value mapped to the end of the ramp.

min : number

Value mapped to the start of the ramp.

AttributeValue

type SceneAttributeValue = { kind: "bool"; value: boolean } | { kind: "int"; value: bigint } | { kind: "real"; value: number } | { kind: "text"; value: string } | { kind: "color"; value: ColorColorRgb }

One attribute value of a leaf, one arm per attribute type.

BlockModel

A block model representation.

appearance optional : SceneBlockModelAppearance

How the block model is drawn.

data : RemoteHandle

Handle of the stored model, as a hyphenated UUID.

BlockModelAppearance

type SceneBlockModelAppearance = { kind: "matCap"; value: SceneBlockModelMatCap } | { kind: "color"; value: SceneBlockModelColor } | { kind: "attributeRamp"; value: SceneBlockModelAttributeRamp } | { kind: "gradient"; value: SceneBlockModelGradient }

How a block model is drawn.

BlockModelAttributeRamp

Block model colored by a named attribute through a color ramp.

appearance optional : SceneAttributeBasedAppearance

Which attribute drives the color and over what range.

filter optional : SceneVolumetricFilter

Which blocks are drawn.

opacity optional : number

Alpha applied to the whole model, 1.0 being fully opaque. When absent, it reads as fully opaque.

outline : boolean

Whether block edges are outlined.

BlockModelColor

Block model drawn in one flat color.

filter optional : SceneVolumetricFilter

Which blocks are drawn.

opacity optional : number

Alpha applied to the whole model, 1.0 being fully opaque. When absent, it reads as fully opaque.

outline : boolean

Whether block edges are outlined.

rgb : ColorColorRgb

The flat color. Transparency is opacity, not an alpha channel here.

BlockModelGradient

Block model colored by a ramp along a world-space axis.

axis : MathVec3

Direction the ramp runs along.

extents : SceneGradientExtentsKind

Which bounds the ramp is stretched across.

filter optional : SceneVolumetricFilter

Which blocks are drawn.

opacity optional : number

Alpha applied to the whole model, 1.0 being fully opaque. When absent, it reads as fully opaque.

outline : boolean

Whether block edges are outlined.

ramp : string

Name of the color ramp.

BlockModelMatCap

Block model shaded with a named matcap texture.

filter optional : SceneVolumetricFilter

Which blocks are drawn.

name : string

Name of the matcap texture.

opacity optional : number

Alpha applied to the whole model, 1.0 being fully opaque. When absent, it reads as fully opaque.

outline : boolean

Whether block edges are outlined.

Capsule

A 3D Capsule.

length : number

The length of the capsule, minus the caps.

radius : number

The radius of the Semi-Sphere.

Clock

The scene’s clock at the moment it was read.

rate : number

Seconds of clock time that pass in each real second.

timeUtc : string

RFC 3339 in UTC, with milliseconds where there are any.

unixSeconds : number

The same moment as seconds since 1970-01-01T00:00:00Z, without leap seconds.

Cube

A 3D Cube.

halfExtents : number

The half-extents of the Cube.

DragKind

type SceneDragKind = { kind: "translationAxis"; value: MathVec3 } | { kind: "translationPlane"; value: MathVec3 } | { kind: "rotation"; value: SceneDragRotation }

How a drag moves the shape it is set on.

DragRotation

An axis through a point, which a DragKind.Rotation turns about.

axis : MathVec3

The axis turned about.

center : MathVec3

The point the axis passes through.

Geometry

type SceneGeometry = { kind: "sphere"; value: SceneSphere } | { kind: "cube"; value: SceneCube } | { kind: "arrow"; value: SceneArrow } | { kind: "capsule"; value: SceneCapsule }

GradientExtentsKind

Enum

Whether a gradient spans the object or the whole scene.

Global = 1

Stretch the ramp across the whole scene’s extents.

Local = 0

Stretch the ramp across the node’s own extents.

LeafDescription

Identifies a block or point in loaded scene geometry.

dataId : number

The loaded model data containing the leaf.

detailLevel : number

Level of detail the leaf was hit at. 0 is full detail (a single leaf); higher values cover progressively larger groups of leaves while the model loads in.

leafIndex : number

Index of the leaf within its level of detail.

region : number

The region of the model containing the leaf.

LeafInfo

Position, size, and attribute values of one leaf.

Unloaded values are listed in missing_attributes and can be queried again after loading.

attributes optional : Record<string, SceneAttributeValue>

Attribute values by name.

bounds optional : MathAabb

The leaf’s box in the model’s local coordinates, absent until its geometry has loaded.

missingAttributes optional : Array<string>

Attributes whose values haven’t loaded yet.

LineDash

gapScale : number

Gap length in multiples of the line width.

lineScale : number

Dash length in multiples of the line width.

LineJoin

type SceneLineJoin = { kind: "none" } | { kind: "miter" } | { kind: "bevel" } | { kind: "round"; value: SceneLineRound }

LineRound

resolution : number

LineStyle

type SceneLineStyle = { kind: "solid" } | { kind: "dotted" } | { kind: "dashed"; value: SceneLineDash }

Mesh

A triangle mesh representation.

appearance optional : SceneMeshAppearance

How the mesh is drawn.

data : RemoteHandle

Handle of the stored model, as a hyphenated UUID.

MeshAppearance

type SceneMeshAppearance = { kind: "matCap"; value: SceneMeshMatCap } | { kind: "color"; value: SceneMeshColor } | { kind: "attributeRamp"; value: SceneMeshAttributeRamp } | { kind: "gradient"; value: SceneMeshGradient }

How a mesh is drawn.

MeshAttributeRamp

Mesh colored by its own vertex attributes.

MeshColor

Mesh drawn in one flat color.

rgba : ColorColorRgba

The flat color.

MeshGradient

Mesh colored by a ramp along a world-space axis.

axis : MathVec3

Direction the ramp runs along.

extents : SceneGradientExtentsKind

Which bounds the ramp is stretched across.

ramp : string

Name of the color ramp.

MeshMatCap

Mesh shaded with a named matcap texture.

name : string

Name of the matcap texture.

Name

A custom label for a node

name : string

Name of the node

NoFilter

Filter that draws every element.

Node

id : bigint

PointCloud

A point cloud representation.

appearance optional : ScenePointCloudAppearance

How the point cloud is drawn.

data : RemoteHandle

Handle of the stored model, as a hyphenated UUID.

PointCloudAppearance

type ScenePointCloudAppearance = { kind: "matCap"; value: ScenePointCloudMatCap } | { kind: "color"; value: ScenePointCloudColor } | { kind: "attributeRamp"; value: ScenePointCloudAttributeRamp } | { kind: "gradient"; value: ScenePointCloudGradient }

How a point cloud is drawn.

PointCloudAttributeRamp

Point cloud colored by a named attribute through a color ramp.

appearance optional : SceneAttributeBasedAppearance

Which attribute drives the color and over what range.

filter optional : SceneVolumetricFilter

Which points are drawn.

opacity optional : number

Alpha applied to the whole cloud, 1.0 being fully opaque. When absent, it reads as fully opaque.

pointSize : number

Diameter of a drawn point in world units.

PointCloudColor

Point cloud drawn in one flat color.

filter optional : SceneVolumetricFilter

Which points are drawn.

opacity optional : number

Alpha applied to the whole cloud, 1.0 being fully opaque. When absent, it reads as fully opaque.

pointSize : number

Diameter of a drawn point in world units.

rgb : ColorColorRgb

The flat color. Transparency is opacity, not an alpha channel here.

PointCloudGradient

Point cloud colored by a ramp along a world-space axis.

axis : MathVec3

Direction the ramp runs along.

extents : SceneGradientExtentsKind

Which bounds the ramp is stretched across.

filter optional : SceneVolumetricFilter

Which points are drawn.

opacity optional : number

Alpha applied to the whole cloud, 1.0 being fully opaque. When absent, it reads as fully opaque.

pointSize : number

Diameter of a drawn point in world units.

ramp : string

Name of the color ramp.

PointCloudMatCap

Point cloud shaded with a named matcap texture.

filter optional : SceneVolumetricFilter

Which points are drawn.

name : string

Name of the matcap texture.

opacity optional : number

Alpha applied to the whole cloud, 1.0 being fully opaque. When absent, it reads as fully opaque.

pointSize : number

Diameter of a drawn point in world units.

Polyline

A polyline representation, carried inline rather than by handle.

appearance optional : ScenePolylineAppearance

vertices optional : Array<MathVec3>

Polyline vertices in order. A closed polyline repeats its first vertex last.

PolylineAppearance

color optional : ColorColorRgba

depthBias optional : number

Depth offset between -1 and 1. Negative values move lines toward the camera.

fillColor optional : ColorColorRgba

Fill color for a closed planar polyline. Absent means no fill.

lineJoin optional : SceneLineJoin

linePerspective optional : boolean

Whether stroke width decreases with distance. The default is false.

lineStyle optional : SceneLineStyle

lineWidth optional : number

Stroke width in pixels when perspective is disabled. It must be positive; the default is 4.

Shape

appearance : SceneShapeAppearance

The appearance of the shape

geometry : SceneGeometry

The shape geometry

ShapeAppearance

How a shape is drawn.

color optional : ColorColorRgba

The color of the shape.

depthBias optional : number

Depth offset between -1 and 1. Negative values move lines toward the camera.

lineJoin optional : SceneLineJoin

linePerspective optional : boolean

Whether wireframe width decreases with distance. The default is false.

lineStyle optional : SceneLineStyle

lineWidth optional : number

Wireframe width in pixels when perspective is disabled. It must be positive; the default is 2.

wireframe : boolean

Whether the engine draws the shape as a solid mesh or as a wireframe.

Skybox

The scene’s skybox.

luminance : number

cd/m^2 for a linear pixel value of 1.

orientation : MathQuat

The turn from the image frame to scene axes.

source : string

The image URL.

Sphere

A 3D Sphere.

radius : number

The radius of the Sphere.

Transform

A translation, rotation, and scale in the scene.

rotation : MathQuat

How the shape is turned.

scale : MathVec3

How the shape is stretched along each of its own axes.

translation : MathVec3

Where the shape sits.

ValueRangeFilter

Filter keeping elements whose attribute falls inside [min, max].

attribute : string

Name of the attribute being tested.

max : number

Inclusive upper bound.

min : number

Inclusive lower bound.

Visibility

Whether an object is drawn.

kind : SceneVisibilityKind

The VisibilityKind as an i32 kind.

VisibilityKind

Enum

Whether an object is drawn, hidden, or follows its parent.

Hidden = 2

Force the node hidden.

Inherited = 0

Inherit visibility from the parent node.

Visible = 1

Force the node visible.

VolumetricFilter

type SceneVolumetricFilter = { kind: "none"; value: SceneNoFilter } | { kind: "valueRange"; value: SceneValueRangeFilter }

Which elements of a model are drawn.