Skip to content

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 Node

Extends 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 ​

MemberDescription
readonly node: NodeReturns this rope's underlying scene node (returns this).
config: RopeConfigConfiguration for procedural curve generation.

Rope: methods ​

MemberDescription
setPoints(points: Float32Array | Array<float>): voidReplaces the rope's polyline points.
update(): voidRecomputes the curve path from the rope's config and updates vertices.

RopeConfig ​

ts
class RopeConfig

Configuration options for constructing and updating a Rope mesh.

RopeConfig: properties ​

MemberDescription
width?: floatWidth of the rope ribbon in pixels.
joinMode?: intCorner join mode: RopeJoinMode.MITER (0) or RopeJoinMode.BEVEL (1).
curveMode?: intCurve algorithm: one of RopeCurveMode constants (0..5).
segments?: intNumber of curve subdivisions (default 20).
start?: Vec2Start point of the curve.
end?: Vec2End point of the curve.
sag?: floatSag offset in pixels for catenary curves.
control0?: Vec2First control point for Bezier curves.
control1?: Vec2Second control point for cubic Bezier curves.
amplitude?: floatWave amplitude in pixels for wave curves.
frequency?: floatWave frequency in cycles for wave curves.
phase?: floatWave phase offset in radians for wave curves.
color?: ColorVertex tint colour.

RopeJoinMode ​

ts
class RopeJoinMode

Controls how segment corners join in a Rope mesh.

RopeJoinMode: static properties ​

MemberDescription
static readonly MITER: intMiter join: outer corner vertices are extended to meet.
static readonly BEVEL: intBevel join: outer corners are square without extension.

RopeCurveMode ​

ts
class RopeCurveMode

Selects the curve algorithm used to compute rope segment vertices.

RopeCurveMode: static properties ​

MemberDescription
static readonly LINE: intLinear interpolation between start and end.
static readonly CATENARY: intCatenary curve with sag.
static readonly QUAD_BEZIER: intQuadratic Bezier curve using control0.
static readonly CUBIC_BEZIER: intCubic Bezier curve using control0 and control1.
static readonly WAVE: intSine wave along the segment between start and end.
static readonly CUSTOM: intCustom curve callback.

DistortionGrid ​

ts
class DistortionGrid extends Node

Extends 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 ​

MemberDescription
readonly cols: intNumber of grid cell columns.
readonly rows: intNumber of grid cell rows.
readonly node: NodeReturns this grid's underlying scene node (returns this).

DistortionGrid: methods ​

MemberDescription
setVertex(col: int, row: int, dx: float, dy: float): voidOffsets a single grid vertex at (col, row) by (dx, dy) from its rest position.
setPoint(col: int, row: int, dx: float, dy: float): voidOffsets a single grid vertex at (col, row) by (dx, dy) from its rest position.
reset(): voidResets all grid vertices to their original rest positions.