@aibee/crc-bmap 0.8.42 → 0.8.44
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 +8 -8
- package/lib/bmap.esm.js +25 -40
- package/lib/bmap.esm.min.js +8 -8
- package/lib/bmap.min.js +8 -8
- package/lib/src/plugins/car-inertial-position/car-inertial-position.d.ts +4 -3
- package/lib/src/plugins/car-inertial-position/car-inertial-position.js +11 -8
- package/lib/src/plugins/car-inertial-position/utils.js +47 -33
- package/package.json +1 -1
package/lib/bmap.esm.js
CHANGED
|
@@ -12798,7 +12798,7 @@ import { isNil as isNil5 } from "lodash";
|
|
|
12798
12798
|
import { EventDispatcher as EventDispatcher19 } from "three";
|
|
12799
12799
|
|
|
12800
12800
|
// ../lib/src/plugins/car-inertial-position/utils.js
|
|
12801
|
-
import {
|
|
12801
|
+
import { Vector2 as Vector218 } from "three";
|
|
12802
12802
|
function linearFit(points) {
|
|
12803
12803
|
const n = points.length;
|
|
12804
12804
|
let sumX = 0, sumY = 0, sumXY = 0, sumX2 = 0;
|
|
@@ -12849,17 +12849,8 @@ function calculateLineDirection(points) {
|
|
|
12849
12849
|
const { start, end } = getLineEndpoints(m, b, filteredPoints);
|
|
12850
12850
|
const radians = new Vector218().subVectors(new Vector218(end[0], end[1]), new Vector218(start[0], start[1])).angle();
|
|
12851
12851
|
const angle = 360 - (radians / Math.PI * 180 - 90 + 360) % 360;
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
if (center2) {
|
|
12855
|
-
geometry.setFromPoints([
|
|
12856
|
-
new Vector326(start[0] - center2[0], start[1] - center2[1], 10),
|
|
12857
|
-
new Vector326(end[0] - center2[0], end[1] - center2[1], 10)
|
|
12858
|
-
]);
|
|
12859
|
-
const line = new Line3(geometry, new LineBasicMaterial3({
|
|
12860
|
-
color: 65535
|
|
12861
|
-
}));
|
|
12862
|
-
window.map.context.scene.add(line);
|
|
12852
|
+
if (Number.isNaN(angle)) {
|
|
12853
|
+
return null;
|
|
12863
12854
|
}
|
|
12864
12855
|
return angle;
|
|
12865
12856
|
}
|
|
@@ -12874,6 +12865,7 @@ function calculateInstantaneousSpeed(positions) {
|
|
|
12874
12865
|
const deltaTime = current.time - prev.time;
|
|
12875
12866
|
if (deltaTime > 0) {
|
|
12876
12867
|
const speed = distance / deltaTime;
|
|
12868
|
+
console.log("speedDelta", prev.type, current.type, transformSpeed(speed), distance, deltaTime);
|
|
12877
12869
|
speeds.push(speed);
|
|
12878
12870
|
} else {
|
|
12879
12871
|
speeds.push(0);
|
|
@@ -12882,23 +12874,14 @@ function calculateInstantaneousSpeed(positions) {
|
|
|
12882
12874
|
return speeds;
|
|
12883
12875
|
}
|
|
12884
12876
|
function predictFutureSpeed(positions, timeIntervalMs) {
|
|
12885
|
-
const
|
|
12886
|
-
const
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
|
|
12890
|
-
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
const speedDifferences = speeds.slice(1).map((speed, index) => speed - speeds[index]);
|
|
12894
|
-
const time = positions.slice(1).reduce((sum, cur, index) => sum + (cur.time - positions[index].time), 0);
|
|
12895
|
-
if (!time) {
|
|
12896
|
-
return 0;
|
|
12897
|
-
}
|
|
12898
|
-
acceleration = speedDifferences.reduce((sum, value) => sum + value, 0) / time;
|
|
12899
|
-
}
|
|
12900
|
-
const futureSpeed = Math.max(currentSpeed + acceleration * timeIntervalMs, 0);
|
|
12901
|
-
return futureSpeed;
|
|
12877
|
+
const first = positions[0];
|
|
12878
|
+
const last = positions.slice(-1)[0];
|
|
12879
|
+
const distance = positions.slice(1).reduce((sum, cur, index) => {
|
|
12880
|
+
const l = getLength(cur.position, positions[index].position);
|
|
12881
|
+
return sum + l;
|
|
12882
|
+
}, 0);
|
|
12883
|
+
const time = last.time - first.time;
|
|
12884
|
+
return distance / time;
|
|
12902
12885
|
}
|
|
12903
12886
|
function transformSpeed(speed) {
|
|
12904
12887
|
return speed * 60 * 60;
|
|
@@ -12910,7 +12893,7 @@ function predictFuturePosition(lastPosition, speed, angle, time) {
|
|
|
12910
12893
|
const vX = Math.cos(angleInRadians);
|
|
12911
12894
|
const vY = Math.sin(angleInRadians);
|
|
12912
12895
|
const dir = new Vector218(vX, vY);
|
|
12913
|
-
vec.add(dir.normalize().multiplyScalar(distance));
|
|
12896
|
+
vec.add(dir.normalize().multiplyScalar(distance + 2));
|
|
12914
12897
|
return [
|
|
12915
12898
|
vec.x,
|
|
12916
12899
|
vec.y
|
|
@@ -13066,13 +13049,14 @@ var CarInertialPosition = class extends EventDispatcher20 {
|
|
|
13066
13049
|
startCompass() {
|
|
13067
13050
|
this.compass.start();
|
|
13068
13051
|
}
|
|
13069
|
-
setPosition(position, time) {
|
|
13052
|
+
setPosition(position, time, duration) {
|
|
13070
13053
|
this.history.push({
|
|
13071
13054
|
position,
|
|
13072
13055
|
time,
|
|
13056
|
+
clientTime: Date.now() - duration,
|
|
13073
13057
|
type: "vision"
|
|
13074
13058
|
});
|
|
13075
|
-
const MAX_DISTANCE =
|
|
13059
|
+
const MAX_DISTANCE = 5;
|
|
13076
13060
|
for (let i = 0; i < this.history.length; i++) {
|
|
13077
13061
|
const item = this.history[i];
|
|
13078
13062
|
const distance = getLength(item.position, position);
|
|
@@ -13083,20 +13067,21 @@ var CarInertialPosition = class extends EventDispatcher20 {
|
|
|
13083
13067
|
break;
|
|
13084
13068
|
}
|
|
13085
13069
|
}
|
|
13086
|
-
const posInfo = this.getPosition();
|
|
13070
|
+
const posInfo = this.getPosition("vision");
|
|
13087
13071
|
this.dispatchEvent({
|
|
13088
13072
|
type: "change-pos",
|
|
13089
13073
|
value: posInfo
|
|
13090
13074
|
});
|
|
13091
13075
|
this.startPositionTimer();
|
|
13092
13076
|
}
|
|
13093
|
-
setBeaconPosition(position, time) {
|
|
13077
|
+
setBeaconPosition(position, time, duration) {
|
|
13094
13078
|
this.history.push({
|
|
13095
13079
|
position,
|
|
13096
13080
|
time,
|
|
13081
|
+
clientTime: Date.now() - duration,
|
|
13097
13082
|
type: "beacon"
|
|
13098
13083
|
});
|
|
13099
|
-
const posInfo = this.getPosition();
|
|
13084
|
+
const posInfo = this.getPosition("beacon");
|
|
13100
13085
|
this.dispatchEvent({
|
|
13101
13086
|
type: "change-pos",
|
|
13102
13087
|
value: posInfo
|
|
@@ -13111,7 +13096,7 @@ var CarInertialPosition = class extends EventDispatcher20 {
|
|
|
13111
13096
|
this.timer.clearTimeout(this.autoCleanTimer);
|
|
13112
13097
|
}
|
|
13113
13098
|
this.positionTimer = this.timer.setInterval(() => {
|
|
13114
|
-
const posInfo = this.getPosition();
|
|
13099
|
+
const posInfo = this.getPosition("pdr");
|
|
13115
13100
|
this.dispatchEvent({
|
|
13116
13101
|
type: "change-pos",
|
|
13117
13102
|
value: posInfo
|
|
@@ -13122,7 +13107,7 @@ var CarInertialPosition = class extends EventDispatcher20 {
|
|
|
13122
13107
|
this.positionTimer = null;
|
|
13123
13108
|
}, 1e3);
|
|
13124
13109
|
}
|
|
13125
|
-
getPosition() {
|
|
13110
|
+
getPosition(from) {
|
|
13126
13111
|
if (this.history.length === 0) {
|
|
13127
13112
|
return {
|
|
13128
13113
|
success: false,
|
|
@@ -13152,7 +13137,7 @@ var CarInertialPosition = class extends EventDispatcher20 {
|
|
|
13152
13137
|
value: angle
|
|
13153
13138
|
});
|
|
13154
13139
|
}
|
|
13155
|
-
const lastTime = lastHistory.
|
|
13140
|
+
const lastTime = lastHistory.clientTime;
|
|
13156
13141
|
const deltaTime = Date.now() - lastTime;
|
|
13157
13142
|
const speed = predictFutureSpeed(this.history, deltaTime);
|
|
13158
13143
|
const pos = this.compassAngle ? predictFuturePosition(lastHistory.position, speed, 360 - this.compassAngle, deltaTime) : lastHistory.position;
|
|
@@ -13339,7 +13324,7 @@ function closeDb(db = _db) {
|
|
|
13339
13324
|
}
|
|
13340
13325
|
|
|
13341
13326
|
// ../lib/src/loader/AibeeLoader/index.js
|
|
13342
|
-
import { Vector3 as
|
|
13327
|
+
import { Vector3 as Vector326, EventDispatcher as EventDispatcher21 } from "three";
|
|
13343
13328
|
|
|
13344
13329
|
// ../lib/src/loader/AibeeLoader/layer.js
|
|
13345
13330
|
function transformLayers(layer, floor) {
|
|
@@ -13811,7 +13796,7 @@ var AibeeLoader = class extends EventDispatcher21 {
|
|
|
13811
13796
|
}
|
|
13812
13797
|
changeFloorBox(data, floor) {
|
|
13813
13798
|
floor.updateBox();
|
|
13814
|
-
const size = floor.box.getSize(new
|
|
13799
|
+
const size = floor.box.getSize(new Vector326());
|
|
13815
13800
|
const max = Math.max(size.x, size.y, size.z);
|
|
13816
13801
|
floor.userData.height = max / 4 + data.floorHeight;
|
|
13817
13802
|
}
|