The root of every Skenra scene — the container that every node, material, light, and camera lives inside, and the surface the scene is drawn onto.
Declarative element:
<sk-scene>
Not on the sk.* global — construct via the declarative element or a module import.
The scene is the top of the SceneNode hierarchy: it extends
sk-scene-node, so it has a transform of its own, but its real job is to
be the tree root everything else hangs from. Only content reachable from the
scene renders. Following the scene-graph conventions, a child's transform is
relative to its parent and materials inherit down the tree (a child uses an
ancestor's material unless it declares its own), and DOM-style events
capture/bubble through the hierarchy.
Defaults. A scene renders even when minimally specified: when no camera or
light is present it supplies a sensible default camera and a default light, so a
lone shape is visible without ceremony. Declare a sk-perspective-camera
or sk-directional-light to take control.
Related. Everything else in this reference is something a scene contains: the
geometry primitives (sk-sphere, sk-cube), grouping nodes
(sk-scene-node), lights, cameras, and the materials/paints that give
surfaces appearance.
constructor(config?: { name?: string; context?: RenderContext })
Inherited from: SceneNode, SkenraAnimatable
— see those pages for inherited members.
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
nameconfig-only |
string |
— | Optional name for the scene. | SceneConfig |
contextconfig-only |
RenderContext |
— | Render context providing viewport dimensions. | SceneConfig |
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
readyread-only |
boolean |
false |
Whether the scene has completed its build phase and is ready for | Scene |
readyPromiseread-only |
Promise<void> |
— | Resolves when the scene has dispatched its first | Scene |
camerasread-only |
readonly AbstractCamera[] |
— | Gets all cameras in the scene. | Scene |
activeCamera |
AbstractCamera |
— | Gets the active camera used for rendering. | Scene |
defaultCameraread-only |
OrthographicCamera |
— | Gets the scene's default camera. | Scene |
defaultLightread-only |
DirectionalLight |
— | Gets the scene's default directional light. | Scene |
activeLight |
DirectionalLight |
— | Gets the active light used for rendering. | Scene |
defaultTimelineread-only |
SceneScopedTimeline |
— | Gets the default timeline for this scene. | Scene |
seed |
number |
0 |
The scene's deterministic-randomness seed (an integer). | Scene |
captureResourcesPendingread-only |
boolean |
— | Whether any registered capture resource is still loading. | Scene |
xanimatable |
number |
0 |
Gets the X position component. | SceneNode |
yanimatable |
number |
0 |
Gets the Y position component. | SceneNode |
zanimatable |
number |
0 |
Gets the Z position component. | SceneNode |
hanimatable |
number |
0 |
Gets the heading (Y-axis) rotation in radians. | SceneNode |
panimatable |
number |
0 |
Gets the pitch (X-axis) rotation in radians. | SceneNode |
banimatable |
number |
0 |
Gets the bank (Z-axis) rotation in radians. | SceneNode |
quaternionanimatable |
Quaternion |
— | Gets the rotation as a quaternion. | SceneNode |
sxanimatable |
number |
1 |
Gets the X-axis scale factor. | SceneNode |
syanimatable |
number |
1 |
Gets the Y-axis scale factor. | SceneNode |
szanimatable |
number |
1 |
Gets the Z-axis scale factor. | SceneNode |
hRad |
number |
0 |
Gets the heading (Y-axis) rotation in radians. | SceneNode |
pRad |
number |
0 |
Gets the pitch (X-axis) rotation in radians. | SceneNode |
bRad |
number |
0 |
Gets the bank (Z-axis) rotation in radians. | SceneNode |
hDeg |
number |
0 |
Gets the heading (Y-axis) rotation in degrees. | SceneNode |
pDeg |
number |
0 |
Gets the pitch (X-axis) rotation in degrees. | SceneNode |
bDeg |
number |
0 |
Gets the bank (Z-axis) rotation in degrees. | SceneNode |
xBasebase value |
number |
— | Gets the base (non-animated) value of X position. | SceneNode |
yBasebase value |
number |
— | Gets the base (non-animated) value of Y position. | SceneNode |
zBasebase value |
number |
— | Gets the base (non-animated) value of Z position. | SceneNode |
hBasebase value |
number |
0 |
Gets the base (non-animated) value of heading (Y-axis rotation). | SceneNode |
pBasebase value |
number |
0 |
Gets the base (non-animated) value of pitch (X-axis rotation). | SceneNode |
bBasebase value |
number |
0 |
Gets the base (non-animated) value of bank (Z-axis rotation). | SceneNode |
quaternionBasebase value |
Quaternion |
— | Gets the base (non-animated) quaternion rotation. | SceneNode |
sxBasebase value |
number |
— | Gets the base (non-animated) value of X-axis scale. | SceneNode |
syBasebase value |
number |
— | Gets the base (non-animated) value of Y-axis scale. | SceneNode |
szBasebase value |
number |
— | Gets the base (non-animated) value of Z-axis scale. | SceneNode |
draggable |
boolean |
false |
Gets whether this node can be dragged. | SceneNode |
parentread-only |
SceneNode | null |
— | The parent node in the scene graph, or null at the root. |
SceneNode |
sceneread-only |
any |
— | Gets the Scene this node belongs to, if any. | SceneNode |
posread-only |
Point3D |
— | Gets the world-space position of this node. | SceneNode |
matrixread-only |
Float32Array<ArrayBufferLike> |
— | Gets the computed 4x4 transformation matrix. | SceneNode |
animationsread-only |
SkenraAnimation[] |
— | Public getter for the animations affecting this target. | SkenraAnimatable |
| Method | Description | Declared by |
|---|---|---|
diagnostics(): SceneDiagnostics |
Single-call self-verification probe for the scene's runtime health. | Scene |
pauseRenderLoop(): void |
Pauses the auto-init render loop. Cancels the pending | Scene |
resumeRenderLoop(): void |
Resumes the auto-init render loop previously paused via | Scene |
onFrame(callback: SceneFrameCallback): () => void |
Registers a per-frame callback that runs in the canonical before-render | Scene |
registerCaptureResource(isReady: () => boolean): () => void |
Registers an async-resource readiness predicate for deterministic capture. | Scene |
addMaterialPaint(material: Material, paintTarget: PaintTarget, options?: any): Paint |
Applies a material to this node for a specific paint target. | SceneNode |
getPaints(): ReadonlyMap<PaintTarget, Paint> |
— | SceneNode |
getOwnPaints(): readonly Paint[] |
Gets only the paints directly applied to this node (not inherited). | SceneNode |
removePaint(paint: Paint): void |
Removes a paint from this node. | SceneNode |
getWorldPosition(): number[] |
Returns this node’s origin in world space. | SceneNode |
getWorldMatrix(): Float32Array<ArrayBufferLike> |
Returns this node’s world transform — its local transform composed with all ancestor transforms. | SceneNode |
setViewportPosition(camera: AbstractCamera, x: number, y: number, z: number = 0.5): boolean |
Sets the node's local translation so that it appears at the specified viewport position. | SceneNode |
getViewportPosition(camera?: AbstractCamera): [number, number, number] | null |
Returns the node's current world position projected to viewport CSS pixel coordinates. | SceneNode |
setNDCPosition(camera: AbstractCamera, ndcX: number, ndcY: number, ndcZ: number = 0.5): boolean |
Sets the node's local translation so that it appears at the specified NDC position in the viewport. | SceneNode |
getBoundsInSpace(targetSpaceMatrix: Float32Array): { minX: number; maxX: number; minY: number; maxY: number; minZ: number; maxZ: number; } | null |
Computes the axis-aligned bounding box (AABB) of this node and its descendants | SceneNode |
animate(firstArg: TypedKeyframe<this>[] | TypedPropertyIndexedKeyframes<this> | Record<string, any> | globalThis.Keyframe[] | globalThis.PropertyIndexedKeyframes | null, secondArg?: number | KeyframeAnimationOptions | globalThis.KeyframeAnimationOptions): SkenraAnimation & Animation |
Creates a new SkenraAnimation for this target per Web Animations API. | SkenraAnimatable |
removeAnimation(animation: SkenraAnimation): boolean |
Removes a specific animation from this object. | SkenraAnimatable |
constrain(type: K, config: ConstraintConfigMap[K]): ConstraintReturnMap[K] |
Creates a constraint on this Animatable using a fluent API. | SkenraAnimatable |
// Create scene with optional configuration
const scene = new Scene({ name: 'main-scene' });
// Add surface paint to root (inherited by all children)
const material = new PlainMaterial({ baseColor: Color.yellow });
scene.addMaterialPaint(material, 'surface');
// Create and add objects to the scene
const sphere = new Sphere({ id: 'sphere', radius: 1 });
sphere.y = 2;
scene.appendChild(sphere);
const cube = new Cube({ id: 'cube', size: 1 });
cube.y = -2;
scene.appendChild(cube);
// Create hierarchy
const parent = new SceneNode({ id: 'parent' });
const child = new Sphere({ id: 'child', radius: 0.5 });
child.x = 3; // 3 units from parent
parent.appendChild(child);
scene.appendChild(parent);
// Clean up when done
scene.dispose();
Used in guides: Scene basics