@cognite/reveal 3.0.0-beta.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -3
- package/core/index.d.ts +1 -2
- package/core/src/index.d.ts +0 -5
- package/core/src/internals.d.ts +2 -7
- package/core/src/public/RevealManager.d.ts +2 -5
- package/core/src/public/createRevealManager.d.ts +1 -1
- package/core/src/public/migration/Cognite3DViewer.d.ts +6 -7
- package/core/src/public/migration/types.d.ts +4 -74
- package/core/src/public/types.d.ts +5 -27
- package/core/src/storage/RevealManagerHelper.d.ts +1 -0
- package/core/src/utilities/index.d.ts +2 -4
- package/extensions/datasource.js +3 -6
- package/extensions/datasource.map +1 -1
- package/index.d.ts +5 -1
- package/index.js +177 -168
- package/index.map +1 -1
- package/package.json +11 -10
- package/packages/cad-geometry-loaders/index.d.ts +1 -6
- package/packages/cad-geometry-loaders/src/CadModelUpdateHandler.d.ts +2 -2
- package/packages/cad-geometry-loaders/src/sector/SectorLoader.d.ts +1 -0
- package/packages/cad-geometry-loaders/src/sector/culling/createV8SectorCuller.d.ts +1 -1
- package/packages/cad-model/index.d.ts +12 -0
- package/{core/src/utilities → packages/cad-model/src}/BoundingBoxClipper.d.ts +0 -0
- package/{core/src/datamodels/cad → packages/cad-model/src}/CadManager.d.ts +9 -4
- package/{core/src/datamodels/cad → packages/cad-model/src}/CadModelFactory.d.ts +6 -4
- package/{core/src/datamodels/cad → packages/cad-model/src}/CadModelSectorLoadStatistics.d.ts +0 -0
- package/{core/src/public/migration → packages/cad-model/src}/Cognite3DModel.d.ts +4 -6
- package/packages/cad-model/src/GeometryFilter.d.ts +20 -0
- package/packages/cad-model/src/InternalRevealCadOptions.d.ts +13 -0
- package/{core/src/public/migration → packages/cad-model/src}/NodeIdAndTreeIndexMaps.d.ts +0 -0
- package/packages/cad-model/src/WellKnownUnit.d.ts +7 -0
- package/{core/src/utilities → packages/cad-model/src}/callActionWithIndicesAsync.d.ts +0 -0
- package/{core/src/datamodels/cad → packages/cad-model/src}/createCadManager.d.ts +6 -4
- package/{core/src/datamodels/cad → packages/cad-model/src}/picking.d.ts +2 -2
- package/packages/cad-parsers/index.d.ts +2 -3
- package/packages/cad-parsers/src/cad/primitiveGeometries.d.ts +0 -1
- package/packages/cad-parsers/src/cad/triangleMeshes.d.ts +2 -2
- package/{core/src/datamodels/cad/sector → packages/cad-parsers/src/metadata}/CadModelClipper.d.ts +1 -1
- package/packages/cad-parsers/src/metadata/CadModelMetadataRepository.d.ts +1 -1
- package/packages/cad-parsers/src/sector/RootSectorNode.d.ts +1 -0
- package/packages/cad-parsers/src/sector/SectorNode.d.ts +1 -0
- package/packages/cad-styling/src/AssetNodeCollection.d.ts +3 -1
- package/packages/cad-styling/src/NodeCollectionDeserializer.d.ts +1 -1
- package/packages/camera-manager/index.d.ts +2 -0
- package/packages/camera-manager/src/CameraManager.d.ts +4 -2
- package/packages/camera-manager/src/CameraManagerHelper.d.ts +42 -0
- package/packages/camera-manager/src/DefaultCameraManager.d.ts +7 -9
- package/packages/camera-manager/src/types.d.ts +5 -14
- package/packages/metrics/index.d.ts +0 -1
- package/packages/model-base/index.d.ts +7 -0
- package/{core/src/public/migration → packages/model-base/src}/CogniteModelBase.d.ts +2 -2
- package/packages/{cad-parsers/src/metadata → model-base/src}/MetadataRepository.d.ts +1 -1
- package/{core/src/datamodels/base → packages/model-base/src}/SupportedModelTypes.d.ts +0 -0
- package/packages/{cad-geometry-loaders/src/utilities → model-base/src}/types.d.ts +11 -0
- package/packages/modeldata-api/index.d.ts +0 -1
- package/packages/pointclouds/index.d.ts +11 -0
- package/{core/src/public/migration → packages/pointclouds/src}/CognitePointCloudModel.d.ts +3 -4
- package/packages/pointclouds/src/PointCloudBudget.d.ts +14 -0
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudFactory.d.ts +1 -1
- package/packages/pointclouds/src/PointCloudIntersection.d.ts +26 -0
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudManager.d.ts +2 -2
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudMetadata.d.ts +2 -2
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudMetadataRepository.d.ts +2 -2
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PointCloudNode.d.ts +1 -1
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PotreeGroupWrapper.d.ts +1 -1
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/PotreeNodeWrapper.d.ts +2 -3
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/createPointCloudManager.d.ts +1 -1
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/picking.d.ts +1 -1
- package/{core/src/datamodels/pointcloud → packages/pointclouds/src}/types.d.ts +0 -0
- package/packages/rendering/index.d.ts +1 -4
- package/packages/rendering/src/CadMaterialManager.d.ts +3 -1
- package/packages/rendering/src/GeometryBatchingManager.d.ts +1 -0
- package/packages/rendering/src/rendering/materials.d.ts +15 -15
- package/packages/rendering/src/sector/CadNode.d.ts +4 -4
- package/packages/utilities/index.d.ts +3 -0
- package/packages/utilities/src/events/InputHandler.d.ts +1 -5
- package/packages/utilities/src/events/index.d.ts +1 -0
- package/packages/utilities/src/events/types.d.ts +27 -0
- package/{core/src/utilities → packages/utilities/src}/worldToViewport.d.ts +0 -0
- package/tools.js +99 -73
- 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/pointcloud/index.d.ts +0 -5
- package/packages/modeldata-api/src/CdfModelOutputsProvider.d.ts +0 -16
- package/packages/modeldata-api/src/Model3DOutputList.d.ts +0 -17
package/README.md
CHANGED
|
@@ -9,13 +9,16 @@ The documentation has a bunch of [live examples](https://cognitedata.github.io/r
|
|
|
9
9
|
|
|
10
10
|
```typescript
|
|
11
11
|
import { Cognite3DViewer } from "@cognite/reveal";
|
|
12
|
-
import { CogniteClient } from "@cognite/sdk";
|
|
12
|
+
import { CogniteClient, CogniteAuthentication } from "@cognite/sdk";
|
|
13
13
|
|
|
14
14
|
const appId = "com.cognite.reveal.example";
|
|
15
|
-
const client = new CogniteClient({
|
|
15
|
+
const client = new CogniteClient({
|
|
16
|
+
appId,
|
|
17
|
+
project,
|
|
18
|
+
getToken
|
|
19
|
+
});
|
|
16
20
|
|
|
17
21
|
async function start() {
|
|
18
|
-
await client.loginWithOAuth({ type: "CDF_OAUTH", options: { project: "publicdata" }});
|
|
19
22
|
await client.authenticate();
|
|
20
23
|
|
|
21
24
|
const viewer = new Cognite3DViewer({
|
|
@@ -25,6 +28,24 @@ async function start() {
|
|
|
25
28
|
viewer.addModel({ modelId: 4715379429968321, revisionId: 5688854005909501 });
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
const project = "publicdata";
|
|
32
|
+
const legacyInstance = new CogniteAuthentication({
|
|
33
|
+
project,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const getToken = async () => {
|
|
37
|
+
await legacyInstance.handleLoginRedirect();
|
|
38
|
+
let token = await legacyInstance.getCDFToken();
|
|
39
|
+
if (token) {
|
|
40
|
+
return token.accessToken;
|
|
41
|
+
}
|
|
42
|
+
token = await legacyInstance.login({ onAuthenticate: "REDIRECT" });
|
|
43
|
+
if (token) {
|
|
44
|
+
return token.accessToken;
|
|
45
|
+
}
|
|
46
|
+
throw new Error("authentication error");
|
|
47
|
+
};
|
|
48
|
+
|
|
28
49
|
start();
|
|
29
50
|
```
|
|
30
51
|
|
package/core/index.d.ts
CHANGED
|
@@ -2,6 +2,5 @@
|
|
|
2
2
|
* Copyright 2021 Cognite AS
|
|
3
3
|
*/
|
|
4
4
|
export { Cognite3DViewer } from './src/public/migration/Cognite3DViewer';
|
|
5
|
-
export { Cognite3DModel } from '
|
|
6
|
-
export { CogniteModelBase } from './src/public/migration/CogniteModelBase';
|
|
5
|
+
export { Cognite3DModel } from '../packages/cad-model';
|
|
7
6
|
export * from './src/public/types';
|
package/core/src/index.d.ts
CHANGED
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @module @cognite/reveal
|
|
6
6
|
*/
|
|
7
|
-
export { revealEnv, IndexSet, NumericRange } from '../../packages/utilities';
|
|
8
|
-
export * from './public/migration/Cognite3DViewer';
|
|
9
|
-
export { BoundingBoxClipper } from './utilities';
|
|
10
|
-
export { Cognite3DModel } from './public/migration/Cognite3DModel';
|
|
11
7
|
export { Cognite3DViewer } from './public/migration/Cognite3DViewer';
|
|
12
|
-
export { CognitePointCloudModel } from './public/migration/CognitePointCloudModel';
|
|
13
8
|
export { ViewerState, ModelState } from './utilities/ViewStateHelper';
|
|
14
9
|
export * from './public/types';
|
|
15
10
|
import * as THREE from 'three';
|
package/core/src/internals.d.ts
CHANGED
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
export { CdfModelIdentifier, LocalModelIdentifier, ModelIdentifier, File3dFormat } from '../../packages/modeldata-api';
|
|
5
5
|
export { RevealManager } from './public/RevealManager';
|
|
6
6
|
export { createLocalRevealManager, createCdfRevealManager } from './public/createRevealManager';
|
|
7
|
-
export { intersectCadNodes } from '
|
|
8
|
-
export {
|
|
9
|
-
export { PointCloudMetadata } from './datamodels/pointcloud';
|
|
10
|
-
export * from './datamodels/pointcloud/types';
|
|
11
|
-
export { PotreeNodeWrapper } from './datamodels/pointcloud/PotreeNodeWrapper';
|
|
12
|
-
export { PotreeGroupWrapper } from './datamodels/pointcloud/PotreeGroupWrapper';
|
|
13
|
-
export { PointCloudNode } from './datamodels/pointcloud/PointCloudNode';
|
|
7
|
+
export { CadModelSectorLoadStatistics, intersectCadNodes } from '../../packages/cad-model';
|
|
8
|
+
export { PotreePointShape, PotreePointColorType, PotreePointSizeType, WellKnownAsprsPointClassCodes, PointCloudNode } from '../../packages/pointclouds';
|
|
14
9
|
import * as utilities from './utilities';
|
|
15
10
|
export { utilities };
|
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
* Copyright 2021 Cognite AS
|
|
3
3
|
*/
|
|
4
4
|
import * as THREE from 'three';
|
|
5
|
-
import { CadManager } from '../datamodels/cad/CadManager';
|
|
6
|
-
import { PointCloudManager } from '../datamodels/pointcloud/PointCloudManager';
|
|
7
5
|
import { LoadingStateChangeListener, PointCloudBudget } from './types';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { GeometryFilter } from '..';
|
|
6
|
+
import { CadManager, GeometryFilter, CadModelSectorLoadStatistics } from '../../../packages/cad-model';
|
|
7
|
+
import { PointCloudManager, PointCloudNode } from '../../../packages/pointclouds';
|
|
11
8
|
import { CadModelBudget } from '../../../packages/cad-geometry-loaders';
|
|
12
9
|
import { NodeAppearanceProvider } from '../../../packages/cad-styling';
|
|
13
10
|
import { RenderOptions, EffectRenderManager, CadNode, RenderMode } from '../../../packages/rendering';
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright 2021 Cognite AS
|
|
3
3
|
*/
|
|
4
4
|
import * as THREE from 'three';
|
|
5
|
-
import { RevealManager } from './RevealManager';
|
|
6
5
|
import { RevealOptions } from './types';
|
|
6
|
+
import { RevealManager } from './RevealManager';
|
|
7
7
|
import { CogniteClient } from '@cognite/sdk';
|
|
8
8
|
/**
|
|
9
9
|
* Used to create an instance of reveal manager that works with localhost.
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
* Copyright 2021 Cognite AS
|
|
3
3
|
*/
|
|
4
4
|
import * as THREE from 'three';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { DisposedDelegate, SceneRenderedDelegate } from '../types';
|
|
10
|
-
import { SupportedModelTypes } from '../../datamodels/base';
|
|
5
|
+
import { PointerEventDelegate, SceneRenderedDelegate, DisposedDelegate } from '../../../../packages/utilities';
|
|
6
|
+
import { Cognite3DModel } from '../../../../packages/cad-model';
|
|
7
|
+
import { PointCloudBudget, CognitePointCloudModel } from '../../../../packages/pointclouds';
|
|
8
|
+
import { AddModelOptions, Cognite3DViewerOptions, Intersection, CadModelBudget } from './types';
|
|
11
9
|
import { IntersectionFromPixelOptions } from '../..';
|
|
12
10
|
import { ViewerState } from '../../utilities/ViewStateHelper';
|
|
13
|
-
import { CameraManager } from '../../../../packages/camera-manager';
|
|
11
|
+
import { CameraManager, CameraChangeDelegate } from '../../../../packages/camera-manager';
|
|
12
|
+
import { SupportedModelTypes, CogniteModelBase } from '../../../../packages/model-base';
|
|
14
13
|
/**
|
|
15
14
|
* @example
|
|
16
15
|
* ```js
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { CogniteClient } from '@cognite/sdk';
|
|
5
5
|
import { CadModelBudget } from '../../../../packages/cad-geometry-loaders';
|
|
6
|
-
import {
|
|
7
|
-
import { CognitePointCloudModel } from './CognitePointCloudModel';
|
|
6
|
+
import { PointCloudBudget, PointCloudIntersection } from '../../../../packages/pointclouds';
|
|
8
7
|
import { CameraManager } from '../../../../packages/camera-manager';
|
|
8
|
+
import { GeometryFilter, Cognite3DModel } from '../../../../packages/cad-model';
|
|
9
|
+
import { DataSource } from '../../../../packages/data-source';
|
|
9
10
|
/**
|
|
10
11
|
* @module @cognite/reveal
|
|
11
12
|
*/
|
|
@@ -14,10 +15,6 @@ export declare type Color = {
|
|
|
14
15
|
g: number;
|
|
15
16
|
b: number;
|
|
16
17
|
};
|
|
17
|
-
/**
|
|
18
|
-
* Units supported by {@link Cognite3DModel}.
|
|
19
|
-
*/
|
|
20
|
-
export declare type WellKnownUnit = 'Meters' | 'Centimeters' | 'Millimeters' | 'Micrometers' | 'Kilometers' | 'Feet' | 'Inches' | 'Yards' | 'Miles' | 'Mils' | 'Microinches';
|
|
21
18
|
/**
|
|
22
19
|
* Callback to monitor loaded requests and progress.
|
|
23
20
|
* Use OnLoadingCallback instead of onProgress/onComplete.
|
|
@@ -117,9 +114,6 @@ export interface Cognite3DViewerOptions {
|
|
|
117
114
|
*/
|
|
118
115
|
continuousModelStreaming?: boolean;
|
|
119
116
|
}
|
|
120
|
-
import { GeometryFilter } from '../../public/types';
|
|
121
|
-
import { DataSource } from '../../../../packages/data-source';
|
|
122
|
-
export { GeometryFilter };
|
|
123
117
|
/**
|
|
124
118
|
* @module @cognite/reveal
|
|
125
119
|
*/
|
|
@@ -151,28 +145,6 @@ export declare type CadIntersection = {
|
|
|
151
145
|
*/
|
|
152
146
|
distanceToCamera: number;
|
|
153
147
|
};
|
|
154
|
-
export declare type PointCloudIntersection = {
|
|
155
|
-
/**
|
|
156
|
-
* The intersection type.
|
|
157
|
-
*/
|
|
158
|
-
type: 'pointcloud';
|
|
159
|
-
/**
|
|
160
|
-
* The model that was intersected.
|
|
161
|
-
*/
|
|
162
|
-
model: CognitePointCloudModel;
|
|
163
|
-
/**
|
|
164
|
-
* Tree index of the intersected 3D node.
|
|
165
|
-
*/
|
|
166
|
-
point: THREE.Vector3;
|
|
167
|
-
/**
|
|
168
|
-
* The index of the point that was intersected.
|
|
169
|
-
*/
|
|
170
|
-
pointIndex: number;
|
|
171
|
-
/**
|
|
172
|
-
* Distance from the camera to the intersection.
|
|
173
|
-
*/
|
|
174
|
-
distanceToCamera: number;
|
|
175
|
-
};
|
|
176
148
|
/**
|
|
177
149
|
* Represents the result from {@link Cognite3DViewer.getIntersectionFromPixel}.
|
|
178
150
|
* @module @cognite/reveal
|
|
@@ -182,50 +154,8 @@ export declare type Intersection = CadIntersection | PointCloudIntersection;
|
|
|
182
154
|
* @module @cognite/reveal
|
|
183
155
|
*/
|
|
184
156
|
export { CameraConfiguration } from '../../../../packages/utilities';
|
|
185
|
-
/**
|
|
186
|
-
* Delegate for pointer events.
|
|
187
|
-
* @module @cognite/reveal
|
|
188
|
-
* @see {@link Cognite3DViewer.on}.
|
|
189
|
-
*/
|
|
190
|
-
export declare type PointerEventDelegate = (event: {
|
|
191
|
-
offsetX: number;
|
|
192
|
-
offsetY: number;
|
|
193
|
-
}) => void;
|
|
194
|
-
/**
|
|
195
|
-
* Delegate for camera update events.
|
|
196
|
-
* @module @cognite/reveal
|
|
197
|
-
* @see {@link Cognite3DViewer.on}.
|
|
198
|
-
*/
|
|
199
|
-
export declare type CameraChangeDelegate = (position: THREE.Vector3, target: THREE.Vector3) => void;
|
|
200
|
-
/**
|
|
201
|
-
* Delegate for disposal events.
|
|
202
|
-
*/
|
|
203
|
-
export declare type DisposedDelegate = () => void;
|
|
204
|
-
/**
|
|
205
|
-
* Delegate for rendering events.
|
|
206
|
-
* @module @cognite/reveal
|
|
207
|
-
* @see {@link Cognite3DViewer.on}.
|
|
208
|
-
*/
|
|
209
|
-
export declare type SceneRenderedDelegate = (event: {
|
|
210
|
-
frameNumber: number;
|
|
211
|
-
renderTime: number;
|
|
212
|
-
renderer: THREE.WebGLRenderer;
|
|
213
|
-
camera: THREE.PerspectiveCamera;
|
|
214
|
-
}) => void;
|
|
215
157
|
export * from './NotSupportedInMigrationWrapperError';
|
|
216
|
-
export {
|
|
217
|
-
export { CadModelBudget };
|
|
218
|
-
/**
|
|
219
|
-
* Represents a budget of how many point from point clouds can be
|
|
220
|
-
* loaded at the same time.
|
|
221
|
-
*/
|
|
222
|
-
export declare type PointCloudBudget = {
|
|
223
|
-
/**
|
|
224
|
-
* Total number of points that can be loaded for all point clouds models
|
|
225
|
-
* accumulated.
|
|
226
|
-
*/
|
|
227
|
-
readonly numberOfPoints: number;
|
|
228
|
-
};
|
|
158
|
+
export { CadModelBudget, PointCloudBudget };
|
|
229
159
|
/**
|
|
230
160
|
* Options to control how {@link Cognite3DViewer.getIntersectionFromPixel} behaves.
|
|
231
161
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright 2021 Cognite AS
|
|
3
3
|
*/
|
|
4
|
-
import { LoadingState
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { LoadingState } from '../../../packages/model-base';
|
|
5
|
+
import { RenderOptions } from '../../../packages/rendering';
|
|
6
|
+
import { InternalRevealCadOptions } from '../../../packages/cad-model';
|
|
7
7
|
/**
|
|
8
8
|
* @property logMetrics Might be used to disable usage statistics.
|
|
9
9
|
* @property nodeAppearanceProvider Style node by tree-index.
|
|
@@ -14,34 +14,12 @@ export declare type RevealOptions = {
|
|
|
14
14
|
renderOptions?: RenderOptions;
|
|
15
15
|
continuousModelStreaming?: boolean;
|
|
16
16
|
internal?: {
|
|
17
|
-
|
|
18
|
-
lod: string;
|
|
19
|
-
data: SectorGeometry | SectorQuads;
|
|
20
|
-
}) => void;
|
|
21
|
-
sectorCuller?: SectorCuller;
|
|
17
|
+
cad?: InternalRevealCadOptions;
|
|
22
18
|
};
|
|
23
19
|
};
|
|
24
|
-
export interface GeometryFilter {
|
|
25
|
-
/**
|
|
26
|
-
* The bounds to load geometry within. By default this box is in CDF coordinate space which
|
|
27
|
-
* will be transformed into coordinates relative to the model using the the model transformation
|
|
28
|
-
* which can be specified using {@link https://docs.cognite.com/api/v1/#operation/update3DRevisions |the CDF API},
|
|
29
|
-
* or set in {@link https://fusion.cognite.com/ |Cognite Fusion}.
|
|
30
|
-
* @see {@link isBoundingBoxInModelCoordinates}.
|
|
31
|
-
*/
|
|
32
|
-
boundingBox?: THREE.Box3;
|
|
33
|
-
/**
|
|
34
|
-
* When set, the geometry filter {@link boundingBox} will be considered to be in "Reveal/ThreeJS space".
|
|
35
|
-
* Rather than CDF space which is the default. When using Reveal space, the model transformation
|
|
36
|
-
* which can be specified using {@link https://docs.cognite.com/api/v1/#operation/update3DRevisions |the CDF API},
|
|
37
|
-
* or set in {@link https://fusion.cognite.com/ |Cognite Fusion}.
|
|
38
|
-
*/
|
|
39
|
-
isBoundingBoxInModelCoordinates?: boolean;
|
|
40
|
-
}
|
|
41
20
|
/**
|
|
42
21
|
* Handler for events about data being loaded.
|
|
43
22
|
*/
|
|
44
23
|
export declare type LoadingStateChangeListener = (loadingState: LoadingState) => any;
|
|
45
|
-
export
|
|
24
|
+
export { PotreePointShape, PotreePointColorType, PotreePointSizeType, WellKnownAsprsPointClassCodes } from '../../../packages/pointclouds';
|
|
46
25
|
export * from './migration/types';
|
|
47
|
-
export { SupportedModelTypes } from '../datamodels/base';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright 2021 Cognite AS
|
|
3
3
|
*/
|
|
4
|
-
export { worldToViewportCoordinates, worldToNormalizedViewportCoordinates } from '
|
|
5
|
-
export {
|
|
6
|
-
export { assertNever, EventTrigger } from '../../../packages/utilities';
|
|
7
|
-
export { LoadingState } from '../../../packages/cad-geometry-loaders';
|
|
4
|
+
export { assertNever, EventTrigger, worldToViewportCoordinates, worldToNormalizedViewportCoordinates } from '../../../packages/utilities';
|
|
5
|
+
export { LoadingState } from '../../../packages/model-base';
|
|
8
6
|
export { LocalModelIdentifier, CdfModelIdentifier } from '../../../packages/modeldata-api';
|
package/extensions/datasource.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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=
|
|
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={}));
|
|
@@ -8,10 +8,7 @@
|
|
|
8
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 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(21);
|
|
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}
|
|
@@ -26,5 +23,5 @@ 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
|
|
|
26
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","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,OAC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W,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 = 75);\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":""}
|
|
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,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":"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
|
@@ -5,5 +5,9 @@
|
|
|
5
5
|
* @module @cognite/reveal
|
|
6
6
|
*/
|
|
7
7
|
export * from './core/src/index';
|
|
8
|
-
export { CameraControlsOptions, DefaultCameraManager,
|
|
8
|
+
export { CameraControlsOptions, DefaultCameraManager, CameraManagerHelper, CameraManager, CameraState, ComboControls, CameraChangeDelegate } from './packages/camera-manager';
|
|
9
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, SceneRenderedDelegate, PointerEventDelegate, DisposedDelegate } from './packages/utilities';
|
|
12
|
+
export { Cognite3DModel, BoundingBoxClipper, GeometryFilter, WellKnownUnit } from './packages/cad-model';
|
|
13
|
+
export { CognitePointCloudModel } from './packages/pointclouds';
|