@xtctwins/tctwins-core 1.0.14 → 1.0.15

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.
@@ -12019,396 +12019,393 @@ const MOUSE_FINDING_TARGET = 2;
12019
12019
  * ````
12020
12020
  */
12021
12021
  class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12022
+ /**
12023
+ * Creates a AngleMeasurementsMouseControl bound to the given AngleMeasurementsPlugin.
12024
+ *
12025
+ * @param {AngleMeasurementsPlugin} angleMeasurementsPlugin The AngleMeasurementsPlugin to control.
12026
+ * @param {*} [cfg] Configuration
12027
+ * @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor when snapping is enabled.
12028
+ * @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this AngleMeasurementsMouseControl.
12029
+ */
12030
+ constructor(angleMeasurementsPlugin, cfg = {}) {
12031
+ super(angleMeasurementsPlugin.viewer.scene);
12022
12032
 
12023
- /**
12024
- * Creates a AngleMeasurementsMouseControl bound to the given AngleMeasurementsPlugin.
12025
- *
12026
- * @param {AngleMeasurementsPlugin} angleMeasurementsPlugin The AngleMeasurementsPlugin to control.
12027
- * @param {*} [cfg] Configuration
12028
- * @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor when snapping is enabled.
12029
- * @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this AngleMeasurementsMouseControl.
12030
- */
12031
- constructor(angleMeasurementsPlugin, cfg = {}) {
12032
-
12033
- super(angleMeasurementsPlugin.viewer.scene);
12034
-
12035
- this.pointerLens = cfg.pointerLens;
12036
-
12037
- this._active = false;
12038
- this._mouseState = MOUSE_FINDING_ORIGIN;
12039
-
12040
- this._currentAngleMeasurement = null;
12041
-
12042
- // init markerDiv element (think about making its style configurable)
12043
- this._initMarkerDiv();
12033
+ this.pointerLens = cfg.pointerLens;
12044
12034
 
12045
- this._onMouseHoverSurface = null;
12046
- this._onHoverNothing = null;
12047
- this._onPickedNothing = null;
12048
- this._onPickedSurface = null;
12035
+ this._active = false;
12036
+ this._mouseState = MOUSE_FINDING_ORIGIN;
12049
12037
 
12050
- this._onInputMouseDown = null;
12051
- this._onInputMouseUp = null;
12038
+ this._currentAngleMeasurement = null;
12052
12039
 
12053
- this._snapping = cfg.snapping !== false;
12040
+ // init markerDiv element (think about making its style configurable)
12041
+ this._initMarkerDiv();
12054
12042
 
12055
- this._attachPlugin(angleMeasurementsPlugin, cfg);
12056
- }
12043
+ this._onMouseHoverSurface = null;
12044
+ this._onHoverNothing = null;
12045
+ this._onPickedNothing = null;
12046
+ this._onPickedSurface = null;
12057
12047
 
12058
- _initMarkerDiv() {
12059
- const markerDiv = document.createElement('div');
12060
- markerDiv.setAttribute('id', 'myAngleMeasureMarker');
12061
- const canvas = this.scene.canvas.canvas;
12062
- canvas.parentNode.insertBefore(markerDiv, canvas);
12048
+ this._onInputMouseDown = null;
12049
+ this._onInputMouseUp = null;
12063
12050
 
12064
- markerDiv.style.background = "black";
12065
- markerDiv.style.border = "2px solid blue";
12066
- markerDiv.style.borderRadius = "10px";
12067
- markerDiv.style.width = "5px";
12068
- markerDiv.style.height = "5px";
12069
- markerDiv.style.margin = "-200px -200px";
12070
- markerDiv.style.zIndex = "100";
12071
- markerDiv.style.position = "absolute";
12072
- markerDiv.style.pointerEvents = "none";
12051
+ this._snapping = cfg.snapping !== false;
12073
12052
 
12074
- this.markerDiv = markerDiv;
12075
- }
12053
+ this._attachPlugin(angleMeasurementsPlugin, cfg);
12054
+ }
12076
12055
 
12077
- _destroyMarkerDiv() {
12078
- if (this.markerDiv) {
12079
- const element = document.getElementById('myAngleMeasureMarker');
12080
- element.parentNode.removeChild(element);
12081
- this.markerDiv = null;
12082
- }
12083
- }
12056
+ _initMarkerDiv() {
12057
+ const markerDiv = document.createElement("div");
12058
+ markerDiv.setAttribute("id", "myAngleMeasureMarker");
12059
+ const canvas = this.scene.canvas.canvas;
12060
+ canvas.parentNode.insertBefore(markerDiv, canvas);
12061
+
12062
+ markerDiv.style.background = "black";
12063
+ markerDiv.style.border = "2px solid blue";
12064
+ markerDiv.style.borderRadius = "10px";
12065
+ markerDiv.style.width = "5px";
12066
+ markerDiv.style.height = "5px";
12067
+ markerDiv.style.margin = "-200px -200px";
12068
+ markerDiv.style.zIndex = "100";
12069
+ markerDiv.style.position = "absolute";
12070
+ markerDiv.style.pointerEvents = "none";
12071
+
12072
+ this.markerDiv = markerDiv;
12073
+ }
12084
12074
 
12085
- _attachPlugin(angleMeasurementsPlugin, cfg = {}) {
12075
+ _destroyMarkerDiv() {
12076
+ if (this.markerDiv) {
12077
+ const element = document.getElementById("myAngleMeasureMarker");
12078
+ element.parentNode.removeChild(element);
12079
+ this.markerDiv = null;
12080
+ }
12081
+ }
12086
12082
 
12087
- /**
12088
- * The {@link AngleMeasurementsPlugin} that owns this AngleMeasurementsMouseControl.
12089
- *
12090
- * @type {AngleMeasurementsPlugin}
12091
- */
12092
- this.angleMeasurementsPlugin = angleMeasurementsPlugin;
12083
+ _attachPlugin(angleMeasurementsPlugin, cfg = {}) {
12084
+ /**
12085
+ * The {@link AngleMeasurementsPlugin} that owns this AngleMeasurementsMouseControl.
12086
+ *
12087
+ * @type {AngleMeasurementsPlugin}
12088
+ */
12089
+ this.angleMeasurementsPlugin = angleMeasurementsPlugin;
12093
12090
 
12094
- /**
12095
- * The {@link AngleMeasurementsPlugin} that owns this AngleMeasurementsMouseControl.
12096
- *
12097
- * @type {AngleMeasurementsPlugin}
12098
- */
12099
- this.plugin = angleMeasurementsPlugin;
12100
- }
12091
+ /**
12092
+ * The {@link AngleMeasurementsPlugin} that owns this AngleMeasurementsMouseControl.
12093
+ *
12094
+ * @type {AngleMeasurementsPlugin}
12095
+ */
12096
+ this.plugin = angleMeasurementsPlugin;
12097
+ }
12101
12098
 
12102
- /**
12103
- * Gets if this AngleMeasurementsMouseControl is currently active, where it is responding to input.
12104
- *
12105
- * @returns {boolean}
12106
- */
12107
- get active() {
12108
- return this._active;
12109
- }
12099
+ /**
12100
+ * Gets if this AngleMeasurementsMouseControl is currently active, where it is responding to input.
12101
+ *
12102
+ * @returns {boolean}
12103
+ */
12104
+ get active() {
12105
+ return this._active;
12106
+ }
12110
12107
 
12111
- /**
12112
- * Sets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
12113
- *
12114
- * This is `true` by default.
12115
- *
12116
- * Internally, this deactivates then activates the AngleMeasurementsMouseControl when changed, which means that
12117
- * it will destroy any AngleMeasurements currently under construction, and incurs some overhead, since it unbinds
12118
- * and rebinds various input handlers.
12119
- *
12120
- * @param {boolean} snapping Whether to enable snap-to-vertex and snap-edge for this AngleMeasurementsMouseControl.
12121
- */
12122
- set snapping(snapping) {
12123
- if (snapping !== this._snapping) {
12124
- this._snapping = snapping;
12125
- this.deactivate();
12126
- this.activate();
12127
- } else {
12128
- this._snapping = snapping;
12129
- }
12130
- }
12108
+ /**
12109
+ * Sets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
12110
+ *
12111
+ * This is `true` by default.
12112
+ *
12113
+ * Internally, this deactivates then activates the AngleMeasurementsMouseControl when changed, which means that
12114
+ * it will destroy any AngleMeasurements currently under construction, and incurs some overhead, since it unbinds
12115
+ * and rebinds various input handlers.
12116
+ *
12117
+ * @param {boolean} snapping Whether to enable snap-to-vertex and snap-edge for this AngleMeasurementsMouseControl.
12118
+ */
12119
+ set snapping(snapping) {
12120
+ if (snapping !== this._snapping) {
12121
+ this._snapping = snapping;
12122
+ this.deactivate();
12123
+ this.activate();
12124
+ } else {
12125
+ this._snapping = snapping;
12126
+ }
12127
+ }
12131
12128
 
12132
- /**
12133
- * Gets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
12134
- *
12135
- * This is `true` by default.
12136
- *
12137
- * @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
12138
- */
12139
- get snapping() {
12140
- return this._snapping;
12141
- }
12129
+ /**
12130
+ * Gets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
12131
+ *
12132
+ * This is `true` by default.
12133
+ *
12134
+ * @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
12135
+ */
12136
+ get snapping() {
12137
+ return this._snapping;
12138
+ }
12142
12139
 
12143
- /**
12144
- * Activates this AngleMeasurementsMouseControl, ready to respond to input.
12145
- */
12146
- activate() {
12147
- if (this._active) {
12148
- return;
12149
- }
12150
- if (!this.markerDiv) {
12151
- this._initMarkerDiv(); // if the marker is destroyed after deactivation, we recreate it
12152
- }
12153
- this.angleMeasurementsPlugin;
12154
- const scene = this.scene;
12155
- scene.input;
12156
- const canvas = scene.canvas.canvas;
12157
- const clickTolerance = 20;
12158
- const cameraControl = this.angleMeasurementsPlugin.viewer.cameraControl;
12159
- const pointerLens = this.pointerLens;
12160
- let mouseHovering = false;
12161
- let hoveredEntity = null;
12162
- let lastMouseCanvasX = 0;
12163
- let lastMouseCanvasY = 0;
12164
- const mouseWorldPos = math.vec3();
12165
- const mouseHoverCanvasPos = math.vec2();
12166
- this._currentAngleMeasurement = null;
12167
- this._onMouseHoverSurface = cameraControl.on(
12168
- this._snapping
12169
- ? "hoverSnapOrSurface"
12170
- : "hoverSurface",
12171
- event => {
12172
- if (event.snappedToVertex || event.snappedToEdge) {
12173
- if (pointerLens) {
12174
- pointerLens.visible = true;
12175
- pointerLens.canvasPos = event.canvasPos;
12176
- pointerLens.snappedCanvasPos = event.snappedCanvasPos || event.canvasPos;
12177
- pointerLens.snapped = true;
12178
- }
12179
- this.markerDiv.style.background = "greenyellow";
12180
- this.markerDiv.style.border = "2px solid green";
12181
- } else {
12182
- if (pointerLens) {
12183
- pointerLens.visible = true;
12184
- pointerLens.canvasPos = event.canvasPos;
12185
- pointerLens.snappedCanvasPos = event.canvasPos;
12186
- pointerLens.snapped = false;
12187
- }
12188
- this.markerDiv.style.background = "pink";
12189
- this.markerDiv.style.border = "2px solid red";
12190
- }
12191
- const canvasPos = event.snappedCanvasPos || event.canvasPos;
12192
- mouseHovering = true;
12193
- hoveredEntity = event.entity;
12194
- mouseWorldPos.set(event.worldPos);
12195
- mouseHoverCanvasPos.set(canvasPos);
12196
- switch (this._mouseState) {
12197
- case MOUSE_FINDING_ORIGIN:
12198
- const canvasBoundRect = canvas.getBoundingClientRect();
12199
- const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
12200
- const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
12201
- const canvasLeftEdge = canvasBoundRect.left + scrollLeft;
12202
- const canvasTopEdge = canvasBoundRect.top + scrollTop;
12203
- this.markerDiv.style.marginLeft = `${canvasLeftEdge + canvasPos[0] - 5}px`;
12204
- this.markerDiv.style.marginTop = `${canvasTopEdge + canvasPos[1] - 5}px`;
12205
- break;
12206
- case MOUSE_FINDING_CORNER:
12207
- if (this._currentAngleMeasurement) {
12208
- this._currentAngleMeasurement.originWireVisible = true;
12209
- this._currentAngleMeasurement.targetWireVisible = false;
12210
- this._currentAngleMeasurement.cornerVisible = true;
12211
- this._currentAngleMeasurement.angleVisible = false;
12212
- this._currentAngleMeasurement.corner.worldPos = event.worldPos;
12213
- this._currentAngleMeasurement.corner.entity = event.entity;
12214
- }
12215
- this.markerDiv.style.marginLeft = `-10000px`;
12216
- this.markerDiv.style.marginTop = `-10000px`;
12217
- canvas.style.cursor = "pointer";
12218
- break;
12219
- case MOUSE_FINDING_TARGET:
12220
- if (this._currentAngleMeasurement) {
12221
- this._currentAngleMeasurement.targetWireVisible = true;
12222
- this._currentAngleMeasurement.targetVisible = true;
12223
- this._currentAngleMeasurement.angleVisible = true;
12224
- this._currentAngleMeasurement.target.worldPos = event.worldPos;
12225
- this._currentAngleMeasurement.target.entity = event.entity;
12226
- }
12227
- this.markerDiv.style.marginLeft = `-10000px`;
12228
- this.markerDiv.style.marginTop = `-10000px`;
12229
- canvas.style.cursor = "pointer";
12230
- break;
12231
- }
12232
- });
12233
- canvas.addEventListener('mousedown', this._onMouseDown = (e) => {
12234
- if (e.which !== 1) {
12235
- return;
12236
- }
12237
- lastMouseCanvasX = e.clientX;
12238
- lastMouseCanvasY = e.clientY;
12239
- });
12240
- canvas.addEventListener("mouseup", this._onMouseUp =(e) => {
12241
- if (e.which !== 1) {
12242
- return;
12243
- }
12244
- if (e.clientX > lastMouseCanvasX + clickTolerance ||
12245
- e.clientX < lastMouseCanvasX - clickTolerance ||
12246
- e.clientY > lastMouseCanvasY + clickTolerance ||
12247
- e.clientY < lastMouseCanvasY - clickTolerance) {
12248
- return;
12249
- }
12250
- switch (this._mouseState) {
12251
- case MOUSE_FINDING_ORIGIN:
12252
- if (mouseHovering) {
12253
- this._currentAngleMeasurement = this.angleMeasurementsPlugin.createMeasurement({
12254
- id: math.createUUID(),
12255
- origin: {
12256
- worldPos: mouseWorldPos
12257
- },
12258
- corner: {
12259
- worldPos: mouseWorldPos
12260
- },
12261
- target: {
12262
- worldPos: mouseWorldPos
12263
- },
12264
- approximate: true
12265
- });
12266
- this._currentAngleMeasurement.clickable = false;
12267
- this._currentAngleMeasurement.originVisible = true;
12268
- this._currentAngleMeasurement.originWireVisible = true;
12269
- this._currentAngleMeasurement.cornerVisible = false;
12270
- this._currentAngleMeasurement.targetWireVisible = false;
12271
- this._currentAngleMeasurement.targetVisible = false;
12272
- this._currentAngleMeasurement.angleVisible = false;
12273
- this._currentAngleMeasurement.origin.entity = hoveredEntity;
12274
- this._mouseState = MOUSE_FINDING_CORNER;
12275
- this.angleMeasurementsPlugin.fire("measurementStart", this._currentAngleMeasurement);
12276
- }
12277
- break;
12278
- case MOUSE_FINDING_CORNER:
12279
- if (mouseHovering) {
12280
- this._currentAngleMeasurement.targetWireVisible = false;
12281
- this._currentAngleMeasurement.targetVisible = true;
12282
- this._currentAngleMeasurement.angleVisible = true;
12283
- this._currentAngleMeasurement.corner.entity = hoveredEntity;
12284
- this._mouseState = MOUSE_FINDING_TARGET;
12285
- } else {
12286
- if (this._currentAngleMeasurement) {
12287
- this._currentAngleMeasurement.destroy();
12288
- this._currentAngleMeasurement = null;
12289
- hoveredEntity = null;
12290
- this._mouseState = MOUSE_FINDING_ORIGIN;
12291
- this.angleMeasurementsPlugin.fire("measurementCancel", this._currentAngleMeasurement);
12292
- }
12293
- }
12294
- break;
12295
- case MOUSE_FINDING_TARGET:
12296
- if (mouseHovering) {
12297
- this._currentAngleMeasurement.targetVisible = true;
12298
- this._currentAngleMeasurement.angleVisible = true;
12299
- this._currentAngleMeasurement.target.entity = hoveredEntity;
12300
- this._currentAngleMeasurement.clickable = true;
12301
- hoveredEntity = null;
12302
- this.angleMeasurementsPlugin.fire("measurementEnd", this._currentAngleMeasurement);
12303
- this._currentAngleMeasurement = null;
12304
- this._mouseState = MOUSE_FINDING_ORIGIN;
12305
- } else {
12306
- if (this._currentAngleMeasurement) {
12307
- this._currentAngleMeasurement.destroy();
12308
- this._currentAngleMeasurement = null;
12309
- hoveredEntity = null;
12310
- this._mouseState = MOUSE_FINDING_ORIGIN;
12311
- this.angleMeasurementsPlugin.fire("measurementCancel", this._currentAngleMeasurement);
12312
- }
12313
- }
12314
- break;
12315
- }
12316
- });
12317
- this._onMouseHoverOff = cameraControl.on(
12318
- this._snapping
12319
- ? "hoverSnapOrSurfaceOff"
12320
- : "hoverOff",
12321
- event => {
12322
- mouseHovering = false;
12323
- if (pointerLens) {
12324
- pointerLens.visible = true;
12325
- pointerLens.pointerPos = event.canvasPos;
12326
- pointerLens.snappedCanvasPos = event.snappedCanvasPos || event.canvasPos;
12327
- pointerLens.snapped = false;
12328
- }
12329
- this.markerDiv.style.marginLeft = `-100px`;
12330
- this.markerDiv.style.marginTop = `-100px`;
12331
- if (this._currentAngleMeasurement) {
12332
- switch (this._mouseState) {
12333
- case MOUSE_FINDING_ORIGIN:
12334
- this._currentAngleMeasurement.originVisible = false;
12335
- break;
12336
- case MOUSE_FINDING_CORNER:
12337
- this._currentAngleMeasurement.cornerVisible = false;
12338
- this._currentAngleMeasurement.originWireVisible = false;
12339
- this._currentAngleMeasurement.targetVisible = false;
12340
- this._currentAngleMeasurement.targetWireVisible = false;
12341
- this._currentAngleMeasurement.angleVisible = false;
12342
- break;
12343
- case MOUSE_FINDING_TARGET:
12344
- this._currentAngleMeasurement.targetVisible = false;
12345
- this._currentAngleMeasurement.targetWireVisible = false;
12346
- this._currentAngleMeasurement.angleVisible = false;
12347
- break;
12348
- }
12349
- canvas.style.cursor = "default";
12350
- }
12351
- });
12352
- this._active = true;
12353
- }
12140
+ /**
12141
+ * Activates this AngleMeasurementsMouseControl, ready to respond to input.
12142
+ */
12143
+ activate() {
12144
+ if (this._active) {
12145
+ return;
12146
+ }
12147
+ if (!this.markerDiv) {
12148
+ this._initMarkerDiv(); // if the marker is destroyed after deactivation, we recreate it
12149
+ }
12150
+ this.angleMeasurementsPlugin;
12151
+ const scene = this.scene;
12152
+ scene.input;
12153
+ const canvas = scene.canvas.canvas;
12154
+ const clickTolerance = 20;
12155
+ const cameraControl = this.angleMeasurementsPlugin.viewer.cameraControl;
12156
+ const pointerLens = this.pointerLens;
12157
+ let mouseHovering = false;
12158
+ let hoveredEntity = null;
12159
+ let lastMouseCanvasX = 0;
12160
+ let lastMouseCanvasY = 0;
12161
+ const mouseWorldPos = math.vec3();
12162
+ const mouseHoverCanvasPos = math.vec2();
12163
+ this._currentAngleMeasurement = null;
12164
+ this._onMouseHoverSurface = cameraControl.on(this._snapping ? "hoverSnapOrSurface" : "hoverSurface", (event) => {
12165
+ if (event.snappedToVertex || event.snappedToEdge) {
12166
+ if (pointerLens) {
12167
+ pointerLens.visible = true;
12168
+ pointerLens.canvasPos = event.canvasPos;
12169
+ pointerLens.snappedCanvasPos = event.snappedCanvasPos || event.canvasPos;
12170
+ pointerLens.snapped = true;
12171
+ }
12172
+ this.markerDiv.style.background = "greenyellow";
12173
+ this.markerDiv.style.border = "2px solid green";
12174
+ } else {
12175
+ if (pointerLens) {
12176
+ pointerLens.visible = true;
12177
+ pointerLens.canvasPos = event.canvasPos;
12178
+ pointerLens.snappedCanvasPos = event.canvasPos;
12179
+ pointerLens.snapped = false;
12180
+ }
12181
+ this.markerDiv.style.background = "pink";
12182
+ this.markerDiv.style.border = "2px solid red";
12183
+ }
12184
+ const canvasPos = event.snappedCanvasPos || event.canvasPos;
12185
+ mouseHovering = true;
12186
+ hoveredEntity = event.entity;
12187
+ mouseWorldPos.set(event.worldPos);
12188
+ mouseHoverCanvasPos.set(canvasPos);
12189
+ switch (this._mouseState) {
12190
+ case MOUSE_FINDING_ORIGIN:
12191
+ canvas.getBoundingClientRect();
12192
+ const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
12193
+ const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
12194
+ const canvasLeftEdge = scrollLeft;
12195
+ const canvasTopEdge = scrollTop;
12196
+ this.markerDiv.style.marginLeft = `${canvasLeftEdge + canvasPos[0] - 5}px`;
12197
+ this.markerDiv.style.marginTop = `${canvasTopEdge + canvasPos[1] - 5}px`;
12198
+ break;
12199
+ case MOUSE_FINDING_CORNER:
12200
+ if (this._currentAngleMeasurement) {
12201
+ this._currentAngleMeasurement.originWireVisible = true;
12202
+ this._currentAngleMeasurement.targetWireVisible = false;
12203
+ this._currentAngleMeasurement.cornerVisible = true;
12204
+ this._currentAngleMeasurement.angleVisible = false;
12205
+ this._currentAngleMeasurement.corner.worldPos = event.worldPos;
12206
+ this._currentAngleMeasurement.corner.entity = event.entity;
12207
+ }
12208
+ this.markerDiv.style.marginLeft = `-10000px`;
12209
+ this.markerDiv.style.marginTop = `-10000px`;
12210
+ canvas.style.cursor = "pointer";
12211
+ break;
12212
+ case MOUSE_FINDING_TARGET:
12213
+ if (this._currentAngleMeasurement) {
12214
+ this._currentAngleMeasurement.targetWireVisible = true;
12215
+ this._currentAngleMeasurement.targetVisible = true;
12216
+ this._currentAngleMeasurement.angleVisible = true;
12217
+ this._currentAngleMeasurement.target.worldPos = event.worldPos;
12218
+ this._currentAngleMeasurement.target.entity = event.entity;
12219
+ }
12220
+ this.markerDiv.style.marginLeft = `-10000px`;
12221
+ this.markerDiv.style.marginTop = `-10000px`;
12222
+ canvas.style.cursor = "pointer";
12223
+ break;
12224
+ }
12225
+ });
12226
+ canvas.addEventListener(
12227
+ "mousedown",
12228
+ (this._onMouseDown = (e) => {
12229
+ if (e.which !== 1) {
12230
+ return;
12231
+ }
12232
+ lastMouseCanvasX = e.clientX;
12233
+ lastMouseCanvasY = e.clientY;
12234
+ })
12235
+ );
12236
+ canvas.addEventListener(
12237
+ "mouseup",
12238
+ (this._onMouseUp = (e) => {
12239
+ if (e.which !== 1) {
12240
+ return;
12241
+ }
12242
+ if (
12243
+ e.clientX > lastMouseCanvasX + clickTolerance ||
12244
+ e.clientX < lastMouseCanvasX - clickTolerance ||
12245
+ e.clientY > lastMouseCanvasY + clickTolerance ||
12246
+ e.clientY < lastMouseCanvasY - clickTolerance
12247
+ ) {
12248
+ return;
12249
+ }
12250
+ switch (this._mouseState) {
12251
+ case MOUSE_FINDING_ORIGIN:
12252
+ if (mouseHovering) {
12253
+ this._currentAngleMeasurement = this.angleMeasurementsPlugin.createMeasurement({
12254
+ id: math.createUUID(),
12255
+ origin: {
12256
+ worldPos: mouseWorldPos
12257
+ },
12258
+ corner: {
12259
+ worldPos: mouseWorldPos
12260
+ },
12261
+ target: {
12262
+ worldPos: mouseWorldPos
12263
+ },
12264
+ approximate: true
12265
+ });
12266
+ this._currentAngleMeasurement.clickable = false;
12267
+ this._currentAngleMeasurement.originVisible = true;
12268
+ this._currentAngleMeasurement.originWireVisible = true;
12269
+ this._currentAngleMeasurement.cornerVisible = false;
12270
+ this._currentAngleMeasurement.targetWireVisible = false;
12271
+ this._currentAngleMeasurement.targetVisible = false;
12272
+ this._currentAngleMeasurement.angleVisible = false;
12273
+ this._currentAngleMeasurement.origin.entity = hoveredEntity;
12274
+ this._mouseState = MOUSE_FINDING_CORNER;
12275
+ this.angleMeasurementsPlugin.fire("measurementStart", this._currentAngleMeasurement);
12276
+ }
12277
+ break;
12278
+ case MOUSE_FINDING_CORNER:
12279
+ if (mouseHovering) {
12280
+ this._currentAngleMeasurement.targetWireVisible = false;
12281
+ this._currentAngleMeasurement.targetVisible = true;
12282
+ this._currentAngleMeasurement.angleVisible = true;
12283
+ this._currentAngleMeasurement.corner.entity = hoveredEntity;
12284
+ this._mouseState = MOUSE_FINDING_TARGET;
12285
+ } else {
12286
+ if (this._currentAngleMeasurement) {
12287
+ this._currentAngleMeasurement.destroy();
12288
+ this._currentAngleMeasurement = null;
12289
+ hoveredEntity = null;
12290
+ this._mouseState = MOUSE_FINDING_ORIGIN;
12291
+ this.angleMeasurementsPlugin.fire("measurementCancel", this._currentAngleMeasurement);
12292
+ }
12293
+ }
12294
+ break;
12295
+ case MOUSE_FINDING_TARGET:
12296
+ if (mouseHovering) {
12297
+ this._currentAngleMeasurement.targetVisible = true;
12298
+ this._currentAngleMeasurement.angleVisible = true;
12299
+ this._currentAngleMeasurement.target.entity = hoveredEntity;
12300
+ this._currentAngleMeasurement.clickable = true;
12301
+ hoveredEntity = null;
12302
+ this.angleMeasurementsPlugin.fire("measurementEnd", this._currentAngleMeasurement);
12303
+ this._currentAngleMeasurement = null;
12304
+ this._mouseState = MOUSE_FINDING_ORIGIN;
12305
+ } else {
12306
+ if (this._currentAngleMeasurement) {
12307
+ this._currentAngleMeasurement.destroy();
12308
+ this._currentAngleMeasurement = null;
12309
+ hoveredEntity = null;
12310
+ this._mouseState = MOUSE_FINDING_ORIGIN;
12311
+ this.angleMeasurementsPlugin.fire("measurementCancel", this._currentAngleMeasurement);
12312
+ }
12313
+ }
12314
+ break;
12315
+ }
12316
+ })
12317
+ );
12318
+ this._onMouseHoverOff = cameraControl.on(this._snapping ? "hoverSnapOrSurfaceOff" : "hoverOff", (event) => {
12319
+ mouseHovering = false;
12320
+ if (pointerLens) {
12321
+ pointerLens.visible = true;
12322
+ pointerLens.pointerPos = event.canvasPos;
12323
+ pointerLens.snappedCanvasPos = event.snappedCanvasPos || event.canvasPos;
12324
+ pointerLens.snapped = false;
12325
+ }
12326
+ this.markerDiv.style.marginLeft = `-100px`;
12327
+ this.markerDiv.style.marginTop = `-100px`;
12328
+ if (this._currentAngleMeasurement) {
12329
+ switch (this._mouseState) {
12330
+ case MOUSE_FINDING_ORIGIN:
12331
+ this._currentAngleMeasurement.originVisible = false;
12332
+ break;
12333
+ case MOUSE_FINDING_CORNER:
12334
+ this._currentAngleMeasurement.cornerVisible = false;
12335
+ this._currentAngleMeasurement.originWireVisible = false;
12336
+ this._currentAngleMeasurement.targetVisible = false;
12337
+ this._currentAngleMeasurement.targetWireVisible = false;
12338
+ this._currentAngleMeasurement.angleVisible = false;
12339
+ break;
12340
+ case MOUSE_FINDING_TARGET:
12341
+ this._currentAngleMeasurement.targetVisible = false;
12342
+ this._currentAngleMeasurement.targetWireVisible = false;
12343
+ this._currentAngleMeasurement.angleVisible = false;
12344
+ break;
12345
+ }
12346
+ canvas.style.cursor = "default";
12347
+ }
12348
+ });
12349
+ this._active = true;
12350
+ }
12354
12351
 
12355
- /**
12356
- * Deactivates this AngleMeasurementsMouseControl, making it unresponsive to input.
12357
- *
12358
- * Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsMouseControl.
12359
- */
12360
- deactivate() {
12361
- if (!this._active) {
12362
- return;
12363
- }
12364
- if (this.pointerLens) {
12365
- this.pointerLens.visible = false;
12366
- }
12367
- if (this.markerDiv) {
12368
- this._destroyMarkerDiv();
12369
- }
12370
- this.reset();
12371
- const canvas = this.scene.canvas.canvas;
12372
- canvas.removeEventListener("mousedown", this._onMouseDown);
12373
- canvas.removeEventListener("mouseup", this._onMouseUp);
12374
- const cameraControl = this.angleMeasurementsPlugin.viewer.cameraControl;
12375
- cameraControl.off(this._onMouseHoverSurface);
12376
- cameraControl.off(this._onPickedSurface);
12377
- cameraControl.off(this._onHoverNothing);
12378
- cameraControl.off(this._onPickedNothing);
12379
- this._currentAngleMeasurement = null;
12380
- this._active = false;
12381
- }
12352
+ /**
12353
+ * Deactivates this AngleMeasurementsMouseControl, making it unresponsive to input.
12354
+ *
12355
+ * Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsMouseControl.
12356
+ */
12357
+ deactivate() {
12358
+ if (!this._active) {
12359
+ return;
12360
+ }
12361
+ if (this.pointerLens) {
12362
+ this.pointerLens.visible = false;
12363
+ }
12364
+ if (this.markerDiv) {
12365
+ this._destroyMarkerDiv();
12366
+ }
12367
+ this.reset();
12368
+ const canvas = this.scene.canvas.canvas;
12369
+ canvas.removeEventListener("mousedown", this._onMouseDown);
12370
+ canvas.removeEventListener("mouseup", this._onMouseUp);
12371
+ const cameraControl = this.angleMeasurementsPlugin.viewer.cameraControl;
12372
+ cameraControl.off(this._onMouseHoverSurface);
12373
+ cameraControl.off(this._onPickedSurface);
12374
+ cameraControl.off(this._onHoverNothing);
12375
+ cameraControl.off(this._onPickedNothing);
12376
+ this._currentAngleMeasurement = null;
12377
+ this._active = false;
12378
+ }
12382
12379
 
12383
- /**
12384
- * Resets this AngleMeasurementsMouseControl.
12385
- *
12386
- * Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsMouseControl.
12387
- *
12388
- * Does nothing if the AngleMeasurementsMouseControl is not active.
12389
- */
12390
- reset() {
12391
- if (!this._active) {
12392
- return;
12393
- }
12380
+ /**
12381
+ * Resets this AngleMeasurementsMouseControl.
12382
+ *
12383
+ * Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsMouseControl.
12384
+ *
12385
+ * Does nothing if the AngleMeasurementsMouseControl is not active.
12386
+ */
12387
+ reset() {
12388
+ if (!this._active) {
12389
+ return;
12390
+ }
12394
12391
 
12395
- this._destroyMarkerDiv();
12396
- this._initMarkerDiv();
12392
+ this._destroyMarkerDiv();
12393
+ this._initMarkerDiv();
12397
12394
 
12398
- if (this._currentAngleMeasurement) {
12399
- this._currentAngleMeasurement.destroy();
12400
- this._currentAngleMeasurement = null;
12401
- }
12402
- this._mouseState = MOUSE_FINDING_ORIGIN;
12403
- }
12395
+ if (this._currentAngleMeasurement) {
12396
+ this._currentAngleMeasurement.destroy();
12397
+ this._currentAngleMeasurement = null;
12398
+ }
12399
+ this._mouseState = MOUSE_FINDING_ORIGIN;
12400
+ }
12404
12401
 
12405
- /**
12406
- * Destroys this AngleMeasurementsMouseControl.
12407
- */
12408
- destroy() {
12409
- this.deactivate();
12410
- super.destroy();
12411
- }
12402
+ /**
12403
+ * Destroys this AngleMeasurementsMouseControl.
12404
+ */
12405
+ destroy() {
12406
+ this.deactivate();
12407
+ super.destroy();
12408
+ }
12412
12409
  }
12413
12410
 
12414
12411
  /**
@@ -84714,6 +84711,7 @@ class DistanceMeasurement extends Component {
84714
84711
  this._zAxisVisible = false;
84715
84712
  this._axisEnabled = true;
84716
84713
  this._labelsVisible = false;
84714
+ this._labelsOnWires = false;
84717
84715
  this._clickable = false;
84718
84716
 
84719
84717
  this._originMarker.on("worldPos", (value) => {
@@ -84773,6 +84771,7 @@ class DistanceMeasurement extends Component {
84773
84771
  this.yAxisVisible = cfg.yAxisVisible;
84774
84772
  this.zAxisVisible = cfg.zAxisVisible;
84775
84773
  this.labelsVisible = cfg.labelsVisible;
84774
+ this.labelsOnWires = cfg.labelsOnWires;
84776
84775
  }
84777
84776
 
84778
84777
  _update() {
@@ -84824,7 +84823,7 @@ class DistanceMeasurement extends Component {
84824
84823
 
84825
84824
  if (this._sectionPlanesDirty) {
84826
84825
 
84827
- if (this._isSliced(this._wp)) {
84826
+ if (this._isSliced(this._originWorld) || this._isSliced(this._targetWorld)) {
84828
84827
  this._xAxisLabel.setCulled(true);
84829
84828
  this._yAxisLabel.setCulled(true);
84830
84829
  this._zAxisLabel.setCulled(true);
@@ -84924,9 +84923,19 @@ class DistanceMeasurement extends Component {
84924
84923
 
84925
84924
  this._lengthLabel.setPosOnWire(cp[0], cp[1], cp[6], cp[7]);
84926
84925
 
84927
- this._xAxisLabel.setPosOnWire(cp[0], cp[1], cp[2], cp[3]);
84928
- this._yAxisLabel.setPosOnWire(cp[2], cp[3], cp[4], cp[5]);
84929
- this._zAxisLabel.setPosOnWire(cp[4], cp[5], cp[6], cp[7]);
84926
+ if (this.labelsOnWires) {
84927
+ this._xAxisLabel.setPosOnWire(cp[0], cp[1], cp[2], cp[3]);
84928
+ this._yAxisLabel.setPosOnWire(cp[2], cp[3], cp[4], cp[5]);
84929
+ this._zAxisLabel.setPosOnWire(cp[4], cp[5], cp[6], cp[7]);
84930
+ } else {
84931
+ const labelOffset = 35;
84932
+ let currentLabelOffset = labelOffset;
84933
+ this._xAxisLabel.setPosOnWire(cp[0], cp[1] + currentLabelOffset, cp[6], cp[7] + currentLabelOffset);
84934
+ currentLabelOffset += labelOffset;
84935
+ this._yAxisLabel.setPosOnWire(cp[0], cp[1] + currentLabelOffset, cp[6], cp[7] + currentLabelOffset);
84936
+ currentLabelOffset += labelOffset;
84937
+ this._zAxisLabel.setPosOnWire(cp[0], cp[1] + currentLabelOffset, cp[6], cp[7] + currentLabelOffset);
84938
+ }
84930
84939
 
84931
84940
  const tilde = this._approximate ? " ~ " : " = ";
84932
84941
 
@@ -84939,9 +84948,15 @@ class DistanceMeasurement extends Component {
84939
84948
 
84940
84949
  const labelMinAxisLength = this.plugin.labelMinAxisLength;
84941
84950
 
84942
- this._xAxisLabelCulled = (xAxisCanvasLength < labelMinAxisLength);
84943
- this._yAxisLabelCulled = (yAxisCanvasLength < labelMinAxisLength);
84944
- this._zAxisLabelCulled = (zAxisCanvasLength < labelMinAxisLength);
84951
+ if (this.labelsOnWires){
84952
+ this._xAxisLabelCulled = (xAxisCanvasLength < labelMinAxisLength);
84953
+ this._yAxisLabelCulled = (yAxisCanvasLength < labelMinAxisLength);
84954
+ this._zAxisLabelCulled = (zAxisCanvasLength < labelMinAxisLength);
84955
+ } else {
84956
+ this._xAxisLabelCulled = false;
84957
+ this._yAxisLabelCulled = false;
84958
+ this._zAxisLabelCulled = false;
84959
+ }
84945
84960
 
84946
84961
  if (!this._xAxisLabelCulled) {
84947
84962
  this._xAxisLabel.setText(tilde + Math.abs((this._targetWorld[0] - this._originWorld[0]) * scale).toFixed(2) + unitAbbrev);
@@ -85342,6 +85357,25 @@ class DistanceMeasurement extends Component {
85342
85357
  return this._labelsVisible;
85343
85358
  }
85344
85359
 
85360
+ /**
85361
+ * Sets if labels should be positioned on the wires.
85362
+ *
85363
+ * @type {Boolean}
85364
+ */
85365
+ set labelsOnWires(value) {
85366
+ value = value !== undefined ? Boolean(value) : this.plugin.defaultLabelsOnWires;
85367
+ this._labelsOnWires = value;
85368
+ }
85369
+
85370
+ /**
85371
+ * Gets if labels should be positioned on the wires.
85372
+ *
85373
+ * @type {Boolean}
85374
+ */
85375
+ get labelsOnWires() {
85376
+ return this._labelsOnWires;
85377
+ }
85378
+
85345
85379
  /**
85346
85380
  * Sets if this DistanceMeasurement appears highlighted.
85347
85381
  * @param highlighted
@@ -85555,361 +85589,375 @@ const MOUSE_FIRST_CLICK_EXPECTED = 0;
85555
85589
  * ````
85556
85590
  */
85557
85591
  class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
85592
+ /**
85593
+ * Creates a DistanceMeasurementsMouseControl bound to the given DistanceMeasurementsPlugin.
85594
+ *
85595
+ * @param {DistanceMeasurementsPlugin} distanceMeasurementsPlugin The AngleMeasurementsPlugin to control.
85596
+ * @param [cfg] Configuration
85597
+ * @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor when snapping is enabled.
85598
+ * @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this DistanceMeasurementsMouseControl.
85599
+ */
85600
+ constructor(distanceMeasurementsPlugin, cfg = {}) {
85601
+ super(distanceMeasurementsPlugin.viewer.scene);
85558
85602
 
85559
- /**
85560
- * Creates a DistanceMeasurementsMouseControl bound to the given DistanceMeasurementsPlugin.
85561
- *
85562
- * @param {DistanceMeasurementsPlugin} distanceMeasurementsPlugin The AngleMeasurementsPlugin to control.
85563
- * @param [cfg] Configuration
85564
- * @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor when snapping is enabled.
85565
- * @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this DistanceMeasurementsMouseControl.
85566
- */
85567
- constructor(distanceMeasurementsPlugin, cfg = {}) {
85568
-
85569
- super(distanceMeasurementsPlugin.viewer.scene);
85570
-
85571
- this.pointerLens = cfg.pointerLens;
85572
-
85573
- this._active = false;
85574
-
85575
- this._currentDistanceMeasurement = null;
85576
-
85577
- this._currentDistanceMeasurementInitState = {
85578
- wireVisible: null,
85579
- axisVisible: null,
85580
- xAxisVisible: null,
85581
- yaxisVisible: null,
85582
- zAxisVisible: null,
85583
- targetVisible: null,
85584
- };
85585
-
85586
- this._initMarkerDiv();
85603
+ this.pointerLens = cfg.pointerLens;
85587
85604
 
85588
- this._onCameraControlHoverSnapOrSurface = null;
85589
- this._onCameraControlHoverSnapOrSurfaceOff = null;
85590
- this._onMouseDown = null;
85591
- this._onMouseUp = null;
85592
- this._onCanvasTouchStart = null;
85593
- this._onCanvasTouchEnd = null;
85594
- this._snapping = cfg.snapping !== false;
85595
- this._mouseState = MOUSE_FIRST_CLICK_EXPECTED;
85605
+ this._active = false;
85596
85606
 
85597
- this._attachPlugin(distanceMeasurementsPlugin, cfg);
85598
- }
85607
+ this._currentDistanceMeasurement = null;
85599
85608
 
85600
- _initMarkerDiv() {
85601
- const markerDiv = document.createElement('div');
85602
- markerDiv.setAttribute('id', 'myDistanceMarker');
85603
- const canvas = this.scene.canvas.canvas;
85604
- canvas.parentNode.insertBefore(markerDiv, canvas);
85605
- markerDiv.style.background = "black";
85606
- markerDiv.style.border = "2px solid blue";
85607
- markerDiv.style.borderRadius = "10px";
85608
- markerDiv.style.width = "5px";
85609
- markerDiv.style.height = "5px";
85610
- markerDiv.style.margin = "-200px -200px";
85611
- markerDiv.style.zIndex = "100";
85612
- markerDiv.style.position = "absolute";
85613
- markerDiv.style.pointerEvents = "none";
85609
+ this._currentDistanceMeasurementInitState = {
85610
+ wireVisible: null,
85611
+ axisVisible: null,
85612
+ xAxisVisible: null,
85613
+ yaxisVisible: null,
85614
+ zAxisVisible: null,
85615
+ targetVisible: null
85616
+ };
85614
85617
 
85615
- this._markerDiv = markerDiv;
85616
- }
85618
+ this._initMarkerDiv();
85617
85619
 
85618
- _destroyMarkerDiv() {
85619
- if (this._markerDiv) {
85620
- const element = document.getElementById('myDistanceMarker');
85621
- element.parentNode.removeChild(element);
85622
- this._markerDiv = null;
85623
- }
85624
- }
85620
+ this._onCameraControlHoverSnapOrSurface = null;
85621
+ this._onCameraControlHoverSnapOrSurfaceOff = null;
85622
+ this._onMouseDown = null;
85623
+ this._onMouseUp = null;
85624
+ this._onCanvasTouchStart = null;
85625
+ this._onCanvasTouchEnd = null;
85626
+ this._snapping = cfg.snapping !== false;
85627
+ this._mouseState = MOUSE_FIRST_CLICK_EXPECTED;
85625
85628
 
85626
- _attachPlugin(distanceMeasurementsPlugin, cfg = {}) {
85629
+ this._attachPlugin(distanceMeasurementsPlugin, cfg);
85630
+ }
85627
85631
 
85628
- /**
85629
- * The {@link DistanceMeasurementsPlugin} that owns this DistanceMeasurementsMouseControl.
85630
- * @type {DistanceMeasurementsPlugin}
85631
- */
85632
- this.distanceMeasurementsPlugin = distanceMeasurementsPlugin;
85632
+ _initMarkerDiv() {
85633
+ const markerDiv = document.createElement("div");
85634
+ markerDiv.setAttribute("id", "myDistanceMarker");
85635
+ const canvas = this.scene.canvas.canvas;
85636
+ canvas.parentNode.insertBefore(markerDiv, canvas);
85637
+ markerDiv.style.background = "black";
85638
+ markerDiv.style.border = "2px solid blue";
85639
+ markerDiv.style.borderRadius = "10px";
85640
+ markerDiv.style.width = "5px";
85641
+ markerDiv.style.height = "5px";
85642
+ markerDiv.style.margin = "-200px -200px";
85643
+ markerDiv.style.zIndex = "100";
85644
+ markerDiv.style.position = "absolute";
85645
+ markerDiv.style.pointerEvents = "none";
85646
+
85647
+ this._markerDiv = markerDiv;
85648
+ }
85633
85649
 
85634
- /**
85635
- * The {@link DistanceMeasurementsPlugin} that owns this DistanceMeasurementsMouseControl.
85636
- * @type {DistanceMeasurementsPlugin}
85637
- */
85638
- this.plugin = distanceMeasurementsPlugin;
85639
- }
85650
+ _destroyMarkerDiv() {
85651
+ if (this._markerDiv) {
85652
+ const element = document.getElementById("myDistanceMarker");
85653
+ element.parentNode.removeChild(element);
85654
+ this._markerDiv = null;
85655
+ }
85656
+ }
85640
85657
 
85641
- /**
85642
- * Gets if this DistanceMeasurementsMouseControl is currently active, where it is responding to input.
85643
- *
85644
- * @returns {boolean} True if this DistanceMeasurementsMouseControl is active.
85645
- */
85646
- get active() {
85647
- return this._active;
85648
- }
85658
+ _attachPlugin(distanceMeasurementsPlugin, cfg = {}) {
85659
+ /**
85660
+ * The {@link DistanceMeasurementsPlugin} that owns this DistanceMeasurementsMouseControl.
85661
+ * @type {DistanceMeasurementsPlugin}
85662
+ */
85663
+ this.distanceMeasurementsPlugin = distanceMeasurementsPlugin;
85649
85664
 
85650
- /**
85651
- * Sets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
85652
- *
85653
- * This is `true` by default.
85654
- *
85655
- * Internally, this deactivates then activates the DistanceMeasurementsMouseControl when changed, which means that
85656
- * it will destroy any DistanceMeasurements currently under construction, and incurs some overhead, since it unbinds
85657
- * and rebinds various input handlers.
85658
- *
85659
- * @param {boolean} snapping Whether to enable snap-to-vertex and snap-edge for this DistanceMeasurementsMouseControl.
85660
- */
85661
- set snapping(snapping) {
85662
- if (snapping !== this._snapping) {
85663
- this._snapping = snapping;
85664
- this.deactivate();
85665
- this.activate();
85666
- } else {
85667
- this._snapping = snapping;
85668
- }
85669
- }
85665
+ /**
85666
+ * The {@link DistanceMeasurementsPlugin} that owns this DistanceMeasurementsMouseControl.
85667
+ * @type {DistanceMeasurementsPlugin}
85668
+ */
85669
+ this.plugin = distanceMeasurementsPlugin;
85670
+ }
85670
85671
 
85671
- /**
85672
- * Gets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
85673
- *
85674
- * This is `true` by default.
85675
- *
85676
- * @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
85677
- */
85678
- get snapping() {
85679
- return this._snapping;
85680
- }
85672
+ /**
85673
+ * Gets if this DistanceMeasurementsMouseControl is currently active, where it is responding to input.
85674
+ *
85675
+ * @returns {boolean} True if this DistanceMeasurementsMouseControl is active.
85676
+ */
85677
+ get active() {
85678
+ return this._active;
85679
+ }
85681
85680
 
85682
- /**
85683
- * Activates this DistanceMeasurementsMouseControl, ready to respond to input.
85684
- */
85685
- activate() {
85681
+ /**
85682
+ * Sets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
85683
+ *
85684
+ * This is `true` by default.
85685
+ *
85686
+ * Internally, this deactivates then activates the DistanceMeasurementsMouseControl when changed, which means that
85687
+ * it will destroy any DistanceMeasurements currently under construction, and incurs some overhead, since it unbinds
85688
+ * and rebinds various input handlers.
85689
+ *
85690
+ * @param {boolean} snapping Whether to enable snap-to-vertex and snap-edge for this DistanceMeasurementsMouseControl.
85691
+ */
85692
+ set snapping(snapping) {
85693
+ if (snapping !== this._snapping) {
85694
+ this._snapping = snapping;
85695
+ this.deactivate();
85696
+ this.activate();
85697
+ } else {
85698
+ this._snapping = snapping;
85699
+ }
85700
+ }
85686
85701
 
85687
- if (this._active) {
85688
- return;
85689
- }
85702
+ /**
85703
+ * Gets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
85704
+ *
85705
+ * This is `true` by default.
85706
+ *
85707
+ * @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
85708
+ */
85709
+ get snapping() {
85710
+ return this._snapping;
85711
+ }
85690
85712
 
85691
- if (!this._markerDiv) {
85692
- this._initMarkerDiv();
85693
- }
85713
+ /**
85714
+ * Activates this DistanceMeasurementsMouseControl, ready to respond to input.
85715
+ */
85716
+ activate() {
85717
+ if (this._active) {
85718
+ return;
85719
+ }
85694
85720
 
85695
- this.fire("activated", true);
85721
+ if (!this._markerDiv) {
85722
+ this._initMarkerDiv();
85723
+ }
85696
85724
 
85697
- const distanceMeasurementsPlugin = this.distanceMeasurementsPlugin;
85698
- const scene = this.scene;
85699
- const cameraControl = distanceMeasurementsPlugin.viewer.cameraControl;
85700
- const canvas = scene.canvas.canvas;
85701
- scene.input;
85702
- let mouseHovering = false;
85703
- const pointerWorldPos = math.vec3();
85704
- const pointerCanvasPos = math.vec2();
85705
- let pointerDownCanvasX;
85706
- let pointerDownCanvasY;
85707
- const clickTolerance = 20;
85708
- let hoveredEntity = null;
85709
-
85710
- this._mouseState = MOUSE_FIRST_CLICK_EXPECTED;
85711
-
85712
- this._onCameraControlHoverSnapOrSurface = cameraControl.on(
85713
- this._snapping
85714
- ? "hoverSnapOrSurface"
85715
- : "hoverSurface", event => {
85716
- const canvasPos = event.snappedCanvasPos || event.canvasPos;
85717
- mouseHovering = true;
85718
- pointerWorldPos.set(event.worldPos);
85719
- pointerCanvasPos.set(event.canvasPos);
85720
- if (this._mouseState === MOUSE_FIRST_CLICK_EXPECTED) {
85721
-
85722
- const canvasBoundRect = canvas.getBoundingClientRect();
85723
- const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
85724
- const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
85725
- const canvasLeftEdge = canvasBoundRect.left + scrollLeft;
85726
- const canvasTopEdge = canvasBoundRect.top + scrollTop;
85727
-
85728
- this._markerDiv.style.marginLeft = `${canvasLeftEdge + canvasPos[0] - 5}px`;
85729
- this._markerDiv.style.marginTop = `${canvasTopEdge + canvasPos[1] - 5}px`;
85730
- this._markerDiv.style.background = "pink";
85731
- if (event.snappedToVertex || event.snappedToEdge) {
85732
- if (this.pointerLens) {
85733
- this.pointerLens.visible = true;
85734
- this.pointerLens.canvasPos = event.canvasPos;
85735
- this.pointerLens.snappedCanvasPos = event.snappedCanvasPos || event.canvasPos;
85736
- this.pointerLens.snapped = true;
85737
- }
85738
- this._markerDiv.style.background = "greenyellow";
85739
- this._markerDiv.style.border = "2px solid green";
85740
- } else {
85741
- if (this.pointerLens) {
85742
- this.pointerLens.visible = true;
85743
- this.pointerLens.canvasPos = event.canvasPos;
85744
- this.pointerLens.snappedCanvasPos = event.canvasPos;
85745
- this.pointerLens.snapped = false;
85746
- }
85747
- this._markerDiv.style.background = "pink";
85748
- this._markerDiv.style.border = "2px solid red";
85749
- }
85750
- hoveredEntity = event.entity;
85751
- } else {
85752
- this._markerDiv.style.marginLeft = `-10000px`;
85753
- this._markerDiv.style.marginTop = `-10000px`;
85754
- }
85755
- canvas.style.cursor = "pointer";
85756
- if (this._currentDistanceMeasurement) {
85757
- this._currentDistanceMeasurement.wireVisible = this._currentDistanceMeasurementInitState.wireVisible;
85758
- this._currentDistanceMeasurement.axisVisible = this._currentDistanceMeasurementInitState.axisVisible && this.distanceMeasurementsPlugin.defaultAxisVisible;
85759
- this._currentDistanceMeasurement.xAxisVisible = this._currentDistanceMeasurementInitState.xAxisVisible && this.distanceMeasurementsPlugin.defaultXAxisVisible;
85760
- this._currentDistanceMeasurement.yAxisVisible = this._currentDistanceMeasurementInitState.yAxisVisible && this.distanceMeasurementsPlugin.defaultYAxisVisible;
85761
- this._currentDistanceMeasurement.zAxisVisible = this._currentDistanceMeasurementInitState.zAxisVisible && this.distanceMeasurementsPlugin.defaultZAxisVisible;
85762
- this._currentDistanceMeasurement.targetVisible = this._currentDistanceMeasurementInitState.targetVisible;
85763
- this._currentDistanceMeasurement.target.worldPos = pointerWorldPos.slice();
85764
- this._markerDiv.style.marginLeft = `-10000px`;
85765
- this._markerDiv.style.marginTop = `-10000px`;
85766
- }
85767
- });
85725
+ this.fire("activated", true);
85726
+
85727
+ const distanceMeasurementsPlugin = this.distanceMeasurementsPlugin;
85728
+ const scene = this.scene;
85729
+ const cameraControl = distanceMeasurementsPlugin.viewer.cameraControl;
85730
+ const canvas = scene.canvas.canvas;
85731
+ scene.input;
85732
+ let mouseHovering = false;
85733
+ const pointerWorldPos = math.vec3();
85734
+ const pointerCanvasPos = math.vec2();
85735
+ let pointerDownCanvasX;
85736
+ let pointerDownCanvasY;
85737
+ const clickTolerance = 20;
85738
+ let hoveredEntity = null;
85739
+
85740
+ this._mouseState = MOUSE_FIRST_CLICK_EXPECTED;
85741
+
85742
+ this._onCameraControlHoverSnapOrSurface = cameraControl.on(
85743
+ this._snapping ? "hoverSnapOrSurface" : "hoverSurface",
85744
+ (event) => {
85745
+ const canvasPos = event.snappedCanvasPos || event.canvasPos;
85746
+ mouseHovering = true;
85747
+ pointerWorldPos.set(event.worldPos);
85748
+ pointerCanvasPos.set(event.canvasPos);
85749
+ if (this._mouseState === MOUSE_FIRST_CLICK_EXPECTED) {
85750
+ canvas.getBoundingClientRect();
85751
+ const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
85752
+ const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
85753
+ const canvasLeftEdge = scrollLeft;
85754
+ const canvasTopEdge = scrollTop;
85755
+
85756
+ this._markerDiv.style.marginLeft = `${canvasLeftEdge + canvasPos[0] - 5}px`;
85757
+ this._markerDiv.style.marginTop = `${canvasTopEdge + canvasPos[1] - 5}px`;
85758
+ this._markerDiv.style.background = "pink";
85759
+ if (event.snappedToVertex || event.snappedToEdge) {
85760
+ if (this.pointerLens) {
85761
+ this.pointerLens.visible = true;
85762
+ this.pointerLens.canvasPos = event.canvasPos;
85763
+ this.pointerLens.snappedCanvasPos = event.snappedCanvasPos || event.canvasPos;
85764
+ this.pointerLens.snapped = true;
85765
+ }
85766
+ this._markerDiv.style.background = "greenyellow";
85767
+ this._markerDiv.style.border = "2px solid green";
85768
+ } else {
85769
+ if (this.pointerLens) {
85770
+ this.pointerLens.visible = true;
85771
+ this.pointerLens.canvasPos = event.canvasPos;
85772
+ this.pointerLens.snappedCanvasPos = event.canvasPos;
85773
+ this.pointerLens.snapped = false;
85774
+ }
85775
+ this._markerDiv.style.background = "pink";
85776
+ this._markerDiv.style.border = "2px solid red";
85777
+ }
85778
+ hoveredEntity = event.entity;
85779
+ } else {
85780
+ this._markerDiv.style.marginLeft = `-10000px`;
85781
+ this._markerDiv.style.marginTop = `-10000px`;
85782
+ }
85783
+ canvas.style.cursor = "pointer";
85784
+ if (this._currentDistanceMeasurement) {
85785
+ this._currentDistanceMeasurement.wireVisible = this._currentDistanceMeasurementInitState.wireVisible;
85786
+ this._currentDistanceMeasurement.axisVisible =
85787
+ this._currentDistanceMeasurementInitState.axisVisible && this.distanceMeasurementsPlugin.defaultAxisVisible;
85788
+ this._currentDistanceMeasurement.xAxisVisible =
85789
+ this._currentDistanceMeasurementInitState.xAxisVisible &&
85790
+ this.distanceMeasurementsPlugin.defaultXAxisVisible;
85791
+ this._currentDistanceMeasurement.yAxisVisible =
85792
+ this._currentDistanceMeasurementInitState.yAxisVisible &&
85793
+ this.distanceMeasurementsPlugin.defaultYAxisVisible;
85794
+ this._currentDistanceMeasurement.zAxisVisible =
85795
+ this._currentDistanceMeasurementInitState.zAxisVisible &&
85796
+ this.distanceMeasurementsPlugin.defaultZAxisVisible;
85797
+ this._currentDistanceMeasurement.targetVisible = this._currentDistanceMeasurementInitState.targetVisible;
85798
+ this._currentDistanceMeasurement.target.worldPos = pointerWorldPos.slice();
85799
+ this._markerDiv.style.marginLeft = `-10000px`;
85800
+ this._markerDiv.style.marginTop = `-10000px`;
85801
+ }
85802
+ }
85803
+ );
85768
85804
 
85769
- canvas.addEventListener('mousedown', this._onMouseDown = (e) => {
85770
- if (e.which !== 1) {
85771
- return;
85772
- }
85773
- pointerDownCanvasX = e.clientX;
85774
- pointerDownCanvasY = e.clientY;
85775
- });
85805
+ canvas.addEventListener(
85806
+ "mousedown",
85807
+ (this._onMouseDown = (e) => {
85808
+ if (e.which !== 1) {
85809
+ return;
85810
+ }
85811
+ pointerDownCanvasX = e.clientX;
85812
+ pointerDownCanvasY = e.clientY;
85813
+ })
85814
+ );
85776
85815
 
85777
- canvas.addEventListener("mouseup", this._onMouseUp =(e) => {
85778
- if (e.which !== 1) {
85779
- return;
85780
- }
85781
- if (e.clientX > pointerDownCanvasX + clickTolerance ||
85782
- e.clientX < pointerDownCanvasX - clickTolerance ||
85783
- e.clientY > pointerDownCanvasY + clickTolerance ||
85784
- e.clientY < pointerDownCanvasY - clickTolerance) {
85785
- return;
85786
- }
85787
- if (this._currentDistanceMeasurement) {
85788
- if (mouseHovering) {
85789
- this._currentDistanceMeasurement.target.entity = hoveredEntity;
85790
- hoveredEntity = null;
85791
- this._currentDistanceMeasurement.clickable = true;
85792
- this.distanceMeasurementsPlugin.fire("measurementEnd", this._currentDistanceMeasurement);
85793
- this._currentDistanceMeasurement = null;
85794
- } else {
85795
- this._currentDistanceMeasurement.destroy();
85796
- this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
85797
- this._currentDistanceMeasurement = null;
85798
- hoveredEntity = null;
85799
- }
85800
- } else {
85801
- if (mouseHovering) {
85802
- this._currentDistanceMeasurement = distanceMeasurementsPlugin.createMeasurement({
85803
- id: math.createUUID(),
85804
- origin: {
85805
- worldPos: pointerWorldPos.slice()
85806
- },
85807
- target: {
85808
- worldPos: pointerWorldPos.slice()
85809
- },
85810
- approximate: true
85811
- });
85812
- this._currentDistanceMeasurementInitState.axisVisible = this._currentDistanceMeasurement.axisVisible && this.distanceMeasurementsPlugin.defaultAxisVisible;
85813
- this._currentDistanceMeasurementInitState.xAxisVisible = this._currentDistanceMeasurement.xAxisVisible && this.distanceMeasurementsPlugin.defaultXAxisVisible;
85814
- this._currentDistanceMeasurementInitState.yAxisVisible = this._currentDistanceMeasurement.yAxisVisible && this.distanceMeasurementsPlugin.defaultYAxisVisible;
85815
- this._currentDistanceMeasurementInitState.zAxisVisible = this._currentDistanceMeasurement.zAxisVisible && this.distanceMeasurementsPlugin.defaultZAxisVisible;
85816
- this._currentDistanceMeasurementInitState.wireVisible = this._currentDistanceMeasurement.wireVisible;
85817
- this._currentDistanceMeasurementInitState.targetVisible = this._currentDistanceMeasurement.targetVisible;
85818
- this._currentDistanceMeasurement.clickable = false;
85819
- this._currentDistanceMeasurement.origin.entity = hoveredEntity;
85820
- hoveredEntity = null;
85821
- this.fire("measurementStart", this._currentDistanceMeasurement);
85822
- }
85823
- }
85824
- });
85816
+ canvas.addEventListener(
85817
+ "mouseup",
85818
+ (this._onMouseUp = (e) => {
85819
+ if (e.which !== 1) {
85820
+ return;
85821
+ }
85822
+ if (
85823
+ e.clientX > pointerDownCanvasX + clickTolerance ||
85824
+ e.clientX < pointerDownCanvasX - clickTolerance ||
85825
+ e.clientY > pointerDownCanvasY + clickTolerance ||
85826
+ e.clientY < pointerDownCanvasY - clickTolerance
85827
+ ) {
85828
+ return;
85829
+ }
85830
+ if (this._currentDistanceMeasurement) {
85831
+ if (mouseHovering) {
85832
+ this._currentDistanceMeasurement.target.entity = hoveredEntity;
85833
+ hoveredEntity = null;
85834
+ this._currentDistanceMeasurement.clickable = true;
85835
+ this.distanceMeasurementsPlugin.fire("measurementEnd", this._currentDistanceMeasurement);
85836
+ this._currentDistanceMeasurement = null;
85837
+ } else {
85838
+ this._currentDistanceMeasurement.destroy();
85839
+ this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
85840
+ this._currentDistanceMeasurement = null;
85841
+ hoveredEntity = null;
85842
+ }
85843
+ } else {
85844
+ if (mouseHovering) {
85845
+ this._currentDistanceMeasurement = distanceMeasurementsPlugin.createMeasurement({
85846
+ id: math.createUUID(),
85847
+ origin: {
85848
+ worldPos: pointerWorldPos.slice()
85849
+ },
85850
+ target: {
85851
+ worldPos: pointerWorldPos.slice()
85852
+ },
85853
+ approximate: true
85854
+ });
85855
+ this._currentDistanceMeasurementInitState.axisVisible =
85856
+ this._currentDistanceMeasurement.axisVisible && this.distanceMeasurementsPlugin.defaultAxisVisible;
85857
+ this._currentDistanceMeasurementInitState.xAxisVisible =
85858
+ this._currentDistanceMeasurement.xAxisVisible && this.distanceMeasurementsPlugin.defaultXAxisVisible;
85859
+ this._currentDistanceMeasurementInitState.yAxisVisible =
85860
+ this._currentDistanceMeasurement.yAxisVisible && this.distanceMeasurementsPlugin.defaultYAxisVisible;
85861
+ this._currentDistanceMeasurementInitState.zAxisVisible =
85862
+ this._currentDistanceMeasurement.zAxisVisible && this.distanceMeasurementsPlugin.defaultZAxisVisible;
85863
+ this._currentDistanceMeasurementInitState.wireVisible = this._currentDistanceMeasurement.wireVisible;
85864
+ this._currentDistanceMeasurementInitState.targetVisible = this._currentDistanceMeasurement.targetVisible;
85865
+ this._currentDistanceMeasurement.clickable = false;
85866
+ this._currentDistanceMeasurement.origin.entity = hoveredEntity;
85867
+ hoveredEntity = null;
85868
+ this.fire("measurementStart", this._currentDistanceMeasurement);
85869
+ }
85870
+ }
85871
+ })
85872
+ );
85825
85873
 
85826
- this._onCameraControlHoverSnapOrSurfaceOff = cameraControl.on(
85827
- this._snapping
85828
- ? "hoverSnapOrSurfaceOff"
85829
- : "hoverOff", event => {
85830
- if (this.pointerLens) {
85831
- this.pointerLens.visible = true;
85832
- this.pointerLens.canvasPos = event.canvasPos;
85833
- this.pointerLens.snappedCanvasPos = event.snappedCanvasPos || event.canvasPos;
85834
- }
85835
- mouseHovering = false;
85836
- this._markerDiv.style.marginLeft = `-100px`;
85837
- this._markerDiv.style.marginTop = `-100px`;
85838
- if (this._currentDistanceMeasurement) {
85839
- this._currentDistanceMeasurement.wireVisible = false;
85840
- this._currentDistanceMeasurement.targetVisible = false;
85841
- this._currentDistanceMeasurement.axisVisible = false;
85842
- }
85843
- canvas.style.cursor = "default";
85844
- });
85874
+ this._onCameraControlHoverSnapOrSurfaceOff = cameraControl.on(
85875
+ this._snapping ? "hoverSnapOrSurfaceOff" : "hoverOff",
85876
+ (event) => {
85877
+ if (this.pointerLens) {
85878
+ this.pointerLens.visible = true;
85879
+ this.pointerLens.canvasPos = event.canvasPos;
85880
+ this.pointerLens.snappedCanvasPos = event.snappedCanvasPos || event.canvasPos;
85881
+ }
85882
+ mouseHovering = false;
85883
+ this._markerDiv.style.marginLeft = `-100px`;
85884
+ this._markerDiv.style.marginTop = `-100px`;
85885
+ if (this._currentDistanceMeasurement) {
85886
+ this._currentDistanceMeasurement.wireVisible = false;
85887
+ this._currentDistanceMeasurement.targetVisible = false;
85888
+ this._currentDistanceMeasurement.axisVisible = false;
85889
+ }
85890
+ canvas.style.cursor = "default";
85891
+ }
85892
+ );
85845
85893
 
85846
- this._active = true;
85847
- }
85894
+ this._active = true;
85895
+ }
85848
85896
 
85849
- /**
85850
- * Deactivates this DistanceMeasurementsMouseControl, making it unresponsive to input.
85851
- *
85852
- * Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsMouseControl.
85853
- */
85854
- deactivate() {
85855
- if (!this._active) {
85856
- return;
85857
- }
85897
+ /**
85898
+ * Deactivates this DistanceMeasurementsMouseControl, making it unresponsive to input.
85899
+ *
85900
+ * Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsMouseControl.
85901
+ */
85902
+ deactivate() {
85903
+ if (!this._active) {
85904
+ return;
85905
+ }
85858
85906
 
85859
- this.fire("activated", false);
85907
+ this.fire("activated", false);
85860
85908
 
85861
- if (this.pointerLens) {
85862
- this.pointerLens.visible = false;
85863
- }
85864
- if (this._markerDiv) {
85865
- this._destroyMarkerDiv();
85866
- }
85867
- this.reset();
85868
- const canvas = this.scene.canvas.canvas;
85869
- canvas.removeEventListener("mousedown", this._onMouseDown);
85870
- canvas.removeEventListener("mouseup", this._onMouseUp);
85871
- const cameraControl = this.distanceMeasurementsPlugin.viewer.cameraControl;
85872
- cameraControl.off(this._onCameraControlHoverSnapOrSurface);
85873
- cameraControl.off(this._onCameraControlHoverSnapOrSurfaceOff);
85874
- if (this._currentDistanceMeasurement) {
85875
- this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
85876
- this._currentDistanceMeasurement.destroy();
85877
- this._currentDistanceMeasurement = null;
85878
- }
85879
- this._active = false;
85880
- }
85909
+ if (this.pointerLens) {
85910
+ this.pointerLens.visible = false;
85911
+ }
85912
+ if (this._markerDiv) {
85913
+ this._destroyMarkerDiv();
85914
+ }
85915
+ this.reset();
85916
+ const canvas = this.scene.canvas.canvas;
85917
+ canvas.removeEventListener("mousedown", this._onMouseDown);
85918
+ canvas.removeEventListener("mouseup", this._onMouseUp);
85919
+ const cameraControl = this.distanceMeasurementsPlugin.viewer.cameraControl;
85920
+ cameraControl.off(this._onCameraControlHoverSnapOrSurface);
85921
+ cameraControl.off(this._onCameraControlHoverSnapOrSurfaceOff);
85922
+ if (this._currentDistanceMeasurement) {
85923
+ this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
85924
+ this._currentDistanceMeasurement.destroy();
85925
+ this._currentDistanceMeasurement = null;
85926
+ }
85927
+ this._active = false;
85928
+ }
85881
85929
 
85882
- /**
85883
- * Resets this DistanceMeasurementsMouseControl.
85884
- *
85885
- * Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsMouseControl.
85886
- *
85887
- * Does nothing if the DistanceMeasurementsMouseControl is not active.
85888
- */
85889
- reset() {
85890
- if (!this._active) {
85891
- return;
85892
- }
85930
+ /**
85931
+ * Resets this DistanceMeasurementsMouseControl.
85932
+ *
85933
+ * Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsMouseControl.
85934
+ *
85935
+ * Does nothing if the DistanceMeasurementsMouseControl is not active.
85936
+ */
85937
+ reset() {
85938
+ if (!this._active) {
85939
+ return;
85940
+ }
85893
85941
 
85894
- this._destroyMarkerDiv();
85895
- this._initMarkerDiv();
85942
+ this._destroyMarkerDiv();
85943
+ this._initMarkerDiv();
85896
85944
 
85897
- if (this._currentDistanceMeasurement) {
85898
- this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
85899
- this._currentDistanceMeasurement.destroy();
85900
- this._currentDistanceMeasurement = null;
85901
- }
85902
- }
85945
+ if (this._currentDistanceMeasurement) {
85946
+ this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
85947
+ this._currentDistanceMeasurement.destroy();
85948
+ this._currentDistanceMeasurement = null;
85949
+ }
85950
+ }
85903
85951
 
85904
- /**
85905
- * Destroys this DistanceMeasurementsMouseControl.
85906
- *
85907
- * Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsMouseControl.
85908
- */
85909
- destroy() {
85910
- this.deactivate();
85911
- super.destroy();
85912
- }
85952
+ /**
85953
+ * Destroys this DistanceMeasurementsMouseControl.
85954
+ *
85955
+ * Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsMouseControl.
85956
+ */
85957
+ destroy() {
85958
+ this.deactivate();
85959
+ super.destroy();
85960
+ }
85913
85961
  }
85914
85962
 
85915
85963
  /**
@@ -92098,371 +92146,379 @@ const tempVec4a$3 = math.vec4();
92098
92146
  const tempVec4b$3 = math.vec4();
92099
92147
  const tempVec4c = math.vec4();
92100
92148
 
92101
-
92102
92149
  /** @private */
92103
92150
  class PivotController {
92151
+ /**
92152
+ * @private
92153
+ */
92154
+ constructor(scene, configs) {
92155
+ // Pivot math by: http://www.derschmale.com/
92156
+
92157
+ this._scene = scene;
92158
+ this._configs = configs;
92159
+ this._pivotWorldPos = math.vec3();
92160
+ this._cameraOffset = math.vec3();
92161
+ this._azimuth = 0;
92162
+ this._polar = 0;
92163
+ this._radius = 0;
92164
+ this._pivotPosSet = false; // Initially false, true as soon as _pivotWorldPos has been set to some value
92165
+ this._pivoting = false; // True while pivoting
92166
+ this._shown = false;
92167
+
92168
+ this._pivotSphereEnabled = false;
92169
+ this._pivotSphere = null;
92170
+ this._pivotSphereSize = 1;
92171
+ this._pivotSphereGeometry = null;
92172
+ this._pivotSphereMaterial = null;
92173
+ this._rtcCenter = math.vec3();
92174
+ this._rtcPos = math.vec3();
92175
+
92176
+ this._pivotViewPos = math.vec4();
92177
+ this._pivotProjPos = math.vec4();
92178
+ this._pivotCanvasPos = math.vec2();
92179
+ this._cameraDirty = true;
92180
+
92181
+ this._onViewMatrix = this._scene.camera.on("viewMatrix", () => {
92182
+ this._cameraDirty = true;
92183
+ });
92104
92184
 
92105
- /**
92106
- * @private
92107
- */
92108
- constructor(scene, configs) {
92109
-
92110
- // Pivot math by: http://www.derschmale.com/
92111
-
92112
- this._scene = scene;
92113
- this._configs = configs;
92114
- this._pivotWorldPos = math.vec3();
92115
- this._cameraOffset = math.vec3();
92116
- this._azimuth = 0;
92117
- this._polar = 0;
92118
- this._radius = 0;
92119
- this._pivotPosSet = false; // Initially false, true as soon as _pivotWorldPos has been set to some value
92120
- this._pivoting = false; // True while pivoting
92121
- this._shown = false;
92122
-
92123
- this._pivotSphereEnabled = false;
92124
- this._pivotSphere = null;
92125
- this._pivotSphereSize = 1;
92126
- this._pivotSphereGeometry = null;
92127
- this._pivotSphereMaterial = null;
92128
- this._rtcCenter = math.vec3();
92129
- this._rtcPos = math.vec3();
92130
-
92131
- this._pivotViewPos = math.vec4();
92132
- this._pivotProjPos = math.vec4();
92133
- this._pivotCanvasPos = math.vec2();
92134
- this._cameraDirty = true;
92135
-
92136
- this._onViewMatrix = this._scene.camera.on("viewMatrix", () => {
92137
- this._cameraDirty = true;
92138
- });
92139
-
92140
- this._onProjMatrix = this._scene.camera.on("projMatrix", () => {
92141
- this._cameraDirty = true;
92142
- });
92143
-
92144
- this._onTick = this._scene.on("tick", () => {
92145
- this.updatePivotElement();
92146
- this.updatePivotSphere();
92147
- });
92148
- }
92149
-
92150
- createPivotSphere() {
92151
- const currentPos = this.getPivotPos();
92152
- const cameraPos = math.vec3();
92153
- math.decomposeMat4(math.inverseMat4(this._scene.viewer.camera.viewMatrix, math.mat4()), cameraPos, math.vec4(), math.vec3());
92154
- const length = math.distVec3(cameraPos, currentPos);
92155
- let radius = (Math.tan(Math.PI / 500) * length) * this._pivotSphereSize;
92156
-
92157
- if (this._scene.camera.projection == "ortho") {
92158
- radius /= (this._scene.camera.ortho.scale / 2);
92159
- }
92160
-
92161
- worldToRTCPos(currentPos, this._rtcCenter, this._rtcPos);
92162
- this._pivotSphereGeometry = new VBOGeometry(
92163
- this._scene,
92164
- buildSphereGeometry({ radius })
92165
- );
92166
- this._pivotSphere = new Mesh(this._scene, {
92167
- geometry: this._pivotSphereGeometry,
92168
- material: this._pivotSphereMaterial,
92169
- pickable: false,
92170
- position: this._rtcPos,
92171
- rtcCenter: this._rtcCenter
92172
- });
92173
- };
92174
-
92175
- destroyPivotSphere() {
92176
- if (this._pivotSphere) {
92177
- this._pivotSphere.destroy();
92178
- this._pivotSphere = null;
92179
- }
92180
- if (this._pivotSphereGeometry) {
92181
- this._pivotSphereGeometry.destroy();
92182
- this._pivotSphereGeometry = null;
92183
- }
92184
- }
92185
-
92186
- updatePivotElement() {
92187
-
92188
- const camera = this._scene.camera;
92189
- const canvas = this._scene.canvas;
92190
-
92191
- if (this._pivoting && this._cameraDirty) {
92192
-
92193
- math.transformPoint3(camera.viewMatrix, this.getPivotPos(), this._pivotViewPos);
92194
- this._pivotViewPos[3] = 1;
92195
- math.transformPoint4(camera.projMatrix, this._pivotViewPos, this._pivotProjPos);
92185
+ this._onProjMatrix = this._scene.camera.on("projMatrix", () => {
92186
+ this._cameraDirty = true;
92187
+ });
92196
92188
 
92197
- const canvasAABB = canvas.boundary;
92198
- const canvasWidth = canvasAABB[2];
92199
- const canvasHeight = canvasAABB[3];
92189
+ this._onTick = this._scene.on("tick", () => {
92190
+ this.updatePivotElement();
92191
+ this.updatePivotSphere();
92192
+ });
92193
+ }
92200
92194
 
92201
- this._pivotCanvasPos[0] = Math.floor((1 + this._pivotProjPos[0] / this._pivotProjPos[3]) * canvasWidth / 2);
92202
- this._pivotCanvasPos[1] = Math.floor((1 - this._pivotProjPos[1] / this._pivotProjPos[3]) * canvasHeight / 2);
92195
+ createPivotSphere() {
92196
+ const currentPos = this.getPivotPos();
92197
+ const cameraPos = math.vec3();
92198
+ math.decomposeMat4(
92199
+ math.inverseMat4(this._scene.viewer.camera.viewMatrix, math.mat4()),
92200
+ cameraPos,
92201
+ math.vec4(),
92202
+ math.vec3()
92203
+ );
92204
+ const length = math.distVec3(cameraPos, currentPos);
92205
+ let radius = Math.tan(Math.PI / 500) * length * this._pivotSphereSize;
92203
92206
 
92204
- // data-textures: avoid to do continuous DOM layout calculations
92205
- let canvasBoundingRect = canvas._lastBoundingClientRect;
92207
+ if (this._scene.camera.projection == "ortho") {
92208
+ radius /= this._scene.camera.ortho.scale / 2;
92209
+ }
92206
92210
 
92207
- if (!canvasBoundingRect || canvas._canvasSizeChanged)
92208
- {
92209
- const canvasElem = canvas.canvas;
92211
+ worldToRTCPos(currentPos, this._rtcCenter, this._rtcPos);
92212
+ this._pivotSphereGeometry = new VBOGeometry(this._scene, buildSphereGeometry({ radius }));
92213
+ this._pivotSphere = new Mesh(this._scene, {
92214
+ geometry: this._pivotSphereGeometry,
92215
+ material: this._pivotSphereMaterial,
92216
+ pickable: false,
92217
+ position: this._rtcPos,
92218
+ rtcCenter: this._rtcCenter
92219
+ });
92220
+ }
92210
92221
 
92211
- canvasBoundingRect = canvas._lastBoundingClientRect = canvasElem.getBoundingClientRect ();
92212
- }
92222
+ destroyPivotSphere() {
92223
+ if (this._pivotSphere) {
92224
+ this._pivotSphere.destroy();
92225
+ this._pivotSphere = null;
92226
+ }
92227
+ if (this._pivotSphereGeometry) {
92228
+ this._pivotSphereGeometry.destroy();
92229
+ this._pivotSphereGeometry = null;
92230
+ }
92231
+ }
92213
92232
 
92214
- if (this._pivotElement) {
92215
- this._pivotElement.style.left = (Math.floor(canvasBoundingRect.left + this._pivotCanvasPos[0]) - (this._pivotElement.clientWidth / 2) + window.scrollX) + "px";
92216
- this._pivotElement.style.top = (Math.floor(canvasBoundingRect.top + this._pivotCanvasPos[1]) - (this._pivotElement.clientHeight / 2) + window.scrollY) + "px";
92217
- }
92218
- this._cameraDirty = false;
92219
- }
92220
- }
92233
+ updatePivotElement() {
92234
+ const camera = this._scene.camera;
92235
+ const canvas = this._scene.canvas;
92236
+
92237
+ if (this._pivoting && this._cameraDirty) {
92238
+ math.transformPoint3(camera.viewMatrix, this.getPivotPos(), this._pivotViewPos);
92239
+ this._pivotViewPos[3] = 1;
92240
+ math.transformPoint4(camera.projMatrix, this._pivotViewPos, this._pivotProjPos);
92241
+
92242
+ const canvasAABB = canvas.boundary;
92243
+ const canvasWidth = canvasAABB[2];
92244
+ const canvasHeight = canvasAABB[3];
92245
+
92246
+ this._pivotCanvasPos[0] = Math.floor(((1 + this._pivotProjPos[0] / this._pivotProjPos[3]) * canvasWidth) / 2);
92247
+ this._pivotCanvasPos[1] = Math.floor(((1 - this._pivotProjPos[1] / this._pivotProjPos[3]) * canvasHeight) / 2);
92248
+
92249
+ // data-textures: avoid to do continuous DOM layout calculations
92250
+ let canvasBoundingRect = canvas._lastBoundingClientRect;
92251
+
92252
+ // if (!canvasBoundingRect || canvas._canvasSizeChanged) {
92253
+ const canvasElem = canvas.canvas;
92254
+
92255
+ canvasBoundingRect = canvas._lastBoundingClientRect = canvasElem.getBoundingClientRect();
92256
+ // }
92257
+
92258
+ if (this._pivotElement) {
92259
+ this._pivotElement.style.left =
92260
+ Math.floor(canvasBoundingRect.left + this._pivotCanvasPos[0]) -
92261
+ this._pivotElement.clientWidth / 2 +
92262
+ window.scrollX +
92263
+ "px";
92264
+ this._pivotElement.style.top =
92265
+ Math.floor(canvasBoundingRect.top + this._pivotCanvasPos[1]) -
92266
+ this._pivotElement.clientHeight / 2 +
92267
+ window.scrollY +
92268
+ "px";
92269
+ }
92270
+ this._cameraDirty = false;
92271
+ }
92272
+ }
92221
92273
 
92222
- updatePivotSphere() {
92223
- if (this._pivoting && this._pivotSphere) {
92224
- worldToRTCPos(this.getPivotPos(), this._rtcCenter, this._rtcPos);
92225
- if(!math.compareVec3(this._rtcPos, this._pivotSphere.position)) {
92226
- this.destroyPivotSphere();
92227
- this.createPivotSphere();
92228
- }
92229
- }
92230
- }
92231
- /**
92232
- * Sets the HTML DOM element that will represent the pivot position.
92233
- *
92234
- * @param pivotElement
92235
- */
92236
- setPivotElement(pivotElement) {
92237
- this._pivotElement = pivotElement;
92238
- }
92274
+ updatePivotSphere() {
92275
+ if (this._pivoting && this._pivotSphere) {
92276
+ worldToRTCPos(this.getPivotPos(), this._rtcCenter, this._rtcPos);
92277
+ if (!math.compareVec3(this._rtcPos, this._pivotSphere.position)) {
92278
+ this.destroyPivotSphere();
92279
+ this.createPivotSphere();
92280
+ }
92281
+ }
92282
+ }
92283
+ /**
92284
+ * Sets the HTML DOM element that will represent the pivot position.
92285
+ *
92286
+ * @param pivotElement
92287
+ */
92288
+ setPivotElement(pivotElement) {
92289
+ this._pivotElement = pivotElement;
92290
+ }
92239
92291
 
92240
- /**
92241
- * Sets a sphere as the representation of the pivot position.
92242
- *
92243
- * @param {Object} [cfg] Sphere configuration.
92244
- * @param {String} [cfg.size=1] Optional size factor of the sphere. Defaults to 1.
92245
- * @param {String} [cfg.color=Array] Optional maretial color. Defaults to a red.
92246
- */
92247
- enablePivotSphere(cfg = {}) {
92248
- this.destroyPivotSphere();
92249
- this._pivotSphereEnabled = true;
92250
- if (cfg.size) {
92251
- this._pivotSphereSize = cfg.size;
92252
- }
92253
- const color = cfg.color || [1, 0, 0];
92254
- this._pivotSphereMaterial = new PhongMaterial(this._scene, {
92255
- emissive: color,
92256
- ambient: color,
92257
- specular: [0,0,0],
92258
- diffuse: [0,0,0],
92259
- });
92260
- }
92292
+ /**
92293
+ * Sets a sphere as the representation of the pivot position.
92294
+ *
92295
+ * @param {Object} [cfg] Sphere configuration.
92296
+ * @param {String} [cfg.size=1] Optional size factor of the sphere. Defaults to 1.
92297
+ * @param {String} [cfg.color=Array] Optional maretial color. Defaults to a red.
92298
+ */
92299
+ enablePivotSphere(cfg = {}) {
92300
+ this.destroyPivotSphere();
92301
+ this._pivotSphereEnabled = true;
92302
+ if (cfg.size) {
92303
+ this._pivotSphereSize = cfg.size;
92304
+ }
92305
+ const color = cfg.color || [1, 0, 0];
92306
+ this._pivotSphereMaterial = new PhongMaterial(this._scene, {
92307
+ emissive: color,
92308
+ ambient: color,
92309
+ specular: [0, 0, 0],
92310
+ diffuse: [0, 0, 0]
92311
+ });
92312
+ }
92261
92313
 
92262
- /**
92263
- * Remove the sphere as the representation of the pivot position.
92264
- *
92265
- */
92266
- disablePivotSphere() {
92267
- this.destroyPivotSphere();
92268
- this._pivotSphereEnabled = false;
92269
- }
92314
+ /**
92315
+ * Remove the sphere as the representation of the pivot position.
92316
+ *
92317
+ */
92318
+ disablePivotSphere() {
92319
+ this.destroyPivotSphere();
92320
+ this._pivotSphereEnabled = false;
92321
+ }
92270
92322
 
92271
- /**
92272
- * Begins pivoting.
92273
- */
92274
- startPivot() {
92323
+ /**
92324
+ * Begins pivoting.
92325
+ */
92326
+ startPivot() {
92327
+ if (this._cameraLookingDownwards()) {
92328
+ this._pivoting = false;
92329
+ return false;
92330
+ }
92275
92331
 
92276
- if (this._cameraLookingDownwards()) {
92277
- this._pivoting = false;
92278
- return false;
92279
- }
92332
+ const camera = this._scene.camera;
92280
92333
 
92281
- const camera = this._scene.camera;
92334
+ let lookat = math.lookAtMat4v(camera.eye, camera.look, camera.worldUp);
92335
+ math.transformPoint3(lookat, this.getPivotPos(), this._cameraOffset);
92282
92336
 
92283
- let lookat = math.lookAtMat4v(camera.eye, camera.look, camera.worldUp);
92284
- math.transformPoint3(lookat, this.getPivotPos(), this._cameraOffset);
92337
+ const pivotPos = this.getPivotPos();
92338
+ this._cameraOffset[2] += math.distVec3(camera.eye, pivotPos);
92285
92339
 
92286
- const pivotPos = this.getPivotPos();
92287
- this._cameraOffset[2] += math.distVec3(camera.eye, pivotPos);
92340
+ lookat = math.inverseMat4(lookat);
92288
92341
 
92289
- lookat = math.inverseMat4(lookat);
92342
+ const offset = math.transformVec3(lookat, this._cameraOffset);
92343
+ const diff = math.vec3();
92290
92344
 
92291
- const offset = math.transformVec3(lookat, this._cameraOffset);
92292
- const diff = math.vec3();
92345
+ math.subVec3(camera.eye, pivotPos, diff);
92346
+ math.addVec3(diff, offset);
92293
92347
 
92294
- math.subVec3(camera.eye, pivotPos, diff);
92295
- math.addVec3(diff, offset);
92348
+ if (camera.zUp) {
92349
+ const t = diff[1];
92350
+ diff[1] = diff[2];
92351
+ diff[2] = t;
92352
+ }
92296
92353
 
92297
- if (camera.zUp) {
92298
- const t = diff[1];
92299
- diff[1] = diff[2];
92300
- diff[2] = t;
92301
- }
92354
+ this._radius = math.lenVec3(diff);
92355
+ this._polar = Math.acos(diff[1] / this._radius);
92356
+ this._azimuth = Math.atan2(diff[0], diff[2]);
92357
+ this._pivoting = true;
92358
+ }
92302
92359
 
92303
- this._radius = math.lenVec3(diff);
92304
- this._polar = Math.acos(diff[1] / this._radius);
92305
- this._azimuth = Math.atan2(diff[0], diff[2]);
92306
- this._pivoting = true;
92307
- }
92360
+ _cameraLookingDownwards() {
92361
+ // Returns true if angle between camera viewing direction and World-space "up" axis is too small
92362
+ const camera = this._scene.camera;
92363
+ const forwardAxis = math.normalizeVec3(math.subVec3(camera.look, camera.eye, tempVec3a$6));
92364
+ const rightAxis = math.cross3Vec3(forwardAxis, camera.worldUp, tempVec3b$3);
92365
+ let rightAxisLen = math.sqLenVec3(rightAxis);
92366
+ return rightAxisLen <= 0.0001;
92367
+ }
92308
92368
 
92309
- _cameraLookingDownwards() { // Returns true if angle between camera viewing direction and World-space "up" axis is too small
92310
- const camera = this._scene.camera;
92311
- const forwardAxis = math.normalizeVec3(math.subVec3(camera.look, camera.eye, tempVec3a$6));
92312
- const rightAxis = math.cross3Vec3(forwardAxis, camera.worldUp, tempVec3b$3);
92313
- let rightAxisLen = math.sqLenVec3(rightAxis);
92314
- return (rightAxisLen <= 0.0001);
92315
- }
92369
+ /**
92370
+ * Returns true if we are currently pivoting.
92371
+ *
92372
+ * @returns {Boolean}
92373
+ */
92374
+ getPivoting() {
92375
+ return this._pivoting;
92376
+ }
92316
92377
 
92317
- /**
92318
- * Returns true if we are currently pivoting.
92319
- *
92320
- * @returns {Boolean}
92321
- */
92322
- getPivoting() {
92323
- return this._pivoting;
92324
- }
92378
+ /**
92379
+ * Sets a 3D World-space position to pivot about.
92380
+ *
92381
+ * @param {Number[]} worldPos The new World-space pivot position.
92382
+ */
92383
+ setPivotPos(worldPos) {
92384
+ this._pivotWorldPos.set(worldPos);
92385
+ this._pivotPosSet = true;
92386
+ }
92325
92387
 
92326
- /**
92327
- * Sets a 3D World-space position to pivot about.
92328
- *
92329
- * @param {Number[]} worldPos The new World-space pivot position.
92330
- */
92331
- setPivotPos(worldPos) {
92332
- this._pivotWorldPos.set(worldPos);
92333
- this._pivotPosSet = true;
92334
- }
92388
+ /**
92389
+ * Sets the pivot position to the 3D projection of the given 2D canvas coordinates on a sphere centered
92390
+ * at the viewpoint. The radius of the sphere is configured via {@link CameraControl#smartPivot}.
92391
+ *
92392
+ *
92393
+ * @param canvasPos
92394
+ */
92395
+ setCanvasPivotPos(canvasPos) {
92396
+ const camera = this._scene.camera;
92397
+ const pivotShereRadius = Math.abs(math.distVec3(this._scene.center, camera.eye));
92398
+ const transposedProjectMat = camera.project.transposedMatrix;
92399
+ const Pt3 = transposedProjectMat.subarray(8, 12);
92400
+ const Pt4 = transposedProjectMat.subarray(12);
92401
+ const D = [0, 0, -1.0, 1];
92402
+ const screenZ = math.dotVec4(D, Pt3) / math.dotVec4(D, Pt4);
92403
+ const worldPos = tempVec4a$3;
92404
+ camera.project.unproject(canvasPos, screenZ, tempVec4b$3, tempVec4c, worldPos);
92405
+ const eyeWorldPosVec = math.normalizeVec3(math.subVec3(worldPos, camera.eye, tempVec3a$6));
92406
+ const posOnSphere = math.addVec3(
92407
+ camera.eye,
92408
+ math.mulVec3Scalar(eyeWorldPosVec, pivotShereRadius, tempVec3b$3),
92409
+ tempVec3c$2
92410
+ );
92411
+ this.setPivotPos(posOnSphere);
92412
+ }
92335
92413
 
92336
- /**
92337
- * Sets the pivot position to the 3D projection of the given 2D canvas coordinates on a sphere centered
92338
- * at the viewpoint. The radius of the sphere is configured via {@link CameraControl#smartPivot}.
92339
- *
92340
- *
92341
- * @param canvasPos
92342
- */
92343
- setCanvasPivotPos(canvasPos) {
92344
- const camera = this._scene.camera;
92345
- const pivotShereRadius = Math.abs(math.distVec3(this._scene.center, camera.eye));
92346
- const transposedProjectMat = camera.project.transposedMatrix;
92347
- const Pt3 = transposedProjectMat.subarray(8, 12);
92348
- const Pt4 = transposedProjectMat.subarray(12);
92349
- const D = [0, 0, -1.0, 1];
92350
- const screenZ = math.dotVec4(D, Pt3) / math.dotVec4(D, Pt4);
92351
- const worldPos = tempVec4a$3;
92352
- camera.project.unproject(canvasPos, screenZ, tempVec4b$3, tempVec4c, worldPos);
92353
- const eyeWorldPosVec = math.normalizeVec3(math.subVec3(worldPos, camera.eye, tempVec3a$6));
92354
- const posOnSphere = math.addVec3(camera.eye, math.mulVec3Scalar(eyeWorldPosVec, pivotShereRadius, tempVec3b$3), tempVec3c$2);
92355
- this.setPivotPos(posOnSphere);
92356
- }
92414
+ /**
92415
+ * Gets the current position we're pivoting about.
92416
+ * @returns {Number[]} The current World-space pivot position.
92417
+ */
92418
+ getPivotPos() {
92419
+ return this._pivotPosSet ? this._pivotWorldPos : this._scene.camera.look; // Avoid pivoting about [0,0,0] by default
92420
+ }
92357
92421
 
92358
- /**
92359
- * Gets the current position we're pivoting about.
92360
- * @returns {Number[]} The current World-space pivot position.
92361
- */
92362
- getPivotPos() {
92363
- return (this._pivotPosSet) ? this._pivotWorldPos : this._scene.camera.look; // Avoid pivoting about [0,0,0] by default
92364
- }
92422
+ /**
92423
+ * Continues to pivot.
92424
+ *
92425
+ * @param {Number} yawInc Yaw rotation increment.
92426
+ * @param {Number} pitchInc Pitch rotation increment.
92427
+ */
92428
+ continuePivot(yawInc, pitchInc) {
92429
+ if (!this._pivoting) {
92430
+ return;
92431
+ }
92432
+ if (yawInc === 0 && pitchInc === 0) {
92433
+ return;
92434
+ }
92435
+ const camera = this._scene.camera;
92436
+ var dx = -yawInc;
92437
+ const dy = -pitchInc;
92438
+ if (camera.worldUp[2] === 1) {
92439
+ dx = -dx;
92440
+ }
92441
+ this._azimuth += -dx * 0.01;
92442
+ this._polar += dy * 0.01;
92443
+ this._polar = math.clamp(this._polar, 0.001, Math.PI - 0.001);
92444
+ const pos = [
92445
+ this._radius * Math.sin(this._polar) * Math.sin(this._azimuth),
92446
+ this._radius * Math.cos(this._polar),
92447
+ this._radius * Math.sin(this._polar) * Math.cos(this._azimuth)
92448
+ ];
92449
+ if (camera.worldUp[2] === 1) {
92450
+ const t = pos[1];
92451
+ pos[1] = pos[2];
92452
+ pos[2] = t;
92453
+ }
92454
+ // Preserve the eye->look distance, since in xeokit "look" is the point-of-interest, not the direction vector.
92455
+ const eyeLookLen = math.lenVec3(math.subVec3(camera.look, camera.eye, math.vec3()));
92456
+ const pivotPos = this.getPivotPos();
92457
+ math.addVec3(pos, pivotPos);
92458
+ let lookat = math.lookAtMat4v(pos, pivotPos, camera.worldUp);
92459
+ lookat = math.inverseMat4(lookat);
92460
+ const offset = math.transformVec3(lookat, this._cameraOffset);
92461
+ lookat[12] -= offset[0];
92462
+ lookat[13] -= offset[1];
92463
+ lookat[14] -= offset[2];
92464
+ const zAxis = [lookat[8], lookat[9], lookat[10]];
92465
+ camera.eye = [lookat[12], lookat[13], lookat[14]];
92466
+ math.subVec3(camera.eye, math.mulVec3Scalar(zAxis, eyeLookLen), camera.look);
92467
+ camera.up = [lookat[4], lookat[5], lookat[6]];
92468
+ this.showPivot();
92469
+ }
92365
92470
 
92366
- /**
92367
- * Continues to pivot.
92368
- *
92369
- * @param {Number} yawInc Yaw rotation increment.
92370
- * @param {Number} pitchInc Pitch rotation increment.
92371
- */
92372
- continuePivot(yawInc, pitchInc) {
92373
- if (!this._pivoting) {
92374
- return;
92375
- }
92376
- if (yawInc === 0 && pitchInc === 0) {
92377
- return;
92378
- }
92379
- const camera = this._scene.camera;
92380
- var dx = -yawInc;
92381
- const dy = -pitchInc;
92382
- if (camera.worldUp[2] === 1) {
92383
- dx = -dx;
92384
- }
92385
- this._azimuth += -dx * .01;
92386
- this._polar += dy * .01;
92387
- this._polar = math.clamp(this._polar, .001, Math.PI - .001);
92388
- const pos = [
92389
- this._radius * Math.sin(this._polar) * Math.sin(this._azimuth),
92390
- this._radius * Math.cos(this._polar),
92391
- this._radius * Math.sin(this._polar) * Math.cos(this._azimuth)
92392
- ];
92393
- if (camera.worldUp[2] === 1) {
92394
- const t = pos[1];
92395
- pos[1] = pos[2];
92396
- pos[2] = t;
92397
- }
92398
- // Preserve the eye->look distance, since in xeokit "look" is the point-of-interest, not the direction vector.
92399
- const eyeLookLen = math.lenVec3(math.subVec3(camera.look, camera.eye, math.vec3()));
92400
- const pivotPos = this.getPivotPos();
92401
- math.addVec3(pos, pivotPos);
92402
- let lookat = math.lookAtMat4v(pos, pivotPos, camera.worldUp);
92403
- lookat = math.inverseMat4(lookat);
92404
- const offset = math.transformVec3(lookat, this._cameraOffset);
92405
- lookat[12] -= offset[0];
92406
- lookat[13] -= offset[1];
92407
- lookat[14] -= offset[2];
92408
- const zAxis = [lookat[8], lookat[9], lookat[10]];
92409
- camera.eye = [lookat[12], lookat[13], lookat[14]];
92410
- math.subVec3(camera.eye, math.mulVec3Scalar(zAxis, eyeLookLen), camera.look);
92411
- camera.up = [lookat[4], lookat[5], lookat[6]];
92412
- this.showPivot();
92413
- }
92414
-
92415
- /**
92416
- * Shows the pivot position.
92417
- *
92418
- * Only works if we set an HTML DOM element to represent the pivot position.
92419
- */
92420
- showPivot() {
92421
- if (this._shown) {
92422
- return;
92423
- }
92424
- if (this._pivotElement) {
92425
- this.updatePivotElement();
92426
- this._pivotElement.style.visibility = "visible";
92427
- }
92428
- if (this._pivotSphereEnabled) {
92429
- this.destroyPivotSphere();
92430
- this.createPivotSphere();
92431
- }
92432
- this._shown = true;
92433
- }
92471
+ /**
92472
+ * Shows the pivot position.
92473
+ *
92474
+ * Only works if we set an HTML DOM element to represent the pivot position.
92475
+ */
92476
+ showPivot() {
92477
+ if (this._shown) {
92478
+ return;
92479
+ }
92480
+ if (this._pivotElement) {
92481
+ this.updatePivotElement();
92482
+ this._pivotElement.style.visibility = "visible";
92483
+ }
92484
+ if (this._pivotSphereEnabled) {
92485
+ this.destroyPivotSphere();
92486
+ this.createPivotSphere();
92487
+ }
92488
+ this._shown = true;
92489
+ }
92434
92490
 
92435
- /**
92436
- * Hides the pivot position.
92437
- *
92438
- * Only works if we set an HTML DOM element to represent the pivot position.
92439
- */
92440
- hidePivot() {
92441
- if (!this._shown) {
92442
- return;
92443
- }
92444
- if (this._pivotElement) {
92445
- this._pivotElement.style.visibility = "hidden";
92446
- }
92447
- if (this._pivotSphereEnabled) {
92448
- this.destroyPivotSphere();
92449
- }
92450
- this._shown = false;
92451
- }
92491
+ /**
92492
+ * Hides the pivot position.
92493
+ *
92494
+ * Only works if we set an HTML DOM element to represent the pivot position.
92495
+ */
92496
+ hidePivot() {
92497
+ if (!this._shown) {
92498
+ return;
92499
+ }
92500
+ if (this._pivotElement) {
92501
+ this._pivotElement.style.visibility = "hidden";
92502
+ }
92503
+ if (this._pivotSphereEnabled) {
92504
+ this.destroyPivotSphere();
92505
+ }
92506
+ this._shown = false;
92507
+ }
92452
92508
 
92453
- /**
92454
- * Finishes pivoting.
92455
- */
92456
- endPivot() {
92457
- this._pivoting = false;
92458
- }
92509
+ /**
92510
+ * Finishes pivoting.
92511
+ */
92512
+ endPivot() {
92513
+ this._pivoting = false;
92514
+ }
92459
92515
 
92460
- destroy() {
92461
- this.destroyPivotSphere();
92462
- this._scene.camera.off(this._onViewMatrix);
92463
- this._scene.camera.off(this._onProjMatrix);
92464
- this._scene.off(this._onTick);
92465
- }
92516
+ destroy() {
92517
+ this.destroyPivotSphere();
92518
+ this._scene.camera.off(this._onViewMatrix);
92519
+ this._scene.camera.off(this._onProjMatrix);
92520
+ this._scene.off(this._onTick);
92521
+ }
92466
92522
  }
92467
92523
 
92468
92524
  /**
@@ -95059,1270 +95115,1274 @@ const DEFAULT_SNAP_EDGE = true;
95059
95115
  * * ````"azerty"````
95060
95116
  */
95061
95117
  class CameraControl extends Component {
95118
+ /**
95119
+ * @private
95120
+ * @constructor
95121
+ */
95122
+ constructor(owner, cfg = {}) {
95123
+ super(owner, cfg);
95062
95124
 
95063
- /**
95064
- * @private
95065
- * @constructor
95066
- */
95067
- constructor(owner, cfg = {}) {
95125
+ /**
95126
+ * Identifies the XX action.
95127
+ * @final
95128
+ * @type {Number}
95129
+ */
95130
+ this.PAN_LEFT = 0;
95068
95131
 
95069
- super(owner, cfg);
95132
+ /**
95133
+ * Identifies the XX action.
95134
+ * @final
95135
+ * @type {Number}
95136
+ */
95137
+ this.PAN_RIGHT = 1;
95070
95138
 
95071
- /**
95072
- * Identifies the XX action.
95073
- * @final
95074
- * @type {Number}
95075
- */
95076
- this.PAN_LEFT = 0;
95139
+ /**
95140
+ * Identifies the XX action.
95141
+ * @final
95142
+ * @type {Number}
95143
+ */
95144
+ this.PAN_UP = 2;
95077
95145
 
95078
- /**
95079
- * Identifies the XX action.
95080
- * @final
95081
- * @type {Number}
95082
- */
95083
- this.PAN_RIGHT = 1;
95146
+ /**
95147
+ * Identifies the XX action.
95148
+ * @final
95149
+ * @type {Number}
95150
+ */
95151
+ this.PAN_DOWN = 3;
95084
95152
 
95085
- /**
95086
- * Identifies the XX action.
95087
- * @final
95088
- * @type {Number}
95089
- */
95090
- this.PAN_UP = 2;
95153
+ /**
95154
+ * Identifies the XX action.
95155
+ * @final
95156
+ * @type {Number}
95157
+ */
95158
+ this.PAN_FORWARDS = 4;
95091
95159
 
95092
- /**
95093
- * Identifies the XX action.
95094
- * @final
95095
- * @type {Number}
95096
- */
95097
- this.PAN_DOWN = 3;
95160
+ /**
95161
+ * Identifies the XX action.
95162
+ * @final
95163
+ * @type {Number}
95164
+ */
95165
+ this.PAN_BACKWARDS = 5;
95098
95166
 
95099
- /**
95100
- * Identifies the XX action.
95101
- * @final
95102
- * @type {Number}
95103
- */
95104
- this.PAN_FORWARDS = 4;
95167
+ /**
95168
+ * Identifies the XX action.
95169
+ * @final
95170
+ * @type {Number}
95171
+ */
95172
+ this.ROTATE_X_POS = 6;
95105
95173
 
95106
- /**
95107
- * Identifies the XX action.
95108
- * @final
95109
- * @type {Number}
95110
- */
95111
- this.PAN_BACKWARDS = 5;
95174
+ /**
95175
+ * Identifies the XX action.
95176
+ * @final
95177
+ * @type {Number}
95178
+ */
95179
+ this.ROTATE_X_NEG = 7;
95112
95180
 
95113
- /**
95114
- * Identifies the XX action.
95115
- * @final
95116
- * @type {Number}
95117
- */
95118
- this.ROTATE_X_POS = 6;
95181
+ /**
95182
+ * Identifies the XX action.
95183
+ * @final
95184
+ * @type {Number}
95185
+ */
95186
+ this.ROTATE_Y_POS = 8;
95119
95187
 
95120
- /**
95121
- * Identifies the XX action.
95122
- * @final
95123
- * @type {Number}
95124
- */
95125
- this.ROTATE_X_NEG = 7;
95188
+ /**
95189
+ * Identifies the XX action.
95190
+ * @final
95191
+ * @type {Number}
95192
+ */
95193
+ this.ROTATE_Y_NEG = 9;
95126
95194
 
95127
- /**
95128
- * Identifies the XX action.
95129
- * @final
95130
- * @type {Number}
95131
- */
95132
- this.ROTATE_Y_POS = 8;
95195
+ /**
95196
+ * Identifies the XX action.
95197
+ * @final
95198
+ * @type {Number}
95199
+ */
95200
+ this.DOLLY_FORWARDS = 10;
95133
95201
 
95134
- /**
95135
- * Identifies the XX action.
95136
- * @final
95137
- * @type {Number}
95138
- */
95139
- this.ROTATE_Y_NEG = 9;
95202
+ /**
95203
+ * Identifies the XX action.
95204
+ * @final
95205
+ * @type {Number}
95206
+ */
95207
+ this.DOLLY_BACKWARDS = 11;
95140
95208
 
95141
- /**
95142
- * Identifies the XX action.
95143
- * @final
95144
- * @type {Number}
95145
- */
95146
- this.DOLLY_FORWARDS = 10;
95209
+ /**
95210
+ * Identifies the XX action.
95211
+ * @final
95212
+ * @type {Number}
95213
+ */
95214
+ this.AXIS_VIEW_RIGHT = 12;
95147
95215
 
95148
- /**
95149
- * Identifies the XX action.
95150
- * @final
95151
- * @type {Number}
95152
- */
95153
- this.DOLLY_BACKWARDS = 11;
95216
+ /**
95217
+ * Identifies the XX action.
95218
+ * @final
95219
+ * @type {Number}
95220
+ */
95221
+ this.AXIS_VIEW_BACK = 13;
95154
95222
 
95155
- /**
95156
- * Identifies the XX action.
95157
- * @final
95158
- * @type {Number}
95159
- */
95160
- this.AXIS_VIEW_RIGHT = 12;
95223
+ /**
95224
+ * Identifies the XX action.
95225
+ * @final
95226
+ * @type {Number}
95227
+ */
95228
+ this.AXIS_VIEW_LEFT = 14;
95161
95229
 
95162
- /**
95163
- * Identifies the XX action.
95164
- * @final
95165
- * @type {Number}
95166
- */
95167
- this.AXIS_VIEW_BACK = 13;
95230
+ /**
95231
+ * Identifies the XX action.
95232
+ * @final
95233
+ * @type {Number}
95234
+ */
95235
+ this.AXIS_VIEW_FRONT = 15;
95168
95236
 
95169
- /**
95170
- * Identifies the XX action.
95171
- * @final
95172
- * @type {Number}
95173
- */
95174
- this.AXIS_VIEW_LEFT = 14;
95237
+ /**
95238
+ * Identifies the XX action.
95239
+ * @final
95240
+ * @type {Number}
95241
+ */
95242
+ this.AXIS_VIEW_TOP = 16;
95175
95243
 
95176
- /**
95177
- * Identifies the XX action.
95178
- * @final
95179
- * @type {Number}
95180
- */
95181
- this.AXIS_VIEW_FRONT = 15;
95244
+ /**
95245
+ * Identifies the XX action.
95246
+ * @final
95247
+ * @type {Number}
95248
+ */
95249
+ this.AXIS_VIEW_BOTTOM = 17;
95182
95250
 
95183
- /**
95184
- * Identifies the XX action.
95185
- * @final
95186
- * @type {Number}
95187
- */
95188
- this.AXIS_VIEW_TOP = 16;
95251
+ this._keyMap = {}; // Maps key codes to the above actions
95189
95252
 
95190
- /**
95191
- * Identifies the XX action.
95192
- * @final
95193
- * @type {Number}
95194
- */
95195
- this.AXIS_VIEW_BOTTOM = 17;
95253
+ this.scene.canvas.canvas.oncontextmenu = (e) => {
95254
+ e.preventDefault();
95255
+ };
95196
95256
 
95197
- this._keyMap = {}; // Maps key codes to the above actions
95257
+ // User-settable CameraControl configurations
95198
95258
 
95199
- this.scene.canvas.canvas.oncontextmenu = (e) => {
95200
- e.preventDefault();
95201
- };
95259
+ this._configs = {
95260
+ // Private
95202
95261
 
95203
- // User-settable CameraControl configurations
95262
+ longTapTimeout: 600, // Millisecs
95263
+ longTapRadius: 5, // Pixels
95204
95264
 
95205
- this._configs = {
95265
+ // General
95206
95266
 
95207
- // Private
95267
+ active: true,
95268
+ keyboardLayout: "qwerty",
95269
+ navMode: "orbit",
95270
+ planView: false,
95271
+ firstPerson: false,
95272
+ followPointer: true,
95273
+ doublePickFlyTo: true,
95274
+ panRightClick: true,
95275
+ showPivot: false,
95276
+ pointerEnabled: true,
95277
+ constrainVertical: false,
95278
+ smartPivot: false,
95279
+ doubleClickTimeFrame: 250,
95208
95280
 
95209
- longTapTimeout: 600, // Millisecs
95210
- longTapRadius: 5, // Pixels
95281
+ snapToVertex: DEFAULT_SNAP_VERTEX,
95282
+ snapToEdge: DEFAULT_SNAP_EDGE,
95283
+ snapRadius: DEFAULT_SNAP_PICK_RADIUS,
95211
95284
 
95212
- // General
95285
+ // Rotation
95213
95286
 
95214
- active: true,
95215
- keyboardLayout: "qwerty",
95216
- navMode: "orbit",
95217
- planView: false,
95218
- firstPerson: false,
95219
- followPointer: true,
95220
- doublePickFlyTo: true,
95221
- panRightClick: true,
95222
- showPivot: false,
95223
- pointerEnabled: true,
95224
- constrainVertical: false,
95225
- smartPivot: false,
95226
- doubleClickTimeFrame: 250,
95227
-
95228
- snapToVertex: DEFAULT_SNAP_VERTEX,
95229
- snapToEdge: DEFAULT_SNAP_EDGE,
95230
- snapRadius: DEFAULT_SNAP_PICK_RADIUS,
95287
+ dragRotationRate: 360.0,
95288
+ keyboardRotationRate: 90.0,
95289
+ rotationInertia: 0.0,
95231
95290
 
95232
- // Rotation
95291
+ // Panning
95233
95292
 
95234
- dragRotationRate: 360.0,
95235
- keyboardRotationRate: 90.0,
95236
- rotationInertia: 0.0,
95293
+ keyboardPanRate: 1.0,
95294
+ touchPanRate: 1.0,
95295
+ panInertia: 0.5,
95237
95296
 
95238
- // Panning
95297
+ // Dollying
95239
95298
 
95240
- keyboardPanRate: 1.0,
95241
- touchPanRate: 1.0,
95242
- panInertia: 0.5,
95299
+ keyboardDollyRate: 10,
95300
+ mouseWheelDollyRate: 100,
95301
+ touchDollyRate: 0.2,
95302
+ dollyInertia: 0,
95303
+ dollyProximityThreshold: 30.0,
95304
+ dollyMinSpeed: 0.04
95305
+ };
95243
95306
 
95244
- // Dollying
95307
+ // Current runtime state of the CameraControl
95308
+
95309
+ this._states = {
95310
+ pointerCanvasPos: math.vec2(),
95311
+ mouseover: false,
95312
+ followPointerDirty: true,
95313
+ mouseDownClientX: 0,
95314
+ mouseDownClientY: 0,
95315
+ mouseDownCursorX: 0,
95316
+ mouseDownCursorY: 0,
95317
+ touchStartTime: null,
95318
+ activeTouches: [],
95319
+ tapStartPos: math.vec2(),
95320
+ tapStartTime: -1,
95321
+ lastTapTime: -1,
95322
+ longTouchTimeout: null
95323
+ };
95245
95324
 
95246
- keyboardDollyRate: 10,
95247
- mouseWheelDollyRate: 100,
95248
- touchDollyRate: 0.2,
95249
- dollyInertia: 0,
95250
- dollyProximityThreshold: 30.0,
95251
- dollyMinSpeed: 0.04
95252
- };
95325
+ // Updates for CameraUpdater to process on next Scene "tick" event
95253
95326
 
95254
- // Current runtime state of the CameraControl
95255
-
95256
- this._states = {
95257
- pointerCanvasPos: math.vec2(),
95258
- mouseover: false,
95259
- followPointerDirty: true,
95260
- mouseDownClientX: 0,
95261
- mouseDownClientY: 0,
95262
- mouseDownCursorX: 0,
95263
- mouseDownCursorY: 0,
95264
- touchStartTime: null,
95265
- activeTouches: [],
95266
- tapStartPos: math.vec2(),
95267
- tapStartTime: -1,
95268
- lastTapTime: -1,
95269
- longTouchTimeout: null
95270
- };
95327
+ this._updates = {
95328
+ rotateDeltaX: 0,
95329
+ rotateDeltaY: 0,
95330
+ panDeltaX: 0,
95331
+ panDeltaY: 0,
95332
+ panDeltaZ: 0,
95333
+ dollyDelta: 0
95334
+ };
95271
95335
 
95272
- // Updates for CameraUpdater to process on next Scene "tick" event
95336
+ // Controllers to assist input event handlers with controlling the Camera
95273
95337
 
95274
- this._updates = {
95275
- rotateDeltaX: 0,
95276
- rotateDeltaY: 0,
95277
- panDeltaX: 0,
95278
- panDeltaY: 0,
95279
- panDeltaZ: 0,
95280
- dollyDelta: 0
95281
- };
95338
+ const scene = this.scene;
95282
95339
 
95283
- // Controllers to assist input event handlers with controlling the Camera
95340
+ this._controllers = {
95341
+ cameraControl: this,
95342
+ pickController: new PickController(this, this._configs),
95343
+ pivotController: new PivotController(scene, this._configs),
95344
+ panController: new PanController(scene),
95345
+ cameraFlight: new CameraFlightAnimation(this, {
95346
+ duration: 0.5
95347
+ })
95348
+ };
95284
95349
 
95285
- const scene = this.scene;
95350
+ // Input event handlers
95286
95351
 
95287
- this._controllers = {
95288
- cameraControl: this,
95289
- pickController: new PickController(this, this._configs),
95290
- pivotController: new PivotController(scene, this._configs),
95291
- panController: new PanController(scene),
95292
- cameraFlight: new CameraFlightAnimation(this, {
95293
- duration: 0.5
95294
- })
95295
- };
95352
+ this._handlers = [
95353
+ new MouseMiscHandler(this.scene, this._controllers, this._configs, this._states, this._updates),
95354
+ new TouchPanRotateAndDollyHandler(this.scene, this._controllers, this._configs, this._states, this._updates),
95355
+ new MousePanRotateDollyHandler(this.scene, this._controllers, this._configs, this._states, this._updates),
95356
+ new KeyboardAxisViewHandler(this.scene, this._controllers, this._configs, this._states, this._updates),
95357
+ new MousePickHandler(this.scene, this._controllers, this._configs, this._states, this._updates),
95358
+ new TouchPickHandler(this.scene, this._controllers, this._configs, this._states, this._updates),
95359
+ new KeyboardPanRotateDollyHandler(this.scene, this._controllers, this._configs, this._states, this._updates)
95360
+ ];
95296
95361
 
95297
- // Input event handlers
95362
+ // Applies scheduled updates to the Camera on each Scene "tick" event
95298
95363
 
95299
- this._handlers = [
95300
- new MouseMiscHandler(this.scene, this._controllers, this._configs, this._states, this._updates),
95301
- new TouchPanRotateAndDollyHandler(this.scene, this._controllers, this._configs, this._states, this._updates),
95302
- new MousePanRotateDollyHandler(this.scene, this._controllers, this._configs, this._states, this._updates),
95303
- new KeyboardAxisViewHandler(this.scene, this._controllers, this._configs, this._states, this._updates),
95304
- new MousePickHandler(this.scene, this._controllers, this._configs, this._states, this._updates),
95305
- new TouchPickHandler(this.scene, this._controllers, this._configs, this._states, this._updates),
95306
- new KeyboardPanRotateDollyHandler(this.scene, this._controllers, this._configs, this._states, this._updates)
95307
- ];
95364
+ this._cameraUpdater = new CameraUpdater(this.scene, this._controllers, this._configs, this._states, this._updates);
95308
95365
 
95309
- // Applies scheduled updates to the Camera on each Scene "tick" event
95366
+ // Set initial user configurations
95310
95367
 
95311
- this._cameraUpdater = new CameraUpdater(this.scene, this._controllers, this._configs, this._states, this._updates);
95368
+ this.navMode = cfg.navMode;
95369
+ if (cfg.planView) {
95370
+ this.planView = cfg.planView;
95371
+ }
95372
+ this.constrainVertical = cfg.constrainVertical;
95373
+ if (cfg.keyboardLayout) {
95374
+ this.keyboardLayout = cfg.keyboardLayout; // Deprecated
95375
+ } else {
95376
+ this.keyMap = cfg.keyMap;
95377
+ }
95378
+ this.doublePickFlyTo = cfg.doublePickFlyTo;
95379
+ this.panRightClick = cfg.panRightClick;
95380
+ this.active = cfg.active;
95381
+ this.followPointer = cfg.followPointer;
95382
+ this.rotationInertia = cfg.rotationInertia;
95383
+ this.keyboardPanRate = cfg.keyboardPanRate;
95384
+ this.touchPanRate = cfg.touchPanRate;
95385
+ this.keyboardRotationRate = cfg.keyboardRotationRate;
95386
+ this.dragRotationRate = cfg.dragRotationRate;
95387
+ this.touchDollyRate = cfg.touchDollyRate;
95388
+ this.dollyInertia = cfg.dollyInertia;
95389
+ this.dollyProximityThreshold = cfg.dollyProximityThreshold;
95390
+ this.dollyMinSpeed = cfg.dollyMinSpeed;
95391
+ this.panInertia = cfg.panInertia;
95392
+ this.pointerEnabled = true;
95393
+ this.keyboardDollyRate = cfg.keyboardDollyRate;
95394
+ this.mouseWheelDollyRate = cfg.mouseWheelDollyRate;
95395
+ }
95312
95396
 
95313
- // Set initial user configurations
95397
+ /**
95398
+ * Sets custom mappings of keys to ````CameraControl```` actions.
95399
+ *
95400
+ * See class docs for usage.
95401
+ *
95402
+ * @param {{Number:Number}|String} value Either a set of new key mappings, or a string to select a keyboard layout,
95403
+ * which causes ````CameraControl```` to use the default key mappings for that layout.
95404
+ */
95405
+ set keyMap(value) {
95406
+ value = value || "qwerty";
95407
+ if (utils.isString(value)) {
95408
+ const input = this.scene.input;
95409
+ const keyMap = {};
95410
+
95411
+ switch (value) {
95412
+ default:
95413
+ this.error("Unsupported value for 'keyMap': " + value + " defaulting to 'qwerty'");
95414
+ // Intentional fall-through to "qwerty"
95415
+ case "qwerty":
95416
+ keyMap[this.PAN_LEFT] = [input.KEY_A];
95417
+ keyMap[this.PAN_RIGHT] = [input.KEY_D];
95418
+ keyMap[this.PAN_UP] = [input.KEY_Z];
95419
+ keyMap[this.PAN_DOWN] = [input.KEY_X];
95420
+ keyMap[this.PAN_BACKWARDS] = [];
95421
+ keyMap[this.PAN_FORWARDS] = [];
95422
+ keyMap[this.DOLLY_FORWARDS] = [input.KEY_W, input.KEY_ADD];
95423
+ keyMap[this.DOLLY_BACKWARDS] = [input.KEY_S, input.KEY_SUBTRACT];
95424
+ keyMap[this.ROTATE_X_POS] = [input.KEY_DOWN_ARROW];
95425
+ keyMap[this.ROTATE_X_NEG] = [input.KEY_UP_ARROW];
95426
+ keyMap[this.ROTATE_Y_POS] = [input.KEY_Q, input.KEY_LEFT_ARROW];
95427
+ keyMap[this.ROTATE_Y_NEG] = [input.KEY_E, input.KEY_RIGHT_ARROW];
95428
+ keyMap[this.AXIS_VIEW_RIGHT] = [input.KEY_NUM_1];
95429
+ keyMap[this.AXIS_VIEW_BACK] = [input.KEY_NUM_2];
95430
+ keyMap[this.AXIS_VIEW_LEFT] = [input.KEY_NUM_3];
95431
+ keyMap[this.AXIS_VIEW_FRONT] = [input.KEY_NUM_4];
95432
+ keyMap[this.AXIS_VIEW_TOP] = [input.KEY_NUM_5];
95433
+ keyMap[this.AXIS_VIEW_BOTTOM] = [input.KEY_NUM_6];
95434
+ break;
95435
+
95436
+ case "azerty":
95437
+ keyMap[this.PAN_LEFT] = [input.KEY_Q];
95438
+ keyMap[this.PAN_RIGHT] = [input.KEY_D];
95439
+ keyMap[this.PAN_UP] = [input.KEY_W];
95440
+ keyMap[this.PAN_DOWN] = [input.KEY_X];
95441
+ keyMap[this.PAN_BACKWARDS] = [];
95442
+ keyMap[this.PAN_FORWARDS] = [];
95443
+ keyMap[this.DOLLY_FORWARDS] = [input.KEY_Z, input.KEY_ADD];
95444
+ keyMap[this.DOLLY_BACKWARDS] = [input.KEY_S, input.KEY_SUBTRACT];
95445
+ keyMap[this.ROTATE_X_POS] = [input.KEY_DOWN_ARROW];
95446
+ keyMap[this.ROTATE_X_NEG] = [input.KEY_UP_ARROW];
95447
+ keyMap[this.ROTATE_Y_POS] = [input.KEY_A, input.KEY_LEFT_ARROW];
95448
+ keyMap[this.ROTATE_Y_NEG] = [input.KEY_E, input.KEY_RIGHT_ARROW];
95449
+ keyMap[this.AXIS_VIEW_RIGHT] = [input.KEY_NUM_1];
95450
+ keyMap[this.AXIS_VIEW_BACK] = [input.KEY_NUM_2];
95451
+ keyMap[this.AXIS_VIEW_LEFT] = [input.KEY_NUM_3];
95452
+ keyMap[this.AXIS_VIEW_FRONT] = [input.KEY_NUM_4];
95453
+ keyMap[this.AXIS_VIEW_TOP] = [input.KEY_NUM_5];
95454
+ keyMap[this.AXIS_VIEW_BOTTOM] = [input.KEY_NUM_6];
95455
+ break;
95456
+ }
95314
95457
 
95315
- this.navMode = cfg.navMode;
95316
- if (cfg.planView) {
95317
- this.planView = cfg.planView;
95318
- }
95319
- this.constrainVertical = cfg.constrainVertical;
95320
- if (cfg.keyboardLayout) {
95321
- this.keyboardLayout = cfg.keyboardLayout; // Deprecated
95322
- } else {
95323
- this.keyMap = cfg.keyMap;
95324
- }
95325
- this.doublePickFlyTo = cfg.doublePickFlyTo;
95326
- this.panRightClick = cfg.panRightClick;
95327
- this.active = cfg.active;
95328
- this.followPointer = cfg.followPointer;
95329
- this.rotationInertia = cfg.rotationInertia;
95330
- this.keyboardPanRate = cfg.keyboardPanRate;
95331
- this.touchPanRate = cfg.touchPanRate;
95332
- this.keyboardRotationRate = cfg.keyboardRotationRate;
95333
- this.dragRotationRate = cfg.dragRotationRate;
95334
- this.touchDollyRate = cfg.touchDollyRate;
95335
- this.dollyInertia = cfg.dollyInertia;
95336
- this.dollyProximityThreshold = cfg.dollyProximityThreshold;
95337
- this.dollyMinSpeed = cfg.dollyMinSpeed;
95338
- this.panInertia = cfg.panInertia;
95339
- this.pointerEnabled = true;
95340
- this.keyboardDollyRate = cfg.keyboardDollyRate;
95341
- this.mouseWheelDollyRate = cfg.mouseWheelDollyRate;
95342
- }
95458
+ this._keyMap = keyMap;
95459
+ } else {
95460
+ const keyMap = value;
95461
+ this._keyMap = keyMap;
95462
+ }
95463
+ }
95343
95464
 
95344
- /**
95345
- * Sets custom mappings of keys to ````CameraControl```` actions.
95346
- *
95347
- * See class docs for usage.
95348
- *
95349
- * @param {{Number:Number}|String} value Either a set of new key mappings, or a string to select a keyboard layout,
95350
- * which causes ````CameraControl```` to use the default key mappings for that layout.
95351
- */
95352
- set keyMap(value) {
95353
- value = value || "qwerty";
95354
- if (utils.isString(value)) {
95355
- const input = this.scene.input;
95356
- const keyMap = {};
95465
+ /**
95466
+ * Gets custom mappings of keys to {@link CameraControl} actions.
95467
+ *
95468
+ * @returns {{Number:Number}} Current key mappings.
95469
+ */
95470
+ get keyMap() {
95471
+ return this._keyMap;
95472
+ }
95357
95473
 
95358
- switch (value) {
95474
+ /**
95475
+ * Returns true if any keys configured for the given action are down.
95476
+ * @param action
95477
+ * @param keyDownMap
95478
+ * @private
95479
+ */
95480
+ _isKeyDownForAction(action, keyDownMap) {
95481
+ const keys = this._keyMap[action];
95482
+ if (!keys) {
95483
+ return false;
95484
+ }
95485
+ if (!keyDownMap) {
95486
+ keyDownMap = this.scene.input.keyDown;
95487
+ }
95488
+ for (let i = 0, len = keys.length; i < len; i++) {
95489
+ const key = keys[i];
95490
+ if (keyDownMap[key]) {
95491
+ return true;
95492
+ }
95493
+ }
95494
+ return false;
95495
+ }
95359
95496
 
95360
- default:
95361
- this.error("Unsupported value for 'keyMap': " + value + " defaulting to 'qwerty'");
95362
- // Intentional fall-through to "qwerty"
95363
- case "qwerty":
95364
- keyMap[this.PAN_LEFT] = [input.KEY_A];
95365
- keyMap[this.PAN_RIGHT] = [input.KEY_D];
95366
- keyMap[this.PAN_UP] = [input.KEY_Z];
95367
- keyMap[this.PAN_DOWN] = [input.KEY_X];
95368
- keyMap[this.PAN_BACKWARDS] = [];
95369
- keyMap[this.PAN_FORWARDS] = [];
95370
- keyMap[this.DOLLY_FORWARDS] = [input.KEY_W, input.KEY_ADD];
95371
- keyMap[this.DOLLY_BACKWARDS] = [input.KEY_S, input.KEY_SUBTRACT];
95372
- keyMap[this.ROTATE_X_POS] = [input.KEY_DOWN_ARROW];
95373
- keyMap[this.ROTATE_X_NEG] = [input.KEY_UP_ARROW];
95374
- keyMap[this.ROTATE_Y_POS] = [input.KEY_Q, input.KEY_LEFT_ARROW];
95375
- keyMap[this.ROTATE_Y_NEG] = [input.KEY_E, input.KEY_RIGHT_ARROW];
95376
- keyMap[this.AXIS_VIEW_RIGHT] = [input.KEY_NUM_1];
95377
- keyMap[this.AXIS_VIEW_BACK] = [input.KEY_NUM_2];
95378
- keyMap[this.AXIS_VIEW_LEFT] = [input.KEY_NUM_3];
95379
- keyMap[this.AXIS_VIEW_FRONT] = [input.KEY_NUM_4];
95380
- keyMap[this.AXIS_VIEW_TOP] = [input.KEY_NUM_5];
95381
- keyMap[this.AXIS_VIEW_BOTTOM] = [input.KEY_NUM_6];
95382
- break;
95497
+ /**
95498
+ * Sets the HTMl element to represent the pivot point when {@link CameraControl#followPointer} is true.
95499
+ *
95500
+ * See class comments for an example.
95501
+ *
95502
+ * @param {HTMLElement} element HTML element representing the pivot point.
95503
+ */
95504
+ set pivotElement(element) {
95505
+ this._controllers.pivotController.setPivotElement(element);
95506
+ }
95383
95507
 
95384
- case "azerty":
95385
- keyMap[this.PAN_LEFT] = [input.KEY_Q];
95386
- keyMap[this.PAN_RIGHT] = [input.KEY_D];
95387
- keyMap[this.PAN_UP] = [input.KEY_W];
95388
- keyMap[this.PAN_DOWN] = [input.KEY_X];
95389
- keyMap[this.PAN_BACKWARDS] = [];
95390
- keyMap[this.PAN_FORWARDS] = [];
95391
- keyMap[this.DOLLY_FORWARDS] = [input.KEY_Z, input.KEY_ADD];
95392
- keyMap[this.DOLLY_BACKWARDS] = [input.KEY_S, input.KEY_SUBTRACT];
95393
- keyMap[this.ROTATE_X_POS] = [input.KEY_DOWN_ARROW];
95394
- keyMap[this.ROTATE_X_NEG] = [input.KEY_UP_ARROW];
95395
- keyMap[this.ROTATE_Y_POS] = [input.KEY_A, input.KEY_LEFT_ARROW];
95396
- keyMap[this.ROTATE_Y_NEG] = [input.KEY_E, input.KEY_RIGHT_ARROW];
95397
- keyMap[this.AXIS_VIEW_RIGHT] = [input.KEY_NUM_1];
95398
- keyMap[this.AXIS_VIEW_BACK] = [input.KEY_NUM_2];
95399
- keyMap[this.AXIS_VIEW_LEFT] = [input.KEY_NUM_3];
95400
- keyMap[this.AXIS_VIEW_FRONT] = [input.KEY_NUM_4];
95401
- keyMap[this.AXIS_VIEW_TOP] = [input.KEY_NUM_5];
95402
- keyMap[this.AXIS_VIEW_BOTTOM] = [input.KEY_NUM_6];
95403
- break;
95404
- }
95508
+ /**
95509
+ * Sets if this ````CameraControl```` is active or not.
95510
+ *
95511
+ * When inactive, the ````CameraControl```` will not react to input.
95512
+ *
95513
+ * Default is ````true````.
95514
+ *
95515
+ * @param {Boolean} value Set ````true```` to activate this ````CameraControl````.
95516
+ */
95517
+ set active(value) {
95518
+ value = value !== false;
95519
+ this._configs.active = value;
95520
+ this._handlers[1]._active = value;
95521
+ this._handlers[5]._active = value;
95522
+ }
95405
95523
 
95406
- this._keyMap = keyMap;
95407
- } else {
95408
- const keyMap = value;
95409
- this._keyMap = keyMap;
95410
- }
95411
- }
95524
+ /**
95525
+ * Gets if this ````CameraControl```` is active or not.
95526
+ *
95527
+ * When inactive, the ````CameraControl```` will not react to input.
95528
+ *
95529
+ * Default is ````true````.
95530
+ *
95531
+ * @returns {Boolean} Returns ````true```` if this ````CameraControl```` is active.
95532
+ */
95533
+ get active() {
95534
+ return this._configs.active;
95535
+ }
95412
95536
 
95413
- /**
95414
- * Gets custom mappings of keys to {@link CameraControl} actions.
95415
- *
95416
- * @returns {{Number:Number}} Current key mappings.
95417
- */
95418
- get keyMap() {
95419
- return this._keyMap;
95420
- }
95537
+ /**
95538
+ * Sets whether the pointer snap to vertex.
95539
+ *
95540
+ * @param {boolean} snapToVertex
95541
+ */
95542
+ set snapToVertex(snapToVertex) {
95543
+ this._configs.snapToVertex = !!snapToVertex;
95544
+ }
95421
95545
 
95422
- /**
95423
- * Returns true if any keys configured for the given action are down.
95424
- * @param action
95425
- * @param keyDownMap
95426
- * @private
95427
- */
95428
- _isKeyDownForAction(action, keyDownMap) {
95429
- const keys = this._keyMap[action];
95430
- if (!keys) {
95431
- return false;
95432
- }
95433
- if (!keyDownMap) {
95434
- keyDownMap = this.scene.input.keyDown;
95435
- }
95436
- for (let i = 0, len = keys.length; i < len; i++) {
95437
- const key = keys[i];
95438
- if (keyDownMap[key]) {
95439
- return true;
95440
- }
95441
- }
95442
- return false;
95443
- }
95546
+ /**
95547
+ * Gets whether the pointer snap to vertex.
95548
+ *
95549
+ * @returns {boolean}
95550
+ */
95551
+ get snapToVertex() {
95552
+ return this._configs.snapToVertex;
95553
+ }
95444
95554
 
95445
- /**
95446
- * Sets the HTMl element to represent the pivot point when {@link CameraControl#followPointer} is true.
95447
- *
95448
- * See class comments for an example.
95449
- *
95450
- * @param {HTMLElement} element HTML element representing the pivot point.
95451
- */
95452
- set pivotElement(element) {
95453
- this._controllers.pivotController.setPivotElement(element);
95454
- }
95555
+ /**
95556
+ * Sets whether the pointer snap to edge.
95557
+ *
95558
+ * @param {boolean} snapToEdge
95559
+ */
95560
+ set snapToEdge(snapToEdge) {
95561
+ this._configs.snapToEdge = !!snapToEdge;
95562
+ }
95455
95563
 
95456
- /**
95457
- * Sets if this ````CameraControl```` is active or not.
95458
- *
95459
- * When inactive, the ````CameraControl```` will not react to input.
95460
- *
95461
- * Default is ````true````.
95462
- *
95463
- * @param {Boolean} value Set ````true```` to activate this ````CameraControl````.
95464
- */
95465
- set active(value) {
95466
- value = value !== false;
95467
- this._configs.active = value;
95468
- this._handlers[1]._active = value;
95469
- this._handlers[5]._active = value;
95470
- }
95564
+ /**
95565
+ * Gets whether the pointer snap to edge.
95566
+ *
95567
+ * @returns {boolean}
95568
+ */
95569
+ get snapToEdge() {
95570
+ return this._configs.snapToEdge;
95571
+ }
95471
95572
 
95472
- /**
95473
- * Gets if this ````CameraControl```` is active or not.
95474
- *
95475
- * When inactive, the ````CameraControl```` will not react to input.
95476
- *
95477
- * Default is ````true````.
95478
- *
95479
- * @returns {Boolean} Returns ````true```` if this ````CameraControl```` is active.
95480
- */
95481
- get active() {
95482
- return this._configs.active;
95483
- }
95573
+ /**
95574
+ * Sets the current snap radius for "hoverSnapOrSurface" events, to specify whether the radius
95575
+ * within which the pointer snaps to the nearest vertex or the nearest edge.
95576
+ *
95577
+ * Default value is 30 pixels.
95578
+ *
95579
+ * @param {Number} snapRadius The snap radius.
95580
+ */
95581
+ set snapRadius(snapRadius) {
95582
+ snapRadius = snapRadius || DEFAULT_SNAP_PICK_RADIUS;
95583
+ this._configs.snapRadius = snapRadius;
95584
+ }
95484
95585
 
95485
- /**
95486
- * Sets whether the pointer snap to vertex.
95487
- *
95488
- * @param {boolean} snapToVertex
95489
- */
95490
- set snapToVertex(snapToVertex) {
95491
- this._configs.snapToVertex = !!snapToVertex;
95492
- }
95586
+ /**
95587
+ * Gets the current snap radius.
95588
+ *
95589
+ * @returns {Number} The snap radius.
95590
+ */
95591
+ get snapRadius() {
95592
+ return this._configs.snapRadius;
95593
+ }
95493
95594
 
95494
- /**
95495
- * Gets whether the pointer snap to vertex.
95496
- *
95497
- * @returns {boolean}
95498
- */
95499
- get snapToVertex() {
95500
- return this._configs.snapToVertex;
95501
- }
95595
+ /**
95596
+ * Sets the current navigation mode.
95597
+ *
95598
+ * Accepted values are:
95599
+ *
95600
+ * * "orbit" - rotation orbits about the current target or pivot point,
95601
+ * * "firstPerson" - rotation is about the current eye position,
95602
+ * * "planView" - rotation is disabled.
95603
+ *
95604
+ * See class comments for more info.
95605
+ *
95606
+ * @param {String} navMode The navigation mode: "orbit", "firstPerson" or "planView".
95607
+ */
95608
+ set navMode(navMode) {
95609
+ navMode = navMode || "orbit";
95610
+ if (navMode !== "firstPerson" && navMode !== "orbit" && navMode !== "planView") {
95611
+ this.error(
95612
+ "Unsupported value for navMode: " +
95613
+ navMode +
95614
+ " - supported values are 'orbit', 'firstPerson' and 'planView' - defaulting to 'orbit'"
95615
+ );
95616
+ navMode = "orbit";
95617
+ }
95618
+ this._configs.firstPerson = navMode === "firstPerson";
95619
+ this._configs.planView = navMode === "planView";
95620
+ if (this._configs.firstPerson || this._configs.planView) {
95621
+ this._controllers.pivotController.hidePivot();
95622
+ this._controllers.pivotController.endPivot();
95623
+ }
95624
+ this._configs.navMode = navMode;
95625
+ }
95502
95626
 
95503
- /**
95504
- * Sets whether the pointer snap to edge.
95505
- *
95506
- * @param {boolean} snapToEdge
95507
- */
95508
- set snapToEdge(snapToEdge) {
95509
- this._configs.snapToEdge = !!snapToEdge;
95510
- }
95627
+ /**
95628
+ * Gets the current navigation mode.
95629
+ *
95630
+ * @returns {String} The navigation mode: "orbit", "firstPerson" or "planView".
95631
+ */
95632
+ get navMode() {
95633
+ return this._configs.navMode;
95634
+ }
95511
95635
 
95512
- /**
95513
- * Gets whether the pointer snap to edge.
95514
- *
95515
- * @returns {boolean}
95516
- */
95517
- get snapToEdge() {
95518
- return this._configs.snapToEdge;
95519
- }
95636
+ /**
95637
+ * Sets whether mouse and touch input is enabled.
95638
+ *
95639
+ * Default is ````true````.
95640
+ *
95641
+ * Disabling mouse and touch input on ````CameraControl```` is useful when we want to temporarily use mouse or
95642
+ * touch input to interact with some other 3D control, without disturbing the {@link Camera}.
95643
+ *
95644
+ * @param {Boolean} value Set ````true```` to enable mouse and touch input.
95645
+ */
95646
+ set pointerEnabled(value) {
95647
+ this._reset();
95648
+ this._configs.pointerEnabled = !!value;
95649
+ }
95520
95650
 
95521
- /**
95522
- * Sets the current snap radius for "hoverSnapOrSurface" events, to specify whether the radius
95523
- * within which the pointer snaps to the nearest vertex or the nearest edge.
95524
- *
95525
- * Default value is 30 pixels.
95526
- *
95527
- * @param {Number} snapRadius The snap radius.
95528
- */
95529
- set snapRadius(snapRadius) {
95530
- snapRadius = snapRadius || DEFAULT_SNAP_PICK_RADIUS;
95531
- this._configs.snapRadius = snapRadius;
95532
- }
95651
+ _reset() {
95652
+ for (let i = 0, len = this._handlers.length; i < len; i++) {
95653
+ const handler = this._handlers[i];
95654
+ if (handler.reset) {
95655
+ handler.reset();
95656
+ }
95657
+ }
95533
95658
 
95534
- /**
95535
- * Gets the current snap radius.
95536
- *
95537
- * @returns {Number} The snap radius.
95538
- */
95539
- get snapRadius() {
95540
- return this._configs.snapRadius;
95541
- }
95542
-
95543
- /**
95544
- * Sets the current navigation mode.
95545
- *
95546
- * Accepted values are:
95547
- *
95548
- * * "orbit" - rotation orbits about the current target or pivot point,
95549
- * * "firstPerson" - rotation is about the current eye position,
95550
- * * "planView" - rotation is disabled.
95551
- *
95552
- * See class comments for more info.
95553
- *
95554
- * @param {String} navMode The navigation mode: "orbit", "firstPerson" or "planView".
95555
- */
95556
- set navMode(navMode) {
95557
- navMode = navMode || "orbit";
95558
- if (navMode !== "firstPerson" && navMode !== "orbit" && navMode !== "planView") {
95559
- this.error("Unsupported value for navMode: " + navMode + " - supported values are 'orbit', 'firstPerson' and 'planView' - defaulting to 'orbit'");
95560
- navMode = "orbit";
95561
- }
95562
- this._configs.firstPerson = (navMode === "firstPerson");
95563
- this._configs.planView = (navMode === "planView");
95564
- if (this._configs.firstPerson || this._configs.planView) {
95565
- this._controllers.pivotController.hidePivot();
95566
- this._controllers.pivotController.endPivot();
95567
- }
95568
- this._configs.navMode = navMode;
95569
- }
95570
-
95571
- /**
95572
- * Gets the current navigation mode.
95573
- *
95574
- * @returns {String} The navigation mode: "orbit", "firstPerson" or "planView".
95575
- */
95576
- get navMode() {
95577
- return this._configs.navMode;
95578
- }
95579
-
95580
- /**
95581
- * Sets whether mouse and touch input is enabled.
95582
- *
95583
- * Default is ````true````.
95584
- *
95585
- * Disabling mouse and touch input on ````CameraControl```` is useful when we want to temporarily use mouse or
95586
- * touch input to interact with some other 3D control, without disturbing the {@link Camera}.
95587
- *
95588
- * @param {Boolean} value Set ````true```` to enable mouse and touch input.
95589
- */
95590
- set pointerEnabled(value) {
95591
- this._reset();
95592
- this._configs.pointerEnabled = !!value;
95593
- }
95594
-
95595
- _reset() {
95596
- for (let i = 0, len = this._handlers.length; i < len; i++) {
95597
- const handler = this._handlers[i];
95598
- if (handler.reset) {
95599
- handler.reset();
95600
- }
95601
- }
95602
-
95603
- this._updates.panDeltaX = 0;
95604
- this._updates.panDeltaY = 0;
95605
- this._updates.rotateDeltaX = 0;
95606
- this._updates.rotateDeltaY = 0;
95607
- this._updates.dolyDelta = 0;
95608
- }
95659
+ this._updates.panDeltaX = 0;
95660
+ this._updates.panDeltaY = 0;
95661
+ this._updates.rotateDeltaX = 0;
95662
+ this._updates.rotateDeltaY = 0;
95663
+ this._updates.dolyDelta = 0;
95664
+ }
95609
95665
 
95610
- /**
95611
- * Gets whether mouse and touch input is enabled.
95612
- *
95613
- * Default is ````true````.
95614
- *
95615
- * Disabling mouse and touch input on ````CameraControl```` is desirable when we want to temporarily use mouse or
95616
- * touch input to interact with some other 3D control, without interfering with the {@link Camera}.
95617
- *
95618
- * @returns {Boolean} Returns ````true```` if mouse and touch input is enabled.
95619
- */
95620
- get pointerEnabled() {
95621
- return this._configs.pointerEnabled;
95622
- }
95666
+ /**
95667
+ * Gets whether mouse and touch input is enabled.
95668
+ *
95669
+ * Default is ````true````.
95670
+ *
95671
+ * Disabling mouse and touch input on ````CameraControl```` is desirable when we want to temporarily use mouse or
95672
+ * touch input to interact with some other 3D control, without interfering with the {@link Camera}.
95673
+ *
95674
+ * @returns {Boolean} Returns ````true```` if mouse and touch input is enabled.
95675
+ */
95676
+ get pointerEnabled() {
95677
+ return this._configs.pointerEnabled;
95678
+ }
95623
95679
 
95624
- /**
95625
- * Sets whether the {@link Camera} follows the mouse/touch pointer.
95626
- *
95627
- * In orbiting mode, the Camera will orbit about the pointer, and will dolly to and from the pointer.
95628
- *
95629
- * In fly-to mode, the Camera will dolly to and from the pointer, however the World will always rotate about the Camera position.
95630
- *
95631
- * In plan-view mode, the Camera will dolly to and from the pointer, however the Camera will not rotate.
95632
- *
95633
- * Default is ````true````.
95634
- *
95635
- * See class comments for more info.
95636
- *
95637
- * @param {Boolean} value Set ````true```` to enable the Camera to follow the pointer.
95638
- */
95639
- set followPointer(value) {
95640
- this._configs.followPointer = (value !== false);
95641
- }
95680
+ /**
95681
+ * Sets whether the {@link Camera} follows the mouse/touch pointer.
95682
+ *
95683
+ * In orbiting mode, the Camera will orbit about the pointer, and will dolly to and from the pointer.
95684
+ *
95685
+ * In fly-to mode, the Camera will dolly to and from the pointer, however the World will always rotate about the Camera position.
95686
+ *
95687
+ * In plan-view mode, the Camera will dolly to and from the pointer, however the Camera will not rotate.
95688
+ *
95689
+ * Default is ````true````.
95690
+ *
95691
+ * See class comments for more info.
95692
+ *
95693
+ * @param {Boolean} value Set ````true```` to enable the Camera to follow the pointer.
95694
+ */
95695
+ set followPointer(value) {
95696
+ this._configs.followPointer = value !== false;
95697
+ }
95642
95698
 
95643
- /**
95644
- * Sets whether the {@link Camera} follows the mouse/touch pointer.
95645
- *
95646
- * In orbiting mode, the Camera will orbit about the pointer, and will dolly to and from the pointer.
95647
- *
95648
- * In fly-to mode, the Camera will dolly to and from the pointer, however the World will always rotate about the Camera position.
95649
- *
95650
- * In plan-view mode, the Camera will dolly to and from the pointer, however the Camera will not rotate.
95651
- *
95652
- * Default is ````true````.
95653
- *
95654
- * See class comments for more info.
95655
- *
95656
- * @returns {Boolean} Returns ````true```` if the Camera follows the pointer.
95657
- */
95658
- get followPointer() {
95659
- return this._configs.followPointer;
95660
- }
95699
+ /**
95700
+ * Sets whether the {@link Camera} follows the mouse/touch pointer.
95701
+ *
95702
+ * In orbiting mode, the Camera will orbit about the pointer, and will dolly to and from the pointer.
95703
+ *
95704
+ * In fly-to mode, the Camera will dolly to and from the pointer, however the World will always rotate about the Camera position.
95705
+ *
95706
+ * In plan-view mode, the Camera will dolly to and from the pointer, however the Camera will not rotate.
95707
+ *
95708
+ * Default is ````true````.
95709
+ *
95710
+ * See class comments for more info.
95711
+ *
95712
+ * @returns {Boolean} Returns ````true```` if the Camera follows the pointer.
95713
+ */
95714
+ get followPointer() {
95715
+ return this._configs.followPointer;
95716
+ }
95661
95717
 
95662
- /**
95663
- * Sets the current World-space 3D target position.
95664
- *
95665
- * Only applies when {@link CameraControl#followPointer} is ````true````.
95666
- *
95667
- * @param {Number[]} worldPos The new World-space 3D target position.
95668
- */
95669
- set pivotPos(worldPos) {
95670
- this._controllers.pivotController.setPivotPos(worldPos);
95671
- }
95718
+ /**
95719
+ * Sets the current World-space 3D target position.
95720
+ *
95721
+ * Only applies when {@link CameraControl#followPointer} is ````true````.
95722
+ *
95723
+ * @param {Number[]} worldPos The new World-space 3D target position.
95724
+ */
95725
+ set pivotPos(worldPos) {
95726
+ this._controllers.pivotController.setPivotPos(worldPos);
95727
+ }
95672
95728
 
95673
- /**
95674
- * Gets the current World-space 3D pivot position.
95675
- *
95676
- * Only applies when {@link CameraControl#followPointer} is ````true````.
95677
- *
95678
- * @return {Number[]} worldPos The current World-space 3D pivot position.
95679
- */
95680
- get pivotPos() {
95681
- return this._controllers.pivotController.getPivotPos();
95682
- }
95729
+ /**
95730
+ * Gets the current World-space 3D pivot position.
95731
+ *
95732
+ * Only applies when {@link CameraControl#followPointer} is ````true````.
95733
+ *
95734
+ * @return {Number[]} worldPos The current World-space 3D pivot position.
95735
+ */
95736
+ get pivotPos() {
95737
+ return this._controllers.pivotController.getPivotPos();
95738
+ }
95683
95739
 
95684
- /**
95685
- * @deprecated
95686
- * @param {Boolean} value Set ````true```` to enable dolly-to-pointer behaviour.
95687
- */
95688
- set dollyToPointer(value) {
95689
- this.warn("dollyToPointer property is deprecated - replaced with followPointer");
95690
- this.followPointer = value;
95691
- }
95740
+ /**
95741
+ * @deprecated
95742
+ * @param {Boolean} value Set ````true```` to enable dolly-to-pointer behaviour.
95743
+ */
95744
+ set dollyToPointer(value) {
95745
+ this.warn("dollyToPointer property is deprecated - replaced with followPointer");
95746
+ this.followPointer = value;
95747
+ }
95692
95748
 
95693
- /**
95694
- * @deprecated
95695
- * @returns {Boolean} Returns ````true```` if dolly-to-pointer behaviour is enabled.
95696
- */
95697
- get dollyToPointer() {
95698
- this.warn("dollyToPointer property is deprecated - replaced with followPointer");
95699
- return this.followPointer;
95700
- }
95749
+ /**
95750
+ * @deprecated
95751
+ * @returns {Boolean} Returns ````true```` if dolly-to-pointer behaviour is enabled.
95752
+ */
95753
+ get dollyToPointer() {
95754
+ this.warn("dollyToPointer property is deprecated - replaced with followPointer");
95755
+ return this.followPointer;
95756
+ }
95701
95757
 
95702
- /**
95703
- * @deprecated
95704
- * @param {Boolean} value Set ````true```` to enable dolly-to-pointer behaviour.
95705
- */
95706
- set panToPointer(value) {
95707
- this.warn("panToPointer property is deprecated - replaced with followPointer");
95708
- }
95758
+ /**
95759
+ * @deprecated
95760
+ * @param {Boolean} value Set ````true```` to enable dolly-to-pointer behaviour.
95761
+ */
95762
+ set panToPointer(value) {
95763
+ this.warn("panToPointer property is deprecated - replaced with followPointer");
95764
+ }
95709
95765
 
95710
- /**
95711
- * @deprecated
95712
- * @returns {Boolean} Returns ````true```` if dolly-to-pointer behaviour is enabled.
95713
- */
95714
- get panToPointer() {
95715
- this.warn("panToPointer property is deprecated - replaced with followPointer");
95716
- return false;
95717
- }
95766
+ /**
95767
+ * @deprecated
95768
+ * @returns {Boolean} Returns ````true```` if dolly-to-pointer behaviour is enabled.
95769
+ */
95770
+ get panToPointer() {
95771
+ this.warn("panToPointer property is deprecated - replaced with followPointer");
95772
+ return false;
95773
+ }
95718
95774
 
95719
- /**
95720
- * Sets whether this ````CameraControl```` is in plan-view mode.
95721
- *
95722
- * When in plan-view mode, rotation is disabled.
95723
- *
95724
- * Default is ````false````.
95725
- *
95726
- * Deprecated - use {@link CameraControl#navMode} instead.
95727
- *
95728
- * @param {Boolean} value Set ````true```` to enable plan-view mode.
95729
- * @deprecated
95730
- */
95731
- set planView(value) {
95732
- this._configs.planView = !!value;
95733
- this._configs.firstPerson = false;
95734
- if (this._configs.planView) {
95735
- this._controllers.pivotController.hidePivot();
95736
- this._controllers.pivotController.endPivot();
95737
- }
95738
- this.warn("planView property is deprecated - replaced with navMode");
95739
- }
95775
+ /**
95776
+ * Sets whether this ````CameraControl```` is in plan-view mode.
95777
+ *
95778
+ * When in plan-view mode, rotation is disabled.
95779
+ *
95780
+ * Default is ````false````.
95781
+ *
95782
+ * Deprecated - use {@link CameraControl#navMode} instead.
95783
+ *
95784
+ * @param {Boolean} value Set ````true```` to enable plan-view mode.
95785
+ * @deprecated
95786
+ */
95787
+ set planView(value) {
95788
+ this._configs.planView = !!value;
95789
+ this._configs.firstPerson = false;
95790
+ if (this._configs.planView) {
95791
+ this._controllers.pivotController.hidePivot();
95792
+ this._controllers.pivotController.endPivot();
95793
+ }
95794
+ this.warn("planView property is deprecated - replaced with navMode");
95795
+ }
95740
95796
 
95741
- /**
95742
- * Gets whether this ````CameraControl```` is in plan-view mode.
95743
- *
95744
- * When in plan-view mode, rotation is disabled.
95745
- *
95746
- * Default is ````false````.
95747
- *
95748
- * Deprecated - use {@link CameraControl#navMode} instead.
95749
- *
95750
- * @returns {Boolean} Returns ````true```` if plan-view mode is enabled.
95751
- * @deprecated
95752
- */
95753
- get planView() {
95754
- this.warn("planView property is deprecated - replaced with navMode");
95755
- return this._configs.planView;
95756
- }
95797
+ /**
95798
+ * Gets whether this ````CameraControl```` is in plan-view mode.
95799
+ *
95800
+ * When in plan-view mode, rotation is disabled.
95801
+ *
95802
+ * Default is ````false````.
95803
+ *
95804
+ * Deprecated - use {@link CameraControl#navMode} instead.
95805
+ *
95806
+ * @returns {Boolean} Returns ````true```` if plan-view mode is enabled.
95807
+ * @deprecated
95808
+ */
95809
+ get planView() {
95810
+ this.warn("planView property is deprecated - replaced with navMode");
95811
+ return this._configs.planView;
95812
+ }
95757
95813
 
95758
- /**
95759
- * Sets whether this ````CameraControl```` is in first-person mode.
95760
- *
95761
- * In "first person" mode (disabled by default) the look position rotates about the eye position. Otherwise, {@link Camera#eye} rotates about {@link Camera#look}.
95762
- *
95763
- * Default is ````false````.
95764
- *
95765
- * Deprecated - use {@link CameraControl#navMode} instead.
95766
- *
95767
- * @param {Boolean} value Set ````true```` to enable first-person mode.
95768
- * @deprecated
95769
- */
95770
- set firstPerson(value) {
95771
- this.warn("firstPerson property is deprecated - replaced with navMode");
95772
- this._configs.firstPerson = !!value;
95773
- this._configs.planView = false;
95774
- if (this._configs.firstPerson) {
95775
- this._controllers.pivotController.hidePivot();
95776
- this._controllers.pivotController.endPivot();
95777
- }
95778
- }
95814
+ /**
95815
+ * Sets whether this ````CameraControl```` is in first-person mode.
95816
+ *
95817
+ * In "first person" mode (disabled by default) the look position rotates about the eye position. Otherwise, {@link Camera#eye} rotates about {@link Camera#look}.
95818
+ *
95819
+ * Default is ````false````.
95820
+ *
95821
+ * Deprecated - use {@link CameraControl#navMode} instead.
95822
+ *
95823
+ * @param {Boolean} value Set ````true```` to enable first-person mode.
95824
+ * @deprecated
95825
+ */
95826
+ set firstPerson(value) {
95827
+ this.warn("firstPerson property is deprecated - replaced with navMode");
95828
+ this._configs.firstPerson = !!value;
95829
+ this._configs.planView = false;
95830
+ if (this._configs.firstPerson) {
95831
+ this._controllers.pivotController.hidePivot();
95832
+ this._controllers.pivotController.endPivot();
95833
+ }
95834
+ }
95779
95835
 
95780
- /**
95781
- * Gets whether this ````CameraControl```` is in first-person mode.
95782
- *
95783
- * In "first person" mode (disabled by default) the look position rotates about the eye position. Otherwise, {@link Camera#eye} rotates about {@link Camera#look}.
95784
- *
95785
- * Default is ````false````.
95786
- *
95787
- * Deprecated - use {@link CameraControl#navMode} instead.
95788
- *
95789
- * @returns {Boolean} Returns ````true```` if first-person mode is enabled.
95790
- * @deprecated
95791
- */
95792
- get firstPerson() {
95793
- this.warn("firstPerson property is deprecated - replaced with navMode");
95794
- return this._configs.firstPerson;
95795
- }
95836
+ /**
95837
+ * Gets whether this ````CameraControl```` is in first-person mode.
95838
+ *
95839
+ * In "first person" mode (disabled by default) the look position rotates about the eye position. Otherwise, {@link Camera#eye} rotates about {@link Camera#look}.
95840
+ *
95841
+ * Default is ````false````.
95842
+ *
95843
+ * Deprecated - use {@link CameraControl#navMode} instead.
95844
+ *
95845
+ * @returns {Boolean} Returns ````true```` if first-person mode is enabled.
95846
+ * @deprecated
95847
+ */
95848
+ get firstPerson() {
95849
+ this.warn("firstPerson property is deprecated - replaced with navMode");
95850
+ return this._configs.firstPerson;
95851
+ }
95796
95852
 
95797
- /**
95798
- * Sets whether to vertically constrain the {@link Camera} position for first-person navigation.
95799
- *
95800
- * When set ````true````, this constrains {@link Camera#eye} to its current vertical position.
95801
- *
95802
- * Only applies when {@link CameraControl#navMode} is ````"firstPerson"````.
95803
- *
95804
- * Default is ````false````.
95805
- *
95806
- * @param {Boolean} value Set ````true```` to vertically constrain the Camera.
95807
- */
95808
- set constrainVertical(value) {
95809
- this._configs.constrainVertical = !!value;
95810
- }
95853
+ /**
95854
+ * Sets whether to vertically constrain the {@link Camera} position for first-person navigation.
95855
+ *
95856
+ * When set ````true````, this constrains {@link Camera#eye} to its current vertical position.
95857
+ *
95858
+ * Only applies when {@link CameraControl#navMode} is ````"firstPerson"````.
95859
+ *
95860
+ * Default is ````false````.
95861
+ *
95862
+ * @param {Boolean} value Set ````true```` to vertically constrain the Camera.
95863
+ */
95864
+ set constrainVertical(value) {
95865
+ this._configs.constrainVertical = !!value;
95866
+ }
95811
95867
 
95812
- /**
95813
- * Gets whether to vertically constrain the {@link Camera} position for first-person navigation.
95814
- *
95815
- * When set ````true````, this constrains {@link Camera#eye} to its current vertical position.
95816
- *
95817
- * Only applies when {@link CameraControl#navMode} is ````"firstPerson"````.
95818
- *
95819
- * Default is ````false````.
95820
- *
95821
- * @returns {Boolean} ````true```` when Camera is vertically constrained.
95822
- */
95823
- get constrainVertical() {
95824
- return this._configs.constrainVertical;
95825
- }
95868
+ /**
95869
+ * Gets whether to vertically constrain the {@link Camera} position for first-person navigation.
95870
+ *
95871
+ * When set ````true````, this constrains {@link Camera#eye} to its current vertical position.
95872
+ *
95873
+ * Only applies when {@link CameraControl#navMode} is ````"firstPerson"````.
95874
+ *
95875
+ * Default is ````false````.
95876
+ *
95877
+ * @returns {Boolean} ````true```` when Camera is vertically constrained.
95878
+ */
95879
+ get constrainVertical() {
95880
+ return this._configs.constrainVertical;
95881
+ }
95826
95882
 
95827
- /**
95828
- * Sets whether double-picking an {@link Entity} causes the {@link Camera} to fly to its boundary.
95829
- *
95830
- * Default is ````false````.
95831
- *
95832
- * @param {Boolean} value Set ````true```` to enable double-pick-fly-to mode.
95833
- */
95834
- set doublePickFlyTo(value) {
95835
- this._configs.doublePickFlyTo = value !== false;
95836
- }
95883
+ /**
95884
+ * Sets whether double-picking an {@link Entity} causes the {@link Camera} to fly to its boundary.
95885
+ *
95886
+ * Default is ````false````.
95887
+ *
95888
+ * @param {Boolean} value Set ````true```` to enable double-pick-fly-to mode.
95889
+ */
95890
+ set doublePickFlyTo(value) {
95891
+ this._configs.doublePickFlyTo = value !== false;
95892
+ }
95837
95893
 
95838
- /**
95839
- * Gets whether double-picking an {@link Entity} causes the {@link Camera} to fly to its boundary.
95840
- *
95841
- * Default is ````false````.
95842
- *
95843
- * @returns {Boolean} Returns ````true```` when double-pick-fly-to mode is enabled.
95844
- */
95845
- get doublePickFlyTo() {
95846
- return this._configs.doublePickFlyTo;
95847
- }
95894
+ /**
95895
+ * Gets whether double-picking an {@link Entity} causes the {@link Camera} to fly to its boundary.
95896
+ *
95897
+ * Default is ````false````.
95898
+ *
95899
+ * @returns {Boolean} Returns ````true```` when double-pick-fly-to mode is enabled.
95900
+ */
95901
+ get doublePickFlyTo() {
95902
+ return this._configs.doublePickFlyTo;
95903
+ }
95848
95904
 
95849
- /**
95850
- * Sets whether either right-clicking (true) or middle-clicking (false) pans the {@link Camera}.
95851
- *
95852
- * Default is ````true````.
95853
- *
95854
- * @param {Boolean} value Set ````false```` to disable pan on right-click.
95855
- */
95856
- set panRightClick(value) {
95857
- this._configs.panRightClick = value !== false;
95858
- }
95905
+ /**
95906
+ * Sets whether either right-clicking (true) or middle-clicking (false) pans the {@link Camera}.
95907
+ *
95908
+ * Default is ````true````.
95909
+ *
95910
+ * @param {Boolean} value Set ````false```` to disable pan on right-click.
95911
+ */
95912
+ set panRightClick(value) {
95913
+ this._configs.panRightClick = value !== false;
95914
+ }
95859
95915
 
95860
- /**
95861
- * Gets whether right-clicking pans the {@link Camera}.
95862
- *
95863
- * Default is ````true````.
95864
- *
95865
- * @returns {Boolean} Returns ````false```` when pan on right-click is disabled.
95866
- */
95867
- get panRightClick() {
95868
- return this._configs.panRightClick;
95869
- }
95916
+ /**
95917
+ * Gets whether right-clicking pans the {@link Camera}.
95918
+ *
95919
+ * Default is ````true````.
95920
+ *
95921
+ * @returns {Boolean} Returns ````false```` when pan on right-click is disabled.
95922
+ */
95923
+ get panRightClick() {
95924
+ return this._configs.panRightClick;
95925
+ }
95870
95926
 
95871
- /**
95872
- * Sets a factor in range ````[0..1]```` indicating how much the {@link Camera} keeps moving after you finish rotating it.
95873
- *
95874
- * A value of ````0.0```` causes it to immediately stop, ````0.5```` causes its movement to decay 50% on each tick,
95875
- * while ````1.0```` causes no decay, allowing it continue moving, by the current rate of rotation.
95876
- *
95877
- * You may choose an inertia of zero when you want be able to precisely rotate the Camera,
95878
- * without interference from inertia. Zero inertia can also mean that less frames are rendered while
95879
- * you are rotating the Camera.
95880
- *
95881
- * Default is ````0.0````.
95882
- *
95883
- * Does not apply when {@link CameraControl#navMode} is ````"planView"````, which disallows rotation.
95884
- *
95885
- * @param {Number} rotationInertia New inertial factor.
95886
- */
95887
- set rotationInertia(rotationInertia) {
95888
- this._configs.rotationInertia = (rotationInertia !== undefined && rotationInertia !== null) ? rotationInertia : 0.0;
95889
- }
95927
+ /**
95928
+ * Sets a factor in range ````[0..1]```` indicating how much the {@link Camera} keeps moving after you finish rotating it.
95929
+ *
95930
+ * A value of ````0.0```` causes it to immediately stop, ````0.5```` causes its movement to decay 50% on each tick,
95931
+ * while ````1.0```` causes no decay, allowing it continue moving, by the current rate of rotation.
95932
+ *
95933
+ * You may choose an inertia of zero when you want be able to precisely rotate the Camera,
95934
+ * without interference from inertia. Zero inertia can also mean that less frames are rendered while
95935
+ * you are rotating the Camera.
95936
+ *
95937
+ * Default is ````0.0````.
95938
+ *
95939
+ * Does not apply when {@link CameraControl#navMode} is ````"planView"````, which disallows rotation.
95940
+ *
95941
+ * @param {Number} rotationInertia New inertial factor.
95942
+ */
95943
+ set rotationInertia(rotationInertia) {
95944
+ this._configs.rotationInertia = rotationInertia !== undefined && rotationInertia !== null ? rotationInertia : 0.0;
95945
+ }
95890
95946
 
95891
- /**
95892
- * Gets the rotation inertia factor.
95893
- *
95894
- * Default is ````0.0````.
95895
- *
95896
- * Does not apply when {@link CameraControl#navMode} is ````"planView"````, which disallows rotation.
95897
- *
95898
- * @returns {Number} The inertia factor.
95899
- */
95900
- get rotationInertia() {
95901
- return this._configs.rotationInertia;
95902
- }
95947
+ /**
95948
+ * Gets the rotation inertia factor.
95949
+ *
95950
+ * Default is ````0.0````.
95951
+ *
95952
+ * Does not apply when {@link CameraControl#navMode} is ````"planView"````, which disallows rotation.
95953
+ *
95954
+ * @returns {Number} The inertia factor.
95955
+ */
95956
+ get rotationInertia() {
95957
+ return this._configs.rotationInertia;
95958
+ }
95903
95959
 
95904
- /**
95905
- * Sets how much the {@link Camera} pans each second with keyboard input.
95906
- *
95907
- * Default is ````5.0````, to pan the Camera ````5.0```` World-space units every second that
95908
- * a panning key is depressed. See the ````CameraControl```` class documentation for which keys control
95909
- * panning.
95910
- *
95911
- * Panning direction is aligned to our Camera's orientation. When we pan horizontally, we pan
95912
- * to our left and right, when we pan vertically, we pan upwards and downwards, and when we pan forwards
95913
- * and backwards, we pan along the direction the Camera is pointing.
95914
- *
95915
- * Unlike dollying when {@link followPointer} is ````true````, panning does not follow the pointer.
95916
- *
95917
- * @param {Number} keyboardPanRate The new keyboard pan rate.
95918
- */
95919
- set keyboardPanRate(keyboardPanRate) {
95920
- this._configs.keyboardPanRate = (keyboardPanRate !== null && keyboardPanRate !== undefined) ? keyboardPanRate : 5.0;
95921
- }
95960
+ /**
95961
+ * Sets how much the {@link Camera} pans each second with keyboard input.
95962
+ *
95963
+ * Default is ````5.0````, to pan the Camera ````5.0```` World-space units every second that
95964
+ * a panning key is depressed. See the ````CameraControl```` class documentation for which keys control
95965
+ * panning.
95966
+ *
95967
+ * Panning direction is aligned to our Camera's orientation. When we pan horizontally, we pan
95968
+ * to our left and right, when we pan vertically, we pan upwards and downwards, and when we pan forwards
95969
+ * and backwards, we pan along the direction the Camera is pointing.
95970
+ *
95971
+ * Unlike dollying when {@link followPointer} is ````true````, panning does not follow the pointer.
95972
+ *
95973
+ * @param {Number} keyboardPanRate The new keyboard pan rate.
95974
+ */
95975
+ set keyboardPanRate(keyboardPanRate) {
95976
+ this._configs.keyboardPanRate = keyboardPanRate !== null && keyboardPanRate !== undefined ? keyboardPanRate : 5.0;
95977
+ }
95922
95978
 
95979
+ /**
95980
+ * Sets how fast the camera pans on touch panning
95981
+ *
95982
+ * @param {Number} touchPanRate The new touch pan rate.
95983
+ */
95984
+ set touchPanRate(touchPanRate) {
95985
+ this._configs.touchPanRate = touchPanRate !== null && touchPanRate !== undefined ? touchPanRate : 1.0;
95986
+ }
95923
95987
 
95924
- /**
95925
- * Sets how fast the camera pans on touch panning
95926
- *
95927
- * @param {Number} touchPanRate The new touch pan rate.
95928
- */
95929
- set touchPanRate(touchPanRate) {
95930
- this._configs.touchPanRate = (touchPanRate !== null && touchPanRate !== undefined) ? touchPanRate : 1.0;
95931
- }
95988
+ /**
95989
+ * Gets how fast the {@link Camera} pans on touch panning
95990
+ *
95991
+ * Default is ````1.0````.
95992
+ *
95993
+ * @returns {Number} The current touch pan rate.
95994
+ */
95995
+ get touchPanRate() {
95996
+ return this._configs.touchPanRate;
95997
+ }
95932
95998
 
95933
- /**
95934
- * Gets how fast the {@link Camera} pans on touch panning
95935
- *
95936
- * Default is ````1.0````.
95937
- *
95938
- * @returns {Number} The current touch pan rate.
95939
- */
95940
- get touchPanRate() {
95941
- return this._configs.touchPanRate;
95942
- }
95999
+ /**
96000
+ * Gets how much the {@link Camera} pans each second with keyboard input.
96001
+ *
96002
+ * Default is ````5.0````.
96003
+ *
96004
+ * @returns {Number} The current keyboard pan rate.
96005
+ */
96006
+ get keyboardPanRate() {
96007
+ return this._configs.keyboardPanRate;
96008
+ }
95943
96009
 
95944
- /**
95945
- * Gets how much the {@link Camera} pans each second with keyboard input.
95946
- *
95947
- * Default is ````5.0````.
95948
- *
95949
- * @returns {Number} The current keyboard pan rate.
95950
- */
95951
- get keyboardPanRate() {
95952
- return this._configs.keyboardPanRate;
95953
- }
96010
+ /**
96011
+ * Sets how many degrees per second the {@link Camera} rotates/orbits with keyboard input.
96012
+ *
96013
+ * Default is ````90.0````, to rotate/orbit the Camera ````90.0```` degrees every second that
96014
+ * a rotation key is depressed. See the ````CameraControl```` class documentation for which keys control
96015
+ * rotation/orbit.
96016
+ *
96017
+ * @param {Number} keyboardRotationRate The new keyboard rotation rate.
96018
+ */
96019
+ set keyboardRotationRate(keyboardRotationRate) {
96020
+ this._configs.keyboardRotationRate =
96021
+ keyboardRotationRate !== null && keyboardRotationRate !== undefined ? keyboardRotationRate : 90.0;
96022
+ }
95954
96023
 
95955
- /**
95956
- * Sets how many degrees per second the {@link Camera} rotates/orbits with keyboard input.
95957
- *
95958
- * Default is ````90.0````, to rotate/orbit the Camera ````90.0```` degrees every second that
95959
- * a rotation key is depressed. See the ````CameraControl```` class documentation for which keys control
95960
- * rotation/orbit.
95961
- *
95962
- * @param {Number} keyboardRotationRate The new keyboard rotation rate.
95963
- */
95964
- set keyboardRotationRate(keyboardRotationRate) {
95965
- this._configs.keyboardRotationRate = (keyboardRotationRate !== null && keyboardRotationRate !== undefined) ? keyboardRotationRate : 90.0;
95966
- }
96024
+ /**
96025
+ * Sets how many degrees per second the {@link Camera} rotates/orbits with keyboard input.
96026
+ *
96027
+ * Default is ````90.0````.
96028
+ *
96029
+ * @returns {Number} The current keyboard rotation rate.
96030
+ */
96031
+ get keyboardRotationRate() {
96032
+ return this._configs.keyboardRotationRate;
96033
+ }
95967
96034
 
95968
- /**
95969
- * Sets how many degrees per second the {@link Camera} rotates/orbits with keyboard input.
95970
- *
95971
- * Default is ````90.0````.
95972
- *
95973
- * @returns {Number} The current keyboard rotation rate.
95974
- */
95975
- get keyboardRotationRate() {
95976
- return this._configs.keyboardRotationRate;
95977
- }
96035
+ /**
96036
+ * Sets the current drag rotation rate.
96037
+ *
96038
+ * This configures how many degrees the {@link Camera} rotates/orbits for a full sweep of the canvas by mouse or touch dragging.
96039
+ *
96040
+ * For example, a value of ````360.0```` indicates that the ````Camera```` rotates/orbits ````360.0```` degrees horizontally
96041
+ * when we sweep the entire width of the canvas.
96042
+ *
96043
+ * ````CameraControl```` makes vertical rotation half as sensitive as horizontal rotation, so that we don't tend to
96044
+ * flip upside-down. Therefore, a value of ````360.0```` rotates/orbits the ````Camera```` through ````180.0```` degrees
96045
+ * vertically when we sweep the entire height of the canvas.
96046
+ *
96047
+ * Default is ````360.0````.
96048
+ *
96049
+ * @param {Number} dragRotationRate The new drag rotation rate.
96050
+ */
96051
+ set dragRotationRate(dragRotationRate) {
96052
+ this._configs.dragRotationRate =
96053
+ dragRotationRate !== null && dragRotationRate !== undefined ? dragRotationRate : 360.0;
96054
+ }
95978
96055
 
95979
- /**
95980
- * Sets the current drag rotation rate.
95981
- *
95982
- * This configures how many degrees the {@link Camera} rotates/orbits for a full sweep of the canvas by mouse or touch dragging.
95983
- *
95984
- * For example, a value of ````360.0```` indicates that the ````Camera```` rotates/orbits ````360.0```` degrees horizontally
95985
- * when we sweep the entire width of the canvas.
95986
- *
95987
- * ````CameraControl```` makes vertical rotation half as sensitive as horizontal rotation, so that we don't tend to
95988
- * flip upside-down. Therefore, a value of ````360.0```` rotates/orbits the ````Camera```` through ````180.0```` degrees
95989
- * vertically when we sweep the entire height of the canvas.
95990
- *
95991
- * Default is ````360.0````.
95992
- *
95993
- * @param {Number} dragRotationRate The new drag rotation rate.
95994
- */
95995
- set dragRotationRate(dragRotationRate) {
95996
- this._configs.dragRotationRate = (dragRotationRate !== null && dragRotationRate !== undefined) ? dragRotationRate : 360.0;
95997
- }
96056
+ /**
96057
+ * Gets the current drag rotation rate.
96058
+ *
96059
+ * Default is ````360.0````.
96060
+ *
96061
+ * @returns {Number} The current drag rotation rate.
96062
+ */
96063
+ get dragRotationRate() {
96064
+ return this._configs.dragRotationRate;
96065
+ }
95998
96066
 
95999
- /**
96000
- * Gets the current drag rotation rate.
96001
- *
96002
- * Default is ````360.0````.
96003
- *
96004
- * @returns {Number} The current drag rotation rate.
96005
- */
96006
- get dragRotationRate() {
96007
- return this._configs.dragRotationRate;
96008
- }
96067
+ /**
96068
+ * Sets how much the {@link Camera} dollys each second with keyboard input.
96069
+ *
96070
+ * Default is ````15.0````, to dolly the {@link Camera} ````15.0```` World-space units per second while we hold down
96071
+ * the ````+```` and ````-```` keys.
96072
+ *
96073
+ * @param {Number} keyboardDollyRate The new keyboard dolly rate.
96074
+ */
96075
+ set keyboardDollyRate(keyboardDollyRate) {
96076
+ this._configs.keyboardDollyRate =
96077
+ keyboardDollyRate !== null && keyboardDollyRate !== undefined ? keyboardDollyRate : 15.0;
96078
+ }
96009
96079
 
96010
- /**
96011
- * Sets how much the {@link Camera} dollys each second with keyboard input.
96012
- *
96013
- * Default is ````15.0````, to dolly the {@link Camera} ````15.0```` World-space units per second while we hold down
96014
- * the ````+```` and ````-```` keys.
96015
- *
96016
- * @param {Number} keyboardDollyRate The new keyboard dolly rate.
96017
- */
96018
- set keyboardDollyRate(keyboardDollyRate) {
96019
- this._configs.keyboardDollyRate = (keyboardDollyRate !== null && keyboardDollyRate !== undefined) ? keyboardDollyRate : 15.0;
96020
- }
96080
+ /**
96081
+ * Gets how much the {@link Camera} dollys each second with keyboard input.
96082
+ *
96083
+ * Default is ````15.0````.
96084
+ *
96085
+ * @returns {Number} The current keyboard dolly rate.
96086
+ */
96087
+ get keyboardDollyRate() {
96088
+ return this._configs.keyboardDollyRate;
96089
+ }
96021
96090
 
96022
- /**
96023
- * Gets how much the {@link Camera} dollys each second with keyboard input.
96024
- *
96025
- * Default is ````15.0````.
96026
- *
96027
- * @returns {Number} The current keyboard dolly rate.
96028
- */
96029
- get keyboardDollyRate() {
96030
- return this._configs.keyboardDollyRate;
96031
- }
96091
+ /**
96092
+ * Sets how much the {@link Camera} dollys with touch input.
96093
+ *
96094
+ * Default is ````0.2````
96095
+ *
96096
+ * @param {Number} touchDollyRate The new touch dolly rate.
96097
+ */
96098
+ set touchDollyRate(touchDollyRate) {
96099
+ this._configs.touchDollyRate = touchDollyRate !== null && touchDollyRate !== undefined ? touchDollyRate : 0.2;
96100
+ }
96032
96101
 
96033
- /**
96034
- * Sets how much the {@link Camera} dollys with touch input.
96035
- *
96036
- * Default is ````0.2````
96037
- *
96038
- * @param {Number} touchDollyRate The new touch dolly rate.
96039
- */
96040
- set touchDollyRate(touchDollyRate) {
96041
- this._configs.touchDollyRate = (touchDollyRate !== null && touchDollyRate !== undefined) ? touchDollyRate : 0.2;
96042
- }
96102
+ /**
96103
+ * Gets how much the {@link Camera} dollys each second with touch input.
96104
+ *
96105
+ * Default is ````0.2````.
96106
+ *
96107
+ * @returns {Number} The current touch dolly rate.
96108
+ */
96109
+ get touchDollyRate() {
96110
+ return this._configs.touchDollyRate;
96111
+ }
96043
96112
 
96044
- /**
96045
- * Gets how much the {@link Camera} dollys each second with touch input.
96046
- *
96047
- * Default is ````0.2````.
96048
- *
96049
- * @returns {Number} The current touch dolly rate.
96050
- */
96051
- get touchDollyRate() {
96052
- return this._configs.touchDollyRate;
96053
- }
96113
+ /**
96114
+ * Sets how much the {@link Camera} dollys each second while the mouse wheel is spinning.
96115
+ *
96116
+ * Default is ````100.0````, to dolly the {@link Camera} ````10.0```` World-space units per second as we spin
96117
+ * the mouse wheel.
96118
+ *
96119
+ * @param {Number} mouseWheelDollyRate The new mouse wheel dolly rate.
96120
+ */
96121
+ set mouseWheelDollyRate(mouseWheelDollyRate) {
96122
+ this._configs.mouseWheelDollyRate =
96123
+ mouseWheelDollyRate !== null && mouseWheelDollyRate !== undefined ? mouseWheelDollyRate : 100.0;
96124
+ }
96054
96125
 
96055
- /**
96056
- * Sets how much the {@link Camera} dollys each second while the mouse wheel is spinning.
96057
- *
96058
- * Default is ````100.0````, to dolly the {@link Camera} ````10.0```` World-space units per second as we spin
96059
- * the mouse wheel.
96060
- *
96061
- * @param {Number} mouseWheelDollyRate The new mouse wheel dolly rate.
96062
- */
96063
- set mouseWheelDollyRate(mouseWheelDollyRate) {
96064
- this._configs.mouseWheelDollyRate = (mouseWheelDollyRate !== null && mouseWheelDollyRate !== undefined) ? mouseWheelDollyRate : 100.0;
96065
- }
96126
+ /**
96127
+ * Gets how much the {@link Camera} dollys each second while the mouse wheel is spinning.
96128
+ *
96129
+ * Default is ````100.0````.
96130
+ *
96131
+ * @returns {Number} The current mouseWheel dolly rate.
96132
+ */
96133
+ get mouseWheelDollyRate() {
96134
+ return this._configs.mouseWheelDollyRate;
96135
+ }
96066
96136
 
96067
- /**
96068
- * Gets how much the {@link Camera} dollys each second while the mouse wheel is spinning.
96069
- *
96070
- * Default is ````100.0````.
96071
- *
96072
- * @returns {Number} The current mouseWheel dolly rate.
96073
- */
96074
- get mouseWheelDollyRate() {
96075
- return this._configs.mouseWheelDollyRate;
96076
- }
96137
+ /**
96138
+ * Sets the dolly inertia factor.
96139
+ *
96140
+ * This factor configures how much the {@link Camera} keeps moving after you finish dollying it.
96141
+ *
96142
+ * This factor is a value in range ````[0..1]````. A value of ````0.0```` causes dollying to immediately stop,
96143
+ * ````0.5```` causes dollying to decay 50% on each animation frame, while ````1.0```` causes no decay, which allows dollying
96144
+ * to continue until further input stops it.
96145
+ *
96146
+ * You might set ````dollyInertia```` to zero when you want be able to precisely position or rotate the Camera,
96147
+ * without interference from inertia. This also means that xeokit renders less frames while dollying the Camera,
96148
+ * which can improve rendering performance.
96149
+ *
96150
+ * Default is ````0````.
96151
+ *
96152
+ * @param {Number} dollyInertia New dolly inertia factor.
96153
+ */
96154
+ set dollyInertia(dollyInertia) {
96155
+ this._configs.dollyInertia = dollyInertia !== undefined && dollyInertia !== null ? dollyInertia : 0;
96156
+ }
96077
96157
 
96078
- /**
96079
- * Sets the dolly inertia factor.
96080
- *
96081
- * This factor configures how much the {@link Camera} keeps moving after you finish dollying it.
96082
- *
96083
- * This factor is a value in range ````[0..1]````. A value of ````0.0```` causes dollying to immediately stop,
96084
- * ````0.5```` causes dollying to decay 50% on each animation frame, while ````1.0```` causes no decay, which allows dollying
96085
- * to continue until further input stops it.
96086
- *
96087
- * You might set ````dollyInertia```` to zero when you want be able to precisely position or rotate the Camera,
96088
- * without interference from inertia. This also means that xeokit renders less frames while dollying the Camera,
96089
- * which can improve rendering performance.
96090
- *
96091
- * Default is ````0````.
96092
- *
96093
- * @param {Number} dollyInertia New dolly inertia factor.
96094
- */
96095
- set dollyInertia(dollyInertia) {
96096
- this._configs.dollyInertia = (dollyInertia !== undefined && dollyInertia !== null) ? dollyInertia : 0;
96097
- }
96158
+ /**
96159
+ * Gets the dolly inertia factor.
96160
+ *
96161
+ * Default is ````0````.
96162
+ *
96163
+ * @returns {Number} The current dolly inertia factor.
96164
+ */
96165
+ get dollyInertia() {
96166
+ return this._configs.dollyInertia;
96167
+ }
96098
96168
 
96099
- /**
96100
- * Gets the dolly inertia factor.
96101
- *
96102
- * Default is ````0````.
96103
- *
96104
- * @returns {Number} The current dolly inertia factor.
96105
- */
96106
- get dollyInertia() {
96107
- return this._configs.dollyInertia;
96108
- }
96169
+ /**
96170
+ * Sets the proximity to the closest object below which dolly speed decreases, and above which dolly speed increases.
96171
+ *
96172
+ * Default is ````35.0````.
96173
+ *
96174
+ * @param {Number} dollyProximityThreshold New dolly proximity threshold.
96175
+ */
96176
+ set dollyProximityThreshold(dollyProximityThreshold) {
96177
+ this._configs.dollyProximityThreshold =
96178
+ dollyProximityThreshold !== undefined && dollyProximityThreshold !== null ? dollyProximityThreshold : 35.0;
96179
+ }
96109
96180
 
96110
- /**
96111
- * Sets the proximity to the closest object below which dolly speed decreases, and above which dolly speed increases.
96112
- *
96113
- * Default is ````35.0````.
96114
- *
96115
- * @param {Number} dollyProximityThreshold New dolly proximity threshold.
96116
- */
96117
- set dollyProximityThreshold(dollyProximityThreshold) {
96118
- this._configs.dollyProximityThreshold = (dollyProximityThreshold !== undefined && dollyProximityThreshold !== null) ? dollyProximityThreshold : 35.0;
96119
- }
96181
+ /**
96182
+ * Gets the proximity to the closest object below which dolly speed decreases, and above which dolly speed increases.
96183
+ *
96184
+ * Default is ````35.0````.
96185
+ *
96186
+ * @returns {Number} The current dolly proximity threshold.
96187
+ */
96188
+ get dollyProximityThreshold() {
96189
+ return this._configs.dollyProximityThreshold;
96190
+ }
96120
96191
 
96121
- /**
96122
- * Gets the proximity to the closest object below which dolly speed decreases, and above which dolly speed increases.
96123
- *
96124
- * Default is ````35.0````.
96125
- *
96126
- * @returns {Number} The current dolly proximity threshold.
96127
- */
96128
- get dollyProximityThreshold() {
96129
- return this._configs.dollyProximityThreshold;
96130
- }
96192
+ /**
96193
+ * Sets the minimum dolly speed.
96194
+ *
96195
+ * Default is ````0.04````.
96196
+ *
96197
+ * @param {Number} dollyMinSpeed New dolly minimum speed.
96198
+ */
96199
+ set dollyMinSpeed(dollyMinSpeed) {
96200
+ this._configs.dollyMinSpeed = dollyMinSpeed !== undefined && dollyMinSpeed !== null ? dollyMinSpeed : 0.04;
96201
+ }
96131
96202
 
96132
- /**
96133
- * Sets the minimum dolly speed.
96134
- *
96135
- * Default is ````0.04````.
96136
- *
96137
- * @param {Number} dollyMinSpeed New dolly minimum speed.
96138
- */
96139
- set dollyMinSpeed(dollyMinSpeed) {
96140
- this._configs.dollyMinSpeed = (dollyMinSpeed !== undefined && dollyMinSpeed !== null) ? dollyMinSpeed : 0.04;
96141
- }
96203
+ /**
96204
+ * Gets the minimum dolly speed.
96205
+ *
96206
+ * Default is ````0.04````.
96207
+ *
96208
+ * @returns {Number} The current minimum dolly speed.
96209
+ */
96210
+ get dollyMinSpeed() {
96211
+ return this._configs.dollyMinSpeed;
96212
+ }
96142
96213
 
96143
- /**
96144
- * Gets the minimum dolly speed.
96145
- *
96146
- * Default is ````0.04````.
96147
- *
96148
- * @returns {Number} The current minimum dolly speed.
96149
- */
96150
- get dollyMinSpeed() {
96151
- return this._configs.dollyMinSpeed;
96152
- }
96214
+ /**
96215
+ * Sets the pan inertia factor.
96216
+ *
96217
+ * This factor configures how much the {@link Camera} keeps moving after you finish panning it.
96218
+ *
96219
+ * This factor is a value in range ````[0..1]````. A value of ````0.0```` causes panning to immediately stop,
96220
+ * ````0.5```` causes panning to decay 50% on each animation frame, while ````1.0```` causes no decay, which allows panning
96221
+ * to continue until further input stops it.
96222
+ *
96223
+ * You might set ````panInertia```` to zero when you want be able to precisely position or rotate the Camera,
96224
+ * without interference from inertia. This also means that xeokit renders less frames while panning the Camera,
96225
+ * wich can improve rendering performance.
96226
+ *
96227
+ * Default is ````0.5````.
96228
+ *
96229
+ * @param {Number} panInertia New pan inertia factor.
96230
+ */
96231
+ set panInertia(panInertia) {
96232
+ this._configs.panInertia = panInertia !== undefined && panInertia !== null ? panInertia : 0.5;
96233
+ }
96153
96234
 
96154
- /**
96155
- * Sets the pan inertia factor.
96156
- *
96157
- * This factor configures how much the {@link Camera} keeps moving after you finish panning it.
96158
- *
96159
- * This factor is a value in range ````[0..1]````. A value of ````0.0```` causes panning to immediately stop,
96160
- * ````0.5```` causes panning to decay 50% on each animation frame, while ````1.0```` causes no decay, which allows panning
96161
- * to continue until further input stops it.
96162
- *
96163
- * You might set ````panInertia```` to zero when you want be able to precisely position or rotate the Camera,
96164
- * without interference from inertia. This also means that xeokit renders less frames while panning the Camera,
96165
- * wich can improve rendering performance.
96166
- *
96167
- * Default is ````0.5````.
96168
- *
96169
- * @param {Number} panInertia New pan inertia factor.
96170
- */
96171
- set panInertia(panInertia) {
96172
- this._configs.panInertia = (panInertia !== undefined && panInertia !== null) ? panInertia : 0.5;
96173
- }
96235
+ /**
96236
+ * Gets the pan inertia factor.
96237
+ *
96238
+ * Default is ````0.5````.
96239
+ *
96240
+ * @returns {Number} The current pan inertia factor.
96241
+ */
96242
+ get panInertia() {
96243
+ return this._configs.panInertia;
96244
+ }
96174
96245
 
96175
- /**
96176
- * Gets the pan inertia factor.
96177
- *
96178
- * Default is ````0.5````.
96179
- *
96180
- * @returns {Number} The current pan inertia factor.
96181
- */
96182
- get panInertia() {
96183
- return this._configs.panInertia;
96184
- }
96246
+ /**
96247
+ * Sets the keyboard layout.
96248
+ *
96249
+ * Supported layouts are:
96250
+ *
96251
+ * * ````"qwerty"```` (default)
96252
+ * * ````"azerty"````
96253
+ *
96254
+ * @deprecated
96255
+ * @param {String} value Selects the keyboard layout.
96256
+ */
96257
+ set keyboardLayout(value) {
96258
+ // this.warn("keyboardLayout property is deprecated - use keyMap property instead");
96259
+ value = value || "qwerty";
96260
+ if (value !== "qwerty" && value !== "azerty") {
96261
+ this.error("Unsupported value for keyboardLayout - defaulting to 'qwerty'");
96262
+ value = "qwerty";
96263
+ }
96264
+ this._configs.keyboardLayout = value;
96265
+ this.keyMap = this._configs.keyboardLayout;
96266
+ }
96185
96267
 
96186
- /**
96187
- * Sets the keyboard layout.
96188
- *
96189
- * Supported layouts are:
96190
- *
96191
- * * ````"qwerty"```` (default)
96192
- * * ````"azerty"````
96193
- *
96194
- * @deprecated
96195
- * @param {String} value Selects the keyboard layout.
96196
- */
96197
- set keyboardLayout(value) {
96198
- // this.warn("keyboardLayout property is deprecated - use keyMap property instead");
96199
- value = value || "qwerty";
96200
- if (value !== "qwerty" && value !== "azerty") {
96201
- this.error("Unsupported value for keyboardLayout - defaulting to 'qwerty'");
96202
- value = "qwerty";
96203
- }
96204
- this._configs.keyboardLayout = value;
96205
- this.keyMap = this._configs.keyboardLayout;
96206
- }
96268
+ /**
96269
+ * Gets the keyboard layout.
96270
+ *
96271
+ * Supported layouts are:
96272
+ *
96273
+ * * ````"qwerty"```` (default)
96274
+ * * ````"azerty"````
96275
+ *
96276
+ * @deprecated
96277
+ * @returns {String} The current keyboard layout.
96278
+ */
96279
+ get keyboardLayout() {
96280
+ return this._configs.keyboardLayout;
96281
+ }
96207
96282
 
96208
- /**
96209
- * Gets the keyboard layout.
96210
- *
96211
- * Supported layouts are:
96212
- *
96213
- * * ````"qwerty"```` (default)
96214
- * * ````"azerty"````
96215
- *
96216
- * @deprecated
96217
- * @returns {String} The current keyboard layout.
96218
- */
96219
- get keyboardLayout() {
96220
- return this._configs.keyboardLayout;
96221
- }
96283
+ /**
96284
+ * Sets a sphere as the representation of the pivot position.
96285
+ *
96286
+ * @param {Object} [cfg] Sphere configuration.
96287
+ * @param {String} [cfg.size=1] Optional size factor of the sphere. Defaults to 1.
96288
+ * @param {String} [cfg.material=PhongMaterial] Optional size factor of the sphere. Defaults to a red opaque material.
96289
+ */
96290
+ enablePivotSphere(cfg = {}) {
96291
+ this._controllers.pivotController.enablePivotSphere(cfg);
96292
+ }
96222
96293
 
96223
- /**
96224
- * Sets a sphere as the representation of the pivot position.
96225
- *
96226
- * @param {Object} [cfg] Sphere configuration.
96227
- * @param {String} [cfg.size=1] Optional size factor of the sphere. Defaults to 1.
96228
- * @param {String} [cfg.material=PhongMaterial] Optional size factor of the sphere. Defaults to a red opaque material.
96229
- */
96230
- enablePivotSphere(cfg = {}) {
96231
- this._controllers.pivotController.enablePivotSphere(cfg);
96232
- }
96294
+ /**
96295
+ * Remove the sphere as the representation of the pivot position.
96296
+ *
96297
+ */
96298
+ disablePivotSphere() {
96299
+ this._controllers.pivotController.disablePivotSphere();
96300
+ }
96233
96301
 
96234
- /**
96235
- * Remove the sphere as the representation of the pivot position.
96236
- *
96237
- */
96238
- disablePivotSphere() {
96239
- this._controllers.pivotController.disablePivotSphere();
96240
- }
96241
-
96242
- /**
96243
- * Sets whether smart default pivoting is enabled.
96244
- *
96245
- * When ````true````, we'll pivot by default about the 3D position of the mouse/touch pointer on an
96246
- * imaginary sphere that's centered at {@link Camera#eye} and sized to the {@link Scene} boundary.
96247
- *
96248
- * When ````false````, we'll pivot by default about {@link Camera#look}.
96249
- *
96250
- * Default is ````false````.
96251
- *
96252
- * @param {Boolean} enabled Set ````true```` to pivot by default about the selected point on the virtual sphere, or ````false```` to pivot by default about {@link Camera#look}.
96253
- */
96254
- set smartPivot(enabled) {
96255
- this._configs.smartPivot = (enabled !== false);
96256
- }
96302
+ /**
96303
+ * Sets whether smart default pivoting is enabled.
96304
+ *
96305
+ * When ````true````, we'll pivot by default about the 3D position of the mouse/touch pointer on an
96306
+ * imaginary sphere that's centered at {@link Camera#eye} and sized to the {@link Scene} boundary.
96307
+ *
96308
+ * When ````false````, we'll pivot by default about {@link Camera#look}.
96309
+ *
96310
+ * Default is ````false````.
96311
+ *
96312
+ * @param {Boolean} enabled Set ````true```` to pivot by default about the selected point on the virtual sphere, or ````false```` to pivot by default about {@link Camera#look}.
96313
+ */
96314
+ set smartPivot(enabled) {
96315
+ this._configs.smartPivot = enabled !== false;
96316
+ }
96257
96317
 
96258
- /**
96259
- * Gets whether smart default pivoting is enabled.
96260
- *
96261
- * When ````true````, we'll pivot by default about the 3D position of the mouse/touch pointer on an
96262
- * imaginary sphere that's centered at {@link Camera#eye} and sized to the {@link Scene} boundary.
96263
- *
96264
- * When ````false````, we'll pivot by default about {@link Camera#look}.
96265
- *
96266
- * Default is ````false````.
96267
- *
96268
- * @returns {Boolean} Returns ````true```` when pivoting by default about the selected point on the virtual sphere, or ````false```` when pivoting by default about {@link Camera#look}.
96269
- */
96270
- get smartPivot() {
96271
- return this._configs.smartPivot;
96272
- }
96318
+ /**
96319
+ * Gets whether smart default pivoting is enabled.
96320
+ *
96321
+ * When ````true````, we'll pivot by default about the 3D position of the mouse/touch pointer on an
96322
+ * imaginary sphere that's centered at {@link Camera#eye} and sized to the {@link Scene} boundary.
96323
+ *
96324
+ * When ````false````, we'll pivot by default about {@link Camera#look}.
96325
+ *
96326
+ * Default is ````false````.
96327
+ *
96328
+ * @returns {Boolean} Returns ````true```` when pivoting by default about the selected point on the virtual sphere, or ````false```` when pivoting by default about {@link Camera#look}.
96329
+ */
96330
+ get smartPivot() {
96331
+ return this._configs.smartPivot;
96332
+ }
96273
96333
 
96274
- /**
96275
- * Sets the double click time frame length in milliseconds.
96276
- *
96277
- * If two mouse click events occur within this time frame, it is considered a double click.
96278
- *
96279
- * Default is ````250````
96280
- *
96281
- * @param {Number} value New double click time frame.
96282
- */
96283
- set doubleClickTimeFrame(value) {
96284
- this._configs.doubleClickTimeFrame = (value !== undefined && value !== null) ? value : 250;
96285
- }
96334
+ /**
96335
+ * Sets the double click time frame length in milliseconds.
96336
+ *
96337
+ * If two mouse click events occur within this time frame, it is considered a double click.
96338
+ *
96339
+ * Default is ````250````
96340
+ *
96341
+ * @param {Number} value New double click time frame.
96342
+ */
96343
+ set doubleClickTimeFrame(value) {
96344
+ this._configs.doubleClickTimeFrame = value !== undefined && value !== null ? value : 250;
96345
+ }
96286
96346
 
96287
- /**
96288
- * Gets the double click time frame length in milliseconds.
96289
- *
96290
- * Default is ````250````
96291
- *
96292
- * @param {Number} value Current double click time frame.
96293
- */
96294
- get doubleClickTimeFrame() {
96295
- return this._configs.doubleClickTimeFrame;
96296
- }
96347
+ /**
96348
+ * Gets the double click time frame length in milliseconds.
96349
+ *
96350
+ * Default is ````250````
96351
+ *
96352
+ * @param {Number} value Current double click time frame.
96353
+ */
96354
+ get doubleClickTimeFrame() {
96355
+ return this._configs.doubleClickTimeFrame;
96356
+ }
96297
96357
 
96298
- /**
96299
- * Destroys this ````CameraControl````.
96300
- * @private
96301
- */
96302
- destroy() {
96303
- this._destroyHandlers();
96304
- this._destroyControllers();
96305
- this._cameraUpdater.destroy();
96306
- super.destroy();
96307
- }
96358
+ /**
96359
+ * Destroys this ````CameraControl````.
96360
+ * @private
96361
+ */
96362
+ destroy() {
96363
+ this._destroyHandlers();
96364
+ this._destroyControllers();
96365
+ this._cameraUpdater.destroy();
96366
+ super.destroy();
96367
+ }
96308
96368
 
96309
- _destroyHandlers() {
96310
- for (let i = 0, len = this._handlers.length; i < len; i++) {
96311
- const handler = this._handlers[i];
96312
- if (handler.destroy) {
96313
- handler.destroy();
96314
- }
96315
- }
96316
- }
96369
+ _destroyHandlers() {
96370
+ for (let i = 0, len = this._handlers.length; i < len; i++) {
96371
+ const handler = this._handlers[i];
96372
+ if (handler.destroy) {
96373
+ handler.destroy();
96374
+ }
96375
+ }
96376
+ }
96317
96377
 
96318
- _destroyControllers() {
96319
- for (let i = 0, len = this._controllers.length; i < len; i++) {
96320
- const controller = this._controllers[i];
96321
- if (controller.destroy) {
96322
- controller.destroy();
96323
- }
96324
- }
96325
- }
96378
+ _destroyControllers() {
96379
+ for (let i = 0, len = this._controllers.length; i < len; i++) {
96380
+ const controller = this._controllers[i];
96381
+ if (controller.destroy) {
96382
+ controller.destroy();
96383
+ }
96384
+ }
96385
+ }
96326
96386
  }
96327
96387
 
96328
96388
  /**