@cognite/reveal 3.0.0-alpha.2 → 3.0.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.
Files changed (265) hide show
  1. package/core/cad.d.ts +4 -4
  2. package/core/index.d.ts +6 -7
  3. package/core/src/index.d.ts +13 -19
  4. package/core/src/internals.d.ts +10 -15
  5. package/core/src/public/RevealManager.d.ts +61 -64
  6. package/core/src/public/createRevealManager.d.ts +23 -23
  7. package/core/src/public/migration/Cognite3DViewer.d.ts +485 -559
  8. package/core/src/public/migration/NotSupportedInMigrationWrapperError.d.ts +11 -11
  9. package/core/src/public/migration/RenderController.d.ts +4 -4
  10. package/core/src/public/migration/types.d.ts +199 -253
  11. package/core/src/public/types.d.ts +25 -47
  12. package/core/src/storage/RevealManagerHelper.d.ts +59 -58
  13. package/core/src/utilities/Spinner.d.ts +27 -27
  14. package/core/src/utilities/ViewStateHelper.d.ts +49 -37
  15. package/core/src/utilities/index.d.ts +6 -8
  16. package/core/src/utilities/reflection.d.ts +7 -7
  17. package/core/utilities.d.ts +4 -4
  18. package/extensions/datasource.d.ts +9 -9
  19. package/extensions/datasource.js +5 -8
  20. package/extensions/datasource.map +1 -1
  21. package/index.d.ts +13 -9
  22. package/index.js +195 -167
  23. package/index.map +1 -1
  24. package/package.json +18 -17
  25. package/packages/cad-geometry-loaders/index.d.ts +7 -13
  26. package/packages/cad-geometry-loaders/src/CadLoadingHints.d.ts +11 -11
  27. package/packages/cad-geometry-loaders/src/CadModelBudget.d.ts +21 -19
  28. package/packages/cad-geometry-loaders/src/CadModelUpdateHandler.d.ts +44 -42
  29. package/packages/cad-geometry-loaders/src/sector/ModelStateHandler.d.ts +12 -12
  30. package/packages/cad-geometry-loaders/src/sector/SectorDownloadScheduler.d.ts +22 -22
  31. package/packages/cad-geometry-loaders/src/sector/SectorLoader.d.ts +32 -31
  32. package/packages/cad-geometry-loaders/src/sector/culling/ByScreenSizeSectorCuller.d.ts +23 -23
  33. package/packages/cad-geometry-loaders/src/sector/culling/ByVisibilityGpuSectorCuller.d.ts +51 -51
  34. package/packages/cad-geometry-loaders/src/sector/culling/OrderSectorsByVisibilityCoverage.d.ts +106 -107
  35. package/packages/cad-geometry-loaders/src/sector/culling/RenderAlreadyLoadedGeometryProvider.d.ts +9 -0
  36. package/packages/cad-geometry-loaders/src/sector/culling/SectorCuller.d.ts +33 -33
  37. package/packages/cad-geometry-loaders/src/sector/culling/WeightFunctionsHelper.d.ts +50 -50
  38. package/packages/cad-geometry-loaders/src/sector/culling/computeNdcAreaOfBox.d.ts +12 -12
  39. package/packages/cad-geometry-loaders/src/sector/culling/computeSectorCost.d.ts +7 -7
  40. package/packages/cad-geometry-loaders/src/sector/culling/createV8SectorCuller.d.ts +7 -7
  41. package/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenSectorMapBase.d.ts +11 -11
  42. package/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenV8SectorMap.d.ts +17 -17
  43. package/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenV8SectorTree.d.ts +24 -24
  44. package/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenV9SectorMap.d.ts +20 -20
  45. package/packages/cad-geometry-loaders/src/sector/culling/takensectors/index.d.ts +5 -5
  46. package/packages/cad-geometry-loaders/src/sector/culling/transformBoxToNDC.d.ts +5 -5
  47. package/packages/cad-geometry-loaders/src/sector/culling/types.d.ts +83 -83
  48. package/packages/cad-geometry-loaders/src/sector/rxSectorUtilities.d.ts +12 -12
  49. package/packages/cad-geometry-loaders/src/utilities/PromiseUtils.d.ts +28 -28
  50. package/packages/cad-geometry-loaders/src/utilities/rxOperations.d.ts +6 -6
  51. package/packages/cad-model/index.d.ts +12 -0
  52. package/{core/src/utilities → packages/cad-model/src}/BoundingBoxClipper.d.ts +23 -23
  53. package/{core/src/datamodels/cad → packages/cad-model/src}/CadManager.d.ts +48 -43
  54. package/packages/cad-model/src/CadModelFactory.d.ts +16 -0
  55. package/{core/src/datamodels/cad → packages/cad-model/src}/CadModelSectorLoadStatistics.d.ts +38 -38
  56. package/{core/src/public/migration → packages/cad-model/src}/Cognite3DModel.d.ts +337 -340
  57. package/packages/cad-model/src/GeometryFilter.d.ts +20 -0
  58. package/packages/cad-model/src/InternalRevealCadOptions.d.ts +13 -0
  59. package/packages/cad-model/src/WellKnownUnit.d.ts +7 -0
  60. package/{core/src/utilities → packages/cad-model/src}/callActionWithIndicesAsync.d.ts +4 -4
  61. package/{core/src/datamodels/cad → packages/cad-model/src}/createCadManager.d.ts +10 -9
  62. package/{core/src/datamodels/cad → packages/cad-model/src}/picking.d.ts +28 -28
  63. package/packages/cad-parsers/index.d.ts +20 -21
  64. package/packages/cad-parsers/src/cad/CadSectorParser.d.ts +15 -15
  65. package/packages/cad-parsers/src/cad/LevelOfDetail.d.ts +8 -8
  66. package/packages/cad-parsers/src/cad/filterInstanceMesh.d.ts +6 -6
  67. package/packages/cad-parsers/src/cad/filterPrimitivesCommon.d.ts +5 -5
  68. package/packages/cad-parsers/src/cad/filterPrimitivesV8.d.ts +9 -9
  69. package/packages/cad-parsers/src/cad/filterPrimitivesV9.d.ts +6 -6
  70. package/packages/cad-parsers/src/cad/primitiveGeometries.d.ts +30 -31
  71. package/packages/cad-parsers/src/cad/triangleMeshes.d.ts +6 -6
  72. package/packages/cad-parsers/src/cad/types.d.ts +56 -56
  73. package/packages/cad-parsers/src/metadata/CadMetadataParser.d.ts +7 -7
  74. package/{core/src/datamodels/cad/sector → packages/cad-parsers/src/metadata}/CadModelClipper.d.ts +10 -10
  75. package/packages/cad-parsers/src/metadata/CadModelMetadata.d.ts +54 -54
  76. package/packages/cad-parsers/src/metadata/CadModelMetadataRepository.d.ts +16 -16
  77. package/packages/cad-parsers/src/metadata/parsers/CadMetadataParserGltf.d.ts +8 -6
  78. package/packages/cad-parsers/src/metadata/parsers/CadMetadataParserV8.d.ts +6 -6
  79. package/packages/cad-parsers/src/metadata/parsers/types.d.ts +62 -60
  80. package/packages/cad-parsers/src/metadata/types.d.ts +53 -52
  81. package/packages/cad-parsers/src/sector/RootSectorNode.d.ts +13 -12
  82. package/packages/cad-parsers/src/sector/SectorNode.d.ts +22 -21
  83. package/packages/cad-parsers/src/utilities/SectorScene.d.ts +23 -21
  84. package/packages/cad-parsers/src/utilities/SectorSceneFactory.d.ts +9 -9
  85. package/packages/cad-parsers/src/utilities/computeBoundingBoxFromAttributes.d.ts +10 -10
  86. package/packages/cad-parsers/src/utilities/float32BufferToMatrix.d.ts +12 -12
  87. package/packages/cad-parsers/src/utilities/types.d.ts +71 -74
  88. package/packages/cad-styling/index.d.ts +20 -13
  89. package/{core/src/datamodels/cad/styling → packages/cad-styling/src}/AssetNodeCollection.d.ts +47 -45
  90. package/packages/cad-styling/src/CdfModelNodeCollectionDataProvider.d.ts +26 -0
  91. package/packages/cad-styling/src/CombineNodeCollectionBase.d.ts +34 -33
  92. package/packages/cad-styling/src/IntersectionNodeCollection.d.ts +20 -19
  93. package/{core/src/datamodels/cad/styling → packages/cad-styling/src}/InvertedNodeCollection.d.ts +27 -25
  94. package/packages/cad-styling/src/NodeAppearance.d.ts +85 -85
  95. package/packages/cad-styling/src/NodeAppearanceProvider.d.ts +38 -36
  96. package/packages/cad-styling/src/NodeCollection.d.ts +26 -0
  97. package/packages/cad-styling/src/NodeCollectionDeserializer.d.ts +26 -0
  98. package/{core/src/datamodels/cad/styling → packages/cad-styling/src}/PopulateIndexSetFromPagedResponseHelper.d.ts +30 -30
  99. package/{core/src/datamodels/cad/styling → packages/cad-styling/src}/PropertyFilterNodeCollection.d.ts +57 -55
  100. package/packages/cad-styling/src/SerializedNodeCollection.d.ts +8 -0
  101. package/{core/src/datamodels/cad/styling → packages/cad-styling/src}/SinglePropertyFilterNodeCollection.d.ts +53 -51
  102. package/packages/cad-styling/src/TreeIndexNodeCollection.d.ts +40 -39
  103. package/packages/cad-styling/src/UnionNodeCollection.d.ts +19 -18
  104. package/packages/cad-styling/src/prioritized/AreaCollection.d.ts +39 -39
  105. package/packages/cad-styling/src/prioritized/BoxClusterer.d.ts +29 -29
  106. package/packages/cad-styling/src/prioritized/ClusteredAreaCollection.d.ts +17 -17
  107. package/packages/cad-styling/src/prioritized/EmptyAreaCollection.d.ts +18 -18
  108. package/packages/cad-styling/src/prioritized/types.d.ts +7 -7
  109. package/packages/camera-manager/index.d.ts +8 -6
  110. package/packages/camera-manager/src/CameraManager.d.ts +73 -84
  111. package/packages/camera-manager/src/CameraManagerHelper.d.ts +42 -0
  112. package/packages/camera-manager/src/ComboControls.d.ts +112 -101
  113. package/packages/camera-manager/src/DefaultCameraManager.d.ts +136 -0
  114. package/packages/camera-manager/src/Keyboard.d.ts +17 -17
  115. package/packages/camera-manager/src/types.d.ts +75 -64
  116. package/packages/data-source/index.d.ts +6 -6
  117. package/packages/data-source/src/CdfDataSource.d.ts +19 -19
  118. package/packages/data-source/src/DataSource.d.ts +25 -25
  119. package/packages/data-source/src/LocalDataSource.d.ts +15 -15
  120. package/packages/logger/index.d.ts +5 -5
  121. package/packages/logger/src/Log.d.ts +5 -5
  122. package/packages/metrics/index.d.ts +4 -5
  123. package/packages/metrics/src/MetricsLogger.d.ts +21 -21
  124. package/packages/metrics/src/types.d.ts +7 -7
  125. package/packages/model-base/index.d.ts +8 -0
  126. package/{core/src/public/migration → packages/model-base/src}/CogniteModelBase.d.ts +17 -17
  127. package/packages/{cad-parsers/src/metadata → model-base/src}/MetadataRepository.d.ts +7 -7
  128. package/{core/src/public/migration → packages/model-base/src}/NodeIdAndTreeIndexMaps.d.ts +4 -4
  129. package/{core/src/datamodels/base → packages/model-base/src}/SupportedModelTypes.d.ts +4 -4
  130. package/packages/{cad-geometry-loaders/src/utilities → model-base/src}/types.d.ts +36 -25
  131. package/packages/modeldata-api/index.d.ts +12 -13
  132. package/packages/modeldata-api/src/CdfModelDataProvider.d.ts +17 -17
  133. package/packages/modeldata-api/src/CdfModelIdentifier.d.ts +15 -15
  134. package/packages/modeldata-api/src/CdfModelMetadataProvider.d.ts +20 -20
  135. package/packages/modeldata-api/src/LocalModelDataProvider.d.ts +10 -10
  136. package/packages/modeldata-api/src/LocalModelIdentifier.d.ts +14 -14
  137. package/packages/modeldata-api/src/LocalModelMetadataProvider.d.ts +16 -16
  138. package/packages/modeldata-api/src/ModelIdentifier.d.ts +12 -12
  139. package/packages/modeldata-api/src/ModelMetadataProvider.d.ts +18 -18
  140. package/packages/modeldata-api/src/applyDefaultModelTransformation.d.ts +6 -6
  141. package/packages/modeldata-api/src/types.d.ts +47 -47
  142. package/packages/modeldata-api/src/utilities.d.ts +7 -7
  143. package/packages/nodes-api/index.d.ts +6 -6
  144. package/packages/nodes-api/src/NodesApiClient.d.ts +50 -50
  145. package/packages/nodes-api/src/NodesCdfClient.d.ts +24 -24
  146. package/packages/nodes-api/src/NodesLocalClient.d.ts +30 -30
  147. package/packages/nodes-api/src/types.d.ts +10 -10
  148. package/packages/pointclouds/index.d.ts +13 -0
  149. package/{core/src/public/migration → packages/pointclouds/src}/CognitePointCloudModel.d.ts +120 -121
  150. package/packages/pointclouds/src/PointCloudBudget.d.ts +14 -0
  151. package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudFactory.d.ts +9 -9
  152. package/packages/pointclouds/src/PointCloudIntersection.d.ts +26 -0
  153. package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudManager.d.ts +26 -26
  154. package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudMetadata.d.ts +14 -14
  155. package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudMetadataRepository.d.ts +14 -14
  156. package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudNode.d.ts +62 -62
  157. package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PotreeGroupWrapper.d.ts +39 -39
  158. package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PotreeNodeWrapper.d.ts +38 -38
  159. package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/createPointCloudManager.d.ts +6 -6
  160. package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/picking.d.ts +29 -29
  161. package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/types.d.ts +114 -114
  162. package/packages/rendering/index.d.ts +14 -17
  163. package/packages/rendering/src/CadMaterialManager.d.ts +39 -37
  164. package/packages/rendering/src/GeometryBatchingManager.d.ts +31 -30
  165. package/packages/rendering/src/InstancedMeshManager.d.ts +20 -20
  166. package/packages/rendering/src/rendering/EffectRenderManager.d.ts +99 -99
  167. package/packages/rendering/src/rendering/NodeAppearanceTextureBuilder.d.ts +51 -51
  168. package/packages/rendering/src/rendering/RenderMode.d.ts +15 -15
  169. package/packages/rendering/src/rendering/createSimpleGeometryMesh.d.ts +6 -6
  170. package/packages/rendering/src/rendering/matCapTextureData.d.ts +5 -5
  171. package/packages/rendering/src/rendering/materials.d.ts +23 -23
  172. package/packages/rendering/src/rendering/primitives.d.ts +12 -12
  173. package/packages/rendering/src/rendering/shaders.d.ts +101 -101
  174. package/packages/rendering/src/rendering/types.d.ts +76 -76
  175. package/packages/rendering/src/sector/CadNode.d.ts +57 -63
  176. package/packages/rendering/src/transform/NodeTransformProvider.d.ts +13 -13
  177. package/packages/rendering/src/transform/NodeTransformTextureBuilder.d.ts +23 -23
  178. package/packages/rendering/src/transform/TransformOverrideBuffer.d.ts +21 -21
  179. package/packages/rendering/src/utilities/types.d.ts +26 -26
  180. package/packages/sector-loader/index.d.ts +6 -6
  181. package/packages/sector-loader/src/GltfSectorLoader.d.ts +12 -0
  182. package/packages/sector-loader/src/GltfSectorRepository.d.ts +19 -14
  183. package/packages/sector-loader/src/SectorRepository.d.ts +10 -9
  184. package/packages/sector-loader/src/V8SectorRepository.d.ts +26 -25
  185. package/packages/sector-loader/src/v8/SimpleAndDetailedToSector3D.d.ts +20 -20
  186. package/packages/sector-loader/src/v8/arrays.d.ts +5 -5
  187. package/packages/sector-loader/src/v8/groupMeshesByNumber.d.ts +8 -8
  188. package/packages/sector-loader/src/v8/sectorUtilities.d.ts +16 -16
  189. package/packages/sector-parser/index.d.ts +5 -5
  190. package/packages/sector-parser/src/DracoDecoderHelper.d.ts +32 -0
  191. package/packages/sector-parser/src/GltfSectorParser.d.ts +19 -18
  192. package/packages/sector-parser/src/constants.d.ts +6 -0
  193. package/packages/sector-parser/src/reveal-glb-parser/GlbMetadataParser.d.ts +14 -14
  194. package/packages/sector-parser/src/reveal-glb-parser/primitiveGeometries.d.ts +12 -12
  195. package/packages/sector-parser/src/types.d.ts +106 -98
  196. package/packages/tools/index.d.ts +15 -15
  197. package/packages/tools/src/AxisView/AxisViewTool.d.ts +32 -32
  198. package/packages/tools/src/AxisView/types.d.ts +98 -98
  199. package/packages/tools/src/Cognite3DViewerToolBase.d.ts +25 -25
  200. package/packages/tools/src/DebugCameraTool.d.ts +20 -20
  201. package/packages/tools/src/DebugLoadedSectorsTool.d.ts +23 -23
  202. package/packages/tools/src/ExplodedViewTool.d.ts +12 -12
  203. package/packages/tools/src/Geomap/Geomap.d.ts +17 -17
  204. package/packages/tools/src/Geomap/GeomapTool.d.ts +23 -23
  205. package/packages/tools/src/Geomap/MapConfig.d.ts +195 -195
  206. package/packages/tools/src/HtmlOverlay/BucketGrid2D.d.ts +28 -28
  207. package/packages/tools/src/HtmlOverlay/HtmlOverlayTool.d.ts +160 -160
  208. package/packages/tools/src/Timeline/Keyframe.d.ts +39 -39
  209. package/packages/tools/src/Timeline/TimelineTool.d.ts +79 -79
  210. package/packages/tools/src/Timeline/types.d.ts +13 -13
  211. package/packages/tools/src/types.d.ts +4 -4
  212. package/packages/utilities/index.d.ts +32 -28
  213. package/packages/utilities/src/CameraConfiguration.d.ts +10 -10
  214. package/packages/utilities/src/DeferredPromise.d.ts +17 -17
  215. package/packages/utilities/src/IndexSet.d.ts +1 -1
  216. package/packages/utilities/src/NumericRange.d.ts +22 -22
  217. package/packages/utilities/src/RandomColors.d.ts +34 -34
  218. package/packages/utilities/src/WebGLRendererStateHelper.d.ts +15 -15
  219. package/packages/utilities/src/assertNever.d.ts +7 -7
  220. package/packages/utilities/src/cache/MemoryRequestCache.d.ts +24 -22
  221. package/packages/utilities/src/cache/MostFrequentlyUsedCache.d.ts +19 -19
  222. package/packages/utilities/src/cache/RequestCache.d.ts +13 -13
  223. package/packages/utilities/src/calculateVolumeOfMesh.d.ts +4 -0
  224. package/packages/utilities/src/counterMap.d.ts +5 -5
  225. package/packages/utilities/src/datastructures/DynamicDefragmentedBuffer.d.ts +33 -35
  226. package/packages/utilities/src/determinePowerOfTwoDimensions.d.ts +11 -11
  227. package/packages/utilities/src/disposeAttributeArrayOnUpload.d.ts +17 -17
  228. package/packages/utilities/src/events/EventTrigger.d.ts +13 -13
  229. package/packages/utilities/src/events/InputHandler.d.ts +34 -25
  230. package/packages/utilities/src/events/clickOrTouchEventOffset.d.ts +13 -13
  231. package/packages/utilities/src/events/index.d.ts +6 -6
  232. package/packages/utilities/src/indexset/IndexSet.d.ts +26 -26
  233. package/packages/utilities/src/indexset/IntermediateIndexNode.d.ts +26 -26
  234. package/packages/utilities/src/indexset/LeafIndexNode.d.ts +16 -16
  235. package/packages/utilities/src/isMobileOrTablet.d.ts +4 -4
  236. package/packages/utilities/src/networking/isTheSameDomain.d.ts +11 -11
  237. package/packages/utilities/src/objectTraversal.d.ts +8 -8
  238. package/packages/utilities/src/packFloat.d.ts +6 -6
  239. package/packages/utilities/src/revealEnv.d.ts +10 -10
  240. package/packages/utilities/src/three/AutoDisposeGroup.d.ts +17 -17
  241. package/packages/utilities/src/three/BoundingBoxLOD.d.ts +27 -27
  242. package/packages/utilities/src/three/isBox3OnPositiveSideOfPlane.d.ts +10 -10
  243. package/packages/utilities/src/three/toThreeBox3.d.ts +6 -6
  244. package/packages/utilities/src/three/unionBoxes.d.ts +5 -0
  245. package/packages/utilities/src/three/visitBox3CornerPoints.d.ts +12 -12
  246. package/packages/utilities/src/transformCameraConfiguration.d.ts +6 -6
  247. package/packages/utilities/src/types.d.ts +11 -11
  248. package/packages/utilities/src/workers/WorkerPool.d.ts +14 -14
  249. package/{core/src/utilities → packages/utilities/src}/worldToViewport.d.ts +30 -30
  250. package/tools.d.ts +7 -7
  251. package/tools.js +98 -74
  252. package/tools.map +1 -1
  253. package/core/src/datamodels/base/index.d.ts +0 -6
  254. package/core/src/datamodels/base/types.d.ts +0 -14
  255. package/core/src/datamodels/cad/CadModelFactory.d.ts +0 -13
  256. package/core/src/datamodels/cad/rendering/RenderAlreadyLoadedGeometryProvider.d.ts +0 -10
  257. package/core/src/datamodels/cad/styling/NodeCollectionDeserializer.d.ts +0 -26
  258. package/core/src/datamodels/cad/styling/index.d.ts +0 -8
  259. package/core/src/datamodels/pointcloud/index.d.ts +0 -5
  260. package/core/src/migration.d.ts +0 -8
  261. package/packages/cad-geometry-loaders/src/sector/culling/OccludingGeometryProvider.d.ts +0 -6
  262. package/packages/cad-styling/src/NodeCollectionBase.d.ts +0 -54
  263. package/packages/modeldata-api/src/CdfModelOutputsProvider.d.ts +0 -16
  264. package/packages/modeldata-api/src/Model3DOutputList.d.ts +0 -17
  265. package/packages/rendering/src/cameraconfig.d.ts +0 -12
@@ -1,340 +1,337 @@
1
- /*!
2
- * Copyright 2021 Cognite AS
3
- */
4
- import * as THREE from 'three';
5
- import { CogniteInternalId } from '@cognite/sdk';
6
- import { CameraConfiguration } from './types';
7
- import { CogniteModelBase } from './CogniteModelBase';
8
- import { SupportedModelTypes } from '../types';
9
- import { WellKnownUnit } from './types';
10
- import { NumericRange } from '../../../../packages/utilities';
11
- import { NodeCollectionBase, NodeAppearance } from '../../../../packages/cad-styling';
12
- /**
13
- * Represents a single 3D CAD model loaded from CDF.
14
- * @noInheritDoc
15
- * @module @cognite/reveal
16
- */
17
- export declare class Cognite3DModel extends THREE.Object3D implements CogniteModelBase {
18
- readonly type: SupportedModelTypes;
19
- /**
20
- * Returns the unit the coordinates for the model is stored. Returns an empty string
21
- * if no unit has been stored.
22
- * Note that coordinates in Reveal always are converted to meters using {@see modelUnitToMetersFactor}.
23
- */
24
- get modelUnit(): WellKnownUnit | '';
25
- /**
26
- * Returns the conversion factor that converts from model coordinates to meters. Note that this can
27
- * return undefined if the model has been stored in an unsupported unit.
28
- */
29
- get modelUnitToMetersFactor(): number | undefined;
30
- /**
31
- * The CDF model ID of the model.
32
- */
33
- readonly modelId: number;
34
- /**
35
- * The CDF revision ID of the model.
36
- */
37
- readonly revisionId: number;
38
- private readonly cadModel;
39
- private readonly nodesApiClient;
40
- private readonly nodeIdAndTreeIndexMaps;
41
- private readonly _styledNodeCollections;
42
- /**
43
- * Sets the default appearance for nodes that are not styled using
44
- * {@link assignStyledNodeCollection}. Updating the default style can be an
45
- * expensive operation, so use with care.
46
- *
47
- * @param appearance Default node appearance.
48
- */
49
- setDefaultNodeAppearance(appearance: NodeAppearance): void;
50
- /**
51
- * Gets the default appearance for nodes that are not styled using
52
- * {@link assignStyledNodeCollection}.
53
- */
54
- getDefaultNodeAppearance(): NodeAppearance;
55
- /**
56
- * Returns all currently registered node collections and associated appearance.
57
- */
58
- get styledNodeCollections(): {
59
- nodeCollection: NodeCollectionBase;
60
- appearance: NodeAppearance;
61
- }[];
62
- /**
63
- * Customizes rendering style for a set of nodes, e.g. to highlight, hide
64
- * or color code a set of 3D objects. This allows for custom look and feel
65
- * of the 3D model which is useful to highlight certain parts or to
66
- * color code the 3D model based on information (e.g. coloring the 3D model
67
- * by construction status).
68
- *
69
- * The {@link NodeCollectionBase} can be updated dynamically and the rendered nodes will be
70
- * updated automatically as the styling changes. The appearance of the style nodes
71
- * cannot be changed.
72
- *
73
- * When nodes are in several styled sets, the style is combined in the order
74
- * the sets were added, i.e. styled sets added late can overwrite styled sets added
75
- * early.
76
- *
77
- * If the `nodeCollection` provided already has an assigned style, this style will
78
- * be replaced with style provided.
79
- *
80
- * @param nodeCollection Dynamic set of nodes to apply the provided appearance to.
81
- * @param appearance Appearance to style the provided set with.
82
- * @example
83
- * ```js
84
- * model.setDefaultNodeAppearance({ rendererGhosted: true });
85
- * const visibleNodes = new TreeIndexNodeCollection(someTreeIndices);
86
- * model.assignStyledNodeCollection(visibleSet, { rendererGhosted: false });
87
- * ```
88
- * @throws Error if node collection already has been assigned to the model.
89
- */
90
- assignStyledNodeCollection(nodeCollection: NodeCollectionBase, appearance: NodeAppearance): void;
91
- /**
92
- * Removes styling for previously added styled collection, resetting the style to the default (or
93
- * the style imposed by other styled collections).
94
- * @param nodeCollection Node collection previously added using {@link assignStyledNodeCollection}.
95
- * @throws Error if node collection isn't assigned to the model.
96
- */
97
- unassignStyledNodeCollection(nodeCollection: NodeCollectionBase): void;
98
- /**
99
- * Removes all styled collections, resetting the appearance of all nodes to the
100
- * default appearance.
101
- */
102
- removeAllStyledNodeCollections(): void;
103
- /**
104
- * Apply a transformation matrix to the tree indices given, changing
105
- * rotation, scale and/or position.
106
- *
107
- * Note that setting multiple transformations for the same
108
- * node isn't supported and might lead to undefined results.
109
- * @param treeIndices Tree indices of nodes to apply the transformation to.
110
- * @param transformMatrix Transformation to apply.
111
- */
112
- setNodeTransform(treeIndices: NumericRange, transformMatrix: THREE.Matrix4): void;
113
- /**
114
- * Resets the transformation for the nodes given.
115
- * @param treeIndices Tree indices of the nodes to reset transforms for.
116
- */
117
- resetNodeTransform(treeIndices: NumericRange): void;
118
- /**
119
- * Maps a position retrieved from the CDF API (e.g. 3D node information) to
120
- * coordinates in "ThreeJS model space". This is necessary because CDF has a right-handed
121
- * Z-up coordinate system while ThreeJS uses a right-hand Y-up coordinate system.
122
- * @param p The CDF coordinate to transform.
123
- * @param out Optional preallocated buffer for storing the result. May be `p`.
124
- * @returns Transformed position.
125
- */
126
- mapFromCdfToModelCoordinates(p: THREE.Vector3, out?: THREE.Vector3): THREE.Vector3;
127
- /**
128
- * Maps from a 3D position in "ThreeJS model space" (e.g. a ray intersection coordinate)
129
- * to coordinates in "CDF space". This is necessary because CDF has a right-handed
130
- * Z-up coordinate system while ThreeJS uses a right-hand Y-up coordinate system.
131
- * This function also accounts for transformation applied to the model.
132
- * @param p The ThreeJS coordinate to transform.
133
- * @param out Optional preallocated buffer for storing the result. May be `p`.
134
- * @returns Transformed position.
135
- */
136
- mapPositionFromModelToCdfCoordinates(p: THREE.Vector3, out?: THREE.Vector3): THREE.Vector3;
137
- /**
138
- * Maps from a 3D position in "ThreeJS model space" to coordinates in "CDF space".
139
- * This is necessary because CDF has a right-handed Z-up coordinate system while ThreeJS
140
- * uses a right-hand Y-up coordinate system. This function also accounts for transformation
141
- * applied to the model.
142
- * @param box The box in ThreeJS/model coordinates.
143
- * @param out Optional preallocated buffer for storing the result. May be same input as `box`.
144
- * @returns Transformed box.
145
- */
146
- mapBoxFromModelToCdfCoordinates(box: THREE.Box3, out?: THREE.Box3): THREE.Box3;
147
- /**
148
- * Maps from a 3D position in "CDF space" to coordinates in "ThreeJS model space".
149
- * This is necessary because CDF has a right-handed Z-up coordinate system while ThreeJS
150
- * uses a right-hand Y-up coordinate system. This function also accounts for transformation
151
- * applied to the model.
152
- * @param box The box in CDF model coordinates.
153
- * @param out Optional preallocated buffer for storing the result. May be same input as `box`.
154
- * @returns Transformed box.
155
- */
156
- mapBoxFromCdfToModelCoordinates(box: THREE.Box3, out?: THREE.Box3): THREE.Box3;
157
- /**
158
- * Cleans up used resources.
159
- */
160
- dispose(): void;
161
- /**
162
- * Determines the range of tree indices for a given subtree.
163
- * @param treeIndex Index of the root of the subtree to get the index range for.
164
- */
165
- getSubtreeTreeIndices(treeIndex: number): Promise<NumericRange>;
166
- /**
167
- * Determines the tree index range of a subtree of an ancestor of the provided
168
- * node defined by a tree index.
169
- *
170
- * @param treeIndex Tree index of node to find ancestor tree index range for.
171
- * @param generation What "generation" to find. 0 is the node itself,
172
- * 1 means parent, 2 means grandparent etc. If the node doesn't have as many
173
- * ancestors, the root of the model is returned. This can be determined by checking
174
- * that the range returned includes 0.
175
- * @returns Tree index range of the subtree spanned by the ancestor at the
176
- * "generation" specified, or the root.
177
- */
178
- getAncestorTreeIndices(treeIndex: number, generation: number): Promise<NumericRange>;
179
- /**
180
- * Determines the full bounding box of the model.
181
- * @param outBbox Optional. Used to write result to.
182
- * @param restrictToMostGeometry Optional. When true, returned bounds are restricted to
183
- * where most of the geometry is located. This is useful for models that have junk geometry
184
- * located far from the "main" model. Added in version 1.3.0.
185
- * @returns Model bounding box.
186
- *
187
- * @example
188
- * ```js
189
- * const box = new THREE.Box3()
190
- * model.getModelBoundingBox(box);
191
- * // box now has the bounding box
192
- * ```
193
- * ```js
194
- * // the following code does the same
195
- * const box = model.getModelBoundingBox();
196
- * ```
197
- */
198
- getModelBoundingBox(outBbox?: THREE.Box3, restrictToMostGeometry?: boolean): THREE.Box3;
199
- /**
200
- * Retrieves the camera position and target stored for the model. Typically this
201
- * is used to store a good starting position for a model. Returns `undefined` if there
202
- * isn't any stored camera configuration for the model.
203
- */
204
- getCameraConfiguration(): CameraConfiguration | undefined;
205
- /**
206
- * Sets transformation matrix of the model. This overrides the current transformation.
207
- * @param matrix Transformation matrix.
208
- */
209
- setModelTransformation(matrix: THREE.Matrix4): void;
210
- /**
211
- * Gets transformation matrix of the model.
212
- * @param out Preallocated `THREE.Matrix4` (optional).
213
- */
214
- getModelTransformation(out?: THREE.Matrix4): THREE.Matrix4;
215
- /**
216
- * Fetches a bounding box from the CDF by the nodeId.
217
- * @param nodeId
218
- * @param box Optional. Used to write result to.
219
- * @example
220
- * ```js
221
- * const box = new THREE.Box3()
222
- * const nodeId = 100500;
223
- * await model.getBoundingBoxByNodeId(nodeId, box);
224
- * // box now has the bounding box
225
- *```
226
- * ```js
227
- * // the following code does the same
228
- * const box = await model.getBoundingBoxByNodeId(nodeId);
229
- * ```
230
- */
231
- getBoundingBoxByNodeId(nodeId: number, box?: THREE.Box3): Promise<THREE.Box3>;
232
- /**
233
- * Determine the bounding box of the node identified by the tree index provided. Note that this
234
- * function uses the CDF API to look up the bounding box.
235
- * @param treeIndex Tree index of the node to find bounding box for.
236
- * @param box Optional preallocated container to hold the bounding box.
237
- * @example
238
- * ```js
239
- * const box = new THREE.Box3()
240
- * const treeIndex = 42;
241
- * await model.getBoundingBoxByTreeIndex(treeIndex, box);
242
- * // box now has the bounding box
243
- *```
244
- * ```js
245
- * // the following code does the same
246
- * const box = await model.getBoundingBoxByTreeIndex(treeIndex);
247
- * ```
248
- */
249
- getBoundingBoxByTreeIndex(treeIndex: number, box?: THREE.Box3): Promise<THREE.Box3>;
250
- /**
251
- * Iterates over all nodes in the model and applies the provided action to each node (identified by tree index).
252
- * The passed action is applied incrementally to avoid main thread blocking, meaning that the changes can be partially
253
- * applied until promise is resolved (iteration is done).
254
- * @param action Function that will be called with a treeIndex argument.
255
- * @returns Promise that is resolved once the iteration is done.
256
- * @example
257
- * ```js
258
- * const logIndex = (treeIndex) => console.log(treeIndex);
259
- * await model.iterateNodesByTreeIndex(logIndex); // 0, 1, 2, ...
260
- * ```
261
- */
262
- iterateNodesByTreeIndex(action: (treeIndex: number) => void): Promise<void>;
263
- /**
264
- * Returns the number of nodes in the model.
265
- */
266
- get nodeCount(): number;
267
- /**
268
- * Iterates over all nodes in a subtree of the model and applies the provided action to each node
269
- * (identified by tree index). The provided node is included in the visited set. The passed action
270
- * is applied incrementally to avoid main thread blocking, meaning that the changes can be partially
271
- * applied until promise is resolved (iteration is done).
272
- * @param treeIndex Tree index of the top parent of the subtree.
273
- * @param action Function that will be called with a treeIndex argument.
274
- * @returns Promise that is resolved once the iteration is done.
275
- * @example
276
- * ```js
277
- * // make a subtree to be gray
278
- * await model.iterateNodesByTreeIndex(treeIndex => {
279
- * model.setNodeColorByTreeIndex(treeIndex, 127, 127, 127);
280
- * });
281
- * ```
282
- */
283
- iterateSubtreeByTreeIndex(treeIndex: number, action: (treeIndex: number) => void): Promise<void>;
284
- /**
285
- * Set override transform of the node by tree index.
286
- * @param treeIndex
287
- * @param transform
288
- * @param applyToChildren
289
- */
290
- setNodeTransformByTreeIndex(treeIndex: number, transform: THREE.Matrix4, applyToChildren?: boolean): Promise<number>;
291
- /**
292
- * Remove override transform of the node by tree index.
293
- * @param treeIndex
294
- * @param applyToChildren
295
- */
296
- resetNodeTransformByTreeIndex(treeIndex: number, applyToChildren?: boolean): Promise<number>;
297
- /**
298
- * Maps a list of Node IDs to tree indices. This function is useful when you have
299
- * a list of nodes, e.g. from Asset Mappings, that you want to highlight, hide,
300
- * color etc in the viewer.
301
- *
302
- * @param nodeIds List of node IDs to map to tree indices.
303
- * @returns A list of tree indices corresponing to the elements in the input.
304
- * @throws If an invalid/non-existant node ID is provided the function throws an error.
305
- */
306
- mapNodeIdsToTreeIndices(nodeIds: CogniteInternalId[]): Promise<number[]>;
307
- /**
308
- * Maps a single node ID to tree index. This is useful when you e.g. have a
309
- * node ID from an asset mapping and want to highlight the given asset using
310
- * {@link mapNodeIdsToTreeIndices} is recommended for better performance when
311
- * mapping multiple IDs.
312
- *
313
- * @param nodeId A Node ID to map to a tree index.
314
- * @returns TreeIndex of the provided node.
315
- * @throws If an invalid/non-existant node ID is provided the function throws an error.
316
- */
317
- mapNodeIdToTreeIndex(nodeId: CogniteInternalId): Promise<number>;
318
- /**
319
- * Maps a list of tree indices to node IDs for use with the Cognite SDK.
320
- * This function is useful if you have a list of tree indices, e.g. from
321
- * {@link Cognite3DModel.iterateSubtreeByTreeIndex}, and want to perform
322
- * some operations on these nodes using the SDK.
323
- *
324
- * @param treeIndices Tree indices to map to node IDs.
325
- * @returns A list of node IDs corresponding to the elements of the input.
326
- * @throws If an invalid tree index is provided the function throws an error.
327
- */
328
- mapTreeIndicesToNodeIds(treeIndices: number[]): Promise<CogniteInternalId[]>;
329
- /**
330
- * Maps a single tree index to node ID for use with the API. If you have multiple
331
- * tree indices to map, {@link mapNodeIdsToTreeIndices} is recommended for better
332
- * performance.
333
- * @param treeIndex A tree index to map to a Node ID.
334
- * @returns TreeIndex of the provided node.
335
- * @throws If an invalid/non-existent node ID is provided the function throws an error.
336
- */
337
- mapTreeIndexToNodeId(treeIndex: number): Promise<CogniteInternalId>;
338
- /** @private */
339
- private determineTreeIndices;
340
- }
1
+ /*!
2
+ * Copyright 2021 Cognite AS
3
+ */
4
+ import * as THREE from 'three';
5
+ import { CogniteInternalId } from '@cognite/sdk';
6
+ import { WellKnownUnit } from './WellKnownUnit';
7
+ import { SupportedModelTypes, CogniteModelBase } from '../../model-base';
8
+ import { NumericRange, CameraConfiguration } from '../../utilities';
9
+ import { NodeAppearance, NodeCollection, CdfModelNodeCollectionDataProvider } from '../../cad-styling';
10
+ /**
11
+ * Represents a single 3D CAD model loaded from CDF.
12
+ * @noInheritDoc
13
+ * @module @cognite/reveal
14
+ */
15
+ export declare class Cognite3DModel extends THREE.Object3D implements CogniteModelBase, CdfModelNodeCollectionDataProvider {
16
+ readonly type: SupportedModelTypes;
17
+ /**
18
+ * Returns the unit the coordinates for the model is stored. Returns an empty string
19
+ * if no unit has been stored.
20
+ * Note that coordinates in Reveal always are converted to meters using {@see modelUnitToMetersFactor}.
21
+ */
22
+ get modelUnit(): WellKnownUnit | '';
23
+ /**
24
+ * Returns the conversion factor that converts from model coordinates to meters. Note that this can
25
+ * return undefined if the model has been stored in an unsupported unit.
26
+ */
27
+ get modelUnitToMetersFactor(): number | undefined;
28
+ /**
29
+ * The CDF model ID of the model.
30
+ */
31
+ readonly modelId: number;
32
+ /**
33
+ * The CDF revision ID of the model.
34
+ */
35
+ readonly revisionId: number;
36
+ private readonly cadModel;
37
+ private readonly nodesApiClient;
38
+ private readonly nodeIdAndTreeIndexMaps;
39
+ private readonly _styledNodeCollections;
40
+ /**
41
+ * Sets the default appearance for nodes that are not styled using
42
+ * {@link assignStyledNodeCollection}. Updating the default style can be an
43
+ * expensive operation, so use with care.
44
+ *
45
+ * @param appearance Default node appearance.
46
+ */
47
+ setDefaultNodeAppearance(appearance: NodeAppearance): void;
48
+ /**
49
+ * Gets the default appearance for nodes that are not styled using
50
+ * {@link assignStyledNodeCollection}.
51
+ */
52
+ getDefaultNodeAppearance(): NodeAppearance;
53
+ /**
54
+ * Returns all currently registered node collections and associated appearance.
55
+ */
56
+ get styledNodeCollections(): {
57
+ nodeCollection: NodeCollection;
58
+ appearance: NodeAppearance;
59
+ }[];
60
+ /**
61
+ * Customizes rendering style for a set of nodes, e.g. to highlight, hide
62
+ * or color code a set of 3D objects. This allows for custom look and feel
63
+ * of the 3D model which is useful to highlight certain parts or to
64
+ * color code the 3D model based on information (e.g. coloring the 3D model
65
+ * by construction status).
66
+ *
67
+ * The {@link NodeCollection} can be updated dynamically and the rendered nodes will be
68
+ * updated automatically as the styling changes. The appearance of the style nodes
69
+ * cannot be changed.
70
+ *
71
+ * When nodes are in several styled sets, the style is combined in the order
72
+ * the sets were added, i.e. styled sets added late can overwrite styled sets added
73
+ * early.
74
+ *
75
+ * If the `nodeCollection` provided already has an assigned style, this style will
76
+ * be replaced with style provided.
77
+ *
78
+ * @param nodeCollection Dynamic set of nodes to apply the provided appearance to.
79
+ * @param appearance Appearance to style the provided set with.
80
+ * @example
81
+ * ```js
82
+ * model.setDefaultNodeAppearance({ rendererGhosted: true });
83
+ * const visibleNodes = new TreeIndexNodeCollection(someTreeIndices);
84
+ * model.assignStyledNodeCollection(visibleSet, { rendererGhosted: false });
85
+ * ```
86
+ */
87
+ assignStyledNodeCollection(nodeCollection: NodeCollection, appearance: NodeAppearance): void;
88
+ /**
89
+ * Removes styling for previously added styled collection, resetting the style to the default (or
90
+ * the style imposed by other styled collections).
91
+ * @param nodeCollection Node collection previously added using {@link assignStyledNodeCollection}.
92
+ * @throws Error if node collection isn't assigned to the model.
93
+ */
94
+ unassignStyledNodeCollection(nodeCollection: NodeCollection): void;
95
+ /**
96
+ * Removes all styled collections, resetting the appearance of all nodes to the
97
+ * default appearance.
98
+ */
99
+ removeAllStyledNodeCollections(): void;
100
+ /**
101
+ * Apply a transformation matrix to the tree indices given, changing
102
+ * rotation, scale and/or position.
103
+ *
104
+ * Note that setting multiple transformations for the same
105
+ * node isn't supported and might lead to undefined results.
106
+ * @param treeIndices Tree indices of nodes to apply the transformation to.
107
+ * @param transformMatrix Transformation to apply.
108
+ */
109
+ setNodeTransform(treeIndices: NumericRange, transformMatrix: THREE.Matrix4): void;
110
+ /**
111
+ * Resets the transformation for the nodes given.
112
+ * @param treeIndices Tree indices of the nodes to reset transforms for.
113
+ */
114
+ resetNodeTransform(treeIndices: NumericRange): void;
115
+ /**
116
+ * Maps a position retrieved from the CDF API (e.g. 3D node information) to
117
+ * coordinates in "ThreeJS model space". This is necessary because CDF has a right-handed
118
+ * Z-up coordinate system while ThreeJS uses a right-hand Y-up coordinate system.
119
+ * @param p The CDF coordinate to transform.
120
+ * @param out Optional preallocated buffer for storing the result. May be `p`.
121
+ * @returns Transformed position.
122
+ */
123
+ mapFromCdfToModelCoordinates(p: THREE.Vector3, out?: THREE.Vector3): THREE.Vector3;
124
+ /**
125
+ * Maps from a 3D position in "ThreeJS model space" (e.g. a ray intersection coordinate)
126
+ * to coordinates in "CDF space". This is necessary because CDF has a right-handed
127
+ * Z-up coordinate system while ThreeJS uses a right-hand Y-up coordinate system.
128
+ * This function also accounts for transformation applied to the model.
129
+ * @param p The ThreeJS coordinate to transform.
130
+ * @param out Optional preallocated buffer for storing the result. May be `p`.
131
+ * @returns Transformed position.
132
+ */
133
+ mapPositionFromModelToCdfCoordinates(p: THREE.Vector3, out?: THREE.Vector3): THREE.Vector3;
134
+ /**
135
+ * Maps from a 3D position in "ThreeJS model space" to coordinates in "CDF space".
136
+ * This is necessary because CDF has a right-handed Z-up coordinate system while ThreeJS
137
+ * uses a right-hand Y-up coordinate system. This function also accounts for transformation
138
+ * applied to the model.
139
+ * @param box The box in ThreeJS/model coordinates.
140
+ * @param out Optional preallocated buffer for storing the result. May be same input as `box`.
141
+ * @returns Transformed box.
142
+ */
143
+ mapBoxFromModelToCdfCoordinates(box: THREE.Box3, out?: THREE.Box3): THREE.Box3;
144
+ /**
145
+ * Maps from a 3D position in "CDF space" to coordinates in "ThreeJS model space".
146
+ * This is necessary because CDF has a right-handed Z-up coordinate system while ThreeJS
147
+ * uses a right-hand Y-up coordinate system. This function also accounts for transformation
148
+ * applied to the model.
149
+ * @param box The box in CDF model coordinates.
150
+ * @param out Optional preallocated buffer for storing the result. May be same input as `box`.
151
+ * @returns Transformed box.
152
+ */
153
+ mapBoxFromCdfToModelCoordinates(box: THREE.Box3, out?: THREE.Box3): THREE.Box3;
154
+ /**
155
+ * Cleans up used resources.
156
+ */
157
+ dispose(): void;
158
+ /**
159
+ * Determines the range of tree indices for a given subtree.
160
+ * @param treeIndex Index of the root of the subtree to get the index range for.
161
+ */
162
+ getSubtreeTreeIndices(treeIndex: number): Promise<NumericRange>;
163
+ /**
164
+ * Determines the tree index range of a subtree of an ancestor of the provided
165
+ * node defined by a tree index.
166
+ *
167
+ * @param treeIndex Tree index of node to find ancestor tree index range for.
168
+ * @param generation What "generation" to find. 0 is the node itself,
169
+ * 1 means parent, 2 means grandparent etc. If the node doesn't have as many
170
+ * ancestors, the root of the model is returned. This can be determined by checking
171
+ * that the range returned includes 0.
172
+ * @returns Tree index range of the subtree spanned by the ancestor at the
173
+ * "generation" specified, or the root.
174
+ */
175
+ getAncestorTreeIndices(treeIndex: number, generation: number): Promise<NumericRange>;
176
+ /**
177
+ * Determines the full bounding box of the model.
178
+ * @param outBbox Optional. Used to write result to.
179
+ * @param restrictToMostGeometry Optional. When true, returned bounds are restricted to
180
+ * where most of the geometry is located. This is useful for models that have junk geometry
181
+ * located far from the "main" model. Added in version 1.3.0.
182
+ * @returns Model bounding box.
183
+ *
184
+ * @example
185
+ * ```js
186
+ * const box = new THREE.Box3()
187
+ * model.getModelBoundingBox(box);
188
+ * // box now has the bounding box
189
+ * ```
190
+ * ```js
191
+ * // the following code does the same
192
+ * const box = model.getModelBoundingBox();
193
+ * ```
194
+ */
195
+ getModelBoundingBox(outBbox?: THREE.Box3, restrictToMostGeometry?: boolean): THREE.Box3;
196
+ /**
197
+ * Retrieves the camera position and target stored for the model. Typically this
198
+ * is used to store a good starting position for a model. Returns `undefined` if there
199
+ * isn't any stored camera configuration for the model.
200
+ */
201
+ getCameraConfiguration(): CameraConfiguration | undefined;
202
+ /**
203
+ * Sets transformation matrix of the model. This overrides the current transformation.
204
+ * @param matrix Transformation matrix.
205
+ */
206
+ setModelTransformation(matrix: THREE.Matrix4): void;
207
+ /**
208
+ * Gets transformation matrix of the model.
209
+ * @param out Preallocated `THREE.Matrix4` (optional).
210
+ */
211
+ getModelTransformation(out?: THREE.Matrix4): THREE.Matrix4;
212
+ /**
213
+ * Fetches a bounding box from the CDF by the nodeId.
214
+ * @param nodeId
215
+ * @param box Optional. Used to write result to.
216
+ * @example
217
+ * ```js
218
+ * const box = new THREE.Box3()
219
+ * const nodeId = 100500;
220
+ * await model.getBoundingBoxByNodeId(nodeId, box);
221
+ * // box now has the bounding box
222
+ *```
223
+ * ```js
224
+ * // the following code does the same
225
+ * const box = await model.getBoundingBoxByNodeId(nodeId);
226
+ * ```
227
+ */
228
+ getBoundingBoxByNodeId(nodeId: number, box?: THREE.Box3): Promise<THREE.Box3>;
229
+ /**
230
+ * Determine the bounding box of the node identified by the tree index provided. Note that this
231
+ * function uses the CDF API to look up the bounding box.
232
+ * @param treeIndex Tree index of the node to find bounding box for.
233
+ * @param box Optional preallocated container to hold the bounding box.
234
+ * @example
235
+ * ```js
236
+ * const box = new THREE.Box3()
237
+ * const treeIndex = 42;
238
+ * await model.getBoundingBoxByTreeIndex(treeIndex, box);
239
+ * // box now has the bounding box
240
+ *```
241
+ * ```js
242
+ * // the following code does the same
243
+ * const box = await model.getBoundingBoxByTreeIndex(treeIndex);
244
+ * ```
245
+ */
246
+ getBoundingBoxByTreeIndex(treeIndex: number, box?: THREE.Box3): Promise<THREE.Box3>;
247
+ /**
248
+ * Iterates over all nodes in the model and applies the provided action to each node (identified by tree index).
249
+ * The passed action is applied incrementally to avoid main thread blocking, meaning that the changes can be partially
250
+ * applied until promise is resolved (iteration is done).
251
+ * @param action Function that will be called with a treeIndex argument.
252
+ * @returns Promise that is resolved once the iteration is done.
253
+ * @example
254
+ * ```js
255
+ * const logIndex = (treeIndex) => console.log(treeIndex);
256
+ * await model.iterateNodesByTreeIndex(logIndex); // 0, 1, 2, ...
257
+ * ```
258
+ */
259
+ iterateNodesByTreeIndex(action: (treeIndex: number) => void): Promise<void>;
260
+ /**
261
+ * Returns the number of nodes in the model.
262
+ */
263
+ get nodeCount(): number;
264
+ /**
265
+ * Iterates over all nodes in a subtree of the model and applies the provided action to each node
266
+ * (identified by tree index). The provided node is included in the visited set. The passed action
267
+ * is applied incrementally to avoid main thread blocking, meaning that the changes can be partially
268
+ * applied until promise is resolved (iteration is done).
269
+ * @param treeIndex Tree index of the top parent of the subtree.
270
+ * @param action Function that will be called with a treeIndex argument.
271
+ * @returns Promise that is resolved once the iteration is done.
272
+ * @example
273
+ * ```js
274
+ * // make a subtree to be gray
275
+ * await model.iterateNodesByTreeIndex(treeIndex => {
276
+ * model.setNodeColorByTreeIndex(treeIndex, 127, 127, 127);
277
+ * });
278
+ * ```
279
+ */
280
+ iterateSubtreeByTreeIndex(treeIndex: number, action: (treeIndex: number) => void): Promise<void>;
281
+ /**
282
+ * Set override transform of the node by tree index.
283
+ * @param treeIndex
284
+ * @param transform
285
+ * @param applyToChildren
286
+ */
287
+ setNodeTransformByTreeIndex(treeIndex: number, transform: THREE.Matrix4, applyToChildren?: boolean): Promise<number>;
288
+ /**
289
+ * Remove override transform of the node by tree index.
290
+ * @param treeIndex
291
+ * @param applyToChildren
292
+ */
293
+ resetNodeTransformByTreeIndex(treeIndex: number, applyToChildren?: boolean): Promise<number>;
294
+ /**
295
+ * Maps a list of Node IDs to tree indices. This function is useful when you have
296
+ * a list of nodes, e.g. from Asset Mappings, that you want to highlight, hide,
297
+ * color etc in the viewer.
298
+ *
299
+ * @param nodeIds List of node IDs to map to tree indices.
300
+ * @returns A list of tree indices corresponing to the elements in the input.
301
+ * @throws If an invalid/non-existant node ID is provided the function throws an error.
302
+ */
303
+ mapNodeIdsToTreeIndices(nodeIds: CogniteInternalId[]): Promise<number[]>;
304
+ /**
305
+ * Maps a single node ID to tree index. This is useful when you e.g. have a
306
+ * node ID from an asset mapping and want to highlight the given asset using
307
+ * {@link mapNodeIdsToTreeIndices} is recommended for better performance when
308
+ * mapping multiple IDs.
309
+ *
310
+ * @param nodeId A Node ID to map to a tree index.
311
+ * @returns TreeIndex of the provided node.
312
+ * @throws If an invalid/non-existant node ID is provided the function throws an error.
313
+ */
314
+ mapNodeIdToTreeIndex(nodeId: CogniteInternalId): Promise<number>;
315
+ /**
316
+ * Maps a list of tree indices to node IDs for use with the Cognite SDK.
317
+ * This function is useful if you have a list of tree indices, e.g. from
318
+ * {@link Cognite3DModel.iterateSubtreeByTreeIndex}, and want to perform
319
+ * some operations on these nodes using the SDK.
320
+ *
321
+ * @param treeIndices Tree indices to map to node IDs.
322
+ * @returns A list of node IDs corresponding to the elements of the input.
323
+ * @throws If an invalid tree index is provided the function throws an error.
324
+ */
325
+ mapTreeIndicesToNodeIds(treeIndices: number[]): Promise<CogniteInternalId[]>;
326
+ /**
327
+ * Maps a single tree index to node ID for use with the API. If you have multiple
328
+ * tree indices to map, {@link mapNodeIdsToTreeIndices} is recommended for better
329
+ * performance.
330
+ * @param treeIndex A tree index to map to a Node ID.
331
+ * @returns TreeIndex of the provided node.
332
+ * @throws If an invalid/non-existent node ID is provided the function throws an error.
333
+ */
334
+ mapTreeIndexToNodeId(treeIndex: number): Promise<CogniteInternalId>;
335
+ /** @private */
336
+ private determineTreeIndices;
337
+ }