@xtctwins/tctwins-core 1.0.26 → 1.0.28
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.es.js
CHANGED
|
@@ -11669,7 +11669,7 @@ class AngleMeasurement extends Component {
|
|
|
11669
11669
|
/**
|
|
11670
11670
|
* Gets the color of the angle measurement.
|
|
11671
11671
|
*
|
|
11672
|
-
* The color is an HTML string representation, eg. "#
|
|
11672
|
+
* The color is an HTML string representation, eg. "#0065fc" and "blue".
|
|
11673
11673
|
*
|
|
11674
11674
|
* @type {String}
|
|
11675
11675
|
*/
|
|
@@ -12772,7 +12772,7 @@ class AngleMeasurementsPlugin extends Plugin {
|
|
|
12772
12772
|
|
|
12773
12773
|
this._measurements = {};
|
|
12774
12774
|
|
|
12775
|
-
this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#
|
|
12775
|
+
this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#0065fc";
|
|
12776
12776
|
this.defaultLabelsVisible = cfg.defaultLabelsVisible !== false;
|
|
12777
12777
|
this.zIndex = cfg.zIndex || 10000;
|
|
12778
12778
|
|
|
@@ -32045,13 +32045,13 @@ class Scene extends Component {
|
|
|
32045
32045
|
*/
|
|
32046
32046
|
destroy(callback) {
|
|
32047
32047
|
super.destroy();
|
|
32048
|
-
|
|
32049
32048
|
for (const id in this.components) {
|
|
32050
32049
|
if (this.components.hasOwnProperty(id)) {
|
|
32051
32050
|
this.components[id].destroy();
|
|
32052
32051
|
}
|
|
32053
32052
|
}
|
|
32054
|
-
this.canvas.destroy();
|
|
32053
|
+
// this.canvas.destroy(); // canvas是scene的其中一个component,所有以不必再destroy
|
|
32054
|
+
|
|
32055
32055
|
// Memory leak prevention
|
|
32056
32056
|
this.components = null;
|
|
32057
32057
|
this.models = null;
|
|
@@ -32073,13 +32073,14 @@ class Scene extends Component {
|
|
|
32073
32073
|
this._selectedObjectIds = null;
|
|
32074
32074
|
this._colorizedObjectIds = null;
|
|
32075
32075
|
this.types = null;
|
|
32076
|
-
this.components = null;
|
|
32077
|
-
this.canvas = null;
|
|
32078
32076
|
this._renderer = null;
|
|
32079
32077
|
this.input = null;
|
|
32080
32078
|
this._viewport = null;
|
|
32081
32079
|
this._camera = null;
|
|
32082
|
-
|
|
32080
|
+
this.canvas = null;
|
|
32081
|
+
if (typeof callback === "function") {
|
|
32082
|
+
callback();
|
|
32083
|
+
}
|
|
32083
32084
|
}
|
|
32084
32085
|
}
|
|
32085
32086
|
|
|
@@ -42161,149 +42162,155 @@ math.vec3();
|
|
|
42161
42162
|
* ````
|
|
42162
42163
|
*/
|
|
42163
42164
|
class SectionPlane extends Component {
|
|
42164
|
-
|
|
42165
|
-
/**
|
|
42165
|
+
/**
|
|
42166
42166
|
@private
|
|
42167
42167
|
*/
|
|
42168
|
-
|
|
42169
|
-
|
|
42170
|
-
|
|
42168
|
+
get type() {
|
|
42169
|
+
return "SectionPlane";
|
|
42170
|
+
}
|
|
42171
42171
|
|
|
42172
|
-
|
|
42173
|
-
|
|
42174
|
-
|
|
42175
|
-
|
|
42176
|
-
|
|
42177
|
-
|
|
42178
|
-
|
|
42179
|
-
|
|
42180
|
-
|
|
42181
|
-
|
|
42172
|
+
/**
|
|
42173
|
+
* @constructor
|
|
42174
|
+
* @param {Component} [owner] Owner component. When destroyed, the owner will destroy this SectionPlane as well.
|
|
42175
|
+
* @param {*} [cfg] SectionPlane configuration
|
|
42176
|
+
* @param {String} [cfg.id] Optional ID, unique among all components in the parent {@link Scene}, generated automatically when omitted.
|
|
42177
|
+
* @param {Boolean} [cfg.active=true] Indicates whether or not this SectionPlane is active.
|
|
42178
|
+
* @param {Number[]} [cfg.pos=[0,0,0]] World-space position of the SectionPlane.
|
|
42179
|
+
* @param {Number[]} [cfg.dir=[0,0,-1]] Vector perpendicular to the plane surface, indicating the SectionPlane plane orientation.
|
|
42180
|
+
*/
|
|
42181
|
+
constructor(owner, cfg = {}) {
|
|
42182
|
+
super(owner, cfg);
|
|
42182
42183
|
|
|
42183
|
-
|
|
42184
|
+
this._state = new RenderState({
|
|
42185
|
+
active: true,
|
|
42186
|
+
pos: math.vec3(),
|
|
42187
|
+
dir: math.vec3(),
|
|
42188
|
+
dist: 0
|
|
42189
|
+
});
|
|
42184
42190
|
|
|
42185
|
-
|
|
42186
|
-
|
|
42187
|
-
|
|
42188
|
-
dir: math.vec3(),
|
|
42189
|
-
dist: 0
|
|
42190
|
-
});
|
|
42191
|
+
this.active = cfg.active;
|
|
42192
|
+
this.pos = cfg.pos;
|
|
42193
|
+
this.dir = cfg.dir;
|
|
42191
42194
|
|
|
42192
|
-
|
|
42193
|
-
|
|
42194
|
-
this.dir = cfg.dir;
|
|
42195
|
+
this.scene._sectionPlaneCreated(this);
|
|
42196
|
+
}
|
|
42195
42197
|
|
|
42196
|
-
|
|
42197
|
-
|
|
42198
|
+
set control(control) {
|
|
42199
|
+
this._control = control;
|
|
42200
|
+
}
|
|
42198
42201
|
|
|
42199
|
-
|
|
42200
|
-
|
|
42201
|
-
|
|
42202
|
-
* Default value is ````true````.
|
|
42203
|
-
*
|
|
42204
|
-
* @param {Boolean} value Set ````true```` to activate else ````false```` to deactivate.
|
|
42205
|
-
*/
|
|
42206
|
-
set active(value) {
|
|
42207
|
-
this._state.active = value !== false;
|
|
42208
|
-
this.glRedraw();
|
|
42209
|
-
this.fire("active", this._state.active);
|
|
42210
|
-
}
|
|
42202
|
+
get control() {
|
|
42203
|
+
return this._control;
|
|
42204
|
+
}
|
|
42211
42205
|
|
|
42212
|
-
|
|
42213
|
-
|
|
42214
|
-
|
|
42215
|
-
|
|
42216
|
-
|
|
42217
|
-
|
|
42218
|
-
|
|
42219
|
-
|
|
42220
|
-
|
|
42221
|
-
|
|
42206
|
+
/**
|
|
42207
|
+
* Sets if this SectionPlane is active or not.
|
|
42208
|
+
*
|
|
42209
|
+
* Default value is ````true````.
|
|
42210
|
+
*
|
|
42211
|
+
* @param {Boolean} value Set ````true```` to activate else ````false```` to deactivate.
|
|
42212
|
+
*/
|
|
42213
|
+
set active(value) {
|
|
42214
|
+
this._state.active = value !== false;
|
|
42215
|
+
this.glRedraw();
|
|
42216
|
+
this.fire("active", this._state.active);
|
|
42217
|
+
}
|
|
42222
42218
|
|
|
42223
|
-
|
|
42224
|
-
|
|
42225
|
-
|
|
42226
|
-
|
|
42227
|
-
|
|
42228
|
-
|
|
42229
|
-
|
|
42230
|
-
|
|
42231
|
-
|
|
42232
|
-
|
|
42233
|
-
this.fire("pos", this._state.pos);
|
|
42234
|
-
this.scene.fire("sectionPlaneUpdated", this);
|
|
42235
|
-
}
|
|
42219
|
+
/**
|
|
42220
|
+
* Gets if this SectionPlane is active or not.
|
|
42221
|
+
*
|
|
42222
|
+
* Default value is ````true````.
|
|
42223
|
+
*
|
|
42224
|
+
* @returns {Boolean} Returns ````true```` if active.
|
|
42225
|
+
*/
|
|
42226
|
+
get active() {
|
|
42227
|
+
return this._state.active;
|
|
42228
|
+
}
|
|
42236
42229
|
|
|
42237
|
-
|
|
42238
|
-
|
|
42239
|
-
|
|
42240
|
-
|
|
42241
|
-
|
|
42242
|
-
|
|
42243
|
-
|
|
42244
|
-
|
|
42245
|
-
|
|
42246
|
-
|
|
42230
|
+
/**
|
|
42231
|
+
* Sets the World-space position of this SectionPlane's plane.
|
|
42232
|
+
*
|
|
42233
|
+
* Default value is ````[0, 0, 0]````.
|
|
42234
|
+
*
|
|
42235
|
+
* @param {Number[]} value New position.
|
|
42236
|
+
*/
|
|
42237
|
+
set pos(value) {
|
|
42238
|
+
this._state.pos.set(value || [0, 0, 0]);
|
|
42239
|
+
this._state.dist = -math.dotVec3(this._state.pos, this._state.dir);
|
|
42240
|
+
this.fire("pos", this._state.pos);
|
|
42241
|
+
this.scene.fire("sectionPlaneUpdated", this);
|
|
42242
|
+
}
|
|
42247
42243
|
|
|
42248
|
-
|
|
42249
|
-
|
|
42250
|
-
|
|
42251
|
-
|
|
42252
|
-
|
|
42253
|
-
|
|
42254
|
-
|
|
42255
|
-
|
|
42256
|
-
|
|
42257
|
-
|
|
42258
|
-
this.glRedraw();
|
|
42259
|
-
this.fire("dir", this._state.dir);
|
|
42260
|
-
this.scene.fire("sectionPlaneUpdated", this);
|
|
42261
|
-
}
|
|
42244
|
+
/**
|
|
42245
|
+
* Gets the World-space position of this SectionPlane's plane.
|
|
42246
|
+
*
|
|
42247
|
+
* Default value is ````[0, 0, 0]````.
|
|
42248
|
+
*
|
|
42249
|
+
* @returns {Number[]} Current position.
|
|
42250
|
+
*/
|
|
42251
|
+
get pos() {
|
|
42252
|
+
return this._state.pos;
|
|
42253
|
+
}
|
|
42262
42254
|
|
|
42263
|
-
|
|
42264
|
-
|
|
42265
|
-
|
|
42266
|
-
|
|
42267
|
-
|
|
42268
|
-
|
|
42269
|
-
|
|
42270
|
-
|
|
42271
|
-
|
|
42272
|
-
|
|
42255
|
+
/**
|
|
42256
|
+
* Sets the direction of this SectionPlane's plane.
|
|
42257
|
+
*
|
|
42258
|
+
* Default value is ````[0, 0, -1]````.
|
|
42259
|
+
*
|
|
42260
|
+
* @param {Number[]} value New direction.
|
|
42261
|
+
*/
|
|
42262
|
+
set dir(value) {
|
|
42263
|
+
this._state.dir.set(value || [0, 0, -1]);
|
|
42264
|
+
this._state.dist = -math.dotVec3(this._state.pos, this._state.dir);
|
|
42265
|
+
this.glRedraw();
|
|
42266
|
+
this.fire("dir", this._state.dir);
|
|
42267
|
+
this.scene.fire("sectionPlaneUpdated", this);
|
|
42268
|
+
}
|
|
42273
42269
|
|
|
42274
|
-
|
|
42275
|
-
|
|
42276
|
-
|
|
42277
|
-
|
|
42278
|
-
|
|
42279
|
-
|
|
42280
|
-
|
|
42281
|
-
|
|
42282
|
-
|
|
42283
|
-
|
|
42284
|
-
}
|
|
42270
|
+
/**
|
|
42271
|
+
* Gets the direction of this SectionPlane's plane.
|
|
42272
|
+
*
|
|
42273
|
+
* Default value is ````[0, 0, -1]````.
|
|
42274
|
+
*
|
|
42275
|
+
* @returns {Number[]} value Current direction.
|
|
42276
|
+
*/
|
|
42277
|
+
get dir() {
|
|
42278
|
+
return this._state.dir;
|
|
42279
|
+
}
|
|
42285
42280
|
|
|
42286
|
-
|
|
42287
|
-
|
|
42288
|
-
|
|
42289
|
-
|
|
42290
|
-
|
|
42291
|
-
|
|
42292
|
-
|
|
42293
|
-
|
|
42294
|
-
|
|
42295
|
-
|
|
42296
|
-
|
|
42297
|
-
}
|
|
42281
|
+
/**
|
|
42282
|
+
* Gets this SectionPlane's distance to the origin of the World-space coordinate system.
|
|
42283
|
+
*
|
|
42284
|
+
* This is the dot product of {@link SectionPlane#pos} and {@link SectionPlane#dir} and is automatically re-calculated
|
|
42285
|
+
* each time either of two properties are updated.
|
|
42286
|
+
*
|
|
42287
|
+
* @returns {Number}
|
|
42288
|
+
*/
|
|
42289
|
+
get dist() {
|
|
42290
|
+
return this._state.dist;
|
|
42291
|
+
}
|
|
42298
42292
|
|
|
42299
|
-
|
|
42300
|
-
|
|
42301
|
-
|
|
42302
|
-
|
|
42303
|
-
|
|
42304
|
-
|
|
42305
|
-
|
|
42306
|
-
|
|
42293
|
+
/**
|
|
42294
|
+
* Inverts the direction of {@link SectionPlane#dir}.
|
|
42295
|
+
*/
|
|
42296
|
+
flipDir() {
|
|
42297
|
+
const dir = this._state.dir;
|
|
42298
|
+
dir[0] *= -1.0;
|
|
42299
|
+
dir[1] *= -1.0;
|
|
42300
|
+
dir[2] *= -1.0;
|
|
42301
|
+
this._state.dist = -math.dotVec3(this._state.pos, this._state.dir);
|
|
42302
|
+
this.fire("dir", this._state.dir);
|
|
42303
|
+
this.glRedraw();
|
|
42304
|
+
}
|
|
42305
|
+
|
|
42306
|
+
/**
|
|
42307
|
+
* @destroy
|
|
42308
|
+
*/
|
|
42309
|
+
destroy() {
|
|
42310
|
+
this._state.destroy();
|
|
42311
|
+
this.scene._sectionPlaneDestroyed(this);
|
|
42312
|
+
super.destroy();
|
|
42313
|
+
}
|
|
42307
42314
|
}
|
|
42308
42315
|
|
|
42309
42316
|
const angleAxis$1 = math.vec4(4);
|
|
@@ -87717,7 +87724,7 @@ class DistanceMeasurementsPlugin extends Plugin {
|
|
|
87717
87724
|
* @param {boolean} [cfg.defaultXAxisVisible=true] The default value of the DistanceMeasurements `xAxisVisible` property.
|
|
87718
87725
|
* @param {boolean} [cfg.defaultYAxisVisible=true] The default value of the DistanceMeasurements `yAxisVisible` property.
|
|
87719
87726
|
* @param {boolean} [cfg.defaultZAxisVisible=true] The default value of the DistanceMeasurements `zAxisVisible` property.
|
|
87720
|
-
* @param {string} [cfg.defaultColor=#
|
|
87727
|
+
* @param {string} [cfg.defaultColor=#0065fc] The default color of the length dots, wire and label.
|
|
87721
87728
|
* @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
|
|
87722
87729
|
* @param {boolean} [cfg.defaultLabelsOnWires=true] The default value of the DistanceMeasurements `labelsOnWires` property.
|
|
87723
87730
|
* @param {PointerCircle} [cfg.pointerLens] A PointerLens to help the user position the pointer. This can be shared with other plugins.
|
|
@@ -87744,7 +87751,7 @@ class DistanceMeasurementsPlugin extends Plugin {
|
|
|
87744
87751
|
this.defaultXAxisVisible = cfg.defaultXAxisVisible !== false;
|
|
87745
87752
|
this.defaultYAxisVisible = cfg.defaultYAxisVisible !== false;
|
|
87746
87753
|
this.defaultZAxisVisible = cfg.defaultZAxisVisible !== false;
|
|
87747
|
-
this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#
|
|
87754
|
+
this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#0065fc";
|
|
87748
87755
|
this.zIndex = cfg.zIndex || 10000;
|
|
87749
87756
|
this.defaultLabelsOnWires = cfg.defaultLabelsOnWires !== false;
|
|
87750
87757
|
|
|
@@ -91342,7 +91349,7 @@ CameraPathAnimation.PLAYING_TO = 3;
|
|
|
91342
91349
|
const tempVec3$3 = math.vec3();
|
|
91343
91350
|
const tempVec3b$5 = math.vec3();
|
|
91344
91351
|
math.vec3();
|
|
91345
|
-
const zeroVec$
|
|
91352
|
+
const zeroVec$4 = math.vec3([0, -1, 0]);
|
|
91346
91353
|
const tempQuat = math.vec4([0, 0, 0, 1]);
|
|
91347
91354
|
|
|
91348
91355
|
/**
|
|
@@ -91769,7 +91776,7 @@ class ImagePlane extends Component {
|
|
|
91769
91776
|
|
|
91770
91777
|
math.normalizeVec3(negDir);
|
|
91771
91778
|
math.mulVec3Scalar(negDir, dist, tempVec3b$5);
|
|
91772
|
-
math.vec3PairToQuaternion(zeroVec$
|
|
91779
|
+
math.vec3PairToQuaternion(zeroVec$4, dir, tempQuat);
|
|
91773
91780
|
|
|
91774
91781
|
this._node.quaternion = tempQuat;
|
|
91775
91782
|
}
|
|
@@ -95195,7 +95202,7 @@ class MousePanRotateDollyHandler {
|
|
|
95195
95202
|
|
|
95196
95203
|
let mouseMovedOnCanvasSinceLastWheel = true;
|
|
95197
95204
|
|
|
95198
|
-
|
|
95205
|
+
this.canvas = this._scene.canvas.canvas;
|
|
95199
95206
|
|
|
95200
95207
|
const keyDown = [];
|
|
95201
95208
|
|
|
@@ -95221,13 +95228,13 @@ class MousePanRotateDollyHandler {
|
|
|
95221
95228
|
})
|
|
95222
95229
|
);
|
|
95223
95230
|
|
|
95224
|
-
|
|
95225
|
-
canvas.style.cursor = "move";
|
|
95231
|
+
const setMousedownState = (pick = true) => {
|
|
95232
|
+
this.canvas.style.cursor = "move";
|
|
95226
95233
|
setMousedownPositions();
|
|
95227
95234
|
if (pick) {
|
|
95228
95235
|
setMousedownPick();
|
|
95229
95236
|
}
|
|
95230
|
-
}
|
|
95237
|
+
};
|
|
95231
95238
|
|
|
95232
95239
|
function setMousedownPositions() {
|
|
95233
95240
|
|
|
@@ -95255,7 +95262,7 @@ class MousePanRotateDollyHandler {
|
|
|
95255
95262
|
}
|
|
95256
95263
|
}
|
|
95257
95264
|
|
|
95258
|
-
canvas.addEventListener(
|
|
95265
|
+
this.canvas.addEventListener(
|
|
95259
95266
|
"mousedown",
|
|
95260
95267
|
(this._mouseDownHandler = (e) => {
|
|
95261
95268
|
if (!(configs.active && configs.pointerEnabled)) {
|
|
@@ -95362,7 +95369,7 @@ class MousePanRotateDollyHandler {
|
|
|
95362
95369
|
})
|
|
95363
95370
|
);
|
|
95364
95371
|
|
|
95365
|
-
canvas.addEventListener(
|
|
95372
|
+
this.canvas.addEventListener(
|
|
95366
95373
|
"mousemove",
|
|
95367
95374
|
(this._canvasMouseMoveHandler = (e) => {
|
|
95368
95375
|
if (!(configs.active && configs.pointerEnabled)) {
|
|
@@ -95403,7 +95410,7 @@ class MousePanRotateDollyHandler {
|
|
|
95403
95410
|
})
|
|
95404
95411
|
);
|
|
95405
95412
|
|
|
95406
|
-
canvas.addEventListener(
|
|
95413
|
+
this.canvas.addEventListener(
|
|
95407
95414
|
"mouseup",
|
|
95408
95415
|
(this._mouseUpHandler = (e) => {
|
|
95409
95416
|
if (!(configs.active && configs.pointerEnabled)) {
|
|
@@ -95428,11 +95435,11 @@ class MousePanRotateDollyHandler {
|
|
|
95428
95435
|
}
|
|
95429
95436
|
break;
|
|
95430
95437
|
}
|
|
95431
|
-
canvas.style.removeProperty("cursor");
|
|
95438
|
+
this.canvas.style.removeProperty("cursor");
|
|
95432
95439
|
})
|
|
95433
95440
|
);
|
|
95434
95441
|
|
|
95435
|
-
canvas.addEventListener(
|
|
95442
|
+
this.canvas.addEventListener(
|
|
95436
95443
|
"mouseenter",
|
|
95437
95444
|
(this._mouseEnterHandler = () => {
|
|
95438
95445
|
if (!(configs.active && configs.pointerEnabled)) {
|
|
@@ -95446,7 +95453,7 @@ class MousePanRotateDollyHandler {
|
|
|
95446
95453
|
|
|
95447
95454
|
let secsNowLast = null;
|
|
95448
95455
|
|
|
95449
|
-
canvas.addEventListener(
|
|
95456
|
+
this.canvas.addEventListener(
|
|
95450
95457
|
"wheel",
|
|
95451
95458
|
(this._mouseWheelHandler = (e) => {
|
|
95452
95459
|
e.preventDefault();
|
|
@@ -95480,18 +95487,17 @@ class MousePanRotateDollyHandler {
|
|
|
95480
95487
|
reset() {}
|
|
95481
95488
|
|
|
95482
95489
|
destroy() {
|
|
95483
|
-
|
|
95484
|
-
|
|
95485
|
-
|
|
95486
|
-
|
|
95487
|
-
canvas.removeEventListener("
|
|
95488
|
-
|
|
95489
|
-
canvas.removeEventListener("mousemove", this._canvasMouseMoveHandler);
|
|
95490
|
-
document.removeEventListener("mouseup", this._documentMouseUpHandler);
|
|
95491
|
-
canvas.removeEventListener("mouseup", this._mouseUpHandler);
|
|
95492
|
-
canvas.removeEventListener("mouseenter", this._mouseEnterHandler);
|
|
95493
|
-
canvas.removeEventListener("wheel", this._mouseWheelHandler);
|
|
95490
|
+
if (this.canvas != null) {
|
|
95491
|
+
this.canvas.removeEventListener("mousedown", this._mouseDownHandler);
|
|
95492
|
+
this.canvas.removeEventListener("mousemove", this._canvasMouseMoveHandler);
|
|
95493
|
+
this.canvas.removeEventListener("mouseup", this._mouseUpHandler);
|
|
95494
|
+
this.canvas.removeEventListener("mouseenter", this._mouseEnterHandler);
|
|
95495
|
+
this.canvas.removeEventListener("wheel", this._mouseWheelHandler);
|
|
95494
95496
|
}
|
|
95497
|
+
document.removeEventListener("keydown", this._documentKeyDownHandler);
|
|
95498
|
+
document.removeEventListener("keyup", this._documentKeyUpHandler);
|
|
95499
|
+
document.removeEventListener("mousemove", this._documentMouseMoveHandler);
|
|
95500
|
+
document.removeEventListener("mouseup", this._documentMouseUpHandler);
|
|
95495
95501
|
}
|
|
95496
95502
|
}
|
|
95497
95503
|
|
|
@@ -95502,116 +95508,113 @@ const tempVec3c$1 = math.vec3();
|
|
|
95502
95508
|
const tempVec3d = math.vec3();
|
|
95503
95509
|
|
|
95504
95510
|
const tempCameraTarget = {
|
|
95505
|
-
|
|
95506
|
-
|
|
95507
|
-
|
|
95511
|
+
eye: math.vec3(),
|
|
95512
|
+
look: math.vec3(),
|
|
95513
|
+
up: math.vec3()
|
|
95508
95514
|
};
|
|
95509
95515
|
|
|
95510
95516
|
/**
|
|
95511
95517
|
* @private
|
|
95512
95518
|
*/
|
|
95513
95519
|
class KeyboardAxisViewHandler {
|
|
95520
|
+
constructor(scene, controllers, configs, states) {
|
|
95521
|
+
this._scene = scene;
|
|
95522
|
+
this.input = scene.input;
|
|
95523
|
+
const cameraControl = controllers.cameraControl;
|
|
95524
|
+
const camera = scene.camera;
|
|
95514
95525
|
|
|
95515
|
-
|
|
95516
|
-
|
|
95517
|
-
|
|
95518
|
-
|
|
95519
|
-
const camera = scene.camera;
|
|
95520
|
-
|
|
95521
|
-
this._onSceneKeyDown = scene.input.on("keydown", () => {
|
|
95522
|
-
|
|
95523
|
-
if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
|
|
95524
|
-
return;
|
|
95525
|
-
}
|
|
95526
|
-
|
|
95527
|
-
if (!states.mouseover) {
|
|
95528
|
-
return;
|
|
95529
|
-
}
|
|
95530
|
-
|
|
95531
|
-
const axisViewRight = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_RIGHT);
|
|
95532
|
-
const axisViewBack = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BACK);
|
|
95533
|
-
const axisViewLeft = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_LEFT);
|
|
95534
|
-
const axisViewFront = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_FRONT);
|
|
95535
|
-
const axisViewTop = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_TOP);
|
|
95536
|
-
const axisViewBottom = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BOTTOM);
|
|
95537
|
-
|
|
95538
|
-
if ((!axisViewRight) && (!axisViewBack) && (!axisViewLeft) && (!axisViewFront) && (!axisViewTop) && (!axisViewBottom)) {
|
|
95539
|
-
return;
|
|
95540
|
-
}
|
|
95541
|
-
|
|
95542
|
-
const aabb = scene.aabb;
|
|
95543
|
-
const diag = math.getAABB3Diag(aabb);
|
|
95544
|
-
|
|
95545
|
-
math.getAABB3Center(aabb, center);
|
|
95546
|
-
|
|
95547
|
-
const perspectiveDist = Math.abs(diag / Math.tan(controllers.cameraFlight.fitFOV * math.DEGTORAD));
|
|
95548
|
-
const orthoScale = diag * 1.1;
|
|
95549
|
-
|
|
95550
|
-
tempCameraTarget.orthoScale = orthoScale;
|
|
95551
|
-
|
|
95552
|
-
if (axisViewRight) {
|
|
95553
|
-
|
|
95554
|
-
tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldRight, perspectiveDist, tempVec3a$5), tempVec3d));
|
|
95555
|
-
tempCameraTarget.look.set(center);
|
|
95556
|
-
tempCameraTarget.up.set(camera.worldUp);
|
|
95557
|
-
|
|
95558
|
-
} else if (axisViewBack) {
|
|
95559
|
-
|
|
95560
|
-
tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldForward, perspectiveDist, tempVec3a$5), tempVec3d));
|
|
95561
|
-
tempCameraTarget.look.set(center);
|
|
95562
|
-
tempCameraTarget.up.set(camera.worldUp);
|
|
95563
|
-
|
|
95564
|
-
} else if (axisViewLeft) {
|
|
95526
|
+
this._onSceneKeyDown = scene.input.on("keydown", () => {
|
|
95527
|
+
if (!(configs.active && configs.pointerEnabled) || !scene.input.keyboardEnabled) {
|
|
95528
|
+
return;
|
|
95529
|
+
}
|
|
95565
95530
|
|
|
95566
|
-
|
|
95567
|
-
|
|
95568
|
-
|
|
95531
|
+
if (!states.mouseover) {
|
|
95532
|
+
return;
|
|
95533
|
+
}
|
|
95569
95534
|
|
|
95570
|
-
|
|
95535
|
+
const axisViewRight = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_RIGHT);
|
|
95536
|
+
const axisViewBack = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BACK);
|
|
95537
|
+
const axisViewLeft = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_LEFT);
|
|
95538
|
+
const axisViewFront = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_FRONT);
|
|
95539
|
+
const axisViewTop = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_TOP);
|
|
95540
|
+
const axisViewBottom = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BOTTOM);
|
|
95571
95541
|
|
|
95572
|
-
|
|
95573
|
-
|
|
95574
|
-
|
|
95542
|
+
if (!axisViewRight && !axisViewBack && !axisViewLeft && !axisViewFront && !axisViewTop && !axisViewBottom) {
|
|
95543
|
+
return;
|
|
95544
|
+
}
|
|
95575
95545
|
|
|
95576
|
-
|
|
95546
|
+
const aabb = scene.aabb;
|
|
95547
|
+
const diag = math.getAABB3Diag(aabb);
|
|
95577
95548
|
|
|
95578
|
-
|
|
95579
|
-
tempCameraTarget.look.set(center);
|
|
95580
|
-
tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward, 1, tempVec3b$2), tempVec3c$1));
|
|
95549
|
+
math.getAABB3Center(aabb, center);
|
|
95581
95550
|
|
|
95582
|
-
|
|
95551
|
+
const perspectiveDist = Math.abs(diag / Math.tan(controllers.cameraFlight.fitFOV * math.DEGTORAD));
|
|
95552
|
+
const orthoScale = diag * 1.1;
|
|
95583
95553
|
|
|
95584
|
-
|
|
95585
|
-
tempCameraTarget.look.set(center);
|
|
95586
|
-
tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward, -1, tempVec3b$2)));
|
|
95587
|
-
}
|
|
95554
|
+
tempCameraTarget.orthoScale = orthoScale;
|
|
95588
95555
|
|
|
95589
|
-
|
|
95590
|
-
|
|
95591
|
-
|
|
95556
|
+
if (axisViewRight) {
|
|
95557
|
+
tempCameraTarget.eye.set(
|
|
95558
|
+
math.addVec3(center, math.mulVec3Scalar(camera.worldRight, perspectiveDist, tempVec3a$5), tempVec3d)
|
|
95559
|
+
);
|
|
95560
|
+
tempCameraTarget.look.set(center);
|
|
95561
|
+
tempCameraTarget.up.set(camera.worldUp);
|
|
95562
|
+
} else if (axisViewBack) {
|
|
95563
|
+
tempCameraTarget.eye.set(
|
|
95564
|
+
math.addVec3(center, math.mulVec3Scalar(camera.worldForward, perspectiveDist, tempVec3a$5), tempVec3d)
|
|
95565
|
+
);
|
|
95566
|
+
tempCameraTarget.look.set(center);
|
|
95567
|
+
tempCameraTarget.up.set(camera.worldUp);
|
|
95568
|
+
} else if (axisViewLeft) {
|
|
95569
|
+
tempCameraTarget.eye.set(
|
|
95570
|
+
math.addVec3(center, math.mulVec3Scalar(camera.worldRight, -perspectiveDist, tempVec3a$5), tempVec3d)
|
|
95571
|
+
);
|
|
95572
|
+
tempCameraTarget.look.set(center);
|
|
95573
|
+
tempCameraTarget.up.set(camera.worldUp);
|
|
95574
|
+
} else if (axisViewFront) {
|
|
95575
|
+
tempCameraTarget.eye.set(
|
|
95576
|
+
math.addVec3(center, math.mulVec3Scalar(camera.worldForward, -perspectiveDist, tempVec3a$5), tempVec3d)
|
|
95577
|
+
);
|
|
95578
|
+
tempCameraTarget.look.set(center);
|
|
95579
|
+
tempCameraTarget.up.set(camera.worldUp);
|
|
95580
|
+
} else if (axisViewTop) {
|
|
95581
|
+
tempCameraTarget.eye.set(
|
|
95582
|
+
math.addVec3(center, math.mulVec3Scalar(camera.worldUp, perspectiveDist, tempVec3a$5), tempVec3d)
|
|
95583
|
+
);
|
|
95584
|
+
tempCameraTarget.look.set(center);
|
|
95585
|
+
tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward, 1, tempVec3b$2), tempVec3c$1));
|
|
95586
|
+
} else if (axisViewBottom) {
|
|
95587
|
+
tempCameraTarget.eye.set(
|
|
95588
|
+
math.addVec3(center, math.mulVec3Scalar(camera.worldUp, -perspectiveDist, tempVec3a$5), tempVec3d)
|
|
95589
|
+
);
|
|
95590
|
+
tempCameraTarget.look.set(center);
|
|
95591
|
+
tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward, -1, tempVec3b$2)));
|
|
95592
|
+
}
|
|
95592
95593
|
|
|
95593
|
-
|
|
95594
|
-
|
|
95595
|
-
|
|
95596
|
-
controllers.pivotController.showPivot();
|
|
95597
|
-
}
|
|
95598
|
-
});
|
|
95594
|
+
if (!configs.firstPerson && configs.followPointer) {
|
|
95595
|
+
controllers.pivotController.setPivotPos(center);
|
|
95596
|
+
}
|
|
95599
95597
|
|
|
95600
|
-
|
|
95601
|
-
|
|
95602
|
-
|
|
95603
|
-
|
|
95604
|
-
|
|
95605
|
-
|
|
95606
|
-
|
|
95607
|
-
|
|
95598
|
+
if (controllers.cameraFlight.duration > 0) {
|
|
95599
|
+
controllers.cameraFlight.flyTo(tempCameraTarget, () => {
|
|
95600
|
+
if (controllers.pivotController.getPivoting() && configs.followPointer) {
|
|
95601
|
+
controllers.pivotController.showPivot();
|
|
95602
|
+
}
|
|
95603
|
+
});
|
|
95604
|
+
} else {
|
|
95605
|
+
controllers.cameraFlight.jumpTo(tempCameraTarget);
|
|
95606
|
+
if (controllers.pivotController.getPivoting() && configs.followPointer) {
|
|
95607
|
+
controllers.pivotController.showPivot();
|
|
95608
|
+
}
|
|
95609
|
+
}
|
|
95610
|
+
});
|
|
95611
|
+
}
|
|
95608
95612
|
|
|
95609
|
-
|
|
95610
|
-
}
|
|
95613
|
+
reset() {}
|
|
95611
95614
|
|
|
95612
|
-
|
|
95613
|
-
|
|
95614
|
-
|
|
95615
|
+
destroy() {
|
|
95616
|
+
this.input.off(this._onSceneKeyDown);
|
|
95617
|
+
}
|
|
95615
95618
|
}
|
|
95616
95619
|
|
|
95617
95620
|
/**
|
|
@@ -95632,7 +95635,7 @@ class MousePickHandler {
|
|
|
95632
95635
|
let leftDown = false;
|
|
95633
95636
|
let rightDown = false;
|
|
95634
95637
|
|
|
95635
|
-
|
|
95638
|
+
this.canvas = this._scene.canvas.canvas;
|
|
95636
95639
|
|
|
95637
95640
|
const tickifiedMouseMoveFn = scene.tickify(
|
|
95638
95641
|
(this._canvasMouseMoveHandler = (e) => {
|
|
@@ -95714,8 +95717,8 @@ class MousePickHandler {
|
|
|
95714
95717
|
})
|
|
95715
95718
|
);
|
|
95716
95719
|
|
|
95717
|
-
canvas.addEventListener("mousemove", tickifiedMouseMoveFn);
|
|
95718
|
-
canvas.addEventListener(
|
|
95720
|
+
this.canvas.addEventListener("mousemove", tickifiedMouseMoveFn);
|
|
95721
|
+
this.canvas.addEventListener(
|
|
95719
95722
|
"dblclick",
|
|
95720
95723
|
(this._canvasDblClickHandler = (e) => {
|
|
95721
95724
|
states.mouseDownClientX = e.clientX;
|
|
@@ -95746,7 +95749,7 @@ class MousePickHandler {
|
|
|
95746
95749
|
})
|
|
95747
95750
|
);
|
|
95748
95751
|
|
|
95749
|
-
canvas.addEventListener(
|
|
95752
|
+
this.canvas.addEventListener(
|
|
95750
95753
|
"mousedown",
|
|
95751
95754
|
(this._canvasMouseDownHandler = (e) => {
|
|
95752
95755
|
if (e.which === 1) {
|
|
@@ -95818,7 +95821,7 @@ class MousePickHandler {
|
|
|
95818
95821
|
})
|
|
95819
95822
|
);
|
|
95820
95823
|
|
|
95821
|
-
canvas.addEventListener(
|
|
95824
|
+
this.canvas.addEventListener(
|
|
95822
95825
|
"mouseup",
|
|
95823
95826
|
(this._canvasMouseUpHandler = (e) => {
|
|
95824
95827
|
if (!(configs.active && configs.pointerEnabled)) {
|
|
@@ -95992,12 +95995,13 @@ class MousePickHandler {
|
|
|
95992
95995
|
}
|
|
95993
95996
|
|
|
95994
95997
|
destroy() {
|
|
95995
|
-
|
|
95996
|
-
|
|
95997
|
-
|
|
95998
|
-
|
|
95998
|
+
if (this.canvas != null) {
|
|
95999
|
+
this.canvas.removeEventListener("mousemove", this._canvasMouseMoveHandler);
|
|
96000
|
+
this.canvas.removeEventListener("mousedown", this._canvasMouseDownHandler);
|
|
96001
|
+
this.canvas.removeEventListener("dblclick", this._canvasDblClickHandler);
|
|
96002
|
+
this.canvas.removeEventListener("mouseup", this._canvasMouseUpHandler);
|
|
96003
|
+
}
|
|
95999
96004
|
document.removeEventListener("mouseup", this._documentMouseUpHandler);
|
|
96000
|
-
canvas.removeEventListener("mouseup", this._canvasMouseUpHandler);
|
|
96001
96005
|
if (this._timeout) {
|
|
96002
96006
|
window.clearTimeout(this._timeout);
|
|
96003
96007
|
this._timeout = null;
|
|
@@ -96013,7 +96017,7 @@ class KeyboardPanRotateDollyHandler {
|
|
|
96013
96017
|
this._scene = scene;
|
|
96014
96018
|
this._updates = updates;
|
|
96015
96019
|
const input = scene.input;
|
|
96016
|
-
|
|
96020
|
+
this.input = input;
|
|
96017
96021
|
const keyDownMap = [];
|
|
96018
96022
|
|
|
96019
96023
|
const canvas = scene.canvas.canvas;
|
|
@@ -96167,9 +96171,9 @@ class KeyboardPanRotateDollyHandler {
|
|
|
96167
96171
|
destroy() {
|
|
96168
96172
|
this._scene.off(this._onTick);
|
|
96169
96173
|
|
|
96170
|
-
this.
|
|
96171
|
-
this.
|
|
96172
|
-
this.
|
|
96174
|
+
this.input.off(this._onSceneMouseMove);
|
|
96175
|
+
this.input.off(this._onSceneKeyDown);
|
|
96176
|
+
this.input.off(this._onSceneKeyUp);
|
|
96173
96177
|
}
|
|
96174
96178
|
}
|
|
96175
96179
|
|
|
@@ -96489,42 +96493,42 @@ class MouseMiscHandler {
|
|
|
96489
96493
|
constructor(scene, controllers, configs, states, updates) {
|
|
96490
96494
|
this._scene = scene;
|
|
96491
96495
|
|
|
96492
|
-
|
|
96496
|
+
this.canvas = this._scene.canvas.canvas;
|
|
96493
96497
|
|
|
96494
|
-
canvas.addEventListener(
|
|
96498
|
+
this.canvas.addEventListener(
|
|
96495
96499
|
"mouseenter",
|
|
96496
96500
|
(this._mouseEnterHandler = () => {
|
|
96497
96501
|
states.mouseover = true;
|
|
96498
96502
|
})
|
|
96499
96503
|
);
|
|
96500
96504
|
|
|
96501
|
-
canvas.addEventListener(
|
|
96505
|
+
this.canvas.addEventListener(
|
|
96502
96506
|
"mouseleave",
|
|
96503
96507
|
(this._mouseLeaveHandler = () => {
|
|
96504
96508
|
states.mouseover = false;
|
|
96505
|
-
canvas.style.cursor = null;
|
|
96509
|
+
this.canvas.style.cursor = null;
|
|
96506
96510
|
})
|
|
96507
96511
|
);
|
|
96508
96512
|
|
|
96509
96513
|
document.addEventListener(
|
|
96510
96514
|
"mousemove",
|
|
96511
96515
|
(this._mouseMoveHandler = (e) => {
|
|
96512
|
-
getCanvasPosFromEvent$2(e, canvas, states.pointerCanvasPos);
|
|
96516
|
+
getCanvasPosFromEvent$2(e, this.canvas, states.pointerCanvasPos);
|
|
96513
96517
|
})
|
|
96514
96518
|
);
|
|
96515
96519
|
|
|
96516
|
-
canvas.addEventListener(
|
|
96520
|
+
this.canvas.addEventListener(
|
|
96517
96521
|
"mousedown",
|
|
96518
96522
|
(this._mouseDownHandler = (e) => {
|
|
96519
96523
|
if (!(configs.active && configs.pointerEnabled)) {
|
|
96520
96524
|
return;
|
|
96521
96525
|
}
|
|
96522
|
-
getCanvasPosFromEvent$2(e, canvas, states.pointerCanvasPos);
|
|
96526
|
+
getCanvasPosFromEvent$2(e, this.canvas, states.pointerCanvasPos);
|
|
96523
96527
|
states.mouseover = true;
|
|
96524
96528
|
})
|
|
96525
96529
|
);
|
|
96526
96530
|
|
|
96527
|
-
canvas.addEventListener(
|
|
96531
|
+
this.canvas.addEventListener(
|
|
96528
96532
|
"mouseup",
|
|
96529
96533
|
(this._mouseUpHandler = (e) => {
|
|
96530
96534
|
if (!(configs.active && configs.pointerEnabled)) {
|
|
@@ -96537,16 +96541,15 @@ class MouseMiscHandler {
|
|
|
96537
96541
|
reset() {}
|
|
96538
96542
|
|
|
96539
96543
|
destroy() {
|
|
96540
|
-
const canvas = this._scene.canvas.canvas;
|
|
96541
96544
|
//网络问题导致的模型加载失败等情况时,如果切换模型,会找不到canvas
|
|
96542
96545
|
//因此暂时在此加判断
|
|
96543
|
-
if (canvas) {
|
|
96544
|
-
|
|
96545
|
-
canvas.removeEventListener("
|
|
96546
|
-
canvas.removeEventListener("
|
|
96547
|
-
canvas.removeEventListener("
|
|
96548
|
-
canvas.removeEventListener("mouseup", this._mouseUpHandler);
|
|
96546
|
+
if (this.canvas != null) {
|
|
96547
|
+
this.canvas.removeEventListener("mouseenter", this._mouseEnterHandler);
|
|
96548
|
+
this.canvas.removeEventListener("mouseleave", this._mouseLeaveHandler);
|
|
96549
|
+
this.canvas.removeEventListener("mousedown", this._mouseDownHandler);
|
|
96550
|
+
this.canvas.removeEventListener("mouseup", this._mouseUpHandler);
|
|
96549
96551
|
}
|
|
96552
|
+
document.removeEventListener("mousemove", this._mouseMoveHandler);
|
|
96550
96553
|
}
|
|
96551
96554
|
}
|
|
96552
96555
|
|
|
@@ -96599,7 +96602,7 @@ class TouchPanRotateAndDollyHandler {
|
|
|
96599
96602
|
const touch0Vec = math.vec2();
|
|
96600
96603
|
|
|
96601
96604
|
const lastCanvasTouchPosList = [];
|
|
96602
|
-
|
|
96605
|
+
this.canvas = this._scene.canvas.canvas;
|
|
96603
96606
|
|
|
96604
96607
|
let numTouches = 0;
|
|
96605
96608
|
let waitForTick = false;
|
|
@@ -96608,7 +96611,7 @@ class TouchPanRotateAndDollyHandler {
|
|
|
96608
96611
|
waitForTick = false;
|
|
96609
96612
|
});
|
|
96610
96613
|
|
|
96611
|
-
canvas.addEventListener(
|
|
96614
|
+
this.canvas.addEventListener(
|
|
96612
96615
|
"touchstart",
|
|
96613
96616
|
(this._canvasTouchStartHandler = (event) => {
|
|
96614
96617
|
if (!(configs.active && configs.pointerEnabled)) {
|
|
@@ -96674,7 +96677,7 @@ class TouchPanRotateAndDollyHandler {
|
|
|
96674
96677
|
})
|
|
96675
96678
|
);
|
|
96676
96679
|
|
|
96677
|
-
canvas.addEventListener(
|
|
96680
|
+
this.canvas.addEventListener(
|
|
96678
96681
|
"touchend",
|
|
96679
96682
|
(this._canvasTouchEndHandler = () => {
|
|
96680
96683
|
if (pivotController.getPivoting()) {
|
|
@@ -96683,9 +96686,9 @@ class TouchPanRotateAndDollyHandler {
|
|
|
96683
96686
|
}
|
|
96684
96687
|
})
|
|
96685
96688
|
);
|
|
96686
|
-
canvas.addEventListener("touchcancel", this._canvasTouchEndHandler);
|
|
96689
|
+
this.canvas.addEventListener("touchcancel", this._canvasTouchEndHandler);
|
|
96687
96690
|
|
|
96688
|
-
canvas.addEventListener(
|
|
96691
|
+
this.canvas.addEventListener(
|
|
96689
96692
|
"touchmove",
|
|
96690
96693
|
(this._canvasTouchMoveHandler = (event) => {
|
|
96691
96694
|
if (!(configs.active && configs.pointerEnabled)) {
|
|
@@ -96831,11 +96834,12 @@ class TouchPanRotateAndDollyHandler {
|
|
|
96831
96834
|
reset() {}
|
|
96832
96835
|
|
|
96833
96836
|
destroy() {
|
|
96834
|
-
|
|
96835
|
-
|
|
96836
|
-
|
|
96837
|
-
|
|
96838
|
-
|
|
96837
|
+
if (this.canvas != null) {
|
|
96838
|
+
this.canvas.removeEventListener("touchstart", this._canvasTouchStartHandler);
|
|
96839
|
+
this.canvas.removeEventListener("touchend", this._canvasTouchEndHandler);
|
|
96840
|
+
this.canvas.removeEventListener("touchcancel", this._canvasTouchEndHandler);
|
|
96841
|
+
this.canvas.removeEventListener("touchmove", this._canvasTouchMoveHandler);
|
|
96842
|
+
}
|
|
96839
96843
|
this._scene.off(this._onTick);
|
|
96840
96844
|
}
|
|
96841
96845
|
}
|
|
@@ -96880,7 +96884,7 @@ class TouchPickHandler {
|
|
|
96880
96884
|
let tapStartTime = -1;
|
|
96881
96885
|
let lastTapTime = -1;
|
|
96882
96886
|
|
|
96883
|
-
|
|
96887
|
+
this.canvas = this._scene.canvas.canvas;
|
|
96884
96888
|
|
|
96885
96889
|
const flyCameraTo = (pickResult) => {
|
|
96886
96890
|
let pos;
|
|
@@ -96904,7 +96908,7 @@ class TouchPickHandler {
|
|
|
96904
96908
|
}
|
|
96905
96909
|
};
|
|
96906
96910
|
|
|
96907
|
-
canvas.addEventListener(
|
|
96911
|
+
this.canvas.addEventListener(
|
|
96908
96912
|
"touchstart",
|
|
96909
96913
|
(this._canvasTouchStartHandler = (e) => {
|
|
96910
96914
|
if (!(configs.active && configs.pointerEnabled)) {
|
|
@@ -96982,7 +96986,7 @@ class TouchPickHandler {
|
|
|
96982
96986
|
{ passive: true }
|
|
96983
96987
|
);
|
|
96984
96988
|
|
|
96985
|
-
canvas.addEventListener(
|
|
96989
|
+
this.canvas.addEventListener(
|
|
96986
96990
|
"touchend",
|
|
96987
96991
|
(this._canvasTouchEndHandler = (e) => {
|
|
96988
96992
|
if (!(configs.active && configs.pointerEnabled)) {
|
|
@@ -97079,7 +97083,7 @@ class TouchPickHandler {
|
|
|
97079
97083
|
{ passive: true }
|
|
97080
97084
|
);
|
|
97081
97085
|
|
|
97082
|
-
canvas.addEventListener("touchcancel", this._canvasTouchEndHandler);
|
|
97086
|
+
this.canvas.addEventListener("touchcancel", this._canvasTouchEndHandler);
|
|
97083
97087
|
}
|
|
97084
97088
|
|
|
97085
97089
|
reset() {
|
|
@@ -97089,10 +97093,11 @@ class TouchPickHandler {
|
|
|
97089
97093
|
}
|
|
97090
97094
|
|
|
97091
97095
|
destroy() {
|
|
97092
|
-
|
|
97093
|
-
|
|
97094
|
-
|
|
97095
|
-
|
|
97096
|
+
if (this.canvas != null) {
|
|
97097
|
+
this.canvas.removeEventListener("touchstart", this._canvasTouchStartHandler);
|
|
97098
|
+
this.canvas.removeEventListener("touchend", this._canvasTouchEndHandler);
|
|
97099
|
+
this.canvas.removeEventListener("touchcancel", this._canvasTouchEndHandler);
|
|
97100
|
+
}
|
|
97096
97101
|
}
|
|
97097
97102
|
}
|
|
97098
97103
|
|
|
@@ -108381,13 +108386,16 @@ class Viewer {
|
|
|
108381
108386
|
this._snapshotBegun = false;
|
|
108382
108387
|
}
|
|
108383
108388
|
|
|
108384
|
-
/**
|
|
108389
|
+
/**
|
|
108390
|
+
* Destroys this Viewer.
|
|
108385
108391
|
*/
|
|
108386
108392
|
destroy(callback) {
|
|
108387
108393
|
const plugins = this._plugins.slice(); // Array will modify as we delete plugins
|
|
108388
|
-
|
|
108389
|
-
|
|
108390
|
-
|
|
108394
|
+
if (plugins.length > 0) {
|
|
108395
|
+
for (let i = 0, len = plugins.length; i < len; i++) {
|
|
108396
|
+
const plugin = plugins[i];
|
|
108397
|
+
plugin.destroy();
|
|
108398
|
+
}
|
|
108391
108399
|
}
|
|
108392
108400
|
this.cameraControl.destroy();
|
|
108393
108401
|
this.scene.destroy(callback);
|
|
@@ -118020,7 +118028,6 @@ class NavCubePlugin extends Plugin {
|
|
|
118020
118028
|
if (hit) {
|
|
118021
118029
|
if (hit.uv) {
|
|
118022
118030
|
var areaId = self._cubeTextureCanvas.getArea(hit.uv);
|
|
118023
|
-
console.log(areaId);
|
|
118024
118031
|
if (areaId >= 0) {
|
|
118025
118032
|
document.body.style.cursor = "pointer";
|
|
118026
118033
|
if (lastAreaId >= 0) {
|
|
@@ -118042,8 +118049,6 @@ class NavCubePlugin extends Plugin {
|
|
|
118042
118049
|
dir = rotateTrueNorth(+1, dir, tempVec3a$4);
|
|
118043
118050
|
up = rotateTrueNorth(+1, up, tempVec3b$1);
|
|
118044
118051
|
}
|
|
118045
|
-
console.log(dir);
|
|
118046
|
-
console.log(up);
|
|
118047
118052
|
flyTo(dir, up, function () {
|
|
118048
118053
|
if (lastAreaId >= 0) {
|
|
118049
118054
|
self._cubeTextureCanvas.setAreaHighlighted(lastAreaId, false);
|
|
@@ -119330,8 +119335,8 @@ class OBJLoaderPlugin extends Plugin {
|
|
|
119330
119335
|
}
|
|
119331
119336
|
}
|
|
119332
119337
|
|
|
119333
|
-
const zeroVec$
|
|
119334
|
-
const quat$
|
|
119338
|
+
const zeroVec$3 = new Float64Array([0, 0, 1]);
|
|
119339
|
+
const quat$3 = new Float64Array(4);
|
|
119335
119340
|
|
|
119336
119341
|
/**
|
|
119337
119342
|
* Controls a {@link SectionPlane} with mouse and touch input.
|
|
@@ -119350,8 +119355,10 @@ class Control {
|
|
|
119350
119355
|
* @type {String|Number}
|
|
119351
119356
|
*/
|
|
119352
119357
|
this.id = null;
|
|
119358
|
+
this.type = "control";
|
|
119353
119359
|
|
|
119354
119360
|
this._viewer = plugin.viewer;
|
|
119361
|
+
this._scene = plugin.viewer.scene;
|
|
119355
119362
|
|
|
119356
119363
|
this._visible = false;
|
|
119357
119364
|
this._pos = math.vec3(); // Full-precision position of the center of the Control
|
|
@@ -119409,6 +119416,44 @@ class Control {
|
|
|
119409
119416
|
return this._sectionPlane;
|
|
119410
119417
|
}
|
|
119411
119418
|
|
|
119419
|
+
/**
|
|
119420
|
+
* 设置剖切面位置
|
|
119421
|
+
* @param {any} value
|
|
119422
|
+
*/
|
|
119423
|
+
set pos(posRate) {
|
|
119424
|
+
if (posRate < 0 || posRate > 100) return;
|
|
119425
|
+
|
|
119426
|
+
const { aabb } = this._scene;
|
|
119427
|
+
const { look } = this._scene.camera;
|
|
119428
|
+
const xRange = aabb[3] - aabb[0]; //前后
|
|
119429
|
+
const yRange = aabb[4] - aabb[1]; //上下
|
|
119430
|
+
const zRange = aabb[5] - aabb[2]; //左右
|
|
119431
|
+
|
|
119432
|
+
const newSectionPos = math.vec3();
|
|
119433
|
+
newSectionPos[0] = this.pos[0];
|
|
119434
|
+
newSectionPos[1] = this.pos[1];
|
|
119435
|
+
newSectionPos[2] = this.pos[2];
|
|
119436
|
+
|
|
119437
|
+
const { dir } = this._sectionPlane;
|
|
119438
|
+
let rateDis;
|
|
119439
|
+
if (dir[0] != 0) {
|
|
119440
|
+
rateDis = (posRate / 100) * xRange;
|
|
119441
|
+
newSectionPos[0] = look[0] - xRange / 2 + rateDis;
|
|
119442
|
+
} else if (dir[1] != 0) {
|
|
119443
|
+
rateDis = (posRate / 100) * yRange;
|
|
119444
|
+
newSectionPos[1] = look[1] - yRange / 2 + rateDis;
|
|
119445
|
+
} else if (dir[2] != 0) {
|
|
119446
|
+
rateDis = (posRate / 100) * zRange;
|
|
119447
|
+
newSectionPos[2] = look[2] - zRange / 2 + rateDis;
|
|
119448
|
+
}
|
|
119449
|
+
|
|
119450
|
+
this._sectionPlane.pos = newSectionPos;
|
|
119451
|
+
}
|
|
119452
|
+
|
|
119453
|
+
get pos() {
|
|
119454
|
+
return this._pos;
|
|
119455
|
+
}
|
|
119456
|
+
|
|
119412
119457
|
/** @private */
|
|
119413
119458
|
_setPos(xyz) {
|
|
119414
119459
|
this._pos.set(xyz);
|
|
@@ -119422,7 +119467,7 @@ class Control {
|
|
|
119422
119467
|
/** @private */
|
|
119423
119468
|
_setDir(xyz) {
|
|
119424
119469
|
this._baseDir.set(xyz);
|
|
119425
|
-
this._rootNode.quaternion = math.vec3PairToQuaternion(zeroVec$
|
|
119470
|
+
this._rootNode.quaternion = math.vec3PairToQuaternion(zeroVec$3, xyz, quat$3);
|
|
119426
119471
|
}
|
|
119427
119472
|
|
|
119428
119473
|
_setSectionPlaneDir(dir) {
|
|
@@ -120817,7 +120862,6 @@ class Control {
|
|
|
120817
120862
|
);
|
|
120818
120863
|
|
|
120819
120864
|
this._onCameraControlHover = this._viewer.cameraControl.on("touchEntity", (hit) => {
|
|
120820
|
-
console.log("111");
|
|
120821
120865
|
if (!this._visible || down || grabbed) return;
|
|
120822
120866
|
grabbed = false;
|
|
120823
120867
|
if (lastAffordanceMesh) {
|
|
@@ -120885,7 +120929,6 @@ class Control {
|
|
|
120885
120929
|
canvas.addEventListener(
|
|
120886
120930
|
"touchstart",
|
|
120887
120931
|
(this._canvasMouseDownListener = (e) => {
|
|
120888
|
-
console.log("222");
|
|
120889
120932
|
e.preventDefault();
|
|
120890
120933
|
if (!this._visible || !grabbed) return;
|
|
120891
120934
|
|
|
@@ -120936,7 +120979,7 @@ class Control {
|
|
|
120936
120979
|
canvas.addEventListener(
|
|
120937
120980
|
"touchend",
|
|
120938
120981
|
(this._canvasTouchEndListener = (e) => {
|
|
120939
|
-
|
|
120982
|
+
if (!this._visible) return;
|
|
120940
120983
|
this._viewer.cameraControl.pointerEnabled = true;
|
|
120941
120984
|
if (lastAffordanceMesh) {
|
|
120942
120985
|
lastAffordanceMesh.visible = false;
|
|
@@ -120987,407 +121030,2033 @@ class Control {
|
|
|
120987
121030
|
}
|
|
120988
121031
|
}
|
|
120989
121032
|
|
|
121033
|
+
const zeroVec$2 = new Float64Array([0, 0, 1]);
|
|
121034
|
+
const quat$2 = new Float64Array(4);
|
|
121035
|
+
|
|
120990
121036
|
/**
|
|
120991
|
-
*
|
|
121037
|
+
* Controls a {@link SectionPlane} with mouse and touch input.
|
|
120992
121038
|
*
|
|
120993
121039
|
* @private
|
|
120994
121040
|
*/
|
|
120995
|
-
class
|
|
120996
|
-
|
|
120997
|
-
|
|
120998
|
-
|
|
120999
|
-
|
|
121000
|
-
|
|
121001
|
-
|
|
121002
|
-
|
|
121003
|
-
|
|
121004
|
-
|
|
121005
|
-
|
|
121006
|
-
|
|
121007
|
-
|
|
121008
|
-
* The {@link SectionPlane} represented by this SectionPlanesOverviewPlane.
|
|
121009
|
-
*
|
|
121010
|
-
* @type {SectionPlane}
|
|
121011
|
-
*/
|
|
121012
|
-
this._sectionPlane = sectionPlane;
|
|
121013
|
-
|
|
121014
|
-
this._mesh = new Mesh(overviewScene, {
|
|
121015
|
-
id: sectionPlane.id,
|
|
121016
|
-
geometry: new ReadableGeometry(overviewScene, buildBoxGeometry({
|
|
121017
|
-
xSize: .5,
|
|
121018
|
-
ySize: .5,
|
|
121019
|
-
zSize: .001
|
|
121020
|
-
})),
|
|
121021
|
-
material: new PhongMaterial(overviewScene, {
|
|
121022
|
-
emissive: [1, 1, 1],
|
|
121023
|
-
diffuse: [0, 0, 0],
|
|
121024
|
-
backfaces: false
|
|
121025
|
-
}),
|
|
121026
|
-
edgeMaterial: new EdgeMaterial(overviewScene, {
|
|
121027
|
-
edgeColor: [0.0, 0.0, 0.0],
|
|
121028
|
-
edgeAlpha: 1.0,
|
|
121029
|
-
edgeWidth: 1
|
|
121030
|
-
}),
|
|
121031
|
-
highlightMaterial: new EmphasisMaterial(overviewScene, {
|
|
121032
|
-
fill: true,
|
|
121033
|
-
fillColor: [0.5, 1, 0.5],
|
|
121034
|
-
fillAlpha: 0.7,
|
|
121035
|
-
edges: true,
|
|
121036
|
-
edgeColor: [0.0, 0.0, 0.0],
|
|
121037
|
-
edgeAlpha: 1.0,
|
|
121038
|
-
edgeWidth: 1
|
|
121039
|
-
}),
|
|
121040
|
-
selectedMaterial: new EmphasisMaterial(overviewScene, {
|
|
121041
|
-
fill: true,
|
|
121042
|
-
fillColor: [0, 0, 1],
|
|
121043
|
-
fillAlpha: 0.7,
|
|
121044
|
-
edges: true,
|
|
121045
|
-
edgeColor: [1.0, 0.0, 0.0],
|
|
121046
|
-
edgeAlpha: 1.0,
|
|
121047
|
-
edgeWidth: 1
|
|
121048
|
-
}),
|
|
121049
|
-
highlighted: true,
|
|
121050
|
-
scale: [3, 3, 3],
|
|
121051
|
-
position: [0, 0, 0],
|
|
121052
|
-
rotation: [0, 0, 0],
|
|
121053
|
-
opacity: 0.3,
|
|
121054
|
-
edges: true
|
|
121055
|
-
});
|
|
121056
|
-
|
|
121057
|
-
|
|
121058
|
-
{
|
|
121059
|
-
const vec = math.vec3([0, 0, 0]);
|
|
121060
|
-
const pos2 = math.vec3();
|
|
121061
|
-
const zeroVec = math.vec3([0, 0, 1]);
|
|
121062
|
-
const quat = math.vec4(4);
|
|
121063
|
-
const pos3 = math.vec3();
|
|
121064
|
-
|
|
121065
|
-
const update = () => {
|
|
121066
|
-
|
|
121067
|
-
const origin = this._sectionPlane.scene.center;
|
|
121041
|
+
class ClippingBox {
|
|
121042
|
+
/** @private */
|
|
121043
|
+
constructor(plugin, cfg) {
|
|
121044
|
+
/**
|
|
121045
|
+
* ID of this Control.
|
|
121046
|
+
*
|
|
121047
|
+
* SectionPlaneControls are mapped by this ID in {@link SectionPlanesPlugin#sectionPlaneControls}.
|
|
121048
|
+
*
|
|
121049
|
+
* @property id
|
|
121050
|
+
* @type {String|Number}
|
|
121051
|
+
*/
|
|
121052
|
+
this.id = null;
|
|
121053
|
+
this.type = "box";
|
|
121068
121054
|
|
|
121069
|
-
|
|
121070
|
-
|
|
121071
|
-
const dist = -math.dotVec3(negDir, vec);
|
|
121055
|
+
this._viewer = plugin.viewer;
|
|
121056
|
+
this._scene = plugin.viewer.scene;
|
|
121072
121057
|
|
|
121073
|
-
|
|
121074
|
-
|
|
121075
|
-
|
|
121058
|
+
this._controlFillColor = !!cfg && !!cfg.controlFillColor ? cfg.controlFillColor : [0.1, 0.4, 0.99];
|
|
121059
|
+
this._planeSize = !!cfg && !!cfg.planeSize ? cfg.planeSize : 1;
|
|
121060
|
+
this._controlSize = !!cfg && !!cfg.controlSize ? cfg.controlSize : 0.07;
|
|
121061
|
+
this._planeOpacity = !!cfg && !!cfg.planeOpacity ? cfg.planeOpacity : 0.4;
|
|
121076
121062
|
|
|
121077
|
-
|
|
121078
|
-
|
|
121079
|
-
|
|
121063
|
+
this._visible = false;
|
|
121064
|
+
this._pos = math.vec3(); // Full-precision position of the center of the Control
|
|
121065
|
+
this._origin = math.vec3();
|
|
121066
|
+
this._rtcPos = math.vec3();
|
|
121080
121067
|
|
|
121081
|
-
|
|
121082
|
-
|
|
121083
|
-
|
|
121068
|
+
this._baseDir = math.vec3(); // Saves direction of clip plane when we start dragging an arrow or ring.
|
|
121069
|
+
this._rootNode = null; // Root of Node graph that represents this control in the 3D scene
|
|
121070
|
+
this._displayMeshes = null; // Meshes that are always visible
|
|
121071
|
+
this._affordanceMeshes = null; // Meshes displayed momentarily for affordance
|
|
121084
121072
|
|
|
121085
|
-
|
|
121086
|
-
this._onSectionPlaneDir = this._sectionPlane.on("dir", update);
|
|
121073
|
+
this._ignoreNextSectionPlaneDirUpdate = false;
|
|
121087
121074
|
|
|
121088
|
-
|
|
121089
|
-
|
|
121075
|
+
this._createNodes();
|
|
121076
|
+
this._bindEvents();
|
|
121077
|
+
}
|
|
121090
121078
|
|
|
121091
|
-
|
|
121092
|
-
|
|
121093
|
-
|
|
121079
|
+
/**
|
|
121080
|
+
* Called by SectionPlanesPlugin to assign this Control to a SectionPlane.
|
|
121081
|
+
* SectionPlanesPlugin keeps SectionPlaneControls in a reuse pool.
|
|
121082
|
+
* Call with a null or undefined value to disconnect the Control ffrom whatever SectionPlane it was assigned to.
|
|
121083
|
+
* @private
|
|
121084
|
+
*/
|
|
121085
|
+
_setSectionPlane(sectionPlane) {
|
|
121086
|
+
if (this._sectionPlane) {
|
|
121087
|
+
this._sectionPlane.off(this._onSectionPlanePos);
|
|
121088
|
+
this._sectionPlane.off(this._onSectionPlaneDir);
|
|
121089
|
+
this._onSectionPlanePos = null;
|
|
121090
|
+
this._onSectionPlaneDir = null;
|
|
121091
|
+
this._sectionPlane = null;
|
|
121092
|
+
}
|
|
121093
|
+
if (sectionPlane) {
|
|
121094
|
+
this.id = sectionPlane.id;
|
|
121095
|
+
this._setPos(sectionPlane.pos);
|
|
121096
|
+
this._setDir(sectionPlane.dir);
|
|
121097
|
+
this._sectionPlane = sectionPlane;
|
|
121098
|
+
this._onSectionPlanePos = sectionPlane.on("pos", () => {
|
|
121099
|
+
this._setPos(this._sectionPlane.pos);
|
|
121100
|
+
});
|
|
121101
|
+
this._onSectionPlaneDir = sectionPlane.on("dir", () => {
|
|
121102
|
+
if (!this._ignoreNextSectionPlaneDirUpdate) {
|
|
121103
|
+
this._setDir(this._sectionPlane.dir);
|
|
121104
|
+
} else {
|
|
121105
|
+
this._ignoreNextSectionPlaneDirUpdate = false;
|
|
121106
|
+
}
|
|
121107
|
+
});
|
|
121108
|
+
}
|
|
121109
|
+
}
|
|
121094
121110
|
|
|
121095
|
-
|
|
121096
|
-
|
|
121097
|
-
|
|
121098
|
-
|
|
121099
|
-
|
|
121100
|
-
|
|
121101
|
-
|
|
121102
|
-
this._highlighted = !!highlighted;
|
|
121103
|
-
this._mesh.highlighted = this._highlighted;
|
|
121104
|
-
this._mesh.highlightMaterial.fillColor = highlighted ? [0, 0.7, 0] : [0, 0, 0];
|
|
121105
|
-
// this._selectedMesh.highlighted = true;
|
|
121106
|
-
}
|
|
121111
|
+
/**
|
|
121112
|
+
* Gets the {@link SectionPlane} controlled by this Control.
|
|
121113
|
+
* @returns {SectionPlane} The SectionPlane.
|
|
121114
|
+
*/
|
|
121115
|
+
get sectionPlane() {
|
|
121116
|
+
return this._sectionPlane;
|
|
121117
|
+
}
|
|
121107
121118
|
|
|
121108
|
-
|
|
121109
|
-
|
|
121110
|
-
|
|
121111
|
-
|
|
121112
|
-
|
|
121113
|
-
|
|
121114
|
-
|
|
121115
|
-
|
|
121116
|
-
|
|
121119
|
+
/**
|
|
121120
|
+
* 设置剖切面位置
|
|
121121
|
+
* @param {any} value
|
|
121122
|
+
*/
|
|
121123
|
+
set pos(posRate) {
|
|
121124
|
+
if (posRate < 0 || posRate > 100) return;
|
|
121125
|
+
|
|
121126
|
+
const { aabb } = this._scene;
|
|
121127
|
+
const { look } = this._scene.camera;
|
|
121128
|
+
const xRange = aabb[3] - aabb[0]; //前后
|
|
121129
|
+
const yRange = aabb[4] - aabb[1]; //上下
|
|
121130
|
+
const zRange = aabb[5] - aabb[2]; //左右
|
|
121131
|
+
|
|
121132
|
+
const newSectionPos = math.vec3();
|
|
121133
|
+
newSectionPos[0] = this.pos[0];
|
|
121134
|
+
newSectionPos[1] = this.pos[1];
|
|
121135
|
+
newSectionPos[2] = this.pos[2];
|
|
121136
|
+
|
|
121137
|
+
const { dir } = this._sectionPlane;
|
|
121138
|
+
let rateDis;
|
|
121139
|
+
if (dir[0] != 0) {
|
|
121140
|
+
rateDis = (posRate / 100) * xRange;
|
|
121141
|
+
newSectionPos[0] = look[0] - xRange / 2 + rateDis;
|
|
121142
|
+
} else if (dir[1] != 0) {
|
|
121143
|
+
rateDis = (posRate / 100) * yRange;
|
|
121144
|
+
newSectionPos[1] = look[1] - yRange / 2 + rateDis;
|
|
121145
|
+
} else if (dir[2] != 0) {
|
|
121146
|
+
rateDis = (posRate / 100) * zRange;
|
|
121147
|
+
newSectionPos[2] = look[2] - zRange / 2 + rateDis;
|
|
121148
|
+
}
|
|
121117
121149
|
|
|
121118
|
-
|
|
121119
|
-
|
|
121120
|
-
*
|
|
121121
|
-
* @type {Boolean}
|
|
121122
|
-
* @private
|
|
121123
|
-
*/
|
|
121124
|
-
setSelected(selected) {
|
|
121125
|
-
this._selected = !!selected;
|
|
121126
|
-
this._mesh.edgeMaterial.edgeWidth = selected ? 3 : 1;
|
|
121127
|
-
this._mesh.highlightMaterial.edgeWidth = selected ? 3 : 1;
|
|
121150
|
+
this._sectionPlane.pos = newSectionPos;
|
|
121151
|
+
}
|
|
121128
121152
|
|
|
121129
|
-
|
|
121153
|
+
get pos() {
|
|
121154
|
+
return this._pos;
|
|
121155
|
+
}
|
|
121130
121156
|
|
|
121131
|
-
|
|
121132
|
-
|
|
121133
|
-
|
|
121134
|
-
* @type {Boolean}
|
|
121135
|
-
* @private
|
|
121136
|
-
*/
|
|
121137
|
-
getSelected() {
|
|
121138
|
-
return this._selected;
|
|
121139
|
-
}
|
|
121157
|
+
/** @private */
|
|
121158
|
+
_setPos(xyz) {
|
|
121159
|
+
this._pos.set(xyz);
|
|
121140
121160
|
|
|
121141
|
-
|
|
121142
|
-
destroy() {
|
|
121143
|
-
this._sectionPlane.off(this._onSectionPlanePos);
|
|
121144
|
-
this._sectionPlane.off(this._onSectionPlaneDir);
|
|
121145
|
-
this._mesh.destroy();
|
|
121146
|
-
}
|
|
121147
|
-
}
|
|
121148
|
-
|
|
121149
|
-
/**
|
|
121150
|
-
* @desc An interactive 3D overview for navigating the {@link SectionPlane}s created by its {@link SectionPlanesPlugin}.
|
|
121151
|
-
*
|
|
121152
|
-
* * Located at {@link SectionPlanesPlugin#overview}.
|
|
121153
|
-
* * Renders the overview on a separate canvas at a corner of the {@link Viewer}'s {@link Scene} {@link Canvas}.
|
|
121154
|
-
* * The overview shows a 3D plane object for each {@link SectionPlane} in the {@link Scene}.
|
|
121155
|
-
* * Click a plane object in the overview to toggle the visibility of a 3D gizmo to edit the position and orientation of its {@link SectionPlane}.
|
|
121156
|
-
*
|
|
121157
|
-
* @private
|
|
121158
|
-
*/
|
|
121159
|
-
class Overview$1 {
|
|
121161
|
+
worldToRTCPos(this._pos, this._origin, this._rtcPos);
|
|
121160
121162
|
|
|
121161
|
-
|
|
121162
|
-
|
|
121163
|
-
|
|
121164
|
-
constructor(plugin, cfg) {
|
|
121163
|
+
this._rootNode.origin = this._origin;
|
|
121164
|
+
this._rootNode.position = this._rtcPos;
|
|
121165
|
+
}
|
|
121165
121166
|
|
|
121166
|
-
|
|
121167
|
-
|
|
121168
|
-
|
|
121167
|
+
/** @private */
|
|
121168
|
+
_setDir(xyz) {
|
|
121169
|
+
this._baseDir.set(xyz);
|
|
121170
|
+
this._rootNode.quaternion = math.vec3PairToQuaternion(zeroVec$2, xyz, quat$2);
|
|
121171
|
+
}
|
|
121169
121172
|
|
|
121170
|
-
|
|
121171
|
-
|
|
121172
|
-
|
|
121173
|
-
|
|
121174
|
-
|
|
121175
|
-
|
|
121173
|
+
_setSectionPlaneDir(dir) {
|
|
121174
|
+
if (this._sectionPlane) {
|
|
121175
|
+
this._ignoreNextSectionPlaneDirUpdate = true;
|
|
121176
|
+
this._sectionPlane.dir = dir;
|
|
121177
|
+
}
|
|
121178
|
+
}
|
|
121176
121179
|
|
|
121177
|
-
|
|
121180
|
+
/**
|
|
121181
|
+
* Sets if this Control is visible.
|
|
121182
|
+
*
|
|
121183
|
+
* @type {Boolean}
|
|
121184
|
+
*/
|
|
121185
|
+
setVisible(visible = true) {
|
|
121186
|
+
if (this._visible === visible) {
|
|
121187
|
+
return;
|
|
121188
|
+
}
|
|
121189
|
+
this._visible = visible;
|
|
121190
|
+
var id;
|
|
121191
|
+
for (id in this._displayMeshes) {
|
|
121192
|
+
if (this._displayMeshes.hasOwnProperty(id)) {
|
|
121193
|
+
this._displayMeshes[id].visible = visible;
|
|
121194
|
+
}
|
|
121195
|
+
}
|
|
121196
|
+
if (!visible) {
|
|
121197
|
+
for (id in this._affordanceMeshes) {
|
|
121198
|
+
if (this._affordanceMeshes.hasOwnProperty(id)) {
|
|
121199
|
+
this._affordanceMeshes[id].visible = visible;
|
|
121200
|
+
}
|
|
121201
|
+
}
|
|
121202
|
+
}
|
|
121203
|
+
}
|
|
121178
121204
|
|
|
121179
|
-
|
|
121180
|
-
|
|
121181
|
-
|
|
121182
|
-
|
|
121183
|
-
|
|
121205
|
+
/**
|
|
121206
|
+
* Gets if this Control is visible.
|
|
121207
|
+
*
|
|
121208
|
+
* @type {Boolean}
|
|
121209
|
+
*/
|
|
121210
|
+
getVisible() {
|
|
121211
|
+
return this._visible;
|
|
121212
|
+
}
|
|
121184
121213
|
|
|
121185
|
-
|
|
121214
|
+
/**
|
|
121215
|
+
* Sets if this Control is culled. This is called by SectionPlanesPlugin to
|
|
121216
|
+
* temporarily hide the Control while a snapshot is being taken by Viewer#getSnapshot().
|
|
121217
|
+
* @param culled
|
|
121218
|
+
*/
|
|
121219
|
+
setCulled(culled) {
|
|
121220
|
+
var id;
|
|
121221
|
+
for (id in this._displayMeshes) {
|
|
121222
|
+
if (this._displayMeshes.hasOwnProperty(id)) {
|
|
121223
|
+
this._displayMeshes[id].culled = culled;
|
|
121224
|
+
}
|
|
121225
|
+
}
|
|
121226
|
+
if (!culled) {
|
|
121227
|
+
for (id in this._affordanceMeshes) {
|
|
121228
|
+
if (this._affordanceMeshes.hasOwnProperty(id)) {
|
|
121229
|
+
this._affordanceMeshes[id].culled = culled;
|
|
121230
|
+
}
|
|
121231
|
+
}
|
|
121232
|
+
}
|
|
121233
|
+
}
|
|
121186
121234
|
|
|
121187
|
-
|
|
121188
|
-
|
|
121189
|
-
|
|
121235
|
+
/**
|
|
121236
|
+
* Builds the Entities that represent this Control.
|
|
121237
|
+
* @private
|
|
121238
|
+
*/
|
|
121239
|
+
_createNodes() {
|
|
121240
|
+
const NO_STATE_INHERIT = false;
|
|
121241
|
+
const scene = this._viewer.scene;
|
|
121190
121242
|
|
|
121191
|
-
|
|
121243
|
+
this._rootNode = new Node$2(scene, {
|
|
121244
|
+
position: [0, 0, 0],
|
|
121245
|
+
scale: [5, 5, 5],
|
|
121246
|
+
isObject: false
|
|
121247
|
+
});
|
|
121192
121248
|
|
|
121193
|
-
|
|
121194
|
-
// Init scene
|
|
121195
|
-
//--------------------------------------------------------------------------------------------------------------
|
|
121249
|
+
const rootNode = this._rootNode;
|
|
121196
121250
|
|
|
121197
|
-
|
|
121198
|
-
|
|
121199
|
-
|
|
121200
|
-
|
|
121201
|
-
|
|
121202
|
-
|
|
121203
|
-
|
|
121204
|
-
|
|
121205
|
-
|
|
121206
|
-
|
|
121207
|
-
|
|
121208
|
-
|
|
121209
|
-
|
|
121210
|
-
|
|
121211
|
-
|
|
121212
|
-
|
|
121213
|
-
|
|
121214
|
-
|
|
121215
|
-
|
|
121216
|
-
|
|
121217
|
-
|
|
121218
|
-
|
|
121219
|
-
|
|
121251
|
+
const newMesh = (color) => {
|
|
121252
|
+
return new Mesh(rootNode, {
|
|
121253
|
+
geometry: MeshConfigs.geometry,
|
|
121254
|
+
material: new PhongMaterial(rootNode, {
|
|
121255
|
+
emissive: [0, 0, 0],
|
|
121256
|
+
diffuse: color,
|
|
121257
|
+
backfaces: true
|
|
121258
|
+
}),
|
|
121259
|
+
opacity: this._planeOpacity,
|
|
121260
|
+
ghosted: true,
|
|
121261
|
+
ghostMaterial: new EmphasisMaterial(rootNode, {
|
|
121262
|
+
edges: false,
|
|
121263
|
+
filled: true,
|
|
121264
|
+
fillColor: color,
|
|
121265
|
+
fillAlpha: 0.1,
|
|
121266
|
+
backfaces: true
|
|
121267
|
+
}),
|
|
121268
|
+
pickable: true,
|
|
121269
|
+
collidable: true,
|
|
121270
|
+
clippable: false,
|
|
121271
|
+
visible: false,
|
|
121272
|
+
scale: [2.4, 2.4, 1],
|
|
121273
|
+
isObject: false
|
|
121274
|
+
});
|
|
121275
|
+
};
|
|
121220
121276
|
|
|
121221
|
-
|
|
121222
|
-
|
|
121277
|
+
this._displayMeshes = {
|
|
121278
|
+
front_plane: rootNode.addChild(newMesh(this._controlFillColor), NO_STATE_INHERIT),
|
|
121279
|
+
back_plane: rootNode.addChild(newMesh(this._controlFillColor), NO_STATE_INHERIT),
|
|
121280
|
+
right_plane: rootNode.addChild(newMesh(this._controlFillColor), NO_STATE_INHERIT),
|
|
121281
|
+
left_plane: rootNode.addChild(newMesh(this._controlFillColor), NO_STATE_INHERIT),
|
|
121282
|
+
top_plane: rootNode.addChild(newMesh(this._controlFillColor), NO_STATE_INHERIT),
|
|
121283
|
+
bottom_plane: rootNode.addChild(newMesh(this._controlFillColor), NO_STATE_INHERIT)
|
|
121284
|
+
};
|
|
121223
121285
|
|
|
121224
|
-
|
|
121286
|
+
this._affordanceMeshes = {
|
|
121287
|
+
front_plane: rootNode.addChild(newMesh(this._controlEdgeColor), NO_STATE_INHERIT),
|
|
121288
|
+
back_plane: rootNode.addChild(newMesh(this._controlEdgeColor), NO_STATE_INHERIT),
|
|
121289
|
+
right_plane: rootNode.addChild(newMesh(this._controlEdgeColor), NO_STATE_INHERIT),
|
|
121290
|
+
left_plane: rootNode.addChild(newMesh(this._controlEdgeColor), NO_STATE_INHERIT),
|
|
121291
|
+
top_plane: rootNode.addChild(newMesh(this._controlEdgeColor), NO_STATE_INHERIT),
|
|
121292
|
+
bottom_plane: rootNode.addChild(newMesh(this._controlEdgeColor), NO_STATE_INHERIT)
|
|
121293
|
+
};
|
|
121294
|
+
}
|
|
121225
121295
|
|
|
121226
|
-
|
|
121227
|
-
|
|
121228
|
-
|
|
121296
|
+
_bindEvents() {
|
|
121297
|
+
const self = this;
|
|
121298
|
+
var grabbed = false;
|
|
121299
|
+
const DRAG_ACTIONS = {
|
|
121300
|
+
none: -1,
|
|
121301
|
+
left_Translate: 0,
|
|
121302
|
+
top_Translate: 1,
|
|
121303
|
+
front_Translate: 2,
|
|
121304
|
+
right_Translate: 3,
|
|
121305
|
+
bottom_Translate: 4,
|
|
121306
|
+
back_Translate: 5
|
|
121307
|
+
};
|
|
121308
|
+
const rootNode = this._rootNode;
|
|
121309
|
+
var nextDragAction = null; // As we hover grabbed an arrow or hoop, self is the action we would do if we then dragged it.
|
|
121310
|
+
var dragAction = null; // Action we're doing while we drag an arrow or hoop.
|
|
121311
|
+
const lastCanvasPos = math.vec2();
|
|
121312
|
+
this.lastCanvasPos = lastCanvasPos;
|
|
121313
|
+
const xBaseAxis = math.vec3([1, 0, 0]);
|
|
121314
|
+
const yBaseAxis = math.vec3([0, 1, 0]);
|
|
121315
|
+
const zBaseAxis = math.vec3([0, 0, 1]);
|
|
121229
121316
|
|
|
121230
|
-
|
|
121231
|
-
|
|
121232
|
-
|
|
121233
|
-
const eyeLookVec = math.vec3();
|
|
121234
|
-
const eyeLookVecOverview = math.vec3();
|
|
121235
|
-
const upOverview = math.vec3();
|
|
121236
|
-
|
|
121237
|
-
this._synchCamera = () => {
|
|
121238
|
-
const eye = this._viewer.camera.eye;
|
|
121239
|
-
const look = this._viewer.camera.look;
|
|
121240
|
-
const up = this._viewer.camera.up;
|
|
121241
|
-
math.mulVec3Scalar(math.normalizeVec3(math.subVec3(eye, look, eyeLookVec)), 7);
|
|
121242
|
-
if (this._zUp) { // +Z up
|
|
121243
|
-
math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
|
|
121244
|
-
math.transformVec3(matrix, up, upOverview);
|
|
121245
|
-
camera.look = [0, 0, 0];
|
|
121246
|
-
camera.eye = math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
|
|
121247
|
-
camera.up = math.transformPoint3(matrix, up, upOverview);
|
|
121248
|
-
} else { // +Y up
|
|
121249
|
-
camera.look = [0, 0, 0];
|
|
121250
|
-
camera.eye = eyeLookVec;
|
|
121251
|
-
camera.up = up;
|
|
121252
|
-
}
|
|
121253
|
-
};
|
|
121254
|
-
}
|
|
121317
|
+
const canvas = this._viewer.scene.canvas.canvas;
|
|
121318
|
+
const camera = this._viewer.camera;
|
|
121319
|
+
const scene = this._viewer.scene;
|
|
121255
121320
|
|
|
121256
|
-
|
|
121321
|
+
{
|
|
121322
|
+
// Keep gizmo screen size constant
|
|
121323
|
+
const tempVec3a = math.vec3([0, 0, 0]);
|
|
121324
|
+
let lastDist = -1;
|
|
121257
121325
|
|
|
121258
|
-
|
|
121326
|
+
this._onCameraViewMatrix = scene.camera.on("viewMatrix", () => {
|
|
121327
|
+
});
|
|
121259
121328
|
|
|
121260
|
-
|
|
121261
|
-
|
|
121262
|
-
});
|
|
121329
|
+
this._onCameraProjMatrix = scene.camera.on("projMatrix", () => {
|
|
121330
|
+
});
|
|
121263
121331
|
|
|
121264
|
-
|
|
121265
|
-
|
|
121266
|
-
//--------------------------------------------------------------------------------------------------------------
|
|
121332
|
+
this._onSceneTick = scene.on("tick", () => {
|
|
121333
|
+
const dist = Math.abs(math.lenVec3(math.subVec3(scene.camera.eye, this._pos, tempVec3a)));
|
|
121267
121334
|
|
|
121268
|
-
|
|
121269
|
-
|
|
121335
|
+
if (dist !== lastDist) {
|
|
121336
|
+
if (camera.projection === "perspective") {
|
|
121337
|
+
const worldSize = Math.tan(camera.perspective.fov * math.DEGTORAD) * dist;
|
|
121338
|
+
const size = this._controlSize * worldSize;
|
|
121339
|
+
rootNode.scale = [size, size, size];
|
|
121340
|
+
lastDist = dist;
|
|
121341
|
+
}
|
|
121342
|
+
}
|
|
121270
121343
|
|
|
121271
|
-
|
|
121272
|
-
|
|
121273
|
-
|
|
121274
|
-
|
|
121275
|
-
|
|
121276
|
-
|
|
121277
|
-
|
|
121278
|
-
|
|
121279
|
-
if (plane) {
|
|
121280
|
-
this._onHoverLeavePlane(hoveredEntity.id);
|
|
121281
|
-
}
|
|
121282
|
-
}
|
|
121283
|
-
hoveredEntity = hit.entity;
|
|
121284
|
-
const plane = this._planes[hoveredEntity.id];
|
|
121285
|
-
if (plane) {
|
|
121286
|
-
this._onHoverEnterPlane(hoveredEntity.id);
|
|
121287
|
-
}
|
|
121288
|
-
}
|
|
121289
|
-
} else {
|
|
121290
|
-
if (hoveredEntity) {
|
|
121291
|
-
this._onHoverLeavePlane(hoveredEntity.id);
|
|
121292
|
-
hoveredEntity = null;
|
|
121293
|
-
}
|
|
121294
|
-
}
|
|
121295
|
-
});
|
|
121344
|
+
if (camera.projection === "ortho") {
|
|
121345
|
+
const worldSize = camera.ortho.scale / 10;
|
|
121346
|
+
const size = worldSize;
|
|
121347
|
+
rootNode.scale = [size, size, size];
|
|
121348
|
+
lastDist = dist;
|
|
121349
|
+
}
|
|
121350
|
+
});
|
|
121351
|
+
}
|
|
121296
121352
|
|
|
121297
|
-
|
|
121298
|
-
|
|
121299
|
-
|
|
121300
|
-
|
|
121301
|
-
|
|
121302
|
-
|
|
121303
|
-
|
|
121304
|
-
|
|
121305
|
-
|
|
121306
|
-
|
|
121353
|
+
//鼠标获取屏幕点击坐标
|
|
121354
|
+
const getClickCoordsWithinElement = (function () {
|
|
121355
|
+
const canvasPos = new Float64Array(2);
|
|
121356
|
+
return function (event) {
|
|
121357
|
+
if (!event) {
|
|
121358
|
+
event = window.event;
|
|
121359
|
+
canvasPos[0] = event.x;
|
|
121360
|
+
canvasPos[1] = event.y;
|
|
121361
|
+
} else {
|
|
121362
|
+
var element = event.target;
|
|
121363
|
+
var totalOffsetLeft = 0;
|
|
121364
|
+
var totalOffsetTop = 0;
|
|
121307
121365
|
|
|
121308
|
-
|
|
121309
|
-
|
|
121310
|
-
|
|
121311
|
-
|
|
121312
|
-
|
|
121313
|
-
|
|
121314
|
-
|
|
121366
|
+
while (element.offsetParent) {
|
|
121367
|
+
totalOffsetLeft += element.offsetLeft;
|
|
121368
|
+
totalOffsetTop += element.offsetTop;
|
|
121369
|
+
element = element.offsetParent;
|
|
121370
|
+
}
|
|
121371
|
+
canvasPos[0] = event.pageX - totalOffsetLeft;
|
|
121372
|
+
canvasPos[1] = event.pageY - totalOffsetTop;
|
|
121373
|
+
}
|
|
121374
|
+
return canvasPos;
|
|
121375
|
+
};
|
|
121376
|
+
})();
|
|
121315
121377
|
|
|
121316
|
-
|
|
121317
|
-
|
|
121318
|
-
|
|
121378
|
+
//触屏获取屏幕点击坐标
|
|
121379
|
+
const getTouchCoordsWithinElement = (function () {
|
|
121380
|
+
const canvasPos = new Float64Array(2);
|
|
121381
|
+
return function (event) {
|
|
121382
|
+
if (!event) {
|
|
121383
|
+
event = window.event;
|
|
121384
|
+
}
|
|
121385
|
+
if (event.touches && event.touches.length) {
|
|
121386
|
+
// 如果有触摸事件,使用第一个触摸点的坐标
|
|
121387
|
+
canvasPos[0] = event.touches[0].pageX;
|
|
121388
|
+
canvasPos[1] = event.touches[0].pageY;
|
|
121389
|
+
} else {
|
|
121390
|
+
// 否则,假设是鼠标事件
|
|
121391
|
+
var element = event.target;
|
|
121392
|
+
var totalOffsetLeft = 0;
|
|
121393
|
+
var totalOffsetTop = 0;
|
|
121319
121394
|
|
|
121320
|
-
|
|
121321
|
-
|
|
121395
|
+
while (element.offsetParent) {
|
|
121396
|
+
totalOffsetLeft += element.offsetLeft;
|
|
121397
|
+
totalOffsetTop += element.offsetTop;
|
|
121398
|
+
element = element.offsetParent;
|
|
121399
|
+
}
|
|
121400
|
+
canvasPos[0] = event.pageX - totalOffsetLeft;
|
|
121401
|
+
canvasPos[1] = event.pageY - totalOffsetTop;
|
|
121402
|
+
}
|
|
121403
|
+
return canvasPos;
|
|
121404
|
+
};
|
|
121405
|
+
})();
|
|
121322
121406
|
|
|
121323
|
-
|
|
121324
|
-
|
|
121325
|
-
|
|
121326
|
-
|
|
121327
|
-
|
|
121328
|
-
|
|
121407
|
+
const localToWorldVec = (function () {
|
|
121408
|
+
const mat = math.mat4();
|
|
121409
|
+
return function (localVec, worldVec) {
|
|
121410
|
+
math.quaternionToMat4(self._rootNode.quaternion, mat);
|
|
121411
|
+
math.transformVec3(mat, localVec, worldVec);
|
|
121412
|
+
math.normalizeVec3(worldVec);
|
|
121413
|
+
return worldVec;
|
|
121414
|
+
};
|
|
121415
|
+
})();
|
|
121329
121416
|
|
|
121330
|
-
|
|
121331
|
-
|
|
121332
|
-
|
|
121333
|
-
|
|
121334
|
-
|
|
121335
|
-
|
|
121336
|
-
|
|
121337
|
-
|
|
121417
|
+
var getTranslationPlane = (function () {
|
|
121418
|
+
const planeNormal = math.vec3();
|
|
121419
|
+
return function (worldAxis) {
|
|
121420
|
+
const absX = Math.abs(worldAxis[0]);
|
|
121421
|
+
if (absX > Math.abs(worldAxis[1]) && absX > Math.abs(worldAxis[2])) {
|
|
121422
|
+
math.cross3Vec3(worldAxis, [0, 1, 0], planeNormal);
|
|
121423
|
+
} else {
|
|
121424
|
+
math.cross3Vec3(worldAxis, [1, 0, 0], planeNormal);
|
|
121425
|
+
}
|
|
121426
|
+
math.cross3Vec3(planeNormal, worldAxis, planeNormal);
|
|
121427
|
+
math.normalizeVec3(planeNormal);
|
|
121428
|
+
return planeNormal;
|
|
121429
|
+
};
|
|
121430
|
+
})();
|
|
121338
121431
|
|
|
121339
|
-
|
|
121340
|
-
|
|
121341
|
-
|
|
121342
|
-
|
|
121343
|
-
|
|
121344
|
-
|
|
121345
|
-
|
|
121346
|
-
|
|
121432
|
+
const dragTranslateSectionPlane = (function () {
|
|
121433
|
+
const p1 = math.vec3();
|
|
121434
|
+
const p2 = math.vec3();
|
|
121435
|
+
const worldAxis = math.vec4();
|
|
121436
|
+
return function (baseAxis, fromMouse, toMouse) {
|
|
121437
|
+
localToWorldVec(baseAxis, worldAxis);
|
|
121438
|
+
const planeNormal = getTranslationPlane(worldAxis, fromMouse, toMouse);
|
|
121439
|
+
getPointerPlaneIntersect(fromMouse, planeNormal, p1);
|
|
121440
|
+
getPointerPlaneIntersect(toMouse, planeNormal, p2);
|
|
121441
|
+
math.subVec3(p2, p1);
|
|
121442
|
+
const dot = math.dotVec3(p2, worldAxis);
|
|
121443
|
+
self._pos[0] += worldAxis[0] * dot;
|
|
121444
|
+
self._pos[1] += worldAxis[1] * dot;
|
|
121445
|
+
self._pos[2] += worldAxis[2] * dot;
|
|
121446
|
+
self._rootNode.position = self._pos;
|
|
121447
|
+
if (self._sectionPlane) {
|
|
121448
|
+
self._sectionPlane.pos = self._pos;
|
|
121449
|
+
}
|
|
121450
|
+
};
|
|
121451
|
+
})();
|
|
121347
121452
|
|
|
121348
|
-
|
|
121349
|
-
|
|
121350
|
-
|
|
121351
|
-
|
|
121352
|
-
|
|
121353
|
-
|
|
121354
|
-
|
|
121453
|
+
var dragRotateSectionPlane = (function () {
|
|
121454
|
+
const p1 = math.vec4();
|
|
121455
|
+
const p2 = math.vec4();
|
|
121456
|
+
const c = math.vec4();
|
|
121457
|
+
const worldAxis = math.vec4();
|
|
121458
|
+
return function (baseAxis, fromMouse, toMouse) {
|
|
121459
|
+
localToWorldVec(baseAxis, worldAxis);
|
|
121460
|
+
const hasData =
|
|
121461
|
+
getPointerPlaneIntersect(fromMouse, worldAxis, p1) && getPointerPlaneIntersect(toMouse, worldAxis, p2);
|
|
121462
|
+
if (!hasData) {
|
|
121463
|
+
// Find intersections with view plane and project down to origin
|
|
121464
|
+
const planeNormal = getTranslationPlane(worldAxis, fromMouse, toMouse);
|
|
121465
|
+
getPointerPlaneIntersect(fromMouse, planeNormal, p1, 1); // Ensure plane moves closer to camera so angles become workable
|
|
121466
|
+
getPointerPlaneIntersect(toMouse, planeNormal, p2, 1);
|
|
121467
|
+
var dot = math.dotVec3(p1, worldAxis);
|
|
121468
|
+
p1[0] -= dot * worldAxis[0];
|
|
121469
|
+
p1[1] -= dot * worldAxis[1];
|
|
121470
|
+
p1[2] -= dot * worldAxis[2];
|
|
121471
|
+
dot = math.dotVec3(p2, worldAxis);
|
|
121472
|
+
p2[0] -= dot * worldAxis[0];
|
|
121473
|
+
p2[1] -= dot * worldAxis[1];
|
|
121474
|
+
p2[2] -= dot * worldAxis[2];
|
|
121475
|
+
}
|
|
121476
|
+
math.normalizeVec3(p1);
|
|
121477
|
+
math.normalizeVec3(p2);
|
|
121478
|
+
dot = math.dotVec3(p1, p2);
|
|
121479
|
+
dot = math.clamp(dot, -1.0, 1.0); // Rounding errors cause dot to exceed allowed range
|
|
121480
|
+
var incDegrees = Math.acos(dot) * math.RADTODEG;
|
|
121481
|
+
math.cross3Vec3(p1, p2, c);
|
|
121482
|
+
if (math.dotVec3(c, worldAxis) < 0.0) {
|
|
121483
|
+
incDegrees = -incDegrees;
|
|
121484
|
+
}
|
|
121485
|
+
self._rootNode.rotate(baseAxis, incDegrees);
|
|
121486
|
+
rotateSectionPlane();
|
|
121487
|
+
};
|
|
121488
|
+
})();
|
|
121489
|
+
|
|
121490
|
+
var getPointerPlaneIntersect = (function () {
|
|
121491
|
+
const dir = math.vec4([0, 0, 0, 1]);
|
|
121492
|
+
const matrix = math.mat4();
|
|
121493
|
+
return function (mouse, axis, dest, offset) {
|
|
121494
|
+
offset = offset || 0;
|
|
121495
|
+
dir[0] = (mouse[0] / canvas.width) * 2.0 - 1.0;
|
|
121496
|
+
dir[1] = -((mouse[1] / canvas.height) * 2.0 - 1.0);
|
|
121497
|
+
dir[2] = 0.0;
|
|
121498
|
+
dir[3] = 1.0;
|
|
121499
|
+
math.mulMat4(camera.projMatrix, camera.viewMatrix, matrix); // Unproject norm device coords to view coords
|
|
121500
|
+
math.inverseMat4(matrix);
|
|
121501
|
+
math.transformVec4(matrix, dir, dir);
|
|
121502
|
+
math.mulVec4Scalar(dir, 1.0 / dir[3]); // This is now point A on the ray in world space
|
|
121503
|
+
var rayO = camera.eye; // The direction
|
|
121504
|
+
math.subVec4(dir, rayO, dir);
|
|
121505
|
+
const origin = self._sectionPlane.pos; // Plane origin:
|
|
121506
|
+
var d = -math.dotVec3(origin, axis) - offset;
|
|
121507
|
+
var dot = math.dotVec3(axis, dir);
|
|
121508
|
+
if (Math.abs(dot) > 0.005) {
|
|
121509
|
+
var t = -(math.dotVec3(axis, rayO) + d) / dot;
|
|
121510
|
+
math.mulVec3Scalar(dir, t, dest);
|
|
121511
|
+
math.addVec3(dest, rayO);
|
|
121512
|
+
math.subVec3(dest, origin, dest);
|
|
121513
|
+
return true;
|
|
121514
|
+
}
|
|
121515
|
+
return false;
|
|
121516
|
+
};
|
|
121517
|
+
})();
|
|
121518
|
+
|
|
121519
|
+
const rotateSectionPlane = (function () {
|
|
121520
|
+
const dir = math.vec3();
|
|
121521
|
+
const mat = math.mat4();
|
|
121522
|
+
return function () {
|
|
121523
|
+
if (self.sectionPlane) {
|
|
121524
|
+
math.quaternionToMat4(rootNode.quaternion, mat); // << ---
|
|
121525
|
+
math.transformVec3(mat, [0, 0, 1], dir);
|
|
121526
|
+
self._setSectionPlaneDir(dir);
|
|
121527
|
+
}
|
|
121528
|
+
};
|
|
121529
|
+
})();
|
|
121530
|
+
|
|
121531
|
+
{
|
|
121532
|
+
var down = false;
|
|
121533
|
+
var lastAffordanceMesh;
|
|
121534
|
+
|
|
121535
|
+
this._onCameraControlHover = this._viewer.cameraControl.on("hoverEnter", (hit) => {
|
|
121536
|
+
if (!this._visible) {
|
|
121537
|
+
return;
|
|
121538
|
+
}
|
|
121539
|
+
if (down) {
|
|
121540
|
+
return;
|
|
121541
|
+
}
|
|
121542
|
+
grabbed = false;
|
|
121543
|
+
if (lastAffordanceMesh) {
|
|
121544
|
+
lastAffordanceMesh.visible = false;
|
|
121545
|
+
}
|
|
121546
|
+
var affordanceMesh;
|
|
121547
|
+
const meshId = hit.entity.id;
|
|
121548
|
+
switch (meshId) {
|
|
121549
|
+
case this._displayMeshes.plane.id:
|
|
121550
|
+
affordanceMesh = this._affordanceMeshes.plane;
|
|
121551
|
+
nextDragAction = DRAG_ACTIONS.front_Translate;
|
|
121552
|
+
break;
|
|
121553
|
+
|
|
121554
|
+
case this._displayMeshes.xAxisArrowHandle.id:
|
|
121555
|
+
affordanceMesh = this._affordanceMeshes.xAxisArrow;
|
|
121556
|
+
nextDragAction = DRAG_ACTIONS.xTranslate;
|
|
121557
|
+
break;
|
|
121558
|
+
|
|
121559
|
+
case this._displayMeshes.xAxisHandle.id:
|
|
121560
|
+
affordanceMesh = this._affordanceMeshes.xAxisArrow;
|
|
121561
|
+
nextDragAction = DRAG_ACTIONS.xTranslate;
|
|
121562
|
+
break;
|
|
121563
|
+
|
|
121564
|
+
case this._displayMeshes.yAxisArrowHandle.id:
|
|
121565
|
+
affordanceMesh = this._affordanceMeshes.yAxisArrow;
|
|
121566
|
+
nextDragAction = DRAG_ACTIONS.yTranslate;
|
|
121567
|
+
break;
|
|
121568
|
+
|
|
121569
|
+
case this._displayMeshes.yShaftHandle.id:
|
|
121570
|
+
affordanceMesh = this._affordanceMeshes.yAxisArrow;
|
|
121571
|
+
nextDragAction = DRAG_ACTIONS.yTranslate;
|
|
121572
|
+
break;
|
|
121573
|
+
|
|
121574
|
+
case this._displayMeshes.zAxisArrowHandle.id:
|
|
121575
|
+
affordanceMesh = this._affordanceMeshes.zAxisArrow;
|
|
121576
|
+
nextDragAction = DRAG_ACTIONS.zTranslate;
|
|
121577
|
+
break;
|
|
121578
|
+
|
|
121579
|
+
case this._displayMeshes.zAxisHandle.id:
|
|
121580
|
+
affordanceMesh = this._affordanceMeshes.zAxisArrow;
|
|
121581
|
+
nextDragAction = DRAG_ACTIONS.zTranslate;
|
|
121582
|
+
break;
|
|
121583
|
+
|
|
121584
|
+
case this._displayMeshes.xCurveHandle.id:
|
|
121585
|
+
affordanceMesh = this._affordanceMeshes.xHoop;
|
|
121586
|
+
nextDragAction = DRAG_ACTIONS.xRotate;
|
|
121587
|
+
break;
|
|
121588
|
+
|
|
121589
|
+
default:
|
|
121590
|
+
nextDragAction = DRAG_ACTIONS.none;
|
|
121591
|
+
return; // Not clicked an arrow or hoop
|
|
121592
|
+
}
|
|
121593
|
+
if (affordanceMesh) {
|
|
121594
|
+
affordanceMesh.visible = true;
|
|
121595
|
+
}
|
|
121596
|
+
lastAffordanceMesh = affordanceMesh;
|
|
121597
|
+
grabbed = true;
|
|
121598
|
+
});
|
|
121599
|
+
|
|
121600
|
+
this._onCameraControlHoverLeave = this._viewer.cameraControl.on("hoverOutEntity", (hit) => {
|
|
121601
|
+
if (!this._visible) {
|
|
121602
|
+
return;
|
|
121603
|
+
}
|
|
121604
|
+
if (lastAffordanceMesh) {
|
|
121605
|
+
lastAffordanceMesh.visible = false;
|
|
121606
|
+
}
|
|
121607
|
+
lastAffordanceMesh = null;
|
|
121608
|
+
nextDragAction = DRAG_ACTIONS.none;
|
|
121609
|
+
});
|
|
121610
|
+
|
|
121611
|
+
//mousedown
|
|
121612
|
+
canvas.addEventListener(
|
|
121613
|
+
"mousedown",
|
|
121614
|
+
(this._canvasMouseDownListener = (e) => {
|
|
121615
|
+
e.preventDefault();
|
|
121616
|
+
if (!this._visible || !grabbed) return;
|
|
121617
|
+
|
|
121618
|
+
this._viewer.cameraControl.pointerEnabled = false;
|
|
121619
|
+
switch (e.which) {
|
|
121620
|
+
case 1: // Left button
|
|
121621
|
+
mouseDownLeft = true;
|
|
121622
|
+
down = true;
|
|
121623
|
+
var canvasPos = getClickCoordsWithinElement(e);
|
|
121624
|
+
dragAction = nextDragAction;
|
|
121625
|
+
lastCanvasPos[0] = canvasPos[0];
|
|
121626
|
+
lastCanvasPos[1] = canvasPos[1];
|
|
121627
|
+
break;
|
|
121628
|
+
}
|
|
121629
|
+
})
|
|
121630
|
+
);
|
|
121631
|
+
//mousemove
|
|
121632
|
+
canvas.addEventListener(
|
|
121633
|
+
"mousemove",
|
|
121634
|
+
(this._canvasMouseMoveListener = (e) => {
|
|
121635
|
+
if (!this._visible) {
|
|
121636
|
+
return;
|
|
121637
|
+
}
|
|
121638
|
+
if (!down) {
|
|
121639
|
+
return;
|
|
121640
|
+
}
|
|
121641
|
+
var canvasPos = getClickCoordsWithinElement(e);
|
|
121642
|
+
const x = canvasPos[0];
|
|
121643
|
+
const y = canvasPos[1];
|
|
121644
|
+
|
|
121645
|
+
switch (dragAction) {
|
|
121646
|
+
case DRAG_ACTIONS.xTranslate:
|
|
121647
|
+
dragTranslateSectionPlane(xBaseAxis, lastCanvasPos, canvasPos);
|
|
121648
|
+
break;
|
|
121649
|
+
case DRAG_ACTIONS.yTranslate:
|
|
121650
|
+
dragTranslateSectionPlane(yBaseAxis, lastCanvasPos, canvasPos);
|
|
121651
|
+
break;
|
|
121652
|
+
case DRAG_ACTIONS.zTranslate:
|
|
121653
|
+
dragTranslateSectionPlane(zBaseAxis, lastCanvasPos, canvasPos);
|
|
121654
|
+
break;
|
|
121655
|
+
case DRAG_ACTIONS.xRotate:
|
|
121656
|
+
dragRotateSectionPlane(xBaseAxis, lastCanvasPos, canvasPos);
|
|
121657
|
+
break;
|
|
121658
|
+
case DRAG_ACTIONS.yRotate:
|
|
121659
|
+
dragRotateSectionPlane(yBaseAxis, lastCanvasPos, canvasPos);
|
|
121660
|
+
break;
|
|
121661
|
+
case DRAG_ACTIONS.zRotate:
|
|
121662
|
+
dragRotateSectionPlane(zBaseAxis, lastCanvasPos, canvasPos);
|
|
121663
|
+
break;
|
|
121664
|
+
}
|
|
121665
|
+
|
|
121666
|
+
lastCanvasPos[0] = x;
|
|
121667
|
+
lastCanvasPos[1] = y;
|
|
121668
|
+
})
|
|
121669
|
+
);
|
|
121670
|
+
//mouseup
|
|
121671
|
+
canvas.addEventListener(
|
|
121672
|
+
"mouseup",
|
|
121673
|
+
(this._canvasMouseUpListener = (e) => {
|
|
121674
|
+
if (!this._visible) return;
|
|
121675
|
+
this._viewer.cameraControl.pointerEnabled = true;
|
|
121676
|
+
if (!down) {
|
|
121677
|
+
return;
|
|
121678
|
+
}
|
|
121679
|
+
switch (e.which) {
|
|
121680
|
+
case 1: // Left button
|
|
121681
|
+
mouseDownLeft = false;
|
|
121682
|
+
break;
|
|
121683
|
+
case 2: // Middle/both buttons
|
|
121684
|
+
mouseDownMiddle = false;
|
|
121685
|
+
break;
|
|
121686
|
+
case 3: // Right button
|
|
121687
|
+
mouseDownRight = false;
|
|
121688
|
+
break;
|
|
121689
|
+
}
|
|
121690
|
+
down = false;
|
|
121691
|
+
grabbed = false;
|
|
121692
|
+
})
|
|
121693
|
+
);
|
|
121694
|
+
|
|
121695
|
+
//wheel
|
|
121696
|
+
canvas.addEventListener(
|
|
121697
|
+
"wheel",
|
|
121698
|
+
(this._canvasWheelListener = (e) => {
|
|
121699
|
+
if (!this._visible) {
|
|
121700
|
+
return;
|
|
121701
|
+
}
|
|
121702
|
+
var delta = Math.max(-1, Math.min(1, -e.deltaY * 40));
|
|
121703
|
+
if (delta === 0) {
|
|
121704
|
+
return;
|
|
121705
|
+
}
|
|
121706
|
+
})
|
|
121707
|
+
);
|
|
121708
|
+
|
|
121709
|
+
this._onCameraControlHover = this._viewer.cameraControl.on("touchEntity", (hit) => {
|
|
121710
|
+
if (!this._visible || down || grabbed) return;
|
|
121711
|
+
grabbed = false;
|
|
121712
|
+
if (lastAffordanceMesh) {
|
|
121713
|
+
lastAffordanceMesh.visible = false;
|
|
121714
|
+
}
|
|
121715
|
+
var affordanceMesh;
|
|
121716
|
+
const meshId = hit.entity.id;
|
|
121717
|
+
switch (meshId) {
|
|
121718
|
+
case this._displayMeshes.plane.id:
|
|
121719
|
+
affordanceMesh = this._affordanceMeshes.plane;
|
|
121720
|
+
nextDragAction = DRAG_ACTIONS.zTranslate;
|
|
121721
|
+
break;
|
|
121722
|
+
// case this._displayMeshes.xAxisArrowHandle.id:
|
|
121723
|
+
// affordanceMesh = this._affordanceMeshes.xAxisArrow;
|
|
121724
|
+
// nextDragAction = DRAG_ACTIONS.xTranslate;
|
|
121725
|
+
// break;
|
|
121726
|
+
|
|
121727
|
+
// case this._displayMeshes.xAxisHandle.id:
|
|
121728
|
+
// affordanceMesh = this._affordanceMeshes.xAxisArrow;
|
|
121729
|
+
// nextDragAction = DRAG_ACTIONS.xTranslate;
|
|
121730
|
+
// break;
|
|
121731
|
+
|
|
121732
|
+
// case this._displayMeshes.yAxisArrowHandle.id:
|
|
121733
|
+
// affordanceMesh = this._affordanceMeshes.yAxisArrow;
|
|
121734
|
+
// nextDragAction = DRAG_ACTIONS.yTranslate;
|
|
121735
|
+
// break;
|
|
121736
|
+
|
|
121737
|
+
// case this._displayMeshes.yShaftHandle.id:
|
|
121738
|
+
// affordanceMesh = this._affordanceMeshes.yAxisArrow;
|
|
121739
|
+
// nextDragAction = DRAG_ACTIONS.yTranslate;
|
|
121740
|
+
// break;
|
|
121741
|
+
|
|
121742
|
+
// case this._displayMeshes.zAxisArrowHandle.id:
|
|
121743
|
+
// affordanceMesh = this._affordanceMeshes.zAxisArrow;
|
|
121744
|
+
// nextDragAction = DRAG_ACTIONS.zTranslate;
|
|
121745
|
+
// break;
|
|
121746
|
+
|
|
121747
|
+
// case this._displayMeshes.zAxisHandle.id:
|
|
121748
|
+
// affordanceMesh = this._affordanceMeshes.zAxisArrow;
|
|
121749
|
+
// nextDragAction = DRAG_ACTIONS.zTranslate;
|
|
121750
|
+
// break;
|
|
121751
|
+
|
|
121752
|
+
// case this._displayMeshes.xCurveHandle.id:
|
|
121753
|
+
// affordanceMesh = this._affordanceMeshes.xHoop;
|
|
121754
|
+
// nextDragAction = DRAG_ACTIONS.xRotate;
|
|
121755
|
+
// break;
|
|
121756
|
+
|
|
121757
|
+
// case this._displayMeshes.yCurveHandle.id:
|
|
121758
|
+
// affordanceMesh = this._affordanceMeshes.yHoop;
|
|
121759
|
+
// nextDragAction = DRAG_ACTIONS.yRotate;
|
|
121760
|
+
// break;
|
|
121761
|
+
|
|
121762
|
+
// case this._displayMeshes.zCurveHandle.id:
|
|
121763
|
+
// affordanceMesh = this._affordanceMeshes.zHoop;
|
|
121764
|
+
// nextDragAction = DRAG_ACTIONS.zRotate;
|
|
121765
|
+
// break;
|
|
121766
|
+
|
|
121767
|
+
default:
|
|
121768
|
+
nextDragAction = DRAG_ACTIONS.none;
|
|
121769
|
+
return; // Not clicked an arrow or hoop
|
|
121770
|
+
}
|
|
121771
|
+
if (affordanceMesh) {
|
|
121772
|
+
affordanceMesh.visible = true;
|
|
121773
|
+
}
|
|
121774
|
+
lastAffordanceMesh = affordanceMesh;
|
|
121775
|
+
grabbed = true;
|
|
121776
|
+
});
|
|
121777
|
+
//touchstart
|
|
121778
|
+
canvas.addEventListener(
|
|
121779
|
+
"touchstart",
|
|
121780
|
+
(this._canvasMouseDownListener = (e) => {
|
|
121781
|
+
e.preventDefault();
|
|
121782
|
+
if (!this._visible || !grabbed) return;
|
|
121783
|
+
this._viewer.cameraControl.pointerEnabled = false;
|
|
121784
|
+
if (lastAffordanceMesh) {
|
|
121785
|
+
lastAffordanceMesh.visible = true;
|
|
121786
|
+
}
|
|
121787
|
+
down = true;
|
|
121788
|
+
var canvasPos = getTouchCoordsWithinElement(e);
|
|
121789
|
+
dragAction = nextDragAction;
|
|
121790
|
+
lastCanvasPos[0] = canvasPos[0];
|
|
121791
|
+
lastCanvasPos[1] = canvasPos[1];
|
|
121792
|
+
})
|
|
121793
|
+
);
|
|
121794
|
+
//touchmove
|
|
121795
|
+
canvas.addEventListener(
|
|
121796
|
+
"touchmove",
|
|
121797
|
+
(this._canvasMouseMoveListener = (e) => {
|
|
121798
|
+
if (!this._visible || !down) return;
|
|
121799
|
+
|
|
121800
|
+
var canvasPos = getTouchCoordsWithinElement(e);
|
|
121801
|
+
const x = canvasPos[0];
|
|
121802
|
+
const y = canvasPos[1];
|
|
121803
|
+
|
|
121804
|
+
switch (dragAction) {
|
|
121805
|
+
case DRAG_ACTIONS.xTranslate:
|
|
121806
|
+
dragTranslateSectionPlane(xBaseAxis, lastCanvasPos, canvasPos);
|
|
121807
|
+
break;
|
|
121808
|
+
case DRAG_ACTIONS.yTranslate:
|
|
121809
|
+
dragTranslateSectionPlane(yBaseAxis, lastCanvasPos, canvasPos);
|
|
121810
|
+
break;
|
|
121811
|
+
case DRAG_ACTIONS.zTranslate:
|
|
121812
|
+
dragTranslateSectionPlane(zBaseAxis, lastCanvasPos, canvasPos);
|
|
121813
|
+
break;
|
|
121814
|
+
case DRAG_ACTIONS.xRotate:
|
|
121815
|
+
dragRotateSectionPlane(xBaseAxis, lastCanvasPos, canvasPos);
|
|
121816
|
+
break;
|
|
121817
|
+
case DRAG_ACTIONS.yRotate:
|
|
121818
|
+
dragRotateSectionPlane(yBaseAxis, lastCanvasPos, canvasPos);
|
|
121819
|
+
break;
|
|
121820
|
+
case DRAG_ACTIONS.zRotate:
|
|
121821
|
+
dragRotateSectionPlane(zBaseAxis, lastCanvasPos, canvasPos);
|
|
121822
|
+
break;
|
|
121823
|
+
}
|
|
121824
|
+
|
|
121825
|
+
lastCanvasPos[0] = x;
|
|
121826
|
+
lastCanvasPos[1] = y;
|
|
121827
|
+
})
|
|
121828
|
+
);
|
|
121829
|
+
//touchend
|
|
121830
|
+
canvas.addEventListener(
|
|
121831
|
+
"touchend",
|
|
121832
|
+
(this._canvasTouchEndListener = (e) => {
|
|
121833
|
+
// if (!this._visible) return;
|
|
121834
|
+
this._viewer.cameraControl.pointerEnabled = true;
|
|
121835
|
+
if (lastAffordanceMesh) {
|
|
121836
|
+
lastAffordanceMesh.visible = false;
|
|
121837
|
+
}
|
|
121838
|
+
lastAffordanceMesh = null;
|
|
121839
|
+
nextDragAction = DRAG_ACTIONS.none;
|
|
121840
|
+
down = false;
|
|
121841
|
+
grabbed = false;
|
|
121842
|
+
})
|
|
121843
|
+
);
|
|
121844
|
+
canvas.addEventListener("touchcancel", this._canvasTouchEndListener);
|
|
121845
|
+
}
|
|
121846
|
+
}
|
|
121847
|
+
|
|
121848
|
+
_destroy() {
|
|
121849
|
+
this._unbindEvents();
|
|
121850
|
+
this._destroyNodes();
|
|
121851
|
+
}
|
|
121852
|
+
|
|
121853
|
+
_unbindEvents() {
|
|
121854
|
+
const viewer = this._viewer;
|
|
121855
|
+
const scene = viewer.scene;
|
|
121856
|
+
const canvas = scene.canvas.canvas;
|
|
121857
|
+
const camera = viewer.camera;
|
|
121858
|
+
const cameraControl = viewer.cameraControl;
|
|
121859
|
+
|
|
121860
|
+
scene.off(this._onSceneTick);
|
|
121861
|
+
|
|
121862
|
+
canvas.removeEventListener("mousedown", this._canvasMouseDownListener);
|
|
121863
|
+
canvas.removeEventListener("mousemove", this._canvasMouseMoveListener);
|
|
121864
|
+
canvas.removeEventListener("mouseup", this._canvasMouseUpListener);
|
|
121865
|
+
canvas.removeEventListener("wheel", this._canvasWheelListener);
|
|
121866
|
+
canvas.removeEventListener("touchend", this._canvasTouchEndListener);
|
|
121867
|
+
canvas.removeEventListener("touchcancel", this._canvasTouchEndListener);
|
|
121868
|
+
|
|
121869
|
+
camera.off(this._onCameraViewMatrix);
|
|
121870
|
+
camera.off(this._onCameraProjMatrix);
|
|
121871
|
+
|
|
121872
|
+
cameraControl.off(this._onCameraControlHover);
|
|
121873
|
+
cameraControl.off(this._onCameraControlHoverLeave);
|
|
121874
|
+
}
|
|
121875
|
+
|
|
121876
|
+
_destroyNodes() {
|
|
121877
|
+
this._setSectionPlane(null);
|
|
121878
|
+
this._rootNode.destroy();
|
|
121879
|
+
this._displayMeshes = {};
|
|
121880
|
+
this._affordanceMeshes = {};
|
|
121881
|
+
}
|
|
121882
|
+
}
|
|
121883
|
+
|
|
121884
|
+
const zeroVec$1 = new Float64Array([0, 0, 1]);
|
|
121885
|
+
const quat$1 = new Float64Array(4);
|
|
121886
|
+
|
|
121887
|
+
/**
|
|
121888
|
+
* Controls a {@link SectionPlane} with mouse and touch input.
|
|
121889
|
+
*
|
|
121890
|
+
* @private
|
|
121891
|
+
*/
|
|
121892
|
+
class ClippingPlane {
|
|
121893
|
+
/** @private */
|
|
121894
|
+
constructor(plugin, cfg) {
|
|
121895
|
+
/**
|
|
121896
|
+
* ID of this Control.
|
|
121897
|
+
*
|
|
121898
|
+
* SectionPlaneControls are mapped by this ID in {@link SectionPlanesPlugin#sectionPlaneControls}.
|
|
121899
|
+
*
|
|
121900
|
+
* @property id
|
|
121901
|
+
* @type {String|Number}
|
|
121902
|
+
*/
|
|
121903
|
+
this.id = null;
|
|
121904
|
+
this.type = "plane";
|
|
121905
|
+
|
|
121906
|
+
this._viewer = plugin.viewer;
|
|
121907
|
+
this._scene = plugin.viewer.scene;
|
|
121908
|
+
|
|
121909
|
+
this._controlFillColor = !!cfg && !!cfg.controlFillColor ? cfg.controlFillColor : [0.1, 0.4, 0.99];
|
|
121910
|
+
this._planeSize = !!cfg && !!cfg.planeSize ? cfg.planeSize : 1;
|
|
121911
|
+
this._controlSize = !!cfg && !!cfg.controlSize ? cfg.controlSize : 0.07;
|
|
121912
|
+
this._planeOpacity = !!cfg && !!cfg.planeOpacity ? cfg.planeOpacity : 0.4;
|
|
121913
|
+
|
|
121914
|
+
this._visible = false;
|
|
121915
|
+
this._pos = math.vec3(); // Full-precision position of the center of the Control
|
|
121916
|
+
this._origin = math.vec3();
|
|
121917
|
+
this._rtcPos = math.vec3();
|
|
121918
|
+
|
|
121919
|
+
this._baseDir = math.vec3(); // Saves direction of clip plane when we start dragging an arrow or ring.
|
|
121920
|
+
this._rootNode = null; // Root of Node graph that represents this control in the 3D scene
|
|
121921
|
+
this._displayMeshes = null; // Meshes that are always visible
|
|
121922
|
+
this._affordanceMeshes = null; // Meshes displayed momentarily for affordance
|
|
121923
|
+
|
|
121924
|
+
this._ignoreNextSectionPlaneDirUpdate = false;
|
|
121925
|
+
|
|
121926
|
+
this._createNodes();
|
|
121927
|
+
this._bindEvents();
|
|
121928
|
+
}
|
|
121929
|
+
|
|
121930
|
+
/**
|
|
121931
|
+
* Builds the Entities that represent this Control.
|
|
121932
|
+
* @private
|
|
121933
|
+
*/
|
|
121934
|
+
_createNodes() {
|
|
121935
|
+
const NO_STATE_INHERIT = false;
|
|
121936
|
+
const scene = this._viewer.scene;
|
|
121937
|
+
|
|
121938
|
+
this._rootNode = new Node$2(scene, {
|
|
121939
|
+
position: [0, 0, 0],
|
|
121940
|
+
scale: [5, 5, 5],
|
|
121941
|
+
isObject: false
|
|
121942
|
+
});
|
|
121943
|
+
|
|
121944
|
+
const rootNode = this._rootNode;
|
|
121945
|
+
|
|
121946
|
+
this._displayMeshes = {
|
|
121947
|
+
plane: rootNode.addChild(
|
|
121948
|
+
new Mesh(rootNode, {
|
|
121949
|
+
geometry: new ReadableGeometry(rootNode, {
|
|
121950
|
+
primitive: "triangles",
|
|
121951
|
+
positions: [
|
|
121952
|
+
0.5,
|
|
121953
|
+
0.5,
|
|
121954
|
+
0.0,
|
|
121955
|
+
0.5,
|
|
121956
|
+
-0.5,
|
|
121957
|
+
0.0, // 0
|
|
121958
|
+
-0.5,
|
|
121959
|
+
-0.5,
|
|
121960
|
+
0.0,
|
|
121961
|
+
-0.5,
|
|
121962
|
+
0.5,
|
|
121963
|
+
0.0, // 1
|
|
121964
|
+
0.5,
|
|
121965
|
+
0.5,
|
|
121966
|
+
-0.0,
|
|
121967
|
+
0.5,
|
|
121968
|
+
-0.5,
|
|
121969
|
+
-0.0, // 2
|
|
121970
|
+
-0.5,
|
|
121971
|
+
-0.5,
|
|
121972
|
+
-0.0,
|
|
121973
|
+
-0.5,
|
|
121974
|
+
0.5,
|
|
121975
|
+
-0.0 // 3
|
|
121976
|
+
],
|
|
121977
|
+
indices: [0, 1, 2, 2, 3, 0]
|
|
121978
|
+
}),
|
|
121979
|
+
material: new PhongMaterial(rootNode, {
|
|
121980
|
+
emissive: [0, 0, 0],
|
|
121981
|
+
diffuse: this._controlFillColor,
|
|
121982
|
+
backfaces: true
|
|
121983
|
+
}),
|
|
121984
|
+
opacity: this._planeOpacity,
|
|
121985
|
+
ghosted: true,
|
|
121986
|
+
ghostMaterial: new EmphasisMaterial(rootNode, {
|
|
121987
|
+
edges: false,
|
|
121988
|
+
filled: true,
|
|
121989
|
+
fillColor: this._controlFillColor ? this._controlFillColor : [0.1, 0.4, 0.99],
|
|
121990
|
+
fillAlpha: 0.1,
|
|
121991
|
+
backfaces: true
|
|
121992
|
+
}),
|
|
121993
|
+
pickable: true,
|
|
121994
|
+
collidable: true,
|
|
121995
|
+
clippable: false,
|
|
121996
|
+
visible: false,
|
|
121997
|
+
scale: [2.4 * this._planeSize, 2.4 * this._planeSize, 1 * this._planeSize],
|
|
121998
|
+
isObject: false
|
|
121999
|
+
}),
|
|
122000
|
+
NO_STATE_INHERIT
|
|
122001
|
+
)
|
|
122002
|
+
};
|
|
122003
|
+
|
|
122004
|
+
this._affordanceMeshes = {
|
|
122005
|
+
// plane: rootNode.addChild(
|
|
122006
|
+
// new Mesh(rootNode, {
|
|
122007
|
+
// geometry: new ReadableGeometry(rootNode, {
|
|
122008
|
+
// primitive: "triangles",
|
|
122009
|
+
// positions: [
|
|
122010
|
+
// 0.5,
|
|
122011
|
+
// 0.5,
|
|
122012
|
+
// 0.0,
|
|
122013
|
+
// 0.5,
|
|
122014
|
+
// -0.5,
|
|
122015
|
+
// 0.0, // 0
|
|
122016
|
+
// -0.5,
|
|
122017
|
+
// -0.5,
|
|
122018
|
+
// 0.0,
|
|
122019
|
+
// -0.5,
|
|
122020
|
+
// 0.5,
|
|
122021
|
+
// 0.0, // 1
|
|
122022
|
+
// 0.5,
|
|
122023
|
+
// 0.5,
|
|
122024
|
+
// -0.0,
|
|
122025
|
+
// 0.5,
|
|
122026
|
+
// -0.5,
|
|
122027
|
+
// -0.0, // 2
|
|
122028
|
+
// -0.5,
|
|
122029
|
+
// -0.5,
|
|
122030
|
+
// -0.0,
|
|
122031
|
+
// -0.5,
|
|
122032
|
+
// 0.5,
|
|
122033
|
+
// -0.0 // 3
|
|
122034
|
+
// ],
|
|
122035
|
+
// indices: [0, 1, 2, 2, 3, 0]
|
|
122036
|
+
// }),
|
|
122037
|
+
// material: new PhongMaterial(rootNode, {
|
|
122038
|
+
// emissive: [0, 0, 0],
|
|
122039
|
+
// diffuse: this._controlFillColor,
|
|
122040
|
+
// backfaces: true
|
|
122041
|
+
// }),
|
|
122042
|
+
// opacity: this._planeOpacity,
|
|
122043
|
+
// ghosted: true,
|
|
122044
|
+
// ghostMaterial: new EmphasisMaterial(rootNode, {
|
|
122045
|
+
// edges: false,
|
|
122046
|
+
// filled: true,
|
|
122047
|
+
// fillColor: this._controlFillColor,
|
|
122048
|
+
// fillAlpha: 0.1,
|
|
122049
|
+
// backfaces: true
|
|
122050
|
+
// }),
|
|
122051
|
+
// pickable: true,
|
|
122052
|
+
// collidable: true,
|
|
122053
|
+
// clippable: false,
|
|
122054
|
+
// visible: false,
|
|
122055
|
+
// scale: [2.4 * this._planeSize, 2.4 * this._planeSize, 1 * this._planeSize],
|
|
122056
|
+
// isObject: false
|
|
122057
|
+
// }),
|
|
122058
|
+
// NO_STATE_INHERIT
|
|
122059
|
+
// )
|
|
122060
|
+
};
|
|
122061
|
+
}
|
|
122062
|
+
|
|
122063
|
+
/**
|
|
122064
|
+
* Called by SectionPlanesPlugin to assign this Control to a SectionPlane.
|
|
122065
|
+
* SectionPlanesPlugin keeps SectionPlaneControls in a reuse pool.
|
|
122066
|
+
* Call with a null or undefined value to disconnect the Control ffrom whatever SectionPlane it was assigned to.
|
|
122067
|
+
* @private
|
|
122068
|
+
*/
|
|
122069
|
+
_setSectionPlane(sectionPlane) {
|
|
122070
|
+
if (this._sectionPlane) {
|
|
122071
|
+
this._sectionPlane.off(this._onSectionPlanePos);
|
|
122072
|
+
this._sectionPlane.off(this._onSectionPlaneDir);
|
|
122073
|
+
this._onSectionPlanePos = null;
|
|
122074
|
+
this._onSectionPlaneDir = null;
|
|
122075
|
+
this._sectionPlane = null;
|
|
122076
|
+
}
|
|
122077
|
+
if (sectionPlane) {
|
|
122078
|
+
this.id = sectionPlane.id;
|
|
122079
|
+
this._setPos(sectionPlane.pos);
|
|
122080
|
+
this._setDir(sectionPlane.dir);
|
|
122081
|
+
this._sectionPlane = sectionPlane;
|
|
122082
|
+
sectionPlane.control = this;
|
|
122083
|
+
this._onSectionPlanePos = sectionPlane.on("pos", () => {
|
|
122084
|
+
this._setPos(this._sectionPlane.pos);
|
|
122085
|
+
});
|
|
122086
|
+
this._onSectionPlaneDir = sectionPlane.on("dir", () => {
|
|
122087
|
+
if (!this._ignoreNextSectionPlaneDirUpdate) {
|
|
122088
|
+
this._setDir(this._sectionPlane.dir);
|
|
122089
|
+
} else {
|
|
122090
|
+
this._ignoreNextSectionPlaneDirUpdate = false;
|
|
122091
|
+
}
|
|
122092
|
+
});
|
|
122093
|
+
}
|
|
122094
|
+
}
|
|
122095
|
+
|
|
122096
|
+
/**
|
|
122097
|
+
* Gets the {@link SectionPlane} controlled by this Control.
|
|
122098
|
+
* @returns {SectionPlane} The SectionPlane.
|
|
122099
|
+
*/
|
|
122100
|
+
get sectionPlane() {
|
|
122101
|
+
return this._sectionPlane;
|
|
122102
|
+
}
|
|
122103
|
+
|
|
122104
|
+
/**
|
|
122105
|
+
* 设置剖切面位置
|
|
122106
|
+
* @param {any} value
|
|
122107
|
+
*/
|
|
122108
|
+
set pos(posRate) {
|
|
122109
|
+
if (posRate < 0 || posRate > 100) return;
|
|
122110
|
+
|
|
122111
|
+
const { aabb } = this._scene;
|
|
122112
|
+
const { look } = this._scene.camera;
|
|
122113
|
+
const xRange = aabb[3] - aabb[0]; //前后
|
|
122114
|
+
const yRange = aabb[4] - aabb[1]; //上下
|
|
122115
|
+
const zRange = aabb[5] - aabb[2]; //左右
|
|
122116
|
+
|
|
122117
|
+
const newSectionPos = math.vec3();
|
|
122118
|
+
newSectionPos[0] = this.pos[0];
|
|
122119
|
+
newSectionPos[1] = this.pos[1];
|
|
122120
|
+
newSectionPos[2] = this.pos[2];
|
|
122121
|
+
|
|
122122
|
+
const { dir } = this._sectionPlane;
|
|
122123
|
+
let rateDis;
|
|
122124
|
+
if (dir[0] != 0) {
|
|
122125
|
+
rateDis = (posRate / 100) * xRange;
|
|
122126
|
+
newSectionPos[0] = look[0] - xRange / 2 + rateDis; // console.log("xRange", rateDis, rateDis + aabb[0]);
|
|
122127
|
+
} else if (dir[1] != 0) {
|
|
122128
|
+
rateDis = (posRate / 100) * yRange;
|
|
122129
|
+
newSectionPos[1] = look[1] - yRange / 2 + rateDis; // console.log("yRange", rateDis, rateDis + aabb[1]);
|
|
122130
|
+
} else if (dir[2] != 0) {
|
|
122131
|
+
rateDis = (posRate / 100) * zRange;
|
|
122132
|
+
newSectionPos[2] = look[2] - zRange / 2 + rateDis; // console.log("zRange", rateDis, rateDis + aabb[2]);
|
|
122133
|
+
}
|
|
122134
|
+
|
|
122135
|
+
this._sectionPlane.pos = newSectionPos;
|
|
122136
|
+
}
|
|
122137
|
+
|
|
122138
|
+
get pos() {
|
|
122139
|
+
return this._pos;
|
|
122140
|
+
}
|
|
122141
|
+
|
|
122142
|
+
/** @private */
|
|
122143
|
+
_setPos(xyz) {
|
|
122144
|
+
this._pos.set(xyz);
|
|
122145
|
+
worldToRTCPos(this._pos, this._origin, this._rtcPos);
|
|
122146
|
+
this._rootNode.origin = this._origin;
|
|
122147
|
+
this._rootNode.position = this._rtcPos;
|
|
122148
|
+
}
|
|
122149
|
+
|
|
122150
|
+
/** @private */
|
|
122151
|
+
_setDir(xyz) {
|
|
122152
|
+
this._baseDir.set(xyz);
|
|
122153
|
+
this._rootNode.quaternion = math.vec3PairToQuaternion(zeroVec$1, xyz, quat$1);
|
|
122154
|
+
}
|
|
122155
|
+
|
|
122156
|
+
_setSectionPlaneDir(dir) {
|
|
122157
|
+
if (this._sectionPlane) {
|
|
122158
|
+
this._ignoreNextSectionPlaneDirUpdate = true;
|
|
122159
|
+
this._sectionPlane.dir = dir;
|
|
122160
|
+
}
|
|
122161
|
+
}
|
|
122162
|
+
|
|
122163
|
+
/**
|
|
122164
|
+
* Sets if this Control is visible.
|
|
122165
|
+
*
|
|
122166
|
+
* @type {Boolean}
|
|
122167
|
+
*/
|
|
122168
|
+
setVisible(visible = true) {
|
|
122169
|
+
if (this._visible === visible) {
|
|
122170
|
+
return;
|
|
122171
|
+
}
|
|
122172
|
+
this._visible = visible;
|
|
122173
|
+
var id;
|
|
122174
|
+
for (id in this._displayMeshes) {
|
|
122175
|
+
if (this._displayMeshes.hasOwnProperty(id)) {
|
|
122176
|
+
this._displayMeshes[id].visible = visible;
|
|
122177
|
+
}
|
|
122178
|
+
}
|
|
122179
|
+
if (!visible) {
|
|
122180
|
+
for (id in this._affordanceMeshes) {
|
|
122181
|
+
if (this._affordanceMeshes.hasOwnProperty(id)) {
|
|
122182
|
+
this._affordanceMeshes[id].visible = visible;
|
|
122183
|
+
}
|
|
122184
|
+
}
|
|
122185
|
+
}
|
|
122186
|
+
}
|
|
122187
|
+
|
|
122188
|
+
/**
|
|
122189
|
+
* Gets if this Control is visible.
|
|
122190
|
+
*
|
|
122191
|
+
* @type {Boolean}
|
|
122192
|
+
*/
|
|
122193
|
+
getVisible() {
|
|
122194
|
+
return this._visible;
|
|
122195
|
+
}
|
|
122196
|
+
|
|
122197
|
+
/**
|
|
122198
|
+
* Sets if this Control is culled. This is called by SectionPlanesPlugin to
|
|
122199
|
+
* temporarily hide the Control while a snapshot is being taken by Viewer#getSnapshot().
|
|
122200
|
+
* @param culled
|
|
122201
|
+
*/
|
|
122202
|
+
setCulled(culled) {
|
|
122203
|
+
var id;
|
|
122204
|
+
for (id in this._displayMeshes) {
|
|
122205
|
+
if (this._displayMeshes.hasOwnProperty(id)) {
|
|
122206
|
+
this._displayMeshes[id].culled = culled;
|
|
122207
|
+
}
|
|
122208
|
+
}
|
|
122209
|
+
if (!culled) {
|
|
122210
|
+
for (id in this._affordanceMeshes) {
|
|
122211
|
+
if (this._affordanceMeshes.hasOwnProperty(id)) {
|
|
122212
|
+
this._affordanceMeshes[id].culled = culled;
|
|
122213
|
+
}
|
|
122214
|
+
}
|
|
122215
|
+
}
|
|
122216
|
+
}
|
|
122217
|
+
|
|
122218
|
+
_bindEvents() {
|
|
122219
|
+
const self = this;
|
|
122220
|
+
|
|
122221
|
+
var grabbed = false;
|
|
122222
|
+
|
|
122223
|
+
const DRAG_ACTIONS = {
|
|
122224
|
+
none: -1,
|
|
122225
|
+
xTranslate: 0,
|
|
122226
|
+
yTranslate: 1,
|
|
122227
|
+
zTranslate: 2,
|
|
122228
|
+
xRotate: 3,
|
|
122229
|
+
yRotate: 4,
|
|
122230
|
+
zRotate: 5
|
|
122231
|
+
};
|
|
122232
|
+
|
|
122233
|
+
this._rootNode;
|
|
122234
|
+
|
|
122235
|
+
var nextDragAction = null; // As we hover grabbed an arrow or hoop, self is the action we would do if we then dragged it.
|
|
122236
|
+
var dragAction = null; // Action we're doing while we drag an arrow or hoop.
|
|
122237
|
+
const lastCanvasPos = math.vec2();
|
|
122238
|
+
this.lastCanvasPos = lastCanvasPos;
|
|
122239
|
+
const xBaseAxis = math.vec3([1, 0, 0]);
|
|
122240
|
+
const yBaseAxis = math.vec3([0, 1, 0]);
|
|
122241
|
+
const zBaseAxis = math.vec3([0, 0, 1]);
|
|
122242
|
+
|
|
122243
|
+
const canvas = this._viewer.scene.canvas.canvas;
|
|
122244
|
+
const camera = this._viewer.camera;
|
|
122245
|
+
const scene = this._viewer.scene;
|
|
122246
|
+
|
|
122247
|
+
{
|
|
122248
|
+
// Keep gizmo screen size constant
|
|
122249
|
+
|
|
122250
|
+
const tempVec3a = math.vec3([0, 0, 0]);
|
|
122251
|
+
let lastDist = -1;
|
|
122252
|
+
|
|
122253
|
+
this._onCameraViewMatrix = scene.camera.on("viewMatrix", () => {
|
|
122254
|
+
});
|
|
122255
|
+
|
|
122256
|
+
this._onCameraProjMatrix = scene.camera.on("projMatrix", () => {
|
|
122257
|
+
});
|
|
122258
|
+
|
|
122259
|
+
this._onSceneTick = scene.on("tick", () => {
|
|
122260
|
+
const dist = Math.abs(math.lenVec3(math.subVec3(scene.camera.eye, this._pos, tempVec3a)));
|
|
122261
|
+
|
|
122262
|
+
if (dist !== lastDist) {
|
|
122263
|
+
if (camera.projection === "perspective") {
|
|
122264
|
+
Math.tan(camera.perspective.fov * math.DEGTORAD) * dist;
|
|
122265
|
+
// const size = this._controlSize * worldSize;
|
|
122266
|
+
// rootNode.scale = [size, size, size];
|
|
122267
|
+
lastDist = dist;
|
|
122268
|
+
}
|
|
122269
|
+
}
|
|
122270
|
+
|
|
122271
|
+
if (camera.projection === "ortho") {
|
|
122272
|
+
camera.ortho.scale / 10;
|
|
122273
|
+
// const size = worldSize;
|
|
122274
|
+
// rootNode.scale = [size, size, size];
|
|
122275
|
+
lastDist = dist;
|
|
122276
|
+
}
|
|
122277
|
+
});
|
|
122278
|
+
}
|
|
122279
|
+
|
|
122280
|
+
const getClickCoordsWithinElement = (function () {
|
|
122281
|
+
const canvasPos = new Float64Array(2);
|
|
122282
|
+
return function (event) {
|
|
122283
|
+
if (!event) {
|
|
122284
|
+
event = window.event;
|
|
122285
|
+
canvasPos[0] = event.x;
|
|
122286
|
+
canvasPos[1] = event.y;
|
|
122287
|
+
} else {
|
|
122288
|
+
var element = event.target;
|
|
122289
|
+
var totalOffsetLeft = 0;
|
|
122290
|
+
var totalOffsetTop = 0;
|
|
122291
|
+
|
|
122292
|
+
while (element.offsetParent) {
|
|
122293
|
+
totalOffsetLeft += element.offsetLeft;
|
|
122294
|
+
totalOffsetTop += element.offsetTop;
|
|
122295
|
+
element = element.offsetParent;
|
|
122296
|
+
}
|
|
122297
|
+
canvasPos[0] = event.pageX - totalOffsetLeft;
|
|
122298
|
+
canvasPos[1] = event.pageY - totalOffsetTop;
|
|
122299
|
+
}
|
|
122300
|
+
return canvasPos;
|
|
122301
|
+
};
|
|
122302
|
+
})();
|
|
122303
|
+
|
|
122304
|
+
const getTouchCoordsWithinElement = (function () {
|
|
122305
|
+
const canvasPos = new Float64Array(2);
|
|
122306
|
+
return function (event) {
|
|
122307
|
+
if (!event) {
|
|
122308
|
+
event = window.event;
|
|
122309
|
+
}
|
|
122310
|
+
if (event.touches && event.touches.length) {
|
|
122311
|
+
// 如果有触摸事件,使用第一个触摸点的坐标
|
|
122312
|
+
canvasPos[0] = event.touches[0].pageX;
|
|
122313
|
+
canvasPos[1] = event.touches[0].pageY;
|
|
122314
|
+
} else {
|
|
122315
|
+
// 否则,假设是鼠标事件
|
|
122316
|
+
var element = event.target;
|
|
122317
|
+
var totalOffsetLeft = 0;
|
|
122318
|
+
var totalOffsetTop = 0;
|
|
122319
|
+
|
|
122320
|
+
while (element.offsetParent) {
|
|
122321
|
+
totalOffsetLeft += element.offsetLeft;
|
|
122322
|
+
totalOffsetTop += element.offsetTop;
|
|
122323
|
+
element = element.offsetParent;
|
|
122324
|
+
}
|
|
122325
|
+
canvasPos[0] = event.pageX - totalOffsetLeft;
|
|
122326
|
+
canvasPos[1] = event.pageY - totalOffsetTop;
|
|
122327
|
+
}
|
|
122328
|
+
return canvasPos;
|
|
122329
|
+
};
|
|
122330
|
+
})();
|
|
122331
|
+
|
|
122332
|
+
//转换为世界坐标
|
|
122333
|
+
const localToWorldVec = (function () {
|
|
122334
|
+
const mat = math.mat4();
|
|
122335
|
+
return function (localVec, worldVec) {
|
|
122336
|
+
math.quaternionToMat4(self._rootNode.quaternion, mat);
|
|
122337
|
+
math.transformVec3(mat, localVec, worldVec);
|
|
122338
|
+
math.normalizeVec3(worldVec);
|
|
122339
|
+
return worldVec;
|
|
122340
|
+
};
|
|
122341
|
+
})();
|
|
122342
|
+
|
|
122343
|
+
var getTranslationPlane = (function () {
|
|
122344
|
+
const planeNormal = math.vec3();
|
|
122345
|
+
return function (worldAxis) {
|
|
122346
|
+
const absX = Math.abs(worldAxis[0]);
|
|
122347
|
+
if (absX > Math.abs(worldAxis[1]) && absX > Math.abs(worldAxis[2])) {
|
|
122348
|
+
math.cross3Vec3(worldAxis, [0, 1, 0], planeNormal);
|
|
122349
|
+
} else {
|
|
122350
|
+
math.cross3Vec3(worldAxis, [1, 0, 0], planeNormal);
|
|
122351
|
+
}
|
|
122352
|
+
math.cross3Vec3(planeNormal, worldAxis, planeNormal);
|
|
122353
|
+
math.normalizeVec3(planeNormal);
|
|
122354
|
+
return planeNormal;
|
|
122355
|
+
};
|
|
122356
|
+
})();
|
|
122357
|
+
|
|
122358
|
+
//拖拽平面
|
|
122359
|
+
const dragTranslateSectionPlane = (function () {
|
|
122360
|
+
const p1 = math.vec3();
|
|
122361
|
+
const p2 = math.vec3();
|
|
122362
|
+
const worldAxis = math.vec4();
|
|
122363
|
+
return function (baseAxis, fromMouse, toMouse) {
|
|
122364
|
+
localToWorldVec(baseAxis, worldAxis);
|
|
122365
|
+
const planeNormal = getTranslationPlane(worldAxis, fromMouse, toMouse);
|
|
122366
|
+
getPointerPlaneIntersect(fromMouse, planeNormal, p1);
|
|
122367
|
+
getPointerPlaneIntersect(toMouse, planeNormal, p2);
|
|
122368
|
+
math.subVec3(p2, p1);
|
|
122369
|
+
const dot = math.dotVec3(p2, worldAxis);
|
|
122370
|
+
self._pos[0] += worldAxis[0] * dot;
|
|
122371
|
+
self._pos[1] += worldAxis[1] * dot;
|
|
122372
|
+
self._pos[2] += worldAxis[2] * dot;
|
|
122373
|
+
self._rootNode.position = self._pos;
|
|
122374
|
+
if (self._sectionPlane) {
|
|
122375
|
+
self._sectionPlane.pos = self._pos;
|
|
122376
|
+
}
|
|
122377
|
+
};
|
|
122378
|
+
})();
|
|
122379
|
+
|
|
122380
|
+
var getPointerPlaneIntersect = (function () {
|
|
122381
|
+
const dir = math.vec4([0, 0, 0, 1]);
|
|
122382
|
+
const matrix = math.mat4();
|
|
122383
|
+
return function (mouse, axis, dest, offset) {
|
|
122384
|
+
offset = offset || 0;
|
|
122385
|
+
dir[0] = (mouse[0] / canvas.width) * 2.0 - 1.0;
|
|
122386
|
+
dir[1] = -((mouse[1] / canvas.height) * 2.0 - 1.0);
|
|
122387
|
+
dir[2] = 0.0;
|
|
122388
|
+
dir[3] = 1.0;
|
|
122389
|
+
math.mulMat4(camera.projMatrix, camera.viewMatrix, matrix); // Unproject norm device coords to view coords
|
|
122390
|
+
math.inverseMat4(matrix);
|
|
122391
|
+
math.transformVec4(matrix, dir, dir);
|
|
122392
|
+
math.mulVec4Scalar(dir, 1.0 / dir[3]); // This is now point A on the ray in world space
|
|
122393
|
+
var rayO = camera.eye; // The direction
|
|
122394
|
+
math.subVec4(dir, rayO, dir);
|
|
122395
|
+
const origin = self._sectionPlane.pos; // Plane origin:
|
|
122396
|
+
var d = -math.dotVec3(origin, axis) - offset;
|
|
122397
|
+
var dot = math.dotVec3(axis, dir);
|
|
122398
|
+
if (Math.abs(dot) > 0.005) {
|
|
122399
|
+
var t = -(math.dotVec3(axis, rayO) + d) / dot;
|
|
122400
|
+
math.mulVec3Scalar(dir, t, dest);
|
|
122401
|
+
math.addVec3(dest, rayO);
|
|
122402
|
+
math.subVec3(dest, origin, dest);
|
|
122403
|
+
return true;
|
|
122404
|
+
}
|
|
122405
|
+
return false;
|
|
122406
|
+
};
|
|
122407
|
+
})();
|
|
122408
|
+
|
|
122409
|
+
{
|
|
122410
|
+
var down = false;
|
|
122411
|
+
// var lastAffordanceMesh;
|
|
122412
|
+
|
|
122413
|
+
this._onCameraControlHover = this._viewer.cameraControl.on("hoverEnter", (hit) => {
|
|
122414
|
+
if (!this._visible) {
|
|
122415
|
+
return;
|
|
122416
|
+
}
|
|
122417
|
+
if (down) {
|
|
122418
|
+
return;
|
|
122419
|
+
}
|
|
122420
|
+
grabbed = false;
|
|
122421
|
+
// if (lastAffordanceMesh) {
|
|
122422
|
+
// lastAffordanceMesh.visible = false;
|
|
122423
|
+
// }
|
|
122424
|
+
// var affordanceMesh;
|
|
122425
|
+
const meshId = hit.entity.id;
|
|
122426
|
+
switch (meshId) {
|
|
122427
|
+
case this._displayMeshes.plane.id:
|
|
122428
|
+
// affordanceMesh = this._affordanceMeshes.plane;
|
|
122429
|
+
nextDragAction = DRAG_ACTIONS.zTranslate;
|
|
122430
|
+
break;
|
|
122431
|
+
default:
|
|
122432
|
+
nextDragAction = DRAG_ACTIONS.none;
|
|
122433
|
+
return; // Not clicked an arrow or hoop
|
|
122434
|
+
}
|
|
122435
|
+
// if (affordanceMesh) {
|
|
122436
|
+
// affordanceMesh.visible = true;
|
|
122437
|
+
// }
|
|
122438
|
+
// lastAffordanceMesh = affordanceMesh;
|
|
122439
|
+
grabbed = true;
|
|
122440
|
+
});
|
|
122441
|
+
|
|
122442
|
+
this._onCameraControlHoverLeave = this._viewer.cameraControl.on("hoverOutEntity", (hit) => {
|
|
122443
|
+
if (!this._visible) {
|
|
122444
|
+
return;
|
|
122445
|
+
}
|
|
122446
|
+
// if (lastAffordanceMesh) {
|
|
122447
|
+
// lastAffordanceMesh.visible = false;
|
|
122448
|
+
// }
|
|
122449
|
+
// lastAffordanceMesh = null;
|
|
122450
|
+
nextDragAction = DRAG_ACTIONS.none;
|
|
122451
|
+
});
|
|
122452
|
+
|
|
122453
|
+
//mousedown
|
|
122454
|
+
canvas.addEventListener(
|
|
122455
|
+
"mousedown",
|
|
122456
|
+
(this._canvasMouseDownListener = (e) => {
|
|
122457
|
+
e.preventDefault();
|
|
122458
|
+
if (!this._visible || !grabbed) return;
|
|
122459
|
+
|
|
122460
|
+
this._viewer.cameraControl.pointerEnabled = false;
|
|
122461
|
+
switch (e.which) {
|
|
122462
|
+
case 1: // Left button
|
|
122463
|
+
down = true;
|
|
122464
|
+
var canvasPos = getClickCoordsWithinElement(e); //获取鼠标点击对应坐标
|
|
122465
|
+
dragAction = nextDragAction;
|
|
122466
|
+
lastCanvasPos[0] = canvasPos[0];
|
|
122467
|
+
lastCanvasPos[1] = canvasPos[1];
|
|
122468
|
+
break;
|
|
122469
|
+
}
|
|
122470
|
+
})
|
|
122471
|
+
);
|
|
122472
|
+
//mousemove
|
|
122473
|
+
canvas.addEventListener(
|
|
122474
|
+
"mousemove",
|
|
122475
|
+
(this._canvasMouseMoveListener = (e) => {
|
|
122476
|
+
if (!this._visible) {
|
|
122477
|
+
return;
|
|
122478
|
+
}
|
|
122479
|
+
if (!down) {
|
|
122480
|
+
return;
|
|
122481
|
+
}
|
|
122482
|
+
var canvasPos = getClickCoordsWithinElement(e);
|
|
122483
|
+
const x = canvasPos[0];
|
|
122484
|
+
const y = canvasPos[1];
|
|
122485
|
+
|
|
122486
|
+
switch (dragAction) {
|
|
122487
|
+
case DRAG_ACTIONS.xTranslate:
|
|
122488
|
+
dragTranslateSectionPlane(xBaseAxis, lastCanvasPos, canvasPos);
|
|
122489
|
+
break;
|
|
122490
|
+
case DRAG_ACTIONS.yTranslate:
|
|
122491
|
+
dragTranslateSectionPlane(yBaseAxis, lastCanvasPos, canvasPos);
|
|
122492
|
+
break;
|
|
122493
|
+
case DRAG_ACTIONS.zTranslate:
|
|
122494
|
+
dragTranslateSectionPlane(zBaseAxis, lastCanvasPos, canvasPos);
|
|
122495
|
+
break;
|
|
122496
|
+
}
|
|
122497
|
+
|
|
122498
|
+
lastCanvasPos[0] = x;
|
|
122499
|
+
lastCanvasPos[1] = y;
|
|
122500
|
+
})
|
|
122501
|
+
);
|
|
122502
|
+
//mouseup
|
|
122503
|
+
canvas.addEventListener(
|
|
122504
|
+
"mouseup",
|
|
122505
|
+
(this._canvasMouseUpListener = (e) => {
|
|
122506
|
+
if (!this._visible) return;
|
|
122507
|
+
this._viewer.cameraControl.pointerEnabled = true;
|
|
122508
|
+
if (!down) {
|
|
122509
|
+
return;
|
|
122510
|
+
}
|
|
122511
|
+
switch (e.which) {
|
|
122512
|
+
}
|
|
122513
|
+
down = false;
|
|
122514
|
+
grabbed = false;
|
|
122515
|
+
})
|
|
122516
|
+
);
|
|
122517
|
+
|
|
122518
|
+
//wheel
|
|
122519
|
+
canvas.addEventListener(
|
|
122520
|
+
"wheel",
|
|
122521
|
+
(this._canvasWheelListener = (e) => {
|
|
122522
|
+
if (!this._visible) {
|
|
122523
|
+
return;
|
|
122524
|
+
}
|
|
122525
|
+
var delta = Math.max(-1, Math.min(1, -e.deltaY * 40));
|
|
122526
|
+
if (delta === 0) {
|
|
122527
|
+
return;
|
|
122528
|
+
}
|
|
122529
|
+
})
|
|
122530
|
+
);
|
|
122531
|
+
|
|
122532
|
+
this._onCameraControlHover = this._viewer.cameraControl.on("touchEntity", (hit) => {
|
|
122533
|
+
if (!this._visible || down || grabbed) return;
|
|
122534
|
+
// if (lastAffordanceMesh) {
|
|
122535
|
+
// lastAffordanceMesh.visible = false;
|
|
122536
|
+
// }
|
|
122537
|
+
var affordanceMesh;
|
|
122538
|
+
const meshId = hit.entity.id;
|
|
122539
|
+
switch (meshId) {
|
|
122540
|
+
case this._displayMeshes.plane.id:
|
|
122541
|
+
affordanceMesh = this._affordanceMeshes.plane;
|
|
122542
|
+
nextDragAction = DRAG_ACTIONS.zTranslate;
|
|
122543
|
+
break;
|
|
122544
|
+
|
|
122545
|
+
default:
|
|
122546
|
+
nextDragAction = DRAG_ACTIONS.none;
|
|
122547
|
+
return; // Not clicked an arrow or hoop
|
|
122548
|
+
}
|
|
122549
|
+
if (affordanceMesh) {
|
|
122550
|
+
affordanceMesh.visible = true;
|
|
122551
|
+
}
|
|
122552
|
+
// lastAffordanceMesh = affordanceMesh;
|
|
122553
|
+
grabbed = true;
|
|
122554
|
+
down = true;
|
|
122555
|
+
});
|
|
122556
|
+
//touchstart
|
|
122557
|
+
canvas.addEventListener(
|
|
122558
|
+
"touchstart",
|
|
122559
|
+
(this._canvasMouseDownListener = (e) => {
|
|
122560
|
+
e.preventDefault();
|
|
122561
|
+
if (!this._visible || !grabbed || !down) return;
|
|
122562
|
+
this._viewer.cameraControl.pointerEnabled = false;
|
|
122563
|
+
// if (lastAffordanceMesh) {
|
|
122564
|
+
// lastAffordanceMesh.visible = true;
|
|
122565
|
+
// }
|
|
122566
|
+
var canvasPos = getTouchCoordsWithinElement(e);
|
|
122567
|
+
dragAction = nextDragAction;
|
|
122568
|
+
lastCanvasPos[0] = canvasPos[0];
|
|
122569
|
+
lastCanvasPos[1] = canvasPos[1];
|
|
122570
|
+
})
|
|
122571
|
+
);
|
|
122572
|
+
//touchmove
|
|
122573
|
+
canvas.addEventListener(
|
|
122574
|
+
"touchmove",
|
|
122575
|
+
(this._canvasMouseMoveListener = (e) => {
|
|
122576
|
+
if (!this._visible || !down || !grabbed) return;
|
|
122577
|
+
|
|
122578
|
+
var canvasPos = getTouchCoordsWithinElement(e);
|
|
122579
|
+
const x = canvasPos[0];
|
|
122580
|
+
const y = canvasPos[1];
|
|
122581
|
+
|
|
122582
|
+
switch (dragAction) {
|
|
122583
|
+
case DRAG_ACTIONS.xTranslate:
|
|
122584
|
+
dragTranslateSectionPlane(xBaseAxis, lastCanvasPos, canvasPos);
|
|
122585
|
+
break;
|
|
122586
|
+
case DRAG_ACTIONS.yTranslate:
|
|
122587
|
+
dragTranslateSectionPlane(yBaseAxis, lastCanvasPos, canvasPos);
|
|
122588
|
+
break;
|
|
122589
|
+
case DRAG_ACTIONS.zTranslate:
|
|
122590
|
+
dragTranslateSectionPlane(zBaseAxis, lastCanvasPos, canvasPos);
|
|
122591
|
+
break;
|
|
122592
|
+
}
|
|
122593
|
+
|
|
122594
|
+
lastCanvasPos[0] = x;
|
|
122595
|
+
lastCanvasPos[1] = y;
|
|
122596
|
+
})
|
|
122597
|
+
);
|
|
122598
|
+
//touchend
|
|
122599
|
+
canvas.addEventListener(
|
|
122600
|
+
"touchend",
|
|
122601
|
+
(this._canvasTouchEndListener = (e) => {
|
|
122602
|
+
if (!this._visible) return;
|
|
122603
|
+
if (grabbed) this._viewer.cameraControl.pointerEnabled = true;
|
|
122604
|
+
// if (lastAffordanceMesh) {
|
|
122605
|
+
// lastAffordanceMesh.visible = false;
|
|
122606
|
+
// }
|
|
122607
|
+
// lastAffordanceMesh = null;
|
|
122608
|
+
nextDragAction = DRAG_ACTIONS.none;
|
|
122609
|
+
down = false;
|
|
122610
|
+
grabbed = false;
|
|
122611
|
+
})
|
|
122612
|
+
);
|
|
122613
|
+
canvas.addEventListener("touchcancel", this._canvasTouchEndListener);
|
|
122614
|
+
}
|
|
122615
|
+
}
|
|
122616
|
+
|
|
122617
|
+
_destroy() {
|
|
122618
|
+
this._unbindEvents();
|
|
122619
|
+
this._destroyNodes();
|
|
122620
|
+
}
|
|
122621
|
+
|
|
122622
|
+
_unbindEvents() {
|
|
122623
|
+
const viewer = this._viewer;
|
|
122624
|
+
const scene = viewer.scene;
|
|
122625
|
+
const canvas = scene.canvas.canvas;
|
|
122626
|
+
const camera = viewer.camera;
|
|
122627
|
+
const cameraControl = viewer.cameraControl;
|
|
122628
|
+
|
|
122629
|
+
scene.off(this._onSceneTick);
|
|
122630
|
+
|
|
122631
|
+
canvas.removeEventListener("mousedown", this._canvasMouseDownListener);
|
|
122632
|
+
canvas.removeEventListener("mousemove", this._canvasMouseMoveListener);
|
|
122633
|
+
canvas.removeEventListener("mouseup", this._canvasMouseUpListener);
|
|
122634
|
+
canvas.removeEventListener("wheel", this._canvasWheelListener);
|
|
122635
|
+
canvas.removeEventListener("touchend", this._canvasTouchEndListener);
|
|
122636
|
+
canvas.removeEventListener("touchcancel", this._canvasTouchEndListener);
|
|
122637
|
+
|
|
122638
|
+
camera.off(this._onCameraViewMatrix);
|
|
122639
|
+
camera.off(this._onCameraProjMatrix);
|
|
122640
|
+
|
|
122641
|
+
cameraControl.off(this._onCameraControlHover);
|
|
122642
|
+
cameraControl.off(this._onCameraControlHoverLeave);
|
|
122643
|
+
}
|
|
122644
|
+
|
|
122645
|
+
_destroyNodes() {
|
|
122646
|
+
this._setSectionPlane(null);
|
|
122647
|
+
this._rootNode.destroy();
|
|
122648
|
+
this._displayMeshes = {};
|
|
122649
|
+
this._affordanceMeshes = {};
|
|
122650
|
+
}
|
|
122651
|
+
}
|
|
122652
|
+
|
|
122653
|
+
/**
|
|
122654
|
+
* Renders a 3D plane within an {@link Overview} to indicate its {@link SectionPlane}'s current position and orientation.
|
|
122655
|
+
*
|
|
122656
|
+
* @private
|
|
122657
|
+
*/
|
|
122658
|
+
class Plane$1 {
|
|
122659
|
+
|
|
122660
|
+
/** @private */
|
|
122661
|
+
constructor(overview, overviewScene, sectionPlane) {
|
|
122662
|
+
|
|
122663
|
+
/**
|
|
122664
|
+
* The ID of this SectionPlanesOverviewPlane.
|
|
122665
|
+
*
|
|
122666
|
+
* @type {String}
|
|
122667
|
+
*/
|
|
122668
|
+
this.id = sectionPlane.id;
|
|
122669
|
+
|
|
122670
|
+
/**
|
|
122671
|
+
* The {@link SectionPlane} represented by this SectionPlanesOverviewPlane.
|
|
122672
|
+
*
|
|
122673
|
+
* @type {SectionPlane}
|
|
122674
|
+
*/
|
|
122675
|
+
this._sectionPlane = sectionPlane;
|
|
122676
|
+
|
|
122677
|
+
this._mesh = new Mesh(overviewScene, {
|
|
122678
|
+
id: sectionPlane.id,
|
|
122679
|
+
geometry: new ReadableGeometry(overviewScene, buildBoxGeometry({
|
|
122680
|
+
xSize: .5,
|
|
122681
|
+
ySize: .5,
|
|
122682
|
+
zSize: .001
|
|
122683
|
+
})),
|
|
122684
|
+
material: new PhongMaterial(overviewScene, {
|
|
122685
|
+
emissive: [1, 1, 1],
|
|
122686
|
+
diffuse: [0, 0, 0],
|
|
122687
|
+
backfaces: false
|
|
122688
|
+
}),
|
|
122689
|
+
edgeMaterial: new EdgeMaterial(overviewScene, {
|
|
122690
|
+
edgeColor: [0.0, 0.0, 0.0],
|
|
122691
|
+
edgeAlpha: 1.0,
|
|
122692
|
+
edgeWidth: 1
|
|
122693
|
+
}),
|
|
122694
|
+
highlightMaterial: new EmphasisMaterial(overviewScene, {
|
|
122695
|
+
fill: true,
|
|
122696
|
+
fillColor: [0.5, 1, 0.5],
|
|
122697
|
+
fillAlpha: 0.7,
|
|
122698
|
+
edges: true,
|
|
122699
|
+
edgeColor: [0.0, 0.0, 0.0],
|
|
122700
|
+
edgeAlpha: 1.0,
|
|
122701
|
+
edgeWidth: 1
|
|
122702
|
+
}),
|
|
122703
|
+
selectedMaterial: new EmphasisMaterial(overviewScene, {
|
|
122704
|
+
fill: true,
|
|
122705
|
+
fillColor: [0, 0, 1],
|
|
122706
|
+
fillAlpha: 0.7,
|
|
122707
|
+
edges: true,
|
|
122708
|
+
edgeColor: [1.0, 0.0, 0.0],
|
|
122709
|
+
edgeAlpha: 1.0,
|
|
122710
|
+
edgeWidth: 1
|
|
122711
|
+
}),
|
|
122712
|
+
highlighted: true,
|
|
122713
|
+
scale: [3, 3, 3],
|
|
122714
|
+
position: [0, 0, 0],
|
|
122715
|
+
rotation: [0, 0, 0],
|
|
122716
|
+
opacity: 0.3,
|
|
122717
|
+
edges: true
|
|
122718
|
+
});
|
|
122719
|
+
|
|
122720
|
+
|
|
122721
|
+
{
|
|
122722
|
+
const vec = math.vec3([0, 0, 0]);
|
|
122723
|
+
const pos2 = math.vec3();
|
|
122724
|
+
const zeroVec = math.vec3([0, 0, 1]);
|
|
122725
|
+
const quat = math.vec4(4);
|
|
122726
|
+
const pos3 = math.vec3();
|
|
122727
|
+
|
|
122728
|
+
const update = () => {
|
|
122729
|
+
|
|
122730
|
+
const origin = this._sectionPlane.scene.center;
|
|
122731
|
+
|
|
122732
|
+
const negDir = [-this._sectionPlane.dir[0], -this._sectionPlane.dir[1], -this._sectionPlane.dir[2]];
|
|
122733
|
+
math.subVec3(origin, this._sectionPlane.pos, vec);
|
|
122734
|
+
const dist = -math.dotVec3(negDir, vec);
|
|
122735
|
+
|
|
122736
|
+
math.normalizeVec3(negDir);
|
|
122737
|
+
math.mulVec3Scalar(negDir, dist, pos2);
|
|
122738
|
+
const quaternion = math.vec3PairToQuaternion(zeroVec, this._sectionPlane.dir, quat);
|
|
122739
|
+
|
|
122740
|
+
pos3[0] = pos2[0] * 0.1;
|
|
122741
|
+
pos3[1] = pos2[1] * 0.1;
|
|
122742
|
+
pos3[2] = pos2[2] * 0.1;
|
|
122743
|
+
|
|
122744
|
+
this._mesh.quaternion = quaternion;
|
|
122745
|
+
this._mesh.position = pos3;
|
|
122746
|
+
};
|
|
122747
|
+
|
|
122748
|
+
this._onSectionPlanePos = this._sectionPlane.on("pos", update);
|
|
122749
|
+
this._onSectionPlaneDir = this._sectionPlane.on("dir", update);
|
|
122750
|
+
|
|
122751
|
+
// update();
|
|
121355
122752
|
}
|
|
122753
|
+
|
|
122754
|
+
this._highlighted = false;
|
|
122755
|
+
this._selected = false;
|
|
121356
122756
|
}
|
|
121357
122757
|
|
|
121358
122758
|
/**
|
|
121359
|
-
* Sets if this
|
|
122759
|
+
* Sets if this SectionPlanesOverviewPlane is highlighted.
|
|
121360
122760
|
*
|
|
121361
|
-
* @
|
|
122761
|
+
* @type {Boolean}
|
|
122762
|
+
* @private
|
|
121362
122763
|
*/
|
|
121363
|
-
|
|
121364
|
-
this.
|
|
121365
|
-
this.
|
|
122764
|
+
setHighlighted(highlighted) {
|
|
122765
|
+
this._highlighted = !!highlighted;
|
|
122766
|
+
this._mesh.highlighted = this._highlighted;
|
|
122767
|
+
this._mesh.highlightMaterial.fillColor = highlighted ? [0, 0.7, 0] : [0, 0, 0];
|
|
122768
|
+
// this._selectedMesh.highlighted = true;
|
|
121366
122769
|
}
|
|
121367
122770
|
|
|
121368
122771
|
/**
|
|
121369
|
-
* Gets if this
|
|
122772
|
+
* Gets if this SectionPlanesOverviewPlane is highlighted.
|
|
121370
122773
|
*
|
|
121371
|
-
* @
|
|
122774
|
+
* @type {Boolean}
|
|
122775
|
+
* @private
|
|
121372
122776
|
*/
|
|
121373
|
-
|
|
121374
|
-
return this.
|
|
122777
|
+
getHighlighted() {
|
|
122778
|
+
return this._highlighted;
|
|
122779
|
+
}
|
|
122780
|
+
|
|
122781
|
+
/**
|
|
122782
|
+
* Sets if this SectionPlanesOverviewPlane is selected.
|
|
122783
|
+
*
|
|
122784
|
+
* @type {Boolean}
|
|
122785
|
+
* @private
|
|
122786
|
+
*/
|
|
122787
|
+
setSelected(selected) {
|
|
122788
|
+
this._selected = !!selected;
|
|
122789
|
+
this._mesh.edgeMaterial.edgeWidth = selected ? 3 : 1;
|
|
122790
|
+
this._mesh.highlightMaterial.edgeWidth = selected ? 3 : 1;
|
|
122791
|
+
|
|
121375
122792
|
}
|
|
121376
122793
|
|
|
121377
|
-
/**
|
|
122794
|
+
/**
|
|
122795
|
+
* Gets if this SectionPlanesOverviewPlane is selected.
|
|
122796
|
+
*
|
|
122797
|
+
* @type {Boolean}
|
|
122798
|
+
* @private
|
|
121378
122799
|
*/
|
|
121379
|
-
|
|
121380
|
-
this.
|
|
121381
|
-
|
|
121382
|
-
this._viewer.camera.perspective.off(this._onViewerCameraFOV);
|
|
122800
|
+
getSelected() {
|
|
122801
|
+
return this._selected;
|
|
122802
|
+
}
|
|
121383
122803
|
|
|
121384
|
-
|
|
121385
|
-
|
|
121386
|
-
this.
|
|
121387
|
-
this.
|
|
122804
|
+
/** @private */
|
|
122805
|
+
destroy() {
|
|
122806
|
+
this._sectionPlane.off(this._onSectionPlanePos);
|
|
122807
|
+
this._sectionPlane.off(this._onSectionPlaneDir);
|
|
122808
|
+
this._mesh.destroy();
|
|
121388
122809
|
}
|
|
121389
122810
|
}
|
|
121390
122811
|
|
|
122812
|
+
/**
|
|
122813
|
+
* @desc An interactive 3D overview for navigating the {@link SectionPlane}s created by its {@link SectionPlanesPlugin}.
|
|
122814
|
+
*
|
|
122815
|
+
* * Located at {@link SectionPlanesPlugin#overview}.
|
|
122816
|
+
* * Renders the overview on a separate canvas at a corner of the {@link Viewer}'s {@link Scene} {@link Canvas}.
|
|
122817
|
+
* * The overview shows a 3D plane object for each {@link SectionPlane} in the {@link Scene}.
|
|
122818
|
+
* * Click a plane object in the overview to toggle the visibility of a 3D gizmo to edit the position and orientation of its {@link SectionPlane}.
|
|
122819
|
+
*
|
|
122820
|
+
* @private
|
|
122821
|
+
*/
|
|
122822
|
+
class Overview$1 {
|
|
122823
|
+
/**
|
|
122824
|
+
* @private
|
|
122825
|
+
*/
|
|
122826
|
+
constructor(plugin, cfg) {
|
|
122827
|
+
if (!cfg.onHoverEnterPlane || !cfg.onHoverLeavePlane || !cfg.onClickedNothing || !cfg.onClickedPlane) {
|
|
122828
|
+
throw "Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";
|
|
122829
|
+
}
|
|
122830
|
+
|
|
122831
|
+
/**
|
|
122832
|
+
* The {@link SectionPlanesPlugin} that owns this SectionPlanesOverview.
|
|
122833
|
+
*
|
|
122834
|
+
* @type {SectionPlanesPlugin}
|
|
122835
|
+
*/
|
|
122836
|
+
this.plugin = plugin;
|
|
122837
|
+
|
|
122838
|
+
this._viewer = plugin.viewer;
|
|
122839
|
+
|
|
122840
|
+
this._onHoverEnterPlane = cfg.onHoverEnterPlane;
|
|
122841
|
+
this._onHoverLeavePlane = cfg.onHoverLeavePlane;
|
|
122842
|
+
this._onClickedNothing = cfg.onClickedNothing;
|
|
122843
|
+
this._onClickedPlane = cfg.onClickedPlane;
|
|
122844
|
+
this._visible = true;
|
|
122845
|
+
|
|
122846
|
+
this._planes = {};
|
|
122847
|
+
|
|
122848
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
122849
|
+
// Init canvas
|
|
122850
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
122851
|
+
|
|
122852
|
+
this._canvas = cfg.overviewCanvas;
|
|
122853
|
+
|
|
122854
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
122855
|
+
// Init scene
|
|
122856
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
122857
|
+
|
|
122858
|
+
this._scene = new Scene(this._viewer, {
|
|
122859
|
+
canvasId: this._canvas.id,
|
|
122860
|
+
transparent: true
|
|
122861
|
+
});
|
|
122862
|
+
this._scene.clearLights();
|
|
122863
|
+
new DirLight(this._scene, {
|
|
122864
|
+
dir: [0.4, -0.4, 0.8],
|
|
122865
|
+
color: [0.8, 1.0, 1.0],
|
|
122866
|
+
intensity: 1.0,
|
|
122867
|
+
space: "view"
|
|
122868
|
+
});
|
|
122869
|
+
new DirLight(this._scene, {
|
|
122870
|
+
dir: [-0.8, -0.3, -0.4],
|
|
122871
|
+
color: [0.8, 0.8, 0.8],
|
|
122872
|
+
intensity: 1.0,
|
|
122873
|
+
space: "view"
|
|
122874
|
+
});
|
|
122875
|
+
new DirLight(this._scene, {
|
|
122876
|
+
dir: [0.8, -0.6, -0.8],
|
|
122877
|
+
color: [1.0, 1.0, 1.0],
|
|
122878
|
+
intensity: 1.0,
|
|
122879
|
+
space: "view"
|
|
122880
|
+
});
|
|
122881
|
+
|
|
122882
|
+
this._scene.camera;
|
|
122883
|
+
this._scene.camera.perspective.fov = 70;
|
|
122884
|
+
|
|
122885
|
+
this._zUp = false;
|
|
122886
|
+
|
|
122887
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
122888
|
+
// Synchronize overview scene camera with viewer camera
|
|
122889
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
122890
|
+
|
|
122891
|
+
{
|
|
122892
|
+
const camera = this._scene.camera;
|
|
122893
|
+
const matrix = math.rotationMat4c(-90 * math.DEGTORAD, 1, 0, 0);
|
|
122894
|
+
const eyeLookVec = math.vec3();
|
|
122895
|
+
const eyeLookVecOverview = math.vec3();
|
|
122896
|
+
const upOverview = math.vec3();
|
|
122897
|
+
|
|
122898
|
+
this._synchCamera = () => {
|
|
122899
|
+
const eye = this._viewer.camera.eye;
|
|
122900
|
+
const look = this._viewer.camera.look;
|
|
122901
|
+
const up = this._viewer.camera.up;
|
|
122902
|
+
math.mulVec3Scalar(math.normalizeVec3(math.subVec3(eye, look, eyeLookVec)), 7);
|
|
122903
|
+
if (this._zUp) {
|
|
122904
|
+
// +Z up
|
|
122905
|
+
math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
|
|
122906
|
+
math.transformVec3(matrix, up, upOverview);
|
|
122907
|
+
camera.look = [0, 0, 0];
|
|
122908
|
+
camera.eye = math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
|
|
122909
|
+
camera.up = math.transformPoint3(matrix, up, upOverview);
|
|
122910
|
+
} else {
|
|
122911
|
+
// +Y up
|
|
122912
|
+
camera.look = [0, 0, 0];
|
|
122913
|
+
camera.eye = eyeLookVec;
|
|
122914
|
+
camera.up = up;
|
|
122915
|
+
}
|
|
122916
|
+
};
|
|
122917
|
+
}
|
|
122918
|
+
|
|
122919
|
+
this._onViewerCameraMatrix = this._viewer.camera.on("matrix", this._synchCamera);
|
|
122920
|
+
|
|
122921
|
+
this._onViewerCameraWorldAxis = this._viewer.camera.on("worldAxis", this._synchCamera);
|
|
122922
|
+
|
|
122923
|
+
this._onViewerCameraFOV = this._viewer.camera.perspective.on("fov", (fov) => {
|
|
122924
|
+
this._scene.camera.perspective.fov = fov;
|
|
122925
|
+
});
|
|
122926
|
+
|
|
122927
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
122928
|
+
// Bind overview canvas events
|
|
122929
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
122930
|
+
|
|
122931
|
+
{
|
|
122932
|
+
var hoveredEntity = null;
|
|
122933
|
+
|
|
122934
|
+
this._onInputMouseMove = this._scene.input.on("mousemove", (coords) => {
|
|
122935
|
+
const hit = this._scene.pick({
|
|
122936
|
+
canvasPos: coords
|
|
122937
|
+
});
|
|
122938
|
+
if (hit) {
|
|
122939
|
+
if (!hoveredEntity || hit.entity.id !== hoveredEntity.id) {
|
|
122940
|
+
if (hoveredEntity) {
|
|
122941
|
+
const plane = this._planes[hoveredEntity.id];
|
|
122942
|
+
if (plane) {
|
|
122943
|
+
this._onHoverLeavePlane(hoveredEntity.id);
|
|
122944
|
+
}
|
|
122945
|
+
}
|
|
122946
|
+
hoveredEntity = hit.entity;
|
|
122947
|
+
const plane = this._planes[hoveredEntity.id];
|
|
122948
|
+
if (plane) {
|
|
122949
|
+
this._onHoverEnterPlane(hoveredEntity.id);
|
|
122950
|
+
}
|
|
122951
|
+
}
|
|
122952
|
+
} else {
|
|
122953
|
+
if (hoveredEntity) {
|
|
122954
|
+
this._onHoverLeavePlane(hoveredEntity.id);
|
|
122955
|
+
hoveredEntity = null;
|
|
122956
|
+
}
|
|
122957
|
+
}
|
|
122958
|
+
});
|
|
122959
|
+
|
|
122960
|
+
this._scene.canvas.canvas.addEventListener(
|
|
122961
|
+
"mouseup",
|
|
122962
|
+
(this._onCanvasMouseUp = () => {
|
|
122963
|
+
if (hoveredEntity) {
|
|
122964
|
+
const plane = this._planes[hoveredEntity.id];
|
|
122965
|
+
if (plane) {
|
|
122966
|
+
this._onClickedPlane(hoveredEntity.id);
|
|
122967
|
+
}
|
|
122968
|
+
} else {
|
|
122969
|
+
this._onClickedNothing();
|
|
122970
|
+
}
|
|
122971
|
+
})
|
|
122972
|
+
);
|
|
122973
|
+
|
|
122974
|
+
this._scene.canvas.canvas.addEventListener(
|
|
122975
|
+
"mouseout",
|
|
122976
|
+
(this._onCanvasMouseOut = () => {
|
|
122977
|
+
if (hoveredEntity) {
|
|
122978
|
+
this._onHoverLeavePlane(hoveredEntity.id);
|
|
122979
|
+
hoveredEntity = null;
|
|
122980
|
+
}
|
|
122981
|
+
})
|
|
122982
|
+
);
|
|
122983
|
+
}
|
|
122984
|
+
|
|
122985
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
122986
|
+
// Configure overview
|
|
122987
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
122988
|
+
|
|
122989
|
+
this.setVisible(cfg.overviewVisible);
|
|
122990
|
+
}
|
|
122991
|
+
|
|
122992
|
+
/** Called by SectionPlanesPlugin#createSectionPlane()
|
|
122993
|
+
* @private
|
|
122994
|
+
*/
|
|
122995
|
+
addSectionPlane(sectionPlane) {
|
|
122996
|
+
this._planes[sectionPlane.id] = new Plane$1(this, this._scene, sectionPlane);
|
|
122997
|
+
}
|
|
122998
|
+
|
|
122999
|
+
/** @private
|
|
123000
|
+
*/
|
|
123001
|
+
setPlaneHighlighted(id, highlighted) {
|
|
123002
|
+
const plane = this._planes[id];
|
|
123003
|
+
if (plane) {
|
|
123004
|
+
plane.setHighlighted(highlighted);
|
|
123005
|
+
}
|
|
123006
|
+
}
|
|
123007
|
+
|
|
123008
|
+
/** @private
|
|
123009
|
+
*/
|
|
123010
|
+
setPlaneSelected(id, selected) {
|
|
123011
|
+
const plane = this._planes[id];
|
|
123012
|
+
if (plane) {
|
|
123013
|
+
plane.setSelected(selected);
|
|
123014
|
+
}
|
|
123015
|
+
}
|
|
123016
|
+
|
|
123017
|
+
/** @private
|
|
123018
|
+
*/
|
|
123019
|
+
removeSectionPlane(sectionPlane) {
|
|
123020
|
+
const plane = this._planes[sectionPlane.id];
|
|
123021
|
+
if (plane) {
|
|
123022
|
+
plane.destroy();
|
|
123023
|
+
delete this._planes[sectionPlane.id];
|
|
123024
|
+
}
|
|
123025
|
+
}
|
|
123026
|
+
|
|
123027
|
+
/**
|
|
123028
|
+
* Sets if this SectionPlanesOverview is visible.
|
|
123029
|
+
*
|
|
123030
|
+
* @param {Boolean} visible Whether or not this SectionPlanesOverview is visible.
|
|
123031
|
+
*/
|
|
123032
|
+
setVisible(visible = true) {
|
|
123033
|
+
this._visible = visible;
|
|
123034
|
+
this._canvas.style.visibility = visible ? "visible" : "hidden";
|
|
123035
|
+
}
|
|
123036
|
+
|
|
123037
|
+
/**
|
|
123038
|
+
* Gets if this SectionPlanesOverview is visible.
|
|
123039
|
+
*
|
|
123040
|
+
* @return {Boolean} True when this SectionPlanesOverview is visible.
|
|
123041
|
+
*/
|
|
123042
|
+
getVisible() {
|
|
123043
|
+
return this._visible;
|
|
123044
|
+
}
|
|
123045
|
+
|
|
123046
|
+
/** @private
|
|
123047
|
+
*/
|
|
123048
|
+
destroy() {
|
|
123049
|
+
this._viewer.camera.off(this._onViewerCameraMatrix);
|
|
123050
|
+
this._viewer.camera.off(this._onViewerCameraWorldAxis);
|
|
123051
|
+
this._viewer.camera.perspective.off(this._onViewerCameraFOV);
|
|
123052
|
+
|
|
123053
|
+
this._scene.input.off(this._onInputMouseMove);
|
|
123054
|
+
this._scene.canvas.canvas.removeEventListener("mouseup", this._onCanvasMouseUp);
|
|
123055
|
+
this._scene.canvas.canvas.removeEventListener("mouseout", this._onCanvasMouseOut);
|
|
123056
|
+
this._scene.destroy();
|
|
123057
|
+
}
|
|
123058
|
+
}
|
|
123059
|
+
|
|
121391
123060
|
const tempAABB$1 = math.AABB3();
|
|
121392
123061
|
const tempVec3$1 = math.vec3();
|
|
121393
123062
|
|
|
@@ -121477,312 +123146,410 @@ const tempVec3$1 = math.vec3();
|
|
|
121477
123146
|
* ````
|
|
121478
123147
|
*/
|
|
121479
123148
|
class SectionPlanesPlugin extends Plugin {
|
|
123149
|
+
/**
|
|
123150
|
+
* @constructor
|
|
123151
|
+
* @param {Viewer} viewer The Viewer.
|
|
123152
|
+
* @param {Object} cfg Plugin configuration.
|
|
123153
|
+
* @param {String} [cfg.id="SectionPlanes"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
|
|
123154
|
+
* @param {String} [cfg.overviewCanvasId] ID of a canvas element to display the overview.
|
|
123155
|
+
* @param {String} [cfg.overviewVisible=true] Initial visibility of the overview canvas.
|
|
123156
|
+
*/
|
|
123157
|
+
constructor(viewer, cfg = {}) {
|
|
123158
|
+
super("SectionPlanes", viewer);
|
|
121480
123159
|
|
|
121481
|
-
|
|
121482
|
-
|
|
121483
|
-
|
|
121484
|
-
|
|
121485
|
-
|
|
121486
|
-
* @param {String} [cfg.overviewCanvasId] ID of a canvas element to display the overview.
|
|
121487
|
-
* @param {String} [cfg.overviewVisible=true] Initial visibility of the overview canvas.
|
|
121488
|
-
*/
|
|
121489
|
-
constructor(viewer, cfg = {}) {
|
|
121490
|
-
|
|
121491
|
-
super("SectionPlanes", viewer);
|
|
123160
|
+
this._freeControls = [];
|
|
123161
|
+
this._sectionPlanes = viewer.scene.sectionPlanes;
|
|
123162
|
+
this._controls = {};
|
|
123163
|
+
this._currentControl = null;
|
|
123164
|
+
this._shownControlId = null;
|
|
121492
123165
|
|
|
121493
|
-
|
|
121494
|
-
|
|
121495
|
-
this._controls = {};
|
|
121496
|
-
this._shownControlId = null;
|
|
123166
|
+
if (cfg.overviewCanvasId !== null && cfg.overviewCanvasId !== undefined) {
|
|
123167
|
+
const overviewCanvas = document.getElementById(cfg.overviewCanvasId);
|
|
121497
123168
|
|
|
121498
|
-
|
|
123169
|
+
if (!overviewCanvas) {
|
|
123170
|
+
this.warn("Can't find overview canvas: '" + cfg.overviewCanvasId + "' - will create plugin without overview");
|
|
123171
|
+
} else {
|
|
123172
|
+
this._overview = new Overview$1(this, {
|
|
123173
|
+
overviewCanvas: overviewCanvas,
|
|
123174
|
+
visible: cfg.overviewVisible,
|
|
121499
123175
|
|
|
121500
|
-
|
|
123176
|
+
onHoverEnterPlane: (id) => {
|
|
123177
|
+
this._overview.setPlaneHighlighted(id, true);
|
|
123178
|
+
},
|
|
121501
123179
|
|
|
121502
|
-
|
|
121503
|
-
|
|
123180
|
+
onHoverLeavePlane: (id) => {
|
|
123181
|
+
this._overview.setPlaneHighlighted(id, false);
|
|
123182
|
+
},
|
|
121504
123183
|
|
|
121505
|
-
|
|
123184
|
+
onClickedPlane: (id) => {
|
|
123185
|
+
if (this.getShownControl() === id) {
|
|
123186
|
+
this.hideControl();
|
|
123187
|
+
return;
|
|
123188
|
+
}
|
|
123189
|
+
this.showControl(id);
|
|
123190
|
+
const sectionPlane = this.sectionPlanes[id];
|
|
123191
|
+
const sectionPlanePos = sectionPlane.pos;
|
|
123192
|
+
tempAABB$1.set(this.viewer.scene.aabb);
|
|
123193
|
+
math.getAABB3Center(tempAABB$1, tempVec3$1);
|
|
123194
|
+
tempAABB$1[0] += sectionPlanePos[0] - tempVec3$1[0];
|
|
123195
|
+
tempAABB$1[1] += sectionPlanePos[1] - tempVec3$1[1];
|
|
123196
|
+
tempAABB$1[2] += sectionPlanePos[2] - tempVec3$1[2];
|
|
123197
|
+
tempAABB$1[3] += sectionPlanePos[0] - tempVec3$1[0];
|
|
123198
|
+
tempAABB$1[4] += sectionPlanePos[1] - tempVec3$1[1];
|
|
123199
|
+
tempAABB$1[5] += sectionPlanePos[2] - tempVec3$1[2];
|
|
123200
|
+
this.viewer.cameraFlight.flyTo({
|
|
123201
|
+
aabb: tempAABB$1,
|
|
123202
|
+
fitFOV: 65
|
|
123203
|
+
});
|
|
123204
|
+
},
|
|
121506
123205
|
|
|
121507
|
-
|
|
121508
|
-
|
|
121509
|
-
|
|
123206
|
+
onClickedNothing: () => {
|
|
123207
|
+
this.hideControl();
|
|
123208
|
+
}
|
|
123209
|
+
});
|
|
123210
|
+
}
|
|
123211
|
+
}
|
|
121510
123212
|
|
|
121511
|
-
|
|
121512
|
-
|
|
121513
|
-
|
|
123213
|
+
this._onSceneSectionPlaneCreated = viewer.scene.on("sectionPlaneCreated", (sectionPlane) => {
|
|
123214
|
+
// SectionPlane created, either via SectionPlanesPlugin#createSectionPlane(), or by directly
|
|
123215
|
+
// instantiating a SectionPlane independently of SectionPlanesPlugin, which can be done
|
|
123216
|
+
// by BCFViewpointsPlugin#loadViewpoint().
|
|
121514
123217
|
|
|
121515
|
-
|
|
121516
|
-
|
|
121517
|
-
|
|
123218
|
+
this._sectionPlaneCreated(sectionPlane);
|
|
123219
|
+
});
|
|
123220
|
+
}
|
|
121518
123221
|
|
|
121519
|
-
|
|
121520
|
-
|
|
121521
|
-
|
|
121522
|
-
|
|
121523
|
-
|
|
121524
|
-
|
|
121525
|
-
|
|
121526
|
-
|
|
121527
|
-
|
|
121528
|
-
|
|
121529
|
-
tempAABB$1[0] += sectionPlanePos[0] - tempVec3$1[0];
|
|
121530
|
-
tempAABB$1[1] += sectionPlanePos[1] - tempVec3$1[1];
|
|
121531
|
-
tempAABB$1[2] += sectionPlanePos[2] - tempVec3$1[2];
|
|
121532
|
-
tempAABB$1[3] += sectionPlanePos[0] - tempVec3$1[0];
|
|
121533
|
-
tempAABB$1[4] += sectionPlanePos[1] - tempVec3$1[1];
|
|
121534
|
-
tempAABB$1[5] += sectionPlanePos[2] - tempVec3$1[2];
|
|
121535
|
-
this.viewer.cameraFlight.flyTo({
|
|
121536
|
-
aabb: tempAABB$1,
|
|
121537
|
-
fitFOV: 65
|
|
121538
|
-
});
|
|
121539
|
-
}),
|
|
123222
|
+
/**
|
|
123223
|
+
* Sets if the overview canvas is visible.
|
|
123224
|
+
*
|
|
123225
|
+
* @param {Boolean} visible Whether or not the overview canvas is visible.
|
|
123226
|
+
*/
|
|
123227
|
+
setOverviewVisible(visible) {
|
|
123228
|
+
if (this._overview) {
|
|
123229
|
+
this._overview.setVisible(visible);
|
|
123230
|
+
}
|
|
123231
|
+
}
|
|
121540
123232
|
|
|
121541
|
-
|
|
121542
|
-
|
|
121543
|
-
|
|
121544
|
-
|
|
121545
|
-
|
|
121546
|
-
|
|
123233
|
+
/**
|
|
123234
|
+
* Gets if the overview canvas is visible.
|
|
123235
|
+
*
|
|
123236
|
+
* @return {Boolean} True when the overview canvas is visible.
|
|
123237
|
+
*/
|
|
123238
|
+
getOverviewVisible() {
|
|
123239
|
+
if (this._overview) {
|
|
123240
|
+
return this._overview.getVisible();
|
|
123241
|
+
}
|
|
123242
|
+
}
|
|
121547
123243
|
|
|
121548
|
-
|
|
123244
|
+
/**
|
|
123245
|
+
* Returns a map of the {@link SectionPlane}s created by this SectionPlanesPlugin.
|
|
123246
|
+
*
|
|
123247
|
+
* @returns {{String:SectionPlane}} A map containing the {@link SectionPlane}s, each mapped to its {@link SectionPlane#id}.
|
|
123248
|
+
*/
|
|
123249
|
+
get sectionPlanes() {
|
|
123250
|
+
return this._sectionPlanes;
|
|
123251
|
+
}
|
|
121549
123252
|
|
|
121550
|
-
|
|
121551
|
-
|
|
121552
|
-
|
|
123253
|
+
/**
|
|
123254
|
+
* Creates a {@link SectionPlane}.
|
|
123255
|
+
*
|
|
123256
|
+
* The {@link SectionPlane} will be registered by {@link SectionPlane#id} in {@link SectionPlanesPlugin#sectionPlanes}.
|
|
123257
|
+
*
|
|
123258
|
+
* @param {Object} params {@link SectionPlane} configuration.
|
|
123259
|
+
* @param {String} [params.id] Unique ID to assign to the {@link SectionPlane}. Must be unique among all components in the {@link Viewer}'s {@link Scene}. Auto-generated when omitted.
|
|
123260
|
+
* @param {Number[]} [params.pos=[0,0,0]] World-space position of the {@link SectionPlane}.
|
|
123261
|
+
* @param {Number[]} [params.dir=[0,0,-1]] World-space vector indicating the orientation of the {@link SectionPlane}.
|
|
123262
|
+
* @param {Boolean} [params.active=true] Whether the {@link SectionPlane} is initially active. Only clips while this is true.
|
|
123263
|
+
* @returns {SectionPlane} The new {@link SectionPlane}.
|
|
123264
|
+
*/
|
|
123265
|
+
createSectionPlane(params = {}) {
|
|
123266
|
+
if (params.id !== undefined && params.id !== null && this.viewer.scene.components[params.id]) {
|
|
123267
|
+
this.error("Viewer component with this ID already exists: " + params.id);
|
|
123268
|
+
delete params.id;
|
|
123269
|
+
}
|
|
121553
123270
|
|
|
121554
|
-
|
|
121555
|
-
|
|
121556
|
-
}
|
|
123271
|
+
// Note that SectionPlane constructor fires "sectionPlaneCreated" on the Scene,
|
|
123272
|
+
// which SectionPlanesPlugin handles and calls #_sectionPlaneCreated to create gizmo and add to overview canvas.
|
|
121557
123273
|
|
|
121558
|
-
|
|
121559
|
-
|
|
121560
|
-
|
|
121561
|
-
|
|
121562
|
-
|
|
121563
|
-
|
|
121564
|
-
|
|
121565
|
-
|
|
121566
|
-
}
|
|
121567
|
-
}
|
|
123274
|
+
const sectionPlane = new SectionPlane(this.viewer.scene, {
|
|
123275
|
+
id: params.id,
|
|
123276
|
+
pos: params.pos,
|
|
123277
|
+
dir: params.dir,
|
|
123278
|
+
active: true
|
|
123279
|
+
});
|
|
123280
|
+
return sectionPlane;
|
|
123281
|
+
}
|
|
121568
123282
|
|
|
121569
|
-
|
|
121570
|
-
|
|
121571
|
-
|
|
121572
|
-
|
|
121573
|
-
|
|
121574
|
-
|
|
121575
|
-
|
|
121576
|
-
|
|
121577
|
-
|
|
121578
|
-
|
|
123283
|
+
//剖切面创建后,创建一个控制器
|
|
123284
|
+
_sectionPlaneCreated(sectionPlane) {
|
|
123285
|
+
let newControl;
|
|
123286
|
+
switch (this._sectionWay) {
|
|
123287
|
+
case "plane":
|
|
123288
|
+
newControl = new ClippingPlane(this, this._controlsConfig);
|
|
123289
|
+
break;
|
|
123290
|
+
case "box":
|
|
123291
|
+
newControl = new ClippingBox(this, this._controlsConfig);
|
|
123292
|
+
break;
|
|
123293
|
+
default:
|
|
123294
|
+
newControl = new Control(this);
|
|
123295
|
+
break;
|
|
123296
|
+
}
|
|
123297
|
+
const control = this._freeControls.length > 0 ? this._freeControls.pop() : newControl;
|
|
123298
|
+
control._setSectionPlane(sectionPlane);
|
|
123299
|
+
control.setVisible(true);
|
|
123300
|
+
this._currentControl = control;
|
|
123301
|
+
this._controls[sectionPlane.id] = control;
|
|
123302
|
+
if (this._overview) {
|
|
123303
|
+
this._overview.addSectionPlane(sectionPlane);
|
|
123304
|
+
}
|
|
123305
|
+
sectionPlane.once("destroyed", () => {
|
|
123306
|
+
this._sectionPlaneDestroyed(sectionPlane);
|
|
123307
|
+
});
|
|
123308
|
+
}
|
|
121579
123309
|
|
|
121580
|
-
|
|
121581
|
-
|
|
121582
|
-
|
|
121583
|
-
|
|
121584
|
-
|
|
121585
|
-
|
|
121586
|
-
|
|
121587
|
-
|
|
123310
|
+
/**
|
|
123311
|
+
* 设置是否是触屏模式
|
|
123312
|
+
* @param {boolean} touch
|
|
123313
|
+
*/
|
|
123314
|
+
set isTouch(touch) {
|
|
123315
|
+
this._isTouch = touch;
|
|
123316
|
+
if (touch === true) this.sectionWay = "plane";
|
|
123317
|
+
else this.sectionWay = "control";
|
|
123318
|
+
}
|
|
121588
123319
|
|
|
121589
|
-
|
|
121590
|
-
|
|
121591
|
-
|
|
121592
|
-
|
|
121593
|
-
|
|
121594
|
-
|
|
121595
|
-
|
|
121596
|
-
|
|
121597
|
-
|
|
121598
|
-
|
|
121599
|
-
|
|
121600
|
-
|
|
121601
|
-
createSectionPlane(params = {}) {
|
|
123320
|
+
/**
|
|
123321
|
+
* 设置剖切对象样式
|
|
123322
|
+
* @param {any} cfg
|
|
123323
|
+
* @param {number} cfg.planeSize?
|
|
123324
|
+
* @param {number} cfg.controlSize?
|
|
123325
|
+
* @param {number} cfg.planeOpacity?
|
|
123326
|
+
* @param {number[]} cfg.controlFillColor?
|
|
123327
|
+
* @param {number[]} cfg.controlEdgeColor?
|
|
123328
|
+
*/
|
|
123329
|
+
set sectionConfigs(cfg) {
|
|
123330
|
+
this._controlsConfig = cfg;
|
|
123331
|
+
}
|
|
121602
123332
|
|
|
121603
|
-
|
|
121604
|
-
|
|
121605
|
-
|
|
121606
|
-
|
|
123333
|
+
/**
|
|
123334
|
+
* 设置剖切方式
|
|
123335
|
+
* @param {string} way
|
|
123336
|
+
*/
|
|
123337
|
+
set sectionWay(way) {
|
|
123338
|
+
this._sectionWay = way;
|
|
123339
|
+
}
|
|
121607
123340
|
|
|
121608
|
-
|
|
121609
|
-
|
|
123341
|
+
/**
|
|
123342
|
+
* 设置剖切面方向
|
|
123343
|
+
* @param {number} direction
|
|
123344
|
+
*/
|
|
123345
|
+
set sectionDirection(direction) {
|
|
123346
|
+
this.clear();
|
|
123347
|
+
let dir;
|
|
123348
|
+
switch (direction) {
|
|
123349
|
+
case 0:
|
|
123350
|
+
dir = [0, 0, -1];
|
|
123351
|
+
break;
|
|
123352
|
+
case 1:
|
|
123353
|
+
dir = [0, -1, 0];
|
|
123354
|
+
break;
|
|
123355
|
+
case 2:
|
|
123356
|
+
dir = [-1, 0, 0];
|
|
123357
|
+
break;
|
|
123358
|
+
}
|
|
123359
|
+
this.createSectionPlane({
|
|
123360
|
+
pos: this.viewer.camera.look,
|
|
123361
|
+
dir: dir
|
|
123362
|
+
});
|
|
123363
|
+
}
|
|
121610
123364
|
|
|
121611
|
-
|
|
121612
|
-
|
|
121613
|
-
|
|
121614
|
-
|
|
121615
|
-
|
|
121616
|
-
|
|
121617
|
-
|
|
121618
|
-
|
|
123365
|
+
/**
|
|
123366
|
+
* 设置剖切面位置
|
|
123367
|
+
* @param id
|
|
123368
|
+
* @param pos
|
|
123369
|
+
*/
|
|
123370
|
+
setControlPos(posRate) {
|
|
123371
|
+
if (this._currentControl == null) return;
|
|
123372
|
+
// if (this._currentControl.type != "plane") return;
|
|
123373
|
+
this._currentControl.pos = posRate;
|
|
123374
|
+
}
|
|
121619
123375
|
|
|
121620
|
-
|
|
121621
|
-
|
|
121622
|
-
|
|
121623
|
-
|
|
121624
|
-
|
|
121625
|
-
|
|
121626
|
-
|
|
121627
|
-
|
|
121628
|
-
|
|
121629
|
-
|
|
121630
|
-
|
|
121631
|
-
|
|
123376
|
+
/**
|
|
123377
|
+
* Inverts the direction of {@link SectionPlane#dir} on every existing SectionPlane.
|
|
123378
|
+
*
|
|
123379
|
+
* Inverts all SectionPlanes, including those that were not created with SectionPlanesPlugin.
|
|
123380
|
+
*/
|
|
123381
|
+
flipSectionPlanes() {
|
|
123382
|
+
const sectionPlanes = this.viewer.scene.sectionPlanes;
|
|
123383
|
+
for (let id in sectionPlanes) {
|
|
123384
|
+
const sectionPlane = sectionPlanes[id];
|
|
123385
|
+
sectionPlane.flipDir();
|
|
123386
|
+
}
|
|
123387
|
+
}
|
|
121632
123388
|
|
|
121633
|
-
|
|
121634
|
-
|
|
121635
|
-
|
|
121636
|
-
|
|
121637
|
-
|
|
121638
|
-
|
|
121639
|
-
|
|
121640
|
-
|
|
121641
|
-
|
|
121642
|
-
|
|
121643
|
-
|
|
121644
|
-
|
|
123389
|
+
/**
|
|
123390
|
+
* Shows the 3D editing gizmo for a {@link SectionPlane}.
|
|
123391
|
+
*
|
|
123392
|
+
* @param {String} id ID of the {@link SectionPlane}.
|
|
123393
|
+
*/
|
|
123394
|
+
showControl(id) {
|
|
123395
|
+
const control = this._controls[id];
|
|
123396
|
+
if (!control) {
|
|
123397
|
+
this.error("Control not found: " + id);
|
|
123398
|
+
return;
|
|
123399
|
+
}
|
|
123400
|
+
this.hideControl();
|
|
123401
|
+
control.setVisible(true);
|
|
123402
|
+
if (this._overview) {
|
|
123403
|
+
this._overview.setPlaneSelected(id, true);
|
|
123404
|
+
}
|
|
123405
|
+
this._shownControlId = id;
|
|
123406
|
+
}
|
|
121645
123407
|
|
|
121646
|
-
|
|
121647
|
-
|
|
121648
|
-
|
|
121649
|
-
|
|
121650
|
-
|
|
121651
|
-
|
|
121652
|
-
|
|
121653
|
-
|
|
121654
|
-
|
|
121655
|
-
return;
|
|
121656
|
-
}
|
|
121657
|
-
this.hideControl();
|
|
121658
|
-
control.setVisible(true);
|
|
121659
|
-
if (this._overview) {
|
|
121660
|
-
this._overview.setPlaneSelected(id, true);
|
|
121661
|
-
}
|
|
121662
|
-
this._shownControlId = id;
|
|
121663
|
-
}
|
|
123408
|
+
/**
|
|
123409
|
+
* 设置剖切对象的尺寸
|
|
123410
|
+
* @param {*} size
|
|
123411
|
+
*/
|
|
123412
|
+
setControlsSize(size) {
|
|
123413
|
+
for (let id in this._controls) {
|
|
123414
|
+
this._controls[id].controlSize = size;
|
|
123415
|
+
}
|
|
123416
|
+
}
|
|
121664
123417
|
|
|
121665
|
-
|
|
121666
|
-
|
|
121667
|
-
|
|
121668
|
-
|
|
121669
|
-
|
|
121670
|
-
|
|
121671
|
-
|
|
121672
|
-
|
|
121673
|
-
|
|
121674
|
-
|
|
123418
|
+
/**
|
|
123419
|
+
* 设置指定id剖切对象的尺寸
|
|
123420
|
+
* @param {*} id
|
|
123421
|
+
* @param {*} size
|
|
123422
|
+
* @returns
|
|
123423
|
+
*/
|
|
123424
|
+
setControlSizeByID(id, size) {
|
|
123425
|
+
const control = this._controls[id];
|
|
123426
|
+
if (!control) {
|
|
123427
|
+
this.error("Control not found: " + id);
|
|
123428
|
+
return;
|
|
123429
|
+
}
|
|
123430
|
+
this._controls[id].controlSize = size;
|
|
123431
|
+
}
|
|
121675
123432
|
|
|
121676
|
-
|
|
121677
|
-
|
|
121678
|
-
|
|
121679
|
-
|
|
121680
|
-
|
|
121681
|
-
|
|
121682
|
-
|
|
121683
|
-
|
|
121684
|
-
|
|
121685
|
-
|
|
121686
|
-
}
|
|
121687
|
-
}
|
|
121688
|
-
this._shownControlId = null;
|
|
121689
|
-
}
|
|
123433
|
+
/**
|
|
123434
|
+
* Gets the ID of the {@link SectionPlane} that the 3D editing gizmo is shown for.
|
|
123435
|
+
*
|
|
123436
|
+
* Returns ````null```` when the editing gizmo is not shown.
|
|
123437
|
+
*
|
|
123438
|
+
* @returns {String} ID of the the {@link SectionPlane} that the 3D editing gizmo is shown for, if shown, else ````null````.
|
|
123439
|
+
*/
|
|
123440
|
+
getShownControl() {
|
|
123441
|
+
return this._shownControlId;
|
|
123442
|
+
}
|
|
121690
123443
|
|
|
121691
|
-
|
|
121692
|
-
|
|
121693
|
-
|
|
121694
|
-
|
|
121695
|
-
|
|
121696
|
-
|
|
121697
|
-
|
|
121698
|
-
|
|
121699
|
-
|
|
121700
|
-
|
|
121701
|
-
|
|
121702
|
-
|
|
121703
|
-
|
|
123444
|
+
/**
|
|
123445
|
+
* Hides the 3D {@link SectionPlane} editing gizmo if shown.
|
|
123446
|
+
*/
|
|
123447
|
+
hideControl() {
|
|
123448
|
+
for (var id in this._controls) {
|
|
123449
|
+
if (this._controls.hasOwnProperty(id)) {
|
|
123450
|
+
this._controls[id].setVisible(false);
|
|
123451
|
+
if (this._overview) {
|
|
123452
|
+
this._overview.setPlaneSelected(id, false);
|
|
123453
|
+
}
|
|
123454
|
+
}
|
|
123455
|
+
}
|
|
123456
|
+
this._shownControlId = null;
|
|
123457
|
+
}
|
|
121704
123458
|
|
|
121705
|
-
|
|
121706
|
-
|
|
121707
|
-
|
|
121708
|
-
|
|
123459
|
+
/**
|
|
123460
|
+
* Destroys a {@link SectionPlane} created by this SectionPlanesPlugin.
|
|
123461
|
+
*
|
|
123462
|
+
* @param {String} id ID of the {@link SectionPlane}.
|
|
123463
|
+
*/
|
|
123464
|
+
destroySectionPlane(id) {
|
|
123465
|
+
var sectionPlane = this.viewer.scene.sectionPlanes[id];
|
|
123466
|
+
if (!sectionPlane) {
|
|
123467
|
+
this.error("SectionPlane not found: " + id);
|
|
123468
|
+
return;
|
|
123469
|
+
}
|
|
123470
|
+
this._sectionPlaneDestroyed(sectionPlane);
|
|
123471
|
+
sectionPlane.destroy();
|
|
121709
123472
|
|
|
121710
|
-
|
|
121711
|
-
|
|
121712
|
-
|
|
121713
|
-
|
|
121714
|
-
const control = this._controls[sectionPlane.id];
|
|
121715
|
-
if (!control) {
|
|
121716
|
-
return;
|
|
121717
|
-
}
|
|
121718
|
-
control.setVisible(false);
|
|
121719
|
-
control._setSectionPlane(null);
|
|
121720
|
-
delete this._controls[sectionPlane.id];
|
|
121721
|
-
this._freeControls.push(control);
|
|
121722
|
-
}
|
|
123473
|
+
if (id === this._shownControlId) {
|
|
123474
|
+
this._shownControlId = null;
|
|
123475
|
+
}
|
|
123476
|
+
}
|
|
121723
123477
|
|
|
121724
|
-
|
|
121725
|
-
|
|
121726
|
-
|
|
121727
|
-
|
|
121728
|
-
|
|
121729
|
-
|
|
121730
|
-
|
|
121731
|
-
|
|
121732
|
-
|
|
123478
|
+
_sectionPlaneDestroyed(sectionPlane) {
|
|
123479
|
+
if (this._overview) {
|
|
123480
|
+
this._overview.removeSectionPlane(sectionPlane);
|
|
123481
|
+
}
|
|
123482
|
+
const control = this._controls[sectionPlane.id];
|
|
123483
|
+
if (!control) {
|
|
123484
|
+
return;
|
|
123485
|
+
}
|
|
123486
|
+
control.setVisible(false);
|
|
123487
|
+
control._setSectionPlane(null);
|
|
123488
|
+
delete this._controls[sectionPlane.id];
|
|
123489
|
+
this._freeControls.push(control);
|
|
123490
|
+
}
|
|
121733
123491
|
|
|
121734
|
-
|
|
121735
|
-
|
|
121736
|
-
|
|
121737
|
-
|
|
121738
|
-
|
|
123492
|
+
/**
|
|
123493
|
+
* Destroys all {@link SectionPlane}s created by this SectionPlanesPlugin.
|
|
123494
|
+
*/
|
|
123495
|
+
clear() {
|
|
123496
|
+
const ids = Object.keys(this._sectionPlanes);
|
|
123497
|
+
for (var i = 0, len = ids.length; i < len; i++) {
|
|
123498
|
+
this.destroySectionPlane(ids[i]);
|
|
123499
|
+
}
|
|
123500
|
+
}
|
|
121739
123501
|
|
|
121740
|
-
|
|
121741
|
-
|
|
121742
|
-
|
|
121743
|
-
|
|
121744
|
-
|
|
121745
|
-
|
|
121746
|
-
|
|
123502
|
+
/**
|
|
123503
|
+
* @private
|
|
123504
|
+
*/
|
|
123505
|
+
send(name, value) {
|
|
123506
|
+
switch (name) {
|
|
123507
|
+
case "snapshotStarting": // Viewer#getSnapshot() about to take snapshot - hide controls
|
|
123508
|
+
for (let id in this._controls) {
|
|
123509
|
+
if (this._controls.hasOwnProperty(id)) {
|
|
123510
|
+
this._controls[id].setCulled(true);
|
|
123511
|
+
}
|
|
123512
|
+
}
|
|
123513
|
+
break;
|
|
121747
123514
|
|
|
121748
|
-
|
|
121749
|
-
|
|
121750
|
-
|
|
121751
|
-
|
|
121752
|
-
|
|
121753
|
-
|
|
121754
|
-
|
|
123515
|
+
case "snapshotFinished": // Viewer#getSnapshot() finished taking snapshot - show controls again
|
|
123516
|
+
for (let id in this._controls) {
|
|
123517
|
+
if (this._controls.hasOwnProperty(id)) {
|
|
123518
|
+
this._controls[id].setCulled(false);
|
|
123519
|
+
}
|
|
123520
|
+
}
|
|
123521
|
+
break;
|
|
121755
123522
|
|
|
121756
|
-
|
|
121757
|
-
|
|
121758
|
-
|
|
121759
|
-
|
|
121760
|
-
|
|
123523
|
+
case "clearSectionPlanes":
|
|
123524
|
+
this.clear();
|
|
123525
|
+
break;
|
|
123526
|
+
}
|
|
123527
|
+
}
|
|
121761
123528
|
|
|
121762
|
-
|
|
121763
|
-
|
|
121764
|
-
|
|
121765
|
-
|
|
121766
|
-
|
|
121767
|
-
|
|
121768
|
-
|
|
121769
|
-
|
|
121770
|
-
|
|
121771
|
-
|
|
121772
|
-
|
|
121773
|
-
|
|
121774
|
-
|
|
121775
|
-
|
|
121776
|
-
|
|
123529
|
+
/**
|
|
123530
|
+
* Destroys this SectionPlanesPlugin.
|
|
123531
|
+
*
|
|
123532
|
+
* Also destroys each {@link SectionPlane} created by this SectionPlanesPlugin.
|
|
123533
|
+
*
|
|
123534
|
+
* Does not destroy the canvas the SectionPlanesPlugin was configured with.
|
|
123535
|
+
*/
|
|
123536
|
+
destroy() {
|
|
123537
|
+
this.clear();
|
|
123538
|
+
if (this._overview) {
|
|
123539
|
+
this._overview.destroy();
|
|
123540
|
+
}
|
|
123541
|
+
this._destroyFreeControls();
|
|
123542
|
+
super.destroy();
|
|
123543
|
+
}
|
|
121777
123544
|
|
|
121778
|
-
|
|
121779
|
-
|
|
121780
|
-
|
|
121781
|
-
|
|
121782
|
-
|
|
121783
|
-
|
|
121784
|
-
|
|
121785
|
-
|
|
123545
|
+
_destroyFreeControls() {
|
|
123546
|
+
var control = this._freeControls.pop();
|
|
123547
|
+
while (control) {
|
|
123548
|
+
control._destroy();
|
|
123549
|
+
control = this._freeControls.pop();
|
|
123550
|
+
}
|
|
123551
|
+
this.viewer.scene.off(this._onSceneSectionPlaneCreated);
|
|
123552
|
+
}
|
|
121786
123553
|
}
|
|
121787
123554
|
|
|
121788
123555
|
/**
|
|
@@ -123538,235 +125305,241 @@ class Plane {
|
|
|
123538
125305
|
* @private
|
|
123539
125306
|
*/
|
|
123540
125307
|
class Overview {
|
|
125308
|
+
/**
|
|
125309
|
+
* @private
|
|
125310
|
+
*/
|
|
125311
|
+
constructor(plugin, cfg) {
|
|
125312
|
+
if (!cfg.onHoverEnterPlane || !cfg.onHoverLeavePlane || !cfg.onClickedNothing || !cfg.onClickedPlane) {
|
|
125313
|
+
throw "Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";
|
|
125314
|
+
}
|
|
123541
125315
|
|
|
123542
|
-
|
|
123543
|
-
|
|
123544
|
-
|
|
123545
|
-
|
|
123546
|
-
|
|
123547
|
-
|
|
123548
|
-
throw "Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";
|
|
123549
|
-
}
|
|
123550
|
-
|
|
123551
|
-
/**
|
|
123552
|
-
* The {@link FaceAlignedSectionPlanesPlugin} that owns this SectionPlanesOverview.
|
|
123553
|
-
*
|
|
123554
|
-
* @type {FaceAlignedSectionPlanesPlugin}
|
|
123555
|
-
*/
|
|
123556
|
-
this.plugin = plugin;
|
|
125316
|
+
/**
|
|
125317
|
+
* The {@link FaceAlignedSectionPlanesPlugin} that owns this SectionPlanesOverview.
|
|
125318
|
+
*
|
|
125319
|
+
* @type {FaceAlignedSectionPlanesPlugin}
|
|
125320
|
+
*/
|
|
125321
|
+
this.plugin = plugin;
|
|
123557
125322
|
|
|
123558
|
-
|
|
125323
|
+
this._viewer = plugin.viewer;
|
|
123559
125324
|
|
|
123560
|
-
|
|
123561
|
-
|
|
123562
|
-
|
|
123563
|
-
|
|
123564
|
-
|
|
125325
|
+
this._onHoverEnterPlane = cfg.onHoverEnterPlane;
|
|
125326
|
+
this._onHoverLeavePlane = cfg.onHoverLeavePlane;
|
|
125327
|
+
this._onClickedNothing = cfg.onClickedNothing;
|
|
125328
|
+
this._onClickedPlane = cfg.onClickedPlane;
|
|
125329
|
+
this._visible = true;
|
|
123565
125330
|
|
|
123566
|
-
|
|
125331
|
+
this._planes = {};
|
|
123567
125332
|
|
|
123568
|
-
|
|
123569
|
-
|
|
123570
|
-
|
|
125333
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
125334
|
+
// Init canvas
|
|
125335
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
123571
125336
|
|
|
123572
|
-
|
|
125337
|
+
this._canvas = cfg.overviewCanvas;
|
|
123573
125338
|
|
|
123574
|
-
|
|
123575
|
-
|
|
123576
|
-
|
|
125339
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
125340
|
+
// Init scene
|
|
125341
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
123577
125342
|
|
|
123578
|
-
|
|
123579
|
-
|
|
123580
|
-
|
|
123581
|
-
|
|
123582
|
-
|
|
123583
|
-
|
|
123584
|
-
|
|
123585
|
-
|
|
123586
|
-
|
|
123587
|
-
|
|
123588
|
-
|
|
123589
|
-
|
|
123590
|
-
|
|
123591
|
-
|
|
123592
|
-
|
|
123593
|
-
|
|
123594
|
-
|
|
123595
|
-
|
|
123596
|
-
|
|
123597
|
-
|
|
123598
|
-
|
|
123599
|
-
|
|
123600
|
-
|
|
125343
|
+
this._scene = new Scene(this._viewer, {
|
|
125344
|
+
canvasId: this._canvas.id,
|
|
125345
|
+
transparent: true
|
|
125346
|
+
});
|
|
125347
|
+
this._scene.clearLights();
|
|
125348
|
+
new DirLight(this._scene, {
|
|
125349
|
+
dir: [0.4, -0.4, 0.8],
|
|
125350
|
+
color: [0.8, 1.0, 1.0],
|
|
125351
|
+
intensity: 1.0,
|
|
125352
|
+
space: "view"
|
|
125353
|
+
});
|
|
125354
|
+
new DirLight(this._scene, {
|
|
125355
|
+
dir: [-0.8, -0.3, -0.4],
|
|
125356
|
+
color: [0.8, 0.8, 0.8],
|
|
125357
|
+
intensity: 1.0,
|
|
125358
|
+
space: "view"
|
|
125359
|
+
});
|
|
125360
|
+
new DirLight(this._scene, {
|
|
125361
|
+
dir: [0.8, -0.6, -0.8],
|
|
125362
|
+
color: [1.0, 1.0, 1.0],
|
|
125363
|
+
intensity: 1.0,
|
|
125364
|
+
space: "view"
|
|
125365
|
+
});
|
|
123601
125366
|
|
|
123602
|
-
|
|
123603
|
-
|
|
125367
|
+
this._scene.camera;
|
|
125368
|
+
this._scene.camera.perspective.fov = 70;
|
|
123604
125369
|
|
|
123605
|
-
|
|
125370
|
+
this._zUp = false;
|
|
123606
125371
|
|
|
123607
|
-
|
|
123608
|
-
|
|
123609
|
-
|
|
125372
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
125373
|
+
// Synchronize overview scene camera with viewer camera
|
|
125374
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
123610
125375
|
|
|
123611
|
-
|
|
123612
|
-
|
|
123613
|
-
|
|
123614
|
-
|
|
123615
|
-
|
|
123616
|
-
|
|
123617
|
-
|
|
123618
|
-
|
|
123619
|
-
|
|
123620
|
-
|
|
123621
|
-
|
|
123622
|
-
|
|
123623
|
-
|
|
123624
|
-
|
|
123625
|
-
|
|
123626
|
-
|
|
123627
|
-
|
|
123628
|
-
|
|
123629
|
-
|
|
123630
|
-
|
|
123631
|
-
|
|
123632
|
-
|
|
123633
|
-
|
|
123634
|
-
|
|
123635
|
-
|
|
125376
|
+
{
|
|
125377
|
+
const camera = this._scene.camera;
|
|
125378
|
+
const matrix = math.rotationMat4c(-90 * math.DEGTORAD, 1, 0, 0);
|
|
125379
|
+
const eyeLookVec = math.vec3();
|
|
125380
|
+
const eyeLookVecOverview = math.vec3();
|
|
125381
|
+
const upOverview = math.vec3();
|
|
125382
|
+
|
|
125383
|
+
this._synchCamera = () => {
|
|
125384
|
+
const eye = this._viewer.camera.eye;
|
|
125385
|
+
const look = this._viewer.camera.look;
|
|
125386
|
+
const up = this._viewer.camera.up;
|
|
125387
|
+
math.mulVec3Scalar(math.normalizeVec3(math.subVec3(eye, look, eyeLookVec)), 7);
|
|
125388
|
+
if (this._zUp) {
|
|
125389
|
+
// +Z up
|
|
125390
|
+
math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
|
|
125391
|
+
math.transformVec3(matrix, up, upOverview);
|
|
125392
|
+
camera.look = [0, 0, 0];
|
|
125393
|
+
camera.eye = math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
|
|
125394
|
+
camera.up = math.transformPoint3(matrix, up, upOverview);
|
|
125395
|
+
} else {
|
|
125396
|
+
// +Y up
|
|
125397
|
+
camera.look = [0, 0, 0];
|
|
125398
|
+
camera.eye = eyeLookVec;
|
|
125399
|
+
camera.up = up;
|
|
125400
|
+
}
|
|
125401
|
+
};
|
|
125402
|
+
}
|
|
123636
125403
|
|
|
123637
|
-
|
|
125404
|
+
this._onViewerCameraMatrix = this._viewer.camera.on("matrix", this._synchCamera);
|
|
123638
125405
|
|
|
123639
|
-
|
|
125406
|
+
this._onViewerCameraWorldAxis = this._viewer.camera.on("worldAxis", this._synchCamera);
|
|
123640
125407
|
|
|
123641
|
-
|
|
123642
|
-
|
|
123643
|
-
|
|
125408
|
+
this._onViewerCameraFOV = this._viewer.camera.perspective.on("fov", (fov) => {
|
|
125409
|
+
this._scene.camera.perspective.fov = fov;
|
|
125410
|
+
});
|
|
123644
125411
|
|
|
123645
|
-
|
|
123646
|
-
|
|
123647
|
-
|
|
125412
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
125413
|
+
// Bind overview canvas events
|
|
125414
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
123648
125415
|
|
|
123649
|
-
|
|
123650
|
-
|
|
125416
|
+
{
|
|
125417
|
+
var hoveredEntity = null;
|
|
123651
125418
|
|
|
123652
|
-
|
|
123653
|
-
|
|
123654
|
-
|
|
123655
|
-
|
|
123656
|
-
|
|
123657
|
-
|
|
123658
|
-
|
|
123659
|
-
|
|
123660
|
-
|
|
123661
|
-
|
|
123662
|
-
|
|
123663
|
-
|
|
123664
|
-
|
|
123665
|
-
|
|
123666
|
-
|
|
123667
|
-
|
|
123668
|
-
|
|
123669
|
-
|
|
123670
|
-
|
|
123671
|
-
|
|
123672
|
-
|
|
123673
|
-
|
|
123674
|
-
|
|
123675
|
-
|
|
123676
|
-
|
|
125419
|
+
this._onInputMouseMove = this._scene.input.on("mousemove", (coords) => {
|
|
125420
|
+
const hit = this._scene.pick({
|
|
125421
|
+
canvasPos: coords
|
|
125422
|
+
});
|
|
125423
|
+
if (hit) {
|
|
125424
|
+
if (!hoveredEntity || hit.entity.id !== hoveredEntity.id) {
|
|
125425
|
+
if (hoveredEntity) {
|
|
125426
|
+
const plane = this._planes[hoveredEntity.id];
|
|
125427
|
+
if (plane) {
|
|
125428
|
+
this._onHoverLeavePlane(hoveredEntity.id);
|
|
125429
|
+
}
|
|
125430
|
+
}
|
|
125431
|
+
hoveredEntity = hit.entity;
|
|
125432
|
+
const plane = this._planes[hoveredEntity.id];
|
|
125433
|
+
if (plane) {
|
|
125434
|
+
this._onHoverEnterPlane(hoveredEntity.id);
|
|
125435
|
+
}
|
|
125436
|
+
}
|
|
125437
|
+
} else {
|
|
125438
|
+
if (hoveredEntity) {
|
|
125439
|
+
this._onHoverLeavePlane(hoveredEntity.id);
|
|
125440
|
+
hoveredEntity = null;
|
|
125441
|
+
}
|
|
125442
|
+
}
|
|
125443
|
+
});
|
|
123677
125444
|
|
|
123678
|
-
|
|
123679
|
-
|
|
123680
|
-
|
|
123681
|
-
|
|
123682
|
-
|
|
123683
|
-
|
|
123684
|
-
|
|
123685
|
-
|
|
123686
|
-
|
|
123687
|
-
|
|
125445
|
+
this._scene.canvas.canvas.addEventListener(
|
|
125446
|
+
"mouseup",
|
|
125447
|
+
(this._onCanvasMouseUp = () => {
|
|
125448
|
+
if (hoveredEntity) {
|
|
125449
|
+
const plane = this._planes[hoveredEntity.id];
|
|
125450
|
+
if (plane) {
|
|
125451
|
+
this._onClickedPlane(hoveredEntity.id);
|
|
125452
|
+
}
|
|
125453
|
+
} else {
|
|
125454
|
+
this._onClickedNothing();
|
|
125455
|
+
}
|
|
125456
|
+
})
|
|
125457
|
+
);
|
|
123688
125458
|
|
|
123689
|
-
|
|
123690
|
-
|
|
123691
|
-
|
|
123692
|
-
|
|
123693
|
-
|
|
123694
|
-
|
|
123695
|
-
|
|
125459
|
+
this._scene.canvas.canvas.addEventListener(
|
|
125460
|
+
"mouseout",
|
|
125461
|
+
(this._onCanvasMouseOut = () => {
|
|
125462
|
+
if (hoveredEntity) {
|
|
125463
|
+
this._onHoverLeavePlane(hoveredEntity.id);
|
|
125464
|
+
hoveredEntity = null;
|
|
125465
|
+
}
|
|
125466
|
+
})
|
|
125467
|
+
);
|
|
125468
|
+
}
|
|
123696
125469
|
|
|
123697
|
-
|
|
123698
|
-
|
|
123699
|
-
|
|
125470
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
125471
|
+
// Configure overview
|
|
125472
|
+
//--------------------------------------------------------------------------------------------------------------
|
|
123700
125473
|
|
|
123701
|
-
|
|
123702
|
-
|
|
125474
|
+
this.setVisible(cfg.overviewVisible);
|
|
125475
|
+
}
|
|
123703
125476
|
|
|
123704
|
-
|
|
123705
|
-
|
|
123706
|
-
|
|
123707
|
-
|
|
123708
|
-
|
|
123709
|
-
|
|
125477
|
+
/** Called by SectionPlanesPlugin#createSectionPlane()
|
|
125478
|
+
* @private
|
|
125479
|
+
*/
|
|
125480
|
+
addSectionPlane(sectionPlane) {
|
|
125481
|
+
this._planes[sectionPlane.id] = new Plane(this, this._scene, sectionPlane);
|
|
125482
|
+
}
|
|
123710
125483
|
|
|
123711
|
-
|
|
123712
|
-
|
|
123713
|
-
|
|
123714
|
-
|
|
123715
|
-
|
|
123716
|
-
|
|
123717
|
-
|
|
123718
|
-
|
|
125484
|
+
/** @private
|
|
125485
|
+
*/
|
|
125486
|
+
setPlaneHighlighted(id, highlighted) {
|
|
125487
|
+
const plane = this._planes[id];
|
|
125488
|
+
if (plane) {
|
|
125489
|
+
plane.setHighlighted(highlighted);
|
|
125490
|
+
}
|
|
125491
|
+
}
|
|
123719
125492
|
|
|
123720
|
-
|
|
123721
|
-
|
|
123722
|
-
|
|
123723
|
-
|
|
123724
|
-
|
|
123725
|
-
|
|
123726
|
-
|
|
123727
|
-
|
|
125493
|
+
/** @private
|
|
125494
|
+
*/
|
|
125495
|
+
setPlaneSelected(id, selected) {
|
|
125496
|
+
const plane = this._planes[id];
|
|
125497
|
+
if (plane) {
|
|
125498
|
+
plane.setSelected(selected);
|
|
125499
|
+
}
|
|
125500
|
+
}
|
|
123728
125501
|
|
|
123729
|
-
|
|
123730
|
-
|
|
123731
|
-
|
|
123732
|
-
|
|
123733
|
-
|
|
123734
|
-
|
|
123735
|
-
|
|
123736
|
-
|
|
123737
|
-
|
|
125502
|
+
/** @private
|
|
125503
|
+
*/
|
|
125504
|
+
removeSectionPlane(sectionPlane) {
|
|
125505
|
+
const plane = this._planes[sectionPlane.id];
|
|
125506
|
+
if (plane) {
|
|
125507
|
+
plane.destroy();
|
|
125508
|
+
delete this._planes[sectionPlane.id];
|
|
125509
|
+
}
|
|
125510
|
+
}
|
|
123738
125511
|
|
|
123739
|
-
|
|
123740
|
-
|
|
123741
|
-
|
|
123742
|
-
|
|
123743
|
-
|
|
123744
|
-
|
|
123745
|
-
|
|
123746
|
-
|
|
123747
|
-
|
|
125512
|
+
/**
|
|
125513
|
+
* Sets if this SectionPlanesOverview is visible.
|
|
125514
|
+
*
|
|
125515
|
+
* @param {Boolean} visible Whether or not this SectionPlanesOverview is visible.
|
|
125516
|
+
*/
|
|
125517
|
+
setVisible(visible = true) {
|
|
125518
|
+
this._visible = visible;
|
|
125519
|
+
this._canvas.style.visibility = visible ? "visible" : "hidden";
|
|
125520
|
+
}
|
|
123748
125521
|
|
|
123749
|
-
|
|
123750
|
-
|
|
123751
|
-
|
|
123752
|
-
|
|
123753
|
-
|
|
123754
|
-
|
|
123755
|
-
|
|
123756
|
-
|
|
125522
|
+
/**
|
|
125523
|
+
* Gets if this SectionPlanesOverview is visible.
|
|
125524
|
+
*
|
|
125525
|
+
* @return {Boolean} True when this SectionPlanesOverview is visible.
|
|
125526
|
+
*/
|
|
125527
|
+
getVisible() {
|
|
125528
|
+
return this._visible;
|
|
125529
|
+
}
|
|
123757
125530
|
|
|
123758
|
-
|
|
123759
|
-
|
|
123760
|
-
|
|
123761
|
-
|
|
123762
|
-
|
|
123763
|
-
|
|
125531
|
+
/** @private
|
|
125532
|
+
*/
|
|
125533
|
+
destroy() {
|
|
125534
|
+
this._viewer.camera.off(this._onViewerCameraMatrix);
|
|
125535
|
+
this._viewer.camera.off(this._onViewerCameraWorldAxis);
|
|
125536
|
+
this._viewer.camera.perspective.off(this._onViewerCameraFOV);
|
|
123764
125537
|
|
|
123765
|
-
|
|
123766
|
-
|
|
123767
|
-
|
|
123768
|
-
|
|
123769
|
-
|
|
125538
|
+
this._scene.input.off(this._onInputMouseMove);
|
|
125539
|
+
this._scene.canvas.canvas.removeEventListener("mouseup", this._onCanvasMouseUp);
|
|
125540
|
+
this._scene.canvas.canvas.removeEventListener("mouseout", this._onCanvasMouseOut);
|
|
125541
|
+
this._scene.destroy();
|
|
125542
|
+
}
|
|
123770
125543
|
}
|
|
123771
125544
|
|
|
123772
125545
|
const tempAABB = math.AABB3();
|