Skip to content
Konjure / spatial intelligence

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

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.

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.