@deck.gl/arcgis 9.3.7 → 9.4.0-alpha.2

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 CHANGED
@@ -797,13 +797,6 @@ var PROJECTION_MODE = {
797
797
  */
798
798
  IDENTITY: 0
799
799
  };
800
- var RECOGNIZERS = {
801
- multipan: [import_mjolnir.Pan, { threshold: 10, direction: import_mjolnir.InputDirection.Vertical, pointers: 2 }],
802
- pinch: [import_mjolnir.Pinch, {}, null, ["multipan"]],
803
- pan: [import_mjolnir.Pan, { threshold: 1 }, ["pinch"], ["multipan"]],
804
- dblclick: [import_mjolnir.Tap, { event: "dblclick", taps: 2 }],
805
- click: [import_mjolnir.Tap, { event: "click" }, null, ["dblclick"]]
806
- };
807
800
 
808
801
  // ../core/src/viewports/viewport.ts
809
802
  var DEGREES_TO_RADIANS = Math.PI / 180;
@@ -1597,8 +1590,8 @@ var import_core8 = require("@math.gl/core");
1597
1590
  // ../core/src/viewports/globe-viewport.ts
1598
1591
  var import_core6 = require("@math.gl/core");
1599
1592
  var import_web_mercator3 = require("@math.gl/web-mercator");
1600
- var import_web_mercator4 = require("@math.gl/web-mercator");
1601
1593
  var import_core7 = require("@math.gl/core");
1594
+ var import_web_mercator4 = require("@math.gl/web-mercator");
1602
1595
  var DEGREES_TO_RADIANS2 = Math.PI / 180;
1603
1596
  var RADIANS_TO_DEGREES = 180 / Math.PI;
1604
1597
  var EARTH_RADIUS = 6370972;
@@ -1619,6 +1612,8 @@ var GlobeViewport = class extends Viewport {
1619
1612
  constructor(opts = {}) {
1620
1613
  const {
1621
1614
  longitude = 0,
1615
+ bearing = 0,
1616
+ pitch = 0,
1622
1617
  zoom = 0,
1623
1618
  // Matches Maplibre defaults
1624
1619
  // https://github.com/maplibre/maplibre-gl-js/blob/f8ab4b48d59ab8fe7b068b102538793bbdd4c848/src/geo/projection/globe_transform.ts#L632-L633
@@ -1627,20 +1622,19 @@ var GlobeViewport = class extends Viewport {
1627
1622
  resolution = 10
1628
1623
  } = opts;
1629
1624
  let { latitude = 0, height, altitude = 1.5, fovy } = opts;
1630
- latitude = Math.max(Math.min(latitude, import_web_mercator4.MAX_LATITUDE), -import_web_mercator4.MAX_LATITUDE);
1625
+ latitude = Math.max(Math.min(latitude, 90), -90);
1631
1626
  height = height || 1;
1632
1627
  if (fovy) {
1633
1628
  altitude = (0, import_web_mercator3.fovyToAltitude)(fovy);
1634
1629
  } else {
1635
1630
  fovy = (0, import_web_mercator3.altitudeToFovy)(altitude);
1636
1631
  }
1637
- const scale = Math.pow(2, zoom - zoomAdjust(latitude));
1632
+ const scaleLatitude = Math.max(Math.min(latitude, import_web_mercator4.MAX_LATITUDE), -import_web_mercator4.MAX_LATITUDE);
1633
+ const scale = Math.pow(2, zoom - zoomAdjust(scaleLatitude));
1634
+ const pitchRadians = pitch * DEGREES_TO_RADIANS2;
1638
1635
  const nearZ = opts.nearZ ?? nearZMultiplier;
1639
- const farZ = opts.farZ ?? (altitude + GLOBE_RADIUS * 2 * scale / height) * farZMultiplier;
1640
- const viewMatrix = new import_core6.Matrix4().lookAt({ eye: [0, -altitude, 0], up: [0, 0, 1] });
1641
- viewMatrix.rotateX(latitude * DEGREES_TO_RADIANS2);
1642
- viewMatrix.rotateZ(-longitude * DEGREES_TO_RADIANS2);
1643
- viewMatrix.scale(scale / height);
1636
+ const farZ = opts.farZ ?? (altitude + GLOBE_RADIUS * 2 * scale / height / Math.max(Math.cos(pitchRadians), 0.1)) * farZMultiplier;
1637
+ const viewMatrix = new import_core6.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);
1644
1638
  super({
1645
1639
  ...opts,
1646
1640
  // x, y, width,
@@ -1660,6 +1654,8 @@ var GlobeViewport = class extends Viewport {
1660
1654
  this.scale = scale;
1661
1655
  this.latitude = latitude;
1662
1656
  this.longitude = longitude;
1657
+ this.bearing = bearing;
1658
+ this.pitch = pitch;
1663
1659
  this.fovy = fovy;
1664
1660
  this.resolution = resolution;
1665
1661
  }
@@ -1749,14 +1745,17 @@ var GlobeViewport = class extends Viewport {
1749
1745
  const rotationSpeed = 0.25 / scale;
1750
1746
  const longitude = startLng + rotationSpeed * (startPixel[0] - pixel[0]);
1751
1747
  let latitude = startLat - rotationSpeed * (startPixel[1] - pixel[1]);
1752
- latitude = Math.max(Math.min(latitude, import_web_mercator4.MAX_LATITUDE), -import_web_mercator4.MAX_LATITUDE);
1748
+ latitude = Math.max(Math.min(latitude, 90), -90);
1753
1749
  const out = { longitude, latitude, zoom: startZoom - zoomAdjust(startLat) };
1754
1750
  out.zoom += zoomAdjust(out.latitude);
1755
1751
  return out;
1756
1752
  }
1757
1753
  };
1758
1754
  GlobeViewport.displayName = "GlobeViewport";
1759
- function zoomAdjust(latitude) {
1755
+ function zoomAdjust(latitude, clampToPoles) {
1756
+ if (clampToPoles) {
1757
+ latitude = Math.max(Math.min(latitude, import_web_mercator4.MAX_LATITUDE), -import_web_mercator4.MAX_LATITUDE);
1758
+ }
1760
1759
  const scaleAdjust = Math.PI * Math.cos(latitude * Math.PI / 180);
1761
1760
  return Math.log2(scaleAdjust);
1762
1761
  }
@@ -1843,6 +1842,7 @@ var EVENT_TYPES = {
1843
1842
  PINCH: ["pinchstart", "pinchmove", "pinchend"],
1844
1843
  MULTI_PAN: ["multipanstart", "multipanmove", "multipanend"],
1845
1844
  DOUBLE_CLICK: ["dblclick"],
1845
+ DOUBLE_CLICK_DRAG: ["dblclickdragstart", "dblclickdragmove", "dblclickdragend", "dblclickdragcancel"],
1846
1846
  KEYBOARD: ["keydown"]
1847
1847
  };
1848
1848
  var pinchEventWorkaround = {};
@@ -1856,6 +1856,10 @@ var Controller = class {
1856
1856
  this._customEvents = [];
1857
1857
  this._eventStartBlocked = null;
1858
1858
  this._panMove = false;
1859
+ this._multiPanMode = null;
1860
+ this._multiPanStartCenter = null;
1861
+ this._doubleClickDragAnchor = null;
1862
+ this._suppressDoubleClickUntil = 0;
1859
1863
  this.invertPan = false;
1860
1864
  this.dragMode = "rotate";
1861
1865
  this.inertia = 0;
@@ -1863,8 +1867,11 @@ var Controller = class {
1863
1867
  this.dragPan = true;
1864
1868
  this.dragRotate = true;
1865
1869
  this.doubleClickZoom = true;
1870
+ this.doubleClickDragZoom = true;
1866
1871
  this.touchZoom = true;
1867
1872
  this.touchRotate = false;
1873
+ this.multiTouchDrag = null;
1874
+ this.trackpadGesture = false;
1868
1875
  this.keyboard = true;
1869
1876
  this.transitionManager = new TransitionManager({
1870
1877
  ...opts,
@@ -1912,11 +1919,11 @@ var Controller = class {
1912
1919
  case "panend":
1913
1920
  return this._onPanEnd(event);
1914
1921
  case "pinchstart":
1915
- return eventStartBlocked ? false : this._onPinchStart(event);
1922
+ return eventStartBlocked || !this._isTrackpadGestureAllowed(event) ? false : this._onPinchStart(event);
1916
1923
  case "pinchmove":
1917
- return this._onPinch(event);
1924
+ return this._isTrackpadGestureAllowed(event) ? this._onPinch(event) : false;
1918
1925
  case "pinchend":
1919
- return this._onPinchEnd(event);
1926
+ return this._isTrackpadGestureAllowed(event) ? this._onPinchEnd(event) : false;
1920
1927
  case "multipanstart":
1921
1928
  return eventStartBlocked ? false : this._onMultiPanStart(event);
1922
1929
  case "multipanmove":
@@ -1925,6 +1932,13 @@ var Controller = class {
1925
1932
  return this._onMultiPanEnd(event);
1926
1933
  case "dblclick":
1927
1934
  return this._onDoubleClick(event);
1935
+ case "dblclickdragstart":
1936
+ return eventStartBlocked ? false : this._onDoubleClickDragStart(event);
1937
+ case "dblclickdragmove":
1938
+ return this._onDoubleClickDrag(event);
1939
+ case "dblclickdragend":
1940
+ case "dblclickdragcancel":
1941
+ return this._onDoubleClickDragEnd(event);
1928
1942
  case "wheel":
1929
1943
  return this._onWheel(event);
1930
1944
  case "keydown":
@@ -1997,23 +2011,33 @@ var Controller = class {
1997
2011
  dragPan = true,
1998
2012
  dragRotate = true,
1999
2013
  doubleClickZoom = true,
2014
+ doubleClickDragZoom = false,
2000
2015
  touchZoom = true,
2001
2016
  touchRotate = false,
2017
+ multiTouchDrag = touchRotate ? "rotate" : null,
2018
+ trackpadGesture = false,
2002
2019
  keyboard = true
2003
2020
  } = props;
2004
2021
  const isInteractive = Boolean(this.onViewStateChange);
2005
2022
  this.toggleEvents(EVENT_TYPES.WHEEL, isInteractive && scrollZoom);
2006
2023
  this.toggleEvents(EVENT_TYPES.PAN, isInteractive);
2007
- this.toggleEvents(EVENT_TYPES.PINCH, isInteractive && (touchZoom || touchRotate));
2008
- this.toggleEvents(EVENT_TYPES.MULTI_PAN, isInteractive && touchRotate);
2024
+ this.toggleEvents(
2025
+ EVENT_TYPES.PINCH,
2026
+ isInteractive && (touchZoom || multiTouchDrag === "rotate")
2027
+ );
2028
+ this.toggleEvents(EVENT_TYPES.MULTI_PAN, isInteractive && Boolean(multiTouchDrag));
2009
2029
  this.toggleEvents(EVENT_TYPES.DOUBLE_CLICK, isInteractive && doubleClickZoom);
2030
+ this.toggleEvents(EVENT_TYPES.DOUBLE_CLICK_DRAG, isInteractive && doubleClickDragZoom);
2010
2031
  this.toggleEvents(EVENT_TYPES.KEYBOARD, isInteractive && keyboard);
2011
2032
  this.scrollZoom = scrollZoom;
2012
2033
  this.dragPan = dragPan;
2013
2034
  this.dragRotate = dragRotate;
2014
2035
  this.doubleClickZoom = doubleClickZoom;
2036
+ this.doubleClickDragZoom = doubleClickDragZoom;
2015
2037
  this.touchZoom = touchZoom;
2016
- this.touchRotate = touchRotate;
2038
+ this.touchRotate = multiTouchDrag === "rotate";
2039
+ this.multiTouchDrag = multiTouchDrag;
2040
+ this.trackpadGesture = trackpadGesture;
2017
2041
  this.keyboard = keyboard;
2018
2042
  const dimensionChanged = !oldProps || oldProps.height !== props.height || oldProps.width !== props.width || oldProps.maxBounds !== props.maxBounds;
2019
2043
  if (dimensionChanged && props.maxBounds) {
@@ -2188,6 +2212,9 @@ var Controller = class {
2188
2212
  if (!this.scrollZoom) {
2189
2213
  return false;
2190
2214
  }
2215
+ if (this.trackpadGesture && event.device !== "mouse") {
2216
+ return false;
2217
+ }
2191
2218
  const pos = this.getCenter(event);
2192
2219
  if (!this.isPointInBounds(pos, event)) {
2193
2220
  return false;
@@ -2215,63 +2242,77 @@ var Controller = class {
2215
2242
  return true;
2216
2243
  }
2217
2244
  _onMultiPanStart(event) {
2218
- const pos = this.getCenter(event);
2219
- if (!this.isPointInBounds(pos, event)) {
2245
+ const { multiTouchDrag } = this;
2246
+ if (!multiTouchDrag || !this._isMultiPanEventAllowed(event, multiTouchDrag)) {
2220
2247
  return false;
2221
2248
  }
2222
- const newControllerState = this.controllerState.rotateStart({ pos });
2249
+ const currentCenter = event.offsetCenter;
2250
+ if (!this.isPointInBounds(this.getCenter(event), event)) {
2251
+ return false;
2252
+ }
2253
+ const isTrackpad = event.pointerType === "trackpad";
2254
+ const startCenter = {
2255
+ x: currentCenter.x - (isTrackpad ? 0 : event.deltaX),
2256
+ y: currentCenter.y - (isTrackpad ? 0 : event.deltaY)
2257
+ };
2258
+ const startEvent = { ...event, offsetCenter: startCenter };
2259
+ const pos = this.getCenter(startEvent);
2260
+ const newControllerState = multiTouchDrag === "pan" ? this.controllerState.panStart({ pos }) : this.controllerState.rotateStart({ pos });
2261
+ this._multiPanMode = multiTouchDrag;
2262
+ this._multiPanStartCenter = startCenter;
2223
2263
  this.updateViewport(newControllerState, NO_TRANSITION_PROPS, { isDragging: true });
2224
2264
  return true;
2225
2265
  }
2226
2266
  _onMultiPan(event) {
2227
- if (!this.touchRotate) {
2228
- return false;
2229
- }
2230
- if (!this.isDragging()) {
2267
+ const { mode, event: panEvent } = this._getMultiPanEvent(event);
2268
+ if (!mode || !panEvent || !this.isDragging()) {
2231
2269
  return false;
2232
2270
  }
2233
- const pos = this.getCenter(event);
2234
- pos[0] -= event.deltaX;
2235
- const newControllerState = this.controllerState.rotate({ pos });
2236
- this.updateViewport(newControllerState, NO_TRANSITION_PROPS, {
2237
- isDragging: true,
2238
- isRotating: true
2239
- });
2240
- return true;
2271
+ return mode === "pan" ? this._onPanMove(panEvent) : this._onPanRotate(panEvent);
2241
2272
  }
2242
2273
  _onMultiPanEnd(event) {
2243
- if (!this.isDragging()) {
2274
+ const { mode, event: panEvent } = this._getMultiPanEvent(event);
2275
+ if (!mode || !panEvent || !this.isDragging()) {
2276
+ this._resetMultiPan();
2244
2277
  return false;
2245
2278
  }
2246
- const { inertia } = this;
2247
- if (this.touchRotate && inertia && event.velocityY) {
2248
- const pos = this.getCenter(event);
2249
- const endPos = [pos[0], pos[1] += event.velocityY * inertia / 2];
2250
- const newControllerState = this.controllerState.rotate({ pos: endPos });
2251
- this.updateViewport(
2252
- newControllerState,
2253
- {
2254
- ...this._getTransitionProps(),
2255
- transitionDuration: inertia,
2256
- transitionEasing: INERTIA_EASING
2257
- },
2258
- {
2259
- isDragging: false,
2260
- isRotating: true
2261
- }
2262
- );
2263
- this.blockEvents(inertia);
2264
- } else {
2265
- const newControllerState = this.controllerState.rotateEnd();
2266
- this.updateViewport(newControllerState, null, {
2267
- isDragging: false,
2268
- isRotating: false
2269
- });
2279
+ const handled = mode === "pan" ? this._onPanMoveEnd(panEvent) : this._onPanRotateEnd(panEvent);
2280
+ this._resetMultiPan();
2281
+ return handled;
2282
+ }
2283
+ _isTrackpadGestureAllowed(event) {
2284
+ return event.pointerType !== "trackpad" || this.trackpadGesture;
2285
+ }
2286
+ _isMultiPanEventAllowed(event, mode) {
2287
+ if (event.pointerType === "trackpad") {
2288
+ return this.trackpadGesture && (mode === "pan" ? this.dragPan : this.dragRotate);
2270
2289
  }
2271
- return true;
2290
+ return event.pointerType === "touch" && (mode === "pan" ? this.dragPan : this.dragRotate);
2291
+ }
2292
+ _getMultiPanEvent(event) {
2293
+ const mode = this._multiPanMode;
2294
+ const startCenter = this._multiPanStartCenter;
2295
+ if (!mode || !startCenter) {
2296
+ return { mode: null, event: null };
2297
+ }
2298
+ return {
2299
+ mode,
2300
+ event: {
2301
+ ...event,
2302
+ offsetCenter: {
2303
+ x: startCenter.x + event.deltaX,
2304
+ y: startCenter.y + event.deltaY
2305
+ }
2306
+ }
2307
+ };
2308
+ }
2309
+ _resetMultiPan() {
2310
+ this._multiPanMode = null;
2311
+ this._multiPanStartCenter = null;
2272
2312
  }
2273
2313
  // Default handler for the `pinchstart` event.
2274
2314
  _onPinchStart(event) {
2315
+ this._doubleClickDragAnchor = null;
2275
2316
  const pos = this.getCenter(event);
2276
2317
  if (!this.isPointInBounds(pos, event)) {
2277
2318
  return false;
@@ -2357,6 +2398,9 @@ var Controller = class {
2357
2398
  if (!this.doubleClickZoom) {
2358
2399
  return false;
2359
2400
  }
2401
+ if (Date.now() < this._suppressDoubleClickUntil) {
2402
+ return false;
2403
+ }
2360
2404
  const pos = this.getCenter(event);
2361
2405
  if (!this.isPointInBounds(pos, event)) {
2362
2406
  return false;
@@ -2370,6 +2414,56 @@ var Controller = class {
2370
2414
  this.blockEvents(100);
2371
2415
  return true;
2372
2416
  }
2417
+ _onDoubleClickDragStart(event) {
2418
+ if (!this.doubleClickDragZoom) {
2419
+ this._doubleClickDragAnchor = null;
2420
+ return false;
2421
+ }
2422
+ const pos = this.getCenter(event);
2423
+ if (!this.isPointInBounds(pos, event)) {
2424
+ this._doubleClickDragAnchor = null;
2425
+ return false;
2426
+ }
2427
+ this._doubleClickDragAnchor = pos;
2428
+ let newControllerState = this.controllerState.zoomStart({ pos });
2429
+ if (event.scale !== 1) {
2430
+ newControllerState = newControllerState.zoom({ pos, scale: event.scale });
2431
+ }
2432
+ this.updateViewport(newControllerState, NO_TRANSITION_PROPS, {
2433
+ isDragging: true,
2434
+ isPanning: true,
2435
+ isZooming: true
2436
+ });
2437
+ return true;
2438
+ }
2439
+ _onDoubleClickDrag(event) {
2440
+ const pos = this._doubleClickDragAnchor;
2441
+ if (!pos) {
2442
+ return false;
2443
+ }
2444
+ const newControllerState = this.controllerState.zoom({ pos, scale: event.scale });
2445
+ this.updateViewport(newControllerState, NO_TRANSITION_PROPS, {
2446
+ isDragging: true,
2447
+ isPanning: true,
2448
+ isZooming: true
2449
+ });
2450
+ return true;
2451
+ }
2452
+ _onDoubleClickDragEnd(_event) {
2453
+ if (!this._doubleClickDragAnchor) {
2454
+ return false;
2455
+ }
2456
+ this._doubleClickDragAnchor = null;
2457
+ const newControllerState = this.controllerState.zoomEnd();
2458
+ this.updateViewport(newControllerState, null, {
2459
+ isDragging: false,
2460
+ isPanning: false,
2461
+ isZooming: false
2462
+ });
2463
+ this._suppressDoubleClickUntil = Date.now() + 100;
2464
+ this.blockEvents(100);
2465
+ return true;
2466
+ }
2373
2467
  // Default handler for the `keydown` event
2374
2468
  _onKeyDown(event) {
2375
2469
  if (!this.keyboard) {