Find and fix what makes a three.js scene slow or broken.
Five small packages that measure, inspect, check and batch three.js scenes. Use one, or all.
- no third-party deps
- vanilla three + R3F
- typed
- MIT
import {
PerformanceMonitor, wrapAnimationLoop,
} from "@zkmake/three-meter";
import { mountPerfHud }
from "@zkmake/three-meter/ui";
const monitor =
new PerformanceMonitor({ renderer });
mountPerfHud(monitor);
renderer.setAnimationLoop(
wrapAnimationLoop(monitor, render),
);import { PerfHud, PerfSampler }
from "@zkmake/three-meter/react";
<>
<Canvas>
<PerfSampler />
{/* scene */}
</Canvas>
<PerfHud />
</>;import { mountTexturePanel }
from "@zkmake/three-textures/ui";
const panel =
mountTexturePanel({ scene, renderer });
// later: panel.dispose()import { TexturePanel }
from "@zkmake/three-textures/react";
<Canvas>
{import.meta.env.DEV && <TexturePanel />}
{/* … */}
</Canvas>;import { mountCameraPanel }
from "@zkmake/three-cameras/ui";
const panel =
mountCameraPanel({ scene, renderer });
// later: panel.dispose()import { CameraPanel }
from "@zkmake/three-cameras/react";
<Canvas>
<CameraPanel />
{/* … */}
</Canvas>;import { findBadGeometry, findZFighting }
from "@zkmake/three-audit";
test("no z-fighting or NaNs", () => {
expect(findZFighting(mill)).toEqual([]);
expect(findBadGeometry(mill)).toEqual([]);
});// No React parts: it runs in tests and CI.
import { findBadGeometry, findZFighting }
from "@zkmake/three-audit";
test("no z-fighting or NaNs", () => {
expect(findZFighting(mill)).toEqual([]);
expect(findBadGeometry(mill)).toEqual([]);
});import { bake, chunkInstances }
from "@zkmake/three-batch";
// dozens of meshes, one draw per material
const undo = bake(station);
// culling cells for a world-wide field
scene.add(
chunkInstances(grass, { size: 128 }),
);import { Baked }
from "@zkmake/three-batch/react";
// dozens of meshes, one draw per material
<Baked name="station">
<mesh geometry={wall} material={brick} />
<mesh geometry={roof} material={slate} />
</Baked>;
three-meter, measuring this page: 4,096 cubes in 1 draw callhover to make ripples
Five packages, one kit
Each installs on its own; the four dev tools as dev dependencies.
See what every frame costs
FPS, CPU and GPU time, stutter, draw calls and triangles, live in a HUD you dock anywhere. Budgets flag what's over. WebGL and WebGPU.
Edit textures in the running scene
Download any texture the scene draws with, paint over it, drop it back in and see it lit, with no rebuild. A/B against the original, live-link a file. KTX2 too.
See every camera, and which are drawing
Lists the scene's cameras and the one the renderer draws with, marks the live ones with their frame rate, reads position and projection live, and draws frustums.
Catch broken geometry before it ships
Find z-fighting, NaN normals, black frames and triangle or draw-call blowups. Assert on them in unit tests, run them in the console, or check glTF files in CI.
Draw less, render faster
Cut draw calls and triangles: culling cells for world-spanning meshes, static bakes, batches that follow moving objects, instance pools, far copies.