@vincentt-xr/sdk 2.0.0-alpha.1 → 2.0.0-alpha.2
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 +1588 -20
- package/dist/{DebuggerUI-CatYc-RG.cjs → DebuggerUI-B45_Gb9d.cjs} +1 -1
- package/dist/{DebuggerUI-gLMKiVwJ.js → DebuggerUI-Cq28c18s.js} +1 -1
- package/dist/FaceMeshRenderer-6t8OsQhK.js +1195 -0
- package/dist/FaceMeshRenderer-lQLhYIW-.cjs +155 -0
- package/dist/FaceRetouch-CDrL0pXg.js +551 -0
- package/dist/FaceRetouch-DtNl8-4e.cjs +134 -0
- package/dist/audio/AudioEngine.d.ts +3 -1
- package/dist/audio/AudioPlayer.d.ts +29 -0
- package/dist/audio/AudioPlayerLogic.d.ts +4 -0
- package/dist/audio/index.d.ts +2 -0
- package/dist/components/Axes/index.d.ts +6 -0
- package/dist/components/FaceMesh/FaceMeshRenderer.d.ts +17 -0
- package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +17 -1
- package/dist/components/FaceMesh/canonical/FaceMeshMaterial.d.ts +25 -0
- package/dist/components/FaceMesh/canonical/assets.d.ts +3 -0
- package/dist/components/FaceMesh/canonical/geometryGroups.d.ts +9 -0
- package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +2 -0
- package/dist/components/FaceMesh/canonical/shaders.d.ts +2 -0
- package/dist/components/FaceMesh/deform.d.ts +3 -0
- package/dist/components/FaceMesh/index.d.ts +5 -0
- package/dist/components/FaceMesh/material/defaults.d.ts +70 -0
- package/dist/components/FaceMesh/material/index.d.ts +1 -0
- package/dist/components/FaceMesh/material/options.d.ts +5 -1
- package/dist/components/FaceMesh/material/support.d.ts +7 -2
- package/dist/components/FaceMesh/material/textures.d.ts +4 -0
- package/dist/components/FaceMesh/material/types.d.ts +2 -2
- package/dist/components/FaceRetouch/Background.d.ts +5 -6
- package/dist/components/FaceRetouch/FaceRetouch.d.ts +47 -0
- package/dist/components/FaceRetouch/index.d.ts +2 -8
- package/dist/components/FaceRetouch/landmarkMask.d.ts +0 -5
- package/dist/components/FaceRetouch/useFaceRetouchMask.d.ts +3 -7
- package/dist/components/FaceTracker/index.d.ts +5 -3
- package/dist/components/FaceWarp3D/FaceWarp3DHead.d.ts +1 -1
- package/dist/components/HandJoints2D/index.d.ts +1 -1
- package/dist/components/HandTracking2D/HandVisual.d.ts +1 -1
- package/dist/components/HandTracking2D/index.d.ts +1 -1
- package/dist/components/HandTracking2DController/index.d.ts +1 -1
- package/dist/components/HandTracking3D/index.d.ts +1 -1
- package/dist/components/LightObject/index.d.ts +20 -0
- package/dist/components/LookAt/index.d.ts +23 -0
- package/dist/components/MeshRenderer/index.d.ts +58 -0
- package/dist/components/PerspectiveCamera/index.d.ts +2 -8
- package/dist/components/PinToMesh/index.d.ts +47 -0
- package/dist/components/RenderGroupLayer/index.d.ts +6 -0
- package/dist/components/SceneObjectRenderer/index.d.ts +16 -0
- package/dist/components/Screen2D/ScreenTransformFrame.d.ts +11 -0
- package/dist/components/Screen2D/ScreenTransformHelpers.d.ts +19 -0
- package/dist/components/Screen2D/ScreenTransformInteraction.d.ts +18 -0
- package/dist/components/Screen2D/index.d.ts +5 -0
- package/dist/components/ScreenGlass/defaults.d.ts +3 -0
- package/dist/components/ScreenGlass/index.d.ts +5 -0
- package/dist/components/ScreenGlass/shaders.d.ts +2 -0
- package/dist/components/ScreenGlass/types.d.ts +10 -0
- package/dist/components/ScreenGradient/defaults.d.ts +5 -0
- package/dist/components/ScreenGradient/index.d.ts +5 -0
- package/dist/components/ScreenGradient/shaders.d.ts +2 -0
- package/dist/components/ScreenGradient/types.d.ts +19 -0
- package/dist/components/ScreenImage/ScreenImage.d.ts +4 -0
- package/dist/components/ScreenImage/components/DynamicTextureSync.d.ts +9 -0
- package/dist/components/ScreenImage/components/ScreenImageBody.d.ts +9 -0
- package/dist/components/ScreenImage/components/ScreenImageFrame.d.ts +9 -0
- package/dist/components/ScreenImage/components/ScreenImageTransformFrame.d.ts +9 -0
- package/dist/components/ScreenImage/fit.d.ts +52 -0
- package/dist/components/ScreenImage/index.d.ts +8 -87
- package/dist/components/ScreenImage/materials/ScreenImageBlendMaterial.d.ts +9 -0
- package/dist/components/ScreenImage/materials/ScreenImageMatcap.d.ts +3 -0
- package/dist/components/ScreenImage/source.d.ts +16 -0
- package/dist/components/ScreenImage/types.d.ts +37 -0
- package/dist/components/ScreenImage/utils/ScreenImageConstants.d.ts +9 -0
- package/dist/components/ScreenImage/utils/ScreenImageHelpers.d.ts +4 -0
- package/dist/components/ScreenShape/geometry.d.ts +5 -0
- package/dist/components/ScreenShape/index.d.ts +5 -0
- package/dist/components/ScreenShape/types.d.ts +41 -0
- package/dist/components/ScreenSpaceUI/ScreenTransformGuide.d.ts +15 -0
- package/dist/components/ScreenSpaceUI/ScreenTransformOverlayGuide.d.ts +9 -0
- package/dist/components/ScreenSpaceUI/index.d.ts +2 -0
- package/dist/components/ScreenText/components/ScreenTextBody.d.ts +2 -0
- package/dist/components/ScreenText/components/ScreenTextTransformFrame.d.ts +9 -0
- package/dist/components/ScreenText/constants.d.ts +5 -0
- package/dist/components/ScreenText/index.d.ts +6 -20
- package/dist/components/ScreenText/types.d.ts +31 -0
- package/dist/components/ScreenText/utils/ScreenTextHelpers.d.ts +14 -0
- package/dist/components/ScreenText/utils/ScreenTextMappings.d.ts +17 -0
- package/dist/components/SequentialRenderPasses/index.d.ts +6 -0
- package/dist/components/TextLabel/TextLabel.d.ts +5 -0
- package/dist/components/TextLabel/alignment.d.ts +4 -0
- package/dist/components/TextLabel/bend.d.ts +9 -0
- package/dist/components/TextLabel/canvas/buildTextLabelTexture.d.ts +4 -0
- package/dist/components/TextLabel/canvas/canvasTypography.d.ts +13 -0
- package/dist/components/TextLabel/canvas/drawBackground.d.ts +21 -0
- package/dist/components/TextLabel/canvas/drawEffects.d.ts +34 -0
- package/dist/components/TextLabel/canvas/drawText.d.ts +19 -0
- package/dist/components/TextLabel/components/TextLabelMesh.d.ts +13 -0
- package/dist/components/TextLabel/constants.d.ts +2 -0
- package/dist/components/TextLabel/hooks/useTextLabelTexture.d.ts +7 -0
- package/dist/components/TextLabel/index.d.ts +2 -161
- package/dist/components/TextLabel/layout/measurement.d.ts +8 -0
- package/dist/components/TextLabel/layout/resolveTextLayout.d.ts +25 -0
- package/dist/components/TextLabel/layout/wrapText.d.ts +6 -0
- package/dist/components/TextLabel/types.d.ts +227 -0
- package/dist/components/TrackingAnchor/index.d.ts +18 -2
- package/dist/components/Transform3D/index.d.ts +30 -0
- package/dist/components/XRMediaSurface/index.d.ts +6 -6
- package/dist/components/XRViewport/XRViewport.d.ts +11 -0
- package/dist/components/XRViewport/components/HiddenMedia.d.ts +7 -0
- package/dist/components/XRViewport/components/MediaAssetPicker.d.ts +8 -0
- package/dist/components/XRViewport/components/MediaControlStack.d.ts +13 -0
- package/dist/components/XRViewport/components/XRViewportLayers.d.ts +30 -0
- package/dist/components/XRViewport/constants.d.ts +24 -0
- package/dist/components/XRViewport/contexts.d.ts +6 -0
- package/dist/components/XRViewport/hooks/useViewportExternalFaces.d.ts +13 -0
- package/dist/components/XRViewport/hooks/useViewportMediaSource.d.ts +16 -0
- package/dist/components/XRViewport/hooks/useViewportMediaTexture.d.ts +10 -0
- package/dist/components/XRViewport/hooks/useViewportPipeline.d.ts +41 -0
- package/dist/components/XRViewport/hooks/useViewportRenderState.d.ts +47 -0
- package/dist/components/XRViewport/index.d.ts +3 -118
- package/dist/components/XRViewport/layout.d.ts +16 -0
- package/dist/components/XRViewport/slots.d.ts +16 -0
- package/dist/components/XRViewport/types.d.ts +89 -0
- package/dist/components/XRViewport/useViewportSize.d.ts +3 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/contexts-BKvTIayr.cjs +1 -0
- package/dist/contexts-Bk5zz_VR.js +214 -0
- package/dist/debug-ui/component-editor/index.d.ts +19 -0
- package/dist/debug-ui/face-mesh-renderer-settings/index.d.ts +8 -0
- package/dist/debug-ui/face-retouch/index.d.ts +11 -0
- package/dist/debug-ui/hand-joints-2d/index.d.ts +1 -1
- package/dist/debug-ui/hand-tracking-2d/index.d.ts +1 -1
- package/dist/debug-ui/hand-tracking-2d-controller/index.d.ts +1 -1
- package/dist/debug-ui/hand-tracking-3d/index.d.ts +1 -1
- package/dist/debug-ui/hierarchy-panel/index.d.ts +29 -0
- package/dist/debug-ui/index.d.ts +25 -2
- package/dist/debug-ui/layer-panel/index.d.ts +3 -2
- package/dist/debug-ui/media-source/index.d.ts +2 -0
- package/dist/debug-ui/media-source/session.d.ts +12 -0
- package/dist/debug-ui/media-source.cjs +1 -1
- package/dist/debug-ui/media-source.js +6 -4
- package/dist/debug-ui/mesh-renderer-settings/index.d.ts +6 -0
- package/dist/debug-ui/object-inspector-panel/index.d.ts +25 -0
- package/dist/debug-ui/pin-to-mesh-settings/index.d.ts +10 -0
- package/dist/debug-ui/scene-editor/context.d.ts +38 -0
- package/dist/debug-ui/scene-editor/hierarchy-panel.d.ts +9 -0
- package/dist/debug-ui/scene-editor/index.d.ts +11 -0
- package/dist/debug-ui/scene-editor/inspector-panel.d.ts +7 -0
- package/dist/debug-ui/scene-editor/store-utils.d.ts +2 -0
- package/dist/debug-ui/scene-editor/viewport-toolbar.d.ts +4 -0
- package/dist/debug-ui/scene-editor/viewport.d.ts +21 -0
- package/dist/debug-ui/screen-glass-settings/index.d.ts +6 -0
- package/dist/debug-ui/screen-gradient-settings/GradientStopsEditor.d.ts +5 -0
- package/dist/debug-ui/screen-gradient-settings/index.d.ts +6 -0
- package/dist/debug-ui/screen-gradient-settings/styles.d.ts +3 -0
- package/dist/debug-ui/screen-image-settings/index.d.ts +4 -2
- package/dist/debug-ui/screen-shape-settings/index.d.ts +6 -0
- package/dist/debug-ui/screen-text-settings/NumberField.d.ts +9 -0
- package/dist/debug-ui/screen-text-settings/ScreenTextSettingsPanel.d.ts +3 -0
- package/dist/debug-ui/screen-text-settings/controls/NestedSection.d.ts +7 -0
- package/dist/debug-ui/screen-text-settings/controls/Section.d.ts +8 -0
- package/dist/debug-ui/screen-text-settings/controls/icons.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/index.d.ts +2 -122
- package/dist/debug-ui/screen-text-settings/sections/BackgroundSection.d.ts +8 -0
- package/dist/debug-ui/screen-text-settings/sections/ContentSection.d.ts +5 -0
- package/dist/debug-ui/screen-text-settings/sections/EffectsSection.d.ts +25 -0
- package/dist/debug-ui/screen-text-settings/sections/StyleSection.d.ts +5 -0
- package/dist/debug-ui/screen-text-settings/sections/TransformSection.d.ts +5 -0
- package/dist/debug-ui/screen-text-settings/sections/background/BackgroundFillControls.d.ts +2 -0
- package/dist/debug-ui/screen-text-settings/sections/background/BackgroundSizeControls.d.ts +2 -0
- package/dist/debug-ui/screen-text-settings/sections/background/BackgroundStrokeControls.d.ts +2 -0
- package/dist/debug-ui/screen-text-settings/sections/background/types.d.ts +7 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/BendEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/EffectChrome.d.ts +21 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/GlowEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/InnerShadowEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/OutlineEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/ShadowEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/types.d.ts +14 -0
- package/dist/debug-ui/screen-text-settings/settings.d.ts +90 -0
- package/dist/debug-ui/screen-text-settings/styles.d.ts +26 -0
- package/dist/debug-ui/screen-text-settings/transform.d.ts +6 -0
- package/dist/debug-ui/screen-text-settings/types.d.ts +9 -0
- package/dist/debug-ui/shared/ScreenTransformSection.d.ts +6 -3
- package/dist/debug-ui/transform-3d-settings/index.d.ts +11 -0
- package/dist/debug-ui.cjs +3 -13
- package/dist/debug-ui.js +7896 -5098
- package/dist/drawNormalizedCrop-B-7zU-Xw.cjs +1 -0
- package/dist/drawNormalizedCrop-CRdIDyl1.js +44 -0
- package/dist/entries/all.d.ts +1 -0
- package/dist/entries/core.d.ts +53 -6
- package/dist/entries/face-effects.d.ts +10 -8
- package/dist/entries/internal.d.ts +1 -1
- package/dist/entries/low-level.d.ts +18 -4
- package/dist/entries/scene-object.d.ts +10 -0
- package/dist/entries/tracking.d.ts +25 -2
- package/dist/face-action/index.d.ts +34 -0
- package/dist/face-attribute-expression/index.d.ts +10 -0
- package/dist/face-effects.cjs +1 -342
- package/dist/face-effects.js +1391 -2767
- package/dist/face-info/blendshapes.d.ts +3 -0
- package/dist/face-info/derive.d.ts +8 -0
- package/dist/face-info/drawFaceCrop.d.ts +10 -0
- package/dist/face-info/getFaceInfo.d.ts +8 -0
- package/dist/face-info/index.d.ts +8 -0
- package/dist/face-info/landmarks.d.ts +21 -0
- package/dist/face-info/types.d.ts +52 -0
- package/dist/getFaceInfo-CyPAKh3h.cjs +1 -0
- package/dist/getFaceInfo-hUKMLFcr.js +118 -0
- package/dist/{handJoints2d.d.ts → hand/handJoints2d.d.ts} +1 -1
- package/dist/{handTracking2d.d.ts → hand/handTracking2d.d.ts} +1 -1
- package/dist/{handTracking2dController.d.ts → hand/handTracking2dController.d.ts} +1 -1
- package/dist/{handTracking3d.d.ts → hand/handTracking3d.d.ts} +1 -1
- package/dist/hooks/faceResults.d.ts +1 -1
- package/dist/hooks/useCalibrationFaceTracker.d.ts +1 -1
- package/dist/hooks/useFaceAction.d.ts +3 -0
- package/dist/hooks/useFaceAttributeExpression.d.ts +16 -0
- package/dist/hooks/useFaceDetection.d.ts +18 -0
- package/dist/hooks/useFaceInfo.d.ts +7 -0
- package/dist/hooks/useFaceInfos.d.ts +15 -0
- package/dist/hooks/useFaceResultReader.d.ts +10 -0
- package/dist/hooks/useFrameCapture.d.ts +18 -0
- package/dist/hooks/useMediaRecorder.d.ts +14 -2
- package/dist/hooks/useOwnedTexture.d.ts +6 -0
- package/dist/hooks/useTrackerContext.d.ts +2 -2
- package/dist/hooks/useXRSession/facade.d.ts +3 -0
- package/dist/hooks/useXRSession/registry.d.ts +9 -0
- package/dist/index-82aENaRq.cjs +1 -0
- package/dist/{index-BGNbrc4C.js → index-BgQAX8rs.js} +213 -125
- package/dist/index-CEc1CAmB.cjs +1 -0
- package/dist/index-CTHeBQOs.js +178 -0
- package/dist/index-D4bLzBr6.cjs +1 -0
- package/dist/index-DSpzjuqd.cjs +1 -0
- package/dist/index-Di70KWuY.js +2049 -0
- package/dist/index-DzEzkBIH.cjs +17 -0
- package/dist/{index-safCs_af.js → index-JygePOwo.js} +565 -508
- package/dist/index-UC0Ux38E.js +111 -0
- package/dist/{internal-Cae1ps15.js → internal-DuMPpcbp.js} +86 -80
- package/dist/internal-i2JkM85N.cjs +1 -0
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +2 -2
- package/dist/low-level.cjs +1 -1
- package/dist/low-level.js +1229 -86
- package/dist/main.cjs +1 -73
- package/dist/main.js +545 -1693
- package/dist/material/MaterialFill.d.ts +20 -0
- package/dist/material/MeshMaterial.d.ts +14 -0
- package/dist/material/index.d.ts +2 -0
- package/dist/models/Body/index.d.ts +1 -1
- package/dist/models/Face/index.d.ts +1 -0
- package/dist/models/Face/rotation.d.ts +3 -0
- package/dist/render/renderGroups.d.ts +47 -0
- package/dist/render/renderPasses.d.ts +18 -0
- package/dist/renderGroups-C9QJrAXu.js +152 -0
- package/dist/renderGroups-Dvm1J4lW.cjs +1 -0
- package/dist/renderLayers-lDtL0_43.cjs +1 -0
- package/dist/renderLayers-zrK2pv5O.js +13 -0
- package/dist/renderPasses-CT5iBwtg.cjs +21 -0
- package/dist/renderPasses-CjgG_6kQ.js +1500 -0
- package/dist/scene-object/index.d.ts +146 -0
- package/dist/scene-object/runtimeRegistry.d.ts +14 -0
- package/dist/scene-object.cjs +1 -0
- package/dist/scene-object.js +40 -0
- package/dist/{screenImageSettings.d.ts → screen-image/screenImageSettings.d.ts} +9 -2
- package/dist/{screenTextSettings.d.ts → screen-text/screenTextSettings.d.ts} +18 -2
- package/dist/screen2d/coordinates.d.ts +87 -0
- package/dist/screen2d/index.d.ts +3 -0
- package/dist/screen2d/screenTransform.d.ts +47 -0
- package/dist/screen2d/smoothing.d.ts +5 -0
- package/dist/{selectors-BLl2JUWW.cjs → selectors-2QvO5RYY.cjs} +1 -1
- package/dist/{selectors-CXd_x-6t.js → selectors-Dw3C-gSk.js} +3 -3
- package/dist/services/MetricsCollector/index.d.ts +7 -1
- package/dist/services/MetricsCollector/utils.d.ts +1 -1
- package/dist/session-BChR4TgK.cjs +31 -0
- package/dist/session-C1StwN0f.js +363 -0
- package/dist/texture/animatedTexture.d.ts +61 -0
- package/dist/texture/animationMath.d.ts +8 -0
- package/dist/texture/sourceResolver.d.ts +30 -0
- package/dist/tracking.cjs +1 -1
- package/dist/tracking.js +580 -321
- package/dist/types/face.d.ts +1 -13
- package/dist/types/index.d.ts +0 -1
- package/dist/types/nodes.d.ts +2 -1
- package/dist/types/session.d.ts +2 -0
- package/dist/types/tracking.d.ts +8 -2
- package/dist/types/util-types.d.ts +1 -1
- package/dist/useFaceInfo-C-WfMlYp.cjs +1 -0
- package/dist/useFaceInfo-CwsHZedC.js +62 -0
- package/dist/useFaceResults-CkFc1egZ.js +19 -0
- package/dist/useFaceResults-VcFdOUFV.cjs +1 -0
- package/dist/utils/drawNormalizedCrop.d.ts +22 -0
- package/dist/utils/integrity.d.ts +4 -25
- package/dist/utils/landmarkBounds.d.ts +1 -1
- package/dist/utils/logger.d.ts +2 -2
- package/docs/MIGRATION_GUIDE.md +589 -0
- package/docs/SDK_DOCUMENTATION.md +1155 -0
- package/docs/api/audio.mdx +36 -0
- package/docs/api/behavior-components.mdx +164 -0
- package/docs/api/capture-recording.mdx +103 -0
- package/docs/api/debug-ui-scene-editor.mdx +249 -0
- package/docs/api/face-actions.mdx +104 -0
- package/docs/api/face-attribute-expression.mdx +87 -0
- package/docs/api/face-binding-anchors.mdx +53 -0
- package/docs/api/face-effects.mdx +19 -0
- package/docs/api/face-info.mdx +112 -0
- package/docs/api/face-mesh.mdx +98 -0
- package/docs/api/face-painting.mdx +33 -0
- package/docs/api/face-retouching.mdx +73 -0
- package/docs/api/material-render-state.mdx +132 -0
- package/docs/api/runtime-3d.mdx +311 -0
- package/docs/api/scene-object-store.mdx +213 -0
- package/docs/api/screen-image.mdx +41 -0
- package/docs/api/screen-shape.mdx +64 -0
- package/docs/api/screen-space-coordinates.mdx +41 -0
- package/docs/api/screen-text.mdx +39 -0
- package/docs/api/texture-sources.mdx +55 -0
- package/docs/api/trackers.mdx +46 -0
- package/docs/docs.json +70 -0
- package/docs/examples/scene-object-recipes.mdx +194 -0
- package/docs/guides/harness-debug-ui.mdx +139 -0
- package/docs/inspector/hierarchy-panel.mdx +51 -0
- package/docs/inspector/object-inspector-panel.mdx +51 -0
- package/docs/introduction.mdx +121 -0
- package/docs/scene-objects/overview.mdx +127 -0
- package/docs/scene-objects/render-groups.mdx +77 -0
- package/docs/scene-objects/runtime-rendering.mdx +75 -0
- package/docs/texture-api-consumer.md +58 -0
- package/package.json +37 -7
- package/dist/MediaSourceSwitcher-C-xYg0nQ.js +0 -317
- package/dist/MediaSourceSwitcher-Cq3g4IKw.cjs +0 -31
- package/dist/components/FaceRetouch/defaults.d.ts +0 -13
- package/dist/components/FaceRetouch/retouchRegions.d.ts +0 -23
- package/dist/components/FaceRetouch/useFaceRetouchRegions.d.ts +0 -12
- package/dist/defaults-BLpcN3pG.cjs +0 -1
- package/dist/defaults-LtY4M7dg.js +0 -55
- package/dist/index-BXyObVHF.cjs +0 -1
- package/dist/index-CY3bUAcW.js +0 -12
- package/dist/index-C_Duh13c.cjs +0 -1
- package/dist/index-D8fpPQkC.cjs +0 -1
- package/dist/index-DxshgBu0.cjs +0 -1
- package/dist/index-O-2crZ3M.js +0 -1102
- package/dist/internal-BjyhBP8i.cjs +0 -1
- package/dist/modules/XRClient/index.d.ts +0 -9
- package/dist/modules/index.d.ts +0 -1
- package/dist/screenImageSettings-6NRg4cx9.js +0 -39
- package/dist/screenImageSettings-y_B4_767.cjs +0 -1
- package/dist/services/ApiService.d.ts +0 -12
- package/dist/types/client.d.ts +0 -3
- package/dist/useFaceResults-cpsSmKKc.js +0 -81
- package/dist/useFaceResults-hVUJYSEY.cjs +0 -1
- package/dist/useXRModel-3DcUa28n.cjs +0 -1
- package/dist/useXRModel-BMJE1hrk.js +0 -28
- /package/dist/{layerStack.d.ts → render/layerStack.d.ts} +0 -0
- /package/dist/{screenImagePresets.d.ts → screen-image/screenImagePresets.d.ts} +0 -0
- /package/dist/{screenTextPresets.d.ts → screen-text/screenTextPresets.d.ts} +0 -0
package/dist/face-effects.cjs
CHANGED
|
@@ -1,342 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("three"),A=require("react/jsx-runtime"),re=require("@react-three/fiber"),E=require("react"),nt=require("./index-DxshgBu0.cjs"),Qe=require("./selectors-BLl2JUWW.cjs"),$e=require("./index-BXyObVHF.cjs"),ye=require("./index-D8fpPQkC.cjs"),Et=require("./defaults-BLpcN3pG.cjs"),He=require("@react-three/drei");function Wt(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const S=Wt(d),me=a=>Math.min(1,Math.max(0,a)),U=(a,e,t)=>me(1-Math.abs(a-e)/t),zt=a=>{let e=1/0,t=-1/0,s=1/0,n=-1/0;for(const c of a)e=Math.min(e,c.x),t=Math.max(t,c.x),s=Math.min(s,c.y),n=Math.max(n,c.y);const o=Math.max(t-e,.001),r=Math.max(n-s,.001);return{centerX:e+o*.5,centerY:s+r*.5,width:o,height:r}},qt=a=>a!=null&&a.enabled?(a.strength??1)!==0&&Object.entries(a).some(([e,t])=>e!=="enabled"&&e!=="strength"&&typeof t=="number"&&t!==0):!1,Zt=(a,e,t,s)=>{const n=t.enabled?t.strength??1:0;if(n===0)return s.x=a.x,s.y=a.y,s.z=a.z,s;const o=(a.x-e.centerX)/e.width,r=(a.y-e.centerY)/e.height,c=Math.abs(o),i=me((-r+.42)/.55),l=U(r,-.02,.34),h=U(r,-.24,.16)*me((c-.05)/.28),u=U(r,.02,.26)*U(c,0,.18),f=U(r,.29,.18)*U(c,0,.36),p=me((r-.16)/.36),T=l*U(c,.34,.22),x=i*U(c,0,.48),g=U(r,-.19,.1)*me((c-.05)/.3),m=U(r,.48,.2)*U(c,0,.26);let v=a.x,M=a.y,b=a.z;const w=(N,L=1)=>{v+=o*e.width*N*n*L},C=(N,L=1)=>{M+=r*e.height*N*n*L};w(t.faceWidth??0),C(t.faceHeight??0),w(t.faceRoundness??0,l*(1-c)),M-=e.height*(t.midfaceHeight??0)*n*l*.25,C(-(t.foreheadHeight??0),x),w(t.foreheadWidth??0,x),w(t.cheekboneWidth??0,U(r,-.06,.16)*U(c,.34,.2)),w(t.cheekWidth??0,T),w(t.jawWidth??0,p),C(t.chinHeight??0,m),M-=e.height*(t.scalpHeight??0)*n*i*.3,b-=(t.midfaceDepth??0)*n*l*.08,b+=(t.cheekHollowness??0)*n*T*.06,b-=(t.browDepth??0)*n*g*.05,M-=e.height*(t.browHeight??0)*n*g*.2,v+=Math.sign(o||1)*e.width*(t.browDistance??0)*n*g*.16;const _=(t.headCurve??0)*n*(r+.1);b-=_*_*.04*Math.sign(t.headCurve??0),v+=e.width*(t.faceTwist??0)*n*r*.18;const P=(t.faceSwirl??0)*n*.22;v+=-r*e.width*P,M+=o*e.height*P;const I=o<0?t.leftEyeSize??0:t.rightEyeSize??0,F=((t.eyeSize??0)+I)*n*h;v+=o*e.width*F*.45,M+=(r+.24)*e.height*F*.7,v+=Math.sign(o||1)*e.width*(t.eyeDistance??0)*n*h*.2,v+=e.width*(o<0?t.leftEyeX??0:t.rightEyeX??0)*n*h*.15,M+=e.height*(o<0?t.leftEyeY??0:t.rightEyeY??0)*n*h*.15;const D=(t.noseSize??0)*n*u;return v+=o*e.width*D*.7,M+=(r-.02)*e.height*D*.5,M+=e.height*(t.noseLength??0)*n*u*Math.max(r+.08,0)*.4,b-=(t.noseSize??0)*n*u*.08,v+=o*e.width*(t.mouthWidth??0)*n*f,M+=(r-.29)*e.height*(t.mouthHeight??0)*n*f,s.x=v,s.y=M,s.z=b,s},Ge=new Set([61,146,91,181,84,17,314,405,321,375,291,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415]),je=new Set([33,7,163,144,145,153,154,155,133,173,157,158,159,160,161,246]),Xe=new Set([362,382,381,380,374,373,390,249,263,466,388,387,386,385,384,398]),Qt=new Set([814,815,816,817,818,819,830,831,832,833]),$t=(a,e,t)=>{const s=Ge.has(a)&&Ge.has(e)&&Ge.has(t),n=je.has(a)&&je.has(e)&&je.has(t),o=Xe.has(a)&&Xe.has(e)&&Xe.has(t);return s?"mouth":n||o?"eye":"base"},St=a=>{const e=[],t=[],s=[],n=[],o=[],r=[];let c=0,i=0;a.split(`
|
|
2
|
-
`).forEach(h=>{const u=h.trim();if(!u)return;if(u.startsWith("v ")){c+=1;return}if(u.startsWith("vt ")){const[,x,g]=u.split(/\s+/);o.push([Number(x),Number(g)]);return}if(!u.startsWith("f "))return;const f=i;i+=1;const[,...p]=u.split(/\s+/),T=p.map(x=>{const[g,m]=x.split("/"),v=Number(g)-1,M=Number(m)-1;return M>=0&&o[M]&&!r[v]&&(r[v]=o[M]),v});if(!(T.length<3))for(let x=1;x<T.length-1;x+=1){const g=T[0],m=T[x],v=T[x+1],M=$t(g,m,v);Qt.has(f)?n.push(g,m,v):M==="mouth"?t.push(g,m,v):M==="eye"?s.push(g,m,v):e.push(g,m,v)}});const l=[];for(let h=0;h<c;h+=1){const[u,f]=r[h]??[0,0];l.push(u,f)}return{baseIndices:new Uint16Array(e),mouthIndices:new Uint16Array(t),eyeIndices:new Uint16Array(s),noseIndices:new Uint16Array(n),uvs:new Float32Array(l),vertexCount:c}},Jt="canonical_face_model.obj",en=new TextDecoder("utf-8"),Ke=new Map,tn=a=>{const e=Ke.get(a);if(e)return e;const t=nt.fetchAndVerify(a).then(s=>St(en.decode(s))).catch(s=>{throw Ke.delete(a),s});return Ke.set(a,t),t},wt=a=>{const{mesh:e,url:t}=a??{},s=t??`${ye.libConfig.sdkAssetsBaseUrl}/${Jt}`,[n,o]=E.useState(e??null);return E.useEffect(()=>{if(e){o(e);return}let r=!1;return tn(s).then(c=>{r||o(c)}).catch(c=>{r||console.error(`${ye.libConfig.loggerPrefix} canonical face mesh load failed`,c)}),()=>{r=!0}},[e,s]),n},Je={normal:0,add:1,subtract:2,multiply:3,screen:4,overlay:5,softLight:6,hardLight:7,lighten:8,darken:9,difference:10,exclusion:11},Ye="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO2YpZcAAAAASUVORK5CYII=",nn={front:S.FrontSide,back:S.BackSide,double:S.DoubleSide},sn=`
|
|
3
|
-
attribute vec2 faceUv;
|
|
4
|
-
varying vec2 vUv;
|
|
5
|
-
varying vec2 vFaceUv;
|
|
6
|
-
varying vec3 vNormal;
|
|
7
|
-
|
|
8
|
-
void main() {
|
|
9
|
-
vUv = uv;
|
|
10
|
-
vFaceUv = faceUv;
|
|
11
|
-
vNormal = normalize(normalMatrix * normal);
|
|
12
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
13
|
-
}
|
|
14
|
-
`,rn=`
|
|
15
|
-
uniform sampler2D cameraTexture;
|
|
16
|
-
uniform sampler2D canonicalTexture;
|
|
17
|
-
uniform sampler2D alphaMask;
|
|
18
|
-
uniform vec3 textureTint;
|
|
19
|
-
uniform float opacity;
|
|
20
|
-
uniform float blendMode;
|
|
21
|
-
uniform float blendOpacity;
|
|
22
|
-
uniform float useCanonicalTexture;
|
|
23
|
-
uniform float useAlphaMask;
|
|
24
|
-
uniform float alphaOpacity;
|
|
25
|
-
uniform float compositeShading;
|
|
26
|
-
uniform vec3 lightDirection;
|
|
27
|
-
uniform float ambientStrength;
|
|
28
|
-
uniform float directionalStrength;
|
|
29
|
-
varying vec2 vUv;
|
|
30
|
-
varying vec2 vFaceUv;
|
|
31
|
-
varying vec3 vNormal;
|
|
32
|
-
|
|
33
|
-
vec3 linearToSrgb(vec3 value) {
|
|
34
|
-
vec3 low = value * 12.92;
|
|
35
|
-
vec3 high = 1.055 * pow(max(value, vec3(0.0)), vec3(1.0 / 2.4)) - 0.055;
|
|
36
|
-
return mix(high, low, step(value, vec3(0.0031308)));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
vec3 srgbToLinear(vec3 value) {
|
|
40
|
-
vec3 low = value / 12.92;
|
|
41
|
-
vec3 high = pow(max((value + 0.055) / 1.055, vec3(0.0)), vec3(2.4));
|
|
42
|
-
return mix(high, low, step(value, vec3(0.04045)));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
float overlayChannel(float base, float blend) {
|
|
46
|
-
return base < 0.5 ? 2.0 * base * blend : 1.0 - 2.0 * (1.0 - base) * (1.0 - blend);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
float hardLightChannel(float base, float blend) {
|
|
50
|
-
return blend < 0.5 ? 2.0 * base * blend : 1.0 - 2.0 * (1.0 - base) * (1.0 - blend);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
float softLightChannel(float base, float blend) {
|
|
54
|
-
if (blend <= 0.5) {
|
|
55
|
-
return base - (1.0 - 2.0 * blend) * base * (1.0 - base);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
float d = base <= 0.25
|
|
59
|
-
? ((16.0 * base - 12.0) * base + 4.0) * base
|
|
60
|
-
: sqrt(base);
|
|
61
|
-
|
|
62
|
-
return base + (2.0 * blend - 1.0) * (d - base);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
vec3 applyBlendMode(vec3 base, vec3 blend, float mode) {
|
|
66
|
-
if (mode < 0.5) return blend;
|
|
67
|
-
if (mode < 1.5) return min(base + blend, 1.0);
|
|
68
|
-
if (mode < 2.5) return max(base - blend, 0.0);
|
|
69
|
-
if (mode < 3.5) return base * blend;
|
|
70
|
-
if (mode < 4.5) return 1.0 - (1.0 - base) * (1.0 - blend);
|
|
71
|
-
if (mode < 5.5) {
|
|
72
|
-
return vec3(
|
|
73
|
-
overlayChannel(base.r, blend.r),
|
|
74
|
-
overlayChannel(base.g, blend.g),
|
|
75
|
-
overlayChannel(base.b, blend.b)
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
if (mode < 6.5) {
|
|
79
|
-
return vec3(
|
|
80
|
-
softLightChannel(base.r, blend.r),
|
|
81
|
-
softLightChannel(base.g, blend.g),
|
|
82
|
-
softLightChannel(base.b, blend.b)
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
if (mode < 7.5) {
|
|
86
|
-
return vec3(
|
|
87
|
-
hardLightChannel(base.r, blend.r),
|
|
88
|
-
hardLightChannel(base.g, blend.g),
|
|
89
|
-
hardLightChannel(base.b, blend.b)
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
if (mode < 8.5) return max(base, blend);
|
|
93
|
-
if (mode < 9.5) return min(base, blend);
|
|
94
|
-
if (mode < 10.5) return abs(base - blend);
|
|
95
|
-
return base + blend - 2.0 * base * blend;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
void main() {
|
|
99
|
-
vec3 base = linearToSrgb(texture2D(cameraTexture, vFaceUv).rgb);
|
|
100
|
-
vec4 textureSample = texture2D(canonicalTexture, vUv);
|
|
101
|
-
vec3 blend = linearToSrgb(textureSample.rgb) * textureTint;
|
|
102
|
-
float light = ambientStrength + max(dot(normalize(vNormal), normalize(lightDirection)), 0.0) * directionalStrength;
|
|
103
|
-
blend *= mix(1.0, clamp(light, 0.35, 1.35), compositeShading);
|
|
104
|
-
float maskSample = texture2D(alphaMask, vUv).r;
|
|
105
|
-
float mask = useAlphaMask > 0.5 ? mix(1.0, maskSample, alphaOpacity) : 1.0;
|
|
106
|
-
float textureAlpha = useCanonicalTexture > 0.5 ? textureSample.a : 1.0;
|
|
107
|
-
vec3 blended = applyBlendMode(base, blend, blendMode);
|
|
108
|
-
vec3 color = useCanonicalTexture > 0.5 ? mix(base, blended, blendOpacity) : base;
|
|
109
|
-
gl_FragColor = vec4(srgbToLinear(color), opacity * mask * textureAlpha);
|
|
110
|
-
}
|
|
111
|
-
`,on=`
|
|
112
|
-
varying vec2 vUv;
|
|
113
|
-
varying vec3 vNormal;
|
|
114
|
-
|
|
115
|
-
void main() {
|
|
116
|
-
vUv = uv;
|
|
117
|
-
vNormal = normalize(normalMatrix * normal);
|
|
118
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
119
|
-
}
|
|
120
|
-
`,an=`
|
|
121
|
-
uniform vec3 color;
|
|
122
|
-
uniform float opacity;
|
|
123
|
-
varying vec3 vNormal;
|
|
124
|
-
|
|
125
|
-
void main() {
|
|
126
|
-
vec3 normalTint = 0.5 + 0.5 * normalize(vNormal);
|
|
127
|
-
vec3 base = color * mix(vec3(1.0), normalTint, 0.35);
|
|
128
|
-
|
|
129
|
-
gl_FragColor = vec4(base, opacity);
|
|
130
|
-
}
|
|
131
|
-
`,cn=()=>{const a=new Uint8Array([32,32,32,255,96,96,96,255,176,176,176,255,255,255,255,255]),e=new S.DataTexture(a,4,1,S.RGBAFormat);return e.minFilter=S.NearestFilter,e.magFilter=S.NearestFilter,e.generateMipmaps=!1,e.needsUpdate=!0,e},ln=()=>{const a=document.createElement("canvas");a.width=256,a.height=256;const e=a.getContext("2d");if(!e)return new S.CanvasTexture(a);const t=e.createRadialGradient(96,80,10,128,128,128);t.addColorStop(0,"#ffffff"),t.addColorStop(.18,"#f7d794"),t.addColorStop(.45,"#d97706"),t.addColorStop(.72,"#78350f"),t.addColorStop(1,"#120701"),e.fillStyle=t,e.fillRect(0,0,a.width,a.height);const s=new S.CanvasTexture(a);return s.needsUpdate=!0,s},un=({faceIndex:a=0,baseColor:e,color:t="#38bdf8",opacity:s=.45,materialType:n="basic",shaderPreset:o="basicShader",textureMap:r="none",alphaMap:c="none",alphaOpacity:i=0,side:l="front",blendMode:h="normal",blendOpacity:u=1,showMouthMask:f=!0,showEyeMask:p=!0,showNoseMask:T=!0,maskTextureSource:x="none",maskColor:g="#111111",maskOpacity:m=0,faceTextureUrl:v="",faceTextureStyle2Url:M="",faceAlphaMaskUrl:b="",compositeShading:w=!1,faceWarp3D:C,renderOrder:_=10,mesh:P,meshUrl:I})=>{const F=Qe.useXRModelNode(nt.XRModel.FACE_TRACKER),D=Qe.useXRCameraTexture(),{camera:N}=re.useThree(),L=wt({mesh:P,url:I}),y=re.useLoader(S.TextureLoader,v||Ye),ae=re.useLoader(S.TextureLoader,M||v||Ye),G=re.useLoader(S.TextureLoader,b||Ye),Z=E.useMemo(()=>cn(),[]),ge=E.useMemo(()=>ln(),[]),ie=E.useRef(null),ce=E.useRef(null),le=E.useRef(null),ee=E.useRef(null),ue=E.useRef(null),Ae=E.useRef(null),xe=E.useRef(null),Te=E.useRef(null),Le=E.useRef(null),Ce=E.useRef(null),Ie=E.useRef(null),lt=E.useRef(null),Xt=E.useRef(new S.Vector3),Kt=E.useRef({x:0,y:0,z:0}),ve=E.useRef(!1),Q=nn[l],te=e??t,ne={side:Q,transparent:!0,opacity:s,wireframe:!1},Fe=r==="style2"?ae:y,he=r!=="none",Me=E.useMemo(()=>({color:{value:new S.Color(te)},opacity:{value:s}}),[]),k=E.useMemo(()=>({cameraTexture:{value:null},canonicalTexture:{value:null},alphaMask:{value:null},textureTint:{value:new S.Color(te)},opacity:{value:s},blendMode:{value:Je[h]},blendOpacity:{value:u},useCanonicalTexture:{value:he?1:0},useAlphaMask:{value:c==="canonical"?1:0},alphaOpacity:{value:i},compositeShading:{value:w?1:0},lightDirection:{value:new S.Vector3(.3,.65,.7).normalize()},ambientStrength:{value:.78},directionalStrength:{value:.38}}),[]);E.useEffect(()=>{Me.color.value.set(te),Me.opacity.value=s},[te,s,Me]),E.useEffect(()=>{k.cameraTexture.value=D??y,k.canonicalTexture.value=Fe,k.alphaMask.value=G,k.textureTint.value.set(te),k.opacity.value=s,k.blendMode.value=Je[h],k.blendOpacity.value=u,k.useCanonicalTexture.value=he?1:0,k.useAlphaMask.value=c==="canonical"?1:0,k.alphaOpacity.value=i,k.compositeShading.value=w?1:0},[c,G,i,h,u,D,w,k,y,he,te,s,Fe,r]);const be=O=>{if(O)return x==="canonical"?A.jsx("meshBasicMaterial",{color:g,alphaMap:G,transparent:!0,opacity:m,side:Q,depthWrite:!1,depthTest:!1,toneMapped:!1},"masked-canonical-material"):A.jsx("meshBasicMaterial",{color:g,transparent:!0,opacity:m,side:Q,depthWrite:!1,depthTest:!1,toneMapped:!1},"masked-solid-material");if(n==="wireframe")return A.jsx("meshBasicMaterial",{color:t,transparent:!0,opacity:s,side:Q,depthWrite:!1,depthTest:!1,wireframe:!0,toneMapped:!1},"wireframe-material");if(n==="shader"&&D&&(o==="originalFace"||o==="composite"&&r==="none"))return A.jsx("meshBasicMaterial",{map:D,alphaMap:G,transparent:!0,opacity:s,side:Q,depthWrite:!1,depthTest:!0,toneMapped:!1},"use-original-face-material");if(n==="shader"&&o==="composite"&&he&&D)return A.jsx("shaderMaterial",{uniforms:k,vertexShader:sn,fragmentShader:rn,transparent:!0,side:Q,depthWrite:!1,depthTest:!0,toneMapped:!1},"composite-material");const j=he?Fe:null,X=c==="canonical"&&i>0?G:null,K=`${n}-${r}-${c}-${i>0?"alpha-on":"alpha-off"}`;return n==="standard"?A.jsx("meshStandardMaterial",{...ne,color:t,map:j??void 0,alphaMap:X??void 0,depthWrite:!0,depthTest:!0,metalness:.05,roughness:.72},K):n==="physical"?A.jsx("meshPhysicalMaterial",{...ne,color:t,map:j??void 0,alphaMap:X??void 0,depthWrite:!0,depthTest:!0,roughness:.58,metalness:.08,clearcoat:.35,clearcoatRoughness:.4},K):n==="toon"?A.jsx("meshToonMaterial",{...ne,color:t,map:j??void 0,alphaMap:X??void 0,gradientMap:Z,depthWrite:!0,depthTest:!0},K):n==="normal"?A.jsx("meshNormalMaterial",{...ne,depthWrite:!0,depthTest:!0,flatShading:!1},"normal-material"):n==="matcap"?A.jsx("meshMatcapMaterial",{...ne,color:t,matcap:ge,depthWrite:!0,depthTest:!0},"matcap-material"):n==="shader"?A.jsx("shaderMaterial",{uniforms:Me,vertexShader:on,fragmentShader:an,transparent:!0,side:Q,depthWrite:!1,depthTest:!0,toneMapped:!1},"generic-shader-material"):A.jsx("meshBasicMaterial",{...ne,color:t,map:j??void 0,alphaMap:X??void 0,depthWrite:!1,depthTest:r!=="none"||c!=="none",toneMapped:!1},K)},Yt=O=>$e.projectLandmarkWithDepth(O,N,Xt.current);return re.useFrame(()=>{var ft,mt;const O=ie.current,j=ce.current,X=le.current,K=ee.current,Pe=ue.current,Ne=Ae.current,Oe=xe.current,De=Te.current,de=(mt=(ft=F==null?void 0:F.detectionResults)==null?void 0:ft.faceLandmarks)==null?void 0:mt[a];if(!L||!O||!j||!X||!K||!Pe||!Ne||!Oe||!De)return;if(!de||de.length<L.vertexCount){Pe.visible=!1,Ne.visible=!1,Oe.visible=!1,De.visible=!1;return}if(lt.current!==L){Le.current=new Float32Array(L.vertexCount*3),Ce.current=new Float32Array(L.uvs),Ie.current=new Float32Array(L.vertexCount*2);const Y=new S.BufferAttribute(Le.current,3),B=new S.BufferAttribute(Ce.current,2),se=new S.BufferAttribute(Ie.current,2);O.setAttribute("position",Y),O.setAttribute("uv",B),O.setAttribute("faceUv",se),O.setIndex(new S.BufferAttribute(L.baseIndices,1)),j.setAttribute("position",Y),j.setAttribute("uv",B),j.setAttribute("faceUv",se),j.setIndex(new S.BufferAttribute(L.mouthIndices,1)),X.setAttribute("position",Y),X.setAttribute("uv",B),X.setAttribute("faceUv",se),X.setIndex(new S.BufferAttribute(L.eyeIndices,1)),K.setAttribute("position",Y),K.setAttribute("uv",B),K.setAttribute("faceUv",se),K.setIndex(new S.BufferAttribute(L.noseIndices,1)),B.needsUpdate=!0,lt.current=L,ve.current=!1}const Re=Le.current,ke=Ie.current,Ee=Ce.current;if(!Re||!ke||!Ee)return;const ut=n==="shader"&&(o==="originalFace"||o==="composite"&&r==="none"),ht=qt(C),dt=ht?zt(de):null,Vt=Math.min(de.length,L.vertexCount);for(let Y=0;Y<Vt;Y++){const B=de[Y],se=ht&&dt?Zt(B,dt,C,Kt.current):B,Ue=Y*3,Se=Y*2,Be=Yt(se);Re[Ue]=Be.x,Re[Ue+1]=Be.y,Re[Ue+2]=Be.z,ke[Se]=B.x,ke[Se+1]=1-B.y,ut&&(Ee[Se]=B.x,Ee[Se+1]=1-B.y)}ut?(O.attributes.uv.needsUpdate=!0,ve.current=!0):ve.current&&(Ee.set(L.uvs),O.attributes.uv.needsUpdate=!0,ve.current=!1),Pe.visible=!0,Ne.visible=!0,Oe.visible=!0,De.visible=!0,O.attributes.position.needsUpdate=!0,O.attributes.faceUv.needsUpdate=!0,O.computeVertexNormals(),j.computeVertexNormals(),X.computeVertexNormals(),K.computeVertexNormals()}),A.jsxs(A.Fragment,{children:[A.jsxs("mesh",{ref:ue,renderOrder:_,frustumCulled:!1,children:[A.jsx("bufferGeometry",{ref:ie}),be(!1)]}),A.jsxs("mesh",{ref:Ae,renderOrder:_+2,frustumCulled:!1,children:[A.jsx("bufferGeometry",{ref:ce}),be(f)]}),A.jsxs("mesh",{ref:xe,renderOrder:_+2,frustumCulled:!1,children:[A.jsx("bufferGeometry",{ref:le}),be(p)]}),A.jsxs("mesh",{ref:Te,renderOrder:_+2,frustumCulled:!1,children:[A.jsx("bufferGeometry",{ref:ee}),be(T)]})]})},hn={materialType:"basic",shaderPreset:"basicShader",textureMap:"none",alphaMap:"none",alphaOpacity:1,side:"front",blendMode:"normal",blendOpacity:1,baseColor:"#38bdf8",opacity:.45,compositeShading:!1},dn={mouth:!0,eyes:!0,nose:!0},fn=[{label:"Wireframe",value:"wireframe"},{label:"Basic",value:"basic"},{label:"Standard",value:"standard"},{label:"Physical",value:"physical"},{label:"Toon",value:"toon"},{label:"Normal",value:"normal"},{label:"Matcap",value:"matcap"},{label:"Shader",value:"shader"}],mn=[{label:"Basic Shader",value:"basicShader"},{label:"Original Face",value:"originalFace"},{label:"Composite",value:"composite"}],pn=[{label:"Front",value:"front"},{label:"Back",value:"back"},{label:"Double",value:"double"}],gn=[{label:"None",value:"none"},{label:"UV Map 1",value:"canonical"},{label:"UV Map 2",value:"style2"}],An=[{label:"None",value:"none"},{label:"Default Mask",value:"canonical"}],xn=[{label:"Normal",value:"normal"},{label:"Add",value:"add"},{label:"Subtract",value:"subtract"},{label:"Multiply",value:"multiply"},{label:"Screen",value:"screen"},{label:"Overlay",value:"overlay"},{label:"Soft Light",value:"softLight"},{label:"Hard Light",value:"hardLight"},{label:"Lighten",value:"lighten"},{label:"Darken",value:"darken"},{label:"Difference",value:"difference"},{label:"Exclusion",value:"exclusion"}],Tn=(a,e)=>a==="basic"||a==="standard"||a==="physical"||a==="toon"||a==="shader"&&e==="composite",vn=(a,e)=>a==="shader"&&e==="composite",Mn=`
|
|
132
|
-
varying vec2 vUv;
|
|
133
|
-
|
|
134
|
-
void main() {
|
|
135
|
-
vUv = uv;
|
|
136
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
137
|
-
}
|
|
138
|
-
`,bn=`
|
|
139
|
-
uniform sampler2D cameraTexture;
|
|
140
|
-
uniform sampler2D retouchMaskTexture;
|
|
141
|
-
uniform sampler2D mouthMaskTexture;
|
|
142
|
-
uniform vec2 texelSize;
|
|
143
|
-
uniform float retouchAmount;
|
|
144
|
-
uniform float blurRadius;
|
|
145
|
-
uniform float detailPreservation;
|
|
146
|
-
uniform float blemishReduction;
|
|
147
|
-
uniform float rednessReduction;
|
|
148
|
-
uniform float blemishRadius;
|
|
149
|
-
uniform float teethWhitening;
|
|
150
|
-
uniform float previewMask;
|
|
151
|
-
uniform float protectLandmarks;
|
|
152
|
-
varying vec2 vUv;
|
|
153
|
-
|
|
154
|
-
vec3 sampleCamera(vec2 uv) {
|
|
155
|
-
return texture2D(cameraTexture, clamp(uv, vec2(0.0), vec2(1.0))).rgb;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
vec3 readRetouchMask(vec2 uv) {
|
|
159
|
-
vec4 mask = texture2D(retouchMaskTexture, uv);
|
|
160
|
-
float faceRegion = clamp(mask.b, 0.0, 1.0);
|
|
161
|
-
float softFaceRegion = min(mask.r, faceRegion);
|
|
162
|
-
float protectedRegion = min(mask.g, faceRegion) * protectLandmarks;
|
|
163
|
-
float hardProtectedRegion = step(0.08, protectedRegion);
|
|
164
|
-
float softRetouchRegion = softFaceRegion * (1.0 - protectedRegion);
|
|
165
|
-
float hardRetouchRegion = step(0.5, faceRegion) * (1.0 - hardProtectedRegion);
|
|
166
|
-
|
|
167
|
-
return vec3(
|
|
168
|
-
clamp(softRetouchRegion, 0.0, 1.0),
|
|
169
|
-
clamp(protectedRegion, 0.0, 1.0),
|
|
170
|
-
clamp(hardRetouchRegion, 0.0, 1.0)
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
float readMouthMask(vec2 uv) {
|
|
175
|
-
return clamp(texture2D(mouthMaskTexture, uv).r, 0.0, 1.0);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
float retouchCoverage(vec2 uv) {
|
|
179
|
-
return step(0.001, readRetouchMask(uv).x);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
void addMaskedBlurSample(inout vec3 color, inout float weightSum, vec2 centerUv, vec2 sampleUv, float weight) {
|
|
183
|
-
float coverage = retouchCoverage(sampleUv);
|
|
184
|
-
vec3 sampleColor = mix(sampleCamera(centerUv), sampleCamera(sampleUv), coverage);
|
|
185
|
-
color += sampleColor * weight;
|
|
186
|
-
weightSum += weight;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
vec3 maskedBlurCamera(vec2 uv, float radius) {
|
|
190
|
-
vec2 r = texelSize * radius;
|
|
191
|
-
vec3 color = sampleCamera(uv) * 0.2;
|
|
192
|
-
float weightSum = 0.2;
|
|
193
|
-
|
|
194
|
-
addMaskedBlurSample(color, weightSum, uv, uv + vec2(r.x, 0.0), 0.1);
|
|
195
|
-
addMaskedBlurSample(color, weightSum, uv, uv - vec2(r.x, 0.0), 0.1);
|
|
196
|
-
addMaskedBlurSample(color, weightSum, uv, uv + vec2(0.0, r.y), 0.1);
|
|
197
|
-
addMaskedBlurSample(color, weightSum, uv, uv - vec2(0.0, r.y), 0.1);
|
|
198
|
-
addMaskedBlurSample(color, weightSum, uv, uv + r, 0.075);
|
|
199
|
-
addMaskedBlurSample(color, weightSum, uv, uv - r, 0.075);
|
|
200
|
-
addMaskedBlurSample(color, weightSum, uv, uv + vec2(r.x, -r.y), 0.075);
|
|
201
|
-
addMaskedBlurSample(color, weightSum, uv, uv + vec2(-r.x, r.y), 0.075);
|
|
202
|
-
addMaskedBlurSample(color, weightSum, uv, uv + r * 2.0, 0.05);
|
|
203
|
-
addMaskedBlurSample(color, weightSum, uv, uv - r * 2.0, 0.05);
|
|
204
|
-
|
|
205
|
-
return color / max(weightSum, 0.001);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
float retouchLuminance(vec3 color) {
|
|
209
|
-
return dot(color, vec3(0.299, 0.587, 0.114));
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
void addMouthSample(inout vec3 color, inout float weightSum, vec2 uv, float weight) {
|
|
213
|
-
float mouth = readMouthMask(uv);
|
|
214
|
-
color += sampleCamera(uv) * mouth * weight;
|
|
215
|
-
weightSum += mouth * weight;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
vec3 mouthAverage(vec2 uv) {
|
|
219
|
-
vec2 r = texelSize * 7.0;
|
|
220
|
-
vec3 color = vec3(0.0);
|
|
221
|
-
float weightSum = 0.0;
|
|
222
|
-
|
|
223
|
-
addMouthSample(color, weightSum, uv, 0.22);
|
|
224
|
-
addMouthSample(color, weightSum, uv + vec2(r.x, 0.0), 0.12);
|
|
225
|
-
addMouthSample(color, weightSum, uv - vec2(r.x, 0.0), 0.12);
|
|
226
|
-
addMouthSample(color, weightSum, uv + vec2(0.0, r.y), 0.12);
|
|
227
|
-
addMouthSample(color, weightSum, uv - vec2(0.0, r.y), 0.12);
|
|
228
|
-
addMouthSample(color, weightSum, uv + r, 0.08);
|
|
229
|
-
addMouthSample(color, weightSum, uv - r, 0.08);
|
|
230
|
-
addMouthSample(color, weightSum, uv + vec2(r.x, -r.y), 0.08);
|
|
231
|
-
addMouthSample(color, weightSum, uv + vec2(-r.x, r.y), 0.08);
|
|
232
|
-
|
|
233
|
-
return weightSum > 0.01 ? color / weightSum : sampleCamera(uv);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
float teethCandidateMask(vec3 color, vec3 localMouth, float mouthRegion) {
|
|
237
|
-
float lum = retouchLuminance(color);
|
|
238
|
-
float localLum = retouchLuminance(localMouth);
|
|
239
|
-
float maxChannel = max(max(color.r, color.g), color.b);
|
|
240
|
-
float minChannel = min(min(color.r, color.g), color.b);
|
|
241
|
-
float saturation = maxChannel - minChannel;
|
|
242
|
-
float redness = max(color.r - max(color.g, color.b), 0.0);
|
|
243
|
-
float yellowness = max(min(color.r, color.g) - color.b, 0.0);
|
|
244
|
-
float pinkness = max(color.r - color.g * 0.92, 0.0) * max(color.r - color.b * 0.92, 0.0);
|
|
245
|
-
float relativeBrightness = lum - localLum;
|
|
246
|
-
float brightEnough = smoothstep(0.015, 0.18, relativeBrightness) * smoothstep(0.28, 0.58, lum);
|
|
247
|
-
float neutralEnough = 1.0 - smoothstep(0.16, 0.42, saturation);
|
|
248
|
-
float notRed = 1.0 - smoothstep(0.08, 0.28, redness + pinkness);
|
|
249
|
-
float notDark = smoothstep(0.18, 0.38, lum);
|
|
250
|
-
float plausibleWarmth = 1.0 - smoothstep(0.24, 0.5, yellowness);
|
|
251
|
-
|
|
252
|
-
return clamp(mouthRegion * brightEnough * max(neutralEnough, 0.35) * notRed * notDark * plausibleWarmth, 0.0, 1.0);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
float softTeethMask(vec2 uv, vec3 color, vec3 localMouth, float mouthRegion) {
|
|
256
|
-
vec2 r = texelSize * 2.0;
|
|
257
|
-
float mask = teethCandidateMask(color, localMouth, mouthRegion) * 0.42;
|
|
258
|
-
mask += teethCandidateMask(sampleCamera(uv + vec2(r.x, 0.0)), localMouth, readMouthMask(uv + vec2(r.x, 0.0))) * 0.14;
|
|
259
|
-
mask += teethCandidateMask(sampleCamera(uv - vec2(r.x, 0.0)), localMouth, readMouthMask(uv - vec2(r.x, 0.0))) * 0.14;
|
|
260
|
-
mask += teethCandidateMask(sampleCamera(uv + vec2(0.0, r.y)), localMouth, readMouthMask(uv + vec2(0.0, r.y))) * 0.14;
|
|
261
|
-
mask += teethCandidateMask(sampleCamera(uv - vec2(0.0, r.y)), localMouth, readMouthMask(uv - vec2(0.0, r.y))) * 0.14;
|
|
262
|
-
|
|
263
|
-
return smoothstep(0.18, 0.62, mask);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
vec3 whitenTeeth(vec2 uv, vec3 color, float amount, float mouthRegion) {
|
|
267
|
-
if (amount <= 0.001 || mouthRegion <= 0.001) return color;
|
|
268
|
-
|
|
269
|
-
vec3 localMouth = mouthAverage(uv);
|
|
270
|
-
float mask = softTeethMask(uv, color, localMouth, mouthRegion);
|
|
271
|
-
float lum = retouchLuminance(color);
|
|
272
|
-
float localLum = retouchLuminance(localMouth);
|
|
273
|
-
vec3 neutral = vec3(lum);
|
|
274
|
-
vec3 chromaCorrected = mix(color, neutral, 0.46);
|
|
275
|
-
chromaCorrected.r = min(chromaCorrected.r, color.r * 0.96 + lum * 0.04);
|
|
276
|
-
chromaCorrected.g = min(chromaCorrected.g * 1.02, 1.0);
|
|
277
|
-
chromaCorrected.b = min(max(chromaCorrected.b, color.b * 1.08), 1.0);
|
|
278
|
-
float lift = clamp((0.62 - lum) * 0.18 + max(lum - localLum, 0.0) * 0.08, 0.0, 0.12);
|
|
279
|
-
vec3 brightened = min(chromaCorrected + vec3(lift), vec3(1.0));
|
|
280
|
-
|
|
281
|
-
return mix(color, brightened, clamp(amount * mask, 0.0, 0.72));
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
vec3 reduceBlemishes(vec2 uv, vec3 original, vec3 localAverage, vec3 skinBase, float skinMask) {
|
|
285
|
-
float originalLum = retouchLuminance(original);
|
|
286
|
-
float localLum = retouchLuminance(localAverage);
|
|
287
|
-
float redness = max(original.r - max(original.g, original.b), 0.0);
|
|
288
|
-
float localRedness = max(localAverage.r - max(localAverage.g, localAverage.b), 0.0);
|
|
289
|
-
float excessRedness = max(redness - localRedness * 0.82, 0.0);
|
|
290
|
-
float darkSpot = max(localLum - originalLum, 0.0);
|
|
291
|
-
float contrast = length(original - localAverage);
|
|
292
|
-
float candidate =
|
|
293
|
-
smoothstep(0.025, 0.13, excessRedness * rednessReduction) +
|
|
294
|
-
smoothstep(0.035, 0.18, darkSpot) +
|
|
295
|
-
smoothstep(0.045, 0.22, contrast);
|
|
296
|
-
float blemishMask = clamp(candidate * 0.45, 0.0, 1.0) * skinMask * blemishReduction;
|
|
297
|
-
|
|
298
|
-
vec3 chromaReduced = vec3(
|
|
299
|
-
mix(original.r, min(original.r, localAverage.r * 1.04), rednessReduction * blemishMask),
|
|
300
|
-
mix(original.g, max(original.g, localAverage.g * 0.98), 0.25 * blemishMask),
|
|
301
|
-
mix(original.b, max(original.b, localAverage.b * 0.98), 0.25 * blemishMask)
|
|
302
|
-
);
|
|
303
|
-
vec3 texture = original - localAverage;
|
|
304
|
-
vec3 repaired = clamp(skinBase + texture * detailPreservation * 0.35, 0.0, 1.0);
|
|
305
|
-
|
|
306
|
-
return mix(chromaReduced, repaired, blemishMask);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
void main() {
|
|
310
|
-
vec3 original = sampleCamera(vUv);
|
|
311
|
-
vec3 masks = readRetouchMask(vUv);
|
|
312
|
-
float mouthMask = readMouthMask(vUv);
|
|
313
|
-
|
|
314
|
-
if (previewMask > 0.5) {
|
|
315
|
-
float sharpPreview = 1.0 - step(0.001, retouchAmount + blurRadius);
|
|
316
|
-
float retouchPreview = mix(masks.x, masks.z, sharpPreview);
|
|
317
|
-
float protectedPreview = mix(masks.y, step(0.08, masks.y), sharpPreview);
|
|
318
|
-
float whiteningPreview = softTeethMask(vUv, original, mouthAverage(vUv), mouthMask) * teethWhitening;
|
|
319
|
-
vec3 facePreview = vec3(retouchPreview, 0.08, 0.08);
|
|
320
|
-
vec3 featurePreview = vec3(0.05, protectedPreview, 0.1);
|
|
321
|
-
vec3 whiteningMaskPreview = vec3(whiteningPreview, whiteningPreview, 0.05);
|
|
322
|
-
vec3 maskPreview = max(max(facePreview, featurePreview), whiteningMaskPreview);
|
|
323
|
-
vec3 debugColor = mix(original * 0.18, maskPreview, max(max(retouchPreview, protectedPreview), whiteningPreview));
|
|
324
|
-
gl_FragColor = vec4(debugColor, 1.0);
|
|
325
|
-
#include <colorspace_fragment>
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
float effectiveBlurRadius = min(blurRadius, 7.0);
|
|
330
|
-
vec3 smallBlur = maskedBlurCamera(vUv, max(0.0, effectiveBlurRadius * 0.45));
|
|
331
|
-
vec3 largeBlur = maskedBlurCamera(vUv, max(0.0, effectiveBlurRadius));
|
|
332
|
-
vec3 detail = original - smallBlur;
|
|
333
|
-
float detailAmount = mix(detailPreservation, 0.9, masks.y);
|
|
334
|
-
vec3 smoothed = clamp(largeBlur + detail * detailAmount, 0.0, 1.0);
|
|
335
|
-
vec3 color = mix(original, smoothed, min(retouchAmount, 0.72) * masks.x);
|
|
336
|
-
vec3 blemishAverage = maskedBlurCamera(vUv, max(1.0, blemishRadius));
|
|
337
|
-
color = reduceBlemishes(vUv, color, blemishAverage, smoothed, masks.x);
|
|
338
|
-
color = whitenTeeth(vUv, color, teethWhitening, mouthMask);
|
|
339
|
-
gl_FragColor = vec4(color, 1.0);
|
|
340
|
-
#include <colorspace_fragment>
|
|
341
|
-
}
|
|
342
|
-
`,Rn=({retouchMask:a,mouthMask:e,retouchAmount:t,blurRadius:s,detailPreservation:n=.62,blemishReduction:o=.35,rednessReduction:r=.45,blemishRadius:c=3,teethWhitening:i,previewMask:l,protectLandmarks:h,renderOrder:u=-1e3})=>{const{camera:f,size:p}=re.useThree(),T=Qe.useXRCameraTexture(),x=E.useMemo(()=>({cameraTexture:{value:null},retouchMaskTexture:{value:a},mouthMaskTexture:{value:e},texelSize:{value:new S.Vector2(1/1280,1/720)},retouchAmount:{value:t},blurRadius:{value:s},detailPreservation:{value:n},blemishReduction:{value:o},rednessReduction:{value:r},blemishRadius:{value:c},teethWhitening:{value:i},previewMask:{value:0},protectLandmarks:{value:1}}),[e,a]),g=E.useMemo(()=>{if(!f.isPerspectiveCamera)return[10,10];const m=f,b=(m.position.z||5)- -1,w=S.MathUtils.degToRad(m.fov),C=2*Math.tan(w/2)*b;return[C*(p.width/p.height),C]},[f,p]);return E.useEffect(()=>{x.cameraTexture.value=T??null,x.retouchMaskTexture.value=a,x.mouthMaskTexture.value=e,x.texelSize.value.set(1/Math.max(p.width,1),1/Math.max(p.height,1)),x.retouchAmount.value=t,x.blurRadius.value=s,x.detailPreservation.value=n,x.blemishReduction.value=o,x.rednessReduction.value=r,x.blemishRadius.value=c,x.teethWhitening.value=i,x.previewMask.value=l?1:0,x.protectLandmarks.value=h?1:0},[s,c,o,T,n,l,h,t,r,e,a,i,p.height,p.width,x]),T?A.jsx("group",{position:[0,0,-1],children:A.jsxs("mesh",{renderOrder:u,children:[A.jsx("planeGeometry",{args:g}),A.jsx("shaderMaterial",{uniforms:x,vertexShader:Mn,fragmentShader:bn,depthTest:!1,depthWrite:!1,toneMapped:!1})]})}):null},_e=512,st=[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],yt=[33,246,161,160,159,158,157,173,133,155,154,153,145,144,163,7],_t=[362,398,384,385,386,387,388,466,263,249,390,373,374,380,381,382],Lt=[61,146,91,181,84,17,314,405,321,375,291,409,270,269,267,0,37,39,40,185],rt=[78,95,88,178,87,14,317,402,318,324,308,415,310,311,312,13,82,81,80,191],Ct=[70,63,105,66,107,55,65,52,53,46],It=[336,296,334,293,300,276,283,282,295,285],En=[yt,_t,Lt,rt,Ct,It],pt=(a,e,t)=>{ot(a,e,st,t)},gt=(a,e,t)=>{const s=J(e,10,t),n=J(e,103,t),o=J(e,332,t),r=J(e,105,t),c=J(e,334,t);if(!s||!n||!o||!r||!c)return;const i=(r.y+c.y)*.5,l=Math.abs(o.x-n.x),h=Math.max(Math.abs(i-s.y)*.72,l*.08),u=Math.max(0,s.y-h),f=h*.34;a.beginPath(),a.moveTo(n.x,n.y-f),a.quadraticCurveTo((n.x+s.x)*.5,u,s.x,u),a.quadraticCurveTo((o.x+s.x)*.5,u,o.x,o.y-f),a.lineTo(c.x,i),a.quadraticCurveTo(s.x,i+h*.16,r.x,i),a.closePath(),a.fill()},Sn=(a,e,t)=>{En.forEach(s=>ot(a,e,s,t))},J=(a,e,t)=>{const s=a[e];return s?{x:s.x*t,y:s.y*t}:null},ot=(a,e,t,s)=>{const n=J(e,t[0],s);if(n){a.beginPath(),a.moveTo(n.x,n.y);for(let o=1;o<t.length;o+=1){const r=J(e,t[o],s);r&&a.lineTo(r.x,r.y)}a.closePath(),a.fill()}},Ft=(a,e,t=_e,s={})=>{a.clearRect(0,0,t,t),e!=null&&e.length&&(a.save(),a.globalCompositeOperation="lighter",a.fillStyle="rgb(0, 0, 255)",pt(a,e,t),s.foreheadCoverage&>(a,e,t),a.restore(),a.save(),a.globalCompositeOperation="lighter",a.filter="blur(8px)",a.fillStyle="rgb(255, 0, 0)",pt(a,e,t),s.foreheadCoverage&>(a,e,t),a.restore(),a.save(),a.globalCompositeOperation="lighter",a.filter="blur(3px)",a.fillStyle="rgb(0, 255, 0)",Sn(a,e,t),a.restore())},Pt=(a,e,t=_e)=>{a.clearRect(0,0,t,t),e!=null&&e.length&&(a.save(),a.filter="blur(2px)",a.fillStyle="rgb(255, 255, 255)",ot(a,e,rt,t),a.restore())},wn=.1,yn=.48,_n=.012,Ln=1,Cn=1.1,In=1.15,Fn=.04,Pn=[61,146,91,181,84,17,314,405,321,375,291,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415],Nn=[33,7,163,144,145,153,154,155,133,173,157,158,159,160,161,246],On=[362,382,381,380,374,373,390,249,263,466,388,387,386,385,384,398],Dn=[70,63,105,66,107,55,65,52,53,46],kn=[336,296,334,293,300,285,295,282,283,276],Un=[1,2,4,5,6,19,94,97,98,99,102,129,168,195,197,240,279,326,327,328,331,344,358,440],Nt=[Pn,Nn,On,Dn,kn,Un],Ot=[61,91,84,17,314,321,291,78,178,14,402,308,80,13,312,0,33,144,145,153,155,133,157,159,161,246,362,382,374,373,263,466,388,386,384,398,70,105,107,55,52,46,336,334,300,285,282,276,1,4,5,94,97,98,327,326,2,195],we=a=>Math.min(Math.max(a,0),1),At=(a,e,t,s,n,o)=>{let r=1,c=1,i=0,l=0,h=0;if(e.forEach(M=>{const b=a[M];b&&(r=Math.min(r,b.x),c=Math.min(c,b.y),i=Math.max(i,b.x),l=Math.max(l,b.y),h+=1)}),h===0)return null;const u=i-r,f=l-c,p=Math.max(u*t,o),T=Math.max(f*t,o),x=we(r-p),g=we(c-T),m=we(i+p),v=we(l+T);return{centerX:(x+m)*.5,centerY:(g+v)*.5,radiusX:Math.max((m-x)*.5,o),radiusY:Math.max((v-g)*.5,o),strength:s,kind:n}},Bn=(a,e,t)=>a?{centerX:a.x,centerY:a.y,radiusX:e,radiusY:e,strength:t,kind:"feature"}:null,Dt=(a,e)=>{if(!(a!=null&&a.length))return[];const t=(e==null?void 0:e.faceOvalIndices)??st,s=(e==null?void 0:e.featureGroups)??Nt,n=(e==null?void 0:e.featurePointIndices)??Ot,o=(e==null?void 0:e.faceBoundsExpansion)??wn,r=(e==null?void 0:e.featureBoundsExpansion)??yn,c=(e==null?void 0:e.minRegionRadius)??_n,i=(e==null?void 0:e.faceRegionStrength)??Ln,l=(e==null?void 0:e.featureRegionStrength)??Cn,h=(e==null?void 0:e.featurePointRegionStrength)??In,u=(e==null?void 0:e.featurePointRadiusRatio)??Fn,f=[],p=At(a,t,o,i,"face",c);p&&f.push(p);const T=Math.max(Math.max((p==null?void 0:p.radiusX)??0,(p==null?void 0:p.radiusY)??0)*u,c*1.35);return s.forEach(x=>{const g=At(a,x,r,l,"feature",c);g&&f.push(g)}),n.forEach(x=>{const g=Bn(a[x],T,h);g&&f.push(g)}),f},xt=a=>{const e=document.createElement("canvas");e.width=a,e.height=a;const t=e.getContext("2d",{willReadFrequently:!1});if(!t)throw new Error("Unable to create face retouch mask context");const s=new S.CanvasTexture(e);return s.colorSpace=S.NoColorSpace,s.minFilter=S.LinearFilter,s.magFilter=S.LinearFilter,s.generateMipmaps=!1,s.needsUpdate=!0,{canvas:e,context:t,texture:s}},Hn=(a,e=_e,t={})=>{const{mask:s,mouthMask:n}=E.useMemo(()=>({mask:xt(e),mouthMask:xt(e)}),[e]);return E.useEffect(()=>{let o=0;const r=()=>{var i,l;o=requestAnimationFrame(r);const c=(l=(i=a==null?void 0:a.detectionResults)==null?void 0:i.faceLandmarks)==null?void 0:l[0];Ft(s.context,c,e,t),Pt(n.context,c,e),s.texture.needsUpdate=!0,n.texture.needsUpdate=!0};return r(),()=>{cancelAnimationFrame(o)}},[a,s.context,s.texture,n.context,n.texture,t,e]),{canvas:s.canvas,texture:s.texture,mouthTexture:n.texture}},Gn=a=>a.map(e=>[e.centerX.toFixed(4),e.centerY.toFixed(4),e.radiusX.toFixed(4),e.radiusY.toFixed(4),e.strength.toFixed(2),e.kind].join(",")).join("|"),jn=(a,e)=>{const[t,s]=E.useState([]);return E.useEffect(()=>{let n=0,o="";const r=()=>{var h,u;n=requestAnimationFrame(r);const c=(u=(h=a==null?void 0:a.detectionResults)==null?void 0:h.faceLandmarks)==null?void 0:u[0],i=Dt(c,e),l=Gn(i);l!==o&&(o=l,s(i))};return r(),()=>{cancelAnimationFrame(n)}},[a]),t};function Tt(a,e){if(e===d.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),a;if(e===d.TriangleFanDrawMode||e===d.TriangleStripDrawMode){let t=a.getIndex();if(t===null){const r=[],c=a.getAttribute("position");if(c!==void 0){for(let i=0;i<c.count;i++)r.push(i);a.setIndex(r),t=a.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),a}const s=t.count-2,n=[];if(e===d.TriangleFanDrawMode)for(let r=1;r<=s;r++)n.push(t.getX(0)),n.push(t.getX(r)),n.push(t.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(n.push(t.getX(r)),n.push(t.getX(r+1)),n.push(t.getX(r+2))):(n.push(t.getX(r+2)),n.push(t.getX(r+1)),n.push(t.getX(r)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=a.clone();return o.setIndex(n),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),a}class Xn extends d.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new zn(t)}),this.register(function(t){return new qn(t)}),this.register(function(t){return new rs(t)}),this.register(function(t){return new os(t)}),this.register(function(t){return new as(t)}),this.register(function(t){return new Qn(t)}),this.register(function(t){return new $n(t)}),this.register(function(t){return new Jn(t)}),this.register(function(t){return new es(t)}),this.register(function(t){return new Wn(t)}),this.register(function(t){return new ts(t)}),this.register(function(t){return new Zn(t)}),this.register(function(t){return new ss(t)}),this.register(function(t){return new ns(t)}),this.register(function(t){return new Yn(t)}),this.register(function(t){return new is(t)}),this.register(function(t){return new cs(t)})}load(e,t,s,n){const o=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const l=d.LoaderUtils.extractUrlBase(e);r=d.LoaderUtils.resolveURL(l,this.path)}else r=d.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const c=function(l){n?n(l):console.error(l),o.manager.itemError(e),o.manager.itemEnd(e)},i=new d.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(l){try{o.parse(l,r,function(h){t(h),o.manager.itemEnd(e)},c)}catch(h){c(h)}},s,c)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let o;const r={},c={},i=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(i.decode(new Uint8Array(e,0,4))===kt){try{r[R.KHR_BINARY_GLTF]=new ls(e)}catch(u){n&&n(u);return}o=JSON.parse(r[R.KHR_BINARY_GLTF].content)}else o=JSON.parse(i.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new bs(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[u.name]=u,r[u.name]=!0}if(o.extensionsUsed)for(let h=0;h<o.extensionsUsed.length;++h){const u=o.extensionsUsed[h],f=o.extensionsRequired||[];switch(u){case R.KHR_MATERIALS_UNLIT:r[u]=new Vn;break;case R.KHR_DRACO_MESH_COMPRESSION:r[u]=new us(o,this.dracoLoader);break;case R.KHR_TEXTURE_TRANSFORM:r[u]=new hs;break;case R.KHR_MESH_QUANTIZATION:r[u]=new ds;break;default:f.indexOf(u)>=0&&c[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(r),l.setPlugins(c),l.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,o){s.parse(e,t,n,o)})}}function Kn(){let a={};return{get:function(e){return a[e]},add:function(e,t){a[e]=t},remove:function(e){delete a[e]},removeAll:function(){a={}}}}const R={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Yn{constructor(e){this.parser=e,this.name=R.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const o=t[s];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const o=t.json,i=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let l;const h=new d.Color(16777215);i.color!==void 0&&h.setRGB(i.color[0],i.color[1],i.color[2],d.LinearSRGBColorSpace);const u=i.range!==void 0?i.range:0;switch(i.type){case"directional":l=new d.DirectionalLight(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new d.PointLight(h),l.distance=u;break;case"spot":l=new d.SpotLight(h),l.distance=u,i.spot=i.spot||{},i.spot.innerConeAngle=i.spot.innerConeAngle!==void 0?i.spot.innerConeAngle:0,i.spot.outerConeAngle=i.spot.outerConeAngle!==void 0?i.spot.outerConeAngle:Math.PI/4,l.angle=i.spot.outerConeAngle,l.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return l.position.set(0,0,0),V(l,i),i.intensity!==void 0&&(l.intensity=i.intensity),l.name=t.createUniqueName(i.name||"light_"+e),n=Promise.resolve(l),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,o=s.json.nodes[e],c=(o.extensions&&o.extensions[this.name]||{}).light;return c===void 0?null:this._loadLight(c).then(function(i){return s._getNodeRef(t.cache,c,i)})}}class Vn{constructor(){this.name=R.KHR_MATERIALS_UNLIT}getMaterialType(){return d.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new d.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const r=o.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],d.LinearSRGBColorSpace),e.opacity=r[3]}o.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",o.baseColorTexture,d.SRGBColorSpace))}return Promise.all(n)}}class Wn{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=n.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class zn{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],r=n.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&o.push(s.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&o.push(s.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(o.push(s.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const c=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new d.Vector2(c,c)}return Promise.all(o)}}class qn{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=n.extensions[this.name];return t.dispersion=o.dispersion!==void 0?o.dispersion:0,Promise.resolve()}}class Zn{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],r=n.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&o.push(s.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&o.push(s.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(o)}}class Qn{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new d.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=n.extensions[this.name];if(r.sheenColorFactor!==void 0){const c=r.sheenColorFactor;t.sheenColor.setRGB(c[0],c[1],c[2],d.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&o.push(s.assignTexture(t,"sheenColorMap",r.sheenColorTexture,d.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&o.push(s.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(o)}}class $n{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],r=n.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&o.push(s.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(o)}}class Jn{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],r=n.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&o.push(s.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const c=r.attenuationColor||[1,1,1];return t.attenuationColor=new d.Color().setRGB(c[0],c[1],c[2],d.LinearSRGBColorSpace),Promise.all(o)}}class es{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=n.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class ts{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],r=n.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&o.push(s.assignTexture(t,"specularIntensityMap",r.specularTexture));const c=r.specularColorFactor||[1,1,1];return t.specularColor=new d.Color().setRGB(c[0],c[1],c[2],d.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&o.push(s.assignTexture(t,"specularColorMap",r.specularColorTexture,d.SRGBColorSpace)),Promise.all(o)}}class ns{constructor(e){this.parser=e,this.name=R.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],r=n.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&o.push(s.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(o)}}class ss{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],r=n.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&o.push(s.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(o)}}class rs{constructor(e){this.parser=e,this.name=R.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const o=n.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,r)}}class os{constructor(e){this.parser=e,this.name=R.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,o=n.textures[e];if(!o.extensions||!o.extensions[t])return null;const r=o.extensions[t],c=n.images[r.source];let i=s.textureLoader;if(c.uri){const l=s.options.manager.getHandler(c.uri);l!==null&&(i=l)}return this.detectSupport().then(function(l){if(l)return s.loadTextureImage(e,r.source,i);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class as{constructor(e){this.parser=e,this.name=R.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,o=n.textures[e];if(!o.extensions||!o.extensions[t])return null;const r=o.extensions[t],c=n.images[r.source];let i=s.textureLoader;if(c.uri){const l=s.options.manager.getHandler(c.uri);l!==null&&(i=l)}return this.detectSupport().then(function(l){if(l)return s.loadTextureImage(e,r.source,i);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class is{constructor(e){this.name=R.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],o=this.parser.getDependency("buffer",n.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(c){const i=n.byteOffset||0,l=n.byteLength||0,h=n.count,u=n.byteStride,f=new Uint8Array(c,i,l);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(h,u,f,n.mode,n.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(h*u);return r.decodeGltfBuffer(new Uint8Array(p),h,u,f,n.mode,n.filter),p})})}else return null}}class cs{constructor(e){this.name=R.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const l of n.primitives)if(l.mode!==H.TRIANGLES&&l.mode!==H.TRIANGLE_STRIP&&l.mode!==H.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=s.extensions[this.name].attributes,c=[],i={};for(const l in r)c.push(this.parser.getDependency("accessor",r[l]).then(h=>(i[l]=h,i[l])));return c.length<1?null:(c.push(this.parser.createNodeMesh(e)),Promise.all(c).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],f=l[0].count,p=[];for(const T of u){const x=new d.Matrix4,g=new d.Vector3,m=new d.Quaternion,v=new d.Vector3(1,1,1),M=new d.InstancedMesh(T.geometry,T.material,f);for(let b=0;b<f;b++)i.TRANSLATION&&g.fromBufferAttribute(i.TRANSLATION,b),i.ROTATION&&m.fromBufferAttribute(i.ROTATION,b),i.SCALE&&v.fromBufferAttribute(i.SCALE,b),M.setMatrixAt(b,x.compose(g,m,v));for(const b in i)if(b==="_COLOR_0"){const w=i[b];M.instanceColor=new d.InstancedBufferAttribute(w.array,w.itemSize,w.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&T.geometry.setAttribute(b,i[b]);d.Object3D.prototype.copy.call(M,T),this.parser.assignFinalMaterial(M),p.push(M)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}}const kt="glTF",fe=12,vt={JSON:1313821514,BIN:5130562};class ls{constructor(e){this.name=R.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,fe),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==kt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-fe,o=new DataView(e,fe);let r=0;for(;r<n;){const c=o.getUint32(r,!0);r+=4;const i=o.getUint32(r,!0);if(r+=4,i===vt.JSON){const l=new Uint8Array(e,fe+r,c);this.content=s.decode(l)}else if(i===vt.BIN){const l=fe+r;this.body=e.slice(l,l+c)}r+=c}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class us{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=R.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,o=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,c={},i={},l={};for(const h in r){const u=et[h]||h.toLowerCase();c[u]=r[h]}for(const h in e.attributes){const u=et[h]||h.toLowerCase();if(r[h]!==void 0){const f=s.accessors[e.attributes[h]],p=oe[f.componentType];l[u]=p.name,i[u]=f.normalized===!0}}return t.getDependency("bufferView",o).then(function(h){return new Promise(function(u,f){n.decodeDracoFile(h,function(p){for(const T in p.attributes){const x=p.attributes[T],g=i[T];g!==void 0&&(x.normalized=g)}u(p)},c,l,d.LinearSRGBColorSpace,f)})})}}class hs{constructor(){this.name=R.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class ds{constructor(){this.name=R.KHR_MESH_QUANTIZATION}}class Ut extends d.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=e*n*3+n;for(let r=0;r!==n;r++)t[r]=s[o+r];return t}interpolate_(e,t,s,n){const o=this.resultBuffer,r=this.sampleValues,c=this.valueSize,i=c*2,l=c*3,h=n-t,u=(s-t)/h,f=u*u,p=f*u,T=e*l,x=T-l,g=-2*p+3*f,m=p-f,v=1-g,M=m-f+u;for(let b=0;b!==c;b++){const w=r[x+b+c],C=r[x+b+i]*h,_=r[T+b+c],P=r[T+b]*h;o[b]=v*w+M*C+g*_+m*P}return o}}const fs=new d.Quaternion;class ms extends Ut{interpolate_(e,t,s,n){const o=super.interpolate_(e,t,s,n);return fs.fromArray(o).normalize().toArray(o),o}}const H={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},oe={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Mt={9728:d.NearestFilter,9729:d.LinearFilter,9984:d.NearestMipmapNearestFilter,9985:d.LinearMipmapNearestFilter,9986:d.NearestMipmapLinearFilter,9987:d.LinearMipmapLinearFilter},bt={33071:d.ClampToEdgeWrapping,33648:d.MirroredRepeatWrapping,10497:d.RepeatWrapping},Ve={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},et={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},z={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ps={CUBICSPLINE:void 0,LINEAR:d.InterpolateLinear,STEP:d.InterpolateDiscrete},We={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function gs(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new d.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:d.FrontSide})),a.DefaultMaterial}function $(a,e,t){for(const s in t.extensions)a[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function V(a,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(a.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function As(a,e,t){let s=!1,n=!1,o=!1;for(let l=0,h=e.length;l<h;l++){const u=e[l];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(o=!0),s&&n&&o)break}if(!s&&!n&&!o)return Promise.resolve(a);const r=[],c=[],i=[];for(let l=0,h=e.length;l<h;l++){const u=e[l];if(s){const f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):a.attributes.position;r.push(f)}if(n){const f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):a.attributes.normal;c.push(f)}if(o){const f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):a.attributes.color;i.push(f)}}return Promise.all([Promise.all(r),Promise.all(c),Promise.all(i)]).then(function(l){const h=l[0],u=l[1],f=l[2];return s&&(a.morphAttributes.position=h),n&&(a.morphAttributes.normal=u),o&&(a.morphAttributes.color=f),a.morphTargetsRelative=!0,a})}function xs(a,e){if(a.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)a.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(a.morphTargetInfluences.length===t.length){a.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)a.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Ts(a){let e;const t=a.extensions&&a.extensions[R.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+ze(t.attributes):e=a.indices+":"+ze(a.attributes)+":"+a.mode,a.targets!==void 0)for(let s=0,n=a.targets.length;s<n;s++)e+=":"+ze(a.targets[s]);return e}function ze(a){let e="";const t=Object.keys(a).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+a[t[s]]+";";return e}function tt(a){switch(a){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function vs(a){return a.search(/\.jpe?g($|\?)/i)>0||a.search(/^data\:image\/jpeg/)===0?"image/jpeg":a.search(/\.webp($|\?)/i)>0||a.search(/^data\:image\/webp/)===0?"image/webp":a.search(/\.ktx2($|\?)/i)>0||a.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Ms=new d.Matrix4;class bs{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Kn,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,o=!1,r=-1;if(typeof navigator<"u"){const c=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(c)===!0;const i=c.match(/Version\/(\d+)/);n=s&&i?parseInt(i[1],10):-1,o=c.indexOf("Firefox")>-1,r=o?c.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||o&&r<98?this.textureLoader=new d.TextureLoader(this.options.manager):this.textureLoader=new d.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new d.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const c={scene:r[0][n.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:n.asset,parser:s,userData:{}};return $(o,c,n),V(c,n),Promise.all(s._invokeAll(function(i){return i.afterRoot&&i.afterRoot(c)})).then(function(){for(const i of c.scenes)i.updateMatrixWorld();e(c)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,o=t.length;n<o;n++){const r=t[n].joints;for(let c=0,i=r.length;c<i;c++)e[r[c]].isBone=!0}for(let n=0,o=e.length;n<o;n++){const r=e[n];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),o=(r,c)=>{const i=this.associations.get(r);i!=null&&this.associations.set(c,i);for(const[l,h]of r.children.entries())o(h,c.children[l])};return o(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const o=e(t[n]);o&&s.push(o)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":n=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(o,r){return s.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[R.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(o,r){s.load(d.LoaderUtils.resolveURL(t.uri,n.path),o,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const n=t.byteLength||0,o=t.byteOffset||0;return s.slice(o,o+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const r=Ve[n.type],c=oe[n.componentType],i=n.normalized===!0,l=new c(n.count*r);return Promise.resolve(new d.BufferAttribute(l,r,i))}const o=[];return n.bufferView!==void 0?o.push(this.getDependency("bufferView",n.bufferView)):o.push(null),n.sparse!==void 0&&(o.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(o).then(function(r){const c=r[0],i=Ve[n.type],l=oe[n.componentType],h=l.BYTES_PER_ELEMENT,u=h*i,f=n.byteOffset||0,p=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,T=n.normalized===!0;let x,g;if(p&&p!==u){const m=Math.floor(f/p),v="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+m+":"+n.count;let M=t.cache.get(v);M||(x=new l(c,m*p,n.count*p/h),M=new d.InterleavedBuffer(x,p/h),t.cache.add(v,M)),g=new d.InterleavedBufferAttribute(M,i,f%p/h,T)}else c===null?x=new l(n.count*i):x=new l(c,f,n.count*i),g=new d.BufferAttribute(x,i,T);if(n.sparse!==void 0){const m=Ve.SCALAR,v=oe[n.sparse.indices.componentType],M=n.sparse.indices.byteOffset||0,b=n.sparse.values.byteOffset||0,w=new v(r[1],M,n.sparse.count*m),C=new l(r[2],b,n.sparse.count*i);c!==null&&(g=new d.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let _=0,P=w.length;_<P;_++){const I=w[_];if(g.setX(I,C[_*i]),i>=2&&g.setY(I,C[_*i+1]),i>=3&&g.setZ(I,C[_*i+2]),i>=4&&g.setW(I,C[_*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=T}return g})}loadTexture(e){const t=this.json,s=this.options,o=t.textures[e].source,r=t.images[o];let c=this.textureLoader;if(r.uri){const i=s.manager.getHandler(r.uri);i!==null&&(c=i)}return this.loadTextureImage(e,o,c)}loadTextureImage(e,t,s){const n=this,o=this.json,r=o.textures[e],c=o.images[t],i=(c.uri||c.bufferView)+":"+r.sampler;if(this.textureCache[i])return this.textureCache[i];const l=this.loadImageSource(t,s).then(function(h){h.flipY=!1,h.name=r.name||c.name||"",h.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(h.name=c.uri);const f=(o.samplers||{})[r.sampler]||{};return h.magFilter=Mt[f.magFilter]||d.LinearFilter,h.minFilter=Mt[f.minFilter]||d.LinearMipmapLinearFilter,h.wrapS=bt[f.wrapS]||d.RepeatWrapping,h.wrapT=bt[f.wrapT]||d.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==d.NearestFilter&&h.minFilter!==d.LinearFilter,n.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[i]=l,l}loadImageSource(e,t){const s=this,n=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const r=n.images[e],c=self.URL||self.webkitURL;let i=r.uri||"",l=!1;if(r.bufferView!==void 0)i=s.getDependency("bufferView",r.bufferView).then(function(u){l=!0;const f=new Blob([u],{type:r.mimeType});return i=c.createObjectURL(f),i});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(i).then(function(u){return new Promise(function(f,p){let T=f;t.isImageBitmapLoader===!0&&(T=function(x){const g=new d.Texture(x);g.needsUpdate=!0,f(g)}),t.load(d.LoaderUtils.resolveURL(u,o.path),T,void 0,p)})}).then(function(u){return l===!0&&c.revokeObjectURL(i),V(u,r),u.userData.mimeType=r.mimeType||vs(r.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",i),u});return this.sourceCache[e]=h,h}assignTexture(e,t,s,n){const o=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),o.extensions[R.KHR_TEXTURE_TRANSFORM]){const c=s.extensions!==void 0?s.extensions[R.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const i=o.associations.get(r);r=o.extensions[R.KHR_TEXTURE_TRANSFORM].extendTexture(r,c),o.associations.set(r,i)}}return n!==void 0&&(r.colorSpace=n),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const c="PointsMaterial:"+s.uuid;let i=this.cache.get(c);i||(i=new d.PointsMaterial,d.Material.prototype.copy.call(i,s),i.color.copy(s.color),i.map=s.map,i.sizeAttenuation=!1,this.cache.add(c,i)),s=i}else if(e.isLine){const c="LineBasicMaterial:"+s.uuid;let i=this.cache.get(c);i||(i=new d.LineBasicMaterial,d.Material.prototype.copy.call(i,s),i.color.copy(s.color),i.map=s.map,this.cache.add(c,i)),s=i}if(n||o||r){let c="ClonedMaterial:"+s.uuid+":";n&&(c+="derivative-tangents:"),o&&(c+="vertex-colors:"),r&&(c+="flat-shading:");let i=this.cache.get(c);i||(i=s.clone(),o&&(i.vertexColors=!0),r&&(i.flatShading=!0),n&&(i.normalScale&&(i.normalScale.y*=-1),i.clearcoatNormalScale&&(i.clearcoatNormalScale.y*=-1)),this.cache.add(c,i),this.associations.set(i,this.associations.get(s))),s=i}e.material=s}getMaterialType(){return d.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,o=s.materials[e];let r;const c={},i=o.extensions||{},l=[];if(i[R.KHR_MATERIALS_UNLIT]){const u=n[R.KHR_MATERIALS_UNLIT];r=u.getMaterialType(),l.push(u.extendParams(c,o,t))}else{const u=o.pbrMetallicRoughness||{};if(c.color=new d.Color(1,1,1),c.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;c.color.setRGB(f[0],f[1],f[2],d.LinearSRGBColorSpace),c.opacity=f[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(c,"map",u.baseColorTexture,d.SRGBColorSpace)),c.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,c.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(c,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(c,"roughnessMap",u.metallicRoughnessTexture))),r=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,c)})))}o.doubleSided===!0&&(c.side=d.DoubleSide);const h=o.alphaMode||We.OPAQUE;if(h===We.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,h===We.MASK&&(c.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&r!==d.MeshBasicMaterial&&(l.push(t.assignTexture(c,"normalMap",o.normalTexture)),c.normalScale=new d.Vector2(1,1),o.normalTexture.scale!==void 0)){const u=o.normalTexture.scale;c.normalScale.set(u,u)}if(o.occlusionTexture!==void 0&&r!==d.MeshBasicMaterial&&(l.push(t.assignTexture(c,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&r!==d.MeshBasicMaterial){const u=o.emissiveFactor;c.emissive=new d.Color().setRGB(u[0],u[1],u[2],d.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&r!==d.MeshBasicMaterial&&l.push(t.assignTexture(c,"emissiveMap",o.emissiveTexture,d.SRGBColorSpace)),Promise.all(l).then(function(){const u=new r(c);return o.name&&(u.name=o.name),V(u,o),t.associations.set(u,{materials:e}),o.extensions&&$(n,u,o),u})}createUniqueName(e){const t=d.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function o(c){return s[R.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,t).then(function(i){return Rt(i,c,t)})}const r=[];for(let c=0,i=e.length;c<i;c++){const l=e[c],h=Ts(l),u=n[h];if(u)r.push(u.promise);else{let f;l.extensions&&l.extensions[R.KHR_DRACO_MESH_COMPRESSION]?f=o(l):f=Rt(new d.BufferGeometry,l,t),n[h]={primitive:l,promise:f},r.push(f)}}return Promise.all(r)}loadMesh(e){const t=this,s=this.json,n=this.extensions,o=s.meshes[e],r=o.primitives,c=[];for(let i=0,l=r.length;i<l;i++){const h=r[i].material===void 0?gs(this.cache):this.getDependency("material",r[i].material);c.push(h)}return c.push(t.loadGeometries(r)),Promise.all(c).then(function(i){const l=i.slice(0,i.length-1),h=i[i.length-1],u=[];for(let p=0,T=h.length;p<T;p++){const x=h[p],g=r[p];let m;const v=l[p];if(g.mode===H.TRIANGLES||g.mode===H.TRIANGLE_STRIP||g.mode===H.TRIANGLE_FAN||g.mode===void 0)m=o.isSkinnedMesh===!0?new d.SkinnedMesh(x,v):new d.Mesh(x,v),m.isSkinnedMesh===!0&&m.normalizeSkinWeights(),g.mode===H.TRIANGLE_STRIP?m.geometry=Tt(m.geometry,d.TriangleStripDrawMode):g.mode===H.TRIANGLE_FAN&&(m.geometry=Tt(m.geometry,d.TriangleFanDrawMode));else if(g.mode===H.LINES)m=new d.LineSegments(x,v);else if(g.mode===H.LINE_STRIP)m=new d.Line(x,v);else if(g.mode===H.LINE_LOOP)m=new d.LineLoop(x,v);else if(g.mode===H.POINTS)m=new d.Points(x,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(m.geometry.morphAttributes).length>0&&xs(m,o),m.name=t.createUniqueName(o.name||"mesh_"+e),V(m,o),g.extensions&&$(n,m,g),t.assignFinalMaterial(m),u.push(m)}for(let p=0,T=u.length;p<T;p++)t.associations.set(u[p],{meshes:e,primitives:p});if(u.length===1)return o.extensions&&$(n,u[0],o),u[0];const f=new d.Group;o.extensions&&$(n,f,o),t.associations.set(f,{meshes:e});for(let p=0,T=u.length;p<T;p++)f.add(u[p]);return f})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new d.PerspectiveCamera(d.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new d.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),V(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,o=t.joints.length;n<o;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const o=n.pop(),r=n,c=[],i=[];for(let l=0,h=r.length;l<h;l++){const u=r[l];if(u){c.push(u);const f=new d.Matrix4;o!==null&&f.fromArray(o.array,l*16),i.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new d.Skeleton(c,i)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],o=n.name?n.name:"animation_"+e,r=[],c=[],i=[],l=[],h=[];for(let u=0,f=n.channels.length;u<f;u++){const p=n.channels[u],T=n.samplers[p.sampler],x=p.target,g=x.node,m=n.parameters!==void 0?n.parameters[T.input]:T.input,v=n.parameters!==void 0?n.parameters[T.output]:T.output;x.node!==void 0&&(r.push(this.getDependency("node",g)),c.push(this.getDependency("accessor",m)),i.push(this.getDependency("accessor",v)),l.push(T),h.push(x))}return Promise.all([Promise.all(r),Promise.all(c),Promise.all(i),Promise.all(l),Promise.all(h)]).then(function(u){const f=u[0],p=u[1],T=u[2],x=u[3],g=u[4],m=[];for(let v=0,M=f.length;v<M;v++){const b=f[v],w=p[v],C=T[v],_=x[v],P=g[v];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const I=s._createAnimationTracks(b,w,C,_,P);if(I)for(let F=0;F<I.length;F++)m.push(I[F])}return new d.AnimationClip(o,void 0,m)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(o){const r=s._getNodeRef(s.meshCache,n.mesh,o);return n.weights!==void 0&&r.traverse(function(c){if(c.isMesh)for(let i=0,l=n.weights.length;i<l;i++)c.morphTargetInfluences[i]=n.weights[i]}),r})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],o=s._loadNodeShallow(e),r=[],c=n.children||[];for(let l=0,h=c.length;l<h;l++)r.push(s.getDependency("node",c[l]));const i=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([o,Promise.all(r),i]).then(function(l){const h=l[0],u=l[1],f=l[2];f!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(f,Ms)});for(let p=0,T=u.length;p<T;p++)h.add(u[p]);return h})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],r=o.name?n.createUniqueName(o.name):"",c=[],i=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return i&&c.push(i),o.camera!==void 0&&c.push(n.getDependency("camera",o.camera).then(function(l){return n._getNodeRef(n.cameraCache,o.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){c.push(l)}),this.nodeCache[e]=Promise.all(c).then(function(l){let h;if(o.isBone===!0?h=new d.Bone:l.length>1?h=new d.Group:l.length===1?h=l[0]:h=new d.Object3D,h!==l[0])for(let u=0,f=l.length;u<f;u++)h.add(l[u]);if(o.name&&(h.userData.name=o.name,h.name=r),V(h,o),o.extensions&&$(s,h,o),o.matrix!==void 0){const u=new d.Matrix4;u.fromArray(o.matrix),h.applyMatrix4(u)}else o.translation!==void 0&&h.position.fromArray(o.translation),o.rotation!==void 0&&h.quaternion.fromArray(o.rotation),o.scale!==void 0&&h.scale.fromArray(o.scale);return n.associations.has(h)||n.associations.set(h,{}),n.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,o=new d.Group;s.name&&(o.name=n.createUniqueName(s.name)),V(o,s),s.extensions&&$(t,o,s);const r=s.nodes||[],c=[];for(let i=0,l=r.length;i<l;i++)c.push(n.getDependency("node",r[i]));return Promise.all(c).then(function(i){for(let h=0,u=i.length;h<u;h++)o.add(i[h]);const l=h=>{const u=new Map;for(const[f,p]of n.associations)(f instanceof d.Material||f instanceof d.Texture)&&u.set(f,p);return h.traverse(f=>{const p=n.associations.get(f);p!=null&&u.set(f,p)}),u};return n.associations=l(o),o})}_createAnimationTracks(e,t,s,n,o){const r=[],c=e.name?e.name:e.uuid,i=[];z[o.path]===z.weights?e.traverse(function(f){f.morphTargetInfluences&&i.push(f.name?f.name:f.uuid)}):i.push(c);let l;switch(z[o.path]){case z.weights:l=d.NumberKeyframeTrack;break;case z.rotation:l=d.QuaternionKeyframeTrack;break;case z.position:case z.scale:l=d.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:l=d.NumberKeyframeTrack;break;case 2:case 3:default:l=d.VectorKeyframeTrack;break}break}const h=n.interpolation!==void 0?ps[n.interpolation]:d.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let f=0,p=i.length;f<p;f++){const T=new l(i[f]+"."+z[o.path],t.array,u,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),r.push(T)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=tt(t.constructor),n=new Float32Array(t.length);for(let o=0,r=t.length;o<r;o++)n[o]=t[o]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof d.QuaternionKeyframeTrack?ms:Ut;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Rs(a,e,t){const s=e.attributes,n=new d.Box3;if(s.POSITION!==void 0){const c=t.json.accessors[s.POSITION],i=c.min,l=c.max;if(i!==void 0&&l!==void 0){if(n.set(new d.Vector3(i[0],i[1],i[2]),new d.Vector3(l[0],l[1],l[2])),c.normalized){const h=tt(oe[c.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const c=new d.Vector3,i=new d.Vector3;for(let l=0,h=o.length;l<h;l++){const u=o[l];if(u.POSITION!==void 0){const f=t.json.accessors[u.POSITION],p=f.min,T=f.max;if(p!==void 0&&T!==void 0){if(i.setX(Math.max(Math.abs(p[0]),Math.abs(T[0]))),i.setY(Math.max(Math.abs(p[1]),Math.abs(T[1]))),i.setZ(Math.max(Math.abs(p[2]),Math.abs(T[2]))),f.normalized){const x=tt(oe[f.componentType]);i.multiplyScalar(x)}c.max(i)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(c)}a.boundingBox=n;const r=new d.Sphere;n.getCenter(r.center),r.radius=n.min.distanceTo(n.max)/2,a.boundingSphere=r}function Rt(a,e,t){const s=e.attributes,n=[];function o(r,c){return t.getDependency("accessor",r).then(function(i){a.setAttribute(c,i)})}for(const r in s){const c=et[r]||r.toLowerCase();c in a.attributes||n.push(o(s[r],c))}if(e.indices!==void 0&&!a.index){const r=t.getDependency("accessor",e.indices).then(function(c){a.setIndex(c)});n.push(r)}return d.ColorManagement.workingColorSpace!==d.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${d.ColorManagement.workingColorSpace}" not supported.`),V(a,e),Rs(a,e,t),Promise.all(n).then(function(){return e.targets!==void 0?As(a,e.targets,t):a})}const pe=[0,0,-10],q=[.5,.5,.5],at=1,qe=new Map,Es=a=>{const e=qe.get(a);if(e)return e;const t=new Xn,s=nt.fetchAndVerify(a).then(n=>new Promise((o,r)=>{t.parse(n,"",o,r)})).catch(n=>{throw qe.delete(a),n});return qe.set(a,s),s},it=({position:a,rotation:e,scale:t,url:s,showDebugMaterial:n=!1,opacity:o=at})=>{const r=s??new URL("/assets/xr/3d-models/head-occluder-v2.glb",ye.libConfig.assetStorageEndpoint).toString(),[c,i]=E.useState(null);E.useEffect(()=>{let h=!1;return Es(r).then(u=>{h||i(u.scene)}).catch(u=>{h||console.error(`${ye.libConfig.loggerPrefix} head occluder load failed`,u)}),()=>{h=!0}},[r]);const l=E.useMemo(()=>{if(!c)return null;const h=c.clone();return h.traverse(u=>{u instanceof S.Mesh&&(u.material=new S.MeshStandardMaterial({color:15132390,colorWrite:n,depthWrite:!0,opacity:n?o:1,side:S.DoubleSide,transparent:n}))}),h},[c,n,o]);return E.useEffect(()=>{if(l)return()=>{l.traverse(h=>{h instanceof S.Mesh&&h.material.dispose()})}},[l]),l?(a?l.position.set(a[0],a[1],a[2]):l.position.set(pe[0],pe[1],pe[2]),e&&l.rotation.set(e[0],e[1],e[2]),t?l.scale.set(t[0],t[1],t[2]):l.scale.set(q[0],q[1],q[2]),l.renderOrder=-1,A.jsx("primitive",{object:l})):null},Ss=4,ws=({children:a,faceIndex:e=0,numFaces:t=Ss,scaleWithFace:s=!0,occluder:n=!0,showFaceMesh:o=!1,faceMeshMaterial:r})=>{const c=E.useMemo(()=>new S.MeshBasicMaterial({color:"#22c55e",side:S.BackSide,transparent:!0,opacity:.35,depthWrite:!1}),[]),i=n===!1?null:n===!0?{}:n;return A.jsxs($e.FaceTracker,{faceIndex:e,numFaces:t,scaleWithFace:s,children:[i&&A.jsx(it,{position:i.position??pe,rotation:i.rotation,scale:i.scale??q,url:i.url,showDebugMaterial:i.showDebugMaterial,opacity:i.opacity??at}),a,o&&A.jsx($e.FaceMesh,{faceIndex:e,numFaces:t,material:r??c})]})},ys=57,_s=15.5,Ze=ys/Math.PI/_s,Ls=-.134,Cs=-.024,W=(a,e,t)=>Math.min(t,Math.max(e,a)),Bt=(a,e)=>a*e-e/2,Ht=(a,e)=>-(a*e-e/2),Is=({eyeMidX:a,noseX:e,offsetX:t,rawYaw:s,sideMidX:n})=>{const o=W((Math.abs(s)-.18)/.42,0,1),r=n*.75+a*.25,c=a*.7+e*.3;return r*(1-o)+c*o+t},Fs=({baseScale:a,pitchRadians:e})=>{const t=e*180/Math.PI,n=1+W((t-6)/22,0,1)*.22;return[a[0]*n,a[1]*n,a[2]*n]},Ps=({yawRadians:a})=>{const e=Math.abs(a*180/Math.PI),s=.066*W((e-8)/12,0,1);return Math.sign(a)*s},Ns=({pitchRadians:a})=>{const e=a*180/Math.PI;return-.026*W((-e-6)/18,0,1)},Os=({baseOffset:a,yawRadians:e})=>{const t=Math.abs(e*180/Math.PI),s=W((t-8)/24,0,1);return a+s*.25},Ds=({baseOffsetY:a,baseScaleY:e,face:t})=>{if(!t||t.bounds.width<=0)return{aspectRatio:0,normalizedAspect:0,scaleY:e,offsetY:a};const s=t.bounds.height/t.bounds.width,n=W((s-1.55)/.35,-1,1);return{aspectRatio:s,normalizedAspect:n,scaleY:e+n*.06,offsetY:a+n*.005}},Gt=({face:a,offsetX:e,offsetY:t,scaleX:s,scaleY:n})=>{const o=a.bounds.width*s,r=a.bounds.height*n,c=a.bounds.centerX+e,i=a.bounds.centerY+t;return{x:c-o*.5,y:i-r*.5,width:o,height:r,centerX:c,centerY:i}},ks=({face:a,height:e,lockDepth:t,lockRotation:s,model:n,offsetX:o,offsetY:r,scaleX:c,scaleY:i,scaleZ:l,width:h})=>{const u=Gt({face:a,offsetX:o,offsetY:r,scaleX:c,scaleY:i}),f=a.landmarks[33],p=a.landmarks[263],T=a.landmarks[234],x=a.landmarks[454],g=a.landmarks[1],m=a.landmarks[10],v=a.landmarks[152],M=u.width*h,b=u.height*e,w=f&&p?(f.x+p.x)*.5:a.bounds.centerX,C=f&&p?(f.y+p.y)*.5:a.bounds.centerY-a.bounds.height*.15,_=T&&x?(T.x+x.x)*.5:w,P=(m==null?void 0:m.y)??a.bounds.minY,I=(v==null?void 0:v.y)??a.bounds.maxY,F=(P+I)*.5,D=f&&p?Math.atan2(p.y-f.y,p.x-f.x):0,N=g&&a.bounds.width>0?W((g.x-a.bounds.centerX)/(a.bounds.width*.5),-1,1)*.75:0,L=Is({eyeMidX:w,noseX:(g==null?void 0:g.x)??w,offsetX:o,rawYaw:N,sideMidX:_}),y=F*.75+C*.25+r,ae=n==="v2"?Bt(L,h):u.centerX*h-h/2,G=n==="v2"?Ht(a.bounds.centerY+r*.75,e):-(u.centerY*e-e/2),Z=m&&g?Math.max(1e-4,g.y-m.y):a.bounds.height*.42,ge=g&&v?Math.max(1e-4,v.y-g.y):a.bounds.height*.58,ie=(ge-Z)/(ge+Z),ce=W((ie-Ls)/.28,-1,1)*.58,le=g&&a.bounds.height>0?W((a.bounds.centerY-g.y)/(a.bounds.height*.5)-Cs,-1,1)*.18:0,ee=ce*.82+le*.18,ue=s?0:n==="v2"?N*.72:N,Ae=s?0:n==="v2"?-ee*.78:-ee,xe=s?0:-D,Te=t?M*Ze:n==="v2"?M*(Ze+Math.abs(ue)*.18):M*Ze;return{centerXPx:ae,centerYPx:G,depthPx:Te*l,heightPx:b,pitch:Ae,rawPitch:ee,rawPitchFromBalance:ce,rawPitchFromCenter:le,rawYaw:N,rotationZ:xe,roll:D,shape:u,skullAnchorX:L,skullAnchorY:y,verticalBalance:ie,widthPx:M,yaw:ue}},jt=({lockDepth:a,lockRotation:e,model:t,face:s,height:n,headDepthOffset:o,offsetX:r,offsetY:c,rotationOffsetX:i,rotationOffsetY:l,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:p,skullCenterMode:T,skullVerticalBias:x,width:g})=>ct({lockDepth:a,lockRotation:e,model:t,face:s,height:n,headDepthOffset:o,offsetX:r,offsetY:c,rotationOffsetX:i,rotationOffsetY:l,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:p,skullCenterMode:T,skullVerticalBias:x,width:g}).pose,ct=({lockDepth:a,lockRotation:e,model:t,face:s,height:n,headDepthOffset:o,offsetX:r,offsetY:c,rotationOffsetX:i,rotationOffsetY:l,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:p,skullCenterMode:T,skullVerticalBias:x,width:g})=>{const m=ks({face:s,height:n,lockDepth:a,lockRotation:e,model:t,offsetX:r,offsetY:c,scaleX:u,scaleY:f,scaleZ:p,width:g});if(T){const M=new d.Vector3(0,m.heightPx*x,-m.depthPx*o).applyEuler(new d.Euler(m.pitch,m.yaw,m.rotationZ,"XYZ")),b=Bt(m.skullAnchorX,g),w=Ht(m.skullAnchorY,n);return{pose:{boxCenterZ:M.z,centerX:b+M.x,centerY:w+M.y,width:m.widthPx,height:m.heightPx,depth:m.depthPx,rotationX:m.pitch+i,rotationY:m.yaw+l,rotationZ:m.rotationZ+h},debugMetrics:{face:{centerX:m.shape.centerX,centerY:m.shape.centerY,width:m.shape.width,height:m.shape.height},normalized:{rawPitch:m.rawPitch,rawPitchFromBalance:m.rawPitchFromBalance,rawPitchFromCenter:m.rawPitchFromCenter,rawYaw:m.rawYaw,roll:m.roll,verticalBalance:m.verticalBalance},pose:{pitch:m.pitch,yaw:m.yaw,rotationX:m.pitch+i,rotationY:m.yaw+l,rotationZ:m.rotationZ+h},skullAnchor:{x:m.skullAnchorX,y:m.skullAnchorY},center:{x:b+M.x,y:w+M.y,z:M.z},depthPx:m.depthPx,screen:{widthPx:m.widthPx,heightPx:m.heightPx}}}}return{pose:{boxCenterZ:-m.depthPx*o,centerX:m.centerXPx,centerY:m.centerYPx,width:m.widthPx,height:m.heightPx,depth:m.depthPx,rotationX:m.pitch+i,rotationY:m.yaw+l,rotationZ:m.rotationZ+h},debugMetrics:{face:{centerX:m.shape.centerX,centerY:m.shape.centerY,width:m.shape.width,height:m.shape.height},normalized:{rawPitch:m.rawPitch,rawPitchFromBalance:m.rawPitchFromBalance,rawPitchFromCenter:m.rawPitchFromCenter,rawYaw:m.rawYaw,roll:m.roll,verticalBalance:m.verticalBalance},pose:{pitch:m.pitch,yaw:m.yaw,rotationX:m.pitch+i,rotationY:m.yaw+l,rotationZ:m.rotationZ+h},skullAnchor:{x:m.skullAnchorX,y:m.skullAnchorY},center:{x:m.centerXPx,y:m.centerYPx,z:-m.depthPx*o},depthPx:m.depthPx,screen:{widthPx:m.widthPx,heightPx:m.heightPx}}}},Us=({lockDepth:a,lockRotation:e,model:t,face:s,height:n,headDepthOffset:o,offsetX:r,offsetY:c,rotationOffsetX:i,rotationOffsetY:l,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:p,skullCenterMode:T,skullVerticalBias:x,width:g})=>ct({lockDepth:a,lockRotation:e,model:t,face:s,height:n,headDepthOffset:o,offsetX:r,offsetY:c,rotationOffsetX:i,rotationOffsetY:l,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:p,skullCenterMode:T,skullVerticalBias:x,width:g}).debugMetrics,Bs=({boxColor:a,boxOpacity:e,face:t,headDepthOffset:s,lockDepth:n,lockRotation:o,model:r,occluderOffset:c,occluderOpacity:i,occluderScale:l,showOccluderProxy:h=!1,offsetX:u,offsetY:f,pose:p,rotationOffsetX:T,rotationOffsetY:x,rotationOffsetZ:g,scaleX:m,scaleY:v,scaleZ:M,show:b,showCenterDot:w,showFacePlaneReference:C,showGizmo:_,showHeadOccluder:P,skullCenterMode:I,skullVerticalBias:F,url:D,viewportHeight:N,viewportWidth:L})=>{const y=E.useMemo(()=>p||(!t||L<=0||N<=0?null:jt({face:t,width:L,height:N,headDepthOffset:s,lockDepth:n,lockRotation:o,model:r,offsetX:u,offsetY:f,rotationOffsetX:T,rotationOffsetY:x,rotationOffsetZ:g,scaleX:m,scaleY:v,scaleZ:M,skullCenterMode:I,skullVerticalBias:F})),[t,s,n,o,r,u,f,T,x,g,m,v,M,I,F,p,N,L]);if(!b||!y)return null;const ae=I?[0,-y.height*F,y.depth*s]:[0,0,0],G=y.height,Z=[q[0]*l[0]*G,q[1]*l[1]*G,q[2]*l[2]*G];return A.jsxs(A.Fragment,{children:[A.jsxs("group",{position:[y.centerX,y.centerY,y.boxCenterZ],rotation:[y.rotationX,y.rotationY,y.rotationZ],children:[A.jsx("group",{scale:[y.width,y.height,y.depth],children:e>0&&A.jsxs("mesh",{children:[A.jsx("boxGeometry",{args:[1,1,1]}),A.jsx("meshBasicMaterial",{color:a,wireframe:!0,transparent:!0,opacity:e})]})}),w&&A.jsxs("mesh",{children:[A.jsx("sphereGeometry",{args:[6,20,20]}),A.jsx("meshBasicMaterial",{color:a})]}),C&&A.jsxs("group",{position:ae,children:[A.jsxs("mesh",{rotation:[0,0,Math.PI/4],children:[A.jsx("ringGeometry",{args:[6,8,24]}),A.jsx("meshBasicMaterial",{color:"#f8fafc",side:d.DoubleSide})]}),A.jsxs("mesh",{rotation:[0,0,Math.PI/2],children:[A.jsx("planeGeometry",{args:[3,16]}),A.jsx("meshBasicMaterial",{color:"#f8fafc",transparent:!0,opacity:.9,side:d.DoubleSide})]}),A.jsxs("mesh",{children:[A.jsx("planeGeometry",{args:[16,3]}),A.jsx("meshBasicMaterial",{color:"#f8fafc",transparent:!0,opacity:.9,side:d.DoubleSide})]})]}),P&&A.jsxs(A.Fragment,{children:[h&&A.jsxs("mesh",{position:c,scale:Z,renderOrder:20,children:[A.jsx("sphereGeometry",{args:[1,24,16]}),A.jsx("meshBasicMaterial",{color:"#facc15",wireframe:!0,transparent:!0,opacity:.95,depthTest:!1,depthWrite:!1})]}),A.jsx(it,{opacity:i,position:c,scale:Z,showDebugMaterial:!0,url:D})]})]}),_&&A.jsx("group",{position:[y.centerX,y.centerY,y.boxCenterZ],rotation:[y.rotationX,y.rotationY,y.rotationZ],renderOrder:10,children:A.jsxs("group",{children:[A.jsxs("mesh",{children:[A.jsx("sphereGeometry",{args:[6,20,20]}),A.jsx("meshBasicMaterial",{color:"#e2e8f0",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[18,0,0],rotation:[0,0,-Math.PI/2],children:[A.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),A.jsx("meshBasicMaterial",{color:"#ef4444",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[34,0,0],rotation:[0,0,-Math.PI/2],children:[A.jsx("coneGeometry",{args:[4.2,12,16]}),A.jsx("meshBasicMaterial",{color:"#ef4444",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[0,18,0],children:[A.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),A.jsx("meshBasicMaterial",{color:"#22c55e",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[0,34,0],children:[A.jsx("coneGeometry",{args:[4.2,12,16]}),A.jsx("meshBasicMaterial",{color:"#22c55e",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[0,0,18],rotation:[Math.PI/2,0,0],children:[A.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),A.jsx("meshBasicMaterial",{color:"#3b82f6",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[0,0,34],rotation:[Math.PI/2,0,0],children:[A.jsx("coneGeometry",{args:[4.2,12,16]}),A.jsx("meshBasicMaterial",{color:"#3b82f6",depthTest:!1,depthWrite:!1})]}),A.jsx(He.Text,{position:[42,0,0],fontSize:10,color:"#ef4444",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"X"}),A.jsx(He.Text,{position:[0,42,0],fontSize:10,color:"#22c55e",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"Y"}),A.jsx(He.Text,{position:[0,0,42],fontSize:10,color:"#3b82f6",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"Z"})]})})]})};exports.DEFAULT_FACE_WARP_3D_SETTINGS=Et.DEFAULT_FACE_WARP_3D_SETTINGS;exports.FACE_WARP_3D_PRESET=Et.FACE_WARP_3D_PRESET;exports.CanonicalFaceMeshRenderer=un;exports.DEFAULT_APPEARANCE=hn;exports.DEFAULT_FEATURE_GROUPS=Nt;exports.DEFAULT_FEATURE_POINT_INDICES=Ot;exports.DEFAULT_MASKING=dn;exports.FACE_MASK_SIZE=_e;exports.FACE_OVAL=st;exports.FaceRetouchBackground=Rn;exports.HEAD_OCCLUDER_DEFAULT_OPACITY=at;exports.HEAD_OCCLUDER_DEFAULT_POSITION=pe;exports.HEAD_OCCLUDER_DEFAULT_SCALE=q;exports.HeadBinding=ws;exports.HeadBindingOccluder=Bs;exports.HeadOccluder=it;exports.INNER_MOUTH=rt;exports.LEFT_EYE=yt;exports.LEFT_EYEBROW=Ct;exports.OUTER_LIPS=Lt;exports.RIGHT_EYE=_t;exports.RIGHT_EYEBROW=It;exports.alphaMapOptions=An;exports.blendModeIndices=Je;exports.blendModeOptions=xn;exports.computeAdaptiveVerticalFit=Ds;exports.computeHeadBindingCubePose=jt;exports.computeHeadBindingDebugMetrics=Us;exports.computeHeadBindingShape=Gt;exports.computeUniversalHeadDepthOffset=Os;exports.computeUniversalOccluderScale=Fs;exports.computeUniversalPitchOffsetY=Ns;exports.computeUniversalYawOffsetX=Ps;exports.createFaceRetouchRegions=Dt;exports.drawFaceRetouchMask=Ft;exports.drawMouthRetouchMask=Pt;exports.materialTypeOptions=fn;exports.parseCanonicalFaceModel=St;exports.shaderPresetOptions=mn;exports.sideOptions=pn;exports.solveHeadBinding=ct;exports.supportsBlendMode=vn;exports.supportsTexturePanel=Tn;exports.textureMapOptions=gn;exports.useCanonicalFaceMesh=wt;exports.useFaceRetouchMask=Hn;exports.useFaceRetouchRegions=jn;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),k=require("react"),d=require("three"),pe=require("./index-82aENaRq.cjs"),se=require("./index-D4bLzBr6.cjs"),Q=require("@react-three/drei"),S=require("./FaceMeshRenderer-lQLhYIW-.cjs"),b=require("./FaceRetouch-DtNl8-4e.cjs");function be(l){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const e in l)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(l,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>l[e]})}}return t.default=l,Object.freeze(t)}const v=be(d);function me(l,t){if(t===d.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(t===d.TriangleFanDrawMode||t===d.TriangleStripDrawMode){let e=l.getIndex();if(e===null){const r=[],a=l.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)r.push(o);l.setIndex(r),e=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const s=e.count-2,n=[];if(t===d.TriangleFanDrawMode)for(let r=1;r<=s;r++)n.push(e.getX(0)),n.push(e.getX(r)),n.push(e.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(n.push(e.getX(r)),n.push(e.getX(r+1)),n.push(e.getX(r+2))):(n.push(e.getX(r+2)),n.push(e.getX(r+1)),n.push(e.getX(r)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),l}class Fe extends d.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new De(e)}),this.register(function(e){return new He(e)}),this.register(function(e){return new Ye(e)}),this.register(function(e){return new Ve(e)}),this.register(function(e){return new We(e)}),this.register(function(e){return new Ue(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new je(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new Oe(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new Be(e)}),this.register(function(e){return new Xe(e)}),this.register(function(e){return new Ke(e)}),this.register(function(e){return new Pe(e)}),this.register(function(e){return new ze(e)}),this.register(function(e){return new qe(e)})}load(t,e,s,n){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const c=d.LoaderUtils.extractUrlBase(t);r=d.LoaderUtils.resolveURL(c,this.path)}else r=d.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const a=function(c){n?n(c):console.error(c),i.manager.itemError(t),i.manager.itemEnd(t)},o=new d.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(c){try{i.parse(c,r,function(h){e(h),i.manager.itemEnd(t)},a)}catch(h){a(h)}},s,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,s,n){let i;const r={},a={},o=new TextDecoder;if(typeof t=="string")i=JSON.parse(t);else if(t instanceof ArrayBuffer)if(o.decode(new Uint8Array(t,0,4))===xe){try{r[x.KHR_BINARY_GLTF]=new Ze(t)}catch(u){n&&n(u);return}i=JSON.parse(r[x.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(t));else i=t;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new lt(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,r[u.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const u=i.extensionsUsed[h],f=i.extensionsRequired||[];switch(u){case x.KHR_MATERIALS_UNLIT:r[u]=new Ne;break;case x.KHR_DRACO_MESH_COMPRESSION:r[u]=new Qe(i,this.dracoLoader);break;case x.KHR_TEXTURE_TRANSFORM:r[u]=new Je;break;case x.KHR_MESH_QUANTIZATION:r[u]=new $e;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(r),c.setPlugins(a),c.parse(s,n)}parseAsync(t,e){const s=this;return new Promise(function(n,i){s.parse(t,e,n,i)})}}function Ie(){let l={};return{get:function(t){return l[t]},add:function(t,e){l[t]=e},remove:function(t){delete l[t]},removeAll:function(){l={}}}}const x={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Pe{constructor(t){this.parser=t,this.name=x.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let s=0,n=e.length;s<n;s++){const i=e[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(t){const e=this.parser,s="light:"+t;let n=e.cache.get(s);if(n)return n;const i=e.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let c;const h=new d.Color(16777215);o.color!==void 0&&h.setRGB(o.color[0],o.color[1],o.color[2],d.LinearSRGBColorSpace);const u=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new d.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new d.PointLight(h),c.distance=u;break;case"spot":c=new d.SpotLight(h),c.distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),O(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=e.createUniqueName(o.name||"light_"+t),n=Promise.resolve(c),e.cache.add(s,n),n}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,s=this.parser,i=s.json.nodes[t],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return s._getNodeRef(e.cache,a,o)})}}class Ne{constructor(){this.name=x.KHR_MATERIALS_UNLIT}getMaterialType(){return d.MeshBasicMaterial}extendParams(t,e,s){const n=[];t.color=new d.Color(1,1,1),t.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;t.color.setRGB(r[0],r[1],r[2],d.LinearSRGBColorSpace),t.opacity=r[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(t,"map",i.baseColorTexture,d.SRGBColorSpace))}return Promise.all(n)}}class Oe{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(e.emissiveIntensity=i),Promise.resolve()}}class De{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];if(r.clearcoatFactor!==void 0&&(e.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(s.assignTexture(e,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(e,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(e,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new d.Vector2(a,a)}return Promise.all(i)}}class He{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_DISPERSION}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Be{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.iridescenceFactor!==void 0&&(e.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&i.push(s.assignTexture(e,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(e.iridescenceIOR=r.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(e,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(i)}}class Ue{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_SHEEN}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];e.sheenColor=new d.Color(0,0,0),e.sheenRoughness=0,e.sheen=1;const r=n.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;e.sheenColor.setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&i.push(s.assignTexture(e,"sheenColorMap",r.sheenColorTexture,d.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(e,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(i)}}class Ge{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.transmissionFactor!==void 0&&(e.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&i.push(s.assignTexture(e,"transmissionMap",r.transmissionTexture)),Promise.all(i)}}class je{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_VOLUME}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];e.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&i.push(s.assignTexture(e,"thicknessMap",r.thicknessTexture)),e.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return e.attenuationColor=new d.Color().setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace),Promise.all(i)}}class ke{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_IOR}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class ve{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_SPECULAR}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];e.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&i.push(s.assignTexture(e,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return e.specularColor=new d.Color().setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&i.push(s.assignTexture(e,"specularColorMap",r.specularColorTexture,d.SRGBColorSpace)),Promise.all(i)}}class Ke{constructor(t){this.parser=t,this.name=x.EXT_MATERIALS_BUMP}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return e.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&i.push(s.assignTexture(e,"bumpMap",r.bumpTexture)),Promise.all(i)}}class Xe{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.anisotropyStrength!==void 0&&(e.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(e.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&i.push(s.assignTexture(e,"anisotropyMap",r.anisotropyTexture)),Promise.all(i)}}class Ye{constructor(t){this.parser=t,this.name=x.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,s=e.json,n=s.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],r=e.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,i.source,r)}}class Ve{constructor(t){this.parser=t,this.name=x.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,s=this.parser,n=s.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=n.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(t,r.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class We{constructor(t){this.parser=t,this.name=x.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,s=this.parser,n=s.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=n.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(t,r.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class ze{constructor(t){this.name=x.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,s=e.bufferViews[t];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const o=n.byteOffset||0,c=n.byteLength||0,h=n.count,u=n.byteStride,f=new Uint8Array(a,o,c);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(h,u,f,n.mode,n.filter).then(function(m){return m.buffer}):r.ready.then(function(){const m=new ArrayBuffer(h*u);return r.decodeGltfBuffer(new Uint8Array(m),h,u,f,n.mode,n.filter),m})})}else return null}}class qe{constructor(t){this.name=x.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,s=e.nodes[t];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=e.meshes[s.mesh];for(const c of n.primitives)if(c.mode!==I.TRIANGLES&&c.mode!==I.TRIANGLE_STRIP&&c.mode!==I.TRIANGLE_FAN&&c.mode!==void 0)return null;const r=s.extensions[this.name].attributes,a=[],o={};for(const c in r)a.push(this.parser.getDependency("accessor",r[c]).then(h=>(o[c]=h,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{const h=c.pop(),u=h.isGroup?h.children:[h],f=c[0].count,m=[];for(const T of u){const E=new d.Matrix4,A=new d.Vector3,p=new d.Quaternion,M=new d.Vector3(1,1,1),_=new d.InstancedMesh(T.geometry,T.material,f);for(let R=0;R<f;R++)o.TRANSLATION&&A.fromBufferAttribute(o.TRANSLATION,R),o.ROTATION&&p.fromBufferAttribute(o.ROTATION,R),o.SCALE&&M.fromBufferAttribute(o.SCALE,R),_.setMatrixAt(R,E.compose(A,p,M));for(const R in o)if(R==="_COLOR_0"){const y=o[R];_.instanceColor=new d.InstancedBufferAttribute(y.array,y.itemSize,y.normalized)}else R!=="TRANSLATION"&&R!=="ROTATION"&&R!=="SCALE"&&T.geometry.setAttribute(R,o[R]);d.Object3D.prototype.copy.call(_,T),this.parser.assignFinalMaterial(_),m.push(_)}return h.isGroup?(h.clear(),h.add(...m),h):m[0]}))}}const xe="glTF",V=12,Ae={JSON:1313821514,BIN:5130562};class Ze{constructor(t){this.name=x.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,V),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==xe)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-V,i=new DataView(t,V);let r=0;for(;r<n;){const a=i.getUint32(r,!0);r+=4;const o=i.getUint32(r,!0);if(r+=4,o===Ae.JSON){const c=new Uint8Array(t,V+r,a);this.content=s.decode(c)}else if(o===Ae.BIN){const c=V+r;this.body=t.slice(c,c+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Qe{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=x.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const s=this.json,n=this.dracoLoader,i=t.extensions[this.name].bufferView,r=t.extensions[this.name].attributes,a={},o={},c={};for(const h in r){const u=re[h]||h.toLowerCase();a[u]=r[h]}for(const h in t.attributes){const u=re[h]||h.toLowerCase();if(r[h]!==void 0){const f=s.accessors[t.attributes[h]],m=K[f.componentType];c[u]=m.name,o[u]=f.normalized===!0}}return e.getDependency("bufferView",i).then(function(h){return new Promise(function(u,f){n.decodeDracoFile(h,function(m){for(const T in m.attributes){const E=m.attributes[T],A=o[T];A!==void 0&&(E.normalized=A)}u(m)},a,c,d.LinearSRGBColorSpace,f)})})}}class Je{constructor(){this.name=x.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class $e{constructor(){this.name=x.KHR_MESH_QUANTIZATION}}class Me extends d.Interpolant{constructor(t,e,s,n){super(t,e,s,n)}copySampleValue_(t){const e=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=t*n*3+n;for(let r=0;r!==n;r++)e[r]=s[i+r];return e}interpolate_(t,e,s,n){const i=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,h=n-e,u=(s-e)/h,f=u*u,m=f*u,T=t*c,E=T-c,A=-2*m+3*f,p=m-f,M=1-A,_=p-f+u;for(let R=0;R!==a;R++){const y=r[E+R+a],F=r[E+R+o]*h,w=r[T+R+a],P=r[T+R]*h;i[R]=M*y+_*F+A*w+p*P}return i}}const et=new d.Quaternion;class tt extends Me{interpolate_(t,e,s,n){const i=super.interpolate_(t,e,s,n);return et.fromArray(i).normalize().toArray(i),i}}const I={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ge={9728:d.NearestFilter,9729:d.LinearFilter,9984:d.NearestMipmapNearestFilter,9985:d.LinearMipmapNearestFilter,9986:d.NearestMipmapLinearFilter,9987:d.LinearMipmapLinearFilter},Te={33071:d.ClampToEdgeWrapping,33648:d.MirroredRepeatWrapping,10497:d.RepeatWrapping},J={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},re={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},B={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},nt={CUBICSPLINE:void 0,LINEAR:d.InterpolateLinear,STEP:d.InterpolateDiscrete},$={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function st(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new d.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:d.FrontSide})),l.DefaultMaterial}function G(l,t,e){for(const s in e.extensions)l[s]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=e.extensions[s])}function O(l,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(l.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function rt(l,t,e){let s=!1,n=!1,i=!1;for(let c=0,h=t.length;c<h;c++){const u=t[c];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(l);const r=[],a=[],o=[];for(let c=0,h=t.length;c<h;c++){const u=t[c];if(s){const f=u.POSITION!==void 0?e.getDependency("accessor",u.POSITION):l.attributes.position;r.push(f)}if(n){const f=u.NORMAL!==void 0?e.getDependency("accessor",u.NORMAL):l.attributes.normal;a.push(f)}if(i){const f=u.COLOR_0!==void 0?e.getDependency("accessor",u.COLOR_0):l.attributes.color;o.push(f)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o)]).then(function(c){const h=c[0],u=c[1],f=c[2];return s&&(l.morphAttributes.position=h),n&&(l.morphAttributes.normal=u),i&&(l.morphAttributes.color=f),l.morphTargetsRelative=!0,l})}function it(l,t){if(l.updateMorphTargets(),t.weights!==void 0)for(let e=0,s=t.weights.length;e<s;e++)l.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(l.morphTargetInfluences.length===e.length){l.morphTargetDictionary={};for(let s=0,n=e.length;s<n;s++)l.morphTargetDictionary[e[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ot(l){let t;const e=l.extensions&&l.extensions[x.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+ee(e.attributes):t=l.indices+":"+ee(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)t+=":"+ee(l.targets[s]);return t}function ee(l){let t="";const e=Object.keys(l).sort();for(let s=0,n=e.length;s<n;s++)t+=e[s]+":"+l[e[s]]+";";return t}function ie(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function at(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":l.search(/\.ktx2($|\?)/i)>0||l.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const ct=new d.Matrix4;class lt{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new Ie,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,i=!1,r=-1;if(typeof navigator<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);n=s&&o?parseInt(o[1],10):-1,i=a.indexOf("Firefox")>-1,r=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&r<98?this.textureLoader=new d.TextureLoader(this.options.manager):this.textureLoader=new d.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new d.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const a={scene:r[0][n.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:n.asset,parser:s,userData:{}};return G(i,a,n),O(a,n),Promise.all(s._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const r=e[n].joints;for(let a=0,o=r.length;a<o;a++)t[r[a]].isBone=!0}for(let n=0,i=t.length;n<i;n++){const r=t[n];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,s){if(t.refs[e]<=1)return s;const n=s.clone(),i=(r,a)=>{const o=this.associations.get(r);o!=null&&this.associations.set(a,o);for(const[c,h]of r.children.entries())i(h,a.children[c])};return i(s,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const n=t(e[s]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let n=0;n<e.length;n++){const i=t(e[n]);i&&s.push(i)}return s}getDependency(t,e){const s=t+":"+e;let n=this.cache.get(s);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(e)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t);break}this.cache.add(s,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const s=this,n=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(n.map(function(i,r){return s.getDependency(t,r)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],s=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[x.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,r){s.load(d.LoaderUtils.resolveURL(e.uri,n.path),i,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(s){const n=e.byteLength||0,i=e.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(t){const e=this,s=this.json,n=this.json.accessors[t];if(n.bufferView===void 0&&n.sparse===void 0){const r=J[n.type],a=K[n.componentType],o=n.normalized===!0,c=new a(n.count*r);return Promise.resolve(new d.BufferAttribute(c,r,o))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(r){const a=r[0],o=J[n.type],c=K[n.componentType],h=c.BYTES_PER_ELEMENT,u=h*o,f=n.byteOffset||0,m=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,T=n.normalized===!0;let E,A;if(m&&m!==u){const p=Math.floor(f/m),M="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+p+":"+n.count;let _=e.cache.get(M);_||(E=new c(a,p*m,n.count*m/h),_=new d.InterleavedBuffer(E,m/h),e.cache.add(M,_)),A=new d.InterleavedBufferAttribute(_,o,f%m/h,T)}else a===null?E=new c(n.count*o):E=new c(a,f,n.count*o),A=new d.BufferAttribute(E,o,T);if(n.sparse!==void 0){const p=J.SCALAR,M=K[n.sparse.indices.componentType],_=n.sparse.indices.byteOffset||0,R=n.sparse.values.byteOffset||0,y=new M(r[1],_,n.sparse.count*p),F=new c(r[2],R,n.sparse.count*o);a!==null&&(A=new d.BufferAttribute(A.array.slice(),A.itemSize,A.normalized)),A.normalized=!1;for(let w=0,P=y.length;w<P;w++){const C=y[w];if(A.setX(C,F[w*o]),o>=2&&A.setY(C,F[w*o+1]),o>=3&&A.setZ(C,F[w*o+2]),o>=4&&A.setW(C,F[w*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}A.normalized=T}return A})}loadTexture(t){const e=this.json,s=this.options,i=e.textures[t].source,r=e.images[i];let a=this.textureLoader;if(r.uri){const o=s.manager.getHandler(r.uri);o!==null&&(a=o)}return this.loadTextureImage(t,i,a)}loadTextureImage(t,e,s){const n=this,i=this.json,r=i.textures[t],a=i.images[e],o=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,s).then(function(h){h.flipY=!1,h.name=r.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const f=(i.samplers||{})[r.sampler]||{};return h.magFilter=ge[f.magFilter]||d.LinearFilter,h.minFilter=ge[f.minFilter]||d.LinearMipmapLinearFilter,h.wrapS=Te[f.wrapS]||d.RepeatWrapping,h.wrapT=Te[f.wrapT]||d.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==d.NearestFilter&&h.minFilter!==d.LinearFilter,n.associations.set(h,{textures:t}),h}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(t,e){const s=this,n=this.json,i=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(u=>u.clone());const r=n.images[t],a=self.URL||self.webkitURL;let o=r.uri||"",c=!1;if(r.bufferView!==void 0)o=s.getDependency("bufferView",r.bufferView).then(function(u){c=!0;const f=new Blob([u],{type:r.mimeType});return o=a.createObjectURL(f),o});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(o).then(function(u){return new Promise(function(f,m){let T=f;e.isImageBitmapLoader===!0&&(T=function(E){const A=new d.Texture(E);A.needsUpdate=!0,f(A)}),e.load(d.LoaderUtils.resolveURL(u,i.path),T,void 0,m)})}).then(function(u){return c===!0&&a.revokeObjectURL(o),O(u,r),u.userData.mimeType=r.mimeType||at(r.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[t]=h,h}assignTexture(t,e,s,n){const i=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),i.extensions[x.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[x.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=i.associations.get(r);r=i.extensions[x.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),i.associations.set(r,o)}}return n!==void 0&&(r.colorSpace=n),t[e]=r,r})}assignFinalMaterial(t){const e=t.geometry;let s=t.material;const n=e.attributes.tangent===void 0,i=e.attributes.color!==void 0,r=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new d.PointsMaterial,d.Material.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,o.sizeAttenuation=!1,this.cache.add(a,o)),s=o}else if(t.isLine){const a="LineBasicMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new d.LineBasicMaterial,d.Material.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,this.cache.add(a,o)),s=o}if(n||i||r){let a="ClonedMaterial:"+s.uuid+":";n&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=s.clone(),i&&(o.vertexColors=!0),r&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(s))),s=o}t.material=s}getMaterialType(){return d.MeshStandardMaterial}loadMaterial(t){const e=this,s=this.json,n=this.extensions,i=s.materials[t];let r;const a={},o=i.extensions||{},c=[];if(o[x.KHR_MATERIALS_UNLIT]){const u=n[x.KHR_MATERIALS_UNLIT];r=u.getMaterialType(),c.push(u.extendParams(a,i,e))}else{const u=i.pbrMetallicRoughness||{};if(a.color=new d.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],d.LinearSRGBColorSpace),a.opacity=f[3]}u.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",u.baseColorTexture,d.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),r=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(t,a)})))}i.doubleSided===!0&&(a.side=d.DoubleSide);const h=i.alphaMode||$.OPAQUE;if(h===$.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===$.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==d.MeshBasicMaterial&&(c.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new d.Vector2(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;a.normalScale.set(u,u)}if(i.occlusionTexture!==void 0&&r!==d.MeshBasicMaterial&&(c.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==d.MeshBasicMaterial){const u=i.emissiveFactor;a.emissive=new d.Color().setRGB(u[0],u[1],u[2],d.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&r!==d.MeshBasicMaterial&&c.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture,d.SRGBColorSpace)),Promise.all(c).then(function(){const u=new r(a);return i.name&&(u.name=i.name),O(u,i),e.associations.set(u,{materials:t}),i.extensions&&G(n,u,i),u})}createUniqueName(t){const e=d.PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,s=this.extensions,n=this.primitiveCache;function i(a){return s[x.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return Ee(o,a,e)})}const r=[];for(let a=0,o=t.length;a<o;a++){const c=t[a],h=ot(c),u=n[h];if(u)r.push(u.promise);else{let f;c.extensions&&c.extensions[x.KHR_DRACO_MESH_COMPRESSION]?f=i(c):f=Ee(new d.BufferGeometry,c,e),n[h]={primitive:c,promise:f},r.push(f)}}return Promise.all(r)}loadMesh(t){const e=this,s=this.json,n=this.extensions,i=s.meshes[t],r=i.primitives,a=[];for(let o=0,c=r.length;o<c;o++){const h=r[o].material===void 0?st(this.cache):this.getDependency("material",r[o].material);a.push(h)}return a.push(e.loadGeometries(r)),Promise.all(a).then(function(o){const c=o.slice(0,o.length-1),h=o[o.length-1],u=[];for(let m=0,T=h.length;m<T;m++){const E=h[m],A=r[m];let p;const M=c[m];if(A.mode===I.TRIANGLES||A.mode===I.TRIANGLE_STRIP||A.mode===I.TRIANGLE_FAN||A.mode===void 0)p=i.isSkinnedMesh===!0?new d.SkinnedMesh(E,M):new d.Mesh(E,M),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),A.mode===I.TRIANGLE_STRIP?p.geometry=me(p.geometry,d.TriangleStripDrawMode):A.mode===I.TRIANGLE_FAN&&(p.geometry=me(p.geometry,d.TriangleFanDrawMode));else if(A.mode===I.LINES)p=new d.LineSegments(E,M);else if(A.mode===I.LINE_STRIP)p=new d.Line(E,M);else if(A.mode===I.LINE_LOOP)p=new d.LineLoop(E,M);else if(A.mode===I.POINTS)p=new d.Points(E,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);Object.keys(p.geometry.morphAttributes).length>0&&it(p,i),p.name=e.createUniqueName(i.name||"mesh_"+t),O(p,i),A.extensions&&G(n,p,A),e.assignFinalMaterial(p),u.push(p)}for(let m=0,T=u.length;m<T;m++)e.associations.set(u[m],{meshes:t,primitives:m});if(u.length===1)return i.extensions&&G(n,u[0],i),u[0];const f=new d.Group;i.extensions&&G(n,f,i),e.associations.set(f,{meshes:t});for(let m=0,T=u.length;m<T;m++)f.add(u[m]);return f})}loadCamera(t){let e;const s=this.json.cameras[t],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?e=new d.PerspectiveCamera(d.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(e=new d.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),O(e,s),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],s=[];for(let n=0,i=e.joints.length;n<i;n++)s.push(this._loadNodeShallow(e.joints[n]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),r=n,a=[],o=[];for(let c=0,h=r.length;c<h;c++){const u=r[c];if(u){a.push(u);const f=new d.Matrix4;i!==null&&f.fromArray(i.array,c*16),o.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new d.Skeleton(a,o)})}loadAnimation(t){const e=this.json,s=this,n=e.animations[t],i=n.name?n.name:"animation_"+t,r=[],a=[],o=[],c=[],h=[];for(let u=0,f=n.channels.length;u<f;u++){const m=n.channels[u],T=n.samplers[m.sampler],E=m.target,A=E.node,p=n.parameters!==void 0?n.parameters[T.input]:T.input,M=n.parameters!==void 0?n.parameters[T.output]:T.output;E.node!==void 0&&(r.push(this.getDependency("node",A)),a.push(this.getDependency("accessor",p)),o.push(this.getDependency("accessor",M)),c.push(T),h.push(E))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(h)]).then(function(u){const f=u[0],m=u[1],T=u[2],E=u[3],A=u[4],p=[];for(let M=0,_=f.length;M<_;M++){const R=f[M],y=m[M],F=T[M],w=E[M],P=A[M];if(R===void 0)continue;R.updateMatrix&&R.updateMatrix();const C=s._createAnimationTracks(R,y,F,w,P);if(C)for(let N=0;N<C.length;N++)p.push(C[N])}return new d.AnimationClip(i,void 0,p)})}createNodeMesh(t){const e=this.json,s=this,n=e.nodes[t];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const r=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let o=0,c=n.weights.length;o<c;o++)a.morphTargetInfluences[o]=n.weights[o]}),r})}loadNode(t){const e=this.json,s=this,n=e.nodes[t],i=s._loadNodeShallow(t),r=[],a=n.children||[];for(let c=0,h=a.length;c<h;c++)r.push(s.getDependency("node",a[c]));const o=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),o]).then(function(c){const h=c[0],u=c[1],f=c[2];f!==null&&h.traverse(function(m){m.isSkinnedMesh&&m.bind(f,ct)});for(let m=0,T=u.length;m<T;m++)h.add(u[m]);return h})}_loadNodeShallow(t){const e=this.json,s=this.extensions,n=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const i=e.nodes[t],r=i.name?n.createUniqueName(i.name):"",a=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(t)});return o&&a.push(o),i.camera!==void 0&&a.push(n.getDependency("camera",i.camera).then(function(c){return n._getNodeRef(n.cameraCache,i.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(t)}).forEach(function(c){a.push(c)}),this.nodeCache[t]=Promise.all(a).then(function(c){let h;if(i.isBone===!0?h=new d.Bone:c.length>1?h=new d.Group:c.length===1?h=c[0]:h=new d.Object3D,h!==c[0])for(let u=0,f=c.length;u<f;u++)h.add(c[u]);if(i.name&&(h.userData.name=i.name,h.name=r),O(h,i),i.extensions&&G(s,h,i),i.matrix!==void 0){const u=new d.Matrix4;u.fromArray(i.matrix),h.applyMatrix4(u)}else i.translation!==void 0&&h.position.fromArray(i.translation),i.rotation!==void 0&&h.quaternion.fromArray(i.rotation),i.scale!==void 0&&h.scale.fromArray(i.scale);return n.associations.has(h)||n.associations.set(h,{}),n.associations.get(h).nodes=t,h}),this.nodeCache[t]}loadScene(t){const e=this.extensions,s=this.json.scenes[t],n=this,i=new d.Group;s.name&&(i.name=n.createUniqueName(s.name)),O(i,s),s.extensions&&G(e,i,s);const r=s.nodes||[],a=[];for(let o=0,c=r.length;o<c;o++)a.push(n.getDependency("node",r[o]));return Promise.all(a).then(function(o){for(let h=0,u=o.length;h<u;h++)i.add(o[h]);const c=h=>{const u=new Map;for(const[f,m]of n.associations)(f instanceof d.Material||f instanceof d.Texture)&&u.set(f,m);return h.traverse(f=>{const m=n.associations.get(f);m!=null&&u.set(f,m)}),u};return n.associations=c(i),i})}_createAnimationTracks(t,e,s,n,i){const r=[],a=t.name?t.name:t.uuid,o=[];B[i.path]===B.weights?t.traverse(function(f){f.morphTargetInfluences&&o.push(f.name?f.name:f.uuid)}):o.push(a);let c;switch(B[i.path]){case B.weights:c=d.NumberKeyframeTrack;break;case B.rotation:c=d.QuaternionKeyframeTrack;break;case B.position:case B.scale:c=d.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:c=d.NumberKeyframeTrack;break;case 2:case 3:default:c=d.VectorKeyframeTrack;break}break}const h=n.interpolation!==void 0?nt[n.interpolation]:d.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let f=0,m=o.length;f<m;f++){const T=new c(o[f]+"."+B[i.path],e.array,u,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),r.push(T)}return r}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const s=ie(e.constructor),n=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)n[i]=e[i]*s;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(s){const n=this instanceof d.QuaternionKeyframeTrack?tt:Me;return new n(this.times,this.values,this.getValueSize()/3,s)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ut(l,t,e){const s=t.attributes,n=new d.Box3;if(s.POSITION!==void 0){const a=e.json.accessors[s.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(n.set(new d.Vector3(o[0],o[1],o[2]),new d.Vector3(c[0],c[1],c[2])),a.normalized){const h=ie(K[a.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=t.targets;if(i!==void 0){const a=new d.Vector3,o=new d.Vector3;for(let c=0,h=i.length;c<h;c++){const u=i[c];if(u.POSITION!==void 0){const f=e.json.accessors[u.POSITION],m=f.min,T=f.max;if(m!==void 0&&T!==void 0){if(o.setX(Math.max(Math.abs(m[0]),Math.abs(T[0]))),o.setY(Math.max(Math.abs(m[1]),Math.abs(T[1]))),o.setZ(Math.max(Math.abs(m[2]),Math.abs(T[2]))),f.normalized){const E=ie(K[f.componentType]);o.multiplyScalar(E)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}l.boundingBox=n;const r=new d.Sphere;n.getCenter(r.center),r.radius=n.min.distanceTo(n.max)/2,l.boundingSphere=r}function Ee(l,t,e){const s=t.attributes,n=[];function i(r,a){return e.getDependency("accessor",r).then(function(o){l.setAttribute(a,o)})}for(const r in s){const a=re[r]||r.toLowerCase();a in l.attributes||n.push(i(s[r],a))}if(t.indices!==void 0&&!l.index){const r=e.getDependency("accessor",t.indices).then(function(a){l.setIndex(a)});n.push(r)}return d.ColorManagement.workingColorSpace!==d.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${d.ColorManagement.workingColorSpace}" not supported.`),O(l,t),ut(l,t,e),Promise.all(n).then(function(){return t.targets!==void 0?rt(l,t.targets,e):l})}const W=[0,0,-10],U=[.5,.5,.5],oe=1,te=new Map,ht=l=>{const t=te.get(l);if(t)return t;const e=new Fe,s=se.fetchAndVerify(l).then(n=>new Promise((i,r)=>{e.parse(n,"",i,r)})).catch(n=>{throw te.delete(l),n});return te.set(l,s),s},ae=({position:l,rotation:t,scale:e,url:s,showDebugMaterial:n=!1,opacity:i=oe})=>{const r=s??new URL("/assets/xr/3d-models/head-occluder-v2.glb",se.libConfig.assetStorageEndpoint).toString(),[a,o]=k.useState(null);k.useEffect(()=>{let h=!1;return ht(r).then(u=>{h||o(u.scene)}).catch(u=>{h||console.error(`${se.libConfig.loggerPrefix} head occluder load failed`,u)}),()=>{h=!0}},[r]);const c=k.useMemo(()=>{if(!a)return null;const h=a.clone();return h.traverse(u=>{u instanceof v.Mesh&&(u.material=new v.MeshStandardMaterial({color:15132390,colorWrite:n,depthWrite:!0,opacity:n?i:1,side:v.DoubleSide,transparent:n}))}),h},[a,n,i]);return k.useEffect(()=>{if(c)return()=>{c.traverse(h=>{h instanceof v.Mesh&&h.material.dispose()})}},[c]),c?(l?c.position.set(l[0],l[1],l[2]):c.position.set(W[0],W[1],W[2]),t&&c.rotation.set(t[0],t[1],t[2]),e?c.scale.set(e[0],e[1],e[2]):c.scale.set(U[0],U[1],U[2]),c.renderOrder=-1,g.jsx("primitive",{object:c})):null},dt=4,ft=({children:l,faceIndex:t=0,numFaces:e=dt,scaleWithFace:s=!0,occluder:n=!0,showFaceMesh:i=!1,faceMeshMaterial:r})=>{const a=k.useMemo(()=>new v.MeshBasicMaterial({color:"#22c55e",side:v.BackSide,transparent:!0,opacity:.35,depthWrite:!1}),[]),o=n===!1?null:n===!0?{}:n;return g.jsxs(pe.FaceTracker,{faceIndex:t,numFaces:e,scaleWithFace:s,children:[o&&g.jsx(ae,{position:o.position??W,rotation:o.rotation,scale:o.scale??U,url:o.url,showDebugMaterial:o.showDebugMaterial,opacity:o.opacity??oe}),l,i&&g.jsx(pe.FaceMesh,{faceIndex:t,numFaces:e,material:r??a})]})},pt=57,mt=15.5,ne=pt/Math.PI/mt,At=-.134,gt=-.024,D=(l,t,e)=>Math.min(e,Math.max(t,l)),Re=(l,t)=>l*t-t/2,_e=(l,t)=>-(l*t-t/2),Tt=({eyeMidX:l,noseX:t,offsetX:e,rawYaw:s,sideMidX:n})=>{const i=D((Math.abs(s)-.18)/.42,0,1),r=n*.75+l*.25,a=l*.7+t*.3;return r*(1-i)+a*i+e},Et=({baseScale:l,pitchRadians:t})=>{const e=t*180/Math.PI,n=1+D((e-6)/22,0,1)*.22;return[l[0]*n,l[1]*n,l[2]*n]},xt=({yawRadians:l})=>{const t=Math.abs(l*180/Math.PI),s=.066*D((t-8)/12,0,1);return Math.sign(l)*s},Mt=({pitchRadians:l})=>{const t=l*180/Math.PI;return-.026*D((-t-6)/18,0,1)},Rt=({baseOffset:l,yawRadians:t})=>{const e=Math.abs(t*180/Math.PI),s=D((e-8)/24,0,1);return l+s*.25},_t=({baseOffsetY:l,baseScaleY:t,face:e})=>{if(!e||e.bounds.width<=0)return{aspectRatio:0,normalizedAspect:0,scaleY:t,offsetY:l};const s=e.bounds.height/e.bounds.width,n=D((s-1.55)/.35,-1,1);return{aspectRatio:s,normalizedAspect:n,scaleY:t+n*.06,offsetY:l+n*.005}},Se=({face:l,offsetX:t,offsetY:e,scaleX:s,scaleY:n})=>{const i=l.bounds.width*s,r=l.bounds.height*n,a=l.bounds.centerX+t,o=l.bounds.centerY+e;return{x:a-i*.5,y:o-r*.5,width:i,height:r,centerX:a,centerY:o}},St=({face:l,height:t,lockDepth:e,lockRotation:s,model:n,offsetX:i,offsetY:r,scaleX:a,scaleY:o,scaleZ:c,width:h})=>{const u=Se({face:l,offsetX:i,offsetY:r,scaleX:a,scaleY:o}),f=l.landmarks[33],m=l.landmarks[263],T=l.landmarks[234],E=l.landmarks[454],A=l.landmarks[1],p=l.landmarks[10],M=l.landmarks[152],_=u.width*h,R=u.height*t,y=f&&m?(f.x+m.x)*.5:l.bounds.centerX,F=f&&m?(f.y+m.y)*.5:l.bounds.centerY-l.bounds.height*.15,w=T&&E?(T.x+E.x)*.5:y,P=(p==null?void 0:p.y)??l.bounds.minY,C=(M==null?void 0:M.y)??l.bounds.maxY,N=(P+C)*.5,z=f&&m?Math.atan2(m.y-f.y,m.x-f.x):0,H=A&&l.bounds.width>0?D((A.x-l.bounds.centerX)/(l.bounds.width*.5),-1,1)*.75:0,j=Tt({eyeMidX:y,noseX:(A==null?void 0:A.x)??y,offsetX:i,rawYaw:H,sideMidX:w}),L=N*.75+F*.25+r,q=n==="v2"?Re(j,h):u.centerX*h-h/2,X=n==="v2"?_e(l.bounds.centerY+r*.75,t):-(u.centerY*t-t/2),Y=p&&A?Math.max(1e-4,A.y-p.y):l.bounds.height*.42,le=A&&M?Math.max(1e-4,M.y-A.y):l.bounds.height*.58,ue=(le-Y)/(le+Y),he=D((ue-At)/.28,-1,1)*.58,de=A&&l.bounds.height>0?D((l.bounds.centerY-A.y)/(l.bounds.height*.5)-gt,-1,1)*.18:0,Z=he*.82+de*.18,fe=s?0:n==="v2"?H*.72:H,ye=s?0:n==="v2"?-Z*.78:-Z,we=s?0:-z,Ce=e?_*ne:n==="v2"?_*(ne+Math.abs(fe)*.18):_*ne;return{centerXPx:q,centerYPx:X,depthPx:Ce*c,heightPx:R,pitch:ye,rawPitch:Z,rawPitchFromBalance:he,rawPitchFromCenter:de,rawYaw:H,rotationZ:we,roll:z,shape:u,skullAnchorX:j,skullAnchorY:L,verticalBalance:ue,widthPx:_,yaw:fe}},Le=({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:A})=>ce({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:A}).pose,ce=({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:A})=>{const p=St({face:s,height:n,lockDepth:l,lockRotation:t,model:e,offsetX:r,offsetY:a,scaleX:u,scaleY:f,scaleZ:m,width:A});if(T){const _=new d.Vector3(0,p.heightPx*E,-p.depthPx*i).applyEuler(new d.Euler(p.pitch,p.yaw,p.rotationZ,"XYZ")),R=Re(p.skullAnchorX,A),y=_e(p.skullAnchorY,n);return{pose:{boxCenterZ:_.z,centerX:R+_.x,centerY:y+_.y,width:p.widthPx,height:p.heightPx,depth:p.depthPx,rotationX:p.pitch+o,rotationY:p.yaw+c,rotationZ:p.rotationZ+h},debugMetrics:{face:{centerX:p.shape.centerX,centerY:p.shape.centerY,width:p.shape.width,height:p.shape.height},normalized:{rawPitch:p.rawPitch,rawPitchFromBalance:p.rawPitchFromBalance,rawPitchFromCenter:p.rawPitchFromCenter,rawYaw:p.rawYaw,roll:p.roll,verticalBalance:p.verticalBalance},pose:{pitch:p.pitch,yaw:p.yaw,rotationX:p.pitch+o,rotationY:p.yaw+c,rotationZ:p.rotationZ+h},skullAnchor:{x:p.skullAnchorX,y:p.skullAnchorY},center:{x:R+_.x,y:y+_.y,z:_.z},depthPx:p.depthPx,screen:{widthPx:p.widthPx,heightPx:p.heightPx}}}}return{pose:{boxCenterZ:-p.depthPx*i,centerX:p.centerXPx,centerY:p.centerYPx,width:p.widthPx,height:p.heightPx,depth:p.depthPx,rotationX:p.pitch+o,rotationY:p.yaw+c,rotationZ:p.rotationZ+h},debugMetrics:{face:{centerX:p.shape.centerX,centerY:p.shape.centerY,width:p.shape.width,height:p.shape.height},normalized:{rawPitch:p.rawPitch,rawPitchFromBalance:p.rawPitchFromBalance,rawPitchFromCenter:p.rawPitchFromCenter,rawYaw:p.rawYaw,roll:p.roll,verticalBalance:p.verticalBalance},pose:{pitch:p.pitch,yaw:p.yaw,rotationX:p.pitch+o,rotationY:p.yaw+c,rotationZ:p.rotationZ+h},skullAnchor:{x:p.skullAnchorX,y:p.skullAnchorY},center:{x:p.centerXPx,y:p.centerYPx,z:-p.depthPx*i},depthPx:p.depthPx,screen:{widthPx:p.widthPx,heightPx:p.heightPx}}}},Lt=({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:A})=>ce({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:A}).debugMetrics,yt=({boxColor:l,boxOpacity:t,face:e,headDepthOffset:s,lockDepth:n,lockRotation:i,model:r,occluderOffset:a,occluderOpacity:o,occluderScale:c,showOccluderProxy:h=!1,offsetX:u,offsetY:f,pose:m,rotationOffsetX:T,rotationOffsetY:E,rotationOffsetZ:A,scaleX:p,scaleY:M,scaleZ:_,show:R,showCenterDot:y,showFacePlaneReference:F,showGizmo:w,showHeadOccluder:P,skullCenterMode:C,skullVerticalBias:N,url:z,viewportHeight:H,viewportWidth:j})=>{const L=k.useMemo(()=>m||(!e||j<=0||H<=0?null:Le({face:e,width:j,height:H,headDepthOffset:s,lockDepth:n,lockRotation:i,model:r,offsetX:u,offsetY:f,rotationOffsetX:T,rotationOffsetY:E,rotationOffsetZ:A,scaleX:p,scaleY:M,scaleZ:_,skullCenterMode:C,skullVerticalBias:N})),[e,s,n,i,r,u,f,T,E,A,p,M,_,C,N,m,H,j]);if(!R||!L)return null;const q=C?[0,-L.height*N,L.depth*s]:[0,0,0],X=L.height,Y=[U[0]*c[0]*X,U[1]*c[1]*X,U[2]*c[2]*X];return g.jsxs(g.Fragment,{children:[g.jsxs("group",{position:[L.centerX,L.centerY,L.boxCenterZ],rotation:[L.rotationX,L.rotationY,L.rotationZ],children:[g.jsx("group",{scale:[L.width,L.height,L.depth],children:t>0&&g.jsxs("mesh",{children:[g.jsx("boxGeometry",{args:[1,1,1]}),g.jsx("meshBasicMaterial",{color:l,wireframe:!0,transparent:!0,opacity:t})]})}),y&&g.jsxs("mesh",{children:[g.jsx("sphereGeometry",{args:[6,20,20]}),g.jsx("meshBasicMaterial",{color:l})]}),F&&g.jsxs("group",{position:q,children:[g.jsxs("mesh",{rotation:[0,0,Math.PI/4],children:[g.jsx("ringGeometry",{args:[6,8,24]}),g.jsx("meshBasicMaterial",{color:"#f8fafc",side:d.DoubleSide})]}),g.jsxs("mesh",{rotation:[0,0,Math.PI/2],children:[g.jsx("planeGeometry",{args:[3,16]}),g.jsx("meshBasicMaterial",{color:"#f8fafc",transparent:!0,opacity:.9,side:d.DoubleSide})]}),g.jsxs("mesh",{children:[g.jsx("planeGeometry",{args:[16,3]}),g.jsx("meshBasicMaterial",{color:"#f8fafc",transparent:!0,opacity:.9,side:d.DoubleSide})]})]}),P&&g.jsxs(g.Fragment,{children:[h&&g.jsxs("mesh",{position:a,scale:Y,renderOrder:20,children:[g.jsx("sphereGeometry",{args:[1,24,16]}),g.jsx("meshBasicMaterial",{color:"#facc15",wireframe:!0,transparent:!0,opacity:.95,depthTest:!1,depthWrite:!1})]}),g.jsx(ae,{opacity:o,position:a,scale:Y,showDebugMaterial:!0,url:z})]})]}),w&&g.jsx("group",{position:[L.centerX,L.centerY,L.boxCenterZ],rotation:[L.rotationX,L.rotationY,L.rotationZ],renderOrder:10,children:g.jsxs("group",{children:[g.jsxs("mesh",{children:[g.jsx("sphereGeometry",{args:[6,20,20]}),g.jsx("meshBasicMaterial",{color:"#e2e8f0",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[18,0,0],rotation:[0,0,-Math.PI/2],children:[g.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),g.jsx("meshBasicMaterial",{color:"#ef4444",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[34,0,0],rotation:[0,0,-Math.PI/2],children:[g.jsx("coneGeometry",{args:[4.2,12,16]}),g.jsx("meshBasicMaterial",{color:"#ef4444",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[0,18,0],children:[g.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),g.jsx("meshBasicMaterial",{color:"#22c55e",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[0,34,0],children:[g.jsx("coneGeometry",{args:[4.2,12,16]}),g.jsx("meshBasicMaterial",{color:"#22c55e",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[0,0,18],rotation:[Math.PI/2,0,0],children:[g.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),g.jsx("meshBasicMaterial",{color:"#3b82f6",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[0,0,34],rotation:[Math.PI/2,0,0],children:[g.jsx("coneGeometry",{args:[4.2,12,16]}),g.jsx("meshBasicMaterial",{color:"#3b82f6",depthTest:!1,depthWrite:!1})]}),g.jsx(Q.Text,{position:[42,0,0],fontSize:10,color:"#ef4444",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"X"}),g.jsx(Q.Text,{position:[0,42,0],fontSize:10,color:"#22c55e",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"Y"}),g.jsx(Q.Text,{position:[0,0,42],fontSize:10,color:"#3b82f6",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"Z"})]})})]})};exports.CANONICAL_FACE_MESH_GEOMETRY_SPECS=S.CANONICAL_FACE_MESH_GEOMETRY_SPECS;exports.CanonicalFaceMeshRenderer=S.CanonicalFaceMeshRenderer;exports.DEFAULT_APPEARANCE=S.DEFAULT_APPEARANCE;exports.DEFAULT_FACE_MESH_RENDERER=S.DEFAULT_FACE_MESH_RENDERER;exports.DEFAULT_FACE_MESH_TRANSFORM=S.DEFAULT_FACE_MESH_TRANSFORM;exports.DEFAULT_MASKING=S.DEFAULT_MASKING;exports.FACE_MESH_ALPHA_MAPS=S.FACE_MESH_ALPHA_MAPS;exports.FACE_MESH_BLEND_MODES=S.FACE_MESH_BLEND_MODES;exports.FACE_MESH_MASK_TEXTURE_SOURCES=S.FACE_MESH_MASK_TEXTURE_SOURCES;exports.FACE_MESH_MATERIAL_TYPES=S.FACE_MESH_MATERIAL_TYPES;exports.FACE_MESH_SHADER_PRESETS=S.FACE_MESH_SHADER_PRESETS;exports.FACE_MESH_SIDES=S.FACE_MESH_SIDES;exports.FACE_MESH_TEXTURE_MAPS=S.FACE_MESH_TEXTURE_MAPS;exports.FaceMeshMaterial=S.FaceMeshMaterial;exports.FaceMeshRenderer=S.FaceMeshRenderer;exports.blendModeIndices=S.blendModeIndices;exports.canonicalFaceAlphaMaskUrl=S.canonicalFaceAlphaMaskUrl;exports.canonicalFaceTextureStyle2Url=S.canonicalFaceTextureStyle2Url;exports.canonicalFaceTextureUrl=S.canonicalFaceTextureUrl;exports.mapFaceMeshRendererSettingsToProps=S.mapFaceMeshRendererSettingsToProps;exports.parseCanonicalFaceModel=S.parseCanonicalFaceModel;exports.resolveFaceMeshRendererSettings=S.resolveFaceMeshRendererSettings;exports.supportsBlendMode=S.supportsBlendMode;exports.supportsTexturePanel=S.supportsTexturePanel;exports.useCanonicalFaceMesh=S.useCanonicalFaceMesh;exports.DEFAULT_FACE_WARP_3D_SETTINGS=b.DEFAULT_FACE_WARP_3D_SETTINGS;exports.FACE_RETOUCH_DEFAULT_CONTROLS=b.FACE_RETOUCH_DEFAULT_CONTROLS;exports.FACE_RETOUCH_SETTINGS_FIELDS=b.FACE_RETOUCH_SETTINGS_FIELDS;exports.FACE_WARP_3D_PRESET=b.FACE_WARP_3D_PRESET;exports.FaceRetouch=b.FaceRetouch;exports.alphaMapOptions=b.alphaMapOptions;exports.blendModeOptions=b.blendModeOptions;exports.materialTypeOptions=b.materialTypeOptions;exports.patchFaceRetouchControls=b.patchFaceRetouchControls;exports.resolveFaceRetouchControls=b.resolveFaceRetouchControls;exports.shaderPresetOptions=b.shaderPresetOptions;exports.sideOptions=b.sideOptions;exports.textureMapOptions=b.textureMapOptions;exports.HEAD_OCCLUDER_DEFAULT_OPACITY=oe;exports.HEAD_OCCLUDER_DEFAULT_POSITION=W;exports.HEAD_OCCLUDER_DEFAULT_SCALE=U;exports.HeadBinding=ft;exports.HeadBindingOccluder=yt;exports.HeadOccluder=ae;exports.computeAdaptiveVerticalFit=_t;exports.computeHeadBindingCubePose=Le;exports.computeHeadBindingDebugMetrics=Lt;exports.computeHeadBindingShape=Se;exports.computeUniversalHeadDepthOffset=Rt;exports.computeUniversalOccluderScale=Et;exports.computeUniversalPitchOffsetY=Mt;exports.computeUniversalYawOffsetX=xt;exports.solveHeadBinding=ce;
|