Scatters clones over the surface of a torus — the way to array copies around a donut, wrapping both the big ring and the tube.
Declarative element:
<sk-torus-points-source>
Not on the sk.* global — construct via the declarative element or a module import.
This is the torus-surface 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 point. Because the positions are
generated procedurally in the shader (see ShaderFunctionPointsSource),
a finely subdivided torus costs the same handful of parameters as a coarse one.
Key attributes. major-radius is the distance from the torus centre to the
middle of the tube (how big the donut is), and minor-radius is the radius of
the tube itself (how thick it is) — a small minor-radius gives a thin hoop, a
large one a fat ring. major-segments sets how many points go around the big
ring and minor-segments how many go around the tube's cross-section; together
they set the surface density. orientation is the axis the ring lies flat
against — the axis through the hole, one of +x, -x, +y, -y, +z, -z.
center offsets the torus from the origin.
Related. For a straight capped tube use sk-capsule-points-source or
sk-cone-points-source; for a flat ring with a hole (no tube) use
sk-disc-points-source. Other closed surfaces include
sk-sphere-points-source and sk-cube-points-source. To scatter
over an arbitrary object's surface rather than an analytic torus, see
sk-mesh-surface-points-source. Its host is always a sk-cloner.
constructor(config?: { majorRadius?: number; minorRadius?: number; majorSegments?: number; minorSegments?: number; orientation?: AxisOrientation; center?: [number, number, number] })
Inherited from: ShaderFunctionPointsSource, SkenraAnimatable
— see those pages for inherited members.
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
majorRadius |
number |
1.0 |
Major radius of the torus. | TorusPointsSource |
minorRadius |
number |
0.3 |
Minor radius of the torus. | TorusPointsSource |
majorSegments |
number |
16 |
Number of major segments. | TorusPointsSource |
minorSegments |
number |
12 |
Number of minor segments. | TorusPointsSource |
orientationanimatable |
AxisOrientation |
"+y" |
Axis perpendicular to the torus plane. | TorusPointsSource |
center |
[number, number, number] |
[0, 0, 0] |
Torus center position. | TorusPointsSource |
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
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 points on a standard torus
const torusSource = new TorusPointsSource({
majorRadius: 1.0,
minorRadius: 0.3,
majorSegments: 16,
minorSegments: 12
});
// Create points on a tire-like torus
const tireSource = new TorusPointsSource({
majorRadius: 1.5,
minorRadius: 0.6,
majorSegments: 24,
minorSegments: 16
});