TypeScript / JavaScript API Reference for the WASM binding.
Geometry Class
The Geometry class is the central data structure. It holds points,
vertices, primitives, typed attributes, and groups. Most SOP functions accept
and return Geometry instances.
new Geometry() constructor
new pg.Geometry() → Geometry
Create an empty geometry with no points or primitives.
const geo = new pg.Geometry();
addPoint method
geo.addPoint(x: number, y: number, z: number) → number
Add a point at the given position. Returns the new point index.
const ptIdx = geo.addPoint(1.0, 2.0, 3.0);
setPointPos method
geo.setPointPos(index: number, x: number, y: number, z: number) → void
Set the position of an existing point by index.
geo.setPointPos(0, 5.0, 0.0, 0.0);
addFace method
geo.addFace(pointIndices: number[]) → number
Add a polygon face from an array of point indices. Returns the new primitive index.
const p0 = geo.addPoint(0, 0, 0);
const p1 = geo.addPoint(1, 0, 0);
const p2 = geo.addPoint(1, 1, 0);
const primIdx = geo.addFace([p0, p1, p2]);
addPolyline method
geo.addPolyline(pointIndices: number[]) → number
Add an open polyline from an array of point indices. Returns the new primitive index.
const lineIdx = geo.addPolyline([p0, p1, p2]);
numPoints getter
geo.numPoints → number
The total number of points in the geometry (readonly).
numPrims getter
geo.numPrims → number
The total number of primitives in the geometry (readonly).
numVertices getter
geo.numVertices → number
The total number of vertices in the geometry (readonly).
pointPos method
geo.pointPos(index: number) → [x, y, z]
Get the position of a point as a 3-element array.
const [x, y, z] = geo.pointPos(0);
boundingBox method
geo.boundingBox() → { min: [x,y,z], max: [x,y,z] }
Compute the axis-aligned bounding box of all points.
const bbox = geo.boundingBox();
console.log(bbox.min, bbox.max);
getPositions method
geo.getPositions() → Float32Array
Get all point positions as a flat interleaved array (x,y,z,x,y,z,...). Suitable for GPU upload.
const positions = geo.getPositions();
// positions.length === geo.numPoints * 3
getTriangleIndices method
geo.getTriangleIndices() → Uint32Array
Triangulate all polygon faces and return the index buffer. Suitable for GPU upload.
const indices = geo.getTriangleIndices();
getNormals method
geo.getNormals() → Float32Array | undefined
Get vertex normals as a flat array, or undefined if no normal attribute exists.
const normals = geo.getNormals();
if (normals) {
bufferGeometry.setAttribute('normal', new THREE.BufferAttribute(normals, 3));
}
getColors method
geo.getColors() → Float32Array | undefined
Get vertex colors (Cd) as a flat array, or undefined if no color attribute exists.
const colors = geo.getColors();
if (colors) {
bufferGeometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
}
attribNames method
geo.attribNames(attribClass: string) → string[]
List attribute names for a given class ("point", "vertex", "primitive", "detail").
const pointAttribs = geo.attribNames("point");
// e.g. ["N", "Cd", "uv"]
attribType method
geo.attribType(attribClass: string, name: string) → string
Get the type of an attribute (e.g. "Float", "Int", "Vector3", "String").
attribSize method
geo.attribSize(attribClass: string, name: string) → number
Get the component count of an attribute (e.g. 3 for Vector3, 1 for Float).
attribData method
geo.attribData(attribClass: string, name: string) → Float32Array
Get the raw numeric data of an attribute as a flat Float32Array.
const uvs = geo.attribData("vertex", "uv");
bufferGeometry.setAttribute('uv', new THREE.BufferAttribute(uvs, 2));
attribDataString method
geo.attribDataString(attribClass: string, name: string) → string[]
Get the values of a string attribute as an array of strings.
primPointIndices method
geo.primPointIndices(primIndex: number) → number[]
Get the point indices for a specific primitive.
const pts = geo.primPointIndices(0);
// e.g. [0, 1, 2, 3] for a quad
primVertexCount method
geo.primVertexCount(primIndex: number) → number
Get the number of vertices in a specific primitive.
vertexPoint method
geo.vertexPoint(vertexIndex: number) → number
Get the point index that a vertex references.
toObj method
geo.toObj() → string
Serialize the geometry to Wavefront OBJ format.
const objString = geo.toObj();
download("model.obj", objString);
toGlb method
geo.toGlb() → Uint8Array
Serialize the geometry to binary glTF (GLB) format.
const glbBytes = geo.toGlb();
const blob = new Blob([glbBytes], { type: "model/gltf-binary" });
SOPs — Creation
Creation SOPs generate new geometry from parameters alone. They take no geometry input.
createBox creation
pg.createBox(params?) → Geometry
Create an axis-aligned box centered at a given position.
| Param | Type | Default | Description |
size | [w, h, d] | [1, 1, 1] | Width, height, and depth of the box |
center | [x, y, z] | [0, 0, 0] | Center position |
let geo = pg.createBox({ size: [2, 1, 3], center: [0, 0.5, 0] });
createGrid creation
pg.createGrid(params?) → Geometry
Create a planar polygon grid.
| Param | Type | Default | Description |
rows | number | 2 | Number of rows |
cols | number | 2 | Number of columns |
sizeX | number | 1 | Size along the X axis |
sizeY | number | 1 | Size along the Y axis |
orientation | string | "xz" | Plane orientation: xz | xy | yz |
let grid = pg.createGrid({ rows: 10, cols: 10, sizeX: 5, sizeY: 5 });
createSphere creation
pg.createSphere(params?) → Geometry
Create a UV sphere.
| Param | Type | Default | Description |
radius | number | 0.5 | Sphere radius |
rows | number | 12 | Number of latitude rows |
cols | number | 24 | Number of longitude columns |
center | [x, y, z] | [0, 0, 0] | Center position |
let sphere = pg.createSphere({ radius: 2, rows: 24, cols: 48 });
createTube creation
pg.createTube(params?) → Geometry
Create a tube (cylinder or cone when radii differ).
| Param | Type | Default | Description |
radiusBottom | number | 0.5 | Bottom radius |
radiusTop | number | 0.5 | Top radius (set to 0 for a cone) |
height | number | 1 | Height of the tube |
rows | number | 1 | Number of height divisions |
cols | number | 12 | Number of radial divisions |
caps | boolean | true | Generate end caps |
let cone = pg.createTube({ radiusBottom: 1, radiusTop: 0, height: 2 });
createTorus creation
pg.createTorus(params?) → Geometry
Create a torus (donut shape).
| Param | Type | Default | Description |
radiusOuter | number | 1.0 | Distance from center to tube center |
radiusInner | number | 0.3 | Tube cross-section radius |
rows | number | 12 | Tube cross-section divisions |
cols | number | 24 | Radial divisions around the ring |
center | [x, y, z] | [0, 0, 0] | Center position |
let torus = pg.createTorus({ radiusOuter: 2, radiusInner: 0.5, rows: 24, cols: 48 });
createCircle creation
pg.createCircle(params?) → Geometry
Create a circle (closed polyline in the XZ plane).
| Param | Type | Default | Description |
radius | number | 1.0 | Circle radius |
divisions | number | 12 | Number of segments |
center | [x, y, z] | [0, 0, 0] | Center position |
let circle = pg.createCircle({ radius: 3, divisions: 32 });
createLine creation
pg.createLine(params?) → Geometry
Create a straight line (polyline) between two points.
| Param | Type | Default | Description |
origin | [x, y, z] | [0, 0, 0] | Start position |
direction | [x, y, z] | [0, 1, 0] | Direction vector |
length | number | 1.0 | Length of the line |
points | number | 2 | Number of points along the line |
let line = pg.createLine({ origin: [0, 0, 0], direction: [1, 0, 0], length: 5, points: 10 });
SOPs — Topology
Topology SOPs modify mesh connectivity, create new primitives, or combine geometries.
polyExtrude topology
pg.polyExtrude(geo, params?) → Geometry
Extrude polygon faces along their normals.
| Param | Type | Default | Description |
distance | number | 0.5 | Extrusion distance |
inset | number | 0.0 | Inset amount before extruding |
outputFront | boolean | true | Output the extruded front face |
outputSide | boolean | true | Output the side faces |
geo = pg.polyExtrude(geo, { distance: 0.5, inset: 0.1 });
polyBevel topology
pg.polyBevel(geo, params?) → Geometry
Bevel polygon edges to create chamfers or rounded edges.
| Param | Type | Default | Description |
offset | number | 0.1 | Bevel offset distance |
divisions | number | 1 | Number of bevel subdivisions |
geo = pg.polyBevel(geo, { offset: 0.05, divisions: 3 });
polyWire topology
pg.polyWire(geo, params?) → Geometry
Convert edges or polylines into tubes (wireframe mesh).
| Param | Type | Default | Description |
radius | number | 0.02 | Wire tube radius |
divisions | number | 4 | Radial divisions of the tube |
let wireframe = pg.polyWire(geo, { radius: 0.05, divisions: 6 });
polyFill topology
pg.polyFill(geo, params?) → Geometry
Fill open holes in geometry with polygons.
| Param | Type | Default | Description |
mode | string | "fan" | Fill mode: single | fan |
smooth | boolean | false | Smooth the filled surface |
geo = pg.polyFill(geo, { mode: "fan" });
polyReduce topology
pg.polyReduce(geo, params?) → Geometry
Reduce polygon count while preserving shape.
| Param | Type | Default | Description |
targetPercent | number | 50.0 | Target polygon count as percentage of original |
preserveBoundaries | boolean | true | Preserve boundary edges |
geo = pg.polyReduce(geo, { targetPercent: 25 });
clip topology
pg.clip(geo, params?) → Geometry
Clip geometry with an infinite plane.
| Param | Type | Default | Description |
origin | [x, y, z] | [0, 0, 0] | A point on the clipping plane |
normal | [x, y, z] | [0, 1, 0] | Plane normal direction |
keepAbove | boolean | true | Keep the geometry above the plane |
geo = pg.clip(geo, { origin: [0, 0.5, 0], normal: [0, 1, 0] });
fuse topology
pg.fuse(geo, params?) → Geometry
Merge points that are within a given distance threshold.
| Param | Type | Default | Description |
distance | number | 0.001 | Maximum distance to merge points |
geo = pg.fuse(geo, { distance: 0.01 });
reverse topology
pg.reverse(geo) → Geometry
Reverse the winding order of all polygon faces (flip normals).
geo = pg.reverse(geo);
scatter topology
pg.scatter(geo, params?) → Geometry
Scatter random points on the surface of a mesh.
| Param | Type | Default | Description |
count | number | 100 | Number of points to scatter |
seed | number | 0 | Random seed |
let points = pg.scatter(geo, { count: 500, seed: 42 });
copyToPoints topology
pg.copyToPoints(source, target) → Geometry
Copy source geometry onto every point of the target geometry.
let box = pg.createBox({ size: [0.1, 0.1, 0.1] });
let pts = pg.scatter(pg.createGrid(), { count: 50 });
let instanced = pg.copyToPoints(box, pts);
merge topology
pg.merge(a, b) → Geometry
Merge two geometries into one. Chain calls to merge more than two.
let box = pg.createBox();
let sphere = pg.createSphere();
let merged = pg.merge(box, sphere);
// Merge three:
let third = pg.createTorus();
merged = pg.merge(pg.merge(box, sphere), third);
voronoiFracture topology
pg.voronoiFracture(geo, points, params?) → Geometry
Fracture geometry into Voronoi cells using a set of seed points.
| Param | Type | Default | Description |
cutPlaneOffset | number | 0.0 | Offset for cut planes |
createInsideFaces | boolean | true | Generate interior faces at cut boundaries |
let box = pg.createBox({ size: [2, 2, 2] });
let seeds = pg.scatter(box, { count: 20 });
let fractured = pg.voronoiFracture(box, seeds, { createInsideFaces: true });
SOPs — Utility
Utility SOPs compute derived data, set attributes, or filter elements.
computeNormals utility
pg.computeNormals(geo) → Geometry
Compute smooth vertex normals from face topology. Creates or overwrites the N attribute.
geo = pg.computeNormals(geo);
color utility
pg.color(geo, params?) → Geometry
Set a uniform color on all points. Creates or overwrites the Cd attribute.
| Param | Type | Default | Description |
color | [r, g, b] | [1, 1, 1] | RGB color in 0–1 range |
geo = pg.color(geo, { color: [0.2, 0.6, 1.0] });
blast utility
pg.blast(geo, params) → Geometry
Delete primitives or points belonging to a named group.
| Param | Type | Default | Description |
groupName | string | — | Name of the group to blast |
entity | string | "primitives" | Entity type: primitives | points |
negate | boolean | false | If true, keep the group and delete everything else |
geo = pg.blast(geo, { groupName: "top_faces", negate: true });
deleteSop utility
pg.deleteSop(geo, params) → Geometry
Delete a range of points or primitives by index.
| Param | Type | Default | Description |
entity | string | — | Entity type: points | primitives |
rangeStart | number | — | Start of the range (inclusive) |
rangeEnd | number | — | End of the range (exclusive) |
geo = pg.deleteSop(geo, { entity: "primitives", rangeStart: 0, rangeEnd: 5 });
sort utility
pg.sort(geo, params?) → Geometry
Randomly reorder primitives using a seed.
| Param | Type | Default | Description |
seed | number | 0 | Random seed for shuffling |
geo = pg.sort(geo, { seed: 42 });
connectivity utility
pg.connectivity(geo, params?) → Geometry
Assign a class attribute to each connected component.
| Param | Type | Default | Description |
attribName | string | "class" | Name of the output attribute |
geo = pg.connectivity(geo);
// Each primitive now has a "class" attribute
enumerateAttrib utility
pg.enumerateAttrib(geo, params?) → Geometry
Add a sequential integer attribute to each element.
| Param | Type | Default | Description |
name | string | "id" | Attribute name |
start | number | 0 | Starting value |
geo = pg.enumerateAttrib(geo, { name: "id", start: 0 });
measure utility
pg.measure(geo, params?) → Geometry
Compute face areas and store as a primitive attribute.
| Param | Type | Default | Description |
attribName | string | "area" | Name of the output attribute |
geo = pg.measure(geo, { attribName: "area" });
SOPs — Attributes
Attribute SOPs create, modify, transfer, and query typed attributes on geometry elements.
attribCreate attributes
pg.attribCreate(geo, params) → Geometry
Create a new attribute with a constant initial value.
| Param | Type | Default | Description |
name | string | — | Attribute name |
class | string | "point" | Attribute class: point | vertex | primitive | detail |
attribType | string | "Float" | Data type: Float | Int | Vector3 | String |
valueFloat | number | — | Default value for Float type |
valueInt | number | — | Default value for Int type |
valueVector3 | [x, y, z] | — | Default value for Vector3 type |
valueString | string | — | Default value for String type |
geo = pg.attribCreate(geo, { name: "density", attribType: "Float", valueFloat: 1.0 });
geo = pg.attribCreate(geo, {
name: "up", class: "point", attribType: "Vector3", valueVector3: [0, 1, 0]
});
attribDelete attributes
pg.attribDelete(geo, params) → Geometry
Remove an attribute from geometry.
| Param | Type | Default | Description |
name | string | — | Attribute name to delete |
class | string | "point" | Attribute class |
geo = pg.attribDelete(geo, { name: "temp_data", class: "point" });
attribRename attributes
pg.attribRename(geo, params) → Geometry
Rename an existing attribute.
| Param | Type | Default | Description |
fromName | string | — | Current attribute name |
toName | string | — | New attribute name |
class | string | "point" | Attribute class |
geo = pg.attribRename(geo, { fromName: "Cd", toName: "base_color" });
attribNoise attributes
pg.attribNoise(geo, params?) → Geometry
Generate noise values based on point positions and store as an attribute.
| Param | Type | Default | Description |
attribName | string | "noise" | Output attribute name |
noiseType | string | "simplex" | Noise type: simplex | perlin | worley |
elementSize | number | 1.0 | Scale of noise features |
amplitude | number | 1.0 | Output amplitude |
fractal | string | "none" | Fractal mode |
octaves | number | 4 | Number of fractal octaves |
operation | string | "set" | How to apply: set | add | multiply |
geo = pg.attribNoise(geo, {
attribName: "height",
noiseType: "simplex",
elementSize: 2.0,
amplitude: 0.5
});
attribRandomize attributes
pg.attribRandomize(geo, params?) → Geometry
Assign random values to an attribute.
| Param | Type | Default | Description |
attribName | string | "rand" | Output attribute name |
class | string | "point" | Attribute class |
attribType | string | "Float" | Data type |
distribution | string | "uniform" | Distribution type |
seed | number | 0 | Random seed |
minValue | number | 0.0 | Minimum value |
maxValue | number | 1.0 | Maximum value |
globalScale | number | 1.0 | Global scale factor |
geo = pg.attribRandomize(geo, {
attribName: "pscale", seed: 42, minValue: 0.5, maxValue: 2.0
});
attribTransfer attributes
pg.attribTransfer(dest, source, params) → Geometry
Transfer an attribute from source geometry to destination geometry using proximity.
| Param | Type | Default | Description |
attribName | string | — | Name of the attribute to transfer |
class | string | — | Attribute class |
attribType | string | — | Attribute data type |
maxSamples | number | 1 | Max nearest points to sample |
distanceThreshold | number | 1.0 | Max transfer distance |
geo = pg.attribTransfer(destGeo, sourceGeo, {
attribName: "Cd", class: "point", attribType: "Vector3"
});
attribCopy attributes
pg.attribCopy(dest, source?, params) → Geometry
Copy an attribute within the same geometry or from another geometry.
| Param | Type | Default | Description |
attribName | string | — | Source attribute name |
class | string | — | Attribute class |
newName | string | — | Name for the copied attribute |
geo = pg.attribCopy(geo, null, {
attribName: "Cd", class: "point", newName: "Cd_backup"
});
attribSort attributes
pg.attribSort(geo, params) → Geometry
Sort elements by an attribute value.
| Param | Type | Default | Description |
attribName | string | — | Attribute to sort by |
order | string | "Ascending" | Sort order: Ascending | Descending |
geo = pg.attribSort(geo, { attribName: "area", order: "Descending" });
attribBlur attributes
pg.attribBlur(geo, params) → Geometry
Smooth an attribute across neighboring elements using diffusion.
| Param | Type | Default | Description |
attribName | string | — | Attribute to blur |
iterations | number | 1 | Number of blur passes |
stepSize | number | 0.5 | Blend factor per pass |
geo = pg.attribBlur(geo, { attribName: "noise", iterations: 5, stepSize: 0.3 });
attribFill attributes
pg.attribFill(geo, params) → Geometry
Fill attribute values by diffusing from boundary elements inward.
| Param | Type | Default | Description |
attribName | string | — | Attribute to fill |
boundaryGroup | string | — | Group defining boundary elements |
iterations | number | 10 | Number of diffusion iterations |
stepSize | number | 1.0 | Diffusion step size |
geo = pg.attribFill(geo, {
attribName: "temperature", boundaryGroup: "edges", iterations: 20
});
COPs — Generators
COP generator functions create images from scratch. All return a CopImage.
You must call await pg.initCopGpu() once before using any COP function. This initializes the WebGPU backend.
copConstant generator
pg.copConstant(params?) → CopImage
Create a solid-color image.
| Param | Type | Default | Description |
color | [r, g, b, a] | [0, 0, 0, 1] | RGBA fill color (0–1) |
width | number | 256 | Image width in pixels |
height | number | 256 | Image height in pixels |
await pg.initCopGpu();
let img = pg.copConstant({ color: [1, 0, 0, 1], width: 512, height: 512 });
copCheckerboard generator
pg.copCheckerboard(params?) → CopImage
Generate a checkerboard pattern.
| Param | Type | Default | Description |
colorA | [r, g, b, a] | — | First checker color |
colorB | [r, g, b, a] | — | Second checker color |
frequency | [x, y] | [8, 8] | Number of checks per axis |
width | number | 256 | Image width |
height | number | 256 | Image height |
let checker = pg.copCheckerboard({
colorA: [1, 1, 1, 1], colorB: [0, 0, 0, 1], frequency: [16, 16]
});
copNoise generator
pg.copNoise(params?) → CopImage
Generate a 2D noise texture.
| Param | Type | Default | Description |
noiseType | string | "perlin" | Noise type: perlin | simplex | worley |
frequency | number | 4.0 | Base frequency |
octaves | number | 4 | Number of octaves |
lacunarity | number | 2.0 | Frequency multiplier per octave |
gain | number | 0.5 | Amplitude multiplier per octave |
amplitude | number | 1.0 | Overall amplitude |
offset | [x, y] | — | Noise space offset |
seed | number | — | Random seed |
width | number | 256 | Image width |
height | number | 256 | Image height |
let noise = pg.copNoise({
noiseType: "simplex", frequency: 8, octaves: 6, width: 512, height: 512
});
copRamp generator
pg.copRamp(params?) → CopImage
Generate a gradient ramp image.
| Param | Type | Default | Description |
rampType | string | "linear" | Ramp shape: linear | radial | box | diagonal |
stops | [{position, color}] | — | Array of color stops with position (0–1) and RGBA color |
width | number | 256 | Image width |
height | number | 256 | Image height |
let ramp = pg.copRamp({
rampType: "radial",
stops: [
{ position: 0.0, color: [1, 1, 1, 1] },
{ position: 1.0, color: [0, 0, 0, 1] }
]
});
copLoadImage generator
pg.copLoadImage(params) → CopImage
Load an image from a URL or path.
| Param | Type | Default | Description |
path | string | — | URL or file path to load |
let img = pg.copLoadImage({ path: "/textures/diffuse.png" });
COPs — Filters
COP filter functions process an existing image and return a new CopImage.
copBlur filter
pg.copBlur(image, params?) → CopImage
Blur an image with a Gaussian or box kernel.
| Param | Type | Default | Description |
blurType | string | "gaussian" | Blur kernel: gaussian | box |
radiusX | number | 4.0 | Horizontal blur radius |
radiusY | number | 4.0 | Vertical blur radius |
let blurred = pg.copBlur(img, { blurType: "gaussian", radiusX: 8, radiusY: 8 });
copFlip filter
pg.copFlip(image, params?) → CopImage
Flip an image horizontally and/or vertically.
| Param | Type | Default | Description |
horizontal | boolean | false | Flip horizontally |
vertical | boolean | true | Flip vertically |
let flipped = pg.copFlip(img, { horizontal: true, vertical: false });
copMirror filter
pg.copMirror(image, params?) → CopImage
Mirror an image along an axis.
| Param | Type | Default | Description |
axis | string | "x" | Mirror axis: x | y |
offset | number | 0.5 | Mirror line position (0–1) |
let mirrored = pg.copMirror(img, { axis: "x", offset: 0.5 });
copChannelSwap filter
pg.copChannelSwap(image, params) → CopImage
Remap color channels.
| Param | Type | Default | Description |
r | string | — | Source for red: r | g | b | a | one | zero |
g | string | — | Source for green |
b | string | — | Source for blue |
a | string | — | Source for alpha |
// Convert to grayscale by using red channel for all
let gray = pg.copChannelSwap(img, { r: "r", g: "r", b: "r", a: "one" });
copResize filter
pg.copResize(image, params) → CopImage
Resize an image to new dimensions.
| Param | Type | Default | Description |
width | number | — | Target width |
height | number | — | Target height |
filter | string | "nearest" | Resize filter: nearest | bilinear |
let small = pg.copResize(img, { width: 128, height: 128, filter: "bilinear" });
copRotate filter
pg.copRotate(image, params?) → CopImage
Rotate an image around a center point.
| Param | Type | Default | Description |
angle | number | 0 | Rotation angle in degrees |
center | [x, y] | [0.5, 0.5] | Rotation center (normalized) |
filter | string | — | Sampling filter |
let rotated = pg.copRotate(img, { angle: 45 });
copSwirl filter
pg.copSwirl(image, params?) → CopImage
Apply a swirl distortion to an image.
| Param | Type | Default | Description |
center | [x, y] | [0.5, 0.5] | Swirl center (normalized) |
angle | number | 90 | Maximum rotation angle in degrees |
radius | number | 0.5 | Effect radius (normalized) |
let swirled = pg.copSwirl(img, { angle: 180, radius: 0.4 });
I/O & Registry
The registry functions provide a dynamic, name-based interface to all SOPs and COPs.
Useful for building UIs, scripting systems, or executing operators by name at runtime.
executeSop registry
pg.executeSop(name, geo, params?) → Geometry
Execute any registered SOP by name. Params use snake_case keys.
let geo = pg.createBox();
geo = pg.executeSop("subdivide", geo, { depth: 2, mode: "catmull_clark" });
executeSopCreate registry
pg.executeSopCreate(name, params?) → Geometry
Execute a creation SOP by name (no geometry input required).
let geo = pg.executeSopCreate("box", { size: [2, 2, 2] });
listSops registry
pg.listSops() → string[]
List all registered SOP names.
const sops = pg.listSops();
// ["box", "grid", "sphere", "tube", "torus", "circle", "line", ...]
executeCopCreate registry
pg.executeCopCreate(name, params?) → CopImage
Execute a COP generator by name.
let img = pg.executeCopCreate("noise", { frequency: 8 });
executeCop registry
pg.executeCop(name, image, params?) → CopImage
Execute a COP filter by name on an existing image.
let blurred = pg.executeCop("blur", img, { radius_x: 4, radius_y: 4 });
executeCopComposite registry
pg.executeCopComposite(name, a, b, params?) → CopImage
Execute a COP composite operation by name.
let result = pg.executeCopComposite("composite", imgA, imgB, { operation: "add" });
listCops registry
pg.listCops() → string[]
List all registered COP names.
const cops = pg.listCops();
// ["constant", "checkerboard", "noise", "ramp", "blur", ...]
initCopGpu registry
await pg.initCopGpu() → void
Initialize the WebGPU backend for COP operations. Must be awaited before calling any COP function.
await pg.initCopGpu();
toObj i/o
geo.toObj() → string
Export geometry to Wavefront OBJ format string.
const objData = geo.toObj();
toGlb i/o
geo.toGlb() → Uint8Array
Export geometry to binary glTF (GLB) format.
const glb = geo.toGlb();
const blob = new Blob([glb], { type: "model/gltf-binary" });
const url = URL.createObjectURL(blob);