deck.gl 9.2.4 → 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 +432 -205
- 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();
|
|
@@ -7164,9 +7169,19 @@ ${source4}`;
|
|
|
7164
7169
|
const { width, height, depth } = this;
|
|
7165
7170
|
const { mipLevel = 0, byteOffset = 0, x: x4 = 0, y: y5 = 0, z: z4 = 0 } = options;
|
|
7166
7171
|
const { glFormat, glType, compressed } = this;
|
|
7167
|
-
const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension,
|
|
7172
|
+
const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, z4);
|
|
7173
|
+
let unpackRowLength;
|
|
7174
|
+
if (!this.compressed) {
|
|
7175
|
+
const { bytesPerPixel } = this.device.getTextureFormatInfo(this.format);
|
|
7176
|
+
if (bytesPerPixel) {
|
|
7177
|
+
if (options.bytesPerRow % bytesPerPixel !== 0) {
|
|
7178
|
+
throw new Error(`bytesPerRow (${options.bytesPerRow}) must be a multiple of bytesPerPixel (${bytesPerPixel}) for ${this.format}`);
|
|
7179
|
+
}
|
|
7180
|
+
unpackRowLength = options.bytesPerRow / bytesPerPixel;
|
|
7181
|
+
}
|
|
7182
|
+
}
|
|
7168
7183
|
const glParameters = !this.compressed ? {
|
|
7169
|
-
[3314]:
|
|
7184
|
+
...unpackRowLength !== void 0 ? { [3314]: unpackRowLength } : {},
|
|
7170
7185
|
[32878]: options.rowsPerImage
|
|
7171
7186
|
} : {};
|
|
7172
7187
|
this.gl.bindTexture(glTarget, this.handle);
|
|
@@ -35247,9 +35262,10 @@ ${fragment}
|
|
|
35247
35262
|
*
|
|
35248
35263
|
* @param {Array} coords - world coordinates
|
|
35249
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)
|
|
35250
35266
|
* @return {Object} props of the new viewport
|
|
35251
35267
|
*/
|
|
35252
|
-
panByPosition(coords, pixel) {
|
|
35268
|
+
panByPosition(coords, pixel, startPixel) {
|
|
35253
35269
|
return null;
|
|
35254
35270
|
}
|
|
35255
35271
|
// INTERNAL METHODS
|
|
@@ -35475,7 +35491,7 @@ ${fragment}
|
|
|
35475
35491
|
addMetersToLngLat(lngLatZ, xyz) {
|
|
35476
35492
|
return addMetersToLngLat(lngLatZ, xyz);
|
|
35477
35493
|
}
|
|
35478
|
-
panByPosition(coords, pixel) {
|
|
35494
|
+
panByPosition(coords, pixel, startPixel) {
|
|
35479
35495
|
const fromLocation = pixelsToWorld(pixel, this.pixelUnprojectionMatrix);
|
|
35480
35496
|
const toLocation = this.projectFlat(coords);
|
|
35481
35497
|
const translate11 = vec2_exports.add([], toLocation, vec2_exports.negate([], fromLocation));
|
|
@@ -36393,12 +36409,12 @@ ${fragment}
|
|
|
36393
36409
|
pipeline.hash = hash;
|
|
36394
36410
|
cache3[hash] = { pipeline, useCount: 1 };
|
|
36395
36411
|
if (this.debug) {
|
|
36396
|
-
log2.
|
|
36412
|
+
log2.log(3, `${this}: ${pipeline} created, count=${cache3[hash].useCount}`)();
|
|
36397
36413
|
}
|
|
36398
36414
|
} else {
|
|
36399
36415
|
cache3[hash].useCount++;
|
|
36400
36416
|
if (this.debug) {
|
|
36401
|
-
log2.
|
|
36417
|
+
log2.log(3, `${this}: ${cache3[hash].pipeline} reused, count=${cache3[hash].useCount}, (id=${props.id})`)();
|
|
36402
36418
|
}
|
|
36403
36419
|
}
|
|
36404
36420
|
return pipeline;
|
|
@@ -36420,12 +36436,12 @@ ${fragment}
|
|
|
36420
36436
|
pipeline.hash = hash;
|
|
36421
36437
|
cache3[hash] = { pipeline, useCount: 1 };
|
|
36422
36438
|
if (this.debug) {
|
|
36423
|
-
log2.
|
|
36439
|
+
log2.log(3, `${this}: ${pipeline} created, count=${cache3[hash].useCount}`)();
|
|
36424
36440
|
}
|
|
36425
36441
|
} else {
|
|
36426
36442
|
cache3[hash].useCount++;
|
|
36427
36443
|
if (this.debug) {
|
|
36428
|
-
log2.
|
|
36444
|
+
log2.log(3, `${this}: ${cache3[hash].pipeline} reused, count=${cache3[hash].useCount}, (id=${props.id})`)();
|
|
36429
36445
|
}
|
|
36430
36446
|
}
|
|
36431
36447
|
return pipeline;
|
|
@@ -36441,13 +36457,13 @@ ${fragment}
|
|
|
36441
36457
|
if (cache3[hash].useCount === 0) {
|
|
36442
36458
|
this._destroyPipeline(pipeline);
|
|
36443
36459
|
if (this.debug) {
|
|
36444
|
-
log2.
|
|
36460
|
+
log2.log(3, `${this}: ${pipeline} released and destroyed`)();
|
|
36445
36461
|
}
|
|
36446
36462
|
} else if (cache3[hash].useCount < 0) {
|
|
36447
36463
|
log2.error(`${this}: ${pipeline} released, useCount < 0, resetting`)();
|
|
36448
36464
|
cache3[hash].useCount = 0;
|
|
36449
36465
|
} else if (this.debug) {
|
|
36450
|
-
log2.
|
|
36466
|
+
log2.log(3, `${this}: ${pipeline} released, count=${cache3[hash].useCount}`)();
|
|
36451
36467
|
}
|
|
36452
36468
|
}
|
|
36453
36469
|
// PRIVATE
|
|
@@ -36552,12 +36568,12 @@ ${fragment}
|
|
|
36552
36568
|
});
|
|
36553
36569
|
this._cache[key] = cacheEntry = { shader, useCount: 1 };
|
|
36554
36570
|
if (this.debug) {
|
|
36555
|
-
log2.
|
|
36571
|
+
log2.log(3, `${this}: Created new shader ${shader.id}`)();
|
|
36556
36572
|
}
|
|
36557
36573
|
} else {
|
|
36558
36574
|
cacheEntry.useCount++;
|
|
36559
36575
|
if (this.debug) {
|
|
36560
|
-
log2.
|
|
36576
|
+
log2.log(3, `${this}: Reusing shader ${cacheEntry.shader.id} count=${cacheEntry.useCount}`)();
|
|
36561
36577
|
}
|
|
36562
36578
|
}
|
|
36563
36579
|
return cacheEntry.shader;
|
|
@@ -36577,13 +36593,13 @@ ${fragment}
|
|
|
36577
36593
|
delete this._cache[key];
|
|
36578
36594
|
cacheEntry.shader.destroy();
|
|
36579
36595
|
if (this.debug) {
|
|
36580
|
-
log2.
|
|
36596
|
+
log2.log(3, `${this}: Releasing shader ${shader.id}, destroyed`)();
|
|
36581
36597
|
}
|
|
36582
36598
|
}
|
|
36583
36599
|
} else if (cacheEntry.useCount < 0) {
|
|
36584
36600
|
throw new Error(`ShaderFactory: Shader ${shader.id} released too many times`);
|
|
36585
36601
|
} else if (this.debug) {
|
|
36586
|
-
log2.
|
|
36602
|
+
log2.log(3, `${this}: Releasing shader ${shader.id} count=${cacheEntry.useCount}`)();
|
|
36587
36603
|
}
|
|
36588
36604
|
}
|
|
36589
36605
|
}
|
|
@@ -40590,6 +40606,174 @@ void main() {
|
|
|
40590
40606
|
}
|
|
40591
40607
|
};
|
|
40592
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
|
+
|
|
40593
40777
|
// ../core/src/transitions/linear-interpolator.ts
|
|
40594
40778
|
var DEFAULT_PROPS3 = ["longitude", "latitude", "zoom", "bearing", "pitch"];
|
|
40595
40779
|
var DEFAULT_REQUIRED_PROPS = ["longitude", "latitude", "zoom"];
|
|
@@ -40617,16 +40801,21 @@ void main() {
|
|
|
40617
40801
|
const result = super.initializeProps(startProps, endProps);
|
|
40618
40802
|
const { makeViewport: makeViewport2, around } = this.opts;
|
|
40619
40803
|
if (makeViewport2 && around) {
|
|
40620
|
-
const
|
|
40621
|
-
|
|
40622
|
-
|
|
40623
|
-
|
|
40624
|
-
|
|
40625
|
-
|
|
40626
|
-
aroundPosition
|
|
40627
|
-
|
|
40628
|
-
|
|
40629
|
-
|
|
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
|
+
}
|
|
40630
40819
|
}
|
|
40631
40820
|
return result;
|
|
40632
40821
|
}
|
|
@@ -41016,6 +41205,9 @@ void main() {
|
|
|
41016
41205
|
isPanning: true
|
|
41017
41206
|
}
|
|
41018
41207
|
);
|
|
41208
|
+
if (!smooth) {
|
|
41209
|
+
this._setInteractionState({ isZooming: false, isPanning: false });
|
|
41210
|
+
}
|
|
41019
41211
|
return true;
|
|
41020
41212
|
}
|
|
41021
41213
|
_onMultiPanStart(event) {
|
|
@@ -42681,7 +42873,7 @@ void main() {
|
|
|
42681
42873
|
fill: { top: 0, left: 0, bottom: 0, right: 0 }
|
|
42682
42874
|
};
|
|
42683
42875
|
var DEFAULT_PLACEMENT = "top-left";
|
|
42684
|
-
var ROOT_CONTAINER_ID = "
|
|
42876
|
+
var ROOT_CONTAINER_ID = "root";
|
|
42685
42877
|
var WidgetManager = class {
|
|
42686
42878
|
constructor({ deck, parentElement }) {
|
|
42687
42879
|
/** Widgets added via the imperative API */
|
|
@@ -42817,11 +43009,12 @@ void main() {
|
|
|
42817
43009
|
/** Initialize new widget */
|
|
42818
43010
|
_addWidget(widget) {
|
|
42819
43011
|
const { viewId = null, placement = DEFAULT_PLACEMENT } = widget;
|
|
43012
|
+
const container = widget.props._container ?? viewId;
|
|
42820
43013
|
widget.widgetManager = this;
|
|
42821
43014
|
widget.deck = this.deck;
|
|
42822
43015
|
widget.rootElement = widget._onAdd({ deck: this.deck, viewId });
|
|
42823
43016
|
if (widget.rootElement) {
|
|
42824
|
-
this._getContainer(
|
|
43017
|
+
this._getContainer(container, placement).append(widget.rootElement);
|
|
42825
43018
|
}
|
|
42826
43019
|
widget.updateHTML();
|
|
42827
43020
|
}
|
|
@@ -42836,8 +43029,11 @@ void main() {
|
|
|
42836
43029
|
widget.widgetManager = void 0;
|
|
42837
43030
|
}
|
|
42838
43031
|
/** Get a container element based on view and placement */
|
|
42839
|
-
_getContainer(
|
|
42840
|
-
|
|
43032
|
+
_getContainer(viewIdOrContainer, placement) {
|
|
43033
|
+
if (viewIdOrContainer && typeof viewIdOrContainer !== "string") {
|
|
43034
|
+
return viewIdOrContainer;
|
|
43035
|
+
}
|
|
43036
|
+
const containerId = viewIdOrContainer || ROOT_CONTAINER_ID;
|
|
42841
43037
|
let viewContainer = this.containers[containerId];
|
|
42842
43038
|
if (!viewContainer) {
|
|
42843
43039
|
viewContainer = document.createElement("div");
|
|
@@ -42906,7 +43102,7 @@ void main() {
|
|
|
42906
43102
|
var Widget = class {
|
|
42907
43103
|
constructor(props) {
|
|
42908
43104
|
/**
|
|
42909
|
-
* The view id that this widget
|
|
43105
|
+
* The view id that this widget controls. Default `null`.
|
|
42910
43106
|
* If assigned, this widget will only respond to events occurred inside the specific view that matches this id.
|
|
42911
43107
|
*/
|
|
42912
43108
|
this.viewId = null;
|
|
@@ -42999,6 +43195,7 @@ void main() {
|
|
|
42999
43195
|
Widget.defaultProps = {
|
|
43000
43196
|
id: "widget",
|
|
43001
43197
|
style: {},
|
|
43198
|
+
_container: null,
|
|
43002
43199
|
className: ""
|
|
43003
43200
|
};
|
|
43004
43201
|
|
|
@@ -43575,7 +43772,12 @@ void main() {
|
|
|
43575
43772
|
_createDevice(props) {
|
|
43576
43773
|
const canvasContextUserProps = this.props.deviceProps?.createCanvasContext;
|
|
43577
43774
|
const canvasContextProps = typeof canvasContextUserProps === "object" ? canvasContextUserProps : void 0;
|
|
43578
|
-
const deviceProps = {
|
|
43775
|
+
const deviceProps = {
|
|
43776
|
+
adapters: [],
|
|
43777
|
+
_cacheShaders: true,
|
|
43778
|
+
_cachePipelines: true,
|
|
43779
|
+
...props.deviceProps
|
|
43780
|
+
};
|
|
43579
43781
|
if (!deviceProps.adapters.includes(webgl2Adapter)) {
|
|
43580
43782
|
deviceProps.adapters.push(webgl2Adapter);
|
|
43581
43783
|
}
|
|
@@ -47867,159 +48069,6 @@ void main(void) {
|
|
|
47867
48069
|
};
|
|
47868
48070
|
CompositeLayer.layerName = "CompositeLayer";
|
|
47869
48071
|
|
|
47870
|
-
// ../core/src/viewports/globe-viewport.ts
|
|
47871
|
-
var DEGREES_TO_RADIANS6 = Math.PI / 180;
|
|
47872
|
-
var RADIANS_TO_DEGREES3 = 180 / Math.PI;
|
|
47873
|
-
var EARTH_RADIUS = 6370972;
|
|
47874
|
-
var GLOBE_RADIUS = 256;
|
|
47875
|
-
function getDistanceScales2() {
|
|
47876
|
-
const unitsPerMeter2 = GLOBE_RADIUS / EARTH_RADIUS;
|
|
47877
|
-
const unitsPerDegree = Math.PI / 180 * GLOBE_RADIUS;
|
|
47878
|
-
return {
|
|
47879
|
-
unitsPerMeter: [unitsPerMeter2, unitsPerMeter2, unitsPerMeter2],
|
|
47880
|
-
unitsPerMeter2: [0, 0, 0],
|
|
47881
|
-
metersPerUnit: [1 / unitsPerMeter2, 1 / unitsPerMeter2, 1 / unitsPerMeter2],
|
|
47882
|
-
unitsPerDegree: [unitsPerDegree, unitsPerDegree, unitsPerMeter2],
|
|
47883
|
-
unitsPerDegree2: [0, 0, 0],
|
|
47884
|
-
degreesPerUnit: [1 / unitsPerDegree, 1 / unitsPerDegree, 1 / unitsPerMeter2]
|
|
47885
|
-
};
|
|
47886
|
-
}
|
|
47887
|
-
var GlobeViewport = class extends Viewport {
|
|
47888
|
-
constructor(opts = {}) {
|
|
47889
|
-
const {
|
|
47890
|
-
longitude = 0,
|
|
47891
|
-
zoom = 0,
|
|
47892
|
-
// Matches Maplibre defaults
|
|
47893
|
-
// https://github.com/maplibre/maplibre-gl-js/blob/f8ab4b48d59ab8fe7b068b102538793bbdd4c848/src/geo/projection/globe_transform.ts#L632-L633
|
|
47894
|
-
nearZMultiplier = 0.5,
|
|
47895
|
-
farZMultiplier = 1,
|
|
47896
|
-
resolution = 10
|
|
47897
|
-
} = opts;
|
|
47898
|
-
let { latitude = 0, height, altitude = 1.5, fovy } = opts;
|
|
47899
|
-
latitude = Math.max(Math.min(latitude, MAX_LATITUDE), -MAX_LATITUDE);
|
|
47900
|
-
height = height || 1;
|
|
47901
|
-
if (fovy) {
|
|
47902
|
-
altitude = fovyToAltitude(fovy);
|
|
47903
|
-
} else {
|
|
47904
|
-
fovy = altitudeToFovy(altitude);
|
|
47905
|
-
}
|
|
47906
|
-
const scaleAdjust = 1 / Math.PI / Math.cos(latitude * Math.PI / 180);
|
|
47907
|
-
const scale24 = Math.pow(2, zoom) * scaleAdjust;
|
|
47908
|
-
const nearZ = opts.nearZ ?? nearZMultiplier;
|
|
47909
|
-
const farZ = opts.farZ ?? (altitude + GLOBE_RADIUS * 2 * scale24 / height) * farZMultiplier;
|
|
47910
|
-
const viewMatrix2 = new Matrix4().lookAt({ eye: [0, -altitude, 0], up: [0, 0, 1] });
|
|
47911
|
-
viewMatrix2.rotateX(latitude * DEGREES_TO_RADIANS6);
|
|
47912
|
-
viewMatrix2.rotateZ(-longitude * DEGREES_TO_RADIANS6);
|
|
47913
|
-
viewMatrix2.scale(scale24 / height);
|
|
47914
|
-
super({
|
|
47915
|
-
...opts,
|
|
47916
|
-
// x, y, width,
|
|
47917
|
-
height,
|
|
47918
|
-
// view matrix
|
|
47919
|
-
viewMatrix: viewMatrix2,
|
|
47920
|
-
longitude,
|
|
47921
|
-
latitude,
|
|
47922
|
-
zoom,
|
|
47923
|
-
// projection matrix parameters
|
|
47924
|
-
distanceScales: getDistanceScales2(),
|
|
47925
|
-
fovy,
|
|
47926
|
-
focalDistance: altitude,
|
|
47927
|
-
near: nearZ,
|
|
47928
|
-
far: farZ
|
|
47929
|
-
});
|
|
47930
|
-
this.scale = scale24;
|
|
47931
|
-
this.latitude = latitude;
|
|
47932
|
-
this.longitude = longitude;
|
|
47933
|
-
this.resolution = resolution;
|
|
47934
|
-
}
|
|
47935
|
-
get projectionMode() {
|
|
47936
|
-
return PROJECTION_MODE.GLOBE;
|
|
47937
|
-
}
|
|
47938
|
-
getDistanceScales() {
|
|
47939
|
-
return this.distanceScales;
|
|
47940
|
-
}
|
|
47941
|
-
getBounds(options = {}) {
|
|
47942
|
-
const unprojectOption = { targetZ: options.z || 0 };
|
|
47943
|
-
const left = this.unproject([0, this.height / 2], unprojectOption);
|
|
47944
|
-
const top = this.unproject([this.width / 2, 0], unprojectOption);
|
|
47945
|
-
const right = this.unproject([this.width, this.height / 2], unprojectOption);
|
|
47946
|
-
const bottom = this.unproject([this.width / 2, this.height], unprojectOption);
|
|
47947
|
-
if (right[0] < this.longitude)
|
|
47948
|
-
right[0] += 360;
|
|
47949
|
-
if (left[0] > this.longitude)
|
|
47950
|
-
left[0] -= 360;
|
|
47951
|
-
return [
|
|
47952
|
-
Math.min(left[0], right[0], top[0], bottom[0]),
|
|
47953
|
-
Math.min(left[1], right[1], top[1], bottom[1]),
|
|
47954
|
-
Math.max(left[0], right[0], top[0], bottom[0]),
|
|
47955
|
-
Math.max(left[1], right[1], top[1], bottom[1])
|
|
47956
|
-
];
|
|
47957
|
-
}
|
|
47958
|
-
unproject(xyz, { topLeft = true, targetZ } = {}) {
|
|
47959
|
-
const [x4, y5, z4] = xyz;
|
|
47960
|
-
const y22 = topLeft ? y5 : this.height - y5;
|
|
47961
|
-
const { pixelUnprojectionMatrix } = this;
|
|
47962
|
-
let coord;
|
|
47963
|
-
if (Number.isFinite(z4)) {
|
|
47964
|
-
coord = transformVector2(pixelUnprojectionMatrix, [x4, y22, z4, 1]);
|
|
47965
|
-
} else {
|
|
47966
|
-
const coord0 = transformVector2(pixelUnprojectionMatrix, [x4, y22, -1, 1]);
|
|
47967
|
-
const coord1 = transformVector2(pixelUnprojectionMatrix, [x4, y22, 1, 1]);
|
|
47968
|
-
const lt2 = ((targetZ || 0) / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
47969
|
-
const lSqr = vec3_exports.sqrLen(vec3_exports.sub([], coord0, coord1));
|
|
47970
|
-
const l0Sqr = vec3_exports.sqrLen(coord0);
|
|
47971
|
-
const l1Sqr = vec3_exports.sqrLen(coord1);
|
|
47972
|
-
const sSqr = (4 * l0Sqr * l1Sqr - (lSqr - l0Sqr - l1Sqr) ** 2) / 16;
|
|
47973
|
-
const dSqr = 4 * sSqr / lSqr;
|
|
47974
|
-
const r0 = Math.sqrt(l0Sqr - dSqr);
|
|
47975
|
-
const dr = Math.sqrt(Math.max(0, lt2 * lt2 - dSqr));
|
|
47976
|
-
const t5 = (r0 - dr) / Math.sqrt(lSqr);
|
|
47977
|
-
coord = vec3_exports.lerp([], coord0, coord1, t5);
|
|
47978
|
-
}
|
|
47979
|
-
const [X2, Y2, Z2] = this.unprojectPosition(coord);
|
|
47980
|
-
if (Number.isFinite(z4)) {
|
|
47981
|
-
return [X2, Y2, Z2];
|
|
47982
|
-
}
|
|
47983
|
-
return Number.isFinite(targetZ) ? [X2, Y2, targetZ] : [X2, Y2];
|
|
47984
|
-
}
|
|
47985
|
-
projectPosition(xyz) {
|
|
47986
|
-
const [lng, lat, Z2 = 0] = xyz;
|
|
47987
|
-
const lambda = lng * DEGREES_TO_RADIANS6;
|
|
47988
|
-
const phi = lat * DEGREES_TO_RADIANS6;
|
|
47989
|
-
const cosPhi = Math.cos(phi);
|
|
47990
|
-
const D4 = (Z2 / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
47991
|
-
return [Math.sin(lambda) * cosPhi * D4, -Math.cos(lambda) * cosPhi * D4, Math.sin(phi) * D4];
|
|
47992
|
-
}
|
|
47993
|
-
unprojectPosition(xyz) {
|
|
47994
|
-
const [x4, y5, z4] = xyz;
|
|
47995
|
-
const D4 = vec3_exports.len(xyz);
|
|
47996
|
-
const phi = Math.asin(z4 / D4);
|
|
47997
|
-
const lambda = Math.atan2(x4, -y5);
|
|
47998
|
-
const lng = lambda * RADIANS_TO_DEGREES3;
|
|
47999
|
-
const lat = phi * RADIANS_TO_DEGREES3;
|
|
48000
|
-
const Z2 = (D4 / GLOBE_RADIUS - 1) * EARTH_RADIUS;
|
|
48001
|
-
return [lng, lat, Z2];
|
|
48002
|
-
}
|
|
48003
|
-
projectFlat(xyz) {
|
|
48004
|
-
return xyz;
|
|
48005
|
-
}
|
|
48006
|
-
unprojectFlat(xyz) {
|
|
48007
|
-
return xyz;
|
|
48008
|
-
}
|
|
48009
|
-
panByPosition(coords, pixel) {
|
|
48010
|
-
const fromPosition = this.unproject(pixel);
|
|
48011
|
-
return {
|
|
48012
|
-
longitude: coords[0] - fromPosition[0] + this.longitude,
|
|
48013
|
-
latitude: coords[1] - fromPosition[1] + this.latitude
|
|
48014
|
-
};
|
|
48015
|
-
}
|
|
48016
|
-
};
|
|
48017
|
-
function transformVector2(matrix, vector) {
|
|
48018
|
-
const result = vec4_exports.transformMat4([], vector, matrix);
|
|
48019
|
-
vec4_exports.scale(result, result, 1 / result[3]);
|
|
48020
|
-
return result;
|
|
48021
|
-
}
|
|
48022
|
-
|
|
48023
48072
|
// ../core/src/viewports/orbit-viewport.ts
|
|
48024
48073
|
var DEGREES_TO_RADIANS7 = Math.PI / 180;
|
|
48025
48074
|
function getViewMatrix2({
|
|
@@ -48079,6 +48128,11 @@ void main(void) {
|
|
|
48079
48128
|
position: target2,
|
|
48080
48129
|
zoom
|
|
48081
48130
|
});
|
|
48131
|
+
this.target = target2;
|
|
48132
|
+
this.orbitAxis = orbitAxis;
|
|
48133
|
+
this.rotationX = rotationX;
|
|
48134
|
+
this.rotationOrbit = rotationOrbit;
|
|
48135
|
+
this.fovy = fovy;
|
|
48082
48136
|
this.projectedCenter = this.project(this.center);
|
|
48083
48137
|
}
|
|
48084
48138
|
unproject(xyz, { topLeft = true } = {}) {
|
|
@@ -48087,7 +48141,7 @@ void main(void) {
|
|
|
48087
48141
|
const [X2, Y2, Z2] = pixelsToWorld([x4, y22, z4], this.pixelUnprojectionMatrix);
|
|
48088
48142
|
return [X2, Y2, Z2];
|
|
48089
48143
|
}
|
|
48090
|
-
panByPosition(coords, pixel) {
|
|
48144
|
+
panByPosition(coords, pixel, startPixel) {
|
|
48091
48145
|
const p0 = this.project(coords);
|
|
48092
48146
|
const nextCenter = [
|
|
48093
48147
|
this.width / 2 + p0[0] - pixel[0],
|
|
@@ -48099,6 +48153,7 @@ void main(void) {
|
|
|
48099
48153
|
};
|
|
48100
48154
|
}
|
|
48101
48155
|
};
|
|
48156
|
+
OrbitViewport.displayName = "OrbitViewport";
|
|
48102
48157
|
|
|
48103
48158
|
// ../core/src/viewports/orthographic-viewport.ts
|
|
48104
48159
|
var viewMatrix = new Matrix4().lookAt({ eye: [0, 0, 1] });
|
|
@@ -48143,8 +48198,8 @@ void main(void) {
|
|
|
48143
48198
|
padding = null,
|
|
48144
48199
|
flipY = true
|
|
48145
48200
|
} = props;
|
|
48146
|
-
const zoomX = Array.isArray(zoom) ? zoom[0] : zoom;
|
|
48147
|
-
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);
|
|
48148
48203
|
const zoom_ = Math.min(zoomX, zoomY);
|
|
48149
48204
|
const scale24 = Math.pow(2, zoom_);
|
|
48150
48205
|
let distanceScales;
|
|
@@ -48173,6 +48228,10 @@ void main(void) {
|
|
|
48173
48228
|
zoom: zoom_,
|
|
48174
48229
|
distanceScales
|
|
48175
48230
|
});
|
|
48231
|
+
this.target = target2;
|
|
48232
|
+
this.zoomX = zoomX;
|
|
48233
|
+
this.zoomY = zoomY;
|
|
48234
|
+
this.flipY = flipY;
|
|
48176
48235
|
}
|
|
48177
48236
|
projectFlat([X2, Y2]) {
|
|
48178
48237
|
const { unitsPerMeter: unitsPerMeter2 } = this.distanceScales;
|
|
@@ -48183,7 +48242,7 @@ void main(void) {
|
|
|
48183
48242
|
return [x4 * metersPerUnit[0], y5 * metersPerUnit[1]];
|
|
48184
48243
|
}
|
|
48185
48244
|
/* Needed by LinearInterpolator */
|
|
48186
|
-
panByPosition(coords, pixel) {
|
|
48245
|
+
panByPosition(coords, pixel, startPixel) {
|
|
48187
48246
|
const fromLocation = pixelsToWorld(pixel, this.pixelUnprojectionMatrix);
|
|
48188
48247
|
const toLocation = this.projectFlat(coords);
|
|
48189
48248
|
const translate11 = vec2_exports.add([], toLocation, vec2_exports.negate([], fromLocation));
|
|
@@ -48191,6 +48250,7 @@ void main(void) {
|
|
|
48191
48250
|
return { target: this.unprojectFlat(newCenter) };
|
|
48192
48251
|
}
|
|
48193
48252
|
};
|
|
48253
|
+
OrthographicViewport.displayName = "OrthographicViewport";
|
|
48194
48254
|
|
|
48195
48255
|
// ../core/src/viewports/first-person-viewport.ts
|
|
48196
48256
|
var FirstPersonViewport = class extends Viewport {
|
|
@@ -48213,8 +48273,12 @@ void main(void) {
|
|
|
48213
48273
|
});
|
|
48214
48274
|
this.latitude = latitude;
|
|
48215
48275
|
this.longitude = longitude;
|
|
48276
|
+
this.pitch = pitch;
|
|
48277
|
+
this.bearing = bearing;
|
|
48278
|
+
this.up = up;
|
|
48216
48279
|
}
|
|
48217
48280
|
};
|
|
48281
|
+
FirstPersonViewport.displayName = "FirstPersonViewport";
|
|
48218
48282
|
|
|
48219
48283
|
// ../core/src/controllers/first-person-controller.ts
|
|
48220
48284
|
var MOVEMENT_SPEED = 20;
|
|
@@ -48905,11 +48969,50 @@ void main(void) {
|
|
|
48905
48969
|
|
|
48906
48970
|
// ../core/src/controllers/globe-controller.ts
|
|
48907
48971
|
var GlobeState = class extends MapState {
|
|
48908
|
-
|
|
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
|
+
}
|
|
48909
49011
|
applyConstraints(props) {
|
|
48910
|
-
const { maxZoom, minZoom, zoom } = props;
|
|
48911
|
-
|
|
48912
|
-
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);
|
|
48913
49016
|
if (longitude < -180 || longitude > 180) {
|
|
48914
49017
|
props.longitude = mod2(longitude + 180, 360) - 180;
|
|
48915
49018
|
}
|
|
@@ -50409,10 +50512,9 @@ void main(void) {
|
|
|
50409
50512
|
this._samplerParameters || DEFAULT_SAMPLER_PARAMETERS
|
|
50410
50513
|
);
|
|
50411
50514
|
}
|
|
50412
|
-
this.onUpdate();
|
|
50515
|
+
this.onUpdate(true);
|
|
50413
50516
|
this._canvas = this._canvas || document.createElement("canvas");
|
|
50414
50517
|
this._loadIcons(icons);
|
|
50415
|
-
this._texture?.generateMipmapsWebGL();
|
|
50416
50518
|
}
|
|
50417
50519
|
}
|
|
50418
50520
|
_loadIcons(icons) {
|
|
@@ -50424,24 +50526,28 @@ void main(void) {
|
|
|
50424
50526
|
load(icon.url, this._loadOptions).then((imageData) => {
|
|
50425
50527
|
const id = getIconId(icon);
|
|
50426
50528
|
const iconDef = this._mapping[id];
|
|
50427
|
-
const { x:
|
|
50529
|
+
const { x: initialX, y: initialY, width: maxWidth, height: maxHeight } = iconDef;
|
|
50428
50530
|
const { image, width, height } = resizeImage(
|
|
50429
50531
|
ctx2,
|
|
50430
50532
|
imageData,
|
|
50431
50533
|
maxWidth,
|
|
50432
50534
|
maxHeight
|
|
50433
50535
|
);
|
|
50536
|
+
const x4 = initialX + (maxWidth - width) / 2;
|
|
50537
|
+
const y5 = initialY + (maxHeight - height) / 2;
|
|
50434
50538
|
this._texture?.copyExternalImage({
|
|
50435
50539
|
image,
|
|
50436
|
-
x: x4
|
|
50437
|
-
y: y5
|
|
50540
|
+
x: x4,
|
|
50541
|
+
y: y5,
|
|
50438
50542
|
width,
|
|
50439
50543
|
height
|
|
50440
50544
|
});
|
|
50545
|
+
iconDef.x = x4;
|
|
50546
|
+
iconDef.y = y5;
|
|
50441
50547
|
iconDef.width = width;
|
|
50442
50548
|
iconDef.height = height;
|
|
50443
50549
|
this._texture?.generateMipmapsWebGL();
|
|
50444
|
-
this.onUpdate();
|
|
50550
|
+
this.onUpdate(width !== maxWidth || height !== maxHeight);
|
|
50445
50551
|
}).catch((error) => {
|
|
50446
50552
|
this.onError({
|
|
50447
50553
|
url: icon.url,
|
|
@@ -50624,8 +50730,13 @@ void main(void) {
|
|
|
50624
50730
|
isInstanced: true
|
|
50625
50731
|
});
|
|
50626
50732
|
}
|
|
50627
|
-
_onUpdate() {
|
|
50628
|
-
|
|
50733
|
+
_onUpdate(didFrameChange) {
|
|
50734
|
+
if (didFrameChange) {
|
|
50735
|
+
this.getAttributeManager()?.invalidate("getIcon");
|
|
50736
|
+
this.setNeedsUpdate();
|
|
50737
|
+
} else {
|
|
50738
|
+
this.setNeedsRedraw();
|
|
50739
|
+
}
|
|
50629
50740
|
}
|
|
50630
50741
|
_onError(evt) {
|
|
50631
50742
|
const onIconError = this.getCurrentLayer()?.props.onIconError;
|
|
@@ -101971,6 +102082,33 @@ void main() {
|
|
|
101971
102082
|
clearCanvas: false
|
|
101972
102083
|
});
|
|
101973
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
|
+
}
|
|
101974
102112
|
function getProjection(map6) {
|
|
101975
102113
|
const projection = map6.getProjection?.();
|
|
101976
102114
|
const type = (
|
|
@@ -102205,11 +102343,92 @@ void main() {
|
|
|
102205
102343
|
}
|
|
102206
102344
|
}
|
|
102207
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
|
+
|
|
102208
102427
|
// ../mapbox/src/mapbox-overlay.ts
|
|
102209
102428
|
var MapboxOverlay = class {
|
|
102210
102429
|
constructor(props) {
|
|
102211
102430
|
this._handleStyleChange = () => {
|
|
102212
|
-
|
|
102431
|
+
this._resolveLayers(this._map, this._deck, this._props.layers, this._props.layers);
|
|
102213
102432
|
if (!this._map)
|
|
102214
102433
|
return;
|
|
102215
102434
|
const projection = getProjection(this._map);
|
|
@@ -102303,6 +102522,7 @@ void main() {
|
|
|
102303
102522
|
};
|
|
102304
102523
|
const { interleaved = false } = props;
|
|
102305
102524
|
this._interleaved = interleaved;
|
|
102525
|
+
this._renderLayersInGroups = props._renderLayersInGroups || false;
|
|
102306
102526
|
this._props = this.filterProps(props);
|
|
102307
102527
|
}
|
|
102308
102528
|
/** Filter out props to pass to Deck **/
|
|
@@ -102316,7 +102536,7 @@ void main() {
|
|
|
102316
102536
|
/** Update (partial) props of the underlying Deck instance. */
|
|
102317
102537
|
setProps(props) {
|
|
102318
102538
|
if (this._interleaved && props.layers) {
|
|
102319
|
-
|
|
102539
|
+
this._resolveLayers(this._map, this._deck, this._props.layers, props.layers);
|
|
102320
102540
|
}
|
|
102321
102541
|
Object.assign(this._props, this.filterProps(props));
|
|
102322
102542
|
if (this._deck && this._map) {
|
|
@@ -102383,9 +102603,16 @@ void main() {
|
|
|
102383
102603
|
})
|
|
102384
102604
|
});
|
|
102385
102605
|
map6.on("styledata", this._handleStyleChange);
|
|
102386
|
-
|
|
102606
|
+
this._resolveLayers(map6, this._deck, [], this._props.layers);
|
|
102387
102607
|
return document.createElement("div");
|
|
102388
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
|
+
}
|
|
102389
102616
|
/** Called when the control is removed from a map */
|
|
102390
102617
|
onRemove() {
|
|
102391
102618
|
const map6 = this._map;
|
|
@@ -102415,7 +102642,7 @@ void main() {
|
|
|
102415
102642
|
}
|
|
102416
102643
|
_onRemoveInterleaved(map6) {
|
|
102417
102644
|
map6.off("styledata", this._handleStyleChange);
|
|
102418
|
-
|
|
102645
|
+
this._resolveLayers(map6, this._deck, this._props.layers, []);
|
|
102419
102646
|
removeDeckInstance(map6);
|
|
102420
102647
|
}
|
|
102421
102648
|
getDefaultPosition() {
|