@sienci/gviewer 0.1.22 → 0.1.24

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.
@@ -2974,7 +2974,7 @@ function Fi(r) {
2974
2974
  }
2975
2975
  };
2976
2976
  }
2977
- const Gi = 25.4, fi = 500, bi = 260;
2977
+ const Gi = 25.4, fi = 500, bi = 300;
2978
2978
  class Yi {
2979
2979
  constructor(Q) {
2980
2980
  this.viewCube = null, this.resizeObserver = null, this.onWindowResize = null, this.animationFrameId = null, this.gridGroup = null, this.axesGroup = null, this.gridLabelsGroup = null, this.boundingBoxGroup = null, this.machineBedGroup = null, this.bitMarker = null, this.preLaserBitType = "drill", this.toolpathStreams = [], this.toolpathCutBucketCount = 1, this.toolpathRotationA = 0, this.lastBitPosition = { x: 0, y: 0, z: 0, a: 0 }, this.sim3dHandle = null, this.currentLines = [], this.linePositions = null, this.renderSequence = 0, this.currentBounds = null, this.cameraFocusTransition = null, this.cameraFollowRequested = !1, this.cameraFollowInterrupted = !1, this.cameraFollowOffset = null, this.id = Q.id, this.container = Q.container, this.callbacks = Q.callbacks ?? {}, this.options = Et(GP, Q.options), this.canvas = document.createElement("canvas"), this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.display = "block", this.container.appendChild(this.canvas), KP(this.container), this.renderer = new a.WebGLRenderer({
@@ -3011,7 +3011,7 @@ class Yi {
3011
3011
  var A;
3012
3012
  if (this.ensureBitMarker(), this.lastBitPosition = { ...this.lastBitPosition, ...Q }, (A = this.bitMarker) == null || A.setTarget(Q, B), this.cameraFollowRequested && !this.cameraFollowInterrupted && this.cameraFollowOffset) {
3013
3013
  const t = new a.Vector3(this.lastBitPosition.x, this.lastBitPosition.y, this.controls.target.z), P = t.clone().add(this.cameraFollowOffset);
3014
- this.startCameraLerp(t, P, bi);
3014
+ this.startCameraLerp(t, P, bi, "linear");
3015
3015
  }
3016
3016
  }
3017
3017
  /**
@@ -3126,6 +3126,28 @@ class Yi {
3126
3126
  const i = (A == null ? void 0 : A.planeZ) ?? this.lastBitPosition.z ?? 0, s = new a.Plane(new a.Vector3(0, 0, 1), -i), v = new a.Vector3();
3127
3127
  return e.ray.intersectPlane(s, v) ? { x: v.x, y: v.y, z: v.z } : null;
3128
3128
  }
3129
+ /**
3130
+ * Project a point in world/scene space to a viewport pixel (clientX/clientY),
3131
+ * the inverse of screenToWorld and in the same coordinate space it consumes.
3132
+ *
3133
+ * The point is projected through the camera to normalized device coordinates
3134
+ * and mapped back onto the laid-out canvas rect, so overlays drawn in fixed
3135
+ * (viewport) coordinates line up with picked scene points and track pan/zoom.
3136
+ *
3137
+ * `z` is the point's height in scene space (default 0); it changes the
3138
+ * projected pixel under the perspective camera, so callers placing markers
3139
+ * off the Z=0 plane should pass it. Returns null when the canvas has no layout.
3140
+ */
3141
+ worldToScreen(Q, B, A = 0) {
3142
+ const t = this.canvas.getBoundingClientRect();
3143
+ if (t.width === 0 || t.height === 0)
3144
+ return null;
3145
+ const P = new a.Vector3(Q, B, A).project(this.camera);
3146
+ return {
3147
+ x: t.left + (P.x + 1) / 2 * t.width,
3148
+ y: t.top + (1 - P.y) / 2 * t.height
3149
+ };
3150
+ }
3129
3151
  startSnapToView(Q, B, A, t) {
3130
3152
  const P = JA(Q), e = B.clone().add(P.multiplyScalar(A)), i = Math.max(1, A);
3131
3153
  this.camera.near = i / 1e3, this.camera.far = i * 50, this.camera.updateProjectionMatrix(), this.startCameraLerp(B, e, t);
@@ -3133,7 +3155,7 @@ class Yi {
3133
3155
  // Shared tween kickoff for any camera position+target move (view snapping,
3134
3156
  // model focus, tool-follow engage/track): saves/restores damping around the
3135
3157
  // transition and hands off to updateCameraFocusTransition() each frame.
3136
- startCameraLerp(Q, B, A) {
3158
+ startCameraLerp(Q, B, A, t = "easeInOutCubic") {
3137
3159
  this.cameraFocusTransition && (this.controls.enableDamping = this.cameraFocusTransition.dampingEnabled), this.cameraFocusTransition = {
3138
3160
  startedAt: performance.now(),
3139
3161
  duration: A,
@@ -3141,7 +3163,8 @@ class Yi {
3141
3163
  toPosition: B,
3142
3164
  fromTarget: this.controls.target.clone(),
3143
3165
  toTarget: Q,
3144
- dampingEnabled: this.controls.enableDamping
3166
+ dampingEnabled: this.controls.enableDamping,
3167
+ easing: t
3145
3168
  }, this.controls.enableDamping = !1;
3146
3169
  }
3147
3170
  async loadFromUrl(Q, B = {}) {
@@ -3490,20 +3513,12 @@ class Yi {
3490
3513
  const A = new a.Vector3();
3491
3514
  Q.getSize(A);
3492
3515
  const t = Math.max(A.x, A.y, 1) / 2, P = a.MathUtils.degToRad(this.camera.fov), e = t / Math.tan(P / 2) * 1.25 + A.z, i = JA("front-top-left"), s = B.clone().add(i.multiplyScalar(e)), v = Math.max(A.x, A.y, A.z, 1);
3493
- this.camera.near = v / 1e3, this.camera.far = v * 50, this.camera.updateProjectionMatrix(), this.cameraFocusTransition && (this.controls.enableDamping = this.cameraFocusTransition.dampingEnabled), this.cameraFocusTransition = {
3494
- startedAt: performance.now(),
3495
- duration: this.options.camera.focusDurationMs,
3496
- fromPosition: this.camera.position.clone(),
3497
- toPosition: s,
3498
- fromTarget: this.controls.target.clone(),
3499
- toTarget: B,
3500
- dampingEnabled: this.controls.enableDamping
3501
- }, this.controls.enableDamping = !1;
3516
+ this.camera.near = v / 1e3, this.camera.far = v * 50, this.camera.updateProjectionMatrix(), this.startCameraLerp(B, s, this.options.camera.focusDurationMs);
3502
3517
  }
3503
3518
  updateCameraFocusTransition() {
3504
3519
  if (!this.cameraFocusTransition)
3505
3520
  return;
3506
- const B = performance.now() - this.cameraFocusTransition.startedAt, A = Math.min(1, Math.max(0, B / this.cameraFocusTransition.duration)), t = ZP(A);
3521
+ const B = performance.now() - this.cameraFocusTransition.startedAt, A = Math.min(1, Math.max(0, B / this.cameraFocusTransition.duration)), t = this.cameraFocusTransition.easing === "linear" ? A : ZP(A);
3507
3522
  if (this.camera.position.lerpVectors(this.cameraFocusTransition.fromPosition, this.cameraFocusTransition.toPosition, t), this.controls.target.lerpVectors(this.cameraFocusTransition.fromTarget, this.cameraFocusTransition.toTarget, t), A >= 1) {
3508
3523
  const P = this.cameraFocusTransition.dampingEnabled;
3509
3524
  this.camera.position.copy(this.cameraFocusTransition.toPosition), this.controls.target.copy(this.cameraFocusTransition.toTarget), this.cameraFocusTransition = null, this.controls.enableDamping = !1, this.controls.update(), this.controls.enableDamping = P;
package/dist/react.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),F=require("./GCodeSVGRenderer-P5rcQTaO.cjs");function C(a){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const s in a)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(a,s);Object.defineProperty(d,s,i.get?i:{enumerable:!0,get:()=>a[s]})}}return d.default=a,Object.freeze(d)}const o=C(w),G=o.forwardRef(function(d,s){const{id:i,options:l,callbacks:c,className:m,style:f}=d,u=o.useRef(null),r=o.useRef(null);return o.useEffect(()=>{const e=u.current;if(!e)return;const p=new F.GCodeViewer({id:i,container:e,options:l,callbacks:c});return r.current=p,()=>{r.current=null,p.dispose()}},[i]),o.useEffect(()=>{var e;(e=r.current)==null||e.setOptions(l??{})},[l]),o.useEffect(()=>{var e;(e=r.current)==null||e.setCallbacks(c??{})},[c]),o.useImperativeHandle(s,()=>{const e=()=>{const t=r.current;if(!t)throw new Error("GCodeViewer is not ready.");return t};return{get id(){return i},setCallbacks(t){e().setCallbacks(t)},snapCameraToView(t,n){e().snapCameraToView(t,n)},setRotateEnabled(t){e().setRotateEnabled(t)},setCameraFollowEnabled(t){e().setCameraFollowEnabled(t)},screenToWorld(t,n,V){return e().screenToWorld(t,n,V)},setBitPosition(t,n){e().setBitPosition(t,n)},setBitVisible(t){e().setBitVisible(t)},setBitSpinning(t){e().setBitSpinning(t)},setToolpathRotationA(t){e().setToolpathRotationA(t)},hideUntilLine(t,n){e().hideUntilLine(t,n)},seekToLine(t,n){e().seekToLine(t,n)},showAll(){e().showAll()},resetColors(){e().resetColors()},loadFromUrl(t,n){return e().loadFromUrl(t,n)},loadFromFile(t){return e().loadFromFile(t)},loadFromText(t){return e().loadFromText(t)},loadFromLines(t){return e().loadFromLines(t)},loadFromWorkerData(t){return e().loadFromWorkerData(t)},unload(){e().unload()},setOptions(t){e().setOptions(t)},getOptions(){return e().getOptions()},resize(){e().resize()},focusToModel(){e().focusToModel()},resetCamera(){e().resetCamera()},getBounds(){return e().getBounds()},dispose(){e().dispose()}}},[i]),o.createElement("div",{ref:u,className:m,style:f})}),b=o.forwardRef(function(d,s){const{id:i,options:l,className:c,style:m}=d,f=o.useRef(null),u=o.useRef(null);return o.useEffect(()=>{const r=f.current;if(!r)return;const e=new F.GCodeSVGRenderer(r,l);return u.current=e,()=>{u.current=null,e.dispose()}},[]),o.useEffect(()=>{var r;l&&((r=u.current)==null||r.setOptions(l))},[l]),o.useImperativeHandle(s,()=>{const r=()=>{const e=u.current;if(!e)throw new Error("GCodeSVGRenderer is not ready.");return e};return{loadFromLines:e=>r().loadFromLines(e),loadFromFile:e=>r().loadFromFile(e),loadFromText:e=>r().loadFromText(e),loadFromWorkerData:e=>r().loadFromWorkerData(e),loadFromPrecomputedGroups:e=>r().loadFromPrecomputedGroups(e),clear:()=>r().clear(),resetView:()=>r().resetView(),setOptions:e=>r().setOptions(e),setProjectionMode:e=>r().setProjectionMode(e),setBitPosition:e=>r().setBitPosition(e),setBitVisible:e=>r().setBitVisible(e),getSVGElement:()=>r().getSVGElement(),dispose:()=>r().dispose()}},[]),o.createElement("div",{ref:f,className:c,style:{width:"100%",height:"100%",...m}})});exports.GCodeSVGVisualizer=b;exports.GCodeVisualizer=G;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react"),F=require("./GCodeSVGRenderer-BS3n-2zr.cjs");function C(a){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const s in a)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(a,s);Object.defineProperty(d,s,i.get?i:{enumerable:!0,get:()=>a[s]})}}return d.default=a,Object.freeze(d)}const o=C(V),G=o.forwardRef(function(d,s){const{id:i,options:l,callbacks:c,className:m,style:f}=d,u=o.useRef(null),r=o.useRef(null);return o.useEffect(()=>{const e=u.current;if(!e)return;const p=new F.GCodeViewer({id:i,container:e,options:l,callbacks:c});return r.current=p,()=>{r.current=null,p.dispose()}},[i]),o.useEffect(()=>{var e;(e=r.current)==null||e.setOptions(l??{})},[l]),o.useEffect(()=>{var e;(e=r.current)==null||e.setCallbacks(c??{})},[c]),o.useImperativeHandle(s,()=>{const e=()=>{const t=r.current;if(!t)throw new Error("GCodeViewer is not ready.");return t};return{get id(){return i},setCallbacks(t){e().setCallbacks(t)},snapCameraToView(t,n){e().snapCameraToView(t,n)},setRotateEnabled(t){e().setRotateEnabled(t)},setCameraFollowEnabled(t){e().setCameraFollowEnabled(t)},screenToWorld(t,n,w){return e().screenToWorld(t,n,w)},worldToScreen(t,n,w){return e().worldToScreen(t,n,w)},setBitPosition(t,n){e().setBitPosition(t,n)},setBitVisible(t){e().setBitVisible(t)},setBitSpinning(t){e().setBitSpinning(t)},setToolpathRotationA(t){e().setToolpathRotationA(t)},hideUntilLine(t,n){e().hideUntilLine(t,n)},seekToLine(t,n){e().seekToLine(t,n)},showAll(){e().showAll()},resetColors(){e().resetColors()},loadFromUrl(t,n){return e().loadFromUrl(t,n)},loadFromFile(t){return e().loadFromFile(t)},loadFromText(t){return e().loadFromText(t)},loadFromLines(t){return e().loadFromLines(t)},loadFromWorkerData(t){return e().loadFromWorkerData(t)},unload(){e().unload()},setOptions(t){e().setOptions(t)},getOptions(){return e().getOptions()},resize(){e().resize()},focusToModel(){e().focusToModel()},resetCamera(){e().resetCamera()},getBounds(){return e().getBounds()},dispose(){e().dispose()}}},[i]),o.createElement("div",{ref:u,className:m,style:f})}),b=o.forwardRef(function(d,s){const{id:i,options:l,className:c,style:m}=d,f=o.useRef(null),u=o.useRef(null);return o.useEffect(()=>{const r=f.current;if(!r)return;const e=new F.GCodeSVGRenderer(r,l);return u.current=e,()=>{u.current=null,e.dispose()}},[]),o.useEffect(()=>{var r;l&&((r=u.current)==null||r.setOptions(l))},[l]),o.useImperativeHandle(s,()=>{const r=()=>{const e=u.current;if(!e)throw new Error("GCodeSVGRenderer is not ready.");return e};return{loadFromLines:e=>r().loadFromLines(e),loadFromFile:e=>r().loadFromFile(e),loadFromText:e=>r().loadFromText(e),loadFromWorkerData:e=>r().loadFromWorkerData(e),loadFromPrecomputedGroups:e=>r().loadFromPrecomputedGroups(e),clear:()=>r().clear(),resetView:()=>r().resetView(),setOptions:e=>r().setOptions(e),setProjectionMode:e=>r().setProjectionMode(e),setBitPosition:e=>r().setBitPosition(e),setBitVisible:e=>r().setBitVisible(e),getSVGElement:()=>r().getSVGElement(),dispose:()=>r().dispose()}},[]),o.createElement("div",{ref:f,className:c,style:{width:"100%",height:"100%",...m}})});exports.GCodeSVGVisualizer=b;exports.GCodeVisualizer=G;
package/dist/react.js CHANGED
@@ -1,67 +1,70 @@
1
1
  import * as o from "react";
2
- import { a as w, G as V } from "./GCodeSVGRenderer-BllsP24E.js";
2
+ import { a as w, G as V } from "./GCodeSVGRenderer-BrTJFrH-.js";
3
3
  const G = o.forwardRef(
4
4
  function(u, c) {
5
- const { id: a, options: n, callbacks: l, className: m, style: d } = u, i = o.useRef(null), r = o.useRef(null);
5
+ const { id: l, options: n, callbacks: a, className: m, style: d } = u, i = o.useRef(null), t = o.useRef(null);
6
6
  return o.useEffect(() => {
7
7
  const e = i.current;
8
8
  if (!e)
9
9
  return;
10
- const f = new w({ id: a, container: e, options: n, callbacks: l });
11
- return r.current = f, () => {
12
- r.current = null, f.dispose();
10
+ const f = new w({ id: l, container: e, options: n, callbacks: a });
11
+ return t.current = f, () => {
12
+ t.current = null, f.dispose();
13
13
  };
14
- }, [a]), o.useEffect(() => {
14
+ }, [l]), o.useEffect(() => {
15
15
  var e;
16
- (e = r.current) == null || e.setOptions(n ?? {});
16
+ (e = t.current) == null || e.setOptions(n ?? {});
17
17
  }, [n]), o.useEffect(() => {
18
18
  var e;
19
- (e = r.current) == null || e.setCallbacks(l ?? {});
20
- }, [l]), o.useImperativeHandle(
19
+ (e = t.current) == null || e.setCallbacks(a ?? {});
20
+ }, [a]), o.useImperativeHandle(
21
21
  c,
22
22
  () => {
23
23
  const e = () => {
24
- const t = r.current;
25
- if (!t)
24
+ const r = t.current;
25
+ if (!r)
26
26
  throw new Error("GCodeViewer is not ready.");
27
- return t;
27
+ return r;
28
28
  };
29
29
  return {
30
30
  get id() {
31
- return a;
31
+ return l;
32
32
  },
33
- setCallbacks(t) {
34
- e().setCallbacks(t);
33
+ setCallbacks(r) {
34
+ e().setCallbacks(r);
35
35
  },
36
- snapCameraToView(t, s) {
37
- e().snapCameraToView(t, s);
36
+ snapCameraToView(r, s) {
37
+ e().snapCameraToView(r, s);
38
38
  },
39
- setRotateEnabled(t) {
40
- e().setRotateEnabled(t);
39
+ setRotateEnabled(r) {
40
+ e().setRotateEnabled(r);
41
41
  },
42
- setCameraFollowEnabled(t) {
43
- e().setCameraFollowEnabled(t);
42
+ setCameraFollowEnabled(r) {
43
+ e().setCameraFollowEnabled(r);
44
44
  },
45
- screenToWorld(t, s, F) {
46
- return e().screenToWorld(t, s, F);
45
+ screenToWorld(r, s, p) {
46
+ return e().screenToWorld(r, s, p);
47
47
  },
48
- setBitPosition(t, s) {
49
- e().setBitPosition(t, s);
48
+ worldToScreen(r, s, p) {
49
+ return e().worldToScreen(r, s, p);
50
50
  },
51
- setBitVisible(t) {
52
- e().setBitVisible(t);
51
+ setBitPosition(r, s) {
52
+ e().setBitPosition(r, s);
53
53
  },
54
- setBitSpinning(t) {
55
- e().setBitSpinning(t);
54
+ setBitVisible(r) {
55
+ e().setBitVisible(r);
56
56
  },
57
- setToolpathRotationA(t) {
58
- e().setToolpathRotationA(t);
57
+ setBitSpinning(r) {
58
+ e().setBitSpinning(r);
59
59
  },
60
- hideUntilLine(t, s) {
61
- e().hideUntilLine(t, s);
60
+ setToolpathRotationA(r) {
61
+ e().setToolpathRotationA(r);
62
62
  },
63
- seekToLine(t, s) {
64
- e().seekToLine(t, s);
63
+ hideUntilLine(r, s) {
64
+ e().hideUntilLine(r, s);
65
+ },
66
+ seekToLine(r, s) {
67
+ e().seekToLine(r, s);
65
68
  },
66
69
  showAll() {
67
70
  e().showAll();
@@ -69,26 +72,26 @@ const G = o.forwardRef(
69
72
  resetColors() {
70
73
  e().resetColors();
71
74
  },
72
- loadFromUrl(t, s) {
73
- return e().loadFromUrl(t, s);
75
+ loadFromUrl(r, s) {
76
+ return e().loadFromUrl(r, s);
74
77
  },
75
- loadFromFile(t) {
76
- return e().loadFromFile(t);
78
+ loadFromFile(r) {
79
+ return e().loadFromFile(r);
77
80
  },
78
- loadFromText(t) {
79
- return e().loadFromText(t);
81
+ loadFromText(r) {
82
+ return e().loadFromText(r);
80
83
  },
81
- loadFromLines(t) {
82
- return e().loadFromLines(t);
84
+ loadFromLines(r) {
85
+ return e().loadFromLines(r);
83
86
  },
84
- loadFromWorkerData(t) {
85
- return e().loadFromWorkerData(t);
87
+ loadFromWorkerData(r) {
88
+ return e().loadFromWorkerData(r);
86
89
  },
87
90
  unload() {
88
91
  e().unload();
89
92
  },
90
- setOptions(t) {
91
- e().setOptions(t);
93
+ setOptions(r) {
94
+ e().setOptions(r);
92
95
  },
93
96
  getOptions() {
94
97
  return e().getOptions();
@@ -110,46 +113,46 @@ const G = o.forwardRef(
110
113
  }
111
114
  };
112
115
  },
113
- [a]
116
+ [l]
114
117
  ), o.createElement("div", { ref: i, className: m, style: d });
115
118
  }
116
119
  ), R = o.forwardRef(
117
120
  function(u, c) {
118
- const { id: a, options: n, className: l, style: m } = u, d = o.useRef(null), i = o.useRef(null);
121
+ const { id: l, options: n, className: a, style: m } = u, d = o.useRef(null), i = o.useRef(null);
119
122
  return o.useEffect(() => {
120
- const r = d.current;
121
- if (!r) return;
122
- const e = new V(r, n);
123
+ const t = d.current;
124
+ if (!t) return;
125
+ const e = new V(t, n);
123
126
  return i.current = e, () => {
124
127
  i.current = null, e.dispose();
125
128
  };
126
129
  }, []), o.useEffect(() => {
127
- var r;
128
- n && ((r = i.current) == null || r.setOptions(n));
130
+ var t;
131
+ n && ((t = i.current) == null || t.setOptions(n));
129
132
  }, [n]), o.useImperativeHandle(c, () => {
130
- const r = () => {
133
+ const t = () => {
131
134
  const e = i.current;
132
135
  if (!e) throw new Error("GCodeSVGRenderer is not ready.");
133
136
  return e;
134
137
  };
135
138
  return {
136
- loadFromLines: (e) => r().loadFromLines(e),
137
- loadFromFile: (e) => r().loadFromFile(e),
138
- loadFromText: (e) => r().loadFromText(e),
139
- loadFromWorkerData: (e) => r().loadFromWorkerData(e),
140
- loadFromPrecomputedGroups: (e) => r().loadFromPrecomputedGroups(e),
141
- clear: () => r().clear(),
142
- resetView: () => r().resetView(),
143
- setOptions: (e) => r().setOptions(e),
144
- setProjectionMode: (e) => r().setProjectionMode(e),
145
- setBitPosition: (e) => r().setBitPosition(e),
146
- setBitVisible: (e) => r().setBitVisible(e),
147
- getSVGElement: () => r().getSVGElement(),
148
- dispose: () => r().dispose()
139
+ loadFromLines: (e) => t().loadFromLines(e),
140
+ loadFromFile: (e) => t().loadFromFile(e),
141
+ loadFromText: (e) => t().loadFromText(e),
142
+ loadFromWorkerData: (e) => t().loadFromWorkerData(e),
143
+ loadFromPrecomputedGroups: (e) => t().loadFromPrecomputedGroups(e),
144
+ clear: () => t().clear(),
145
+ resetView: () => t().resetView(),
146
+ setOptions: (e) => t().setOptions(e),
147
+ setProjectionMode: (e) => t().setProjectionMode(e),
148
+ setBitPosition: (e) => t().setBitPosition(e),
149
+ setBitVisible: (e) => t().setBitVisible(e),
150
+ getSVGElement: () => t().getSVGElement(),
151
+ dispose: () => t().dispose()
149
152
  };
150
153
  }, []), o.createElement("div", {
151
154
  ref: d,
152
- className: l,
155
+ className: a,
153
156
  style: { width: "100%", height: "100%", ...m }
154
157
  });
155
158
  }
@@ -92,6 +92,22 @@ export declare class GCodeViewer implements GCodeViewerHandle {
92
92
  y: number;
93
93
  z: number;
94
94
  } | null;
95
+ /**
96
+ * Project a point in world/scene space to a viewport pixel (clientX/clientY),
97
+ * the inverse of screenToWorld and in the same coordinate space it consumes.
98
+ *
99
+ * The point is projected through the camera to normalized device coordinates
100
+ * and mapped back onto the laid-out canvas rect, so overlays drawn in fixed
101
+ * (viewport) coordinates line up with picked scene points and track pan/zoom.
102
+ *
103
+ * `z` is the point's height in scene space (default 0); it changes the
104
+ * projected pixel under the perspective camera, so callers placing markers
105
+ * off the Z=0 plane should pass it. Returns null when the canvas has no layout.
106
+ */
107
+ worldToScreen(x: number, y: number, z?: number): {
108
+ x: number;
109
+ y: number;
110
+ } | null;
95
111
  private startSnapToView;
96
112
  private startCameraLerp;
97
113
  loadFromUrl(url: string, args?: {
@@ -183,6 +183,10 @@ export type GCodeViewerHandle = {
183
183
  y: number;
184
184
  z: number;
185
185
  } | null;
186
+ worldToScreen(x: number, y: number, z?: number): {
187
+ x: number;
188
+ y: number;
189
+ } | null;
186
190
  setBitPosition(position: GCodeViewerBitPosition, options?: {
187
191
  immediate?: boolean;
188
192
  }): void;
package/dist/viewer.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./GCodeSVGRenderer-P5rcQTaO.cjs"),a={dark:{background:"#111827",opacity:.9,rapidOpacity:.3,colors:{rapid:"#0ef6ae",cutting:"#3e85c7",laser:"#a855f7",processed:"#6b7280",boundingBox:"#e2e8f0",machineBed:"#f5a623",machineBedKeepout:"#df3b3b",grid:{major:"#77a9d7",minor:"#3e6e9e"},axes:{x:"#df3b3b",y:"#06b881",z:"#295d8d"}}},light:{background:"#e5e7eb",opacity:.9,rapidOpacity:.3,colors:{rapid:"#295d8d",cutting:"#111827",laser:"#FF0000",processed:"#9ca3af",boundingBox:"#4b5563",machineBed:"#b45309",machineBedKeepout:"#df3b3b",grid:{major:"#295d8d",minor:"#5191cc"},axes:{x:"#df3b3b",y:"#06b881",z:"#295d8d"}}},"flexoki-dark":{background:"#100f0f",opacity:.9,rapidOpacity:.3,colors:{rapid:"#DA702C",cutting:"#3AA99F",laser:"#8B7EC8",processed:"#6f6e69",boundingBox:"#cecdc3",machineBed:"#ffcc66",machineBedKeepout:"#d14d41",grid:{major:"#a89984",minor:"#6f6e69"},axes:{x:"#d14d41",y:"#879a39",z:"#4385be"}}},"tokyo-night":{background:"#1a1b26",opacity:.9,rapidOpacity:.3,colors:{rapid:"#ff9e64",cutting:"#7dcfff",laser:"#bb9af7",processed:"#565f89",boundingBox:"#c0caf5",machineBed:"#e0af68",machineBedKeepout:"#f7768e",grid:{major:"#7aa2f7",minor:"#414868"},axes:{x:"#f7768e",y:"#9ece6a",z:"#7aa2f7"}}},"gruvbox-light":{background:"#fbf1c7",opacity:.9,rapidOpacity:.3,colors:{rapid:"#d65d0e",cutting:"#3c3836",laser:"#b16286",processed:"#928374",boundingBox:"#7c6f64",machineBed:"#d79921",machineBedKeepout:"#cc241d",grid:{major:"#7c6f64",minor:"#a89984"},axes:{x:"#cc241d",y:"#98971a",z:"#458588"}}},"ayu-dark":{background:"#0b0e14",opacity:.9,rapidOpacity:.3,colors:{rapid:"#FFA659",cutting:"#73D0FF",laser:"#DFBFFF",processed:"#6E7C8F",boundingBox:"#CBCCC6",machineBed:"#FFD173",machineBedKeepout:"#F28779",grid:{major:"#77a9d7",minor:"#3e6590"},axes:{x:"#F28779",y:"#D5FF80",z:"#5CCFE6"}}},"ayu-light":{background:"#fafafa",opacity:.9,rapidOpacity:.3,colors:{rapid:"#FA8D3E",cutting:"#22A4E6",laser:"#A37ACC",processed:"#ADAEB1",boundingBox:"#5C6773",machineBed:"#F2AE49",machineBedKeepout:"#F07171",grid:{major:"#5c6773",minor:"#9aacba"},axes:{x:"#F07171",y:"#86B300",z:"#55B4D4"}}}};exports.GCodeSVGRenderer=e.GCodeSVGRenderer;exports.GCodeViewer=e.GCodeViewer;exports.ViewCube=e.ViewCube;exports.defaultGCodeViewerOptions=e.defaultGCodeViewerOptions;exports.defaultGCodeViewerTheme=e.defaultGCodeViewerTheme;exports.gCodeViewerThemePresets=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./GCodeSVGRenderer-BS3n-2zr.cjs"),a={dark:{background:"#111827",opacity:.9,rapidOpacity:.3,colors:{rapid:"#0ef6ae",cutting:"#3e85c7",laser:"#a855f7",processed:"#6b7280",boundingBox:"#e2e8f0",machineBed:"#f5a623",machineBedKeepout:"#df3b3b",grid:{major:"#77a9d7",minor:"#3e6e9e"},axes:{x:"#df3b3b",y:"#06b881",z:"#295d8d"}}},light:{background:"#e5e7eb",opacity:.9,rapidOpacity:.3,colors:{rapid:"#295d8d",cutting:"#111827",laser:"#FF0000",processed:"#9ca3af",boundingBox:"#4b5563",machineBed:"#b45309",machineBedKeepout:"#df3b3b",grid:{major:"#295d8d",minor:"#5191cc"},axes:{x:"#df3b3b",y:"#06b881",z:"#295d8d"}}},"flexoki-dark":{background:"#100f0f",opacity:.9,rapidOpacity:.3,colors:{rapid:"#DA702C",cutting:"#3AA99F",laser:"#8B7EC8",processed:"#6f6e69",boundingBox:"#cecdc3",machineBed:"#ffcc66",machineBedKeepout:"#d14d41",grid:{major:"#a89984",minor:"#6f6e69"},axes:{x:"#d14d41",y:"#879a39",z:"#4385be"}}},"tokyo-night":{background:"#1a1b26",opacity:.9,rapidOpacity:.3,colors:{rapid:"#ff9e64",cutting:"#7dcfff",laser:"#bb9af7",processed:"#565f89",boundingBox:"#c0caf5",machineBed:"#e0af68",machineBedKeepout:"#f7768e",grid:{major:"#7aa2f7",minor:"#414868"},axes:{x:"#f7768e",y:"#9ece6a",z:"#7aa2f7"}}},"gruvbox-light":{background:"#fbf1c7",opacity:.9,rapidOpacity:.3,colors:{rapid:"#d65d0e",cutting:"#3c3836",laser:"#b16286",processed:"#928374",boundingBox:"#7c6f64",machineBed:"#d79921",machineBedKeepout:"#cc241d",grid:{major:"#7c6f64",minor:"#a89984"},axes:{x:"#cc241d",y:"#98971a",z:"#458588"}}},"ayu-dark":{background:"#0b0e14",opacity:.9,rapidOpacity:.3,colors:{rapid:"#FFA659",cutting:"#73D0FF",laser:"#DFBFFF",processed:"#6E7C8F",boundingBox:"#CBCCC6",machineBed:"#FFD173",machineBedKeepout:"#F28779",grid:{major:"#77a9d7",minor:"#3e6590"},axes:{x:"#F28779",y:"#D5FF80",z:"#5CCFE6"}}},"ayu-light":{background:"#fafafa",opacity:.9,rapidOpacity:.3,colors:{rapid:"#FA8D3E",cutting:"#22A4E6",laser:"#A37ACC",processed:"#ADAEB1",boundingBox:"#5C6773",machineBed:"#F2AE49",machineBedKeepout:"#F07171",grid:{major:"#5c6773",minor:"#9aacba"},axes:{x:"#F07171",y:"#86B300",z:"#55B4D4"}}}};exports.GCodeSVGRenderer=e.GCodeSVGRenderer;exports.GCodeViewer=e.GCodeViewer;exports.ViewCube=e.ViewCube;exports.defaultGCodeViewerOptions=e.defaultGCodeViewerOptions;exports.defaultGCodeViewerTheme=e.defaultGCodeViewerTheme;exports.gCodeViewerThemePresets=a;
package/dist/viewer.js CHANGED
@@ -1,4 +1,4 @@
1
- import { G as o, a as i, V as c, d as r, b as n } from "./GCodeSVGRenderer-BllsP24E.js";
1
+ import { G as o, a as i, V as c, d as r, b as n } from "./GCodeSVGRenderer-BrTJFrH-.js";
2
2
  const e = {
3
3
  dark: {
4
4
  background: "#111827",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sienci/gviewer",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "GCode visualization library using Three.js",
5
5
  "repository": {
6
6
  "type": "git",