@antv/l7-map 2.21.11-beta.5 → 2.21.11-beta.6
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/README.md +27 -6
- package/es/index.d.ts +3 -4
- package/es/index.js +2 -4
- package/es/map/camera.d.ts +690 -0
- package/es/map/camera.js +1138 -0
- package/{lib → es/map}/css/l7.css +41 -7
- package/es/map/events.d.ts +384 -0
- package/es/map/events.js +222 -0
- package/es/map/geo/edge_insets.d.ts +97 -0
- package/es/{geo → map/geo}/edge_insets.js +55 -33
- package/es/map/geo/lng_lat.d.ts +116 -0
- package/es/map/geo/lng_lat.js +159 -0
- package/es/map/geo/lng_lat_bounds.d.ts +217 -0
- package/es/map/geo/lng_lat_bounds.js +334 -0
- package/es/map/geo/mercator_coordinate.d.ts +113 -0
- package/es/map/geo/mercator_coordinate.js +142 -0
- package/es/map/geo/transform.d.ts +262 -0
- package/es/map/geo/transform.js +736 -0
- package/{lib → es/map}/handler/box_zoom.d.ts +30 -24
- package/es/map/handler/box_zoom.js +145 -0
- package/es/map/handler/click_zoom.d.ts +24 -0
- package/es/map/handler/click_zoom.js +47 -0
- package/es/map/handler/cooperative_gestures.d.ts +40 -0
- package/es/map/handler/cooperative_gestures.js +94 -0
- package/es/map/handler/drag_handler.d.ts +88 -0
- package/es/map/handler/drag_handler.js +89 -0
- package/es/map/handler/drag_move_state_manager.d.ts +30 -0
- package/es/map/handler/drag_move_state_manager.js +94 -0
- package/es/map/handler/handler_util.d.ts +3 -0
- package/es/{handler → map/handler}/handler_util.js +1 -2
- package/es/map/handler/keyboard.d.ts +88 -0
- package/es/map/handler/keyboard.js +197 -0
- package/es/map/handler/map_event.d.ts +46 -0
- package/es/map/handler/map_event.js +131 -0
- package/es/map/handler/mouse.d.ts +30 -0
- package/es/map/handler/mouse.js +85 -0
- package/es/map/handler/one_finger_touch_drag.d.ts +15 -0
- package/es/map/handler/one_finger_touch_drag.js +39 -0
- package/es/map/handler/scroll_zoom.d.ts +102 -0
- package/es/map/handler/scroll_zoom.js +312 -0
- package/es/{handler → map/handler}/shim/dblclick_zoom.d.ts +14 -10
- package/es/{handler → map/handler}/shim/dblclick_zoom.js +20 -16
- package/es/map/handler/shim/drag_pan.d.ts +79 -0
- package/es/map/handler/shim/drag_pan.js +77 -0
- package/es/{handler → map/handler}/shim/drag_rotate.d.ts +24 -16
- package/es/map/handler/shim/drag_rotate.js +66 -0
- package/es/map/handler/shim/two_fingers_touch.d.ts +74 -0
- package/es/map/handler/shim/two_fingers_touch.js +106 -0
- package/es/map/handler/tap_drag_zoom.d.ts +28 -0
- package/es/map/handler/tap_drag_zoom.js +92 -0
- package/es/map/handler/tap_recognizer.d.ts +35 -0
- package/es/map/handler/tap_recognizer.js +107 -0
- package/es/map/handler/tap_zoom.d.ts +28 -0
- package/es/map/handler/tap_zoom.js +87 -0
- package/es/map/handler/touch_pan.d.ts +40 -0
- package/es/map/handler/touch_pan.js +85 -0
- package/es/map/handler/transform-provider.d.ts +23 -0
- package/es/map/handler/transform-provider.js +35 -0
- package/es/map/handler/two_fingers_touch.d.ts +107 -0
- package/es/map/handler/two_fingers_touch.js +289 -0
- package/es/map/handler_inertia.d.ts +20 -0
- package/es/{handler → map}/handler_inertia.js +36 -50
- package/es/map/handler_manager.d.ts +154 -0
- package/es/map/handler_manager.js +466 -0
- package/es/map/map.d.ts +625 -0
- package/es/map/map.js +972 -0
- package/es/map/util/abort_error.d.ts +15 -0
- package/es/map/util/abort_error.js +21 -0
- package/es/map/util/browser.d.ts +10 -0
- package/es/map/util/browser.js +30 -0
- package/es/map/util/dom.d.ts +30 -0
- package/es/map/util/dom.js +105 -0
- package/es/map/util/evented.d.ts +75 -0
- package/es/map/util/evented.js +158 -0
- package/es/map/util/task_queue.d.ts +18 -0
- package/es/map/util/task_queue.js +54 -0
- package/es/map/util/util.d.ts +104 -0
- package/es/map/util/util.js +155 -0
- package/lib/index.d.ts +3 -4
- package/lib/index.js +12 -42
- package/lib/map/camera.d.ts +690 -0
- package/lib/map/camera.js +1145 -0
- package/{es → lib/map}/css/l7.css +41 -7
- package/lib/map/events.d.ts +384 -0
- package/lib/map/events.js +231 -0
- package/lib/map/geo/edge_insets.d.ts +97 -0
- package/lib/{geo → map/geo}/edge_insets.js +56 -35
- package/lib/map/geo/lng_lat.d.ts +116 -0
- package/lib/map/geo/lng_lat.js +166 -0
- package/lib/map/geo/lng_lat_bounds.d.ts +217 -0
- package/lib/map/geo/lng_lat_bounds.js +341 -0
- package/lib/map/geo/mercator_coordinate.d.ts +113 -0
- package/lib/map/geo/mercator_coordinate.js +157 -0
- package/lib/map/geo/transform.d.ts +262 -0
- package/lib/map/geo/transform.js +744 -0
- package/{es → lib/map}/handler/box_zoom.d.ts +30 -24
- package/lib/map/handler/box_zoom.js +153 -0
- package/lib/map/handler/click_zoom.d.ts +24 -0
- package/lib/map/handler/click_zoom.js +54 -0
- package/lib/map/handler/cooperative_gestures.d.ts +40 -0
- package/lib/map/handler/cooperative_gestures.js +101 -0
- package/lib/map/handler/drag_handler.d.ts +88 -0
- package/lib/map/handler/drag_handler.js +97 -0
- package/lib/map/handler/drag_move_state_manager.d.ts +30 -0
- package/lib/map/handler/drag_move_state_manager.js +103 -0
- package/lib/map/handler/handler_util.d.ts +3 -0
- package/lib/{handler → map/handler}/handler_util.js +1 -2
- package/lib/map/handler/keyboard.d.ts +88 -0
- package/lib/map/handler/keyboard.js +205 -0
- package/lib/map/handler/map_event.d.ts +46 -0
- package/lib/map/handler/map_event.js +140 -0
- package/lib/map/handler/mouse.d.ts +30 -0
- package/lib/map/handler/mouse.js +93 -0
- package/lib/map/handler/one_finger_touch_drag.d.ts +15 -0
- package/lib/map/handler/one_finger_touch_drag.js +47 -0
- package/lib/map/handler/scroll_zoom.d.ts +102 -0
- package/lib/map/handler/scroll_zoom.js +320 -0
- package/lib/{handler → map/handler}/shim/dblclick_zoom.d.ts +14 -10
- package/lib/{handler → map/handler}/shim/dblclick_zoom.js +21 -17
- package/lib/map/handler/shim/drag_pan.d.ts +79 -0
- package/lib/map/handler/shim/drag_pan.js +85 -0
- package/lib/{handler → map/handler}/shim/drag_rotate.d.ts +24 -16
- package/lib/map/handler/shim/drag_rotate.js +74 -0
- package/lib/map/handler/shim/two_fingers_touch.d.ts +74 -0
- package/lib/map/handler/shim/two_fingers_touch.js +114 -0
- package/lib/map/handler/tap_drag_zoom.d.ts +28 -0
- package/lib/map/handler/tap_drag_zoom.js +99 -0
- package/lib/map/handler/tap_recognizer.d.ts +35 -0
- package/lib/map/handler/tap_recognizer.js +116 -0
- package/lib/map/handler/tap_zoom.d.ts +28 -0
- package/lib/map/handler/tap_zoom.js +94 -0
- package/lib/map/handler/touch_pan.d.ts +40 -0
- package/lib/map/handler/touch_pan.js +92 -0
- package/lib/map/handler/transform-provider.d.ts +23 -0
- package/lib/map/handler/transform-provider.js +43 -0
- package/lib/map/handler/two_fingers_touch.d.ts +107 -0
- package/lib/map/handler/two_fingers_touch.js +296 -0
- package/lib/map/handler_inertia.d.ts +20 -0
- package/lib/{handler → map}/handler_inertia.js +38 -53
- package/lib/map/handler_manager.d.ts +154 -0
- package/lib/map/handler_manager.js +474 -0
- package/lib/map/map.d.ts +625 -0
- package/lib/map/map.js +979 -0
- package/lib/map/util/abort_error.d.ts +15 -0
- package/lib/map/util/abort_error.js +29 -0
- package/lib/map/util/browser.d.ts +10 -0
- package/lib/map/util/browser.js +36 -0
- package/lib/map/util/dom.d.ts +30 -0
- package/lib/map/util/dom.js +113 -0
- package/lib/map/util/evented.d.ts +75 -0
- package/lib/map/util/evented.js +167 -0
- package/lib/map/util/task_queue.d.ts +18 -0
- package/lib/map/util/task_queue.js +62 -0
- package/lib/map/util/util.d.ts +104 -0
- package/lib/map/util/util.js +171 -0
- package/package.json +6 -3
- package/es/camera.d.ts +0 -86
- package/es/camera.js +0 -639
- package/es/earthmap.d.ts +0 -69
- package/es/earthmap.js +0 -445
- package/es/geo/edge_insets.d.ts +0 -54
- package/es/geo/lng_lat.d.ts +0 -18
- package/es/geo/lng_lat.js +0 -59
- package/es/geo/lng_lat_bounds.d.ts +0 -25
- package/es/geo/lng_lat_bounds.js +0 -118
- package/es/geo/mercator.d.ts +0 -30
- package/es/geo/mercator.js +0 -72
- package/es/geo/point.d.ts +0 -40
- package/es/geo/point.js +0 -153
- package/es/geo/simple.d.ts +0 -30
- package/es/geo/simple.js +0 -75
- package/es/geo/transform.d.ts +0 -198
- package/es/geo/transform.js +0 -895
- package/es/handler/IHandler.d.ts +0 -34
- package/es/handler/IHandler.js +0 -1
- package/es/handler/blockable_map_event.d.ts +0 -17
- package/es/handler/blockable_map_event.js +0 -58
- package/es/handler/box_zoom.js +0 -162
- package/es/handler/click_zoom.d.ts +0 -16
- package/es/handler/click_zoom.js +0 -40
- package/es/handler/events/event.d.ts +0 -4
- package/es/handler/events/event.js +0 -12
- package/es/handler/events/index.d.ts +0 -4
- package/es/handler/events/index.js +0 -4
- package/es/handler/events/map_mouse_event.d.ts +0 -34
- package/es/handler/events/map_mouse_event.js +0 -45
- package/es/handler/events/map_touch_event.d.ts +0 -57
- package/es/handler/events/map_touch_event.js +0 -75
- package/es/handler/events/map_wheel_event.d.ts +0 -33
- package/es/handler/events/map_wheel_event.js +0 -33
- package/es/handler/events/render_event.d.ts +0 -6
- package/es/handler/events/render_event.js +0 -10
- package/es/handler/handler_inertia.d.ts +0 -23
- package/es/handler/handler_manager.d.ts +0 -61
- package/es/handler/handler_manager.js +0 -487
- package/es/handler/handler_util.d.ts +0 -4
- package/es/handler/keyboard.d.ts +0 -36
- package/es/handler/keyboard.js +0 -131
- package/es/handler/map_event.d.ts +0 -29
- package/es/handler/map_event.js +0 -89
- package/es/handler/mouse/index.d.ts +0 -4
- package/es/handler/mouse/index.js +0 -4
- package/es/handler/mouse/mouse_handler.d.ts +0 -22
- package/es/handler/mouse/mouse_handler.js +0 -99
- package/es/handler/mouse/mousepan_handler.d.ts +0 -10
- package/es/handler/mouse/mousepan_handler.js +0 -21
- package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
- package/es/handler/mouse/mousepitch_hander.js +0 -24
- package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
- package/es/handler/mouse/mouserotate_hander.js +0 -24
- package/es/handler/mouse/util.d.ts +0 -6
- package/es/handler/mouse/util.js +0 -12
- package/es/handler/scroll_zoom.d.ts +0 -93
- package/es/handler/scroll_zoom.js +0 -315
- package/es/handler/shim/drag_pan.d.ts +0 -61
- package/es/handler/shim/drag_pan.js +0 -75
- package/es/handler/shim/drag_rotate.js +0 -64
- package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
- package/es/handler/shim/touch_zoom_rotate.js +0 -104
- package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
- package/es/handler/tap/single_tap_recognizer.js +0 -77
- package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
- package/es/handler/tap/tap_drag_zoom.js +0 -89
- package/es/handler/tap/tap_recognizer.d.ts +0 -17
- package/es/handler/tap/tap_recognizer.js +0 -46
- package/es/handler/tap/tap_zoom.d.ts +0 -22
- package/es/handler/tap/tap_zoom.js +0 -81
- package/es/handler/touch/index.d.ts +0 -5
- package/es/handler/touch/index.js +0 -5
- package/es/handler/touch/touch_pan.d.ts +0 -30
- package/es/handler/touch/touch_pan.js +0 -91
- package/es/handler/touch/touch_pitch.d.ts +0 -13
- package/es/handler/touch/touch_pitch.js +0 -75
- package/es/handler/touch/touch_rotate.d.ts +0 -12
- package/es/handler/touch/touch_rotate.js +0 -57
- package/es/handler/touch/touch_zoom.d.ts +0 -12
- package/es/handler/touch/touch_zoom.js +0 -37
- package/es/handler/touch/two_touch.d.ts +0 -23
- package/es/handler/touch/two_touch.js +0 -98
- package/es/hash.d.ts +0 -14
- package/es/hash.js +0 -121
- package/es/interface.d.ts +0 -34
- package/es/interface.js +0 -1
- package/es/map.d.ts +0 -70
- package/es/map.js +0 -472
- package/es/util.d.ts +0 -25
- package/es/util.js +0 -70
- package/es/utils/Aabb.d.ts +0 -12
- package/es/utils/Aabb.js +0 -72
- package/es/utils/dom.d.ts +0 -4
- package/es/utils/dom.js +0 -117
- package/es/utils/performance.d.ts +0 -17
- package/es/utils/performance.js +0 -58
- package/es/utils/primitives.d.ts +0 -6
- package/es/utils/primitives.js +0 -37
- package/es/utils/task_queue.d.ts +0 -13
- package/es/utils/task_queue.js +0 -60
- package/lib/camera.d.ts +0 -86
- package/lib/camera.js +0 -648
- package/lib/earthmap.d.ts +0 -69
- package/lib/earthmap.js +0 -451
- package/lib/geo/edge_insets.d.ts +0 -54
- package/lib/geo/lng_lat.d.ts +0 -18
- package/lib/geo/lng_lat.js +0 -67
- package/lib/geo/lng_lat_bounds.d.ts +0 -25
- package/lib/geo/lng_lat_bounds.js +0 -126
- package/lib/geo/mercator.d.ts +0 -30
- package/lib/geo/mercator.js +0 -88
- package/lib/geo/point.d.ts +0 -40
- package/lib/geo/point.js +0 -161
- package/lib/geo/simple.d.ts +0 -30
- package/lib/geo/simple.js +0 -92
- package/lib/geo/transform.d.ts +0 -198
- package/lib/geo/transform.js +0 -906
- package/lib/handler/IHandler.d.ts +0 -34
- package/lib/handler/IHandler.js +0 -5
- package/lib/handler/blockable_map_event.d.ts +0 -17
- package/lib/handler/blockable_map_event.js +0 -66
- package/lib/handler/box_zoom.js +0 -168
- package/lib/handler/click_zoom.d.ts +0 -16
- package/lib/handler/click_zoom.js +0 -48
- package/lib/handler/events/event.d.ts +0 -4
- package/lib/handler/events/event.js +0 -20
- package/lib/handler/events/index.d.ts +0 -4
- package/lib/handler/events/index.js +0 -27
- package/lib/handler/events/map_mouse_event.d.ts +0 -34
- package/lib/handler/events/map_mouse_event.js +0 -53
- package/lib/handler/events/map_touch_event.d.ts +0 -57
- package/lib/handler/events/map_touch_event.js +0 -83
- package/lib/handler/events/map_wheel_event.d.ts +0 -33
- package/lib/handler/events/map_wheel_event.js +0 -41
- package/lib/handler/events/render_event.d.ts +0 -6
- package/lib/handler/events/render_event.js +0 -18
- package/lib/handler/handler_inertia.d.ts +0 -23
- package/lib/handler/handler_manager.d.ts +0 -61
- package/lib/handler/handler_manager.js +0 -495
- package/lib/handler/handler_util.d.ts +0 -4
- package/lib/handler/keyboard.d.ts +0 -36
- package/lib/handler/keyboard.js +0 -138
- package/lib/handler/map_event.d.ts +0 -29
- package/lib/handler/map_event.js +0 -97
- package/lib/handler/mouse/index.d.ts +0 -4
- package/lib/handler/mouse/index.js +0 -27
- package/lib/handler/mouse/mouse_handler.d.ts +0 -22
- package/lib/handler/mouse/mouse_handler.js +0 -107
- package/lib/handler/mouse/mousepan_handler.d.ts +0 -10
- package/lib/handler/mouse/mousepan_handler.js +0 -29
- package/lib/handler/mouse/mousepitch_hander.d.ts +0 -9
- package/lib/handler/mouse/mousepitch_hander.js +0 -32
- package/lib/handler/mouse/mouserotate_hander.d.ts +0 -9
- package/lib/handler/mouse/mouserotate_hander.js +0 -32
- package/lib/handler/mouse/util.d.ts +0 -6
- package/lib/handler/mouse/util.js +0 -19
- package/lib/handler/scroll_zoom.d.ts +0 -93
- package/lib/handler/scroll_zoom.js +0 -322
- package/lib/handler/shim/drag_pan.d.ts +0 -61
- package/lib/handler/shim/drag_pan.js +0 -83
- package/lib/handler/shim/drag_rotate.js +0 -72
- package/lib/handler/shim/touch_zoom_rotate.d.ts +0 -70
- package/lib/handler/shim/touch_zoom_rotate.js +0 -112
- package/lib/handler/tap/single_tap_recognizer.d.ts +0 -20
- package/lib/handler/tap/single_tap_recognizer.js +0 -86
- package/lib/handler/tap/tap_drag_zoom.d.ts +0 -22
- package/lib/handler/tap/tap_drag_zoom.js +0 -97
- package/lib/handler/tap/tap_recognizer.d.ts +0 -17
- package/lib/handler/tap/tap_recognizer.js +0 -56
- package/lib/handler/tap/tap_zoom.d.ts +0 -22
- package/lib/handler/tap/tap_zoom.js +0 -89
- package/lib/handler/touch/index.d.ts +0 -5
- package/lib/handler/touch/index.js +0 -34
- package/lib/handler/touch/touch_pan.d.ts +0 -30
- package/lib/handler/touch/touch_pan.js +0 -100
- package/lib/handler/touch/touch_pitch.d.ts +0 -13
- package/lib/handler/touch/touch_pitch.js +0 -83
- package/lib/handler/touch/touch_rotate.d.ts +0 -12
- package/lib/handler/touch/touch_rotate.js +0 -65
- package/lib/handler/touch/touch_zoom.d.ts +0 -12
- package/lib/handler/touch/touch_zoom.js +0 -45
- package/lib/handler/touch/two_touch.d.ts +0 -23
- package/lib/handler/touch/two_touch.js +0 -106
- package/lib/hash.d.ts +0 -14
- package/lib/hash.js +0 -129
- package/lib/interface.d.ts +0 -34
- package/lib/interface.js +0 -5
- package/lib/map.d.ts +0 -70
- package/lib/map.js +0 -478
- package/lib/util.d.ts +0 -25
- package/lib/util.js +0 -89
- package/lib/utils/Aabb.d.ts +0 -12
- package/lib/utils/Aabb.js +0 -80
- package/lib/utils/dom.d.ts +0 -4
- package/lib/utils/dom.js +0 -125
- package/lib/utils/performance.d.ts +0 -17
- package/lib/utils/performance.js +0 -64
- package/lib/utils/primitives.d.ts +0 -6
- package/lib/utils/primitives.js +0 -45
- package/lib/utils/task_queue.d.ts +0 -13
- package/lib/utils/task_queue.js +0 -67
package/es/map.js
DELETED
|
@@ -1,472 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { DOM, lodashUtil } from '@antv/l7-utils';
|
|
3
|
-
import Camera from "./camera";
|
|
4
|
-
function loadStyles(css, doc) {
|
|
5
|
-
var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
|
|
6
|
-
var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
|
|
7
|
-
if (isMiniAli || isWeChatMiniProgram) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
if (!doc) doc = document;
|
|
11
|
-
if (!doc) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
var head = doc.head || doc.getElementsByTagName('head')[0];
|
|
15
|
-
if (!head) {
|
|
16
|
-
head = doc.createElement('head');
|
|
17
|
-
var body = doc.body || doc.getElementsByTagName('body')[0];
|
|
18
|
-
if (body) {
|
|
19
|
-
body.parentNode.insertBefore(head, body);
|
|
20
|
-
} else {
|
|
21
|
-
doc.documentElement.appendChild(head);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
var style = doc.createElement('style');
|
|
25
|
-
style.type = 'text/css';
|
|
26
|
-
if (style.styleSheet) {
|
|
27
|
-
style.styleSheet.cssText = css;
|
|
28
|
-
} else {
|
|
29
|
-
style.appendChild(doc.createTextNode(css));
|
|
30
|
-
}
|
|
31
|
-
head.appendChild(style);
|
|
32
|
-
return style;
|
|
33
|
-
}
|
|
34
|
-
loadStyles(`.l7-map {
|
|
35
|
-
font:
|
|
36
|
-
12px/20px 'Helvetica Neue',
|
|
37
|
-
Arial,
|
|
38
|
-
Helvetica,
|
|
39
|
-
sans-serif;
|
|
40
|
-
overflow: hidden;
|
|
41
|
-
position: relative;
|
|
42
|
-
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.l7-canvas {
|
|
46
|
-
position: absolute;
|
|
47
|
-
left: 0;
|
|
48
|
-
top: 0;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.l7-map:-webkit-full-screen {
|
|
52
|
-
width: 100%;
|
|
53
|
-
height: 100%;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.l7-canary {
|
|
57
|
-
background-color: salmon;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.l7-canvas-container.l7-interactive,
|
|
61
|
-
.l7-ctrl-group button.l7-ctrl-compass {
|
|
62
|
-
cursor: grab;
|
|
63
|
-
-moz-user-select: none;
|
|
64
|
-
-webkit-user-select: none;
|
|
65
|
-
-ms-user-select: none;
|
|
66
|
-
user-select: none;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.l7-canvas-container.l7-interactive.l7-track-pointer {
|
|
70
|
-
cursor: pointer;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.l7-canvas-container.l7-interactive:active,
|
|
74
|
-
.l7-ctrl-group button.l7-ctrl-compass:active {
|
|
75
|
-
cursor: grabbing;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.l7-canvas-container.l7-touch-zoom-rotate,
|
|
79
|
-
.l7-canvas-container.l7-touch-zoom-rotate .l7-canvas {
|
|
80
|
-
touch-action: pan-x pan-y;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.l7-canvas-container.l7-touch-drag-pan,
|
|
84
|
-
.l7-canvas-container.l7-touch-drag-pan .l7-canvas {
|
|
85
|
-
touch-action: pinch-zoom;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan,
|
|
89
|
-
.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan .l7-canvas {
|
|
90
|
-
touch-action: none;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.l7-ctrl-top-left,
|
|
94
|
-
.l7-ctrl-top-right,
|
|
95
|
-
.l7-ctrl-bottom-left,
|
|
96
|
-
.l7-ctrl-bottom-right {
|
|
97
|
-
position: absolute;
|
|
98
|
-
pointer-events: none;
|
|
99
|
-
z-index: 2;
|
|
100
|
-
}
|
|
101
|
-
.l7-ctrl-top-left {
|
|
102
|
-
top: 0;
|
|
103
|
-
left: 0;
|
|
104
|
-
}
|
|
105
|
-
.l7-ctrl-top-right {
|
|
106
|
-
top: 0;
|
|
107
|
-
right: 0;
|
|
108
|
-
}
|
|
109
|
-
.l7-ctrl-bottom-left {
|
|
110
|
-
bottom: 0;
|
|
111
|
-
left: 0;
|
|
112
|
-
}
|
|
113
|
-
.l7-ctrl-bottom-right {
|
|
114
|
-
right: 0;
|
|
115
|
-
bottom: 0;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.l7-ctrl {
|
|
119
|
-
clear: both;
|
|
120
|
-
pointer-events: auto;
|
|
121
|
-
|
|
122
|
-
/* workaround for a Safari bug https://github.com/mapbox/mapbox-gl-js/issues/8185 */
|
|
123
|
-
-webkit-transform: translate(0, 0);
|
|
124
|
-
transform: translate(0, 0);
|
|
125
|
-
}
|
|
126
|
-
.l7-ctrl-top-left .l7-ctrl {
|
|
127
|
-
margin: 10px 0 0 10px;
|
|
128
|
-
float: left;
|
|
129
|
-
}
|
|
130
|
-
.l7-ctrl-top-right .l7-ctrl {
|
|
131
|
-
margin: 10px 10px 0 0;
|
|
132
|
-
float: right;
|
|
133
|
-
}
|
|
134
|
-
.l7-ctrl-bottom-left .l7-ctrl {
|
|
135
|
-
margin: 0 0 10px 10px;
|
|
136
|
-
float: left;
|
|
137
|
-
}
|
|
138
|
-
.l7-ctrl-bottom-right .l7-ctrl {
|
|
139
|
-
margin: 0 10px 10px 0;
|
|
140
|
-
float: right;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.l7-crosshair,
|
|
144
|
-
.l7-crosshair .l7-interactive,
|
|
145
|
-
.l7-crosshair .l7-interactive:active {
|
|
146
|
-
cursor: crosshair;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.l7-boxzoom {
|
|
150
|
-
position: absolute;
|
|
151
|
-
top: 0;
|
|
152
|
-
left: 0;
|
|
153
|
-
width: 0;
|
|
154
|
-
height: 0;
|
|
155
|
-
background: #fff;
|
|
156
|
-
border: 2px dotted #202020;
|
|
157
|
-
opacity: 0.5;
|
|
158
|
-
z-index: 10;
|
|
159
|
-
}
|
|
160
|
-
`);
|
|
161
|
-
import LngLat from "./geo/lng_lat";
|
|
162
|
-
import LngLatBounds from "./geo/lng_lat_bounds";
|
|
163
|
-
// @ts-ignore
|
|
164
|
-
|
|
165
|
-
import Point from "./geo/point";
|
|
166
|
-
import HandlerManager from "./handler/handler_manager";
|
|
167
|
-
import Hash from "./hash";
|
|
168
|
-
import { renderframe } from "./util";
|
|
169
|
-
import { PerformanceUtils } from "./utils/performance";
|
|
170
|
-
import TaskQueue from "./utils/task_queue";
|
|
171
|
-
(function () {
|
|
172
|
-
if (typeof window.CustomEvent === 'function') return false; //If not IE
|
|
173
|
-
|
|
174
|
-
function CustomEvent(event, params) {
|
|
175
|
-
params = params || {
|
|
176
|
-
bubbles: false,
|
|
177
|
-
cancelable: false,
|
|
178
|
-
detail: undefined
|
|
179
|
-
};
|
|
180
|
-
const evt = document.createEvent('CustomEvent');
|
|
181
|
-
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
|
182
|
-
return evt;
|
|
183
|
-
}
|
|
184
|
-
CustomEvent.prototype = window.Event.prototype;
|
|
185
|
-
// @ts-ignore
|
|
186
|
-
window.CustomEvent = CustomEvent;
|
|
187
|
-
})();
|
|
188
|
-
const defaultMinZoom = -2;
|
|
189
|
-
const defaultMaxZoom = 22;
|
|
190
|
-
const {
|
|
191
|
-
merge
|
|
192
|
-
} = lodashUtil;
|
|
193
|
-
// the default values, but also the valid range
|
|
194
|
-
const defaultMinPitch = 0;
|
|
195
|
-
const defaultMaxPitch = 60;
|
|
196
|
-
const DefaultOptions = {
|
|
197
|
-
hash: false,
|
|
198
|
-
zoom: -1,
|
|
199
|
-
center: [112, 32],
|
|
200
|
-
pitch: 0,
|
|
201
|
-
bearing: 0,
|
|
202
|
-
interactive: true,
|
|
203
|
-
minZoom: defaultMinZoom,
|
|
204
|
-
maxZoom: defaultMaxZoom,
|
|
205
|
-
minPitch: defaultMinPitch,
|
|
206
|
-
maxPitch: defaultMaxPitch,
|
|
207
|
-
scrollZoom: true,
|
|
208
|
-
boxZoom: true,
|
|
209
|
-
dragRotate: true,
|
|
210
|
-
dragPan: true,
|
|
211
|
-
keyboard: true,
|
|
212
|
-
doubleClickZoom: true,
|
|
213
|
-
touchZoomRotate: true,
|
|
214
|
-
touchPitch: true,
|
|
215
|
-
bearingSnap: 7,
|
|
216
|
-
clickTolerance: 3,
|
|
217
|
-
pitchWithRotate: true,
|
|
218
|
-
trackResize: true,
|
|
219
|
-
renderWorldCopies: true,
|
|
220
|
-
pitchEnabled: true,
|
|
221
|
-
rotateEnabled: true
|
|
222
|
-
};
|
|
223
|
-
export class Map extends Camera {
|
|
224
|
-
constructor(options) {
|
|
225
|
-
super(merge({}, DefaultOptions, options));
|
|
226
|
-
_defineProperty(this, "doubleClickZoom", void 0);
|
|
227
|
-
_defineProperty(this, "dragRotate", void 0);
|
|
228
|
-
_defineProperty(this, "dragPan", void 0);
|
|
229
|
-
_defineProperty(this, "touchZoomRotate", void 0);
|
|
230
|
-
_defineProperty(this, "scrollZoom", void 0);
|
|
231
|
-
_defineProperty(this, "keyboard", void 0);
|
|
232
|
-
_defineProperty(this, "touchPitch", void 0);
|
|
233
|
-
_defineProperty(this, "boxZoom", void 0);
|
|
234
|
-
_defineProperty(this, "handlers", void 0);
|
|
235
|
-
_defineProperty(this, "container", void 0);
|
|
236
|
-
_defineProperty(this, "canvas", void 0);
|
|
237
|
-
_defineProperty(this, "canvasContainer", void 0);
|
|
238
|
-
_defineProperty(this, "renderTaskQueue", new TaskQueue());
|
|
239
|
-
_defineProperty(this, "frame", void 0);
|
|
240
|
-
_defineProperty(this, "trackResize", true);
|
|
241
|
-
_defineProperty(this, "hash", void 0);
|
|
242
|
-
_defineProperty(this, "onWindowOnline", () => {
|
|
243
|
-
this.update();
|
|
244
|
-
});
|
|
245
|
-
_defineProperty(this, "onWindowResize", event => {
|
|
246
|
-
if (this.trackResize) {
|
|
247
|
-
this.resize({
|
|
248
|
-
originalEvent: event
|
|
249
|
-
}).update();
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
this.initContainer();
|
|
253
|
-
this.resize();
|
|
254
|
-
this.handlers = new HandlerManager(this, this.options);
|
|
255
|
-
if (typeof window !== 'undefined') {
|
|
256
|
-
window.addEventListener('online', this.onWindowOnline, false);
|
|
257
|
-
window.addEventListener('resize', this.onWindowResize, false);
|
|
258
|
-
window.addEventListener('orientationchange', this.onWindowResize, false);
|
|
259
|
-
}
|
|
260
|
-
const hashName = typeof options.hash === 'string' && options.hash || undefined;
|
|
261
|
-
if (options.hash) {
|
|
262
|
-
this.hash = new Hash(hashName).addTo(this);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// don't set position from options if set through hash
|
|
266
|
-
if (!this.hash || !this.hash.onHashChange()) {
|
|
267
|
-
this.jumpTo({
|
|
268
|
-
center: options.center,
|
|
269
|
-
zoom: options.zoom,
|
|
270
|
-
bearing: options.bearing,
|
|
271
|
-
pitch: options.pitch
|
|
272
|
-
});
|
|
273
|
-
if (options.bounds) {
|
|
274
|
-
this.resize();
|
|
275
|
-
this.fitBounds(options.bounds, merge({}, options.fitBoundsOptions, {
|
|
276
|
-
duration: 0
|
|
277
|
-
}));
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
resize(eventData) {
|
|
282
|
-
const [width, height] = this.containerDimensions();
|
|
283
|
-
this.transform.resize(width, height);
|
|
284
|
-
// 小程序环境不需要执行后续动作
|
|
285
|
-
const fireMoving = !this.moving;
|
|
286
|
-
if (fireMoving) {
|
|
287
|
-
this.stop();
|
|
288
|
-
this.emit('movestart', new window.CustomEvent('movestart', eventData));
|
|
289
|
-
this.emit('move', new window.CustomEvent('move', eventData));
|
|
290
|
-
}
|
|
291
|
-
this.emit('resize', new window.CustomEvent('resize', eventData));
|
|
292
|
-
if (fireMoving) {
|
|
293
|
-
this.emit('moveend', new window.CustomEvent('moveend', eventData));
|
|
294
|
-
}
|
|
295
|
-
return this;
|
|
296
|
-
}
|
|
297
|
-
getContainer() {
|
|
298
|
-
return this.container;
|
|
299
|
-
}
|
|
300
|
-
getCanvas() {
|
|
301
|
-
return this.canvas;
|
|
302
|
-
}
|
|
303
|
-
getCanvasContainer() {
|
|
304
|
-
return this.canvasContainer;
|
|
305
|
-
}
|
|
306
|
-
getCanvasOverlays() {
|
|
307
|
-
return this.getCanvasContainer();
|
|
308
|
-
}
|
|
309
|
-
project(lngLat) {
|
|
310
|
-
return this.transform.locationPoint(LngLat.convert(lngLat));
|
|
311
|
-
}
|
|
312
|
-
unproject(point) {
|
|
313
|
-
return this.transform.pointLocation(Point.convert(point));
|
|
314
|
-
}
|
|
315
|
-
getBounds() {
|
|
316
|
-
return this.transform.getBounds();
|
|
317
|
-
}
|
|
318
|
-
getMaxBounds() {
|
|
319
|
-
return this.transform.getMaxBounds();
|
|
320
|
-
}
|
|
321
|
-
setMaxBounds(bounds) {
|
|
322
|
-
this.transform.setMaxBounds(LngLatBounds.convert(bounds));
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
326
|
-
setStyle(style) {
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
setMinZoom(minZoom) {
|
|
330
|
-
minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
|
|
331
|
-
if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
|
|
332
|
-
this.transform.minZoom = minZoom;
|
|
333
|
-
if (this.getZoom() < minZoom) {
|
|
334
|
-
this.setZoom(minZoom);
|
|
335
|
-
}
|
|
336
|
-
return this;
|
|
337
|
-
} else {
|
|
338
|
-
throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
getMinZoom() {
|
|
342
|
-
return this.transform.minZoom;
|
|
343
|
-
}
|
|
344
|
-
setMaxZoom(maxZoom) {
|
|
345
|
-
maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
|
|
346
|
-
if (maxZoom >= this.transform.minZoom) {
|
|
347
|
-
this.transform.maxZoom = maxZoom;
|
|
348
|
-
if (this.getZoom() > maxZoom) {
|
|
349
|
-
this.setZoom(maxZoom);
|
|
350
|
-
}
|
|
351
|
-
return this;
|
|
352
|
-
} else {
|
|
353
|
-
throw new Error('maxZoom must be greater than the current minZoom');
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
getMaxZoom() {
|
|
357
|
-
return this.transform.maxZoom;
|
|
358
|
-
}
|
|
359
|
-
setMinPitch(minPitch) {
|
|
360
|
-
minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
|
|
361
|
-
if (minPitch < defaultMinPitch) {
|
|
362
|
-
throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);
|
|
363
|
-
}
|
|
364
|
-
if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
|
|
365
|
-
this.transform.minPitch = minPitch;
|
|
366
|
-
if (this.getPitch() < minPitch) {
|
|
367
|
-
this.setPitch(minPitch);
|
|
368
|
-
}
|
|
369
|
-
return this;
|
|
370
|
-
} else {
|
|
371
|
-
throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
getMinPitch() {
|
|
375
|
-
return this.transform.minPitch;
|
|
376
|
-
}
|
|
377
|
-
setMaxPitch(maxPitch) {
|
|
378
|
-
maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
|
|
379
|
-
if (maxPitch > defaultMaxPitch) {
|
|
380
|
-
throw new Error(`maxPitch must be less than or equal to ${defaultMaxPitch}`);
|
|
381
|
-
}
|
|
382
|
-
if (maxPitch >= this.transform.minPitch) {
|
|
383
|
-
this.transform.maxPitch = maxPitch;
|
|
384
|
-
if (this.getPitch() > maxPitch) {
|
|
385
|
-
this.setPitch(maxPitch);
|
|
386
|
-
}
|
|
387
|
-
return this;
|
|
388
|
-
} else {
|
|
389
|
-
throw new Error('maxPitch must be greater than the current minPitch');
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
getMaxPitch() {
|
|
393
|
-
return this.transform.maxPitch;
|
|
394
|
-
}
|
|
395
|
-
getRenderWorldCopies() {
|
|
396
|
-
return this.transform.renderWorldCopies;
|
|
397
|
-
}
|
|
398
|
-
setRenderWorldCopies(renderWorldCopies) {
|
|
399
|
-
this.transform.renderWorldCopies = !!renderWorldCopies;
|
|
400
|
-
}
|
|
401
|
-
remove() {
|
|
402
|
-
this.container.removeChild(this.canvasContainer);
|
|
403
|
-
// @ts-ignore
|
|
404
|
-
this.canvasContainer = null;
|
|
405
|
-
if (this.frame) {
|
|
406
|
-
this.frame.cancel();
|
|
407
|
-
this.frame = null;
|
|
408
|
-
}
|
|
409
|
-
this.renderTaskQueue.clear();
|
|
410
|
-
//销毁事件
|
|
411
|
-
this.handlers.destroy();
|
|
412
|
-
if (typeof window !== 'undefined') {
|
|
413
|
-
window.removeEventListener('online', this.onWindowOnline, false);
|
|
414
|
-
window.removeEventListener('resize', this.onWindowResize, false);
|
|
415
|
-
window.removeEventListener('orientationchange', this.onWindowResize, false);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
requestRenderFrame(cb) {
|
|
419
|
-
this.update();
|
|
420
|
-
return this.renderTaskQueue.add(cb);
|
|
421
|
-
}
|
|
422
|
-
cancelRenderFrame(id) {
|
|
423
|
-
return this.renderTaskQueue.remove(id);
|
|
424
|
-
}
|
|
425
|
-
triggerRepaint() {
|
|
426
|
-
if (!this.frame) {
|
|
427
|
-
this.frame = renderframe(paintStartTimeStamp => {
|
|
428
|
-
PerformanceUtils.frame(paintStartTimeStamp);
|
|
429
|
-
this.frame = null;
|
|
430
|
-
this.update(paintStartTimeStamp);
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
update(time) {
|
|
435
|
-
if (!this.frame) {
|
|
436
|
-
this.frame = renderframe(paintStartTimeStamp => {
|
|
437
|
-
PerformanceUtils.frame(paintStartTimeStamp);
|
|
438
|
-
this.frame = null;
|
|
439
|
-
this.renderTaskQueue.run(time);
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
initContainer() {
|
|
444
|
-
if (typeof this.options.container === 'string') {
|
|
445
|
-
this.container = window.document.getElementById(this.options.container);
|
|
446
|
-
if (!this.container) {
|
|
447
|
-
throw new Error(`Container '${this.options.container}' not found.`);
|
|
448
|
-
}
|
|
449
|
-
} else if (this.options.container instanceof HTMLElement) {
|
|
450
|
-
this.container = this.options.container;
|
|
451
|
-
} else {
|
|
452
|
-
throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
|
|
453
|
-
}
|
|
454
|
-
const container = this.container;
|
|
455
|
-
container.classList.add('l7-map');
|
|
456
|
-
const canvasContainer = this.canvasContainer = DOM.create('div', 'l7-canvas-container', container);
|
|
457
|
-
if (this.options.interactive) {
|
|
458
|
-
canvasContainer.classList.add('l7-interactive');
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
containerDimensions() {
|
|
462
|
-
let width = 0;
|
|
463
|
-
let height = 0;
|
|
464
|
-
if (this.container) {
|
|
465
|
-
width = this.container.clientWidth;
|
|
466
|
-
height = this.container.clientHeight;
|
|
467
|
-
width = width === 0 ? 400 : width;
|
|
468
|
-
height = height === 0 ? 300 : height;
|
|
469
|
-
}
|
|
470
|
-
return [width, height];
|
|
471
|
-
}
|
|
472
|
-
}
|
package/es/util.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export interface ICancelable {
|
|
2
|
-
cancel: () => void;
|
|
3
|
-
}
|
|
4
|
-
export declare function wrap(n: number, min: number, max: number): number;
|
|
5
|
-
export declare function clamp(n: number, min: number, max: number): number;
|
|
6
|
-
export declare function interpolate(a: number, b: number, t: number): number;
|
|
7
|
-
export declare function bezier(p1x: number, p1y: number, p2x: number, p2y: number): (t: number) => number;
|
|
8
|
-
export declare const ease: (t: number) => number;
|
|
9
|
-
export declare function prefersReducedMotion(): boolean;
|
|
10
|
-
export declare function pick(src: {
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
}, properties: string[]): {
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
};
|
|
15
|
-
export declare const now: () => number;
|
|
16
|
-
export declare const raf: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
|
|
17
|
-
export declare const cancel: ((handle: number) => void) & typeof cancelAnimationFrame;
|
|
18
|
-
export declare function renderframe(fn: (paintStartTimestamp: number) => void): ICancelable;
|
|
19
|
-
export declare function extend(dest: {
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
}, ...sources: Array<Partial<{
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
}>>): {
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
};
|
package/es/util.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import UnitBezier from '@mapbox/unitbezier';
|
|
3
|
-
let reducedMotionQuery;
|
|
4
|
-
export function wrap(n, min, max) {
|
|
5
|
-
const d = max - min;
|
|
6
|
-
const w = ((n - min) % d + d) % d + min;
|
|
7
|
-
return w === min ? max : w;
|
|
8
|
-
}
|
|
9
|
-
export function clamp(n, min, max) {
|
|
10
|
-
return Math.min(max, Math.max(min, n));
|
|
11
|
-
}
|
|
12
|
-
export function interpolate(a, b, t) {
|
|
13
|
-
return a * (1 - t) + b * t;
|
|
14
|
-
}
|
|
15
|
-
export function bezier(p1x, p1y, p2x, p2y) {
|
|
16
|
-
const bez = new UnitBezier(p1x, p1y, p2x, p2y);
|
|
17
|
-
return t => {
|
|
18
|
-
return bez.solve(t);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export const ease = bezier(0.25, 0.1, 0.25, 1);
|
|
22
|
-
export function prefersReducedMotion() {
|
|
23
|
-
var _reducedMotionQuery;
|
|
24
|
-
// Lazily initialize media query
|
|
25
|
-
if (reducedMotionQuery == null && typeof window !== 'undefined' && window.matchMedia) {
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
reducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
28
|
-
}
|
|
29
|
-
return (_reducedMotionQuery = reducedMotionQuery) === null || _reducedMotionQuery === void 0 ? void 0 : _reducedMotionQuery.matches;
|
|
30
|
-
}
|
|
31
|
-
export function pick(src, properties) {
|
|
32
|
-
const result = {};
|
|
33
|
-
for (const name of properties) {
|
|
34
|
-
if (name in src) {
|
|
35
|
-
result[name] = src[name];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
export const now = window.performance && window.performance.now ? window.performance.now.bind(window.performance) : Date.now.bind(Date);
|
|
41
|
-
export const raf = window.requestAnimationFrame ||
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
window.mozRequestAnimationFrame ||
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
window.webkitRequestAnimationFrame ||
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
window.msRequestAnimationFrame;
|
|
48
|
-
export const cancel = window.cancelAnimationFrame ||
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
window.mozCancelAnimationFrame ||
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
window.webkitCancelAnimationFrame ||
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
window.msCancelAnimationFrame;
|
|
55
|
-
export function renderframe(fn) {
|
|
56
|
-
const frame = raf(fn);
|
|
57
|
-
return {
|
|
58
|
-
cancel: () => cancel(frame)
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
export function extend(dest, ...sources) {
|
|
62
|
-
for (const src of sources) {
|
|
63
|
-
for (const k in src) {
|
|
64
|
-
if (src[k] !== undefined) {
|
|
65
|
-
dest[k] = src[k];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return dest;
|
|
70
|
-
}
|
package/es/utils/Aabb.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { vec3 } from 'gl-matrix';
|
|
2
|
-
import type 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
|
-
}
|
package/es/utils/Aabb.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { vec3, vec4 } from 'gl-matrix';
|
|
3
|
-
export default class Aabb {
|
|
4
|
-
constructor(min, max) {
|
|
5
|
-
_defineProperty(this, "min", void 0);
|
|
6
|
-
_defineProperty(this, "max", void 0);
|
|
7
|
-
_defineProperty(this, "center", void 0);
|
|
8
|
-
this.min = min;
|
|
9
|
-
this.max = max;
|
|
10
|
-
this.center = vec3.scale(new Float32Array(3), vec3.add(new Float32Array(3), this.min, this.max), 0.5);
|
|
11
|
-
}
|
|
12
|
-
quadrant(index) {
|
|
13
|
-
const split = [index % 2 === 0, index < 2];
|
|
14
|
-
const qMin = vec3.clone(this.min);
|
|
15
|
-
const qMax = vec3.clone(this.max);
|
|
16
|
-
for (let axis = 0; axis < split.length; axis++) {
|
|
17
|
-
qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];
|
|
18
|
-
qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];
|
|
19
|
-
}
|
|
20
|
-
// Elevation is always constant, hence quadrant.max.z = this.max.z
|
|
21
|
-
qMax[2] = this.max[2];
|
|
22
|
-
return new Aabb(qMin, qMax);
|
|
23
|
-
}
|
|
24
|
-
distanceX(point) {
|
|
25
|
-
const pointOnAabb = Math.max(Math.min(this.max[0], point[0]), this.min[0]);
|
|
26
|
-
return pointOnAabb - point[0];
|
|
27
|
-
}
|
|
28
|
-
distanceY(point) {
|
|
29
|
-
const pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);
|
|
30
|
-
return pointOnAabb - point[1];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Performs a frustum-aabb intersection test. Returns 0 if there's no intersection,
|
|
34
|
-
// 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum.
|
|
35
|
-
intersects(frustum) {
|
|
36
|
-
// Execute separating axis test between two convex objects to find intersections
|
|
37
|
-
// Each frustum plane together with 3 major axes define the separating axes
|
|
38
|
-
// Note: test only 4 points as both min and max points have equal elevation
|
|
39
|
-
|
|
40
|
-
const 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]];
|
|
41
|
-
let fullyInside = true;
|
|
42
|
-
for (const plane of frustum.planes) {
|
|
43
|
-
let pointsInside = 0;
|
|
44
|
-
for (const i of aabbPoints) {
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
pointsInside += vec4.dot(plane, i) >= 0;
|
|
47
|
-
}
|
|
48
|
-
if (pointsInside === 0) {
|
|
49
|
-
return 0;
|
|
50
|
-
}
|
|
51
|
-
if (pointsInside !== aabbPoints.length) {
|
|
52
|
-
fullyInside = false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (fullyInside) {
|
|
56
|
-
return 2;
|
|
57
|
-
}
|
|
58
|
-
for (let axis = 0; axis < 3; axis++) {
|
|
59
|
-
let projMin = Number.MAX_VALUE;
|
|
60
|
-
let projMax = -Number.MAX_VALUE;
|
|
61
|
-
for (const p of frustum.points) {
|
|
62
|
-
const projectedPoint = p[axis] - this.min[axis];
|
|
63
|
-
projMin = Math.min(projMin, projectedPoint);
|
|
64
|
-
projMax = Math.max(projMax, projectedPoint);
|
|
65
|
-
}
|
|
66
|
-
if (projMax < 0 || projMin > this.max[axis] - this.min[axis]) {
|
|
67
|
-
return 0;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return 1;
|
|
71
|
-
}
|
|
72
|
-
}
|
package/es/utils/dom.d.ts
DELETED