Appearance
Scientific geometry
Meshes
const surface = extractIsosurface(field(48, 10, radial), 9);
const mesh = plot.uploadMesh(surface);
plot.showMesh(mesh, [0.85, 0.35, 0.2]);
plot.frameScene();
return { readout: `${(surface.indices.length / 3).toLocaleString("en-GB")} triangles` };Calls
4 in the code above, in the order it makes them
extractIsosurface(field: Field, isovalue: number): SurfaceThe surface through
isovaluein a scalar field, as triangles.Nothing is uploaded and nothing is drawn. The drawn path --
Plot.uploadFieldandPlot.showIsosurface-- triangulates in a compute shader every frame and keeps nothing, which is what makes a dragged isovalue cost a frame rather than an upload, and also why it cannot answer a question about the surface itself. This is the path for those: an area, an intersection, a file to export.An isovalue the field never reaches gives a surface of no triangles rather than an error, so a slider swept past the end of the range makes the surface disappear rather than fail.
plot.uploadMesh(mesh: Mesh): MeshHandleUpload a surface and return a handle naming it.
plot.showMesh(handle: MeshHandle, colour: Colour | Hex): voidDraw the surface
handlenames.plot.frameScene(): voidPoint the camera at the middle of everything uploaded, far enough back to see it.
Call after uploading. A scene measured in grid cells or in millimetres is nowhere near where a camera starts, and without this the first thing a caller sees is an empty canvas.