@cognite/reveal 4.10.1 → 4.10.3

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.
@@ -12,6 +12,7 @@ import { CameraManager, CameraChangeDelegate, CameraStopDelegate } from '../../.
12
12
  import { Image360DataModelIdentifier } from '../../../../data-providers';
13
13
  import { SupportedModelTypes } from '../../../../model-base';
14
14
  import { Image360Collection, Image360, Image360Revision, Image360AnnotationIntersection } from '../../../../360-images';
15
+ import { CustomObject } from '../../../../utilities';
15
16
  /**
16
17
  * @example
17
18
  * ```js
@@ -365,6 +366,22 @@ export declare class Cognite3DViewer {
365
366
  * ```
366
367
  */
367
368
  addObject3D(object: THREE.Object3D): void;
369
+ /**
370
+ * Add a CustomObject to the viewer.
371
+ * @param customObject
372
+ * @example
373
+ * ```js
374
+ * const sphere = new THREE.Mesh(
375
+ * new THREE.SphereGeometry(),
376
+ * new THREE.MeshBasicMaterial()
377
+ * );
378
+ * const customObject = CustomObject(sphere);
379
+ * customObject.isPartOfBoundingBox = false;
380
+ * viewer.addCustomObject(customObject);
381
+ * ```
382
+ * @beta
383
+ */
384
+ addCustomObject(customObject: CustomObject): void;
368
385
  /**
369
386
  * Remove a THREE.Object3D from the viewer.
370
387
  * @param object
@@ -376,6 +393,19 @@ export declare class Cognite3DViewer {
376
393
  * ```
377
394
  */
378
395
  removeObject3D(object: THREE.Object3D): void;
396
+ /**
397
+ * Remove a CustomObject from the viewer.
398
+ * @param customObject
399
+ * @example
400
+ * ```js
401
+ * const sphere = new THREE.Mesh(new THREE.SphereGeometry(), new THREE.MeshBasicMaterial());
402
+ * const customObject = CustomObject(sphere);
403
+ * viewer.addCustomObject(sphere);
404
+ * viewer.removeCustomObject(sphere);
405
+ * ```
406
+ * @beta
407
+ */
408
+ removeCustomObject(customObject: CustomObject): void;
379
409
  /**
380
410
  * Sets the color used as the clear color of the renderer.
381
411
  * @param backgroundColor
@@ -604,6 +634,8 @@ export declare class Cognite3DViewer {
604
634
  private animate;
605
635
  /** @private */
606
636
  private intersectModels;
637
+ private getCustomObjectIntersectionIfCloser;
638
+ private createCustomObjectIntersectInput;
607
639
  /**
608
640
  * Callback used by DefaultCameraManager to do model intersection. Made synchronous to avoid
609
641
  * input lag when zooming in and out. Default implementation is async. See PR #2405 for more info.
@@ -39,6 +39,9 @@ export { LineGeometry } from './src/three/lines/LineGeometry';
39
39
  export { LineMaterial } from './src/three/lines/LineMaterial';
40
40
  export { DeferredPromise } from './src/DeferredPromise';
41
41
  export { SceneHandler } from './src/SceneHandler';
42
+ export { CustomObject } from './src/customObject/CustomObject';
43
+ export { CustomObjectIntersectInput } from './src/customObject/CustomObjectIntersectInput';
44
+ export { CustomObjectIntersection } from './src/customObject/CustomObjectIntersection';
42
45
  export { CDF_TO_VIEWER_TRANSFORMATION } from './src/constants';
43
46
  export * from './src/workers/workerize-transferable';
44
47
  export * from './src/shapes';
@@ -2,6 +2,7 @@
2
2
  * Copyright 2022 Cognite AS
3
3
  */
4
4
  import * as THREE from 'three';
5
+ import { CustomObject } from './customObject/CustomObject';
5
6
  export declare class SceneHandler {
6
7
  private readonly _scene;
7
8
  private readonly _cadModels;
@@ -16,13 +17,15 @@ export declare class SceneHandler {
16
17
  pointCloudNode: THREE.Object3D;
17
18
  modelIdentifier: symbol;
18
19
  }[];
19
- get customObjects(): THREE.Object3D[];
20
+ get customObjects(): CustomObject[];
20
21
  constructor();
21
22
  addCadModel(cadNode: THREE.Object3D, modelIdentifier: string): void;
22
23
  addPointCloudModel(pointCloudNode: THREE.Object3D, modelIdentifier: symbol): void;
23
24
  removePointCloudModel(pointCloudNode: THREE.Object3D): void;
24
25
  removeCadModel(cadNode: THREE.Object3D): void;
25
- addCustomObject(object: THREE.Object3D): void;
26
- removeCustomObject(object: THREE.Object3D): void;
26
+ addObject3D(object: THREE.Object3D): void;
27
+ addCustomObject(customObject: CustomObject): void;
28
+ removeObject3D(object: THREE.Object3D): void;
29
+ removeCustomObject(customObject: CustomObject): void;
27
30
  dispose(): void;
28
31
  }
@@ -0,0 +1,54 @@
1
+ /*!
2
+ * Copyright 2024 Cognite AS
3
+ */
4
+ import { Object3D } from 'three';
5
+ import { CustomObjectIntersection } from './CustomObjectIntersection';
6
+ import { CustomObjectIntersectInput } from './CustomObjectIntersectInput';
7
+ /**
8
+ * This class encasulate a Object3D, and made it possible to add flags to it.
9
+ * It might be extended with more flags in the future.
10
+ * @beta
11
+ */
12
+ export declare class CustomObject {
13
+ private readonly _object;
14
+ private _isPartOfBoundingBox;
15
+ private _shouldPick;
16
+ private _shouldPickBoundingBox;
17
+ /**
18
+ * Constructor
19
+ * @beta
20
+ */
21
+ constructor(object: Object3D);
22
+ /**
23
+ * Get the Object3D
24
+ * @beta
25
+ */
26
+ get object(): Object3D;
27
+ /**
28
+ * Set or get whether it should be part of the combined bounding box or not.
29
+ * Default is true.
30
+ * @beta
31
+ */
32
+ get isPartOfBoundingBox(): boolean;
33
+ set isPartOfBoundingBox(value: boolean);
34
+ /**
35
+ * Set or get whether it should be picked by the camera manager
36
+ * Default is false.
37
+ * @beta
38
+ */
39
+ get shouldPick(): boolean;
40
+ set shouldPick(value: boolean);
41
+ /**
42
+ * Set or get whether it should be also give the bounding box when picked by the camera
43
+ * Default is false.
44
+ * @beta
45
+ */
46
+ get shouldPickBoundingBox(): boolean;
47
+ set shouldPickBoundingBox(value: boolean);
48
+ /**
49
+ * Intersect the object with the raycaster.
50
+ * This function can be overridden to provide custom intersection logic.
51
+ * @beta
52
+ */
53
+ intersectIfCloser(intersectInput: CustomObjectIntersectInput, closestDistance: number | undefined): undefined | CustomObjectIntersection;
54
+ }
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Copyright 2024 Cognite AS
3
+ */
4
+ import { Raycaster, Vector3, Vector2, PerspectiveCamera, Plane } from 'three';
5
+ /**
6
+ * This class is used as input for intersecting custom objects
7
+ * @beta
8
+ */
9
+ export declare class CustomObjectIntersectInput {
10
+ readonly normalizedCoords: Vector2;
11
+ readonly camera: PerspectiveCamera;
12
+ readonly clippingPlanes: Plane[] | undefined;
13
+ readonly raycaster: Raycaster;
14
+ constructor(normalizedCoords: Vector2, camera: PerspectiveCamera, clippingPlanes?: Plane[] | undefined);
15
+ isVisible(point: Vector3): boolean;
16
+ }
@@ -0,0 +1,25 @@
1
+ /*!
2
+ * Copyright 2024 Cognite AS
3
+ */
4
+ import { Vector3, Box3 } from 'three';
5
+ import { CustomObject } from './CustomObject';
6
+ /**
7
+ * This class is used as output intersecting custom objects
8
+ * @beta
9
+ */
10
+ export type CustomObjectIntersection = {
11
+ /**
12
+ * The intersection type.
13
+ */
14
+ type: 'customObject';
15
+ /**
16
+ * Coordinate of the intersection.
17
+ */
18
+ point: Vector3;
19
+ /**
20
+ * Distance from the camera to the intersection.
21
+ */
22
+ distanceToCamera: number;
23
+ customObject: CustomObject;
24
+ boundingBox?: Box3;
25
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognite/reveal",
3
- "version": "4.10.1",
3
+ "version": "4.10.3",
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": {
@@ -81,7 +81,7 @@
81
81
  "devDependencies": {
82
82
  "@azure/msal-browser": "2.38.3",
83
83
  "@cognite/sdk": "8.3.0",
84
- "@microsoft/api-extractor": "7.40.1",
84
+ "@microsoft/api-extractor": "7.40.2",
85
85
  "@types/dat.gui": "0.7.12",
86
86
  "@types/gl": "^6.0.2",
87
87
  "@types/glob": "8.1.0",
@@ -91,7 +91,7 @@
91
91
  "@types/jsdom": "21.1.6",
92
92
  "@types/lodash": "4.14.202",
93
93
  "@types/mixpanel-browser": "2.49.0",
94
- "@types/node": "18.19.15",
94
+ "@types/node": "18.19.17",
95
95
  "@types/random-seed": "0.3.5",
96
96
  "@types/skmeans": "0.11.7",
97
97
  "@types/stats": "0.16.30",
@@ -122,7 +122,7 @@
122
122
  "jest-puppeteer": "9.0.2",
123
123
  "jsdom": "23.2.0",
124
124
  "moq.ts": "10.0.8",
125
- "nock": "13.5.1",
125
+ "nock": "13.5.3",
126
126
  "prettier": "3.2.5",
127
127
  "process": "0.11.10",
128
128
  "puppeteer": "21.11.0",
@@ -138,7 +138,7 @@
138
138
  "tsc-alias": "1.8.8",
139
139
  "typescript": "5.3.3",
140
140
  "wasm-pack": "0.12.1",
141
- "webpack": "5.90.1",
141
+ "webpack": "5.90.2",
142
142
  "webpack-cli": "5.1.4",
143
143
  "webpack-dev-server": "4.15.1",
144
144
  "webpack-node-externals": "3.0.0",