@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 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