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.
- package/LICENSE +21 -0
- package/README.en.md +753 -0
- package/README.md +1760 -0
- package/lib/types/components/PluginToolbar.vue.d.ts +7 -0
- package/lib/types/components/ToolbarExtension.vue.d.ts +9 -0
- package/lib/types/components/ToolbarInfoPanel.vue.d.ts +10 -0
- package/lib/types/components/VtkViewer.vue.d.ts +32 -0
- package/lib/types/components/index.d.ts +4 -0
- package/lib/types/composables/index.d.ts +7 -0
- package/lib/types/composables/useFormatLoader.d.ts +33 -0
- package/lib/types/composables/useResponsiveLayout.d.ts +46 -0
- package/lib/types/composables/useUIPlugins.d.ts +57 -0
- package/lib/types/composables/useViewer.d.ts +47 -0
- package/lib/types/configs/index.d.ts +76 -0
- package/lib/types/core/CommandRegistrar.d.ts +12 -0
- package/lib/types/core/CommandRegistry.d.ts +34 -0
- package/lib/types/core/ConfigAccessor.d.ts +33 -0
- package/lib/types/core/DisposalRegistry.d.ts +32 -0
- package/lib/types/core/EventBus.d.ts +79 -0
- package/lib/types/core/FormatDetector.d.ts +59 -0
- package/lib/types/core/I18nManager.d.ts +135 -0
- package/lib/types/core/InteractionSubContext.d.ts +73 -0
- package/lib/types/core/RenderSubContext.d.ts +74 -0
- package/lib/types/core/ResetManager.d.ts +122 -0
- package/lib/types/core/ResetRegistry.d.ts +170 -0
- package/lib/types/core/SceneSubContext.d.ts +25 -0
- package/lib/types/core/StateManager.d.ts +104 -0
- package/lib/types/core/ThemeContext.d.ts +37 -0
- package/lib/types/core/ToolbarExtensionRegistry.d.ts +105 -0
- package/lib/types/core/ToolbarInfoRegistry.d.ts +77 -0
- package/lib/types/core/UISubContext.d.ts +32 -0
- package/lib/types/core/ViewerContext.d.ts +101 -0
- package/lib/types/core/ViewerContextBuilder.d.ts +57 -0
- package/lib/types/core/createViewerContext.d.ts +26 -0
- package/lib/types/core/index.d.ts +23 -0
- package/lib/types/icons/index.d.ts +47 -0
- package/lib/types/index.d.ts +7 -0
- package/lib/types/plugins/PluginBase.d.ts +131 -0
- package/lib/types/plugins/PluginRegistry.d.ts +67 -0
- package/lib/types/plugins/defaults.d.ts +3 -0
- package/lib/types/plugins/format/DrcPlugin.d.ts +30 -0
- package/lib/types/plugins/format/GlbPlugin.d.ts +23 -0
- package/lib/types/plugins/format/ObjPlugin.d.ts +23 -0
- package/lib/types/plugins/format/PdbPlugin.d.ts +33 -0
- package/lib/types/plugins/format/PlyPlugin.d.ts +24 -0
- package/lib/types/plugins/format/StlPlugin.d.ts +25 -0
- package/lib/types/plugins/format/VtiPlugin.d.ts +60 -0
- package/lib/types/plugins/format/VtpPlugin.d.ts +24 -0
- package/lib/types/plugins/format/VtuPlugin.d.ts +25 -0
- package/lib/types/plugins/format/ZipPlugin.d.ts +38 -0
- package/lib/types/plugins/format/index.d.ts +13 -0
- package/lib/types/plugins/index.d.ts +13 -0
- package/lib/types/plugins/injectionKeys.d.ts +22 -0
- package/lib/types/plugins/pluginUtils.d.ts +61 -0
- package/lib/types/plugins/service/DragDropPlugin.d.ts +94 -0
- package/lib/types/plugins/service/KeyBindingPlugin.d.ts +83 -0
- package/lib/types/plugins/service/MemoryPressurePlugin.d.ts +68 -0
- package/lib/types/plugins/service/index.d.ts +6 -0
- package/lib/types/plugins/toolbar/animation/AnimationPlugin.d.ts +34 -0
- package/lib/types/plugins/toolbar/animation/index.d.ts +1 -0
- package/lib/types/plugins/toolbar/index.d.ts +9 -0
- package/lib/types/plugins/toolbar/interaction/CenterModelPlugin.d.ts +21 -0
- package/lib/types/plugins/toolbar/interaction/FullscreenPlugin.d.ts +27 -0
- package/lib/types/plugins/toolbar/interaction/PanPlugin.d.ts +24 -0
- package/lib/types/plugins/toolbar/interaction/ResetAllPlugin.d.ts +25 -0
- package/lib/types/plugins/toolbar/interaction/RotatePlugin.d.ts +24 -0
- package/lib/types/plugins/toolbar/interaction/ViewSelectPlugin.d.ts +26 -0
- package/lib/types/plugins/toolbar/interaction/ZoomPlugin.d.ts +24 -0
- package/lib/types/plugins/toolbar/interaction/index.d.ts +7 -0
- package/lib/types/plugins/toolbar/model/ClippingPlugin.d.ts +87 -0
- package/lib/types/plugins/toolbar/model/ColorByPlugin.d.ts +113 -0
- package/lib/types/plugins/toolbar/model/LoadModelPlugin.d.ts +93 -0
- package/lib/types/plugins/toolbar/model/RenderPrecisionPlugin.d.ts +68 -0
- package/lib/types/plugins/toolbar/model/RenderStylePlugin.d.ts +88 -0
- package/lib/types/plugins/toolbar/model/UnloadModelPlugin.d.ts +25 -0
- package/lib/types/plugins/toolbar/model/index.d.ts +6 -0
- package/lib/types/plugins/toolbar/scene/AxesPlugin.d.ts +96 -0
- package/lib/types/plugins/toolbar/scene/BackgroundColorPlugin.d.ts +25 -0
- package/lib/types/plugins/toolbar/scene/LanguageSwitchPlugin.d.ts +45 -0
- package/lib/types/plugins/toolbar/scene/LightIntensityPlugin.d.ts +42 -0
- package/lib/types/plugins/toolbar/scene/RenderGridPlugin.d.ts +98 -0
- package/lib/types/plugins/toolbar/scene/ThemeSwitchPlugin.d.ts +49 -0
- package/lib/types/plugins/toolbar/scene/index.d.ts +6 -0
- package/lib/types/plugins/toolbar/tools/BookmarkPlugin.d.ts +70 -0
- package/lib/types/plugins/toolbar/tools/MeasurementPlugin.d.ts +112 -0
- package/lib/types/plugins/toolbar/tools/PerformancePlugin.d.ts +55 -0
- package/lib/types/plugins/toolbar/tools/ScreenshotPlugin.d.ts +58 -0
- package/lib/types/plugins/toolbar/tools/index.d.ts +4 -0
- package/lib/types/plugins/toolbar/utils.d.ts +67 -0
- package/lib/types/plugins/types/index.d.ts +250 -0
- package/lib/types/plugins/ui/ErrorPlugin.d.ts +30 -0
- package/lib/types/plugins/ui/FilenameInfoPlugin.d.ts +40 -0
- package/lib/types/plugins/ui/LoadingPlugin.d.ts +28 -0
- package/lib/types/plugins/ui/SceneTreePlugin.d.ts +60 -0
- package/lib/types/plugins/ui/WebGLContextLostPlugin.d.ts +33 -0
- package/lib/types/plugins/ui/index.d.ts +8 -0
- package/lib/types/polyfills.d.ts +1 -0
- package/lib/types/types/index.d.ts +187 -0
- package/lib/types/types/vtk-modules.d.ts +80 -0
- package/lib/types/utils/asyncUtils.d.ts +8 -0
- package/lib/types/utils/colorByUtils.d.ts +55 -0
- package/lib/types/utils/debugLog.d.ts +13 -0
- package/lib/types/utils/errorHandler.d.ts +28 -0
- package/lib/types/utils/index.d.ts +10 -0
- package/lib/types/utils/sceneUtils.d.ts +11 -0
- package/lib/types/utils/themeManager.d.ts +78 -0
- package/lib/types/utils/volumeUtils.d.ts +14 -0
- package/lib/types/utils/vtkHelpers.d.ts +46 -0
- package/lib/types/utils/vtuLoader.d.ts +26 -0
- package/lib/types/utils/zipReader.d.ts +71 -0
- package/lib/vtkviewer.css +2 -0
- package/lib/vtkviewer.js +54714 -0
- package/lib/vtkviewer.umd.cjs +4560 -0
- package/package.json +89 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { CommandHandler, ToolbarExtensionItem, ToolbarInfoItem, ViewerContext } from '../core';
|
|
2
|
+
import { IViewerPlugin, PluginConfig, PluginMetadata, ToolbarPluginGroup } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 插件基类
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class PluginBase<TConfig extends PluginConfig = PluginConfig> implements IViewerPlugin<TConfig> {
|
|
7
|
+
abstract readonly metadata: PluginMetadata;
|
|
8
|
+
readonly dependencies?: string[];
|
|
9
|
+
readonly initOrder?: number;
|
|
10
|
+
readonly defaultConfig?: TConfig;
|
|
11
|
+
protected ctx: ViewerContext;
|
|
12
|
+
protected config: TConfig;
|
|
13
|
+
/** 事件清理追踪列表(通过 onEvent 注册的事件自动入队) */
|
|
14
|
+
private _eventCleanups;
|
|
15
|
+
/** 点击外部监听器引用,dispose 时自动清理 */
|
|
16
|
+
private _outsideClickHandler;
|
|
17
|
+
private _outsideClickCapture;
|
|
18
|
+
/** 已注册的 infoPanel 项 ID */
|
|
19
|
+
private _infoPanelId;
|
|
20
|
+
/** 已注册的扩展区项 ID */
|
|
21
|
+
private _extensionId;
|
|
22
|
+
/** 已注册的命令 ID 列表 */
|
|
23
|
+
private _commandIds;
|
|
24
|
+
/**
|
|
25
|
+
* 初始化插件
|
|
26
|
+
* 自动合并 defaultConfig 和外部 config
|
|
27
|
+
*/
|
|
28
|
+
init(ctx: ViewerContext, config?: TConfig): void;
|
|
29
|
+
/**
|
|
30
|
+
* 子类重写此方法进行初始化
|
|
31
|
+
* 在 config 合并完成后调用
|
|
32
|
+
*/
|
|
33
|
+
protected onInit(): void;
|
|
34
|
+
/**
|
|
35
|
+
* 释放插件资源。
|
|
36
|
+
* 基类默认实现:自动清理事件监听、点击外部监听器、infoPanel、扩展区,
|
|
37
|
+
* 再调用 onDispose() 钩子。
|
|
38
|
+
* 子类不覆写 dispose(),通过 onDispose() 扩展自定义清理。
|
|
39
|
+
*/
|
|
40
|
+
dispose(): void;
|
|
41
|
+
/**
|
|
42
|
+
* 子类扩展清理钩子
|
|
43
|
+
* 用于释放 VTK 对象、注销命令、移除 DOM 监听器、重置状态等
|
|
44
|
+
*/
|
|
45
|
+
protected onDispose(): void;
|
|
46
|
+
/**
|
|
47
|
+
* 插件是否可见。
|
|
48
|
+
* 子类可重写此方法实现自定义可见性逻辑。
|
|
49
|
+
* 默认行为:若 hideWhenNoModel 为 true 则无模型时隐藏。
|
|
50
|
+
*/
|
|
51
|
+
isVisible(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* 注册事件并自动追踪(推荐替代直接调用 ctx.events.on)
|
|
54
|
+
* 注册的事件会在 dispose() 中统一清理
|
|
55
|
+
* @param event 事件名称
|
|
56
|
+
* @param callback 回调函数
|
|
57
|
+
*/
|
|
58
|
+
protected onEvent(event: string, callback: (...args: any[]) => void): void;
|
|
59
|
+
/**
|
|
60
|
+
* 清理所有通过 onEvent() 注册的事件监听
|
|
61
|
+
*/
|
|
62
|
+
private cleanupEventListeners;
|
|
63
|
+
/**
|
|
64
|
+
* 设置点击外部监听器,dispose() 时自动清理
|
|
65
|
+
* @param handler 点击处理函数
|
|
66
|
+
* @param useCapture 是否使用捕获阶段,默认 true
|
|
67
|
+
*/
|
|
68
|
+
protected setupOutsideClickListener(handler: (e: MouseEvent) => void, useCapture?: boolean): void;
|
|
69
|
+
/** 内部清理点击外部监听 */
|
|
70
|
+
private _teardownOutsideClickListener;
|
|
71
|
+
/**
|
|
72
|
+
* 注册信息面板项。dispose() 时自动注销。
|
|
73
|
+
* @param item 信息面板配置(id 默认为插件 metadata.id,priority 默认为插件 order)
|
|
74
|
+
*/
|
|
75
|
+
protected registerInfoPanelItem(item: Omit<ToolbarInfoItem, 'id'> & {
|
|
76
|
+
id?: string;
|
|
77
|
+
}): void;
|
|
78
|
+
/** 注销信息面板项 */
|
|
79
|
+
protected unregisterInfoPanel(): void;
|
|
80
|
+
/**
|
|
81
|
+
* 注册扩展区项。dispose() 时自动注销。
|
|
82
|
+
* @param item 扩展区配置(id 默认为插件 metadata.id,priority 默认为插件 order)
|
|
83
|
+
*/
|
|
84
|
+
protected registerExtensionItem(item: Omit<ToolbarExtensionItem, 'id'> & {
|
|
85
|
+
id?: string;
|
|
86
|
+
}): void;
|
|
87
|
+
/** 注销扩展区项 */
|
|
88
|
+
protected unregisterExtension(): void;
|
|
89
|
+
/**
|
|
90
|
+
* 注册命令并自动追踪,dispose() 时自动注销
|
|
91
|
+
* @param id 命令 ID
|
|
92
|
+
* @param handler 命令处理器
|
|
93
|
+
*/
|
|
94
|
+
protected registerCommand<T = void>(id: string, handler: CommandHandler<T>): void;
|
|
95
|
+
/** 注销所有通过 registerCommand 注册的命令 */
|
|
96
|
+
private unregisterAllCommands;
|
|
97
|
+
/**
|
|
98
|
+
* 获取配置值
|
|
99
|
+
* @param key 配置键
|
|
100
|
+
* @returns 配置值
|
|
101
|
+
*/
|
|
102
|
+
protected getConfig<K extends keyof TConfig>(key: K): TConfig[K];
|
|
103
|
+
/**
|
|
104
|
+
* 获取完整配置(浅拷贝)
|
|
105
|
+
*/
|
|
106
|
+
protected getConfigAll(): TConfig;
|
|
107
|
+
/**
|
|
108
|
+
* 检查配置中是否包含指定键
|
|
109
|
+
*/
|
|
110
|
+
protected hasConfig(key: keyof TConfig): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* 获取 hideWhenNoModel 配置值
|
|
113
|
+
* 默认 false(没有模型时也显示)
|
|
114
|
+
*/
|
|
115
|
+
getHideWhenNoModel(): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* 获取分组标识(从 config.group 读取)
|
|
118
|
+
* 工具栏插件可通过配置 `{ group: 'core' }` 指定分组
|
|
119
|
+
*/
|
|
120
|
+
getGroup(): ToolbarPluginGroup | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* 调试日志:仅当 debug=true 时输出 console.log
|
|
123
|
+
* @param args 日志参数
|
|
124
|
+
*/
|
|
125
|
+
protected debugLog(...args: any[]): void;
|
|
126
|
+
/**
|
|
127
|
+
* 调试警告:仅当 debug=true 时输出 console.warn
|
|
128
|
+
* @param args 警告参数
|
|
129
|
+
*/
|
|
130
|
+
protected debugWarn(...args: any[]): void;
|
|
131
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { EventBusImpl, ViewerContext } from '../core';
|
|
3
|
+
import { IFormatPlugin, IViewerPlugin, PluginConfig, PluginsConfig } from './types';
|
|
4
|
+
export declare class PluginRegistry {
|
|
5
|
+
private plugins;
|
|
6
|
+
private initialized;
|
|
7
|
+
private configs;
|
|
8
|
+
private registrationOrder;
|
|
9
|
+
private events;
|
|
10
|
+
/** useViewer 默认插件配置(最低优先级) */
|
|
11
|
+
private _defaultPluginConfig;
|
|
12
|
+
/** 响应式就绪标记:所有插件初始化完成后为 true,replaceAll/disposeAll 后为 false */
|
|
13
|
+
readonly pluginsReady: Ref<boolean>;
|
|
14
|
+
/** 格式插件索引缓存(懒构建,插件变更时失效) */
|
|
15
|
+
private _formatCache;
|
|
16
|
+
constructor(events?: EventBusImpl);
|
|
17
|
+
/**
|
|
18
|
+
* 清除所有已注册插件并重新注册
|
|
19
|
+
* 用于 VtkViewer props.plugins 覆盖 useViewer 默认插件的场景
|
|
20
|
+
* @param plugins 要注册的插件列表(扁平格式)
|
|
21
|
+
* @param configs 插件配置映射
|
|
22
|
+
*/
|
|
23
|
+
replaceAll(plugins: IViewerPlugin[], configs?: Map<string, any>): void;
|
|
24
|
+
/**
|
|
25
|
+
* 设置 useViewer 默认插件配置(最低优先级)
|
|
26
|
+
* VtkViewer 可通过 getDefaultPluginConfig() 读取并合并
|
|
27
|
+
*/
|
|
28
|
+
setDefaultPluginConfig(config: PluginsConfig): void;
|
|
29
|
+
/** 获取 useViewer 默认插件配置 */
|
|
30
|
+
getDefaultPluginConfig(): PluginsConfig;
|
|
31
|
+
register(plugin: IViewerPlugin, config?: PluginConfig): void;
|
|
32
|
+
unregister(id: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* 初始化所有已注册的插件
|
|
35
|
+
* @param ctx 查看器上下文(必须提供,用于插件初始化)
|
|
36
|
+
*/
|
|
37
|
+
initAll(ctx: ViewerContext): Promise<void>;
|
|
38
|
+
disposeAll(): void;
|
|
39
|
+
get<T extends IViewerPlugin>(id: string): T | undefined;
|
|
40
|
+
has(id: string): boolean;
|
|
41
|
+
getAll(): IViewerPlugin[];
|
|
42
|
+
/**
|
|
43
|
+
* 构建格式名称 → 格式插件的索引映射(O(1) 查找)
|
|
44
|
+
* 结果被缓存,插件变更时自动失效重建。
|
|
45
|
+
* 同一格式被多个插件支持时,priority 高的胜出。
|
|
46
|
+
*/
|
|
47
|
+
getFormatPluginIndex(): Map<string, IFormatPlugin>;
|
|
48
|
+
/**
|
|
49
|
+
* 获取所有支持的扩展名列表(去重、排序,缓存结果)
|
|
50
|
+
*/
|
|
51
|
+
getSupportedExtensions(): string[];
|
|
52
|
+
/** 失效格式缓存,下次访问时懒重建 */
|
|
53
|
+
private _invalidateFormatCache;
|
|
54
|
+
/** 懒构建格式缓存 */
|
|
55
|
+
private _ensureFormatCache;
|
|
56
|
+
isInitialized(id: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 解析插件初始化顺序
|
|
59
|
+
* 排序规则:依赖关系(拓扑排序) > initOrder > 注册顺序
|
|
60
|
+
*/
|
|
61
|
+
private resolveInitOrder;
|
|
62
|
+
/**
|
|
63
|
+
* 带优先级的拓扑排序
|
|
64
|
+
* 保证依赖关系的同时,同层插件按 initOrder 和注册顺序排序
|
|
65
|
+
*/
|
|
66
|
+
private topologicalSortWithOrder;
|
|
67
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IFormatPlugin, FormatParseResult, PluginConfig } from '../types';
|
|
2
|
+
import { PluginBase } from '../PluginBase';
|
|
3
|
+
/**
|
|
4
|
+
* DRC格式插件
|
|
5
|
+
* 支持 Draco 压缩格式
|
|
6
|
+
*/
|
|
7
|
+
export declare class DrcPlugin extends PluginBase<PluginConfig> implements IFormatPlugin {
|
|
8
|
+
readonly metadata: {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
type: "format";
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
readonly formats: string[];
|
|
15
|
+
readonly priority = 10;
|
|
16
|
+
dispose(): void;
|
|
17
|
+
canHandle(format: string): boolean;
|
|
18
|
+
parse(arrayBuffer: ArrayBuffer, _format: string, _options?: Record<string, any>): Promise<FormatParseResult>;
|
|
19
|
+
/**
|
|
20
|
+
* 确保 Draco 解码器已初始化
|
|
21
|
+
*
|
|
22
|
+
* 解码器加载顺序:
|
|
23
|
+
* 1. 检查 vtkDracoReader 是否已有解码器
|
|
24
|
+
* 2. 从 ctx.decoders.draco 读取路径(如有),通过 <script> 动态加载
|
|
25
|
+
* 3. 尝试动态 import('draco3d') 使用 npm 包
|
|
26
|
+
*/
|
|
27
|
+
private ensureDracoDecoderReady;
|
|
28
|
+
private initDecoder;
|
|
29
|
+
private loadFromScript;
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IFormatPlugin, FormatParseResult, PluginConfig } from '../types';
|
|
2
|
+
import { PluginBase } from '../PluginBase';
|
|
3
|
+
/** GLB格式插件配置 */
|
|
4
|
+
export interface GlbPluginConfig extends PluginConfig {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* GLB格式插件
|
|
8
|
+
* 仅支持 GLB 二进制格式
|
|
9
|
+
*/
|
|
10
|
+
export declare class GlbPlugin extends PluginBase<GlbPluginConfig> implements IFormatPlugin {
|
|
11
|
+
readonly metadata: {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
type: "format";
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
readonly formats: string[];
|
|
18
|
+
readonly priority = 10;
|
|
19
|
+
readonly defaultConfig: GlbPluginConfig;
|
|
20
|
+
dispose(): void;
|
|
21
|
+
canHandle(format: string): boolean;
|
|
22
|
+
parse(arrayBuffer: ArrayBuffer, format: string, _options?: Record<string, any>): Promise<FormatParseResult>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IFormatPlugin, FormatParseResult, PluginConfig } from '../types';
|
|
2
|
+
import { PluginBase } from '../PluginBase';
|
|
3
|
+
/** OBJ格式插件配置 */
|
|
4
|
+
export interface ObjPluginConfig extends PluginConfig {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* OBJ格式插件
|
|
8
|
+
* 支持 OBJ 格式
|
|
9
|
+
*/
|
|
10
|
+
export declare class ObjPlugin extends PluginBase<ObjPluginConfig> implements IFormatPlugin {
|
|
11
|
+
readonly metadata: {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
type: "format";
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
readonly formats: string[];
|
|
18
|
+
readonly priority = 10;
|
|
19
|
+
readonly defaultConfig: ObjPluginConfig;
|
|
20
|
+
dispose(): void;
|
|
21
|
+
canHandle(format: string): boolean;
|
|
22
|
+
parse(arrayBuffer: ArrayBuffer, _format: string, _options?: Record<string, any>): Promise<FormatParseResult>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IFormatPlugin, FormatParseResult, PluginConfig } from '../types';
|
|
2
|
+
import { PluginBase } from '../PluginBase';
|
|
3
|
+
/** PDB格式插件配置 */
|
|
4
|
+
export interface PdbPluginConfig extends PluginConfig {
|
|
5
|
+
/** 原子半径缩放因子 */
|
|
6
|
+
atomicRadiusScaleFactor?: number;
|
|
7
|
+
/** 化学键半径 */
|
|
8
|
+
bondRadius?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* PDB格式插件
|
|
12
|
+
* 支持 Protein Data Bank 分子格式
|
|
13
|
+
*
|
|
14
|
+
* 渲染管线:
|
|
15
|
+
* PDBReader → Molecule → MoleculeToRepresentation → SphereMapper + StickMapper
|
|
16
|
+
*/
|
|
17
|
+
export declare class PdbPlugin extends PluginBase<PdbPluginConfig> implements IFormatPlugin {
|
|
18
|
+
readonly metadata: {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
type: "format";
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
readonly formats: string[];
|
|
25
|
+
readonly priority = 10;
|
|
26
|
+
readonly defaultConfig: PdbPluginConfig;
|
|
27
|
+
canHandle(format: string): boolean;
|
|
28
|
+
parse(arrayBuffer: ArrayBuffer, _format: string, _options?: Record<string, any>): Promise<FormatParseResult>;
|
|
29
|
+
/**
|
|
30
|
+
* 检查是否包含氢原子
|
|
31
|
+
*/
|
|
32
|
+
private checkForHydrogen;
|
|
33
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IFormatPlugin, FormatParseResult, PluginConfig } from '../types';
|
|
2
|
+
import { PluginBase } from '../PluginBase';
|
|
3
|
+
/** PLY格式插件配置 */
|
|
4
|
+
export interface PlyPluginConfig extends PluginConfig {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* PLY格式插件
|
|
8
|
+
* 支持 PLY 格式(ASCII 和二进制)
|
|
9
|
+
* 支持顶点颜色和标量数据颜色映射
|
|
10
|
+
*/
|
|
11
|
+
export declare class PlyPlugin extends PluginBase<PlyPluginConfig> implements IFormatPlugin {
|
|
12
|
+
readonly metadata: {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
type: "format";
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
readonly formats: string[];
|
|
19
|
+
readonly priority = 10;
|
|
20
|
+
readonly defaultConfig: PlyPluginConfig;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
canHandle(format: string): boolean;
|
|
23
|
+
parse(arrayBuffer: ArrayBuffer, _format: string, _options?: Record<string, any>): Promise<FormatParseResult>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IFormatPlugin, FormatParseResult, PluginConfig } from '../types';
|
|
2
|
+
import { PluginBase } from '../PluginBase';
|
|
3
|
+
/** STL格式插件配置 */
|
|
4
|
+
export interface StlPluginConfig extends PluginConfig {
|
|
5
|
+
/** 是否合并重复点 */
|
|
6
|
+
mergePoints?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* STL格式插件
|
|
10
|
+
* 支持 STL/STLA/STLB 格式
|
|
11
|
+
*/
|
|
12
|
+
export declare class StlPlugin extends PluginBase<StlPluginConfig> implements IFormatPlugin {
|
|
13
|
+
readonly metadata: {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: "format";
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
readonly formats: string[];
|
|
20
|
+
readonly priority = 10;
|
|
21
|
+
readonly defaultConfig: StlPluginConfig;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
canHandle(format: string): boolean;
|
|
24
|
+
parse(arrayBuffer: ArrayBuffer, _format: string, _options?: Record<string, any>): Promise<FormatParseResult>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { IFormatPlugin, FormatParseResult, PluginConfig } from '../types';
|
|
2
|
+
import { PluginBase } from '../PluginBase';
|
|
3
|
+
/** 体渲染传递函数控制点 */
|
|
4
|
+
export interface VolumeTransferPoint {
|
|
5
|
+
/** 在数据范围中的位置 (0-1),0=最小值,1=最大值 */
|
|
6
|
+
position: number;
|
|
7
|
+
/** 该位置的透明度 (0-1) */
|
|
8
|
+
opacity: number;
|
|
9
|
+
}
|
|
10
|
+
/** 体渲染颜色控制点 */
|
|
11
|
+
export interface VolumeColorPoint extends VolumeTransferPoint {
|
|
12
|
+
/** RGB 颜色分量 (0-1) */
|
|
13
|
+
r: number;
|
|
14
|
+
g: number;
|
|
15
|
+
b: number;
|
|
16
|
+
}
|
|
17
|
+
/** 体渲染参数(可在插件注册时配置) */
|
|
18
|
+
export interface VolumeRenderingConfig {
|
|
19
|
+
/** 采样距离缩放因子,越小越精细(性能开销越大),默认 0.7 */
|
|
20
|
+
sampleDistanceScale?: number;
|
|
21
|
+
/** 颜色控制点列表(按 position 排序),不传则用默认冷暖渐变 */
|
|
22
|
+
colorPoints?: VolumeColorPoint[];
|
|
23
|
+
/** 透明度控制点列表(按 position 排序),不传则用默认 S 型曲线 */
|
|
24
|
+
opacityPoints?: VolumeTransferPoint[];
|
|
25
|
+
/** 环境光强度 (0-1),默认 0.2 */
|
|
26
|
+
ambient?: number;
|
|
27
|
+
/** 漫反射强度 (0-1),默认 0.7 */
|
|
28
|
+
diffuse?: number;
|
|
29
|
+
/** 镜面反射强度 (0-1),默认 0.3 */
|
|
30
|
+
specular?: number;
|
|
31
|
+
/** 镜面反射锐度,默认 8.0 */
|
|
32
|
+
specularPower?: number;
|
|
33
|
+
/** 是否启用光照着色,默认 true */
|
|
34
|
+
shade?: boolean;
|
|
35
|
+
/** 梯度透明度最大值的缩放因子(相对于数据范围),默认 0.05 */
|
|
36
|
+
gradientOpacityScale?: number;
|
|
37
|
+
}
|
|
38
|
+
/** VTI格式插件配置 */
|
|
39
|
+
export interface VtiPluginConfig extends PluginConfig {
|
|
40
|
+
/** 体渲染参数 */
|
|
41
|
+
volumeRendering?: VolumeRenderingConfig;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* VTI格式插件
|
|
45
|
+
* 支持 VTK ImageData 格式(体渲染)
|
|
46
|
+
*/
|
|
47
|
+
export declare class VtiPlugin extends PluginBase<VtiPluginConfig> implements IFormatPlugin {
|
|
48
|
+
readonly metadata: {
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
type: "format";
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
readonly formats: string[];
|
|
55
|
+
readonly priority = 10;
|
|
56
|
+
readonly defaultConfig: VtiPluginConfig;
|
|
57
|
+
dispose(): void;
|
|
58
|
+
canHandle(format: string): boolean;
|
|
59
|
+
parse(arrayBuffer: ArrayBuffer, _format: string, _options?: Record<string, any>): Promise<FormatParseResult>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IFormatPlugin, FormatParseResult, PluginConfig } from '../types';
|
|
2
|
+
import { PluginBase } from '../PluginBase';
|
|
3
|
+
/** VTP格式插件配置 */
|
|
4
|
+
export interface VtpPluginConfig extends PluginConfig {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* VTP格式插件
|
|
8
|
+
* 支持 VTK PolyData XML 格式
|
|
9
|
+
* 支持标量数据颜色映射(ColorBy 功能)
|
|
10
|
+
*/
|
|
11
|
+
export declare class VtpPlugin extends PluginBase<VtpPluginConfig> implements IFormatPlugin {
|
|
12
|
+
readonly metadata: {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
type: "format";
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
readonly formats: string[];
|
|
19
|
+
readonly priority = 10;
|
|
20
|
+
readonly defaultConfig: VtpPluginConfig;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
canHandle(format: string): boolean;
|
|
23
|
+
parse(arrayBuffer: ArrayBuffer, _format: string, _options?: Record<string, any>): Promise<FormatParseResult>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IFormatPlugin, FormatParseResult, PluginConfig } from '../types';
|
|
2
|
+
import { PluginBase } from '../PluginBase';
|
|
3
|
+
/** VTU格式插件配置 */
|
|
4
|
+
export interface VtuPluginConfig extends PluginConfig {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* VTU格式插件
|
|
8
|
+
* 支持 VTK UnstructuredGrid XML 格式
|
|
9
|
+
* 通过提取表面多边形转换为 PolyData 进行渲染
|
|
10
|
+
* 支持标量数据颜色映射(ColorBy 功能)
|
|
11
|
+
*/
|
|
12
|
+
export declare class VtuPlugin extends PluginBase<VtuPluginConfig> implements IFormatPlugin {
|
|
13
|
+
readonly metadata: {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: "format";
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
readonly formats: string[];
|
|
20
|
+
readonly priority = 10;
|
|
21
|
+
readonly defaultConfig: VtuPluginConfig;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
canHandle(format: string): boolean;
|
|
24
|
+
parse(arrayBuffer: ArrayBuffer, _format: string, _options?: Record<string, any>): Promise<FormatParseResult>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { IFormatPlugin, FormatParseResult, PluginConfig } from '../types';
|
|
2
|
+
import { PluginBase } from '../PluginBase';
|
|
3
|
+
/** ZIP格式插件配置 */
|
|
4
|
+
export interface ZipPluginConfig extends PluginConfig {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* ZIP格式插件
|
|
8
|
+
* 聚合处理器,支持解压后自动识别内部格式
|
|
9
|
+
* 支持:通用 ZIP、VTK.js 原生 ZIP (.vtkjs)、OBJ+MTL+纹理 ZIP (.obz)
|
|
10
|
+
*/
|
|
11
|
+
export declare class ZipPlugin extends PluginBase<ZipPluginConfig> implements IFormatPlugin {
|
|
12
|
+
readonly metadata: {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
type: "format";
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
readonly formats: string[];
|
|
19
|
+
readonly priority = 5;
|
|
20
|
+
readonly initOrder = 250;
|
|
21
|
+
readonly dependencies: string[];
|
|
22
|
+
readonly defaultConfig: ZipPluginConfig;
|
|
23
|
+
dispose(): void;
|
|
24
|
+
canHandle(format: string): boolean;
|
|
25
|
+
parse(arrayBuffer: ArrayBuffer, format: string, _options?: Record<string, any>): Promise<FormatParseResult>;
|
|
26
|
+
/**
|
|
27
|
+
* 处理 VTK.js 原生 ZIP 格式
|
|
28
|
+
*/
|
|
29
|
+
private handleVtkJsZip;
|
|
30
|
+
/**
|
|
31
|
+
* 处理 OBJ+MTL+纹理的 ZIP 包
|
|
32
|
+
*/
|
|
33
|
+
private handleObjBundleZip;
|
|
34
|
+
/**
|
|
35
|
+
* 处理通用 ZIP 格式
|
|
36
|
+
*/
|
|
37
|
+
private handleGenericZip;
|
|
38
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式插件导出
|
|
3
|
+
*/
|
|
4
|
+
export * from './StlPlugin';
|
|
5
|
+
export * from './ObjPlugin';
|
|
6
|
+
export * from './PlyPlugin';
|
|
7
|
+
export * from './VtpPlugin';
|
|
8
|
+
export * from './VtuPlugin';
|
|
9
|
+
export * from './VtiPlugin';
|
|
10
|
+
export * from './GlbPlugin';
|
|
11
|
+
export * from './DrcPlugin';
|
|
12
|
+
export * from './PdbPlugin';
|
|
13
|
+
export * from './ZipPlugin';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件模块导出
|
|
3
|
+
*/
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './pluginUtils';
|
|
6
|
+
export * from './PluginBase';
|
|
7
|
+
export * from './PluginRegistry';
|
|
8
|
+
export * from './injectionKeys';
|
|
9
|
+
export * from './defaults';
|
|
10
|
+
export * from './format';
|
|
11
|
+
export * from './toolbar';
|
|
12
|
+
export * from './ui';
|
|
13
|
+
export * from './service';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InjectionKey } from 'vue';
|
|
2
|
+
import { CommandRegistry, EventBus, IStateManager, ViewerContext } from '../core';
|
|
3
|
+
/**
|
|
4
|
+
* 状态管理器注入键
|
|
5
|
+
* UI插件通过 inject(stateManagerKey) 访问核心状态和插件状态
|
|
6
|
+
*/
|
|
7
|
+
export declare const stateManagerKey: InjectionKey<IStateManager>;
|
|
8
|
+
/**
|
|
9
|
+
* 命令注册表注入键
|
|
10
|
+
* 插件通过 inject(commandExecutorKey) 执行跨插件命令
|
|
11
|
+
*/
|
|
12
|
+
export declare const commandExecutorKey: InjectionKey<CommandRegistry>;
|
|
13
|
+
/**
|
|
14
|
+
* 事件总线注入键
|
|
15
|
+
* 插件通过 inject(eventBusKey) 进行事件通信
|
|
16
|
+
*/
|
|
17
|
+
export declare const eventBusKey: InjectionKey<EventBus>;
|
|
18
|
+
/**
|
|
19
|
+
* 查看器上下文注入键
|
|
20
|
+
* 提供完整的 ViewerContext,用于需要访问多个子系统的场景
|
|
21
|
+
*/
|
|
22
|
+
export declare const viewerContextKey: InjectionKey<ViewerContext>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { PluginItem, PluginsConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 将插件配置归一化为 PluginsConfig
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizePluginsConfig(plugins: PluginsConfig | undefined): PluginsConfig;
|
|
6
|
+
/**
|
|
7
|
+
* 合并多个插件配置(按优先级从低到高)
|
|
8
|
+
*
|
|
9
|
+
* 规则:同一分类后者 **完全覆盖** 前者
|
|
10
|
+
*
|
|
11
|
+
* @param configs 按优先级从低到高排列的配置列表
|
|
12
|
+
* @returns 合并后的 PluginsConfig
|
|
13
|
+
*/
|
|
14
|
+
export declare function mergePluginsConfig(...configs: (PluginsConfig | undefined)[]): PluginsConfig;
|
|
15
|
+
/**
|
|
16
|
+
* 将 PluginsConfig 展平为 PluginItem[]
|
|
17
|
+
* 顺序:format → toolbar → ui → service
|
|
18
|
+
*/
|
|
19
|
+
export declare function flattenPluginsConfig(config: PluginsConfig): PluginItem[];
|
|
20
|
+
/**
|
|
21
|
+
* 检查 PluginsConfig 是否为空(无任何插件配置)
|
|
22
|
+
*/
|
|
23
|
+
export declare function isPluginsConfigEmpty(config: PluginsConfig): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* PluginConfigMerger — 统一的插件配置合并器
|
|
26
|
+
*
|
|
27
|
+
* 将分散的 normalizePluginsConfig / mergePluginsConfig / flattenPluginsConfig /
|
|
28
|
+
* isPluginsConfigEmpty 封装为单一入口,提供简洁的合并 API。
|
|
29
|
+
*
|
|
30
|
+
* 调用方只需:
|
|
31
|
+
* const merger = new PluginConfigMerger()
|
|
32
|
+
* const plugins = merger.merge(baseConfig, overrideConfig) // => PluginItem[]
|
|
33
|
+
*
|
|
34
|
+
* 内部自动处理归一化、空配置检查、合并、展平。
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const merger = new PluginConfigMerger()
|
|
39
|
+
* const merged = merger.merge(config.plugins, pluginsOverride)
|
|
40
|
+
* for (const item of merged) {
|
|
41
|
+
* registry.register(item)
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare class PluginConfigMerger {
|
|
46
|
+
/**
|
|
47
|
+
* 合并基础配置和覆盖配置,返回最终的 PluginItem[]
|
|
48
|
+
*
|
|
49
|
+
* @param base 基础配置(低优先级)— PluginsConfig | undefined
|
|
50
|
+
* @param override 覆盖配置(高优先级)— PluginsConfig | undefined
|
|
51
|
+
* @returns 合并并展平后的 PluginItem[]
|
|
52
|
+
*/
|
|
53
|
+
merge(base?: PluginsConfig, override?: PluginsConfig): PluginItem[];
|
|
54
|
+
/**
|
|
55
|
+
* 合并配置,返回合并后的 PluginsConfig(未展平)
|
|
56
|
+
* 当调用方需要继续处理分类结构时使用
|
|
57
|
+
*
|
|
58
|
+
* 任一配置为空时,直接返回另一方,避免 mergePluginsConfig 清空有效配置。
|
|
59
|
+
*/
|
|
60
|
+
mergeConfigs(base?: PluginsConfig, override?: PluginsConfig): PluginsConfig;
|
|
61
|
+
}
|