@npcify/web 0.2.0 → 0.2.1

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/README.md CHANGED
@@ -98,7 +98,9 @@ animate()
98
98
  - `character.attachTo(parent)` / `character.detach()`: Attach or detach from any `THREE.Object3D`.
99
99
  - `character.setShadows({ cast, receive })`: Configure shadow flags across all character meshes.
100
100
  - `character.setTransform({ position, rotation, scale })`: Set root transform with `Vector3`/`Euler` or `[x, y, z]` tuples.
101
- - `character.setGazeTarget(object3d)`: Make template-face eyes follow a `THREE.Camera` or `THREE.Object3D`.
101
+ - `character.setGazeTarget(object3d)`: Make template-face eyes follow a `THREE.Camera` or `THREE.Object3D` with their gaze cone and idle eye moves. Other faces do not follow it. `mountNpcify` sets its camera.
102
+ - `character.lookAt(object3d | [x, y, z] | { x, y, z } | x, y, z)`: Look at an object or a world position. A template face keeps its gaze cone, idle eye moves and staging look cues; other faces turn their eyes with three-vrm `vrm.lookAt.target`. Coordinates that are not finite numbers throw a `RangeError`.
103
+ - `character.clearLookAt()`: Remove the gaze target, so that the eyes look ahead.
102
104
  - **Audio & Web Audio (`character.audio`)**:
103
105
  - `character.audio.element`: Underlying `HTMLAudioElement | null`.
104
106
  - `character.audio.playing`, `paused`, `ended`, `currentTime`, `duration`, `unlocked`.
package/dist/index.d.ts CHANGED
@@ -1,10 +1,9 @@
1
1
  import { VRM, VRMExpressionPresetName, VRMHumanoid, VRMHumanBoneName } from '@pixiv/three-vrm';
2
2
  import { VRMAnimation } from '@pixiv/three-vrm-animation';
3
- import { AnimationMixer, AnimationAction, Object3D, Group, SkinnedMesh, Mesh, Material, Skeleton, Vector3, Euler, Scene, PerspectiveCamera, WebGLRenderer } from 'three';
3
+ import { AnimationMixer, AnimationAction, Object3D, Vector3, Group, SkinnedMesh, Mesh, Material, Skeleton, Euler, Scene, PerspectiveCamera, WebGLRenderer } from 'three';
4
4
  import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
5
5
 
6
- declare const TTS_PROVIDERS: readonly ["11labs"];
7
- type TtsProviderId = (typeof TTS_PROVIDERS)[number];
6
+ type TtsProviderId = string;
8
7
  type NullableTtsProviderId = TtsProviderId | null;
9
8
 
10
9
  declare const EXPRESSION_CALL_RANGES: readonly ["linear", "bool"];
@@ -977,6 +976,12 @@ declare class StagingPlayer {
977
976
  }
978
977
 
979
978
  type Vector3Tuple = readonly [number, number, number];
979
+ interface Vector3Like {
980
+ readonly x: number;
981
+ readonly y: number;
982
+ readonly z: number;
983
+ }
984
+ type CharacterLookAtTarget = Object3D | Vector3 | Vector3Tuple | Vector3Like | null;
980
985
  interface CharacterShadowOptions {
981
986
  cast?: boolean;
982
987
  receive?: boolean;
@@ -994,8 +999,26 @@ declare class CharacterSceneRig {
994
999
  private cachedSkeletons;
995
1000
  private shadowOptions;
996
1001
  private transformOptions;
1002
+ private lookAtAnchor;
1003
+ /** The target that setVrmLookAtTarget set on the current model. */
1004
+ private vrmLookAtTarget;
997
1005
  get vrm(): VRM | null;
998
1006
  setVrm(vrm: VRM | null): void;
1007
+ /**
1008
+ * The `Object3D` of a `lookAt()` argument: an `Object3D` as it is, a point
1009
+ * or three coordinates as a world position that this rig keeps, or null.
1010
+ * Coordinates that are not finite numbers throw a `RangeError` and change
1011
+ * nothing.
1012
+ */
1013
+ resolveLookAtTarget(targetOrX: CharacterLookAtTarget | number, y?: number, z?: number): Object3D | null;
1014
+ /**
1015
+ * Sets three-vrm's own look-at target (`vrm.lookAt.target`) of the current
1016
+ * model. Null removes the target that this method set; a target that other
1017
+ * code set stays. The IdleFace of a template face does not move the eyes
1018
+ * while `vrm.lookAt.target` is set.
1019
+ */
1020
+ setVrmLookAtTarget(target: Object3D | null): void;
1021
+ private updateLookAtAnchor;
999
1022
  /** Root Three.js group containing the VRM hierarchy (`vrm.scene`). */
1000
1023
  get scene(): Group | null;
1001
1024
  /** Alias for `scene` for Three.js `Object3D` workflows. */
@@ -1217,6 +1240,8 @@ declare class CharacterRuntime {
1217
1240
  protected readonly streamPlayback: StreamPlaybackController;
1218
1241
  protected defaultParent: Object3D | null;
1219
1242
  protected currentGazeTarget: Object3D | null;
1243
+ /** The current gaze target came from `lookAt()`. */
1244
+ protected lookAtActive: boolean;
1220
1245
  protected thinkingState: boolean;
1221
1246
  protected errorCallback: ((error: Error) => void) | null;
1222
1247
  constructor(options: CharacterRuntimeInitOptions);
@@ -1296,8 +1321,22 @@ declare class CharacterRuntime {
1296
1321
  getExpressionWeight(name: FacialChannelName): number;
1297
1322
  setEmotion(name: FacialChannelName, weight?: number, mouthMode?: FacialMouthMode): void;
1298
1323
  clearEmotion(mouthMode?: FacialMouthMode): void;
1299
- /** The object the eyes of a template face follow (the camera); null looks ahead. */
1324
+ /**
1325
+ * The object the eyes of a template face follow (the camera); null looks
1326
+ * ahead. It replaces a `lookAt()` target. Other faces do not follow it.
1327
+ */
1300
1328
  setGazeTarget(target: Object3D | null): void;
1329
+ /**
1330
+ * Direct the character's gaze toward a Three.js `Object3D` or world
1331
+ * coordinates. A template face keeps its gaze cone, idle eye moves and the
1332
+ * look cues of staging; other faces turn their eyes with three-vrm's
1333
+ * `vrm.lookAt.target`. Coordinates must be finite numbers, else this throws
1334
+ * a `RangeError` and keeps the current target.
1335
+ */
1336
+ lookAt(target: CharacterLookAtTarget): void;
1337
+ lookAt(x: number, y: number, z: number): void;
1338
+ /** Reset the character's gaze target so the eyes look straight ahead. */
1339
+ clearLookAt(): void;
1301
1340
  startPerformanceRecording(options?: PerformanceRecordingStartOptions): void;
1302
1341
  stopPerformanceRecording(): PerformanceRecording | null;
1303
1342
  getPerformanceRecording(): PerformanceRecording | null;
@@ -1314,6 +1353,13 @@ declare class CharacterRuntime {
1314
1353
  update(delta: number): void;
1315
1354
  protected readonly getAudioPlayer: () => AudioPlayer;
1316
1355
  protected readonly getStagingPlayer: () => StagingPlayer;
1356
+ /**
1357
+ * A template face follows the gaze target with its IdleFace. Only a
1358
+ * `lookAt()` target moves the eyes of another face, through three-vrm's
1359
+ * `vrm.lookAt.target`; on a template face that target would stop the
1360
+ * IdleFace (its gaze cone, idle eye moves and look cues).
1361
+ */
1362
+ protected applyGaze(): void;
1317
1363
  protected resetRuntimeAssets(): void;
1318
1364
  protected disposeRuntimeAssets(): void;
1319
1365
  protected readonly handleCallbackError: (context: string, error: unknown) => void;
@@ -1469,4 +1515,4 @@ interface NpcifyView {
1469
1515
  /** Mount into an existing canvas. Its CSS must give it a nonzero width and height. */
1470
1516
  declare const mountNpcify: (options: MountNpcifyOptions) => Promise<NpcifyView>;
1471
1517
 
1472
- export { AnimationController, type AnimationControllerLike, type AssetLoadProgress, type AudioPerformanceFrameSnapshot, AudioPlayer, BakedConversation, type BakedConversationAsset, Character, CharacterAnimation, type CharacterAnimationPlayOptions, CharacterAudio, type CharacterDisposeOptions, CharacterExpressions, type CharacterOptions, type CharacterPlaybackCursor, CharacterRuntime, type CharacterRuntimeInitOptions, CharacterSceneRig, type CharacterShadowOptions, type CharacterSpeechState, type CharacterTransformOptions, type ConversationTurnOptions, type FacialChannelName, type FacialCueOptions, type FacialMouthMode, type FacialPerformanceFrameSnapshot, FacialPerformanceLayer, type FacialPerformanceLayerId, FacialPerformanceMixer, type FacialPerformanceModelSnapshot, type LlmThinkingPayload, type LoadCharacterOptions, type MountNpcifyOptions, Npcify, type NpcifyAssetInfo, Character as NpcifyCharacter, type NpcifyOptions, type NpcifyView, PERFORMANCE_FILE_EXTENSION, PERFORMANCE_MEDIA_TYPE, type PerformanceAnalysis, type PerformanceAnalysisOptions, type PerformanceEvent, type PerformanceFrame, type PerformanceIssue, type PerformanceKind, type PerformanceRecording, PerformanceRecordingSchemaVersion, type PerformanceRecordingStartOptions, type PerformanceTimelineSnapshot, type PlayStagingOptions, RemoteAnimationController, type RepeatedVisemeTransitionAnalysis, type StagingOptionsReadyPayload, type StagingPlaybackStart, type StagingSpeechPlaybackEvent, type Vector3Tuple, type VisemePerformanceFrameSnapshot, analyzePerformanceRecording, createCharacter, decodePerformance, encodePerformance, loadBakedConversation, loadCharacter, mountNpcify };
1518
+ export { AnimationController, type AnimationControllerLike, type AssetLoadProgress, type AudioPerformanceFrameSnapshot, AudioPlayer, BakedConversation, type BakedConversationAsset, Character, CharacterAnimation, type CharacterAnimationPlayOptions, CharacterAudio, type CharacterDisposeOptions, CharacterExpressions, type CharacterLookAtTarget, type CharacterOptions, type CharacterPlaybackCursor, CharacterRuntime, type CharacterRuntimeInitOptions, CharacterSceneRig, type CharacterShadowOptions, type CharacterSpeechState, type CharacterTransformOptions, type ConversationTurnOptions, type FacialChannelName, type FacialCueOptions, type FacialMouthMode, type FacialPerformanceFrameSnapshot, FacialPerformanceLayer, type FacialPerformanceLayerId, FacialPerformanceMixer, type FacialPerformanceModelSnapshot, type LlmThinkingPayload, type LoadCharacterOptions, type MountNpcifyOptions, Npcify, type NpcifyAssetInfo, Character as NpcifyCharacter, type NpcifyOptions, type NpcifyView, PERFORMANCE_FILE_EXTENSION, PERFORMANCE_MEDIA_TYPE, type PerformanceAnalysis, type PerformanceAnalysisOptions, type PerformanceEvent, type PerformanceFrame, type PerformanceIssue, type PerformanceKind, type PerformanceRecording, PerformanceRecordingSchemaVersion, type PerformanceRecordingStartOptions, type PerformanceTimelineSnapshot, type PlayStagingOptions, RemoteAnimationController, type RepeatedVisemeTransitionAnalysis, type StagingOptionsReadyPayload, type StagingPlaybackStart, type StagingSpeechPlaybackEvent, type Vector3Like, type Vector3Tuple, type VisemePerformanceFrameSnapshot, analyzePerformanceRecording, createCharacter, decodePerformance, encodePerformance, loadBakedConversation, loadCharacter, mountNpcify };
package/dist/index.js CHANGED
@@ -5,693 +5,9 @@ var STAGING_PROTOCOL_VERSION = 1;
5
5
  var SERVER_RENDER_PROTOCOL_VERSION = 3;
6
6
  var MAXIMUM_PLAYBACK_DURATION_SECONDS = 10 * 60;
7
7
 
8
- // ../ts-shared/src/tts-voices-asian.ts
9
- var asianTtsVoices = [
10
- {
11
- id: "qbfQuoRJv1T3ei3qV4bc",
12
- name: "Kazuha",
13
- gender: "female",
14
- description: "Conversation: Warm & Friendly",
15
- lang: ["Japanese"]
16
- },
17
- {
18
- id: "NO5A3b3sSzDyJQF7MiNS",
19
- name: "Shohei",
20
- gender: "male",
21
- description: "Conversation: Serious, Clear and Measured",
22
- lang: ["Japanese"]
23
- },
24
- {
25
- id: "3321Alera3fXjEWjjbAX",
26
- name: "Akane",
27
- gender: "female",
28
- description: "Calm: Soft, Warm and Soothing",
29
- lang: ["Japanese"]
30
- },
31
- {
32
- id: "4sirbXwrtRlmPV80MJkQ",
33
- name: "Sora",
34
- gender: "male",
35
- description: "Calm: Clear and Airy",
36
- lang: ["Japanese"]
37
- },
38
- {
39
- id: "HxuFAkkGVeQs1sDIMF5g",
40
- name: "Claire",
41
- gender: "female",
42
- description: "Lively: Cute & Cheerful JP",
43
- lang: ["Japanese"]
44
- },
45
- {
46
- id: "tGhb4uYSV8sWBI31DYU8",
47
- name: "Gary",
48
- gender: "male",
49
- description: "Lively: Joyful, Clear and Husky",
50
- lang: ["Japanese"]
51
- },
52
- {
53
- id: "8PfKHL4nZToWC3pbz9U9",
54
- name: "Rose",
55
- gender: "female",
56
- description: "Mature narration: Inviting, Clear and Steady",
57
- lang: ["Japanese"]
58
- },
59
- {
60
- id: "Mv8AjrYZCBkdsmDHNwcB",
61
- name: "Ishibashi",
62
- gender: "male",
63
- description: "Mature narration: Inviting, Natural and Smoky",
64
- lang: ["Japanese"]
65
- },
66
- {
67
- id: "6awt6FKyZGV0HyQEwisX",
68
- name: "Suzu",
69
- gender: "female",
70
- description: "Character: Cute, Clear & Calm",
71
- lang: ["Japanese"]
72
- },
73
- {
74
- id: "ZcX76PwFSkrkyI78RBTK",
75
- name: "Nayuta",
76
- gender: "male",
77
- description: "Character: Dark Anime Hero",
78
- lang: ["Japanese"]
79
- },
80
- {
81
- id: "9lHjugDhwqoxA5MhX0az",
82
- name: "Anna Su",
83
- gender: "female",
84
- description: "Conversation: Casual, Friendly and Bright",
85
- lang: ["Chinese"]
86
- },
87
- {
88
- id: "UwT0JPexcCbH107hq7i5",
89
- name: "James",
90
- gender: "male",
91
- description: "Conversation: Young, Friendly and Positive",
92
- lang: ["Chinese"]
93
- },
94
- {
95
- id: "APSIkVZudNbPAwyPoeVO",
96
- name: "Sage",
97
- gender: "female",
98
- description: "Calm: Soothing & Gentle",
99
- lang: ["Chinese"]
100
- },
101
- {
102
- id: "Z5oklYidFFuqcVQNGzYK",
103
- name: "Aman",
104
- gender: "male",
105
- description: "Calm: ASMR, Soft and Whisper",
106
- lang: ["Chinese"]
107
- },
108
- {
109
- id: "ByhETIclHirOlWnWKhHc",
110
- name: "Shan Shan",
111
- gender: "female",
112
- description: "Lively: Young Energetic Female",
113
- lang: ["Chinese"]
114
- },
115
- {
116
- id: "5mZxJZhSmJTjL7GoYfYI",
117
- name: "Karo Yang",
118
- gender: "male",
119
- description: "Lively: Clear, Lively and Energetic",
120
- lang: ["Chinese"]
121
- },
122
- {
123
- id: "xDISamJf8LV5rG5A2te1",
124
- name: "Aki | Deep & Suspenseful",
125
- gender: "female",
126
- description: "Mature narration: Deep & Suspenseful",
127
- lang: ["Chinese"]
128
- },
129
- {
130
- id: "WuLq5z7nEcrhppO0ZQJw",
131
- name: "Martin Li",
132
- gender: "male",
133
- description: "Mature narration: Raspy, Serious and Deep",
134
- lang: ["Chinese"]
135
- },
136
- {
137
- id: "BT0SH7Hb8NRPpT5xbCgg",
138
- name: "Lulu",
139
- gender: "female",
140
- description: "Character: Cute Little Witch",
141
- lang: ["Chinese"]
142
- },
143
- {
144
- id: "YaHyfWIwVxVEIhSTnKOi",
145
- name: "Xiao Bai",
146
- gender: "male",
147
- description: "Character: Nasal, Slow and Annoying",
148
- lang: ["Chinese"]
149
- },
150
- {
151
- id: "8jHHF8rMqMlg8if2mOUe",
152
- name: "Han",
153
- gender: "female",
154
- description: "Conversation: Natural, Casual and Spontaneous",
155
- lang: ["Korean"]
156
- },
157
- {
158
- id: "pb3lVZVjdFWbkhPKlelB",
159
- name: "Harry Kim",
160
- gender: "male",
161
- description: "Conversation: Soft, Natural and Steady",
162
- lang: ["Korean"]
163
- },
164
- {
165
- id: "7oLyBHyhxAjrctX6ZQlw",
166
- name: "Bomisori",
167
- gender: "female",
168
- description: "Calm: Warm and Clear",
169
- lang: ["Korean"]
170
- },
171
- {
172
- id: "BbsagRO6ohd8MKPS2Ob0",
173
- name: "Jin Geon Song",
174
- gender: "male",
175
- description: "Calm: Neutral, Calm and Steady",
176
- lang: ["Korean"]
177
- },
178
- {
179
- id: "bQlkYuipD5BHEhntA5iz",
180
- name: "JY",
181
- gender: "female",
182
- description: "Lively: Trendy K-Culture Vlog Girl",
183
- lang: ["Korean"]
184
- },
185
- {
186
- id: "1W00IGEmNmwmsDeYy7ag",
187
- name: "Krys",
188
- gender: "male",
189
- description: "Lively: Cheerful, Clear and Measured",
190
- lang: ["Korean"]
191
- },
192
- {
193
- id: "ksaI0TCD9BstzEzlxj4q",
194
- name: "Seulki",
195
- gender: "female",
196
- description: "Mature narration: Inviting, Calm and Measured",
197
- lang: ["Korean"]
198
- },
199
- {
200
- id: "FQ3MuLxZh0jHcZmA5vW1",
201
- name: "Dohyeon",
202
- gender: "male",
203
- description: "Mature narration: Whisper, Measured and Neutral",
204
- lang: ["Korean"]
205
- },
206
- {
207
- id: "DGDjWy2CQ8Ishu0meQte",
208
- name: "Chaemong",
209
- gender: "female",
210
- description: "Character: Young and Sassy",
211
- lang: ["Korean"]
212
- },
213
- {
214
- id: "ZZ4xhVcc83kZBfNIlIIz",
215
- name: "Manbo",
216
- gender: "male",
217
- description: "Character: Encouraging, Clear and Measured",
218
- lang: ["Korean"]
219
- }
220
- ];
221
-
222
- // ../ts-shared/src/tts-voices-european.ts
223
- var europeanTtsVoices = [
224
- {
225
- id: "kdmDKE6EkgrWrrykO9Qt",
226
- name: "Alexandra",
227
- gender: "female",
228
- description: "Conversation: Natural and Relatable",
229
- lang: ["English"]
230
- },
231
- {
232
- id: "UgBBYS2sOqTuMpoF3BR0",
233
- name: "Mark",
234
- gender: "male",
235
- description: "Conversation: Natural and Casual",
236
- lang: ["English"]
237
- },
238
- {
239
- id: "ftDdhfYtmfGP0tFlBYA1",
240
- name: "Alisha",
241
- gender: "female",
242
- description: "Calm: Soft and Engaging",
243
- lang: ["English"]
244
- },
245
- {
246
- id: "GUDYcgRAONiI1nXDcNQQ",
247
- name: "Milo",
248
- gender: "male",
249
- description: "Calm: Soothing and Meditative",
250
- lang: ["English"]
251
- },
252
- {
253
- id: "r1KmysJdVYZjJCm4mL3b",
254
- name: "Jessica",
255
- gender: "female",
256
- description: "Lively: Playful, Bright, Warm",
257
- lang: ["English"]
258
- },
259
- {
260
- id: "o2zd9K5QOO7ppTb04Lx0",
261
- name: "Gabriel Ripley",
262
- gender: "male",
263
- description: "Lively: Facetious, Quick-Spoken",
264
- lang: ["English"]
265
- },
266
- {
267
- id: "RILOU7YmBhvwJGDGjNmP",
268
- name: "Jane",
269
- gender: "female",
270
- description: "Mature narration: Professional Audiobook Reader",
271
- lang: ["English"]
272
- },
273
- {
274
- id: "wAGzRVkxKEs8La0lmdrE",
275
- name: "Sully",
276
- gender: "male",
277
- description: "Mature narration: Mature, Deep and Intriguing",
278
- lang: ["English"]
279
- },
280
- {
281
- id: "flHkNRp1BlvT73UL6gyz",
282
- name: "Jessica Anne Bogart",
283
- gender: "female",
284
- description: "Character: Eloquent Villain",
285
- lang: ["English"]
286
- },
287
- {
288
- id: "IRHApOXLvnW57QJPQH2P",
289
- name: "Adam - American, Dark and Tough",
290
- gender: "male",
291
- description: "Character: American, Dark and Tough",
292
- lang: ["English"]
293
- },
294
- {
295
- id: "lvQdCgwZfBuOzxyV5pxu",
296
- name: "Audia",
297
- gender: "female",
298
- description: "Conversation: Warm, Clear and Welcoming",
299
- lang: ["French"]
300
- },
301
- {
302
- id: "kENkNtk0xyzG09WW40xE",
303
- name: "Marcel - Warm and Conversational",
304
- gender: "male",
305
- description: "Conversation: Warm and Conversational",
306
- lang: ["French"]
307
- },
308
- {
309
- id: "kwhMCf63M8O3rCfnQ3oQ",
310
- name: "Caroline",
311
- gender: "female",
312
- description: "Calm: Warm, Sweet and Soft",
313
- lang: ["French"]
314
- },
315
- {
316
- id: "YV28ox2c5Cuh5rim0LrW",
317
- name: "Marcel - Warm, Soft and Intimate",
318
- gender: "male",
319
- description: "Calm: Warm, Soft and Intimate",
320
- lang: ["French"]
321
- },
322
- {
323
- id: "KSyQzmsYhFbuOhqj1Xxv",
324
- name: "Lea",
325
- gender: "female",
326
- description: "Lively: Energetic and Modern",
327
- lang: ["French"]
328
- },
329
- {
330
- id: "4TfTGcPwoefWe878B0rm",
331
- name: "Troy",
332
- gender: "male",
333
- description: "Lively: Cartoon Hero",
334
- lang: ["French"]
335
- },
336
- {
337
- id: "WeAAwKYcS06VmXw086yZ",
338
- name: "Victoria",
339
- gender: "female",
340
- description: "Mature narration: Warm and calm",
341
- lang: ["French"]
342
- },
343
- {
344
- id: "TTtB1x9U8PF0Vgf20IAP",
345
- name: "Adrien",
346
- gender: "male",
347
- description: "Mature narration: Deep, Comforting and Warm",
348
- lang: ["French"]
349
- },
350
- {
351
- id: "ZYOBieLaunTiQrTrvNQq",
352
- name: "Morgane",
353
- gender: "female",
354
- description: "Character: Gentle and Expressive",
355
- lang: ["French"]
356
- },
357
- {
358
- id: "RBhYSNMNu6b2CGZ9Fn1M",
359
- name: "Felix Tabarnak",
360
- gender: "male",
361
- description: "Character: Confident and Witty",
362
- lang: ["French"]
363
- },
364
- {
365
- id: "MuTiG4dbrEGYEy3XP4iP",
366
- name: "Rossana",
367
- gender: "female",
368
- description: "Conversation: Warm Italian Conversational",
369
- lang: ["Italian"]
370
- },
371
- {
372
- id: "5wE9Co8DESyhUw0GgAHG",
373
- name: "Alessandro Zanierato",
374
- gender: "male",
375
- description: "Conversation: Casual",
376
- lang: ["Italian"]
377
- },
378
- {
379
- id: "PS6wM7QnnPTUDE3t4bbl",
380
- name: "Serena",
381
- gender: "female",
382
- description: "Calm: Soft, Soothing and Gentle",
383
- lang: ["Italian"]
384
- },
385
- {
386
- id: "TnICJ0opDnjladqWtQ6k",
387
- name: "Livio",
388
- gender: "male",
389
- description: "Calm: Meditative and Balanced",
390
- lang: ["Italian"]
391
- },
392
- {
393
- id: "ZRKmc75tGxpIMNTEiwe0",
394
- name: "Mimmi",
395
- gender: "female",
396
- description: "Lively: Playful and Cartoonish",
397
- lang: ["Italian"]
398
- },
399
- {
400
- id: "nH7uLS5UdEnvKEOAXtlQ",
401
- name: "Vittorio",
402
- gender: "male",
403
- description: "Lively: Believable, Friendly and Rich",
404
- lang: ["Italian"]
405
- },
406
- {
407
- id: "fNmw8sukfGuvWVOp33Ge",
408
- name: "Tosca",
409
- gender: "female",
410
- description: "Mature narration: Mature, Whispery and Seductive",
411
- lang: ["Italian"]
412
- },
413
- {
414
- id: "YGp1lBJLaHhfIFT0yeDE",
415
- name: "RaffaeleR",
416
- gender: "male",
417
- description: "Mature narration: Deep, Rich and Steady",
418
- lang: ["Italian"]
419
- },
420
- {
421
- id: "G0q9AYE8QsarSbMtaIEu",
422
- name: "Elettra",
423
- gender: "female",
424
- description: "Character: Mature actress",
425
- lang: ["Italian"]
426
- },
427
- {
428
- id: "TdZgLZ1h5vbFJrgh8QqK",
429
- name: "Vito Pepe",
430
- gender: "male",
431
- description: "Character: Profound and Confident",
432
- lang: ["Italian"]
433
- },
434
- {
435
- id: "CaJslL1xziwefCeTNzHv",
436
- name: "Cristina Campos",
437
- gender: "female",
438
- description: "Conversation: Friendly and Soft",
439
- lang: ["Spanish"]
440
- },
441
- {
442
- id: "YExhVa4bZONzeingloMX",
443
- name: "Juan Carlos",
444
- gender: "male",
445
- description: "Conversation: Warm and Conversational",
446
- lang: ["Spanish"]
447
- },
448
- {
449
- id: "2Lb1en5ujrODDIqmp7F3",
450
- name: "Jhenny",
451
- gender: "female",
452
- description: "Calm: Soft, Calm, Sweet",
453
- lang: ["Spanish"]
454
- },
455
- {
456
- id: "iDEmt5MnqUotdwCIVplo",
457
- name: "Enrique Mondrag\xF3n",
458
- gender: "male",
459
- description: "Calm: Elegant and Dynamic",
460
- lang: ["Spanish"]
461
- },
462
- {
463
- id: "JYyJjNPfmNJdaby8LdZs",
464
- name: "Marlene",
465
- gender: "female",
466
- description: "Lively: Melodic, Pleasant and Bright",
467
- lang: ["Spanish"]
468
- },
469
- {
470
- id: "9F4C8ztpNUmXkdDDbz3J",
471
- name: "Dan",
472
- gender: "male",
473
- description: "Lively: Upbeat, Dynamic and Friendly",
474
- lang: ["Spanish"]
475
- },
476
- {
477
- id: "2rigMbVWLdqtBSCahJFX",
478
- name: "Tatiana Martin",
479
- gender: "female",
480
- description: "Mature narration: Wise-speaking, calm",
481
- lang: ["Spanish"]
482
- },
483
- {
484
- id: "k8cFOyAg7B9qwBlDDNTC",
485
- name: "Miguel",
486
- gender: "male",
487
- description: "Mature narration: Deep, Rich and Cinematic",
488
- lang: ["Spanish"]
489
- },
490
- {
491
- id: "U9tZtg3uJtVgXPkvosWR",
492
- name: "Kate",
493
- gender: "female",
494
- description: "Character: Playful Latina Storyteller",
495
- lang: ["Spanish"]
496
- },
497
- {
498
- id: "HMCmDsbKeaSZp5LMOYKR",
499
- name: "Johnny",
500
- gender: "male",
501
- description: "Character: Mocking, Sarcastic and Rich",
502
- lang: ["Spanish"]
503
- },
504
- {
505
- id: "dHAwRJVaEPhU907QLTPW",
506
- name: "Natalia",
507
- gender: "female",
508
- description: "Conversation: Gentle and Soothing",
509
- lang: ["Russian"]
510
- },
511
- {
512
- id: "qJBO8ZmKp4te7NTtYgzz",
513
- name: "Egor T",
514
- gender: "male",
515
- description: "Conversation: Natural, Soothing & Relatable",
516
- lang: ["Russian"]
517
- },
518
- {
519
- id: "ymDCYd8puC7gYjxIamPt",
520
- name: "Marina",
521
- gender: "female",
522
- description: "Calm: Soft, Clear and Warm",
523
- lang: ["Russian"]
524
- },
525
- {
526
- id: "e5A3tSm7sjA7Sbiz2Qac",
527
- name: "Maksim",
528
- gender: "male",
529
- description: "Calm: Deep and Steady",
530
- lang: ["Russian"]
531
- },
532
- {
533
- id: "AB9XsbSA4eLG12t2myjN",
534
- name: "Larisa Actrisa",
535
- gender: "female",
536
- description: "Lively: Confident and Clear",
537
- lang: ["Russian"]
538
- },
539
- {
540
- id: "m0OQuJtWCw1V23P0pQmG",
541
- name: "Eugene",
542
- gender: "male",
543
- description: "Lively: Bright, Clear & Engaging",
544
- lang: ["Russian"]
545
- },
546
- {
547
- id: "d60rsXo2p0OwikDR5bS7",
548
- name: "Olga Orlova",
549
- gender: "female",
550
- description: "Mature narration: Calm, Clear and Serious",
551
- lang: ["Russian"]
552
- },
553
- {
554
- id: "dWNEQ4rqRY6thcusuDyq",
555
- name: "Fuad",
556
- gender: "male",
557
- description: "Mature narration: Clear, Deep and Rich",
558
- lang: ["Russian"]
559
- },
560
- {
561
- id: "TPIitICAZ8CqlGZ81AKm",
562
- name: "Elen Kuragina",
563
- gender: "female",
564
- description: "Character: Golden & Dangerous",
565
- lang: ["Russian"]
566
- },
567
- {
568
- id: "6A9D8WSMm4rFsg2DWFeE",
569
- name: "Egor Gadzhiyev",
570
- gender: "male",
571
- description: "Character: Clear and Commanding",
572
- lang: ["Russian"]
573
- }
574
- ];
575
-
576
8
  // ../ts-shared/src/tts.ts
577
9
  var TTS_PROVIDERS = ["11labs"];
578
10
  var DEFAULT_TTS_PROVIDER = TTS_PROVIDERS[0];
579
- var ttsVoices = [
580
- {
581
- id: "ngvNHfiCrXLPAHcTrZK1",
582
- name: "Aki",
583
- gender: "female",
584
- description: "Friendly, Clear and Natural",
585
- lang: ["Japanese"]
586
- },
587
- {
588
- id: "8kgj5469z1URcH4MB2G4",
589
- name: "Sakuya",
590
- gender: "female",
591
- description: "Cheerful and Clear",
592
- lang: ["Japanese"]
593
- },
594
- {
595
- id: "KgETZ36CCLD1Cob4xpkv",
596
- name: "Romaco",
597
- description: "Cheerful, Clear and Full",
598
- gender: "female",
599
- lang: ["Japanese"]
600
- },
601
- {
602
- id: "lhTvHflPVOqgSWyuWQry",
603
- name: "Hina",
604
- description: "Cute and Friendly",
605
- gender: "female",
606
- lang: ["Japanese"]
607
- },
608
- {
609
- id: "cGbEKHsmg38m62yxIWFk",
610
- name: "Aira",
611
- gender: "male",
612
- description: "Neutral, Clear and Steady",
613
- lang: ["Japanese"]
614
- },
615
- {
616
- id: "A4AyGcPAjb1pHgflyZZp",
617
- name: "Ritsuto",
618
- gender: "male",
619
- description: "Anime Prince Voice",
620
- lang: ["Japanese"]
621
- },
622
- {
623
- id: "hkfHEbBvdQFNX4uWHqRF",
624
- name: "Stacy",
625
- gender: "female",
626
- description: "Young, Sweet and Cute",
627
- lang: ["Chinese"]
628
- },
629
- {
630
- id: "JZLpE3AGwpKYZI2X65hN",
631
- name: "Mingyao Ye",
632
- gender: "female",
633
- description: "Sad and Broken Hearted",
634
- lang: ["Chinese"]
635
- },
636
- {
637
- id: "bhJUNIXWQQ94l8eI2VUf",
638
- name: "Amy",
639
- gender: "female",
640
- description: "Young, Natural and Friendly",
641
- lang: ["Chinese", "English", "French", "Italian"]
642
- },
643
- {
644
- id: "54Cze5LrTSyLgbO6Fhlc",
645
- name: "Caty",
646
- gender: "female",
647
- description: "Droll, Wry and Dry",
648
- lang: ["Chinese", "English", "Korean", "French"]
649
- },
650
- {
651
- id: "kbrsaic1zriFXx1pgRYN",
652
- name: "Evan",
653
- gender: "male",
654
- description: "Warm, Soothing and Soft",
655
- lang: ["Chinese"]
656
- },
657
- {
658
- id: "93nuHbke4dTER9x2pDwE",
659
- name: "Adam",
660
- gender: "male",
661
- description: "Warm and Friendly",
662
- lang: ["Chinese", "French", "Korean", "Spanish", "Russian"]
663
- },
664
- {
665
- id: "6MoEUz34rbRrmmyxgRm4",
666
- name: "Manav",
667
- gender: "male",
668
- description: "Husky and Conversational",
669
- lang: ["Spanish", "Japanese", "Chinese", "Italian"]
670
- },
671
- {
672
- id: "gOupLcAkjEnguROwi4oS",
673
- name: "Darian",
674
- gender: "male",
675
- description: "Warm, Grounded Baritone",
676
- lang: ["English"]
677
- },
678
- {
679
- id: "ktkP7Nsj67dw2zcplQYt",
680
- name: "Lawrence",
681
- gender: "male",
682
- description: "Bright, Informative",
683
- lang: ["English"]
684
- },
685
- {
686
- id: "10NkTYmU7tSz3Kkl3Lex",
687
- name: "Kaelen",
688
- gender: "male",
689
- description: "Rugged, Gravelly Bass-Baritone",
690
- lang: ["English"]
691
- },
692
- ...asianTtsVoices,
693
- ...europeanTtsVoices
694
- ];
695
11
 
696
12
  // ../ts-shared/src/product-usage.ts
697
13
  var productUsageEvents = [
@@ -8062,6 +7378,7 @@ var FacialPerformanceMixer = class {
8062
7378
  import {
8063
7379
  Euler,
8064
7380
  Mesh,
7381
+ Object3D,
8065
7382
  SkinnedMesh,
8066
7383
  Vector3 as Vector35
8067
7384
  } from "three";
@@ -8085,6 +7402,17 @@ var applyEuler = function(target, value) {
8085
7402
  }
8086
7403
  target.set(value[0], value[1], value[2]);
8087
7404
  };
7405
+ var isObject3D = function(value) {
7406
+ return value instanceof Object3D || typeof value === "object" && value !== null && value.isObject3D === true;
7407
+ };
7408
+ var finiteCoordinate = function(value, axis) {
7409
+ if (typeof value !== "number" || !Number.isFinite(value)) {
7410
+ throw new RangeError(
7411
+ `lookAt needs a finite ${axis} coordinate, not ${String(value)}`
7412
+ );
7413
+ }
7414
+ return value;
7415
+ };
8088
7416
  var CharacterSceneRig = class {
8089
7417
  currentVrm = null;
8090
7418
  cachedMeshes = [];
@@ -8093,10 +7421,14 @@ var CharacterSceneRig = class {
8093
7421
  cachedSkeletons = [];
8094
7422
  shadowOptions = null;
8095
7423
  transformOptions = null;
7424
+ lookAtAnchor = null;
7425
+ /** The target that setVrmLookAtTarget set on the current model. */
7426
+ vrmLookAtTarget = null;
8096
7427
  get vrm() {
8097
7428
  return this.currentVrm;
8098
7429
  }
8099
7430
  setVrm(vrm) {
7431
+ this.setVrmLookAtTarget(null);
8100
7432
  this.currentVrm = vrm;
8101
7433
  this.refreshMeshes();
8102
7434
  if (this.shadowOptions) {
@@ -8106,6 +7438,64 @@ var CharacterSceneRig = class {
8106
7438
  this.applyTransform(this.transformOptions);
8107
7439
  }
8108
7440
  }
7441
+ /**
7442
+ * The `Object3D` of a `lookAt()` argument: an `Object3D` as it is, a point
7443
+ * or three coordinates as a world position that this rig keeps, or null.
7444
+ * Coordinates that are not finite numbers throw a `RangeError` and change
7445
+ * nothing.
7446
+ */
7447
+ resolveLookAtTarget(targetOrX, y, z) {
7448
+ if (targetOrX === null) {
7449
+ return null;
7450
+ }
7451
+ if (typeof targetOrX === "number") {
7452
+ return this.updateLookAtAnchor(targetOrX, y, z);
7453
+ }
7454
+ if (isObject3D(targetOrX)) {
7455
+ return targetOrX;
7456
+ }
7457
+ if (Array.isArray(targetOrX)) {
7458
+ return this.updateLookAtAnchor(targetOrX[0], targetOrX[1], targetOrX[2]);
7459
+ }
7460
+ if (typeof targetOrX === "object") {
7461
+ const point = targetOrX;
7462
+ return this.updateLookAtAnchor(point.x, point.y, point.z);
7463
+ }
7464
+ throw new TypeError(
7465
+ "lookAt needs an Object3D, a point, [x, y, z] or three coordinates"
7466
+ );
7467
+ }
7468
+ /**
7469
+ * Sets three-vrm's own look-at target (`vrm.lookAt.target`) of the current
7470
+ * model. Null removes the target that this method set; a target that other
7471
+ * code set stays. The IdleFace of a template face does not move the eyes
7472
+ * while `vrm.lookAt.target` is set.
7473
+ */
7474
+ setVrmLookAtTarget(target) {
7475
+ const lookAt = this.currentVrm?.lookAt;
7476
+ if (lookAt) {
7477
+ if (target) {
7478
+ lookAt.target = target;
7479
+ } else if (this.vrmLookAtTarget && lookAt.target === this.vrmLookAtTarget) {
7480
+ lookAt.target = void 0;
7481
+ }
7482
+ }
7483
+ this.vrmLookAtTarget = lookAt ? target : null;
7484
+ }
7485
+ updateLookAtAnchor(x, y, z) {
7486
+ const position = [
7487
+ finiteCoordinate(x, "x"),
7488
+ finiteCoordinate(y, "y"),
7489
+ finiteCoordinate(z, "z")
7490
+ ];
7491
+ if (!this.lookAtAnchor) {
7492
+ this.lookAtAnchor = new Object3D();
7493
+ this.lookAtAnchor.name = "npcify-look-at-target";
7494
+ }
7495
+ this.lookAtAnchor.position.set(...position);
7496
+ this.lookAtAnchor.updateMatrixWorld(true);
7497
+ return this.lookAtAnchor;
7498
+ }
8109
7499
  /** Root Three.js group containing the VRM hierarchy (`vrm.scene`). */
8110
7500
  get scene() {
8111
7501
  return this.currentVrm?.scene ?? null;
@@ -8886,8 +8276,9 @@ var StagingPlayer = class {
8886
8276
  if (animation?.animation === this.activeAnimation?.animation && animation?.startTime === this.activeAnimation?.startTime && animation?.loop === this.activeAnimation?.loop) {
8887
8277
  return;
8888
8278
  }
8279
+ const continuesIdle = !this.activeAnimation && animation?.startTime === 0 && animation?.animation === this.animationController.getIdleAnimationId?.();
8889
8280
  this.activeAnimation = animation ? { ...animation } : null;
8890
- if (animation) {
8281
+ if (animation && !continuesIdle) {
8891
8282
  this.animationController.playAnimation(
8892
8283
  animation.animation,
8893
8284
  0.25,
@@ -9338,6 +8729,8 @@ var CharacterRuntime = class {
9338
8729
  streamPlayback;
9339
8730
  defaultParent;
9340
8731
  currentGazeTarget = null;
8732
+ /** The current gaze target came from `lookAt()`. */
8733
+ lookAtActive = false;
9341
8734
  thinkingState = false;
9342
8735
  errorCallback;
9343
8736
  constructor(options) {
@@ -9427,6 +8820,7 @@ var CharacterRuntime = class {
9427
8820
  set vrm(value) {
9428
8821
  this.sceneRig.setVrm(value);
9429
8822
  this.facialMixer.setVrm(value);
8823
+ this.applyGaze();
9430
8824
  if (value && this.defaultParent && !value.scene?.parent) {
9431
8825
  this.sceneRig.attachTo(this.defaultParent);
9432
8826
  }
@@ -9603,10 +8997,24 @@ var CharacterRuntime = class {
9603
8997
  clearEmotion(mouthMode) {
9604
8998
  this.facialMixer.clearEmotion(mouthMode);
9605
8999
  }
9606
- /** The object the eyes of a template face follow (the camera); null looks ahead. */
9000
+ /**
9001
+ * The object the eyes of a template face follow (the camera); null looks
9002
+ * ahead. It replaces a `lookAt()` target. Other faces do not follow it.
9003
+ */
9607
9004
  setGazeTarget(target) {
9608
9005
  this.currentGazeTarget = target;
9609
- this.facialMixer.setGazeTarget(target);
9006
+ this.lookAtActive = false;
9007
+ this.applyGaze();
9008
+ }
9009
+ lookAt(targetOrX, y, z) {
9010
+ const target = this.sceneRig.resolveLookAtTarget(targetOrX, y, z);
9011
+ this.currentGazeTarget = target;
9012
+ this.lookAtActive = target !== null;
9013
+ this.applyGaze();
9014
+ }
9015
+ /** Reset the character's gaze target so the eyes look straight ahead. */
9016
+ clearLookAt() {
9017
+ this.setGazeTarget(null);
9610
9018
  }
9611
9019
  startPerformanceRecording(options) {
9612
9020
  this.performanceRecorder.start(options);
@@ -9688,15 +9096,24 @@ var CharacterRuntime = class {
9688
9096
  }
9689
9097
  return this.stagingPlayer;
9690
9098
  };
9099
+ /**
9100
+ * A template face follows the gaze target with its IdleFace. Only a
9101
+ * `lookAt()` target moves the eyes of another face, through three-vrm's
9102
+ * `vrm.lookAt.target`; on a template face that target would stop the
9103
+ * IdleFace (its gaze cone, idle eye moves and look cues).
9104
+ */
9105
+ applyGaze() {
9106
+ this.facialMixer.setGazeTarget(this.currentGazeTarget);
9107
+ this.sceneRig.setVrmLookAtTarget(
9108
+ this.lookAtActive && !this.facialMixer.hasIdleFace ? this.currentGazeTarget : null
9109
+ );
9110
+ }
9691
9111
  resetRuntimeAssets() {
9692
9112
  this.lazyAnimations.reset();
9693
- if (this.stagingPlayer) {
9694
- this.stagingPlayer.cleanup();
9695
- this.stagingPlayer = null;
9696
- } else {
9697
- this.audioPlayer?.reset();
9698
- this.facialMixer.reset();
9699
- }
9113
+ this.stagingPlayer?.cleanup();
9114
+ this.stagingPlayer = null;
9115
+ this.audioPlayer?.reset();
9116
+ this.facialMixer.reset();
9700
9117
  if (this.animationController instanceof AnimationController) {
9701
9118
  this.animationController.clearAnimations();
9702
9119
  }
@@ -9706,20 +9123,10 @@ var CharacterRuntime = class {
9706
9123
  this.facialMixer.setVrm(null);
9707
9124
  }
9708
9125
  disposeRuntimeAssets() {
9709
- this.lazyAnimations.reset();
9710
- if (this.stagingPlayer) {
9711
- this.stagingPlayer.cleanup();
9712
- this.stagingPlayer = null;
9713
- }
9126
+ this.sceneRig.disposeVrm();
9127
+ this.resetRuntimeAssets();
9714
9128
  this.audioPlayer?.cleanup();
9715
9129
  this.audioPlayer = null;
9716
- if (this.animationController instanceof AnimationController) {
9717
- this.animationController.clearAnimations();
9718
- }
9719
- this.animationController = void 0;
9720
- this.animations.clear();
9721
- this.facialMixer.setVrm(null);
9722
- this.sceneRig.disposeVrm();
9723
9130
  }
9724
9131
  handleCallbackError = (context2, error) => {
9725
9132
  const normalized = error instanceof Error ? error : new Error(String(error ?? "Error"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npcify/web",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Framework-independent Npcify characters, live conversations and baked performances for the web",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -35,8 +35,8 @@
35
35
  "tsup": "^8.5.0",
36
36
  "typescript": "^5.9.3",
37
37
  "@npcify/shared": "^0.1.0",
38
- "@npcify/web-client": "^0.0.0",
39
- "@npcify/vrm-renderer": "^0.1.0"
38
+ "@npcify/vrm-renderer": "^0.1.0",
39
+ "@npcify/web-client": "^0.0.0"
40
40
  },
41
41
  "repository": {
42
42
  "type": "git",