@displayxr/inline3d-tools 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -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.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 ...
18
+ npx -y @displayxr/inline3d-tools@0.1.6 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
19
+ npx -y @displayxr/inline3d-tools@0.1.6 assets <file.glb> [--target tablet|desktop]
20
+ npx -y @displayxr/inline3d-tools@0.1.6 assets prep <in> <out.glb> [--metres 0.01] [--decimate 0.5]
21
+ npx -y @displayxr/inline3d-tools@0.1.6 scaffold <esm|vite> <target-dir> --title "<page title>"
22
+ npx -y @displayxr/inline3d-tools@0.1.6 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
@@ -147,8 +147,15 @@ world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
147
147
  `onLayerLost: viewer.onLayerLost`; `addSplat` / `addModel` / `addPlayer` handle it themselves.
148
148
  - [ ] **Nothing opaque above the canvas**; backgrounds and black go *under* it. Never overlap two
149
149
  woven canvases (hide the lower one with `display: none`).
150
- - [ ] **Buffer = 2 × eye width**: `addScene` pages size it themselves (2× the box aspect, devicePixelRatio
151
- ≤ 2, every side ≤ 4096 for tablets) and draw into `gl.drawingBufferWidth/Height`. three.js:
150
+ - [ ] **Buffer = 2 × eye width, from `sceneBufferSize`** (core, 1.58.0+): an `addScene` page sizes its
151
+ canvas with `sceneBufferSize(canvas, { sbs, viewScale: sbs ? await handle.getDisplayInfo() : null })` (set
152
+ `canvas.width/height`, or `renderer.setSize(s.width, s.height, false)`, only when they change;
153
+ camera aspect from `s.eyeWidth / s.eyeHeight`), never `clientWidth × devicePixelRatio × 2`. Per eye
154
+ it is window device px × the runtime's view scale (dpr ≤ 2 without one), fitted to the GL limits
155
+ and the browser's drawing-buffer area cap. Hand-rolled on an 8K panel at 300% it asks for
156
+ 15360×4320; the browser silently shrinks the buffer, the eyes land off-centre and one eye shows
157
+ both images. The SDK's `the browser clamped this canvas's drawing buffer` warning is that bug.
158
+ Draw into `gl.drawingBufferWidth/Height`. three.js:
152
159
  `renderer.setPixelRatio(1)` when you use `getViewport()`.
153
160
  - [ ] **Validate before you clear**: skip the clear when `views.length < 2` or a viewport is `null`;
154
161
  repaint the last good frame. Copy `XRViewport` / `XRView` fields by name (their fields are
@@ -182,8 +189,8 @@ world per frame. Shrinking depth: rotate or scale uniformly, never squash z.
182
189
 
183
190
  ### 6. Pins (exact versions, no `^`)
184
191
 
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`,
192
+ `@displayxr/inline3d` **1.58.1**, `playcanvas` **2.24.0** (exact; `>=2.22.3 <3` is the supported
193
+ range), `three` **0.180.0**. CDN import maps pin the same: `https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.58.1/js/inline3d.js`,
187
194
  `https://cdn.jsdelivr.net/npm/playcanvas@2.24.0/build/playcanvas.mjs`,
188
195
  `https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js`. If a newer SDK is installed, its
189
196
  `CHANGELOG.md` says what changed; prefer the installed version's docs over this list.
@@ -191,7 +198,7 @@ range), `three` **0.180.0**. CDN import maps pin the same: `https://cdn.jsdelivr
191
198
  ### 7. Before you say done: run the checker
192
199
 
193
200
  ```sh
194
- npx -y @displayxr/inline3d-tools@0.1.4 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
201
+ npx -y @displayxr/inline3d-tools@0.1.6 check <url | dir | page.html> [--root <project>] [--max-texture 4096]
195
202
  ```
196
203
 
197
204
  This runs the exact-pinned `@displayxr/inline3d-tools` package from npm (the first run downloads it;
@@ -219,8 +226,8 @@ The templates ship in the exact-pinned `@displayxr/inline3d-tools` npm package;
219
226
  command copies them (the first run downloads the package; the user may be asked to approve the command):
220
227
 
221
228
  ```sh
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>]
229
+ npx -y @displayxr/inline3d-tools@0.1.6 scaffold esm <target-dir> --title "<page title>"
230
+ npx -y @displayxr/inline3d-tools@0.1.6 scaffold vite <target-dir> --title "<page title>" [--name <npm-name>]
224
231
  ```
225
232
 
226
233
  It never overwrites an existing file (`--force` replaces). What it writes:
@@ -230,7 +237,7 @@ It never overwrites an existing file (`--force` replaces). What it writes:
230
237
  | `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 |
231
238
  | `style.css` | page styles; the canvas and its ancestors carry no CSS effects |
232
239
  | `index.html` (esm) | no build step: an import map with exact CDN pins |
233
- | `index.html` + `package.json` (vite) | Vite: exact npm pins (`@displayxr/inline3d` 1.57.1, `three` 0.180.0) |
240
+ | `index.html` + `package.json` (vite) | Vite: exact npm pins (`@displayxr/inline3d` 1.58.1, `three` 0.180.0) |
234
241
 
235
242
  ### Steps
236
243
 
@@ -261,7 +268,7 @@ It never overwrites an existing file (`--force` replaces). What it writes:
261
268
  without `player.firstWoven`, wait for the first frame and then ~1200 ms more.
262
269
 
263
270
  Add `"playcanvas": "https://cdn.jsdelivr.net/npm/playcanvas@2.24.0/build/playcanvas.mjs"` and
264
- `"@displayxr/inline3d/model": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.57.1/js/inline3d-model-entry.js"`
271
+ `"@displayxr/inline3d/model": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.58.1/js/inline3d-model-entry.js"`
265
272
  (or `.../js/inline3d-splat-pc-entry.js` for `/splat/playcanvas`) to the import map, or
266
273
  `"playcanvas": "2.24.0"` to `package.json`. Images and video use `wall.addImage(canvas, 'pic_2x1.jpg')`
267
274
  / `wall.addVideo(canvas, videoEl)` in the 3D branch and an `<img>` of the left half (or a mono
@@ -272,8 +279,8 @@ It never overwrites an existing file (`--force` replaces). What it writes:
272
279
  5. **Run the checker before saying done**, and fix every FAIL:
273
280
 
274
281
  ```sh
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
282
+ npx -y @displayxr/inline3d-tools@0.1.6 check <target-dir> # esm
283
+ npx -y @displayxr/inline3d-tools@0.1.6 check http://localhost:5173/ # vite dev server
277
284
  ```
278
285
 
279
286
  The untouched template passes every check (verdict PASS). If your change makes a check fail, the
@@ -290,17 +297,17 @@ Tools, in the order to reach for them:
290
297
 
291
298
  | Tool | When | Install |
292
299
  |---|---|---|
293
- | `inline3d-tools assets` | always, last | `npx -y @displayxr/inline3d-tools@0.1.4 assets` (exact pin, from npm; Node only) |
300
+ | `inline3d-tools assets` | always, last | `npx -y @displayxr/inline3d-tools@0.1.6 assets` (exact pin, from npm; Node only) |
294
301
  | 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) |
295
302
  | Blender (headless) | any other format (FBX, OBJ, STL, PLY, DAE, .blend), units/axis fixes, heavy decimation | **only if already installed**; never install it |
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 |
303
+ | `inline3d-tools gen` | no asset exists and the user wants one generated | `npx -y @displayxr/inline3d-tools@0.1.6 gen`; needs the user's own API key in the environment; every call is paid and needs the user's yes |
297
304
 
298
305
  ### 1. Get it
299
306
 
300
307
  In order of preference:
301
308
 
302
309
  1. **The user's own asset** (in the project, or a path they gave). Record it:
303
- `npx -y @displayxr/inline3d-tools@0.1.4 gen provenance --file assets/x.glb --source "supplied by the user" --license "user's"`.
310
+ `npx -y @displayxr/inline3d-tools@0.1.6 gen provenance --file assets/x.glb --source "supplied by the user" --license "user's"`.
304
311
  2. **A library asset with a clear licence** (CC0 / CC-BY, e.g. the Khronos glTF sample models,
305
312
  Poly Haven). Record the URL, author and licence; CC-BY needs visible credit on the page.
306
313
  3. **A placeholder you build** (primitives in three.js/PlayCanvas) when nothing fits and the user
@@ -330,7 +337,7 @@ fetches decoders from a CDN). Other fixes: `$GT simplify in.glb out.glb --ratio
330
337
  **Anything else (Blender, if present).** Detect it, don't install it:
331
338
 
332
339
  ```sh
333
- npx -y @displayxr/inline3d-tools@0.1.4 assets prep in.fbx out.glb [--metres 0.01] [--decimate 0.5] [--blender <path>]
340
+ npx -y @displayxr/inline3d-tools@0.1.6 assets prep in.fbx out.glb [--metres 0.01] [--decimate 0.5] [--blender <path>]
334
341
  ```
335
342
 
336
343
  It looks for Blender (`--blender`, `$BLENDER`, `PATH`, the default install location), never installs
@@ -347,8 +354,8 @@ helmet is ~0.3 m, not 2 m).
347
354
  ### 3. Check it (before the page uses it)
348
355
 
349
356
  ```sh
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
357
+ npx -y @displayxr/inline3d-tools@0.1.6 assets out.glb # tablet budget (default)
358
+ npx -y @displayxr/inline3d-tools@0.1.6 assets out.glb --target desktop
352
359
  ```
353
360
 
354
361
  It reports: missing external files, decoders the page must provide, triangles (both eyes draw
@@ -362,7 +369,7 @@ animations. Fix every FAIL; act on WARNs or say why not. Then run the page check
362
369
  ### 4. Generate it (optional, paid, the user's keys)
363
370
 
364
371
  ```sh
365
- npx -y @displayxr/inline3d-tools@0.1.4 gen providers # which adapters have a key (names only)
372
+ npx -y @displayxr/inline3d-tools@0.1.6 gen providers # which adapters have a key (names only)
366
373
  ```
367
374
 
368
375
  Adapters: `meshy` and `tripo` (text-to-3d, image-to-3d → GLB), `openai` (image → PNG, for
@@ -383,7 +390,7 @@ textures, posters and backdrops). Each reads its key from the environment (`MESH
383
390
  shippable.
384
391
 
385
392
  ```sh
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
393
+ npx -y @displayxr/inline3d-tools@0.1.6 gen run meshy --kind text-to-3d --prompt "a brass desk lamp, PBR" --out assets/lamp-raw.glb --confirm-paid
387
394
  ```
388
395
 
389
396
  ### 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.4 <command> ...
12
+ npx -y @displayxr/inline3d-tools@0.1.6 <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.4 mcp
50
+ claude mcp add inline3d-tools -- npx -y @displayxr/inline3d-tools@0.1.6 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.4", "mcp"]
60
+ "args": ["-y", "@displayxr/inline3d-tools@0.1.6", "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.4", "mcp"]
80
+ args = ["-y", "@displayxr/inline3d-tools@0.1.6", "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.4 mcp`. The
88
+ or `codex mcp add inline3d-tools -- npx -y @displayxr/inline3d-tools@0.1.6 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.4 --version`.
92
+ **Fetch the package once before the first Codex session:** `npx -y @displayxr/inline3d-tools@0.1.6 --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.4", "mcp"]
112
+ "args": ["-y", "@displayxr/inline3d-tools@0.1.6", "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.4 check <url | dir | page.html> [--root <dir>] [--max-texture 4096] [--json] [--out report.json]
154
+ npx -y @displayxr/inline3d-tools@0.1.6 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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@displayxr/inline3d-tools",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
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/app.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // Display rig (the user turns a SUBJECT). Scene units are metres for a 0.24 m virtual display;
3
3
  // the subject straddles z = 0 (the glass). Replace buildScene() with your content.
4
4
  import * as THREE from 'three';
5
- import { createInline3D } from '@displayxr/inline3d';
5
+ import { createInline3D, sceneBufferSize } from '@displayxr/inline3d';
6
6
  import { EyeCamera } from '@displayxr/inline3d/three';
7
7
 
8
8
  const VIRTUAL_DISPLAY_HEIGHT = 0.24; // metres of virtual display the canvas shows
@@ -52,21 +52,19 @@ function animate(now) {
52
52
  subject.rotation.x = 0.35;
53
53
  }
54
54
 
55
- // ---- backing store: 2 x the box in 3D, 1 x in 2D; dpr <= 2; within the GPU's limits ---------
55
+ // ---- backing store: sceneBufferSize, never clientWidth x devicePixelRatio x 2 ----------------
56
+ // Per eye it gives window device px x the runtime's recommended view scale (once getDisplayInfo()
57
+ // has answered; devicePixelRatio <= 2 until then), fitted to the GL limits and the browser's
58
+ // drawing-buffer area cap. The view scale is the 3D mode's: never pass it for the flat 2D store.
59
+ // A hand-rolled store overflows that cap on a big panel: the browser
60
+ // shrinks the buffer silently, the eyes land off-centre and one eye shows both images.
61
+ let viewInfo = null;
56
62
  function sizeBuffer(stereo) {
57
- const r = canvas.getBoundingClientRect();
58
- const dpr = Math.min(window.devicePixelRatio || 1, 2);
59
- let w = Math.round(r.width * dpr * (stereo ? 2 : 1));
60
- let h = Math.round(r.height * dpr);
61
- const gl = renderer.getContext();
62
- const max = Math.min(gl.getParameter(gl.MAX_TEXTURE_SIZE), gl.getParameter(gl.MAX_RENDERBUFFER_SIZE), ...gl.getParameter(gl.MAX_VIEWPORT_DIMS));
63
- const k = Math.min(1, max / Math.max(w, h)); // one factor for both axes keeps the eyes' shape
64
- w = Math.max(2, Math.floor(w * k) & ~1);
65
- h = Math.max(1, Math.floor(h * k));
63
+ const s = sceneBufferSize(canvas, { sbs: stereo, viewScale: stereo ? viewInfo : null, gl: renderer.getContext() });
66
64
  // Writing width/height clears the buffer even when the value is the same: only on a change.
67
- if (canvas.width !== w || canvas.height !== h) {
68
- canvas.width = w;
69
- canvas.height = h;
65
+ if (canvas.width !== s.width || canvas.height !== s.height) {
66
+ canvas.width = s.width;
67
+ canvas.height = s.height;
70
68
  return true;
71
69
  }
72
70
  return false;
@@ -140,6 +138,10 @@ async function start() {
140
138
  onLayerLost: () => start2D('3D layer lost'),
141
139
  });
142
140
  statusEl.textContent = '3D on a Spatial Display';
141
+ handle.getDisplayInfo().then((info) => {
142
+ viewInfo = info;
143
+ if (sizeBuffer(true) && haveLast) drawEyes(lastGood);
144
+ }).catch(() => {});
143
145
  addEventListener('pagehide', () => wall.close());
144
146
  const result = await handle.firstWoven; // never rejects
145
147
  clearTimeout(coverTimer);
@@ -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.57.1/js/inline3d.js",
14
- "@displayxr/inline3d/three": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.57.1/js/inline3d-three.js"
13
+ "@displayxr/inline3d": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.58.1/js/inline3d.js",
14
+ "@displayxr/inline3d/three": "https://cdn.jsdelivr.net/npm/@displayxr/inline3d@1.58.1/js/inline3d-three.js"
15
15
  } }
16
16
  </script>
17
17
  </head>
@@ -9,7 +9,7 @@
9
9
  "preview": "vite preview"
10
10
  },
11
11
  "dependencies": {
12
- "@displayxr/inline3d": "1.57.1",
12
+ "@displayxr/inline3d": "1.58.1",
13
13
  "three": "0.180.0"
14
14
  },
15
15
  "devDependencies": {