@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 CHANGED
@@ -11463,8 +11463,8 @@ void main(void) {
11463
11463
  }
11464
11464
  return PROJECTION_MODE.IDENTITY;
11465
11465
  }
11466
- // Two viewports are equal if width and height are identical, and if
11467
- // their view and projection matrices are (approximately) equal.
11466
+ // Two viewports are equal if their dimensions, common-space scale, and
11467
+ // view and projection matrices are (approximately) equal.
11468
11468
  equals(viewport) {
11469
11469
  if (!(viewport instanceof _Viewport)) {
11470
11470
  return false;
@@ -11472,7 +11472,7 @@ void main(void) {
11472
11472
  if (this === viewport) {
11473
11473
  return true;
11474
11474
  }
11475
- return viewport.width === this.width && viewport.height === this.height && viewport.scale === this.scale && equals(viewport.projectionMatrix, this.projectionMatrix) && equals(viewport.viewMatrix, this.viewMatrix);
11475
+ return viewport.width === this.width && viewport.height === this.height && viewport.scale === this.scale && viewport.projectionMode === this.projectionMode && viewport.resolution === this.resolution && equals(viewport.distanceScales.unitsPerMeter, this.distanceScales.unitsPerMeter) && equals(viewport.projectionMatrix, this.projectionMatrix) && equals(viewport.viewMatrix, this.viewMatrix);
11476
11476
  }
11477
11477
  /**
11478
11478
  * Projects xyz (possibly latitude and longitude) to pixel coordinates in window
@@ -11807,6 +11807,10 @@ void main(void) {
11807
11807
  }
11808
11808
  return this._subViewports;
11809
11809
  }
11810
+ /** Returns whether two Web Mercator viewports use the same projection settings. */
11811
+ equals(viewport) {
11812
+ return viewport instanceof _WebMercatorViewport && viewport._pseudoMeters === this._pseudoMeters && super.equals(viewport);
11813
+ }
11810
11814
  projectPosition(xyz) {
11811
11815
  if (this._pseudoMeters) {
11812
11816
  return super.projectPosition(xyz);
@@ -12177,178 +12181,6 @@ void main(void) {
12177
12181
  }
12178
12182
  };
12179
12183
 
12180
- // ../core/src/viewports/globe-viewport.ts
12181
- var DEGREES_TO_RADIANS5 = Math.PI / 180;
12182
- var RADIANS_TO_DEGREES3 = 180 / Math.PI;
12183
- var EARTH_RADIUS = 6370972;
12184
- var GLOBE_RADIUS = 256;
12185
- function getDistanceScales2() {
12186
- const unitsPerMeter2 = GLOBE_RADIUS / EARTH_RADIUS;
12187
- const unitsPerDegree = Math.PI / 180 * GLOBE_RADIUS;
12188
- return {
12189
- unitsPerMeter: [unitsPerMeter2, unitsPerMeter2, unitsPerMeter2],
12190
- unitsPerMeter2: [0, 0, 0],
12191
- metersPerUnit: [1 / unitsPerMeter2, 1 / unitsPerMeter2, 1 / unitsPerMeter2],
12192
- unitsPerDegree: [unitsPerDegree, unitsPerDegree, unitsPerMeter2],
12193
- unitsPerDegree2: [0, 0, 0],
12194
- degreesPerUnit: [1 / unitsPerDegree, 1 / unitsPerDegree, 1 / unitsPerMeter2]
12195
- };
12196
- }
12197
- var GlobeViewport = class extends Viewport {
12198
- constructor(opts = {}) {
12199
- const {
12200
- longitude = 0,
12201
- bearing = 0,
12202
- pitch = 0,
12203
- zoom = 0,
12204
- // Matches Maplibre defaults
12205
- // https://github.com/maplibre/maplibre-gl-js/blob/f8ab4b48d59ab8fe7b068b102538793bbdd4c848/src/geo/projection/globe_transform.ts#L632-L633
12206
- nearZMultiplier = 0.5,
12207
- farZMultiplier = 1,
12208
- resolution = 10
12209
- } = opts;
12210
- let { latitude = 0, height, altitude = 1.5, fovy } = opts;
12211
- latitude = Math.max(Math.min(latitude, 90), -90);
12212
- height = height || 1;
12213
- if (fovy) {
12214
- altitude = fovyToAltitude(fovy);
12215
- } else {
12216
- fovy = altitudeToFovy(altitude);
12217
- }
12218
- const scaleLatitude = Math.max(Math.min(latitude, MAX_LATITUDE), -MAX_LATITUDE);
12219
- const scale5 = Math.pow(2, zoom - zoomAdjust(scaleLatitude));
12220
- const pitchRadians = pitch * DEGREES_TO_RADIANS5;
12221
- const nearZ = opts.nearZ ?? nearZMultiplier;
12222
- const farZ = opts.farZ ?? (altitude + GLOBE_RADIUS * 2 * scale5 / height / Math.max(Math.cos(pitchRadians), 0.1)) * farZMultiplier;
12223
- const viewMatrix = new Matrix4().lookAt({ eye: [0, -altitude, 0], up: [0, 0, 1] }).rotateX(-pitchRadians).rotateY(-bearing * DEGREES_TO_RADIANS5).rotateX(latitude * DEGREES_TO_RADIANS5).rotateZ(-longitude * DEGREES_TO_RADIANS5).scale(scale5 / height);
12224
- super({
12225
- ...opts,
12226
- // x, y, width,
12227
- height,
12228
- // view matrix
12229
- viewMatrix,
12230
- longitude,
12231
- latitude,
12232
- zoom,
12233
- // projection matrix parameters
12234
- distanceScales: getDistanceScales2(),
12235
- fovy,
12236
- focalDistance: altitude,
12237
- near: nearZ,
12238
- far: farZ
12239
- });
12240
- this.scale = scale5;
12241
- this.latitude = latitude;
12242
- this.longitude = longitude;
12243
- this.bearing = bearing;
12244
- this.pitch = pitch;
12245
- this.fovy = fovy;
12246
- this.resolution = resolution;
12247
- }
12248
- get projectionMode() {
12249
- return PROJECTION_MODE.GLOBE;
12250
- }
12251
- getDistanceScales() {
12252
- return this.distanceScales;
12253
- }
12254
- getBounds(options = {}) {
12255
- const unprojectOption = { targetZ: options.z || 0 };
12256
- const left = this.unproject([0, this.height / 2], unprojectOption);
12257
- const top = this.unproject([this.width / 2, 0], unprojectOption);
12258
- const right = this.unproject([this.width, this.height / 2], unprojectOption);
12259
- const bottom = this.unproject([this.width / 2, this.height], unprojectOption);
12260
- if (right[0] < this.longitude) right[0] += 360;
12261
- if (left[0] > this.longitude) left[0] -= 360;
12262
- return [
12263
- Math.min(left[0], right[0], top[0], bottom[0]),
12264
- Math.min(left[1], right[1], top[1], bottom[1]),
12265
- Math.max(left[0], right[0], top[0], bottom[0]),
12266
- Math.max(left[1], right[1], top[1], bottom[1])
12267
- ];
12268
- }
12269
- unproject(xyz, { topLeft = true, targetZ } = {}) {
12270
- const [x, y, z] = xyz;
12271
- const y2 = topLeft ? y : this.height - y;
12272
- const { pixelUnprojectionMatrix } = this;
12273
- let coord;
12274
- if (Number.isFinite(z)) {
12275
- coord = transformVector2(pixelUnprojectionMatrix, [x, y2, z, 1]);
12276
- } else {
12277
- const coord0 = transformVector2(pixelUnprojectionMatrix, [x, y2, -1, 1]);
12278
- const coord1 = transformVector2(pixelUnprojectionMatrix, [x, y2, 1, 1]);
12279
- const lt = ((targetZ || 0) / EARTH_RADIUS + 1) * GLOBE_RADIUS;
12280
- const lSqr = vec3_exports.sqrLen(vec3_exports.sub([], coord0, coord1));
12281
- const l0Sqr = vec3_exports.sqrLen(coord0);
12282
- const l1Sqr = vec3_exports.sqrLen(coord1);
12283
- const sSqr = (4 * l0Sqr * l1Sqr - (lSqr - l0Sqr - l1Sqr) ** 2) / 16;
12284
- const dSqr = 4 * sSqr / lSqr;
12285
- const r0 = Math.sqrt(l0Sqr - dSqr);
12286
- const dr = Math.sqrt(Math.max(0, lt * lt - dSqr));
12287
- const t = (r0 - dr) / Math.sqrt(lSqr);
12288
- coord = vec3_exports.lerp([], coord0, coord1, t);
12289
- }
12290
- const [X, Y, Z] = this.unprojectPosition(coord);
12291
- if (Number.isFinite(z)) {
12292
- return [X, Y, Z];
12293
- }
12294
- return Number.isFinite(targetZ) ? [X, Y, targetZ] : [X, Y];
12295
- }
12296
- projectPosition(xyz) {
12297
- const [lng, lat, Z = 0] = xyz;
12298
- const lambda = lng * DEGREES_TO_RADIANS5;
12299
- const phi = lat * DEGREES_TO_RADIANS5;
12300
- const cosPhi = Math.cos(phi);
12301
- const D = (Z / EARTH_RADIUS + 1) * GLOBE_RADIUS;
12302
- return [Math.sin(lambda) * cosPhi * D, -Math.cos(lambda) * cosPhi * D, Math.sin(phi) * D];
12303
- }
12304
- unprojectPosition(xyz) {
12305
- const [x, y, z] = xyz;
12306
- const D = vec3_exports.len(xyz);
12307
- const phi = Math.asin(z / D);
12308
- const lambda = Math.atan2(x, -y);
12309
- const lng = lambda * RADIANS_TO_DEGREES3;
12310
- const lat = phi * RADIANS_TO_DEGREES3;
12311
- const Z = (D / GLOBE_RADIUS - 1) * EARTH_RADIUS;
12312
- return [lng, lat, Z];
12313
- }
12314
- projectFlat(xyz) {
12315
- return xyz;
12316
- }
12317
- unprojectFlat(xyz) {
12318
- return xyz;
12319
- }
12320
- /**
12321
- * Pan the globe using delta-based movement
12322
- * @param coords - the geographic coordinates where the pan started
12323
- * @param pixel - the current screen position
12324
- * @param startPixel - the screen position where the pan started
12325
- * @returns updated viewport options with new longitude/latitude
12326
- */
12327
- panByPosition([startLng, startLat, startZoom], pixel, startPixel) {
12328
- const scale5 = Math.pow(2, this.zoom - zoomAdjust(this.latitude));
12329
- const rotationSpeed = 0.25 / scale5;
12330
- const longitude = startLng + rotationSpeed * (startPixel[0] - pixel[0]);
12331
- let latitude = startLat - rotationSpeed * (startPixel[1] - pixel[1]);
12332
- latitude = Math.max(Math.min(latitude, 90), -90);
12333
- const out = { longitude, latitude, zoom: startZoom - zoomAdjust(startLat) };
12334
- out.zoom += zoomAdjust(out.latitude);
12335
- return out;
12336
- }
12337
- };
12338
- GlobeViewport.displayName = "GlobeViewport";
12339
- function zoomAdjust(latitude, clampToPoles) {
12340
- if (clampToPoles) {
12341
- latitude = Math.max(Math.min(latitude, MAX_LATITUDE), -MAX_LATITUDE);
12342
- }
12343
- const scaleAdjust = Math.PI * Math.cos(latitude * Math.PI / 180);
12344
- return Math.log2(scaleAdjust);
12345
- }
12346
- function transformVector2(matrix, vector) {
12347
- const result = vec4_exports.transformMat4([], vector, matrix);
12348
- vec4_exports.scale(result, result, 1 / result[3]);
12349
- return result;
12350
- }
12351
-
12352
12184
  // ../core/src/transitions/linear-interpolator.ts
12353
12185
  var DEFAULT_PROPS = ["longitude", "latitude", "zoom", "bearing", "pitch"];
12354
12186
  var DEFAULT_REQUIRED_PROPS = ["longitude", "latitude", "zoom"];
@@ -12376,21 +12208,16 @@ void main(void) {
12376
12208
  const result = super.initializeProps(startProps, endProps);
12377
12209
  const { makeViewport, around } = this.opts;
12378
12210
  if (makeViewport && around) {
12379
- const TestViewport = makeViewport(startProps);
12380
- if (TestViewport instanceof GlobeViewport) {
12381
- log_default.warn("around not supported in GlobeView")();
12382
- } else {
12383
- const startViewport = makeViewport(startProps);
12384
- const endViewport = makeViewport(endProps);
12385
- const aroundPosition = startViewport.unproject(around);
12386
- result.start.around = around;
12387
- Object.assign(result.end, {
12388
- around: endViewport.project(aroundPosition),
12389
- aroundPosition,
12390
- width: endProps.width,
12391
- height: endProps.height
12392
- });
12393
- }
12211
+ const startViewport = makeViewport(startProps);
12212
+ const endViewport = makeViewport(endProps);
12213
+ const aroundPosition = startViewport.unproject(around);
12214
+ result.start.around = around;
12215
+ Object.assign(result.end, {
12216
+ around: endViewport.project(aroundPosition),
12217
+ aroundPosition,
12218
+ width: endProps.width,
12219
+ height: endProps.height
12220
+ });
12394
12221
  }
12395
12222
  return result;
12396
12223
  }
@@ -12463,6 +12290,7 @@ void main(void) {
12463
12290
  this.touchRotate = false;
12464
12291
  this.multiTouchDrag = null;
12465
12292
  this.trackpadGesture = false;
12293
+ this.zoomAround = "pointer";
12466
12294
  this.keyboard = true;
12467
12295
  this.transitionManager = new TransitionManager({
12468
12296
  ...opts,
@@ -12556,6 +12384,15 @@ void main(void) {
12556
12384
  const { offsetCenter } = event;
12557
12385
  return [offsetCenter.x - x, offsetCenter.y - y];
12558
12386
  }
12387
+ /** Resolves the zoom anchor for pointer-based controls. */
12388
+ getZoomPosition(position) {
12389
+ if (this.zoomAround === "pointer") {
12390
+ return position;
12391
+ }
12392
+ const viewport = this.makeViewport(this.controllerState.getViewportProps());
12393
+ const [centerX, centerY] = worldToPixels(viewport.center, viewport.pixelProjectionMatrix);
12394
+ return [centerX, centerY];
12395
+ }
12559
12396
  isPointInBounds(pos, event) {
12560
12397
  const { width, height } = this.props;
12561
12398
  if (event && event.handled) {
@@ -12613,6 +12450,7 @@ void main(void) {
12613
12450
  touchRotate = false,
12614
12451
  multiTouchDrag = touchRotate ? "rotate" : null,
12615
12452
  trackpadGesture = false,
12453
+ zoomAround = "pointer",
12616
12454
  keyboard = true
12617
12455
  } = props;
12618
12456
  const isInteractive = Boolean(this.onViewStateChange);
@@ -12635,6 +12473,7 @@ void main(void) {
12635
12473
  this.touchRotate = multiTouchDrag === "rotate";
12636
12474
  this.multiTouchDrag = multiTouchDrag;
12637
12475
  this.trackpadGesture = trackpadGesture;
12476
+ this.zoomAround = zoomAround;
12638
12477
  this.keyboard = keyboard;
12639
12478
  const constraintChanged = !oldProps || oldProps.height !== props.height || oldProps.width !== props.width || oldProps.maxBounds !== props.maxBounds || oldProps.maxBoundsPadding !== props.maxBoundsPadding;
12640
12479
  if (constraintChanged && props.maxBounds) {
@@ -12868,8 +12707,9 @@ void main(void) {
12868
12707
  if (delta < 0 && scale5 !== 0) {
12869
12708
  scale5 = 1 / scale5;
12870
12709
  }
12871
- const transitionProps = smooth ? { ...this._getTransitionProps({ around: pos }), transitionDuration: 250 } : NO_TRANSITION_PROPS;
12872
- const newControllerState = this.controllerState.zoom({ pos, scale: scale5 });
12710
+ const zoomPosition = this.getZoomPosition(pos);
12711
+ const transitionProps = smooth ? { ...this._getTransitionProps({ around: zoomPosition }), transitionDuration: 250 } : NO_TRANSITION_PROPS;
12712
+ const newControllerState = this.controllerState.zoom({ pos: zoomPosition, scale: scale5 });
12873
12713
  this.updateViewport(newControllerState, transitionProps, {
12874
12714
  isZooming: true,
12875
12715
  isPanning: true
@@ -12955,7 +12795,7 @@ void main(void) {
12955
12795
  if (!this.isPointInBounds(pos, event)) {
12956
12796
  return false;
12957
12797
  }
12958
- const newControllerState = this.controllerState.zoomStart({ pos }, this._getConstraintContext("zoom", "start")).rotateStart({ pos }, this._getConstraintContext("rotate", "start"));
12798
+ const newControllerState = this.controllerState.zoomStart({ pos: this.getZoomPosition(pos) }, this._getConstraintContext("zoom", "start")).rotateStart({ pos }, this._getConstraintContext("rotate", "start"));
12959
12799
  pinchEventWorkaround._startPinchRotation = event.rotation;
12960
12800
  pinchEventWorkaround._lastPinchEvent = event;
12961
12801
  this.updateViewport(newControllerState, NO_TRANSITION_PROPS, { isDragging: true });
@@ -12974,7 +12814,7 @@ void main(void) {
12974
12814
  const { scale: scale5 } = event;
12975
12815
  const pos = this.getCenter(event);
12976
12816
  newControllerState = newControllerState.zoom(
12977
- { pos, scale: scale5 },
12817
+ { pos: this.getZoomPosition(pos), scale: scale5 },
12978
12818
  this._getConstraintContext("zoom", "update")
12979
12819
  );
12980
12820
  }
@@ -13002,15 +12842,16 @@ void main(void) {
13002
12842
  const { _lastPinchEvent } = pinchEventWorkaround;
13003
12843
  if (this.touchZoom && inertia && _lastPinchEvent && event.scale !== _lastPinchEvent.scale) {
13004
12844
  const pos = this.getCenter(event);
12845
+ const zoomPosition = this.getZoomPosition(pos);
13005
12846
  let newControllerState = this.controllerState.rotateEnd();
13006
12847
  const z = Math.log2(event.scale);
13007
12848
  const velocityZ = (z - Math.log2(_lastPinchEvent.scale)) / (event.deltaTime - _lastPinchEvent.deltaTime);
13008
12849
  const endScale = Math.pow(2, z + velocityZ * inertia / 2);
13009
- newControllerState = newControllerState.zoom({ pos, scale: endScale }).zoomEnd();
12850
+ newControllerState = newControllerState.zoom({ pos: zoomPosition, scale: endScale }).zoomEnd();
13010
12851
  this.updateViewport(
13011
12852
  newControllerState,
13012
12853
  {
13013
- ...this._getTransitionProps({ around: pos }),
12854
+ ...this._getTransitionProps({ around: zoomPosition }),
13014
12855
  transitionDuration: inertia,
13015
12856
  transitionEasing: INERTIA_EASING
13016
12857
  },
@@ -13055,8 +12896,12 @@ void main(void) {
13055
12896
  return false;
13056
12897
  }
13057
12898
  const isZoomOut = this.isFunctionKeyPressed(event);
13058
- const newControllerState = this.controllerState.zoom({ pos, scale: isZoomOut ? 0.5 : 2 });
13059
- this.updateViewport(newControllerState, this._getTransitionProps({ around: pos }), {
12899
+ const zoomPosition = this.getZoomPosition(pos);
12900
+ const newControllerState = this.controllerState.zoom({
12901
+ pos: zoomPosition,
12902
+ scale: isZoomOut ? 0.5 : 2
12903
+ });
12904
+ this.updateViewport(newControllerState, this._getTransitionProps({ around: zoomPosition }), {
13060
12905
  isZooming: true,
13061
12906
  isPanning: true
13062
12907
  });
@@ -13073,14 +12918,14 @@ void main(void) {
13073
12918
  this._doubleClickDragAnchor = null;
13074
12919
  return false;
13075
12920
  }
13076
- this._doubleClickDragAnchor = pos;
12921
+ this._doubleClickDragAnchor = this.getZoomPosition(pos);
13077
12922
  let newControllerState = this.controllerState.zoomStart(
13078
- { pos },
12923
+ { pos: this._doubleClickDragAnchor },
13079
12924
  this._getConstraintContext("zoom", "start")
13080
12925
  );
13081
12926
  if (event.scale !== 1) {
13082
12927
  newControllerState = newControllerState.zoom(
13083
- { pos, scale: event.scale },
12928
+ { pos: this._doubleClickDragAnchor, scale: event.scale },
13084
12929
  this._getConstraintContext("zoom", "update")
13085
12930
  );
13086
12931
  }