@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/components/AdaptiveDpr.d.ts +3 -0
- package/dist/contexts/headStore.d.ts +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +624 -656
- package/dist/stats.html +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { CharacterState as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
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
|
|
15
|
-
const
|
|
16
|
-
if (!Object.is(
|
|
17
|
-
const
|
|
18
|
-
t =
|
|
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:
|
|
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
|
-
},
|
|
23
|
-
function
|
|
24
|
-
const
|
|
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
|
-
|
|
27
|
-
|
|
27
|
+
y.useCallback(() => t(e.getState()), [e, t]),
|
|
28
|
+
y.useCallback(() => t(e.getInitialState()), [e, t])
|
|
28
29
|
);
|
|
29
|
-
return
|
|
30
|
+
return y.useDebugValue(r), r;
|
|
30
31
|
}
|
|
31
|
-
const
|
|
32
|
-
const t =
|
|
33
|
-
return Object.assign(
|
|
34
|
-
},
|
|
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:
|
|
51
|
-
})),
|
|
52
|
-
|
|
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
|
-
} }),
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
},
|
|
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
|
|
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
|
-
})),
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
|
|
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
|
-
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
},
|
|
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
|
-
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
|
|
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 =
|
|
105
|
+
const t = b.getState().globalManager;
|
|
113
106
|
if (e)
|
|
114
107
|
t == null || t.lookAtAndKeep(e);
|
|
115
108
|
else {
|
|
116
|
-
const
|
|
117
|
-
t == null || t.lookAtAndKeep(
|
|
109
|
+
const r = D.getState().cameraRef;
|
|
110
|
+
t == null || t.lookAtAndKeep(r);
|
|
118
111
|
}
|
|
119
|
-
},
|
|
112
|
+
}, Kt = () => {
|
|
120
113
|
var e;
|
|
121
|
-
(e =
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
}, re =
|
|
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
|
-
})),
|
|
122
|
+
})), Zt = (e) => {
|
|
130
123
|
re.setState({ animationsNames: e });
|
|
131
|
-
},
|
|
124
|
+
}, Qt = (e) => {
|
|
132
125
|
re.setState({ animations: e });
|
|
133
|
-
},
|
|
126
|
+
}, Er = () => re.getState().animations, Fr = (e) => {
|
|
134
127
|
re.setState({ autoPlay: e });
|
|
135
|
-
},
|
|
128
|
+
}, Ur = (e) => {
|
|
136
129
|
if (re.setState({ autoPlay: !1 }), re.getState().animationsNames.includes(e)) {
|
|
137
|
-
const
|
|
138
|
-
|
|
130
|
+
const r = b.getState().animationManager;
|
|
131
|
+
r == null || r.playAnimation(e);
|
|
139
132
|
}
|
|
140
133
|
};
|
|
141
|
-
var
|
|
142
|
-
const
|
|
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
|
-
]),
|
|
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
|
-
]),
|
|
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
|
-
]),
|
|
256
|
-
position:
|
|
257
|
-
distance:
|
|
258
|
-
lookAt:
|
|
248
|
+
]), Jt = {
|
|
249
|
+
position: R.mouth,
|
|
250
|
+
distance: V.farther,
|
|
251
|
+
lookAt: R.lowerbelly
|
|
259
252
|
}, Xt = {
|
|
260
|
-
position:
|
|
261
|
-
distance:
|
|
262
|
-
lookAt:
|
|
263
|
-
},
|
|
264
|
-
position:
|
|
265
|
-
distance:
|
|
266
|
-
lookAt:
|
|
267
|
-
},
|
|
268
|
-
position:
|
|
269
|
-
distance:
|
|
270
|
-
lookAt:
|
|
271
|
-
},
|
|
272
|
-
position:
|
|
273
|
-
distance:
|
|
274
|
-
lookAt:
|
|
275
|
-
},
|
|
276
|
-
position:
|
|
277
|
-
distance:
|
|
278
|
-
lookAt:
|
|
279
|
-
},
|
|
280
|
-
position:
|
|
281
|
-
distance:
|
|
282
|
-
lookAt:
|
|
283
|
-
},
|
|
284
|
-
position:
|
|
285
|
-
distance:
|
|
286
|
-
lookAt:
|
|
287
|
-
},
|
|
288
|
-
default:
|
|
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:
|
|
291
|
-
shoulders:
|
|
292
|
-
chest:
|
|
293
|
-
belly:
|
|
294
|
-
knees:
|
|
295
|
-
feet:
|
|
296
|
-
},
|
|
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
|
-
})),
|
|
310
|
-
|
|
311
|
-
},
|
|
302
|
+
})), or = (e) => {
|
|
303
|
+
x.setState({ credentials: e });
|
|
304
|
+
}, ir = (e) => {
|
|
312
305
|
if (e) {
|
|
313
|
-
const t =
|
|
306
|
+
const t = x.getState().voice;
|
|
314
307
|
t && (e.voice = t);
|
|
315
308
|
}
|
|
316
|
-
|
|
317
|
-
},
|
|
318
|
-
|
|
319
|
-
},
|
|
320
|
-
|
|
321
|
-
},
|
|
322
|
-
|
|
323
|
-
},
|
|
324
|
-
|
|
325
|
-
},
|
|
326
|
-
const
|
|
327
|
-
if (
|
|
328
|
-
const
|
|
329
|
-
|
|
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
|
-
},
|
|
332
|
-
|
|
333
|
-
},
|
|
334
|
-
|
|
335
|
-
},
|
|
324
|
+
}, cr = (e) => {
|
|
325
|
+
x.setState({ currentVisemeIndex: e });
|
|
326
|
+
}, lr = (e) => {
|
|
327
|
+
x.setState({ currentBlendshapeIndex: e });
|
|
328
|
+
}, Ge = () => {
|
|
336
329
|
var e;
|
|
337
|
-
|
|
330
|
+
x.setState({
|
|
338
331
|
visemes: [],
|
|
339
332
|
currentVisemeIndex: 0
|
|
340
|
-
}), (e =
|
|
341
|
-
},
|
|
333
|
+
}), (e = b.getState().lipSyncManager) == null || e.stop();
|
|
334
|
+
}, We = () => {
|
|
342
335
|
var e;
|
|
343
|
-
|
|
336
|
+
x.setState({
|
|
344
337
|
blendshapes: [],
|
|
345
338
|
currentBlendshapeIndex: 0
|
|
346
|
-
}), (e =
|
|
347
|
-
},
|
|
348
|
-
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
},
|
|
352
|
-
|
|
353
|
-
},
|
|
354
|
-
|
|
355
|
-
},
|
|
356
|
-
e !==
|
|
357
|
-
},
|
|
358
|
-
let
|
|
359
|
-
const o =
|
|
360
|
-
let
|
|
361
|
-
const
|
|
362
|
-
switch (
|
|
363
|
-
case
|
|
364
|
-
|
|
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
|
|
367
|
-
|
|
359
|
+
case V.closer:
|
|
360
|
+
a = t.closer;
|
|
368
361
|
break;
|
|
369
|
-
case
|
|
370
|
-
|
|
362
|
+
case V.close:
|
|
363
|
+
a = t.close;
|
|
371
364
|
break;
|
|
372
|
-
case
|
|
373
|
-
|
|
365
|
+
case V.midclose:
|
|
366
|
+
a = t.midclose;
|
|
374
367
|
break;
|
|
375
|
-
case
|
|
376
|
-
|
|
368
|
+
case V.medium:
|
|
369
|
+
a = t.medium;
|
|
377
370
|
break;
|
|
378
|
-
case
|
|
379
|
-
|
|
371
|
+
case V.midfar:
|
|
372
|
+
a = t.midfar;
|
|
380
373
|
break;
|
|
381
|
-
case
|
|
382
|
-
|
|
374
|
+
case V.far:
|
|
375
|
+
a = t.far;
|
|
383
376
|
break;
|
|
384
|
-
case
|
|
377
|
+
case V.farther:
|
|
385
378
|
case void 0:
|
|
386
379
|
default:
|
|
387
|
-
|
|
380
|
+
a = t.farther;
|
|
388
381
|
break;
|
|
389
|
-
case
|
|
390
|
-
|
|
382
|
+
case V.veryfar:
|
|
383
|
+
a = t.veryfar;
|
|
391
384
|
break;
|
|
392
385
|
}
|
|
393
|
-
if (v && v !==
|
|
386
|
+
if (v && v !== W.face)
|
|
394
387
|
switch (v) {
|
|
395
|
-
case
|
|
396
|
-
const
|
|
397
|
-
|
|
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
|
|
401
|
-
|
|
393
|
+
case W.thirdleft:
|
|
394
|
+
s = s - a * (1 / 2), a = a * (Math.sqrt(3) / 2);
|
|
402
395
|
break;
|
|
403
|
-
case
|
|
404
|
-
|
|
396
|
+
case W.quarterleft:
|
|
397
|
+
s = s - a * (Math.SQRT2 / 2), a = a * (Math.SQRT2 / 2);
|
|
405
398
|
break;
|
|
406
|
-
case
|
|
407
|
-
|
|
399
|
+
case W.halfleft:
|
|
400
|
+
s = s - a, a = r.eye.getComponent(2);
|
|
408
401
|
break;
|
|
409
|
-
case
|
|
410
|
-
const
|
|
411
|
-
|
|
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
|
|
415
|
-
|
|
407
|
+
case W.thirdright:
|
|
408
|
+
s = s + a * (1 / 2), a = a * (Math.sqrt(3) / 2);
|
|
416
409
|
break;
|
|
417
|
-
case
|
|
418
|
-
|
|
410
|
+
case W.quarterright:
|
|
411
|
+
s = s + a * (Math.SQRT2 / 2), a = a * (Math.SQRT2 / 2);
|
|
419
412
|
break;
|
|
420
|
-
case
|
|
421
|
-
|
|
413
|
+
case W.halfright:
|
|
414
|
+
s = s + a, a = r.eye.getComponent(2);
|
|
422
415
|
break;
|
|
423
416
|
}
|
|
424
|
-
return new
|
|
425
|
-
},
|
|
426
|
-
let
|
|
427
|
-
|
|
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 "
|
|
422
|
+
return "TRAANode";
|
|
479
423
|
}
|
|
480
|
-
|
|
481
|
-
|
|
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
|
-
|
|
487
|
-
|
|
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
|
-
*
|
|
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,
|
|
459
|
+
setViewOffset(t, r) {
|
|
493
460
|
this.camera.updateProjectionMatrix(), this._originalProjectionMatrix.copy(this.camera.projectionMatrix), this._velocityNode.setProjectionMatrix(this._originalProjectionMatrix);
|
|
494
|
-
const
|
|
461
|
+
const s = {
|
|
495
462
|
fullWidth: t,
|
|
496
|
-
fullHeight:
|
|
463
|
+
fullHeight: r,
|
|
497
464
|
offsetX: 0,
|
|
498
465
|
offsetY: 0,
|
|
499
466
|
width: t,
|
|
500
|
-
height:
|
|
501
|
-
}, o =
|
|
467
|
+
height: r
|
|
468
|
+
}, o = Fe[this._jitterIndex];
|
|
502
469
|
this.camera.setViewOffset(
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
521
|
-
|
|
481
|
+
clearViewOffset() {
|
|
482
|
+
this.camera.clearViewOffset(), this._velocityNode.setProjectionMatrix(null), this._jitterIndex++, this._jitterIndex = this._jitterIndex % (Fe.length - 1);
|
|
522
483
|
}
|
|
523
484
|
/**
|
|
524
|
-
*
|
|
525
|
-
*
|
|
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:
|
|
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
|
|
550
|
-
this._needsPostProcessingSync === !0 && (this.setViewOffset(
|
|
551
|
-
const
|
|
552
|
-
this.setSize(
|
|
553
|
-
const
|
|
554
|
-
if (this._historyRenderTarget.height ===
|
|
555
|
-
const
|
|
556
|
-
|
|
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
|
-
|
|
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
|
|
562
|
-
|
|
563
|
-
const
|
|
564
|
-
this.setViewOffset(
|
|
565
|
-
},
|
|
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 =
|
|
568
|
-
const
|
|
569
|
-
const { x:
|
|
570
|
-
return
|
|
571
|
-
}, o =
|
|
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
|
-
}),
|
|
576
|
-
const
|
|
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
|
|
579
|
-
const
|
|
580
|
-
let
|
|
581
|
-
t.renderer.reversedDepthBuffer && (
|
|
582
|
-
|
|
583
|
-
}),
|
|
584
|
-
d.assign(
|
|
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(
|
|
588
|
-
}),
|
|
589
|
-
let
|
|
590
|
-
t.renderer.logarithmicDepthBuffer && (
|
|
591
|
-
const
|
|
592
|
-
return this.camera.isOrthographicCamera ? bt(c, this._cameraNearFar.x, this._cameraNearFar.y) :
|
|
593
|
-
}, v =
|
|
594
|
-
const c = d.rgb.add(
|
|
595
|
-
return
|
|
596
|
-
|
|
597
|
-
|
|
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
|
-
}),
|
|
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
|
-
],
|
|
619
|
-
for (const [
|
|
620
|
-
const
|
|
621
|
-
|
|
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
|
|
624
|
-
return v(
|
|
625
|
-
}),
|
|
626
|
-
const d =
|
|
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
|
-
}),
|
|
636
|
-
const d =
|
|
637
|
-
return
|
|
638
|
-
}),
|
|
639
|
-
const
|
|
640
|
-
this.useSubpixelCorrection &&
|
|
641
|
-
const
|
|
642
|
-
|
|
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.
|
|
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
|
-
|
|
659
|
-
|
|
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
|
|
637
|
+
return M(() => {
|
|
667
638
|
if (c) {
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
|
|
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]),
|
|
674
|
-
|
|
675
|
-
}, [
|
|
676
|
-
if (
|
|
677
|
-
const
|
|
678
|
-
|
|
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
|
-
}, [
|
|
681
|
-
var
|
|
682
|
-
|
|
683
|
-
console.log("Start"), Re(
|
|
684
|
-
},
|
|
685
|
-
console.log("End"), Re(
|
|
686
|
-
},
|
|
687
|
-
},
|
|
688
|
-
|
|
689
|
-
}, (
|
|
690
|
-
}, [
|
|
691
|
-
|
|
692
|
-
}, [
|
|
693
|
-
if (!
|
|
694
|
-
if (!
|
|
695
|
-
v.forEach((
|
|
696
|
-
const
|
|
697
|
-
if (!isNaN(
|
|
698
|
-
const
|
|
699
|
-
|
|
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
|
|
704
|
-
const
|
|
705
|
-
if (!isNaN(
|
|
706
|
-
const
|
|
707
|
-
|
|
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
|
-
|
|
681
|
+
cr(v.length - 1);
|
|
711
682
|
}
|
|
712
|
-
}, [t, v,
|
|
713
|
-
if (
|
|
714
|
-
if (!
|
|
715
|
-
|
|
716
|
-
|
|
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
|
|
720
|
-
const
|
|
721
|
-
|
|
690
|
+
for (let n = _ + 1; n < T.length; n++) {
|
|
691
|
+
const g = T[n];
|
|
692
|
+
s.PlayBlendShapeAsync(g);
|
|
722
693
|
}
|
|
723
|
-
|
|
694
|
+
lr(T.length - 1);
|
|
724
695
|
}
|
|
725
|
-
}, [t,
|
|
726
|
-
t !==
|
|
696
|
+
}, [t, T, s, N]), M(() => {
|
|
697
|
+
t !== q.speaking && (Ge(), We());
|
|
727
698
|
}, [t]), null;
|
|
728
|
-
},
|
|
729
|
-
const
|
|
730
|
-
const
|
|
731
|
-
return new
|
|
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__ */
|
|
734
|
-
},
|
|
735
|
-
const o =
|
|
736
|
-
|
|
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
|
-
|
|
739
|
-
|
|
740
|
-
}, [c.current]),
|
|
741
|
-
var
|
|
742
|
-
if (
|
|
743
|
-
|
|
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
|
|
746
|
-
|
|
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
|
-
}, [
|
|
749
|
-
|
|
750
|
-
}, [o,
|
|
751
|
-
if (
|
|
752
|
-
if (
|
|
753
|
-
|
|
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 (
|
|
732
|
+
switch (u.tier) {
|
|
759
733
|
case 0:
|
|
760
734
|
case 1:
|
|
761
|
-
|
|
735
|
+
_(
|
|
762
736
|
"low"
|
|
763
737
|
/* low */
|
|
764
738
|
);
|
|
765
739
|
break;
|
|
766
740
|
case 2:
|
|
767
|
-
|
|
741
|
+
_(
|
|
768
742
|
"medium"
|
|
769
743
|
/* medium */
|
|
770
744
|
);
|
|
771
745
|
break;
|
|
772
746
|
case 3:
|
|
773
|
-
|
|
747
|
+
_(
|
|
774
748
|
"high"
|
|
775
749
|
/* high */
|
|
776
750
|
);
|
|
777
751
|
break;
|
|
778
752
|
default:
|
|
779
|
-
|
|
753
|
+
_(
|
|
780
754
|
"low"
|
|
781
755
|
/* low */
|
|
782
756
|
);
|
|
783
757
|
break;
|
|
784
758
|
}
|
|
785
|
-
}, [
|
|
786
|
-
switch (
|
|
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
|
-
|
|
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
|
-
|
|
768
|
+
f([1, 2]), console.log(`Retorik React-Bodyengine-Three > GPU tier detected : ${P}`), t(!0);
|
|
795
769
|
break;
|
|
796
770
|
}
|
|
797
|
-
}, [
|
|
798
|
-
const
|
|
799
|
-
const
|
|
800
|
-
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
|
|
806
|
-
}, []),
|
|
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
|
|
809
|
-
return [
|
|
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
|
|
812
|
-
return [
|
|
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
|
|
817
|
-
},
|
|
818
|
-
const { gl:
|
|
819
|
-
return
|
|
820
|
-
|
|
821
|
-
}, [
|
|
822
|
-
|
|
823
|
-
}, [
|
|
824
|
-
if (!
|
|
825
|
-
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
|
|
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
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
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
|
-
}, [
|
|
850
|
-
!
|
|
851
|
-
}, [
|
|
852
|
-
|
|
853
|
-
}, 1), /* @__PURE__ */
|
|
854
|
-
},
|
|
855
|
-
const
|
|
856
|
-
return
|
|
857
|
-
const
|
|
858
|
-
deltaTime:
|
|
859
|
-
timestamp:
|
|
860
|
-
AU:
|
|
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:
|
|
863
|
-
characterState:
|
|
864
|
-
lookAt:
|
|
865
|
-
targets:
|
|
831
|
+
headPose: a,
|
|
832
|
+
characterState: r,
|
|
833
|
+
lookAt: k ? v : void 0,
|
|
834
|
+
targets: T
|
|
866
835
|
};
|
|
867
|
-
e.update(
|
|
868
|
-
}),
|
|
836
|
+
e.update(_);
|
|
837
|
+
}), M(() => {
|
|
869
838
|
if (t)
|
|
870
|
-
switch (
|
|
871
|
-
case
|
|
872
|
-
case
|
|
873
|
-
|
|
839
|
+
switch (r) {
|
|
840
|
+
case q.idle:
|
|
841
|
+
case q.waiting:
|
|
842
|
+
pe(!1);
|
|
874
843
|
break;
|
|
875
|
-
case
|
|
876
|
-
case
|
|
877
|
-
|
|
844
|
+
case q.listening:
|
|
845
|
+
case q.speaking:
|
|
846
|
+
pe(!0);
|
|
878
847
|
break;
|
|
879
848
|
}
|
|
880
849
|
else
|
|
881
|
-
|
|
882
|
-
}, [
|
|
883
|
-
|
|
850
|
+
pe(!1);
|
|
851
|
+
}, [r, t]), M(() => {
|
|
852
|
+
Ft(e);
|
|
884
853
|
}, [e]), null;
|
|
885
|
-
},
|
|
886
|
-
const
|
|
887
|
-
let
|
|
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
|
|
890
|
-
|
|
858
|
+
case X.cc3:
|
|
859
|
+
A = new ot(), B(le.cc3);
|
|
891
860
|
break;
|
|
892
|
-
case
|
|
893
|
-
|
|
861
|
+
case X.avatarsdk:
|
|
862
|
+
A = new at(), B(le.avatarsdk);
|
|
894
863
|
break;
|
|
895
|
-
case
|
|
896
|
-
|
|
864
|
+
case X.avaturn:
|
|
865
|
+
A = new nt(), B(le.avaturn);
|
|
897
866
|
break;
|
|
898
867
|
}
|
|
899
|
-
const
|
|
900
|
-
if (
|
|
901
|
-
let
|
|
902
|
-
const
|
|
903
|
-
mesh:
|
|
904
|
-
onAnimationsLoaded:
|
|
905
|
-
animationsUrl:
|
|
906
|
-
gender:
|
|
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:
|
|
909
|
-
enableBmlManager: !!
|
|
910
|
-
animationWeights:
|
|
911
|
-
useBlendshapeManager:
|
|
912
|
-
license:
|
|
877
|
+
debug: P,
|
|
878
|
+
enableBmlManager: !!_,
|
|
879
|
+
animationWeights: N,
|
|
880
|
+
useBlendshapeManager: n,
|
|
881
|
+
license: l
|
|
913
882
|
};
|
|
914
883
|
switch (t) {
|
|
915
|
-
case
|
|
916
|
-
|
|
884
|
+
case X.cc3:
|
|
885
|
+
G = await ue.fromCharacterCreator(ne);
|
|
917
886
|
break;
|
|
918
|
-
case
|
|
919
|
-
|
|
887
|
+
case X.avatarsdk:
|
|
888
|
+
G = await ue.fromAvatarSDK(ne);
|
|
920
889
|
break;
|
|
921
|
-
case
|
|
922
|
-
|
|
890
|
+
case X.avaturn:
|
|
891
|
+
G = await ue.fromAvaturn(ne);
|
|
923
892
|
break;
|
|
924
893
|
}
|
|
925
|
-
|
|
894
|
+
G && H(G);
|
|
926
895
|
}
|
|
927
|
-
},
|
|
928
|
-
|
|
896
|
+
}, he = () => {
|
|
897
|
+
Ne(!0);
|
|
929
898
|
};
|
|
930
|
-
|
|
931
|
-
var
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
}, 1e3)) :
|
|
935
|
-
}, [
|
|
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]),
|
|
938
|
-
|
|
939
|
-
}, [e,
|
|
940
|
-
if (
|
|
941
|
-
if (
|
|
942
|
-
const
|
|
943
|
-
|
|
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
|
|
946
|
-
|
|
914
|
+
const C = h.mouth.clone();
|
|
915
|
+
C.setComponent(2, p.farther), Ve(C), Ie(h.lowerbelly);
|
|
947
916
|
}
|
|
948
|
-
}, [
|
|
949
|
-
o && (o.credentials &&
|
|
950
|
-
}, [o]),
|
|
951
|
-
|
|
952
|
-
}, [
|
|
953
|
-
const
|
|
954
|
-
if (
|
|
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
|
|
957
|
-
|
|
958
|
-
const
|
|
959
|
-
|
|
960
|
-
x:
|
|
961
|
-
y:
|
|
962
|
-
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);
|
|
928
|
+
Ut({
|
|
929
|
+
x: ne,
|
|
930
|
+
y: F,
|
|
931
|
+
z: qe
|
|
963
932
|
});
|
|
964
|
-
const
|
|
965
|
-
eye: new
|
|
966
|
-
mouth: new
|
|
967
|
-
neck: new
|
|
968
|
-
clavicle: new
|
|
969
|
-
torso: new
|
|
970
|
-
belly: new
|
|
971
|
-
lowerbelly: new
|
|
972
|
-
hips:
|
|
973
|
-
higherthigh: new
|
|
974
|
-
thigh: new
|
|
975
|
-
knee: new
|
|
976
|
-
leg: new
|
|
977
|
-
feet: new
|
|
978
|
-
}, K = (
|
|
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
|
-
|
|
990
|
-
} catch (
|
|
991
|
-
console.warn(
|
|
958
|
+
Ot(Ke), Ht(Ze);
|
|
959
|
+
} catch (C) {
|
|
960
|
+
console.warn(C);
|
|
992
961
|
}
|
|
993
|
-
|
|
962
|
+
ce(!0);
|
|
994
963
|
}
|
|
995
964
|
};
|
|
996
|
-
return /* @__PURE__ */
|
|
997
|
-
},
|
|
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:
|
|
968
|
+
currentTopEmotion: we.Neutral,
|
|
1000
969
|
useTopEmotionOnly: !0,
|
|
1001
970
|
autoDecay: !1
|
|
1002
|
-
}, ie =
|
|
971
|
+
}, ie = se()(() => br), Qr = (e) => {
|
|
1003
972
|
if (ie.setState({ emotions: e || [] }), e != null && e.length) {
|
|
1004
|
-
const t = e.reduce((
|
|
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:
|
|
1008
|
-
},
|
|
976
|
+
ie.setState({ currentTopEmotion: we.Neutral });
|
|
977
|
+
}, $r = (e) => {
|
|
1009
978
|
ie.setState({ useTopEmotionOnly: e });
|
|
1010
|
-
},
|
|
979
|
+
}, Yr = (e) => {
|
|
1011
980
|
ie.setState({ autoDecay: e });
|
|
1012
|
-
},
|
|
1013
|
-
const t =
|
|
981
|
+
}, Jr = (e) => {
|
|
982
|
+
const t = b.getState().FACSManager;
|
|
1014
983
|
t == null || t.playFacialAnimation({ ...e });
|
|
1015
984
|
};
|
|
1016
985
|
export {
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
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
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
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
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
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
|
};
|