@cognite/reveal 2.2.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/cad.d.ts +4 -4
- package/core/index.d.ts +7 -7
- package/core/src/datamodels/base/SupportedModelTypes.d.ts +4 -4
- package/core/src/datamodels/base/index.d.ts +6 -6
- package/core/src/datamodels/base/types.d.ts +14 -14
- package/core/src/datamodels/cad/CadManager.d.ts +45 -45
- package/core/src/datamodels/cad/CadModelFactory.d.ts +7 -7
- package/core/src/datamodels/cad/CadModelSectorLoadStatistics.d.ts +38 -38
- package/core/src/datamodels/cad/createCadManager.d.ts +9 -9
- package/core/src/datamodels/cad/picking.d.ts +28 -28
- package/core/src/datamodels/cad/rendering/RenderAlreadyLoadedGeometryProvider.d.ts +10 -10
- package/core/src/datamodels/cad/sector/CadModelClipper.d.ts +10 -10
- package/core/src/datamodels/cad/styling/AssetNodeCollection.d.ts +38 -38
- package/core/src/datamodels/cad/styling/InvertedNodeCollection.d.ts +24 -24
- package/core/src/datamodels/cad/styling/NodeCollectionDeserializer.d.ts +26 -26
- package/core/src/datamodels/cad/styling/PopulateIndexSetFromPagedResponseHelper.d.ts +24 -24
- package/core/src/datamodels/cad/styling/PropertyFilterNodeCollection.d.ts +54 -54
- package/core/src/datamodels/cad/styling/SinglePropertyFilterNodeCollection.d.ts +50 -50
- package/core/src/datamodels/cad/styling/index.d.ts +8 -8
- package/core/src/datamodels/pointcloud/PointCloudFactory.d.ts +9 -9
- package/core/src/datamodels/pointcloud/PointCloudManager.d.ts +26 -26
- package/core/src/datamodels/pointcloud/PointCloudMetadata.d.ts +11 -11
- package/core/src/datamodels/pointcloud/PointCloudMetadataRepository.d.ts +13 -13
- package/core/src/datamodels/pointcloud/PointCloudNode.d.ts +62 -62
- package/core/src/datamodels/pointcloud/PotreeGroupWrapper.d.ts +39 -39
- package/core/src/datamodels/pointcloud/PotreeNodeWrapper.d.ts +38 -38
- package/core/src/datamodels/pointcloud/createPointCloudManager.d.ts +6 -6
- package/core/src/datamodels/pointcloud/index.d.ts +5 -5
- package/core/src/datamodels/pointcloud/picking.d.ts +29 -29
- package/core/src/datamodels/pointcloud/types.d.ts +114 -114
- package/core/src/index.d.ts +19 -19
- package/core/src/internals.d.ts +15 -15
- package/core/src/migration.d.ts +8 -8
- package/core/src/public/RevealManager.d.ts +64 -64
- package/core/src/public/createRevealManager.d.ts +23 -23
- package/core/src/public/migration/Cognite3DModel.d.ts +339 -339
- package/core/src/public/migration/Cognite3DViewer.d.ts +566 -611
- package/core/src/public/migration/CogniteModelBase.d.ts +17 -17
- package/core/src/public/migration/CognitePointCloudModel.d.ts +121 -121
- package/core/src/public/migration/NodeIdAndTreeIndexMaps.d.ts +4 -4
- package/core/src/public/migration/NotSupportedInMigrationWrapperError.d.ts +11 -11
- package/core/src/public/migration/RenderController.d.ts +4 -4
- package/core/src/public/migration/types.d.ts +290 -290
- package/core/src/public/types.d.ts +46 -46
- package/core/src/storage/RevealManagerHelper.d.ts +58 -58
- package/core/src/utilities/BoundingBoxClipper.d.ts +23 -23
- package/core/src/utilities/Spinner.d.ts +27 -27
- package/core/src/utilities/ViewStateHelper.d.ts +37 -33
- package/core/src/utilities/callActionWithIndicesAsync.d.ts +4 -4
- package/core/src/utilities/index.d.ts +8 -8
- package/core/src/utilities/reflection.d.ts +7 -7
- package/core/src/utilities/worldToViewport.d.ts +30 -30
- package/core/utilities.d.ts +4 -4
- package/extensions/datasource.d.ts +9 -9
- package/extensions/datasource.js +6 -6
- package/extensions/datasource.map +1 -1
- package/index.d.ts +9 -8
- package/index.js +101 -91
- package/index.map +1 -1
- package/package.json +2 -2
- package/packages/cad-geometry-loaders/index.d.ts +14 -14
- package/packages/cad-geometry-loaders/src/CadLoadingHints.d.ts +11 -11
- package/packages/cad-geometry-loaders/src/CadModelSectorBudget.d.ts +26 -26
- package/packages/cad-geometry-loaders/src/CadModelUpdateHandler.d.ts +44 -44
- package/packages/cad-geometry-loaders/src/sector/CachedRepository.d.ts +25 -25
- package/packages/cad-geometry-loaders/src/sector/ModelStateHandler.d.ts +12 -12
- package/packages/cad-geometry-loaders/src/sector/Repository.d.ts +9 -9
- package/packages/cad-geometry-loaders/src/sector/SectorLoader.d.ts +28 -28
- package/packages/cad-geometry-loaders/src/sector/SimpleAndDetailedToSector3D.d.ts +20 -20
- package/packages/cad-geometry-loaders/src/sector/culling/ByVisibilityGpuSectorCuller.d.ts +53 -53
- package/packages/cad-geometry-loaders/src/sector/culling/OccludingGeometryProvider.d.ts +6 -6
- package/packages/cad-geometry-loaders/src/sector/culling/OrderSectorsByVisibilityCoverage.d.ts +107 -107
- package/packages/cad-geometry-loaders/src/sector/culling/SectorCuller.d.ts +33 -33
- package/packages/cad-geometry-loaders/src/sector/culling/TakenSectorTree.d.ts +24 -24
- package/packages/cad-geometry-loaders/src/sector/culling/types.d.ts +71 -71
- package/packages/cad-geometry-loaders/src/sector/rxSectorUtilities.d.ts +12 -12
- package/packages/cad-geometry-loaders/src/sector/sectorUtilities.d.ts +20 -20
- package/packages/cad-geometry-loaders/src/utilities/PromiseUtils.d.ts +18 -18
- package/packages/cad-geometry-loaders/src/utilities/arrays.d.ts +5 -5
- package/packages/cad-geometry-loaders/src/utilities/groupMeshesByNumber.d.ts +8 -8
- package/packages/cad-geometry-loaders/src/utilities/rxOperations.d.ts +6 -6
- package/packages/cad-geometry-loaders/src/utilities/types.d.ts +25 -25
- package/packages/cad-parsers/index.d.ts +21 -21
- package/packages/cad-parsers/src/cad/CadSectorParser.d.ts +15 -15
- package/packages/cad-parsers/src/cad/LevelOfDetail.d.ts +8 -8
- package/packages/cad-parsers/src/cad/filterInstanceMesh.d.ts +6 -6
- package/packages/cad-parsers/src/cad/filterPrimitives.d.ts +9 -9
- package/packages/cad-parsers/src/cad/primitiveGeometries.d.ts +31 -31
- package/packages/cad-parsers/src/cad/triangleMeshes.d.ts +6 -6
- package/packages/cad-parsers/src/cad/types.d.ts +56 -56
- package/packages/cad-parsers/src/metadata/CadMetadataParser.d.ts +7 -7
- package/packages/cad-parsers/src/metadata/CadModelMetadata.d.ts +44 -44
- package/packages/cad-parsers/src/metadata/CadModelMetadataRepository.d.ts +16 -16
- package/packages/cad-parsers/src/metadata/MetadataRepository.d.ts +7 -7
- package/packages/cad-parsers/src/metadata/parsers/CadMetadataParserV8.d.ts +51 -51
- package/packages/cad-parsers/src/metadata/types.d.ts +41 -41
- package/packages/cad-parsers/src/sector/RootSectorNode.d.ts +12 -12
- package/packages/cad-parsers/src/sector/SectorNode.d.ts +21 -21
- package/packages/cad-parsers/src/utilities/SectorScene.d.ts +21 -21
- package/packages/cad-parsers/src/utilities/SectorSceneFactory.d.ts +9 -9
- package/packages/cad-parsers/src/utilities/computeBoundingBoxFromAttributes.d.ts +9 -9
- package/packages/cad-parsers/src/utilities/float32BufferToMatrix.d.ts +12 -12
- package/packages/cad-parsers/src/utilities/types.d.ts +48 -48
- package/packages/cad-styling/index.d.ts +9 -9
- package/packages/cad-styling/src/CombineNodeCollectionBase.d.ts +31 -31
- package/packages/cad-styling/src/IntersectionNodeCollection.d.ts +15 -15
- package/packages/cad-styling/src/NodeAppearance.d.ts +62 -62
- package/packages/cad-styling/src/NodeAppearanceProvider.d.ts +33 -33
- package/packages/cad-styling/src/NodeCollectionBase.d.ts +47 -47
- package/packages/cad-styling/src/TreeIndexNodeCollection.d.ts +23 -23
- package/packages/cad-styling/src/UnionNodeCollection.d.ts +15 -15
- package/packages/camera-manager/index.d.ts +6 -4
- package/packages/camera-manager/src/CameraManager.d.ts +85 -0
- package/packages/camera-manager/src/ComboControls.d.ts +102 -100
- package/packages/camera-manager/src/Keyboard.d.ts +17 -17
- package/packages/camera-manager/src/types.d.ts +64 -0
- package/packages/data-source/index.d.ts +6 -6
- package/packages/data-source/src/CdfDataSource.d.ts +19 -19
- package/packages/data-source/src/DataSource.d.ts +26 -26
- package/packages/data-source/src/LocalDataSource.d.ts +15 -15
- package/packages/logger/index.d.ts +5 -5
- package/packages/logger/src/Log.d.ts +5 -5
- package/packages/metrics/index.d.ts +5 -5
- package/packages/metrics/src/MetricsLogger.d.ts +21 -21
- package/packages/metrics/src/types.d.ts +7 -7
- package/packages/modeldata-api/index.d.ts +13 -13
- package/packages/modeldata-api/src/CdfModelDataProvider.d.ts +17 -15
- package/packages/modeldata-api/src/CdfModelIdentifier.d.ts +17 -17
- package/packages/modeldata-api/src/CdfModelMetadataProvider.d.ts +19 -19
- package/packages/modeldata-api/src/CdfModelOutputsProvider.d.ts +15 -15
- package/packages/modeldata-api/src/LocalModelDataProvider.d.ts +10 -10
- package/packages/modeldata-api/src/LocalModelIdentifier.d.ts +14 -14
- package/packages/modeldata-api/src/LocalModelMetadataProvider.d.ts +14 -14
- package/packages/modeldata-api/src/Model3DOutputList.d.ts +17 -17
- package/packages/modeldata-api/src/ModelIdentifier.d.ts +12 -12
- package/packages/modeldata-api/src/ModelMetadataProvider.d.ts +17 -17
- package/packages/modeldata-api/src/applyDefaultModelTransformation.d.ts +6 -6
- package/packages/modeldata-api/src/types.d.ts +41 -41
- package/packages/modeldata-api/src/utilities.d.ts +7 -7
- package/packages/nodes-api/index.d.ts +6 -6
- package/packages/nodes-api/src/NodesApiClient.d.ts +52 -52
- package/packages/nodes-api/src/NodesCdfClient.d.ts +24 -24
- package/packages/nodes-api/src/NodesLocalClient.d.ts +30 -30
- package/packages/nodes-api/src/types.d.ts +10 -10
- package/packages/rendering/index.d.ts +17 -17
- package/packages/rendering/src/CadMaterialManager.d.ts +37 -37
- package/packages/rendering/src/InstancedMeshManager.d.ts +20 -20
- package/packages/rendering/src/cameraconfig.d.ts +12 -12
- package/packages/rendering/src/rendering/EffectRenderManager.d.ts +99 -99
- package/packages/rendering/src/rendering/NodeAppearanceTextureBuilder.d.ts +51 -51
- package/packages/rendering/src/rendering/RenderMode.d.ts +15 -15
- package/packages/rendering/src/rendering/createSimpleGeometryMesh.d.ts +6 -6
- package/packages/rendering/src/rendering/matCapTextureData.d.ts +5 -5
- package/packages/rendering/src/rendering/materials.d.ts +23 -23
- package/packages/rendering/src/rendering/primitives.d.ts +12 -12
- package/packages/rendering/src/rendering/shaders.d.ts +101 -101
- package/packages/rendering/src/rendering/types.d.ts +76 -76
- package/packages/rendering/src/sector/CadNode.d.ts +54 -54
- package/packages/rendering/src/transform/NodeTransformProvider.d.ts +13 -13
- package/packages/rendering/src/transform/NodeTransformTextureBuilder.d.ts +23 -23
- package/packages/rendering/src/transform/TransformOverrideBuffer.d.ts +21 -21
- package/packages/rendering/src/utilities/types.d.ts +26 -26
- package/packages/tools/index.d.ts +15 -15
- package/packages/tools/src/AxisView/AxisViewTool.d.ts +32 -32
- package/packages/tools/src/AxisView/types.d.ts +98 -98
- package/packages/tools/src/Cognite3DViewerToolBase.d.ts +25 -25
- package/packages/tools/src/DebugCameraTool.d.ts +20 -20
- package/packages/tools/src/DebugLoadedSectorsTool.d.ts +23 -23
- package/packages/tools/src/ExplodedViewTool.d.ts +12 -12
- package/packages/tools/src/Geomap/Geomap.d.ts +17 -17
- package/packages/tools/src/Geomap/GeomapTool.d.ts +24 -24
- package/packages/tools/src/Geomap/MapConfig.d.ts +195 -195
- package/packages/tools/src/HtmlOverlay/BucketGrid2D.d.ts +28 -28
- package/packages/tools/src/HtmlOverlay/HtmlOverlayTool.d.ts +159 -159
- package/packages/tools/src/Timeline/Keyframe.d.ts +38 -38
- package/packages/tools/src/Timeline/TimelineTool.d.ts +79 -79
- package/packages/tools/src/Timeline/types.d.ts +13 -13
- package/packages/tools/src/types.d.ts +4 -4
- package/packages/utilities/index.d.ts +24 -24
- package/packages/utilities/src/CameraConfiguration.d.ts +10 -10
- package/packages/utilities/src/IndexSet.d.ts +1 -1
- package/packages/utilities/src/NumericRange.d.ts +22 -22
- package/packages/utilities/src/RandomColors.d.ts +34 -34
- package/packages/utilities/src/WebGLRendererStateHelper.d.ts +15 -15
- package/packages/utilities/src/assertNever.d.ts +7 -7
- package/packages/utilities/src/cache/MemoryRequestCache.d.ts +22 -22
- package/packages/utilities/src/cache/MostFrequentlyUsedCache.d.ts +19 -19
- package/packages/utilities/src/cache/RequestCache.d.ts +13 -13
- package/packages/utilities/src/datastructures/DynamicDefragmentedBuffer.d.ts +22 -22
- package/packages/utilities/src/determinePowerOfTwoDimensions.d.ts +11 -11
- package/packages/utilities/src/disposeAttributeArrayOnUpload.d.ts +17 -17
- package/packages/utilities/src/events/EventTrigger.d.ts +13 -13
- package/packages/utilities/src/events/InputHandler.d.ts +34 -0
- package/packages/utilities/src/events/clickOrTouchEventOffset.d.ts +13 -13
- package/packages/utilities/src/events/index.d.ts +6 -5
- package/packages/utilities/src/indexset/IndexSet.d.ts +26 -26
- package/packages/utilities/src/indexset/IntermediateIndexNode.d.ts +26 -26
- package/packages/utilities/src/indexset/LeafIndexNode.d.ts +16 -16
- package/packages/utilities/src/isMobileOrTablet.d.ts +4 -4
- package/packages/utilities/src/networking/isTheSameDomain.d.ts +11 -11
- package/packages/utilities/src/objectTraversal.d.ts +8 -8
- package/packages/utilities/src/packFloat.d.ts +6 -6
- package/packages/utilities/src/revealEnv.d.ts +10 -10
- package/packages/utilities/src/three/AutoDisposeGroup.d.ts +17 -17
- package/packages/utilities/src/three/BoundingBoxLOD.d.ts +27 -27
- package/packages/utilities/src/three/getBox3CornerPoints.d.ts +5 -5
- package/packages/utilities/src/transformCameraConfiguration.d.ts +6 -6
- package/packages/utilities/src/types.d.ts +10 -10
- package/packages/utilities/src/workers/WorkerPool.d.ts +14 -14
- package/tools.d.ts +7 -7
- package/tools.js +62 -58
- package/tools.map +1 -1
|
@@ -1,611 +1,566 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright 2021 Cognite AS
|
|
3
|
-
*/
|
|
4
|
-
import * as THREE from 'three';
|
|
5
|
-
import { AddModelOptions, Cognite3DViewerOptions, Intersection, CameraChangeDelegate, PointerEventDelegate, CadModelBudget, PointCloudBudget
|
|
6
|
-
import { CogniteModelBase } from './CogniteModelBase';
|
|
7
|
-
import { Cognite3DModel } from './Cognite3DModel';
|
|
8
|
-
import { CognitePointCloudModel } from './CognitePointCloudModel';
|
|
9
|
-
import { DisposedDelegate, SceneRenderedDelegate } from '../types';
|
|
10
|
-
import { SupportedModelTypes } from '../../datamodels/base';
|
|
11
|
-
import { IntersectionFromPixelOptions } from '../..';
|
|
12
|
-
import { ViewerState } from '../../utilities/ViewStateHelper';
|
|
13
|
-
import ComboControls from '../../../../packages/camera-manager';
|
|
14
|
-
/**
|
|
15
|
-
* @example
|
|
16
|
-
* ```js
|
|
17
|
-
* const viewer = new Cognite3DViewer({
|
|
18
|
-
* noBackground: true,
|
|
19
|
-
* sdk: CogniteClient({...})
|
|
20
|
-
* });
|
|
21
|
-
* ```
|
|
22
|
-
* @module @cognite/reveal
|
|
23
|
-
*/
|
|
24
|
-
export declare class Cognite3DViewer {
|
|
25
|
-
private get canvas();
|
|
26
|
-
/**
|
|
27
|
-
* For now it just always returns true.
|
|
28
|
-
* @see Https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext#Browser_compatibility.
|
|
29
|
-
*/
|
|
30
|
-
static isBrowserSupported(): true;
|
|
31
|
-
/**
|
|
32
|
-
* The DOM element the viewer will insert its rendering canvas into.
|
|
33
|
-
* The DOM element can be specified in the options when the viewer is created.
|
|
34
|
-
* If not specified, the DOM element will be created automatically.
|
|
35
|
-
* The DOM element cannot be changed after the viewer has been created.
|
|
36
|
-
*/
|
|
37
|
-
get domElement(): HTMLElement;
|
|
38
|
-
/**
|
|
39
|
-
* Returns the renderer used to produce images from 3D geometry.
|
|
40
|
-
*/
|
|
41
|
-
get renderer(): THREE.WebGLRenderer;
|
|
42
|
-
private readonly _cdfSdkClient;
|
|
43
|
-
private readonly _dataSource;
|
|
44
|
-
private readonly camera;
|
|
45
|
-
private readonly scene;
|
|
46
|
-
private readonly
|
|
47
|
-
private readonly _subscription;
|
|
48
|
-
private readonly _revealManagerHelper;
|
|
49
|
-
private readonly _domElement;
|
|
50
|
-
private readonly _renderer;
|
|
51
|
-
private readonly _boundAnimate;
|
|
52
|
-
private
|
|
53
|
-
private
|
|
54
|
-
private readonly
|
|
55
|
-
private
|
|
56
|
-
private readonly
|
|
57
|
-
private readonly
|
|
58
|
-
private
|
|
59
|
-
private readonly
|
|
60
|
-
private
|
|
61
|
-
private readonly
|
|
62
|
-
private
|
|
63
|
-
private readonly
|
|
64
|
-
private
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
private readonly
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
*
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
*
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* ```
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*/
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
*
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
*
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
*
|
|
175
|
-
* @
|
|
176
|
-
*
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* viewer.
|
|
183
|
-
*
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
*
|
|
191
|
-
* @
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
*
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*/
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* @param
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
*
|
|
221
|
-
* }
|
|
222
|
-
*
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* @
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* viewer
|
|
236
|
-
* viewer.
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
*
|
|
267
|
-
* @param
|
|
268
|
-
* @
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
*
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
* );
|
|
299
|
-
* viewer.
|
|
300
|
-
* ```
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
* const
|
|
309
|
-
*
|
|
310
|
-
* viewer.
|
|
311
|
-
* ```
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
*
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
* @
|
|
373
|
-
*
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
*
|
|
407
|
-
* @
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
*
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
*
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
*
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
* ```
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
*
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
*
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
*
|
|
502
|
-
* @
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
* ```js
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
* ```
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
* model
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
* @
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
* const intersection = await viewer.getIntersectionFromPixel(offsetX, offsetY);
|
|
568
|
-
* if (intersection) // it was a hit
|
|
569
|
-
* console.log(
|
|
570
|
-
* 'You hit model ', intersection.model,
|
|
571
|
-
* ' at the node with tree index ', intersection.treeIndex,
|
|
572
|
-
* ' at this exact point ', intersection.point
|
|
573
|
-
* );
|
|
574
|
-
* ```
|
|
575
|
-
*
|
|
576
|
-
* @example For point cloud
|
|
577
|
-
* ```js
|
|
578
|
-
* const offsetX = 50 // pixels from the left
|
|
579
|
-
* const offsetY = 100 // pixels from the top
|
|
580
|
-
* const intersection = await viewer.getIntersectionFromPixel(offsetX, offsetY);
|
|
581
|
-
* if (intersection) // it was a hit
|
|
582
|
-
* console.log(
|
|
583
|
-
* 'You hit model ', intersection.model,
|
|
584
|
-
* ' at the point index ', intersection.pointIndex,
|
|
585
|
-
* ' at this exact point ', intersection.point
|
|
586
|
-
* );
|
|
587
|
-
* ```
|
|
588
|
-
*/
|
|
589
|
-
getIntersectionFromPixel(offsetX: number, offsetY: number, options?: IntersectionFromPixelOptions): Promise<null | Intersection>;
|
|
590
|
-
private getModels;
|
|
591
|
-
/**
|
|
592
|
-
* Calculates default duration for camera animation based on distance from the camera to the object.
|
|
593
|
-
* @param distanceToCamera
|
|
594
|
-
*/
|
|
595
|
-
private calculateDefaultDuration;
|
|
596
|
-
/** @private */
|
|
597
|
-
private moveCameraTargetTo;
|
|
598
|
-
/** @private */
|
|
599
|
-
private moveCameraTo;
|
|
600
|
-
/**
|
|
601
|
-
* Creates a helper for managing viewer state.
|
|
602
|
-
*/
|
|
603
|
-
private createViewStateHelper;
|
|
604
|
-
/** @private */
|
|
605
|
-
private animate;
|
|
606
|
-
/** @private */
|
|
607
|
-
private updateCameraNearAndFar;
|
|
608
|
-
/** @private */
|
|
609
|
-
private resizeIfNecessary;
|
|
610
|
-
private readonly startPointerEventListeners;
|
|
611
|
-
}
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 Cognite AS
|
|
3
|
+
*/
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import { AddModelOptions, Cognite3DViewerOptions, Intersection, CameraChangeDelegate, PointerEventDelegate, CadModelBudget, PointCloudBudget } from './types';
|
|
6
|
+
import { CogniteModelBase } from './CogniteModelBase';
|
|
7
|
+
import { Cognite3DModel } from './Cognite3DModel';
|
|
8
|
+
import { CognitePointCloudModel } from './CognitePointCloudModel';
|
|
9
|
+
import { DisposedDelegate, SceneRenderedDelegate } from '../types';
|
|
10
|
+
import { SupportedModelTypes } from '../../datamodels/base';
|
|
11
|
+
import { IntersectionFromPixelOptions } from '../..';
|
|
12
|
+
import { ViewerState } from '../../utilities/ViewStateHelper';
|
|
13
|
+
import { CameraControlsOptions, ComboControls } from '../../../../packages/camera-manager';
|
|
14
|
+
/**
|
|
15
|
+
* @example
|
|
16
|
+
* ```js
|
|
17
|
+
* const viewer = new Cognite3DViewer({
|
|
18
|
+
* noBackground: true,
|
|
19
|
+
* sdk: CogniteClient({...})
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
* @module @cognite/reveal
|
|
23
|
+
*/
|
|
24
|
+
export declare class Cognite3DViewer {
|
|
25
|
+
private get canvas();
|
|
26
|
+
/**
|
|
27
|
+
* For now it just always returns true.
|
|
28
|
+
* @see Https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext#Browser_compatibility.
|
|
29
|
+
*/
|
|
30
|
+
static isBrowserSupported(): true;
|
|
31
|
+
/**
|
|
32
|
+
* The DOM element the viewer will insert its rendering canvas into.
|
|
33
|
+
* The DOM element can be specified in the options when the viewer is created.
|
|
34
|
+
* If not specified, the DOM element will be created automatically.
|
|
35
|
+
* The DOM element cannot be changed after the viewer has been created.
|
|
36
|
+
*/
|
|
37
|
+
get domElement(): HTMLElement;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the renderer used to produce images from 3D geometry.
|
|
40
|
+
*/
|
|
41
|
+
get renderer(): THREE.WebGLRenderer;
|
|
42
|
+
private readonly _cdfSdkClient;
|
|
43
|
+
private readonly _dataSource;
|
|
44
|
+
private readonly camera;
|
|
45
|
+
private readonly scene;
|
|
46
|
+
private readonly _cameraManager;
|
|
47
|
+
private readonly _subscription;
|
|
48
|
+
private readonly _revealManagerHelper;
|
|
49
|
+
private readonly _domElement;
|
|
50
|
+
private readonly _renderer;
|
|
51
|
+
private readonly _boundAnimate;
|
|
52
|
+
private readonly _events;
|
|
53
|
+
private readonly _mouseHandler;
|
|
54
|
+
private readonly _models;
|
|
55
|
+
private readonly _extraObjects;
|
|
56
|
+
private readonly _automaticNearFarPlane;
|
|
57
|
+
private readonly _automaticControlsSensitivity;
|
|
58
|
+
private isDisposed;
|
|
59
|
+
private readonly renderController;
|
|
60
|
+
private latestRequestId;
|
|
61
|
+
private readonly clock;
|
|
62
|
+
private _clippingNeedsUpdate;
|
|
63
|
+
private readonly spinner;
|
|
64
|
+
private get revealManager();
|
|
65
|
+
/**
|
|
66
|
+
* Reusable buffers used by functions in Cognite3dViewer to avoid allocations.
|
|
67
|
+
*/
|
|
68
|
+
private readonly _updateNearAndFarPlaneBuffers;
|
|
69
|
+
/**
|
|
70
|
+
* Gets the current budget for downloading geometry for CAD models. Note that this
|
|
71
|
+
* budget is shared between all added CAD models and not a per-model budget.
|
|
72
|
+
*/
|
|
73
|
+
get cadBudget(): CadModelBudget;
|
|
74
|
+
/**
|
|
75
|
+
* Sets the current budget for downloading geometry for CAD models. Note that this
|
|
76
|
+
* budget is shared between all added CAD models and not a per-model budget.
|
|
77
|
+
*/
|
|
78
|
+
set cadBudget(budget: CadModelBudget);
|
|
79
|
+
/**
|
|
80
|
+
* Returns the point cloud budget. The budget is shared between all loaded
|
|
81
|
+
* point cloud models.
|
|
82
|
+
*/
|
|
83
|
+
get pointCloudBudget(): PointCloudBudget;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the point cloud budget. The budget is shared between all loaded
|
|
86
|
+
* point cloud models.
|
|
87
|
+
*/
|
|
88
|
+
set pointCloudBudget(budget: PointCloudBudget);
|
|
89
|
+
/**
|
|
90
|
+
* Gets a list of models currently added to the viewer.
|
|
91
|
+
*/
|
|
92
|
+
get models(): CogniteModelBase[];
|
|
93
|
+
constructor(options: Cognite3DViewerOptions);
|
|
94
|
+
/**
|
|
95
|
+
* Returns reveal version installed.
|
|
96
|
+
*/
|
|
97
|
+
getVersion(): string;
|
|
98
|
+
/**
|
|
99
|
+
* Sets the log level. Used for debugging.
|
|
100
|
+
* Defaults to 'none' (which is identical to 'silent').
|
|
101
|
+
* @param level
|
|
102
|
+
*/
|
|
103
|
+
setLogLevel(level: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent' | 'none'): void;
|
|
104
|
+
/**
|
|
105
|
+
* Dispose of WebGL resources. Can be used to free up memory when the viewer is no longer in use.
|
|
106
|
+
* @see {@link https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects}
|
|
107
|
+
* ```ts
|
|
108
|
+
* // Viewer is no longer in use, free up memory
|
|
109
|
+
* viewer.dispose();
|
|
110
|
+
* ```.
|
|
111
|
+
*/
|
|
112
|
+
dispose(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Triggered when the viewer is disposed. Listeners should clean up any
|
|
115
|
+
* resources held and remove the reference to the viewer.
|
|
116
|
+
*/
|
|
117
|
+
on(event: 'disposed', callback: DisposedDelegate): void;
|
|
118
|
+
/**
|
|
119
|
+
* @example
|
|
120
|
+
* ```js
|
|
121
|
+
* const onClick = (event) => { console.log(event.offsetX, event.offsetY) };
|
|
122
|
+
* viewer.on('click', onClick);
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
on(event: 'click' | 'hover', callback: PointerEventDelegate): void;
|
|
126
|
+
/**
|
|
127
|
+
* @example
|
|
128
|
+
* ```js
|
|
129
|
+
* viewer.on('cameraChange', (position, target) => {
|
|
130
|
+
* console.log('Camera changed: ', position, target);
|
|
131
|
+
* });
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
on(event: 'cameraChange', callback: CameraChangeDelegate): void;
|
|
135
|
+
/**
|
|
136
|
+
* Event that is triggered immediatly after the scene has been rendered.
|
|
137
|
+
* @param event Metadata about the rendering frame.
|
|
138
|
+
* @param callback Callback to trigger when the event occurs.
|
|
139
|
+
*/
|
|
140
|
+
on(event: 'sceneRendered', callback: SceneRenderedDelegate): void;
|
|
141
|
+
/**
|
|
142
|
+
* @example
|
|
143
|
+
* ```js
|
|
144
|
+
* viewer.off('click', onClick);
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
off(event: 'click' | 'hover', callback: PointerEventDelegate): void;
|
|
148
|
+
off(event: 'cameraChange', callback: CameraChangeDelegate): void;
|
|
149
|
+
off(event: 'sceneRendered', callback: SceneRenderedDelegate): void;
|
|
150
|
+
off(event: 'disposed', callback: DisposedDelegate): void;
|
|
151
|
+
/**
|
|
152
|
+
* Sets camera control options. See {@link CameraControlsOptions}.
|
|
153
|
+
* @param controlsOptions JSON object with camera controls options.
|
|
154
|
+
*/
|
|
155
|
+
setCameraControlsOptions(controlsOptions: CameraControlsOptions): void;
|
|
156
|
+
/**
|
|
157
|
+
* Gets camera controls mode.
|
|
158
|
+
*/
|
|
159
|
+
getCameraControlsOptions(): CameraControlsOptions;
|
|
160
|
+
/**
|
|
161
|
+
* Gets the current viewer state which includes the camera pose as well as applied styling.
|
|
162
|
+
* @returns JSON object containing viewer state.
|
|
163
|
+
*/
|
|
164
|
+
getViewState(): ViewerState;
|
|
165
|
+
/**
|
|
166
|
+
* Restores camera settings from the state provided, and clears all current styled
|
|
167
|
+
* node collections and applies the `state` object.
|
|
168
|
+
* @param state Viewer state retrieved from {@link Cognite3DViewer.getViewState}.
|
|
169
|
+
*/
|
|
170
|
+
setViewState(state: ViewerState): Promise<void>;
|
|
171
|
+
/**
|
|
172
|
+
* Add a new model to the viewer.
|
|
173
|
+
* Call {@link Cognite3DViewer.fitCameraToModel} to see the model after the model has loaded.
|
|
174
|
+
* @param options
|
|
175
|
+
* @example
|
|
176
|
+
* ```js
|
|
177
|
+
* const options = {
|
|
178
|
+
* modelId: 'COGNITE_3D_MODEL_ID',
|
|
179
|
+
* revisionId: 'COGNITE_3D_REVISION_ID',
|
|
180
|
+
* };
|
|
181
|
+
* viewer.addModel(options).then(model => {
|
|
182
|
+
* viewer.fitCameraToModel(model, 0);
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
addModel(options: AddModelOptions): Promise<Cognite3DModel | CognitePointCloudModel>;
|
|
187
|
+
/**
|
|
188
|
+
* Add a new CAD 3D model to the viewer.
|
|
189
|
+
* Call {@link Cognite3DViewer.fitCameraToModel} to see the model after the model has loaded.
|
|
190
|
+
* @param options
|
|
191
|
+
* @example
|
|
192
|
+
* ```js
|
|
193
|
+
* const options = {
|
|
194
|
+
* modelId: 'COGNITE_3D_MODEL_ID',
|
|
195
|
+
* revisionId: 'COGNITE_3D_REVISION_ID',
|
|
196
|
+
* };
|
|
197
|
+
* viewer.addCadModel(options).then(model => {
|
|
198
|
+
* viewer.fitCameraToModel(model, 0);
|
|
199
|
+
* });
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
addCadModel(options: AddModelOptions): Promise<Cognite3DModel>;
|
|
203
|
+
/**
|
|
204
|
+
* Add a new pointcloud 3D model to the viewer.
|
|
205
|
+
* Call {@link Cognite3DViewer.fitCameraToModel} to see the model after the model has loaded.
|
|
206
|
+
* @param options
|
|
207
|
+
* @example
|
|
208
|
+
* ```js
|
|
209
|
+
* const options = {
|
|
210
|
+
* modelId: 'COGNITE_3D_MODEL_ID',
|
|
211
|
+
* revisionId: 'COGNITE_3D_REVISION_ID',
|
|
212
|
+
* };
|
|
213
|
+
* viewer.addPointCloudModel(options).then(model => {
|
|
214
|
+
* viewer.fitCameraToModel(model, 0);
|
|
215
|
+
* });
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
addPointCloudModel(options: AddModelOptions): Promise<CognitePointCloudModel>;
|
|
219
|
+
/**
|
|
220
|
+
* Removes a model that was previously added using {@link Cognite3DViewer.addModel},
|
|
221
|
+
* {@link Cognite3DViewer.addCadModel} or {@link Cognite3DViewer.addPointCloudModel}
|
|
222
|
+
* .
|
|
223
|
+
* @param model
|
|
224
|
+
*/
|
|
225
|
+
removeModel(model: CogniteModelBase): void;
|
|
226
|
+
/**
|
|
227
|
+
* Use to determine of which type the model is.
|
|
228
|
+
*
|
|
229
|
+
* @param modelId The model's id.
|
|
230
|
+
* @param revisionId The model's revision id.
|
|
231
|
+
*
|
|
232
|
+
* @returns Empty string if type is not supported.
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const viewer = new Cognite3DViewer(...);
|
|
236
|
+
* const type = await viewer.determineModelType(options.modelId, options.revisionId)
|
|
237
|
+
* let model: Cognite3DModel | CognitePointCloudModel
|
|
238
|
+
* switch (type) {
|
|
239
|
+
* case 'cad':
|
|
240
|
+
* model = await viewer.addCadModel(options);
|
|
241
|
+
* break;
|
|
242
|
+
* case 'pointcloud':
|
|
243
|
+
* model = await viewer.addPointCloudModel(options);
|
|
244
|
+
* break;
|
|
245
|
+
* default:
|
|
246
|
+
* throw new Error('Model is not supported');
|
|
247
|
+
* }
|
|
248
|
+
* viewer.fitCameraToModel(model);
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
determineModelType(modelId: number, revisionId: number): Promise<SupportedModelTypes | ''>;
|
|
252
|
+
/**
|
|
253
|
+
* Add a THREE.Object3D to the viewer.
|
|
254
|
+
* @param object
|
|
255
|
+
* @example
|
|
256
|
+
* ```js
|
|
257
|
+
* const sphere = new THREE.Mesh(
|
|
258
|
+
* new THREE.SphereBufferGeometry(),
|
|
259
|
+
* new THREE.MeshBasicMaterial()
|
|
260
|
+
* );
|
|
261
|
+
* viewer.addObject3D(sphere);
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
addObject3D(object: THREE.Object3D): void;
|
|
265
|
+
/**
|
|
266
|
+
* Remove a THREE.Object3D from the viewer.
|
|
267
|
+
* @param object
|
|
268
|
+
* @example
|
|
269
|
+
* ```js
|
|
270
|
+
* const sphere = new THREE.Mesh(new THREE.SphereBufferGeometry(), new THREE.MeshBasicMaterial());
|
|
271
|
+
* viewer.addObject3D(sphere);
|
|
272
|
+
* viewer.removeObject3D(sphere);
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
removeObject3D(object: THREE.Object3D): void;
|
|
276
|
+
/**
|
|
277
|
+
* Add an object that will be considered a UI object. It will be rendered in the last stage and with orthographic projection.
|
|
278
|
+
* @param object
|
|
279
|
+
* @param screenPos Screen space position of object (in pixels).
|
|
280
|
+
* @param size Pixel width and height of the object.
|
|
281
|
+
*/
|
|
282
|
+
addUiObject(object: THREE.Object3D, screenPos: THREE.Vector2, size: THREE.Vector2): void;
|
|
283
|
+
/** Removes the UI object from the viewer.
|
|
284
|
+
* @param object
|
|
285
|
+
*/
|
|
286
|
+
removeUiObject(object: THREE.Object3D): void;
|
|
287
|
+
/**
|
|
288
|
+
* Sets the color used as the clear color of the renderer.
|
|
289
|
+
* @param color
|
|
290
|
+
*/
|
|
291
|
+
setBackgroundColor(color: THREE.Color): void;
|
|
292
|
+
/**
|
|
293
|
+
* Sets per-pixel clipping planes. Pixels behind any of the planes will be sliced away.
|
|
294
|
+
* @param clippingPlanes The planes to use for clipping.
|
|
295
|
+
* @example
|
|
296
|
+
* ```js
|
|
297
|
+
* // Hide pixels with values less than 0 in the x direction
|
|
298
|
+
* const plane = new THREE.Plane(new THREE.Vector3(1, 0, 0), 0);
|
|
299
|
+
* viewer.setClippingPlanes([plane]);
|
|
300
|
+
* ```
|
|
301
|
+
* ```js
|
|
302
|
+
* // Hide pixels with values greater than 20 in the x direction
|
|
303
|
+
* const plane = new THREE.Plane(new THREE.Vector3(-1, 0, 0), 20);
|
|
304
|
+
* viewer.setClippingPlanes([plane]);
|
|
305
|
+
* ```
|
|
306
|
+
* ```js
|
|
307
|
+
* // Hide pixels with values less than 0 in the x direction or greater than 0 in the y direction
|
|
308
|
+
* const xPlane = new THREE.Plane(new THREE.Vector3(1, 0, 0), 0);
|
|
309
|
+
* const yPlane = new THREE.Plane(new THREE.Vector3(0, -1, 0), 0);
|
|
310
|
+
* viewer.setClippingPlanes([xPlane, yPlane]);
|
|
311
|
+
* ```
|
|
312
|
+
* ```js
|
|
313
|
+
* // Hide pixels behind an arbitrary, non axis-aligned plane
|
|
314
|
+
* const plane = new THREE.Plane(new THREE.Vector3(1.5, 20, -19), 20);
|
|
315
|
+
* viewer.setClippingPlanes([plane]);
|
|
316
|
+
* ```
|
|
317
|
+
* ```js
|
|
318
|
+
* // Disable clipping planes
|
|
319
|
+
* viewer.setClippingPlanes([]);
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
setClippingPlanes(clippingPlanes: THREE.Plane[]): void;
|
|
323
|
+
/**
|
|
324
|
+
* @param slicingPlanes
|
|
325
|
+
* @deprecated Since version 2.1, will be removed in version 3.0. Use {@link setClippingPlanes}.
|
|
326
|
+
*/
|
|
327
|
+
setSlicingPlanes(slicingPlanes: THREE.Plane[]): void;
|
|
328
|
+
/**
|
|
329
|
+
* Returns the current active clipping planes.
|
|
330
|
+
* @version New in 2.1
|
|
331
|
+
*/
|
|
332
|
+
getClippingPlanes(): THREE.Plane[];
|
|
333
|
+
/**
|
|
334
|
+
* @obvious
|
|
335
|
+
* @returns The THREE.Camera used for rendering.
|
|
336
|
+
*/
|
|
337
|
+
getCamera(): THREE.PerspectiveCamera;
|
|
338
|
+
/**
|
|
339
|
+
* @obvious
|
|
340
|
+
* @returns The THREE.Scene used for rendering.
|
|
341
|
+
*/
|
|
342
|
+
getScene(): THREE.Scene;
|
|
343
|
+
/**
|
|
344
|
+
* @obvious
|
|
345
|
+
* @returns Camera's position in world space.
|
|
346
|
+
*/
|
|
347
|
+
getCameraPosition(): THREE.Vector3;
|
|
348
|
+
/**
|
|
349
|
+
* @obvious
|
|
350
|
+
* @returns Camera's target in world space.
|
|
351
|
+
*/
|
|
352
|
+
getCameraTarget(): THREE.Vector3;
|
|
353
|
+
/**
|
|
354
|
+
* @obvious
|
|
355
|
+
* @param position Position in world space.
|
|
356
|
+
* @example
|
|
357
|
+
* ```js
|
|
358
|
+
* // store position, target
|
|
359
|
+
* const position = viewer.getCameraPosition();
|
|
360
|
+
* const target = viewer.getCameraTarget();
|
|
361
|
+
* // restore position, target
|
|
362
|
+
* viewer.setCameraPosition(position);
|
|
363
|
+
* viewer.setCameraTarget(target);
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
setCameraPosition(position: THREE.Vector3): void;
|
|
367
|
+
/**
|
|
368
|
+
* Set camera's target.
|
|
369
|
+
* @public
|
|
370
|
+
* @param target Target in world space.
|
|
371
|
+
* @param animated Whether change of target should be animated or not (default is false).
|
|
372
|
+
* @example
|
|
373
|
+
* ```js
|
|
374
|
+
* // store position, target
|
|
375
|
+
* const position = viewer.getCameraPosition();
|
|
376
|
+
* const target = viewer.getCameraTarget();
|
|
377
|
+
* // restore position, target
|
|
378
|
+
* viewer.setCameraPosition(position);
|
|
379
|
+
* viewer.setCameraTarget(target);
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
setCameraTarget(target: THREE.Vector3, animated?: boolean): void;
|
|
383
|
+
/**
|
|
384
|
+
* Gets the camera controller. See https://www.npmjs.com/package/@cognite/three-combo-controls
|
|
385
|
+
* for documentation. Note that by default the `minDistance` setting of the controls will
|
|
386
|
+
* be automatic. This can be disabled using {@link Cognite3DViewerOptions.automaticControlsSensitivity}.
|
|
387
|
+
*/
|
|
388
|
+
get cameraControls(): ComboControls;
|
|
389
|
+
/**
|
|
390
|
+
* Gets whether camera controls through mouse, touch and keyboard are enabled.
|
|
391
|
+
*/
|
|
392
|
+
get cameraControlsEnabled(): boolean;
|
|
393
|
+
/**
|
|
394
|
+
* Sets whether camera controls through mouse, touch and keyboard are enabled.
|
|
395
|
+
* This can be useful to e.g. temporarily disable navigation when manipulating other
|
|
396
|
+
* objects in the scene or when implementing a "cinematic" viewer.
|
|
397
|
+
*/
|
|
398
|
+
set cameraControlsEnabled(enabled: boolean);
|
|
399
|
+
/**
|
|
400
|
+
* Attempts to load the camera settings from the settings stored for the
|
|
401
|
+
* provided model. See {@link https://docs.cognite.com/api/v1/#operation/get3DRevision}
|
|
402
|
+
* and {@link https://docs.cognite.com/api/v1/#operation/update3DRevisions} for
|
|
403
|
+
* information on how this setting is retrieved and stored. This setting can
|
|
404
|
+
* also be changed through the 3D models management interface in Cognite Fusion.
|
|
405
|
+
* If no camera configuration is stored in CDF, {@link Cognite3DViewer.fitCameraToModel}
|
|
406
|
+
* is used as a fallback.
|
|
407
|
+
* @param model The model to load camera settings from.
|
|
408
|
+
*/
|
|
409
|
+
loadCameraFromModel(model: CogniteModelBase): void;
|
|
410
|
+
/**
|
|
411
|
+
* Move camera to a place where the 3D model is visible.
|
|
412
|
+
* It uses the bounding box of the 3D model and calls {@link Cognite3DViewer.fitCameraToBoundingBox}.
|
|
413
|
+
* @param model The 3D model.
|
|
414
|
+
* @param duration The duration of the animation moving the camera. Set this to 0 (zero) to disable animation.
|
|
415
|
+
* @example
|
|
416
|
+
* ```js
|
|
417
|
+
* // Fit camera to model
|
|
418
|
+
* viewer.fitCameraToModel(model);
|
|
419
|
+
* ```
|
|
420
|
+
* ```js
|
|
421
|
+
* // Fit camera to model over 500 milliseconds
|
|
422
|
+
* viewer.fitCameraToModel(model, 500);
|
|
423
|
+
* ```
|
|
424
|
+
* ```js
|
|
425
|
+
* // Fit camera to model instantly
|
|
426
|
+
* viewer.fitCameraToModel(model, 0);
|
|
427
|
+
* ```
|
|
428
|
+
*/
|
|
429
|
+
fitCameraToModel(model: CogniteModelBase, duration?: number): void;
|
|
430
|
+
/**
|
|
431
|
+
* Move camera to a place where the content of a bounding box is visible to the camera.
|
|
432
|
+
* @param box The bounding box in world space.
|
|
433
|
+
* @param duration The duration of the animation moving the camera. Set this to 0 (zero) to disable animation.
|
|
434
|
+
* @param radiusFactor The ratio of the distance from camera to center of box and radius of the box.
|
|
435
|
+
* @example
|
|
436
|
+
* ```js
|
|
437
|
+
* // Fit camera to bounding box over 500 milliseconds
|
|
438
|
+
* viewer.fitCameraToBoundingBox(boundingBox, 500);
|
|
439
|
+
* ```
|
|
440
|
+
* ```js
|
|
441
|
+
* // Fit camera to bounding box instantaneously
|
|
442
|
+
* viewer.fitCameraToBoundingBox(boundingBox, 0);
|
|
443
|
+
* ```
|
|
444
|
+
* ```js
|
|
445
|
+
* // Place the camera closer to the bounding box
|
|
446
|
+
* viewer.fitCameraToBoundingBox(boundingBox, 500, 2);
|
|
447
|
+
* ```
|
|
448
|
+
*/
|
|
449
|
+
fitCameraToBoundingBox(box: THREE.Box3, duration?: number, radiusFactor?: number): void;
|
|
450
|
+
/**
|
|
451
|
+
* Typically used when you perform some changes and can't see them unless you move camera.
|
|
452
|
+
*/
|
|
453
|
+
requestRedraw(): void;
|
|
454
|
+
/**
|
|
455
|
+
* Allows to move camera with WASD or arrows keys.
|
|
456
|
+
*/
|
|
457
|
+
enableKeyboardNavigation(): void;
|
|
458
|
+
/**
|
|
459
|
+
* Disables camera movement by pressing WASD or arrows keys.
|
|
460
|
+
*/
|
|
461
|
+
disableKeyboardNavigation(): void;
|
|
462
|
+
/**
|
|
463
|
+
* Convert a point in world space to its coordinates in the canvas. This can be used to place HTML objects near 3D objects on top of the 3D viewer.
|
|
464
|
+
* @see {@link https://www.w3schools.com/graphics/canvas_coordinates.asp https://www.w3schools.com/graphics/canvas_coordinates.asp}.
|
|
465
|
+
* @param point World space coordinate.
|
|
466
|
+
* @param normalize Optional. If true, coordinates are normalized into [0,1]. If false, the values are in the range [0, <canvas_size>).
|
|
467
|
+
* @returns Returns 2D coordinates if the point is visible on screen, or `null` if object is outside screen.
|
|
468
|
+
* @example
|
|
469
|
+
* ```js
|
|
470
|
+
* const boundingBoxCenter = new THREE.Vector3();
|
|
471
|
+
* // Find center of bounding box in world space
|
|
472
|
+
* model.getBoundingBox(nodeId).getCenter(boundingBoxCenter);
|
|
473
|
+
* // Screen coordinates of that point
|
|
474
|
+
* const screenCoordinates = viewer.worldToScreen(boundingBoxCenter);
|
|
475
|
+
* ```
|
|
476
|
+
* ```js
|
|
477
|
+
* const boundingBoxCenter = new THREE.Vector3();
|
|
478
|
+
* // Find center of bounding box in world space
|
|
479
|
+
* model.getBoundingBox(nodeId).getCenter(boundingBoxCenter);
|
|
480
|
+
* // Screen coordinates of that point normalized in the range [0,1]
|
|
481
|
+
* const screenCoordinates = viewer.worldToScreen(boundingBoxCenter, true);
|
|
482
|
+
* ```
|
|
483
|
+
* ```js
|
|
484
|
+
* const boundingBoxCenter = new THREE.Vector3();
|
|
485
|
+
* // Find center of bounding box in world space
|
|
486
|
+
* model.getBoundingBox(nodeId).getCenter(boundingBoxCenter);
|
|
487
|
+
* // Screen coordinates of that point
|
|
488
|
+
* const screenCoordinates = viewer.worldToScreen(boundingBoxCenter);
|
|
489
|
+
* if (screenCoordinates == null) {
|
|
490
|
+
* // Object not visible on screen
|
|
491
|
+
* } else {
|
|
492
|
+
* // Object is visible on screen
|
|
493
|
+
* }
|
|
494
|
+
* ```
|
|
495
|
+
*/
|
|
496
|
+
worldToScreen(point: THREE.Vector3, normalize?: boolean): THREE.Vector2 | null;
|
|
497
|
+
/**
|
|
498
|
+
* Take screenshot from the current camera position.
|
|
499
|
+
* @param width Width of the final image. Default is current canvas size.
|
|
500
|
+
* @param height Height of the final image. Default is current canvas size.
|
|
501
|
+
* @returns A {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URL} of the image ('image/png').
|
|
502
|
+
* @example
|
|
503
|
+
* ```js
|
|
504
|
+
* // Take a screenshot with custom resolution
|
|
505
|
+
* const url = await viewer.getScreenshot(1920, 1080);
|
|
506
|
+
* ```
|
|
507
|
+
* ```js
|
|
508
|
+
* // Add a screenshot with resolution of the canvas to the page
|
|
509
|
+
* const url = await viewer.getScreenshot();
|
|
510
|
+
* const image = document.createElement('img');
|
|
511
|
+
* image.src = url;
|
|
512
|
+
* document.body.appendChild(url);
|
|
513
|
+
* ```
|
|
514
|
+
*/
|
|
515
|
+
getScreenshot(width?: number, height?: number): Promise<string>;
|
|
516
|
+
/**
|
|
517
|
+
* Raycasting model(s) for finding where the ray intersects with the model.
|
|
518
|
+
* @param offsetX X coordinate in pixels (relative to the domElement).
|
|
519
|
+
* @param offsetY Y coordinate in pixels (relative to the domElement).
|
|
520
|
+
* @param options Options to control the behavior of the intersection operation. Optional (new in 1.3.0).
|
|
521
|
+
* @returns A promise that if there was an intersection then return the intersection object - otherwise it
|
|
522
|
+
* returns `null` if there were no intersections.
|
|
523
|
+
* @see {@link https://en.wikipedia.org/wiki/Ray_casting}.
|
|
524
|
+
*
|
|
525
|
+
* @example For CAD model
|
|
526
|
+
* ```js
|
|
527
|
+
* const offsetX = 50 // pixels from the left
|
|
528
|
+
* const offsetY = 100 // pixels from the top
|
|
529
|
+
* const intersection = await viewer.getIntersectionFromPixel(offsetX, offsetY);
|
|
530
|
+
* if (intersection) // it was a hit
|
|
531
|
+
* console.log(
|
|
532
|
+
* 'You hit model ', intersection.model,
|
|
533
|
+
* ' at the node with tree index ', intersection.treeIndex,
|
|
534
|
+
* ' at this exact point ', intersection.point
|
|
535
|
+
* );
|
|
536
|
+
* ```
|
|
537
|
+
*
|
|
538
|
+
* @example For point cloud
|
|
539
|
+
* ```js
|
|
540
|
+
* const offsetX = 50 // pixels from the left
|
|
541
|
+
* const offsetY = 100 // pixels from the top
|
|
542
|
+
* const intersection = await viewer.getIntersectionFromPixel(offsetX, offsetY);
|
|
543
|
+
* if (intersection) // it was a hit
|
|
544
|
+
* console.log(
|
|
545
|
+
* 'You hit model ', intersection.model,
|
|
546
|
+
* ' at the point index ', intersection.pointIndex,
|
|
547
|
+
* ' at this exact point ', intersection.point
|
|
548
|
+
* );
|
|
549
|
+
* ```
|
|
550
|
+
*/
|
|
551
|
+
getIntersectionFromPixel(offsetX: number, offsetY: number, options?: IntersectionFromPixelOptions): Promise<null | Intersection>;
|
|
552
|
+
private getModels;
|
|
553
|
+
/**
|
|
554
|
+
* Creates a helper for managing viewer state.
|
|
555
|
+
*/
|
|
556
|
+
private createViewStateHelper;
|
|
557
|
+
/** @private */
|
|
558
|
+
private animate;
|
|
559
|
+
/** @private */
|
|
560
|
+
private modelIntersectionCallback;
|
|
561
|
+
/** @private */
|
|
562
|
+
private updateCameraNearAndFar;
|
|
563
|
+
/** @private */
|
|
564
|
+
private resizeIfNecessary;
|
|
565
|
+
private readonly startPointerEventListeners;
|
|
566
|
+
}
|