Skip to content

ae3d.batch: a frame in one buffer from a host (three.js on sae), MeshNormalMaterial as a quoted pair - #1102

Merged
paul-hammant merged 2 commits into
mainfrom
feat/threejs-batch
Nov 27, 2026
Merged

paul-hammant merged 2 commits into
mainfrom
feat/threejs-batch

Conversation

@paul-hammant

Copy link
Copy Markdown
Collaborator

The ae3d half of the first three.js-on-sae spike (three.js fork, branch sae-port, PORT.md).

A sae page runs three.js's own JavaScript; its AeRenderer walks the scene once a frame and hands over one buffer. This PR is what ae3d needs to draw it, with no window:

  • ae3d.batch: the buffer's layout (version 1, in the module header): the eye's view and lens, clear colour, meshes new or changed (positions, normals, uvs, indices) under the host's ids, frees, and draws (mesh id, material, flags, opacity, world matrix). batch_submit checks the whole buffer first (bounds, indices, ids, the host's limits from batch_set_limits) and refuses with a reason, changing nothing. Then it queues canvas draws (gl.renderer_canvas_draw), computing each draw's MVP and normal matrix natively. batch_draw / batch_pixels draw and read back.
  • ae3d.batchmaterials: three.js's MeshNormalMaterial as a quoted vertex + pixel pair: normalize(n_eye) * 0.5 + 0.5, written as is (three.js's normal material has no colour-space step).
  • gl.renderer_canvas_pixels and gl.renderer_draw_canvases: a canvas read back (rows top first), and the canvases drawn without a frame around them. Additive.
  • tests/test_batch (in GPU_SUITES): a cube whose visible faces are, at their centres, their eye-space normal's colour to 2/255 (worked out by hand from the pose); a second pose moves the silhouette; five malformed / over-limit batches each refused with nothing changed. With AE3D_BATCH_FILES + AE3D_BATCH_OUT it draws a page's own batches.

OpenGL only for now. Vulkan would need the pair's SPIR-V made at build time through quotegen, as examples/canvas.ae does.

Verified

On cachyos (Mesa 26.3.1 llvmpipe under Xvfb): test_batch passes. Three.js's README cube (BoxGeometry(0.2), MeshNormalMaterial, at t=1200 and t=2600 ms) was batched by AeRenderer on sae's engine (tools/saejs, byte-identical to Node), drawn by this PR, and checked against three.js's own normal-matrix maths: every visible face centre within 1/255, the corners clear, and 1,633 pixels differing between the frames.

No motion code touched.

🤖 Generated with Claude Code

…hNormalMaterial as a quoted pair

A sae page running three.js describes its frame in one buffer a frame
(its AeRenderer): the eye's view and lens, each draw's world matrix and
material, and the meshes that are new or changed. ae3d.batch checks it
whole against the host's limits, keeps the meshes under the host's ids,
and queues canvas draws with ae3d.batchmaterials' pair for three.js's
MeshNormalMaterial; batch_draw and batch_pixels draw and read it back
with no window (gl.renderer_draw_canvases, gl.renderer_canvas_pixels).

tests/test_batch: the cube's faces the colour of their normals in the
eye's space to 2/255 by hand-worked pose, five refusals changing nothing,
and three.js's README cube from batches made on sae's engine, held by
three.js's own maths to 1/255 (Mesa llvmpipe on Linux).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
paul-hammant added a commit to aether-lang-dev/three.js that referenced this pull request Nov 26, 2026
src/renderers/sae/AeRenderer.js walks the scene once a frame and hands
the host one buffer (ae3d.batch's layout, version 1): the camera, each
visible mesh's world matrix and material, and the geometry that is new
or changed. First cut: Mesh + MeshNormalMaterial.

sae-port/cube: the README's cube through it. Its batches, made on sae's
engine (byte-identical to Node), drawn by ae3d (aether-lang-dev/ae3d#1102)
on cachyos, match three.js's own normal-matrix maths at every visible
face centre to 1/255.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
paul-hammant added a commit to aether-lang-dev/sae-it-aint-so that referenced this pull request Nov 26, 2026
… counted, not drawn)

gfx.scene, gfx.submit, gfx.stats and gfx.free, in the gate spec with
their seals (docs/gpu-pages.md's first slice, shaped by three.js's
AeRenderer, aether-lang-dev/three.js branch sae-port). A page hands over
one buffer a frame in ae3d.batch's layout (aether-lang-dev/ae3d#1102):
the host checks it whole, holds it to the page's budgets (4 scenes, 256
meshes and a million vertices over them, 4096 draws and 16 MB a batch)
or throws a TypeError saying why with nothing changed, and frees every
scene with its page. sae does not link ae3d yet, so nothing is drawn
(gfx.stats says drawn: false).

site/gfx.ts and spec_nav's "gfx"; the gate dump and spec_globals know
the new global. Verified on cachyos (0.946.0 release install):
check_gate 42/42, tests/run_all.sh 97 of 98 (spec_app_rexxconsole needs
a RexxAE sibling that was not there), and three.js's README cube as a
sae page: its batches arrive natively, 1,176 bytes then 252 a frame,
render() 0.1-0.2 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e on

It printed "test_batch: ok", so the Linux suites runner called it FAIL with
every check in it ok.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paul-hammant
paul-hammant merged commit dc4c06b into main Nov 27, 2026
19 of 20 checks passed
@paul-hammant
paul-hammant deleted the feat/threejs-batch branch November 27, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant