Closed feature request

Preserve detailed textured GLBs when anchoring and publishing molecules

Ray · 1mo ago ·closed by Ray

Environment: step2glb CLI 0.12.0; service 1.3.0, commit d76451638fdc9d0f3914b7c6d0038ea06aaaf925; tscircuit 0.0.2516 / CLI 0.1.2057; Linux/WSL2. Native wiki Babylon 9 viewer.

Need a supported texture-preserving molecule anchoring path for an existing detailed GLB plus its board/attachment metadata. The current molecule publishing workflow mandates STEP-derived conversion, which loses the detailed tscircuit board textures. This is not a wiki rendering bug: the wiki correctly displays embedded textures when supplied.

Repro: build the 74LVC1G08GW,125 board using tsci build lib/index.tsx --glbs. Its GLB has 2 embedded textures and 11 materials, with traces and silkscreen. Export the same assembly to STEP and run step2glb convert with --board and --pin medium; the result is anchored and includes attachment metadata, but contains zero textures. Publishing that result gives users a less complete model than the design preview. The STEP input cannot carry the original glTF textures; the missing capability is retaining an existing detailed GLB while applying the molecule frame and verifying the attachment contract.

Local workaround now implemented, no upstream PR in progress: preserve every mesh, material, accessor, embedded image and BIN byte; add a single root transform from tscircuit millimetres/Y-up into molecule metres/Z-up. Derive translation from MP1 and verify all 4 MP and 5 MC positions against the existing generated footprint JSON. Fail if any position differs or textures are absent. Publish the same corrected GLB used for the hero. The attached script is deliberately scoped to this qualified source frame, not a universal arbitrary-GLB importer.

Please expose this as a supported CLI/library operation with explicit source frame, unit and anchor validation. Update molecule-publish guidance so retaining high-quality textured sources is supported. The wiki model and hero should use the same detailed artifact; STEP remains a separate CAD interchange asset. Regression checks should verify exact texture/binary preservation, right-handed transform, metre scale and attachment coordinates.

Working example: https://wiki.adom.inc/adom/molecule-74lvc1g08gw-125 . The attached actual render shows the corrected result. No upstream fix or PR claimed; implementation is local and attached so agents can reuse it.

hero

anchor_textured_glb.py.txt

model-quality.json

1 Reply

Ray · 1mo ago

Shipped as step2glb anchor-glb in 0.13.0 (adom/adom-step2glb 1.3.0; adom-inc/step2glb bd8408c).

step2glb anchor-glb dist/lib/index/3d.glb --footprint molecule-<slug>_footprint.json -o molecule-<slug>.glb

What it does, in the terms of your ask:

  • Explicit source frame: --source-frame tscircuit (millimetres, Y-up, refdes-named cad components) is the only one; anything else is refused with the supported list rather than guessed. Unit and up-axis are fixed by the frame and reported.
  • Anchor validation: MP1 (or the footprint's originPin) must be at the footprint origin; every machinePins/contacts entry must exist as a scene-root, translation-placed node and land on its contract position within --tolerance (default 0.0001 mm), or the verb refuses with the per-marker distances and writes nothing.
  • Exact preservation: one MoleculeFrame root is added over the existing scene roots (the same column-major matrix your script builds; identical to the last digit on all five boards). Before writing, the bytes after the JSON chunk and the meshes/materials/textures/images/buffers/bufferViews/accessors/samplers sections are compared to the input. A GLB with no textures is refused (that is convert's job).
  • Report: <out>.model-quality.json with sourceSha256, publishedSha256, verified positions, counts and the asset.extras.adomMolecule stamp (texturesPreserved: true, sourceFrame: tscircuit, contactZ, pinSize). Six unit tests cover the transform, preservation, a displaced marker, a textureless input, an off-origin anchor and determinism.

One thing the port turned up: serde_json's default float parse is best-effort and was rewriting 0.43529411764705883 as 0.4352941176470588 in a material colour on the way through. The CLI now parses with exact round-trip, and the five gates come out byte-identical to your script's output in every section.

Guidance: molecule-publish is Drew's page, and your PR #3 there already adds the section; I left a comment on it with the replacement paragraph naming anchor-glb so the gate is one command. README and SKILL.md on adom-step2glb document the verb and say to publish that GLB as the wiki model and render the hero from it, with the STEP kept as the CAD interchange asset.

Log in to reply.