3D engine that AI agents drive
Link unshipped docs by absolute URL and check links in the packed archive
Nguyen Xuan Anea5b013d76d3
diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlindex d576602c..b737035f 100644--- a/.github/workflows/test.yml+++ b/.github/workflows/test.yml@@ -27,4 +27,5 @@ jobs:- run: npm test- run: npm run prepare:release- run: npm run smoke:package+ - run: npm run check:links:package- run: npm run smoke:mcp-packagediff --git a/CHANGELOG.md b/CHANGELOG.mdindex 03c3d1f9..d8860c79 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,7 @@## Unreleased+- Fix links in the npm package that pointed at docs it does not ship (issue #178). `docs/guide.md`, `docs/material-maps.md`, `README.md` and `ROADMAP.md` now link the 20 unshipped docs, `CONTRIBUTING.md`, the texture credits and the changelog by absolute GitHub URL; shipping those docs would add 64 KB gzip. `npm run check:links:package` packs the archive, unpacks it and checks every link inside (26 files, 0 broken), and the `Test` workflow runs it.- Take 34 KB of headroom under the npm archive budget without raising it (issue #177). `CHANGELOG.md` no longer ships in the package, because GitHub serves it; the archive went from 740,972 to 705,961 bytes against the 740,000 budget. `bench/size/README.md` now says how the budget is set and what it protects.- Add a test that fails when the MCP tool count in `docs/guide.md`, `docs/mcp.md`, `index.html` or `scripts/smoke-mcp.mjs` differs from the `tools/list` result (issue #180). The server registers 22 tools; the 23rd `register(` in the file is the function definition, so the documented count was right.- A renderer no longer draws its shadow map a second time on the first frame when the frame has no assembly; the constructor already drew it. On `mountain-valley` that removes 9.72 million shadow triangles from the first frame, with identical pictures (issue #171). `node bench/reference/profile-scene.mjs <scene>` prints where a scene's time goes, and `frame-time.mjs --plain` measures scenes that are too large for the light bake.diff --git a/README.md b/README.mdindex 688c21bd..c3d788e6 100644--- a/README.md+++ b/README.md@@ -19,7 +19,7 @@<a href="https://67js.codepawl.com">Showcase</a> ·<a href="https://67js.codepawl.com/docs.html">Documentation</a> ·<a href="https://67js.codepawl.com/llms.txt">Guide for agents</a> ·- <a href="CHANGELOG.md">Changelog</a>+ <a href="https://github.com/anxuanng/67.js/blob/main/CHANGELOG.md">Changelog</a></p><p align="center">@@ -188,13 +188,13 @@ They compare matching scenes on the same hardware. They do not show a general sp## Contributing-Read [CONTRIBUTING.md](CONTRIBUTING.md) before you open a pull request. It covers setup, checks, code style and the release flow.+Read [CONTRIBUTING.md](https://github.com/anxuanng/67.js/blob/main/CONTRIBUTING.md) before you open a pull request. It covers setup, checks, code style and the release flow.## Credits- [gl-matrix](https://github.com/toji/gl-matrix) supplies the matrix math.- The glTF addon has its own parser and does not depend on [Three.js](https://threejs.org/). The Draco, meshopt and KTX2 decoders are Three.js loaders that you pass in.-- Textures, leaf atlases and the HDRI on the site are CC0 scans from [Poly Haven](https://polyhaven.com) and [ambientCG](https://ambientcg.com). See [the texture credits](public/textures/CREDITS.md).+- Textures, leaf atlases and the HDRI on the site are CC0 scans from [Poly Haven](https://polyhaven.com) and [ambientCG](https://ambientcg.com). See [the texture credits](https://github.com/anxuanng/67.js/blob/main/public/textures/CREDITS.md).- WALL·E is a Disney/Pixar character. The study is procedural geometry with no external model assets.- The trailer study follows the shot order of [a Universal Pictures trailer](https://www.youtube.com/watch?v=uYPbbksJxIg) with procedural sets and an original score. It contains no film footage or soundtrack samples.diff --git a/ROADMAP.md b/ROADMAP.mdindex ea5c169c..98e2223f 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -33,7 +33,7 @@ Version `0.10.0` adds terrain, texture sets, vegetation, liquid playback, vehiclVersion `0.11.0` adds `addons/mesh` for polygon editing, with booleans, bevel, loop cuts, UV unwrapping and a modifier stack. It adds the `mesh_edit`, `mesh_stack` and `mesh_inspect` tools, plus grass, clutter and moss.Version `0.12.0` adds seeded procedural material patterns.Version `0.13.0` adds `addons/skeleton-pose` with clip layers, masks and IK, and `0.13.1` and `0.14.0` make it work on real imported characters, including through MCP.-[CHANGELOG.md](CHANGELOG.md) lists every change, including work on `main` that is not released yet.+[CHANGELOG.md](https://github.com/anxuanng/67.js/blob/main/CHANGELOG.md) lists every change, including work on `main` that is not released yet.The stdio MCP server supplies twenty-two schema-backed tools and persistent CPU/GPU image previews.Recipes retain lighting, volumetric fog, grading and directional shadow coverage with atomic edits and undo.diff --git a/docs/guide.md b/docs/guide.mdindex 6e2a2e35..a975ce75 100644--- a/docs/guide.md+++ b/docs/guide.md@@ -161,8 +161,8 @@ Extrusion supports holes and bevels. Open tube ends remain uncapped.4. Share the geometry among repeated parts.The [modeling contract](/modeling.md) defines input bounds, winding, bevel limits and resource estimates.-The [scene graph](/scene-graph.md) supports hierarchy and pivots without changing mesh topology.-The [modeling demo](/modeling.html) combines these tools in a lantern scene.+The [scene graph](https://github.com/anxuanng/67.js/blob/main/docs/scene-graph.md) supports hierarchy and pivots without changing mesh topology.+The [modeling demo](https://67js.codepawl.com/modeling.html) combines these tools in a lantern scene.These generators do not perform solid Boolean operations or provide a mesh editor.## Sculpt brushes@@ -177,9 +177,9 @@ The result preserves topology, UVs and colors, and rebuilds normals.3. Inspect the resulting surface for folds or intersections.4. Rebuild surface patches and query indices after changing geometry.-The [sculpt contract](/sculpt.md) defines brush strength, seam handling and work limits.+The [sculpt contract](https://github.com/anxuanng/67.js/blob/main/docs/sculpt.md) defines brush strength, seam handling and work limits.Smoothing can shrink volume. Sculpting rejects skin and morph channels and does not remesh or prevent intersections.-Compatible deformations can become [relative morph targets](/morph-targets.md) for animation.+Compatible deformations can become [relative morph targets](https://github.com/anxuanng/67.js/blob/main/docs/morph-targets.md) for animation.## Contact detection@@ -194,7 +194,7 @@ The `surfaces` mode finds triangle contact. The `closed-solids` mode also tests5. Dispose the indices when their geometry is no longer needed.An index also supports `raycast(matrix, ray)` for a triangle number, hit point and barycentric coordinates.-The [mesh query contract](/mesh-query.md) describes results, solid validation, numerical limits and budget errors.+The [mesh query contract](https://github.com/anxuanng/67.js/blob/main/docs/mesh-query.md) describes results, solid validation, numerical limits and budget errors.Rebuild indices after geometry edits. Queries reject skin and morph channels.Contact results do not measure penetration depth, resolve collisions or diagnose z-fighting.@@ -210,11 +210,11 @@ Nearest mode chooses a surface point. Project mode casts along a target-local di4. Use the returned geometry with the target part's retained matrix.5. Inspect `stats` and the resulting mesh before rendering.-The [shrinkwrap contract](/shrinkwrap.md) defines local distances, work budgets and miss handling.+The [shrinkwrap contract](https://github.com/anxuanng/67.js/blob/main/docs/shrinkwrap.md) defines local distances, work budgets and miss handling.Collapsed output triangles cause errors. Projection does not guarantee clearance across the complete accessory surface.`createSurfacePatch` from `67js/addons/surface` clips target triangles into an overlay with its own UVs and material.-The [surface patch contract](/surface.md) defines projector orientation, depth and local clearance.+The [surface patch contract](https://github.com/anxuanng/67.js/blob/main/docs/surface.md) defines projector orientation, depth and local clearance.Patches and shrinkwrap are static operations. They do not follow skin or morph deformation.## HDR environment lighting@@ -230,7 +230,7 @@ Pass `environment: { map }` to light and reflect from an equirectangular HDR ima3. Play it with `createSkinClipPlayer(skin, clip).apply(seconds)`, then `renderer.updateParts(parts)`.4. For a crowd, `createCrowd({ count, clip, seed })` gives placement, time offsets and playback rates. Each instance needs its own skin pose.-The [retarget contract](/retarget.md) covers rest-pose assumptions and measured cost. Mixamo clips need the owner's Adobe login to download; the code only consumes files.+The [retarget contract](https://github.com/anxuanng/67.js/blob/main/docs/retarget.md) covers rest-pose assumptions and measured cost. Mixamo clips need the owner's Adobe login to download; the code only consumes files.## Baked liquid@@ -241,7 +241,7 @@ The [retarget contract](/retarget.md) covers rest-pose assumptions and measured3. Create a player with `createSpumePlayer(cache, { matrix, loop })`.4. Each frame, call `renderer.replaceParts([...sceneParts, ...player.partsAt(seconds)])` and render.-The [Spume contract](/spume.md) covers the cache format, whitewater options, placement and measured cost.+The [Spume contract](https://github.com/anxuanng/67.js/blob/main/docs/spume.md) covers the cache format, whitewater options, placement and measured cost.Textured, skinned and morphed parts may stay in the list unchanged while frames are replaced; adding or removing them needs a new renderer.## Wheeled vehicles@@ -254,7 +254,7 @@ Textured, skinned and morphed parts may stay in the list unchanged while framesWheel spin, front-wheel steering, roll, pitch and ground following come from the path.Scene-graph nodes and imported GLBs use `applyVehiclePoseToSceneGraph` and `applyVehiclePoseToAsset`.-The [vehicle contract](/vehicle.md) lists conventions, options and limits.+The [vehicle contract](https://github.com/anxuanng/67.js/blob/main/docs/vehicle.md) lists conventions, options and limits.## Trees and grass@@ -264,7 +264,7 @@ The [vehicle contract](/vehicle.md) lists conventions, options and limits.2. Pick detail per camera with `selectLevels(forest.instances, eye)`.3. Pass `view.parts` to `Renderer67` and rebuild when `view.changed` is true.-Cards (`leaves: 'cards'`, the default) are single-sided, alpha-masked, double-sided `foliage` textures that sway with the wind; `'mesh'` leaves cost about twice the triangles. Pass `barkTextures` for scanned bark and `leafTextures: await loadLeafTextures('/textures/leaves')` for scanned leaf cards. The [Vegetation contract](/vegetation.md) lists species, triangle budgets and limits.+Cards (`leaves: 'cards'`, the default) are single-sided, alpha-masked, double-sided `foliage` textures that sway with the wind; `'mesh'` leaves cost about twice the triangles. Pass `barkTextures` for scanned bark and `leafTextures: await loadLeafTextures('/textures/leaves')` for scanned leaf cards. The [Vegetation contract](https://github.com/anxuanng/67.js/blob/main/docs/vegetation.md) lists species, triangle budgets and limits.## Grass fields@@ -274,11 +274,11 @@ Cards (`leaves: 'cards'`, the default) are single-sided, alpha-masked, double-si2. Add `grass.parts` to the renderer and pass `wind` in each frame.3. When `grass.update(eye)` returns true, call `renderer.replaceParts` with the new part list.-Tint the ground under the grass with `grass.groundColor`. The [Grass contract](/grass.md) lists options, levels, measured budgets and limits.+Tint the ground under the grass with `grass.groundColor`. The [Grass contract](https://github.com/anxuanng/67.js/blob/main/docs/grass.md) lists options, levels, measured budgets and limits.-`67js/addons/clutter` is in the current source and not yet published. It scatters pebbles, rocks, twigs and fallen leaves over terrain in the same streamed tiles. Pick a `preset` (`meadow`, `forest`, `riverbed`, `scree`), pass `terrainHeight`, and add `clutter.parts` next to the grass. The [Clutter contract](/clutter.md) lists options and budgets.+`67js/addons/clutter` is in the current source and not yet published. It scatters pebbles, rocks, twigs and fallen leaves over terrain in the same streamed tiles. Pick a `preset` (`meadow`, `forest`, `riverbed`, `scree`), pass `terrainHeight`, and add `clutter.parts` next to the grass. The [Clutter contract](https://github.com/anxuanng/67.js/blob/main/docs/clutter.md) lists options and budgets.-`67js/addons/light-bake` is in the current source and not yet published. `bakeLightmaps(parts, lights, options)` ray traces the light that bounces between surfaces into a lightmap texture for each part and returns new parts that draw it through the emissive map; direct light stays live. The [Light bake contract](/light-bake.md) lists the limits.+`67js/addons/light-bake` is in the current source and not yet published. `bakeLightmaps(parts, lights, options)` ray traces the light that bounces between surfaces into a lightmap texture for each part and returns new parts that draw it through the emissive map; direct light stays live. The [Light bake contract](https://github.com/anxuanng/67.js/blob/main/docs/light-bake.md) lists the limits.## Terrain and ground textures@@ -288,7 +288,7 @@ Tint the ground under the grass with `grass.groundColor`. The [Grass contract](/2. `const terrain = createTerrain({ size, chunks, resolution, levels, seed })`; give every `terrain.parts` entry the one shared material.3. Pass `terrain.heightAt` to `scatterVegetation` and vehicles, and call `renderer.replaceParts` when `terrain.update(eye)` returns parts.-The [Terrain contract](/terrain.md) lists every option, the texture-array memory and the limits.+The [Terrain contract](https://github.com/anxuanng/67.js/blob/main/docs/terrain.md) lists every option, the texture-array memory and the limits.## Retained surface attachments@@ -302,7 +302,7 @@ The accessory uses the attachment's retained world matrix. Its positive Z axis f4. Update the target matrix, morph weights and skin palette for the frame.5. Call `attachment.update()` before `renderer.updateParts()`.-The [attachment contract](/surface-attachment.md) defines retained identities, world-unit clearance and unsupported shader deformation.+The [attachment contract](https://github.com/anxuanng/67.js/blob/main/docs/surface-attachment.md) defines retained identities, world-unit clearance and unsupported shader deformation.Updates sample the selected triangle without rebuilding a BVH.Static raycast hits can supply binding coordinates, but query indices cannot raycast a visibly skinned or morphed surface.An attachment positions one rigid frame. It does not conform the accessory footprint or prevent every intersection.@@ -395,7 +395,7 @@ The [lighting contract](/lighting.md) defines intensity, radius, range and validPoint lights have no local shadows and can illuminate through walls.Radius regularizes attenuation and does not create an area emitter.-The [volume fog contract](/volumetric.md) covers depth-clipped directional scattering in version `0.4.0`.+The [volume fog contract](https://github.com/anxuanng/67.js/blob/main/docs/volumetric.md) covers depth-clipped directional scattering in version `0.4.0`.Active fog requires `hdr: true`, `depth: true` and supported floating-point targets.Its depth texture contributes to the render memory estimate.@@ -421,11 +421,11 @@ Tracks target unique part names. Supported transform tracks are translation, rotVersion `0.4.0` supports `CUBICSPLINE` tracks with explicit `inTangent` and `outTangent` values on every keyframe.Tangents represent component changes per second. Quaternion tangents are component derivatives.-The [curve contract](/animation-curves.md) defines interpolation, overshoot constraints and retained player buffers.+The [curve contract](https://github.com/anxuanng/67.js/blob/main/docs/animation-curves.md) defines interpolation, overshoot constraints and retained player buffers.`createAnimationMixer(parts)` combines clips through reusable actions and absolute-time control timelines.Actions support weights, playback speed, fades and crossfades.-The [mixer contract](/animation-mixer.md) defines blending, ownership and control ordering.+The [mixer contract](https://github.com/anxuanng/67.js/blob/main/docs/animation-mixer.md) defines blending, ownership and control ordering.1. Create clips and bind their actions through `mixer.clipAction(clip)`.2. Author `play`, `fadeTo` or `crossFade` controls in nondecreasing time order.@@ -447,13 +447,13 @@ The renderer applies morph deltas before skinning.3. Update joint palette values and morph weights for the desired frame.4. Call `renderer.updateParts(parts)` to validate and upload the poses.-The [skinning contract](/skinning.md) defines supported transforms, four influences and identity requirements.-The [morph contract](/morph-targets.md) defines channel shapes, weight bounds and resource estimates.+The [skinning contract](https://github.com/anxuanng/67.js/blob/main/docs/skinning.md) defines supported transforms, four influences and identity requirements.+The [morph contract](https://github.com/anxuanng/67.js/blob/main/docs/morph-targets.md) defines channel shapes, weight bounds and resource estimates.Changing topology, influences or pose identities requires a new renderer.The glTF addon imports supported skins and relative targets, including joint and weight animation.`asset.applyAnimation(time, clipIndex)` updates retained parts and poses for upload.-The [glTF morph contract](/gltf-morph.md) and [asset contract](/gltf.md) define the supported asset subset.+The [glTF morph contract](https://github.com/anxuanng/67.js/blob/main/docs/gltf-morph.md) and [asset contract](/gltf.md) define the supported asset subset.## Recorded physics@@ -607,7 +607,7 @@ Core exports are available from `67js`:## Release and source availabilityPublished npm `0.4.0` includes modeling, sculpting, static mesh queries, shrinkwrap, surface patches, animation mixing, skinning, morphs, physics and lighting.-Retained [surface attachments](/surface-attachment.md) are introduced in `0.4.1` and are absent from published npm `0.4.0`.+Retained [surface attachments](https://github.com/anxuanng/67.js/blob/main/docs/surface-attachment.md) are introduced in `0.4.1` and are absent from published npm `0.4.0`.Source checkouts can contain unreleased changes beyond their package version.The [release metadata](/release.json) identifies the published package and browser module.diff --git a/docs/material-maps.md b/docs/material-maps.mdindex ecce3b4c..ea69950b 100644--- a/docs/material-maps.md+++ b/docs/material-maps.md@@ -109,7 +109,7 @@ Moss is shaded as its own material, not as a tint. Where it grows, roughness bec## Splat layers-A standard-tag material can carry `layers` (up to four `{ color, normal, roughness, height, scale, tint, triplanar }` entries built from `loadTextureSet`) and a `splat` rule object instead of these single maps. The layers are blended by slope, height and a weight mask, sampled in world space and packed into texture arrays on units 11 to 14. They replace `map`, `normalMap`, `metallicRoughnessMap` and `occlusionMap`, which must be absent, and parts batch only when `layers` and `splat` are the same objects. See [Terrain](/terrain.md).+A standard-tag material can carry `layers` (up to four `{ color, normal, roughness, height, scale, tint, triplanar }` entries built from `loadTextureSet`) and a `splat` rule object instead of these single maps. The layers are blended by slope, height and a weight mask, sampled in world space and packed into texture arrays on units 11 to 14. They replace `map`, `normalMap`, `metallicRoughnessMap` and `occlusionMap`, which must be absent, and parts batch only when `layers` and `splat` are the same objects. See [Terrain](https://github.com/anxuanng/67.js/blob/main/docs/terrain.md).## Material layersdiff --git a/package.json b/package.jsonindex 5e6b4e12..fe821edb 100644--- a/package.json+++ b/package.json@@ -132,7 +132,8 @@"size": "node scripts/measure-size.mjs","benchmark:runtime": "node bench/runtime/run.mjs","check:tool-schemas": "node scripts/check-tool-schemas.mjs",- "check:links": "node scripts/check-links.mjs"+ "check:links": "node scripts/check-links.mjs",+ "check:links:package": "node scripts/check-links.mjs --package"},"peerDependencies": {"@dimforge/rapier3d-compat": "0.21.0",diff --git a/scripts/check-links.mjs b/scripts/check-links.mjsindex 1b7a12d1..159e9cae 100644--- a/scripts/check-links.mjs+++ b/scripts/check-links.mjs@@ -1,11 +1,13 @@-// Checks that every relative link in the markdown and HTML files of the repository points at a file.-// Usage: node scripts/check-links.mjs-// A link resolves against its own folder, the repository root, `public/` or `docs/`, because the site serves-// the docs and the public folder from one origin.-import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';+// Checks that every relative link in the markdown and HTML files points at a file.+// Usage: node scripts/check-links.mjs the repository checkout+// node scripts/check-links.mjs --package the packed npm archive, as a coding agent reads it in node_modules+// A link resolves against its own folder, the root, `public/` or `docs/`, because the site serves+// the docs and the public folder from one origin. The archive has no `public/`, so only the other bases apply.+import { execFileSync, execSync } from 'node:child_process';+import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync } from 'node:fs';+import { tmpdir } from 'node:os';import { dirname, join, relative, resolve } from 'node:path';-const repositoryRoot = process.cwd();const skippedFolders = new Set(['node_modules', '.git', '.claude', 'build', 'dist', 'artifacts', 'coverage']);const linkPattern = /(?:\]\(|href="|src=")([^)"#\s]+)/g;// `release.json` is generated by `npm run prepare:release`. `./main.js` is an example path inside the guide.@@ -22,26 +24,48 @@ function collectFiles(folder, found) {return found;}-function linkResolves(file, link) {+function linkResolves(root, file, link) {const withoutQuery = link.split('?')[0];- const bases = [dirname(file), repositoryRoot, join(repositoryRoot, 'public'), join(repositoryRoot, 'docs')];+ const rootBases = [root, join(root, 'public'), join(root, 'docs')];const targets = withoutQuery.startsWith('/')- ? bases.slice(1).map((base) => join(base, withoutQuery))- : [resolve(dirname(file), withoutQuery), ...bases.slice(1).map((base) => join(base, withoutQuery))];+ ? rootBases.map((base) => join(base, withoutQuery))+ : [resolve(dirname(file), withoutQuery), ...rootBases.map((base) => join(base, withoutQuery))];return targets.some((target) => [target, `${target}.html`, `${target}.md`].some((candidate) => existsSync(candidate)));}-const files = collectFiles(repositoryRoot, []);-const broken = [];-for (const file of files) {- const text = readFileSync(file, 'utf8');- for (const match of text.matchAll(linkPattern)) {- const link = match[1];- if (externalPattern.test(link) || knownGeneratedLinks.has(link)) continue;- if (!linkResolves(file, link)) broken.push(`${relative(repositoryRoot, file)} -> ${link}`);+function findBrokenLinks(root) {+ const files = collectFiles(root, []);+ const broken = [];+ for (const file of files) {+ const text = readFileSync(file, 'utf8');+ for (const match of text.matchAll(linkPattern)) {+ const link = match[1];+ if (externalPattern.test(link) || knownGeneratedLinks.has(link)) continue;+ if (!linkResolves(root, file, link)) broken.push(`${relative(root, file)} -> ${link}`);+ }}+ return { checked: files.length, broken };}-console.log(`${files.length} files checked, ${broken.length} broken links`);+// Packs without lifecycle scripts, so run `npm run prepare:release` first when `build/` is stale.+function unpackArchive(workFolder) {+ const packed = JSON.parse(execSync(`npm pack --ignore-scripts --json --pack-destination "${workFolder}"`, { encoding: 'utf8' }));+ const entry = Array.isArray(packed) ? packed[0] : Object.values(packed)[0];+ // A relative name with `cwd` keeps GNU tar from reading `C:` in a Windows path as a host name.+ execFileSync('tar', ['-xzf', entry.filename], { cwd: workFolder });+ return join(workFolder, 'package');+}++const checkArchive = process.argv.includes('--package');+let root = process.cwd();+let workFolder;+if (checkArchive) {+ workFolder = mkdtempSync(join(tmpdir(), '67js-links-'));+ root = unpackArchive(workFolder);+}+const { checked, broken } = findBrokenLinks(root);+if (workFolder) rmSync(workFolder, { recursive: true, force: true });++console.log(`${checked} files checked${checkArchive ? ' in the packed archive' : ''}, ${broken.length} broken links`);for (const entry of broken) console.log(entry);process.exitCode = broken.length === 0 ? 0 : 1;