@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.
- package/core/cad.d.ts +4 -4
- package/core/index.d.ts +6 -7
- package/core/src/index.d.ts +13 -19
- package/core/src/internals.d.ts +10 -15
- package/core/src/public/RevealManager.d.ts +61 -64
- package/core/src/public/createRevealManager.d.ts +23 -23
- package/core/src/public/migration/Cognite3DViewer.d.ts +485 -559
- 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 +199 -253
- package/core/src/public/types.d.ts +25 -47
- package/core/src/storage/RevealManagerHelper.d.ts +59 -58
- package/core/src/utilities/Spinner.d.ts +27 -27
- package/core/src/utilities/ViewStateHelper.d.ts +49 -37
- package/core/src/utilities/index.d.ts +6 -8
- package/core/src/utilities/reflection.d.ts +7 -7
- package/core/utilities.d.ts +4 -4
- package/extensions/datasource.d.ts +9 -9
- package/extensions/datasource.js +5 -8
- package/extensions/datasource.map +1 -1
- package/index.d.ts +13 -9
- package/index.js +195 -167
- package/index.map +1 -1
- package/package.json +18 -17
- package/packages/cad-geometry-loaders/index.d.ts +7 -13
- package/packages/cad-geometry-loaders/src/CadLoadingHints.d.ts +11 -11
- package/packages/cad-geometry-loaders/src/CadModelBudget.d.ts +21 -19
- package/packages/cad-geometry-loaders/src/CadModelUpdateHandler.d.ts +44 -42
- package/packages/cad-geometry-loaders/src/sector/ModelStateHandler.d.ts +12 -12
- package/packages/cad-geometry-loaders/src/sector/SectorDownloadScheduler.d.ts +22 -22
- package/packages/cad-geometry-loaders/src/sector/SectorLoader.d.ts +32 -31
- package/packages/cad-geometry-loaders/src/sector/culling/ByScreenSizeSectorCuller.d.ts +23 -23
- package/packages/cad-geometry-loaders/src/sector/culling/ByVisibilityGpuSectorCuller.d.ts +51 -51
- package/packages/cad-geometry-loaders/src/sector/culling/OrderSectorsByVisibilityCoverage.d.ts +106 -107
- package/packages/cad-geometry-loaders/src/sector/culling/RenderAlreadyLoadedGeometryProvider.d.ts +9 -0
- package/packages/cad-geometry-loaders/src/sector/culling/SectorCuller.d.ts +33 -33
- package/packages/cad-geometry-loaders/src/sector/culling/WeightFunctionsHelper.d.ts +50 -50
- package/packages/cad-geometry-loaders/src/sector/culling/computeNdcAreaOfBox.d.ts +12 -12
- package/packages/cad-geometry-loaders/src/sector/culling/computeSectorCost.d.ts +7 -7
- package/packages/cad-geometry-loaders/src/sector/culling/createV8SectorCuller.d.ts +7 -7
- package/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenSectorMapBase.d.ts +11 -11
- package/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenV8SectorMap.d.ts +17 -17
- package/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenV8SectorTree.d.ts +24 -24
- package/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenV9SectorMap.d.ts +20 -20
- package/packages/cad-geometry-loaders/src/sector/culling/takensectors/index.d.ts +5 -5
- package/packages/cad-geometry-loaders/src/sector/culling/transformBoxToNDC.d.ts +5 -5
- package/packages/cad-geometry-loaders/src/sector/culling/types.d.ts +83 -83
- package/packages/cad-geometry-loaders/src/sector/rxSectorUtilities.d.ts +12 -12
- package/packages/cad-geometry-loaders/src/utilities/PromiseUtils.d.ts +28 -28
- package/packages/cad-geometry-loaders/src/utilities/rxOperations.d.ts +6 -6
- package/packages/cad-model/index.d.ts +12 -0
- package/{core/src/utilities → packages/cad-model/src}/BoundingBoxClipper.d.ts +23 -23
- package/{core/src/datamodels/cad → packages/cad-model/src}/CadManager.d.ts +48 -43
- package/packages/cad-model/src/CadModelFactory.d.ts +16 -0
- package/{core/src/datamodels/cad → packages/cad-model/src}/CadModelSectorLoadStatistics.d.ts +38 -38
- package/{core/src/public/migration → packages/cad-model/src}/Cognite3DModel.d.ts +337 -340
- package/packages/cad-model/src/GeometryFilter.d.ts +20 -0
- package/packages/cad-model/src/InternalRevealCadOptions.d.ts +13 -0
- package/packages/cad-model/src/WellKnownUnit.d.ts +7 -0
- package/{core/src/utilities → packages/cad-model/src}/callActionWithIndicesAsync.d.ts +4 -4
- package/{core/src/datamodels/cad → packages/cad-model/src}/createCadManager.d.ts +10 -9
- package/{core/src/datamodels/cad → packages/cad-model/src}/picking.d.ts +28 -28
- package/packages/cad-parsers/index.d.ts +20 -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/filterPrimitivesCommon.d.ts +5 -5
- package/packages/cad-parsers/src/cad/filterPrimitivesV8.d.ts +9 -9
- package/packages/cad-parsers/src/cad/filterPrimitivesV9.d.ts +6 -6
- package/packages/cad-parsers/src/cad/primitiveGeometries.d.ts +30 -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/{core/src/datamodels/cad/sector → packages/cad-parsers/src/metadata}/CadModelClipper.d.ts +10 -10
- package/packages/cad-parsers/src/metadata/CadModelMetadata.d.ts +54 -54
- package/packages/cad-parsers/src/metadata/CadModelMetadataRepository.d.ts +16 -16
- package/packages/cad-parsers/src/metadata/parsers/CadMetadataParserGltf.d.ts +8 -6
- package/packages/cad-parsers/src/metadata/parsers/CadMetadataParserV8.d.ts +6 -6
- package/packages/cad-parsers/src/metadata/parsers/types.d.ts +62 -60
- package/packages/cad-parsers/src/metadata/types.d.ts +53 -52
- package/packages/cad-parsers/src/sector/RootSectorNode.d.ts +13 -12
- package/packages/cad-parsers/src/sector/SectorNode.d.ts +22 -21
- package/packages/cad-parsers/src/utilities/SectorScene.d.ts +23 -21
- package/packages/cad-parsers/src/utilities/SectorSceneFactory.d.ts +9 -9
- package/packages/cad-parsers/src/utilities/computeBoundingBoxFromAttributes.d.ts +10 -10
- package/packages/cad-parsers/src/utilities/float32BufferToMatrix.d.ts +12 -12
- package/packages/cad-parsers/src/utilities/types.d.ts +71 -74
- package/packages/cad-styling/index.d.ts +20 -13
- package/{core/src/datamodels/cad/styling → packages/cad-styling/src}/AssetNodeCollection.d.ts +47 -45
- package/packages/cad-styling/src/CdfModelNodeCollectionDataProvider.d.ts +26 -0
- package/packages/cad-styling/src/CombineNodeCollectionBase.d.ts +34 -33
- package/packages/cad-styling/src/IntersectionNodeCollection.d.ts +20 -19
- package/{core/src/datamodels/cad/styling → packages/cad-styling/src}/InvertedNodeCollection.d.ts +27 -25
- package/packages/cad-styling/src/NodeAppearance.d.ts +85 -85
- package/packages/cad-styling/src/NodeAppearanceProvider.d.ts +38 -36
- package/packages/cad-styling/src/NodeCollection.d.ts +26 -0
- package/packages/cad-styling/src/NodeCollectionDeserializer.d.ts +26 -0
- package/{core/src/datamodels/cad/styling → packages/cad-styling/src}/PopulateIndexSetFromPagedResponseHelper.d.ts +30 -30
- package/{core/src/datamodels/cad/styling → packages/cad-styling/src}/PropertyFilterNodeCollection.d.ts +57 -55
- package/packages/cad-styling/src/SerializedNodeCollection.d.ts +8 -0
- package/{core/src/datamodels/cad/styling → packages/cad-styling/src}/SinglePropertyFilterNodeCollection.d.ts +53 -51
- package/packages/cad-styling/src/TreeIndexNodeCollection.d.ts +40 -39
- package/packages/cad-styling/src/UnionNodeCollection.d.ts +19 -18
- package/packages/cad-styling/src/prioritized/AreaCollection.d.ts +39 -39
- package/packages/cad-styling/src/prioritized/BoxClusterer.d.ts +29 -29
- package/packages/cad-styling/src/prioritized/ClusteredAreaCollection.d.ts +17 -17
- package/packages/cad-styling/src/prioritized/EmptyAreaCollection.d.ts +18 -18
- package/packages/cad-styling/src/prioritized/types.d.ts +7 -7
- package/packages/camera-manager/index.d.ts +8 -6
- package/packages/camera-manager/src/CameraManager.d.ts +73 -84
- package/packages/camera-manager/src/CameraManagerHelper.d.ts +42 -0
- package/packages/camera-manager/src/ComboControls.d.ts +112 -101
- package/packages/camera-manager/src/DefaultCameraManager.d.ts +136 -0
- package/packages/camera-manager/src/Keyboard.d.ts +17 -17
- package/packages/camera-manager/src/types.d.ts +75 -64
- 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 +25 -25
- 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 +4 -5
- package/packages/metrics/src/MetricsLogger.d.ts +21 -21
- package/packages/metrics/src/types.d.ts +7 -7
- package/packages/model-base/index.d.ts +8 -0
- package/{core/src/public/migration → packages/model-base/src}/CogniteModelBase.d.ts +17 -17
- package/packages/{cad-parsers/src/metadata → model-base/src}/MetadataRepository.d.ts +7 -7
- package/{core/src/public/migration → packages/model-base/src}/NodeIdAndTreeIndexMaps.d.ts +4 -4
- package/{core/src/datamodels/base → packages/model-base/src}/SupportedModelTypes.d.ts +4 -4
- package/packages/{cad-geometry-loaders/src/utilities → model-base/src}/types.d.ts +36 -25
- package/packages/modeldata-api/index.d.ts +12 -13
- package/packages/modeldata-api/src/CdfModelDataProvider.d.ts +17 -17
- package/packages/modeldata-api/src/CdfModelIdentifier.d.ts +15 -15
- package/packages/modeldata-api/src/CdfModelMetadataProvider.d.ts +20 -20
- 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 +16 -16
- package/packages/modeldata-api/src/ModelIdentifier.d.ts +12 -12
- package/packages/modeldata-api/src/ModelMetadataProvider.d.ts +18 -18
- package/packages/modeldata-api/src/applyDefaultModelTransformation.d.ts +6 -6
- package/packages/modeldata-api/src/types.d.ts +47 -47
- 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 +50 -50
- 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/pointclouds/index.d.ts +13 -0
- package/{core/src/public/migration → packages/pointclouds/src}/CognitePointCloudModel.d.ts +120 -121
- package/packages/pointclouds/src/PointCloudBudget.d.ts +14 -0
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudFactory.d.ts +9 -9
- package/packages/pointclouds/src/PointCloudIntersection.d.ts +26 -0
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudManager.d.ts +26 -26
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudMetadata.d.ts +14 -14
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudMetadataRepository.d.ts +14 -14
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudNode.d.ts +62 -62
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PotreeGroupWrapper.d.ts +39 -39
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PotreeNodeWrapper.d.ts +38 -38
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/createPointCloudManager.d.ts +6 -6
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/picking.d.ts +29 -29
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/types.d.ts +114 -114
- package/packages/rendering/index.d.ts +14 -17
- package/packages/rendering/src/CadMaterialManager.d.ts +39 -37
- package/packages/rendering/src/GeometryBatchingManager.d.ts +31 -30
- package/packages/rendering/src/InstancedMeshManager.d.ts +20 -20
- 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 +57 -63
- 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/sector-loader/index.d.ts +6 -6
- package/packages/sector-loader/src/GltfSectorLoader.d.ts +12 -0
- package/packages/sector-loader/src/GltfSectorRepository.d.ts +19 -14
- package/packages/sector-loader/src/SectorRepository.d.ts +10 -9
- package/packages/sector-loader/src/V8SectorRepository.d.ts +26 -25
- package/packages/sector-loader/src/v8/SimpleAndDetailedToSector3D.d.ts +20 -20
- package/packages/sector-loader/src/v8/arrays.d.ts +5 -5
- package/packages/sector-loader/src/v8/groupMeshesByNumber.d.ts +8 -8
- package/packages/sector-loader/src/v8/sectorUtilities.d.ts +16 -16
- package/packages/sector-parser/index.d.ts +5 -5
- package/packages/sector-parser/src/DracoDecoderHelper.d.ts +32 -0
- package/packages/sector-parser/src/GltfSectorParser.d.ts +19 -18
- package/packages/sector-parser/src/constants.d.ts +6 -0
- package/packages/sector-parser/src/reveal-glb-parser/GlbMetadataParser.d.ts +14 -14
- package/packages/sector-parser/src/reveal-glb-parser/primitiveGeometries.d.ts +12 -12
- package/packages/sector-parser/src/types.d.ts +106 -98
- 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 +23 -23
- 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 +160 -160
- package/packages/tools/src/Timeline/Keyframe.d.ts +39 -39
- 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 +32 -28
- package/packages/utilities/src/CameraConfiguration.d.ts +10 -10
- package/packages/utilities/src/DeferredPromise.d.ts +17 -17
- 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 +24 -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/calculateVolumeOfMesh.d.ts +4 -0
- package/packages/utilities/src/counterMap.d.ts +5 -5
- package/packages/utilities/src/datastructures/DynamicDefragmentedBuffer.d.ts +33 -35
- 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 -25
- package/packages/utilities/src/events/clickOrTouchEventOffset.d.ts +13 -13
- package/packages/utilities/src/events/index.d.ts +6 -6
- 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/isBox3OnPositiveSideOfPlane.d.ts +10 -10
- package/packages/utilities/src/three/toThreeBox3.d.ts +6 -6
- package/packages/utilities/src/three/unionBoxes.d.ts +5 -0
- package/packages/utilities/src/three/visitBox3CornerPoints.d.ts +12 -12
- package/packages/utilities/src/transformCameraConfiguration.d.ts +6 -6
- package/packages/utilities/src/types.d.ts +11 -11
- package/packages/utilities/src/workers/WorkerPool.d.ts +14 -14
- package/{core/src/utilities → packages/utilities/src}/worldToViewport.d.ts +30 -30
- package/tools.d.ts +7 -7
- package/tools.js +98 -74
- package/tools.map +1 -1
- package/core/src/datamodels/base/index.d.ts +0 -6
- package/core/src/datamodels/base/types.d.ts +0 -14
- package/core/src/datamodels/cad/CadModelFactory.d.ts +0 -13
- package/core/src/datamodels/cad/rendering/RenderAlreadyLoadedGeometryProvider.d.ts +0 -10
- package/core/src/datamodels/cad/styling/NodeCollectionDeserializer.d.ts +0 -26
- package/core/src/datamodels/cad/styling/index.d.ts +0 -8
- package/core/src/datamodels/pointcloud/index.d.ts +0 -5
- package/core/src/migration.d.ts +0 -8
- package/packages/cad-geometry-loaders/src/sector/culling/OccludingGeometryProvider.d.ts +0 -6
- package/packages/cad-styling/src/NodeCollectionBase.d.ts +0 -54
- package/packages/modeldata-api/src/CdfModelOutputsProvider.d.ts +0 -16
- package/packages/modeldata-api/src/Model3DOutputList.d.ts +0 -17
- package/packages/rendering/src/cameraconfig.d.ts +0 -12
|
@@ -1,58 +1,59 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright 2021 Cognite AS
|
|
3
|
-
*/
|
|
4
|
-
import * as THREE from 'three';
|
|
5
|
-
import { AddModelOptions } from '../public/migration/types';
|
|
6
|
-
import { RevealOptions } from '../public/types';
|
|
7
|
-
import { PointCloudNode, RevealManager } from '../internals';
|
|
8
|
-
import { DataSource } from '../../../packages/data-source';
|
|
9
|
-
import { CadNode } from '../../../packages/rendering';
|
|
10
|
-
import { CogniteClient } from '@cognite/sdk';
|
|
11
|
-
/**
|
|
12
|
-
* Helper for {@link RevealManager} for creating a uniform interface for
|
|
13
|
-
* working with instances that fetch models from CDF or instances that fetch
|
|
14
|
-
* models from local storage (i.e. in development/debugging).
|
|
15
|
-
*/
|
|
16
|
-
export declare class RevealManagerHelper {
|
|
17
|
-
private readonly _revealManager;
|
|
18
|
-
addCadModel: (model: AddModelOptions) => Promise<CadNode>;
|
|
19
|
-
addPointCloudModel: (model: AddModelOptions) => Promise<PointCloudNode>;
|
|
20
|
-
private constructor();
|
|
21
|
-
private constructor();
|
|
22
|
-
/**
|
|
23
|
-
* Create helper for RevealManager that loads models from local storage. This is only
|
|
24
|
-
* meant for use in debugging and development.
|
|
25
|
-
* @param renderer
|
|
26
|
-
* @param scene
|
|
27
|
-
* @param revealOptions
|
|
28
|
-
*/
|
|
29
|
-
static createLocalHelper(renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions: RevealOptions): RevealManagerHelper;
|
|
30
|
-
/**
|
|
31
|
-
* Creates a helper for RevealManager that loads models from CDF.
|
|
32
|
-
* @param renderer
|
|
33
|
-
* @param scene
|
|
34
|
-
* @param revealOptions
|
|
35
|
-
* @param sdkClient
|
|
36
|
-
*/
|
|
37
|
-
static createCdfHelper(renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions: RevealOptions, sdkClient: CogniteClient): RevealManagerHelper;
|
|
38
|
-
static createCustomDataSourceHelper(renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions: RevealOptions, dataSource: DataSource): RevealManagerHelper;
|
|
39
|
-
get revealManager(): RevealManager;
|
|
40
|
-
/**
|
|
41
|
-
* Adds a local CAD model.
|
|
42
|
-
* @param model
|
|
43
|
-
* @param revealManager
|
|
44
|
-
*/
|
|
45
|
-
private static addLocalCadModel;
|
|
46
|
-
/**
|
|
47
|
-
* Adds a CDF hosted CAD model.
|
|
48
|
-
* @param model
|
|
49
|
-
* @param revealManager
|
|
50
|
-
*/
|
|
51
|
-
private static addCdfCadModel;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*
|
|
55
|
-
* @param
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 Cognite AS
|
|
3
|
+
*/
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import { AddModelOptions } from '../public/migration/types';
|
|
6
|
+
import { RevealOptions } from '../public/types';
|
|
7
|
+
import { PointCloudNode, RevealManager } from '../internals';
|
|
8
|
+
import { DataSource } from '../../../packages/data-source';
|
|
9
|
+
import { CadNode } from '../../../packages/rendering';
|
|
10
|
+
import { CogniteClient } from '@cognite/sdk';
|
|
11
|
+
/**
|
|
12
|
+
* Helper for {@link RevealManager} for creating a uniform interface for
|
|
13
|
+
* working with instances that fetch models from CDF or instances that fetch
|
|
14
|
+
* models from local storage (i.e. in development/debugging).
|
|
15
|
+
*/
|
|
16
|
+
export declare class RevealManagerHelper {
|
|
17
|
+
private readonly _revealManager;
|
|
18
|
+
addCadModel: (model: AddModelOptions) => Promise<CadNode>;
|
|
19
|
+
addPointCloudModel: (model: AddModelOptions) => Promise<PointCloudNode>;
|
|
20
|
+
private constructor();
|
|
21
|
+
private constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Create helper for RevealManager that loads models from local storage. This is only
|
|
24
|
+
* meant for use in debugging and development.
|
|
25
|
+
* @param renderer
|
|
26
|
+
* @param scene
|
|
27
|
+
* @param revealOptions
|
|
28
|
+
*/
|
|
29
|
+
static createLocalHelper(renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions: RevealOptions): RevealManagerHelper;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a helper for RevealManager that loads models from CDF.
|
|
32
|
+
* @param renderer
|
|
33
|
+
* @param scene
|
|
34
|
+
* @param revealOptions
|
|
35
|
+
* @param sdkClient
|
|
36
|
+
*/
|
|
37
|
+
static createCdfHelper(renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions: RevealOptions, sdkClient: CogniteClient): RevealManagerHelper;
|
|
38
|
+
static createCustomDataSourceHelper(renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions: RevealOptions, dataSource: DataSource): RevealManagerHelper;
|
|
39
|
+
get revealManager(): RevealManager;
|
|
40
|
+
/**
|
|
41
|
+
* Adds a local CAD model.
|
|
42
|
+
* @param model
|
|
43
|
+
* @param revealManager
|
|
44
|
+
*/
|
|
45
|
+
private static addLocalCadModel;
|
|
46
|
+
/**
|
|
47
|
+
* Adds a CDF hosted CAD model.
|
|
48
|
+
* @param model
|
|
49
|
+
* @param revealManager
|
|
50
|
+
*/
|
|
51
|
+
private static addCdfCadModel;
|
|
52
|
+
private static addLocalPointCloudModel;
|
|
53
|
+
/**
|
|
54
|
+
* Add a CDF hosted point cloud model.
|
|
55
|
+
* @param model
|
|
56
|
+
* @param revealManager
|
|
57
|
+
*/
|
|
58
|
+
private static addCdfPointCloudModel;
|
|
59
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright 2021 Cognite AS
|
|
3
|
-
*/
|
|
4
|
-
import * as THREE from 'three';
|
|
5
|
-
export declare type Corner = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
|
|
6
|
-
export declare class Spinner {
|
|
7
|
-
private static readonly stylesId;
|
|
8
|
-
private static readonly classnames;
|
|
9
|
-
private static readonly titles;
|
|
10
|
-
private _loading;
|
|
11
|
-
private static loadStyles;
|
|
12
|
-
private readonly el;
|
|
13
|
-
constructor(parent: HTMLElement);
|
|
14
|
-
set placement(placement: Corner);
|
|
15
|
-
set opacity(fractionOpacity: number);
|
|
16
|
-
get loading(): boolean;
|
|
17
|
-
set loading(loadingState: boolean);
|
|
18
|
-
/**
|
|
19
|
-
* Pass background cover of the viewer to adjust Logo color
|
|
20
|
-
* @param color
|
|
21
|
-
* @param color.r 0..1 red
|
|
22
|
-
* @param color.g 0..1 green
|
|
23
|
-
* @param color.b 0..1 blue
|
|
24
|
-
*/
|
|
25
|
-
updateBackgroundColor(color: Pick<THREE.Color, 'getHSL'>): void;
|
|
26
|
-
dispose(): void;
|
|
27
|
-
}
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 Cognite AS
|
|
3
|
+
*/
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
export declare type Corner = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
|
|
6
|
+
export declare class Spinner {
|
|
7
|
+
private static readonly stylesId;
|
|
8
|
+
private static readonly classnames;
|
|
9
|
+
private static readonly titles;
|
|
10
|
+
private _loading;
|
|
11
|
+
private static loadStyles;
|
|
12
|
+
private readonly el;
|
|
13
|
+
constructor(parent: HTMLElement);
|
|
14
|
+
set placement(placement: Corner);
|
|
15
|
+
set opacity(fractionOpacity: number);
|
|
16
|
+
get loading(): boolean;
|
|
17
|
+
set loading(loadingState: boolean);
|
|
18
|
+
/**
|
|
19
|
+
* Pass background cover of the viewer to adjust Logo color
|
|
20
|
+
* @param color
|
|
21
|
+
* @param color.r 0..1 red
|
|
22
|
+
* @param color.g 0..1 green
|
|
23
|
+
* @param color.b 0..1 blue
|
|
24
|
+
*/
|
|
25
|
+
updateBackgroundColor(color: Pick<THREE.Color, 'getHSL'>): void;
|
|
26
|
+
dispose(): void;
|
|
27
|
+
}
|
|
@@ -1,37 +1,49 @@
|
|
|
1
|
-
import { Cognite3DViewer } from '../public/migration/Cognite3DViewer';
|
|
2
|
-
import { NodeAppearance } from '../../../packages/cad-styling';
|
|
3
|
-
import { CogniteClient } from '@cognite/sdk';
|
|
4
|
-
export declare type ViewerState = {
|
|
5
|
-
camera
|
|
6
|
-
position: {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
z: number;
|
|
10
|
-
};
|
|
11
|
-
target: {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
z: number;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
models
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
import { Cognite3DViewer } from '../public/migration/Cognite3DViewer';
|
|
2
|
+
import { NodeAppearance } from '../../../packages/cad-styling';
|
|
3
|
+
import { CogniteClient } from '@cognite/sdk';
|
|
4
|
+
export declare type ViewerState = {
|
|
5
|
+
camera?: {
|
|
6
|
+
position: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
z: number;
|
|
10
|
+
};
|
|
11
|
+
target: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
z: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
models?: ModelState[];
|
|
18
|
+
clippingPlanes?: ClippingPlanesState[];
|
|
19
|
+
};
|
|
20
|
+
export declare type ClippingPlanesState = {
|
|
21
|
+
nx: number;
|
|
22
|
+
ny: number;
|
|
23
|
+
nz: number;
|
|
24
|
+
constant: number;
|
|
25
|
+
};
|
|
26
|
+
export declare type ModelState = {
|
|
27
|
+
defaultNodeAppearance: NodeAppearance;
|
|
28
|
+
modelId: number;
|
|
29
|
+
revisionId: number;
|
|
30
|
+
styledSets: {
|
|
31
|
+
token: string;
|
|
32
|
+
state: any;
|
|
33
|
+
options?: any;
|
|
34
|
+
appearance: NodeAppearance;
|
|
35
|
+
}[];
|
|
36
|
+
};
|
|
37
|
+
export declare class ViewStateHelper {
|
|
38
|
+
private readonly _cameraManager;
|
|
39
|
+
private readonly _viewer;
|
|
40
|
+
private readonly _cdfClient;
|
|
41
|
+
constructor(viewer: Cognite3DViewer, cdfClient: CogniteClient);
|
|
42
|
+
getCurrentState(): ViewerState;
|
|
43
|
+
setState(viewerState: ViewerState): Promise<void>;
|
|
44
|
+
private getModelsState;
|
|
45
|
+
private getClippingPlanesState;
|
|
46
|
+
private setCameraFromState;
|
|
47
|
+
private setModelState;
|
|
48
|
+
private setClippingPlanesState;
|
|
49
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright 2021 Cognite AS
|
|
3
|
-
*/
|
|
4
|
-
export { worldToViewportCoordinates, worldToNormalizedViewportCoordinates } from '
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export { LoadingState } from '../../../packages/cad-geometry-loaders';
|
|
8
|
-
export { LocalModelIdentifier, CdfModelIdentifier } from '../../../packages/modeldata-api';
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 Cognite AS
|
|
3
|
+
*/
|
|
4
|
+
export { assertNever, EventTrigger, worldToViewportCoordinates, worldToNormalizedViewportCoordinates } from '../../../packages/utilities';
|
|
5
|
+
export { LoadingState } from '../../../packages/model-base';
|
|
6
|
+
export { LocalModelIdentifier, CdfModelIdentifier } from '../../../packages/modeldata-api';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright 2021 Cognite AS
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Retrieves the property type of a single property of a type.
|
|
6
|
-
*/
|
|
7
|
-
export declare type PropType<TObj, TProp extends keyof TObj> = TObj[TProp];
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 Cognite AS
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves the property type of a single property of a type.
|
|
6
|
+
*/
|
|
7
|
+
export declare type PropType<TObj, TProp extends keyof TObj> = TObj[TProp];
|
package/core/utilities.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright 2021 Cognite AS
|
|
3
|
-
*/
|
|
4
|
-
export * from './src/utilities';
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 Cognite AS
|
|
3
|
+
*/
|
|
4
|
+
export * from './src/utilities';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright 2021 Cognite AS
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @module @cognite/reveal/extensions/datasource
|
|
6
|
-
*/
|
|
7
|
-
export { DataSource } from '../packages/data-source';
|
|
8
|
-
export { NodesApiClient } from '../packages/nodes-api';
|
|
9
|
-
export { ModelIdentifier, CdfModelIdentifier, ModelMetadataProvider, ModelDataProvider, BlobOutputMetadata, File3dFormat } from '../packages/modeldata-api';
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 Cognite AS
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @module @cognite/reveal/extensions/datasource
|
|
6
|
+
*/
|
|
7
|
+
export { DataSource } from '../packages/data-source';
|
|
8
|
+
export { NodesApiClient } from '../packages/nodes-api';
|
|
9
|
+
export { ModelIdentifier, CdfModelIdentifier, ModelMetadataProvider, ModelDataProvider, BlobOutputMetadata, File3dFormat } from '../packages/modeldata-api';
|
package/extensions/datasource.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var
|
|
1
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="https://apps-cdn.cogniteapp.com/@cognite/reveal-parser-worker/1.3.0/",r(r.s=70)}({0:function(t,e){t.exports=require("three")},19:function(t,e){t.exports=require("@cognite/sdk-core")},6:function(t,e,r){"use strict";r.d(e,"a",(function(){return n})),r.d(e,"b",(function(){return o})),r.d(e,"c",(function(){return u})),r.d(e,"e",(function(){return f})),r.d(e,"f",(function(){return h})),r.d(e,"g",(function(){return m})),r.d(e,"d",(function(){return i}));class n{constructor(t){this.client=t,this.authenticationPromise=t.authenticate()}get headers(){return this.client.getDefaultRequestHeaders()}async getBinaryFile(t,e){const r=`${t}/${e}`,n={...this.client.getDefaultRequestHeaders(),Accept:"*/*"};return(await this.fetchWithRetry(r,{headers:n,method:"GET"}).catch(t=>{throw Error("Could not download binary file")})).arrayBuffer()}async getJsonFile(t,e){return(await this.client.get(`${t}/${e}`).catch(t=>{throw Error("Could not download Json file")})).data}async fetchWithRetry(t,e,r=3){let n;for(let o=0;o<r;o++)try{await this.authenticationPromise;const r=await fetch(t,e);if(401===r.status){this.authenticationPromise=this.client.authenticate();continue}return r}catch(t){void 0!==n&&(n=t)}throw n}}class o{constructor(t,e){this.revealInternalId=Symbol(`${t}/${e}`),this.modelId=t,this.revisionId=e}toString(){return`${o.name} (${String(this.revealInternalId)})`}}var i,a=r(0);
|
|
2
2
|
/*!
|
|
3
3
|
* Copyright 2021 Cognite AS
|
|
4
4
|
*/!function(t){t.EptPointCloud="ept-pointcloud",t.RevealCadModel="reveal-directory",t.GltfCadModel="gltf-directory",t.AnyFormat="all-outputs"}(i||(i={}));
|
|
5
5
|
/*!
|
|
6
6
|
* Copyright 2021 Cognite AS
|
|
7
7
|
*/
|
|
8
|
-
const s=(new a.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function c(t,e){switch(e){case i.RevealCadModel:
|
|
8
|
+
const s=(new a.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function c(t,e){switch(e){case i.RevealCadModel:case i.GltfCadModel:t.premultiply(s);break;case i.EptPointCloud:break;default:throw new Error("Unknown model format '"+e)}}
|
|
9
9
|
/*!
|
|
10
10
|
* Copyright 2021 Cognite AS
|
|
11
|
-
*/class u{constructor(t){this._client=t}async getModelMatrix(t,e){if(!(t instanceof
|
|
12
|
-
/*!
|
|
13
|
-
* Copyright 2021 Cognite AS
|
|
14
|
-
*/var l=r(20);
|
|
11
|
+
*/class u{constructor(t){this._client=t}async getModelMatrix(t,e){if(!(t instanceof o))throw new Error(`Model must be a ${o.name}, but got ${t.toString()}`);const{modelId:r,revisionId:n}=t,i=await this._client.revisions3D.retrieve(r,n),s=new a.Matrix4;return i.rotation&&s.makeRotationFromEuler(new a.Euler(...i.rotation)),c(s,e),s}async getModelCamera(t){if(!(t instanceof o))throw new Error(`Model must be a ${o.name}, but got ${t.toString()}`);const{modelId:e,revisionId:r}=t,n=await this._client.revisions3D.retrieve(e,r);if(n.camera&&n.camera.position&&n.camera.target){const{position:t,target:e}=n.camera;return{position:new a.Vector3(t[0],t[1],t[2]),target:new a.Vector3(e[0],e[1],e[2])}}}async getModelUri(t,e){if(!(t instanceof o))throw new Error(`Model must be a ${o.name}, but got ${t.toString()}`);return`${this._client.getBaseUrl()}${this.getRequestPath(e.blobId)}`}async getModelOutputs(t){if(!(t instanceof o))throw new Error(`Model must be a ${o.name}, but got ${t.toString()}`);const{modelId:e,revisionId:r}=t,n=`/api/v1/projects/${this._client.project}/3d/models/${e}/revisions/${r}/outputs`,a=await this._client.get(n,{params:{format:i.AnyFormat}});if(200===a.status)return a.data.items.filter(t=>Object.values(i).includes(t.format));throw new Error(`Unexpected response ${a.status} (payload: '${a.data})`)}getRequestPath(t){return`/api/v1/projects/${this._client.project}/3d/files/${t}`}}var l=r(19);
|
|
15
12
|
/*!
|
|
16
13
|
* Copyright 2021 Cognite AS
|
|
17
14
|
*/async function d(t){const e=await fetch(t);if(!e.ok){const t={};throw e.headers.forEach((e,r)=>{t[e]=r}),new l.HttpError(e.status,e.body,t)}return e}
|
|
@@ -23,8 +20,8 @@ const s=(new a.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function c(t,e){sw
|
|
|
23
20
|
*/class h{constructor(t){this.revealInternalId=Symbol(t),this.localPath=t}toString(){return`${h.name} (${this.localPath})`}}
|
|
24
21
|
/*!
|
|
25
22
|
* Copyright 2021 Cognite AS
|
|
26
|
-
*/class m{getModelUri(t){if(!(t instanceof h))throw new Error(`Model must be a ${h.name}, but got ${t.toString()}`);return Promise.resolve(`${location.origin}/${t.localPath}`)}async getModelMatrix(t){if(!(t instanceof h))throw new Error(`Model must be a ${h.name}, but got ${t.toString()}`);const e=new a.Matrix4;return c(e,i.RevealCadModel),e}getModelCamera(t){if(!(t instanceof h))throw new Error(`Model must be a ${h.name}, but got ${t.toString()}`);return Promise.resolve(void 0)}async getModelOutputs(t){var e;const r=await this.getModelUri(t),
|
|
23
|
+
*/class m{getModelUri(t){if(!(t instanceof h))throw new Error(`Model must be a ${h.name}, but got ${t.toString()}`);return Promise.resolve(`${location.origin}/${t.localPath}`)}async getModelMatrix(t){if(!(t instanceof h))throw new Error(`Model must be a ${h.name}, but got ${t.toString()}`);const e=new a.Matrix4;return c(e,i.RevealCadModel),e}getModelCamera(t){if(!(t instanceof h))throw new Error(`Model must be a ${h.name}, but got ${t.toString()}`);return Promise.resolve(void 0)}async getModelOutputs(t){var e;const r=await this.getModelUri(t),n=null!==(e=await async function(t){let e;try{e=(await(await d(t+"/scene.json")).json()).version}catch(t){return}switch(e){case 8:return Promise.resolve({blobId:-1,format:i.RevealCadModel,version:8});case 9:return Promise.resolve({blobId:-1,format:i.GltfCadModel,version:9});default:return}}(r))&&void 0!==e?e:await async function(t){let e;try{e=await(await d(t+"/ept.json")).json()}catch(t){return}return e?Promise.resolve({blobId:-1,format:i.EptPointCloud,version:-1}):void 0}(r);if(n)return[n];throw new Error("Only point cloud or CAD models (version 8 and 9) are supported)")}}
|
|
27
24
|
/*!
|
|
28
25
|
* Copyright 2021 Cognite AS
|
|
29
|
-
*/},
|
|
26
|
+
*/},70:function(t,e,r){"use strict";r.r(e);var n=r(6);r.d(e,"CdfModelIdentifier",(function(){return n.b})),r.d(e,"File3dFormat",(function(){return n.d}))}})}));
|
|
30
27
|
//# sourceMappingURL=datasource.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///external \"three\"","webpack:///external \"@cognite/sdk-core\"","webpack:///./packages/modeldata-api/src/CdfModelDataProvider.ts","webpack:///./packages/modeldata-api/src/CdfModelIdentifier.ts","webpack:///./packages/modeldata-api/src/types.ts","webpack:///./packages/modeldata-api/src/applyDefaultModelTransformation.ts","webpack:///./packages/modeldata-api/src/CdfModelMetadataProvider.ts","webpack:///./packages/modeldata-api/src/utilities.ts","webpack:///./packages/modeldata-api/src/LocalModelDataProvider.ts","webpack:///./packages/modeldata-api/src/LocalModelIdentifier.ts","webpack:///./packages/modeldata-api/src/LocalModelMetadataProvider.ts","webpack:///./extensions/datasource.ts"],"names":["root","factory","exports","module","define","amd","a","i","self","this","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","require","CdfModelDataProvider","client","authenticationPromise","authenticate","getDefaultRequestHeaders","baseUrl","fileName","url","headers","Accept","fetchWithRetry","method","catch","_err","Error","arrayBuffer","data","input","options","retries","error","response","fetch","status","err","undefined","CdfModelIdentifier","modelId","revisionId","revealInternalId","String","File3dFormat","cadFromCdfToThreeMatrix","set","applyDefaultModelTransformation","matrix","format","RevealCadModel","premultiply","GltfCadModel","EptPointCloud","_client","modelIdentifier","toString","model","revisions3D","retrieve","modelMatrix","rotation","makeRotationFromEuler","camera","position","target","formatMetadata","getBaseUrl","getRequestPath","blobId","project","params","AnyFormat","items","filter","output","values","includes","directoryId","async","fetchWithStatusCheck","ok","forEach","body","json","LocalModelIdentifier","localPath","Promise","resolve","location","origin","modelUri","getModelUri","version","getCadOutput","scene","getPointCloudOutput"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,IAPxE,CASoB,oBAATC,KAAuBA,KAAOC,MAAO,WAChD,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUV,QAGnC,IAAIC,EAASO,EAAiBE,GAAY,CACzCL,EAAGK,EACHC,GAAG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AM,mBAAmB0D,EAAqBlG,iBAAiBoE,EAAgBC,cAE3F,OAAO+B,QAAQC,QAAQ,GAAGC,SAASC,UAAUnC,EAAgB+B,aAG/D,qBAAqB/B,GACnB,KAAMA,aAA2B8B,GAC/B,MAAM,IAAI1D,MAAM,mBAAmB0D,EAAqBlG,iBAAiBoE,EAAgBC,cAG3F,MAAMR,EAAS,IAAI,UAEnB,OADAD,EAAgCC,EAAQJ,EAAaM,gBAC9CF,EAGT,eACEO,GAEA,KAAMA,aAA2B8B,GAC/B,MAAM,IAAI1D,MAAM,mBAAmB0D,EAAqBlG,iBAAiBoE,EAAgBC,cAG3F,OAAO+B,QAAQC,aAAQlD,GAGzB,sBAAsBiB,G,MACpB,MAAMoC,QAAiBlH,KAAKmH,YAAYrC,GAElCoB,EAAuC,QAA7B,QAQhBI,eAA4BY,GAC1B,IAAIE,EAEJ,IACEA,eAAwBb,EAAqBW,EAAW,gBAAgBP,QAAQS,QAChF,MAAO5D,GACP,OAEF,OAAQ4D,GACN,KAAK,EACH,OAAON,QAAQC,QAAQ,CACrBnB,QAAS,EACTpB,OAAQL,EAAaM,eACrB2C,QAAS,IAEb,KAAK,EACH,OAAON,QAAQC,QAAQ,CACrBnB,QAAS,EACTpB,OAAQL,EAAaQ,aACrByC,QAAS,IAEb,QACE,QA9BgBC,CAAaH,UAAU,cAkC7CZ,eAAmCY,GACjC,IAAII,EAEJ,IACEA,cAAqBf,EAAqBW,EAAW,cAAcP,OACnE,MAAOnD,GACP,OAGF,OAAI8D,EACKR,QAAQC,QAAQ,CACrBnB,QAAS,EACTpB,OAAQL,EAAaS,cACrBwC,SAAU,SAGZ,EAlDoDG,CAAoBL,GAE5E,GAAIhB,EACF,MAAO,CAACA,GAGV,MAAM,IAAIhD,MAAM;;;qCCjDpB","file":"extensions/datasource.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})((typeof self !== 'undefined' ? self : this), function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"https://apps-cdn.cogniteapp.com/@cognite/reveal-parser-worker/1.3.0/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 65);\n","module.exports = require(\"three\");","module.exports = require(\"@cognite/sdk-core\");","/*!\n * Copyright 2021 Cognite AS\n */\nimport { CogniteClient, HttpHeaders } from '@cognite/sdk';\n\nimport { ModelDataProvider } from './types';\n\n/**\n * Provides 3D V2 specific extensions for the standard CogniteClient used by Reveal.\n */\nexport class CdfModelDataProvider implements ModelDataProvider {\n private readonly client: CogniteClient;\n private authenticationPromise: Promise<boolean>;\n\n constructor(client: CogniteClient) {\n this.client = client;\n this.authenticationPromise = client.authenticate();\n }\n\n get headers(): HttpHeaders {\n return this.client.getDefaultRequestHeaders();\n }\n\n public async getBinaryFile(baseUrl: string, fileName: string): Promise<ArrayBuffer> {\n const url = `${baseUrl}/${fileName}`;\n const headers = {\n ...this.client.getDefaultRequestHeaders(),\n Accept: '*/*'\n };\n\n const response = await this.fetchWithRetry(url, { headers, method: 'GET' }).catch(_err => {\n throw Error('Could not download binary file');\n });\n return response.arrayBuffer();\n }\n\n async getJsonFile(baseUrl: string, fileName: string): Promise<any> {\n const response = await this.client.get(`${baseUrl}/${fileName}`).catch(_err => {\n throw Error('Could not download Json file');\n });\n return response.data;\n }\n\n private async fetchWithRetry(input: RequestInfo, options: RequestInit, retries: number = 3) {\n let error: Error | undefined;\n for (let i = 0; i < retries; i++) {\n try {\n await this.authenticationPromise;\n\n const response = await fetch(input, options);\n\n // Authentication error\n if (response.status === 401) {\n this.authenticationPromise = this.client.authenticate();\n continue;\n }\n\n return response;\n } catch (err) {\n // Keep first error only\n if (error !== undefined) {\n error = err as Error;\n }\n }\n }\n throw error;\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\nimport { ModelIdentifier } from '..';\n\n/**\n * Identifies a 3D model stored in CDF by the combination of a modelId, a revisionId\n * and a format.\n */\nexport class CdfModelIdentifier implements ModelIdentifier {\n readonly revealInternalId: symbol;\n\n readonly modelId: number;\n readonly revisionId: number;\n\n constructor(modelId: number, revisionId: number) {\n this.revealInternalId = Symbol(`${modelId}/${revisionId}`);\n this.modelId = modelId;\n this.revisionId = revisionId;\n }\n\n public toString(): string {\n return `${CdfModelIdentifier.name} (${String(this.revealInternalId)})`;\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport { HttpHeaders } from '@cognite/sdk-core';\nexport interface JsonFileProvider {\n getJsonFile(baseUrl: string, fileName: string): Promise<any>;\n}\n\nexport interface BinaryFileProvider {\n getBinaryFile(baseUrl: string, fileName: string): Promise<ArrayBuffer>;\n}\n\n/**\n * Provides data for 3D models.\n */\nexport interface ModelDataProvider extends HttpHeadersProvider, JsonFileProvider, BinaryFileProvider {\n /**\n * Download and parse a JSON file and return the resulting struct.\n * @param baseUrl Base URL of the model.\n * @param fileName Filename of JSON file.\n */\n getJsonFile(baseUrl: string, fileName: string): Promise<any>;\n /**\n * Downloads a binary blob.\n * @param baseUrl Base URL of the model.\n * @param fileName Filename of binary file.\n */\n getBinaryFile(baseUrl: string, fileName: string): Promise<ArrayBuffer>;\n}\n\nexport interface HttpHeadersProvider {\n readonly headers: HttpHeaders;\n}\n\nexport enum File3dFormat {\n EptPointCloud = 'ept-pointcloud',\n /**\n * V8 models only due to bug for version checks in Reveal <3.0\n */\n RevealCadModel = 'reveal-directory',\n /**\n * Reveal v9 and above (GLTF based output)\n */\n GltfCadModel = 'gltf-directory',\n AnyFormat = 'all-outputs'\n}\n\nexport interface BlobOutputMetadata {\n blobId: number;\n format: File3dFormat | string;\n version: number;\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport * as THREE from 'three';\n\nimport { File3dFormat } from './types';\n\n// The below is equal to new THREE.Matrix4().makeRotationFromEuler(new THREE.Euler(-Math.PI / 2, 0, 0));\nconst cadFromCdfToThreeMatrix = new THREE.Matrix4().set(1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1);\n\nexport function applyDefaultModelTransformation(matrix: THREE.Matrix4, format: File3dFormat | string): void {\n switch (format) {\n case File3dFormat.RevealCadModel:\n matrix.premultiply(cadFromCdfToThreeMatrix);\n break;\n\n case File3dFormat.RevealCadModel:\n case File3dFormat.GltfCadModel:\n matrix.premultiply(cadFromCdfToThreeMatrix);\n break;\n\n case File3dFormat.EptPointCloud:\n // No action, identity transform\n break;\n\n default:\n throw new Error(`Unknown model format '${format}`);\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\nimport * as THREE from 'three';\nimport { BlobOutputMetadata, File3dFormat } from './types';\nimport { ModelMetadataProvider } from './ModelMetadataProvider';\n\nimport { applyDefaultModelTransformation } from './applyDefaultModelTransformation';\n\nimport { CogniteClient } from '@cognite/sdk';\nimport { ItemsResponse } from '@cognite/sdk-core';\nimport { ModelIdentifier } from './ModelIdentifier';\nimport { CdfModelIdentifier } from './CdfModelIdentifier';\n\n// TODO 2020-06-25 larsmoa: Extend CogniteClient.files3d.retrieve() to support subpath instead of\n// using URLs directly. Also add support for listing outputs in the SDK.\nexport class CdfModelMetadataProvider implements ModelMetadataProvider {\n private readonly _client: CogniteClient;\n\n constructor(client: CogniteClient) {\n this._client = client;\n }\n\n public async getModelMatrix(modelIdentifier: ModelIdentifier, format: File3dFormat): Promise<THREE.Matrix4> {\n if (!(modelIdentifier instanceof CdfModelIdentifier)) {\n throw new Error(`Model must be a ${CdfModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n const { modelId, revisionId } = modelIdentifier;\n const model = await this._client.revisions3D.retrieve(modelId, revisionId);\n\n const modelMatrix = new THREE.Matrix4();\n if (model.rotation) {\n modelMatrix.makeRotationFromEuler(new THREE.Euler(...model.rotation));\n }\n applyDefaultModelTransformation(modelMatrix, format);\n return modelMatrix;\n }\n\n public async getModelCamera(\n modelIdentifier: ModelIdentifier\n ): Promise<{ position: THREE.Vector3; target: THREE.Vector3 } | undefined> {\n if (!(modelIdentifier instanceof CdfModelIdentifier)) {\n throw new Error(`Model must be a ${CdfModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n const { modelId, revisionId } = modelIdentifier;\n const model = await this._client.revisions3D.retrieve(modelId, revisionId);\n if (model.camera && model.camera.position && model.camera.target) {\n const { position, target } = model.camera;\n return {\n position: new THREE.Vector3(position[0], position[1], position[2]),\n target: new THREE.Vector3(target[0], target[1], target[2])\n };\n }\n return undefined;\n }\n\n public async getModelUri(modelIdentifier: ModelIdentifier, formatMetadata: BlobOutputMetadata): Promise<string> {\n if (!(modelIdentifier instanceof CdfModelIdentifier)) {\n throw new Error(`Model must be a ${CdfModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n return `${this._client.getBaseUrl()}${this.getRequestPath(formatMetadata.blobId)}`;\n }\n\n public async getModelOutputs(modelIdentifier: ModelIdentifier): Promise<BlobOutputMetadata[]> {\n if (!(modelIdentifier instanceof CdfModelIdentifier)) {\n throw new Error(`Model must be a ${CdfModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n const { modelId, revisionId } = modelIdentifier;\n\n const url = `/api/v1/projects/${this._client.project}/3d/models/${modelId}/revisions/${revisionId}/outputs`;\n\n const response = await this._client.get<ItemsResponse<BlobOutputMetadata>>(url, {\n params: { format: File3dFormat.AnyFormat }\n });\n\n if (response.status === 200) {\n return response.data.items.filter(output => Object.values<string>(File3dFormat).includes(output.format));\n }\n\n throw new Error(`Unexpected response ${response.status} (payload: '${response.data})`);\n }\n\n private getRequestPath(directoryId: number): string {\n return `/api/v1/projects/${this._client.project}/3d/files/${directoryId}`;\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport { Versioned3DFile } from '@cognite/sdk';\n\n// To avoid direct dependency on @cognite/sdk we use sdk-core here for HttpError.\n// that's why it's avoided https://github.com/cognitedata/cdf-hub/pull/687/files#r489204315\nimport { HttpError } from '@cognite/sdk-core';\n\nexport const supportedVersions = [8];\n\nexport function getNewestVersionedFile(files: Versioned3DFile[]): Versioned3DFile {\n return files\n .filter(file => supportedVersions.includes(file.version))\n .reduce((newestFile, file) => (file.version > newestFile.version ? file : newestFile), {\n fileId: -1,\n version: -1\n });\n}\n\nexport async function fetchWithStatusCheck(url: string): Promise<Response> {\n const response = await fetch(url);\n if (!response.ok) {\n const headers: { [key: string]: string } = {};\n response.headers.forEach((key, value) => {\n headers[key] = value;\n });\n throw new HttpError(response.status, response.body, headers);\n }\n return response;\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport { HttpHeaders } from '@cognite/sdk-core';\nimport { ModelDataProvider } from './types';\nimport { fetchWithStatusCheck } from './utilities';\n\nexport class LocalModelDataProvider implements ModelDataProvider {\n get headers(): HttpHeaders {\n return {};\n }\n\n async getBinaryFile(baseUrl: string, fileName: string): Promise<ArrayBuffer> {\n const response = await fetchWithStatusCheck(`${baseUrl}/${fileName}`);\n return response.arrayBuffer();\n }\n\n async getJsonFile(baseUrl: string, fileName: string): Promise<any> {\n const response = await fetchWithStatusCheck(`${baseUrl}/${fileName}`);\n return response.json();\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport { ModelIdentifier } from './ModelIdentifier';\n\n/**\n * Identifies a 3D model by a URL. This implementation is used for testing\n * purposes.\n */\nexport class LocalModelIdentifier implements ModelIdentifier {\n readonly revealInternalId: symbol;\n readonly localPath: string;\n\n constructor(localPath: string) {\n this.revealInternalId = Symbol(localPath);\n this.localPath = localPath;\n }\n\n public toString(): string {\n return `${LocalModelIdentifier.name} (${this.localPath})`;\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\nimport * as THREE from 'three';\n\nimport { applyDefaultModelTransformation } from './applyDefaultModelTransformation';\nimport { LocalModelIdentifier } from './LocalModelIdentifier';\nimport { ModelIdentifier } from './ModelIdentifier';\nimport { ModelMetadataProvider } from './ModelMetadataProvider';\nimport { BlobOutputMetadata, File3dFormat } from './types';\nimport { fetchWithStatusCheck } from './utilities';\n\nexport class LocalModelMetadataProvider implements ModelMetadataProvider {\n getModelUri(modelIdentifier: ModelIdentifier): Promise<string> {\n if (!(modelIdentifier instanceof LocalModelIdentifier)) {\n throw new Error(`Model must be a ${LocalModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n return Promise.resolve(`${location.origin}/${modelIdentifier.localPath}`);\n }\n\n async getModelMatrix(modelIdentifier: ModelIdentifier): Promise<THREE.Matrix4> {\n if (!(modelIdentifier instanceof LocalModelIdentifier)) {\n throw new Error(`Model must be a ${LocalModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n const matrix = new THREE.Matrix4();\n applyDefaultModelTransformation(matrix, File3dFormat.RevealCadModel);\n return matrix;\n }\n\n getModelCamera(\n modelIdentifier: ModelIdentifier\n ): Promise<{ position: THREE.Vector3; target: THREE.Vector3 } | undefined> {\n if (!(modelIdentifier instanceof LocalModelIdentifier)) {\n throw new Error(`Model must be a ${LocalModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n return Promise.resolve(undefined);\n }\n\n async getModelOutputs(modelIdentifier: ModelIdentifier): Promise<BlobOutputMetadata[]> {\n const modelUri = await this.getModelUri(modelIdentifier);\n\n const output = (await getCadOutput(modelUri)) ?? (await getPointCloudOutput(modelUri));\n\n if (output) {\n return [output];\n }\n\n throw new Error(`Only point cloud or CAD models (version 8 and 9) are supported)`);\n\n async function getCadOutput(modelUri: string): Promise<BlobOutputMetadata | undefined> {\n let version: number;\n\n try {\n version = (await (await fetchWithStatusCheck(modelUri + '/scene.json')).json()).version;\n } catch (error) {\n return undefined;\n }\n switch (version) {\n case 8:\n return Promise.resolve({\n blobId: -1,\n format: File3dFormat.RevealCadModel,\n version: 8\n });\n case 9:\n return Promise.resolve({\n blobId: -1,\n format: File3dFormat.GltfCadModel,\n version: 9\n });\n default:\n return undefined;\n }\n }\n\n async function getPointCloudOutput(modelUri: string): Promise<BlobOutputMetadata | undefined> {\n let scene: any;\n\n try {\n scene = await (await fetchWithStatusCheck(modelUri + '/ept.json')).json();\n } catch (error) {\n return undefined;\n }\n\n if (scene) {\n return Promise.resolve({\n blobId: -1,\n format: File3dFormat.EptPointCloud,\n version: -1\n });\n } else {\n return undefined;\n }\n }\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\n/**\n * @module @cognite/reveal/extensions/datasource\n */\n\nexport { DataSource } from '../packages/data-source';\nexport { NodesApiClient } from '../packages/nodes-api';\nexport {\n ModelIdentifier,\n CdfModelIdentifier,\n ModelMetadataProvider,\n ModelDataProvider,\n BlobOutputMetadata,\n File3dFormat\n} from '../packages/modeldata-api';\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///external \"three\"","webpack:///external \"@cognite/sdk-core\"","webpack:///./packages/modeldata-api/src/CdfModelDataProvider.ts","webpack:///./packages/modeldata-api/src/CdfModelIdentifier.ts","webpack:///./packages/modeldata-api/src/types.ts","webpack:///./packages/modeldata-api/src/applyDefaultModelTransformation.ts","webpack:///./packages/modeldata-api/src/CdfModelMetadataProvider.ts","webpack:///./packages/modeldata-api/src/utilities.ts","webpack:///./packages/modeldata-api/src/LocalModelDataProvider.ts","webpack:///./packages/modeldata-api/src/LocalModelIdentifier.ts","webpack:///./packages/modeldata-api/src/LocalModelMetadataProvider.ts","webpack:///./extensions/datasource.ts"],"names":["root","factory","exports","module","define","amd","a","i","self","this","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","require","CdfModelDataProvider","client","authenticationPromise","authenticate","getDefaultRequestHeaders","baseUrl","fileName","url","headers","Accept","fetchWithRetry","method","catch","_err","Error","arrayBuffer","data","input","options","retries","error","response","fetch","status","err","undefined","CdfModelIdentifier","modelId","revisionId","revealInternalId","String","File3dFormat","cadFromCdfToThreeMatrix","set","applyDefaultModelTransformation","matrix","format","RevealCadModel","GltfCadModel","premultiply","EptPointCloud","_client","modelIdentifier","toString","model","revisions3D","retrieve","modelMatrix","rotation","makeRotationFromEuler","camera","position","target","formatMetadata","getBaseUrl","getRequestPath","blobId","project","params","AnyFormat","items","filter","output","values","includes","directoryId","async","fetchWithStatusCheck","ok","forEach","body","json","LocalModelIdentifier","localPath","Promise","resolve","location","origin","modelUri","getModelUri","version","getCadOutput","scene","getPointCloudOutput"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,IAPxE,CASoB,oBAATC,KAAuBA,KAAOC,MAAO,WAChD,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUV,QAGnC,IAAIC,EAASO,EAAiBE,GAAY,CACzCL,EAAGK,EACHC,GAAG,EACHX,QAAS,IAUV,OANAY,EAAQF,GAAUG,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAASS,GAG/DR,EAAOU,GAA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MAAM,IAAI1D,MAAM,mBAAmB0D,EAAqBlG,iBAAiBoE,EAAgBC,cAG3F,MAAMR,EAAS,IAAI,UAEnB,OADAD,EAAgCC,EAAQJ,EAAaM,gBAC9CF,EAGT,eACEO,GAEA,KAAMA,aAA2B8B,GAC/B,MAAM,IAAI1D,MAAM,mBAAmB0D,EAAqBlG,iBAAiBoE,EAAgBC,cAG3F,OAAO+B,QAAQC,aAAQlD,GAGzB,sBAAsBiB,G,MACpB,MAAMoC,QAAiBlH,KAAKmH,YAAYrC,GAElCoB,EAAuC,QAA7B,QAQhBI,eAA4BY,GAC1B,IAAIE,EAEJ,IACEA,eAAwBb,EAAqBW,EAAW,gBAAgBP,QAAQS,QAChF,MAAO5D,GACP,OAEF,OAAQ4D,GACN,KAAK,EACH,OAAON,QAAQC,QAAQ,CACrBnB,QAAS,EACTpB,OAAQL,EAAaM,eACrB2C,QAAS,IAEb,KAAK,EACH,OAAON,QAAQC,QAAQ,CACrBnB,QAAS,EACTpB,OAAQL,EAAaO,aACrB0C,QAAS,IAEb,QACE,QA9BgBC,CAAaH,UAAU,cAkC7CZ,eAAmCY,GACjC,IAAII,EAEJ,IACEA,cAAqBf,EAAqBW,EAAW,cAAcP,OACnE,MAAOnD,GACP,OAGF,OAAI8D,EACKR,QAAQC,QAAQ,CACrBnB,QAAS,EACTpB,OAAQL,EAAaS,cACrBwC,SAAU,SAGZ,EAlDoDG,CAAoBL,GAE5E,GAAIhB,EACF,MAAO,CAACA,GAGV,MAAM,IAAIhD,MAAM;;;qCCjDpB","file":"extensions/datasource.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})((typeof self !== 'undefined' ? self : this), function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"https://apps-cdn.cogniteapp.com/@cognite/reveal-parser-worker/1.3.0/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 70);\n","module.exports = require(\"three\");","module.exports = require(\"@cognite/sdk-core\");","/*!\n * Copyright 2021 Cognite AS\n */\nimport { CogniteClient, HttpHeaders } from '@cognite/sdk';\n\nimport { ModelDataProvider } from './types';\n\n/**\n * Provides 3D V2 specific extensions for the standard CogniteClient used by Reveal.\n */\nexport class CdfModelDataProvider implements ModelDataProvider {\n private readonly client: CogniteClient;\n private authenticationPromise: Promise<string | undefined>;\n\n constructor(client: CogniteClient) {\n this.client = client;\n this.authenticationPromise = client.authenticate();\n }\n\n get headers(): HttpHeaders {\n return this.client.getDefaultRequestHeaders();\n }\n\n public async getBinaryFile(baseUrl: string, fileName: string): Promise<ArrayBuffer> {\n const url = `${baseUrl}/${fileName}`;\n const headers = {\n ...this.client.getDefaultRequestHeaders(),\n Accept: '*/*'\n };\n\n const response = await this.fetchWithRetry(url, { headers, method: 'GET' }).catch(_err => {\n throw Error('Could not download binary file');\n });\n return response.arrayBuffer();\n }\n\n async getJsonFile(baseUrl: string, fileName: string): Promise<any> {\n const response = await this.client.get(`${baseUrl}/${fileName}`).catch(_err => {\n throw Error('Could not download Json file');\n });\n return response.data;\n }\n\n private async fetchWithRetry(input: RequestInfo, options: RequestInit, retries: number = 3) {\n let error: Error | undefined;\n for (let i = 0; i < retries; i++) {\n try {\n await this.authenticationPromise;\n\n const response = await fetch(input, options);\n\n // Authentication error\n if (response.status === 401) {\n this.authenticationPromise = this.client.authenticate();\n continue;\n }\n\n return response;\n } catch (err) {\n // Keep first error only\n if (error !== undefined) {\n error = err as Error;\n }\n }\n }\n throw error;\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\nimport { ModelIdentifier } from '..';\n\n/**\n * Identifies a 3D model stored in CDF by the combination of a modelId, a revisionId\n * and a format.\n */\nexport class CdfModelIdentifier implements ModelIdentifier {\n readonly revealInternalId: symbol;\n\n readonly modelId: number;\n readonly revisionId: number;\n\n constructor(modelId: number, revisionId: number) {\n this.revealInternalId = Symbol(`${modelId}/${revisionId}`);\n this.modelId = modelId;\n this.revisionId = revisionId;\n }\n\n public toString(): string {\n return `${CdfModelIdentifier.name} (${String(this.revealInternalId)})`;\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport { HttpHeaders } from '@cognite/sdk-core';\nexport interface JsonFileProvider {\n getJsonFile(baseUrl: string, fileName: string): Promise<any>;\n}\n\nexport interface BinaryFileProvider {\n getBinaryFile(baseUrl: string, fileName: string): Promise<ArrayBuffer>;\n}\n\n/**\n * Provides data for 3D models.\n */\nexport interface ModelDataProvider extends HttpHeadersProvider, JsonFileProvider, BinaryFileProvider {\n /**\n * Download and parse a JSON file and return the resulting struct.\n * @param baseUrl Base URL of the model.\n * @param fileName Filename of JSON file.\n */\n getJsonFile(baseUrl: string, fileName: string): Promise<any>;\n /**\n * Downloads a binary blob.\n * @param baseUrl Base URL of the model.\n * @param fileName Filename of binary file.\n */\n getBinaryFile(baseUrl: string, fileName: string): Promise<ArrayBuffer>;\n}\n\nexport interface HttpHeadersProvider {\n readonly headers: HttpHeaders;\n}\n\nexport enum File3dFormat {\n EptPointCloud = 'ept-pointcloud',\n /**\n * V8 models only due to bug for version checks in Reveal <3.0\n */\n RevealCadModel = 'reveal-directory',\n /**\n * Reveal v9 and above (GLTF based output)\n */\n GltfCadModel = 'gltf-directory',\n AnyFormat = 'all-outputs'\n}\n\nexport interface BlobOutputMetadata {\n blobId: number;\n format: File3dFormat | string;\n version: number;\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport * as THREE from 'three';\n\nimport { File3dFormat } from './types';\n\n// The below is equal to new THREE.Matrix4().makeRotationFromEuler(new THREE.Euler(-Math.PI / 2, 0, 0));\nconst cadFromCdfToThreeMatrix = new THREE.Matrix4().set(1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1);\n\nexport function applyDefaultModelTransformation(matrix: THREE.Matrix4, format: File3dFormat | string): void {\n switch (format) {\n case File3dFormat.RevealCadModel:\n case File3dFormat.GltfCadModel:\n matrix.premultiply(cadFromCdfToThreeMatrix);\n break;\n\n case File3dFormat.EptPointCloud:\n // No action, identity transform\n break;\n\n default:\n throw new Error(`Unknown model format '${format}`);\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\nimport * as THREE from 'three';\nimport { BlobOutputMetadata, File3dFormat } from './types';\nimport { ModelMetadataProvider } from './ModelMetadataProvider';\n\nimport { applyDefaultModelTransformation } from './applyDefaultModelTransformation';\n\nimport { CogniteClient } from '@cognite/sdk';\nimport { ItemsResponse } from '@cognite/sdk-core';\nimport { ModelIdentifier } from './ModelIdentifier';\nimport { CdfModelIdentifier } from './CdfModelIdentifier';\n\n// TODO 2020-06-25 larsmoa: Extend CogniteClient.files3d.retrieve() to support subpath instead of\n// using URLs directly. Also add support for listing outputs in the SDK.\nexport class CdfModelMetadataProvider implements ModelMetadataProvider {\n private readonly _client: CogniteClient;\n\n constructor(client: CogniteClient) {\n this._client = client;\n }\n\n public async getModelMatrix(modelIdentifier: ModelIdentifier, format: File3dFormat): Promise<THREE.Matrix4> {\n if (!(modelIdentifier instanceof CdfModelIdentifier)) {\n throw new Error(`Model must be a ${CdfModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n const { modelId, revisionId } = modelIdentifier;\n const model = await this._client.revisions3D.retrieve(modelId, revisionId);\n\n const modelMatrix = new THREE.Matrix4();\n if (model.rotation) {\n modelMatrix.makeRotationFromEuler(new THREE.Euler(...model.rotation));\n }\n applyDefaultModelTransformation(modelMatrix, format);\n return modelMatrix;\n }\n\n public async getModelCamera(\n modelIdentifier: ModelIdentifier\n ): Promise<{ position: THREE.Vector3; target: THREE.Vector3 } | undefined> {\n if (!(modelIdentifier instanceof CdfModelIdentifier)) {\n throw new Error(`Model must be a ${CdfModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n const { modelId, revisionId } = modelIdentifier;\n const model = await this._client.revisions3D.retrieve(modelId, revisionId);\n if (model.camera && model.camera.position && model.camera.target) {\n const { position, target } = model.camera;\n return {\n position: new THREE.Vector3(position[0], position[1], position[2]),\n target: new THREE.Vector3(target[0], target[1], target[2])\n };\n }\n return undefined;\n }\n\n public async getModelUri(modelIdentifier: ModelIdentifier, formatMetadata: BlobOutputMetadata): Promise<string> {\n if (!(modelIdentifier instanceof CdfModelIdentifier)) {\n throw new Error(`Model must be a ${CdfModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n return `${this._client.getBaseUrl()}${this.getRequestPath(formatMetadata.blobId)}`;\n }\n\n public async getModelOutputs(modelIdentifier: ModelIdentifier): Promise<BlobOutputMetadata[]> {\n if (!(modelIdentifier instanceof CdfModelIdentifier)) {\n throw new Error(`Model must be a ${CdfModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n const { modelId, revisionId } = modelIdentifier;\n\n const url = `/api/v1/projects/${this._client.project}/3d/models/${modelId}/revisions/${revisionId}/outputs`;\n\n const response = await this._client.get<ItemsResponse<BlobOutputMetadata>>(url, {\n params: { format: File3dFormat.AnyFormat }\n });\n\n if (response.status === 200) {\n return response.data.items.filter(output => Object.values<string>(File3dFormat).includes(output.format));\n }\n\n throw new Error(`Unexpected response ${response.status} (payload: '${response.data})`);\n }\n\n private getRequestPath(directoryId: number): string {\n return `/api/v1/projects/${this._client.project}/3d/files/${directoryId}`;\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport { Versioned3DFile } from '@cognite/sdk';\n\n// To avoid direct dependency on @cognite/sdk we use sdk-core here for HttpError.\n// that's why it's avoided https://github.com/cognitedata/cdf-hub/pull/687/files#r489204315\nimport { HttpError } from '@cognite/sdk-core';\n\nexport const supportedVersions = [8];\n\nexport function getNewestVersionedFile(files: Versioned3DFile[]): Versioned3DFile {\n return files\n .filter(file => supportedVersions.includes(file.version))\n .reduce((newestFile, file) => (file.version > newestFile.version ? file : newestFile), {\n fileId: -1,\n version: -1\n });\n}\n\nexport async function fetchWithStatusCheck(url: string): Promise<Response> {\n const response = await fetch(url);\n if (!response.ok) {\n const headers: { [key: string]: string } = {};\n response.headers.forEach((key, value) => {\n headers[key] = value;\n });\n throw new HttpError(response.status, response.body, headers);\n }\n return response;\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport { HttpHeaders } from '@cognite/sdk-core';\nimport { ModelDataProvider } from './types';\nimport { fetchWithStatusCheck } from './utilities';\n\nexport class LocalModelDataProvider implements ModelDataProvider {\n get headers(): HttpHeaders {\n return {};\n }\n\n async getBinaryFile(baseUrl: string, fileName: string): Promise<ArrayBuffer> {\n const response = await fetchWithStatusCheck(`${baseUrl}/${fileName}`);\n return response.arrayBuffer();\n }\n\n async getJsonFile(baseUrl: string, fileName: string): Promise<any> {\n const response = await fetchWithStatusCheck(`${baseUrl}/${fileName}`);\n return response.json();\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport { ModelIdentifier } from './ModelIdentifier';\n\n/**\n * Identifies a 3D model by a URL. This implementation is used for testing\n * purposes.\n */\nexport class LocalModelIdentifier implements ModelIdentifier {\n readonly revealInternalId: symbol;\n readonly localPath: string;\n\n constructor(localPath: string) {\n this.revealInternalId = Symbol(localPath);\n this.localPath = localPath;\n }\n\n public toString(): string {\n return `${LocalModelIdentifier.name} (${this.localPath})`;\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\nimport * as THREE from 'three';\n\nimport { applyDefaultModelTransformation } from './applyDefaultModelTransformation';\nimport { LocalModelIdentifier } from './LocalModelIdentifier';\nimport { ModelIdentifier } from './ModelIdentifier';\nimport { ModelMetadataProvider } from './ModelMetadataProvider';\nimport { BlobOutputMetadata, File3dFormat } from './types';\nimport { fetchWithStatusCheck } from './utilities';\n\nexport class LocalModelMetadataProvider implements ModelMetadataProvider {\n getModelUri(modelIdentifier: ModelIdentifier): Promise<string> {\n if (!(modelIdentifier instanceof LocalModelIdentifier)) {\n throw new Error(`Model must be a ${LocalModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n return Promise.resolve(`${location.origin}/${modelIdentifier.localPath}`);\n }\n\n async getModelMatrix(modelIdentifier: ModelIdentifier): Promise<THREE.Matrix4> {\n if (!(modelIdentifier instanceof LocalModelIdentifier)) {\n throw new Error(`Model must be a ${LocalModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n const matrix = new THREE.Matrix4();\n applyDefaultModelTransformation(matrix, File3dFormat.RevealCadModel);\n return matrix;\n }\n\n getModelCamera(\n modelIdentifier: ModelIdentifier\n ): Promise<{ position: THREE.Vector3; target: THREE.Vector3 } | undefined> {\n if (!(modelIdentifier instanceof LocalModelIdentifier)) {\n throw new Error(`Model must be a ${LocalModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n return Promise.resolve(undefined);\n }\n\n async getModelOutputs(modelIdentifier: ModelIdentifier): Promise<BlobOutputMetadata[]> {\n const modelUri = await this.getModelUri(modelIdentifier);\n\n const output = (await getCadOutput(modelUri)) ?? (await getPointCloudOutput(modelUri));\n\n if (output) {\n return [output];\n }\n\n throw new Error(`Only point cloud or CAD models (version 8 and 9) are supported)`);\n\n async function getCadOutput(modelUri: string): Promise<BlobOutputMetadata | undefined> {\n let version: number;\n\n try {\n version = (await (await fetchWithStatusCheck(modelUri + '/scene.json')).json()).version;\n } catch (error) {\n return undefined;\n }\n switch (version) {\n case 8:\n return Promise.resolve({\n blobId: -1,\n format: File3dFormat.RevealCadModel,\n version: 8\n });\n case 9:\n return Promise.resolve({\n blobId: -1,\n format: File3dFormat.GltfCadModel,\n version: 9\n });\n default:\n return undefined;\n }\n }\n\n async function getPointCloudOutput(modelUri: string): Promise<BlobOutputMetadata | undefined> {\n let scene: any;\n\n try {\n scene = await (await fetchWithStatusCheck(modelUri + '/ept.json')).json();\n } catch (error) {\n return undefined;\n }\n\n if (scene) {\n return Promise.resolve({\n blobId: -1,\n format: File3dFormat.EptPointCloud,\n version: -1\n });\n } else {\n return undefined;\n }\n }\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\n/**\n * @module @cognite/reveal/extensions/datasource\n */\n\nexport { DataSource } from '../packages/data-source';\nexport { NodesApiClient } from '../packages/nodes-api';\nexport {\n ModelIdentifier,\n CdfModelIdentifier,\n ModelMetadataProvider,\n ModelDataProvider,\n BlobOutputMetadata,\n File3dFormat\n} from '../packages/modeldata-api';\n"],"sourceRoot":""}
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright 2021 Cognite AS
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @module @cognite/reveal
|
|
6
|
-
*/
|
|
7
|
-
export * from './core/src/index';
|
|
8
|
-
export { CameraControlsOptions } from './packages/camera-manager';
|
|
9
|
-
export { NodeAppearance, DefaultNodeAppearance,
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 Cognite AS
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @module @cognite/reveal
|
|
6
|
+
*/
|
|
7
|
+
export * from './core/src/index';
|
|
8
|
+
export { CameraControlsOptions, DefaultCameraManager, CameraManagerHelper, CameraManager, CameraChangeDelegate, CameraState, ComboControls } from './packages/camera-manager';
|
|
9
|
+
export { AreaCollection, ClusteredAreaCollection, NodeAppearanceProvider, NodeAppearance, NodeOutlineColor, DefaultNodeAppearance, NodeCollection, TreeIndexNodeCollection, IntersectionNodeCollection, UnionNodeCollection, SerializedNodeCollection, PropertyFilterNodeCollection, SinglePropertyFilterNodeCollection, AssetNodeCollection, InvertedNodeCollection, registerCustomNodeCollectionType, TypeName, NodeCollectionDescriptor, NodeCollectionSerializationContext, CdfModelNodeCollectionDataProvider } from './packages/cad-styling';
|
|
10
|
+
export { CogniteModelBase, SupportedModelTypes } from './packages/model-base';
|
|
11
|
+
export { revealEnv, IndexSet, NumericRange } from './packages/utilities';
|
|
12
|
+
export { Cognite3DModel, BoundingBoxClipper, GeometryFilter, WellKnownUnit } from './packages/cad-model';
|
|
13
|
+
export { CognitePointCloudModel } from './packages/pointclouds';
|