@math.gl/web-mercator 5.0.0-alpha.9 → 5.0.0-beta.10

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 (47) hide show
  1. package/LICENSE +7 -119
  2. package/README.md +5 -0
  3. package/THIRD-PARTY-NOTICES.md +16 -0
  4. package/dist/assert.d.ts.map +1 -1
  5. package/dist/assert.js +3 -0
  6. package/dist/assert.js.map +1 -1
  7. package/dist/fit-bounds.d.ts +1 -1
  8. package/dist/fit-bounds.d.ts.map +1 -1
  9. package/dist/fit-bounds.js +11 -5
  10. package/dist/fit-bounds.js.map +1 -1
  11. package/dist/fly-to-viewport.d.ts.map +1 -1
  12. package/dist/fly-to-viewport.js +4 -1
  13. package/dist/fly-to-viewport.js.map +1 -1
  14. package/dist/get-bounds.d.ts.map +1 -1
  15. package/dist/get-bounds.js +4 -1
  16. package/dist/get-bounds.js.map +1 -1
  17. package/dist/index.cjs +59 -434
  18. package/dist/index.cjs.map +3 -3
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +3 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/math-utils.d.ts.map +1 -1
  23. package/dist/math-utils.js +4 -1
  24. package/dist/math-utils.js.map +1 -1
  25. package/dist/mercator-meters.js +1 -1
  26. package/dist/mercator-meters.js.map +1 -1
  27. package/dist/normalize-viewport-props.d.ts.map +1 -1
  28. package/dist/normalize-viewport-props.js +3 -0
  29. package/dist/normalize-viewport-props.js.map +1 -1
  30. package/dist/web-mercator-utils.d.ts.map +1 -1
  31. package/dist/web-mercator-utils.js +6 -3
  32. package/dist/web-mercator-utils.js.map +1 -1
  33. package/dist/web-mercator-viewport.d.ts +0 -5
  34. package/dist/web-mercator-viewport.d.ts.map +1 -1
  35. package/dist/web-mercator-viewport.js +6 -8
  36. package/dist/web-mercator-viewport.js.map +1 -1
  37. package/package.json +8 -7
  38. package/src/assert.ts +3 -0
  39. package/src/fit-bounds.ts +13 -9
  40. package/src/fly-to-viewport.ts +4 -1
  41. package/src/get-bounds.ts +4 -1
  42. package/src/index.ts +3 -0
  43. package/src/math-utils.ts +4 -1
  44. package/src/mercator-meters.ts +1 -1
  45. package/src/normalize-viewport-props.ts +3 -0
  46. package/src/web-mercator-utils.ts +6 -3
  47. package/src/web-mercator-viewport.ts +6 -10
package/dist/index.cjs CHANGED
@@ -53,37 +53,14 @@ __export(index_exports, {
53
53
  });
54
54
  module.exports = __toCommonJS(index_exports);
55
55
 
56
- // ../core/src/gl-matrix/common.js
57
- var EPSILON = 1e-6;
58
- var degree = Math.PI / 180;
59
-
60
- // ../core/src/gl-matrix/vec4.ts
61
- function scale(out, a, b) {
62
- out[0] = a[0] * b;
63
- out[1] = a[1] * b;
64
- out[2] = a[2] * b;
65
- out[3] = a[3] * b;
66
- return out;
67
- }
68
- function transformMat4(out, a, m) {
69
- const x = a[0];
70
- const y = a[1];
71
- const z = a[2];
72
- const w = a[3];
73
- out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
74
- out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
75
- out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
76
- out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
77
- return out;
78
- }
79
-
80
56
  // dist/math-utils.js
57
+ var import_core = require("@math.gl/core");
81
58
  function createMat4() {
82
59
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
83
60
  }
84
61
  function transformVector(matrix, vector) {
85
- const result = transformMat4([], vector, matrix);
86
- scale(result, result, 1 / result[3]);
62
+ const result = import_core.vec4.transformMat4([], vector, matrix);
63
+ import_core.vec4.scale(result, result, 1 / result[3]);
87
64
  return result;
88
65
  }
89
66
  function mod(value, divisor) {
@@ -101,365 +78,10 @@ function ieLog2(x) {
101
78
  }
102
79
  var log2 = Math.log2 || ieLog2;
103
80
 
104
- // ../core/src/gl-matrix/mat4.ts
105
- function invert(out, a) {
106
- const a00 = a[0];
107
- const a01 = a[1];
108
- const a02 = a[2];
109
- const a03 = a[3];
110
- const a10 = a[4];
111
- const a11 = a[5];
112
- const a12 = a[6];
113
- const a13 = a[7];
114
- const a20 = a[8];
115
- const a21 = a[9];
116
- const a22 = a[10];
117
- const a23 = a[11];
118
- const a30 = a[12];
119
- const a31 = a[13];
120
- const a32 = a[14];
121
- const a33 = a[15];
122
- const b00 = a00 * a11 - a01 * a10;
123
- const b01 = a00 * a12 - a02 * a10;
124
- const b02 = a00 * a13 - a03 * a10;
125
- const b03 = a01 * a12 - a02 * a11;
126
- const b04 = a01 * a13 - a03 * a11;
127
- const b05 = a02 * a13 - a03 * a12;
128
- const b06 = a20 * a31 - a21 * a30;
129
- const b07 = a20 * a32 - a22 * a30;
130
- const b08 = a20 * a33 - a23 * a30;
131
- const b09 = a21 * a32 - a22 * a31;
132
- const b10 = a21 * a33 - a23 * a31;
133
- const b11 = a22 * a33 - a23 * a32;
134
- let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
135
- if (!det) {
136
- return null;
137
- }
138
- det = 1 / det;
139
- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
140
- out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
141
- out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
142
- out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
143
- out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
144
- out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
145
- out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
146
- out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
147
- out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
148
- out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
149
- out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
150
- out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
151
- out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
152
- out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
153
- out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
154
- out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
155
- return out;
156
- }
157
- function multiply(out, a, b) {
158
- const a00 = a[0];
159
- const a01 = a[1];
160
- const a02 = a[2];
161
- const a03 = a[3];
162
- const a10 = a[4];
163
- const a11 = a[5];
164
- const a12 = a[6];
165
- const a13 = a[7];
166
- const a20 = a[8];
167
- const a21 = a[9];
168
- const a22 = a[10];
169
- const a23 = a[11];
170
- const a30 = a[12];
171
- const a31 = a[13];
172
- const a32 = a[14];
173
- const a33 = a[15];
174
- let b0 = b[0];
175
- let b1 = b[1];
176
- let b2 = b[2];
177
- let b3 = b[3];
178
- out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
179
- out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
180
- out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
181
- out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
182
- b0 = b[4];
183
- b1 = b[5];
184
- b2 = b[6];
185
- b3 = b[7];
186
- out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
187
- out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
188
- out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
189
- out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
190
- b0 = b[8];
191
- b1 = b[9];
192
- b2 = b[10];
193
- b3 = b[11];
194
- out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
195
- out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
196
- out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
197
- out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
198
- b0 = b[12];
199
- b1 = b[13];
200
- b2 = b[14];
201
- b3 = b[15];
202
- out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
203
- out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
204
- out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
205
- out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
206
- return out;
207
- }
208
- function translate(out, a, v) {
209
- const x = v[0];
210
- const y = v[1];
211
- const z = v[2];
212
- let a00;
213
- let a01;
214
- let a02;
215
- let a03;
216
- let a10;
217
- let a11;
218
- let a12;
219
- let a13;
220
- let a20;
221
- let a21;
222
- let a22;
223
- let a23;
224
- if (a === out) {
225
- out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
226
- out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
227
- out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
228
- out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
229
- } else {
230
- a00 = a[0];
231
- a01 = a[1];
232
- a02 = a[2];
233
- a03 = a[3];
234
- a10 = a[4];
235
- a11 = a[5];
236
- a12 = a[6];
237
- a13 = a[7];
238
- a20 = a[8];
239
- a21 = a[9];
240
- a22 = a[10];
241
- a23 = a[11];
242
- out[0] = a00;
243
- out[1] = a01;
244
- out[2] = a02;
245
- out[3] = a03;
246
- out[4] = a10;
247
- out[5] = a11;
248
- out[6] = a12;
249
- out[7] = a13;
250
- out[8] = a20;
251
- out[9] = a21;
252
- out[10] = a22;
253
- out[11] = a23;
254
- out[12] = a00 * x + a10 * y + a20 * z + a[12];
255
- out[13] = a01 * x + a11 * y + a21 * z + a[13];
256
- out[14] = a02 * x + a12 * y + a22 * z + a[14];
257
- out[15] = a03 * x + a13 * y + a23 * z + a[15];
258
- }
259
- return out;
260
- }
261
- function scale2(out, a, v) {
262
- const x = v[0];
263
- const y = v[1];
264
- const z = v[2];
265
- out[0] = a[0] * x;
266
- out[1] = a[1] * x;
267
- out[2] = a[2] * x;
268
- out[3] = a[3] * x;
269
- out[4] = a[4] * y;
270
- out[5] = a[5] * y;
271
- out[6] = a[6] * y;
272
- out[7] = a[7] * y;
273
- out[8] = a[8] * z;
274
- out[9] = a[9] * z;
275
- out[10] = a[10] * z;
276
- out[11] = a[11] * z;
277
- out[12] = a[12];
278
- out[13] = a[13];
279
- out[14] = a[14];
280
- out[15] = a[15];
281
- return out;
282
- }
283
- function rotateX(out, a, rad) {
284
- const s = Math.sin(rad);
285
- const c = Math.cos(rad);
286
- const a10 = a[4];
287
- const a11 = a[5];
288
- const a12 = a[6];
289
- const a13 = a[7];
290
- const a20 = a[8];
291
- const a21 = a[9];
292
- const a22 = a[10];
293
- const a23 = a[11];
294
- if (a !== out) {
295
- out[0] = a[0];
296
- out[1] = a[1];
297
- out[2] = a[2];
298
- out[3] = a[3];
299
- out[12] = a[12];
300
- out[13] = a[13];
301
- out[14] = a[14];
302
- out[15] = a[15];
303
- }
304
- out[4] = a10 * c + a20 * s;
305
- out[5] = a11 * c + a21 * s;
306
- out[6] = a12 * c + a22 * s;
307
- out[7] = a13 * c + a23 * s;
308
- out[8] = a20 * c - a10 * s;
309
- out[9] = a21 * c - a11 * s;
310
- out[10] = a22 * c - a12 * s;
311
- out[11] = a23 * c - a13 * s;
312
- return out;
313
- }
314
- function rotateZ(out, a, rad) {
315
- const s = Math.sin(rad);
316
- const c = Math.cos(rad);
317
- const a00 = a[0];
318
- const a01 = a[1];
319
- const a02 = a[2];
320
- const a03 = a[3];
321
- const a10 = a[4];
322
- const a11 = a[5];
323
- const a12 = a[6];
324
- const a13 = a[7];
325
- if (a !== out) {
326
- out[8] = a[8];
327
- out[9] = a[9];
328
- out[10] = a[10];
329
- out[11] = a[11];
330
- out[12] = a[12];
331
- out[13] = a[13];
332
- out[14] = a[14];
333
- out[15] = a[15];
334
- }
335
- out[0] = a00 * c + a10 * s;
336
- out[1] = a01 * c + a11 * s;
337
- out[2] = a02 * c + a12 * s;
338
- out[3] = a03 * c + a13 * s;
339
- out[4] = a10 * c - a00 * s;
340
- out[5] = a11 * c - a01 * s;
341
- out[6] = a12 * c - a02 * s;
342
- out[7] = a13 * c - a03 * s;
343
- return out;
344
- }
345
- function perspectiveNO(out, fovy, aspect, near, far) {
346
- const f = 1 / Math.tan(fovy / 2);
347
- out[0] = f / aspect;
348
- out[1] = 0;
349
- out[2] = 0;
350
- out[3] = 0;
351
- out[4] = 0;
352
- out[5] = f;
353
- out[6] = 0;
354
- out[7] = 0;
355
- out[8] = 0;
356
- out[9] = 0;
357
- out[11] = -1;
358
- out[12] = 0;
359
- out[13] = 0;
360
- out[15] = 0;
361
- if (far != null && far !== Infinity) {
362
- const nf = 1 / (near - far);
363
- out[10] = (far + near) * nf;
364
- out[14] = 2 * far * near * nf;
365
- } else {
366
- out[10] = -1;
367
- out[14] = -2 * near;
368
- }
369
- return out;
370
- }
371
- var perspective = perspectiveNO;
372
- function equals(a, b) {
373
- const a0 = a[0];
374
- const a1 = a[1];
375
- const a2 = a[2];
376
- const a3 = a[3];
377
- const a4 = a[4];
378
- const a5 = a[5];
379
- const a6 = a[6];
380
- const a7 = a[7];
381
- const a8 = a[8];
382
- const a9 = a[9];
383
- const a10 = a[10];
384
- const a11 = a[11];
385
- const a12 = a[12];
386
- const a13 = a[13];
387
- const a14 = a[14];
388
- const a15 = a[15];
389
- const b0 = b[0];
390
- const b1 = b[1];
391
- const b2 = b[2];
392
- const b3 = b[3];
393
- const b4 = b[4];
394
- const b5 = b[5];
395
- const b6 = b[6];
396
- const b7 = b[7];
397
- const b8 = b[8];
398
- const b9 = b[9];
399
- const b10 = b[10];
400
- const b11 = b[11];
401
- const b12 = b[12];
402
- const b13 = b[13];
403
- const b14 = b[14];
404
- const b15 = b[15];
405
- return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= EPSILON * Math.max(1, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= EPSILON * Math.max(1, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= EPSILON * Math.max(1, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= EPSILON * Math.max(1, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= EPSILON * Math.max(1, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= EPSILON * Math.max(1, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= EPSILON * Math.max(1, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= EPSILON * Math.max(1, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= EPSILON * Math.max(1, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= EPSILON * Math.max(1, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= EPSILON * Math.max(1, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= EPSILON * Math.max(1, Math.abs(a15), Math.abs(b15));
406
- }
407
-
408
- // ../core/src/gl-matrix/vec2.ts
409
- function add(out, a, b) {
410
- out[0] = a[0] + b[0];
411
- out[1] = a[1] + b[1];
412
- return out;
413
- }
414
- function subtract(out, a, b) {
415
- out[0] = a[0] - b[0];
416
- out[1] = a[1] - b[1];
417
- return out;
418
- }
419
- function scale3(out, a, b) {
420
- out[0] = a[0] * b;
421
- out[1] = a[1] * b;
422
- return out;
423
- }
424
- function length(a) {
425
- const x = a[0];
426
- const y = a[1];
427
- return Math.sqrt(x * x + y * y);
428
- }
429
- function negate(out, a) {
430
- out[0] = -a[0];
431
- out[1] = -a[1];
432
- return out;
433
- }
434
- function lerp2(out, a, b, t) {
435
- const ax = a[0];
436
- const ay = a[1];
437
- out[0] = ax + t * (b[0] - ax);
438
- out[1] = ay + t * (b[1] - ay);
439
- return out;
440
- }
441
- var sub = subtract;
442
-
443
- // ../core/src/gl-matrix/vec3.ts
444
- function add2(out, a, b) {
445
- out[0] = a[0] + b[0];
446
- out[1] = a[1] + b[1];
447
- out[2] = a[2] + b[2];
448
- return out;
449
- }
450
- function multiply2(out, a, b) {
451
- out[0] = a[0] * b[0];
452
- out[1] = a[1] * b[1];
453
- out[2] = a[2] * b[2];
454
- return out;
455
- }
456
- function negate2(out, a) {
457
- out[0] = -a[0];
458
- out[1] = -a[1];
459
- out[2] = -a[2];
460
- return out;
461
- }
462
- var mul = multiply2;
81
+ // dist/web-mercator-utils.js
82
+ var import_core2 = require("@math.gl/core");
83
+ var import_core3 = require("@math.gl/core");
84
+ var import_core4 = require("@math.gl/core");
463
85
 
464
86
  // dist/assert.js
465
87
  function assert(condition, message) {
@@ -480,8 +102,8 @@ var DEFAULT_ALTITUDE = 1.5;
480
102
  function zoomToScale(zoom) {
481
103
  return Math.pow(2, zoom);
482
104
  }
483
- function scaleToZoom(scale4) {
484
- return log2(scale4);
105
+ function scaleToZoom(scale) {
106
+ return log2(scale);
485
107
  }
486
108
  function lngLatToWorld(lngLat) {
487
109
  const [lng, lat] = lngLat;
@@ -556,22 +178,22 @@ function getViewMatrix(options) {
556
178
  bearing,
557
179
  altitude,
558
180
  // Pre-calculated parameters
559
- scale: scale4,
181
+ scale,
560
182
  center
561
183
  } = options;
562
184
  const vm = createMat4();
563
- translate(vm, vm, [0, 0, -altitude]);
564
- rotateX(vm, vm, -pitch * DEGREES_TO_RADIANS);
565
- rotateZ(vm, vm, bearing * DEGREES_TO_RADIANS);
566
- const relativeScale = scale4 / height;
567
- scale2(vm, vm, [relativeScale, relativeScale, relativeScale]);
185
+ import_core2.mat4.translate(vm, vm, [0, 0, -altitude]);
186
+ import_core2.mat4.rotateX(vm, vm, -pitch * DEGREES_TO_RADIANS);
187
+ import_core2.mat4.rotateZ(vm, vm, bearing * DEGREES_TO_RADIANS);
188
+ const relativeScale = scale / height;
189
+ import_core2.mat4.scale(vm, vm, [relativeScale, relativeScale, relativeScale]);
568
190
  if (center) {
569
- translate(vm, vm, negate2([], center));
191
+ import_core2.mat4.translate(vm, vm, import_core4.vec3.negate([], center));
570
192
  }
571
193
  return vm;
572
194
  }
573
195
  function getProjectionParameters(options) {
574
- const { width, height, altitude, pitch = 0, offset, center, scale: scale4, nearZMultiplier = 1, farZMultiplier = 1 } = options;
196
+ const { width, height, altitude, pitch = 0, offset, center, scale, nearZMultiplier = 1, farZMultiplier = 1 } = options;
575
197
  let { fovy = altitudeToFovy(DEFAULT_ALTITUDE) } = options;
576
198
  if (altitude !== void 0) {
577
199
  fovy = altitudeToFovy(altitude);
@@ -581,7 +203,7 @@ function getProjectionParameters(options) {
581
203
  const focalDistance = fovyToAltitude(fovy);
582
204
  let cameraToSeaLevelDistance = focalDistance;
583
205
  if (center) {
584
- cameraToSeaLevelDistance += center[2] * scale4 / Math.cos(pitchRadians) / height;
206
+ cameraToSeaLevelDistance += center[2] * scale / Math.cos(pitchRadians) / height;
585
207
  }
586
208
  const fovAboveCenter = fovRadians * (0.5 + (offset ? offset[1] : 0) / height);
587
209
  const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * cameraToSeaLevelDistance / Math.sin(clamp(Math.PI / 2 - pitchRadians - fovAboveCenter, 0.01, Math.PI - 0.01));
@@ -598,7 +220,7 @@ function getProjectionParameters(options) {
598
220
  }
599
221
  function getProjectionMatrix(options) {
600
222
  const { fov, aspect, near, far } = getProjectionParameters(options);
601
- const projectionMatrix = perspective(
223
+ const projectionMatrix = import_core2.mat4.perspective(
602
224
  [],
603
225
  fov,
604
226
  // fov in radians
@@ -634,7 +256,7 @@ function pixelsToWorld(xyz, pixelUnprojectionMatrix, targetZ = 0) {
634
256
  const z0 = coord0[2];
635
257
  const z1 = coord1[2];
636
258
  const t = z0 === z1 ? 0 : ((targetZ || 0) - z0) / (z1 - z0);
637
- return lerp2([], coord0, coord1, t);
259
+ return import_core3.vec2.lerp([], coord0, coord1, t);
638
260
  }
639
261
 
640
262
  // dist/fit-bounds.js
@@ -664,12 +286,15 @@ function fitBounds(options) {
664
286
  assert(targetSize[0] > 0 && targetSize[1] > 0);
665
287
  const scaleX = targetSize[0] / size[0];
666
288
  const scaleY = targetSize[1] / size[1];
667
- const offsetX = (padding.right - padding.left) / 2 / scaleX;
668
- const offsetY = (padding.top - padding.bottom) / 2 / scaleY;
669
- const center = [(se[0] + nw[0]) / 2 + offsetX, (se[1] + nw[1]) / 2 + offsetY];
670
- const centerLngLat = worldToLngLat(center);
671
289
  const zoom = Math.min(maxZoom, log2(Math.abs(Math.min(scaleX, scaleY))));
672
290
  assert(Number.isFinite(zoom));
291
+ const scale = 2 ** zoom;
292
+ const shiftX = (padding.left - padding.right) / 2 + offset[0];
293
+ const shiftY = (padding.top - padding.bottom) / 2 + offset[1];
294
+ const centerLngLat = worldToLngLat([
295
+ (se[0] + nw[0]) / 2 - shiftX / scale,
296
+ (se[1] + nw[1]) / 2 + shiftY / scale
297
+ ]);
673
298
  return {
674
299
  longitude: centerLngLat[0],
675
300
  latitude: centerLngLat[1],
@@ -690,6 +315,7 @@ function getPaddingObject(padding = 0) {
690
315
  }
691
316
 
692
317
  // dist/get-bounds.js
318
+ var import_core5 = require("@math.gl/core");
693
319
  var DEGREES_TO_RADIANS2 = Math.PI / 180;
694
320
  function getBounds(viewport, z = 0) {
695
321
  const { width, height, unproject } = viewport;
@@ -715,13 +341,16 @@ function unprojectOnFarPlane(viewport, x, targetZ) {
715
341
  const coord1 = transformVector(pixelUnprojectionMatrix, [x, viewport.height, 1, 1]);
716
342
  const z = targetZ * viewport.distanceScales.unitsPerMeter[2];
717
343
  const t = (z - coord0[2]) / (coord1[2] - coord0[2]);
718
- const coord = lerp2([], coord0, coord1, t);
344
+ const coord = import_core5.vec2.lerp([], coord0, coord1, t);
719
345
  const result = worldToLngLat(coord);
720
346
  result.push(targetZ);
721
347
  return result;
722
348
  }
723
349
 
724
350
  // dist/web-mercator-viewport.js
351
+ var import_core6 = require("@math.gl/core");
352
+ var import_core7 = require("@math.gl/core");
353
+ var import_core8 = require("@math.gl/core");
725
354
  var WebMercatorViewport = class _WebMercatorViewport {
726
355
  /**
727
356
  * @classdesc
@@ -735,7 +364,7 @@ var WebMercatorViewport = class _WebMercatorViewport {
735
364
  if (!(viewport instanceof _WebMercatorViewport)) {
736
365
  return false;
737
366
  }
738
- return viewport.width === this.width && viewport.height === this.height && equals(viewport.projectionMatrix, this.projectionMatrix) && equals(viewport.viewMatrix, this.viewMatrix);
367
+ return viewport.width === this.width && viewport.height === this.height && import_core6.mat4.equals(viewport.projectionMatrix, this.projectionMatrix) && import_core6.mat4.equals(viewport.viewMatrix, this.viewMatrix);
739
368
  };
740
369
  this.project = (lngLatZ, options = {}) => {
741
370
  const { topLeft = true } = options;
@@ -785,18 +414,18 @@ var WebMercatorViewport = class _WebMercatorViewport {
785
414
  } else if (altitude === null) {
786
415
  altitude = fovyToAltitude(fovy);
787
416
  }
788
- const scale4 = zoomToScale(zoom);
417
+ const scale = zoomToScale(zoom);
789
418
  altitude = Math.max(0.75, altitude);
790
419
  const distanceScales = getDistanceScales({ longitude, latitude });
791
420
  const center = lngLatToWorld([longitude, latitude]);
792
421
  center.push(0);
793
422
  if (position) {
794
- add2(center, center, mul([], position, distanceScales.unitsPerMeter));
423
+ import_core8.vec3.add(center, center, import_core8.vec3.mul([], position, distanceScales.unitsPerMeter));
795
424
  }
796
425
  this.projectionMatrix = getProjectionMatrix({
797
426
  width,
798
427
  height,
799
- scale: scale4,
428
+ scale,
800
429
  center,
801
430
  pitch,
802
431
  fovy,
@@ -805,7 +434,7 @@ var WebMercatorViewport = class _WebMercatorViewport {
805
434
  });
806
435
  this.viewMatrix = getViewMatrix({
807
436
  height,
808
- scale: scale4,
437
+ scale,
809
438
  center,
810
439
  pitch,
811
440
  bearing,
@@ -813,7 +442,7 @@ var WebMercatorViewport = class _WebMercatorViewport {
813
442
  });
814
443
  this.width = width;
815
444
  this.height = height;
816
- this.scale = scale4;
445
+ this.scale = scale;
817
446
  this.latitude = latitude;
818
447
  this.longitude = longitude;
819
448
  this.zoom = zoom;
@@ -830,14 +459,14 @@ var WebMercatorViewport = class _WebMercatorViewport {
830
459
  _initMatrices() {
831
460
  const { width, height, projectionMatrix, viewMatrix } = this;
832
461
  const vpm = createMat4();
833
- multiply(vpm, vpm, projectionMatrix);
834
- multiply(vpm, vpm, viewMatrix);
462
+ import_core6.mat4.multiply(vpm, vpm, projectionMatrix);
463
+ import_core6.mat4.multiply(vpm, vpm, viewMatrix);
835
464
  this.viewProjectionMatrix = vpm;
836
465
  const m = createMat4();
837
- scale2(m, m, [width / 2, -height / 2, 1]);
838
- translate(m, m, [1, -1, 0]);
839
- multiply(m, m, vpm);
840
- const mInverse = invert(createMat4(), m);
466
+ import_core6.mat4.scale(m, m, [width / 2, -height / 2, 1]);
467
+ import_core6.mat4.translate(m, m, [1, -1, 0]);
468
+ import_core6.mat4.multiply(m, m, vpm);
469
+ const mInverse = import_core6.mat4.invert(createMat4(), m);
841
470
  if (!mInverse) {
842
471
  throw new Error("Pixel project matrix not invertible");
843
472
  }
@@ -881,8 +510,8 @@ var WebMercatorViewport = class _WebMercatorViewport {
881
510
  getMapCenterByLngLatPosition({ lngLat, pos }) {
882
511
  const fromLocation = pixelsToWorld(pos, this.pixelUnprojectionMatrix);
883
512
  const toLocation = lngLatToWorld(lngLat);
884
- const translate2 = add([], toLocation, negate([], fromLocation));
885
- const newCenter = add([], this.center, translate2);
513
+ const translate = import_core7.vec2.add([], toLocation, import_core7.vec2.negate([], fromLocation));
514
+ const newCenter = import_core7.vec2.add([], this.center, translate);
886
515
  return worldToLngLat(newCenter);
887
516
  }
888
517
  /**
@@ -926,11 +555,6 @@ var WebMercatorViewport = class _WebMercatorViewport {
926
555
  getBoundingRegion(options = {}) {
927
556
  return getBounds(this, options.z || 0);
928
557
  }
929
- // DEPRECATED
930
- /** @deprecated Legacy method name */
931
- getLocationAtPoint({ lngLat, pos }) {
932
- return this.getMapCenterByLngLatPosition({ lngLat, pos });
933
- }
934
558
  };
935
559
 
936
560
  // dist/normalize-viewport-props.js
@@ -964,7 +588,8 @@ function normalizeViewportProps(props) {
964
588
  }
965
589
 
966
590
  // dist/fly-to-viewport.js
967
- var EPSILON2 = 0.01;
591
+ var import_core9 = require("@math.gl/core");
592
+ var EPSILON = 0.01;
968
593
  var VIEWPORT_TRANSITION_PROPS = ["longitude", "latitude", "zoom"];
969
594
  var DEFAULT_OPTS = {
970
595
  curve: 1.414,
@@ -973,7 +598,7 @@ var DEFAULT_OPTS = {
973
598
  };
974
599
  function flyToViewport(startProps, endProps, t, options) {
975
600
  const { startZoom, startCenterXY, uDelta, w0, u1, S, rho, rho2, r0 } = getFlyToTransitionParams(startProps, endProps, options);
976
- if (u1 < EPSILON2) {
601
+ if (u1 < EPSILON) {
977
602
  const viewport = {
978
603
  longitude: 0,
979
604
  latitude: 0,
@@ -991,8 +616,8 @@ function flyToViewport(startProps, endProps, t, options) {
991
616
  const u = w0 * ((Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2) / u1;
992
617
  const scaleIncrement = 1 / w;
993
618
  const newZoom = startZoom + scaleToZoom(scaleIncrement);
994
- const newCenterWorld = scale3([], uDelta, u);
995
- add(newCenterWorld, newCenterWorld, startCenterXY);
619
+ const newCenterWorld = import_core9.vec2.scale([], uDelta, u);
620
+ import_core9.vec2.add(newCenterWorld, newCenterWorld, startCenterXY);
996
621
  const newCenter = worldToLngLat(newCenterWorld);
997
622
  return {
998
623
  longitude: newCenter[0],
@@ -1004,12 +629,12 @@ function getFlyToDuration(startProps, endProps, options) {
1004
629
  const opts = { ...DEFAULT_OPTS, ...options };
1005
630
  const { screenSpeed, speed, maxDuration } = opts;
1006
631
  const { S, rho } = getFlyToTransitionParams(startProps, endProps, opts);
1007
- const length2 = 1e3 * S;
632
+ const length = 1e3 * S;
1008
633
  let duration;
1009
634
  if (Number.isFinite(screenSpeed)) {
1010
- duration = length2 / (screenSpeed / rho);
635
+ duration = length / (screenSpeed / rho);
1011
636
  } else {
1012
- duration = length2 / speed;
637
+ duration = length / speed;
1013
638
  }
1014
639
  return Number.isFinite(maxDuration) && duration > maxDuration ? 0 : duration;
1015
640
  }
@@ -1021,14 +646,14 @@ function getFlyToTransitionParams(startProps, endProps, opts) {
1021
646
  const startScale = zoomToScale(startZoom);
1022
647
  const endZoom = endProps.zoom;
1023
648
  const endCenter = [endProps.longitude, endProps.latitude];
1024
- const scale4 = zoomToScale(endZoom - startZoom);
649
+ const scale = zoomToScale(endZoom - startZoom);
1025
650
  const startCenterXY = lngLatToWorld(startCenter);
1026
651
  const endCenterXY = lngLatToWorld(endCenter);
1027
- const uDelta = sub([], endCenterXY, startCenterXY);
652
+ const uDelta = import_core9.vec2.sub([], endCenterXY, startCenterXY);
1028
653
  const w0 = Math.max(startProps.width, startProps.height);
1029
- const w1 = w0 / scale4;
1030
- const u1 = length(uDelta) * startScale;
1031
- const _u1 = Math.max(u1, EPSILON2);
654
+ const w1 = w0 / scale;
655
+ const u1 = import_core9.vec2.length(uDelta) * startScale;
656
+ const _u1 = Math.max(u1, EPSILON);
1032
657
  const rho2 = rho * rho;
1033
658
  const b0 = (w1 * w1 - w0 * w0 + rho2 * rho2 * _u1 * _u1) / (2 * w0 * rho2 * _u1);
1034
659
  const b1 = (w1 * w1 - w0 * w0 - rho2 * rho2 * _u1 * _u1) / (2 * w1 * rho2 * _u1);