npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gltf-slice

v0.0.3

Published

Slice glTF and GLB meshes into section views with hatched interior caps

Readme

gltf-slice

Slice static glTF/GLB meshes into section views and close each cut surface with a diagonal hatch texture.

| Axis-aligned slice | Hole-aware cap | Transformed mesh | | --- | --- | --- | | A box sliced on the XY plane | A rectangular tube with a hatched ring-shaped section | A rotated and scaled box with a hatched section |

Install

bun add github:tscircuit/gltf-slice

The package is source-first TypeScript and targets Bun or a modern TypeScript toolchain.

Slice a GLB in memory

import { readFile, writeFile } from "node:fs/promises"
import { sliceGLB } from "gltf-slice"

const input = await readFile("model.glb")
const output = await sliceGLB(input, {
  plane: "xy",
  zOffset: 10,
  side: "z+",
})

await writeFile("model-section.glb", output)

side names the half-space retained in the output. In this example, geometry with z >= 10 is retained, and the cap's outward face points toward z-.

Slice files

The input and output formats are selected from their .gltf or .glb extensions. External buffers and images referenced by JSON glTF inputs are loaded and rewritten automatically.

import { sliceGltfFile } from "gltf-slice"

const stats = await sliceGltfFile(
  "model.gltf",
  "model-section.glb",
  { plane: "yz", xOffset: 4.5, side: "x-" },
)

console.log(stats.capTriangles, stats.capLoops)

For an in-memory JSON glTF package, use sliceGLTF() with a glTF Transform JSONDocument ({ json, resources }). Lower-level callers can use sliceDocument() directly.

CLI

bunx gltf-slice model.glb section.glb \
  --plane xy \
  --z-offset 10 \
  --side z+

Run gltf-slice --help for all options, including generic offsets, cap disablement, hatch spacing, hatch line width, and geometry tolerance.

Slice syntax

| Plane | Per-axis offset | Valid retained sides | | --- | --- | --- | | "xy" | zOffset | "z+", "z-" | | "xz" | yOffset | "y+", "y-" | | "yz" | xOffset | "x+", "x-" |

Every plane also accepts the shorter offset property. The default offset is zero in the model's coordinate system.

Customize the section hatch

const output = await sliceGLB(input, spec, {
  hatch: {
    size: 128,
    spacing: 12,
    lineWidth: 2,
    background: [255, 238, 232, 255],
    lineColor: [170, 34, 34, 255],
  },
  capMaterialName: "machined interior",
})

The hatch is embedded as a PNG base-color texture, so it remains visible in ordinary glTF viewers and in exported GLB files. Caps support disconnected solids and nested loops such as holes in tubes.

Geometry behavior

  • The slice plane is evaluated in world coordinates, including nested node transforms, rotation, and non-uniform scale.
  • Shared mesh instances are sliced independently because each instance can intersect the world-space plane differently.
  • Vertex attributes are interpolated at cut edges; normals and tangents are normalized after interpolation.
  • Triangle primitives are sliced. Non-triangle primitives are preserved.
  • Input meshes should be watertight to produce closed cap loops. Open cut chains are reported in SliceStats.openChains and are left uncapped.
  • Skins and morph targets must be baked before slicing. Compressed mesh extensions should be decoded before passing the asset to this package.

Development

bun install
bun run check

The test suite includes 18 committed PNG snapshots rendered with PoppyGL, covering every axis and side, offsets, holes, multiple solids, nested transforms, uncapped output, and hatch styles. PoppyGL renders in native JavaScript without WebGL, keeping visual checks deterministic in CI.