@gisatcz/deckgl-geolib 1.5.0-dev.0 → 1.6.0-dev.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.
package/dist/esm/index.js CHANGED
@@ -1,7 +1,8 @@
1
- import { CompositeLayer } from '@deck.gl/core';
1
+ import { WebMercatorViewport, OrthographicViewport, project, _LayersPass, _PickLayersPass, log, LayerExtension, CompositeLayer } from '@deck.gl/core';
2
2
  import { TileLayer, TerrainLayer } from '@deck.gl/geo-layers';
3
3
  import { BitmapLayer } from '@deck.gl/layers';
4
4
  import chroma from 'chroma-js';
5
+ import { Framebuffer, Texture2D, isWebGL2, withParameters, ProgramManager } from '@luma.gl/core';
5
6
 
6
7
  /******************************************************************************
7
8
  Copyright (c) Microsoft Corporation.
@@ -30,6 +31,1226 @@ function __awaiter(thisArg, _arguments, P, generator) {
30
31
  });
31
32
  }
32
33
 
34
+ function _typeof(obj) {
35
+ "@babel/helpers - typeof";
36
+
37
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
38
+ return typeof obj;
39
+ } : function (obj) {
40
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
41
+ }, _typeof(obj);
42
+ }
43
+
44
+ function _toPrimitive(input, hint) {
45
+ if (_typeof(input) !== "object" || input === null) return input;
46
+ var prim = input[Symbol.toPrimitive];
47
+ if (prim !== undefined) {
48
+ var res = prim.call(input, hint || "default");
49
+ if (_typeof(res) !== "object") return res;
50
+ throw new TypeError("@@toPrimitive must return a primitive value.");
51
+ }
52
+ return (hint === "string" ? String : Number)(input);
53
+ }
54
+
55
+ function _toPropertyKey(arg) {
56
+ var key = _toPrimitive(arg, "string");
57
+ return _typeof(key) === "symbol" ? key : String(key);
58
+ }
59
+
60
+ function _defineProperty(obj, key, value) {
61
+ key = _toPropertyKey(key);
62
+ if (key in obj) {
63
+ Object.defineProperty(obj, key, {
64
+ value: value,
65
+ enumerable: true,
66
+ configurable: true,
67
+ writable: true
68
+ });
69
+ } else {
70
+ obj[key] = value;
71
+ }
72
+ return obj;
73
+ }
74
+
75
+ /**
76
+ * Common utilities
77
+ * @module glMatrix
78
+ */
79
+ // Configuration Constants
80
+ var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
81
+ if (!Math.hypot) Math.hypot = function () {
82
+ var y = 0,
83
+ i = arguments.length;
84
+
85
+ while (i--) {
86
+ y += arguments[i] * arguments[i];
87
+ }
88
+
89
+ return Math.sqrt(y);
90
+ };
91
+
92
+ /**
93
+ * 2 Dimensional Vector
94
+ * @module vec2
95
+ */
96
+
97
+ /**
98
+ * Creates a new, empty vec2
99
+ *
100
+ * @returns {vec2} a new 2D vector
101
+ */
102
+
103
+ function create$2() {
104
+ var out = new ARRAY_TYPE(2);
105
+
106
+ if (ARRAY_TYPE != Float32Array) {
107
+ out[0] = 0;
108
+ out[1] = 0;
109
+ }
110
+
111
+ return out;
112
+ }
113
+ /**
114
+ * Perform some operation over an array of vec2s.
115
+ *
116
+ * @param {Array} a the array of vectors to iterate over
117
+ * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
118
+ * @param {Number} offset Number of elements to skip at the beginning of the array
119
+ * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
120
+ * @param {Function} fn Function to call for each vector in the array
121
+ * @param {Object} [arg] additional argument to pass to fn
122
+ * @returns {Array} a
123
+ * @function
124
+ */
125
+
126
+ (function () {
127
+ var vec = create$2();
128
+ return function (a, stride, offset, count, fn, arg) {
129
+ var i, l;
130
+
131
+ if (!stride) {
132
+ stride = 2;
133
+ }
134
+
135
+ if (!offset) {
136
+ offset = 0;
137
+ }
138
+
139
+ if (count) {
140
+ l = Math.min(count * stride + offset, a.length);
141
+ } else {
142
+ l = a.length;
143
+ }
144
+
145
+ for (i = offset; i < l; i += stride) {
146
+ vec[0] = a[i];
147
+ vec[1] = a[i + 1];
148
+ fn(vec, vec, arg);
149
+ a[i] = vec[0];
150
+ a[i + 1] = vec[1];
151
+ }
152
+
153
+ return a;
154
+ };
155
+ })();
156
+
157
+ /**
158
+ * 3 Dimensional Vector
159
+ * @module vec3
160
+ */
161
+
162
+ /**
163
+ * Creates a new, empty vec3
164
+ *
165
+ * @returns {vec3} a new 3D vector
166
+ */
167
+
168
+ function create$1() {
169
+ var out = new ARRAY_TYPE(3);
170
+
171
+ if (ARRAY_TYPE != Float32Array) {
172
+ out[0] = 0;
173
+ out[1] = 0;
174
+ out[2] = 0;
175
+ }
176
+
177
+ return out;
178
+ }
179
+ /**
180
+ * Perform some operation over an array of vec3s.
181
+ *
182
+ * @param {Array} a the array of vectors to iterate over
183
+ * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
184
+ * @param {Number} offset Number of elements to skip at the beginning of the array
185
+ * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
186
+ * @param {Function} fn Function to call for each vector in the array
187
+ * @param {Object} [arg] additional argument to pass to fn
188
+ * @returns {Array} a
189
+ * @function
190
+ */
191
+
192
+ (function () {
193
+ var vec = create$1();
194
+ return function (a, stride, offset, count, fn, arg) {
195
+ var i, l;
196
+
197
+ if (!stride) {
198
+ stride = 3;
199
+ }
200
+
201
+ if (!offset) {
202
+ offset = 0;
203
+ }
204
+
205
+ if (count) {
206
+ l = Math.min(count * stride + offset, a.length);
207
+ } else {
208
+ l = a.length;
209
+ }
210
+
211
+ for (i = offset; i < l; i += stride) {
212
+ vec[0] = a[i];
213
+ vec[1] = a[i + 1];
214
+ vec[2] = a[i + 2];
215
+ fn(vec, vec, arg);
216
+ a[i] = vec[0];
217
+ a[i + 1] = vec[1];
218
+ a[i + 2] = vec[2];
219
+ }
220
+
221
+ return a;
222
+ };
223
+ })();
224
+
225
+ /**
226
+ * 4 Dimensional Vector
227
+ * @module vec4
228
+ */
229
+
230
+ /**
231
+ * Creates a new, empty vec4
232
+ *
233
+ * @returns {vec4} a new 4D vector
234
+ */
235
+
236
+ function create() {
237
+ var out = new ARRAY_TYPE(4);
238
+
239
+ if (ARRAY_TYPE != Float32Array) {
240
+ out[0] = 0;
241
+ out[1] = 0;
242
+ out[2] = 0;
243
+ out[3] = 0;
244
+ }
245
+
246
+ return out;
247
+ }
248
+ /**
249
+ * Perform some operation over an array of vec4s.
250
+ *
251
+ * @param {Array} a the array of vectors to iterate over
252
+ * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed
253
+ * @param {Number} offset Number of elements to skip at the beginning of the array
254
+ * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array
255
+ * @param {Function} fn Function to call for each vector in the array
256
+ * @param {Object} [arg] additional argument to pass to fn
257
+ * @returns {Array} a
258
+ * @function
259
+ */
260
+
261
+ (function () {
262
+ var vec = create();
263
+ return function (a, stride, offset, count, fn, arg) {
264
+ var i, l;
265
+
266
+ if (!stride) {
267
+ stride = 4;
268
+ }
269
+
270
+ if (!offset) {
271
+ offset = 0;
272
+ }
273
+
274
+ if (count) {
275
+ l = Math.min(count * stride + offset, a.length);
276
+ } else {
277
+ l = a.length;
278
+ }
279
+
280
+ for (i = offset; i < l; i += stride) {
281
+ vec[0] = a[i];
282
+ vec[1] = a[i + 1];
283
+ vec[2] = a[i + 2];
284
+ vec[3] = a[i + 3];
285
+ fn(vec, vec, arg);
286
+ a[i] = vec[0];
287
+ a[i + 1] = vec[1];
288
+ a[i + 2] = vec[2];
289
+ a[i + 3] = vec[3];
290
+ }
291
+
292
+ return a;
293
+ };
294
+ })();
295
+
296
+ function joinLayerBounds(layers, viewport) {
297
+ const bounds = [Infinity, Infinity, -Infinity, -Infinity];
298
+
299
+ for (const layer of layers) {
300
+ const layerBounds = layer.getBounds();
301
+
302
+ if (layerBounds) {
303
+ const bottomLeftCommon = layer.projectPosition(layerBounds[0], {
304
+ viewport,
305
+ autoOffset: false
306
+ });
307
+ const topRightCommon = layer.projectPosition(layerBounds[1], {
308
+ viewport,
309
+ autoOffset: false
310
+ });
311
+ bounds[0] = Math.min(bounds[0], bottomLeftCommon[0]);
312
+ bounds[1] = Math.min(bounds[1], bottomLeftCommon[1]);
313
+ bounds[2] = Math.max(bounds[2], topRightCommon[0]);
314
+ bounds[3] = Math.max(bounds[3], topRightCommon[1]);
315
+ }
316
+ }
317
+
318
+ if (Number.isFinite(bounds[0])) {
319
+ return bounds;
320
+ }
321
+
322
+ return null;
323
+ }
324
+ const MAX_VIEWPORT_SIZE = 2048;
325
+ function makeViewport(opts) {
326
+ const {
327
+ bounds,
328
+ viewport,
329
+ border = 0
330
+ } = opts;
331
+ const {
332
+ isGeospatial
333
+ } = viewport;
334
+
335
+ if (bounds[2] <= bounds[0] || bounds[3] <= bounds[1]) {
336
+ return null;
337
+ }
338
+
339
+ const centerWorld = viewport.unprojectPosition([(bounds[0] + bounds[2]) / 2, (bounds[1] + bounds[3]) / 2, 0]);
340
+ let {
341
+ width,
342
+ height,
343
+ zoom
344
+ } = opts;
345
+
346
+ if (zoom === undefined) {
347
+ width = width - border * 2;
348
+ height = height - border * 2;
349
+ const scale = Math.min(width / (bounds[2] - bounds[0]), height / (bounds[3] - bounds[1]));
350
+ zoom = Math.min(Math.log2(scale), 20);
351
+ } else if (!width || !height) {
352
+ const scale = 2 ** zoom;
353
+ width = Math.round(Math.abs(bounds[2] - bounds[0]) * scale);
354
+ height = Math.round(Math.abs(bounds[3] - bounds[1]) * scale);
355
+ const maxSize = MAX_VIEWPORT_SIZE - border * 2;
356
+
357
+ if (width > maxSize || height > maxSize) {
358
+ const r = maxSize / Math.max(width, height);
359
+ width = Math.round(width * r);
360
+ height = Math.round(height * r);
361
+ zoom += Math.log2(r);
362
+ }
363
+ }
364
+
365
+ return isGeospatial ? new WebMercatorViewport({
366
+ id: viewport.id,
367
+ x: border,
368
+ y: border,
369
+ width,
370
+ height,
371
+ longitude: centerWorld[0],
372
+ latitude: centerWorld[1],
373
+ zoom,
374
+ orthographic: true
375
+ }) : new OrthographicViewport({
376
+ id: viewport.id,
377
+ x: border,
378
+ y: border,
379
+ width,
380
+ height,
381
+ target: centerWorld,
382
+ zoom,
383
+ flipY: false
384
+ });
385
+ }
386
+ function getViewportBounds(viewport, zRange) {
387
+ let viewportBoundsWorld;
388
+
389
+ if (zRange && zRange.length === 2) {
390
+ const [minZ, maxZ] = zRange;
391
+ const bounds0 = viewport.getBounds({
392
+ z: minZ
393
+ });
394
+ const bounds1 = viewport.getBounds({
395
+ z: maxZ
396
+ });
397
+ viewportBoundsWorld = [Math.min(bounds0[0], bounds1[0]), Math.min(bounds0[1], bounds1[1]), Math.max(bounds0[2], bounds1[2]), Math.max(bounds0[3], bounds1[3])];
398
+ } else {
399
+ viewportBoundsWorld = viewport.getBounds();
400
+ }
401
+
402
+ const viewportBottomLeftCommon = viewport.projectPosition(viewportBoundsWorld.slice(0, 2));
403
+ const viewportTopRightCommon = viewport.projectPosition(viewportBoundsWorld.slice(2, 4));
404
+ return [viewportBottomLeftCommon[0], viewportBottomLeftCommon[1], viewportTopRightCommon[0], viewportTopRightCommon[1]];
405
+ }
406
+ function getRenderBounds(layerBounds, viewport, zRange) {
407
+ if (!layerBounds) {
408
+ return [0, 0, 1, 1];
409
+ }
410
+
411
+ const viewportBounds = getViewportBounds(viewport, zRange);
412
+ const paddedBounds = doubleBounds(viewportBounds);
413
+
414
+ if (layerBounds[2] - layerBounds[0] <= paddedBounds[2] - paddedBounds[0] && layerBounds[3] - layerBounds[1] <= paddedBounds[3] - paddedBounds[1]) {
415
+ return layerBounds;
416
+ }
417
+
418
+ return [Math.max(layerBounds[0], paddedBounds[0]), Math.max(layerBounds[1], paddedBounds[1]), Math.min(layerBounds[2], paddedBounds[2]), Math.min(layerBounds[3], paddedBounds[3])];
419
+ }
420
+
421
+ function doubleBounds(bounds) {
422
+ const dx = bounds[2] - bounds[0];
423
+ const dy = bounds[3] - bounds[1];
424
+ const centerX = (bounds[0] + bounds[2]) / 2;
425
+ const centerY = (bounds[1] + bounds[3]) / 2;
426
+ return [centerX - dx, centerY - dy, centerX + dx, centerY + dy];
427
+ }
428
+
429
+ const TERRAIN_MODE = {
430
+ NONE: 0,
431
+ WRITE_HEIGHT_MAP: 1,
432
+ USE_HEIGHT_MAP: 2,
433
+ USE_COVER: 3,
434
+ USE_COVER_ONLY: 4,
435
+ SKIP: 5
436
+ };
437
+ const TERRAIN_MODE_CONSTANTS = Object.keys(TERRAIN_MODE).map(key => "const float TERRAIN_MODE_".concat(key, " = ").concat(TERRAIN_MODE[key], ".0;")).join('\n');
438
+ const terrainModule = {
439
+ name: 'terrain',
440
+ dependencies: [project],
441
+ inject: {
442
+ 'vs:#decl': "\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nvarying vec3 commonPos;\n".concat(TERRAIN_MODE_CONSTANTS, "\n "),
443
+ 'vs:#main-start': "\nif (terrain_mode == TERRAIN_MODE_SKIP) {\n gl_Position = vec4(0.0);\n return;\n}\n",
444
+ 'vs:DECKGL_FILTER_GL_POSITION': "\ncommonPos = geometry.position.xyz;\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);\n commonPos.z += project_uCommonOrigin.z;\n}\nif (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) {\n vec3 anchor = geometry.worldPosition;\n anchor.z = 0.0;\n vec3 anchorCommon = project_position(anchor);\n vec2 texCoords = (anchorCommon.xy - terrain_bounds.xy) / terrain_bounds.zw;\n if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {\n float terrainZ = texture2D(terrain_map, texCoords).r;\n geometry.position.z += terrainZ;\n position = project_common_position_to_clipspace(geometry.position);\n }\n}\n ",
445
+ 'fs:#decl': "\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nvarying vec3 commonPos;\n".concat(TERRAIN_MODE_CONSTANTS, "\n "),
446
+ 'fs:#main-start': "\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n gl_FragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);\n return;\n}\n ",
447
+ 'fs:DECKGL_FILTER_COLOR': "\nif ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY)) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n vec4 pixel = texture2D(terrain_map, texCoords);\n if (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY) {\n color = pixel;\n } else {\n // pixel is premultiplied\n color = pixel + color * (1.0 - pixel.a);\n }\n return;\n}\n "
448
+ },
449
+ getUniforms: (opts = {}, uniforms) => {
450
+ if ('dummyHeightMap' in opts) {
451
+ const {
452
+ drawToTerrainHeightMap,
453
+ heightMap,
454
+ heightMapBounds,
455
+ dummyHeightMap,
456
+ terrainCover,
457
+ useTerrainHeightMap,
458
+ terrainSkipRender
459
+ } = opts;
460
+ const {
461
+ project_uCommonOrigin
462
+ } = uniforms;
463
+ let mode = terrainSkipRender ? TERRAIN_MODE.SKIP : TERRAIN_MODE.NONE;
464
+ let sampler = dummyHeightMap;
465
+ let bounds = null;
466
+
467
+ if (drawToTerrainHeightMap) {
468
+ mode = TERRAIN_MODE.WRITE_HEIGHT_MAP;
469
+ bounds = heightMapBounds;
470
+ } else if (useTerrainHeightMap && heightMap) {
471
+ mode = TERRAIN_MODE.USE_HEIGHT_MAP;
472
+ sampler = heightMap;
473
+ bounds = heightMapBounds;
474
+ } else if (terrainCover) {
475
+ const isPicking = opts.pickingActive;
476
+ sampler = isPicking ? terrainCover.getPickingFramebuffer() : terrainCover.getRenderFramebuffer();
477
+
478
+ if (isPicking) {
479
+ mode = TERRAIN_MODE.SKIP;
480
+ }
481
+
482
+ if (sampler) {
483
+ mode = mode === TERRAIN_MODE.SKIP ? TERRAIN_MODE.USE_COVER_ONLY : TERRAIN_MODE.USE_COVER;
484
+ bounds = terrainCover.bounds;
485
+ } else {
486
+ sampler = dummyHeightMap;
487
+ }
488
+ }
489
+
490
+ return {
491
+ terrain_mode: mode,
492
+ terrain_map: sampler,
493
+ terrain_bounds: bounds ? [bounds[0] - project_uCommonOrigin[0], bounds[1] - project_uCommonOrigin[1], bounds[2] - bounds[0], bounds[3] - bounds[1]] : [0, 0, 0, 0]
494
+ };
495
+ }
496
+
497
+ return null;
498
+ }
499
+ };
500
+
501
+ function createRenderTarget(gl, opts) {
502
+ return new Framebuffer(gl, {
503
+ id: opts.id,
504
+ attachments: {
505
+ [36064]: new Texture2D(gl, { ...(opts.float && {
506
+ format: isWebGL2(gl) ? 34836 : 6408,
507
+ type: 5126
508
+ }),
509
+ mipmaps: false,
510
+ parameters: {
511
+ [10241]: 9729,
512
+ [10240]: 9729,
513
+ [10242]: 33071,
514
+ [10243]: 33071
515
+ }
516
+ })
517
+ }
518
+ });
519
+ }
520
+
521
+ class TerrainCover {
522
+ constructor(targetLayer) {
523
+ _defineProperty(this, "isDirty", true);
524
+
525
+ _defineProperty(this, "targetLayer", void 0);
526
+
527
+ _defineProperty(this, "renderViewport", null);
528
+
529
+ _defineProperty(this, "bounds", null);
530
+
531
+ _defineProperty(this, "fbo", void 0);
532
+
533
+ _defineProperty(this, "pickingFbo", void 0);
534
+
535
+ _defineProperty(this, "layers", []);
536
+
537
+ _defineProperty(this, "tile", void 0);
538
+
539
+ _defineProperty(this, "targetBounds", null);
540
+
541
+ _defineProperty(this, "targetBoundsCommon", null);
542
+
543
+ this.targetLayer = targetLayer;
544
+ this.tile = getTile(targetLayer);
545
+ }
546
+
547
+ get id() {
548
+ return this.targetLayer.id;
549
+ }
550
+
551
+ get isActive() {
552
+ return Boolean(this.targetLayer.getCurrentLayer());
553
+ }
554
+
555
+ shouldUpdate({
556
+ targetLayer,
557
+ viewport,
558
+ layers,
559
+ layerNeedsRedraw
560
+ }) {
561
+ if (targetLayer) {
562
+ this.targetLayer = targetLayer;
563
+ }
564
+
565
+ const sizeChanged = viewport ? this._updateViewport(viewport) : false;
566
+ let layersChanged = layers ? this._updateLayers(layers) : false;
567
+
568
+ if (layerNeedsRedraw) {
569
+ for (const id of this.layers) {
570
+ if (layerNeedsRedraw[id]) {
571
+ layersChanged = true;
572
+ break;
573
+ }
574
+ }
575
+ }
576
+
577
+ return layersChanged || sizeChanged;
578
+ }
579
+
580
+ _updateLayers(layers) {
581
+ let needsRedraw = false;
582
+ layers = this.tile ? getIntersectingLayers(this.tile, layers) : layers;
583
+
584
+ if (layers.length !== this.layers.length) {
585
+ needsRedraw = true;
586
+ } else {
587
+ for (let i = 0; i < layers.length; i++) {
588
+ const id = layers[i].id;
589
+
590
+ if (id !== this.layers[i]) {
591
+ needsRedraw = true;
592
+ break;
593
+ }
594
+ }
595
+ }
596
+
597
+ if (needsRedraw) {
598
+ this.layers = layers.map(layer => layer.id);
599
+ }
600
+
601
+ return needsRedraw;
602
+ }
603
+
604
+ _updateViewport(viewport) {
605
+ const targetLayer = this.targetLayer;
606
+ let shouldRedraw = false;
607
+
608
+ if (this.tile && 'boundingBox' in this.tile) {
609
+ if (!this.targetBounds) {
610
+ shouldRedraw = true;
611
+ this.targetBounds = this.tile.boundingBox;
612
+ const bottomLeftCommon = viewport.projectPosition(this.targetBounds[0]);
613
+ const topRightCommon = viewport.projectPosition(this.targetBounds[1]);
614
+ this.targetBoundsCommon = [bottomLeftCommon[0], bottomLeftCommon[1], topRightCommon[0], topRightCommon[1]];
615
+ }
616
+ } else if (this.targetBounds !== targetLayer.getBounds()) {
617
+ shouldRedraw = true;
618
+ this.targetBounds = targetLayer.getBounds();
619
+ this.targetBoundsCommon = joinLayerBounds([targetLayer], viewport);
620
+ }
621
+
622
+ if (!this.targetBoundsCommon) {
623
+ return false;
624
+ }
625
+
626
+ const newZoom = Math.ceil(viewport.zoom + 0.5);
627
+
628
+ if (this.tile) {
629
+ this.bounds = this.targetBoundsCommon;
630
+ } else {
631
+ var _this$renderViewport;
632
+
633
+ const oldZoom = (_this$renderViewport = this.renderViewport) === null || _this$renderViewport === void 0 ? void 0 : _this$renderViewport.zoom;
634
+ shouldRedraw = shouldRedraw || newZoom !== oldZoom;
635
+ const newBounds = getRenderBounds(this.targetBoundsCommon, viewport);
636
+ const oldBounds = this.bounds;
637
+ shouldRedraw = shouldRedraw || !oldBounds || newBounds.some((x, i) => x !== oldBounds[i]);
638
+ this.bounds = newBounds;
639
+ }
640
+
641
+ if (shouldRedraw) {
642
+ this.renderViewport = makeViewport({
643
+ bounds: this.bounds,
644
+ zoom: newZoom,
645
+ viewport
646
+ });
647
+ }
648
+
649
+ return shouldRedraw;
650
+ }
651
+
652
+ getRenderFramebuffer() {
653
+ if (!this.renderViewport || this.layers.length === 0) {
654
+ return null;
655
+ }
656
+
657
+ if (!this.fbo) {
658
+ this.fbo = createRenderTarget(this.targetLayer.context.gl, {
659
+ id: this.id
660
+ });
661
+ }
662
+
663
+ return this.fbo;
664
+ }
665
+
666
+ getPickingFramebuffer() {
667
+ if (!this.renderViewport || this.layers.length === 0 && !this.targetLayer.props.pickable) {
668
+ return null;
669
+ }
670
+
671
+ if (!this.pickingFbo) {
672
+ this.pickingFbo = createRenderTarget(this.targetLayer.context.gl, {
673
+ id: "".concat(this.id, "-picking")
674
+ });
675
+ }
676
+
677
+ return this.pickingFbo;
678
+ }
679
+
680
+ filterLayers(layers) {
681
+ return layers.filter(({
682
+ id
683
+ }) => this.layers.includes(id));
684
+ }
685
+
686
+ delete() {
687
+ const {
688
+ fbo,
689
+ pickingFbo
690
+ } = this;
691
+
692
+ if (fbo) {
693
+ fbo.texture.delete();
694
+ fbo.delete();
695
+ }
696
+
697
+ if (pickingFbo) {
698
+ pickingFbo.texture.delete();
699
+ pickingFbo.delete();
700
+ }
701
+ }
702
+
703
+ }
704
+
705
+ function getIntersectingLayers(sourceTile, layers) {
706
+ return layers.filter(layer => {
707
+ const tile = getTile(layer);
708
+
709
+ if (tile) {
710
+ return intersect(sourceTile.boundingBox, tile.boundingBox);
711
+ }
712
+
713
+ return true;
714
+ });
715
+ }
716
+
717
+ function getTile(layer) {
718
+ while (layer) {
719
+ const {
720
+ tile
721
+ } = layer.props;
722
+
723
+ if (tile) {
724
+ return tile;
725
+ }
726
+
727
+ layer = layer.parent;
728
+ }
729
+
730
+ return null;
731
+ }
732
+
733
+ function intersect(b1, b2) {
734
+ if (b1 && b2) {
735
+ return b1[0][0] < b2[1][0] && b2[0][0] < b1[1][0] && b1[0][1] < b2[1][1] && b2[0][1] < b1[1][1];
736
+ }
737
+
738
+ return false;
739
+ }
740
+
741
+ class TerrainPass extends _LayersPass {
742
+ getRenderableLayers(viewport, opts) {
743
+ const {
744
+ layers
745
+ } = opts;
746
+ const result = [];
747
+
748
+ const drawParamsByIndex = this._getDrawLayerParams(viewport, opts, true);
749
+
750
+ for (let i = 0; i < layers.length; i++) {
751
+ const layer = layers[i];
752
+
753
+ if (!layer.isComposite && drawParamsByIndex[i].shouldDrawLayer) {
754
+ result.push(layer);
755
+ }
756
+ }
757
+
758
+ return result;
759
+ }
760
+
761
+ renderHeightMap(heightMap, opts) {
762
+ const target = heightMap.getRenderFramebuffer();
763
+ const viewport = heightMap.renderViewport;
764
+
765
+ if (!target || !viewport) {
766
+ return;
767
+ }
768
+
769
+ target.resize(viewport);
770
+ withParameters(this.gl, {
771
+ clearColor: [0, 0, 0, 0],
772
+ blend: true,
773
+ blendFunc: [1, 1],
774
+ blendEquation: 32776,
775
+ depthTest: false
776
+ }, () => this.render({ ...opts,
777
+ target,
778
+ pass: 'terrain-height-map',
779
+ layers: opts.layers,
780
+ viewports: [viewport],
781
+ effects: []
782
+ }));
783
+ }
784
+
785
+ renderTerrainCover(terrainCover, opts) {
786
+ const target = terrainCover.getRenderFramebuffer();
787
+ const viewport = terrainCover.renderViewport;
788
+
789
+ if (!target || !viewport) {
790
+ return;
791
+ }
792
+
793
+ const layers = terrainCover.filterLayers(opts.layers);
794
+ target.resize(viewport);
795
+ withParameters(this.gl, {
796
+ depthTest: false
797
+ }, () => this.render({ ...opts,
798
+ target,
799
+ pass: "terrain-cover-".concat(terrainCover.id),
800
+ layers,
801
+ effects: [],
802
+ viewports: [viewport]
803
+ }));
804
+ }
805
+
806
+ }
807
+
808
+ class TerrainPickingPass extends _PickLayersPass {
809
+ constructor(...args) {
810
+ super(...args);
811
+
812
+ _defineProperty(this, "drawParameters", {});
813
+ }
814
+
815
+ getRenderableLayers(viewport, opts) {
816
+ const {
817
+ layers
818
+ } = opts;
819
+ const result = [];
820
+ this.drawParameters = {};
821
+
822
+ this._resetColorEncoder(opts.pickZ);
823
+
824
+ const drawParamsByIndex = this._getDrawLayerParams(viewport, opts);
825
+
826
+ for (let i = 0; i < layers.length; i++) {
827
+ const layer = layers[i];
828
+
829
+ if (!layer.isComposite && drawParamsByIndex[i].shouldDrawLayer) {
830
+ result.push(layer);
831
+ this.drawParameters[layer.id] = drawParamsByIndex[i].layerParameters;
832
+ }
833
+ }
834
+
835
+ return result;
836
+ }
837
+
838
+ renderTerrainCover(terrainCover, opts) {
839
+ const target = terrainCover.getPickingFramebuffer();
840
+ const viewport = terrainCover.renderViewport;
841
+
842
+ if (!target || !viewport) {
843
+ return;
844
+ }
845
+
846
+ const layers = terrainCover.filterLayers(opts.layers);
847
+ const terrainLayer = terrainCover.targetLayer;
848
+
849
+ if (terrainLayer.props.pickable) {
850
+ layers.unshift(terrainLayer);
851
+ }
852
+
853
+ target.resize(viewport);
854
+ withParameters(this.gl, {
855
+ depthTest: false
856
+ }, () => this.render({ ...opts,
857
+ pickingFBO: target,
858
+ pass: "terrain-cover-picking-".concat(terrainCover.id),
859
+ layers,
860
+ effects: [],
861
+ viewports: [viewport],
862
+ cullRect: undefined,
863
+ deviceRect: viewport,
864
+ pickZ: false
865
+ }));
866
+ }
867
+
868
+ getLayerParameters(layer, layerIndex, viewport) {
869
+ if (this.drawParameters[layer.id]) {
870
+ return this.drawParameters[layer.id];
871
+ }
872
+
873
+ const parameters = super.getLayerParameters(layer, layerIndex, viewport);
874
+ parameters.blend = true;
875
+ return parameters;
876
+ }
877
+
878
+ }
879
+
880
+ const MAP_MAX_SIZE = 2048;
881
+ class HeightMapBuilder {
882
+ static isSupported(gl) {
883
+ return Framebuffer.isSupported(gl, {
884
+ colorBufferFloat: true
885
+ });
886
+ }
887
+
888
+ constructor(gl) {
889
+ _defineProperty(this, "renderViewport", null);
890
+
891
+ _defineProperty(this, "bounds", null);
892
+
893
+ _defineProperty(this, "fbo", void 0);
894
+
895
+ _defineProperty(this, "gl", void 0);
896
+
897
+ _defineProperty(this, "layers", []);
898
+
899
+ _defineProperty(this, "layersBounds", []);
900
+
901
+ _defineProperty(this, "layersBoundsCommon", null);
902
+
903
+ _defineProperty(this, "lastViewport", null);
904
+
905
+ this.gl = gl;
906
+ }
907
+
908
+ getRenderFramebuffer() {
909
+ if (!this.renderViewport) {
910
+ return null;
911
+ }
912
+
913
+ if (!this.fbo) {
914
+ this.fbo = createRenderTarget(this.gl, {
915
+ id: 'height-map',
916
+ float: true
917
+ });
918
+ }
919
+
920
+ return this.fbo;
921
+ }
922
+
923
+ shouldUpdate({
924
+ layers,
925
+ viewport
926
+ }) {
927
+ const layersChanged = layers.length !== this.layers.length || layers.some((layer, i) => layer !== this.layers[i] || layer.props.transitions || layer.getBounds() !== this.layersBounds[i]);
928
+
929
+ if (layersChanged) {
930
+ this.layers = layers;
931
+ this.layersBounds = layers.map(layer => layer.getBounds());
932
+ this.layersBoundsCommon = joinLayerBounds(layers, viewport);
933
+ }
934
+
935
+ const viewportChanged = !this.lastViewport || !viewport.equals(this.lastViewport);
936
+
937
+ if (!this.layersBoundsCommon) {
938
+ this.renderViewport = null;
939
+ } else if (layersChanged || viewportChanged) {
940
+ const bounds = getRenderBounds(this.layersBoundsCommon, viewport);
941
+
942
+ if (bounds[2] <= bounds[0] || bounds[3] <= bounds[1]) {
943
+ this.renderViewport = null;
944
+ return false;
945
+ }
946
+
947
+ this.bounds = bounds;
948
+ this.lastViewport = viewport;
949
+ const scale = viewport.scale;
950
+ const pixelWidth = (bounds[2] - bounds[0]) * scale;
951
+ const pixelHeight = (bounds[3] - bounds[1]) * scale;
952
+ this.renderViewport = pixelWidth > 0 || pixelHeight > 0 ? makeViewport({
953
+ bounds: [viewport.center[0] - 1, viewport.center[1] - 1, viewport.center[0] + 1, viewport.center[1] + 1],
954
+ zoom: viewport.zoom,
955
+ width: Math.min(pixelWidth, MAP_MAX_SIZE),
956
+ height: Math.min(pixelHeight, MAP_MAX_SIZE),
957
+ viewport
958
+ }) : null;
959
+ return true;
960
+ }
961
+
962
+ return false;
963
+ }
964
+
965
+ delete() {
966
+ if (this.fbo) {
967
+ this.fbo.color.delete();
968
+ this.fbo.delete();
969
+ }
970
+ }
971
+
972
+ }
973
+
974
+ class TerrainEffect {
975
+ constructor() {
976
+ _defineProperty(this, "id", 'terrain-effect');
977
+
978
+ _defineProperty(this, "props", null);
979
+
980
+ _defineProperty(this, "useInPicking", true);
981
+
982
+ _defineProperty(this, "isPicking", false);
983
+
984
+ _defineProperty(this, "isDrapingEnabled", false);
985
+
986
+ _defineProperty(this, "dummyHeightMap", void 0);
987
+
988
+ _defineProperty(this, "heightMap", void 0);
989
+
990
+ _defineProperty(this, "terrainPass", void 0);
991
+
992
+ _defineProperty(this, "terrainPickingPass", void 0);
993
+
994
+ _defineProperty(this, "terrainCovers", new Map());
995
+ }
996
+
997
+ initialize(gl) {
998
+ this.dummyHeightMap = new Texture2D(gl, {
999
+ width: 1,
1000
+ height: 1,
1001
+ data: new Uint8Array([0, 0, 0, 0])
1002
+ });
1003
+ this.terrainPass = new TerrainPass(gl, {
1004
+ id: 'terrain'
1005
+ });
1006
+ this.terrainPickingPass = new TerrainPickingPass(gl, {
1007
+ id: 'terrain-picking'
1008
+ });
1009
+
1010
+ if (HeightMapBuilder.isSupported(gl)) {
1011
+ this.heightMap = new HeightMapBuilder(gl);
1012
+ } else {
1013
+ log.warn('Terrain offset mode is not supported by this browser')();
1014
+ }
1015
+
1016
+ ProgramManager.getDefaultProgramManager(gl).addDefaultModule(terrainModule);
1017
+ }
1018
+
1019
+ preRender(gl, opts) {
1020
+ if (!this.dummyHeightMap) {
1021
+ this.initialize(gl);
1022
+
1023
+ for (const layer of opts.layers) {
1024
+ if (layer.props.operation.includes('terrain')) {
1025
+ layer.setChangeFlags({
1026
+ extensionsChanged: true
1027
+ });
1028
+ }
1029
+ }
1030
+ }
1031
+
1032
+ if (opts.pickZ) {
1033
+ this.isDrapingEnabled = false;
1034
+ return;
1035
+ }
1036
+
1037
+ const {
1038
+ viewports,
1039
+ isPicking = false
1040
+ } = opts;
1041
+ this.isPicking = isPicking;
1042
+ this.isDrapingEnabled = true;
1043
+ const viewport = viewports[0];
1044
+ const layers = (isPicking ? this.terrainPickingPass : this.terrainPass).getRenderableLayers(viewport, opts);
1045
+ const terrainLayers = layers.filter(l => l.props.operation.includes('terrain'));
1046
+
1047
+ if (terrainLayers.length === 0) {
1048
+ return;
1049
+ }
1050
+
1051
+ if (!isPicking) {
1052
+ const offsetLayers = layers.filter(l => l.state.terrainDrawMode === 'offset');
1053
+
1054
+ if (offsetLayers.length > 0) {
1055
+ this._updateHeightMap(terrainLayers, viewport, opts);
1056
+ }
1057
+ }
1058
+
1059
+ const drapeLayers = layers.filter(l => l.state.terrainDrawMode === 'drape');
1060
+
1061
+ this._updateTerrainCovers(terrainLayers, drapeLayers, viewport, opts);
1062
+ }
1063
+
1064
+ getModuleParameters(layer) {
1065
+ var _this$heightMap, _this$heightMap2;
1066
+
1067
+ const {
1068
+ terrainDrawMode
1069
+ } = layer.state;
1070
+ return {
1071
+ heightMap: (_this$heightMap = this.heightMap) === null || _this$heightMap === void 0 ? void 0 : _this$heightMap.getRenderFramebuffer(),
1072
+ heightMapBounds: (_this$heightMap2 = this.heightMap) === null || _this$heightMap2 === void 0 ? void 0 : _this$heightMap2.bounds,
1073
+ dummyHeightMap: this.dummyHeightMap,
1074
+ terrainCover: this.isDrapingEnabled ? this.terrainCovers.get(layer.id) : null,
1075
+ useTerrainHeightMap: terrainDrawMode === 'offset',
1076
+ terrainSkipRender: terrainDrawMode === 'drape' || !layer.props.operation.includes('draw')
1077
+ };
1078
+ }
1079
+
1080
+ cleanup() {
1081
+ if (this.dummyHeightMap) {
1082
+ this.dummyHeightMap.delete();
1083
+ this.dummyHeightMap = undefined;
1084
+ }
1085
+
1086
+ if (this.heightMap) {
1087
+ this.heightMap.delete();
1088
+ this.heightMap = undefined;
1089
+ }
1090
+
1091
+ for (const terrainCover of this.terrainCovers.values()) {
1092
+ terrainCover.delete();
1093
+ }
1094
+
1095
+ this.terrainCovers.clear();
1096
+ }
1097
+
1098
+ _updateHeightMap(terrainLayers, viewport, opts) {
1099
+ if (!this.heightMap) {
1100
+ return;
1101
+ }
1102
+
1103
+ const shouldUpdate = this.heightMap.shouldUpdate({
1104
+ layers: terrainLayers,
1105
+ viewport
1106
+ });
1107
+
1108
+ if (!shouldUpdate) {
1109
+ return;
1110
+ }
1111
+
1112
+ this.terrainPass.renderHeightMap(this.heightMap, { ...opts,
1113
+ layers: terrainLayers,
1114
+ moduleParameters: {
1115
+ heightMapBounds: this.heightMap.bounds,
1116
+ dummyHeightMap: this.dummyHeightMap,
1117
+ devicePixelRatio: 1,
1118
+ drawToTerrainHeightMap: true
1119
+ }
1120
+ });
1121
+ }
1122
+
1123
+ _updateTerrainCovers(terrainLayers, drapeLayers, viewport, opts) {
1124
+ const layerNeedsRedraw = {};
1125
+
1126
+ for (const layer of drapeLayers) {
1127
+ if (layer.state.terrainCoverNeedsRedraw) {
1128
+ layerNeedsRedraw[layer.id] = true;
1129
+ layer.state.terrainCoverNeedsRedraw = false;
1130
+ }
1131
+ }
1132
+
1133
+ for (const terrainCover of this.terrainCovers.values()) {
1134
+ terrainCover.isDirty = terrainCover.isDirty || terrainCover.shouldUpdate({
1135
+ layerNeedsRedraw
1136
+ });
1137
+ }
1138
+
1139
+ for (const layer of terrainLayers) {
1140
+ this._updateTerrainCover(layer, drapeLayers, viewport, opts);
1141
+ }
1142
+
1143
+ if (!this.isPicking) {
1144
+ this._pruneTerrainCovers();
1145
+ }
1146
+ }
1147
+
1148
+ _updateTerrainCover(terrainLayer, drapeLayers, viewport, opts) {
1149
+ const renderPass = this.isPicking ? this.terrainPickingPass : this.terrainPass;
1150
+ let terrainCover = this.terrainCovers.get(terrainLayer.id);
1151
+
1152
+ if (!terrainCover) {
1153
+ terrainCover = new TerrainCover(terrainLayer);
1154
+ this.terrainCovers.set(terrainLayer.id, terrainCover);
1155
+ }
1156
+
1157
+ try {
1158
+ const isDirty = terrainCover.shouldUpdate({
1159
+ targetLayer: terrainLayer,
1160
+ viewport,
1161
+ layers: drapeLayers
1162
+ });
1163
+
1164
+ if (this.isPicking || terrainCover.isDirty || isDirty) {
1165
+ renderPass.renderTerrainCover(terrainCover, { ...opts,
1166
+ layers: drapeLayers,
1167
+ moduleParameters: {
1168
+ dummyHeightMap: this.dummyHeightMap,
1169
+ terrainSkipRender: false,
1170
+ devicePixelRatio: 1
1171
+ }
1172
+ });
1173
+ terrainCover.isDirty = false;
1174
+ }
1175
+ } catch (err) {
1176
+ terrainLayer.raiseError(err, "Error rendering terrain cover ".concat(terrainCover.id));
1177
+ }
1178
+ }
1179
+
1180
+ _pruneTerrainCovers() {
1181
+ const idsToRemove = [];
1182
+
1183
+ for (const [id, terrainCover] of this.terrainCovers) {
1184
+ if (!terrainCover.isActive) {
1185
+ idsToRemove.push(id);
1186
+ }
1187
+ }
1188
+
1189
+ for (const id of idsToRemove) {
1190
+ this.terrainCovers.delete(id);
1191
+ }
1192
+ }
1193
+
1194
+ }
1195
+
1196
+ const defaultProps = {
1197
+ terrainDrawMode: undefined
1198
+ };
1199
+ class TerrainExtension extends LayerExtension {
1200
+ getShaders() {
1201
+ return {
1202
+ modules: [terrainModule]
1203
+ };
1204
+ }
1205
+
1206
+ initializeState() {
1207
+ var _this$context$deck;
1208
+
1209
+ (_this$context$deck = this.context.deck) === null || _this$context$deck === void 0 ? void 0 : _this$context$deck._addDefaultEffect(new TerrainEffect());
1210
+ }
1211
+
1212
+ updateState(params) {
1213
+ const {
1214
+ props,
1215
+ oldProps
1216
+ } = params;
1217
+
1218
+ if (this.state.terrainDrawMode && props.terrainDrawMode === oldProps.terrainDrawMode && props.extruded === oldProps.extruded) {
1219
+ return;
1220
+ }
1221
+
1222
+ let {
1223
+ terrainDrawMode
1224
+ } = props;
1225
+
1226
+ if (!terrainDrawMode) {
1227
+ var _this$getAttributeMan;
1228
+
1229
+ const is3d = this.props.extruded;
1230
+ const attributes = (_this$getAttributeMan = this.getAttributeManager()) === null || _this$getAttributeMan === void 0 ? void 0 : _this$getAttributeMan.attributes;
1231
+ const hasAnchor = attributes && 'instancePositions' in attributes;
1232
+ terrainDrawMode = is3d || hasAnchor ? 'offset' : 'drape';
1233
+ }
1234
+
1235
+ this.setState({
1236
+ terrainDrawMode
1237
+ });
1238
+ }
1239
+
1240
+ onNeedsRedraw() {
1241
+ const state = this.state;
1242
+
1243
+ if (state.terrainDrawMode === 'drape') {
1244
+ state.terrainCoverNeedsRedraw = true;
1245
+ }
1246
+ }
1247
+
1248
+ }
1249
+
1250
+ _defineProperty(TerrainExtension, "defaultProps", defaultProps);
1251
+
1252
+ _defineProperty(TerrainExtension, "extensionName", 'TerrainExtension');
1253
+
33
1254
  /**
34
1255
  * MimeType conversion for common tif image types
35
1256
  */
@@ -10456,227 +11677,6 @@ var jpegJs = {
10456
11677
 
10457
11678
  var jpeg$1 = /*@__PURE__*/getDefaultExportFromCjs(jpegJs);
10458
11679
 
10459
- /**
10460
- * Common utilities
10461
- * @module glMatrix
10462
- */
10463
- // Configuration Constants
10464
- var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
10465
- if (!Math.hypot) Math.hypot = function () {
10466
- var y = 0,
10467
- i = arguments.length;
10468
-
10469
- while (i--) {
10470
- y += arguments[i] * arguments[i];
10471
- }
10472
-
10473
- return Math.sqrt(y);
10474
- };
10475
-
10476
- /**
10477
- * 4 Dimensional Vector
10478
- * @module vec4
10479
- */
10480
-
10481
- /**
10482
- * Creates a new, empty vec4
10483
- *
10484
- * @returns {vec4} a new 4D vector
10485
- */
10486
-
10487
- function create$2() {
10488
- var out = new ARRAY_TYPE(4);
10489
-
10490
- if (ARRAY_TYPE != Float32Array) {
10491
- out[0] = 0;
10492
- out[1] = 0;
10493
- out[2] = 0;
10494
- out[3] = 0;
10495
- }
10496
-
10497
- return out;
10498
- }
10499
- /**
10500
- * Perform some operation over an array of vec4s.
10501
- *
10502
- * @param {Array} a the array of vectors to iterate over
10503
- * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed
10504
- * @param {Number} offset Number of elements to skip at the beginning of the array
10505
- * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array
10506
- * @param {Function} fn Function to call for each vector in the array
10507
- * @param {Object} [arg] additional argument to pass to fn
10508
- * @returns {Array} a
10509
- * @function
10510
- */
10511
-
10512
- (function () {
10513
- var vec = create$2();
10514
- return function (a, stride, offset, count, fn, arg) {
10515
- var i, l;
10516
-
10517
- if (!stride) {
10518
- stride = 4;
10519
- }
10520
-
10521
- if (!offset) {
10522
- offset = 0;
10523
- }
10524
-
10525
- if (count) {
10526
- l = Math.min(count * stride + offset, a.length);
10527
- } else {
10528
- l = a.length;
10529
- }
10530
-
10531
- for (i = offset; i < l; i += stride) {
10532
- vec[0] = a[i];
10533
- vec[1] = a[i + 1];
10534
- vec[2] = a[i + 2];
10535
- vec[3] = a[i + 3];
10536
- fn(vec, vec, arg);
10537
- a[i] = vec[0];
10538
- a[i + 1] = vec[1];
10539
- a[i + 2] = vec[2];
10540
- a[i + 3] = vec[3];
10541
- }
10542
-
10543
- return a;
10544
- };
10545
- })();
10546
-
10547
- /**
10548
- * 2 Dimensional Vector
10549
- * @module vec2
10550
- */
10551
-
10552
- /**
10553
- * Creates a new, empty vec2
10554
- *
10555
- * @returns {vec2} a new 2D vector
10556
- */
10557
-
10558
- function create$1() {
10559
- var out = new ARRAY_TYPE(2);
10560
-
10561
- if (ARRAY_TYPE != Float32Array) {
10562
- out[0] = 0;
10563
- out[1] = 0;
10564
- }
10565
-
10566
- return out;
10567
- }
10568
- /**
10569
- * Perform some operation over an array of vec2s.
10570
- *
10571
- * @param {Array} a the array of vectors to iterate over
10572
- * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
10573
- * @param {Number} offset Number of elements to skip at the beginning of the array
10574
- * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
10575
- * @param {Function} fn Function to call for each vector in the array
10576
- * @param {Object} [arg] additional argument to pass to fn
10577
- * @returns {Array} a
10578
- * @function
10579
- */
10580
-
10581
- (function () {
10582
- var vec = create$1();
10583
- return function (a, stride, offset, count, fn, arg) {
10584
- var i, l;
10585
-
10586
- if (!stride) {
10587
- stride = 2;
10588
- }
10589
-
10590
- if (!offset) {
10591
- offset = 0;
10592
- }
10593
-
10594
- if (count) {
10595
- l = Math.min(count * stride + offset, a.length);
10596
- } else {
10597
- l = a.length;
10598
- }
10599
-
10600
- for (i = offset; i < l; i += stride) {
10601
- vec[0] = a[i];
10602
- vec[1] = a[i + 1];
10603
- fn(vec, vec, arg);
10604
- a[i] = vec[0];
10605
- a[i + 1] = vec[1];
10606
- }
10607
-
10608
- return a;
10609
- };
10610
- })();
10611
-
10612
- /**
10613
- * 3 Dimensional Vector
10614
- * @module vec3
10615
- */
10616
-
10617
- /**
10618
- * Creates a new, empty vec3
10619
- *
10620
- * @returns {vec3} a new 3D vector
10621
- */
10622
-
10623
- function create() {
10624
- var out = new ARRAY_TYPE(3);
10625
-
10626
- if (ARRAY_TYPE != Float32Array) {
10627
- out[0] = 0;
10628
- out[1] = 0;
10629
- out[2] = 0;
10630
- }
10631
-
10632
- return out;
10633
- }
10634
- /**
10635
- * Perform some operation over an array of vec3s.
10636
- *
10637
- * @param {Array} a the array of vectors to iterate over
10638
- * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
10639
- * @param {Number} offset Number of elements to skip at the beginning of the array
10640
- * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
10641
- * @param {Function} fn Function to call for each vector in the array
10642
- * @param {Object} [arg] additional argument to pass to fn
10643
- * @returns {Array} a
10644
- * @function
10645
- */
10646
-
10647
- (function () {
10648
- var vec = create();
10649
- return function (a, stride, offset, count, fn, arg) {
10650
- var i, l;
10651
-
10652
- if (!stride) {
10653
- stride = 3;
10654
- }
10655
-
10656
- if (!offset) {
10657
- offset = 0;
10658
- }
10659
-
10660
- if (count) {
10661
- l = Math.min(count * stride + offset, a.length);
10662
- } else {
10663
- l = a.length;
10664
- }
10665
-
10666
- for (i = offset; i < l; i += stride) {
10667
- vec[0] = a[i];
10668
- vec[1] = a[i + 1];
10669
- vec[2] = a[i + 2];
10670
- fn(vec, vec, arg);
10671
- a[i] = vec[0];
10672
- a[i + 1] = vec[1];
10673
- a[i + 2] = vec[2];
10674
- }
10675
-
10676
- return a;
10677
- };
10678
- })();
10679
-
10680
11680
  const PI = Math.PI;
10681
11681
  const PI_4 = PI / 4;
10682
11682
  const RADIANS_TO_DEGREES = 180 / PI;
@@ -14602,13 +15602,11 @@ class CogBitmapLayer extends CompositeLayer {
14602
15602
  maxRequests: 6,
14603
15603
  extent: this.cogTiles.cog ? this.cogTiles.getBoundsAsLatLon(this.cogTiles.cog) : null,
14604
15604
  renderSubLayers: (props) => {
15605
+ var _a, _b, _c, _d, _e, _f, _g;
14605
15606
  const { bbox: { west, south, east, north, }, } = props.tile;
14606
- return new BitmapLayer(props, {
14607
- data: null,
14608
- image: props.data,
14609
- bounds: [west, south, east, north],
14610
- opacity: 1, // 0.6
14611
- });
15607
+ return new BitmapLayer(props, Object.assign({ data: null, image: props.data, bounds: [west, south, east, north], opacity: 1, extensions: ((_b = (_a = this.cogTiles) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.clampToTerrain) ? [new TerrainExtension()] : [] }, (((_e = (_d = (_c = this.cogTiles) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.clampToTerrain) === null || _e === void 0 ? void 0 : _e.terrainDrawMode)
15608
+ ? { terrainDrawMode: (_g = (_f = this.cogTiles) === null || _f === void 0 ? void 0 : _f.options) === null || _g === void 0 ? void 0 : _g.clampToTerrain.terrainDrawMode }
15609
+ : {})));
14612
15610
  },
14613
15611
  });
14614
15612
  return layer;