@@ -90,6 +90,7 @@ const plane = new THREE.Plane(
90
90
91
91
// default parameters :
92
92
const defaultOptions = {
93
+ enabled : true ,
93
94
enableRotation : true ,
94
95
rotateSpeed : 2.0 ,
95
96
minPanSpeed : 0.05 ,
@@ -134,6 +135,7 @@ export const PLANAR_CONTROL_EVENT = {
134
135
* @class PlanarControls
135
136
* @param {PlanarView } view the view where the controls will be used
136
137
* @param {object } options
138
+ * @param {boolean } [options.enabled=true] Set to false to disable this control
137
139
* @param {boolean } [options.enableRotation=true] Enable the rotation with the `CTRL + Left mouse button`
138
140
* and in animations, like the smart zoom.
139
141
* @param {boolean } [options.enableSmartTravel=true] Enable smart travel with the `wheel-click / space-bar`.
@@ -173,6 +175,9 @@ class PlanarControls extends THREE.EventDispatcher {
173
175
this . view = view ;
174
176
this . camera = view . camera . camera3D ;
175
177
178
+ // Set to false to disable this control
179
+ this . enabled = typeof options . enabled == 'boolean' ? options . enabled : defaultOptions . enabled ;
180
+
176
181
if ( this . camera . isOrthographicCamera ) {
177
182
cameraInitialZoom = this . camera . zoom ;
178
183
@@ -969,6 +974,10 @@ class PlanarControls extends THREE.EventDispatcher {
969
974
* @ignore
970
975
*/
971
976
onMouseDown ( event ) {
977
+ if ( ! this . enabled ) {
978
+ return ;
979
+ }
980
+
972
981
event . preventDefault ( ) ;
973
982
974
983
this . view . domElement . focus ( ) ;
@@ -1036,6 +1045,10 @@ class PlanarControls extends THREE.EventDispatcher {
1036
1045
* @ignore
1037
1046
*/
1038
1047
onMouseMove ( event ) {
1048
+ if ( ! this . enabled ) {
1049
+ return ;
1050
+ }
1051
+
1039
1052
event . preventDefault ( ) ;
1040
1053
1041
1054
this . updateMousePositionAndDelta ( event ) ;
@@ -1053,7 +1066,7 @@ class PlanarControls extends THREE.EventDispatcher {
1053
1066
* @ignore
1054
1067
*/
1055
1068
onKeyDown ( event ) {
1056
- if ( STATE . NONE !== this . state ) {
1069
+ if ( STATE . NONE !== this . state || ! this . enabled ) {
1057
1070
return ;
1058
1071
}
1059
1072
switch ( event . keyCode ) {
@@ -1083,6 +1096,10 @@ class PlanarControls extends THREE.EventDispatcher {
1083
1096
* @ignore
1084
1097
*/
1085
1098
onMouseWheel ( event ) {
1099
+ if ( ! this . enabled ) {
1100
+ return ;
1101
+ }
1102
+
1086
1103
event . preventDefault ( ) ;
1087
1104
event . stopPropagation ( ) ;
1088
1105
0 commit comments