Debugging

Visualize framing zones, camera frustums and orbits.

Framing zones

PositionComposer, RotationComposer and GroupFraming can draw their zones on top of the canvas.

PieceDraws
PositionComposer, RotationComposerdeadZone in green, hardLimit in red, and a crosshair at screenPosition.
GroupFramingpadding in blue.

Each element has a CSS class you can restyle: klipp-debug-deadzone, klipp-debug-hardlimit, klipp-debug-groupframing and klipp-debug-crosshair.

.klipp-debug-deadzone {
  border-color: lime;
}

Camera frustums

A frustum helper draws a camera in the scene, so you can see where an inactive camera is and what it's looking at. Every camera's state holds what it needs: position, quaternion, fov or orthographicSize, near and far. Off screen, a camera updates only now and then by default, so its frustum moves in steps. Give it standbyUpdate: 'always' to see it move smoothly.

Orbits

An orbit helper draws where an OrbitFollow camera can move, around the point it tracks: the circle horizontal moves it along in orange, the arc vertical moves it along in blue, and the three rings of 'threeRing' in gray.

Usage

Framing zones

Draw them with DebugOverlay from @pmndrs/klipp/dom:

import { debugZones } from '@pmndrs/klipp';
import { DebugOverlay } from '@pmndrs/klipp/dom';

const overlay = new DebugOverlay();
overlay.connect(canvas.parentElement!);
overlay.render(debugZones.composer(body.screenPosition, body.deadZone, body.hardLimit), body.screenPosition);

debugZones.composer turns a composer's settings into the same boxes the React components draw. Call render again whenever the zones change, and disconnect() to remove the overlay. For group framing, debugZones.groupFramingPaddingBox gives the size of the padding boundary.

Orbits

orbitFollow.point(out, body.state, body, horizontal, vertical) gives where the camera would be at any axis values, to draw with your own renderer.