spec · web target · slice 5 approved2026-11-07#140 #158 #161

The web target, slice 5: the second consumer

status: approved·issue #140, with #82 #153 #154 #158-#161·follows the slice 1-4 spec of 2026-11-06

Slices 1 to 4 made a walk-and-pick app run in a tab from Python alone. Slice 5 gives the page the rest of manifoldx's runtime model: entities spawned, moved and destroyed by frame code over component arrays, events with payloads, the interactive widgets and posed skinned meshes. The check is the second consumer, a virtual trade fair whose 3D world is today 3,446 lines of hand-written three.js; at the end of slice 5 that world comes from manifoldx export --web.

01What this delivers

Today frame code may move the camera, swap materials and write three widget fields. Every entity stays where setup put it, so an app that wants anything else to move keeps it in JavaScript. A third consumer, a factory tour built with export --web, shows the result: nothing in it moves but the camera, its floors hide by swapping to an invisible material, and its joystick, on-screen buttons, minimap, fullscreen and install support are 472 lines of JavaScript pasted into the export by a shell script.

The page also draws each entity as its own three.js mesh, one draw call each. Measured on this host in headless Chromium (software GL, a loaded 4-core machine; section 11 has the method):

9.9 ms
main thread per tick, 1,000 static boxes, the page as it is
66 ms
the same with 10,000 boxes: under 16 fps before any app code
1.7 ms
1,000 boxes as one instanced mesh, all moving every frame
0.48 ms
one numpy-style system step over 10,000 entities in Node

After slice 5, an app's systems take a component query, update component arrays with numpy expressions, spawn and destroy entities, emit and handle events, and read Buttons, Sliders, Toggles, Images and a new Joystick. The page holds the entity store as typed arrays and draws one instanced mesh per geometry and material, as the desktop renderer batches. Each of these is checked the way slices 2 to 4 were: a scripted input replayed through the Python app and the export, compared frame by frame, in Node and in Chromium.

02Decisions

decisionwhatwhyby
the trade fair is slice 5's consumerSlice 5 is done when the second consumer's 3D world runs from export --web (section 12).Set in the slice 1-4 spec. Its world exercises every gap at once: about 40 posed people, animated props, rooms built on entering, on-screen controls.maintainer
functional parityEvery runtime feature the page gains is the desktop's feature with the desktop's semantics. Where the desktop lacks it (a Joystick, a wall clock in frames), it lands on the desktop first, in the same slice.#158: the web build is the same app, not a reduced copy. A page-only API would make the browser the only place an app can be tested.maintainer
no app JavaScriptThe fair's world code becomes Python. The only JavaScript it may keep after slice 5 is its host page for document panels, which talks to the export through events (Q1).The rule of the slice 1-4 spec. The host page is the one boundary the rule does not settle, so it is an open question.maintainer
the ECS crosses as arraysThe export writes the entity store to ecs.bin: the alive mask, the free list, the high-water mark and every registered component's rows below it, with each component's dtype and field layout in state.json.A JSON row per entity would be 10 numbers in text per Transform; 10,000 entities are 400 KB of float32 raw, less gzipped. The page then holds the same arrays the desktop holds.agent
same slots, same orderThe page's spawn picks slots exactly as EntityStore.spawn does (the free list popped from its end, then the lowest never-used slots); destroy dedupes and skips dead slots as the desktop does.Entity indices are values: app objects store them and the replay traces them. Any other allocation is a mismatch on the first respawn.agent
writes land when the desktop lands themWrites through a query (q[Transform].pos += v) and destroy are queued and applied at the frame's flush, after every system; spawn and writes through an entity handle (e.transform.pos = p) are immediate.That is Engine._draw_frame's order (src/manifoldx/engine.py:1202). A system that reads what an earlier system wrote sees the old value on the desktop; the page must too.agent
numpy over components, one loop per operationEach numpy operation on a component array runs as one loop over a typed array into a new typed array, rounding to float32 where numpy does. No fusion of expressions in slice 5.Per-operation rounding is what numpy computes, so parity is exact by construction. Measured: 0.48 ms for pos += vel * dt over 10,000 entities with temporaries, 0.09 ms fused; the simple form fits the budget.agent
one instanced mesh per batchThe page draws entities as a three.js InstancedMesh per (geometry, material), the desktop's batch key, rebuilding membership when spawns, destroys or set_material change it and uploading the instance matrices of batches whose transforms moved.Measured: 1,000 boxes cost 9.9 ms a tick as meshes and 1.7 ms instanced; 10,000 cost 66 ms and 13.1 ms. Static scenes gain too.agent
under --web the glb is a libraryexport --web writes each registered geometry once and every material, tagged with their ids, and no node per entity; the entity table comes from ecs.bin. export_gltf for other uses keeps its nodes.The page spawns geometries no entity uses at export (a room's walls), and batches need geometry ids, not nodes. The glb export for other tools stays a scene.agent
queries filter by componentThe desktop store tracks which components each entity was spawned with, and a query returns the alive entities that have all of them, as its docstring says.EntityStore.get_component_view returns every alive entity whatever the query (src/manifoldx/ecs.py:123). The page could copy the defect; parity with a defect would freeze it (Q3).maintainer
one event queue, the desktop's orderEach frame delivers the frame event, then the events emitted during the previous frame, then the input and widget events since then, in that order. The page records input and widget events in the replay frame, so Python replays them through the same bus.That is the desktop's order: emits queue during systems, OS events queue between frames, and dispatch_pending drains both at the next frame's start.agent
random.Random ported bit for bitrandom.Random instances (and the module's functions) cross with their Mersenne Twister state, and the runtime implements random, uniform, randint, randrange and choice as CPython does.The fair's people pause for random times. A replay compares exact values, and MT19937 is small and fully specified; numpy's generators stay setup-only.agent
five widgetsButton, Slider, Toggle and Image draw in the page with the desktop's fields and events; a new Joystick widget lands on both.Both consumers wrote a joystick and on-screen buttons by hand. Image is an SVG the page can show as is, so it is cheap.agent
joint poses in, clips outset_joints works in frame code and the export writes each skinned geometry's joints, which closes #82. Animation clips are not part of slice 5.The fair's people are rigid parts with one joint each, posed by code every frame; set_joints is that. The desktop has no clips to be at parity with.agent
sound is outNo sound API in slice 5.manifoldx has no audio on the desktop (no module names it). Parity means designing both, with a dependency choice for the desktop (Q2).agent
#153 and #154 ride alongengine.camera.up joins the surface, and a write to a material's field fails with a message that points at set_material.Both are surface fixes in the files slice 5 edits anyway.agent
a host page may frame the exportAn app may keep a host page that frames its export and talks to it only through events (section 06). The second consumer's world counts as replaced when its world code is gone from its page script.Q1. Its document panels need rich text, text input and network access the GUI lacks; porting them first would hold slice 5 behind #105. Revisit when the GUI has text input.maintainer
the audio backend waits for slice 7A spike in slice 7 measures latency and install weight of two desktop candidates on the three desktop platforms; the API is a loop, a one-shot, a positional source and volume, started from frame code.Q2. Sound is out of slice 5, and the dependency is the maintainer's choice once it is measured.maintainer
the query fix lands firstQuery filtering is fixed on the desktop as the first task of plan 5a, with a CHANGELOG entry under changed behaviour, and the examples and demos are run before and after.Q3. It is what the docstring promises and what an ECS query means; matching the defect would freeze it.maintainer
widgets drawn from the themeThe page draws Button, Slider, Toggle and Joystick from the widget's resolved style, with ARIA roles and arrow keys on the Slider, not as native inputs.Q4. The GUI's theme then means the same on the desktop and in the page.maintainer
Joystick is a manifoldx widgetJoystick lands in manifoldx.gui, small like the Slider, on the desktop and in the page.Q5. An app's controls stay one piece of code, and the replay can drive it.maintainer
no instanced skinning in slice 5One SkinnedMesh per skinned entity. A crowd past a few hundred gets a joint texture and a custom three.js material later.Q6. 40 people cost 40 draw calls, which the second consumer pays today.maintainer
measure the rooms in 5cPlan 5c measures the gzipped library glb with every room. If it adds more than 203 KB, slice 9 moves before slice 7.Q7. Until slice 9 the rooms ship in the first download.maintainer
batch culling measured in 5cBatches ship by (geometry, material). Plan 5c measures the second consumer's six viewpoints; if triangles per view grow, scene.js splits large batches by a spatial cell, with no API change.Q8. A batch is culled whole; the consumer's audit found culling worth 54 to 79% of the triangles per view.maintainer

03What the consumers need

Read from the second consumer's viewer (its frame loop, its people, input and panels) and the third consumer's app and the JavaScript it pastes into its export. Each row says where the need lands.

needwhat the consumer does todaymanifoldx todaylands in
moving people5 walkers along a path graph, 5 promoters pacing, stand crew that wander, point or sit, a guide, the player: position and heading eased every frameno entity moves in the pageslice 5 handle transforms, query systems
posed bodieseach person is one skinned mesh with a bone per part (legs, arms), weight 1, posed by angles from distance walked; 40 people, one draw call eachset_joints exists on the desktop; the export writes rest pose only (#82)slice 5
animated propsspinning, bobbing, waving flags, orbiting parts, flickering flames, drifting clouds, a pulsing markerno transform writesslice 5
moving machinesthe factory tour wanted them and shipped a static plantno transform writesslice 5
rooms built on enteringa stand's interior is built when its door comes near and dropped when three newer ones are cachedno spawn or destroy in frame codeslice 5 spawn from the geometry library
detail by distancea stand's details and crew hide beyond 48 m, scenes beyond 72 mno visibility on the desktop eitherslice 5 by destroy and spawn, or set_material to a hidden material, as the factory tour does
on-screen controlsa joystick and a column of round buttons on both consumers, written in JavaScript; the factory tour's synthesize key eventsButton, Slider, Toggle fail the exportslice 5 widgets and Joystick
a timed screenthe theater's screen follows an agenda by wall-clock timeframe code has no clock but dtslice 5 engine.elapsed and a recorded wall clock
rotating billboardseach billboard swaps its texture every 8 sset_material among materials made at setup works todaytoday, an app change
a texture that scrollswater and screens move their texture offsetmaterial fields are not writablelater, with material writes
labels and speech bubblesHTML labels placed at 3D points with overlap avoidance; bubbles over crewthe export drops text labels (no glTF form)slice 7
music and ambiencea looped track per biome, ambience synthesized with Web Audio, started by the first tapno audio anywhereslice 7 (Q2)
remembered choicesthe visitor's look, saved cards, guide seen, sound on, kept in localStorageengine.state lives one sessionslice 7 persisted keys
fullscreen, orientation, resolutionboth consumers: fullscreen and landscape on the first touch; the fair also scales the pixel ratio by frame timenothingslice 6 (#160)
install and offlinethe factory tour builds a manifest, icons and a service worker with sed over the exportnothingslice 6 (#160)
pinch, gamepad, control schemesthe factory tour turns a pinch into wheel events; both write first-person and orbit control by handone pointer, keys, wheelslice 8 (#161)
a minimapthe factory tour draws the scene again from above into a corner, through three.js's devtools hookthe desktop has render_to_texture; the page has one viewlater, with views
spaces and rooms on demandthe fair loads one space's JSON at a time and switches spaces by reloading its frameone glb, loaded wholeslice 9 (#159)
document panelscompany sheets with image pagers and video, a message inbox over the fair's HTTP API, saved cards, a map, the character screen: about 380 lines of main.js and most of its HTMLthe GUI has no rich text, text input or networkthe host page (Q1); in manifoldx with #105

04How it fits

setup Python, until run() scene.glb geometries + materials, by id ecs.bin alive, free list, components state.json objects, layouts, rng state app/*.js systems take queries the page, each frame Store typed arrays systems reads now, writes queued flush updates, destroys batches InstancedMesh each three.js render reads
New in slice 5: ecs.bin, the Store, the flush and the batches. The glb keeps the scene's lights, sky and fog; under --web it carries no node per entity.

All of it extends what exists: manifoldx.js gains the store, the flush and the event queue (Node runs it, so the replay covers it), scene.js gains the batches, gui.js the widgets, pyrt.js the array operations and the Mersenne Twister, and types.py, reach.py, transpile.py and snapshot.py learn queries, components and arrays. On the desktop, the store learns component membership (section 05), gui gains Joystick, frames gain a wall clock, and the glTF writer learns joints.

05The ECS in the page

The store

The page's Store holds what EntityStore holds: an alive mask (Uint8Array), the free list, the high-water mark, and per component a typed array of capacity × columns in the component's dtype (float32 for every built-in and every Component field today). It loads from ecs.bin with the rows below the high-water mark and grows by doubling up to max_entities; spawning past it throws the desktop's message (Max entities 100000 reached: ...). New on both sides: a membership bit per component and entity, set by spawn for the components it was given (Transform always), so a query returns the entities that have all its components.

Spawning and destroying

engine.spawn(Mesh(BOX), Material(RED), Transform(pos=p, scale=s), Velocity(v=v))     # immediate, returns a handle
engine.spawn(Mesh(DOT), Material(BLUE), Transform(pos=ps), n=k)                       # k rows, the handle of the first
engine.destroy(q[Life].t <= 0.0)                                                       # at the flush; a mask or indices
crate.destroy()                                                                       # an EntityHandle, at the flush

The component constructors that reached code may call are Mesh, Material, Transform and the app's Component subclasses, each turned into rows as get_data makes them, broadcast as the desktop broadcasts. Mesh(g) needs a geometry the export saw: one registered at setup, or held by a value reached code reads, which the export registers so the glb writes it. A geometry built in frame code (mx.geometry.cube() inside a system) fails the export: building meshes at runtime is #158's later part. A handle's destroy(free_geometry) frees nothing in the page, since the geometry stays in the library for the next spawn.

Systems with queries

@engine.system
def drift(q: Query[Transform, Velocity], dt: float):
    q[Transform].pos += q[Velocity].v * dt            # (k, 3) float32, applied at the flush
    q[Transform].rot += spin                          # composes quaternions, as _FieldView.__iadd__ does
    engine.destroy(q[Transform].pos[:, 1] < -10.0)

A query parameter types as Query[A, B]; q[A] as A's accessor; a field (.pos, .rot, .scale, a Component's annotated fields, .data) as a (k, c) array that reads the current rows. Assignment and +=, -=, *=, /= queue an update of those rows with the values cast to float32, and rot += composes with _quat_multiply's formula. len(q) and iterating q give the indices. A handler's query is read-only: a write through it fails the export, as ReadOnlyView raises on the desktop.

The arrays

Arrays become NdArray objects in pyrt.js: a typed array, a shape and a dtype (float32, float64, bool, int32), always contiguous. The subset adds, each with a parity test:

Every operation writes a new typed array of the result's dtype, so float32 results round at each step as numpy's do. That keeps exact parity without analysis; section 11 measures what it costs and when fusing would be worth it.

Entity handles

EntityHandle gains its desktop surface: index, transform.pos (float64 world coordinates, the engine's origin added and removed as _TransformProxy does), transform.rot, transform.scale, all immediate, plus set_material, set_joints and destroy. This is the path for a few hundred objects with their own logic, the fair's people: a loop over app objects that each hold a handle. The query path is for ten thousand alike.

Batches

scene.js keeps one InstancedMesh per (geometry id, material id), sized by doubling. A store version counter, bumped by spawn, destroy, set_material and membership changes, tells it when to rebuild membership (one pass over the alive rows); a dirty range per frame tells it which instance matrices to recompute from Transform (position, quaternion, scale, the desktop's column-major TRS) and upload. Each batch's bounding sphere is recomputed when its instances moved, so frustum culling still works per batch. set_material now moves an instance between batches, and the page's material record (materialOf) reads the Material column. Shadows, fog and the calibration apply to batches as they apply to meshes today.

06Events

input setFrame deliver events frame · emits of N-1 · input and widget events systems emit queues flush commands sync widgets, camera, batches render engine.emit in frame N: delivered in frame N+1 DOM events and widget clicks since the last frame
The page's frame, in Engine._draw_frame's order. Async handlers and the asyncio pump have no counterpart: async is outside the subset.

engine.emit(name, payload) joins the surface. The runtime keeps one queue, as EventBus does, and delivers it at the next frame's start to the handler roots of each name, in registration order, after the frame event with {"dt", "elapsed", "frame"}. A payload is any value reached code builds (a dict is a Map, as now). A handler with a query gets the read-only view.

The page now fires the input events the desktop's input layer emits: key_down, key_up, pointer_down, pointer_up, pointer_move, wheel and resize, with KeyEvent, PointerEvent, WheelEvent and ResizeEvent payloads whose fields join the surface. Widgets emit gui:button:<name>:click, gui:slider:<name>:change and :commit, gui:toggle:<name>:change and gui:joystick:<name>:change. The replay frame gains an optional events list of [name, payload] in the order they happened; the page builds it from the DOM, the Python replay emits it through the bus, and the frame checks of slice 3 assert it. An agent's manifoldx emit enters the same queue.

The page also speaks to the page around it, for Q1: every event the app emits is dispatched on window as a mx:emit CustomEvent and posted to window.parent when the page is framed, and a {"mx": "emit", "name", "payload"} message from the parent enters the queue. Payloads cross as plain data, in the forms engine.state crosses under run --web.

07Widgets

The four desktop widgets that fail the export today draw in the page, and the page applies their fields both ways, as it applies Text.text today:

widgetframe code reads and writeseventsin the page
Buttonlabel, was_clicked() (the latch, consumed on read)gui:button:<name>:click, {}a <button> styled from the widget's resolved style
Slidervalue, min, max:change while dragged, :commit on release, {"value"}a track and a knob with role="slider", the pointer captured while dragging, as _gui_captures_pointer does
Togglevalue:change, {"value"}a switch with role="switch"
Imagestyle_overridesnonethe widget's SVG bytes as an <img>, at svg_size
Joystick (new)value, an (x, y) in the unit disc, 0 when released:change, {"value"}a pad and a knob that takes its own pointer, so a joystick and a button work at once on a phone

Joystick lands in manifoldx.gui first: a mouse drag on the desktop, drawn by the painter like the Slider. The latch, the values and the events follow the desktop's code paths (src/manifoldx/gui/button.py, slider.py, toggle.py), and the widget's own value changes before its event is queued, as on the desktop.

try itThe widgets as the page would draw them over a scene, with the queue below the frame clock: an event queued in one frame reaches its handler in the next. Sample app, not a real one: the handlers move and colour the box.

speed
highlight
frame 0
sample · events queued and delivered, newest first

08Skinned entities

A skinned entity is one spawned from a geometry with joints (Mesh(joints=...), one joint index per vertex). The export writes such a geometry with JOINTS_0, WEIGHTS_0 of 1 on that joint and a skin of identity inverse binds, and writes each entity's current joint matrices into ecs.bin; the glTF report then lists posed skinned entities as exported, which closes #82 for export_gltf as well. In the page each skinned entity is a SkinnedMesh of its own, its bone matrices set from set_joints:

engine.set_joints(indices, matrices)     # (N,) and (N, J, 4, 4), joints past J keep their last matrix
person.set_joints(m)                     # (J, 4, 4) for one entity

The fair poses each person from a few angles per part every frame. In Python that is a (N, J, 4, 4) stack built with np.eye, the angles and @, then one engine.set_joints for the crowd. One draw call per skinned entity is what the fair pays today (40 people, 40 calls); instanced skinning waits for a crowd that needs it (Q6).

Animation clips are not in slice 5. The desktop has none (the humanoid module poses by code and its animation work is still ahead), so there is nothing to be at parity with; when the desktop gains clips, the page plays them with the same sampler as a later slice.

09Sound and what stays out

Sound is out of slice 5. No manifoldx module plays audio, so a page-only sound API would break the parity rule, and a desktop one needs a dependency the maintainer should choose (Q2). The fair keeps its 171-line sound module in its host page until slice 7.

Also outside slice 5, each with the slice it belongs to in section 14: text labels in the world, persisted state, fullscreen and display control, install and offline, gamepad and multi-touch gestures, scenes on demand, second views (the minimap), material field writes (a scrolling texture), lights moved by frame code (#155 fails today at engine._spot.position, a private field, and needs a public light surface first), meshes built at runtime and GPU compute.

10Transpiler and snapshot changes

wherechange
reach.pyA system's query parameter is allowed (the error at reach.py:367 goes); reach follows Query[...]'s components to their classes so their layouts are written. Component subclasses and Mesh, Material, Transform constructors are reachable.
types.pyNew types: query, accessor, nd[dtype, rank] with numpy 2's promotion, entity handle, the four input event classes, the widget types. RUNTIME_SURFACE gains spawn, destroy, emit, set_joints, elapsed, camera.up (#153) and the handle and widget fields of sections 05 and 07. WRITABLE gains the widget values and camera.up.
transpile.pyArray expressions become $rt.nd.* calls; @ becomes $rt.nd.matmul; query field writes become queued updates; random.* calls go to the runtime's MT19937. A material field write fails with the set_material hint (#154).
snapshot.pyWrites ecs.bin and, in state.json, each component's name, dtype, columns and field map, the geometry ids reached code can spawn, random states (getstate(): 624 words and an index), widget values and the joint matrices.
gltf exportA library mode for --web: every registered geometry once with extras.mx.geometry, every material, no entity nodes. Joints and skins in both modes.
replay.pyTraces the store: alive indices and each component's rows of the alive entities, per frame (a digest past 1,000 entities, full rows below). Frames take events and clock (the wall clock the page read, which time.time() returns in frame code on both sides).
desktopComponent membership in EntityStore; Joystick in manifoldx.gui; time.time() in frame code read from the frame under replay; the glTF writer's joints.

11Performance budget

Measured for this spec on the build host, a shared 4-core machine whose load average was 5 to 11 during the runs, so read the numbers as rough. Chromium is headless with SwiftShader, so a tick's time includes software rasterizing and says nothing about a phone's GPU; draw calls and the JavaScript side carry over.

caseN = 1,000N = 10,000
the page today, static boxes, one mesh each: a tick9.9 ms66.4 ms
the same meshes, each moved every frame: the moves / the tick1.3 ms / 12.9 ms5.5 ms / 63.6 ms
one InstancedMesh, every matrix rewritten with trigonometry each frame: the writes / the tick0.49 ms / 1.7 ms4.3 ms / 13.1 ms
Node: pos += vel * dt as numpy runs it (two temporaries)0.37 ms0.48 ms
Node: the same fused, each step rounded to float320.13 ms0.09 ms
Node: Transform rows to instance matrices0.41 ms0.42 ms

At 100,000 entities Node took 8.1 ms with temporaries, 2.7 ms fused and 4.9 ms for the matrices. The 1,000-entity Node numbers are mostly the JIT warming up. Method: examples-style app spawning N boxes, exported with export --web; Playwright runs 60 __mx.tick calls per case and times them in the page; the instanced and moved cases change the scene from page.evaluate. The scripts are not kept; the bench case below replaces them.

The budget

10,000 moving entities in one batch, each moved by a query system: the page's own work per frame (events, systems, flush, matrix sync, excluding renderer.render) under 4 ms in headless Chromium on CI. The draw calls for that scene: one per batch, not one per entity, which a test asserts through renderer.info.render.calls.

The second consumer: its own bench (make bench, the mobile audit's six viewpoints) no worse after the port than before, in draw calls and in main-thread time per frame with the CPU slowed 4 times. Its plaza in first person drew 169 calls in the audit; batching should lower that, and frame code must stay within the 18 ms the viewer's resolution scaler treats as fast.

If fused loops become worth their complexity, the bench says so first: fusion cut the step by 5 times at 10,000 entities here, but the step is a tenth of the budget.

A benchmarks case, web-crowd, measures the first line of the budget and joins know-how/benchmarking.md; it reports, it does not gate.

12Delivery and done

Slice 5 is three plans, each ending with a replay in CI, as slices 1 to 4 did:

5a · the store, queries, spawn and destroy, batches

Desktop component membership, ecs.bin, the library glb, the page's Store and flush, the array subset, entity handles, instanced batches. Done when a new public example, examples/web_crowd.py (boxes spawned by a key, drifting by a query system, destroyed when they fall, picked and highlighted), replays with no mismatch in Node and in Chromium, and the draw-call test passes.

5b · events and widgets

emit, the input events, the frame's events and clock, MT19937, the host-page bridge, Button, Slider, Toggle, Image and Joystick (desktop first). Done when web_crowd gains a panel with all five widgets and a handler per event, and its Chromium replay drives each widget through Playwright's pointer and passes its frame checks.

5c · skinned entities and the second consumer

Joints in the glTF writer (#82), set_joints and @ in the page, a walking figure in web_crowd. Then the second consumer's port, planned in its own repository.

Done for slice 5

The second consumer's 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. The world code of its main.js (the frame loop, the people, the props, input and camera) is deleted. What remains is its host page with the document panels, sound and fullscreen, talking to the export only through events (Q1), until slices 6 and 7 take sound and fullscreen.

Checked three ways, in the consumer's CI: a replay of a scripted visit (walk the plaza, click-to-walk to a stand, enter and leave its room, press each button, push the joystick, 1,800 frames or more) 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 budget above.

The third consumer is the next check: its machines move with query systems and its own joystick and buttons give way to the widgets, so its mobile.js shrinks to the pinch, which goes in slice 8.

13Testing

14The slices after 5

How the four direction issues split. Slice 5 takes from #158 the runtime ECS on the CPU, from #161 the on-screen widgets, and nothing yet from #159 and #160 beyond the geometry library, which is the seam #159 builds on.

slicewhatdone when
6 · display and install#160: fullscreen and orientation on the engine (the window's fullscreen on the desktop), a wake lock, a pixel-ratio cap and a frame-time scaler; export --web --pwa writes a manifest, icons and a service worker caching the folder. #156's minified three.js and optional meshopt.The third consumer drops pwa.js, sw.js and the sed lines of its publish script; the second drops its fullscreen code.
7 · text in the world, sound, memoryText labels and billboards drawn in the page; a sound API on both sides (music loop, one-shots, positional sources, started by the first gesture in the page); engine.state keys marked persistent, kept in the browser and in a file on the desktop.The second consumer deletes its labels, bubbles and sound module.
8 · controllers#161: first-person, orbit and fly controllers as manifoldx parts, driven by keys, mouse, gamepad, Joystick and touch; multi-touch gestures (pinch, two-finger drag) in the input layer and the frame.The third consumer deletes mobile.js; both consumers use a shipped controller.
9 · scenes on demand#159: the library split per scene, loaded or generated when the app switches, a small Python server for generated scenes, cached by the service worker of slice 6.The second consumer loads one space at a time and its rooms stream rather than ship in the first glb.
10 · generation and shaders#158's rest: a WebGPU path that runs manifoldx's WGSL as is (compute kernels, generated vertex work), meshes built at runtime, the runtime server for what the client cannot run.An example with a compute system and runtime terrain replays in Chromium with WebGPU.

Notebook and document embedding (#162) packages the export and can follow any slice from 6 on. Views (a second camera, the minimap), material field writes and lights in frame code wait for an app that asks, as the slice 1-4 spec's rule says.

15Non-goals

16Questions, settled

The maintainer settled all eight questions on 2026-11-07 by accepting each recommendation. Each one keeps its question; its last paragraph is now the decision, and the decisions table carries it as a row tagged maintainer.

Q1 · May an app keep a host page around its export?settled · maintainer

The second consumer's document panels (sheets with image pagers and video, a message inbox over its HTTP API, saved cards, a map, the character screen) need rich text, text input and network access that manifoldx's GUI does not have, and #105 is far off. The rule says no app JavaScript; these panels are the consumer's website more than its 3D app.

decisionA host page is allowed: one that frames the export and talks to it only through events (section 06), and count the fair's world as replaced when its main.js holds no world code. Revisit when the GUI has text input. Porting the panels into the GUI first was rejected: it would hold slice 5's done behind #105.

Q2 · Which audio backend on the desktop?settled · maintainer

Parity needs sound on both sides. The desktop needs a library for output and decoding; the browser has Web Audio.

decisionDecided in slice 7, by a spike that measures latency and install weight of two candidates on the three desktop platforms. The API stays small: a loop, a one-shot, a positional source, volume, all started from frame code.

Q3 · Fix query filtering on the desktop, or match it?settled · maintainer

Today every query returns every alive entity. An app whose query names a component some entities lack today also writes those entities' rows (zeros nothing reads); after the fix it skips them, and len(q) changes.

decisionFixed, as the first task of 5a, with a CHANGELOG entry under changed behaviour: it is what the docstring promises and what an ECS query means. The examples and demos are run before and after to show which, if any, relied on it.

Q4 · Widgets in the desktop's look or the browser's?settled · maintainer

Native <input type="range"> and checkboxes come with keyboard and screen-reader support for free; drawn elements match the desktop and the theme.

decisionDrawn from the widget's resolved style, as the mockup does, with ARIA roles and arrow keys on the Slider. The GUI's theme then means the same in both places.

Q5 · Is Joystick a manifoldx widget?settled · maintainer

It could be page-only, since a desktop has a keyboard. Parity says land it on both; on the desktop it is a mouse drag nobody needs much.

decisionYes: Joystick lands in manifoldx.gui, small like the Slider, so an app's controls are one piece of code and the replay can drive it.

Q6 · When does skinning get instanced?settled · maintainer

One SkinnedMesh per entity costs a draw call each. The fair has 40 people and is fine; a crowd of thousands is not.

decisionNot in slice 5. When an app needs more than a few hundred, use a joint texture and the desktop's rigid-joint shader idea in a custom three.js material.

Q7 · The fair's rooms in the first glb?settled · maintainer

Until slice 9, rooms that spawn on entering must ship in the library glb, which a phone downloads up front; today the viewer builds them from JSON with no download.

decisionThe 5c plan measures the gzipped glb with every room. If it adds more than the 203 KB the fair's character screen waits for today, move slice 9 before 7.

Q8 · Batches and cullingsettled · maintainer

A batch is culled as a whole. The fair's audit found culling worth 54 to 79% of the triangles per view with its merged meshes cut in 32 m stretches; one batch spanning the grounds would draw everything.

decisionBatches ship by (geometry, material), and 5c measures the fair's six viewpoints in 5c. If triangles per view grow, split large batches by a spatial cell as the fair's merge does, inside scene.js, with no API change.