@davi-ai/react-bodyengine-three 1.0.25 → 1.0.27

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.js CHANGED
@@ -1,26 +1,27 @@
1
- import v, { useState as D, useMemo as ye, useEffect as V, useRef as se, useCallback as Ye, Suspense as Xe } from "react";
1
+ import * as we from "react";
2
+ import v, { useState as D, useMemo as ye, useEffect as V, useRef as se, useCallback as $e, Suspense as et } from "react";
2
3
  import * as A from "three/webgpu";
3
- import { Vector3 as $e, TempNode as et, NodeUpdateType as tt, Matrix4 as X, Vector2 as ge, RenderTarget as be, DepthTexture as we, HalfFloatType as Me, NodeMaterial as st, RendererUtils as Te, Color as rt, QuadMesh as at, FloatType as nt } from "three/webgpu";
4
- import { Object3D as $s } from "three/webgpu";
5
- import { CharacterState as J, CreationTool as ee, AvaturnLoader as ot, AvatarSDKLoader as it, CC3Loader as ct, Character as he } from "@davi-ai/bodyengine-three";
6
- import { CharacterState as tr, CreationTool as sr, bmlTags as rr, emotionList as ar } from "@davi-ai/bodyengine-three";
7
- import { useDetectGPU as lt, AdaptiveDpr as ht, PerspectiveCamera as dt, CameraControls as ut, Environment as mt } from "@react-three/drei";
8
- import { convertToTexture as pt, uniform as Q, passTexture as gt, texture as Ae, velocity as fe, struct as ft, Fn as te, float as Y, vec2 as de, If as ke, vec4 as $, max as oe, ivec2 as yt, luminance as Ce, add as Oe, uv as St, mix as _e, logarithmicDepthToViewZ as xt, viewZToPerspectiveDepth as Pe, getViewPosition as vt, viewZToOrthographicDepth as bt, pass as wt, mrt as Ve, diffuseColor as Mt, output as Ne, directionToColor as Tt, normalView as At, sample as kt, colorToDirection as Ct } from "three/tsl";
9
- import { ssgi as _t } from "three/addons/tsl/display/SSGINode.js";
10
- import { Canvas as Pt, useThree as Vt, useFrame as He } from "@react-three/fiber";
11
- import { createSpeechSynthesisPonyfill as Nt, SpeechSynthesisUtterance as It } from "@davi-ai/web-speech-cognitive-services-davi";
4
+ import { Vector3 as tt, TempNode as st, NodeUpdateType as rt, Matrix4 as X, Vector2 as pe, RenderTarget as be, DepthTexture as Me, HalfFloatType as Te, NodeMaterial as nt, RendererUtils as Ae, Color as at, QuadMesh as ot, FloatType as it } from "three/webgpu";
5
+ import { Object3D as sr } from "three/webgpu";
6
+ import { CharacterState as J, CreationTool as ee, AvaturnLoader as ct, AvatarSDKLoader as lt, CC3Loader as ht, Character as he } from "@davi-ai/bodyengine-three";
7
+ import { CharacterState as nr, CreationTool as ar, bmlTags as or, emotionList as ir } from "@davi-ai/bodyengine-three";
8
+ import { usePerformanceMonitor as dt, useDetectGPU as ut, PerformanceMonitor as mt, PerspectiveCamera as gt, CameraControls as pt, Environment as ft } from "@react-three/drei";
9
+ import { convertToTexture as yt, uniform as Q, passTexture as St, texture as ke, velocity as fe, struct as xt, Fn as te, float as Y, vec2 as de, If as Pe, vec4 as $, max as oe, ivec2 as vt, luminance as Ce, add as He, uv as wt, mix as _e, logarithmicDepthToViewZ as bt, viewZToPerspectiveDepth as Ve, getViewPosition as Mt, viewZToOrthographicDepth as Tt, pass as At, mrt as Ne, diffuseColor as kt, output as Re, directionToColor as Pt, normalView as Ct, sample as _t, colorToDirection as Vt } from "three/tsl";
10
+ import { ssgi as Nt } from "three/addons/tsl/display/SSGINode.js";
11
+ import { useThree as We, Canvas as Rt, useFrame as qe } from "@react-three/fiber";
12
+ import { createSpeechSynthesisPonyfill as It, SpeechSynthesisUtterance as Ft } from "@davi-ai/web-speech-cognitive-services-davi";
12
13
  const Ie = (e) => {
13
14
  let t;
14
- const s = /* @__PURE__ */ new Set(), r = (h, p) => {
15
- const g = typeof h == "function" ? h(t) : h;
16
- if (!Object.is(g, t)) {
17
- const w = t;
18
- t = p ?? (typeof g != "object" || g === null) ? g : Object.assign({}, t, g), s.forEach((i) => i(t, w));
15
+ const s = /* @__PURE__ */ new Set(), r = (h, g) => {
16
+ const p = typeof h == "function" ? h(t) : h;
17
+ if (!Object.is(p, t)) {
18
+ const b = t;
19
+ t = g ?? (typeof p != "object" || p === null) ? p : Object.assign({}, t, p), s.forEach((i) => i(t, b));
19
20
  }
20
- }, o = () => t, b = { setState: r, getState: o, getInitialState: () => x, subscribe: (h) => (s.add(h), () => s.delete(h)) }, x = t = e(r, o, b);
21
- return b;
22
- }, Ft = (e) => e ? Ie(e) : Ie, Rt = (e) => e;
23
- function Bt(e, t = Rt) {
21
+ }, o = () => t, w = { setState: r, getState: o, getInitialState: () => x, subscribe: (h) => (s.add(h), () => s.delete(h)) }, x = t = e(r, o, w);
22
+ return w;
23
+ }, Bt = (e) => e ? Ie(e) : Ie, zt = (e) => e;
24
+ function Dt(e, t = zt) {
24
25
  const s = v.useSyncExternalStore(
25
26
  e.subscribe,
26
27
  v.useCallback(() => t(e.getState()), [e, t]),
@@ -28,10 +29,10 @@ function Bt(e, t = Rt) {
28
29
  );
29
30
  return v.useDebugValue(s), s;
30
31
  }
31
- const zt = (e) => {
32
- const t = Ft(e), s = (r) => Bt(t, r);
32
+ const Et = (e) => {
33
+ const t = Bt(e), s = (r) => Dt(t, r);
33
34
  return Object.assign(s, t), s;
34
- }, ae = (e) => zt, k = ae()(() => ({
35
+ }, ne = (e) => Et, k = ne()(() => ({
35
36
  character: null,
36
37
  managers: [],
37
38
  globalManager: null,
@@ -48,7 +49,7 @@ const zt = (e) => {
48
49
  characterHeight: 0,
49
50
  characterDepth: 0,
50
51
  characterState: J.idle
51
- })), Dt = (e) => {
52
+ })), jt = (e) => {
52
53
  k.setState({ character: e }), k.setState({ managers: {
53
54
  lipSyncManager: (e == null ? void 0 : e.lipSyncManager) || null,
54
55
  blendshapeManager: (e == null ? void 0 : e.blendshapeManager) || null,
@@ -57,58 +58,58 @@ const zt = (e) => {
57
58
  } }), k.setState({ globalManager: (e == null ? void 0 : e.globalManager) || null }), k.setState({ lipSyncManager: (e == null ? void 0 : e.lipSyncManager) || null }), k.setState({ blendshapeManager: (e == null ? void 0 : e.blendshapeManager) || null }), k.setState({ eyeBlinkManager: (e == null ? void 0 : e.eyeBlinkManager) || null }), k.setState({ animationManager: (e == null ? void 0 : e.animationManager) || null }), k.setState({ FACSManager: (e == null ? void 0 : e.FACSManager) || null }), k.setState({ headPoseManager: (e == null ? void 0 : e.headPoseManager) || null }), k.setState({ gazeManager: (e == null ? void 0 : e.gazeManager) || null }), k.setState({ bmlManager: (e == null ? void 0 : e.bmlManager) || null });
58
59
  }, Fe = (e) => {
59
60
  k.setState({ animationsLoaded: e });
60
- }, jt = (e) => {
61
+ }, Ut = (e) => {
61
62
  k.setState({ characterWidth: e.x }), k.setState({ characterHeight: e.y }), k.setState({ characterDepth: e.z });
62
- }, Cs = () => k.getState().characterHeight, Re = (e) => {
63
+ }, Vs = () => k.getState().characterHeight, Be = (e) => {
63
64
  k.setState({ characterState: e });
64
- }, z = ae()(() => ({
65
+ }, z = ne()(() => ({
65
66
  cameraRef: null,
66
- cameraPosition: new $e(0, 0, 5),
67
+ cameraPosition: new tt(0, 0, 5),
67
68
  bodyCenter: null,
68
69
  defaultPositions: null,
69
70
  defaultDistances: null,
70
71
  lookAt: null,
71
72
  movable: !0
72
- })), Et = (e) => {
73
+ })), Lt = (e) => {
73
74
  z.setState({ cameraRef: e });
74
- }, Be = (e) => {
75
+ }, ze = (e) => {
75
76
  z.setState({ cameraPosition: e });
76
- }, _s = () => z.getState().cameraPosition, Ut = (e) => {
77
+ }, Ns = () => z.getState().cameraPosition, Ot = (e) => {
77
78
  z.setState({ bodyCenter: e });
78
- }, Lt = (e) => {
79
+ }, Ht = (e) => {
79
80
  z.setState({ defaultPositions: e });
80
- }, Ot = (e) => {
81
+ }, Wt = (e) => {
81
82
  z.setState({ defaultDistances: e });
82
- }, ze = (e) => {
83
+ }, De = (e) => {
83
84
  z.setState({ lookAt: e });
84
- }, Ps = () => z.getState().lookAt, Ht = (e) => {
85
+ }, Rs = () => z.getState().lookAt, qt = (e) => {
85
86
  z.setState({ movable: e });
86
- }, E = ae()(() => ({
87
+ }, j = ne()(() => ({
87
88
  currentAUs: null,
88
89
  currentGaze: null,
89
90
  currentHeadPose: null,
90
91
  lookAtCamera: !1,
91
92
  targets: [],
92
93
  showFirstTarget: !1
93
- })), Wt = (e) => {
94
- E.setState({ targets: e });
95
- }, Vs = (e) => {
96
- E.setState({ currentAUs: e });
97
- }, Ns = (e) => {
98
- E.setState({ currentGaze: e });
94
+ })), Gt = (e) => {
95
+ j.setState({ targets: e });
99
96
  }, Is = (e) => {
100
- E.setState({ currentHeadPose: e });
101
- }, ue = (e) => {
102
- E.setState({ lookAtCamera: e }), e ? qt() : Gt();
97
+ j.setState({ currentAUs: e });
103
98
  }, Fs = (e) => {
104
- E.setState({ lookAtCamera: e });
99
+ j.setState({ currentGaze: e });
100
+ }, Bs = (e) => {
101
+ j.setState({ currentHeadPose: e });
102
+ }, ue = (e) => {
103
+ j.setState({ lookAtCamera: e }), e ? Jt() : Kt();
104
+ }, zs = (e) => {
105
+ j.setState({ lookAtCamera: e });
105
106
  const t = k.getState().globalManager;
106
107
  if (e) {
107
108
  const s = z.getState().cameraRef;
108
109
  t == null || t.lookAtAndSteady(s);
109
110
  } else
110
111
  t == null || t.releaseLookAt();
111
- }, qt = (e) => {
112
+ }, Jt = (e) => {
112
113
  const t = k.getState().globalManager;
113
114
  if (e)
114
115
  t == null || t.lookAtAndKeep(e);
@@ -116,30 +117,30 @@ const zt = (e) => {
116
117
  const s = z.getState().cameraRef;
117
118
  t == null || t.lookAtAndKeep(s);
118
119
  }
119
- }, Gt = () => {
120
+ }, Kt = () => {
120
121
  var e;
121
122
  (e = k.getState().globalManager) == null || e.releaseLookAt();
122
- }, Rs = (e) => {
123
- E.setState({ showFirstTarget: e });
124
- }, re = ae()(() => ({
123
+ }, Ds = (e) => {
124
+ j.setState({ showFirstTarget: e });
125
+ }, re = ne()(() => ({
125
126
  animationsNames: [],
126
127
  animations: /* @__PURE__ */ new Map(),
127
128
  currentAnimation: null,
128
129
  autoPlay: !0
129
- })), Jt = (e) => {
130
+ })), Zt = (e) => {
130
131
  re.setState({ animationsNames: e });
131
- }, Kt = (e) => {
132
+ }, Qt = (e) => {
132
133
  re.setState({ animations: e });
133
- }, Bs = () => re.getState().animations, zs = (e) => {
134
+ }, Es = () => re.getState().animations, js = (e) => {
134
135
  re.setState({ autoPlay: e });
135
- }, Ds = (e) => {
136
+ }, Us = (e) => {
136
137
  if (re.setState({ autoPlay: !1 }), re.getState().animationsNames.includes(e)) {
137
138
  const s = k.getState().animationManager;
138
139
  s == null || s.playAnimation(e);
139
140
  }
140
141
  };
141
- var F = /* @__PURE__ */ ((e) => (e.eye = "eye", e.mouth = "mouth", e.neck = "neck", e.clavicle = "clavicle", e.torso = "torso", e.belly = "belly", e.lowerbelly = "lowerbelly", e.hips = "hips", e.higherthigh = "higherthigh", e.thigh = "thigh", e.knee = "knee", e.leg = "leg", e.feet = "feet", e))(F || {}), G = /* @__PURE__ */ ((e) => (e[e.face = 1] = "face", e[e.eighthleft = 2] = "eighthleft", e[e.thirdleft = 3] = "thirdleft", e[e.quarterleft = 4] = "quarterleft", e[e.halfleft = 5] = "halfleft", e[e.eighthright = 6] = "eighthright", e[e.thirdright = 7] = "thirdright", e[e.quarterright = 8] = "quarterright", e[e.halfright = 9] = "halfright", e))(G || {}), R = /* @__PURE__ */ ((e) => (e[e.veryclose = 1] = "veryclose", e[e.closer = 2] = "closer", e[e.close = 3] = "close", e[e.midclose = 4] = "midclose", e[e.medium = 5] = "medium", e[e.midfar = 6] = "midfar", e[e.far = 7] = "far", e[e.farther = 8] = "farther", e[e.veryfar = 9] = "veryfar", e))(R || {}), le = /* @__PURE__ */ ((e) => (e.cc3 = "CC_Base_Body", e.avatarsdk = "AvatarBody", e.avaturn = "Body_Mesh", e))(le || {}), Se = /* @__PURE__ */ ((e) => (e.Jay = "joy", e.Anger = "anger", e.Contempt = "contempt", e.Disgust = "disgust", e.Dislike = "dislike", e.Distress = "distress", e.Fear = "fear", e.Frustration = "frustration", e.Guilt = "guilt", e.Hope = "hope", e.Love = "love", e.Pride = "pride", e.Regret = "regret", e.Relief = "relief", e.Sadness = "sadness", e.Shame = "shame", e.Smile = "smile", e.Surprise = "surprise", e.Neutral = "neutral", e))(Se || {});
142
- const De = /* @__PURE__ */ new Map([
142
+ var I = /* @__PURE__ */ ((e) => (e.eye = "eye", e.mouth = "mouth", e.neck = "neck", e.clavicle = "clavicle", e.torso = "torso", e.belly = "belly", e.lowerbelly = "lowerbelly", e.hips = "hips", e.higherthigh = "higherthigh", e.thigh = "thigh", e.knee = "knee", e.leg = "leg", e.feet = "feet", e))(I || {}), G = /* @__PURE__ */ ((e) => (e[e.face = 1] = "face", e[e.eighthleft = 2] = "eighthleft", e[e.thirdleft = 3] = "thirdleft", e[e.quarterleft = 4] = "quarterleft", e[e.halfleft = 5] = "halfleft", e[e.eighthright = 6] = "eighthright", e[e.thirdright = 7] = "thirdright", e[e.quarterright = 8] = "quarterright", e[e.halfright = 9] = "halfright", e))(G || {}), F = /* @__PURE__ */ ((e) => (e[e.veryclose = 1] = "veryclose", e[e.closer = 2] = "closer", e[e.close = 3] = "close", e[e.midclose = 4] = "midclose", e[e.medium = 5] = "medium", e[e.midfar = 6] = "midfar", e[e.far = 7] = "far", e[e.farther = 8] = "farther", e[e.veryfar = 9] = "veryfar", e))(F || {}), le = /* @__PURE__ */ ((e) => (e.cc3 = "CC_Base_Body", e.avatarsdk = "AvatarBody", e.avaturn = "Body_Mesh", e))(le || {}), Se = /* @__PURE__ */ ((e) => (e.Jay = "joy", e.Anger = "anger", e.Contempt = "contempt", e.Disgust = "disgust", e.Dislike = "dislike", e.Distress = "distress", e.Fear = "fear", e.Frustration = "frustration", e.Guilt = "guilt", e.Hope = "hope", e.Love = "love", e.Pride = "pride", e.Regret = "regret", e.Relief = "relief", e.Sadness = "sadness", e.Shame = "shame", e.Smile = "smile", e.Surprise = "surprise", e.Neutral = "neutral", e))(Se || {});
143
+ const Ee = /* @__PURE__ */ new Map([
143
144
  [0, "sil"],
144
145
  [1, "aa"],
145
146
  [2, "aa"],
@@ -162,7 +163,7 @@ const De = /* @__PURE__ */ new Map([
162
163
  [19, "DD"],
163
164
  [20, "kk"],
164
165
  [21, "PP"]
165
- ]), Zt = /* @__PURE__ */ new Map([
166
+ ]), Yt = /* @__PURE__ */ new Map([
166
167
  ["#", "#"],
167
168
  ["p", "p"],
168
169
  ["b", "b"],
@@ -211,7 +212,7 @@ const De = /* @__PURE__ */ new Map([
211
212
  ["9~", "oẽ"],
212
213
  ["N", "ŋ"],
213
214
  ["J", "ɲ"]
214
- ]), Qt = /* @__PURE__ */ new Map([
215
+ ]), Xt = /* @__PURE__ */ new Map([
215
216
  ["#", 0],
216
217
  ["æ", 1],
217
218
  ["ə", 1],
@@ -252,48 +253,48 @@ const De = /* @__PURE__ */ new Map([
252
253
  ["p", 21],
253
254
  ["b", 21],
254
255
  ["m", 21]
255
- ]), Yt = {
256
- position: F.mouth,
257
- distance: R.farther,
258
- lookAt: F.lowerbelly
259
- }, Xt = {
260
- position: F.mouth,
261
- distance: R.close,
262
- lookAt: F.mouth
263
- }, $t = {
264
- position: F.mouth,
265
- distance: R.midclose,
266
- lookAt: F.mouth
256
+ ]), $t = {
257
+ position: I.mouth,
258
+ distance: F.farther,
259
+ lookAt: I.lowerbelly
267
260
  }, es = {
268
- position: F.neck,
269
- distance: R.close,
270
- lookAt: F.neck
261
+ position: I.mouth,
262
+ distance: F.close,
263
+ lookAt: I.mouth
271
264
  }, ts = {
272
- position: F.eye,
273
- distance: R.medium,
274
- lookAt: F.neck
265
+ position: I.mouth,
266
+ distance: F.midclose,
267
+ lookAt: I.mouth
275
268
  }, ss = {
276
- position: F.eye,
277
- distance: R.medium,
278
- lookAt: F.clavicle
269
+ position: I.neck,
270
+ distance: F.close,
271
+ lookAt: I.neck
279
272
  }, rs = {
280
- position: F.eye,
281
- distance: R.midfar,
282
- lookAt: F.belly
273
+ position: I.eye,
274
+ distance: F.medium,
275
+ lookAt: I.neck
276
+ }, ns = {
277
+ position: I.eye,
278
+ distance: F.medium,
279
+ lookAt: I.clavicle
283
280
  }, as = {
284
- position: F.eye,
285
- distance: R.far,
286
- lookAt: F.lowerbelly
287
- }, js = {
288
- default: Yt,
289
- head: Xt,
290
- neck: $t,
291
- shoulders: es,
292
- chest: ts,
293
- belly: ss,
294
- knees: rs,
295
- feet: as
296
- }, C = ae()(() => ({
281
+ position: I.eye,
282
+ distance: F.midfar,
283
+ lookAt: I.belly
284
+ }, os = {
285
+ position: I.eye,
286
+ distance: F.far,
287
+ lookAt: I.lowerbelly
288
+ }, Ls = {
289
+ default: $t,
290
+ head: es,
291
+ neck: ts,
292
+ shoulders: ss,
293
+ chest: rs,
294
+ belly: ns,
295
+ knees: as,
296
+ feet: os
297
+ }, P = ne()(() => ({
297
298
  credentials: void 0,
298
299
  currentUtterance: null,
299
300
  boundaries: [],
@@ -306,179 +307,179 @@ const De = /* @__PURE__ */ new Map([
306
307
  textToSpeak: null,
307
308
  visemeIntensity: 1,
308
309
  useBlendshapeManager: !1
309
- })), ns = (e) => {
310
- C.setState({ credentials: e });
311
- }, os = (e) => {
310
+ })), is = (e) => {
311
+ P.setState({ credentials: e });
312
+ }, cs = (e) => {
312
313
  if (e) {
313
- const t = C.getState().voice;
314
+ const t = P.getState().voice;
314
315
  t && (e.voice = t);
315
316
  }
316
- C.setState({ currentUtterance: e }), C.setState({ textToSpeak: null });
317
- }, Es = (e) => {
318
- C.setState({ visemes: e });
319
- }, Us = (e) => {
320
- C.setState({ blendshapes: e });
321
- }, We = (e) => {
322
- C.setState({ visemes: [...C.getState().visemes, e] });
323
- }, Ls = (e) => {
324
- C.setState({ blendshapes: [...C.getState().blendshapes, e] });
325
- }, Os = (e, t) => {
326
- const s = Zt.get(e.name);
317
+ P.setState({ currentUtterance: e }), P.setState({ textToSpeak: null });
318
+ }, Os = (e) => {
319
+ P.setState({ visemes: e });
320
+ }, Hs = (e) => {
321
+ P.setState({ blendshapes: e });
322
+ }, Ge = (e) => {
323
+ P.setState({ visemes: [...P.getState().visemes, e] });
324
+ }, Ws = (e) => {
325
+ P.setState({ blendshapes: [...P.getState().blendshapes, e] });
326
+ }, qs = (e, t) => {
327
+ const s = Yt.get(e.name);
327
328
  if (s) {
328
- const r = Qt.get(s);
329
- r !== void 0 && We({ ...e, name: `${r}`, elapsedTime: e.elapsedTime * (t || 1e7) });
329
+ const r = Xt.get(s);
330
+ r !== void 0 && Ge({ ...e, name: `${r}`, elapsedTime: e.elapsedTime * (t || 1e7) });
330
331
  }
331
- }, is = (e) => {
332
- C.setState({ currentVisemeIndex: e });
333
- }, cs = (e) => {
334
- C.setState({ currentBlendshapeIndex: e });
335
- }, qe = () => {
332
+ }, ls = (e) => {
333
+ P.setState({ currentVisemeIndex: e });
334
+ }, hs = (e) => {
335
+ P.setState({ currentBlendshapeIndex: e });
336
+ }, Je = () => {
336
337
  var e;
337
- C.setState({
338
+ P.setState({
338
339
  visemes: [],
339
340
  currentVisemeIndex: 0
340
341
  }), (e = k.getState().lipSyncManager) == null || e.stop();
341
- }, Ge = () => {
342
+ }, Ke = () => {
342
343
  var e;
343
- C.setState({
344
+ P.setState({
344
345
  blendshapes: [],
345
346
  currentBlendshapeIndex: 0
346
347
  }), (e = k.getState().blendshapeManager) == null || e.stop();
347
- }, ls = (e) => {
348
- C.setState({ voice: e });
348
+ }, ds = (e) => {
349
+ P.setState({ voice: e });
349
350
  }, je = (e) => {
350
- C.setState({ voices: e });
351
- }, Hs = (e) => {
352
- C.setState({ textToSpeak: e });
353
- }, Ws = () => C.getState().voices, qs = (e) => {
354
- C.setState({ visemeIntensity: e });
355
- }, hs = (e) => {
356
- e !== C.getState().useBlendshapeManager && (qe(), Ge(), C.setState({ useBlendshapeManager: e }));
357
- }, ds = (e, t, s) => {
358
- let r = s[e.position || F.eye].getComponent(0);
359
- const o = s[e.position || F.mouth].getComponent(1);
360
- let n = 0;
361
- const f = typeof e.distance == "string" ? parseInt(e.distance) : e.distance, b = typeof e.rotation == "string" ? parseInt(e.rotation) : e.rotation;
351
+ P.setState({ voices: e });
352
+ }, Gs = (e) => {
353
+ P.setState({ textToSpeak: e });
354
+ }, Js = () => P.getState().voices, Ks = (e) => {
355
+ P.setState({ visemeIntensity: e });
356
+ }, us = (e) => {
357
+ e !== P.getState().useBlendshapeManager && (Je(), Ke(), P.setState({ useBlendshapeManager: e }));
358
+ }, ms = (e, t, s) => {
359
+ let r = s[e.position || I.eye].getComponent(0);
360
+ const o = s[e.position || I.mouth].getComponent(1);
361
+ let a = 0;
362
+ const f = typeof e.distance == "string" ? parseInt(e.distance) : e.distance, w = typeof e.rotation == "string" ? parseInt(e.rotation) : e.rotation;
362
363
  switch (f) {
363
- case R.veryclose:
364
- n = t.veryclose;
364
+ case F.veryclose:
365
+ a = t.veryclose;
365
366
  break;
366
- case R.closer:
367
- n = t.closer;
367
+ case F.closer:
368
+ a = t.closer;
368
369
  break;
369
- case R.close:
370
- n = t.close;
370
+ case F.close:
371
+ a = t.close;
371
372
  break;
372
- case R.midclose:
373
- n = t.midclose;
373
+ case F.midclose:
374
+ a = t.midclose;
374
375
  break;
375
- case R.medium:
376
- n = t.medium;
376
+ case F.medium:
377
+ a = t.medium;
377
378
  break;
378
- case R.midfar:
379
- n = t.midfar;
379
+ case F.midfar:
380
+ a = t.midfar;
380
381
  break;
381
- case R.far:
382
- n = t.far;
382
+ case F.far:
383
+ a = t.far;
383
384
  break;
384
- case R.farther:
385
+ case F.farther:
385
386
  case void 0:
386
387
  default:
387
- n = t.farther;
388
+ a = t.farther;
388
389
  break;
389
- case R.veryfar:
390
- n = t.veryfar;
390
+ case F.veryfar:
391
+ a = t.veryfar;
391
392
  break;
392
393
  }
393
- if (b && b !== G.face)
394
- switch (b) {
394
+ if (w && w !== G.face)
395
+ switch (w) {
395
396
  case G.eighthleft: {
396
397
  const x = 0.2588190451;
397
- r = r - n * x, n = n * Math.sqrt(1 - Math.pow(x, 2));
398
+ r = r - a * x, a = a * Math.sqrt(1 - Math.pow(x, 2));
398
399
  break;
399
400
  }
400
401
  case G.thirdleft:
401
- r = r - n * (1 / 2), n = n * (Math.sqrt(3) / 2);
402
+ r = r - a * (1 / 2), a = a * (Math.sqrt(3) / 2);
402
403
  break;
403
404
  case G.quarterleft:
404
- r = r - n * (Math.SQRT2 / 2), n = n * (Math.SQRT2 / 2);
405
+ r = r - a * (Math.SQRT2 / 2), a = a * (Math.SQRT2 / 2);
405
406
  break;
406
407
  case G.halfleft:
407
- r = r - n, n = s.eye.getComponent(2);
408
+ r = r - a, a = s.eye.getComponent(2);
408
409
  break;
409
410
  case G.eighthright: {
410
411
  const x = 0.2588190451;
411
- r = r + n * x, n = n * Math.sqrt(1 - Math.pow(x, 2));
412
+ r = r + a * x, a = a * Math.sqrt(1 - Math.pow(x, 2));
412
413
  break;
413
414
  }
414
415
  case G.thirdright:
415
- r = r + n * (1 / 2), n = n * (Math.sqrt(3) / 2);
416
+ r = r + a * (1 / 2), a = a * (Math.sqrt(3) / 2);
416
417
  break;
417
418
  case G.quarterright:
418
- r = r + n * (Math.SQRT2 / 2), n = n * (Math.SQRT2 / 2);
419
+ r = r + a * (Math.SQRT2 / 2), a = a * (Math.SQRT2 / 2);
419
420
  break;
420
421
  case G.halfright:
421
- r = r + n, n = s.eye.getComponent(2);
422
+ r = r + a, a = s.eye.getComponent(2);
422
423
  break;
423
424
  }
424
- return new A.Vector3(r, o, n);
425
- }, me = /* @__PURE__ */ new at(), Ee = /* @__PURE__ */ new ge();
426
- let pe;
427
- function Je(e) {
425
+ return new A.Vector3(r, o, a);
426
+ }, me = /* @__PURE__ */ new ot(), Ue = /* @__PURE__ */ new pe();
427
+ let ge;
428
+ function Ze(e) {
428
429
  const t = [];
429
430
  let s, r;
430
431
  function o(h) {
431
432
  s = new Array(h).fill(!1), r = new Array(h).fill(!1);
432
433
  }
433
- let n = 12345;
434
+ let a = 12345;
434
435
  function f() {
435
- return n = n * 1664525 + 1013904223 & 4294967295, (n >>> 0) / 4294967296;
436
+ return a = a * 1664525 + 1013904223 & 4294967295, (a >>> 0) / 4294967296;
436
437
  }
437
- function b(h, p) {
438
- const g = p;
439
- let w;
440
- if (g <= s.length) {
438
+ function w(h, g) {
439
+ const p = g;
440
+ let b;
441
+ if (p <= s.length) {
441
442
  const d = [];
442
- for (let c = 0; c < g; c++)
443
+ for (let c = 0; c < p; c++)
443
444
  s[c] || d.push(c);
444
- w = d[Math.floor(f() * d.length)];
445
+ b = d[Math.floor(f() * d.length)];
445
446
  } else
446
- w = Math.floor(f() * g);
447
+ b = Math.floor(f() * p);
447
448
  let i;
448
- if (g <= r.length) {
449
+ if (p <= r.length) {
449
450
  const d = [];
450
- for (let c = 0; c < g; c++)
451
+ for (let c = 0; c < p; c++)
451
452
  r[c] || d.push(c);
452
453
  i = d[Math.floor(f() * d.length)];
453
454
  } else
454
- i = Math.floor(f() * g);
455
- const l = (w + f()) / g, y = (i + f()) / g;
456
- return w < s.length && (s[w] = !0), i < r.length && (r[i] = !0), [l, y];
455
+ i = Math.floor(f() * p);
456
+ const l = (b + f()) / p, y = (i + f()) / p;
457
+ return b < s.length && (s[b] = !0), i < r.length && (r[i] = !0), [l, y];
457
458
  }
458
459
  o(1), t.push([f(), f()]), s[0] = !0, r[0] = !0;
459
460
  let x = 1;
460
461
  for (; x < e; ) {
461
462
  const h = x * 2;
462
463
  o(h);
463
- for (let p = 0; p < x; p++) {
464
- const [g, w] = t[p], i = Math.min(Math.floor(g * h), h - 1), l = Math.min(Math.floor(w * h), h - 1);
464
+ for (let g = 0; g < x; g++) {
465
+ const [p, b] = t[g], i = Math.min(Math.floor(p * h), h - 1), l = Math.min(Math.floor(b * h), h - 1);
465
466
  i < s.length && (s[i] = !0), l < r.length && (r[l] = !0);
466
467
  }
467
- for (let p = 0; p < x; p++) {
468
- const g = b(p, h);
469
- t.push(g);
468
+ for (let g = 0; g < x; g++) {
469
+ const p = w(g, h);
470
+ t.push(p);
470
471
  }
471
472
  x = h;
472
473
  }
473
474
  return t.slice(0, e);
474
475
  }
475
- const Ue = /* @__PURE__ */ Je(64);
476
- class us extends et {
476
+ const Le = /* @__PURE__ */ Ze(64);
477
+ class gs extends st {
477
478
  static get type() {
478
479
  return "PMJTAANode";
479
480
  }
480
481
  constructor(t, s, r, o) {
481
- super("vec4"), this.isPMJTAANode = !0, this.updateBeforeType = tt.FRAME, this.beautyNode = t, this.depthNode = s, this.velocityNode = r, this.camera = o, this.depthThreshold = 5e-4, this.edgeDepthDiff = 1e-3, this.maxVelocityLength = 128, this.useSubpixelCorrection = !0, this.jitterIntensity = 1, this.useProgressiveAccumulation = !1, this._accumulatedFrames = 0, this.maxAccumulationFrames = 256, this._prevCameraMatrix = new X(), this._progressiveWeight = Q(0), this._jitterIndex = 0, this._sampleCount = 64, this._sequenceLength = Ue.length, this._sequence = Ue, this._invSize = Q(new ge()), this._historyRenderTarget = new be(1, 1, { depthBuffer: !1, type: Me, depthTexture: new we() }), this._historyRenderTarget.texture.name = "PMJTAANode.history", this._resolveRenderTarget = new be(1, 1, { depthBuffer: !1, type: Me }), this._resolveRenderTarget.texture.name = "PMJTAANode.resolve", this._resolveMaterial = new st(), this._resolveMaterial.name = "PMJTAA.resolve", this._textureNode = gt(this, this._resolveRenderTarget.texture), this._originalProjectionMatrix = new X(), this._cameraNearFar = Q(new ge()), this._cameraWorldMatrix = Q(new X()), this._cameraWorldMatrixInverse = Q(new X()), this._cameraProjectionMatrixInverse = Q(new X()), this._previousCameraWorldMatrix = Q(new X()), this._previousCameraProjectionMatrixInverse = Q(new X()), this._previousDepthNode = Ae(new we(1, 1)), this._needsPostProcessingSync = !1, this._velocityNode = null;
482
+ super("vec4"), this.isPMJTAANode = !0, this.updateBeforeType = rt.FRAME, this.beautyNode = t, this.depthNode = s, this.velocityNode = r, this.camera = o, this.depthThreshold = 5e-4, this.edgeDepthDiff = 1e-3, this.maxVelocityLength = 128, this.useSubpixelCorrection = !0, this.jitterIntensity = 1, this.useProgressiveAccumulation = !1, this._accumulatedFrames = 0, this.maxAccumulationFrames = 256, this._prevCameraMatrix = new X(), this._progressiveWeight = Q(0), this._jitterIndex = 0, this._sampleCount = 64, this._sequenceLength = Le.length, this._sequence = Le, this._invSize = Q(new pe()), this._historyRenderTarget = new be(1, 1, { depthBuffer: !1, type: Te, depthTexture: new Me() }), this._historyRenderTarget.texture.name = "PMJTAANode.history", this._resolveRenderTarget = new be(1, 1, { depthBuffer: !1, type: Te }), this._resolveRenderTarget.texture.name = "PMJTAANode.resolve", this._resolveMaterial = new nt(), this._resolveMaterial.name = "PMJTAA.resolve", this._textureNode = St(this, this._resolveRenderTarget.texture), this._originalProjectionMatrix = new X(), this._cameraNearFar = Q(new pe()), this._cameraWorldMatrix = Q(new X()), this._cameraWorldMatrixInverse = Q(new X()), this._cameraProjectionMatrixInverse = Q(new X()), this._previousCameraWorldMatrix = Q(new X()), this._previousCameraProjectionMatrixInverse = Q(new X()), this._previousDepthNode = ke(new Me(1, 1)), this._needsPostProcessingSync = !1, this._velocityNode = null;
482
483
  }
483
484
  getTextureNode() {
484
485
  return this._textureNode;
@@ -518,7 +519,7 @@ class us extends et {
518
519
  * @param {number} count - The number of samples (power of 2).
519
520
  */
520
521
  setSampleCount(t) {
521
- t = Math.max(2, Math.min(256, t)), t = Math.pow(2, Math.round(Math.log2(t))), t !== this._sampleCount && (this._sampleCount = t, this._sequence = Je(t), this._jitterIndex = 0);
522
+ t = Math.max(2, Math.min(256, t)), t = Math.pow(2, Math.round(Math.log2(t))), t !== this._sampleCount && (this._sampleCount = t, this._sequence = Ze(t), this._jitterIndex = 0);
522
523
  }
523
524
  /**
524
525
  * Returns the current sample count.
@@ -534,53 +535,53 @@ class us extends et {
534
535
  const { renderer: s } = t, r = this.camera.matrixWorld;
535
536
  let o = !1;
536
537
  if (this.useProgressiveAccumulation) {
537
- const p = r.elements, g = this._prevCameraMatrix.elements;
538
+ const g = r.elements, p = this._prevCameraMatrix.elements;
538
539
  for (let i = 0; i < 16; i++)
539
- if (Math.abs(p[i] - g[i]) > 1e-6) {
540
+ if (Math.abs(g[i] - p[i]) > 1e-6) {
540
541
  o = !0;
541
542
  break;
542
543
  }
543
544
  o && (this._accumulatedFrames = 0), this._accumulatedFrames++;
544
- const w = Math.min(this._accumulatedFrames, this.maxAccumulationFrames);
545
- this._progressiveWeight.value = o ? 0 : 1 / w, this._prevCameraMatrix.copy(r);
545
+ const b = Math.min(this._accumulatedFrames, this.maxAccumulationFrames);
546
+ this._progressiveWeight.value = o ? 0 : 1 / b, this._prevCameraMatrix.copy(r);
546
547
  } else
547
548
  this._progressiveWeight.value = 0, this._accumulatedFrames = 0;
548
549
  this._previousCameraWorldMatrix.value.copy(this._cameraWorldMatrix.value), this._previousCameraProjectionMatrixInverse.value.copy(this._cameraProjectionMatrixInverse.value), this._cameraNearFar.value.set(this.camera.near, this.camera.far), this._cameraWorldMatrix.value.copy(this.camera.matrixWorld), this._cameraWorldMatrixInverse.value.copy(this.camera.matrixWorldInverse), this._cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse);
549
- const n = this.beautyNode.isRTTNode ? this.beautyNode.renderTarget : this.beautyNode.passNode.renderTarget, f = n.texture.width, b = n.texture.height;
550
- this._needsPostProcessingSync === !0 && (this.setViewOffset(f, b), this._needsPostProcessingSync = !1), pe = Te.resetRendererState(s, pe), s.setClearColor(new rt(0), 0);
551
- const x = this._historyRenderTarget.width !== f || this._historyRenderTarget.height !== b;
552
- this.setSize(f, b), x === !0 && (s.initRenderTarget(this._historyRenderTarget), s.initRenderTarget(this._resolveRenderTarget), s.copyTextureToTexture(n.texture, this._historyRenderTarget.texture)), s.setRenderTarget(this._resolveRenderTarget), me.material = this._resolveMaterial, me.name = "PMJTAA", me.render(s), s.setRenderTarget(null), s.copyTextureToTexture(this._resolveRenderTarget.texture, this._historyRenderTarget.texture);
553
- const h = s.getDrawingBufferSize(Ee);
550
+ const a = this.beautyNode.isRTTNode ? this.beautyNode.renderTarget : this.beautyNode.passNode.renderTarget, f = a.texture.width, w = a.texture.height;
551
+ this._needsPostProcessingSync === !0 && (this.setViewOffset(f, w), this._needsPostProcessingSync = !1), ge = Ae.resetRendererState(s, ge), s.setClearColor(new at(0), 0);
552
+ const x = this._historyRenderTarget.width !== f || this._historyRenderTarget.height !== w;
553
+ this.setSize(f, w), x === !0 && (s.initRenderTarget(this._historyRenderTarget), s.initRenderTarget(this._resolveRenderTarget), s.copyTextureToTexture(a.texture, this._historyRenderTarget.texture)), s.setRenderTarget(this._resolveRenderTarget), me.material = this._resolveMaterial, me.name = "PMJTAA", me.render(s), s.setRenderTarget(null), s.copyTextureToTexture(this._resolveRenderTarget.texture, this._historyRenderTarget.texture);
554
+ const h = s.getDrawingBufferSize(Ue);
554
555
  if (this._historyRenderTarget.height === h.height && this._historyRenderTarget.width === h.width) {
555
- const p = this.depthNode.value;
556
- s.copyTextureToTexture(p, this._historyRenderTarget.depthTexture), this._previousDepthNode.value = this._historyRenderTarget.depthTexture;
556
+ const g = this.depthNode.value;
557
+ s.copyTextureToTexture(g, this._historyRenderTarget.depthTexture), this._previousDepthNode.value = this._historyRenderTarget.depthTexture;
557
558
  }
558
- Te.restoreRendererState(s, pe);
559
+ Ae.restoreRendererState(s, ge);
559
560
  }
560
561
  setup(t) {
561
562
  const s = t.context.renderPipeline;
562
563
  s && (this._needsPostProcessingSync = !0, s.context.onBeforeRenderPipeline = () => {
563
- const i = t.renderer.getDrawingBufferSize(Ee);
564
+ const i = t.renderer.getDrawingBufferSize(Ue);
564
565
  this.setViewOffset(i.width, i.height);
565
566
  }, s.context.onAfterRenderPipeline = () => {
566
567
  this.clearViewOffset();
567
- }), t.renderer.reversedDepthBuffer === !0 && (this._historyRenderTarget.depthTexture.type = nt), t.context.velocity !== void 0 ? this._velocityNode = t.context.velocity : this._velocityNode = fe;
568
+ }), t.renderer.reversedDepthBuffer === !0 && (this._historyRenderTarget.depthTexture.type = it), t.context.velocity !== void 0 ? this._velocityNode = t.context.velocity : this._velocityNode = fe;
568
569
  const r = (i) => {
569
- const { x: l, y } = this._cameraNearFar, d = xt(i, l, y);
570
- return Pe(d, l, y);
571
- }, o = ft({
570
+ const { x: l, y } = this._cameraNearFar, d = bt(i, l, y);
571
+ return Ve(d, l, y);
572
+ }, o = xt({
572
573
  closestDepth: "float",
573
574
  closestPositionTexel: "vec2",
574
575
  farthestDepth: "float"
575
- }), n = te(([i]) => {
576
+ }), a = te(([i]) => {
576
577
  const l = Y(2).toVar(), y = de(0).toVar(), d = Y(-1).toVar();
577
578
  for (let c = -1; c <= 1; ++c)
578
- for (let a = -1; a <= 1; ++a) {
579
- const S = i.add(de(c, a)).toVar();
579
+ for (let n = -1; n <= 1; ++n) {
580
+ const S = i.add(de(c, n)).toVar();
580
581
  let m = this.depthNode.load(S).r;
581
- t.renderer.reversedDepthBuffer && (m = m.oneMinus()), t.renderer.logarithmicDepthBuffer && (m = r(m)), m = m.toVar(), ke(m.lessThan(l), () => {
582
+ t.renderer.reversedDepthBuffer && (m = m.oneMinus()), t.renderer.logarithmicDepthBuffer && (m = r(m)), m = m.toVar(), Pe(m.lessThan(l), () => {
582
583
  l.assign(m), y.assign(S);
583
- }), ke(m.greaterThan(d), () => {
584
+ }), Pe(m.greaterThan(d), () => {
584
585
  d.assign(m);
585
586
  });
586
587
  }
@@ -588,10 +589,10 @@ class us extends et {
588
589
  }), f = (i) => {
589
590
  let l = this._previousDepthNode.sample(i).r;
590
591
  t.renderer.logarithmicDepthBuffer && (l = r(l));
591
- const y = vt(i, l, this._previousCameraProjectionMatrixInverse), d = this._previousCameraWorldMatrix.mul($(y, 1)).xyz, c = this._cameraWorldMatrixInverse.mul($(d, 1)).z;
592
- return this.camera.isOrthographicCamera ? bt(c, this._cameraNearFar.x, this._cameraNearFar.y) : Pe(c, this._cameraNearFar.x, this._cameraNearFar.y);
593
- }, b = te(([i, l, y, d]) => {
594
- const c = d.rgb.add(y.rgb).mul(0.5), a = d.rgb.sub(y.rgb).mul(0.5).add(1e-7), S = l.sub($(c, i.a)), P = S.xyz.div(a).abs(), B = oe(P.x, P.y, P.z);
592
+ const y = Mt(i, l, this._previousCameraProjectionMatrixInverse), d = this._previousCameraWorldMatrix.mul($(y, 1)).xyz, c = this._cameraWorldMatrixInverse.mul($(d, 1)).z;
593
+ return this.camera.isOrthographicCamera ? Tt(c, this._cameraNearFar.x, this._cameraNearFar.y) : Ve(c, this._cameraNearFar.x, this._cameraNearFar.y);
594
+ }, w = te(([i, l, y, d]) => {
595
+ const c = d.rgb.add(y.rgb).mul(0.5), n = d.rgb.sub(y.rgb).mul(0.5).add(1e-7), S = l.sub($(c, i.a)), _ = S.xyz.div(n).abs(), B = oe(_.x, _.y, _.z);
595
596
  return B.greaterThan(1).select(
596
597
  $(c, i.a).add(S.div(B)),
597
598
  l
@@ -615,13 +616,13 @@ class us extends et {
615
616
  [0, -1],
616
617
  [0, 1],
617
618
  [-1, 0]
618
- ], a = l.toVar(), S = l.pow2().toVar();
619
+ ], n = l.toVar(), S = l.pow2().toVar();
619
620
  for (const [U, q] of c) {
620
- const I = this.beautyNode.offset(yt(U, q)).load(i).max(0), L = $(I.rgb.mul(I.a), I.a);
621
- a.addAssign(L), S.addAssign(L.pow2());
621
+ const R = this.beautyNode.offset(vt(U, q)).load(i).max(0), L = $(R.rgb.mul(R.a), R.a);
622
+ n.addAssign(L), S.addAssign(L.pow2());
622
623
  }
623
- const m = Y(c.length + 1), P = a.div(m), B = S.div(m).sub(P.pow2()).max(0).sqrt().mul(d), u = P.sub(B), M = P.add(B);
624
- return b(P.clamp(u, M), y, u, M);
624
+ const m = Y(c.length + 1), _ = n.div(m), B = S.div(m).sub(_.pow2()).max(0).sqrt().mul(d), u = _.sub(B), M = _.add(B);
625
+ return w(_.clamp(u, M), y, u, M);
625
626
  }), h = te(([i, l]) => {
626
627
  const d = i.mul(l).fract().abs(), c = oe(d, d.oneMinus());
627
628
  return c.x.mul(c.y).oneMinus().div(0.75);
@@ -632,31 +633,48 @@ class us extends et {
632
633
  { name: "velocityUV", type: "vec2" },
633
634
  { name: "textureSize", type: "ivec2" }
634
635
  ]
635
- }), p = te(([i, l, y]) => {
636
- const d = y.oneMinus(), c = i.mul(Y(1).div(oe(i.r, i.g, i.b).add(1))), a = l.mul(Y(1).div(oe(l.r, l.g, l.b).add(1))), S = Ce(c.rgb), m = Ce(a.rgb);
637
- return y.mulAssign(Y(1).div(S.add(1))), d.mulAssign(Y(1).div(m.add(1))), Oe(i.mul(y), l.mul(d)).div(oe(y.add(d), 1e-5)).toVar();
638
- }), g = Ae(this._historyRenderTarget.texture), w = te(() => {
639
- const i = St(), l = this.beautyNode.size(), y = i.mul(l), d = n(y), c = d.get("closestDepth"), a = d.get("closestPositionTexel"), S = d.get("farthestDepth"), m = this.velocityNode.load(a).xy.mul(de(0.5, -0.5)), P = i.sub(m), B = f(P), u = P.greaterThanEqual(0).all().and(P.lessThanEqual(1).all()), M = S.sub(c).greaterThan(this.edgeDepthDiff), U = c.sub(B).greaterThan(this.depthThreshold), q = u.and(M.or(U.not())), I = this.beautyNode.sample(i), L = g.sample(i.sub(m)), ne = $(I.rgb.mul(I.a), I.a).toVar(), ce = i.sub(P).mul(l).length().div(this.maxVelocityLength).saturate().sqrt(), T = Y(0.05).toVar();
636
+ }), g = te(([i, l, y]) => {
637
+ const d = y.oneMinus(), c = i.mul(Y(1).div(oe(i.r, i.g, i.b).add(1))), n = l.mul(Y(1).div(oe(l.r, l.g, l.b).add(1))), S = Ce(c.rgb), m = Ce(n.rgb);
638
+ return y.mulAssign(Y(1).div(S.add(1))), d.mulAssign(Y(1).div(m.add(1))), He(i.mul(y), l.mul(d)).div(oe(y.add(d), 1e-5)).toVar();
639
+ }), p = ke(this._historyRenderTarget.texture), b = te(() => {
640
+ const i = wt(), l = this.beautyNode.size(), y = i.mul(l), d = a(y), c = d.get("closestDepth"), n = d.get("closestPositionTexel"), S = d.get("farthestDepth"), m = this.velocityNode.load(n).xy.mul(de(0.5, -0.5)), _ = i.sub(m), B = f(_), u = _.greaterThanEqual(0).all().and(_.lessThanEqual(1).all()), M = S.sub(c).greaterThan(this.edgeDepthDiff), U = c.sub(B).greaterThan(this.depthThreshold), q = u.and(M.or(U.not())), R = this.beautyNode.sample(i), L = p.sample(i.sub(m)), ae = $(R.rgb.mul(R.a), R.a).toVar(), ce = i.sub(_).mul(l).length().div(this.maxVelocityLength).saturate().sqrt(), T = Y(0.05).toVar();
640
641
  this.useSubpixelCorrection && T.addAssign(h(m, l).mul(0.5)), T.assign(q.select(T.add(ce.mul(0.6)).saturate(), 1));
641
- const _ = this._progressiveWeight, N = _.greaterThan(0).and(q);
642
- T.assign(N.select(_, T));
642
+ const C = this._progressiveWeight, N = C.greaterThan(0).and(q);
643
+ T.assign(N.select(C, T));
643
644
  const O = _e(0.25, 1.25, ce.oneMinus().pow2()), Z = N.select(
644
645
  L,
645
- x(y, ne, L, O)
646
+ x(y, ae, L, O)
646
647
  );
647
648
  return N.select(
648
- _e(Z, ne, T),
649
- p(ne, Z, T)
649
+ _e(Z, ae, T),
650
+ g(ae, Z, T)
650
651
  );
651
652
  });
652
- return this._resolveMaterial.fragmentNode = w(), this._textureNode;
653
+ return this._resolveMaterial.fragmentNode = b(), this._textureNode;
653
654
  }
654
655
  dispose() {
655
656
  this._historyRenderTarget.dispose(), this._resolveRenderTarget.dispose(), this._resolveMaterial.dispose();
656
657
  }
657
658
  }
658
- const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
659
- const e = k((a) => a.animationsLoaded), t = k((a) => a.characterState), s = k((a) => a.lipSyncManager), r = k((a) => a.blendshapeManager), o = C((a) => a.credentials), n = C((a) => a.currentUtterance), f = C((a) => a.textToSpeak), b = C((a) => a.visemes), x = C((a) => a.blendshapes), h = C((a) => a.visemeIntensity), p = C((a) => a.currentVisemeIndex), g = C((a) => a.currentBlendshapeIndex), w = C((a) => a.useBlendshapeManager), [i, l] = D(!1), [y, d] = D(!1), c = ye(() => o != null && o.region && (o.subscriptionKey || o.token) ? Nt({
659
+ const Oe = (e, t, s, r) => new gs(yt(e), t, s, r);
660
+ function ps({ pixelated: e }) {
661
+ const t = We((r) => r.gl), s = we.useRef(1);
662
+ return we.useEffect(() => {
663
+ const r = t.domElement;
664
+ return () => {
665
+ t.setPixelRatio(window.devicePixelRatio), e && r && (r.style.imageRendering = "auto");
666
+ };
667
+ }, []), dt({
668
+ onDecline: (r) => {
669
+ s.current = Math.max(0.33, s.current * 0.66), t.setPixelRatio(s.current * window.devicePixelRatio), e && t.domElement && (t.domElement.style.imageRendering = "pixelated");
670
+ },
671
+ onIncline: (r) => {
672
+ s.current = Math.min(1, s.current * 1.25), t.setPixelRatio(s.current * window.devicePixelRatio), e && t.domElement && (t.domElement.style.imageRendering = s.current === 1 ? "auto" : "pixelated");
673
+ }
674
+ }), null;
675
+ }
676
+ const fs = () => {
677
+ const e = k((n) => n.animationsLoaded), t = k((n) => n.characterState), s = k((n) => n.lipSyncManager), r = k((n) => n.blendshapeManager), o = P((n) => n.credentials), a = P((n) => n.currentUtterance), f = P((n) => n.textToSpeak), w = P((n) => n.visemes), x = P((n) => n.blendshapes), h = P((n) => n.visemeIntensity), g = P((n) => n.currentVisemeIndex), p = P((n) => n.currentBlendshapeIndex), b = P((n) => n.useBlendshapeManager), [i, l] = D(!1), [y, d] = D(!1), c = ye(() => o != null && o.region && (o.subscriptionKey || o.token) ? It({
660
678
  credentials: {
661
679
  region: o.region,
662
680
  authorizationToken: o.token,
@@ -665,92 +683,92 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
665
683
  }) : null, [o]);
666
684
  return V(() => {
667
685
  if (c) {
668
- const a = c.speechSynthesis.getVoices();
669
- a && Array.isArray(a) && a.length ? (je(a), l(!0)) : c.speechSynthesis.onvoiceschanged = () => {
686
+ const n = c.speechSynthesis.getVoices();
687
+ n && Array.isArray(n) && n.length ? (je(n), l(!0)) : c.speechSynthesis.onvoiceschanged = () => {
670
688
  je(c.speechSynthesis.getVoices()), l(!0);
671
689
  };
672
690
  }
673
691
  }, [c]), V(() => {
674
- i && (w ? !!r : !!s) && e && d(!0);
675
- }, [i, s, r, e, w]), V(() => {
692
+ i && (b ? !!r : !!s) && e && d(!0);
693
+ }, [i, s, r, e, b]), V(() => {
676
694
  if (f) {
677
- const a = new It(f);
678
- os(a);
695
+ const n = new Ft(f);
696
+ cs(n);
679
697
  }
680
698
  }, [f]), V(() => {
681
- var a, S;
682
- n && y ? (n.onstart = () => {
683
- console.log("Start"), Re(J.speaking);
684
- }, n.onend = () => {
685
- console.log("End"), Re(J.idle);
686
- }, n.onboundary = () => {
687
- }, n.onviseme = (m) => {
688
- We(m);
689
- }, (a = c == null ? void 0 : c.speechSynthesis) == null || a.speak(n, null)) : (S = c == null ? void 0 : c.speechSynthesis) == null || S.cancel();
690
- }, [n]), V(() => {
699
+ var n, S;
700
+ a && y ? (a.onstart = () => {
701
+ console.log("Start"), Be(J.speaking);
702
+ }, a.onend = () => {
703
+ console.log("End"), Be(J.idle);
704
+ }, a.onboundary = () => {
705
+ }, a.onviseme = (m) => {
706
+ Ge(m);
707
+ }, (n = c == null ? void 0 : c.speechSynthesis) == null || n.speak(a, null)) : (S = c == null ? void 0 : c.speechSynthesis) == null || S.cancel();
708
+ }, [a]), V(() => {
691
709
  s && (s.visemeIntensity = h);
692
710
  }, [h]), V(() => {
693
- if (!w && s && t === J.speaking) {
694
- if (!s.isStarted && s.start(), b.length > 1 && p === 0)
695
- b.forEach((a) => {
696
- const S = parseInt(a.name);
711
+ if (!b && s && t === J.speaking) {
712
+ if (!s.isStarted && s.start(), w.length > 1 && g === 0)
713
+ w.forEach((n) => {
714
+ const S = parseInt(n.name);
697
715
  if (!isNaN(S)) {
698
- const m = De.get(S);
699
- m && s.PlayVisemeAsync(m, a.elapsedTime / 1e4);
716
+ const m = Ee.get(S);
717
+ m && s.PlayVisemeAsync(m, n.elapsedTime / 1e4);
700
718
  }
701
719
  });
702
720
  else
703
- for (let a = p + 1; a < b.length; a++) {
704
- const S = b[a], m = parseInt(S.name);
721
+ for (let n = g + 1; n < w.length; n++) {
722
+ const S = w[n], m = parseInt(S.name);
705
723
  if (!isNaN(m)) {
706
- const P = De.get(m);
707
- P && s.PlayVisemeAsync(P, S.elapsedTime / 1e4);
724
+ const _ = Ee.get(m);
725
+ _ && s.PlayVisemeAsync(_, S.elapsedTime / 1e4);
708
726
  }
709
727
  }
710
- is(b.length - 1);
728
+ ls(w.length - 1);
711
729
  }
712
- }, [t, b, s, w]), V(() => {
713
- if (w && r && t === J.speaking) {
714
- if (!r.isStarted && r.start(), x.length > 1 && g === 0)
715
- x.forEach((a) => {
716
- r.PlayBlendShapeAsync(a);
730
+ }, [t, w, s, b]), V(() => {
731
+ if (b && r && t === J.speaking) {
732
+ if (!r.isStarted && r.start(), x.length > 1 && p === 0)
733
+ x.forEach((n) => {
734
+ r.PlayBlendShapeAsync(n);
717
735
  });
718
736
  else
719
- for (let a = g + 1; a < x.length; a++) {
720
- const S = x[a];
737
+ for (let n = p + 1; n < x.length; n++) {
738
+ const S = x[n];
721
739
  r.PlayBlendShapeAsync(S);
722
740
  }
723
- cs(x.length - 1);
741
+ hs(x.length - 1);
724
742
  }
725
- }, [t, x, r, w]), V(() => {
726
- t !== J.speaking && (qe(), Ge());
743
+ }, [t, x, r, b]), V(() => {
744
+ t !== J.speaking && (Je(), Ke());
727
745
  }, [t]), null;
728
- }, ps = ({ points: e, color: t = "red" }) => {
746
+ }, ys = ({ points: e, color: t = "red" }) => {
729
747
  const s = ye(() => {
730
748
  const r = new A.BufferGeometry().setFromPoints(e), o = new A.LineBasicMaterial({ color: t, toneMapped: !1 });
731
749
  return new A.Line(r, o);
732
750
  }, [e, t]);
733
751
  return /* @__PURE__ */ v.createElement("primitive", { object: s });
734
- }, gs = ({ parentGpuTier: e, setIsGpuAvailable: t, children: s, tonemapping: r }) => {
735
- const o = z((u) => u.cameraPosition), n = z((u) => u.lookAt), f = z((u) => u.movable), b = E((u) => u.targets), x = E((u) => u.showFirstTarget), [h] = D(e || lt()), [p, g] = D(), [w, i] = D(null), [l, y] = D(void 0), d = se(null), c = se(null), a = se(null), S = (u) => {
752
+ }, Ss = ({ parentGpuTier: e, setIsGpuAvailable: t, children: s, tonemapping: r }) => {
753
+ const o = z((u) => u.cameraPosition), a = z((u) => u.lookAt), f = z((u) => u.movable), w = j((u) => u.targets), x = j((u) => u.showFirstTarget), [h] = D(e || ut()), [g, p] = D(), [b, i] = D(null), [l, y] = D(void 0), d = se(null), c = se(null), n = se(null), S = (u) => {
736
754
  u.preventDefault(), u.stopPropagation();
737
755
  };
738
756
  V(() => {
739
- Et(c.current);
757
+ Lt(c.current);
740
758
  }, [c.current]), V(() => {
741
759
  var u, M, U, q;
742
760
  if (f)
743
- w == null || w.abort(), i(null);
761
+ b == null || b.abort(), i(null);
744
762
  else {
745
- const I = new AbortController();
746
- i(I), (u = d.current) == null || u.addEventListener("wheel", S, { passive: !1, signal: I.signal }), (M = d.current) == null || M.addEventListener("pointerdown", S, { passive: !1, signal: I.signal }), (U = d.current) == null || U.addEventListener("pointermove", S, { passive: !1, signal: I.signal }), (q = d.current) == null || q.addEventListener("click", S, { passive: !1, signal: I.signal });
763
+ const R = new AbortController();
764
+ i(R), (u = d.current) == null || u.addEventListener("wheel", S, { passive: !1, signal: R.signal }), (M = d.current) == null || M.addEventListener("pointerdown", S, { passive: !1, signal: R.signal }), (U = d.current) == null || U.addEventListener("pointermove", S, { passive: !1, signal: R.signal }), (q = d.current) == null || q.addEventListener("click", S, { passive: !1, signal: R.signal });
747
765
  }
748
766
  }, [f]), V(() => {
749
- a != null && a.current && n && o && a.current.setLookAt(o.x, o.y, o.z, n.x, n.y, n.z, !0);
750
- }, [o, n]), V(() => {
767
+ n != null && n.current && a && o && n.current.setLookAt(o.x, o.y, o.z, a.x, a.y, a.z, !0);
768
+ }, [o, a]), V(() => {
751
769
  if (h)
752
770
  if (h.type === "FALLBACK")
753
- g(
771
+ p(
754
772
  "medium"
755
773
  /* medium */
756
774
  );
@@ -758,44 +776,44 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
758
776
  switch (h.tier) {
759
777
  case 0:
760
778
  case 1:
761
- g(
779
+ p(
762
780
  "low"
763
781
  /* low */
764
782
  );
765
783
  break;
766
784
  case 2:
767
- g(
785
+ p(
768
786
  "medium"
769
787
  /* medium */
770
788
  );
771
789
  break;
772
790
  case 3:
773
- g(
791
+ p(
774
792
  "high"
775
793
  /* high */
776
794
  );
777
795
  break;
778
796
  default:
779
- g(
797
+ p(
780
798
  "low"
781
799
  /* low */
782
800
  );
783
801
  break;
784
802
  }
785
803
  }, [h]), V(() => {
786
- switch (p && (m.current = p), p) {
804
+ switch (g && (m.current = g), g) {
787
805
  case "low":
788
806
  console.warn("Retorik React-Bodyengine-Three > GPU tier too low, no rendering available"), t(!1);
789
807
  break;
790
808
  case "medium":
791
- y([0.9, 1]), console.log(`Retorik React-Bodyengine-Three > GPU tier detected : ${p}`), t(!0);
809
+ y([1, 1.5]), console.log(`Retorik React-Bodyengine-Three > GPU tier detected : ${g}`), t(!0);
792
810
  break;
793
811
  case "high":
794
- y([1, 2]), console.log(`Retorik React-Bodyengine-Three > GPU tier detected : ${p}`), t(!0);
812
+ y([1, 2]), console.log(`Retorik React-Bodyengine-Three > GPU tier detected : ${g}`), t(!0);
795
813
  break;
796
814
  }
797
- }, [p]);
798
- const m = se(void 0), P = Ye(async (u) => {
815
+ }, [g]);
816
+ const m = se(void 0), _ = $e(async (u) => {
799
817
  const M = new A.WebGPURenderer({
800
818
  canvas: u.canvas,
801
819
  antialias: !1,
@@ -804,37 +822,37 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
804
822
  });
805
823
  return M.setClearColor(new A.Color("#000000"), 0), M.setPixelRatio(devicePixelRatio), M.shadowMap.type = A.PCFSoftShadowMap, await M.init(), M;
806
824
  }, []), B = ye(() => {
807
- if (b.length) {
808
- const u = b[0], M = new A.Vector3(u.position.x - 0.5, u.position.y, u.position.z - 0.1), U = new A.Vector3(u.position.x + 0.5, u.position.y, u.position.z - 0.1);
825
+ if (w.length) {
826
+ const u = w[0], M = new A.Vector3(u.position.x - 0.5, u.position.y, u.position.z - 0.1), U = new A.Vector3(u.position.x + 0.5, u.position.y, u.position.z - 0.1);
809
827
  return [M, U];
810
828
  } else if (o) {
811
829
  const u = new A.Vector3(o.x - 0.5, o.y, o.z - 0.1), M = new A.Vector3(o.x + 0.5, o.y, o.z - 0.1);
812
830
  return [u, M];
813
831
  }
814
832
  return [];
815
- }, [b, o]);
816
- return l ? /* @__PURE__ */ v.createElement(Pt, { gl: P, dpr: l, ref: d, shadows: !0 }, /* @__PURE__ */ v.createElement(fs, { tonemapping: r, processedTier: p }), /* @__PURE__ */ v.createElement(ht, null), /* @__PURE__ */ v.createElement(ms, null), /* @__PURE__ */ v.createElement(dt, { ref: c, makeDefault: !0, fov: 28 }), /* @__PURE__ */ v.createElement(ut, { ref: a }), x && B.length && /* @__PURE__ */ v.createElement(ps, { points: B, color: "red" }), /* @__PURE__ */ v.createElement(Xe, { fallback: null }, s)) : /* @__PURE__ */ v.createElement(v.Fragment, null);
817
- }, fs = ({ tonemapping: e, processedTier: t }) => {
818
- const { gl: s, scene: r, camera: o, size: n } = Vt(), [f] = D(new A.Vector3(-3, 2, 2)), [b] = D(new A.Vector3(0, 1, 0)), [x] = D(2), [h] = D(-3e-3), [p] = D(0.6), g = se(null), w = se(null);
833
+ }, [w, o]);
834
+ return l ? /* @__PURE__ */ v.createElement(Rt, { gl: _, dpr: l, ref: d, shadows: !0 }, /* @__PURE__ */ v.createElement(mt, { iterations: 5, ms: 100, threshold: 0.75 }, /* @__PURE__ */ v.createElement(xs, { tonemapping: r, processedTier: g }), /* @__PURE__ */ v.createElement(fs, null), /* @__PURE__ */ v.createElement(gt, { ref: c, makeDefault: !0, fov: 28 }), /* @__PURE__ */ v.createElement(pt, { ref: n }), x && B.length && /* @__PURE__ */ v.createElement(ys, { points: B, color: "red" }), /* @__PURE__ */ v.createElement(et, { fallback: null }, s, /* @__PURE__ */ v.createElement(ps, { pixelated: !0 })))) : /* @__PURE__ */ v.createElement(v.Fragment, null);
835
+ }, xs = ({ tonemapping: e, processedTier: t }) => {
836
+ const { gl: s, scene: r, camera: o, size: a } = We(), [f] = D(new A.Vector3(-3, 2, 2)), [w] = D(new A.Vector3(0, 1, 0)), [x] = D(2), [h] = D(-3e-3), [g] = D(0.6), p = se(null), b = se(null);
819
837
  return V(() => {
820
- s && (s.shadowMap.type = A.PCFSoftShadowMap, s.toneMapping = e, t !== "low" ? r.environmentIntensity = p : r.environmentIntensity = 1);
838
+ s && (s.shadowMap.type = A.PCFSoftShadowMap, s.toneMapping = e, t !== "low" ? r.environmentIntensity = g : r.environmentIntensity = 1);
821
839
  }, [s, e]), V(() => {
822
- r.environmentIntensity = p;
823
- }, [p]), V(() => {
840
+ r.environmentIntensity = g;
841
+ }, [g]), V(() => {
824
842
  if (!s || !r || !o || !t) return;
825
843
  r.background = null;
826
- const i = t === "high", l = wt(r, o);
844
+ const i = t === "high", l = At(r, o);
827
845
  l.setMRT(
828
- i ? Ve({ output: Ne, diffuseColor: Mt, normal: Tt(At), velocity: fe }) : Ve({ output: Ne, velocity: fe })
846
+ i ? Ne({ output: Re, diffuseColor: kt, normal: Pt(Ct), velocity: fe }) : Ne({ output: Re, velocity: fe })
829
847
  );
830
848
  let y;
831
849
  if (i) {
832
- const c = l.getTextureNode("output"), a = l.getTextureNode("diffuseColor"), S = l.getTextureNode("depth"), m = l.getTextureNode("velocity"), P = l.getTextureNode("normal"), B = kt((L) => Ct(P.sample(L))), u = _t(c, S, B, o);
850
+ const c = l.getTextureNode("output"), n = l.getTextureNode("diffuseColor"), S = l.getTextureNode("depth"), m = l.getTextureNode("velocity"), _ = l.getTextureNode("normal"), B = _t((L) => Vt(_.sample(L))), u = Nt(c, S, B, o);
833
851
  u.aoIntensity.value = 1, u.giIntensity.value = 5, u.sliceCount.value = 2, u.stepCount.value = 8, u.thickness.value = 0.03, u.radius.value = 0.5, u.expFactor.value = 0.1, u.backfaceLighting.value = 0.1;
834
- const M = u.rgb, U = u.a, q = $(Oe(c.rgb.mul(U), a.rgb.mul(M)), c.a), I = Le(q, S, m, o);
835
- I.jitterIntensity = 0.25, y = I;
852
+ const M = u.rgb, U = u.a, q = $(He(c.rgb.mul(U), n.rgb.mul(M)), c.a), R = Oe(q, S, m, o);
853
+ R.jitterIntensity = 0.25, y = R;
836
854
  } else {
837
- const c = Le(
855
+ const c = Oe(
838
856
  l,
839
857
  l.getTextureNode("depth"),
840
858
  l.getTextureNode("velocity"),
@@ -843,28 +861,28 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
843
861
  c.jitterIntensity = 0.25, y = c;
844
862
  }
845
863
  const d = new A.RenderPipeline(s);
846
- return d.outputNode = y, w.current = d, () => {
847
- d.dispose(), w.current = null;
864
+ return d.outputNode = y, b.current = d, () => {
865
+ d.dispose(), b.current = null;
848
866
  };
849
867
  }, [s, r, o, t]), V(() => {
850
- !s || !n || s.setSize(n.width, n.height);
851
- }, [n]), He(({ gl: i, scene: l, camera: y }) => {
852
- w.current && w.current.render();
853
- }, 1), /* @__PURE__ */ v.createElement(v.Fragment, null, t !== "low" && s && /* @__PURE__ */ v.createElement(v.Fragment, null, /* @__PURE__ */ v.createElement("directionalLight", { ref: g, color: "white", position: f.toArray(), "target-position": b.toArray(), intensity: x, castShadow: !0, "shadow-mapSize-width": 512, "shadow-mapSize-height": 512, "shadow-bias": h, "shadow-intensity": 0.7, "shadow-radius": 1.5 }, /* @__PURE__ */ v.createElement("orthographicCamera", { attach: "shadow-camera", args: [-1, 1, 2, -0.5, 2, 8] })), /* @__PURE__ */ v.createElement("directionalLight", { name: "DirectionalLight2", color: "white", position: [0, 1, -1], intensity: 0.5 })));
854
- }, ys = ({ character: e, autoLookAt: t }) => {
855
- const s = k((h) => h.characterState), r = E((h) => h.currentAUs), o = E((h) => h.currentGaze), n = E((h) => h.currentHeadPose), f = E((h) => h.lookAtCamera), b = z((h) => h.cameraPosition), x = E((h) => h.targets);
856
- return He((h, p) => {
857
- const g = {
858
- deltaTime: p,
868
+ !s || !a || s.setSize(a.width, a.height);
869
+ }, [a]), qe(({ gl: i, scene: l, camera: y }) => {
870
+ b.current && b.current.render();
871
+ }, 1), /* @__PURE__ */ v.createElement(v.Fragment, null, t !== "low" && s && /* @__PURE__ */ v.createElement(v.Fragment, null, /* @__PURE__ */ v.createElement("directionalLight", { ref: p, color: "white", position: f.toArray(), "target-position": w.toArray(), intensity: x, castShadow: !0, "shadow-mapSize-width": 512, "shadow-mapSize-height": 512, "shadow-bias": h, "shadow-intensity": 0.7, "shadow-radius": 1.5 }, /* @__PURE__ */ v.createElement("orthographicCamera", { attach: "shadow-camera", args: [-1, 1, 2, -0.5, 2, 8] }))));
872
+ }, vs = ({ character: e, autoLookAt: t }) => {
873
+ const s = k((h) => h.characterState), r = j((h) => h.currentAUs), o = j((h) => h.currentGaze), a = j((h) => h.currentHeadPose), f = j((h) => h.lookAtCamera), w = z((h) => h.cameraPosition), x = j((h) => h.targets);
874
+ return qe((h, g) => {
875
+ const p = {
876
+ deltaTime: g,
859
877
  timestamp: h.clock.oldTime,
860
878
  AU: r,
861
879
  gaze: o,
862
- headPose: n,
880
+ headPose: a,
863
881
  characterState: s,
864
- lookAt: f ? b : void 0,
882
+ lookAt: f ? w : void 0,
865
883
  targets: x
866
884
  };
867
- e.update(g);
885
+ e.update(p);
868
886
  }), V(() => {
869
887
  if (t)
870
888
  switch (s) {
@@ -880,23 +898,23 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
880
898
  else
881
899
  ue(!1);
882
900
  }, [s, t]), V(() => {
883
- Dt(e);
901
+ jt(e);
884
902
  }, [e]), null;
885
- }, Gs = ({ url: e, type: t, animationsUrl: s, gender: r, speechSynthesis: o, camera: n, onLoadingCompleted: f, autoLookAt: b, breathing: x, disableAnimations: h, debug: p, enableBml: g, animationWeights: w, license: i, detectGpuData: l, environmentPreset: y = "apartment", tonemapping: d = A.NeutralToneMapping, targets: c, useBlendshapeManager: a = !1 }) => {
886
- const S = k((T) => T.animationsLoaded), m = z((T) => T.defaultPositions), P = z((T) => T.defaultDistances), [B, u] = D(), [M, U] = D(null), [q, I] = D(), [L, ne] = D(!1), xe = async (T) => {
887
- let _ = null;
903
+ }, Zs = ({ url: e, type: t, animationsUrl: s, gender: r, speechSynthesis: o, camera: a, onLoadingCompleted: f, autoLookAt: w, breathing: x, disableAnimations: h, debug: g, enableBml: p, animationWeights: b, license: i, detectGpuData: l, environmentPreset: y = "apartment", tonemapping: d = A.NeutralToneMapping, targets: c, useBlendshapeManager: n = !1 }) => {
904
+ const S = k((T) => T.animationsLoaded), m = z((T) => T.defaultPositions), _ = z((T) => T.defaultDistances), [B, u] = D(), [M, U] = D(null), [q, R] = D(), [L, ae] = D(!1), xe = async (T) => {
905
+ let C = null;
888
906
  switch (t) {
889
907
  case ee.cc3:
890
- _ = new ct(), I(le.cc3);
908
+ C = new ht(), R(le.cc3);
891
909
  break;
892
910
  case ee.avatarsdk:
893
- _ = new it(), I(le.avatarsdk);
911
+ C = new lt(), R(le.avatarsdk);
894
912
  break;
895
913
  case ee.avaturn:
896
- _ = new ot(), I(le.avaturn);
914
+ C = new ct(), R(le.avaturn);
897
915
  break;
898
916
  }
899
- const N = await _.loadAsync(T).catch((O) => console.warn("Error loading character : ", O));
917
+ const N = await C.loadAsync(T).catch((O) => console.warn("Error loading character : ", O));
900
918
  if (N) {
901
919
  let O = null;
902
920
  const Z = {
@@ -905,10 +923,10 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
905
923
  animationsUrl: s,
906
924
  gender: r || "male",
907
925
  type: t,
908
- debug: p,
909
- enableBmlManager: !!g,
910
- animationWeights: w,
911
- useBlendshapeManager: a,
926
+ debug: g,
927
+ enableBmlManager: !!p,
928
+ animationWeights: b,
929
+ useBlendshapeManager: n,
912
930
  license: i
913
931
  };
914
932
  switch (t) {
@@ -928,54 +946,54 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
928
946
  Fe(!0);
929
947
  };
930
948
  V(() => {
931
- var T, _;
932
- M && S && (x === !1 && ((_ = (T = M.animationManager) == null ? void 0 : T.disableBreathing) == null || _.call(T)), L ? (Jt(M.getAllAnimationNames()), Kt(M.getAllAnimations()), setTimeout(() => {
949
+ var T, C;
950
+ M && S && (x === !1 && ((C = (T = M.animationManager) == null ? void 0 : T.disableBreathing) == null || C.call(T)), L ? (Zt(M.getAllAnimationNames()), Qt(M.getAllAnimations()), setTimeout(() => {
933
951
  f == null || f();
934
952
  }, 1e3)) : ce());
935
953
  }, [M, S, L]), V(() => {
936
- Wt(c || []);
954
+ Gt(c || []);
937
955
  }, [c]), V(() => {
938
956
  Fe(!1), B !== void 0 && (B ? xe(e) : f == null || f());
939
957
  }, [e, B]), V(() => {
940
- if (L && P && m)
941
- if (n) {
942
- const T = ds(n, P, m);
943
- Be(T), ze(n.lookAt ? m[n.lookAt] : m.lowerbelly), Ht(!!n.movable);
958
+ if (L && _ && m)
959
+ if (a) {
960
+ const T = ms(a, _, m);
961
+ ze(T), De(a.lookAt ? m[a.lookAt] : m.lowerbelly), qt(!!a.movable);
944
962
  } else {
945
963
  const T = m.mouth.clone();
946
- T.setComponent(2, P.farther), Be(T), ze(m.lowerbelly);
964
+ T.setComponent(2, _.farther), ze(T), De(m.lowerbelly);
947
965
  }
948
- }, [L, n, P, m]), V(() => {
949
- o && (o.credentials && ns(o.credentials), o.voice && ls(o.voice));
966
+ }, [L, a, _, m]), V(() => {
967
+ o && (o.credentials && is(o.credentials), o.voice && ds(o.voice));
950
968
  }, [o]), V(() => {
951
- hs(a);
952
- }, [a]);
969
+ us(n);
970
+ }, [n]);
953
971
  const ce = () => {
954
972
  if (M && q) {
955
973
  try {
956
- const T = new A.Box3().setFromObject(M), _ = T.max, N = T.min, O = new A.Vector3((_.x + N.x) / 2, (_.y + N.y) / 2, (_.z + N.z) / 2);
957
- Ut(O);
958
- const Z = Math.abs(_.x - N.x), j = Math.abs(_.y - N.y), Ke = Math.abs(_.z - N.z);
959
- jt({
974
+ const T = new A.Box3().setFromObject(M), C = T.max, N = T.min, O = new A.Vector3((C.x + N.x) / 2, (C.y + N.y) / 2, (C.z + N.z) / 2);
975
+ Ot(O);
976
+ const Z = Math.abs(C.x - N.x), E = Math.abs(C.y - N.y), Qe = Math.abs(C.z - N.z);
977
+ Ut({
960
978
  x: Z,
961
- y: j,
962
- z: Ke
979
+ y: E,
980
+ z: Qe
963
981
  });
964
- const H = (_.x + N.x) / 2, W = (_.z + N.z) / 2, Ze = {
965
- eye: new A.Vector3(H, _.y - j / 16, W),
966
- mouth: new A.Vector3(H, _.y - j / 12, W),
967
- neck: new A.Vector3(H, _.y - j / 8, W),
968
- clavicle: new A.Vector3(H, _.y - j / 6, W),
969
- torso: new A.Vector3(H, _.y - j / 4, W),
970
- belly: new A.Vector3(H, _.y - j / 8 * 3, W),
971
- lowerbelly: new A.Vector3(H, _.y - j / 32 * 15, W),
982
+ const H = (C.x + N.x) / 2, W = (C.z + N.z) / 2, Ye = {
983
+ eye: new A.Vector3(H, C.y - E / 16, W),
984
+ mouth: new A.Vector3(H, C.y - E / 12, W),
985
+ neck: new A.Vector3(H, C.y - E / 8, W),
986
+ clavicle: new A.Vector3(H, C.y - E / 6, W),
987
+ torso: new A.Vector3(H, C.y - E / 4, W),
988
+ belly: new A.Vector3(H, C.y - E / 8 * 3, W),
989
+ lowerbelly: new A.Vector3(H, C.y - E / 32 * 15, W),
972
990
  hips: O,
973
- higherthigh: new A.Vector3(H, N.y + j / 32 * 15, W),
974
- thigh: new A.Vector3(H, N.y + j / 8 * 3, W),
975
- knee: new A.Vector3(H, N.y + j / 4, W),
976
- leg: new A.Vector3(H, N.y + j / 8, W),
991
+ higherthigh: new A.Vector3(H, N.y + E / 32 * 15, W),
992
+ thigh: new A.Vector3(H, N.y + E / 8 * 3, W),
993
+ knee: new A.Vector3(H, N.y + E / 4, W),
994
+ leg: new A.Vector3(H, N.y + E / 8, W),
977
995
  feet: new A.Vector3(H, N.y, W)
978
- }, K = (_.y - (N.y + j / 7 * 2)) / 2 / Math.tan(25 * (Math.PI / 180)), Qe = {
996
+ }, K = (C.y - (N.y + E / 7 * 2)) / 2 / Math.tan(25 * (Math.PI / 180)), Xe = {
979
997
  veryclose: K / 4,
980
998
  closer: K / 3,
981
999
  close: K / 2.5,
@@ -986,76 +1004,76 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
986
1004
  farther: K * 3,
987
1005
  veryfar: K * 4
988
1006
  };
989
- Lt(Ze), Ot(Qe);
1007
+ Ht(Ye), Wt(Xe);
990
1008
  } catch (T) {
991
1009
  console.warn(T);
992
1010
  }
993
- ne(!0);
1011
+ ae(!0);
994
1012
  }
995
1013
  };
996
- return /* @__PURE__ */ v.createElement(gs, { parentGpuTier: l, setIsGpuAvailable: u, tonemapping: d }, B ? /* @__PURE__ */ v.createElement(v.Fragment, null, M && /* @__PURE__ */ v.createElement(ys, { character: M, autoLookAt: !!b }), M && /* @__PURE__ */ v.createElement(v.Fragment, null, /* @__PURE__ */ v.createElement(mt, { preset: y }), /* @__PURE__ */ v.createElement("primitive", { object: M, castShadow: !0, receiveShadow: !0 }))) : /* @__PURE__ */ v.createElement(v.Fragment, null));
997
- }, Ss = {
1014
+ return /* @__PURE__ */ v.createElement(Ss, { parentGpuTier: l, setIsGpuAvailable: u, tonemapping: d }, B ? /* @__PURE__ */ v.createElement(v.Fragment, null, M && /* @__PURE__ */ v.createElement(vs, { character: M, autoLookAt: !!w }), M && /* @__PURE__ */ v.createElement(v.Fragment, null, /* @__PURE__ */ v.createElement(ft, { preset: y }), /* @__PURE__ */ v.createElement("primitive", { object: M, castShadow: !0, receiveShadow: !0 }))) : /* @__PURE__ */ v.createElement(v.Fragment, null));
1015
+ }, ws = {
998
1016
  emotions: [],
999
1017
  currentTopEmotion: Se.Neutral,
1000
1018
  useTopEmotionOnly: !0,
1001
1019
  autoDecay: !1
1002
- }, ie = ae()(() => Ss), Js = (e) => {
1020
+ }, ie = ne()(() => ws), Qs = (e) => {
1003
1021
  if (ie.setState({ emotions: e || [] }), e != null && e.length) {
1004
1022
  const t = e.reduce((s, r) => s.value > r.value ? s : r);
1005
1023
  ie.setState({ currentTopEmotion: t.emotion });
1006
1024
  } else
1007
1025
  ie.setState({ currentTopEmotion: Se.Neutral });
1008
- }, Ks = (e) => {
1026
+ }, Ys = (e) => {
1009
1027
  ie.setState({ useTopEmotionOnly: e });
1010
- }, Zs = (e) => {
1028
+ }, Xs = (e) => {
1011
1029
  ie.setState({ autoDecay: e });
1012
- }, Qs = (e) => {
1030
+ }, $s = (e) => {
1013
1031
  const t = k.getState().FACSManager;
1014
1032
  t == null || t.playFacialAnimation({ ...e });
1015
1033
  };
1016
1034
  export {
1017
- Gs as Character,
1018
- tr as CharacterState,
1019
- sr as CreationTool,
1020
- R as Distances,
1021
- $s as Object3D,
1022
- F as Positions,
1035
+ Zs as Character,
1036
+ nr as CharacterState,
1037
+ ar as CreationTool,
1038
+ F as Distances,
1039
+ sr as Object3D,
1040
+ I as Positions,
1023
1041
  G as Rotations,
1024
- Ls as addBlendshape,
1025
- Os as addSPPASViseme,
1026
- We as addViseme,
1027
- rr as bmlTags,
1028
- ar as emotionList,
1029
- Ge as flushBlendshapeData,
1030
- qe as flushLipSyncData,
1031
- Bs as getAnimationsMap,
1032
- _s as getCameraPosition,
1033
- Cs as getCharacterHeight,
1034
- Ps as getLookAt,
1035
- Ws as getVoices,
1036
- qt as lookAtAndKeep,
1037
- Fs as lookAtAndSteady,
1038
- Ds as playAnimationByName,
1039
- Qs as playFacialAnimation,
1040
- js as presets,
1041
- Gt as releaseLookAt,
1042
- Zs as setAutoDecay,
1043
- zs as setAutoPlay,
1044
- Us as setBlendshapes,
1045
- Be as setCameraPosition,
1046
- Re as setCharacterState,
1047
- Vs as setCurrentAUs,
1048
- Ns as setCurrentGaze,
1049
- Is as setCurrentHeadPose,
1050
- os as setCurrentUtterance,
1051
- Js as setEmotions,
1042
+ Ws as addBlendshape,
1043
+ qs as addSPPASViseme,
1044
+ Ge as addViseme,
1045
+ or as bmlTags,
1046
+ ir as emotionList,
1047
+ Ke as flushBlendshapeData,
1048
+ Je as flushLipSyncData,
1049
+ Es as getAnimationsMap,
1050
+ Ns as getCameraPosition,
1051
+ Vs as getCharacterHeight,
1052
+ Rs as getLookAt,
1053
+ Js as getVoices,
1054
+ Jt as lookAtAndKeep,
1055
+ zs as lookAtAndSteady,
1056
+ Us as playAnimationByName,
1057
+ $s as playFacialAnimation,
1058
+ Ls as presets,
1059
+ Kt as releaseLookAt,
1060
+ Xs as setAutoDecay,
1061
+ js as setAutoPlay,
1062
+ Hs as setBlendshapes,
1063
+ ze as setCameraPosition,
1064
+ Be as setCharacterState,
1065
+ Is as setCurrentAUs,
1066
+ Fs as setCurrentGaze,
1067
+ Bs as setCurrentHeadPose,
1068
+ cs as setCurrentUtterance,
1069
+ Qs as setEmotions,
1052
1070
  ue as setLookAtCamera,
1053
- Ht as setMovable,
1054
- Rs as setShowFirstTarget,
1055
- Hs as setTextToSpeak,
1056
- Ks as setUseTopEmotionOnly,
1057
- qs as setVisemeIntensity,
1058
- Es as setVisemes,
1059
- ls as setVoice,
1071
+ qt as setMovable,
1072
+ Ds as setShowFirstTarget,
1073
+ Gs as setTextToSpeak,
1074
+ Ys as setUseTopEmotionOnly,
1075
+ Ks as setVisemeIntensity,
1076
+ Os as setVisemes,
1077
+ ds as setVoice,
1060
1078
  k as useCharacterStore
1061
1079
  };