@displayxr/inline3d-tools 0.1.1 → 0.1.2

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 CHANGED
@@ -1,6 +1,6 @@
1
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
2
 
3
- # Agent instructions: glasses-free 3D web pages with @displayxr/inline3d
3
+ # Agent instructions: 3D web pages for Spatial Displays with @displayxr/inline3d
4
4
 
5
5
  For any coding agent (OpenAI Codex, Cursor, Claude Code without the plugin, others). Copy this file
6
6
  into a project as `AGENTS.md` (or point your agent at it) when the project builds pages on
@@ -15,11 +15,11 @@ sandboxed agent, prefer the MCP server** (below): MCP servers run outside the sa
15
15
  sandbox. Otherwise run them as shell commands:
16
16
 
17
17
  ```sh
18
- npx -y @displayxr/inline3d-tools@0.1.1 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
19
- npx -y @displayxr/inline3d-tools@0.1.1 assets <file.glb> [--target tablet|desktop]
20
- npx -y @displayxr/inline3d-tools@0.1.1 assets prep <in> <out.glb> [--metres 0.01] [--decimate 0.5]
21
- npx -y @displayxr/inline3d-tools@0.1.1 scaffold <esm|vite> <target-dir> --title "<page title>"
22
- npx -y @displayxr/inline3d-tools@0.1.1 gen providers | gen run <adapter> ... --confirm-paid | gen provenance --file ...
18
+ npx -y @displayxr/inline3d-tools@0.1.2 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
19
+ npx -y @displayxr/inline3d-tools@0.1.2 assets <file.glb> [--target tablet|desktop]
20
+ npx -y @displayxr/inline3d-tools@0.1.2 assets prep <in> <out.glb> [--metres 0.01] [--decimate 0.5]
21
+ npx -y @displayxr/inline3d-tools@0.1.2 scaffold <esm|vite> <target-dir> --title "<page title>"
22
+ npx -y @displayxr/inline3d-tools@0.1.2 gen providers | gen run <adapter> ... --confirm-paid | gen provenance --file ...
23
23
  ```
24
24
 
25
25
  or, with the MCP server configured (`inline3d-tools mcp`; config snippets for Codex, Cursor and
@@ -100,6 +100,11 @@ world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
100
100
  Release on `handle.firstWoven` (`addVideo`), `player.firstWoven` (`addPlayer`, SDK 1.53+; on an
101
101
  older SDK where it is undefined, wait for the first frame and then `firstWovenHoldMs` ≈ 1200 ms
102
102
  more), plus the timeout. Give a player a `poster`: it is painted into both eyes under the cover.
103
+ - [ ] **Covering a move or resize:** use `rectCover: 'auto'` (the default on `./splat` / `./model`).
104
+ Running your own cover (`rectCover: 'off'`): raise it only while `handle.wovenState` is not
105
+ `'woven'`, and release it on `handle.rewoven()`. A cover over a tile the browser is still weaving
106
+ is woven with it: each eye gets half of its 2D picture, stretched twice as wide (SDK 1.56.1+;
107
+ `woven-canvas-rules.md` §11).
103
108
  - [ ] **What is behind a transparent tile is part of the picture.** `addSplat` / `addModel` clear
104
109
  transparent by default, and the browser pre-blends the page under both eyes, flat, at half
105
110
  horizontal resolution. Make that page area a soft light or mid-tone colour or gradient (no
@@ -120,9 +125,12 @@ world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
120
125
  - [ ] **Never draw one full-width flat picture into a woven canvas.** To show 2D on purpose, call
121
126
  `wall.setStereoEnabled(false)` (fall back to easing `ipdFactor` to 0 on `NotSupportedError`).
122
127
  - [ ] **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.
128
+ never the packed side-by-side pair. `createInline3D()` and the startup around it can also
129
+ **reject** (an unexpected error, no WebGL, a failed import or asset). Guard it, log the reason:
130
+ `const wall = await createInline3D().catch((err) => { console.warn('inline 3D unavailable, showing 2D', err); return null; });`
131
+ (or wrap the whole startup in `start().catch(...)`, as the scaffold's `app.js` does), then
132
+ treat `null` like `!wall.supported`: draw the 2D view, or show a visible error, and drop the
133
+ cover. An unhandled rejection leaves a blank or still-covered canvas: no 3D and no 2D.
126
134
 
127
135
  ### 5. Page chrome, HUD and detection
128
136
 
@@ -152,7 +160,7 @@ range), `three` **0.180.0**. CDN import maps pin the same: `https://cdn.jsdelivr
152
160
  ### 7. Before you say done: run the checker
153
161
 
154
162
  ```sh
155
- npx -y @displayxr/inline3d-tools@0.1.1 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
163
+ npx -y @displayxr/inline3d-tools@0.1.2 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
156
164
  ```
157
165
 
158
166
  This runs the exact-pinned `@displayxr/inline3d-tools` package from npm (the first run downloads it;
@@ -180,8 +188,8 @@ The templates ship in the exact-pinned `@displayxr/inline3d-tools` npm package;
180
188
  command copies them (the first run downloads the package; the user may be asked to approve the command):
181
189
 
182
190
  ```sh
183
- npx -y @displayxr/inline3d-tools@0.1.1 scaffold esm <target-dir> --title "<page title>"
184
- npx -y @displayxr/inline3d-tools@0.1.1 scaffold vite <target-dir> --title "<page title>" [--name <npm-name>]
191
+ npx -y @displayxr/inline3d-tools@0.1.2 scaffold esm <target-dir> --title "<page title>"
192
+ npx -y @displayxr/inline3d-tools@0.1.2 scaffold vite <target-dir> --title "<page title>" [--name <npm-name>]
185
193
  ```
186
194
 
187
195
  It never overwrites an existing file (`--force` replaces). What it writes:
@@ -207,7 +215,10 @@ It never overwrites an existing file (`--force` replaces). What it writes:
207
215
  ```js
208
216
  import { createInline3D } from '@displayxr/inline3d';
209
217
  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
218
+ const wall = await createInline3D().catch((err) => { // a rejection must not blank the page:
219
+ console.warn('inline 3D unavailable, showing 2D', err); // log it, then the viewer draws 2D
220
+ return null;
221
+ });
211
222
  const handle = addModel(wall, canvas, './assets/model.glb'); // addSplat(wall, canvas, './scene.sog', { engine: 'playcanvas' })
212
223
  // the page behind the tile shows around the subject: keep it a soft colour (or pass clearColor)
213
224
  Promise.race([handle.firstWoven, new Promise((r) => setTimeout(r, 4000))]).finally(dropCover);
@@ -229,8 +240,8 @@ It never overwrites an existing file (`--force` replaces). What it writes:
229
240
  5. **Run the checker before saying done**, and fix every FAIL:
230
241
 
231
242
  ```sh
232
- npx -y @displayxr/inline3d-tools@0.1.1 check <target-dir> # esm
233
- npx -y @displayxr/inline3d-tools@0.1.1 check http://localhost:5173/ # vite dev server
243
+ npx -y @displayxr/inline3d-tools@0.1.2 check <target-dir> # esm
244
+ npx -y @displayxr/inline3d-tools@0.1.2 check http://localhost:5173/ # vite dev server
234
245
  ```
235
246
 
236
247
  The untouched template passes every check (verdict PASS). If your change makes a check fail, the
@@ -247,17 +258,17 @@ Tools, in the order to reach for them:
247
258
 
248
259
  | Tool | When | Install |
249
260
  |---|---|---|
250
- | `inline3d-tools assets` | always, last | `npx -y @displayxr/inline3d-tools@0.1.1 assets` (exact pin, from npm; Node only) |
261
+ | `inline3d-tools assets` | always, last | `npx -y @displayxr/inline3d-tools@0.1.2 assets` (exact pin, from npm; Node only) |
251
262
  | 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
263
  | 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.1 gen`; needs the user's own API key in the environment; every call is paid and needs the user's yes |
264
+ | `inline3d-tools gen` | no asset exists and the user wants one generated | `npx -y @displayxr/inline3d-tools@0.1.2 gen`; needs the user's own API key in the environment; every call is paid and needs the user's yes |
254
265
 
255
266
  ### 1. Get it
256
267
 
257
268
  In order of preference:
258
269
 
259
270
  1. **The user's own asset** (in the project, or a path they gave). Record it:
260
- `npx -y @displayxr/inline3d-tools@0.1.1 gen provenance --file assets/x.glb --source "supplied by the user" --license "user's"`.
271
+ `npx -y @displayxr/inline3d-tools@0.1.2 gen provenance --file assets/x.glb --source "supplied by the user" --license "user's"`.
261
272
  2. **A library asset with a clear licence** (CC0 / CC-BY, e.g. the Khronos glTF sample models,
262
273
  Poly Haven). Record the URL, author and licence; CC-BY needs visible credit on the page.
263
274
  3. **A placeholder you build** (primitives in three.js/PlayCanvas) when nothing fits and the user
@@ -287,7 +298,7 @@ fetches decoders from a CDN). Other fixes: `$GT simplify in.glb out.glb --ratio
287
298
  **Anything else (Blender, if present).** Detect it, don't install it:
288
299
 
289
300
  ```sh
290
- npx -y @displayxr/inline3d-tools@0.1.1 assets prep in.fbx out.glb [--metres 0.01] [--decimate 0.5] [--blender <path>]
301
+ npx -y @displayxr/inline3d-tools@0.1.2 assets prep in.fbx out.glb [--metres 0.01] [--decimate 0.5] [--blender <path>]
291
302
  ```
292
303
 
293
304
  It looks for Blender (`--blender`, `$BLENDER`, `PATH`, the default install location), never installs
@@ -303,8 +314,8 @@ helmet is ~0.3 m, not 2 m).
303
314
  ### 3. Check it (before the page uses it)
304
315
 
305
316
  ```sh
306
- npx -y @displayxr/inline3d-tools@0.1.1 assets out.glb # tablet budget (default)
307
- npx -y @displayxr/inline3d-tools@0.1.1 assets out.glb --target desktop
317
+ npx -y @displayxr/inline3d-tools@0.1.2 assets out.glb # tablet budget (default)
318
+ npx -y @displayxr/inline3d-tools@0.1.2 assets out.glb --target desktop
308
319
  ```
309
320
 
310
321
  It reports: missing external files, decoders the page must provide, triangles (both eyes draw
@@ -318,7 +329,7 @@ animations. Fix every FAIL; act on WARNs or say why not. Then run the page check
318
329
  ### 4. Generate it (optional, paid, the user's keys)
319
330
 
320
331
  ```sh
321
- npx -y @displayxr/inline3d-tools@0.1.1 gen providers # which adapters have a key (names only)
332
+ npx -y @displayxr/inline3d-tools@0.1.2 gen providers # which adapters have a key (names only)
322
333
  ```
323
334
 
324
335
  Adapters: `meshy` and `tripo` (text-to-3d, image-to-3d → GLB), `openai` (image → PNG, for
@@ -339,7 +350,7 @@ textures, posters and backdrops). Each reads its key from the environment (`MESH
339
350
  shippable.
340
351
 
341
352
  ```sh
342
- npx -y @displayxr/inline3d-tools@0.1.1 gen run meshy --kind text-to-3d --prompt "a brass desk lamp, PBR" --out assets/lamp-raw.glb --confirm-paid
353
+ npx -y @displayxr/inline3d-tools@0.1.2 gen run meshy --kind text-to-3d --prompt "a brass desk lamp, PBR" --out assets/lamp-raw.glb --confirm-paid
343
354
  ```
344
355
 
345
356
  ### 5. ASSETS.md
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @displayxr/inline3d-tools
2
2
 
3
- Tools for building glasses-free 3D web pages on
3
+ Tools for building 3D web pages for Spatial Displays on
4
4
  [`@displayxr/inline3d`](https://www.npmjs.com/package/@displayxr/inline3d), for any coding agent
5
5
  or a human: a headless page checker, a glTF/GLB asset check, page scaffolds, optional paid asset
6
6
  generation with provenance, and a stdio [MCP](https://modelcontextprotocol.io) server exposing the
@@ -9,7 +9,7 @@ same operations. [`AGENTS.md`](AGENTS.md) is the matching authoring checklist fo
9
9
  Needs Node ≥ 18. `check` also needs a local Chrome or Chromium. Always run an **exact version**:
10
10
 
11
11
  ```sh
12
- npx -y @displayxr/inline3d-tools@0.1.1 <command> ...
12
+ npx -y @displayxr/inline3d-tools@0.1.2 <command> ...
13
13
  ```
14
14
 
15
15
  ## CLI
@@ -47,7 +47,7 @@ environment only and are redacted from every tool result.
47
47
  ### Claude Code
48
48
 
49
49
  ```sh
50
- claude mcp add inline3d-tools -- npx -y @displayxr/inline3d-tools@0.1.1 mcp
50
+ claude mcp add inline3d-tools -- npx -y @displayxr/inline3d-tools@0.1.2 mcp
51
51
  ```
52
52
 
53
53
  or in a project's `.mcp.json`:
@@ -57,7 +57,7 @@ or in a project's `.mcp.json`:
57
57
  "mcpServers": {
58
58
  "inline3d-tools": {
59
59
  "command": "npx",
60
- "args": ["-y", "@displayxr/inline3d-tools@0.1.1", "mcp"]
60
+ "args": ["-y", "@displayxr/inline3d-tools@0.1.2", "mcp"]
61
61
  }
62
62
  }
63
63
  }
@@ -77,7 +77,7 @@ needs you to approve running it outside the sandbox. In `~/.codex/config.toml` (
77
77
  ```toml
78
78
  [mcp_servers.inline3d-tools]
79
79
  command = "npx"
80
- args = ["-y", "@displayxr/inline3d-tools@0.1.1", "mcp"]
80
+ args = ["-y", "@displayxr/inline3d-tools@0.1.2", "mcp"]
81
81
  # cwd = "/path/to/your/project" # relative paths in tool calls resolve here
82
82
  startup_timeout_sec = 30 # first run downloads the package (default 10)
83
83
  tool_timeout_sec = 180 # a page check takes 10-60 s; generation can take minutes (default 60)
@@ -85,11 +85,11 @@ tool_timeout_sec = 180 # a page check takes 10-60 s; generation can t
85
85
  # env_vars = ["MESHY_API_KEY", "TRIPO_API_KEY", "OPENAI_API_KEY"]
86
86
  ```
87
87
 
88
- or `codex mcp add inline3d-tools -- npx -y @displayxr/inline3d-tools@0.1.1 mcp`. The
88
+ or `codex mcp add inline3d-tools -- npx -y @displayxr/inline3d-tools@0.1.2 mcp`. The
89
89
  [`displayxr-inline3d-codex` plugin](https://github.com/DisplayXR/displayxr-web/tree/main/plugins/displayxr-inline3d-codex)
90
90
  sets the server up for you in Codex.
91
91
 
92
- **Fetch the package once before the first Codex session:** `npx -y @displayxr/inline3d-tools@0.1.1 --version`.
92
+ **Fetch the package once before the first Codex session:** `npx -y @displayxr/inline3d-tools@0.1.2 --version`.
93
93
  Codex starts MCP servers when a session starts and can stop one before a cold `npx` download
94
94
  finishes. The interrupted download leaves a broken entry in npm's `_npx` cache (`node_modules`
95
95
  without a `package.json`), and from then on the server fails at every start with
@@ -109,7 +109,7 @@ In `~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (one project):
109
109
  "mcpServers": {
110
110
  "inline3d-tools": {
111
111
  "command": "npx",
112
- "args": ["-y", "@displayxr/inline3d-tools@0.1.1", "mcp"]
112
+ "args": ["-y", "@displayxr/inline3d-tools@0.1.2", "mcp"]
113
113
  }
114
114
  }
115
115
  }
@@ -151,7 +151,7 @@ forwarding). Never paste a key into an agent chat.
151
151
  ## check
152
152
 
153
153
  ```sh
154
- npx -y @displayxr/inline3d-tools@0.1.1 check <url | dir | page.html> [--root <dir>] [--max-texture 4096] [--json] [--out report.json]
154
+ npx -y @displayxr/inline3d-tools@0.1.2 check <url | dir | page.html> [--root <dir>] [--max-texture 4096] [--json] [--out report.json]
155
155
  ```
156
156
 
157
157
  Needs Node ≥ 18 and a local Chrome (`CHROME=/path/to/chrome` overrides the default location). It
@@ -177,8 +177,9 @@ disparity, so the checker can measure depth in millimetres of screen disparity.
177
177
  | (f) `single-session` | concurrent live sessions, a canvas registered twice, overlapping woven canvases | real |
178
178
  | (f) `overlay` | grid hit-test (pointer-events forced on) for opaque elements above the canvas after `firstWoven`; a cover present at registration and still there = "never came off"; then a **scroll sweep** over the whole page: chrome that passes over a tile with a filter, blend mode or 3D context, a whole-tile frost, or a section painted over the whole tile. Partial chrome (sticky header, buy card), opaque or translucent, passes: current browsers occlude by draw order | real, grid-sampled |
179
179
  | (f) `layer-lost` | ends the session, then compares each canvas with what it showed before: unchanged = the page left its side-by-side pair up (no-op `onLayerLost`) | real |
180
- | (g) `console` | console errors, uncaught exceptions, HTTP ≥ 400, GL errors, failed shader compile/link | real |
180
+ | (g) `console` | console errors, uncaught exceptions and unhandled promise rejections (labelled as such, 0.1.2), HTTP ≥ 400, GL errors, failed shader compile/link | real |
181
181
  | (h) `fallback-2d` | second run without the fake: no errors, and each canvas that wove shows something | real |
182
+ | (h) `startup-guard` | static scan of same-origin scripts: a `createInline3D()` / `sharedInline3D()` / `startInline3D()` call in a file with no `.catch(` or `try`/`catch` at all is a WARN (a rejection there leaves a blank or covered canvas), 0.1.2 | approximate |
182
183
  | `detection` | runtime `isSessionSupported('inline-3d')` calls; static scan of same-origin scripts for it and for UA sniffing next to "DisplayXR" | approximate |
183
184
  | `pins` | import-map CDN URLs and `package.json` versions for the SDK, playcanvas and three are exact | approximate |
184
185
  | `depth` | block-matched disparity of the primary canvas, in mm of screen disparity, against the Shibata comfort zone at 0.65 m; subject entirely off the glass | approximate |
@@ -1,4 +1,4 @@
1
- // inline3d-tools assets — is this glTF/GLB ready for an inline-3D page on a glasses-free 3D display?
1
+ // inline3d-tools assets — is this glTF/GLB ready for an inline-3D page on a Spatial Display?
2
2
  // Zero dependencies: reads the glTF JSON, the accessor bounds and the image headers itself.
3
3
  //
4
4
  // inline3d-tools assets <file.glb|file.gltf> [--json] [--target desktop|tablet]
package/lib/check/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // inline3d-tools check — does this @displayxr/inline3d page really render glasses-free 3D?
1
+ // inline3d-tools check — does this @displayxr/inline3d page really render 3D on a Spatial Display?
2
2
  //
3
3
  // inline3d-tools check <url | dir | file.html> [--root <dir>] [--max-texture 4096] [--json] [--out report.json]
4
4
  //
package/lib/check/run.mjs CHANGED
@@ -15,6 +15,12 @@ const PROBE_SRC = readFileSync(join(HERE, 'probe.js'), 'utf8');
15
15
  const FAKE_SRC = readFileSync(join(HERE, 'fake-env.js'), 'utf8');
16
16
  export const VERSION = JSON.parse(readFileSync(join(HERE, '..', '..', 'package.json'), 'utf8')).version;
17
17
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
18
+ const SNAP_TRIES = 6, SNAP_RETRY_MS = 150;
19
+ function eyeBlank(snap) {
20
+ if (!snap || !snap.sw || snap.error) return false; // reported as is; nothing to retry against
21
+ const [L, R] = halves(fromBase64Rgba(snap.rgba, snap.sw, snap.sh));
22
+ return contentStats(L).blank || contentStats(R).blank;
23
+ }
18
24
  const DOCS = 'node_modules/@displayxr/inline3d/docs';
19
25
  const MPP = 0.3456 / 1920; // metres per CSS px on the fake panel (see fake-env.js)
20
26
 
@@ -52,7 +58,11 @@ function collect(page, pageOrigin) {
52
58
  });
53
59
  page.on('Runtime.exceptionThrown', (p) => {
54
60
  const d = p.exceptionDetails || {};
55
- log.exceptions.push({ text: ((d.exception && d.exception.description) || d.text || 'exception').slice(0, 600), at: d.url ? `${d.url}:${(d.lineNumber || 0) + 1}` : undefined });
61
+ log.exceptions.push({
62
+ text: ((d.exception && d.exception.description) || d.text || 'exception').slice(0, 600),
63
+ at: d.url ? `${d.url}:${(d.lineNumber || 0) + 1}` : undefined,
64
+ rejection: /in promise/i.test(d.text || ''), // Chrome: "Uncaught (in promise)"
65
+ });
56
66
  });
57
67
  page.on('Log.entryAdded', (p) => {
58
68
  const e = p.entry || {};
@@ -108,8 +118,20 @@ async function screenshot(page) {
108
118
  return decodePng(Buffer.from(data, 'base64'));
109
119
  }
110
120
 
121
+ // A page script that opens the session (createInline3D / sharedInline3D / startInline3D) but has
122
+ // no catch anywhere: a rejection there is unhandled and leaves a blank or covered canvas.
123
+ // Approximate on purpose: one `.catch(` or `try/catch` anywhere in the file counts as guarded.
124
+ const CREATE_CALL_RE = /\b(?:createInline3D|sharedInline3D|startInline3D)\s*\(/;
125
+ const CATCH_RE = /\.catch\s*\(|\bcatch\s*[({]/;
126
+ export function unguardedCreateCall(source) {
127
+ const code = String(source || '')
128
+ .replace(/\/\*[\s\S]*?\*\//g, ' ')
129
+ .replace(/(^|[^:\\])\/\/[^\n]*/g, '$1'); // line comments, not the // in a URL
130
+ return CREATE_CALL_RE.test(code) && !CATCH_RE.test(code);
131
+ }
132
+
111
133
  async function staticScan(page, log) {
112
- const findings = { isSessionSupported: [], uaSniff: [], importMaps: [] };
134
+ const findings = { isSessionSupported: [], uaSniff: [], importMaps: [], createCalls: [], unguardedCreate: [] };
113
135
  for (const s of log.scripts.slice(0, 40)) {
114
136
  let body = '';
115
137
  try {
@@ -119,6 +141,8 @@ async function staticScan(page, log) {
119
141
  if (body.length > 3_000_000) continue;
120
142
  if (/isSessionSupported\s*\(\s*['"`]inline-3d/.test(body)) findings.isSessionSupported.push(s.url);
121
143
  if (/navigator\.(userAgent|userAgentData)/.test(body) && /displayxr/i.test(body)) findings.uaSniff.push(s.url);
144
+ if (unguardedCreateCall(body)) findings.unguardedCreate.push(s.url);
145
+ else if (CREATE_CALL_RE.test(body)) findings.createCalls.push(s.url);
122
146
  if (s.type === 'Document') {
123
147
  const re = /<script[^>]*type\s*=\s*["']importmap["'][^>]*>([\s\S]*?)<\/script>/gi;
124
148
  let m;
@@ -181,7 +205,18 @@ async function fakeRun(conn, url, opt, origin) {
181
205
  summary = await ev(page, '__dxrCheck.summary()').catch(() => summary);
182
206
  const layers = [];
183
207
  for (const l of (summary ? summary.layers : []).filter((x) => x.open).slice(0, 4)) {
184
- const snap = await ev(page, `__dxrCheck.snap(${l.index}, 640)`).catch((e) => ({ error: String(e) }));
208
+ // One commit-time frame can catch an eye not yet drawn on a fast GPU (seen on a cloud GPU: the
209
+ // left half transparent, the right half drawn, in ~4 of 10 runs of a page that passes
210
+ // everywhere else). The readiness loop above already saw both halves drawn, so re-take the
211
+ // snapshot a few times before reporting a blank eye; a page whose eye is really blank stays
212
+ // blank in every sample and still fails.
213
+ let snap = await ev(page, `__dxrCheck.snap(${l.index}, 640)`).catch((e) => ({ error: String(e) }));
214
+ let snapTries = 1;
215
+ while (snapTries < SNAP_TRIES && eyeBlank(snap)) {
216
+ await sleep(SNAP_RETRY_MS);
217
+ snap = await ev(page, `__dxrCheck.snap(${l.index}, 640)`).catch((e) => ({ error: String(e) }));
218
+ snapTries++;
219
+ }
185
220
  const buffer = await ev(page, `__dxrProbe.bufferInfo(__dxrCheck.layerCanvas(${l.index}))`).catch(() => null);
186
221
  const occlusion = await ev(page, `__dxrProbe.occlusionAudit(__dxrCheck.layerCanvas(${l.index}))`).catch(() => null);
187
222
  const css = await ev(page, `__dxrProbe.cssAudit(__dxrCheck.layerCanvas(${l.index}))`).catch(() => null);
@@ -194,7 +229,7 @@ async function fakeRun(conn, url, opt, origin) {
194
229
  const cssAll = seen
195
230
  ? { problems: [...seen.problems.values()], decorations: [...seen.decorations], animations: [...seen.animations.values()] }
196
231
  : css || { problems: [], decorations: [], animations: [] };
197
- layers.push({ ...l, snap, buffer, occlusion, css: cssAll });
232
+ layers.push({ ...l, snap, snapTries, buffer, occlusion, css: cssAll });
198
233
  }
199
234
  const shaderErrors = await ev(page, '__dxrProbe.shaderErrors').catch(() => []);
200
235
  const scrollY = await ev(page, 'window.scrollY').catch(() => 0);
@@ -341,7 +376,7 @@ function classify(log, shaderErrors) {
341
376
  else warnings.push(c.text);
342
377
  }
343
378
  }
344
- for (const e of log.exceptions) errors.push(`uncaught: ${e.text}${e.at ? ` (${e.at})` : ''}`);
379
+ for (const e of log.exceptions) errors.push(`${e.rejection ? 'unhandled rejection' : 'uncaught'}: ${e.text}${e.at ? ` (${e.at})` : ''}`);
345
380
  for (const e of log.logEntries) {
346
381
  if (GL_RE.test(e.text)) { gl.push(e.text); continue; }
347
382
  if (e.level === 'error' && !ignoreUrl(e.url) && e.source !== 'network') errors.push(`${e.source}: ${e.text}`);
@@ -443,7 +478,7 @@ function buildChecks(fake, plain, opt) {
443
478
  for (const l of open) {
444
479
  if (!l.px) continue;
445
480
  const f = (st) => ({ blank: st.blank, black: !!st.black, transparent: !!st.transparent, contentPct: +(st.contentFraction * 100).toFixed(2), meanLum: +st.meanLum.toFixed(1) });
446
- details.push({ selector: l.selector, left: f(l.px.statsL), right: f(l.px.statsR) });
481
+ details.push({ selector: l.selector, left: f(l.px.statsL), right: f(l.px.statsR), snapshots: l.snapTries || 1 });
447
482
  }
448
483
  if (details.length) {
449
484
  const bad = details.filter((d) => d.left.blank || d.right.blank);
@@ -623,7 +658,9 @@ function buildChecks(fake, plain, opt) {
623
658
  checks.push(check('console', 'g', 'No console errors, shader or GL errors', status,
624
659
  c.gl[0] ? `GL/shader: ${c.gl[0]}` : c.errors[0] || (c.sdkWarnings[0] ? `SDK warning: ${c.sdkWarnings[0]}` : 'clean console'), {
625
660
  details: c,
626
- hint: c.sdkWarnings.length && !c.errors.length && !c.gl.length ? 'The SDK warns ([inline3d] ...) only about a page mistake it detected. Read the message: it names the fix.' : undefined,
661
+ hint: c.errors.some((e) => e.startsWith('unhandled rejection')) && !c.gl.length
662
+ ? 'A promise rejected with no handler. Await createInline3D() and the setup around it inside try/catch (or start().catch(...)): log the error and show the 2D view, so a failure never leaves a blank or covered canvas.'
663
+ : c.sdkWarnings.length && !c.errors.length && !c.gl.length ? 'The SDK warns ([inline3d] ...) only about a page mistake it detected. Read the message: it names the fix.' : undefined,
627
664
  }));
628
665
  }
629
666
 
@@ -662,6 +699,22 @@ function buildChecks(fake, plain, opt) {
662
699
  checks.push(check('detection', 'f', 'Detects support by capability, not isSessionSupported or the UA string', warns.length ? 'warn' : 'pass', warns[0] || 'no isSessionSupported/UA gating seen', { details: warns, approximate: true }));
663
700
  }
664
701
 
702
+ // startup guard (static): a rejecting createInline3D() / startup must not go unhandled
703
+ {
704
+ const st = fake.statics;
705
+ const bad = st.unguardedCreate || [];
706
+ const seen = bad.length + (st.createCalls || []).length;
707
+ checks.push(check('startup-guard', 'h', 'A rejecting createInline3D() is handled (logged, then a 2D view)', bad.length ? 'warn' : seen ? 'pass' : 'skip',
708
+ bad.length
709
+ ? `${bad[0]} calls createInline3D() with no .catch or try/catch anywhere: a rejection (no WebGL, a failed import or asset) goes unhandled and leaves a blank or covered canvas`
710
+ : seen ? `${seen} script(s) open the session with a catch in place` : 'no createInline3D() call seen in same-origin page scripts', {
711
+ details: { guarded: st.createCalls || [], unguarded: bad },
712
+ approximate: true,
713
+ hint: bad.length ? "const wall = await createInline3D().catch((err) => { console.warn('inline 3D unavailable, showing 2D', err); return null; }); then treat null like !wall.supported, or wrap the whole startup in start().catch(...) as the scaffold does." : undefined,
714
+ doc: `${DOCS}/authoring-inline-3d.md#detecting-support--do-this-not-that`,
715
+ }));
716
+ }
717
+
665
718
  // version pins (import maps + package.json)
666
719
  {
667
720
  const warns = [], seen = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@displayxr/inline3d-tools",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Agent-agnostic tools for @displayxr/inline3d pages: a headless checker (fake DisplayXR Browser + plain 2D run), a glTF/GLB asset check, page scaffolds, optional asset generation with provenance, and a stdio MCP server exposing the same operations.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,7 +30,7 @@
30
30
  "keywords": [
31
31
  "displayxr",
32
32
  "inline-3d",
33
- "glasses-free-3d",
33
+ "spatial-display",
34
34
  "3d-display",
35
35
  "mcp",
36
36
  "model-context-protocol",
package/templates/app.js CHANGED
@@ -139,7 +139,7 @@ async function start() {
139
139
  // would leave the last side-by-side pair on screen, unwoven.
140
140
  onLayerLost: () => start2D('3D layer lost'),
141
141
  });
142
- statusEl.textContent = 'glasses-free 3D';
142
+ statusEl.textContent = '3D on a Spatial Display';
143
143
  addEventListener('pagehide', () => wall.close());
144
144
  const result = await handle.firstWoven; // never rejects
145
145
  clearTimeout(coverTimer);
@@ -147,6 +147,9 @@ async function start() {
147
147
  if (!result.woven) statusEl.textContent = `3D (${result.reason})`;
148
148
  }
149
149
 
150
+ // createInline3D() and the setup around it can reject (no WebGL, a failed import, a bad asset).
151
+ // Keep this catch: log the reason and show the 2D view, never an unhandled rejection over a
152
+ // blank or still-covered canvas.
150
153
  start().catch((err) => {
151
154
  console.warn('inline 3D setup failed, showing 2D', err);
152
155
  start2D('error');