@gcode-viewer/plugins 0.3.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.
- package/README.md +26 -0
- package/dist/index.esm.js +288 -0
- package/dist/types/axis-gizmo/AxisGizmoPlugin.d.ts +25 -0
- package/dist/types/axis-gizmo/CoordinateAxes.d.ts +1 -0
- package/dist/types/axis-gizmo/index.d.ts +2 -0
- package/dist/types/bottom-bar/BottomBarPlugin.d.ts +36 -0
- package/dist/types/bottom-bar/index.d.ts +2 -0
- package/dist/types/context-menu/Constants.d.ts +34 -0
- package/dist/types/context-menu/ContextMenu.config.d.ts +2 -0
- package/dist/types/context-menu/ContextMenuPlugin.d.ts +23 -0
- package/dist/types/context-menu/Locale.d.ts +51 -0
- package/dist/types/context-menu/index.d.ts +4 -0
- package/dist/types/dat-gui/Viewer3dDatGui.d.ts +69 -0
- package/dist/types/dat-gui/index.d.ts +1 -0
- package/dist/types/explode/ExplodePlugin.d.ts +46 -0
- package/dist/types/explode/ObjectExploder.d.ts +48 -0
- package/dist/types/explode/index.d.ts +1 -0
- package/dist/types/export/ExportPlugin.d.ts +57 -0
- package/dist/types/export/Locale.d.ts +41 -0
- package/dist/types/export/gltf/GltfExporter.d.ts +32 -0
- package/dist/types/export/gltf/index.d.ts +1 -0
- package/dist/types/export/index.d.ts +2 -0
- package/dist/types/export/obj/ObjZipExporter.d.ts +14 -0
- package/dist/types/export/obj/index.d.ts +3 -0
- package/dist/types/export/obj/mtl.d.ts +9 -0
- package/dist/types/export/obj/textures.d.ts +15 -0
- package/dist/types/gcode-layer-bar/GCodeLayerBarPlugin.d.ts +66 -0
- package/dist/types/gcode-layer-bar/Locale.d.ts +13 -0
- package/dist/types/gcode-layer-bar/index.d.ts +2 -0
- package/dist/types/gcode-legend/GCodeLegendPlugin.d.ts +58 -0
- package/dist/types/gcode-legend/Locale.d.ts +83 -0
- package/dist/types/gcode-legend/NephogramLegend.d.ts +8 -0
- package/dist/types/gcode-legend/index.d.ts +2 -0
- package/dist/types/gcode-steps-bar/GCodeStepsBarPlugin.d.ts +46 -0
- package/dist/types/gcode-steps-bar/Locale.d.ts +11 -0
- package/dist/types/gcode-steps-bar/index.d.ts +2 -0
- package/dist/types/gcode-text-panel/GCodeTextPanelPlugin.d.ts +54 -0
- package/dist/types/gcode-text-panel/Locale.d.ts +11 -0
- package/dist/types/gcode-text-panel/index.d.ts +2 -0
- package/dist/types/ground-grid/GroundGridPlugin.d.ts +38 -0
- package/dist/types/ground-grid/index.d.ts +1 -0
- package/dist/types/ground-shaow/GroundShadowPlugin.d.ts +58 -0
- package/dist/types/ground-shaow/index.d.ts +1 -0
- package/dist/types/hotpoint/HotpointPlugin.d.ts +92 -0
- package/dist/types/hotpoint/index.d.ts +1 -0
- package/dist/types/index.d.ts +29 -0
- package/dist/types/local-model-uploader/IUploader.d.ts +55 -0
- package/dist/types/local-model-uploader/LocalModelUploader.d.ts +19 -0
- package/dist/types/local-model-uploader/index.d.ts +2 -0
- package/dist/types/measurements/AngleMeasureDrawable.d.ts +12 -0
- package/dist/types/measurements/AngleMeasurement.d.ts +13 -0
- package/dist/types/measurements/AreaMeasureDrawable.d.ts +14 -0
- package/dist/types/measurements/AreaMeasurement.d.ts +24 -0
- package/dist/types/measurements/BaseMeasureDrawable.d.ts +28 -0
- package/dist/types/measurements/BaseMeasurement.d.ts +123 -0
- package/dist/types/measurements/CoordinateMeasureDrawable.d.ts +10 -0
- package/dist/types/measurements/CoordinateMeasurement.d.ts +12 -0
- package/dist/types/measurements/DistanceMeasureDrawable.d.ts +13 -0
- package/dist/types/measurements/DistanceMeasurement.d.ts +21 -0
- package/dist/types/measurements/Locale.d.ts +13 -0
- package/dist/types/measurements/MeasurementPlugin.d.ts +102 -0
- package/dist/types/measurements/index.d.ts +3 -0
- package/dist/types/measurements/undo/AddMeasurementCommand.d.ts +10 -0
- package/dist/types/measurements/undo/RemoveMeasurementCommand.d.ts +10 -0
- package/dist/types/plate/PlatePlugin.d.ts +85 -0
- package/dist/types/plate/index.d.ts +1 -0
- package/dist/types/property/AnimationPanel.d.ts +3 -0
- package/dist/types/property/CameraEditor.d.ts +3 -0
- package/dist/types/property/EnvironmentPanel.d.ts +3 -0
- package/dist/types/property/LightEditor.d.ts +3 -0
- package/dist/types/property/Locale.d.ts +83 -0
- package/dist/types/property/MaterialEditor.d.ts +9 -0
- package/dist/types/property/PropertyPanelUi.d.ts +34 -0
- package/dist/types/property/PropertyPlugin.d.ts +95 -0
- package/dist/types/property/Utils.d.ts +19 -0
- package/dist/types/property/Vec3Field.d.ts +25 -0
- package/dist/types/property/index.d.ts +2 -0
- package/dist/types/rhino-3dm-loader/Rhino3dmLoaderPlugin.d.ts +17 -0
- package/dist/types/rhino-3dm-loader/Rhino3dmModelLoader.d.ts +25 -0
- package/dist/types/rhino-3dm-loader/index.d.ts +1 -0
- package/dist/types/scene-edit/SceneEditActions.d.ts +24 -0
- package/dist/types/scene-edit/SceneEditPlugin.d.ts +26 -0
- package/dist/types/scene-edit/SceneEditRecording.d.ts +11 -0
- package/dist/types/scene-edit/SceneMeshSnapshot.d.ts +23 -0
- package/dist/types/scene-edit/SceneMeshSnapshotUtils.d.ts +11 -0
- package/dist/types/scene-edit/SceneNodeSnapshot.d.ts +7 -0
- package/dist/types/scene-edit/SceneNodeSnapshotUtils.d.ts +11 -0
- package/dist/types/scene-edit/commands/GeometryEditCommand.d.ts +10 -0
- package/dist/types/scene-edit/commands/InsertSceneNodeCommand.d.ts +10 -0
- package/dist/types/scene-edit/commands/MaterialEditCommand.d.ts +10 -0
- package/dist/types/scene-edit/commands/MoveSceneNodeCommand.d.ts +10 -0
- package/dist/types/scene-edit/commands/RemoveSceneObjectCommand.d.ts +9 -0
- package/dist/types/scene-edit/commands/TransformSceneObjectCommand.d.ts +17 -0
- package/dist/types/scene-edit/index.d.ts +13 -0
- package/dist/types/screenshot/ScreenshotPlugin.d.ts +134 -0
- package/dist/types/screenshot/index.d.ts +1 -0
- package/dist/types/sections/AxisPlaneSection.d.ts +65 -0
- package/dist/types/sections/AxisSectionPopPanel.d.ts +18 -0
- package/dist/types/sections/BaseSection.d.ts +64 -0
- package/dist/types/sections/Locale.d.ts +21 -0
- package/dist/types/sections/ObjectsBoxSection.d.ts +29 -0
- package/dist/types/sections/PickPlaneSection.d.ts +48 -0
- package/dist/types/sections/PickSectionPopPanel.d.ts +18 -0
- package/dist/types/sections/Section.constants.d.ts +13 -0
- package/dist/types/sections/SectionGizmo.d.ts +22 -0
- package/dist/types/sections/SectionPlaneMesh.d.ts +23 -0
- package/dist/types/sections/SectionPlugin.d.ts +147 -0
- package/dist/types/sections/index.d.ts +6 -0
- package/dist/types/settings-3d/Locale.d.ts +61 -0
- package/dist/types/settings-3d/Settings3dPlugin.d.ts +46 -0
- package/dist/types/settings-3d/index.d.ts +2 -0
- package/dist/types/skybox/GradientColorSkybox.d.ts +9 -0
- package/dist/types/skybox/SkyboxPlugin.d.ts +48 -0
- package/dist/types/skybox/index.d.ts +1 -0
- package/dist/types/stats/StatsPlugin.d.ts +18 -0
- package/dist/types/stats/index.d.ts +2 -0
- package/dist/types/step-loader/OcctImportScriptLoader.d.ts +22 -0
- package/dist/types/step-loader/StepLoaderPlugin.d.ts +22 -0
- package/dist/types/step-loader/StepModelLoader.d.ts +39 -0
- package/dist/types/step-loader/index.d.ts +3 -0
- package/dist/types/step-loader/occtMeshBuilder.d.ts +35 -0
- package/dist/types/toolbars/Locale.d.ts +57 -0
- package/dist/types/toolbars/Toolbar.config.d.ts +5 -0
- package/dist/types/toolbars/Toolbar.constants.d.ts +71 -0
- package/dist/types/toolbars/Toolbar.d.ts +112 -0
- package/dist/types/toolbars/Viewer3dToolbarPlugin.d.ts +37 -0
- package/dist/types/toolbars/index.d.ts +5 -0
- package/dist/types/transform/Locale.d.ts +21 -0
- package/dist/types/transform/TransformPlugin.d.ts +38 -0
- package/dist/types/transform/index.d.ts +1 -0
- package/dist/types/tree-view/Locale.d.ts +29 -0
- package/dist/types/tree-view/TreeNodeTypeIcons.d.ts +15 -0
- package/dist/types/tree-view/TreeViewDragDrop.d.ts +17 -0
- package/dist/types/tree-view/TreeViewPlugin.d.ts +66 -0
- package/dist/types/tree-view/index.d.ts +2 -0
- package/dist/types/view-cube/Locale.d.ts +21 -0
- package/dist/types/view-cube/ViewCube.d.ts +86 -0
- package/dist/types/view-cube/ViewCubePlugin.d.ts +20 -0
- package/dist/types/view-cube/index.d.ts +2 -0
- package/package.json +73 -0
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IconClass, BaseViewer, Plugin } from "@gcode-viewer/core";
|
|
2
|
+
import { Tooltip } from "@gcode-viewer/ui";
|
|
3
|
+
declare enum BottomBarItemId {
|
|
4
|
+
statistics = "gcode-viewer-threejs-statistics",
|
|
5
|
+
cameraCfg = "gcode-viewer-threejs-cameraCfg",
|
|
6
|
+
tips = "gcode-viewer-threejs-tips"
|
|
7
|
+
}
|
|
8
|
+
interface BottomBarItemConfig {
|
|
9
|
+
icon: IconClass;
|
|
10
|
+
mutexIds?: BottomBarItemId[];
|
|
11
|
+
onActive?: (item: BottomBarItem) => void;
|
|
12
|
+
onDeactive?: (item: BottomBarItem) => void;
|
|
13
|
+
onClick?: (item: BottomBarItem) => void;
|
|
14
|
+
onUpdate?: (item: BottomBarItem) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Bottom bar plugin is a debug tool for developers.
|
|
18
|
+
*/
|
|
19
|
+
export declare class BottomBarPlugin extends Plugin {
|
|
20
|
+
itemList: Map<string, BottomBarItem>;
|
|
21
|
+
constructor(viewer: BaseViewer);
|
|
22
|
+
update(): void;
|
|
23
|
+
}
|
|
24
|
+
declare class BottomBarItem {
|
|
25
|
+
readonly viewer: BaseViewer;
|
|
26
|
+
private readonly bottomBar;
|
|
27
|
+
protected readonly menuId: string;
|
|
28
|
+
protected cfg: BottomBarItemConfig;
|
|
29
|
+
tooltip: Tooltip;
|
|
30
|
+
element: HTMLElement;
|
|
31
|
+
active: boolean;
|
|
32
|
+
constructor(viewer: BaseViewer, bottomBar: BottomBarPlugin, menuId: string, cfg: BottomBarItemConfig);
|
|
33
|
+
setActive(active: boolean): void;
|
|
34
|
+
update(): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BaseViewer } from "@gcode-viewer/core";
|
|
2
|
+
import type { AxisPlaneSection, ObjectsBoxSection, PickPlaneSection } from "../sections";
|
|
3
|
+
import type { Toolbar } from "../toolbars";
|
|
4
|
+
/**
|
|
5
|
+
* Context for ContextMenu
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
export interface Context {
|
|
9
|
+
viewer: BaseViewer;
|
|
10
|
+
hit?: any;
|
|
11
|
+
instanceId?: number;
|
|
12
|
+
batchId?: number;
|
|
13
|
+
/**
|
|
14
|
+
* For Viewer3d
|
|
15
|
+
* @hidden
|
|
16
|
+
*/
|
|
17
|
+
section?: ObjectsBoxSection | PickPlaneSection | AxisPlaneSection;
|
|
18
|
+
toolbar?: Toolbar;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @hidden
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
export interface ContextMenuItem {
|
|
27
|
+
title?: string;
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
shown?: boolean;
|
|
30
|
+
getTitle?: (context: Context) => string;
|
|
31
|
+
getEnabled?: (context: Context) => boolean;
|
|
32
|
+
getShown?: (context: Context) => boolean;
|
|
33
|
+
doAction?: (context: Context) => void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type BaseViewer, Plugin, PluginConfig } from "@gcode-viewer/core";
|
|
2
|
+
import { Context, ContextMenuItem } from "./Constants";
|
|
3
|
+
/**
|
|
4
|
+
* Context menu plugin config.
|
|
5
|
+
*/
|
|
6
|
+
export type ContextMenuPluginConfig = Partial<PluginConfig>;
|
|
7
|
+
/**
|
|
8
|
+
* Context menu plugin.
|
|
9
|
+
* Can be used by Viewer3d.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ContextMenuPlugin extends Plugin {
|
|
12
|
+
static readonly DEFAULT_ID = "ContextMenuPlugin";
|
|
13
|
+
protected cfg: ContextMenuPluginConfig;
|
|
14
|
+
protected container: HTMLElement;
|
|
15
|
+
protected element: HTMLDivElement;
|
|
16
|
+
protected context: Context;
|
|
17
|
+
protected itemList: [ContextMenuItem, HTMLElement][];
|
|
18
|
+
constructor(viewer: BaseViewer, cfg?: ContextMenuPluginConfig);
|
|
19
|
+
protected handleClick: () => void;
|
|
20
|
+
show(pageX: number, pageY: number): void;
|
|
21
|
+
hide(): void;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { i18n } from "@gcode-viewer/core";
|
|
2
|
+
export declare const en: {
|
|
3
|
+
viewFitAll: string;
|
|
4
|
+
hideAll: string;
|
|
5
|
+
showAll: string;
|
|
6
|
+
xRayAll: string;
|
|
7
|
+
xRayNone: string;
|
|
8
|
+
selectNone: string;
|
|
9
|
+
resetView: string;
|
|
10
|
+
viewFitEntity: string;
|
|
11
|
+
hideEntity: string;
|
|
12
|
+
hideOthers: string;
|
|
13
|
+
xRayEntity: string;
|
|
14
|
+
xRayOthers: string;
|
|
15
|
+
select: string;
|
|
16
|
+
deselect: string;
|
|
17
|
+
showSectionPlane: string;
|
|
18
|
+
showSectionBox: string;
|
|
19
|
+
showAxisSection: string;
|
|
20
|
+
hideSectionPlane: string;
|
|
21
|
+
hideSectionBox: string;
|
|
22
|
+
hideAxisSection: string;
|
|
23
|
+
undoSection: string;
|
|
24
|
+
};
|
|
25
|
+
export declare const zh: {
|
|
26
|
+
viewFitAll: string;
|
|
27
|
+
hideAll: string;
|
|
28
|
+
showAll: string;
|
|
29
|
+
xRayAll: string;
|
|
30
|
+
xRayNone: string;
|
|
31
|
+
selectNone: string;
|
|
32
|
+
resetView: string;
|
|
33
|
+
viewFitEntity: string;
|
|
34
|
+
hideEntity: string;
|
|
35
|
+
hideOthers: string;
|
|
36
|
+
xRayEntity: string;
|
|
37
|
+
xRayOthers: string;
|
|
38
|
+
select: string;
|
|
39
|
+
deselect: string;
|
|
40
|
+
showSectionPlane: string;
|
|
41
|
+
showSectionBox: string;
|
|
42
|
+
showAxisSection: string;
|
|
43
|
+
hideSectionPlane: string;
|
|
44
|
+
hideSectionBox: string;
|
|
45
|
+
hideAxisSection: string;
|
|
46
|
+
undoSection: string;
|
|
47
|
+
};
|
|
48
|
+
export declare const CONTEXT_MENU_I18N_NAMESPACE: "contextMenu";
|
|
49
|
+
export { i18n };
|
|
50
|
+
export type ContextMenuTranslationKey = keyof typeof en;
|
|
51
|
+
export declare function t(translateKey: ContextMenuTranslationKey | string): string;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Plugin, Viewer3d } from "@gcode-viewer/core";
|
|
2
|
+
import * as dat from "dat.gui";
|
|
3
|
+
/**
|
|
4
|
+
* Can be used by Viewer3d.
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
export declare class Viewer3dDatGuiPlugin extends Plugin {
|
|
8
|
+
protected viewer: Viewer3d;
|
|
9
|
+
gui?: dat.GUI;
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param viewer pass in the Viewer3D, so we can reference its data members
|
|
13
|
+
*/
|
|
14
|
+
constructor(viewer: Viewer3d);
|
|
15
|
+
/**
|
|
16
|
+
* Defined all controls here, which will be displyed in dat.GUI
|
|
17
|
+
* Color should follow these formats:
|
|
18
|
+
* '#ffffff', [0, 0, 0], [0, 0, 0, 0.5], \{ h: 100, s: 0.9, v: 0.3 \}
|
|
19
|
+
*/
|
|
20
|
+
readonly controls: {
|
|
21
|
+
showGroundGrid: boolean;
|
|
22
|
+
environments: string[];
|
|
23
|
+
homeView: () => void;
|
|
24
|
+
views: string[];
|
|
25
|
+
OrthographicCamera: boolean;
|
|
26
|
+
viewpoints: boolean;
|
|
27
|
+
annotations: boolean;
|
|
28
|
+
takeSnapshot: () => void;
|
|
29
|
+
takeSnapshotForViewerBBox: () => void;
|
|
30
|
+
fullScreen: () => void;
|
|
31
|
+
webcam: boolean;
|
|
32
|
+
uploadFile: () => void;
|
|
33
|
+
showTreeView: boolean;
|
|
34
|
+
showPropertyPanel: boolean;
|
|
35
|
+
transparentMode: boolean;
|
|
36
|
+
enableOutline: boolean;
|
|
37
|
+
doubleSidedMaterial: boolean;
|
|
38
|
+
showVertexNormals: boolean;
|
|
39
|
+
explode: number;
|
|
40
|
+
sectionMode: string[];
|
|
41
|
+
alVisible: boolean;
|
|
42
|
+
alColor: string;
|
|
43
|
+
alIntensity: number;
|
|
44
|
+
dlColor: string;
|
|
45
|
+
showDlHelper: boolean;
|
|
46
|
+
hlVisible: boolean;
|
|
47
|
+
hlIntensity: number;
|
|
48
|
+
hlColor: number[];
|
|
49
|
+
hlGroundColor: number[];
|
|
50
|
+
fogEnabled: boolean;
|
|
51
|
+
fogColor: number;
|
|
52
|
+
fogNearDistance: number;
|
|
53
|
+
fogFarDistance: number;
|
|
54
|
+
distanceCullingFactor: number;
|
|
55
|
+
errorTarget: number;
|
|
56
|
+
ssao_output: string;
|
|
57
|
+
ssao_kernelRadius: number;
|
|
58
|
+
ssao_minDistance: number;
|
|
59
|
+
ssao_maxDistance: number;
|
|
60
|
+
ssao_enable: boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Init dat.GUI
|
|
64
|
+
*/
|
|
65
|
+
init(): void;
|
|
66
|
+
open(): void;
|
|
67
|
+
close(): void;
|
|
68
|
+
destroy(): void;
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Viewer3dDatGui";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { THREE, BaseViewer, Plugin, PluginConfig } from "@gcode-viewer/core";
|
|
2
|
+
import { ObjectExploder } from "./ObjectExploder";
|
|
3
|
+
export interface ExplodePluginConfig extends Partial<PluginConfig> {
|
|
4
|
+
/**
|
|
5
|
+
* Explode center.
|
|
6
|
+
* If specified, each object explode based on this position. Otherwise,
|
|
7
|
+
* each object explode based on its own center.
|
|
8
|
+
*/
|
|
9
|
+
explodeCenter?: THREE.Vector3;
|
|
10
|
+
/**
|
|
11
|
+
* By default, it explodes to every direction. In some scenarios, user may want to
|
|
12
|
+
* explode only in up/down direction.
|
|
13
|
+
*/
|
|
14
|
+
explodeUp?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Exploder class is used to explode objects in a viewer.
|
|
18
|
+
* Can be used by Viewer3d.
|
|
19
|
+
* @hidden
|
|
20
|
+
*/
|
|
21
|
+
export declare class ExplodePlugin extends Plugin {
|
|
22
|
+
static readonly DEFAULT_ID = "ExplodePlugin";
|
|
23
|
+
protected cfg: ExplodePluginConfig;
|
|
24
|
+
protected exploders: ObjectExploder[];
|
|
25
|
+
constructor(viewer: BaseViewer, cfg?: ExplodePluginConfig);
|
|
26
|
+
get scene(): THREE.Scene;
|
|
27
|
+
/**
|
|
28
|
+
* Initialize the
|
|
29
|
+
*/
|
|
30
|
+
init(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Explode objects
|
|
33
|
+
* @param scale 1 means do not explode at all, recommended value between 1-5.
|
|
34
|
+
*/
|
|
35
|
+
explode(scale: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Unexplode objects
|
|
38
|
+
*/
|
|
39
|
+
unexplode(): void;
|
|
40
|
+
protected onModelLoaded: () => void;
|
|
41
|
+
/**
|
|
42
|
+
* Checks if exploder already exists for a model/object.
|
|
43
|
+
*/
|
|
44
|
+
protected hasExploderForModel(modelObjectId: number): boolean;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { THREE } from "@gcode-viewer/core";
|
|
2
|
+
/**
|
|
3
|
+
* ObjectExploder class is used to explode an object
|
|
4
|
+
* @hidden
|
|
5
|
+
*/
|
|
6
|
+
export declare class ObjectExploder {
|
|
7
|
+
private scene;
|
|
8
|
+
objectId: number;
|
|
9
|
+
explodeCenter: THREE.Vector3;
|
|
10
|
+
private scale;
|
|
11
|
+
private explodeUp;
|
|
12
|
+
/**
|
|
13
|
+
* Constructor of Explode
|
|
14
|
+
* @param objectId target object id, that is going to be exploded
|
|
15
|
+
* @param explodeCenter if undefined, will explode object by its center
|
|
16
|
+
* @param scale scale factor, 1 means 1 time farer away from exploder's position
|
|
17
|
+
*/
|
|
18
|
+
constructor(scene: THREE.Scene, objectId: number, explodeCenter?: THREE.Vector3 | undefined);
|
|
19
|
+
/**
|
|
20
|
+
* Explodes the object
|
|
21
|
+
*/
|
|
22
|
+
explode(scale: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Explodes a parent or leaf object.
|
|
25
|
+
* If an object has both geometry and children, we'll move itself
|
|
26
|
+
* and we shouldn't move its children again.
|
|
27
|
+
*/
|
|
28
|
+
private explodeObject;
|
|
29
|
+
/**
|
|
30
|
+
* Explodes a leaf object (that has geometry, and ususally no children).
|
|
31
|
+
* It doesn't support THREE.InstancedMesh.
|
|
32
|
+
*/
|
|
33
|
+
private explodeLeafObject;
|
|
34
|
+
/**
|
|
35
|
+
* Unexplodes the object
|
|
36
|
+
*/
|
|
37
|
+
unexplode(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Unexplodes a parent or leaf object
|
|
40
|
+
*/
|
|
41
|
+
private unexplodeObject;
|
|
42
|
+
/**
|
|
43
|
+
* Unexplodes a leaf object
|
|
44
|
+
*/
|
|
45
|
+
private unexplodeLeafObject;
|
|
46
|
+
setExplodeUp(explodeUp: boolean): void;
|
|
47
|
+
private getObjectCenter;
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ExplodePlugin";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { THREE, BaseViewer, Plugin, PluginConfig, Viewer3d, THREEAddons } from "@gcode-viewer/core";
|
|
2
|
+
import { BasePanel } from "@gcode-viewer/ui";
|
|
3
|
+
export declare enum ExportFormats {
|
|
4
|
+
Glb = "glb",
|
|
5
|
+
Gltf = "gltf",
|
|
6
|
+
Obj = "obj",
|
|
7
|
+
Stl = "stl",
|
|
8
|
+
Ply = "ply"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Export plugin config.
|
|
12
|
+
*/
|
|
13
|
+
export type ExportPluginConfig = Partial<PluginConfig>;
|
|
14
|
+
/**
|
|
15
|
+
* Export plugin is used to export scene to a 3d model.
|
|
16
|
+
* @description
|
|
17
|
+
*/
|
|
18
|
+
export declare class ExportPlugin extends Plugin {
|
|
19
|
+
static readonly DEFAULT_ID = "ExportPlugin";
|
|
20
|
+
protected cfg: ExportPluginConfig;
|
|
21
|
+
protected basePanel?: BasePanel;
|
|
22
|
+
protected viewer3d: Viewer3d;
|
|
23
|
+
constructor(viewer: BaseViewer, cfg?: ExportPluginConfig);
|
|
24
|
+
private readonly onLanguageChange;
|
|
25
|
+
private applyLocalizedChrome;
|
|
26
|
+
/**
|
|
27
|
+
* Exports to gltf or glb format.
|
|
28
|
+
* @param filename pure filename without extension.
|
|
29
|
+
* @param options GLTFExporter options.
|
|
30
|
+
* @param targetObject optional specific object to export; defaults to all loaded models.
|
|
31
|
+
* @param quantize when true, geometry attributes are quantized via KHR_mesh_quantization
|
|
32
|
+
* (POSITION→Int16, NORMAL→Int8, UV→Uint16) to reduce file size by ~30–50 %.
|
|
33
|
+
* Forces `trs: false` (matrix mode) so per-mesh decode matrices are written correctly.
|
|
34
|
+
*/
|
|
35
|
+
exportGltf(filename: string, options?: THREEAddons.GLTFExporterOptions, targetObject?: THREE.Object3D | null, quantize?: boolean): void;
|
|
36
|
+
/**
|
|
37
|
+
* Exports to OBJ format.
|
|
38
|
+
* @param filename pure filename without extension.
|
|
39
|
+
*/
|
|
40
|
+
exportObj(filename: string, targetObject?: THREE.Object3D | null): void;
|
|
41
|
+
exportStl(filename: string, targetObject?: THREE.Object3D | null): void;
|
|
42
|
+
exportPly(filename: string, binary?: boolean, targetObject?: THREE.Object3D | null): void;
|
|
43
|
+
/**
|
|
44
|
+
* Shows the export options panel.
|
|
45
|
+
*/
|
|
46
|
+
showExportPanel(targetFormat?: ExportFormats, filename?: string, targetObject?: THREE.Object3D | null): void;
|
|
47
|
+
private normalizeExportBaseName;
|
|
48
|
+
/**
|
|
49
|
+
* Saves/downloads a blob as a file.
|
|
50
|
+
* @param blob The blob to save.
|
|
51
|
+
* @param filename The filename (with extension) to save as.
|
|
52
|
+
*/
|
|
53
|
+
saveBlobAsFile(blob: Blob, filename: string): void;
|
|
54
|
+
saveStringAsFile(text: string, filename: string): void;
|
|
55
|
+
saveArrayBufferAsFile: (buffer: ArrayBuffer, filename: string) => void;
|
|
56
|
+
destroy(): void;
|
|
57
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { i18n } from "@gcode-viewer/core";
|
|
2
|
+
export declare const en: {
|
|
3
|
+
export: string;
|
|
4
|
+
format: string;
|
|
5
|
+
fileName: string;
|
|
6
|
+
embedTextures: string;
|
|
7
|
+
embedGeometry: string;
|
|
8
|
+
useTrsTransforms: string;
|
|
9
|
+
visibleObjects: string;
|
|
10
|
+
customExtensions: string;
|
|
11
|
+
quantizeGeometry: string;
|
|
12
|
+
binary: string;
|
|
13
|
+
exportButton: string;
|
|
14
|
+
formatObj: string;
|
|
15
|
+
formatStl: string;
|
|
16
|
+
formatPly: string;
|
|
17
|
+
formatGltf: string;
|
|
18
|
+
formatGlb: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const zh: {
|
|
21
|
+
export: string;
|
|
22
|
+
format: string;
|
|
23
|
+
fileName: string;
|
|
24
|
+
embedTextures: string;
|
|
25
|
+
embedGeometry: string;
|
|
26
|
+
useTrsTransforms: string;
|
|
27
|
+
visibleObjects: string;
|
|
28
|
+
customExtensions: string;
|
|
29
|
+
quantizeGeometry: string;
|
|
30
|
+
binary: string;
|
|
31
|
+
exportButton: string;
|
|
32
|
+
formatObj: string;
|
|
33
|
+
formatStl: string;
|
|
34
|
+
formatPly: string;
|
|
35
|
+
formatGltf: string;
|
|
36
|
+
formatGlb: string;
|
|
37
|
+
};
|
|
38
|
+
export declare const EXPORT_I18N_NAMESPACE: "export";
|
|
39
|
+
export { i18n };
|
|
40
|
+
export type ExportTranslationKey = keyof typeof en;
|
|
41
|
+
export declare function t(key: ExportTranslationKey): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { THREE, THREEAddons } from "@gcode-viewer/core";
|
|
2
|
+
export declare const DefaultGltfExportOptions: THREEAddons.GLTFExporterOptions;
|
|
3
|
+
/**
|
|
4
|
+
* Wraps `THREEAddons.GLTFExporter` with optional KHR_mesh_quantization pre-processing.
|
|
5
|
+
*/
|
|
6
|
+
export declare class GltfExporter {
|
|
7
|
+
/**
|
|
8
|
+
* Exports `objects` to GLB / GLTF.
|
|
9
|
+
*
|
|
10
|
+
* When `quantize` is true, geometry attributes are converted before export:
|
|
11
|
+
* - POSITION : Float32 → Int16 normalized; decode matrix is baked into each
|
|
12
|
+
* mesh's node matrix (requires `trs: false`, enforced automatically).
|
|
13
|
+
* - NORMAL : Float32 → Int8 normalized (75 % smaller per vertex)
|
|
14
|
+
* - UV attrs : Float32 → Uint16 normalized (50 % smaller, [0,1] range only)
|
|
15
|
+
*
|
|
16
|
+
* Geometry deduplication is preserved: meshes that shared the same BufferGeometry
|
|
17
|
+
* will still share the same quantized clone, so shared geometry is only written once.
|
|
18
|
+
*/
|
|
19
|
+
parse(objects: THREE.Object3D[], options: THREEAddons.GLTFExporterOptions, onDone: (result: ArrayBuffer | object) => void, onError: (error: ErrorEvent) => void, quantize?: boolean): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Clone `objects` and quantize their geometry attributes.
|
|
23
|
+
* Returns `{ clones, dispose }`. Call `dispose()` after the export finishes.
|
|
24
|
+
*
|
|
25
|
+
* Geometry deduplication is preserved: meshes that shared the same BufferGeometry
|
|
26
|
+
* before cloning will still share the same quantized BufferGeometry afterward,
|
|
27
|
+
* so the GLTFExporter writes each unique geometry only once.
|
|
28
|
+
*/
|
|
29
|
+
export declare function quantizeObjectsForGltf(objects: THREE.Object3D[]): {
|
|
30
|
+
clones: THREE.Object3D[];
|
|
31
|
+
dispose: () => void;
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./GltfExporter";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { THREE } from "@gcode-viewer/core";
|
|
2
|
+
import { type ExportedTextureFile } from "./textures";
|
|
3
|
+
export type ObjZipExportResult = {
|
|
4
|
+
objFilename: string;
|
|
5
|
+
objText: string;
|
|
6
|
+
mtlFilename: string | null;
|
|
7
|
+
mtlText: string | null;
|
|
8
|
+
textureFiles: ExportedTextureFile[];
|
|
9
|
+
};
|
|
10
|
+
export declare class ObjZipExporter {
|
|
11
|
+
exportSync(root: THREE.Object3D, _baseName: string): string;
|
|
12
|
+
export(root: THREE.Object3D, baseName: string): Promise<ObjZipExportResult>;
|
|
13
|
+
private injectMtllib;
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { THREE } from "@gcode-viewer/core";
|
|
2
|
+
import type { ExportedTextureFile } from "./textures";
|
|
3
|
+
export type MtlTextureBindings = Partial<Record<"map_Kd", ExportedTextureFile>>;
|
|
4
|
+
export declare function getMaterialName(material: THREE.Material, fallbackIndex: number): string;
|
|
5
|
+
/**
|
|
6
|
+
* Minimal MTL writer: writes Kd (color), opacity (d) and optional map_Kd.
|
|
7
|
+
* Writes fields only if source data exists.
|
|
8
|
+
*/
|
|
9
|
+
export declare function writeMtl(materials: THREE.Material[], materialToTextures: Map<THREE.Material, MtlTextureBindings>): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { THREE } from "@gcode-viewer/core";
|
|
2
|
+
export type TextureUsage = "map" | "normalMap" | "alphaMap" | "emissiveMap" | "roughnessMap" | "metalnessMap";
|
|
3
|
+
export type CollectedTexture = {
|
|
4
|
+
usage: TextureUsage;
|
|
5
|
+
texture: THREE.Texture;
|
|
6
|
+
};
|
|
7
|
+
export type ExportedTextureFile = {
|
|
8
|
+
key: string;
|
|
9
|
+
usage: TextureUsage;
|
|
10
|
+
filename: string;
|
|
11
|
+
blob: Blob;
|
|
12
|
+
};
|
|
13
|
+
export declare function collectTexturesFromObject(root: THREE.Object3D): CollectedTexture[];
|
|
14
|
+
export declare function textureToBlob(texture: THREE.Texture, preferMime?: string): Promise<Blob | null>;
|
|
15
|
+
export declare function exportTextureFiles(textures: CollectedTexture[], baseDir?: string): Promise<ExportedTextureFile[]>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { BaseViewer, Plugin, PluginConfig } from "@gcode-viewer/core";
|
|
2
|
+
export interface GCodeLayerBarPluginConfig extends Partial<PluginConfig> {
|
|
3
|
+
/**
|
|
4
|
+
* UI element id to contain the plugin. When omitted, the viewer widget container is used.
|
|
5
|
+
*/
|
|
6
|
+
containerId?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Vertical layer range bar for {@link GCodeViewer}.
|
|
10
|
+
*/
|
|
11
|
+
export declare class GCodeLayerBarPlugin extends Plugin {
|
|
12
|
+
static readonly DEFAULT_ID = "GCodeLayerBarPlugin";
|
|
13
|
+
private readonly cfg;
|
|
14
|
+
private readonly gcodeViewer?;
|
|
15
|
+
private root?;
|
|
16
|
+
private maxLabel?;
|
|
17
|
+
private minLabel?;
|
|
18
|
+
private slider?;
|
|
19
|
+
private fill?;
|
|
20
|
+
private startThumb?;
|
|
21
|
+
private endThumb?;
|
|
22
|
+
private startHintLayer?;
|
|
23
|
+
private startHintHeight?;
|
|
24
|
+
private endHintLayer?;
|
|
25
|
+
private endHintHeight?;
|
|
26
|
+
private modeButton?;
|
|
27
|
+
private estRoot?;
|
|
28
|
+
private estBubble?;
|
|
29
|
+
private minLayer;
|
|
30
|
+
private maxLayer;
|
|
31
|
+
private startLayer;
|
|
32
|
+
private endLayer;
|
|
33
|
+
private singleLayerMode;
|
|
34
|
+
private previousStartLayer;
|
|
35
|
+
private dragThumb?;
|
|
36
|
+
constructor(viewer: BaseViewer, cfg?: GCodeLayerBarPluginConfig);
|
|
37
|
+
private init;
|
|
38
|
+
private hostContainer;
|
|
39
|
+
private buildDom;
|
|
40
|
+
private createBound;
|
|
41
|
+
private createThumb;
|
|
42
|
+
private createHint;
|
|
43
|
+
private onModelsChanged;
|
|
44
|
+
private onLanguageChange;
|
|
45
|
+
private onLayerRangeChanged;
|
|
46
|
+
private refreshFromViewer;
|
|
47
|
+
private setVisible;
|
|
48
|
+
private applyLocalizedTitles;
|
|
49
|
+
private onToggleMode;
|
|
50
|
+
private onWheel;
|
|
51
|
+
private onSliderPointerDown;
|
|
52
|
+
private onSliderPointerMove;
|
|
53
|
+
private onSliderPointerUp;
|
|
54
|
+
private onSliderHoverMove;
|
|
55
|
+
private onSliderHoverLeave;
|
|
56
|
+
private updateEstimatedHover;
|
|
57
|
+
private hideEstimatedHover;
|
|
58
|
+
private nearestThumb;
|
|
59
|
+
private valueFromPointer;
|
|
60
|
+
private applyPointerValue;
|
|
61
|
+
private setRange;
|
|
62
|
+
private fillHint;
|
|
63
|
+
private percent;
|
|
64
|
+
private render;
|
|
65
|
+
destroy(): void;
|
|
66
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { i18n } from "@gcode-viewer/core";
|
|
2
|
+
export declare const en: {
|
|
3
|
+
singleLayer: string;
|
|
4
|
+
multiLayer: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const zh: {
|
|
7
|
+
singleLayer: string;
|
|
8
|
+
multiLayer: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const GCODE_LAYER_BAR_I18N_NAMESPACE: "gcodeLayerBar";
|
|
11
|
+
export { i18n };
|
|
12
|
+
export type GCodeLayerBarTranslationKey = keyof typeof en;
|
|
13
|
+
export declare function t(key: GCodeLayerBarTranslationKey | string): string;
|