@antv/l7-map 2.18.2 → 2.18.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.
Files changed (168) hide show
  1. package/es/camera.d.ts +85 -0
  2. package/es/camera.js +718 -0
  3. package/es/css/l7.css +98 -0
  4. package/es/earthmap.d.ts +66 -0
  5. package/es/earthmap.js +369 -0
  6. package/es/geo/edge_insets.d.ts +54 -0
  7. package/es/geo/edge_insets.js +108 -0
  8. package/es/geo/lng_lat.d.ts +18 -0
  9. package/es/geo/lng_lat.js +73 -0
  10. package/es/geo/lng_lat_bounds.d.ts +24 -0
  11. package/es/geo/lng_lat_bounds.js +154 -0
  12. package/es/geo/mercator.d.ts +29 -0
  13. package/es/geo/mercator.js +84 -0
  14. package/es/geo/point.d.ts +40 -0
  15. package/es/geo/point.js +224 -0
  16. package/es/geo/simple.d.ts +29 -0
  17. package/es/geo/simple.js +87 -0
  18. package/es/geo/transform.d.ts +198 -0
  19. package/es/geo/transform.js +961 -0
  20. package/es/handler/IHandler.d.ts +34 -0
  21. package/es/handler/IHandler.js +1 -0
  22. package/es/handler/blockable_map_event.d.ts +17 -0
  23. package/es/handler/blockable_map_event.js +78 -0
  24. package/es/handler/box_zoom.d.ts +59 -0
  25. package/es/handler/box_zoom.js +180 -0
  26. package/es/handler/click_zoom.d.ts +16 -0
  27. package/es/handler/click_zoom.js +54 -0
  28. package/es/handler/events/event.d.ts +4 -0
  29. package/es/handler/events/event.js +11 -0
  30. package/es/handler/events/index.d.ts +4 -0
  31. package/es/handler/events/index.js +4 -0
  32. package/es/handler/events/map_mouse_event.d.ts +34 -0
  33. package/es/handler/events/map_mouse_event.js +64 -0
  34. package/es/handler/events/map_touch_event.d.ts +57 -0
  35. package/es/handler/events/map_touch_event.js +95 -0
  36. package/es/handler/events/map_wheel_event.d.ts +33 -0
  37. package/es/handler/events/map_wheel_event.js +50 -0
  38. package/es/handler/events/render_event.d.ts +5 -0
  39. package/es/handler/events/render_event.js +26 -0
  40. package/es/handler/handler_inertia.d.ts +23 -0
  41. package/es/handler/handler_inertia.js +157 -0
  42. package/es/handler/handler_manager.d.ts +61 -0
  43. package/es/handler/handler_manager.js +577 -0
  44. package/es/handler/handler_util.d.ts +4 -0
  45. package/es/handler/handler_util.js +9 -0
  46. package/es/handler/keyboard.d.ts +36 -0
  47. package/es/handler/keyboard.js +143 -0
  48. package/es/handler/map_event.d.ts +29 -0
  49. package/es/handler/map_event.js +125 -0
  50. package/es/handler/mouse/index.d.ts +4 -0
  51. package/es/handler/mouse/index.js +4 -0
  52. package/es/handler/mouse/mouse_handler.d.ts +22 -0
  53. package/es/handler/mouse/mouse_handler.js +118 -0
  54. package/es/handler/mouse/mousepan_handler.d.ts +10 -0
  55. package/es/handler/mouse/mousepan_handler.js +44 -0
  56. package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
  57. package/es/handler/mouse/mousepitch_hander.js +46 -0
  58. package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
  59. package/es/handler/mouse/mouserotate_hander.js +46 -0
  60. package/es/handler/mouse/util.d.ts +6 -0
  61. package/es/handler/mouse/util.js +11 -0
  62. package/es/handler/scroll_zoom.d.ts +93 -0
  63. package/es/handler/scroll_zoom.js +325 -0
  64. package/es/handler/shim/dblclick_zoom.d.ts +40 -0
  65. package/es/handler/shim/dblclick_zoom.js +67 -0
  66. package/es/handler/shim/drag_pan.d.ts +61 -0
  67. package/es/handler/shim/drag_pan.js +84 -0
  68. package/es/handler/shim/drag_rotate.d.ts +46 -0
  69. package/es/handler/shim/drag_rotate.js +74 -0
  70. package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
  71. package/es/handler/shim/touch_zoom_rotate.js +115 -0
  72. package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
  73. package/es/handler/tap/single_tap_recognizer.js +97 -0
  74. package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
  75. package/es/handler/tap/tap_drag_zoom.js +106 -0
  76. package/es/handler/tap/tap_recognizer.d.ts +17 -0
  77. package/es/handler/tap/tap_recognizer.js +54 -0
  78. package/es/handler/tap/tap_zoom.d.ts +22 -0
  79. package/es/handler/tap/tap_zoom.js +109 -0
  80. package/es/handler/touch/index.d.ts +5 -0
  81. package/es/handler/touch/index.js +5 -0
  82. package/es/handler/touch/touch_pan.d.ts +30 -0
  83. package/es/handler/touch/touch_pan.js +110 -0
  84. package/es/handler/touch/touch_pitch.d.ts +13 -0
  85. package/es/handler/touch/touch_pitch.js +93 -0
  86. package/es/handler/touch/touch_rotate.d.ts +12 -0
  87. package/es/handler/touch/touch_rotate.js +77 -0
  88. package/es/handler/touch/touch_zoom.d.ts +12 -0
  89. package/es/handler/touch/touch_zoom.js +54 -0
  90. package/es/handler/touch/two_touch.d.ts +23 -0
  91. package/es/handler/touch/two_touch.js +125 -0
  92. package/es/hash.d.ts +14 -0
  93. package/es/hash.js +134 -0
  94. package/es/index.d.ts +4 -0
  95. package/es/index.js +4 -0
  96. package/es/interface.d.ts +34 -0
  97. package/es/interface.js +1 -0
  98. package/es/map.d.ts +70 -0
  99. package/es/map.js +387 -0
  100. package/es/util.d.ts +25 -0
  101. package/es/util.js +88 -0
  102. package/es/utils/Aabb.d.ts +12 -0
  103. package/es/utils/Aabb.js +112 -0
  104. package/es/utils/dom.d.ts +4 -0
  105. package/es/utils/dom.js +140 -0
  106. package/es/utils/performance.d.ts +17 -0
  107. package/es/utils/performance.js +62 -0
  108. package/es/utils/primitives.d.ts +6 -0
  109. package/es/utils/primitives.js +47 -0
  110. package/es/utils/task_queue.d.ts +13 -0
  111. package/es/utils/task_queue.js +89 -0
  112. package/lib/camera.js +724 -0
  113. package/lib/css/l7.css +98 -0
  114. package/lib/earthmap.js +376 -0
  115. package/lib/geo/edge_insets.js +114 -0
  116. package/lib/geo/lng_lat.js +81 -0
  117. package/lib/geo/lng_lat_bounds.js +161 -0
  118. package/lib/geo/mercator.js +100 -0
  119. package/lib/geo/point.js +231 -0
  120. package/lib/geo/simple.js +104 -0
  121. package/lib/geo/transform.js +971 -0
  122. package/lib/handler/IHandler.js +5 -0
  123. package/lib/handler/blockable_map_event.js +84 -0
  124. package/lib/handler/box_zoom.js +186 -0
  125. package/lib/handler/click_zoom.js +61 -0
  126. package/lib/handler/events/event.js +20 -0
  127. package/lib/handler/events/index.js +27 -0
  128. package/lib/handler/events/map_mouse_event.js +70 -0
  129. package/lib/handler/events/map_touch_event.js +100 -0
  130. package/lib/handler/events/map_wheel_event.js +57 -0
  131. package/lib/handler/events/render_event.js +33 -0
  132. package/lib/handler/handler_inertia.js +162 -0
  133. package/lib/handler/handler_manager.js +584 -0
  134. package/lib/handler/handler_util.js +15 -0
  135. package/lib/handler/keyboard.js +151 -0
  136. package/lib/handler/map_event.js +131 -0
  137. package/lib/handler/mouse/index.js +27 -0
  138. package/lib/handler/mouse/mouse_handler.js +124 -0
  139. package/lib/handler/mouse/mousepan_handler.js +49 -0
  140. package/lib/handler/mouse/mousepitch_hander.js +51 -0
  141. package/lib/handler/mouse/mouserotate_hander.js +51 -0
  142. package/lib/handler/mouse/util.js +22 -0
  143. package/lib/handler/scroll_zoom.js +333 -0
  144. package/lib/handler/shim/dblclick_zoom.js +74 -0
  145. package/lib/handler/shim/drag_pan.js +91 -0
  146. package/lib/handler/shim/drag_rotate.js +81 -0
  147. package/lib/handler/shim/touch_zoom_rotate.js +122 -0
  148. package/lib/handler/tap/single_tap_recognizer.js +106 -0
  149. package/lib/handler/tap/tap_drag_zoom.js +112 -0
  150. package/lib/handler/tap/tap_recognizer.js +63 -0
  151. package/lib/handler/tap/tap_zoom.js +115 -0
  152. package/lib/handler/touch/index.js +34 -0
  153. package/lib/handler/touch/touch_pan.js +117 -0
  154. package/lib/handler/touch/touch_pitch.js +98 -0
  155. package/lib/handler/touch/touch_rotate.js +82 -0
  156. package/lib/handler/touch/touch_zoom.js +59 -0
  157. package/lib/handler/touch/two_touch.js +131 -0
  158. package/lib/hash.js +143 -0
  159. package/lib/index.js +49 -0
  160. package/lib/interface.js +5 -0
  161. package/lib/map.js +394 -0
  162. package/lib/util.js +108 -0
  163. package/lib/utils/Aabb.js +119 -0
  164. package/lib/utils/dom.js +147 -0
  165. package/lib/utils/performance.js +70 -0
  166. package/lib/utils/primitives.js +54 -0
  167. package/lib/utils/task_queue.js +97 -0
  168. package/package.json +3 -3
package/es/util.js ADDED
@@ -0,0 +1,88 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ // @ts-ignore
5
+ import UnitBezier from '@mapbox/unitbezier';
6
+ var reducedMotionQuery;
7
+ export function wrap(n, min, max) {
8
+ var d = max - min;
9
+ var w = ((n - min) % d + d) % d + min;
10
+ return w === min ? max : w;
11
+ }
12
+ export function clamp(n, min, max) {
13
+ return Math.min(max, Math.max(min, n));
14
+ }
15
+ export function interpolate(a, b, t) {
16
+ return a * (1 - t) + b * t;
17
+ }
18
+ export function bezier(p1x, p1y, p2x, p2y) {
19
+ var bez = new UnitBezier(p1x, p1y, p2x, p2y);
20
+ return function (t) {
21
+ return bez.solve(t);
22
+ };
23
+ }
24
+ export var ease = bezier(0.25, 0.1, 0.25, 1);
25
+ export function prefersReducedMotion() {
26
+ // Lazily initialize media query
27
+ if (reducedMotionQuery == null) {
28
+ // @ts-ignore
29
+ reducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
30
+ }
31
+ return reducedMotionQuery.matches;
32
+ }
33
+ export function pick(src, properties) {
34
+ var result = {};
35
+ var _iterator = _createForOfIteratorHelper(properties),
36
+ _step;
37
+ try {
38
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
39
+ var name = _step.value;
40
+ if (name in src) {
41
+ result[name] = src[name];
42
+ }
43
+ }
44
+ } catch (err) {
45
+ _iterator.e(err);
46
+ } finally {
47
+ _iterator.f();
48
+ }
49
+ return result;
50
+ }
51
+ export var now = window.performance && window.performance.now ? window.performance.now.bind(window.performance) : Date.now.bind(Date);
52
+ export var raf = window.requestAnimationFrame ||
53
+ // @ts-ignore
54
+ window.mozRequestAnimationFrame ||
55
+ // @ts-ignore
56
+ window.webkitRequestAnimationFrame ||
57
+ // @ts-ignore
58
+ window.msRequestAnimationFrame;
59
+ var _cancel = window.cancelAnimationFrame ||
60
+ // @ts-ignore
61
+ window.mozCancelAnimationFrame ||
62
+ // @ts-ignore
63
+ window.webkitCancelAnimationFrame ||
64
+ // @ts-ignore
65
+ window.msCancelAnimationFrame;
66
+ export { _cancel as cancel };
67
+ export function renderframe(fn) {
68
+ var frame = raf(fn);
69
+ return {
70
+ cancel: function cancel() {
71
+ return _cancel(frame);
72
+ }
73
+ };
74
+ }
75
+ export function extend(dest) {
76
+ for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
77
+ sources[_key - 1] = arguments[_key];
78
+ }
79
+ for (var _i = 0, _sources = sources; _i < _sources.length; _i++) {
80
+ var src = _sources[_i];
81
+ for (var k in src) {
82
+ if (src[k] !== undefined) {
83
+ dest[k] = src[k];
84
+ }
85
+ }
86
+ }
87
+ return dest;
88
+ }
@@ -0,0 +1,12 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ import Frustum from './primitives';
3
+ export default class Aabb {
4
+ min: vec3;
5
+ max: vec3;
6
+ center: vec3;
7
+ constructor(min: vec3, max: vec3);
8
+ quadrant(index: number): Aabb;
9
+ distanceX(point: number[]): number;
10
+ distanceY(point: number[]): number;
11
+ intersects(frustum: Frustum): number;
12
+ }
@@ -0,0 +1,112 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
+ import { vec3, vec4 } from 'gl-matrix';
7
+ var Aabb = /*#__PURE__*/function () {
8
+ function Aabb(min, max) {
9
+ _classCallCheck(this, Aabb);
10
+ this.min = min;
11
+ this.max = max;
12
+ this.center = vec3.scale(new Float32Array(3), vec3.add(new Float32Array(3), this.min, this.max), 0.5);
13
+ }
14
+ _createClass(Aabb, [{
15
+ key: "quadrant",
16
+ value: function quadrant(index) {
17
+ var split = [index % 2 === 0, index < 2];
18
+ var qMin = vec3.clone(this.min);
19
+ var qMax = vec3.clone(this.max);
20
+ for (var axis = 0; axis < split.length; axis++) {
21
+ qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];
22
+ qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];
23
+ }
24
+ // Elevation is always constant, hence quadrant.max.z = this.max.z
25
+ qMax[2] = this.max[2];
26
+ return new Aabb(qMin, qMax);
27
+ }
28
+ }, {
29
+ key: "distanceX",
30
+ value: function distanceX(point) {
31
+ var pointOnAabb = Math.max(Math.min(this.max[0], point[0]), this.min[0]);
32
+ return pointOnAabb - point[0];
33
+ }
34
+ }, {
35
+ key: "distanceY",
36
+ value: function distanceY(point) {
37
+ var pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);
38
+ return pointOnAabb - point[1];
39
+ }
40
+
41
+ // Performs a frustum-aabb intersection test. Returns 0 if there's no intersection,
42
+ // 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum.
43
+ }, {
44
+ key: "intersects",
45
+ value: function intersects(frustum) {
46
+ // Execute separating axis test between two convex objects to find intersections
47
+ // Each frustum plane together with 3 major axes define the separating axes
48
+ // Note: test only 4 points as both min and max points have equal elevation
49
+
50
+ var aabbPoints = [[this.min[0], this.min[1], 0.0, 1], [this.max[0], this.min[1], 0.0, 1], [this.max[0], this.max[1], 0.0, 1], [this.min[0], this.max[1], 0.0, 1]];
51
+ var fullyInside = true;
52
+ var _iterator = _createForOfIteratorHelper(frustum.planes),
53
+ _step;
54
+ try {
55
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
56
+ var plane = _step.value;
57
+ var pointsInside = 0;
58
+ var _iterator3 = _createForOfIteratorHelper(aabbPoints),
59
+ _step3;
60
+ try {
61
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
62
+ var i = _step3.value;
63
+ // @ts-ignore
64
+ pointsInside += vec4.dot(plane, i) >= 0;
65
+ }
66
+ } catch (err) {
67
+ _iterator3.e(err);
68
+ } finally {
69
+ _iterator3.f();
70
+ }
71
+ if (pointsInside === 0) {
72
+ return 0;
73
+ }
74
+ if (pointsInside !== aabbPoints.length) {
75
+ fullyInside = false;
76
+ }
77
+ }
78
+ } catch (err) {
79
+ _iterator.e(err);
80
+ } finally {
81
+ _iterator.f();
82
+ }
83
+ if (fullyInside) {
84
+ return 2;
85
+ }
86
+ for (var axis = 0; axis < 3; axis++) {
87
+ var projMin = Number.MAX_VALUE;
88
+ var projMax = -Number.MAX_VALUE;
89
+ var _iterator2 = _createForOfIteratorHelper(frustum.points),
90
+ _step2;
91
+ try {
92
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
93
+ var p = _step2.value;
94
+ var projectedPoint = p[axis] - this.min[axis];
95
+ projMin = Math.min(projMin, projectedPoint);
96
+ projMax = Math.max(projMax, projectedPoint);
97
+ }
98
+ } catch (err) {
99
+ _iterator2.e(err);
100
+ } finally {
101
+ _iterator2.f();
102
+ }
103
+ if (projMax < 0 || projMin > this.max[axis] - this.min[axis]) {
104
+ return 0;
105
+ }
106
+ }
107
+ return 1;
108
+ }
109
+ }]);
110
+ return Aabb;
111
+ }();
112
+ export { Aabb as default };
@@ -0,0 +1,4 @@
1
+ declare const DOM: {
2
+ [key: string]: (...arg: any[]) => any;
3
+ };
4
+ export default DOM;
@@ -0,0 +1,140 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ // @ts-ignore
5
+ import Point from "../geo/point";
6
+ var DOM = {};
7
+ export default DOM;
8
+ DOM.create = function (tagName, className, container) {
9
+ var el = window.document.createElement(tagName);
10
+ if (className !== undefined) {
11
+ el.className = className;
12
+ }
13
+ if (container) {
14
+ container.appendChild(el);
15
+ }
16
+ return el;
17
+ };
18
+ DOM.createNS = function (namespaceURI, tagName) {
19
+ var el = window.document.createElementNS(namespaceURI, tagName);
20
+ return el;
21
+ };
22
+ var docStyle = window.document && window.document.documentElement.style;
23
+ function testProp(props) {
24
+ if (!docStyle) {
25
+ return props[0];
26
+ }
27
+ var _iterator = _createForOfIteratorHelper(props),
28
+ _step;
29
+ try {
30
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
31
+ var i = _step.value;
32
+ if (i in docStyle) {
33
+ return i;
34
+ }
35
+ }
36
+ } catch (err) {
37
+ _iterator.e(err);
38
+ } finally {
39
+ _iterator.f();
40
+ }
41
+ return props[0];
42
+ }
43
+ var selectProp = testProp(['userSelect', 'MozUserSelect', 'WebkitUserSelect', 'msUserSelect']);
44
+ var userSelect;
45
+ DOM.disableDrag = function () {
46
+ if (docStyle && selectProp) {
47
+ userSelect = docStyle[selectProp];
48
+ docStyle[selectProp] = 'none';
49
+ }
50
+ };
51
+ DOM.enableDrag = function () {
52
+ if (docStyle && selectProp) {
53
+ docStyle[selectProp] = userSelect;
54
+ }
55
+ };
56
+ var transformProp = testProp(['transform', 'WebkitTransform']);
57
+ DOM.setTransform = function (el, value) {
58
+ // https://github.com/facebook/flow/issues/7754
59
+ // $FlowFixMe
60
+ el.style[transformProp] = value;
61
+ };
62
+
63
+ // Feature detection for {passive: false} support in add/removeEventListener.
64
+ var passiveSupported = false;
65
+ try {
66
+ // https://github.com/facebook/flow/issues/285
67
+ // $FlowFixMe
68
+ var options = Object.defineProperty({}, 'passive', {
69
+ get: function get() {
70
+ // eslint-disable-line
71
+ passiveSupported = true;
72
+ }
73
+ });
74
+ // @ts-ignore
75
+ window.addEventListener('test', options, options);
76
+ // @ts-ignore
77
+ window.removeEventListener('test', options, options);
78
+ } catch (err) {
79
+ passiveSupported = false;
80
+ }
81
+ DOM.addEventListener = function (target, type, callback) {
82
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
83
+ if ('passive' in options && passiveSupported) {
84
+ target.addEventListener(type, callback, options);
85
+ } else {
86
+ target.addEventListener(type, callback, options.capture);
87
+ }
88
+ };
89
+ DOM.removeEventListener = function (target, type, callback) {
90
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
91
+ if ('passive' in options && passiveSupported) {
92
+ target.removeEventListener(type, callback, options);
93
+ } else {
94
+ target.removeEventListener(type, callback, options.capture);
95
+ }
96
+ };
97
+
98
+ // Suppress the next click, but only if it's immediate.
99
+ var suppressClick = function suppressClick(e) {
100
+ e.preventDefault();
101
+ e.stopPropagation();
102
+ window.removeEventListener('click', suppressClick, true);
103
+ };
104
+ DOM.suppressClick = function () {
105
+ window.addEventListener('click', suppressClick, true);
106
+ setTimeout(function () {
107
+ window.removeEventListener('click', suppressClick, true);
108
+ }, 0);
109
+ };
110
+ DOM.mousePos = function (el, e) {
111
+ // 暂时从 el 上获取 top/left, 后面需要动态获取
112
+ var rect = el.getBoundingClientRect();
113
+ return new Point(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop);
114
+ };
115
+ DOM.touchPos = function (el, touches) {
116
+ // 暂时从 el 上获取 top/left, 后面需要动态获取
117
+ var rect = el.getBoundingClientRect();
118
+ var points = [];
119
+ var _iterator2 = _createForOfIteratorHelper(touches),
120
+ _step2;
121
+ try {
122
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
123
+ var touche = _step2.value;
124
+ points.push(new Point(touche.clientX - rect.left - el.clientLeft, touche.clientY - rect.top - el.clientTop));
125
+ }
126
+ } catch (err) {
127
+ _iterator2.e(err);
128
+ } finally {
129
+ _iterator2.f();
130
+ }
131
+ return points;
132
+ };
133
+ DOM.mouseButton = function (e) {
134
+ return e.button;
135
+ };
136
+ DOM.remove = function (node) {
137
+ if (node.parentNode) {
138
+ node.parentNode.removeChild(node);
139
+ }
140
+ };
@@ -0,0 +1,17 @@
1
+ export interface IPerformanceMetrics {
2
+ loadTime: number;
3
+ fullLoadTime: number;
4
+ fps: number;
5
+ percentDroppedFrames: number;
6
+ }
7
+ export declare const PerformanceMarkers: {
8
+ create: string;
9
+ load: string;
10
+ fullLoad: string;
11
+ };
12
+ export declare const PerformanceUtils: {
13
+ mark(marker: string): void;
14
+ frame(timestamp: number): void;
15
+ clearMetrics(): void;
16
+ getPerformanceMetrics(): IPerformanceMetrics;
17
+ };
@@ -0,0 +1,62 @@
1
+ var lastFrameTime = null;
2
+ var frameTimes = [];
3
+ var minFramerateTarget = 30;
4
+ var frameTimeTarget = 1000 / minFramerateTarget;
5
+ var performance = window.performance;
6
+ export var PerformanceMarkers = {
7
+ create: 'create',
8
+ load: 'load',
9
+ fullLoad: 'fullLoad'
10
+ };
11
+ export var PerformanceUtils = {
12
+ mark: function mark(marker) {
13
+ performance.mark(marker);
14
+ },
15
+ frame: function frame(timestamp) {
16
+ var currTimestamp = timestamp;
17
+ if (lastFrameTime != null) {
18
+ var frameTime = currTimestamp - lastFrameTime;
19
+ frameTimes.push(frameTime);
20
+ }
21
+ lastFrameTime = currTimestamp;
22
+ },
23
+ clearMetrics: function clearMetrics() {
24
+ lastFrameTime = null;
25
+ frameTimes = [];
26
+ performance.clearMeasures('loadTime');
27
+ performance.clearMeasures('fullLoadTime');
28
+ // @ts-ignore
29
+ // tslint:disable-next-line:forin
30
+ for (var marker in PerformanceMarkers) {
31
+ // @ts-ignore
32
+ performance.clearMarks(PerformanceMarkers[marker]);
33
+ }
34
+ },
35
+ getPerformanceMetrics: function getPerformanceMetrics() {
36
+ var loadTime = performance.measure('loadTime', PerformanceMarkers.create, PerformanceMarkers.load
37
+ // @ts-ignore
38
+ ).duration;
39
+ var fullLoadTime = performance.measure('fullLoadTime', PerformanceMarkers.create, PerformanceMarkers.fullLoad
40
+ // @ts-ignore
41
+ ).duration;
42
+ var totalFrames = frameTimes.length;
43
+ var avgFrameTime = frameTimes.reduce(function (prev, curr) {
44
+ return prev + curr;
45
+ }, 0) / totalFrames / 1000;
46
+ var fps = 1 / avgFrameTime;
47
+
48
+ // count frames that missed our framerate target
49
+ var droppedFrames = frameTimes.filter(function (frameTime) {
50
+ return frameTime > frameTimeTarget;
51
+ }).reduce(function (acc, curr) {
52
+ return acc + (curr - frameTimeTarget) / frameTimeTarget;
53
+ }, 0);
54
+ var percentDroppedFrames = droppedFrames / (totalFrames + droppedFrames) * 100;
55
+ return {
56
+ loadTime: loadTime,
57
+ fullLoadTime: fullLoadTime,
58
+ fps: fps,
59
+ percentDroppedFrames: percentDroppedFrames
60
+ };
61
+ }
62
+ };
@@ -0,0 +1,6 @@
1
+ export default class Frustum {
2
+ static fromInvProjectionMatrix(invProj: Float32Array, worldSize: number, zoom: number): Frustum;
3
+ points: number[][];
4
+ planes: number[][];
5
+ constructor(points: number[][], planes: number[][]);
6
+ }
@@ -0,0 +1,47 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import { vec3, vec4 } from 'gl-matrix';
4
+ var Frustum = /*#__PURE__*/function () {
5
+ function Frustum(points, planes) {
6
+ _classCallCheck(this, Frustum);
7
+ this.points = points;
8
+ this.planes = planes;
9
+ }
10
+ _createClass(Frustum, null, [{
11
+ key: "fromInvProjectionMatrix",
12
+ value: function fromInvProjectionMatrix(invProj, worldSize, zoom) {
13
+ var clipSpaceCorners = [[-1, 1, -1, 1], [1, 1, -1, 1], [1, -1, -1, 1], [-1, -1, -1, 1], [-1, 1, 1, 1], [1, 1, 1, 1], [1, -1, 1, 1], [-1, -1, 1, 1]];
14
+ var scale = Math.pow(2, zoom);
15
+
16
+ // Transform frustum corner points from clip space to tile space
17
+ var frustumCoords = clipSpaceCorners.map(function (v) {
18
+ return vec4.transformMat4(new Float32Array([]), v, invProj);
19
+ }).map(function (v) {
20
+ return vec4.scale(new Float32Array([]), v, 1.0 / v[3] / worldSize * scale);
21
+ });
22
+ var frustumPlanePointIndices = [[0, 1, 2],
23
+ // near
24
+ [6, 5, 4],
25
+ // far
26
+ [0, 3, 7],
27
+ // left
28
+ [2, 1, 5],
29
+ // right
30
+ [3, 2, 6],
31
+ // bottom
32
+ [0, 4, 5] // top
33
+ ];
34
+
35
+ var frustumPlanes = frustumPlanePointIndices.map(function (p) {
36
+ var a = vec3.sub(new Float32Array(3), new Float32Array(frustumCoords[p[0]]), new Float32Array(frustumCoords[p[1]]));
37
+ var b = vec3.sub(new Float32Array(3), new Float32Array(frustumCoords[p[2]]), new Float32Array(frustumCoords[p[1]]));
38
+ var n = vec3.normalize(new Float32Array(3), vec3.cross(new Float32Array(3), a, b));
39
+ var d = -vec3.dot(n, new Float32Array(frustumCoords[p[1]]));
40
+ return n.concat(d);
41
+ });
42
+ return new Frustum(frustumCoords, frustumPlanes);
43
+ }
44
+ }]);
45
+ return Frustum;
46
+ }();
47
+ export { Frustum as default };
@@ -0,0 +1,13 @@
1
+ export type TaskID = number;
2
+ declare class TaskQueue {
3
+ private queue;
4
+ private id;
5
+ private cleared;
6
+ private currentlyRunning;
7
+ constructor();
8
+ add(callback: (timeStamp: number) => void): TaskID;
9
+ remove(id: TaskID): void;
10
+ run(timeStamp?: number): void;
11
+ clear(): void;
12
+ }
13
+ export default TaskQueue;
@@ -0,0 +1,89 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
+ // can't mark opaque due to https://github.com/flowtype/flow-remove-types/pull/61
7
+ var TaskQueue = /*#__PURE__*/function () {
8
+ function TaskQueue() {
9
+ _classCallCheck(this, TaskQueue);
10
+ this.queue = [];
11
+ this.id = 0;
12
+ this.cleared = false;
13
+ this.currentlyRunning = false;
14
+ }
15
+ _createClass(TaskQueue, [{
16
+ key: "add",
17
+ value: function add(callback) {
18
+ var id = ++this.id;
19
+ var queue = this.queue;
20
+ queue.push({
21
+ callback: callback,
22
+ id: id,
23
+ cancelled: false
24
+ });
25
+ return id;
26
+ }
27
+ }, {
28
+ key: "remove",
29
+ value: function remove(id) {
30
+ var running = this.currentlyRunning;
31
+ var queue = running ? this.queue.concat(running) : this.queue;
32
+ var _iterator = _createForOfIteratorHelper(queue),
33
+ _step;
34
+ try {
35
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
36
+ var task = _step.value;
37
+ if (task.id === id) {
38
+ task.cancelled = true;
39
+ return;
40
+ }
41
+ }
42
+ } catch (err) {
43
+ _iterator.e(err);
44
+ } finally {
45
+ _iterator.f();
46
+ }
47
+ }
48
+ }, {
49
+ key: "run",
50
+ value: function run() {
51
+ var timeStamp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
52
+ var queue = this.currentlyRunning = this.queue;
53
+
54
+ // Tasks queued by callbacks in the current queue should be executed
55
+ // on the next run, not the current run.
56
+ this.queue = [];
57
+ var _iterator2 = _createForOfIteratorHelper(queue),
58
+ _step2;
59
+ try {
60
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
61
+ var task = _step2.value;
62
+ if (task.cancelled) {
63
+ continue;
64
+ }
65
+ task.callback(timeStamp);
66
+ if (this.cleared) {
67
+ break;
68
+ }
69
+ }
70
+ } catch (err) {
71
+ _iterator2.e(err);
72
+ } finally {
73
+ _iterator2.f();
74
+ }
75
+ this.cleared = false;
76
+ this.currentlyRunning = false;
77
+ }
78
+ }, {
79
+ key: "clear",
80
+ value: function clear() {
81
+ if (this.currentlyRunning) {
82
+ this.cleared = true;
83
+ }
84
+ this.queue = [];
85
+ }
86
+ }]);
87
+ return TaskQueue;
88
+ }();
89
+ export default TaskQueue;