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