MotionScript

@motion-script/core


@motion-script/core / ParametricGeometry3D

Interface: ParametricGeometry3D

Defined in: render3d/geometry.ts:234

A surface sampled over a [0,1] × [0,1] grid — the ergonomic form of BufferGeometry3D for procedural meshes (waves, terrain, ribbons).

Core evaluates the callbacks into vertex buffers at record time, so the descriptor handed to the renderer is still plain data. Re-evaluated every frame, so read signals and the frame time inside vertex.

Geo.parametric({ segments: [70, 70], vertex: (u, v) => ({ x: (u - 0.5) * 20, y: wave(u, v, t), z: (v - 0.5) * 20 }), computeNormals: true, })

Extends

Properties

color?

optional color?: (u, v, position) => Color

Defined in: render3d/geometry.ts:241

Optional per-vertex colour. Needs vertexColors: true on the material.

Parameters

u

number

v

number

position

Vector3

Returns

Color


computeNormals?

optional computeNormals?: boolean

Defined in: render3d/geometry.ts:243

Derive vertex normals. Almost always wanted for a lit surface.


params?

optional params?: Record<string, unknown>

Defined in: render3d/geometry.ts:14

Inherited from

Passthrough3D.params


revision?

optional revision?: number

Defined in: render3d/geometry.ts:265

A value that changes exactly when vertex would return something different — supply it and the surface is re-evaluated only when it moves.

Omitted (the default) the surface is re-evaluated every frame, which is what makes the read signals and the frame time inside vertex contract above work without any bookkeeping. It is also expensive: segments: 80 is ~6.6k calls to vertex, plus normals and a full buffer re-upload, and a frame draws for any reason at all — an unrelated node being dragged, the camera orbiting, a tween elsewhere in the scene. A surface whose shape did not change pays all of that for an identical result.

vertex is a closure, so the renderer cannot inspect what it captured; only the author knows. Derive this from exactly those captures — the domain, the amplitude, the identity of the function being plotted — and leave it out for a surface that genuinely varies with time.

Same name and same role as BufferGeometry3D.revision: the explicit "this is what changed" signal. segments needs no help here, being plain data the renderer already compares.


segments

segments: number | readonly [number, number]

Defined in: render3d/geometry.ts:237

Grid resolution as [uSegments, vSegments], or one number for both.


type

type: "parametric"

Defined in: render3d/geometry.ts:235


vertex

vertex: (u, v) => ParametricVertex3D

Defined in: render3d/geometry.ts:239

Position for grid coordinate (u, v), both in [0, 1].

Parameters

u

number

v

number

Returns

ParametricVertex3D