@displayxr/inline3d-tools 0.1.1 → 0.1.3
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 +56 -29
- package/README.md +13 -11
- package/lib/assets/asset-check.mjs +1 -1
- package/lib/check/analyze.mjs +76 -1
- package/lib/check/cli.mjs +1 -1
- package/lib/check/fake-env.js +1 -0
- package/lib/check/run.mjs +79 -11
- package/package.json +2 -2
- package/templates/app.js +4 -1
- package/templates/esm/index.html +2 -2
- package/templates/vite/package.template.json +1 -1
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:
|
|
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.
|
|
19
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
20
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
21
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
22
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
18
|
+
npx -y @displayxr/inline3d-tools@0.1.3 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
|
|
19
|
+
npx -y @displayxr/inline3d-tools@0.1.3 assets <file.glb> [--target tablet|desktop]
|
|
20
|
+
npx -y @displayxr/inline3d-tools@0.1.3 assets prep <in> <out.glb> [--metres 0.01] [--decimate 0.5]
|
|
21
|
+
npx -y @displayxr/inline3d-tools@0.1.3 scaffold <esm|vite> <target-dir> --title "<page title>"
|
|
22
|
+
npx -y @displayxr/inline3d-tools@0.1.3 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
|
|
@@ -70,8 +70,23 @@ three when the page already is a three.js app (`addScene` + `EyeCamera`, see
|
|
|
70
70
|
and zooms): the camera moves, so it is a camera rig. Tie `convergence` to the ground at the view
|
|
71
71
|
centre (raycast the centre of the screen to the ground plane), not to the cursor or a gaze point,
|
|
72
72
|
and cap zoom-in so the comfort product stays ≤ 1.
|
|
73
|
-
-
|
|
74
|
-
|
|
73
|
+
- **Use most of the comfort zone: too little depth is a failure too** (near-zero disparity reads
|
|
74
|
+
flat). Camera-rig eyes are real eyes, `0.063 m × ipdFactor × metersToVirtual` apart (world units
|
|
75
|
+
per real metre). Rule:
|
|
76
|
+
1. `convergence` = camera to centre of interest; the subject straddles the glass.
|
|
77
|
+
2. Never rescale your world; set `metersToVirtual`: true scale (metres, cm, ported VR) → the true
|
|
78
|
+
conversion (1, 100); no true scale (most games) → `convergence / 2` in your units (subject at
|
|
79
|
+
2 m; 13.4 → 6.7). If zoom changes the distance a lot, re-set it per frame in `setViewRig`.
|
|
80
|
+
3. `ipdFactor` tunes depth: ≈ 1 for an open scene (to the horizon); bounded (board, room, track):
|
|
81
|
+
0.8–1× of `cameraRigComfortFactor({ zNear, zFar, convergence, verticalFov, aspect, tileHeightM,
|
|
82
|
+
viewerM, ipdFactor, metersToVirtual })` (`@displayxr/inline3d/depth`; fills the zone; often 1.5–2.5).
|
|
83
|
+
`parallaxFactor` = `ipdFactor`; perspective, tilted camera; never `convergence: 0`. Comfort
|
|
84
|
+
`ipdFactor × metersToVirtual × convergenceDiopters × N` ≤ 1 (N = `nominalViewerPosition.z`, else
|
|
85
|
+
0.6 m) is the ceiling for content at infinity, not a target. Example: 13.4 units out, `ipdFactor: 2.5`, `metersToVirtual: 1`
|
|
86
|
+
uses ~20% of the zone, flat; rule: `metersToVirtual: 6.7`, `ipdFactor` ≈ 1.4–1.7.
|
|
87
|
+
- **Display rig:** `ipdFactor`/`parallaxFactor` 1 = natural, full roundness; don't lower without a reason.
|
|
88
|
+
- Budgets are reports, not limits to stay far inside: never lower depth as the user zooms.
|
|
89
|
+
Details: `docs/authoring-inline-3d.md` § Aim for real depth.
|
|
75
90
|
|
|
76
91
|
### 3. Depth and comfort (`docs/making-3d-look-right.md`, nine rules)
|
|
77
92
|
|
|
@@ -100,6 +115,11 @@ world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
|
|
|
100
115
|
Release on `handle.firstWoven` (`addVideo`), `player.firstWoven` (`addPlayer`, SDK 1.53+; on an
|
|
101
116
|
older SDK where it is undefined, wait for the first frame and then `firstWovenHoldMs` ≈ 1200 ms
|
|
102
117
|
more), plus the timeout. Give a player a `poster`: it is painted into both eyes under the cover.
|
|
118
|
+
- [ ] **Covering a move or resize:** use `rectCover: 'auto'` (the default on `./splat` / `./model`).
|
|
119
|
+
Running your own cover (`rectCover: 'off'`): raise it only while `handle.wovenState` is not
|
|
120
|
+
`'woven'`, and release it on `handle.rewoven()`. A cover over a tile the browser is still weaving
|
|
121
|
+
is woven with it: each eye gets half of its 2D picture, stretched twice as wide (SDK 1.56.1+;
|
|
122
|
+
`woven-canvas-rules.md` §11).
|
|
103
123
|
- [ ] **What is behind a transparent tile is part of the picture.** `addSplat` / `addModel` clear
|
|
104
124
|
transparent by default, and the browser pre-blends the page under both eyes, flat, at half
|
|
105
125
|
horizontal resolution. Make that page area a soft light or mid-tone colour or gradient (no
|
|
@@ -120,9 +140,12 @@ world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
|
|
|
120
140
|
- [ ] **Never draw one full-width flat picture into a woven canvas.** To show 2D on purpose, call
|
|
121
141
|
`wall.setStereoEnabled(false)` (fall back to easing `ipdFactor` to 0 on `NotSupportedError`).
|
|
122
142
|
- [ ] **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()`
|
|
124
|
-
|
|
125
|
-
|
|
143
|
+
never the packed side-by-side pair. `createInline3D()` and the startup around it can also
|
|
144
|
+
**reject** (an unexpected error, no WebGL, a failed import or asset). Guard it, log the reason:
|
|
145
|
+
`const wall = await createInline3D().catch((err) => { console.warn('inline 3D unavailable, showing 2D', err); return null; });`
|
|
146
|
+
(or wrap the whole startup in `start().catch(...)`, as the scaffold's `app.js` does), then
|
|
147
|
+
treat `null` like `!wall.supported`: draw the 2D view, or show a visible error, and drop the
|
|
148
|
+
cover. An unhandled rejection leaves a blank or still-covered canvas: no 3D and no 2D.
|
|
126
149
|
|
|
127
150
|
### 5. Page chrome, HUD and detection
|
|
128
151
|
|
|
@@ -143,8 +166,8 @@ world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
|
|
|
143
166
|
|
|
144
167
|
### 6. Pins (exact versions, no `^`)
|
|
145
168
|
|
|
146
|
-
`@displayxr/inline3d` **1.
|
|
147
|
-
range), `three` **0.180.0**. CDN import maps pin the same: `https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.
|
|
169
|
+
`@displayxr/inline3d` **1.56.1**, `playcanvas` **2.24.0** (exact; `>=2.22.3 <3` is the supported
|
|
170
|
+
range), `three` **0.180.0**. CDN import maps pin the same: `https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.56.1/js/inline3d.js`,
|
|
148
171
|
`https://cdn.jsdelivr.net/npm/playcanvas@2.24.0/build/playcanvas.mjs`,
|
|
149
172
|
`https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js`. If a newer SDK is installed, its
|
|
150
173
|
`CHANGELOG.md` says what changed; prefer the installed version's docs over this list.
|
|
@@ -152,7 +175,7 @@ range), `three` **0.180.0**. CDN import maps pin the same: `https://cdn.jsdelivr
|
|
|
152
175
|
### 7. Before you say done: run the checker
|
|
153
176
|
|
|
154
177
|
```sh
|
|
155
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
178
|
+
npx -y @displayxr/inline3d-tools@0.1.3 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
|
|
156
179
|
```
|
|
157
180
|
|
|
158
181
|
This runs the exact-pinned `@displayxr/inline3d-tools` package from npm (the first run downloads it;
|
|
@@ -180,8 +203,8 @@ The templates ship in the exact-pinned `@displayxr/inline3d-tools` npm package;
|
|
|
180
203
|
command copies them (the first run downloads the package; the user may be asked to approve the command):
|
|
181
204
|
|
|
182
205
|
```sh
|
|
183
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
184
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
206
|
+
npx -y @displayxr/inline3d-tools@0.1.3 scaffold esm <target-dir> --title "<page title>"
|
|
207
|
+
npx -y @displayxr/inline3d-tools@0.1.3 scaffold vite <target-dir> --title "<page title>" [--name <npm-name>]
|
|
185
208
|
```
|
|
186
209
|
|
|
187
210
|
It never overwrites an existing file (`--force` replaces). What it writes:
|
|
@@ -191,7 +214,7 @@ It never overwrites an existing file (`--force` replaces). What it writes:
|
|
|
191
214
|
| `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
215
|
| `style.css` | page styles; the canvas and its ancestors carry no CSS effects |
|
|
193
216
|
| `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.
|
|
217
|
+
| `index.html` + `package.json` (vite) | Vite: exact npm pins (`@displayxr/inline3d` 1.56.1, `three` 0.180.0) |
|
|
195
218
|
|
|
196
219
|
### Steps
|
|
197
220
|
|
|
@@ -207,7 +230,10 @@ It never overwrites an existing file (`--force` replaces). What it writes:
|
|
|
207
230
|
```js
|
|
208
231
|
import { createInline3D } from '@displayxr/inline3d';
|
|
209
232
|
import { addModel } from '@displayxr/inline3d/model'; // or: import { addSplat } from '@displayxr/inline3d/splat/playcanvas';
|
|
210
|
-
const wall = await createInline3D().catch(() =>
|
|
233
|
+
const wall = await createInline3D().catch((err) => { // a rejection must not blank the page:
|
|
234
|
+
console.warn('inline 3D unavailable, showing 2D', err); // log it, then the viewer draws 2D
|
|
235
|
+
return null;
|
|
236
|
+
});
|
|
211
237
|
const handle = addModel(wall, canvas, './assets/model.glb'); // addSplat(wall, canvas, './scene.sog', { engine: 'playcanvas' })
|
|
212
238
|
// the page behind the tile shows around the subject: keep it a soft colour (or pass clearColor)
|
|
213
239
|
Promise.race([handle.firstWoven, new Promise((r) => setTimeout(r, 4000))]).finally(dropCover);
|
|
@@ -219,18 +245,19 @@ It never overwrites an existing file (`--force` replaces). What it writes:
|
|
|
219
245
|
without `player.firstWoven`, wait for the first frame and then ~1200 ms more.
|
|
220
246
|
|
|
221
247
|
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.
|
|
248
|
+
`"@displayxr/inline3d/model": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.56.1/js/inline3d-model-entry.js"`
|
|
223
249
|
(or `.../js/inline3d-splat-pc-entry.js` for `/splat/playcanvas`) to the import map, or
|
|
224
250
|
`"playcanvas": "2.24.0"` to `package.json`. Images and video use `wall.addImage(canvas, 'pic_2x1.jpg')`
|
|
225
251
|
/ `wall.addVideo(canvas, videoEl)` in the 3D branch and an `<img>` of the left half (or a mono
|
|
226
252
|
video) in the 2D branch. Check each export against the installed `.d.ts` before using it.
|
|
253
|
+
A camera-rig world or game: set its depth by the rule in "Building on @displayxr/inline3d" §2.
|
|
227
254
|
4. Run it: esm → serve the directory (`python3 -m http.server`), or let the checker
|
|
228
255
|
serve it; vite → `npm install && npm run dev`.
|
|
229
256
|
5. **Run the checker before saying done**, and fix every FAIL:
|
|
230
257
|
|
|
231
258
|
```sh
|
|
232
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
233
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
259
|
+
npx -y @displayxr/inline3d-tools@0.1.3 check <target-dir> # esm
|
|
260
|
+
npx -y @displayxr/inline3d-tools@0.1.3 check http://localhost:5173/ # vite dev server
|
|
234
261
|
```
|
|
235
262
|
|
|
236
263
|
The untouched template passes every check (verdict PASS). If your change makes a check fail, the
|
|
@@ -247,17 +274,17 @@ Tools, in the order to reach for them:
|
|
|
247
274
|
|
|
248
275
|
| Tool | When | Install |
|
|
249
276
|
|---|---|---|
|
|
250
|
-
| `inline3d-tools assets` | always, last | `npx -y @displayxr/inline3d-tools@0.1.
|
|
277
|
+
| `inline3d-tools assets` | always, last | `npx -y @displayxr/inline3d-tools@0.1.3 assets` (exact pin, from npm; Node only) |
|
|
251
278
|
| 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
279
|
| 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.
|
|
280
|
+
| `inline3d-tools gen` | no asset exists and the user wants one generated | `npx -y @displayxr/inline3d-tools@0.1.3 gen`; needs the user's own API key in the environment; every call is paid and needs the user's yes |
|
|
254
281
|
|
|
255
282
|
### 1. Get it
|
|
256
283
|
|
|
257
284
|
In order of preference:
|
|
258
285
|
|
|
259
286
|
1. **The user's own asset** (in the project, or a path they gave). Record it:
|
|
260
|
-
`npx -y @displayxr/inline3d-tools@0.1.
|
|
287
|
+
`npx -y @displayxr/inline3d-tools@0.1.3 gen provenance --file assets/x.glb --source "supplied by the user" --license "user's"`.
|
|
261
288
|
2. **A library asset with a clear licence** (CC0 / CC-BY, e.g. the Khronos glTF sample models,
|
|
262
289
|
Poly Haven). Record the URL, author and licence; CC-BY needs visible credit on the page.
|
|
263
290
|
3. **A placeholder you build** (primitives in three.js/PlayCanvas) when nothing fits and the user
|
|
@@ -287,7 +314,7 @@ fetches decoders from a CDN). Other fixes: `$GT simplify in.glb out.glb --ratio
|
|
|
287
314
|
**Anything else (Blender, if present).** Detect it, don't install it:
|
|
288
315
|
|
|
289
316
|
```sh
|
|
290
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
317
|
+
npx -y @displayxr/inline3d-tools@0.1.3 assets prep in.fbx out.glb [--metres 0.01] [--decimate 0.5] [--blender <path>]
|
|
291
318
|
```
|
|
292
319
|
|
|
293
320
|
It looks for Blender (`--blender`, `$BLENDER`, `PATH`, the default install location), never installs
|
|
@@ -303,8 +330,8 @@ helmet is ~0.3 m, not 2 m).
|
|
|
303
330
|
### 3. Check it (before the page uses it)
|
|
304
331
|
|
|
305
332
|
```sh
|
|
306
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
307
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
333
|
+
npx -y @displayxr/inline3d-tools@0.1.3 assets out.glb # tablet budget (default)
|
|
334
|
+
npx -y @displayxr/inline3d-tools@0.1.3 assets out.glb --target desktop
|
|
308
335
|
```
|
|
309
336
|
|
|
310
337
|
It reports: missing external files, decoders the page must provide, triangles (both eyes draw
|
|
@@ -318,7 +345,7 @@ animations. Fix every FAIL; act on WARNs or say why not. Then run the page check
|
|
|
318
345
|
### 4. Generate it (optional, paid, the user's keys)
|
|
319
346
|
|
|
320
347
|
```sh
|
|
321
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
348
|
+
npx -y @displayxr/inline3d-tools@0.1.3 gen providers # which adapters have a key (names only)
|
|
322
349
|
```
|
|
323
350
|
|
|
324
351
|
Adapters: `meshy` and `tripo` (text-to-3d, image-to-3d → GLB), `openai` (image → PNG, for
|
|
@@ -339,7 +366,7 @@ textures, posters and backdrops). Each reads its key from the environment (`MESH
|
|
|
339
366
|
shippable.
|
|
340
367
|
|
|
341
368
|
```sh
|
|
342
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
369
|
+
npx -y @displayxr/inline3d-tools@0.1.3 gen run meshy --kind text-to-3d --prompt "a brass desk lamp, PBR" --out assets/lamp-raw.glb --confirm-paid
|
|
343
370
|
```
|
|
344
371
|
|
|
345
372
|
### 5. ASSETS.md
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @displayxr/inline3d-tools
|
|
2
2
|
|
|
3
|
-
Tools for building
|
|
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.
|
|
12
|
+
npx -y @displayxr/inline3d-tools@0.1.3 <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.
|
|
50
|
+
claude mcp add inline3d-tools -- npx -y @displayxr/inline3d-tools@0.1.3 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.
|
|
60
|
+
"args": ["-y", "@displayxr/inline3d-tools@0.1.3", "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.
|
|
80
|
+
args = ["-y", "@displayxr/inline3d-tools@0.1.3", "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.
|
|
88
|
+
or `codex mcp add inline3d-tools -- npx -y @displayxr/inline3d-tools@0.1.3 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.
|
|
92
|
+
**Fetch the package once before the first Codex session:** `npx -y @displayxr/inline3d-tools@0.1.3 --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.
|
|
112
|
+
"args": ["-y", "@displayxr/inline3d-tools@0.1.3", "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.
|
|
154
|
+
npx -y @displayxr/inline3d-tools@0.1.3 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,14 +177,16 @@ 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 |
|
|
186
|
+
| `depth-underused` | too little depth is a failure too (a report, never a limit), 0.1.3. **Camera rig: measured** from the two eye images: the share of the Shibata comfort zone (0.65 m) the default view uses, on its binding side (`max(|p05| / front, p95 / behind)` of the block disparities, mm on the glass; `cameraRigComfortFactor` ≈ 1 / that share). Below 30 % is a WARN; a rig converged at infinity WARNs too. The hint gives the rule: convergence on the centre of interest, `metersToVirtual` = the true conversion or `convergence / 2` (no true scale), then `ipdFactor` ≈ 1 (open scene) or 0.8–1× `cameraRigComfortFactor` (bounded). **Display rig: from the rig** (its natural depth is the subject's real proportions, so the measured span is not judged): `ipdFactor` below 0.5 is a WARN (0 = 2D on purpose) | camera: approximate; display: real |
|
|
185
187
|
|
|
186
188
|
Also reported: the rig (display/camera and its fields) and, for a camera rig, the comfort number
|
|
187
|
-
`ipdFactor × metersToVirtual × convergenceDiopters × 0.65
|
|
189
|
+
`ipdFactor × metersToVirtual × convergenceDiopters × 0.65` (the divergence ceiling: keep ≤ 1).
|
|
188
190
|
|
|
189
191
|
**Blind spots.** It is not a panel: no weave, no real compositor join, no eye tracking, no crosstalk.
|
|
190
192
|
Views come from the most recently created layer, so a page with several tiles on different rigs is
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// inline3d-tools assets — is this glTF/GLB ready for an inline-3D page on a
|
|
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/analyze.mjs
CHANGED
|
@@ -194,7 +194,11 @@ export function flatWideVerdict(buf) {
|
|
|
194
194
|
const fwd = blockDisparity(L, R), back = blockDisparity(R, L);
|
|
195
195
|
const textured = fwd.textured + back.textured;
|
|
196
196
|
const matchRatio = textured ? (fwd.length + back.length) / textured : 1;
|
|
197
|
-
|
|
197
|
+
// A scene with real depth has no ONE shift that explains it (near and far content move apart),
|
|
198
|
+
// so strong local evidence on its own (most textured blocks of both halves matched) also counts.
|
|
199
|
+
const sameScene = cmp.identical
|
|
200
|
+
|| (cmp.madBest < Math.max(3, 0.35 * cmp.baseline) && (textured < 8 || matchRatio >= 0.35))
|
|
201
|
+
|| (textured >= 8 && matchRatio >= 0.6);
|
|
198
202
|
// The seam is evidence, not a gate: on a mostly uniform background the "typical" column step is
|
|
199
203
|
// ~0 and any content crossing the middle looks like a break. Two halves that no shift within
|
|
200
204
|
// ±12 % of the eye width explains are not a stereo pair a display could fuse either way.
|
|
@@ -242,3 +246,74 @@ export function regionDiff(A, B) {
|
|
|
242
246
|
for (let i = 0; i < a.length; i++) t += Math.abs(a[i] - b[i]);
|
|
243
247
|
return t / a.length;
|
|
244
248
|
}
|
|
249
|
+
|
|
250
|
+
/** depth-underused: a camera rig using less than this share of the comfort zone WARNs (= cameraRigComfortFactor above ~3.3). */
|
|
251
|
+
export const DEPTH_ZONE_USE_FLOOR = 0.3;
|
|
252
|
+
/** depth-underused: a display rig with ipdFactor below this (and above 0, which is 2D on purpose) WARNs. */
|
|
253
|
+
export const DISPLAY_IPD_UNDERUSED = 0.5;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Is the page using the depth the display can show? A report, never a limit.
|
|
257
|
+
*
|
|
258
|
+
* - Camera rig: MEASURED. `measured` = on-glass disparities (mm, signed, < 0 in front) of the
|
|
259
|
+
* textured blocks of the captured default view. Share of the zone used = the binding side,
|
|
260
|
+
* max(|p05| / zone.frontMm, p95 / zone.behindMm) (the side cameraRigComfortFactor binds on; its
|
|
261
|
+
* factor is 1 / this share). WARN below DEPTH_ZONE_USE_FLOOR: near-zero disparity is a defect.
|
|
262
|
+
* A rig converged at infinity WARNs from the rig alone.
|
|
263
|
+
* - Display rig: from the RIG. ipdFactor / parallaxFactor 1 are the natural depth (full roundness at
|
|
264
|
+
* real proportions), so a shallow measured span is not judged; ipdFactor below 0.5 WARNs.
|
|
265
|
+
* @returns {{status: 'pass'|'warn'|'skip', summary: string, hint?: string, details: object|null}}
|
|
266
|
+
*/
|
|
267
|
+
export function rigDepthUse(rig, measured, zone) {
|
|
268
|
+
if (rig === undefined) return { status: 'skip', summary: 'no woven layer: no view rig to read', details: null };
|
|
269
|
+
if (!rig || rig.type !== 'camera') {
|
|
270
|
+
const ipd = rig && typeof rig.ipdFactor === 'number' ? rig.ipdFactor : 1;
|
|
271
|
+
const details = { type: 'display', ipdFactor: ipd };
|
|
272
|
+
if (ipd === 0) return { status: 'pass', summary: 'display rig at ipdFactor 0: 2D on purpose', details };
|
|
273
|
+
if (ipd < DISPLAY_IPD_UNDERUSED) {
|
|
274
|
+
return {
|
|
275
|
+
status: 'warn',
|
|
276
|
+
summary: `display rig ipdFactor ${+ipd.toFixed(3)}: below ${DISPLAY_IPD_UNDERUSED}, the subject is drawn at under half its natural depth and reads flat`,
|
|
277
|
+
hint: 'On a display rig ipdFactor and parallaxFactor 1 are the natural depth (full roundness at real proportions): keep them at 1 unless you can name the reason. Too little depth is a failure too.',
|
|
278
|
+
details,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
return { status: 'pass', summary: `display rig at ipdFactor ${+ipd.toFixed(3)} (1 = natural depth)`, details };
|
|
282
|
+
}
|
|
283
|
+
const ipd = typeof rig.ipdFactor === 'number' ? rig.ipdFactor : 1;
|
|
284
|
+
const m2v = rig.metersToVirtual || 1;
|
|
285
|
+
const dio = typeof rig.convergenceDiopters === 'number' ? rig.convergenceDiopters : 0;
|
|
286
|
+
const details = { type: 'camera', ipdFactor: ipd, metersToVirtual: m2v, convergenceDiopters: dio };
|
|
287
|
+
if (ipd === 0) return { status: 'pass', summary: 'camera rig at ipdFactor 0: 2D on purpose', details };
|
|
288
|
+
if (!(dio > 0)) {
|
|
289
|
+
return {
|
|
290
|
+
status: 'warn',
|
|
291
|
+
summary: 'camera rig converged at infinity (convergenceDiopters 0): the whole scene sits in front of the glass',
|
|
292
|
+
hint: 'Converge on the centre of interest (convergence = its distance from the camera), so the subject straddles the glass; then metersToVirtual = the true conversion, or convergence / 2 for a world with no true scale, and ipdFactor ≈ 1 (more for a bounded scene, via cameraRigComfortFactor).',
|
|
293
|
+
details,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
if (!measured || measured.length < 8 || !zone) {
|
|
297
|
+
return { status: 'skip', summary: 'camera rig: too few textured blocks to measure its disparity', details };
|
|
298
|
+
}
|
|
299
|
+
const D = 1 / dio;
|
|
300
|
+
const front = Math.max(0, -quantile(measured, 0.05)), back = Math.max(0, quantile(measured, 0.95));
|
|
301
|
+
const use = Math.max(front / zone.frontMm, isFinite(zone.behindMm) ? back / zone.behindMm : 0);
|
|
302
|
+
const normM2v = D / 2; // rule 2: the centre of interest declared 2 real metres away
|
|
303
|
+
const normIpd = (ipd * m2v) / normM2v; // this rig's eye separation on that scale
|
|
304
|
+
Object.assign(details, {
|
|
305
|
+
zoneUsed: +use.toFixed(3), floor: DEPTH_ZONE_USE_FLOOR, frontMm: +front.toFixed(2), behindMm: +back.toFixed(2),
|
|
306
|
+
zoneMm: { front: +zone.frontMm.toFixed(1), behind: +zone.behindMm.toFixed(1) },
|
|
307
|
+
normalisedMetersToVirtual: +normM2v.toPrecision(3), ipdFactorOnThatScale: +normIpd.toPrecision(3),
|
|
308
|
+
fillMultiplier: use > 0 ? +(1 / use).toPrecision(3) : null,
|
|
309
|
+
});
|
|
310
|
+
if (use < DEPTH_ZONE_USE_FLOOR) {
|
|
311
|
+
return {
|
|
312
|
+
status: 'warn',
|
|
313
|
+
summary: `the scene uses ${Math.round(use * 100)}% of the comfort zone at the default view (measured: ${front.toFixed(1)} mm in front, ${back.toFixed(1)} mm behind the glass): it reads nearly flat`,
|
|
314
|
+
hint: `Camera-rig rule: (1) convergence = the distance to the centre of interest (here ${+D.toPrecision(3)}), so the subject straddles the glass; (2) never rescale the world, set metersToVirtual: the true conversion if the world has a true scale (metres 1, centimetres 100), else convergence / 2 = ${details.normalisedMetersToVirtual} (the subject declared 2 m away; this rig is ipdFactor ${details.ipdFactorOnThatScale} on that scale), re-set per frame if the camera zooms a lot; (3) ipdFactor tunes depth: ≈ 1 for an open scene, more for a bounded one (typically 1.5–2.5): 0.8–1× of cameraRigComfortFactor({ zNear, zFar, convergence, verticalFov, aspect, tileHeightM, viewerM, ipdFactor, metersToVirtual }) from @displayxr/inline3d/depth. Disparity scales with ipdFactor${details.fillMultiplier ? `: ×${details.fillMultiplier} would fill the zone here` : ''}. Keep parallaxFactor with it.`,
|
|
315
|
+
details,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
return { status: 'pass', summary: `the scene uses ${Math.round(use * 100)}% of the comfort zone at the default view (${front.toFixed(1)} mm in front, ${back.toFixed(1)} mm behind)`, details };
|
|
319
|
+
}
|
package/lib/check/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// inline3d-tools check — does this @displayxr/inline3d page really render
|
|
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/fake-env.js
CHANGED
|
@@ -422,6 +422,7 @@
|
|
|
422
422
|
ageMs: now() - r.createdAt,
|
|
423
423
|
init: r.init,
|
|
424
424
|
rig: r.layer.rig ? safeClone(r.layer.rig) : null,
|
|
425
|
+
firstRig: r.rigs.length ? r.rigs[0] : null, // the rig at the default view (before any user input)
|
|
425
426
|
rigPushes: r.rigPushes,
|
|
426
427
|
sameCanvasLiveAtCreate: r.sameCanvasLiveAtCreate,
|
|
427
428
|
coverAtCreate: r.coverAtCreate,
|
package/lib/check/run.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { launchChrome, withTimeout } from './cdp.mjs';
|
|
|
7
7
|
import { serveDir } from './server.mjs';
|
|
8
8
|
import { decodePng } from './png.mjs';
|
|
9
9
|
import {
|
|
10
|
-
crop, halves, contentStats, regionDiff, compareEyes, blockDisparity, quantile, flatWideVerdict, sbsPairVerdict, shibataZoneMm, fromBase64Rgba,
|
|
10
|
+
crop, halves, contentStats, regionDiff, compareEyes, blockDisparity, quantile, flatWideVerdict, sbsPairVerdict, shibataZoneMm, fromBase64Rgba, rigDepthUse,
|
|
11
11
|
} from './analyze.mjs';
|
|
12
12
|
|
|
13
13
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
@@ -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({
|
|
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
|
-
|
|
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(
|
|
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.
|
|
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 = [];
|
|
@@ -689,13 +742,15 @@ function buildChecks(fake, plain, opt) {
|
|
|
689
742
|
}
|
|
690
743
|
|
|
691
744
|
// depth / comfort (measured)
|
|
745
|
+
const zone = shibataZoneMm(0.65);
|
|
746
|
+
let measuredMm = null; // on-glass disparity per textured block of the primary canvas, mm, signed
|
|
692
747
|
{
|
|
693
748
|
let status = 'skip', summary = 'no stereo pair to measure';
|
|
694
749
|
let details = null;
|
|
695
|
-
const zone = shibataZoneMm(0.65);
|
|
696
750
|
if (primary && primary.px && primary.px.blocks.length >= 3 && primary.occlusion) {
|
|
697
751
|
const k = (primary.occlusion.rect.width / primary.px.eyeW) * MPP * 1000; // mm per eye px
|
|
698
752
|
const ds = primary.px.blocks.map((b) => b.d * k);
|
|
753
|
+
measuredMm = ds;
|
|
699
754
|
const p05 = quantile(ds, 0.05), p50 = quantile(ds, 0.5), p95 = quantile(ds, 0.95);
|
|
700
755
|
details = { frontMostMm: +p05.toFixed(2), medianMm: +p50.toFixed(2), backMostMm: +p95.toFixed(2), comfortZoneMm: { front: +zone.frontMm.toFixed(1), behind: +zone.behindMm.toFixed(1) }, blocks: ds.length, sign: '- = in front of the glass, + = behind' };
|
|
701
756
|
const warns = [];
|
|
@@ -708,6 +763,19 @@ function buildChecks(fake, plain, opt) {
|
|
|
708
763
|
}
|
|
709
764
|
checks.push(check('depth', '-', 'Depth sits on the glass and inside the comfort zone (measured, approximate)', status, summary, { details, approximate: true, doc: `${DOCS}/making-3d-look-right.md` }));
|
|
710
765
|
}
|
|
766
|
+
|
|
767
|
+
// depth used: too little depth is a failure too. A report, never a limit. Camera rig: the measured
|
|
768
|
+
// disparity of the captured (default, no-input) view against a floor; display rig: its ipdFactor.
|
|
769
|
+
{
|
|
770
|
+
const rig = primary ? (primary.firstRig !== undefined ? primary.firstRig : primary.rig) : undefined;
|
|
771
|
+
const r = rigDepthUse(rig, measuredMm, zone);
|
|
772
|
+
checks.push(check('depth-underused', '-', 'The scene uses the depth the display can show (camera rig: at least ~30% of the comfort zone, measured; display rig: ipdFactor near 1)', r.status, r.summary, {
|
|
773
|
+
details: r.details,
|
|
774
|
+
hint: r.hint,
|
|
775
|
+
approximate: !!(rig && rig.type === 'camera'),
|
|
776
|
+
doc: `${DOCS}/authoring-inline-3d.md#aim-for-real-depth`,
|
|
777
|
+
}));
|
|
778
|
+
}
|
|
711
779
|
return checks;
|
|
712
780
|
}
|
|
713
781
|
|
|
@@ -723,7 +791,7 @@ function rigInfo(fake) {
|
|
|
723
791
|
const m2v = rig.metersToVirtual || 1;
|
|
724
792
|
const dio = typeof rig.convergenceDiopters === 'number' ? rig.convergenceDiopters : 0;
|
|
725
793
|
out.comfort = +(ipd * m2v * dio * 0.65).toFixed(3);
|
|
726
|
-
out.comfortNote = 'ipdFactor x metersToVirtual x convergenceDiopters x 0.65 m (nominal viewer); keep <= 1';
|
|
794
|
+
out.comfortNote = 'ipdFactor x metersToVirtual x convergenceDiopters x 0.65 m (nominal viewer); the divergence ceiling, keep <= 1';
|
|
727
795
|
} else {
|
|
728
796
|
out.comfort = null;
|
|
729
797
|
out.comfortNote = 'display rig: ipdFactor/parallaxFactor are relative comfort dials in [0,1]';
|
|
@@ -805,7 +873,7 @@ export function formatHuman(r) {
|
|
|
805
873
|
if ((c.status === 'fail' || c.status === 'warn') && c.doc) lines.push(` see: ${c.doc}`);
|
|
806
874
|
}
|
|
807
875
|
const rig = r.info.rig;
|
|
808
|
-
lines.push(` rig: ${rig.type || 'n/a'}${rig.type === 'camera' ? `, comfort ${rig.comfort} (
|
|
876
|
+
lines.push(` rig: ${rig.type || 'n/a'}${rig.type === 'camera' ? `, comfort ${rig.comfort} (ceiling 1)` : ''}${rig.virtualDisplayHeight ? `, virtualDisplayHeight ${rig.virtualDisplayHeight}` : ''}`);
|
|
809
877
|
lines.push(` verdict: ${r.verdict.toUpperCase()} in ${(r.durationMs / 1000).toFixed(1)} s`);
|
|
810
878
|
return lines.join('\n');
|
|
811
879
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@displayxr/inline3d-tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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
|
-
"
|
|
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 = '
|
|
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');
|
package/templates/esm/index.html
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
{ "imports": {
|
|
11
11
|
"three": "https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js",
|
|
12
12
|
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.180.0/examples/jsm/",
|
|
13
|
-
"@displayxr/inline3d": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.
|
|
14
|
-
"@displayxr/inline3d/three": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.
|
|
13
|
+
"@displayxr/inline3d": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.56.1/js/inline3d.js",
|
|
14
|
+
"@displayxr/inline3d/three": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.56.1/js/inline3d-three.js"
|
|
15
15
|
} }
|
|
16
16
|
</script>
|
|
17
17
|
</head>
|