@vincentt-xr/sdk 2.0.0-alpha.7 → 2.0.0-alpha.8
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/GROUNDING.md +1109 -13
- package/dist/{DebuggerUI-BjOMr8q_.js → DebuggerUI-C-ldiozL.js} +1 -1
- package/dist/{DebuggerUI-B6bP6P9r.cjs → DebuggerUI-CWX5EtQv.cjs} +1 -1
- package/dist/FaceMeshRenderer-BEEXZwS6.cjs +158 -0
- package/dist/FaceMeshRenderer-UuH5sTXG.js +1322 -0
- package/dist/FaceRetouch-C7h7x9kd.js +683 -0
- package/dist/FaceRetouch-DqftT26Y.cjs +134 -0
- package/dist/GLTFLoader-C5q63sKO.js +1633 -0
- package/dist/GLTFLoader-Cb_CRwmG.cjs +1 -0
- package/dist/SegmentationOverlay-DQuW3dsc.js +133 -0
- package/dist/SegmentationOverlay-aWVod8Kl.cjs +1 -0
- package/dist/assets/cache.d.ts +99 -0
- package/dist/assets/estimate.d.ts +11 -0
- package/dist/assets/index.d.ts +7 -0
- package/dist/assets/loaders.d.ts +28 -0
- package/dist/assets/react.d.ts +33 -0
- package/dist/calibration/calibration.d.ts +70 -0
- package/dist/calibration/index.d.ts +6 -0
- package/dist/calibration/storage.d.ts +13 -0
- package/dist/calibration/types.d.ts +53 -0
- package/dist/calibration/useXRCalibration.d.ts +46 -0
- package/dist/camera/CameraPermissionGate.d.ts +26 -0
- package/dist/camera/devices.d.ts +26 -0
- package/dist/camera/index.d.ts +8 -0
- package/dist/camera/permission.d.ts +86 -0
- package/dist/camera/useCameraPermission.d.ts +35 -0
- package/dist/capabilities/detect.d.ts +45 -0
- package/dist/capabilities/index.d.ts +5 -0
- package/dist/capabilities/types.d.ts +120 -0
- package/dist/capabilities/useXRCapabilities.d.ts +18 -0
- package/dist/compat/environment.d.ts +5 -0
- package/dist/compat/index.d.ts +4 -0
- package/dist/compat/run.d.ts +18 -0
- package/dist/compat/scenarios.d.ts +10 -0
- package/dist/compat/types.d.ts +101 -0
- package/dist/components/BodyTracker/index.d.ts +9 -0
- package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +33 -3
- package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +12 -0
- package/dist/components/FaceMesh/canonical/shaders.d.ts +1 -1
- package/dist/components/FaceMesh/index.d.ts +1 -1
- package/dist/components/GestureListener/index.d.ts +11 -0
- package/dist/components/HandTracker/index.d.ts +10 -0
- package/dist/components/HolisticTracker/index.d.ts +69 -0
- package/dist/components/HolisticTracker/settings.d.ts +58 -0
- package/dist/components/HolisticTracker/signals.d.ts +49 -0
- package/dist/components/IrisEffect/IrisMaterial.d.ts +73 -0
- package/dist/components/IrisEffect/index.d.ts +51 -0
- package/dist/components/IrisEffect/settings.d.ts +117 -0
- package/dist/components/LipEffect/LipEffect.d.ts +7 -1
- package/dist/components/LipEffect/LipEffectMaterial.d.ts +43 -7
- package/dist/components/LipEffect/LipEffects.d.ts +9 -0
- package/dist/components/LipEffect/defaults.d.ts +27 -4
- package/dist/components/LipEffect/index.d.ts +11 -3
- package/dist/components/LipEffect/settings.d.ts +271 -0
- package/dist/components/LipEffect/types.d.ts +56 -9
- package/dist/components/LipEffect/useLipDesignTextures.d.ts +11 -0
- package/dist/components/LipEffect/uvGuide.d.ts +59 -0
- package/dist/components/PersonCutout/index.d.ts +50 -0
- package/dist/components/PersonCutout/personCutout.d.ts +16 -0
- package/dist/components/ScreenImage/components/ScreenImageBody.d.ts +1 -1
- package/dist/components/ScreenImage/index.d.ts +3 -1
- package/dist/components/ScreenImage/materials/ScreenImageBlendMaterial.d.ts +1 -1
- package/dist/components/ScreenImage/materials/ScreenImageMaskMaterial.d.ts +11 -0
- package/dist/components/ScreenImage/source.d.ts +6 -0
- package/dist/components/ScreenImage/types.d.ts +18 -0
- package/dist/components/SegmentationOverlay/SegmentationOverlay.d.ts +37 -0
- package/dist/components/SegmentationOverlay/SegmentationOverlayMaterial.d.ts +31 -0
- package/dist/components/SegmentationOverlay/index.d.ts +9 -0
- package/dist/components/SegmentationOverlay/maskTexture.d.ts +23 -0
- package/dist/components/SegmentationOverlay/providers.d.ts +72 -0
- package/dist/components/SegmentationOverlay/settings.d.ts +65 -0
- package/dist/components/XRProvider/index.d.ts +16 -2
- package/dist/components/XRViewport/hooks/useViewportExternalFaces.d.ts +1 -1
- package/dist/components/XRViewport/hooks/useViewportMediaSource.d.ts +1 -1
- package/dist/components/XRViewport/hooks/useViewportPipeline.d.ts +1 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/constants/index.d.ts +4 -1
- package/dist/contexts-CO0sd4JQ.cjs +1 -0
- package/dist/{contexts-ByhzppYl.js → contexts-FzlnnMYD.js} +252 -246
- package/dist/coordinates/feed.d.ts +52 -0
- package/dist/coordinates/index.d.ts +5 -0
- package/dist/coordinates/spaces.d.ts +49 -0
- package/dist/coordinates/viewport.d.ts +22 -0
- package/dist/coordinates/world.d.ts +15 -0
- package/dist/debug-ui/gesture-settings/index.d.ts +14 -0
- package/dist/debug-ui/holistic-tracker-settings/index.d.ts +16 -0
- package/dist/debug-ui/index.d.ts +14 -0
- package/dist/debug-ui/iris-effect-settings/index.d.ts +12 -0
- package/dist/debug-ui/lip-effect-settings/index.d.ts +15 -0
- package/dist/debug-ui/media-source.cjs +1 -1
- package/dist/debug-ui/media-source.js +1 -1
- package/dist/debug-ui/product-hotspots/index.d.ts +24 -0
- package/dist/debug-ui/segmentation-overlay-settings/index.d.ts +12 -0
- package/dist/debug-ui/xr-diagnostics/index.d.ts +25 -0
- package/dist/debug-ui.cjs +3 -3
- package/dist/debug-ui.js +2057 -1687
- package/dist/detector-K8aej4MB.js +59 -0
- package/dist/detector-ijypGtse.cjs +1 -0
- package/dist/entries/core.d.ts +18 -1
- package/dist/entries/face-effects.d.ts +11 -3
- package/dist/entries/low-level.d.ts +22 -3
- package/dist/entries/product.d.ts +11 -0
- package/dist/entries/tracking.d.ts +24 -1
- package/dist/face-effects.cjs +155 -1
- package/dist/face-effects.js +1134 -2197
- package/dist/gestures/definitions.d.ts +85 -0
- package/dist/gestures/detector.d.ts +87 -0
- package/dist/gestures/index.d.ts +8 -0
- package/dist/gestures/measures.d.ts +101 -0
- package/dist/gestures/settings.d.ts +49 -0
- package/dist/{getFaceInfo-C4QpCQIY.js → getFaceInfo-BkZfaQs-.js} +5 -5
- package/dist/{getFaceInfo-fA1bFBub.cjs → getFaceInfo-ahPxQFGu.cjs} +1 -1
- package/dist/hooks/selectors.d.ts +68 -1
- package/dist/hooks/useCalibrationFaceTracker.d.ts +1 -1
- package/dist/hooks/useFaceInfo.d.ts +13 -1
- package/dist/hooks/useFaceInfos.d.ts +1 -1
- package/dist/hooks/useGesture.d.ts +32 -0
- package/dist/hooks/useIrisTracking.d.ts +45 -0
- package/dist/hooks/useXRDiagnostics.d.ts +81 -0
- package/dist/hooks/useXRModel.d.ts +7 -0
- package/dist/hooks/useXRSession/facade.d.ts +42 -2
- package/dist/hooks/useXRSession/index.d.ts +2 -2
- package/dist/hooks/useXRSession/reason.d.ts +3 -1
- package/dist/hooks/useXRSession/registry.d.ts +14 -0
- package/dist/hooks/useXRSession/store.d.ts +52 -3
- package/dist/index--RgGzZ6X.cjs +47 -0
- package/dist/{index-VJ0SJwmG.js → index-CHVbH0hz.js} +4 -4
- package/dist/index-CeVkgsag.cjs +1 -0
- package/dist/index-CnGox6Xr.js +3054 -0
- package/dist/{index-ByoNj0QP.js → index-CsUdQ-pn.js} +113 -111
- package/dist/{index-BjmTe9eM.cjs → index-DKBAh6hV.cjs} +1 -1
- package/dist/index-DsZwTfG0.cjs +1 -0
- package/dist/index-Dw6tj2Mi.js +144 -0
- package/dist/index-OCPjOaeP.cjs +1 -0
- package/dist/{index-DXT3WccE.js → index-s9pF4zkG.js} +1065 -1101
- package/dist/internal-BYza1h8_.cjs +1 -0
- package/dist/{internal-Dmk1cTXq.js → internal-vsfNQycj.js} +15 -16
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +2 -2
- package/dist/iris/compute.d.ts +25 -0
- package/dist/iris/index.d.ts +4 -0
- package/dist/iris/lead.d.ts +19 -0
- package/dist/iris/types.d.ts +87 -0
- package/dist/landmarkMask-CbTFzBYG.js +224 -0
- package/dist/landmarkMask-u7es2k4X.cjs +1 -0
- package/dist/low-level.cjs +1 -1
- package/dist/low-level.js +1085 -634
- package/dist/main.cjs +1 -1
- package/dist/main.js +1519 -465
- package/dist/measures-9dQPdw96.js +154 -0
- package/dist/measures-KfJzpvod.cjs +1 -0
- package/dist/models/Base/index.d.ts +49 -0
- package/dist/models/Body/index.d.ts +1 -1
- package/dist/models/Face/index.d.ts +1 -1
- package/dist/models/Hand/GestureTracking.d.ts +1 -1
- package/dist/models/Hand/HandTracking.d.ts +1 -1
- package/dist/models/Holistic/index.d.ts +49 -0
- package/dist/models/Holistic/result.d.ts +68 -0
- package/dist/models/SemanticSegmentation/index.d.ts +31 -0
- package/dist/models/SemanticSegmentation/presets.d.ts +28 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/product/ProductDimensions.d.ts +16 -0
- package/dist/product/ProductHotspot.d.ts +16 -0
- package/dist/product/ProductViewer.d.ts +9 -0
- package/dist/product/details.d.ts +53 -0
- package/dist/product/index.d.ts +14 -0
- package/dist/product/loadModelViewer.d.ts +4 -0
- package/dist/product/types.d.ts +71 -0
- package/dist/product/useProductAr.d.ts +37 -0
- package/dist/product/useProductDetails.d.ts +60 -0
- package/dist/product.cjs +1 -0
- package/dist/product.js +414 -0
- package/dist/providers-C0Dlhh9Z.js +365 -0
- package/dist/providers-YNwkmNeK.cjs +62 -0
- package/dist/quality/XRQualityController.d.ts +25 -0
- package/dist/quality/controller.d.ts +33 -0
- package/dist/quality/index.d.ts +6 -0
- package/dist/quality/types.d.ts +100 -0
- package/dist/quality/useXRQuality.d.ts +28 -0
- package/dist/{renderGroups-KZk6eRiY.js → renderGroups-CN1cGFUo.js} +1 -1
- package/dist/{renderGroups-80H3DpTl.cjs → renderGroups-O4KmaMl9.cjs} +1 -1
- package/dist/renderPasses-Cg-zqmEz.cjs +21 -0
- package/dist/renderPasses-NnKZVfBy.js +1460 -0
- package/dist/scene-object.cjs +1 -1
- package/dist/scene-object.js +2 -2
- package/dist/screenTransform-BenfCtZt.js +44 -0
- package/dist/screenTransform-BiXdpVf0.cjs +1 -0
- package/dist/segmentation-9PhSvc-R.cjs +1 -0
- package/dist/segmentation-CeOTKemr.js +5 -0
- package/dist/segmentation2d/faceMemory.d.ts +28 -0
- package/dist/segmentation2d/faceRegions.d.ts +24 -0
- package/dist/segmentation2d/index.d.ts +9 -0
- package/dist/segmentation2d/maskUv.d.ts +23 -0
- package/dist/segmentation2d/rasterize.d.ts +14 -0
- package/dist/segmentation2d/types.d.ts +46 -0
- package/dist/selectors-C5G1PMYL.js +195 -0
- package/dist/selectors-Du_PsVnW.cjs +1 -0
- package/dist/{session-CpkiK5YA.cjs → session-BBr0yN8h.cjs} +7 -7
- package/dist/{session-DLFN_VII.js → session-Cy0m7l7-.js} +76 -76
- package/dist/settings-DRR7-snV.cjs +1 -0
- package/dist/settings-aQk845NJ.js +73 -0
- package/dist/subjects/index.d.ts +2 -0
- package/dist/subjects/select.d.ts +62 -0
- package/dist/subjects/types.d.ts +55 -0
- package/dist/tracking-config/apply.d.ts +57 -0
- package/dist/tracking-config/index.d.ts +7 -0
- package/dist/tracking-config/resolve.d.ts +25 -0
- package/dist/tracking-config/storage.d.ts +8 -0
- package/dist/tracking-config/types.d.ts +106 -0
- package/dist/tracking-config/useXRTrackingConfig.d.ts +38 -0
- package/dist/tracking.cjs +1 -1
- package/dist/tracking.js +1056 -383
- package/dist/types/compositor.d.ts +21 -0
- package/dist/types/holistic.d.ts +121 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/model.d.ts +22 -2
- package/dist/types/nodes.d.ts +27 -2
- package/dist/types/segmentation.d.ts +19 -0
- package/dist/types/session.d.ts +41 -3
- package/dist/useFaceInfo-Blf7FCu3.js +303 -0
- package/dist/useFaceInfo-C5mO8NQY.cjs +1 -0
- package/dist/useXRCapabilities-B1R2ghy-.cjs +1 -0
- package/dist/useXRCapabilities-C68v__wB.js +30 -0
- package/dist/utils/fns.d.ts +6 -3
- package/dist/utils/integrity.d.ts +4 -1
- package/dist/utils/updateThrottle.d.ts +2 -0
- package/dist/utils/useStableUniforms.d.ts +18 -0
- package/docs/api/adaptive-quality.mdx +104 -0
- package/docs/api/asset-lifecycle.mdx +78 -0
- package/docs/api/camera-permission.mdx +142 -0
- package/docs/api/coordinate-spaces.mdx +165 -0
- package/docs/api/cross-camera.mdx +88 -0
- package/docs/api/diagnostics-calibration.mdx +97 -0
- package/docs/api/face-effects.mdx +6 -0
- package/docs/api/face-mesh.mdx +4 -2
- package/docs/api/gestures.mdx +173 -0
- package/docs/api/holistic-tracker.mdx +159 -0
- package/docs/api/iris-tracking.mdx +242 -0
- package/docs/api/multi-subject.mdx +95 -0
- package/docs/api/person-cutout.mdx +136 -0
- package/docs/api/product-ar.mdx +111 -0
- package/docs/api/product-details.mdx +78 -0
- package/docs/api/screen-space-coordinates.mdx +4 -1
- package/docs/api/segmentation-overlay.mdx +301 -0
- package/docs/api/session-lifecycle.mdx +136 -0
- package/docs/api/trackers.mdx +5 -0
- package/docs/api/tracking-config.mdx +108 -0
- package/docs/docs.json +23 -1
- package/docs/examples/lip-shaders.mdx +224 -0
- package/docs/guides/lip-effect-textures.mdx +292 -0
- package/docs/guides/lip-uv-template.png +0 -0
- package/docs/guides/lip-uv-template.svg +1 -0
- package/package.json +13 -1
- package/dist/FaceMeshRenderer-C5l6VLdO.cjs +0 -155
- package/dist/FaceMeshRenderer-wjAHrJzP.js +0 -1270
- package/dist/FaceRetouch-BkJzoA79.cjs +0 -134
- package/dist/FaceRetouch-DwbKQJAN.js +0 -551
- package/dist/contexts-Dr62It_K.cjs +0 -1
- package/dist/index-9dlAQAhy.js +0 -1462
- package/dist/index-BpEf2BBb.cjs +0 -1
- package/dist/index-CyUUurQT.cjs +0 -1
- package/dist/index-DCiMbxC3.cjs +0 -1
- package/dist/index-DpI-qo5X.cjs +0 -17
- package/dist/index-DyVF4vEW.js +0 -111
- package/dist/internal-Cq-TEQ5Y.cjs +0 -1
- package/dist/renderLayers-lDtL0_43.cjs +0 -1
- package/dist/renderLayers-zrK2pv5O.js +0 -13
- package/dist/renderPasses-BOoBSr8z.cjs +0 -21
- package/dist/renderPasses-BcquyVtu.js +0 -1500
- package/dist/selectors-B8H97CKA.js +0 -59
- package/dist/selectors-CZLKT2Iv.cjs +0 -1
- package/dist/useFaceInfo-BJ8-_MOs.cjs +0 -1
- package/dist/useFaceInfo-Dk426LTu.js +0 -62
- package/dist/useFaceResults-CtetsO9M.js +0 -19
- package/dist/useFaceResults-wBJF3zyp.cjs +0 -1
|
@@ -0,0 +1,1322 @@
|
|
|
1
|
+
import { jsx as M, jsxs as Ie, Fragment as et } from "react/jsx-runtime";
|
|
2
|
+
import { useLoader as fe, useThree as Zt, useFrame as en } from "@react-three/fiber";
|
|
3
|
+
import { useRef as m, useMemo as J, useState as tt, useCallback as Ye, useEffect as Fe } from "react";
|
|
4
|
+
import * as k from "three";
|
|
5
|
+
import { MathUtils as nt, Color as tn, Vector2 as qe } from "three";
|
|
6
|
+
import { l as se, p as nn, X as rn, F as an } from "./index-CnGox6Xr.js";
|
|
7
|
+
import { a as on, u as sn } from "./selectors-C5G1PMYL.js";
|
|
8
|
+
import { s as cn, t as ln, p as dn, b as fn } from "./index-CsUdQ-pn.js";
|
|
9
|
+
import { T as Me, c as un, a as hn } from "./index-Dw6tj2Mi.js";
|
|
10
|
+
import { TransformControls as mn } from "@react-three/drei";
|
|
11
|
+
const pn = (e) => {
|
|
12
|
+
const n = m(null);
|
|
13
|
+
if (n.current) {
|
|
14
|
+
const t = n.current;
|
|
15
|
+
Object.keys(e).forEach((r) => {
|
|
16
|
+
t[r].value = e[r];
|
|
17
|
+
});
|
|
18
|
+
} else {
|
|
19
|
+
const t = {};
|
|
20
|
+
Object.keys(e).forEach((r) => {
|
|
21
|
+
t[r] = { value: e[r] };
|
|
22
|
+
}), n.current = t;
|
|
23
|
+
}
|
|
24
|
+
return n.current;
|
|
25
|
+
}, we = 8, Q = {
|
|
26
|
+
type: "linear",
|
|
27
|
+
stops: [
|
|
28
|
+
{ offset: 0, color: "#38bdf8" },
|
|
29
|
+
{ offset: 1, color: "#a78bfa" }
|
|
30
|
+
],
|
|
31
|
+
angle: 0,
|
|
32
|
+
center: { x: 0.5, y: 0.5 },
|
|
33
|
+
radius: 0.5
|
|
34
|
+
}, yn = (e) => {
|
|
35
|
+
const n = e.slice(0, we).map((t) => ({ ...t, offset: nt.clamp(t.offset, 0, 1) })).sort((t, r) => t.offset - r.offset);
|
|
36
|
+
return n.length >= 2 ? n : Q.stops.map((t) => ({ ...t }));
|
|
37
|
+
}, gn = (e) => ({
|
|
38
|
+
...Q,
|
|
39
|
+
...e,
|
|
40
|
+
center: { ...Q.center, ...e == null ? void 0 : e.center },
|
|
41
|
+
radius: Math.max(0.01, (e == null ? void 0 : e.radius) ?? Q.radius),
|
|
42
|
+
stops: yn((e == null ? void 0 : e.stops) ?? Q.stops)
|
|
43
|
+
}), bn = `
|
|
44
|
+
varying vec2 vPosition;
|
|
45
|
+
void main() {
|
|
46
|
+
vPosition = position.xy;
|
|
47
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
48
|
+
}
|
|
49
|
+
`, En = `
|
|
50
|
+
#define MAX_STOPS 8
|
|
51
|
+
uniform vec3 stopColors[MAX_STOPS];
|
|
52
|
+
uniform float stopOffsets[MAX_STOPS];
|
|
53
|
+
uniform int stopCount;
|
|
54
|
+
uniform int gradientType;
|
|
55
|
+
uniform vec2 direction;
|
|
56
|
+
uniform vec2 center;
|
|
57
|
+
uniform float radius;
|
|
58
|
+
uniform float angleOffset;
|
|
59
|
+
uniform float opacity;
|
|
60
|
+
varying vec2 vPosition;
|
|
61
|
+
|
|
62
|
+
vec3 sampleGradient(float amount) {
|
|
63
|
+
vec3 color = stopColors[0];
|
|
64
|
+
for (int index = 1; index < MAX_STOPS; index++) {
|
|
65
|
+
if (index >= stopCount) break;
|
|
66
|
+
if (amount <= stopOffsets[index]) {
|
|
67
|
+
float width = max(0.0001, stopOffsets[index] - stopOffsets[index - 1]);
|
|
68
|
+
return mix(stopColors[index - 1], stopColors[index], clamp((amount - stopOffsets[index - 1]) / width, 0.0, 1.0));
|
|
69
|
+
}
|
|
70
|
+
color = stopColors[index];
|
|
71
|
+
}
|
|
72
|
+
return color;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
void main() {
|
|
76
|
+
vec2 delta = vPosition - center;
|
|
77
|
+
float amount;
|
|
78
|
+
if (gradientType == 1) {
|
|
79
|
+
amount = clamp(length(delta) / radius, 0.0, 1.0);
|
|
80
|
+
} else if (gradientType == 2) {
|
|
81
|
+
amount = fract(atan(delta.y, delta.x) / 6.28318530718 + 0.5 + angleOffset);
|
|
82
|
+
} else {
|
|
83
|
+
amount = clamp(dot(delta, direction) + 0.5, 0.0, 1.0);
|
|
84
|
+
}
|
|
85
|
+
gl_FragColor = vec4(sampleGradient(amount), opacity);
|
|
86
|
+
}
|
|
87
|
+
`, Mn = { linear: 0, radial: 1, angular: 2 }, xn = ({ opacity: e = 1, value: n }) => {
|
|
88
|
+
const t = J(() => {
|
|
89
|
+
const a = gn(n), o = nt.degToRad(a.angle), s = a.stops.map((f) => new tn(f.color)), l = a.stops.map((f) => f.offset);
|
|
90
|
+
for (; s.length < we; ) s.push(s[s.length - 1]);
|
|
91
|
+
for (; l.length < we; ) l.push(1);
|
|
92
|
+
return {
|
|
93
|
+
stopColors: s,
|
|
94
|
+
stopOffsets: l,
|
|
95
|
+
stopCount: a.stops.length,
|
|
96
|
+
gradientType: Mn[a.type],
|
|
97
|
+
direction: new qe(Math.cos(o), Math.sin(o)),
|
|
98
|
+
center: new qe(a.center.x - 0.5, 0.5 - a.center.y),
|
|
99
|
+
radius: a.radius,
|
|
100
|
+
angleOffset: a.angle / 360,
|
|
101
|
+
opacity: e
|
|
102
|
+
};
|
|
103
|
+
}, [e, n]), r = pn(t);
|
|
104
|
+
return /* @__PURE__ */ M(
|
|
105
|
+
"shaderMaterial",
|
|
106
|
+
{
|
|
107
|
+
uniforms: r,
|
|
108
|
+
vertexShader: bn,
|
|
109
|
+
fragmentShader: En,
|
|
110
|
+
transparent: e < 1,
|
|
111
|
+
depthTest: !1,
|
|
112
|
+
depthWrite: !1,
|
|
113
|
+
toneMapped: !1
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
}, vn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO2YpZcAAAAASUVORK5CYII=", fr = {
|
|
117
|
+
source: "solid",
|
|
118
|
+
color: "#ffffff",
|
|
119
|
+
opacity: 1,
|
|
120
|
+
textureUrl: "",
|
|
121
|
+
gradient: Q
|
|
122
|
+
}, rt = (e) => ({
|
|
123
|
+
...Q,
|
|
124
|
+
stops: [
|
|
125
|
+
{ offset: 0, color: "#ffffff" },
|
|
126
|
+
{ offset: 1, color: e }
|
|
127
|
+
]
|
|
128
|
+
}), An = ({
|
|
129
|
+
depthTest: e,
|
|
130
|
+
depthWrite: n,
|
|
131
|
+
settings: t,
|
|
132
|
+
side: r,
|
|
133
|
+
toneMapped: a
|
|
134
|
+
}) => {
|
|
135
|
+
const o = fe(
|
|
136
|
+
k.TextureLoader,
|
|
137
|
+
t.textureUrl || vn
|
|
138
|
+
);
|
|
139
|
+
return /* @__PURE__ */ M(
|
|
140
|
+
"meshBasicMaterial",
|
|
141
|
+
{
|
|
142
|
+
color: t.color,
|
|
143
|
+
map: o,
|
|
144
|
+
transparent: !0,
|
|
145
|
+
opacity: t.opacity,
|
|
146
|
+
side: r,
|
|
147
|
+
depthWrite: n,
|
|
148
|
+
depthTest: e,
|
|
149
|
+
toneMapped: a
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
}, Sn = ({
|
|
153
|
+
depthTest: e = !1,
|
|
154
|
+
depthWrite: n = !1,
|
|
155
|
+
settings: t,
|
|
156
|
+
side: r,
|
|
157
|
+
toneMapped: a = !1
|
|
158
|
+
}) => {
|
|
159
|
+
const o = J(
|
|
160
|
+
() => t.gradient ?? rt(t.color),
|
|
161
|
+
[t.color, t.gradient]
|
|
162
|
+
);
|
|
163
|
+
return t.source === "gradient" ? /* @__PURE__ */ M(xn, { value: o, opacity: t.opacity }) : t.source === "texture" ? /* @__PURE__ */ M(
|
|
164
|
+
An,
|
|
165
|
+
{
|
|
166
|
+
settings: t,
|
|
167
|
+
side: r,
|
|
168
|
+
depthTest: e,
|
|
169
|
+
depthWrite: n,
|
|
170
|
+
toneMapped: a
|
|
171
|
+
}
|
|
172
|
+
) : /* @__PURE__ */ M(
|
|
173
|
+
"meshBasicMaterial",
|
|
174
|
+
{
|
|
175
|
+
color: t.color,
|
|
176
|
+
transparent: !0,
|
|
177
|
+
opacity: t.opacity,
|
|
178
|
+
side: r,
|
|
179
|
+
depthWrite: n,
|
|
180
|
+
depthTest: e,
|
|
181
|
+
toneMapped: a
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
}, xe = Math.PI / 180, ve = 180 / Math.PI, W = (e) => Number(e.toFixed(6)), Je = {
|
|
185
|
+
enabled: !0,
|
|
186
|
+
linked: {
|
|
187
|
+
position: !1,
|
|
188
|
+
rotation: !1,
|
|
189
|
+
scale: !1
|
|
190
|
+
},
|
|
191
|
+
showTransformControls: !1,
|
|
192
|
+
transformControlMode: "translate",
|
|
193
|
+
transformControlSpace: "local",
|
|
194
|
+
position: { x: 0, y: 0, z: 0 },
|
|
195
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
196
|
+
scale: { x: 1, y: 1, z: 1 },
|
|
197
|
+
visible: !0
|
|
198
|
+
}, ur = ({ children: e, objectRef: n, onChange: t, value: r }) => {
|
|
199
|
+
const a = m(null), o = m(n);
|
|
200
|
+
o.current = n;
|
|
201
|
+
const [s, l] = tt(null), f = Ye((i) => {
|
|
202
|
+
var u;
|
|
203
|
+
a.current = i, l(i), (u = o.current) == null || u.call(o, i);
|
|
204
|
+
}, []), d = Ye(() => {
|
|
205
|
+
const i = a.current;
|
|
206
|
+
!i || !t || t({
|
|
207
|
+
...r,
|
|
208
|
+
position: {
|
|
209
|
+
x: W(i.position.x),
|
|
210
|
+
y: W(i.position.y),
|
|
211
|
+
z: W(i.position.z)
|
|
212
|
+
},
|
|
213
|
+
rotation: {
|
|
214
|
+
x: W(i.rotation.x * ve),
|
|
215
|
+
y: W(i.rotation.y * ve),
|
|
216
|
+
z: W(i.rotation.z * ve)
|
|
217
|
+
},
|
|
218
|
+
scale: {
|
|
219
|
+
x: W(i.scale.x),
|
|
220
|
+
y: W(i.scale.y),
|
|
221
|
+
z: W(i.scale.z)
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}, [t, r]);
|
|
225
|
+
return r.enabled ? /* @__PURE__ */ Ie(et, { children: [
|
|
226
|
+
/* @__PURE__ */ M(
|
|
227
|
+
"group",
|
|
228
|
+
{
|
|
229
|
+
ref: f,
|
|
230
|
+
position: [r.position.x, r.position.y, r.position.z],
|
|
231
|
+
rotation: [
|
|
232
|
+
r.rotation.x * xe,
|
|
233
|
+
r.rotation.y * xe,
|
|
234
|
+
r.rotation.z * xe
|
|
235
|
+
],
|
|
236
|
+
scale: [r.scale.x, r.scale.y, r.scale.z],
|
|
237
|
+
visible: r.visible,
|
|
238
|
+
children: e
|
|
239
|
+
}
|
|
240
|
+
),
|
|
241
|
+
s && r.showTransformControls && /* @__PURE__ */ M(
|
|
242
|
+
mn,
|
|
243
|
+
{
|
|
244
|
+
object: s,
|
|
245
|
+
mode: r.transformControlMode,
|
|
246
|
+
space: r.transformControlSpace,
|
|
247
|
+
size: 0.85,
|
|
248
|
+
onMouseUp: d,
|
|
249
|
+
onObjectChange: d
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
] }) : null;
|
|
253
|
+
}, ae = (e) => Math.min(1, Math.max(0, e)), O = (e, n, t) => ae(1 - Math.abs(e - n) / t), Tn = (e) => {
|
|
254
|
+
let n = 1 / 0, t = -1 / 0, r = 1 / 0, a = -1 / 0;
|
|
255
|
+
for (const l of e)
|
|
256
|
+
n = Math.min(n, l.x), t = Math.max(t, l.x), r = Math.min(r, l.y), a = Math.max(a, l.y);
|
|
257
|
+
const o = Math.max(t - n, 1e-3), s = Math.max(a - r, 1e-3);
|
|
258
|
+
return {
|
|
259
|
+
centerX: n + o * 0.5,
|
|
260
|
+
centerY: r + s * 0.5,
|
|
261
|
+
width: o,
|
|
262
|
+
height: s
|
|
263
|
+
};
|
|
264
|
+
}, Rn = (e) => e != null && e.enabled ? (e.strength ?? 1) !== 0 && Object.entries(e).some(
|
|
265
|
+
([n, t]) => n !== "enabled" && n !== "strength" && typeof t == "number" && t !== 0
|
|
266
|
+
) : !1, _n = (e, n, t, r) => {
|
|
267
|
+
const a = t.enabled ? t.strength ?? 1 : 0;
|
|
268
|
+
if (a === 0)
|
|
269
|
+
return r.x = e.x, r.y = e.y, r.z = e.z, r;
|
|
270
|
+
const o = (e.x - n.centerX) / n.width, s = (e.y - n.centerY) / n.height, l = Math.abs(o), f = ae((-s + 0.42) / 0.55), d = O(s, -0.02, 0.34), i = O(s, -0.24, 0.16) * ae((l - 0.05) / 0.28), u = O(s, 0.02, 0.26) * O(l, 0, 0.18), c = O(s, 0.29, 0.18) * O(l, 0, 0.36), p = ae((s - 0.16) / 0.36), h = d * O(l, 0.34, 0.22), A = f * O(l, 0, 0.48), x = O(s, -0.19, 0.1) * ae((l - 0.05) / 0.3), U = O(s, 0.48, 0.2) * O(l, 0, 0.26);
|
|
271
|
+
let g = e.x, b = e.y, R = e.z;
|
|
272
|
+
const S = (K, L = 1) => {
|
|
273
|
+
g += o * n.width * K * a * L;
|
|
274
|
+
}, E = (K, L = 1) => {
|
|
275
|
+
b += s * n.height * K * a * L;
|
|
276
|
+
};
|
|
277
|
+
S(t.faceWidth ?? 0), E(t.faceHeight ?? 0), S(t.faceRoundness ?? 0, d * (1 - l)), b -= n.height * (t.midfaceHeight ?? 0) * a * d * 0.25, E(-(t.foreheadHeight ?? 0), A), S(t.foreheadWidth ?? 0, A), S(
|
|
278
|
+
t.cheekboneWidth ?? 0,
|
|
279
|
+
O(s, -0.06, 0.16) * O(l, 0.34, 0.2)
|
|
280
|
+
), S(t.cheekWidth ?? 0, h), S(t.jawWidth ?? 0, p), E(t.chinHeight ?? 0, U), b -= n.height * (t.scalpHeight ?? 0) * a * f * 0.3, R -= (t.midfaceDepth ?? 0) * a * d * 0.08, R += (t.cheekHollowness ?? 0) * a * h * 0.06, R -= (t.browDepth ?? 0) * a * x * 0.05, b -= n.height * (t.browHeight ?? 0) * a * x * 0.2, g += Math.sign(o || 1) * n.width * (t.browDistance ?? 0) * a * x * 0.16;
|
|
281
|
+
const _ = (t.headCurve ?? 0) * a * (s + 0.1);
|
|
282
|
+
R -= _ * _ * 0.04 * Math.sign(t.headCurve ?? 0), g += n.width * (t.faceTwist ?? 0) * a * s * 0.18;
|
|
283
|
+
const v = (t.faceSwirl ?? 0) * a * 0.22;
|
|
284
|
+
g += -s * n.width * v, b += o * n.height * v;
|
|
285
|
+
const F = o < 0 ? t.leftEyeSize ?? 0 : t.rightEyeSize ?? 0, N = ((t.eyeSize ?? 0) + F) * a * i;
|
|
286
|
+
g += o * n.width * N * 0.45, b += (s + 0.24) * n.height * N * 0.7, g += Math.sign(o || 1) * n.width * (t.eyeDistance ?? 0) * a * i * 0.2, g += n.width * (o < 0 ? t.leftEyeX ?? 0 : t.rightEyeX ?? 0) * a * i * 0.15, b += n.height * (o < 0 ? t.leftEyeY ?? 0 : t.rightEyeY ?? 0) * a * i * 0.15;
|
|
287
|
+
const $ = (t.noseSize ?? 0) * a * u;
|
|
288
|
+
return g += o * n.width * $ * 0.7, b += (s - 0.02) * n.height * $ * 0.5, b += n.height * (t.noseLength ?? 0) * a * u * Math.max(s + 0.08, 0) * 0.4, R -= (t.noseSize ?? 0) * a * u * 0.08, g += o * n.width * (t.mouthWidth ?? 0) * a * c, b += (s - 0.29) * n.height * (t.mouthHeight ?? 0) * a * c, r.x = g, r.y = b, r.z = R, r;
|
|
289
|
+
}, Ae = /* @__PURE__ */ new Set([
|
|
290
|
+
61,
|
|
291
|
+
146,
|
|
292
|
+
91,
|
|
293
|
+
181,
|
|
294
|
+
84,
|
|
295
|
+
17,
|
|
296
|
+
314,
|
|
297
|
+
405,
|
|
298
|
+
321,
|
|
299
|
+
375,
|
|
300
|
+
291,
|
|
301
|
+
78,
|
|
302
|
+
95,
|
|
303
|
+
88,
|
|
304
|
+
178,
|
|
305
|
+
87,
|
|
306
|
+
14,
|
|
307
|
+
317,
|
|
308
|
+
402,
|
|
309
|
+
318,
|
|
310
|
+
324,
|
|
311
|
+
308,
|
|
312
|
+
191,
|
|
313
|
+
80,
|
|
314
|
+
81,
|
|
315
|
+
82,
|
|
316
|
+
13,
|
|
317
|
+
312,
|
|
318
|
+
311,
|
|
319
|
+
310,
|
|
320
|
+
415
|
|
321
|
+
]), at = [
|
|
322
|
+
61,
|
|
323
|
+
146,
|
|
324
|
+
91,
|
|
325
|
+
181,
|
|
326
|
+
84,
|
|
327
|
+
17,
|
|
328
|
+
314,
|
|
329
|
+
405,
|
|
330
|
+
321,
|
|
331
|
+
375,
|
|
332
|
+
291,
|
|
333
|
+
409,
|
|
334
|
+
270,
|
|
335
|
+
269,
|
|
336
|
+
267,
|
|
337
|
+
0,
|
|
338
|
+
37,
|
|
339
|
+
39,
|
|
340
|
+
40,
|
|
341
|
+
185
|
|
342
|
+
], Oe = [
|
|
343
|
+
78,
|
|
344
|
+
95,
|
|
345
|
+
88,
|
|
346
|
+
178,
|
|
347
|
+
87,
|
|
348
|
+
14,
|
|
349
|
+
317,
|
|
350
|
+
402,
|
|
351
|
+
318,
|
|
352
|
+
324,
|
|
353
|
+
308,
|
|
354
|
+
415,
|
|
355
|
+
310,
|
|
356
|
+
311,
|
|
357
|
+
312,
|
|
358
|
+
13,
|
|
359
|
+
82,
|
|
360
|
+
81,
|
|
361
|
+
80,
|
|
362
|
+
191
|
|
363
|
+
], Se = new Set(Oe), Te = /* @__PURE__ */ new Set([
|
|
364
|
+
33,
|
|
365
|
+
7,
|
|
366
|
+
163,
|
|
367
|
+
144,
|
|
368
|
+
145,
|
|
369
|
+
153,
|
|
370
|
+
154,
|
|
371
|
+
155,
|
|
372
|
+
133,
|
|
373
|
+
173,
|
|
374
|
+
157,
|
|
375
|
+
158,
|
|
376
|
+
159,
|
|
377
|
+
160,
|
|
378
|
+
161,
|
|
379
|
+
246
|
|
380
|
+
]), Re = /* @__PURE__ */ new Set([
|
|
381
|
+
362,
|
|
382
|
+
382,
|
|
383
|
+
381,
|
|
384
|
+
380,
|
|
385
|
+
374,
|
|
386
|
+
373,
|
|
387
|
+
390,
|
|
388
|
+
249,
|
|
389
|
+
263,
|
|
390
|
+
466,
|
|
391
|
+
388,
|
|
392
|
+
387,
|
|
393
|
+
386,
|
|
394
|
+
385,
|
|
395
|
+
384,
|
|
396
|
+
398
|
|
397
|
+
]), Cn = /* @__PURE__ */ new Set([814, 815, 816, 817, 818, 819, 830, 831, 832, 833]), kn = (e, n, t) => {
|
|
398
|
+
const r = Ae.has(e) && Ae.has(n) && Ae.has(t), a = Te.has(e) && Te.has(n) && Te.has(t), o = Re.has(e) && Re.has(n) && Re.has(t);
|
|
399
|
+
return r ? "mouth" : a ? "leftEye" : o ? "rightEye" : "base";
|
|
400
|
+
}, ue = (e, n) => e < n ? `${e}:${n}` : `${n}:${e}`, ot = (e) => e.map((n, t) => ue(n, e[(t + 1) % e.length])), st = ot(Oe), _e = /* @__PURE__ */ new Set([...ot(at), ...st]), Fn = (e) => {
|
|
401
|
+
const n = e.length / 3, t = /* @__PURE__ */ new Map(), r = (c, p) => e[c * 3 + p], a = (c) => {
|
|
402
|
+
const p = r(c, 0), h = r(c, 1), A = r(c, 2);
|
|
403
|
+
return [ue(p, h), ue(h, A), ue(A, p)];
|
|
404
|
+
}, o = (c) => Se.has(r(c, 0)) && Se.has(r(c, 1)) && Se.has(r(c, 2));
|
|
405
|
+
for (let c = 0; c < n; c += 1)
|
|
406
|
+
a(c).forEach((p) => {
|
|
407
|
+
const h = t.get(p);
|
|
408
|
+
h ? h.push(c) : t.set(p, [c]);
|
|
409
|
+
});
|
|
410
|
+
let s = -1;
|
|
411
|
+
for (const c of st) {
|
|
412
|
+
const p = (t.get(c) ?? []).find((h) => !o(h));
|
|
413
|
+
if (p !== void 0) {
|
|
414
|
+
s = p;
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
if (s < 0) return [];
|
|
419
|
+
const l = /* @__PURE__ */ new Set([s]), f = [s], d = /* @__PURE__ */ new Map();
|
|
420
|
+
for (; f.length > 0; ) {
|
|
421
|
+
const c = f.pop();
|
|
422
|
+
a(c).forEach((p) => {
|
|
423
|
+
d.set(p, (d.get(p) ?? 0) + 1), !_e.has(p) && (t.get(p) ?? []).forEach((h) => {
|
|
424
|
+
l.has(h) || (l.add(h), f.push(h));
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
const i = [...d].filter(([, c]) => c === 1).map(([c]) => c);
|
|
429
|
+
return i.length === _e.size && i.every((c) => _e.has(c)) ? [...l].sort((c, p) => c - p).flatMap((c) => [r(c, 0), r(c, 1), r(c, 2)]) : [];
|
|
430
|
+
}, wn = (e, n) => {
|
|
431
|
+
const t = new Float32Array(n).fill(1), r = /* @__PURE__ */ new Map(), a = (f, d) => {
|
|
432
|
+
r.has(f) || r.set(f, /* @__PURE__ */ new Set()), r.get(f).add(d);
|
|
433
|
+
};
|
|
434
|
+
for (let f = 0; f < e.length; f += 3) {
|
|
435
|
+
const [d, i, u] = [e[f], e[f + 1], e[f + 2]];
|
|
436
|
+
a(d, i), a(i, d), a(i, u), a(u, i), a(u, d), a(d, u);
|
|
437
|
+
}
|
|
438
|
+
const o = (f) => {
|
|
439
|
+
const d = /* @__PURE__ */ new Map(), i = f.filter((u) => r.has(u));
|
|
440
|
+
i.forEach((u) => d.set(u, 0));
|
|
441
|
+
for (let u = 0; u < i.length; u += 1) {
|
|
442
|
+
const c = i[u], p = d.get(c) + 1;
|
|
443
|
+
r.get(c).forEach((h) => {
|
|
444
|
+
d.has(h) || (d.set(h, p), i.push(h));
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
return d;
|
|
448
|
+
}, s = o(at), l = o(Oe);
|
|
449
|
+
return r.forEach((f, d) => {
|
|
450
|
+
const i = s.get(d) ?? 0, u = l.get(d) ?? 0;
|
|
451
|
+
t[d] = i + u === 0 ? 1 : i / (i + u);
|
|
452
|
+
}), t;
|
|
453
|
+
}, Un = (e) => {
|
|
454
|
+
const n = [], t = [], r = [], a = [], o = [], s = [], l = [], f = [];
|
|
455
|
+
let d = 0, i = 0;
|
|
456
|
+
e.split(`
|
|
457
|
+
`).forEach((x) => {
|
|
458
|
+
const U = x.trim();
|
|
459
|
+
if (!U) return;
|
|
460
|
+
if (U.startsWith("v ")) {
|
|
461
|
+
d += 1;
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
if (U.startsWith("vt ")) {
|
|
465
|
+
const [, S, E] = U.split(/\s+/);
|
|
466
|
+
l.push([Number(S), Number(E)]);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (!U.startsWith("f ")) return;
|
|
470
|
+
const g = i;
|
|
471
|
+
i += 1;
|
|
472
|
+
const [, ...b] = U.split(/\s+/), R = b.map((S) => {
|
|
473
|
+
const [E, _] = S.split("/"), v = Number(E) - 1, F = Number(_) - 1;
|
|
474
|
+
return F >= 0 && l[F] && !f[v] && (f[v] = l[F]), v;
|
|
475
|
+
});
|
|
476
|
+
if (!(R.length < 3))
|
|
477
|
+
for (let S = 1; S < R.length - 1; S += 1) {
|
|
478
|
+
const E = R[0], _ = R[S], v = R[S + 1];
|
|
479
|
+
n.push(E, _, v);
|
|
480
|
+
const F = kn(E, _, v);
|
|
481
|
+
Cn.has(g) ? s.push(E, _, v) : F === "mouth" ? r.push(E, _, v) : F === "leftEye" ? a.push(E, _, v) : F === "rightEye" ? o.push(E, _, v) : t.push(E, _, v);
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
const u = [];
|
|
485
|
+
for (let x = 0; x < d; x += 1) {
|
|
486
|
+
const [U, g] = f[x] ?? [0, 0];
|
|
487
|
+
u.push(U, g);
|
|
488
|
+
}
|
|
489
|
+
const c = new Uint16Array(a), p = new Uint16Array(o), h = new Uint16Array(a.length + o.length);
|
|
490
|
+
h.set(c), h.set(p, c.length);
|
|
491
|
+
const A = Fn(n);
|
|
492
|
+
return {
|
|
493
|
+
baseIndices: new Uint16Array(t),
|
|
494
|
+
mouthIndices: new Uint16Array(r),
|
|
495
|
+
lipIndices: new Uint16Array(A),
|
|
496
|
+
lipEdgeDistance: wn(A, d),
|
|
497
|
+
leftEyeIndices: c,
|
|
498
|
+
rightEyeIndices: p,
|
|
499
|
+
eyeIndices: h,
|
|
500
|
+
noseIndices: new Uint16Array(s),
|
|
501
|
+
uvs: new Float32Array(u),
|
|
502
|
+
vertexCount: d
|
|
503
|
+
};
|
|
504
|
+
}, In = "canonical_face_model.obj", On = new TextDecoder("utf-8"), Ce = /* @__PURE__ */ new Map(), Ln = (e) => {
|
|
505
|
+
const n = Ce.get(e);
|
|
506
|
+
if (n) return n;
|
|
507
|
+
const t = nn(e).then((r) => Un(On.decode(r))).catch((r) => {
|
|
508
|
+
throw Ce.delete(e), r;
|
|
509
|
+
});
|
|
510
|
+
return Ce.set(e, t), t;
|
|
511
|
+
}, Dn = (e) => {
|
|
512
|
+
const { mesh: n, url: t } = e ?? {}, r = t ?? `${se.sdkAssetsBaseUrl}/${In}`, [a, o] = tt(n ?? null);
|
|
513
|
+
return Fe(() => {
|
|
514
|
+
if (n) {
|
|
515
|
+
o(n);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
let s = !1;
|
|
519
|
+
return Ln(r).then((l) => {
|
|
520
|
+
s || o(l);
|
|
521
|
+
}).catch((l) => {
|
|
522
|
+
s || console.error(`${se.loggerPrefix} canonical face mesh load failed`, l);
|
|
523
|
+
}), () => {
|
|
524
|
+
s = !0;
|
|
525
|
+
};
|
|
526
|
+
}, [n, r]), a;
|
|
527
|
+
}, C = {
|
|
528
|
+
basic: "basic",
|
|
529
|
+
standard: "standard",
|
|
530
|
+
physical: "physical",
|
|
531
|
+
toon: "toon",
|
|
532
|
+
normal: "normal",
|
|
533
|
+
matcap: "matcap",
|
|
534
|
+
wireframe: "wireframe",
|
|
535
|
+
shader: "shader"
|
|
536
|
+
}, V = {
|
|
537
|
+
originalFace: "originalFace",
|
|
538
|
+
composite: "composite"
|
|
539
|
+
}, j = {
|
|
540
|
+
none: "none",
|
|
541
|
+
canonical: "canonical",
|
|
542
|
+
style2: "style2"
|
|
543
|
+
}, ee = {
|
|
544
|
+
none: "none",
|
|
545
|
+
canonical: "canonical"
|
|
546
|
+
}, ce = {
|
|
547
|
+
solid: "solid",
|
|
548
|
+
gradient: "gradient",
|
|
549
|
+
imageUrl: "imageUrl",
|
|
550
|
+
mediaUrl: "mediaUrl"
|
|
551
|
+
}, oe = {
|
|
552
|
+
front: "front",
|
|
553
|
+
back: "back",
|
|
554
|
+
double: "double"
|
|
555
|
+
}, ct = {
|
|
556
|
+
normal: "normal",
|
|
557
|
+
add: "add",
|
|
558
|
+
subtract: "subtract",
|
|
559
|
+
multiply: "multiply",
|
|
560
|
+
screen: "screen",
|
|
561
|
+
overlay: "overlay",
|
|
562
|
+
softLight: "softLight",
|
|
563
|
+
hardLight: "hardLight",
|
|
564
|
+
lighten: "lighten",
|
|
565
|
+
darken: "darken",
|
|
566
|
+
difference: "difference",
|
|
567
|
+
exclusion: "exclusion"
|
|
568
|
+
}, Pn = {
|
|
569
|
+
textureMap: j.canonical,
|
|
570
|
+
alphaMap: ee.canonical,
|
|
571
|
+
alphaOpacity: 1
|
|
572
|
+
}, Qe = {
|
|
573
|
+
...Pn,
|
|
574
|
+
blendMode: ct.hardLight,
|
|
575
|
+
blendOpacity: 0.85,
|
|
576
|
+
baseColor: "#ffffff",
|
|
577
|
+
opacity: 1,
|
|
578
|
+
compositeShading: !0
|
|
579
|
+
}, P = {
|
|
580
|
+
materialType: C.basic,
|
|
581
|
+
shaderPreset: V.originalFace,
|
|
582
|
+
textureMap: j.none,
|
|
583
|
+
alphaMap: ee.none,
|
|
584
|
+
alphaOpacity: 1,
|
|
585
|
+
side: oe.front,
|
|
586
|
+
blendMode: ct.normal,
|
|
587
|
+
blendOpacity: 1,
|
|
588
|
+
baseColor: "#38bdf8",
|
|
589
|
+
opacity: 0.45,
|
|
590
|
+
compositeShading: !1
|
|
591
|
+
};
|
|
592
|
+
C.shader, V.composite, oe.front;
|
|
593
|
+
const ke = {
|
|
594
|
+
mouth: !0,
|
|
595
|
+
eyes: !0,
|
|
596
|
+
nose: !0
|
|
597
|
+
}, te = {
|
|
598
|
+
textureSource: ce.solid,
|
|
599
|
+
color: "#111111",
|
|
600
|
+
opacity: 0.5
|
|
601
|
+
}, Nn = 24, it = 10, Le = (e, n, t) => e !== C.shader ? "none" : n === V.originalFace ? "originalFace" : n === V.composite ? t === j.none ? "originalFace" : "composite" : "none", hr = (e, n) => e === C.basic || e === C.standard || e === C.physical || e === C.toon || e === C.shader && n === V.composite, mr = (e, n, t = j.canonical) => Le(e, n, t) === "composite", Gn = (e, n, t) => Le(e, n, t) === "originalFace", Ue = (e) => e === ce.imageUrl || e === ce.mediaUrl, zn = (e) => e === ce.solid || e === ce.gradient, Ze = {
|
|
602
|
+
normal: 0,
|
|
603
|
+
add: 1,
|
|
604
|
+
subtract: 2,
|
|
605
|
+
multiply: 3,
|
|
606
|
+
screen: 4,
|
|
607
|
+
overlay: 5,
|
|
608
|
+
softLight: 6,
|
|
609
|
+
hardLight: 7,
|
|
610
|
+
lighten: 8,
|
|
611
|
+
darken: 9,
|
|
612
|
+
difference: 10,
|
|
613
|
+
exclusion: 11
|
|
614
|
+
}, Hn = `
|
|
615
|
+
attribute vec2 faceUv;
|
|
616
|
+
varying vec2 vUv;
|
|
617
|
+
varying vec2 vFaceUv;
|
|
618
|
+
varying vec3 vNormal;
|
|
619
|
+
|
|
620
|
+
void main() {
|
|
621
|
+
vUv = uv;
|
|
622
|
+
vFaceUv = faceUv;
|
|
623
|
+
vNormal = normalize(normalMatrix * normal);
|
|
624
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
625
|
+
}
|
|
626
|
+
`, Bn = `
|
|
627
|
+
uniform sampler2D cameraTexture;
|
|
628
|
+
uniform sampler2D canonicalTexture;
|
|
629
|
+
uniform sampler2D alphaMask;
|
|
630
|
+
uniform vec3 textureTint;
|
|
631
|
+
uniform float opacity;
|
|
632
|
+
uniform int blendMode;
|
|
633
|
+
uniform float blendOpacity;
|
|
634
|
+
uniform float useCanonicalTexture;
|
|
635
|
+
uniform float useAlphaMask;
|
|
636
|
+
uniform float alphaOpacity;
|
|
637
|
+
uniform float compositeShading;
|
|
638
|
+
uniform vec3 lightDirection;
|
|
639
|
+
uniform float ambientStrength;
|
|
640
|
+
uniform float directionalStrength;
|
|
641
|
+
varying vec2 vUv;
|
|
642
|
+
varying vec2 vFaceUv;
|
|
643
|
+
varying vec3 vNormal;
|
|
644
|
+
|
|
645
|
+
vec3 linearToSrgb(vec3 value) {
|
|
646
|
+
vec3 low = value * 12.92;
|
|
647
|
+
vec3 high = 1.055 * pow(max(value, vec3(0.0)), vec3(1.0 / 2.4)) - 0.055;
|
|
648
|
+
return mix(high, low, step(value, vec3(0.0031308)));
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
vec3 srgbToLinear(vec3 value) {
|
|
652
|
+
vec3 low = value / 12.92;
|
|
653
|
+
vec3 high = pow(max((value + 0.055) / 1.055, vec3(0.0)), vec3(2.4));
|
|
654
|
+
return mix(high, low, step(value, vec3(0.04045)));
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
float overlayChannel(float base, float blend) {
|
|
658
|
+
return base < 0.5 ? 2.0 * base * blend : 1.0 - 2.0 * (1.0 - base) * (1.0 - blend);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
float hardLightChannel(float base, float blend) {
|
|
662
|
+
return blend < 0.5 ? 2.0 * base * blend : 1.0 - 2.0 * (1.0 - base) * (1.0 - blend);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
float softLightChannel(float base, float blend) {
|
|
666
|
+
if (blend <= 0.5) {
|
|
667
|
+
return base - (1.0 - 2.0 * blend) * base * (1.0 - base);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
float d = base <= 0.25
|
|
671
|
+
? ((16.0 * base - 12.0) * base + 4.0) * base
|
|
672
|
+
: sqrt(base);
|
|
673
|
+
|
|
674
|
+
return base + (2.0 * blend - 1.0) * (d - base);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
vec3 applyBlendMode(vec3 base, vec3 blend, int mode) {
|
|
678
|
+
if (mode == 0) return blend;
|
|
679
|
+
if (mode == 1) return min(base + blend, 1.0);
|
|
680
|
+
if (mode == 2) return max(base - blend, 0.0);
|
|
681
|
+
if (mode == 3) return base * blend;
|
|
682
|
+
if (mode == 4) return 1.0 - (1.0 - base) * (1.0 - blend);
|
|
683
|
+
if (mode == 5) {
|
|
684
|
+
return vec3(
|
|
685
|
+
overlayChannel(base.r, blend.r),
|
|
686
|
+
overlayChannel(base.g, blend.g),
|
|
687
|
+
overlayChannel(base.b, blend.b)
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
if (mode == 6) {
|
|
691
|
+
return vec3(
|
|
692
|
+
softLightChannel(base.r, blend.r),
|
|
693
|
+
softLightChannel(base.g, blend.g),
|
|
694
|
+
softLightChannel(base.b, blend.b)
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
if (mode == 7) {
|
|
698
|
+
return vec3(
|
|
699
|
+
hardLightChannel(base.r, blend.r),
|
|
700
|
+
hardLightChannel(base.g, blend.g),
|
|
701
|
+
hardLightChannel(base.b, blend.b)
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
if (mode == 8) return max(base, blend);
|
|
705
|
+
if (mode == 9) return min(base, blend);
|
|
706
|
+
if (mode == 10) return abs(base - blend);
|
|
707
|
+
return base + blend - 2.0 * base * blend;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
void main() {
|
|
711
|
+
vec3 base = linearToSrgb(texture2D(cameraTexture, vFaceUv).rgb);
|
|
712
|
+
vec4 textureSample = texture2D(canonicalTexture, vUv);
|
|
713
|
+
vec3 blend = linearToSrgb(textureSample.rgb) * textureTint;
|
|
714
|
+
float light = ambientStrength + max(dot(normalize(vNormal), normalize(lightDirection)), 0.0) * directionalStrength;
|
|
715
|
+
blend *= mix(1.0, clamp(light, 0.35, 1.35), compositeShading);
|
|
716
|
+
float maskSample = texture2D(alphaMask, vUv).r;
|
|
717
|
+
float mask = useAlphaMask > 0.5 ? mix(1.0, maskSample, alphaOpacity) : 1.0;
|
|
718
|
+
float textureAlpha = useCanonicalTexture > 0.5 ? textureSample.a : 1.0;
|
|
719
|
+
vec3 blended = applyBlendMode(base, blend, blendMode);
|
|
720
|
+
vec3 color = useCanonicalTexture > 0.5 ? mix(base, blended, blendOpacity) : base;
|
|
721
|
+
gl_FragColor = vec4(srgbToLinear(color), opacity * mask * textureAlpha);
|
|
722
|
+
// Blending above runs in sRGB; the result is linear here and three only
|
|
723
|
+
// encodes built-in materials, so encode for the output colour space.
|
|
724
|
+
#include <colorspace_fragment>
|
|
725
|
+
}
|
|
726
|
+
`, Wn = ({
|
|
727
|
+
alphaMap: e,
|
|
728
|
+
alphaOpacity: n,
|
|
729
|
+
blendMode: t,
|
|
730
|
+
blendOpacity: r,
|
|
731
|
+
cameraTexture: a,
|
|
732
|
+
color: o,
|
|
733
|
+
compositeShading: s,
|
|
734
|
+
faceAlphaMaskUrl: l,
|
|
735
|
+
faceTextureStyle2Url: f,
|
|
736
|
+
faceTextureUrl: d,
|
|
737
|
+
masked: i = !1,
|
|
738
|
+
maskColor: u,
|
|
739
|
+
maskOpacity: c,
|
|
740
|
+
maskSourceUrl: p,
|
|
741
|
+
maskTextureSource: h,
|
|
742
|
+
materialType: A,
|
|
743
|
+
opacity: x,
|
|
744
|
+
shaderPreset: U,
|
|
745
|
+
side: g,
|
|
746
|
+
textureMap: b
|
|
747
|
+
}) => {
|
|
748
|
+
const R = fe(
|
|
749
|
+
k.TextureLoader,
|
|
750
|
+
d || Me
|
|
751
|
+
), S = fe(
|
|
752
|
+
k.TextureLoader,
|
|
753
|
+
f || d || Me
|
|
754
|
+
), E = fe(
|
|
755
|
+
k.TextureLoader,
|
|
756
|
+
l || Me
|
|
757
|
+
), _ = J(() => un(), []), v = J(() => hn(), []);
|
|
758
|
+
Fe(
|
|
759
|
+
() => () => {
|
|
760
|
+
_.dispose(), v.dispose();
|
|
761
|
+
},
|
|
762
|
+
[v, _]
|
|
763
|
+
);
|
|
764
|
+
const F = b === j.style2 ? S : R, N = b !== j.none, $ = Le(A, U, b), K = [
|
|
765
|
+
"composite-material",
|
|
766
|
+
b,
|
|
767
|
+
e,
|
|
768
|
+
n,
|
|
769
|
+
t,
|
|
770
|
+
r,
|
|
771
|
+
s ? "lit" : "flat",
|
|
772
|
+
o,
|
|
773
|
+
x,
|
|
774
|
+
d,
|
|
775
|
+
f,
|
|
776
|
+
l
|
|
777
|
+
].join("|"), L = {
|
|
778
|
+
side: g,
|
|
779
|
+
transparent: !0,
|
|
780
|
+
opacity: x,
|
|
781
|
+
wireframe: !1
|
|
782
|
+
}, he = J(
|
|
783
|
+
() => ({
|
|
784
|
+
source: Ue(h) ? "texture" : h,
|
|
785
|
+
color: zn(h) ? u : "#ffffff",
|
|
786
|
+
opacity: c,
|
|
787
|
+
textureUrl: Ue(h) ? p : "",
|
|
788
|
+
gradient: rt(u)
|
|
789
|
+
}),
|
|
790
|
+
[u, c, p, h]
|
|
791
|
+
), w = J(
|
|
792
|
+
() => ({
|
|
793
|
+
cameraTexture: { value: null },
|
|
794
|
+
canonicalTexture: { value: null },
|
|
795
|
+
alphaMask: { value: null },
|
|
796
|
+
textureTint: { value: new k.Color(o) },
|
|
797
|
+
opacity: { value: x },
|
|
798
|
+
blendMode: { value: Ze[t] },
|
|
799
|
+
blendOpacity: { value: r },
|
|
800
|
+
useCanonicalTexture: { value: N ? 1 : 0 },
|
|
801
|
+
useAlphaMask: { value: e === ee.canonical ? 1 : 0 },
|
|
802
|
+
alphaOpacity: { value: n },
|
|
803
|
+
compositeShading: { value: s ? 1 : 0 },
|
|
804
|
+
lightDirection: { value: new k.Vector3(0.3, 0.65, 0.7).normalize() },
|
|
805
|
+
ambientStrength: { value: 0.78 },
|
|
806
|
+
directionalStrength: { value: 0.38 }
|
|
807
|
+
}),
|
|
808
|
+
[
|
|
809
|
+
e,
|
|
810
|
+
n,
|
|
811
|
+
t,
|
|
812
|
+
r,
|
|
813
|
+
o,
|
|
814
|
+
s,
|
|
815
|
+
N,
|
|
816
|
+
x
|
|
817
|
+
]
|
|
818
|
+
);
|
|
819
|
+
if (Fe(() => {
|
|
820
|
+
w.cameraTexture.value = a ?? R, w.canonicalTexture.value = F, w.alphaMask.value = E, w.textureTint.value.set(o), w.opacity.value = x, w.blendMode.value = Ze[t], w.blendOpacity.value = r, w.useCanonicalTexture.value = N ? 1 : 0, w.useAlphaMask.value = e === ee.canonical ? 1 : 0, w.alphaOpacity.value = n, w.compositeShading.value = s ? 1 : 0;
|
|
821
|
+
}, [
|
|
822
|
+
e,
|
|
823
|
+
E,
|
|
824
|
+
n,
|
|
825
|
+
t,
|
|
826
|
+
r,
|
|
827
|
+
a,
|
|
828
|
+
o,
|
|
829
|
+
s,
|
|
830
|
+
w,
|
|
831
|
+
R,
|
|
832
|
+
N,
|
|
833
|
+
x,
|
|
834
|
+
F
|
|
835
|
+
]), i)
|
|
836
|
+
return /* @__PURE__ */ M(
|
|
837
|
+
Sn,
|
|
838
|
+
{
|
|
839
|
+
settings: he,
|
|
840
|
+
side: g
|
|
841
|
+
},
|
|
842
|
+
`masked-${h}-material`
|
|
843
|
+
);
|
|
844
|
+
if (A === C.wireframe)
|
|
845
|
+
return /* @__PURE__ */ M(
|
|
846
|
+
"meshBasicMaterial",
|
|
847
|
+
{
|
|
848
|
+
color: o,
|
|
849
|
+
transparent: !0,
|
|
850
|
+
opacity: x,
|
|
851
|
+
side: g,
|
|
852
|
+
depthWrite: !1,
|
|
853
|
+
depthTest: !1,
|
|
854
|
+
wireframe: !0,
|
|
855
|
+
toneMapped: !1
|
|
856
|
+
},
|
|
857
|
+
"wireframe-material"
|
|
858
|
+
);
|
|
859
|
+
if ($ === "originalFace" && a)
|
|
860
|
+
return /* @__PURE__ */ M(
|
|
861
|
+
"meshBasicMaterial",
|
|
862
|
+
{
|
|
863
|
+
map: a,
|
|
864
|
+
alphaMap: E,
|
|
865
|
+
transparent: !0,
|
|
866
|
+
opacity: x,
|
|
867
|
+
side: g,
|
|
868
|
+
depthWrite: !1,
|
|
869
|
+
depthTest: !0,
|
|
870
|
+
toneMapped: !1
|
|
871
|
+
},
|
|
872
|
+
"use-original-face-material"
|
|
873
|
+
);
|
|
874
|
+
if ($ === "composite" && a)
|
|
875
|
+
return /* @__PURE__ */ M(
|
|
876
|
+
"shaderMaterial",
|
|
877
|
+
{
|
|
878
|
+
uniforms: w,
|
|
879
|
+
vertexShader: Hn,
|
|
880
|
+
fragmentShader: Bn,
|
|
881
|
+
transparent: !0,
|
|
882
|
+
side: g,
|
|
883
|
+
depthWrite: !1,
|
|
884
|
+
depthTest: !0,
|
|
885
|
+
toneMapped: !1
|
|
886
|
+
},
|
|
887
|
+
K
|
|
888
|
+
);
|
|
889
|
+
const Z = N ? F : null, Y = e === ee.canonical && n > 0 ? E : null, X = `${A}-${b}-${e}-${n > 0 ? "alpha-on" : "alpha-off"}`;
|
|
890
|
+
return A === C.standard ? /* @__PURE__ */ M(
|
|
891
|
+
"meshStandardMaterial",
|
|
892
|
+
{
|
|
893
|
+
...L,
|
|
894
|
+
color: o,
|
|
895
|
+
map: Z ?? void 0,
|
|
896
|
+
alphaMap: Y ?? void 0,
|
|
897
|
+
depthWrite: !0,
|
|
898
|
+
depthTest: !0,
|
|
899
|
+
metalness: 0.05,
|
|
900
|
+
roughness: 0.72
|
|
901
|
+
},
|
|
902
|
+
X
|
|
903
|
+
) : A === C.physical ? /* @__PURE__ */ M(
|
|
904
|
+
"meshPhysicalMaterial",
|
|
905
|
+
{
|
|
906
|
+
...L,
|
|
907
|
+
color: o,
|
|
908
|
+
map: Z ?? void 0,
|
|
909
|
+
alphaMap: Y ?? void 0,
|
|
910
|
+
depthWrite: !0,
|
|
911
|
+
depthTest: !0,
|
|
912
|
+
roughness: 0.58,
|
|
913
|
+
metalness: 0.08,
|
|
914
|
+
clearcoat: 0.35,
|
|
915
|
+
clearcoatRoughness: 0.4
|
|
916
|
+
},
|
|
917
|
+
X
|
|
918
|
+
) : A === C.toon ? /* @__PURE__ */ M(
|
|
919
|
+
"meshToonMaterial",
|
|
920
|
+
{
|
|
921
|
+
...L,
|
|
922
|
+
color: o,
|
|
923
|
+
map: Z ?? void 0,
|
|
924
|
+
alphaMap: Y ?? void 0,
|
|
925
|
+
gradientMap: _,
|
|
926
|
+
depthWrite: !0,
|
|
927
|
+
depthTest: !0
|
|
928
|
+
},
|
|
929
|
+
X
|
|
930
|
+
) : A === C.normal ? /* @__PURE__ */ M(
|
|
931
|
+
"meshNormalMaterial",
|
|
932
|
+
{
|
|
933
|
+
...L,
|
|
934
|
+
depthWrite: !0,
|
|
935
|
+
depthTest: !0,
|
|
936
|
+
flatShading: !1
|
|
937
|
+
},
|
|
938
|
+
"normal-material"
|
|
939
|
+
) : A === C.matcap ? /* @__PURE__ */ M(
|
|
940
|
+
"meshMatcapMaterial",
|
|
941
|
+
{
|
|
942
|
+
...L,
|
|
943
|
+
color: o,
|
|
944
|
+
matcap: v,
|
|
945
|
+
depthWrite: !0,
|
|
946
|
+
depthTest: !0
|
|
947
|
+
},
|
|
948
|
+
"matcap-material"
|
|
949
|
+
) : /* @__PURE__ */ M(
|
|
950
|
+
"meshBasicMaterial",
|
|
951
|
+
{
|
|
952
|
+
...L,
|
|
953
|
+
color: o,
|
|
954
|
+
map: Z ?? void 0,
|
|
955
|
+
alphaMap: Y ?? void 0,
|
|
956
|
+
depthWrite: !1,
|
|
957
|
+
depthTest: b !== j.none || e !== ee.none,
|
|
958
|
+
toneMapped: !1
|
|
959
|
+
},
|
|
960
|
+
X
|
|
961
|
+
);
|
|
962
|
+
}, Xn = [
|
|
963
|
+
{
|
|
964
|
+
key: "base",
|
|
965
|
+
getIndices: (e) => e.baseIndices,
|
|
966
|
+
masked: !1,
|
|
967
|
+
renderOrderOffset: 0
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
key: "mouth",
|
|
971
|
+
getIndices: (e) => e.mouthIndices,
|
|
972
|
+
masked: !1,
|
|
973
|
+
renderOrderOffset: 2
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
key: "lips",
|
|
977
|
+
getIndices: (e) => e.lipIndices,
|
|
978
|
+
masked: !1,
|
|
979
|
+
renderOrderOffset: 3
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
key: "left-eye",
|
|
983
|
+
getIndices: (e) => e.leftEyeIndices,
|
|
984
|
+
masked: !1,
|
|
985
|
+
renderOrderOffset: 2
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
key: "right-eye",
|
|
989
|
+
getIndices: (e) => e.rightEyeIndices,
|
|
990
|
+
masked: !1,
|
|
991
|
+
renderOrderOffset: 2
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
key: "nose",
|
|
995
|
+
getIndices: (e) => e.noseIndices,
|
|
996
|
+
masked: !1,
|
|
997
|
+
renderOrderOffset: 2
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
key: "mouth-mask",
|
|
1001
|
+
getIndices: (e) => e.mouthIndices,
|
|
1002
|
+
masked: !0,
|
|
1003
|
+
renderOrderOffset: 3
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
key: "left-eye-mask",
|
|
1007
|
+
getIndices: (e) => e.leftEyeIndices,
|
|
1008
|
+
masked: !0,
|
|
1009
|
+
renderOrderOffset: 3
|
|
1010
|
+
},
|
|
1011
|
+
{
|
|
1012
|
+
key: "right-eye-mask",
|
|
1013
|
+
getIndices: (e) => e.rightEyeIndices,
|
|
1014
|
+
masked: !0,
|
|
1015
|
+
renderOrderOffset: 3
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
key: "nose-mask",
|
|
1019
|
+
getIndices: (e) => e.noseIndices,
|
|
1020
|
+
masked: !0,
|
|
1021
|
+
renderOrderOffset: 3
|
|
1022
|
+
}
|
|
1023
|
+
], Vn = {
|
|
1024
|
+
[oe.front]: k.FrontSide,
|
|
1025
|
+
[oe.back]: k.BackSide,
|
|
1026
|
+
[oe.double]: k.DoubleSide
|
|
1027
|
+
}, jn = (e) => ({
|
|
1028
|
+
position: new k.BufferAttribute(new Float32Array(e.vertexCount * 3), 3),
|
|
1029
|
+
uv: new k.BufferAttribute(new Float32Array(e.uvs), 2),
|
|
1030
|
+
faceUv: new k.BufferAttribute(new Float32Array(e.vertexCount * 2), 2),
|
|
1031
|
+
lipEdge: new k.BufferAttribute(new Float32Array(e.lipEdgeDistance), 1)
|
|
1032
|
+
}), $n = (e, n, t) => {
|
|
1033
|
+
e.setAttribute("position", n.position), e.setAttribute("uv", n.uv), e.setAttribute("faceUv", n.faceUv), e.setAttribute("lipEdge", n.lipEdge), e.setIndex(new k.BufferAttribute(t, 1));
|
|
1034
|
+
}, Kn = ({
|
|
1035
|
+
faceIndex: e = 0,
|
|
1036
|
+
baseColor: n,
|
|
1037
|
+
color: t = P.baseColor,
|
|
1038
|
+
opacity: r = P.opacity,
|
|
1039
|
+
materialType: a = P.materialType,
|
|
1040
|
+
shaderPreset: o = P.shaderPreset,
|
|
1041
|
+
textureMap: s = P.textureMap,
|
|
1042
|
+
alphaMap: l = P.alphaMap,
|
|
1043
|
+
alphaOpacity: f = P.alphaOpacity,
|
|
1044
|
+
side: d = P.side,
|
|
1045
|
+
blendMode: i = P.blendMode,
|
|
1046
|
+
blendOpacity: u = P.blendOpacity,
|
|
1047
|
+
showOverlayMask: c = !1,
|
|
1048
|
+
showMouthMask: p = ke.mouth,
|
|
1049
|
+
showEyeMask: h = ke.eyes,
|
|
1050
|
+
showLeftEyeMask: A,
|
|
1051
|
+
showRightEyeMask: x,
|
|
1052
|
+
showNoseMask: U = ke.nose,
|
|
1053
|
+
showEyeGeometry: g = !0,
|
|
1054
|
+
showLeftEyeGeometry: b,
|
|
1055
|
+
showRightEyeGeometry: R,
|
|
1056
|
+
showMouthGeometry: S = !0,
|
|
1057
|
+
// The lips mesh is an effect-only overlay. Rendering it with the base face
|
|
1058
|
+
// mesh duplicates an incomplete triangulation over the mouth.
|
|
1059
|
+
showLipsGeometry: E = !1,
|
|
1060
|
+
showBaseGeometry: _ = !0,
|
|
1061
|
+
showNoseGeometry: v = !0,
|
|
1062
|
+
maskTextureSource: F = te.textureSource,
|
|
1063
|
+
maskSourceUrl: N = "",
|
|
1064
|
+
maskColor: $ = te.color,
|
|
1065
|
+
maskOpacity: K = te.opacity,
|
|
1066
|
+
faceTextureUrl: L = "",
|
|
1067
|
+
faceTextureStyle2Url: he = "",
|
|
1068
|
+
faceAlphaMaskUrl: w = "",
|
|
1069
|
+
compositeShading: Z = !1,
|
|
1070
|
+
faceWarp3D: Y,
|
|
1071
|
+
transform: X,
|
|
1072
|
+
renderOrder: lt = it,
|
|
1073
|
+
externalScale: me = 1,
|
|
1074
|
+
mesh: dt,
|
|
1075
|
+
meshUrl: ft,
|
|
1076
|
+
materialOverride: ne,
|
|
1077
|
+
maxUpdateFps: ut,
|
|
1078
|
+
holdMs: De = 250,
|
|
1079
|
+
predictMs: Pe = 0
|
|
1080
|
+
}) => {
|
|
1081
|
+
const pe = on(rn.FACE_TRACKER), Ne = sn(), { camera: ht } = Zt(), G = Dn({ mesh: dt, url: ft }), Ge = m(null), mt = m(null), pt = m(null), yt = m(null), gt = m(null), bt = m(null), Et = m(null), Mt = m(null), xt = m(null), vt = m(null), At = m(null), St = m(null), Tt = m(null), Rt = m(null), _t = m(null), Ct = m(null), kt = m(null), Ft = m(null), wt = m(null), Ut = m(null), I = J(
|
|
1082
|
+
() => G ? jn(G) : null,
|
|
1083
|
+
[G]
|
|
1084
|
+
), ze = m(null), He = m(-1 / 0), ie = m(null);
|
|
1085
|
+
ie.current || (ie.current = new an({ holdMs: De, predictMs: Pe })), ie.current.setOptions({ holdMs: De, predictMs: Pe });
|
|
1086
|
+
const It = m(new k.Vector3()), Ot = m({ x: 0, y: 0, z: 0 }), Lt = m({ x: 0, y: 0, z: 0 }), Dt = m({ x: 0, y: 0, z: 0 }), le = m(!1), Pt = Vn[d], Nt = n ?? t, Gt = b ?? g, zt = R ?? g, Ht = c || (A ?? h), Bt = c || (x ?? h), Wt = c || p, Xt = c || U, Vt = {
|
|
1087
|
+
base: Ge,
|
|
1088
|
+
mouth: mt,
|
|
1089
|
+
lips: pt,
|
|
1090
|
+
"left-eye": yt,
|
|
1091
|
+
"right-eye": gt,
|
|
1092
|
+
nose: bt,
|
|
1093
|
+
"mouth-mask": Et,
|
|
1094
|
+
"left-eye-mask": Mt,
|
|
1095
|
+
"right-eye-mask": xt,
|
|
1096
|
+
"nose-mask": vt
|
|
1097
|
+
}, jt = {
|
|
1098
|
+
base: At,
|
|
1099
|
+
mouth: St,
|
|
1100
|
+
lips: Tt,
|
|
1101
|
+
"left-eye": Rt,
|
|
1102
|
+
"right-eye": _t,
|
|
1103
|
+
nose: Ct,
|
|
1104
|
+
"mouth-mask": kt,
|
|
1105
|
+
"left-eye-mask": Ft,
|
|
1106
|
+
"right-eye-mask": wt,
|
|
1107
|
+
"nose-mask": Ut
|
|
1108
|
+
}, $t = {
|
|
1109
|
+
base: _,
|
|
1110
|
+
mouth: S,
|
|
1111
|
+
lips: E,
|
|
1112
|
+
"left-eye": Gt,
|
|
1113
|
+
"right-eye": zt,
|
|
1114
|
+
nose: v,
|
|
1115
|
+
"mouth-mask": Wt,
|
|
1116
|
+
"left-eye-mask": Ht,
|
|
1117
|
+
"right-eye-mask": Bt,
|
|
1118
|
+
"nose-mask": Xt
|
|
1119
|
+
}, Kt = (T) => /* @__PURE__ */ M(
|
|
1120
|
+
Wn,
|
|
1121
|
+
{
|
|
1122
|
+
alphaMap: l,
|
|
1123
|
+
alphaOpacity: f,
|
|
1124
|
+
blendMode: i,
|
|
1125
|
+
blendOpacity: u,
|
|
1126
|
+
cameraTexture: Ne,
|
|
1127
|
+
color: Nt,
|
|
1128
|
+
compositeShading: Z,
|
|
1129
|
+
faceAlphaMaskUrl: w,
|
|
1130
|
+
faceTextureStyle2Url: he,
|
|
1131
|
+
faceTextureUrl: L,
|
|
1132
|
+
masked: T,
|
|
1133
|
+
maskColor: $,
|
|
1134
|
+
maskOpacity: K,
|
|
1135
|
+
maskSourceUrl: N,
|
|
1136
|
+
maskTextureSource: F,
|
|
1137
|
+
materialType: a,
|
|
1138
|
+
opacity: r,
|
|
1139
|
+
shaderPreset: o,
|
|
1140
|
+
side: Pt,
|
|
1141
|
+
textureMap: s
|
|
1142
|
+
}
|
|
1143
|
+
), q = Xn.map(
|
|
1144
|
+
(T) => ({
|
|
1145
|
+
...T,
|
|
1146
|
+
geometryRef: Vt[T.key],
|
|
1147
|
+
meshRef: jt[T.key],
|
|
1148
|
+
visible: $t[T.key]
|
|
1149
|
+
})
|
|
1150
|
+
), Yt = (T) => dn(T, ht, It.current);
|
|
1151
|
+
return en((T) => {
|
|
1152
|
+
var je, $e;
|
|
1153
|
+
const B = Ge.current, re = ($e = (je = pe == null ? void 0 : pe.detectionResults) == null ? void 0 : je.faceLandmarks) == null ? void 0 : $e[e], qt = q.every(
|
|
1154
|
+
(y) => y.geometryRef.current && y.meshRef.current
|
|
1155
|
+
);
|
|
1156
|
+
if (!G || !I || !B || !qt) return;
|
|
1157
|
+
const z = ie.current.update(
|
|
1158
|
+
[re ?? []],
|
|
1159
|
+
T.clock.elapsedTime * 1e3
|
|
1160
|
+
)[0];
|
|
1161
|
+
if (!z || z.length < G.vertexCount) {
|
|
1162
|
+
q.forEach((y) => {
|
|
1163
|
+
y.meshRef.current.visible = !1;
|
|
1164
|
+
});
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
if ((ze.current !== G || q.some((y) => !y.geometryRef.current.index)) && (q.forEach((y) => {
|
|
1168
|
+
$n(y.geometryRef.current, I, y.getIndices(G));
|
|
1169
|
+
}), I.uv.needsUpdate = !0, I.lipEdge.needsUpdate = !0, ze.current = G, le.current = !1), cn(T.clock.elapsedTime, He.current, ut)) return;
|
|
1170
|
+
He.current = T.clock.elapsedTime;
|
|
1171
|
+
const ye = I.position.array, Be = I.faceUv.array, ge = I.uv.array, We = Gn(a, o, s), Xe = Rn(Y), Ve = Xe ? Tn(z) : null, D = X ? Dt.current : null;
|
|
1172
|
+
if (D) {
|
|
1173
|
+
D.x = 0, D.y = 0, D.z = 0;
|
|
1174
|
+
for (let y = 0; y < z.length; y++) {
|
|
1175
|
+
const H = z[y];
|
|
1176
|
+
D.x += H.x, D.y += H.y, D.z += H.z;
|
|
1177
|
+
}
|
|
1178
|
+
D.x /= z.length, D.y /= z.length, D.z /= z.length;
|
|
1179
|
+
}
|
|
1180
|
+
const Jt = Math.min(z.length, G.vertexCount);
|
|
1181
|
+
for (let y = 0; y < Jt; y++) {
|
|
1182
|
+
const H = z[y], Ke = Xe && Ve ? _n(H, Ve, Y, Ot.current) : H, Qt = X && D ? ln(
|
|
1183
|
+
Ke,
|
|
1184
|
+
D,
|
|
1185
|
+
X,
|
|
1186
|
+
Lt.current
|
|
1187
|
+
) : Ke, be = y * 3, de = y * 2, Ee = Yt(Qt);
|
|
1188
|
+
ye[be] = Ee.x, ye[be + 1] = Ee.y, ye[be + 2] = Ee.z, Be[de] = H.x, Be[de + 1] = 1 - H.y, We && (ge[de] = H.x, ge[de + 1] = 1 - H.y);
|
|
1189
|
+
}
|
|
1190
|
+
We ? (B.attributes.uv.needsUpdate = !0, le.current = !0) : le.current && (ge.set(G.uvs), B.attributes.uv.needsUpdate = !0, le.current = !1), q.forEach((y) => {
|
|
1191
|
+
y.meshRef.current.visible = y.visible;
|
|
1192
|
+
}), B.attributes.position.needsUpdate = !0, B.attributes.faceUv.needsUpdate = !0, q.forEach((y) => {
|
|
1193
|
+
y.geometryRef.current.computeVertexNormals();
|
|
1194
|
+
});
|
|
1195
|
+
}), /* @__PURE__ */ M("group", { scale: [me, me, me], children: q.map((T) => {
|
|
1196
|
+
const B = ne ? typeof ne == "function" ? ne({
|
|
1197
|
+
cameraTexture: Ne ?? null,
|
|
1198
|
+
geometryKey: T.key,
|
|
1199
|
+
faceUv: (I == null ? void 0 : I.faceUv) ?? null,
|
|
1200
|
+
lipEdge: (I == null ? void 0 : I.lipEdge) ?? null
|
|
1201
|
+
}) : ne : void 0, re = B instanceof k.Material ? B : void 0;
|
|
1202
|
+
return /* @__PURE__ */ Ie(
|
|
1203
|
+
"mesh",
|
|
1204
|
+
{
|
|
1205
|
+
ref: T.meshRef,
|
|
1206
|
+
renderOrder: lt + T.renderOrderOffset,
|
|
1207
|
+
frustumCulled: !1,
|
|
1208
|
+
material: re,
|
|
1209
|
+
children: [
|
|
1210
|
+
/* @__PURE__ */ M("bufferGeometry", { ref: T.geometryRef }),
|
|
1211
|
+
re ? null : ne ? B : Kt(T.masked)
|
|
1212
|
+
]
|
|
1213
|
+
},
|
|
1214
|
+
`${T.key}:${re ? "instance" : "node"}`
|
|
1215
|
+
);
|
|
1216
|
+
}) });
|
|
1217
|
+
}, Yn = `${se.sdkAssetsBaseUrl}/Canonical_Face_Color.png`, qn = `${se.sdkAssetsBaseUrl}/Canonical_Face_Color_style_2.png`, Jn = `${se.sdkAssetsBaseUrl}/Canonical_Face_Color_Mask.png`, Qn = {
|
|
1218
|
+
...Je,
|
|
1219
|
+
position: { ...Je.position, y: 1e-3 }
|
|
1220
|
+
}, pr = {
|
|
1221
|
+
enabled: !0,
|
|
1222
|
+
faceIndex: 0,
|
|
1223
|
+
targetFps: Nn,
|
|
1224
|
+
...P,
|
|
1225
|
+
showLeftEyeGeometry: !0,
|
|
1226
|
+
showRightEyeGeometry: !0,
|
|
1227
|
+
showMouthGeometry: !0,
|
|
1228
|
+
showNoseGeometry: !0,
|
|
1229
|
+
externalScale: 1,
|
|
1230
|
+
showOverlayMask: !1,
|
|
1231
|
+
showMouthMask: !1,
|
|
1232
|
+
showLeftEyeMask: !1,
|
|
1233
|
+
showRightEyeMask: !1,
|
|
1234
|
+
showNoseMask: !1,
|
|
1235
|
+
maskTextureSource: te.textureSource,
|
|
1236
|
+
maskSourceUrl: "",
|
|
1237
|
+
maskColor: te.color,
|
|
1238
|
+
maskOpacity: te.opacity,
|
|
1239
|
+
faceTextureUrl: Yn,
|
|
1240
|
+
faceTextureStyle2Url: qn,
|
|
1241
|
+
faceAlphaMaskUrl: Jn,
|
|
1242
|
+
renderOrder: it
|
|
1243
|
+
}, Zn = (e) => {
|
|
1244
|
+
const { externalMeshUrl: n, ...t } = e;
|
|
1245
|
+
return { ...t, color: t.baseColor, meshUrl: n };
|
|
1246
|
+
}, er = ({
|
|
1247
|
+
materialOverride: e,
|
|
1248
|
+
value: n
|
|
1249
|
+
}) => ({
|
|
1250
|
+
...Zn(n),
|
|
1251
|
+
materialOverride: e
|
|
1252
|
+
}), yr = (e, n) => {
|
|
1253
|
+
const t = { ...e, ...n };
|
|
1254
|
+
return n.maskTextureSource && !Ue(n.maskTextureSource) && (t.maskSourceUrl = ""), t.materialType === C.shader && n.shaderPreset === V.composite ? {
|
|
1255
|
+
...t,
|
|
1256
|
+
...Qe,
|
|
1257
|
+
materialType: C.shader,
|
|
1258
|
+
shaderPreset: V.composite
|
|
1259
|
+
} : t.materialType === C.shader && t.shaderPreset === V.composite && t.textureMap === j.none ? {
|
|
1260
|
+
...t,
|
|
1261
|
+
textureMap: Qe.textureMap
|
|
1262
|
+
} : t;
|
|
1263
|
+
}, gr = ({ transform: e, value: n, materialOverride: t }) => n.enabled ? /* @__PURE__ */ Ie(et, { children: [
|
|
1264
|
+
/* @__PURE__ */ M(
|
|
1265
|
+
fn,
|
|
1266
|
+
{
|
|
1267
|
+
active: n.enabled,
|
|
1268
|
+
faceIndex: n.faceIndex,
|
|
1269
|
+
numFaces: n.faceIndex + 1,
|
|
1270
|
+
targetFps: n.targetFps
|
|
1271
|
+
}
|
|
1272
|
+
),
|
|
1273
|
+
/* @__PURE__ */ M(
|
|
1274
|
+
Kn,
|
|
1275
|
+
{
|
|
1276
|
+
...er({ value: n, materialOverride: t }),
|
|
1277
|
+
transform: e ?? Qn
|
|
1278
|
+
}
|
|
1279
|
+
)
|
|
1280
|
+
] }) : null;
|
|
1281
|
+
export {
|
|
1282
|
+
Q as A,
|
|
1283
|
+
gn as B,
|
|
1284
|
+
at as C,
|
|
1285
|
+
P as D,
|
|
1286
|
+
Je as E,
|
|
1287
|
+
C as F,
|
|
1288
|
+
fr as G,
|
|
1289
|
+
rt as H,
|
|
1290
|
+
we as I,
|
|
1291
|
+
zn as J,
|
|
1292
|
+
Ue as K,
|
|
1293
|
+
Sn as M,
|
|
1294
|
+
xn as S,
|
|
1295
|
+
ur as T,
|
|
1296
|
+
V as a,
|
|
1297
|
+
oe as b,
|
|
1298
|
+
j as c,
|
|
1299
|
+
ee as d,
|
|
1300
|
+
ct as e,
|
|
1301
|
+
ce as f,
|
|
1302
|
+
Oe as g,
|
|
1303
|
+
Kn as h,
|
|
1304
|
+
Ze as i,
|
|
1305
|
+
pr as j,
|
|
1306
|
+
Qn as k,
|
|
1307
|
+
ke as l,
|
|
1308
|
+
mr as m,
|
|
1309
|
+
Wn as n,
|
|
1310
|
+
gr as o,
|
|
1311
|
+
Jn as p,
|
|
1312
|
+
qn as q,
|
|
1313
|
+
Yn as r,
|
|
1314
|
+
hr as s,
|
|
1315
|
+
Xn as t,
|
|
1316
|
+
Dn as u,
|
|
1317
|
+
er as v,
|
|
1318
|
+
Zn as w,
|
|
1319
|
+
yr as x,
|
|
1320
|
+
Un as y,
|
|
1321
|
+
pn as z
|
|
1322
|
+
};
|