@sienci/gviewer 0.1.16 → 0.1.17
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-Onjhdwbv.js} +233 -195
- package/dist/{GCodeSVGRenderer-BOliBeEd.cjs → GCodeSVGRenderer-_n8GbXrI.cjs} +3 -3
- package/dist/react.cjs +1 -1
- package/dist/react.js +67 -61
- package/dist/types/viewer/GCodeViewer.d.ts +32 -0
- package/dist/types/viewer/types.d.ts +8 -0
- package/dist/viewer.cjs +1 -1
- package/dist/viewer.js +1 -1
- package/package.json +1 -1
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 w=require("react"),V=require("./GCodeSVGRenderer-_n8GbXrI.cjs");function G(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=G(w),C=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 V.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)},screenToWorld(t,n,F){return e().screenToWorld(t,n,F)},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})}),g=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 V.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=g;exports.GCodeVisualizer=C;
|
package/dist/react.js
CHANGED
|
@@ -1,58 +1,64 @@
|
|
|
1
1
|
import * as o from "react";
|
|
2
|
-
import { a as
|
|
3
|
-
const
|
|
2
|
+
import { a as w, G as V } from "./GCodeSVGRenderer-Onjhdwbv.js";
|
|
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),
|
|
5
|
+
const { id: a, options: n, callbacks: l, className: m, style: d } = u, i = o.useRef(null), r = 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
|
|
11
|
-
return
|
|
12
|
-
|
|
10
|
+
const f = new w({ id: a, container: e, options: n, callbacks: l });
|
|
11
|
+
return r.current = f, () => {
|
|
12
|
+
r.current = null, f.dispose();
|
|
13
13
|
};
|
|
14
14
|
}, [a]), o.useEffect(() => {
|
|
15
15
|
var e;
|
|
16
|
-
(e =
|
|
16
|
+
(e = r.current) == null || e.setOptions(n ?? {});
|
|
17
17
|
}, [n]), o.useEffect(() => {
|
|
18
18
|
var e;
|
|
19
|
-
(e =
|
|
19
|
+
(e = r.current) == null || e.setCallbacks(l ?? {});
|
|
20
20
|
}, [l]), o.useImperativeHandle(
|
|
21
21
|
c,
|
|
22
22
|
() => {
|
|
23
23
|
const e = () => {
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
24
|
+
const t = r.current;
|
|
25
|
+
if (!t)
|
|
26
26
|
throw new Error("GCodeViewer is not ready.");
|
|
27
|
-
return
|
|
27
|
+
return t;
|
|
28
28
|
};
|
|
29
29
|
return {
|
|
30
30
|
get id() {
|
|
31
31
|
return a;
|
|
32
32
|
},
|
|
33
|
-
setCallbacks(
|
|
34
|
-
e().setCallbacks(
|
|
33
|
+
setCallbacks(t) {
|
|
34
|
+
e().setCallbacks(t);
|
|
35
35
|
},
|
|
36
|
-
snapCameraToView(
|
|
37
|
-
e().snapCameraToView(
|
|
36
|
+
snapCameraToView(t, s) {
|
|
37
|
+
e().snapCameraToView(t, s);
|
|
38
38
|
},
|
|
39
|
-
|
|
40
|
-
e().
|
|
39
|
+
setRotateEnabled(t) {
|
|
40
|
+
e().setRotateEnabled(t);
|
|
41
41
|
},
|
|
42
|
-
|
|
43
|
-
e().
|
|
42
|
+
screenToWorld(t, s, F) {
|
|
43
|
+
return e().screenToWorld(t, s, F);
|
|
44
44
|
},
|
|
45
|
-
|
|
46
|
-
e().
|
|
45
|
+
setBitPosition(t, s) {
|
|
46
|
+
e().setBitPosition(t, s);
|
|
47
47
|
},
|
|
48
|
-
|
|
49
|
-
e().
|
|
48
|
+
setBitVisible(t) {
|
|
49
|
+
e().setBitVisible(t);
|
|
50
50
|
},
|
|
51
|
-
|
|
52
|
-
e().
|
|
51
|
+
setBitSpinning(t) {
|
|
52
|
+
e().setBitSpinning(t);
|
|
53
53
|
},
|
|
54
|
-
|
|
55
|
-
e().
|
|
54
|
+
setToolpathRotationA(t) {
|
|
55
|
+
e().setToolpathRotationA(t);
|
|
56
|
+
},
|
|
57
|
+
hideUntilLine(t, s) {
|
|
58
|
+
e().hideUntilLine(t, s);
|
|
59
|
+
},
|
|
60
|
+
seekToLine(t, s) {
|
|
61
|
+
e().seekToLine(t, s);
|
|
56
62
|
},
|
|
57
63
|
showAll() {
|
|
58
64
|
e().showAll();
|
|
@@ -60,26 +66,26 @@ const C = o.forwardRef(
|
|
|
60
66
|
resetColors() {
|
|
61
67
|
e().resetColors();
|
|
62
68
|
},
|
|
63
|
-
loadFromUrl(
|
|
64
|
-
return e().loadFromUrl(
|
|
69
|
+
loadFromUrl(t, s) {
|
|
70
|
+
return e().loadFromUrl(t, s);
|
|
65
71
|
},
|
|
66
|
-
loadFromFile(
|
|
67
|
-
return e().loadFromFile(
|
|
72
|
+
loadFromFile(t) {
|
|
73
|
+
return e().loadFromFile(t);
|
|
68
74
|
},
|
|
69
|
-
loadFromText(
|
|
70
|
-
return e().loadFromText(
|
|
75
|
+
loadFromText(t) {
|
|
76
|
+
return e().loadFromText(t);
|
|
71
77
|
},
|
|
72
|
-
loadFromLines(
|
|
73
|
-
return e().loadFromLines(
|
|
78
|
+
loadFromLines(t) {
|
|
79
|
+
return e().loadFromLines(t);
|
|
74
80
|
},
|
|
75
|
-
loadFromWorkerData(
|
|
76
|
-
return e().loadFromWorkerData(
|
|
81
|
+
loadFromWorkerData(t) {
|
|
82
|
+
return e().loadFromWorkerData(t);
|
|
77
83
|
},
|
|
78
84
|
unload() {
|
|
79
85
|
e().unload();
|
|
80
86
|
},
|
|
81
|
-
setOptions(
|
|
82
|
-
e().setOptions(
|
|
87
|
+
setOptions(t) {
|
|
88
|
+
e().setOptions(t);
|
|
83
89
|
},
|
|
84
90
|
getOptions() {
|
|
85
91
|
return e().getOptions();
|
|
@@ -104,39 +110,39 @@ const C = o.forwardRef(
|
|
|
104
110
|
[a]
|
|
105
111
|
), o.createElement("div", { ref: i, className: m, style: d });
|
|
106
112
|
}
|
|
107
|
-
),
|
|
113
|
+
), R = o.forwardRef(
|
|
108
114
|
function(u, c) {
|
|
109
115
|
const { id: a, options: n, className: l, style: m } = u, d = o.useRef(null), i = o.useRef(null);
|
|
110
116
|
return o.useEffect(() => {
|
|
111
|
-
const
|
|
112
|
-
if (!
|
|
113
|
-
const e = new
|
|
117
|
+
const r = d.current;
|
|
118
|
+
if (!r) return;
|
|
119
|
+
const e = new V(r, n);
|
|
114
120
|
return i.current = e, () => {
|
|
115
121
|
i.current = null, e.dispose();
|
|
116
122
|
};
|
|
117
123
|
}, []), o.useEffect(() => {
|
|
118
|
-
var
|
|
119
|
-
n && ((
|
|
124
|
+
var r;
|
|
125
|
+
n && ((r = i.current) == null || r.setOptions(n));
|
|
120
126
|
}, [n]), o.useImperativeHandle(c, () => {
|
|
121
|
-
const
|
|
127
|
+
const r = () => {
|
|
122
128
|
const e = i.current;
|
|
123
129
|
if (!e) throw new Error("GCodeSVGRenderer is not ready.");
|
|
124
130
|
return e;
|
|
125
131
|
};
|
|
126
132
|
return {
|
|
127
|
-
loadFromLines: (e) =>
|
|
128
|
-
loadFromFile: (e) =>
|
|
129
|
-
loadFromText: (e) =>
|
|
130
|
-
loadFromWorkerData: (e) =>
|
|
131
|
-
loadFromPrecomputedGroups: (e) =>
|
|
132
|
-
clear: () =>
|
|
133
|
-
resetView: () =>
|
|
134
|
-
setOptions: (e) =>
|
|
135
|
-
setProjectionMode: (e) =>
|
|
136
|
-
setBitPosition: (e) =>
|
|
137
|
-
setBitVisible: (e) =>
|
|
138
|
-
getSVGElement: () =>
|
|
139
|
-
dispose: () =>
|
|
133
|
+
loadFromLines: (e) => r().loadFromLines(e),
|
|
134
|
+
loadFromFile: (e) => r().loadFromFile(e),
|
|
135
|
+
loadFromText: (e) => r().loadFromText(e),
|
|
136
|
+
loadFromWorkerData: (e) => r().loadFromWorkerData(e),
|
|
137
|
+
loadFromPrecomputedGroups: (e) => r().loadFromPrecomputedGroups(e),
|
|
138
|
+
clear: () => r().clear(),
|
|
139
|
+
resetView: () => r().resetView(),
|
|
140
|
+
setOptions: (e) => r().setOptions(e),
|
|
141
|
+
setProjectionMode: (e) => r().setProjectionMode(e),
|
|
142
|
+
setBitPosition: (e) => r().setBitPosition(e),
|
|
143
|
+
setBitVisible: (e) => r().setBitVisible(e),
|
|
144
|
+
getSVGElement: () => r().getSVGElement(),
|
|
145
|
+
dispose: () => r().dispose()
|
|
140
146
|
};
|
|
141
147
|
}, []), o.createElement("div", {
|
|
142
148
|
ref: d,
|
|
@@ -146,6 +152,6 @@ const C = o.forwardRef(
|
|
|
146
152
|
}
|
|
147
153
|
);
|
|
148
154
|
export {
|
|
149
|
-
|
|
150
|
-
|
|
155
|
+
R as GCodeSVGVisualizer,
|
|
156
|
+
G as GCodeVisualizer
|
|
151
157
|
};
|
|
@@ -25,6 +25,7 @@ export declare class GCodeViewer implements GCodeViewerHandle {
|
|
|
25
25
|
private toolpathStreams;
|
|
26
26
|
private toolpathCutBucketCount;
|
|
27
27
|
private toolpathRotationA;
|
|
28
|
+
private lastBitPosition;
|
|
28
29
|
private sim3dHandle;
|
|
29
30
|
private currentLines;
|
|
30
31
|
private linePositions;
|
|
@@ -47,6 +48,37 @@ export declare class GCodeViewer implements GCodeViewerHandle {
|
|
|
47
48
|
durationMs?: number;
|
|
48
49
|
distance?: number;
|
|
49
50
|
}): void;
|
|
51
|
+
/**
|
|
52
|
+
* Enable or disable orbit *rotation* while leaving pan and zoom untouched.
|
|
53
|
+
*
|
|
54
|
+
* Used to pin the camera to a fixed view (e.g. top-down) so a press-and-hold
|
|
55
|
+
* gesture is not interpreted as a rotate-drag and the picked plane stays
|
|
56
|
+
* stable under the cursor. Picking (screenToWorld) works from any camera
|
|
57
|
+
* orientation, so this is a UX lock, not a correctness requirement.
|
|
58
|
+
*/
|
|
59
|
+
setRotateEnabled(enabled: boolean): void;
|
|
60
|
+
/**
|
|
61
|
+
* Convert a viewport pixel (clientX/clientY, e.g. from a PointerEvent) into a
|
|
62
|
+
* point on a horizontal toolpath plane, in the scene's coordinate space.
|
|
63
|
+
*
|
|
64
|
+
* A ray is cast from the camera through the pixel and intersected with the
|
|
65
|
+
* plane Z = `planeZ`, which defaults to the bit's current Z so the pick lands
|
|
66
|
+
* on the plane the tool is sitting on. Returns null when the pixel is outside
|
|
67
|
+
* a laid-out canvas or the ray is parallel to the plane (no intersection).
|
|
68
|
+
*
|
|
69
|
+
* The result is in world/scene space. The toolpath root sits at the origin,
|
|
70
|
+
* so for a normal (non-rotary) file this equals the gcode work coordinate.
|
|
71
|
+
* For a rotary file the toolpath root is rotated about X, so the returned XY
|
|
72
|
+
* is not a meaningful work coordinate — callers supporting only XY moves
|
|
73
|
+
* should gate on file type.
|
|
74
|
+
*/
|
|
75
|
+
screenToWorld(clientX: number, clientY: number, options?: {
|
|
76
|
+
planeZ?: number;
|
|
77
|
+
}): {
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
z: number;
|
|
81
|
+
} | null;
|
|
50
82
|
private startSnapToView;
|
|
51
83
|
loadFromUrl(url: string, args?: {
|
|
52
84
|
signal?: AbortSignal;
|
|
@@ -140,6 +140,14 @@ export type GCodeViewerHandle = {
|
|
|
140
140
|
durationMs?: number;
|
|
141
141
|
distance?: number;
|
|
142
142
|
}): void;
|
|
143
|
+
setRotateEnabled(enabled: boolean): void;
|
|
144
|
+
screenToWorld(clientX: number, clientY: number, options?: {
|
|
145
|
+
planeZ?: number;
|
|
146
|
+
}): {
|
|
147
|
+
x: number;
|
|
148
|
+
y: number;
|
|
149
|
+
z: number;
|
|
150
|
+
} | null;
|
|
143
151
|
setBitPosition(position: GCodeViewerBitPosition, options?: {
|
|
144
152
|
immediate?: boolean;
|
|
145
153
|
}): 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-_n8GbXrI.cjs"),a={dark:{background:"#111827",opacity:.9,rapidOpacity:.3,colors:{rapid:"#0ef6ae",cutting:"#3e85c7",laser:"#a855f7",processed:"#6b7280",boundingBox:"#77a9d7",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:"#5191cc",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:"#da702c",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:"#73daca",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:"#076678",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:"#95E6CB",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",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