Brickheart LFrame build plan
What the reference proves (verified from your pastes)
- Per-part load: a part is loaded once with LDrawLoader. The loader is not given a whole MPD. The result is merged into one triangle geometry and one edge geometry, rotated 180° about X to Y-up, and cached by part id.
- Drawing: one instanced mesh per part and colour, with one matrix per record. A selected brick gets its own mesh with an emissive glow.
- Persistence: the renderer and scene persist. Only the parts group is cleared and refilled when the records change. This avoids the loader's redraw limit.
- Packed parts: a packed part is a self-contained MPD with flattened sub-file names (
s-3003s01.dat), main block first. Connector data is static JSON in LDU. - Rotation: rotation is one vertical-axis step in 90° increments, which matches your decision.
Design
- Python builds everything the browser reads.
- Packed per-part MPDs, with flattened names, in four subject libraries.
LDConfig.ldr.- Connector JSON from BrickNet.
- A per-set inventory.
- One colour table that maps the 74 colours to the 12 groups. Each group has a light-grey fallback for transparent colours, a pattern id and any alternate material.
- Offline. Picking a subject downloads one library in the background. Decompress once, store each part separately, and answer the loader's requests from that store.
- Geometry service. Reuse the reference pattern: one loader, a promise cache, merge, flip. Geometry has no colour, so it is built once per part in every mode.
- Material service. Materials are keyed by mode and colour group.
- Full colour: the loader's material for the code.
- 12 colour: the group colour. Transparent colours become light grey.
- Outline only: the baked edge geometry.
- Pattern: the group's pattern (
|||,///,\\\,###, dots,***and so on) with no colour.
- Scene. A fixed camera, with a wall group (one instance per distinct part and colour) and a placed group. The count and the selection ring are DOM elements. The highlight must work in all four modes.
- State. The ordered history is the truth, and the records array is derived from it. The MPD is regenerated for save only. Records hold part, colour, position and a rotation step.
- Placement. Pair a connector on the moving brick with one on the target, following your
PLACErule. - Deferred: collision, voice, IDs, zones, non-vertical rotations.
What is new work (not in the reference)
- Colour modes: the reference has full colour only.
- Patterns: I believe LDraw part geometry has no UV coordinates, so a pattern probably has to be computed in a shader from object-space position. Which direction the stripes run on each face is a design choice that needs trying on real parts.
- Highlight: the emissive glow suits solid materials. Outline and pattern modes need their own rule, such as a thicker outline.
- Mode switching: only the material on each instance group changes, while cached geometry is reused. This should be cheap, but I haven't measured it.
- Wall order and the ring: structural, then decorative, then functional, then wheeled parts. This needs the category-to-group table made by hand in
load_data.py.
Tests, in order
- One packed part with flattened names through the loader. This isolates whether naming caused your earlier failure.
- Feeding the loader offline, via its URL rewrite hook or a service worker. Neither is verified.
- Full colour on a printed part, a transparent colour and a part with fixed-colour sub-parts. Merging drops material groups, so those may take the instance colour (inference).
- The same parts in the other three modes, especially pattern legibility and the highlight.
- A 399-part set on a phone: rebuild time and memory.
- Aliased parts in the correct pose, using the non-identity alias count from your handover.
Not seen in the reference
- The bodies of
composeMatrixand the connector-solving functions, and the loader class itself. - What production uses the packed files for, beyond what the code tries first.
- Whether their packed files inline primitives.
Settled by you in this session
- No camera or mouse selection. Tab navigation and filters. A text-only picker and history.
- Four subject libraries, downloaded in the background.
- Four colour modes, with patterns for the 12 groups only.
- Rotation about the vertical axis in 90° steps.
Corrections to the handover
-
The packs are colourless until unpacked, and the colour definitions come from
LDConfig.ldr. -
A full MPD redraw per edit is ruled out.
Questions for next session
- Which tool builds the packed per-part files, and does it keep sub-file names flat?
- What are the 12 colour groups, and which of the 74 colours go in each?