@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,413 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { BaseViewer } from "./BaseViewer";
|
|
3
|
+
import { ViewerName } from "./Constants";
|
|
4
|
+
import { Model2dConfig, Viewer2dConfig } from "../../core/Configs";
|
|
5
|
+
import { DxfData, DxfLayer } from "../../core/dxf";
|
|
6
|
+
import { EventInfo } from "../../core/input-manager/InputManager";
|
|
7
|
+
import { Model2d } from "../../core/model";
|
|
8
|
+
export interface EntityData {
|
|
9
|
+
modelId: string;
|
|
10
|
+
layerName: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A group of dxf/dwg layers for a drawing.
|
|
14
|
+
*/
|
|
15
|
+
export interface DxfLayers {
|
|
16
|
+
modelId: string;
|
|
17
|
+
layers: Record<string, DxfLayer>;
|
|
18
|
+
}
|
|
19
|
+
export interface PdfLayers {
|
|
20
|
+
modelId: string;
|
|
21
|
+
layers: Record<string, PdfLayer>;
|
|
22
|
+
}
|
|
23
|
+
export interface PdfLayer {
|
|
24
|
+
name: string;
|
|
25
|
+
id: string;
|
|
26
|
+
index: string;
|
|
27
|
+
visible: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface PdfData {
|
|
30
|
+
threejsObject: THREE.Object3D;
|
|
31
|
+
layers: Record<string, PdfLayer>;
|
|
32
|
+
layersAndThreejsObjects?: Record<string, THREE.Object3D[]>;
|
|
33
|
+
loadedEntityCount: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export declare const GroundPlaneRenderOrder = -1000;
|
|
39
|
+
/**
|
|
40
|
+
* Threejs objects are organized in tree view as below:
|
|
41
|
+
*
|
|
42
|
+
* - modelLevelObject1 (THREE.Group, name = <modelId>)
|
|
43
|
+
* - layoutLevelObject1 (THREE.Group, name = <layout name>, used to control layout visibility)
|
|
44
|
+
* - entityLevelObject1 (THREE.Point/Line/Mesh/Group)
|
|
45
|
+
*
|
|
46
|
+
* - Layer threejs objects
|
|
47
|
+
* {
|
|
48
|
+
* layerName:[threejsObject1,threejsObject2,threejsObject3,...] (THREE.Point/Line/Mesh)
|
|
49
|
+
* }
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* "dwg" is short for "drawing", it is a file format saved by AutoCAD.
|
|
53
|
+
* And "dxf" is data exchange format, which can be converted from a dwg file.
|
|
54
|
+
* We cannot read dwg directly, and need to convert it to dxf first via ODA.
|
|
55
|
+
*
|
|
56
|
+
* Supported dxf version: AutoCAD 2018. Both binary and ascii are supported.
|
|
57
|
+
*
|
|
58
|
+
* Json Encoding: UTF-8 encoding without BOM
|
|
59
|
+
*
|
|
60
|
+
* Coordinate system: right-handed, y-up
|
|
61
|
+
*
|
|
62
|
+
* About units:
|
|
63
|
+
* - The unit of distance follows the master dxf file's unit
|
|
64
|
+
* - The unit of area follows the master dxf file's unit
|
|
65
|
+
* - The unit of angle is "degree", counterclockwise
|
|
66
|
+
* - The unit of time is "second"
|
|
67
|
+
*
|
|
68
|
+
* Color: use rgb/rgba, values between 0-1
|
|
69
|
+
*
|
|
70
|
+
* About Measurement in Viewer2d:
|
|
71
|
+
* - A measurement is generated by Viewer2d.
|
|
72
|
+
* - Measurements data should be stored by users, so users can restore measurements data into Viewer2d later.
|
|
73
|
+
* - Viewer2d manages measurements data, it can be created, removed, hidden, etc.
|
|
74
|
+
* - Viewer2d doesn't maintain the relationship between measurement and layout.
|
|
75
|
+
*
|
|
76
|
+
* About Markup in Viewer2d:
|
|
77
|
+
* Markup is pretty similar to measurement.
|
|
78
|
+
*
|
|
79
|
+
* About Hotpoint in Viewer2d:
|
|
80
|
+
* - A hotpoint is created and stored by user.
|
|
81
|
+
* - A hotpoint can be added to, and removed from Viewer2d.
|
|
82
|
+
* - Caller should set a hotpointId that is unique in the session of current Viewer2d.
|
|
83
|
+
* - Viewer2d doesn't hide a hotpoint, user is able to do it.
|
|
84
|
+
* - Viewer2d doesn't maintain the relationship between hotpoint and layout.
|
|
85
|
+
*
|
|
86
|
+
* About layouts
|
|
87
|
+
* - Each layout has its own home view.
|
|
88
|
+
* - When switching to another layout, it clears all measurements, markups and hotpoints.
|
|
89
|
+
* - When switching to another layout, it deactivates any in-progress operation like measurement, markup, etc.
|
|
90
|
+
*
|
|
91
|
+
* About overlay
|
|
92
|
+
* - It supports to add as many models as user want, as long as the browser has sufficient memory, cpu/gpu, etc.
|
|
93
|
+
* - The first model is called "master" model, others are called "overlay" models.
|
|
94
|
+
* - It ignores an overlay model's paper space.
|
|
95
|
+
* - An overlay model's unit should be converted to master model's unit if they are not the same.
|
|
96
|
+
* - We'll append modelId as prefix for getLayers()
|
|
97
|
+
*
|
|
98
|
+
* About comparision
|
|
99
|
+
* - It compares just "Model" spaces.
|
|
100
|
+
* - It compares entities with the same handles and types.
|
|
101
|
+
* - It compares entities' geometries, positions, scales, etc.
|
|
102
|
+
* - It ignores a layer's visibility, freeze settings.
|
|
103
|
+
* - It ignores an entity's properties, like linetype, line width, fill pattern, font, color, etc.
|
|
104
|
+
* - It ignores spatial filters (xclip) of block references.
|
|
105
|
+
* - It ignores layer relative operations, like moving an entity to another layer, changing a layer color, etc.
|
|
106
|
+
* - By default, an "Added" entity is rendered in green, a "Removed" entity is in red, a "Modified" entity is composed by two parts, one "Removed" and another "Added".
|
|
107
|
+
*
|
|
108
|
+
* About undo/redo
|
|
109
|
+
* - It supports undo/redo for measurement and markup operations. E.g., creating/deleting/moving a markup.
|
|
110
|
+
* - Setting/removing a batch of measurements or markups will be taken as one operation.
|
|
111
|
+
* - Switching to another layout clears all undo/redo history.
|
|
112
|
+
*
|
|
113
|
+
* About OSnap
|
|
114
|
+
* - It supports snapping to the end points and middle point of a line.
|
|
115
|
+
* - It supports snapping to the intersection point of two lines.
|
|
116
|
+
* - It supports snapping to the foot of perpendicular against a line.
|
|
117
|
+
* - It supports snapping to any point along a line.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ``` typescript
|
|
121
|
+
* const viewerCfg = {
|
|
122
|
+
* containerId: "myCanvas",
|
|
123
|
+
* enableSpinner: true,
|
|
124
|
+
* enableLayoutBar: true,
|
|
125
|
+
* };
|
|
126
|
+
* const modelCfg = {
|
|
127
|
+
* modelId: "id_0",
|
|
128
|
+
* name: "sample",
|
|
129
|
+
* src: "http://www.abc.com/sample.dxf",
|
|
130
|
+
* }
|
|
131
|
+
* const fontFiles = ["http://www.abc.com/hztxt.shx", "http://www.abc.com/simplex.shx"];
|
|
132
|
+
*
|
|
133
|
+
* const viewer = new Viewer2d(viewerCfg);
|
|
134
|
+
* await viewer.setFont(fontFiles);
|
|
135
|
+
* await viewer.loadModel(modelCfg);
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare class Viewer2d extends BaseViewer {
|
|
139
|
+
name: ViewerName;
|
|
140
|
+
loadedModels: Model2d[];
|
|
141
|
+
/**
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
masterModelId: string;
|
|
145
|
+
private activeLayoutName;
|
|
146
|
+
private dxfLayoutBar?;
|
|
147
|
+
private layoutInfos;
|
|
148
|
+
private units;
|
|
149
|
+
private enableHideVisuallySmallObjects;
|
|
150
|
+
private sortedHidableObjects;
|
|
151
|
+
private lastCameraZoom;
|
|
152
|
+
groundPlane?: THREE.Mesh;
|
|
153
|
+
raycastableObjects?: THREE.Object3D[];
|
|
154
|
+
constructor(viewerCfg: Viewer2dConfig);
|
|
155
|
+
get camera(): THREE.OrthographicCamera;
|
|
156
|
+
private setDefaultBackground;
|
|
157
|
+
/**
|
|
158
|
+
* Used to indicate how many dxf is loading
|
|
159
|
+
*/
|
|
160
|
+
private loadingDxfCount;
|
|
161
|
+
/**
|
|
162
|
+
* @description {en} Loads a dxf file.
|
|
163
|
+
* The first loaded file will be taken as a "master" model.
|
|
164
|
+
* Any other files are non-master, we call "overlay" model.
|
|
165
|
+
* We'll load everything of a master model, including model and paper space.
|
|
166
|
+
* For an overlay model, we'll only load its model space. And its model space can only
|
|
167
|
+
* overly to master model's model space.
|
|
168
|
+
* @description {zh} 加载 dxf 文件。
|
|
169
|
+
* 第一个加载的文件将被视为“主”模型。
|
|
170
|
+
* 任何其他文件都是非主文件,我们称之为“叠加”模型。
|
|
171
|
+
* 我们将加载主模型的所有内容,包括模型和图纸空间。
|
|
172
|
+
* 对于叠加模型,我们只会加载其模型空间。并且它的模型空间只能叠加到主模型的模型空间上。
|
|
173
|
+
* @param modelCfg
|
|
174
|
+
* - {en} The configuration of the model to be loaded.
|
|
175
|
+
* - {zh} 要加载的模型的配置。
|
|
176
|
+
* @param onProgress
|
|
177
|
+
* - {en} A callback function to indicate the loading progress.
|
|
178
|
+
* - {zh} 用于指示加载进度的回调函数。
|
|
179
|
+
* @example
|
|
180
|
+
* ``` typescript
|
|
181
|
+
* const viewerCfg = {
|
|
182
|
+
* containerId: "myCanvas",
|
|
183
|
+
* };
|
|
184
|
+
* const modelCfg = {
|
|
185
|
+
* modelId: "id_0",
|
|
186
|
+
* name: "dxf 0",
|
|
187
|
+
* src: "http://www.abc.com/sample.dxf",
|
|
188
|
+
* }
|
|
189
|
+
* const viewer = new Viewer2d(viewerCfg);
|
|
190
|
+
* await viewer.loadModel(modelCfg, (event) => {
|
|
191
|
+
* const progress = (event.loaded * 100) / event.total;
|
|
192
|
+
* console.log(`Loading progress: ${progress}%`);
|
|
193
|
+
* });
|
|
194
|
+
* console.log("Loaded");
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
loadModel(modelCfg: Model2dConfig, onProgress?: ((event: ProgressEvent<EventTarget>) => void) | undefined): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Parses a dwg or dxf and return json object.
|
|
200
|
+
* @param modelCfg
|
|
201
|
+
* @param onProgress
|
|
202
|
+
*/
|
|
203
|
+
parseFile(modelCfg: Model2dConfig, onProgress?: ((event: ProgressEvent<EventTarget>) => void) | undefined): Promise<DxfData>;
|
|
204
|
+
addModel(model: Model2d): void;
|
|
205
|
+
private getDxfUnits;
|
|
206
|
+
private handleOverlayDxf;
|
|
207
|
+
setObjectHighlight(object: THREE.Object3D): void;
|
|
208
|
+
setObjectUnHighlight(object: THREE.Object3D): void;
|
|
209
|
+
clearHighlight(): void;
|
|
210
|
+
clearSelection(): void;
|
|
211
|
+
/**
|
|
212
|
+
* Gets if selection is enabled.
|
|
213
|
+
*/
|
|
214
|
+
get enableSelection(): boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Sets if selection is enabled.
|
|
217
|
+
*/
|
|
218
|
+
set enableSelection(enable: boolean);
|
|
219
|
+
/**
|
|
220
|
+
* Creates a ground plane which is much bigger than bbox.
|
|
221
|
+
*/
|
|
222
|
+
private updateGroundPlane;
|
|
223
|
+
getRaycastableObjects(): THREE.Object3D[];
|
|
224
|
+
/**
|
|
225
|
+
* Gets the corresponding viewport by judging that the point is in the viewport
|
|
226
|
+
*/
|
|
227
|
+
private getViewportByPoint;
|
|
228
|
+
/**
|
|
229
|
+
* Gets the world position by the mouse's position.
|
|
230
|
+
*/
|
|
231
|
+
getWorldPositionByMousePick(mousePosition: THREE.Vector2): THREE.Vector3 | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* @description {en} Activates a layout.
|
|
234
|
+
* @description {zh} 激活布局。
|
|
235
|
+
* @param layoutName
|
|
236
|
+
* - {en} The name of the layout to be activated.
|
|
237
|
+
* - {zh} 要激活的布局名称。
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* viewer.activateLayout('Layout1');
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
activateLayout(layoutName?: string): void;
|
|
244
|
+
private getLayoutExtentEx;
|
|
245
|
+
private getActiveLayoutInfo;
|
|
246
|
+
private getLayoutByName;
|
|
247
|
+
/**
|
|
248
|
+
* Gets loaded entity count
|
|
249
|
+
* @internal
|
|
250
|
+
* @returns {number}
|
|
251
|
+
*/
|
|
252
|
+
getEntityCount(): number;
|
|
253
|
+
/**
|
|
254
|
+
* @description Gets layout names of the master model.
|
|
255
|
+
* @returns Layout names of the master model.
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* const layoutNames = viewer.getLayoutNames();
|
|
259
|
+
* console.log(layoutNames); // ['Model', 'Layout1', 'Layout2']
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
getLayoutNames(): string[];
|
|
263
|
+
/**
|
|
264
|
+
* Gets LayoutInfo by layoutName. It creats LayoutInfo if doesn't exist.
|
|
265
|
+
*/
|
|
266
|
+
private getLayoutInfo;
|
|
267
|
+
goToHomeView(): void;
|
|
268
|
+
zoomToBBox(bbox: THREE.Box3): void;
|
|
269
|
+
/**
|
|
270
|
+
* @description {en} Gets current view extent.
|
|
271
|
+
* This is useful for user to save this value as a viewpoint, and jump to this viewpoint next time.
|
|
272
|
+
* @description {zh} 获取当前视图范围。
|
|
273
|
+
* 用户可使用该接口获取当前视口范围,并在适当的场景下跳转到该视口范围。
|
|
274
|
+
* @example
|
|
275
|
+
* ``` typescript
|
|
276
|
+
* const box = viewer.getCurrentViewExtent();
|
|
277
|
+
* console.log("Current view extent:", box);
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
getCurrentViewExtent(): THREE.Box2;
|
|
281
|
+
/**
|
|
282
|
+
* Gets hit result by Normalized Device Coordinates.
|
|
283
|
+
* Lower left coordinate: (-1, -1)
|
|
284
|
+
* Upper right coordinate: (1, 1)
|
|
285
|
+
*/
|
|
286
|
+
protected getHitResultByNdcCoordinate(coord: THREE.Vector2): THREE.Vector2 | undefined;
|
|
287
|
+
/**
|
|
288
|
+
* Gets mouse hit result in world coordinate
|
|
289
|
+
* @example
|
|
290
|
+
* ``` typescript
|
|
291
|
+
* document.addEventListener("click", (event) => {
|
|
292
|
+
* const result = viewer.getHitResult(event);
|
|
293
|
+
* const loc = result?.location;
|
|
294
|
+
* if (loc) {
|
|
295
|
+
* console.log(`Clicked at x: ${loc[0]}, y: ${loc[1]}`);
|
|
296
|
+
* }
|
|
297
|
+
* });
|
|
298
|
+
* ```
|
|
299
|
+
* @internal
|
|
300
|
+
*/
|
|
301
|
+
getHitResult(event: MouseEvent | PointerEvent | EventInfo): THREE.Vector2 | undefined;
|
|
302
|
+
/**
|
|
303
|
+
* @description {en} Gets active layout.
|
|
304
|
+
* @description {zh} 获取当前布局。
|
|
305
|
+
* @returns
|
|
306
|
+
* - {en} Active layout name or undefined.
|
|
307
|
+
* - {zh} 当前激活的布局名称或undefined。
|
|
308
|
+
* @example
|
|
309
|
+
* ``` typescript
|
|
310
|
+
* const activeLayout = viewer.getActiveLayoutName();
|
|
311
|
+
* console.log(activeLayout);
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
getActiveLayoutName(): string | undefined;
|
|
315
|
+
zoomIn(step?: number): void;
|
|
316
|
+
zoomOut(step?: number): void;
|
|
317
|
+
/**
|
|
318
|
+
* @description {en} Gets dxf layers.
|
|
319
|
+
* @description {zh} 获取dxf图层。
|
|
320
|
+
* @returns
|
|
321
|
+
* - {en} Dxf layers.
|
|
322
|
+
* - {zh} dxf图层。
|
|
323
|
+
* @example
|
|
324
|
+
* ``` typescript
|
|
325
|
+
* const dxfLayers = viewer.getLayers();
|
|
326
|
+
* for (let i = 0; i < dxfLayers.length; ++i) {
|
|
327
|
+
* const layers = dxfLayers[i].layers;
|
|
328
|
+
* const layerNames = Object.keys(layers).sort();
|
|
329
|
+
* console.log(layerNames);
|
|
330
|
+
* }
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
getLayers(): (DxfLayers | PdfLayers)[];
|
|
334
|
+
/**
|
|
335
|
+
* Sets model's (aka, a dxf file) visibility.
|
|
336
|
+
* @throws Throws exception if modelId doesn't exist.
|
|
337
|
+
* @internal
|
|
338
|
+
*/
|
|
339
|
+
setModelVisibility(modelId: string, visible: boolean): void;
|
|
340
|
+
/**
|
|
341
|
+
* @description {en} Sets layer's visibility.
|
|
342
|
+
* @description {zh} 设置图层的可见性。
|
|
343
|
+
* @param layerName
|
|
344
|
+
* - {en} Layer's name to show or hide.
|
|
345
|
+
* - {zh} 要显示或隐藏的图层名称。
|
|
346
|
+
* @param visible
|
|
347
|
+
* - {en} Layer's target visibility.
|
|
348
|
+
* - {zh} 图层的目标可见性。
|
|
349
|
+
* @param modelId
|
|
350
|
+
* - {en} Useful when more than one model is loaded, if not specified, will use the master model.
|
|
351
|
+
* - {zh} 当加载了多个模型时有用,如果未指定,将使用主模型。
|
|
352
|
+
* @throws Error
|
|
353
|
+
* - {en}: Throws exception if given modelId doesn't exist.
|
|
354
|
+
* - {zh} 如果给定的modelId不存在,则抛出异常。
|
|
355
|
+
* @example
|
|
356
|
+
* ``` typescript
|
|
357
|
+
* // Hides layer "0"
|
|
358
|
+
* viewer.setLayerVisibility("0", false);
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
setLayerVisibility(layerName: string, visible: boolean, modelId?: string): void;
|
|
362
|
+
/**
|
|
363
|
+
* Sets layer's opacity
|
|
364
|
+
* @internal
|
|
365
|
+
*/
|
|
366
|
+
setLayerOpacity(layerName: string, opacity: number, modelId?: string): void;
|
|
367
|
+
/**
|
|
368
|
+
* Sets layer's color
|
|
369
|
+
* @throws Throws exception if layer doesn't exist.
|
|
370
|
+
* @internal
|
|
371
|
+
*/
|
|
372
|
+
setLayerColor(layerName: string, color: number, modelId?: string): void;
|
|
373
|
+
/**
|
|
374
|
+
* Resets a layer's color.
|
|
375
|
+
* @internal
|
|
376
|
+
*/
|
|
377
|
+
resetLayerColor(layerName: string, modelId?: string): void;
|
|
378
|
+
/**
|
|
379
|
+
* Enables to hide visually small objects in order to improve performance.
|
|
380
|
+
*/
|
|
381
|
+
enableHidingVisuallySmallObjects(enable: boolean): void;
|
|
382
|
+
/**
|
|
383
|
+
* If it enabled to hide visually small objects.
|
|
384
|
+
*/
|
|
385
|
+
isHidingVisuallySmallObjectsEnabled(): boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Gets a proper visible pixel size according to given object count.
|
|
388
|
+
* You can understand the size as pixel size, but it is not exactly pixel size.
|
|
389
|
+
* E.g., a line's length is 1000 in world coordinate. When zoom is 1, then it display as (let's say) 1000px.
|
|
390
|
+
* When we zoom out, so the zoom becomes 0.001, then the line displays as 1px. (Not exactly, but you'd better understand it this way).
|
|
391
|
+
* So, when there are less objects in scene, it's likely to see smaller object when it takes n(1, etc.) pixels in screen.
|
|
392
|
+
* And when there are many objects in scene, it's going to hide it when it takes more pixels (7, etc.).
|
|
393
|
+
* - < 10000 objects: 0.3
|
|
394
|
+
* - 10000 - 50000 objects: 0.5-3
|
|
395
|
+
* - > 50000 objects: 3
|
|
396
|
+
*/
|
|
397
|
+
private getVisiblePixelSize;
|
|
398
|
+
private setLayoutHidableObjectArray;
|
|
399
|
+
/**
|
|
400
|
+
* Updates raycaster threshold to a proper value, so user can easily pick points and lines
|
|
401
|
+
*/
|
|
402
|
+
private updateRaycasterThreshold;
|
|
403
|
+
/**
|
|
404
|
+
* Updates hidable objects' visibility once camera.zoom changed.
|
|
405
|
+
* @param enableHideVisuallySmallObjects When enableHideVisuallySmallObjects is set to false, we may force
|
|
406
|
+
* all objects to be visible!
|
|
407
|
+
*/
|
|
408
|
+
private updateHidableObjectsVisibility;
|
|
409
|
+
/**
|
|
410
|
+
* Updates camera zoom value for shader materials, which are created in DxfLoader
|
|
411
|
+
*/
|
|
412
|
+
private updateCameraZoomUniform;
|
|
413
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { BaseViewer } from "./BaseViewer";
|
|
3
|
+
import { ViewerName } from "./Constants";
|
|
4
|
+
import { EffectManager } from "../effect";
|
|
5
|
+
import { Model3d } from "../model";
|
|
6
|
+
import { Viewer3dConfig, ModelConfig, Viewpoint } from "../../core/Configs";
|
|
7
|
+
export declare class Viewer3d extends BaseViewer {
|
|
8
|
+
name: ViewerName;
|
|
9
|
+
loadedModels: Model3d[];
|
|
10
|
+
distanceCullingFactor: number;
|
|
11
|
+
protected effect: EffectManager;
|
|
12
|
+
private shouldDispatchModelLoadEvent;
|
|
13
|
+
constructor(viewerCfg: Viewer3dConfig, homeView?: Viewpoint);
|
|
14
|
+
protected setDefaultBackground(): void;
|
|
15
|
+
is3d(): boolean;
|
|
16
|
+
loadLocalModel(url: string, modelCfg: ModelConfig, manager?: THREE.LoadingManager, onProgress?: (event: ProgressEvent) => void): Promise<void>;
|
|
17
|
+
loadModel(modelCfg: ModelConfig, onProgress?: ((event: ProgressEvent<EventTarget>) => void) | undefined): Promise<void>;
|
|
18
|
+
private loadModelInternal;
|
|
19
|
+
addModel(model: Model3d): void;
|
|
20
|
+
/**
|
|
21
|
+
* Sets distance culling factor in order to improve performance.
|
|
22
|
+
* 0 means distance culling is disabled.
|
|
23
|
+
* 100 means a 1x1 squre mesh is visible within 100.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
setDistanceCullingFactor(val: number): void;
|
|
27
|
+
/**
|
|
28
|
+
* Gets distance culling factor.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
getDistanceCullingFactor(): number;
|
|
32
|
+
/**
|
|
33
|
+
* Sets an object's opacity.
|
|
34
|
+
*/
|
|
35
|
+
setObjectOpacity(object: THREE.Object3D, opacity: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Sets an object's opacity.
|
|
38
|
+
*/
|
|
39
|
+
setOtherObjectsOpacity(object: THREE.Object3D, opacity: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* Clears an object's opacity.
|
|
42
|
+
*/
|
|
43
|
+
clearObjectOpacity(object: THREE.Object3D): void;
|
|
44
|
+
/**
|
|
45
|
+
* Sets a model's opacity.
|
|
46
|
+
*/
|
|
47
|
+
setModelOpacity(modelId: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Clears a model's opacity.
|
|
50
|
+
*/
|
|
51
|
+
clearModelOpacity(modelId: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Sets all models' opacity.
|
|
54
|
+
*/
|
|
55
|
+
setModelsOpacity(opacity: number): void;
|
|
56
|
+
/**
|
|
57
|
+
* Clears all models' opacity.
|
|
58
|
+
*/
|
|
59
|
+
clearModelsOpacity(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Checks if there is any transparent object in any model.
|
|
62
|
+
* Note that this only consider the objects that we set as transparent,
|
|
63
|
+
* it does not count objects that are transparent by default (like glass).
|
|
64
|
+
*/
|
|
65
|
+
hasTransparentObject(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Sets an object's visibility.
|
|
68
|
+
*/
|
|
69
|
+
setObjectVisible(object: THREE.Object3D, visible: boolean): void;
|
|
70
|
+
/**
|
|
71
|
+
* Hides all other objects except the given one.
|
|
72
|
+
*/
|
|
73
|
+
hideOtherObjects(object: THREE.Object3D): void;
|
|
74
|
+
/**
|
|
75
|
+
* Sets a model's visibility.
|
|
76
|
+
*/
|
|
77
|
+
setModelVisible(modelId: string, visible: boolean): void;
|
|
78
|
+
/**
|
|
79
|
+
* Sets all models' visibility.
|
|
80
|
+
*/
|
|
81
|
+
setModelsVisible(visible: boolean): void;
|
|
82
|
+
/**
|
|
83
|
+
* Enables a model's outline.
|
|
84
|
+
*/
|
|
85
|
+
enableModelOutline(modelId: string, enable: boolean): void;
|
|
86
|
+
/**
|
|
87
|
+
* Enables all models' outline.
|
|
88
|
+
*/
|
|
89
|
+
enableModelsOutline(enable: boolean): void;
|
|
90
|
+
/**
|
|
91
|
+
* Highlights an object.
|
|
92
|
+
* TODO: support merged object and InstancedMesh
|
|
93
|
+
*/
|
|
94
|
+
setObjectHighlight(object: THREE.Object3D): void;
|
|
95
|
+
/**
|
|
96
|
+
* Gets highlighted object.
|
|
97
|
+
*/
|
|
98
|
+
getHighlightedObject(): THREE.Object3D | undefined;
|
|
99
|
+
clearHighlight(): void;
|
|
100
|
+
setDoubleSidedMaterials(): void;
|
|
101
|
+
revertDoubleSidedMaterials(): void;
|
|
102
|
+
clearSelection(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Gets if selection is enabled.
|
|
105
|
+
*/
|
|
106
|
+
get enableSelection(): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Sets if selection is enabled.
|
|
109
|
+
*/
|
|
110
|
+
set enableSelection(enable: boolean);
|
|
111
|
+
/**
|
|
112
|
+
* Checks if there is any visible object.
|
|
113
|
+
*/
|
|
114
|
+
hasVisibleObject(): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Checks if there is any invisible object.
|
|
117
|
+
*/
|
|
118
|
+
hasInvisibleObject(): boolean;
|
|
119
|
+
enableSsao(enable: boolean): void;
|
|
120
|
+
getSsaoEnabled(): boolean;
|
|
121
|
+
setEnvironmentData(data?: Uint16Array): Promise<void>;
|
|
122
|
+
setEnvironment(hdrUrl: string): Promise<void>;
|
|
123
|
+
showVertexNormals(show: boolean, size?: number): void;
|
|
124
|
+
getLights(): {
|
|
125
|
+
sun: THREE.DirectionalLight;
|
|
126
|
+
ambient: THREE.Object3D<THREE.Object3DEventMap> | undefined;
|
|
127
|
+
hemisphere: THREE.Object3D<THREE.Object3DEventMap> | undefined;
|
|
128
|
+
};
|
|
129
|
+
debugLights(enable: boolean): void;
|
|
130
|
+
setModelClipPlanes(modelId: number, planes: THREE.Plane[]): void;
|
|
131
|
+
setGlobalClipPlanes(planes: THREE.Plane[]): void;
|
|
132
|
+
/**
|
|
133
|
+
* Generates "uv1" for specified mesh or all meshes in this model. "uv1" is useful for lightmap.
|
|
134
|
+
*/
|
|
135
|
+
generateSmartUv1(object?: THREE.Object3D): void;
|
|
136
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { IsolateObjectsParam, ModelConfig } from "../../core/Configs";
|
|
3
|
+
import { CameraControlsEx } from "../../core/controls/CameraControlsEx";
|
|
4
|
+
import { ModelData3d } from "../../core/model";
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare enum ViewerMode {
|
|
9
|
+
Browser = 0,
|
|
10
|
+
Browserless = 1,
|
|
11
|
+
Headless = 2
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare class Viewer3dLite {
|
|
17
|
+
containerOrCanvas: HTMLDivElement | any;
|
|
18
|
+
glContext?: WebGLRenderingContext | WebGL2RenderingContext;
|
|
19
|
+
camera?: THREE.PerspectiveCamera;
|
|
20
|
+
scene: THREE.Scene;
|
|
21
|
+
renderer?: THREE.WebGLRenderer;
|
|
22
|
+
renderTarget?: THREE.WebGLRenderTarget;
|
|
23
|
+
controls?: CameraControlsEx;
|
|
24
|
+
selectedObject: any | undefined;
|
|
25
|
+
loadedModels: ModelData3d[];
|
|
26
|
+
pmremGenerator?: THREE.PMREMGenerator;
|
|
27
|
+
private clock;
|
|
28
|
+
private viewerMode;
|
|
29
|
+
private raycaster?;
|
|
30
|
+
private savedMaterialsForOpacity?;
|
|
31
|
+
private jobCount;
|
|
32
|
+
private bbox;
|
|
33
|
+
private outlineMaterial;
|
|
34
|
+
private outlineRoot;
|
|
35
|
+
private transparentObjectIds;
|
|
36
|
+
private requestAnimationFrameHandle?;
|
|
37
|
+
constructor(containerOrCanvas: HTMLDivElement | any, // eslint-disable-line
|
|
38
|
+
viewerMode?: ViewerMode, glContext?: WebGLRenderingContext | WebGL2RenderingContext);
|
|
39
|
+
/**
|
|
40
|
+
* Initialize everything it needs
|
|
41
|
+
*/
|
|
42
|
+
init(): void;
|
|
43
|
+
private initScene;
|
|
44
|
+
private isBrowserlessMode;
|
|
45
|
+
private isBrowserMode;
|
|
46
|
+
private initRenderer;
|
|
47
|
+
private initCamera;
|
|
48
|
+
private initControls;
|
|
49
|
+
private initLights;
|
|
50
|
+
/**
|
|
51
|
+
* Initialize mouse/pointer events
|
|
52
|
+
*/
|
|
53
|
+
private initPointerEvents;
|
|
54
|
+
animate(): void;
|
|
55
|
+
destroy(): void;
|
|
56
|
+
loadLocalModel(url: string, modelCfg: ModelConfig, onProgress?: (event: ProgressEvent) => void): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* We don't plan to support onProgress really well in this class.
|
|
59
|
+
*/
|
|
60
|
+
loadModel(modelCfg: ModelConfig, onProgress?: (event: ProgressEvent) => void): Promise<void>;
|
|
61
|
+
parseGltf(data: ArrayBuffer | string, modelCfg: ModelConfig, onSuccess: (object: THREE.Object3D) => void, onError?: (event: ErrorEvent) => void): void;
|
|
62
|
+
/**
|
|
63
|
+
* Applies options and add object to scene.
|
|
64
|
+
*/
|
|
65
|
+
applyOptionsAndAddToScene: (url: string, object: THREE.Object3D, modelCfg: ModelConfig, onProgress?: ((event: ProgressEvent) => void) | undefined) => Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param model
|
|
69
|
+
* @returns
|
|
70
|
+
* @description Add model data to viewer.
|
|
71
|
+
*/
|
|
72
|
+
addModel(model: ModelData3d): void;
|
|
73
|
+
/**
|
|
74
|
+
* We won't set a opacity or highlight directly, because that way will lose model's original opacity or color value
|
|
75
|
+
* @param isAdd is add or remove the opacity we added
|
|
76
|
+
* @param opacity
|
|
77
|
+
*/
|
|
78
|
+
addOrRemoveObjectOpacity(isAdd?: boolean, opacity?: number, includeObjectIds?: number[], excludeObjectIds?: number[]): void;
|
|
79
|
+
hasTransparentObject(): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Gets intersections by given mouse location.
|
|
82
|
+
* If no MouseEvent is passed in, use (0, 0) as the raycaster's origin.
|
|
83
|
+
*/
|
|
84
|
+
private getIntersections;
|
|
85
|
+
/**
|
|
86
|
+
* Handles mouse click event
|
|
87
|
+
*/
|
|
88
|
+
private handleMouseClick;
|
|
89
|
+
selectObject(object?: THREE.Object3D): void;
|
|
90
|
+
/**
|
|
91
|
+
* Clears the current selection
|
|
92
|
+
*/
|
|
93
|
+
clearSelection(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Make camera fly to objects
|
|
96
|
+
*/
|
|
97
|
+
flyToObjects(objects: THREE.Object3D[]): void;
|
|
98
|
+
/**
|
|
99
|
+
* Make camera fly to an object
|
|
100
|
+
*/
|
|
101
|
+
flyToObject(object: THREE.Object3D): void;
|
|
102
|
+
/**
|
|
103
|
+
* Flies to current selected object if any
|
|
104
|
+
*/
|
|
105
|
+
flyToSelectedObject(): void;
|
|
106
|
+
/**
|
|
107
|
+
* Make camera fly to target position with given lookAt position
|
|
108
|
+
* @param position camera's target position
|
|
109
|
+
* @param lookAt camera's new lookAt position
|
|
110
|
+
*/
|
|
111
|
+
flyTo(position: THREE.Vector3 | number[], lookAt: THREE.Vector3 | number[], onCompleteCallback?: () => void): void;
|
|
112
|
+
goToHomeView(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Sets environment for the scene.
|
|
115
|
+
* @param data Uint16Array of the hdr content
|
|
116
|
+
*/
|
|
117
|
+
setEnvironmentFromDataArray(data?: Uint16Array): void;
|
|
118
|
+
/**
|
|
119
|
+
* Tries to adjust camera near/far clip plane according to objects size in scene.
|
|
120
|
+
* Do this to avoid the case when objects are too small or big thus clipped!
|
|
121
|
+
*/
|
|
122
|
+
private tryAdjustCameraNearAndFar;
|
|
123
|
+
isolateObjects(params: IsolateObjectsParam[]): void;
|
|
124
|
+
private getMeshes;
|
|
125
|
+
/**
|
|
126
|
+
* Increases job count, and show spinner accordingly
|
|
127
|
+
*/
|
|
128
|
+
increaseJobCount(): void;
|
|
129
|
+
/**
|
|
130
|
+
* Decreases job count, and hide spinner accordingly
|
|
131
|
+
*/
|
|
132
|
+
decreaseJobCount(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Compute bounding box of loaded models
|
|
135
|
+
*/
|
|
136
|
+
computeBoundingBox(): THREE.Box3;
|
|
137
|
+
getContext(): WebGLRenderingContext | WebGL2RenderingContext | undefined;
|
|
138
|
+
getCameraDirection(): {
|
|
139
|
+
x: number;
|
|
140
|
+
y: number;
|
|
141
|
+
z: number;
|
|
142
|
+
};
|
|
143
|
+
setFov(fov: number): void;
|
|
144
|
+
}
|