@loaders.gl/terrain 3.1.0-beta.3 → 3.1.0

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.
@@ -1,12 +1,20 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.default = void 0;
7
9
 
8
- class Delatin {
9
- constructor(data, width, height = width) {
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var Delatin = function () {
15
+ function Delatin(data, width) {
16
+ var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : width;
17
+ (0, _classCallCheck2.default)(this, Delatin);
10
18
  this.data = data;
11
19
  this.width = width;
12
20
  this.height = height;
@@ -21,436 +29,461 @@ class Delatin {
21
29
  this._pending = [];
22
30
  this._pendingLen = 0;
23
31
  this._rmsSum = 0;
24
- const x1 = width - 1;
25
- const y1 = height - 1;
32
+ var x1 = width - 1;
33
+ var y1 = height - 1;
26
34
 
27
- const p0 = this._addPoint(0, 0);
35
+ var p0 = this._addPoint(0, 0);
28
36
 
29
- const p1 = this._addPoint(x1, 0);
37
+ var p1 = this._addPoint(x1, 0);
30
38
 
31
- const p2 = this._addPoint(0, y1);
39
+ var p2 = this._addPoint(0, y1);
32
40
 
33
- const p3 = this._addPoint(x1, y1);
41
+ var p3 = this._addPoint(x1, y1);
34
42
 
35
- const t0 = this._addTriangle(p3, p0, p2, -1, -1, -1);
43
+ var t0 = this._addTriangle(p3, p0, p2, -1, -1, -1);
36
44
 
37
45
  this._addTriangle(p0, p3, p1, t0, -1, -1);
38
46
 
39
47
  this._flush();
40
48
  }
41
49
 
42
- run(maxError = 1) {
43
- while (this.getMaxError() > maxError) {
44
- this.refine();
45
- }
46
- }
47
-
48
- refine() {
49
- this._step();
50
-
51
- this._flush();
52
- }
53
-
54
- getMaxError() {
55
- return this._errors[0];
56
- }
50
+ (0, _createClass2.default)(Delatin, [{
51
+ key: "run",
52
+ value: function run() {
53
+ var maxError = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
57
54
 
58
- getRMSD() {
59
- return this._rmsSum > 0 ? Math.sqrt(this._rmsSum / (this.width * this.height)) : 0;
60
- }
61
-
62
- heightAt(x, y) {
63
- return this.data[this.width * y + x];
64
- }
65
-
66
- _flush() {
67
- const coords = this.coords;
68
-
69
- for (let i = 0; i < this._pendingLen; i++) {
70
- const t = this._pending[i];
71
- const a = 2 * this.triangles[t * 3 + 0];
72
- const b = 2 * this.triangles[t * 3 + 1];
73
- const c = 2 * this.triangles[t * 3 + 2];
74
-
75
- this._findCandidate(coords[a], coords[a + 1], coords[b], coords[b + 1], coords[c], coords[c + 1], t);
76
- }
77
-
78
- this._pendingLen = 0;
79
- }
80
-
81
- _findCandidate(p0x, p0y, p1x, p1y, p2x, p2y, t) {
82
- const minX = Math.min(p0x, p1x, p2x);
83
- const minY = Math.min(p0y, p1y, p2y);
84
- const maxX = Math.max(p0x, p1x, p2x);
85
- const maxY = Math.max(p0y, p1y, p2y);
86
- let w00 = orient(p1x, p1y, p2x, p2y, minX, minY);
87
- let w01 = orient(p2x, p2y, p0x, p0y, minX, minY);
88
- let w02 = orient(p0x, p0y, p1x, p1y, minX, minY);
89
- const a01 = p1y - p0y;
90
- const b01 = p0x - p1x;
91
- const a12 = p2y - p1y;
92
- const b12 = p1x - p2x;
93
- const a20 = p0y - p2y;
94
- const b20 = p2x - p0x;
95
- const a = orient(p0x, p0y, p1x, p1y, p2x, p2y);
96
- const z0 = this.heightAt(p0x, p0y) / a;
97
- const z1 = this.heightAt(p1x, p1y) / a;
98
- const z2 = this.heightAt(p2x, p2y) / a;
99
- let maxError = 0;
100
- let mx = 0;
101
- let my = 0;
102
- let rms = 0;
103
-
104
- for (let y = minY; y <= maxY; y++) {
105
- let dx = 0;
106
-
107
- if (w00 < 0 && a12 !== 0) {
108
- dx = Math.max(dx, Math.floor(-w00 / a12));
109
- }
110
-
111
- if (w01 < 0 && a20 !== 0) {
112
- dx = Math.max(dx, Math.floor(-w01 / a20));
55
+ while (this.getMaxError() > maxError) {
56
+ this.refine();
113
57
  }
58
+ }
59
+ }, {
60
+ key: "refine",
61
+ value: function refine() {
62
+ this._step();
114
63
 
115
- if (w02 < 0 && a01 !== 0) {
116
- dx = Math.max(dx, Math.floor(-w02 / a01));
64
+ this._flush();
65
+ }
66
+ }, {
67
+ key: "getMaxError",
68
+ value: function getMaxError() {
69
+ return this._errors[0];
70
+ }
71
+ }, {
72
+ key: "getRMSD",
73
+ value: function getRMSD() {
74
+ return this._rmsSum > 0 ? Math.sqrt(this._rmsSum / (this.width * this.height)) : 0;
75
+ }
76
+ }, {
77
+ key: "heightAt",
78
+ value: function heightAt(x, y) {
79
+ return this.data[this.width * y + x];
80
+ }
81
+ }, {
82
+ key: "_flush",
83
+ value: function _flush() {
84
+ var coords = this.coords;
85
+
86
+ for (var i = 0; i < this._pendingLen; i++) {
87
+ var t = this._pending[i];
88
+ var a = 2 * this.triangles[t * 3 + 0];
89
+ var b = 2 * this.triangles[t * 3 + 1];
90
+ var c = 2 * this.triangles[t * 3 + 2];
91
+
92
+ this._findCandidate(coords[a], coords[a + 1], coords[b], coords[b + 1], coords[c], coords[c + 1], t);
117
93
  }
118
94
 
119
- let w0 = w00 + a12 * dx;
120
- let w1 = w01 + a20 * dx;
121
- let w2 = w02 + a01 * dx;
122
- let wasInside = false;
123
-
124
- for (let x = minX + dx; x <= maxX; x++) {
125
- if (w0 >= 0 && w1 >= 0 && w2 >= 0) {
126
- wasInside = true;
127
- const z = z0 * w0 + z1 * w1 + z2 * w2;
128
- const dz = Math.abs(z - this.heightAt(x, y));
129
- rms += dz * dz;
130
-
131
- if (dz > maxError) {
132
- maxError = dz;
133
- mx = x;
134
- my = y;
135
- }
136
- } else if (wasInside) {
137
- break;
95
+ this._pendingLen = 0;
96
+ }
97
+ }, {
98
+ key: "_findCandidate",
99
+ value: function _findCandidate(p0x, p0y, p1x, p1y, p2x, p2y, t) {
100
+ var minX = Math.min(p0x, p1x, p2x);
101
+ var minY = Math.min(p0y, p1y, p2y);
102
+ var maxX = Math.max(p0x, p1x, p2x);
103
+ var maxY = Math.max(p0y, p1y, p2y);
104
+ var w00 = orient(p1x, p1y, p2x, p2y, minX, minY);
105
+ var w01 = orient(p2x, p2y, p0x, p0y, minX, minY);
106
+ var w02 = orient(p0x, p0y, p1x, p1y, minX, minY);
107
+ var a01 = p1y - p0y;
108
+ var b01 = p0x - p1x;
109
+ var a12 = p2y - p1y;
110
+ var b12 = p1x - p2x;
111
+ var a20 = p0y - p2y;
112
+ var b20 = p2x - p0x;
113
+ var a = orient(p0x, p0y, p1x, p1y, p2x, p2y);
114
+ var z0 = this.heightAt(p0x, p0y) / a;
115
+ var z1 = this.heightAt(p1x, p1y) / a;
116
+ var z2 = this.heightAt(p2x, p2y) / a;
117
+ var maxError = 0;
118
+ var mx = 0;
119
+ var my = 0;
120
+ var rms = 0;
121
+
122
+ for (var y = minY; y <= maxY; y++) {
123
+ var dx = 0;
124
+
125
+ if (w00 < 0 && a12 !== 0) {
126
+ dx = Math.max(dx, Math.floor(-w00 / a12));
138
127
  }
139
128
 
140
- w0 += a12;
141
- w1 += a20;
142
- w2 += a01;
143
- }
144
-
145
- w00 += b12;
146
- w01 += b20;
147
- w02 += b01;
148
- }
129
+ if (w01 < 0 && a20 !== 0) {
130
+ dx = Math.max(dx, Math.floor(-w01 / a20));
131
+ }
149
132
 
150
- if (mx === p0x && my === p0y || mx === p1x && my === p1y || mx === p2x && my === p2y) {
151
- maxError = 0;
152
- }
133
+ if (w02 < 0 && a01 !== 0) {
134
+ dx = Math.max(dx, Math.floor(-w02 / a01));
135
+ }
153
136
 
154
- this._candidates[2 * t] = mx;
155
- this._candidates[2 * t + 1] = my;
156
- this._rms[t] = rms;
137
+ var w0 = w00 + a12 * dx;
138
+ var w1 = w01 + a20 * dx;
139
+ var w2 = w02 + a01 * dx;
140
+ var wasInside = false;
141
+
142
+ for (var x = minX + dx; x <= maxX; x++) {
143
+ if (w0 >= 0 && w1 >= 0 && w2 >= 0) {
144
+ wasInside = true;
145
+ var z = z0 * w0 + z1 * w1 + z2 * w2;
146
+ var dz = Math.abs(z - this.heightAt(x, y));
147
+ rms += dz * dz;
148
+
149
+ if (dz > maxError) {
150
+ maxError = dz;
151
+ mx = x;
152
+ my = y;
153
+ }
154
+ } else if (wasInside) {
155
+ break;
156
+ }
157
157
 
158
- this._queuePush(t, maxError, rms);
159
- }
158
+ w0 += a12;
159
+ w1 += a20;
160
+ w2 += a01;
161
+ }
160
162
 
161
- _step() {
162
- const t = this._queuePop();
163
-
164
- const e0 = t * 3 + 0;
165
- const e1 = t * 3 + 1;
166
- const e2 = t * 3 + 2;
167
- const p0 = this.triangles[e0];
168
- const p1 = this.triangles[e1];
169
- const p2 = this.triangles[e2];
170
- const ax = this.coords[2 * p0];
171
- const ay = this.coords[2 * p0 + 1];
172
- const bx = this.coords[2 * p1];
173
- const by = this.coords[2 * p1 + 1];
174
- const cx = this.coords[2 * p2];
175
- const cy = this.coords[2 * p2 + 1];
176
- const px = this._candidates[2 * t];
177
- const py = this._candidates[2 * t + 1];
178
-
179
- const pn = this._addPoint(px, py);
180
-
181
- if (orient(ax, ay, bx, by, px, py) === 0) {
182
- this._handleCollinear(pn, e0);
183
- } else if (orient(bx, by, cx, cy, px, py) === 0) {
184
- this._handleCollinear(pn, e1);
185
- } else if (orient(cx, cy, ax, ay, px, py) === 0) {
186
- this._handleCollinear(pn, e2);
187
- } else {
188
- const h0 = this._halfedges[e0];
189
- const h1 = this._halfedges[e1];
190
- const h2 = this._halfedges[e2];
191
-
192
- const t0 = this._addTriangle(p0, p1, pn, h0, -1, -1, e0);
193
-
194
- const t1 = this._addTriangle(p1, p2, pn, h1, -1, t0 + 1);
195
-
196
- const t2 = this._addTriangle(p2, p0, pn, h2, t0 + 2, t1 + 1);
163
+ w00 += b12;
164
+ w01 += b20;
165
+ w02 += b01;
166
+ }
197
167
 
198
- this._legalize(t0);
168
+ if (mx === p0x && my === p0y || mx === p1x && my === p1y || mx === p2x && my === p2y) {
169
+ maxError = 0;
170
+ }
199
171
 
200
- this._legalize(t1);
172
+ this._candidates[2 * t] = mx;
173
+ this._candidates[2 * t + 1] = my;
174
+ this._rms[t] = rms;
201
175
 
202
- this._legalize(t2);
176
+ this._queuePush(t, maxError, rms);
203
177
  }
204
- }
205
-
206
- _addPoint(x, y) {
207
- const i = this.coords.length >> 1;
208
- this.coords.push(x, y);
209
- return i;
210
- }
178
+ }, {
179
+ key: "_step",
180
+ value: function _step() {
181
+ var t = this._queuePop();
182
+
183
+ var e0 = t * 3 + 0;
184
+ var e1 = t * 3 + 1;
185
+ var e2 = t * 3 + 2;
186
+ var p0 = this.triangles[e0];
187
+ var p1 = this.triangles[e1];
188
+ var p2 = this.triangles[e2];
189
+ var ax = this.coords[2 * p0];
190
+ var ay = this.coords[2 * p0 + 1];
191
+ var bx = this.coords[2 * p1];
192
+ var by = this.coords[2 * p1 + 1];
193
+ var cx = this.coords[2 * p2];
194
+ var cy = this.coords[2 * p2 + 1];
195
+ var px = this._candidates[2 * t];
196
+ var py = this._candidates[2 * t + 1];
197
+
198
+ var pn = this._addPoint(px, py);
199
+
200
+ if (orient(ax, ay, bx, by, px, py) === 0) {
201
+ this._handleCollinear(pn, e0);
202
+ } else if (orient(bx, by, cx, cy, px, py) === 0) {
203
+ this._handleCollinear(pn, e1);
204
+ } else if (orient(cx, cy, ax, ay, px, py) === 0) {
205
+ this._handleCollinear(pn, e2);
206
+ } else {
207
+ var h0 = this._halfedges[e0];
208
+ var h1 = this._halfedges[e1];
209
+ var h2 = this._halfedges[e2];
211
210
 
212
- _addTriangle(a, b, c, ab, bc, ca, e = this.triangles.length) {
213
- const t = e / 3;
214
- this.triangles[e + 0] = a;
215
- this.triangles[e + 1] = b;
216
- this.triangles[e + 2] = c;
217
- this._halfedges[e + 0] = ab;
218
- this._halfedges[e + 1] = bc;
219
- this._halfedges[e + 2] = ca;
220
-
221
- if (ab >= 0) {
222
- this._halfedges[ab] = e + 0;
223
- }
211
+ var t0 = this._addTriangle(p0, p1, pn, h0, -1, -1, e0);
224
212
 
225
- if (bc >= 0) {
226
- this._halfedges[bc] = e + 1;
227
- }
213
+ var t1 = this._addTriangle(p1, p2, pn, h1, -1, t0 + 1);
228
214
 
229
- if (ca >= 0) {
230
- this._halfedges[ca] = e + 2;
231
- }
215
+ var t2 = this._addTriangle(p2, p0, pn, h2, t0 + 2, t1 + 1);
232
216
 
233
- this._candidates[2 * t + 0] = 0;
234
- this._candidates[2 * t + 1] = 0;
235
- this._queueIndices[t] = -1;
236
- this._rms[t] = 0;
237
- this._pending[this._pendingLen++] = t;
238
- return e;
239
- }
217
+ this._legalize(t0);
240
218
 
241
- _legalize(a) {
242
- const b = this._halfedges[a];
219
+ this._legalize(t1);
243
220
 
244
- if (b < 0) {
245
- return;
221
+ this._legalize(t2);
222
+ }
246
223
  }
247
-
248
- const a0 = a - a % 3;
249
- const b0 = b - b % 3;
250
- const al = a0 + (a + 1) % 3;
251
- const ar = a0 + (a + 2) % 3;
252
- const bl = b0 + (b + 2) % 3;
253
- const br = b0 + (b + 1) % 3;
254
- const p0 = this.triangles[ar];
255
- const pr = this.triangles[a];
256
- const pl = this.triangles[al];
257
- const p1 = this.triangles[bl];
258
- const coords = this.coords;
259
-
260
- if (!inCircle(coords[2 * p0], coords[2 * p0 + 1], coords[2 * pr], coords[2 * pr + 1], coords[2 * pl], coords[2 * pl + 1], coords[2 * p1], coords[2 * p1 + 1])) {
261
- return;
224
+ }, {
225
+ key: "_addPoint",
226
+ value: function _addPoint(x, y) {
227
+ var i = this.coords.length >> 1;
228
+ this.coords.push(x, y);
229
+ return i;
262
230
  }
231
+ }, {
232
+ key: "_addTriangle",
233
+ value: function _addTriangle(a, b, c, ab, bc, ca) {
234
+ var e = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : this.triangles.length;
235
+ var t = e / 3;
236
+ this.triangles[e + 0] = a;
237
+ this.triangles[e + 1] = b;
238
+ this.triangles[e + 2] = c;
239
+ this._halfedges[e + 0] = ab;
240
+ this._halfedges[e + 1] = bc;
241
+ this._halfedges[e + 2] = ca;
242
+
243
+ if (ab >= 0) {
244
+ this._halfedges[ab] = e + 0;
245
+ }
263
246
 
264
- const hal = this._halfedges[al];
265
- const har = this._halfedges[ar];
266
- const hbl = this._halfedges[bl];
267
- const hbr = this._halfedges[br];
247
+ if (bc >= 0) {
248
+ this._halfedges[bc] = e + 1;
249
+ }
268
250
 
269
- this._queueRemove(a0 / 3);
251
+ if (ca >= 0) {
252
+ this._halfedges[ca] = e + 2;
253
+ }
270
254
 
271
- this._queueRemove(b0 / 3);
255
+ this._candidates[2 * t + 0] = 0;
256
+ this._candidates[2 * t + 1] = 0;
257
+ this._queueIndices[t] = -1;
258
+ this._rms[t] = 0;
259
+ this._pending[this._pendingLen++] = t;
260
+ return e;
261
+ }
262
+ }, {
263
+ key: "_legalize",
264
+ value: function _legalize(a) {
265
+ var b = this._halfedges[a];
272
266
 
273
- const t0 = this._addTriangle(p0, p1, pl, -1, hbl, hal, a0);
267
+ if (b < 0) {
268
+ return;
269
+ }
274
270
 
275
- const t1 = this._addTriangle(p1, p0, pr, t0, har, hbr, b0);
271
+ var a0 = a - a % 3;
272
+ var b0 = b - b % 3;
273
+ var al = a0 + (a + 1) % 3;
274
+ var ar = a0 + (a + 2) % 3;
275
+ var bl = b0 + (b + 2) % 3;
276
+ var br = b0 + (b + 1) % 3;
277
+ var p0 = this.triangles[ar];
278
+ var pr = this.triangles[a];
279
+ var pl = this.triangles[al];
280
+ var p1 = this.triangles[bl];
281
+ var coords = this.coords;
282
+
283
+ if (!inCircle(coords[2 * p0], coords[2 * p0 + 1], coords[2 * pr], coords[2 * pr + 1], coords[2 * pl], coords[2 * pl + 1], coords[2 * p1], coords[2 * p1 + 1])) {
284
+ return;
285
+ }
276
286
 
277
- this._legalize(t0 + 1);
287
+ var hal = this._halfedges[al];
288
+ var har = this._halfedges[ar];
289
+ var hbl = this._halfedges[bl];
290
+ var hbr = this._halfedges[br];
278
291
 
279
- this._legalize(t1 + 2);
280
- }
292
+ this._queueRemove(a0 / 3);
281
293
 
282
- _handleCollinear(pn, a) {
283
- const a0 = a - a % 3;
284
- const al = a0 + (a + 1) % 3;
285
- const ar = a0 + (a + 2) % 3;
286
- const p0 = this.triangles[ar];
287
- const pr = this.triangles[a];
288
- const pl = this.triangles[al];
289
- const hal = this._halfedges[al];
290
- const har = this._halfedges[ar];
291
- const b = this._halfedges[a];
294
+ this._queueRemove(b0 / 3);
292
295
 
293
- if (b < 0) {
294
- const t0 = this._addTriangle(pn, p0, pr, -1, har, -1, a0);
296
+ var t0 = this._addTriangle(p0, p1, pl, -1, hbl, hal, a0);
295
297
 
296
- const t1 = this._addTriangle(p0, pn, pl, t0, -1, hal);
298
+ var t1 = this._addTriangle(p1, p0, pr, t0, har, hbr, b0);
297
299
 
298
300
  this._legalize(t0 + 1);
299
301
 
300
302
  this._legalize(t1 + 2);
301
-
302
- return;
303
303
  }
304
+ }, {
305
+ key: "_handleCollinear",
306
+ value: function _handleCollinear(pn, a) {
307
+ var a0 = a - a % 3;
308
+ var al = a0 + (a + 1) % 3;
309
+ var ar = a0 + (a + 2) % 3;
310
+ var p0 = this.triangles[ar];
311
+ var pr = this.triangles[a];
312
+ var pl = this.triangles[al];
313
+ var hal = this._halfedges[al];
314
+ var har = this._halfedges[ar];
315
+ var b = this._halfedges[a];
304
316
 
305
- const b0 = b - b % 3;
306
- const bl = b0 + (b + 2) % 3;
307
- const br = b0 + (b + 1) % 3;
308
- const p1 = this.triangles[bl];
309
- const hbl = this._halfedges[bl];
310
- const hbr = this._halfedges[br];
317
+ if (b < 0) {
318
+ var _t = this._addTriangle(pn, p0, pr, -1, har, -1, a0);
311
319
 
312
- this._queueRemove(b0 / 3);
320
+ var _t2 = this._addTriangle(p0, pn, pl, _t, -1, hal);
313
321
 
314
- const t0 = this._addTriangle(p0, pr, pn, har, -1, -1, a0);
322
+ this._legalize(_t + 1);
315
323
 
316
- const t1 = this._addTriangle(pr, p1, pn, hbr, -1, t0 + 1, b0);
324
+ this._legalize(_t2 + 2);
317
325
 
318
- const t2 = this._addTriangle(p1, pl, pn, hbl, -1, t1 + 1);
326
+ return;
327
+ }
319
328
 
320
- const t3 = this._addTriangle(pl, p0, pn, hal, t0 + 2, t2 + 1);
329
+ var b0 = b - b % 3;
330
+ var bl = b0 + (b + 2) % 3;
331
+ var br = b0 + (b + 1) % 3;
332
+ var p1 = this.triangles[bl];
333
+ var hbl = this._halfedges[bl];
334
+ var hbr = this._halfedges[br];
321
335
 
322
- this._legalize(t0);
336
+ this._queueRemove(b0 / 3);
323
337
 
324
- this._legalize(t1);
338
+ var t0 = this._addTriangle(p0, pr, pn, har, -1, -1, a0);
325
339
 
326
- this._legalize(t2);
340
+ var t1 = this._addTriangle(pr, p1, pn, hbr, -1, t0 + 1, b0);
327
341
 
328
- this._legalize(t3);
329
- }
342
+ var t2 = this._addTriangle(p1, pl, pn, hbl, -1, t1 + 1);
330
343
 
331
- _queuePush(t, error, rms) {
332
- const i = this._queue.length;
333
- this._queueIndices[t] = i;
344
+ var t3 = this._addTriangle(pl, p0, pn, hal, t0 + 2, t2 + 1);
334
345
 
335
- this._queue.push(t);
346
+ this._legalize(t0);
336
347
 
337
- this._errors.push(error);
348
+ this._legalize(t1);
338
349
 
339
- this._rmsSum += rms;
350
+ this._legalize(t2);
340
351
 
341
- this._queueUp(i);
342
- }
352
+ this._legalize(t3);
353
+ }
354
+ }, {
355
+ key: "_queuePush",
356
+ value: function _queuePush(t, error, rms) {
357
+ var i = this._queue.length;
358
+ this._queueIndices[t] = i;
343
359
 
344
- _queuePop() {
345
- const n = this._queue.length - 1;
360
+ this._queue.push(t);
346
361
 
347
- this._queueSwap(0, n);
362
+ this._errors.push(error);
348
363
 
349
- this._queueDown(0, n);
364
+ this._rmsSum += rms;
350
365
 
351
- return this._queuePopBack();
352
- }
366
+ this._queueUp(i);
367
+ }
368
+ }, {
369
+ key: "_queuePop",
370
+ value: function _queuePop() {
371
+ var n = this._queue.length - 1;
353
372
 
354
- _queuePopBack() {
355
- const t = this._queue.pop();
373
+ this._queueSwap(0, n);
356
374
 
357
- this._errors.pop();
375
+ this._queueDown(0, n);
358
376
 
359
- this._rmsSum -= this._rms[t];
360
- this._queueIndices[t] = -1;
361
- return t;
362
- }
377
+ return this._queuePopBack();
378
+ }
379
+ }, {
380
+ key: "_queuePopBack",
381
+ value: function _queuePopBack() {
382
+ var t = this._queue.pop();
363
383
 
364
- _queueRemove(t) {
365
- const i = this._queueIndices[t];
384
+ this._errors.pop();
366
385
 
367
- if (i < 0) {
368
- const it = this._pending.indexOf(t);
386
+ this._rmsSum -= this._rms[t];
387
+ this._queueIndices[t] = -1;
388
+ return t;
389
+ }
390
+ }, {
391
+ key: "_queueRemove",
392
+ value: function _queueRemove(t) {
393
+ var i = this._queueIndices[t];
394
+
395
+ if (i < 0) {
396
+ var it = this._pending.indexOf(t);
397
+
398
+ if (it !== -1) {
399
+ this._pending[it] = this._pending[--this._pendingLen];
400
+ } else {
401
+ throw new Error('Broken triangulation (something went wrong).');
402
+ }
369
403
 
370
- if (it !== -1) {
371
- this._pending[it] = this._pending[--this._pendingLen];
372
- } else {
373
- throw new Error('Broken triangulation (something went wrong).');
404
+ return;
374
405
  }
375
406
 
376
- return;
377
- }
378
-
379
- const n = this._queue.length - 1;
407
+ var n = this._queue.length - 1;
380
408
 
381
- if (n !== i) {
382
- this._queueSwap(i, n);
409
+ if (n !== i) {
410
+ this._queueSwap(i, n);
383
411
 
384
- if (!this._queueDown(i, n)) {
385
- this._queueUp(i);
412
+ if (!this._queueDown(i, n)) {
413
+ this._queueUp(i);
414
+ }
386
415
  }
387
- }
388
416
 
389
- this._queuePopBack();
390
- }
417
+ this._queuePopBack();
418
+ }
419
+ }, {
420
+ key: "_queueLess",
421
+ value: function _queueLess(i, j) {
422
+ return this._errors[i] > this._errors[j];
423
+ }
424
+ }, {
425
+ key: "_queueSwap",
426
+ value: function _queueSwap(i, j) {
427
+ var pi = this._queue[i];
428
+ var pj = this._queue[j];
429
+ this._queue[i] = pj;
430
+ this._queue[j] = pi;
431
+ this._queueIndices[pi] = j;
432
+ this._queueIndices[pj] = i;
433
+ var e = this._errors[i];
434
+ this._errors[i] = this._errors[j];
435
+ this._errors[j] = e;
436
+ }
437
+ }, {
438
+ key: "_queueUp",
439
+ value: function _queueUp(j0) {
440
+ var j = j0;
391
441
 
392
- _queueLess(i, j) {
393
- return this._errors[i] > this._errors[j];
394
- }
442
+ while (true) {
443
+ var i = j - 1 >> 1;
395
444
 
396
- _queueSwap(i, j) {
397
- const pi = this._queue[i];
398
- const pj = this._queue[j];
399
- this._queue[i] = pj;
400
- this._queue[j] = pi;
401
- this._queueIndices[pi] = j;
402
- this._queueIndices[pj] = i;
403
- const e = this._errors[i];
404
- this._errors[i] = this._errors[j];
405
- this._errors[j] = e;
406
- }
407
-
408
- _queueUp(j0) {
409
- let j = j0;
445
+ if (i === j || !this._queueLess(j, i)) {
446
+ break;
447
+ }
410
448
 
411
- while (true) {
412
- const i = j - 1 >> 1;
449
+ this._queueSwap(i, j);
413
450
 
414
- if (i === j || !this._queueLess(j, i)) {
415
- break;
451
+ j = i;
416
452
  }
417
-
418
- this._queueSwap(i, j);
419
-
420
- j = i;
421
453
  }
422
- }
454
+ }, {
455
+ key: "_queueDown",
456
+ value: function _queueDown(i0, n) {
457
+ var i = i0;
423
458
 
424
- _queueDown(i0, n) {
425
- let i = i0;
459
+ while (true) {
460
+ var j1 = 2 * i + 1;
426
461
 
427
- while (true) {
428
- const j1 = 2 * i + 1;
462
+ if (j1 >= n || j1 < 0) {
463
+ break;
464
+ }
429
465
 
430
- if (j1 >= n || j1 < 0) {
431
- break;
432
- }
466
+ var j2 = j1 + 1;
467
+ var j = j1;
433
468
 
434
- const j2 = j1 + 1;
435
- let j = j1;
469
+ if (j2 < n && this._queueLess(j2, j1)) {
470
+ j = j2;
471
+ }
436
472
 
437
- if (j2 < n && this._queueLess(j2, j1)) {
438
- j = j2;
439
- }
473
+ if (!this._queueLess(j, i)) {
474
+ break;
475
+ }
440
476
 
441
- if (!this._queueLess(j, i)) {
442
- break;
443
- }
477
+ this._queueSwap(i, j);
444
478
 
445
- this._queueSwap(i, j);
479
+ i = j;
480
+ }
446
481
 
447
- i = j;
482
+ return i > i0;
448
483
  }
449
-
450
- return i > i0;
451
- }
452
-
453
- }
484
+ }]);
485
+ return Delatin;
486
+ }();
454
487
 
455
488
  exports.default = Delatin;
456
489
 
@@ -459,15 +492,15 @@ function orient(ax, ay, bx, by, cx, cy) {
459
492
  }
460
493
 
461
494
  function inCircle(ax, ay, bx, by, cx, cy, px, py) {
462
- const dx = ax - px;
463
- const dy = ay - py;
464
- const ex = bx - px;
465
- const ey = by - py;
466
- const fx = cx - px;
467
- const fy = cy - py;
468
- const ap = dx * dx + dy * dy;
469
- const bp = ex * ex + ey * ey;
470
- const cp = fx * fx + fy * fy;
495
+ var dx = ax - px;
496
+ var dy = ay - py;
497
+ var ex = bx - px;
498
+ var ey = by - py;
499
+ var fx = cx - px;
500
+ var fy = cy - py;
501
+ var ap = dx * dx + dy * dy;
502
+ var bp = ex * ex + ey * ey;
503
+ var cp = fx * fx + fy * fy;
471
504
  return dx * (ey * cp - bp * fy) - dy * (ex * cp - bp * fx) + ap * (ex * fy - ey * fx) < 0;
472
505
  }
473
506
  //# sourceMappingURL=index.js.map