@deck.gl/arcgis 9.4.0-beta.1 → 9.4.0-beta.3
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 +46 -201
- package/dist/index.cjs +72 -232
- package/dist/index.cjs.map +3 -3
- package/dist.min.js +4 -4
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -719,12 +719,12 @@ function calculateViewportUniforms({
|
|
|
719
719
|
}
|
|
720
720
|
}
|
|
721
721
|
if (viewport.projectionMode === PROJECTION_MODE.GLOBE && coordinateSystem === "meter-offsets") {
|
|
722
|
-
const
|
|
723
|
-
const
|
|
722
|
+
const EARTH_RADIUS = 6370972;
|
|
723
|
+
const GLOBE_RADIUS = 256;
|
|
724
724
|
const lambda = coordinateOrigin[0] * Math.PI / 180;
|
|
725
725
|
const phi = coordinateOrigin[1] * Math.PI / 180;
|
|
726
726
|
const cosPhi = Math.cos(phi);
|
|
727
|
-
const D = ((coordinateOrigin[2] || 0) /
|
|
727
|
+
const D = ((coordinateOrigin[2] || 0) / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
728
728
|
uniforms.commonOrigin = [
|
|
729
729
|
Math.sin(lambda) * cosPhi * D,
|
|
730
730
|
-Math.cos(lambda) * cosPhi * D,
|
|
@@ -912,7 +912,7 @@ fn project_mercator_(lnglat: vec2<f32>) -> vec2<f32> {
|
|
|
912
912
|
let y = clamp(lnglat.y, -89.9, 89.9);
|
|
913
913
|
return vec2<f32>(
|
|
914
914
|
radians(x) + PI,
|
|
915
|
-
PI + log(
|
|
915
|
+
PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))
|
|
916
916
|
) * WORLD_SCALE;
|
|
917
917
|
}
|
|
918
918
|
|
|
@@ -2525,8 +2525,8 @@ var _Viewport = class _Viewport {
|
|
|
2525
2525
|
}
|
|
2526
2526
|
return PROJECTION_MODE.IDENTITY;
|
|
2527
2527
|
}
|
|
2528
|
-
// Two viewports are equal if
|
|
2529
|
-
//
|
|
2528
|
+
// Two viewports are equal if their dimensions, common-space scale, and
|
|
2529
|
+
// view and projection matrices are (approximately) equal.
|
|
2530
2530
|
equals(viewport) {
|
|
2531
2531
|
if (!(viewport instanceof _Viewport)) {
|
|
2532
2532
|
return false;
|
|
@@ -2534,7 +2534,7 @@ var _Viewport = class _Viewport {
|
|
|
2534
2534
|
if (this === viewport) {
|
|
2535
2535
|
return true;
|
|
2536
2536
|
}
|
|
2537
|
-
return viewport.width === this.width && viewport.height === this.height && viewport.scale === this.scale && (0, import_core7.equals)(viewport.projectionMatrix, this.projectionMatrix) && (0, import_core7.equals)(viewport.viewMatrix, this.viewMatrix);
|
|
2537
|
+
return viewport.width === this.width && viewport.height === this.height && viewport.scale === this.scale && viewport.projectionMode === this.projectionMode && viewport.resolution === this.resolution && (0, import_core7.equals)(viewport.distanceScales.unitsPerMeter, this.distanceScales.unitsPerMeter) && (0, import_core7.equals)(viewport.projectionMatrix, this.projectionMatrix) && (0, import_core7.equals)(viewport.viewMatrix, this.viewMatrix);
|
|
2538
2538
|
}
|
|
2539
2539
|
/**
|
|
2540
2540
|
* Projects xyz (possibly latitude and longitude) to pixel coordinates in window
|
|
@@ -2871,6 +2871,10 @@ var _WebMercatorViewport = class _WebMercatorViewport extends Viewport {
|
|
|
2871
2871
|
}
|
|
2872
2872
|
return this._subViewports;
|
|
2873
2873
|
}
|
|
2874
|
+
/** Returns whether two Web Mercator viewports use the same projection settings. */
|
|
2875
|
+
equals(viewport) {
|
|
2876
|
+
return viewport instanceof _WebMercatorViewport && viewport._pseudoMeters === this._pseudoMeters && super.equals(viewport);
|
|
2877
|
+
}
|
|
2874
2878
|
projectPosition(xyz) {
|
|
2875
2879
|
if (this._pseudoMeters) {
|
|
2876
2880
|
return super.projectPosition(xyz);
|
|
@@ -4253,7 +4257,7 @@ var View = class {
|
|
|
4253
4257
|
};
|
|
4254
4258
|
|
|
4255
4259
|
// ../core/src/controllers/map-controller.ts
|
|
4256
|
-
var
|
|
4260
|
+
var import_core12 = require("@math.gl/core");
|
|
4257
4261
|
|
|
4258
4262
|
// ../core/src/transitions/transition.ts
|
|
4259
4263
|
var Transition = class {
|
|
@@ -4565,185 +4569,7 @@ var TransitionInterpolator = class {
|
|
|
4565
4569
|
};
|
|
4566
4570
|
|
|
4567
4571
|
// ../core/src/transitions/linear-interpolator.ts
|
|
4568
|
-
var import_core13 = require("@math.gl/core");
|
|
4569
|
-
|
|
4570
|
-
// ../core/src/viewports/globe-viewport.ts
|
|
4571
4572
|
var import_core11 = require("@math.gl/core");
|
|
4572
|
-
var import_web_mercator4 = require("@math.gl/web-mercator");
|
|
4573
|
-
var import_core12 = require("@math.gl/core");
|
|
4574
|
-
var import_web_mercator5 = require("@math.gl/web-mercator");
|
|
4575
|
-
var DEGREES_TO_RADIANS2 = Math.PI / 180;
|
|
4576
|
-
var RADIANS_TO_DEGREES = 180 / Math.PI;
|
|
4577
|
-
var EARTH_RADIUS = 6370972;
|
|
4578
|
-
var GLOBE_RADIUS = 256;
|
|
4579
|
-
function getDistanceScales2() {
|
|
4580
|
-
const unitsPerMeter2 = GLOBE_RADIUS / EARTH_RADIUS;
|
|
4581
|
-
const unitsPerDegree = Math.PI / 180 * GLOBE_RADIUS;
|
|
4582
|
-
return {
|
|
4583
|
-
unitsPerMeter: [unitsPerMeter2, unitsPerMeter2, unitsPerMeter2],
|
|
4584
|
-
unitsPerMeter2: [0, 0, 0],
|
|
4585
|
-
metersPerUnit: [1 / unitsPerMeter2, 1 / unitsPerMeter2, 1 / unitsPerMeter2],
|
|
4586
|
-
unitsPerDegree: [unitsPerDegree, unitsPerDegree, unitsPerMeter2],
|
|
4587
|
-
unitsPerDegree2: [0, 0, 0],
|
|
4588
|
-
degreesPerUnit: [1 / unitsPerDegree, 1 / unitsPerDegree, 1 / unitsPerMeter2]
|
|
4589
|
-
};
|
|
4590
|
-
}
|
|
4591
|
-
var GlobeViewport = class extends Viewport {
|
|
4592
|
-
constructor(opts = {}) {
|
|
4593
|
-
const {
|
|
4594
|
-
longitude = 0,
|
|
4595
|
-
bearing = 0,
|
|
4596
|
-
pitch = 0,
|
|
4597
|
-
zoom = 0,
|
|
4598
|
-
// Matches Maplibre defaults
|
|
4599
|
-
// https://github.com/maplibre/maplibre-gl-js/blob/f8ab4b48d59ab8fe7b068b102538793bbdd4c848/src/geo/projection/globe_transform.ts#L632-L633
|
|
4600
|
-
nearZMultiplier = 0.5,
|
|
4601
|
-
farZMultiplier = 1,
|
|
4602
|
-
resolution = 10
|
|
4603
|
-
} = opts;
|
|
4604
|
-
let { latitude = 0, height, altitude = 1.5, fovy } = opts;
|
|
4605
|
-
latitude = Math.max(Math.min(latitude, 90), -90);
|
|
4606
|
-
height = height || 1;
|
|
4607
|
-
if (fovy) {
|
|
4608
|
-
altitude = (0, import_web_mercator4.fovyToAltitude)(fovy);
|
|
4609
|
-
} else {
|
|
4610
|
-
fovy = (0, import_web_mercator4.altitudeToFovy)(altitude);
|
|
4611
|
-
}
|
|
4612
|
-
const scaleLatitude = Math.max(Math.min(latitude, import_web_mercator5.MAX_LATITUDE), -import_web_mercator5.MAX_LATITUDE);
|
|
4613
|
-
const scale = Math.pow(2, zoom - zoomAdjust(scaleLatitude));
|
|
4614
|
-
const pitchRadians = pitch * DEGREES_TO_RADIANS2;
|
|
4615
|
-
const nearZ = opts.nearZ ?? nearZMultiplier;
|
|
4616
|
-
const farZ = opts.farZ ?? (altitude + GLOBE_RADIUS * 2 * scale / height / Math.max(Math.cos(pitchRadians), 0.1)) * farZMultiplier;
|
|
4617
|
-
const viewMatrix = new import_core11.Matrix4().lookAt({ eye: [0, -altitude, 0], up: [0, 0, 1] }).rotateX(-pitchRadians).rotateY(-bearing * DEGREES_TO_RADIANS2).rotateX(latitude * DEGREES_TO_RADIANS2).rotateZ(-longitude * DEGREES_TO_RADIANS2).scale(scale / height);
|
|
4618
|
-
super({
|
|
4619
|
-
...opts,
|
|
4620
|
-
// x, y, width,
|
|
4621
|
-
height,
|
|
4622
|
-
// view matrix
|
|
4623
|
-
viewMatrix,
|
|
4624
|
-
longitude,
|
|
4625
|
-
latitude,
|
|
4626
|
-
zoom,
|
|
4627
|
-
// projection matrix parameters
|
|
4628
|
-
distanceScales: getDistanceScales2(),
|
|
4629
|
-
fovy,
|
|
4630
|
-
focalDistance: altitude,
|
|
4631
|
-
near: nearZ,
|
|
4632
|
-
far: farZ
|
|
4633
|
-
});
|
|
4634
|
-
this.scale = scale;
|
|
4635
|
-
this.latitude = latitude;
|
|
4636
|
-
this.longitude = longitude;
|
|
4637
|
-
this.bearing = bearing;
|
|
4638
|
-
this.pitch = pitch;
|
|
4639
|
-
this.fovy = fovy;
|
|
4640
|
-
this.resolution = resolution;
|
|
4641
|
-
}
|
|
4642
|
-
get projectionMode() {
|
|
4643
|
-
return PROJECTION_MODE.GLOBE;
|
|
4644
|
-
}
|
|
4645
|
-
getDistanceScales() {
|
|
4646
|
-
return this.distanceScales;
|
|
4647
|
-
}
|
|
4648
|
-
getBounds(options = {}) {
|
|
4649
|
-
const unprojectOption = { targetZ: options.z || 0 };
|
|
4650
|
-
const left = this.unproject([0, this.height / 2], unprojectOption);
|
|
4651
|
-
const top = this.unproject([this.width / 2, 0], unprojectOption);
|
|
4652
|
-
const right = this.unproject([this.width, this.height / 2], unprojectOption);
|
|
4653
|
-
const bottom = this.unproject([this.width / 2, this.height], unprojectOption);
|
|
4654
|
-
if (right[0] < this.longitude) right[0] += 360;
|
|
4655
|
-
if (left[0] > this.longitude) left[0] -= 360;
|
|
4656
|
-
return [
|
|
4657
|
-
Math.min(left[0], right[0], top[0], bottom[0]),
|
|
4658
|
-
Math.min(left[1], right[1], top[1], bottom[1]),
|
|
4659
|
-
Math.max(left[0], right[0], top[0], bottom[0]),
|
|
4660
|
-
Math.max(left[1], right[1], top[1], bottom[1])
|
|
4661
|
-
];
|
|
4662
|
-
}
|
|
4663
|
-
unproject(xyz, { topLeft = true, targetZ } = {}) {
|
|
4664
|
-
const [x, y, z] = xyz;
|
|
4665
|
-
const y2 = topLeft ? y : this.height - y;
|
|
4666
|
-
const { pixelUnprojectionMatrix } = this;
|
|
4667
|
-
let coord;
|
|
4668
|
-
if (Number.isFinite(z)) {
|
|
4669
|
-
coord = transformVector(pixelUnprojectionMatrix, [x, y2, z, 1]);
|
|
4670
|
-
} else {
|
|
4671
|
-
const coord0 = transformVector(pixelUnprojectionMatrix, [x, y2, -1, 1]);
|
|
4672
|
-
const coord1 = transformVector(pixelUnprojectionMatrix, [x, y2, 1, 1]);
|
|
4673
|
-
const lt = ((targetZ || 0) / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
4674
|
-
const lSqr = import_core12.vec3.sqrLen(import_core12.vec3.sub([], coord0, coord1));
|
|
4675
|
-
const l0Sqr = import_core12.vec3.sqrLen(coord0);
|
|
4676
|
-
const l1Sqr = import_core12.vec3.sqrLen(coord1);
|
|
4677
|
-
const sSqr = (4 * l0Sqr * l1Sqr - (lSqr - l0Sqr - l1Sqr) ** 2) / 16;
|
|
4678
|
-
const dSqr = 4 * sSqr / lSqr;
|
|
4679
|
-
const r0 = Math.sqrt(l0Sqr - dSqr);
|
|
4680
|
-
const dr = Math.sqrt(Math.max(0, lt * lt - dSqr));
|
|
4681
|
-
const t = (r0 - dr) / Math.sqrt(lSqr);
|
|
4682
|
-
coord = import_core12.vec3.lerp([], coord0, coord1, t);
|
|
4683
|
-
}
|
|
4684
|
-
const [X, Y, Z] = this.unprojectPosition(coord);
|
|
4685
|
-
if (Number.isFinite(z)) {
|
|
4686
|
-
return [X, Y, Z];
|
|
4687
|
-
}
|
|
4688
|
-
return Number.isFinite(targetZ) ? [X, Y, targetZ] : [X, Y];
|
|
4689
|
-
}
|
|
4690
|
-
projectPosition(xyz) {
|
|
4691
|
-
const [lng, lat, Z = 0] = xyz;
|
|
4692
|
-
const lambda = lng * DEGREES_TO_RADIANS2;
|
|
4693
|
-
const phi = lat * DEGREES_TO_RADIANS2;
|
|
4694
|
-
const cosPhi = Math.cos(phi);
|
|
4695
|
-
const D = (Z / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
4696
|
-
return [Math.sin(lambda) * cosPhi * D, -Math.cos(lambda) * cosPhi * D, Math.sin(phi) * D];
|
|
4697
|
-
}
|
|
4698
|
-
unprojectPosition(xyz) {
|
|
4699
|
-
const [x, y, z] = xyz;
|
|
4700
|
-
const D = import_core12.vec3.len(xyz);
|
|
4701
|
-
const phi = Math.asin(z / D);
|
|
4702
|
-
const lambda = Math.atan2(x, -y);
|
|
4703
|
-
const lng = lambda * RADIANS_TO_DEGREES;
|
|
4704
|
-
const lat = phi * RADIANS_TO_DEGREES;
|
|
4705
|
-
const Z = (D / GLOBE_RADIUS - 1) * EARTH_RADIUS;
|
|
4706
|
-
return [lng, lat, Z];
|
|
4707
|
-
}
|
|
4708
|
-
projectFlat(xyz) {
|
|
4709
|
-
return xyz;
|
|
4710
|
-
}
|
|
4711
|
-
unprojectFlat(xyz) {
|
|
4712
|
-
return xyz;
|
|
4713
|
-
}
|
|
4714
|
-
/**
|
|
4715
|
-
* Pan the globe using delta-based movement
|
|
4716
|
-
* @param coords - the geographic coordinates where the pan started
|
|
4717
|
-
* @param pixel - the current screen position
|
|
4718
|
-
* @param startPixel - the screen position where the pan started
|
|
4719
|
-
* @returns updated viewport options with new longitude/latitude
|
|
4720
|
-
*/
|
|
4721
|
-
panByPosition([startLng, startLat, startZoom], pixel, startPixel) {
|
|
4722
|
-
const scale = Math.pow(2, this.zoom - zoomAdjust(this.latitude));
|
|
4723
|
-
const rotationSpeed = 0.25 / scale;
|
|
4724
|
-
const longitude = startLng + rotationSpeed * (startPixel[0] - pixel[0]);
|
|
4725
|
-
let latitude = startLat - rotationSpeed * (startPixel[1] - pixel[1]);
|
|
4726
|
-
latitude = Math.max(Math.min(latitude, 90), -90);
|
|
4727
|
-
const out = { longitude, latitude, zoom: startZoom - zoomAdjust(startLat) };
|
|
4728
|
-
out.zoom += zoomAdjust(out.latitude);
|
|
4729
|
-
return out;
|
|
4730
|
-
}
|
|
4731
|
-
};
|
|
4732
|
-
GlobeViewport.displayName = "GlobeViewport";
|
|
4733
|
-
function zoomAdjust(latitude, clampToPoles) {
|
|
4734
|
-
if (clampToPoles) {
|
|
4735
|
-
latitude = Math.max(Math.min(latitude, import_web_mercator5.MAX_LATITUDE), -import_web_mercator5.MAX_LATITUDE);
|
|
4736
|
-
}
|
|
4737
|
-
const scaleAdjust = Math.PI * Math.cos(latitude * Math.PI / 180);
|
|
4738
|
-
return Math.log2(scaleAdjust);
|
|
4739
|
-
}
|
|
4740
|
-
function transformVector(matrix, vector) {
|
|
4741
|
-
const result = import_core12.vec4.transformMat4([], vector, matrix);
|
|
4742
|
-
import_core12.vec4.scale(result, result, 1 / result[3]);
|
|
4743
|
-
return result;
|
|
4744
|
-
}
|
|
4745
|
-
|
|
4746
|
-
// ../core/src/transitions/linear-interpolator.ts
|
|
4747
4573
|
var DEFAULT_PROPS = ["longitude", "latitude", "zoom", "bearing", "pitch"];
|
|
4748
4574
|
var DEFAULT_REQUIRED_PROPS = ["longitude", "latitude", "zoom"];
|
|
4749
4575
|
var LinearInterpolator = class extends TransitionInterpolator {
|
|
@@ -4770,28 +4596,23 @@ var LinearInterpolator = class extends TransitionInterpolator {
|
|
|
4770
4596
|
const result = super.initializeProps(startProps, endProps);
|
|
4771
4597
|
const { makeViewport, around } = this.opts;
|
|
4772
4598
|
if (makeViewport && around) {
|
|
4773
|
-
const
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
aroundPosition,
|
|
4784
|
-
width: endProps.width,
|
|
4785
|
-
height: endProps.height
|
|
4786
|
-
});
|
|
4787
|
-
}
|
|
4599
|
+
const startViewport = makeViewport(startProps);
|
|
4600
|
+
const endViewport = makeViewport(endProps);
|
|
4601
|
+
const aroundPosition = startViewport.unproject(around);
|
|
4602
|
+
result.start.around = around;
|
|
4603
|
+
Object.assign(result.end, {
|
|
4604
|
+
around: endViewport.project(aroundPosition),
|
|
4605
|
+
aroundPosition,
|
|
4606
|
+
width: endProps.width,
|
|
4607
|
+
height: endProps.height
|
|
4608
|
+
});
|
|
4788
4609
|
}
|
|
4789
4610
|
return result;
|
|
4790
4611
|
}
|
|
4791
4612
|
interpolateProps(startProps, endProps, t) {
|
|
4792
4613
|
const propsInTransition = {};
|
|
4793
4614
|
for (const key of this._propsToExtract) {
|
|
4794
|
-
propsInTransition[key] = (0,
|
|
4615
|
+
propsInTransition[key] = (0, import_core11.lerp)(startProps[key] || 0, endProps[key] || 0, t);
|
|
4795
4616
|
}
|
|
4796
4617
|
if (endProps.aroundPosition && this.opts.makeViewport) {
|
|
4797
4618
|
const viewport = this.opts.makeViewport({ ...endProps, ...propsInTransition });
|
|
@@ -4800,7 +4621,7 @@ var LinearInterpolator = class extends TransitionInterpolator {
|
|
|
4800
4621
|
viewport.panByPosition(
|
|
4801
4622
|
endProps.aroundPosition,
|
|
4802
4623
|
// anchor point in current screen coordinates
|
|
4803
|
-
(0,
|
|
4624
|
+
(0, import_core11.lerp)(startProps.around, endProps.around, t)
|
|
4804
4625
|
)
|
|
4805
4626
|
);
|
|
4806
4627
|
}
|
|
@@ -4809,6 +4630,7 @@ var LinearInterpolator = class extends TransitionInterpolator {
|
|
|
4809
4630
|
};
|
|
4810
4631
|
|
|
4811
4632
|
// ../core/src/controllers/controller.ts
|
|
4633
|
+
var import_web_mercator4 = require("@math.gl/web-mercator");
|
|
4812
4634
|
var NO_TRANSITION_PROPS = {
|
|
4813
4635
|
transitionDuration: 0
|
|
4814
4636
|
};
|
|
@@ -4857,6 +4679,7 @@ var Controller = class {
|
|
|
4857
4679
|
this.touchRotate = false;
|
|
4858
4680
|
this.multiTouchDrag = null;
|
|
4859
4681
|
this.trackpadGesture = false;
|
|
4682
|
+
this.zoomAround = "pointer";
|
|
4860
4683
|
this.keyboard = true;
|
|
4861
4684
|
this.transitionManager = new TransitionManager({
|
|
4862
4685
|
...opts,
|
|
@@ -4951,6 +4774,15 @@ var Controller = class {
|
|
|
4951
4774
|
const { offsetCenter } = event;
|
|
4952
4775
|
return [offsetCenter.x - x, offsetCenter.y - y];
|
|
4953
4776
|
}
|
|
4777
|
+
/** Resolves the zoom anchor for pointer-based controls. */
|
|
4778
|
+
getZoomPosition(position) {
|
|
4779
|
+
if (this.zoomAround === "pointer") {
|
|
4780
|
+
return position;
|
|
4781
|
+
}
|
|
4782
|
+
const viewport = this.makeViewport(this.controllerState.getViewportProps());
|
|
4783
|
+
const [centerX, centerY] = (0, import_web_mercator4.worldToPixels)(viewport.center, viewport.pixelProjectionMatrix);
|
|
4784
|
+
return [centerX, centerY];
|
|
4785
|
+
}
|
|
4954
4786
|
isPointInBounds(pos, event) {
|
|
4955
4787
|
const { width, height } = this.props;
|
|
4956
4788
|
if (event && event.handled) {
|
|
@@ -5008,6 +4840,7 @@ var Controller = class {
|
|
|
5008
4840
|
touchRotate = false,
|
|
5009
4841
|
multiTouchDrag = touchRotate ? "rotate" : null,
|
|
5010
4842
|
trackpadGesture = false,
|
|
4843
|
+
zoomAround = "pointer",
|
|
5011
4844
|
keyboard = true
|
|
5012
4845
|
} = props;
|
|
5013
4846
|
const isInteractive = Boolean(this.onViewStateChange);
|
|
@@ -5030,6 +4863,7 @@ var Controller = class {
|
|
|
5030
4863
|
this.touchRotate = multiTouchDrag === "rotate";
|
|
5031
4864
|
this.multiTouchDrag = multiTouchDrag;
|
|
5032
4865
|
this.trackpadGesture = trackpadGesture;
|
|
4866
|
+
this.zoomAround = zoomAround;
|
|
5033
4867
|
this.keyboard = keyboard;
|
|
5034
4868
|
const constraintChanged = !oldProps || oldProps.height !== props.height || oldProps.width !== props.width || oldProps.maxBounds !== props.maxBounds || oldProps.maxBoundsPadding !== props.maxBoundsPadding;
|
|
5035
4869
|
if (constraintChanged && props.maxBounds) {
|
|
@@ -5263,8 +5097,9 @@ var Controller = class {
|
|
|
5263
5097
|
if (delta < 0 && scale !== 0) {
|
|
5264
5098
|
scale = 1 / scale;
|
|
5265
5099
|
}
|
|
5266
|
-
const
|
|
5267
|
-
const
|
|
5100
|
+
const zoomPosition = this.getZoomPosition(pos);
|
|
5101
|
+
const transitionProps = smooth ? { ...this._getTransitionProps({ around: zoomPosition }), transitionDuration: 250 } : NO_TRANSITION_PROPS;
|
|
5102
|
+
const newControllerState = this.controllerState.zoom({ pos: zoomPosition, scale });
|
|
5268
5103
|
this.updateViewport(newControllerState, transitionProps, {
|
|
5269
5104
|
isZooming: true,
|
|
5270
5105
|
isPanning: true
|
|
@@ -5350,7 +5185,7 @@ var Controller = class {
|
|
|
5350
5185
|
if (!this.isPointInBounds(pos, event)) {
|
|
5351
5186
|
return false;
|
|
5352
5187
|
}
|
|
5353
|
-
const newControllerState = this.controllerState.zoomStart({ pos }, this._getConstraintContext("zoom", "start")).rotateStart({ pos }, this._getConstraintContext("rotate", "start"));
|
|
5188
|
+
const newControllerState = this.controllerState.zoomStart({ pos: this.getZoomPosition(pos) }, this._getConstraintContext("zoom", "start")).rotateStart({ pos }, this._getConstraintContext("rotate", "start"));
|
|
5354
5189
|
pinchEventWorkaround._startPinchRotation = event.rotation;
|
|
5355
5190
|
pinchEventWorkaround._lastPinchEvent = event;
|
|
5356
5191
|
this.updateViewport(newControllerState, NO_TRANSITION_PROPS, { isDragging: true });
|
|
@@ -5369,7 +5204,7 @@ var Controller = class {
|
|
|
5369
5204
|
const { scale } = event;
|
|
5370
5205
|
const pos = this.getCenter(event);
|
|
5371
5206
|
newControllerState = newControllerState.zoom(
|
|
5372
|
-
{ pos, scale },
|
|
5207
|
+
{ pos: this.getZoomPosition(pos), scale },
|
|
5373
5208
|
this._getConstraintContext("zoom", "update")
|
|
5374
5209
|
);
|
|
5375
5210
|
}
|
|
@@ -5397,15 +5232,16 @@ var Controller = class {
|
|
|
5397
5232
|
const { _lastPinchEvent } = pinchEventWorkaround;
|
|
5398
5233
|
if (this.touchZoom && inertia && _lastPinchEvent && event.scale !== _lastPinchEvent.scale) {
|
|
5399
5234
|
const pos = this.getCenter(event);
|
|
5235
|
+
const zoomPosition = this.getZoomPosition(pos);
|
|
5400
5236
|
let newControllerState = this.controllerState.rotateEnd();
|
|
5401
5237
|
const z = Math.log2(event.scale);
|
|
5402
5238
|
const velocityZ = (z - Math.log2(_lastPinchEvent.scale)) / (event.deltaTime - _lastPinchEvent.deltaTime);
|
|
5403
5239
|
const endScale = Math.pow(2, z + velocityZ * inertia / 2);
|
|
5404
|
-
newControllerState = newControllerState.zoom({ pos, scale: endScale }).zoomEnd();
|
|
5240
|
+
newControllerState = newControllerState.zoom({ pos: zoomPosition, scale: endScale }).zoomEnd();
|
|
5405
5241
|
this.updateViewport(
|
|
5406
5242
|
newControllerState,
|
|
5407
5243
|
{
|
|
5408
|
-
...this._getTransitionProps({ around:
|
|
5244
|
+
...this._getTransitionProps({ around: zoomPosition }),
|
|
5409
5245
|
transitionDuration: inertia,
|
|
5410
5246
|
transitionEasing: INERTIA_EASING
|
|
5411
5247
|
},
|
|
@@ -5450,8 +5286,12 @@ var Controller = class {
|
|
|
5450
5286
|
return false;
|
|
5451
5287
|
}
|
|
5452
5288
|
const isZoomOut = this.isFunctionKeyPressed(event);
|
|
5453
|
-
const
|
|
5454
|
-
|
|
5289
|
+
const zoomPosition = this.getZoomPosition(pos);
|
|
5290
|
+
const newControllerState = this.controllerState.zoom({
|
|
5291
|
+
pos: zoomPosition,
|
|
5292
|
+
scale: isZoomOut ? 0.5 : 2
|
|
5293
|
+
});
|
|
5294
|
+
this.updateViewport(newControllerState, this._getTransitionProps({ around: zoomPosition }), {
|
|
5455
5295
|
isZooming: true,
|
|
5456
5296
|
isPanning: true
|
|
5457
5297
|
});
|
|
@@ -5468,14 +5308,14 @@ var Controller = class {
|
|
|
5468
5308
|
this._doubleClickDragAnchor = null;
|
|
5469
5309
|
return false;
|
|
5470
5310
|
}
|
|
5471
|
-
this._doubleClickDragAnchor = pos;
|
|
5311
|
+
this._doubleClickDragAnchor = this.getZoomPosition(pos);
|
|
5472
5312
|
let newControllerState = this.controllerState.zoomStart(
|
|
5473
|
-
{ pos },
|
|
5313
|
+
{ pos: this._doubleClickDragAnchor },
|
|
5474
5314
|
this._getConstraintContext("zoom", "start")
|
|
5475
5315
|
);
|
|
5476
5316
|
if (event.scale !== 1) {
|
|
5477
5317
|
newControllerState = newControllerState.zoom(
|
|
5478
|
-
{ pos, scale: event.scale },
|
|
5318
|
+
{ pos: this._doubleClickDragAnchor, scale: event.scale },
|
|
5479
5319
|
this._getConstraintContext("zoom", "update")
|
|
5480
5320
|
);
|
|
5481
5321
|
}
|
|
@@ -5644,7 +5484,7 @@ function getMaxBoundsExtents(viewport, target, rect) {
|
|
|
5644
5484
|
}
|
|
5645
5485
|
|
|
5646
5486
|
// ../core/src/controllers/map-controller.ts
|
|
5647
|
-
var
|
|
5487
|
+
var import_web_mercator5 = require("@math.gl/web-mercator");
|
|
5648
5488
|
var PITCH_MOUSE_THRESHOLD = 5;
|
|
5649
5489
|
var PITCH_ACCEL = 1.2;
|
|
5650
5490
|
var WEB_MERCATOR_TILE_SIZE = 512;
|
|
@@ -5658,11 +5498,11 @@ function lngLatToWorld2([lng, lat]) {
|
|
|
5658
5498
|
lat = Math.sign(lat) * 90;
|
|
5659
5499
|
}
|
|
5660
5500
|
if (Number.isFinite(lng)) {
|
|
5661
|
-
const [x, y2] = (0,
|
|
5662
|
-
return [x, (0,
|
|
5501
|
+
const [x, y2] = (0, import_web_mercator5.lngLatToWorld)([lng, lat]);
|
|
5502
|
+
return [x, (0, import_core12.clamp)(y2, 0, WEB_MERCATOR_TILE_SIZE)];
|
|
5663
5503
|
}
|
|
5664
|
-
const [, y] = (0,
|
|
5665
|
-
return [lng, (0,
|
|
5504
|
+
const [, y] = (0, import_web_mercator5.lngLatToWorld)([0, lat]);
|
|
5505
|
+
return [lng, (0, import_core12.clamp)(y, 0, WEB_MERCATOR_TILE_SIZE)];
|
|
5666
5506
|
}
|
|
5667
5507
|
var MapState = class extends ViewState {
|
|
5668
5508
|
constructor(options) {
|
|
@@ -5971,7 +5811,7 @@ var MapState = class extends ViewState {
|
|
|
5971
5811
|
props.bearing = mod(bearing + 180, 360) - 180;
|
|
5972
5812
|
}
|
|
5973
5813
|
}
|
|
5974
|
-
props.pitch = (0,
|
|
5814
|
+
props.pitch = (0, import_core12.clamp)(pitch, minPitch, maxPitch);
|
|
5975
5815
|
const constrainedZoom = this._constrainZoom(props.zoom, props);
|
|
5976
5816
|
const shouldRubberBand = rubberBand && (constraintContext == null ? void 0 : constraintContext.mode) === "elastic";
|
|
5977
5817
|
props.zoom = (constraintContext == null ? void 0 : constraintContext.mode) === "preserve" ? props.zoom : shouldRubberBand ? applyRubberBand(props.zoom, constrainedZoom, ZOOM_RUBBER_BAND_RANGE) : constrainedZoom;
|
|
@@ -6006,8 +5846,8 @@ var MapState = class extends ViewState {
|
|
|
6006
5846
|
];
|
|
6007
5847
|
const center = lngLatToWorld2([props.longitude, props.latitude]);
|
|
6008
5848
|
const constrainedCenter = [
|
|
6009
|
-
(0,
|
|
6010
|
-
(0,
|
|
5849
|
+
(0, import_core12.clamp)(center[0], minimumCenter[0], maximumCenter[0]),
|
|
5850
|
+
(0, import_core12.clamp)(center[1], minimumCenter[1], maximumCenter[1])
|
|
6011
5851
|
];
|
|
6012
5852
|
const displayedCenter = center.slice();
|
|
6013
5853
|
if (maxBoundsRect.width >= 0) {
|
|
@@ -6017,7 +5857,7 @@ var MapState = class extends ViewState {
|
|
|
6017
5857
|
displayedCenter[1] = (constraintContext == null ? void 0 : constraintContext.mode) === "preserve" ? center[1] : shouldRubberBand ? applyRubberBand(center[1], constrainedCenter[1], maxBoundsRect.height / 2 / scale) : constrainedCenter[1];
|
|
6018
5858
|
}
|
|
6019
5859
|
if (displayedCenter[0] !== center[0] || displayedCenter[1] !== center[1]) {
|
|
6020
|
-
const [displayedLongitude, displayedLatitude] = (0,
|
|
5860
|
+
const [displayedLongitude, displayedLatitude] = (0, import_web_mercator5.worldToLngLat)(displayedCenter);
|
|
6021
5861
|
if (displayedCenter[0] !== center[0]) {
|
|
6022
5862
|
props.longitude = displayedLongitude;
|
|
6023
5863
|
}
|
|
@@ -6048,7 +5888,7 @@ var MapState = class extends ViewState {
|
|
|
6048
5888
|
}
|
|
6049
5889
|
if (minZoom > maxZoom) minZoom = maxZoom;
|
|
6050
5890
|
}
|
|
6051
|
-
return (0,
|
|
5891
|
+
return (0, import_core12.clamp)(zoom, minZoom, maxZoom);
|
|
6052
5892
|
}
|
|
6053
5893
|
_zoomFromCenter(scale, constraintContext) {
|
|
6054
5894
|
const { width, height } = this.getViewportProps();
|
|
@@ -6104,7 +5944,7 @@ var MapState = class extends ViewState {
|
|
|
6104
5944
|
deltaScaleY = 1 - centerY / startY;
|
|
6105
5945
|
}
|
|
6106
5946
|
}
|
|
6107
|
-
deltaScaleY = (0,
|
|
5947
|
+
deltaScaleY = (0, import_core12.clamp)(deltaScaleY, -1, 1);
|
|
6108
5948
|
const { minPitch, maxPitch } = this.getViewportProps();
|
|
6109
5949
|
const bearing = startBearing + 180 * deltaScaleX;
|
|
6110
5950
|
let pitch = startPitch;
|
|
@@ -6433,7 +6273,7 @@ var DeckRenderer = class {
|
|
|
6433
6273
|
};
|
|
6434
6274
|
|
|
6435
6275
|
// ../core/src/lib/deck-picker.ts
|
|
6436
|
-
var
|
|
6276
|
+
var import_core13 = require("@luma.gl/core");
|
|
6437
6277
|
|
|
6438
6278
|
// ../core/src/lib/picking/query-object.ts
|
|
6439
6279
|
var NO_PICKED_OBJECT = {
|
|
@@ -6702,7 +6542,7 @@ var DeckPicker = class {
|
|
|
6702
6542
|
format: "rgba8unorm",
|
|
6703
6543
|
width: 1,
|
|
6704
6544
|
height: 1,
|
|
6705
|
-
usage:
|
|
6545
|
+
usage: import_core13.Texture.RENDER_ATTACHMENT | import_core13.Texture.COPY_SRC
|
|
6706
6546
|
});
|
|
6707
6547
|
this.pickingFBO = this.device.createFramebuffer({
|
|
6708
6548
|
colorAttachments: [pickingColorTexture],
|
|
@@ -6713,7 +6553,7 @@ var DeckPicker = class {
|
|
|
6713
6553
|
format: "rgba32float",
|
|
6714
6554
|
width: 1,
|
|
6715
6555
|
height: 1,
|
|
6716
|
-
usage:
|
|
6556
|
+
usage: import_core13.Texture.RENDER_ATTACHMENT | import_core13.Texture.COPY_SRC
|
|
6717
6557
|
});
|
|
6718
6558
|
const depthFBO = this.device.createFramebuffer({
|
|
6719
6559
|
colorAttachments: [depthColorTexture],
|
|
@@ -7231,7 +7071,7 @@ var DeckPicker = class {
|
|
|
7231
7071
|
const layout = texture.computeMemoryLayout(options);
|
|
7232
7072
|
const readBuffer = this.device.createBuffer({
|
|
7233
7073
|
byteLength: layout.byteLength,
|
|
7234
|
-
usage:
|
|
7074
|
+
usage: import_core13.Buffer.COPY_DST | import_core13.Buffer.MAP_READ
|
|
7235
7075
|
});
|
|
7236
7076
|
try {
|
|
7237
7077
|
texture.readBuffer(options, readBuffer);
|
|
@@ -7956,7 +7796,7 @@ var CanvasManager = class {
|
|
|
7956
7796
|
};
|
|
7957
7797
|
|
|
7958
7798
|
// ../core/src/lib/deck.ts
|
|
7959
|
-
var
|
|
7799
|
+
var import_core14 = require("@luma.gl/core");
|
|
7960
7800
|
var import_webgl = require("@luma.gl/webgl");
|
|
7961
7801
|
|
|
7962
7802
|
// ../../node_modules/@luma.gl/webgl/dist/constants/webgl-constants.js
|
|
@@ -9574,7 +9414,7 @@ var Deck = class {
|
|
|
9574
9414
|
// we must use 'premultiplied' canvas for webgpu to enable transparency and match shaders
|
|
9575
9415
|
alphaMode: ((_b = this.props.deviceProps) == null ? void 0 : _b.type) === "webgpu" ? "premultiplied" : void 0
|
|
9576
9416
|
};
|
|
9577
|
-
return
|
|
9417
|
+
return import_core14.luma.createDevice({
|
|
9578
9418
|
// luma by default throws if a device is already attached
|
|
9579
9419
|
// asynchronous device creation could happen after finalize() is called
|
|
9580
9420
|
// TODO - createDevice should support AbortController?
|
|
@@ -9855,7 +9695,7 @@ var Deck = class {
|
|
|
9855
9695
|
metrics.cpuTime = stats.get("CPU Time").time;
|
|
9856
9696
|
metrics.gpuTimePerFrame = stats.get("GPU Time").getAverageTime();
|
|
9857
9697
|
metrics.cpuTimePerFrame = stats.get("CPU Time").getAverageTime();
|
|
9858
|
-
const memoryStats =
|
|
9698
|
+
const memoryStats = import_core14.luma.stats.get("GPU Time and Memory");
|
|
9859
9699
|
metrics.bufferMemory = memoryStats.get("Buffer Memory").count;
|
|
9860
9700
|
metrics.textureMemory = memoryStats.get("Texture Memory").count;
|
|
9861
9701
|
metrics.renderbufferMemory = memoryStats.get("Renderbuffer Memory").count;
|