Brick Heart: handover, build page
1. State
Verified (you tested, on Cloudflare):
/en/build/?set=…works. Pack download prompt, then models load.- Palette list moves camera. Search, colour and category filters work.
- Browse has a Build link on each row.
- PICK, PLACE, move (buttons and arrow keys), rotate, undo, redo, SELECT all work.
- DELETE puts part back in palette. Used-up rows leave list and wall.
- History shows placed parts at final position plus rotation.
- Export MPD works. One STEP per part.
- Parts show the right way up.
Not tested or unknown:
- Subjects 2 and 3 on build page. Cold install on clean origin.
- Large sets (cap is under 999 parts). Whole scene re-renders on each action.
- Rotation direction vs "rotated 90°" text vs exported matrix.
- Colour 16 export for the 8 colours with no
ldraw_code. Those place as grey. - Exported MPD in a real LDraw viewer. You said all works, but you did not name the viewer.
- Service worker. True offline reload.
- Blocked-network test and
removeSubjectdedup (still open from last session).
2. Decisions made
- Palette is the left list. One row per part and colour. Row hides at zero left.
- Ids. Every brick gets a 4-digit id up front. Id is
(seed + n × 6181) mod 10000. Seed is a hash of the set number. Deterministic. Unique. - Label.
#0412 red.4 plate 1x2. Family iscolors.base_color. Colour id iscolors.ldraw_code, falling back to the Rebrickable id. Name is the DB name lowercased with1 x 2squeezed to1x2. - State. Op list (place, move, rot, del) is the truth. History, palette and scene are all derived. Undo and redo move a cursor.
- Place. Drops at x=0, z=0, lowest point on the floor. Next free id of the row.
- Move. Stud 20, plate 8, brick 24 LDU. Arrows are screen-relative. Rotate is a 90° turn about Y.
- Export. One
0 FILE.0 // #id labelcomment, then the type 1 line, then0 STEP. Engine coordinates converted back: x, -y, -z. - Scene. 32×32 stud baseplate. Parts wall stands behind it at z=-340. Light values copied from the reference.
- "Iso" camera is a fixed diagonal view, not orthographic.
- Voxels parked. No collision.
voxels.jsonis 264 MB, over the 25 MiB limit.
3. Files (all in app/)
src/build.ts. Whole page logic. Imports./ldraw/ldraw-hook,ldraw-store,geometry,parts,mpd.render-build.mjs. HTML andDEFAULTSfor allbuild.*strings.css/build.css.build.mjs.renderBuildcall must sit afterfs.rmSync(dist). Two esbuild entries:js/app.js,js/build.js. WASM copy covers both bundles.render.mjs. Build column header,BROWSE_DEFAULTS.src/main.ts.renderRowshas the Build link and colSpan 6.
Build order: npm run typecheck && npm run build && npm run preview.
4. Next session
- Add
build.*andbrowse.*Build keys toui.json. The key list isDEFAULTSinrender-build.mjs. Thenzh/buildcan be built. - Link from
zhbrowse tozh/buildonce it exists. It currently links toen/build. - Test subjects 2 and 3 on the build page. Test a set with a colour that has no
ldraw_code. - Check rotation direction. Rotate, export, open in a viewer, compare.
- Cmarea buttons. 4 fixed cameras plus wall camera.
- Place position. All parts drop at 0,0 and stack. Consider a free spot or a cursor.
- Blocked-network test,
removeSubjectdedup, interrupted install. - Service worker for real offline reload.
- Then, in order: connector snapping (
connections.json,solveAttachmentSeated), command line, colour modes, collision.
5. Cautions
- Don't guess. Ask for terminal output first.
- Mark anything unverified. British spelling.
- All visible text in the real app goes through
site/ui.jsonwith your approval. Currentbuild.*text is English defaults only. - No inline styles. CSP is
style-src 'self'. Set colours through CSSOM. - Cloudflare limits are 25 MiB per file and 20,000 files. Generated artefacts must be committed.
- Whole files, not patches, when edits are not simple.
- Unresolved from reference:
connections.jsonkey mapping. The keys are not confirmed to be LDraw stems.- Reference collision code location. Not found.
metaOfandSTUD_PITCHdefinitions. Seen only at call sites. The code uses 20.
- Known gaps: bench
flattenMpdreads the first0 FILEas a submodel, so exported files load empty in the bench. Part names use the full DB name, so odd labels likeweapon sword (uruk-hai)appear. The spec wants the generic noun.