rhodonite-mbt
v0.1.8
Published
TypeScript wrappers and MoonBit JavaScript bridge for RhodoniteMBT.
Readme
rhodonite-mbt
TypeScript wrapper package for RhodoniteMBT. It includes the existing math, ECS, and browser app runtime wrappers plus the MoonBit JavaScript bridge code they call.
Installation
Install from npm with your package manager:
npm install rhodonite-mbtpnpm add rhodonite-mbtyarn add rhodonite-mbtThis package is ESM-only and is intended for modern TypeScript projects and
bundlers. Use it from browser-capable ESM environments. The package depends on
@webgpu/types for WebGPU TypeScript declarations.
Import paths
The package exposes these entrypoints:
rhodonite-mbt— combined export surfacerhodonite-mbt/math— vector and matrix wrappersrhodonite-mbt/ecs— ECS wrappers and GPU write helpersrhodonite-mbt/app— browser WebGPU app/runtime helpers
Basic math usage
import { Vector3F } from "rhodonite-mbt/math";
const v = Vector3F.new(1, 2, 3);
const doubled = v.scale(2);
console.log(doubled.toString());ECS usage
import { World } from "rhodonite-mbt/ecs";
const world = World.new();
const entity = world.createEntity();
world.addComponent(entity, world.transformComponent());Browser app runtime usage
The app runtime helpers are browser-only and expect WebGPU support.
import {
Engine,
PlatformApp,
PlatformOptions,
runSingleCanvasPlatform,
} from "rhodonite-mbt/app";
const canvas = document.querySelector<HTMLCanvasElement>("#canvas");
if (canvas) {
await runSingleCanvasPlatform(
canvas,
PlatformApp.defaultEngine((engine: Engine) => {
engine.addPhaseHandler("rhodonite/render", (_engine, frame) => {
if (!frame.surface.active) {
return;
}
const encoder = engine.device.createCommandEncoder();
const pass = encoder.beginRenderPass({
colorAttachments: [
{
view: engine.context.getCurrentTexture().createView(),
clearValue: { r: 0.04, g: 0.04, b: 0.05, a: 1 },
loadOp: "clear",
storeOp: "store",
},
],
});
pass.end();
engine.queue.submit([encoder.finish()]);
});
}),
PlatformOptions.interactive(),
);
}If you only need input normalization or frame-loop helpers, import them from
rhodonite-mbt/app directly, for example installBrowserInputState,
startBrowserFrameLoop, or startBrowserOnDemandFrameLoop.
Local package testing
From the RhodoniteMBT repository root, build and pack the npm package with:
pnpm run build:npm
pnpm run pack:npmThen install the generated tarball into another project with your package manager, for example:
pnpm add /path/to/RhodoniteMBT/packages/rhodonite-mbt/rhodonite-mbt-0.1.8.tgzLicense
Apache-2.0. See LICENSE.
