@aibee/crc-bmap 0.1.2 → 0.1.3

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.
@@ -2,3 +2,4 @@ export * from "./equipment";
2
2
  export * from "./navigation";
3
3
  export * from './mul-floors';
4
4
  export * from './nav-path';
5
+ export * from './select';
@@ -1,5 +1,5 @@
1
1
  import { EventDispatcher } from "three";
2
- import { End, PathData, PathDirection, RouteType, Start } from "../../utils";
2
+ import { End2, PathData, PathDirection, RouteType2, Start2 } from "../../utils";
3
3
  import { Facility, RoadData2 } from "../../utils/road2";
4
4
  interface EventMap {
5
5
  "init-road-status": {
@@ -16,7 +16,7 @@ export declare class NavPath extends EventDispatcher<EventMap> {
16
16
  initRoadStatus: boolean;
17
17
  constructor();
18
18
  setRoadData(roadData: RoadData2[], facilities: Facility[]): Promise<void>;
19
- getPath(start: Start, end: End, type?: RouteType): Promise<PathData>;
19
+ getPath(start: Start2, end: End2, type?: RouteType2): Promise<PathData>;
20
20
  getDirectionPath(points: [number, number][]): Promise<DirectionPathData[]>;
21
21
  dispose(): Promise<void>;
22
22
  }
@@ -1,10 +1,16 @@
1
1
  import { BMap } from "../../bmap";
2
2
  import { Plugin } from "../base";
3
3
  import { Path, PathConfig } from "./path";
4
- import { PathData, RoadData } from "../../utils";
4
+ import { PathData2, TweenUtil } from "../../utils";
5
5
  import { Floor, Poi2, PoiOptions2 } from "../../elements";
6
- import { Group as TweenGroup } from "@tweenjs/tween.js";
6
+ import { PathDirection } from "../../utils/path";
7
+ import { Tween } from "@tweenjs/tween.js";
7
8
  export type Point = [number, number];
9
+ export interface NavigationProcessInfo {
10
+ distance: number;
11
+ dir: PathDirection;
12
+ nextDirDistance: number;
13
+ }
8
14
  interface EventMap {
9
15
  "fetch-road-status": {
10
16
  status: boolean;
@@ -13,42 +19,55 @@ interface EventMap {
13
19
  pathIndex: number;
14
20
  };
15
21
  "path-animation-end": {};
16
- "fetch-road-data": {
17
- roadInfo: RoadData[];
22
+ "render-path": {
23
+ path: Path;
18
24
  };
25
+ "navigation-info": NavigationProcessInfo;
19
26
  }
20
27
  export interface NavigationConfig {
21
28
  path?: Partial<PathConfig>;
22
- speed: number;
23
29
  cheapMaximumDistance: number;
24
30
  startPoi: Partial<PoiOptions2>;
25
31
  needStartPoi: boolean;
26
32
  offsetY: number;
33
+ directionEmitThreshold: number;
34
+ disablePathAnimation: boolean;
27
35
  }
28
36
  export declare class Navigation extends Plugin<EventMap> {
29
37
  path: Path | null;
30
38
  fetchRoadStatus: boolean;
31
- paths: PathData;
39
+ paths: PathData2;
40
+ curPathIndex: number;
41
+ curFloorPath: PathData2[0] | null;
42
+ translatePath: PathData2[0]["points"] | null;
43
+ currentPathPosition: [number, number] | null;
32
44
  options: NavigationConfig;
33
- pathTween: TweenGroup;
45
+ pathTween: Tween<any> | null;
34
46
  startPoi: Poi2 | null;
35
47
  movedDistance: number;
36
48
  pathStart: [number, number];
49
+ tweenUtil: TweenUtil;
37
50
  animationPathOptions: {
38
51
  cPathIndex: number;
39
52
  };
40
53
  cPath: Point[];
41
- constructor(bmap: BMap, project: string, options?: Partial<NavigationConfig>);
54
+ constructor(bmap: BMap, project?: string | Partial<NavigationConfig>, options?: Partial<NavigationConfig>);
55
+ get curFloorPathLength(): number;
56
+ get curFloorPathPoints(): [number, number][];
42
57
  registryEvent(): void;
58
+ pauseAnimation(): void;
59
+ continueAnimation(): void;
43
60
  unRegistryEvent(): void;
44
61
  onUpdate: () => void;
45
62
  clearPath(): void;
63
+ private setCurFloorPath;
64
+ setCurPathIndex(index: number): void;
46
65
  onSwitchFloor: ({ data: { curFloor } }: {
47
66
  data: {
48
67
  curFloor: Floor;
49
68
  };
50
69
  }) => void;
51
- addPath(paths: PathData): void;
70
+ addPath(paths: PathData2, routeIndex?: number): void;
52
71
  translatePoints(points: Point[]): Point[];
53
72
  renderPath(points: Point[]): void;
54
73
  catmullRomCurve3(points: Point[]): [number, number][];
@@ -60,12 +79,23 @@ export declare class Navigation extends Plugin<EventMap> {
60
79
  animationTo(point: {
61
80
  floor: string;
62
81
  pos: [number, number];
63
- }, speed?: number): Promise<unknown>;
82
+ }, speed: number): Promise<unknown>;
64
83
  getPathDirection(): number | null;
65
84
  changeCameraToPathUp(duration?: number): Promise<unknown>;
66
85
  initNavigationCamera(): Promise<void>;
67
86
  translateCameraToStartPoi(duration?: number): Promise<unknown>;
68
87
  initCameraZoom(duration?: number): Promise<unknown>;
88
+ toPositionBySpeed(position: [number, number], speed: number): Promise<unknown>;
89
+ adsorb(position: [number, number]): {
90
+ distance: number;
91
+ closestPoint: [number, number];
92
+ } | null;
93
+ getRemainDistance(): number;
94
+ getNextDirDistance(): {
95
+ dir: PathDirection;
96
+ distance: number;
97
+ } | null;
98
+ private emitNavigationInfo;
69
99
  dispose(): void;
70
100
  }
71
101
  export {};
@@ -15,7 +15,6 @@ export declare class Path extends Object3D {
15
15
  texture: Texture | null;
16
16
  config: PathConfig;
17
17
  points: [number, number][];
18
- pathDistance: number;
19
18
  basicRepeat: number;
20
19
  prevCameraZoom: number;
21
20
  constructor(navigation: Navigation, config?: Partial<PathConfig>);
@@ -28,7 +27,7 @@ export declare class Path extends Object3D {
28
27
  loadTexture(url: string): Promise<Texture>;
29
28
  transformPoints(points: [number, number][]): number[];
30
29
  updatePoints(points: [number, number][]): void;
31
- movePath(distance: number): void;
30
+ movePath(ratio: number): void;
32
31
  create(points: [number, number][]): Promise<Mesh<any, any, import("three").Object3DEventMap>>;
33
32
  dispose(): void;
34
33
  }
@@ -0,0 +1,2 @@
1
+ export * from './sensor';
2
+ export * from './position';
File without changes
File without changes
@@ -0,0 +1,11 @@
1
+ import { Sensor, SensorOptions } from "./sensor";
2
+ export interface PdrPositionOptions {
3
+ sensor?: Partial<SensorOptions>;
4
+ }
5
+ export declare class PdrPosition {
6
+ sensor: Sensor;
7
+ constructor(options?: PdrPositionOptions);
8
+ checkSensor(): Promise<{
9
+ deviceOrientation: boolean;
10
+ }>;
11
+ }
@@ -0,0 +1,59 @@
1
+ import { Timer } from "../../utils";
2
+ import { EventDispatcher } from "three";
3
+ interface SensorEventMap {
4
+ "start": {};
5
+ "stop": {};
6
+ "sensor-data": {
7
+ data: SensorData[];
8
+ };
9
+ }
10
+ interface DeviceMotionData {
11
+ type: "deviceMotion";
12
+ timestamp: number;
13
+ res: [number, number, number];
14
+ }
15
+ interface AccelerationData {
16
+ type: "accelerometer";
17
+ timestamp: number;
18
+ res: [number, number, number];
19
+ }
20
+ interface GpsData {
21
+ type: "gps";
22
+ timestamp: number;
23
+ res: [number, number, number];
24
+ }
25
+ interface CompassData {
26
+ type: "compass";
27
+ timestamp: number;
28
+ res: number;
29
+ }
30
+ type SensorData = DeviceMotionData | AccelerationData | GpsData | CompassData;
31
+ export interface SensorOptions {
32
+ time: number;
33
+ elements: ("compass" | "deviceMotion" | "acceleration" | "gps")[];
34
+ }
35
+ export declare class Sensor extends EventDispatcher<SensorEventMap> {
36
+ options: SensorOptions;
37
+ gpsTimer: null | number;
38
+ data: SensorData[];
39
+ timer: Timer;
40
+ dispatchTimer: number | null;
41
+ constructor(options?: Partial<SensorOptions>);
42
+ start(): void;
43
+ addDeviceMotion: import("lodash").DebouncedFunc<(data: DeviceMotionData) => void>;
44
+ addAcceleration: import("lodash").DebouncedFunc<(data: AccelerationData) => void>;
45
+ deviceOrientationAbsHandler: (e: DeviceOrientationEvent) => void;
46
+ /**
47
+ * 获取 compass 和 deviceMotion
48
+ */
49
+ listenDeviceOrientation(): void;
50
+ handleAcceleration: (e: DeviceMotionEvent) => void;
51
+ listenAcceleration(): void;
52
+ listenGps(): void;
53
+ checkSensor(): Promise<{
54
+ deviceOrientation: boolean;
55
+ }>;
56
+ checkDeviceOrientation(): Promise<boolean>;
57
+ stop(): void;
58
+ }
59
+ export {};
@@ -0,0 +1,39 @@
1
+ import { Context } from "../../context/context";
2
+ import { BaseSvg, Graphic } from "../../elements";
3
+ import { Frustum, Vector3 } from "three";
4
+ interface BoxSelectionEventMap {
5
+ "selected": {
6
+ list: Graphic[];
7
+ };
8
+ }
9
+ export declare class BoxSelection extends BaseSvg<BoxSelectionEventMap> {
10
+ startPoint?: Vector3;
11
+ endPoint?: Vector3;
12
+ rect: SVGElement;
13
+ frustum: Frustum;
14
+ constructor(context: Context);
15
+ setEnable(enable: boolean): void;
16
+ onPointerDown: (e: PointerEvent) => void;
17
+ onPointerMove: (e: PointerEvent) => void;
18
+ onPointerUp: (e: PointerEvent) => void;
19
+ onUpdate: () => void;
20
+ registryEvent(): void;
21
+ unRegistryEvent(): void;
22
+ doSelect(): void;
23
+ searchMapInFrustum(leftTop: {
24
+ x: number;
25
+ y: number;
26
+ }, rightBottom: {
27
+ x: number;
28
+ y: number;
29
+ }): Graphic[];
30
+ searchChildInFrustum(object: Graphic, leftTop: {
31
+ x: number;
32
+ y: number;
33
+ }, rightBottom: {
34
+ x: number;
35
+ y: number;
36
+ }): boolean;
37
+ dispose(): void;
38
+ }
39
+ export {};
@@ -0,0 +1 @@
1
+ export * from './select';
@@ -0,0 +1,47 @@
1
+ import { Graphic, Poi, Poi2 } from "../../elements";
2
+ import { BMap } from "../../bmap";
3
+ import { Plugin } from "../base";
4
+ import { BoxSelection } from "./box-selection";
5
+ export interface BMapSelectOptions {
6
+ boxSelection: boolean;
7
+ elements: ("graphic" | "poi")[];
8
+ }
9
+ interface SelectionEventMap {
10
+ "select": {
11
+ graphics: Graphic[];
12
+ pois: (Poi | Poi2)[];
13
+ isMultipleSelect: boolean;
14
+ };
15
+ }
16
+ export declare class BMapSelect extends Plugin<SelectionEventMap> {
17
+ options: BMapSelectOptions;
18
+ _list: Set<Graphic>;
19
+ _poiList: Set<Poi | Poi2>;
20
+ boxSelection: BoxSelection;
21
+ prevPanStatus?: boolean;
22
+ prevRotateStatus?: boolean;
23
+ downPoint: {
24
+ x: number;
25
+ y: number;
26
+ } | null;
27
+ isMultipleSelect: boolean;
28
+ constructor(bmap: BMap, options?: Partial<BMapSelectOptions>);
29
+ get list(): Set<Graphic>;
30
+ enableBoxSelection(): void;
31
+ disableBoxSelection(): void;
32
+ onPointerDown: (e: PointerEvent) => void;
33
+ onPointerUp: (e: PointerEvent) => void;
34
+ onPointerOut: (e: PointerEvent) => void;
35
+ onKeyDown: (e: KeyboardEvent) => void;
36
+ onKeyUp: (e: KeyboardEvent) => void;
37
+ onBoxSelected: ({ list }: {
38
+ list: Graphic[];
39
+ }) => void;
40
+ selectEnd(): void;
41
+ registryEvent(): void;
42
+ unRegistryEvent(): void;
43
+ clear(): void;
44
+ remove(graphic: Graphic): void;
45
+ dispose(): void;
46
+ }
47
+ export {};
@@ -1,2 +1,3 @@
1
- import { BufferGeometry, Line, LineBasicMaterial, Vector3 } from "three";
1
+ import { BoxGeometry, BufferGeometry, Line, LineBasicMaterial, Mesh, Vector3 } from "three";
2
2
  export declare function createThreeLine(points: Vector3[], color?: number): Line<BufferGeometry<import("three").NormalBufferAttributes>, LineBasicMaterial>;
3
+ export declare function createThreeBox(pos: Vector3, color?: number): Mesh<BoxGeometry, LineBasicMaterial, import("three").Object3DEventMap>;
@@ -21,3 +21,4 @@ export * from './webworker';
21
21
  export * from './string';
22
22
  export * from './create';
23
23
  export * from './translate';
24
+ export * from './tween';
@@ -1 +1,4 @@
1
1
  export declare const isMac: boolean;
2
+ export declare const UA: string;
3
+ export declare const isIphone: boolean;
4
+ export declare const isAndroid: boolean;
@@ -62,3 +62,5 @@ export declare function getDirectPath(points: [number, number][]): {
62
62
  distance: number;
63
63
  points: [number, number][];
64
64
  }[];
65
+ export declare function getDistanceByPathPos(path: [number, number][], pos: [number, number]): number;
66
+ export declare function getPosByPathDistance(path: [number, number][], distance: number): [number, number] | null;
@@ -0,0 +1,16 @@
1
+ import { Tween, Group } from '@tweenjs/tween.js';
2
+ export declare class TweenUtil {
3
+ pauseTween: boolean;
4
+ tweenStore: Set<Tween<any>>;
5
+ group: Group;
6
+ constructor();
7
+ update(): void;
8
+ pause(): void;
9
+ continue(): void;
10
+ remove(tween: Tween<any>): void;
11
+ getAll(): Tween<{
12
+ [x: string]: any;
13
+ }>[];
14
+ clear(): void;
15
+ dispose(): void;
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibee/crc-bmap",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "",
5
5
  "main": "lib/bmap.min.js",
6
6
  "module": "lib/bmap.esm.js",