@sienci/gviewer 0.1.23 → 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.
- package/dist/{GCodeSVGRenderer-BvaXifw1.cjs → GCodeSVGRenderer-BS3n-2zr.cjs} +1 -1
- package/dist/{GCodeSVGRenderer-BMoDX03w.js → GCodeSVGRenderer-BrTJFrH-.js} +22 -0
- package/dist/react.cjs +1 -1
- package/dist/react.js +72 -69
- package/dist/types/viewer/GCodeViewer.d.ts +16 -0
- package/dist/types/viewer/types.d.ts +4 -0
- package/dist/viewer.cjs +1 -1
- package/dist/viewer.js +1 -1
- package/package.json +1 -1
|
@@ -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);
|
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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-
|
|
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:
|
|
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:
|
|
11
|
-
return
|
|
12
|
-
|
|
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
|
-
}, [
|
|
14
|
+
}, [l]), o.useEffect(() => {
|
|
15
15
|
var e;
|
|
16
|
-
(e =
|
|
16
|
+
(e = t.current) == null || e.setOptions(n ?? {});
|
|
17
17
|
}, [n]), o.useEffect(() => {
|
|
18
18
|
var e;
|
|
19
|
-
(e =
|
|
20
|
-
}, [
|
|
19
|
+
(e = t.current) == null || e.setCallbacks(a ?? {});
|
|
20
|
+
}, [a]), o.useImperativeHandle(
|
|
21
21
|
c,
|
|
22
22
|
() => {
|
|
23
23
|
const e = () => {
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
24
|
+
const r = t.current;
|
|
25
|
+
if (!r)
|
|
26
26
|
throw new Error("GCodeViewer is not ready.");
|
|
27
|
-
return
|
|
27
|
+
return r;
|
|
28
28
|
};
|
|
29
29
|
return {
|
|
30
30
|
get id() {
|
|
31
|
-
return
|
|
31
|
+
return l;
|
|
32
32
|
},
|
|
33
|
-
setCallbacks(
|
|
34
|
-
e().setCallbacks(
|
|
33
|
+
setCallbacks(r) {
|
|
34
|
+
e().setCallbacks(r);
|
|
35
35
|
},
|
|
36
|
-
snapCameraToView(
|
|
37
|
-
e().snapCameraToView(
|
|
36
|
+
snapCameraToView(r, s) {
|
|
37
|
+
e().snapCameraToView(r, s);
|
|
38
38
|
},
|
|
39
|
-
setRotateEnabled(
|
|
40
|
-
e().setRotateEnabled(
|
|
39
|
+
setRotateEnabled(r) {
|
|
40
|
+
e().setRotateEnabled(r);
|
|
41
41
|
},
|
|
42
|
-
setCameraFollowEnabled(
|
|
43
|
-
e().setCameraFollowEnabled(
|
|
42
|
+
setCameraFollowEnabled(r) {
|
|
43
|
+
e().setCameraFollowEnabled(r);
|
|
44
44
|
},
|
|
45
|
-
screenToWorld(
|
|
46
|
-
return e().screenToWorld(
|
|
45
|
+
screenToWorld(r, s, p) {
|
|
46
|
+
return e().screenToWorld(r, s, p);
|
|
47
47
|
},
|
|
48
|
-
|
|
49
|
-
e().
|
|
48
|
+
worldToScreen(r, s, p) {
|
|
49
|
+
return e().worldToScreen(r, s, p);
|
|
50
50
|
},
|
|
51
|
-
|
|
52
|
-
e().
|
|
51
|
+
setBitPosition(r, s) {
|
|
52
|
+
e().setBitPosition(r, s);
|
|
53
53
|
},
|
|
54
|
-
|
|
55
|
-
e().
|
|
54
|
+
setBitVisible(r) {
|
|
55
|
+
e().setBitVisible(r);
|
|
56
56
|
},
|
|
57
|
-
|
|
58
|
-
e().
|
|
57
|
+
setBitSpinning(r) {
|
|
58
|
+
e().setBitSpinning(r);
|
|
59
59
|
},
|
|
60
|
-
|
|
61
|
-
e().
|
|
60
|
+
setToolpathRotationA(r) {
|
|
61
|
+
e().setToolpathRotationA(r);
|
|
62
62
|
},
|
|
63
|
-
|
|
64
|
-
e().
|
|
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(
|
|
73
|
-
return e().loadFromUrl(
|
|
75
|
+
loadFromUrl(r, s) {
|
|
76
|
+
return e().loadFromUrl(r, s);
|
|
74
77
|
},
|
|
75
|
-
loadFromFile(
|
|
76
|
-
return e().loadFromFile(
|
|
78
|
+
loadFromFile(r) {
|
|
79
|
+
return e().loadFromFile(r);
|
|
77
80
|
},
|
|
78
|
-
loadFromText(
|
|
79
|
-
return e().loadFromText(
|
|
81
|
+
loadFromText(r) {
|
|
82
|
+
return e().loadFromText(r);
|
|
80
83
|
},
|
|
81
|
-
loadFromLines(
|
|
82
|
-
return e().loadFromLines(
|
|
84
|
+
loadFromLines(r) {
|
|
85
|
+
return e().loadFromLines(r);
|
|
83
86
|
},
|
|
84
|
-
loadFromWorkerData(
|
|
85
|
-
return e().loadFromWorkerData(
|
|
87
|
+
loadFromWorkerData(r) {
|
|
88
|
+
return e().loadFromWorkerData(r);
|
|
86
89
|
},
|
|
87
90
|
unload() {
|
|
88
91
|
e().unload();
|
|
89
92
|
},
|
|
90
|
-
setOptions(
|
|
91
|
-
e().setOptions(
|
|
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
|
-
[
|
|
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:
|
|
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
|
|
121
|
-
if (!
|
|
122
|
-
const e = new V(
|
|
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
|
|
128
|
-
n && ((
|
|
130
|
+
var t;
|
|
131
|
+
n && ((t = i.current) == null || t.setOptions(n));
|
|
129
132
|
}, [n]), o.useImperativeHandle(c, () => {
|
|
130
|
-
const
|
|
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) =>
|
|
137
|
-
loadFromFile: (e) =>
|
|
138
|
-
loadFromText: (e) =>
|
|
139
|
-
loadFromWorkerData: (e) =>
|
|
140
|
-
loadFromPrecomputedGroups: (e) =>
|
|
141
|
-
clear: () =>
|
|
142
|
-
resetView: () =>
|
|
143
|
-
setOptions: (e) =>
|
|
144
|
-
setProjectionMode: (e) =>
|
|
145
|
-
setBitPosition: (e) =>
|
|
146
|
-
setBitVisible: (e) =>
|
|
147
|
-
getSVGElement: () =>
|
|
148
|
-
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:
|
|
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-
|
|
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