@cognite/reveal 2.2.1 → 2.2.2
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.
- package/core/src/public/migration/Cognite3DViewer.d.ts +58 -2
- package/core/src/public/migration/types.d.ts +24 -0
- package/index.js +37 -37
- package/index.map +1 -1
- package/package.json +2 -2
- package/packages/camera-manager/src/ComboControls.d.ts +34 -18
- package/packages/utilities/src/NumericRange.d.ts +1 -0
- package/tools.js +12 -12
- package/tools.map +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright 2021 Cognite AS
|
|
3
3
|
*/
|
|
4
4
|
import * as THREE from 'three';
|
|
5
|
-
import { AddModelOptions, Cognite3DViewerOptions, Intersection, CameraChangeDelegate, PointerEventDelegate, CadModelBudget, PointCloudBudget } from './types';
|
|
5
|
+
import { AddModelOptions, Cognite3DViewerOptions, Intersection, CameraChangeDelegate, PointerEventDelegate, CadModelBudget, PointCloudBudget, CameraControlsOptions } from './types';
|
|
6
6
|
import { CogniteModelBase } from './CogniteModelBase';
|
|
7
7
|
import { Cognite3DModel } from './Cognite3DModel';
|
|
8
8
|
import { CognitePointCloudModel } from './CognitePointCloudModel';
|
|
@@ -49,11 +49,19 @@ export declare class Cognite3DViewer {
|
|
|
49
49
|
private readonly _domElement;
|
|
50
50
|
private readonly _renderer;
|
|
51
51
|
private readonly _boundAnimate;
|
|
52
|
+
private _onClick;
|
|
53
|
+
private _onWheel;
|
|
52
54
|
private readonly _events;
|
|
55
|
+
private _cameraControlsOptions;
|
|
53
56
|
private readonly _models;
|
|
54
57
|
private readonly _extraObjects;
|
|
55
58
|
private readonly _automaticNearFarPlane;
|
|
56
59
|
private readonly _automaticControlsSensitivity;
|
|
60
|
+
private readonly _animationDuration;
|
|
61
|
+
private readonly _minDefaultAnimationDuration;
|
|
62
|
+
private readonly _maxDefaultAnimationDuration;
|
|
63
|
+
private readonly _minDistanceDefault;
|
|
64
|
+
private readonly raycaster;
|
|
57
65
|
private isDisposed;
|
|
58
66
|
private readonly renderController;
|
|
59
67
|
private latestRequestId;
|
|
@@ -65,6 +73,37 @@ export declare class Cognite3DViewer {
|
|
|
65
73
|
* Reusable buffers used by functions in Cognite3dViewer to avoid allocations.
|
|
66
74
|
*/
|
|
67
75
|
private readonly _updateNearAndFarPlaneBuffers;
|
|
76
|
+
/**
|
|
77
|
+
* Convert pixel coordinates of the cursor to [-1,1]^2 coordinates.
|
|
78
|
+
* @param pixelX
|
|
79
|
+
* @param pixelY
|
|
80
|
+
*/
|
|
81
|
+
private convertPixelCoordinatesToNormalized;
|
|
82
|
+
/**
|
|
83
|
+
* Calculates new target when raycaster doesn't have any intersections with the model.
|
|
84
|
+
* @param cursorPosition Cursor position for desired calculations.
|
|
85
|
+
* @param cursorPosition.x
|
|
86
|
+
* @param cursorPosition.y
|
|
87
|
+
*/
|
|
88
|
+
private calculateMissedRaycast;
|
|
89
|
+
/**
|
|
90
|
+
* Removes controls event listeners if they are defined.
|
|
91
|
+
*/
|
|
92
|
+
private teardownControls;
|
|
93
|
+
/**
|
|
94
|
+
* Method for setting up camera controls listeners and values inside current controls class.
|
|
95
|
+
*/
|
|
96
|
+
private setupControls;
|
|
97
|
+
/**
|
|
98
|
+
* Changes controls target based on current cursor position.
|
|
99
|
+
* @param event MouseEvent that contains pointer location data.
|
|
100
|
+
*/
|
|
101
|
+
private changeTarget;
|
|
102
|
+
/**
|
|
103
|
+
* Changes controls scroll target based on current cursor position.
|
|
104
|
+
* @param event MouseEvent that contains pointer location data.
|
|
105
|
+
*/
|
|
106
|
+
private changeScrollTarget;
|
|
68
107
|
/**
|
|
69
108
|
* Gets the current budget for downloading geometry for CAD models. Note that this
|
|
70
109
|
* budget is shared between all added CAD models and not a per-model budget.
|
|
@@ -147,6 +186,15 @@ export declare class Cognite3DViewer {
|
|
|
147
186
|
off(event: 'cameraChange', callback: CameraChangeDelegate): void;
|
|
148
187
|
off(event: 'sceneRendered', callback: SceneRenderedDelegate): void;
|
|
149
188
|
off(event: 'disposed', callback: DisposedDelegate): void;
|
|
189
|
+
/**
|
|
190
|
+
* Sets camera controls mode anything allowed in CameraControlsOptions type.
|
|
191
|
+
* @param controlsOptions JSON object with camera controls options.
|
|
192
|
+
*/
|
|
193
|
+
setCameraControlsOptions(controlsOptions: CameraControlsOptions): void;
|
|
194
|
+
/**
|
|
195
|
+
* Gets camera controls mode.
|
|
196
|
+
*/
|
|
197
|
+
getCameraControlsOptions(): CameraControlsOptions;
|
|
150
198
|
/**
|
|
151
199
|
* Gets the current viewer state which includes the camera pose as well as applied styling.
|
|
152
200
|
* @returns JSON object containing viewer state.
|
|
@@ -358,6 +406,7 @@ export declare class Cognite3DViewer {
|
|
|
358
406
|
* Set camera's target.
|
|
359
407
|
* @public
|
|
360
408
|
* @param target Target in world space.
|
|
409
|
+
* @param animated Whether change of target should be animated or not (default is false).
|
|
361
410
|
* @example
|
|
362
411
|
* ```js
|
|
363
412
|
* // store position, target
|
|
@@ -368,7 +417,7 @@ export declare class Cognite3DViewer {
|
|
|
368
417
|
* viewer.setCameraTarget(target);
|
|
369
418
|
* ```
|
|
370
419
|
*/
|
|
371
|
-
setCameraTarget(target: THREE.Vector3): void;
|
|
420
|
+
setCameraTarget(target: THREE.Vector3, animated?: boolean): void;
|
|
372
421
|
/**
|
|
373
422
|
* Gets the camera controller. See https://www.npmjs.com/package/@cognite/three-combo-controls
|
|
374
423
|
* for documentation. Note that by default the `minDistance` setting of the controls will
|
|
@@ -539,6 +588,13 @@ export declare class Cognite3DViewer {
|
|
|
539
588
|
*/
|
|
540
589
|
getIntersectionFromPixel(offsetX: number, offsetY: number, options?: IntersectionFromPixelOptions): Promise<null | Intersection>;
|
|
541
590
|
private getModels;
|
|
591
|
+
/**
|
|
592
|
+
* Calculates default duration for camera animation based on distance from the camera to the object.
|
|
593
|
+
* @param distanceToCamera
|
|
594
|
+
*/
|
|
595
|
+
private calculateDefaultDuration;
|
|
596
|
+
/** @private */
|
|
597
|
+
private moveCameraTargetTo;
|
|
542
598
|
/** @private */
|
|
543
599
|
private moveCameraTo;
|
|
544
600
|
/**
|
|
@@ -134,6 +134,30 @@ export interface AddModelOptions {
|
|
|
134
134
|
localPath?: string;
|
|
135
135
|
geometryFilter?: GeometryFilter;
|
|
136
136
|
}
|
|
137
|
+
export declare type CameraControlsOptions = {
|
|
138
|
+
/**
|
|
139
|
+
* Sets mouse wheel initiated action.
|
|
140
|
+
*
|
|
141
|
+
* Modes:
|
|
142
|
+
*
|
|
143
|
+
* 'zoomToTarget' - zooms just to the current target (center of the screen) of the camera.
|
|
144
|
+
*
|
|
145
|
+
* 'zoomPastCursor' - zooms in the direction of the ray coming from camera through cursor screen position, allows going through objects.
|
|
146
|
+
*
|
|
147
|
+
* 'zoomToCursor' - mouse wheel scroll zooms towards the point on the model where cursor is hovering over, doesn't allow going through objects.
|
|
148
|
+
*
|
|
149
|
+
* Default is 'zoomPastCursor'.
|
|
150
|
+
*
|
|
151
|
+
*/
|
|
152
|
+
mouseWheelAction?: 'zoomToTarget' | 'zoomPastCursor' | 'zoomToCursor';
|
|
153
|
+
/**
|
|
154
|
+
* Enables or disables change of camera target on mouse click. New target is then set to the point of the model under current cursor position.
|
|
155
|
+
*
|
|
156
|
+
* Default is false.
|
|
157
|
+
*
|
|
158
|
+
*/
|
|
159
|
+
onClickTargetChange?: boolean;
|
|
160
|
+
};
|
|
137
161
|
export declare type CadIntersection = {
|
|
138
162
|
/**
|
|
139
163
|
* The intersection type.
|