@spatialwalk/avatarkit 1.0.0-beta.31 → 1.0.0-beta.34

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,16 @@ 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.34] - 2025-12-16
9
+
10
+ ### ✨ New Features
11
+ - **Avatar Transform API** - Added `setTransform` method to `AvatarView` for controlling avatar position and scale within the canvas. Supports normalized coordinates (-1 to 1) for position and scale factor.
12
+
13
+ ## [1.0.0-beta.32] - 2025-12-16
14
+
15
+ ### 🔄 Breaking Changes
16
+ - **Host Mode Interface** - Updated `yieldFramesData` method to accept binary data array instead of single binary data. The method now processes multiple protobuf-encoded Message objects in a single call.
17
+
8
18
  ## [1.0.0-beta.31] - 2025-12-16
9
19
 
10
20
  ### 🐛 Bugfix
package/README.md CHANGED
@@ -87,7 +87,7 @@ const avatarView = new AvatarView(avatar, container)
87
87
  // 4. Host Mode Workflow:
88
88
  // Send audio data first to get conversationId, then use it to send animation data
89
89
  const conversationId = avatarView.avatarController.yieldAudioData(audioData, false)
90
- avatarView.avatarController.yieldFramesData(animationData, conversationId)
90
+ avatarView.avatarController.yieldFramesData(animationDataArray, conversationId) // animationDataArray: (Uint8Array | ArrayBuffer)[]
91
91
  ```
92
92
 
93
93
  ### Complete Examples
@@ -177,7 +177,7 @@ External data source (audio + animation)
177
177
 
178
178
  AvatarController.yieldAudioData(audioChunk) // Returns conversationId
179
179
 
180
- AvatarController.yieldFramesData(keyframes, conversationId)
180
+ AvatarController.yieldFramesData(keyframesDataArray, conversationId) // keyframesDataArray: (Uint8Array | ArrayBuffer)[] - each element is a protobuf encoded Message
181
181
 
182
182
  AvatarController → AnimationPlayer (synchronized playback)
183
183
 
@@ -292,6 +292,12 @@ const avatarView = new AvatarView(avatar, container)
292
292
  // Wait for first frame to render
293
293
  await avatarView.ready // Promise that resolves when the first frame is rendered
294
294
 
295
+ // Set avatar transform (position and scale)
296
+ avatarView.setTransform(x, y, scale)
297
+ // - x: Horizontal offset in normalized coordinates (-1 to 1, where -1 = left edge, 0 = center, 1 = right edge)
298
+ // - y: Vertical offset in normalized coordinates (-1 to 1, where -1 = bottom edge, 0 = center, 1 = top edge)
299
+ // - scale: Scale factor (1.0 = original size, 2.0 = double size, 0.5 = half size)
300
+
295
301
  // Cleanup resources (must be called before switching characters)
296
302
  avatarView.dispose()
297
303
  ```
@@ -348,8 +354,8 @@ const conversationId = avatarView.avatarController.yieldAudioData(
348
354
 
349
355
  // Stream animation keyframes (requires conversationId from audio data)
350
356
  avatarView.avatarController.yieldFramesData(
351
- keyframes: any[], // Animation keyframes (obtained from your service)
352
- conversationId: string // Conversation ID (required)
357
+ keyframesDataArray: (Uint8Array | ArrayBuffer)[], // Animation keyframes binary data array (each element is a protobuf encoded Message)
358
+ conversationId: string // Conversation ID (required)
353
359
  )
354
360
  ```
355
361
 
@@ -389,6 +395,19 @@ avatarView.avatarController.onConversationState = (state: ConversationState) =>
389
395
  avatarView.avatarController.onError = (error: Error) => {}
390
396
  ```
391
397
 
398
+ #### Avatar Transform Methods
399
+
400
+ ```typescript
401
+ // Set avatar transform (position and scale in canvas)
402
+ avatarView.setTransform(x, y, scale)
403
+ // - x: Horizontal offset in normalized coordinates (-1 to 1, where -1 = left edge, 0 = center, 1 = right edge)
404
+ // - y: Vertical offset in normalized coordinates (-1 to 1, where -1 = bottom edge, 0 = center, 1 = top edge)
405
+ // - scale: Scale factor (1.0 = original size, 2.0 = double size, 0.5 = half size)
406
+ // Example:
407
+ avatarView.setTransform(0, 0, 1.0) // Center, original size
408
+ avatarView.setTransform(0.5, 0, 2.0) // Right half, double size
409
+ ```
410
+
392
411
  **Important Notes:**
393
412
  - `start()` and `close()` are only available in SDK mode
394
413
  - `yieldAudioData()` and `yieldFramesData()` are only available in Host mode
@@ -552,7 +571,7 @@ const avatarView = new AvatarView(avatar, container)
552
571
 
553
572
  // Use
554
573
  const conversationId = avatarView.avatarController.yieldAudioData(audioChunk, false)
555
- avatarView.avatarController.yieldFramesData(keyframes, conversationId)
574
+ avatarView.avatarController.yieldFramesData(keyframesDataArray, conversationId) // keyframesDataArray: (Uint8Array | ArrayBuffer)[]
556
575
 
557
576
  // Cleanup
558
577
  avatarView.avatarController.clear() // Clear all data and resources
@@ -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-CCBBCJi2.js";
4
+ import { A as APP_CONFIG, e as errorToMessage, l as logEvent, a as logger } from "./index-D8QhzqfR.js";
5
5
  class StreamingAudioPlayer {
6
6
  constructor(options) {
7
7
  __publicField(this, "audioContext", null);
@@ -39,7 +39,7 @@ export declare class AvatarController {
39
39
  send(audioData: ArrayBuffer, end?: boolean): string | null;
40
40
  close(): void;
41
41
  yieldAudioData(data: Uint8Array, isLast?: boolean): string | null;
42
- yieldFramesData(keyframes: Flame[], conversationId: string): void;
42
+ yieldFramesData(keyframesDataArray: (Uint8Array | ArrayBuffer)[], conversationId: string): void;
43
43
  pause(): void;
44
44
  resume(): Promise<void>;
45
45
  interrupt(): void;
@@ -61,4 +61,5 @@ export declare class AvatarView {
61
61
  get isOpaque(): boolean;
62
62
  set isOpaque(value: boolean);
63
63
  setBackgroundImage(image: HTMLImageElement | string | null): void;
64
+ setTransform(x: number, y: number, scale: number): void;
64
65
  }