@spatialwalk/avatarkit 1.0.0-beta.7 → 1.0.0-beta.71
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/CHANGELOG.md +602 -10
- package/README.md +475 -312
- package/dist/StreamingAudioPlayer-D8Q8WiEg.js +638 -0
- package/dist/animation/AnimationWebSocketClient.d.ts +6 -50
- package/dist/animation/utils/eventEmitter.d.ts +1 -9
- package/dist/animation/utils/flameConverter.d.ts +3 -24
- package/dist/audio/AnimationPlayer.d.ts +6 -57
- package/dist/audio/StreamingAudioPlayer.d.ts +2 -118
- package/dist/avatar_core_wasm-Dv943JJl.js +2696 -0
- package/dist/{avatar_core_wasm.wasm → avatar_core_wasm-e68766db.wasm} +0 -0
- package/dist/config/app-config.d.ts +3 -4
- package/dist/config/constants.d.ts +10 -18
- package/dist/config/sdk-config-loader.d.ts +4 -10
- package/dist/core/Avatar.d.ts +2 -14
- package/dist/core/AvatarController.d.ts +95 -85
- package/dist/core/AvatarDownloader.d.ts +7 -92
- package/dist/core/AvatarManager.d.ts +22 -12
- package/dist/core/AvatarSDK.d.ts +35 -0
- package/dist/core/AvatarView.d.ts +55 -140
- package/dist/core/NetworkLayer.d.ts +7 -59
- package/dist/generated/common/v1/models.d.ts +36 -0
- package/dist/generated/driveningress/v1/driveningress.d.ts +0 -1
- package/dist/generated/driveningress/v2/driveningress.d.ts +82 -1
- package/dist/generated/google/protobuf/struct.d.ts +0 -1
- package/dist/generated/google/protobuf/timestamp.d.ts +0 -1
- package/dist/index-U8QcNdma.js +16477 -0
- package/dist/index.d.ts +2 -4
- package/dist/index.js +17 -18
- package/dist/renderer/RenderSystem.d.ts +9 -79
- package/dist/renderer/covariance.d.ts +3 -11
- package/dist/renderer/renderer.d.ts +6 -2
- package/dist/renderer/sortSplats.d.ts +3 -10
- package/dist/renderer/webgl/reorderData.d.ts +4 -11
- package/dist/renderer/webgl/webglRenderer.d.ts +34 -4
- package/dist/renderer/webgpu/webgpuRenderer.d.ts +30 -5
- package/dist/types/character-settings.d.ts +1 -1
- package/dist/types/character.d.ts +3 -15
- package/dist/types/index.d.ts +123 -43
- package/dist/utils/animation-interpolation.d.ts +4 -15
- package/dist/utils/client-id.d.ts +6 -0
- package/dist/utils/conversationId.d.ts +10 -0
- package/dist/utils/error-utils.d.ts +0 -1
- package/dist/utils/id-manager.d.ts +34 -0
- package/dist/utils/logger.d.ts +2 -11
- package/dist/utils/posthog-tracker.d.ts +8 -0
- package/dist/utils/pwa-cache-manager.d.ts +17 -0
- package/dist/utils/usage-tracker.d.ts +6 -0
- package/dist/vanilla/vite.config.d.ts +2 -0
- package/dist/vite.d.ts +19 -0
- package/dist/wasm/avatarCoreAdapter.d.ts +15 -126
- package/dist/wasm/avatarCoreMemory.d.ts +5 -2
- package/package.json +19 -8
- package/vite.d.ts +20 -0
- package/vite.js +126 -0
- package/dist/StreamingAudioPlayer-D7s8q5h0.js +0 -319
- package/dist/StreamingAudioPlayer-D7s8q5h0.js.map +0 -1
- package/dist/animation/AnimationWebSocketClient.d.ts.map +0 -1
- package/dist/animation/utils/eventEmitter.d.ts.map +0 -1
- package/dist/animation/utils/flameConverter.d.ts.map +0 -1
- package/dist/audio/AnimationPlayer.d.ts.map +0 -1
- package/dist/audio/StreamingAudioPlayer.d.ts.map +0 -1
- package/dist/avatar_core_wasm-D4eEi7Eh.js +0 -1666
- package/dist/avatar_core_wasm-D4eEi7Eh.js.map +0 -1
- package/dist/config/app-config.d.ts.map +0 -1
- package/dist/config/constants.d.ts.map +0 -1
- package/dist/config/sdk-config-loader.d.ts.map +0 -1
- package/dist/core/Avatar.d.ts.map +0 -1
- package/dist/core/AvatarController.d.ts.map +0 -1
- package/dist/core/AvatarDownloader.d.ts.map +0 -1
- package/dist/core/AvatarKit.d.ts +0 -66
- package/dist/core/AvatarKit.d.ts.map +0 -1
- package/dist/core/AvatarManager.d.ts.map +0 -1
- package/dist/core/AvatarView.d.ts.map +0 -1
- package/dist/core/NetworkLayer.d.ts.map +0 -1
- package/dist/generated/driveningress/v1/driveningress.d.ts.map +0 -1
- package/dist/generated/driveningress/v2/driveningress.d.ts.map +0 -1
- package/dist/generated/google/protobuf/struct.d.ts.map +0 -1
- package/dist/generated/google/protobuf/timestamp.d.ts.map +0 -1
- package/dist/index-CpSvWi6A.js +0 -6026
- package/dist/index-CpSvWi6A.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/renderer/RenderSystem.d.ts.map +0 -1
- package/dist/renderer/covariance.d.ts.map +0 -1
- package/dist/renderer/renderer.d.ts.map +0 -1
- package/dist/renderer/sortSplats.d.ts.map +0 -1
- package/dist/renderer/webgl/reorderData.d.ts.map +0 -1
- package/dist/renderer/webgl/webglRenderer.d.ts.map +0 -1
- package/dist/renderer/webgpu/webgpuRenderer.d.ts.map +0 -1
- package/dist/types/character-settings.d.ts.map +0 -1
- package/dist/types/character.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/utils/animation-interpolation.d.ts.map +0 -1
- package/dist/utils/cls-tracker.d.ts +0 -17
- package/dist/utils/cls-tracker.d.ts.map +0 -1
- package/dist/utils/error-utils.d.ts.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/reqId.d.ts +0 -20
- package/dist/utils/reqId.d.ts.map +0 -1
- package/dist/wasm/avatarCoreAdapter.d.ts.map +0 -1
- package/dist/wasm/avatarCoreMemory.d.ts.map +0 -1
|
Binary file
|
|
@@ -3,9 +3,9 @@ export declare const APP_CONFIG: {
|
|
|
3
3
|
readonly debug: boolean;
|
|
4
4
|
rendering: {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* - 'balance':
|
|
8
|
-
* - 'quality':
|
|
6
|
+
* Sort mode
|
|
7
|
+
* - 'balance': Performance first, sort first frame then reuse (default)
|
|
8
|
+
* - 'quality': Quality first, re-sort every frame
|
|
9
9
|
*/
|
|
10
10
|
sortMode: "balance" | "quality";
|
|
11
11
|
};
|
|
@@ -41,4 +41,3 @@ export declare const APP_CONFIG: {
|
|
|
41
41
|
enablePerformanceMetrics: boolean;
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
-
//# sourceMappingURL=app-config.d.ts.map
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import { Environment } from '../types';
|
|
2
|
-
export declare const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
export declare const CLS_CONFIG: {
|
|
14
|
-
endpoint: string;
|
|
15
|
-
topicId: string;
|
|
16
|
-
secretId: string;
|
|
17
|
-
secretKey: string;
|
|
18
|
-
token: string;
|
|
2
|
+
export declare const POSTHOG_HOST_CN: string;
|
|
3
|
+
export declare const POSTHOG_API_KEY_CN: string;
|
|
4
|
+
export declare const POSTHOG_HOST_INTL: string;
|
|
5
|
+
export declare const POSTHOG_API_KEY_INTL: string;
|
|
6
|
+
export declare const POSTHOG_TRACK_EVENTS: boolean;
|
|
7
|
+
export declare const POSTHOG_PROJECT_NAME: string;
|
|
8
|
+
export declare function getPostHogConfig(_environment: Environment): {
|
|
9
|
+
host: string;
|
|
10
|
+
apiKey: string;
|
|
11
|
+
disableCompression: boolean;
|
|
19
12
|
};
|
|
20
13
|
export declare const ENV_TEST: boolean;
|
|
21
14
|
/**
|
|
@@ -26,4 +19,3 @@ export declare const ENV_TEST: boolean;
|
|
|
26
19
|
* - URL has debug=1 parameter
|
|
27
20
|
*/
|
|
28
21
|
export declare function isDebugMode(): boolean;
|
|
29
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import { Environment } from '../types';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
2
|
+
* SDK configuration loader
|
|
3
|
+
* Fetch SDK endpoint configuration from remote config API
|
|
4
|
+
* @internal
|
|
6
5
|
*/
|
|
7
|
-
export
|
|
8
|
-
/**
|
|
9
|
-
* 清除配置缓存(用于测试或重新加载)
|
|
10
|
-
*/
|
|
11
|
-
export declare function clearSdkConfigCache(): void;
|
|
12
|
-
//# sourceMappingURL=sdk-config-loader.d.ts.map
|
|
6
|
+
export {};
|
package/dist/core/Avatar.d.ts
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
import { CharacterMeta } from '../types';
|
|
2
|
-
import { PreloadResult } from './AvatarDownloader';
|
|
3
2
|
export declare class Avatar {
|
|
4
3
|
readonly id: string;
|
|
5
4
|
private characterMeta;
|
|
6
5
|
private resources;
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
* @param characterMeta 角色元数据
|
|
11
|
-
* @param resources 资源数据
|
|
12
|
-
*/
|
|
13
|
-
constructor(id: string, characterMeta: CharacterMeta, resources: PreloadResult);
|
|
14
|
-
/**
|
|
15
|
-
* 获取角色元数据(内部使用)
|
|
7
|
+
* Get character metadata
|
|
8
|
+
* @returns Character metadata, including all configuration information (version, resource URLs, camera config, etc.)
|
|
16
9
|
*/
|
|
17
10
|
getCharacterMeta(): CharacterMeta;
|
|
18
|
-
/**
|
|
19
|
-
* 获取资源数据(内部使用)
|
|
20
|
-
*/
|
|
21
|
-
getResources(): PreloadResult;
|
|
22
11
|
}
|
|
23
|
-
//# sourceMappingURL=Avatar.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Flame } from '../generated/driveningress/v1/driveningress';
|
|
2
2
|
import { Avatar } from './Avatar';
|
|
3
3
|
import { AnimationPlayer } from '../audio/AnimationPlayer';
|
|
4
|
-
import { AvatarState, ConnectionState,
|
|
4
|
+
import { AvatarState, ConnectionState, DrivingServiceMode, ConversationState, PostProcessingConfig, KeyframeData } from '../types';
|
|
5
5
|
export declare class AvatarController {
|
|
6
6
|
private networkLayer?;
|
|
7
|
-
readonly playbackMode
|
|
7
|
+
private readonly playbackMode;
|
|
8
8
|
protected avatar: Avatar;
|
|
9
9
|
protected animationPlayer: AnimationPlayer | null;
|
|
10
10
|
protected currentKeyframes: Flame[];
|
|
@@ -13,140 +13,150 @@ export declare class AvatarController {
|
|
|
13
13
|
isLast: boolean;
|
|
14
14
|
}>;
|
|
15
15
|
protected isPlaying: boolean;
|
|
16
|
+
private isStartingPlayback;
|
|
16
17
|
protected isConnected: boolean;
|
|
17
18
|
protected currentState: AvatarState;
|
|
19
|
+
private currentConversationId;
|
|
20
|
+
private reqEnd;
|
|
18
21
|
onConnectionState: ((state: ConnectionState) => void) | null;
|
|
19
|
-
|
|
22
|
+
onConversationState: ((state: ConversationState) => void) | null;
|
|
20
23
|
onError: ((error: Error) => void) | null;
|
|
21
24
|
private eventListeners;
|
|
22
25
|
private renderCallback?;
|
|
23
|
-
private
|
|
26
|
+
private characterHandle;
|
|
27
|
+
private characterId;
|
|
28
|
+
private postProcessingConfig;
|
|
24
29
|
private playbackLoopId;
|
|
25
30
|
private lastRenderedFrameIndex;
|
|
31
|
+
private keyframesOffset;
|
|
32
|
+
private readonly MAX_KEYFRAMES;
|
|
33
|
+
private readonly KEYFRAMES_CLEANUP_THRESHOLD;
|
|
34
|
+
private lastSyncLogTime;
|
|
35
|
+
private lastOutOfBoundsState;
|
|
36
|
+
private isAudioOnlyMode;
|
|
37
|
+
private playbackStuckCheckState;
|
|
38
|
+
private readonly MAX_AUDIO_TIME_ZERO_COUNT;
|
|
39
|
+
private readonly MAX_AUDIO_TIME_STUCK_COUNT;
|
|
40
|
+
private readonly AUDIO_TIME_STUCK_THRESHOLD;
|
|
41
|
+
private hostModeMetrics;
|
|
42
|
+
private readonly audioBytesPerSecond;
|
|
26
43
|
constructor(avatar: Avatar, options?: {
|
|
27
|
-
playbackMode?:
|
|
44
|
+
playbackMode?: DrivingServiceMode;
|
|
28
45
|
});
|
|
29
46
|
/**
|
|
30
|
-
*
|
|
47
|
+
* Get current conversation ID
|
|
48
|
+
* Returns the current conversation ID for the active audio session
|
|
49
|
+
* @returns Current conversation ID, or null if no active session
|
|
31
50
|
*/
|
|
32
|
-
|
|
51
|
+
getCurrentConversationId(): string | null;
|
|
33
52
|
/**
|
|
34
|
-
*
|
|
53
|
+
* Initialize audio context (must be called in user gesture context)
|
|
54
|
+
*
|
|
55
|
+
* This method must be called before any audio operations (send, yieldAudioData, etc.)
|
|
56
|
+
* to ensure AudioContext is created and initialized in a user gesture context.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // In user click handler
|
|
60
|
+
* button.addEventListener('click', async () => {
|
|
61
|
+
* await avatarView.controller.initializeAudioContext()
|
|
62
|
+
* // Now you can safely use send() or yieldAudioData()
|
|
63
|
+
* })
|
|
35
64
|
*/
|
|
36
|
-
|
|
65
|
+
initializeAudioContext(): Promise<void>;
|
|
37
66
|
/**
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
|
-
setConnected(connected: boolean): void;
|
|
41
|
-
/**
|
|
42
|
-
* 获取连接状态
|
|
43
|
-
*/
|
|
44
|
-
get connected(): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* 获取当前状态
|
|
47
|
-
*/
|
|
48
|
-
get state(): AvatarState;
|
|
49
|
-
/**
|
|
50
|
-
* 获取动画播放器实例
|
|
51
|
-
* @internal
|
|
52
|
-
*/
|
|
53
|
-
getAnimationPlayer(): AnimationPlayer | null;
|
|
54
|
-
/**
|
|
55
|
-
* 启动服务(仅网络模式)
|
|
67
|
+
* Start service (SDK mode only)
|
|
56
68
|
*/
|
|
57
69
|
start(): Promise<void>;
|
|
58
70
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
71
|
+
* Send audio to server (SDK mode only)
|
|
72
|
+
* Also cache to data layer for playback
|
|
73
|
+
* @returns conversationId - Conversation ID for this audio session
|
|
61
74
|
*/
|
|
62
|
-
send(audioData: ArrayBuffer, end?: boolean):
|
|
75
|
+
send(audioData: ArrayBuffer, end?: boolean): string | null;
|
|
63
76
|
/**
|
|
64
|
-
*
|
|
77
|
+
* Close service (SDK mode only)
|
|
65
78
|
*/
|
|
66
79
|
close(): void;
|
|
67
80
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
|
|
71
|
-
play(initialAudioChunks?: Array<{
|
|
72
|
-
data: Uint8Array;
|
|
73
|
-
isLast: boolean;
|
|
74
|
-
}>, initialKeyframes?: Flame[]): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* 发送音频数据(外部数据模式)
|
|
77
|
-
* 在 play() 之后流式添加剩余音频数据
|
|
78
|
-
*/
|
|
79
|
-
sendAudioChunk(data: Uint8Array, isLast?: boolean): void;
|
|
80
|
-
/**
|
|
81
|
-
* 发送动画关键帧(外部数据模式或网络模式)
|
|
82
|
-
* 在 play() 之后流式添加剩余动画数据
|
|
81
|
+
* Send audio data (host mode)
|
|
82
|
+
* Stream additional audio data after playback()
|
|
83
|
+
* @returns conversationId - Conversation ID for this audio session
|
|
83
84
|
*/
|
|
84
|
-
|
|
85
|
+
yieldAudioData(data: Uint8Array, isLast?: boolean): string | null;
|
|
85
86
|
/**
|
|
86
|
-
*
|
|
87
|
+
* Send animation keyframes (host mode or SDK mode)
|
|
88
|
+
* Stream additional animation data after playback()
|
|
89
|
+
*
|
|
90
|
+
* Public API: accepts binary data array (protobuf encoded Message array)
|
|
91
|
+
* @param keyframesDataArray - Animation keyframes binary data array (each element is a protobuf encoded Message) or empty array to trigger audio-only mode
|
|
92
|
+
* @param conversationId - Conversation ID (required). If conversationId doesn't match current conversationId, keyframes will be discarded.
|
|
93
|
+
* Use getCurrentConversationId() to get the current conversationId.
|
|
87
94
|
*/
|
|
88
|
-
|
|
95
|
+
yieldFramesData(keyframesDataArray: (Uint8Array | ArrayBuffer)[], conversationId: string): void;
|
|
89
96
|
/**
|
|
90
|
-
*
|
|
97
|
+
* Send animation keyframes (host mode)
|
|
98
|
+
* Stream animation keyframes data after yieldAudioData()
|
|
99
|
+
*
|
|
100
|
+
* ⚠️ **Not recommended**: Prefer using `yieldFramesData()` method, which accepts binary data (protobuf encoded Message) with better performance.
|
|
101
|
+
* This method is only for scenarios where you already have decoded KeyframeData arrays.
|
|
102
|
+
*
|
|
103
|
+
* Public API: accepts decoded keyframes
|
|
104
|
+
* @param keyframes - Animation keyframes array (KeyframeData[]) or empty array to trigger audio-only mode
|
|
105
|
+
* @param conversationId - Conversation ID (required). If conversationId doesn't match current conversationId, keyframes will be discarded.
|
|
106
|
+
* Use getCurrentConversationId() to get the current conversationId.
|
|
91
107
|
*/
|
|
92
|
-
|
|
108
|
+
yieldKeyframes(keyframes: KeyframeData[], conversationId: string): void;
|
|
93
109
|
/**
|
|
94
|
-
*
|
|
110
|
+
* Pause playback (can be resumed later)
|
|
111
|
+
* Pause audio playback and stop render loop, but preserve all state (keyframes, audio buffers, etc.)
|
|
95
112
|
*/
|
|
96
|
-
|
|
113
|
+
pause(): void;
|
|
97
114
|
/**
|
|
98
|
-
*
|
|
115
|
+
* Resume playback (from paused state)
|
|
116
|
+
* Resume audio playback and restart render loop
|
|
117
|
+
* Animation will continue from paused frame (because animation time base comes from audio, will auto-sync)
|
|
99
118
|
*/
|
|
100
|
-
|
|
119
|
+
resume(): Promise<void>;
|
|
101
120
|
/**
|
|
102
|
-
*
|
|
121
|
+
* Interrupt current playback
|
|
103
122
|
*/
|
|
104
|
-
|
|
123
|
+
interrupt(): void;
|
|
105
124
|
/**
|
|
106
|
-
*
|
|
125
|
+
* Clear all data and resources
|
|
107
126
|
*/
|
|
108
|
-
|
|
127
|
+
clear(): void;
|
|
109
128
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @
|
|
129
|
+
* Get point cloud count of the current avatar
|
|
130
|
+
* @returns Point cloud count, or null if avatar is not loaded
|
|
112
131
|
*/
|
|
113
|
-
|
|
114
|
-
onKeyframesUpdate?: (keyframes: Flame[]) => void;
|
|
115
|
-
onStartRendering?: () => void;
|
|
116
|
-
onStopRendering?: () => void;
|
|
117
|
-
onInterrupt?: () => void;
|
|
118
|
-
}): void;
|
|
132
|
+
getPointCount(): number | null;
|
|
119
133
|
/**
|
|
120
|
-
*
|
|
134
|
+
* Set post-processing configuration
|
|
135
|
+
* These parameters will be applied in real-time to animation parameters returned by the server
|
|
136
|
+
* @param config Post-processing configuration, or null to clear
|
|
121
137
|
*/
|
|
122
|
-
|
|
138
|
+
setPostProcessingConfig(config: PostProcessingConfig | null): void;
|
|
123
139
|
/**
|
|
124
|
-
*
|
|
140
|
+
* Set audio playback volume
|
|
141
|
+
* Note: This only controls the avatar audio player volume, not the system volume
|
|
142
|
+
* @param volume Volume value, range from 0.0 to 1.0 (0.0 = mute, 1.0 = max volume)
|
|
125
143
|
*/
|
|
126
|
-
|
|
144
|
+
setVolume(volume: number): void;
|
|
127
145
|
/**
|
|
128
|
-
*
|
|
146
|
+
* Get current audio playback volume
|
|
147
|
+
* @returns Current volume value (0.0 - 1.0)
|
|
129
148
|
*/
|
|
130
|
-
|
|
149
|
+
getVolume(): number;
|
|
131
150
|
/**
|
|
132
|
-
*
|
|
151
|
+
* Stop playback
|
|
133
152
|
*/
|
|
134
153
|
protected stopPlayback(): void;
|
|
135
154
|
/**
|
|
136
|
-
*
|
|
155
|
+
* Clean up players
|
|
137
156
|
*/
|
|
138
157
|
protected cleanupPlayers(): void;
|
|
139
158
|
/**
|
|
140
|
-
*
|
|
141
|
-
*/
|
|
142
|
-
private addAudioChunkToBuffer;
|
|
143
|
-
/**
|
|
144
|
-
* 事件系统
|
|
145
|
-
*/
|
|
146
|
-
private registerEventListener;
|
|
147
|
-
/**
|
|
148
|
-
* 触发事件
|
|
159
|
+
* Emit event
|
|
149
160
|
*/
|
|
150
161
|
protected emit(event: string, data?: any): void;
|
|
151
162
|
}
|
|
152
|
-
//# sourceMappingURL=AvatarController.d.ts.map
|
|
@@ -1,100 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
filename: string;
|
|
6
|
-
loaded: number;
|
|
7
|
-
total: number;
|
|
8
|
-
progress: number;
|
|
9
|
-
}
|
|
10
|
-
type ProgressCallback = (info: ProgressInfo) => void;
|
|
11
|
-
interface TemplateResources {
|
|
12
|
-
[key: string]: ArrayBuffer;
|
|
13
|
-
}
|
|
14
|
-
interface FlameResources {
|
|
15
|
-
flameModel?: {
|
|
16
|
-
remote?: string;
|
|
17
|
-
};
|
|
18
|
-
flameTemplate?: {
|
|
19
|
-
remote?: string;
|
|
20
|
-
};
|
|
21
|
-
teethPb?: {
|
|
22
|
-
remote?: string;
|
|
23
|
-
};
|
|
24
|
-
teethNpz?: {
|
|
25
|
-
remote?: string;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
interface CharacterDataResult {
|
|
29
|
-
shape: ArrayBuffer;
|
|
30
|
-
pointCloud: ArrayBuffer;
|
|
31
|
-
idleAnimation?: ArrayBuffer;
|
|
32
|
-
monoAnimation?: ArrayBuffer;
|
|
33
|
-
monoAudioUrl?: string;
|
|
34
|
-
}
|
|
35
|
-
export interface PreloadResult {
|
|
36
|
-
templateResources: TemplateResources;
|
|
37
|
-
characterData: CharacterDataResult;
|
|
38
|
-
preloadCameraSettings?: PreloadCameraSettings;
|
|
39
|
-
characterSettings?: CharacterSettings;
|
|
40
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Avatar Downloader (iOS Compatible)
|
|
3
|
+
* Downloads character resources from CharacterMeta structure
|
|
4
|
+
*/
|
|
41
5
|
export declare class AvatarDownloader {
|
|
42
6
|
private baseAssetsPath;
|
|
43
|
-
private characterAssets;
|
|
44
7
|
constructor(baseAssetsPath?: string);
|
|
45
8
|
/**
|
|
46
|
-
*
|
|
47
|
-
* Falls back to global CDN config if not provided by API
|
|
48
|
-
*/
|
|
49
|
-
loadTemplateResources(flameResources?: FlameResources, progressCallback?: ProgressCallback | null): Promise<TemplateResources>;
|
|
50
|
-
/**
|
|
51
|
-
* Load global FLAME template resources from CDN
|
|
52
|
-
* Uses centralized FLAME CDN config (shared across all characters)
|
|
53
|
-
*/
|
|
54
|
-
private loadGlobalFlameResources;
|
|
55
|
-
/**
|
|
56
|
-
* Load camera settings from CharacterMeta (optional)
|
|
57
|
-
*/
|
|
58
|
-
loadCameraSettings(characterMeta: CharacterMeta): Promise<PreloadCameraSettings | undefined>;
|
|
59
|
-
/**
|
|
60
|
-
* Load character data from CharacterMeta (iOS compatible)
|
|
61
|
-
*/
|
|
62
|
-
loadCharacterData(characterMeta: CharacterMeta, options?: {
|
|
63
|
-
loadMonologue?: boolean;
|
|
64
|
-
progressCallback?: ProgressCallback | null;
|
|
65
|
-
}): Promise<CharacterDataResult>;
|
|
66
|
-
/**
|
|
67
|
-
* Preload all resources (template + character data + camera info + settings)
|
|
68
|
-
*/
|
|
69
|
-
preloadResources(characterMeta: CharacterMeta, options?: {
|
|
70
|
-
loadMonologue?: boolean;
|
|
71
|
-
progressCallback?: ProgressCallback | null;
|
|
72
|
-
}): Promise<PreloadResult>;
|
|
73
|
-
/**
|
|
74
|
-
* Get loaded character asset by key
|
|
75
|
-
*/
|
|
76
|
-
getCharacterAsset(key: string): ArrayBuffer | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Clear cached assets
|
|
79
|
-
*/
|
|
80
|
-
clear(): void;
|
|
81
|
-
/**
|
|
82
|
-
* Get Main App API Client (enjoi.spatialwalk.top)
|
|
83
|
-
* Used for: character list, auth, customization, etc.
|
|
84
|
-
*/
|
|
85
|
-
private getMainAppClient;
|
|
86
|
-
/**
|
|
87
|
-
* Get SPAvatarKit SDK API Client (api.spatialwalk.top)
|
|
9
|
+
* Get AvatarKit SDK API Client (api.open.spatialwalk.top for cn, api.intl.spatialwalk.cloud for intl)
|
|
88
10
|
* Used for: character details and resource URLs (public endpoints, no auth required)
|
|
11
|
+
* Note: This endpoint does not require authentication, so we don't add X-App-Id or Authorization headers
|
|
12
|
+
* to avoid CORS preflight requests for simple GET requests
|
|
89
13
|
*/
|
|
90
14
|
private getSdkApiClient;
|
|
91
|
-
/**
|
|
92
|
-
* Get single character by ID from SPAvatarKit SDK API (v2, iOS compatible)
|
|
93
|
-
* Domain: api.spatialwalk.top
|
|
94
|
-
* Auth: Public endpoint, no authentication required
|
|
95
|
-
* Returns CharacterMeta with nested resource structure
|
|
96
|
-
*/
|
|
97
|
-
getCharacterById(characterId: string): Promise<CharacterMeta>;
|
|
98
15
|
}
|
|
99
|
-
export {};
|
|
100
|
-
//# sourceMappingURL=AvatarDownloader.d.ts.map
|
|
@@ -3,24 +3,34 @@ import { Avatar } from './Avatar';
|
|
|
3
3
|
export declare class AvatarManager {
|
|
4
4
|
private static _instance;
|
|
5
5
|
private avatarDownloader;
|
|
6
|
-
private
|
|
6
|
+
private avatarCache;
|
|
7
|
+
private loadingPromises;
|
|
8
|
+
private downloadQueue;
|
|
9
|
+
private isDownloading;
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
11
|
+
* Access via global singleton
|
|
9
12
|
*/
|
|
10
13
|
static get shared(): AvatarManager;
|
|
11
14
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @param id
|
|
14
|
-
* @param onProgress
|
|
15
|
-
* @param options 加载选项
|
|
15
|
+
* Load avatar
|
|
16
|
+
* @param id Avatar ID
|
|
17
|
+
* @param onProgress Progress callback
|
|
16
18
|
* @returns Promise<Avatar>
|
|
17
19
|
*/
|
|
18
|
-
load(id: string, onProgress?: (progress: LoadProgressInfo) => void
|
|
19
|
-
enableMonologue?: boolean;
|
|
20
|
-
}): Promise<Avatar>;
|
|
20
|
+
load(id: string, onProgress?: (progress: LoadProgressInfo) => void): Promise<Avatar>;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Get cached avatar
|
|
23
|
+
* @param id Avatar ID
|
|
24
|
+
* @returns Avatar instance, or undefined if not in cache
|
|
23
25
|
*/
|
|
24
|
-
|
|
26
|
+
retrieve(id: string): Avatar | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Clear cached avatar for specified ID
|
|
29
|
+
* @param id Avatar ID
|
|
30
|
+
*/
|
|
31
|
+
clear(id: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Clear all avatar cache and resource loader cache
|
|
34
|
+
*/
|
|
35
|
+
clearAll(): void;
|
|
25
36
|
}
|
|
26
|
-
//# sourceMappingURL=AvatarManager.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Configuration } from '../types';
|
|
2
|
+
export declare class AvatarSDK {
|
|
3
|
+
private static _isInitialized;
|
|
4
|
+
private static _configuration;
|
|
5
|
+
private static readonly _version;
|
|
6
|
+
private static _avatarCore;
|
|
7
|
+
private static _dynamicSdkConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Initialize SDK
|
|
10
|
+
* @param appId Application ID to be included in both HTTP Headers and WebSocket Headers
|
|
11
|
+
* @param configuration Configuration parameters
|
|
12
|
+
*/
|
|
13
|
+
static initialize(appId: string, configuration: Configuration): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Set sessionToken
|
|
16
|
+
* Developer Client -> Developer Server -> AvatarKit Server -> return sessionToken (max 1 hour validity)
|
|
17
|
+
* Include in WebSocket Headers for avatar WebSocket service authentication
|
|
18
|
+
*/
|
|
19
|
+
static setSessionToken(token: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Set userId
|
|
22
|
+
* Optional interface for developers, SDK includes this in telemetry logs
|
|
23
|
+
*/
|
|
24
|
+
static setUserId(userId: string): void;
|
|
25
|
+
static get isInitialized(): boolean;
|
|
26
|
+
static get appId(): string | null;
|
|
27
|
+
static get configuration(): Configuration | null;
|
|
28
|
+
static get sessionToken(): string | null;
|
|
29
|
+
static get userId(): string | null;
|
|
30
|
+
static get version(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Cleanup resources
|
|
33
|
+
*/
|
|
34
|
+
static cleanup(): void;
|
|
35
|
+
}
|