Add StlDef FileDef subclass for .stl 3D meshes - #5627
Closed
FadhlanR wants to merge 2 commits into
Closed
Conversation
Register `.stl` as a first-class file type: - StlDef (packages/base/stl-file-def.gts) with a cube icon, the four display formats, and a `format` field (binary vs ASCII). - stl-meta-extractor.ts classifies the encoding from the first 84 bytes plus the file size (the `84 + 50*count == size` binary identity, else an ASCII `solid` header), guarding non-STL bytes with FileContentMismatchError so a bad file indexes as a bare FileDef. - file-def-code-ref maps `.stl -> StlDef`, so urlNamesFile()/resolveFileDefCodeRef() route a `.stl` link through the file-meta path instead of mis-dispatching it as a card. - isBinaryFilename() now treats model/stl (and the legacy application/vnd.ms-pki.stl) as binary; otherwise binary STL was read as UTF-8 text and its bytes mangled in boxel-cli push/pull/read. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Preview deploymentsHost Test Results 1 files ±0 1 suites ±0 2h 31m 41s ⏱️ +51s Results for commit a78e47d. ± Comparison against earlier commit 7856763. Realm Server Test Results 1 files ±0 1 suites ±0 14m 19s ⏱️ -25s Results for commit a78e47d. ± Comparison against earlier commit 7856763. For more details on these errors, see this check. |
Adopts the metadata + rendering from the file-experience prototype onto the current FileDef subclass, keeping expensive work off the indexing hot path. Metadata (cheap, index path): - extractStlMetadata also returns the binary triangle count (already read for the format sniff, so free) and the ASCII `solid <name>` label. - StlDef stores `triangleCount` and `solidName` alongside `format`. Rendering (interactive card view): - ThreeModelViewer (base) mounts a three.js WebGL viewer in the StlDef isolated view; reusable for a future 3MF def via the same component. - three.js is loaded with a runtime CDN dynamic import inside the component (the approach from the prototype), so it resolves natively in the Boxel card runtime with no host build wiring. Bytes are fetched with credentials. - Ported the prototype's scene setup: hemisphere + directional lights, ACES tone mapping, vertex-normal repair, STL Z-up→Y-up, geometry-centered camera framing, orbit controls with damping, double-click reset, full GPU teardown. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
FadhlanR
force-pushed
the
cs-12053-stl-file-def
branch
from
July 30, 2026 10:23
7856763 to
a78e47d
Compare
Contributor
Author
|
[Claude Code 🤖] Superseded by #5658, which unifies StlDef (CS-12053) and ThreeMfDef (CS-12054) under a shared |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves CS-12053.
Registers
.stl(3D-print mesh) as a first-class file type, the way every other file extension already is.What changed
packages/base/stl-file-def.gts—StlDef extends FileDef: cube icon,'3D Model (STL)'display name, isolated/embedded/fitted/atom formats, and a singleformatfield (binary|ascii).packages/base/stl-meta-extractor.ts—extractStlFormat(bytes, contentSize). Classifies the encoding from the first 84 bytes plus the file size: the binary size identity84 + 50·count === contentSize, else an ASCIIsolid …header. Non-STL bytes throwFileContentMismatchErrorso a mislabeled/truncated file indexes as a bareFileDefinstead of erroring the row. Isolated from the component for unit testing, mirroringmp3-meta-extractor.ts.packages/runtime-common/file-def-code-ref.ts— maps.stl → StlDef, sourlNamesFile()/resolveFileDefCodeRef()route alinksToa.stlthrough the file-meta MIME path rather than mis-dispatching it as a card.packages/runtime-common/infer-content-type.ts—isBinaryFilename()now treatsmodel/stl(and legacyapplication/vnd.ms-pki.stl) as binary..stlmatched no MIME prefix before, so binary STL was read as UTF-8 text and its bytes mangled in boxel-cli push/pull/read.Extract scope
Only
formatis stored. The extractor reads the header triangle count internally to run the binary/ASCII sniff but does not persist it —triangleCountisn't a real search key and carries no display value on its own.extractAttributesruns per-file on the indexing hot path, so the read is bounded to an 84-bytereadFirstBytes(likemp3-audio-def); a full-mesh parse (bounding box, volume) is deliberately deferred off the index path.Tests
packages/host/tests/integration/components/stl-file-def-test.gts—extractStlFormat(binary / ASCII / whitespace-ASCII / non-STL) andStlDef.extractAttributes(format stamping, inherited base fields, extension guard).packages/host/tests/acceptance/stl-file-def-test.gts— drives thefile-extractrender route for binary + ASCII fixtures, the mismatch fallback, and the indexing → file-meta path resolving toStlDef(mirrorscsv-file-def-test.gts).packages/host/tests/unit/file-def-code-ref-test.ts— extendsisFileDefCodeRefcoverage forStlDef.Follow-ups (out of scope)
🤖 Generated with Claude Code