@cognite/reveal 4.2.0-dev.20230523 → 4.2.0-dev.20230525

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.
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Copyright 2022 Cognite AS
3
3
  */
4
- export { Image360, Image360Metadata } from './src/entity/Image360';
4
+ export { Image360 } from './src/entity/Image360';
5
5
  export { Image360Revision } from './src/entity/Image360Revision';
6
6
  export { Image360Collection, Image360AnnotationAssetFilter, Image360AnnotationAssetQueryResult } from './src/collection/Image360Collection';
7
7
  export { Image360Facade } from './src/Image360Facade';
@@ -11,10 +11,18 @@ export interface Image360Annotation {
11
11
  * The underlying CDF annotation
12
12
  */
13
13
  readonly annotation: AnnotationModel;
14
+ /**
15
+ * Get the individual display color of this annotation.
16
+ */
17
+ getColor(): Color;
14
18
  /**
15
19
  * Set the display color of this annotation. Default: Random, based on annotation label
16
20
  */
17
21
  setColor(color?: Color): void;
22
+ /**
23
+ * Get whether this annotation is visible
24
+ */
25
+ getVisible(): boolean;
18
26
  /**
19
27
  * Set whether this annotation should be visible. Default: true
20
28
  */
@@ -27,7 +27,10 @@ export declare class ImageAnnotationObject implements Image360Annotation {
27
27
  intersects(raycaster: Raycaster): boolean;
28
28
  private updateMaterials;
29
29
  setDefaultStyle(appearance: Image360AnnotationAppearance): void;
30
+ private getColorReference;
31
+ getColor(): Color;
30
32
  setColor(color?: Color): void;
33
+ getVisible(): boolean;
31
34
  setVisible(visible?: boolean): void;
32
35
  dispose(): void;
33
36
  getCenter(out?: Vector3): Vector3;
@@ -75,7 +75,7 @@ export declare class DefaultImage360Collection implements Image360Collection {
75
75
  dispose(): void;
76
76
  get needsRedraw(): boolean;
77
77
  resetRedraw(): void;
78
- get defaultStyle(): Image360AnnotationAppearance;
78
+ getDefaultAnnotationStyle(): Image360AnnotationAppearance;
79
79
  setDefaultAnnotationStyle(defaultStyle: Image360AnnotationAppearance): void;
80
80
  findImageAnnotation(filter: Image360AnnotationAssetFilter): Promise<Image360AnnotationAssetQueryResult[]>;
81
81
  }
@@ -70,6 +70,10 @@ export interface Image360Collection {
70
70
  */
71
71
  off(event: 'image360Entered', callback: Image360EnteredDelegate): void;
72
72
  off(event: 'image360Exited', callback: Image360ExitedDelegate): void;
73
+ /**
74
+ * Get the assigned default style affecting all annotations
75
+ */
76
+ getDefaultAnnotationStyle(): Image360AnnotationAppearance;
73
77
  /**
74
78
  * Assign a default style which affects all annotations
75
79
  */
@@ -3,11 +3,10 @@
3
3
  */
4
4
  import { Image360Revision } from './Image360Revision';
5
5
  import { Image360Visualization } from './Image360Visualization';
6
- export type Image360Metadata = {
7
- station: string;
8
- collection: string;
9
- date?: Date;
10
- };
6
+ /**
7
+ * A single 360 image "station", which may consist of several revisions
8
+ * captured in approximately the same location
9
+ */
11
10
  export interface Image360 {
12
11
  /**
13
12
  * Get a copy of the model-to-world transformation matrix
@@ -21,9 +20,15 @@ export interface Image360 {
21
20
  */
22
21
  readonly image360Visualization: Image360Visualization;
23
22
  /**
24
- * Get additional information about this image and its active revision.
23
+ * Get Id of 360 image entity.
24
+ * @returns Station Id
25
25
  */
26
- getImageMetadata(): Image360Metadata;
26
+ readonly id: string;
27
+ /**
28
+ * Get label of 360 image entity.
29
+ * @returns Station label
30
+ * */
31
+ readonly label: string;
27
32
  /**
28
33
  * List all historical images for this entity.
29
34
  * @returns A list of available revisions.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { DeviceDescriptor, SceneHandler } from '../../../utilities';
5
5
  import { Image360DataProvider } from '../../../data-providers';
6
- import { Image360, Image360Metadata } from './Image360';
6
+ import { Image360 } from './Image360';
7
7
  import { Historical360ImageSet } from '../../../data-providers/src/types';
8
8
  import { Image360RevisionEntity } from './Image360RevisionEntity';
9
9
  import { Image360VisualizationBox } from './Image360VisualizationBox';
@@ -34,6 +34,16 @@ export declare class Image360Entity implements Image360 {
34
34
  * @returns Image360Visualization
35
35
  */
36
36
  get image360Visualization(): Image360VisualizationBox;
37
+ /**
38
+ * Get Id of 360 image entity.
39
+ * @returns Station Id
40
+ */
41
+ get id(): string;
42
+ /**
43
+ * Get label of 360 image entity.
44
+ * @returns Station label
45
+ * */
46
+ get label(): string;
37
47
  constructor(image360Metadata: Historical360ImageSet, sceneHandler: SceneHandler, imageProvider: Image360DataProvider, annotationFilterer: Image360AnnotationFilter, transform: THREE.Matrix4, icon: Overlay3DIcon, device: DeviceDescriptor);
38
48
  /**
39
49
  * List all historical images for this entity.
@@ -58,7 +68,6 @@ export declare class Image360Entity implements Image360 {
58
68
  * Drops the GPU resources for the 360 image
59
69
  */
60
70
  unloadImage(): void;
61
- getImageMetadata(): Image360Metadata;
62
71
  activateAnnotations(): void;
63
72
  deactivateAnnotations(): void;
64
73
  /**
@@ -5,5 +5,5 @@ export { Overlay3DCollection } from './src/Overlay3DCollection';
5
5
  export { OverlayPointsObject, OverlayPointsParameters } from './src/OverlayPointsObject';
6
6
  export { Overlay3DIcon } from './src/Overlay3DIcon';
7
7
  export { Overlay3D } from './src/Overlay3D';
8
- export { OverlayCollection, OverlayInfo, DefaultMetadataType } from './src/OverlayCollection';
8
+ export { OverlayCollection, OverlayInfo, DefaultOverlay3DContentType } from './src/OverlayCollection';
9
9
  export { IconOctree } from './src/IconOctree';
@@ -1,29 +1,33 @@
1
1
  /*!
2
2
  * Copyright 2023 Cognite AS
3
3
  */
4
- export interface Overlay3D<MetadataType> {
4
+ import { Color, Vector3 } from 'three';
5
+ /**
6
+ * Represents one 3d overlay
7
+ */
8
+ export interface Overlay3D<ContentType> {
5
9
  /**
6
10
  * Set whether this overlay should be visible.
7
11
  * */
8
- set visible(visible: boolean);
12
+ setVisible(visible: boolean): void;
9
13
  /**
10
14
  * Get whether this overlay is visible.
11
15
  */
12
- get visible(): boolean;
16
+ getVisible(): boolean;
13
17
  /**
14
18
  * Get the position of this overlay.
15
19
  */
16
- get position(): THREE.Vector3;
20
+ getPosition(): Vector3;
17
21
  /**
18
22
  * Set the display color of this overlay.
19
23
  * */
20
- setColor(color: THREE.Color): void;
24
+ setColor(color: Color): void;
21
25
  /**
22
26
  * Get the display color of this overlay.
23
27
  * */
24
- get color(): THREE.Color;
28
+ getColor(): Color;
25
29
  /**
26
30
  * Get the metadata associated with this overlay.
27
31
  * */
28
- getMetadata(): MetadataType | undefined;
32
+ getContent(): ContentType;
29
33
  }
@@ -3,13 +3,13 @@
3
3
  */
4
4
  import { Color, Texture, Object3D } from 'three';
5
5
  import { Overlay3D } from './Overlay3D';
6
- import { DefaultMetadataType, OverlayCollection, OverlayInfo } from './OverlayCollection';
6
+ import { DefaultOverlay3DContentType, OverlayCollection, OverlayInfo } from './OverlayCollection';
7
7
  export type Overlay3DCollectionOptions = {
8
8
  overlayTexture?: Texture;
9
9
  maxPointSize?: number;
10
10
  defaultOverlayColor?: Color;
11
11
  };
12
- export declare class Overlay3DCollection<MetadataType = DefaultMetadataType> extends Object3D implements OverlayCollection<MetadataType> {
12
+ export declare class Overlay3DCollection<MetadataType = DefaultOverlay3DContentType> extends Object3D implements OverlayCollection<MetadataType> {
13
13
  private readonly MinPixelSize;
14
14
  private readonly MaxPixelSize;
15
15
  private readonly DefaultMaxPoints;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { PerspectiveCamera, Ray, Vector3, Color } from 'three';
5
5
  import { Overlay3D } from './Overlay3D';
6
- import { DefaultMetadataType } from './OverlayCollection';
6
+ import { DefaultOverlay3DContentType } from './OverlayCollection';
7
7
  export type IconParameters = {
8
8
  position: THREE.Vector3;
9
9
  color?: THREE.Color;
@@ -25,14 +25,14 @@ export type SelectedDelegate = (event: {
25
25
  selected: boolean;
26
26
  }) => void;
27
27
  export type IconEvent = 'selected' | 'parametersChange';
28
- export declare class Overlay3DIcon<MetadataType = DefaultMetadataType> implements Overlay3D<MetadataType> {
28
+ export declare class Overlay3DIcon<ContentType = DefaultOverlay3DContentType> implements Overlay3D<ContentType> {
29
29
  private readonly _position;
30
30
  private readonly _minPixelSize;
31
31
  private readonly _maxPixelSize;
32
32
  private readonly _setAdaptiveScale;
33
33
  private readonly _iconRadius;
34
34
  private readonly _hoverSprite?;
35
- private readonly _iconMetadata?;
35
+ private readonly _content;
36
36
  private readonly _raycastBoundingSphere;
37
37
  private _adaptiveScale;
38
38
  private _visible;
@@ -41,7 +41,7 @@ export declare class Overlay3DIcon<MetadataType = DefaultMetadataType> implement
41
41
  private _color;
42
42
  private readonly _ndcPosition;
43
43
  private readonly _events;
44
- constructor(iconParameters: IconParameters, iconMetadata?: MetadataType);
44
+ constructor(iconParameters: IconParameters, content: ContentType);
45
45
  on(event: 'selected', callback: SelectedDelegate): void;
46
46
  on(event: 'parametersChange', callback: ParametersChangeDelegate): void;
47
47
  off(event: 'selected', callback: SelectedDelegate): void;
@@ -55,14 +55,14 @@ export declare class Overlay3DIcon<MetadataType = DefaultMetadataType> implement
55
55
  domElement: HTMLElement;
56
56
  }): void;
57
57
  setColor(color: Color): void;
58
- get color(): Color;
59
- getMetadata(): MetadataType | undefined;
58
+ getColor(): Color;
59
+ getContent(): ContentType;
60
60
  get adaptiveScale(): number;
61
61
  set culled(culled: boolean);
62
62
  get culled(): boolean;
63
- set visible(visible: boolean);
64
- get visible(): boolean;
65
- get position(): Vector3;
63
+ setVisible(visible: boolean): void;
64
+ getVisible(): boolean;
65
+ getPosition(): Vector3;
66
66
  intersect(ray: Ray): Vector3 | null;
67
67
  dispose(): void;
68
68
  private setupAdaptiveScaling;
@@ -2,31 +2,48 @@
2
2
  * Copyright 2023 Cognite AS
3
3
  */
4
4
  import { Overlay3D } from './Overlay3D';
5
- export type DefaultMetadataType = {
6
- text?: string;
7
- [key: string]: string | undefined;
5
+ /**
6
+ * The default metadata type contained in Overlays
7
+ */
8
+ export type DefaultOverlay3DContentType = {
9
+ [key: string]: string;
8
10
  };
9
- export type OverlayInfo<MetadataType = DefaultMetadataType> = {
11
+ /**
12
+ * Data used in creating an overlay
13
+ */
14
+ export type OverlayInfo<ContentType = DefaultOverlay3DContentType> = {
15
+ /**
16
+ * Position of the overlay
17
+ */
10
18
  position: THREE.Vector3;
11
- metadata?: MetadataType;
19
+ /**
20
+ * The data contained in this overlay
21
+ */
22
+ content: ContentType;
23
+ /**
24
+ * The color of this overlay. Will be set by collection if undefined
25
+ */
12
26
  color?: THREE.Color;
13
27
  };
14
- export interface OverlayCollection<MetadataType> {
28
+ /**
29
+ * A set of overlays managed
30
+ */
31
+ export interface OverlayCollection<ContentType> {
15
32
  /**
16
33
  * Get all overlays in the collection.
17
34
  * */
18
- getOverlays(): Overlay3D<MetadataType>[];
35
+ getOverlays(): Overlay3D<ContentType>[];
19
36
  /**
20
37
  * Add overlays to the collection.
21
38
  * @param overlays Overlays to add to the collection.
22
39
  * @returns The added overlays.
23
40
  */
24
- addOverlays(overlays: OverlayInfo<MetadataType>[]): Overlay3D<MetadataType>[];
41
+ addOverlays(overlays: OverlayInfo<ContentType>[]): Overlay3D<ContentType>[];
25
42
  /**
26
43
  * Remove overlays from the collection.
27
44
  * @param overlays Overlays to remove from the collection.
28
45
  */
29
- removeOverlays(overlays: Overlay3D<MetadataType>[]): void;
46
+ removeOverlays(overlays: Overlay3D<ContentType>[]): void;
30
47
  /**
31
48
  * Remove all overlays from the collection.
32
49
  */
@@ -5,7 +5,7 @@ export { HtmlOverlayTool, HtmlOverlayOptions, HtmlOverlayToolOptions, HtmlOverla
5
5
  export { DebugCameraTool } from './src/DebugCameraTool';
6
6
  export { AxisViewTool } from './src/AxisView/AxisViewTool';
7
7
  export { AxisBoxConfig, AxisBoxCompassConfig, AxisBoxFaceConfig, Corner, AbsolutePosition, RelativePosition } from './src/AxisView/types';
8
- export { SmartOverlayTool, SmartOverlayToolParameters, OverlayEventHandler, OverlayToolEvent } from './src/SmartOverlay/SmartOverlayTool';
8
+ export { Overlay3DTool, Overlay3DToolParameters, OverlayEventHandler, OverlayToolEvent } from './src/Overlay3D/Overlay3DTool';
9
9
  export { TimelineTool } from './src/Timeline/TimelineTool';
10
10
  export { Keyframe } from './src/Timeline/Keyframe';
11
11
  export { TimelineDateUpdateDelegate } from './src/Timeline/types';
@@ -4,18 +4,27 @@
4
4
  import { Cognite3DViewer } from '../../../api';
5
5
  import { DisposedDelegate } from '../../../utilities';
6
6
  import * as THREE from 'three';
7
- import { OverlayInfo, DefaultMetadataType, OverlayCollection, Overlay3D } from '../../../3d-overlays';
7
+ import { OverlayInfo, DefaultOverlay3DContentType, OverlayCollection, Overlay3D } from '../../../3d-overlays';
8
8
  import { Cognite3DViewerToolBase } from '../Cognite3DViewerToolBase';
9
+ /**
10
+ * Events related to overlays
11
+ */
9
12
  export type OverlayToolEvent = 'hover' | 'click' | 'disposed';
10
- export type OverlayEventHandler<MetadataType> = (event: {
11
- targetOverlay: Overlay3D<MetadataType>;
13
+ /**
14
+ * Type for handlers of overlay events
15
+ */
16
+ export type OverlayEventHandler<ContentType> = (event: {
17
+ targetOverlay: Overlay3D<ContentType>;
12
18
  htmlOverlay: HTMLElement;
13
19
  mousePosition: {
14
20
  clientX: number;
15
21
  clientY: number;
16
22
  };
17
23
  }) => void;
18
- export type SmartOverlayToolParameters = {
24
+ /**
25
+ * Parameters for instantiating the Overlay3DTool
26
+ */
27
+ export type Overlay3DToolParameters = {
19
28
  /**
20
29
  * Max point markers size in pixels. Different platforms has limitations for this value.
21
30
  * On Android and MacOS in Chrome maximum is 64. Windows in Chrome and MacOS Safari desktops can support up to 500.
@@ -27,7 +36,10 @@ export type SmartOverlayToolParameters = {
27
36
  */
28
37
  defaultOverlayColor: THREE.Color;
29
38
  };
30
- export declare class SmartOverlayTool<MetadataType = DefaultMetadataType> extends Cognite3DViewerToolBase {
39
+ /**
40
+ * Tool for adding and interacting with 2D overlays positioned at points in
41
+ */
42
+ export declare class Overlay3DTool<ContentType = DefaultOverlay3DContentType> extends Cognite3DViewerToolBase {
31
43
  private readonly _viewer;
32
44
  private readonly _textOverlay;
33
45
  private readonly _defaultOverlayColor;
@@ -38,29 +50,38 @@ export declare class SmartOverlayTool<MetadataType = DefaultMetadataType> extend
38
50
  private _isVisible;
39
51
  private _textOverlayVisible;
40
52
  private readonly _events;
41
- constructor(viewer: Cognite3DViewer, toolParameters?: SmartOverlayToolParameters);
53
+ constructor(viewer: Cognite3DViewer, toolParameters?: Overlay3DToolParameters);
42
54
  /**
43
55
  * Creates new OverlayCollection.
44
56
  * @param overlays Array of overlays to add.
45
57
  * @returns Overlay group containing it's id.
46
58
  */
47
- createOverlayCollection(overlays?: OverlayInfo<MetadataType>[]): OverlayCollection<MetadataType>;
59
+ createOverlayCollection(overlays?: OverlayInfo<ContentType>[]): OverlayCollection<ContentType>;
48
60
  /**
49
61
  * Removes overlays that were added with addOverlays method.
50
62
  * @param overlayCollection Id of the overlay group to remove.
51
63
  */
52
- removeOverlayCollection(overlayCollection: OverlayCollection<MetadataType>): void;
64
+ removeOverlayCollection(overlayCollection: OverlayCollection<ContentType>): void;
53
65
  /**
54
66
  * Gets all added overlay collections.
55
67
  */
56
- get collections(): OverlayCollection<MetadataType>[];
68
+ getCollections(): OverlayCollection<ContentType>[];
57
69
  /**
58
70
  * Sets whether overlays are visible.
59
71
  */
60
- set visible(visible: boolean);
61
- get visible(): boolean;
62
- set textOverlayVisible(visible: boolean);
63
- get textOverlayVisible(): boolean;
72
+ setVisible(visible: boolean): void;
73
+ /**
74
+ * Gets whether overlays are visible.
75
+ */
76
+ getVisible(): boolean;
77
+ /**
78
+ * Sets whether text overlay is visible.
79
+ */
80
+ setTextOverlayVisible(visible: boolean): void;
81
+ /**
82
+ * Gets whether text overlay is visible.
83
+ */
84
+ getTextOverlayVisible(): boolean;
64
85
  /**
65
86
  * Removes all overlays.
66
87
  */
@@ -70,12 +91,15 @@ export declare class SmartOverlayTool<MetadataType = DefaultMetadataType> extend
70
91
  * @param event event to subscribe to.
71
92
  * @param eventHandler
72
93
  */
73
- on(event: 'hover', eventHandler: OverlayEventHandler<MetadataType>): void;
74
- on(event: 'click', eventHandler: OverlayEventHandler<MetadataType>): void;
94
+ on(event: 'hover', eventHandler: OverlayEventHandler<ContentType>): void;
95
+ on(event: 'click', eventHandler: OverlayEventHandler<ContentType>): void;
75
96
  on(event: 'disposed', eventHandler: DisposedDelegate): void;
76
- off(event: 'hover', eventHandler: OverlayEventHandler<MetadataType>): void;
77
- off(event: 'click', eventHandler: OverlayEventHandler<MetadataType>): void;
97
+ off(event: 'hover', eventHandler: OverlayEventHandler<ContentType>): void;
98
+ off(event: 'click', eventHandler: OverlayEventHandler<ContentType>): void;
78
99
  off(event: 'disposed', eventHandler: DisposedDelegate): void;
100
+ /**
101
+ * Dispose of resources used by this tool
102
+ */
79
103
  dispose(): void;
80
104
  private readonly onMouseMove;
81
105
  private readonly onMouseClick;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognite/reveal",
3
- "version": "4.2.0-dev.20230523",
3
+ "version": "4.2.0-dev.20230525",
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": {
@@ -91,7 +91,7 @@
91
91
  "@types/jsdom": "21.1.1",
92
92
  "@types/lodash": "4.14.194",
93
93
  "@types/mixpanel-browser": "2.38.1",
94
- "@types/node": "18.16.12",
94
+ "@types/node": "18.16.13",
95
95
  "@types/random-seed": "0.3.3",
96
96
  "@types/skmeans": "0.11.4",
97
97
  "@types/stats": "0.16.30",
@@ -102,7 +102,7 @@
102
102
  "concurrently": "8.0.1",
103
103
  "cross-env": "7.0.3",
104
104
  "dat.gui": "0.7.9",
105
- "eslint": "8.40.0",
105
+ "eslint": "8.41.0",
106
106
  "eslint-config-prettier": "8.8.0",
107
107
  "eslint-plugin-header": "3.1.1",
108
108
  "eslint-plugin-jsdoc": "44.2.4",
@@ -115,7 +115,7 @@
115
115
  "glslify-loader": "2.0.0",
116
116
  "html-webpack-plugin": "5.5.1",
117
117
  "jest": "29.5.0",
118
- "jest-canvas-mock": "2.5.0",
118
+ "jest-canvas-mock": "2.5.1",
119
119
  "jest-environment-jsdom": "29.5.0",
120
120
  "jest-extended": "3.2.4",
121
121
  "jest-image-snapshot": "6.1.0",