isard 1.9.0 → 1.11.0

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/README.md +9 -4
  3. package/dist/basemap/vectortiles/requests.d.ts +8 -1
  4. package/dist/basemap/vectortiles/requests.js +32 -4
  5. package/dist/basemap/vectortiles/requests.js.map +1 -1
  6. package/dist/basemap/vectortiles/vectors.d.ts +8 -1
  7. package/dist/basemap/vectortiles/vectors.js +26 -2
  8. package/dist/basemap/vectortiles/vectors.js.map +1 -1
  9. package/dist/basemap/vectortiles.d.ts +15 -9
  10. package/dist/basemap/vectortiles.js +3 -1
  11. package/dist/basemap/vectortiles.js.map +1 -1
  12. package/dist/basemap.worker.js +2 -2
  13. package/dist/basemap.worker.js.map +4 -4
  14. package/dist/bind/layers.js +10 -2
  15. package/dist/bind/layers.js.map +1 -1
  16. package/dist/data/tileset.d.ts +21 -0
  17. package/dist/data/tileset.js +101 -0
  18. package/dist/data/tileset.js.map +1 -0
  19. package/dist/decoder.worker.js +3 -3
  20. package/dist/decoder.worker.js.map +3 -3
  21. package/dist/engine-loader.d.ts +2 -2
  22. package/dist/engine-loader.js +9 -3
  23. package/dist/engine-loader.js.map +1 -1
  24. package/dist/index.d.ts +3 -3
  25. package/dist/index.js +1 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/isard_bg.wasm +0 -0
  28. package/dist/isard_core_bg.wasm +0 -0
  29. package/dist/isard_tess_bg.wasm +0 -0
  30. package/dist/layers/features.d.ts +7 -0
  31. package/dist/layers/features.js +21 -5
  32. package/dist/layers/features.js.map +1 -1
  33. package/dist/layers/layers.js +2 -0
  34. package/dist/layers/layers.js.map +1 -1
  35. package/dist/layers/tiles3d.d.ts +6 -0
  36. package/dist/layers/tiles3d.js +57 -3
  37. package/dist/layers/tiles3d.js.map +1 -1
  38. package/dist/layers/vectors.d.ts +3 -0
  39. package/dist/layers/vectors.js +4 -0
  40. package/dist/layers/vectors.js.map +1 -1
  41. package/dist/map/events.js +1 -0
  42. package/dist/map/events.js.map +1 -1
  43. package/dist/map/quality.d.ts +33 -0
  44. package/dist/map/quality.js +61 -0
  45. package/dist/map/quality.js.map +1 -0
  46. package/dist/map.d.ts +22 -1
  47. package/dist/map.js +87 -8
  48. package/dist/map.js.map +1 -1
  49. package/dist/react/IsardMap.d.ts +1 -0
  50. package/dist/react/IsardMap.js +2 -0
  51. package/dist/react/IsardMap.js.map +1 -1
  52. package/dist/react/VectorGeometry.d.ts +4 -0
  53. package/dist/react/VectorGeometry.js +6 -3
  54. package/dist/react/VectorGeometry.js.map +1 -1
  55. package/dist/react/VectorTiles.d.ts +5 -1
  56. package/dist/react/VectorTiles.js +8 -0
  57. package/dist/react/VectorTiles.js.map +1 -1
  58. package/dist/react/index.d.ts +1 -1
  59. package/dist/react/index.js +1 -1
  60. package/dist/react/index.js.map +1 -1
  61. package/dist/types.d.ts +22 -0
  62. package/dist/types.js.map +1 -1
  63. package/dist/ui/interaction.d.ts +4 -0
  64. package/dist/ui/interaction.js +53 -2
  65. package/dist/ui/interaction.js.map +1 -1
  66. package/dist/wasm/isard.d.ts +30 -6
  67. package/dist/wasm/isard.js +61 -7
  68. package/dist/wasm/isard_core.d.ts +20 -6
  69. package/dist/wasm/isard_core.js +41 -7
  70. package/dist/workers/basemap/protocol.d.ts +3 -0
  71. package/package.json +1 -1
@@ -10,6 +10,10 @@ const WHEEL_RATE = 1 / 300;
10
10
  const WHEEL_EASE = 0.3;
11
11
  /** Degrees per pixel when rotating or tilting with the mouse */
12
12
  const ROTATE_RATE = 0.4;
13
+ /** Degrees of tilt per CSS pixel two fingers move up or down together (MapLibre's rate) */
14
+ const TOUCH_PITCH_RATE = 0.5;
15
+ /** CSS pixels a finger moves before a two-finger gesture is told: a tilt or a pinch */
16
+ const GESTURE_THRESHOLD = 6;
13
17
  /** A press that moves less than this (CSS pixels) is a click */
14
18
  const CLICK_TOLERANCE = 4;
15
19
  /** Pan speed kept on release, decaying with this time constant (ms) */
@@ -75,11 +79,31 @@ const editable = (target) => {
75
79
  return false;
76
80
  return target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName);
77
81
  };
82
+ /**
83
+ * What two fingers do, once both moved (or one far, alone): a tilt if they lie side by side and both move up or down
84
+ * together (as MapLibre and Google Earth take it), else a pinch (zoom, turn, pan); undefined before. A touch screen
85
+ * sends the fingers' moves one after the other: the first one alone tells nothing yet
86
+ */
87
+ const twoFingerGesture = (a, b) => {
88
+ const [ma, mb] = [Math.hypot(...a.moved), Math.hypot(...b.moved)];
89
+ const [most, least] = [Math.max(ma, mb), Math.min(ma, mb)];
90
+ if (most < GESTURE_THRESHOLD)
91
+ return undefined;
92
+ if (least < GESTURE_THRESHOLD / 2 && most < 2 * GESTURE_THRESHOLD)
93
+ return undefined;
94
+ const sideBySide = Math.abs(a.point[1] - b.point[1]) < Math.abs(a.point[0] - b.point[0]);
95
+ const vertical = (q) => Math.abs(q.moved[1]) > 2 * Math.abs(q.moved[0]);
96
+ const together = Math.sign(a.moved[1]) === Math.sign(b.moved[1]);
97
+ const both = Math.min(Math.abs(a.moved[1]), Math.abs(b.moved[1])) >= GESTURE_THRESHOLD / 2;
98
+ return sideBySide && vertical(a) && vertical(b) && together && both ? 'tilt' : 'pinch';
99
+ };
78
100
  export class Interaction {
79
101
  map;
80
102
  pointers = new Map();
81
103
  cleanup = [];
82
104
  wheel = { pending: 0, at: [0, 0] };
105
+ /** What the two fingers on the map do, once told (`twoFingerGesture`) */
106
+ gesture;
83
107
  /** Recent pan moves, for the release speed: [time, dx, dy] */
84
108
  trail = [];
85
109
  moved = false;
@@ -88,6 +112,8 @@ export class Interaction {
88
112
  rect;
89
113
  /** A double click zooms in (Shift: out); off while the page takes double clicks (ending a drawing) */
90
114
  doubleClickZoom = true;
115
+ /** A drag that turns and tilts goes around what is under the pointer where it starts (else around the center) */
116
+ rotateAroundPointer = true;
91
117
  constructor(map, options = {}) {
92
118
  this.map = map;
93
119
  const canvas = map.canvas;
@@ -152,7 +178,19 @@ export class Interaction {
152
178
  this.map.canvas.setPointerCapture(e.pointerId);
153
179
  const point = this.local(e);
154
180
  const rotate = e.button === 2 || e.ctrlKey || e.shiftKey;
155
- this.pointers.set(e.pointerId, { point, start: point, button: e.button, rotate });
181
+ this.pointers.set(e.pointerId, { point, start: point, button: e.button, rotate, moved: [0, 0] });
182
+ // A new gesture: told again from here
183
+ this.gesture = undefined;
184
+ this.pointers.forEach((q) => {
185
+ q.moved = [0, 0];
186
+ });
187
+ // A turn goes around what the pointer grabbed (a roof, a mesh, the relief); a pinch around the center
188
+ if (rotate && this.rotateAroundPointer && this.pointers.size === 1 && !this.map.firstPerson) {
189
+ this.map.engine.setPivot(...point);
190
+ }
191
+ else {
192
+ this.map.engine.clearPivot();
193
+ }
156
194
  this.trail = [];
157
195
  this.moved = false;
158
196
  // Grabbing the map stops any running animation (inertia, wheel zoom, easeTo)
@@ -180,7 +218,14 @@ export class Interaction {
180
218
  }
181
219
  const engine = this.map.engine;
182
220
  const other = [...this.pointers.values()].find((q) => q !== p);
183
- if (this.pointers.size === 2 && other) {
221
+ p.moved = [p.moved[0] + dx, p.moved[1] + dy];
222
+ if (this.pointers.size === 2 && other)
223
+ this.gesture ??= twoFingerGesture(p, other);
224
+ if (this.pointers.size === 2 && this.gesture === 'tilt') {
225
+ // Both fingers up or down: the midpoint moves by half of this one's move
226
+ engine.rotate(0, (-dy / 2) * TOUCH_PITCH_RATE);
227
+ }
228
+ else if (this.pointers.size === 2 && other && this.gesture === 'pinch') {
184
229
  // Pinch: zoom by the change of spread, turn by the change of angle, pan by the midpoint
185
230
  const before = Math.hypot(p.point[0] - other.point[0], p.point[1] - other.point[1]);
186
231
  const after = Math.hypot(point[0] - other.point[0], point[1] - other.point[1]);
@@ -191,6 +236,9 @@ export class Interaction {
191
236
  engine.zoomAt(Math.log2(after / before), ...mid(point));
192
237
  engine.rotate((-(angle(point) - angle(p.point)) * 180) / Math.PI, 0);
193
238
  }
239
+ else if (this.pointers.size === 2) {
240
+ // Two fingers whose gesture is not told yet: a few pixels left out
241
+ }
194
242
  else if (p.rotate) {
195
243
  engine.rotate(-dx * ROTATE_RATE, -dy * ROTATE_RATE);
196
244
  }
@@ -206,6 +254,9 @@ export class Interaction {
206
254
  if (!p)
207
255
  return;
208
256
  this.pointers.delete(e.pointerId);
257
+ this.gesture = undefined;
258
+ if (p.rotate)
259
+ this.map.engine.clearPivot();
209
260
  // The next frame sends 'moveend' if the camera stays
210
261
  this.map.requestRender();
211
262
  if (!this.moved && e.type === 'pointerup' && p.button === 0 && this.pointers.size === 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"interaction.js","sourceRoot":"","sources":["../../src/ui/interaction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAGxC,kFAAkF;AAClF,MAAM,UAAU,GAAG,CAAC,GAAG,GAAG,CAAC;AAC3B,2FAA2F;AAC3F,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,gEAAgE;AAChE,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,gEAAgE;AAChE,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,uEAAuE;AACvE,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,qCAAqC;AACrC,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,8CAA8C;AAC9C,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,2CAA2C;AAC3C,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,uDAAuD;AACvD,MAAM,YAAY,GAAG,GAAG,CAAC;AAKzB;iEACiE;AACjE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,KAAc,EAAyB,EAAE;IAC9E,QAAQ,GAAG,EA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AAC;IAED,gGAAgG;IACxF,MAAM,CAAC,KAAa,EAAE,EAAS,EAAE,MAAM,GAAG,KAAK;QACrD,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5C,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;YAEzB,OAAO;QACT,CAAC;QACD,wEAAwE;QACxE,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE;YACpB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC;YAEzG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC;YAC3B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAEjE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/**\n * Mouse, touch and keyboard controls. Every gesture only updates the camera and asks for a frame: the engine draws at most\n * once per display refresh, whatever the event rate of the device.\n */\n\nimport type { GeoMap } from '../map.ts';\nimport type { Point } from '../types.ts';\nimport { latitude, mercatorX, mercatorY, RAD } from '../util/geo.ts';\nimport { clamp } from '../util/math.ts';\nimport type { Camera } from '../wasm/isard.js';\n\n/** Zoom levels per wheel pixel (a mouse notch is about 100 px: 1/3 of a level) */\nconst WHEEL_RATE = 1 / 300;\n/** Share of the remaining wheel zoom applied per frame (smooth, about 150 ms to settle) */\nconst WHEEL_EASE = 0.3;\n/** Degrees per pixel when rotating or tilting with the mouse */\nconst ROTATE_RATE = 0.4;\n/** A press that moves less than this (CSS pixels) is a click */\nconst CLICK_TOLERANCE = 4;\n/** Pan speed kept on release, decaying with this time constant (ms) */\nconst INERTIA_DECAY = 280;\n\n/** CSS pixels per arrow key press */\nconst KEY_PAN = 100;\n/** Degrees per Shift + left or right arrow */\nconst KEY_BEARING = 15;\n/** Degrees per Shift + up or down arrow */\nconst KEY_PITCH = 10;\n/** Duration of the moves made by keys, milliseconds */\nconst KEY_DURATION = 300;\n\n/** What a key does to the camera: a pan in CSS pixels, a zoom, rotation or tilt step, or facing north */\nexport type KeyAction = { pan: Point } | { zoom: number } | { bearing: number } | { pitch: number } | { reset: true };\n\n/** The action of a key (`KeyboardEvent.key`), as MapLibre's: arrows pan (with Shift: rotate and tilt), + and - zoom\n * (with Shift: two levels), 0 faces north and levels the view */\nexport const keyAction = (key: string, shift: boolean): KeyAction | undefined => {\n switch (key) {\n case 'ArrowLeft':\n return shift ? { bearing: -KEY_BEARING } : { pan: [-KEY_PAN, 0] };\n case 'ArrowRight':\n return shift ? { bearing: KEY_BEARING } : { pan: [KEY_PAN, 0] };\n case 'ArrowUp':\n return shift ? { pitch: KEY_PITCH } : { pan: [0, -KEY_PAN] };\n case 'ArrowDown':\n return shift ? { pitch: -KEY_PITCH } : { pan: [0, KEY_PAN] };\n case '+':\n case '=':\n return { zoom: shift ? 2 : 1 };\n case '-':\n case '_':\n return { zoom: shift ? -2 : -1 };\n case '0':\n return { reset: true };\n default:\n return undefined;\n }\n};\n\n/** The camera after a key's action: a pan moves the center by that many CSS pixels on screen (the ground in view,\n * turned with the bearing, stretched by the tilt) */\nexport const keyCamera = (action: KeyAction, camera: Camera): Partial<Camera> => {\n if ('zoom' in action) return { zoom: camera.zoom + action.zoom };\n if ('bearing' in action) return { bearing: camera.bearing + action.bearing };\n if ('pitch' in action) return { pitch: Math.max(0, camera.pitch + action.pitch) };\n if ('reset' in action) return { bearing: 0, pitch: 0 };\n\n const b = camera.bearing * RAD;\n const [sx, sy] = [action.pan[0], action.pan[1] / Math.max(0.25, Math.cos(camera.pitch * RAD))];\n // Web Mercator units (0 to 1 across the world, y down); the world is 512 CSS pixels at zoom 0\n const world = 512 * 2 ** camera.zoom;\n const dx = (sx * Math.cos(b) - sy * Math.sin(b)) / world;\n const dy = (sx * Math.sin(b) + sy * Math.cos(b)) / world;\n const [lon, lat] = camera.center;\n const x = mercatorX(lon) + dx;\n const y = clamp(mercatorY(lat) + dy, 0, 1);\n const wrapped = ((((x * 360) % 360) + 360) % 360) - 180;\n\n return { center: [wrapped, latitude(y)] };\n};\n\n/** An element that takes the keys typed in it */\nconst editable = (target: EventTarget | null): boolean => {\n if (!(target instanceof HTMLElement)) return false;\n\n return target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName);\n};\n\ninterface Pointer {\n point: Point;\n start: Point;\n button: number;\n rotate: boolean;\n}\n\nexport class Interaction {\n private readonly pointers = new Map<number, Pointer>();\n private readonly cleanup: (() => void)[] = [];\n private wheel: { pending: number; at: Point } = { pending: 0, at: [0, 0] };\n /** Recent pan moves, for the release speed: [time, dx, dy] */\n private trail: [number, number, number][] = [];\n private moved = false;\n /** The canvas's place on the page, read once: reading it on every pointer move would force a layout each time.\n * Read again after a resize, a scroll, and when a pointer comes in or goes down */\n private rect: DOMRect | undefined;\n /** A double click zooms in (Shift: out); off while the page takes double clicks (ending a drawing) */\n doubleClickZoom = true;\n\n constructor(\n private readonly map: GeoMap,\n options: { keyboard?: boolean } = {},\n ) {\n const canvas = map.canvas;\n const listen = <K extends keyof HTMLElementEventMap>(\n type: K,\n handler: (e: HTMLElementEventMap[K]) => void,\n options?: AddEventListenerOptions,\n ) => {\n canvas.addEventListener(type, handler, options);\n this.cleanup.push(() => canvas.removeEventListener(type, handler));\n };\n const moved = () => {\n this.rect = undefined;\n };\n\n listen('pointerenter', moved);\n // Scrolls of the page or of any element holding the map\n if (typeof addEventListener === 'function') {\n addEventListener('scroll', moved, { capture: true, passive: true });\n this.cleanup.push(() => removeEventListener('scroll', moved, { capture: true }));\n }\n this.cleanup.push(map.on('resize', moved));\n listen('pointerdown', (e) => {\n this.rect = undefined;\n this.down(e);\n });\n listen('pointermove', (e) => this.move(e));\n listen('pointerup', (e) => this.up(e));\n listen('pointercancel', (e) => this.up(e));\n listen('pointerleave', (e) => {\n if (e.pointerType !== 'mouse') return;\n map.hover(undefined);\n map.emit('leave', {});\n });\n\n // On the container, the wheel zooms over markers and popups too\n const container = map.getContainer();\n const wheel = (e: WheelEvent) => this.onWheel(e);\n\n container.addEventListener('wheel', wheel, { passive: false });\n this.cleanup.push(() => container.removeEventListener('wheel', wheel));\n listen('dblclick', (e) => {\n if (this.doubleClickZoom && !this.map.firstPerson) this.zoomBy(e.shiftKey ? -1 : 1, this.local(e));\n });\n listen('contextmenu', (e) => e.preventDefault());\n if (options.keyboard ?? true) {\n // On the container: the keys work with the focus on a marker or a control too\n const key = (e: KeyboardEvent) => this.onKey(e);\n\n container.addEventListener('keydown', key);\n this.cleanup.push(() => container.removeEventListener('keydown', key));\n }\n }\n\n destroy(): void {\n this.cleanup.forEach((off) => {\n off();\n });\n }\n\n /** A gesture holds the map (pointers down): the camera has not stopped moving */\n get active(): boolean {\n return this.pointers.size > 0;\n }\n\n private local(e: MouseEvent): Point {\n this.rect ??= this.map.canvas.getBoundingClientRect();\n\n return [e.clientX - this.rect.left, e.clientY - this.rect.top];\n }\n\n private down(e: PointerEvent): void {\n this.map.canvas.setPointerCapture(e.pointerId);\n\n const point = this.local(e);\n const rotate = e.button === 2 || e.ctrlKey || e.shiftKey;\n\n this.pointers.set(e.pointerId, { point, start: point, button: e.button, rotate });\n this.trail = [];\n this.moved = false;\n // Grabbing the map stops any running animation (inertia, wheel zoom, easeTo)\n this.wheel.pending = 0;\n this.map.animate(undefined);\n }\n\n private move(e: PointerEvent): void {\n const point = this.local(e);\n const p = this.pointers.get(e.pointerId);\n\n if (!p) {\n if (e.pointerType === 'mouse') this.map.hover(point);\n\n return;\n }\n\n const [dx, dy] = [point[0] - p.point[0], point[1] - p.point[1]];\n\n if (Math.hypot(point[0] - p.start[0], point[1] - p.start[1]) > CLICK_TOLERANCE) this.moved = true;\n\n const eye = this.map.firstPerson;\n\n if (eye) {\n // At street level the drag turns the eye, the scene following the pointer as if grabbed\n const degrees = eye.fov / Math.max(1, this.map.canvas.clientHeight);\n\n this.map.setFirstPerson({ ...eye, bearing: eye.bearing - dx * degrees, pitch: eye.pitch + dy * degrees });\n p.point = point;\n\n return;\n }\n\n const engine = this.map.engine;\n const other = [...this.pointers.values()].find((q) => q !== p);\n\n if (this.pointers.size === 2 && other) {\n // Pinch: zoom by the change of spread, turn by the change of angle, pan by the midpoint\n const before = Math.hypot(p.point[0] - other.point[0], p.point[1] - other.point[1]);\n const after = Math.hypot(point[0] - other.point[0], point[1] - other.point[1]);\n const angle = (q: Point) => Math.atan2(q[1] - other.point[1], q[0] - other.point[0]);\n const mid = (q: Point): Point => [(q[0] + other.point[0]) / 2, (q[1] + other.point[1]) / 2];\n\n engine.pan(...mid(p.point), ...mid(point));\n if (before > 0 && after > 0) engine.zoomAt(Math.log2(after / before), ...mid(point));\n engine.rotate((-(angle(point) - angle(p.point)) * 180) / Math.PI, 0);\n } else if (p.rotate) {\n engine.rotate(-dx * ROTATE_RATE, -dy * ROTATE_RATE);\n } else {\n engine.pan(p.point[0], p.point[1], point[0], point[1]);\n this.trail.push([e.timeStamp, dx, dy]);\n }\n p.point = point;\n this.map.requestRender();\n }\n\n private up(e: PointerEvent): void {\n const p = this.pointers.get(e.pointerId);\n\n if (!p) return;\n this.pointers.delete(e.pointerId);\n // The next frame sends 'moveend' if the camera stays\n this.map.requestRender();\n if (!this.moved && e.type === 'pointerup' && p.button === 0 && this.pointers.size === 0) {\n this.map.emit('click', { point: p.point, lonLat: this.map.unproject(p.point) });\n\n return;\n }\n if (!p.rotate && this.pointers.size === 0 && !this.map.firstPerson) this.inertia(e.timeStamp, p.point);\n }\n\n /** Keeps panning at the release speed (last 50 ms), decaying exponentially */\n private inertia(now: number, from: Point): void {\n const recent = this.trail.filter(([t]) => now - t < 50);\n const first = recent[0];\n\n if (!first || recent.length < 2) return;\n\n const span = Math.max(16, now - first[0]);\n let vx = recent.reduce((s, [, dx]) => s + dx, 0) / span;\n let vy = recent.reduce((s, [, , dy]) => s + dy, 0) / span;\n\n if (Math.hypot(vx, vy) < 0.1) return;\n\n let last = performance.now();\n let point = from;\n\n this.map.animate((t) => {\n const dt = Math.min(64, t - last);\n\n last = t;\n\n const decay = Math.exp(-dt / INERTIA_DECAY);\n const next: Point = [point[0] + vx * dt, point[1] + vy * dt];\n\n this.map.engine.pan(point[0], point[1], next[0], next[1]);\n point = next;\n vx *= decay;\n vy *= decay;\n\n return Math.hypot(vx, vy) > 0.02;\n });\n }\n\n private onWheel(e: WheelEvent): void {\n e.preventDefault();\n\n // Lines (Firefox mouse wheels) are about 33 px\n const pixels = e.deltaMode === 1 ? e.deltaY * 33 : e.deltaY;\n const eye = this.map.firstPerson;\n\n if (eye) {\n // At street level: a narrower or wider field of view\n this.map.setFirstPerson({ ...eye, fov: eye.fov * Math.exp(pixels * 0.001) });\n\n return;\n }\n this.zoomBy(clamp(-pixels * WHEEL_RATE, -1, 1), this.local(e), e.deltaMode === 0 && Math.abs(pixels) < 40);\n }\n\n private onKey(e: KeyboardEvent): void {\n if (e.defaultPrevented || e.ctrlKey || e.metaKey || e.altKey || editable(e.target)) return;\n\n const action = keyAction(e.key, e.shiftKey);\n\n if (!action) return;\n e.preventDefault();\n\n const eye = this.map.firstPerson;\n\n if (eye) {\n // At street level the arrows turn the eye\n const turn = { ArrowLeft: [-10, 0], ArrowRight: [10, 0], ArrowUp: [0, 10], ArrowDown: [0, -10] }[e.key];\n\n if (turn)\n this.map.setFirstPerson({ ...eye, bearing: eye.bearing + (turn[0] ?? 0), pitch: eye.pitch + (turn[1] ?? 0) });\n\n return;\n }\n this.wheel.pending = 0;\n\n const reduced = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n this.map.easeTo(keyCamera(action, this.map.getCamera()), reduced ? 0 : KEY_DURATION);\n }\n\n /** Smooth zoom around a screen point; touchpads (`direct`) follow the fingers without easing */\n private zoomBy(delta: number, at: Point, direct = false): void {\n if (direct) {\n this.map.engine.zoomAt(delta, at[0], at[1]);\n this.map.requestRender();\n\n return;\n }\n // Accumulate: a second notch before the end of the first one adds to it\n this.wheel.pending += delta;\n this.wheel.at = at;\n this.map.animate(() => {\n const step = Math.abs(this.wheel.pending) < 0.002 ? this.wheel.pending : this.wheel.pending * WHEEL_EASE;\n\n this.wheel.pending -= step;\n this.map.engine.zoomAt(step, this.wheel.at[0], this.wheel.at[1]);\n\n return this.wheel.pending !== 0;\n });\n }\n}\n"]}
1
+ {"version":3,"file":"interaction.js","sourceRoot":"","sources":["../../src/ui/interaction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAGxC,kFAAkF;AAClF,MAAM,UAAU,GAAG,CAAC,GAAG,GAAG,CAAC;AAC3B,2FAA2F;AAC3F,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,gEAAgE;AAChE,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,2FAA2F;AAC3F,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,uFAAuF;AACvF,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,gEAAgE;AAChE,MAAM,eAAe,GAAG,CAAC,C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C,CAAC,CAAC,CAAC,CAAC;YAC5C,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;YAEzB,OAAO;QACT,CAAC;QACD,wEAAwE;QACxE,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE;YACpB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC;YAEzG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC;YAC3B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAEjE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/**\n * Mouse, touch and keyboard controls. Every gesture only updates the camera and asks for a frame: the engine draws at most\n * once per display refresh, whatever the event rate of the device.\n */\n\nimport type { GeoMap } from '../map.ts';\nimport type { Point } from '../types.ts';\nimport { latitude, mercatorX, mercatorY, RAD } from '../util/geo.ts';\nimport { clamp } from '../util/math.ts';\nimport type { Camera } from '../wasm/isard.js';\n\n/** Zoom levels per wheel pixel (a mouse notch is about 100 px: 1/3 of a level) */\nconst WHEEL_RATE = 1 / 300;\n/** Share of the remaining wheel zoom applied per frame (smooth, about 150 ms to settle) */\nconst WHEEL_EASE = 0.3;\n/** Degrees per pixel when rotating or tilting with the mouse */\nconst ROTATE_RATE = 0.4;\n/** Degrees of tilt per CSS pixel two fingers move up or down together (MapLibre's rate) */\nconst TOUCH_PITCH_RATE = 0.5;\n/** CSS pixels a finger moves before a two-finger gesture is told: a tilt or a pinch */\nconst GESTURE_THRESHOLD = 6;\n/** A press that moves less than this (CSS pixels) is a click */\nconst CLICK_TOLERANCE = 4;\n/** Pan speed kept on release, decaying with this time constant (ms) */\nconst INERTIA_DECAY = 280;\n\n/** CSS pixels per arrow key press */\nconst KEY_PAN = 100;\n/** Degrees per Shift + left or right arrow */\nconst KEY_BEARING = 15;\n/** Degrees per Shift + up or down arrow */\nconst KEY_PITCH = 10;\n/** Duration of the moves made by keys, milliseconds */\nconst KEY_DURATION = 300;\n\n/** What a key does to the camera: a pan in CSS pixels, a zoom, rotation or tilt step, or facing north */\nexport type KeyAction = { pan: Point } | { zoom: number } | { bearing: number } | { pitch: number } | { reset: true };\n\n/** The action of a key (`KeyboardEvent.key`), as MapLibre's: arrows pan (with Shift: rotate and tilt), + and - zoom\n * (with Shift: two levels), 0 faces north and levels the view */\nexport const keyAction = (key: string, shift: boolean): KeyAction | undefined => {\n switch (key) {\n case 'ArrowLeft':\n return shift ? { bearing: -KEY_BEARING } : { pan: [-KEY_PAN, 0] };\n case 'ArrowRight':\n return shift ? { bearing: KEY_BEARING } : { pan: [KEY_PAN, 0] };\n case 'ArrowUp':\n return shift ? { pitch: KEY_PITCH } : { pan: [0, -KEY_PAN] };\n case 'ArrowDown':\n return shift ? { pitch: -KEY_PITCH } : { pan: [0, KEY_PAN] };\n case '+':\n case '=':\n return { zoom: shift ? 2 : 1 };\n case '-':\n case '_':\n return { zoom: shift ? -2 : -1 };\n case '0':\n return { reset: true };\n default:\n return undefined;\n }\n};\n\n/** The camera after a key's action: a pan moves the center by that many CSS pixels on screen (the ground in view,\n * turned with the bearing, stretched by the tilt) */\nexport const keyCamera = (action: KeyAction, camera: Camera): Partial<Camera> => {\n if ('zoom' in action) return { zoom: camera.zoom + action.zoom };\n if ('bearing' in action) return { bearing: camera.bearing + action.bearing };\n if ('pitch' in action) return { pitch: Math.max(0, camera.pitch + action.pitch) };\n if ('reset' in action) return { bearing: 0, pitch: 0 };\n\n const b = camera.bearing * RAD;\n const [sx, sy] = [action.pan[0], action.pan[1] / Math.max(0.25, Math.cos(camera.pitch * RAD))];\n // Web Mercator units (0 to 1 across the world, y down); the world is 512 CSS pixels at zoom 0\n const world = 512 * 2 ** camera.zoom;\n const dx = (sx * Math.cos(b) - sy * Math.sin(b)) / world;\n const dy = (sx * Math.sin(b) + sy * Math.cos(b)) / world;\n const [lon, lat] = camera.center;\n const x = mercatorX(lon) + dx;\n const y = clamp(mercatorY(lat) + dy, 0, 1);\n const wrapped = ((((x * 360) % 360) + 360) % 360) - 180;\n\n return { center: [wrapped, latitude(y)] };\n};\n\n/** An element that takes the keys typed in it */\nconst editable = (target: EventTarget | null): boolean => {\n if (!(target instanceof HTMLElement)) return false;\n\n return target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName);\n};\n\ninterface Pointer {\n point: Point;\n start: Point;\n button: number;\n rotate: boolean;\n /** How far it moved since the two-finger gesture began (CSS pixels) */\n moved: Point;\n}\n\n/**\n * What two fingers do, once both moved (or one far, alone): a tilt if they lie side by side and both move up or down\n * together (as MapLibre and Google Earth take it), else a pinch (zoom, turn, pan); undefined before. A touch screen\n * sends the fingers' moves one after the other: the first one alone tells nothing yet\n */\nconst twoFingerGesture = (a: Pointer, b: Pointer): 'tilt' | 'pinch' | undefined => {\n const [ma, mb] = [Math.hypot(...a.moved), Math.hypot(...b.moved)];\n const [most, least] = [Math.max(ma, mb), Math.min(ma, mb)];\n\n if (most < GESTURE_THRESHOLD) return undefined;\n if (least < GESTURE_THRESHOLD / 2 && most < 2 * GESTURE_THRESHOLD) return undefined;\n\n const sideBySide = Math.abs(a.point[1] - b.point[1]) < Math.abs(a.point[0] - b.point[0]);\n const vertical = (q: Pointer) => Math.abs(q.moved[1]) > 2 * Math.abs(q.moved[0]);\n const together = Math.sign(a.moved[1]) === Math.sign(b.moved[1]);\n const both = Math.min(Math.abs(a.moved[1]), Math.abs(b.moved[1])) >= GESTURE_THRESHOLD / 2;\n\n return sideBySide && vertical(a) && vertical(b) && together && both ? 'tilt' : 'pinch';\n};\n\nexport class Interaction {\n private readonly pointers = new Map<number, Pointer>();\n private readonly cleanup: (() => void)[] = [];\n private wheel: { pending: number; at: Point } = { pending: 0, at: [0, 0] };\n /** What the two fingers on the map do, once told (`twoFingerGesture`) */\n private gesture: 'tilt' | 'pinch' | undefined;\n /** Recent pan moves, for the release speed: [time, dx, dy] */\n private trail: [number, number, number][] = [];\n private moved = false;\n /** The canvas's place on the page, read once: reading it on every pointer move would force a layout each time.\n * Read again after a resize, a scroll, and when a pointer comes in or goes down */\n private rect: DOMRect | undefined;\n /** A double click zooms in (Shift: out); off while the page takes double clicks (ending a drawing) */\n doubleClickZoom = true;\n /** A drag that turns and tilts goes around what is under the pointer where it starts (else around the center) */\n rotateAroundPointer = true;\n\n constructor(\n private readonly map: GeoMap,\n options: { keyboard?: boolean } = {},\n ) {\n const canvas = map.canvas;\n const listen = <K extends keyof HTMLElementEventMap>(\n type: K,\n handler: (e: HTMLElementEventMap[K]) => void,\n options?: AddEventListenerOptions,\n ) => {\n canvas.addEventListener(type, handler, options);\n this.cleanup.push(() => canvas.removeEventListener(type, handler));\n };\n const moved = () => {\n this.rect = undefined;\n };\n\n listen('pointerenter', moved);\n // Scrolls of the page or of any element holding the map\n if (typeof addEventListener === 'function') {\n addEventListener('scroll', moved, { capture: true, passive: true });\n this.cleanup.push(() => removeEventListener('scroll', moved, { capture: true }));\n }\n this.cleanup.push(map.on('resize', moved));\n listen('pointerdown', (e) => {\n this.rect = undefined;\n this.down(e);\n });\n listen('pointermove', (e) => this.move(e));\n listen('pointerup', (e) => this.up(e));\n listen('pointercancel', (e) => this.up(e));\n listen('pointerleave', (e) => {\n if (e.pointerType !== 'mouse') return;\n map.hover(undefined);\n map.emit('leave', {});\n });\n\n // On the container, the wheel zooms over markers and popups too\n const container = map.getContainer();\n const wheel = (e: WheelEvent) => this.onWheel(e);\n\n container.addEventListener('wheel', wheel, { passive: false });\n this.cleanup.push(() => container.removeEventListener('wheel', wheel));\n listen('dblclick', (e) => {\n if (this.doubleClickZoom && !this.map.firstPerson) this.zoomBy(e.shiftKey ? -1 : 1, this.local(e));\n });\n listen('contextmenu', (e) => e.preventDefault());\n if (options.keyboard ?? true) {\n // On the container: the keys work with the focus on a marker or a control too\n const key = (e: KeyboardEvent) => this.onKey(e);\n\n container.addEventListener('keydown', key);\n this.cleanup.push(() => container.removeEventListener('keydown', key));\n }\n }\n\n destroy(): void {\n this.cleanup.forEach((off) => {\n off();\n });\n }\n\n /** A gesture holds the map (pointers down): the camera has not stopped moving */\n get active(): boolean {\n return this.pointers.size > 0;\n }\n\n private local(e: MouseEvent): Point {\n this.rect ??= this.map.canvas.getBoundingClientRect();\n\n return [e.clientX - this.rect.left, e.clientY - this.rect.top];\n }\n\n private down(e: PointerEvent): void {\n this.map.canvas.setPointerCapture(e.pointerId);\n\n const point = this.local(e);\n const rotate = e.button === 2 || e.ctrlKey || e.shiftKey;\n\n this.pointers.set(e.pointerId, { point, start: point, button: e.button, rotate, moved: [0, 0] });\n // A new gesture: told again from here\n this.gesture = undefined;\n this.pointers.forEach((q) => {\n q.moved = [0, 0];\n });\n // A turn goes around what the pointer grabbed (a roof, a mesh, the relief); a pinch around the center\n if (rotate && this.rotateAroundPointer && this.pointers.size === 1 && !this.map.firstPerson) {\n this.map.engine.setPivot(...point);\n } else {\n this.map.engine.clearPivot();\n }\n this.trail = [];\n this.moved = false;\n // Grabbing the map stops any running animation (inertia, wheel zoom, easeTo)\n this.wheel.pending = 0;\n this.map.animate(undefined);\n }\n\n private move(e: PointerEvent): void {\n const point = this.local(e);\n const p = this.pointers.get(e.pointerId);\n\n if (!p) {\n if (e.pointerType === 'mouse') this.map.hover(point);\n\n return;\n }\n\n const [dx, dy] = [point[0] - p.point[0], point[1] - p.point[1]];\n\n if (Math.hypot(point[0] - p.start[0], point[1] - p.start[1]) > CLICK_TOLERANCE) this.moved = true;\n\n const eye = this.map.firstPerson;\n\n if (eye) {\n // At street level the drag turns the eye, the scene following the pointer as if grabbed\n const degrees = eye.fov / Math.max(1, this.map.canvas.clientHeight);\n\n this.map.setFirstPerson({ ...eye, bearing: eye.bearing - dx * degrees, pitch: eye.pitch + dy * degrees });\n p.point = point;\n\n return;\n }\n\n const engine = this.map.engine;\n const other = [...this.pointers.values()].find((q) => q !== p);\n\n p.moved = [p.moved[0] + dx, p.moved[1] + dy];\n if (this.pointers.size === 2 && other) this.gesture ??= twoFingerGesture(p, other);\n if (this.pointers.size === 2 && this.gesture === 'tilt') {\n // Both fingers up or down: the midpoint moves by half of this one's move\n engine.rotate(0, (-dy / 2) * TOUCH_PITCH_RATE);\n } else if (this.pointers.size === 2 && other && this.gesture === 'pinch') {\n // Pinch: zoom by the change of spread, turn by the change of angle, pan by the midpoint\n const before = Math.hypot(p.point[0] - other.point[0], p.point[1] - other.point[1]);\n const after = Math.hypot(point[0] - other.point[0], point[1] - other.point[1]);\n const angle = (q: Point) => Math.atan2(q[1] - other.point[1], q[0] - other.point[0]);\n const mid = (q: Point): Point => [(q[0] + other.point[0]) / 2, (q[1] + other.point[1]) / 2];\n\n engine.pan(...mid(p.point), ...mid(point));\n if (before > 0 && after > 0) engine.zoomAt(Math.log2(after / before), ...mid(point));\n engine.rotate((-(angle(point) - angle(p.point)) * 180) / Math.PI, 0);\n } else if (this.pointers.size === 2) {\n // Two fingers whose gesture is not told yet: a few pixels left out\n } else if (p.rotate) {\n engine.rotate(-dx * ROTATE_RATE, -dy * ROTATE_RATE);\n } else {\n engine.pan(p.point[0], p.point[1], point[0], point[1]);\n this.trail.push([e.timeStamp, dx, dy]);\n }\n p.point = point;\n this.map.requestRender();\n }\n\n private up(e: PointerEvent): void {\n const p = this.pointers.get(e.pointerId);\n\n if (!p) return;\n this.pointers.delete(e.pointerId);\n this.gesture = undefined;\n if (p.rotate) this.map.engine.clearPivot();\n // The next frame sends 'moveend' if the camera stays\n this.map.requestRender();\n if (!this.moved && e.type === 'pointerup' && p.button === 0 && this.pointers.size === 0) {\n this.map.emit('click', { point: p.point, lonLat: this.map.unproject(p.point) });\n\n return;\n }\n if (!p.rotate && this.pointers.size === 0 && !this.map.firstPerson) this.inertia(e.timeStamp, p.point);\n }\n\n /** Keeps panning at the release speed (last 50 ms), decaying exponentially */\n private inertia(now: number, from: Point): void {\n const recent = this.trail.filter(([t]) => now - t < 50);\n const first = recent[0];\n\n if (!first || recent.length < 2) return;\n\n const span = Math.max(16, now - first[0]);\n let vx = recent.reduce((s, [, dx]) => s + dx, 0) / span;\n let vy = recent.reduce((s, [, , dy]) => s + dy, 0) / span;\n\n if (Math.hypot(vx, vy) < 0.1) return;\n\n let last = performance.now();\n let point = from;\n\n this.map.animate((t) => {\n const dt = Math.min(64, t - last);\n\n last = t;\n\n const decay = Math.exp(-dt / INERTIA_DECAY);\n const next: Point = [point[0] + vx * dt, point[1] + vy * dt];\n\n this.map.engine.pan(point[0], point[1], next[0], next[1]);\n point = next;\n vx *= decay;\n vy *= decay;\n\n return Math.hypot(vx, vy) > 0.02;\n });\n }\n\n private onWheel(e: WheelEvent): void {\n e.preventDefault();\n\n // Lines (Firefox mouse wheels) are about 33 px\n const pixels = e.deltaMode === 1 ? e.deltaY * 33 : e.deltaY;\n const eye = this.map.firstPerson;\n\n if (eye) {\n // At street level: a narrower or wider field of view\n this.map.setFirstPerson({ ...eye, fov: eye.fov * Math.exp(pixels * 0.001) });\n\n return;\n }\n this.zoomBy(clamp(-pixels * WHEEL_RATE, -1, 1), this.local(e), e.deltaMode === 0 && Math.abs(pixels) < 40);\n }\n\n private onKey(e: KeyboardEvent): void {\n if (e.defaultPrevented || e.ctrlKey || e.metaKey || e.altKey || editable(e.target)) return;\n\n const action = keyAction(e.key, e.shiftKey);\n\n if (!action) return;\n e.preventDefault();\n\n const eye = this.map.firstPerson;\n\n if (eye) {\n // At street level the arrows turn the eye\n const turn = { ArrowLeft: [-10, 0], ArrowRight: [10, 0], ArrowUp: [0, 10], ArrowDown: [0, -10] }[e.key];\n\n if (turn)\n this.map.setFirstPerson({ ...eye, bearing: eye.bearing + (turn[0] ?? 0), pitch: eye.pitch + (turn[1] ?? 0) });\n\n return;\n }\n this.wheel.pending = 0;\n\n const reduced = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n this.map.easeTo(keyCamera(action, this.map.getCamera()), reduced ? 0 : KEY_DURATION);\n }\n\n /** Smooth zoom around a screen point; touchpads (`direct`) follow the fingers without easing */\n private zoomBy(delta: number, at: Point, direct = false): void {\n if (direct) {\n this.map.engine.zoomAt(delta, at[0], at[1]);\n this.map.requestRender();\n\n return;\n }\n // Accumulate: a second notch before the end of the first one adds to it\n this.wheel.pending += delta;\n this.wheel.at = at;\n this.map.animate(() => {\n const step = Math.abs(this.wheel.pending) < 0.002 ? this.wheel.pending : this.wheel.pending * WHEEL_EASE;\n\n this.wheel.pending -= step;\n this.map.engine.zoomAt(step, this.wheel.at[0], this.wheel.at[1]);\n\n return this.wheel.pending !== 0;\n });\n }\n}\n"]}
@@ -336,7 +336,7 @@ export class Engine {
336
336
  * Throws (to JavaScript) when a WebGL object cannot be created or a shader fails to compile (the error carries its
337
337
  * info log), or when the features or the lines need a table texture past the GPU's `MAX_TEXTURE_SIZE`
338
338
  */
339
- addLines(points: Float64Array, start: Uint32Array, feature: Uint32Array, feature_count: number): number;
339
+ addLines(points: Float64Array, start: Uint32Array, feature: Uint32Array, feature_count: number, heights?: Float64Array | null, sea?: boolean | null): number;
340
340
  /**
341
341
  * A glTF / GLB model (its URL, a `blob:` one for data of the page) drawn at each instance of `instances`
342
342
  * (`INSTANCE_NUMBERS` numbers each: longitude, latitude, altitude, heading, pitch, roll in degrees, scale);
@@ -425,6 +425,10 @@ export class Engine {
425
425
  * Removes the panorama
426
426
  */
427
427
  clearPanorama(): void;
428
+ /**
429
+ * The turns go around the screen center again
430
+ */
431
+ clearPivot(): void;
428
432
  /**
429
433
  * Stops loading the tiles of the flight's destination (`preload`)
430
434
  */
@@ -450,7 +454,9 @@ export class Engine {
450
454
  */
451
455
  static geoidHeight(lon: number, lat: number): number;
452
456
  /**
453
- * Position under a screen point (CSS pixels), undefined above the horizon; on the relief itself
457
+ * Position under a screen point (CSS pixels), undefined above the horizon; on the relief itself: from the copy of
458
+ * its tiles kept on the CPU, the drawn ground read back from the GPU only where none is there (a read back waits
459
+ * for the frame: called during a move, it stalls it)
454
460
  */
455
461
  ground(x: number, y: number): [lon: number, lat: number] | undefined;
456
462
  /**
@@ -554,7 +560,7 @@ export class Engine {
554
560
  */
555
561
  resize(width: number, height: number, pixel_ratio: number): void;
556
562
  /**
557
- * Turns and tilts around the screen center, in degrees
563
+ * Turns and tilts, in degrees: around the pivot if one is set (`setPivot`), else around the screen center
558
564
  */
559
565
  rotate(bearing: number, pitch: number): void;
560
566
  /**
@@ -754,7 +760,7 @@ export class Engine {
754
760
  * Throws (to JavaScript) when the lines need a table texture past the GPU's `MAX_TEXTURE_SIZE`, or
755
761
  * when it cannot be created; the layer then keeps its lines
756
762
  */
757
- setLines(id: number, points: Float64Array, start: Uint32Array, feature: Uint32Array): void;
763
+ setLines(id: number, points: Float64Array, start: Uint32Array, feature: Uint32Array, heights?: Float64Array | null, sea?: boolean | null): void;
758
764
  /**
759
765
  * Highest pitch the camera accepts, degrees (up to 85)
760
766
  */
@@ -816,6 +822,12 @@ export class Engine {
816
822
  * shader fails to compile (the error carries its info log)
817
823
  */
818
824
  setPanorama(lon: number, lat: number, height: number, rotation: Float64Array, cameras: Float64Array, radius: number, opacity: number): void;
825
+ /**
826
+ * Sets the point the next turns and tilts go around (`rotate`): what is drawn under a screen point (CSS
827
+ * pixels), a roof or a mesh as the relief. Read back from the last frame (a stall): once, where a drag starts.
828
+ * Returns whether something was drawn there; over nothing, the turns go around the center
829
+ */
830
+ setPivot(x: number, y: number): boolean;
819
831
  /**
820
832
  * The style of a point cloud: 14 numbers (see `Style::parse`), the colors of the 256 classes (RGBA,
821
833
  * alpha 0 hides a class) and the ramp of the altitudes (256 RGBA texels)
@@ -888,6 +900,14 @@ export class Engine {
888
900
  * it, tiles are decoded on the main thread. Set it before adding 3D Tiles layers.
889
901
  */
890
902
  setTileLoader(loader: TileLoaderLike | null): void;
903
+ /**
904
+ * Whether the walls of a 3D Tiles layer's untextured meshes show their windows: glass by day, some lit at night
905
+ */
906
+ setTiles3dFacades(id: number, facades: boolean): void;
907
+ /**
908
+ * Each feature of a 3D Tiles layer its color (null: the layer's)
909
+ */
910
+ setTiles3dFeatureColors(id: number, colors: ((properties: Record<string, unknown>[] | undefined, count: number) => Uint8Array) | null): void;
891
911
  /**
892
912
  * Screen-space error threshold, opacity, size of the points (CSS pixels, 2 if not given) and color (RGB 0-1, empty
893
913
  * for none: it tints the textures and colors the untextured meshes) of a 3D Tiles layer
@@ -1067,7 +1087,7 @@ export interface InitOutput {
1067
1087
  readonly engine_addFills: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number];
1068
1088
  readonly engine_addFlow: (a: number, b: number, c: number) => [number, number, number];
1069
1089
  readonly engine_addGround: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number];
1070
- readonly engine_addLines: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
1090
+ readonly engine_addLines: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number];
1071
1091
  readonly engine_addModels: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
1072
1092
  readonly engine_addNetwork: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => [number, number, number];
1073
1093
  readonly engine_addPointCloud: (a: number, b: number, c: number, d: any) => [number, number, number];
@@ -1078,6 +1098,7 @@ export interface InitOutput {
1078
1098
  readonly engine_bounds: (a: number) => [number, number];
1079
1099
  readonly engine_camera: (a: number) => any;
1080
1100
  readonly engine_clearPanorama: (a: number) => void;
1101
+ readonly engine_clearPivot: (a: number) => void;
1081
1102
  readonly engine_clearPreload: (a: number) => void;
1082
1103
  readonly engine_clearViewshed: (a: number) => void;
1083
1104
  readonly engine_customMatrix: (a: number, b: number, c: number) => [number, number];
@@ -1137,7 +1158,7 @@ export interface InitOutput {
1137
1158
  readonly engine_setIconAtlas: (a: number, b: number, c: number) => [number, number];
1138
1159
  readonly engine_setImmediateLoading: (a: number, b: number) => void;
1139
1160
  readonly engine_setLineDash: (a: number, b: number, c: number, d: number) => void;
1140
- readonly engine_setLines: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
1161
+ readonly engine_setLines: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number];
1141
1162
  readonly engine_setMaxPitch: (a: number, b: number) => void;
1142
1163
  readonly engine_setModelGlow: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1143
1164
  readonly engine_setModelHighlight: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
@@ -1149,6 +1170,7 @@ export interface InitOutput {
1149
1170
  readonly engine_setNetworkValues: (a: number, b: number, c: number, d: number) => void;
1150
1171
  readonly engine_setPanorama: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
1151
1172
  readonly engine_setPanoramaImage: (a: number, b: number, c: any) => [number, number];
1173
+ readonly engine_setPivot: (a: number, b: number, c: number) => number;
1152
1174
  readonly engine_setPointCloudStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
1153
1175
  readonly engine_setRasterStyle: (a: number, b: number, c: number, d: number) => void;
1154
1176
  readonly engine_setRequestHeaders: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
@@ -1159,6 +1181,8 @@ export interface InitOutput {
1159
1181
  readonly engine_setSymbols: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number];
1160
1182
  readonly engine_setTerrain: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
1161
1183
  readonly engine_setTileLoader: (a: number, b: any) => void;
1184
+ readonly engine_setTiles3dFacades: (a: number, b: number, c: number) => void;
1185
+ readonly engine_setTiles3dFeatureColors: (a: number, b: number, c: any) => void;
1162
1186
  readonly engine_setTiles3dStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
1163
1187
  readonly engine_setVectorSublayers: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number) => void;
1164
1188
  readonly engine_setVectorTile: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number, z: number, a1: number, b1: number, c1: number, d1: number, e1: number, f1: number, g1: number) => [number, number];
@@ -154,16 +154,20 @@ export class Engine {
154
154
  * @param {Uint32Array} start
155
155
  * @param {Uint32Array} feature
156
156
  * @param {number} feature_count
157
+ * @param {Float64Array | null} [heights]
158
+ * @param {boolean | null} [sea]
157
159
  * @returns {number}
158
160
  */
159
- addLines(points, start, feature, feature_count) {
161
+ addLines(points, start, feature, feature_count, heights, sea) {
160
162
  const ptr0 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
161
163
  const len0 = WASM_VECTOR_LEN;
162
164
  const ptr1 = passArray32ToWasm0(start, wasm.__wbindgen_malloc);
163
165
  const len1 = WASM_VECTOR_LEN;
164
166
  const ptr2 = passArray32ToWasm0(feature, wasm.__wbindgen_malloc);
165
167
  const len2 = WASM_VECTOR_LEN;
166
- const ret = wasm.engine_addLines(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, feature_count);
168
+ var ptr3 = isLikeNone(heights) ? 0 : passArrayF64ToWasm0(heights, wasm.__wbindgen_malloc);
169
+ var len3 = WASM_VECTOR_LEN;
170
+ const ret = wasm.engine_addLines(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, feature_count, ptr3, len3, isLikeNone(sea) ? 0xFFFFFF : sea ? 1 : 0);
167
171
  if (ret[2]) {
168
172
  throw takeFromExternrefTable0(ret[1]);
169
173
  }
@@ -361,6 +365,12 @@ export class Engine {
361
365
  clearPanorama() {
362
366
  wasm.engine_clearPanorama(this.__wbg_ptr);
363
367
  }
368
+ /**
369
+ * The turns go around the screen center again
370
+ */
371
+ clearPivot() {
372
+ wasm.engine_clearPivot(this.__wbg_ptr);
373
+ }
364
374
  /**
365
375
  * Stops loading the tiles of the flight's destination (`preload`)
366
376
  */
@@ -414,7 +424,9 @@ export class Engine {
414
424
  return ret;
415
425
  }
416
426
  /**
417
- * Position under a screen point (CSS pixels), undefined above the horizon; on the relief itself
427
+ * Position under a screen point (CSS pixels), undefined above the horizon; on the relief itself: from the copy of
428
+ * its tiles kept on the CPU, the drawn ground read back from the GPU only where none is there (a read back waits
429
+ * for the frame: called during a move, it stalls it)
418
430
  * @param {number} x
419
431
  * @param {number} y
420
432
  * @returns {[lon: number, lat: number] | undefined}
@@ -640,7 +652,7 @@ export class Engine {
640
652
  wasm.engine_resize(this.__wbg_ptr, width, height, pixel_ratio);
641
653
  }
642
654
  /**
643
- * Turns and tilts around the screen center, in degrees
655
+ * Turns and tilts, in degrees: around the pivot if one is set (`setPivot`), else around the screen center
644
656
  * @param {number} bearing
645
657
  * @param {number} pitch
646
658
  */
@@ -1117,15 +1129,19 @@ export class Engine {
1117
1129
  * @param {Float64Array} points
1118
1130
  * @param {Uint32Array} start
1119
1131
  * @param {Uint32Array} feature
1132
+ * @param {Float64Array | null} [heights]
1133
+ * @param {boolean | null} [sea]
1120
1134
  */
1121
- setLines(id, points, start, feature) {
1135
+ setLines(id, points, start, feature, heights, sea) {
1122
1136
  const ptr0 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
1123
1137
  const len0 = WASM_VECTOR_LEN;
1124
1138
  const ptr1 = passArray32ToWasm0(start, wasm.__wbindgen_malloc);
1125
1139
  const len1 = WASM_VECTOR_LEN;
1126
1140
  const ptr2 = passArray32ToWasm0(feature, wasm.__wbindgen_malloc);
1127
1141
  const len2 = WASM_VECTOR_LEN;
1128
- const ret = wasm.engine_setLines(this.__wbg_ptr, id, ptr0, len0, ptr1, len1, ptr2, len2);
1142
+ var ptr3 = isLikeNone(heights) ? 0 : passArrayF64ToWasm0(heights, wasm.__wbindgen_malloc);
1143
+ var len3 = WASM_VECTOR_LEN;
1144
+ const ret = wasm.engine_setLines(this.__wbg_ptr, id, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, isLikeNone(sea) ? 0xFFFFFF : sea ? 1 : 0);
1129
1145
  if (ret[1]) {
1130
1146
  throw takeFromExternrefTable0(ret[0]);
1131
1147
  }
@@ -1268,6 +1284,18 @@ export class Engine {
1268
1284
  throw takeFromExternrefTable0(ret[0]);
1269
1285
  }
1270
1286
  }
1287
+ /**
1288
+ * Sets the point the next turns and tilts go around (`rotate`): what is drawn under a screen point (CSS
1289
+ * pixels), a roof or a mesh as the relief. Read back from the last frame (a stall): once, where a drag starts.
1290
+ * Returns whether something was drawn there; over nothing, the turns go around the center
1291
+ * @param {number} x
1292
+ * @param {number} y
1293
+ * @returns {boolean}
1294
+ */
1295
+ setPivot(x, y) {
1296
+ const ret = wasm.engine_setPivot(this.__wbg_ptr, x, y);
1297
+ return ret !== 0;
1298
+ }
1271
1299
  /**
1272
1300
  * The style of a point cloud: 14 numbers (see `Style::parse`), the colors of the 256 classes (RGBA,
1273
1301
  * alpha 0 hides a class) and the ramp of the altitudes (256 RGBA texels)
@@ -1439,6 +1467,22 @@ export class Engine {
1439
1467
  setTileLoader(loader) {
1440
1468
  wasm.engine_setTileLoader(this.__wbg_ptr, loader);
1441
1469
  }
1470
+ /**
1471
+ * Whether the walls of a 3D Tiles layer's untextured meshes show their windows: glass by day, some lit at night
1472
+ * @param {number} id
1473
+ * @param {boolean} facades
1474
+ */
1475
+ setTiles3dFacades(id, facades) {
1476
+ wasm.engine_setTiles3dFacades(this.__wbg_ptr, id, facades);
1477
+ }
1478
+ /**
1479
+ * Each feature of a 3D Tiles layer its color (null: the layer's)
1480
+ * @param {number} id
1481
+ * @param {((properties: Record<string, unknown>[] | undefined, count: number) => Uint8Array) | null} colors
1482
+ */
1483
+ setTiles3dFeatureColors(id, colors) {
1484
+ wasm.engine_setTiles3dFeatureColors(this.__wbg_ptr, id, colors);
1485
+ }
1442
1486
  /**
1443
1487
  * Screen-space error threshold, opacity, size of the points (CSS pixels, 2 if not given) and color (RGB 0-1, empty
1444
1488
  * for none: it tints the textures and colors the untextured meshes) of a 3D Tiles layer
@@ -2093,6 +2137,10 @@ function __wbg_get_imports() {
2093
2137
  const ret = arg0.call(arg1, arg2, arg3, arg4, arg5);
2094
2138
  return ret;
2095
2139
  }, arguments); },
2140
+ __wbg_call_1875a20c43a36133: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2141
+ const ret = arg0.call(arg1, arg2, arg3);
2142
+ return ret;
2143
+ }, arguments); },
2096
2144
  __wbg_call_187d372bd5fdd4aa: function() { return handleError(function (arg0, arg1, arg2) {
2097
2145
  const ret = arg0.call(arg1, arg2);
2098
2146
  return ret;
@@ -2282,6 +2330,12 @@ function __wbg_get_imports() {
2282
2330
  __wbg_detachShader_67dabaaad80a795e: function(arg0, arg1, arg2) {
2283
2331
  arg0.detachShader(arg1, arg2);
2284
2332
  },
2333
+ __wbg_disableVertexAttribArray_11c9f11bee30c9d8: function(arg0, arg1) {
2334
+ arg0.disableVertexAttribArray(arg1 >>> 0);
2335
+ },
2336
+ __wbg_disableVertexAttribArray_c4c8af1f9e4120d4: function(arg0, arg1) {
2337
+ arg0.disableVertexAttribArray(arg1 >>> 0);
2338
+ },
2285
2339
  __wbg_disable_19fe787eccdf0272: function(arg0, arg1) {
2286
2340
  arg0.disable(arg1 >>> 0);
2287
2341
  },
@@ -3129,7 +3183,7 @@ function __wbg_get_imports() {
3129
3183
  return ret;
3130
3184
  },
3131
3185
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
3132
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 226, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3186
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 229, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3133
3187
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_2e566c63402fe7fa___convert__closures_____invoke___wasm_bindgen_2e566c63402fe7fa___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_2e566c63402fe7fa___JsError___true_);
3134
3188
  return ret;
3135
3189
  },
@@ -132,7 +132,7 @@ export class Engine {
132
132
  * Throws (to JavaScript) when a WebGL object cannot be created or a shader fails to compile (the error carries its
133
133
  * info log), or when the features or the lines need a table texture past the GPU's `MAX_TEXTURE_SIZE`
134
134
  */
135
- addLines(points: Float64Array, start: Uint32Array, feature: Uint32Array, feature_count: number): number;
135
+ addLines(points: Float64Array, start: Uint32Array, feature: Uint32Array, feature_count: number, heights?: Float64Array | null, sea?: boolean | null): number;
136
136
  /**
137
137
  * Network of `mercator.length / 2` nodes (Mercator [0, 1], y towards the south, interleaved: converted by the
138
138
  * JavaScript side, where `Math.tan` and `Math.log` are much faster than in WebAssembly) and `edges.length / 2`
@@ -184,6 +184,10 @@ export class Engine {
184
184
  * The camera as set or moved: center (degrees), zoom, pitch and bearing (degrees)
185
185
  */
186
186
  camera(): Camera;
187
+ /**
188
+ * The turns go around the screen center again
189
+ */
190
+ clearPivot(): void;
187
191
  /**
188
192
  * Stops loading the tiles of the flight's destination (`preload`)
189
193
  */
@@ -209,7 +213,9 @@ export class Engine {
209
213
  */
210
214
  static geoidHeight(lon: number, lat: number): number;
211
215
  /**
212
- * Position under a screen point (CSS pixels), undefined above the horizon; on the relief itself
216
+ * Position under a screen point (CSS pixels), undefined above the horizon; on the relief itself: from the copy of
217
+ * its tiles kept on the CPU, the drawn ground read back from the GPU only where none is there (a read back waits
218
+ * for the frame: called during a move, it stalls it)
213
219
  */
214
220
  ground(x: number, y: number): [lon: number, lat: number] | undefined;
215
221
  /**
@@ -300,7 +306,7 @@ export class Engine {
300
306
  */
301
307
  resize(width: number, height: number, pixel_ratio: number): void;
302
308
  /**
303
- * Turns and tilts around the screen center, in degrees
309
+ * Turns and tilts, in degrees: around the pivot if one is set (`setPivot`), else around the screen center
304
310
  */
305
311
  rotate(bearing: number, pitch: number): void;
306
312
  /**
@@ -500,7 +506,7 @@ export class Engine {
500
506
  * Throws (to JavaScript) when the lines need a table texture past the GPU's `MAX_TEXTURE_SIZE`, or
501
507
  * when it cannot be created; the layer then keeps its lines
502
508
  */
503
- setLines(id: number, points: Float64Array, start: Uint32Array, feature: Uint32Array): void;
509
+ setLines(id: number, points: Float64Array, start: Uint32Array, feature: Uint32Array, heights?: Float64Array | null, sea?: boolean | null): void;
504
510
  /**
505
511
  * Highest pitch the camera accepts, degrees (up to 85)
506
512
  */
@@ -527,6 +533,12 @@ export class Engine {
527
533
  * One value per node; negative = unreached
528
534
  */
529
535
  setNetworkValues(id: number, values: Float32Array): void;
536
+ /**
537
+ * Sets the point the next turns and tilts go around (`rotate`): what is drawn under a screen point (CSS
538
+ * pixels), a roof or a mesh as the relief. Read back from the last frame (a stall): once, where a drag starts.
539
+ * Returns whether something was drawn there; over nothing, the turns go around the center
540
+ */
541
+ setPivot(x: number, y: number): boolean;
530
542
  /**
531
543
  * Opacity and saturation (0-1) of a raster layer; nothing for another id
532
544
  */
@@ -732,13 +744,14 @@ export interface InitOutput {
732
744
  readonly engine_addFills: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number];
733
745
  readonly engine_addFlow: (a: number, b: number, c: number) => [number, number, number];
734
746
  readonly engine_addGround: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number];
735
- readonly engine_addLines: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
747
+ readonly engine_addLines: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number];
736
748
  readonly engine_addNetwork: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => [number, number, number];
737
749
  readonly engine_addRaster: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number];
738
750
  readonly engine_addSymbols: (a: number) => [number, number, number];
739
751
  readonly engine_addVectorTiles: (a: number) => [number, number, number];
740
752
  readonly engine_bounds: (a: number) => [number, number];
741
753
  readonly engine_camera: (a: number) => any;
754
+ readonly engine_clearPivot: (a: number) => void;
742
755
  readonly engine_clearPreload: (a: number) => void;
743
756
  readonly engine_clearViewshed: (a: number) => void;
744
757
  readonly engine_customMatrix: (a: number, b: number, c: number) => [number, number];
@@ -795,13 +808,14 @@ export interface InitOutput {
795
808
  readonly engine_setIconAtlas: (a: number, b: number, c: number) => [number, number];
796
809
  readonly engine_setImmediateLoading: (a: number, b: number) => void;
797
810
  readonly engine_setLineDash: (a: number, b: number, c: number, d: number) => void;
798
- readonly engine_setLines: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
811
+ readonly engine_setLines: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number];
799
812
  readonly engine_setMaxPitch: (a: number, b: number) => void;
800
813
  readonly engine_setNetworkCosts: (a: number, b: number, c: number, d: number) => void;
801
814
  readonly engine_setNetworkRamp: (a: number, b: number, c: number, d: number) => void;
802
815
  readonly engine_setNetworkScales: (a: number, b: number, c: number, d: number) => void;
803
816
  readonly engine_setNetworkStyle: (a: number, b: number, c: number, d: number) => void;
804
817
  readonly engine_setNetworkValues: (a: number, b: number, c: number, d: number) => void;
818
+ readonly engine_setPivot: (a: number, b: number, c: number) => number;
805
819
  readonly engine_setRasterStyle: (a: number, b: number, c: number, d: number) => void;
806
820
  readonly engine_setRequestHeaders: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
807
821
  readonly engine_setSky: (a: number, b: number) => void;