@realsee/dnalogel 3.78.1-alpha.1 → 3.79.0

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.
@@ -6,13 +6,20 @@ import type { Config as BaseConfig } from '../base/BasePlugin';
6
6
  import { GuideLineItem } from './GuideLineItem';
7
7
  import CruisePluginController from '../CruisePlugin/Work';
8
8
  export declare const pluginFlag: (name: string) => string;
9
- type Config = BaseConfig;
9
+ type Config = BaseConfig & {
10
+ /**
11
+ * @description 格式化距离函数,用于将米转换为显示文本(包含单位)
12
+ * @param distanceInMeter 距离(单位:米)
13
+ * @returns 格式化后的距离字符串,例如 "10m" 或 "32'10""
14
+ */
15
+ formatDistance?: (distanceInMeter: number) => string;
16
+ };
10
17
  export default class Controller extends BasePluginWithData.Controller<PluginState, EventMap, PluginServerData, PluginData> {
11
18
  readonly name = "GuideLinePlugin";
12
19
  readonly cruisePlugin: CruisePluginController;
13
20
  /** GuideLineItem 索引 */
14
21
  readonly itemMap: Map<string | number, GuideLineItem>;
15
- get config(): BaseConfig;
22
+ get config(): Config;
16
23
  state: {
17
24
  visible: boolean;
18
25
  enabled: boolean;
@@ -54,6 +61,31 @@ export default class Controller extends BasePluginWithData.Controller<PluginStat
54
61
  getGuideLineItemByID(id: string | number): GuideLineItem;
55
62
  /** 移除一个 GuideLineItem */
56
63
  removeGuideLineItem(item: GuideLineItem): void;
64
+ /**
65
+ * 动态更新距离格式化函数,立即刷新所有路线标签的距离显示。
66
+ * 不传参时恢复为默认格式(i18n('全程') + 距离 + i18n('米'))。
67
+ * @param fn 格式化函数,输入米数,返回带单位的完整字符串
68
+ * @example
69
+ * // 室内英制:英尺 + 英寸(如 "5'10"")
70
+ * plugin.setDistanceFormatter((m) => {
71
+ * const totalInches = Math.round(m * 39.3701)
72
+ * const feet = Math.floor(totalInches / 12)
73
+ * const inches = totalInches % 12
74
+ * return `${feet}'${inches}"`
75
+ * })
76
+ * // 室外英制:英里(如 "1.24 mi")
77
+ * plugin.setDistanceFormatter((m) => `${(m * 0.000621371).toFixed(2)} mi`)
78
+ * // 自动切换:近距离用英尺,远距离用英里
79
+ * plugin.setDistanceFormatter((m) => {
80
+ * if (m < 300) return `${Math.round(m * 3.28084)} ft`
81
+ * return `${(m * 0.000621371).toFixed(2)} mi`
82
+ * })
83
+ * // 恢复默认(i18n '米')
84
+ * plugin.setDistanceFormatter()
85
+ */
86
+ setDistanceFormatter(fn?: (distanceInMeter: number) => string): void;
87
+ /** 更新所有 tag 的距离显示(当 formatDistance 函数改变时调用) */
88
+ private updateTagDistances;
57
89
  /** 全量更新 tag */
58
90
  updateTagsEnable(): void;
59
91
  /** 清空所有 GuideLineItem */
@@ -23,8 +23,8 @@ declare class GuideLineModeItem {
23
23
  /** THREE Curve 路径上的点 */
24
24
  get curvePoints(): THREE.Vector3[];
25
25
  name: string;
26
- startTagContainer: GuideLineTagContainer;
27
- endTagContainer: GuideLineTagContainer;
26
+ startTagContainer?: GuideLineTagContainer;
27
+ endTagContainer?: GuideLineTagContainer;
28
28
  path: PluginType.PathItem[];
29
29
  geometryStyle: PluginType.GuideLineGeometryStyle;
30
30
  materialStyle: PluginType.GuideLineMaterialStyle;
@@ -32,6 +32,9 @@ declare class GuideLineModeItem {
32
32
  readonly group: THREE.Group;
33
33
  readonly mesh: THREE.Mesh<THREE.BufferGeometry, THREE.ShaderMaterial>;
34
34
  visible: boolean | null;
35
+ /** 保存原始的 tag 数据,用于更新距离显示 */
36
+ private startTagData;
37
+ private endTagData;
35
38
  private five;
36
39
  private mode;
37
40
  private _curvePath;
@@ -117,6 +120,8 @@ declare class GuideLineModeItem {
117
120
  setVisibleFloorIndexes(floorIndexes: number[]): void;
118
121
  setStartTag(tag: Tag | PluginType.ModelGuideLineTagData | null): void;
119
122
  setEndTag(tag: Tag | PluginType.ModelGuideLineTagData | null): void;
123
+ /** 更新 tag 的距离显示(当 formatDistance 函数改变时调用) */
124
+ updateTagDistance(): void;
120
125
  /** 闪烁 */
121
126
  flicker(): void;
122
127
  /** 求起点到 panoIndex 曲线长度