@davi-ai/react-bodyengine-three 1.0.26 → 1.0.28

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