@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.
- package/dist/tctwins-core.cjs.js +2245 -2185
- package/dist/tctwins-core.es.js +2245 -2185
- package/dist/tctwins-core.es5.js +740 -730
- package/dist/tctwins-core.min.cjs.js +2 -2
- package/dist/tctwins-core.min.es.js +2 -2
- package/dist/tctwins-core.min.es5.js +2 -2
- package/package.json +1 -1
- package/types/viewer/scene/CameraControl/CameraControl.d.ts +674 -672
package/dist/tctwins-core.es.js
CHANGED
|
@@ -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
|
-
|
|
12046
|
-
|
|
12047
|
-
this._onPickedNothing = null;
|
|
12048
|
-
this._onPickedSurface = null;
|
|
12035
|
+
this._active = false;
|
|
12036
|
+
this._mouseState = MOUSE_FINDING_ORIGIN;
|
|
12049
12037
|
|
|
12050
|
-
|
|
12051
|
-
this._onInputMouseUp = null;
|
|
12038
|
+
this._currentAngleMeasurement = null;
|
|
12052
12039
|
|
|
12053
|
-
|
|
12040
|
+
// init markerDiv element (think about making its style configurable)
|
|
12041
|
+
this._initMarkerDiv();
|
|
12054
12042
|
|
|
12055
|
-
|
|
12056
|
-
|
|
12043
|
+
this._onMouseHoverSurface = null;
|
|
12044
|
+
this._onHoverNothing = null;
|
|
12045
|
+
this._onPickedNothing = null;
|
|
12046
|
+
this._onPickedSurface = null;
|
|
12057
12047
|
|
|
12058
|
-
|
|
12059
|
-
|
|
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
|
-
|
|
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
|
-
|
|
12075
|
-
|
|
12053
|
+
this._attachPlugin(angleMeasurementsPlugin, cfg);
|
|
12054
|
+
}
|
|
12076
12055
|
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
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
|
-
|
|
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
|
-
|
|
12089
|
-
|
|
12090
|
-
|
|
12091
|
-
|
|
12092
|
-
|
|
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
|
-
|
|
12096
|
-
|
|
12097
|
-
|
|
12098
|
-
|
|
12099
|
-
|
|
12100
|
-
|
|
12091
|
+
/**
|
|
12092
|
+
* The {@link AngleMeasurementsPlugin} that owns this AngleMeasurementsMouseControl.
|
|
12093
|
+
*
|
|
12094
|
+
* @type {AngleMeasurementsPlugin}
|
|
12095
|
+
*/
|
|
12096
|
+
this.plugin = angleMeasurementsPlugin;
|
|
12097
|
+
}
|
|
12101
12098
|
|
|
12102
|
-
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12108
|
-
|
|
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
|
-
|
|
12113
|
-
|
|
12114
|
-
|
|
12115
|
-
|
|
12116
|
-
|
|
12117
|
-
|
|
12118
|
-
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
|
|
12128
|
-
|
|
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
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
12140
|
-
|
|
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
|
-
|
|
12145
|
-
|
|
12146
|
-
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
|
|
12163
|
-
|
|
12164
|
-
|
|
12165
|
-
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
|
|
12172
|
-
|
|
12173
|
-
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
|
|
12200
|
-
|
|
12201
|
-
|
|
12202
|
-
|
|
12203
|
-
|
|
12204
|
-
|
|
12205
|
-
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
|
|
12210
|
-
|
|
12211
|
-
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
|
-
|
|
12216
|
-
|
|
12217
|
-
|
|
12218
|
-
|
|
12219
|
-
|
|
12220
|
-
|
|
12221
|
-
|
|
12222
|
-
|
|
12223
|
-
|
|
12224
|
-
|
|
12225
|
-
|
|
12226
|
-
|
|
12227
|
-
|
|
12228
|
-
|
|
12229
|
-
|
|
12230
|
-
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
|
|
12244
|
-
|
|
12245
|
-
|
|
12246
|
-
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
|
|
12252
|
-
|
|
12253
|
-
|
|
12254
|
-
|
|
12255
|
-
|
|
12256
|
-
|
|
12257
|
-
|
|
12258
|
-
|
|
12259
|
-
|
|
12260
|
-
|
|
12261
|
-
|
|
12262
|
-
|
|
12263
|
-
|
|
12264
|
-
|
|
12265
|
-
|
|
12266
|
-
|
|
12267
|
-
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12288
|
-
|
|
12289
|
-
|
|
12290
|
-
|
|
12291
|
-
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
|
|
12296
|
-
|
|
12297
|
-
|
|
12298
|
-
|
|
12299
|
-
|
|
12300
|
-
|
|
12301
|
-
|
|
12302
|
-
|
|
12303
|
-
|
|
12304
|
-
|
|
12305
|
-
|
|
12306
|
-
|
|
12307
|
-
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12312
|
-
|
|
12313
|
-
|
|
12314
|
-
|
|
12315
|
-
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
12335
|
-
|
|
12336
|
-
|
|
12337
|
-
|
|
12338
|
-
|
|
12339
|
-
|
|
12340
|
-
|
|
12341
|
-
|
|
12342
|
-
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
|
|
12348
|
-
|
|
12349
|
-
|
|
12350
|
-
|
|
12351
|
-
|
|
12352
|
-
|
|
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
|
-
|
|
12357
|
-
|
|
12358
|
-
|
|
12359
|
-
|
|
12360
|
-
|
|
12361
|
-
|
|
12362
|
-
|
|
12363
|
-
|
|
12364
|
-
|
|
12365
|
-
|
|
12366
|
-
|
|
12367
|
-
|
|
12368
|
-
|
|
12369
|
-
|
|
12370
|
-
|
|
12371
|
-
|
|
12372
|
-
|
|
12373
|
-
|
|
12374
|
-
|
|
12375
|
-
|
|
12376
|
-
|
|
12377
|
-
|
|
12378
|
-
|
|
12379
|
-
|
|
12380
|
-
|
|
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
|
-
|
|
12385
|
-
|
|
12386
|
-
|
|
12387
|
-
|
|
12388
|
-
|
|
12389
|
-
|
|
12390
|
-
|
|
12391
|
-
|
|
12392
|
-
|
|
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
|
-
|
|
12396
|
-
|
|
12392
|
+
this._destroyMarkerDiv();
|
|
12393
|
+
this._initMarkerDiv();
|
|
12397
12394
|
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
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
|
-
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12410
|
-
|
|
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.
|
|
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.
|
|
84928
|
-
|
|
84929
|
-
|
|
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.
|
|
84943
|
-
|
|
84944
|
-
|
|
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
|
-
|
|
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
|
-
|
|
85598
|
-
}
|
|
85607
|
+
this._currentDistanceMeasurement = null;
|
|
85599
85608
|
|
|
85600
|
-
|
|
85601
|
-
|
|
85602
|
-
|
|
85603
|
-
|
|
85604
|
-
|
|
85605
|
-
|
|
85606
|
-
|
|
85607
|
-
|
|
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
|
-
|
|
85616
|
-
}
|
|
85618
|
+
this._initMarkerDiv();
|
|
85617
85619
|
|
|
85618
|
-
|
|
85619
|
-
|
|
85620
|
-
|
|
85621
|
-
|
|
85622
|
-
|
|
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
|
-
|
|
85629
|
+
this._attachPlugin(distanceMeasurementsPlugin, cfg);
|
|
85630
|
+
}
|
|
85627
85631
|
|
|
85628
|
-
|
|
85629
|
-
|
|
85630
|
-
|
|
85631
|
-
|
|
85632
|
-
|
|
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
|
-
|
|
85636
|
-
|
|
85637
|
-
|
|
85638
|
-
|
|
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
|
-
|
|
85643
|
-
|
|
85644
|
-
|
|
85645
|
-
|
|
85646
|
-
|
|
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
|
-
|
|
85652
|
-
|
|
85653
|
-
|
|
85654
|
-
|
|
85655
|
-
|
|
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
|
-
|
|
85673
|
-
|
|
85674
|
-
|
|
85675
|
-
|
|
85676
|
-
|
|
85677
|
-
|
|
85678
|
-
|
|
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
|
-
|
|
85684
|
-
|
|
85685
|
-
|
|
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
|
-
|
|
85688
|
-
|
|
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
|
-
|
|
85692
|
-
|
|
85693
|
-
|
|
85713
|
+
/**
|
|
85714
|
+
* Activates this DistanceMeasurementsMouseControl, ready to respond to input.
|
|
85715
|
+
*/
|
|
85716
|
+
activate() {
|
|
85717
|
+
if (this._active) {
|
|
85718
|
+
return;
|
|
85719
|
+
}
|
|
85694
85720
|
|
|
85695
|
-
|
|
85721
|
+
if (!this._markerDiv) {
|
|
85722
|
+
this._initMarkerDiv();
|
|
85723
|
+
}
|
|
85696
85724
|
|
|
85697
|
-
|
|
85698
|
-
|
|
85699
|
-
|
|
85700
|
-
|
|
85701
|
-
|
|
85702
|
-
|
|
85703
|
-
|
|
85704
|
-
|
|
85705
|
-
|
|
85706
|
-
|
|
85707
|
-
|
|
85708
|
-
|
|
85709
|
-
|
|
85710
|
-
|
|
85711
|
-
|
|
85712
|
-
|
|
85713
|
-
|
|
85714
|
-
|
|
85715
|
-
|
|
85716
|
-
|
|
85717
|
-
|
|
85718
|
-
|
|
85719
|
-
|
|
85720
|
-
|
|
85721
|
-
|
|
85722
|
-
|
|
85723
|
-
|
|
85724
|
-
|
|
85725
|
-
|
|
85726
|
-
|
|
85727
|
-
|
|
85728
|
-
|
|
85729
|
-
|
|
85730
|
-
|
|
85731
|
-
|
|
85732
|
-
|
|
85733
|
-
|
|
85734
|
-
|
|
85735
|
-
|
|
85736
|
-
|
|
85737
|
-
|
|
85738
|
-
|
|
85739
|
-
|
|
85740
|
-
|
|
85741
|
-
|
|
85742
|
-
|
|
85743
|
-
|
|
85744
|
-
|
|
85745
|
-
|
|
85746
|
-
|
|
85747
|
-
|
|
85748
|
-
|
|
85749
|
-
|
|
85750
|
-
|
|
85751
|
-
|
|
85752
|
-
|
|
85753
|
-
|
|
85754
|
-
|
|
85755
|
-
|
|
85756
|
-
|
|
85757
|
-
|
|
85758
|
-
|
|
85759
|
-
|
|
85760
|
-
|
|
85761
|
-
|
|
85762
|
-
|
|
85763
|
-
|
|
85764
|
-
|
|
85765
|
-
|
|
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
|
-
|
|
85770
|
-
|
|
85771
|
-
|
|
85772
|
-
|
|
85773
|
-
|
|
85774
|
-
|
|
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
|
-
|
|
85778
|
-
|
|
85779
|
-
|
|
85780
|
-
|
|
85781
|
-
|
|
85782
|
-
|
|
85783
|
-
|
|
85784
|
-
|
|
85785
|
-
|
|
85786
|
-
|
|
85787
|
-
|
|
85788
|
-
|
|
85789
|
-
|
|
85790
|
-
|
|
85791
|
-
|
|
85792
|
-
|
|
85793
|
-
|
|
85794
|
-
|
|
85795
|
-
|
|
85796
|
-
|
|
85797
|
-
|
|
85798
|
-
|
|
85799
|
-
|
|
85800
|
-
|
|
85801
|
-
|
|
85802
|
-
|
|
85803
|
-
|
|
85804
|
-
|
|
85805
|
-
|
|
85806
|
-
|
|
85807
|
-
|
|
85808
|
-
|
|
85809
|
-
|
|
85810
|
-
|
|
85811
|
-
|
|
85812
|
-
|
|
85813
|
-
|
|
85814
|
-
|
|
85815
|
-
|
|
85816
|
-
|
|
85817
|
-
|
|
85818
|
-
|
|
85819
|
-
|
|
85820
|
-
|
|
85821
|
-
|
|
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
|
-
|
|
85827
|
-
|
|
85828
|
-
|
|
85829
|
-
|
|
85830
|
-
|
|
85831
|
-
|
|
85832
|
-
|
|
85833
|
-
|
|
85834
|
-
|
|
85835
|
-
|
|
85836
|
-
|
|
85837
|
-
|
|
85838
|
-
|
|
85839
|
-
|
|
85840
|
-
|
|
85841
|
-
|
|
85842
|
-
|
|
85843
|
-
|
|
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
|
-
|
|
85847
|
-
|
|
85894
|
+
this._active = true;
|
|
85895
|
+
}
|
|
85848
85896
|
|
|
85849
|
-
|
|
85850
|
-
|
|
85851
|
-
|
|
85852
|
-
|
|
85853
|
-
|
|
85854
|
-
|
|
85855
|
-
|
|
85856
|
-
|
|
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
|
-
|
|
85907
|
+
this.fire("activated", false);
|
|
85860
85908
|
|
|
85861
|
-
|
|
85862
|
-
|
|
85863
|
-
|
|
85864
|
-
|
|
85865
|
-
|
|
85866
|
-
|
|
85867
|
-
|
|
85868
|
-
|
|
85869
|
-
|
|
85870
|
-
|
|
85871
|
-
|
|
85872
|
-
|
|
85873
|
-
|
|
85874
|
-
|
|
85875
|
-
|
|
85876
|
-
|
|
85877
|
-
|
|
85878
|
-
|
|
85879
|
-
|
|
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
|
-
|
|
85884
|
-
|
|
85885
|
-
|
|
85886
|
-
|
|
85887
|
-
|
|
85888
|
-
|
|
85889
|
-
|
|
85890
|
-
|
|
85891
|
-
|
|
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
|
-
|
|
85895
|
-
|
|
85942
|
+
this._destroyMarkerDiv();
|
|
85943
|
+
this._initMarkerDiv();
|
|
85896
85944
|
|
|
85897
|
-
|
|
85898
|
-
|
|
85899
|
-
|
|
85900
|
-
|
|
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
|
-
|
|
85906
|
-
|
|
85907
|
-
|
|
85908
|
-
|
|
85909
|
-
|
|
85910
|
-
|
|
85911
|
-
|
|
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
|
-
|
|
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
|
-
|
|
92198
|
-
|
|
92199
|
-
|
|
92189
|
+
this._onTick = this._scene.on("tick", () => {
|
|
92190
|
+
this.updatePivotElement();
|
|
92191
|
+
this.updatePivotSphere();
|
|
92192
|
+
});
|
|
92193
|
+
}
|
|
92200
92194
|
|
|
92201
|
-
|
|
92202
|
-
|
|
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
|
-
|
|
92205
|
-
|
|
92207
|
+
if (this._scene.camera.projection == "ortho") {
|
|
92208
|
+
radius /= this._scene.camera.ortho.scale / 2;
|
|
92209
|
+
}
|
|
92206
92210
|
|
|
92207
|
-
|
|
92208
|
-
|
|
92209
|
-
|
|
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
|
-
|
|
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
|
-
|
|
92215
|
-
|
|
92216
|
-
|
|
92217
|
-
|
|
92218
|
-
|
|
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
|
-
|
|
92223
|
-
|
|
92224
|
-
|
|
92225
|
-
|
|
92226
|
-
|
|
92227
|
-
|
|
92228
|
-
|
|
92229
|
-
|
|
92230
|
-
|
|
92231
|
-
|
|
92232
|
-
|
|
92233
|
-
|
|
92234
|
-
|
|
92235
|
-
|
|
92236
|
-
|
|
92237
|
-
|
|
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
|
-
|
|
92242
|
-
|
|
92243
|
-
|
|
92244
|
-
|
|
92245
|
-
|
|
92246
|
-
|
|
92247
|
-
|
|
92248
|
-
|
|
92249
|
-
|
|
92250
|
-
|
|
92251
|
-
|
|
92252
|
-
|
|
92253
|
-
|
|
92254
|
-
|
|
92255
|
-
|
|
92256
|
-
|
|
92257
|
-
|
|
92258
|
-
|
|
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
|
-
|
|
92264
|
-
|
|
92265
|
-
|
|
92266
|
-
|
|
92267
|
-
|
|
92268
|
-
|
|
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
|
-
|
|
92273
|
-
|
|
92274
|
-
|
|
92323
|
+
/**
|
|
92324
|
+
* Begins pivoting.
|
|
92325
|
+
*/
|
|
92326
|
+
startPivot() {
|
|
92327
|
+
if (this._cameraLookingDownwards()) {
|
|
92328
|
+
this._pivoting = false;
|
|
92329
|
+
return false;
|
|
92330
|
+
}
|
|
92275
92331
|
|
|
92276
|
-
|
|
92277
|
-
this._pivoting = false;
|
|
92278
|
-
return false;
|
|
92279
|
-
}
|
|
92332
|
+
const camera = this._scene.camera;
|
|
92280
92333
|
|
|
92281
|
-
|
|
92334
|
+
let lookat = math.lookAtMat4v(camera.eye, camera.look, camera.worldUp);
|
|
92335
|
+
math.transformPoint3(lookat, this.getPivotPos(), this._cameraOffset);
|
|
92282
92336
|
|
|
92283
|
-
|
|
92284
|
-
|
|
92337
|
+
const pivotPos = this.getPivotPos();
|
|
92338
|
+
this._cameraOffset[2] += math.distVec3(camera.eye, pivotPos);
|
|
92285
92339
|
|
|
92286
|
-
|
|
92287
|
-
this._cameraOffset[2] += math.distVec3(camera.eye, pivotPos);
|
|
92340
|
+
lookat = math.inverseMat4(lookat);
|
|
92288
92341
|
|
|
92289
|
-
|
|
92342
|
+
const offset = math.transformVec3(lookat, this._cameraOffset);
|
|
92343
|
+
const diff = math.vec3();
|
|
92290
92344
|
|
|
92291
|
-
|
|
92292
|
-
|
|
92345
|
+
math.subVec3(camera.eye, pivotPos, diff);
|
|
92346
|
+
math.addVec3(diff, offset);
|
|
92293
92347
|
|
|
92294
|
-
|
|
92295
|
-
|
|
92348
|
+
if (camera.zUp) {
|
|
92349
|
+
const t = diff[1];
|
|
92350
|
+
diff[1] = diff[2];
|
|
92351
|
+
diff[2] = t;
|
|
92352
|
+
}
|
|
92296
92353
|
|
|
92297
|
-
|
|
92298
|
-
|
|
92299
|
-
|
|
92300
|
-
|
|
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
|
-
|
|
92304
|
-
|
|
92305
|
-
|
|
92306
|
-
|
|
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
|
-
|
|
92310
|
-
|
|
92311
|
-
|
|
92312
|
-
|
|
92313
|
-
|
|
92314
|
-
|
|
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
|
-
|
|
92319
|
-
|
|
92320
|
-
|
|
92321
|
-
|
|
92322
|
-
|
|
92323
|
-
|
|
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
|
-
|
|
92328
|
-
|
|
92329
|
-
|
|
92330
|
-
|
|
92331
|
-
|
|
92332
|
-
|
|
92333
|
-
|
|
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
|
-
|
|
92338
|
-
|
|
92339
|
-
|
|
92340
|
-
|
|
92341
|
-
|
|
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
|
-
|
|
92360
|
-
|
|
92361
|
-
|
|
92362
|
-
|
|
92363
|
-
|
|
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
|
-
|
|
92368
|
-
|
|
92369
|
-
|
|
92370
|
-
|
|
92371
|
-
|
|
92372
|
-
|
|
92373
|
-
|
|
92374
|
-
|
|
92375
|
-
|
|
92376
|
-
|
|
92377
|
-
|
|
92378
|
-
|
|
92379
|
-
|
|
92380
|
-
|
|
92381
|
-
|
|
92382
|
-
|
|
92383
|
-
|
|
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
|
-
|
|
92437
|
-
|
|
92438
|
-
|
|
92439
|
-
|
|
92440
|
-
|
|
92441
|
-
|
|
92442
|
-
|
|
92443
|
-
|
|
92444
|
-
|
|
92445
|
-
|
|
92446
|
-
|
|
92447
|
-
|
|
92448
|
-
|
|
92449
|
-
|
|
92450
|
-
|
|
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
|
-
|
|
92455
|
-
|
|
92456
|
-
|
|
92457
|
-
|
|
92458
|
-
|
|
92509
|
+
/**
|
|
92510
|
+
* Finishes pivoting.
|
|
92511
|
+
*/
|
|
92512
|
+
endPivot() {
|
|
92513
|
+
this._pivoting = false;
|
|
92514
|
+
}
|
|
92459
92515
|
|
|
92460
|
-
|
|
92461
|
-
|
|
92462
|
-
|
|
92463
|
-
|
|
92464
|
-
|
|
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
|
-
|
|
95065
|
-
|
|
95066
|
-
|
|
95067
|
-
|
|
95125
|
+
/**
|
|
95126
|
+
* Identifies the XX action.
|
|
95127
|
+
* @final
|
|
95128
|
+
* @type {Number}
|
|
95129
|
+
*/
|
|
95130
|
+
this.PAN_LEFT = 0;
|
|
95068
95131
|
|
|
95069
|
-
|
|
95132
|
+
/**
|
|
95133
|
+
* Identifies the XX action.
|
|
95134
|
+
* @final
|
|
95135
|
+
* @type {Number}
|
|
95136
|
+
*/
|
|
95137
|
+
this.PAN_RIGHT = 1;
|
|
95070
95138
|
|
|
95071
|
-
|
|
95072
|
-
|
|
95073
|
-
|
|
95074
|
-
|
|
95075
|
-
|
|
95076
|
-
|
|
95139
|
+
/**
|
|
95140
|
+
* Identifies the XX action.
|
|
95141
|
+
* @final
|
|
95142
|
+
* @type {Number}
|
|
95143
|
+
*/
|
|
95144
|
+
this.PAN_UP = 2;
|
|
95077
95145
|
|
|
95078
|
-
|
|
95079
|
-
|
|
95080
|
-
|
|
95081
|
-
|
|
95082
|
-
|
|
95083
|
-
|
|
95146
|
+
/**
|
|
95147
|
+
* Identifies the XX action.
|
|
95148
|
+
* @final
|
|
95149
|
+
* @type {Number}
|
|
95150
|
+
*/
|
|
95151
|
+
this.PAN_DOWN = 3;
|
|
95084
95152
|
|
|
95085
|
-
|
|
95086
|
-
|
|
95087
|
-
|
|
95088
|
-
|
|
95089
|
-
|
|
95090
|
-
|
|
95153
|
+
/**
|
|
95154
|
+
* Identifies the XX action.
|
|
95155
|
+
* @final
|
|
95156
|
+
* @type {Number}
|
|
95157
|
+
*/
|
|
95158
|
+
this.PAN_FORWARDS = 4;
|
|
95091
95159
|
|
|
95092
|
-
|
|
95093
|
-
|
|
95094
|
-
|
|
95095
|
-
|
|
95096
|
-
|
|
95097
|
-
|
|
95160
|
+
/**
|
|
95161
|
+
* Identifies the XX action.
|
|
95162
|
+
* @final
|
|
95163
|
+
* @type {Number}
|
|
95164
|
+
*/
|
|
95165
|
+
this.PAN_BACKWARDS = 5;
|
|
95098
95166
|
|
|
95099
|
-
|
|
95100
|
-
|
|
95101
|
-
|
|
95102
|
-
|
|
95103
|
-
|
|
95104
|
-
|
|
95167
|
+
/**
|
|
95168
|
+
* Identifies the XX action.
|
|
95169
|
+
* @final
|
|
95170
|
+
* @type {Number}
|
|
95171
|
+
*/
|
|
95172
|
+
this.ROTATE_X_POS = 6;
|
|
95105
95173
|
|
|
95106
|
-
|
|
95107
|
-
|
|
95108
|
-
|
|
95109
|
-
|
|
95110
|
-
|
|
95111
|
-
|
|
95174
|
+
/**
|
|
95175
|
+
* Identifies the XX action.
|
|
95176
|
+
* @final
|
|
95177
|
+
* @type {Number}
|
|
95178
|
+
*/
|
|
95179
|
+
this.ROTATE_X_NEG = 7;
|
|
95112
95180
|
|
|
95113
|
-
|
|
95114
|
-
|
|
95115
|
-
|
|
95116
|
-
|
|
95117
|
-
|
|
95118
|
-
|
|
95181
|
+
/**
|
|
95182
|
+
* Identifies the XX action.
|
|
95183
|
+
* @final
|
|
95184
|
+
* @type {Number}
|
|
95185
|
+
*/
|
|
95186
|
+
this.ROTATE_Y_POS = 8;
|
|
95119
95187
|
|
|
95120
|
-
|
|
95121
|
-
|
|
95122
|
-
|
|
95123
|
-
|
|
95124
|
-
|
|
95125
|
-
|
|
95188
|
+
/**
|
|
95189
|
+
* Identifies the XX action.
|
|
95190
|
+
* @final
|
|
95191
|
+
* @type {Number}
|
|
95192
|
+
*/
|
|
95193
|
+
this.ROTATE_Y_NEG = 9;
|
|
95126
95194
|
|
|
95127
|
-
|
|
95128
|
-
|
|
95129
|
-
|
|
95130
|
-
|
|
95131
|
-
|
|
95132
|
-
|
|
95195
|
+
/**
|
|
95196
|
+
* Identifies the XX action.
|
|
95197
|
+
* @final
|
|
95198
|
+
* @type {Number}
|
|
95199
|
+
*/
|
|
95200
|
+
this.DOLLY_FORWARDS = 10;
|
|
95133
95201
|
|
|
95134
|
-
|
|
95135
|
-
|
|
95136
|
-
|
|
95137
|
-
|
|
95138
|
-
|
|
95139
|
-
|
|
95202
|
+
/**
|
|
95203
|
+
* Identifies the XX action.
|
|
95204
|
+
* @final
|
|
95205
|
+
* @type {Number}
|
|
95206
|
+
*/
|
|
95207
|
+
this.DOLLY_BACKWARDS = 11;
|
|
95140
95208
|
|
|
95141
|
-
|
|
95142
|
-
|
|
95143
|
-
|
|
95144
|
-
|
|
95145
|
-
|
|
95146
|
-
|
|
95209
|
+
/**
|
|
95210
|
+
* Identifies the XX action.
|
|
95211
|
+
* @final
|
|
95212
|
+
* @type {Number}
|
|
95213
|
+
*/
|
|
95214
|
+
this.AXIS_VIEW_RIGHT = 12;
|
|
95147
95215
|
|
|
95148
|
-
|
|
95149
|
-
|
|
95150
|
-
|
|
95151
|
-
|
|
95152
|
-
|
|
95153
|
-
|
|
95216
|
+
/**
|
|
95217
|
+
* Identifies the XX action.
|
|
95218
|
+
* @final
|
|
95219
|
+
* @type {Number}
|
|
95220
|
+
*/
|
|
95221
|
+
this.AXIS_VIEW_BACK = 13;
|
|
95154
95222
|
|
|
95155
|
-
|
|
95156
|
-
|
|
95157
|
-
|
|
95158
|
-
|
|
95159
|
-
|
|
95160
|
-
|
|
95223
|
+
/**
|
|
95224
|
+
* Identifies the XX action.
|
|
95225
|
+
* @final
|
|
95226
|
+
* @type {Number}
|
|
95227
|
+
*/
|
|
95228
|
+
this.AXIS_VIEW_LEFT = 14;
|
|
95161
95229
|
|
|
95162
|
-
|
|
95163
|
-
|
|
95164
|
-
|
|
95165
|
-
|
|
95166
|
-
|
|
95167
|
-
|
|
95230
|
+
/**
|
|
95231
|
+
* Identifies the XX action.
|
|
95232
|
+
* @final
|
|
95233
|
+
* @type {Number}
|
|
95234
|
+
*/
|
|
95235
|
+
this.AXIS_VIEW_FRONT = 15;
|
|
95168
95236
|
|
|
95169
|
-
|
|
95170
|
-
|
|
95171
|
-
|
|
95172
|
-
|
|
95173
|
-
|
|
95174
|
-
|
|
95237
|
+
/**
|
|
95238
|
+
* Identifies the XX action.
|
|
95239
|
+
* @final
|
|
95240
|
+
* @type {Number}
|
|
95241
|
+
*/
|
|
95242
|
+
this.AXIS_VIEW_TOP = 16;
|
|
95175
95243
|
|
|
95176
|
-
|
|
95177
|
-
|
|
95178
|
-
|
|
95179
|
-
|
|
95180
|
-
|
|
95181
|
-
|
|
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
|
-
|
|
95192
|
-
|
|
95193
|
-
* @type {Number}
|
|
95194
|
-
*/
|
|
95195
|
-
this.AXIS_VIEW_BOTTOM = 17;
|
|
95253
|
+
this.scene.canvas.canvas.oncontextmenu = (e) => {
|
|
95254
|
+
e.preventDefault();
|
|
95255
|
+
};
|
|
95196
95256
|
|
|
95197
|
-
|
|
95257
|
+
// User-settable CameraControl configurations
|
|
95198
95258
|
|
|
95199
|
-
|
|
95200
|
-
|
|
95201
|
-
};
|
|
95259
|
+
this._configs = {
|
|
95260
|
+
// Private
|
|
95202
95261
|
|
|
95203
|
-
|
|
95262
|
+
longTapTimeout: 600, // Millisecs
|
|
95263
|
+
longTapRadius: 5, // Pixels
|
|
95204
95264
|
|
|
95205
|
-
|
|
95265
|
+
// General
|
|
95206
95266
|
|
|
95207
|
-
|
|
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
|
-
|
|
95210
|
-
|
|
95281
|
+
snapToVertex: DEFAULT_SNAP_VERTEX,
|
|
95282
|
+
snapToEdge: DEFAULT_SNAP_EDGE,
|
|
95283
|
+
snapRadius: DEFAULT_SNAP_PICK_RADIUS,
|
|
95211
95284
|
|
|
95212
|
-
|
|
95285
|
+
// Rotation
|
|
95213
95286
|
|
|
95214
|
-
|
|
95215
|
-
|
|
95216
|
-
|
|
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
|
-
|
|
95291
|
+
// Panning
|
|
95233
95292
|
|
|
95234
|
-
|
|
95235
|
-
|
|
95236
|
-
|
|
95293
|
+
keyboardPanRate: 1.0,
|
|
95294
|
+
touchPanRate: 1.0,
|
|
95295
|
+
panInertia: 0.5,
|
|
95237
95296
|
|
|
95238
|
-
|
|
95297
|
+
// Dollying
|
|
95239
95298
|
|
|
95240
|
-
|
|
95241
|
-
|
|
95242
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
95255
|
-
|
|
95256
|
-
|
|
95257
|
-
|
|
95258
|
-
|
|
95259
|
-
|
|
95260
|
-
|
|
95261
|
-
|
|
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
|
-
|
|
95336
|
+
// Controllers to assist input event handlers with controlling the Camera
|
|
95273
95337
|
|
|
95274
|
-
|
|
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
|
-
|
|
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
|
-
|
|
95350
|
+
// Input event handlers
|
|
95286
95351
|
|
|
95287
|
-
|
|
95288
|
-
|
|
95289
|
-
|
|
95290
|
-
|
|
95291
|
-
|
|
95292
|
-
|
|
95293
|
-
|
|
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
|
-
|
|
95362
|
+
// Applies scheduled updates to the Camera on each Scene "tick" event
|
|
95298
95363
|
|
|
95299
|
-
|
|
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
|
-
|
|
95366
|
+
// Set initial user configurations
|
|
95310
95367
|
|
|
95311
|
-
|
|
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
|
-
|
|
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
|
-
|
|
95316
|
-
|
|
95317
|
-
|
|
95318
|
-
|
|
95319
|
-
|
|
95320
|
-
|
|
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
|
-
|
|
95346
|
-
|
|
95347
|
-
|
|
95348
|
-
|
|
95349
|
-
|
|
95350
|
-
|
|
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
|
-
|
|
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
|
-
|
|
95361
|
-
|
|
95362
|
-
|
|
95363
|
-
|
|
95364
|
-
|
|
95365
|
-
|
|
95366
|
-
|
|
95367
|
-
|
|
95368
|
-
|
|
95369
|
-
|
|
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
|
-
|
|
95385
|
-
|
|
95386
|
-
|
|
95387
|
-
|
|
95388
|
-
|
|
95389
|
-
|
|
95390
|
-
|
|
95391
|
-
|
|
95392
|
-
|
|
95393
|
-
|
|
95394
|
-
|
|
95395
|
-
|
|
95396
|
-
|
|
95397
|
-
|
|
95398
|
-
|
|
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
|
-
|
|
95407
|
-
|
|
95408
|
-
|
|
95409
|
-
|
|
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
|
-
|
|
95415
|
-
|
|
95416
|
-
|
|
95417
|
-
|
|
95418
|
-
|
|
95419
|
-
|
|
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
|
-
|
|
95424
|
-
|
|
95425
|
-
|
|
95426
|
-
|
|
95427
|
-
|
|
95428
|
-
|
|
95429
|
-
|
|
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
|
-
|
|
95447
|
-
|
|
95448
|
-
|
|
95449
|
-
|
|
95450
|
-
|
|
95451
|
-
|
|
95452
|
-
|
|
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
|
-
|
|
95458
|
-
|
|
95459
|
-
|
|
95460
|
-
|
|
95461
|
-
|
|
95462
|
-
|
|
95463
|
-
|
|
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
|
-
|
|
95474
|
-
|
|
95475
|
-
|
|
95476
|
-
|
|
95477
|
-
|
|
95478
|
-
|
|
95479
|
-
|
|
95480
|
-
|
|
95481
|
-
|
|
95482
|
-
|
|
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
|
-
|
|
95487
|
-
|
|
95488
|
-
|
|
95489
|
-
|
|
95490
|
-
|
|
95491
|
-
|
|
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
|
-
|
|
95496
|
-
|
|
95497
|
-
|
|
95498
|
-
|
|
95499
|
-
|
|
95500
|
-
|
|
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
|
-
|
|
95505
|
-
|
|
95506
|
-
|
|
95507
|
-
|
|
95508
|
-
|
|
95509
|
-
|
|
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
|
-
|
|
95514
|
-
|
|
95515
|
-
|
|
95516
|
-
|
|
95517
|
-
|
|
95518
|
-
|
|
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
|
-
|
|
95523
|
-
|
|
95524
|
-
|
|
95525
|
-
|
|
95526
|
-
|
|
95527
|
-
|
|
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
|
-
|
|
95536
|
-
|
|
95537
|
-
|
|
95538
|
-
|
|
95539
|
-
|
|
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
|
-
|
|
95612
|
-
|
|
95613
|
-
|
|
95614
|
-
|
|
95615
|
-
|
|
95616
|
-
|
|
95617
|
-
|
|
95618
|
-
|
|
95619
|
-
|
|
95620
|
-
|
|
95621
|
-
|
|
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
|
-
|
|
95626
|
-
|
|
95627
|
-
|
|
95628
|
-
|
|
95629
|
-
|
|
95630
|
-
|
|
95631
|
-
|
|
95632
|
-
|
|
95633
|
-
|
|
95634
|
-
|
|
95635
|
-
|
|
95636
|
-
|
|
95637
|
-
|
|
95638
|
-
|
|
95639
|
-
|
|
95640
|
-
|
|
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
|
-
|
|
95645
|
-
|
|
95646
|
-
|
|
95647
|
-
|
|
95648
|
-
|
|
95649
|
-
|
|
95650
|
-
|
|
95651
|
-
|
|
95652
|
-
|
|
95653
|
-
|
|
95654
|
-
|
|
95655
|
-
|
|
95656
|
-
|
|
95657
|
-
|
|
95658
|
-
|
|
95659
|
-
|
|
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
|
-
|
|
95664
|
-
|
|
95665
|
-
|
|
95666
|
-
|
|
95667
|
-
|
|
95668
|
-
|
|
95669
|
-
|
|
95670
|
-
|
|
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
|
-
|
|
95675
|
-
|
|
95676
|
-
|
|
95677
|
-
|
|
95678
|
-
|
|
95679
|
-
|
|
95680
|
-
|
|
95681
|
-
|
|
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
|
-
|
|
95686
|
-
|
|
95687
|
-
|
|
95688
|
-
|
|
95689
|
-
|
|
95690
|
-
|
|
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
|
-
|
|
95695
|
-
|
|
95696
|
-
|
|
95697
|
-
|
|
95698
|
-
|
|
95699
|
-
|
|
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
|
-
|
|
95704
|
-
|
|
95705
|
-
|
|
95706
|
-
|
|
95707
|
-
|
|
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
|
-
|
|
95712
|
-
|
|
95713
|
-
|
|
95714
|
-
|
|
95715
|
-
|
|
95716
|
-
|
|
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
|
-
|
|
95721
|
-
|
|
95722
|
-
|
|
95723
|
-
|
|
95724
|
-
|
|
95725
|
-
|
|
95726
|
-
|
|
95727
|
-
|
|
95728
|
-
|
|
95729
|
-
|
|
95730
|
-
|
|
95731
|
-
|
|
95732
|
-
|
|
95733
|
-
|
|
95734
|
-
|
|
95735
|
-
|
|
95736
|
-
|
|
95737
|
-
|
|
95738
|
-
|
|
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
|
-
|
|
95743
|
-
|
|
95744
|
-
|
|
95745
|
-
|
|
95746
|
-
|
|
95747
|
-
|
|
95748
|
-
|
|
95749
|
-
|
|
95750
|
-
|
|
95751
|
-
|
|
95752
|
-
|
|
95753
|
-
|
|
95754
|
-
|
|
95755
|
-
|
|
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
|
-
|
|
95760
|
-
|
|
95761
|
-
|
|
95762
|
-
|
|
95763
|
-
|
|
95764
|
-
|
|
95765
|
-
|
|
95766
|
-
|
|
95767
|
-
|
|
95768
|
-
|
|
95769
|
-
|
|
95770
|
-
|
|
95771
|
-
|
|
95772
|
-
|
|
95773
|
-
|
|
95774
|
-
|
|
95775
|
-
|
|
95776
|
-
|
|
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
|
-
|
|
95782
|
-
|
|
95783
|
-
|
|
95784
|
-
|
|
95785
|
-
|
|
95786
|
-
|
|
95787
|
-
|
|
95788
|
-
|
|
95789
|
-
|
|
95790
|
-
|
|
95791
|
-
|
|
95792
|
-
|
|
95793
|
-
|
|
95794
|
-
|
|
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
|
-
|
|
95799
|
-
|
|
95800
|
-
|
|
95801
|
-
|
|
95802
|
-
|
|
95803
|
-
|
|
95804
|
-
|
|
95805
|
-
|
|
95806
|
-
|
|
95807
|
-
|
|
95808
|
-
|
|
95809
|
-
|
|
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
|
-
|
|
95814
|
-
|
|
95815
|
-
|
|
95816
|
-
|
|
95817
|
-
|
|
95818
|
-
|
|
95819
|
-
|
|
95820
|
-
|
|
95821
|
-
|
|
95822
|
-
|
|
95823
|
-
|
|
95824
|
-
|
|
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
|
-
|
|
95829
|
-
|
|
95830
|
-
|
|
95831
|
-
|
|
95832
|
-
|
|
95833
|
-
|
|
95834
|
-
|
|
95835
|
-
|
|
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
|
-
|
|
95840
|
-
|
|
95841
|
-
|
|
95842
|
-
|
|
95843
|
-
|
|
95844
|
-
|
|
95845
|
-
|
|
95846
|
-
|
|
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
|
-
|
|
95851
|
-
|
|
95852
|
-
|
|
95853
|
-
|
|
95854
|
-
|
|
95855
|
-
|
|
95856
|
-
|
|
95857
|
-
|
|
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
|
-
|
|
95862
|
-
|
|
95863
|
-
|
|
95864
|
-
|
|
95865
|
-
|
|
95866
|
-
|
|
95867
|
-
|
|
95868
|
-
|
|
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
|
-
|
|
95873
|
-
|
|
95874
|
-
|
|
95875
|
-
|
|
95876
|
-
|
|
95877
|
-
|
|
95878
|
-
|
|
95879
|
-
|
|
95880
|
-
|
|
95881
|
-
|
|
95882
|
-
|
|
95883
|
-
|
|
95884
|
-
|
|
95885
|
-
|
|
95886
|
-
|
|
95887
|
-
|
|
95888
|
-
|
|
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
|
-
|
|
95893
|
-
|
|
95894
|
-
|
|
95895
|
-
|
|
95896
|
-
|
|
95897
|
-
|
|
95898
|
-
|
|
95899
|
-
|
|
95900
|
-
|
|
95901
|
-
|
|
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
|
-
|
|
95906
|
-
|
|
95907
|
-
|
|
95908
|
-
|
|
95909
|
-
|
|
95910
|
-
|
|
95911
|
-
|
|
95912
|
-
|
|
95913
|
-
|
|
95914
|
-
|
|
95915
|
-
|
|
95916
|
-
|
|
95917
|
-
|
|
95918
|
-
|
|
95919
|
-
|
|
95920
|
-
|
|
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
|
-
|
|
95926
|
-
|
|
95927
|
-
|
|
95928
|
-
|
|
95929
|
-
|
|
95930
|
-
|
|
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
|
-
|
|
95935
|
-
|
|
95936
|
-
|
|
95937
|
-
|
|
95938
|
-
|
|
95939
|
-
|
|
95940
|
-
|
|
95941
|
-
|
|
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
|
-
|
|
95946
|
-
|
|
95947
|
-
|
|
95948
|
-
|
|
95949
|
-
|
|
95950
|
-
|
|
95951
|
-
|
|
95952
|
-
|
|
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
|
-
|
|
95957
|
-
|
|
95958
|
-
|
|
95959
|
-
|
|
95960
|
-
|
|
95961
|
-
|
|
95962
|
-
|
|
95963
|
-
|
|
95964
|
-
|
|
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
|
-
|
|
95970
|
-
|
|
95971
|
-
|
|
95972
|
-
|
|
95973
|
-
|
|
95974
|
-
|
|
95975
|
-
|
|
95976
|
-
|
|
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
|
-
|
|
95981
|
-
|
|
95982
|
-
|
|
95983
|
-
|
|
95984
|
-
|
|
95985
|
-
|
|
95986
|
-
|
|
95987
|
-
|
|
95988
|
-
|
|
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
|
-
|
|
96001
|
-
|
|
96002
|
-
|
|
96003
|
-
|
|
96004
|
-
|
|
96005
|
-
|
|
96006
|
-
|
|
96007
|
-
|
|
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
|
-
|
|
96012
|
-
|
|
96013
|
-
|
|
96014
|
-
|
|
96015
|
-
|
|
96016
|
-
|
|
96017
|
-
|
|
96018
|
-
|
|
96019
|
-
|
|
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
|
-
|
|
96024
|
-
|
|
96025
|
-
|
|
96026
|
-
|
|
96027
|
-
|
|
96028
|
-
|
|
96029
|
-
|
|
96030
|
-
|
|
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
|
-
|
|
96035
|
-
|
|
96036
|
-
|
|
96037
|
-
|
|
96038
|
-
|
|
96039
|
-
|
|
96040
|
-
|
|
96041
|
-
|
|
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
|
-
|
|
96046
|
-
|
|
96047
|
-
|
|
96048
|
-
|
|
96049
|
-
|
|
96050
|
-
|
|
96051
|
-
|
|
96052
|
-
|
|
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
|
-
|
|
96057
|
-
|
|
96058
|
-
|
|
96059
|
-
|
|
96060
|
-
|
|
96061
|
-
|
|
96062
|
-
|
|
96063
|
-
|
|
96064
|
-
|
|
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
|
-
|
|
96069
|
-
|
|
96070
|
-
|
|
96071
|
-
|
|
96072
|
-
|
|
96073
|
-
|
|
96074
|
-
|
|
96075
|
-
|
|
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
|
-
|
|
96080
|
-
|
|
96081
|
-
|
|
96082
|
-
|
|
96083
|
-
|
|
96084
|
-
|
|
96085
|
-
|
|
96086
|
-
|
|
96087
|
-
|
|
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
|
-
|
|
96101
|
-
|
|
96102
|
-
|
|
96103
|
-
|
|
96104
|
-
|
|
96105
|
-
|
|
96106
|
-
|
|
96107
|
-
|
|
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
|
-
|
|
96112
|
-
|
|
96113
|
-
|
|
96114
|
-
|
|
96115
|
-
|
|
96116
|
-
|
|
96117
|
-
|
|
96118
|
-
|
|
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
|
-
|
|
96123
|
-
|
|
96124
|
-
|
|
96125
|
-
|
|
96126
|
-
|
|
96127
|
-
|
|
96128
|
-
|
|
96129
|
-
|
|
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
|
-
|
|
96134
|
-
|
|
96135
|
-
|
|
96136
|
-
|
|
96137
|
-
|
|
96138
|
-
|
|
96139
|
-
|
|
96140
|
-
|
|
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
|
-
|
|
96145
|
-
|
|
96146
|
-
|
|
96147
|
-
|
|
96148
|
-
|
|
96149
|
-
|
|
96150
|
-
|
|
96151
|
-
|
|
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
|
-
|
|
96156
|
-
|
|
96157
|
-
|
|
96158
|
-
|
|
96159
|
-
|
|
96160
|
-
|
|
96161
|
-
|
|
96162
|
-
|
|
96163
|
-
|
|
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
|
-
|
|
96177
|
-
|
|
96178
|
-
|
|
96179
|
-
|
|
96180
|
-
|
|
96181
|
-
|
|
96182
|
-
|
|
96183
|
-
|
|
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
|
-
|
|
96188
|
-
|
|
96189
|
-
|
|
96190
|
-
|
|
96191
|
-
|
|
96192
|
-
|
|
96193
|
-
|
|
96194
|
-
|
|
96195
|
-
|
|
96196
|
-
|
|
96197
|
-
|
|
96198
|
-
|
|
96199
|
-
|
|
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
|
-
|
|
96210
|
-
|
|
96211
|
-
|
|
96212
|
-
|
|
96213
|
-
|
|
96214
|
-
|
|
96215
|
-
|
|
96216
|
-
|
|
96217
|
-
|
|
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
|
-
|
|
96225
|
-
|
|
96226
|
-
|
|
96227
|
-
|
|
96228
|
-
|
|
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
|
-
|
|
96236
|
-
|
|
96237
|
-
|
|
96238
|
-
|
|
96239
|
-
|
|
96240
|
-
|
|
96241
|
-
|
|
96242
|
-
|
|
96243
|
-
|
|
96244
|
-
|
|
96245
|
-
|
|
96246
|
-
|
|
96247
|
-
|
|
96248
|
-
|
|
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
|
-
|
|
96260
|
-
|
|
96261
|
-
|
|
96262
|
-
|
|
96263
|
-
|
|
96264
|
-
|
|
96265
|
-
|
|
96266
|
-
|
|
96267
|
-
|
|
96268
|
-
|
|
96269
|
-
|
|
96270
|
-
|
|
96271
|
-
|
|
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
|
-
|
|
96276
|
-
|
|
96277
|
-
|
|
96278
|
-
|
|
96279
|
-
|
|
96280
|
-
|
|
96281
|
-
|
|
96282
|
-
|
|
96283
|
-
|
|
96284
|
-
|
|
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
|
-
|
|
96289
|
-
|
|
96290
|
-
|
|
96291
|
-
|
|
96292
|
-
|
|
96293
|
-
|
|
96294
|
-
|
|
96295
|
-
|
|
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
|
-
|
|
96300
|
-
|
|
96301
|
-
|
|
96302
|
-
|
|
96303
|
-
|
|
96304
|
-
|
|
96305
|
-
|
|
96306
|
-
|
|
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
|
-
|
|
96310
|
-
|
|
96311
|
-
|
|
96312
|
-
|
|
96313
|
-
|
|
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
|
-
|
|
96319
|
-
|
|
96320
|
-
|
|
96321
|
-
|
|
96322
|
-
|
|
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
|
/**
|