Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

defineShapeBuilder

defineShapeBuilder<Record, Shape>(name, build): ShapeBuilder<Record, Shape>

Registers build under name and returns the collider shape a record makes: islandShape({ seed: 7 }). Call it at module scope in a module the room and every page import. The builder makes a triangleMesh, a heightfield or voxels from its record alone, as plain numbers, strings and booleans; both ends run it, from the record rounded as the stream rounds numbers, and the room’s hash of the shape it built goes with the record, so a page that builds another shape is named in development. Math that two engines compute to different last digits, such as Math.sin and Math.pow in V8 and in Safari’s engine, is rounded to the dump’s places before the hash, which absorbs most of it. A collider built from one is a fixed body’s, or a kinematic one’s for a triangle mesh.

Type Parameter
Record extends ShapeRecord
Shape extends BuildableShape
Parameter Type
name string
build (record) => Shape

ShapeBuilder<Record, Shape>

export const islandShape = defineShapeBuilder("island", ({ seed }: { seed: number }) => triangleMesh(generateIsland(seed)));