@antv/l7-map 2.9.21 → 2.9.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/camera.js +115 -85
- package/es/css/l7.css +98 -0
- package/es/earthmap.js +27 -43
- package/es/geo/edge_insets.js +44 -14
- package/es/geo/lng_lat.js +15 -11
- package/es/geo/lng_lat_bounds.js +6 -10
- package/es/geo/mercator.js +24 -12
- package/es/geo/point.js +2 -8
- package/es/geo/simple.js +24 -12
- package/es/geo/transform.js +421 -120
- package/es/handler/IHandler.js +1 -2
- package/es/handler/blockable_map_event.js +13 -14
- package/es/handler/box_zoom.js +43 -27
- package/es/handler/click_zoom.js +3 -8
- package/es/handler/events/event.js +3 -6
- package/es/handler/events/index.js +4 -5
- package/es/handler/events/map_mouse_event.js +30 -20
- package/es/handler/events/map_touch_event.js +55 -25
- package/es/handler/events/map_wheel_event.js +24 -15
- package/es/handler/events/render_event.js +3 -6
- package/es/handler/handler_inertia.js +10 -12
- package/es/handler/handler_manager.js +75 -72
- package/es/handler/handler_util.js +2 -2
- package/es/handler/keyboard.js +20 -15
- package/es/handler/map_event.js +23 -12
- package/es/handler/mouse/index.js +4 -5
- package/es/handler/mouse/mouse_handler.js +17 -21
- package/es/handler/mouse/mousepan_handler.js +5 -5
- package/es/handler/mouse/mousepitch_hander.js +7 -5
- package/es/handler/mouse/mouserotate_hander.js +7 -5
- package/es/handler/mouse/util.js +3 -3
- package/es/handler/scroll_zoom.js +103 -67
- package/es/handler/shim/dblclick_zoom.js +35 -8
- package/es/handler/shim/drag_pan.js +48 -12
- package/es/handler/shim/drag_rotate.js +39 -10
- package/es/handler/shim/touch_zoom_rotate.js +59 -16
- package/es/handler/tap/single_tap_recognizer.js +7 -17
- package/es/handler/tap/tap_drag_zoom.js +5 -18
- package/es/handler/tap/tap_recognizer.js +4 -15
- package/es/handler/tap/tap_zoom.js +4 -13
- package/es/handler/touch/index.js +5 -6
- package/es/handler/touch/touch_pan.js +9 -20
- package/es/handler/touch/touch_pitch.js +11 -23
- package/es/handler/touch/touch_rotate.js +15 -18
- package/es/handler/touch/touch_zoom.js +5 -19
- package/es/handler/touch/two_touch.js +14 -21
- package/es/hash.js +28 -16
- package/es/index.js +2 -3
- package/es/interface.js +1 -2
- package/es/map.js +26 -47
- package/es/util.js +15 -6
- package/es/utils/Aabb.js +11 -12
- package/es/utils/dom.js +30 -11
- package/es/utils/performance.js +10 -6
- package/es/utils/primitives.js +11 -10
- package/es/utils/task_queue.js +6 -13
- package/lib/camera.js +508 -721
- package/lib/css/l7.css +98 -0
- package/lib/earthmap.js +222 -392
- package/lib/geo/edge_insets.js +64 -83
- package/lib/geo/lng_lat.js +65 -81
- package/lib/geo/lng_lat_bounds.js +124 -165
- package/lib/geo/mercator.js +62 -78
- package/lib/geo/point.js +171 -239
- package/lib/geo/simple.js +61 -80
- package/lib/geo/transform.js +470 -653
- package/lib/handler/IHandler.js +17 -2
- package/lib/handler/blockable_map_event.js +63 -83
- package/lib/handler/box_zoom.js +123 -176
- package/lib/handler/click_zoom.js +56 -68
- package/lib/handler/events/event.js +35 -23
- package/lib/handler/events/index.js +35 -29
- package/lib/handler/events/map_mouse_event.js +42 -72
- package/lib/handler/events/map_touch_event.js +45 -80
- package/lib/handler/events/map_wheel_event.js +34 -58
- package/lib/handler/events/render_event.js +31 -52
- package/lib/handler/handler_inertia.js +113 -160
- package/lib/handler/handler_manager.js +379 -620
- package/lib/handler/handler_util.js +28 -10
- package/lib/handler/keyboard.js +114 -146
- package/lib/handler/map_event.js +84 -120
- package/lib/handler/mouse/index.js +35 -29
- package/lib/handler/mouse/mouse_handler.js +90 -123
- package/lib/handler/mouse/mousepan_handler.js +46 -65
- package/lib/handler/mouse/mousepitch_hander.js +44 -63
- package/lib/handler/mouse/mouserotate_hander.js +44 -63
- package/lib/handler/mouse/util.js +38 -20
- package/lib/handler/scroll_zoom.js +175 -258
- package/lib/handler/shim/dblclick_zoom.js +42 -48
- package/lib/handler/shim/drag_pan.js +48 -59
- package/lib/handler/shim/drag_rotate.js +43 -51
- package/lib/handler/shim/touch_zoom_rotate.js +58 -78
- package/lib/handler/tap/single_tap_recognizer.js +84 -117
- package/lib/handler/tap/tap_drag_zoom.js +92 -115
- package/lib/handler/tap/tap_recognizer.js +60 -78
- package/lib/handler/tap/tap_zoom.js +88 -119
- package/lib/handler/touch/index.js +38 -37
- package/lib/handler/touch/touch_pan.js +98 -132
- package/lib/handler/touch/touch_pitch.js +73 -117
- package/lib/handler/touch/touch_rotate.js +58 -94
- package/lib/handler/touch/touch_zoom.js +49 -84
- package/lib/handler/touch/two_touch.js +88 -128
- package/lib/hash.js +100 -133
- package/lib/index.js +19 -31
- package/lib/interface.js +17 -2
- package/lib/map.js +238 -420
- package/lib/util.js +67 -78
- package/lib/utils/Aabb.js +80 -132
- package/lib/utils/dom.js +84 -141
- package/lib/utils/performance.js +54 -42
- package/lib/utils/primitives.js +59 -51
- package/lib/utils/task_queue.js +61 -108
- package/package.json +11 -8
- package/es/camera.js.map +0 -1
- package/es/earthmap.js.map +0 -1
- package/es/geo/edge_insets.js.map +0 -1
- package/es/geo/lng_lat.js.map +0 -1
- package/es/geo/lng_lat_bounds.js.map +0 -1
- package/es/geo/mercator.js.map +0 -1
- package/es/geo/point.js.map +0 -1
- package/es/geo/simple.js.map +0 -1
- package/es/geo/transform.js.map +0 -1
- package/es/handler/IHandler.js.map +0 -1
- package/es/handler/blockable_map_event.js.map +0 -1
- package/es/handler/box_zoom.js.map +0 -1
- package/es/handler/click_zoom.js.map +0 -1
- package/es/handler/events/event.js.map +0 -1
- package/es/handler/events/index.js.map +0 -1
- package/es/handler/events/map_mouse_event.js.map +0 -1
- package/es/handler/events/map_touch_event.js.map +0 -1
- package/es/handler/events/map_wheel_event.js.map +0 -1
- package/es/handler/events/render_event.js.map +0 -1
- package/es/handler/handler_inertia.js.map +0 -1
- package/es/handler/handler_manager.js.map +0 -1
- package/es/handler/handler_util.js.map +0 -1
- package/es/handler/keyboard.js.map +0 -1
- package/es/handler/map_event.js.map +0 -1
- package/es/handler/mouse/index.js.map +0 -1
- package/es/handler/mouse/mouse_handler.js.map +0 -1
- package/es/handler/mouse/mousepan_handler.js.map +0 -1
- package/es/handler/mouse/mousepitch_hander.js.map +0 -1
- package/es/handler/mouse/mouserotate_hander.js.map +0 -1
- package/es/handler/mouse/util.js.map +0 -1
- package/es/handler/scroll_zoom.js.map +0 -1
- package/es/handler/shim/dblclick_zoom.js.map +0 -1
- package/es/handler/shim/drag_pan.js.map +0 -1
- package/es/handler/shim/drag_rotate.js.map +0 -1
- package/es/handler/shim/touch_zoom_rotate.js.map +0 -1
- package/es/handler/tap/single_tap_recognizer.js.map +0 -1
- package/es/handler/tap/tap_drag_zoom.js.map +0 -1
- package/es/handler/tap/tap_recognizer.js.map +0 -1
- package/es/handler/tap/tap_zoom.js.map +0 -1
- package/es/handler/touch/index.js.map +0 -1
- package/es/handler/touch/touch_pan.js.map +0 -1
- package/es/handler/touch/touch_pitch.js.map +0 -1
- package/es/handler/touch/touch_rotate.js.map +0 -1
- package/es/handler/touch/touch_zoom.js.map +0 -1
- package/es/handler/touch/two_touch.js.map +0 -1
- package/es/hash.js.map +0 -1
- package/es/index.js.map +0 -1
- package/es/interface.js.map +0 -1
- package/es/map.js.map +0 -1
- package/es/util.js.map +0 -1
- package/es/utils/Aabb.js.map +0 -1
- package/es/utils/dom.js.map +0 -1
- package/es/utils/performance.js.map +0 -1
- package/es/utils/primitives.js.map +0 -1
- package/es/utils/task_queue.js.map +0 -1
- package/lib/camera.js.map +0 -1
- package/lib/earthmap.js.map +0 -1
- package/lib/geo/edge_insets.js.map +0 -1
- package/lib/geo/lng_lat.js.map +0 -1
- package/lib/geo/lng_lat_bounds.js.map +0 -1
- package/lib/geo/mercator.js.map +0 -1
- package/lib/geo/point.js.map +0 -1
- package/lib/geo/simple.js.map +0 -1
- package/lib/geo/transform.js.map +0 -1
- package/lib/handler/IHandler.js.map +0 -1
- package/lib/handler/blockable_map_event.js.map +0 -1
- package/lib/handler/box_zoom.js.map +0 -1
- package/lib/handler/click_zoom.js.map +0 -1
- package/lib/handler/events/event.js.map +0 -1
- package/lib/handler/events/index.js.map +0 -1
- package/lib/handler/events/map_mouse_event.js.map +0 -1
- package/lib/handler/events/map_touch_event.js.map +0 -1
- package/lib/handler/events/map_wheel_event.js.map +0 -1
- package/lib/handler/events/render_event.js.map +0 -1
- package/lib/handler/handler_inertia.js.map +0 -1
- package/lib/handler/handler_manager.js.map +0 -1
- package/lib/handler/handler_util.js.map +0 -1
- package/lib/handler/keyboard.js.map +0 -1
- package/lib/handler/map_event.js.map +0 -1
- package/lib/handler/mouse/index.js.map +0 -1
- package/lib/handler/mouse/mouse_handler.js.map +0 -1
- package/lib/handler/mouse/mousepan_handler.js.map +0 -1
- package/lib/handler/mouse/mousepitch_hander.js.map +0 -1
- package/lib/handler/mouse/mouserotate_hander.js.map +0 -1
- package/lib/handler/mouse/util.js.map +0 -1
- package/lib/handler/scroll_zoom.js.map +0 -1
- package/lib/handler/shim/dblclick_zoom.js.map +0 -1
- package/lib/handler/shim/drag_pan.js.map +0 -1
- package/lib/handler/shim/drag_rotate.js.map +0 -1
- package/lib/handler/shim/touch_zoom_rotate.js.map +0 -1
- package/lib/handler/tap/single_tap_recognizer.js.map +0 -1
- package/lib/handler/tap/tap_drag_zoom.js.map +0 -1
- package/lib/handler/tap/tap_recognizer.js.map +0 -1
- package/lib/handler/tap/tap_zoom.js.map +0 -1
- package/lib/handler/touch/index.js.map +0 -1
- package/lib/handler/touch/touch_pan.js.map +0 -1
- package/lib/handler/touch/touch_pitch.js.map +0 -1
- package/lib/handler/touch/touch_rotate.js.map +0 -1
- package/lib/handler/touch/touch_zoom.js.map +0 -1
- package/lib/handler/touch/two_touch.js.map +0 -1
- package/lib/hash.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interface.js.map +0 -1
- package/lib/map.js.map +0 -1
- package/lib/util.js.map +0 -1
- package/lib/utils/Aabb.js.map +0 -1
- package/lib/utils/dom.js.map +0 -1
- package/lib/utils/performance.js.map +0 -1
- package/lib/utils/primitives.js.map +0 -1
- package/lib/utils/task_queue.js.map +0 -1
package/lib/util.js
CHANGED
|
@@ -1,108 +1,97 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/util.ts
|
|
23
|
+
var util_exports = {};
|
|
24
|
+
__export(util_exports, {
|
|
25
|
+
bezier: () => bezier,
|
|
26
|
+
cancel: () => cancel,
|
|
27
|
+
clamp: () => clamp,
|
|
28
|
+
ease: () => ease,
|
|
29
|
+
interpolate: () => interpolate,
|
|
30
|
+
now: () => now,
|
|
31
|
+
pick: () => pick,
|
|
32
|
+
prefersReducedMotion: () => prefersReducedMotion,
|
|
33
|
+
raf: () => raf,
|
|
34
|
+
renderframe: () => renderframe,
|
|
35
|
+
wrap: () => wrap
|
|
7
36
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.ease = void 0;
|
|
12
|
-
exports.interpolate = interpolate;
|
|
13
|
-
exports.now = void 0;
|
|
14
|
-
exports.pick = pick;
|
|
15
|
-
exports.prefersReducedMotion = prefersReducedMotion;
|
|
16
|
-
exports.raf = void 0;
|
|
17
|
-
exports.renderframe = renderframe;
|
|
18
|
-
exports.wrap = wrap;
|
|
19
|
-
|
|
20
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
21
|
-
|
|
22
|
-
var _unitbezier = _interopRequireDefault(require("@mapbox/unitbezier"));
|
|
23
|
-
|
|
24
|
-
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; } } }; }
|
|
25
|
-
|
|
26
|
-
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); }
|
|
27
|
-
|
|
28
|
-
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; }
|
|
29
|
-
|
|
37
|
+
module.exports = __toCommonJS(util_exports);
|
|
38
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
39
|
+
var import_unitbezier = __toESM(require("@mapbox/unitbezier"));
|
|
30
40
|
var reducedMotionQuery;
|
|
31
|
-
|
|
32
41
|
function wrap(n, min, max) {
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
const d = max - min;
|
|
43
|
+
const w = ((n - min) % d + d) % d + min;
|
|
35
44
|
return w === min ? max : w;
|
|
36
45
|
}
|
|
37
|
-
|
|
38
46
|
function clamp(n, min, max) {
|
|
39
47
|
return Math.min(max, Math.max(min, n));
|
|
40
48
|
}
|
|
41
|
-
|
|
42
49
|
function interpolate(a, b, t) {
|
|
43
50
|
return a * (1 - t) + b * t;
|
|
44
51
|
}
|
|
45
|
-
|
|
46
52
|
function bezier(p1x, p1y, p2x, p2y) {
|
|
47
|
-
|
|
48
|
-
return
|
|
53
|
+
const bez = new import_unitbezier.default(p1x, p1y, p2x, p2y);
|
|
54
|
+
return (t) => {
|
|
49
55
|
return bez.solve(t);
|
|
50
56
|
};
|
|
51
57
|
}
|
|
52
|
-
|
|
53
58
|
var ease = bezier(0.25, 0.1, 0.25, 1);
|
|
54
|
-
exports.ease = ease;
|
|
55
|
-
|
|
56
59
|
function prefersReducedMotion() {
|
|
57
|
-
if (
|
|
60
|
+
if (import_l7_utils.isMini || !import_l7_utils.$window.matchMedia) {
|
|
58
61
|
return false;
|
|
59
62
|
}
|
|
60
|
-
|
|
61
63
|
if (reducedMotionQuery == null) {
|
|
62
|
-
reducedMotionQuery =
|
|
64
|
+
reducedMotionQuery = import_l7_utils.$window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
63
65
|
}
|
|
64
|
-
|
|
65
66
|
return reducedMotionQuery.matches;
|
|
66
67
|
}
|
|
67
|
-
|
|
68
68
|
function pick(src, properties) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
76
|
-
var name = _step.value;
|
|
77
|
-
|
|
78
|
-
if (name in src) {
|
|
79
|
-
result[name] = src[name];
|
|
80
|
-
}
|
|
69
|
+
const result = {};
|
|
70
|
+
for (const name of properties) {
|
|
71
|
+
if (name in src) {
|
|
72
|
+
result[name] = src[name];
|
|
81
73
|
}
|
|
82
|
-
} catch (err) {
|
|
83
|
-
_iterator.e(err);
|
|
84
|
-
} finally {
|
|
85
|
-
_iterator.f();
|
|
86
74
|
}
|
|
87
|
-
|
|
88
75
|
return result;
|
|
89
76
|
}
|
|
90
|
-
|
|
91
|
-
var
|
|
92
|
-
|
|
93
|
-
var raf = _l7Utils.$window.requestAnimationFrame || _l7Utils.$window.mozRequestAnimationFrame || _l7Utils.$window.webkitRequestAnimationFrame || _l7Utils.$window.msRequestAnimationFrame;
|
|
94
|
-
exports.raf = raf;
|
|
95
|
-
|
|
96
|
-
var _cancel = _l7Utils.$window.cancelAnimationFrame || _l7Utils.$window.mozCancelAnimationFrame || _l7Utils.$window.webkitCancelAnimationFrame || _l7Utils.$window.msCancelAnimationFrame;
|
|
97
|
-
|
|
98
|
-
exports.cancel = _cancel;
|
|
99
|
-
|
|
77
|
+
var now = import_l7_utils.isMini ? Date.now.bind(Date) : import_l7_utils.$window.performance && import_l7_utils.$window.performance.now ? import_l7_utils.$window.performance.now.bind(import_l7_utils.$window.performance) : Date.now.bind(Date);
|
|
78
|
+
var raf = import_l7_utils.$window.requestAnimationFrame || import_l7_utils.$window.mozRequestAnimationFrame || import_l7_utils.$window.webkitRequestAnimationFrame || import_l7_utils.$window.msRequestAnimationFrame;
|
|
79
|
+
var cancel = import_l7_utils.$window.cancelAnimationFrame || import_l7_utils.$window.mozCancelAnimationFrame || import_l7_utils.$window.webkitCancelAnimationFrame || import_l7_utils.$window.msCancelAnimationFrame;
|
|
100
80
|
function renderframe(fn) {
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
cancel: function cancel() {
|
|
104
|
-
return _cancel(frame);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
81
|
+
const frame = raf(fn);
|
|
82
|
+
return { cancel: () => cancel(frame) };
|
|
107
83
|
}
|
|
108
|
-
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
bezier,
|
|
87
|
+
cancel,
|
|
88
|
+
clamp,
|
|
89
|
+
ease,
|
|
90
|
+
interpolate,
|
|
91
|
+
now,
|
|
92
|
+
pick,
|
|
93
|
+
prefersReducedMotion,
|
|
94
|
+
raf,
|
|
95
|
+
renderframe,
|
|
96
|
+
wrap
|
|
97
|
+
});
|
package/lib/utils/Aabb.js
CHANGED
|
@@ -1,142 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/Aabb.ts
|
|
20
|
+
var Aabb_exports = {};
|
|
21
|
+
__export(Aabb_exports, {
|
|
22
|
+
default: () => Aabb
|
|
7
23
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
|
-
var _glMatrix = require("gl-matrix");
|
|
17
|
-
|
|
18
|
-
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; } } }; }
|
|
19
|
-
|
|
20
|
-
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); }
|
|
21
|
-
|
|
22
|
-
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; }
|
|
23
|
-
|
|
24
|
-
var Aabb = function () {
|
|
25
|
-
function Aabb(min, max) {
|
|
26
|
-
(0, _classCallCheck2.default)(this, Aabb);
|
|
27
|
-
(0, _defineProperty2.default)(this, "min", void 0);
|
|
28
|
-
(0, _defineProperty2.default)(this, "max", void 0);
|
|
29
|
-
(0, _defineProperty2.default)(this, "center", void 0);
|
|
24
|
+
module.exports = __toCommonJS(Aabb_exports);
|
|
25
|
+
var import_gl_matrix = require("gl-matrix");
|
|
26
|
+
var Aabb = class {
|
|
27
|
+
constructor(min, max) {
|
|
30
28
|
this.min = min;
|
|
31
29
|
this.max = max;
|
|
32
|
-
this.center =
|
|
30
|
+
this.center = import_gl_matrix.vec3.scale(new Float32Array(3), import_gl_matrix.vec3.add(new Float32Array(3), this.min, this.max), 0.5);
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var qMax = _glMatrix.vec3.clone(this.max);
|
|
43
|
-
|
|
44
|
-
for (var axis = 0; axis < split.length; axis++) {
|
|
45
|
-
qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];
|
|
46
|
-
qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
qMax[2] = this.max[2];
|
|
50
|
-
return new Aabb(qMin, qMax);
|
|
32
|
+
quadrant(index) {
|
|
33
|
+
const split = [index % 2 === 0, index < 2];
|
|
34
|
+
const qMin = import_gl_matrix.vec3.clone(this.min);
|
|
35
|
+
const qMax = import_gl_matrix.vec3.clone(this.max);
|
|
36
|
+
for (let axis = 0; axis < split.length; axis++) {
|
|
37
|
+
qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];
|
|
38
|
+
qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];
|
|
51
39
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
qMax[2] = this.max[2];
|
|
41
|
+
return new Aabb(qMin, qMax);
|
|
42
|
+
}
|
|
43
|
+
distanceX(point) {
|
|
44
|
+
const pointOnAabb = Math.max(Math.min(this.max[0], point[0]), this.min[0]);
|
|
45
|
+
return pointOnAabb - point[0];
|
|
46
|
+
}
|
|
47
|
+
distanceY(point) {
|
|
48
|
+
const pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);
|
|
49
|
+
return pointOnAabb - point[1];
|
|
50
|
+
}
|
|
51
|
+
intersects(frustum) {
|
|
52
|
+
const aabbPoints = [
|
|
53
|
+
[this.min[0], this.min[1], 0, 1],
|
|
54
|
+
[this.max[0], this.min[1], 0, 1],
|
|
55
|
+
[this.max[0], this.max[1], 0, 1],
|
|
56
|
+
[this.min[0], this.max[1], 0, 1]
|
|
57
|
+
];
|
|
58
|
+
let fullyInside = true;
|
|
59
|
+
for (const plane of frustum.planes) {
|
|
60
|
+
let pointsInside = 0;
|
|
61
|
+
for (const i of aabbPoints) {
|
|
62
|
+
pointsInside += import_gl_matrix.vec4.dot(plane, i) >= 0;
|
|
63
|
+
}
|
|
64
|
+
if (pointsInside === 0) {
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
if (pointsInside !== aabbPoints.length) {
|
|
68
|
+
fullyInside = false;
|
|
69
|
+
}
|
|
57
70
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
value: function distanceY(point) {
|
|
61
|
-
var pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);
|
|
62
|
-
return pointOnAabb - point[1];
|
|
71
|
+
if (fullyInside) {
|
|
72
|
+
return 2;
|
|
63
73
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
_step;
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
75
|
-
var plane = _step.value;
|
|
76
|
-
var pointsInside = 0;
|
|
77
|
-
|
|
78
|
-
var _iterator3 = _createForOfIteratorHelper(aabbPoints),
|
|
79
|
-
_step3;
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
83
|
-
var i = _step3.value;
|
|
84
|
-
pointsInside += _glMatrix.vec4.dot(plane, i) >= 0;
|
|
85
|
-
}
|
|
86
|
-
} catch (err) {
|
|
87
|
-
_iterator3.e(err);
|
|
88
|
-
} finally {
|
|
89
|
-
_iterator3.f();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (pointsInside === 0) {
|
|
93
|
-
return 0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (pointsInside !== aabbPoints.length) {
|
|
97
|
-
fullyInside = false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
} catch (err) {
|
|
101
|
-
_iterator.e(err);
|
|
102
|
-
} finally {
|
|
103
|
-
_iterator.f();
|
|
74
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
75
|
+
let projMin = Number.MAX_VALUE;
|
|
76
|
+
let projMax = -Number.MAX_VALUE;
|
|
77
|
+
for (const p of frustum.points) {
|
|
78
|
+
const projectedPoint = p[axis] - this.min[axis];
|
|
79
|
+
projMin = Math.min(projMin, projectedPoint);
|
|
80
|
+
projMax = Math.max(projMax, projectedPoint);
|
|
104
81
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return 2;
|
|
82
|
+
if (projMax < 0 || projMin > this.max[axis] - this.min[axis]) {
|
|
83
|
+
return 0;
|
|
108
84
|
}
|
|
109
|
-
|
|
110
|
-
for (var axis = 0; axis < 3; axis++) {
|
|
111
|
-
var projMin = Number.MAX_VALUE;
|
|
112
|
-
var projMax = -Number.MAX_VALUE;
|
|
113
|
-
|
|
114
|
-
var _iterator2 = _createForOfIteratorHelper(frustum.points),
|
|
115
|
-
_step2;
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
119
|
-
var p = _step2.value;
|
|
120
|
-
var projectedPoint = p[axis] - this.min[axis];
|
|
121
|
-
projMin = Math.min(projMin, projectedPoint);
|
|
122
|
-
projMax = Math.max(projMax, projectedPoint);
|
|
123
|
-
}
|
|
124
|
-
} catch (err) {
|
|
125
|
-
_iterator2.e(err);
|
|
126
|
-
} finally {
|
|
127
|
-
_iterator2.f();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (projMax < 0 || projMin > this.max[axis] - this.min[axis]) {
|
|
131
|
-
return 0;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return 1;
|
|
136
85
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
exports
|
|
142
|
-
//# sourceMappingURL=Aabb.js.map
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {});
|