@aibee/crc-bmap 0.14.34 → 0.14.36

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.
@@ -66,6 +66,10 @@ export interface Config {
66
66
  };
67
67
  poi: {
68
68
  boxScale: number;
69
+ /** 是否把 POI 文字合并成少量 InstancedMesh 绘制(默认开启) */
70
+ batchText: boolean;
71
+ /** 是否把相同贴图的 POI 图标合并成 InstancedMesh 绘制(默认开启) */
72
+ batchIcon: boolean;
69
73
  };
70
74
  loaderPlaceConfig: {
71
75
  textFontSize: number;
@@ -75,7 +79,17 @@ export interface Config {
75
79
  color: string;
76
80
  opacity: number;
77
81
  };
82
+ /** POI 文字默认字体族(CSS font-family),POI 未单独指定 text_font_family 时生效 */
83
+ poiTextFontFamily: string;
78
84
  renderAnimation: 'setTimeout' | 'requestAnimationFrame';
85
+ /**
86
+ * 渲染器参数。iOS 默认关闭 antialias、限制 DPR,避免高 DPR + MSAA 的帧缓冲峰值。
87
+ * antialias 不传时由 Renderer 按设备自动选择。
88
+ */
89
+ renderer: {
90
+ antialias?: boolean;
91
+ maxPixelRatio: number;
92
+ };
79
93
  }
80
94
  export declare const defaultConfig: Config;
81
95
  export type DeepPartial<T> = {
@@ -14,8 +14,10 @@ export declare class Renderer extends WebGLRenderer {
14
14
  enable: boolean;
15
15
  timer: Timer;
16
16
  constructor(context: Context, options?: WebGLRendererParameters & {
17
- backgroundColor: string | number;
17
+ backgroundColor?: string | number;
18
18
  });
19
+ onContextLost: (event: Event) => void;
20
+ onContextRestored: () => void;
19
21
  setCameraAndScene(scene: ContextScene, camera: ContextCamera): void;
20
22
  autoRender(): void;
21
23
  pauseRender(): void;
@@ -1,6 +1,8 @@
1
1
  import { Context } from "../context/context";
2
2
  import { Box2, DataTexture, Mesh, Object3D, Object3DEventMap, ShaderMaterial, Sprite, Vector3 } from "three";
3
3
  import type { TextLayoutResult } from "../utils/text-layout";
4
+ import type { PoiTextBatch } from "../layer/poi-text-batch";
5
+ import type { PoiIconBatch } from "../layer/poi-icon-batch";
4
6
  export interface PoiOptions2 {
5
7
  text: string;
6
8
  icon: string;
@@ -17,6 +19,8 @@ export interface PoiOptions2 {
17
19
  text_font_size: number;
18
20
  /** 文字字重:400(常规)/'bold'、700(加粗)。不同字重使用独立的 SDF 图集 */
19
21
  text_font_weight: string | number;
22
+ /** 文字字体族(CSS font-family)。不同字体使用独立的 SDF 图集 */
23
+ text_font_family: string;
20
24
  /** 文字描边宽度,单位 CSS 像素(0 表示不描边) */
21
25
  text_outline_width: number;
22
26
  icon_rotate: number;
@@ -62,6 +66,14 @@ export declare class Poi2 extends Object3D<PoiEventMap2> {
62
66
  private _shouldShow;
63
67
  /** 文字布局结果(按 textTextureKey 缓存) */
64
68
  textLayoutMap: Record<string, TextLayoutResult>;
69
+ /** 所属 PoiLayer2 的文字合批器;为空时保持旧的逐 POI Mesh 渲染 */
70
+ textBatch: PoiTextBatch | null;
71
+ /** 合批模式下是否已经注册过文字 */
72
+ batchTextReady: boolean;
73
+ /** 所属 PoiLayer2 的图标合批器 */
74
+ iconBatch: PoiIconBatch | null;
75
+ /** 合批模式下是否已经注册过图标 */
76
+ batchIconReady: boolean;
65
77
  textTextureRectMap: Record<string, {
66
78
  width: number;
67
79
  height: number;
@@ -69,11 +81,15 @@ export declare class Poi2 extends Object3D<PoiEventMap2> {
69
81
  aspect: number;
70
82
  }>;
71
83
  constructor(context: Context, options: PoiOptionsParam2);
72
- /** 当前文字使用的 SDF 字体规格:字重不同即对应不同图集 */
84
+ /** 当前文字使用的 SDF 字体规格:字重/字体族不同即对应不同图集 */
73
85
  get sdfFontSpec(): import("../factory").SdfFontSpec;
74
86
  get textTexture(): DataTexture | null;
75
87
  /** 当前文字渲染对象 */
76
88
  get textObject(): Mesh | undefined;
89
+ /** 合批使用的垂直 pivot(与旧 Sprite.center.y 语义一致) */
90
+ get textPivotY(): number;
91
+ /** 导航起点/终点辅助 POI 会逐帧移动,不适合放进静态合批 */
92
+ get isMovingBatchPoi(): boolean;
77
93
  /** 当前文字材质列表(字形分布在多张图集页时,每页对应一个材质) */
78
94
  get textMaterials(): ShaderMaterial[];
79
95
  /** 合并各图集页的几何;只有一页时直接复用,避免无谓开销 */
@@ -150,6 +166,8 @@ export declare class Poi2 extends Object3D<PoiEventMap2> {
150
166
  setVisible(visible: boolean): void;
151
167
  parentSetVisible(visible: boolean): void;
152
168
  clearTextTextureCache(): void;
169
+ private resetBatchText;
170
+ private resetBatchIcon;
153
171
  dispose(): void;
154
172
  }
155
173
  export {};
@@ -86,6 +86,8 @@ export declare class SdfTextFactory {
86
86
  static getAtlasSize(): number;
87
87
  /** 获取(必要时创建)某个字体规格对应的共享图集 */
88
88
  static getAtlas(partial?: Partial<SdfFontSpec>): SdfAtlas;
89
+ /** 按字体 key 取已存在的图集(合批用,不主动创建) */
90
+ static getAtlasByKey(key: string): SdfAtlas | undefined;
89
91
  /** 图集第一页纹理(单页场景的常用入口) */
90
92
  static getTexture(partial?: Partial<SdfFontSpec>): DataTexture;
91
93
  /** 该字体规格的全部图集页纹理(多页时按字形所属页取用) */
@@ -97,6 +99,8 @@ export declare class SdfTextFactory {
97
99
  */
98
100
  static ensureText(text: string, partial?: Partial<SdfFontSpec>): Promise<SdfAtlas>;
99
101
  private static createAtlas;
102
+ /** 按需创建/获取指定页(当前只按顺序追加) */
103
+ private static ensurePage;
100
104
  /** 新建一张图集页(独立的缓冲与纹理) */
101
105
  private static createPage;
102
106
  private static generateMissing;
@@ -104,7 +108,7 @@ export declare class SdfTextFactory {
104
108
  private static insertGlyph;
105
109
  /** 判断某页还能否放下指定尺寸的字形(shelf packing 规则) */
106
110
  private static pageCanFit;
107
- /** 选择可容纳该字形的图集页;所有页都放不下时新建一页 */
111
+ /** 选择可容纳该字形的图集页;预算用尽后允许少量溢出页,优先保证文字完整 */
108
112
  private static pickPage;
109
113
  private static generate;
110
114
  private static getWorker;
@@ -0,0 +1,34 @@
1
+ import { Object3D, Texture } from "three";
2
+ import { Context } from "../context/context";
3
+ export declare class PoiIconBatch extends Object3D {
4
+ private context;
5
+ private items;
6
+ private buckets;
7
+ private materials;
8
+ private rebuildRaf;
9
+ private rebuildScheduled;
10
+ constructor(context: Context);
11
+ addPoi(poi: any, texture: Texture, options: {
12
+ size: [number, number];
13
+ offsetY: number;
14
+ rotation: number;
15
+ opacity: number;
16
+ depthTest: boolean;
17
+ alphaTest: number;
18
+ }): void;
19
+ removePoi(poi: any): void;
20
+ setVisible(poi: any, visible: boolean): void;
21
+ setOpacity(poi: any, opacity: number): void;
22
+ setRotation(poi: any, rotation: number): void;
23
+ setSize(poi: any, size: [number, number]): void;
24
+ setOffsetY(poi: any, offsetY: number): void;
25
+ setDepthTest(poi: any, depthTest: boolean): void;
26
+ dispose(): void;
27
+ private onZoomChange;
28
+ private writeOpacity;
29
+ private writeTransform;
30
+ private scheduleRebuild;
31
+ private clearBuckets;
32
+ private rebuild;
33
+ private getMaterial;
34
+ }
@@ -2,9 +2,13 @@ import { Poi2, PoiOptionsParam2 } from "../elements";
2
2
  import { Layer } from "./layer";
3
3
  import { Context } from "../context/context";
4
4
  import { Timer } from "../utils";
5
+ import { PoiTextBatch } from "./poi-text-batch";
6
+ import { PoiIconBatch } from "./poi-icon-batch";
5
7
  export declare class PoiLayer2 extends Layer {
6
8
  pois: Poi2[];
7
9
  timer: Timer;
10
+ textBatch: PoiTextBatch | null;
11
+ iconBatch: PoiIconBatch | null;
8
12
  constructor(context: Context);
9
13
  clear(): this;
10
14
  createPoi(options: PoiOptionsParam2): Poi2;
@@ -0,0 +1,31 @@
1
+ import { Object3D } from "three";
2
+ import { Context } from "../context/context";
3
+ import type { TextLayoutResult } from "../utils/text-layout";
4
+ /**
5
+ * 文字合批只接管 POI 文字;图标/背景仍走各自的对象,
6
+ * 这样不改动碰撞、拾取和 icon 的既有逻辑。
7
+ */
8
+ export declare class PoiTextBatch extends Object3D {
9
+ private context;
10
+ private items;
11
+ private buckets;
12
+ private materials;
13
+ private rebuildRaf;
14
+ private rebuildScheduled;
15
+ constructor(context: Context);
16
+ addPoi(poi: any, layout: TextLayoutResult): void;
17
+ removePoi(poi: any): void;
18
+ refresh(poi: any, layout: TextLayoutResult): void;
19
+ setVisible(poi: any, visible: boolean): void;
20
+ setOpacity(poi: any, opacity: number): void;
21
+ setDepthTest(poi: any, depthTest: boolean): void;
22
+ setOutlineWidth(poi: any, outlineWidth: number): void;
23
+ dispose(): void;
24
+ private get pixelRatio();
25
+ private onZoomChange;
26
+ private writeOpacity;
27
+ private scheduleRebuild;
28
+ private clearBuckets;
29
+ private rebuild;
30
+ private getMaterial;
31
+ }
@@ -62,23 +62,37 @@ export declare class AibeeLoader extends EventDispatcher<AibeeLoaderEventMap> {
62
62
  bmap: BMap;
63
63
  floors: AibeeFloorInfo[];
64
64
  initDbPromise: Promise<void>;
65
+ /** 全场预热的完成信号;需要确保缓存已就绪时可 await 它 */
66
+ preloadPromise: Promise<void>;
65
67
  db: IDBDatabase | null;
66
68
  taskQueue: TaskQueue;
67
69
  loadWorker: Worker;
68
70
  options: AibeeLoaderOptions;
69
71
  locale: Locale;
70
72
  placeConfig: PlaceConfig;
73
+ /** 只缓存在途的楼层请求;请求完成并写入 IndexedDB 后会被清理,不常驻整层数据 */
71
74
  getFloorDataPromise: Map<string, Promise<AibeeFloorData>>;
72
75
  constructor(bmap: BMap, options?: Partial<AibeeLoaderOptions>);
73
76
  initDb(): Promise<void>;
74
77
  load(data: number | string | AibeeFloorInfo[], placeConfig?: Partial<PlaceConfig>): Promise<void>;
78
+ waitForPreload(): Promise<void>;
75
79
  setCacheData(storeName: string, key: string | number, data: any): Promise<unknown>;
76
80
  getCacheData<T>(storeName: string, key: string | number): Promise<T>;
81
+ /**
82
+ * 刚写入 IndexedDB 的数据,在 Safari/WKWebView 下可能因为事务提交时序短暂读不到。
83
+ * 这里做一次轻量重试;正常命中时没有额外开销。
84
+ */
85
+ private getCacheDataWithRetry;
77
86
  getFloorData(floor: string): Promise<Floor | null>;
78
87
  getFloorDataByFloorInfo(floorInfo: AibeeFloorInfo): Promise<Floor>;
79
88
  setLocale(locale: Locale): void;
89
+ /**
90
+ * 读取顺序:IndexedDB → 正在进行的 Promise → 网络请求。
91
+ * 这个方法只负责前两步,不会触发网络。
92
+ */
93
+ private readFloorFromCache;
80
94
  getFloorJsonDataByFloorInfo(floorInfo: AibeeFloorInfo): Promise<AibeeFloorData>;
81
- getFloorJsonData(floor: string): Promise<AibeeFloorData | null>;
95
+ getFloorJsonData(floor: string, retry?: boolean): Promise<AibeeFloorData | null>;
82
96
  getRoadNetworkData(): Promise<RoadData2[]>;
83
97
  getFacilitiesData(): Promise<{
84
98
  infrastructures: any[];
@@ -2,3 +2,5 @@ export declare const isMac: boolean;
2
2
  export declare const UA: string;
3
3
  export declare const isIphone: boolean;
4
4
  export declare const isAndroid: boolean;
5
+ /** iPadOS 13+ 的 UA 伪装成 Mac,需要结合 touch points 判断 */
6
+ export declare const isIOS: boolean;