@cognite/reveal 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +24 -3
  2. package/core/src/internals.d.ts +2 -2
  3. package/core/src/public/RevealManager.d.ts +8 -17
  4. package/core/src/public/createRevealManager.d.ts +5 -4
  5. package/core/src/public/migration/Cognite3DViewer.d.ts +29 -16
  6. package/core/src/public/migration/renderOptionsHelpers.d.ts +29 -0
  7. package/core/src/public/migration/types.d.ts +2 -30
  8. package/core/src/public/types.d.ts +6 -1
  9. package/core/src/storage/RevealManagerHelper.d.ts +7 -6
  10. package/eptBinaryDecoder.worker.map +1 -0
  11. package/extensions/datasource.js +6 -6
  12. package/extensions/datasource.map +1 -1
  13. package/index.d.ts +2 -2
  14. package/index.js +216 -168
  15. package/index.map +1 -1
  16. package/package.json +5 -4
  17. package/packages/cad-geometry-loaders/index.d.ts +3 -0
  18. package/packages/{cad-model → cad-geometry-loaders}/src/CadManager.d.ts +2 -4
  19. package/packages/cad-geometry-loaders/src/CadModelUpdateHandler.d.ts +1 -1
  20. package/packages/{cad-model → cad-geometry-loaders}/src/InternalRevealCadOptions.d.ts +0 -0
  21. package/packages/{cad-model → cad-geometry-loaders}/src/createCadManager.d.ts +2 -2
  22. package/packages/cad-geometry-loaders/src/sector/culling/OrderSectorsByVisibilityCoverage.d.ts +3 -3
  23. package/packages/cad-geometry-loaders/src/sector/culling/RenderAlreadyLoadedGeometryProvider.d.ts +5 -3
  24. package/packages/cad-geometry-loaders/src/sector/culling/createV8SectorCuller.d.ts +2 -2
  25. package/packages/cad-geometry-loaders/src/sector/culling/types.d.ts +1 -1
  26. package/packages/cad-model/index.d.ts +6 -9
  27. package/packages/cad-model/src/CadModelFactory.d.ts +3 -2
  28. package/packages/{rendering/src → cad-model/src/batching}/GeometryBatchingManager.d.ts +2 -2
  29. package/packages/{rendering/src → cad-model/src/batching}/InstancedMeshManager.d.ts +2 -2
  30. package/packages/cad-model/src/picking/PickingHandler.d.ts +35 -0
  31. package/packages/cad-model/src/types.d.ts +59 -0
  32. package/packages/cad-model/src/{BoundingBoxClipper.d.ts → utilities/BoundingBoxClipper.d.ts} +0 -0
  33. package/packages/{model-base/src → cad-model/src/utilities}/NodeIdAndTreeIndexMaps.d.ts +0 -0
  34. package/packages/cad-model/src/{callActionWithIndicesAsync.d.ts → utilities/callActionWithIndicesAsync.d.ts} +0 -0
  35. package/packages/{rendering/src/sector → cad-model/src/wrappers}/CadNode.d.ts +2 -5
  36. package/packages/cad-model/src/{Cognite3DModel.d.ts → wrappers/Cognite3DModel.d.ts} +4 -4
  37. package/packages/cad-parsers/src/cad/primitiveGeometries.d.ts +3 -3
  38. package/packages/cad-styling/src/NodeAppearance.d.ts +6 -6
  39. package/packages/camera-manager/src/CameraManager.d.ts +2 -1
  40. package/packages/camera-manager/src/ComboControls.d.ts +1 -1
  41. package/packages/camera-manager/src/DefaultCameraManager.d.ts +1 -1
  42. package/packages/camera-manager/src/types.d.ts +5 -14
  43. package/packages/model-base/index.d.ts +0 -1
  44. package/packages/modeldata-api/index.d.ts +1 -1
  45. package/packages/modeldata-api/src/CdfModelDataProvider.d.ts +1 -2
  46. package/packages/modeldata-api/src/LocalModelDataProvider.d.ts +0 -2
  47. package/packages/modeldata-api/src/LocalModelMetadataProvider.d.ts +2 -2
  48. package/packages/modeldata-api/src/types.d.ts +1 -5
  49. package/packages/pointclouds/index.d.ts +3 -1
  50. package/packages/pointclouds/src/CognitePointCloudModel.d.ts +12 -1
  51. package/packages/pointclouds/src/PointCloudFactory.d.ts +9 -5
  52. package/packages/pointclouds/src/PointCloudManager.d.ts +13 -2
  53. package/packages/pointclouds/src/PointCloudNode.d.ts +11 -4
  54. package/packages/pointclouds/src/PotreeGroupWrapper.d.ts +8 -1
  55. package/packages/pointclouds/src/PotreeNodeWrapper.d.ts +8 -10
  56. package/packages/pointclouds/src/PotreePnextLoader.d.ts +4 -0
  57. package/packages/pointclouds/src/createPointClassKey.d.ts +5 -0
  58. package/packages/pointclouds/src/createPointCloudManager.d.ts +2 -1
  59. package/packages/pointclouds/src/potree-three-loader/Potree.d.ts +46 -0
  60. package/packages/pointclouds/src/potree-three-loader/geometry/IPointCloudTreeGeometry.d.ts +10 -0
  61. package/packages/pointclouds/src/potree-three-loader/geometry/IPointCloudTreeGeometryNode.d.ts +11 -0
  62. package/packages/pointclouds/src/potree-three-loader/geometry/PointCloudEptGeometry.d.ts +50 -0
  63. package/packages/pointclouds/src/potree-three-loader/geometry/PointCloudEptGeometryNode.d.ts +63 -0
  64. package/packages/pointclouds/src/potree-three-loader/geometry/translationUtils.d.ts +7 -0
  65. package/packages/pointclouds/src/potree-three-loader/index.d.ts +10 -0
  66. package/packages/pointclouds/src/potree-three-loader/loading/EptBinaryLoader.d.ts +12 -0
  67. package/packages/pointclouds/src/potree-three-loader/loading/EptLoader.d.ts +5 -0
  68. package/packages/pointclouds/src/potree-three-loader/loading/ILoader.d.ts +4 -0
  69. package/packages/pointclouds/src/potree-three-loader/loading/globalLoadingCounter.d.ts +5 -0
  70. package/packages/pointclouds/src/potree-three-loader/rendering/PointCloudMaterial.d.ts +203 -0
  71. package/packages/pointclouds/src/potree-three-loader/rendering/classification.d.ts +2 -0
  72. package/packages/pointclouds/src/potree-three-loader/rendering/clipping.d.ts +12 -0
  73. package/packages/pointclouds/src/potree-three-loader/rendering/constants.d.ts +14 -0
  74. package/packages/pointclouds/src/potree-three-loader/rendering/enums.d.ts +46 -0
  75. package/packages/pointclouds/src/potree-three-loader/rendering/features.d.ts +6 -0
  76. package/packages/pointclouds/src/potree-three-loader/rendering/gradients/SpectralGradient.d.ts +2 -0
  77. package/packages/pointclouds/src/potree-three-loader/rendering/index.d.ts +5 -0
  78. package/packages/pointclouds/src/potree-three-loader/rendering/texture-generation.d.ts +5 -0
  79. package/packages/pointclouds/src/potree-three-loader/rendering/types.d.ts +10 -0
  80. package/packages/pointclouds/src/potree-three-loader/tree/IPointCloudTreeNode.d.ts +7 -0
  81. package/packages/pointclouds/src/potree-three-loader/tree/IPointCloudTreeNodeBase.d.ts +18 -0
  82. package/packages/pointclouds/src/potree-three-loader/tree/PointAttributes.d.ts +52 -0
  83. package/packages/pointclouds/src/potree-three-loader/tree/PointCloudOctree.d.ts +48 -0
  84. package/packages/pointclouds/src/potree-three-loader/tree/PointCloudOctreeNode.d.ts +27 -0
  85. package/packages/pointclouds/src/potree-three-loader/tree/PointCloudOctreePicker.d.ts +11 -0
  86. package/packages/pointclouds/src/potree-three-loader/tree/PointCloudOctreePickerHelper.d.ts +57 -0
  87. package/packages/pointclouds/src/potree-three-loader/tree/PointCloudTree.d.ts +6 -0
  88. package/packages/pointclouds/src/potree-three-loader/types/IPotree.d.ts +11 -0
  89. package/packages/pointclouds/src/potree-three-loader/types/IVisibilityUpdateResult.d.ts +18 -0
  90. package/packages/pointclouds/src/potree-three-loader/types/type-predicates.d.ts +6 -0
  91. package/packages/pointclouds/src/potree-three-loader/types/types.d.ts +14 -0
  92. package/packages/pointclouds/src/potree-three-loader/utils/BinaryHeap.d.ts +11 -0
  93. package/packages/pointclouds/src/potree-three-loader/utils/WorkerPool.d.ts +31 -0
  94. package/packages/pointclouds/src/potree-three-loader/utils/async-blocking-queue.d.ts +8 -0
  95. package/packages/pointclouds/src/potree-three-loader/utils/bounds.d.ts +6 -0
  96. package/packages/pointclouds/src/potree-three-loader/utils/box3-helper.d.ts +13 -0
  97. package/packages/pointclouds/src/potree-three-loader/utils/lru.d.ts +32 -0
  98. package/packages/pointclouds/src/potree-three-loader/utils/math.d.ts +1 -0
  99. package/packages/pointclouds/src/potree-three-loader/utils/utils.d.ts +8 -0
  100. package/packages/pointclouds/src/potree-three-loader/version.d.ts +9 -0
  101. package/packages/pointclouds/src/potree-three-loader/workers/eptBinaryDecoder.worker.d.ts +18 -0
  102. package/packages/pointclouds/src/types.d.ts +0 -30
  103. package/packages/rendering/index.d.ts +5 -2
  104. package/packages/rendering/src/RenderPass.d.ts +15 -0
  105. package/packages/rendering/src/RenderPipelineExecutor.d.ts +12 -0
  106. package/packages/rendering/src/RenderPipelineProvider.d.ts +15 -0
  107. package/packages/rendering/src/pipeline-executors/BasicPipelineExecutor.d.ts +11 -0
  108. package/packages/rendering/src/render-passes/GeometryPass.d.ts +16 -0
  109. package/packages/rendering/src/render-passes/PostProcessingPass.d.ts +24 -0
  110. package/packages/rendering/src/render-passes/SSAOPass.d.ts +14 -0
  111. package/packages/rendering/src/render-passes/types.d.ts +31 -0
  112. package/packages/rendering/src/render-pipeline-providers/CadGeometryRenderModePipelineProvider.d.ts +23 -0
  113. package/packages/rendering/src/render-pipeline-providers/CadGeometryRenderPipelineProvider.d.ts +25 -0
  114. package/packages/rendering/src/render-pipeline-providers/DefaultRenderPipelineProvider.d.ts +34 -0
  115. package/packages/rendering/src/render-pipeline-providers/types.d.ts +19 -0
  116. package/packages/rendering/src/rendering/shaders.d.ts +1 -15
  117. package/packages/rendering/src/rendering/types.d.ts +1 -1
  118. package/packages/rendering/src/utilities/renderUtilities.d.ts +26 -0
  119. package/packages/tools/src/AxisView/AxisViewTool.d.ts +0 -1
  120. package/packages/utilities/index.d.ts +4 -0
  121. package/packages/utilities/src/DeferredPromise.d.ts +1 -1
  122. package/packages/utilities/src/SceneHandler.d.ts +21 -0
  123. package/packages/utilities/src/WebGLRendererStateHelper.d.ts +12 -0
  124. package/packages/utilities/src/device.d.ts +10 -0
  125. package/packages/utilities/src/events/InputHandler.d.ts +1 -5
  126. package/packages/utilities/src/events/index.d.ts +1 -0
  127. package/packages/utilities/src/events/types.d.ts +27 -0
  128. package/packages/utilities/src/isMobileOrTablet.d.ts +1 -0
  129. package/packages/utilities/src/three/createFullScreenTriangleGeometry.d.ts +5 -0
  130. package/tools.js +62 -46
  131. package/tools.map +1 -1
  132. package/packages/cad-model/src/CadModelSectorLoadStatistics.d.ts +0 -38
  133. package/packages/cad-model/src/GeometryFilter.d.ts +0 -20
  134. package/packages/cad-model/src/WellKnownUnit.d.ts +0 -7
  135. package/packages/cad-model/src/picking.d.ts +0 -28
  136. package/packages/rendering/src/rendering/EffectRenderManager.d.ts +0 -99
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({ appId });
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
 
@@ -4,7 +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 { CadModelSectorLoadStatistics, intersectCadNodes } from '../../packages/cad-model';
8
- export { PotreePointShape, PotreePointColorType, PotreePointSizeType, WellKnownAsprsPointClassCodes, PotreeNodeWrapper, PotreeGroupWrapper, PointCloudNode } from '../../packages/pointclouds';
7
+ export { CadModelSectorLoadStatistics, PickingHandler } from '../../packages/cad-model';
8
+ export { PotreePointShape, PotreePointColorType, PotreePointSizeType, WellKnownAsprsPointClassCodes, PotreeNodeWrapper, PotreeGroupWrapper, PointCloudNode, Potree, PointCloudOctree } from '../../packages/pointclouds';
9
9
  import * as utilities from './utilities';
10
10
  export { utilities };
@@ -3,11 +3,11 @@
3
3
  */
4
4
  import * as THREE from 'three';
5
5
  import { LoadingStateChangeListener, PointCloudBudget } from './types';
6
- import { CadManager, GeometryFilter, CadModelSectorLoadStatistics } from '../../../packages/cad-model';
6
+ import { GeometryFilter, CadModelSectorLoadStatistics, CadNode } from '../../../packages/cad-model';
7
7
  import { PointCloudManager, PointCloudNode } from '../../../packages/pointclouds';
8
- import { CadModelBudget } from '../../../packages/cad-geometry-loaders';
8
+ import { CadManager, CadModelBudget } from '../../../packages/cad-geometry-loaders';
9
9
  import { NodeAppearanceProvider } from '../../../packages/cad-styling';
10
- import { RenderOptions, EffectRenderManager, CadNode, RenderMode } from '../../../packages/rendering';
10
+ import { RenderMode, RenderPipelineExecutor, CadMaterialManager, RenderPipelineProvider } from '../../../packages/rendering';
11
11
  import { ModelIdentifier } from '../../../packages/modeldata-api';
12
12
  export declare type AddCadModelOptions = {
13
13
  nodeAppearanceProvider?: NodeAppearanceProvider;
@@ -16,20 +16,19 @@ export declare type AddCadModelOptions = {
16
16
  export declare class RevealManager {
17
17
  private readonly _cadManager;
18
18
  private readonly _pointCloudManager;
19
- private readonly _effectRenderManager;
19
+ private readonly _pipelineExecutor;
20
+ private readonly _renderPipeline;
20
21
  private readonly _lastCamera;
21
22
  private _isDisposed;
22
23
  private readonly _subscriptions;
23
24
  private readonly _events;
24
25
  private readonly _updateSubject;
25
- constructor(cadManager: CadManager, renderManager: EffectRenderManager, pointCloudManager: PointCloudManager);
26
+ private readonly _materialManager;
27
+ constructor(cadManager: CadManager, pointCloudManager: PointCloudManager, pipelineExecutor: RenderPipelineExecutor, renderPipeline: RenderPipelineProvider, materialManager: CadMaterialManager);
26
28
  dispose(): void;
27
29
  requestRedraw(): void;
28
30
  resetRedraw(): void;
29
- get debugRenderTiming(): boolean;
30
- set debugRenderTiming(enable: boolean);
31
- get renderOptions(): RenderOptions;
32
- set renderOptions(options: RenderOptions);
31
+ get materialManager(): CadMaterialManager;
33
32
  get needsRedraw(): boolean;
34
33
  update(camera: THREE.PerspectiveCamera): void;
35
34
  get cadBudget(): CadModelBudget;
@@ -44,18 +43,10 @@ export declare class RevealManager {
44
43
  on(event: 'loadingStateChanged', listener: LoadingStateChangeListener): void;
45
44
  off(event: 'loadingStateChanged', listener: LoadingStateChangeListener): void;
46
45
  render(camera: THREE.PerspectiveCamera): void;
47
- /**
48
- * Overrides the default rendering target.
49
- * @param target New rendering target.
50
- * @param autoSetTargetSize Auto size target to fit canvas.
51
- */
52
- setRenderTarget(target: THREE.WebGLRenderTarget | null, autoSetTargetSize?: boolean): void;
53
46
  addModel(type: 'cad', modelIdentifier: ModelIdentifier, options?: AddCadModelOptions): Promise<CadNode>;
54
47
  addModel(type: 'pointcloud', modelIdentifier: ModelIdentifier): Promise<PointCloudNode>;
55
48
  removeModel(type: 'cad', model: CadNode): void;
56
49
  removeModel(type: 'pointcloud', model: PointCloudNode): void;
57
- addUiObject(object: THREE.Object3D, screenPos: THREE.Vector2, size: THREE.Vector2): void;
58
- removeUiObject(object: THREE.Object3D): void;
59
50
  private notifyLoadingStateChanged;
60
51
  private initLoadingStateObserver;
61
52
  }
@@ -5,19 +5,20 @@ import * as THREE from 'three';
5
5
  import { RevealOptions } from './types';
6
6
  import { RevealManager } from './RevealManager';
7
7
  import { CogniteClient } from '@cognite/sdk';
8
+ import { SceneHandler } from '../../../packages/utilities';
8
9
  /**
9
10
  * Used to create an instance of reveal manager that works with localhost.
10
11
  * @param renderer
11
- * @param scene
12
+ * @param sceneHandler
12
13
  * @param revealOptions
13
14
  * @returns RevealManager instance.
14
15
  */
15
- export declare function createLocalRevealManager(renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions?: RevealOptions): RevealManager;
16
+ export declare function createLocalRevealManager(renderer: THREE.WebGLRenderer, sceneHandler: SceneHandler, revealOptions?: RevealOptions): RevealManager;
16
17
  /**
17
18
  * Used to create an instance of reveal manager that works with the CDF.
18
19
  * @param client
19
20
  * @param renderer
20
- * @param scene
21
+ * @param sceneHandler
21
22
  * @param revealOptions
22
23
  */
23
- export declare function createCdfRevealManager(client: CogniteClient, renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions?: RevealOptions): RevealManager;
24
+ export declare function createCdfRevealManager(client: CogniteClient, renderer: THREE.WebGLRenderer, sceneHandler: SceneHandler, revealOptions?: RevealOptions): RevealManager;
@@ -2,13 +2,13 @@
2
2
  * Copyright 2021 Cognite AS
3
3
  */
4
4
  import * as THREE from 'three';
5
+ import { PointerEventDelegate, SceneRenderedDelegate, DisposedDelegate } from '../../../../packages/utilities';
5
6
  import { Cognite3DModel } from '../../../../packages/cad-model';
6
7
  import { PointCloudBudget, CognitePointCloudModel } from '../../../../packages/pointclouds';
7
- import { AddModelOptions, Cognite3DViewerOptions, Intersection, CameraChangeDelegate, PointerEventDelegate, CadModelBudget } from './types';
8
- import { DisposedDelegate, SceneRenderedDelegate } from '../types';
8
+ import { AddModelOptions, Cognite3DViewerOptions, Intersection, CadModelBudget } from './types';
9
9
  import { IntersectionFromPixelOptions } from '../..';
10
10
  import { ViewerState } from '../../utilities/ViewStateHelper';
11
- import { CameraManager } from '../../../../packages/camera-manager';
11
+ import { CameraManager, CameraChangeDelegate } from '../../../../packages/camera-manager';
12
12
  import { SupportedModelTypes, CogniteModelBase } from '../../../../packages/model-base';
13
13
  /**
14
14
  * @example
@@ -41,12 +41,13 @@ export declare class Cognite3DViewer {
41
41
  private readonly _cdfSdkClient;
42
42
  private readonly _dataSource;
43
43
  private readonly camera;
44
- private readonly scene;
44
+ private readonly _sceneHandler;
45
45
  private readonly _cameraManager;
46
46
  private readonly _subscription;
47
47
  private readonly _revealManagerHelper;
48
48
  private readonly _domElement;
49
49
  private readonly _renderer;
50
+ private readonly _pickingHandler;
50
51
  private readonly _boundAnimate;
51
52
  private readonly _events;
52
53
  private readonly _mouseHandler;
@@ -142,8 +143,26 @@ export declare class Cognite3DViewer {
142
143
  * ```
143
144
  */
144
145
  off(event: 'click' | 'hover', callback: PointerEventDelegate): void;
146
+ /**
147
+ * @example
148
+ * ```js
149
+ * viewer.off('cameraChange', onCameraChange);
150
+ * ```
151
+ */
145
152
  off(event: 'cameraChange', callback: CameraChangeDelegate): void;
153
+ /**
154
+ * @example
155
+ * ```js
156
+ * viewer.off('sceneRendered', updateStats);
157
+ * ```
158
+ */
146
159
  off(event: 'sceneRendered', callback: SceneRenderedDelegate): void;
160
+ /**
161
+ * @example
162
+ * ```js
163
+ * viewer.off('disposed', clearAll);
164
+ * ```
165
+ */
147
166
  off(event: 'disposed', callback: DisposedDelegate): void;
148
167
  get cameraManager(): CameraManager;
149
168
  /**
@@ -262,17 +281,6 @@ export declare class Cognite3DViewer {
262
281
  * ```
263
282
  */
264
283
  removeObject3D(object: THREE.Object3D): void;
265
- /**
266
- * Add an object that will be considered a UI object. It will be rendered in the last stage and with orthographic projection.
267
- * @param object
268
- * @param screenPos Screen space position of object (in pixels).
269
- * @param size Pixel width and height of the object.
270
- */
271
- addUiObject(object: THREE.Object3D, screenPos: THREE.Vector2, size: THREE.Vector2): void;
272
- /** Removes the UI object from the viewer.
273
- * @param object
274
- */
275
- removeUiObject(object: THREE.Object3D): void;
276
284
  /**
277
285
  * Sets the color used as the clear color of the renderer.
278
286
  * @param color
@@ -467,7 +475,12 @@ export declare class Cognite3DViewer {
467
475
  * );
468
476
  * ```
469
477
  */
470
- getIntersectionFromPixel(offsetX: number, offsetY: number, options?: IntersectionFromPixelOptions): Promise<null | Intersection>;
478
+ getIntersectionFromPixel(offsetX: number, offsetY: number): Promise<null | Intersection>;
479
+ /**
480
+ * @deprecated Since 3.1 options argument have no effect.
481
+ * */
482
+ getIntersectionFromPixel(offsetX: number, offsetY: number, options: IntersectionFromPixelOptions): Promise<null | Intersection>;
483
+ /** @private */
471
484
  private getModels;
472
485
  /**
473
486
  * Creates a helper for managing viewer state.
@@ -0,0 +1,29 @@
1
+ /*!
2
+ * Copyright 2022 Cognite AS
3
+ */
4
+ import { AntiAliasingMode, SsaoParameters } from '../../../../packages/rendering';
5
+ import { DeviceDescriptor } from '../../../../packages/utilities';
6
+ import { PropType } from '../../utilities/reflection';
7
+ import { Cognite3DViewerOptions } from './types';
8
+ declare type AntiAliasingHintOption = NonNullable<PropType<Cognite3DViewerOptions, 'antiAliasingHint'>>;
9
+ declare type SsaoQualityHintOption = PropType<Cognite3DViewerOptions, 'ssaoQualityHint'>;
10
+ /**
11
+ * Determines anti-aliasing mode based on the mode requested and the device in question.
12
+ * For mobile and tablets MSAA is disabled. FXAA is supported on all devices.
13
+ * @param modeHint Mode as provided in options to the viewer.
14
+ * @param device Descriptor for current device.
15
+ * @returns Actual anti-aliasing mode to initialize the renderer with.
16
+ */
17
+ export declare function determineAntiAliasingMode(modeHint: AntiAliasingHintOption | undefined, device: DeviceDescriptor): {
18
+ antiAliasing: AntiAliasingMode;
19
+ multiSampleCount: number;
20
+ };
21
+ /**
22
+ * Determines SSAO mode based on the mode requested and the device in question.
23
+ * For mobile and tablets SSAO is disabled.
24
+ * @param qualityHint Mode as provided in options to the viewer.
25
+ * @param device Descriptor for current device.
26
+ * @returns Actual SSAO mode to initialize viewer with.
27
+ */
28
+ export declare function determineSsaoRenderParameters(qualityHint: SsaoQualityHintOption, device: DeviceDescriptor): SsaoParameters;
29
+ export {};
@@ -154,46 +154,18 @@ export declare type Intersection = CadIntersection | PointCloudIntersection;
154
154
  * @module @cognite/reveal
155
155
  */
156
156
  export { CameraConfiguration } from '../../../../packages/utilities';
157
- /**
158
- * Delegate for pointer events.
159
- * @module @cognite/reveal
160
- * @see {@link Cognite3DViewer.on}.
161
- */
162
- export declare type PointerEventDelegate = (event: {
163
- offsetX: number;
164
- offsetY: number;
165
- }) => void;
166
- /**
167
- * Delegate for camera update events.
168
- * @module @cognite/reveal
169
- * @see {@link Cognite3DViewer.on}.
170
- */
171
- export declare type CameraChangeDelegate = (position: THREE.Vector3, target: THREE.Vector3) => void;
172
- /**
173
- * Delegate for disposal events.
174
- */
175
- export declare type DisposedDelegate = () => void;
176
- /**
177
- * Delegate for rendering events.
178
- * @module @cognite/reveal
179
- * @see {@link Cognite3DViewer.on}.
180
- */
181
- export declare type SceneRenderedDelegate = (event: {
182
- frameNumber: number;
183
- renderTime: number;
184
- renderer: THREE.WebGLRenderer;
185
- camera: THREE.PerspectiveCamera;
186
- }) => void;
187
157
  export * from './NotSupportedInMigrationWrapperError';
188
158
  export { CadModelBudget, PointCloudBudget };
189
159
  /**
190
160
  * Options to control how {@link Cognite3DViewer.getIntersectionFromPixel} behaves.
161
+ * @deprecated Since 3.1 these options have no effect.
191
162
  */
192
163
  export interface IntersectionFromPixelOptions {
193
164
  /**
194
165
  * Threshold (in meters) for how close a point must be an intersection
195
166
  * ray for it to be considered an intersection for point clouds. Defaults
196
167
  * to 0.05.
168
+ * @deprecated Since 3.1, threshold doesn't affect picking because of new, GPU based method.
197
169
  */
198
170
  pointIntersectionThreshold?: number;
199
171
  }
@@ -1,9 +1,10 @@
1
1
  /*!
2
2
  * Copyright 2021 Cognite AS
3
3
  */
4
+ import * as THREE from 'three';
4
5
  import { LoadingState } from '../../../packages/model-base';
5
6
  import { RenderOptions } from '../../../packages/rendering';
6
- import { InternalRevealCadOptions } from '../../../packages/cad-model';
7
+ import { InternalRevealCadOptions } from '../../../packages/cad-geometry-loaders';
7
8
  /**
8
9
  * @property logMetrics Might be used to disable usage statistics.
9
10
  * @property nodeAppearanceProvider Style node by tree-index.
@@ -13,6 +14,10 @@ export declare type RevealOptions = {
13
14
  logMetrics?: boolean;
14
15
  renderOptions?: RenderOptions;
15
16
  continuousModelStreaming?: boolean;
17
+ outputRenderTarget?: {
18
+ target: THREE.WebGLRenderTarget;
19
+ autoSize?: boolean;
20
+ };
16
21
  internal?: {
17
22
  cad?: InternalRevealCadOptions;
18
23
  };
@@ -6,8 +6,9 @@ import { AddModelOptions } from '../public/migration/types';
6
6
  import { RevealOptions } from '../public/types';
7
7
  import { PointCloudNode, RevealManager } from '../internals';
8
8
  import { DataSource } from '../../../packages/data-source';
9
- import { CadNode } from '../../../packages/rendering';
9
+ import { SceneHandler } from '../../../packages/utilities';
10
10
  import { CogniteClient } from '@cognite/sdk';
11
+ import { CadNode } from '../../../packages/cad-model';
11
12
  /**
12
13
  * Helper for {@link RevealManager} for creating a uniform interface for
13
14
  * working with instances that fetch models from CDF or instances that fetch
@@ -23,19 +24,19 @@ export declare class RevealManagerHelper {
23
24
  * Create helper for RevealManager that loads models from local storage. This is only
24
25
  * meant for use in debugging and development.
25
26
  * @param renderer
26
- * @param scene
27
+ * @param sceneHandler
27
28
  * @param revealOptions
28
29
  */
29
- static createLocalHelper(renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions: RevealOptions): RevealManagerHelper;
30
+ static createLocalHelper(renderer: THREE.WebGLRenderer, sceneHandler: SceneHandler, revealOptions: RevealOptions): RevealManagerHelper;
30
31
  /**
31
32
  * Creates a helper for RevealManager that loads models from CDF.
32
33
  * @param renderer
33
- * @param scene
34
+ * @param sceneHandler
34
35
  * @param revealOptions
35
36
  * @param sdkClient
36
37
  */
37
- static createCdfHelper(renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions: RevealOptions, sdkClient: CogniteClient): RevealManagerHelper;
38
- static createCustomDataSourceHelper(renderer: THREE.WebGLRenderer, scene: THREE.Scene, revealOptions: RevealOptions, dataSource: DataSource): RevealManagerHelper;
38
+ static createCdfHelper(renderer: THREE.WebGLRenderer, sceneHandler: SceneHandler, revealOptions: RevealOptions, sdkClient: CogniteClient): RevealManagerHelper;
39
+ static createCustomDataSourceHelper(renderer: THREE.WebGLRenderer, sceneHandler: SceneHandler, revealOptions: RevealOptions, dataSource: DataSource): RevealManagerHelper;
39
40
  get revealManager(): RevealManager;
40
41
  /**
41
42
  * Adds a local CAD model.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./packages/pointclouds/src/potree-three-loader/workers/eptBinaryDecoder.worker.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","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","ctx","self","onmessage","arg0","event","buffer","data","view","DataView","schema","scale","offset","mins","dimensions","reduce","getExtractor","length","size","dimOffset","type","getInt8","getInt16","getInt32","Error","getUint8","getUint16","getUint32","getFloat32","getFloat64","str","JSON","stringify","pointSize","numPoints","byteLength","rgbBuffer","intensityBuffer","classificationBuffer","returnNumberBuffer","numberOfReturnsBuffer","pointSourceIdBuffer","rgb","intensity","classification","returnNumber","numberOfReturns","pointSourceId","rgbExtractor","intensityExtractor","classificationExtractor","returnNumberExtractor","numberOfReturnsExtractor","pointSourceIdExtractor","twoByteColor","xyzBuffer","ArrayBuffer","xyz","Float32Array","xyzExtractor","g","b","pos","Uint8Array","Uint16Array","mean","bounds","min","Number","MAX_VALUE","max","x","y","z","Math","indicesBuffer","indices","Uint32Array","message","tightBoundingBox","position","color","transferables","filter","undefined","postMessage","parseEpt"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,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F,EAAI,GAAKwG,GAGf/B,IACF3D,EAAIiE,EAAc,GAAGc,GACrBF,EAAIZ,EAAc,GAAGc,GACrBD,EAAIb,EAAc,GAAGc,GAEjBR,IACFvE,GAAK,IACL6E,GAAK,IACLC,GAAK,KAGPnB,EAAI,EAAIzE,EAAI,GAAKc,EACjB2D,EAAI,EAAIzE,EAAI,GAAK2F,EACjBlB,EAAI,EAAIzE,EAAI,GAAK4F,GAGflB,IAAWA,EAAU1E,GAAKgF,EAAoBa,IAC9ClB,IAAgBA,EAAe3E,GAAKiF,EAAyBY,IAC7DjB,IAAcA,EAAa5E,GAAKkF,EAAuBW,IACvDhB,IAAiBA,EAAgB7E,GAAKmF,EAA0BU,IAChEf,IAAeA,EAAc9E,GAAKoF,EAAwBS,IAGhE,MAAMa,EAAgB,IAAInB,YAAwB,EAAZtB,GAChC0C,EAAU,IAAIC,YAAYF,GAChC,IAAK,IAAI1G,EAAI,EAAGA,EAAIiE,IAAajE,EAC/B2G,EAAQ3G,GAAKA,EAGf,MAAM6G,EAAyB,CAC7B5C,UAAWA,EACX6C,iBAAkBb,EAClBD,KAAMA,EAENe,SAAUzB,EACV0B,MAAO7C,EACPO,UAAWN,EACXO,eAAgBN,EAChBO,aAAcN,EACdO,gBAAiBN,EACjBO,cAAeN,EACfmC,QAASD,GAOX,MAAMO,EAAgB,CACpBJ,EAAQE,SACRF,EAAQG,MACRH,EAAQnC,UACRmC,EAAQlC,eACRkC,EAAQjC,aACRiC,EAAQhC,gBACRgC,EAAQ/B,cACR+B,EAAQF,SACRO,QAbF,SAAuB7E,GACrB,YAAkB8E,IAAX9E,KAcTL,EAAIoF,YAAYP,EAASI,GArQzBI,CAASlF,IAwQI","file":"eptBinaryDecoder.worker.worker.js","sourcesContent":[" \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 = 0);\n","const ctx: Worker = self as any;\n\nctx.onmessage = function (arg0: any) {\n parseEpt(arg0);\n};\n\nexport type ParsedEptData = {\n numPoints: number;\n tightBoundingBox: { min: number[]; max: number[] };\n mean: number[];\n position: ArrayBuffer;\n color: ArrayBuffer | undefined;\n intensity: ArrayBuffer | undefined;\n classification: ArrayBuffer | undefined;\n returnNumber: ArrayBuffer | undefined;\n numberOfReturns: ArrayBuffer | undefined;\n pointSourceId: ArrayBuffer | undefined;\n indices: ArrayBuffer;\n};\n\ntype SchemaEntry = {\n name: string;\n size: number;\n type: 'signed' | 'unsigned' | 'float';\n};\n\nfunction parseEpt(event: MessageEvent): void {\n const buffer = event.data.buffer;\n const view = new DataView(buffer);\n const schema: SchemaEntry[] = event.data.schema;\n const scale = event.data.scale;\n const offset = event.data.offset;\n const mins = event.data.mins;\n\n const dimensions: Record<string, SchemaEntry> = schema.reduce((p, c) => {\n p[c.name] = c;\n return p;\n }, {} as Record<string, SchemaEntry>);\n\n const dimOffset = (name: string) => {\n let offset = 0;\n for (let i = 0; i < schema.length; ++i) {\n if (schema[i].name === name) return offset;\n offset += schema[i].size;\n }\n return undefined;\n };\n\n function getExtractor(name: string) {\n const offset = dimOffset(name)!;\n const type = dimensions[name].type;\n const size = dimensions[name].size;\n\n if (type == 'signed')\n switch (size) {\n case 1:\n return (p: number) => view.getInt8(p + offset);\n case 2:\n return (p: number) => view.getInt16(p + offset, true);\n case 4:\n return (p: number) => view.getInt32(p + offset, true);\n default:\n throw Error('Unrecognized byte size for \"signed\" numbers');\n }\n if (type == 'unsigned')\n switch (size) {\n case 1:\n return (p: number) => view.getUint8(p + offset);\n case 2:\n return (p: number) => view.getUint16(p + offset, true);\n case 4:\n return (p: number) => view.getUint32(p + offset, true);\n default:\n throw Error('Unrecognized byte size for \"unsigned\" numbers');\n }\n if (type == 'float')\n switch (size) {\n case 4:\n return (p: number) => view.getFloat32(p + offset, true);\n case 8:\n return (p: number) => view.getFloat64(p + offset, true);\n default:\n throw Error('Unrecognized byte size for \"float\" numbers');\n }\n\n const str = JSON.stringify(dimensions[name]);\n throw new Error(`Invalid dimension specification for ${name}: ${str}`);\n }\n\n const pointSize = schema.reduce((p: number, c) => p + c.size, 0);\n const numPoints = buffer.byteLength / pointSize;\n\n let rgbBuffer: ArrayBuffer | undefined;\n let intensityBuffer: ArrayBuffer | undefined;\n let classificationBuffer: ArrayBuffer | undefined;\n let returnNumberBuffer: ArrayBuffer | undefined;\n let numberOfReturnsBuffer: ArrayBuffer | undefined;\n let pointSourceIdBuffer: ArrayBuffer | undefined;\n\n let rgb: Uint8Array | undefined;\n let intensity: Float32Array | undefined;\n let classification: Uint8Array | undefined;\n let returnNumber: Uint8Array | undefined;\n let numberOfReturns: Uint8Array | undefined;\n let pointSourceId: Uint16Array | undefined;\n\n let rgbExtractor: ((name: number) => number)[];\n let intensityExtractor: (name: number) => number;\n let classificationExtractor: (name: number) => number;\n let returnNumberExtractor: (name: number) => number;\n let numberOfReturnsExtractor: (name: number) => number;\n let pointSourceIdExtractor: (name: number) => number;\n\n let twoByteColor = false;\n\n if (!dimensions['X'] || !dimensions['Y'] || !dimensions['Z']) {\n throw Error('Point cloud did not contain position data');\n }\n\n const xyzBuffer = new ArrayBuffer(numPoints * 4 * 3);\n const xyz = new Float32Array(xyzBuffer);\n const xyzExtractor = [getExtractor('X'), getExtractor('Y'), getExtractor('Z')];\n\n if (dimensions['Red'] && dimensions['Green'] && dimensions['Blue']) {\n rgbBuffer = new ArrayBuffer(numPoints * 4);\n rgb = new Uint8Array(rgbBuffer);\n rgbExtractor = [getExtractor('Red'), getExtractor('Green'), getExtractor('Blue')];\n\n let r: number, g: number, b: number, pos: number;\n for (let i = 0; i < numPoints && !twoByteColor; ++i) {\n pos = i * pointSize;\n r = rgbExtractor[0](pos);\n g = rgbExtractor[1](pos);\n b = rgbExtractor[2](pos);\n if (r > 255 || g > 255 || b > 255) twoByteColor = true;\n }\n }\n\n if (dimensions['Intensity']) {\n intensityBuffer = new ArrayBuffer(numPoints * 4);\n intensity = new Float32Array(intensityBuffer);\n intensityExtractor = getExtractor('Intensity');\n }\n\n if (dimensions['Classification']) {\n classificationBuffer = new ArrayBuffer(numPoints);\n classification = new Uint8Array(classificationBuffer);\n classificationExtractor = getExtractor('Classification');\n }\n\n if (dimensions['ReturnNumber']) {\n returnNumberBuffer = new ArrayBuffer(numPoints);\n returnNumber = new Uint8Array(returnNumberBuffer);\n returnNumberExtractor = getExtractor('ReturnNumber');\n }\n\n if (dimensions['NumberOfReturns']) {\n numberOfReturnsBuffer = new ArrayBuffer(numPoints);\n numberOfReturns = new Uint8Array(numberOfReturnsBuffer);\n numberOfReturnsExtractor = getExtractor('NumberOfReturns');\n }\n\n if (dimensions['PointSourceId']) {\n pointSourceIdBuffer = new ArrayBuffer(numPoints * 2);\n pointSourceId = new Uint16Array(pointSourceIdBuffer);\n pointSourceIdExtractor = getExtractor('PointSourceId');\n }\n\n const mean = [0, 0, 0];\n const bounds = {\n min: [Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE],\n max: [-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE]\n };\n\n let x: number;\n let y: number;\n let z: number;\n let r: number;\n let g: number;\n let b: number;\n\n for (let i = 0; i < numPoints; ++i) {\n const pos = i * pointSize;\n if (xyz) {\n x = xyzExtractor[0](pos) * scale.x + offset.x - mins[0];\n y = xyzExtractor[1](pos) * scale.y + offset.y - mins[1];\n z = xyzExtractor[2](pos) * scale.z + offset.z - mins[2];\n\n mean[0] += x / numPoints;\n mean[1] += y / numPoints;\n mean[2] += z / numPoints;\n\n bounds.min[0] = Math.min(bounds.min[0], x);\n bounds.min[1] = Math.min(bounds.min[1], y);\n bounds.min[2] = Math.min(bounds.min[2], z);\n\n bounds.max[0] = Math.max(bounds.max[0], x);\n bounds.max[1] = Math.max(bounds.max[1], y);\n bounds.max[2] = Math.max(bounds.max[2], z);\n\n xyz[3 * i + 0] = x;\n xyz[3 * i + 1] = y;\n xyz[3 * i + 2] = z;\n }\n\n if (rgb) {\n r = rgbExtractor![0](pos);\n g = rgbExtractor![1](pos);\n b = rgbExtractor![2](pos);\n\n if (twoByteColor) {\n r /= 256;\n g /= 256;\n b /= 256;\n }\n\n rgb[4 * i + 0] = r;\n rgb[4 * i + 1] = g;\n rgb[4 * i + 2] = b;\n }\n\n if (intensity) intensity[i] = intensityExtractor!(pos);\n if (classification) classification[i] = classificationExtractor!(pos);\n if (returnNumber) returnNumber[i] = returnNumberExtractor!(pos);\n if (numberOfReturns) numberOfReturns[i] = numberOfReturnsExtractor!(pos);\n if (pointSourceId) pointSourceId[i] = pointSourceIdExtractor!(pos);\n }\n\n const indicesBuffer = new ArrayBuffer(numPoints * 4);\n const indices = new Uint32Array(indicesBuffer);\n for (let i = 0; i < numPoints; ++i) {\n indices[i] = i;\n }\n\n const message: ParsedEptData = {\n numPoints: numPoints,\n tightBoundingBox: bounds,\n mean: mean,\n\n position: xyzBuffer,\n color: rgbBuffer,\n intensity: intensityBuffer,\n classification: classificationBuffer,\n returnNumber: returnNumberBuffer,\n numberOfReturns: numberOfReturnsBuffer,\n pointSourceId: pointSourceIdBuffer,\n indices: indicesBuffer\n };\n\n function assertDefined(buffer: ArrayBuffer | undefined): buffer is ArrayBuffer {\n return buffer !== undefined;\n }\n\n const transferables = [\n message.position,\n message.color,\n message.intensity,\n message.classification,\n message.returnNumber,\n message.numberOfReturns,\n message.pointSourceId,\n message.indices\n ].filter(assertDefined);\n\n ctx.postMessage(message, transferables);\n}\n\nexport default null as any;\n"],"sourceRoot":""}
@@ -1,27 +1,27 @@
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);
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 o in r)("object"==typeof exports?exports:t)[o]=r[o]}}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},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 o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},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=73)}({0:function(t,e){t.exports=require("three")},18:function(t,e){t.exports=require("@cognite/sdk-core")},6:function(t,e,r){"use strict";r.d(e,"a",(function(){return o})),r.d(e,"b",(function(){return n})),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 o{constructor(t){this.client=t,this.authenticationPromise=t.authenticate()}async getBinaryFile(t,e){const r=`${t}/${e}`,o={...this.client.getDefaultRequestHeaders(),Accept:"*/*"};return(await this.fetchWithRetry(r,{headers:o,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 o;for(let n=0;n<r;n++)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!==o&&(o=t)}throw o}}class n{constructor(t,e){this.revealInternalId=Symbol(`${t}/${e}`),this.modelId=t,this.revisionId=e}toString(){return`${n.name} (${String(this.revealInternalId)})`}}var i,a=r(0);
2
2
  /*!
3
3
  * Copyright 2021 Cognite AS
4
4
  */!function(t){t.EptPointCloud="ept-pointcloud",t.RevealCadModel="reveal-directory",t.GltfCadModel="gltf-directory",t.AnyFormat="all-outputs"}(i||(i={}));
5
5
  /*!
6
6
  * Copyright 2021 Cognite AS
7
7
  */
8
- const s=(new a.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function c(t,e){switch(e){case i.RevealCadModel:case i.GltfCadModel:t.premultiply(s);break;case i.EptPointCloud:break;default:throw new Error("Unknown model format '"+e)}}
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:case i.EptPointCloud:t.premultiply(s);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}`}}var l=r(19);
11
+ */class u{constructor(t){this._client=t}async getModelMatrix(t,e){if(!(t instanceof n))throw new Error(`Model must be a ${n.name}, but got ${t.toString()}`);const{modelId:r,revisionId:o}=t,i=await this._client.revisions3D.retrieve(r,o),s=new a.Matrix4;return i.rotation&&s.makeRotationFromEuler(new a.Euler(...i.rotation)),c(s,e),s}async getModelCamera(t){if(!(t instanceof n))throw new Error(`Model must be a ${n.name}, but got ${t.toString()}`);const{modelId:e,revisionId:r}=t,o=await this._client.revisions3D.retrieve(e,r);if(o.camera&&o.camera.position&&o.camera.target){const{position:t,target:e}=o.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 n))throw new Error(`Model must be a ${n.name}, but got ${t.toString()}`);return`${this._client.getBaseUrl()}${this.getRequestPath(e.blobId)}`}async getModelOutputs(t){if(!(t instanceof n))throw new Error(`Model must be a ${n.name}, but got ${t.toString()}`);const{modelId:e,revisionId:r}=t,o=`/api/v1/projects/${this._client.project}/3d/models/${e}/revisions/${r}/outputs`,a=await this._client.get(o,{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(18);
12
12
  /*!
13
13
  * Copyright 2021 Cognite AS
14
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}
15
15
  /*!
16
16
  * Copyright 2021 Cognite AS
17
- */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()}}
17
+ */class f{async getBinaryFile(t,e){return(await d(`${t}/${e}`)).arrayBuffer()}async getJsonFile(t,e){return(await d(`${t}/${e}`)).json()}}
18
18
  /*!
19
19
  * Copyright 2021 Cognite AS
20
20
  */class h{constructor(t){this.revealInternalId=Symbol(t),this.localPath=t}toString(){return`${h.name} (${this.localPath})`}}
21
21
  /*!
22
22
  * Copyright 2021 Cognite AS
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)")}}
23
+ */class m{getModelUri(t){if(!(t instanceof h))throw new Error(`Model must be a ${h.name}, but got ${t.toString()}`);return t.localPath.startsWith("http")?Promise.resolve(t.localPath):Promise.resolve(`${location.origin}/${t.localPath}`)}async getModelMatrix(t,e){if(!(t instanceof h))throw new Error(`Model must be a ${h.name}, but got ${t.toString()}`);const r=new a.Matrix4;return c(r,e),r}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),o=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(o)return[o];throw new Error("Only point cloud or CAD models (version 8 and 9) are supported)")}}
24
24
  /*!
25
25
  * Copyright 2021 Cognite AS
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}))}})}));
26
+ */},73:function(t,e,r){"use strict";r.r(e);var o=r(6);r.d(e,"CdfModelIdentifier",(function(){return o.b})),r.d(e,"File3dFormat",(function(){return o.d}))}})}));
27
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,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,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aS,cACrBwC,SAAU,SAGZ,EAlDoDG,CAAoBL,GAE5E,GAAIhB,EACF,MAAO,CAACA,GAGV,MAAM,IAAIhD,MAAM;;;qCCjDpB","file":"extensions/datasource.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})((typeof self !== 'undefined' ? self : this), function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"https://apps-cdn.cogniteapp.com/@cognite/reveal-parser-worker/1.3.0/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 70);\n","module.exports = require(\"three\");","module.exports = require(\"@cognite/sdk-core\");","/*!\n * Copyright 2021 Cognite AS\n */\nimport { CogniteClient, HttpHeaders } from '@cognite/sdk';\n\nimport { ModelDataProvider } from './types';\n\n/**\n * Provides 3D V2 specific extensions for the standard CogniteClient used by Reveal.\n */\nexport class CdfModelDataProvider implements ModelDataProvider {\n private readonly client: CogniteClient;\n private authenticationPromise: Promise<string | undefined>;\n\n constructor(client: CogniteClient) {\n this.client = client;\n this.authenticationPromise = client.authenticate();\n }\n\n get headers(): HttpHeaders {\n return this.client.getDefaultRequestHeaders();\n }\n\n public async getBinaryFile(baseUrl: string, fileName: string): Promise<ArrayBuffer> {\n const url = `${baseUrl}/${fileName}`;\n const headers = {\n ...this.client.getDefaultRequestHeaders(),\n Accept: '*/*'\n };\n\n const response = await this.fetchWithRetry(url, { headers, method: 'GET' }).catch(_err => {\n throw Error('Could not download binary file');\n });\n return response.arrayBuffer();\n }\n\n async getJsonFile(baseUrl: string, fileName: string): Promise<any> {\n const response = await this.client.get(`${baseUrl}/${fileName}`).catch(_err => {\n throw Error('Could not download Json file');\n });\n return response.data;\n }\n\n private async fetchWithRetry(input: RequestInfo, options: RequestInit, retries: number = 3) {\n let error: Error | undefined;\n for (let i = 0; i < retries; i++) {\n try {\n await this.authenticationPromise;\n\n const response = await fetch(input, options);\n\n // Authentication error\n if (response.status === 401) {\n this.authenticationPromise = this.client.authenticate();\n continue;\n }\n\n return response;\n } catch (err) {\n // Keep first error only\n if (error !== undefined) {\n error = err as Error;\n }\n }\n }\n throw error;\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\nimport { ModelIdentifier } from '..';\n\n/**\n * Identifies a 3D model stored in CDF by the combination of a modelId, a revisionId\n * and a format.\n */\nexport class CdfModelIdentifier implements ModelIdentifier {\n readonly revealInternalId: symbol;\n\n readonly modelId: number;\n readonly revisionId: number;\n\n constructor(modelId: number, revisionId: number) {\n this.revealInternalId = Symbol(`${modelId}/${revisionId}`);\n this.modelId = modelId;\n this.revisionId = revisionId;\n }\n\n public toString(): string {\n return `${CdfModelIdentifier.name} (${String(this.revealInternalId)})`;\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport { HttpHeaders } from '@cognite/sdk-core';\nexport interface JsonFileProvider {\n getJsonFile(baseUrl: string, fileName: string): Promise<any>;\n}\n\nexport interface BinaryFileProvider {\n getBinaryFile(baseUrl: string, fileName: string): Promise<ArrayBuffer>;\n}\n\n/**\n * Provides data for 3D models.\n */\nexport interface ModelDataProvider extends HttpHeadersProvider, JsonFileProvider, BinaryFileProvider {\n /**\n * Download and parse a JSON file and return the resulting struct.\n * @param baseUrl Base URL of the model.\n * @param fileName Filename of JSON file.\n */\n getJsonFile(baseUrl: string, fileName: string): Promise<any>;\n /**\n * Downloads a binary blob.\n * @param baseUrl Base URL of the model.\n * @param fileName Filename of binary file.\n */\n getBinaryFile(baseUrl: string, fileName: string): Promise<ArrayBuffer>;\n}\n\nexport interface HttpHeadersProvider {\n readonly headers: HttpHeaders;\n}\n\nexport enum File3dFormat {\n EptPointCloud = 'ept-pointcloud',\n /**\n * V8 models only due to bug for version checks in Reveal <3.0\n */\n RevealCadModel = 'reveal-directory',\n /**\n * Reveal v9 and above (GLTF based output)\n */\n GltfCadModel = 'gltf-directory',\n AnyFormat = 'all-outputs'\n}\n\nexport interface BlobOutputMetadata {\n blobId: number;\n format: File3dFormat | string;\n version: number;\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport * as THREE from 'three';\n\nimport { File3dFormat } from './types';\n\n// The below is equal to new THREE.Matrix4().makeRotationFromEuler(new THREE.Euler(-Math.PI / 2, 0, 0));\nconst cadFromCdfToThreeMatrix = new THREE.Matrix4().set(1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1);\n\nexport function applyDefaultModelTransformation(matrix: THREE.Matrix4, format: File3dFormat | string): void {\n switch (format) {\n case File3dFormat.RevealCadModel:\n case File3dFormat.GltfCadModel:\n matrix.premultiply(cadFromCdfToThreeMatrix);\n break;\n\n case File3dFormat.EptPointCloud:\n // No action, identity transform\n break;\n\n default:\n throw new Error(`Unknown model format '${format}`);\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\nimport * as THREE from 'three';\nimport { BlobOutputMetadata, File3dFormat } from './types';\nimport { ModelMetadataProvider } from './ModelMetadataProvider';\n\nimport { applyDefaultModelTransformation } from './applyDefaultModelTransformation';\n\nimport { CogniteClient } from '@cognite/sdk';\nimport { ItemsResponse } from '@cognite/sdk-core';\nimport { ModelIdentifier } from './ModelIdentifier';\nimport { CdfModelIdentifier } from './CdfModelIdentifier';\n\n// TODO 2020-06-25 larsmoa: Extend CogniteClient.files3d.retrieve() to support subpath instead of\n// using URLs directly. Also add support for listing outputs in the SDK.\nexport class CdfModelMetadataProvider implements ModelMetadataProvider {\n private readonly _client: CogniteClient;\n\n constructor(client: CogniteClient) {\n this._client = client;\n }\n\n public async getModelMatrix(modelIdentifier: ModelIdentifier, format: File3dFormat): Promise<THREE.Matrix4> {\n if (!(modelIdentifier instanceof CdfModelIdentifier)) {\n throw new Error(`Model must be a ${CdfModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n const { modelId, revisionId } = modelIdentifier;\n const model = await this._client.revisions3D.retrieve(modelId, revisionId);\n\n const modelMatrix = new THREE.Matrix4();\n if (model.rotation) {\n modelMatrix.makeRotationFromEuler(new THREE.Euler(...model.rotation));\n }\n applyDefaultModelTransformation(modelMatrix, format);\n return modelMatrix;\n }\n\n public async getModelCamera(\n modelIdentifier: ModelIdentifier\n ): Promise<{ position: THREE.Vector3; target: THREE.Vector3 } | undefined> {\n if (!(modelIdentifier instanceof CdfModelIdentifier)) {\n throw new Error(`Model must be a ${CdfModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n const { modelId, revisionId } = modelIdentifier;\n const model = await this._client.revisions3D.retrieve(modelId, revisionId);\n if (model.camera && model.camera.position && model.camera.target) {\n const { position, target } = model.camera;\n return {\n position: new THREE.Vector3(position[0], position[1], position[2]),\n target: new THREE.Vector3(target[0], target[1], target[2])\n };\n }\n return undefined;\n }\n\n public async getModelUri(modelIdentifier: ModelIdentifier, formatMetadata: BlobOutputMetadata): Promise<string> {\n if (!(modelIdentifier instanceof CdfModelIdentifier)) {\n throw new Error(`Model must be a ${CdfModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n return `${this._client.getBaseUrl()}${this.getRequestPath(formatMetadata.blobId)}`;\n }\n\n public async getModelOutputs(modelIdentifier: ModelIdentifier): Promise<BlobOutputMetadata[]> {\n if (!(modelIdentifier instanceof CdfModelIdentifier)) {\n throw new Error(`Model must be a ${CdfModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n const { modelId, revisionId } = modelIdentifier;\n\n const url = `/api/v1/projects/${this._client.project}/3d/models/${modelId}/revisions/${revisionId}/outputs`;\n\n const response = await this._client.get<ItemsResponse<BlobOutputMetadata>>(url, {\n params: { format: File3dFormat.AnyFormat }\n });\n\n if (response.status === 200) {\n return response.data.items.filter(output => Object.values<string>(File3dFormat).includes(output.format));\n }\n\n throw new Error(`Unexpected response ${response.status} (payload: '${response.data})`);\n }\n\n private getRequestPath(directoryId: number): string {\n return `/api/v1/projects/${this._client.project}/3d/files/${directoryId}`;\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport { Versioned3DFile } from '@cognite/sdk';\n\n// To avoid direct dependency on @cognite/sdk we use sdk-core here for HttpError.\n// that's why it's avoided https://github.com/cognitedata/cdf-hub/pull/687/files#r489204315\nimport { HttpError } from '@cognite/sdk-core';\n\nexport const supportedVersions = [8];\n\nexport function getNewestVersionedFile(files: Versioned3DFile[]): Versioned3DFile {\n return files\n .filter(file => supportedVersions.includes(file.version))\n .reduce((newestFile, file) => (file.version > newestFile.version ? file : newestFile), {\n fileId: -1,\n version: -1\n });\n}\n\nexport async function fetchWithStatusCheck(url: string): Promise<Response> {\n const response = await fetch(url);\n if (!response.ok) {\n const headers: { [key: string]: string } = {};\n response.headers.forEach((key, value) => {\n headers[key] = value;\n });\n throw new HttpError(response.status, response.body, headers);\n }\n return response;\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport { HttpHeaders } from '@cognite/sdk-core';\nimport { ModelDataProvider } from './types';\nimport { fetchWithStatusCheck } from './utilities';\n\nexport class LocalModelDataProvider implements ModelDataProvider {\n get headers(): HttpHeaders {\n return {};\n }\n\n async getBinaryFile(baseUrl: string, fileName: string): Promise<ArrayBuffer> {\n const response = await fetchWithStatusCheck(`${baseUrl}/${fileName}`);\n return response.arrayBuffer();\n }\n\n async getJsonFile(baseUrl: string, fileName: string): Promise<any> {\n const response = await fetchWithStatusCheck(`${baseUrl}/${fileName}`);\n return response.json();\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\nimport { ModelIdentifier } from './ModelIdentifier';\n\n/**\n * Identifies a 3D model by a URL. This implementation is used for testing\n * purposes.\n */\nexport class LocalModelIdentifier implements ModelIdentifier {\n readonly revealInternalId: symbol;\n readonly localPath: string;\n\n constructor(localPath: string) {\n this.revealInternalId = Symbol(localPath);\n this.localPath = localPath;\n }\n\n public toString(): string {\n return `${LocalModelIdentifier.name} (${this.localPath})`;\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\nimport * as THREE from 'three';\n\nimport { applyDefaultModelTransformation } from './applyDefaultModelTransformation';\nimport { LocalModelIdentifier } from './LocalModelIdentifier';\nimport { ModelIdentifier } from './ModelIdentifier';\nimport { ModelMetadataProvider } from './ModelMetadataProvider';\nimport { BlobOutputMetadata, File3dFormat } from './types';\nimport { fetchWithStatusCheck } from './utilities';\n\nexport class LocalModelMetadataProvider implements ModelMetadataProvider {\n getModelUri(modelIdentifier: ModelIdentifier): Promise<string> {\n if (!(modelIdentifier instanceof LocalModelIdentifier)) {\n throw new Error(`Model must be a ${LocalModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n return Promise.resolve(`${location.origin}/${modelIdentifier.localPath}`);\n }\n\n async getModelMatrix(modelIdentifier: ModelIdentifier): Promise<THREE.Matrix4> {\n if (!(modelIdentifier instanceof LocalModelIdentifier)) {\n throw new Error(`Model must be a ${LocalModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n const matrix = new THREE.Matrix4();\n applyDefaultModelTransformation(matrix, File3dFormat.RevealCadModel);\n return matrix;\n }\n\n getModelCamera(\n modelIdentifier: ModelIdentifier\n ): Promise<{ position: THREE.Vector3; target: THREE.Vector3 } | undefined> {\n if (!(modelIdentifier instanceof LocalModelIdentifier)) {\n throw new Error(`Model must be a ${LocalModelIdentifier.name}, but got ${modelIdentifier.toString()}`);\n }\n\n return Promise.resolve(undefined);\n }\n\n async getModelOutputs(modelIdentifier: ModelIdentifier): Promise<BlobOutputMetadata[]> {\n const modelUri = await this.getModelUri(modelIdentifier);\n\n const output = (await getCadOutput(modelUri)) ?? (await getPointCloudOutput(modelUri));\n\n if (output) {\n return [output];\n }\n\n throw new Error(`Only point cloud or CAD models (version 8 and 9) are supported)`);\n\n async function getCadOutput(modelUri: string): Promise<BlobOutputMetadata | undefined> {\n let version: number;\n\n try {\n version = (await (await fetchWithStatusCheck(modelUri + '/scene.json')).json()).version;\n } catch (error) {\n return undefined;\n }\n switch (version) {\n case 8:\n return Promise.resolve({\n blobId: -1,\n format: File3dFormat.RevealCadModel,\n version: 8\n });\n case 9:\n return Promise.resolve({\n blobId: -1,\n format: File3dFormat.GltfCadModel,\n version: 9\n });\n default:\n return undefined;\n }\n }\n\n async function getPointCloudOutput(modelUri: string): Promise<BlobOutputMetadata | undefined> {\n let scene: any;\n\n try {\n scene = await (await fetchWithStatusCheck(modelUri + '/ept.json')).json();\n } catch (error) {\n return undefined;\n }\n\n if (scene) {\n return Promise.resolve({\n blobId: -1,\n format: File3dFormat.EptPointCloud,\n version: -1\n });\n } else {\n return undefined;\n }\n }\n }\n}\n","/*!\n * Copyright 2021 Cognite AS\n */\n\n/**\n * @module @cognite/reveal/extensions/datasource\n */\n\nexport { DataSource } from '../packages/data-source';\nexport { NodesApiClient } from '../packages/nodes-api';\nexport {\n ModelIdentifier,\n CdfModelIdentifier,\n ModelMetadataProvider,\n ModelDataProvider,\n BlobOutputMetadata,\n File3dFormat\n} from '../packages/modeldata-api';\n"],"sourceRoot":""}
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","baseUrl","fileName","url","headers","getDefaultRequestHeaders","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","EptPointCloud","premultiply","_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","startsWith","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,OAAO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AiBoE,EAAgBC,cAE3F,OAAID,EAAgB+B,UAAUC,WAAW,QAChCC,QAAQC,QAAQlC,EAAgB+B,WAElCE,QAAQC,QAAQ,GAAGC,SAASC,UAAUpC,EAAgB+B,aAG/D,qBAAqB/B,EAAkCN,GACrD,KAAMM,aAA2B8B,GAC/B,MAAM,IAAI1D,MAAM,mBAAmB0D,EAAqBlG,iBAAiBoE,EAAgBC,cAG3F,MAAMR,EAAS,IAAI,UAEnB,OADAD,EAAgCC,EAAQC,GACjCD,EAGT,eACEO,GAEA,KAAMA,aAA2B8B,GAC/B,MAAM,IAAI1D,MAAM,mBAAmB0D,EAAqBlG,iBAAiBoE,EAAgBC,cAG3F,OAAOgC,QAAQC,aAAQnD,GAGzB,sBAAsBiB,G,MACpB,MAAMqC,QAAiBnH,KAAKoH,YAAYtC,GAElCoB,EAAuC,QAA7B,QAQhBI,eAA4Ba,GAC1B,IAAIE,EAEJ,IACEA,eAAwBd,EAAqBY,EAAW,gBAAgBR,QAAQU,QAChF,MAAO7D,GACP,OAEF,OAAQ6D,GACN,KAAK,EACH,OAAON,QAAQC,QAAQ,CACrBpB,QAAS,EACTpB,OAAQL,EAAaM,eACrB4C,QAAS,IAEb,KAAK,EACH,OAAON,QAAQC,QAAQ,CACrBpB,QAAS,EACTpB,OAAQL,EAAaO,aACrB2C,QAAS,IAEb,QACE,QA9BgBC,CAAaH,UAAU,cAkC7Cb,eAAmCa,GACjC,IAAII,EAEJ,IACEA,cAAqBhB,EAAqBY,EAAW,cAAcR,OACnE,MAAOnD,GACP,OAGF,OAAI+D,EACKR,QAAQC,QAAQ,CACrBpB,QAAS,EACTpB,OAAQL,EAAaQ,cACrB0C,SAAU,SAGZ,EAlDoDG,CAAoBL,GAE5E,GAAIjB,EACF,MAAO,CAACA,GAGV,MAAM,IAAIhD,MAAM;;;qCCpDpB","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 = 73);\n","module.exports = require(\"three\");","module.exports = require(\"@cognite/sdk-core\");","/*!\n * Copyright 2021 Cognite AS\n */\nimport { CogniteClient } 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 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\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 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 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 case File3dFormat.EptPointCloud:\n matrix.premultiply(cadFromCdfToThreeMatrix);\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 { ModelDataProvider } from './types';\nimport { fetchWithStatusCheck } from './utilities';\n\nexport class LocalModelDataProvider implements ModelDataProvider {\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 if (modelIdentifier.localPath.startsWith('http')) {\n return Promise.resolve(modelIdentifier.localPath);\n }\n return Promise.resolve(`${location.origin}/${modelIdentifier.localPath}`);\n }\n\n async getModelMatrix(modelIdentifier: ModelIdentifier, format: File3dFormat): 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, format);\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":""}