@antv/l7-map 2.21.11-beta.4 → 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/lib/utils/Aabb.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _glMatrix = require("gl-matrix");
|
|
10
|
-
class Aabb {
|
|
11
|
-
constructor(min, max) {
|
|
12
|
-
(0, _defineProperty2.default)(this, "min", void 0);
|
|
13
|
-
(0, _defineProperty2.default)(this, "max", void 0);
|
|
14
|
-
(0, _defineProperty2.default)(this, "center", void 0);
|
|
15
|
-
this.min = min;
|
|
16
|
-
this.max = max;
|
|
17
|
-
this.center = _glMatrix.vec3.scale(new Float32Array(3), _glMatrix.vec3.add(new Float32Array(3), this.min, this.max), 0.5);
|
|
18
|
-
}
|
|
19
|
-
quadrant(index) {
|
|
20
|
-
const split = [index % 2 === 0, index < 2];
|
|
21
|
-
const qMin = _glMatrix.vec3.clone(this.min);
|
|
22
|
-
const qMax = _glMatrix.vec3.clone(this.max);
|
|
23
|
-
for (let axis = 0; axis < split.length; axis++) {
|
|
24
|
-
qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];
|
|
25
|
-
qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];
|
|
26
|
-
}
|
|
27
|
-
// Elevation is always constant, hence quadrant.max.z = this.max.z
|
|
28
|
-
qMax[2] = this.max[2];
|
|
29
|
-
return new Aabb(qMin, qMax);
|
|
30
|
-
}
|
|
31
|
-
distanceX(point) {
|
|
32
|
-
const pointOnAabb = Math.max(Math.min(this.max[0], point[0]), this.min[0]);
|
|
33
|
-
return pointOnAabb - point[0];
|
|
34
|
-
}
|
|
35
|
-
distanceY(point) {
|
|
36
|
-
const pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);
|
|
37
|
-
return pointOnAabb - point[1];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Performs a frustum-aabb intersection test. Returns 0 if there's no intersection,
|
|
41
|
-
// 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum.
|
|
42
|
-
intersects(frustum) {
|
|
43
|
-
// Execute separating axis test between two convex objects to find intersections
|
|
44
|
-
// Each frustum plane together with 3 major axes define the separating axes
|
|
45
|
-
// Note: test only 4 points as both min and max points have equal elevation
|
|
46
|
-
|
|
47
|
-
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]];
|
|
48
|
-
let fullyInside = true;
|
|
49
|
-
for (const plane of frustum.planes) {
|
|
50
|
-
let pointsInside = 0;
|
|
51
|
-
for (const i of aabbPoints) {
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
pointsInside += _glMatrix.vec4.dot(plane, i) >= 0;
|
|
54
|
-
}
|
|
55
|
-
if (pointsInside === 0) {
|
|
56
|
-
return 0;
|
|
57
|
-
}
|
|
58
|
-
if (pointsInside !== aabbPoints.length) {
|
|
59
|
-
fullyInside = false;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (fullyInside) {
|
|
63
|
-
return 2;
|
|
64
|
-
}
|
|
65
|
-
for (let axis = 0; axis < 3; axis++) {
|
|
66
|
-
let projMin = Number.MAX_VALUE;
|
|
67
|
-
let projMax = -Number.MAX_VALUE;
|
|
68
|
-
for (const p of frustum.points) {
|
|
69
|
-
const projectedPoint = p[axis] - this.min[axis];
|
|
70
|
-
projMin = Math.min(projMin, projectedPoint);
|
|
71
|
-
projMax = Math.max(projMax, projectedPoint);
|
|
72
|
-
}
|
|
73
|
-
if (projMax < 0 || projMin > this.max[axis] - this.min[axis]) {
|
|
74
|
-
return 0;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return 1;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.default = Aabb;
|
package/lib/utils/dom.d.ts
DELETED
package/lib/utils/dom.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _point = _interopRequireDefault(require("../geo/point"));
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
|
|
11
|
-
const DOM = {};
|
|
12
|
-
var _default = exports.default = DOM;
|
|
13
|
-
DOM.create = (tagName, className, container) => {
|
|
14
|
-
const el = window.document.createElement(tagName);
|
|
15
|
-
if (className !== undefined) {
|
|
16
|
-
el.className = className;
|
|
17
|
-
}
|
|
18
|
-
if (container) {
|
|
19
|
-
container.appendChild(el);
|
|
20
|
-
}
|
|
21
|
-
return el;
|
|
22
|
-
};
|
|
23
|
-
DOM.createNS = (namespaceURI, tagName) => {
|
|
24
|
-
const el = window.document.createElementNS(namespaceURI, tagName);
|
|
25
|
-
return el;
|
|
26
|
-
};
|
|
27
|
-
const docStyle = window.document && window.document.documentElement.style;
|
|
28
|
-
function testProp(props) {
|
|
29
|
-
if (!docStyle) {
|
|
30
|
-
return props[0];
|
|
31
|
-
}
|
|
32
|
-
for (const i of props) {
|
|
33
|
-
if (i in docStyle) {
|
|
34
|
-
return i;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return props[0];
|
|
38
|
-
}
|
|
39
|
-
const selectProp = testProp(['userSelect', 'MozUserSelect', 'WebkitUserSelect', 'msUserSelect']);
|
|
40
|
-
let userSelect;
|
|
41
|
-
DOM.disableDrag = () => {
|
|
42
|
-
if (docStyle && selectProp) {
|
|
43
|
-
userSelect = docStyle[selectProp];
|
|
44
|
-
docStyle[selectProp] = 'none';
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
DOM.enableDrag = () => {
|
|
48
|
-
if (docStyle && selectProp) {
|
|
49
|
-
docStyle[selectProp] = userSelect;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const transformProp = testProp(['transform', 'WebkitTransform']);
|
|
53
|
-
DOM.setTransform = (el, value) => {
|
|
54
|
-
// https://github.com/facebook/flow/issues/7754
|
|
55
|
-
// $FlowFixMe
|
|
56
|
-
el.style[transformProp] = value;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// Feature detection for {passive: false} support in add/removeEventListener.
|
|
60
|
-
let passiveSupported = false;
|
|
61
|
-
try {
|
|
62
|
-
// https://github.com/facebook/flow/issues/285
|
|
63
|
-
// $FlowFixMe
|
|
64
|
-
const options = Object.defineProperty({}, 'passive', {
|
|
65
|
-
get() {
|
|
66
|
-
// eslint-disable-line
|
|
67
|
-
passiveSupported = true;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
window.addEventListener('test', options, options);
|
|
72
|
-
// @ts-ignore
|
|
73
|
-
window.removeEventListener('test', options, options);
|
|
74
|
-
} catch (err) {
|
|
75
|
-
passiveSupported = false;
|
|
76
|
-
}
|
|
77
|
-
DOM.addEventListener = (target, type, callback, options = {}) => {
|
|
78
|
-
if ('passive' in options && passiveSupported) {
|
|
79
|
-
target.addEventListener(type, callback, options);
|
|
80
|
-
} else {
|
|
81
|
-
target.addEventListener(type, callback, options.capture);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
DOM.removeEventListener = (target, type, callback, options = {}) => {
|
|
85
|
-
if ('passive' in options && passiveSupported) {
|
|
86
|
-
target.removeEventListener(type, callback, options);
|
|
87
|
-
} else {
|
|
88
|
-
target.removeEventListener(type, callback, options.capture);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// Suppress the next click, but only if it's immediate.
|
|
93
|
-
const suppressClick = e => {
|
|
94
|
-
e.preventDefault();
|
|
95
|
-
e.stopPropagation();
|
|
96
|
-
window.removeEventListener('click', suppressClick, true);
|
|
97
|
-
};
|
|
98
|
-
DOM.suppressClick = () => {
|
|
99
|
-
window.addEventListener('click', suppressClick, true);
|
|
100
|
-
setTimeout(() => {
|
|
101
|
-
window.removeEventListener('click', suppressClick, true);
|
|
102
|
-
}, 0);
|
|
103
|
-
};
|
|
104
|
-
DOM.mousePos = (el, e) => {
|
|
105
|
-
// 暂时从 el 上获取 top/left, 后面需要动态获取
|
|
106
|
-
const rect = el.getBoundingClientRect();
|
|
107
|
-
return new _point.default(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop);
|
|
108
|
-
};
|
|
109
|
-
DOM.touchPos = (el, touches) => {
|
|
110
|
-
// 暂时从 el 上获取 top/left, 后面需要动态获取
|
|
111
|
-
const rect = el.getBoundingClientRect();
|
|
112
|
-
const points = [];
|
|
113
|
-
for (const touche of touches) {
|
|
114
|
-
points.push(new _point.default(touche.clientX - rect.left - el.clientLeft, touche.clientY - rect.top - el.clientTop));
|
|
115
|
-
}
|
|
116
|
-
return points;
|
|
117
|
-
};
|
|
118
|
-
DOM.mouseButton = e => {
|
|
119
|
-
return e.button;
|
|
120
|
-
};
|
|
121
|
-
DOM.remove = node => {
|
|
122
|
-
if (node.parentNode) {
|
|
123
|
-
node.parentNode.removeChild(node);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
};
|
package/lib/utils/performance.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PerformanceUtils = exports.PerformanceMarkers = void 0;
|
|
7
|
-
let lastFrameTime = null;
|
|
8
|
-
let frameTimes = [];
|
|
9
|
-
const minFramerateTarget = 30;
|
|
10
|
-
const frameTimeTarget = 1000 / minFramerateTarget;
|
|
11
|
-
const performance = window.performance;
|
|
12
|
-
const PerformanceMarkers = exports.PerformanceMarkers = {
|
|
13
|
-
create: 'create',
|
|
14
|
-
load: 'load',
|
|
15
|
-
fullLoad: 'fullLoad'
|
|
16
|
-
};
|
|
17
|
-
const PerformanceUtils = exports.PerformanceUtils = {
|
|
18
|
-
mark(marker) {
|
|
19
|
-
performance.mark(marker);
|
|
20
|
-
},
|
|
21
|
-
frame(timestamp) {
|
|
22
|
-
const currTimestamp = timestamp;
|
|
23
|
-
if (lastFrameTime != null) {
|
|
24
|
-
const frameTime = currTimestamp - lastFrameTime;
|
|
25
|
-
frameTimes.push(frameTime);
|
|
26
|
-
}
|
|
27
|
-
lastFrameTime = currTimestamp;
|
|
28
|
-
},
|
|
29
|
-
clearMetrics() {
|
|
30
|
-
lastFrameTime = null;
|
|
31
|
-
frameTimes = [];
|
|
32
|
-
performance.clearMeasures('loadTime');
|
|
33
|
-
performance.clearMeasures('fullLoadTime');
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
// tslint:disable-next-line:forin
|
|
36
|
-
for (const marker in PerformanceMarkers) {
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
performance.clearMarks(PerformanceMarkers[marker]);
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
getPerformanceMetrics() {
|
|
42
|
-
const loadTime = performance.measure('loadTime', PerformanceMarkers.create, PerformanceMarkers.load
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
).duration;
|
|
45
|
-
const fullLoadTime = performance.measure('fullLoadTime', PerformanceMarkers.create, PerformanceMarkers.fullLoad
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
).duration;
|
|
48
|
-
const totalFrames = frameTimes.length;
|
|
49
|
-
const avgFrameTime = frameTimes.reduce((prev, curr) => prev + curr, 0) / totalFrames / 1000;
|
|
50
|
-
const fps = 1 / avgFrameTime;
|
|
51
|
-
|
|
52
|
-
// count frames that missed our framerate target
|
|
53
|
-
const droppedFrames = frameTimes.filter(frameTime => frameTime > frameTimeTarget).reduce((acc, curr) => {
|
|
54
|
-
return acc + (curr - frameTimeTarget) / frameTimeTarget;
|
|
55
|
-
}, 0);
|
|
56
|
-
const percentDroppedFrames = droppedFrames / (totalFrames + droppedFrames) * 100;
|
|
57
|
-
return {
|
|
58
|
-
loadTime,
|
|
59
|
-
fullLoadTime,
|
|
60
|
-
fps,
|
|
61
|
-
percentDroppedFrames
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
};
|
package/lib/utils/primitives.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _glMatrix = require("gl-matrix");
|
|
10
|
-
class Frustum {
|
|
11
|
-
static fromInvProjectionMatrix(invProj, worldSize, zoom) {
|
|
12
|
-
const 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]];
|
|
13
|
-
const scale = Math.pow(2, zoom);
|
|
14
|
-
|
|
15
|
-
// Transform frustum corner points from clip space to tile space
|
|
16
|
-
const frustumCoords = clipSpaceCorners.map(v => _glMatrix.vec4.transformMat4(new Float32Array([]), v, invProj)).map(v => _glMatrix.vec4.scale(new Float32Array([]), v, 1.0 / v[3] / worldSize * scale));
|
|
17
|
-
const frustumPlanePointIndices = [[0, 1, 2],
|
|
18
|
-
// near
|
|
19
|
-
[6, 5, 4],
|
|
20
|
-
// far
|
|
21
|
-
[0, 3, 7],
|
|
22
|
-
// left
|
|
23
|
-
[2, 1, 5],
|
|
24
|
-
// right
|
|
25
|
-
[3, 2, 6],
|
|
26
|
-
// bottom
|
|
27
|
-
[0, 4, 5] // top
|
|
28
|
-
];
|
|
29
|
-
const frustumPlanes = frustumPlanePointIndices.map(p => {
|
|
30
|
-
const a = _glMatrix.vec3.sub(new Float32Array(3), new Float32Array(frustumCoords[p[0]]), new Float32Array(frustumCoords[p[1]]));
|
|
31
|
-
const b = _glMatrix.vec3.sub(new Float32Array(3), new Float32Array(frustumCoords[p[2]]), new Float32Array(frustumCoords[p[1]]));
|
|
32
|
-
const n = _glMatrix.vec3.normalize(new Float32Array(3), _glMatrix.vec3.cross(new Float32Array(3), a, b));
|
|
33
|
-
const d = -_glMatrix.vec3.dot(n, new Float32Array(frustumCoords[p[1]]));
|
|
34
|
-
return n.concat(d);
|
|
35
|
-
});
|
|
36
|
-
return new Frustum(frustumCoords, frustumPlanes);
|
|
37
|
-
}
|
|
38
|
-
constructor(points, planes) {
|
|
39
|
-
(0, _defineProperty2.default)(this, "points", void 0);
|
|
40
|
-
(0, _defineProperty2.default)(this, "planes", void 0);
|
|
41
|
-
this.points = points;
|
|
42
|
-
this.planes = planes;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.default = Frustum;
|
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
package/lib/utils/task_queue.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
// can't mark opaque due to https://github.com/flowtype/flow-remove-types/pull/61
|
|
10
|
-
|
|
11
|
-
class TaskQueue {
|
|
12
|
-
constructor() {
|
|
13
|
-
(0, _defineProperty2.default)(this, "queue", void 0);
|
|
14
|
-
(0, _defineProperty2.default)(this, "id", void 0);
|
|
15
|
-
(0, _defineProperty2.default)(this, "cleared", void 0);
|
|
16
|
-
(0, _defineProperty2.default)(this, "currentlyRunning", void 0);
|
|
17
|
-
this.queue = [];
|
|
18
|
-
this.id = 0;
|
|
19
|
-
this.cleared = false;
|
|
20
|
-
this.currentlyRunning = false;
|
|
21
|
-
}
|
|
22
|
-
add(callback) {
|
|
23
|
-
const id = ++this.id;
|
|
24
|
-
const queue = this.queue;
|
|
25
|
-
queue.push({
|
|
26
|
-
callback,
|
|
27
|
-
id,
|
|
28
|
-
cancelled: false
|
|
29
|
-
});
|
|
30
|
-
return id;
|
|
31
|
-
}
|
|
32
|
-
remove(id) {
|
|
33
|
-
const running = this.currentlyRunning;
|
|
34
|
-
const queue = running ? this.queue.concat(running) : this.queue;
|
|
35
|
-
for (const task of queue) {
|
|
36
|
-
if (task.id === id) {
|
|
37
|
-
task.cancelled = true;
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
run(timeStamp = 0) {
|
|
43
|
-
const queue = this.currentlyRunning = this.queue;
|
|
44
|
-
|
|
45
|
-
// Tasks queued by callbacks in the current queue should be executed
|
|
46
|
-
// on the next run, not the current run.
|
|
47
|
-
this.queue = [];
|
|
48
|
-
for (const task of queue) {
|
|
49
|
-
if (task.cancelled) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
task.callback(timeStamp);
|
|
53
|
-
if (this.cleared) {
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
this.cleared = false;
|
|
58
|
-
this.currentlyRunning = false;
|
|
59
|
-
}
|
|
60
|
-
clear() {
|
|
61
|
-
if (this.currentlyRunning) {
|
|
62
|
-
this.cleared = true;
|
|
63
|
-
}
|
|
64
|
-
this.queue = [];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
var _default = exports.default = TaskQueue;
|