Skip to content
Konjure / spatial intelligence
Browse docs

Mesh

← Builtin reference

Indexed triangle geometry.

Signature

type Mesh { positions: Tensor[f32] = tensor[f32]([], [0, 3])?; normals: Tensor[f32] = tensor[f32]([], [0, 3])?; indices: Tensor[u32] = tensor[u32]([], [0, 3])?; }

The spatial adapter requires 3..=16384 positions and 1..=32768 triangles, validates indices, and computes normals when it builds a render mesh.

Fields

positions: Tensor[f32]
An N by 3 Tensor[f32] of local XYZ coordinates in meters. The empty default is not renderable.
Defaulttensor[f32]([], [0, 3])?
normals: Tensor[f32]
An optional N by 3 Tensor[f32] of nonzero local vertex normals. When empty, the spatial adapter derives smooth normals from the triangles.
Defaulttensor[f32]([], [0, 3])?
indices: Tensor[u32]
An M by 3 Tensor[u32]; each row is a triangle and every index must address a position.
Defaulttensor[u32]([], [0, 3])?

Methods

sphere

sphere(f64, f64, f64) -> Res[Mesh, DataError]

Returns a bounded procedural Mesh; dimensions, integer resolution, and topology are validated before buffers are retained.

torus

torus(f64, f64, f64, f64) -> Res[Mesh, DataError]

Returns a bounded procedural Mesh; dimensions, integer resolution, and topology are validated before buffers are retained.

cone

cone(f64, f64, f64) -> Res[Mesh, DataError]

Returns a bounded procedural Mesh; dimensions, integer resolution, and topology are validated before buffers are retained.

grid

grid(f64, f64, f64, f64) -> Res[Mesh, DataError]

Returns a bounded procedural Mesh; dimensions, integer resolution, and topology are validated before buffers are retained.

lathe

lathe(Tensor[f32], f64) -> Res[Mesh, DataError]

Returns a bounded procedural Mesh; dimensions, integer resolution, and topology are validated before buffers are retained.

suzanne

suzanne() -> Res[Mesh, DataError]

Returns a bounded procedural Mesh; dimensions, integer resolution, and topology are validated before buffers are retained.

translated

translated(Vec3) -> Res[Mesh, DataError]

Returns a transformed Mesh with finite coordinates and correctly transformed normals; negative scale reverses winding.

scaled

scaled(Vec3) -> Res[Mesh, DataError]

Returns a transformed Mesh with finite coordinates and correctly transformed normals; negative scale reverses winding.

rotated

rotated(Vec3) -> Res[Mesh, DataError]

Returns a transformed Mesh with finite coordinates and correctly transformed normals; negative scale reverses winding.

mapped

mapped(func(Vec3) -> Res[Vec3, DataError]) -> Res[Mesh, DataError]

Calls the checked mapper once per vertex and returns a Mesh with derived smooth normals; mapper errors reject the whole result.

decode_json

decode_json(List[Str]) -> Res[Mesh, DataError]

Decodes bounded immutable Mesh JSON string chunks without paths, fetching, or code execution; malformed or oversized payloads return DataError.

Examples

Define one triangle

Indices address positions in triples.

More
Tick 0 · 0.00 s
main.kj⌘ / Ctrl + Enter
Loading…Drag to orbit · select to inspect
0 entities
Results
Loading the language runtime…
Output 0
No output.
Expected output
3

Inspect an unfilled schema

Construction itself does not invoke the mesh adapter.

More
Tick 0 · 0.00 s⌘ / Ctrl + Enter
main.kj
Results
Loading the language runtime…
Output 0
No output.
Expected output
0

Rust definition

Interpreter RecordValue geometry schema; adapter validation produces the render mesh.

See also