nanoraster
0.7.1

Cut section views

Cut one or more retained half-spaces and render deterministic striped caps and outlines.

Open Markdown

Plane points and normals use the caller world. Normals point into the retained half-space. Omit world for canonical glTF +Y-up metres.

Cut with one or more planes

Use sections.planes for one to eight simultaneous cuts. The retained subject is the intersection of every half-space. Plane order therefore does not change the image.

import { directionFromOrbit, renderImage } from 'nanoraster';const world = { up: '+z', forward: '-y', unit: 'meter' } as const;const image = await renderImage(glb, {  format: 'webp',  world,  sections: {    planes: [      { point: [0, 0, 0], normal: directionFromOrbit({ azimuth: -90, elevation: 0 }, world) },      { point: [0, 0, 0], normal: directionFromOrbit({ azimuth: 0, elevation: 90 }, world) },    ],    clipSurfaces: true,    clipLines: true,  },});

Rendering…

 

facing
advanced · plane 1 normal XYZ
facing
advanced · plane 2 normal XYZ

Normals take any finite non-zero magnitude, and directionFromOrbit names one. Omit sections for no cut. Elevation 90 is caller +Z. nanoraster converts the plane once.

Control what each plane clips

Both switches default to true. Disabling clipSurfaces leaves triangles uncut and produces no caps. Disabling clipLines leaves authored lines uncut.

Read the cap

Closed orientable surfaces receive striped material-colour caps and black outlines. Overlaps are red with yellow cross-stripes. Tangent planes may yield only an outline. nanoraster pairs duplicated glTF seams but does not repair meshes.

Sections never refuse a mesh. An open, cracked or non-manifold source is sliced directly: every loop that closes on the plane is filled, nested loops by the even-odd rule, and every open chain is drawn in #DD003F at the outline width over an unfilled region. Only malformed indices, non-finite positions and coordinates beyond the fixed-point range return parse errors. With timings: true, sections reports each cut source's loop and chain counts.

A valid EXT_mesh_manifold mesh supplies exact topology. Base primitives still control rendering, materials, and visibility. Hatch direction follows the plane. Hatch spacing follows the camera.

Fitted framing follows the visible primitive set but does not refit after a plane moves. The cut therefore reveals the interior without making the camera jump.

On this page