Lays out points on a regular 3D lattice centred at the origin — the way to array copies of an object in even rows, on a plane, or through a filled volume.
Declarative element:
<sk-grid-points-source>
Global: available as sk.GridPointsSource inside a scene <script>.
This is the lattice member of the points-source family: a points-source
defines the set of positions at which a sk-cloner places copies of its
content, so it lives as a child of a <sk-cloner> and the cloner's other child
is the template that gets cloned at each grid point. Because the positions are
generated procedurally in the shader (see ShaderFunctionPointsSource),
a million-point grid costs the same handful of parameters as a hundred-point
one.
Key attributes. count-x / count-y / count-z set how many points lie
along each axis — the total is their product, and setting one count to 1
collapses that axis to give a line (two 1s) or a plane (one 1) instead of a
volume. spacing-x / spacing-y / spacing-z set the gap between adjacent
points on each axis, so the grid's extent on an axis is (count − 1) × spacing.
The lattice is always auto-centred on the origin, so growing the counts expands
it symmetrically. normal-direction is the shared surface normal reported for
every point; a cloner with align-to-normal turns each clone to face it (so the
whole field leans together), and it otherwise stays at the default up vector.
Related. It sits alongside the surface sources — sk-sphere-points-source,
sk-disc-points-source, sk-plane-points-source,
sk-cube-points-source, and the rest — as the volumetric member of the
family; sk-plane-points-source is the dedicated 2D counterpart. For
points that come from data or another object rather than a formula, see
sk-buffer-points-source, sk-mesh-vertex-points-source, and
sk-cloner-points-source. Its host is always a sk-cloner.
constructor(config?: { countX: number; countY: number; countZ: number; spacingX: number; spacingY: number; spacingZ: number; normalDirection?: [number, number, number] })
Inherited from: ShaderFunctionPointsSource, SkenraAnimatable
— see those pages for inherited members.
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
countX |
number |
1 |
Number of points along the X axis. | GridPointsSource |
countY |
number |
1 |
Number of points along the Y axis. | GridPointsSource |
countZ |
number |
1 |
Number of points along the Z axis. | GridPointsSource |
spacingX |
number |
1 |
Distance between adjacent points along the X axis. | GridPointsSource |
spacingY |
number |
1 |
Distance between adjacent points along the Y axis. | GridPointsSource |
spacingZ |
number |
1 |
Distance between adjacent points along the Z axis. | GridPointsSource |
normalDirection |
[number, number, number] |
[0, 1, 0] |
Normal direction for all grid points. | GridPointsSource |
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
sizeXread-only |
number |
— | Total extent of the grid along the X axis. | GridPointsSource |
sizeYread-only |
number |
— | Total extent of the grid along the Y axis. | GridPointsSource |
sizeZread-only |
number |
— | Total extent of the grid along the Z axis. | GridPointsSource |
pointCountread-only |
number |
— | Number of points provided by this source. | ShaderFunctionPointsSource |
localMatricesread-only |
Float32Array<ArrayBufferLike> | null |
— | CPU-side local matrices. | ShaderFunctionPointsSource |
typeread-only |
PointsSourceType |
"shader-function" |
The type of this points source. | ShaderFunctionPointsSource |
sceneread-only |
any |
— | Gets the Scene this animatable belongs to, if any. | SkenraAnimatable |
animationsread-only |
SkenraAnimation[] |
— | Public getter for the animations affecting this target. | SkenraAnimatable |
| Method | Description | Declared by |
|---|---|---|
getBoundsInSpace(fullTransform: Float32Array): { minX: number; maxX: number; minY: number; maxY: number; minZ: number; maxZ: number; } | null |
Computes the AABB in target space by transforming local bounds corners. | ShaderFunctionPointsSource |
setWorldReferenceNode(node: WorldReferenceNode | null): void |
Sets the reference node whose world matrix should be used for transforms. | ShaderFunctionPointsSource |
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 a 10x10x10 grid of points centered at origin
const gridSource = new GridPointsSource({
countX: 10, countY: 10, countZ: 10,
spacingX: 2, spacingY: 2, spacingZ: 2
});
// Grid spans from -9 to +9 on each axis (size = 18)
console.log(gridSource.sizeX); // 18
const cloner = new Cloner({ id: 'grid-cloner',
pointsSource: gridSource
});
cloner.appendChild(sphereNode);