@sienci/gviewer 0.1.16 → 0.1.18
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 +25 -0
- package/dist/{GCodeSVGRenderer-AJzTt7mi.js → GCodeSVGRenderer-DZeQSwum.js} +670 -573
- package/dist/{GCodeSVGRenderer-BOliBeEd.cjs → GCodeSVGRenderer-eKBgdYHt.cjs} +3 -3
- package/dist/react.cjs +1 -1
- package/dist/react.js +67 -61
- package/dist/types/viewer/GCodeViewer.d.ts +35 -0
- package/dist/types/viewer/bed/machineBed.d.ts +10 -0
- package/dist/types/viewer/grid/grid.d.ts +6 -3
- package/dist/types/viewer/types.d.ts +22 -1
- package/dist/viewer.cjs +1 -1
- package/dist/viewer.js +11 -4
- 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
|
+
##### Picking & interaction
|
|
362
|
+
|
|
363
|
+
```ts
|
|
364
|
+
// Lock orbit rotation while keeping pan + zoom (e.g. to pin a top-down view
|
|
365
|
+
// so a click maps predictably onto the XY plane). Picking works from any
|
|
366
|
+
// camera angle, so this is a UX lock, not a correctness requirement.
|
|
367
|
+
viewer.setRotateEnabled(false);
|
|
368
|
+
|
|
369
|
+
// Convert a viewport pixel (e.g. PointerEvent clientX/clientY) into a point on
|
|
370
|
+
// a horizontal toolpath plane. planeZ defaults to the bit's current Z.
|
|
371
|
+
const hit = viewer.screenToWorld(event.clientX, event.clientY);
|
|
372
|
+
if (hit) {
|
|
373
|
+
// hit.x / hit.y are in the GCode's coordinate space (work coords for a
|
|
374
|
+
// non-rotary file, since the toolpath root sits at the origin).
|
|
375
|
+
console.log(hit.x, hit.y, hit.z);
|
|
376
|
+
}
|
|
377
|
+
// Pick against an explicit plane height instead of the bit's Z:
|
|
378
|
+
viewer.screenToWorld(event.clientX, event.clientY, { planeZ: 0 });
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
> Returns `null` when the canvas has no layout yet or the ray is parallel to
|
|
382
|
+
> the plane. For rotary files the toolpath root is rotated about X, so the
|
|
383
|
+
> returned XY is not a meaningful work coordinate — gate on file type if you
|
|
384
|
+
> only support XY moves.
|
|
385
|
+
|
|
361
386
|
##### Progress / simulation
|
|
362
387
|
|
|
363
388
|
```ts
|