@soonspacejs/plugin-measuring 2.14.12 → 2.14.13

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 (2) hide show
  1. package/dist/index.esm.js +102 -102
  2. package/package.json +3 -3
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
- import P from "soonspacejs";
2
- import { LineBasicMaterial as x, DoubleSide as L, MeshBasicMaterial as C, SpriteMaterial as I, Sprite as B, BufferGeometry as y, Line as M, Mesh as D, Vector3 as h, QuadraticBezierCurve3 as H } from "three";
1
+ import w from "soonspacejs";
2
+ import { LineBasicMaterial as x, DoubleSide as L, MeshBasicMaterial as C, SpriteMaterial as I, Sprite as B, BufferGeometry as m, Line as M, Mesh as D, Vector3 as p, QuadraticBezierCurve3 as H } from "three";
3
3
  function F() {
4
4
  const a = document.createElement("div");
5
5
  return a.setAttribute("style", "height: 1in; visibility: hidden; position: absolute; margin: 0; padding: 0;"), document.body.appendChild(a), 0.0254 / a.clientHeight;
@@ -11,21 +11,21 @@ const E = {
11
11
  ft: 0.3048,
12
12
  in: 0.0254,
13
13
  pt: F()
14
- }, w = (a) => a === 2 ? "²" : a === 3 ? "³" : "", A = (a, e = 1) => a + w(e), k = (a, e, t, s = 1) => (t == null && (t = e), t === e ? {
14
+ }, P = (a) => a === 2 ? "²" : a === 3 ? "³" : "", y = (a, t = 1) => a + P(t), k = (a, t, e, s = 1) => (e == null && (e = t), e === t ? {
15
15
  value: a,
16
- unit: A(t)
16
+ unit: y(e)
17
17
  } : {
18
- value: a * Math.pow(E[e] / E[t], s),
19
- unit: A(t) + w(s)
20
- }), b = (a, e) => a.toFixed(e), N = "data:image/webp;base64,UklGRkQKAABXRUJQVlA4TDcKAAAvf8AfEPXYu/7fldLqffq1m957773PvGmmnNn7tr+2a7MtsCLfFPA64lEOkVxiOQ79un+LMKYHxiu6FhmcEJyAXUgcQq4jcXAlSbJp7X9NN59t27bfud8MI0mKqigsj0cFBaGV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Zw9eg0054+Wvhm+/X+A0aLIBTEB9lBZdAeDADTwUqwHRzY9tVX234Pl06eGq62xt8Z3YIgEAYiZ/L5mWLPYfOv3AA=";
18
+ value: a * Math.pow(E[t] / E[e], s),
19
+ unit: y(e) + P(s)
20
+ }), u = (a, t) => a.toFixed(t), N = "data:image/webp;base64,UklGRkQKAABXRUJQVlA4TDcKAAAvf8AfEPXYu/7fldLqffq1m957773PvGmmnNn7tr+2a7MtsCLfFPA64lEOkVxiOQ79un+LMKYHxiu6FhmcEJyAXUgcQq4jcXAlSbJp7X9NN59t27bfud8MI0mKqigsj0cFBaGVAwYAASBWtm3btm3b5m3btm3btm3brk2A+ScuCAShIBJEB7FB3NqgL36nHRABkoL8oA7oCUaDhWAzOABOgvPgUvvNr37/bPXcpQGQ/8KcHkAMkBO0ABPBHnAHfAR/gLQ7tn/75+7o+7ziQGJQDYwFx8Eb8J8kItb4rYmIIidEgrW2znmKi6LICcm+o+DYvlu9yhoElcBUcA38JOkitzbBhvS2pfC5qzbd3349MuiemDZPL27PrS7Pby8vbC87Fn5aLDwy6Hr2HpZVFzmSK20f2UEVgQygHzgBvpOIiNy65LalsNzXej0xaV7cnV6/Ve+8s/d/SeIfEnFIxiFFW6l+tufSzLDMuggR5Oh88U/FgCCQdzd4SHJN9JMNme3u2jDzyrF655V98A/JcAi9TYSQtvWhHzt1cKaHUgDI/btPHFZHCeQBM8ArUgrrk9td1enJefP6taj60MZZtKGvDi19Vy8Ief3wfEkRIC0YA16QTjbllod73cH3v8H7OIDeNw7+9os4cmD0rAryoAu4CVC4pbDMvPko4mR8iAPbFl+cESKCPAS65HMOFAHbwF9AZHNheWLavP3MrI8D7W210CXC5S/LuQWig/4DpNuQ2R4ddm89MmvjwFu7dIAO4MB+n0MgM1gH/lFW720Or16q2MY5aWNfXhWeGf8oZ0B1cI10m3OfZ5a3RjIc4pz1jZkrjmyr5AYIA73AOwoSlPfYOKftnvK88Op3PTmQ3wd+0a1PbY9Puve+iY9z3NcmS47T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IFNmYXR7ovl46nN77JN4Hwfvwi8u/i5C3Puw2ijy5cpyUaF1yu6PymXztXNRsMg42Gza0taXJidlIyOMrJ41CT4Lh4HYf6aTrzsr02Kh7aX+qfvALPvQ2PetDv1Cdait3iSP7Ll04aRR7DnQB+8FngHRubZL6PY2h7fn1ZalaG4t92KSPx2rVpW/bLtfPOEfy649Bl3NGwTOgJBh9E3wDSInWRD8kWJ/a6hP3NoeHeo+2J2fN08vm2dXt0KHxyQNtc+WJemm+EAnJ2Zvnjs0YVYO4oCwYDPaB5x0kKS6KIickKS6KIick2THVf+2LmlE7iAIygXrbwSZw9eg0054+Wvhm+/X+A0aLIBTEB9lBZdAeDADTwUqwHRzY9tVX234Pl06eGq62xt8Z3YIgEAYiZ/L5mWLPYfOv3AA=";
21
21
  var T = /* @__PURE__ */ ((a) => (a.Distance = "Distance", a.Area = "Area", a.Angle = "Angle", a))(T || {});
22
- const { utils: { randomString: v } } = P;
22
+ const { utils: { randomString: b } } = w;
23
23
  class d {
24
24
  // save the last click time, in order to detect double click event
25
- constructor(e) {
26
- this.ssp = e;
27
- const { viewport: { scene: t, camera: s } } = e;
28
- this.scene = t, this.camera = s;
25
+ constructor(t) {
26
+ this.ssp = t;
27
+ const { viewport: { scene: e, camera: s } } = t;
28
+ this.scene = e, this.camera = s;
29
29
  }
30
30
  // lineWidth is ignored for Chrome on Windows, which is a known issue:
31
31
  // https://github.com/mrdoob/three.js/issues/269
@@ -33,8 +33,8 @@ class d {
33
33
  static MESH_MATERIAL = new C({ color: 8900346, transparent: !0, opacity: 0.8, side: L, depthWrite: !1, depthTest: !1 });
34
34
  static MAX_DISTANCE = 500;
35
35
  // when intersected object's distance is too far away, then ignore it
36
- static OBJ_NAME = "object_for_measure" + v();
37
- static LABEL_NAME = "label_for_measure" + v();
36
+ static OBJ_NAME = "object_for_measure" + b();
37
+ static LABEL_NAME = "label_for_measure" + b();
38
38
  mode = null;
39
39
  options = { unit: "m", precision: 2 };
40
40
  scene;
@@ -70,29 +70,29 @@ class d {
70
70
  /**
71
71
  * Starts the measurement
72
72
  */
73
- start(e = "Distance", t = {}) {
74
- const { unit: s = "m", precision: i = 2 } = t;
75
- this.mode = e, this.options.unit = s, this.options.precision = i, this.ssp.signals.mouseMove.add(this.mousemove), this.ssp.signals.click.add(this.click), this.ssp.signals.dblClick.add(this.dblclick), this.ssp.signals.keyDown.add(this.keydown), this.pointArray = [], this.polyline = this.createLine(), this.scene.add(this.polyline), this.mode === "Area" && (this.faces = this.createFaces(), this.scene.add(this.faces)), this.domElement.style.cursor = "crosshair";
73
+ start(t = "Distance", e = {}) {
74
+ const { unit: s = "m", precision: i = 2 } = e;
75
+ this.mode = t, this.options.unit = s, this.options.precision = i, this.ssp.signals.mouseMove.add(this.mousemove), this.ssp.signals.click.add(this.click), this.ssp.signals.dblClick.add(this.dblclick), this.ssp.signals.keyDown.add(this.keydown), this.pointArray = [], this.polyline = this.createLine(), this.scene.add(this.polyline), this.mode === "Area" && (this.faces = this.createFaces(), this.scene.add(this.faces)), this.domElement.style.cursor = "crosshair";
76
76
  }
77
77
  /**
78
78
  * Ends the measurement
79
79
  */
80
80
  close() {
81
- this.mode !== null && (this.ssp.signals.mouseMove.remove(this.mousemove), this.ssp.signals.click.remove(this.click), this.ssp.signals.dblClick.remove(this.dblclick), this.ssp.signals.keyDown.remove(this.keydown), this.mode = null, this.domElement.style.cursor = "", this.pointArray = [], this.tempPointMarker && this.scene.remove(this.tempPointMarker), this.tempLine && this.scene.remove(this.tempLine), this.tempLabel && this.ssp.removeObject(this.tempLabel), this.pointMarkers.forEach((e) => this.scene.remove(e)), this.polyline && this.scene.remove(this.polyline), this.faces && this.scene.remove(this.faces), this.curve && this.scene.remove(this.curve), this.labels.forEach((e) => this.ssp.removeObject(e)), this.tempPointMarker = void 0, this.tempLine = void 0, this.tempLabel = void 0, this.pointMarkers = [], this.polyline = void 0, this.faces = void 0, this.curve = void 0, this.labels = [], this.ssp.render());
81
+ this.mode !== null && (this.ssp.signals.mouseMove.remove(this.mousemove), this.ssp.signals.click.remove(this.click), this.ssp.signals.dblClick.remove(this.dblclick), this.ssp.signals.keyDown.remove(this.keydown), this.mode = null, this.domElement.style.cursor = "", this.pointArray = [], this.tempPointMarker && this.scene.remove(this.tempPointMarker), this.tempLine && this.scene.remove(this.tempLine), this.tempLabel && this.ssp.removeObject(this.tempLabel), this.pointMarkers.forEach((t) => this.scene.remove(t)), this.polyline && this.scene.remove(this.polyline), this.faces && this.scene.remove(this.faces), this.curve && this.scene.remove(this.curve), this.labels.forEach((t) => this.ssp.removeObject(t)), this.tempPointMarker = void 0, this.tempLine = void 0, this.tempLabel = void 0, this.pointMarkers = [], this.polyline = void 0, this.faces = void 0, this.curve = void 0, this.labels = [], this.ssp.render());
82
82
  }
83
83
  cancel() {
84
84
  this.close(), this.onCancel();
85
85
  }
86
86
  clear() {
87
- this.objectsStore.forEach((e) => this.ssp.removeObject(e)), this.objectsStore.clear();
87
+ this.objectsStore.forEach((t) => this.ssp.removeObject(t)), this.objectsStore.clear();
88
88
  }
89
89
  /**
90
90
  * Initializes point marker material
91
91
  */
92
92
  initPointMarkerMaterial() {
93
- const e = P.utils.textureLoader.load(N);
93
+ const t = w.utils.textureLoader.load(N);
94
94
  this.spriteMaterial = new I({
95
- map: e,
95
+ map: t,
96
96
  depthTest: !1,
97
97
  depthWrite: !1,
98
98
  sizeAttenuation: !1,
@@ -102,128 +102,128 @@ class d {
102
102
  /**
103
103
  * Creates point marker
104
104
  */
105
- createPointMarker(e) {
105
+ createPointMarker(t) {
106
106
  this.spriteMaterial || this.initPointMarkerMaterial();
107
- const t = 0.012, s = new B(this.spriteMaterial);
108
- return s.scale.set(t, t, t), e && s.position.copy(e), s.name = d.OBJ_NAME, s;
107
+ const e = 0.012, s = new B(this.spriteMaterial);
108
+ return s.scale.set(e, e, e), t && s.position.copy(t), s.name = d.OBJ_NAME, s;
109
109
  }
110
110
  /**
111
111
  * Creates Line
112
112
  */
113
- createLine(e = d.LINE_MATERIAL) {
114
- const t = new y(), s = new M(t, e);
113
+ createLine(t = d.LINE_MATERIAL) {
114
+ const e = new m(), s = new M(e, t);
115
115
  return s.frustumCulled = !1, s.name = d.OBJ_NAME, s;
116
116
  }
117
117
  /**
118
118
  * Creates Mesh
119
119
  */
120
120
  createFaces() {
121
- const e = new y(), t = new D(e, d.MESH_MATERIAL);
122
- return t.userData.vertices = [], t.frustumCulled = !1, t.name = d.OBJ_NAME, t;
121
+ const t = new m(), e = new D(t, d.MESH_MATERIAL);
122
+ return e.userData.vertices = [], e.frustumCulled = !1, e.name = d.OBJ_NAME, e;
123
123
  }
124
124
  /**
125
125
  * Draw completed
126
126
  */
127
127
  done() {
128
128
  if (this.mode === null) return;
129
- let e = !1;
130
- const t = this.pointArray.length;
129
+ let t = !1;
130
+ const e = this.pointArray.length;
131
131
  if (this.mode === "Area" && this.polyline)
132
- if (t > 2) {
132
+ if (e > 2) {
133
133
  const s = this.pointArray[0];
134
- this.polyline.geometry.setFromPoints([...this.pointArray, s]);
135
- const i = this.calculateArea(this.pointArray), n = `${b(k(i, "m", this.options.unit, 2).value, this.options.precision)} ${this.getUnitString()}`, r = this.getBarycenter(this.pointArray), o = this.createLabel(n);
134
+ this.polyline.geometry.dispose(), this.polyline.geometry = new m().setFromPoints([...this.pointArray, s]);
135
+ const i = this.calculateArea(this.pointArray), n = `${u(k(i, "m", this.options.unit, 2).value, this.options.precision)} ${this.getUnitString()}`, r = this.getBarycenter(this.pointArray), o = this.createLabel(n);
136
136
  o.position.copy(r), o.element && (o.element.innerHTML = n), this.labels.push(o);
137
137
  } else
138
- e = !0;
139
- if (this.mode === "Distance" && t < 2 && (e = !0), this.mode === "Angle" && this.polyline)
140
- if (t >= 3) {
141
- const s = this.pointArray[0], i = this.pointArray[1], n = this.pointArray[2], r = new h(s.x - i.x, s.y - i.y, s.z - i.z).normalize(), o = this.getAngleBisector(s, i, n), c = new h(n.x - i.x, n.y - i.y, n.z - i.z).normalize(), p = this.calculateAngle(s, i, n), m = `${b(p, this.options.precision)} ${this.getUnitString()}`, g = Math.min(s.distanceTo(i), n.distanceTo(i));
142
- let l = g * 0.3, f = i.clone().add(new h(o.x * l, o.y * l, o.z * l));
143
- const u = this.createLabel(m);
144
- u.position.set(f.x, f.y, f.z), u.element.innerHTML = m, this.labels.push(u), l = g * 0.2, f = i.clone().add(new h(o.x * l, o.y * l, o.z * l));
145
- const S = i.clone().add(new h(r.x * l, r.y * l, r.z * l)), z = i.clone().add(new h(c.x * l, c.y * l, c.z * l));
138
+ t = !0;
139
+ if (this.mode === "Distance" && e < 2 && (t = !0), this.mode === "Angle" && this.polyline)
140
+ if (e >= 3) {
141
+ const s = this.pointArray[0], i = this.pointArray[1], n = this.pointArray[2], r = new p(s.x - i.x, s.y - i.y, s.z - i.z).normalize(), o = this.getAngleBisector(s, i, n), c = new p(n.x - i.x, n.y - i.y, n.z - i.z).normalize(), l = this.calculateAngle(s, i, n), v = `${u(l, this.options.precision)} ${this.getUnitString()}`, g = Math.min(s.distanceTo(i), n.distanceTo(i));
142
+ let h = g * 0.3, f = i.clone().add(new p(o.x * h, o.y * h, o.z * h));
143
+ const A = this.createLabel(v);
144
+ A.position.set(f.x, f.y, f.z), A.element.innerHTML = v, this.labels.push(A), h = g * 0.2, f = i.clone().add(new p(o.x * h, o.y * h, o.z * h));
145
+ const S = i.clone().add(new p(r.x * h, r.y * h, r.z * h)), z = i.clone().add(new p(c.x * h, c.y * h, c.z * h));
146
146
  this.curve = this.createCurve(S, f, z), this.scene.add(this.curve);
147
147
  } else
148
- e = !0;
149
- e || (this.pointMarkers.length > 0 && this.pointMarkers.forEach((s) => this.objectsStore.add(s)), this.polyline && this.objectsStore.add(this.polyline), this.faces && this.objectsStore.add(this.faces), this.curve && this.objectsStore.add(this.curve), this.labels.length > 0 && this.labels.forEach((s) => this.objectsStore.add(s)), this.pointMarkers = [], this.polyline = void 0, this.faces = void 0, this.curve = void 0, this.labels = []), this.close(), this.ssp.render(), this.onDone();
148
+ t = !0;
149
+ t || (this.pointMarkers.length > 0 && this.pointMarkers.forEach((s) => this.objectsStore.add(s)), this.polyline && this.objectsStore.add(this.polyline), this.faces && this.objectsStore.add(this.faces), this.curve && this.objectsStore.add(this.curve), this.labels.length > 0 && this.labels.forEach((s) => this.objectsStore.add(s)), this.pointMarkers = [], this.polyline = void 0, this.faces = void 0, this.curve = void 0, this.labels = []), this.close(), this.ssp.render(), this.onDone();
150
150
  }
151
- mousemove = (e) => {
151
+ mousemove = (t) => {
152
152
  if (this.mode === null) return;
153
- const t = this.getClosestIntersection(e);
154
- if (t) {
155
- if (this.tempPointMarker ? this.tempPointMarker.position.set(t.x, t.y, t.z) : (this.tempPointMarker = this.createPointMarker(t), this.scene.add(this.tempPointMarker)), this.pointArray.length > 0) {
156
- const s = this.pointArray[this.pointArray.length - 1], i = this.tempLine || this.createLine(), n = i.geometry, r = this.pointArray[0], o = this.pointArray[this.pointArray.length - 1];
157
- if (this.mode === "Area" ? n.setFromPoints([o, t, r]) : n.setFromPoints([o, t]), this.mode === "Distance") {
158
- const c = s.distanceTo(t), p = `${b(k(c, "m", this.options.unit).value, this.options.precision)} ${this.getUnitString()}`, m = new h((t.x + s.x) / 2, (t.y + s.y) / 2, (t.z + s.z) / 2);
159
- this.addOrUpdateTempLabel(p, m);
153
+ const e = this.getClosestIntersection(t);
154
+ if (e) {
155
+ if (this.tempPointMarker ? this.tempPointMarker.position.set(e.x, e.y, e.z) : (this.tempPointMarker = this.createPointMarker(e), this.scene.add(this.tempPointMarker)), this.pointArray.length > 0) {
156
+ const s = this.pointArray[this.pointArray.length - 1], i = this.tempLine || this.createLine(), n = this.pointArray[0], r = this.pointArray[this.pointArray.length - 1];
157
+ if (this.mode === "Area" ? (i.geometry.dispose(), i.geometry = new m().setFromPoints([r, e, n])) : (i.geometry.dispose(), i.geometry = new m().setFromPoints([r, e])), this.mode === "Distance") {
158
+ const o = s.distanceTo(e), c = `${u(k(o, "m", this.options.unit).value, this.options.precision)} ${this.getUnitString()}`, l = new p((e.x + s.x) / 2, (e.y + s.y) / 2, (e.z + s.z) / 2);
159
+ this.addOrUpdateTempLabel(c, l);
160
160
  }
161
161
  this.tempLine || (this.scene.add(i), this.tempLine = i);
162
162
  }
163
163
  this.ssp.render();
164
164
  }
165
165
  };
166
- dblclick = (e) => {
167
- this.click(e), this.done();
166
+ dblclick = (t) => {
167
+ this.click(t), this.done();
168
168
  };
169
- click = (e) => {
169
+ click = (t) => {
170
170
  if (this.mode === null) return;
171
- const t = this.getClosestIntersection(e);
172
- if (!t) return;
171
+ const e = this.getClosestIntersection(t);
172
+ if (!e) return;
173
173
  const s = Date.now();
174
174
  if (this.lastClickTime && s - this.lastClickTime < 300)
175
175
  return;
176
- this.lastClickTime = s, this.pointArray.push(t);
177
- const i = this.pointArray.length, n = this.createPointMarker(t);
178
- if (this.pointMarkers.push(n), this.scene.add(n), this.polyline && (this.polyline.geometry.setFromPoints(this.pointArray), this.tempLabel && i > 1)) {
176
+ this.lastClickTime = s, this.pointArray.push(e);
177
+ const i = this.pointArray.length, n = this.createPointMarker(e);
178
+ if (this.pointMarkers.push(n), this.scene.add(n), this.polyline && (this.polyline.geometry.dispose(), this.polyline.geometry = new m().setFromPoints(this.pointArray), this.tempLabel && i > 1)) {
179
179
  const r = this.pointArray[i - 2];
180
- this.tempLabel.position.set((r.x + t.x) / 2, (r.y + t.y) / 2, (r.z + t.z) / 2), this.scene.add(this.tempLabel), this.labels.push(this.tempLabel), this.tempLabel = void 0;
180
+ this.tempLabel.position.set((r.x + e.x) / 2, (r.y + e.y) / 2, (r.z + e.z) / 2), this.scene.add(this.tempLabel), this.labels.push(this.tempLabel), this.tempLabel = void 0;
181
181
  }
182
182
  if (this.mode === "Area" && this.faces) {
183
- const r = this.faces.geometry, o = this.faces.userData.vertices;
184
- o.push(t), r.setFromPoints(o);
185
- const c = o.length;
186
- if (c > 2) {
187
- const p = [];
188
- for (let m = 1; m < c - 1; ++m)
189
- p.push(0, m, m + 1);
190
- r.setIndex(p);
183
+ const r = this.faces.userData.vertices;
184
+ r.push(e), this.faces.geometry.dispose(), this.faces.geometry = new m().setFromPoints(r);
185
+ const o = r.length;
186
+ if (o > 2) {
187
+ const c = [];
188
+ for (let l = 1; l < o - 1; ++l)
189
+ c.push(0, l, l + 1);
190
+ this.faces.geometry.setIndex(c);
191
191
  }
192
192
  }
193
193
  this.mode === "Angle" && this.pointArray.length >= 3 && this.done(), this.ssp.render();
194
194
  };
195
- keydown = (e) => {
196
- e.key === "Enter" ? this.done() : e.key === "Escape" && this.cancel();
195
+ keydown = (t) => {
196
+ t.key === "Enter" ? this.done() : t.key === "Escape" && this.cancel();
197
197
  };
198
198
  /**
199
199
  * The the closest intersection
200
200
  * @param e
201
201
  */
202
- getClosestIntersection = (e) => {
202
+ getClosestIntersection = (t) => {
203
203
  if (this.mode === null) return;
204
- let t = this.ssp.viewport.getIntersects(e);
205
- return t && t.length > 0 && (t = t.filter((s) => s.object.name !== d.OBJ_NAME && s.object.visible), t.length > 0 && t[0].distance < d.MAX_DISTANCE) ? t[0].point : null;
204
+ let e = this.ssp.viewport.getIntersects(t);
205
+ return e && e.length > 0 && (e = e.filter((s) => s.object.name !== d.OBJ_NAME && s.object.visible), e.length > 0 && e[0].distance < d.MAX_DISTANCE) ? e[0].point : null;
206
206
  };
207
207
  /**
208
208
  * Adds or update temp label and position
209
209
  */
210
- addOrUpdateTempLabel(e, t) {
211
- this.tempLabel || (this.tempLabel = this.createLabel(e)), this.tempLabel.position.set(t.x, t.y, t.z), this.tempLabel.element.innerHTML = e;
210
+ addOrUpdateTempLabel(t, e) {
211
+ this.tempLabel || (this.tempLabel = this.createLabel(t)), this.tempLabel.position.set(e.x, e.y, e.z), this.tempLabel.element.innerHTML = t;
212
212
  }
213
213
  /**
214
214
  * Creates label
215
215
  */
216
- createLabel(e) {
217
- const t = document.createElement("div");
218
- t.innerHTML = e, t.style.padding = "3px 6px", t.style.color = "#fff", t.style.fontSize = "12px", t.style.position = "absolute", t.style.backgroundColor = "rgba(25, 25, 25, 0.3)", t.style.borderRadius = "12px", t.style.top = "0px", t.style.left = "0px";
219
- const s = this.ssp.createPoiNode({ id: v(), element: t, type: "2D" });
216
+ createLabel(t) {
217
+ const e = document.createElement("div");
218
+ e.innerHTML = t, e.style.padding = "3px 6px", e.style.color = "#fff", e.style.fontSize = "12px", e.style.position = "absolute", e.style.backgroundColor = "rgba(25, 25, 25, 0.3)", e.style.borderRadius = "12px", e.style.top = "0px", e.style.left = "0px";
219
+ const s = this.ssp.createPoiNode({ id: "label_id" + b(), element: e, type: "2D" });
220
220
  return s.name = d.LABEL_NAME, s;
221
221
  }
222
222
  /**
223
223
  * Creates the arc curve to indicate the angle in degree
224
224
  */
225
- createCurve(e, t, s) {
226
- const n = new H(e, t, s).getPoints(4), r = new y().setFromPoints(n), o = new M(r, d.LINE_MATERIAL);
225
+ createCurve(t, e, s) {
226
+ const n = new H(t, e, s).getPoints(4), r = new m().setFromPoints(n), o = new M(r, d.LINE_MATERIAL);
227
227
  return o.name = d.OBJ_NAME, o;
228
228
  }
229
229
  /**
@@ -231,52 +231,52 @@ class d {
231
231
  * TODO: for concave polygon, the value doesn't right, need to fix it
232
232
  * @param points
233
233
  */
234
- calculateArea(e) {
235
- let t = 0;
236
- for (let s = 0, i = 1, n = 2; n < e.length; i++, n++) {
237
- const r = e[s].distanceTo(e[i]), o = e[i].distanceTo(e[n]), c = e[n].distanceTo(e[s]), p = (r + o + c) / 2;
238
- t += Math.sqrt(p * (p - r) * (p - o) * (p - c));
234
+ calculateArea(t) {
235
+ let e = 0;
236
+ for (let s = 0, i = 1, n = 2; n < t.length; i++, n++) {
237
+ const r = t[s].distanceTo(t[i]), o = t[i].distanceTo(t[n]), c = t[n].distanceTo(t[s]), l = (r + o + c) / 2;
238
+ e += Math.sqrt(l * (l - r) * (l - o) * (l - c));
239
239
  }
240
- return t;
240
+ return e;
241
241
  }
242
242
  /**
243
243
  * Gets included angle of two lines in degree
244
244
  */
245
- calculateAngle(e, t, s) {
246
- const i = e, n = t, r = s, o = new h(i.x - n.x, i.y - n.y, i.z - n.z), c = new h(r.x - n.x, r.y - n.y, r.z - n.z);
245
+ calculateAngle(t, e, s) {
246
+ const i = t, n = e, r = s, o = new p(i.x - n.x, i.y - n.y, i.z - n.z), c = new p(r.x - n.x, r.y - n.y, r.z - n.z);
247
247
  return o.angleTo(c) * 180 / Math.PI;
248
248
  }
249
249
  /**
250
250
  * Gets angle bisector of two lines
251
251
  */
252
- getAngleBisector(e, t, s) {
253
- const i = e, n = t, r = s, o = new h(i.x - n.x, i.y - n.y, i.z - n.z).normalize(), c = new h(r.x - n.x, r.y - n.y, r.z - n.z).normalize();
254
- return new h(o.x + c.x, o.y + c.y, o.z + c.z).normalize();
252
+ getAngleBisector(t, e, s) {
253
+ const i = t, n = e, r = s, o = new p(i.x - n.x, i.y - n.y, i.z - n.z).normalize(), c = new p(r.x - n.x, r.y - n.y, r.z - n.z).normalize();
254
+ return new p(o.x + c.x, o.y + c.y, o.z + c.z).normalize();
255
255
  }
256
256
  /**
257
257
  * Get the barycenter of points
258
258
  */
259
- getBarycenter(e) {
260
- const t = e.length;
259
+ getBarycenter(t) {
260
+ const e = t.length;
261
261
  let s = 0, i = 0, n = 0;
262
- return e.forEach((r) => {
262
+ return t.forEach((r) => {
263
263
  s += r.x, i += r.y, n += r.z;
264
- }), new h(s / t, i / t, n / t);
264
+ }), new p(s / e, i / e, n / e);
265
265
  }
266
266
  /**
267
267
  * Gets unit string for distance, area or angle
268
268
  */
269
269
  getUnitString() {
270
- return this.mode === "Distance" ? A(this.options.unit) : this.mode === "Area" ? `${A(this.options.unit, 2)}` : this.mode === "Angle" ? "°" : "";
270
+ return this.mode === "Distance" ? y(this.options.unit) : this.mode === "Area" ? `${y(this.options.unit, 2)}` : this.mode === "Angle" ? "°" : "";
271
271
  }
272
272
  /**
273
273
  * Converts a number to a string with proper fraction digits
274
274
  */
275
- numberToString(e) {
276
- if (e < 1e-4)
277
- return e.toString();
278
- let t = 2;
279
- return e < 0.01 ? t = 4 : e < 0.1 && (t = 3), e.toFixed(t);
275
+ numberToString(t) {
276
+ if (t < 1e-4)
277
+ return t.toString();
278
+ let e = 2;
279
+ return t < 0.01 ? e = 4 : t < 0.1 && (e = 3), t.toFixed(e);
280
280
  }
281
281
  }
282
282
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soonspacejs/plugin-measuring",
3
3
  "pluginName": "MeasuringPlugin",
4
- "version": "2.14.12",
4
+ "version": "2.14.13",
5
5
  "description": "Measuring plugin for SoonSpace.js",
6
6
  "main": "dist/index.esm.js",
7
7
  "module": "dist/index.esm.js",
@@ -13,8 +13,8 @@
13
13
  ],
14
14
  "author": "xunwei",
15
15
  "license": "UNLICENSED",
16
- "gitHead": "041aa109b28647422687bced042730be5770551b",
16
+ "gitHead": "240acccc2a7fc9908f311f166bf0c8aa2e64f49b",
17
17
  "peerDependencies": {
18
- "soonspacejs": "2.14.12"
18
+ "soonspacejs": "2.14.13"
19
19
  }
20
20
  }