@gcode-viewer/plugins 0.3.0 → 0.3.1

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.
@@ -17,6 +17,8 @@ export declare class GCodeStepsBarPlugin extends Plugin {
17
17
  private slider?;
18
18
  private rail?;
19
19
  private fill?;
20
+ private rangeStartEl?;
21
+ private rangeEndEl?;
20
22
  private thumb?;
21
23
  private valueEl?;
22
24
  private minLine;
@@ -1,9 +1,13 @@
1
1
  import { i18n } from "@gcode-viewer/core";
2
2
  export declare const en: {
3
3
  currentLine: string;
4
+ startLine: string;
5
+ endLine: string;
4
6
  };
5
7
  export declare const zh: {
6
8
  currentLine: string;
9
+ startLine: string;
10
+ endLine: string;
7
11
  };
8
12
  export declare const GCODE_STEPS_BAR_I18N_NAMESPACE: "gcodeStepsBar";
9
13
  export { i18n };
@@ -1,4 +1,3 @@
1
- export * from "./axis-gizmo";
2
1
  export * from "./bottom-bar";
3
2
  export * from "./context-menu";
4
3
  export * from "./dat-gui";
@@ -1,4 +1,4 @@
1
- import type { ModelConfig, Viewer3d } from "@gcode-viewer/core";
1
+ import type { BaseViewer, ModelConfig } from "@gcode-viewer/core";
2
2
  import { IUploader, UploaderConfig } from "./IUploader";
3
3
  /**
4
4
  * @hidden
@@ -6,7 +6,7 @@ import { IUploader, UploaderConfig } from "./IUploader";
6
6
  export declare class LocalModelUploader extends IUploader {
7
7
  static readonly DEFAULT_ID = "LocalModelUploader";
8
8
  readonly defaultModelConfig: ModelConfig;
9
- constructor(viewer: Viewer3d, cfg?: UploaderConfig);
9
+ constructor(viewer: BaseViewer, cfg?: UploaderConfig);
10
10
  protected formats(): string[];
11
11
  /**
12
12
  * Uploads model files. There are several cases:
@@ -23,9 +23,9 @@ export interface PlatePluginConfig extends Partial<PluginConfig> {
23
23
  /** World Z of the plate top surface. Default `0`. */
24
24
  height?: number;
25
25
  /**
26
- * Where world XY `(0,0)` sits on the plate.
27
- * - `corner` (default): plate covers `[0, sizeX] × [0, sizeY]` (printer-style).
28
- * - `center`: plate is centered on the origin.
26
+ * Where world XY `(0,0)` sits on the plate before {@link fitToBox} offsets.
27
+ * - `corner` (default): plate covers `[offset, offset+size]` (printer-style; offset defaults to 0).
28
+ * - `center`: plate is centered on `(offsetX, offsetY)` (defaults to world origin).
29
29
  */
30
30
  origin?: "corner" | "center";
31
31
  /** Plate fill color. Default dark charcoal. */
@@ -37,10 +37,42 @@ export interface PlatePluginConfig extends Partial<PluginConfig> {
37
37
  /** Plate edge outline color. */
38
38
  edgeColor?: number;
39
39
  /**
40
- * Labeled scale marks along the origin edges, in mm from the plate min corner.
41
- * Default `[100, 200, 300]`. Pass `[]` to disable. Marks are drawn outside the plate.
40
+ * Spacing (mm) between labeled scale marks along the origin edges.
41
+ * Default `100` marks at `interval`, `2*interval`, while strictly inside each edge.
42
+ * Pass `0` to disable all labels including origin {@code 0}.
43
+ * Marks are drawn outside the plate (slicer-style rulers use {@code 0}, not {@code (0, 0)}).
42
44
  */
43
- scaleMarks?: number[];
45
+ scaleInterval?: number;
46
+ }
47
+ /**
48
+ * Options for {@link PlatePlugin.fitToBox} / {@link PlatePlugin.fitToLoadedModels}.
49
+ * Does not move models — only resizes / repositions the plate in XY.
50
+ */
51
+ export interface FitPlateOptions {
52
+ /** Padding around the model XY AABB (mm). Default `20`. */
53
+ margin?: number;
54
+ /** Minimum plate width (mm). Default `100`. */
55
+ minSizeX?: number;
56
+ /** Minimum plate depth (mm). Default `100`. */
57
+ minSizeY?: number;
58
+ /**
59
+ * Snap plate sizes up to a multiple of this value (mm). Default `10`.
60
+ * Pass `0` to disable.
61
+ */
62
+ roundTo?: number;
63
+ /**
64
+ * How the plate is placed relative to the model.
65
+ * - `frame` (default): size = XY extent + `2 * margin`; plate is centered on the model
66
+ * so the toolpath sits in the middle of the bed (equal margin on each side).
67
+ * - `coverOrigin`: keep plate corner at world `(0, 0)`; grow size to cover `box.max + margin`
68
+ * (classic printer-bed layout when GCode uses the bed corner as origin).
69
+ */
70
+ placement?: "frame" | "coverOrigin";
71
+ /**
72
+ * When true, use a square plate with side = max(sizeX, sizeY).
73
+ * Default `false`.
74
+ */
75
+ square?: boolean;
44
76
  }
45
77
  /**
46
78
  * Finite build-plate with a dark surface and anti-aliased light gray grid.
@@ -49,9 +81,12 @@ export interface PlatePluginConfig extends Partial<PluginConfig> {
49
81
  export declare class PlatePlugin extends Plugin {
50
82
  static readonly DEFAULT_ID = "PlatePlugin";
51
83
  protected readonly NAME = "BUILD_PLATE";
52
- protected cfg: Required<Pick<PlatePluginConfig, "visible" | "sizeX" | "sizeY" | "cellSize" | "majorEvery" | "height" | "origin" | "plateColor" | "gridColor" | "majorGridColor" | "edgeColor" | "scaleMarks">> & PlatePluginConfig;
84
+ protected cfg: Required<Pick<PlatePluginConfig, "visible" | "sizeX" | "sizeY" | "cellSize" | "majorEvery" | "height" | "origin" | "plateColor" | "gridColor" | "majorGridColor" | "edgeColor" | "scaleInterval">> & PlatePluginConfig;
53
85
  protected root?: THREE.Group;
54
86
  protected plateMesh?: THREE.Mesh;
87
+ /** World XY of the plate corner (`corner`) or plate center (`center`). */
88
+ protected plateOffsetX: number;
89
+ protected plateOffsetY: number;
55
90
  constructor(viewer: BaseViewer, cfg?: PlatePluginConfig);
56
91
  getSize(): {
57
92
  sizeX: number;
@@ -63,6 +98,35 @@ export declare class PlatePlugin extends Plugin {
63
98
  */
64
99
  getWorldBBox(): THREE.Box3;
65
100
  setSize(sizeX: number, sizeY: number): void;
101
+ /**
102
+ * Resize and reposition the plate so it covers {@link box} in XY.
103
+ * Does **not** move loaded models — GCode / CAD stay in world coordinates.
104
+ *
105
+ * Default {@link FitPlateOptions.placement|placement} is `frame`: the plate is sized to the
106
+ * model footprint plus margin and shifted so the model sits in the geometric center of the bed.
107
+ *
108
+ * @returns `false` if `box` is empty/invalid
109
+ */
110
+ fitToBox(box: THREE.Box3, options?: FitPlateOptions): boolean;
111
+ /**
112
+ * Fits the plate to the viewer's loaded-model bounds (`viewer.getBBox()`).
113
+ * @returns `false` if there is no valid model bbox
114
+ */
115
+ fitToLoadedModels(options?: FitPlateOptions): boolean;
116
+ /**
117
+ * Size and place the plate from a slicer build volume (mm).
118
+ * Uses corner origin at `volume.origin` (default `(0,0)`); does not move models.
119
+ */
120
+ applyBuildVolume(volume: {
121
+ size: {
122
+ x: number;
123
+ y: number;
124
+ };
125
+ origin?: {
126
+ x?: number;
127
+ y?: number;
128
+ };
129
+ }): boolean;
66
130
  getCellSize(): number;
67
131
  setCellSize(cellSize: number): void;
68
132
  getHeight(): number;
@@ -72,8 +136,9 @@ export declare class PlatePlugin extends Plugin {
72
136
  isVisible(): boolean;
73
137
  /** Rebuild geometry from the current config. */
74
138
  rebuild(): void;
75
- protected normalizedScaleMarks(sizeX: number, sizeY: number): number[];
76
- protected addScaleLabels(root: THREE.Group, marks: number[], minX: number, minY: number, z: number): void;
139
+ /** Marks at interval, 2*interval, … strictly inside `span` (capped). */
140
+ protected scaleMarksForSpan(span: number): number[];
141
+ protected addScaleLabels(root: THREE.Group, marksX: number[], marksY: number[], minX: number, minY: number, z: number): void;
77
142
  /** Flat label mesh on the XY plane (not a camera-facing sprite). */
78
143
  protected createScaleLabelMesh(text: string): THREE.Mesh;
79
144
  protected plateBounds(): {
@@ -3,10 +3,7 @@ export declare const en: {
3
3
  settings: string;
4
4
  showOutline: string;
5
5
  doubleSidedMaterials: string;
6
- showGroundGrid: string;
7
- groundGridHeight: string;
8
6
  showViewCube: string;
9
- showAxesHelper: string;
10
7
  enableGroundShadow: string;
11
8
  enableQuantization: string;
12
9
  regenGroundShadowTitle: string;
@@ -31,10 +28,7 @@ export declare const zh: {
31
28
  settings: string;
32
29
  showOutline: string;
33
30
  doubleSidedMaterials: string;
34
- showGroundGrid: string;
35
- groundGridHeight: string;
36
31
  showViewCube: string;
37
- showAxesHelper: string;
38
32
  enableGroundShadow: string;
39
33
  enableQuantization: string;
40
34
  regenGroundShadowTitle: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gcode-viewer/plugins",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "homepage": "https://dwg.thingraph.site/",
5
5
  "description": "Plugin modules for @gcode-viewer/core: measurement tools, toolbar, screenshot and more.",
6
6
  "author": "Thingraph",
@@ -1,25 +0,0 @@
1
- import { BaseViewer, Plugin, PluginConfig } from "@gcode-viewer/core";
2
- /**
3
- * AxisGizmo plugin config.
4
- */
5
- export interface AxisGizmoPluginConfig extends Partial<PluginConfig> {
6
- /**
7
- * UI element id to contain the plugin.
8
- */
9
- containerId?: string;
10
- /**
11
- * Ignores z-axis. It is useful for Viewer2d.
12
- */
13
- ignoreZAxis?: boolean;
14
- }
15
- /**
16
- * This renderer monitors the host renderer's camera, and keeps a coordinate axes
17
- * the same direction as host renderer's
18
- */
19
- export declare class AxisGizmoPlugin extends Plugin {
20
- static readonly DEFAULT_ID = "AxisGizmoPlugin";
21
- constructor(viewer: BaseViewer, cfg?: AxisGizmoPluginConfig);
22
- setVisible(visible: boolean): void;
23
- isVisible(): boolean;
24
- destroy(): void;
25
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import "./axisgizmo.scss";
2
- export * from "./AxisGizmoPlugin";