Klorad SDK · 0.2

Build digital twins on an Earth anchored world model.

A scene anchored on a real place, objects that mirror physical things, readings ordered by when they happened, and Actions that only the right people can take. In TypeScript, with React bindings and a three.js renderer, for the developers of Klorad customers and partners and the agents they work with.

twin.ts
import { createScene } from "@klorad/api/world";
import { connectSource, fixtureSource } from "@klorad/api/integration";

// Space: every scene is anchored on Earth.
const scene = createScene({ coordinateSystem: { origin: { lat: 40.62637, lon: 22.94838 } } });

// Physical correspondence: a Digital Shadow bound to a sensor.
scene.add({
  id: "entrance",
  name: "Entrance counter",
  position: { east: 16, north: -10 },
  correspondence: "shadow",
  binding: { source: "gateway", entity: "entrance-01" },
});

// Integration: readings flow one way, from the source into the shadow.
connectSource(scene, fixtureSource({
  id: "gateway",
  channels: [{ entity: "entrance-01", quantity: "occupancy", unit: "people", value: (t) => 20 + (t % 7) }],
}));

// Time: the current state is the reading observed last, not the one that arrived last.
const label = document.getElementById("occupancy")!;
scene.subscribe(() => (label.textContent = `${scene.latest("entrance", "occupancy")?.value ?? "?"} people inside`));

Where to go

Packages