@zeewain/3d-avatar-sdk 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +3 -4
  2. package/dist/assets/Build/webgl.data.unityweb +0 -0
  3. package/dist/assets/Build/webgl.framework.js.unityweb +0 -0
  4. package/dist/assets/Build/webgl.wasm.unityweb +0 -0
  5. package/dist/examples/test-umd/index.html +762 -0
  6. package/dist/examples/test-vue2/.eslintignore +45 -0
  7. package/dist/examples/test-vue2/.eslintrc.js +174 -0
  8. package/dist/examples/test-vue2/.stylelintignore +50 -0
  9. package/dist/examples/test-vue2/.stylelintrc.js +79 -0
  10. package/dist/examples/test-vue2/README.md +139 -0
  11. package/dist/examples/test-vue2/babel.config.js +14 -0
  12. package/dist/examples/test-vue2/package.json +53 -0
  13. package/dist/examples/test-vue2/pnpm-lock.yaml +8776 -0
  14. package/dist/examples/test-vue2/public/index.html +19 -0
  15. package/dist/examples/test-vue2/setup.js +170 -0
  16. package/dist/examples/test-vue2/src/App.vue +943 -0
  17. package/dist/examples/test-vue2/src/components/BroadcastAPI.vue +666 -0
  18. package/dist/examples/test-vue2/src/components/CameraAPI.vue +414 -0
  19. package/dist/examples/test-vue2/src/components/GlobalConfig.vue +200 -0
  20. package/dist/examples/test-vue2/src/components/InfoCards.vue +294 -0
  21. package/dist/examples/test-vue2/src/components/InitAPI.vue +334 -0
  22. package/dist/examples/test-vue2/src/components/LogPanel.vue +249 -0
  23. package/dist/examples/test-vue2/src/components/MotionControlAPI.vue +400 -0
  24. package/dist/examples/test-vue2/src/components/UnityPreview.vue +201 -0
  25. package/dist/examples/test-vue2/src/main.js +16 -0
  26. package/dist/examples/test-vue2/vue.config.js +41 -0
  27. package/dist/examples/test-vue3/.eslintrc +3 -0
  28. package/dist/examples/test-vue3/.stylelintignore +3 -0
  29. package/dist/examples/test-vue3/.stylelintrc +48 -0
  30. package/dist/examples/test-vue3/README.md +236 -0
  31. package/dist/examples/test-vue3/env.d.ts +8 -0
  32. package/dist/examples/test-vue3/index.html +95 -0
  33. package/dist/examples/test-vue3/package.json +55 -0
  34. package/dist/examples/test-vue3/pnpm-lock.yaml +4636 -0
  35. package/dist/examples/test-vue3/setup.js +167 -0
  36. package/dist/examples/test-vue3/src/App.vue +962 -0
  37. package/dist/examples/test-vue3/src/components/BroadcastAPI.vue +636 -0
  38. package/dist/examples/test-vue3/src/components/CameraAPI.vue +376 -0
  39. package/dist/examples/test-vue3/src/components/GlobalConfig.vue +213 -0
  40. package/dist/examples/test-vue3/src/components/InfoCards.vue +288 -0
  41. package/dist/examples/test-vue3/src/components/InitAPI.vue +339 -0
  42. package/dist/examples/test-vue3/src/components/LogPanel.vue +236 -0
  43. package/dist/examples/test-vue3/src/components/MotionControlAPI.vue +373 -0
  44. package/dist/examples/test-vue3/src/components/UnityPreview.vue +189 -0
  45. package/dist/examples/test-vue3/src/main.ts +12 -0
  46. package/dist/examples/test-vue3/src/types.ts +9 -0
  47. package/dist/examples/test-vue3/tsconfig.json +44 -0
  48. package/dist/examples/test-vue3/tsconfig.node.json +14 -0
  49. package/dist/examples/test-vue3/vite.config.ts +75 -0
  50. package/dist/index.d.ts +15 -9
  51. package/dist/index.es5.js +75 -27
  52. package/dist/index.es5.umd.js +75 -27
  53. package/dist/index.esm.js +78 -22
  54. package/dist/index.umd.cjs +78 -22
  55. package/package.json +4 -3
@@ -0,0 +1,294 @@
1
+ <template>
2
+ <div class="info-cards">
3
+ <el-row :gutter="16">
4
+ <el-col :xs="24"
5
+ :sm="12"
6
+ :md="8"
7
+ :lg="6"
8
+ :xl="6"
9
+ >
10
+ <el-card class="info-card" shadow="hover">
11
+ <div slot="header" class="card-header">
12
+ <i class="el-icon-info"></i>
13
+ <span>SDK版本</span>
14
+ </div>
15
+ <div class="card-content">
16
+ <div class="version-info">
17
+ <div class="version-item">
18
+ <span class="label">当前版本:</span>
19
+ <el-tag type="primary" size="mini">v1.0.0</el-tag>
20
+ </div>
21
+ <div class="version-item">
22
+ <span class="label">发布日期:</span>
23
+ <span class="value">2025-01-01</span>
24
+ </div>
25
+ <div class="version-item">
26
+ <span class="label">Unity版本:</span>
27
+ <span class="value">2022.3.0f1</span>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ </el-card>
32
+ </el-col>
33
+
34
+ <el-col :xs="24"
35
+ :sm="12"
36
+ :md="8"
37
+ :lg="6"
38
+ :xl="6"
39
+ >
40
+ <el-card class="info-card" shadow="hover">
41
+ <div slot="header" class="card-header">
42
+ <i class="el-icon-cpu"></i>
43
+ <span>系统信息</span>
44
+ </div>
45
+ <div class="card-content">
46
+ <div class="system-info">
47
+ <div class="system-item">
48
+ <span class="label">浏览器:</span>
49
+ <span class="value">{{ browserInfo }}</span>
50
+ </div>
51
+ <div class="system-item">
52
+ <span class="label">平台:</span>
53
+ <span class="value">{{ platformInfo }}</span>
54
+ </div>
55
+ <div class="system-item">
56
+ <span class="label">WebGL:</span>
57
+ <el-tag :type="webglSupported ? 'success' : 'danger'" size="mini">
58
+ {{ webglSupported ? '支持' : '不支持' }}
59
+ </el-tag>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ </el-card>
64
+ </el-col>
65
+
66
+ <el-col :xs="24"
67
+ :sm="12"
68
+ :md="8"
69
+ :lg="6"
70
+ :xl="6"
71
+ >
72
+ <el-card class="info-card" shadow="hover">
73
+ <div slot="header" class="card-header">
74
+ <i class="el-icon-document"></i>
75
+ <span>快速文档</span>
76
+ </div>
77
+ <div class="card-content">
78
+ <div class="doc-links">
79
+ <el-button type="text" size="small" icon="el-icon-link">
80
+ API文档
81
+ </el-button>
82
+ <el-button type="text" size="small" icon="el-icon-video-play">
83
+ 视频教程
84
+ </el-button>
85
+ <el-button type="text" size="small" icon="el-icon-chat-line-round">
86
+ 技术支持
87
+ </el-button>
88
+ </div>
89
+ </div>
90
+ </el-card>
91
+ </el-col>
92
+
93
+ <el-col :xs="24"
94
+ :sm="12"
95
+ :md="8"
96
+ :lg="6"
97
+ :xl="6"
98
+ >
99
+ <el-card class="info-card" shadow="hover">
100
+ <div slot="header" class="card-header">
101
+ <i class="el-icon-star-on"></i>
102
+ <span>功能特性</span>
103
+ </div>
104
+ <div class="card-content">
105
+ <div class="features">
106
+ <div class="feature-item">
107
+ <i class="el-icon-check"></i>
108
+ <span>3D数字人渲染</span>
109
+ </div>
110
+ <div class="feature-item">
111
+ <i class="el-icon-check"></i>
112
+ <span>智能语音播报</span>
113
+ </div>
114
+ <div class="feature-item">
115
+ <i class="el-icon-check"></i>
116
+ <span>动作控制系统</span>
117
+ </div>
118
+ <div class="feature-item">
119
+ <i class="el-icon-check"></i>
120
+ <span>多平台支持</span>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ </el-card>
125
+ </el-col>
126
+ </el-row>
127
+ </div>
128
+ </template>
129
+
130
+ <script>
131
+ export default {
132
+ name: 'InfoCards',
133
+ data () {
134
+ return {
135
+ browserInfo: '',
136
+ platformInfo: '',
137
+ webglSupported: false
138
+ }
139
+ },
140
+ mounted () {
141
+ this.getBrowserInfo()
142
+ this.getPlatformInfo()
143
+ this.checkWebGLSupport()
144
+ },
145
+ methods: {
146
+ getBrowserInfo () {
147
+ const userAgent = navigator.userAgent
148
+ if (userAgent.includes('Chrome')) {
149
+ this.browserInfo = 'Chrome'
150
+ } else if (userAgent.includes('Firefox')) {
151
+ this.browserInfo = 'Firefox'
152
+ } else if (userAgent.includes('Safari')) {
153
+ this.browserInfo = 'Safari'
154
+ } else if (userAgent.includes('Edge')) {
155
+ this.browserInfo = 'Edge'
156
+ } else {
157
+ this.browserInfo = 'Unknown'
158
+ }
159
+ },
160
+
161
+ getPlatformInfo () {
162
+ const platform = navigator.platform
163
+ if (platform.includes('Win')) {
164
+ this.platformInfo = 'Windows'
165
+ } else if (platform.includes('Mac')) {
166
+ this.platformInfo = 'macOS'
167
+ } else if (platform.includes('Linux')) {
168
+ this.platformInfo = 'Linux'
169
+ } else {
170
+ this.platformInfo = 'Unknown'
171
+ }
172
+ },
173
+
174
+ checkWebGLSupport () {
175
+ try {
176
+ const canvas = document.createElement('canvas')
177
+ const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl')
178
+ this.webglSupported = !!gl
179
+ } catch (e) {
180
+ this.webglSupported = false
181
+ }
182
+ }
183
+ }
184
+ }
185
+ </script>
186
+
187
+ <style lang="scss" scoped>
188
+ .info-cards {
189
+ .info-card {
190
+ margin-bottom: 16px;
191
+
192
+ .card-header {
193
+ display: flex;
194
+ align-items: center;
195
+ gap: 8px;
196
+ font-weight: 600;
197
+ color: #2c3e50;
198
+
199
+ i {
200
+ font-size: 16px;
201
+ }
202
+ }
203
+
204
+ .card-content {
205
+ .version-info, .system-info {
206
+ .version-item, .system-item {
207
+ display: flex;
208
+ justify-content: space-between;
209
+ align-items: center;
210
+ margin-bottom: 8px;
211
+
212
+ .label {
213
+ font-size: 13px;
214
+ color: #606266;
215
+ }
216
+
217
+ .value {
218
+ font-size: 13px;
219
+ color: #2c3e50;
220
+ }
221
+ }
222
+ }
223
+
224
+ .doc-links {
225
+ display: flex;
226
+ flex-direction: column;
227
+ gap: 8px;
228
+
229
+ .el-button {
230
+ text-align: left;
231
+ padding: 8px 0;
232
+
233
+ &:hover {
234
+ color: #409eff;
235
+ }
236
+ }
237
+ }
238
+
239
+ .features {
240
+ .feature-item {
241
+ display: flex;
242
+ align-items: center;
243
+ gap: 8px;
244
+ margin-bottom: 8px;
245
+ font-size: 13px;
246
+ color: #2c3e50;
247
+
248
+ i {
249
+ color: #67c23a;
250
+ font-size: 14px;
251
+ }
252
+ }
253
+ }
254
+ }
255
+ }
256
+ }
257
+
258
+ // 移动端优化
259
+ @media screen and (max-width: 768px) {
260
+ .info-cards {
261
+ .info-card {
262
+ .card-header {
263
+ font-size: 14px;
264
+
265
+ i {
266
+ font-size: 14px;
267
+ }
268
+ }
269
+
270
+ .card-content {
271
+ .version-info, .system-info {
272
+ .version-item, .system-item {
273
+ .label, .value {
274
+ font-size: 12px;
275
+ }
276
+ }
277
+ }
278
+
279
+ .doc-links {
280
+ .el-button {
281
+ font-size: 12px;
282
+ }
283
+ }
284
+
285
+ .features {
286
+ .feature-item {
287
+ font-size: 12px;
288
+ }
289
+ }
290
+ }
291
+ }
292
+ }
293
+ }
294
+ </style>
@@ -0,0 +1,334 @@
1
+ <template>
2
+ <div class="init-api">
3
+ <div class="api-description">
4
+ <el-alert
5
+ title="API说明"
6
+ type="info"
7
+ :closable="false"
8
+ show-icon
9
+ >
10
+ <template slot="default">
11
+ <div class="api-signature">
12
+ <code>initializeAvatar(avatarCode: string, cameraType?: AvatarCameraType): Promise&lt;IAvatarCallbackResponse&gt;</code>
13
+ </div>
14
+ <p>通过数字人编码加载数字人,token在SDK初始化时配置,无需在每次调用时传递</p>
15
+ <p class="api-features">
16
+ ✅ Promise-based异步API &nbsp;&nbsp;
17
+ ✅ 统一错误处理 &nbsp;&nbsp;
18
+ ✅ 详细响应信息
19
+ </p>
20
+ </template>
21
+ </el-alert>
22
+ </div>
23
+
24
+ <div class="api-controls">
25
+ <el-card shadow="hover" class="control-card">
26
+ <div slot="header" class="card-header">
27
+ <span>初始化控制</span>
28
+ <el-tag v-if="sdkStatus.avatarLoaded" type="success" size="mini">已加载</el-tag>
29
+ <el-tag v-else type="info" size="mini">未加载</el-tag>
30
+ </div>
31
+
32
+ <div class="control-content">
33
+ <div class="status-info">
34
+ <el-row :gutter="16">
35
+ <el-col :span="12">
36
+ <div class="status-item">
37
+ <span class="status-label">Unity状态:</span>
38
+ <el-tag :type="sdkStatus.unityLoaded ? 'success' : 'info'" size="mini">
39
+ {{ sdkStatus.unityLoaded ? '已加载' : '未加载' }}
40
+ </el-tag>
41
+ </div>
42
+ </el-col>
43
+ <el-col :span="12">
44
+ <div class="status-item">
45
+ <span class="status-label">Avatar状态:</span>
46
+ <el-tag :type="sdkStatus.avatarLoaded ? 'success' : 'info'" size="mini">
47
+ {{ sdkStatus.avatarLoaded ? '已加载' : '未加载' }}
48
+ </el-tag>
49
+ </div>
50
+ </el-col>
51
+ </el-row>
52
+ </div>
53
+
54
+ <div class="config-info">
55
+ <el-descriptions :column="1" size="mini" border>
56
+ <el-descriptions-item label="Token状态">
57
+ <el-tag :type="globalConfig.token ? 'success' : 'danger'" size="mini">
58
+ {{ globalConfig.token ? '已配置' : '未配置' }}
59
+ </el-tag>
60
+ </el-descriptions-item>
61
+ <el-descriptions-item label="Avatar编码">
62
+ <span v-if="globalConfig.avatarCode" class="avatar-code">{{ globalConfig.avatarCode }}</span>
63
+ <el-tag v-else type="warning" size="mini">未设置</el-tag>
64
+ </el-descriptions-item>
65
+ </el-descriptions>
66
+ </div>
67
+
68
+ <div class="action-buttons">
69
+ <el-button
70
+ type="primary"
71
+ size="medium"
72
+ icon="el-icon-play"
73
+ :loading="isLoading"
74
+ :disabled="sdkStatus.avatarLoaded || !globalConfig.token || !globalConfig.avatarCode"
75
+ @click="handleInitAvatar"
76
+ >
77
+ {{ isLoading ? '初始化中...' : '初始化 Unity + Avatar' }}
78
+ </el-button>
79
+
80
+ <div class="button-tips">
81
+ <el-alert
82
+ v-if="!globalConfig.token || !globalConfig.avatarCode"
83
+ title="请先在全局配置中设置Token和Avatar Code"
84
+ type="warning"
85
+ :closable="false"
86
+ show-icon
87
+ />
88
+ <el-alert
89
+ v-else-if="sdkStatus.avatarLoaded"
90
+ title="Avatar已加载,请先卸载后再重新初始化"
91
+ type="info"
92
+ :closable="false"
93
+ show-icon
94
+ />
95
+ <el-alert
96
+ v-else-if="!sdkStatus.unityLoaded"
97
+ title="将同时初始化Unity实例和Avatar,首次加载需要一些时间"
98
+ type="info"
99
+ :closable="false"
100
+ show-icon
101
+ />
102
+ </div>
103
+ </div>
104
+ </div>
105
+ </el-card>
106
+ </div>
107
+
108
+ <div class="api-result">
109
+ <el-card shadow="hover" class="result-card">
110
+ <div slot="header" class="card-header">
111
+ <span>执行结果</span>
112
+ <el-button
113
+ type="text"
114
+ size="mini"
115
+ icon="el-icon-refresh"
116
+ @click="clearResult"
117
+ >
118
+ 清空
119
+ </el-button>
120
+ </div>
121
+
122
+ <div class="result-content">
123
+ <pre class="result-text">{{ result }}</pre>
124
+ </div>
125
+ </el-card>
126
+ </div>
127
+ </div>
128
+ </template>
129
+
130
+ <script>
131
+ export default {
132
+ name: 'InitAPI',
133
+ props: {
134
+ sdkStatus: {
135
+ type: Object,
136
+ required: true
137
+ },
138
+ globalConfig: {
139
+ type: Object,
140
+ required: true
141
+ }
142
+ },
143
+ data () {
144
+ return {
145
+ result: '等待初始化操作...\n\n新版SDK特性:\n- token在初始化时配置,无需重复传递\n- Promise-based异步API\n- 统一的错误处理和响应格式\n- 完整的TypeScript类型支持',
146
+ isLoading: false
147
+ }
148
+ },
149
+ methods: {
150
+ async handleInitAvatar () {
151
+ if (!this.globalConfig.token || !this.globalConfig.avatarCode) {
152
+ this.result = '❌ 请先在全局配置中设置Token和Avatar Code'
153
+ this.$message.warning('请先配置Token和Avatar Code')
154
+ return
155
+ }
156
+
157
+ this.isLoading = true
158
+ this.result = '🔄 正在初始化Unity实例和Avatar...\n📦 加载Unity引擎(约19MB)\n🤖 初始化数字人模型\n⚙️ 配置播报服务\n\n请稍等,这可能需要一些时间...'
159
+
160
+ try {
161
+ // 发送初始化请求
162
+ this.$emit('init-avatar-with-unity', {
163
+ avatarCode: this.globalConfig.avatarCode
164
+ })
165
+
166
+ // 等待初始化完成的反馈
167
+ setTimeout(() => {
168
+ this.isLoading = false
169
+ this.result = '✅ 初始化请求已发送\n📋 请查看右侧日志面板获取详细信息\n\n📝 操作说明:\n- 初始化成功后可以使用其他API功能\n- Unity实例将在中间预览窗口中显示\n- 所有操作日志会在右侧面板实时更新'
170
+ }, 1000)
171
+ } catch (error) {
172
+ this.isLoading = false
173
+ this.result = `❌ 初始化失败: ${error.message}\n\n🔍 可能的原因:\n- Token无效或已过期\n- 网络连接问题\n- Unity资源文件加载失败\n- Avatar编码不存在`
174
+ this.$message.error(`初始化失败: ${error.message}`)
175
+ }
176
+ },
177
+
178
+ clearResult () {
179
+ this.result = '等待初始化操作...\n\n新版SDK特性:\n- token在初始化时配置,无需重复传递\n- Promise-based异步API\n- 统一的错误处理和响应格式\n- 完整的TypeScript类型支持'
180
+ }
181
+ }
182
+ }
183
+ </script>
184
+
185
+ <style lang="scss" scoped>
186
+ .init-api {
187
+ .api-description {
188
+ margin-bottom: 20px;
189
+
190
+ .api-signature {
191
+ background-color: #f5f5f5;
192
+ padding: 8px 12px;
193
+ border-radius: 4px;
194
+ margin-bottom: 10px;
195
+ font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
196
+ font-size: 12px;
197
+ border-left: 4px solid #409eff;
198
+
199
+ code {
200
+ color: #2c3e50;
201
+ font-weight: 600;
202
+ }
203
+ }
204
+
205
+ p {
206
+ margin: 5px 0;
207
+ color: #606266;
208
+ font-size: 14px;
209
+
210
+ &.api-features {
211
+ color: #67c23a;
212
+ font-weight: 500;
213
+ margin-top: 8px;
214
+ }
215
+ }
216
+ }
217
+
218
+ .api-controls {
219
+ margin-bottom: 20px;
220
+
221
+ .control-card {
222
+ .card-header {
223
+ display: flex;
224
+ justify-content: space-between;
225
+ align-items: center;
226
+ font-weight: 600;
227
+ }
228
+
229
+ .control-content {
230
+ .status-info {
231
+ margin-bottom: 15px;
232
+
233
+ .status-item {
234
+ display: flex;
235
+ align-items: center;
236
+ margin-bottom: 8px;
237
+
238
+ .status-label {
239
+ margin-right: 8px;
240
+ font-size: 13px;
241
+ color: #606266;
242
+ }
243
+ }
244
+ }
245
+
246
+ .config-info {
247
+ margin-bottom: 20px;
248
+
249
+ .avatar-code {
250
+ font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
251
+ background-color: #f5f5f5;
252
+ padding: 2px 6px;
253
+ border-radius: 3px;
254
+ font-size: 12px;
255
+ }
256
+ }
257
+
258
+ .action-buttons {
259
+ .el-button {
260
+ width: 100%;
261
+ margin-bottom: 15px;
262
+ }
263
+
264
+ .button-tips {
265
+ .el-alert {
266
+ margin-bottom: 10px;
267
+
268
+ &:last-child {
269
+ margin-bottom: 0;
270
+ }
271
+ }
272
+ }
273
+ }
274
+ }
275
+ }
276
+ }
277
+
278
+ .api-result {
279
+ .result-card {
280
+ .card-header {
281
+ display: flex;
282
+ justify-content: space-between;
283
+ align-items: center;
284
+ font-weight: 600;
285
+ }
286
+
287
+ .result-content {
288
+ max-height: 300px;
289
+ overflow-y: auto;
290
+
291
+ .result-text {
292
+ margin: 0;
293
+ padding: 15px;
294
+ background-color: #f8f9fa;
295
+ border-radius: 4px;
296
+ border: 1px solid #e9ecef;
297
+ font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
298
+ font-size: 13px;
299
+ line-height: 1.6;
300
+ color: #2c3e50;
301
+ white-space: pre-wrap;
302
+ word-wrap: break-word;
303
+ }
304
+ }
305
+ }
306
+ }
307
+ }
308
+
309
+ // 移动端优化
310
+ @media screen and (width <= 768px) {
311
+ .init-api {
312
+ .api-description {
313
+ .api-signature {
314
+ font-size: 11px;
315
+ padding: 6px 10px;
316
+
317
+ code {
318
+ word-break: break-all;
319
+ }
320
+ }
321
+ }
322
+
323
+ .control-content {
324
+ .status-info {
325
+ .el-row {
326
+ .el-col {
327
+ margin-bottom: 8px;
328
+ }
329
+ }
330
+ }
331
+ }
332
+ }
333
+ }
334
+ </style>