sa2kit 1.1.0 → 1.2.1

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.
@@ -1,346 +1,66 @@
1
+ import { M as MMDPlayerBaseProps, a as MMDPlayerBaseRef, b as MMDPlayerEnhancedProps, c as MMDPlaylistProps, d as MMDPlaylistNode } from '../types-C2ale3d9.js';
2
+ export { j as MMDPlaylistConfig, f as MMDResourceItem, g as MMDResourceOptions, e as MMDResources, h as MMDStage, i as MobileOptimization, R as ResourceOption } from '../types-C2ale3d9.js';
1
3
  import React__default from 'react';
4
+ import 'three';
2
5
 
3
- /**
4
- * MMD 资源配置
5
- */
6
- interface MMDResources {
7
- /** 模型路径 */
8
- modelPath: string;
9
- /** 动作路径 */
10
- motionPath?: string;
11
- /** 相机路径 */
12
- cameraPath?: string;
13
- /** 音频路径 */
14
- audioPath?: string;
15
- /**
16
- * 场景模型路径 (.pmx/.pmd)
17
- * 通常是静态的 3D 场景模型,如教室、舞台等
18
- */
19
- stageModelPath?: string;
20
- /**
21
- * 背景图片路径
22
- * 支持 jpg/png 等图片格式,将作为 360度背景 (Equirectangular) 或固定背景
23
- */
24
- backgroundPath?: string;
25
- }
26
- /**
27
- * MMD 资源配置项(用于动态切换)
28
- */
29
- interface MMDResourceItem {
30
- /** 配置项 ID */
31
- id: string;
32
- /** 配置项名称 */
33
- name: string;
34
- /** 资源配置 */
35
- resources: MMDResources;
36
- }
37
- /**
38
- * MMD 资源选项(用于下拉框选择)
39
- */
40
- interface MMDResourceOption {
41
- /** 选项 ID */
42
- id: string;
43
- /** 选项名称 */
44
- name: string;
45
- /** 资源路径 */
46
- path: string;
47
- }
48
- /**
49
- * MMD 播放列表节点
50
- * 代表一个完整的 MMD 播放配置(模型+动作+音乐+相机+场景+背景)
51
- */
52
- interface MMDPlaylistNode {
53
- /** 节点 ID */
54
- id: string;
55
- /** 节点名称 */
56
- name: string;
57
- /** 节点描述(可选) */
58
- description?: string;
59
- /** 资源配置 */
60
- resources: MMDResources;
61
- /** 是否循环播放当前节点(默认 false) */
62
- loop?: boolean;
63
- }
64
- /**
65
- * MMD 播放列表配置
66
- */
67
- interface MMDPlaylistConfig {
68
- /** 播放列表 ID */
69
- id: string;
70
- /** 播放列表名称 */
71
- name: string;
72
- /** 播放列表描述(可选) */
73
- description?: string;
74
- /** 播放节点列表 */
75
- nodes: MMDPlaylistNode[];
76
- /** 是否循环播放整个列表(默认 false) */
77
- loop?: boolean;
78
- /** 是否自动播放(默认 true) */
79
- autoPlay?: boolean;
80
- }
81
- /**
82
- * MMD 资源选项列表(用于独立选择模型、动作、音乐、相机等)
83
- */
84
- interface MMDResourceOptions {
85
- /** 模型选项列表 */
86
- models?: MMDResourceOption[];
87
- /** 动作选项列表 */
88
- motions?: MMDResourceOption[];
89
- /** 音频选项列表 */
90
- audios?: MMDResourceOption[];
91
- /** 相机选项列表 */
92
- cameras?: MMDResourceOption[];
93
- /** 场景模型选项列表 */
94
- stageModels?: MMDResourceOption[];
95
- /** 背景图片选项列表 */
96
- backgrounds?: MMDResourceOption[];
97
- }
98
- /**
99
- * MMD 舞台配置
100
- */
101
- interface MMDStage {
102
- /** 背景色 */
103
- backgroundColor?: string;
104
- /**
105
- * 背景类型
106
- * 'color': 纯色背景 (默认)
107
- * 'image': 固定背景图片 (backgroundPath)
108
- * 'skybox': 360度全景图 (backgroundPath)
109
- * @default 'color'
110
- */
111
- backgroundType?: 'color' | 'image' | 'skybox';
112
- /** 相机初始位置 */
113
- cameraPosition?: {
114
- x: number;
115
- y: number;
116
- z: number;
117
- };
118
- /** 相机目标位置 */
119
- cameraTarget?: {
120
- x: number;
121
- y: number;
122
- z: number;
123
- };
124
- /** 启用物理引擎 */
125
- enablePhysics?: boolean;
126
- /** 启用网格 */
127
- showGrid?: boolean;
128
- /** Ammo.js 脚本路径 */
129
- ammoPath?: string;
130
- /** Ammo WASM 文件的基础路径 */
131
- ammoWasmPath?: string;
132
- }
133
- /**
134
- * 基础 MMD 播放器属性(原始API)
135
- */
136
- interface MMDPlayerBaseProps {
137
- /**
138
- * URL to the PMX model file
139
- */
140
- modelUrl: string;
141
- /**
142
- * URL to the VMD motion file for the model
143
- */
144
- vmdUrl?: string;
145
- /**
146
- * URL to the VMD motion file for the camera
147
- */
148
- cameraUrl?: string;
149
- /**
150
- * URL to the audio file (wav, mp3)
151
- */
152
- audioUrl?: string;
153
- /**
154
- * Whether to enable physics simulation (requires Ammo.js)
155
- * @default true
156
- */
157
- physics?: boolean;
158
- /**
159
- * Width of the player
160
- * @default '100%'
161
- */
162
- width?: string | number;
163
- /**
164
- * Height of the player
165
- * @default '100%'
166
- */
167
- height?: string | number;
168
- /**
169
- * Callback when resources are loaded
170
- */
171
- onLoad?: () => void;
172
- /**
173
- * Callback for loading progress
174
- */
175
- onProgress?: (xhr: ProgressEvent) => void;
176
- /**
177
- * Callback for loading error
178
- */
179
- onError?: (error: unknown) => void;
180
- }
181
- /**
182
- * MMD 播放列表组件属性
183
- */
184
- interface MMDPlaylistProps {
185
- /** 播放列表配置 */
186
- playlist: MMDPlaylistConfig;
187
- /** 舞台配置 */
188
- stage?: MMDStage;
189
- /** 默认播放的节点索引(默认 0) */
190
- defaultNodeIndex?: number;
191
- /** 自定义样式类名 */
192
- className?: string;
193
- /** 自定义样式 */
194
- style?: React.CSSProperties;
195
- /** 资源加载完成回调 */
196
- onLoad?: () => void;
197
- /** 资源加载错误回调 */
198
- onError?: (error: any) => void;
199
- /** 节点切换回调 */
200
- onNodeChange?: (nodeIndex: number, node: MMDPlaylistNode) => void;
201
- /** 播放列表完成回调 */
202
- onPlaylistComplete?: () => void;
203
- }
204
- /**
205
- * 增强版 MMD 播放器属性(支持resources和stage配置)
206
- */
207
- interface MMDPlayerEnhancedProps {
208
- /** MMD资源配置(单个) */
209
- resources?: MMDResources;
210
- /** MMD资源配置列表(用于动态切换),如果提供则显示设置按钮 */
211
- resourcesList?: MMDResourceItem[];
212
- /** 默认选中的资源ID(当使用 resourcesList 时) */
213
- defaultResourceId?: string;
214
- /** MMD资源选项列表(用于下拉框独立选择),如果提供则显示设置按钮 */
215
- resourceOptions?: MMDResourceOptions;
216
- /** 默认选中的资源(当使用 resourceOptions 时) */
217
- defaultSelection?: {
218
- modelId?: string;
219
- motionId?: string;
220
- audioId?: string;
221
- cameraId?: string;
222
- stageModelId?: string;
223
- backgroundId?: string;
224
- };
225
- /** 舞台配置 */
226
- stage?: MMDStage;
227
- /** 自动播放 */
228
- autoPlay?: boolean;
229
- /** 循环播放 */
230
- loop?: boolean;
231
- /** 自定义类名 */
232
- className?: string;
233
- /** 自定义样式 */
234
- style?: React.CSSProperties;
235
- /** 加载完成回调 */
236
- onLoad?: () => void;
237
- /** 错误回调 */
238
- onError?: (error: Error) => void;
239
- /** 资源切换回调(resourcesList 模式) */
240
- onResourceChange?: (resourceId: string) => void;
241
- /** 资源选择回调(resourceOptions 模式) */
242
- onSelectionChange?: (selection: {
243
- modelId?: string;
244
- motionId?: string;
245
- audioId?: string;
246
- cameraId?: string;
247
- stageModelId?: string;
248
- backgroundId?: string;
249
- }) => void;
250
- /** 音频播放结束回调 */
251
- onAudioEnded?: () => void;
252
- /** 动画播放结束回调(当没有音频或音频先结束时) */
253
- onAnimationEnded?: () => void;
254
- }
255
- /**
256
- * MMD 播放器属性(联合类型)
257
- */
258
- type MMDPlayerProps = MMDPlayerBaseProps | MMDPlayerEnhancedProps;
259
-
260
- declare const MMDPlayerBase: React__default.FC<MMDPlayerBaseProps>;
6
+ declare const MMDPlayerBase: React__default.ForwardRefExoticComponent<MMDPlayerBaseProps & React__default.RefAttributes<MMDPlayerBaseRef>>;
261
7
 
262
- /**
263
- * 增强版 MMD 播放器组件
264
- * 支持通过 resources 和 stage 配置快速使用
265
- * 所有资源均从 public 目录加载,无需额外配置
266
- */
267
- declare const MMDPlayerEnhanced: React__default.ForwardRefExoticComponent<MMDPlayerEnhancedProps & React__default.RefAttributes<any>>;
8
+ declare const MMDPlayerEnhanced: React__default.FC<MMDPlayerEnhancedProps>;
268
9
 
269
10
  /**
270
- * MMD 播放列表组件(预加载版本)
271
- *
272
- * 在初始化时预加载所有节点的资源,切换时无需加载页面,实现无缝切换
11
+ * MMDPlaylist - 播放列表管理器
273
12
  *
274
- * @example
275
- * ```tsx
276
- * const playlist = {
277
- * id: 'my-playlist',
278
- * name: '我的播放列表',
279
- * nodes: [
280
- * {
281
- * id: 'node1',
282
- * name: '第一个节点',
283
- * resources: { modelPath: '...', motionPath: '...', audioPath: '...' }
284
- * },
285
- * {
286
- * id: 'node2',
287
- * name: '第二个节点',
288
- * resources: { modelPath: '...', motionPath: '...', audioPath: '...' }
289
- * }
290
- * ],
291
- * loop: true,
292
- * autoPlay: true
293
- * };
294
- *
295
- * <MMDPlaylist playlist={playlist} />
296
- * ```
13
+ * 核心功能:
14
+ * - 管理多个播放节点
15
+ * - 实现无缝切换(通过 key 变化触发组件重新挂载)
16
+ * - 预加载策略 (none / next / all)
17
+ * - 智能内存回收
18
+ * - 播放列表 UI
297
19
  */
298
20
  declare const MMDPlaylist: React__default.FC<MMDPlaylistProps>;
299
21
 
300
- interface AmmoConfig {
301
- /** Ammo.js 脚本路径(例如:'/mikutalking/libs/ammo.wasm.js') */
302
- scriptPath: string;
303
- /** Ammo WASM 文件的基础路径(例如:'/mikutalking/libs/') */
304
- wasmBasePath: string;
22
+ interface MMDPlayerEnhancedDebugInfoProps {
23
+ isPlaying: boolean;
24
+ isLooping: boolean;
25
+ isFullscreen: boolean;
26
+ showAxes: boolean;
27
+ isLoading: boolean;
28
+ currentResourceId?: string;
29
+ currentResourceName?: string;
30
+ mode: 'single' | 'list' | 'options';
31
+ totalResources: number;
305
32
  }
306
- /**
307
- * 加载 Ammo.js 物理引擎
308
- * @param config Ammo.js 配置,包含脚本路径和 WASM 基础路径
309
- */
310
- declare const loadAmmo: (config: AmmoConfig) => Promise<void>;
33
+ declare const MMDPlayerEnhancedDebugInfo: React__default.FC<MMDPlayerEnhancedDebugInfoProps>;
311
34
 
312
- /**
313
- * MMD 预设配置
314
- */
315
- interface MMDPreset {
316
- /** 预设ID */
317
- id: string;
318
- /** 预设名称 */
319
- name: string;
320
- /** 预设简介 */
321
- summary: string;
322
- /** 预设标签 */
323
- badges?: string[];
324
- /** 资源配置 */
325
- resources: MMDResources;
326
- /** 舞台配置 */
327
- stage?: MMDStage;
35
+ interface MMDPlaylistDebugInfoProps {
36
+ playlistName: string;
37
+ currentIndex: number;
38
+ currentNode: MMDPlaylistNode;
39
+ totalNodes: number;
40
+ isPlaying: boolean;
41
+ isListLooping: boolean;
42
+ isNodeLooping: boolean;
43
+ preloadStrategy: 'none' | 'next' | 'all';
44
+ isLoading: boolean;
45
+ isFullscreen: boolean;
46
+ showAxes: boolean;
47
+ preloadedNodes: number[];
328
48
  }
49
+ declare const MMDPlaylistDebugInfo: React__default.FC<MMDPlaylistDebugInfoProps>;
50
+
329
51
  /**
330
- * 默认预设 - 仅模型
331
- */
332
- declare const defaultMMDPreset: MMDPreset;
333
- /**
334
- * 完整动画预设 - 模型+动作+相机+音频
335
- */
336
- declare const catchTheWavePreset: MMDPreset;
337
- /**
338
- * 简单模型预设
52
+ * Ammo.js 加载器
53
+ * 用于异步加载 Ammo.js 物理引擎 (WASM 版本)
339
54
  */
340
- declare const simpleModelPreset: MMDPreset;
55
+ declare global {
56
+ interface Window {
57
+ Ammo: any;
58
+ }
59
+ }
341
60
  /**
342
- * 所有可用的预设
61
+ * 加载 Ammo.js
62
+ * @param path Ammo.js (WASM wrapper) 的路径,默认为 '/libs/ammo.wasm.js'
343
63
  */
344
- declare const availableMMDPresets: MMDPreset[];
64
+ declare const loadAmmo: (path?: string) => Promise<any>;
345
65
 
346
- export { type AmmoConfig, MMDPlayerBase, type MMDPlayerBaseProps, MMDPlayerEnhanced, type MMDPlayerEnhancedProps, type MMDPlayerProps, MMDPlaylist, type MMDPlaylistConfig, type MMDPlaylistNode, type MMDPlaylistProps, type MMDPreset, type MMDResourceItem, type MMDResourceOption, type MMDResourceOptions, type MMDResources, type MMDStage, availableMMDPresets, catchTheWavePreset, defaultMMDPreset, loadAmmo, simpleModelPreset };
66
+ export { MMDPlayerBase, MMDPlayerBaseProps, MMDPlayerBaseRef, MMDPlayerEnhanced, MMDPlayerEnhancedDebugInfo, MMDPlayerEnhancedProps, MMDPlaylist, MMDPlaylistDebugInfo, MMDPlaylistNode, MMDPlaylistProps, loadAmmo };