Skip to content

Commit 38406b9

Browse files
committed
feat: add Cognite3dViewer.cameraControlsEnabled to allow disabling navigation
1 parent 9631344 commit 38406b9

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

viewer/src/public/migration/Cognite3DViewer.ts

+22-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
import * as THREE from 'three';
6+
67
import TWEEN from '@tweenjs/tween.js';
78
import debounce from 'lodash/debounce';
89
import omit from 'lodash/omit';
@@ -664,6 +665,24 @@ export class Cognite3DViewer {
664665
this.controls.setState(this.getCameraPosition(), target);
665666
}
666667

668+
/**
669+
* Gets wheter camera controls through mouse, touch and keyboard are enabled.
670+
* @version new in 1.2.0
671+
*/
672+
get cameraControlsEnabled(): boolean {
673+
return this.controls.enabled;
674+
}
675+
676+
/**
677+
* Sets wheter camera controls through mouse, touch and keyboard are enabled.
678+
* This can be useful to e.g. temporarily disable navigation when manipulating other
679+
* objects in the scene or when implementing a "cinematic" viewer.
680+
* @version new in 1.2.0
681+
*/
682+
set cameraControlsEnabled(enabled: boolean) {
683+
this.controls.enabled = enabled;
684+
}
685+
667686
/**
668687
* Attempts to load the camera settings from the settings stored for the
669688
* provided model. See {@link https://docs.cognite.com/api/v1/#operation/get3DRevision}
@@ -1258,11 +1277,11 @@ export class Cognite3DViewer {
12581277
};
12591278

12601279
// down
1261-
canvas.addEventListener('mousedown', onDown);
1262-
canvas.addEventListener('touchstart', onDown);
1280+
// canvas.addEventListener('mousedown', onDown);
1281+
// canvas.addEventListener('touchstart', onDown);
12631282

12641283
// on hover callback
1265-
canvas.addEventListener('mousemove', onHoverCallback);
1284+
// canvas.addEventListener('mousemove', onHoverCallback);
12661285
};
12671286
}
12681287

0 commit comments

Comments
 (0)