@spatialwalk/avatarkit 1.0.0-beta.50 → 1.0.0-beta.52

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 CHANGED
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.0.0-beta.52] - 2025-01-05
9
+
10
+ ### 🔧 Performance Improvements
11
+ - **Telemetry Optimization** - Consolidated resource download telemetry: removed individual `resource_download` events and added cache information (`cache_hit`, `cache_type`) to total duration metrics (`template_resources_load_measure` and `download_avatar_assets_total_measure`). This enables analysis of download times for cache misses while reducing telemetry overhead.
12
+
13
+ ## [1.0.0-beta.51] - 2025-01-05
14
+
15
+ ### 🐛 Bugfix
16
+ - **Character Settings Update** - Fixed issue where cached Avatar instances would not update `characterSettings` in resources when `characterMeta` was updated. Now `resources.characterSettings` is synchronized when `characterMeta` changes, ensuring new `AvatarView` instances use the latest configuration.
17
+
18
+ ### ✨ New Features
19
+ - **Post-Processing Config Enhancement** - Added `translation` and `eyePose` fields to `PostProcessingConfig` interface:
20
+ - `translation`: Position offset (x, y, z)
21
+ - `eyePose`: Eye pose offset with bias and weights (x, y, z, weightX, weightY, weightZ), applied to both left and right eyes
22
+
8
23
  ## [1.0.0-beta.50] - 2025-01-05
9
24
 
10
25
  ### 🔧 Performance Improvements
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { A as APP_CONFIG, e as errorToMessage, l as logEvent, a as logger } from "./index-BHk2NbFu.js";
4
+ import { A as APP_CONFIG, e as errorToMessage, l as logEvent, a as logger } from "./index-DmQOISG3.js";
5
5
  class StreamingAudioPlayer {
6
6
  constructor(options) {
7
7
  __publicField(this, "audioContext", null);
@@ -15,6 +15,9 @@ class Avatar {
15
15
  }
16
16
  updateCharacterMeta(newMeta) {
17
17
  this.characterMeta = newMeta;
18
+ if (this.resources.characterSettings !== newMeta.characterSettings) {
19
+ this.resources.characterSettings = newMeta.characterSettings;
20
+ }
18
21
  }
19
22
  getResources() {
20
23
  return this.resources;
@@ -7576,7 +7579,7 @@ const _AnimationPlayer = class _AnimationPlayer {
7576
7579
  if (this.streamingPlayer) {
7577
7580
  return;
7578
7581
  }
7579
- const { StreamingAudioPlayer } = await import("./StreamingAudioPlayer-DTpMpES9.js");
7582
+ const { StreamingAudioPlayer } = await import("./StreamingAudioPlayer-DZfQ6O5L.js");
7580
7583
  const { AvatarSDK: AvatarSDK2 } = await Promise.resolve().then(() => AvatarSDK$1);
7581
7584
  const audioFormat = AvatarSDK2.getAudioFormat();
7582
7585
  this.streamingPlayer = new StreamingAudioPlayer({
@@ -8966,7 +8969,7 @@ class AvatarSDK {
8966
8969
  }
8967
8970
  __publicField(AvatarSDK, "_isInitialized", false);
8968
8971
  __publicField(AvatarSDK, "_configuration", null);
8969
- __publicField(AvatarSDK, "_version", "1.0.0-beta.50");
8972
+ __publicField(AvatarSDK, "_version", "1.0.0-beta.52");
8970
8973
  __publicField(AvatarSDK, "_avatarCore", null);
8971
8974
  __publicField(AvatarSDK, "_dynamicSdkConfig", null);
8972
8975
  const AvatarSDK$1 = Object.freeze(Object.defineProperty({
@@ -11569,6 +11572,11 @@ class AvatarController {
11569
11572
  result2.rotation[1] += this.postProcessingConfig.rotation.y ?? 0;
11570
11573
  result2.rotation[2] += this.postProcessingConfig.rotation.z ?? 0;
11571
11574
  }
11575
+ if (this.postProcessingConfig.translation && result2.translation) {
11576
+ result2.translation[0] += this.postProcessingConfig.translation.x ?? 0;
11577
+ result2.translation[1] += this.postProcessingConfig.translation.y ?? 0;
11578
+ result2.translation[2] += this.postProcessingConfig.translation.z ?? 0;
11579
+ }
11572
11580
  if (this.postProcessingConfig.neckPose && result2.neck_pose) {
11573
11581
  const biasX = this.postProcessingConfig.neckPose.x ?? 0;
11574
11582
  const biasY = this.postProcessingConfig.neckPose.y ?? 0;
@@ -11589,6 +11597,20 @@ class AvatarController {
11589
11597
  result2.jaw_pose[1] = result2.jaw_pose[1] * weight + biasY;
11590
11598
  result2.jaw_pose[2] = result2.jaw_pose[2] * weight + biasZ;
11591
11599
  }
11600
+ if (this.postProcessingConfig.eyePose && result2.eyes_pose) {
11601
+ const biasX = this.postProcessingConfig.eyePose.x ?? 0;
11602
+ const biasY = this.postProcessingConfig.eyePose.y ?? 0;
11603
+ const biasZ = this.postProcessingConfig.eyePose.z ?? 0;
11604
+ const weightX = this.postProcessingConfig.eyePose.weightX ?? 1;
11605
+ const weightY = this.postProcessingConfig.eyePose.weightY ?? 1;
11606
+ const weightZ = this.postProcessingConfig.eyePose.weightZ ?? 1;
11607
+ result2.eyes_pose[0] = result2.eyes_pose[0] * weightX + biasX;
11608
+ result2.eyes_pose[1] = result2.eyes_pose[1] * weightY + biasY;
11609
+ result2.eyes_pose[2] = result2.eyes_pose[2] * weightZ + biasZ;
11610
+ result2.eyes_pose[3] = result2.eyes_pose[3] * weightX + biasX;
11611
+ result2.eyes_pose[4] = result2.eyes_pose[4] * weightY + biasY;
11612
+ result2.eyes_pose[5] = result2.eyes_pose[5] * weightZ + biasZ;
11613
+ }
11592
11614
  if (this.postProcessingConfig.eyeBlink !== void 0 && result2.eyelid) {
11593
11615
  const blinkValue = this.postProcessingConfig.eyeBlink;
11594
11616
  result2.eyelid[0] = blinkValue;
@@ -11893,24 +11915,16 @@ class AvatarDownloader {
11893
11915
  }
11894
11916
  updateProgress(resourceName, false);
11895
11917
  logger.log(`📥 Loading ${key} from API CDN: ${url}`);
11896
- const { data: buffer, cacheInfo } = await downloadResource(url, { resourceType: "template" });
11918
+ const { data: buffer } = await downloadResource(url, { resourceType: "template" });
11897
11919
  logger.log(`✅ ${key} loaded: ${buffer.byteLength} bytes`);
11898
11920
  templateResources[key] = buffer;
11899
11921
  updateProgress(resourceName, true);
11900
- logEvent("resource_download", "info", {
11901
- resource_type: "template",
11902
- resource_name: resourceName,
11903
- cache_hit: cacheInfo.cacheHit,
11904
- cache_type: cacheInfo.cacheType,
11905
- pwa_cache_subtype: cacheInfo.pwaCacheSubtype,
11906
- transfer_size: cacheInfo.transferSize,
11907
- cdn_cache_status: cacheInfo.cdnCacheStatus
11908
- });
11909
11922
  });
11910
11923
  await Promise.all(promises);
11911
11924
  return templateResources;
11912
11925
  }
11913
11926
  async loadGlobalFlameResources(progressCallback = null) {
11927
+ var _a;
11914
11928
  await PwaCacheManager.checkTemplateCacheVersion();
11915
11929
  const startTime = Date.now();
11916
11930
  const { cdnBaseUrl, resources } = APP_CONFIG.flame;
@@ -11948,6 +11962,7 @@ class AvatarDownloader {
11948
11962
  }
11949
11963
  };
11950
11964
  const templateResources = {};
11965
+ const cacheInfos = [];
11951
11966
  try {
11952
11967
  const promises = Object.entries(templateFiles).map(async ([key, { url, resourceName }]) => {
11953
11968
  updateProgress(resourceName, false);
@@ -11955,22 +11970,18 @@ class AvatarDownloader {
11955
11970
  const { data: buffer, cacheInfo } = await downloadResource(url, { resourceType: "template" });
11956
11971
  logger.log(`✅ ${key} loaded: ${buffer.byteLength} bytes`);
11957
11972
  templateResources[key] = buffer;
11973
+ cacheInfos.push(cacheInfo);
11958
11974
  updateProgress(resourceName, true);
11959
- logEvent("resource_download", "info", {
11960
- resource_type: "template",
11961
- resource_name: resourceName,
11962
- cache_hit: cacheInfo.cacheHit,
11963
- cache_type: cacheInfo.cacheType,
11964
- pwa_cache_subtype: cacheInfo.pwaCacheSubtype,
11965
- transfer_size: cacheInfo.transferSize,
11966
- cdn_cache_status: cacheInfo.cdnCacheStatus
11967
- });
11968
11975
  });
11969
11976
  await Promise.all(promises);
11977
+ const cacheHit = cacheInfos.length > 0 && cacheInfos.every((info) => info.cacheHit);
11978
+ const cacheType = ((_a = cacheInfos[0]) == null ? void 0 : _a.cacheType) || "none";
11970
11979
  const duration = Date.now() - startTime;
11971
11980
  logEvent("template_resources_load_measure", "info", {
11972
11981
  duration,
11973
- file_count: totalFiles
11982
+ file_count: totalFiles,
11983
+ cache_hit: cacheHit,
11984
+ cache_type: cacheType
11974
11985
  });
11975
11986
  return templateResources;
11976
11987
  } catch (error) {
@@ -11986,21 +11997,12 @@ class AvatarDownloader {
11986
11997
  }
11987
11998
  try {
11988
11999
  logger.log(`📥 Loading camera info from: ${cameraUrl}`);
11989
- const { data: arrayBuffer, cacheInfo } = await downloadResource(cameraUrl, {
12000
+ const { data: arrayBuffer } = await downloadResource(cameraUrl, {
11990
12001
  characterId: characterMeta.characterId ?? void 0,
11991
12002
  resourceType: "character"
11992
12003
  });
11993
12004
  const text = new TextDecoder().decode(arrayBuffer);
11994
12005
  const cameraSettings = JSON.parse(text);
11995
- logEvent("resource_download", "info", {
11996
- resource_type: "camera_settings",
11997
- resource_name: "camera.json",
11998
- cache_hit: cacheInfo.cacheHit,
11999
- cache_type: cacheInfo.cacheType,
12000
- pwa_cache_subtype: cacheInfo.pwaCacheSubtype,
12001
- transfer_size: cacheInfo.transferSize,
12002
- cdn_cache_status: cacheInfo.cdnCacheStatus
12003
- });
12004
12006
  logger.log("✅ Camera info loaded:", cameraSettings);
12005
12007
  return cameraSettings;
12006
12008
  } catch (error) {
@@ -12009,7 +12011,7 @@ class AvatarDownloader {
12009
12011
  }
12010
12012
  }
12011
12013
  async loadCharacterData(characterMeta, options) {
12012
- var _a, _b, _c, _d, _e2, _f, _g, _h, _i2;
12014
+ var _a, _b, _c, _d, _e2, _f, _g, _h, _i2, _j;
12013
12015
  const { progressCallback = null } = options || {};
12014
12016
  const totalStartTime = Date.now();
12015
12017
  const shapeUrl = (_c = (_b = (_a = characterMeta.models) == null ? void 0 : _a.shape) == null ? void 0 : _b.resource) == null ? void 0 : _c.remote;
@@ -12046,6 +12048,7 @@ class AvatarDownloader {
12046
12048
  }
12047
12049
  };
12048
12050
  const characterData = {};
12051
+ const cacheInfos = [];
12049
12052
  const parallelStartTime = Date.now();
12050
12053
  const downloadPromises = filesToLoad.map(async ({ key, url, filename, optional }) => {
12051
12054
  updateProgress(filename, false);
@@ -12061,16 +12064,8 @@ class AvatarDownloader {
12061
12064
  } else if (key === "idleAnimation") {
12062
12065
  characterData.idleAnimation = arrayBuffer;
12063
12066
  }
12067
+ cacheInfos.push(cacheInfo);
12064
12068
  updateProgress(filename, true);
12065
- logEvent("resource_download", "info", {
12066
- resource_type: "character_asset",
12067
- resource_name: filename,
12068
- cache_hit: cacheInfo.cacheHit,
12069
- cache_type: cacheInfo.cacheType,
12070
- pwa_cache_subtype: cacheInfo.pwaCacheSubtype,
12071
- transfer_size: cacheInfo.transferSize,
12072
- cdn_cache_status: cacheInfo.cdnCacheStatus
12073
- });
12074
12069
  return { key, success: true, size: arrayBuffer.byteLength };
12075
12070
  } catch (error) {
12076
12071
  if (!optional) {
@@ -12092,6 +12087,8 @@ class AvatarDownloader {
12092
12087
  });
12093
12088
  throw new Error(reason);
12094
12089
  }
12090
+ const cacheHit = cacheInfos.length > 0 && cacheInfos.every((info) => info.cacheHit);
12091
+ const cacheType = ((_j = cacheInfos[0]) == null ? void 0 : _j.cacheType) || "none";
12095
12092
  const totalSize = Object.values(characterData).reduce((sum, buffer) => {
12096
12093
  return sum + (buffer ? buffer.byteLength : 0);
12097
12094
  }, 0);
@@ -12100,7 +12097,9 @@ class AvatarDownloader {
12100
12097
  total_duration: totalDuration,
12101
12098
  parallel_duration: parallelDuration,
12102
12099
  total_size: totalSize,
12103
- file_count: filesToLoad.length
12100
+ file_count: filesToLoad.length,
12101
+ cache_hit: cacheHit,
12102
+ cache_type: cacheType
12104
12103
  });
12105
12104
  return characterData;
12106
12105
  }
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b, c, f, d, j, g, C, i, D, E, k, h, L, R, S, m } from "./index-BHk2NbFu.js";
1
+ import { b, c, f, d, j, g, C, i, D, E, k, h, L, R, S, m } from "./index-DmQOISG3.js";
2
2
  export {
3
3
  b as Avatar,
4
4
  c as AvatarController,
@@ -102,6 +102,11 @@ export interface PostProcessingConfig {
102
102
  y?: number;
103
103
  z?: number;
104
104
  };
105
+ translation?: {
106
+ x?: number;
107
+ y?: number;
108
+ z?: number;
109
+ };
105
110
  neckPose?: {
106
111
  x?: number;
107
112
  y?: number;
@@ -116,6 +121,14 @@ export interface PostProcessingConfig {
116
121
  z?: number;
117
122
  weight?: number;
118
123
  };
124
+ eyePose?: {
125
+ x?: number;
126
+ y?: number;
127
+ z?: number;
128
+ weightX?: number;
129
+ weightY?: number;
130
+ weightZ?: number;
131
+ };
119
132
  eyeBlink?: number;
120
133
  expressionWeight?: number;
121
134
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spatialwalk/avatarkit",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.50",
4
+ "version": "1.0.0-beta.52",
5
5
  "packageManager": "pnpm@10.18.2",
6
6
  "description": "SPAvatar SDK - 3D Gaussian Splatting Avatar Rendering SDK",
7
7
  "author": "SPAvatar Team",