beckhoff-xts-viewer-3d 4.4.0 → 4.6.0

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
@@ -70,9 +70,11 @@ reflections, ACES tone mapping and anisotropic textures are on by default.
70
70
  - [Read selection + errors](#4-read-selection--errors)
71
71
  - [Detect mover collisions](#5-detect-mover-collisions)
72
72
  - [Capture screenshots](#6-capture-screenshots)
73
- - [Mark zones with Areas](#7-mark-zones-with-areas)
74
- - [Stator heatmap](#8-stator-heatmap)
75
- - [Track direction + zero offset](#9-track-direction--zero-offset)
73
+ - [Live 2D plan view (orthographic top-down)](#7-live-2d-plan-view-orthographic-top-down)
74
+ - [Fly the camera to an object (focusOn)](#8-fly-the-camera-to-an-object-focuson)
75
+ - [Mark zones with Areas](#9-mark-zones-with-areas)
76
+ - [Stator heatmap](#10-stator-heatmap)
77
+ - [Track direction + zero offset](#11-track-direction--zero-offset)
76
78
  - [Realism + performance](#realism--performance)
77
79
  - [Troubleshooting](#troubleshooting)
78
80
  - [Documentation](#documentation)
@@ -135,7 +137,14 @@ reflections, ACES tone mapping and anisotropic textures are on by default.
135
137
  - **Custom assets** — static, mover-bound, all-movers; opacity + scale
136
138
  per-instance, never leaks back into the source GLB.
137
139
  - **CAD ViewCube** — opt-in, snap to standard orthogonal views.
138
- - **Imperative ref API** — `zoomToFit` / `setCamera` / `getCamera` /
140
+ - **Live 2D plan view** — `projection="orthographic"` flips the live canvas to
141
+ a flat top-down view, pixel-consistent with the `'top-down'` screenshot, with
142
+ no WebGL-context remount and rotation auto-locked.
143
+ - **Animated focus** — `viewerRef.current.focusOn({ kind: 'station' | 'area' |
144
+ 'mover' | 'module' | 'scene', ... })` flies the camera so the whole target
145
+ fits the frame, in both 3D and 2D.
146
+ - **Imperative ref API** — `zoomToFit` / `frameTopDown` / `focusOn` /
147
+ `setCamera` / `getCamera` /
139
148
  `getMoverWorldTransform` / `getBoundingBox` / `exportModel` /
140
149
  `exportScreenshot` / `setMoverPosition(s)` (Record or
141
150
  `MoverPositionEntry[]` indexed by `MoverConfig.index`) / `getMoverPosition` /
@@ -371,7 +380,63 @@ viewer.current!.exportScreenshot({
371
380
  Renders go to an offscreen WebGLRenderTarget — the live canvas keeps
372
381
  running at full speed, no `preserveDrawingBuffer` perf cost.
373
382
 
374
- ### 7. Mark zones with Areas
383
+ ### 7. Live 2D plan view (orthographic top-down)
384
+
385
+ Set `projection="orthographic"` to switch the **live** canvas into a flat 2D
386
+ plan view — straight down +Z, world +Y up — that is pixel-consistent with
387
+ `exportScreenshot({ mode: 'top-down' })`. Switching at runtime does **not**
388
+ recreate the WebGL context, so toggling between 3D and 2D is instant.
389
+
390
+ ```tsx
391
+ const [is2D, setIs2D] = useState(false);
392
+
393
+ <XtsViewer3D
394
+ config={config}
395
+ projection={is2D ? 'orthographic' : 'perspective'}
396
+ // shadows add nothing to a flat plan — drop them in 2D
397
+ display={is2D ? { ...display, shadows: false } : display}
398
+ />
399
+ ```
400
+
401
+ In orthographic top-down, **rotation is auto-disabled** (a 2D plan has no
402
+ meaningful orbit); pan and zoom stay on. Set `lock={{ rotate: false }}` to
403
+ opt rotation back in. The frustum re-fits automatically on container resize
404
+ and whenever the scene's bounding box changes. From the ref, `frameTopDown()`
405
+ re-fits on demand and `zoomToFit()` adjusts the ortho frustum (instead of
406
+ dollying) when the live camera is orthographic.
407
+
408
+ ### 8. Fly the camera to an object (focusOn)
409
+
410
+ `viewerRef.current.focusOn(target, opts)` animates the camera so a **station,
411
+ area, mover, module** — or the whole `scene` — fits the frame. In perspective
412
+ the current view angle is preserved (the camera only dollies + re-centres); in
413
+ orthographic top-down the frustum re-frames and the camera pans straight over
414
+ the target. Works in both 2D and 3D.
415
+
416
+ ```tsx
417
+ // Frame a station, 700 ms ease-in-out (defaults)
418
+ viewerRef.current?.focusOn({ kind: 'station', stationId: 3 });
419
+
420
+ // Frame a mover, faster
421
+ viewerRef.current?.focusOn(
422
+ { kind: 'mover', ref: { processingUnitObjectId: 0, moverIndex: 2 } },
423
+ { durationMs: 500 },
424
+ );
425
+
426
+ // Frame an area / a module / the whole scene
427
+ viewerRef.current?.focusOn({ kind: 'area', areaId: 1 });
428
+ viewerRef.current?.focusOn({
429
+ kind: 'module',
430
+ ref: { processingUnitObjectId: 0, partObjectId: 10, moduleIndex: 4 },
431
+ });
432
+ viewerRef.current?.focusOn({ kind: 'scene' }, { durationMs: 0 }); // 0 = jump
433
+ ```
434
+
435
+ `FocusOptions`: `durationMs` (default `700`, `0` jumps), `paddingFactor`
436
+ (default `1.2` perspective / `1.1` ortho), `easing` (`'easeInOutCubic'` |
437
+ `'linear'`). A new `focusOn` call supersedes any in-flight animation.
438
+
439
+ ### 9. Mark zones with Areas
375
440
 
376
441
  Areas are stop-position-free range overlays — like Stations, but with no
377
442
  markers. Use them for cleanroom / safety-area / manual-access
@@ -404,7 +469,7 @@ zones that don't drive any mover behaviour:
404
469
  />;
405
470
  ```
406
471
 
407
- ### 8. Stator heatmap
472
+ ### 10. Stator heatmap
408
473
 
409
474
  Coloured tube along each part's centerline, vertex colours interpolated
410
475
  across consumer-supplied `(positionMm, value)` samples — perfect for
@@ -427,7 +492,7 @@ const heatmap: StatorHeatmap = {
427
492
  />;
428
493
  ```
429
494
 
430
- ### 9. Track direction + zero offset
495
+ ### 11. Track direction + zero offset
431
496
 
432
497
  When the host machine uses a different sign convention or zero point
433
498
  than the GLB chain, set a `positionFrame` on the XPU. Movers, stations,