vtkviewer-vue 0.1.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.
Files changed (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +753 -0
  3. package/README.md +1760 -0
  4. package/lib/types/components/PluginToolbar.vue.d.ts +7 -0
  5. package/lib/types/components/ToolbarExtension.vue.d.ts +9 -0
  6. package/lib/types/components/ToolbarInfoPanel.vue.d.ts +10 -0
  7. package/lib/types/components/VtkViewer.vue.d.ts +32 -0
  8. package/lib/types/components/index.d.ts +4 -0
  9. package/lib/types/composables/index.d.ts +7 -0
  10. package/lib/types/composables/useFormatLoader.d.ts +33 -0
  11. package/lib/types/composables/useResponsiveLayout.d.ts +46 -0
  12. package/lib/types/composables/useUIPlugins.d.ts +57 -0
  13. package/lib/types/composables/useViewer.d.ts +47 -0
  14. package/lib/types/configs/index.d.ts +76 -0
  15. package/lib/types/core/CommandRegistrar.d.ts +12 -0
  16. package/lib/types/core/CommandRegistry.d.ts +34 -0
  17. package/lib/types/core/ConfigAccessor.d.ts +33 -0
  18. package/lib/types/core/DisposalRegistry.d.ts +32 -0
  19. package/lib/types/core/EventBus.d.ts +79 -0
  20. package/lib/types/core/FormatDetector.d.ts +59 -0
  21. package/lib/types/core/I18nManager.d.ts +135 -0
  22. package/lib/types/core/InteractionSubContext.d.ts +73 -0
  23. package/lib/types/core/RenderSubContext.d.ts +74 -0
  24. package/lib/types/core/ResetManager.d.ts +122 -0
  25. package/lib/types/core/ResetRegistry.d.ts +170 -0
  26. package/lib/types/core/SceneSubContext.d.ts +25 -0
  27. package/lib/types/core/StateManager.d.ts +104 -0
  28. package/lib/types/core/ThemeContext.d.ts +37 -0
  29. package/lib/types/core/ToolbarExtensionRegistry.d.ts +105 -0
  30. package/lib/types/core/ToolbarInfoRegistry.d.ts +77 -0
  31. package/lib/types/core/UISubContext.d.ts +32 -0
  32. package/lib/types/core/ViewerContext.d.ts +101 -0
  33. package/lib/types/core/ViewerContextBuilder.d.ts +57 -0
  34. package/lib/types/core/createViewerContext.d.ts +26 -0
  35. package/lib/types/core/index.d.ts +23 -0
  36. package/lib/types/icons/index.d.ts +47 -0
  37. package/lib/types/index.d.ts +7 -0
  38. package/lib/types/plugins/PluginBase.d.ts +131 -0
  39. package/lib/types/plugins/PluginRegistry.d.ts +67 -0
  40. package/lib/types/plugins/defaults.d.ts +3 -0
  41. package/lib/types/plugins/format/DrcPlugin.d.ts +30 -0
  42. package/lib/types/plugins/format/GlbPlugin.d.ts +23 -0
  43. package/lib/types/plugins/format/ObjPlugin.d.ts +23 -0
  44. package/lib/types/plugins/format/PdbPlugin.d.ts +33 -0
  45. package/lib/types/plugins/format/PlyPlugin.d.ts +24 -0
  46. package/lib/types/plugins/format/StlPlugin.d.ts +25 -0
  47. package/lib/types/plugins/format/VtiPlugin.d.ts +60 -0
  48. package/lib/types/plugins/format/VtpPlugin.d.ts +24 -0
  49. package/lib/types/plugins/format/VtuPlugin.d.ts +25 -0
  50. package/lib/types/plugins/format/ZipPlugin.d.ts +38 -0
  51. package/lib/types/plugins/format/index.d.ts +13 -0
  52. package/lib/types/plugins/index.d.ts +13 -0
  53. package/lib/types/plugins/injectionKeys.d.ts +22 -0
  54. package/lib/types/plugins/pluginUtils.d.ts +61 -0
  55. package/lib/types/plugins/service/DragDropPlugin.d.ts +94 -0
  56. package/lib/types/plugins/service/KeyBindingPlugin.d.ts +83 -0
  57. package/lib/types/plugins/service/MemoryPressurePlugin.d.ts +68 -0
  58. package/lib/types/plugins/service/index.d.ts +6 -0
  59. package/lib/types/plugins/toolbar/animation/AnimationPlugin.d.ts +34 -0
  60. package/lib/types/plugins/toolbar/animation/index.d.ts +1 -0
  61. package/lib/types/plugins/toolbar/index.d.ts +9 -0
  62. package/lib/types/plugins/toolbar/interaction/CenterModelPlugin.d.ts +21 -0
  63. package/lib/types/plugins/toolbar/interaction/FullscreenPlugin.d.ts +27 -0
  64. package/lib/types/plugins/toolbar/interaction/PanPlugin.d.ts +24 -0
  65. package/lib/types/plugins/toolbar/interaction/ResetAllPlugin.d.ts +25 -0
  66. package/lib/types/plugins/toolbar/interaction/RotatePlugin.d.ts +24 -0
  67. package/lib/types/plugins/toolbar/interaction/ViewSelectPlugin.d.ts +26 -0
  68. package/lib/types/plugins/toolbar/interaction/ZoomPlugin.d.ts +24 -0
  69. package/lib/types/plugins/toolbar/interaction/index.d.ts +7 -0
  70. package/lib/types/plugins/toolbar/model/ClippingPlugin.d.ts +87 -0
  71. package/lib/types/plugins/toolbar/model/ColorByPlugin.d.ts +113 -0
  72. package/lib/types/plugins/toolbar/model/LoadModelPlugin.d.ts +93 -0
  73. package/lib/types/plugins/toolbar/model/RenderPrecisionPlugin.d.ts +68 -0
  74. package/lib/types/plugins/toolbar/model/RenderStylePlugin.d.ts +88 -0
  75. package/lib/types/plugins/toolbar/model/UnloadModelPlugin.d.ts +25 -0
  76. package/lib/types/plugins/toolbar/model/index.d.ts +6 -0
  77. package/lib/types/plugins/toolbar/scene/AxesPlugin.d.ts +96 -0
  78. package/lib/types/plugins/toolbar/scene/BackgroundColorPlugin.d.ts +25 -0
  79. package/lib/types/plugins/toolbar/scene/LanguageSwitchPlugin.d.ts +45 -0
  80. package/lib/types/plugins/toolbar/scene/LightIntensityPlugin.d.ts +42 -0
  81. package/lib/types/plugins/toolbar/scene/RenderGridPlugin.d.ts +98 -0
  82. package/lib/types/plugins/toolbar/scene/ThemeSwitchPlugin.d.ts +49 -0
  83. package/lib/types/plugins/toolbar/scene/index.d.ts +6 -0
  84. package/lib/types/plugins/toolbar/tools/BookmarkPlugin.d.ts +70 -0
  85. package/lib/types/plugins/toolbar/tools/MeasurementPlugin.d.ts +112 -0
  86. package/lib/types/plugins/toolbar/tools/PerformancePlugin.d.ts +55 -0
  87. package/lib/types/plugins/toolbar/tools/ScreenshotPlugin.d.ts +58 -0
  88. package/lib/types/plugins/toolbar/tools/index.d.ts +4 -0
  89. package/lib/types/plugins/toolbar/utils.d.ts +67 -0
  90. package/lib/types/plugins/types/index.d.ts +250 -0
  91. package/lib/types/plugins/ui/ErrorPlugin.d.ts +30 -0
  92. package/lib/types/plugins/ui/FilenameInfoPlugin.d.ts +40 -0
  93. package/lib/types/plugins/ui/LoadingPlugin.d.ts +28 -0
  94. package/lib/types/plugins/ui/SceneTreePlugin.d.ts +60 -0
  95. package/lib/types/plugins/ui/WebGLContextLostPlugin.d.ts +33 -0
  96. package/lib/types/plugins/ui/index.d.ts +8 -0
  97. package/lib/types/polyfills.d.ts +1 -0
  98. package/lib/types/types/index.d.ts +187 -0
  99. package/lib/types/types/vtk-modules.d.ts +80 -0
  100. package/lib/types/utils/asyncUtils.d.ts +8 -0
  101. package/lib/types/utils/colorByUtils.d.ts +55 -0
  102. package/lib/types/utils/debugLog.d.ts +13 -0
  103. package/lib/types/utils/errorHandler.d.ts +28 -0
  104. package/lib/types/utils/index.d.ts +10 -0
  105. package/lib/types/utils/sceneUtils.d.ts +11 -0
  106. package/lib/types/utils/themeManager.d.ts +78 -0
  107. package/lib/types/utils/volumeUtils.d.ts +14 -0
  108. package/lib/types/utils/vtkHelpers.d.ts +46 -0
  109. package/lib/types/utils/vtuLoader.d.ts +26 -0
  110. package/lib/types/utils/zipReader.d.ts +71 -0
  111. package/lib/vtkviewer.css +2 -0
  112. package/lib/vtkviewer.js +54714 -0
  113. package/lib/vtkviewer.umd.cjs +4560 -0
  114. package/package.json +89 -0
@@ -0,0 +1,250 @@
1
+ import { Component } from 'vue';
2
+ import { ViewerContext } from '../../core/ViewerContext';
3
+ /** 插件类型 */
4
+ export declare const PluginType: {
5
+ readonly FORMAT: "format";
6
+ readonly TOOLBAR: "toolbar";
7
+ readonly UI: "ui";
8
+ readonly SERVICE: "service";
9
+ };
10
+ export type PluginType = (typeof PluginType)[keyof typeof PluginType];
11
+ /** 插件元数据 */
12
+ export interface PluginMetadata {
13
+ id: string;
14
+ name: string;
15
+ type: PluginType;
16
+ description?: string;
17
+ version?: string;
18
+ icon?: Component;
19
+ }
20
+ /** 插件配置 */
21
+ export interface PluginConfig {
22
+ enabled?: boolean;
23
+ [key: string]: any;
24
+ }
25
+ /**
26
+ * 统一插件接口(所有插件基类)
27
+ */
28
+ export interface IViewerPlugin<TConfig extends PluginConfig = PluginConfig> {
29
+ readonly metadata: PluginMetadata;
30
+ readonly dependencies?: string[];
31
+ readonly initOrder?: number;
32
+ readonly defaultConfig?: TConfig;
33
+ init(ctx: ViewerContext, config?: TConfig): void | Promise<void>;
34
+ dispose(): void;
35
+ onConfigChange?(config: TConfig): void;
36
+ /** 获取插件配置中 hideWhenNoModel 的值 */
37
+ getHideWhenNoModel?(): boolean;
38
+ }
39
+ /** 格式解析结果 */
40
+ export interface FormatParseResult {
41
+ /** 渲染对象(Actor/Volume) */
42
+ actors?: any[];
43
+ volumes?: any[];
44
+ /** 原始数据(如点云、网格) */
45
+ data?: any;
46
+ /** 元数据 */
47
+ metadata?: Record<string, any>;
48
+ /** 是否为体渲染 */
49
+ isVolume?: boolean;
50
+ }
51
+ /**
52
+ * 格式处理器插件
53
+ * 负责文件解析、数据转换、场景构建
54
+ */
55
+ export interface IFormatPlugin<T extends PluginConfig = PluginConfig> extends IViewerPlugin<T> {
56
+ readonly metadata: PluginMetadata & {
57
+ type: 'format';
58
+ };
59
+ /** 支持的格式列表 */
60
+ readonly formats: string[];
61
+ /** 优先级(数值越大越优先) */
62
+ readonly priority: number;
63
+ /** 是否能处理该格式 */
64
+ canHandle(format: string, buffer?: ArrayBuffer): boolean;
65
+ /** 解析文件 */
66
+ parse(arrayBuffer: ArrayBuffer, format: string, options?: Record<string, any>): Promise<FormatParseResult>;
67
+ /** 获取文件元数据(可选) */
68
+ getMetadata?(arrayBuffer: ArrayBuffer, format: string): Promise<Record<string, any>>;
69
+ }
70
+ /** 工具栏插件分组 */
71
+ export type ToolbarPluginGroup = string;
72
+ /**
73
+ * 工具栏图标配置
74
+ * 支持单图标、双状态图标、多状态图标
75
+ */
76
+ export interface ToolbarIconConfig {
77
+ /** 默认图标(当无状态特定图标时使用) */
78
+ default: Component;
79
+ /** 激活状态图标(可选,用于开关类插件) */
80
+ active?: Component;
81
+ /** 非激活状态图标(可选,用于开关类插件) */
82
+ inactive?: Component;
83
+ /** 多状态图标(用于多状态插件,如坐标轴切换) */
84
+ states?: Record<string, Component>;
85
+ }
86
+ /**
87
+ * 图标配置类型
88
+ * 支持单组件或带状态的图标配置
89
+ */
90
+ export type PluginIcon = Component | ToolbarIconConfig;
91
+ /**
92
+ * 输入映射类型
93
+ * 支持键盘、鼠标、手势三种输入方式
94
+ */
95
+ export type InputMappingType = 'keyboard' | 'mouse' | 'gesture';
96
+ /**
97
+ * 输入映射
98
+ * 定义一个具体的输入绑定
99
+ */
100
+ export interface InputMapping {
101
+ /** 映射类型,默认 'keyboard' */
102
+ type?: InputMappingType;
103
+ /** 键盘按键(type='keyboard' 或省略 type 时使用) */
104
+ key?: string;
105
+ /** 键盘修饰键 */
106
+ ctrl?: boolean;
107
+ shift?: boolean;
108
+ alt?: boolean;
109
+ meta?: boolean;
110
+ /** 鼠标按钮(type='mouse' 时使用,0=左键, 1=中键, 2=右键) */
111
+ button?: number;
112
+ /** 鼠标事件(type='mouse' 时使用) */
113
+ event?: 'click' | 'dblclick' | 'mousedown' | 'mouseup';
114
+ /** 手势类型(type='gesture' 时使用) */
115
+ gesture?: 'pinch' | 'rotate' | 'swipe' | 'pan';
116
+ /** 手势方向(type='gesture' 时使用) */
117
+ direction?: 'up' | 'down' | 'left' | 'right';
118
+ }
119
+ /**
120
+ * 键盘快捷键配置项(仅支持键盘按键)
121
+ * 用于工具栏插件的快捷键配置
122
+ */
123
+ export interface KeyboardShortcutConfigItem {
124
+ /** 动作标识 */
125
+ action: string;
126
+ /** 动作描述 */
127
+ description?: string;
128
+ /** 按键(单个按键或组合键,如 'f' 或 'Ctrl+S') */
129
+ key: string | string[];
130
+ }
131
+ /**
132
+ * 快捷键配置类型
133
+ * 支持多种简写形式,最终统一解析为 KeyboardShortcutConfigItem[]
134
+ *
135
+ * 使用规则:
136
+ * - string / string[]:仅当插件只有一种 action 时使用,等价于 { action: metadata.id, key: ... }
137
+ * - KeyboardShortcutConfigItem / KeyboardShortcutConfigItem[]:多 action 或需要自定义描述时使用
138
+ */
139
+ export type ShortcutConfig = string | string[] | KeyboardShortcutConfigItem | KeyboardShortcutConfigItem[];
140
+ export interface KeyboardShortcutAction {
141
+ /** 快捷键名称,对应 KeyboardShortcutConfigItem 的 action */
142
+ name?: string;
143
+ key: string;
144
+ ctrl?: boolean;
145
+ shift?: boolean;
146
+ alt?: boolean;
147
+ action: () => void;
148
+ description?: string;
149
+ }
150
+ /**
151
+ * 工具栏插件基础配置
152
+ * 所有工具栏插件的 config 都应继承此接口
153
+ */
154
+ export interface ToolbarPluginConfig extends PluginConfig {
155
+ /** 图标配置 */
156
+ icon?: PluginIcon;
157
+ /** 开关类插件的默认激活状态,true=默认开启,false/undefined=默认关闭 */
158
+ defaultActive?: boolean;
159
+ /** 没有模型时是否隐藏 */
160
+ hideWhenNoModel?: boolean;
161
+ /** 分组标识(可选),通过注册时配置传入,如 `[PluginClass, { group: 'core' }]` */
162
+ group?: ToolbarPluginGroup;
163
+ /** 快捷键配置(支持多种简写形式,统一解析为 KeyboardShortcutConfigItem[]) */
164
+ shortcut?: ShortcutConfig;
165
+ /** 在信息显示区的显示排序,越小越靠前 */
166
+ infoPanelPriority?: number;
167
+ /** 在工具栏拓展功能区域的显示排序越小越靠前 */
168
+ toolbarExtensionPriority?: number;
169
+ }
170
+ /**
171
+ * 工具栏插件
172
+ */
173
+ export interface IToolbarPlugin extends IViewerPlugin {
174
+ readonly metadata: PluginMetadata & {
175
+ type: 'toolbar';
176
+ };
177
+ readonly order: number;
178
+ readonly icon?: PluginIcon;
179
+ getIcon?(state?: string): Component | undefined;
180
+ /** 获取分组标识(从 config.group 读取) */
181
+ getGroup?(): ToolbarPluginGroup | undefined;
182
+ render(): Component;
183
+ isVisible(ctx: ViewerContext): boolean;
184
+ /** 获取快捷键配置列表(统一解析后的标准格式) */
185
+ getShortcutConfig?(): KeyboardShortcutConfigItem[];
186
+ getKeyboardShortcutActions?(): KeyboardShortcutAction[];
187
+ /**
188
+ * 渲染扩展区内容(可选)
189
+ * 当插件功能激活时,扩展区内容将显示在工具栏下方
190
+ */
191
+ renderExtension?(): Component;
192
+ /**
193
+ * 扩展区是否激活(可选)
194
+ * 返回 true 时显示扩展区内容
195
+ */
196
+ isExtensionActive?(): boolean;
197
+ }
198
+ /** UI插件子类型 */
199
+ export type UIPluginType = 'overlay' | 'panel' | 'notification' | 'portal';
200
+ /** UI插件位置 */
201
+ export type UIPluginPosition = 'top' | 'bottom' | 'left' | 'right' | 'center';
202
+ /**
203
+ * UI插件
204
+ */
205
+ export interface IUIPlugin extends IViewerPlugin {
206
+ readonly metadata: PluginMetadata & {
207
+ type: 'ui';
208
+ };
209
+ readonly uiType: UIPluginType;
210
+ readonly order: number;
211
+ render(): Component;
212
+ isVisible(ctx: ViewerContext): boolean;
213
+ getPosition?(): UIPluginPosition;
214
+ activate?(): void;
215
+ deactivate?(): void;
216
+ /** 获取 Teleport 目标(仅 uiType='portal' 时生效) */
217
+ getPortalTarget?(): string | Element | null;
218
+ /** 获取 Teleport 额外属性(仅 uiType='portal' 时生效) */
219
+ getPortalProps?(): Record<string, any>;
220
+ }
221
+ /**
222
+ * 服务插件(无UI)
223
+ */
224
+ export interface IServicePlugin extends IViewerPlugin {
225
+ readonly metadata: PluginMetadata & {
226
+ type: 'service';
227
+ };
228
+ }
229
+ /** 通用插件标识类型 */
230
+ export type PluginIdentifier<T extends PluginConfig = PluginConfig> = string | (new (...args: any[]) => IViewerPlugin<T>);
231
+ /** 格式插件标识类型(仅类引用) */
232
+ export type FormatPluginIdentifier<T extends PluginConfig = PluginConfig> = new (...args: any[]) => IFormatPlugin<T>;
233
+ /** 通用插件配置项 */
234
+ export type PluginItem<T extends PluginConfig = PluginConfig> = PluginIdentifier<T> | [PluginIdentifier<T>, T?];
235
+ /** 格式插件配置项 */
236
+ export type FormatPluginItem<T extends PluginConfig = PluginConfig> = FormatPluginIdentifier<T> | [FormatPluginIdentifier<T>, T?];
237
+ /**
238
+ * 分类插件配置
239
+ * 按插件类型分组配置,支持按分类独立配置和覆盖
240
+ */
241
+ export interface PluginsConfig {
242
+ /** 格式插件 */
243
+ format?: FormatPluginItem[];
244
+ /** 工具栏插件 */
245
+ toolbar?: PluginItem[];
246
+ /** UI 插件 */
247
+ ui?: PluginItem[];
248
+ /** 服务插件 */
249
+ service?: PluginItem[];
250
+ }
@@ -0,0 +1,30 @@
1
+ import { IUIPlugin, PluginConfig } from '../types';
2
+ import { PluginBase } from '../PluginBase';
3
+ import { DefineComponent, VNode, RendererNode, RendererElement, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
4
+ /** 错误提示插件配置 */
5
+ export interface ErrorPluginConfig extends PluginConfig {
6
+ /** 是否显示重试按钮 */
7
+ showRetry?: boolean;
8
+ /** 遮罩层背景色(覆盖 CSS 变量 --iimm-vtk-error-overlay-bg),默认继承主题 */
9
+ overlayBackground?: string;
10
+ }
11
+ /**
12
+ * 错误提示插件
13
+ * 显示错误信息和恢复操作
14
+ */
15
+ export declare class ErrorPlugin extends PluginBase<ErrorPluginConfig> implements IUIPlugin {
16
+ readonly metadata: {
17
+ id: string;
18
+ name: string;
19
+ type: "ui";
20
+ description: string;
21
+ };
22
+ readonly uiType: "overlay";
23
+ readonly order = 1;
24
+ readonly defaultConfig: ErrorPluginConfig;
25
+ render(): DefineComponent<{}, () => VNode<RendererNode, RendererElement, {
26
+ [key: string]: any;
27
+ }> | null, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
28
+ isVisible(): boolean;
29
+ getPosition(): 'bottom';
30
+ }
@@ -0,0 +1,40 @@
1
+ import { IUIPlugin, PluginConfig } from '../types';
2
+ import { PluginBase } from '../PluginBase';
3
+ import { DefineComponent, VNode, RendererNode, RendererElement, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
4
+ /** 文件名信息插件配置 */
5
+ export interface FilenameInfoPluginConfig extends PluginConfig {
6
+ /** 无模型时是否隐藏,默认 true */
7
+ hideWhenNoModel?: boolean;
8
+ }
9
+ /**
10
+ * 文件名信息展示插件
11
+ * 在视口底部以半透明状态栏形式显示当前加载模型的文件名
12
+ */
13
+ export declare class FilenameInfoPlugin extends PluginBase<FilenameInfoPluginConfig> implements IUIPlugin {
14
+ readonly metadata: {
15
+ id: string;
16
+ name: string;
17
+ type: "ui";
18
+ description: string;
19
+ };
20
+ readonly uiType: "overlay";
21
+ readonly order = 2;
22
+ readonly defaultConfig: FilenameInfoPluginConfig;
23
+ /** 当前显示的文件名文本 */
24
+ private displayName;
25
+ /** 当前显示的文件名类型提示 */
26
+ private sourceType;
27
+ protected onInit(): void;
28
+ /**
29
+ * 根据输入解析显示名称。
30
+ *
31
+ * @param raw 场景加载事件中的 filename 字段
32
+ * @returns 处理后的显示名称,无效时返回空字符串
33
+ */
34
+ private resolveDisplayName;
35
+ render(): DefineComponent<{}, () => VNode<RendererNode, RendererElement, {
36
+ [key: string]: any;
37
+ }> | null, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
38
+ isVisible(): boolean;
39
+ getPosition(): 'bottom';
40
+ }
@@ -0,0 +1,28 @@
1
+ import { IUIPlugin, PluginConfig } from '../types';
2
+ import { PluginBase } from '../PluginBase';
3
+ import { DefineComponent, VNode, RendererNode, RendererElement, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
4
+ /** 加载进度插件配置 */
5
+ export interface LoadingPluginConfig extends PluginConfig {
6
+ /** 是否显示进度条 */
7
+ showProgress?: boolean;
8
+ }
9
+ /**
10
+ * 加载进度插件
11
+ * 显示文件加载进度(现代化玻璃态卡片 + 环形进度条)
12
+ */
13
+ export declare class LoadingPlugin extends PluginBase<LoadingPluginConfig> implements IUIPlugin {
14
+ readonly metadata: {
15
+ id: string;
16
+ name: string;
17
+ type: "ui";
18
+ description: string;
19
+ };
20
+ readonly uiType: "overlay";
21
+ readonly order = 0;
22
+ readonly defaultConfig: LoadingPluginConfig;
23
+ render(): DefineComponent<{}, () => VNode<RendererNode, RendererElement, {
24
+ [key: string]: any;
25
+ }> | null, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
26
+ isVisible(): boolean;
27
+ getPosition(): 'center';
28
+ }
@@ -0,0 +1,60 @@
1
+ import { Component } from 'vue';
2
+ import { IResettableActions, ResetAction } from '../../core';
3
+ import { IUIPlugin, PluginConfig, UIPluginPosition } from '../types';
4
+ import { PluginBase } from '../PluginBase';
5
+ /** 场景树插件配置 */
6
+ export interface SceneTreePluginConfig extends PluginConfig {
7
+ /** 面板宽度(px),默认 280 */
8
+ panelWidth?: number;
9
+ /** 是否在无模型时隐藏,默认 true */
10
+ hideWhenNoModel?: boolean;
11
+ /** 面板位置,默认 'left' */
12
+ position?: 'left' | 'right';
13
+ }
14
+ export declare class SceneTreePlugin extends PluginBase<SceneTreePluginConfig> implements IUIPlugin, IResettableActions {
15
+ readonly metadata: {
16
+ id: string;
17
+ name: string;
18
+ type: "ui";
19
+ description: string;
20
+ };
21
+ readonly uiType: "panel";
22
+ readonly order = 10;
23
+ readonly defaultConfig: SceneTreePluginConfig;
24
+ /** 场景树条目列表 */
25
+ private items;
26
+ /** 面板是否展开 */
27
+ private isExpanded;
28
+ /** 颜色拾取中条目的 ID(打开颜色选择器的条目) */
29
+ private pickingColorId;
30
+ /**
31
+ * 初始状态快照
32
+ * 每次场景加载时记录所有 actor/volume 的初始 visible/opacity/color,
33
+ * resetAll 时恢复到此状态
34
+ */
35
+ private initialStates;
36
+ protected onInit(): void;
37
+ /**
38
+ * 保存当前场景对象的状态作为初始状态快照
39
+ * 用于 resetAll 时恢复
40
+ */
41
+ private saveInitialStates;
42
+ /**
43
+ * 刷新场景树条目
44
+ * 扫描场景中的 Actor 和 Volume,同步到树列表
45
+ */
46
+ private refreshSceneItems;
47
+ protected onDispose(): void;
48
+ /** 切换面板展开/收起 */
49
+ private togglePanel;
50
+ /** 切换条目显隐 */
51
+ private toggleVisibility;
52
+ /** 设置条目透明度 */
53
+ private setOpacity;
54
+ /** 设置 Actor 颜色 */
55
+ private setColor;
56
+ registerResetActions(): ResetAction[];
57
+ isVisible(): boolean;
58
+ getPosition(): UIPluginPosition;
59
+ render(): Component;
60
+ }
@@ -0,0 +1,33 @@
1
+ import { IUIPlugin, PluginConfig } from '../types';
2
+ import { PluginBase } from '../PluginBase';
3
+ import { DefineComponent, VNode, RendererNode, RendererElement, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
4
+ /** WebGL上下文丢失插件配置 */
5
+ export interface WebGLContextLostPluginConfig extends PluginConfig {
6
+ /** 最大重试次数 */
7
+ maxRetries?: number;
8
+ }
9
+ /**
10
+ * WebGL上下文丢失插件
11
+ * 显示WebGL上下文丢失提示和恢复操作
12
+ */
13
+ export declare class WebGLContextLostPlugin extends PluginBase<WebGLContextLostPluginConfig> implements IUIPlugin {
14
+ readonly metadata: {
15
+ id: string;
16
+ name: string;
17
+ type: "ui";
18
+ description: string;
19
+ };
20
+ readonly uiType: "overlay";
21
+ readonly order = 2;
22
+ readonly defaultConfig: WebGLContextLostPluginConfig;
23
+ private isContextLost;
24
+ private retryCount;
25
+ protected onInit(): void;
26
+ private onContextLost;
27
+ private onContextRestored;
28
+ render(): DefineComponent<{}, () => VNode<RendererNode, RendererElement, {
29
+ [key: string]: any;
30
+ }> | null, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
31
+ isVisible(): boolean;
32
+ getPosition(): 'center';
33
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * UI插件导出
3
+ */
4
+ export * from './LoadingPlugin';
5
+ export * from './ErrorPlugin';
6
+ export * from './WebGLContextLostPlugin';
7
+ export * from './FilenameInfoPlugin';
8
+ export * from './SceneTreePlugin';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,187 @@
1
+ import { Ref } from 'vue';
2
+ import { I18nTranslateFunction, LanguageOption, ThemeConfig, ViewerContext } from '../core';
3
+ import { PluginsConfig } from '../plugins';
4
+ /** 工具栏组件Props */
5
+ export interface PluginToolbarProps {
6
+ /** 查看器上下文 */
7
+ ctx: ViewerContext;
8
+ /** 自定义类名 */
9
+ class?: string | string[];
10
+ /** i18n 版本号(locale 变更时递增,用于清空 renderCache) */
11
+ localeVersion?: number | Ref<number>;
12
+ }
13
+ /** 工具栏扩展区Props */
14
+ export interface ToolbarExtensionProps {
15
+ /** 查看器上下文 */
16
+ ctx: ViewerContext;
17
+ /** 自定义类名 */
18
+ class?: string | string[];
19
+ /** 背景色 */
20
+ background?: string;
21
+ /** 圆角(px),默认 8 */
22
+ borderRadius?: number;
23
+ /** 内边距(px),默认 4 8 */
24
+ padding?: string;
25
+ /** 分隔线颜色 */
26
+ separatorColor?: string;
27
+ /** 按钮间距(px),默认 2 */
28
+ gap?: number;
29
+ }
30
+ /** 工具栏信息区Props */
31
+ export interface ToolbarInfoPanelProps {
32
+ /** 查看器上下文 */
33
+ ctx: ViewerContext;
34
+ /** 自定义类名 */
35
+ class?: string | string[];
36
+ /** 背景色 */
37
+ background?: string;
38
+ /** 圆角(px),默认 8 */
39
+ borderRadius?: number;
40
+ /** 内边距(px),默认 4 8 */
41
+ padding?: string;
42
+ /** 字体大小,默认 12px */
43
+ fontSize?: number;
44
+ /** 最大高度(px),超出后滚动,默认 120 */
45
+ maxHeight?: number;
46
+ }
47
+ /** 工具栏配置 */
48
+ export interface ToolbarConfig {
49
+ /** 图标尺寸(px),默认 20 */
50
+ iconSize?: number;
51
+ /** 按钮尺寸(px),默认 32 */
52
+ buttonSize?: number;
53
+ /** 背景色,默认 rgba(167, 165, 165, 0.6) */
54
+ background?: string;
55
+ /** 圆角(px),默认 8 */
56
+ borderRadius?: number;
57
+ /** 内边距(px),默认 8 */
58
+ padding?: number;
59
+ /** 按钮间距(px),默认 2 */
60
+ gap?: number;
61
+ /** 按钮背景色,默认 rgba(255, 255, 255, 0.06) */
62
+ buttonBackground?: string;
63
+ /** 按钮圆角(px),默认 6 */
64
+ buttonBorderRadius?: number;
65
+ /** 分隔线颜色,默认 rgba(255, 255, 255, 0.2) */
66
+ separatorColor?: string;
67
+ }
68
+ /** UI插件配置 */
69
+ export interface UIConfig {
70
+ /** 没有模型时是否隐藏UI插件,默认 false */
71
+ hideWhenNoModel?: boolean;
72
+ }
73
+ /** 信息面板配置 */
74
+ export interface InfoPanelConfig {
75
+ /** 是否显示信息面板,默认 true */
76
+ show?: boolean;
77
+ /** 背景色 */
78
+ background?: string;
79
+ /** 圆角(px),默认 8 */
80
+ borderRadius?: number;
81
+ /** 内边距,默认 '4px 8px' */
82
+ padding?: string;
83
+ /** 字体大小(px),默认 12 */
84
+ fontSize?: number;
85
+ /** 最大高度(px),默认 120 */
86
+ maxHeight?: number;
87
+ }
88
+ /** 数据源类型 */
89
+ export type VtkViewerSource = File | string | ArrayBuffer | ReadableStream;
90
+ /** VtkViewer组件属性 */
91
+ export interface VtkViewerProps {
92
+ /** 默认背景色(响应式,支持外部动态修改)
93
+ * @default '#e6e6e6'
94
+ */
95
+ background?: string;
96
+ /** 自定义类名 */
97
+ class?: string | string[];
98
+ /** 工具栏配置,false 则隐藏工具栏 */
99
+ toolbar?: ToolbarConfig | boolean;
100
+ /** 传递到 PluginToolbar 的自定义 CSS class */
101
+ toolbarClass?: string | string[];
102
+ /** 信息面板配置,false 则隐藏信息面板 */
103
+ infoPanel?: InfoPanelConfig | boolean;
104
+ /** 传递到 ToolbarInfoPanel 的自定义 CSS class */
105
+ toolbarInfoPanelClass?: string | string[];
106
+ /** 传递到 ToolbarExtension 的自定义 CSS class */
107
+ toolbarExtensionClass?: string | string[];
108
+ /** UI插件配置 */
109
+ ui?: UIConfig;
110
+ /**
111
+ * 插件配置(高优先级)
112
+ * 采用分类配置格式,按插件类型分组:
113
+ * - format: 格式插件
114
+ * - toolbar: 工具栏插件
115
+ * - ui: UI 插件
116
+ * - service: 服务插件
117
+ *
118
+ * 当 ctx 由外部传入时,同分类配置将覆盖 useViewer 中的默认配置。
119
+ * 当 ctx 由内部创建时,作为 useViewer 的 plugins 参数。
120
+ */
121
+ plugins?: PluginsConfig;
122
+ /**
123
+ * 数据源(File/URL/ArrayBuffer/ReadableStream),组件内部自动加载
124
+ * 设置后外部无需手动调用 loadFile 等操作
125
+ */
126
+ source?: VtkViewerSource | null;
127
+ /**
128
+ * 数据源格式(可选,但建议提供)
129
+ * 当 source 为 File 或 URL 时,可以从文件扩展名自动检测
130
+ * 当 source 为 ArrayBuffer 或 ReadableStream 时,建议提供此参数
131
+ * 如果不提供,内部会尝试使用魔数(magic number)进行格式探测
132
+ */
133
+ sourceFormat?: string;
134
+ /** 数据源文件名(当 source 为 ArrayBuffer 或 ReadableStream 时可选,用于格式检测) */
135
+ sourceFilename?: string;
136
+ /** 主题ID(如 'dark', 'light', 'ocean', 'forest', 'sunset')
137
+ * @default 'light'
138
+ */
139
+ theme?: string;
140
+ /** 自定义主题配置(格式与内置主题一致,同名覆盖内置主题) */
141
+ customThemes?: Record<string, ThemeConfig>;
142
+ /**
143
+ * 国际化翻译函数(外部注入)。
144
+ * 不传时所有字符串原样使用 key 作为 fallback。
145
+ * key 格式:`vtkviewer.模块.子键`(如 `vtkviewer.toolbar.rotate.title`)
146
+ */
147
+ t?: I18nTranslateFunction | null;
148
+ /**
149
+ * 当前语言标识(如 'zh', 'en')。
150
+ * 变更时触发 renderCache 清理和组件重渲染。
151
+ * @default 'zh'
152
+ */
153
+ locale?: string;
154
+ /**
155
+ * 可用语言列表。
156
+ * 传递给 LanguageSwitchPlugin,未传时默认 [{ id:'zh', label:'中文' }, { id:'en', label:'English' }]。
157
+ */
158
+ languages?: LanguageOption[];
159
+ /**
160
+ * 外部解码器路径配置。
161
+ * 键为解码器标识,值为 JS 文件路径(本地 public/ 路径或 CDN URL)。
162
+ * 支持的标识:
163
+ * - draco: Draco 解码器,对应 draco_decoder.js
164
+ * - ifc: IFC 解码器(预留),对应 web-ifc.js
165
+ * 未配置时插件会尝试动态 import 对应的 npm 包。
166
+ */
167
+ decoders?: Record<string, string>;
168
+ /**
169
+ * 是否启用调试日志输出。
170
+ * 开启后会在控制台输出插件初始化、过程追踪等调试信息。
171
+ * 生产环境建议保持关闭。
172
+ * @default false
173
+ */
174
+ debug?: boolean;
175
+ /**
176
+ * 是否启用手势控制(触摸/捏合/旋转等触屏交互)。
177
+ * 设置为 false 时,即使硬件支持触屏,手势交互也不会启用。
178
+ * @default true。
179
+ */
180
+ enableGesture?: boolean;
181
+ /**
182
+ * 是否启用键盘控制(相机 WASD 导航和所有插件快捷键)。
183
+ * 设置为 false 时,所有键盘快捷键失效且不在 tooltip 中显示。
184
+ * @default true。
185
+ */
186
+ enableKeyboard?: boolean;
187
+ }