Stamps copies of its content across a set of points — the way to place many instances (a grid of spheres, particles over a mesh's surface) without authoring each one by hand.
Declarative element:
<sk-cloner>
Global: available as sk.Cloner inside a scene <script>.
The cloner is a SceneNode that instances geometry on the GPU: it takes
what to clone from its content children (any clonable node — a mesh, a spline)
and where to place them from a points-source. One points-source and one small
template become thousands of positioned copies, and when the points-source
changes the clones follow automatically.
Key attributes. mode chooses how clones are drawn: object renders each as
a full instance (its own transform, pickable), vertex merges them into one
particle-like batch that is cheaper at high counts. clone-scale uniformly
resizes every clone. align-to-normal orients clones to the source surface's
normal (with alignment-axis selecting which local axis points along it) — useful
for studding a surface. illumination-min-scale / illumination-max-scale size
clones by how much light they receive.
Related. The points-source child decides the layout: sk-grid-points-source
for a lattice, sk-mesh-vertex-points-source to sit on a mesh's vertices,
and the other *-points-source shapes. To drive each clone individually on the
GPU (push them from a point, weight them by a field) add a
sk-simple-point-constraint — the per-clone counterpart to the single-node
constraints.
constructor(config?: { pointsSource?: PointsSource; mode?: ClonerMode; alignToNormal?: boolean; applyScale?: boolean; alignmentAxis?: AlignmentAxis | AxisOrientation; cloneScale?: number; illuminationEnabled?: boolean; illuminationMinScale?: number; illuminationMaxScale?: number; illuminationUseShadows?: boolean; reportBounds?: boolean; overlay?: boolean; overlayOccludedOpacity?: number; id?: string; x?: number; y?: number; z?: number; h?: number; p?: number; b?: number; quaternion?: Quaternion; sx?: number; sy?: number; sz?: number; s?: number; class?: string; style?: string })
Inherited from: SceneNode, SkenraAnimatable
— see those pages for inherited members.
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
pointsSource |
PointsSource |
— | The source providing points for clone placement. | Cloner |
mode |
ClonerMode |
— | The current cloning mode. | Cloner |
alignToNormal |
boolean |
— | Whether clones are oriented to align with point normals. | Cloner |
applyScale |
boolean |
— | Whether each point's per-clone scale (from the source localMatrix) is | Cloner |
alignmentAxis |
AlignmentAxis | AxisOrientation |
— | The local axis that aligns with the normal direction. | Cloner |
cloneScaleanimatable |
number |
— | The uniform scale factor applied to each clone. | Cloner |
illuminationEnabled |
boolean |
false |
Gets whether illumination-based scaling is enabled. | Cloner |
illuminationMinScaleanimatable |
number |
— | Gets the minimum scale for illumination-based scaling. | Cloner |
illuminationMaxScaleanimatable |
number |
— | Gets the maximum scale for illumination-based scaling. | Cloner |
illuminationUseShadows |
boolean |
false |
Gets whether shadow maps are used for illumination visibility. | Cloner |
reportBoundsconfig-only |
boolean |
— | Whether this cloner reports bounds for auto-clipping. | ClonerConfig |
overlay |
boolean |
false |
Whether this cloner renders as an overlay with depth-aware translucency. | Cloner |
overlayOccludedOpacity |
number |
0.3 |
Alpha multiplier for overlay fragments occluded by scene geometry. | Cloner |
idconfig-only |
string |
— | Unique identifier for the node, reflected to the host id attribute. |
SceneNodeConfig |
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 |
sconfig-only |
number |
— | Uniform scale factor for all axes (overrides sx, sy, sz if provided) | SceneNodeConfig |
classconfig-only |
string |
— | Standard HTML class applied to the node host at construction |
SceneNodeConfig |
styleconfig-only |
string |
— | Standard inline style applied to the node host at construction |
SceneNodeConfig |
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
castShadow |
boolean |
true |
Gets whether this cloner's instances cast shadows. | Cloner |
cloneCountread-only |
number |
— | The number of clones that will be created. | Cloner |
templateCountread-only |
number |
— | The number of template units for instancing. | Cloner |
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 |
|---|---|---|
addPointConstraint(modifier: PointConstraint): void |
Adds a PointConstraint to this cloner. | Cloner |
removePointConstraint(modifier: PointConstraint): boolean |
Removes a PointConstraint from this cloner. | Cloner |
getBoundsInSpace(targetSpaceMatrix: Float32Array): { minX: number; maxX: number; minY: number; maxY: number; minZ: number; maxZ: number; } | null |
Returns the world-space AABB for this cloner's instances. | Cloner |
getTemplateRadius(): number |
Computes the bounding sphere radius of the cloned content children. | Cloner |
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 |
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 |
// Place small spheres at each vertex of a larger sphere
const baseSphere = new Sphere({ id: 'base', radius: 2, segments: 2 });
const pointsSource = new MeshVertexPointsSource({ mesh: baseSphere });
const cloner = new Cloner({ id: 'cloner',
pointsSource,
alignToNormal: true,
cloneScale: 1
});
// Add the content to clone as a child
const dotSphere = new Sphere({ id: 'dot', radius: 0.1 });
cloner.appendChild(dotSphere);
scene.appendChild(cloner);