@xeokit/xeokit-sdk 2.6.55 → 2.6.57

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.
Files changed (32) hide show
  1. package/dist/xeokit-sdk.cjs.js +1369 -1771
  2. package/dist/xeokit-sdk.es.js +1367 -1772
  3. package/dist/xeokit-sdk.es5.js +709 -719
  4. package/dist/xeokit-sdk.min.cjs.js +5 -5
  5. package/dist/xeokit-sdk.min.es.js +5 -5
  6. package/dist/xeokit-sdk.min.es5.js +4 -4
  7. package/package.json +1 -1
  8. package/src/plugins/AngleMeasurementsPlugin/AngleMeasurement.js +155 -415
  9. package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +1 -1
  10. package/src/plugins/AnnotationsPlugin/Annotation.js +7 -5
  11. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +236 -750
  12. package/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js +51 -0
  13. package/src/plugins/TreeViewPlugin/RenderService.js +2 -1
  14. package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +5 -1
  15. package/src/plugins/ZonesPlugin/ZonesPlugin.js +15 -79
  16. package/src/plugins/lib/html/Dot.js +14 -41
  17. package/src/plugins/lib/html/Label.js +10 -37
  18. package/src/plugins/lib/html/MenuEvent.js +74 -0
  19. package/src/plugins/lib/html/Wire.js +20 -47
  20. package/src/plugins/lib/ui/index.js +370 -12
  21. package/src/viewer/Viewer.js +9 -0
  22. package/src/viewer/index.js +1 -0
  23. package/src/viewer/scene/CameraControl/lib/handlers/MousePanRotateDollyHandler.js +1 -1
  24. package/src/viewer/scene/CameraControl/lib/handlers/TouchPanRotateAndDollyHandler.js +2 -1
  25. package/src/viewer/scene/marker/Marker.js +20 -23
  26. package/src/viewer/scene/model/SceneModelEntity.js +5 -0
  27. package/src/viewer/utils/index.js +1 -0
  28. package/src/viewer/utils/os.js +8 -1
  29. package/types/viewer/scene/models/PerformanceModel/index.d.ts +0 -1
  30. package/types/viewer/scene/models/SceneModel.d.ts +0 -3
  31. package/types/viewer/scene/models/SceneModelEntity.d.ts +6 -0
  32. package/types/viewer/scene/nodes/Node.d.ts +1 -1
@@ -1,11 +1,9 @@
1
- import {Dot3D} from "../lib/ui/index.js";
2
- import {Wire} from "../lib/html/Wire.js";
3
- import {Label} from "../lib/html/Label.js";
1
+ import {Dot3D, Label3D, Wire3D} from "../lib/ui/index.js";
4
2
  import {math} from "../../viewer/scene/math/math.js";
5
3
  import {Component} from "../../viewer/scene/Component.js";
6
4
 
7
- var originVec = math.vec3();
8
- var targetVec = math.vec3();
5
+ const tmpVec3a = math.vec3();
6
+ const tmpVec3b = math.vec3();
9
7
 
10
8
  /**
11
9
  * @desc Measures the angle indicated by three 3D points.
@@ -19,7 +17,9 @@ class AngleMeasurement extends Component {
19
17
  */
20
18
  constructor(plugin, cfg = {}) {
21
19
 
22
- super(plugin.viewer.scene, cfg);
20
+ const scene = plugin.viewer.scene;
21
+
22
+ super(scene, cfg);
23
23
 
24
24
  /**
25
25
  * The {@link AngleMeasurementsPlugin} that owns this AngleMeasurement.
@@ -27,349 +27,165 @@ class AngleMeasurement extends Component {
27
27
  */
28
28
  this.plugin = plugin;
29
29
 
30
- this._container = cfg.container;
31
- if (!this._container) {
30
+ const container = cfg.container;
31
+ if (!container) {
32
32
  throw "config missing: container";
33
33
  }
34
34
 
35
35
  this._color = cfg.color || plugin.defaultColor;
36
36
 
37
- var scene = this.plugin.viewer.scene;
37
+ const channel = function(v) {
38
+ const listeners = [ ];
39
+ let value = v !== false;
40
+ return {
41
+ reg: (l) => listeners.push(l),
42
+ get: () => value,
43
+ set: (v) => {
44
+ value = v !== false;
45
+ listeners.forEach(l => l(value));
46
+ }
47
+ };
48
+ };
49
+
50
+ this._visible = channel(cfg.visible);
51
+ this._originVisible = channel(cfg.originVisible);
52
+ this._cornerVisible = channel(cfg.cornerVisible);
53
+ this._targetVisible = channel(cfg.targetVisible);
54
+ this._originWireVisible = channel(cfg.originWireVisible);
55
+ this._targetWireVisible = channel(cfg.targetWireVisible);
56
+ this._angleVisible = channel(cfg.angleVisible);
57
+ this._labelsVisible = channel();
58
+ this.labelsVisible = cfg.labelsVisible;
59
+ this._clickable = channel(false);
60
+
61
+ this.approximate = cfg.approximate;
38
62
 
39
- this._originWorld = math.vec3();
40
- this._cornerWorld = math.vec3();
41
- this._targetWorld = math.vec3();
42
63
 
43
- this._wp = new Float64Array(12);
44
- this._vp = new Float64Array(12);
45
- this._pp = new Float64Array(12);
46
- this._cp = new Int16Array(6);
64
+ const canvas = scene.canvas.canvas;
47
65
 
48
66
  const onMouseOver = cfg.onMouseOver ? (event) => {
49
67
  cfg.onMouseOver(event, this);
50
- this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mouseover', event));
68
+ canvas.dispatchEvent(new MouseEvent('mouseover', event));
51
69
  } : null;
52
70
 
53
71
  const onMouseLeave = cfg.onMouseLeave ? (event) => {
54
72
  cfg.onMouseLeave(event, this);
55
- this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mouseleave', event));
73
+ canvas.dispatchEvent(new MouseEvent('mouseleave', event));
56
74
  } : null;
57
75
 
58
76
  const onContextMenu = cfg.onContextMenu ? (event) => {
59
77
  cfg.onContextMenu(event, this);
60
78
  } : null;
61
79
 
62
- const onMouseWheel = (event) => {
63
- this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel', event));
64
- };
80
+ const onMouseDown = (event) => canvas.dispatchEvent(new MouseEvent('mousedown', event));
81
+ const onMouseUp = (event) => canvas.dispatchEvent(new MouseEvent('mouseup', event));
82
+ const onMouseMove = (event) => canvas.dispatchEvent(new MouseEvent('mousemove', event));
83
+ const onMouseWheel = (event) => canvas.dispatchEvent(new WheelEvent('wheel', event));
65
84
 
66
- const onMouseDown = (event) => {
67
- this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mousedown', event));
68
- } ;
69
85
 
70
- const onMouseUp = (event) => {
71
- this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mouseup', event));
72
- };
86
+ this._cleanups = [ ];
87
+ this._drawables = [ ];
73
88
 
74
- const onMouseMove = (event) => {
75
- this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mousemove', event));
89
+ const registerDrawable = (drawable, visibilityChannels) => {
90
+ const updateVisibility = () => drawable.setVisible(visibilityChannels.every(ch => ch.get()));
91
+ visibilityChannels.forEach(ch => ch.reg(updateVisibility));
92
+ this._drawables.push(drawable);
93
+ this._cleanups.push(() => drawable.destroy());
76
94
  };
77
95
 
78
- this._originDot = new Dot3D(scene, cfg.origin, this._container, {
79
- fillColor: this._color,
80
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
81
- onMouseOver,
82
- onMouseLeave,
83
- onMouseWheel,
84
- onMouseDown,
85
- onMouseUp,
86
- onMouseMove,
87
- onContextMenu
88
- });
89
- this._cornerDot = new Dot3D(scene, cfg.corner, this._container, {
90
- fillColor: this._color,
91
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
92
- onMouseOver,
93
- onMouseLeave,
94
- onMouseWheel,
95
- onMouseDown,
96
- onMouseUp,
97
- onMouseMove,
98
- onContextMenu
99
- });
100
- this._targetDot = new Dot3D(scene, cfg.target, this._container, {
101
- fillColor: this._color,
102
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
103
- onMouseOver,
104
- onMouseLeave,
105
- onMouseWheel,
106
- onMouseDown,
107
- onMouseUp,
108
- onMouseMove,
109
- onContextMenu
110
- });
111
-
112
- this._originWire = new Wire(this._container, {
113
- color: this._color || "blue",
114
- thickness: 1,
115
- zIndex: plugin.zIndex,
116
- onMouseOver,
117
- onMouseLeave,
118
- onMouseWheel,
119
- onMouseDown,
120
- onMouseUp,
121
- onMouseMove,
122
- onContextMenu
123
- });
124
- this._targetWire = new Wire(this._container, {
125
- color: this._color || "red",
126
- thickness: 1,
127
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
128
- onMouseOver,
129
- onMouseLeave,
130
- onMouseWheel,
131
- onMouseDown,
132
- onMouseUp,
133
- onMouseMove,
134
- onContextMenu
135
- });
136
-
137
- this._angleLabel = new Label(this._container, {
138
- fillColor: this._color || "#00BBFF",
139
- prefix: "",
140
- text: "",
141
- zIndex: plugin.zIndex + 2,
142
- onMouseOver,
143
- onMouseLeave,
144
- onMouseWheel,
145
- onMouseDown,
146
- onMouseUp,
147
- onMouseMove,
148
- onContextMenu
149
- });
150
-
151
- this._wpDirty = false;
152
- this._vpDirty = false;
153
- this._cpDirty = false;
154
-
155
- this._visible = false;
156
- this._originVisible = false;
157
- this._cornerVisible = false;
158
- this._targetVisible = false;
159
-
160
- this._originWireVisible = false;
161
- this._targetWireVisible = false;
162
-
163
- this._angleVisible = false;
164
- this._labelsVisible = false;
165
- this._clickable = false;
166
-
167
- this._originDot.on("worldPos", (value) => {
168
- this._originWorld.set(value || [0, 0, 0]);
169
- this._wpDirty = true;
170
- this._needUpdate(0); // No lag
171
- });
172
-
173
- this._cornerDot.on("worldPos", (value) => {
174
- this._cornerWorld.set(value || [0, 0, 0]);
175
- this._wpDirty = true;
176
- this._needUpdate(0); // No lag
177
- });
178
-
179
- this._targetDot.on("worldPos", (value) => {
180
- this._targetWorld.set(value || [0, 0, 0]);
181
- this._wpDirty = true;
182
- this._needUpdate(0); // No lag
183
- });
184
-
185
- this._onViewMatrix = scene.camera.on("viewMatrix", () => {
186
- this._vpDirty = true;
187
- this._needUpdate(0); // No lag
188
- });
189
-
190
- this._onProjMatrix = scene.camera.on("projMatrix", () => {
191
- this._cpDirty = true;
192
- this._needUpdate();
193
- });
194
-
195
- this._onCanvasBoundary = scene.canvas.on("boundary", () => {
196
- this._cpDirty = true;
197
- this._needUpdate(0); // No lag
198
- });
199
-
200
- this._onSectionPlaneUpdated = scene.on("sectionPlaneUpdated", () => {
201
- this._sectionPlanesDirty = true;
202
- this._needUpdate();
203
- });
204
-
205
- this.approximate = cfg.approximate;
206
- this.visible = cfg.visible;
207
-
208
- this.originVisible = cfg.originVisible;
209
- this.cornerVisible = cfg.cornerVisible;
210
- this.targetVisible = cfg.targetVisible;
211
-
212
- this.originWireVisible = cfg.originWireVisible;
213
- this.targetWireVisible = cfg.targetWireVisible;
96
+ const makeWire = (color, thickness, visibilityChannels) => {
97
+ const wire = new Wire3D(scene, container, {
98
+ color: color,
99
+ thickness: thickness,
100
+ thicknessClickable: 6,
101
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
102
+ onMouseOver,
103
+ onMouseLeave,
104
+ onMouseWheel,
105
+ onMouseDown,
106
+ onMouseUp,
107
+ onMouseMove,
108
+ onContextMenu
109
+ });
110
+ registerDrawable(wire, visibilityChannels);
111
+ return {
112
+ setEnds: (p0, p1) => wire.setEnds(p0, p1),
113
+ setColor: value => wire.setColor(value)
114
+ };
115
+ };
116
+ this._originWire = makeWire(this._color || "blue", 1, [ this._visible, this._originWireVisible ]);
117
+ this._targetWire = makeWire(this._color || "red", 1, [ this._visible, this._targetWireVisible ]);
118
+
119
+ const makeLabel = (color, zIndexOffset, visibilityChannels) => {
120
+ const label = new Label3D(scene, container, {
121
+ fillColor: color,
122
+ zIndex: plugin.zIndex + zIndexOffset,
123
+ onMouseOver,
124
+ onMouseLeave,
125
+ onMouseWheel,
126
+ onMouseDown,
127
+ onMouseUp,
128
+ onMouseMove,
129
+ onContextMenu
130
+ });
131
+ registerDrawable(label, visibilityChannels);
132
+ return {
133
+ setFillColor: value => label.setFillColor(value),
134
+ setPosOnWire: (p0, p1, offset) => label.setPosOnWire(p0, p1, offset),
135
+ setPosBetween: (p0, p1, p2) => label.setPosBetween(p0, p1, p2),
136
+ setText: str => label.setText(str)
137
+ };
138
+ };
139
+ this._angleLabel = makeLabel(this._color || "#00BBFF", 2, [ this._visible, this._angleVisible, this._labelsVisible ]);
140
+
141
+ const makeDot = (cfg, visibilityChannels) => {
142
+ const dot = new Dot3D(scene, cfg, container, {
143
+ fillColor: this._color,
144
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
145
+ onMouseOver,
146
+ onMouseLeave,
147
+ onMouseWheel,
148
+ onMouseDown,
149
+ onMouseUp,
150
+ onMouseMove,
151
+ onContextMenu
152
+ });
153
+ dot.on("worldPos", () => this._update());
154
+ registerDrawable(dot, visibilityChannels);
155
+ return dot;
156
+ };
157
+ this._originDot = makeDot(cfg.origin, [ this._visible, this._originVisible ]);
158
+ this._cornerDot = makeDot(cfg.corner, [ this._visible, this._cornerVisible ]);
159
+ this._targetDot = makeDot(cfg.target, [ this._visible, this._targetVisible ]);
214
160
 
215
- this.angleVisible = cfg.angleVisible;
216
- this.labelsVisible = cfg.labelsVisible;
161
+ this._update();
217
162
  }
218
163
 
219
164
  _update() {
220
-
221
- if (!this._visible) {
165
+ if (! this._targetDot) {
222
166
  return;
223
167
  }
224
168
 
225
- const scene = this.plugin.viewer.scene;
226
-
227
- if (this._wpDirty) {
228
-
229
- this._wp[0] = this._originWorld[0];
230
- this._wp[1] = this._originWorld[1];
231
- this._wp[2] = this._originWorld[2];
232
- this._wp[3] = 1.0;
233
-
234
- this._wp[4] = this._cornerWorld[0];
235
- this._wp[5] = this._cornerWorld[1];
236
- this._wp[6] = this._cornerWorld[2];
237
- this._wp[7] = 1.0;
238
-
239
- this._wp[8] = this._targetWorld[0];
240
- this._wp[9] = this._targetWorld[1];
241
- this._wp[10] = this._targetWorld[2];
242
- this._wp[11] = 1.0;
243
-
244
- this._wpDirty = false;
245
- this._vpDirty = true;
246
- }
247
-
248
- if (this._vpDirty) {
249
-
250
- math.transformPositions4(scene.camera.viewMatrix, this._wp, this._vp);
251
-
252
- this._vp[3] = 1.0;
253
- this._vp[7] = 1.0;
254
- this._vp[11] = 1.0;
255
-
256
- this._vpDirty = false;
257
- this._cpDirty = true;
258
- }
259
-
260
- if (this._sectionPlanesDirty) {
261
-
262
- if (this._isSliced(this._wp)) {
263
- this._angleLabel.setCulled(true);
264
- this._originWire.setCulled(true);
265
- this._targetWire.setCulled(true);
266
- this._originDot.setCulled(true);
267
- this._cornerDot.setCulled(true);
268
- this._targetDot.setCulled(true);
269
- return;
270
- } else {
271
- this._angleLabel.setCulled(false);
272
- this._originWire.setCulled(false);
273
- this._targetWire.setCulled(false);
274
- this._originDot.setCulled(false);
275
- this._cornerDot.setCulled(false);
276
- this._targetDot.setCulled(false);
277
- }
278
-
279
- this._sectionPlanesDirty = true;
280
- }
281
-
282
- if (this._cpDirty) {
283
-
284
- const near = -0.3;
285
- const zOrigin = this._originDot.viewPos[2];
286
- const zCorner = this._cornerDot.viewPos[2];
287
- const zTarget = this._targetDot.viewPos[2];
288
-
289
- if (zOrigin > near || zCorner > near || zTarget > near) {
290
-
291
- this._originDot.setVisible(false);
292
- this._cornerDot.setVisible(false);
293
- this._targetDot.setVisible(false);
294
-
295
- this._originWire.setVisible(false);
296
- this._targetWire.setVisible(false);
297
-
298
- this._angleLabel.setCulled(true);
299
-
300
- return;
301
- }
302
-
303
- math.transformPositions4(scene.camera.project.matrix, this._vp, this._pp);
304
-
305
- var pp = this._pp;
306
- var cp = this._cp;
307
-
308
- var canvas = scene.canvas.canvas;
309
- var offsets = canvas.getBoundingClientRect();
310
- const containerOffsets = this._container.getBoundingClientRect();
311
- var top = offsets.top - containerOffsets.top;
312
- var left = offsets.left - containerOffsets.left;
313
- var aabb = scene.canvas.boundary;
314
- var canvasWidth = aabb[2];
315
- var canvasHeight = aabb[3];
316
- var j = 0;
317
-
318
- for (var i = 0, len = pp.length; i < len; i += 4) {
319
- cp[j] = left + Math.floor((1 + pp[i + 0] / pp[i + 3]) * canvasWidth / 2);
320
- cp[j + 1] = top + Math.floor((1 - pp[i + 1] / pp[i + 3]) * canvasHeight / 2);
321
- j += 2;
322
- }
323
-
324
- this._originWire.setStartAndEnd(cp[0], cp[1], cp[2], cp[3]);
325
- this._targetWire.setStartAndEnd(cp[2], cp[3], cp[4], cp[5]);
326
-
327
- this._angleLabel.setPosBetweenWires(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]);
328
-
329
- math.subVec3(this._originWorld, this._cornerWorld, originVec);
330
- math.subVec3(this._targetWorld, this._cornerWorld, targetVec);
331
-
332
- var validVecs =
333
- (originVec[0] !== 0 || originVec[1] !== 0 || originVec[2] !== 0) &&
334
- (targetVec[0] !== 0 || targetVec[1] !== 0 || targetVec[2] !== 0);
335
-
336
- if (validVecs) {
337
-
338
- const tilde = this._approximate ? " ~ " : " = ";
339
-
340
- math.normalizeVec3(originVec);
341
- math.normalizeVec3(targetVec);
342
- const angle = Math.abs(math.angleVec3(originVec, targetVec));
343
- this._angle = angle / math.DEGTORAD;
344
- this._angleLabel.setText(tilde + this._angle.toFixed(2) + "°");
345
- } else {
346
- this._angleLabel.setText("");
347
- }
348
-
349
- // this._angleLabel.setText((Math.abs(math.lenVec3(math.subVec3(this._targetWorld, this._originWorld, distVec3)) * scale).toFixed(2)) + unitAbbrev);
350
-
351
- this._originDot.setVisible(this._visible && this._originVisible);
352
- this._cornerDot.setVisible(this._visible && this._cornerVisible);
353
- this._targetDot.setVisible(this._visible && this._targetVisible);
354
-
355
- this._originWire.setVisible(this._visible && this._originWireVisible);
356
- this._targetWire.setVisible(this._visible && this._targetWireVisible);
357
-
358
- this._angleLabel.setCulled(!(this._visible && this._angleVisible && this.labelsVisible));
359
-
360
- this._cpDirty = false;
361
- }
362
- }
363
-
364
- _isSliced(positions) {
365
- const sectionPlanes = this.scene._sectionPlanesState.sectionPlanes;
366
- for (let i = 0, len = sectionPlanes.length; i < len; i++) {
367
- const sectionPlane = sectionPlanes[i];
368
- if (math.planeClipsPositions3(sectionPlane.pos, sectionPlane.dir, positions, 4)) {
369
- return true
370
- }
169
+ const p0 = this._originDot.worldPos;
170
+ const p1 = this._cornerDot.worldPos;
171
+ const p2 = this._targetDot.worldPos;
172
+
173
+ this._originWire.setEnds(p0, p1);
174
+ this._targetWire.setEnds(p1, p2);
175
+ this._angleLabel.setPosBetween(p0, p1, p2);
176
+
177
+ math.subVec3(p0, p1, tmpVec3a);
178
+ math.subVec3(p2, p1, tmpVec3b);
179
+
180
+ if ((math.lenVec3(tmpVec3a) > 0) && (math.lenVec3(tmpVec3b) > 0)) {
181
+ math.normalizeVec3(tmpVec3a);
182
+ math.normalizeVec3(tmpVec3b);
183
+ this._angle = Math.abs(math.angleVec3(tmpVec3a, tmpVec3b)) * math.RADTODEG;
184
+ this._angleLabel.setText((this._approximate ? " ~ " : " = ") + this._angle.toFixed(2) + "°");
185
+ } else {
186
+ this._angle = undefined;
187
+ this._angleLabel.setText("");
371
188
  }
372
- return false;
373
189
  }
374
190
 
375
191
  /**
@@ -385,8 +201,7 @@ class AngleMeasurement extends Component {
385
201
  return;
386
202
  }
387
203
  this._approximate = approximate;
388
- this._cpDirty = true;
389
- this._needUpdate(0);
204
+ this._update();
390
205
  }
391
206
 
392
207
  /**
@@ -434,7 +249,6 @@ class AngleMeasurement extends Component {
434
249
  * @type {Number}
435
250
  */
436
251
  get angle() {
437
- this._update();
438
252
  return this._angle;
439
253
  }
440
254
 
@@ -456,14 +270,13 @@ class AngleMeasurement extends Component {
456
270
  * @type {String}
457
271
  */
458
272
  set color(value) {
273
+ this._color = value;
459
274
  this._originDot.setFillColor(value);
460
275
  this._cornerDot.setFillColor(value);
461
276
  this._targetDot.setFillColor(value);
462
277
  this._originWire.setColor(value || "blue");
463
278
  this._targetWire.setColor(value || "red");
464
279
  this._angleLabel.setFillColor(value || "#00BBFF");
465
-
466
- this._color = value;
467
280
  }
468
281
 
469
282
  /**
@@ -472,16 +285,7 @@ class AngleMeasurement extends Component {
472
285
  * @type {Boolean}
473
286
  */
474
287
  set visible(value) {
475
- value = value !== false;
476
- this._visible = value;
477
- this._originDot.setVisible(this._visible && this._originVisible);
478
- this._cornerDot.setVisible(this._visible && this._cornerVisible);
479
- this._targetDot.setVisible(this._visible && this._targetVisible);
480
- this._originWire.setVisible(this._visible && this._originWireVisible);
481
- this._targetWire.setVisible(this._visible && this._targetWireVisible);
482
- this._angleLabel.setVisible(this._visible && this._angleVisible);
483
- this._cpDirty = true;
484
- this._needUpdate();
288
+ this._visible.set(value);
485
289
  }
486
290
 
487
291
  /**
@@ -490,7 +294,7 @@ class AngleMeasurement extends Component {
490
294
  * @type {Boolean}
491
295
  */
492
296
  get visible() {
493
- return this._visible;
297
+ return this._visible.get();
494
298
  }
495
299
 
496
300
  /**
@@ -499,11 +303,7 @@ class AngleMeasurement extends Component {
499
303
  * @type {Boolean}
500
304
  */
501
305
  set originVisible(value) {
502
- value = value !== false;
503
- this._originVisible = value;
504
- this._originDot.setVisible(this._visible && this._originVisible);
505
- this._cpDirty = true;
506
- this._needUpdate();
306
+ this._originVisible.set(value);
507
307
  }
508
308
 
509
309
  /**
@@ -512,7 +312,7 @@ class AngleMeasurement extends Component {
512
312
  * @type {Boolean}
513
313
  */
514
314
  get originVisible() {
515
- return this._originVisible;
315
+ return this._originVisible.get();
516
316
  }
517
317
 
518
318
  /**
@@ -521,11 +321,7 @@ class AngleMeasurement extends Component {
521
321
  * @type {Boolean}
522
322
  */
523
323
  set cornerVisible(value) {
524
- value = value !== false;
525
- this._cornerVisible = value;
526
- this._cornerDot.setVisible(this._visible && this._cornerVisible);
527
- this._cpDirty = true;
528
- this._needUpdate();
324
+ this._cornerVisible.set(value);
529
325
  }
530
326
 
531
327
  /**
@@ -534,7 +330,7 @@ class AngleMeasurement extends Component {
534
330
  * @type {Boolean}
535
331
  */
536
332
  get cornerVisible() {
537
- return this._cornerVisible;
333
+ return this._cornerVisible.get();
538
334
  }
539
335
 
540
336
  /**
@@ -543,11 +339,7 @@ class AngleMeasurement extends Component {
543
339
  * @type {Boolean}
544
340
  */
545
341
  set targetVisible(value) {
546
- value = value !== false;
547
- this._targetVisible = value;
548
- this._targetDot.setVisible(this._visible && this._targetVisible);
549
- this._cpDirty = true;
550
- this._needUpdate();
342
+ this._targetVisible.set(value);
551
343
  }
552
344
 
553
345
  /**
@@ -556,7 +348,7 @@ class AngleMeasurement extends Component {
556
348
  * @type {Boolean}
557
349
  */
558
350
  get targetVisible() {
559
- return this._targetVisible;
351
+ return this._targetVisible.get();
560
352
  }
561
353
 
562
354
  /**
@@ -565,11 +357,7 @@ class AngleMeasurement extends Component {
565
357
  * @type {Boolean}
566
358
  */
567
359
  set originWireVisible(value) {
568
- value = value !== false;
569
- this._originWireVisible = value;
570
- this._originWire.setVisible(this._visible && this._originWireVisible);
571
- this._cpDirty = true;
572
- this._needUpdate();
360
+ this._originWireVisible.set(value);
573
361
  }
574
362
 
575
363
  /**
@@ -578,7 +366,7 @@ class AngleMeasurement extends Component {
578
366
  * @type {Boolean}
579
367
  */
580
368
  get originWireVisible() {
581
- return this._originWireVisible;
369
+ return this._originWireVisible.get();
582
370
  }
583
371
 
584
372
  /**
@@ -587,11 +375,7 @@ class AngleMeasurement extends Component {
587
375
  * @type {Boolean}
588
376
  */
589
377
  set targetWireVisible(value) {
590
- value = value !== false;
591
- this._targetWireVisible = value;
592
- this._targetWire.setVisible(this._visible && this._targetWireVisible);
593
- this._cpDirty = true;
594
- this._needUpdate();
378
+ this._targetWireVisible.set(value);
595
379
  }
596
380
 
597
381
  /**
@@ -600,7 +384,7 @@ class AngleMeasurement extends Component {
600
384
  * @type {Boolean}
601
385
  */
602
386
  get targetWireVisible() {
603
- return this._targetWireVisible;
387
+ return this._targetWireVisible.get();
604
388
  }
605
389
 
606
390
  /**
@@ -609,11 +393,7 @@ class AngleMeasurement extends Component {
609
393
  * @type {Boolean}
610
394
  */
611
395
  set angleVisible(value) {
612
- value = value !== false;
613
- this._angleVisible = value;
614
- this._angleLabel.setVisible(this._visible && this._angleVisible);
615
- this._cpDirty = true;
616
- this._needUpdate();
396
+ this._angleVisible.set(value);
617
397
  }
618
398
 
619
399
  /**
@@ -622,7 +402,7 @@ class AngleMeasurement extends Component {
622
402
  * @type {Boolean}
623
403
  */
624
404
  get angleVisible() {
625
- return this._angleVisible;
405
+ return this._angleVisible.get();
626
406
  }
627
407
 
628
408
  /**
@@ -631,12 +411,7 @@ class AngleMeasurement extends Component {
631
411
  * @type {Boolean}
632
412
  */
633
413
  set labelsVisible(value) {
634
- value = value !== undefined ? Boolean(value) : this.plugin.defaultLabelsVisible;
635
- this._labelsVisible = value;
636
- var labelsVisible = this._visible && this._labelsVisible;
637
- this._angleLabel.setVisible(labelsVisible);
638
- this._cpDirty = true;
639
- this._needUpdate();
414
+ this._labelsVisible.set(value !== undefined ? Boolean(value) : this.plugin.defaultLabelsVisible);
640
415
  }
641
416
 
642
417
  /**
@@ -645,7 +420,7 @@ class AngleMeasurement extends Component {
645
420
  * @type {Boolean}
646
421
  */
647
422
  get labelsVisible() {
648
- return this._labelsVisible;
423
+ return this._labelsVisible.get();
649
424
  }
650
425
 
651
426
  /**
@@ -653,12 +428,7 @@ class AngleMeasurement extends Component {
653
428
  * @param highlighted
654
429
  */
655
430
  setHighlighted(highlighted) {
656
- this._originDot.setHighlighted(highlighted);
657
- this._cornerDot.setHighlighted(highlighted);
658
- this._targetDot.setHighlighted(highlighted);
659
- this._originWire.setHighlighted(highlighted);
660
- this._targetWire.setHighlighted(highlighted);
661
- this._angleLabel.setHighlighted(highlighted);
431
+ this._drawables.forEach(d => d.setHighlighted(highlighted));
662
432
  }
663
433
 
664
434
  /**
@@ -667,14 +437,8 @@ class AngleMeasurement extends Component {
667
437
  * @type {Boolean}
668
438
  */
669
439
  set clickable(value) {
670
- value = !!value;
671
- this._clickable = value;
672
- this._originDot.setClickable(this._clickable);
673
- this._cornerDot.setClickable(this._clickable);
674
- this._targetDot.setClickable(this._clickable);
675
- this._originWire.setClickable(this._clickable);
676
- this._targetWire.setClickable(this._clickable);
677
- this._angleLabel.setClickable(this._clickable);
440
+ this._clickable.set(!!value);
441
+ this._drawables.forEach(d => d.setClickable(this._clickable.get()));
678
442
  }
679
443
 
680
444
  /**
@@ -683,38 +447,14 @@ class AngleMeasurement extends Component {
683
447
  * @type {Boolean}
684
448
  */
685
449
  get clickable() {
686
- return this._clickable;
450
+ return this._clickable.get();
687
451
  }
688
452
 
689
453
  /**
690
454
  * @private
691
455
  */
692
456
  destroy() {
693
-
694
- const scene = this.plugin.viewer.scene;
695
-
696
- if (this._onViewMatrix) {
697
- scene.camera.off(this._onViewMatrix);
698
- }
699
- if (this._onProjMatrix) {
700
- scene.camera.off(this._onProjMatrix);
701
- }
702
- if (this._onCanvasBoundary) {
703
- scene.canvas.off(this._onCanvasBoundary);
704
- }
705
- if (this._onSectionPlaneUpdated) {
706
- scene.off(this._onSectionPlaneUpdated);
707
- }
708
-
709
- this._originDot.destroy();
710
- this._cornerDot.destroy();
711
- this._targetDot.destroy();
712
-
713
- this._originWire.destroy();
714
- this._targetWire.destroy();
715
-
716
- this._angleLabel.destroy();
717
-
457
+ this._cleanups.forEach(cleanup => cleanup());
718
458
  super.destroy();
719
459
  }
720
460
  }