@aibee/crc-bmap 0.8.44 → 0.8.46
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/lib/bmap.cjs.min.js +408 -401
- package/lib/bmap.esm.js +7644 -1526
- package/lib/bmap.esm.min.js +408 -401
- package/lib/bmap.min.js +408 -401
- package/lib/src/bmap.js +60 -54
- package/lib/src/context/OrbitControls.js +4 -1
- package/lib/src/context/context.js +54 -37
- package/lib/src/context/control.js +85 -83
- package/lib/src/context/scene.js +1 -0
- package/lib/src/elements/base-svg.js +5 -4
- package/lib/src/elements/floor.js +8 -0
- package/lib/src/elements/glb-model.js +14 -18
- package/lib/src/elements/graphic.js +18 -8
- package/lib/src/elements/ground-texture.js +41 -44
- package/lib/src/elements/heatmap.js +2 -1
- package/lib/src/elements/lane.js +5 -1
- package/lib/src/elements/merge-graphic.js +3 -28
- package/lib/src/elements/model.js +5 -9
- package/lib/src/elements/overlay.js +9 -7
- package/lib/src/elements/poi.js +55 -49
- package/lib/src/elements/poi2.js +52 -53
- package/lib/src/elements/shadow.js +3 -1
- package/lib/src/elements/svg-line.js +2 -0
- package/lib/src/elements/svg-polygon.js +1 -0
- package/lib/src/elements/text-texture.js +32 -36
- package/lib/src/elements/wall.js +3 -41
- package/lib/src/external/meshLine.js +17 -0
- package/lib/src/factory/img-texture.js +1 -0
- package/lib/src/factory/material.js +21 -51
- package/lib/src/factory/model.js +31 -33
- package/lib/src/factory/text-texture.js +17 -0
- package/lib/src/factory/unique-key.js +8 -0
- package/lib/src/layer/graphic-layer.js +1 -0
- package/lib/src/layer/parking-layer.d.ts +6 -0
- package/lib/src/layer/parking-layer.js +8 -0
- package/lib/src/layer/poi-layer.js +4 -1
- package/lib/src/layer/poi-layer2.js +2 -0
- package/lib/src/loader/AibeeLoader/index.js +230 -276
- package/lib/src/loader/AibeeLoader/layer.js +8 -6
- package/lib/src/loader/CrLoader/api/floor.js +45 -73
- package/lib/src/loader/CrLoader/index.js +88 -106
- package/lib/src/operations/hover/hover-helper.js +12 -2
- package/lib/src/operations/selection/selection.js +11 -1
- package/lib/src/plugins/car-inertial-position/car-inertial-position.d.ts +42 -10
- package/lib/src/plugins/car-inertial-position/car-inertial-position.js +285 -67
- package/lib/src/plugins/car-inertial-position/compass.d.ts +4 -5
- package/lib/src/plugins/car-inertial-position/compass.js +43 -38
- package/lib/src/plugins/car-inertial-position/kalman-filter.d.ts +14 -0
- package/lib/src/plugins/car-inertial-position/kalman-filter.js +30 -0
- package/lib/src/plugins/car-inertial-position/utils.d.ts +1 -1
- package/lib/src/plugins/car-inertial-position/utils.js +8 -5
- package/lib/src/plugins/cr-nav-path/cr-nav-path.js +47 -55
- package/lib/src/plugins/cr-nav-path/cr-path.worker.js +4 -2
- package/lib/src/plugins/equipment/equipment.js +20 -22
- package/lib/src/plugins/mul-floor-navigation/mul-floor-navigation.js +63 -61
- package/lib/src/plugins/mul-floor-navigation/path.js +34 -30
- package/lib/src/plugins/mul-floor-navigation/start-model.js +2 -1
- package/lib/src/plugins/mul-floor-select/mul-floor-select.js +2 -1
- package/lib/src/plugins/mul-floors/mul-floors.js +1 -0
- package/lib/src/plugins/nav-path/nav-path.js +51 -59
- package/lib/src/plugins/nav-path/path.worker.js +4 -2
- package/lib/src/plugins/navigation/navigation.d.ts +5 -0
- package/lib/src/plugins/navigation/navigation.js +240 -217
- package/lib/src/plugins/navigation/path.js +34 -30
- package/lib/src/plugins/navigation/position-navigation.d.ts +4 -0
- package/lib/src/plugins/navigation/position-navigation.js +96 -79
- package/lib/src/plugins/navigation/start-rotate-helper-poi.js +18 -6
- package/lib/src/plugins/pdr-position/imu-position.js +13 -9
- package/lib/src/plugins/pdr-position/particle.js +4 -2
- package/lib/src/plugins/pdr-position/pdr.js +5 -4
- package/lib/src/plugins/pdr-position/position.js +5 -2
- package/lib/src/plugins/pdr-position/sensor.js +20 -25
- package/lib/src/plugins/select/select.js +11 -1
- package/lib/src/utils/camera-bound.js +3 -1
- package/lib/src/utils/color.js +8 -4
- package/lib/src/utils/coordinate.js +1 -0
- package/lib/src/utils/create.js +4 -2
- package/lib/src/utils/events.js +15 -4
- package/lib/src/utils/index-db.js +18 -11
- package/lib/src/utils/init-helper.js +7 -2
- package/lib/src/utils/obj-utils.js +3 -2
- package/lib/src/utils/os.js +1 -0
- package/lib/src/utils/path.js +15 -4
- package/lib/src/utils/promise.js +3 -1
- package/lib/src/utils/proxy.js +2 -1
- package/lib/src/utils/road.js +20 -14
- package/lib/src/utils/road2.js +60 -39
- package/lib/src/utils/rules.js +1 -0
- package/lib/src/utils/string.js +3 -1
- package/lib/src/utils/svg.js +12 -11
- package/lib/src/utils/taskQueue.js +29 -29
- package/lib/src/utils/timer.js +8 -1
- package/lib/src/utils/translate.js +3 -1
- package/lib/src/utils/tween.js +8 -0
- package/lib/src/utils/webworker.js +10 -9
- package/package.json +2 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import "core-js/modules/es.array.unshift.js";
|
|
3
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
4
|
+
import "core-js/modules/es.array.push.js";
|
|
5
|
+
import { EventDispatcher, Vector2 } from "three";
|
|
6
|
+
import { calc_angle, calc_direction, distancePointToSegment, getLength, getPathLength, getPointEdgeIndex, getPosByPathDistance, PathDirection, Timer, TweenUtil } from "../../utils";
|
|
5
7
|
import { Tween } from "@tweenjs/tween.js";
|
|
6
8
|
import { throttle } from 'lodash';
|
|
7
9
|
const defaultConfig = {
|
|
@@ -116,7 +118,7 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
116
118
|
}
|
|
117
119
|
toPosition(floor, pos) {
|
|
118
120
|
const adsorbData = this.adsorb(floor, pos);
|
|
119
|
-
console.log("adsorbData", adsorbData)
|
|
121
|
+
// console.log("adsorbData", adsorbData)
|
|
120
122
|
if (!adsorbData) {
|
|
121
123
|
return;
|
|
122
124
|
}
|
|
@@ -157,57 +159,54 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
157
159
|
this.paused = false;
|
|
158
160
|
this.startCurRouteSimulation();
|
|
159
161
|
}
|
|
160
|
-
startCurRouteSimulation() {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}).start();
|
|
209
|
-
});
|
|
210
|
-
})();
|
|
162
|
+
async startCurRouteSimulation() {
|
|
163
|
+
const { curRoutePath } = this;
|
|
164
|
+
if (!curRoutePath) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (this.simulationTween) {
|
|
168
|
+
this.tweenUtil.remove(this.simulationTween);
|
|
169
|
+
}
|
|
170
|
+
const arr = [];
|
|
171
|
+
return new Promise((resolve)=>{
|
|
172
|
+
const path = [
|
|
173
|
+
this.position,
|
|
174
|
+
...this.curRoutePathPoints.slice(this.pointIndex + 1)
|
|
175
|
+
];
|
|
176
|
+
const distance = this.getCurRouteRemainDistance();
|
|
177
|
+
const time = distance / this.options.simulationSpeed;
|
|
178
|
+
const onUpdate = this.throttleUpdatePosition = throttle((v)=>{
|
|
179
|
+
const pos = getPosByPathDistance(path, v.distance);
|
|
180
|
+
if (!pos) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
arr.push({
|
|
184
|
+
floor: curRoutePath.floor,
|
|
185
|
+
pos
|
|
186
|
+
});
|
|
187
|
+
this.toPosition(curRoutePath.floor, pos);
|
|
188
|
+
}, 100);
|
|
189
|
+
const tween = this.simulationTween = new Tween({
|
|
190
|
+
distance: 0
|
|
191
|
+
}, this.tweenUtil.group).to({
|
|
192
|
+
distance
|
|
193
|
+
}, time * 1000).onUpdate(onUpdate).onComplete(()=>{
|
|
194
|
+
this.tweenUtil.remove(tween);
|
|
195
|
+
onUpdate.flush();
|
|
196
|
+
onUpdate.cancel();
|
|
197
|
+
if (this.routeIndex + 1 < this.paths.length) {
|
|
198
|
+
this.routeIndex++;
|
|
199
|
+
this.position = this.paths[this.routeIndex].points[0];
|
|
200
|
+
this.pointIndex = 0;
|
|
201
|
+
setTimeout(()=>{
|
|
202
|
+
resolve(this.startCurRouteSimulation());
|
|
203
|
+
}, 3000);
|
|
204
|
+
} else {
|
|
205
|
+
resolve(true);
|
|
206
|
+
console.log(arr, this.routeIndex, this.paths);
|
|
207
|
+
}
|
|
208
|
+
}).start();
|
|
209
|
+
});
|
|
211
210
|
}
|
|
212
211
|
changeSimulationSpeed(speed) {
|
|
213
212
|
this.options.simulationSpeed = speed;
|
|
@@ -258,6 +257,8 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
258
257
|
let dir = PathDirection.FRONT;
|
|
259
258
|
let crossName = (curRoutePath == null ? void 0 : (_curRoutePath_pointInfos_index = curRoutePath.pointInfos[index]) == null ? void 0 : _curRoutePath_pointInfos_index.crossName) || "";
|
|
260
259
|
let distance = 0;
|
|
260
|
+
let angle = 0;
|
|
261
|
+
let nextAngle = 0;
|
|
261
262
|
while(dir === PathDirection.FRONT && index <= curRoutePathPoints.length){
|
|
262
263
|
const p1 = curRoutePathPoints[index];
|
|
263
264
|
const p2 = curRoutePathPoints[index + 1];
|
|
@@ -265,43 +266,54 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
265
266
|
if (!p1 || !p2) {
|
|
266
267
|
dir = PathDirection.END;
|
|
267
268
|
} else {
|
|
268
|
-
if (pointIndex === 0) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
269
|
+
// if (pointIndex === 0) {
|
|
270
|
+
// // 判断离起点的距离
|
|
271
|
+
// const l = getLength(p1, position)
|
|
272
|
+
// if (l < 5) {
|
|
273
|
+
// dir = PathDirection.START
|
|
274
|
+
// } else {
|
|
275
|
+
// dir = PathDirection.FRONT
|
|
276
|
+
// index += 1;
|
|
277
|
+
// }
|
|
278
|
+
// } else {
|
|
279
|
+
distance += getLength(p1, p2);
|
|
280
|
+
if (!p3) {
|
|
281
|
+
dir = PathDirection.END;
|
|
277
282
|
} else {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
index += 1;
|
|
286
|
-
}
|
|
283
|
+
dir = calc_direction(p1, p2, p3);
|
|
284
|
+
angle = calc_angle(p1, p2, p3);
|
|
285
|
+
const nextRadians = new Vector2(p3[0] - p2[0], p3[1] - p2[1]).angle();
|
|
286
|
+
nextAngle = (nextRadians * 180 / Math.PI - 90 + 360) % 360;
|
|
287
|
+
var _curRoutePath_pointInfos__crossName;
|
|
288
|
+
crossName = (_curRoutePath_pointInfos__crossName = curRoutePath == null ? void 0 : curRoutePath.pointInfos[index + 1].crossName) != null ? _curRoutePath_pointInfos__crossName : "";
|
|
289
|
+
index += 1;
|
|
287
290
|
}
|
|
291
|
+
// }
|
|
288
292
|
}
|
|
289
293
|
}
|
|
294
|
+
if (curRoutePathPoints[index]) {
|
|
295
|
+
// distance 是 position - curRoutePathPoints[index] 的距离 前面最后的时候index+1了,所以index就是拐弯的点了
|
|
296
|
+
distance = getLength(position, curRoutePathPoints[index]);
|
|
297
|
+
}
|
|
290
298
|
// 如果是终点,并且distance <= this.options.directionEmitThreshold 不做修改
|
|
291
299
|
if (dir === PathDirection.END && distance <= this.options.directionEmitThreshold) {
|
|
292
300
|
return {
|
|
293
301
|
dir,
|
|
294
302
|
distance,
|
|
295
|
-
crossName
|
|
303
|
+
crossName,
|
|
304
|
+
angle,
|
|
305
|
+
nextAngle
|
|
296
306
|
};
|
|
297
307
|
}
|
|
298
308
|
// 其他情况下判断距离起点的距离,如果是 <= 5米 就是start
|
|
299
309
|
const distanceToStart = this.getCurRouteToStartDistance();
|
|
300
|
-
if (distanceToStart <= 5) {
|
|
310
|
+
if (pointIndex === 0 && distanceToStart <= 5) {
|
|
301
311
|
return {
|
|
302
312
|
dir: PathDirection.START,
|
|
303
313
|
distance,
|
|
304
|
-
crossName
|
|
314
|
+
crossName,
|
|
315
|
+
angle,
|
|
316
|
+
nextAngle
|
|
305
317
|
};
|
|
306
318
|
}
|
|
307
319
|
// 其他情况根据拐弯距离判断是不是直行
|
|
@@ -311,7 +323,9 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
311
323
|
return {
|
|
312
324
|
dir,
|
|
313
325
|
distance,
|
|
314
|
-
crossName
|
|
326
|
+
crossName,
|
|
327
|
+
angle,
|
|
328
|
+
nextAngle
|
|
315
329
|
};
|
|
316
330
|
}
|
|
317
331
|
getNavigationInfo() {
|
|
@@ -323,7 +337,7 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
323
337
|
if (!nextDirInfo) {
|
|
324
338
|
return null;
|
|
325
339
|
}
|
|
326
|
-
let { dir, distance: nextDirDistance, crossName } = nextDirInfo;
|
|
340
|
+
let { dir, distance: nextDirDistance, crossName, angle, nextAngle } = nextDirInfo;
|
|
327
341
|
// if (dir === PathDirection.END && nextDirDistance > 15) {
|
|
328
342
|
// // 请直行
|
|
329
343
|
// dir = PathDirection.FRONT;
|
|
@@ -337,6 +351,8 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
337
351
|
curRouteDistance: curRouteRemainDistance,
|
|
338
352
|
nextDirDistance: nextDirDistance,
|
|
339
353
|
dir,
|
|
354
|
+
angle,
|
|
355
|
+
nextAngle,
|
|
340
356
|
pos: this.position,
|
|
341
357
|
routeIndex: this.routeIndex,
|
|
342
358
|
crossName,
|
|
@@ -356,7 +372,8 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
356
372
|
] // 当前吸附后的位置
|
|
357
373
|
, this.routeIndex = 0 // 当前位置所在路线下标
|
|
358
374
|
, this.pointIndex = 0 // 当前位置在当前路线段所在的下标
|
|
359
|
-
, this.paths = [], this.timer = new Timer(), this.resetTimer = null, this.tweenUtil = new TweenUtil(), this.paused = false, this.onAddPaths = (
|
|
375
|
+
, this.paths = [], this.timer = new Timer(), this.resetTimer = null, this.tweenUtil = new TweenUtil(), this.paused = false, this.onAddPaths = (param)=>{
|
|
376
|
+
let { paths } = param;
|
|
360
377
|
this.paths = paths;
|
|
361
378
|
this.resetStatus(paths);
|
|
362
379
|
// this.emitNavigationStatus()
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
+
import "core-js/modules/es.typed-array.uint8-array.js";
|
|
2
|
+
import "core-js/modules/es.typed-array.at.js";
|
|
3
|
+
import "core-js/modules/es.typed-array.fill.js";
|
|
4
|
+
import "core-js/modules/es.typed-array.find-last.js";
|
|
5
|
+
import "core-js/modules/es.typed-array.find-last-index.js";
|
|
6
|
+
import "core-js/modules/es.typed-array.set.js";
|
|
7
|
+
import "core-js/modules/es.typed-array.sort.js";
|
|
8
|
+
import "core-js/modules/es.typed-array.to-reversed.js";
|
|
9
|
+
import "core-js/modules/es.typed-array.to-sorted.js";
|
|
10
|
+
import "core-js/modules/es.typed-array.with.js";
|
|
11
|
+
import "core-js/modules/es.array-buffer.constructor.js";
|
|
12
|
+
import "core-js/modules/es.array-buffer.slice.js";
|
|
13
|
+
import "core-js/modules/es.array-buffer.detached.js";
|
|
14
|
+
import "core-js/modules/es.array-buffer.transfer.js";
|
|
15
|
+
import "core-js/modules/es.array-buffer.transfer-to-fixed-length.js";
|
|
16
|
+
import "core-js/modules/es.typed-array.from.js";
|
|
17
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
1
18
|
import { DataTexture, LinearFilter, RGBAFormat, Sprite, SpriteMaterial } from "three";
|
|
2
19
|
import { Poi2 } from "../../elements";
|
|
3
20
|
export class StartRotateHelperPoi extends Poi2 {
|
|
4
21
|
addDebug() {
|
|
5
|
-
StartRotateHelperPoi.canvas.style.cssText =
|
|
6
|
-
position: fixed;
|
|
7
|
-
top: 0;
|
|
8
|
-
left: 0;
|
|
9
|
-
z-index: 9999;
|
|
10
|
-
`;
|
|
22
|
+
StartRotateHelperPoi.canvas.style.cssText = "\n position: fixed;\n top: 0;\n left: 0;\n z-index: 9999;\n ";
|
|
11
23
|
document.body.appendChild(StartRotateHelperPoi.canvas);
|
|
12
24
|
}
|
|
13
25
|
setAngle(angle) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// import * as math from "mathjs";
|
|
2
|
+
import "core-js/modules/es.array.push.js";
|
|
3
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
2
4
|
export class ImuPosition {
|
|
3
5
|
init() {
|
|
4
6
|
this.fre = 100; // IMU init frequency, dynamic adjust
|
|
@@ -59,15 +61,17 @@ export class ImuPosition {
|
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* Set PDR init pose.
|
|
62
|
-
*/ setInitPose(pose
|
|
63
|
-
0
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
*/ setInitPose(pose) {
|
|
65
|
+
if (pose === void 0) pose = [
|
|
66
|
+
0,
|
|
67
|
+
0
|
|
68
|
+
];
|
|
66
69
|
this.last_px = pose[0];
|
|
67
70
|
this.last_py = pose[1];
|
|
68
|
-
console.info(
|
|
71
|
+
console.info("pdr init pos: " + this.last_px + ", " + this.last_py);
|
|
69
72
|
}
|
|
70
|
-
setInitYaw(yaw
|
|
73
|
+
setInitYaw(yaw) {
|
|
74
|
+
if (yaw === void 0) yaw = 0;
|
|
71
75
|
this.last_yaw = yaw;
|
|
72
76
|
}
|
|
73
77
|
/**
|
|
@@ -168,7 +172,7 @@ export class ImuPosition {
|
|
|
168
172
|
*/ imuFreUpdate() {
|
|
169
173
|
if (this.accH_time_fifo.length > 2) {
|
|
170
174
|
if (this.accH_time_fifo[this.accH_time_fifo.length - 1] - this.accH_time_fifo[this.accH_time_fifo.length - 2] < 0 || this.accH_time_fifo[this.accH_time_fifo.length - 1] - this.accH_time_fifo[this.accH_time_fifo.length - 2] > 10 || this.accH_time_fifo[this.accH_time_fifo.length - 1] === this.accH_time_fifo[0]) {
|
|
171
|
-
console.warn(
|
|
175
|
+
console.warn("pdr reset last one time " + this.accH_time_fifo[this.accH_time_fifo.length - 1] + " last two time " + this.accH_time_fifo[this.accH_time_fifo.length - 2]);
|
|
172
176
|
this.reset();
|
|
173
177
|
}
|
|
174
178
|
}
|
|
@@ -177,10 +181,10 @@ export class ImuPosition {
|
|
|
177
181
|
if (Math.abs(this.fre - new_fre) > 8) {
|
|
178
182
|
this.fre = Math.round((new_fre - 3) / 10.0) * 10; // update imu fre
|
|
179
183
|
if (this.fre <= 10 || this.fre >= 100) {
|
|
180
|
-
console.warn(
|
|
184
|
+
console.warn("Frequency Error " + this.fre);
|
|
181
185
|
this.fre = 100;
|
|
182
186
|
}
|
|
183
|
-
console.debug(
|
|
187
|
+
console.debug("Frequency change to " + this.fre);
|
|
184
188
|
this.accH_fifo_len = Math.floor(1 * this.fre) + 1;
|
|
185
189
|
}
|
|
186
190
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "core-js/modules/es.array.push.js";
|
|
2
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
1
3
|
import { euclideanDist, gaussLikelihood, limitYaw } from "./utils";
|
|
2
4
|
import { reshape, multiply } from 'mathjs';
|
|
3
5
|
class ParticleFilter {
|
|
@@ -182,11 +184,11 @@ class ParticleFilter {
|
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
186
|
initParticlesByCompass(compass) {
|
|
185
|
-
console.log(
|
|
187
|
+
console.log("Init compass: " + compass);
|
|
186
188
|
let yaw_compass = 360 - compass;
|
|
187
189
|
yaw_compass += this.delta_yaw;
|
|
188
190
|
yaw_compass = limitYaw(yaw_compass);
|
|
189
|
-
console.log(
|
|
191
|
+
console.log("Init Yaw: " + yaw_compass);
|
|
190
192
|
for(let index = 0; index < this.NumParticle; index++){
|
|
191
193
|
const yaw_noise = (2 * Math.random() - 1) * this.initial_yaw_uncertainty;
|
|
192
194
|
this.particleX[2][index] = yaw_compass + yaw_noise;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import "core-js/modules/es.array.push.js";
|
|
2
3
|
import { SENSOR_TYPE } from "./enum";
|
|
3
4
|
import { ParticleFilter } from "./particle";
|
|
4
5
|
import { wgs84ToWebMercator, euclideanDist } from "./utils"; // Assuming these exist
|
|
@@ -66,16 +67,16 @@ export class PositioningSystem {
|
|
|
66
67
|
if (gps_pos) {
|
|
67
68
|
this.particleFilter.initParticlesByPos(gps_pos.x, gps_pos.y, ()=>true);
|
|
68
69
|
this.last_pos_time = time;
|
|
69
|
-
console.log(
|
|
70
|
+
console.log("init Pos by gps success time " + time);
|
|
70
71
|
this.cacheSensorData.length = 0;
|
|
71
72
|
} else {
|
|
72
|
-
console.log(
|
|
73
|
+
console.log("init Pos by gps fail time " + time);
|
|
73
74
|
}
|
|
74
75
|
} else if (!this.particleFilter.getYawInitFlag() && data_type === SENSOR_TYPE.COMPASS) {
|
|
75
76
|
const compass = data;
|
|
76
77
|
this.particleFilter.initParticlesByCompass(compass);
|
|
77
78
|
this.particleFilter.setLastCompassTime(time);
|
|
78
|
-
console.log(
|
|
79
|
+
console.log("init yaw by compass success time " + time);
|
|
79
80
|
}
|
|
80
81
|
if (success) {
|
|
81
82
|
this.last_pos_time = time;
|
|
@@ -126,7 +127,7 @@ export class PositioningSystem {
|
|
|
126
127
|
if (type === "gps" ? accuracy && dist > accuracy || dist > this.GpsMaxEstimateErr : dist > this.MaxEstimateErr) {
|
|
127
128
|
this.outTrustRegionNum += 1;
|
|
128
129
|
if (this.outTrustRegionNum >= this.TrustNum) {
|
|
129
|
-
console.info(
|
|
130
|
+
console.info("超出可信区域,重置粒子过滤器到: " + pos.x + ", " + pos.y);
|
|
130
131
|
this.particleFilter.setPosInitFlag(false);
|
|
131
132
|
this.particleFilter.setYawInitFlag(false);
|
|
132
133
|
this.outTrustRegionNum = 0;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
1
2
|
import { EventDispatcher } from "three";
|
|
2
3
|
import { PositioningSystem } from "./pdr";
|
|
3
4
|
import { Sensor } from "./sensor";
|
|
@@ -8,7 +9,8 @@ export class PdrPosition extends EventDispatcher {
|
|
|
8
9
|
}
|
|
9
10
|
start() {
|
|
10
11
|
this.sensor.start();
|
|
11
|
-
this.sensor.addEventListener("add-data-item", (
|
|
12
|
+
this.sensor.addEventListener("add-data-item", (param)=>{
|
|
13
|
+
let { item } = param;
|
|
12
14
|
this.getPositionBySensorItem(item, !this._pause);
|
|
13
15
|
});
|
|
14
16
|
}
|
|
@@ -18,7 +20,8 @@ export class PdrPosition extends EventDispatcher {
|
|
|
18
20
|
continue() {
|
|
19
21
|
this._pause = false;
|
|
20
22
|
}
|
|
21
|
-
getPositionBySensorItem(data, dispatch
|
|
23
|
+
getPositionBySensorItem(data, dispatch) {
|
|
24
|
+
if (dispatch === void 0) dispatch = true;
|
|
22
25
|
const [success, x, y] = this.pdr.pfFusionPDRiBeacon(data);
|
|
23
26
|
if (success && dispatch) {
|
|
24
27
|
this.dispatchEvent({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import "core-js/modules/es.array.push.js";
|
|
3
3
|
import { cloneDeep, isNil, throttle } from "lodash";
|
|
4
4
|
import { isIphone, Timer } from "../../utils";
|
|
5
5
|
import { EventDispatcher } from "three";
|
|
@@ -76,32 +76,27 @@ export class Sensor extends EventDispatcher {
|
|
|
76
76
|
enableHighAccuracy: true
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
checkSensor() {
|
|
80
|
-
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
deviceOrientation
|
|
85
|
-
};
|
|
86
|
-
})();
|
|
79
|
+
async checkSensor() {
|
|
80
|
+
const deviceOrientation = await this.checkDeviceOrientation();
|
|
81
|
+
return {
|
|
82
|
+
deviceOrientation
|
|
83
|
+
};
|
|
87
84
|
}
|
|
88
|
-
checkDeviceOrientation() {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
85
|
+
async checkDeviceOrientation() {
|
|
86
|
+
var _window_DeviceOrientationEvent;
|
|
87
|
+
if (!isIphone) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
if (typeof window.DeviceOrientationEvent !== 'undefined' && typeof ((_window_DeviceOrientationEvent = window.DeviceOrientationEvent) == null ? void 0 : _window_DeviceOrientationEvent.requestPermission) === 'function') {
|
|
91
|
+
try {
|
|
92
|
+
var _window_DeviceOrientationEvent1;
|
|
93
|
+
const permission = await ((_window_DeviceOrientationEvent1 = window.DeviceOrientationEvent) == null ? void 0 : _window_DeviceOrientationEvent1.requestPermission());
|
|
94
|
+
return permission === 'granted';
|
|
95
|
+
} catch (e) {
|
|
96
|
+
return false;
|
|
102
97
|
}
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
105
100
|
}
|
|
106
101
|
stop() {
|
|
107
102
|
window.removeEventListener('devicemotion', this.handleAcceleration, false);
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
3
|
+
import "core-js/modules/es.set.difference.v2.js";
|
|
4
|
+
import "core-js/modules/es.set.intersection.v2.js";
|
|
5
|
+
import "core-js/modules/es.set.is-disjoint-from.v2.js";
|
|
6
|
+
import "core-js/modules/es.set.is-subset-of.v2.js";
|
|
7
|
+
import "core-js/modules/es.set.is-superset-of.v2.js";
|
|
8
|
+
import "core-js/modules/es.set.symmetric-difference.v2.js";
|
|
9
|
+
import "core-js/modules/es.set.union.v2.js";
|
|
10
|
+
import "core-js/modules/es.array.push.js";
|
|
2
11
|
import { Plugin } from "../base";
|
|
3
12
|
import { BoxSelection } from "./box-selection";
|
|
4
13
|
import { isControl, isMac } from "../../utils";
|
|
@@ -126,7 +135,8 @@ export class BMapSelect extends Plugin {
|
|
|
126
135
|
if (isControl(e.key)) {
|
|
127
136
|
this.disableBoxSelection();
|
|
128
137
|
}
|
|
129
|
-
}, this.onBoxSelected = (
|
|
138
|
+
}, this.onBoxSelected = (param)=>{
|
|
139
|
+
let { list } = param;
|
|
130
140
|
this._list.clear();
|
|
131
141
|
this._poiList.clear();
|
|
132
142
|
list.forEach((item)=>{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
1
2
|
import { Box3, Vector3 } from "three";
|
|
2
3
|
import { vector3ToDevice } from "./coordinate";
|
|
3
4
|
import { Floor } from "../elements";
|
|
@@ -61,7 +62,8 @@ export class CameraBound {
|
|
|
61
62
|
* 检测地图是不是在显示范围
|
|
62
63
|
* @param param0
|
|
63
64
|
* @returns
|
|
64
|
-
*/ checkDistanceToScreenEdge(
|
|
65
|
+
*/ checkDistanceToScreenEdge(param) {
|
|
66
|
+
let { left, right, top, bottom } = param;
|
|
65
67
|
const { width, height } = this.context.clientSize;
|
|
66
68
|
const [pt, pr, pb, pl] = this.context.config.cameraBound.padding;
|
|
67
69
|
// 判断右边是不是超出 true 没有超出
|
package/lib/src/utils/color.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import "core-js/modules/es.string.replace.js";
|
|
2
|
+
import "core-js/modules/es.regexp.exec.js";
|
|
3
|
+
import "core-js/modules/es.string.trim.js";
|
|
1
4
|
export function strToNumber(str) {
|
|
2
5
|
return parseInt(str.replace("#", "0x"), 16);
|
|
3
6
|
}
|
|
@@ -16,10 +19,11 @@ export function strToNumber(str) {
|
|
|
16
19
|
let newG = Math.round(g * alpha);
|
|
17
20
|
let newB = Math.round(b * alpha);
|
|
18
21
|
// 将新的RGB数值转换为16进制格式
|
|
19
|
-
let newHexColor =
|
|
22
|
+
let newHexColor = "#" + (1 << 24 | newR << 16 | newG << 8 | newB).toString(16).slice(1);
|
|
20
23
|
return newHexColor;
|
|
21
24
|
}
|
|
22
|
-
export function darkenColor(hexColor, factor
|
|
25
|
+
export function darkenColor(hexColor, factor) {
|
|
26
|
+
if (factor === void 0) factor = 0.85;
|
|
23
27
|
let r;
|
|
24
28
|
let g;
|
|
25
29
|
let b;
|
|
@@ -52,8 +56,8 @@ export function hexToRgb(hex, opacity) {
|
|
|
52
56
|
const b = parseInt(hex.substring(4, 6), 16);
|
|
53
57
|
// 如果提供了opacity,构造RGBA格式
|
|
54
58
|
if (opacity !== undefined) {
|
|
55
|
-
return
|
|
59
|
+
return "rgba(" + r + ", " + g + ", " + b + ", " + opacity + ")";
|
|
56
60
|
}
|
|
57
61
|
// 默认返回RGB格式
|
|
58
|
-
return
|
|
62
|
+
return "rgb(" + r + ", " + g + ", " + b + ")";
|
|
59
63
|
}
|
package/lib/src/utils/create.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BoxGeometry, BufferGeometry, Line, LineBasicMaterial, Mesh } from "three";
|
|
2
|
-
export function createThreeLine(points, color
|
|
2
|
+
export function createThreeLine(points, color) {
|
|
3
|
+
if (color === void 0) color = 0xff0000;
|
|
3
4
|
const material = new LineBasicMaterial({
|
|
4
5
|
color: color
|
|
5
6
|
});
|
|
@@ -7,7 +8,8 @@ export function createThreeLine(points, color = 0xff0000) {
|
|
|
7
8
|
const line = new Line(geometry, material);
|
|
8
9
|
return line;
|
|
9
10
|
}
|
|
10
|
-
export function createThreeBox(pos, color
|
|
11
|
+
export function createThreeBox(pos, color) {
|
|
12
|
+
if (color === void 0) color = 0xff0000;
|
|
11
13
|
const material = new LineBasicMaterial({
|
|
12
14
|
color: color
|
|
13
15
|
});
|
package/lib/src/utils/events.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import "core-js/modules/es.set.difference.v2.js";
|
|
2
|
+
import "core-js/modules/es.set.intersection.v2.js";
|
|
3
|
+
import "core-js/modules/es.set.is-disjoint-from.v2.js";
|
|
4
|
+
import "core-js/modules/es.set.is-subset-of.v2.js";
|
|
5
|
+
import "core-js/modules/es.set.is-superset-of.v2.js";
|
|
6
|
+
import "core-js/modules/es.set.symmetric-difference.v2.js";
|
|
7
|
+
import "core-js/modules/es.set.union.v2.js";
|
|
8
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
1
9
|
const oncePrefix = '__once__';
|
|
2
10
|
export class Events {
|
|
3
11
|
on(type, callback) {
|
|
@@ -12,7 +20,7 @@ export class Events {
|
|
|
12
20
|
}
|
|
13
21
|
once(type, callback) {
|
|
14
22
|
if (typeof callback !== 'function') return undefined;
|
|
15
|
-
const event =
|
|
23
|
+
const event = "" + oncePrefix + type;
|
|
16
24
|
const events = this.events.get(event);
|
|
17
25
|
if (events) {
|
|
18
26
|
return events.add(callback);
|
|
@@ -23,7 +31,7 @@ export class Events {
|
|
|
23
31
|
}
|
|
24
32
|
off(type, callback) {
|
|
25
33
|
const events = this.events.get(type);
|
|
26
|
-
const onceEvents = this.events.get(
|
|
34
|
+
const onceEvents = this.events.get("" + oncePrefix + type);
|
|
27
35
|
if (!events && !onceEvents) {
|
|
28
36
|
return;
|
|
29
37
|
}
|
|
@@ -41,9 +49,12 @@ export class Events {
|
|
|
41
49
|
offAll() {
|
|
42
50
|
this.events.clear();
|
|
43
51
|
}
|
|
44
|
-
emit(type
|
|
52
|
+
emit(type) {
|
|
53
|
+
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
54
|
+
args[_key - 1] = arguments[_key];
|
|
55
|
+
}
|
|
45
56
|
const events = this.events.get(type);
|
|
46
|
-
const onceEvents = this.events.get(
|
|
57
|
+
const onceEvents = this.events.get("" + oncePrefix + type);
|
|
47
58
|
if (!events && !onceEvents) {
|
|
48
59
|
return;
|
|
49
60
|
}
|