Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Record engine capability gaps and prevent lossy texture exports

Nguyen Xuan An5405d23c2a9b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ba44be1b..ebb074da 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,15 @@
# Changelog
+## Unreleased
+
+- Add Hermite animation curves with explicit tangents and retained playback buffers.
+- Add absolute-time clip mixing, weighted actions and crossfades with deterministic seeking.
+- Import and render normal, metallic/roughness, occlusion and emissive texture maps.
+- Count and release every material texture channel within the existing render budget.
+- Add sphere UVs and preserve normal mapping across small atlas regions.
+- Reuse instance normal matrices and reject GLB exports that would discard material maps.
+- Keep orbital velocity continuous with fewer showcase keyframes.
+
## 0.3.3
- Smooth WALL·E assembly changes when visitors tap or drag the slider
diff --git a/docs/capability-audit.md b/docs/capability-audit.md
new file mode 100644
index 00000000..517620af
--- /dev/null
+++ b/docs/capability-audit.md
@@ -0,0 +1,95 @@
+# Engine and authoring capability audit
+
+The upgrade covers rendering, modeling, animation, authoring, media export, and agent workflows.
+This inventory records the current gaps. Passing one demo does not establish feature parity or general performance superiority.
+
+## Reference systems
+
+- [Three.js animation system](https://threejs.org/manual/pages/animation-system.html): clips, actions, mixers, bone animation, morph animation, and asset loading.
+- [Three.js AnimationAction](https://threejs.org/docs/pages/AnimationAction.html): weighted playback, crossfades, repeat modes, and time scaling.
+- [Blender keyframes](https://docs.blender.org/manual/en/4.5/animation/keyframes/introduction.html): animated properties and interpolation.
+- [Blender F-Curve editing](https://docs.blender.org/manual/en/5.3/editors/graph_editor/fcurves/editing.html): curve handles and motion editing.
+- [Blender Armature modifier](https://docs.blender.org/manual/en/latest/modeling/modifiers/deform/armature.html): deformation through bones.
+
+The Blender references describe authoring capabilities. Their interpolation and rendering results require separate validation in 67.js.
+
+## Current coverage and evidence required
+
+| Area | Current implementation | Missing work | Completion evidence |
+| --- | --- | --- | --- |
+| Scene graph | Flat part matrices and custom demo rigs | Shared hierarchy, local transforms, pivots, constraints | Nested transforms and arbitrary seeks reproduce identical poses |
+| Modeling | Box, sphere, cylinder, torus, and procedural sampled surfaces | Mesh editing, extrusion, lathe, curves, bevel, subdivision, modifiers | Edited models retain topology, normals, UVs, and export behavior |
+| Animation curves | Linear, step, smooth and Hermite tangent interpolation in source | Curve editor; package release verification | Known curve samples, quaternion normalization, and continuous velocity checks |
+| Animation composition | Weighted clips and absolute-time crossfades integrated in source | Additive motion, layer masks, events, package verification | Walking and gestures blend without pose discontinuities |
+| Character deformation | Rigid parts | Skinning, morph targets, IK, retargeting | Animated imported character, expressions, and joint contact tests |
+| Camera authoring | Manually coded shot endpoints | Paths, tracking, focus targets, lens presets | Reviewed moving shot previews across aspect ratios |
+| Film authoring | Scene-specific shot list and player | Shared timeline, shot editing, transitions, audio cues | Edited timeline seeks and exports deterministically |
+| Asset import | Opaque glTF meshes, base-color texture, rigid animation | Deformation, material maps, transparency, compression, streaming | Blender fixtures preserve geometry, materials, and animation |
+| Materials | Factors and five PBR texture channels integrated in source | Layered materials, advanced extensions, authored tangents, package verification | Reference material scenes and texture budget checks |
+| Lighting | Directional shadows and procedural studio illumination | Configurable lights, HDR environments, baked lighting, reflection probes | Reference lighting scenes, stable shadows, and measured render cost |
+| Image rendering | HDR, bloom, grading, MSAA, FXAA | Depth of field, motion blur, temporal sampling, render passes | Reviewed stills and moving previews with measured artifacts |
+| Simulation | Demo-specific wind, water, sparks, and ignition | Shared particles, collision, physics, cloth, hair, volumetric tools | Repeatable simulations, contact tests, and bounded resource usage |
+| Interaction | Demo-specific orbit, zoom, and sliders | Picking, transform gizmos, reusable controls | Pointer, keyboard, and mobile interaction checks |
+| Browser editor | Demonstration pages | Modeling, material, lighting, rig, curve, and timeline editing | Complete edit, save, reload, and export workflows |
+| Runtime diagnostics | Render budget estimates and export reports | CPU/GPU timers, draw diagnostics, adaptive quality, LOD, culling | Matching-scene benchmarks with quality and memory measurements |
+| Media export | Deterministic streamed PNG/MP4 capture | Production profiles, batch jobs, passes, resumable exports | Frame count, image quality, audio sync, memory, and time reports |
+| Agent workflow | Scene and export skills | Film direction, motion review, asset selection, and editor workflows | Tasks produce usable scenes and reviewed previews through documented APIs |
+
+This inventory remains open. Each area requires its own implementation and verification.
+An API must work through exported package entry points before its capability is marked available.
+
+## First implementation units
+
+1. Retain animation and renderer scratch buffers to reduce per-frame allocation.
+2. Add serializable curve tangents with deterministic sampling and validation.
+3. Add animation composition and a shared transform hierarchy.
+4. Extend asset deformation and material support.
+5. Build reusable camera and timeline authoring tools.
+6. Improve model and image showcases using these capabilities.
+
+The remaining inventory stays in scope while these units land.
+
+## Integrated source units
+
+Hermite curves and retained animation-player buffers are integrated locally.
+The orbit showcase uses analytical velocity tangents with 25 keys per orbit instead of 97 linear keys.
+Tests check velocity continuity across its interior keys and matching start/end positions.
+The native browser smoke verifies deterministic motion, persistent GPU resources, and responsive scene rendering.
+These source checks do not establish that the new API is available in the published npm version.
+
+Weighted clip actions and crossfades are also integrated locally.
+Tests compare scalar and quaternion mixing against the installed Three.js implementation.
+The mixer retains authored controls so backward seeks reproduce earlier playback and interrupted fades.
+
+Four additional material texture channels are integrated with glTF import, budget accounting, caching, and GPU disposal.
+Native GPU checks confirm image changes for every channel without WebGL errors.
+Equivalent normal maps with UV coordinates scaled by `0.001` differ by only `0.000257` mean pixel-channel units.
+GLB texture export remains missing. Export now rejects textured materials instead of silently discarding their maps.
+
+The API review found detached material bindings, an absolute UV threshold, and a Float32 minimum-scale mismatch.
+Each finding received a fix and a regression check.
+Claude CLI was unavailable on both attempts because its weekly quota was exhausted.
+The review therefore has evidence from one model family only.
+
+## Renderer update measurement
+
+The local CPU benchmark uses the existing WALL·E scene with 574 parts.
+It warms the code, then measures five trials of 500 updates each.
+GPU buffer calls are mocked. These results describe validation and instance packing only.
+
+Run `node scripts/benchmark-instance-updates.mjs` from the repository root.
+It writes `artifacts/instance-update-benchmark.json` and lowers its process priority on this shared machine.
+
+| Metric | Before | After |
+| --- | --- | --- |
+| Median CPU update | 0.988 ms | 0.134 ms |
+| Normal-matrix allocations across 2,500 updates | 1,435,000 | 0 |
+
+After adding validation for all five material channels, a follow-up measurement reported a median of `0.213 ms`.
+That measurement also reported zero normal-matrix allocations.
+
+The update keeps two phases: validate every part, then write packed buffers.
+Invalid mixed updates still fail before changing packed instance data or submitting GPU writes.
+Normal scratch buffers belong to uploaded parts and remain bounded by the scene size.
+
+Live GPU frame timing and broader scene measurements remain required before claiming an overall speed improvement.
diff --git a/src/export.js b/src/export.js
index dd644616..c0e5b5a4 100644
--- a/src/export.js
+++ b/src/export.js
@@ -3,6 +3,13 @@ function paddedLength(length) {
}
export function exportGlb(parts) {
+ for (const part of parts) {
+ for (const channel of ['map', 'normalMap', 'metallicRoughnessMap', 'occlusionMap', 'emissiveMap']) {
+ if (part.material[channel]) {
+ throw new RangeError(`GLB export cannot preserve ${channel} yet. Texture export must be implemented before exporting this material.`);
+ }
+ }
+ }
const document = {
asset: { version: '2.0', generator: '67.js' },
scene: 0,
diff --git a/tests/export.test.js b/tests/export.test.js
index 7e2c61fe..0ffb1c8b 100644
--- a/tests/export.test.js
+++ b/tests/export.test.js
@@ -16,3 +16,11 @@ test('exported GLB loads with an independent glTF loader and preserves every par
assert.equal(meshCount, parts.length);
assert.ok(binary.byteLength < 1024 * 1024);
});
+
+test('GLB export refuses to silently discard any material texture channel', () => {
+ const part = createModel()[0];
+ for (const channel of ['map', 'normalMap', 'metallicRoughnessMap', 'occlusionMap', 'emissiveMap']) {
+ assert.throws(() => exportGlb([{ ...part, material: { ...part.material, [channel]: {} } }]),
+ error => error instanceof RangeError && error.message.includes(channel));
+ }
+});