@vincentt-xr/sdk 2.0.0-alpha.0 → 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 +1813 -27
- package/dist/{DebuggerUI-CEfdddkZ.cjs → DebuggerUI-B45_Gb9d.cjs} +1 -1
- package/dist/{DebuggerUI-Dgop6Q6o.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 +22 -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 +74 -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 +4 -2
- package/dist/components/FaceRetouch/Background.d.ts +9 -5
- package/dist/components/FaceRetouch/FaceRetouch.d.ts +47 -0
- package/dist/components/FaceRetouch/index.d.ts +2 -6
- package/dist/components/FaceRetouch/landmarkMask.d.ts +4 -6
- package/dist/components/FaceRetouch/useFaceRetouchMask.d.ts +4 -7
- package/dist/components/FaceTracker/index.d.ts +5 -3
- package/dist/components/FaceWarp3D/FaceWarp3DHead.d.ts +15 -0
- package/dist/components/FaceWarp3D/defaults.d.ts +37 -0
- package/dist/components/FaceWarp3D/index.d.ts +3 -0
- package/dist/components/FaceWarp3D/warp.d.ts +13 -0
- package/dist/components/HandJoints2D/index.d.ts +6 -0
- package/dist/components/HandTracker/index.d.ts +2 -2
- package/dist/components/HandTracking2D/HandVisual.d.ts +12 -0
- package/dist/components/HandTracking2D/index.d.ts +5 -0
- package/dist/components/HandTracking2DController/index.d.ts +5 -0
- package/dist/components/HandTracking3D/index.d.ts +6 -0
- 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 -0
- 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 -0
- 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 -62
- 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/XRScene/index.d.ts +14 -3
- 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 -101
- 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 +19 -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/default-setting/index.d.ts +37 -0
- package/dist/debug-ui/default-setting.cjs +21 -0
- package/dist/debug-ui/default-setting.js +777 -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/face-warp-3d/index.d.ts +6 -0
- package/dist/debug-ui/hand-joints-2d/index.d.ts +6 -0
- package/dist/debug-ui/hand-tracking-2d/index.d.ts +6 -0
- package/dist/debug-ui/hand-tracking-2d-controller/index.d.ts +6 -0
- package/dist/debug-ui/hand-tracking-3d/index.d.ts +6 -0
- package/dist/debug-ui/hierarchy-panel/index.d.ts +29 -0
- package/dist/debug-ui/index.d.ts +46 -0
- package/dist/debug-ui/layer-panel/index.d.ts +18 -0
- package/dist/debug-ui/media-source/MediaSourceSwitcher.d.ts +10 -0
- package/dist/debug-ui/media-source/index.d.ts +6 -0
- package/dist/debug-ui/media-source/media-preset.d.ts +9 -0
- package/dist/debug-ui/media-source/session.d.ts +12 -0
- package/dist/debug-ui/media-source.cjs +1 -0
- package/dist/debug-ui/media-source.js +9 -0
- 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 +9 -0
- 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 -0
- 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/settings-panel/index.d.ts +38 -0
- package/dist/debug-ui/shared/MaterialSection.d.ts +13 -0
- package/dist/debug-ui/shared/ScreenTransformSection.d.ts +32 -0
- package/dist/debug-ui/transform-3d-settings/index.d.ts +11 -0
- package/dist/debug-ui.cjs +10 -0
- package/dist/debug-ui.js +8861 -0
- 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 +55 -4
- package/dist/entries/face-effects.d.ts +12 -8
- package/dist/entries/internal.d.ts +1 -1
- package/dist/entries/low-level.d.ts +21 -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 -252
- package/dist/face-effects.js +1404 -2613
- 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/hand/handJoints2d.d.ts +49 -0
- package/dist/hand/handTracking2d.d.ts +33 -0
- package/dist/hand/handTracking2dController.d.ts +65 -0
- package/dist/hand/handTracking3d.d.ts +52 -0
- 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-BD-JWMjE.js → index-BgQAX8rs.js} +198 -134
- 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-CYMj26Ej.js → index-JygePOwo.js} +565 -498
- package/dist/index-UC0Ux38E.js +111 -0
- package/dist/{internal-KOKJDxCG.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 +959 -632
- package/dist/main.cjs +1 -1
- package/dist/main.js +556 -455
- 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/models/Hand/HandTracking.d.ts +2 -0
- package/dist/render/layerStack.d.ts +29 -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/screen-image/screenImagePresets.d.ts +13 -0
- package/dist/screen-image/screenImageSettings.d.ts +57 -0
- package/dist/screen-text/screenTextPresets.d.ts +6 -0
- package/dist/screen-text/screenTextSettings.d.ts +147 -0
- package/dist/screen2d/coordinates.d.ts +87 -0
- package/dist/screen2d/index.d.ts +7 -0
- package/dist/screen2d/material-runtime.d.ts +32 -0
- package/dist/screen2d/screenTransform.d.ts +47 -0
- package/dist/screen2d/smoothing.d.ts +5 -0
- package/dist/screen2d/texture.d.ts +10 -0
- package/dist/screen2d/transform.d.ts +25 -0
- package/dist/screen2d/types.d.ts +90 -0
- package/dist/{selectors-Bub0o3qy.cjs → selectors-2QvO5RYY.cjs} +1 -1
- package/dist/{selectors-BHO6TnoC.js → selectors-Dw3C-gSk.js} +5 -5
- 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 +582 -298
- package/dist/types/face.d.ts +1 -13
- package/dist/types/hand-tracking.d.ts +8 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/nodes.d.ts +4 -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/dist/x-Co8jPhP0.js +127 -0
- package/dist/x-KC8E4Gaj.cjs +41 -0
- 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 +55 -7
- package/dist/components/FaceRetouch/retouchRegions.d.ts +0 -23
- package/dist/components/FaceRetouch/useFaceRetouchRegions.d.ts +0 -12
- package/dist/index-B5J4gzn2.cjs +0 -1
- package/dist/index-BVBVg96G.cjs +0 -1
- package/dist/index-DtwHElmG.js +0 -157
- package/dist/index-PtFmD6B8.cjs +0 -1
- package/dist/internal-DH5d1Xnq.cjs +0 -1
- package/dist/modules/XRClient/index.d.ts +0 -9
- package/dist/modules/index.d.ts +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/face-effects.cjs
CHANGED
|
@@ -1,252 +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"),S=require("react"),$=require("./index-PtFmD6B8.cjs"),je=require("./selectors-Bub0o3qy.cjs"),Xe=require("./index-B5J4gzn2.cjs"),Fe=require("@react-three/drei");function Ft(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 E=Ft(d),Ke={normal:0,add:1,subtract:2,multiply:3,screen:4,overlay:5,softLight:6,hardLight:7,lighten:8,darken:9,difference:10,exclusion:11},Pe=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]),Ne=new Set([33,7,163,144,145,153,154,155,133,173,157,158,159,160,161,246]),Oe=new Set([362,382,381,380,374,373,390,249,263,466,388,387,386,385,384,398]),Pt=new Set([814,815,816,817,818,819,830,831,832,833]),Nt=(a,e,t)=>{const s=Pe.has(a)&&Pe.has(e)&&Pe.has(t),n=Ne.has(a)&&Ne.has(e)&&Ne.has(t),r=Oe.has(a)&&Oe.has(e)&&Oe.has(t);return s?"mouth":n||r?"eye":"base"},ht=a=>{const e=[],t=[],s=[],n=[],r=[],o=[];let c=0,i=0;a.split(`
|
|
2
|
-
`).forEach(u=>{const h=u.trim();if(!h)return;if(h.startsWith("v ")){c+=1;return}if(h.startsWith("vt ")){const[,x,g]=h.split(/\s+/);r.push([Number(x),Number(g)]);return}if(!h.startsWith("f "))return;const f=i;i+=1;const[,...m]=h.split(/\s+/),T=m.map(x=>{const[g,p]=x.split("/"),v=Number(g)-1,b=Number(p)-1;return b>=0&&r[b]&&!o[v]&&(o[v]=r[b]),v});if(!(T.length<3))for(let x=1;x<T.length-1;x+=1){const g=T[0],p=T[x],v=T[x+1],b=Nt(g,p,v);Pt.has(f)?n.push(g,p,v):b==="mouth"?t.push(g,p,v):b==="eye"?s.push(g,p,v):e.push(g,p,v)}});const l=[];for(let u=0;u<c;u+=1){const[h,f]=o[u]??[0,0];l.push(h,f)}return{baseIndices:new Uint16Array(e),mouthIndices:new Uint16Array(t),eyeIndices:new Uint16Array(s),noseIndices:new Uint16Array(n),uvs:new Float32Array(l),vertexCount:c}},Ot="canonical_face_model.obj",Dt=new TextDecoder("utf-8"),De=new Map,Bt=a=>{const e=De.get(a);if(e)return e;const t=$.fetchAndVerify(a).then(s=>ht(Dt.decode(s))).catch(s=>{throw De.delete(a),s});return De.set(a,t),t},dt=a=>{const{mesh:e,url:t}=a??{},s=t??`${$.libConfig.sdkAssetsBaseUrl}/${Ot}`,[n,r]=S.useState(e??null);return S.useEffect(()=>{if(e){r(e);return}let o=!1;return Bt(s).then(c=>{o||r(c)}).catch(c=>{o||console.error(`${$.libConfig.loggerPrefix} canonical face mesh load failed`,c)}),()=>{o=!0}},[e,s]),n},Ut={front:E.FrontSide,back:E.BackSide,double:E.DoubleSide},kt=`
|
|
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
|
-
`,Gt=`
|
|
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 useCanonicalTexture;
|
|
22
|
-
uniform float useAlphaMask;
|
|
23
|
-
uniform float alphaOpacity;
|
|
24
|
-
uniform float compositeShading;
|
|
25
|
-
uniform vec3 lightDirection;
|
|
26
|
-
uniform float ambientStrength;
|
|
27
|
-
uniform float directionalStrength;
|
|
28
|
-
varying vec2 vUv;
|
|
29
|
-
varying vec2 vFaceUv;
|
|
30
|
-
varying vec3 vNormal;
|
|
31
|
-
|
|
32
|
-
vec3 linearToSrgb(vec3 value) {
|
|
33
|
-
vec3 low = value * 12.92;
|
|
34
|
-
vec3 high = 1.055 * pow(max(value, vec3(0.0)), vec3(1.0 / 2.4)) - 0.055;
|
|
35
|
-
return mix(high, low, step(value, vec3(0.0031308)));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
vec3 srgbToLinear(vec3 value) {
|
|
39
|
-
vec3 low = value / 12.92;
|
|
40
|
-
vec3 high = pow(max((value + 0.055) / 1.055, vec3(0.0)), vec3(2.4));
|
|
41
|
-
return mix(high, low, step(value, vec3(0.04045)));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
float overlayChannel(float base, float blend) {
|
|
45
|
-
return base < 0.5 ? 2.0 * base * blend : 1.0 - 2.0 * (1.0 - base) * (1.0 - blend);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
float hardLightChannel(float base, float blend) {
|
|
49
|
-
return blend < 0.5 ? 2.0 * base * blend : 1.0 - 2.0 * (1.0 - base) * (1.0 - blend);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
float softLightChannel(float base, float blend) {
|
|
53
|
-
if (blend <= 0.5) {
|
|
54
|
-
return base - (1.0 - 2.0 * blend) * base * (1.0 - base);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
float d = base <= 0.25
|
|
58
|
-
? ((16.0 * base - 12.0) * base + 4.0) * base
|
|
59
|
-
: sqrt(base);
|
|
60
|
-
|
|
61
|
-
return base + (2.0 * blend - 1.0) * (d - base);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
vec3 applyBlendMode(vec3 base, vec3 blend, float mode) {
|
|
65
|
-
if (mode < 0.5) return blend;
|
|
66
|
-
if (mode < 1.5) return min(base + blend, 1.0);
|
|
67
|
-
if (mode < 2.5) return max(base - blend, 0.0);
|
|
68
|
-
if (mode < 3.5) return base * blend;
|
|
69
|
-
if (mode < 4.5) return 1.0 - (1.0 - base) * (1.0 - blend);
|
|
70
|
-
if (mode < 5.5) {
|
|
71
|
-
return vec3(
|
|
72
|
-
overlayChannel(base.r, blend.r),
|
|
73
|
-
overlayChannel(base.g, blend.g),
|
|
74
|
-
overlayChannel(base.b, blend.b)
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
if (mode < 6.5) {
|
|
78
|
-
return vec3(
|
|
79
|
-
softLightChannel(base.r, blend.r),
|
|
80
|
-
softLightChannel(base.g, blend.g),
|
|
81
|
-
softLightChannel(base.b, blend.b)
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
if (mode < 7.5) {
|
|
85
|
-
return vec3(
|
|
86
|
-
hardLightChannel(base.r, blend.r),
|
|
87
|
-
hardLightChannel(base.g, blend.g),
|
|
88
|
-
hardLightChannel(base.b, blend.b)
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
if (mode < 8.5) return max(base, blend);
|
|
92
|
-
if (mode < 9.5) return min(base, blend);
|
|
93
|
-
if (mode < 10.5) return abs(base - blend);
|
|
94
|
-
return base + blend - 2.0 * base * blend;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
void main() {
|
|
98
|
-
vec3 base = linearToSrgb(texture2D(cameraTexture, vFaceUv).rgb);
|
|
99
|
-
vec4 textureSample = texture2D(canonicalTexture, vUv);
|
|
100
|
-
vec3 blend = linearToSrgb(textureSample.rgb) * textureTint;
|
|
101
|
-
float light = ambientStrength + max(dot(normalize(vNormal), normalize(lightDirection)), 0.0) * directionalStrength;
|
|
102
|
-
blend *= mix(1.0, clamp(light, 0.35, 1.35), compositeShading);
|
|
103
|
-
float maskSample = texture2D(alphaMask, vUv).r;
|
|
104
|
-
float mask = useAlphaMask > 0.5 ? mix(1.0, maskSample, alphaOpacity) : 1.0;
|
|
105
|
-
float textureAlpha = useCanonicalTexture > 0.5 ? textureSample.a : 1.0;
|
|
106
|
-
vec3 color = useCanonicalTexture > 0.5 ? applyBlendMode(base, blend, blendMode) : base;
|
|
107
|
-
gl_FragColor = vec4(srgbToLinear(color), opacity * mask * textureAlpha);
|
|
108
|
-
}
|
|
109
|
-
`,Ht=`
|
|
110
|
-
varying vec2 vUv;
|
|
111
|
-
varying vec3 vNormal;
|
|
112
|
-
|
|
113
|
-
void main() {
|
|
114
|
-
vUv = uv;
|
|
115
|
-
vNormal = normalize(normalMatrix * normal);
|
|
116
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
117
|
-
}
|
|
118
|
-
`,jt=`
|
|
119
|
-
uniform vec3 color;
|
|
120
|
-
uniform float opacity;
|
|
121
|
-
varying vec3 vNormal;
|
|
122
|
-
|
|
123
|
-
void main() {
|
|
124
|
-
vec3 normalTint = 0.5 + 0.5 * normalize(vNormal);
|
|
125
|
-
vec3 base = color * mix(vec3(1.0), normalTint, 0.35);
|
|
126
|
-
|
|
127
|
-
gl_FragColor = vec4(base, opacity);
|
|
128
|
-
}
|
|
129
|
-
`,Xt=()=>{const a=new Uint8Array([32,32,32,255,96,96,96,255,176,176,176,255,255,255,255,255]),e=new E.DataTexture(a,4,1,E.RGBAFormat);return e.minFilter=E.NearestFilter,e.magFilter=E.NearestFilter,e.generateMipmaps=!1,e.needsUpdate=!0,e},Kt=()=>{const a=document.createElement("canvas");a.width=256,a.height=256;const e=a.getContext("2d");if(!e)return new E.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 E.CanvasTexture(a);return s.needsUpdate=!0,s},Yt=({faceIndex:a=0,color:e="#38bdf8",opacity:t=.45,materialType:s="basic",shaderPreset:n="basicShader",textureMap:r="none",alphaMap:o="none",alphaOpacity:c=0,side:i="front",blendMode:l="normal",showMouthMask:u=!0,showEyeMask:h=!0,showNoseMask:f=!0,maskTextureSource:m="none",maskColor:T="#111111",maskOpacity:x=0,faceTextureUrl:g="",faceTextureStyle2Url:p="",faceAlphaMaskUrl:v="",compositeShading:b=!1,mesh:M,meshUrl:y})=>{const C=je.useXRModelNode($.XRModel.FACE_TRACKER),L=je.useXRCameraTexture(),{camera:D}=re.useThree(),w=dt({mesh:M,url:y}),P=re.useLoader(E.TextureLoader,g||"/placeholder.png"),J=re.useLoader(E.TextureLoader,p||g||"/placeholder.png"),I=re.useLoader(E.TextureLoader,v||"/placeholder.png"),K=S.useMemo(()=>Xt(),[]),_=S.useMemo(()=>Kt(),[]),ee=S.useRef(null),Y=S.useRef(null),V=S.useRef(null),ae=S.useRef(null),ie=S.useRef(null),ce=S.useRef(null),le=S.useRef(null),te=S.useRef(null),ne=S.useRef(null),ue=S.useRef(null),he=S.useRef(null),me=S.useRef(null),Lt=S.useRef(new E.Vector3),ge=S.useRef(!1),Z=Ut[i],se={side:Z,transparent:!0,opacity:t,wireframe:!1},Se=r==="style2"?J:P,de=r!=="none",Ae=S.useMemo(()=>({color:{value:new E.Color(e)},opacity:{value:t}}),[]),N=S.useMemo(()=>({cameraTexture:{value:null},canonicalTexture:{value:null},alphaMask:{value:null},textureTint:{value:new E.Color(e)},opacity:{value:t},blendMode:{value:Ke[l]},useCanonicalTexture:{value:de?1:0},useAlphaMask:{value:o==="canonical"?1:0},alphaOpacity:{value:c},compositeShading:{value:b?1:0},lightDirection:{value:new E.Vector3(.3,.65,.7).normalize()},ambientStrength:{value:.78},directionalStrength:{value:.38}}),[]);S.useEffect(()=>{Ae.color.value.set(e),Ae.opacity.value=t},[e,t,Ae]),S.useEffect(()=>{N.cameraTexture.value=L??P,N.canonicalTexture.value=Se,N.alphaMask.value=I,N.textureTint.value.set(e),N.opacity.value=t,N.blendMode.value=Ke[l],N.useCanonicalTexture.value=de?1:0,N.useAlphaMask.value=o==="canonical"?1:0,N.alphaOpacity.value=c,N.compositeShading.value=b?1:0},[o,I,c,l,L,e,b,N,P,de,t,Se,r]);const Te=F=>{if(F)return m==="canonical"?A.jsx("meshBasicMaterial",{color:T,alphaMap:I,transparent:!0,opacity:x,side:Z,depthWrite:!1,depthTest:!1,toneMapped:!1},"masked-canonical-material"):A.jsx("meshBasicMaterial",{color:T,transparent:!0,opacity:x,side:Z,depthWrite:!1,depthTest:!1,toneMapped:!1},"masked-solid-material");if(s==="wireframe")return A.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:t,side:Z,depthWrite:!1,depthTest:!1,wireframe:!0,toneMapped:!1},"wireframe-material");if(s==="shader"&&L&&(n==="originalFace"||n==="composite"&&r==="none"))return A.jsx("meshBasicMaterial",{map:L,alphaMap:I,transparent:!0,opacity:t,side:Z,depthWrite:!1,depthTest:!0,toneMapped:!1},"use-original-face-material");if(s==="shader"&&n==="composite"&&de&&L)return A.jsx("shaderMaterial",{uniforms:N,vertexShader:kt,fragmentShader:Gt,transparent:!0,side:Z,depthWrite:!1,depthTest:!0,toneMapped:!1},"composite-material");const B=de?Se:null,U=o==="canonical"&&c>0?I:null,k=`${s}-${r}-${o}-${c>0?"alpha-on":"alpha-off"}`;return s==="standard"?A.jsx("meshStandardMaterial",{...se,color:e,map:B??void 0,alphaMap:U??void 0,depthWrite:!0,depthTest:!0,metalness:.05,roughness:.72},k):s==="physical"?A.jsx("meshPhysicalMaterial",{...se,color:e,map:B??void 0,alphaMap:U??void 0,depthWrite:!0,depthTest:!0,roughness:.58,metalness:.08,clearcoat:.35,clearcoatRoughness:.4},k):s==="toon"?A.jsx("meshToonMaterial",{...se,color:e,map:B??void 0,alphaMap:U??void 0,gradientMap:K,depthWrite:!0,depthTest:!0},k):s==="normal"?A.jsx("meshNormalMaterial",{...se,depthWrite:!0,depthTest:!0,flatShading:!1},"normal-material"):s==="matcap"?A.jsx("meshMatcapMaterial",{...se,color:e,matcap:_,depthWrite:!0,depthTest:!0},"matcap-material"):s==="shader"?A.jsx("shaderMaterial",{uniforms:Ae,vertexShader:Ht,fragmentShader:jt,transparent:!0,side:Z,depthWrite:!1,depthTest:!0,toneMapped:!1},"generic-shader-material"):A.jsx("meshBasicMaterial",{...se,color:e,map:B??void 0,alphaMap:U??void 0,depthWrite:!1,depthTest:r!=="none"||o!=="none",toneMapped:!1},k)},Ct=F=>Xe.projectLandmarkWithDepth(F,D,Lt.current);return re.useFrame(()=>{var et,tt;const F=ee.current,B=Y.current,U=V.current,k=ae.current,we=ie.current,_e=ce.current,ye=le.current,Le=te.current,xe=(tt=(et=C==null?void 0:C.detectionResults)==null?void 0:et.faceLandmarks)==null?void 0:tt[a];if(!w||!F||!B||!U||!k||!we||!_e||!ye||!Le)return;if(!xe||xe.length<w.vertexCount){we.visible=!1,_e.visible=!1,ye.visible=!1,Le.visible=!1;return}if(me.current!==w){ne.current=new Float32Array(w.vertexCount*3),ue.current=new Float32Array(w.uvs),he.current=new Float32Array(w.vertexCount*2);const H=new E.BufferAttribute(ne.current,3),G=new E.BufferAttribute(ue.current,2),W=new E.BufferAttribute(he.current,2);F.setAttribute("position",H),F.setAttribute("uv",G),F.setAttribute("faceUv",W),F.setIndex(new E.BufferAttribute(w.baseIndices,1)),B.setAttribute("position",H),B.setAttribute("uv",G),B.setAttribute("faceUv",W),B.setIndex(new E.BufferAttribute(w.mouthIndices,1)),U.setAttribute("position",H),U.setAttribute("uv",G),U.setAttribute("faceUv",W),U.setIndex(new E.BufferAttribute(w.eyeIndices,1)),k.setAttribute("position",H),k.setAttribute("uv",G),k.setAttribute("faceUv",W),k.setIndex(new E.BufferAttribute(w.noseIndices,1)),G.needsUpdate=!0,me.current=w,ge.current=!1}const ve=ne.current,Ce=he.current,be=ue.current;if(!ve||!Ce||!be)return;const Je=s==="shader"&&(n==="originalFace"||n==="composite"&&r==="none"),It=Math.min(xe.length,w.vertexCount);for(let H=0;H<It;H++){const G=xe[H],W=H*3,Me=H*2,Ie=Ct(G);ve[W]=Ie.x,ve[W+1]=Ie.y,ve[W+2]=Ie.z,Ce[Me]=G.x,Ce[Me+1]=1-G.y,Je&&(be[Me]=G.x,be[Me+1]=1-G.y)}Je?(F.attributes.uv.needsUpdate=!0,ge.current=!0):ge.current&&(be.set(w.uvs),F.attributes.uv.needsUpdate=!0,ge.current=!1),we.visible=!0,_e.visible=!0,ye.visible=!0,Le.visible=!0,F.attributes.position.needsUpdate=!0,F.attributes.faceUv.needsUpdate=!0,F.computeVertexNormals(),B.computeVertexNormals(),U.computeVertexNormals(),k.computeVertexNormals()}),A.jsxs(A.Fragment,{children:[A.jsxs("mesh",{ref:ie,renderOrder:10,frustumCulled:!1,children:[A.jsx("bufferGeometry",{ref:ee}),Te(!1)]}),A.jsxs("mesh",{ref:ce,renderOrder:12,frustumCulled:!1,children:[A.jsx("bufferGeometry",{ref:Y}),Te(u)]}),A.jsxs("mesh",{ref:le,renderOrder:12,frustumCulled:!1,children:[A.jsx("bufferGeometry",{ref:V}),Te(h)]}),A.jsxs("mesh",{ref:te,renderOrder:12,frustumCulled:!1,children:[A.jsx("bufferGeometry",{ref:ae}),Te(f)]})]})},Vt={materialType:"basic",shaderPreset:"basicShader",textureMap:"none",alphaMap:"none",alphaOpacity:1,side:"front",blendMode:"normal",baseColor:"#38bdf8",opacity:.45},Wt={mouth:!0,eyes:!0,nose:!0},zt=[{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"}],qt=[{label:"Basic Shader",value:"basicShader"},{label:"Original Face",value:"originalFace"},{label:"Composite",value:"composite"}],Zt=[{label:"Front",value:"front"},{label:"Back",value:"back"},{label:"Double",value:"double"}],Qt=[{label:"None",value:"none"},{label:"UV Map 1",value:"canonical"},{label:"UV Map 2",value:"style2"}],$t=[{label:"None",value:"none"},{label:"Default Mask",value:"canonical"}],Jt=[{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"}],en=(a,e)=>a==="basic"||a==="standard"||a==="physical"||a==="toon"||a==="shader"&&e==="composite",tn=(a,e)=>a==="shader"&&e==="composite",nn=`
|
|
130
|
-
varying vec2 vUv;
|
|
131
|
-
|
|
132
|
-
void main() {
|
|
133
|
-
vUv = uv;
|
|
134
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
135
|
-
}
|
|
136
|
-
`,sn=`
|
|
137
|
-
uniform sampler2D cameraTexture;
|
|
138
|
-
uniform sampler2D retouchMaskTexture;
|
|
139
|
-
uniform sampler2D mouthMaskTexture;
|
|
140
|
-
uniform vec2 texelSize;
|
|
141
|
-
uniform float retouchAmount;
|
|
142
|
-
uniform float blurRadius;
|
|
143
|
-
uniform float teethWhitening;
|
|
144
|
-
uniform float previewMask;
|
|
145
|
-
uniform float protectLandmarks;
|
|
146
|
-
varying vec2 vUv;
|
|
147
|
-
|
|
148
|
-
vec3 sampleCamera(vec2 uv) {
|
|
149
|
-
return texture2D(cameraTexture, clamp(uv, vec2(0.0), vec2(1.0))).rgb;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
vec3 readRetouchMask(vec2 uv) {
|
|
153
|
-
vec4 mask = texture2D(retouchMaskTexture, uv);
|
|
154
|
-
float faceRegion = clamp(mask.b, 0.0, 1.0);
|
|
155
|
-
float softFaceRegion = min(mask.r, faceRegion);
|
|
156
|
-
float protectedRegion = min(mask.g, faceRegion) * protectLandmarks;
|
|
157
|
-
float hardProtectedRegion = step(0.08, protectedRegion);
|
|
158
|
-
float softRetouchRegion = softFaceRegion * (1.0 - protectedRegion);
|
|
159
|
-
float hardRetouchRegion = step(0.5, faceRegion) * (1.0 - hardProtectedRegion);
|
|
160
|
-
|
|
161
|
-
return vec3(
|
|
162
|
-
clamp(softRetouchRegion, 0.0, 1.0),
|
|
163
|
-
clamp(protectedRegion, 0.0, 1.0),
|
|
164
|
-
clamp(hardRetouchRegion, 0.0, 1.0)
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
float readMouthMask(vec2 uv) {
|
|
169
|
-
return clamp(texture2D(mouthMaskTexture, uv).r, 0.0, 1.0);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
float retouchCoverage(vec2 uv) {
|
|
173
|
-
return step(0.001, readRetouchMask(uv).x);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
void addMaskedBlurSample(inout vec3 color, inout float weightSum, vec2 centerUv, vec2 sampleUv, float weight) {
|
|
177
|
-
float coverage = retouchCoverage(sampleUv);
|
|
178
|
-
vec3 sampleColor = mix(sampleCamera(centerUv), sampleCamera(sampleUv), coverage);
|
|
179
|
-
color += sampleColor * weight;
|
|
180
|
-
weightSum += weight;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
vec3 maskedBlurCamera(vec2 uv, float radius) {
|
|
184
|
-
vec2 r = texelSize * radius;
|
|
185
|
-
vec3 color = sampleCamera(uv) * 0.2;
|
|
186
|
-
float weightSum = 0.2;
|
|
187
|
-
|
|
188
|
-
addMaskedBlurSample(color, weightSum, uv, uv + vec2(r.x, 0.0), 0.1);
|
|
189
|
-
addMaskedBlurSample(color, weightSum, uv, uv - vec2(r.x, 0.0), 0.1);
|
|
190
|
-
addMaskedBlurSample(color, weightSum, uv, uv + vec2(0.0, r.y), 0.1);
|
|
191
|
-
addMaskedBlurSample(color, weightSum, uv, uv - vec2(0.0, r.y), 0.1);
|
|
192
|
-
addMaskedBlurSample(color, weightSum, uv, uv + r, 0.075);
|
|
193
|
-
addMaskedBlurSample(color, weightSum, uv, uv - r, 0.075);
|
|
194
|
-
addMaskedBlurSample(color, weightSum, uv, uv + vec2(r.x, -r.y), 0.075);
|
|
195
|
-
addMaskedBlurSample(color, weightSum, uv, uv + vec2(-r.x, r.y), 0.075);
|
|
196
|
-
addMaskedBlurSample(color, weightSum, uv, uv + r * 2.0, 0.05);
|
|
197
|
-
addMaskedBlurSample(color, weightSum, uv, uv - r * 2.0, 0.05);
|
|
198
|
-
|
|
199
|
-
return color / max(weightSum, 0.001);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
vec3 whitenTeeth(vec3 color, float amount, float mouthRegion) {
|
|
203
|
-
float maxChannel = max(max(color.r, color.g), color.b);
|
|
204
|
-
float minChannel = min(min(color.r, color.g), color.b);
|
|
205
|
-
float saturation = maxChannel - minChannel;
|
|
206
|
-
float brightness = dot(color, vec3(0.299, 0.587, 0.114));
|
|
207
|
-
float redness = max(color.r - max(color.g, color.b), 0.0);
|
|
208
|
-
float greenBlueBalance = 1.0 - smoothstep(0.08, 0.24, abs(color.g - color.b));
|
|
209
|
-
float candidate =
|
|
210
|
-
smoothstep(0.34, 0.62, brightness) *
|
|
211
|
-
(1.0 - smoothstep(0.14, 0.32, redness)) *
|
|
212
|
-
(1.0 - smoothstep(0.18, 0.42, saturation)) *
|
|
213
|
-
greenBlueBalance;
|
|
214
|
-
float whiteningMask = clamp(mouthRegion * candidate, 0.0, 1.0);
|
|
215
|
-
vec3 desaturated = mix(color, vec3(brightness), 0.42);
|
|
216
|
-
vec3 brightened = min(desaturated + vec3(0.16), vec3(1.0));
|
|
217
|
-
|
|
218
|
-
return mix(color, brightened, clamp(amount * whiteningMask * 0.38, 0.0, 1.0));
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
void main() {
|
|
222
|
-
vec3 original = sampleCamera(vUv);
|
|
223
|
-
vec3 masks = readRetouchMask(vUv);
|
|
224
|
-
float mouthMask = readMouthMask(vUv);
|
|
225
|
-
|
|
226
|
-
if (previewMask > 0.5) {
|
|
227
|
-
float sharpPreview = 1.0 - step(0.001, retouchAmount + blurRadius);
|
|
228
|
-
float retouchPreview = mix(masks.x, masks.z, sharpPreview);
|
|
229
|
-
float protectedPreview = mix(masks.y, step(0.08, masks.y), sharpPreview);
|
|
230
|
-
float whiteningPreview = mouthMask * teethWhitening;
|
|
231
|
-
vec3 facePreview = vec3(retouchPreview, 0.08, 0.08);
|
|
232
|
-
vec3 featurePreview = vec3(0.05, protectedPreview, 0.1);
|
|
233
|
-
vec3 whiteningMaskPreview = vec3(whiteningPreview, whiteningPreview, 0.05);
|
|
234
|
-
vec3 maskPreview = max(max(facePreview, featurePreview), whiteningMaskPreview);
|
|
235
|
-
vec3 debugColor = mix(original * 0.18, maskPreview, max(max(retouchPreview, protectedPreview), whiteningPreview));
|
|
236
|
-
gl_FragColor = vec4(debugColor, 1.0);
|
|
237
|
-
#include <colorspace_fragment>
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
float effectiveBlurRadius = min(blurRadius, 7.0);
|
|
242
|
-
vec3 smallBlur = maskedBlurCamera(vUv, max(0.0, effectiveBlurRadius * 0.45));
|
|
243
|
-
vec3 largeBlur = maskedBlurCamera(vUv, max(0.0, effectiveBlurRadius));
|
|
244
|
-
vec3 detail = original - smallBlur;
|
|
245
|
-
float detailAmount = mix(0.5, 0.9, masks.y);
|
|
246
|
-
vec3 smoothed = clamp(largeBlur + detail * detailAmount, 0.0, 1.0);
|
|
247
|
-
vec3 color = mix(original, smoothed, min(retouchAmount, 0.72) * masks.x);
|
|
248
|
-
color = whitenTeeth(color, teethWhitening, mouthMask);
|
|
249
|
-
gl_FragColor = vec4(color, 1.0);
|
|
250
|
-
#include <colorspace_fragment>
|
|
251
|
-
}
|
|
252
|
-
`,rn=({retouchMask:a,mouthMask:e,retouchAmount:t,blurRadius:s,teethWhitening:n,previewMask:r,protectLandmarks:o})=>{const{camera:c,size:i}=re.useThree(),l=je.useXRCameraTexture(),u=S.useMemo(()=>({cameraTexture:{value:null},retouchMaskTexture:{value:a},mouthMaskTexture:{value:e},texelSize:{value:new E.Vector2(1/1280,1/720)},retouchAmount:{value:t},blurRadius:{value:s},teethWhitening:{value:n},previewMask:{value:0},protectLandmarks:{value:1}}),[e,a]),h=S.useMemo(()=>{if(!(c instanceof E.PerspectiveCamera))return[10,10];const T=(c.position.z||5)- -1,x=E.MathUtils.degToRad(c.fov),g=2*Math.tan(x/2)*T;return[g*(i.width/i.height),g]},[c,i]);return S.useEffect(()=>{u.cameraTexture.value=l??null,u.retouchMaskTexture.value=a,u.mouthMaskTexture.value=e,u.texelSize.value.set(1/Math.max(i.width,1),1/Math.max(i.height,1)),u.retouchAmount.value=t,u.blurRadius.value=s,u.teethWhitening.value=n,u.previewMask.value=r?1:0,u.protectLandmarks.value=o?1:0},[s,l,r,o,t,e,a,n,i.height,i.width,u]),l?A.jsx("group",{position:[0,0,-1],children:A.jsxs("mesh",{renderOrder:-1e3,children:[A.jsx("planeGeometry",{args:h}),A.jsx("shaderMaterial",{uniforms:u,vertexShader:nn,fragmentShader:sn,depthTest:!1,depthWrite:!1,toneMapped:!1})]})}):null},Ee=512,We=[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],ft=[33,246,161,160,159,158,157,173,133,155,154,153,145,144,163,7],pt=[362,398,384,385,386,387,388,466,263,249,390,373,374,380,381,382],mt=[61,146,91,181,84,17,314,405,321,375,291,409,270,269,267,0,37,39,40,185],ze=[78,95,88,178,87,14,317,402,318,324,308,415,310,311,312,13,82,81,80,191],gt=[70,63,105,66,107,55,65,52,53,46],At=[336,296,334,293,300,276,283,282,295,285],on=[ft,pt,mt,ze,gt,At],nt=(a,e,t)=>{qe(a,e,We,t)},an=(a,e,t)=>{on.forEach(s=>qe(a,e,s,t))},st=(a,e,t)=>{const s=a[e];return s?{x:s.x*t,y:s.y*t}:null},qe=(a,e,t,s)=>{const n=st(e,t[0],s);if(n){a.beginPath(),a.moveTo(n.x,n.y);for(let r=1;r<t.length;r+=1){const o=st(e,t[r],s);o&&a.lineTo(o.x,o.y)}a.closePath(),a.fill()}},Tt=(a,e,t=Ee)=>{a.clearRect(0,0,t,t),e!=null&&e.length&&(a.save(),a.globalCompositeOperation="lighter",a.fillStyle="rgb(0, 0, 255)",nt(a,e,t),a.restore(),a.save(),a.globalCompositeOperation="lighter",a.filter="blur(8px)",a.fillStyle="rgb(255, 0, 0)",nt(a,e,t),a.restore(),a.save(),a.globalCompositeOperation="lighter",a.filter="blur(3px)",a.fillStyle="rgb(0, 255, 0)",an(a,e,t),a.restore())},xt=(a,e,t=Ee)=>{a.clearRect(0,0,t,t),e!=null&&e.length&&(a.save(),a.filter="blur(2px)",a.fillStyle="rgb(255, 255, 255)",qe(a,e,ze,t),a.restore())},cn=.1,ln=.48,un=.012,hn=1,dn=1.1,fn=1.15,pn=.04,mn=[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],gn=[33,7,163,144,145,153,154,155,133,173,157,158,159,160,161,246],An=[362,382,381,380,374,373,390,249,263,466,388,387,386,385,384,398],Tn=[70,63,105,66,107,55,65,52,53,46],xn=[336,296,334,293,300,285,295,282,283,276],vn=[1,2,4,5,6,19,94,97,98,99,102,129,168,195,197,240,279,326,327,328,331,344,358,440],vt=[mn,gn,An,Tn,xn,vn],bt=[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],Re=a=>Math.min(Math.max(a,0),1),rt=(a,e,t,s,n,r)=>{let o=1,c=1,i=0,l=0,u=0;if(e.forEach(b=>{const M=a[b];M&&(o=Math.min(o,M.x),c=Math.min(c,M.y),i=Math.max(i,M.x),l=Math.max(l,M.y),u+=1)}),u===0)return null;const h=i-o,f=l-c,m=Math.max(h*t,r),T=Math.max(f*t,r),x=Re(o-m),g=Re(c-T),p=Re(i+m),v=Re(l+T);return{centerX:(x+p)*.5,centerY:(g+v)*.5,radiusX:Math.max((p-x)*.5,r),radiusY:Math.max((v-g)*.5,r),strength:s,kind:n}},bn=(a,e,t)=>a?{centerX:a.x,centerY:a.y,radiusX:e,radiusY:e,strength:t,kind:"feature"}:null,Mt=(a,e)=>{if(!(a!=null&&a.length))return[];const t=(e==null?void 0:e.faceOvalIndices)??We,s=(e==null?void 0:e.featureGroups)??vt,n=(e==null?void 0:e.featurePointIndices)??bt,r=(e==null?void 0:e.faceBoundsExpansion)??cn,o=(e==null?void 0:e.featureBoundsExpansion)??ln,c=(e==null?void 0:e.minRegionRadius)??un,i=(e==null?void 0:e.faceRegionStrength)??hn,l=(e==null?void 0:e.featureRegionStrength)??dn,u=(e==null?void 0:e.featurePointRegionStrength)??fn,h=(e==null?void 0:e.featurePointRadiusRatio)??pn,f=[],m=rt(a,t,r,i,"face",c);m&&f.push(m);const T=Math.max(Math.max((m==null?void 0:m.radiusX)??0,(m==null?void 0:m.radiusY)??0)*h,c*1.35);return s.forEach(x=>{const g=rt(a,x,o,l,"feature",c);g&&f.push(g)}),n.forEach(x=>{const g=bn(a[x],T,u);g&&f.push(g)}),f},ot=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 E.CanvasTexture(e);return s.colorSpace=E.NoColorSpace,s.minFilter=E.LinearFilter,s.magFilter=E.LinearFilter,s.generateMipmaps=!1,s.needsUpdate=!0,{canvas:e,context:t,texture:s}},Mn=(a,e=Ee)=>{const{mask:t,mouthMask:s}=S.useMemo(()=>({mask:ot(e),mouthMask:ot(e)}),[e]);return S.useEffect(()=>{let n=0;const r=()=>{var c,i;n=requestAnimationFrame(r);const o=(i=(c=a==null?void 0:a.detectionResults)==null?void 0:c.faceLandmarks)==null?void 0:i[0];Tt(t.context,o,e),xt(s.context,o,e),t.texture.needsUpdate=!0,s.texture.needsUpdate=!0};return r(),()=>{cancelAnimationFrame(n)}},[a,t.context,t.texture,s.context,s.texture,e]),{canvas:t.canvas,texture:t.texture,mouthTexture:s.texture}},Rn=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("|"),En=(a,e)=>{const[t,s]=S.useState([]);return S.useEffect(()=>{let n=0,r="";const o=()=>{var u,h;n=requestAnimationFrame(o);const c=(h=(u=a==null?void 0:a.detectionResults)==null?void 0:u.faceLandmarks)==null?void 0:h[0],i=Mt(c,e),l=Rn(i);l!==r&&(r=l,s(i))};return o(),()=>{cancelAnimationFrame(n)}},[a]),t};function at(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 o=[],c=a.getAttribute("position");if(c!==void 0){for(let i=0;i<c.count;i++)o.push(i);a.setIndex(o),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 o=1;o<=s;o++)n.push(t.getX(0)),n.push(t.getX(o)),n.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(n.push(t.getX(o)),n.push(t.getX(o+1)),n.push(t.getX(o+2))):(n.push(t.getX(o+2)),n.push(t.getX(o+1)),n.push(t.getX(o)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=a.clone();return r.setIndex(n),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),a}class Sn extends d.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Cn(t)}),this.register(function(t){return new In(t)}),this.register(function(t){return new Gn(t)}),this.register(function(t){return new Hn(t)}),this.register(function(t){return new jn(t)}),this.register(function(t){return new Pn(t)}),this.register(function(t){return new Nn(t)}),this.register(function(t){return new On(t)}),this.register(function(t){return new Dn(t)}),this.register(function(t){return new Ln(t)}),this.register(function(t){return new Bn(t)}),this.register(function(t){return new Fn(t)}),this.register(function(t){return new kn(t)}),this.register(function(t){return new Un(t)}),this.register(function(t){return new _n(t)}),this.register(function(t){return new Xn(t)}),this.register(function(t){return new Kn(t)})}load(e,t,s,n){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const l=d.LoaderUtils.extractUrlBase(e);o=d.LoaderUtils.resolveURL(l,this.path)}else o=d.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const c=function(l){n?n(l):console.error(l),r.manager.itemError(e),r.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{r.parse(l,o,function(u){t(u),r.manager.itemEnd(e)},c)}catch(u){c(u)}},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 r;const o={},c={},i=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(i.decode(new Uint8Array(e,0,4))===Rt){try{o[R.KHR_BINARY_GLTF]=new Yn(e)}catch(h){n&&n(h);return}r=JSON.parse(o[R.KHR_BINARY_GLTF].content)}else r=JSON.parse(i.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new rs(r,{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 u=0;u<this.pluginCallbacks.length;u++){const h=this.pluginCallbacks[u](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[h.name]=h,o[h.name]=!0}if(r.extensionsUsed)for(let u=0;u<r.extensionsUsed.length;++u){const h=r.extensionsUsed[u],f=r.extensionsRequired||[];switch(h){case R.KHR_MATERIALS_UNLIT:o[h]=new yn;break;case R.KHR_DRACO_MESH_COMPRESSION:o[h]=new Vn(r,this.dracoLoader);break;case R.KHR_TEXTURE_TRANSFORM:o[h]=new Wn;break;case R.KHR_MESH_QUANTIZATION:o[h]=new zn;break;default:f.indexOf(h)>=0&&c[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(o),l.setPlugins(c),l.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,r){s.parse(e,t,n,r)})}}function wn(){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 _n{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 r=t[s];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const r=t.json,i=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let l;const u=new d.Color(16777215);i.color!==void 0&&u.setRGB(i.color[0],i.color[1],i.color[2],d.LinearSRGBColorSpace);const h=i.range!==void 0?i.range:0;switch(i.type){case"directional":l=new d.DirectionalLight(u),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new d.PointLight(u),l.distance=h;break;case"spot":l=new d.SpotLight(u),l.distance=h,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),j(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,r=s.json.nodes[e],c=(r.extensions&&r.extensions[this.name]||{}).light;return c===void 0?null:this._loadLight(c).then(function(i){return s._getNodeRef(t.cache,c,i)})}}class yn{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 r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],d.LinearSRGBColorSpace),e.opacity=o[3]}r.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",r.baseColorTexture,d.SRGBColorSpace))}return Promise.all(n)}}class Ln{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 r=n.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class Cn{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 r=[],o=n.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&r.push(s.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&r.push(s.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(r.push(s.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const c=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new d.Vector2(c,c)}return Promise.all(r)}}class In{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 r=n.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class Fn{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 r=[],o=n.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&r.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&r.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}}class Pn{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 r=[];t.sheenColor=new d.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];if(o.sheenColorFactor!==void 0){const c=o.sheenColorFactor;t.sheenColor.setRGB(c[0],c[1],c[2],d.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(s.assignTexture(t,"sheenColorMap",o.sheenColorTexture,d.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&r.push(s.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}}class Nn{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 r=[],o=n.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&r.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}}class On{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 r=[],o=n.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&r.push(s.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const c=o.attenuationColor||[1,1,1];return t.attenuationColor=new d.Color().setRGB(c[0],c[1],c[2],d.LinearSRGBColorSpace),Promise.all(r)}}class Dn{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 r=n.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class Bn{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 r=[],o=n.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&r.push(s.assignTexture(t,"specularIntensityMap",o.specularTexture));const c=o.specularColorFactor||[1,1,1];return t.specularColor=new d.Color().setRGB(c[0],c[1],c[2],d.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&r.push(s.assignTexture(t,"specularColorMap",o.specularColorTexture,d.SRGBColorSpace)),Promise.all(r)}}class Un{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 r=[],o=n.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&r.push(s.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(r)}}class kn{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 r=[],o=n.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&r.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}}class Gn{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 r=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){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,r.source,o)}}class Hn{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,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],c=n.images[o.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,o.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 jn{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,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],c=n.images[o.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,o.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 Xn{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],r=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.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 r.then(function(c){const i=n.byteOffset||0,l=n.byteLength||0,u=n.count,h=n.byteStride,f=new Uint8Array(c,i,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,h,f,n.mode,n.filter).then(function(m){return m.buffer}):o.ready.then(function(){const m=new ArrayBuffer(u*h);return o.decodeGltfBuffer(new Uint8Array(m),u,h,f,n.mode,n.filter),m})})}else return null}}class Kn{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!==O.TRIANGLES&&l.mode!==O.TRIANGLE_STRIP&&l.mode!==O.TRIANGLE_FAN&&l.mode!==void 0)return null;const o=s.extensions[this.name].attributes,c=[],i={};for(const l in o)c.push(this.parser.getDependency("accessor",o[l]).then(u=>(i[l]=u,i[l])));return c.length<1?null:(c.push(this.parser.createNodeMesh(e)),Promise.all(c).then(l=>{const u=l.pop(),h=u.isGroup?u.children:[u],f=l[0].count,m=[];for(const T of h){const x=new d.Matrix4,g=new d.Vector3,p=new d.Quaternion,v=new d.Vector3(1,1,1),b=new d.InstancedMesh(T.geometry,T.material,f);for(let M=0;M<f;M++)i.TRANSLATION&&g.fromBufferAttribute(i.TRANSLATION,M),i.ROTATION&&p.fromBufferAttribute(i.ROTATION,M),i.SCALE&&v.fromBufferAttribute(i.SCALE,M),b.setMatrixAt(M,x.compose(g,p,v));for(const M in i)if(M==="_COLOR_0"){const y=i[M];b.instanceColor=new d.InstancedBufferAttribute(y.array,y.itemSize,y.normalized)}else M!=="TRANSLATION"&&M!=="ROTATION"&&M!=="SCALE"&&T.geometry.setAttribute(M,i[M]);d.Object3D.prototype.copy.call(b,T),this.parser.assignFinalMaterial(b),m.push(b)}return u.isGroup?(u.clear(),u.add(...m),u):m[0]}))}}const Rt="glTF",fe=12,it={JSON:1313821514,BIN:5130562};class Yn{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!==Rt)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,r=new DataView(e,fe);let o=0;for(;o<n;){const c=r.getUint32(o,!0);o+=4;const i=r.getUint32(o,!0);if(o+=4,i===it.JSON){const l=new Uint8Array(e,fe+o,c);this.content=s.decode(l)}else if(i===it.BIN){const l=fe+o;this.body=e.slice(l,l+c)}o+=c}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Vn{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,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,c={},i={},l={};for(const u in o){const h=Ye[u]||u.toLowerCase();c[h]=o[u]}for(const u in e.attributes){const h=Ye[u]||u.toLowerCase();if(o[u]!==void 0){const f=s.accessors[e.attributes[u]],m=oe[f.componentType];l[h]=m.name,i[h]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(u){return new Promise(function(h,f){n.decodeDracoFile(u,function(m){for(const T in m.attributes){const x=m.attributes[T],g=i[T];g!==void 0&&(x.normalized=g)}h(m)},c,l,d.LinearSRGBColorSpace,f)})})}}class Wn{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 zn{constructor(){this.name=R.KHR_MESH_QUANTIZATION}}class Et 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,r=e*n*3+n;for(let o=0;o!==n;o++)t[o]=s[r+o];return t}interpolate_(e,t,s,n){const r=this.resultBuffer,o=this.sampleValues,c=this.valueSize,i=c*2,l=c*3,u=n-t,h=(s-t)/u,f=h*h,m=f*h,T=e*l,x=T-l,g=-2*m+3*f,p=m-f,v=1-g,b=p-f+h;for(let M=0;M!==c;M++){const y=o[x+M+c],C=o[x+M+i]*u,L=o[T+M+c],D=o[T+M]*u;r[M]=v*y+b*C+g*L+p*D}return r}}const qn=new d.Quaternion;class Zn extends Et{interpolate_(e,t,s,n){const r=super.interpolate_(e,t,s,n);return qn.fromArray(r).normalize().toArray(r),r}}const O={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},ct={9728:d.NearestFilter,9729:d.LinearFilter,9984:d.NearestMipmapNearestFilter,9985:d.LinearMipmapNearestFilter,9986:d.NearestMipmapLinearFilter,9987:d.LinearMipmapLinearFilter},lt={33071:d.ClampToEdgeWrapping,33648:d.MirroredRepeatWrapping,10497:d.RepeatWrapping},Be={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ye={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"},Qn={CUBICSPLINE:void 0,LINEAR:d.InterpolateLinear,STEP:d.InterpolateDiscrete},Ue={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function $n(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 Q(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 j(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 Jn(a,e,t){let s=!1,n=!1,r=!1;for(let l=0,u=e.length;l<u;l++){const h=e[l];if(h.POSITION!==void 0&&(s=!0),h.NORMAL!==void 0&&(n=!0),h.COLOR_0!==void 0&&(r=!0),s&&n&&r)break}if(!s&&!n&&!r)return Promise.resolve(a);const o=[],c=[],i=[];for(let l=0,u=e.length;l<u;l++){const h=e[l];if(s){const f=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):a.attributes.position;o.push(f)}if(n){const f=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):a.attributes.normal;c.push(f)}if(r){const f=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):a.attributes.color;i.push(f)}}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(i)]).then(function(l){const u=l[0],h=l[1],f=l[2];return s&&(a.morphAttributes.position=u),n&&(a.morphAttributes.normal=h),r&&(a.morphAttributes.color=f),a.morphTargetsRelative=!0,a})}function es(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+":"+ke(t.attributes):e=a.indices+":"+ke(a.attributes)+":"+a.mode,a.targets!==void 0)for(let s=0,n=a.targets.length;s<n;s++)e+=":"+ke(a.targets[s]);return e}function ke(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 Ve(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 ns(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 ss=new d.Matrix4;class rs{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new wn,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,r=!1,o=-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,r=c.indexOf("Firefox")>-1,o=r?c.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||r&&o<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,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const c={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};return Q(r,c,n),j(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,r=t.length;n<r;n++){const o=t[n].joints;for(let c=0,i=o.length;c<i;c++)e[o[c]].isBone=!0}for(let n=0,r=e.length;n<r;n++){const o=e[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.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(),r=(o,c)=>{const i=this.associations.get(o);i!=null&&this.associations.set(c,i);for(const[l,u]of o.children.entries())r(u,c.children[l])};return r(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 r=e(t[n]);r&&s.push(r)}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(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":n=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.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(r,o){return s.getDependency(e,o)})),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(r,o){s.load(d.LoaderUtils.resolveURL(t.uri,n.path),r,void 0,function(){o(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,r=t.byteOffset||0;return s.slice(r,r+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const o=Be[n.type],c=oe[n.componentType],i=n.normalized===!0,l=new c(n.count*o);return Promise.resolve(new d.BufferAttribute(l,o,i))}const r=[];return n.bufferView!==void 0?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),n.sparse!==void 0&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then(function(o){const c=o[0],i=Be[n.type],l=oe[n.componentType],u=l.BYTES_PER_ELEMENT,h=u*i,f=n.byteOffset||0,m=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,T=n.normalized===!0;let x,g;if(m&&m!==h){const p=Math.floor(f/m),v="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+p+":"+n.count;let b=t.cache.get(v);b||(x=new l(c,p*m,n.count*m/u),b=new d.InterleavedBuffer(x,m/u),t.cache.add(v,b)),g=new d.InterleavedBufferAttribute(b,i,f%m/u,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 p=Be.SCALAR,v=oe[n.sparse.indices.componentType],b=n.sparse.indices.byteOffset||0,M=n.sparse.values.byteOffset||0,y=new v(o[1],b,n.sparse.count*p),C=new l(o[2],M,n.sparse.count*i);c!==null&&(g=new d.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let L=0,D=y.length;L<D;L++){const w=y[L];if(g.setX(w,C[L*i]),i>=2&&g.setY(w,C[L*i+1]),i>=3&&g.setZ(w,C[L*i+2]),i>=4&&g.setW(w,C[L*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,r=t.textures[e].source,o=t.images[r];let c=this.textureLoader;if(o.uri){const i=s.manager.getHandler(o.uri);i!==null&&(c=i)}return this.loadTextureImage(e,r,c)}loadTextureImage(e,t,s){const n=this,r=this.json,o=r.textures[e],c=r.images[t],i=(c.uri||c.bufferView)+":"+o.sampler;if(this.textureCache[i])return this.textureCache[i];const l=this.loadImageSource(t,s).then(function(u){u.flipY=!1,u.name=o.name||c.name||"",u.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(u.name=c.uri);const f=(r.samplers||{})[o.sampler]||{};return u.magFilter=ct[f.magFilter]||d.LinearFilter,u.minFilter=ct[f.minFilter]||d.LinearMipmapLinearFilter,u.wrapS=lt[f.wrapS]||d.RepeatWrapping,u.wrapT=lt[f.wrapT]||d.RepeatWrapping,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==d.NearestFilter&&u.minFilter!==d.LinearFilter,n.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[i]=l,l}loadImageSource(e,t){const s=this,n=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const o=n.images[e],c=self.URL||self.webkitURL;let i=o.uri||"",l=!1;if(o.bufferView!==void 0)i=s.getDependency("bufferView",o.bufferView).then(function(h){l=!0;const f=new Blob([h],{type:o.mimeType});return i=c.createObjectURL(f),i});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(i).then(function(h){return new Promise(function(f,m){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(h,r.path),T,void 0,m)})}).then(function(h){return l===!0&&c.revokeObjectURL(i),j(h,o),h.userData.mimeType=o.mimeType||ns(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",i),h});return this.sourceCache[e]=u,u}assignTexture(e,t,s,n){const r=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),r.extensions[R.KHR_TEXTURE_TRANSFORM]){const c=s.extensions!==void 0?s.extensions[R.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const i=r.associations.get(o);o=r.extensions[R.KHR_TEXTURE_TRANSFORM].extendTexture(o,c),r.associations.set(o,i)}}return n!==void 0&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=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||r||o){let c="ClonedMaterial:"+s.uuid+":";n&&(c+="derivative-tangents:"),r&&(c+="vertex-colors:"),o&&(c+="flat-shading:");let i=this.cache.get(c);i||(i=s.clone(),r&&(i.vertexColors=!0),o&&(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,r=s.materials[e];let o;const c={},i=r.extensions||{},l=[];if(i[R.KHR_MATERIALS_UNLIT]){const h=n[R.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),l.push(h.extendParams(c,r,t))}else{const h=r.pbrMetallicRoughness||{};if(c.color=new d.Color(1,1,1),c.opacity=1,Array.isArray(h.baseColorFactor)){const f=h.baseColorFactor;c.color.setRGB(f[0],f[1],f[2],d.LinearSRGBColorSpace),c.opacity=f[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(c,"map",h.baseColorTexture,d.SRGBColorSpace)),c.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,c.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(c,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(c,"roughnessMap",h.metallicRoughnessTexture))),o=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)})))}r.doubleSided===!0&&(c.side=d.DoubleSide);const u=r.alphaMode||Ue.OPAQUE;if(u===Ue.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,u===Ue.MASK&&(c.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==d.MeshBasicMaterial&&(l.push(t.assignTexture(c,"normalMap",r.normalTexture)),c.normalScale=new d.Vector2(1,1),r.normalTexture.scale!==void 0)){const h=r.normalTexture.scale;c.normalScale.set(h,h)}if(r.occlusionTexture!==void 0&&o!==d.MeshBasicMaterial&&(l.push(t.assignTexture(c,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==d.MeshBasicMaterial){const h=r.emissiveFactor;c.emissive=new d.Color().setRGB(h[0],h[1],h[2],d.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&o!==d.MeshBasicMaterial&&l.push(t.assignTexture(c,"emissiveMap",r.emissiveTexture,d.SRGBColorSpace)),Promise.all(l).then(function(){const h=new o(c);return r.name&&(h.name=r.name),j(h,r),t.associations.set(h,{materials:e}),r.extensions&&Q(n,h,r),h})}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 r(c){return s[R.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,t).then(function(i){return ut(i,c,t)})}const o=[];for(let c=0,i=e.length;c<i;c++){const l=e[c],u=ts(l),h=n[u];if(h)o.push(h.promise);else{let f;l.extensions&&l.extensions[R.KHR_DRACO_MESH_COMPRESSION]?f=r(l):f=ut(new d.BufferGeometry,l,t),n[u]={primitive:l,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,n=this.extensions,r=s.meshes[e],o=r.primitives,c=[];for(let i=0,l=o.length;i<l;i++){const u=o[i].material===void 0?$n(this.cache):this.getDependency("material",o[i].material);c.push(u)}return c.push(t.loadGeometries(o)),Promise.all(c).then(function(i){const l=i.slice(0,i.length-1),u=i[i.length-1],h=[];for(let m=0,T=u.length;m<T;m++){const x=u[m],g=o[m];let p;const v=l[m];if(g.mode===O.TRIANGLES||g.mode===O.TRIANGLE_STRIP||g.mode===O.TRIANGLE_FAN||g.mode===void 0)p=r.isSkinnedMesh===!0?new d.SkinnedMesh(x,v):new d.Mesh(x,v),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),g.mode===O.TRIANGLE_STRIP?p.geometry=at(p.geometry,d.TriangleStripDrawMode):g.mode===O.TRIANGLE_FAN&&(p.geometry=at(p.geometry,d.TriangleFanDrawMode));else if(g.mode===O.LINES)p=new d.LineSegments(x,v);else if(g.mode===O.LINE_STRIP)p=new d.Line(x,v);else if(g.mode===O.LINE_LOOP)p=new d.LineLoop(x,v);else if(g.mode===O.POINTS)p=new d.Points(x,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(p.geometry.morphAttributes).length>0&&es(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),j(p,r),g.extensions&&Q(n,p,g),t.assignFinalMaterial(p),h.push(p)}for(let m=0,T=h.length;m<T;m++)t.associations.set(h[m],{meshes:e,primitives:m});if(h.length===1)return r.extensions&&Q(n,h[0],r),h[0];const f=new d.Group;r.extensions&&Q(n,f,r),t.associations.set(f,{meshes:e});for(let m=0,T=h.length;m<T;m++)f.add(h[m]);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)),j(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,r=t.joints.length;n<r;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 r=n.pop(),o=n,c=[],i=[];for(let l=0,u=o.length;l<u;l++){const h=o[l];if(h){c.push(h);const f=new d.Matrix4;r!==null&&f.fromArray(r.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],r=n.name?n.name:"animation_"+e,o=[],c=[],i=[],l=[],u=[];for(let h=0,f=n.channels.length;h<f;h++){const m=n.channels[h],T=n.samplers[m.sampler],x=m.target,g=x.node,p=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&&(o.push(this.getDependency("node",g)),c.push(this.getDependency("accessor",p)),i.push(this.getDependency("accessor",v)),l.push(T),u.push(x))}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(i),Promise.all(l),Promise.all(u)]).then(function(h){const f=h[0],m=h[1],T=h[2],x=h[3],g=h[4],p=[];for(let v=0,b=f.length;v<b;v++){const M=f[v],y=m[v],C=T[v],L=x[v],D=g[v];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();const w=s._createAnimationTracks(M,y,C,L,D);if(w)for(let P=0;P<w.length;P++)p.push(w[P])}return new d.AnimationClip(r,void 0,p)})}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(r){const o=s._getNodeRef(s.meshCache,n.mesh,r);return n.weights!==void 0&&o.traverse(function(c){if(c.isMesh)for(let i=0,l=n.weights.length;i<l;i++)c.morphTargetInfluences[i]=n.weights[i]}),o})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],r=s._loadNodeShallow(e),o=[],c=n.children||[];for(let l=0,u=c.length;l<u;l++)o.push(s.getDependency("node",c[l]));const i=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([r,Promise.all(o),i]).then(function(l){const u=l[0],h=l[1],f=l[2];f!==null&&u.traverse(function(m){m.isSkinnedMesh&&m.bind(f,ss)});for(let m=0,T=h.length;m<T;m++)u.add(h[m]);return u})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?n.createUniqueName(r.name):"",c=[],i=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return i&&c.push(i),r.camera!==void 0&&c.push(n.getDependency("camera",r.camera).then(function(l){return n._getNodeRef(n.cameraCache,r.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 u;if(r.isBone===!0?u=new d.Bone:l.length>1?u=new d.Group:l.length===1?u=l[0]:u=new d.Object3D,u!==l[0])for(let h=0,f=l.length;h<f;h++)u.add(l[h]);if(r.name&&(u.userData.name=r.name,u.name=o),j(u,r),r.extensions&&Q(s,u,r),r.matrix!==void 0){const h=new d.Matrix4;h.fromArray(r.matrix),u.applyMatrix4(h)}else r.translation!==void 0&&u.position.fromArray(r.translation),r.rotation!==void 0&&u.quaternion.fromArray(r.rotation),r.scale!==void 0&&u.scale.fromArray(r.scale);return n.associations.has(u)||n.associations.set(u,{}),n.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,r=new d.Group;s.name&&(r.name=n.createUniqueName(s.name)),j(r,s),s.extensions&&Q(t,r,s);const o=s.nodes||[],c=[];for(let i=0,l=o.length;i<l;i++)c.push(n.getDependency("node",o[i]));return Promise.all(c).then(function(i){for(let u=0,h=i.length;u<h;u++)r.add(i[u]);const l=u=>{const h=new Map;for(const[f,m]of n.associations)(f instanceof d.Material||f instanceof d.Texture)&&h.set(f,m);return u.traverse(f=>{const m=n.associations.get(f);m!=null&&h.set(f,m)}),h};return n.associations=l(r),r})}_createAnimationTracks(e,t,s,n,r){const o=[],c=e.name?e.name:e.uuid,i=[];z[r.path]===z.weights?e.traverse(function(f){f.morphTargetInfluences&&i.push(f.name?f.name:f.uuid)}):i.push(c);let l;switch(z[r.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 u=n.interpolation!==void 0?Qn[n.interpolation]:d.InterpolateLinear,h=this._getArrayFromAccessor(s);for(let f=0,m=i.length;f<m;f++){const T=new l(i[f]+"."+z[r.path],t.array,h,u);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),o.push(T)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=Ve(t.constructor),n=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)n[r]=t[r]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof d.QuaternionKeyframeTrack?Zn:Et;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function os(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 u=Ve(oe[c.componentType]);n.min.multiplyScalar(u),n.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const c=new d.Vector3,i=new d.Vector3;for(let l=0,u=r.length;l<u;l++){const h=r[l];if(h.POSITION!==void 0){const f=t.json.accessors[h.POSITION],m=f.min,T=f.max;if(m!==void 0&&T!==void 0){if(i.setX(Math.max(Math.abs(m[0]),Math.abs(T[0]))),i.setY(Math.max(Math.abs(m[1]),Math.abs(T[1]))),i.setZ(Math.max(Math.abs(m[2]),Math.abs(T[2]))),f.normalized){const x=Ve(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 o=new d.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,a.boundingSphere=o}function ut(a,e,t){const s=e.attributes,n=[];function r(o,c){return t.getDependency("accessor",o).then(function(i){a.setAttribute(c,i)})}for(const o in s){const c=Ye[o]||o.toLowerCase();c in a.attributes||n.push(r(s[o],c))}if(e.indices!==void 0&&!a.index){const o=t.getDependency("accessor",e.indices).then(function(c){a.setIndex(c)});n.push(o)}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.`),j(a,e),os(a,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Jn(a,e.targets,t):a})}const pe=[0,0,-10],q=[.5,.5,.5],Ze=1,Ge=new Map,as=a=>{const e=Ge.get(a);if(e)return e;const t=new Sn,s=$.fetchAndVerify(a).then(n=>new Promise((r,o)=>{t.parse(n,"",r,o)})).catch(n=>{throw Ge.delete(a),n});return Ge.set(a,s),s},Qe=({position:a,rotation:e,scale:t,url:s,showDebugMaterial:n=!1,opacity:r=Ze})=>{const o=s??new URL("/assets/xr/3d-models/head-occluder-v2.glb",$.libConfig.assetStorageEndpoint).toString(),[c,i]=S.useState(null);S.useEffect(()=>{let u=!1;return as(o).then(h=>{u||i(h.scene)}).catch(h=>{u||console.error(`${$.libConfig.loggerPrefix} head occluder load failed`,h)}),()=>{u=!0}},[o]);const l=S.useMemo(()=>{if(!c)return null;const u=c.clone();return u.traverse(h=>{h instanceof E.Mesh&&(h.material=new E.MeshStandardMaterial({color:15132390,colorWrite:n,depthWrite:!0,opacity:n?r:1,side:E.DoubleSide,transparent:n}))}),u},[c,n,r]);return S.useEffect(()=>{if(l)return()=>{l.traverse(u=>{u instanceof E.Mesh&&u.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},is=4,cs=({children:a,faceIndex:e=0,numFaces:t=is,scaleWithFace:s=!0,occluder:n=!0,showFaceMesh:r=!1,faceMeshMaterial:o})=>{const c=S.useMemo(()=>new E.MeshBasicMaterial({color:"#22c55e",side:E.BackSide,transparent:!0,opacity:.35,depthWrite:!1}),[]),i=n===!1?null:n===!0?{}:n;return A.jsxs(Xe.FaceTracker,{faceIndex:e,numFaces:t,scaleWithFace:s,children:[i&&A.jsx(Qe,{position:i.position??pe,rotation:i.rotation,scale:i.scale??q,url:i.url,showDebugMaterial:i.showDebugMaterial,opacity:i.opacity??Ze}),a,r&&A.jsx(Xe.FaceMesh,{faceIndex:e,numFaces:t,material:o??c})]})},ls=57,us=15.5,He=ls/Math.PI/us,hs=-.134,ds=-.024,X=(a,e,t)=>Math.min(t,Math.max(e,a)),St=(a,e)=>a*e-e/2,wt=(a,e)=>-(a*e-e/2),fs=({eyeMidX:a,noseX:e,offsetX:t,rawYaw:s,sideMidX:n})=>{const r=X((Math.abs(s)-.18)/.42,0,1),o=n*.75+a*.25,c=a*.7+e*.3;return o*(1-r)+c*r+t},ps=({baseScale:a,pitchRadians:e})=>{const t=e*180/Math.PI,n=1+X((t-6)/22,0,1)*.22;return[a[0]*n,a[1]*n,a[2]*n]},ms=({yawRadians:a})=>{const e=Math.abs(a*180/Math.PI),s=.066*X((e-8)/12,0,1);return Math.sign(a)*s},gs=({pitchRadians:a})=>{const e=a*180/Math.PI;return-.026*X((-e-6)/18,0,1)},As=({baseOffset:a,yawRadians:e})=>{const t=Math.abs(e*180/Math.PI),s=X((t-8)/24,0,1);return a+s*.25},Ts=({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=X((s-1.55)/.35,-1,1);return{aspectRatio:s,normalizedAspect:n,scaleY:e+n*.06,offsetY:a+n*.005}},_t=({face:a,offsetX:e,offsetY:t,scaleX:s,scaleY:n})=>{const r=a.bounds.width*s,o=a.bounds.height*n,c=a.bounds.centerX+e,i=a.bounds.centerY+t;return{x:c-r*.5,y:i-o*.5,width:r,height:o,centerX:c,centerY:i}},xs=({face:a,height:e,lockDepth:t,lockRotation:s,model:n,offsetX:r,offsetY:o,scaleX:c,scaleY:i,scaleZ:l,width:u})=>{const h=_t({face:a,offsetX:r,offsetY:o,scaleX:c,scaleY:i}),f=a.landmarks[33],m=a.landmarks[263],T=a.landmarks[234],x=a.landmarks[454],g=a.landmarks[1],p=a.landmarks[10],v=a.landmarks[152],b=h.width*u,M=h.height*e,y=f&&m?(f.x+m.x)*.5:a.bounds.centerX,C=f&&m?(f.y+m.y)*.5:a.bounds.centerY-a.bounds.height*.15,L=T&&x?(T.x+x.x)*.5:y,D=(p==null?void 0:p.y)??a.bounds.minY,w=(v==null?void 0:v.y)??a.bounds.maxY,P=(D+w)*.5,J=f&&m?Math.atan2(m.y-f.y,m.x-f.x):0,I=g&&a.bounds.width>0?X((g.x-a.bounds.centerX)/(a.bounds.width*.5),-1,1)*.75:0,K=fs({eyeMidX:y,noseX:(g==null?void 0:g.x)??y,offsetX:r,rawYaw:I,sideMidX:L}),_=P*.75+C*.25+o,ee=n==="v2"?St(K,u):h.centerX*u-u/2,Y=n==="v2"?wt(a.bounds.centerY+o*.75,e):-(h.centerY*e-e/2),V=p&&g?Math.max(1e-4,g.y-p.y):a.bounds.height*.42,ae=g&&v?Math.max(1e-4,v.y-g.y):a.bounds.height*.58,ie=(ae-V)/(ae+V),ce=X((ie-hs)/.28,-1,1)*.58,le=g&&a.bounds.height>0?X((a.bounds.centerY-g.y)/(a.bounds.height*.5)-ds,-1,1)*.18:0,te=ce*.82+le*.18,ne=s?0:n==="v2"?I*.72:I,ue=s?0:n==="v2"?-te*.78:-te,he=s?0:-J,me=t?b*He:n==="v2"?b*(He+Math.abs(ne)*.18):b*He;return{centerXPx:ee,centerYPx:Y,depthPx:me*l,heightPx:M,pitch:ue,rawPitch:te,rawPitchFromBalance:ce,rawPitchFromCenter:le,rawYaw:I,rotationZ:he,roll:J,shape:h,skullAnchorX:K,skullAnchorY:_,verticalBalance:ie,widthPx:b,yaw:ne}},yt=({lockDepth:a,lockRotation:e,model:t,face:s,height:n,headDepthOffset:r,offsetX:o,offsetY:c,rotationOffsetX:i,rotationOffsetY:l,rotationOffsetZ:u,scaleX:h,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:x,width:g})=>$e({lockDepth:a,lockRotation:e,model:t,face:s,height:n,headDepthOffset:r,offsetX:o,offsetY:c,rotationOffsetX:i,rotationOffsetY:l,rotationOffsetZ:u,scaleX:h,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:x,width:g}).pose,$e=({lockDepth:a,lockRotation:e,model:t,face:s,height:n,headDepthOffset:r,offsetX:o,offsetY:c,rotationOffsetX:i,rotationOffsetY:l,rotationOffsetZ:u,scaleX:h,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:x,width:g})=>{const p=xs({face:s,height:n,lockDepth:a,lockRotation:e,model:t,offsetX:o,offsetY:c,scaleX:h,scaleY:f,scaleZ:m,width:g});if(T){const b=new d.Vector3(0,p.heightPx*x,-p.depthPx*r).applyEuler(new d.Euler(p.pitch,p.yaw,p.rotationZ,"XYZ")),M=St(p.skullAnchorX,g),y=wt(p.skullAnchorY,n);return{pose:{boxCenterZ:b.z,centerX:M+b.x,centerY:y+b.y,width:p.widthPx,height:p.heightPx,depth:p.depthPx,rotationX:p.pitch+i,rotationY:p.yaw+l,rotationZ:p.rotationZ+u},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+i,rotationY:p.yaw+l,rotationZ:p.rotationZ+u},skullAnchor:{x:p.skullAnchorX,y:p.skullAnchorY},center:{x:M+b.x,y:y+b.y,z:b.z},depthPx:p.depthPx,screen:{widthPx:p.widthPx,heightPx:p.heightPx}}}}return{pose:{boxCenterZ:-p.depthPx*r,centerX:p.centerXPx,centerY:p.centerYPx,width:p.widthPx,height:p.heightPx,depth:p.depthPx,rotationX:p.pitch+i,rotationY:p.yaw+l,rotationZ:p.rotationZ+u},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+i,rotationY:p.yaw+l,rotationZ:p.rotationZ+u},skullAnchor:{x:p.skullAnchorX,y:p.skullAnchorY},center:{x:p.centerXPx,y:p.centerYPx,z:-p.depthPx*r},depthPx:p.depthPx,screen:{widthPx:p.widthPx,heightPx:p.heightPx}}}},vs=({lockDepth:a,lockRotation:e,model:t,face:s,height:n,headDepthOffset:r,offsetX:o,offsetY:c,rotationOffsetX:i,rotationOffsetY:l,rotationOffsetZ:u,scaleX:h,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:x,width:g})=>$e({lockDepth:a,lockRotation:e,model:t,face:s,height:n,headDepthOffset:r,offsetX:o,offsetY:c,rotationOffsetX:i,rotationOffsetY:l,rotationOffsetZ:u,scaleX:h,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:x,width:g}).debugMetrics,bs=({boxColor:a,boxOpacity:e,face:t,headDepthOffset:s,lockDepth:n,lockRotation:r,model:o,occluderOffset:c,occluderOpacity:i,occluderScale:l,showOccluderProxy:u=!1,offsetX:h,offsetY:f,pose:m,rotationOffsetX:T,rotationOffsetY:x,rotationOffsetZ:g,scaleX:p,scaleY:v,scaleZ:b,show:M,showCenterDot:y,showFacePlaneReference:C,showGizmo:L,showHeadOccluder:D,skullCenterMode:w,skullVerticalBias:P,url:J,viewportHeight:I,viewportWidth:K})=>{const _=S.useMemo(()=>m||(!t||K<=0||I<=0?null:yt({face:t,width:K,height:I,headDepthOffset:s,lockDepth:n,lockRotation:r,model:o,offsetX:h,offsetY:f,rotationOffsetX:T,rotationOffsetY:x,rotationOffsetZ:g,scaleX:p,scaleY:v,scaleZ:b,skullCenterMode:w,skullVerticalBias:P})),[t,s,n,r,o,h,f,T,x,g,p,v,b,w,P,m,I,K]);if(!M||!_)return null;const ee=w?[0,-_.height*P,_.depth*s]:[0,0,0],Y=_.height,V=[q[0]*l[0]*Y,q[1]*l[1]*Y,q[2]*l[2]*Y];return A.jsxs(A.Fragment,{children:[A.jsxs("group",{position:[_.centerX,_.centerY,_.boxCenterZ],rotation:[_.rotationX,_.rotationY,_.rotationZ],children:[A.jsx("group",{scale:[_.width,_.height,_.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})]})}),y&&A.jsxs("mesh",{children:[A.jsx("sphereGeometry",{args:[6,20,20]}),A.jsx("meshBasicMaterial",{color:a})]}),C&&A.jsxs("group",{position:ee,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})]})]}),D&&A.jsxs(A.Fragment,{children:[u&&A.jsxs("mesh",{position:c,scale:V,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(Qe,{opacity:i,position:c,scale:V,showDebugMaterial:!0,url:J})]})]}),L&&A.jsx("group",{position:[_.centerX,_.centerY,_.boxCenterZ],rotation:[_.rotationX,_.rotationY,_.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(Fe.Text,{position:[42,0,0],fontSize:10,color:"#ef4444",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"X"}),A.jsx(Fe.Text,{position:[0,42,0],fontSize:10,color:"#22c55e",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"Y"}),A.jsx(Fe.Text,{position:[0,0,42],fontSize:10,color:"#3b82f6",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"Z"})]})})]})};exports.CanonicalFaceMeshRenderer=Yt;exports.DEFAULT_APPEARANCE=Vt;exports.DEFAULT_FEATURE_GROUPS=vt;exports.DEFAULT_FEATURE_POINT_INDICES=bt;exports.DEFAULT_MASKING=Wt;exports.FACE_MASK_SIZE=Ee;exports.FACE_OVAL=We;exports.FaceRetouchBackground=rn;exports.HEAD_OCCLUDER_DEFAULT_OPACITY=Ze;exports.HEAD_OCCLUDER_DEFAULT_POSITION=pe;exports.HEAD_OCCLUDER_DEFAULT_SCALE=q;exports.HeadBinding=cs;exports.HeadBindingOccluder=bs;exports.HeadOccluder=Qe;exports.INNER_MOUTH=ze;exports.LEFT_EYE=ft;exports.LEFT_EYEBROW=gt;exports.OUTER_LIPS=mt;exports.RIGHT_EYE=pt;exports.RIGHT_EYEBROW=At;exports.alphaMapOptions=$t;exports.blendModeIndices=Ke;exports.blendModeOptions=Jt;exports.computeAdaptiveVerticalFit=Ts;exports.computeHeadBindingCubePose=yt;exports.computeHeadBindingDebugMetrics=vs;exports.computeHeadBindingShape=_t;exports.computeUniversalHeadDepthOffset=As;exports.computeUniversalOccluderScale=ps;exports.computeUniversalPitchOffsetY=gs;exports.computeUniversalYawOffsetX=ms;exports.createFaceRetouchRegions=Mt;exports.drawFaceRetouchMask=Tt;exports.drawMouthRetouchMask=xt;exports.materialTypeOptions=zt;exports.parseCanonicalFaceModel=ht;exports.shaderPresetOptions=qt;exports.sideOptions=Zt;exports.solveHeadBinding=$e;exports.supportsBlendMode=tn;exports.supportsTexturePanel=en;exports.textureMapOptions=Qt;exports.useCanonicalFaceMesh=dt;exports.useFaceRetouchMask=Mn;exports.useFaceRetouchRegions=En;
|
|
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;
|