@displayxr/inline3d-tools 0.1.3 → 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 +45 -28
- package/README.md +9 -8
- package/lib/check/analyze.mjs +39 -0
- package/lib/check/probe.js +58 -0
- package/lib/check/run.mjs +18 -3
- 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
|
|
@@ -88,13 +88,28 @@ three when the page already is a three.js app (`addScene` + `EyeCamera`, see
|
|
|
88
88
|
- Budgets are reports, not limits to stay far inside: never lower depth as the user zooms.
|
|
89
89
|
Details: `docs/authoring-inline-3d.md` § Aim for real depth.
|
|
90
90
|
|
|
91
|
-
### 3. Depth and comfort (`docs/making-3d-look-right.md`,
|
|
91
|
+
### 3. Depth and comfort (`docs/making-3d-look-right.md`, ten rules)
|
|
92
92
|
|
|
93
|
-
|
|
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.
|
|
94
100
|
`+z` is OUT of the glass. Frame the whole subject in the first view. Tilt flat layouts 25–40° about an
|
|
95
101
|
axis through the glass. Keep moving things' forward swing small. Worlds: fixed convergence, keep the
|
|
96
102
|
camera clear of near geometry. Light/mid-tone low-contrast backgrounds (never pure black behind a
|
|
97
|
-
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
|
|
98
113
|
sub-pixel detail. Scene units: metres for a `virtualDisplayHeight` (0.24 by default); never scale the
|
|
99
114
|
world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
|
|
100
115
|
|
|
@@ -122,8 +137,9 @@ world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
|
|
|
122
137
|
`woven-canvas-rules.md` §11).
|
|
123
138
|
- [ ] **What is behind a transparent tile is part of the picture.** `addSplat` / `addModel` clear
|
|
124
139
|
transparent by default, and the browser pre-blends the page under both eyes, flat, at half
|
|
125
|
-
horizontal resolution. Make that page area a soft light or mid-tone colour or gradient (no
|
|
126
|
-
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
|
|
127
143
|
`clearColor: [r, g, b, 1]` (0..1).
|
|
128
144
|
- [ ] **`onLayerLost` goes flat** (`addScene` pages): pass `onLayerLost` and, in it, render ONE mono
|
|
129
145
|
camera across the whole canvas on your own rAF loop (the `!wall.supported` path) or show a 2D
|
|
@@ -166,8 +182,8 @@ world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
|
|
|
166
182
|
|
|
167
183
|
### 6. Pins (exact versions, no `^`)
|
|
168
184
|
|
|
169
|
-
`@displayxr/inline3d` **1.
|
|
170
|
-
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`,
|
|
171
187
|
`https://cdn.jsdelivr.net/npm/playcanvas@2.24.0/build/playcanvas.mjs`,
|
|
172
188
|
`https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js`. If a newer SDK is installed, its
|
|
173
189
|
`CHANGELOG.md` says what changed; prefer the installed version's docs over this list.
|
|
@@ -175,7 +191,7 @@ range), `three` **0.180.0**. CDN import maps pin the same: `https://cdn.jsdelivr
|
|
|
175
191
|
### 7. Before you say done: run the checker
|
|
176
192
|
|
|
177
193
|
```sh
|
|
178
|
-
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]
|
|
179
195
|
```
|
|
180
196
|
|
|
181
197
|
This runs the exact-pinned `@displayxr/inline3d-tools` package from npm (the first run downloads it;
|
|
@@ -203,8 +219,8 @@ The templates ship in the exact-pinned `@displayxr/inline3d-tools` npm package;
|
|
|
203
219
|
command copies them (the first run downloads the package; the user may be asked to approve the command):
|
|
204
220
|
|
|
205
221
|
```sh
|
|
206
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
207
|
-
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>]
|
|
208
224
|
```
|
|
209
225
|
|
|
210
226
|
It never overwrites an existing file (`--force` replaces). What it writes:
|
|
@@ -214,7 +230,7 @@ It never overwrites an existing file (`--force` replaces). What it writes:
|
|
|
214
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 |
|
|
215
231
|
| `style.css` | page styles; the canvas and its ancestors carry no CSS effects |
|
|
216
232
|
| `index.html` (esm) | no build step: an import map with exact CDN pins |
|
|
217
|
-
| `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) |
|
|
218
234
|
|
|
219
235
|
### Steps
|
|
220
236
|
|
|
@@ -245,7 +261,7 @@ It never overwrites an existing file (`--force` replaces). What it writes:
|
|
|
245
261
|
without `player.firstWoven`, wait for the first frame and then ~1200 ms more.
|
|
246
262
|
|
|
247
263
|
Add `"playcanvas": "https://cdn.jsdelivr.net/npm/playcanvas@2.24.0/build/playcanvas.mjs"` and
|
|
248
|
-
`"@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"`
|
|
249
265
|
(or `.../js/inline3d-splat-pc-entry.js` for `/splat/playcanvas`) to the import map, or
|
|
250
266
|
`"playcanvas": "2.24.0"` to `package.json`. Images and video use `wall.addImage(canvas, 'pic_2x1.jpg')`
|
|
251
267
|
/ `wall.addVideo(canvas, videoEl)` in the 3D branch and an `<img>` of the left half (or a mono
|
|
@@ -256,8 +272,8 @@ It never overwrites an existing file (`--force` replaces). What it writes:
|
|
|
256
272
|
5. **Run the checker before saying done**, and fix every FAIL:
|
|
257
273
|
|
|
258
274
|
```sh
|
|
259
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
260
|
-
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
|
|
261
277
|
```
|
|
262
278
|
|
|
263
279
|
The untouched template passes every check (verdict PASS). If your change makes a check fail, the
|
|
@@ -274,17 +290,17 @@ Tools, in the order to reach for them:
|
|
|
274
290
|
|
|
275
291
|
| Tool | When | Install |
|
|
276
292
|
|---|---|---|
|
|
277
|
-
| `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) |
|
|
278
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) |
|
|
279
295
|
| Blender (headless) | any other format (FBX, OBJ, STL, PLY, DAE, .blend), units/axis fixes, heavy decimation | **only if already installed**; never install it |
|
|
280
|
-
| `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 |
|
|
281
297
|
|
|
282
298
|
### 1. Get it
|
|
283
299
|
|
|
284
300
|
In order of preference:
|
|
285
301
|
|
|
286
302
|
1. **The user's own asset** (in the project, or a path they gave). Record it:
|
|
287
|
-
`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"`.
|
|
288
304
|
2. **A library asset with a clear licence** (CC0 / CC-BY, e.g. the Khronos glTF sample models,
|
|
289
305
|
Poly Haven). Record the URL, author and licence; CC-BY needs visible credit on the page.
|
|
290
306
|
3. **A placeholder you build** (primitives in three.js/PlayCanvas) when nothing fits and the user
|
|
@@ -314,7 +330,7 @@ fetches decoders from a CDN). Other fixes: `$GT simplify in.glb out.glb --ratio
|
|
|
314
330
|
**Anything else (Blender, if present).** Detect it, don't install it:
|
|
315
331
|
|
|
316
332
|
```sh
|
|
317
|
-
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>]
|
|
318
334
|
```
|
|
319
335
|
|
|
320
336
|
It looks for Blender (`--blender`, `$BLENDER`, `PATH`, the default install location), never installs
|
|
@@ -323,15 +339,16 @@ metres (`--metres` = metres per source unit: 0.01 for centimetres), decimates, r
|
|
|
323
339
|
the glTF-Transform `optimize` line on its output (Blender writes PNG textures; WebP is far smaller).
|
|
324
340
|
No Blender: say the format cannot be converted here, and ask for a GLB.
|
|
325
341
|
|
|
326
|
-
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
|
|
327
344
|
it; a model you place in your own `addScene` must be in **metres, centred** (its real size: a
|
|
328
345
|
helmet is ~0.3 m, not 2 m).
|
|
329
346
|
|
|
330
347
|
### 3. Check it (before the page uses it)
|
|
331
348
|
|
|
332
349
|
```sh
|
|
333
|
-
npx -y @displayxr/inline3d-tools@0.1.
|
|
334
|
-
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
|
|
335
352
|
```
|
|
336
353
|
|
|
337
354
|
It reports: missing external files, decoders the page must provide, triangles (both eyes draw
|
|
@@ -345,7 +362,7 @@ animations. Fix every FAIL; act on WARNs or say why not. Then run the page check
|
|
|
345
362
|
### 4. Generate it (optional, paid, the user's keys)
|
|
346
363
|
|
|
347
364
|
```sh
|
|
348
|
-
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)
|
|
349
366
|
```
|
|
350
367
|
|
|
351
368
|
Adapters: `meshy` and `tripo` (text-to-3d, image-to-3d → GLB), `openai` (image → PNG, for
|
|
@@ -366,7 +383,7 @@ textures, posters and backdrops). Each reads its key from the environment (`MESH
|
|
|
366
383
|
shippable.
|
|
367
384
|
|
|
368
385
|
```sh
|
|
369
|
-
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
|
|
370
387
|
```
|
|
371
388
|
|
|
372
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
|
|
@@ -184,6 +184,7 @@ disparity, so the checker can measure depth in millimetres of screen disparity.
|
|
|
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
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 |
|
|
187
188
|
|
|
188
189
|
Also reported: the rig (display/camera and its fields) and, for a camera rig, the comfort number
|
|
189
190
|
`ipdFactor × metersToVirtual × convergenceDiopters × 0.65` (the divergence ceiling: keep ≤ 1).
|
package/lib/check/analyze.mjs
CHANGED
|
@@ -317,3 +317,42 @@ export function rigDepthUse(rig, measured, zone) {
|
|
|
317
317
|
}
|
|
318
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
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/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, rigDepthUse,
|
|
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);
|
|
@@ -757,7 +758,7 @@ function buildChecks(fake, plain, opt) {
|
|
|
757
758
|
if (p05 < -zone.frontMm) warns.push(`pops out ${(-p05).toFixed(1)} mm (comfort zone ${zone.frontMm.toFixed(1)} mm in front)`);
|
|
758
759
|
if (p95 > zone.behindMm) warns.push(`recedes ${p95.toFixed(1)} mm (comfort zone ${zone.behindMm.toFixed(1)} mm behind)`);
|
|
759
760
|
const span = Math.max(1e-6, p95 - p05);
|
|
760
|
-
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)`);
|
|
761
762
|
status = warns.length ? 'warn' : 'pass';
|
|
762
763
|
summary = warns.length ? warns.join('; ') : `screen disparity ${p05.toFixed(1)} … ${p95.toFixed(1)} mm (median ${p50.toFixed(1)}), inside the comfort zone`;
|
|
763
764
|
}
|
|
@@ -776,6 +777,20 @@ function buildChecks(fake, plain, opt) {
|
|
|
776
777
|
doc: `${DOCS}/authoring-inline-3d.md#aim-for-real-depth`,
|
|
777
778
|
}));
|
|
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
|
+
}
|
|
779
794
|
return checks;
|
|
780
795
|
}
|
|
781
796
|
|
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>
|