ConePointsSource

← prev index next →

Scatters clones over the surface of a cone, cylinder, or frustum — the way to array copies up a tapering or straight tube, caps included.

Remarks

This is the cone/cylinder 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 cone costs the same handful of parameters as a coarse one.

Key attributes. bottom-radius and top-radius set the two end radii: a top-radius of 0 gives a pointed cone, equal radii give a straight cylinder, and two different non-zero radii give a truncated cone (frustum). height sets how far it extends along the orientation axis. height-segments sets how many rings run up the side and rotation-segments how many points sit around each ring (the angular resolution). orientation is the axis the cone extends along — one of +x, -x, +y, -y, +z, -z. center offsets the shape from the origin. Only unique points are emitted — a single apex for a pointed cone, one centre per end cap, and no seam duplicates.

Related. For a rounded-capped tube use sk-capsule-points-source; for a full donut use sk-torus-points-source. Its flat end cap is a sk-disc-points-source, and for a filled volume use sk-grid-points-source. To scatter over an arbitrary object's surface rather than an analytic cone, see sk-mesh-surface-points-source. Its host is always a sk-cloner.

Constructor

constructor(config?: { topRadius?: number; bottomRadius?: number; height?: number; heightSegments?: number; rotationSegments?: number; orientation?: AxisOrientation; center?: [number, number, number] })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
topRadius number 0 Top radius of the cone. ConePointsSource
bottomRadius number 1.0 Bottom radius of the cone. ConePointsSource
height number 1.0 Height of the cone. ConePointsSource
heightSegments number 1 Number of height segments. ConePointsSource
rotationSegments number 8 Number of rotation segments. ConePointsSource
orientationanimatable AxisOrientation "+y" Axis along which the cone extends. ConePointsSource
center [number, number, number] [0, 0, 0] Cone base center position. ConePointsSource

Other Properties

PropertyTypeDefaultDescriptionDeclared 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

Methods

MethodDescriptionDeclared 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

Example

// Create points on a pointed cone
const coneSource = new ConePointsSource({
    topRadius: 0,
    bottomRadius: 1.0,
    height: 2.0,
    heightSegments: 1,
    rotationSegments: 16
});

// Create points on a cylinder (equal radii)
const cylinderSource = new ConePointsSource({
    topRadius: 1.0,
    bottomRadius: 1.0,
    height: 2.0
});