PathSpline

← prev index next →

A spline whose curve is an SVG path — the convenience way to turn hand-drawn or exported vector artwork (an icon outline, a logo, an Illustrator path) into a 3D curve without wiring up a separate source element.

Remarks

This is the SVG-input member of the AbstractSpline family: a spline you place, transform and paint directly, whose geometry it builds for you from an svg path string. Internally it wraps an SVGSplineSource — the same source a <sk-spline> would host as a child — and exposes that source's controls as its own attributes. A stroke paint child draws the resulting curve, and the spline can be referenced by an sk-align-to-spline-constraint to ride a node along it. The source is fixed for the node's lifetime; to host an arbitrary or swappable source (GPU, morph, trail), use sk-spline.

Key attributes. svg is the path d string, in any grammar the browser parses (M/L/C/A/Z…). coordinate-space maps the 2D path into 3D by a signed axis token: x-y (the default) negates Y so Y-down SVG artwork stands upright in Skenra's Y-up world, x-z lays the path flat in the ground plane, and xy keeps it hand-authored Y-up. normalize-scale rescales the path to fit a [-n, n] box so exported artwork at pixel coordinates becomes scene-sized (omit it to keep authored coordinates). anchor picks which point of the artwork lands on the node origin — a named preset (center, top-left, …), normalized [x, y], or a specific content(x, y) point. subpath-index selects one subpath when the d string has several; flatness-tolerance trades curve smoothness against vertex count.

Related. sk-points-spline is the sibling convenience leaf for the other input modality — control points instead of a path. The underlying source is sk-svg-spline-source, which sk-spline can host directly alongside the rest of the spline-source family. The base concept is AbstractSpline.

Constructor

constructor(config?: { 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 })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
overlay boolean false Whether this node renders as an overlay with depth-aware translucency. RenderableNode
overlayOccludedOpacity number 0.3 Alpha multiplier for overlay fragments occluded by scene geometry. RenderableNode
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

Other Properties

PropertyTypeDefaultDescriptionDeclared by
svg string The SVG path data string (d attribute). Setting a new value PathSpline
subpathIndex number The selected subpath index. PathSpline
coordinateSpace string The coordinate space used for 2D→3D mapping. PathSpline
anchor AnchorValue2D The anchor point for origin placement (see AnchorValue). PathSpline
normalizeScale number | "none" The single normalization control: a number scales the path to fit PathSpline
flatnessTolerance number Tolerance for flattening curves into line segments. PathSpline
castShadow boolean true Whether this spline casts shadows. AbstractSpline
isValidread-only boolean Indicates whether the spline was successfully initialized and is valid. AbstractSpline
sourceread-only SplineSource The current segment source providing polyline data. AbstractSpline
pointsSourceread-only PointsSource The points source for this spline — its SplineSource (which AbstractSpline
pointConstraintsread-only readonly PointConstraint[] [] Read-only view of the attached point constraints. AbstractSpline
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

Methods

MethodDescriptionDeclared by
isShadowCaster(): boolean Indicates whether this spline participates in shadow casting. AbstractSpline
getBoundsInSpace(targetSpaceMatrix: Float32Array): { minX: number; maxX: number; minY: number; maxY: number; minZ: number; maxZ: number; } | null Computes the axis-aligned bounding box of this spline in a target AbstractSpline
getPathLength(): number Gets the total length of the processed spline. AbstractSpline
getPointAt(t: number): number[] Gets a 3D point on the spline at a given normalized progression t. AbstractSpline
getClosestPoint(worldPos: [number, number, number]): ClosestPointResult | null Finds the closest point on the spline to a given world-space position. AbstractSpline
getPolyline3D(): readonly Readonly<SplinePoint>[] Gets the internal 3D polyline points. AbstractSpline
getVertices3D(resolution: number = AbstractSpline.DEFAULT_RESOLUTION): Float32Array<ArrayBufferLike> Gets all the 3D vertices of the spline, transformed to world space. AbstractSpline
getVerticesAndWidths3D(resolution: number = AbstractSpline.DEFAULT_RESOLUTION): Float32Array<ArrayBufferLike> Gets all 3D vertices in local space, stride-4 for GPU upload. AbstractSpline
addPointConstraint(constraint: PointConstraint): void Add a PointConstraint to this spline. AbstractSpline
removePointConstraint(constraint: PointConstraint): boolean Remove a PointConstraint from this spline. AbstractSpline
retessellate(currentZoom: number, lookaheadFactor?: number): void Re-tessellates the spline at the given zoom level with adaptive tolerance. AbstractSpline
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

Example

const orbit = new PathSpline({
    id: 'orbit',
    svg: 'M 50 0 A 50 50 0 1 1 -50 0 A 50 50 0 1 1 50 0 Z',
    coordinateSpace: 'x-z',
    normalizeScale: 1,
});