Rope and DistortionGrid
Ribbons along a path, and deformable grid meshes.
ts
import { Rope, RopeConfig, RopeJoinMode, RopeCurveMode, DistortionGrid } from "willow";Rope
ts
class Rope extends NodeExtends Node.
Generates a ribbon/rope mesh following a polyline path or procedural curve.
Rope: constructors
ts
new Rope(texture: Texture | TextureRegion, pointsOrConfig?: Float32Array | Array<float> | RopeConfig, config?: RopeConfig)Creates a new Rope node with an optional path or curve configuration.
Rope: properties
| Member | Description |
|---|---|
readonly node: Node | Returns this rope's underlying scene node (returns this). |
config: RopeConfig | Configuration for procedural curve generation. |
Rope: methods
| Member | Description |
|---|---|
setPoints(points: Float32Array | Array<float>): void | Replaces the rope's polyline points. |
update(): void | Recomputes the curve path from the rope's config and updates vertices. |
RopeConfig
ts
class RopeConfigConfiguration options for constructing and updating a Rope mesh.
RopeConfig: properties
| Member | Description |
|---|---|
width?: float | Width of the rope ribbon in pixels. |
joinMode?: int | Corner join mode: RopeJoinMode.MITER (0) or RopeJoinMode.BEVEL (1). |
curveMode?: int | Curve algorithm: one of RopeCurveMode constants (0..5). |
segments?: int | Number of curve subdivisions (default 20). |
start?: Vec2 | Start point of the curve. |
end?: Vec2 | End point of the curve. |
sag?: float | Sag offset in pixels for catenary curves. |
control0?: Vec2 | First control point for Bezier curves. |
control1?: Vec2 | Second control point for cubic Bezier curves. |
amplitude?: float | Wave amplitude in pixels for wave curves. |
frequency?: float | Wave frequency in cycles for wave curves. |
phase?: float | Wave phase offset in radians for wave curves. |
color?: Color | Vertex tint colour. |
RopeJoinMode
ts
class RopeJoinModeControls how segment corners join in a Rope mesh.
RopeJoinMode: static properties
| Member | Description |
|---|---|
static readonly MITER: int | Miter join: outer corner vertices are extended to meet. |
static readonly BEVEL: int | Bevel join: outer corners are square without extension. |
RopeCurveMode
ts
class RopeCurveModeSelects the curve algorithm used to compute rope segment vertices.
RopeCurveMode: static properties
| Member | Description |
|---|---|
static readonly LINE: int | Linear interpolation between start and end. |
static readonly CATENARY: int | Catenary curve with sag. |
static readonly QUAD_BEZIER: int | Quadratic Bezier curve using control0. |
static readonly CUBIC_BEZIER: int | Cubic Bezier curve using control0 and control1. |
static readonly WAVE: int | Sine wave along the segment between start and end. |
static readonly CUSTOM: int | Custom curve callback. |
DistortionGrid
ts
class DistortionGrid extends NodeExtends Node.
Deformable grid mesh that can be deformed per-vertex from its rest position.
DistortionGrid: constructors
ts
new DistortionGrid(texture: Texture | TextureRegion, cols: int, rows: int)Creates a grid mesh over texture with cols columns and rows rows.
DistortionGrid: properties
| Member | Description |
|---|---|
readonly cols: int | Number of grid cell columns. |
readonly rows: int | Number of grid cell rows. |
readonly node: Node | Returns this grid's underlying scene node (returns this). |
DistortionGrid: methods
| Member | Description |
|---|---|
setVertex(col: int, row: int, dx: float, dy: float): void | Offsets a single grid vertex at (col, row) by (dx, dy) from its rest position. |
setPoint(col: int, row: int, dx: float, dy: float): void | Offsets a single grid vertex at (col, row) by (dx, dy) from its rest position. |
reset(): void | Resets all grid vertices to their original rest positions. |