@cognite/reveal 4.14.9-dev.20240621 → 4.15.0-dev.20240624

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 2023 Cognite AS
3
3
  */
4
- export { Overlay3DCollection } from './src/Overlay3DCollection';
4
+ export { Overlay3DCollection, Overlay3DCollectionOptions } 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';
@@ -0,0 +1,8 @@
1
+ import { Camera } from 'three';
2
+ export type Callback = () => void;
3
+ export declare class CameraChangeThrottler {
4
+ private readonly _prevCameraMatrix;
5
+ call: (camera: Camera, callback: Callback) => void;
6
+ constructor(wait?: number);
7
+ private _call;
8
+ }
@@ -4,10 +4,11 @@
4
4
  import { Node, PointOctant, PointOctree } from 'sparse-octree';
5
5
  import { Box3, Matrix4 } from 'three';
6
6
  import { Overlay3DIcon } from './Overlay3DIcon';
7
- export declare class IconOctree extends PointOctree<Overlay3DIcon> {
7
+ import { DefaultOverlay3DContentType } from './OverlayCollection';
8
+ export declare class IconOctree<ContentType = DefaultOverlay3DContentType> extends PointOctree<Overlay3DIcon<ContentType>> {
8
9
  private readonly _nodeCenters;
9
- static getMinimalOctreeBoundsFromIcons(icons: Overlay3DIcon[]): Box3;
10
- constructor(icons: Overlay3DIcon[], bounds: Box3, maxLeafSize: number);
10
+ static getMinimalOctreeBoundsFromIcons<ContentType>(icons: Overlay3DIcon<ContentType>[]): Box3;
11
+ constructor(icons: Overlay3DIcon<ContentType>[], bounds: Box3, maxLeafSize: number);
11
12
  getNodeIcon(node: Node): Overlay3DIcon | undefined;
12
13
  getLODByScreenArea(areaThreshold: number, projection: Matrix4, minimumLevel?: number): Set<PointOctant<Overlay3DIcon>>;
13
14
  private populateNodeCenters;
@@ -1,15 +1,33 @@
1
1
  /*!
2
2
  * Copyright 2023 Cognite AS
3
3
  */
4
- import { Color, Texture, Object3D, type Camera } from 'three';
4
+ import { Color, Texture, Object3D, Camera, Vector2 } from 'three';
5
5
  import { Overlay3D } from './Overlay3D';
6
6
  import { DefaultOverlay3DContentType, OverlayCollection, OverlayInfo } from './OverlayCollection';
7
+ /**
8
+ * Constructor options for the Overlay3DCollection
9
+ */
7
10
  export type Overlay3DCollectionOptions = {
11
+ /**
12
+ * The texture to display as icons in this collection
13
+ */
8
14
  overlayTexture?: Texture;
15
+ /**
16
+ * A texture mask for marking what pixels are transparent in the supplied overlayTexture
17
+ */
9
18
  overlayTextureMask?: Texture;
19
+ /**
20
+ * The maximum display size of each icon in pixels
21
+ */
10
22
  maxPointSize?: number;
23
+ /**
24
+ * The default color to apply to overlay icons without a color on their own
25
+ */
11
26
  defaultOverlayColor?: Color;
12
27
  };
28
+ /**
29
+ * A collection of overlay icons with associated data
30
+ */
13
31
  export declare class Overlay3DCollection<MetadataType = DefaultOverlay3DContentType> extends Object3D implements OverlayCollection<MetadataType> {
14
32
  private readonly MinPixelSize;
15
33
  private readonly MaxPixelSize;
@@ -20,16 +38,41 @@ export declare class Overlay3DCollection<MetadataType = DefaultOverlay3DContentT
20
38
  private readonly _iconRadius;
21
39
  private _overlays;
22
40
  private _octree;
23
- constructor(overlayInfos?: OverlayInfo<MetadataType>[], options?: Overlay3DCollectionOptions);
41
+ private readonly _rayCaster;
42
+ private readonly _cameraChangeDebouncer;
43
+ constructor(overlayInfos: OverlayInfo<MetadataType>[], options?: Overlay3DCollectionOptions);
44
+ /**
45
+ * Set whether this collection is visible or not
46
+ */
24
47
  setVisibility(visibility: boolean): void;
48
+ /**
49
+ * Get the overlay icons contained in this collection
50
+ */
25
51
  getOverlays(): Overlay3D<MetadataType>[];
52
+ /**
53
+ * Add more overlays into this collection
54
+ */
26
55
  addOverlays(overlayInfos: OverlayInfo<MetadataType>[]): Overlay3D<MetadataType>[];
27
- sortOverlaysRelativeToCamera(camera: Camera): void;
56
+ private readonly onBeforeRenderDelegate;
57
+ private sortOverlaysRelativeToCamera;
58
+ /**
59
+ * Remove the listed overlays from this collection
60
+ */
28
61
  removeOverlays(overlays: Overlay3D<MetadataType>[]): void;
62
+ /**
63
+ * Clean up all icons in this collection
64
+ */
29
65
  removeAllOverlays(): void;
66
+ /**
67
+ * Run intersection on icons in this collection. Returns the closest hit
68
+ */
69
+ intersectOverlays(normalizedCoordinates: Vector2, camera: Camera): Overlay3D<MetadataType> | undefined;
30
70
  private rebuildOctree;
31
71
  private updatePointsObject;
32
72
  private initializeOverlay3DIcons;
73
+ /**
74
+ * Dispose this collection and icons with all associated resources
75
+ */
33
76
  dispose(): void;
34
77
  private createCircleTextures;
35
78
  }
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Copyright 2023 Cognite AS
3
3
  */
4
- import { Color, DepthModes, Group, Matrix4, Texture, Vector3 } from 'three';
4
+ import { Color, DepthModes, Group, Matrix4, Object3D, Texture, Vector3 } from 'three';
5
5
  export type OverlayPointsParameters = {
6
6
  spriteTexture: Texture;
7
7
  maskTexture?: Texture;
@@ -20,8 +20,9 @@ export declare class OverlayPointsObject extends Group {
20
20
  private readonly _colorBuffer;
21
21
  private readonly _colorAttribute;
22
22
  private readonly _points;
23
+ private readonly _onBeforeRender?;
23
24
  private _modelTransform;
24
- constructor(maxNumberOfPoints: number, materialParameters: OverlayPointsParameters);
25
+ constructor(maxNumberOfPoints: number, materialParameters: OverlayPointsParameters, onBeforeRender?: Object3D['onBeforeRender']);
25
26
  setPoints(points: Vector3[], colors?: Color[]): void;
26
27
  setTransform(transform: Matrix4): void;
27
28
  getTransform(out?: Matrix4): Matrix4;
@@ -65,14 +65,10 @@ export type OverlayCollectionOptions = {
65
65
  */
66
66
  export declare class Overlay3DTool<ContentType = DefaultOverlay3DContentType> extends Cognite3DViewerToolBase {
67
67
  private readonly _viewer;
68
- private readonly _textOverlay;
69
68
  private readonly _defaultOverlayColor;
70
- private readonly _defaultTextOverlayToCursorOffset;
71
- private readonly _temporaryVec;
72
- private readonly _raycaster;
73
69
  private _overlayCollections;
74
70
  private _isVisible;
75
- private _textOverlayVisible;
71
+ private readonly _textOverlay;
76
72
  private readonly _events;
77
73
  constructor(viewer: Cognite3DViewer, toolParameters?: Overlay3DToolParameters);
78
74
  /**
@@ -128,7 +124,5 @@ export declare class Overlay3DTool<ContentType = DefaultOverlay3DContentType> ex
128
124
  dispose(): void;
129
125
  private readonly onMouseMove;
130
126
  private readonly onMouseClick;
131
- private positionTextOverlay;
132
127
  private intersectPointsMarkers;
133
- private createTextOverlay;
134
128
  }
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * Copyright 2024 Cognite AS
3
+ */
4
+ export declare class TextOverlay {
5
+ private readonly _textOverlay;
6
+ private readonly _defaultTextOverlayToCursorOffset;
7
+ private _textOverlayVisible;
8
+ constructor(domElement: HTMLElement);
9
+ get textOverlay(): HTMLElement;
10
+ /**
11
+ * Sets whether text overlay is visible.
12
+ * Default is false.
13
+ */
14
+ setTextOverlayEnabled(visible: boolean): void;
15
+ /**
16
+ * Resets (i.e. hides) text overlay before recalculating position/visibility
17
+ */
18
+ reset(): void;
19
+ /**
20
+ * Gets whether text overlay is visible.
21
+ */
22
+ getTextOverlayEnabled(): boolean;
23
+ dispose(): void;
24
+ positionTextOverlay(event: MouseEvent): void;
25
+ private createTextOverlay;
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognite/reveal",
3
- "version": "4.14.9-dev.20240621",
3
+ "version": "4.15.0-dev.20240624",
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": {