@davi-ai/react-bodyengine-three 1.0.34 → 1.0.37
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/Character.d.ts +1 -1
- package/dist/components/Controllers/EmotionController.d.ts +4 -0
- package/dist/contexts/characterStore.d.ts +1 -4
- package/dist/contexts/speechStore.d.ts +8 -15
- package/dist/index.d.ts +2 -2
- package/dist/index.js +402 -1230
- package/dist/models/enums.d.ts +1 -64
- package/dist/models/types.d.ts +18 -47
- package/dist/stats.html +1 -1
- package/package.json +11 -4
- package/dist/components/PostProcessing/pipelines.d.ts +0 -37
- package/dist/models/constants.d.ts +0 -15
- package/dist/utils/getCameraPositionVector.d.ts +0 -3
package/dist/index.js
CHANGED
|
@@ -1,42 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
3
|
-
import { Vector3 as
|
|
4
|
-
import { Object3D as
|
|
5
|
-
import { CharacterState as de,
|
|
6
|
-
import { CharacterState as
|
|
7
|
-
import { useDetectGPU as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
const wt = (e) => {
|
|
1
|
+
import i, { useState as A, useMemo as _, useEffect as l, useRef as X, useCallback as pe, Suspense as fe } from "react";
|
|
2
|
+
import * as R from "three/webgpu";
|
|
3
|
+
import { Vector3 as ye } from "three/webgpu";
|
|
4
|
+
import { Object3D as $t } from "three/webgpu";
|
|
5
|
+
import { CharacterState as z, convertSPPASViseme as Ae, speechAudioClock as ke, playPendingVisemes as be, connectSpeechAudio as Ce, createHighPipeline as we, createTraaPipeline as Pe, Emotions as de, emotionsToActionUnits as Me, getCameraPositionVector as Ee, computeBodyFraming as Te, CreationTool as $, AvaturnLoader as Re, BodyMesh as ne, AvatarSDKLoader as ve, CC3Loader as De, Character as ae } from "@davi-ai/bodyengine-three";
|
|
6
|
+
import { CharacterState as qt, CreationTool as Jt, Distances as Qt, Positions as Yt, Rotations as Zt, bmlTags as _t, emotionList as en, cameraPresets as tn } from "@davi-ai/bodyengine-three";
|
|
7
|
+
import { useDetectGPU as Ve, PerformanceMonitor as xe, PerspectiveCamera as Fe, CameraControls as Ie, Environment as Le } from "@react-three/drei";
|
|
8
|
+
import { vec4 as oe, vec3 as ze } from "three/tsl";
|
|
9
|
+
import { Canvas as Be, useThree as Ue, useFrame as ge } from "@react-three/fiber";
|
|
10
|
+
import { createSpeechSynthesisPonyfill as Ge, SpeechSynthesisUtterance as Oe } from "@davi-ai/web-speech-cognitive-services-davi";
|
|
11
|
+
const re = (e) => {
|
|
13
12
|
let t;
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
if (!Object.is(
|
|
17
|
-
const
|
|
18
|
-
t =
|
|
13
|
+
const n = /* @__PURE__ */ new Set(), r = (c, w) => {
|
|
14
|
+
const P = typeof c == "function" ? c(t) : c;
|
|
15
|
+
if (!Object.is(P, t)) {
|
|
16
|
+
const E = t;
|
|
17
|
+
t = w ?? (typeof P != "object" || P === null) ? P : Object.assign({}, t, P), n.forEach((D) => D(t, E));
|
|
19
18
|
}
|
|
20
|
-
},
|
|
21
|
-
return
|
|
22
|
-
},
|
|
23
|
-
function
|
|
24
|
-
const
|
|
19
|
+
}, d = () => t, k = { setState: r, getState: d, getInitialState: () => C, subscribe: (c) => (n.add(c), () => n.delete(c)) }, C = t = e(r, d, k);
|
|
20
|
+
return k;
|
|
21
|
+
}, Ne = (e) => e ? re(e) : re, He = (e) => e;
|
|
22
|
+
function Ke(e, t = He) {
|
|
23
|
+
const n = i.useSyncExternalStore(
|
|
25
24
|
e.subscribe,
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
i.useCallback(() => t(e.getState()), [e, t]),
|
|
26
|
+
() => t(e.getInitialState())
|
|
28
27
|
);
|
|
29
|
-
return
|
|
28
|
+
return i.useDebugValue(n), n;
|
|
30
29
|
}
|
|
31
|
-
const
|
|
32
|
-
const t =
|
|
33
|
-
return Object.assign(
|
|
34
|
-
},
|
|
30
|
+
const je = (e) => {
|
|
31
|
+
const t = Ne(e), n = (r) => Ke(t, r);
|
|
32
|
+
return Object.assign(n, t), n;
|
|
33
|
+
}, J = (e) => je, g = J()(() => ({
|
|
35
34
|
character: null,
|
|
36
35
|
managers: [],
|
|
37
36
|
globalManager: null,
|
|
38
37
|
lipSyncManager: null,
|
|
39
|
-
blendshapeManager: null,
|
|
40
38
|
eyeBlinkManager: null,
|
|
41
39
|
animationManager: null,
|
|
42
40
|
FACSManager: null,
|
|
@@ -47,1328 +45,502 @@ const Ys = (e) => {
|
|
|
47
45
|
characterWidth: 0,
|
|
48
46
|
characterHeight: 0,
|
|
49
47
|
characterDepth: 0,
|
|
50
|
-
characterState:
|
|
51
|
-
})),
|
|
52
|
-
|
|
48
|
+
characterState: z.idle
|
|
49
|
+
})), We = (e) => {
|
|
50
|
+
g.setState({ character: e }), g.setState({ managers: {
|
|
53
51
|
lipSyncManager: (e == null ? void 0 : e.lipSyncManager) || null,
|
|
54
|
-
blendshapeManager: (e == null ? void 0 : e.blendshapeManager) || null,
|
|
55
52
|
eyeBlinkManager: (e == null ? void 0 : e.eyeBlinkManager) || null,
|
|
56
53
|
animationManager: (e == null ? void 0 : e.animationManager) || null
|
|
57
|
-
} }),
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
}, $
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
},
|
|
54
|
+
} }), g.setState({ globalManager: (e == null ? void 0 : e.globalManager) || null }), g.setState({ lipSyncManager: (e == null ? void 0 : e.lipSyncManager) || null }), g.setState({ eyeBlinkManager: (e == null ? void 0 : e.eyeBlinkManager) || null }), g.setState({ animationManager: (e == null ? void 0 : e.animationManager) || null }), g.setState({ FACSManager: (e == null ? void 0 : e.FACSManager) || null }), g.setState({ headPoseManager: (e == null ? void 0 : e.headPoseManager) || null }), g.setState({ gazeManager: (e == null ? void 0 : e.gazeManager) || null }), g.setState({ bmlManager: (e == null ? void 0 : e.bmlManager) || null });
|
|
55
|
+
}, ie = (e) => {
|
|
56
|
+
g.setState({ animationsLoaded: e });
|
|
57
|
+
}, $e = (e) => {
|
|
58
|
+
g.setState({ characterWidth: e.x }), g.setState({ characterHeight: e.y }), g.setState({ characterDepth: e.z });
|
|
59
|
+
}, Mt = () => g.getState().characterHeight, ce = (e) => {
|
|
60
|
+
g.setState({ characterState: e });
|
|
61
|
+
}, M = J()(() => ({
|
|
65
62
|
cameraRef: null,
|
|
66
|
-
cameraPosition: new
|
|
63
|
+
cameraPosition: new ye(0, 0, 5),
|
|
67
64
|
bodyCenter: null,
|
|
68
65
|
defaultPositions: null,
|
|
69
66
|
defaultDistances: null,
|
|
70
67
|
lookAt: null,
|
|
71
68
|
movable: !0
|
|
72
|
-
})),
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
},
|
|
69
|
+
})), Xe = (e) => {
|
|
70
|
+
M.setState({ cameraRef: e });
|
|
71
|
+
}, le = (e) => {
|
|
72
|
+
M.setState({ cameraPosition: e });
|
|
73
|
+
}, Et = () => M.getState().cameraPosition, qe = (e) => {
|
|
74
|
+
M.setState({ bodyCenter: e });
|
|
75
|
+
}, Je = (e) => {
|
|
76
|
+
M.setState({ defaultPositions: e });
|
|
77
|
+
}, Qe = (e) => {
|
|
78
|
+
M.setState({ defaultDistances: e });
|
|
79
|
+
}, me = (e) => {
|
|
80
|
+
M.setState({ lookAt: e });
|
|
81
|
+
}, Tt = () => M.getState().lookAt, Ye = (e) => {
|
|
82
|
+
M.setState({ movable: e });
|
|
83
|
+
}, F = J()(() => ({
|
|
87
84
|
currentAUs: null,
|
|
88
85
|
currentGaze: null,
|
|
89
86
|
currentHeadPose: null,
|
|
90
87
|
lookAtCamera: !1,
|
|
91
88
|
targets: [],
|
|
92
89
|
showFirstTarget: !1
|
|
93
|
-
})),
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
const t =
|
|
90
|
+
})), Ze = (e) => {
|
|
91
|
+
F.setState({ targets: e });
|
|
92
|
+
}, _e = (e) => {
|
|
93
|
+
F.setState({ currentAUs: e });
|
|
94
|
+
}, Rt = (e) => {
|
|
95
|
+
F.setState({ currentGaze: e });
|
|
96
|
+
}, vt = (e) => {
|
|
97
|
+
F.setState({ currentHeadPose: e });
|
|
98
|
+
}, se = (e) => {
|
|
99
|
+
F.setState({ lookAtCamera: e }), e ? et() : tt();
|
|
100
|
+
}, et = (e) => {
|
|
101
|
+
const t = g.getState().globalManager;
|
|
105
102
|
if (e)
|
|
106
103
|
t == null || t.lookAtAndKeep(e);
|
|
107
104
|
else {
|
|
108
|
-
const
|
|
109
|
-
t == null || t.lookAtAndKeep(
|
|
105
|
+
const n = M.getState().cameraRef;
|
|
106
|
+
t == null || t.lookAtAndKeep(n);
|
|
110
107
|
}
|
|
111
|
-
},
|
|
108
|
+
}, tt = () => {
|
|
112
109
|
var e;
|
|
113
|
-
(e =
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
},
|
|
110
|
+
(e = g.getState().globalManager) == null || e.releaseLookAt();
|
|
111
|
+
}, Dt = (e) => {
|
|
112
|
+
F.setState({ showFirstTarget: e });
|
|
113
|
+
}, q = J()(() => ({
|
|
117
114
|
animationsNames: [],
|
|
118
115
|
animations: /* @__PURE__ */ new Map(),
|
|
119
116
|
currentAnimation: null,
|
|
120
117
|
autoPlay: !0
|
|
121
|
-
})),
|
|
122
|
-
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
},
|
|
128
|
-
if (
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
var $ = /* @__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))($ || {}), le = /* @__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))(le || {}), X = /* @__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))(X || {}), Le = /* @__PURE__ */ ((e) => (e.cc3 = "CC_Base_Body", e.avatarsdk = "AvatarBody", e.avaturn = "Body_Mesh", e))(Le || {}), lt = /* @__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))(lt || {});
|
|
134
|
-
const kt = /* @__PURE__ */ new Map([
|
|
135
|
-
[0, "sil"],
|
|
136
|
-
[1, "aa"],
|
|
137
|
-
[2, "aa"],
|
|
138
|
-
[3, "O"],
|
|
139
|
-
[4, "E"],
|
|
140
|
-
[5, "E"],
|
|
141
|
-
[6, "I"],
|
|
142
|
-
[7, "U"],
|
|
143
|
-
[8, "O"],
|
|
144
|
-
[9, "U"],
|
|
145
|
-
[10, "O"],
|
|
146
|
-
[11, "aa"],
|
|
147
|
-
[12, "kk"],
|
|
148
|
-
[13, "RR"],
|
|
149
|
-
[14, "nn"],
|
|
150
|
-
[15, "SS"],
|
|
151
|
-
[16, "CH"],
|
|
152
|
-
[17, "TH"],
|
|
153
|
-
[18, "FF"],
|
|
154
|
-
[19, "DD"],
|
|
155
|
-
[20, "kk"],
|
|
156
|
-
[21, "PP"]
|
|
157
|
-
]), cn = /* @__PURE__ */ new Map([
|
|
158
|
-
["#", "#"],
|
|
159
|
-
["p", "p"],
|
|
160
|
-
["b", "b"],
|
|
161
|
-
["t", "t"],
|
|
162
|
-
["d", "d"],
|
|
163
|
-
["k", "k"],
|
|
164
|
-
["g", "g"],
|
|
165
|
-
["f", "f"],
|
|
166
|
-
["s", "s"],
|
|
167
|
-
["S", "ʃ"],
|
|
168
|
-
["v", "v"],
|
|
169
|
-
["z", "z"],
|
|
170
|
-
["Z", "ʒ"],
|
|
171
|
-
["m", "m"],
|
|
172
|
-
["n", "n"],
|
|
173
|
-
["l", "l"],
|
|
174
|
-
["R", "ʁ"],
|
|
175
|
-
["j", "j"],
|
|
176
|
-
["w", "w"],
|
|
177
|
-
["H", "ɥ"],
|
|
178
|
-
["E", "ɛ"],
|
|
179
|
-
["A/", "ɑ"],
|
|
180
|
-
["9", "oe"],
|
|
181
|
-
["i", "i"],
|
|
182
|
-
["e", "e"],
|
|
183
|
-
["O/", "o"],
|
|
184
|
-
["u", "u"],
|
|
185
|
-
["y", "y"],
|
|
186
|
-
["2", "ø"],
|
|
187
|
-
["@", "ə"],
|
|
188
|
-
["a~", "ã"],
|
|
189
|
-
["U~/", "ɛ̃"],
|
|
190
|
-
["U~/", "oẽ"],
|
|
191
|
-
["O~", "ɔ̃"],
|
|
192
|
-
["a", "a"],
|
|
193
|
-
["A", "ɑ"],
|
|
194
|
-
["3", "ɜ"],
|
|
195
|
-
["I", "ɪ"],
|
|
196
|
-
["o", "o"],
|
|
197
|
-
["O", "ɔ"],
|
|
198
|
-
["U", "ʊ"],
|
|
199
|
-
["Y", "ʏ"],
|
|
200
|
-
["A~", "ɑ̃"],
|
|
201
|
-
["E~", "ɛ̃"],
|
|
202
|
-
["e~", "ɛ̃"],
|
|
203
|
-
["9~", "oẽ"],
|
|
204
|
-
["N", "ŋ"],
|
|
205
|
-
["J", "ɲ"]
|
|
206
|
-
]), ln = /* @__PURE__ */ new Map([
|
|
207
|
-
["#", 0],
|
|
208
|
-
["æ", 1],
|
|
209
|
-
["ə", 1],
|
|
210
|
-
["ʌ", 1],
|
|
211
|
-
["ɑ", 2],
|
|
212
|
-
["ɔ", 3],
|
|
213
|
-
["ɛ", 4],
|
|
214
|
-
["ʊ", 4],
|
|
215
|
-
["ɝ", 5],
|
|
216
|
-
["j", 6],
|
|
217
|
-
["i", 6],
|
|
218
|
-
["ɪ", 6],
|
|
219
|
-
["w", 7],
|
|
220
|
-
["u", 7],
|
|
221
|
-
["o", 8],
|
|
222
|
-
["aʊ", 9],
|
|
223
|
-
["ɔɪ", 10],
|
|
224
|
-
["aɪ", 11],
|
|
225
|
-
["h", 12],
|
|
226
|
-
["ɹ", 13],
|
|
227
|
-
["l", 14],
|
|
228
|
-
["s", 15],
|
|
229
|
-
["z", 15],
|
|
230
|
-
["ʃ", 16],
|
|
231
|
-
["tʃ", 16],
|
|
232
|
-
["dʒ", 16],
|
|
233
|
-
["ʒ", 16],
|
|
234
|
-
["ð", 17],
|
|
235
|
-
["f", 18],
|
|
236
|
-
["v", 18],
|
|
237
|
-
["d", 19],
|
|
238
|
-
["t", 19],
|
|
239
|
-
["n", 19],
|
|
240
|
-
["θ", 19],
|
|
241
|
-
["k", 20],
|
|
242
|
-
["g", 20],
|
|
243
|
-
["ŋ", 20],
|
|
244
|
-
["p", 21],
|
|
245
|
-
["b", 21],
|
|
246
|
-
["m", 21]
|
|
247
|
-
]), dn = {
|
|
248
|
-
position: $.mouth,
|
|
249
|
-
distance: X.farther,
|
|
250
|
-
lookAt: $.lowerbelly
|
|
251
|
-
}, un = {
|
|
252
|
-
position: $.mouth,
|
|
253
|
-
distance: X.close,
|
|
254
|
-
lookAt: $.mouth
|
|
255
|
-
}, hn = {
|
|
256
|
-
position: $.mouth,
|
|
257
|
-
distance: X.midclose,
|
|
258
|
-
lookAt: $.mouth
|
|
259
|
-
}, mn = {
|
|
260
|
-
position: $.neck,
|
|
261
|
-
distance: X.close,
|
|
262
|
-
lookAt: $.neck
|
|
263
|
-
}, pn = {
|
|
264
|
-
position: $.eye,
|
|
265
|
-
distance: X.medium,
|
|
266
|
-
lookAt: $.neck
|
|
267
|
-
}, gn = {
|
|
268
|
-
position: $.eye,
|
|
269
|
-
distance: X.medium,
|
|
270
|
-
lookAt: $.clavicle
|
|
271
|
-
}, fn = {
|
|
272
|
-
position: $.eye,
|
|
273
|
-
distance: X.midfar,
|
|
274
|
-
lookAt: $.belly
|
|
275
|
-
}, yn = {
|
|
276
|
-
position: $.eye,
|
|
277
|
-
distance: X.far,
|
|
278
|
-
lookAt: $.lowerbelly
|
|
279
|
-
}, lo = {
|
|
280
|
-
default: dn,
|
|
281
|
-
head: un,
|
|
282
|
-
neck: hn,
|
|
283
|
-
shoulders: mn,
|
|
284
|
-
chest: pn,
|
|
285
|
-
belly: gn,
|
|
286
|
-
knees: fn,
|
|
287
|
-
feet: yn
|
|
288
|
-
}, z = we()(() => ({
|
|
118
|
+
})), nt = (e) => {
|
|
119
|
+
q.setState({ animationsNames: e });
|
|
120
|
+
}, at = (e) => {
|
|
121
|
+
q.setState({ animations: e });
|
|
122
|
+
}, Vt = () => q.getState().animations, xt = (e) => {
|
|
123
|
+
q.setState({ autoPlay: e });
|
|
124
|
+
}, Ft = (e) => {
|
|
125
|
+
if (q.setState({ autoPlay: !1 }), q.getState().animationsNames.includes(e)) {
|
|
126
|
+
const n = g.getState().animationManager;
|
|
127
|
+
n == null || n.playAnimation(e);
|
|
128
|
+
}
|
|
129
|
+
}, p = J()(() => ({
|
|
289
130
|
credentials: void 0,
|
|
290
131
|
currentUtterance: null,
|
|
291
132
|
boundaries: [],
|
|
292
133
|
visemes: [],
|
|
293
|
-
|
|
294
|
-
currentVisemeIndex: 0,
|
|
295
|
-
currentBlendshapeIndex: 0,
|
|
134
|
+
playedVisemeCount: 0,
|
|
296
135
|
voice: null,
|
|
297
136
|
voices: [],
|
|
298
137
|
textToSpeak: null,
|
|
299
138
|
visemeIntensity: 1,
|
|
300
|
-
|
|
301
|
-
})),
|
|
302
|
-
|
|
303
|
-
},
|
|
139
|
+
lipSyncFromAudio: !1
|
|
140
|
+
})), st = (e) => {
|
|
141
|
+
p.setState({ credentials: e });
|
|
142
|
+
}, ot = (e) => {
|
|
304
143
|
if (e) {
|
|
305
|
-
const t =
|
|
144
|
+
const t = p.getState().voice;
|
|
306
145
|
t && (e.voice = t);
|
|
307
146
|
}
|
|
308
|
-
|
|
309
|
-
},
|
|
310
|
-
|
|
311
|
-
},
|
|
312
|
-
|
|
313
|
-
},
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (s) {
|
|
320
|
-
const a = ln.get(s);
|
|
321
|
-
a !== void 0 && qt({ ...e, name: `${a}`, elapsedTime: e.elapsedTime * (t || 1e7) });
|
|
322
|
-
}
|
|
323
|
-
}, bn = (e) => {
|
|
324
|
-
z.setState({ currentVisemeIndex: e });
|
|
325
|
-
}, Tn = (e) => {
|
|
326
|
-
z.setState({ currentBlendshapeIndex: e });
|
|
327
|
-
}, Wt = () => {
|
|
147
|
+
p.setState({ currentUtterance: e }), p.setState({ textToSpeak: null });
|
|
148
|
+
}, It = (e) => {
|
|
149
|
+
p.setState({ visemes: e });
|
|
150
|
+
}, he = (e) => {
|
|
151
|
+
p.setState({ visemes: [...p.getState().visemes, e] });
|
|
152
|
+
}, Lt = (e, t) => {
|
|
153
|
+
const n = Ae(e, t);
|
|
154
|
+
n && he(n);
|
|
155
|
+
}, rt = (e) => {
|
|
156
|
+
p.setState({ playedVisemeCount: e });
|
|
157
|
+
}, it = () => {
|
|
328
158
|
var e;
|
|
329
|
-
|
|
159
|
+
p.setState({
|
|
330
160
|
visemes: [],
|
|
331
|
-
|
|
332
|
-
}), (e =
|
|
333
|
-
},
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
},
|
|
340
|
-
|
|
341
|
-
},
|
|
342
|
-
|
|
343
|
-
},
|
|
344
|
-
|
|
345
|
-
}, fo = () => z.getState().voices, yo = (e) => {
|
|
346
|
-
z.setState({ visemeIntensity: e });
|
|
347
|
-
}, An = (e) => {
|
|
348
|
-
e !== z.getState().useBlendshapeManager && (Wt(), Kt(), z.setState({ useBlendshapeManager: e }));
|
|
349
|
-
}, wn = (e, t, s) => {
|
|
350
|
-
let a = s[e.position || $.eye].getComponent(0);
|
|
351
|
-
const r = s[e.position || $.mouth].getComponent(1);
|
|
352
|
-
let o = 0;
|
|
353
|
-
const l = typeof e.distance == "string" ? parseInt(e.distance) : e.distance, f = typeof e.rotation == "string" ? parseInt(e.rotation) : e.rotation;
|
|
354
|
-
switch (l) {
|
|
355
|
-
case X.veryclose:
|
|
356
|
-
o = t.veryclose;
|
|
357
|
-
break;
|
|
358
|
-
case X.closer:
|
|
359
|
-
o = t.closer;
|
|
360
|
-
break;
|
|
361
|
-
case X.close:
|
|
362
|
-
o = t.close;
|
|
363
|
-
break;
|
|
364
|
-
case X.midclose:
|
|
365
|
-
o = t.midclose;
|
|
366
|
-
break;
|
|
367
|
-
case X.medium:
|
|
368
|
-
o = t.medium;
|
|
369
|
-
break;
|
|
370
|
-
case X.midfar:
|
|
371
|
-
o = t.midfar;
|
|
372
|
-
break;
|
|
373
|
-
case X.far:
|
|
374
|
-
o = t.far;
|
|
375
|
-
break;
|
|
376
|
-
case X.farther:
|
|
377
|
-
case void 0:
|
|
378
|
-
default:
|
|
379
|
-
o = t.farther;
|
|
380
|
-
break;
|
|
381
|
-
case X.veryfar:
|
|
382
|
-
o = t.veryfar;
|
|
383
|
-
break;
|
|
384
|
-
}
|
|
385
|
-
if (f && f !== le.face)
|
|
386
|
-
switch (f) {
|
|
387
|
-
case le.eighthleft: {
|
|
388
|
-
const T = 0.2588190451;
|
|
389
|
-
a = a - o * T, o = o * Math.sqrt(1 - Math.pow(T, 2));
|
|
390
|
-
break;
|
|
391
|
-
}
|
|
392
|
-
case le.thirdleft:
|
|
393
|
-
a = a - o * (1 / 2), o = o * (Math.sqrt(3) / 2);
|
|
394
|
-
break;
|
|
395
|
-
case le.quarterleft:
|
|
396
|
-
a = a - o * (Math.SQRT2 / 2), o = o * (Math.SQRT2 / 2);
|
|
397
|
-
break;
|
|
398
|
-
case le.halfleft:
|
|
399
|
-
a = a - o, o = s.eye.getComponent(2);
|
|
400
|
-
break;
|
|
401
|
-
case le.eighthright: {
|
|
402
|
-
const T = 0.2588190451;
|
|
403
|
-
a = a + o * T, o = o * Math.sqrt(1 - Math.pow(T, 2));
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
case le.thirdright:
|
|
407
|
-
a = a + o * (1 / 2), o = o * (Math.sqrt(3) / 2);
|
|
408
|
-
break;
|
|
409
|
-
case le.quarterright:
|
|
410
|
-
a = a + o * (Math.SQRT2 / 2), o = o * (Math.SQRT2 / 2);
|
|
411
|
-
break;
|
|
412
|
-
case le.halfright:
|
|
413
|
-
a = a + o, o = s.eye.getComponent(2);
|
|
414
|
-
break;
|
|
415
|
-
}
|
|
416
|
-
return new B.Vector3(a, r, o);
|
|
417
|
-
}, Xe = /* @__PURE__ */ new zt(), Vt = /* @__PURE__ */ new Te();
|
|
418
|
-
let Je;
|
|
419
|
-
class Cn extends He {
|
|
420
|
-
static get type() {
|
|
421
|
-
return "TRAANode";
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Constructs a new TRAA node.
|
|
425
|
-
*
|
|
426
|
-
* @param {TextureNode} beautyNode - The texture node that represents the input of the effect.
|
|
427
|
-
* @param {TextureNode} depthNode - A node that represents the scene's depth.
|
|
428
|
-
* @param {TextureNode} velocityNode - A node that represents the scene's velocity.
|
|
429
|
-
* @param {Camera} camera - The camera the scene is rendered with.
|
|
430
|
-
*/
|
|
431
|
-
constructor(t, s, a, r) {
|
|
432
|
-
super("vec4"), this.isTRAANode = !0, this.updateBeforeType = Xt.FRAME, this.beautyNode = t, this.depthNode = s, this.velocityNode = a, this.camera = r, this.depthThreshold = 5e-4, this.edgeDepthDiff = 1e-3, this.maxVelocityLength = 32, this.useSubpixelCorrection = !0, this._jitterIndex = 0, this._invSize = I(new Te()), this._historyRenderTarget = new st(1, 1, { depthBuffer: !1, type: gt, depthTexture: new pt() }), this._historyRenderTarget.texture.name = "TRAANode.history", this._resolveRenderTarget = new st(1, 1, { depthBuffer: !1, type: gt }), this._resolveRenderTarget.texture.name = "TRAANode.resolve", this._resolveMaterial = new Dt(), this._resolveMaterial.name = "TRAA.resolve", this._resolveMaterial.blending = Jt, this._textureNode = ze(this, this._resolveRenderTarget.texture), this._originalProjectionMatrix = new xe(), this._cameraNearFar = I(new Te()), this._cameraWorldMatrix = I(new xe()), this._cameraWorldMatrixInverse = I(new xe()), this._cameraProjectionMatrixInverse = I(new xe()), this._previousCameraWorldMatrix = I(new xe()), this._previousCameraProjectionMatrixInverse = I(new xe()), this._previousDepthNode = Fe(new pt(1, 1)), this._needsPostProcessingSync = !1, this._velocityNode = null;
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Returns the result of the effect as a texture node.
|
|
436
|
-
*
|
|
437
|
-
* @return {PassTextureNode} A texture node that represents the result of the effect.
|
|
438
|
-
*/
|
|
439
|
-
getTextureNode() {
|
|
440
|
-
return this._textureNode;
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* Returns the history buffer as a texture node. During the update of a new frame this
|
|
444
|
-
* texture holds the *previous* frame's anti-aliased resolve, which makes it a cheap
|
|
445
|
-
* feedback source for effects that want last frame's final lighting (e.g. feeding it
|
|
446
|
-
* into SSGI as the beauty input turns single-bounce GI into infinite bounces).
|
|
447
|
-
*
|
|
448
|
-
* Note: this is intentionally a plain TextureNode (not a PassTextureNode) so referencing
|
|
449
|
-
* it does not create a cyclic dependency in the node graph.
|
|
450
|
-
*
|
|
451
|
-
* @return {TextureNode} A texture node that represents the previous frame's resolve.
|
|
452
|
-
*/
|
|
453
|
-
getHistoryTextureNode() {
|
|
454
|
-
return this._historyTextureNode === void 0 && (this._historyTextureNode = Fe(this._historyRenderTarget.texture)), this._historyTextureNode;
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* Sets the size of the effect.
|
|
458
|
-
*
|
|
459
|
-
* @param {number} width - The width of the effect.
|
|
460
|
-
* @param {number} height - The height of the effect.
|
|
461
|
-
*/
|
|
462
|
-
setSize(t, s) {
|
|
463
|
-
this._historyRenderTarget.setSize(t, s), this._resolveRenderTarget.setSize(t, s), this._invSize.value.set(1 / t, 1 / s);
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Defines the TRAA's current jitter as a view offset
|
|
467
|
-
* to the scene's camera.
|
|
468
|
-
*
|
|
469
|
-
* @param {number} width - The width of the effect.
|
|
470
|
-
* @param {number} height - The height of the effect.
|
|
471
|
-
*/
|
|
472
|
-
setViewOffset(t, s) {
|
|
473
|
-
this.camera.updateProjectionMatrix(), this._originalProjectionMatrix.copy(this.camera.projectionMatrix), this._velocityNode.setProjectionMatrix(this._originalProjectionMatrix);
|
|
474
|
-
const a = {
|
|
475
|
-
fullWidth: t,
|
|
476
|
-
fullHeight: s,
|
|
477
|
-
offsetX: 0,
|
|
478
|
-
offsetY: 0,
|
|
479
|
-
width: t,
|
|
480
|
-
height: s
|
|
481
|
-
}, r = Rt[this._jitterIndex];
|
|
482
|
-
this.camera.setViewOffset(
|
|
483
|
-
a.fullWidth,
|
|
484
|
-
a.fullHeight,
|
|
485
|
-
a.offsetX + (r[0] - 0.5) * 1,
|
|
486
|
-
a.offsetY + (r[1] - 0.5) * 1,
|
|
487
|
-
a.width,
|
|
488
|
-
a.height
|
|
489
|
-
);
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Clears the view offset from the scene's camera.
|
|
493
|
-
*/
|
|
494
|
-
clearViewOffset() {
|
|
495
|
-
this.camera.clearViewOffset(), this._velocityNode.setProjectionMatrix(null), this._jitterIndex++, this._jitterIndex = this._jitterIndex % Rt.length;
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* This method is used to render the effect once per frame.
|
|
499
|
-
*
|
|
500
|
-
* @param {NodeFrame} frame - The current node frame.
|
|
501
|
-
*/
|
|
502
|
-
updateBefore(t) {
|
|
503
|
-
const { renderer: s } = t;
|
|
504
|
-
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);
|
|
505
|
-
const a = this.beautyNode.isRTTNode ? this.beautyNode.renderTarget : this.beautyNode.passNode.renderTarget, r = a.texture.width, o = a.texture.height;
|
|
506
|
-
this._needsPostProcessingSync === !0 && (this.setViewOffset(r, o), this._needsPostProcessingSync = !1), Je = Ue.resetRendererState(s, Je);
|
|
507
|
-
const l = this._historyRenderTarget.width !== r || this._historyRenderTarget.height !== o;
|
|
508
|
-
this.setSize(r, o), l === !0 && (s.initRenderTarget(this._historyRenderTarget), s.initRenderTarget(this._resolveRenderTarget), s.copyTextureToTexture(a.texture, this._historyRenderTarget.texture)), s.setClearColor(16777215, 0), s.setRenderTarget(this._resolveRenderTarget), Xe.material = this._resolveMaterial, Xe.name = "TRAA", Xe.render(s), s.setRenderTarget(null), s.copyTextureToTexture(this._resolveRenderTarget.texture, this._historyRenderTarget.texture);
|
|
509
|
-
const f = s.getDrawingBufferSize(Vt);
|
|
510
|
-
if (this._historyRenderTarget.height === f.height && this._historyRenderTarget.width === f.width) {
|
|
511
|
-
const T = this.depthNode.value;
|
|
512
|
-
s.copyTextureToTexture(T, this._historyRenderTarget.depthTexture), this._previousDepthNode.value = this._historyRenderTarget.depthTexture;
|
|
513
|
-
}
|
|
514
|
-
Ue.restoreRendererState(s, Je);
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* This method is used to setup the effect's render targets and TSL code.
|
|
518
|
-
*
|
|
519
|
-
* @param {NodeBuilder} builder - The current node builder.
|
|
520
|
-
* @return {PassTextureNode}
|
|
521
|
-
*/
|
|
522
|
-
setup(t) {
|
|
523
|
-
t.renderPipeline && !t.context.renderPipelineState.viewOffsetOwner && (t.context.renderPipelineState.viewOffsetOwner = this, this._needsPostProcessingSync = !0, gs(() => {
|
|
524
|
-
const d = t.renderer.getDrawingBufferSize(Vt);
|
|
525
|
-
this.setViewOffset(d.width, d.height);
|
|
526
|
-
}), fs(() => {
|
|
527
|
-
this.clearViewOffset();
|
|
528
|
-
})), t.renderer.reversedDepthBuffer === !0 && (this._historyRenderTarget.depthTexture.type = es), t.context.velocity !== void 0 ? this._velocityNode = t.context.velocity : this._velocityNode = ct;
|
|
529
|
-
const s = (d) => {
|
|
530
|
-
const { x: g, y: c } = this._cameraNearFar, n = Ft(d, g, c);
|
|
531
|
-
return nt(n, g, c);
|
|
532
|
-
}, a = ys({
|
|
533
|
-
closestDepth: "float",
|
|
534
|
-
closestPositionTexel: "vec2",
|
|
535
|
-
farthestDepth: "float"
|
|
536
|
-
}), r = Q(([d]) => {
|
|
537
|
-
const g = w(2).toVar(), c = Y(0).toVar(), n = w(-1).toVar();
|
|
538
|
-
for (let i = -1; i <= 1; ++i)
|
|
539
|
-
for (let p = -1; p <= 1; ++p) {
|
|
540
|
-
const y = d.add(Y(i, p)).toVar();
|
|
541
|
-
let h = this.depthNode.load(y).r;
|
|
542
|
-
t.renderer.reversedDepthBuffer && (h = h.oneMinus()), t.renderer.logarithmicDepthBuffer && (h = s(h)), h = h.toVar(), he(h.lessThan(g), () => {
|
|
543
|
-
g.assign(h), c.assign(y);
|
|
544
|
-
}), he(h.greaterThan(n), () => {
|
|
545
|
-
n.assign(h);
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
return a(g, c, n);
|
|
549
|
-
}), o = (d) => {
|
|
550
|
-
let g = this._previousDepthNode.sample(d).r;
|
|
551
|
-
t.renderer.reversedDepthBuffer && (g = g.oneMinus()), t.renderer.logarithmicDepthBuffer && (g = s(g));
|
|
552
|
-
const c = Ie(d, g, this._previousCameraProjectionMatrixInverse), n = this._previousCameraWorldMatrix.mul(J(c, 1)).xyz, i = this._cameraWorldMatrixInverse.mul(J(n, 1)).z;
|
|
553
|
-
return this.camera.isOrthographicCamera ? Ss(i, this._cameraNearFar.x, this._cameraNearFar.y) : nt(i, this._cameraNearFar.x, this._cameraNearFar.y);
|
|
554
|
-
}, l = Q(([d, g, c, n]) => {
|
|
555
|
-
const i = n.rgb.add(c.rgb).mul(0.5), p = n.rgb.sub(c.rgb).mul(0.5).add(1e-7), y = g.sub(J(i, d.a)), A = y.xyz.div(p).abs(), C = W(A.x, A.y, A.z);
|
|
556
|
-
return C.greaterThan(1).select(
|
|
557
|
-
J(i, d.a).add(y.div(C)),
|
|
558
|
-
g
|
|
559
|
-
);
|
|
560
|
-
}).setLayout({
|
|
561
|
-
name: "clipAABB",
|
|
562
|
-
type: "vec4",
|
|
563
|
-
inputs: [
|
|
564
|
-
{ name: "currentColor", type: "vec4" },
|
|
565
|
-
{ name: "historyColor", type: "vec4" },
|
|
566
|
-
{ name: "minColor", type: "vec4" },
|
|
567
|
-
{ name: "maxColor", type: "vec4" }
|
|
568
|
-
]
|
|
569
|
-
}), f = Q(([d]) => ae(
|
|
570
|
-
d.x.mul(0.25).add(d.y.mul(0.5)).add(d.z.mul(0.25)),
|
|
571
|
-
d.x.mul(0.5).sub(d.z.mul(0.5)),
|
|
572
|
-
d.x.mul(-0.25).add(d.y.mul(0.5)).sub(d.z.mul(0.25))
|
|
573
|
-
)).setLayout({
|
|
574
|
-
name: "RGBToYCoCg",
|
|
575
|
-
type: "vec3",
|
|
576
|
-
inputs: [{ name: "c", type: "vec3" }]
|
|
577
|
-
}), T = Q(([d]) => ae(
|
|
578
|
-
d.x.add(d.y).sub(d.z),
|
|
579
|
-
d.x.add(d.z),
|
|
580
|
-
d.x.sub(d.y).sub(d.z)
|
|
581
|
-
)).setLayout({
|
|
582
|
-
name: "YCoCgToRGB",
|
|
583
|
-
type: "vec3",
|
|
584
|
-
inputs: [{ name: "c", type: "vec3" }]
|
|
585
|
-
}), v = Q(([d, g, c, n]) => {
|
|
586
|
-
const i = [
|
|
587
|
-
[-1, -1],
|
|
588
|
-
[-1, 1],
|
|
589
|
-
[1, -1],
|
|
590
|
-
[1, 1],
|
|
591
|
-
[1, 0],
|
|
592
|
-
[0, -1],
|
|
593
|
-
[0, 1],
|
|
594
|
-
[-1, 0]
|
|
595
|
-
], p = J(f(g.rgb), g.a).toVar(), y = J(f(c.rgb), c.a).toVar(), h = p.toVar(), A = p.pow2().toVar();
|
|
596
|
-
for (const [j, G] of i) {
|
|
597
|
-
const E = this.beautyNode.offset(_e(j, G)).load(d).max(0), U = J(f(E.rgb), E.a).toVar();
|
|
598
|
-
h.addAssign(U), A.addAssign(U.pow2());
|
|
599
|
-
}
|
|
600
|
-
const C = w(i.length + 1), N = h.div(C), u = A.div(C).sub(N.pow2()).max(0).sqrt().mul(n), S = N.sub(u), M = N.add(u), b = l(N.clamp(S, M), y, S, M);
|
|
601
|
-
return J(T(b.rgb), b.a);
|
|
602
|
-
}), x = Q(([d, g]) => {
|
|
603
|
-
const n = d.mul(g).fract().abs(), i = W(n, n.oneMinus());
|
|
604
|
-
return i.x.mul(i.y).oneMinus().div(0.75);
|
|
605
|
-
}).setLayout({
|
|
606
|
-
name: "subpixelCorrection",
|
|
607
|
-
type: "float",
|
|
608
|
-
inputs: [
|
|
609
|
-
{ name: "velocityUV", type: "vec2" },
|
|
610
|
-
{ name: "textureSize", type: "ivec2" }
|
|
611
|
-
]
|
|
612
|
-
}), V = Q(([d, g, c]) => {
|
|
613
|
-
const n = c.oneMinus(), i = d.mul(w(1).div(W(d.r, d.g, d.b).add(1))), p = g.mul(w(1).div(W(g.r, g.g, g.b).add(1))), y = ve(i.rgb), h = ve(p.rgb);
|
|
614
|
-
return c.mulAssign(w(1).div(y.add(1))), n.mulAssign(w(1).div(h.add(1))), xs(d.mul(c), g.mul(n)).div(W(c.add(n), 1e-5)).toVar();
|
|
615
|
-
}), m = Fe(this._historyRenderTarget.texture), k = Q(([d, g]) => {
|
|
616
|
-
const c = d.mul(g), n = c.sub(0.5).floor().add(0.5).toVar(), i = c.sub(n).toVar(), p = i.mul(i.mul(i.mul(-0.5).add(1)).sub(0.5)).toVar(), y = i.pow2().mul(i.mul(1.5).sub(2.5)).add(1).toVar(), h = i.mul(i.mul(i.mul(-1.5).add(2)).add(0.5)).toVar(), A = i.pow2().mul(i.mul(0.5).sub(0.5)).toVar(), C = y.add(h).toVar(), N = h.div(C).toVar(), u = n.sub(1).mul(this._invSize).toVar(), S = n.add(2).mul(this._invSize).toVar(), M = n.add(N).mul(this._invSize).toVar();
|
|
617
|
-
return m.sample(Y(u.x, u.y)).mul(p.x.mul(p.y)).add(m.sample(Y(M.x, u.y)).mul(C.x.mul(p.y))).add(m.sample(Y(S.x, u.y)).mul(A.x.mul(p.y))).add(m.sample(Y(u.x, M.y)).mul(p.x.mul(C.y))).add(m.sample(Y(M.x, M.y)).mul(C.x.mul(C.y))).add(m.sample(Y(S.x, M.y)).mul(A.x.mul(C.y))).add(m.sample(Y(u.x, S.y)).mul(p.x.mul(A.y))).add(m.sample(Y(M.x, S.y)).mul(C.x.mul(A.y))).add(m.sample(Y(S.x, S.y)).mul(A.x.mul(A.y))).max(0);
|
|
618
|
-
}), R = Q(() => {
|
|
619
|
-
const d = Re(), g = this.beautyNode.size(), c = d.mul(g), n = r(c), i = n.get("closestDepth"), p = n.get("closestPositionTexel"), y = n.get("farthestDepth"), h = this.velocityNode.load(p).xy.mul(Y(0.5, -0.5)), A = d.sub(h), C = o(A), N = A.greaterThanEqual(0).all().and(A.lessThanEqual(1).all()), u = y.sub(i).greaterThan(this.edgeDepthDiff), S = i.sub(C).greaterThan(this.depthThreshold), M = N.and(u.or(S.not())), b = this.beautyNode.sample(d), j = k(A, g), G = d.sub(A).mul(g).length().div(this.maxVelocityLength).saturate(), E = w(0.01).toVar();
|
|
620
|
-
this.useSubpixelCorrection && E.addAssign(x(h, g).mul(0.2)), E.assign(M.select(E.add(G).saturate(), 1));
|
|
621
|
-
const U = ke(0.5, 1, G.oneMinus().pow2()), P = v(c, b, j, U);
|
|
622
|
-
return V(b, P, E);
|
|
623
|
-
});
|
|
624
|
-
return this._resolveMaterial.colorNode = R(), this._textureNode;
|
|
625
|
-
}
|
|
626
|
-
/**
|
|
627
|
-
* Frees internal resources. This method should be called
|
|
628
|
-
* when the effect is no longer required.
|
|
629
|
-
*/
|
|
630
|
-
dispose() {
|
|
631
|
-
this._historyRenderTarget.dispose(), this._resolveRenderTarget.dispose(), this._resolveMaterial.dispose();
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
function It(e, t) {
|
|
635
|
-
let s = 1, a = 0;
|
|
636
|
-
for (; e > 0; )
|
|
637
|
-
s /= t, a += s * (e % t), e = Math.floor(e / t);
|
|
638
|
-
return a;
|
|
639
|
-
}
|
|
640
|
-
const Rt = /* @__PURE__ */ Array.from(
|
|
641
|
-
{ length: 16 },
|
|
642
|
-
(e, t) => [It(t + 1, 2), It(t + 1, 3)]
|
|
643
|
-
), Yt = (e, t, s, a) => new Cn(qe(e), t, s, a), et = /* @__PURE__ */ new zt(), Nn = /* @__PURE__ */ new Te(), Mn = [60, 300, 180, 240, 120, 0], _n = [0, 0.5, 0.25, 0.75];
|
|
644
|
-
let tt;
|
|
645
|
-
class kn extends He {
|
|
646
|
-
static get type() {
|
|
647
|
-
return "SSGINode";
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Constructs a new SSGI node.
|
|
651
|
-
*
|
|
652
|
-
* @param {TextureNode} beautyNode - A texture node that represents the beauty or scene pass.
|
|
653
|
-
* @param {TextureNode} depthNode - A texture node that represents the scene's depth.
|
|
654
|
-
* @param {TextureNode} normalNode - A texture node that represents the scene's normals.
|
|
655
|
-
* @param {PerspectiveCamera} camera - The camera the scene is rendered with.
|
|
656
|
-
*/
|
|
657
|
-
constructor(t, s, a, r) {
|
|
658
|
-
super("vec4"), this.beautyNode = t, this.depthNode = s, this.normalNode = a, this.updateBeforeType = Ot.FRAME, this.sliceCount = I(1, "uint"), this.stepCount = I(12, "uint"), this.aoIntensity = I(1, "float"), this.giIntensity = I(10, "float"), this.radius = I(12, "float"), this.useScreenSpaceSampling = I(!0, "bool"), this.expFactor = I(2, "float"), this.thickness = I(1, "float"), this.useLinearThickness = I(!1, "bool"), this.backfaceLighting = I(0, "float"), this.useTemporalFiltering = !0, this.resolutionScale = 1, this._resolution = I(new Te()), this._halfProjScale = I(1), this._temporalDirection = I(0), this._temporalOffset = I(0), this._cameraProjectionMatrix = I(r.projectionMatrix), this._cameraProjectionMatrixInverse = I(r.projectionMatrixInverse), this._cameraNear = je("near", "float", r), this._cameraFar = je("far", "float", r), this._camera = r, this._ssgiRenderTarget = new st(1, 1, { depthBuffer: !1, count: 3 });
|
|
659
|
-
const o = this._ssgiRenderTarget.textures[0];
|
|
660
|
-
o.name = "SSGI.AO", o.type = ft, o.format = ts;
|
|
661
|
-
const l = this._ssgiRenderTarget.textures[1];
|
|
662
|
-
l.name = "SSGI.GI", l.type = ss, l.format = ns;
|
|
663
|
-
const f = this._ssgiRenderTarget.textures[2];
|
|
664
|
-
f.name = "SSGI.BentNormals", f.type = ft, this._material = new Dt(), this._material.name = "SSGI", this._aoNode = ze(this, this._ssgiRenderTarget.textures[0]), this._giNode = ze(this, this._ssgiRenderTarget.textures[1]), this._bentNormalNode = ze(this, this._ssgiRenderTarget.textures[2]);
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
|
-
* Returns the AO result of the effect as a texture node.
|
|
668
|
-
*
|
|
669
|
-
* @return {PassTextureNode} A texture node that represents the AO result of the effect.
|
|
670
|
-
*/
|
|
671
|
-
getAONode() {
|
|
672
|
-
return this._aoNode;
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* Returns the GI result of the effect as a texture node.
|
|
676
|
-
*
|
|
677
|
-
* @return {PassTextureNode} A texture node that represents the GI result of the effect.
|
|
678
|
-
*/
|
|
679
|
-
getGINode() {
|
|
680
|
-
return this._giNode;
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Returns the bent normals of the effect as a texture node. The bent normal is the
|
|
684
|
-
* average unoccluded direction of the hemisphere, in view space, packed into `[0, 1]`
|
|
685
|
-
* (unpack with `normal * 2 - 1`). It can be used for occlusion-aware environment
|
|
686
|
-
* lighting (e.g. sampling IBL along the bent normal instead of the surface normal).
|
|
687
|
-
*
|
|
688
|
-
* @return {PassTextureNode} A texture node that represents the bent normals of the effect.
|
|
689
|
-
*/
|
|
690
|
-
getBentNormalNode() {
|
|
691
|
-
return this._bentNormalNode;
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Sets the size of the effect.
|
|
695
|
-
*
|
|
696
|
-
* @param {number} width - The width of the effect.
|
|
697
|
-
* @param {number} height - The height of the effect.
|
|
698
|
-
*/
|
|
699
|
-
setSize(t, s) {
|
|
700
|
-
t = Math.max(1, Math.round(t * this.resolutionScale)), s = Math.max(1, Math.round(s * this.resolutionScale)), this._resolution.value.set(t, s), this._ssgiRenderTarget.setSize(t, s), this._halfProjScale.value = s / (Math.tan(this._camera.fov * os.DEG2RAD * 0.5) * 2) * 0.5;
|
|
701
|
-
}
|
|
702
|
-
/**
|
|
703
|
-
* This method is used to render the effect once per frame.
|
|
704
|
-
*
|
|
705
|
-
* @param {NodeFrame} frame - The current node frame.
|
|
706
|
-
*/
|
|
707
|
-
updateBefore(t) {
|
|
708
|
-
const { renderer: s } = t;
|
|
709
|
-
tt = Ue.resetRendererState(s, tt);
|
|
710
|
-
const a = s.getDrawingBufferSize(Nn);
|
|
711
|
-
if (this.setSize(a.width, a.height), this.useTemporalFiltering === !0) {
|
|
712
|
-
const r = t.frameId;
|
|
713
|
-
this._temporalDirection.value = Mn[r % 6] / 360, this._temporalOffset.value = _n[r % 4];
|
|
714
|
-
} else
|
|
715
|
-
this._temporalDirection.value = 1, this._temporalOffset.value = 1;
|
|
716
|
-
et.material = this._material, et.name = "SSGI", s.setClearColor(16777215, 1), s.setRenderTarget(this._ssgiRenderTarget), et.render(s), Ue.restoreRendererState(s, tt);
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* This method is used to setup the effect's TSL code.
|
|
720
|
-
*
|
|
721
|
-
* @param {NodeBuilder} builder - The current node builder.
|
|
722
|
-
* @return {PassTextureNode}
|
|
723
|
-
*/
|
|
724
|
-
setup(t) {
|
|
725
|
-
const s = t.renderer;
|
|
726
|
-
s.backend.isWebGPUBackend === !0 && s.hasFeature("rg11b10ufloat-renderable") === !1 && console.error('THREE.SSGINode: The device does not support the "rg11b10ufloat-renderable" feature which is required for SSGI.');
|
|
727
|
-
const a = Re(), r = oe(32), o = oe(0), l = (c) => {
|
|
728
|
-
const n = this.depthNode.sample(c).r;
|
|
729
|
-
if (t.renderer.logarithmicDepthBuffer === !0) {
|
|
730
|
-
const i = Ft(n, this._cameraNear, this._cameraFar);
|
|
731
|
-
return nt(i, this._cameraNear, this._cameraFar);
|
|
732
|
-
}
|
|
733
|
-
return n;
|
|
734
|
-
}, f = (c) => this.normalNode !== null ? this.normalNode.sample(c).rgb.normalize() : Lt(c, this.depthNode.value, this._cameraProjectionMatrixInverse), T = (c) => this.beautyNode.sample(c), v = Q(([c]) => w(0.25).mul(bs(c.y, c.x).bitAnd(3))).setLayout({
|
|
735
|
-
name: "spatialOffsets",
|
|
736
|
-
type: "float",
|
|
737
|
-
inputs: [
|
|
738
|
-
{ name: "position", type: "vec2" }
|
|
739
|
-
]
|
|
740
|
-
}), x = Q(([c]) => {
|
|
741
|
-
const n = pe(c).mul(w(-0.156583)).add(Ze);
|
|
742
|
-
n.mulAssign(Et(pe(c).oneMinus()));
|
|
743
|
-
const i = c.x.greaterThanEqual(0).select(n.x, fe.sub(n.x)), p = c.y.greaterThanEqual(0).select(n.y, fe.sub(n.y));
|
|
744
|
-
return Y(i, p);
|
|
745
|
-
}).setLayout({
|
|
746
|
-
name: "GTAOFastAcos",
|
|
747
|
-
type: "vec2",
|
|
748
|
-
inputs: [
|
|
749
|
-
{ name: "value", type: "vec2" }
|
|
750
|
-
]
|
|
751
|
-
}), V = Q(([c, n, i, p, y, h, A, C, N, u]) => {
|
|
752
|
-
const S = this.stepCount.toConst(), M = this.expFactor.toConst(), b = this.thickness.toConst(), j = this.backfaceLighting.toConst(), G = c.select(Y(1, -1), Y(-1, 1)), E = c.select(1, -1), U = ae(0);
|
|
753
|
-
return Oe({ start: oe(0), end: S, type: "uint", condition: "<" }, ({ i: P }) => {
|
|
754
|
-
const _ = Ge(pe($e(n, w(P).add(h)).div(i)), M).mul(i).toConst(), L = y.mul(W(_, w(P).add(1))).toConst(), H = A.add(L.mul(G)).toConst();
|
|
755
|
-
he(H.x.lessThanEqual(0).or(H.y.lessThanEqual(0)).or(H.x.greaterThanEqual(1)).or(H.y.greaterThanEqual(1)), () => {
|
|
756
|
-
Ts();
|
|
757
|
-
});
|
|
758
|
-
const ne = Ie(H, l(H), this._cameraProjectionMatrixInverse).toConst(), K = ne.sub(p).normalize().toConst(), ue = this.useLinearThickness.select(ne.z.negate().div(this._cameraFar).clamp().mul(100), w(1)), Z = be(ne.sub(ue.mul(C).mul(b)).sub(p));
|
|
759
|
-
let F = Y(ie(K, C), ie(Z, C));
|
|
760
|
-
F = x(Me(F, -1, 1)), F = Me(vs($e(E, F.negate()).sub(u.sub(Ze)), fe)), F = c.select(F.yx, F.xy);
|
|
761
|
-
const me = F.x.toConst(), te = F.y.toConst(), Ce = oe(F.mul(w(r))).toConst(), Be = oe(As(te.sub(me).mul(w(r)))).toConst();
|
|
762
|
-
let ge = Be.greaterThan(oe(0)).select(oe(ws(oe(4294967295), oe(32).sub(r).add(r.sub(Be)))), oe(0)).toConst().shiftLeft(Ce);
|
|
763
|
-
ge = ge.bitAnd(o.bitNot()), o.assign(o.bitOr(ge));
|
|
764
|
-
const Ne = xt(ge);
|
|
765
|
-
he(Ne.greaterThan(0), () => {
|
|
766
|
-
const dt = T(H);
|
|
767
|
-
he(ve(dt).greaterThan(1e-3), () => {
|
|
768
|
-
const ut = be(K), ht = Me(ie(N, ut));
|
|
769
|
-
he(ht.greaterThan(1e-3), () => {
|
|
770
|
-
const mt = f(H);
|
|
771
|
-
let ye = ie(mt, ut.negate());
|
|
772
|
-
const Zt = St(ye).lessThan(0).select(pe(ye).mul(j), pe(ye));
|
|
773
|
-
ye = j.greaterThan(0).and(ie(mt, C).greaterThan(0)).select(Zt, Me(ye)), U.rgb.addAssign(w(Ne).div(w(r)).mul(dt).mul(ht).mul(ye));
|
|
774
|
-
});
|
|
775
|
-
});
|
|
776
|
-
});
|
|
777
|
-
}), U;
|
|
778
|
-
}), m = Ee("float"), k = Ee("vec3"), R = Ee("vec4"), d = Cs(m, k, R), g = Q(() => {
|
|
779
|
-
const c = l(a).toVar();
|
|
780
|
-
c.greaterThanEqual(1).discard();
|
|
781
|
-
const n = Ie(a, c, this._cameraProjectionMatrixInverse).toVar(), i = f(a).toVar(), p = be(n.xyz.negate()).toVar(), y = v(bt), h = Ns(bt), A = this._temporalDirection.mul(0.02), C = Ms(y.add(this._temporalOffset)).add(_s(a.add(A).mul(2).sub(1))), N = w(0), u = ae(0), S = ae(0), M = this.sliceCount.toConst(), b = this.stepCount.toConst(), j = this.aoIntensity.toConst(), G = this.giIntensity.toConst(), E = this.radius.toConst(), U = w(0).toVar();
|
|
782
|
-
he(this.useScreenSpaceSampling, () => {
|
|
783
|
-
U.assign(E.mul(this._resolution.x.div(2)).div(w(16)));
|
|
784
|
-
}).Else(() => {
|
|
785
|
-
U.assign(W(E.mul(this._halfProjScale).div(n.z.negate()), w(b)));
|
|
786
|
-
}), U.divAssign(w(b).add(1));
|
|
787
|
-
const P = W(1, w(b.sub(1))).mul(U).toConst();
|
|
788
|
-
Oe({ start: oe(0), end: M, type: "uint", condition: "<" }, ({ i: ne }) => {
|
|
789
|
-
const K = $e(w(ne).add(h).add(this._temporalDirection), fe.div(w(M))).toConst(), ue = ae(Y(ot(K), at(K)), 0).toConst(), Z = ue.xy.mul(w(1).div(this._resolution)).toConst(), F = be(Tt(ue, p)).toConst(), me = Tt(p, F).toConst(), te = i.sub(F.mul(ie(i, F))).toConst(), Ce = be(te).toConst(), Be = Me(ie(Ce, p), -1, 1).toConst(), De = St(ie(te, me)).negate().mul(ks(Be)).toConst();
|
|
790
|
-
o.assign(0), u.addAssign(V(vt(!0), U, P, n, Z, C, a, p, i, De)), u.addAssign(V(vt(!1), U, P, n, Z, C, a, p, i, De)), N.addAssign(w(xt(o)).div(w(r))), Oe({ start: oe(0), end: r, type: "uint", condition: "<", name: "j" }, ({ j: ge }) => {
|
|
791
|
-
he(o.shiftRight(ge).bitAnd(oe(1)).equal(oe(0)), () => {
|
|
792
|
-
const Ne = Ze.sub(De).sub(w(ge).add(0.5).div(w(r)).mul(fe));
|
|
793
|
-
S.addAssign(p.mul(ot(Ne)).add(me.mul(at(Ne))));
|
|
794
|
-
});
|
|
795
|
-
});
|
|
796
|
-
}), N.divAssign(w(M)), N.assign(Ge(N.clamp().oneMinus(), j).clamp()), u.divAssign(w(M)), u.mulAssign(G);
|
|
797
|
-
const _ = w(7).toConst(), L = ve(u), H = L.greaterThan(_).select(_.div(L), w(1));
|
|
798
|
-
return u.mulAssign(H), S.assign(be(S.add(i.mul(1e-4)))), m.assign(N), k.assign(u), R.assign(J(S.mul(0.5).add(0.5), 1)), J(0);
|
|
799
|
-
});
|
|
800
|
-
return this._material.colorNode = g().context(t.getSharedContext()), this._material.outputNode = d, this._material.needsUpdate = !0, this._aoNode;
|
|
801
|
-
}
|
|
802
|
-
/**
|
|
803
|
-
* Frees internal resources. This method should be called
|
|
804
|
-
* when the effect is no longer required.
|
|
805
|
-
*/
|
|
806
|
-
dispose() {
|
|
807
|
-
this._ssgiRenderTarget.dispose(), this._material.dispose();
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
const Pn = (e, t, s, a) => new kn(qe(e), t, s, a);
|
|
811
|
-
class Vn extends He {
|
|
812
|
-
static get type() {
|
|
813
|
-
return "DenoiseNode";
|
|
814
|
-
}
|
|
815
|
-
/**
|
|
816
|
-
* Constructs a new denoise node.
|
|
817
|
-
*
|
|
818
|
-
* @param {TextureNode} textureNode - The texture node that represents the input of the effect (e.g. AO).
|
|
819
|
-
* @param {Node<float>} depthNode - A node that represents the scene's depth.
|
|
820
|
-
* @param {?Node<vec3>} normalNode - A node that represents the scene's normals.
|
|
821
|
-
* @param {Camera} camera - The camera the scene is rendered with.
|
|
822
|
-
*/
|
|
823
|
-
constructor(t, s, a, r) {
|
|
824
|
-
super("vec4"), this.textureNode = t, this.depthNode = s, this.normalNode = a, this.noiseNode = Fe(Rn()), this.lumaPhi = I(5), this.depthPhi = I(5), this.normalPhi = I(5), this.radius = I(5), this.index = I(0), this.updateBeforeType = Ot.FRAME, this._resolution = I(new Te()), this._sampleVectors = Ps(In(16, 2, 1)), this._cameraProjectionMatrixInverse = I(r.projectionMatrixInverse);
|
|
825
|
-
}
|
|
826
|
-
/**
|
|
827
|
-
* This method is used to update internal uniforms once per frame.
|
|
828
|
-
*
|
|
829
|
-
* @param {NodeFrame} frame - The current node frame.
|
|
830
|
-
*/
|
|
831
|
-
updateBefore() {
|
|
832
|
-
const t = this.textureNode.value;
|
|
833
|
-
this._resolution.value.set(t.image.width, t.image.height);
|
|
834
|
-
}
|
|
835
|
-
/**
|
|
836
|
-
* This method is used to setup the effect's TSL code.
|
|
837
|
-
*
|
|
838
|
-
* @param {NodeBuilder} builder - The current node builder.
|
|
839
|
-
* @return {ShaderCallNodeInternal}
|
|
840
|
-
*/
|
|
841
|
-
setup() {
|
|
842
|
-
const t = Re(), s = (x) => this.textureNode.sample(x), a = (x) => this.depthNode.sample(x).x, r = (x) => this.normalNode !== null ? this.normalNode.sample(x).rgb.normalize() : Lt(x, this.depthNode.value, this._cameraProjectionMatrixInverse), o = (x) => this.noiseNode.sample(x), l = (x, V, m, k) => {
|
|
843
|
-
const R = s(k).toVar(), d = a(k).toVar(), g = r(k).toVar(), c = Ie(k, d, this._cameraProjectionMatrixInverse).toVar(), n = ie(V, g), i = Ge(W(n, 0), this.normalPhi), p = pe(ve(R.rgb).sub(ve(x))), y = W(w(1).sub(p.div(this.lumaPhi)), 0), h = pe(ie(m.sub(c), V)), A = W(w(1).sub(h.div(this.depthPhi)), 0), C = y.mul(A).mul(i).toVar();
|
|
844
|
-
return { color: R.mul(C), weight: C };
|
|
845
|
-
}, f = Q(([x]) => {
|
|
846
|
-
const V = a(x).toVar(), m = r(x).toVar(), k = s(x).toVar(), R = Ee("vec4");
|
|
847
|
-
return he(V.greaterThanEqual(1).or(ie(m, m).equal(0)), () => {
|
|
848
|
-
R.assign(k);
|
|
849
|
-
}).Else(() => {
|
|
850
|
-
const d = ae(k.rgb), g = Ie(x, V, this._cameraProjectionMatrixInverse).toConst(), c = Vs(this.noiseNode, 0);
|
|
851
|
-
let n = Y(x.x, x.y.oneMinus());
|
|
852
|
-
n = n.mul(this._resolution.div(c));
|
|
853
|
-
const i = o(n).toVar(), p = at(i.element(this.index.mod(4).mul(2).mul(fe))), y = ot(i.element(this.index.mod(4).mul(2).mul(fe))), h = Y(p, y), A = Is(h.x, h.y.negate(), h.x, h.y), C = w(1).toVar(), N = J(k).toVar();
|
|
854
|
-
Oe({ start: At(0), end: At(16), type: "int", condition: "<" }, ({ i: u }) => {
|
|
855
|
-
const S = this._sampleVectors.element(u), M = A.mul(S.xy.mul(w(1).add(S.z.mul(this.radius.sub(1))))).div(this._resolution), b = x.add(M), j = l(d, m, g, b);
|
|
856
|
-
N.addAssign(j.color), C.addAssign(j.weight);
|
|
857
|
-
}), R.assign(N.div(C));
|
|
858
|
-
}), R;
|
|
859
|
-
});
|
|
860
|
-
return Q(() => f(t))();
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
function In(e, t, s) {
|
|
864
|
-
const a = [];
|
|
865
|
-
for (let r = 0; r < e; r++) {
|
|
866
|
-
const o = 2 * Math.PI * t * r / e, l = Math.pow(r / (e - 1), s);
|
|
867
|
-
a.push(new Bt(Math.cos(o), Math.sin(o), l));
|
|
868
|
-
}
|
|
869
|
-
return a;
|
|
870
|
-
}
|
|
871
|
-
function Rn(e = 64) {
|
|
872
|
-
const t = new Ls(), s = e * e * 4, a = new Uint8Array(s);
|
|
873
|
-
for (let o = 0; o < e; o++)
|
|
874
|
-
for (let l = 0; l < e; l++) {
|
|
875
|
-
const f = o, T = l;
|
|
876
|
-
a[(o * e + l) * 4] = (t.noise(f, T) * 0.5 + 0.5) * 255, a[(o * e + l) * 4 + 1] = (t.noise(f + e, T) * 0.5 + 0.5) * 255, a[(o * e + l) * 4 + 2] = (t.noise(f, T + e) * 0.5 + 0.5) * 255, a[(o * e + l) * 4 + 3] = (t.noise(f + e, T + e) * 0.5 + 0.5) * 255;
|
|
877
|
-
}
|
|
878
|
-
const r = new as(a, e, e);
|
|
879
|
-
return r.wrapS = yt, r.wrapT = yt, r.needsUpdate = !0, r;
|
|
880
|
-
}
|
|
881
|
-
const Bn = (e, t, s, a) => new Vn(qe(e), rt(t), rt(s), a);
|
|
882
|
-
class Dn extends He {
|
|
883
|
-
static get type() {
|
|
884
|
-
return "CASNode";
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* Constructs a new CAS node.
|
|
888
|
-
*
|
|
889
|
-
* @param {TextureNode} textureNode - The texture node to sharpen (premultiplied, linear).
|
|
890
|
-
* @param {number} [amount=0.5] - Sharpening strength in [0,1]: 0 = off, 1 = RCAS maximum.
|
|
891
|
-
* @param {boolean} [denoise=true] - Whether to attenuate sharpening where the 3×3 cross looks like noise.
|
|
892
|
-
*/
|
|
893
|
-
constructor(t, s = 0.5, a = !0) {
|
|
894
|
-
super("vec4"), this.isCASNode = !0, this.textureNode = t, this.amount = I(s), this.denoise = I(a ? 1 : 0);
|
|
895
|
-
}
|
|
896
|
-
/**
|
|
897
|
-
* This method is used to setup the effect's TSL code.
|
|
898
|
-
*
|
|
899
|
-
* @param {NodeBuilder} builder - The current node builder.
|
|
900
|
-
* @return {Node<vec4>}
|
|
901
|
-
*/
|
|
902
|
-
setup() {
|
|
903
|
-
const t = this.textureNode, s = (l) => Et(l.div(l.add(1))), a = (l) => {
|
|
904
|
-
const f = l.pow2().min(0.9999);
|
|
905
|
-
return f.div(f.oneMinus());
|
|
906
|
-
}, r = (l) => l.g.add(l.r.add(l.b).mul(0.5));
|
|
907
|
-
return Q(() => {
|
|
908
|
-
const l = _e(t.size()).toConst(), f = l.sub(1).toConst(), T = _e(Re().mul(Y(l))).toConst(), v = (U, P) => {
|
|
909
|
-
const _ = t.load(W(ce(T.add(_e(U, P)), f), _e(0))), L = _.a.saturate().toConst(), H = L.greaterThan(1 / 255).select(_.rgb.max(0).div(L), ae(0));
|
|
910
|
-
return { p: s(H).toConst(), a: L };
|
|
911
|
-
}, x = v(0, 0), V = v(0, -1), m = v(-1, 0), k = v(1, 0), R = v(0, 1), d = ce(ce(V.p, m.p), ce(k.p, R.p)).toConst(), g = W(W(V.p, m.p), W(k.p, R.p)).toConst(), c = w(0.25 - 1 / 16), n = ce(d, x.p).div(g.mul(4).max(1e-5)), i = ae(1).sub(W(g, x.p)).div(d.mul(4).sub(4)), p = W(n.negate(), i).toConst(), y = W(c.negate(), ce(W(p.r, W(p.g, p.b)), 0)).mul(this.amount).toVar(), h = r(V.p), A = r(m.p), C = r(x.p), N = r(k.p), u = r(R.p), S = h.add(A).add(N).add(u).mul(0.25).sub(C), M = W(W(h, A), W(C, W(N, u))).sub(ce(ce(h, A), ce(C, ce(N, u)))), b = w(1).sub(pe(S).div(M.max(1 / 65536)).saturate().mul(0.5));
|
|
912
|
-
y.mulAssign(this.denoise.greaterThan(0.5).select(b, 1));
|
|
913
|
-
const j = y.mul(4).add(1).reciprocal().toConst(), G = a(V.p.add(m.p).add(k.p).add(R.p).mul(y).add(x.p).mul(j).max(0)), E = V.a.add(m.a).add(k.a).add(R.a).mul(y).add(x.a).mul(j).saturate().toConst();
|
|
914
|
-
return J(G.mul(E), E);
|
|
915
|
-
})();
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
const zn = (e, t, s) => new Dn(typeof e.getTextureNode == "function" ? e.getTextureNode() : qe(e), t, s);
|
|
919
|
-
function Fn(e, t) {
|
|
920
|
-
const s = Ut(e, t);
|
|
921
|
-
s.setMRT(jt({
|
|
922
|
-
output: Gt,
|
|
923
|
-
diffuseColor: Rs,
|
|
924
|
-
// alpha holds the kind of surface for the composite (SURFACE: eye / skin / hair / other,
|
|
925
|
-
// 0 = background) in the byte the RGBA8 target already stores
|
|
926
|
-
normal: J(Bs(Ds), rs),
|
|
927
|
-
velocity: ct
|
|
928
|
-
}));
|
|
929
|
-
const a = s.getTextureNode("output"), r = s.getTextureNode("depth"), o = s.getTextureNode("normal"), l = s.getTextureNode("velocity"), f = s.getTextureNode("diffuseColor");
|
|
930
|
-
s.getTexture("diffuseColor").type = B.UnsignedByteType, s.getTexture("normal").type = B.UnsignedByteType;
|
|
931
|
-
const T = We(o.a, Ke.skin), v = We(o.a, Ke.eye), x = We(o.a, Ke.hair), V = zs((G) => Fs(o.sample(G))), m = Pn(a, r, V, t);
|
|
932
|
-
m.resolutionScale = 0.5, m.aoIntensity.value = 1, m.giIntensity.value = 5, m.sliceCount.value = 2, m.stepCount.value = 8, m.thickness.value = 0.03, m.radius.value = 1, m.expFactor.value = 1, m.backfaceLighting.value = 0.1;
|
|
933
|
-
const k = m.getAONode(), R = m.getGINode(), d = je("near", "float", t), g = je("far", "float", t), c = (G) => Es(r.sample(G).r, d, g), n = Q(() => {
|
|
934
|
-
const G = Re(), E = Y(m.getAONode().size()), U = G.mul(E).sub(0.5), P = U.floor(), _ = U.sub(P), L = c(G), H = J(0).toVar(), ne = w(0).toVar();
|
|
935
|
-
for (const [K, ue] of [[0, 0], [1, 0], [0, 1], [1, 1]]) {
|
|
936
|
-
const Z = P.add(Y(K + 0.5, ue + 0.5)).div(E), F = (K === 1 ? _.x : _.x.oneMinus()).mul(ue === 1 ? _.y : _.y.oneMinus()), me = Os(L.sub(c(Z)).abs().mul(-32)).add(1e-3), te = F.mul(me);
|
|
937
|
-
H.addAssign(J(R.sample(Z).rgb, k.sample(Z).r).mul(te)), ne.addAssign(te);
|
|
938
|
-
}
|
|
939
|
-
return H.div(ne);
|
|
940
|
-
}), i = Bn(n(), r, V, t);
|
|
941
|
-
i.radius.value = 8, i.depthPhi.value = 0.1, i.lumaPhi.value = 5;
|
|
942
|
-
const p = rt(i), y = I(0.5), h = I(0.5), A = p.a.oneMinus().mul(ke(w(1), y, x)).mul(ke(w(1), h, v)).oneMinus(), C = ke(a.rgb, f.rgb, f.a), N = Q(([G, E]) => {
|
|
943
|
-
const U = E.mul(2.0404).sub(0.3324), P = E.mul(-4.7951).add(0.6417), _ = E.mul(2.7552).add(0.6903);
|
|
944
|
-
return ae(G).max(U.mul(G).add(P).mul(G).add(_).mul(G));
|
|
945
|
-
}), u = I(new B.Vector3(0.45, 0.15, 0.05)), S = ke(ae(A), Ge(ae(A), ae(1).sub(u)), T), M = J(
|
|
946
|
-
a.rgb.mul(N(S, C)).add(C.mul(p.rgb)),
|
|
947
|
-
// indirect diffuse modulated by albedo
|
|
948
|
-
a.a
|
|
949
|
-
), b = Yt(M, r, l, t);
|
|
950
|
-
return b._resolveMaterial.needsUpdate = !0, { outputNode: zn(b, 0.5), scenePassColor: a, traaPass: b, giPass: m, denoisePass: i, ao: k, gi: R, hairAO: y, eyeAO: h };
|
|
951
|
-
}
|
|
952
|
-
function On(e, t) {
|
|
953
|
-
const s = Ut(e, t);
|
|
954
|
-
s.setMRT(jt({ output: Gt, velocity: ct }));
|
|
955
|
-
const a = s.getTextureNode("output"), r = Yt(a, s.getTextureNode("depth"), s.getTextureNode("velocity"), t);
|
|
956
|
-
return r._resolveMaterial.needsUpdate = !0, { outputNode: r, scenePassColor: a, traaPass: r };
|
|
957
|
-
}
|
|
958
|
-
const En = () => {
|
|
959
|
-
const e = O((n) => n.animationsLoaded), t = O((n) => n.characterState), s = O((n) => n.lipSyncManager), a = O((n) => n.blendshapeManager), r = z((n) => n.credentials), o = z((n) => n.currentUtterance), l = z((n) => n.textToSpeak), f = z((n) => n.visemes), T = z((n) => n.blendshapes), v = z((n) => n.visemeIntensity), x = z((n) => n.currentVisemeIndex), V = z((n) => n.currentBlendshapeIndex), m = z((n) => n.useBlendshapeManager), [k, R] = ee(!1), [d, g] = ee(!1), c = it(() => r != null && r.region && (r.subscriptionKey || r.token) ? Gs({
|
|
161
|
+
playedVisemeCount: 0
|
|
162
|
+
}), (e = g.getState().lipSyncManager) == null || e.stop();
|
|
163
|
+
}, ct = (e) => {
|
|
164
|
+
p.setState({ voice: e });
|
|
165
|
+
}, ue = (e) => {
|
|
166
|
+
p.setState({ voices: e });
|
|
167
|
+
}, zt = (e) => {
|
|
168
|
+
p.setState({ textToSpeak: e });
|
|
169
|
+
}, Bt = () => p.getState().voices, Ut = (e) => {
|
|
170
|
+
p.setState({ visemeIntensity: e });
|
|
171
|
+
}, lt = (e) => {
|
|
172
|
+
p.setState({ lipSyncFromAudio: e });
|
|
173
|
+
}, mt = () => {
|
|
174
|
+
const e = g((o) => o.animationsLoaded), t = g((o) => o.characterState), n = g((o) => o.lipSyncManager), r = p((o) => o.credentials), d = p((o) => o.currentUtterance), s = p((o) => o.textToSpeak), m = p((o) => o.visemes), k = p((o) => o.visemeIntensity), C = p((o) => o.playedVisemeCount), c = p((o) => o.lipSyncFromAudio), [w, P] = A(!1), [E, D] = A(!1), h = _(() => r != null && r.region && (r.subscriptionKey || r.token) ? Ge({
|
|
960
175
|
credentials: {
|
|
961
176
|
region: r.region,
|
|
962
177
|
authorizationToken: r.token,
|
|
963
178
|
subscriptionKey: r.subscriptionKey
|
|
964
179
|
}
|
|
965
|
-
}) : null, [r]);
|
|
966
|
-
return
|
|
967
|
-
if (
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
|
|
180
|
+
}) : null, [r]), U = _(() => ke(() => h), [h]);
|
|
181
|
+
return l(() => {
|
|
182
|
+
if (h) {
|
|
183
|
+
const o = h.speechSynthesis.getVoices();
|
|
184
|
+
o && Array.isArray(o) && o.length ? (ue(o), P(!0)) : h.speechSynthesis.onvoiceschanged = () => {
|
|
185
|
+
ue(h.speechSynthesis.getVoices()), P(!0);
|
|
971
186
|
};
|
|
972
187
|
}
|
|
973
|
-
}, [
|
|
974
|
-
|
|
975
|
-
}, [
|
|
976
|
-
if (
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
-
}
|
|
980
|
-
}, [l]), q(() => {
|
|
981
|
-
var n, i;
|
|
982
|
-
o && d ? (o.onstart = () => {
|
|
983
|
-
console.log("Start"), Nt(de.speaking);
|
|
984
|
-
}, o.onend = () => {
|
|
985
|
-
console.log("End"), Nt(de.idle);
|
|
986
|
-
}, o.onboundary = () => {
|
|
987
|
-
}, o.onviseme = (p) => {
|
|
988
|
-
qt(p);
|
|
989
|
-
}, (n = c == null ? void 0 : c.speechSynthesis) == null || n.speak(o, null)) : (i = c == null ? void 0 : c.speechSynthesis) == null || i.cancel();
|
|
990
|
-
}, [o]), q(() => {
|
|
991
|
-
s && (s.visemeIntensity = v);
|
|
992
|
-
}, [v]), q(() => {
|
|
993
|
-
if (!m && s && t === de.speaking) {
|
|
994
|
-
if (!s.isStarted && s.start(), f.length > 1 && x === 0)
|
|
995
|
-
f.forEach((n) => {
|
|
996
|
-
const i = parseInt(n.name);
|
|
997
|
-
if (!isNaN(i)) {
|
|
998
|
-
const p = kt.get(i);
|
|
999
|
-
p && s.PlayVisemeAsync(p, n.elapsedTime / 1e4);
|
|
1000
|
-
}
|
|
1001
|
-
});
|
|
1002
|
-
else
|
|
1003
|
-
for (let n = x + 1; n < f.length; n++) {
|
|
1004
|
-
const i = f[n], p = parseInt(i.name);
|
|
1005
|
-
if (!isNaN(p)) {
|
|
1006
|
-
const y = kt.get(p);
|
|
1007
|
-
y && s.PlayVisemeAsync(y, i.elapsedTime / 1e4);
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
bn(f.length - 1);
|
|
1011
|
-
}
|
|
1012
|
-
}, [t, f, s, m]), q(() => {
|
|
1013
|
-
if (m && a && t === de.speaking) {
|
|
1014
|
-
if (!a.isStarted && a.start(), T.length > 1 && V === 0)
|
|
1015
|
-
T.forEach((n) => {
|
|
1016
|
-
a.PlayBlendShapeAsync(n);
|
|
1017
|
-
});
|
|
1018
|
-
else
|
|
1019
|
-
for (let n = V + 1; n < T.length; n++) {
|
|
1020
|
-
const i = T[n];
|
|
1021
|
-
a.PlayBlendShapeAsync(i);
|
|
1022
|
-
}
|
|
1023
|
-
Tn(T.length - 1);
|
|
188
|
+
}, [h]), l(() => {
|
|
189
|
+
w && n && e && D(!0);
|
|
190
|
+
}, [w, n, e]), l(() => {
|
|
191
|
+
if (s) {
|
|
192
|
+
const o = new Oe(s);
|
|
193
|
+
ot(o);
|
|
1024
194
|
}
|
|
1025
|
-
}, [
|
|
1026
|
-
|
|
195
|
+
}, [s]), l(() => {
|
|
196
|
+
var o, T;
|
|
197
|
+
d && E ? (d.onstart = () => {
|
|
198
|
+
console.log("Start"), ce(z.speaking);
|
|
199
|
+
}, d.onend = () => {
|
|
200
|
+
console.log("End"), ce(z.idle);
|
|
201
|
+
}, d.onboundary = () => {
|
|
202
|
+
}, d.onviseme = (y) => {
|
|
203
|
+
he(y);
|
|
204
|
+
}, n == null || n.setSpeechText(d.text), (o = h == null ? void 0 : h.speechSynthesis) == null || o.speak(d, null)) : (T = h == null ? void 0 : h.speechSynthesis) == null || T.cancel();
|
|
205
|
+
}, [d]), l(() => {
|
|
206
|
+
n && (n.visemeIntensity = k);
|
|
207
|
+
}, [k]), l(() => {
|
|
208
|
+
c || n && t === z.speaking && rt(be(n, m, C, U));
|
|
209
|
+
}, [t, m, n, c]), l(() => {
|
|
210
|
+
n && (t === z.speaking ? c && Ce(n, h) : n.disconnectAudio());
|
|
211
|
+
}, [t, n]), l(() => {
|
|
212
|
+
t !== z.speaking && it();
|
|
1027
213
|
}, [t]), null;
|
|
1028
|
-
},
|
|
1029
|
-
const
|
|
1030
|
-
const
|
|
1031
|
-
return new
|
|
214
|
+
}, ut = ({ points: e, color: t = "red" }) => {
|
|
215
|
+
const n = _(() => {
|
|
216
|
+
const r = new R.BufferGeometry().setFromPoints(e), d = new R.LineBasicMaterial({ color: t, toneMapped: !1 });
|
|
217
|
+
return new R.Line(r, d);
|
|
1032
218
|
}, [e, t]);
|
|
1033
|
-
return /* @__PURE__ */
|
|
1034
|
-
},
|
|
1035
|
-
const
|
|
219
|
+
return /* @__PURE__ */ i.createElement("primitive", { object: n });
|
|
220
|
+
}, dt = async (e) => {
|
|
221
|
+
const t = new R.WebGPURenderer({
|
|
222
|
+
canvas: e,
|
|
223
|
+
antialias: !1,
|
|
224
|
+
alpha: !0,
|
|
225
|
+
powerPreference: "high-performance"
|
|
226
|
+
});
|
|
227
|
+
return t.setClearColor(new R.Color("#000000"), 0), t.setPixelRatio(Math.min(devicePixelRatio, 1.5)), t.shadowMap.type = R.PCFShadowMap, t.forceContextLoss = () => {
|
|
228
|
+
t.dispose();
|
|
229
|
+
}, await t.init(), t;
|
|
230
|
+
}, gt = ({ parentGpuTier: e, setIsGpuAvailable: t, children: n, tonemapping: r, inspector: d = !1 }) => {
|
|
231
|
+
const s = M((a) => a.cameraPosition), m = M((a) => a.lookAt), k = M((a) => a.movable), C = F((a) => a.targets), c = F((a) => a.showFirstTarget), [w, P] = A(e || Ve()), [E, D] = A(
|
|
1036
232
|
"low"
|
|
1037
233
|
/* low */
|
|
1038
|
-
), [
|
|
1039
|
-
|
|
234
|
+
), [h, U] = A(null), [o, T] = A(void 0), y = X(null), [I, H] = A(null), G = X(null), b = (a) => {
|
|
235
|
+
a.preventDefault(), a.stopPropagation();
|
|
1040
236
|
};
|
|
1041
|
-
|
|
1042
|
-
var
|
|
1043
|
-
if (
|
|
1044
|
-
|
|
237
|
+
l(() => {
|
|
238
|
+
var a, v, V, u;
|
|
239
|
+
if (k)
|
|
240
|
+
h == null || h.abort(), U(null);
|
|
1045
241
|
else {
|
|
1046
|
-
const
|
|
1047
|
-
|
|
242
|
+
const x = new AbortController();
|
|
243
|
+
U(x), (a = y.current) == null || a.addEventListener("wheel", b, { passive: !1, signal: x.signal }), (v = y.current) == null || v.addEventListener("pointerdown", b, { passive: !1, signal: x.signal }), (V = y.current) == null || V.addEventListener("pointermove", b, { passive: !1, signal: x.signal }), (u = y.current) == null || u.addEventListener("click", b, { passive: !1, signal: x.signal });
|
|
1048
244
|
}
|
|
1049
|
-
}, [
|
|
1050
|
-
if (
|
|
1051
|
-
const
|
|
1052
|
-
|
|
245
|
+
}, [k]), l(() => {
|
|
246
|
+
if (I && m && s) {
|
|
247
|
+
const a = G.current === I;
|
|
248
|
+
I.setLookAt(s.x, s.y, s.z, m.x, m.y, m.z, a), G.current = I;
|
|
1053
249
|
}
|
|
1054
|
-
}, [
|
|
1055
|
-
e &&
|
|
1056
|
-
}, [e]),
|
|
1057
|
-
if (
|
|
1058
|
-
if (
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1061
|
-
|
|
250
|
+
}, [I, s, m]), l(() => {
|
|
251
|
+
e && P(e);
|
|
252
|
+
}, [e]), l(() => {
|
|
253
|
+
if (w)
|
|
254
|
+
if (w.type === "FALLBACK") {
|
|
255
|
+
const a = typeof navigator < "u" && /Macintosh|Mac OS X/.test(navigator.userAgent);
|
|
256
|
+
D(
|
|
257
|
+
a ? "medium" : "low"
|
|
1062
258
|
/* low */
|
|
1063
259
|
);
|
|
1064
260
|
} else
|
|
1065
|
-
switch (
|
|
261
|
+
switch (w.tier) {
|
|
1066
262
|
case 0:
|
|
1067
263
|
case 1:
|
|
1068
|
-
|
|
264
|
+
D(
|
|
1069
265
|
"low"
|
|
1070
266
|
/* low */
|
|
1071
267
|
);
|
|
1072
268
|
break;
|
|
1073
269
|
case 2:
|
|
1074
|
-
|
|
270
|
+
D(
|
|
1075
271
|
"medium"
|
|
1076
272
|
/* medium */
|
|
1077
273
|
);
|
|
1078
274
|
break;
|
|
1079
275
|
case 3:
|
|
1080
|
-
|
|
276
|
+
D(
|
|
1081
277
|
"high"
|
|
1082
278
|
/* high */
|
|
1083
279
|
);
|
|
1084
280
|
break;
|
|
1085
281
|
default:
|
|
1086
|
-
|
|
282
|
+
D(
|
|
1087
283
|
"low"
|
|
1088
284
|
/* low */
|
|
1089
285
|
);
|
|
1090
286
|
break;
|
|
1091
287
|
}
|
|
1092
|
-
}, [
|
|
1093
|
-
switch (
|
|
288
|
+
}, [w]), l(() => {
|
|
289
|
+
switch (E && (f.current = E), E) {
|
|
1094
290
|
case "low":
|
|
1095
291
|
console.warn("Retorik React-Bodyengine-Three > GPU tier too low, no rendering available"), t(!1);
|
|
1096
292
|
break;
|
|
1097
293
|
case "medium":
|
|
1098
|
-
|
|
294
|
+
T([0.8, 1]), console.log(`Retorik React-Bodyengine-Three > GPU tier detected : ${E}`), t(!0);
|
|
1099
295
|
break;
|
|
1100
296
|
case "high":
|
|
1101
|
-
|
|
297
|
+
T([1, 1.5]), console.log(`Retorik React-Bodyengine-Three > GPU tier detected : ${E}`), t(!0);
|
|
1102
298
|
break;
|
|
1103
299
|
}
|
|
1104
|
-
}, [
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
return S.setClearColor(new B.Color("#000000"), 0), S.setPixelRatio(Math.min(devicePixelRatio, 1.5)), S.shadowMap.type = B.PCFShadowMap, await S.init(), S;
|
|
1113
|
-
}, []), N = it(() => {
|
|
1114
|
-
if (T.length) {
|
|
1115
|
-
const u = T[0], S = new B.Vector3(u.position.x - 0.5, u.position.y, u.position.z - 0.1), M = new B.Vector3(u.position.x + 0.5, u.position.y, u.position.z - 0.1);
|
|
1116
|
-
return [S, M];
|
|
1117
|
-
} else if (o) {
|
|
1118
|
-
const u = new B.Vector3(o.x - 0.5, o.y, o.z - 0.1), S = new B.Vector3(o.x + 0.5, o.y, o.z - 0.1);
|
|
1119
|
-
return [u, S];
|
|
300
|
+
}, [E]);
|
|
301
|
+
const f = X(void 0), L = X(null), O = pe((a) => ((!L.current || L.current.canvas !== a.canvas) && (L.current = { canvas: a.canvas, renderer: dt(a.canvas) }), L.current.renderer), []), W = _(() => {
|
|
302
|
+
if (C.length) {
|
|
303
|
+
const a = C[0], v = new R.Vector3(a.position.x - 0.5, a.position.y, a.position.z - 0.1), V = new R.Vector3(a.position.x + 0.5, a.position.y, a.position.z - 0.1);
|
|
304
|
+
return [v, V];
|
|
305
|
+
} else if (s) {
|
|
306
|
+
const a = new R.Vector3(s.x - 0.5, s.y, s.z - 0.1), v = new R.Vector3(s.x + 0.5, s.y, s.z - 0.1);
|
|
307
|
+
return [a, v];
|
|
1120
308
|
}
|
|
1121
309
|
return [];
|
|
1122
|
-
}, [
|
|
1123
|
-
return
|
|
310
|
+
}, [C, s]);
|
|
311
|
+
return o ? (
|
|
1124
312
|
// "percentage" = PCFShadowMap; shadows={true} would make R3F set the removed PCFSoftShadowMap
|
|
1125
|
-
/* @__PURE__ */
|
|
1126
|
-
) : /* @__PURE__ */
|
|
1127
|
-
},
|
|
1128
|
-
const [
|
|
1129
|
-
return
|
|
1130
|
-
|
|
1131
|
-
}, [
|
|
1132
|
-
|
|
1133
|
-
}, [
|
|
1134
|
-
if (!
|
|
1135
|
-
let
|
|
1136
|
-
return import("three/addons/inspector/Inspector.js").then(({ Inspector:
|
|
1137
|
-
|
|
1138
|
-
}).catch((
|
|
1139
|
-
|
|
313
|
+
/* @__PURE__ */ i.createElement(Be, { gl: O, dpr: o, ref: y, shadows: "percentage" }, /* @__PURE__ */ i.createElement(xe, { iterations: 5, ms: 100, threshold: 0.75 }, /* @__PURE__ */ i.createElement(ht, { tonemapping: r, processedTier: E, inspector: d }), /* @__PURE__ */ i.createElement(mt, null), /* @__PURE__ */ i.createElement(Fe, { ref: Xe, makeDefault: !0, fov: 28 }), /* @__PURE__ */ i.createElement(Ie, { ref: H }), c && W.length && /* @__PURE__ */ i.createElement(ut, { points: W, color: "red" }), /* @__PURE__ */ i.createElement(fe, { fallback: null }, n)))
|
|
314
|
+
) : /* @__PURE__ */ i.createElement(i.Fragment, null);
|
|
315
|
+
}, ht = ({ tonemapping: e, processedTier: t, inspector: n = !1 }) => {
|
|
316
|
+
const [r, d] = A(!1), { gl: s, scene: m, camera: k, size: C } = Ue(), [c] = A(new R.Vector3(-3, 2, 2)), [w] = A(new R.Vector3(0, 1, 0)), [P] = A(3.5), [E] = A(-2e-4), [D] = A(0.57), [h] = A(0.25), U = X(null), o = X(null);
|
|
317
|
+
return l(() => {
|
|
318
|
+
s && (s.shadowMap.type = R.PCFShadowMap, s.toneMapping = e, t !== "low" ? m.environmentIntensity = h : m.environmentIntensity = 1);
|
|
319
|
+
}, [s, e]), l(() => {
|
|
320
|
+
m.environmentIntensity = h;
|
|
321
|
+
}, [h]), l(() => {
|
|
322
|
+
if (!n || !s || r) return;
|
|
323
|
+
let T = !1;
|
|
324
|
+
return import("three/addons/inspector/Inspector.js").then(({ Inspector: y }) => {
|
|
325
|
+
T || (s.inspector = new y(), d(!0));
|
|
326
|
+
}).catch((y) => console.warn("Scene: could not load three's Inspector", y)), () => {
|
|
327
|
+
T = !0;
|
|
1140
328
|
};
|
|
1141
|
-
}, [
|
|
1142
|
-
if (!
|
|
1143
|
-
|
|
1144
|
-
const
|
|
1145
|
-
if (
|
|
1146
|
-
const
|
|
1147
|
-
|
|
1148
|
-
},
|
|
1149
|
-
if (
|
|
1150
|
-
const
|
|
1151
|
-
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
}),
|
|
1155
|
-
|
|
329
|
+
}, [n, s, r]), l(() => {
|
|
330
|
+
if (!s || !m || !k || !t) return;
|
|
331
|
+
m.background = null;
|
|
332
|
+
const T = t === "high", y = { inspector: n && r && !!s.inspector }, I = T ? we(m, k, y) : Pe(m, k, y), { outputNode: H, scenePassColor: G, traaPass: b, giPass: f, ao: L, gi: O, hairAO: W, eyeAO: a } = I, v = new R.RenderPipeline(s);
|
|
333
|
+
if (v.outputNode = H, o.current = v, n && r && s.inspector) {
|
|
334
|
+
const V = () => {
|
|
335
|
+
v.needsUpdate = !0;
|
|
336
|
+
}, u = s.inspector.createParameters(T ? "SSGI + TRAA" : "TRAA");
|
|
337
|
+
if (T) {
|
|
338
|
+
const x = { output: 0, feedback: !1 }, ee = { Combined: 0, AO: 1, GI: 2, Direct: 3 };
|
|
339
|
+
u.add(x, "output", ee).name("output").onChange((Q) => {
|
|
340
|
+
const Y = Number(Q);
|
|
341
|
+
v.outputNode = Y === 1 ? oe(ze(L.r), 1) : Y === 2 ? oe(O.rgb, 1) : Y === 3 ? G : H, V();
|
|
342
|
+
}), u.add(f.sliceCount, "value", 1, 4, 1).name("slice count"), u.add(f.stepCount, "value", 1, 32, 1).name("step count"), u.add(f.radius, "value", 0.1, 2).name("radius"), u.add(f.expFactor, "value", 1e-3, 10).name("exp factor"), u.add(f.thickness, "value", 1e-3, 0.1).name("thickness"), u.add(f.backfaceLighting, "value", 0, 1).name("backface lighting"), u.add(f.aoIntensity, "value", 0, 4).name("AO intensity"), u.add(f.giIntensity, "value", 0, 20).name("GI intensity"), u.add(f, "resolutionScale", 0.25, 1).name("SSGI resolution scale"), u.add(W, "value", 0, 1).name("SSGI AO on hair"), u.add(a, "value", 0, 1).name("SSGI AO on eyes"), u.add(x, "feedback").name("SSGI 2nd bounce (TRAA history)").onChange((Q) => {
|
|
343
|
+
f.beautyNode = Q ? b.getHistoryTextureNode() : G, V();
|
|
1156
344
|
});
|
|
1157
345
|
}
|
|
1158
|
-
|
|
346
|
+
u.add(b, "maxVelocityLength", 4, 128, 1).name("TRAA max velocity").onChange(V), u.add(b, "depthThreshold", 1e-4, 0.01).name("TRAA depth threshold").onChange(V), u.add(b, "edgeDepthDiff", 1e-4, 0.01).name("TRAA edge depth diff").onChange(V), u.add(b, "useSubpixelCorrection").name("TRAA subpixel correction").onChange(V), u.add(b.maskedMotionWeight, "value", 0, 1, 0.01).name("TRAA hair motion weight"), u.add(b.maskedClipWidening, "value", 0, 2, 0.05).name("TRAA hair clip widening (still)"), u.add(b.maskedClipFadeVelocity, "value", 0.05, 4, 0.05).name("TRAA hair clip fade (px/frame)");
|
|
1159
347
|
}
|
|
1160
348
|
return () => {
|
|
1161
|
-
|
|
349
|
+
v.dispose(), o.current = null;
|
|
1162
350
|
};
|
|
1163
|
-
}, [
|
|
1164
|
-
!
|
|
1165
|
-
}, [
|
|
1166
|
-
|
|
1167
|
-
}, 1), /* @__PURE__ */
|
|
1168
|
-
},
|
|
1169
|
-
const
|
|
1170
|
-
return
|
|
1171
|
-
const
|
|
1172
|
-
deltaTime:
|
|
1173
|
-
timestamp:
|
|
1174
|
-
AU:
|
|
1175
|
-
gaze:
|
|
1176
|
-
headPose:
|
|
1177
|
-
characterState:
|
|
1178
|
-
lookAt:
|
|
1179
|
-
targets:
|
|
351
|
+
}, [s, m, k, t, n, r]), l(() => {
|
|
352
|
+
!s || !C || s.setSize(C.width, C.height);
|
|
353
|
+
}, [C]), ge(({ gl: T, scene: y, camera: I }) => {
|
|
354
|
+
o.current && o.current.render();
|
|
355
|
+
}, 1), /* @__PURE__ */ i.createElement(i.Fragment, null, t !== "low" && s && /* @__PURE__ */ i.createElement(i.Fragment, null, /* @__PURE__ */ i.createElement("directionalLight", { ref: U, color: "white", position: c.toArray(), "target-position": w.toArray(), intensity: P, castShadow: !0, "shadow-mapSize-width": 1024, "shadow-mapSize-height": 1024, "shadow-bias": E, "shadow-normalBias": 3e-3, "shadow-intensity": 0.6, "shadow-radius": 2.5 }, /* @__PURE__ */ i.createElement("orthographicCamera", { attach: "shadow-camera", args: [-1, 1, 2, -0.5, 2, 5] })), t === "high" && /* @__PURE__ */ i.createElement("directionalLight", { name: "RimLight", color: "#fff4e8", position: [0.9, 2.3, -3.2], "target-position": [0, 1.6, 0], intensity: D })));
|
|
356
|
+
}, St = ({ character: e, autoLookAt: t }) => {
|
|
357
|
+
const n = g((c) => c.characterState), r = F((c) => c.currentAUs), d = F((c) => c.currentGaze), s = F((c) => c.currentHeadPose), m = F((c) => c.lookAtCamera), k = M((c) => c.cameraPosition), C = F((c) => c.targets);
|
|
358
|
+
return ge((c, w) => {
|
|
359
|
+
const P = {
|
|
360
|
+
deltaTime: w,
|
|
361
|
+
timestamp: c.clock.oldTime,
|
|
362
|
+
AU: r,
|
|
363
|
+
gaze: d,
|
|
364
|
+
headPose: s,
|
|
365
|
+
characterState: n,
|
|
366
|
+
lookAt: m ? k : void 0,
|
|
367
|
+
targets: C
|
|
1180
368
|
};
|
|
1181
|
-
e.update(
|
|
1182
|
-
}),
|
|
369
|
+
e.update(P);
|
|
370
|
+
}), l(() => {
|
|
1183
371
|
if (t)
|
|
1184
|
-
switch (
|
|
1185
|
-
case
|
|
1186
|
-
case
|
|
1187
|
-
|
|
372
|
+
switch (n) {
|
|
373
|
+
case z.idle:
|
|
374
|
+
case z.waiting:
|
|
375
|
+
se(!1);
|
|
1188
376
|
break;
|
|
1189
|
-
case
|
|
1190
|
-
case
|
|
1191
|
-
|
|
377
|
+
case z.listening:
|
|
378
|
+
case z.speaking:
|
|
379
|
+
se(!0);
|
|
1192
380
|
break;
|
|
1193
381
|
}
|
|
1194
382
|
else
|
|
1195
|
-
|
|
1196
|
-
}, [
|
|
1197
|
-
|
|
383
|
+
se(!1);
|
|
384
|
+
}, [n, t]), l(() => {
|
|
385
|
+
We(e);
|
|
1198
386
|
}, [e]), null;
|
|
1199
|
-
},
|
|
1200
|
-
|
|
1201
|
-
|
|
387
|
+
}, pt = {
|
|
388
|
+
emotions: [],
|
|
389
|
+
currentTopEmotion: de.Neutral,
|
|
390
|
+
useTopEmotionOnly: !0,
|
|
391
|
+
autoDecay: !1
|
|
392
|
+
}, j = J()(() => pt), Gt = (e) => {
|
|
393
|
+
if (j.setState({ emotions: e || [] }), e != null && e.length) {
|
|
394
|
+
const t = e.reduce((n, r) => n.value > r.value ? n : r);
|
|
395
|
+
j.setState({ currentTopEmotion: t.emotion });
|
|
396
|
+
} else
|
|
397
|
+
j.setState({ currentTopEmotion: de.Neutral });
|
|
398
|
+
}, Ot = (e) => {
|
|
399
|
+
j.setState({ useTopEmotionOnly: e });
|
|
400
|
+
}, Nt = (e) => {
|
|
401
|
+
j.setState({ autoDecay: e });
|
|
402
|
+
}, Ht = (e) => {
|
|
403
|
+
const t = g.getState().FACSManager;
|
|
404
|
+
t == null || t.playFacialAnimation({ ...e });
|
|
405
|
+
}, ft = ({ animationsLoaded: e }) => {
|
|
406
|
+
const t = j((r) => r.emotions), n = j((r) => r.useTopEmotionOnly);
|
|
407
|
+
return l(() => {
|
|
408
|
+
e && _e(Me(t, { topOnly: n }));
|
|
409
|
+
}, [t, n, e]), null;
|
|
410
|
+
}, Kt = ({ url: e, type: t, animationsUrl: n, gender: r, speechSynthesis: d, camera: s, onLoadingCompleted: m, autoLookAt: k, breathing: C, disableAnimations: c, debug: w, inspector: P, enableBml: E, animationWeights: D, license: h, detectGpuData: U, environmentPreset: o = "apartment", tonemapping: T = R.NeutralToneMapping, targets: y, lipSyncFromAudio: I = !1, lipSyncAudio: H, lipSyncAudioContext: G }) => {
|
|
411
|
+
const b = g((S) => S.animationsLoaded), f = M((S) => S.defaultPositions), L = M((S) => S.defaultDistances), [O, W] = A(), [a, v] = A(null), [V, u] = A(), [x, ee] = A(!1), Q = async (S, K) => {
|
|
412
|
+
let N = null;
|
|
1202
413
|
switch (t) {
|
|
1203
|
-
case
|
|
1204
|
-
|
|
414
|
+
case $.cc3:
|
|
415
|
+
N = new De(), u(ne.cc3);
|
|
1205
416
|
break;
|
|
1206
|
-
case
|
|
1207
|
-
|
|
417
|
+
case $.avatarsdk:
|
|
418
|
+
N = new ve(), u(ne.avatarsdk);
|
|
1208
419
|
break;
|
|
1209
|
-
case
|
|
1210
|
-
|
|
420
|
+
case $.avaturn:
|
|
421
|
+
N = new Re(), u(ne.avaturn);
|
|
1211
422
|
break;
|
|
1212
423
|
}
|
|
1213
|
-
const
|
|
1214
|
-
if (
|
|
1215
|
-
let
|
|
1216
|
-
const
|
|
1217
|
-
mesh:
|
|
1218
|
-
onAnimationsLoaded:
|
|
1219
|
-
animationsUrl:
|
|
1220
|
-
gender:
|
|
424
|
+
const Z = await N.loadAsync(S).catch((B) => console.warn("Error loading character : ", B));
|
|
425
|
+
if (Z && !K()) {
|
|
426
|
+
let B = null;
|
|
427
|
+
const te = {
|
|
428
|
+
mesh: Z,
|
|
429
|
+
onAnimationsLoaded: Y,
|
|
430
|
+
animationsUrl: n,
|
|
431
|
+
gender: r || "male",
|
|
1221
432
|
type: t,
|
|
1222
|
-
debug:
|
|
1223
|
-
enableBmlManager: !!
|
|
1224
|
-
animationWeights:
|
|
1225
|
-
|
|
1226
|
-
license: R
|
|
433
|
+
debug: w,
|
|
434
|
+
enableBmlManager: !!E,
|
|
435
|
+
animationWeights: D,
|
|
436
|
+
license: h
|
|
1227
437
|
};
|
|
1228
438
|
switch (t) {
|
|
1229
|
-
case
|
|
1230
|
-
|
|
439
|
+
case $.cc3:
|
|
440
|
+
B = await ae.fromCharacterCreator(te);
|
|
1231
441
|
break;
|
|
1232
|
-
case
|
|
1233
|
-
|
|
442
|
+
case $.avatarsdk:
|
|
443
|
+
B = await ae.fromAvatarSDK(te);
|
|
1234
444
|
break;
|
|
1235
|
-
case
|
|
1236
|
-
|
|
445
|
+
case $.avaturn:
|
|
446
|
+
B = await ae.fromAvaturn(te);
|
|
1237
447
|
break;
|
|
1238
448
|
}
|
|
1239
|
-
|
|
449
|
+
B && K() ? B.dispose() : B && v(B);
|
|
1240
450
|
}
|
|
1241
|
-
},
|
|
1242
|
-
|
|
451
|
+
}, Y = () => {
|
|
452
|
+
ie(!0);
|
|
1243
453
|
};
|
|
1244
|
-
|
|
1245
|
-
var
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
454
|
+
l(() => {
|
|
455
|
+
var S, K;
|
|
456
|
+
if (a && b)
|
|
457
|
+
if (C === !1 && ((K = (S = a.animationManager) == null ? void 0 : S.disableBreathing) == null || K.call(S)), x) {
|
|
458
|
+
nt(a.getAllAnimationNames()), at(a.getAllAnimations());
|
|
459
|
+
const N = setTimeout(() => {
|
|
460
|
+
m == null || m();
|
|
461
|
+
}, 1e3);
|
|
462
|
+
return () => clearTimeout(N);
|
|
463
|
+
} else
|
|
464
|
+
Se();
|
|
465
|
+
}, [a, b, x]), l(() => {
|
|
466
|
+
Ze(y || []);
|
|
467
|
+
}, [y]), l(() => {
|
|
468
|
+
ie(!1);
|
|
469
|
+
let S = !1;
|
|
470
|
+
return O !== void 0 && (O ? Q(e, () => S) : m == null || m()), () => {
|
|
471
|
+
S = !0;
|
|
472
|
+
};
|
|
473
|
+
}, [e, O]), l(() => () => {
|
|
474
|
+
a == null || a.dispose();
|
|
475
|
+
}, [a]), l(() => {
|
|
476
|
+
if (x && L && f)
|
|
477
|
+
if (s) {
|
|
478
|
+
const S = Ee(s, L, f);
|
|
479
|
+
le(S), me(s.lookAt ? f[s.lookAt] : f.lowerbelly), Ye(!!s.movable);
|
|
1258
480
|
} else {
|
|
1259
|
-
const
|
|
1260
|
-
|
|
481
|
+
const S = f.mouth.clone();
|
|
482
|
+
S.setComponent(2, L.farther), le(S), me(f.lowerbelly);
|
|
1261
483
|
}
|
|
1262
|
-
}, [
|
|
1263
|
-
|
|
1264
|
-
}, [
|
|
1265
|
-
|
|
1266
|
-
}, [
|
|
1267
|
-
|
|
1268
|
-
|
|
484
|
+
}, [x, s, L, f]), l(() => {
|
|
485
|
+
d && (d.credentials && st(d.credentials), d.voice && ct(d.voice));
|
|
486
|
+
}, [d]), l(() => {
|
|
487
|
+
lt(I);
|
|
488
|
+
}, [I]), l(() => {
|
|
489
|
+
a == null || a.lipSyncManager.setAudioSource(H ?? null, G);
|
|
490
|
+
}, [a, H, G]);
|
|
491
|
+
const Se = () => {
|
|
492
|
+
if (a && V) {
|
|
1269
493
|
try {
|
|
1270
|
-
const
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
x: ne,
|
|
1275
|
-
y: K,
|
|
1276
|
-
z: ue
|
|
1277
|
-
});
|
|
1278
|
-
const Z = (_.x + L.x) / 2, F = (_.z + L.z) / 2, me = {
|
|
1279
|
-
eye: new B.Vector3(Z, _.y - K / 16, F),
|
|
1280
|
-
mouth: new B.Vector3(Z, _.y - K / 12, F),
|
|
1281
|
-
neck: new B.Vector3(Z, _.y - K / 8, F),
|
|
1282
|
-
clavicle: new B.Vector3(Z, _.y - K / 6, F),
|
|
1283
|
-
torso: new B.Vector3(Z, _.y - K / 4, F),
|
|
1284
|
-
belly: new B.Vector3(Z, _.y - K / 8 * 3, F),
|
|
1285
|
-
lowerbelly: new B.Vector3(Z, _.y - K / 32 * 15, F),
|
|
1286
|
-
hips: H,
|
|
1287
|
-
higherthigh: new B.Vector3(Z, L.y + K / 32 * 15, F),
|
|
1288
|
-
thigh: new B.Vector3(Z, L.y + K / 8 * 3, F),
|
|
1289
|
-
knee: new B.Vector3(Z, L.y + K / 4, F),
|
|
1290
|
-
leg: new B.Vector3(Z, L.y + K / 8, F),
|
|
1291
|
-
feet: new B.Vector3(Z, L.y, F)
|
|
1292
|
-
}, te = (_.y - (L.y + K / 7 * 2)) / 2 / Math.tan(25 * (Math.PI / 180)), Ce = {
|
|
1293
|
-
veryclose: te / 4,
|
|
1294
|
-
closer: te / 3,
|
|
1295
|
-
close: te / 2.5,
|
|
1296
|
-
midclose: te / 2,
|
|
1297
|
-
medium: te,
|
|
1298
|
-
midfar: te * 2,
|
|
1299
|
-
far: te * 2.5,
|
|
1300
|
-
farther: te * 3,
|
|
1301
|
-
veryfar: te * 4
|
|
1302
|
-
};
|
|
1303
|
-
Js(me), en(Ce);
|
|
1304
|
-
} catch (P) {
|
|
1305
|
-
console.warn(P);
|
|
494
|
+
const { center: S, dimensions: K, defaultPositions: N, defaultDistances: Z } = Te(a);
|
|
495
|
+
qe(S), $e(K), Je(N), Qe(Z);
|
|
496
|
+
} catch (S) {
|
|
497
|
+
console.warn(S);
|
|
1306
498
|
}
|
|
1307
|
-
|
|
499
|
+
ee(!0);
|
|
1308
500
|
}
|
|
1309
501
|
};
|
|
1310
|
-
return /* @__PURE__ */
|
|
1311
|
-
}, Hn = {
|
|
1312
|
-
emotions: [],
|
|
1313
|
-
currentTopEmotion: lt.Neutral,
|
|
1314
|
-
useTopEmotionOnly: !0,
|
|
1315
|
-
autoDecay: !1
|
|
1316
|
-
}, Ve = we()(() => Hn), So = (e) => {
|
|
1317
|
-
if (Ve.setState({ emotions: e || [] }), e != null && e.length) {
|
|
1318
|
-
const t = e.reduce((s, a) => s.value > a.value ? s : a);
|
|
1319
|
-
Ve.setState({ currentTopEmotion: t.emotion });
|
|
1320
|
-
} else
|
|
1321
|
-
Ve.setState({ currentTopEmotion: lt.Neutral });
|
|
1322
|
-
}, bo = (e) => {
|
|
1323
|
-
Ve.setState({ useTopEmotionOnly: e });
|
|
1324
|
-
}, To = (e) => {
|
|
1325
|
-
Ve.setState({ autoDecay: e });
|
|
1326
|
-
}, vo = (e) => {
|
|
1327
|
-
const t = O.getState().FACSManager;
|
|
1328
|
-
t == null || t.playFacialAnimation({ ...e });
|
|
502
|
+
return /* @__PURE__ */ i.createElement(gt, { parentGpuTier: U, setIsGpuAvailable: W, tonemapping: T, inspector: P }, O ? /* @__PURE__ */ i.createElement(i.Fragment, null, a && /* @__PURE__ */ i.createElement(St, { character: a, autoLookAt: !!k }), a && /* @__PURE__ */ i.createElement(ft, { animationsLoaded: b }), a && /* @__PURE__ */ i.createElement(i.Fragment, null, /* @__PURE__ */ i.createElement(Le, { preset: o }), /* @__PURE__ */ i.createElement("primitive", { object: a, castShadow: !0, receiveShadow: !0 }))) : /* @__PURE__ */ i.createElement(i.Fragment, null));
|
|
1329
503
|
};
|
|
1330
504
|
export {
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
vn as setVoice,
|
|
1373
|
-
O as useCharacterStore
|
|
505
|
+
Kt as Character,
|
|
506
|
+
qt as CharacterState,
|
|
507
|
+
Jt as CreationTool,
|
|
508
|
+
Qt as Distances,
|
|
509
|
+
$t as Object3D,
|
|
510
|
+
Yt as Positions,
|
|
511
|
+
Zt as Rotations,
|
|
512
|
+
Lt as addSPPASViseme,
|
|
513
|
+
he as addViseme,
|
|
514
|
+
_t as bmlTags,
|
|
515
|
+
en as emotionList,
|
|
516
|
+
it as flushLipSyncData,
|
|
517
|
+
Vt as getAnimationsMap,
|
|
518
|
+
Et as getCameraPosition,
|
|
519
|
+
Mt as getCharacterHeight,
|
|
520
|
+
Tt as getLookAt,
|
|
521
|
+
Bt as getVoices,
|
|
522
|
+
et as lookAtAndKeep,
|
|
523
|
+
Ft as playAnimationByName,
|
|
524
|
+
Ht as playFacialAnimation,
|
|
525
|
+
tn as presets,
|
|
526
|
+
tt as releaseLookAt,
|
|
527
|
+
Nt as setAutoDecay,
|
|
528
|
+
xt as setAutoPlay,
|
|
529
|
+
le as setCameraPosition,
|
|
530
|
+
ce as setCharacterState,
|
|
531
|
+
_e as setCurrentAUs,
|
|
532
|
+
Rt as setCurrentGaze,
|
|
533
|
+
vt as setCurrentHeadPose,
|
|
534
|
+
ot as setCurrentUtterance,
|
|
535
|
+
Gt as setEmotions,
|
|
536
|
+
lt as setLipSyncFromAudio,
|
|
537
|
+
se as setLookAtCamera,
|
|
538
|
+
Ye as setMovable,
|
|
539
|
+
Dt as setShowFirstTarget,
|
|
540
|
+
zt as setTextToSpeak,
|
|
541
|
+
Ot as setUseTopEmotionOnly,
|
|
542
|
+
Ut as setVisemeIntensity,
|
|
543
|
+
It as setVisemes,
|
|
544
|
+
ct as setVoice,
|
|
545
|
+
g as useCharacterStore
|
|
1374
546
|
};
|