@tscircuit/3d-viewer 0.0.636 → 0.0.637

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/README.md CHANGED
@@ -349,3 +349,79 @@ and `pcb_component_id` (when available). These support name tooltips, hiding
349
349
  individual components, and `onViewSchematicComponent` without supplying Circuit
350
350
  JSON. Existing GLBs without metadata still render. Board layers, folding, and
351
351
  model appearance are baked into the GLB; regenerate it to change them.
352
+
353
+ ### Assembly explosion views
354
+
355
+ Right-click the viewer and select **Advanced → Exploded view…** to open the
356
+ built-in slider. Drag through ordered stages and sequential moves; **Reset** or
357
+ closing the panel restores the assembled view. Both Manifold and JSCAD apply
358
+ translations in place and show dashed movement guides.
359
+
360
+ Pass ordinary Circuit JSON containing `cad_explosion_stage` and
361
+ `cad_explosion_move` records:
362
+
363
+ ```tsx
364
+ ;<CadViewer circuitJson={assembledCircuitJson} />
365
+ ```
366
+
367
+ The document contains assembled geometry and the complete explosion program.
368
+ No second pose, live TSX tree or external selector is needed. The viewer consumes
369
+ explicit stage membership, typed movement targets, resolved order and world-space
370
+ translation vectors. A movement may target an entire explosion stage: all of its
371
+ members move together, preserving their earlier relative displacement. Overlapping
372
+ targets move once per instruction; separate instructions accumulate.
373
+
374
+ Generate the document from TSX with core, then pass it to the viewer:
375
+
376
+ ```tsx
377
+ import { Circuit, assembly } from "@tscircuit/core"
378
+ import { CadViewer } from "@tscircuit/3d-viewer"
379
+
380
+ const circuit = new Circuit()
381
+ circuit.add(
382
+ <assembly.device name="case">
383
+ <assembly.part name="lid" cadModel={{ jscad: { type: "cube", size: 8 } }} />
384
+ <assembly.explosion.stage name="lift">
385
+ <assembly.explosion.move targetRef="lid" offZ="20mm" />
386
+ </assembly.explosion.stage>
387
+ <assembly.explosion.stage name="park" prevStageRef="lift">
388
+ <assembly.explosion.move targetRef="lift" offX="15mm" />
389
+ </assembly.explosion.stage>
390
+ </assembly.device>,
391
+ )
392
+ await circuit.renderUntilSettled()
393
+ const assembledCircuitJson = circuit.getCircuitJson()
394
+
395
+ ;<CadViewer circuitJson={assembledCircuitJson} />
396
+ ```
397
+
398
+ For an existing circuit, `await circuit.renderUntilSettled()` and pass
399
+ `<CadViewer circuit={circuit} />`. Replace the instance when the design changes.
400
+ TSX children passed directly to `CadViewer` use the same JSON playback path.
401
+ `circuitJson` takes precedence over `circuit` and TSX children. TSX renders
402
+ asynchronously before display. Core emits the explosion program in its CAD render
403
+ phases; invalid TSX references are reported as render errors. Inputs without an explosion program and
404
+ pre-rendered GLBs have the menu action disabled.
405
+
406
+ Invalid programs show an error while retaining assembled geometry. The evaluator
407
+ validates every stage even during partial playback. This version supports CAD and
408
+ reference-surface translations; PCB/cable-containing movements and rotations are
409
+ not supported. Displaying an explosion does not verify collision clearance.
410
+
411
+ The schema is published in `circuit-json@0.0.539` following
412
+ [circuit-json #937](https://github.com/tscircuit/circuit-json/pull/937).
413
+ Core's producer and evaluator are published in `@tscircuit/core@0.0.2234`
414
+ following [core #4990](https://github.com/tscircuit/core/pull/4990).
415
+
416
+ See **Assembly / Explosion / Staged Tsx** and **Assembly / RP2040 motor controller**
417
+ in Storybook. The real board fixture has four serialized stages: lift the cover
418
+ with all four bolts, remove the bolts, separate the motor, then separate the
419
+ spacers. The first move targets the entire bolt stage alongside the cover.
420
+
421
+ The stage snapshots below pair the actual TSX with the exported Circuit JSON
422
+ rendered through circuit-json-to-gltf, including halfway through bolt removal.
423
+
424
+ ![RP2040 assembly explosion stages with TSX](./docs/images/rp2040-explosion-stages.png)
425
+
426
+ Run browser regressions with
427
+ `bunx playwright test --config playwright.explosion.config.ts`.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as React$1 from 'react';
2
+ import { RootCircuit } from '@tscircuit/core';
2
3
  import { AnyCircuitElement, PcbBoard } from 'circuit-json';
3
4
  import * as THREE from 'three';
4
5
  import { GLTFExporterOptions } from 'three/examples/jsm/exporters/GLTFExporter.js';
@@ -49,6 +50,8 @@ declare const CadViewerJscad: React$1.ForwardRefExoticComponent<Props & {
49
50
 
50
51
  type CadViewerProps = Omit<React.ComponentProps<typeof CadViewerJscad>, "circuitJson" | "hiddenCadComponentIds"> & {
51
52
  circuitJson?: any[];
53
+ /** Settled circuit retaining authored assembly.explosion stages. */
54
+ circuit?: RootCircuit;
52
55
  /** Pre-rendered circuit-json-to-gltf GLB URL. Bypasses geometry/model generation. */
53
56
  glbUrl?: string;
54
57
  /** In-memory alternative to glbUrl. Supply only one GLB source. */