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

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,38 +1,38 @@
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";
3
- import * as A from "three/webgpu";
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";
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
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";
13
- const Ie = (e) => {
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) => {
14
14
  let t;
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));
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));
20
20
  }
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;
21
+ }, o = () => t, v = { setState: s, getState: o, getInitialState: () => T, subscribe: (u) => (r.add(u), () => r.delete(u)) }, T = t = e(s, o, v);
22
+ return v;
23
+ }, Bt = (e) => e ? _e(e) : _e, zt = (e) => e;
24
24
  function Dt(e, t = zt) {
25
- const s = v.useSyncExternalStore(
25
+ const r = y.useSyncExternalStore(
26
26
  e.subscribe,
27
- v.useCallback(() => t(e.getState()), [e, t]),
28
- v.useCallback(() => t(e.getInitialState()), [e, t])
27
+ y.useCallback(() => t(e.getState()), [e, t]),
28
+ y.useCallback(() => t(e.getInitialState()), [e, t])
29
29
  );
30
- return v.useDebugValue(s), s;
30
+ return y.useDebugValue(r), r;
31
31
  }
32
32
  const Et = (e) => {
33
- const t = Bt(e), s = (r) => Dt(t, r);
34
- return Object.assign(s, t), s;
35
- }, ne = (e) => Et, k = ne()(() => ({
33
+ const t = Bt(e), r = (s) => Dt(t, s);
34
+ return Object.assign(r, t), r;
35
+ }, se = (e) => Et, b = se()(() => ({
36
36
  character: null,
37
37
  managers: [],
38
38
  globalManager: null,
@@ -48,81 +48,73 @@ const Et = (e) => {
48
48
  characterWidth: 0,
49
49
  characterHeight: 0,
50
50
  characterDepth: 0,
51
- characterState: J.idle
52
- })), jt = (e) => {
53
- k.setState({ character: e }), k.setState({ managers: {
51
+ characterState: q.idle
52
+ })), Ft = (e) => {
53
+ b.setState({ character: e }), b.setState({ managers: {
54
54
  lipSyncManager: (e == null ? void 0 : e.lipSyncManager) || null,
55
55
  blendshapeManager: (e == null ? void 0 : e.blendshapeManager) || null,
56
56
  eyeBlinkManager: (e == null ? void 0 : e.eyeBlinkManager) || null,
57
57
  animationManager: (e == null ? void 0 : e.animationManager) || null
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 });
59
- }, Fe = (e) => {
60
- k.setState({ animationsLoaded: e });
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
61
  }, Ut = (e) => {
62
- k.setState({ characterWidth: e.x }), k.setState({ characterHeight: e.y }), k.setState({ characterDepth: e.z });
63
- }, Vs = () => k.getState().characterHeight, Be = (e) => {
64
- k.setState({ characterState: e });
65
- }, z = ne()(() => ({
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()(() => ({
66
66
  cameraRef: null,
67
- cameraPosition: new tt(0, 0, 5),
67
+ cameraPosition: new Ye(0, 0, 5),
68
68
  bodyCenter: null,
69
69
  defaultPositions: null,
70
70
  defaultDistances: null,
71
71
  lookAt: null,
72
72
  movable: !0
73
- })), Lt = (e) => {
74
- z.setState({ cameraRef: e });
75
- }, ze = (e) => {
76
- z.setState({ cameraPosition: e });
77
- }, Ns = () => z.getState().cameraPosition, Ot = (e) => {
78
- z.setState({ bodyCenter: 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 });
79
+ }, Ot = (e) => {
80
+ D.setState({ defaultPositions: e });
79
81
  }, Ht = (e) => {
80
- z.setState({ defaultPositions: e });
81
- }, Wt = (e) => {
82
- z.setState({ defaultDistances: e });
83
- }, De = (e) => {
84
- z.setState({ lookAt: e });
85
- }, Rs = () => z.getState().lookAt, qt = (e) => {
86
- z.setState({ movable: e });
87
- }, j = ne()(() => ({
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()(() => ({
88
88
  currentAUs: null,
89
89
  currentGaze: null,
90
90
  currentHeadPose: null,
91
91
  lookAtCamera: !1,
92
92
  targets: [],
93
93
  showFirstTarget: !1
94
- })), Gt = (e) => {
95
- j.setState({ targets: e });
96
- }, Is = (e) => {
97
- j.setState({ currentAUs: e });
98
- }, Fs = (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 });
106
- const t = k.getState().globalManager;
107
- if (e) {
108
- const s = z.getState().cameraRef;
109
- t == null || t.lookAtAndSteady(s);
110
- } else
111
- t == null || t.releaseLookAt();
112
- }, Jt = (e) => {
113
- const t = k.getState().globalManager;
94
+ })), Wt = (e) => {
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();
104
+ }, qt = (e) => {
105
+ const t = b.getState().globalManager;
114
106
  if (e)
115
107
  t == null || t.lookAtAndKeep(e);
116
108
  else {
117
- const s = z.getState().cameraRef;
118
- t == null || t.lookAtAndKeep(s);
109
+ const r = D.getState().cameraRef;
110
+ t == null || t.lookAtAndKeep(r);
119
111
  }
120
112
  }, Kt = () => {
121
113
  var e;
122
- (e = k.getState().globalManager) == null || e.releaseLookAt();
123
- }, Ds = (e) => {
124
- j.setState({ showFirstTarget: e });
125
- }, re = ne()(() => ({
114
+ (e = b.getState().globalManager) == null || e.releaseLookAt();
115
+ }, Dr = (e) => {
116
+ U.setState({ showFirstTarget: e });
117
+ }, re = se()(() => ({
126
118
  animationsNames: [],
127
119
  animations: /* @__PURE__ */ new Map(),
128
120
  currentAnimation: null,
@@ -131,16 +123,16 @@ const Et = (e) => {
131
123
  re.setState({ animationsNames: e });
132
124
  }, Qt = (e) => {
133
125
  re.setState({ animations: e });
134
- }, Es = () => re.getState().animations, js = (e) => {
126
+ }, Er = () => re.getState().animations, Fr = (e) => {
135
127
  re.setState({ autoPlay: e });
136
- }, Us = (e) => {
128
+ }, Ur = (e) => {
137
129
  if (re.setState({ autoPlay: !1 }), re.getState().animationsNames.includes(e)) {
138
- const s = k.getState().animationManager;
139
- s == null || s.playAnimation(e);
130
+ const r = b.getState().animationManager;
131
+ r == null || r.playAnimation(e);
140
132
  }
141
133
  };
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([
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([
144
136
  [0, "sil"],
145
137
  [1, "aa"],
146
138
  [2, "aa"],
@@ -163,7 +155,7 @@ const Ee = /* @__PURE__ */ new Map([
163
155
  [19, "DD"],
164
156
  [20, "kk"],
165
157
  [21, "PP"]
166
- ]), Yt = /* @__PURE__ */ new Map([
158
+ ]), $t = /* @__PURE__ */ new Map([
167
159
  ["#", "#"],
168
160
  ["p", "p"],
169
161
  ["b", "b"],
@@ -212,7 +204,7 @@ const Ee = /* @__PURE__ */ new Map([
212
204
  ["9~", "oẽ"],
213
205
  ["N", "ŋ"],
214
206
  ["J", "ɲ"]
215
- ]), Xt = /* @__PURE__ */ new Map([
207
+ ]), Yt = /* @__PURE__ */ new Map([
216
208
  ["#", 0],
217
209
  ["æ", 1],
218
210
  ["ə", 1],
@@ -253,48 +245,48 @@ const Ee = /* @__PURE__ */ new Map([
253
245
  ["p", 21],
254
246
  ["b", 21],
255
247
  ["m", 21]
256
- ]), $t = {
257
- position: I.mouth,
258
- distance: F.farther,
259
- lookAt: I.lowerbelly
260
- }, es = {
261
- position: I.mouth,
262
- distance: F.close,
263
- lookAt: I.mouth
264
- }, ts = {
265
- position: I.mouth,
266
- distance: F.midclose,
267
- lookAt: I.mouth
268
- }, ss = {
269
- position: I.neck,
270
- distance: F.close,
271
- lookAt: I.neck
272
- }, rs = {
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
280
- }, as = {
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()(() => ({
248
+ ]), Jt = {
249
+ position: R.mouth,
250
+ distance: V.farther,
251
+ lookAt: R.lowerbelly
252
+ }, Xt = {
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,
282
+ head: Xt,
283
+ neck: er,
284
+ shoulders: tr,
285
+ chest: rr,
286
+ belly: sr,
287
+ knees: nr,
288
+ feet: ar
289
+ }, x = se()(() => ({
298
290
  credentials: void 0,
299
291
  currentUtterance: null,
300
292
  boundaries: [],
@@ -307,295 +299,251 @@ const Ee = /* @__PURE__ */ new Map([
307
299
  textToSpeak: null,
308
300
  visemeIntensity: 1,
309
301
  useBlendshapeManager: !1
310
- })), is = (e) => {
311
- P.setState({ credentials: e });
312
- }, cs = (e) => {
302
+ })), or = (e) => {
303
+ x.setState({ credentials: e });
304
+ }, ir = (e) => {
313
305
  if (e) {
314
- const t = P.getState().voice;
306
+ const t = x.getState().voice;
315
307
  t && (e.voice = t);
316
308
  }
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);
328
- if (s) {
329
- const r = Xt.get(s);
330
- r !== void 0 && Ge({ ...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) });
331
323
  }
332
- }, ls = (e) => {
333
- P.setState({ currentVisemeIndex: e });
334
- }, hs = (e) => {
335
- P.setState({ currentBlendshapeIndex: e });
336
- }, Je = () => {
324
+ }, cr = (e) => {
325
+ x.setState({ currentVisemeIndex: e });
326
+ }, lr = (e) => {
327
+ x.setState({ currentBlendshapeIndex: e });
328
+ }, Ge = () => {
337
329
  var e;
338
- P.setState({
330
+ x.setState({
339
331
  visemes: [],
340
332
  currentVisemeIndex: 0
341
- }), (e = k.getState().lipSyncManager) == null || e.stop();
342
- }, Ke = () => {
333
+ }), (e = b.getState().lipSyncManager) == null || e.stop();
334
+ }, We = () => {
343
335
  var e;
344
- P.setState({
336
+ x.setState({
345
337
  blendshapes: [],
346
338
  currentBlendshapeIndex: 0
347
- }), (e = k.getState().blendshapeManager) == null || e.stop();
348
- }, ds = (e) => {
349
- P.setState({ voice: e });
350
- }, je = (e) => {
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);
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);
361
353
  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;
363
- switch (f) {
364
- case F.veryclose:
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:
365
357
  a = t.veryclose;
366
358
  break;
367
- case F.closer:
359
+ case V.closer:
368
360
  a = t.closer;
369
361
  break;
370
- case F.close:
362
+ case V.close:
371
363
  a = t.close;
372
364
  break;
373
- case F.midclose:
365
+ case V.midclose:
374
366
  a = t.midclose;
375
367
  break;
376
- case F.medium:
368
+ case V.medium:
377
369
  a = t.medium;
378
370
  break;
379
- case F.midfar:
371
+ case V.midfar:
380
372
  a = t.midfar;
381
373
  break;
382
- case F.far:
374
+ case V.far:
383
375
  a = t.far;
384
376
  break;
385
- case F.farther:
377
+ case V.farther:
386
378
  case void 0:
387
379
  default:
388
380
  a = t.farther;
389
381
  break;
390
- case F.veryfar:
382
+ case V.veryfar:
391
383
  a = t.veryfar;
392
384
  break;
393
385
  }
394
- if (w && w !== G.face)
395
- switch (w) {
396
- case G.eighthleft: {
397
- const x = 0.2588190451;
398
- r = r - a * x, a = a * Math.sqrt(1 - Math.pow(x, 2));
386
+ if (v && v !== W.face)
387
+ switch (v) {
388
+ case W.eighthleft: {
389
+ const T = 0.2588190451;
390
+ s = s - a * T, a = a * Math.sqrt(1 - Math.pow(T, 2));
399
391
  break;
400
392
  }
401
- case G.thirdleft:
402
- r = r - a * (1 / 2), a = a * (Math.sqrt(3) / 2);
393
+ case W.thirdleft:
394
+ s = s - a * (1 / 2), a = a * (Math.sqrt(3) / 2);
403
395
  break;
404
- case G.quarterleft:
405
- r = r - a * (Math.SQRT2 / 2), a = a * (Math.SQRT2 / 2);
396
+ case W.quarterleft:
397
+ s = s - a * (Math.SQRT2 / 2), a = a * (Math.SQRT2 / 2);
406
398
  break;
407
- case G.halfleft:
408
- r = r - a, a = s.eye.getComponent(2);
399
+ case W.halfleft:
400
+ s = s - a, a = r.eye.getComponent(2);
409
401
  break;
410
- case G.eighthright: {
411
- const x = 0.2588190451;
412
- r = r + a * x, a = a * 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));
413
405
  break;
414
406
  }
415
- case G.thirdright:
416
- r = r + a * (1 / 2), a = a * (Math.sqrt(3) / 2);
407
+ case W.thirdright:
408
+ s = s + a * (1 / 2), a = a * (Math.sqrt(3) / 2);
417
409
  break;
418
- case G.quarterright:
419
- r = r + a * (Math.SQRT2 / 2), a = a * (Math.SQRT2 / 2);
410
+ case W.quarterright:
411
+ s = s + a * (Math.SQRT2 / 2), a = a * (Math.SQRT2 / 2);
420
412
  break;
421
- case G.halfright:
422
- r = r + a, a = s.eye.getComponent(2);
413
+ case W.halfright:
414
+ s = s + a, a = r.eye.getComponent(2);
423
415
  break;
424
416
  }
425
- return new A.Vector3(r, o, a);
426
- }, me = /* @__PURE__ */ new ot(), Ue = /* @__PURE__ */ new pe();
427
- let ge;
428
- function Ze(e) {
429
- const t = [];
430
- let s, r;
431
- function o(h) {
432
- s = new Array(h).fill(!1), r = new Array(h).fill(!1);
433
- }
434
- let a = 12345;
435
- function f() {
436
- return a = a * 1664525 + 1013904223 & 4294967295, (a >>> 0) / 4294967296;
437
- }
438
- function w(h, g) {
439
- const p = g;
440
- let b;
441
- if (p <= s.length) {
442
- const d = [];
443
- for (let c = 0; c < p; c++)
444
- s[c] || d.push(c);
445
- b = d[Math.floor(f() * d.length)];
446
- } else
447
- b = Math.floor(f() * p);
448
- let i;
449
- if (p <= r.length) {
450
- const d = [];
451
- for (let c = 0; c < p; c++)
452
- r[c] || d.push(c);
453
- i = d[Math.floor(f() * d.length)];
454
- } else
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];
458
- }
459
- o(1), t.push([f(), f()]), s[0] = !0, r[0] = !0;
460
- let x = 1;
461
- for (; x < e; ) {
462
- const h = x * 2;
463
- o(h);
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);
466
- i < s.length && (s[i] = !0), l < r.length && (r[l] = !0);
467
- }
468
- for (let g = 0; g < x; g++) {
469
- const p = w(g, h);
470
- t.push(p);
471
- }
472
- x = h;
473
- }
474
- return t.slice(0, e);
475
- }
476
- const Le = /* @__PURE__ */ Ze(64);
477
- class gs extends st {
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 {
478
421
  static get type() {
479
- return "PMJTAANode";
422
+ return "TRAANode";
480
423
  }
481
- constructor(t, s, r, o) {
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;
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;
483
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
+ */
484
440
  getTextureNode() {
485
441
  return this._textureNode;
486
442
  }
487
- setSize(t, s) {
488
- 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);
489
451
  }
490
452
  /**
491
- * 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.
492
458
  */
493
- setViewOffset(t, s) {
459
+ setViewOffset(t, r) {
494
460
  this.camera.updateProjectionMatrix(), this._originalProjectionMatrix.copy(this.camera.projectionMatrix), this._velocityNode.setProjectionMatrix(this._originalProjectionMatrix);
495
- const r = {
461
+ const s = {
496
462
  fullWidth: t,
497
- fullHeight: s,
463
+ fullHeight: r,
498
464
  offsetX: 0,
499
465
  offsetY: 0,
500
466
  width: t,
501
- height: s
502
- }, o = this._sequence[this._jitterIndex];
467
+ height: r
468
+ }, o = Fe[this._jitterIndex];
503
469
  this.camera.setViewOffset(
504
- r.fullWidth,
505
- r.fullHeight,
506
- r.offsetX + (o[0] - 0.5) * this.jitterIntensity,
507
- r.offsetY + (o[1] - 0.5) * this.jitterIntensity,
508
- r.width,
509
- 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
510
476
  );
511
477
  }
512
- clearViewOffset() {
513
- this.camera.clearViewOffset(), this._velocityNode.setProjectionMatrix(null), this._jitterIndex++, this._jitterIndex = this._jitterIndex % this._sampleCount;
514
- }
515
478
  /**
516
- * Sets the number of samples in the jitter sequence.
517
- * Must be a power of 2 between 2 and 256.
518
- *
519
- * @param {number} count - The number of samples (power of 2).
479
+ * Clears the view offset from the scene's camera.
520
480
  */
521
- setSampleCount(t) {
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);
481
+ clearViewOffset() {
482
+ this.camera.clearViewOffset(), this._velocityNode.setProjectionMatrix(null), this._jitterIndex++, this._jitterIndex = this._jitterIndex % (Fe.length - 1);
523
483
  }
524
484
  /**
525
- * Returns the current sample count.
526
- * @returns {number}
485
+ * This method is used to render the effect once per frame.
486
+ *
487
+ * @param {NodeFrame} frame - The current node frame.
527
488
  */
528
- get sampleCount() {
529
- return this._sampleCount;
530
- }
531
- set sampleCount(t) {
532
- this.setSampleCount(t);
533
- }
534
489
  updateBefore(t) {
535
- const { renderer: s } = t, r = this.camera.matrixWorld;
536
- let o = !1;
537
- if (this.useProgressiveAccumulation) {
538
- const g = r.elements, p = this._prevCameraMatrix.elements;
539
- for (let i = 0; i < 16; i++)
540
- if (Math.abs(g[i] - p[i]) > 1e-6) {
541
- o = !0;
542
- break;
543
- }
544
- o && (this._accumulatedFrames = 0), this._accumulatedFrames++;
545
- const b = Math.min(this._accumulatedFrames, this.maxAccumulationFrames);
546
- this._progressiveWeight.value = o ? 0 : 1 / b, this._prevCameraMatrix.copy(r);
547
- } else
548
- this._progressiveWeight.value = 0, this._accumulatedFrames = 0;
490
+ const { renderer: r } = t;
549
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);
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);
555
- if (this._historyRenderTarget.height === h.height && this._historyRenderTarget.width === h.width) {
556
- const g = this.depthNode.value;
557
- s.copyTextureToTexture(g, 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;
558
500
  }
559
- Ae.restoreRendererState(s, ge);
501
+ Me.restoreRendererState(r, fe);
560
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
+ */
561
509
  setup(t) {
562
- const s = t.context.renderPipeline;
563
- s && (this._needsPostProcessingSync = !0, s.context.onBeforeRenderPipeline = () => {
564
- const i = t.renderer.getDrawingBufferSize(Ue);
565
- this.setViewOffset(i.width, i.height);
566
- }, 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 = () => {
567
515
  this.clearViewOffset();
568
- }), t.renderer.reversedDepthBuffer === !0 && (this._historyRenderTarget.depthTexture.type = it), t.context.velocity !== void 0 ? this._velocityNode = t.context.velocity : this._velocityNode = fe;
569
- const r = (i) => {
570
- const { x: l, y } = this._cameraNearFar, d = bt(i, l, y);
571
- return Ve(d, l, y);
572
- }, o = xt({
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({
573
521
  closestDepth: "float",
574
522
  closestPositionTexel: "vec2",
575
523
  farthestDepth: "float"
576
- }), a = te(([i]) => {
577
- 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();
578
526
  for (let c = -1; c <= 1; ++c)
579
527
  for (let n = -1; n <= 1; ++n) {
580
- const S = i.add(de(c, n)).toVar();
581
- let m = this.depthNode.load(S).r;
582
- t.renderer.reversedDepthBuffer && (m = m.oneMinus()), t.renderer.logarithmicDepthBuffer && (m = r(m)), m = m.toVar(), Pe(m.lessThan(l), () => {
583
- l.assign(m), y.assign(S);
584
- }), Pe(m.greaterThan(d), () => {
585
- d.assign(m);
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);
586
534
  });
587
535
  }
588
- return o(l, y, d);
589
- }), f = (i) => {
590
- let l = this._previousDepthNode.sample(i).r;
591
- t.renderer.logarithmicDepthBuffer && (l = r(l));
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);
596
- return B.greaterThan(1).select(
597
- $(c, i.a).add(S.div(B)),
598
- 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
599
547
  );
600
548
  }).setLayout({
601
549
  name: "clipAABB",
@@ -606,7 +554,7 @@ class gs extends st {
606
554
  { name: "minColor", type: "vec4" },
607
555
  { name: "maxColor", type: "vec4" }
608
556
  ]
609
- }), x = te(([i, l, y, d]) => {
557
+ }), T = ee(([l, i, f, d]) => {
610
558
  const c = [
611
559
  [-1, -1],
612
560
  [-1, 1],
@@ -616,15 +564,15 @@ class gs extends st {
616
564
  [0, -1],
617
565
  [0, 1],
618
566
  [-1, 0]
619
- ], n = l.toVar(), S = l.pow2().toVar();
620
- for (const [U, q] of c) {
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());
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());
623
571
  }
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);
626
- }), h = te(([i, l]) => {
627
- 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());
628
576
  return c.x.mul(c.y).oneMinus().div(0.75);
629
577
  }).setLayout({
630
578
  name: "subpixelCorrection",
@@ -633,367 +581,370 @@ class gs extends st {
633
581
  { name: "velocityUV", type: "vec2" },
634
582
  { name: "textureSize", type: "ivec2" }
635
583
  ]
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();
641
- this.useSubpixelCorrection && T.addAssign(h(m, l).mul(0.5)), T.assign(q.select(T.add(ce.mul(0.6)).saturate(), 1));
642
- const C = this._progressiveWeight, N = C.greaterThan(0).and(q);
643
- T.assign(N.select(C, T));
644
- const O = _e(0.25, 1.25, ce.oneMinus().pow2()), Z = N.select(
645
- L,
646
- x(y, ae, L, O)
647
- );
648
- return N.select(
649
- _e(Z, ae, T),
650
- g(ae, Z, T)
651
- );
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);
652
592
  });
653
- return this._resolveMaterial.fragmentNode = b(), this._textureNode;
593
+ return this._resolveMaterial.colorNode = N(), this._textureNode;
654
594
  }
595
+ /**
596
+ * Frees internal resources. This method should be called
597
+ * when the effect is no longer required.
598
+ */
655
599
  dispose() {
656
600
  this._historyRenderTarget.dispose(), this._resolveRenderTarget.dispose(), this._resolveMaterial.dispose();
657
601
  }
658
602
  }
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;
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;
664
617
  return () => {
665
- t.setPixelRatio(window.devicePixelRatio), e && r && (r.style.imageRendering = "auto");
618
+ t.setPixelRatio(window.devicePixelRatio), e && s && (s.style.imageRendering = "auto");
666
619
  };
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");
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");
670
623
  },
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");
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");
673
626
  }
674
627
  }), null;
675
628
  }
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({
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({
678
631
  credentials: {
679
632
  region: o.region,
680
633
  authorizationToken: o.token,
681
634
  subscriptionKey: o.subscriptionKey
682
635
  }
683
636
  }) : null, [o]);
684
- return V(() => {
637
+ return M(() => {
685
638
  if (c) {
686
639
  const n = c.speechSynthesis.getVoices();
687
- n && Array.isArray(n) && n.length ? (je(n), l(!0)) : c.speechSynthesis.onvoiceschanged = () => {
688
- je(c.speechSynthesis.getVoices()), l(!0);
640
+ n && Array.isArray(n) && n.length ? (ze(n), i(!0)) : c.speechSynthesis.onvoiceschanged = () => {
641
+ ze(c.speechSynthesis.getVoices()), i(!0);
689
642
  };
690
643
  }
691
- }, [c]), V(() => {
692
- i && (b ? !!r : !!s) && e && d(!0);
693
- }, [i, s, r, e, b]), V(() => {
694
- if (f) {
695
- const n = new Ft(f);
696
- cs(n);
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);
697
650
  }
698
- }, [f]), V(() => {
699
- var n, S;
700
- a && y ? (a.onstart = () => {
701
- console.log("Start"), Be(J.speaking);
651
+ }, [k]), M(() => {
652
+ var n, g;
653
+ a && f ? (a.onstart = () => {
654
+ console.log("Start"), Re(q.speaking);
702
655
  }, a.onend = () => {
703
- console.log("End"), Be(J.idle);
656
+ console.log("End"), Re(q.idle);
704
657
  }, 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(() => {
709
- s && (s.visemeIntensity = h);
710
- }, [h]), V(() => {
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);
715
- if (!isNaN(S)) {
716
- const m = Ee.get(S);
717
- m && s.PlayVisemeAsync(m, n.elapsedTime / 1e4);
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);
718
671
  }
719
672
  });
720
673
  else
721
- for (let n = g + 1; n < w.length; n++) {
722
- const S = w[n], m = parseInt(S.name);
723
- if (!isNaN(m)) {
724
- const _ = Ee.get(m);
725
- _ && s.PlayVisemeAsync(_, 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);
726
679
  }
727
680
  }
728
- ls(w.length - 1);
681
+ cr(v.length - 1);
729
682
  }
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);
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);
735
688
  });
736
689
  else
737
- for (let n = p + 1; n < x.length; n++) {
738
- const S = x[n];
739
- r.PlayBlendShapeAsync(S);
690
+ for (let n = _ + 1; n < T.length; n++) {
691
+ const g = T[n];
692
+ s.PlayBlendShapeAsync(g);
740
693
  }
741
- hs(x.length - 1);
694
+ lr(T.length - 1);
742
695
  }
743
- }, [t, x, r, b]), V(() => {
744
- t !== J.speaking && (Je(), Ke());
696
+ }, [t, T, s, N]), M(() => {
697
+ t !== q.speaking && (Ge(), We());
745
698
  }, [t]), null;
746
- }, ys = ({ points: e, color: t = "red" }) => {
747
- const s = ye(() => {
748
- const r = new A.BufferGeometry().setFromPoints(e), o = new A.LineBasicMaterial({ color: t, toneMapped: !1 });
749
- 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);
750
703
  }, [e, t]);
751
- return /* @__PURE__ */ v.createElement("primitive", { object: s });
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) => {
754
- 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();
755
711
  };
756
- V(() => {
757
- Lt(c.current);
758
- }, [c.current]), V(() => {
759
- var u, M, U, q;
760
- if (f)
761
- 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);
762
718
  else {
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 });
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 });
765
721
  }
766
- }, [f]), V(() => {
722
+ }, [k]), M(() => {
767
723
  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(() => {
769
- if (h)
770
- if (h.type === "FALLBACK")
771
- p(
724
+ }, [o, a]), M(() => {
725
+ if (u)
726
+ if (u.type === "FALLBACK")
727
+ _(
772
728
  "medium"
773
729
  /* medium */
774
730
  );
775
731
  else
776
- switch (h.tier) {
732
+ switch (u.tier) {
777
733
  case 0:
778
734
  case 1:
779
- p(
735
+ _(
780
736
  "low"
781
737
  /* low */
782
738
  );
783
739
  break;
784
740
  case 2:
785
- p(
741
+ _(
786
742
  "medium"
787
743
  /* medium */
788
744
  );
789
745
  break;
790
746
  case 3:
791
- p(
747
+ _(
792
748
  "high"
793
749
  /* high */
794
750
  );
795
751
  break;
796
752
  default:
797
- p(
753
+ _(
798
754
  "low"
799
755
  /* low */
800
756
  );
801
757
  break;
802
758
  }
803
- }, [h]), V(() => {
804
- switch (g && (m.current = g), g) {
759
+ }, [u]), M(() => {
760
+ switch (P && (h.current = P), P) {
805
761
  case "low":
806
762
  console.warn("Retorik React-Bodyengine-Three > GPU tier too low, no rendering available"), t(!1);
807
763
  break;
808
764
  case "medium":
809
- y([1, 1.5]), console.log(`Retorik React-Bodyengine-Three > GPU tier detected : ${g}`), t(!0);
765
+ f([0.8, 1]), console.log(`Retorik React-Bodyengine-Three > GPU tier detected : ${P}`), t(!0);
810
766
  break;
811
767
  case "high":
812
- y([1, 2]), console.log(`Retorik React-Bodyengine-Three > GPU tier detected : ${g}`), t(!0);
768
+ f([1, 2]), console.log(`Retorik React-Bodyengine-Three > GPU tier detected : ${P}`), t(!0);
813
769
  break;
814
770
  }
815
- }, [g]);
816
- const m = se(void 0), _ = $e(async (u) => {
817
- const M = new A.WebGPURenderer({
818
- 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,
819
775
  antialias: !1,
820
776
  alpha: !0,
821
777
  powerPreference: "high-performance"
822
778
  });
823
- return M.setClearColor(new A.Color("#000000"), 0), M.setPixelRatio(devicePixelRatio), M.shadowMap.type = A.PCFSoftShadowMap, await M.init(), M;
824
- }, []), B = ye(() => {
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);
827
- return [M, U];
779
+ return S.setClearColor(new w.Color("#000000"), 0), S.setPixelRatio(devicePixelRatio), S.shadowMap.type = w.PCFSoftShadowMap, await S.init(), S;
780
+ }, []), I = Se(() => {
781
+ if (v.length) {
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];
828
784
  } else if (o) {
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);
830
- return [u, M];
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];
831
787
  }
832
788
  return [];
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);
837
- return V(() => {
838
- s && (s.shadowMap.type = A.PCFSoftShadowMap, s.toneMapping = e, t !== "low" ? r.environmentIntensity = g : r.environmentIntensity = 1);
839
- }, [s, e]), V(() => {
840
- r.environmentIntensity = g;
841
- }, [g]), V(() => {
842
- if (!s || !r || !o || !t) return;
843
- r.background = null;
844
- const i = t === "high", l = At(r, o);
845
- l.setMRT(
846
- i ? Ne({ output: Re, diffuseColor: kt, normal: Pt(Ct), velocity: fe }) : Ne({ output: Re, velocity: fe })
789
+ }, [v, o]);
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 })
847
806
  );
848
- let y;
849
- if (i) {
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);
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;
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;
854
- } else {
855
- const c = Oe(
856
- l,
857
- l.getTextureNode("depth"),
858
- l.getTextureNode("velocity"),
859
- o
860
- );
861
- c.jitterIntensity = 0.25, y = c;
862
- }
863
- const d = new A.RenderPipeline(s);
864
- return d.outputNode = y, b.current = d, () => {
865
- 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;
866
817
  };
867
- }, [s, r, o, t]), V(() => {
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,
877
- timestamp: h.clock.oldTime,
878
- 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,
879
830
  gaze: o,
880
831
  headPose: a,
881
- characterState: s,
882
- lookAt: f ? w : void 0,
883
- targets: x
832
+ characterState: r,
833
+ lookAt: k ? v : void 0,
834
+ targets: T
884
835
  };
885
- e.update(p);
886
- }), V(() => {
836
+ e.update(_);
837
+ }), M(() => {
887
838
  if (t)
888
- switch (s) {
889
- case J.idle:
890
- case J.waiting:
891
- ue(!1);
839
+ switch (r) {
840
+ case q.idle:
841
+ case q.waiting:
842
+ pe(!1);
892
843
  break;
893
- case J.listening:
894
- case J.speaking:
895
- ue(!0);
844
+ case q.listening:
845
+ case q.speaking:
846
+ pe(!0);
896
847
  break;
897
848
  }
898
849
  else
899
- ue(!1);
900
- }, [s, t]), V(() => {
901
- jt(e);
850
+ pe(!1);
851
+ }, [r, t]), M(() => {
852
+ Ft(e);
902
853
  }, [e]), 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;
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;
906
857
  switch (t) {
907
- case ee.cc3:
908
- C = new ht(), R(le.cc3);
858
+ case X.cc3:
859
+ A = new ot(), B(le.cc3);
909
860
  break;
910
- case ee.avatarsdk:
911
- C = new lt(), R(le.avatarsdk);
861
+ case X.avatarsdk:
862
+ A = new at(), B(le.avatarsdk);
912
863
  break;
913
- case ee.avaturn:
914
- C = new ct(), R(le.avaturn);
864
+ case X.avaturn:
865
+ A = new nt(), B(le.avaturn);
915
866
  break;
916
867
  }
917
- const N = await C.loadAsync(T).catch((O) => console.warn("Error loading character : ", O));
918
- if (N) {
919
- let O = null;
920
- const Z = {
921
- mesh: N,
922
- onAnimationsLoaded: ve,
923
- animationsUrl: s,
924
- 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",
925
876
  type: t,
926
- debug: g,
927
- enableBmlManager: !!p,
928
- animationWeights: b,
877
+ debug: P,
878
+ enableBmlManager: !!_,
879
+ animationWeights: N,
929
880
  useBlendshapeManager: n,
930
- license: i
881
+ license: l
931
882
  };
932
883
  switch (t) {
933
- case ee.cc3:
934
- O = await he.fromCharacterCreator(Z);
884
+ case X.cc3:
885
+ G = await ue.fromCharacterCreator(ne);
935
886
  break;
936
- case ee.avatarsdk:
937
- O = await he.fromAvatarSDK(Z);
887
+ case X.avatarsdk:
888
+ G = await ue.fromAvatarSDK(ne);
938
889
  break;
939
- case ee.avaturn:
940
- O = await he.fromAvaturn(Z);
890
+ case X.avaturn:
891
+ G = await ue.fromAvaturn(ne);
941
892
  break;
942
893
  }
943
- O && U(O);
894
+ G && H(G);
944
895
  }
945
- }, ve = () => {
946
- Fe(!0);
896
+ }, he = () => {
897
+ Ne(!0);
947
898
  };
948
- V(() => {
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(() => {
951
- f == null || f();
952
- }, 1e3)) : ce());
953
- }, [M, S, L]), V(() => {
954
- Gt(c || []);
955
- }, [c]), V(() => {
956
- Fe(!1), B !== void 0 && (B ? xe(e) : f == null || f());
957
- }, [e, B]), V(() => {
958
- if (L && _ && m)
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(() => {
905
+ Wt(c || []);
906
+ }, [c]), M(() => {
907
+ Ne(!1), I !== void 0 && (I ? Y(e) : k == null || k());
908
+ }, [e, I]), M(() => {
909
+ if ($ && p && h)
959
910
  if (a) {
960
- const T = ms(a, _, m);
961
- ze(T), De(a.lookAt ? m[a.lookAt] : m.lowerbelly), qt(!!a.movable);
911
+ const C = ur(a, p, h);
912
+ Ve(C), Ie(a.lookAt ? h[a.lookAt] : h.lowerbelly), Gt(!!a.movable);
962
913
  } else {
963
- const T = m.mouth.clone();
964
- T.setComponent(2, _.farther), ze(T), De(m.lowerbelly);
914
+ const C = h.mouth.clone();
915
+ C.setComponent(2, p.farther), Ve(C), Ie(h.lowerbelly);
965
916
  }
966
- }, [L, a, _, m]), V(() => {
967
- o && (o.credentials && is(o.credentials), o.voice && ds(o.voice));
968
- }, [o]), V(() => {
969
- us(n);
917
+ }, [$, a, p, h]), M(() => {
918
+ o && (o.credentials && or(o.credentials), o.voice && hr(o.voice));
919
+ }, [o]), M(() => {
920
+ dr(n);
970
921
  }, [n]);
971
- const ce = () => {
972
- if (M && q) {
922
+ const de = () => {
923
+ if (S && j) {
973
924
  try {
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);
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);
977
928
  Ut({
978
- x: Z,
979
- y: E,
980
- z: Qe
929
+ x: ne,
930
+ y: F,
931
+ z: qe
981
932
  });
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),
990
- hips: O,
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),
995
- feet: new A.Vector3(H, N.y, W)
996
- }, K = (C.y - (N.y + E / 7 * 2)) / 2 / Math.tan(25 * (Math.PI / 180)), Xe = {
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 = {
997
948
  veryclose: K / 4,
998
949
  closer: K / 3,
999
950
  close: K / 2.5,
@@ -1004,76 +955,75 @@ const fs = () => {
1004
955
  farther: K * 3,
1005
956
  veryfar: K * 4
1006
957
  };
1007
- Ht(Ye), Wt(Xe);
1008
- } catch (T) {
1009
- console.warn(T);
958
+ Ot(Ke), Ht(Ze);
959
+ } catch (C) {
960
+ console.warn(C);
1010
961
  }
1011
- ae(!0);
962
+ ce(!0);
1012
963
  }
1013
964
  };
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 = {
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 = {
1016
967
  emotions: [],
1017
- currentTopEmotion: Se.Neutral,
968
+ currentTopEmotion: we.Neutral,
1018
969
  useTopEmotionOnly: !0,
1019
970
  autoDecay: !1
1020
- }, ie = ne()(() => ws), Qs = (e) => {
971
+ }, ie = se()(() => br), Qr = (e) => {
1021
972
  if (ie.setState({ emotions: e || [] }), e != null && e.length) {
1022
- 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);
1023
974
  ie.setState({ currentTopEmotion: t.emotion });
1024
975
  } else
1025
- ie.setState({ currentTopEmotion: Se.Neutral });
1026
- }, Ys = (e) => {
976
+ ie.setState({ currentTopEmotion: we.Neutral });
977
+ }, $r = (e) => {
1027
978
  ie.setState({ useTopEmotionOnly: e });
1028
- }, Xs = (e) => {
979
+ }, Yr = (e) => {
1029
980
  ie.setState({ autoDecay: e });
1030
- }, $s = (e) => {
1031
- const t = k.getState().FACSManager;
981
+ }, Jr = (e) => {
982
+ const t = b.getState().FACSManager;
1032
983
  t == null || t.playFacialAnimation({ ...e });
1033
984
  };
1034
985
  export {
1035
- Zs as Character,
1036
- nr as CharacterState,
1037
- ar as CreationTool,
1038
- F as Distances,
1039
- sr as Object3D,
1040
- I as Positions,
1041
- G as Rotations,
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,
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,
1005
+ qt as lookAtAndKeep,
1006
+ Ur as playAnimationByName,
1007
+ Jr as playFacialAnimation,
1008
+ jr as presets,
1059
1009
  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,
1070
- ue as setLookAtCamera,
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,
1078
- k as useCharacterStore
1010
+ Yr as setAutoDecay,
1011
+ Fr as setAutoPlay,
1012
+ Or as setBlendshapes,
1013
+ Ve as setCameraPosition,
1014
+ Re as setCharacterState,
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
1079
1029
  };