@chestnutlabs/gcode-preview-vue 0.3.0 → 0.5.0
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.
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* and staying pure TypeScript keeps the package on the plain tsc build with typed props/emits.
|
|
11
11
|
*/
|
|
12
12
|
import { type PropType } from 'vue';
|
|
13
|
-
import type { BuildVolumeDef, CameraMode, ColorMode, QualityMode, Theme, TubeOptions } from '@chestnutlabs/gcode-renderer-three';
|
|
13
|
+
import type { BuildVolumeDef, CameraMode, CameraState, CameraView, ColorMode, QualityMode, Theme, TubeOptions } from '@chestnutlabs/gcode-renderer-three';
|
|
14
|
+
import type { Confidence, Warning } from '@chestnutlabs/toolpath-core';
|
|
14
15
|
import type { MachineGeometry, ProgressObservation } from '@chestnutlabs/toolpath-core';
|
|
15
16
|
import type { WireParseOptions, WorkerLike } from '@chestnutlabs/gcode-parser';
|
|
16
17
|
import { type RendererMode, type UseGcodePreviewOptions } from './use-gcode-preview.js';
|
|
@@ -49,6 +50,16 @@ export declare const GcodePreview: import("vue").DefineComponent<import("vue").E
|
|
|
49
50
|
type: PropType<CameraMode>;
|
|
50
51
|
default: string;
|
|
51
52
|
};
|
|
53
|
+
/** #268/#275/M6: snap to a preset orientation (top/front/iso/…). */
|
|
54
|
+
view: {
|
|
55
|
+
type: PropType<CameraView>;
|
|
56
|
+
default: undefined;
|
|
57
|
+
};
|
|
58
|
+
/** #268/#275/M6: restore a saved camera pose. Pair with `@camera-change` for a two-way binding. */
|
|
59
|
+
cameraState: {
|
|
60
|
+
type: PropType<CameraState | null>;
|
|
61
|
+
default: undefined;
|
|
62
|
+
};
|
|
52
63
|
/** #153 (DD-009 D4): bounded declarative theme. */
|
|
53
64
|
theme: {
|
|
54
65
|
type: PropType<Theme>;
|
|
@@ -114,7 +125,10 @@ export declare const GcodePreview: import("vue").DefineComponent<import("vue").E
|
|
|
114
125
|
segments: number;
|
|
115
126
|
layers: number;
|
|
116
127
|
complete: boolean;
|
|
128
|
+
capabilities: Record<string, Confidence>;
|
|
129
|
+
warnings: readonly Warning[];
|
|
117
130
|
}) => true;
|
|
131
|
+
'camera-change': (_state: CameraState) => true;
|
|
118
132
|
'parse-error': (_e: {
|
|
119
133
|
code: string;
|
|
120
134
|
message: string;
|
|
@@ -178,6 +192,16 @@ export declare const GcodePreview: import("vue").DefineComponent<import("vue").E
|
|
|
178
192
|
type: PropType<CameraMode>;
|
|
179
193
|
default: string;
|
|
180
194
|
};
|
|
195
|
+
/** #268/#275/M6: snap to a preset orientation (top/front/iso/…). */
|
|
196
|
+
view: {
|
|
197
|
+
type: PropType<CameraView>;
|
|
198
|
+
default: undefined;
|
|
199
|
+
};
|
|
200
|
+
/** #268/#275/M6: restore a saved camera pose. Pair with `@camera-change` for a two-way binding. */
|
|
201
|
+
cameraState: {
|
|
202
|
+
type: PropType<CameraState | null>;
|
|
203
|
+
default: undefined;
|
|
204
|
+
};
|
|
181
205
|
/** #153 (DD-009 D4): bounded declarative theme. */
|
|
182
206
|
theme: {
|
|
183
207
|
type: PropType<Theme>;
|
|
@@ -246,7 +270,10 @@ export declare const GcodePreview: import("vue").DefineComponent<import("vue").E
|
|
|
246
270
|
segments: number;
|
|
247
271
|
layers: number;
|
|
248
272
|
complete: boolean;
|
|
273
|
+
capabilities: Record<string, Confidence>;
|
|
274
|
+
warnings: readonly Warning[];
|
|
249
275
|
}) => any) | undefined;
|
|
276
|
+
"onCamera-change"?: ((_state: CameraState) => any) | undefined;
|
|
250
277
|
"onParse-error"?: ((_e: {
|
|
251
278
|
code: string;
|
|
252
279
|
message: string;
|
|
@@ -282,6 +309,8 @@ export declare const GcodePreview: import("vue").DefineComponent<import("vue").E
|
|
|
282
309
|
tube: TubeOptions;
|
|
283
310
|
adjacentLayers: number;
|
|
284
311
|
parseOptions: WireParseOptions;
|
|
312
|
+
view: CameraView;
|
|
313
|
+
cameraState: CameraState | null;
|
|
285
314
|
layerRange: [number, number] | null;
|
|
286
315
|
scrub: number | null;
|
|
287
316
|
scrubTime: number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcode-preview-component.d.ts","sourceRoot":"","sources":["../src/gcode-preview-component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAA6C,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/E,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,SAAS,EACT,WAAW,EACX,KAAK,EACL,WAAW,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC;AAExE,eAAO,MAAM,YAAY;IAGrB,qFAAqF;;cAC1B,QAAQ,CAAC,kBAAkB,CAAC;;;;cACvD,QAAQ,CAAC,gBAAgB,CAAC;;;IAC1D,qGAAqG;;cACzE,QAAQ,CAAC,YAAY,CAAC;;;IAClD,uGAAuG;;cACrE,QAAQ,CAAC,MAAM,CAAC;;;IAClD,2FAA2F;;cAC5D,QAAQ,CAAC,cAAc,GAAG,eAAe,CAAC;;;;cAC9C,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC;;;IACzD,2CAA2C;;cACb,QAAQ,CAAC,UAAU,CAAC;;;IAClD,mDAAmD;;cAC1B,QAAQ,CAAC,KAAK,CAAC;;;;cACX,QAAQ,CAAC,SAAS,CAAC;;;;cACxB,QAAQ,CAAC,WAAW,CAAC;;;IAC7C,sDAAsD;;cACd,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,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C,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;;;IACzE,iFAAiF;;cACxD,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;IAChD,uEAAuE;;cAC1C,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;;;;;IAEpD,2DAA2D;;;;;IAE3D,gEAAgE;;;;;IAEhE,gEAAgE;;cACpC,QAAQ,CAAC,mBAAmB,GAAG,IAAI,CAAC;;;IAChE;sFACkF;;cAE9D,QAAQ,CAAC,MAAM,UAAU,CAAC;;;IAG9C,mFAAmF;;cAEjE,QAAQ,CACtB,IAAI,CACF,WAAW,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC,EAC/C,aAAa,GAAG,SAAS,GAAG,YAAY,GAAG,OAAO,GAAG,WAAW,GAAG,MAAM,CAC1E,CACF;;;;;;cAuBiB,MAAM;iBAAW,MAAM;;;kBAhB/B,MAAM;gBACR,MAAM;kBACJ,OAAO;sBACH,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;kBAC9B,SAAS,OAAO,EAAE;;;;cAGF,MAAM;iBAAW,MAAM;;;;wBAEV,MAAM;oBAAc,MAAM;;;kBAChC,MAAM;iBAAW,WAAW;;;cAC9B,WAAW;YAAM,WAAW;gBAAU,MAAM;;;;;cAG/B,MAAM;iBAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;wBA/BlC,UAAU;;;;;;;;;;;;;;;4EA6M/C,CAAC"}
|
|
@@ -26,6 +26,10 @@ export const GcodePreview = defineComponent({
|
|
|
26
26
|
quality: { type: String, default: 'auto' },
|
|
27
27
|
/** #150 (DD-009 D3): camera projection. */
|
|
28
28
|
cameraMode: { type: String, default: 'perspective' },
|
|
29
|
+
/** #268/#275/M6: snap to a preset orientation (top/front/iso/…). */
|
|
30
|
+
view: { type: String, default: undefined },
|
|
31
|
+
/** #268/#275/M6: restore a saved camera pose. Pair with `@camera-change` for a two-way binding. */
|
|
32
|
+
cameraState: { type: Object, default: undefined },
|
|
29
33
|
/** #153 (DD-009 D4): bounded declarative theme. */
|
|
30
34
|
theme: { type: Object, default: undefined },
|
|
31
35
|
colorMode: { type: Object, default: undefined },
|
|
@@ -58,6 +62,7 @@ export const GcodePreview = defineComponent({
|
|
|
58
62
|
emits: {
|
|
59
63
|
/* eslint-disable @typescript-eslint/no-unused-vars -- emit validators document payloads */
|
|
60
64
|
ready: (_summary) => true,
|
|
65
|
+
'camera-change': (_state) => true,
|
|
61
66
|
'parse-error': (_e) => true,
|
|
62
67
|
'parse-cancelled': () => true,
|
|
63
68
|
'parse-progress': (_p) => true,
|
|
@@ -95,7 +100,16 @@ export const GcodePreview = defineComponent({
|
|
|
95
100
|
preview.onEvent((e) => {
|
|
96
101
|
switch (e.type) {
|
|
97
102
|
case 'parse-complete':
|
|
98
|
-
emit('ready', {
|
|
103
|
+
emit('ready', {
|
|
104
|
+
segments: e.segments,
|
|
105
|
+
layers: e.layers,
|
|
106
|
+
complete: e.complete,
|
|
107
|
+
capabilities: e.capabilities,
|
|
108
|
+
warnings: e.warnings
|
|
109
|
+
});
|
|
110
|
+
break;
|
|
111
|
+
case 'camera-changed':
|
|
112
|
+
emit('camera-change', e.state);
|
|
99
113
|
break;
|
|
100
114
|
case 'parse-error':
|
|
101
115
|
emit('parse-error', { code: e.code, message: e.message });
|
|
@@ -151,6 +165,14 @@ export const GcodePreview = defineComponent({
|
|
|
151
165
|
});
|
|
152
166
|
watch(() => props.quality, (quality) => preview.controls.setQuality(quality));
|
|
153
167
|
watch(() => props.cameraMode, (mode) => preview.controls.setCameraMode(mode));
|
|
168
|
+
watch(() => props.view, (view) => {
|
|
169
|
+
if (view !== undefined)
|
|
170
|
+
preview.controls.setView(view);
|
|
171
|
+
});
|
|
172
|
+
watch(() => props.cameraState, (state) => {
|
|
173
|
+
if (state !== undefined && state !== null)
|
|
174
|
+
preview.controls.setCameraState(state);
|
|
175
|
+
});
|
|
154
176
|
watch(() => props.theme, (theme) => {
|
|
155
177
|
if (theme !== undefined)
|
|
156
178
|
preview.controls.setTheme(theme);
|
|
@@ -174,6 +196,7 @@ export const GcodePreview = defineComponent({
|
|
|
174
196
|
return () => h('canvas', {
|
|
175
197
|
ref: canvasEl,
|
|
176
198
|
style: { width: '100%', height: '100%', display: 'block', touchAction: 'none' },
|
|
199
|
+
tabindex: '0', // focusable → keyboard camera (DD-004 a11y, #275/M4)
|
|
177
200
|
'aria-label': '3D G-code toolpath preview'
|
|
178
201
|
});
|
|
179
202
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chestnutlabs/gcode-preview-vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Thin Vue 3 integration for the Chestnut Labs G-code viewer (DD-007): useGcodePreview composable + GcodePreview component over the framework-neutral parser/renderer/progress packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gcode",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"test": "vitest run"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@chestnutlabs/gcode-parser": "0.
|
|
54
|
-
"@chestnutlabs/gcode-renderer-three": "0.
|
|
55
|
-
"@chestnutlabs/toolpath-core": "0.
|
|
56
|
-
"@chestnutlabs/gcode-preview-core": "0.
|
|
53
|
+
"@chestnutlabs/gcode-parser": "0.5.0",
|
|
54
|
+
"@chestnutlabs/gcode-renderer-three": "0.5.0",
|
|
55
|
+
"@chestnutlabs/toolpath-core": "0.5.0",
|
|
56
|
+
"@chestnutlabs/gcode-preview-core": "0.5.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"vue": "^3.4.0"
|