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,7 @@
|
|
|
1
|
+
import { PluginToolbarProps } from '../types';
|
|
2
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, Ref, ComponentProvideOptions } from 'vue';
|
|
3
|
+
declare const __VLS_export: DefineComponent<PluginToolbarProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<PluginToolbarProps> & Readonly<{}>, {
|
|
4
|
+
localeVersion: number | Ref<number>;
|
|
5
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ToolbarExtensionProps } from '../types';
|
|
2
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
3
|
+
declare const __VLS_export: DefineComponent<ToolbarExtensionProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ToolbarExtensionProps> & Readonly<{}>, {
|
|
4
|
+
borderRadius: number;
|
|
5
|
+
padding: string;
|
|
6
|
+
gap: number;
|
|
7
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ToolbarInfoPanelProps } from '../types';
|
|
2
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
3
|
+
declare const __VLS_export: DefineComponent<ToolbarInfoPanelProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ToolbarInfoPanelProps> & Readonly<{}>, {
|
|
4
|
+
borderRadius: number;
|
|
5
|
+
padding: string;
|
|
6
|
+
fontSize: number;
|
|
7
|
+
maxHeight: number;
|
|
8
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ViewerContext, ThemeConfig } from '../core';
|
|
2
|
+
import { InfoPanelConfig, ToolbarConfig, VtkViewerProps } from '../types';
|
|
3
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
4
|
+
declare var __VLS_22: {};
|
|
5
|
+
type __VLS_Slots = {} & {
|
|
6
|
+
default?: (props: typeof __VLS_22) => any;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_base: DefineComponent<VtkViewerProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
9
|
+
"update:theme": (themeId: string) => any;
|
|
10
|
+
"update:locale": (locale: string) => any;
|
|
11
|
+
"update:ctx": (ctx: ViewerContext | null) => any;
|
|
12
|
+
}, string, PublicProps, Readonly<VtkViewerProps> & Readonly<{
|
|
13
|
+
"onUpdate:theme"?: ((themeId: string) => any) | undefined;
|
|
14
|
+
"onUpdate:locale"?: ((locale: string) => any) | undefined;
|
|
15
|
+
"onUpdate:ctx"?: ((ctx: ViewerContext | null) => any) | undefined;
|
|
16
|
+
}>, {
|
|
17
|
+
toolbar: ToolbarConfig | boolean;
|
|
18
|
+
infoPanel: InfoPanelConfig | boolean;
|
|
19
|
+
theme: string;
|
|
20
|
+
enableGesture: boolean;
|
|
21
|
+
enableKeyboard: boolean;
|
|
22
|
+
background: string;
|
|
23
|
+
customThemes: Record<string, ThemeConfig>;
|
|
24
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
25
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
26
|
+
declare const _default: typeof __VLS_export;
|
|
27
|
+
export default _default;
|
|
28
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
29
|
+
new (): {
|
|
30
|
+
$slots: S;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { FormatDetectionResult, ViewerContext } from '../core';
|
|
3
|
+
/** 加载状态 */
|
|
4
|
+
export interface LoadState {
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
progress: number;
|
|
7
|
+
stage: string;
|
|
8
|
+
error: string | null;
|
|
9
|
+
/** 正在解析的文件大小(字节),0 表示未知 */
|
|
10
|
+
fileSize?: number;
|
|
11
|
+
}
|
|
12
|
+
/** useFormatLoader 返回值 */
|
|
13
|
+
export interface UseFormatLoaderReturn {
|
|
14
|
+
/** 加载状态 */
|
|
15
|
+
loadState: Ref<LoadState>;
|
|
16
|
+
/** 加载文件(自动清除旧场景) */
|
|
17
|
+
loadFile: (file: File) => Promise<void>;
|
|
18
|
+
/** 加载 ArrayBuffer(自动清除旧场景) */
|
|
19
|
+
loadBuffer: (buffer: ArrayBuffer, format: string, filename?: string) => Promise<void>;
|
|
20
|
+
/** 检测格式 */
|
|
21
|
+
detectFormat: (filename?: string, buffer?: ArrayBuffer) => FormatDetectionResult | null;
|
|
22
|
+
/** 支持的格式列表 */
|
|
23
|
+
supportedFormats: string[];
|
|
24
|
+
/** 清空场景(移除所有 Actor 和 Volume) */
|
|
25
|
+
clearScene: () => void;
|
|
26
|
+
/** 卸载模型(完整释放资源,复用卸载模型操作) */
|
|
27
|
+
unloadModels: () => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* useFormatLoader 组合式函数
|
|
31
|
+
* 提供文件格式检测和加载能力
|
|
32
|
+
*/
|
|
33
|
+
export declare function useFormatLoader(ctx: ViewerContext): UseFormatLoaderReturn;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Ref, ComputedRef } from 'vue';
|
|
2
|
+
export interface Breakpoint {
|
|
3
|
+
name: string;
|
|
4
|
+
minWidth: number;
|
|
5
|
+
maxWidth?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ResponsiveConfig {
|
|
8
|
+
/** 断点定义 */
|
|
9
|
+
breakpoints?: Breakpoint[];
|
|
10
|
+
/** 是否启用响应式 */
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
/** 工具栏折叠阈值 */
|
|
13
|
+
toolbarCollapseThreshold?: number;
|
|
14
|
+
/** 紧凑模式阈值 */
|
|
15
|
+
compactModeThreshold?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* useResponsiveLayout 组合式函数
|
|
19
|
+
* 提供响应式断点检测和布局适配
|
|
20
|
+
*/
|
|
21
|
+
export declare function useResponsiveLayout(containerRef: Ref<HTMLElement | null>, config?: ResponsiveConfig): {
|
|
22
|
+
windowWidth: Readonly<Ref<number, number>>;
|
|
23
|
+
windowHeight: Readonly<Ref<number, number>>;
|
|
24
|
+
containerWidth: Readonly<Ref<number, number>>;
|
|
25
|
+
containerHeight: Readonly<Ref<number, number>>;
|
|
26
|
+
currentBreakpoint: Readonly<Ref<string, string>>;
|
|
27
|
+
isCompactMode: Readonly<Ref<boolean, boolean>>;
|
|
28
|
+
isToolbarCollapsed: Readonly<Ref<boolean, boolean>>;
|
|
29
|
+
isMobile: ComputedRef<boolean>;
|
|
30
|
+
isTablet: ComputedRef<boolean>;
|
|
31
|
+
isDesktop: ComputedRef<boolean>;
|
|
32
|
+
orientation: ComputedRef<"landscape" | "portrait">;
|
|
33
|
+
aspectRatio: ComputedRef<number>;
|
|
34
|
+
updateBreakpoint: () => void;
|
|
35
|
+
updateContainerSize: () => void;
|
|
36
|
+
getResponsiveClasses: () => string[];
|
|
37
|
+
getResponsiveStyles: () => Record<string, string>;
|
|
38
|
+
getToolbarPosition: () => {
|
|
39
|
+
position: string;
|
|
40
|
+
alignment: string;
|
|
41
|
+
};
|
|
42
|
+
getPanelPosition: (panelType: string) => {
|
|
43
|
+
position: string;
|
|
44
|
+
size: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ComputedRef, Ref, Component } from 'vue';
|
|
2
|
+
import { ViewerContext } from '../core';
|
|
3
|
+
import { IUIPlugin, UIPluginType } from '../plugins';
|
|
4
|
+
/** UI插件渲染项 */
|
|
5
|
+
export interface UIPluginRenderItem {
|
|
6
|
+
/** 插件ID */
|
|
7
|
+
id: string;
|
|
8
|
+
/** 渲染组件 */
|
|
9
|
+
component: Component;
|
|
10
|
+
/** UI类型 */
|
|
11
|
+
uiType: UIPluginType;
|
|
12
|
+
/** 渲染顺序 */
|
|
13
|
+
order: number;
|
|
14
|
+
/** 是否可见 */
|
|
15
|
+
visible: boolean;
|
|
16
|
+
/** 位置 */
|
|
17
|
+
position: string;
|
|
18
|
+
}
|
|
19
|
+
/** Portal 插件渲染项 */
|
|
20
|
+
export interface UIPortalRenderItem {
|
|
21
|
+
/** 插件ID */
|
|
22
|
+
id: string;
|
|
23
|
+
/** 渲染组件 */
|
|
24
|
+
component: Component;
|
|
25
|
+
/** 渲染顺序 */
|
|
26
|
+
order: number;
|
|
27
|
+
/** 是否可见 */
|
|
28
|
+
visible: boolean;
|
|
29
|
+
/** Teleport 目标 */
|
|
30
|
+
portalTarget: string | Element;
|
|
31
|
+
/** Teleport 额外属性 */
|
|
32
|
+
portalProps: Record<string, any>;
|
|
33
|
+
}
|
|
34
|
+
/** useUIPlugins 返回值 */
|
|
35
|
+
export interface UseUIPluginsReturn {
|
|
36
|
+
/** 所有UI插件 */
|
|
37
|
+
uiPlugins: ComputedRef<IUIPlugin[]>;
|
|
38
|
+
/** 覆盖层插件 */
|
|
39
|
+
overlayPlugins: ComputedRef<UIPluginRenderItem[]>;
|
|
40
|
+
/** 面板插件 */
|
|
41
|
+
panelPlugins: ComputedRef<UIPluginRenderItem[]>;
|
|
42
|
+
/** 通知插件 */
|
|
43
|
+
notificationPlugins: ComputedRef<UIPluginRenderItem[]>;
|
|
44
|
+
/** Portal 插件(挂载到外部 DOM) */
|
|
45
|
+
portalPlugins: ComputedRef<UIPortalRenderItem[]>;
|
|
46
|
+
/** 获取可见的UI插件 */
|
|
47
|
+
getVisiblePlugins: (type?: UIPluginType) => UIPluginRenderItem[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* useUIPlugins 组合式函数
|
|
51
|
+
* 管理UI插件的渲染和状态
|
|
52
|
+
* @param ctx ViewerContext 或 ComputedRef<ViewerContext | null>,支持响应式
|
|
53
|
+
*/
|
|
54
|
+
export declare function useUIPlugins(ctx: ViewerContext | Ref<ViewerContext | null> | null, options?: {
|
|
55
|
+
hideWhenNoModel?: boolean;
|
|
56
|
+
localeVersion?: Ref<number>;
|
|
57
|
+
}): UseUIPluginsReturn;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { ThemeContextImpl, ViewerContext } from '../core';
|
|
3
|
+
import { IViewerPlugin, PluginConfig, PluginsConfig } from '../plugins';
|
|
4
|
+
/** useViewer 配置 */
|
|
5
|
+
export interface UseViewerConfig {
|
|
6
|
+
/** 初始配置 */
|
|
7
|
+
config?: Record<string, any>;
|
|
8
|
+
/**
|
|
9
|
+
* 插件配置(默认列表,最低优先级)
|
|
10
|
+
* 采用分类配置格式。
|
|
11
|
+
*
|
|
12
|
+
* 当 VtkViewer 组件传入 plugins prop 时,
|
|
13
|
+
* 同分类配置将覆盖此处的配置。
|
|
14
|
+
*/
|
|
15
|
+
plugins?: PluginsConfig;
|
|
16
|
+
/** 外部解码器路径配置 */
|
|
17
|
+
decoders?: Record<string, string>;
|
|
18
|
+
/** 容器元素引用 */
|
|
19
|
+
containerRef?: Ref<HTMLElement | null>;
|
|
20
|
+
}
|
|
21
|
+
/** useViewer 返回值 */
|
|
22
|
+
export interface UseViewerReturn {
|
|
23
|
+
/** 查看器上下文 */
|
|
24
|
+
ctx: Ref<ViewerContext | null>;
|
|
25
|
+
/** 是否已初始化 */
|
|
26
|
+
isReady: Ref<boolean>;
|
|
27
|
+
/** 错误信息 */
|
|
28
|
+
error: Ref<string | null>;
|
|
29
|
+
/** 主题上下文(setup 阶段立即可用,不依赖 initialize) */
|
|
30
|
+
themeContext: ThemeContextImpl;
|
|
31
|
+
/**
|
|
32
|
+
* 初始化查看器
|
|
33
|
+
* @param pluginsOverride 插件覆盖配置(高优先级,同分类覆盖 useViewer 默认配置)
|
|
34
|
+
*/
|
|
35
|
+
initialize: (pluginsOverride?: PluginsConfig) => Promise<void>;
|
|
36
|
+
/** 销毁查看器 */
|
|
37
|
+
destroy: () => void;
|
|
38
|
+
/** 注册插件 */
|
|
39
|
+
registerPlugin: (plugin: IViewerPlugin, config?: PluginConfig) => void;
|
|
40
|
+
/** 加载文件 */
|
|
41
|
+
loadFile: (file: File) => Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* useViewer 组合式函数
|
|
45
|
+
* 创建和管理完整的 ViewerContext
|
|
46
|
+
*/
|
|
47
|
+
export declare function useViewer(config?: UseViewerConfig): UseViewerReturn;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ThemeConfig } from '../core';
|
|
2
|
+
/**
|
|
3
|
+
* VtkViewer 内置语言包。
|
|
4
|
+
* 当外部未注入 t 函数时,PluginBase.t() 从此处按当前 locale 取值作为 fallback。
|
|
5
|
+
*
|
|
6
|
+
* 所有 value 均为纯静态字符串,不包含 {param} 插值占位符。
|
|
7
|
+
* 带参数的文本(如快捷键组合)由调用方手动拼接。
|
|
8
|
+
*/
|
|
9
|
+
export declare const BUILTIN_LANGS: Record<string, Record<string, string>>;
|
|
10
|
+
/**
|
|
11
|
+
* 内置事件常量
|
|
12
|
+
*/
|
|
13
|
+
export declare const BuiltinEvents: {
|
|
14
|
+
readonly SCENE_LOADED: "scene:loaded";
|
|
15
|
+
readonly SCENE_CLEARED: "scene:cleared";
|
|
16
|
+
readonly RENDER_START: "render:start";
|
|
17
|
+
readonly RENDER_END: "render:end";
|
|
18
|
+
readonly RENDER_PIPELINE_READY: "render:pipelineReady";
|
|
19
|
+
readonly TOOL_CHANGED: "interaction:toolChanged";
|
|
20
|
+
readonly MEASUREMENT_START: "measurement:start";
|
|
21
|
+
readonly MEASUREMENT_COMPLETE: "measurement:complete";
|
|
22
|
+
readonly MEASUREMENT_CLEAR: "measurement:clear";
|
|
23
|
+
readonly COLORBY_PICKING_START: "colorBy:pickingStart";
|
|
24
|
+
readonly ANIMATION_PLAY: "animation:play";
|
|
25
|
+
readonly ANIMATION_PAUSE: "animation:pause";
|
|
26
|
+
readonly VOLUME_PRESET_CHANGED: "volume:presetChanged";
|
|
27
|
+
readonly COLOR_ARRAY_CHANGED: "colorBy:arrayChanged";
|
|
28
|
+
readonly PERFORMANCE_UPDATE: "performance:update";
|
|
29
|
+
readonly PLUGINS_INITIALIZED: "plugins:initialized";
|
|
30
|
+
readonly KEY_BINDING_REGISTRY_READY: "keyBinding:registry-ready";
|
|
31
|
+
readonly ERROR_OCCURRED: "error:occurred";
|
|
32
|
+
readonly ERROR_CLEARED: "error:cleared";
|
|
33
|
+
readonly WEBGL_CONTEXT_LOST: "webgl:contextLost";
|
|
34
|
+
readonly WEBGL_CONTEXT_RESTORED: "webgl:contextRestored";
|
|
35
|
+
readonly MEMORY_PRESSURE_CHANGED: "memory:pressureChanged";
|
|
36
|
+
readonly MEMORY_CLEANUP: "memory:cleanup";
|
|
37
|
+
readonly THEME_CHANGED: "theme:changed";
|
|
38
|
+
readonly LOCALE_CHANGED: "locale:changed";
|
|
39
|
+
readonly FILE_LOAD: "file:load";
|
|
40
|
+
readonly FILES_LOAD: "files:load";
|
|
41
|
+
readonly RESET_START: "reset:start";
|
|
42
|
+
readonly RESET_COMPLETE: "reset:complete";
|
|
43
|
+
};
|
|
44
|
+
export type BuiltinEventType = (typeof BuiltinEvents)[keyof typeof BuiltinEvents];
|
|
45
|
+
/**
|
|
46
|
+
* 内置命令常量
|
|
47
|
+
* 命令ID命名规范:{pluginId}:{commandName}
|
|
48
|
+
*/
|
|
49
|
+
export declare const BuiltinCommands: {
|
|
50
|
+
readonly RENDER: "render";
|
|
51
|
+
readonly RESET_CAMERA: "resetCamera";
|
|
52
|
+
readonly RESET_TO_DEFAULT_VIEW: "resetToDefaultView";
|
|
53
|
+
readonly RESET_ALL: "resetAll";
|
|
54
|
+
readonly SET_CAMERA_VIEW: "setCameraView";
|
|
55
|
+
readonly RESTORE_CAMERA: "restoreCamera";
|
|
56
|
+
readonly TOGGLE_TOOL: "toggleTool";
|
|
57
|
+
readonly CAPTURE_SCREENSHOT: "captureScreenshot";
|
|
58
|
+
readonly TOGGLE_FULLSCREEN: "toggleFullscreen";
|
|
59
|
+
readonly TOGGLE_AXES: "toggleAxes";
|
|
60
|
+
readonly SET_BACKGROUND_COLOR: "setBackgroundColor";
|
|
61
|
+
readonly APPLY_VIEW_PRESET: "applyViewPreset";
|
|
62
|
+
readonly START_MEASUREMENT: "startMeasurement";
|
|
63
|
+
readonly CLEAR_MEASUREMENT: "clearMeasurement";
|
|
64
|
+
readonly PLAY_ANIMATION: "playAnimation";
|
|
65
|
+
readonly PAUSE_ANIMATION: "pauseAnimation";
|
|
66
|
+
readonly GO_TO_FRAME: "goToFrame";
|
|
67
|
+
readonly SET_VOLUME_PRESET: "setVolumePreset";
|
|
68
|
+
readonly SET_VOLUME_QUALITY: "setVolumeQuality";
|
|
69
|
+
readonly SET_COLOR_BY_ARRAY: "setColorByArray";
|
|
70
|
+
readonly GET_PERFORMANCE_DATA: "getPerformanceData";
|
|
71
|
+
readonly RETRY_LOAD: "retryLoad";
|
|
72
|
+
readonly DISMISS_ERROR: "dismissError";
|
|
73
|
+
};
|
|
74
|
+
export type BuiltinCommandType = (typeof BuiltinCommands)[keyof typeof BuiltinCommands];
|
|
75
|
+
/** 内置主题预设(只用于 UI 显示,状态管理在 ctx.theme 中) */
|
|
76
|
+
export declare const BUILTIN_THEMES: Record<string, ThemeConfig>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CommandRegistry } from './CommandRegistry';
|
|
2
|
+
import { RenderSubContext } from './RenderSubContext';
|
|
3
|
+
import { SceneSubContext } from './SceneSubContext';
|
|
4
|
+
import { InteractionSubContext } from './InteractionSubContext';
|
|
5
|
+
import { UISubContext } from './UISubContext';
|
|
6
|
+
import { IStateManager } from './StateManager';
|
|
7
|
+
import { ResetManager } from './ResetManager';
|
|
8
|
+
/**
|
|
9
|
+
* 注册内置核心命令
|
|
10
|
+
* 将 BuiltinCommands 中的命令委托给各子上下文
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerCoreBuiltinCommands(commands: CommandRegistry, renderCtx: RenderSubContext, _sceneCtx: SceneSubContext, interactionCtx: InteractionSubContext, uiCtx: UISubContext, resetManager: ResetManager, stateManager?: IStateManager): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 命令注册表
|
|
3
|
+
* 支持跨插件命令执行
|
|
4
|
+
* 命令ID命名规范:{pluginId}:{commandName}
|
|
5
|
+
*/
|
|
6
|
+
export interface CommandHandler<T = void> {
|
|
7
|
+
execute(...args: any[]): T;
|
|
8
|
+
canExecute?(): boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 命令注册表接口
|
|
12
|
+
*/
|
|
13
|
+
export interface CommandRegistry {
|
|
14
|
+
/** 注册命令 */
|
|
15
|
+
register<T = void>(id: string, handler: CommandHandler<T>): void;
|
|
16
|
+
/** 注销命令 */
|
|
17
|
+
unregister(id: string): void;
|
|
18
|
+
/** 执行命令 */
|
|
19
|
+
execute<T = void>(id: string, ...args: any[]): T | undefined;
|
|
20
|
+
/** 命令是否已注册 */
|
|
21
|
+
has(id: string): boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 命令注册表实现
|
|
25
|
+
*/
|
|
26
|
+
export declare class CommandRegistryImpl implements CommandRegistry {
|
|
27
|
+
private handlers;
|
|
28
|
+
register<T = void>(id: string, handler: CommandHandler<T>): void;
|
|
29
|
+
unregister(id: string): void;
|
|
30
|
+
execute<T = void>(id: string, ...args: any[]): T | undefined;
|
|
31
|
+
has(id: string): boolean;
|
|
32
|
+
/** 清除所有命令 */
|
|
33
|
+
clear(): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置访问器
|
|
3
|
+
* 提供类型安全的配置访问能力
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 配置访问器接口
|
|
7
|
+
*/
|
|
8
|
+
export interface ConfigAccessor {
|
|
9
|
+
/** 获取配置值 */
|
|
10
|
+
get<T>(key: string): T | undefined;
|
|
11
|
+
/** 获取配置值(带默认值) */
|
|
12
|
+
get<T>(key: string, defaultValue: T): T;
|
|
13
|
+
/** 设置配置值 */
|
|
14
|
+
set<T>(key: string, value: T): void;
|
|
15
|
+
/** 检查配置是否存在 */
|
|
16
|
+
has(key: string): boolean;
|
|
17
|
+
/** 获取所有配置 */
|
|
18
|
+
getAll(): Record<string, any>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 配置访问器实现
|
|
22
|
+
*/
|
|
23
|
+
export declare class ConfigAccessorImpl implements ConfigAccessor {
|
|
24
|
+
private config;
|
|
25
|
+
constructor(initialConfig?: Record<string, any>);
|
|
26
|
+
get<T>(key: string): T | undefined;
|
|
27
|
+
get<T>(key: string, defaultValue: T): T;
|
|
28
|
+
set<T>(key: string, value: T): void;
|
|
29
|
+
has(key: string): boolean;
|
|
30
|
+
getAll(): Record<string, any>;
|
|
31
|
+
/** 更新配置(合并) */
|
|
32
|
+
update(patch: Record<string, any>): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 资源释放注册表
|
|
3
|
+
* 支持自动识别 VTK.js 对象并释放
|
|
4
|
+
*/
|
|
5
|
+
/** 可释放对象接口 */
|
|
6
|
+
export interface Disposable {
|
|
7
|
+
delete?: () => void;
|
|
8
|
+
setRenderWindow?: (rw: any) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 资源释放注册表接口
|
|
12
|
+
*/
|
|
13
|
+
export interface DisposalRegistry {
|
|
14
|
+
/** 注册释放函数(回调形式) */
|
|
15
|
+
register(releaseFn: () => void): void;
|
|
16
|
+
/** 注册 VTK.js 可释放对象(自动识别并调用 delete() 或 setRenderWindow(null) 等) */
|
|
17
|
+
registerDisposable(disposable: Disposable): void;
|
|
18
|
+
/** 释放所有已注册的资源 */
|
|
19
|
+
dispose(): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 资源释放注册表实现
|
|
23
|
+
*/
|
|
24
|
+
export declare class DisposalRegistryImpl implements DisposalRegistry {
|
|
25
|
+
private releaseFns;
|
|
26
|
+
private disposed;
|
|
27
|
+
register(releaseFn: () => void): void;
|
|
28
|
+
registerDisposable(disposable: Disposable): void;
|
|
29
|
+
dispose(): void;
|
|
30
|
+
/** 是否已释放 */
|
|
31
|
+
isDisposed(): boolean;
|
|
32
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 事件总线
|
|
3
|
+
* 支持插件间事件通信
|
|
4
|
+
*/
|
|
5
|
+
export type EventCallback = (...args: any[]) => void;
|
|
6
|
+
/**
|
|
7
|
+
* 查看器事件数据映射
|
|
8
|
+
* 为已知事件提供类型安全的数据约束
|
|
9
|
+
*/
|
|
10
|
+
export interface ViewerEventMap {
|
|
11
|
+
'scene:loaded': {
|
|
12
|
+
format: string;
|
|
13
|
+
filename?: string;
|
|
14
|
+
supportsColorBy?: boolean;
|
|
15
|
+
};
|
|
16
|
+
'scene:cleared': void;
|
|
17
|
+
'render:start': void;
|
|
18
|
+
'render:end': void;
|
|
19
|
+
'interaction:toolChanged': {
|
|
20
|
+
tool: string;
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
};
|
|
23
|
+
'measurement:start': void;
|
|
24
|
+
'measurement:complete': void;
|
|
25
|
+
'measurement:clear': void;
|
|
26
|
+
'animation:play': void;
|
|
27
|
+
'animation:pause': void;
|
|
28
|
+
'volume:presetChanged': void;
|
|
29
|
+
'colorBy:arrayChanged': {
|
|
30
|
+
arrayName: string;
|
|
31
|
+
};
|
|
32
|
+
'performance:update': void;
|
|
33
|
+
'plugins:initialized': void;
|
|
34
|
+
'keyBinding:registry-ready': void;
|
|
35
|
+
'error:occurred': void;
|
|
36
|
+
'error:cleared': void;
|
|
37
|
+
'webgl:contextLost': void;
|
|
38
|
+
'webgl:contextRestored': void;
|
|
39
|
+
'memory:pressureChanged': void;
|
|
40
|
+
'memory:cleanup': void;
|
|
41
|
+
'file:load': File;
|
|
42
|
+
'files:load': File[];
|
|
43
|
+
'reset:start': any;
|
|
44
|
+
'reset:complete': any;
|
|
45
|
+
'camera:saved': void;
|
|
46
|
+
'camera:restored': void;
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 事件总线接口
|
|
51
|
+
* 提供事件的注册、注销、触发能力
|
|
52
|
+
* 已知事件自动获得类型约束,未知事件保持 any 兼容性
|
|
53
|
+
*/
|
|
54
|
+
export interface EventBus {
|
|
55
|
+
/** 监听事件 */
|
|
56
|
+
on<K extends keyof ViewerEventMap>(event: K, callback: (data: ViewerEventMap[K]) => void): void;
|
|
57
|
+
on(event: string, callback: EventCallback): void;
|
|
58
|
+
/** 取消监听 */
|
|
59
|
+
off<K extends keyof ViewerEventMap>(event: K, callback: (data: ViewerEventMap[K]) => void): void;
|
|
60
|
+
off(event: string, callback: EventCallback): void;
|
|
61
|
+
/** 触发事件 */
|
|
62
|
+
emit<K extends keyof ViewerEventMap>(event: K, data?: ViewerEventMap[K]): void;
|
|
63
|
+
emit(event: string, data?: any): void;
|
|
64
|
+
/** 监听一次 */
|
|
65
|
+
once<K extends keyof ViewerEventMap>(event: K, callback: (data: ViewerEventMap[K]) => void): void;
|
|
66
|
+
once(event: string, callback: EventCallback): void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 事件总线实现
|
|
70
|
+
*/
|
|
71
|
+
export declare class EventBusImpl implements EventBus {
|
|
72
|
+
private listeners;
|
|
73
|
+
on(event: string, callback: EventCallback): void;
|
|
74
|
+
off(event: string, callback: EventCallback): void;
|
|
75
|
+
emit(event: string, data?: any): void;
|
|
76
|
+
once(event: string, callback: EventCallback): void;
|
|
77
|
+
/** 清除所有监听器 */
|
|
78
|
+
clear(): void;
|
|
79
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式检测器(迁移自FormatRegistry)
|
|
3
|
+
* 提供统一的格式检测接口,支持扩展名+魔数+内容分析
|
|
4
|
+
*/
|
|
5
|
+
export interface FormatDetectionResult {
|
|
6
|
+
format: string;
|
|
7
|
+
confidence: number;
|
|
8
|
+
method: 'extension' | 'magic' | 'content';
|
|
9
|
+
}
|
|
10
|
+
export declare class FormatDetector {
|
|
11
|
+
private static readonly MAGIC_NUMBERS;
|
|
12
|
+
/** VTK XML type 属性到格式的映射 */
|
|
13
|
+
private static readonly VTK_XML_TYPE_MAP;
|
|
14
|
+
private static readonly EXTENSION_MAP;
|
|
15
|
+
/**
|
|
16
|
+
* 根据文件扩展名检测格式
|
|
17
|
+
* @param filename 可选,文件名
|
|
18
|
+
*/
|
|
19
|
+
static detectFormat(filename?: string): FormatDetectionResult | null;
|
|
20
|
+
/**
|
|
21
|
+
* 根据文件内容检测格式
|
|
22
|
+
*/
|
|
23
|
+
static detectFormatFromBuffer(buffer: ArrayBuffer): FormatDetectionResult | null;
|
|
24
|
+
/**
|
|
25
|
+
* 检测 VTK XML 格式(通过解析 type 属性区分 VTP/VTU/VTI 等)
|
|
26
|
+
*
|
|
27
|
+
* VTK XML 文件都以 <VTKFile 开头,但 type 属性不同:
|
|
28
|
+
* - VTP: <VTKFile type="PolyData" ...
|
|
29
|
+
* - VTU: <?xml ...><VTKFile type="UnstructuredGrid" ...
|
|
30
|
+
* - VTI: <VTKFile type="ImageData" ...
|
|
31
|
+
*/
|
|
32
|
+
private static detectVtkXmlFormat;
|
|
33
|
+
/**
|
|
34
|
+
* 综合检测格式(优先使用内容检测)
|
|
35
|
+
* @param filename 可选,文件名(用于扩展名检测)
|
|
36
|
+
* @param buffer 可选,文件内容(用于魔术数字和内容分析)
|
|
37
|
+
*/
|
|
38
|
+
static detect(filename?: string, buffer?: ArrayBuffer): FormatDetectionResult | null;
|
|
39
|
+
/**
|
|
40
|
+
* 获取文件扩展名
|
|
41
|
+
*/
|
|
42
|
+
private static getExtension;
|
|
43
|
+
/**
|
|
44
|
+
* 匹配魔术数字
|
|
45
|
+
*/
|
|
46
|
+
private static matchMagic;
|
|
47
|
+
/**
|
|
48
|
+
* 分析内容特征
|
|
49
|
+
*/
|
|
50
|
+
private static analyzeContent;
|
|
51
|
+
/**
|
|
52
|
+
* 根据格式ID列表构建 HTML input[accept] 属性字符串。
|
|
53
|
+
* 从 EXTENSION_MAP 动态查找对应扩展名,无硬编码。
|
|
54
|
+
*
|
|
55
|
+
* @param formats 格式ID数组(如 ['stl', 'obj', 'ply'])
|
|
56
|
+
* @returns HTML accept 属性值(如 ".stl,.stla,.stlb,.obj,.ply")
|
|
57
|
+
*/
|
|
58
|
+
static getAcceptedExtensions(formats: string[]): string;
|
|
59
|
+
}
|