@displayxr/inline3d-tools 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md ADDED
@@ -0,0 +1,351 @@
1
+ <!-- GENERATED by tools/inline3d-tools/scripts/sync-agents.mjs from plugins/displayxr-inline3d/skills/*/SKILL.md. Do not edit by hand: edit the skills and re-run the script. -->
2
+
3
+ # Agent instructions: glasses-free 3D web pages with @displayxr/inline3d
4
+
5
+ For any coding agent (OpenAI Codex, Cursor, Claude Code without the plugin, others). Copy this file
6
+ into a project as `AGENTS.md` (or point your agent at it) when the project builds pages on
7
+ [`@displayxr/inline3d`](https://www.npmjs.com/package/@displayxr/inline3d).
8
+
9
+ ## How to call the tools
10
+
11
+ The tools are the npm package `@displayxr/inline3d-tools`, pinned to an exact version. **In a
12
+ sandboxed agent, prefer the MCP server** (below): MCP servers run outside the sandbox, while a shell
13
+ `check` starts a local file server and headless Chrome, which OpenAI Codex's default sandbox blocks
14
+ (`listen EPERM 127.0.0.1`), so there it needs the user to approve running the command outside the
15
+ sandbox. Otherwise run them as shell commands:
16
+
17
+ ```sh
18
+ npx -y @displayxr/inline3d-tools@0.1.0 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
19
+ npx -y @displayxr/inline3d-tools@0.1.0 assets <file.glb> [--target tablet|desktop]
20
+ npx -y @displayxr/inline3d-tools@0.1.0 assets prep <in> <out.glb> [--metres 0.01] [--decimate 0.5]
21
+ npx -y @displayxr/inline3d-tools@0.1.0 scaffold <esm|vite> <target-dir> --title "<page title>"
22
+ npx -y @displayxr/inline3d-tools@0.1.0 gen providers | gen run <adapter> ... --confirm-paid | gen provenance --file ...
23
+ ```
24
+
25
+ or, with the MCP server configured (`inline3d-tools mcp`; config snippets for Codex, Cursor and
26
+ Claude Code in this package's README), call its tools with the same
27
+ semantics: `check`, `asset_check`, `scaffold`, `gen_providers`, `gen_run` (paid: pass
28
+ `confirm_paid: true` only after the user approved that one call and its cost),
29
+ `gen_provenance`, `authoring_guide` (returns this file). Relative paths resolve against the
30
+ server's working directory.
31
+
32
+ Needs Node ≥ 18; `check` also needs a local Chrome or Chromium (`CHROME=/path/to/chrome`).
33
+ Generator keys come only from the environment (`MESHY_API_KEY`, `TRIPO_API_KEY`,
34
+ `OPENAI_API_KEY`); never ask for, print, log or write one.
35
+
36
+ ## Building on @displayxr/inline3d
37
+
38
+ A woven window is a `<canvas>` whose **buffer holds two eyes side by side** while its CSS box is the
39
+ shape the viewer sees. The DisplayXR Browser weaves it; every other browser shows the page in 2D.
40
+ The installed package is the source of truth: read `node_modules/@displayxr/inline3d/llms.txt` first,
41
+ then the docs below **from `node_modules/@displayxr/inline3d/`** (they match the installed version;
42
+ this file does not copy them). The `.d.ts` files there carry the full API with JSDoc.
43
+
44
+ ### 1. Pick the content type and entry point
45
+
46
+ | You have | Call | Notes |
47
+ |---|---|---|
48
+ | a side-by-side 3D photo | `wall.addImage(canvas, 'pic_2x1.jpg')` | SDK sizes the buffer; style only the box |
49
+ | an SBS 3D video element | `wall.addVideo(canvas, videoEl)` | VP9/WebM plays everywhere; `.mp4` may not |
50
+ | a video with transport UI | `addPlayer(wall, canvas, src, opts)` from `/player` | canvas must sit in a container; `format: 'mono'` for 2D titles |
51
+ | a glTF/GLB model | `addModel(wall, canvas, url, opts)` from `/model` | PlayCanvas by default; `engine: 'three'` for three.js; Draco/KTX2 decoders are files YOU serve |
52
+ | a Gaussian splat (.sog/.ply) | `addSplat(wall, canvas, src, { engine: 'playcanvas' })` from `/splat/playcanvas` | the page behind the tile shows around the splat (§4: keep it soft, or pass an opaque `clearColor`); Spark (three) is the `/splat` default; PlayCanvas adds `setSource`, effects, streaming |
53
+ | your own three.js / WebGL scene | `wall.addScene(canvas, onFrame, opts)` + `EyeCamera` from `/three` | you render each eye into `layer.getViewport(view)` |
54
+
55
+ `addModel` / `addSplat` / `addPlayer` take the wall and work with an unsupported one (they draw the
56
+ 2D fallback themselves). Prefer them over a hand-written scene whenever the content fits: they size
57
+ the buffer, clamp it to the device, frame the subject on the glass, and validate frames.
58
+ three or PlayCanvas: use PlayCanvas for models and splats (the default, the most tested path); use
59
+ three when the page already is a three.js app (`addScene` + `EyeCamera`, see
60
+ `docs/porting-three-js-apps.md`).
61
+
62
+ ### 2. Pick the rig by what the user moves
63
+
64
+ - The user turns a **subject** (model, product, diorama, chart, avatar), even with an orbit control:
65
+ **display rig** (the default). Keep an existing orbit camera and pose the portal from it:
66
+ `displayRig({ position: target, orientation: camera.quaternion, virtualDisplayHeight: 2*d*tan(fov/2) })`.
67
+ - The user moves **through a world** (first person, game, map, walkthrough, ported VR): **camera rig**,
68
+ `cameraRigFromCamera(THREE, cam, { convergence })`, set per frame with `handle.setViewRig`.
69
+ A game is a world even when it is seen from above (an RTS, a board, a top-down map the user pans
70
+ and zooms): the camera moves, so it is a camera rig. Tie `convergence` to the ground at the view
71
+ centre (raycast the centre of the screen to the ground plane), not to the cursor or a gaze point,
72
+ and cap zoom-in so the comfort product stays ≤ 1.
73
+ - Details: `docs/authoring-inline-3d.md` § View rigs. Comfort on a camera rig:
74
+ `ipdFactor × metersToVirtual × convergenceDiopters × ~0.6` must stay ≤ 1; never `convergence: 0`.
75
+
76
+ ### 3. Depth and comfort (`docs/making-3d-look-right.md`, nine rules)
77
+
78
+ Centre the subject on z = 0 (the glass), at real proportions; don't push it back or flatten it.
79
+ `+z` is OUT of the glass. Frame the whole subject in the first view. Tilt flat layouts 25–40° about an
80
+ axis through the glass. Keep moving things' forward swing small. Worlds: fixed convergence, keep the
81
+ camera clear of near geometry. Light/mid-tone low-contrast backgrounds (never pure black behind a
82
+ bright subject). Text as HTML near the glass, not in the scene. No coplanar faces (z-fighting), no
83
+ sub-pixel detail. Scene units: metres for a `virtualDisplayHeight` (0.24 by default); never scale the
84
+ world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
85
+
86
+ ### 4. Woven-canvas checklist (`docs/woven-canvas-rules.md`)
87
+
88
+ - [ ] **One** `createInline3D()` per document (or `sharedInline3D()`); `close()` on `pagehide`.
89
+ - [ ] **One persistent canvas**; never remount it on state change (React keys, Strict Mode). Swap
90
+ content inside it (`setSource`, redraw the source, change the scene). `add*()` twice on a canvas
91
+ is not a swap: `remove()` first.
92
+ - [ ] **No CSS effects on the canvas or any ancestor**: `filter`, `opacity < 1`, `mask`, `clip-path`,
93
+ `mix-blend-mode`, `backdrop-filter`, scale/rotate transforms. No `border`, `border-radius`,
94
+ `box-shadow` on the canvas (use `cornerRadius` / `feather`). Never animate the tile's box.
95
+ - [ ] **Cover a new canvas** with an opaque element on top until `await handle.firstWoven`, then remove
96
+ it with a hard cut, and ALSO on a timeout (~4 s) and in `catch`, so it always comes off. A
97
+ `firstWoven` with `woven: false` still means "drop the cover and keep drawing both eyes".
98
+ **Video and players too:** `loadeddata`, `canplay`, a player's `'ready'` and the first decoded
99
+ frame all fire BEFORE the join, so a cover released there shows the raw pair for up to ~1.2 s.
100
+ Release on `handle.firstWoven` (`addVideo`), `player.firstWoven` (`addPlayer`, SDK 1.53+; on an
101
+ older SDK where it is undefined, wait for the first frame and then `firstWovenHoldMs` ≈ 1200 ms
102
+ more), plus the timeout. Give a player a `poster`: it is painted into both eyes under the cover.
103
+ - [ ] **What is behind a transparent tile is part of the picture.** `addSplat` / `addModel` clear
104
+ transparent by default, and the browser pre-blends the page under both eyes, flat, at half
105
+ horizontal resolution. Make that page area a soft light or mid-tone colour or gradient (no
106
+ text or photo behind a tile, never black behind a bright subject), or pass an opaque
107
+ `clearColor: [r, g, b, 1]` (0..1).
108
+ - [ ] **`onLayerLost` goes flat** (`addScene` pages): pass `onLayerLost` and, in it, render ONE mono
109
+ camera across the whole canvas on your own rAF loop (the `!wall.supported` path) or show a 2D
110
+ fallback. An empty `() => {}` leaves the last side-by-side pair on screen, unwoven. `SceneViewer`:
111
+ `onLayerLost: viewer.onLayerLost`; `addSplat` / `addModel` / `addPlayer` handle it themselves.
112
+ - [ ] **Nothing opaque above the canvas**; backgrounds and black go *under* it. Never overlap two
113
+ woven canvases (hide the lower one with `display: none`).
114
+ - [ ] **Buffer = 2 × eye width**: `addScene` pages size it themselves (2× the box aspect, devicePixelRatio
115
+ ≤ 2, every side ≤ 4096 for tablets) and draw into `gl.drawingBufferWidth/Height`. three.js:
116
+ `renderer.setPixelRatio(1)` when you use `getViewport()`.
117
+ - [ ] **Validate before you clear**: skip the clear when `views.length < 2` or a viewport is `null`;
118
+ repaint the last good frame. Copy `XRViewport` / `XRView` fields by name (their fields are
119
+ getters: spread and `Object.assign` copy nothing). Redraw every frame.
120
+ - [ ] **Never draw one full-width flat picture into a woven canvas.** To show 2D on purpose, call
121
+ `wall.setStereoEnabled(false)` (fall back to easing `ipdFactor` to 0 on `NotSupportedError`).
122
+ - [ ] **2D fallback**: on `!wall.supported` render one mono view or show an `<img>` (the left eye),
123
+ never the packed side-by-side pair. `createInline3D()` can also **reject**. Guard it with
124
+ `await createInline3D().catch(() => null)` (or `try`/`catch`) and treat `null` like
125
+ `!wall.supported`. An uncaught rejection leaves the page with no 3D and no 2D fallback.
126
+
127
+ ### 5. Page chrome, HUD and detection
128
+
129
+ - Detect by capability: `await createInline3D()` → `wall.supported`, or `inline3DAvailable()` as a sync
130
+ pre-gate. **Never** the user-agent string, never `navigator.xr.isSessionSupported('inline-3d')`.
131
+ - Current browsers occlude woven tiles with 2D by draw order: a sticky header the tile scrolls
132
+ under, a buy card in a corner, badges, menus and captions over a tile just work, **opaque or
133
+ translucent**, as plain HTML (a solid or rgba background and text). Keep them **partial** (a bar,
134
+ a card, a pill): a section painted over the WHOLE tile hides it while it keeps rendering.
135
+ - What does NOT work over a tile: a pixel-moving `filter` (blur, drop-shadow), a `mix-blend-mode`
136
+ other than normal, `transform-style: preserve-3d` on the chrome; the tile weaves through them.
137
+ `backdrop-filter` (frost) is fine on DisplayXR Browser 0.1.16+ over a **partial** region (the tile
138
+ is drawn flat under it), never over a whole visible tile. If you must also serve older browsers,
139
+ use a near-solid `rgba(…, .92)` bar without blur.
140
+ - Hide chrome with `display: none`, not `opacity: 0`. Ask `inline3dOcclusionByDrawOrder()` only to
141
+ drop legacy calls. The checker scrolls the page and reports chrome that passes over a tile.
142
+ - HUD text and values: HTML beside or over the tile, readable size, not drawn into the 3D scene.
143
+
144
+ ### 6. Pins (exact versions, no `^`)
145
+
146
+ `@displayxr/inline3d` **1.52.3**, `playcanvas` **2.24.0** (exact; `>=2.22.3 <3` is the supported
147
+ range), `three` **0.180.0**. CDN import maps pin the same: `https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.52.3/js/inline3d.js`,
148
+ `https://cdn.jsdelivr.net/npm/playcanvas@2.24.0/build/playcanvas.mjs`,
149
+ `https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js`. If a newer SDK is installed, its
150
+ `CHANGELOG.md` says what changed; prefer the installed version's docs over this list.
151
+
152
+ ### 7. Before you say done: run the checker
153
+
154
+ ```sh
155
+ npx -y @displayxr/inline3d-tools@0.1.0 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
156
+ ```
157
+
158
+ This runs the exact-pinned `@displayxr/inline3d-tools` package from npm (the first run downloads it;
159
+ the user may be asked to approve the command). Needs Node ≥ 18 and a local Chrome (`CHROME=/path/to/chrome`).
160
+ If the `inline3d-tools` MCP server is configured, its `check` tool is the same check (and the route
161
+ to use inside a sandbox that blocks local servers).
162
+ It loads the page in headless Chrome inside a fake DisplayXR Browser (two real eye views) and again
163
+ plain, and reports pass/fail per check: session reached, real stereo, no blank eye, no flat
164
+ side-by-side, buffer not clamped, CSS/cover/overlay/session rules (scrolling the page past each
165
+ tile), the page going flat when the session ends (`onLayerLost`), console and GL errors, 2D
166
+ fallback, plus the rig, comfort and measured depth. Fix every **FAIL**; read every **WARN**; each
167
+ line names the doc section. For a Vite/dev-server app pass the running URL. Use `--root <project>`
168
+ when a page imports `../` or `/node_modules/`. A green run is not a panel test: say so, and ask for
169
+ a check on real hardware when depth or look matters. Scaffold a known-good page with the "Scaffold an inline-3D page" section below. Any model, texture or poster the page loads goes through the "Assets for inline-3D pages" section below first (convert, optimise, `assets` check, `ASSETS.md`).
170
+
171
+ **When to run it.** After you edit any file of a page that uses `@displayxr/inline3d` (its HTML,
172
+ scripts or CSS), the page is unchecked until the checker has run again: run it before you tell the
173
+ user the page is done, and again after every round of fixes. If you end a turn with an edited page
174
+ you could not check (no Chrome, no Node, the user declined the command), say so in one line and give
175
+ the user the command above to run.
176
+
177
+ ## Scaffold an inline-3D page
178
+
179
+ The templates ship in the exact-pinned `@displayxr/inline3d-tools` npm package; its `scaffold`
180
+ command copies them (the first run downloads the package; the user may be asked to approve the command):
181
+
182
+ ```sh
183
+ npx -y @displayxr/inline3d-tools@0.1.0 scaffold esm <target-dir> --title "<page title>"
184
+ npx -y @displayxr/inline3d-tools@0.1.0 scaffold vite <target-dir> --title "<page title>" [--name <npm-name>]
185
+ ```
186
+
187
+ It never overwrites an existing file (`--force` replaces). What it writes:
188
+
189
+ | file | what |
190
+ |---|---|
191
+ | `app.js` | the page logic (shared by both flavours): a three.js scene on `addScene` with `EyeCamera`, display rig, validate-before-clear with last-good replay, buffer sized 2× the box (dpr ≤ 2, clamped to the GPU), cover removed on `handle.firstWoven` + a 4 s timeout + `catch`, a mono 2D fallback |
192
+ | `style.css` | page styles; the canvas and its ancestors carry no CSS effects |
193
+ | `index.html` (esm) | no build step: an import map with exact CDN pins |
194
+ | `index.html` + `package.json` (vite) | Vite: exact npm pins (`@displayxr/inline3d` 1.52.3, `three` 0.180.0) |
195
+
196
+ ### Steps
197
+
198
+ 1. Pick the flavour: **esm** unless the project already uses npm/a bundler (then **vite**, or merge
199
+ the pins into the existing `package.json` exactly, no `^`).
200
+ 2. Run `scaffold` with the flavour and the target directory (it fills in the title and, for vite,
201
+ the package name). Don't add an `<img>` or extra canvas: there is ONE persistent canvas.
202
+ 3. Pick the content (the "Building on @displayxr/inline3d" §1 table) and swap the scene block if it is not a custom
203
+ scene. Keep the cover, the fallback and the pins. For a model or a splat, replace everything from
204
+ "renderer + scene" down with the viewer call, which handles the buffer, framing, validation and
205
+ the 2D fallback itself:
206
+
207
+ ```js
208
+ import { createInline3D } from '@displayxr/inline3d';
209
+ import { addModel } from '@displayxr/inline3d/model'; // or: import { addSplat } from '@displayxr/inline3d/splat/playcanvas';
210
+ const wall = await createInline3D().catch(() => null); // unsupported -> the viewer draws 2D
211
+ const handle = addModel(wall, canvas, './assets/model.glb'); // addSplat(wall, canvas, './scene.sog', { engine: 'playcanvas' })
212
+ // the page behind the tile shows around the subject: keep it a soft colour (or pass clearColor)
213
+ Promise.race([handle.firstWoven, new Promise((r) => setTimeout(r, 4000))]).finally(dropCover);
214
+ ```
215
+
216
+ A player is the same shape: `addPlayer(wall, canvas, ['./clip.webm', './clip.mp4'], { poster })`
217
+ from `/player` (webm first; the canvas sits in a container for the transport), and the cover
218
+ comes off on `player.firstWoven` + the timeout, never on `'ready'` / `loadeddata`. On an SDK
219
+ without `player.firstWoven`, wait for the first frame and then ~1200 ms more.
220
+
221
+ Add `"playcanvas": "https://cdn.jsdelivr.net/npm/playcanvas@2.24.0/build/playcanvas.mjs"` and
222
+ `"@displayxr/inline3d/model": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.52.3/js/inline3d-model-entry.js"`
223
+ (or `.../js/inline3d-splat-pc-entry.js` for `/splat/playcanvas`) to the import map, or
224
+ `"playcanvas": "2.24.0"` to `package.json`. Images and video use `wall.addImage(canvas, 'pic_2x1.jpg')`
225
+ / `wall.addVideo(canvas, videoEl)` in the 3D branch and an `<img>` of the left half (or a mono
226
+ video) in the 2D branch. Check each export against the installed `.d.ts` before using it.
227
+ 4. Run it: esm → serve the directory (`python3 -m http.server`), or let the checker
228
+ serve it; vite → `npm install && npm run dev`.
229
+ 5. **Run the checker before saying done**, and fix every FAIL:
230
+
231
+ ```sh
232
+ npx -y @displayxr/inline3d-tools@0.1.0 check <target-dir> # esm
233
+ npx -y @displayxr/inline3d-tools@0.1.0 check http://localhost:5173/ # vite dev server
234
+ ```
235
+
236
+ The untouched template passes every check (verdict PASS). If your change makes a check fail, the
237
+ failing line names the rule and the doc in `node_modules/@displayxr/inline3d/docs/`.
238
+
239
+ ## Assets for inline-3D pages
240
+
241
+ Both eyes draw every triangle and sample every texture, the weakest device is a tablet with a
242
+ 4096 px texture limit, and depth errors that a 2D page hides (sorting, z-fighting, a model that is
243
+ centimetres instead of metres) show in stereo. So every asset goes through the same three steps:
244
+ **get it → prepare it → check it**, and every asset gets a line in `ASSETS.md`.
245
+
246
+ Tools, in the order to reach for them:
247
+
248
+ | Tool | When | Install |
249
+ |---|---|---|
250
+ | `inline3d-tools assets` | always, last | `npx -y @displayxr/inline3d-tools@0.1.0 assets` (exact pin, from npm; Node only) |
251
+ | glTF-Transform CLI | glTF/GLB in, glTF/GLB out: inspect, resize, compress, simplify, centre | `npx -y @gltf-transform/cli@4.3.0` (pinned; nothing installed globally) |
252
+ | Blender (headless) | any other format (FBX, OBJ, STL, PLY, DAE, .blend), units/axis fixes, heavy decimation | **only if already installed**; never install it |
253
+ | `inline3d-tools gen` | no asset exists and the user wants one generated | `npx -y @displayxr/inline3d-tools@0.1.0 gen`; needs the user's own API key in the environment; every call is paid and needs the user's yes |
254
+
255
+ ### 1. Get it
256
+
257
+ In order of preference:
258
+
259
+ 1. **The user's own asset** (in the project, or a path they gave). Record it:
260
+ `npx -y @displayxr/inline3d-tools@0.1.0 gen provenance --file assets/x.glb --source "supplied by the user" --license "user's"`.
261
+ 2. **A library asset with a clear licence** (CC0 / CC-BY, e.g. the Khronos glTF sample models,
262
+ Poly Haven). Record the URL, author and licence; CC-BY needs visible credit on the page.
263
+ 3. **A placeholder you build** (primitives in three.js/PlayCanvas) when nothing fits and the user
264
+ did not ask for generation. Say so in your notes.
265
+ 4. **Generation**, only when the user asked for it or agreed. See §4.
266
+
267
+ Never take a model from a site whose licence you cannot state.
268
+
269
+ ### 2. Prepare it
270
+
271
+ **glTF/GLB (glTF-Transform).** Look first, then fix only what the check flags:
272
+
273
+ ```sh
274
+ GT="npx -y @gltf-transform/cli@4.3.0"
275
+ $GT inspect in.glb # triangles, textures, extensions, size
276
+ $GT optimize in.glb out.glb --compress false --texture-compress webp --texture-size 2048
277
+ ```
278
+
279
+ That default (WebP textures resized to 2048, deduplicated, pruned, no geometry compression) needs
280
+ **no decoder** on the page. Only for big meshes add `--compress meshopt` and then the
281
+ `meshoptimizer` package (an import-map entry or `package.json` pin): nothing to serve. Avoid
282
+ `--compress draco` and KTX2 unless the page already serves `/draco/` and `/basis/` (the SDK never
283
+ fetches decoders from a CDN). Other fixes: `$GT simplify in.glb out.glb --ratio 0.5 --error 0.001`
284
+ (too many triangles), `$GT center in.glb out.glb --pivot center` (the origin is far from the model),
285
+ `$GT copy in.gltf out.glb` (a multi-file .gltf → one file you cannot half-deploy).
286
+
287
+ **Anything else (Blender, if present).** Detect it, don't install it:
288
+
289
+ ```sh
290
+ npx -y @displayxr/inline3d-tools@0.1.0 assets prep in.fbx out.glb [--metres 0.01] [--decimate 0.5] [--blender <path>]
291
+ ```
292
+
293
+ It looks for Blender (`--blender`, `$BLENDER`, `PATH`, the default install location), never installs
294
+ it, and runs the package's headless prep script, which imports, applies transforms, scales to
295
+ metres (`--metres` = metres per source unit: 0.01 for centimetres), decimates, recentres the bounds on the origin and exports one GLB. Then run
296
+ the glTF-Transform `optimize` line on its output (Blender writes PNG textures; WebP is far smaller).
297
+ No Blender: say the format cannot be converted here, and ask for a GLB.
298
+
299
+ Units: `addModel` frames the model on the glass from its bounds, so units and offset do not break
300
+ it; a model you place in your own `addScene` must be in **metres, centred** (its real size: a
301
+ helmet is ~0.3 m, not 2 m).
302
+
303
+ ### 3. Check it (before the page uses it)
304
+
305
+ ```sh
306
+ npx -y @displayxr/inline3d-tools@0.1.0 assets out.glb # tablet budget (default)
307
+ npx -y @displayxr/inline3d-tools@0.1.0 assets out.glb --target desktop
308
+ ```
309
+
310
+ It reports: missing external files, decoders the page must provide, triangles (both eyes draw
311
+ them; tablet budget 300k), draw calls, size/units/pivot, texture sizes and decoded GPU memory
312
+ (over 4096 px fails on a tablet), alpha-BLEND materials (sorting errors read as depth errors in
313
+ stereo; use MASK for cut-outs), metallic/glass materials (they need an environment map: keep
314
+ `addModel`'s default image-based environment (`'room'` / `'neutral'`) or pass `envMap`; never
315
+ `environment: 'studio'`, a punctual rig under which metal renders dark), file size, and
316
+ animations. Fix every FAIL; act on WARNs or say why not. Then run the page checker ("Building on @displayxr/inline3d" §7): the asset check is about the file, the page check about how it is shown.
317
+
318
+ ### 4. Generate it (optional, paid, the user's keys)
319
+
320
+ ```sh
321
+ npx -y @displayxr/inline3d-tools@0.1.0 gen providers # which adapters have a key (names only)
322
+ ```
323
+
324
+ Adapters: `meshy` and `tripo` (text-to-3d, image-to-3d → GLB), `openai` (image → PNG, for
325
+ textures, posters and backdrops). Each reads its key from the environment (`MESHY_API_KEY`,
326
+ `TRIPO_API_KEY`, `OPENAI_API_KEY`) and from nowhere else.
327
+
328
+ **Rules, no exceptions:**
329
+ - **Never ask for, print, echo, log, write or commit a key.** Never put one in a file, an env file
330
+ you create, a command line, or `ASSETS.md`. If no key is set, the adapter is unavailable: say so
331
+ and use §1 instead. Do not suggest pasting a key into the chat.
332
+ - **Ask before every paid call.** Tell the user the adapter, what you will generate (the prompt or
333
+ image), and the cost estimate `gen run` prints; only after they say yes run it with
334
+ `--confirm-paid`. Without that flag `gen run` refuses and prints the estimate. One yes covers
335
+ one call, not a batch, unless the user said otherwise.
336
+ - **Every generated file goes through §2 and §3** (generated models are often huge, off-centre,
337
+ with 4K textures), and `gen run` has already written its `ASSETS.md` line (adapter, prompt,
338
+ date, the provider's licence note). Check the provider's licence terms before calling the asset
339
+ shippable.
340
+
341
+ ```sh
342
+ npx -y @displayxr/inline3d-tools@0.1.0 gen run meshy --kind text-to-3d --prompt "a brass desk lamp, PBR" --out assets/lamp-raw.glb --confirm-paid
343
+ ```
344
+
345
+ ### 5. ASSETS.md
346
+
347
+ One table, at the project root, one row per file the page loads that you did not write: file,
348
+ source (URL, "supplied by the user", or `generated: <adapter> <kind>`), licence, date, notes
349
+ (prompt, author, changes made: "optimised: webp 2048, decimated 50%"). Create it with the
350
+ `provenance` command; keep it in the deliverable. A CC-BY asset also needs a visible credit on the
351
+ page.
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025-2026 David Fattal
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.