@omote/three 0.2.0 → 0.3.2

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/dist/index.d.cts CHANGED
@@ -1,6 +1,10 @@
1
1
  import * as _omote_core from '@omote/core';
2
- import { FaceCompositorConfig, EmotionWeights, ConversationalState, A2EOrchestratorConfig } from '@omote/core';
2
+ import { FaceCompositorConfig, CharacterControllerConfig, FrameSource, TTSBackend, TTSSpeakerConfig, SpeechListenerConfig, TranscriptResult, VoiceOrchestratorConfig, ConversationalState, LoadingProgress, EmotionWeights, CharacterProfile } from '@omote/core';
3
+ export { FrameSource, TTSSpeakerConfig as TTSConfig } from '@omote/core';
4
+ import { SpeakOptions, StreamTextSink } from '@omote/avatar';
5
+ import * as THREE from 'three';
3
6
  import { Object3D, Camera, SkinnedMesh } from 'three';
7
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
4
8
 
5
9
  /**
6
10
  * SceneDiscovery — Traverse a Three.js scene graph to discover bones and
@@ -67,35 +71,22 @@ interface SceneDiscoveryResult {
67
71
  */
68
72
  declare function discoverScene(scene: SceneObject): SceneDiscoveryResult;
69
73
 
70
- /** Generic frame source — any object that emits 'frame' events with blendshapes. */
71
- interface FrameSource {
72
- on(event: 'frame', callback: (frame: {
73
- blendshapes: Float32Array;
74
- }) => void): void;
75
- off?(event: 'frame', callback: (...args: any[]) => void): void;
76
- }
77
74
  interface OmoteAvatarOptions {
78
75
  /** Three.js Object3D (loaded GLB scene, Group, etc.) to traverse for meshes and bones. */
79
76
  target: Object3D;
80
77
  /** FaceCompositor configuration (profile, emotion, life layer). */
81
78
  compositor?: FaceCompositorConfig;
82
79
  /** Gaze tracking configuration. */
83
- gaze?: {
84
- enabled?: boolean;
85
- yawInfluence?: number;
86
- pitchInfluence?: number;
87
- smoothing?: number;
88
- };
80
+ gaze?: CharacterControllerConfig['gaze'];
89
81
  }
90
82
  declare class OmoteAvatar {
91
83
  private readonly controller;
92
84
  private readonly discovery;
85
+ private readonly core;
93
86
  private frameSourceCallback;
94
87
  private connectedSource;
95
88
  private currentBlendshapes;
96
89
  private _emotion;
97
- private _isSpeaking;
98
- private _state;
99
90
  private _audioEnergy;
100
91
  constructor(options: OmoteAvatarOptions);
101
92
  /**
@@ -119,6 +110,32 @@ declare class OmoteAvatar {
119
110
  connectFrameSource(source: FrameSource): void;
120
111
  /** Disconnect the currently connected frame source. */
121
112
  disconnectFrameSource(): void;
113
+ /** Warm up AudioContext for iOS/Safari autoplay policy. Call from user gesture. */
114
+ warmup(): Promise<void>;
115
+ connectSpeaker(tts: TTSBackend, config?: TTSSpeakerConfig): Promise<void>;
116
+ speak(text: string, options?: SpeakOptions): Promise<void>;
117
+ streamText(options?: SpeakOptions): Promise<StreamTextSink>;
118
+ stopSpeaking(): void;
119
+ disconnectSpeaker(): Promise<void>;
120
+ /** @deprecated Use connectSpeaker(). Will be removed in v1.0. */
121
+ connectTTS(tts: TTSBackend, config?: TTSSpeakerConfig): Promise<void>;
122
+ /** @deprecated Use disconnectSpeaker(). Will be removed in v1.0. */
123
+ disconnectTTS(): Promise<void>;
124
+ connectListener(config?: SpeechListenerConfig): Promise<void>;
125
+ startListening(): Promise<void>;
126
+ stopListening(): void;
127
+ onTranscript(callback: (result: TranscriptResult) => void): () => void;
128
+ disconnectListener(): Promise<void>;
129
+ connectVoice(config: VoiceOrchestratorConfig): Promise<void>;
130
+ disconnectVoice(): Promise<void>;
131
+ onTranscriptEvent(callback: (result: TranscriptResult) => void): () => void;
132
+ onVoiceStateChange(callback: (state: ConversationalState) => void): () => void;
133
+ onLoadingProgress(callback: (progress: LoadingProgress) => void): () => void;
134
+ onError(callback: (error: Error) => void): () => void;
135
+ onAudioLevel(callback: (level: {
136
+ rms: number;
137
+ peak: number;
138
+ }) => void): () => void;
122
139
  /** Set raw blendshapes directly (alternative to connectFrameSource). */
123
140
  setFrame(blendshapes: Float32Array): void;
124
141
  /** Set the current emotion (string preset name or EmotionWeights object). */
@@ -129,6 +146,8 @@ declare class OmoteAvatar {
129
146
  setState(state: ConversationalState): void;
130
147
  /** Set audio energy level (0-1, drives emphasis/gesture intensity). */
131
148
  setAudioEnergy(energy: number): void;
149
+ /** Update character expression profile at runtime. */
150
+ setProfile(profile: CharacterProfile): void;
132
151
  /** Access the underlying FaceCompositor for advanced configuration. */
133
152
  get compositor(): _omote_core.FaceCompositor;
134
153
  /** Access discovered scene parts (meshes, bones). */
@@ -137,10 +156,20 @@ declare class OmoteAvatar {
137
156
  get hasMorphTargets(): boolean;
138
157
  /** Number of successfully mapped ARKit blendshapes. */
139
158
  get mappedBlendshapeCount(): number;
159
+ /** Whether the avatar is currently speaking via TTS. */
160
+ get isSpeaking(): boolean;
161
+ /** Whether the avatar is currently listening for speech. */
162
+ get isListening(): boolean;
163
+ /** Current conversational state. */
164
+ get conversationalState(): ConversationalState;
165
+ /** Access the internal TTSSpeaker (null if not connected). */
166
+ get speaker(): _omote_core.TTSSpeaker | null;
167
+ /** Access the internal SpeechListener (null if not connected). */
168
+ get listener(): _omote_core.SpeechListener | null;
140
169
  /** Reset all state (smoothing, life layer, emotions). */
141
170
  reset(): void;
142
- /** Disconnect frame sources and dispose the controller. */
143
- dispose(): void;
171
+ /** Disconnect all voice resources, frame sources, and dispose the controller. */
172
+ dispose(): Promise<void>;
144
173
  }
145
174
 
146
175
  /**
@@ -162,6 +191,48 @@ declare class OmoteAvatar {
162
191
  */
163
192
  declare function writeBlendshapes(blendshapes: Float32Array, morphEntries: MorphIndexEntry[]): void;
164
193
 
194
+ /**
195
+ * createAvatar — Async factory for a complete Three.js avatar scene.
196
+ *
197
+ * Sets up renderer, scene, camera, lighting, GLTF loading, OmoteAvatar,
198
+ * render loop, and resize handling. Returns a handle with all sub-objects.
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * import { createAvatar } from '@omote/three';
203
+ *
204
+ * const { avatar, dispose } = await createAvatar({
205
+ * src: '/avatar.glb',
206
+ * container: '#avatar-container',
207
+ * });
208
+ * avatar.connectFrameSource(pipeline);
209
+ * ```
210
+ *
211
+ * @category Three
212
+ */
213
+
214
+ interface CreateAvatarConfig {
215
+ /** URL to GLB/GLTF avatar model */
216
+ src: string;
217
+ /** Container element or CSS selector */
218
+ container: HTMLElement | string;
219
+ /** Camera FOV (default: 35) */
220
+ fov?: number;
221
+ /** Enable orbit controls (default: true) */
222
+ controls?: boolean;
223
+ }
224
+ interface AvatarHandle {
225
+ avatar: OmoteAvatar;
226
+ scene: THREE.Scene;
227
+ camera: THREE.PerspectiveCamera;
228
+ renderer: THREE.WebGLRenderer;
229
+ controls: OrbitControls | null;
230
+ /** Animation clips embedded in the GLTF/GLB file. Pass to avatar.connectAnimations(). */
231
+ animations: THREE.AnimationClip[];
232
+ dispose(): void;
233
+ }
234
+ declare function createAvatar(config: CreateAvatarConfig): Promise<AvatarHandle>;
235
+
165
236
  interface BlendshapeControllerOptions {
166
237
  /** Blendshape names in order (default: LAM_BLENDSHAPES, 52 ARKit) */
167
238
  names?: readonly string[];
@@ -186,25 +257,4 @@ declare class BlendshapeController {
186
257
  dispose(): void;
187
258
  }
188
259
 
189
- interface OmoteA2EOptions extends A2EOrchestratorConfig {
190
- target: Object3D;
191
- controllerOptions?: BlendshapeControllerOptions;
192
- }
193
- /**
194
- * @deprecated Use {@link OmoteAvatar} instead. OmoteA2E will be removed in v0.8.0.
195
- */
196
- declare class OmoteA2E {
197
- private orchestrator;
198
- private controller;
199
- constructor(options: OmoteA2EOptions);
200
- load(): Promise<void>;
201
- start(): Promise<void>;
202
- stop(): void;
203
- update(): void;
204
- dispose(): Promise<void>;
205
- get isReady(): boolean;
206
- get isStreaming(): boolean;
207
- get backend(): string | null;
208
- }
209
-
210
- export { BlendshapeController, type BlendshapeControllerOptions, type DiscoveredBone, type DiscoveredMesh, type FrameSource, type MorphIndexEntry, OmoteA2E, type OmoteA2EOptions, OmoteAvatar, type OmoteAvatarOptions, type SceneDiscoveryResult, type SceneObject, discoverScene, writeBlendshapes };
260
+ export { type AvatarHandle, BlendshapeController, type BlendshapeControllerOptions, type CreateAvatarConfig, type DiscoveredBone, type DiscoveredMesh, type MorphIndexEntry, OmoteAvatar, type OmoteAvatarOptions, type SceneDiscoveryResult, type SceneObject, createAvatar, discoverScene, writeBlendshapes };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import * as _omote_core from '@omote/core';
2
- import { FaceCompositorConfig, EmotionWeights, ConversationalState, A2EOrchestratorConfig } from '@omote/core';
2
+ import { FaceCompositorConfig, CharacterControllerConfig, FrameSource, TTSBackend, TTSSpeakerConfig, SpeechListenerConfig, TranscriptResult, VoiceOrchestratorConfig, ConversationalState, LoadingProgress, EmotionWeights, CharacterProfile } from '@omote/core';
3
+ export { FrameSource, TTSSpeakerConfig as TTSConfig } from '@omote/core';
4
+ import { SpeakOptions, StreamTextSink } from '@omote/avatar';
5
+ import * as THREE from 'three';
3
6
  import { Object3D, Camera, SkinnedMesh } from 'three';
7
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
4
8
 
5
9
  /**
6
10
  * SceneDiscovery — Traverse a Three.js scene graph to discover bones and
@@ -67,35 +71,22 @@ interface SceneDiscoveryResult {
67
71
  */
68
72
  declare function discoverScene(scene: SceneObject): SceneDiscoveryResult;
69
73
 
70
- /** Generic frame source — any object that emits 'frame' events with blendshapes. */
71
- interface FrameSource {
72
- on(event: 'frame', callback: (frame: {
73
- blendshapes: Float32Array;
74
- }) => void): void;
75
- off?(event: 'frame', callback: (...args: any[]) => void): void;
76
- }
77
74
  interface OmoteAvatarOptions {
78
75
  /** Three.js Object3D (loaded GLB scene, Group, etc.) to traverse for meshes and bones. */
79
76
  target: Object3D;
80
77
  /** FaceCompositor configuration (profile, emotion, life layer). */
81
78
  compositor?: FaceCompositorConfig;
82
79
  /** Gaze tracking configuration. */
83
- gaze?: {
84
- enabled?: boolean;
85
- yawInfluence?: number;
86
- pitchInfluence?: number;
87
- smoothing?: number;
88
- };
80
+ gaze?: CharacterControllerConfig['gaze'];
89
81
  }
90
82
  declare class OmoteAvatar {
91
83
  private readonly controller;
92
84
  private readonly discovery;
85
+ private readonly core;
93
86
  private frameSourceCallback;
94
87
  private connectedSource;
95
88
  private currentBlendshapes;
96
89
  private _emotion;
97
- private _isSpeaking;
98
- private _state;
99
90
  private _audioEnergy;
100
91
  constructor(options: OmoteAvatarOptions);
101
92
  /**
@@ -119,6 +110,32 @@ declare class OmoteAvatar {
119
110
  connectFrameSource(source: FrameSource): void;
120
111
  /** Disconnect the currently connected frame source. */
121
112
  disconnectFrameSource(): void;
113
+ /** Warm up AudioContext for iOS/Safari autoplay policy. Call from user gesture. */
114
+ warmup(): Promise<void>;
115
+ connectSpeaker(tts: TTSBackend, config?: TTSSpeakerConfig): Promise<void>;
116
+ speak(text: string, options?: SpeakOptions): Promise<void>;
117
+ streamText(options?: SpeakOptions): Promise<StreamTextSink>;
118
+ stopSpeaking(): void;
119
+ disconnectSpeaker(): Promise<void>;
120
+ /** @deprecated Use connectSpeaker(). Will be removed in v1.0. */
121
+ connectTTS(tts: TTSBackend, config?: TTSSpeakerConfig): Promise<void>;
122
+ /** @deprecated Use disconnectSpeaker(). Will be removed in v1.0. */
123
+ disconnectTTS(): Promise<void>;
124
+ connectListener(config?: SpeechListenerConfig): Promise<void>;
125
+ startListening(): Promise<void>;
126
+ stopListening(): void;
127
+ onTranscript(callback: (result: TranscriptResult) => void): () => void;
128
+ disconnectListener(): Promise<void>;
129
+ connectVoice(config: VoiceOrchestratorConfig): Promise<void>;
130
+ disconnectVoice(): Promise<void>;
131
+ onTranscriptEvent(callback: (result: TranscriptResult) => void): () => void;
132
+ onVoiceStateChange(callback: (state: ConversationalState) => void): () => void;
133
+ onLoadingProgress(callback: (progress: LoadingProgress) => void): () => void;
134
+ onError(callback: (error: Error) => void): () => void;
135
+ onAudioLevel(callback: (level: {
136
+ rms: number;
137
+ peak: number;
138
+ }) => void): () => void;
122
139
  /** Set raw blendshapes directly (alternative to connectFrameSource). */
123
140
  setFrame(blendshapes: Float32Array): void;
124
141
  /** Set the current emotion (string preset name or EmotionWeights object). */
@@ -129,6 +146,8 @@ declare class OmoteAvatar {
129
146
  setState(state: ConversationalState): void;
130
147
  /** Set audio energy level (0-1, drives emphasis/gesture intensity). */
131
148
  setAudioEnergy(energy: number): void;
149
+ /** Update character expression profile at runtime. */
150
+ setProfile(profile: CharacterProfile): void;
132
151
  /** Access the underlying FaceCompositor for advanced configuration. */
133
152
  get compositor(): _omote_core.FaceCompositor;
134
153
  /** Access discovered scene parts (meshes, bones). */
@@ -137,10 +156,20 @@ declare class OmoteAvatar {
137
156
  get hasMorphTargets(): boolean;
138
157
  /** Number of successfully mapped ARKit blendshapes. */
139
158
  get mappedBlendshapeCount(): number;
159
+ /** Whether the avatar is currently speaking via TTS. */
160
+ get isSpeaking(): boolean;
161
+ /** Whether the avatar is currently listening for speech. */
162
+ get isListening(): boolean;
163
+ /** Current conversational state. */
164
+ get conversationalState(): ConversationalState;
165
+ /** Access the internal TTSSpeaker (null if not connected). */
166
+ get speaker(): _omote_core.TTSSpeaker | null;
167
+ /** Access the internal SpeechListener (null if not connected). */
168
+ get listener(): _omote_core.SpeechListener | null;
140
169
  /** Reset all state (smoothing, life layer, emotions). */
141
170
  reset(): void;
142
- /** Disconnect frame sources and dispose the controller. */
143
- dispose(): void;
171
+ /** Disconnect all voice resources, frame sources, and dispose the controller. */
172
+ dispose(): Promise<void>;
144
173
  }
145
174
 
146
175
  /**
@@ -162,6 +191,48 @@ declare class OmoteAvatar {
162
191
  */
163
192
  declare function writeBlendshapes(blendshapes: Float32Array, morphEntries: MorphIndexEntry[]): void;
164
193
 
194
+ /**
195
+ * createAvatar — Async factory for a complete Three.js avatar scene.
196
+ *
197
+ * Sets up renderer, scene, camera, lighting, GLTF loading, OmoteAvatar,
198
+ * render loop, and resize handling. Returns a handle with all sub-objects.
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * import { createAvatar } from '@omote/three';
203
+ *
204
+ * const { avatar, dispose } = await createAvatar({
205
+ * src: '/avatar.glb',
206
+ * container: '#avatar-container',
207
+ * });
208
+ * avatar.connectFrameSource(pipeline);
209
+ * ```
210
+ *
211
+ * @category Three
212
+ */
213
+
214
+ interface CreateAvatarConfig {
215
+ /** URL to GLB/GLTF avatar model */
216
+ src: string;
217
+ /** Container element or CSS selector */
218
+ container: HTMLElement | string;
219
+ /** Camera FOV (default: 35) */
220
+ fov?: number;
221
+ /** Enable orbit controls (default: true) */
222
+ controls?: boolean;
223
+ }
224
+ interface AvatarHandle {
225
+ avatar: OmoteAvatar;
226
+ scene: THREE.Scene;
227
+ camera: THREE.PerspectiveCamera;
228
+ renderer: THREE.WebGLRenderer;
229
+ controls: OrbitControls | null;
230
+ /** Animation clips embedded in the GLTF/GLB file. Pass to avatar.connectAnimations(). */
231
+ animations: THREE.AnimationClip[];
232
+ dispose(): void;
233
+ }
234
+ declare function createAvatar(config: CreateAvatarConfig): Promise<AvatarHandle>;
235
+
165
236
  interface BlendshapeControllerOptions {
166
237
  /** Blendshape names in order (default: LAM_BLENDSHAPES, 52 ARKit) */
167
238
  names?: readonly string[];
@@ -186,25 +257,4 @@ declare class BlendshapeController {
186
257
  dispose(): void;
187
258
  }
188
259
 
189
- interface OmoteA2EOptions extends A2EOrchestratorConfig {
190
- target: Object3D;
191
- controllerOptions?: BlendshapeControllerOptions;
192
- }
193
- /**
194
- * @deprecated Use {@link OmoteAvatar} instead. OmoteA2E will be removed in v0.8.0.
195
- */
196
- declare class OmoteA2E {
197
- private orchestrator;
198
- private controller;
199
- constructor(options: OmoteA2EOptions);
200
- load(): Promise<void>;
201
- start(): Promise<void>;
202
- stop(): void;
203
- update(): void;
204
- dispose(): Promise<void>;
205
- get isReady(): boolean;
206
- get isStreaming(): boolean;
207
- get backend(): string | null;
208
- }
209
-
210
- export { BlendshapeController, type BlendshapeControllerOptions, type DiscoveredBone, type DiscoveredMesh, type FrameSource, type MorphIndexEntry, OmoteA2E, type OmoteA2EOptions, OmoteAvatar, type OmoteAvatarOptions, type SceneDiscoveryResult, type SceneObject, discoverScene, writeBlendshapes };
260
+ export { type AvatarHandle, BlendshapeController, type BlendshapeControllerOptions, type CreateAvatarConfig, type DiscoveredBone, type DiscoveredMesh, type MorphIndexEntry, OmoteAvatar, type OmoteAvatarOptions, type SceneDiscoveryResult, type SceneObject, createAvatar, discoverScene, writeBlendshapes };