@aibee/crc-bmap 0.14.30 → 0.14.31

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
@@ -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",
@@ -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",
@@ -9956,10 +9956,10 @@
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
9965
  "bytesInOutput": 7718
@@ -10061,7 +10061,7 @@
10061
10061
  "bytesInOutput": 4578
10062
10062
  },
10063
10063
  "../src/factory/material.ts": {
10064
- "bytesInOutput": 14227
10064
+ "bytesInOutput": 13989
10065
10065
  },
10066
10066
  "../src/factory/unique-key.ts": {
10067
10067
  "bytesInOutput": 368
@@ -10340,7 +10340,7 @@
10340
10340
  "bytesInOutput": 0
10341
10341
  }
10342
10342
  },
10343
- "bytes": 452178
10343
+ "bytes": 451684
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
  };
@@ -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: {
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.31",
4
4
  "description": "",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.esm.min.js",