A 3D Voronoi cell structure as a spatial field — cell-wall line art, cracked and crazed surfaces, stained-glass leading, organic panelling, all sampled in 3D so they cross any surface without a UV, a seam, or a pole.
Declarative element:
<sk-voronoi-spatial-field>
Global: available as sk.VoronoiSpatialField inside a scene <script>.
This is the Voronoi member of the SpatialField family: like every
field it turns where into how much — a scalar weight over space that
consumers read by #id (field="#id") to gate material alpha, tonemap
coverage, or colour-map weight alike. Because it is sampled at a 3D position,
a surface simply shows the cross-section of the volumetric cells it cuts
through — immune to the seams and poles that plague a tiled 2D pattern.
Key attributes. output chooses the scalar: distance-to-edge (default,
the unsigned distance to the nearest cell wall — this is the mode that makes
line art), f1/f2 (distance to the nearest / second-nearest seed, classic
Worley), or cell-id (a stable per-cell hash for per-cell variation). scale
sets cell density; jitter is the seed displacement within each cell (0 is a
regular lattice, Blender calls this randomness). seed is a CONTINUOUS
re-roll axis and seed-period the advance that returns the identical field,
so a linear seed animation loops seamlessly. swell fillets junctions where
three or more cells meet, in the field's distance units, without widening
straight runs (distance-to-edge only). voronoi-type selects xy/yz/zx
(an extruded prism of cells, constant along the omitted axis) or xyz (full
3D packing). The field rides its own frame, so animating its x/y/z or
rotation moves and turns the cells with it.
**Width and softness come from remapCurve, not attributes.** A line of a
given width is a threshold on the distance-to-edge scalar — a pointwise
remap — so it is expressed through the base's SpatialField.remapCurve
(e.g. remap-curve="step:0.05" for a crisp wall, inverse:... to flip which
side survives), never a bespoke width/softness attribute.
Related. It shares the field="#id" model with every field; its smooth
counterpart is sk-noise-spatial-field and its uncorrelated one
sk-random-spatial-field. To turn cells into COLOUR, drive a
sk-color-map-source intensity-field with this field. Typical
consumers are a sk-tonemap (gate coverage), a sk-plain-material
(gate alpha), and sk-field-constraint (drive a property per cell).
constructor(config?: { voronoiType?: VoronoiType; scale?: number; jitter?: number; seed?: number; seedPeriod?: number; output?: VoronoiOutput; swell?: number; remapCurve?: SampledCurve; visualize?: boolean; interactiveControls?: boolean; visualizationMarkerSize?: number; visualizationColor?: string; visualizationZeroWeightColor?: string; visualizationSplineThickness?: number; visualizationSplineOccludedOpacity?: number; visualizationMarkerOpacity?: 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: SpatialField, VisualizableSceneNode, SceneNode, SkenraAnimatable
— see those pages for inherited members.
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
voronoiType |
VoronoiType |
"xyz" |
Which plane(s) the cells pack in. Not animatable — changing it changes the | VoronoiSpatialField |
scaleanimatable |
number |
1.0 |
Cell density — higher packs more, smaller cells into the same space. | VoronoiSpatialField |
jitteranimatable |
number |
1.0 |
Seed displacement within its cell (0 = regular lattice, 1 = fully random). | VoronoiSpatialField |
seedanimatable |
number |
0 |
Continuous re-roll axis. | VoronoiSpatialField |
seedPeriodanimatable |
number |
— | The seed advance that returns the identical field. | VoronoiSpatialField |
output |
VoronoiOutput |
"distance-to-edge" |
Which scalar to emit. Not animatable — changing it changes the shaderKey |
VoronoiSpatialField |
swellanimatable |
number |
0 |
Junction fillet radius in the field's distance units (distance-to-edge only). |
VoronoiSpatialField |
remapCurveanimatable |
SampledCurve |
— | Optional curve that reshapes this field's raw [0, 1] output. | SpatialField |
visualize |
boolean |
false |
Whether the visualization is visible (wireframe splines + center marker). | VisualizableSceneNode |
interactiveControlsconfig-only |
boolean |
— | Whether to show interactive controls (draggable markers). Requires visualize. Default: false | VisualizableSceneNodeConfig |
visualizationMarkerSizeconfig-only |
number |
— | Size of visualization markers in pixels. Default: 20 | VisualizableSceneNodeConfig |
visualizationColorconfig-only |
string |
— | Color for visualization geometry and markers (CSS color string). Default: VISUALIZATION_HIGHLIGHT_COLOR ('#FF8C00'). | VisualizableSceneNodeConfig |
visualizationZeroWeightColorconfig-only |
string |
— | Color for zero-weight boundary geometry (outer radius, origin plane, etc.). Default: VISUALIZATION_ZERO_WEIGHT_COLOR ('#888888'). | VisualizableSceneNodeConfig |
visualizationSplineThicknessconfig-only |
number |
— | Spline stroke thickness in pixels. Default varies by subclass. | VisualizableSceneNodeConfig |
visualizationSplineOccludedOpacityconfig-only |
number |
— | Opacity of visualization splines when occluded. Default: 0.5 | VisualizableSceneNodeConfig |
visualizationMarkerOpacityconfig-only |
number |
— | Opacity of visualization markers. Default: 0.9 | VisualizableSceneNodeConfig |
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 |
|---|---|---|---|---|
scaleBasebase value |
number |
— | The base (non-animated) value of scale. |
VoronoiSpatialField |
jitterBasebase value |
number |
— | The base (non-animated) value of jitter. |
VoronoiSpatialField |
seedBasebase value |
number |
— | The base (non-animated) value of seed. |
VoronoiSpatialField |
seedPeriodBasebase value |
number |
— | The base (non-animated) value of seedPeriod. |
VoronoiSpatialField |
swellBasebase value |
number |
— | The base (non-animated) value of swell. |
VoronoiSpatialField |
remapPhaseanimatable |
number |
0 |
Horizontal remap phase — an animatable scalar that translates a present | SpatialField |
enabled |
boolean |
true |
Whether this field is enabled. When disabled, evaluate() returns 0. |
SpatialField |
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 |
|---|---|---|
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 |
const cells = new VoronoiSpatialField({
id: 'cells', scale: 1.5, jitter: 0.85, output: 'distance-to-edge',
remapCurve: SampledCurve.step(0.06),
});
scene.appendChild(cells);