Skip to content
Konjure / spatial intelligence
Browse docs

Rust, web, Unity & Python

Choose a host language without reimplementing the scene semantics.

Rust

Add konjure-sdk as a path dependency from a source checkout. The standalone runtime API does not require any renderer.

Sourcerust
use konjure_sdk::{compile, Runtime};

let scene = compile("scene demo { node signal { sphere 0.2m; } }")?;
let runtime = Runtime::new(scene)?;
let frame = runtime.sample(2.0)?;
println!("{} draws", frame.draws.len());
# Ok::<(), konjure_sdk::Diagnostic>(())

Web and Astro

konjure-web is the Rust browser adapter: it owns capability queries and the validated presentation clock. Its Rust API is included in this site. konjure-wasm supplies generated JavaScript bindings; @konjure/web adds the existing Three.js renderer and DOM controls. The browser adapter is a foundation for Rust browser applications, not a replacement for Astro or a general-purpose UI framework.

For numeric data, LanguageRuntime.tensor_bytes(name) returns an owned Uint8Array in logical row-major, little-endian order. tensor_metadata_json(name) supplies dtype, dimensions and byte length. Use a matching typed array on little-endian hosts or DataView with explicit endianness. u128, i128, f16 and f128 need dtype-aware readers; do not reinterpret them as JavaScript numbers. Diagnostic snapshots keep exact strings.

Run npm ci and npm run sdk:wasm at the repository root. The @konjure/web workspace package adapts the compiled Rust runtime to a canvas.

Sourcetypescript
import { KonjureView } from '@konjure/web';

const view = await KonjureView.create({
  canvas,
  moduleUrl: '/sdk/konjure_wasm.js',
});
view.load(source);
view.setPlaying(true);
// When the component is removed:
await view.dispose();

Serve the wasm-bindgen JS and WASM files together. Compile and upload geometry once, then consume one packed matrix/color buffer per frame. Keep the runtime out of server-rendered code; hydrate the interactive component when needed. This website is a working Astro consumer of the same package.

Blender

The Blender 5.2 extension exchanges evaluated .konjure snapshots through file import/export or the loopback kj-blender bridge. Importing into Kreate creates bounded editable source: a main module for transforms, materials and local hierarchy, plus generated geometry_N modules for baked triangle meshes. Positions and normals round into the language’s Tensor[f32] buffers; transform values retain Number/f64 precision. Imports reject over-large or unsupported bundles rather than simplifying them silently.

This is snapshot exchange, not modifier, texture, custom shader, animation or procedural-graph synchronization. Keep the .blend and Kreate source project for the editable information outside the snapshot. See the Blender guide.

Unity / C#

The UPM package lives at packages/unity. Build the native library with:

Sourcesh
bash scripts/build-sdk-native.sh

Follow that package’s README for plugin placement and supported CPU/OS targets. Its C# facade uses P/Invoke and explicit disposal. The scene component consumes Rust mesh/frame batches, applies the coordinate reflection, and lets Unity render them. It does not translate DSL to a second behavior language.

Unity native and Unity Web are different integration paths. Unity Web’s Emscripten plugin pipeline is not supplied by the browser wasm32-unknown-unknown bundle. The Unity 2022.3 Editor has executed native compile/sample/dispatch/dispose against the built library. A rendered player and each target platform still need release validation.

Python

The dependency-free packages/python package uses ctypes over the same native C ABI. Build the library, install the package from the checkout, and use its context-managed runtime. See the package README for the library path and executable example.

Use Python to connect simulation environments or model tooling. Keep domain decisions in Rust and convert the environment’s units and frames explicitly at the adapter boundary.

C ABI ownership

The ABI provides versioned, generation-checked handles and caller-owned buffers. A disposed handle cannot be reused as a current runtime. Required lengths exclude a NUL terminator. Errors are returned into per-call buffers. Insufficient capacity for an action response must not execute the action; the native regression suite verifies this behavior.

Callers must supply valid pointers and buffers as specified in the generated header. Panic containment is not a memory-safety boundary for an invalid foreign pointer.