@sienci/gviewer 0.1.31 → 0.1.32
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 +29 -2
- package/dist/{GCodeSVGRenderer-BeeQVu4r.js → GCodeSVGRenderer-D4QGoHWJ.js} +2651 -2497
- package/dist/{GCodeSVGRenderer-HssywtI7.cjs → GCodeSVGRenderer-i9duYU8q.cjs} +3 -3
- package/dist/react.cjs +1 -1
- package/dist/react.js +40 -34
- package/dist/types/viewer/GCodeViewer.d.ts +38 -5
- package/dist/types/viewer/camera/camera.d.ts +59 -1
- package/dist/types/viewer/types.d.ts +10 -0
- package/dist/viewcube.css +50 -0
- package/dist/viewer.cjs +1 -1
- package/dist/viewer.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -358,6 +358,31 @@ viewer.snapCameraToView("front", { durationMs: 300 });
|
|
|
358
358
|
// | "front-top-left" | "front-top-right" | ... (14 presets)
|
|
359
359
|
```
|
|
360
360
|
|
|
361
|
+
The optional `distance` on `snapCameraToView` is the camera standoff, which only
|
|
362
|
+
frames under a perspective camera. An orthographic camera frames by frustum
|
|
363
|
+
height, so the value moves the camera without changing how much is visible — use
|
|
364
|
+
`focusToModel()` to reframe in either projection.
|
|
365
|
+
|
|
366
|
+
##### Projection
|
|
367
|
+
|
|
368
|
+
The camera is perspective by default. Under perspective, two toolpath segments
|
|
369
|
+
that share X/Y but sit at different Z do not project to the same pixel — they lie
|
|
370
|
+
on the same ray through the camera — so in a top-down view stacked cut passes
|
|
371
|
+
splay apart, increasingly so away from the centre of the frame. Orthographic
|
|
372
|
+
projection has no divide-by-z, so those passes land on exactly the same pixel.
|
|
373
|
+
|
|
374
|
+
```ts
|
|
375
|
+
viewer.setCameraProjection("orthographic");
|
|
376
|
+
viewer.getCameraProjection(); // "perspective" | "orthographic"
|
|
377
|
+
|
|
378
|
+
// Equivalent, and how it's set at construction:
|
|
379
|
+
viewer.setOptions({ camera: { ...viewer.getOptions().camera, projection: "orthographic" } });
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Swapping preserves the view direction and the apparent framing, so the model does
|
|
383
|
+
not jump. Orbit, pan, zoom, picking and the ViewCube all work in both
|
|
384
|
+
projections; under ortho, zoom changes the frustum rather than the standoff.
|
|
385
|
+
|
|
361
386
|
##### Picking & interaction
|
|
362
387
|
|
|
363
388
|
```ts
|
|
@@ -432,7 +457,7 @@ viewer.setOptions({
|
|
|
432
457
|
},
|
|
433
458
|
grid: { size: 1000, axisDepth: 200, labels: true },
|
|
434
459
|
boundingBox: { visible: true, labels: true },
|
|
435
|
-
camera: { fov: 45 },
|
|
460
|
+
camera: { fov: 45, projection: "perspective" },
|
|
436
461
|
});
|
|
437
462
|
|
|
438
463
|
viewer.getOptions(); // returns current options (readonly)
|
|
@@ -477,7 +502,8 @@ type GCodeViewerOptions = {
|
|
|
477
502
|
};
|
|
478
503
|
render: { antialias: boolean; theme: GCodeViewerTheme };
|
|
479
504
|
camera: {
|
|
480
|
-
|
|
505
|
+
projection: "perspective" | "orthographic"; // default: "perspective"
|
|
506
|
+
fov: number; // perspective only; also seeds ortho framing on swap
|
|
481
507
|
focusDurationMs: number;
|
|
482
508
|
orbit: { enableDamping: boolean };
|
|
483
509
|
initialPosition: { x: number; y: number; z: number };
|
|
@@ -597,6 +623,7 @@ ref.current?.loadFromWorkerData(workerData);
|
|
|
597
623
|
ref.current?.focusToModel();
|
|
598
624
|
ref.current?.hideUntilLine(currentLine, "grey");
|
|
599
625
|
ref.current?.snapCameraToView("top");
|
|
626
|
+
ref.current?.setCameraProjection("orthographic");
|
|
600
627
|
ref.current?.setBitPosition({ x, y, z });
|
|
601
628
|
```
|
|
602
629
|
|