@cognite/reveal 4.0.0-dev.20221220 → 4.0.0-dev.20221222

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.
@@ -8,7 +8,7 @@ import { PointCloudManager, PointCloudNode } from '../../../pointclouds';
8
8
  import { LoadingState } from '../../../model-base';
9
9
  import { CadManager, CadModelBudget } from '../../../cad-geometry-loaders';
10
10
  import { NodeAppearanceProvider } from '../../../cad-styling';
11
- import { RenderMode, RenderPipelineExecutor, CadMaterialManager, RenderPipelineProvider } from '../../../rendering';
11
+ import { RenderMode, RenderPipelineExecutor, CadMaterialManager, RenderPipelineProvider, ResizeHandler } from '../../../rendering';
12
12
  import { CameraManager } from '../../../camera-manager';
13
13
  import { ModelIdentifier } from '../../../data-providers';
14
14
  export type AddCadModelOptions = {
@@ -24,6 +24,7 @@ export declare class RevealManager {
24
24
  private readonly _pointCloudManager;
25
25
  private readonly _pipelineExecutor;
26
26
  private readonly _renderPipeline;
27
+ private readonly _resizeHandler;
27
28
  private _cameraInMotion;
28
29
  private _isDisposed;
29
30
  private readonly _subscriptions;
@@ -32,7 +33,7 @@ export declare class RevealManager {
32
33
  private readonly _cameraManager;
33
34
  private readonly _onCameraChange;
34
35
  private readonly _onCameraStop;
35
- constructor(cadManager: CadManager, pointCloudManager: PointCloudManager, pipelineExecutor: RenderPipelineExecutor, renderPipeline: RenderPipelineProvider, cameraManager: CameraManager);
36
+ constructor(cadManager: CadManager, pointCloudManager: PointCloudManager, pipelineExecutor: RenderPipelineExecutor, renderPipeline: RenderPipelineProvider, resizeHandler: ResizeHandler, cameraManager: CameraManager);
36
37
  dispose(): void;
37
38
  requestRedraw(): void;
38
39
  resetRedraw(): void;
@@ -50,6 +51,8 @@ export declare class RevealManager {
50
51
  get clippingPlanes(): THREE.Plane[];
51
52
  on(event: 'loadingStateChanged', listener: LoadingStateChangeListener): void;
52
53
  off(event: 'loadingStateChanged', listener: LoadingStateChangeListener): void;
54
+ setResolutionThreshold(threshold: number): void;
55
+ setMovingCameraResolutionFactor(factor: number): void;
53
56
  render(camera: THREE.PerspectiveCamera): void;
54
57
  addModel(type: 'cad', modelIdentifier: ModelIdentifier, options?: AddCadModelOptions): Promise<CadNode>;
55
58
  addModel(type: 'pointcloud', modelIdentifier: ModelIdentifier): Promise<PointCloudNode>;
@@ -6,7 +6,8 @@ import { RenderOptions } from '../../../rendering';
6
6
  import { InternalRevealCadOptions } from '../../../cad-geometry-loaders';
7
7
  /**
8
8
  * @property logMetrics Might be used to disable usage statistics.
9
- * @property nodeAppearanceProvider Style node by tree-index.
9
+ * @property movingCameraResolutionFactor Factor with which the resolution (number of screen pixels) is scaled
10
+ * when camera is moving.
10
11
  * @property internal Internals are for internal usage only (like unit-testing).
11
12
  */
12
13
  export type RevealOptions = {
@@ -5,7 +5,7 @@ import * as THREE from 'three';
5
5
  import { PointerEventDelegate, SceneRenderedDelegate, DisposedDelegate, BeforeSceneRenderedDelegate } from '../../../../utilities';
6
6
  import { CogniteCadModel } from '../../../../cad-model';
7
7
  import { PointCloudBudget, CognitePointCloudModel } from '../../../../pointclouds';
8
- import { AddImage360Options, AddModelOptions, Cognite3DViewerOptions, Intersection, CadModelBudget } from './types';
8
+ import { AddImage360Options, AddModelOptions, Cognite3DViewerOptions, Intersection, CadModelBudget, ResolutionOptions } from './types';
9
9
  import { CogniteModel } from '../types';
10
10
  import { ViewerState } from '../../utilities/ViewStateHelper';
11
11
  import { CameraManager, CameraChangeDelegate } from '../../../../camera-manager';
@@ -91,6 +91,12 @@ export declare class Cognite3DViewer {
91
91
  */
92
92
  get models(): CogniteModel[];
93
93
  constructor(options: Cognite3DViewerOptions);
94
+ /**
95
+ * Set options to control resolution of the viewer. This includes
96
+ * settings for max resolution and limiting resolution when moving the camera.
97
+ * @param options Options to apply.
98
+ */
99
+ setResolutionOptions(options: ResolutionOptions): void;
94
100
  /**
95
101
  * Returns reveal version installed.
96
102
  */
@@ -69,6 +69,8 @@ export interface Cognite3DViewerOptions {
69
69
  * To ensure managable performance, Reveal will by default set an upper threshold to limit
70
70
  * the resolution. Setting the {@link Cognite3DViewerOptions.rendererResolutionThreshold} will
71
71
  * set this upper limit of what resolution Reveal will allow.
72
+ *
73
+ * @deprecated Use {@link Cognite3DViewer.setResolutionOptions} instead.
72
74
  */
73
75
  rendererResolutionThreshold?: number;
74
76
  /**
@@ -175,6 +177,29 @@ export type CadIntersection = {
175
177
  */
176
178
  distanceToCamera: number;
177
179
  };
180
+ /**
181
+ * Options to control resolution of the viewer. This includes
182
+ * settings for max resolution and limiting resolution when moving the camera.
183
+ *
184
+ * @module @cognite/reveal
185
+ */
186
+ export type ResolutionOptions = {
187
+ /**
188
+ * Generally Reveal will follow the resolution given by the size
189
+ * of the encapsulating DOM element of the Canvas {@link Cognite3DViewerOptions.domElement}.
190
+ * To ensure managable performance, Reveal will by default set an upper threshold to limit
191
+ * the resolution. The `maxRenderResolution` option will
192
+ * directly control this upper limit. It corresponds to the number of pixels in the render target.
193
+ */
194
+ maxRenderResolution?: number;
195
+ /**
196
+ * A factor that will scale down the resolution when moving the camera. This can
197
+ * be used to achieve a better user experience on devices with limited hardware.
198
+ * Values must be greater than 0 and at most 1.
199
+ * A value of e.g. 0.25 will approximately divide the number of pixels on the screen by four.
200
+ */
201
+ movingCameraResolutionFactor?: number;
202
+ };
178
203
  /**
179
204
  * Represents the result from {@link Cognite3DViewer.getIntersectionFromPixel}.
180
205
  * @module @cognite/reveal
@@ -3,13 +3,13 @@
3
3
  */
4
4
  import { DetermineSectorCostDelegate, DetermineSectorsInput, SectorLoadingSpent } from './types';
5
5
  import { SectorCuller } from './SectorCuller';
6
- import { V9SectorMetadata, WantedSector } from '../../../../cad-parsers';
6
+ import { SectorMetadata, WantedSector } from '../../../../cad-parsers';
7
7
  export type ByScreenSizeSectorCullerOptions = {
8
8
  /**
9
9
  * Optional callback for determining the cost of a sector. The default unit of the cost
10
10
  * function is bytes downloaded.
11
11
  */
12
- determineSectorCost?: DetermineSectorCostDelegate<V9SectorMetadata>;
12
+ determineSectorCost?: DetermineSectorCostDelegate<SectorMetadata>;
13
13
  };
14
14
  export declare class ByScreenSizeSectorCuller implements SectorCuller {
15
15
  private readonly _determineSectorCost;
@@ -2,7 +2,7 @@
2
2
  * Copyright 2021 Cognite AS
3
3
  */
4
4
  import * as THREE from 'three';
5
- import { SectorMetadata, V9SectorMetadata } from '../../../../cad-parsers';
5
+ import { SectorMetadata } from '../../../../cad-parsers';
6
6
  import { PrioritizedArea } from '../../../../cad-styling';
7
7
  export declare class WeightFunctionsHelper {
8
8
  private readonly _camera;
@@ -35,7 +35,7 @@ export declare class WeightFunctionsHelper {
35
35
  * sectors right below root sector.
36
36
  * @param sector
37
37
  */
38
- computeSectorTreePlacementWeight(sector: V9SectorMetadata): number;
38
+ computeSectorTreePlacementWeight(sector: SectorMetadata): number;
39
39
  /**
40
40
  * Computes a weight based on how large the biggest node within the sector
41
41
  * will be on screen (a number in range [0-1]).
@@ -4,14 +4,14 @@
4
4
  import { DetermineSectorCostDelegate, PrioritizedWantedSector, SectorCost } from '../types';
5
5
  import { CadModelBudget } from '../../../CadModelBudget';
6
6
  import { TakenSectorMapBase } from './TakenSectorMapBase';
7
- import { CadModelMetadata, V9SectorMetadata } from '../../../../../cad-parsers';
7
+ import { CadModelMetadata, SectorMetadata } from '../../../../../cad-parsers';
8
8
  export declare class TakenV9SectorMap extends TakenSectorMapBase {
9
9
  private readonly determineSectorCost;
10
10
  private readonly _totalCost;
11
11
  private readonly _models;
12
12
  get totalCost(): SectorCost;
13
13
  get modelsMetadata(): CadModelMetadata[];
14
- constructor(determineSectorCost: DetermineSectorCostDelegate<V9SectorMetadata>);
14
+ constructor(determineSectorCost: DetermineSectorCostDelegate<SectorMetadata>);
15
15
  initializeScene(modelMetadata: CadModelMetadata): void;
16
16
  markSectorDetailed(model: CadModelMetadata, sectorId: number, priority: number): void;
17
17
  isWithinBudget(budget: CadModelBudget): boolean;
@@ -6,7 +6,7 @@ export { CadModelMetadata } from './src/metadata/CadModelMetadata';
6
6
  export { SectorSceneFactory } from './src/utilities/SectorSceneFactory';
7
7
  export { CadModelClipper } from './src/metadata/CadModelClipper';
8
8
  export { SectorScene } from './src/utilities/types';
9
- export { SectorMetadata, V9SectorMetadata } from './src/metadata/types';
9
+ export { SectorMetadata } from './src/metadata/types';
10
10
  export { SectorNode } from './src/sector/SectorNode';
11
11
  export { RootSectorNode } from './src/sector/RootSectorNode';
12
12
  export { LevelOfDetail } from './src/cad/LevelOfDetail';
@@ -7,9 +7,6 @@ export type CadSceneRootMetadata = {
7
7
  readonly sectors: SceneSectorMetadata[];
8
8
  readonly unit: string | null;
9
9
  };
10
- export type SceneSectorMetadata = BaseSceneSectorMetadata & (GltfSceneSectorMetadata | I3dF3dSceneSectorMetadata);
11
- export type V8SceneSectorMetadata = BaseSceneSectorMetadata & I3dF3dSceneSectorMetadata;
12
- export type V9SceneSectorMetadata = BaseSceneSectorMetadata & GltfSceneSectorMetadata;
13
10
  export type BoundingBox = {
14
11
  readonly min: {
15
12
  x: number;
@@ -22,7 +19,7 @@ export type BoundingBox = {
22
19
  z: number;
23
20
  };
24
21
  };
25
- export type BaseSceneSectorMetadata = {
22
+ export type SceneSectorMetadata = {
26
23
  readonly id: number;
27
24
  readonly parentId: number | null;
28
25
  readonly path: string;
@@ -31,32 +28,8 @@ export type BaseSceneSectorMetadata = {
31
28
  readonly estimatedTriangleCount: number;
32
29
  readonly boundingBox: BoundingBox;
33
30
  readonly geometryBoundingBox?: BoundingBox;
34
- };
35
- export type GltfSceneSectorMetadata = {
36
31
  readonly sectorFileName: string | null;
37
32
  readonly maxDiagonalLength: number;
38
33
  readonly minDiagonalLength: number;
39
34
  readonly downloadSize: number;
40
35
  };
41
- export type I3dF3dSceneSectorMetadata = {
42
- readonly indexFile: {
43
- readonly fileName: string;
44
- readonly peripheralFiles: string[];
45
- readonly downloadSize: number;
46
- };
47
- readonly facesFile: {
48
- readonly quadSize: number;
49
- readonly coverageFactors: {
50
- xy: number;
51
- yz: number;
52
- xz: number;
53
- };
54
- readonly recursiveCoverageFactors: {
55
- xy: number;
56
- yz: number;
57
- xz: number;
58
- } | undefined;
59
- readonly fileName: string | null;
60
- readonly downloadSize: number;
61
- } | null;
62
- };
@@ -2,33 +2,7 @@
2
2
  * Copyright 2021 Cognite AS
3
3
  */
4
4
  import * as THREE from 'three';
5
- export interface SectorMetadataIndexFileSection {
6
- readonly fileName: string;
7
- readonly peripheralFiles: string[];
8
- readonly downloadSize: number;
9
- }
10
- export interface SectorMetadataFacesFileSection {
11
- readonly quadSize: number;
12
- /**
13
- * Coverage factors for the sector without children.
14
- */
15
- readonly coverageFactors: {
16
- xy: number;
17
- yz: number;
18
- xz: number;
19
- };
20
- /**
21
- * Coverage factor for the sectors including children.
22
- */
23
- readonly recursiveCoverageFactors: {
24
- xy: number;
25
- yz: number;
26
- xz: number;
27
- };
28
- readonly fileName: string | null;
29
- readonly downloadSize: number;
30
- }
31
- export type BaseSectorMetadata = {
5
+ export type SectorMetadata = {
32
6
  readonly id: number;
33
7
  readonly path: string;
34
8
  readonly depth: number;
@@ -36,14 +10,6 @@ export type BaseSectorMetadata = {
36
10
  readonly children: SectorMetadata[];
37
11
  readonly estimatedDrawCallCount: number;
38
12
  readonly estimatedRenderCost: number;
39
- };
40
- export type SectorMetadata = BaseSectorMetadata & (I3dF3dSectorMetadata | GltfSectorMetadata);
41
- export type V9SectorMetadata = BaseSectorMetadata & GltfSectorMetadata;
42
- export type I3dF3dSectorMetadata = {
43
- readonly indexFile: SectorMetadataIndexFileSection;
44
- readonly facesFile: SectorMetadataFacesFileSection;
45
- };
46
- export type GltfSectorMetadata = {
47
13
  readonly sectorFileName: string | null;
48
14
  readonly maxDiagonalLength: number;
49
15
  readonly minDiagonalLength: number;
@@ -18,11 +18,13 @@ export declare class Potree implements IPotree {
18
18
  private readonly _modelDataProvider;
19
19
  private readonly _materialManager;
20
20
  private readonly _throttledUpdateFunc;
21
+ private _shouldLoad;
21
22
  maxNumNodesLoading: number;
22
23
  lru: LRU;
23
24
  constructor(modelDataProvider: ModelDataProvider, pointCloudMaterialManager: PointCloudMaterialManager);
24
25
  loadPointCloud(baseUrl: string, fileName: string, pointCloudObjects: PointCloudObject[], modelIdentifier: symbol): Promise<PointCloudOctree>;
25
26
  updatePointClouds(pointClouds: PointCloudOctree[], camera: Camera, renderer: WebGLRenderer): void;
27
+ set shouldLoad(value: boolean);
26
28
  private innerUpdatePointClouds;
27
29
  get pointBudget(): number;
28
30
  set pointBudget(value: number);
@@ -20,3 +20,4 @@ export { CadGeometryRenderModePipelineProvider } from './src/render-pipeline-pro
20
20
  export { BasicPipelineExecutor } from './src/pipeline-executors/BasicPipelineExecutor';
21
21
  export { RenderPipelineExecutor } from './src/RenderPipelineExecutor';
22
22
  export { RenderPipelineProvider } from './src/RenderPipelineProvider';
23
+ export { ResizeHandler } from './src/ResizeHandler';
@@ -0,0 +1,29 @@
1
+ /*!
2
+ * Copyright 2022 Cognite AS
3
+ */
4
+ import { WebGLRenderer, PerspectiveCamera } from 'three';
5
+ import { CameraManager } from '../../camera-manager';
6
+ export type ResizeHandlerOptions = {
7
+ renderResolutionThreshold?: number;
8
+ };
9
+ export declare class ResizeHandler {
10
+ private readonly _defaultResolutionThreshold;
11
+ private readonly _renderer;
12
+ private readonly _cameraManager;
13
+ private _stoppedCameraResolutionThreshold;
14
+ private _currentResolutionThreshold;
15
+ private _movingResolutionFactor;
16
+ private readonly _onCameraChangeCallback;
17
+ private readonly _onCameraStopCallback;
18
+ private readonly _resizeObserver;
19
+ private _shouldResize;
20
+ constructor(renderer: WebGLRenderer, cameraManager: CameraManager, resizeOptions?: ResizeHandlerOptions);
21
+ get needsRedraw(): boolean;
22
+ resetRedraw(): void;
23
+ setResolutionThreshold(threshold: number): void;
24
+ setMovingCameraResolutionFactor(factor: number): void;
25
+ handleResize(camera: PerspectiveCamera): void;
26
+ private setupResizeListener;
27
+ private resize;
28
+ dispose(): void;
29
+ }
@@ -4,19 +4,9 @@
4
4
  import * as THREE from 'three';
5
5
  import { RenderPipelineExecutor } from '../RenderPipelineExecutor';
6
6
  import { RenderPipelineProvider } from '../RenderPipelineProvider';
7
- export type BasicPipelineExecutorOptions = {
8
- autoResizeRenderer: boolean;
9
- resolutionThreshold?: number;
10
- };
11
7
  export declare class BasicPipelineExecutor implements RenderPipelineExecutor {
12
- private readonly _defaultResolutionThreshold;
13
8
  private readonly _renderer;
14
- private readonly _resolutionThreshold;
15
- private readonly _resizeObserver;
16
- private _shouldResize;
17
- constructor(renderer: THREE.WebGLRenderer, options?: BasicPipelineExecutorOptions);
9
+ constructor(renderer: THREE.WebGLRenderer);
18
10
  render(renderPipeline: RenderPipelineProvider, camera: THREE.PerspectiveCamera): void;
19
- private setupResizeListener;
20
- private resize;
21
11
  dispose(): void;
22
12
  }
@@ -39,7 +39,6 @@ export interface IPointCloudMaterialUniforms {
39
39
  }
40
40
  export declare class PointCloudMaterial extends RawShaderMaterial {
41
41
  private static readonly helperVec3;
42
- private static readonly helperVec2;
43
42
  /**
44
43
  * Use the drawing buffer size instead of the dom client width and height when passing the screen height and screen width uniforms to the
45
44
  * shader. This is useful if you have offscreen canvases (which in some browsers return 0 as client width and client height).
@@ -115,7 +114,7 @@ export declare class PointCloudMaterial extends RawShaderMaterial {
115
114
  set elevationRange(value: [number, number]);
116
115
  getUniform<K extends keyof IPointCloudMaterialUniforms>(name: K): IPointCloudMaterialUniforms[K]['value'];
117
116
  setUniform<K extends keyof IPointCloudMaterialUniforms>(name: K, value: IPointCloudMaterialUniforms[K]['value']): void;
118
- onBeforeRender(): void;
119
- updateMaterial(octreeParams: OctreeMaterialParams, visibilityTextureData: Uint8Array, camera: Camera, renderer: WebGLRenderer): void;
117
+ onBeforeRender(renderer: WebGLRenderer): void;
118
+ updateMaterial(octreeParams: OctreeMaterialParams, visibilityTextureData: Uint8Array, camera: Camera): void;
120
119
  private updateVisibilityTextureData;
121
120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognite/reveal",
3
- "version": "4.0.0-dev.20221220",
3
+ "version": "4.0.0-dev.20221222",
4
4
  "description": "WebGL based 3D viewer for CAD and point clouds processed in Cognite Data Fusion.",
5
5
  "homepage": "https://github.com/cognitedata/reveal/tree/master/viewer",
6
6
  "repository": {
@@ -80,7 +80,7 @@
80
80
  "mixpanel-browser": "2.45.0",
81
81
  "path-browserify": "1.0.1",
82
82
  "proj4": "2.8.0",
83
- "rxjs": "7.6.0",
83
+ "rxjs": "7.8.0",
84
84
  "skmeans": "0.11.3",
85
85
  "three-stdlib": "2.20.4"
86
86
  },
@@ -93,7 +93,7 @@
93
93
  "@types/glob": "8.0.0",
94
94
  "@types/jest": "29.2.4",
95
95
  "@types/jest-environment-puppeteer": "5.0.3",
96
- "@types/jest-image-snapshot": "5.1.0",
96
+ "@types/jest-image-snapshot": "6.1.0",
97
97
  "@types/jsdom": "20.0.1",
98
98
  "@types/lodash": "4.14.191",
99
99
  "@types/mixpanel-browser": "2.38.0",
@@ -132,7 +132,7 @@
132
132
  "nock": "13.2.9",
133
133
  "prettier": "2.8.1",
134
134
  "process": "0.11.10",
135
- "puppeteer": "19.4.0",
135
+ "puppeteer": "19.4.1",
136
136
  "random-seed": "0.3.0",
137
137
  "raw-loader": "4.0.2",
138
138
  "remove-files-webpack-plugin": "1.5.0",