@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,51 @@
|
|
|
1
|
+
import { BaseViewer, Plugin, PluginConfig } from "@x-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
|
+
private cfg;
|
|
22
|
+
private hostCamera?;
|
|
23
|
+
private container?;
|
|
24
|
+
private coordinateAxes?;
|
|
25
|
+
private ignoreZAxis;
|
|
26
|
+
private camera?;
|
|
27
|
+
private scene?;
|
|
28
|
+
private renderer?;
|
|
29
|
+
private css2dRenderer?;
|
|
30
|
+
constructor(viewer: BaseViewer, cfg?: AxisGizmoPluginConfig);
|
|
31
|
+
private init;
|
|
32
|
+
private initRenderer;
|
|
33
|
+
private initScene;
|
|
34
|
+
/**
|
|
35
|
+
* Sets hostCamera in case it is changed.
|
|
36
|
+
* It is possible for a viewer to switch camera between a OrthographicCamera and a PerspectiveCamera.
|
|
37
|
+
*/
|
|
38
|
+
private setHostCamera;
|
|
39
|
+
setVisible(visible: boolean): void;
|
|
40
|
+
isVisible(): boolean;
|
|
41
|
+
private render;
|
|
42
|
+
private animate;
|
|
43
|
+
private update;
|
|
44
|
+
/**
|
|
45
|
+
* Update axes according to camera direction.
|
|
46
|
+
* Camera's direction is the only input factor for this class. It always look at the origin.
|
|
47
|
+
* @param direction
|
|
48
|
+
*/
|
|
49
|
+
private updateCameraDirection;
|
|
50
|
+
destroy(): void;
|
|
51
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { THREE, THREEAddons } from "@x-viewer/core";
|
|
2
|
+
/**
|
|
3
|
+
* CoordinateAxes class.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CoordinateAxes extends THREE.Object3D {
|
|
6
|
+
name: string;
|
|
7
|
+
private readonly AXIS_LENGTH;
|
|
8
|
+
private readonly AXIS_COLOR_X;
|
|
9
|
+
private readonly AXIS_COLOR_Y;
|
|
10
|
+
private readonly AXIS_COLOR_Z;
|
|
11
|
+
constructor(addTexts?: boolean, ignoreZAxis?: boolean);
|
|
12
|
+
addTexts(ignoreZAxis?: boolean): void;
|
|
13
|
+
createText(text: string, color: string, size?: number): THREEAddons.CSS2DObject;
|
|
14
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IconClass, BaseViewer, Plugin } from "@x-viewer/core";
|
|
2
|
+
import { Tooltip } from "@x-viewer/ui";
|
|
3
|
+
declare enum BottomBarItemId {
|
|
4
|
+
statistics = "x-viewer-threejs-statistics",
|
|
5
|
+
cameraCfg = "x-viewer-threejs-cameraCfg",
|
|
6
|
+
tips = "x-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
|
+
private element;
|
|
21
|
+
itemList: Map<string, BottomBarItem>;
|
|
22
|
+
constructor(viewer: BaseViewer);
|
|
23
|
+
update(): void;
|
|
24
|
+
private init;
|
|
25
|
+
private createItem;
|
|
26
|
+
}
|
|
27
|
+
declare class BottomBarItem {
|
|
28
|
+
readonly viewer: BaseViewer;
|
|
29
|
+
private readonly bottomBar;
|
|
30
|
+
protected readonly menuId: string;
|
|
31
|
+
protected cfg: BottomBarItemConfig;
|
|
32
|
+
private eventBus;
|
|
33
|
+
private itemconfig;
|
|
34
|
+
tooltip: Tooltip;
|
|
35
|
+
element: HTMLElement;
|
|
36
|
+
active: boolean;
|
|
37
|
+
constructor(viewer: BaseViewer, bottomBar: BottomBarPlugin, menuId: string, cfg: BottomBarItemConfig);
|
|
38
|
+
private createButton;
|
|
39
|
+
setActive(active: boolean): void;
|
|
40
|
+
update(): void;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BaseViewer } from "@x-viewer/core";
|
|
2
|
+
import type { AxisPlaneSection, ObjectsBoxSection, PickPlaneSection } from "../sections";
|
|
3
|
+
import type { Toolbar } from "../toolbars";
|
|
4
|
+
/**
|
|
5
|
+
* Context for ContextMenu
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface Context {
|
|
9
|
+
viewer: BaseViewer;
|
|
10
|
+
hit?: any;
|
|
11
|
+
instanceId?: number;
|
|
12
|
+
batchId?: number;
|
|
13
|
+
/**
|
|
14
|
+
* For Viewer3d
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
section?: ObjectsBoxSection | PickPlaneSection | AxisPlaneSection;
|
|
18
|
+
toolbar?: Toolbar;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
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,36 @@
|
|
|
1
|
+
import { type BaseViewer, Plugin, PluginConfig } from "@x-viewer/core";
|
|
2
|
+
import { Context, ContextMenuItem } from "./Constants";
|
|
3
|
+
/**
|
|
4
|
+
* Context menu plugin config.
|
|
5
|
+
*/
|
|
6
|
+
export interface ContextMenuPluginConfig extends Partial<PluginConfig> {
|
|
7
|
+
language?: "cn" | "en";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Context menu plugin.
|
|
11
|
+
* Can be used by Viewer3d.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ContextMenuPlugin extends Plugin {
|
|
14
|
+
static readonly DEFAULT_ID = "ContextMenuPlugin";
|
|
15
|
+
protected cfg: ContextMenuPluginConfig;
|
|
16
|
+
protected container: HTMLElement;
|
|
17
|
+
protected element: HTMLDivElement;
|
|
18
|
+
protected context: Context;
|
|
19
|
+
protected itemList: [ContextMenuItem, HTMLElement][];
|
|
20
|
+
constructor(viewer: BaseViewer, cfg?: ContextMenuPluginConfig);
|
|
21
|
+
private initLocalization;
|
|
22
|
+
private initEvents;
|
|
23
|
+
protected handleClick: () => void;
|
|
24
|
+
private showContextMenu;
|
|
25
|
+
private isEnabled;
|
|
26
|
+
private isShown;
|
|
27
|
+
private getTitle;
|
|
28
|
+
private createMenuUI;
|
|
29
|
+
private createMenuGroup;
|
|
30
|
+
private createMenuItem;
|
|
31
|
+
private updateMenuItems;
|
|
32
|
+
private showMenuElement;
|
|
33
|
+
show(pageX: number, pageY: number): void;
|
|
34
|
+
hide(): void;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { i18next } from "@x-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 cn: {
|
|
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 i18n: i18next.i18n;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Plugin, Viewer3d } from "@x-viewer/core";
|
|
2
|
+
import * as dat from "dat.gui";
|
|
3
|
+
/**
|
|
4
|
+
* Can be used by Viewer3d and BimTilesViewer.
|
|
5
|
+
* @internal
|
|
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
|
+
showGroundGrass: boolean;
|
|
23
|
+
skyMode: string[];
|
|
24
|
+
environments: string[];
|
|
25
|
+
homeView: () => void;
|
|
26
|
+
views: string[];
|
|
27
|
+
OrthographicCamera: boolean;
|
|
28
|
+
viewpoints: boolean;
|
|
29
|
+
annotations: boolean;
|
|
30
|
+
takeSnapshot: () => void;
|
|
31
|
+
takeSnapshotForViewerBBox: () => void;
|
|
32
|
+
fullScreen: () => void;
|
|
33
|
+
webcam: boolean;
|
|
34
|
+
uploadFile: () => void;
|
|
35
|
+
showTreeView: boolean;
|
|
36
|
+
showPropertyPanel: boolean;
|
|
37
|
+
transparentMode: boolean;
|
|
38
|
+
enableOutline: boolean;
|
|
39
|
+
doubleSidedMaterial: boolean;
|
|
40
|
+
showVertexNormals: boolean;
|
|
41
|
+
explode: number;
|
|
42
|
+
sectionMode: string[];
|
|
43
|
+
alVisible: boolean;
|
|
44
|
+
alColor: string;
|
|
45
|
+
alIntensity: number;
|
|
46
|
+
dlColor: string;
|
|
47
|
+
showDlHelper: boolean;
|
|
48
|
+
hlVisible: boolean;
|
|
49
|
+
hlIntensity: number;
|
|
50
|
+
hlColor: number[];
|
|
51
|
+
hlGroundColor: number[];
|
|
52
|
+
fogEnabled: boolean;
|
|
53
|
+
fogColor: number;
|
|
54
|
+
fogNearDistance: number;
|
|
55
|
+
fogFarDistance: number;
|
|
56
|
+
distanceCullingFactor: number;
|
|
57
|
+
errorTarget: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Init dat.GUI
|
|
61
|
+
*/
|
|
62
|
+
init(): void;
|
|
63
|
+
open(): void;
|
|
64
|
+
close(): void;
|
|
65
|
+
destroy(): void;
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Viewer3dDatGui";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { THREE, BaseViewer, Plugin, PluginConfig } from "@x-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
|
+
* @internal
|
|
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<THREE.Object3DEventMap>;
|
|
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 "@x-viewer/core";
|
|
2
|
+
/**
|
|
3
|
+
* ObjectExploder class is used to explode an object
|
|
4
|
+
* @internal
|
|
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,53 @@
|
|
|
1
|
+
import { THREE, BaseViewer, Plugin, PluginConfig, Viewer3d, THREEAddons } from "@x-viewer/core";
|
|
2
|
+
import { BasePanel } from "@x-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 interface ExportPluginConfig extends Partial<PluginConfig> {
|
|
14
|
+
language?: "cn" | "en";
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Export plugin is used to export scene to a 3d model.
|
|
18
|
+
* @description
|
|
19
|
+
*/
|
|
20
|
+
export declare class ExportPlugin extends Plugin {
|
|
21
|
+
static readonly DEFAULT_ID = "ExportPlugin";
|
|
22
|
+
protected cfg: ExportPluginConfig;
|
|
23
|
+
protected basePanel?: BasePanel;
|
|
24
|
+
protected viewer3d: Viewer3d;
|
|
25
|
+
constructor(viewer: BaseViewer, cfg?: ExportPluginConfig);
|
|
26
|
+
/**
|
|
27
|
+
* Exports to gltf or glb format.
|
|
28
|
+
* @param filename pure filename without extension.
|
|
29
|
+
* @param binary true to export as binary glb, false to export as text gltf.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
exportGltf(filename: string, options?: THREEAddons.GLTFExporterOptions, targetObject?: THREE.Object3D | null): void;
|
|
33
|
+
/**
|
|
34
|
+
* Exports to OBJ format.
|
|
35
|
+
* @param filename pure filename without extension.
|
|
36
|
+
*/
|
|
37
|
+
exportObj(filename: string, targetObject?: THREE.Object3D | null): void;
|
|
38
|
+
exportStl(filename: string, targetObject?: THREE.Object3D | null): void;
|
|
39
|
+
exportPly(filename: string, binary?: boolean, targetObject?: THREE.Object3D | null): void;
|
|
40
|
+
/**
|
|
41
|
+
* Shows the export options panel.
|
|
42
|
+
*/
|
|
43
|
+
showExportPanel(targetFormat?: ExportFormats, filename?: string, targetObject?: THREE.Object3D | null): void;
|
|
44
|
+
/**
|
|
45
|
+
* Saves/downloads a blob as a file.
|
|
46
|
+
* @param blob The blob to save.
|
|
47
|
+
* @param filename The filename (with extension) to save as.
|
|
48
|
+
*/
|
|
49
|
+
saveBlobAsFile(blob: Blob, filename: string): void;
|
|
50
|
+
saveStringAsFile(text: string, filename: string): void;
|
|
51
|
+
saveArrayBufferAsFile: (buffer: ArrayBuffer, filename: string) => void;
|
|
52
|
+
destroy(): void;
|
|
53
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { THREE, BaseViewer, Plugin, PluginConfig } from "@x-viewer/core";
|
|
2
|
+
export interface GroundGrassPluginConfig extends Partial<PluginConfig> {
|
|
3
|
+
/**
|
|
4
|
+
* Url of a texture image.
|
|
5
|
+
*/
|
|
6
|
+
texture?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Ground width.
|
|
9
|
+
*/
|
|
10
|
+
width?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Ground height.
|
|
13
|
+
*/
|
|
14
|
+
height?: number;
|
|
15
|
+
/**
|
|
16
|
+
* How many times the texture is repeated.
|
|
17
|
+
*/
|
|
18
|
+
repeatX?: number;
|
|
19
|
+
/**
|
|
20
|
+
* How many times the texture is repeated.
|
|
21
|
+
*/
|
|
22
|
+
repeatY?: number;
|
|
23
|
+
/**
|
|
24
|
+
* If ground grass is visible. It is visible by default.
|
|
25
|
+
*/
|
|
26
|
+
visible?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Ground grass plugin.
|
|
30
|
+
* Can be used by Viewer3d.
|
|
31
|
+
*/
|
|
32
|
+
export declare class GroundGrassPlugin extends Plugin {
|
|
33
|
+
static readonly DEFAULT_ID = "GroundGrassPlugin";
|
|
34
|
+
protected readonly NAME = "GROUND_GRASS";
|
|
35
|
+
protected readonly DEFAULT_SIZE = 1000;
|
|
36
|
+
protected readonly DEFAULT_REPEAT = 20;
|
|
37
|
+
protected cfg: GroundGrassPluginConfig;
|
|
38
|
+
protected groundGrass?: THREE.Mesh;
|
|
39
|
+
constructor(viewer: BaseViewer, cfg?: GroundGrassPluginConfig);
|
|
40
|
+
protected init(): void;
|
|
41
|
+
setVisible(visible: boolean): void;
|
|
42
|
+
protected onModelLoaded: () => void;
|
|
43
|
+
protected createGrassGround(texture: string, width: number, height: number, repeatX: number, repeatY: number): Promise<THREE.Mesh>;
|
|
44
|
+
destroy(): void;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./GroundGrassPlugin";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { THREE, BaseViewer, Plugin, PluginConfig } from "@x-viewer/core";
|
|
2
|
+
/**
|
|
3
|
+
* Ground grid plugin.
|
|
4
|
+
*/
|
|
5
|
+
export interface GroundGridPluginConfig extends Partial<PluginConfig> {
|
|
6
|
+
/**
|
|
7
|
+
* Ground size.
|
|
8
|
+
*/
|
|
9
|
+
size?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Number of divisions.
|
|
12
|
+
*/
|
|
13
|
+
divisions?: number;
|
|
14
|
+
/**
|
|
15
|
+
* If ground grid is visible. It is visible by default.
|
|
16
|
+
*/
|
|
17
|
+
visible?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Ground grid plugin.
|
|
21
|
+
* Can be used by Viewer3d.
|
|
22
|
+
*/
|
|
23
|
+
export declare class GroundGridPlugin extends Plugin {
|
|
24
|
+
static readonly DEFAULT_ID = "GroundGridPlugin";
|
|
25
|
+
protected readonly NAME = "GROUND_GRID";
|
|
26
|
+
protected readonly DEFAULT_SIZE = 1000;
|
|
27
|
+
protected readonly DEFAULT_DIVISIONS = 100;
|
|
28
|
+
protected readonly DEFAULT_MAT_PARAMS: {
|
|
29
|
+
color: number;
|
|
30
|
+
transparent: boolean;
|
|
31
|
+
opacity: number;
|
|
32
|
+
wireframeLinewidth: number;
|
|
33
|
+
};
|
|
34
|
+
protected cfg: GroundGridPluginConfig;
|
|
35
|
+
protected gridHelper?: THREE.GridHelper;
|
|
36
|
+
constructor(viewer: BaseViewer, cfg?: GroundGridPluginConfig);
|
|
37
|
+
protected init(): void;
|
|
38
|
+
setVisible(visible: boolean): void;
|
|
39
|
+
isVisible(): boolean;
|
|
40
|
+
protected onModelLoaded: () => void;
|
|
41
|
+
/**
|
|
42
|
+
* Creates ground grid
|
|
43
|
+
*/
|
|
44
|
+
protected createGroundGrid(size?: number, divisions?: number, groundCenter?: THREE.Vector3): THREE.GridHelper;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./GroundGridPlugin";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { THREE, BaseViewer, Plugin, PluginConfig } from "@x-viewer/core";
|
|
2
|
+
/**
|
|
3
|
+
* Ground shadow config.
|
|
4
|
+
*/
|
|
5
|
+
export interface GroundShadowPluginConfig extends Partial<PluginConfig> {
|
|
6
|
+
/**
|
|
7
|
+
* Blur amount for the shadow.
|
|
8
|
+
* Default is 5.
|
|
9
|
+
*/
|
|
10
|
+
blur?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Darkness of the shadow.
|
|
13
|
+
* Default is 0.8.
|
|
14
|
+
*/
|
|
15
|
+
darkness?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Delay in milliseconds before updating the shadow after a model is loaded.
|
|
18
|
+
* Default is 2000.
|
|
19
|
+
* This is to avoid updating the shadow too frequently when many models are loaded at once.
|
|
20
|
+
*/
|
|
21
|
+
updateDelay?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Enable or disable the ground shadow.
|
|
24
|
+
* Default is true.
|
|
25
|
+
*/
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Ground shadow plugin is used to show shadow for models.
|
|
30
|
+
* Can be used by Viewer3d.
|
|
31
|
+
* @description
|
|
32
|
+
*/
|
|
33
|
+
export declare class GroundShadowPlugin extends Plugin {
|
|
34
|
+
static readonly DEFAULT_ID = "GroundShadowPlugin";
|
|
35
|
+
protected cfg: GroundShadowPluginConfig;
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
protected shadowGroup?: THREE.Group;
|
|
38
|
+
protected blurPlane?: THREE.Mesh;
|
|
39
|
+
protected depthMaterial?: THREE.MeshDepthMaterial;
|
|
40
|
+
protected horizontalBlurMaterial?: THREE.ShaderMaterial;
|
|
41
|
+
protected verticalBlurMaterial?: THREE.ShaderMaterial;
|
|
42
|
+
protected shadowCamera?: THREE.OrthographicCamera;
|
|
43
|
+
protected renderTarget?: THREE.WebGLRenderTarget;
|
|
44
|
+
protected renderTargetBlur?: THREE.WebGLRenderTarget;
|
|
45
|
+
private shouldRender;
|
|
46
|
+
private timeout?;
|
|
47
|
+
constructor(viewer: BaseViewer, cfg?: GroundShadowPluginConfig);
|
|
48
|
+
protected get scene(): THREE.Scene<THREE.Object3DEventMap>;
|
|
49
|
+
protected get renderer(): THREE.WebGLRenderer;
|
|
50
|
+
setEnabled(enabled: boolean): void;
|
|
51
|
+
isEnabled(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Updates ground shadow.
|
|
54
|
+
*/
|
|
55
|
+
update(): void;
|
|
56
|
+
protected onModelUpdate: () => void;
|
|
57
|
+
protected onShadowRender: () => void;
|
|
58
|
+
private initMaterial;
|
|
59
|
+
private initRenderTarget;
|
|
60
|
+
private updateGroundShadow;
|
|
61
|
+
private blurShadow;
|
|
62
|
+
protected render(): void;
|
|
63
|
+
destroy(): void;
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./GroundShadowPlugin";
|