@nightmarket/sanwei
v0.3.0
Published
Three.js / WebGPU scene engine — managers, postprocessing, and debug tooling.
Maintainers
Readme
@nightmarket/sanwei
Three.js / WebGPU scene engine — managers, postprocessing, input, and optional debug tooling via @nightmarket/tiao.
Install
npm install @nightmarket/sanwei threeFor the debug pane:
npm install @nightmarket/tiaoUsage
Import from the renderer-specific entry point so THREE is bound correctly:
// WebGL
import { Manager, CameraManager, THREE } from "@nightmarket/sanwei/three";
// WebGPU
import { Manager, CameraManager, THREE } from "@nightmarket/sanwei/three-webgpu";Core utilities that do not depend on a THREE binding:
import { Input, RAF, UIEmitter } from "@nightmarket/sanwei";Debug
Debugging is enabled automatically when NODE_ENV !== "production" and disabled
in production. App code should not branch on an environment variable.
Debug.init() is agnostic: it creates one generalized Inspector pane with Performance monitors (FPS / CPU / GPU / draw calls). Apps add their own folders, bindings, or extra panes on top.
The runtime facade is safe to import normally. The package export resolves to the full lazy runtime in development and a no-op module in production, so tiao is absent from production bundles:
import { Debug } from "@nightmarket/sanwei/debug-runtime";
import { Manager } from "@nightmarket/sanwei/three";
await Manager.init({
canvas,
renderer,
initDebug: () =>
Debug.init({
renderer,
setup: ({ pane }) => {
const folder = pane.addFolder({ title: "My Controls" });
return () => folder.dispose();
},
}),
});Components can contribute controls before or after initialization without polling:
const dispose = Debug.setup(({ pane }) => {
const folder = pane.addFolder({ title: "Physics" });
// add bindings...
return () => folder.dispose();
});Other entry points
| Export | Description |
| --- | --- |
| @nightmarket/sanwei/constants | Shared constants and gates (isDebugEnabled(), pass types, …) |
| @nightmarket/sanwei/debug | DebugContext helper types (no runtime) |
| @nightmarket/sanwei/debug-runtime | Development-only Debug facade |
| @nightmarket/sanwei/util/* | Utilities (camera, viewport, bindings, …) |
| @nightmarket/sanwei/extras/* | Optional extras (Physics, Synth, ScreenQuad, …) |
This package ships TypeScript source and is meant to be consumed by a bundler (Vite, Next.js, etc.). GLTF Draco/Basis paths in AssetManager are relative to the app (./libs/draco/, ./libs/basis/).
Publish
pnpm install
pnpm run publish:packageLicense
MIT
