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