deck.gl 9.2.5 → 9.2.6
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/dist.dev.js +414 -202
- package/dist.min.js +230 -230
- package/package.json +17 -17
package/dist/dist.dev.js
CHANGED
|
@@ -995,7 +995,7 @@ var __exports__ = (() => {
|
|
|
995
995
|
}
|
|
996
996
|
/** The usage with which this buffer was created */
|
|
997
997
|
usage;
|
|
998
|
-
/** For index buffers, whether indices are 16 or 32 bit */
|
|
998
|
+
/** For index buffers, whether indices are 8, 16 or 32 bit. Note: uint8 indices are automatically converted to uint16 for WebGPU compatibility */
|
|
999
999
|
indexType;
|
|
1000
1000
|
/** "Time" of last update, can be used to check if redraw is needed */
|
|
1001
1001
|
updateTimestamp;
|
|
@@ -1006,6 +1006,8 @@ var __exports__ = (() => {
|
|
|
1006
1006
|
deducedProps.indexType = "uint32";
|
|
1007
1007
|
} else if (props.data instanceof Uint16Array) {
|
|
1008
1008
|
deducedProps.indexType = "uint16";
|
|
1009
|
+
} else if (props.data instanceof Uint8Array) {
|
|
1010
|
+
deducedProps.indexType = "uint8";
|
|
1009
1011
|
}
|
|
1010
1012
|
}
|
|
1011
1013
|
delete deducedProps.data;
|
|
@@ -1826,6 +1828,9 @@ or create a device with the 'debug: true' prop.`;
|
|
|
1826
1828
|
newProps.indexType = "uint32";
|
|
1827
1829
|
} else if (props.data instanceof Uint16Array) {
|
|
1828
1830
|
newProps.indexType = "uint16";
|
|
1831
|
+
} else if (props.data instanceof Uint8Array) {
|
|
1832
|
+
newProps.data = new Uint16Array(props.data);
|
|
1833
|
+
newProps.indexType = "uint16";
|
|
1829
1834
|
}
|
|
1830
1835
|
}
|
|
1831
1836
|
if (!newProps.indexType) {
|
|
@@ -1907,7 +1912,7 @@ or create a device with the 'debug: true' prop.`;
|
|
|
1907
1912
|
VERSION = (
|
|
1908
1913
|
// Version detection using build plugin
|
|
1909
1914
|
// @ts-expect-error no-undef
|
|
1910
|
-
true ? "9.2.
|
|
1915
|
+
true ? "9.2.6" : "running from source"
|
|
1911
1916
|
);
|
|
1912
1917
|
spector;
|
|
1913
1918
|
preregisteredAdapters = /* @__PURE__ */ new Map();
|
|
@@ -35257,9 +35262,10 @@ ${fragment}
|
|
|
35257
35262
|
*
|
|
35258
35263
|
* @param {Array} coords - world coordinates
|
|
35259
35264
|
* @param {Array} pixel - [x,y] coordinates on screen
|
|
35265
|
+
* @param {Array} startPixel - [x,y] screen position where pan started (optional, for delta-based panning)
|
|
35260
35266
|
* @return {Object} props of the new viewport
|
|
35261
35267
|
*/
|
|
35262
|
-
panByPosition(coords, pixel) {
|
|
35268
|
+
panByPosition(coords, pixel, startPixel) {
|
|
35263
35269
|
return null;
|
|
35264
35270
|
}
|
|
35265
35271
|
// INTERNAL METHODS
|
|
@@ -35485,7 +35491,7 @@ ${fragment}
|
|
|
35485
35491
|
addMetersToLngLat(lngLatZ, xyz) {
|
|
35486
35492
|
return addMetersToLngLat(lngLatZ, xyz);
|
|
35487
35493
|
}
|
|
35488
|
-
panByPosition(coords, pixel) {
|
|
35494
|
+
panByPosition(coords, pixel, startPixel) {
|
|
35489
35495
|
const fromLocation = pixelsToWorld(pixel, this.pixelUnprojectionMatrix);
|
|
35490
35496
|
const toLocation = this.projectFlat(coords);
|
|
35491
35497
|
const translate11 = vec2_exports.add([], toLocation, vec2_exports.negate([], fromLocation));
|
|
@@ -36403,12 +36409,12 @@ ${fragment}
|
|
|
36403
36409
|
pipeline.hash = hash;
|
|
36404
36410
|
cache3[hash] = { pipeline, useCount: 1 };
|
|
36405
36411
|
if (this.debug) {
|
|
36406
|
-
log2.
|
|
36412
|
+
log2.log(3, `${this}: ${pipeline} created, count=${cache3[hash].useCount}`)();
|
|
36407
36413
|
}
|
|
36408
36414
|
} else {
|
|
36409
36415
|
cache3[hash].useCount++;
|
|
36410
36416
|
if (this.debug) {
|
|
36411
|
-
log2.
|
|
36417
|
+
log2.log(3, `${this}: ${cache3[hash].pipeline} reused, count=${cache3[hash].useCount}, (id=${props.id})`)();
|
|
36412
36418
|
}
|
|
36413
36419
|
}
|
|
36414
36420
|
return pipeline;
|
|
@@ -36430,12 +36436,12 @@ ${fragment}
|
|
|
36430
36436
|
pipeline.hash = hash;
|
|
36431
36437
|
cache3[hash] = { pipeline, useCount: 1 };
|
|
36432
36438
|
if (this.debug) {
|
|
36433
|
-
log2.
|
|
36439
|
+
log2.log(3, `${this}: ${pipeline} created, count=${cache3[hash].useCount}`)();
|
|
36434
36440
|
}
|
|
36435
36441
|
} else {
|
|
36436
36442
|
cache3[hash].useCount++;
|
|
36437
36443
|
if (this.debug) {
|
|
36438
|
-
log2.
|
|
36444
|
+
log2.log(3, `${this}: ${cache3[hash].pipeline} reused, count=${cache3[hash].useCount}, (id=${props.id})`)();
|
|
36439
36445
|
}
|
|
36440
36446
|
}
|
|
36441
36447
|
return pipeline;
|
|
@@ -36451,13 +36457,13 @@ ${fragment}
|
|
|
36451
36457
|
if (cache3[hash].useCount === 0) {
|
|
36452
36458
|
this._destroyPipeline(pipeline);
|
|
36453
36459
|
if (this.debug) {
|
|
36454
|
-
log2.
|
|
36460
|
+
log2.log(3, `${this}: ${pipeline} released and destroyed`)();
|
|
36455
36461
|
}
|
|
36456
36462
|
} else if (cache3[hash].useCount < 0) {
|
|
36457
36463
|
log2.error(`${this}: ${pipeline} released, useCount < 0, resetting`)();
|
|
36458
36464
|
cache3[hash].useCount = 0;
|
|
36459
36465
|
} else if (this.debug) {
|
|
36460
|
-
log2.
|
|
36466
|
+
log2.log(3, `${this}: ${pipeline} released, count=${cache3[hash].useCount}`)();
|
|
36461
36467
|
}
|
|
36462
36468
|
}
|
|
36463
36469
|
// PRIVATE
|
|
@@ -36562,12 +36568,12 @@ ${fragment}
|
|
|
36562
36568
|
});
|
|
36563
36569
|
this._cache[key] = cacheEntry = { shader, useCount: 1 };
|
|
36564
36570
|
if (this.debug) {
|
|
36565
|
-
log2.
|
|
36571
|
+
log2.log(3, `${this}: Created new shader ${shader.id}`)();
|
|
36566
36572
|
}
|
|
36567
36573
|
} else {
|
|
36568
36574
|
cacheEntry.useCount++;
|
|
36569
36575
|
if (this.debug) {
|
|
36570
|
-
log2.
|
|
36576
|
+
log2.log(3, `${this}: Reusing shader ${cacheEntry.shader.id} count=${cacheEntry.useCount}`)();
|
|
36571
36577
|
}
|
|
36572
36578
|
}
|
|
36573
36579
|
return cacheEntry.shader;
|
|
@@ -36587,13 +36593,13 @@ ${fragment}
|
|
|
36587
36593
|
delete this._cache[key];
|
|
36588
36594
|
cacheEntry.shader.destroy();
|
|
36589
36595
|
if (this.debug) {
|
|
36590
|
-
log2.
|
|
36596
|
+
log2.log(3, `${this}: Releasing shader ${shader.id}, destroyed`)();
|
|
36591
36597
|
}
|
|
36592
36598
|
}
|
|
36593
36599
|
} else if (cacheEntry.useCount < 0) {
|
|
36594
36600
|
throw new Error(`ShaderFactory: Shader ${shader.id} released too many times`);
|
|
36595
36601
|
} else if (this.debug) {
|
|
36596
|
-
log2.
|
|
36602
|
+
log2.log(3, `${this}: Releasing shader ${shader.id} count=${cacheEntry.useCount}`)();
|
|
36597
36603
|
}
|
|
36598
36604
|
}
|
|
36599
36605
|
}
|
|
@@ -40600,6 +40606,174 @@ void main() {
|
|
|
40600
40606
|
}
|
|
40601
40607
|
};
|
|
40602
40608
|
|
|
40609
|
+
// ../core/src/viewports/globe-viewport.ts
|
|
40610
|
+
var DEGREES_TO_RADIANS6 = Math.PI / 180;
|
|
40611
|
+
var RADIANS_TO_DEGREES3 = 180 / Math.PI;
|
|
40612
|
+
var EARTH_RADIUS = 6370972;
|
|
40613
|
+
var GLOBE_RADIUS = 256;
|
|
40614
|
+
function getDistanceScales2() {
|
|
40615
|
+
const unitsPerMeter2 = GLOBE_RADIUS / EARTH_RADIUS;
|
|
40616
|
+
const unitsPerDegree = Math.PI / 180 * GLOBE_RADIUS;
|
|
40617
|
+
return {
|
|
40618
|
+
unitsPerMeter: [unitsPerMeter2, unitsPerMeter2, unitsPerMeter2],
|
|
40619
|
+
unitsPerMeter2: [0, 0, 0],
|
|
40620
|
+
metersPerUnit: [1 / unitsPerMeter2, 1 / unitsPerMeter2, 1 / unitsPerMeter2],
|
|
40621
|
+
unitsPerDegree: [unitsPerDegree, unitsPerDegree, unitsPerMeter2],
|
|
40622
|
+
unitsPerDegree2: [0, 0, 0],
|
|
40623
|
+
degreesPerUnit: [1 / unitsPerDegree, 1 / unitsPerDegree, 1 / unitsPerMeter2]
|
|
40624
|
+
};
|
|
40625
|
+
}
|
|
40626
|
+
var GlobeViewport = class extends Viewport {
|
|
40627
|
+
constructor(opts = {}) {
|
|
40628
|
+
const {
|
|
40629
|
+
longitude = 0,
|
|
40630
|
+
zoom = 0,
|
|
40631
|
+
// Matches Maplibre defaults
|
|
40632
|
+
// https://github.com/maplibre/maplibre-gl-js/blob/f8ab4b48d59ab8fe7b068b102538793bbdd4c848/src/geo/projection/globe_transform.ts#L632-L633
|
|
40633
|
+
nearZMultiplier = 0.5,
|
|
40634
|
+
farZMultiplier = 1,
|
|
40635
|
+
resolution = 10
|
|
40636
|
+
} = opts;
|
|
40637
|
+
let { latitude = 0, height, altitude = 1.5, fovy } = opts;
|
|
40638
|
+
latitude = Math.max(Math.min(latitude, MAX_LATITUDE), -MAX_LATITUDE);
|
|
40639
|
+
height = height || 1;
|
|
40640
|
+
if (fovy) {
|
|
40641
|
+
altitude = fovyToAltitude(fovy);
|
|
40642
|
+
} else {
|
|
40643
|
+
fovy = altitudeToFovy(altitude);
|
|
40644
|
+
}
|
|
40645
|
+
const scale24 = Math.pow(2, zoom - zoomAdjust(latitude));
|
|
40646
|
+
const nearZ = opts.nearZ ?? nearZMultiplier;
|
|
40647
|
+
const farZ = opts.farZ ?? (altitude + GLOBE_RADIUS * 2 * scale24 / height) * farZMultiplier;
|
|
40648
|
+
const viewMatrix2 = new Matrix4().lookAt({ eye: [0, -altitude, 0], up: [0, 0, 1] });
|
|
40649
|
+
viewMatrix2.rotateX(latitude * DEGREES_TO_RADIANS6);
|
|
40650
|
+
viewMatrix2.rotateZ(-longitude * DEGREES_TO_RADIANS6);
|
|
40651
|
+
viewMatrix2.scale(scale24 / height);
|
|
40652
|
+
super({
|
|
40653
|
+
...opts,
|
|
40654
|
+
// x, y, width,
|
|
40655
|
+
height,
|
|
40656
|
+
// view matrix
|
|
40657
|
+
viewMatrix: viewMatrix2,
|
|
40658
|
+
longitude,
|
|
40659
|
+
latitude,
|
|
40660
|
+
zoom,
|
|
40661
|
+
// projection matrix parameters
|
|
40662
|
+
distanceScales: getDistanceScales2(),
|
|
40663
|
+
fovy,
|
|
40664
|
+
focalDistance: altitude,
|
|
40665
|
+
near: nearZ,
|
|
40666
|
+
far: farZ
|
|
40667
|
+
});
|
|
40668
|
+
this.scale = scale24;
|
|
40669
|
+
this.latitude = latitude;
|
|
40670
|
+
this.longitude = longitude;
|
|
40671
|
+
this.fovy = fovy;
|
|
40672
|
+
this.resolution = resolution;
|
|
40673
|
+
}
|
|
40674
|
+
get projectionMode() {
|
|
40675
|
+
return PROJECTION_MODE.GLOBE;
|
|
40676
|
+
}
|
|
40677
|
+
getDistanceScales() {
|
|
40678
|
+
return this.distanceScales;
|
|
40679
|
+
}
|
|
40680
|
+
getBounds(options = {}) {
|
|
40681
|
+
const unprojectOption = { targetZ: options.z || 0 };
|
|
40682
|
+
const left = this.unproject([0, this.height / 2], unprojectOption);
|
|
40683
|
+
const top = this.unproject([this.width / 2, 0], unprojectOption);
|
|
40684
|
+
const right = this.unproject([this.width, this.height / 2], unprojectOption);
|
|
40685
|
+
const bottom = this.unproject([this.width / 2, this.height], unprojectOption);
|
|
40686
|
+
if (right[0] < this.longitude)
|
|
40687
|
+
right[0] += 360;
|
|
40688
|
+
if (left[0] > this.longitude)
|
|
40689
|
+
left[0] -= 360;
|
|
40690
|
+
return [
|
|
40691
|
+
Math.min(left[0], right[0], top[0], bottom[0]),
|
|
40692
|
+
Math.min(left[1], right[1], top[1], bottom[1]),
|
|
40693
|
+
Math.max(left[0], right[0], top[0], bottom[0]),
|
|
40694
|
+
Math.max(left[1], right[1], top[1], bottom[1])
|
|
40695
|
+
];
|
|
40696
|
+
}
|
|
40697
|
+
unproject(xyz, { topLeft = true, targetZ } = {}) {
|
|
40698
|
+
const [x4, y5, z4] = xyz;
|
|
40699
|
+
const y22 = topLeft ? y5 : this.height - y5;
|
|
40700
|
+
const { pixelUnprojectionMatrix } = this;
|
|
40701
|
+
let coord;
|
|
40702
|
+
if (Number.isFinite(z4)) {
|
|
40703
|
+
coord = transformVector2(pixelUnprojectionMatrix, [x4, y22, z4, 1]);
|
|
40704
|
+
} else {
|
|
40705
|
+
const coord0 = transformVector2(pixelUnprojectionMatrix, [x4, y22, -1, 1]);
|
|
40706
|
+
const coord1 = transformVector2(pixelUnprojectionMatrix, [x4, y22, 1, 1]);
|
|
40707
|
+
const lt2 = ((targetZ || 0) / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
40708
|
+
const lSqr = vec3_exports.sqrLen(vec3_exports.sub([], coord0, coord1));
|
|
40709
|
+
const l0Sqr = vec3_exports.sqrLen(coord0);
|
|
40710
|
+
const l1Sqr = vec3_exports.sqrLen(coord1);
|
|
40711
|
+
const sSqr = (4 * l0Sqr * l1Sqr - (lSqr - l0Sqr - l1Sqr) ** 2) / 16;
|
|
40712
|
+
const dSqr = 4 * sSqr / lSqr;
|
|
40713
|
+
const r0 = Math.sqrt(l0Sqr - dSqr);
|
|
40714
|
+
const dr = Math.sqrt(Math.max(0, lt2 * lt2 - dSqr));
|
|
40715
|
+
const t5 = (r0 - dr) / Math.sqrt(lSqr);
|
|
40716
|
+
coord = vec3_exports.lerp([], coord0, coord1, t5);
|
|
40717
|
+
}
|
|
40718
|
+
const [X2, Y2, Z2] = this.unprojectPosition(coord);
|
|
40719
|
+
if (Number.isFinite(z4)) {
|
|
40720
|
+
return [X2, Y2, Z2];
|
|
40721
|
+
}
|
|
40722
|
+
return Number.isFinite(targetZ) ? [X2, Y2, targetZ] : [X2, Y2];
|
|
40723
|
+
}
|
|
40724
|
+
projectPosition(xyz) {
|
|
40725
|
+
const [lng, lat, Z2 = 0] = xyz;
|
|
40726
|
+
const lambda = lng * DEGREES_TO_RADIANS6;
|
|
40727
|
+
const phi = lat * DEGREES_TO_RADIANS6;
|
|
40728
|
+
const cosPhi = Math.cos(phi);
|
|
40729
|
+
const D4 = (Z2 / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
40730
|
+
return [Math.sin(lambda) * cosPhi * D4, -Math.cos(lambda) * cosPhi * D4, Math.sin(phi) * D4];
|
|
40731
|
+
}
|
|
40732
|
+
unprojectPosition(xyz) {
|
|
40733
|
+
const [x4, y5, z4] = xyz;
|
|
40734
|
+
const D4 = vec3_exports.len(xyz);
|
|
40735
|
+
const phi = Math.asin(z4 / D4);
|
|
40736
|
+
const lambda = Math.atan2(x4, -y5);
|
|
40737
|
+
const lng = lambda * RADIANS_TO_DEGREES3;
|
|
40738
|
+
const lat = phi * RADIANS_TO_DEGREES3;
|
|
40739
|
+
const Z2 = (D4 / GLOBE_RADIUS - 1) * EARTH_RADIUS;
|
|
40740
|
+
return [lng, lat, Z2];
|
|
40741
|
+
}
|
|
40742
|
+
projectFlat(xyz) {
|
|
40743
|
+
return xyz;
|
|
40744
|
+
}
|
|
40745
|
+
unprojectFlat(xyz) {
|
|
40746
|
+
return xyz;
|
|
40747
|
+
}
|
|
40748
|
+
/**
|
|
40749
|
+
* Pan the globe using delta-based movement
|
|
40750
|
+
* @param coords - the geographic coordinates where the pan started
|
|
40751
|
+
* @param pixel - the current screen position
|
|
40752
|
+
* @param startPixel - the screen position where the pan started
|
|
40753
|
+
* @returns updated viewport options with new longitude/latitude
|
|
40754
|
+
*/
|
|
40755
|
+
panByPosition([startLng, startLat, startZoom], pixel, startPixel) {
|
|
40756
|
+
const scale24 = Math.pow(2, this.zoom - zoomAdjust(this.latitude));
|
|
40757
|
+
const rotationSpeed = 0.25 / scale24;
|
|
40758
|
+
const longitude = startLng + rotationSpeed * (startPixel[0] - pixel[0]);
|
|
40759
|
+
let latitude = startLat - rotationSpeed * (startPixel[1] - pixel[1]);
|
|
40760
|
+
latitude = Math.max(Math.min(latitude, MAX_LATITUDE), -MAX_LATITUDE);
|
|
40761
|
+
const out = { longitude, latitude, zoom: startZoom - zoomAdjust(startLat) };
|
|
40762
|
+
out.zoom += zoomAdjust(out.latitude);
|
|
40763
|
+
return out;
|
|
40764
|
+
}
|
|
40765
|
+
};
|
|
40766
|
+
GlobeViewport.displayName = "GlobeViewport";
|
|
40767
|
+
function zoomAdjust(latitude) {
|
|
40768
|
+
const scaleAdjust = Math.PI * Math.cos(latitude * Math.PI / 180);
|
|
40769
|
+
return Math.log2(scaleAdjust);
|
|
40770
|
+
}
|
|
40771
|
+
function transformVector2(matrix, vector) {
|
|
40772
|
+
const result = vec4_exports.transformMat4([], vector, matrix);
|
|
40773
|
+
vec4_exports.scale(result, result, 1 / result[3]);
|
|
40774
|
+
return result;
|
|
40775
|
+
}
|
|
40776
|
+
|
|
40603
40777
|
// ../core/src/transitions/linear-interpolator.ts
|
|
40604
40778
|
var DEFAULT_PROPS3 = ["longitude", "latitude", "zoom", "bearing", "pitch"];
|
|
40605
40779
|
var DEFAULT_REQUIRED_PROPS = ["longitude", "latitude", "zoom"];
|
|
@@ -40627,16 +40801,21 @@ void main() {
|
|
|
40627
40801
|
const result = super.initializeProps(startProps, endProps);
|
|
40628
40802
|
const { makeViewport: makeViewport2, around } = this.opts;
|
|
40629
40803
|
if (makeViewport2 && around) {
|
|
40630
|
-
const
|
|
40631
|
-
|
|
40632
|
-
|
|
40633
|
-
|
|
40634
|
-
|
|
40635
|
-
|
|
40636
|
-
aroundPosition
|
|
40637
|
-
|
|
40638
|
-
|
|
40639
|
-
|
|
40804
|
+
const TestViewport = makeViewport2(startProps);
|
|
40805
|
+
if (TestViewport instanceof GlobeViewport) {
|
|
40806
|
+
log_default.warn("around not supported in GlobeView")();
|
|
40807
|
+
} else {
|
|
40808
|
+
const startViewport = makeViewport2(startProps);
|
|
40809
|
+
const endViewport = makeViewport2(endProps);
|
|
40810
|
+
const aroundPosition = startViewport.unproject(around);
|
|
40811
|
+
result.start.around = around;
|
|
40812
|
+
Object.assign(result.end, {
|
|
40813
|
+
around: endViewport.project(aroundPosition),
|
|
40814
|
+
aroundPosition,
|
|
40815
|
+
width: endProps.width,
|
|
40816
|
+
height: endProps.height
|
|
40817
|
+
});
|
|
40818
|
+
}
|
|
40640
40819
|
}
|
|
40641
40820
|
return result;
|
|
40642
40821
|
}
|
|
@@ -41026,6 +41205,9 @@ void main() {
|
|
|
41026
41205
|
isPanning: true
|
|
41027
41206
|
}
|
|
41028
41207
|
);
|
|
41208
|
+
if (!smooth) {
|
|
41209
|
+
this._setInteractionState({ isZooming: false, isPanning: false });
|
|
41210
|
+
}
|
|
41029
41211
|
return true;
|
|
41030
41212
|
}
|
|
41031
41213
|
_onMultiPanStart(event) {
|
|
@@ -42691,7 +42873,7 @@ void main() {
|
|
|
42691
42873
|
fill: { top: 0, left: 0, bottom: 0, right: 0 }
|
|
42692
42874
|
};
|
|
42693
42875
|
var DEFAULT_PLACEMENT = "top-left";
|
|
42694
|
-
var ROOT_CONTAINER_ID = "
|
|
42876
|
+
var ROOT_CONTAINER_ID = "root";
|
|
42695
42877
|
var WidgetManager = class {
|
|
42696
42878
|
constructor({ deck, parentElement }) {
|
|
42697
42879
|
/** Widgets added via the imperative API */
|
|
@@ -42827,11 +43009,12 @@ void main() {
|
|
|
42827
43009
|
/** Initialize new widget */
|
|
42828
43010
|
_addWidget(widget) {
|
|
42829
43011
|
const { viewId = null, placement = DEFAULT_PLACEMENT } = widget;
|
|
43012
|
+
const container = widget.props._container ?? viewId;
|
|
42830
43013
|
widget.widgetManager = this;
|
|
42831
43014
|
widget.deck = this.deck;
|
|
42832
43015
|
widget.rootElement = widget._onAdd({ deck: this.deck, viewId });
|
|
42833
43016
|
if (widget.rootElement) {
|
|
42834
|
-
this._getContainer(
|
|
43017
|
+
this._getContainer(container, placement).append(widget.rootElement);
|
|
42835
43018
|
}
|
|
42836
43019
|
widget.updateHTML();
|
|
42837
43020
|
}
|
|
@@ -42846,8 +43029,11 @@ void main() {
|
|
|
42846
43029
|
widget.widgetManager = void 0;
|
|
42847
43030
|
}
|
|
42848
43031
|
/** Get a container element based on view and placement */
|
|
42849
|
-
_getContainer(
|
|
42850
|
-
|
|
43032
|
+
_getContainer(viewIdOrContainer, placement) {
|
|
43033
|
+
if (viewIdOrContainer && typeof viewIdOrContainer !== "string") {
|
|
43034
|
+
return viewIdOrContainer;
|
|
43035
|
+
}
|
|
43036
|
+
const containerId = viewIdOrContainer || ROOT_CONTAINER_ID;
|
|
42851
43037
|
let viewContainer = this.containers[containerId];
|
|
42852
43038
|
if (!viewContainer) {
|
|
42853
43039
|
viewContainer = document.createElement("div");
|
|
@@ -42916,7 +43102,7 @@ void main() {
|
|
|
42916
43102
|
var Widget = class {
|
|
42917
43103
|
constructor(props) {
|
|
42918
43104
|
/**
|
|
42919
|
-
* The view id that this widget
|
|
43105
|
+
* The view id that this widget controls. Default `null`.
|
|
42920
43106
|
* If assigned, this widget will only respond to events occurred inside the specific view that matches this id.
|
|
42921
43107
|
*/
|
|
42922
43108
|
this.viewId = null;
|
|
@@ -43009,6 +43195,7 @@ void main() {
|
|
|
43009
43195
|
Widget.defaultProps = {
|
|
43010
43196
|
id: "widget",
|
|
43011
43197
|
style: {},
|
|
43198
|
+
_container: null,
|
|
43012
43199
|
className: ""
|
|
43013
43200
|
};
|
|
43014
43201
|
|
|
@@ -47882,159 +48069,6 @@ void main(void) {
|
|
|
47882
48069
|
};
|
|
47883
48070
|
CompositeLayer.layerName = "CompositeLayer";
|
|
47884
48071
|
|
|
47885
|
-
// ../core/src/viewports/globe-viewport.ts
|
|
47886
|
-
var DEGREES_TO_RADIANS6 = Math.PI / 180;
|
|
47887
|
-
var RADIANS_TO_DEGREES3 = 180 / Math.PI;
|
|
47888
|
-
var EARTH_RADIUS = 6370972;
|
|
47889
|
-
var GLOBE_RADIUS = 256;
|
|
47890
|
-
function getDistanceScales2() {
|
|
47891
|
-
const unitsPerMeter2 = GLOBE_RADIUS / EARTH_RADIUS;
|
|
47892
|
-
const unitsPerDegree = Math.PI / 180 * GLOBE_RADIUS;
|
|
47893
|
-
return {
|
|
47894
|
-
unitsPerMeter: [unitsPerMeter2, unitsPerMeter2, unitsPerMeter2],
|
|
47895
|
-
unitsPerMeter2: [0, 0, 0],
|
|
47896
|
-
metersPerUnit: [1 / unitsPerMeter2, 1 / unitsPerMeter2, 1 / unitsPerMeter2],
|
|
47897
|
-
unitsPerDegree: [unitsPerDegree, unitsPerDegree, unitsPerMeter2],
|
|
47898
|
-
unitsPerDegree2: [0, 0, 0],
|
|
47899
|
-
degreesPerUnit: [1 / unitsPerDegree, 1 / unitsPerDegree, 1 / unitsPerMeter2]
|
|
47900
|
-
};
|
|
47901
|
-
}
|
|
47902
|
-
var GlobeViewport = class extends Viewport {
|
|
47903
|
-
constructor(opts = {}) {
|
|
47904
|
-
const {
|
|
47905
|
-
longitude = 0,
|
|
47906
|
-
zoom = 0,
|
|
47907
|
-
// Matches Maplibre defaults
|
|
47908
|
-
// https://github.com/maplibre/maplibre-gl-js/blob/f8ab4b48d59ab8fe7b068b102538793bbdd4c848/src/geo/projection/globe_transform.ts#L632-L633
|
|
47909
|
-
nearZMultiplier = 0.5,
|
|
47910
|
-
farZMultiplier = 1,
|
|
47911
|
-
resolution = 10
|
|
47912
|
-
} = opts;
|
|
47913
|
-
let { latitude = 0, height, altitude = 1.5, fovy } = opts;
|
|
47914
|
-
latitude = Math.max(Math.min(latitude, MAX_LATITUDE), -MAX_LATITUDE);
|
|
47915
|
-
height = height || 1;
|
|
47916
|
-
if (fovy) {
|
|
47917
|
-
altitude = fovyToAltitude(fovy);
|
|
47918
|
-
} else {
|
|
47919
|
-
fovy = altitudeToFovy(altitude);
|
|
47920
|
-
}
|
|
47921
|
-
const scaleAdjust = 1 / Math.PI / Math.cos(latitude * Math.PI / 180);
|
|
47922
|
-
const scale24 = Math.pow(2, zoom) * scaleAdjust;
|
|
47923
|
-
const nearZ = opts.nearZ ?? nearZMultiplier;
|
|
47924
|
-
const farZ = opts.farZ ?? (altitude + GLOBE_RADIUS * 2 * scale24 / height) * farZMultiplier;
|
|
47925
|
-
const viewMatrix2 = new Matrix4().lookAt({ eye: [0, -altitude, 0], up: [0, 0, 1] });
|
|
47926
|
-
viewMatrix2.rotateX(latitude * DEGREES_TO_RADIANS6);
|
|
47927
|
-
viewMatrix2.rotateZ(-longitude * DEGREES_TO_RADIANS6);
|
|
47928
|
-
viewMatrix2.scale(scale24 / height);
|
|
47929
|
-
super({
|
|
47930
|
-
...opts,
|
|
47931
|
-
// x, y, width,
|
|
47932
|
-
height,
|
|
47933
|
-
// view matrix
|
|
47934
|
-
viewMatrix: viewMatrix2,
|
|
47935
|
-
longitude,
|
|
47936
|
-
latitude,
|
|
47937
|
-
zoom,
|
|
47938
|
-
// projection matrix parameters
|
|
47939
|
-
distanceScales: getDistanceScales2(),
|
|
47940
|
-
fovy,
|
|
47941
|
-
focalDistance: altitude,
|
|
47942
|
-
near: nearZ,
|
|
47943
|
-
far: farZ
|
|
47944
|
-
});
|
|
47945
|
-
this.scale = scale24;
|
|
47946
|
-
this.latitude = latitude;
|
|
47947
|
-
this.longitude = longitude;
|
|
47948
|
-
this.resolution = resolution;
|
|
47949
|
-
}
|
|
47950
|
-
get projectionMode() {
|
|
47951
|
-
return PROJECTION_MODE.GLOBE;
|
|
47952
|
-
}
|
|
47953
|
-
getDistanceScales() {
|
|
47954
|
-
return this.distanceScales;
|
|
47955
|
-
}
|
|
47956
|
-
getBounds(options = {}) {
|
|
47957
|
-
const unprojectOption = { targetZ: options.z || 0 };
|
|
47958
|
-
const left = this.unproject([0, this.height / 2], unprojectOption);
|
|
47959
|
-
const top = this.unproject([this.width / 2, 0], unprojectOption);
|
|
47960
|
-
const right = this.unproject([this.width, this.height / 2], unprojectOption);
|
|
47961
|
-
const bottom = this.unproject([this.width / 2, this.height], unprojectOption);
|
|
47962
|
-
if (right[0] < this.longitude)
|
|
47963
|
-
right[0] += 360;
|
|
47964
|
-
if (left[0] > this.longitude)
|
|
47965
|
-
left[0] -= 360;
|
|
47966
|
-
return [
|
|
47967
|
-
Math.min(left[0], right[0], top[0], bottom[0]),
|
|
47968
|
-
Math.min(left[1], right[1], top[1], bottom[1]),
|
|
47969
|
-
Math.max(left[0], right[0], top[0], bottom[0]),
|
|
47970
|
-
Math.max(left[1], right[1], top[1], bottom[1])
|
|
47971
|
-
];
|
|
47972
|
-
}
|
|
47973
|
-
unproject(xyz, { topLeft = true, targetZ } = {}) {
|
|
47974
|
-
const [x4, y5, z4] = xyz;
|
|
47975
|
-
const y22 = topLeft ? y5 : this.height - y5;
|
|
47976
|
-
const { pixelUnprojectionMatrix } = this;
|
|
47977
|
-
let coord;
|
|
47978
|
-
if (Number.isFinite(z4)) {
|
|
47979
|
-
coord = transformVector2(pixelUnprojectionMatrix, [x4, y22, z4, 1]);
|
|
47980
|
-
} else {
|
|
47981
|
-
const coord0 = transformVector2(pixelUnprojectionMatrix, [x4, y22, -1, 1]);
|
|
47982
|
-
const coord1 = transformVector2(pixelUnprojectionMatrix, [x4, y22, 1, 1]);
|
|
47983
|
-
const lt2 = ((targetZ || 0) / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
47984
|
-
const lSqr = vec3_exports.sqrLen(vec3_exports.sub([], coord0, coord1));
|
|
47985
|
-
const l0Sqr = vec3_exports.sqrLen(coord0);
|
|
47986
|
-
const l1Sqr = vec3_exports.sqrLen(coord1);
|
|
47987
|
-
const sSqr = (4 * l0Sqr * l1Sqr - (lSqr - l0Sqr - l1Sqr) ** 2) / 16;
|
|
47988
|
-
const dSqr = 4 * sSqr / lSqr;
|
|
47989
|
-
const r0 = Math.sqrt(l0Sqr - dSqr);
|
|
47990
|
-
const dr = Math.sqrt(Math.max(0, lt2 * lt2 - dSqr));
|
|
47991
|
-
const t5 = (r0 - dr) / Math.sqrt(lSqr);
|
|
47992
|
-
coord = vec3_exports.lerp([], coord0, coord1, t5);
|
|
47993
|
-
}
|
|
47994
|
-
const [X2, Y2, Z2] = this.unprojectPosition(coord);
|
|
47995
|
-
if (Number.isFinite(z4)) {
|
|
47996
|
-
return [X2, Y2, Z2];
|
|
47997
|
-
}
|
|
47998
|
-
return Number.isFinite(targetZ) ? [X2, Y2, targetZ] : [X2, Y2];
|
|
47999
|
-
}
|
|
48000
|
-
projectPosition(xyz) {
|
|
48001
|
-
const [lng, lat, Z2 = 0] = xyz;
|
|
48002
|
-
const lambda = lng * DEGREES_TO_RADIANS6;
|
|
48003
|
-
const phi = lat * DEGREES_TO_RADIANS6;
|
|
48004
|
-
const cosPhi = Math.cos(phi);
|
|
48005
|
-
const D4 = (Z2 / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
48006
|
-
return [Math.sin(lambda) * cosPhi * D4, -Math.cos(lambda) * cosPhi * D4, Math.sin(phi) * D4];
|
|
48007
|
-
}
|
|
48008
|
-
unprojectPosition(xyz) {
|
|
48009
|
-
const [x4, y5, z4] = xyz;
|
|
48010
|
-
const D4 = vec3_exports.len(xyz);
|
|
48011
|
-
const phi = Math.asin(z4 / D4);
|
|
48012
|
-
const lambda = Math.atan2(x4, -y5);
|
|
48013
|
-
const lng = lambda * RADIANS_TO_DEGREES3;
|
|
48014
|
-
const lat = phi * RADIANS_TO_DEGREES3;
|
|
48015
|
-
const Z2 = (D4 / GLOBE_RADIUS - 1) * EARTH_RADIUS;
|
|
48016
|
-
return [lng, lat, Z2];
|
|
48017
|
-
}
|
|
48018
|
-
projectFlat(xyz) {
|
|
48019
|
-
return xyz;
|
|
48020
|
-
}
|
|
48021
|
-
unprojectFlat(xyz) {
|
|
48022
|
-
return xyz;
|
|
48023
|
-
}
|
|
48024
|
-
panByPosition(coords, pixel) {
|
|
48025
|
-
const fromPosition = this.unproject(pixel);
|
|
48026
|
-
return {
|
|
48027
|
-
longitude: coords[0] - fromPosition[0] + this.longitude,
|
|
48028
|
-
latitude: coords[1] - fromPosition[1] + this.latitude
|
|
48029
|
-
};
|
|
48030
|
-
}
|
|
48031
|
-
};
|
|
48032
|
-
function transformVector2(matrix, vector) {
|
|
48033
|
-
const result = vec4_exports.transformMat4([], vector, matrix);
|
|
48034
|
-
vec4_exports.scale(result, result, 1 / result[3]);
|
|
48035
|
-
return result;
|
|
48036
|
-
}
|
|
48037
|
-
|
|
48038
48072
|
// ../core/src/viewports/orbit-viewport.ts
|
|
48039
48073
|
var DEGREES_TO_RADIANS7 = Math.PI / 180;
|
|
48040
48074
|
function getViewMatrix2({
|
|
@@ -48094,6 +48128,11 @@ void main(void) {
|
|
|
48094
48128
|
position: target2,
|
|
48095
48129
|
zoom
|
|
48096
48130
|
});
|
|
48131
|
+
this.target = target2;
|
|
48132
|
+
this.orbitAxis = orbitAxis;
|
|
48133
|
+
this.rotationX = rotationX;
|
|
48134
|
+
this.rotationOrbit = rotationOrbit;
|
|
48135
|
+
this.fovy = fovy;
|
|
48097
48136
|
this.projectedCenter = this.project(this.center);
|
|
48098
48137
|
}
|
|
48099
48138
|
unproject(xyz, { topLeft = true } = {}) {
|
|
@@ -48102,7 +48141,7 @@ void main(void) {
|
|
|
48102
48141
|
const [X2, Y2, Z2] = pixelsToWorld([x4, y22, z4], this.pixelUnprojectionMatrix);
|
|
48103
48142
|
return [X2, Y2, Z2];
|
|
48104
48143
|
}
|
|
48105
|
-
panByPosition(coords, pixel) {
|
|
48144
|
+
panByPosition(coords, pixel, startPixel) {
|
|
48106
48145
|
const p0 = this.project(coords);
|
|
48107
48146
|
const nextCenter = [
|
|
48108
48147
|
this.width / 2 + p0[0] - pixel[0],
|
|
@@ -48114,6 +48153,7 @@ void main(void) {
|
|
|
48114
48153
|
};
|
|
48115
48154
|
}
|
|
48116
48155
|
};
|
|
48156
|
+
OrbitViewport.displayName = "OrbitViewport";
|
|
48117
48157
|
|
|
48118
48158
|
// ../core/src/viewports/orthographic-viewport.ts
|
|
48119
48159
|
var viewMatrix = new Matrix4().lookAt({ eye: [0, 0, 1] });
|
|
@@ -48158,8 +48198,8 @@ void main(void) {
|
|
|
48158
48198
|
padding = null,
|
|
48159
48199
|
flipY = true
|
|
48160
48200
|
} = props;
|
|
48161
|
-
const zoomX = Array.isArray(zoom) ? zoom[0] : zoom;
|
|
48162
|
-
const zoomY = Array.isArray(zoom) ? zoom[1] : zoom;
|
|
48201
|
+
const zoomX = props.zoomX ?? (Array.isArray(zoom) ? zoom[0] : zoom);
|
|
48202
|
+
const zoomY = props.zoomY ?? (Array.isArray(zoom) ? zoom[1] : zoom);
|
|
48163
48203
|
const zoom_ = Math.min(zoomX, zoomY);
|
|
48164
48204
|
const scale24 = Math.pow(2, zoom_);
|
|
48165
48205
|
let distanceScales;
|
|
@@ -48188,6 +48228,10 @@ void main(void) {
|
|
|
48188
48228
|
zoom: zoom_,
|
|
48189
48229
|
distanceScales
|
|
48190
48230
|
});
|
|
48231
|
+
this.target = target2;
|
|
48232
|
+
this.zoomX = zoomX;
|
|
48233
|
+
this.zoomY = zoomY;
|
|
48234
|
+
this.flipY = flipY;
|
|
48191
48235
|
}
|
|
48192
48236
|
projectFlat([X2, Y2]) {
|
|
48193
48237
|
const { unitsPerMeter: unitsPerMeter2 } = this.distanceScales;
|
|
@@ -48198,7 +48242,7 @@ void main(void) {
|
|
|
48198
48242
|
return [x4 * metersPerUnit[0], y5 * metersPerUnit[1]];
|
|
48199
48243
|
}
|
|
48200
48244
|
/* Needed by LinearInterpolator */
|
|
48201
|
-
panByPosition(coords, pixel) {
|
|
48245
|
+
panByPosition(coords, pixel, startPixel) {
|
|
48202
48246
|
const fromLocation = pixelsToWorld(pixel, this.pixelUnprojectionMatrix);
|
|
48203
48247
|
const toLocation = this.projectFlat(coords);
|
|
48204
48248
|
const translate11 = vec2_exports.add([], toLocation, vec2_exports.negate([], fromLocation));
|
|
@@ -48206,6 +48250,7 @@ void main(void) {
|
|
|
48206
48250
|
return { target: this.unprojectFlat(newCenter) };
|
|
48207
48251
|
}
|
|
48208
48252
|
};
|
|
48253
|
+
OrthographicViewport.displayName = "OrthographicViewport";
|
|
48209
48254
|
|
|
48210
48255
|
// ../core/src/viewports/first-person-viewport.ts
|
|
48211
48256
|
var FirstPersonViewport = class extends Viewport {
|
|
@@ -48228,8 +48273,12 @@ void main(void) {
|
|
|
48228
48273
|
});
|
|
48229
48274
|
this.latitude = latitude;
|
|
48230
48275
|
this.longitude = longitude;
|
|
48276
|
+
this.pitch = pitch;
|
|
48277
|
+
this.bearing = bearing;
|
|
48278
|
+
this.up = up;
|
|
48231
48279
|
}
|
|
48232
48280
|
};
|
|
48281
|
+
FirstPersonViewport.displayName = "FirstPersonViewport";
|
|
48233
48282
|
|
|
48234
48283
|
// ../core/src/controllers/first-person-controller.ts
|
|
48235
48284
|
var MOVEMENT_SPEED = 20;
|
|
@@ -48920,11 +48969,50 @@ void main(void) {
|
|
|
48920
48969
|
|
|
48921
48970
|
// ../core/src/controllers/globe-controller.ts
|
|
48922
48971
|
var GlobeState = class extends MapState {
|
|
48923
|
-
|
|
48972
|
+
constructor(options) {
|
|
48973
|
+
const { startPanPos, ...mapStateOptions } = options;
|
|
48974
|
+
super(mapStateOptions);
|
|
48975
|
+
if (startPanPos !== void 0) {
|
|
48976
|
+
this._state.startPanPos = startPanPos;
|
|
48977
|
+
}
|
|
48978
|
+
}
|
|
48979
|
+
panStart({ pos }) {
|
|
48980
|
+
const { latitude, longitude, zoom } = this.getViewportProps();
|
|
48981
|
+
return this._getUpdatedState({
|
|
48982
|
+
startPanLngLat: [longitude, latitude],
|
|
48983
|
+
startPanPos: pos,
|
|
48984
|
+
startZoom: zoom
|
|
48985
|
+
});
|
|
48986
|
+
}
|
|
48987
|
+
pan({ pos, startPos }) {
|
|
48988
|
+
const state = this.getState();
|
|
48989
|
+
const startPanLngLat = state.startPanLngLat || this._unproject(startPos);
|
|
48990
|
+
if (!startPanLngLat)
|
|
48991
|
+
return this;
|
|
48992
|
+
const startZoom = state.startZoom ?? this.getViewportProps().zoom;
|
|
48993
|
+
const startPanPos = state.startPanPos || startPos;
|
|
48994
|
+
const coords = [startPanLngLat[0], startPanLngLat[1], startZoom];
|
|
48995
|
+
const viewport = this.makeViewport(this.getViewportProps());
|
|
48996
|
+
const newProps = viewport.panByPosition(coords, pos, startPanPos);
|
|
48997
|
+
return this._getUpdatedState(newProps);
|
|
48998
|
+
}
|
|
48999
|
+
panEnd() {
|
|
49000
|
+
return this._getUpdatedState({
|
|
49001
|
+
startPanLngLat: null,
|
|
49002
|
+
startPanPos: null,
|
|
49003
|
+
startZoom: null
|
|
49004
|
+
});
|
|
49005
|
+
}
|
|
49006
|
+
zoom({ scale: scale24 }) {
|
|
49007
|
+
const startZoom = this.getState().startZoom || this.getViewportProps().zoom;
|
|
49008
|
+
const zoom = startZoom + Math.log2(scale24);
|
|
49009
|
+
return this._getUpdatedState({ zoom });
|
|
49010
|
+
}
|
|
48924
49011
|
applyConstraints(props) {
|
|
48925
|
-
const { maxZoom, minZoom, zoom } = props;
|
|
48926
|
-
|
|
48927
|
-
const
|
|
49012
|
+
const { longitude, latitude, maxZoom, minZoom, zoom } = props;
|
|
49013
|
+
const ZOOM0 = zoomAdjust(0);
|
|
49014
|
+
const zoomAdjustment = zoomAdjust(latitude) - ZOOM0;
|
|
49015
|
+
props.zoom = clamp(zoom, minZoom + zoomAdjustment, maxZoom + zoomAdjustment);
|
|
48928
49016
|
if (longitude < -180 || longitude > 180) {
|
|
48929
49017
|
props.longitude = mod2(longitude + 180, 360) - 180;
|
|
48930
49018
|
}
|
|
@@ -50424,10 +50512,9 @@ void main(void) {
|
|
|
50424
50512
|
this._samplerParameters || DEFAULT_SAMPLER_PARAMETERS
|
|
50425
50513
|
);
|
|
50426
50514
|
}
|
|
50427
|
-
this.onUpdate();
|
|
50515
|
+
this.onUpdate(true);
|
|
50428
50516
|
this._canvas = this._canvas || document.createElement("canvas");
|
|
50429
50517
|
this._loadIcons(icons);
|
|
50430
|
-
this._texture?.generateMipmapsWebGL();
|
|
50431
50518
|
}
|
|
50432
50519
|
}
|
|
50433
50520
|
_loadIcons(icons) {
|
|
@@ -50439,24 +50526,28 @@ void main(void) {
|
|
|
50439
50526
|
load(icon.url, this._loadOptions).then((imageData) => {
|
|
50440
50527
|
const id = getIconId(icon);
|
|
50441
50528
|
const iconDef = this._mapping[id];
|
|
50442
|
-
const { x:
|
|
50529
|
+
const { x: initialX, y: initialY, width: maxWidth, height: maxHeight } = iconDef;
|
|
50443
50530
|
const { image, width, height } = resizeImage(
|
|
50444
50531
|
ctx2,
|
|
50445
50532
|
imageData,
|
|
50446
50533
|
maxWidth,
|
|
50447
50534
|
maxHeight
|
|
50448
50535
|
);
|
|
50536
|
+
const x4 = initialX + (maxWidth - width) / 2;
|
|
50537
|
+
const y5 = initialY + (maxHeight - height) / 2;
|
|
50449
50538
|
this._texture?.copyExternalImage({
|
|
50450
50539
|
image,
|
|
50451
|
-
x: x4
|
|
50452
|
-
y: y5
|
|
50540
|
+
x: x4,
|
|
50541
|
+
y: y5,
|
|
50453
50542
|
width,
|
|
50454
50543
|
height
|
|
50455
50544
|
});
|
|
50545
|
+
iconDef.x = x4;
|
|
50546
|
+
iconDef.y = y5;
|
|
50456
50547
|
iconDef.width = width;
|
|
50457
50548
|
iconDef.height = height;
|
|
50458
50549
|
this._texture?.generateMipmapsWebGL();
|
|
50459
|
-
this.onUpdate();
|
|
50550
|
+
this.onUpdate(width !== maxWidth || height !== maxHeight);
|
|
50460
50551
|
}).catch((error) => {
|
|
50461
50552
|
this.onError({
|
|
50462
50553
|
url: icon.url,
|
|
@@ -50639,8 +50730,13 @@ void main(void) {
|
|
|
50639
50730
|
isInstanced: true
|
|
50640
50731
|
});
|
|
50641
50732
|
}
|
|
50642
|
-
_onUpdate() {
|
|
50643
|
-
|
|
50733
|
+
_onUpdate(didFrameChange) {
|
|
50734
|
+
if (didFrameChange) {
|
|
50735
|
+
this.getAttributeManager()?.invalidate("getIcon");
|
|
50736
|
+
this.setNeedsUpdate();
|
|
50737
|
+
} else {
|
|
50738
|
+
this.setNeedsRedraw();
|
|
50739
|
+
}
|
|
50644
50740
|
}
|
|
50645
50741
|
_onError(evt) {
|
|
50646
50742
|
const onIconError = this.getCurrentLayer()?.props.onIconError;
|
|
@@ -101986,6 +102082,33 @@ void main() {
|
|
|
101986
102082
|
clearCanvas: false
|
|
101987
102083
|
});
|
|
101988
102084
|
}
|
|
102085
|
+
function drawLayerGroup(deck, map6, group, renderParameters) {
|
|
102086
|
+
let { currentViewport } = deck.userData;
|
|
102087
|
+
let clearStack = false;
|
|
102088
|
+
if (!currentViewport) {
|
|
102089
|
+
currentViewport = getViewport(deck, map6, renderParameters);
|
|
102090
|
+
deck.userData.currentViewport = currentViewport;
|
|
102091
|
+
clearStack = true;
|
|
102092
|
+
}
|
|
102093
|
+
if (!deck.isInitialized) {
|
|
102094
|
+
return;
|
|
102095
|
+
}
|
|
102096
|
+
deck._drawLayers("mapbox-repaint", {
|
|
102097
|
+
viewports: [currentViewport],
|
|
102098
|
+
layerFilter: (params) => {
|
|
102099
|
+
if (deck.props.layerFilter && !deck.props.layerFilter(params)) {
|
|
102100
|
+
return false;
|
|
102101
|
+
}
|
|
102102
|
+
const layer = params.layer;
|
|
102103
|
+
if (layer.props.beforeId === group.beforeId && layer.props.slot === group.slot) {
|
|
102104
|
+
return true;
|
|
102105
|
+
}
|
|
102106
|
+
return false;
|
|
102107
|
+
},
|
|
102108
|
+
clearStack,
|
|
102109
|
+
clearCanvas: false
|
|
102110
|
+
});
|
|
102111
|
+
}
|
|
101989
102112
|
function getProjection(map6) {
|
|
101990
102113
|
const projection = map6.getProjection?.();
|
|
101991
102114
|
const type = (
|
|
@@ -102220,11 +102343,92 @@ void main() {
|
|
|
102220
102343
|
}
|
|
102221
102344
|
}
|
|
102222
102345
|
|
|
102346
|
+
// ../mapbox/src/mapbox-layer-group.ts
|
|
102347
|
+
var MapboxLayerGroup = class {
|
|
102348
|
+
/* eslint-disable no-this-before-super */
|
|
102349
|
+
constructor(props) {
|
|
102350
|
+
assert8(props.id, "id is required");
|
|
102351
|
+
this.id = props.id;
|
|
102352
|
+
this.type = "custom";
|
|
102353
|
+
this.renderingMode = props.renderingMode || "3d";
|
|
102354
|
+
this.slot = props.slot;
|
|
102355
|
+
this.beforeId = props.beforeId;
|
|
102356
|
+
this.map = null;
|
|
102357
|
+
this.deck = null;
|
|
102358
|
+
}
|
|
102359
|
+
/* Mapbox custom layer methods */
|
|
102360
|
+
onAdd(map6, gl) {
|
|
102361
|
+
this.map = map6;
|
|
102362
|
+
this.deck = getDeckInstance({ map: map6, gl });
|
|
102363
|
+
}
|
|
102364
|
+
render(gl, renderParameters) {
|
|
102365
|
+
if (!this.deck || !this.map)
|
|
102366
|
+
return;
|
|
102367
|
+
drawLayerGroup(this.deck, this.map, this, renderParameters);
|
|
102368
|
+
}
|
|
102369
|
+
};
|
|
102370
|
+
|
|
102371
|
+
// ../mapbox/src/resolve-layer-groups.ts
|
|
102372
|
+
var UNDEFINED_BEFORE_ID2 = "__UNDEFINED__";
|
|
102373
|
+
function getLayerGroupId(layer) {
|
|
102374
|
+
if (layer.props.beforeId) {
|
|
102375
|
+
return `deck-layer-group-before:${layer.props.beforeId}`;
|
|
102376
|
+
} else if (layer.props.slot) {
|
|
102377
|
+
return `deck-layer-group-slot:${layer.props.slot}`;
|
|
102378
|
+
}
|
|
102379
|
+
return "deck-layer-group-last";
|
|
102380
|
+
}
|
|
102381
|
+
function resolveLayerGroups(map6, oldLayers, newLayers) {
|
|
102382
|
+
if (!map6 || !map6.style || !map6.style._loaded) {
|
|
102383
|
+
return;
|
|
102384
|
+
}
|
|
102385
|
+
const layers = flatten(newLayers, Boolean);
|
|
102386
|
+
if (oldLayers !== newLayers) {
|
|
102387
|
+
const prevLayers = flatten(oldLayers, Boolean);
|
|
102388
|
+
const prevLayerGroupIds = new Set(prevLayers.map((l5) => getLayerGroupId(l5)));
|
|
102389
|
+
const newLayerGroupIds = new Set(layers.map((l5) => getLayerGroupId(l5)));
|
|
102390
|
+
for (const groupId of prevLayerGroupIds) {
|
|
102391
|
+
if (!newLayerGroupIds.has(groupId)) {
|
|
102392
|
+
if (map6.getLayer(groupId)) {
|
|
102393
|
+
map6.removeLayer(groupId);
|
|
102394
|
+
}
|
|
102395
|
+
}
|
|
102396
|
+
}
|
|
102397
|
+
}
|
|
102398
|
+
const layerGroups = {};
|
|
102399
|
+
for (const layer of layers) {
|
|
102400
|
+
const groupId = getLayerGroupId(layer);
|
|
102401
|
+
const mapboxGroup = map6.getLayer(groupId);
|
|
102402
|
+
if (mapboxGroup) {
|
|
102403
|
+
const groupInstance = mapboxGroup.implementation || mapboxGroup;
|
|
102404
|
+
layerGroups[groupId] = groupInstance;
|
|
102405
|
+
} else {
|
|
102406
|
+
const newGroup = new MapboxLayerGroup({
|
|
102407
|
+
id: groupId,
|
|
102408
|
+
slot: layer.props.slot,
|
|
102409
|
+
beforeId: layer.props.beforeId
|
|
102410
|
+
});
|
|
102411
|
+
layerGroups[groupId] = newGroup;
|
|
102412
|
+
map6.addLayer(newGroup, layer.props.beforeId);
|
|
102413
|
+
}
|
|
102414
|
+
}
|
|
102415
|
+
const mapLayers = map6.style._order;
|
|
102416
|
+
for (const [groupId, group] of Object.entries(layerGroups)) {
|
|
102417
|
+
const beforeId = group.beforeId || UNDEFINED_BEFORE_ID2;
|
|
102418
|
+
const expectedGroupIndex = beforeId === UNDEFINED_BEFORE_ID2 ? mapLayers.length : mapLayers.indexOf(beforeId);
|
|
102419
|
+
const currentGropupIndex = mapLayers.indexOf(groupId);
|
|
102420
|
+
if (currentGropupIndex !== expectedGroupIndex - 1) {
|
|
102421
|
+
const moveBeforeId = beforeId === UNDEFINED_BEFORE_ID2 ? void 0 : beforeId;
|
|
102422
|
+
map6.moveLayer(groupId, moveBeforeId);
|
|
102423
|
+
}
|
|
102424
|
+
}
|
|
102425
|
+
}
|
|
102426
|
+
|
|
102223
102427
|
// ../mapbox/src/mapbox-overlay.ts
|
|
102224
102428
|
var MapboxOverlay = class {
|
|
102225
102429
|
constructor(props) {
|
|
102226
102430
|
this._handleStyleChange = () => {
|
|
102227
|
-
|
|
102431
|
+
this._resolveLayers(this._map, this._deck, this._props.layers, this._props.layers);
|
|
102228
102432
|
if (!this._map)
|
|
102229
102433
|
return;
|
|
102230
102434
|
const projection = getProjection(this._map);
|
|
@@ -102318,6 +102522,7 @@ void main() {
|
|
|
102318
102522
|
};
|
|
102319
102523
|
const { interleaved = false } = props;
|
|
102320
102524
|
this._interleaved = interleaved;
|
|
102525
|
+
this._renderLayersInGroups = props._renderLayersInGroups || false;
|
|
102321
102526
|
this._props = this.filterProps(props);
|
|
102322
102527
|
}
|
|
102323
102528
|
/** Filter out props to pass to Deck **/
|
|
@@ -102331,7 +102536,7 @@ void main() {
|
|
|
102331
102536
|
/** Update (partial) props of the underlying Deck instance. */
|
|
102332
102537
|
setProps(props) {
|
|
102333
102538
|
if (this._interleaved && props.layers) {
|
|
102334
|
-
|
|
102539
|
+
this._resolveLayers(this._map, this._deck, this._props.layers, props.layers);
|
|
102335
102540
|
}
|
|
102336
102541
|
Object.assign(this._props, this.filterProps(props));
|
|
102337
102542
|
if (this._deck && this._map) {
|
|
@@ -102398,9 +102603,16 @@ void main() {
|
|
|
102398
102603
|
})
|
|
102399
102604
|
});
|
|
102400
102605
|
map6.on("styledata", this._handleStyleChange);
|
|
102401
|
-
|
|
102606
|
+
this._resolveLayers(map6, this._deck, [], this._props.layers);
|
|
102402
102607
|
return document.createElement("div");
|
|
102403
102608
|
}
|
|
102609
|
+
_resolveLayers(map6, deck, prevLayers, newLayers) {
|
|
102610
|
+
if (this._renderLayersInGroups) {
|
|
102611
|
+
resolveLayerGroups(map6, prevLayers, newLayers);
|
|
102612
|
+
} else {
|
|
102613
|
+
resolveLayers(map6, deck, prevLayers, newLayers);
|
|
102614
|
+
}
|
|
102615
|
+
}
|
|
102404
102616
|
/** Called when the control is removed from a map */
|
|
102405
102617
|
onRemove() {
|
|
102406
102618
|
const map6 = this._map;
|
|
@@ -102430,7 +102642,7 @@ void main() {
|
|
|
102430
102642
|
}
|
|
102431
102643
|
_onRemoveInterleaved(map6) {
|
|
102432
102644
|
map6.off("styledata", this._handleStyleChange);
|
|
102433
|
-
|
|
102645
|
+
this._resolveLayers(map6, this._deck, this._props.layers, []);
|
|
102434
102646
|
removeDeckInstance(map6);
|
|
102435
102647
|
}
|
|
102436
102648
|
getDefaultPosition() {
|