@justai/asset
v0.3.0
Published
What is true about a 3D file — format, scale, bounds and facts, read rather than assumed.
Downloads
552
Readme
@justai/asset
What is true about a 3D file — format, scale, bounds and facts, read rather than assumed.
Extracted from 3dviewer, which had to answer these questions first and answered them against real exports rather than against a specification. It is not a viewer SDK: it carries no loaders, no renderer, no UI, and nothing that only one persona needs.
Why it is a package
Five of these questions stopped belonging to one product the moment a second one needed them:
| subpath | the question |
|---|---|
| units | how big is this, really — and is the file lying about its unit |
| frame | bounds algebra, and where a camera stands to see all of it |
| facts | the vocabulary: what a loaded model is, as plain data |
| formats | which format is this, from the bytes — never from the name |
| resolve | which of these files is the model, and what is it missing |
| three | measure(Object3D) → those plain facts |
Three.js is optional, and that is load-bearing
three is an optional peer and appears behind exactly one subpath:
import { sizeOf } from "@justai/asset/units"; // no three, anywhere
import { measure } from "@justai/asset/three"; // three required hereA consumer that only asks how big something is never resolves three — not in its bundle, not in its
install tree. The rule exists because a sibling package (camera-runtime) is contractually
engine-neutral, and a shared import that dragged three along would take that contract with it.
Source is TypeScript, the artefact is not
The fleet's packages ship hand-written .js beside hand-written .d.ts. This one keeps TypeScript
source — rewriting a thousand working lines to match a convention is a cost with no buyer — and
compiles on prepack, so the published bytes match every other @justai/* package exactly.
The unit offer is an offer
suspectedUnit asks one question: is there a power-of-ten rescaling that lands this model much
closer to something a person owns than it is now? The referents do the deciding, so a tree, a gull
and a screw are each judged against the nearest thing to them rather than against an assumption
that every model is about a metre tall.
from names the unit the numbers appear to be in; factor is what turns them into metres. A
model that is too small has no unit that explains it — nothing in this family is larger than a
metre — so those come back with from: null: an offer without a story, which is more honest than
a borrowed one.
Where a file is genuinely ambiguous — a four-millimetre screw thread and a four-metre object shrunk by a thousand are the same numbers — it says nothing.
What it deliberately does not carry
Loaders (three ships 48; a persona should download the one it needs), zip expansion, animation clip presentation, skeleton drawing, project files, share envelopes. Those stayed in the viewer, because they are what the viewer is.
