manifoldxplan · web target 5c execution: subagent-driven, one queue worker per task#140#822026-11-07
0 of 0 done

Web target, plan 5c: skinned entities and the second consumer

The last of slice 5's three plans. The glTF writer learns joints and skins, which closes #82; frame code in the page gets @ on matrix stacks, np.eye and set_joints; the page draws each skinned entity as a three.js SkinnedMesh posed from the store; examples/web_crowd.py gains a walking figure. Then the second consumer's 3D world is ported to Python and comes from manifoldx export --web, in seven tasks in its own repository, and its page script keeps only the document panels, labels, sound and fullscreen around the export.

3,446lines in the consumer's page script today
≈ 3,240lines of world JavaScript the port replaces (≈ 2,860 of it, plus its 384-line texture module)
0 / 32,000float32 @ results that differ from a float64-accumulated chain, numpy 2.4.4 on this host
7 + 7tasks: manifoldx, then the consumer
goalA skinned entity exports with its joints and pose (desktop glTF and the page), frame code poses skinned entities with set_joints from matrices it builds with np.eye, nested np.array, np.stack and @, and the page draws them posed. web_crowd's walking figure replays with no mismatch in Node and in Chromium. Then the second consumer's world (grounds, stands, rooms, theater, props, people, input and camera) runs from export --web, checked by a scripted visit of 1,800 frames or more replayed in Python, Node and Chromium in its CI, and by its bench before and after. architectureThe desktop keeps a pose per entity in JointStore (src/manifoldx/skinning.py:43). The export writes the poses of posed entities into ecs.bin beside the components, and the joint count of each skinned geometry into the header; the page's Store keeps a pose per entity and resets it on destroy and respawn, as the desktop's release hooks do. scene.js leaves skinned entities out of the batches and draws each as a SkinnedMesh whose bones are not in the scene graph: their matrixWorld is the pose, so three's skeleton multiplies it by identity inverses (Q6 of the spec: one draw call per skinned entity). The consumer's world becomes a manifoldx app in Python that reads the same space JSON at setup; its host page frames the export and talks to it through events (spec Q1). techPython 3.13 and numpy 2; plain ES modules; Node 20+ for node --test and the replay; three.js 0.186.1 as vendored, its GLTFLoader in the Node suite; Playwright with Chromium in the browser CI job on lavapipe; pygltflib in the glTF tests. spec.knowledge/analysis/2026-11-07-web-target-slice5-design.html (approved; sections 05, 08, 11, 12 and 13; Q1, Q6, Q7 and Q8 of section 16) builds onplan 5a (merged as #166) and plan 5b (merged as #169). This plan's branch is feat/web-target-5c from main at b399468; its PR targets main. gia-uh/manifoldx#13 (desktop anchors), being fixed on fix/gui-anchors, is assumed merged before task 8: the consumer's button column sits on a side. code it changesdesktop: src/manifoldx/skinning.py, src/manifoldx/gltf/writer.py, glb.py, engine_export.py. web: src/manifoldx/web/ types.py, transpile.py, snapshot.py, replay.py, and in js/: pyrt.js, manifoldx.js, scene.js. examples/web_crowd.py. Then the consumer's repository (tasks 8 to 14). executionsubagent-driven, one queue worker per task, in order. Tasks 2 to 5 depend on 1 only through the test fixtures; 3 needs 2 (@ builds the poses); 4 needs 3; 5 needs 2; 6 needs 3 and 4; 7 closes the manifoldx PR. Tasks 8 to 14 run in order after the PR merges.

Open questions

Each had a recommendation; the maintainer accepted all five on 2026-11-07. Tasks are written for those answers.

1 · Labels and speech bubbles while the port waits for slice 7settled · maintainer

The consumer draws HTML labels and speech bubbles at 3D points, with overlap avoidance (its drawLabels, about 50 lines). The spec moves them into manifoldx in slice 7 and says nothing of them for 5c. Once the world is in the export, the host page cannot project a 3D point: the camera is in the frame. Either the labels disappear from the consumer between 5c and slice 7, or frame code projects the points and emits their screen positions to the host.

recommendationAdd Camera.project to frame code (task 5; the desktop already has it at src/manifoldx/camera.py:103, so parity holds) and let the world emit the label anchors' pixels each frame they change. The host keeps its label code until slice 7. If the answer is no, drop task 5 and task 14 removes the labels and bubbles with the world code.

2 · The download once the world comes from the library glbsettled · maintainer

Today the consumer builds its geometry and its canvas textures in the browser from a small JSON file: 581 KB on a first visit without the music, by its audit. After the port, every geometry and texture is in the library glb, written as raw float32 with no meshopt (that is #156, slice 6), and the spec's Q7 only bounds the rooms (203 KB gzipped). The grounds, stands, people and props may weigh more than the rooms.

recommendationTask 8 measures the gzipped glb and ecs.bin of the grounds alone, and task 12 of the whole space with every room. Both numbers go on #140. If the first visit grows past twice the audit's 581 KB, propose moving #156's meshopt ahead of slice 7, as Q7 does for slice 9; the port still merges, and its deployment waits for that answer.

3 · The pixel ratio, until slice 6settled · maintainer

The export page renders at min(devicePixelRatio, 2) (src/manifoldx/web/js/browser.js:153). The consumer starts a phone at ratio 1, at most 1.5 elsewhere, and scales it down to 0.7 when frames run slow. A phone of ratio 3 would draw four times the pixels after the port, and the spec puts the ratio cap and scaler in slice 6 (#160).

recommendationKeep it in slice 6. The bench of task 14 runs before and after at a device scale factor of 1, so it compares the world code and not the ratio. The port merges in 5c and reaches visitors once slice 6's cap lands; task 14 says so in its PR.

4 · Publishing runs the export on the serversettled · maintainer

The consumer publishes a fair by copying its viewer and writing the space JSON. After the port, publishing runs export --web per space in its backend. The export opens an offscreen wgpu device when the app has startup handlers (src/manifoldx/web/export.py:112-114), and load_texture needs one, so the backend's image needs a software Vulkan driver it does not have.

recommendationInstall mesa's lavapipe in the consumer's image, as manifoldx's CI does, and measure in task 8 the image's growth and the export's time per space. Building the textures as SVG or as arrays to avoid the device would change more code for the same result.

5 · The consumer's own work in flightsettled · maintainer

The consumer has a scope spec dated today (a character editor, visitor cards, analytics, video) whose tasks touch the same page script. A port that deletes the world sections while other branches edit them will conflict on every merge.

recommendationThe port builds beside the current viewer: a new entry page serves the export, and the old page stays as it is until task 14 swaps them and deletes the world code. Changes to the world sections of the page script made after task 8 starts are ported in the task that owns that section; the panels are free to change throughout.

Done when

The spec's criterion for 5c, and for slice 5

manifoldx (tasks 1 to 7): Engine.export_gltf writes a posed skinned entity with JOINTS_0, WEIGHTS_0, a skin and its pose, and three's GLTFLoader puts each vertex where the desktop draws it (#82 closed). compare(replay_python(...), replay_node(...)) is None for tests/web/apps/skinned.py and for web_crowd with its walking figure, the trace carrying each posed entity's joints; in Chromium the figure's bone matrices equal what the Python replay's set_joints gave, frame by frame, and the draw calls are the batches plus one per skinned entity. CI's test, web and browser jobs are green.

The second consumer (tasks 8 to 14): its world comes from manifoldx export --web: the grounds, stands and props as the library scene; the walkers, promoters, crew, guide and player moving and posed by set_joints; the animated props; walking by keys, by a click on the ground and by the Joystick; its button column as GUI Buttons; a stand's room spawned when the visitor comes to its door and destroyed when it leaves the cache of three. Its page script holds no world code (the frame loop, the people, the props, input and camera are deleted); what remains is the host page with the document panels, the labels (Q1), sound and fullscreen, talking to the export only through events.

Checked three ways in the consumer's CI: a scripted visit of 1,800 frames or more (walk the plaza, click-to-walk to a stand, enter and leave its room, press each button, push the Joystick) through Python and Node with compare None; the same script through Chromium with the frame checks for keys, clicks, widget events and the clock; and its bench before and after against the spec's budget (section 11): no worse in draw calls and in main-thread time per frame with the CPU slowed four times, at the six viewpoints. The measurements Q7 and Q8 asked for are posted on #140.

Global constraints

Review focus

File structure

fileresponsibility
src/manifoldx/skinning.pyJointStore.pose(entity, j), joint_count(geometry) (task 1)
src/manifoldx/gltf/writer.py, glb.pyNode.joints; JOINTS_0 and WEIGHTS_0; a skin and its joint nodes; MAT4 and uint8 accessors (task 1)
src/manifoldx/gltf/engine_export.pynodes() passes each skinned entity's pose (task 1)
src/manifoldx/web/types.py, transpile.py@, np.eye, nested np.array, np.stack of any rank (task 2); set_joints on the engine and the handle (task 3); camera.project (task 5)
src/manifoldx/web/js/pyrt.jsnd.matmul, nd.eye, nd.array of rows, stack of any rank (task 2)
src/manifoldx/web/snapshot.pythe header's skinned and poses; pose bytes in ecs.bin (task 3)
src/manifoldx/web/js/manifoldx.jsStore.skinned, Store.joints, setJoints, release on destroy and spawn, traceJoints (task 3); cameraMatrix and project (task 5)
src/manifoldx/web/replay.pyjoints_trace(engine), the trace's joints (task 3)
src/manifoldx/web/js/scene.jsskinned entities as SkinnedMesh, out of the batches (task 4)
examples/web_crowd.pythe walking figure (task 6)
tests/test_gltf_skin.py, tests/web/js/gltf_skin.test.mjsthe desktop writer and three's reading of it (task 1)
tests/web/test_matmul.pyarray parity for task 2
tests/web/apps/skinned.py, tests/web/test_joints.pythe joints across the export and the replay (task 3)
tests/web/js/scene.test.mjs, tests/web/test_node_suites.pythe skinned drawing in Node, on skinned.py's export (task 4)
tests/web/apps/projecting.py, tests/web/test_project.pycamera.project (task 5)
tests/web/test_web_crowd.py, tests/web/browser/test_web_crowd_page.pythe figure in the replay and in Chromium (task 6)
know-how/web-export.md, CHANGELOG.md, AGENTS.mddocs (task 7)
the consumer's repositorya world package of Python modules (app, grounds, stands, rooms, people, props, controls, textures), the host page, the publisher, CI jobs, the bench (tasks 8 to 14)

Tasks

1Desktop: the glTF writer writes joints, a skin and the current pose (#82; changes behaviour)skinning.py · gltf/writer.py · gltf/glb.py · gltf/engine_export.py · tests/test_gltf_skin.py · tests/web/js/gltf_skin.test.mjs · tests/web/test_node_suites.py · CHANGELOG.md

This task changes what Engine.export_gltf writes for an entity spawned from a geometry with joints. Today it writes the rest positions as a plain mesh node and reports nothing (#82). After it, the node carries JOINTS_0, WEIGHTS_0 and a skin posed as the entity is drawn, so a viewer that ignored joints now poses the figure, and the file holds more nodes (one per joint and one skeleton node per skinned entity). Unskinned entities are written as before.

interfaces

consumes JointStore (src/manifoldx/skinning.py:43-109), Node and _Writer (src/manifoldx/gltf/writer.py:16, :130-205), GlbBuilder.accessor (src/manifoldx/gltf/glb.py:35), nodes() and export_engine (src/manifoldx/gltf/engine_export.py:101-150) · produces JointStore.pose(entity: int, j: int) -> np.ndarray, (j, 4, 4) float32 row-major, identity for an entity never posed; joint_count(geometry: dict) -> int in skinning.py, int(max(joints)) + 1; Node.joints: np.ndarray | None = None, a (J, 4, 4) row-major pose; library meshes of a skinned geometry carry JOINTS_0 and WEIGHTS_0 and no skin; _TYPE[16] = "MAT4" and uint8 in _COMPONENT
  1. Write the failing tests in a new tests/test_gltf_skin.py, reading the glb with tests/gltf_helpers.py's load (a pygltflib GLTF2, as plan 5a's departures say). The fixture builds the figure of examples/skinning.py (four parts, joints 0 to 3) at setup on an offscreen engine, spawns it at pos=(1, 2, 3) with a rotation of 0.5 rad about y and scale=(2, 2, 2), and poses it with handle.set_joints(P), P four float32 matrices: identity, a translation by (0, 0.1, 0), and rotations of 0.3 and -0.3 rad about x through the shoulders. A Node test, tests/web/js/gltf_skin.test.mjs, on a glb that a new session fixture skinned_glb_path in tests/web/test_node_suites.py writes beside expected.json (each vertex at TRS · P[joint] · (x, y, z, 1), computed in numpy float64) and passes as MX_SKIN_GLB: Run uv run pytest tests/test_gltf_skin.py tests/web/test_node_suites.py -q: the new tests fail (no JOINTS_0, no pose).
  2. Implement. JointStore.pose reads mirror[block_of[entity], :j].transpose(0, 2, 1). glb.py gains np.dtype(np.uint8): 5121 and _TYPE[16] = "MAT4". _Writer.accessors adds JOINTS_0 (uint8, the joint in column 0) and WEIGHTS_0 (float32, 1 in column 0) when the geometry has "joints", so library meshes carry them too; skinned and unskinned uses of one geometry share the accessors as today. _Writer.node, when node.joints is set: J joint nodes, each {"name": f"{name}_joint_{j}", "matrix": node.joints[j].T.ravel()}; a skeleton node f"{name}_skeleton" with the TRS the plain node would have, its children the joints, added to the scene's roots; one skin {"joints", "inverseBindMatrices": J identities as a MAT4 accessor, "skeleton"}; the mesh node keeps the name and extras, takes "skin", and has no TRS. The reason is in departure 3. nodes() sets joints=engine._render_pipeline._joints.pose(i, joint_count(geo)) for a geometry with joints.
  3. Run the same command: all pass. Run uv run pytest tests/test_gltf_library.py tests/test_gltf_export.py -q too (the files that exist under those names; ls tests/test_gltf*): unskinned output is unchanged.
  4. Add to CHANGELOG.md under [Unreleased], ### Changed: Engine.export_gltf writes a skinned entity with its joints and its current pose: JOINTS_0 and WEIGHTS_0 on its mesh, a skin with identity inverse binds, and one joint node per joint under a node carrying the entity's Transform. Viewers that ignored the joints now pose the figure. Lifts the 0.10.0 known limitation (#82). Leave the released section's text as it is.
  5. Commit: feat(gltf): skinned entities export with their joints and pose (#82), the body saying it changes the written file for skinned entities.
verify

uv run pytest tests/test_gltf_skin.py tests/test_gltf_library.py tests/web/test_node_suites.py -q: all pass. Write the joint matrices row-major once (drop the .T): the Node test fails on the first rotated vertex.

2The array subset gains @ on matrix stacks, np.eye, nested np.array and np.stack of any rankweb/types.py · web/transpile.py · js/pyrt.js · tests/web/test_matmul.py

interfaces

consumes NdArray, CAST, TYPED, stack, nd.array (src/manifoldx/web/js/pyrt.js:237-541), ND_FUNCTIONS and lib_call (src/manifoldx/web/types.py:640-646, :1276-1300), the dtype passed last (plan 5a, departure 32) · produces $rt.nd.matmul(a, b, dtype) on shapes (..., n, k) @ (..., k, m), leading dimensions equal or one side of rank 2; $rt.nd.eye(n, dtype); $rt.nd.array(rows, dtype) taking a list of equal-length lists of numbers or of rank-1 arrays, giving rank 2; stack(list, 0, dtype) of equal-shape arrays of any rank, giving shape [k, ...shape] (axis 1 keeps today's rank-1 form); types: ast.MatMult between nd operands of rank ≥ 2 types as nd(numpy 2's dtype, max rank); numpy.eye types as nd(dtype or "f64", 2); np.array of a list of lists or of arrays types as nd(d, 2)
  1. Write the failing tests in tests/web/test_matmul.py with tests/web/parity.py's run_both, each main() returning a value both sides trace: Run uv run pytest tests/web/test_matmul.py -q: they fail at the export (MatMult on numpy arrays is outside the subset).
  2. Types and transpile. ND_OPS gains ast.MatMult: "matmul"; the binop rule types it as above and fails a rank-1 operand with the message of the test. numpy.eye joins lib_call with one positional N and dtype= (other arguments fail as "this call to np.eye()"). np.array of a list whose elements are lists of numbers or rank-1 arrays becomes $rt.nd.array(rows, d); np.stack accepts any equal rank with axis 0 (default), axis 1 only for rank 1 as now.
  3. Runtime. float32 matmul: for each output element, acc = 0, then for k in order acc = Math.fround(acc + a_ik * b_kj), the product of two float32 values being exact in a double: the forward FMA chain numpy's float32 matmul computes (departure 1). float64: acc += a_ik * b_kj. Broadcasting: leading dimensions equal, or one operand of rank 2; anything else throws numpy's ValueError for the shapes.
  4. Run the same command: all pass. Write the measured count and CPU into this plan's departure 1 if they differ from it.
  5. Commit: feat(web): @ on matrix stacks, np.eye, nested np.array and np.stack of any rank.
verify

uv run pytest tests/web/test_matmul.py tests/web/test_ndarray.py tests/web/test_numpy.py -q: all pass, the breaking test included.

3set_joints in frame code: poses in ecs.bin, in the page's store and in the traceweb/types.py · web/transpile.py · web/snapshot.py · web/replay.py · js/manifoldx.js · tests/web/apps/skinned.py · tests/web/test_joints.py

interfaces

consumes JointStore.pose and joint_count (task 1), nd.matmul, nd.eye, nested nd.array, stack (task 2), ecs_bytes (src/manifoldx/web/snapshot.py:291), Store.fromBuffer, spawn, destroy (src/manifoldx/web/js/manifoldx.js:150-281), EntityHandle (:556), store_trace and the digest (src/manifoldx/web/replay.py:326-349) · produces header ecs.skinned: {gid: J} for every skinned geometry in the library and ecs.poses: [{"entity": i, "at": [offset, bytes]}], each a (MAX_JOINTS, 4, 4) float32 row-major block of a posed alive entity; JS Store.skinned: Map<number, number>, Store.joints: Map<number, Float32Array> (MAX_JOINTS × 16, row-major), Store.setJoints(indices, data, j); destroy and spawn delete the slots' poses; engine.set_joints(indices, matrices), EntityHandle.set_joints(matrices); MAX_JOINTS = 32 in manifoldx.js; trace key "joints": {str(i): [[16 floats] × J]} per posed alive entity, J from skinned, or {"digest": d, "n": k} past JOINTS_DIGEST_PAST = 8 posed entities; Python joints_trace(engine) -> dict in replay.py, JS traceJoints(store); types: "set_joints" in RUNTIME_SURFACE for manifoldx.Engine and manifoldx.engine.EntityHandle, returning None
  1. Write tests/web/apps/skinned.py: FIG, a 3-joint figure geometry (body, two arms) built at setup as examples/skinning.py builds its figure; BOX, a plain cube. Setup spawns three figures and a box, keeps the handles in a module-level Figures object with class-level annotations (5a, departure 49), poses figure 0 with handle.set_joints(...) before run(), and calls engine.set_origin(100.0, -50.0). A helper about(px, py, pz, axis, angle) -> np.ndarray builds a (4, 4) float32 rotation about a pivot from a nested np.array of math.cos, math.sin and numbers, then @ with two translations. System pose(dt): angle from engine.elapsed; for each alive figure, a (3, 4, 4) np.stack; one engine.set_joints(np.array([f.index for f in alive]), np.stack(poses)). Frame 10: figure 1 gets set_joints with J = 2 once and leaves the crowd call. Frame 30: figure 2 destroyed; frame 31: a new figure spawned into its slot, not posed until frame 40. Then the failing tests in tests/web/test_joints.py: Run uv run pytest tests/web/test_joints.py -q: fails at the export (set_joints on an EntityHandle is outside the surface).
  2. Export. ecs_bytes writes skinned from the geometry registry (every registered geometry with "joints", joint_count each) and poses for each alive entity whose block_of is not 0, its block read with pose(i, MAX_JOINTS), each block on a multiple of 4 bytes as 5a's blocks are.
  3. Runtime. Store.fromBuffer loads both. setJoints(indices, data, j) creates a pose of 32 identities for a slot that has none and writes j matrices into it. engine.set_joints and EntityHandle.set_joints check and fail in the desktop's order and words (src/manifoldx/engine.py:1094-1110, :155-163): shapes first, then the geometry of each entity through its Mesh column and skinned; the values are cast to float32; an empty index list does nothing. Store.destroy deletes the pose of every slot it frees and Store.spawn of each slot it hands out, as the release hooks run (src/manifoldx/skinning.py:97).
  4. Trace. joints_trace reads the desktop's JointStore for alive entities with a block, ascending, J from joint_count of the entity's geometry; traceJoints reads Store.joints the same way. Past 8 the digest is 5a's formula over the float32 words of all J-joint blocks, in entity order. Both traces add "joints" beside "store".
  5. Run uv run pytest tests/web/test_joints.py tests/web/test_ecs_snapshot.py tests/web/test_handles.py -q: all pass.
  6. Commit: feat(web): set_joints in frame code, poses in ecs.bin and the trace.
verify

uv run pytest tests/web/test_joints.py tests/web/test_ecs_snapshot.py tests/web/test_handles.py tests/web/test_store.py -q: all pass, the breaking test included.

4The page draws each skinned entity as a SkinnedMesh posed from the storejs/scene.js · tests/web/js/scene.test.mjs · tests/web/test_node_suites.py

interfaces

consumes Store.skinned, Store.joints (task 3), library meshes with JOINTS_0, which GLTFLoader reads as skinIndex and skinWeight (task 1), buildScene, writeInstance, sync (src/manifoldx/web/js/scene.js:111-310) · produces MxScene.skinned: Map<number, SkinnedMesh> keyed by entity; skinned entities are in no batch; each SkinnedMesh has J bones outside the scene graph, matrixAutoUpdate false, bound with mesh.bind(new Skeleton(bones), new Matrix4()); sync sets the mesh's matrix from the Transform row as writeInstance does, each bone's matrixWorld from the pose (transposed into three's column-major) or the identity, and the mesh's boundingSphere as the desktop pads it, r * 1.5 + 0.5 about the box centre (src/manifoldx/renderer.py:113-120); materialOf is unchanged
  1. Add a session fixture skinned_export to tests/web/test_node_suites.py (skinned.py exported, as spawner_export is) passed as MX_SKINNED_EXPORT, and the failing tests in tests/web/js/scene.test.mjs: Run uv run pytest tests/web/test_node_suites.py -q: the new cases fail.
  2. Implement in scene.js: buildScene records which library geometries have skinIndex; the batch membership pass skips their entities; a pass over alive skinned entities creates, keeps or disposes their SkinnedMesh (geometry shared, skeleton per entity, skeleton.dispose() on removal) under the same parent as the batches; shadows, fog and the calibration apply as to batches. Skinned meshes rebuild when the store object or its version changes, as batches do (5a, departure 53), and their matrices and bones are written every sync.
  3. Run the same command: all pass.
  4. Commit: feat(web): the page draws skinned entities posed from the store.
verify

uv run pytest tests/web/test_node_suites.py -q: all pass. Skip the bone write once: "bone matrices are the store's pose" fails.

5Camera.project in frame code (open question 1)web/types.py · web/transpile.py · js/manifoldx.js · tests/web/apps/projecting.py · tests/web/test_project.py

Runs if question 1 is answered as recommended; otherwise skip it and mark it done with a one-line note.

interfaces

consumes Camera.project, get_view_matrix, get_projection_matrix (src/manifoldx/camera.py:103-120 and their definitions in that file), nd.matmul float32 (task 2), the page's camera object (plan 2) · produces JS cameraMatrix(camera, aspect) -> Float32Array(16), projection times view in float32 as the desktop computes it; camera.project(points, width, height) returning [xy, w], an f64 NdArray (n, 2) and an f64 NdArray (n,); types: "project" in the camera's surface returning tuple[nd[f64, 2], nd[f64, 1]]
  1. Write tests/web/apps/projecting.py: the camera orbits a point; five world points as a float64 (5, 3) array, one behind the camera; a system stores xy.tolist() and w.tolist() from engine.camera.project(PTS, engine.w, engine.h) in engine.state. Then tests/web/test_project.py: Run uv run pytest tests/web/test_project.py -q: fails at the export.
  2. Implement cameraMatrix from the desktop's two functions line for line in float32, the product through nd.matmul; project as the desktop's body: points as float64 with a column of ones, times the matrix transposed, the divide and the pixel formulas in float64. Add project to the camera's surface.
  3. Run the same command: all pass.
  4. Commit: feat(web): Camera.project in frame code.
verify

uv run pytest tests/web/test_project.py tests/web/test_frames.py -q: all pass, the breaking test included.

6web_crowd gains a walking figure, replayed in Node and in Chromiumexamples/web_crowd.py · tests/web/test_web_crowd.py · tests/web/fixtures/web_crowd_script.json · tests/web/browser/test_web_crowd_page.py

interfaces

consumes tasks 2 to 4; web_crowd's script, PATHS and the fixture (tests/web/test_web_crowd.py:14-60); the browser conftest's export and BATCHES_OF (tests/web/browser/conftest.py) · produces in examples/web_crowd.py: FIGURE, a 6-joint geometry (body, head, two legs, two arms) built at setup; one figure spawned at setup; a system walk(dt) moving it by its handle along a circle of radius 6 about the origin at 1.2 m/s and posing it each frame with handle.set_joints(np.stack([...])), legs and arms swinging by 0.5 * sin(walked * 2.2), opposite pairs in opposite phase; key f pauses and resumes it; engine.state["walked"] joins PATHS
  1. Write the failing tests. In tests/web/test_web_crowd.py: the existing replay test is unchanged and now carries joints; In tests/web/browser/test_web_crowd_page.py: Add f twice to the script (frames 400 and 460), regenerate the fixture with the generator the seventh test checks, and run uv run pytest tests/web/test_web_crowd.py -q: the new tests fail.
  2. Implement the figure in examples/web_crowd.py. Its matrices use about() as in task 3's app (nested np.array and @), the swing on float64 trigonometry (5a, departure 9). The figure has no Velocity and no Wave, so web_crowd's queries leave it out: pick and drift still see only boxes.
  3. Run uv run pytest tests/web/test_web_crowd.py -q, then the browser file where Chromium is installed: all pass. If 5a's or 5b's counts in that file move because the figure takes a slot, update them and say which in this plan's departures.
  4. Commit: feat(examples): a walking skinned figure in web_crowd.
verify

uv run pytest tests/web/test_web_crowd.py tests/web/browser/test_web_crowd_page.py -q: all pass, or the browser file skipped here and green in CI's browser job.

7Docs, CHANGELOG, the PR and CIknow-how/web-export.md · CHANGELOG.md · AGENTS.md
  1. know-how/web-export.md: the surface gains set_joints (engine and handle), @ on matrix stacks with its float32 rule, np.eye, nested np.array, np.stack of any rank and camera.project; a matrix times a vector is out, and how to write it; skinned entities draw one call each (spec Q6). CHANGELOG.md under [Unreleased], ### Added: In export --web frame code: set_joints on the engine and on handles, @ on matrix stacks, np.eye, nested np.array, np.stack of any rank and Camera.project; the page draws skinned entities posed (#140). AGENTS.md's web target line names plan 5c and the plan's path.
  2. Commit docs(web): skinned entities and matrices in the know-how, push the branch, open the PR against main with Closes #82 and not #140 (it closes with the consumer's port), and work it until CI's test, web and browser jobs are green. Ask the maintainer to merge.
verify

CI green on the PR, the browser job listing test_web_crowd_page.py with no skips; grep -n set_joints know-how/web-export.md finds the new lines.

The second consumer's port

Tasks 8 to 14 run in the second consumer's repository after this plan's PR merges, on one issue, one branch and one PR there, as plan 2's and plan 3's consumer tasks did for the first consumer. The consumer's page script is 3,446 lines; this table is its split by its own section comments, and which task replaces each section. Line counts are today's and move as the consumer works (question 5).

section of the page scriptlinesafter the port
renderer, scene, light; building blocks119Python setup (task 8)
the grounds; platforms; the first slice and the merge424Python setup, static parts merged per 32 m cell (task 8)
stands; and the canvas texture module (a separate file)497 + 384Python setup, textures drawn with Pillow (task 9)
models (bodies, poses); people247skinned geometries and set_joints (task 10)
input, camera (its world half); the loop's joystick, button column and frame loop≈ 310frame code, a Joystick and GUI Buttons (task 11)
inside a stand; interiors and the theater356rooms spawned from the library (task 12)
prop kits; miradors and the world's tail (greenery, clouds, kits placed)≈ 880Python setup and query systems (task 13)
the sheet, messages, cards, picker, map; panel wiring of input≈ 470stays: the host page's document panels (Q1 of the spec)
labels and speech bubbles≈ 50stays, fed by an event (question 1), until slice 7
fullscreen and orientation, sound start, the host handshake, the resolution scaler≈ 110stays (sound and fullscreen until slices 6 and 7); the scaler goes with the world (question 3)

Sum: about 2,860 lines of the page script and the 384-line texture module are replaced, about 3,240 lines of JavaScript, by an estimated 2,500 to 3,000 lines of Python in a new world package. The page script keeps about 590 lines. The consumer already depends on manifoldx (its models are built with manifoldx.modeling and written with manifoldx.gltf), and its person builder already groups each body's vertices by joint, so people become skinned geometries without a new model format.

8Consumer: the issue, the pin, the world app's shell with the grounds, the host page, publishing, and the first measurementsthe consumer's repository: pyproject.toml · a world package (app, grounds) · a new entry page · its publisher · Dockerfile · CI · tests/world/

interfaces

consumes manifoldx at the merge commit of this plan's PR: export_web (manifoldx.web.export), replay_python, replay_node, compare (manifoldx.web.replay), manifoldx.modeling, the host-page bridge (5b, task 9) · produces in the consumer: world/app.py, the manifoldx app, reading the space JSON the viewer reads today (path from the SPACE_JSON environment variable, default the demo space) at setup; world/grounds.py, build_grounds(engine, space) -> Grounds (the walkable surface, the blocks and platform heights later tasks use: height_at(x, z), blocked(x, z)); merge_cells(parts, cell=32.0), static parts merged per cell into vertex-coloured geometries; a new entry page that frames the export and relays events; the publisher writes world/<space>/ per space with export_web; tests/world/visit.py, the frame-script builder every later task extends
  1. Open an issue in the consumer's repository (the 3D world from manifoldx export --web), linking gia-uh/manifoldx#140 and this plan; branch from its main. Following its AGENTS.md, copy tasks 8 to 14 into a plan page in its plans folder with its real file names, and mark progress there as well as here.
  2. Pin manifoldx to the merge commit in pyproject.toml's [tool.uv.sources]; uv sync; its tests still pass.
  3. Write the failing tests in tests/world/test_grounds.py: Run uv run pytest tests/world -q: all fail (no world package).
  4. Implement world/app.py (engine, sun, fog and sky from the renderer section's values) and world/grounds.py from the grounds, platforms, first-slice and merge sections. The merge keeps the page script's key (cell in x and z) so culling stays as its audit measured; animated and spawned things are never merged. The entry page frames the export's index.html, forwards mx:emit messages to the document panels' code and posts {"mx": "emit"} messages in. The current viewer is untouched (question 5).
  5. Publishing: the publisher runs export_web for each space of a fair into the bundle. Install lavapipe in the image (question 4). Add Node to its CI so the replay tests run there.
  6. Measure once, on a quiet host: the gzipped scene.glb and ecs.bin of the demo space's grounds, the export's time per space, and the image's growth. Post them on the consumer's issue and, without naming the consumer, on gia-uh/manifoldx#140 (question 2).
  7. Run uv run pytest tests/world -q: all pass. Commit: feat(world): the grounds from manifoldx export --web.
verify

uv run pytest tests/world -q: all pass, the replay not skipped. Shift one platform's height in height_at by 0.1: the height test fails.

9Consumer: the stands and their texturesthe consumer's world package (stands, textures) · tests/world/test_stands.py

interfaces

consumes build_grounds, merge_cells (task 8), manifoldx.textures.load_texture, engine.set_material, engine.elapsed · produces build_stands(engine, space, grounds) -> list[Stand], a Stand holding its place, door, kit and the handles of its parts that change (boards, billboards); world/textures.py with one function per texture of the canvas module (logo, product card, screen, billboard, sign, displays, directory, badge), each returning a Pillow image the app loads at setup; a system rotate_billboards swapping each billboard's material every 8 s by engine.elapsed
  1. Write the failing tests in tests/world/test_stands.py: Run uv run pytest tests/world/test_stands.py -q: fails.
  2. Implement from the stands section and the texture module. Text on textures is drawn with a font file the repository already ships, or one it adds; a texture's look may differ in antialiasing from the canvas, not in layout.
  3. Run the same command: all pass. Commit: feat(world): the stands and their textures in Python.
verify

uv run pytest tests/world/test_stands.py tests/world/test_grounds.py -q: all pass.

10Consumer: the people as skinned entities posed by set_jointsthe consumer's world package (people) · its person model builder · tests/world/test_people.py

interfaces

consumes Mesh(joints=), engine.set_joints(indices, matrices), @, np.stack, np.eye, nested np.array (tasks 2 and 3), random.Random made at setup (5b), the person model builder's joint groups and pivots · produces skinned(look) -> manifoldx.modeling.Mesh, one joint per group, every look registered at setup so the library holds it; People with the walkers, promoters, crew, guide and player, each an app object holding its handle, path state and pose angles; a system pose_people(dt) making one (N, J, 4, 4) stack and one engine.set_joints per frame; a handler for the host's look event that destroys the player and spawns it with the chosen look at the same place and heading
  1. Write the failing tests in tests/world/test_people.py: Run uv run pytest tests/world/test_people.py -q: fails.
  2. Implement from the models and people sections and the grounds' deal and sit helpers. Random pauses draw from one random.Random seeded at setup.
  3. Run the same command: all pass. Commit: feat(world): people as skinned entities posed by set_joints.
verify

uv run pytest tests/world/test_people.py -q: all pass. Swap two joints' order in skinned(): the stride test fails.

11Consumer: walking, the camera, the Joystick and the button columnthe consumer's world package (controls) · tests/world/test_controls.py · tests/world/visit.py

interfaces

consumes engine.input, the pointer and key events, manifoldx.gui.Joystick, Button and anchored panels (5b and #13), height_at, blocked (task 8), the player (task 10) · produces a system walk(dt) taking keys, the Joystick's value and a click-to-walk target; ray(engine, x, y) and the ground pick for a click; the camera in third and first person with the page script's distances and easing; the button column as GUI Buttons in a panel anchored to the right; nearest() of the interactive things, and an open event to the host with {"kind", "id"} when the hint button or E acts; handlers for the host's place event (jump, take-me-to and the bench's viewpoints)
  1. Write the failing tests in tests/world/test_controls.py, extending visit.py with key, click and Joystick frames: Run uv run pytest tests/world/test_controls.py -q: fails.
  2. Implement from the input and camera section and the loop's joystick and button-column code. The touch pinch is slice 8: the wheel zooms.
  3. Run the same command: all pass. Commit: feat(world): walking, camera, Joystick and buttons in frame code.
verify

uv run pytest tests/world/test_controls.py tests/world/test_people.py -q: all pass.

12Consumer: rooms spawned at their doors, the theater, and the Q7 measurementthe consumer's world package (rooms) · tests/world/test_rooms.py

interfaces

consumes engine.spawn of library geometries and engine.destroy (5a), time.time() (5b), the stands (task 9), the player and place (tasks 10 and 11) · produces Rooms: every stand's interior built at setup as geometries and materials only (no entity), spawned when the visitor comes within 12 m of its door, at most three kept, the oldest not on screen destroyed; entering and leaving as the page script's enter and leave, the fade as a host event; the theater hall the same way, its screen following the agenda by time.time()
  1. Write the failing tests in tests/world/test_rooms.py: Run uv run pytest tests/world/test_rooms.py -q: fails.
  2. Implement from the sections on rooms, interiors and the theater.
  3. Measure once (spec Q7): the gzipped library glb of the demo space with every room, against the same build with no rooms. Post both on the consumer's issue and on gia-uh/manifoldx#140 without naming the consumer: if the rooms add more than 203 KB, propose there that slice 9 moves before slice 7.
  4. Run the same command: all pass. Commit: feat(world): rooms and the theater spawned at their doors.
verify

uv run pytest tests/world/test_rooms.py -q: all pass. Keep four rooms: the cache test fails.

13Consumer: the prop kits and the animated propsthe consumer's world package (props) · tests/world/test_props.py

interfaces

consumes the grounds' free-spot rule (task 8), query systems over Component arrays (5a), random.Random (5b) · produces one function per kit piece of the prop kits section, built at setup; Components for what moves alike (Spin, Bob, Orbit, Drift) and one query system each; the dogs and other props with their own logic as app objects holding handles; detail by distance: a stand's details and crew take a material made at setup with opacity 0 beyond 48 m and scenes beyond 72 m, as the third consumer hides its floors (spec section 03)
  1. Write the failing tests in tests/world/test_props.py: Run uv run pytest tests/world/test_props.py -q: fails.
  2. Implement from the prop kits section and the world's tail (miradors, greenery, clouds, kits placed).
  3. Run the same command: all pass. Commit: feat(world): prop kits and animated props.
verify

uv run pytest tests/world/test_props.py -q: all pass.

14Consumer: the cut, the scripted visit in CI, the bench before and after, and Q8the consumer's page script and pages · its bench · CI · tests/world/test_visit.py · tests/world/browser/

interfaces

consumes tasks 8 to 13, Camera.project (task 5) · produces the visit script (1,800 frames or more); the host page as the only page script, holding the document panels, the labels fed by a labels event of anchors' pixels, sound and fullscreen; the bench reading __mx.renderer and placing the visitor through the place event; a browser CI job with Playwright, Chromium and lavapipe
  1. Write the failing tests. tests/world/test_visit.py: test_the_visit_replays, the full visit (walk the plaza, click-to-walk to a stand, enter and leave its room, press each button, push the Joystick) through Python and Node, compare None. tests/world/browser/test_visit_page.py: the same script driven through the host page with Playwright's keyboard, mouse and a two-finger touch (5b's conftest helper as a model), compare(replay_python(page_frames), page_trace) None, and the frame checks: each key and click in its frame, each widget event the frame after its pointer, the clock never backwards; a labels event places a label at the pixel Camera.project gives.
  2. Run them: they fail while the entry page still loads the old viewer.
  3. The cut. The entry page frames the host page, which frames the export. Delete from the page script the sections tasks 8 to 13 replaced, the frame loop and every three.js import; delete the canvas texture module; remove the world's markup from its page. grep -n "three" over the page script finds nothing.
  4. The bench. Point it at __mx.renderer and the place event; run it on main and on the branch at a device scale factor of 1 with the CPU slowed four times (question 3), compare with its compare tool, and check the spec's budget: no worse in draw calls and main-thread time per frame at the six viewpoints, frame code under 18 ms. Q8: triangles per view and the share the frustum keeps, before and after; if they grow, open a manifoldx issue for splitting large batches by a spatial cell inside scene.js, as Q8 says. Post the table on the consumer's issue and, without naming the consumer, on gia-uh/manifoldx#140, with the host's load.
  5. CI: add the browser job. Run both test files: all pass. Commit feat(world): the 3D world comes from manifoldx export --web, open the PR, work it until CI is green, and ask the maintainer to merge. Deployment waits for questions 2 and 3, and for the maintainer's go.
verify

The consumer's CI green with the replay and browser jobs not skipped; the page script has no three.js import and no frame loop; the bench table on #140 meets the budget or names the line that does not.

Where this plan departs from the spec

Self-review

Spec coverage, 5c of section 12: joints in the glTF writer and #82 (task 1), @ in the page (2), set_joints (3), the page drawing skinned entities (4), the walking figure in web_crowd (6), the second consumer's port (8 to 14). Section 08: JOINTS_0, WEIGHTS_0 of 1, a skin of identity inverse binds, poses in ecs.bin, a SkinnedMesh per entity (1, 3, 4). Section 13's items for 5c: the glTF writer's joints read by GLTFLoader in Node (1); "a skinned entity's bone matrices equal what set_joints was given" in Chromium (6); @ on stacks in the parity tests (2). Section 11's consumer budget and Q7 and Q8 (12, 14). The done criterion for slice 5 (14).

Names across tasks: JointStore.pose, joint_count (1) in 3; nd.matmul, nd.eye, nested nd.array, stack (2) in 3, 5, 6, 10; Store.skinned, Store.joints, setJoints, the trace's joints (3) in 4 and 6; MxScene.skinned (4) in 6; camera.project (5) in 14; build_grounds, height_at, blocked, merge_cells, visit.py (8) in 9 to 14; the open, place, look and labels events (10, 11, 14).

Proportion: code is given for tests whose assertions carry values; implementations are named by signature and by the desktop file and line, or the consumer's section, they follow.