@x-viewer/core 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 +2 -0
- package/dist/index.esm.js +11790 -0
- package/dist/types/Locale.d.ts +23 -0
- package/dist/types/components/dxf-layout-bar/DxfLayoutBar.d.ts +26 -0
- package/dist/types/components/dxf-layout-bar/index.d.ts +1 -0
- package/dist/types/components/tool-tip/Tooltip.d.ts +20 -0
- package/dist/types/components/tool-tip/index.d.ts +1 -0
- package/dist/types/core/Configs.d.ts +288 -0
- package/dist/types/core/Constants.d.ts +81 -0
- package/dist/types/core/Units.d.ts +16 -0
- package/dist/types/core/VersionManager.d.ts +14 -0
- package/dist/types/core/camera/CameraManager.d.ts +80 -0
- package/dist/types/core/camera/index.d.ts +1 -0
- package/dist/types/core/camera-controls/CameraControls.d.ts +744 -0
- package/dist/types/core/camera-controls/Constants.d.ts +2 -0
- package/dist/types/core/camera-controls/EventDispatcher.d.ts +41 -0
- package/dist/types/core/camera-controls/index.d.ts +3 -0
- package/dist/types/core/camera-controls/types.d.ts +112 -0
- package/dist/types/core/camera-controls/utils/extractClientCoordFromEvent.d.ts +3 -0
- package/dist/types/core/camera-controls/utils/math-utils.d.ts +14 -0
- package/dist/types/core/camera-controls/utils/notSupportedInOrthographicCamera.d.ts +2 -0
- package/dist/types/core/canvas/CanvasRender.d.ts +52 -0
- package/dist/types/core/canvas/Constants.d.ts +31 -0
- package/dist/types/core/canvas/Drawable.d.ts +98 -0
- package/dist/types/core/canvas/DrawableList.d.ts +40 -0
- package/dist/types/core/canvas/MarkerDrawable.d.ts +30 -0
- package/dist/types/core/canvas/PathDrawable.d.ts +39 -0
- package/dist/types/core/canvas/index.d.ts +6 -0
- package/dist/types/core/compare/BaseDxfCompareHelper.d.ts +104 -0
- package/dist/types/core/compare/CompareDrawable.d.ts +18 -0
- package/dist/types/core/compare/DxfCompareHelper.d.ts +69 -0
- package/dist/types/core/compare/DxfCompareMarkupManager.d.ts +11 -0
- package/dist/types/core/compare/index.d.ts +4 -0
- package/dist/types/core/components/Container.d.ts +38 -0
- package/dist/types/core/components/ProgressBar.d.ts +31 -0
- package/dist/types/core/components/Spinner.d.ts +16 -0
- package/dist/types/core/components/index.d.ts +3 -0
- package/dist/types/core/controls/CameraControlsEx.d.ts +37 -0
- package/dist/types/core/controls/Control.d.ts +17 -0
- package/dist/types/core/controls/OrbitControls.d.ts +13 -0
- package/dist/types/core/controls/PlanControls.d.ts +13 -0
- package/dist/types/core/controls/index.d.ts +4 -0
- package/dist/types/core/dxf/DxfCompare.d.ts +151 -0
- package/dist/types/core/dxf/DxfConstants.d.ts +33 -0
- package/dist/types/core/dxf/DxfLoader.d.ts +557 -0
- package/dist/types/core/dxf/DxfObject.d.ts +33 -0
- package/dist/types/core/dxf/DxfUtils.d.ts +45 -0
- package/dist/types/core/dxf/HatchPatternShaders.d.ts +12 -0
- package/dist/types/core/dxf/LinePatternShaders.d.ts +12 -0
- package/dist/types/core/dxf/bspline.d.ts +7 -0
- package/dist/types/core/dxf/dxfom-mtext.d.ts +46 -0
- package/dist/types/core/dxf/dxfom-text.d.ts +16 -0
- package/dist/types/core/dxf/index.d.ts +10 -0
- package/dist/types/core/dxf/round10.d.ts +1 -0
- package/dist/types/core/dxf-parser/AutoCadColorIndex.d.ts +8 -0
- package/dist/types/core/dxf-parser/DxfBaseReader.d.ts +12 -0
- package/dist/types/core/dxf-parser/DxfBinaryReader.d.ts +14 -0
- package/dist/types/core/dxf-parser/DxfParser.d.ts +324 -0
- package/dist/types/core/dxf-parser/DxfTextReader.d.ts +31 -0
- package/dist/types/core/dxf-parser/ParseHelpers.d.ts +45 -0
- package/dist/types/core/dxf-parser/entities/3dface.d.ts +13 -0
- package/dist/types/core/dxf-parser/entities/arc.d.ts +18 -0
- package/dist/types/core/dxf-parser/entities/attdef.d.ts +33 -0
- package/dist/types/core/dxf-parser/entities/attrib.d.ts +33 -0
- package/dist/types/core/dxf-parser/entities/circle.d.ts +15 -0
- package/dist/types/core/dxf-parser/entities/dimension.d.ts +24 -0
- package/dist/types/core/dxf-parser/entities/ellipse.d.ts +17 -0
- package/dist/types/core/dxf-parser/entities/geomtry.d.ts +42 -0
- package/dist/types/core/dxf-parser/entities/hatch.d.ts +110 -0
- package/dist/types/core/dxf-parser/entities/image.d.ts +39 -0
- package/dist/types/core/dxf-parser/entities/insert.d.ts +22 -0
- package/dist/types/core/dxf-parser/entities/leader.d.ts +23 -0
- package/dist/types/core/dxf-parser/entities/line.d.ts +12 -0
- package/dist/types/core/dxf-parser/entities/lwpolyline.d.ts +23 -0
- package/dist/types/core/dxf-parser/entities/mleader.d.ts +103 -0
- package/dist/types/core/dxf-parser/entities/mtext.d.ts +20 -0
- package/dist/types/core/dxf-parser/entities/ole2frame.d.ts +22 -0
- package/dist/types/core/dxf-parser/entities/point.d.ts +13 -0
- package/dist/types/core/dxf-parser/entities/polyline.d.ts +22 -0
- package/dist/types/core/dxf-parser/entities/ray.d.ts +12 -0
- package/dist/types/core/dxf-parser/entities/region.d.ts +12 -0
- package/dist/types/core/dxf-parser/entities/seqend.d.ts +10 -0
- package/dist/types/core/dxf-parser/entities/solid.d.ts +12 -0
- package/dist/types/core/dxf-parser/entities/spline.d.ts +25 -0
- package/dist/types/core/dxf-parser/entities/table.d.ts +44 -0
- package/dist/types/core/dxf-parser/entities/text.d.ts +20 -0
- package/dist/types/core/dxf-parser/entities/vertex.d.ts +22 -0
- package/dist/types/core/dxf-parser/entities/viewport.d.ts +56 -0
- package/dist/types/core/dxf-parser/entities/xline.d.ts +12 -0
- package/dist/types/core/dxf-parser/index.d.ts +27 -0
- package/dist/types/core/dxf-parser/objects/common.d.ts +26 -0
- package/dist/types/core/dxf-parser/objects/dictionary.d.ts +23 -0
- package/dist/types/core/dxf-parser/objects/imagedef.d.ts +24 -0
- package/dist/types/core/dxf-parser/objects/layout.d.ts +29 -0
- package/dist/types/core/dxf-parser/objects/sortentstable.d.ts +12 -0
- package/dist/types/core/dxf-parser/objects/spatialfilter.d.ts +22 -0
- package/dist/types/core/dxf-parser/objects/xrecord.d.ts +11 -0
- package/dist/types/core/effect/EffectManager.d.ts +43 -0
- package/dist/types/core/effect/index.d.ts +1 -0
- package/dist/types/core/font/BaseFont.d.ts +41 -0
- package/dist/types/core/font/FontManager.d.ts +52 -0
- package/dist/types/core/font/MeshFont.d.ts +14 -0
- package/dist/types/core/font/ShxFont.d.ts +49 -0
- package/dist/types/core/font/index.d.ts +1 -0
- package/dist/types/core/font/shx/ExtraLettersTemplate.d.ts +4 -0
- package/dist/types/core/font/shx/Shx.constants.d.ts +20 -0
- package/dist/types/core/font/shx/ShxParser.d.ts +18 -0
- package/dist/types/core/font/shx/TextShape.d.ts +24 -0
- package/dist/types/core/font/shx/gbk/index.d.ts +4 -0
- package/dist/types/core/font/shx/index.d.ts +1 -0
- package/dist/types/core/font/shx/util/BitConverter.d.ts +18 -0
- package/dist/types/core/geometry-offset/Edge.d.ts +27 -0
- package/dist/types/core/geometry-offset/Offset.d.ts +46 -0
- package/dist/types/core/geometry-offset/index.d.ts +1 -0
- package/dist/types/core/helpers/BinaryReader.d.ts +23 -0
- package/dist/types/core/helpers/BoxSelectHelper.d.ts +44 -0
- package/dist/types/core/helpers/InstantiateHelper.d.ts +26 -0
- package/dist/types/core/helpers/LoadingHelper.d.ts +65 -0
- package/dist/types/core/helpers/MeshBvhHelper.d.ts +15 -0
- package/dist/types/core/helpers/MobileTouchHelperDrawable.d.ts +26 -0
- package/dist/types/core/helpers/OSnapHelper.d.ts +159 -0
- package/dist/types/core/helpers/ObjectPixelSizeHelper.d.ts +13 -0
- package/dist/types/core/helpers/PickMarkupHelper.d.ts +29 -0
- package/dist/types/core/helpers/RafHelper.d.ts +18 -0
- package/dist/types/core/helpers/ZoomToRectHelper.d.ts +20 -0
- package/dist/types/core/helpers/index.d.ts +11 -0
- package/dist/types/core/index.d.ts +24 -0
- package/dist/types/core/indexeddb/BaseTable.d.ts +36 -0
- package/dist/types/core/indexeddb/DxfDataTable.d.ts +22 -0
- package/dist/types/core/indexeddb/FontDataTable.d.ts +32 -0
- package/dist/types/core/indexeddb/IndexedDbManager.d.ts +49 -0
- package/dist/types/core/indexeddb/index.d.ts +4 -0
- package/dist/types/core/input-manager/InputManager.d.ts +147 -0
- package/dist/types/core/input-manager/index.d.ts +1 -0
- package/dist/types/core/interactions/Interaction.d.ts +10 -0
- package/dist/types/core/interactions/Viewer2dInteraction.d.ts +17 -0
- package/dist/types/core/interactions/Viewer3dInteraction.d.ts +26 -0
- package/dist/types/core/interactions/index.d.ts +1 -0
- package/dist/types/core/materials/BimTilesHighlightMaterial.d.ts +21 -0
- package/dist/types/core/materials/BimTilesMaterial.d.ts +26 -0
- package/dist/types/core/materials/BimTilesPickMaterial.d.ts +9 -0
- package/dist/types/core/materials/BimTilesTransparentMaterial.d.ts +20 -0
- package/dist/types/core/materials/StandardMaterialEx.d.ts +16 -0
- package/dist/types/core/materials/constants.d.ts +0 -0
- package/dist/types/core/materials/index.d.ts +5 -0
- package/dist/types/core/model/Constants.d.ts +58 -0
- package/dist/types/core/model/Model.d.ts +18 -0
- package/dist/types/core/model/Model2d.d.ts +142 -0
- package/dist/types/core/model/Model3d.d.ts +137 -0
- package/dist/types/core/model/bimtiles/BatchedMeshesParser.d.ts +26 -0
- package/dist/types/core/model/bimtiles/BimTilesConfigParser.d.ts +43 -0
- package/dist/types/core/model/bimtiles/BimTilesData.d.ts +280 -0
- package/dist/types/core/model/bimtiles/BimTilesMaterialManager.d.ts +139 -0
- package/dist/types/core/model/bimtiles/BimTilesModel.d.ts +67 -0
- package/dist/types/core/model/bimtiles/BimTilesPropertyParser.d.ts +42 -0
- package/dist/types/core/model/bimtiles/BimTilesRenderer.d.ts +49 -0
- package/dist/types/core/model/bimtiles/InstancedMeshesParser.d.ts +37 -0
- package/dist/types/core/model/bimtiles/TileParser.d.ts +11 -0
- package/dist/types/core/model/bimtiles/Utils.d.ts +29 -0
- package/dist/types/core/model/index.d.ts +6 -0
- package/dist/types/core/patches/Constants.d.ts +6 -0
- package/dist/types/core/patches/Line.d.ts +2 -0
- package/dist/types/core/patches/Mesh.d.ts +2 -0
- package/dist/types/core/patches/Points.d.ts +2 -0
- package/dist/types/core/patches/index.d.ts +4 -0
- package/dist/types/core/patches/shaders/ShaderChunk.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderChunk/common_ex.glsl.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderChunk/id_pars_vertex.glsl.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderChunk/id_vertex.glsl.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderChunk/outine_bc_vertex.glsl.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderChunk/outline_bc_fragment.glsl.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderChunk/outline_bc_pars_fragment.glsl.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderChunk/outline_bc_pars_vertex.glsl.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderChunk/state_fragment.glsl.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderChunk/state_highlight_fragment.glsl.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderChunk/state_pars_fragment.glsl.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderChunk/state_transparent_fragment.glsl.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderLib/pick_ex.glsl.d.ts +2 -0
- package/dist/types/core/patches/shaders/shaderLib/standard_ex.glsl.d.ts +2 -0
- package/dist/types/core/pick/PickManager.d.ts +52 -0
- package/dist/types/core/pick/index.d.ts +1 -0
- package/dist/types/core/scene/SceneManager.d.ts +48 -0
- package/dist/types/core/scene/index.d.ts +1 -0
- package/dist/types/core/shp-js/BitView.d.ts +12 -0
- package/dist/types/core/shp-js/SHPLoader.d.ts +12 -0
- package/dist/types/core/shp-js/Shp.d.ts +10 -0
- package/dist/types/core/shp-js/ShpThree.d.ts +23 -0
- package/dist/types/core/shp-js/index.d.ts +4 -0
- package/dist/types/core/text-texture/TextTexture.d.ts +45 -0
- package/dist/types/core/text-texture/index.d.ts +1 -0
- package/dist/types/core/undo/Command.d.ts +6 -0
- package/dist/types/core/undo/UndoManager.d.ts +24 -0
- package/dist/types/core/undo/index.d.ts +2 -0
- package/dist/types/core/utils/CSS2DObjectUtils.d.ts +14 -0
- package/dist/types/core/utils/CancelablePromise.d.ts +6 -0
- package/dist/types/core/utils/ColorUtils.d.ts +25 -0
- package/dist/types/core/utils/CommonUtils.d.ts +141 -0
- package/dist/types/core/utils/CoordinateUtils.d.ts +81 -0
- package/dist/types/core/utils/DecimalPrecisionUtils.d.ts +10 -0
- package/dist/types/core/utils/DeviceUtils.d.ts +15 -0
- package/dist/types/core/utils/EdgeUtils.d.ts +14 -0
- package/dist/types/core/utils/Event.d.ts +33 -0
- package/dist/types/core/utils/ExportUtils.d.ts +61 -0
- package/dist/types/core/utils/FpsUtils.d.ts +13 -0
- package/dist/types/core/utils/GeometryUtils.d.ts +78 -0
- package/dist/types/core/utils/LodashUtils.d.ts +208 -0
- package/dist/types/core/utils/LogUtils.d.ts +29 -0
- package/dist/types/core/utils/MaterialUtils.d.ts +40 -0
- package/dist/types/core/utils/MathUtils.d.ts +41 -0
- package/dist/types/core/utils/MergeUtils.d.ts +126 -0
- package/dist/types/core/utils/ObjectUtils.d.ts +216 -0
- package/dist/types/core/utils/PolygonUtils.d.ts +9 -0
- package/dist/types/core/utils/SVGObjectUtils.d.ts +22 -0
- package/dist/types/core/utils/SceneUtils.d.ts +26 -0
- package/dist/types/core/utils/SectionUtils.d.ts +11 -0
- package/dist/types/core/utils/SimplifyUtils.d.ts +15 -0
- package/dist/types/core/utils/TextureUtils.d.ts +16 -0
- package/dist/types/core/utils/UVUtils.d.ts +21 -0
- package/dist/types/core/utils/UnitConversionUtils.d.ts +31 -0
- package/dist/types/core/utils/index.d.ts +26 -0
- package/dist/types/core/viewers/BaseViewer.d.ts +253 -0
- package/dist/types/core/viewers/BimTilesViewer.d.ts +130 -0
- package/dist/types/core/viewers/Constants.d.ts +9 -0
- package/dist/types/core/viewers/Plugin.d.ts +30 -0
- package/dist/types/core/viewers/Viewer2d.d.ts +413 -0
- package/dist/types/core/viewers/Viewer3d.d.ts +136 -0
- package/dist/types/core/viewers/Viewer3dLite.d.ts +144 -0
- package/dist/types/core/viewers/ViewerEvent.d.ts +108 -0
- package/dist/types/core/viewers/index.d.ts +8 -0
- package/dist/types/core/webcam/WebCam.d.ts +28 -0
- package/dist/types/core/webcam/index.d.ts +1 -0
- package/dist/types/core/workers/CreateMeshBvh.worker.d.ts +1 -0
- package/dist/types/core/workers/GenerateMeshBvhWorker.d.ts +17 -0
- package/dist/types/core/workers/index.d.ts +1 -0
- package/dist/types/export.doc.d.ts +9 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/version.d.ts +2 -0
- package/package.json +88 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { CSS2DRenderer } from "three/examples/jsm/renderers/CSS2DRenderer.js";
|
|
3
|
+
import { ViewerName } from "./Constants";
|
|
4
|
+
import type { Plugin } from "./Plugin";
|
|
5
|
+
import { ViewerEvent } from "./ViewerEvent";
|
|
6
|
+
import { ProgressBar, Spinner } from "../components";
|
|
7
|
+
import { BaseViewerConfig, CameraInfo, CameraProjection, ModelConfig, Viewpoint } from "../../core/Configs";
|
|
8
|
+
import { CameraManager } from "../../core/camera";
|
|
9
|
+
import { CanvasRender } from "../../core/canvas";
|
|
10
|
+
import { Container } from "../../core/components/Container";
|
|
11
|
+
import { FontManager } from "../../core/font";
|
|
12
|
+
import { ZoomToRectHelper } from "../../core/helpers";
|
|
13
|
+
import { LoadingHelper } from "../../core/helpers/LoadingHelper";
|
|
14
|
+
import { InputManager } from "../../core/input-manager";
|
|
15
|
+
import { Interaction } from "../../core/interactions/Interaction";
|
|
16
|
+
import { Model } from "../../core/model";
|
|
17
|
+
import { PickManager } from "../../core/pick";
|
|
18
|
+
import { SceneManager } from "../../core/scene/SceneManager";
|
|
19
|
+
import { UndoManager } from "../../core/undo";
|
|
20
|
+
import { Event } from "../../core/utils";
|
|
21
|
+
type ViewerEvents = {
|
|
22
|
+
[K in ViewerEvent]: any;
|
|
23
|
+
};
|
|
24
|
+
export declare abstract class BaseViewer<BaseViewerEvents extends ViewerEvents = Record<ViewerEvent, any>> extends Event<BaseViewerEvents> {
|
|
25
|
+
name: ViewerName;
|
|
26
|
+
protected viewerCfg: BaseViewerConfig;
|
|
27
|
+
private clock;
|
|
28
|
+
protected targetMaxFps: number;
|
|
29
|
+
protected timeStamp: number;
|
|
30
|
+
private renderEnabled;
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
protected requestAnimationFrameHandle?: number;
|
|
35
|
+
container: Container;
|
|
36
|
+
protected plugins: Plugin[];
|
|
37
|
+
loadedModels: Model[];
|
|
38
|
+
private raf?;
|
|
39
|
+
private timeoutSymbol?;
|
|
40
|
+
protected homeView?: Viewpoint;
|
|
41
|
+
protected inputManager: InputManager;
|
|
42
|
+
protected cameraManager: CameraManager;
|
|
43
|
+
protected sceneManager: SceneManager;
|
|
44
|
+
protected fontManager?: FontManager;
|
|
45
|
+
protected pickManager: PickManager;
|
|
46
|
+
protected undoManager: UndoManager;
|
|
47
|
+
protected overlayRender: CanvasRender;
|
|
48
|
+
protected css2dRenderer: CSS2DRenderer;
|
|
49
|
+
protected spinner: Spinner;
|
|
50
|
+
protected progressBar?: ProgressBar;
|
|
51
|
+
protected loaderHelper: LoadingHelper;
|
|
52
|
+
protected zoomToRectHelper?: ZoomToRectHelper;
|
|
53
|
+
protected interaction?: Interaction;
|
|
54
|
+
/**
|
|
55
|
+
* Enables selecting an object
|
|
56
|
+
*/
|
|
57
|
+
protected _enableSelection: boolean;
|
|
58
|
+
constructor(viewerCfg: BaseViewerConfig);
|
|
59
|
+
private initLogLevel;
|
|
60
|
+
private initLocalization;
|
|
61
|
+
get viewerContainer(): HTMLElement;
|
|
62
|
+
get widgetContainer(): HTMLElement;
|
|
63
|
+
getUndoManager(): UndoManager;
|
|
64
|
+
getInputManager(): InputManager;
|
|
65
|
+
getCssRender(): CSS2DRenderer;
|
|
66
|
+
getCameraManager(): CameraManager;
|
|
67
|
+
getOverlayRender(): CanvasRender;
|
|
68
|
+
getSceneManager(): SceneManager;
|
|
69
|
+
/**
|
|
70
|
+
* The WebGLRenderer.
|
|
71
|
+
*/
|
|
72
|
+
get renderer(): THREE.WebGLRenderer;
|
|
73
|
+
/**
|
|
74
|
+
* Current camera.
|
|
75
|
+
*/
|
|
76
|
+
get camera(): THREE.PerspectiveCamera | THREE.OrthographicCamera;
|
|
77
|
+
/**
|
|
78
|
+
* Current Scene.
|
|
79
|
+
*/
|
|
80
|
+
get scene(): THREE.Scene<THREE.Object3DEventMap>;
|
|
81
|
+
/**
|
|
82
|
+
* Gets if selection is enabled.
|
|
83
|
+
*/
|
|
84
|
+
abstract get enableSelection(): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Sets if selection is enabled.
|
|
87
|
+
* A derived class may need to clean up selected object if any.
|
|
88
|
+
*/
|
|
89
|
+
abstract set enableSelection(enable: boolean);
|
|
90
|
+
abstract setObjectHighlight(object: THREE.Object3D): void;
|
|
91
|
+
abstract clearHighlight(): void;
|
|
92
|
+
getRaycaster(): THREE.Raycaster;
|
|
93
|
+
getPickManager(): PickManager;
|
|
94
|
+
getViewerConfig(): BaseViewerConfig;
|
|
95
|
+
getSpinner(): Spinner;
|
|
96
|
+
getFontManager(): FontManager | undefined;
|
|
97
|
+
setInteraction(interaction: Interaction): void;
|
|
98
|
+
private initCSS2DRenderer;
|
|
99
|
+
/**
|
|
100
|
+
* In order to have a better performance, it should only render when necessary.
|
|
101
|
+
* Usually, we should enable render for these cases:
|
|
102
|
+
* - Anything added to, removed from scene, or objects' position, scale, rotation, opacity, material, etc. changed
|
|
103
|
+
* - Anything selected/unselected
|
|
104
|
+
* - Camera changed
|
|
105
|
+
* - Render area resized
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
enableRender: (time?: number) => void;
|
|
109
|
+
protected animate(timeStamp?: number): void;
|
|
110
|
+
resize(): void;
|
|
111
|
+
/**
|
|
112
|
+
* Sets decoder path for draco loader.
|
|
113
|
+
* Draco decoder will be used if a model is draco encoded.
|
|
114
|
+
* @param decoderPath e.g., "libs/draco/gltf/"
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
setDracoDecoderPath(path: string): void;
|
|
118
|
+
abstract loadModel(modelCfg: ModelConfig, onProgress?: (event: ProgressEvent) => void): Promise<void>;
|
|
119
|
+
addModel(model: Model): void;
|
|
120
|
+
removeModelById(modelId: string): void;
|
|
121
|
+
setFont(urls: string[]): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
* @description 2d ignore position z.
|
|
125
|
+
*/
|
|
126
|
+
is3d(): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Gets how long a pixel represents in world coordinate.
|
|
129
|
+
* This works fine for OrthographicCamera.
|
|
130
|
+
* As for PerspectiveCamera, a pixel represents different size for different position,
|
|
131
|
+
* depends on how far the camera is and its fov, etc. We'll simply take the camera target as the position to calculate.
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
getPixelSizeInWorldCoord(): number;
|
|
135
|
+
/**
|
|
136
|
+
* @description {en} Asks user to select a box area, and zooms to it.
|
|
137
|
+
* @description {zh} 询问用户选择一个框选区域,然后缩放到该区域。
|
|
138
|
+
* @example
|
|
139
|
+
* ``` typescript
|
|
140
|
+
* viewer.zoomToRect();
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
zoomToRect(): void;
|
|
144
|
+
/**
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
deactivateZoomRect(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Gets an unique modelId in case the expected id is duplicated.
|
|
150
|
+
*/
|
|
151
|
+
protected getUniqueModelId(expectedModelId: string): string;
|
|
152
|
+
/**
|
|
153
|
+
* Gets all objects' bounding box.
|
|
154
|
+
*/
|
|
155
|
+
getBBox(): THREE.Box3;
|
|
156
|
+
/**
|
|
157
|
+
* Flies to given object and keep current view direction unchanged.
|
|
158
|
+
*/
|
|
159
|
+
flyToObject(object: THREE.Object3D): void;
|
|
160
|
+
flyToObjectFront(object: THREE.Object3D): Promise<unknown>;
|
|
161
|
+
flyToObjects(objects: THREE.Object3D[]): void;
|
|
162
|
+
/**
|
|
163
|
+
* Make camera fly to target position with given lookAt position
|
|
164
|
+
* @param position camera's target position
|
|
165
|
+
* @param lookAt camera's new lookAt position
|
|
166
|
+
*/
|
|
167
|
+
flyTo(position: THREE.Vector3, lookAt: THREE.Vector3, enableTransition?: boolean): void;
|
|
168
|
+
/**
|
|
169
|
+
* Views objects by given direction.
|
|
170
|
+
*/
|
|
171
|
+
flyToDirection(direction: THREE.Vector3): void;
|
|
172
|
+
/**
|
|
173
|
+
* Goes to home view.
|
|
174
|
+
*/
|
|
175
|
+
goToHomeView(): void;
|
|
176
|
+
/**
|
|
177
|
+
* Fits the camera to view all objects in scene, keeps current view
|
|
178
|
+
* direction unchanged.
|
|
179
|
+
*/
|
|
180
|
+
viewFitAll(): void;
|
|
181
|
+
/**
|
|
182
|
+
* Zooms to given bounding box.
|
|
183
|
+
*/
|
|
184
|
+
zoomToBBox(bbox: THREE.Box3): void;
|
|
185
|
+
/**
|
|
186
|
+
* Picks the closest object by mouse position.
|
|
187
|
+
*/
|
|
188
|
+
pickObject(mousePosition: THREE.Vector2, layerChannels?: number[]): THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>> | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Picks objects by mouse position.
|
|
191
|
+
*/
|
|
192
|
+
pickObjects(mousePosition: THREE.Vector2, layerChannels?: number[]): THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>>[];
|
|
193
|
+
getRaycastableObjects(): THREE.Object3D<THREE.Object3DEventMap>[];
|
|
194
|
+
/**
|
|
195
|
+
* @description {en} Sets background color.
|
|
196
|
+
* @param r Red channel value between 0 and 1.
|
|
197
|
+
* @param g Green channel value between 0 and 1.
|
|
198
|
+
* @param b Blue channel value between 0 and 1.
|
|
199
|
+
* @example
|
|
200
|
+
* ``` typescript
|
|
201
|
+
* // Sets background to gray
|
|
202
|
+
* viewer.setBackgroundColor(0.5, 0.5, 0.5);
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
setBackgroundColor(r: number, g: number, b: number): void;
|
|
206
|
+
/**
|
|
207
|
+
* Sets global clip planes.
|
|
208
|
+
* This is mainly used by 3d viewers.
|
|
209
|
+
*/
|
|
210
|
+
setGlobalClipPlanes(planes: THREE.Plane[]): void;
|
|
211
|
+
getCameraProjection(): CameraProjection;
|
|
212
|
+
setCameraProjection(proj: CameraProjection): void;
|
|
213
|
+
enableControl(enable: boolean): void;
|
|
214
|
+
enableRotate(enable: boolean): void;
|
|
215
|
+
enableZoom(enable: boolean): void;
|
|
216
|
+
enablePan(enable: boolean): void;
|
|
217
|
+
getHomeView(): Viewpoint | undefined;
|
|
218
|
+
setHomeView(viewpoint: Viewpoint): void;
|
|
219
|
+
getCameraInfo(): CameraInfo;
|
|
220
|
+
goToViewpoint(vp: Viewpoint): void;
|
|
221
|
+
getCameraDirection(): THREE.Vector3;
|
|
222
|
+
getRenderInfo(): {
|
|
223
|
+
drawCalls: number;
|
|
224
|
+
lines: number;
|
|
225
|
+
points: number;
|
|
226
|
+
triangles: number;
|
|
227
|
+
geometries: number;
|
|
228
|
+
textures: number;
|
|
229
|
+
materials: number;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
*
|
|
233
|
+
*/
|
|
234
|
+
destroy(): void;
|
|
235
|
+
/**
|
|
236
|
+
* Installs a Plugin.
|
|
237
|
+
*/
|
|
238
|
+
addPlugin(plugin: Plugin): void;
|
|
239
|
+
/**
|
|
240
|
+
* Uninstalls a Plugin, clearing content from it first.
|
|
241
|
+
*/
|
|
242
|
+
removePlugin(plugin: Plugin): void;
|
|
243
|
+
/**
|
|
244
|
+
* Clears all plugins.
|
|
245
|
+
* A plugin is not created by viewer, thus, won't be destroyed by viewer.
|
|
246
|
+
*/
|
|
247
|
+
clearPlugins(): void;
|
|
248
|
+
/**
|
|
249
|
+
* Finds a Plugin.
|
|
250
|
+
*/
|
|
251
|
+
findPlugin(id: string): Plugin | undefined;
|
|
252
|
+
}
|
|
253
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { BaseViewer } from "./BaseViewer";
|
|
3
|
+
import { ViewerName } from "./Constants";
|
|
4
|
+
import { Viewer3dConfig, ModelConfig, Viewpoint } from "../../core/Configs";
|
|
5
|
+
import { EffectManager } from "../../core/effect";
|
|
6
|
+
import { EventInfo } from "../../core/input-manager/InputManager";
|
|
7
|
+
import { BimTilesModel, TileObject } from "../../core/model";
|
|
8
|
+
/**
|
|
9
|
+
* BimTilesViewer
|
|
10
|
+
*/
|
|
11
|
+
export declare class BimTilesViewer extends BaseViewer {
|
|
12
|
+
name: ViewerName;
|
|
13
|
+
protected pickUsageScene: THREE.Scene;
|
|
14
|
+
protected effect: EffectManager;
|
|
15
|
+
loadedModels: BimTilesModel[];
|
|
16
|
+
selectedObject?: TileObject;
|
|
17
|
+
/**
|
|
18
|
+
* Enables the feature to hover on an object and blend it color a bit.
|
|
19
|
+
*/
|
|
20
|
+
enableHoverEffect: boolean;
|
|
21
|
+
constructor(viewerCfg: Viewer3dConfig, homeView?: Viewpoint);
|
|
22
|
+
protected setupDefaultEvents(): void;
|
|
23
|
+
protected setDefaultBackground(): void;
|
|
24
|
+
private renderImmediately;
|
|
25
|
+
protected handleAnchorPoint(intersect?: THREE.Intersection): void;
|
|
26
|
+
protected handleClickObject(intersection: TileObject): void;
|
|
27
|
+
is3d(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Sets a model's opacity.
|
|
30
|
+
*/
|
|
31
|
+
setModelOpacity(modelId: string, opacity: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Clears a model's opacity.
|
|
34
|
+
*/
|
|
35
|
+
clearModelOpacity(modelId: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Sets all models' opacity.
|
|
38
|
+
*/
|
|
39
|
+
setModelsOpacity(opacity: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* Clears all models' opacity.
|
|
42
|
+
*/
|
|
43
|
+
clearModelsOpacity(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Enables a model's outline.
|
|
46
|
+
*/
|
|
47
|
+
enableModelOutline(modelId: string, enable: boolean): void;
|
|
48
|
+
/**
|
|
49
|
+
* Enables all models' outline.
|
|
50
|
+
*/
|
|
51
|
+
enableModelsOutline(enable: boolean): void;
|
|
52
|
+
setModelVisible(modelId: string, visible: boolean): void;
|
|
53
|
+
setModelsVisible(visible: boolean): void;
|
|
54
|
+
clearHighlight(): void;
|
|
55
|
+
setDoubleSidedMaterials(): void;
|
|
56
|
+
revertDoubleSidedMaterials(): void;
|
|
57
|
+
clearSelection(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Gets if selection is enabled.
|
|
60
|
+
*/
|
|
61
|
+
get enableSelection(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Sets if selection is enabled.
|
|
64
|
+
*/
|
|
65
|
+
set enableSelection(enable: boolean);
|
|
66
|
+
flyToUserId(tilesetId: number, userId: number): void;
|
|
67
|
+
getBoxByUserId(tilesetId: number, userId: number): THREE.Box3 | undefined;
|
|
68
|
+
protected handleMouseMove(event: EventInfo): void;
|
|
69
|
+
private update3dTiles;
|
|
70
|
+
/**
|
|
71
|
+
* BimTiles does not support external incoming matrix.
|
|
72
|
+
* Don't support external incoming modelId.
|
|
73
|
+
*/
|
|
74
|
+
loadModel(modelCfg: ModelConfig, onProgress?: ((event: ProgressEvent<EventTarget>) => void) | undefined): Promise<void>;
|
|
75
|
+
setObjectHighlight(object: THREE.Object3D): void;
|
|
76
|
+
setObjectHighlightedByUserIds(modelId: number, userIds: number[], highlight: boolean): void;
|
|
77
|
+
setObjectOpacityByUserIds(modelId: number, userIds: number[], opacity: number): void;
|
|
78
|
+
setOtherObjectOpacityByUserIds(modelId: number, userIds: number[], opacity: number): void;
|
|
79
|
+
setObjectVisibleByUserIds(modelId: number, userIds: number[], visible: boolean): void;
|
|
80
|
+
setOtherObjectVisibleByUserIds(modelId: number, userIds: number[], visible: boolean): void;
|
|
81
|
+
setObjectHoveredByUserId(modelId: number, userId: number, hovered: boolean): void;
|
|
82
|
+
/**
|
|
83
|
+
* Gets the hovered object if any.
|
|
84
|
+
*/
|
|
85
|
+
getHoveredObject(): TileObject | undefined;
|
|
86
|
+
clearHovered(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Checks if there is any visible object.
|
|
89
|
+
*/
|
|
90
|
+
hasVisibleObject(): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Checks if there is any invisible object.
|
|
93
|
+
*/
|
|
94
|
+
hasInvisibleObject(): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Isolates given object.
|
|
97
|
+
* Which means, other objects will be hidden or transparent.
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* Isolates given objects.
|
|
101
|
+
* Which means, other objects will be hidden or transparent.
|
|
102
|
+
*/
|
|
103
|
+
setModelClipPlanes(modelId: number, planes: THREE.Plane[]): void;
|
|
104
|
+
setGlobalClipPlanes(planes: THREE.Plane[]): void;
|
|
105
|
+
showVertexNormals(show: boolean, size?: number): void;
|
|
106
|
+
getLights(): {
|
|
107
|
+
sun: THREE.DirectionalLight;
|
|
108
|
+
ambient: THREE.Object3D<THREE.Object3DEventMap> | undefined;
|
|
109
|
+
hemisphere: THREE.Object3D<THREE.Object3DEventMap> | undefined;
|
|
110
|
+
};
|
|
111
|
+
debugLights(enable: boolean): void;
|
|
112
|
+
/**
|
|
113
|
+
* Picks objects by mouse position.
|
|
114
|
+
* First get the object through the gpu, and then get the specific intersection point
|
|
115
|
+
*/
|
|
116
|
+
pickObjects(mousePosition: THREE.Vector2, layerChannels?: number[]): THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>>[];
|
|
117
|
+
/**
|
|
118
|
+
* `errorTarget` refers to The target screenspace error in pixels to target when updating the geometry.
|
|
119
|
+
* It represents the maximum acceptable error in pixels for the tiles' geometry.
|
|
120
|
+
* When the actual screenspace error of a tile is below this target, the tile will not be rendered,
|
|
121
|
+
* as it is considered too detailed for the current view.
|
|
122
|
+
* So, a higher `errorTarget` value results in better performance, but less detail in the rendered scene.
|
|
123
|
+
* @default 8
|
|
124
|
+
*/
|
|
125
|
+
getErrorTarget(): number;
|
|
126
|
+
/**
|
|
127
|
+
* Sets errorTarget for all models.
|
|
128
|
+
*/
|
|
129
|
+
setErrorTarget(errorTarget: number): void;
|
|
130
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { BaseViewer } from "./BaseViewer";
|
|
2
|
+
import { Event } from "../utils";
|
|
3
|
+
/**
|
|
4
|
+
* Base plugin config.
|
|
5
|
+
*/
|
|
6
|
+
export interface PluginConfig {
|
|
7
|
+
/**
|
|
8
|
+
* ID for this Plugin, unique within its viewer.
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Base plugin class.
|
|
14
|
+
*/
|
|
15
|
+
export declare abstract class Plugin<PluginEvents extends Record<string, unknown> = {}> extends Event<PluginEvents> {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
protected viewer: BaseViewer;
|
|
18
|
+
/**
|
|
19
|
+
* Creates this Plugin and installs it into the given {@link Viewer}.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} id ID for this plugin, unique among all plugins in the viewer.
|
|
22
|
+
* @param {Viewer} viewer The viewer.
|
|
23
|
+
* @param {Object} [cfg] Options
|
|
24
|
+
*/
|
|
25
|
+
constructor(viewer: BaseViewer, cfg: PluginConfig);
|
|
26
|
+
/**
|
|
27
|
+
* Destroys this Plugin and removes it from its viewer.
|
|
28
|
+
*/
|
|
29
|
+
destroy(): void;
|
|
30
|
+
}
|