@cognite/reveal 2.1.2 → 3.0.0-alpha.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 +1 -2
- package/core/src/datamodels/cad/CadManager.d.ts +10 -10
- package/core/src/datamodels/cad/CadModelFactory.d.ts +10 -4
- package/core/src/datamodels/cad/createCadManager.d.ts +4 -5
- package/core/src/datamodels/cad/picking.d.ts +1 -1
- package/core/src/datamodels/cad/rendering/RenderAlreadyLoadedGeometryProvider.d.ts +2 -1
- package/core/src/datamodels/cad/styling/AssetNodeCollection.d.ts +8 -2
- package/core/src/datamodels/cad/styling/InvertedNodeCollection.d.ts +3 -2
- package/core/src/datamodels/cad/styling/PopulateIndexSetFromPagedResponseHelper.d.ts +10 -4
- package/core/src/datamodels/cad/styling/PropertyFilterNodeCollection.d.ts +5 -11
- package/core/src/datamodels/cad/styling/SinglePropertyFilterNodeCollection.d.ts +5 -14
- package/core/src/datamodels/pointcloud/PointCloudManager.d.ts +5 -4
- package/core/src/datamodels/pointcloud/PointCloudMetadataRepository.d.ts +6 -5
- package/core/src/datamodels/pointcloud/createPointCloudManager.d.ts +2 -4
- package/core/src/datamodels/pointcloud/index.d.ts +5 -0
- package/core/src/index.d.ts +1 -1
- package/core/src/internals.d.ts +15 -0
- package/core/src/public/RevealManager.d.ts +11 -8
- package/core/src/public/createRevealManager.d.ts +2 -3
- package/core/src/public/migration/Cognite3DModel.d.ts +20 -1
- package/core/src/public/migration/Cognite3DViewer.d.ts +30 -10
- package/core/src/public/migration/types.d.ts +36 -23
- package/core/src/public/types.d.ts +3 -1
- package/core/src/{public/migration → storage}/RevealManagerHelper.d.ts +7 -7
- package/core/src/utilities/Spinner.d.ts +4 -5
- package/core/src/utilities/ViewStateHelper.d.ts +2 -2
- package/core/src/utilities/worldToViewport.d.ts +1 -2
- package/extensions/datasource.d.ts +9 -0
- package/extensions/datasource.js +30 -0
- package/extensions/datasource.map +1 -0
- package/index.d.ts +2 -1
- package/index.js +214 -125
- package/index.map +1 -1
- package/package.json +6 -8
- package/packages/cad-geometry-loaders/index.d.ts +4 -11
- package/packages/cad-geometry-loaders/src/{CadModelSectorBudget.d.ts → CadModelBudget.d.ts} +3 -10
- package/packages/cad-geometry-loaders/src/CadModelUpdateHandler.d.ts +5 -7
- package/packages/cad-geometry-loaders/src/sector/SectorLoader.d.ts +7 -6
- package/packages/cad-geometry-loaders/src/sector/culling/ByScreenSizeSectorCuller.d.ts +23 -0
- package/packages/cad-geometry-loaders/src/sector/culling/ByVisibilityGpuSectorCuller.d.ts +3 -5
- package/packages/cad-geometry-loaders/src/sector/culling/WeightFunctionsHelper.d.ts +50 -0
- package/packages/cad-geometry-loaders/src/sector/culling/computeNdcAreaOfBox.d.ts +12 -0
- package/packages/cad-geometry-loaders/src/sector/culling/computeSectorCost.d.ts +7 -0
- package/packages/cad-geometry-loaders/src/sector/culling/createV8SectorCuller.d.ts +7 -0
- package/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenSectorMapBase.d.ts +11 -0
- package/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenV8SectorMap.d.ts +17 -0
- package/packages/cad-geometry-loaders/src/sector/culling/{TakenSectorTree.d.ts → takensectors/TakenV8SectorTree.d.ts} +6 -6
- package/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenV9SectorMap.d.ts +20 -0
- package/packages/cad-geometry-loaders/src/sector/culling/takensectors/index.d.ts +5 -0
- package/packages/cad-geometry-loaders/src/sector/culling/transformBoxToNDC.d.ts +5 -0
- package/packages/cad-geometry-loaders/src/sector/culling/types.d.ts +16 -4
- package/packages/cad-geometry-loaders/src/sector/rxSectorUtilities.d.ts +2 -2
- package/packages/cad-geometry-loaders/src/utilities/rxOperations.d.ts +3 -2
- package/packages/cad-geometry-loaders/src/utilities/types.d.ts +0 -23
- package/packages/cad-parsers/index.d.ts +7 -6
- package/packages/{cad-geometry-loaders/src/material-manager/rendering → cad-parsers/src/cad}/filterInstanceMesh.d.ts +1 -1
- package/packages/cad-parsers/src/cad/filterPrimitivesCommon.d.ts +5 -0
- package/packages/cad-parsers/src/cad/{filterPrimitives.d.ts → filterPrimitivesV8.d.ts} +0 -0
- package/packages/cad-parsers/src/cad/filterPrimitivesV9.d.ts +6 -0
- package/packages/cad-parsers/src/cad/primitiveGeometries.d.ts +1 -1
- package/packages/{cad-geometry-loaders/src/material-manager/rendering → cad-parsers/src/cad}/triangleMeshes.d.ts +1 -1
- package/packages/cad-parsers/src/cad/types.d.ts +2 -2
- package/packages/cad-parsers/src/metadata/CadModelMetadata.d.ts +10 -0
- package/packages/cad-parsers/src/metadata/CadModelMetadataRepository.d.ts +6 -6
- package/packages/cad-parsers/src/metadata/MetadataRepository.d.ts +3 -2
- package/packages/cad-parsers/src/metadata/parsers/CadMetadataParserGltf.d.ts +6 -0
- package/packages/cad-parsers/src/metadata/parsers/CadMetadataParserV8.d.ts +2 -47
- package/packages/cad-parsers/src/metadata/parsers/types.d.ts +60 -0
- package/packages/cad-parsers/src/metadata/types.d.ts +15 -4
- package/packages/{cad-geometry-loaders → cad-parsers}/src/sector/RootSectorNode.d.ts +1 -1
- package/packages/{cad-geometry-loaders → cad-parsers}/src/sector/SectorNode.d.ts +1 -1
- package/packages/cad-parsers/src/utilities/SectorSceneFactory.d.ts +2 -5
- package/packages/cad-parsers/src/utilities/computeBoundingBoxFromAttributes.d.ts +10 -0
- package/packages/{cad-geometry-loaders → cad-parsers}/src/utilities/float32BufferToMatrix.d.ts +0 -0
- package/packages/cad-parsers/src/utilities/types.d.ts +26 -0
- package/packages/cad-styling/index.d.ts +4 -0
- package/packages/cad-styling/src/CombineNodeCollectionBase.d.ts +4 -2
- package/packages/cad-styling/src/IntersectionNodeCollection.d.ts +4 -0
- package/packages/cad-styling/src/NodeAppearance.d.ts +23 -0
- package/packages/cad-styling/src/NodeAppearanceProvider.d.ts +7 -0
- package/packages/cad-styling/src/NodeCollectionBase.d.ts +7 -0
- package/packages/cad-styling/src/TreeIndexNodeCollection.d.ts +17 -1
- package/packages/cad-styling/src/UnionNodeCollection.d.ts +3 -0
- package/packages/cad-styling/src/prioritized/AreaCollection.d.ts +39 -0
- package/packages/cad-styling/src/prioritized/BoxClusterer.d.ts +29 -0
- package/packages/cad-styling/src/prioritized/ClusteredAreaCollection.d.ts +17 -0
- package/packages/cad-styling/src/prioritized/EmptyAreaCollection.d.ts +18 -0
- package/packages/cad-styling/src/prioritized/types.d.ts +7 -0
- package/packages/camera-manager/index.d.ts +3 -1
- package/packages/camera-manager/src/CameraManager.d.ts +84 -0
- package/packages/camera-manager/src/ComboControls.d.ts +60 -42
- package/packages/camera-manager/src/Keyboard.d.ts +10 -7
- package/packages/camera-manager/src/types.d.ts +64 -0
- package/packages/data-source/index.d.ts +6 -0
- package/packages/data-source/src/CdfDataSource.d.ts +19 -0
- package/packages/data-source/src/DataSource.d.ts +26 -0
- package/packages/data-source/src/LocalDataSource.d.ts +15 -0
- package/packages/metrics/index.d.ts +5 -0
- package/packages/metrics/src/MetricsLogger.d.ts +21 -0
- package/packages/metrics/src/types.d.ts +7 -0
- package/packages/modeldata-api/index.d.ts +8 -3
- package/packages/modeldata-api/src/{CdfModelDataClient.d.ts → CdfModelDataProvider.d.ts} +6 -6
- package/packages/modeldata-api/src/CdfModelIdentifier.d.ts +15 -0
- package/packages/modeldata-api/src/CdfModelMetadataProvider.d.ts +11 -27
- package/packages/modeldata-api/src/CdfModelOutputsProvider.d.ts +16 -0
- package/packages/modeldata-api/src/LocalModelDataProvider.d.ts +10 -0
- package/packages/modeldata-api/src/LocalModelIdentifier.d.ts +14 -0
- package/packages/modeldata-api/src/LocalModelMetadataProvider.d.ts +11 -14
- package/packages/modeldata-api/src/ModelIdentifier.d.ts +12 -0
- package/packages/modeldata-api/src/ModelMetadataProvider.d.ts +19 -0
- package/packages/modeldata-api/src/types.d.ts +19 -26
- package/packages/nodes-api/index.d.ts +0 -1
- package/packages/nodes-api/src/NodesApiClient.d.ts +16 -8
- package/packages/nodes-api/src/NodesCdfClient.d.ts +9 -4
- package/packages/nodes-api/src/NodesLocalClient.d.ts +10 -5
- package/packages/nodes-api/src/types.d.ts +0 -4
- package/packages/rendering/index.d.ts +17 -0
- package/packages/{cad-geometry-loaders/src/material-manager → rendering/src}/CadMaterialManager.d.ts +5 -5
- package/packages/rendering/src/GeometryBatchingManager.d.ts +30 -0
- package/packages/{cad-geometry-loaders → rendering}/src/InstancedMeshManager.d.ts +1 -1
- package/packages/{cad-geometry-loaders → rendering}/src/cameraconfig.d.ts +0 -0
- package/packages/{cad-geometry-loaders/src/material-manager → rendering/src}/rendering/EffectRenderManager.d.ts +28 -12
- package/packages/{cad-geometry-loaders/src/material-manager/styling → rendering/src/rendering}/NodeAppearanceTextureBuilder.d.ts +8 -7
- package/packages/{cad-parsers/src/cad → rendering/src/rendering}/RenderMode.d.ts +0 -0
- package/packages/{cad-geometry-loaders/src/material-manager → rendering/src}/rendering/createSimpleGeometryMesh.d.ts +1 -1
- package/packages/{cad-parsers/src/cad → rendering/src/rendering}/matCapTextureData.d.ts +0 -0
- package/packages/{cad-parsers/src/cad → rendering/src/rendering}/materials.d.ts +0 -0
- package/packages/{cad-parsers/src/cad → rendering/src/rendering}/primitives.d.ts +3 -3
- package/packages/{cad-parsers/src/cad → rendering/src/rendering}/shaders.d.ts +1 -1
- package/packages/{cad-geometry-loaders/src/material-manager → rendering/src}/rendering/types.d.ts +1 -1
- package/packages/{cad-geometry-loaders/src → rendering/src/sector}/CadNode.d.ts +18 -9
- package/packages/{cad-geometry-loaders/src/material-manager/styling → rendering/src/transform}/NodeTransformProvider.d.ts +1 -1
- package/packages/{cad-geometry-loaders/src/material-manager/styling → rendering/src/transform}/NodeTransformTextureBuilder.d.ts +1 -1
- package/packages/{cad-geometry-loaders/src/material-manager/styling → rendering/src/transform}/TransformOverrideBuffer.d.ts +3 -3
- package/packages/rendering/src/utilities/types.d.ts +26 -0
- package/packages/sector-loader/index.d.ts +6 -0
- package/packages/sector-loader/src/GltfSectorRepository.d.ts +14 -0
- package/packages/{cad-geometry-loaders/src/sector/Repository.d.ts → sector-loader/src/SectorRepository.d.ts} +2 -2
- package/packages/{cad-geometry-loaders/src/sector/CachedRepository.d.ts → sector-loader/src/V8SectorRepository.d.ts} +6 -6
- package/packages/{cad-geometry-loaders/src/sector → sector-loader/src/v8}/SimpleAndDetailedToSector3D.d.ts +4 -4
- package/packages/{cad-geometry-loaders/src/utilities → sector-loader/src/v8}/arrays.d.ts +0 -0
- package/packages/{cad-geometry-loaders/src/utilities → sector-loader/src/v8}/groupMeshesByNumber.d.ts +0 -0
- package/packages/sector-loader/src/v8/sectorUtilities.d.ts +16 -0
- package/packages/sector-parser/index.d.ts +5 -0
- package/packages/sector-parser/src/GltfSectorParser.d.ts +18 -0
- package/packages/sector-parser/src/reveal-glb-parser/GlbMetadataParser.d.ts +14 -0
- package/packages/sector-parser/src/reveal-glb-parser/primitiveGeometries.d.ts +12 -0
- package/packages/sector-parser/src/types.d.ts +98 -0
- package/packages/tools/index.d.ts +4 -1
- package/packages/tools/src/AxisView/AxisViewTool.d.ts +2 -2
- package/packages/tools/src/DebugLoadedSectorsTool.d.ts +1 -1
- package/packages/tools/src/Geomap/Geomap.d.ts +5 -2
- package/packages/tools/src/Geomap/GeomapTool.d.ts +5 -2
- package/packages/tools/src/HtmlOverlay/BucketGrid2D.d.ts +28 -0
- package/packages/tools/src/HtmlOverlay/HtmlOverlayTool.d.ts +160 -0
- package/packages/tools/src/Timeline/Keyframe.d.ts +39 -0
- package/packages/tools/src/Timeline/TimelineTool.d.ts +79 -0
- package/packages/tools/src/Timeline/types.d.ts +13 -0
- package/packages/utilities/index.d.ts +7 -3
- package/packages/utilities/src/NumericRange.d.ts +2 -1
- package/packages/utilities/src/RandomColors.d.ts +34 -0
- package/packages/utilities/src/WebGLRendererStateHelper.d.ts +1 -1
- package/packages/utilities/src/counterMap.d.ts +5 -0
- package/packages/utilities/src/datastructures/DynamicDefragmentedBuffer.d.ts +18 -5
- package/packages/utilities/src/events/InputHandler.d.ts +25 -0
- package/packages/utilities/src/events/index.d.ts +1 -0
- package/packages/utilities/src/indexset/IndexSet.d.ts +1 -1
- package/packages/utilities/src/three/isBox3OnPositiveSideOfPlane.d.ts +10 -0
- package/packages/utilities/src/three/toThreeBox3.d.ts +6 -0
- package/packages/utilities/src/three/visitBox3CornerPoints.d.ts +12 -0
- package/packages/utilities/src/types.d.ts +1 -0
- package/tools.js +77 -117
- package/tools.map +1 -1
- package/packages/cad-geometry-loaders/src/sector/sectorUtilities.d.ts +0 -19
- package/packages/cad-parsers/src/cad/computeBoundingBoxFromAttributes.d.ts +0 -9
- package/packages/modeldata-api/src/LocalModelDataClient.d.ts +0 -10
- package/packages/tools/src/HtmlOverlayTool.d.ts +0 -88
- package/packages/utilities/src/metrics.d.ts +0 -15
- package/packages/utilities/src/three/getBox3CornerPoints.d.ts +0 -5
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright 2021 Cognite AS
|
|
3
3
|
*/
|
|
4
4
|
import { CogniteClient } from '@cognite/sdk';
|
|
5
|
+
import { CadModelBudget } from '../../../../packages/cad-geometry-loaders';
|
|
5
6
|
import { Cognite3DModel } from './Cognite3DModel';
|
|
6
7
|
import { CognitePointCloudModel } from './CognitePointCloudModel';
|
|
7
8
|
/**
|
|
@@ -43,6 +44,20 @@ export interface Cognite3DViewerOptions {
|
|
|
43
44
|
target: THREE.WebGLRenderTarget;
|
|
44
45
|
autoSetSize?: boolean;
|
|
45
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Style the loading indicator.
|
|
49
|
+
*/
|
|
50
|
+
loadingIndicatorStyle?: {
|
|
51
|
+
/**
|
|
52
|
+
* What corner the spinner should be placed in. Defaults top topLeft.
|
|
53
|
+
*/
|
|
54
|
+
placement: 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
|
|
55
|
+
/**
|
|
56
|
+
* Opacity of the spinner in fractions. Valid values are between
|
|
57
|
+
* 0.2 and 1.0. Defaults to 1.0.
|
|
58
|
+
*/
|
|
59
|
+
opacity: number;
|
|
60
|
+
};
|
|
46
61
|
/**
|
|
47
62
|
* When false, camera near and far planes will not be updated automatically (defaults to true).
|
|
48
63
|
* This can be useful when you have custom content in the 3D view and need to better
|
|
@@ -96,8 +111,28 @@ export interface Cognite3DViewerOptions {
|
|
|
96
111
|
enableEdges?: boolean;
|
|
97
112
|
/** Callback to download stream progress. */
|
|
98
113
|
onLoading?: OnLoadingCallback;
|
|
114
|
+
/**
|
|
115
|
+
* Allows providing a custom data source that Reveal will
|
|
116
|
+
* use to load model data. Note that some features might not
|
|
117
|
+
* work when implementing a custom data source. Please refer
|
|
118
|
+
* to the Reveal documentation for details.
|
|
119
|
+
*
|
|
120
|
+
* Note that the data source must support {@link CdfModelIdentifier}.
|
|
121
|
+
*
|
|
122
|
+
* This cannot be used together with {@link _localModels}.
|
|
123
|
+
*/
|
|
124
|
+
customDataSource?: DataSource;
|
|
125
|
+
/**
|
|
126
|
+
* Allows for controlling if geometry streaming should be halted when
|
|
127
|
+
* the camera is moving. Note that this option should left to false on
|
|
128
|
+
* low-end devices as more loading can cause frame drops.
|
|
129
|
+
*
|
|
130
|
+
* Default value is set to false.
|
|
131
|
+
*/
|
|
132
|
+
continuousModelStreaming?: boolean;
|
|
99
133
|
}
|
|
100
134
|
import { GeometryFilter } from '../../public/types';
|
|
135
|
+
import { DataSource } from '../../../../packages/data-source';
|
|
101
136
|
export { GeometryFilter };
|
|
102
137
|
/**
|
|
103
138
|
* @module @cognite/reveal
|
|
@@ -193,29 +228,7 @@ export declare type SceneRenderedDelegate = (event: {
|
|
|
193
228
|
}) => void;
|
|
194
229
|
export * from './NotSupportedInMigrationWrapperError';
|
|
195
230
|
export { CogniteModelBase } from './CogniteModelBase';
|
|
196
|
-
|
|
197
|
-
* Represents a measurement of how much geometry can be loaded.
|
|
198
|
-
*/
|
|
199
|
-
export declare type CadModelBudget = {
|
|
200
|
-
/**
|
|
201
|
-
* Sectors within this distance from the camera will always be loaded in high details.
|
|
202
|
-
*/
|
|
203
|
-
readonly highDetailProximityThreshold: number;
|
|
204
|
-
/**
|
|
205
|
-
* Number of bytes of the geometry that must be downloaded.
|
|
206
|
-
*/
|
|
207
|
-
readonly geometryDownloadSizeBytes: number;
|
|
208
|
-
/**
|
|
209
|
-
* Estimated maximum number of WebGL draw calls to download geometry for. Draw calls
|
|
210
|
-
* are very important for the framerate.
|
|
211
|
-
*/
|
|
212
|
-
readonly maximumNumberOfDrawCalls: number;
|
|
213
|
-
/**
|
|
214
|
-
* Maximum render cost. This number can be thought of as triangle count, although the number
|
|
215
|
-
* doesn't match this directly.
|
|
216
|
-
*/
|
|
217
|
-
readonly maximumRenderCost: number;
|
|
218
|
-
};
|
|
231
|
+
export { CadModelBudget };
|
|
219
232
|
/**
|
|
220
233
|
* Represents a budget of how many point from point clouds can be
|
|
221
234
|
* loaded at the same time.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright 2021 Cognite AS
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { LoadingState, SectorCuller } from '../../../packages/cad-geometry-loaders';
|
|
5
|
+
import { SectorQuads, RenderOptions } from '../../../packages/rendering';
|
|
5
6
|
import { SectorGeometry } from '../../../packages/cad-parsers';
|
|
6
7
|
/**
|
|
7
8
|
* @property logMetrics Might be used to disable usage statistics.
|
|
@@ -11,6 +12,7 @@ import { SectorGeometry } from '../../../packages/cad-parsers';
|
|
|
11
12
|
export declare type RevealOptions = {
|
|
12
13
|
logMetrics?: boolean;
|
|
13
14
|
renderOptions?: RenderOptions;
|
|
15
|
+
continuousModelStreaming?: boolean;
|
|
14
16
|
internal?: {
|
|
15
17
|
parseCallback?: (parsed: {
|
|
16
18
|
lod: string;
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
* Copyright 2021 Cognite AS
|
|
3
3
|
*/
|
|
4
4
|
import * as THREE from 'three';
|
|
5
|
-
import { AddModelOptions } from '
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { CadNode } from '../../../../packages/cad-geometry-loaders';
|
|
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';
|
|
11
10
|
import { CogniteClient } from '@cognite/sdk';
|
|
12
11
|
/**
|
|
13
12
|
* Helper for {@link RevealManager} for creating a uniform interface for
|
|
@@ -36,7 +35,8 @@ export declare class RevealManagerHelper {
|
|
|
36
35
|
* @param sdkClient
|
|
37
36
|
*/
|
|
38
37
|
static createCdfHelper(renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions: RevealOptions, sdkClient: CogniteClient): RevealManagerHelper;
|
|
39
|
-
|
|
38
|
+
static createCustomDataSourceHelper(renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions: RevealOptions, dataSource: DataSource): RevealManagerHelper;
|
|
39
|
+
get revealManager(): RevealManager;
|
|
40
40
|
/**
|
|
41
41
|
* Adds a local CAD model.
|
|
42
42
|
* @param model
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
* Copyright 2021 Cognite AS
|
|
3
3
|
*/
|
|
4
4
|
import * as THREE from 'three';
|
|
5
|
+
export declare type Corner = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
|
|
5
6
|
export declare class Spinner {
|
|
6
7
|
private static readonly stylesId;
|
|
7
|
-
static classnames
|
|
8
|
-
base: string;
|
|
9
|
-
loading: string;
|
|
10
|
-
dark: string;
|
|
11
|
-
};
|
|
8
|
+
private static readonly classnames;
|
|
12
9
|
private static readonly titles;
|
|
13
10
|
private _loading;
|
|
14
11
|
private static loadStyles;
|
|
15
12
|
private readonly el;
|
|
16
13
|
constructor(parent: HTMLElement);
|
|
14
|
+
set placement(placement: Corner);
|
|
15
|
+
set opacity(fractionOpacity: number);
|
|
17
16
|
get loading(): boolean;
|
|
18
17
|
set loading(loadingState: boolean);
|
|
19
18
|
/**
|
|
@@ -26,8 +26,8 @@ export declare type ModelState = {
|
|
|
26
26
|
export declare class ViewStateHelper {
|
|
27
27
|
private readonly _cameraControls;
|
|
28
28
|
private readonly _viewer;
|
|
29
|
-
private
|
|
30
|
-
constructor(viewer: Cognite3DViewer,
|
|
29
|
+
private readonly _cdfClient;
|
|
30
|
+
constructor(viewer: Cognite3DViewer, cdfClient: CogniteClient);
|
|
31
31
|
getCurrentState(): ViewerState;
|
|
32
32
|
setState(viewerState: ViewerState): Promise<void>;
|
|
33
33
|
}
|
|
@@ -7,14 +7,13 @@ import * as THREE from 'three';
|
|
|
7
7
|
* relative to the canvas being rendered to. X and Y will
|
|
8
8
|
* be in range [0, 1]. Z is in range [-1, 1] if the coordinate
|
|
9
9
|
* is inside the camera near and far planes.
|
|
10
|
-
* @param renderer Renderer used to render the "world"
|
|
11
10
|
* @param camera Camera used to project point from 3D to NDC coordinates
|
|
12
11
|
* @param position3D World position in 3D
|
|
13
12
|
* @param out Optionally pre-allocated THREE.Vector3
|
|
14
13
|
* @returns Relative screen coordinates in X, Y and Z in range [-1, 1] if point
|
|
15
14
|
* is within near/far of camera.
|
|
16
15
|
*/
|
|
17
|
-
export declare function worldToNormalizedViewportCoordinates(
|
|
16
|
+
export declare function worldToNormalizedViewportCoordinates(camera: THREE.PerspectiveCamera, position3D: THREE.Vector3, out?: THREE.Vector3): THREE.Vector3;
|
|
18
17
|
/**
|
|
19
18
|
* Maps from 3D world coordinates to screen coordinates
|
|
20
19
|
* relative to the canvas. X and Y will be in absolute
|
|
@@ -0,0 +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';
|
|
@@ -0,0 +1,30 @@
|
|
|
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=65)}({0:function(t,e){t.exports=require("three")},20:function(t,e){t.exports=require("@cognite/sdk-core")},5: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"})).arrayBuffer()}async getJsonFile(t,e){return(await this.client.get(`${t}/${e}`)).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
|
+
/*!
|
|
3
|
+
* Copyright 2021 Cognite AS
|
|
4
|
+
*/!function(t){t.EptPointCloud="ept-pointcloud",t.RevealCadModel="reveal-directory",t.GltfCadModel="gltf-directory",t.AnyFormat="all-outputs"}(i||(i={}));
|
|
5
|
+
/*!
|
|
6
|
+
* Copyright 2021 Cognite AS
|
|
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:t.premultiply(s);break;case i.RevealCadModel:case i.GltfCadModel:t.premultiply(s);break;case i.EptPointCloud:break;default:throw new Error("Unknown model format '"+e)}}
|
|
9
|
+
/*!
|
|
10
|
+
* Copyright 2021 Cognite AS
|
|
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}`}}
|
|
12
|
+
/*!
|
|
13
|
+
* Copyright 2021 Cognite AS
|
|
14
|
+
*/var l=r(20);
|
|
15
|
+
/*!
|
|
16
|
+
* Copyright 2021 Cognite AS
|
|
17
|
+
*/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}
|
|
18
|
+
/*!
|
|
19
|
+
* Copyright 2021 Cognite AS
|
|
20
|
+
*/class f{get headers(){return{}}async getBinaryFile(t,e){return(await d(`${t}/${e}`)).arrayBuffer()}async getJsonFile(t,e){return(await d(`${t}/${e}`)).json()}}
|
|
21
|
+
/*!
|
|
22
|
+
* Copyright 2021 Cognite AS
|
|
23
|
+
*/class h{constructor(t){this.revealInternalId=Symbol(t),this.localPath=t}toString(){return`${h.name} (${this.localPath})`}}
|
|
24
|
+
/*!
|
|
25
|
+
* 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),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
|
+
/*!
|
|
28
|
+
* Copyright 2021 Cognite AS
|
|
29
|
+
*/},65:function(t,e,r){"use strict";r.r(e);var n=r(5);r.d(e,"CdfModelIdentifier",(function(){return n.b})),r.d(e,"File3dFormat",(function(){return n.d}))}})}));
|
|
30
|
+
//# sourceMappingURL=datasource.map
|
|
@@ -0,0 +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","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","Error","_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,GAAI,EAGJV,EAAOD,QA0Df,OArDAS,EAAoBK,EAAIF,EAGxBH,EAAoBM,EAAIP,EAGxBC,EAAoBO,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,EAAaM,gBAC9CF,EAGT,eACEQ,GAEA,KAAMA,aAA2B8B,GAC/B,MAAM,IAAIhC,MAAM,mBAAmBgC,EAAqBhG,iBAAiBkE,EAAgBC,cAG3F,OAAO+B,QAAQC,aAAQnD,GAGzB,sBAAsBkB,G,MACpB,MAAMoC,QAAiBhH,KAAKiH,YAAYrC,GAElCoB,EAAuC,QAA7B,QAQhBI,eAA4BY,GAC1B,IAAIE,EAEJ,IACEA,eAAwBb,EAAqBW,EAAW,gBAAgBP,QAAQS,QAChF,MAAO7D,GACP,OAEF,OAAQ6D,GACN,KAAK,EACH,OAAON,QAAQC,QAAQ,CACrBnB,QAAS,EACTrB,OAAQL,EAAaM,eACrB4C,QAAS,IAEb,KAAK,EACH,OAAON,QAAQC,QAAQ,CACrBnB,QAAS,EACTrB,OAAQL,EAAaQ,aACrB0C,QAAS,IAEb,QACE,QA9BgBC,CAAaH,UAAU,cAkC7CZ,eAAmCY,GACjC,IAAII,EAEJ,IACEA,cAAqBf,EAAqBW,EAAW,cAAcP,OACnE,MAAOpD,GACP,OAGF,OAAI+D,EACKR,QAAQC,QAAQ,CACrBnB,QAAS,EACTrB,OAAQL,EAAaS,cACrByC,SAAU,SAGZ,EAlDoDG,CAAoBL,GAE5E,GAAIhB,EACF,MAAO,CAACA,GAGV,MAAM,IAAItB,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' });\n return response.arrayBuffer();\n }\n\n async getJsonFile(baseUrl: string, fileName: string): Promise<any> {\n const response = await this.client.get(`${baseUrl}/${fileName}`);\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 * @version New since 2.2\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":""}
|
package/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
* @module @cognite/reveal
|
|
6
6
|
*/
|
|
7
7
|
export * from './core/src/index';
|
|
8
|
-
export {
|
|
8
|
+
export { CameraControlsOptions } from './packages/camera-manager';
|
|
9
|
+
export { NodeAppearance, DefaultNodeAppearance, AreaCollection, ClusteredAreaCollection } from './packages/cad-styling';
|