@displayxr/inline3d-tools 0.1.2 → 0.1.4
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 +65 -32
- package/README.md +11 -9
- package/lib/check/analyze.mjs +115 -1
- package/lib/check/fake-env.js +1 -0
- package/lib/check/probe.js +58 -0
- package/lib/check/run.mjs +36 -6
- package/package.json +1 -1
- package/templates/esm/index.html +2 -2
- package/templates/vite/package.template.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -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.4 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
|
|
19
|
+
npx -y @displayxr/inline3d-tools@0.1.4 assets <file.glb> [--target tablet|desktop]
|
|
20
|
+
npx -y @displayxr/inline3d-tools@0.1.4 assets prep <in> <out.glb> [--metres 0.01] [--decimate 0.5]
|
|
21
|
+
npx -y @displayxr/inline3d-tools@0.1.4 scaffold <esm|vite> <target-dir> --title "<page title>"
|
|
22
|
+
npx -y @displayxr/inline3d-tools@0.1.4 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,16 +70,46 @@ 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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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.
|
|
90
|
+
|
|
91
|
+
### 3. Depth and comfort (`docs/making-3d-look-right.md`, ten rules)
|
|
92
|
+
|
|
93
|
+
The subject straddles the glass (z = 0): about a quarter in front, the rest just behind, at real
|
|
94
|
+
proportions; don't push it back, shrink it or flatten it. `addModel` does this by default (SDK
|
|
95
|
+
1.57.0+): screen plane at the surface's 75th-percentile depth toward the viewer, pivot at the surface's
|
|
96
|
+
median, fit from trimmed extents, so a thin tail or antenna moves neither size nor depth; keep that
|
|
97
|
+
placement (`framing: 'box'` restores the old bounding-box centring, only for a reason you can name).
|
|
98
|
+
`addSplat` and `SceneViewer.fitTo(center, extent)` centre the subject's robust centre on the glass; a
|
|
99
|
+
scene you build yourself follows the same rule.
|
|
79
100
|
`+z` is OUT of the glass. Frame the whole subject in the first view. Tilt flat layouts 25–40° about an
|
|
80
101
|
axis through the glass. Keep moving things' forward swing small. Worlds: fixed convergence, keep the
|
|
81
102
|
camera clear of near geometry. Light/mid-tone low-contrast backgrounds (never pure black behind a
|
|
82
|
-
bright subject).
|
|
103
|
+
bright subject). **A backdrop sits behind the subject, never on the glass** (rule 10): a CSS image
|
|
104
|
+
behind a transparent canvas is on the glass and conflicts with any part of the subject behind it.
|
|
105
|
+
Draw a photo backdrop in the scene as ONE unlit plane fixed to the display, NOT to the subject (it
|
|
106
|
+
does not turn with the orbit or grow with the zoom; never parent it to the model. PlayCanvas: a child of
|
|
107
|
+
`handle.viewer.rigNode`; +z toward the viewer, one tile height = `viewer.vH`), behind the subject's
|
|
108
|
+
farthest point at any turn and the largest zoom you allow (cap the zoom so this holds), at about 40% of the rear comfort budget:
|
|
109
|
+
`backdropPlacement({ backH, tileHeightM })` from `@displayxr/inline3d/depth` returns its depth
|
|
110
|
+
(`depthH`) and size (`widthH` × `heightH`), tile heights. Pre-blurred, mid-tone; no skybox or
|
|
111
|
+
environment map as a backdrop. A plain colour or soft gradient needs none of this.
|
|
112
|
+
Text as HTML near the glass, not in the scene. No coplanar faces (z-fighting), no
|
|
83
113
|
sub-pixel detail. Scene units: metres for a `virtualDisplayHeight` (0.24 by default); never scale the
|
|
84
114
|
world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
|
|
85
115
|
|
|
@@ -107,8 +137,9 @@ world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
|
|
|
107
137
|
`woven-canvas-rules.md` §11).
|
|
108
138
|
- [ ] **What is behind a transparent tile is part of the picture.** `addSplat` / `addModel` clear
|
|
109
139
|
transparent by default, and the browser pre-blends the page under both eyes, flat, at half
|
|
110
|
-
horizontal resolution. Make that page area a soft light or mid-tone colour or gradient (no
|
|
111
|
-
text or photo behind a tile, never black behind a bright subject
|
|
140
|
+
horizontal resolution, on the glass. Make that page area a soft light or mid-tone colour or gradient (no
|
|
141
|
+
text or photo behind a tile, never black behind a bright subject; a photo backdrop goes IN the
|
|
142
|
+
scene, behind the subject: §3, rule 10), or pass an opaque
|
|
112
143
|
`clearColor: [r, g, b, 1]` (0..1).
|
|
113
144
|
- [ ] **`onLayerLost` goes flat** (`addScene` pages): pass `onLayerLost` and, in it, render ONE mono
|
|
114
145
|
camera across the whole canvas on your own rAF loop (the `!wall.supported` path) or show a 2D
|
|
@@ -151,8 +182,8 @@ world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
|
|
|
151
182
|
|
|
152
183
|
### 6. Pins (exact versions, no `^`)
|
|
153
184
|
|
|
154
|
-
`@displayxr/inline3d` **1.
|
|
155
|
-
range), `three` **0.180.0**. CDN import maps pin the same: `https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.
|
|
185
|
+
`@displayxr/inline3d` **1.57.1**, `playcanvas` **2.24.0** (exact; `>=2.22.3 <3` is the supported
|
|
186
|
+
range), `three` **0.180.0**. CDN import maps pin the same: `https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.57.1/js/inline3d.js`,
|
|
156
187
|
`https://cdn.jsdelivr.net/npm/playcanvas@2.24.0/build/playcanvas.mjs`,
|
|
157
188
|
`https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js`. If a newer SDK is installed, its
|
|
158
189
|
`CHANGELOG.md` says what changed; prefer the installed version's docs over this list.
|
|
@@ -160,7 +191,7 @@ range), `three` **0.180.0**. CDN import maps pin the same: `https://cdn.jsdelivr
|
|
|
160
191
|
### 7. Before you say done: run the checker
|
|
161
192
|
|
|
162
193
|
```sh
|
|
163
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
194
|
+
npx -y @displayxr/inline3d-tools@0.1.4 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
|
|
164
195
|
```
|
|
165
196
|
|
|
166
197
|
This runs the exact-pinned `@displayxr/inline3d-tools` package from npm (the first run downloads it;
|
|
@@ -188,8 +219,8 @@ The templates ship in the exact-pinned `@displayxr/inline3d-tools` npm package;
|
|
|
188
219
|
command copies them (the first run downloads the package; the user may be asked to approve the command):
|
|
189
220
|
|
|
190
221
|
```sh
|
|
191
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
192
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
222
|
+
npx -y @displayxr/inline3d-tools@0.1.4 scaffold esm <target-dir> --title "<page title>"
|
|
223
|
+
npx -y @displayxr/inline3d-tools@0.1.4 scaffold vite <target-dir> --title "<page title>" [--name <npm-name>]
|
|
193
224
|
```
|
|
194
225
|
|
|
195
226
|
It never overwrites an existing file (`--force` replaces). What it writes:
|
|
@@ -199,7 +230,7 @@ It never overwrites an existing file (`--force` replaces). What it writes:
|
|
|
199
230
|
| `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 |
|
|
200
231
|
| `style.css` | page styles; the canvas and its ancestors carry no CSS effects |
|
|
201
232
|
| `index.html` (esm) | no build step: an import map with exact CDN pins |
|
|
202
|
-
| `index.html` + `package.json` (vite) | Vite: exact npm pins (`@displayxr/inline3d` 1.
|
|
233
|
+
| `index.html` + `package.json` (vite) | Vite: exact npm pins (`@displayxr/inline3d` 1.57.1, `three` 0.180.0) |
|
|
203
234
|
|
|
204
235
|
### Steps
|
|
205
236
|
|
|
@@ -230,18 +261,19 @@ It never overwrites an existing file (`--force` replaces). What it writes:
|
|
|
230
261
|
without `player.firstWoven`, wait for the first frame and then ~1200 ms more.
|
|
231
262
|
|
|
232
263
|
Add `"playcanvas": "https://cdn.jsdelivr.net/npm/playcanvas@2.24.0/build/playcanvas.mjs"` and
|
|
233
|
-
`"@displayxr/inline3d/model": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.
|
|
264
|
+
`"@displayxr/inline3d/model": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.57.1/js/inline3d-model-entry.js"`
|
|
234
265
|
(or `.../js/inline3d-splat-pc-entry.js` for `/splat/playcanvas`) to the import map, or
|
|
235
266
|
`"playcanvas": "2.24.0"` to `package.json`. Images and video use `wall.addImage(canvas, 'pic_2x1.jpg')`
|
|
236
267
|
/ `wall.addVideo(canvas, videoEl)` in the 3D branch and an `<img>` of the left half (or a mono
|
|
237
268
|
video) in the 2D branch. Check each export against the installed `.d.ts` before using it.
|
|
269
|
+
A camera-rig world or game: set its depth by the rule in "Building on @displayxr/inline3d" §2.
|
|
238
270
|
4. Run it: esm → serve the directory (`python3 -m http.server`), or let the checker
|
|
239
271
|
serve it; vite → `npm install && npm run dev`.
|
|
240
272
|
5. **Run the checker before saying done**, and fix every FAIL:
|
|
241
273
|
|
|
242
274
|
```sh
|
|
243
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
244
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
275
|
+
npx -y @displayxr/inline3d-tools@0.1.4 check <target-dir> # esm
|
|
276
|
+
npx -y @displayxr/inline3d-tools@0.1.4 check http://localhost:5173/ # vite dev server
|
|
245
277
|
```
|
|
246
278
|
|
|
247
279
|
The untouched template passes every check (verdict PASS). If your change makes a check fail, the
|
|
@@ -258,17 +290,17 @@ Tools, in the order to reach for them:
|
|
|
258
290
|
|
|
259
291
|
| Tool | When | Install |
|
|
260
292
|
|---|---|---|
|
|
261
|
-
| `inline3d-tools assets` | always, last | `npx -y @displayxr/inline3d-tools@0.1.
|
|
293
|
+
| `inline3d-tools assets` | always, last | `npx -y @displayxr/inline3d-tools@0.1.4 assets` (exact pin, from npm; Node only) |
|
|
262
294
|
| 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) |
|
|
263
295
|
| Blender (headless) | any other format (FBX, OBJ, STL, PLY, DAE, .blend), units/axis fixes, heavy decimation | **only if already installed**; never install it |
|
|
264
|
-
| `inline3d-tools gen` | no asset exists and the user wants one generated | `npx -y @displayxr/inline3d-tools@0.1.
|
|
296
|
+
| `inline3d-tools gen` | no asset exists and the user wants one generated | `npx -y @displayxr/inline3d-tools@0.1.4 gen`; needs the user's own API key in the environment; every call is paid and needs the user's yes |
|
|
265
297
|
|
|
266
298
|
### 1. Get it
|
|
267
299
|
|
|
268
300
|
In order of preference:
|
|
269
301
|
|
|
270
302
|
1. **The user's own asset** (in the project, or a path they gave). Record it:
|
|
271
|
-
`npx -y @displayxr/inline3d-tools@0.1.
|
|
303
|
+
`npx -y @displayxr/inline3d-tools@0.1.4 gen provenance --file assets/x.glb --source "supplied by the user" --license "user's"`.
|
|
272
304
|
2. **A library asset with a clear licence** (CC0 / CC-BY, e.g. the Khronos glTF sample models,
|
|
273
305
|
Poly Haven). Record the URL, author and licence; CC-BY needs visible credit on the page.
|
|
274
306
|
3. **A placeholder you build** (primitives in three.js/PlayCanvas) when nothing fits and the user
|
|
@@ -298,7 +330,7 @@ fetches decoders from a CDN). Other fixes: `$GT simplify in.glb out.glb --ratio
|
|
|
298
330
|
**Anything else (Blender, if present).** Detect it, don't install it:
|
|
299
331
|
|
|
300
332
|
```sh
|
|
301
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
333
|
+
npx -y @displayxr/inline3d-tools@0.1.4 assets prep in.fbx out.glb [--metres 0.01] [--decimate 0.5] [--blender <path>]
|
|
302
334
|
```
|
|
303
335
|
|
|
304
336
|
It looks for Blender (`--blender`, `$BLENDER`, `PATH`, the default install location), never installs
|
|
@@ -307,15 +339,16 @@ metres (`--metres` = metres per source unit: 0.01 for centimetres), decimates, r
|
|
|
307
339
|
the glTF-Transform `optimize` line on its output (Blender writes PNG textures; WebP is far smaller).
|
|
308
340
|
No Blender: say the format cannot be converted here, and ask for a GLB.
|
|
309
341
|
|
|
310
|
-
Units: `addModel` frames the model on the glass from its
|
|
342
|
+
Units: `addModel` frames the model on the glass from its surface (screen plane at the 75th-percentile
|
|
343
|
+
depth, pivot at the median, fit from trimmed extents), so units, offset and a thin tail do not break
|
|
311
344
|
it; a model you place in your own `addScene` must be in **metres, centred** (its real size: a
|
|
312
345
|
helmet is ~0.3 m, not 2 m).
|
|
313
346
|
|
|
314
347
|
### 3. Check it (before the page uses it)
|
|
315
348
|
|
|
316
349
|
```sh
|
|
317
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
318
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
350
|
+
npx -y @displayxr/inline3d-tools@0.1.4 assets out.glb # tablet budget (default)
|
|
351
|
+
npx -y @displayxr/inline3d-tools@0.1.4 assets out.glb --target desktop
|
|
319
352
|
```
|
|
320
353
|
|
|
321
354
|
It reports: missing external files, decoders the page must provide, triangles (both eyes draw
|
|
@@ -329,7 +362,7 @@ animations. Fix every FAIL; act on WARNs or say why not. Then run the page check
|
|
|
329
362
|
### 4. Generate it (optional, paid, the user's keys)
|
|
330
363
|
|
|
331
364
|
```sh
|
|
332
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
365
|
+
npx -y @displayxr/inline3d-tools@0.1.4 gen providers # which adapters have a key (names only)
|
|
333
366
|
```
|
|
334
367
|
|
|
335
368
|
Adapters: `meshy` and `tripo` (text-to-3d, image-to-3d → GLB), `openai` (image → PNG, for
|
|
@@ -350,7 +383,7 @@ textures, posters and backdrops). Each reads its key from the environment (`MESH
|
|
|
350
383
|
shippable.
|
|
351
384
|
|
|
352
385
|
```sh
|
|
353
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
386
|
+
npx -y @displayxr/inline3d-tools@0.1.4 gen run meshy --kind text-to-3d --prompt "a brass desk lamp, PBR" --out assets/lamp-raw.glb --confirm-paid
|
|
354
387
|
```
|
|
355
388
|
|
|
356
389
|
### 5. ASSETS.md
|
package/README.md
CHANGED
|
@@ -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.4 <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.4 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.4", "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.4", "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.4 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.4 --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.4", "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.4 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
|
|
@@ -183,9 +183,11 @@ disparity, so the checker can measure depth in millimetres of screen disparity.
|
|
|
183
183
|
| `detection` | runtime `isSessionSupported('inline-3d')` calls; static scan of same-origin scripts for it and for UA sniffing next to "DisplayXR" | approximate |
|
|
184
184
|
| `pins` | import-map CDN URLs and `package.json` versions for the SDK, playcanvas and three are exact | approximate |
|
|
185
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 |
|
|
187
|
+
| `backdrop-on-glass` | rule 10, 0.1.4 (a report, never a limit). A picture the page draws under the woven canvas (a CSS `background-image` with a `url()`, an `<img>`, a `<video>`: found by walking the paint order below the canvas on a 9×6 grid) sits at the depth of the glass. WARN when at least 10% of the canvas has such a picture under it, at least 10% of the eye images is see-through, and the measured content reaches behind the glass (p95 of the block disparities past 10% of the rear comfort zone). The hint: draw the backdrop in the scene, behind the subject (`backdropPlacement()`), or bring the subject on or in front of the glass | approximate |
|
|
186
188
|
|
|
187
189
|
Also reported: the rig (display/camera and its fields) and, for a camera rig, the comfort number
|
|
188
|
-
`ipdFactor × metersToVirtual × convergenceDiopters × 0.65
|
|
190
|
+
`ipdFactor × metersToVirtual × convergenceDiopters × 0.65` (the divergence ceiling: keep ≤ 1).
|
|
189
191
|
|
|
190
192
|
**Blind spots.** It is not a panel: no weave, no real compositor join, no eye tracking, no crosstalk.
|
|
191
193
|
Views come from the most recently created layer, so a page with several tiles on different rigs is
|
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,113 @@ 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
|
+
}
|
|
320
|
+
|
|
321
|
+
/** backdrop-on-glass: the canvas counts as see-through when at least this share of an eye image is not opaque. */
|
|
322
|
+
export const BACKDROP_SEE_THROUGH = 0.1;
|
|
323
|
+
/** backdrop-on-glass: an image counts as "behind the canvas" when it shows under at least this share of it. */
|
|
324
|
+
export const BACKDROP_IMAGE_SHARE = 0.1;
|
|
325
|
+
/** backdrop-on-glass: content "extends behind the glass" past this share of the rear comfort zone (and 1 mm). */
|
|
326
|
+
export const BACKDROP_BEHIND_SHARE = 0.1;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Rule 10: a backdrop sits behind the subject, never on the glass. A picture the page draws under a
|
|
330
|
+
* see-through woven canvas (a CSS background-image, an <img> or a <video>) is at the depth of the
|
|
331
|
+
* glass, so any part of the subject that disparity puts behind the glass is drawn over a surface
|
|
332
|
+
* that is nearer than it. A report, never a limit.
|
|
333
|
+
* @param audit __dxrProbe.backdropAudit(): { total, imageFraction, sources: [{selector, kind, hits}] }
|
|
334
|
+
* @param seeThrough share of the eye images that is not opaque (0..1), or null when not captured
|
|
335
|
+
* @param measured on-glass disparities of the textured blocks, mm, signed (> 0 behind the glass)
|
|
336
|
+
* @param zone shibataZoneMm()
|
|
337
|
+
* @returns {{status: 'pass'|'warn'|'skip', summary: string, hint?: string, details: object|null}}
|
|
338
|
+
*/
|
|
339
|
+
export function backdropOnGlass(audit, seeThrough, measured, zone) {
|
|
340
|
+
if (!audit || !audit.total) return { status: 'skip', summary: 'no woven canvas on screen to look behind', details: null };
|
|
341
|
+
const src = audit.sources && audit.sources[0];
|
|
342
|
+
const details = { imageBehind: +audit.imageFraction.toFixed(3), sources: audit.sources || [], seeThrough: seeThrough == null ? null : +seeThrough.toFixed(3) };
|
|
343
|
+
if (audit.imageFraction < BACKDROP_IMAGE_SHARE || !src) return { status: 'pass', summary: 'no page image behind the woven canvas', details };
|
|
344
|
+
if (seeThrough == null) return { status: 'skip', summary: 'no eye images to tell whether the canvas is see-through', details };
|
|
345
|
+
if (seeThrough < BACKDROP_SEE_THROUGH) return { status: 'pass', summary: `${src.selector} is behind the canvas, but the canvas is opaque, so it does not show through`, details };
|
|
346
|
+
if (!measured || measured.length < 3 || !zone) return { status: 'skip', summary: 'a page image shows through the canvas, but too few textured blocks to measure where the content sits', details };
|
|
347
|
+
const back = Math.max(0, quantile(measured, 0.95));
|
|
348
|
+
const limit = Math.max(1, BACKDROP_BEHIND_SHARE * (isFinite(zone.behindMm) ? zone.behindMm : 25));
|
|
349
|
+
Object.assign(details, { behindMm: +back.toFixed(2), behindLimitMm: +limit.toFixed(2) });
|
|
350
|
+
if (back <= limit) return { status: 'pass', summary: `${src.selector} shows through the canvas, and the content stays on or in front of the glass (${back.toFixed(1)} mm behind)`, details };
|
|
351
|
+
const what = src.kind === 'css' ? 'a CSS background-image' : `a <${src.kind}>`;
|
|
352
|
+
return {
|
|
353
|
+
status: 'warn',
|
|
354
|
+
summary: `${what} (${src.selector}) shows through the woven canvas, so it sits on the glass, while the content reaches ${back.toFixed(1)} mm behind the glass: the backdrop is in front of the part of the subject it should be behind`,
|
|
355
|
+
hint: 'Rule 10: a backdrop sits behind the subject, never on the glass. Draw the picture in the scene instead: one unlit plane fixed to the display (PlayCanvas: a child of viewer.rigNode), behind the subject, at about 40% of the rear comfort budget; backdropPlacement() from @displayxr/inline3d/depth gives its depth and size. Or keep the page image and bring the whole subject on or in front of the glass.',
|
|
356
|
+
details,
|
|
357
|
+
};
|
|
358
|
+
}
|
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/probe.js
CHANGED
|
@@ -215,6 +215,64 @@
|
|
|
215
215
|
};
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
+
// Rule 10: what picture does the PAGE draw under the canvas? Hit-test a grid, start at the canvas
|
|
219
|
+
// and walk down the paint order to the first thing that fills the point: a CSS background-image
|
|
220
|
+
// (url), an <img>/<video>/<picture>, or an opaque colour (which ends the walk with no picture).
|
|
221
|
+
// A picture there is at the depth of the glass.
|
|
222
|
+
// Like occlusionAudit, it forces pointer-events on for the hit test, on purpose (a picture with
|
|
223
|
+
// pointer-events: none still paints); the rule is removed in `finally`, within the same task, so
|
|
224
|
+
// the page is never painted with it.
|
|
225
|
+
P.backdropAudit = function (canvas, cols = 9, rows = 6) {
|
|
226
|
+
const style = document.createElement('style');
|
|
227
|
+
style.textContent = '*{pointer-events:auto !important}';
|
|
228
|
+
document.documentElement.appendChild(style);
|
|
229
|
+
const r = canvas.getBoundingClientRect();
|
|
230
|
+
let total = 0, image = 0;
|
|
231
|
+
const sources = new Map();
|
|
232
|
+
const paints = (el) => {
|
|
233
|
+
const cs = getComputedStyle(el);
|
|
234
|
+
if (cs.visibility === 'hidden' || parseFloat(cs.opacity) < 0.05) return null;
|
|
235
|
+
const tag = el.tagName;
|
|
236
|
+
if (el !== canvas && (tag === 'IMG' || tag === 'VIDEO' || tag === 'PICTURE')) return tag.toLowerCase();
|
|
237
|
+
const bg = cs.backgroundImage || '';
|
|
238
|
+
if (/url\(/.test(bg)) return 'css';
|
|
239
|
+
if (el === canvas) return null; // its own background colour is under its pixels, not a picture
|
|
240
|
+
if (tag === 'CANVAS' || tag === 'IFRAME' || tag === 'svg' || bg !== 'none') return 'opaque';
|
|
241
|
+
const m = /rgba?\(([^)]+)\)/.exec(cs.backgroundColor || '');
|
|
242
|
+
if (!m) return null;
|
|
243
|
+
const parts = m[1].split(/[ ,/]+/).filter(Boolean).map(Number);
|
|
244
|
+
return (parts.length >= 4 ? parts[3] : 1) >= 0.9 ? 'opaque' : null;
|
|
245
|
+
};
|
|
246
|
+
try {
|
|
247
|
+
for (let j = 0; j < rows; j++) {
|
|
248
|
+
for (let i = 0; i < cols; i++) {
|
|
249
|
+
const x = r.left + ((i + 0.5) / cols) * r.width;
|
|
250
|
+
const y = r.top + ((j + 0.5) / rows) * r.height;
|
|
251
|
+
if (x < 0 || y < 0 || x >= innerWidth || y >= innerHeight) continue;
|
|
252
|
+
const list = document.elementsFromPoint(x, y);
|
|
253
|
+
const at = list.indexOf(canvas);
|
|
254
|
+
if (at < 0) continue;
|
|
255
|
+
total++;
|
|
256
|
+
for (let k = at; k < list.length; k++) {
|
|
257
|
+
const kind = paints(list[k]);
|
|
258
|
+
if (!kind) continue;
|
|
259
|
+
if (kind !== 'opaque') {
|
|
260
|
+
image++;
|
|
261
|
+
const s = selectorOf(list[k]) || list[k].tagName.toLowerCase();
|
|
262
|
+
const rec = sources.get(s) || { selector: s, kind, hits: 0 };
|
|
263
|
+
rec.hits++;
|
|
264
|
+
sources.set(s, rec);
|
|
265
|
+
}
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
} finally {
|
|
271
|
+
style.remove();
|
|
272
|
+
}
|
|
273
|
+
return { total, imageFraction: total ? image / total : 0, sources: [...sources.values()].sort((a, b) => b.hits - a.hits) };
|
|
274
|
+
};
|
|
275
|
+
|
|
218
276
|
// Media elements big enough to show a picture (for the "raw side-by-side shown flat" scan).
|
|
219
277
|
P.mediaElements = function (exclude = []) {
|
|
220
278
|
const out = [];
|
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, backdropOnGlass,
|
|
11
11
|
} from './analyze.mjs';
|
|
12
12
|
|
|
13
13
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
@@ -220,6 +220,7 @@ async function fakeRun(conn, url, opt, origin) {
|
|
|
220
220
|
const buffer = await ev(page, `__dxrProbe.bufferInfo(__dxrCheck.layerCanvas(${l.index}))`).catch(() => null);
|
|
221
221
|
const occlusion = await ev(page, `__dxrProbe.occlusionAudit(__dxrCheck.layerCanvas(${l.index}))`).catch(() => null);
|
|
222
222
|
const css = await ev(page, `__dxrProbe.cssAudit(__dxrCheck.layerCanvas(${l.index}))`).catch(() => null);
|
|
223
|
+
const backdrop = await ev(page, `__dxrProbe.backdropAudit(__dxrCheck.layerCanvas(${l.index}))`).catch(() => null);
|
|
223
224
|
const seen = cssSeen.get(l.index);
|
|
224
225
|
if (css && seen) {
|
|
225
226
|
for (const p of css.problems) seen.problems.set(`${p.element}|${p.prop}`, p);
|
|
@@ -229,7 +230,7 @@ async function fakeRun(conn, url, opt, origin) {
|
|
|
229
230
|
const cssAll = seen
|
|
230
231
|
? { problems: [...seen.problems.values()], decorations: [...seen.decorations], animations: [...seen.animations.values()] }
|
|
231
232
|
: css || { problems: [], decorations: [], animations: [] };
|
|
232
|
-
layers.push({ ...l, snap, snapTries, buffer, occlusion, css: cssAll });
|
|
233
|
+
layers.push({ ...l, snap, snapTries, buffer, occlusion, backdrop, css: cssAll });
|
|
233
234
|
}
|
|
234
235
|
const shaderErrors = await ev(page, '__dxrProbe.shaderErrors').catch(() => []);
|
|
235
236
|
const scrollY = await ev(page, 'window.scrollY').catch(() => 0);
|
|
@@ -742,25 +743,54 @@ function buildChecks(fake, plain, opt) {
|
|
|
742
743
|
}
|
|
743
744
|
|
|
744
745
|
// depth / comfort (measured)
|
|
746
|
+
const zone = shibataZoneMm(0.65);
|
|
747
|
+
let measuredMm = null; // on-glass disparity per textured block of the primary canvas, mm, signed
|
|
745
748
|
{
|
|
746
749
|
let status = 'skip', summary = 'no stereo pair to measure';
|
|
747
750
|
let details = null;
|
|
748
|
-
const zone = shibataZoneMm(0.65);
|
|
749
751
|
if (primary && primary.px && primary.px.blocks.length >= 3 && primary.occlusion) {
|
|
750
752
|
const k = (primary.occlusion.rect.width / primary.px.eyeW) * MPP * 1000; // mm per eye px
|
|
751
753
|
const ds = primary.px.blocks.map((b) => b.d * k);
|
|
754
|
+
measuredMm = ds;
|
|
752
755
|
const p05 = quantile(ds, 0.05), p50 = quantile(ds, 0.5), p95 = quantile(ds, 0.95);
|
|
753
756
|
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' };
|
|
754
757
|
const warns = [];
|
|
755
758
|
if (p05 < -zone.frontMm) warns.push(`pops out ${(-p05).toFixed(1)} mm (comfort zone ${zone.frontMm.toFixed(1)} mm in front)`);
|
|
756
759
|
if (p95 > zone.behindMm) warns.push(`recedes ${p95.toFixed(1)} mm (comfort zone ${zone.behindMm.toFixed(1)} mm behind)`);
|
|
757
760
|
const span = Math.max(1e-6, p95 - p05);
|
|
758
|
-
if (Math.abs(p50) > Math.max(1.5, 0.6 * span) && (p05 > 0 || p95 < 0)) warns.push(`the subject sits entirely ${p50 > 0 ? 'behind' : 'in front of'} the glass (median ${p50.toFixed(1)} mm):
|
|
761
|
+
if (Math.abs(p50) > Math.max(1.5, 0.6 * span) && (p05 > 0 || p95 < 0)) warns.push(`the subject sits entirely ${p50 > 0 ? 'behind' : 'in front of'} the glass (median ${p50.toFixed(1)} mm): put the glass through it (about a quarter in front, the rest just behind)`);
|
|
759
762
|
status = warns.length ? 'warn' : 'pass';
|
|
760
763
|
summary = warns.length ? warns.join('; ') : `screen disparity ${p05.toFixed(1)} … ${p95.toFixed(1)} mm (median ${p50.toFixed(1)}), inside the comfort zone`;
|
|
761
764
|
}
|
|
762
765
|
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` }));
|
|
763
766
|
}
|
|
767
|
+
|
|
768
|
+
// depth used: too little depth is a failure too. A report, never a limit. Camera rig: the measured
|
|
769
|
+
// disparity of the captured (default, no-input) view against a floor; display rig: its ipdFactor.
|
|
770
|
+
{
|
|
771
|
+
const rig = primary ? (primary.firstRig !== undefined ? primary.firstRig : primary.rig) : undefined;
|
|
772
|
+
const r = rigDepthUse(rig, measuredMm, zone);
|
|
773
|
+
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, {
|
|
774
|
+
details: r.details,
|
|
775
|
+
hint: r.hint,
|
|
776
|
+
approximate: !!(rig && rig.type === 'camera'),
|
|
777
|
+
doc: `${DOCS}/authoring-inline-3d.md#aim-for-real-depth`,
|
|
778
|
+
}));
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// backdrop on the glass (rule 10): a page image showing through a see-through canvas, under
|
|
782
|
+
// content that reaches behind the glass. A report, never a limit.
|
|
783
|
+
{
|
|
784
|
+
const px = primary && primary.px;
|
|
785
|
+
const seeThrough = px ? 1 - (px.statsL.opaqueFraction + px.statsR.opaqueFraction) / 2 : null;
|
|
786
|
+
const r = backdropOnGlass(primary ? primary.backdrop : null, seeThrough, measuredMm, zone);
|
|
787
|
+
checks.push(check('backdrop-on-glass', '-', 'A backdrop sits behind the subject, never on the glass (a page image under a see-through canvas is on the glass)', r.status, r.summary, {
|
|
788
|
+
details: r.details,
|
|
789
|
+
hint: r.hint,
|
|
790
|
+
approximate: true,
|
|
791
|
+
doc: `${DOCS}/making-3d-look-right.md`,
|
|
792
|
+
}));
|
|
793
|
+
}
|
|
764
794
|
return checks;
|
|
765
795
|
}
|
|
766
796
|
|
|
@@ -776,7 +806,7 @@ function rigInfo(fake) {
|
|
|
776
806
|
const m2v = rig.metersToVirtual || 1;
|
|
777
807
|
const dio = typeof rig.convergenceDiopters === 'number' ? rig.convergenceDiopters : 0;
|
|
778
808
|
out.comfort = +(ipd * m2v * dio * 0.65).toFixed(3);
|
|
779
|
-
out.comfortNote = 'ipdFactor x metersToVirtual x convergenceDiopters x 0.65 m (nominal viewer); keep <= 1';
|
|
809
|
+
out.comfortNote = 'ipdFactor x metersToVirtual x convergenceDiopters x 0.65 m (nominal viewer); the divergence ceiling, keep <= 1';
|
|
780
810
|
} else {
|
|
781
811
|
out.comfort = null;
|
|
782
812
|
out.comfortNote = 'display rig: ipdFactor/parallaxFactor are relative comfort dials in [0,1]';
|
|
@@ -858,7 +888,7 @@ export function formatHuman(r) {
|
|
|
858
888
|
if ((c.status === 'fail' || c.status === 'warn') && c.doc) lines.push(` see: ${c.doc}`);
|
|
859
889
|
}
|
|
860
890
|
const rig = r.info.rig;
|
|
861
|
-
lines.push(` rig: ${rig.type || 'n/a'}${rig.type === 'camera' ? `, comfort ${rig.comfort} (
|
|
891
|
+
lines.push(` rig: ${rig.type || 'n/a'}${rig.type === 'camera' ? `, comfort ${rig.comfort} (ceiling 1)` : ''}${rig.virtualDisplayHeight ? `, virtualDisplayHeight ${rig.virtualDisplayHeight}` : ''}`);
|
|
862
892
|
lines.push(` verdict: ${r.verdict.toUpperCase()} in ${(r.durationMs / 1000).toFixed(1)} s`);
|
|
863
893
|
return lines.join('\n');
|
|
864
894
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@displayxr/inline3d-tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
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": {
|
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.57.1/js/inline3d.js",
|
|
14
|
+
"@displayxr/inline3d/three": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.57.1/js/inline3d-three.js"
|
|
15
15
|
} }
|
|
16
16
|
</script>
|
|
17
17
|
</head>
|