@x-viewer/plugins 0.9.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 +3 -0
- package/dist/index.esm.js +264 -0
- package/dist/types/axis-gizmo/AxisGizmoPlugin.d.ts +51 -0
- package/dist/types/axis-gizmo/CoordinateAxes.d.ts +14 -0
- package/dist/types/axis-gizmo/index.d.ts +2 -0
- package/dist/types/bottom-bar/BottomBarPlugin.d.ts +42 -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 +36 -0
- package/dist/types/context-menu/Locale.d.ts +48 -0
- package/dist/types/context-menu/index.d.ts +4 -0
- package/dist/types/dat-gui/Viewer3dDatGui.d.ts +66 -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 +53 -0
- package/dist/types/export/index.d.ts +2 -0
- package/dist/types/ground-grass/GroundGrassPlugin.d.ts +45 -0
- package/dist/types/ground-grass/index.d.ts +1 -0
- package/dist/types/ground-grid/GroundGridPlugin.d.ts +46 -0
- package/dist/types/ground-grid/index.d.ts +1 -0
- package/dist/types/ground-shaow/GroundShadowPlugin.d.ts +64 -0
- package/dist/types/ground-shaow/index.d.ts +1 -0
- package/dist/types/hotpoint/HotpointPlugin.d.ts +103 -0
- package/dist/types/hotpoint/index.d.ts +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/layer-manager/LayerManagerPlugin.d.ts +51 -0
- package/dist/types/layer-manager/index.d.ts +2 -0
- package/dist/types/local-model-uploader/IUploader.d.ts +19 -0
- package/dist/types/local-model-uploader/LocalDxfUploader.d.ts +22 -0
- package/dist/types/local-model-uploader/LocalModelUploader.d.ts +24 -0
- package/dist/types/local-model-uploader/index.d.ts +3 -0
- package/dist/types/markups/ArrowMarkup.d.ts +12 -0
- package/dist/types/markups/BaseMarkup.d.ts +33 -0
- package/dist/types/markups/CircleMarkup.d.ts +12 -0
- package/dist/types/markups/CloudLineMarkup.d.ts +10 -0
- package/dist/types/markups/CloudRectMarkup.d.ts +11 -0
- package/dist/types/markups/CloudRectWithTextMarkup.d.ts +42 -0
- package/dist/types/markups/Constants.d.ts +17 -0
- package/dist/types/markups/DotMarkup.d.ts +9 -0
- package/dist/types/markups/EllipseMarkup.d.ts +12 -0
- package/dist/types/markups/LeaderLineMarkup.d.ts +25 -0
- package/dist/types/markups/MarkupPlugin.d.ts +91 -0
- package/dist/types/markups/PolylineMarkup.d.ts +10 -0
- package/dist/types/markups/RectMarkup.d.ts +11 -0
- package/dist/types/markups/TextMarkup.d.ts +44 -0
- package/dist/types/markups/XMarkup.d.ts +10 -0
- package/dist/types/markups/index.d.ts +14 -0
- package/dist/types/markups/undo/AddMarkupCommand.d.ts +10 -0
- package/dist/types/markups/undo/RemoveMarkupCommand.d.ts +10 -0
- package/dist/types/markups/undo/UpdateMarkupCommand.d.ts +11 -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 +28 -0
- package/dist/types/measurements/BaseMeasureDrawable.d.ts +28 -0
- package/dist/types/measurements/BaseMeasurement.d.ts +124 -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 +15 -0
- package/dist/types/measurements/DistanceMeasurement.d.ts +25 -0
- package/dist/types/measurements/Locale.d.ts +10 -0
- package/dist/types/measurements/MeasurementPlugin.d.ts +140 -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/nav-cube/Locale.d.ts +18 -0
- package/dist/types/nav-cube/NavCube.d.ts +12 -0
- package/dist/types/nav-cube/NavCubePlugin.d.ts +36 -0
- package/dist/types/nav-cube/index.d.ts +2 -0
- package/dist/types/overview-map/ImageDrawable.d.ts +28 -0
- package/dist/types/overview-map/OverviewMapPlugin.d.ts +16 -0
- package/dist/types/overview-map/OverviewMapViewer.d.ts +50 -0
- package/dist/types/overview-map/index.d.ts +1 -0
- package/dist/types/pdf/PdfLoader.d.ts +238 -0
- package/dist/types/pdf/PdfLoaderPlugin.d.ts +47 -0
- package/dist/types/pdf/index.d.ts +2 -0
- package/dist/types/property/Locale.d.ts +8 -0
- package/dist/types/property/PropertyPlugin.d.ts +76 -0
- package/dist/types/property/index.d.ts +2 -0
- package/dist/types/screenshot/ScreenshotPlugin.d.ts +153 -0
- package/dist/types/screenshot/index.d.ts +1 -0
- package/dist/types/sections/AxisPlaneSection.d.ts +63 -0
- package/dist/types/sections/AxisSectionPopPanel.d.ts +18 -0
- package/dist/types/sections/BaseSection.d.ts +61 -0
- package/dist/types/sections/Locale.d.ts +16 -0
- package/dist/types/sections/ObjectsBoxSection.d.ts +28 -0
- package/dist/types/sections/PickPlaneSection.d.ts +42 -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 +87 -0
- package/dist/types/sections/index.d.ts +6 -0
- package/dist/types/settings-2d/Locale.d.ts +14 -0
- package/dist/types/settings-2d/Settings2dPlugin.d.ts +55 -0
- package/dist/types/settings-2d/index.d.ts +2 -0
- package/dist/types/settings-3d/Locale.d.ts +50 -0
- package/dist/types/settings-3d/Settings3dPlugin.d.ts +51 -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 +49 -0
- package/dist/types/skybox/index.d.ts +1 -0
- package/dist/types/stats/StatsPlugin.d.ts +19 -0
- package/dist/types/stats/index.d.ts +2 -0
- package/dist/types/toolbars/Locale.d.ts +98 -0
- package/dist/types/toolbars/MarkupToolbar.d.ts +18 -0
- package/dist/types/toolbars/Toolbar.config.d.ts +9 -0
- package/dist/types/toolbars/Toolbar.constants.d.ts +95 -0
- package/dist/types/toolbars/Toolbar.d.ts +107 -0
- package/dist/types/toolbars/Viewer2dToolbarPlugin.d.ts +37 -0
- package/dist/types/toolbars/Viewer3dToolbarPlugin.d.ts +37 -0
- package/dist/types/toolbars/index.d.ts +7 -0
- package/dist/types/tree-view/Locale.d.ts +8 -0
- package/dist/types/tree-view/TreeViewPlugin.d.ts +71 -0
- package/dist/types/tree-view/index.d.ts +2 -0
- package/dist/types/view-cube/Locale.d.ts +18 -0
- package/dist/types/view-cube/ViewCube.d.ts +79 -0
- package/dist/types/view-cube/ViewCubePlugin.d.ts +55 -0
- package/dist/types/view-cube/index.d.ts +2 -0
- package/package.json +58 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type BaseViewer, IconClass } from "@x-viewer/core";
|
|
2
|
+
import type { Toolbar } from "./Toolbar";
|
|
3
|
+
/**
|
|
4
|
+
* @type
|
|
5
|
+
* 1: click event
|
|
6
|
+
* 2:show popup
|
|
7
|
+
* 3:show submenu
|
|
8
|
+
* 4:turn on/off
|
|
9
|
+
*/
|
|
10
|
+
export declare enum MenuTypeEnums {
|
|
11
|
+
ClickEvent = 1,
|
|
12
|
+
Popup = 2,
|
|
13
|
+
SubMenu = 3,
|
|
14
|
+
Switch = 4
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Buildin toolbar ids
|
|
18
|
+
*/
|
|
19
|
+
export declare enum ToolbarMenuId {
|
|
20
|
+
HomeView = "HomeView",
|
|
21
|
+
OrthoMode = "OrthoMode",
|
|
22
|
+
Measure = "Measure",
|
|
23
|
+
MeasureDistance = "MeasureDistance",
|
|
24
|
+
MeasureArea = "MeasureArea",
|
|
25
|
+
MeasureAngle = "MeasureAngle",
|
|
26
|
+
MeasureCoordinate = "MeasureCoordinate",
|
|
27
|
+
MeasureClear = "MeasureClear",
|
|
28
|
+
MarkupVisibility = "MarkupVisibility",
|
|
29
|
+
Markup = "Markup",
|
|
30
|
+
MarkupArrow = "Arrow",
|
|
31
|
+
MarkupRect = "Rect",
|
|
32
|
+
MarkupCloudRect = "CloudRect",
|
|
33
|
+
MarkupPolyLine = "PolyLine",
|
|
34
|
+
MarkupCloudLine = "CloudLine",
|
|
35
|
+
MarkupEllipse = "Ellipse",
|
|
36
|
+
MarkupCircle = "Circle",
|
|
37
|
+
MarkupDot = "Dot",
|
|
38
|
+
MarkupText = "Text",
|
|
39
|
+
MarkupX = "X",
|
|
40
|
+
MarkupStrokeStyle = "StrokeStyle",
|
|
41
|
+
MarkupLineWidth = "LineWidth",
|
|
42
|
+
MarkupLineWidth2 = "LineWidth2",
|
|
43
|
+
MarkupLineWidth5 = "LineWidth5",
|
|
44
|
+
MarkupLineWidth10 = "LineWidth10",
|
|
45
|
+
MarkupFontSize = "FontSize",
|
|
46
|
+
MarkupFontSize14 = "FontSize14",
|
|
47
|
+
MarkupFontSize18 = "FontSize18",
|
|
48
|
+
MarkupFontSize24 = "FontSize24",
|
|
49
|
+
MarkupClear = "MarkupClear",
|
|
50
|
+
MarkupQuit = "MarkupQuit",
|
|
51
|
+
Section = "Section",
|
|
52
|
+
SectionBox = "SectionBox",
|
|
53
|
+
SectionPlane = "SectionPlane",
|
|
54
|
+
SectionAxis = "SectionAxis",
|
|
55
|
+
TreeView = "Tree View",
|
|
56
|
+
Viewpoint = "Viewpoint",
|
|
57
|
+
Annotation = "Annotation",
|
|
58
|
+
Property = "Property",
|
|
59
|
+
Settings = "Settings",
|
|
60
|
+
Compared = "Compared",
|
|
61
|
+
QuitCompare = "QuitCompare",
|
|
62
|
+
Fullscreen = "FullScreen",
|
|
63
|
+
SceneClear = "SceneClear",
|
|
64
|
+
Layers = "Layers",
|
|
65
|
+
ZoomToRectangle = "ZoomToRectangle",
|
|
66
|
+
Screenshot = "GetScreenshot"
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Toolbar menu config.
|
|
70
|
+
* Used to define menu item name, icon, child items, etc.
|
|
71
|
+
*/
|
|
72
|
+
export interface ToolbarMenuConfig {
|
|
73
|
+
menuName?: string;
|
|
74
|
+
icon?: IconClass;
|
|
75
|
+
children?: ToolbarConfig;
|
|
76
|
+
visible?: boolean;
|
|
77
|
+
mutexIds?: ToolbarMenuId[];
|
|
78
|
+
defaultActive?: boolean;
|
|
79
|
+
type?: MenuTypeEnums;
|
|
80
|
+
customElement?: (viewer: BaseViewer, menuId: string, cfg: ToolbarMenuConfig) => HTMLDivElement;
|
|
81
|
+
onActive?: (viewer: BaseViewer, toolbar: Toolbar) => void;
|
|
82
|
+
onDeactive?: (viewer: BaseViewer) => void;
|
|
83
|
+
onClick?: (viewer: BaseViewer, toolbar: Toolbar, event: MouseEvent | TouchEvent) => void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Toolbar config.
|
|
87
|
+
* The key is ToolbarMenuId, and the value is a ToolbarMenuConfig.
|
|
88
|
+
*/
|
|
89
|
+
export type ToolbarConfig = {
|
|
90
|
+
[key in ToolbarMenuId]?: ToolbarMenuConfig;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
export declare const GroupConfig: ToolbarMenuId[][];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type BaseViewer } from "@x-viewer/core";
|
|
2
|
+
import { ToolbarConfig, ToolbarMenuConfig, ToolbarMenuId } from "./Toolbar.constants";
|
|
3
|
+
/**
|
|
4
|
+
* @class Toolbar
|
|
5
|
+
* @description A customized toolbar.
|
|
6
|
+
*
|
|
7
|
+
* For example:
|
|
8
|
+
* #### Example 1:
|
|
9
|
+
* Using {@link updateMenu} to modify the toolbar configuration
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const toolbar = this.viewer.toolbar;
|
|
12
|
+
* toolbar.updateMenu(ToolbarMenuId.Viewpoint, { onActive: this.handleActive });
|
|
13
|
+
* toolbar.updateMenu(ToolbarMenuId.Annotation, { visible: false });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* #### Example 2:
|
|
17
|
+
* Using {@link addMenu} to add a new menu to the toolbar with specific position.
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const toolbar = this.viewer.toolbar;
|
|
20
|
+
* toolbar.addMenu(
|
|
21
|
+
* "newMenu",
|
|
22
|
+
* { icon: { default: "icon-new" }, menuName: "New menu item", controller: TreeViewerController },
|
|
23
|
+
* [2, 5]
|
|
24
|
+
* );
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* #### Example 3:
|
|
28
|
+
* Modify the configuration in to custmize the toolbar directly, and then {@link refresh} the whole toolbar.
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const toolbar = this.viewer.toolbar;
|
|
31
|
+
* const toolbarGroupConfig = [
|
|
32
|
+
* [ToolbarMenuId.OrthoMode, ToolbarMenuId.FullScreen],
|
|
33
|
+
* [ToolbarMenuId.Measure, ToolbarMenuId.Section],
|
|
34
|
+
* [ToolbarMenuId.TreeView, ToolbarMenuId.Viewpoint, ToolbarMenuId.Annotation, ToolbarMenuId.Property],
|
|
35
|
+
* [ToolbarMenuId.Setting, "newMenu"],
|
|
36
|
+
* ];
|
|
37
|
+
* toolbar.toolbarGroupConfig = toolbarGroupConfig;
|
|
38
|
+
* toolbar.refresh();
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare class Toolbar {
|
|
42
|
+
protected viewer: BaseViewer;
|
|
43
|
+
protected element: HTMLDivElement | undefined;
|
|
44
|
+
protected visible: boolean;
|
|
45
|
+
activateMenuId?: string;
|
|
46
|
+
menuList: Map<string, ToolbarMenu>;
|
|
47
|
+
protected menuCfg: ToolbarConfig;
|
|
48
|
+
protected groupCfg: ToolbarMenuId[][] | string[][];
|
|
49
|
+
protected screenshotDownloadFileName: string;
|
|
50
|
+
constructor(viewer: BaseViewer, menuCfg: ToolbarConfig, groupCfg?: ToolbarMenuId[][] | string[][]);
|
|
51
|
+
private init;
|
|
52
|
+
keydown: (e: KeyboardEvent) => void;
|
|
53
|
+
clearActive(): void;
|
|
54
|
+
setActive(menuId: string, active: boolean): void;
|
|
55
|
+
isActive(menuId: string): boolean;
|
|
56
|
+
setScreenshotDownloadFileName(filename: string): void;
|
|
57
|
+
getScreenshotDownloadFileName(): string;
|
|
58
|
+
private createToolbarMenu;
|
|
59
|
+
/**
|
|
60
|
+
* @description Modify the menu configuration and update the toolbar.
|
|
61
|
+
* @param {ToolbarMenuId} menuId
|
|
62
|
+
* @param {Partial<ToolbarMenuConfig>} config
|
|
63
|
+
* @memberof Toolbar
|
|
64
|
+
*/
|
|
65
|
+
updateMenu(menuId: ToolbarMenuId, config: Partial<ToolbarMenuConfig>): void;
|
|
66
|
+
/**
|
|
67
|
+
* @description Modify the menu configuration and update the toolbar.
|
|
68
|
+
* @param {{ menuId: ToolbarMenuId; config: Partial<ToolbarMenuConfig> }[]} configs
|
|
69
|
+
* @memberof Toolbar
|
|
70
|
+
*/
|
|
71
|
+
updateMenus(configs: {
|
|
72
|
+
menuId: ToolbarMenuId;
|
|
73
|
+
config: Partial<ToolbarMenuConfig>;
|
|
74
|
+
}[]): void;
|
|
75
|
+
/**
|
|
76
|
+
* @description Add a custmized menu to toolbar.
|
|
77
|
+
* @param {string} menuId
|
|
78
|
+
* @param {ToolbarMenuConfig} config
|
|
79
|
+
* @param {[number, number]} [insertPosition]
|
|
80
|
+
* @return {*}
|
|
81
|
+
* @memberof Toolbar
|
|
82
|
+
*/
|
|
83
|
+
addMenu(menuId: string, config: ToolbarMenuConfig, insertPosition?: [number, number]): void;
|
|
84
|
+
/**
|
|
85
|
+
* @description Update the whole toolbar element with the current configuration.
|
|
86
|
+
* @memberof Toolbar
|
|
87
|
+
*/
|
|
88
|
+
refresh(): void;
|
|
89
|
+
show(): void;
|
|
90
|
+
hide(): void;
|
|
91
|
+
destroy(): void;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
export declare class ToolbarMenu {
|
|
97
|
+
private eventBus;
|
|
98
|
+
active: boolean;
|
|
99
|
+
element: HTMLDivElement;
|
|
100
|
+
toolbar: Toolbar;
|
|
101
|
+
markupToolbar?: Toolbar;
|
|
102
|
+
menuId: string;
|
|
103
|
+
constructor(viewer: BaseViewer, toolbar: Toolbar, menuId: string, cfg: ToolbarMenuConfig, parent?: ToolbarMenu);
|
|
104
|
+
private createButton;
|
|
105
|
+
setActive(active: boolean): void;
|
|
106
|
+
isActive(): boolean;
|
|
107
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Plugin, type BaseViewer, PluginConfig } from "@x-viewer/core";
|
|
2
|
+
import { Toolbar } from "./Toolbar";
|
|
3
|
+
import { ToolbarConfig, ToolbarMenuId } from "./Toolbar.constants";
|
|
4
|
+
/**
|
|
5
|
+
* Viewer2d toolbar plugin config.
|
|
6
|
+
*/
|
|
7
|
+
export interface Viewer2dToolbarPluginConfig extends Partial<PluginConfig> {
|
|
8
|
+
language?: "cn" | "en";
|
|
9
|
+
menuConfig: ToolbarConfig;
|
|
10
|
+
groupConfig?: ToolbarMenuId[][] | string[][];
|
|
11
|
+
markupMenuCfg?: ToolbarConfig;
|
|
12
|
+
markupGroupCfg?: ToolbarMenuId[][] | string[][];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Viewer2d toolbar plugin.
|
|
16
|
+
*/
|
|
17
|
+
export declare class Viewer2dToolbarPlugin extends Plugin {
|
|
18
|
+
static readonly DEFAULT_ID = "Viewer2dToolbarPlugin";
|
|
19
|
+
protected cfg: Viewer2dToolbarPluginConfig;
|
|
20
|
+
protected toolbar: Toolbar;
|
|
21
|
+
protected markupToolbar?: Toolbar;
|
|
22
|
+
constructor(viewer: BaseViewer, cfg?: Viewer2dToolbarPluginConfig);
|
|
23
|
+
private initLocalization;
|
|
24
|
+
getToolbar(): Toolbar;
|
|
25
|
+
getMarkupToolbar(): Toolbar | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Sets a menu item to be active or inactive.
|
|
28
|
+
*/
|
|
29
|
+
setActive(menuId: string, active: boolean): void;
|
|
30
|
+
/**
|
|
31
|
+
* Gets if a menu item is active.
|
|
32
|
+
*/
|
|
33
|
+
isActive(menuId: string): boolean;
|
|
34
|
+
protected onMarkupActivated: () => void;
|
|
35
|
+
protected onMarkupDeactivated: () => void;
|
|
36
|
+
destroy(): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Plugin, type BaseViewer, PluginConfig } from "@x-viewer/core";
|
|
2
|
+
import { Toolbar } from "./Toolbar";
|
|
3
|
+
import { ToolbarConfig, ToolbarMenuId } from "./Toolbar.constants";
|
|
4
|
+
/**
|
|
5
|
+
* Viewer3d toolbar plugin config.
|
|
6
|
+
*/
|
|
7
|
+
export interface Viewer3dToolbarPluginConfig extends Partial<PluginConfig> {
|
|
8
|
+
language?: "cn" | "en";
|
|
9
|
+
menuConfig: ToolbarConfig;
|
|
10
|
+
groupConfig?: ToolbarMenuId[][] | string[][];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Viewer3d toolbar plugin.
|
|
14
|
+
*/
|
|
15
|
+
export declare class Viewer3dToolbarPlugin extends Plugin {
|
|
16
|
+
static readonly DEFAULT_ID = "Viewer3dToolbarPlugin";
|
|
17
|
+
protected cfg: Viewer3dToolbarPluginConfig;
|
|
18
|
+
private toolbar;
|
|
19
|
+
constructor(viewer: BaseViewer, cfg?: Viewer3dToolbarPluginConfig);
|
|
20
|
+
private initLocalization;
|
|
21
|
+
getToolbar(): Toolbar;
|
|
22
|
+
/**
|
|
23
|
+
* Sets a menu item to be active or inactive.
|
|
24
|
+
*/
|
|
25
|
+
setActive(menuId: string, active: boolean): void;
|
|
26
|
+
/**
|
|
27
|
+
* Gets if a menu item is active.
|
|
28
|
+
*/
|
|
29
|
+
isActive(menuId: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* When taking a screenshot, user may want to set a custom filename.
|
|
32
|
+
* If not set, it will be "download", so the file is "download.png" or "download.jpg".
|
|
33
|
+
* @param filename The filename, e.g., "thumbnail".
|
|
34
|
+
*/
|
|
35
|
+
setScreenshotDownloadFileName(filename: string): void;
|
|
36
|
+
destroy(): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Viewer3d, Plugin, PluginConfig, THREE } from "@x-viewer/core";
|
|
2
|
+
import { BasePanel } from "@x-viewer/ui";
|
|
3
|
+
/**
|
|
4
|
+
* Tree view plugin config.
|
|
5
|
+
*/
|
|
6
|
+
export interface TreeViewPluginConfig extends Partial<PluginConfig> {
|
|
7
|
+
/**
|
|
8
|
+
* Container div id.
|
|
9
|
+
*/
|
|
10
|
+
containerId?: string;
|
|
11
|
+
/**
|
|
12
|
+
* If panel is visible. It is visible by default.
|
|
13
|
+
*/
|
|
14
|
+
visible?: boolean;
|
|
15
|
+
language?: "cn" | "en";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Tree view plugin events.
|
|
19
|
+
*/
|
|
20
|
+
type TreeViewPluginEvents = {
|
|
21
|
+
/**
|
|
22
|
+
* Panel visibility change event.
|
|
23
|
+
*/
|
|
24
|
+
visibilitychange: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Tree view plugin.
|
|
28
|
+
*/
|
|
29
|
+
export declare class TreeViewPlugin extends Plugin<TreeViewPluginEvents> {
|
|
30
|
+
static readonly DEFAULT_ID = "TreeViewPlugin";
|
|
31
|
+
protected cfg: TreeViewPluginConfig;
|
|
32
|
+
protected basePanel?: BasePanel;
|
|
33
|
+
protected container?: HTMLDivElement;
|
|
34
|
+
protected content?: HTMLDivElement;
|
|
35
|
+
protected lastHighlightedObject?: THREE.Object3D;
|
|
36
|
+
constructor(viewer: Viewer3d, cfg?: TreeViewPluginConfig);
|
|
37
|
+
protected updateContent(): void;
|
|
38
|
+
private initLocalization;
|
|
39
|
+
setVisible(visible: boolean): void;
|
|
40
|
+
isVisible(): boolean;
|
|
41
|
+
protected onModelLoadOrRemove: () => void;
|
|
42
|
+
protected onObjectSelected: (evt: THREE.Object3D) => void;
|
|
43
|
+
protected onObjectDeselected: (evt: THREE.Object3D) => void;
|
|
44
|
+
private onClose;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
protected addContent(): void;
|
|
47
|
+
private buildTreeForNodeRecursive;
|
|
48
|
+
private selectTreeNodeAndHighlightSceneObject;
|
|
49
|
+
private highlightTreeNodeBySceneObject;
|
|
50
|
+
private highlightSceneObject;
|
|
51
|
+
private focusSceneObject;
|
|
52
|
+
/**
|
|
53
|
+
* Recursively update all children visibility and their checkboxes.
|
|
54
|
+
*/
|
|
55
|
+
private updateChildrenVisibility;
|
|
56
|
+
/**
|
|
57
|
+
* Update parent checkbox state (checked/unchecked/indeterminate) based on children.
|
|
58
|
+
*/
|
|
59
|
+
private updateParentVisibility;
|
|
60
|
+
private handleSingleClick;
|
|
61
|
+
private handleDoubleClick;
|
|
62
|
+
private handleClick;
|
|
63
|
+
private IsModelNode;
|
|
64
|
+
private showPopMenu;
|
|
65
|
+
private getClosestParentTreeNode;
|
|
66
|
+
/**
|
|
67
|
+
* Find Object3D by uuid in all loaded models.
|
|
68
|
+
*/
|
|
69
|
+
private findObjectByUuid;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { i18next } from "@x-viewer/core";
|
|
2
|
+
export declare const en: {
|
|
3
|
+
front: string;
|
|
4
|
+
back: string;
|
|
5
|
+
top: string;
|
|
6
|
+
bottom: string;
|
|
7
|
+
left: string;
|
|
8
|
+
right: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const cn: {
|
|
11
|
+
front: string;
|
|
12
|
+
back: string;
|
|
13
|
+
top: string;
|
|
14
|
+
bottom: string;
|
|
15
|
+
left: string;
|
|
16
|
+
right: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const i18n: i18next.i18n;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { THREE } from "@x-viewer/core";
|
|
2
|
+
/**
|
|
3
|
+
* View cube config.
|
|
4
|
+
*/
|
|
5
|
+
export interface ViewCubeConfig {
|
|
6
|
+
showAxes?: boolean;
|
|
7
|
+
lineColor?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* View cube element names.
|
|
11
|
+
*/
|
|
12
|
+
export declare enum ViewCubeElement {
|
|
13
|
+
TopFace = "TopFace",
|
|
14
|
+
FrontFace = "FrontFace",
|
|
15
|
+
RightFace = "RightFace",
|
|
16
|
+
BackFace = "BackFace",
|
|
17
|
+
LeftFace = "LeftFace",
|
|
18
|
+
BottomFace = "BottomFace",
|
|
19
|
+
TopFrontEdge = "TopFrontEdge",
|
|
20
|
+
TopRightEdge = "TopRightEdge",
|
|
21
|
+
TopBackEdge = "TopBackEdge",
|
|
22
|
+
TopLeftEdge = "TopLeftEdge",
|
|
23
|
+
FrontRightEdge = "FrontRightEdge",
|
|
24
|
+
BackRightEdge = "BackRightEdge",
|
|
25
|
+
BackLeftEdge = "BackLeftEdge",
|
|
26
|
+
FrontLeftEdge = "FrontLeftEdge",
|
|
27
|
+
BottomFrontEdge = "BottomFrontEdge",
|
|
28
|
+
BottomRightEdge = "BottomRightEdge",
|
|
29
|
+
BottomBackEdge = "BottomBackEdge",
|
|
30
|
+
BottomLeftEdge = "BottomLeftEdge",
|
|
31
|
+
TopFrontRightCorner = "TopFrontRightCorner",
|
|
32
|
+
TopBackRightCorner = "TopBackRightCorner",
|
|
33
|
+
TopBackLeftCorner = "TopBackLeftCorner",
|
|
34
|
+
TopFrontLeftCorner = "TopFrontLeftCorner",
|
|
35
|
+
BottomFrontRightCorner = "BottomFrontRightCorner",
|
|
36
|
+
BottomBackRightCorner = "BottomBackRightCorner",
|
|
37
|
+
BottomBackLeftCorner = "BottomBackLeftCorner",
|
|
38
|
+
BottomFrontLeftCorner = "BottomFrontLeftCorner"
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* ViewCube class.
|
|
42
|
+
*/
|
|
43
|
+
export declare class ViewCube extends THREE.Object3D {
|
|
44
|
+
readonly name = "ViewCube";
|
|
45
|
+
private readonly AXIS_COLOR_X;
|
|
46
|
+
private readonly AXIS_COLOR_Y;
|
|
47
|
+
private readonly AXIS_COLOR_Z;
|
|
48
|
+
private readonly FACE_BACKGROUND_COLOR;
|
|
49
|
+
private readonly FACE_HOVER_BACKGROUND_COLOR;
|
|
50
|
+
private readonly INNER_CUBE_WIDTH;
|
|
51
|
+
private readonly OUTER_CUBE_WIDTH;
|
|
52
|
+
private readonly CORNER_WIDTH;
|
|
53
|
+
private readonly AXIS_LENGTH;
|
|
54
|
+
private readonly EDGE_COLOUR;
|
|
55
|
+
private readonly EDGE_OPACITY;
|
|
56
|
+
private readonly EDGE_SIZE;
|
|
57
|
+
private readonly CORNER_COLOR;
|
|
58
|
+
private readonly CORNER_OPACITY;
|
|
59
|
+
private faces;
|
|
60
|
+
private innerViewCubeMesh?;
|
|
61
|
+
private showAxes;
|
|
62
|
+
private lineColor;
|
|
63
|
+
dirty: boolean;
|
|
64
|
+
activateMeshName?: string;
|
|
65
|
+
constructor(cfg?: ViewCubeConfig);
|
|
66
|
+
private init;
|
|
67
|
+
private createAxes;
|
|
68
|
+
private createViewCubeFaces;
|
|
69
|
+
private createViewCubeFace;
|
|
70
|
+
private createViewCubeEdges;
|
|
71
|
+
private createEdge;
|
|
72
|
+
private createViewCubeCorners;
|
|
73
|
+
private createCorner;
|
|
74
|
+
getBBox(): THREE.Box3;
|
|
75
|
+
getDirectionByElement(viewCubeName: ViewCubeElement): THREE.Vector3 | undefined;
|
|
76
|
+
update(): void;
|
|
77
|
+
private updateViewCube;
|
|
78
|
+
private updateMeshTick;
|
|
79
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type BaseViewer, Plugin, PluginConfig } from "@x-viewer/core";
|
|
2
|
+
export interface ViewCubePluginConfig extends Partial<PluginConfig> {
|
|
3
|
+
containerId?: string;
|
|
4
|
+
language?: "cn" | "en";
|
|
5
|
+
showAxes?: boolean;
|
|
6
|
+
lineColor?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class ViewCubePlugin extends Plugin {
|
|
9
|
+
static readonly DEFAULT_ID = "ViewCubePlugin";
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
private cfg;
|
|
14
|
+
private container;
|
|
15
|
+
private scene?;
|
|
16
|
+
private camera?;
|
|
17
|
+
private renderer?;
|
|
18
|
+
private directionalLight?;
|
|
19
|
+
private width;
|
|
20
|
+
private height;
|
|
21
|
+
private requestAnimationFrameHandle?;
|
|
22
|
+
private pickManager;
|
|
23
|
+
private renderEnabled;
|
|
24
|
+
private inputManager?;
|
|
25
|
+
private viewCube?;
|
|
26
|
+
private lastCoords?;
|
|
27
|
+
constructor(viewer: BaseViewer, cfg?: ViewCubePluginConfig);
|
|
28
|
+
get viewerContainer(): HTMLElement;
|
|
29
|
+
private init;
|
|
30
|
+
private initLocalization;
|
|
31
|
+
private initScene;
|
|
32
|
+
private initCamera;
|
|
33
|
+
private initRenderer;
|
|
34
|
+
private initLights;
|
|
35
|
+
private initViewCube;
|
|
36
|
+
private initEvents;
|
|
37
|
+
setVisible(visible: boolean): void;
|
|
38
|
+
isVisible(): boolean;
|
|
39
|
+
private onPointerDown;
|
|
40
|
+
private onPointerMove;
|
|
41
|
+
private onPointerleave;
|
|
42
|
+
private onClick;
|
|
43
|
+
private updateViewerCamera;
|
|
44
|
+
private updateActivateMeshName;
|
|
45
|
+
private updateCameraAndMeshName;
|
|
46
|
+
/**
|
|
47
|
+
* Update viewCube according to camera direction.
|
|
48
|
+
* Camera's direction is the only input factor for this class. It always look at the origin.
|
|
49
|
+
* @param direction
|
|
50
|
+
*/
|
|
51
|
+
private updateCameraDirection;
|
|
52
|
+
private animate;
|
|
53
|
+
private zoomToBBox;
|
|
54
|
+
destroy(): void;
|
|
55
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x-viewer/plugins",
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "The first typescript example for the Monorepo example",
|
|
5
|
+
"author": "x-viewer",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"ifc",
|
|
9
|
+
"bim",
|
|
10
|
+
"gis",
|
|
11
|
+
"cad",
|
|
12
|
+
"viewer",
|
|
13
|
+
"three.js",
|
|
14
|
+
"typescript"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public",
|
|
21
|
+
"registry": "https://registry.npmjs.org/"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"package.json",
|
|
25
|
+
"dist",
|
|
26
|
+
"LICENSE",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"type": "module",
|
|
30
|
+
"main": "dist/index.esm.js",
|
|
31
|
+
"module": "dist/index.esm.js",
|
|
32
|
+
"types": "dist/types/index.d.ts",
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"clipper-lib": "^6.4.2",
|
|
35
|
+
"dat.gui": "^0.7.7",
|
|
36
|
+
"mitt": "^3.0.0",
|
|
37
|
+
"pdfjs-dist": "3.8.162",
|
|
38
|
+
"screenfull": "^6.0.0",
|
|
39
|
+
"stats.js": "^0.17.0",
|
|
40
|
+
"@x-viewer/core": "^0.9.0",
|
|
41
|
+
"@x-viewer/ui": "^0.9.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/dat.gui": "^0.7.6",
|
|
45
|
+
"@types/stats.js": "^0.17.3"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "pnpm run clean:build && pnpm run data-type && rollup -c --environment BUILD:production",
|
|
49
|
+
"clean:build": "rimraf ./dist",
|
|
50
|
+
"data-type": "tsc --project tsconfig.bundle.json && tsc-alias -p tsconfig.bundle.json",
|
|
51
|
+
"dev": "pnpm run data-type && rollup -c -w",
|
|
52
|
+
"lint": "eslint . --ext .js,.ts",
|
|
53
|
+
"lint:fix": "pnpm lint --fix",
|
|
54
|
+
"format": "prettier --check .",
|
|
55
|
+
"format:fix": "prettier --write .",
|
|
56
|
+
"lint-staged": "lint-staged"
|
|
57
|
+
}
|
|
58
|
+
}
|