Geometry · class
Spline
Explained in Hello world, Meshes and geometry.
class Splineimport { Spline } from '@driftengine/core';Constructor
new
constructor(points: readonly SplinePoint[])| Parameter | Type | Description |
|---|---|---|
points | readonly SplinePoint[] |
Accessors
| Name | Type | Description |
|---|---|---|
lengthMget | number | |
pointCountget | number | Control points, for callers that need the authored shape back. |
Methods
pointParamAt
pointParamAt(distanceM: number): numberWhere an arc length falls in control-point terms: index + fraction.
| Parameter | Type | Description |
|---|---|---|
distanceM | number |
More
The inverse of distanceAtPoint, for a caller that measured something along
the curve and needs to write the answer back onto the points that produced it.
The fraction matters as much as the index — bank and width are blended between
two control points, so attributing a measurement to one of them without
knowing which one dominates there gets the wrong point by half the time.
distanceAtPoint
distanceAtPoint(index: number): numberArc length at control point index.
| Parameter | Type | Description |
|---|---|---|
index | number |
More
A generator authors in control points — "the gap runs from the sixth point to the eighth" — but everything downstream is in metres, and the conversion is only knowable once the curve exists. Without this the caller has to guess, and a guessed hole is a hole in the wrong place.
sampleAt
sampleAt(distanceM: number, out: SplineSample): voidEvaluate the curve at an arc length, clamped to its ends.
| Parameter | Type | Description |
|---|---|---|
distanceM | number | |
out | SplineSample |
More
Allocation-free by contract: it is called from the simulation, from the generator and from the mesh builder, and the first of those makes it a hot path rule rather than a preference.