@deck.gl/test-utils 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/index.cjs +72 -232
- package/dist/index.cjs.map +3 -3
- package/dist/vitest.cjs +61 -221
- package/dist/vitest.cjs.map +3 -3
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -675,12 +675,12 @@ function calculateViewportUniforms({
|
|
|
675
675
|
}
|
|
676
676
|
}
|
|
677
677
|
if (viewport.projectionMode === PROJECTION_MODE.GLOBE && coordinateSystem === "meter-offsets") {
|
|
678
|
-
const
|
|
679
|
-
const
|
|
678
|
+
const EARTH_RADIUS = 6370972;
|
|
679
|
+
const GLOBE_RADIUS = 256;
|
|
680
680
|
const lambda = coordinateOrigin[0] * Math.PI / 180;
|
|
681
681
|
const phi = coordinateOrigin[1] * Math.PI / 180;
|
|
682
682
|
const cosPhi = Math.cos(phi);
|
|
683
|
-
const D = ((coordinateOrigin[2] || 0) /
|
|
683
|
+
const D = ((coordinateOrigin[2] || 0) / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
684
684
|
uniforms.commonOrigin = [
|
|
685
685
|
Math.sin(lambda) * cosPhi * D,
|
|
686
686
|
-Math.cos(lambda) * cosPhi * D,
|
|
@@ -868,7 +868,7 @@ fn project_mercator_(lnglat: vec2<f32>) -> vec2<f32> {
|
|
|
868
868
|
let y = clamp(lnglat.y, -89.9, 89.9);
|
|
869
869
|
return vec2<f32>(
|
|
870
870
|
radians(x) + PI,
|
|
871
|
-
PI + log(
|
|
871
|
+
PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))
|
|
872
872
|
) * WORLD_SCALE;
|
|
873
873
|
}
|
|
874
874
|
|
|
@@ -2481,8 +2481,8 @@ var _Viewport = class _Viewport {
|
|
|
2481
2481
|
}
|
|
2482
2482
|
return PROJECTION_MODE.IDENTITY;
|
|
2483
2483
|
}
|
|
2484
|
-
// Two viewports are equal if
|
|
2485
|
-
//
|
|
2484
|
+
// Two viewports are equal if their dimensions, common-space scale, and
|
|
2485
|
+
// view and projection matrices are (approximately) equal.
|
|
2486
2486
|
equals(viewport) {
|
|
2487
2487
|
if (!(viewport instanceof _Viewport)) {
|
|
2488
2488
|
return false;
|
|
@@ -2490,7 +2490,7 @@ var _Viewport = class _Viewport {
|
|
|
2490
2490
|
if (this === viewport) {
|
|
2491
2491
|
return true;
|
|
2492
2492
|
}
|
|
2493
|
-
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);
|
|
2493
|
+
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);
|
|
2494
2494
|
}
|
|
2495
2495
|
/**
|
|
2496
2496
|
* Projects xyz (possibly latitude and longitude) to pixel coordinates in window
|
|
@@ -2827,6 +2827,10 @@ var _WebMercatorViewport = class _WebMercatorViewport extends Viewport {
|
|
|
2827
2827
|
}
|
|
2828
2828
|
return this._subViewports;
|
|
2829
2829
|
}
|
|
2830
|
+
/** Returns whether two Web Mercator viewports use the same projection settings. */
|
|
2831
|
+
equals(viewport) {
|
|
2832
|
+
return viewport instanceof _WebMercatorViewport && viewport._pseudoMeters === this._pseudoMeters && super.equals(viewport);
|
|
2833
|
+
}
|
|
2830
2834
|
projectPosition(xyz) {
|
|
2831
2835
|
if (this._pseudoMeters) {
|
|
2832
2836
|
return super.projectPosition(xyz);
|
|
@@ -4209,7 +4213,7 @@ var View = class {
|
|
|
4209
4213
|
};
|
|
4210
4214
|
|
|
4211
4215
|
// ../core/src/controllers/map-controller.ts
|
|
4212
|
-
var
|
|
4216
|
+
var import_core12 = require("@math.gl/core");
|
|
4213
4217
|
|
|
4214
4218
|
// ../core/src/transitions/transition.ts
|
|
4215
4219
|
var Transition = class {
|
|
@@ -4521,185 +4525,7 @@ var TransitionInterpolator = class {
|
|
|
4521
4525
|
};
|
|
4522
4526
|
|
|
4523
4527
|
// ../core/src/transitions/linear-interpolator.ts
|
|
4524
|
-
var import_core13 = require("@math.gl/core");
|
|
4525
|
-
|
|
4526
|
-
// ../core/src/viewports/globe-viewport.ts
|
|
4527
4528
|
var import_core11 = require("@math.gl/core");
|
|
4528
|
-
var import_web_mercator4 = require("@math.gl/web-mercator");
|
|
4529
|
-
var import_core12 = require("@math.gl/core");
|
|
4530
|
-
var import_web_mercator5 = require("@math.gl/web-mercator");
|
|
4531
|
-
var DEGREES_TO_RADIANS2 = Math.PI / 180;
|
|
4532
|
-
var RADIANS_TO_DEGREES = 180 / Math.PI;
|
|
4533
|
-
var EARTH_RADIUS = 6370972;
|
|
4534
|
-
var GLOBE_RADIUS = 256;
|
|
4535
|
-
function getDistanceScales2() {
|
|
4536
|
-
const unitsPerMeter2 = GLOBE_RADIUS / EARTH_RADIUS;
|
|
4537
|
-
const unitsPerDegree = Math.PI / 180 * GLOBE_RADIUS;
|
|
4538
|
-
return {
|
|
4539
|
-
unitsPerMeter: [unitsPerMeter2, unitsPerMeter2, unitsPerMeter2],
|
|
4540
|
-
unitsPerMeter2: [0, 0, 0],
|
|
4541
|
-
metersPerUnit: [1 / unitsPerMeter2, 1 / unitsPerMeter2, 1 / unitsPerMeter2],
|
|
4542
|
-
unitsPerDegree: [unitsPerDegree, unitsPerDegree, unitsPerMeter2],
|
|
4543
|
-
unitsPerDegree2: [0, 0, 0],
|
|
4544
|
-
degreesPerUnit: [1 / unitsPerDegree, 1 / unitsPerDegree, 1 / unitsPerMeter2]
|
|
4545
|
-
};
|
|
4546
|
-
}
|
|
4547
|
-
var GlobeViewport = class extends Viewport {
|
|
4548
|
-
constructor(opts = {}) {
|
|
4549
|
-
const {
|
|
4550
|
-
longitude = 0,
|
|
4551
|
-
bearing = 0,
|
|
4552
|
-
pitch = 0,
|
|
4553
|
-
zoom = 0,
|
|
4554
|
-
// Matches Maplibre defaults
|
|
4555
|
-
// https://github.com/maplibre/maplibre-gl-js/blob/f8ab4b48d59ab8fe7b068b102538793bbdd4c848/src/geo/projection/globe_transform.ts#L632-L633
|
|
4556
|
-
nearZMultiplier = 0.5,
|
|
4557
|
-
farZMultiplier = 1,
|
|
4558
|
-
resolution = 10
|
|
4559
|
-
} = opts;
|
|
4560
|
-
let { latitude = 0, height, altitude = 1.5, fovy } = opts;
|
|
4561
|
-
latitude = Math.max(Math.min(latitude, 90), -90);
|
|
4562
|
-
height = height || 1;
|
|
4563
|
-
if (fovy) {
|
|
4564
|
-
altitude = (0, import_web_mercator4.fovyToAltitude)(fovy);
|
|
4565
|
-
} else {
|
|
4566
|
-
fovy = (0, import_web_mercator4.altitudeToFovy)(altitude);
|
|
4567
|
-
}
|
|
4568
|
-
const scaleLatitude = Math.max(Math.min(latitude, import_web_mercator5.MAX_LATITUDE), -import_web_mercator5.MAX_LATITUDE);
|
|
4569
|
-
const scale = Math.pow(2, zoom - zoomAdjust(scaleLatitude));
|
|
4570
|
-
const pitchRadians = pitch * DEGREES_TO_RADIANS2;
|
|
4571
|
-
const nearZ = opts.nearZ ?? nearZMultiplier;
|
|
4572
|
-
const farZ = opts.farZ ?? (altitude + GLOBE_RADIUS * 2 * scale / height / Math.max(Math.cos(pitchRadians), 0.1)) * farZMultiplier;
|
|
4573
|
-
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);
|
|
4574
|
-
super({
|
|
4575
|
-
...opts,
|
|
4576
|
-
// x, y, width,
|
|
4577
|
-
height,
|
|
4578
|
-
// view matrix
|
|
4579
|
-
viewMatrix,
|
|
4580
|
-
longitude,
|
|
4581
|
-
latitude,
|
|
4582
|
-
zoom,
|
|
4583
|
-
// projection matrix parameters
|
|
4584
|
-
distanceScales: getDistanceScales2(),
|
|
4585
|
-
fovy,
|
|
4586
|
-
focalDistance: altitude,
|
|
4587
|
-
near: nearZ,
|
|
4588
|
-
far: farZ
|
|
4589
|
-
});
|
|
4590
|
-
this.scale = scale;
|
|
4591
|
-
this.latitude = latitude;
|
|
4592
|
-
this.longitude = longitude;
|
|
4593
|
-
this.bearing = bearing;
|
|
4594
|
-
this.pitch = pitch;
|
|
4595
|
-
this.fovy = fovy;
|
|
4596
|
-
this.resolution = resolution;
|
|
4597
|
-
}
|
|
4598
|
-
get projectionMode() {
|
|
4599
|
-
return PROJECTION_MODE.GLOBE;
|
|
4600
|
-
}
|
|
4601
|
-
getDistanceScales() {
|
|
4602
|
-
return this.distanceScales;
|
|
4603
|
-
}
|
|
4604
|
-
getBounds(options = {}) {
|
|
4605
|
-
const unprojectOption = { targetZ: options.z || 0 };
|
|
4606
|
-
const left = this.unproject([0, this.height / 2], unprojectOption);
|
|
4607
|
-
const top = this.unproject([this.width / 2, 0], unprojectOption);
|
|
4608
|
-
const right = this.unproject([this.width, this.height / 2], unprojectOption);
|
|
4609
|
-
const bottom = this.unproject([this.width / 2, this.height], unprojectOption);
|
|
4610
|
-
if (right[0] < this.longitude) right[0] += 360;
|
|
4611
|
-
if (left[0] > this.longitude) left[0] -= 360;
|
|
4612
|
-
return [
|
|
4613
|
-
Math.min(left[0], right[0], top[0], bottom[0]),
|
|
4614
|
-
Math.min(left[1], right[1], top[1], bottom[1]),
|
|
4615
|
-
Math.max(left[0], right[0], top[0], bottom[0]),
|
|
4616
|
-
Math.max(left[1], right[1], top[1], bottom[1])
|
|
4617
|
-
];
|
|
4618
|
-
}
|
|
4619
|
-
unproject(xyz, { topLeft = true, targetZ } = {}) {
|
|
4620
|
-
const [x, y, z] = xyz;
|
|
4621
|
-
const y2 = topLeft ? y : this.height - y;
|
|
4622
|
-
const { pixelUnprojectionMatrix } = this;
|
|
4623
|
-
let coord;
|
|
4624
|
-
if (Number.isFinite(z)) {
|
|
4625
|
-
coord = transformVector(pixelUnprojectionMatrix, [x, y2, z, 1]);
|
|
4626
|
-
} else {
|
|
4627
|
-
const coord0 = transformVector(pixelUnprojectionMatrix, [x, y2, -1, 1]);
|
|
4628
|
-
const coord1 = transformVector(pixelUnprojectionMatrix, [x, y2, 1, 1]);
|
|
4629
|
-
const lt = ((targetZ || 0) / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
4630
|
-
const lSqr = import_core12.vec3.sqrLen(import_core12.vec3.sub([], coord0, coord1));
|
|
4631
|
-
const l0Sqr = import_core12.vec3.sqrLen(coord0);
|
|
4632
|
-
const l1Sqr = import_core12.vec3.sqrLen(coord1);
|
|
4633
|
-
const sSqr = (4 * l0Sqr * l1Sqr - (lSqr - l0Sqr - l1Sqr) ** 2) / 16;
|
|
4634
|
-
const dSqr = 4 * sSqr / lSqr;
|
|
4635
|
-
const r0 = Math.sqrt(l0Sqr - dSqr);
|
|
4636
|
-
const dr = Math.sqrt(Math.max(0, lt * lt - dSqr));
|
|
4637
|
-
const t = (r0 - dr) / Math.sqrt(lSqr);
|
|
4638
|
-
coord = import_core12.vec3.lerp([], coord0, coord1, t);
|
|
4639
|
-
}
|
|
4640
|
-
const [X, Y, Z] = this.unprojectPosition(coord);
|
|
4641
|
-
if (Number.isFinite(z)) {
|
|
4642
|
-
return [X, Y, Z];
|
|
4643
|
-
}
|
|
4644
|
-
return Number.isFinite(targetZ) ? [X, Y, targetZ] : [X, Y];
|
|
4645
|
-
}
|
|
4646
|
-
projectPosition(xyz) {
|
|
4647
|
-
const [lng, lat, Z = 0] = xyz;
|
|
4648
|
-
const lambda = lng * DEGREES_TO_RADIANS2;
|
|
4649
|
-
const phi = lat * DEGREES_TO_RADIANS2;
|
|
4650
|
-
const cosPhi = Math.cos(phi);
|
|
4651
|
-
const D = (Z / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
4652
|
-
return [Math.sin(lambda) * cosPhi * D, -Math.cos(lambda) * cosPhi * D, Math.sin(phi) * D];
|
|
4653
|
-
}
|
|
4654
|
-
unprojectPosition(xyz) {
|
|
4655
|
-
const [x, y, z] = xyz;
|
|
4656
|
-
const D = import_core12.vec3.len(xyz);
|
|
4657
|
-
const phi = Math.asin(z / D);
|
|
4658
|
-
const lambda = Math.atan2(x, -y);
|
|
4659
|
-
const lng = lambda * RADIANS_TO_DEGREES;
|
|
4660
|
-
const lat = phi * RADIANS_TO_DEGREES;
|
|
4661
|
-
const Z = (D / GLOBE_RADIUS - 1) * EARTH_RADIUS;
|
|
4662
|
-
return [lng, lat, Z];
|
|
4663
|
-
}
|
|
4664
|
-
projectFlat(xyz) {
|
|
4665
|
-
return xyz;
|
|
4666
|
-
}
|
|
4667
|
-
unprojectFlat(xyz) {
|
|
4668
|
-
return xyz;
|
|
4669
|
-
}
|
|
4670
|
-
/**
|
|
4671
|
-
* Pan the globe using delta-based movement
|
|
4672
|
-
* @param coords - the geographic coordinates where the pan started
|
|
4673
|
-
* @param pixel - the current screen position
|
|
4674
|
-
* @param startPixel - the screen position where the pan started
|
|
4675
|
-
* @returns updated viewport options with new longitude/latitude
|
|
4676
|
-
*/
|
|
4677
|
-
panByPosition([startLng, startLat, startZoom], pixel, startPixel) {
|
|
4678
|
-
const scale = Math.pow(2, this.zoom - zoomAdjust(this.latitude));
|
|
4679
|
-
const rotationSpeed = 0.25 / scale;
|
|
4680
|
-
const longitude = startLng + rotationSpeed * (startPixel[0] - pixel[0]);
|
|
4681
|
-
let latitude = startLat - rotationSpeed * (startPixel[1] - pixel[1]);
|
|
4682
|
-
latitude = Math.max(Math.min(latitude, 90), -90);
|
|
4683
|
-
const out = { longitude, latitude, zoom: startZoom - zoomAdjust(startLat) };
|
|
4684
|
-
out.zoom += zoomAdjust(out.latitude);
|
|
4685
|
-
return out;
|
|
4686
|
-
}
|
|
4687
|
-
};
|
|
4688
|
-
GlobeViewport.displayName = "GlobeViewport";
|
|
4689
|
-
function zoomAdjust(latitude, clampToPoles) {
|
|
4690
|
-
if (clampToPoles) {
|
|
4691
|
-
latitude = Math.max(Math.min(latitude, import_web_mercator5.MAX_LATITUDE), -import_web_mercator5.MAX_LATITUDE);
|
|
4692
|
-
}
|
|
4693
|
-
const scaleAdjust = Math.PI * Math.cos(latitude * Math.PI / 180);
|
|
4694
|
-
return Math.log2(scaleAdjust);
|
|
4695
|
-
}
|
|
4696
|
-
function transformVector(matrix, vector) {
|
|
4697
|
-
const result = import_core12.vec4.transformMat4([], vector, matrix);
|
|
4698
|
-
import_core12.vec4.scale(result, result, 1 / result[3]);
|
|
4699
|
-
return result;
|
|
4700
|
-
}
|
|
4701
|
-
|
|
4702
|
-
// ../core/src/transitions/linear-interpolator.ts
|
|
4703
4529
|
var DEFAULT_PROPS = ["longitude", "latitude", "zoom", "bearing", "pitch"];
|
|
4704
4530
|
var DEFAULT_REQUIRED_PROPS = ["longitude", "latitude", "zoom"];
|
|
4705
4531
|
var LinearInterpolator = class extends TransitionInterpolator {
|
|
@@ -4726,28 +4552,23 @@ var LinearInterpolator = class extends TransitionInterpolator {
|
|
|
4726
4552
|
const result = super.initializeProps(startProps, endProps);
|
|
4727
4553
|
const { makeViewport, around } = this.opts;
|
|
4728
4554
|
if (makeViewport && around) {
|
|
4729
|
-
const
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
aroundPosition,
|
|
4740
|
-
width: endProps.width,
|
|
4741
|
-
height: endProps.height
|
|
4742
|
-
});
|
|
4743
|
-
}
|
|
4555
|
+
const startViewport = makeViewport(startProps);
|
|
4556
|
+
const endViewport = makeViewport(endProps);
|
|
4557
|
+
const aroundPosition = startViewport.unproject(around);
|
|
4558
|
+
result.start.around = around;
|
|
4559
|
+
Object.assign(result.end, {
|
|
4560
|
+
around: endViewport.project(aroundPosition),
|
|
4561
|
+
aroundPosition,
|
|
4562
|
+
width: endProps.width,
|
|
4563
|
+
height: endProps.height
|
|
4564
|
+
});
|
|
4744
4565
|
}
|
|
4745
4566
|
return result;
|
|
4746
4567
|
}
|
|
4747
4568
|
interpolateProps(startProps, endProps, t) {
|
|
4748
4569
|
const propsInTransition = {};
|
|
4749
4570
|
for (const key of this._propsToExtract) {
|
|
4750
|
-
propsInTransition[key] = (0,
|
|
4571
|
+
propsInTransition[key] = (0, import_core11.lerp)(startProps[key] || 0, endProps[key] || 0, t);
|
|
4751
4572
|
}
|
|
4752
4573
|
if (endProps.aroundPosition && this.opts.makeViewport) {
|
|
4753
4574
|
const viewport = this.opts.makeViewport({ ...endProps, ...propsInTransition });
|
|
@@ -4756,7 +4577,7 @@ var LinearInterpolator = class extends TransitionInterpolator {
|
|
|
4756
4577
|
viewport.panByPosition(
|
|
4757
4578
|
endProps.aroundPosition,
|
|
4758
4579
|
// anchor point in current screen coordinates
|
|
4759
|
-
(0,
|
|
4580
|
+
(0, import_core11.lerp)(startProps.around, endProps.around, t)
|
|
4760
4581
|
)
|
|
4761
4582
|
);
|
|
4762
4583
|
}
|
|
@@ -4765,6 +4586,7 @@ var LinearInterpolator = class extends TransitionInterpolator {
|
|
|
4765
4586
|
};
|
|
4766
4587
|
|
|
4767
4588
|
// ../core/src/controllers/controller.ts
|
|
4589
|
+
var import_web_mercator4 = require("@math.gl/web-mercator");
|
|
4768
4590
|
var NO_TRANSITION_PROPS = {
|
|
4769
4591
|
transitionDuration: 0
|
|
4770
4592
|
};
|
|
@@ -4813,6 +4635,7 @@ var Controller = class {
|
|
|
4813
4635
|
this.touchRotate = false;
|
|
4814
4636
|
this.multiTouchDrag = null;
|
|
4815
4637
|
this.trackpadGesture = false;
|
|
4638
|
+
this.zoomAround = "pointer";
|
|
4816
4639
|
this.keyboard = true;
|
|
4817
4640
|
this.transitionManager = new TransitionManager({
|
|
4818
4641
|
...opts,
|
|
@@ -4907,6 +4730,15 @@ var Controller = class {
|
|
|
4907
4730
|
const { offsetCenter } = event;
|
|
4908
4731
|
return [offsetCenter.x - x, offsetCenter.y - y];
|
|
4909
4732
|
}
|
|
4733
|
+
/** Resolves the zoom anchor for pointer-based controls. */
|
|
4734
|
+
getZoomPosition(position) {
|
|
4735
|
+
if (this.zoomAround === "pointer") {
|
|
4736
|
+
return position;
|
|
4737
|
+
}
|
|
4738
|
+
const viewport = this.makeViewport(this.controllerState.getViewportProps());
|
|
4739
|
+
const [centerX, centerY] = (0, import_web_mercator4.worldToPixels)(viewport.center, viewport.pixelProjectionMatrix);
|
|
4740
|
+
return [centerX, centerY];
|
|
4741
|
+
}
|
|
4910
4742
|
isPointInBounds(pos, event) {
|
|
4911
4743
|
const { width, height } = this.props;
|
|
4912
4744
|
if (event && event.handled) {
|
|
@@ -4964,6 +4796,7 @@ var Controller = class {
|
|
|
4964
4796
|
touchRotate = false,
|
|
4965
4797
|
multiTouchDrag = touchRotate ? "rotate" : null,
|
|
4966
4798
|
trackpadGesture = false,
|
|
4799
|
+
zoomAround = "pointer",
|
|
4967
4800
|
keyboard = true
|
|
4968
4801
|
} = props;
|
|
4969
4802
|
const isInteractive = Boolean(this.onViewStateChange);
|
|
@@ -4986,6 +4819,7 @@ var Controller = class {
|
|
|
4986
4819
|
this.touchRotate = multiTouchDrag === "rotate";
|
|
4987
4820
|
this.multiTouchDrag = multiTouchDrag;
|
|
4988
4821
|
this.trackpadGesture = trackpadGesture;
|
|
4822
|
+
this.zoomAround = zoomAround;
|
|
4989
4823
|
this.keyboard = keyboard;
|
|
4990
4824
|
const constraintChanged = !oldProps || oldProps.height !== props.height || oldProps.width !== props.width || oldProps.maxBounds !== props.maxBounds || oldProps.maxBoundsPadding !== props.maxBoundsPadding;
|
|
4991
4825
|
if (constraintChanged && props.maxBounds) {
|
|
@@ -5219,8 +5053,9 @@ var Controller = class {
|
|
|
5219
5053
|
if (delta < 0 && scale !== 0) {
|
|
5220
5054
|
scale = 1 / scale;
|
|
5221
5055
|
}
|
|
5222
|
-
const
|
|
5223
|
-
const
|
|
5056
|
+
const zoomPosition = this.getZoomPosition(pos);
|
|
5057
|
+
const transitionProps = smooth ? { ...this._getTransitionProps({ around: zoomPosition }), transitionDuration: 250 } : NO_TRANSITION_PROPS;
|
|
5058
|
+
const newControllerState = this.controllerState.zoom({ pos: zoomPosition, scale });
|
|
5224
5059
|
this.updateViewport(newControllerState, transitionProps, {
|
|
5225
5060
|
isZooming: true,
|
|
5226
5061
|
isPanning: true
|
|
@@ -5306,7 +5141,7 @@ var Controller = class {
|
|
|
5306
5141
|
if (!this.isPointInBounds(pos, event)) {
|
|
5307
5142
|
return false;
|
|
5308
5143
|
}
|
|
5309
|
-
const newControllerState = this.controllerState.zoomStart({ pos }, this._getConstraintContext("zoom", "start")).rotateStart({ pos }, this._getConstraintContext("rotate", "start"));
|
|
5144
|
+
const newControllerState = this.controllerState.zoomStart({ pos: this.getZoomPosition(pos) }, this._getConstraintContext("zoom", "start")).rotateStart({ pos }, this._getConstraintContext("rotate", "start"));
|
|
5310
5145
|
pinchEventWorkaround._startPinchRotation = event.rotation;
|
|
5311
5146
|
pinchEventWorkaround._lastPinchEvent = event;
|
|
5312
5147
|
this.updateViewport(newControllerState, NO_TRANSITION_PROPS, { isDragging: true });
|
|
@@ -5325,7 +5160,7 @@ var Controller = class {
|
|
|
5325
5160
|
const { scale } = event;
|
|
5326
5161
|
const pos = this.getCenter(event);
|
|
5327
5162
|
newControllerState = newControllerState.zoom(
|
|
5328
|
-
{ pos, scale },
|
|
5163
|
+
{ pos: this.getZoomPosition(pos), scale },
|
|
5329
5164
|
this._getConstraintContext("zoom", "update")
|
|
5330
5165
|
);
|
|
5331
5166
|
}
|
|
@@ -5353,15 +5188,16 @@ var Controller = class {
|
|
|
5353
5188
|
const { _lastPinchEvent } = pinchEventWorkaround;
|
|
5354
5189
|
if (this.touchZoom && inertia && _lastPinchEvent && event.scale !== _lastPinchEvent.scale) {
|
|
5355
5190
|
const pos = this.getCenter(event);
|
|
5191
|
+
const zoomPosition = this.getZoomPosition(pos);
|
|
5356
5192
|
let newControllerState = this.controllerState.rotateEnd();
|
|
5357
5193
|
const z = Math.log2(event.scale);
|
|
5358
5194
|
const velocityZ = (z - Math.log2(_lastPinchEvent.scale)) / (event.deltaTime - _lastPinchEvent.deltaTime);
|
|
5359
5195
|
const endScale = Math.pow(2, z + velocityZ * inertia / 2);
|
|
5360
|
-
newControllerState = newControllerState.zoom({ pos, scale: endScale }).zoomEnd();
|
|
5196
|
+
newControllerState = newControllerState.zoom({ pos: zoomPosition, scale: endScale }).zoomEnd();
|
|
5361
5197
|
this.updateViewport(
|
|
5362
5198
|
newControllerState,
|
|
5363
5199
|
{
|
|
5364
|
-
...this._getTransitionProps({ around:
|
|
5200
|
+
...this._getTransitionProps({ around: zoomPosition }),
|
|
5365
5201
|
transitionDuration: inertia,
|
|
5366
5202
|
transitionEasing: INERTIA_EASING
|
|
5367
5203
|
},
|
|
@@ -5406,8 +5242,12 @@ var Controller = class {
|
|
|
5406
5242
|
return false;
|
|
5407
5243
|
}
|
|
5408
5244
|
const isZoomOut = this.isFunctionKeyPressed(event);
|
|
5409
|
-
const
|
|
5410
|
-
|
|
5245
|
+
const zoomPosition = this.getZoomPosition(pos);
|
|
5246
|
+
const newControllerState = this.controllerState.zoom({
|
|
5247
|
+
pos: zoomPosition,
|
|
5248
|
+
scale: isZoomOut ? 0.5 : 2
|
|
5249
|
+
});
|
|
5250
|
+
this.updateViewport(newControllerState, this._getTransitionProps({ around: zoomPosition }), {
|
|
5411
5251
|
isZooming: true,
|
|
5412
5252
|
isPanning: true
|
|
5413
5253
|
});
|
|
@@ -5424,14 +5264,14 @@ var Controller = class {
|
|
|
5424
5264
|
this._doubleClickDragAnchor = null;
|
|
5425
5265
|
return false;
|
|
5426
5266
|
}
|
|
5427
|
-
this._doubleClickDragAnchor = pos;
|
|
5267
|
+
this._doubleClickDragAnchor = this.getZoomPosition(pos);
|
|
5428
5268
|
let newControllerState = this.controllerState.zoomStart(
|
|
5429
|
-
{ pos },
|
|
5269
|
+
{ pos: this._doubleClickDragAnchor },
|
|
5430
5270
|
this._getConstraintContext("zoom", "start")
|
|
5431
5271
|
);
|
|
5432
5272
|
if (event.scale !== 1) {
|
|
5433
5273
|
newControllerState = newControllerState.zoom(
|
|
5434
|
-
{ pos, scale: event.scale },
|
|
5274
|
+
{ pos: this._doubleClickDragAnchor, scale: event.scale },
|
|
5435
5275
|
this._getConstraintContext("zoom", "update")
|
|
5436
5276
|
);
|
|
5437
5277
|
}
|
|
@@ -5600,7 +5440,7 @@ function getMaxBoundsExtents(viewport, target, rect) {
|
|
|
5600
5440
|
}
|
|
5601
5441
|
|
|
5602
5442
|
// ../core/src/controllers/map-controller.ts
|
|
5603
|
-
var
|
|
5443
|
+
var import_web_mercator5 = require("@math.gl/web-mercator");
|
|
5604
5444
|
var PITCH_MOUSE_THRESHOLD = 5;
|
|
5605
5445
|
var PITCH_ACCEL = 1.2;
|
|
5606
5446
|
var WEB_MERCATOR_TILE_SIZE = 512;
|
|
@@ -5614,11 +5454,11 @@ function lngLatToWorld2([lng, lat]) {
|
|
|
5614
5454
|
lat = Math.sign(lat) * 90;
|
|
5615
5455
|
}
|
|
5616
5456
|
if (Number.isFinite(lng)) {
|
|
5617
|
-
const [x, y2] = (0,
|
|
5618
|
-
return [x, (0,
|
|
5457
|
+
const [x, y2] = (0, import_web_mercator5.lngLatToWorld)([lng, lat]);
|
|
5458
|
+
return [x, (0, import_core12.clamp)(y2, 0, WEB_MERCATOR_TILE_SIZE)];
|
|
5619
5459
|
}
|
|
5620
|
-
const [, y] = (0,
|
|
5621
|
-
return [lng, (0,
|
|
5460
|
+
const [, y] = (0, import_web_mercator5.lngLatToWorld)([0, lat]);
|
|
5461
|
+
return [lng, (0, import_core12.clamp)(y, 0, WEB_MERCATOR_TILE_SIZE)];
|
|
5622
5462
|
}
|
|
5623
5463
|
var MapState = class extends ViewState {
|
|
5624
5464
|
constructor(options) {
|
|
@@ -5927,7 +5767,7 @@ var MapState = class extends ViewState {
|
|
|
5927
5767
|
props.bearing = mod(bearing + 180, 360) - 180;
|
|
5928
5768
|
}
|
|
5929
5769
|
}
|
|
5930
|
-
props.pitch = (0,
|
|
5770
|
+
props.pitch = (0, import_core12.clamp)(pitch, minPitch, maxPitch);
|
|
5931
5771
|
const constrainedZoom = this._constrainZoom(props.zoom, props);
|
|
5932
5772
|
const shouldRubberBand = rubberBand && (constraintContext == null ? void 0 : constraintContext.mode) === "elastic";
|
|
5933
5773
|
props.zoom = (constraintContext == null ? void 0 : constraintContext.mode) === "preserve" ? props.zoom : shouldRubberBand ? applyRubberBand(props.zoom, constrainedZoom, ZOOM_RUBBER_BAND_RANGE) : constrainedZoom;
|
|
@@ -5962,8 +5802,8 @@ var MapState = class extends ViewState {
|
|
|
5962
5802
|
];
|
|
5963
5803
|
const center = lngLatToWorld2([props.longitude, props.latitude]);
|
|
5964
5804
|
const constrainedCenter = [
|
|
5965
|
-
(0,
|
|
5966
|
-
(0,
|
|
5805
|
+
(0, import_core12.clamp)(center[0], minimumCenter[0], maximumCenter[0]),
|
|
5806
|
+
(0, import_core12.clamp)(center[1], minimumCenter[1], maximumCenter[1])
|
|
5967
5807
|
];
|
|
5968
5808
|
const displayedCenter = center.slice();
|
|
5969
5809
|
if (maxBoundsRect.width >= 0) {
|
|
@@ -5973,7 +5813,7 @@ var MapState = class extends ViewState {
|
|
|
5973
5813
|
displayedCenter[1] = (constraintContext == null ? void 0 : constraintContext.mode) === "preserve" ? center[1] : shouldRubberBand ? applyRubberBand(center[1], constrainedCenter[1], maxBoundsRect.height / 2 / scale) : constrainedCenter[1];
|
|
5974
5814
|
}
|
|
5975
5815
|
if (displayedCenter[0] !== center[0] || displayedCenter[1] !== center[1]) {
|
|
5976
|
-
const [displayedLongitude, displayedLatitude] = (0,
|
|
5816
|
+
const [displayedLongitude, displayedLatitude] = (0, import_web_mercator5.worldToLngLat)(displayedCenter);
|
|
5977
5817
|
if (displayedCenter[0] !== center[0]) {
|
|
5978
5818
|
props.longitude = displayedLongitude;
|
|
5979
5819
|
}
|
|
@@ -6004,7 +5844,7 @@ var MapState = class extends ViewState {
|
|
|
6004
5844
|
}
|
|
6005
5845
|
if (minZoom > maxZoom) minZoom = maxZoom;
|
|
6006
5846
|
}
|
|
6007
|
-
return (0,
|
|
5847
|
+
return (0, import_core12.clamp)(zoom, minZoom, maxZoom);
|
|
6008
5848
|
}
|
|
6009
5849
|
_zoomFromCenter(scale, constraintContext) {
|
|
6010
5850
|
const { width, height } = this.getViewportProps();
|
|
@@ -6060,7 +5900,7 @@ var MapState = class extends ViewState {
|
|
|
6060
5900
|
deltaScaleY = 1 - centerY / startY;
|
|
6061
5901
|
}
|
|
6062
5902
|
}
|
|
6063
|
-
deltaScaleY = (0,
|
|
5903
|
+
deltaScaleY = (0, import_core12.clamp)(deltaScaleY, -1, 1);
|
|
6064
5904
|
const { minPitch, maxPitch } = this.getViewportProps();
|
|
6065
5905
|
const bearing = startBearing + 180 * deltaScaleX;
|
|
6066
5906
|
let pitch = startPitch;
|
|
@@ -6389,7 +6229,7 @@ var DeckRenderer = class {
|
|
|
6389
6229
|
};
|
|
6390
6230
|
|
|
6391
6231
|
// ../core/src/lib/deck-picker.ts
|
|
6392
|
-
var
|
|
6232
|
+
var import_core13 = require("@luma.gl/core");
|
|
6393
6233
|
|
|
6394
6234
|
// ../core/src/lib/picking/query-object.ts
|
|
6395
6235
|
var NO_PICKED_OBJECT = {
|
|
@@ -6658,7 +6498,7 @@ var DeckPicker = class {
|
|
|
6658
6498
|
format: "rgba8unorm",
|
|
6659
6499
|
width: 1,
|
|
6660
6500
|
height: 1,
|
|
6661
|
-
usage:
|
|
6501
|
+
usage: import_core13.Texture.RENDER_ATTACHMENT | import_core13.Texture.COPY_SRC
|
|
6662
6502
|
});
|
|
6663
6503
|
this.pickingFBO = this.device.createFramebuffer({
|
|
6664
6504
|
colorAttachments: [pickingColorTexture],
|
|
@@ -6669,7 +6509,7 @@ var DeckPicker = class {
|
|
|
6669
6509
|
format: "rgba32float",
|
|
6670
6510
|
width: 1,
|
|
6671
6511
|
height: 1,
|
|
6672
|
-
usage:
|
|
6512
|
+
usage: import_core13.Texture.RENDER_ATTACHMENT | import_core13.Texture.COPY_SRC
|
|
6673
6513
|
});
|
|
6674
6514
|
const depthFBO = this.device.createFramebuffer({
|
|
6675
6515
|
colorAttachments: [depthColorTexture],
|
|
@@ -7187,7 +7027,7 @@ var DeckPicker = class {
|
|
|
7187
7027
|
const layout = texture.computeMemoryLayout(options);
|
|
7188
7028
|
const readBuffer = this.device.createBuffer({
|
|
7189
7029
|
byteLength: layout.byteLength,
|
|
7190
|
-
usage:
|
|
7030
|
+
usage: import_core13.Buffer.COPY_DST | import_core13.Buffer.MAP_READ
|
|
7191
7031
|
});
|
|
7192
7032
|
try {
|
|
7193
7033
|
texture.readBuffer(options, readBuffer);
|
|
@@ -7912,7 +7752,7 @@ var CanvasManager = class {
|
|
|
7912
7752
|
};
|
|
7913
7753
|
|
|
7914
7754
|
// ../core/src/lib/deck.ts
|
|
7915
|
-
var
|
|
7755
|
+
var import_core14 = require("@luma.gl/core");
|
|
7916
7756
|
var import_webgl = require("@luma.gl/webgl");
|
|
7917
7757
|
|
|
7918
7758
|
// ../../node_modules/@luma.gl/webgl/dist/constants/webgl-constants.js
|
|
@@ -9530,7 +9370,7 @@ var Deck = class {
|
|
|
9530
9370
|
// we must use 'premultiplied' canvas for webgpu to enable transparency and match shaders
|
|
9531
9371
|
alphaMode: ((_b = this.props.deviceProps) == null ? void 0 : _b.type) === "webgpu" ? "premultiplied" : void 0
|
|
9532
9372
|
};
|
|
9533
|
-
return
|
|
9373
|
+
return import_core14.luma.createDevice({
|
|
9534
9374
|
// luma by default throws if a device is already attached
|
|
9535
9375
|
// asynchronous device creation could happen after finalize() is called
|
|
9536
9376
|
// TODO - createDevice should support AbortController?
|
|
@@ -9811,7 +9651,7 @@ var Deck = class {
|
|
|
9811
9651
|
metrics.cpuTime = stats.get("CPU Time").time;
|
|
9812
9652
|
metrics.gpuTimePerFrame = stats.get("GPU Time").getAverageTime();
|
|
9813
9653
|
metrics.cpuTimePerFrame = stats.get("CPU Time").getAverageTime();
|
|
9814
|
-
const memoryStats =
|
|
9654
|
+
const memoryStats = import_core14.luma.stats.get("GPU Time and Memory");
|
|
9815
9655
|
metrics.bufferMemory = memoryStats.get("Buffer Memory").count;
|
|
9816
9656
|
metrics.textureMemory = memoryStats.get("Texture Memory").count;
|
|
9817
9657
|
metrics.renderbufferMemory = memoryStats.get("Renderbuffer Memory").count;
|