@tscircuit/3d-viewer 0.0.600 → 0.0.602

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.
Files changed (3) hide show
  1. package/README.md +100 -0
  2. package/dist/index.js +4443 -1963
  3. package/package.json +20 -7
package/README.md CHANGED
@@ -146,6 +146,106 @@ Each component has specific props for defining its characteristics and position
146
146
 
147
147
  ## Advanced Usage
148
148
 
149
+ ### Non-blocking renderer comparison diagnostics
150
+
151
+ The `Diagnostics/Renderer Parity` stories compare the actual viewer with
152
+ `circuit-json-to-gltf` using the same Circuit JSON and local model assets:
153
+
154
+ ```bash
155
+ bun run storybook:comparisons
156
+ ```
157
+
158
+ This opens `Diagnostics/Renderer Parity / X Rotation` directly instead of
159
+ restoring an unrelated story. The ordinary `bun run storybook` entry point is
160
+ unchanged.
161
+
162
+ Each comparison story automatically displays **both oblique and side geometry**
163
+ once its model geometry loads. Both panels remain visible, with the exact
164
+ unlit/no-texture PNGs, edge maps, red/cyan overlays, and metrics used by the
165
+ browser tests. There are no comparison buttons. Click an image to download its
166
+ full-resolution PNG. Bottom-layer fixtures use cameras below the PCB.
167
+
168
+ circuit-json-to-gltf is a development-only dependency. A Bun preparation step generates
169
+ GLBs and records circuit-json-to-gltf failures; it is not imported into the viewer's
170
+ production bundle or the browser story. Model files are local, not fetched from
171
+ ModelCDN during the tests.
172
+
173
+ `build-storybook` also prepares the fixture data, so the existing `vercel-build`
174
+ entry point publishes working comparison stories. Vercel hosts those static
175
+ stories; Playwright diagnostics run separately in GitHub Actions.
176
+
177
+ The browser suite has two separate roles:
178
+
179
+ ```bash
180
+ # Blocking tests of the matcher itself and deliberate browser mutations
181
+ bun test ./tests/geometry-edge-*.test.ts ./tests/renderer-diagnostic-result.test.ts ./tests/renderer-comparison-*.test.ts ./tests/renderer-usb-mounting.test.ts
182
+ bun run test:renderer-calibration
183
+
184
+ # Diagnostic comparisons: failures are reported but do not gate a completed run
185
+ bun run test:renderer-comparisons
186
+ bunx --no-install playwright show-report
187
+ ```
188
+
189
+ Install the test browser with `bunx playwright install chromium` if Playwright
190
+ reports that its Chromium executable is missing.
191
+
192
+ CI uses Ubuntu, Node 22, Bun 1.3.14 and the Chromium version paired with the
193
+ pinned Playwright dependency. `playwright install --with-deps chromium`
194
+ installs the Linux browser libraries; captures use software WebGL and require
195
+ no physical GPU. Playwright executes under Node even when launched by a Bun
196
+ package script.
197
+
198
+ A local Node 26 `module.register()` deprecation warning is not a test failure;
199
+ Node 22 is the CI runtime. Vite messages about missing dependency source maps
200
+ (for example `manifold-3d/lib/wasm.js.map`) concern debugger metadata, not a
201
+ missing JavaScript or WebAssembly module. A run ending in `passed` completed
202
+ successfully. Runtime/model-loading errors are still surfaced normally; the
203
+ harness does not blanket-suppress logs.
204
+
205
+ Actual comparisons are ordinary failing Playwright assertions, not skipped or
206
+ automatically approved baselines. The runner retains those failures and their
207
+ artifacts but returns success after a completed diagnostic report, making it
208
+ non-blocking for local gate runners too. Missing reports, global runner errors,
209
+ and interrupted runs still fail. For strict exit behavior, invoke
210
+ `bunx playwright test --project=diagnostics` directly.
211
+
212
+ The CI comparison step additionally has `continue-on-error: true`.
213
+ Dependency setup, matcher/runner unit tests, and browser calibration remain blocking.
214
+ The workflow always uploads the HTML report, geometry images, edge maps, diff
215
+ overlays, metadata, and failure traces.
216
+
217
+ The geometry pass isolates the studied CAD component, preserves its actual
218
+ world placement, and uses neutral unlit surfaces rather than textures/shadows.
219
+ The exported GLB receives only the fixed frame conversion back to project
220
+ coordinates: `P = (-G.x, G.z, G.y)`. Both sides use the same orthographic camera
221
+ and viewport. There is no recentering, image registration, or per-renderer fit.
222
+
223
+ The matcher checks edge coverage in both directions with a 1.5-pixel tolerance
224
+ and at most 1% unmatched edges on each side. It does not average differences
225
+ over the whole PCB image. Browser calibration requires identical geometry to
226
+ match and deliberate X-sign, rotation-order, and 0.2248885 mm origin errors to
227
+ be rejected. Pixel agreement is not a substitute for the existing numerical
228
+ placement tests, and it is not a test of material or normal appearance.
229
+ The calibration case has no exported GLB and compares viewer geometry only, so
230
+ browser-side exporter failures remain in the non-blocking diagnostic stage.
231
+ Diff overlays show unmatched viewer edges in red, unmatched exporter edges in
232
+ cyan, and covered edges in gray.
233
+
234
+ Cases keep rotation, origin inference, format dispatch, and the physical USB
235
+ mounting example separate. Explicit-origin zero/Z cases are controls; missing-origin
236
+ cases retain their original alignment tags. Generated output lives in ignored
237
+ directories, never committed PNG baselines. See
238
+ [`tests/fixtures/renderer-parity/README.md`](tests/fixtures/renderer-parity/README.md)
239
+ for source provenance and the common-board adaptation.
240
+
241
+ Nonzero angle probes use oblique values (for example X=37, Y=30, Z=47, and
242
+ mixed 23/31/47), not quarter turns that can conceal symmetry and axis mistakes.
243
+ Zero angles and the renderer's implicit bottom-layer fallback remain deliberate
244
+ controls. The physical USB mounting fixture is a documented exception: its
245
+ native Z-up mesh requires Z=270 degrees to fit the footprint. Actual tab/hole
246
+ and contact/pad geometry is checked separately. The original USB missing-origin
247
+ input remains a distinct diagnostic, not the mounted pose's zero-angle control.
248
+
149
249
  ### Custom Component Models
150
250
 
151
251
  You can define custom 3D models for components using the `cadModel` prop: