@aibee/crc-bmap 0.14.30 → 0.14.32

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/meta.json CHANGED
@@ -273,15 +273,15 @@
273
273
  "format": "esm"
274
274
  },
275
275
  "../lib/src/utils/text-layout.js": {
276
- "bytes": 8986,
276
+ "bytes": 11045,
277
277
  "imports": [
278
278
  {
279
- "path": "core-js/modules/es.array.push.js",
279
+ "path": "core-js/modules/es.regexp.exec.js",
280
280
  "kind": "import-statement",
281
281
  "external": true
282
282
  },
283
283
  {
284
- "path": "core-js/modules/es.regexp.exec.js",
284
+ "path": "core-js/modules/es.array.push.js",
285
285
  "kind": "import-statement",
286
286
  "external": true
287
287
  },
@@ -1111,7 +1111,7 @@
1111
1111
  "format": "esm"
1112
1112
  },
1113
1113
  "../lib/src/factory/material.js": {
1114
- "bytes": 18099,
1114
+ "bytes": 17404,
1115
1115
  "imports": [
1116
1116
  {
1117
1117
  "path": "core-js/modules/web.dom-collections.iterator.js",
@@ -1153,7 +1153,7 @@
1153
1153
  "format": "esm"
1154
1154
  },
1155
1155
  "../lib/src/factory/sdf-text.js": {
1156
- "bytes": 17640,
1156
+ "bytes": 17858,
1157
1157
  "imports": [
1158
1158
  {
1159
1159
  "path": "../../../node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_extends.js",
@@ -1762,7 +1762,7 @@
1762
1762
  "format": "esm"
1763
1763
  },
1764
1764
  "../lib/src/elements/graphic.js": {
1765
- "bytes": 17324,
1765
+ "bytes": 18300,
1766
1766
  "imports": [
1767
1767
  {
1768
1768
  "path": "../../../node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_extends.js",
@@ -2103,7 +2103,7 @@
2103
2103
  "format": "esm"
2104
2104
  },
2105
2105
  "../src/factory/material.ts": {
2106
- "bytes": 18157,
2106
+ "bytes": 17779,
2107
2107
  "imports": [
2108
2108
  {
2109
2109
  "path": "three/examples/jsm/lines/LineMaterial.js",
@@ -2193,7 +2193,7 @@
2193
2193
  "format": "esm"
2194
2194
  },
2195
2195
  "../src/factory/sdf-text.ts": {
2196
- "bytes": 18116,
2196
+ "bytes": 18715,
2197
2197
  "imports": [
2198
2198
  {
2199
2199
  "path": "three",
@@ -2382,7 +2382,7 @@
2382
2382
  "format": "esm"
2383
2383
  },
2384
2384
  "../src/utils/text-layout.ts": {
2385
- "bytes": 8784,
2385
+ "bytes": 11298,
2386
2386
  "imports": [
2387
2387
  {
2388
2388
  "path": "three",
@@ -3193,7 +3193,7 @@
3193
3193
  "format": "esm"
3194
3194
  },
3195
3195
  "../lib/src/elements/poi2.js": {
3196
- "bytes": 24968,
3196
+ "bytes": 25509,
3197
3197
  "imports": [
3198
3198
  {
3199
3199
  "path": "../../../node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_extends.js",
@@ -3625,7 +3625,7 @@
3625
3625
  "format": "esm"
3626
3626
  },
3627
3627
  "../lib/src/elements/text-texture.js": {
3628
- "bytes": 5425,
3628
+ "bytes": 5644,
3629
3629
  "imports": [
3630
3630
  {
3631
3631
  "path": "../../../node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_extends.js",
@@ -7194,12 +7194,12 @@
7194
7194
  "external": true
7195
7195
  },
7196
7196
  {
7197
- "path": "core-js/modules/es.array.push.js",
7197
+ "path": "core-js/modules/es.regexp.exec.js",
7198
7198
  "kind": "import-statement",
7199
7199
  "external": true
7200
7200
  },
7201
7201
  {
7202
- "path": "core-js/modules/es.regexp.exec.js",
7202
+ "path": "core-js/modules/es.array.push.js",
7203
7203
  "kind": "import-statement",
7204
7204
  "external": true
7205
7205
  },
@@ -9848,10 +9848,10 @@
9848
9848
  "bytesInOutput": 208
9849
9849
  },
9850
9850
  "../lib/src/bmap.js": {
9851
- "bytesInOutput": 11142
9851
+ "bytesInOutput": 11143
9852
9852
  },
9853
9853
  "../lib/src/context/context.js": {
9854
- "bytesInOutput": 9421
9854
+ "bytesInOutput": 9410
9855
9855
  },
9856
9856
  "../lib/src/utils/timer.js": {
9857
9857
  "bytesInOutput": 1783
@@ -9899,7 +9899,7 @@
9899
9899
  "bytesInOutput": 196
9900
9900
  },
9901
9901
  "../lib/src/utils/text-layout.js": {
9902
- "bytesInOutput": 2623
9902
+ "bytesInOutput": 2962
9903
9903
  },
9904
9904
  "../lib/src/utils/string.js": {
9905
9905
  "bytesInOutput": 423
@@ -9941,7 +9941,7 @@
9941
9941
  "bytesInOutput": 829
9942
9942
  },
9943
9943
  "../lib/src/utils/event-dispatcher.js": {
9944
- "bytesInOutput": 95
9944
+ "bytesInOutput": 96
9945
9945
  },
9946
9946
  "../lib/src/utils/kalman-filter.js": {
9947
9947
  "bytesInOutput": 405
@@ -9956,13 +9956,13 @@
9956
9956
  "bytesInOutput": 3434
9957
9957
  },
9958
9958
  "../lib/src/elements/graphic.js": {
9959
- "bytesInOutput": 7531
9959
+ "bytesInOutput": 7516
9960
9960
  },
9961
9961
  "../lib/src/factory/material.js": {
9962
- "bytesInOutput": 14229
9962
+ "bytesInOutput": 13988
9963
9963
  },
9964
9964
  "../lib/src/factory/sdf-text.js": {
9965
- "bytesInOutput": 7718
9965
+ "bytesInOutput": 7759
9966
9966
  },
9967
9967
  "../../../node_modules/.pnpm/@mapbox+tiny-sdf@2.3.0/node_modules/@mapbox/tiny-sdf/index.js": {
9968
9968
  "bytesInOutput": 2371
@@ -10031,10 +10031,10 @@
10031
10031
  "bytesInOutput": 5457
10032
10032
  },
10033
10033
  "../lib/src/elements/overlay.js": {
10034
- "bytesInOutput": 4420
10034
+ "bytesInOutput": 4421
10035
10035
  },
10036
10036
  "../lib/src/elements/floor.js": {
10037
- "bytesInOutput": 4503
10037
+ "bytesInOutput": 4504
10038
10038
  },
10039
10039
  "../lib/src/elements/model.js": {
10040
10040
  "bytesInOutput": 410
@@ -10049,7 +10049,7 @@
10049
10049
  "bytesInOutput": 2240
10050
10050
  },
10051
10051
  "../lib/src/layer/poi-layer2.js": {
10052
- "bytesInOutput": 1754
10052
+ "bytesInOutput": 1756
10053
10053
  },
10054
10054
  "../lib/src/layer/parking-layer.js": {
10055
10055
  "bytesInOutput": 4035
@@ -10061,22 +10061,22 @@
10061
10061
  "bytesInOutput": 4578
10062
10062
  },
10063
10063
  "../src/factory/material.ts": {
10064
- "bytesInOutput": 14227
10064
+ "bytesInOutput": 14000
10065
10065
  },
10066
10066
  "../src/factory/unique-key.ts": {
10067
- "bytesInOutput": 368
10067
+ "bytesInOutput": 369
10068
10068
  },
10069
10069
  "../src/utils/webworker.ts": {
10070
10070
  "bytesInOutput": 277
10071
10071
  },
10072
10072
  "../src/utils/worker-pool.ts": {
10073
- "bytesInOutput": 826
10073
+ "bytesInOutput": 829
10074
10074
  },
10075
10075
  "../src/factory/worker/merge-geometry.worker.ts": {
10076
10076
  "bytesInOutput": 103
10077
10077
  },
10078
10078
  "../src/factory/merge-geometry.ts": {
10079
- "bytesInOutput": 1695
10079
+ "bytesInOutput": 1696
10080
10080
  },
10081
10081
  "../lib/src/layer/tile-layer.js": {
10082
10082
  "bytesInOutput": 3860
@@ -10085,7 +10085,7 @@
10085
10085
  "bytesInOutput": 1595
10086
10086
  },
10087
10087
  "../lib/src/elements/poi2.js": {
10088
- "bytesInOutput": 12068
10088
+ "bytesInOutput": 12193
10089
10089
  },
10090
10090
  "../lib/src/elements/heatmap.js": {
10091
10091
  "bytesInOutput": 2123
@@ -10118,7 +10118,7 @@
10118
10118
  "bytesInOutput": 3905
10119
10119
  },
10120
10120
  "../lib/src/elements/text-texture.js": {
10121
- "bytesInOutput": 2168
10121
+ "bytesInOutput": 2224
10122
10122
  },
10123
10123
  "../lib/src/elements/line.js": {
10124
10124
  "bytesInOutput": 1125
@@ -10154,7 +10154,7 @@
10154
10154
  "bytesInOutput": 2645
10155
10155
  },
10156
10156
  "../lib/src/operations/hover/hover-helper.js": {
10157
- "bytesInOutput": 2929
10157
+ "bytesInOutput": 2930
10158
10158
  },
10159
10159
  "../lib/src/utils/camera-bound.js": {
10160
10160
  "bytesInOutput": 2201
@@ -10163,7 +10163,7 @@
10163
10163
  "bytesInOutput": 3691
10164
10164
  },
10165
10165
  "../lib/src/context/OrbitControls.js": {
10166
- "bytesInOutput": 13559
10166
+ "bytesInOutput": 13548
10167
10167
  },
10168
10168
  "../lib/src/context/renderer.js": {
10169
10169
  "bytesInOutput": 1126
@@ -10184,10 +10184,10 @@
10184
10184
  "bytesInOutput": 1276
10185
10185
  },
10186
10186
  "../lib/src/loader/AibeeLoader/index.js": {
10187
- "bytesInOutput": 9188
10187
+ "bytesInOutput": 9189
10188
10188
  },
10189
10189
  "../lib/src/loader/AibeeLoader/layer.js": {
10190
- "bytesInOutput": 4410
10190
+ "bytesInOutput": 4413
10191
10191
  },
10192
10192
  "../lib/src/loader/AibeeLoader/utils.js": {
10193
10193
  "bytesInOutput": 1143
@@ -10211,10 +10211,10 @@
10211
10211
  "bytesInOutput": 1524
10212
10212
  },
10213
10213
  "../lib/src/plugins/base.js": {
10214
- "bytesInOutput": 205
10214
+ "bytesInOutput": 206
10215
10215
  },
10216
10216
  "../lib/src/plugins/navigation/navigation.js": {
10217
- "bytesInOutput": 15448
10217
+ "bytesInOutput": 15451
10218
10218
  },
10219
10219
  "../lib/src/plugins/navigation/path.js": {
10220
10220
  "bytesInOutput": 2839
@@ -10223,10 +10223,10 @@
10223
10223
  "bytesInOutput": 13835
10224
10224
  },
10225
10225
  "../lib/src/plugins/navigation/position-navigation.js": {
10226
- "bytesInOutput": 7114
10226
+ "bytesInOutput": 7115
10227
10227
  },
10228
10228
  "../lib/src/plugins/navigation/start-rotate-helper-poi.js": {
10229
- "bytesInOutput": 3438
10229
+ "bytesInOutput": 3439
10230
10230
  },
10231
10231
  "../lib/src/plugins/mul-floors/mul-floors.js": {
10232
10232
  "bytesInOutput": 2266
@@ -10250,13 +10250,13 @@
10250
10250
  "bytesInOutput": 2645
10251
10251
  },
10252
10252
  "../lib/src/plugins/pdr-position/sensor.js": {
10253
- "bytesInOutput": 2925
10253
+ "bytesInOutput": 2926
10254
10254
  },
10255
10255
  "../lib/src/plugins/pdr-position/enum.js": {
10256
10256
  "bytesInOutput": 125
10257
10257
  },
10258
10258
  "../lib/src/plugins/pdr-position/position.js": {
10259
- "bytesInOutput": 930
10259
+ "bytesInOutput": 931
10260
10260
  },
10261
10261
  "../lib/src/plugins/pdr-position/pdr.js": {
10262
10262
  "bytesInOutput": 3682
@@ -10286,7 +10286,7 @@
10286
10286
  "bytesInOutput": 1040
10287
10287
  },
10288
10288
  "../lib/src/plugins/car-inertial-position/car-inertial-position.js": {
10289
- "bytesInOutput": 6825
10289
+ "bytesInOutput": 6826
10290
10290
  },
10291
10291
  "../lib/src/plugins/car-inertial-position/utils.js": {
10292
10292
  "bytesInOutput": 1820
@@ -10301,10 +10301,10 @@
10301
10301
  "bytesInOutput": 4004
10302
10302
  },
10303
10303
  "../lib/src/plugins/position/position.js": {
10304
- "bytesInOutput": 11417
10304
+ "bytesInOutput": 11409
10305
10305
  },
10306
10306
  "../lib/src/plugins/position/socket.js": {
10307
- "bytesInOutput": 2592
10307
+ "bytesInOutput": 2593
10308
10308
  },
10309
10309
  "../lib/src/plugins/position/utils.js": {
10310
10310
  "bytesInOutput": 140
@@ -10340,7 +10340,7 @@
10340
10340
  "bytesInOutput": 0
10341
10341
  }
10342
10342
  },
10343
- "bytes": 452178
10343
+ "bytes": 452255
10344
10344
  }
10345
10345
  }
10346
10346
  }
@@ -1,4 +1,4 @@
1
- import { Object3D, ExtrudeGeometry, Mesh, MeshBasicMaterial, Raycaster, Object3DEventMap, Vector3, BufferGeometry, LineBasicMaterial, LineSegments, ShaderMaterial, LineDashedMaterial } from "three";
1
+ import { Object3D, ExtrudeGeometry, Mesh, Box3, MeshBasicMaterial, Raycaster, Object3DEventMap, Vector3, BufferGeometry, LineBasicMaterial, LineSegments, ShaderMaterial, LineDashedMaterial } from "three";
2
2
  import { GraphicOptions } from "src/types";
3
3
  import { Context } from "../context/context";
4
4
  export type GraphicOptionsParam = Partial<GraphicOptions>;
@@ -35,7 +35,26 @@ export declare class Graphic extends Object3D<GraphicEventMap> {
35
35
  initDoor(): void;
36
36
  initGeometry(): ExtrudeGeometry;
37
37
  initSingleMaterial(): MeshBasicMaterial | MeshBasicMaterial[];
38
- getMaxAndMin(pos: Vector3, dir: Vector3): {
38
+ /**
39
+ * 几何体本地包围盒(shader 里 position 用的就是这个坐标系)
40
+ *
41
+ * 不能用 Box3.setFromObject(this):它给的是世界坐标包围盒。图元摆到楼层上之后,
42
+ * 端点会带上楼层高度 / airHeight / deltaHeight 的偏移,而 shader 用的是本地 position,
43
+ * 坐标系不一致会让渐变整体平移(偏移量 = dot(Δ, lineVec) / |lineVec|²)。
44
+ */
45
+ getLocalBox(): Box3;
46
+ /**
47
+ * 沿 direction 取渐变线段的两个端点
48
+ *
49
+ * 线性投影的极值一定落在包围盒角点上,遍历 8 个角点即可。
50
+ * 端点恒在包围盒内、且与 shader 的 position 同坐标系:
51
+ * 不会出现射线求交打空退化成 (0, 0, 0)(t = 0/0 = NaN → 整面纯色),
52
+ * 也不受图元摆放位置、airHeight、deltaHeight 影响。
53
+ *
54
+ * min = 沿 direction 投影较小的一端(shader 里 t = 0 → uColor),
55
+ * max = 投影较大的一端(t = 1 → uGradualColor)。
56
+ */
57
+ getGradualEndpoints(box: Box3, direction: Vector3): {
39
58
  max: Vector3;
40
59
  min: Vector3;
41
60
  };
@@ -91,6 +91,11 @@ export declare class Poi2 extends Object3D<PoiEventMap2> {
91
91
  get iconWidth(): number;
92
92
  get iconHeight(): number;
93
93
  get textWidth(): number;
94
+ /**
95
+ * 文字块高度(显示像素)。
96
+ * 直接由排版高度按固定比例换算:`text_font_size / spec.fontSize`,
97
+ * 与行数、字符组成无关,保证每一行在屏幕上都精确等于 text_font_size 像素。
98
+ */
94
99
  get textHeight(): number;
95
100
  get initedTextRect(): true | "" | {
96
101
  width: number;
@@ -16,12 +16,17 @@ interface MeshBasicMaterialOptions {
16
16
  }
17
17
  interface ShaderMaterialOptions {
18
18
  gradualColor: string[];
19
- center: Vector3;
20
- maxValue: number;
21
19
  opacity: number;
22
- direction: Vector3;
20
+ /** 渐变线段的两端,必须是几何体本地坐标系(与 shader 里的 position 同系) */
23
21
  max: Vector3;
24
22
  min: Vector3;
23
+ /**
24
+ * @deprecated 渐变轴只由 min / max 决定,center / maxValue / direction
25
+ * 已不参与渲染,仅为兼容旧调用保留。
26
+ */
27
+ center?: Vector3;
28
+ maxValue?: number;
29
+ direction?: Vector3;
25
30
  }
26
31
  interface Line2MaterialMapOptions {
27
32
  color: string;
@@ -45,7 +50,7 @@ export declare class MaterialFactory {
45
50
  static createLineMaterial({ color, opacity, vertexColors }: LineMaterialOptions): LineBasicMaterial;
46
51
  static createMeshStandardMaterial({ color, opacity }: MeshStandardMaterialOptions): MeshStandardMaterial;
47
52
  static createMeshBasicMaterial({ color, opacity, vertexColors }: MeshBasicMaterialOptions): MeshBasicMaterial;
48
- static createShaderMaterial({ gradualColor, center, maxValue, opacity, direction, max, min, }: ShaderMaterialOptions): ShaderMaterial;
53
+ static createShaderMaterial({ gradualColor, opacity, max, min, }: ShaderMaterialOptions): ShaderMaterial;
49
54
  static createLine2MaterialMap({ color, width, dashed, resolution, vertexColors }: Line2MaterialMapOptions): LineMaterial;
50
55
  private static lineDashedMaterialMap;
51
56
  static createLineDashedMaterial(options: {
@@ -12,8 +12,18 @@ export interface SdfFontSpec {
12
12
  cutoff: number;
13
13
  /** 字形位图四周的 SDF padding(参考像素),决定描边的最大可用宽度 */
14
14
  buffer: number;
15
- /** 行距(在 fontSize 之上追加的参考像素),与 SDF padding 解耦 */
16
- lineGap: number;
15
+ /**
16
+ * 行距(相对 fontSize 的比例,与 SDF padding 解耦)。
17
+ * 0.125 表示行高 = 1.125em:显示字号 14px 时行距为 1.75px。
18
+ */
19
+ lineGapRatio: number;
20
+ /**
21
+ * 字体上升部(相对 fontSize 的比例):行顶到基线的距离。
22
+ * 属于字体级度量,与具体字符无关,是排版高度的唯一来源。
23
+ */
24
+ ascentRatio: number;
25
+ /** 字体下降部(相对 fontSize 的比例):基线到行底的距离 */
26
+ descentRatio: number;
17
27
  }
18
28
  /**
19
29
  * 默认字体规格。
@@ -15,21 +15,37 @@ export interface TextLayoutResult {
15
15
  glyphs: PositionedGlyph[];
16
16
  /** 布局宽度(SDF 基准字号像素) */
17
17
  width: number;
18
- /** 布局高度(SDF 基准字号像素) */
18
+ /**
19
+ * 文本块高度(SDF 基准字号像素,即 em 单位)。
20
+ * 只由字号、行距、行数决定,与具体字符无关:
21
+ * `[1 + (行数 - 1) × (1 + lineGapRatio)] × fontSize`
22
+ * (ascentRatio + descentRatio 默认合计为 1em)
23
+ */
19
24
  height: number;
20
25
  /** 宽高比 */
21
26
  aspect: number;
22
27
  /** 行数 */
23
28
  linesCount: number;
29
+ /** 实际字形 ink 的下边界(相对文本块底部,SDF 基准字号像素) */
30
+ inkBottom: number;
31
+ /** 实际字形 ink 的高度(SDF 基准字号像素);如需紧贴文字的旧行为,用它做归一化 */
32
+ inkHeight: number;
24
33
  }
25
34
  type MeasureFn = (str: string) => number;
26
35
  /**
27
36
  * 按括号/空格/中文逐字规则换行。
28
37
  * 逻辑与旧 `TextTextureFactory.splitText` 保持一致,仅把度量方式换成字形 advance 累加。
38
+ *
39
+ * 显式换行符 `\n` 优先:业务方常用它按字段分行,不能被宽度折行打乱。
29
40
  */
30
41
  export declare function splitTextByMeasure(text: string, maxWidth: number, measure: MeasureFn): string[];
31
42
  /**
32
43
  * 对文字进行 SDF 布局。
44
+ *
45
+ * 排版高度与基线位置全部由字体规格(fontSize / lineGapRatio / ascentRatio / descentRatio)决定,
46
+ * 与实际渲染的字符无关,因此同一字号在不同行数、不同文本下都能得到一致的显示字号。
47
+ * 这里的数值都是 em 单位,最终乘 `text_font_size / fontSize` 即可得到显示像素。
48
+ *
33
49
  * @param text 文本
34
50
  * @param charMap 字符 → 字形度量(来自 SdfTextFactory 图集)
35
51
  * @param spec 字体规格
@@ -41,6 +57,13 @@ interface BuildGeometryOptions {
41
57
  pivotY?: number;
42
58
  /** 水平 pivot,对应 Sprite.center.x,默认 0.5 */
43
59
  pivotX?: number;
60
+ /**
61
+ * 归一化区间的下边界(默认 0:以整个文本块底部为准)。
62
+ * 传入 `layout.inkBottom` + `layout.inkHeight` 可让几何紧贴字形 ink,保持旧行为的视觉尺寸。
63
+ */
64
+ normalizeBottom?: number;
65
+ /** 归一化区间的高度(默认整个文本块高度) */
66
+ normalizeHeight?: number;
44
67
  }
45
68
  /** 某个图集页对应的那部分文字几何 */
46
69
  export interface SdfTextGeometryPart {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibee/crc-bmap",
3
- "version": "0.14.30",
3
+ "version": "0.14.32",
4
4
  "description": "",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.esm.min.js",