Package Exports
- @openfluke/isocard
Readme
isocard
isocard is a lightweight, isomorphic physics + AI scene wrapper built on top of Three.js and Jolt Physics.
It provides a JSON-driven way to define, load, and run physics experiments that can run in both the browser and server environments.
โจ Features
- ๐ Isomorphic runtime โ same code works in browser or server (Node/Bun).
- ๐ฎ Three.js + Jolt Physics integration out of the box.
- ๐ฆ JSON-defined scenes โ easy to save, share, and replay experiments.
- ๐ Deterministic replay โ record inputs and re-run with the same results.
- ๐งฉ Extensible โ wrap with controllers, automation, or AI policies.
- ๐ Headless mode โ run simulations without rendering for server-side compute.
๐ฆ Installation
# with bun
bun add isocard
# or with npm
npm install isocard๐ Usage
Basic Example
import * as THREE from "three";
import { IsoCard } from "isocard";
// dependencies passed into IsoCard
const deps = {
THREE,
// optional: lets IsoCard load Jolt if not available on `window`
loadJolt: async () => (await import("jolt-physics")).default,
};
// create IsoCard instance
const iso = new IsoCard(
{ clientWidth: 800, clientHeight: 600, appendChild() {}, addEventListener() {} } as any,
deps,
{ isPreview: true, isServer: true }
);
// setup physics
await iso.setupJOLT();
iso.loadSceneWithConstraints(JSON.stringify({
objects: [
{ name: "box", shape: "box", size: [1, 1, 1], position: [0, 5, 0], physics: { motionType: "dynamic" } }
]
}));
iso.startPhysics();
iso.startAnimate();
console.log("Simulation running with", iso.dynamicObjects.length, "dynamic objects");๐ Project Structure
src/
isocard.ts # main IsoCard class
index.ts # entrypoint
dist/ # compiled output (published)๐งช Development
Clone and build locally:
git clone https://github.com/openfluke/isocard
cd isocard
bun install
bun run buildTo use it in another local project:
bun link # in isocard repo
bun link isocard # in your test project๐ License
Apache License 2.0 ยฉ 2025 Samuel Watson