@vincentt-xr/sdk 2.0.0-alpha.7 → 2.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GROUNDING.md +1109 -13
- package/dist/{DebuggerUI-BjOMr8q_.js → DebuggerUI-C-ldiozL.js} +1 -1
- package/dist/{DebuggerUI-B6bP6P9r.cjs → DebuggerUI-CWX5EtQv.cjs} +1 -1
- package/dist/FaceMeshRenderer-BEEXZwS6.cjs +158 -0
- package/dist/FaceMeshRenderer-UuH5sTXG.js +1322 -0
- package/dist/FaceRetouch-C7h7x9kd.js +683 -0
- package/dist/FaceRetouch-DqftT26Y.cjs +134 -0
- package/dist/GLTFLoader-C5q63sKO.js +1633 -0
- package/dist/GLTFLoader-Cb_CRwmG.cjs +1 -0
- package/dist/SegmentationOverlay-DQuW3dsc.js +133 -0
- package/dist/SegmentationOverlay-aWVod8Kl.cjs +1 -0
- package/dist/assets/cache.d.ts +99 -0
- package/dist/assets/estimate.d.ts +11 -0
- package/dist/assets/index.d.ts +7 -0
- package/dist/assets/loaders.d.ts +28 -0
- package/dist/assets/react.d.ts +33 -0
- package/dist/calibration/calibration.d.ts +70 -0
- package/dist/calibration/index.d.ts +6 -0
- package/dist/calibration/storage.d.ts +13 -0
- package/dist/calibration/types.d.ts +53 -0
- package/dist/calibration/useXRCalibration.d.ts +46 -0
- package/dist/camera/CameraPermissionGate.d.ts +26 -0
- package/dist/camera/devices.d.ts +26 -0
- package/dist/camera/index.d.ts +8 -0
- package/dist/camera/permission.d.ts +86 -0
- package/dist/camera/useCameraPermission.d.ts +35 -0
- package/dist/capabilities/detect.d.ts +45 -0
- package/dist/capabilities/index.d.ts +5 -0
- package/dist/capabilities/types.d.ts +120 -0
- package/dist/capabilities/useXRCapabilities.d.ts +18 -0
- package/dist/compat/environment.d.ts +5 -0
- package/dist/compat/index.d.ts +4 -0
- package/dist/compat/run.d.ts +18 -0
- package/dist/compat/scenarios.d.ts +10 -0
- package/dist/compat/types.d.ts +101 -0
- package/dist/components/BodyTracker/index.d.ts +9 -0
- package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +33 -3
- package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +12 -0
- package/dist/components/FaceMesh/canonical/shaders.d.ts +1 -1
- package/dist/components/FaceMesh/index.d.ts +1 -1
- package/dist/components/GestureListener/index.d.ts +11 -0
- package/dist/components/HandTracker/index.d.ts +10 -0
- package/dist/components/HolisticTracker/index.d.ts +69 -0
- package/dist/components/HolisticTracker/settings.d.ts +58 -0
- package/dist/components/HolisticTracker/signals.d.ts +49 -0
- package/dist/components/IrisEffect/IrisMaterial.d.ts +73 -0
- package/dist/components/IrisEffect/index.d.ts +51 -0
- package/dist/components/IrisEffect/settings.d.ts +117 -0
- package/dist/components/LipEffect/LipEffect.d.ts +7 -1
- package/dist/components/LipEffect/LipEffectMaterial.d.ts +43 -7
- package/dist/components/LipEffect/LipEffects.d.ts +9 -0
- package/dist/components/LipEffect/defaults.d.ts +27 -4
- package/dist/components/LipEffect/index.d.ts +11 -3
- package/dist/components/LipEffect/settings.d.ts +271 -0
- package/dist/components/LipEffect/types.d.ts +56 -9
- package/dist/components/LipEffect/useLipDesignTextures.d.ts +11 -0
- package/dist/components/LipEffect/uvGuide.d.ts +59 -0
- package/dist/components/PersonCutout/index.d.ts +50 -0
- package/dist/components/PersonCutout/personCutout.d.ts +16 -0
- package/dist/components/ScreenImage/components/ScreenImageBody.d.ts +1 -1
- package/dist/components/ScreenImage/index.d.ts +3 -1
- package/dist/components/ScreenImage/materials/ScreenImageBlendMaterial.d.ts +1 -1
- package/dist/components/ScreenImage/materials/ScreenImageMaskMaterial.d.ts +11 -0
- package/dist/components/ScreenImage/source.d.ts +6 -0
- package/dist/components/ScreenImage/types.d.ts +18 -0
- package/dist/components/SegmentationOverlay/SegmentationOverlay.d.ts +37 -0
- package/dist/components/SegmentationOverlay/SegmentationOverlayMaterial.d.ts +31 -0
- package/dist/components/SegmentationOverlay/index.d.ts +9 -0
- package/dist/components/SegmentationOverlay/maskTexture.d.ts +23 -0
- package/dist/components/SegmentationOverlay/providers.d.ts +72 -0
- package/dist/components/SegmentationOverlay/settings.d.ts +65 -0
- package/dist/components/XRProvider/index.d.ts +16 -2
- package/dist/components/XRViewport/hooks/useViewportExternalFaces.d.ts +1 -1
- package/dist/components/XRViewport/hooks/useViewportMediaSource.d.ts +1 -1
- package/dist/components/XRViewport/hooks/useViewportPipeline.d.ts +1 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/constants/index.d.ts +4 -1
- package/dist/contexts-CO0sd4JQ.cjs +1 -0
- package/dist/{contexts-ByhzppYl.js → contexts-FzlnnMYD.js} +252 -246
- package/dist/coordinates/feed.d.ts +52 -0
- package/dist/coordinates/index.d.ts +5 -0
- package/dist/coordinates/spaces.d.ts +49 -0
- package/dist/coordinates/viewport.d.ts +22 -0
- package/dist/coordinates/world.d.ts +15 -0
- package/dist/debug-ui/gesture-settings/index.d.ts +14 -0
- package/dist/debug-ui/holistic-tracker-settings/index.d.ts +16 -0
- package/dist/debug-ui/index.d.ts +14 -0
- package/dist/debug-ui/iris-effect-settings/index.d.ts +12 -0
- package/dist/debug-ui/lip-effect-settings/index.d.ts +15 -0
- package/dist/debug-ui/media-source.cjs +1 -1
- package/dist/debug-ui/media-source.js +1 -1
- package/dist/debug-ui/product-hotspots/index.d.ts +24 -0
- package/dist/debug-ui/segmentation-overlay-settings/index.d.ts +12 -0
- package/dist/debug-ui/xr-diagnostics/index.d.ts +25 -0
- package/dist/debug-ui.cjs +3 -3
- package/dist/debug-ui.js +2057 -1687
- package/dist/detector-K8aej4MB.js +59 -0
- package/dist/detector-ijypGtse.cjs +1 -0
- package/dist/entries/core.d.ts +18 -1
- package/dist/entries/face-effects.d.ts +11 -3
- package/dist/entries/low-level.d.ts +22 -3
- package/dist/entries/product.d.ts +11 -0
- package/dist/entries/tracking.d.ts +24 -1
- package/dist/face-effects.cjs +155 -1
- package/dist/face-effects.js +1134 -2197
- package/dist/gestures/definitions.d.ts +85 -0
- package/dist/gestures/detector.d.ts +87 -0
- package/dist/gestures/index.d.ts +8 -0
- package/dist/gestures/measures.d.ts +101 -0
- package/dist/gestures/settings.d.ts +49 -0
- package/dist/{getFaceInfo-C4QpCQIY.js → getFaceInfo-BkZfaQs-.js} +5 -5
- package/dist/{getFaceInfo-fA1bFBub.cjs → getFaceInfo-ahPxQFGu.cjs} +1 -1
- package/dist/hooks/selectors.d.ts +68 -1
- package/dist/hooks/useCalibrationFaceTracker.d.ts +1 -1
- package/dist/hooks/useFaceInfo.d.ts +13 -1
- package/dist/hooks/useFaceInfos.d.ts +1 -1
- package/dist/hooks/useGesture.d.ts +32 -0
- package/dist/hooks/useIrisTracking.d.ts +45 -0
- package/dist/hooks/useXRDiagnostics.d.ts +81 -0
- package/dist/hooks/useXRModel.d.ts +7 -0
- package/dist/hooks/useXRSession/facade.d.ts +42 -2
- package/dist/hooks/useXRSession/index.d.ts +2 -2
- package/dist/hooks/useXRSession/reason.d.ts +3 -1
- package/dist/hooks/useXRSession/registry.d.ts +14 -0
- package/dist/hooks/useXRSession/store.d.ts +52 -3
- package/dist/index--RgGzZ6X.cjs +47 -0
- package/dist/{index-VJ0SJwmG.js → index-CHVbH0hz.js} +4 -4
- package/dist/index-CeVkgsag.cjs +1 -0
- package/dist/index-CnGox6Xr.js +3054 -0
- package/dist/{index-ByoNj0QP.js → index-CsUdQ-pn.js} +113 -111
- package/dist/{index-BjmTe9eM.cjs → index-DKBAh6hV.cjs} +1 -1
- package/dist/index-DsZwTfG0.cjs +1 -0
- package/dist/index-Dw6tj2Mi.js +144 -0
- package/dist/index-OCPjOaeP.cjs +1 -0
- package/dist/{index-DXT3WccE.js → index-s9pF4zkG.js} +1065 -1101
- package/dist/internal-BYza1h8_.cjs +1 -0
- package/dist/{internal-Dmk1cTXq.js → internal-vsfNQycj.js} +15 -16
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +2 -2
- package/dist/iris/compute.d.ts +25 -0
- package/dist/iris/index.d.ts +4 -0
- package/dist/iris/lead.d.ts +19 -0
- package/dist/iris/types.d.ts +87 -0
- package/dist/landmarkMask-CbTFzBYG.js +224 -0
- package/dist/landmarkMask-u7es2k4X.cjs +1 -0
- package/dist/low-level.cjs +1 -1
- package/dist/low-level.js +1085 -634
- package/dist/main.cjs +1 -1
- package/dist/main.js +1519 -465
- package/dist/measures-9dQPdw96.js +154 -0
- package/dist/measures-KfJzpvod.cjs +1 -0
- package/dist/models/Base/index.d.ts +49 -0
- package/dist/models/Body/index.d.ts +1 -1
- package/dist/models/Face/index.d.ts +1 -1
- package/dist/models/Hand/GestureTracking.d.ts +1 -1
- package/dist/models/Hand/HandTracking.d.ts +1 -1
- package/dist/models/Holistic/index.d.ts +49 -0
- package/dist/models/Holistic/result.d.ts +68 -0
- package/dist/models/SemanticSegmentation/index.d.ts +31 -0
- package/dist/models/SemanticSegmentation/presets.d.ts +28 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/product/ProductDimensions.d.ts +16 -0
- package/dist/product/ProductHotspot.d.ts +16 -0
- package/dist/product/ProductViewer.d.ts +9 -0
- package/dist/product/details.d.ts +53 -0
- package/dist/product/index.d.ts +14 -0
- package/dist/product/loadModelViewer.d.ts +4 -0
- package/dist/product/types.d.ts +71 -0
- package/dist/product/useProductAr.d.ts +37 -0
- package/dist/product/useProductDetails.d.ts +60 -0
- package/dist/product.cjs +1 -0
- package/dist/product.js +414 -0
- package/dist/providers-C0Dlhh9Z.js +365 -0
- package/dist/providers-YNwkmNeK.cjs +62 -0
- package/dist/quality/XRQualityController.d.ts +25 -0
- package/dist/quality/controller.d.ts +33 -0
- package/dist/quality/index.d.ts +6 -0
- package/dist/quality/types.d.ts +100 -0
- package/dist/quality/useXRQuality.d.ts +28 -0
- package/dist/{renderGroups-KZk6eRiY.js → renderGroups-CN1cGFUo.js} +1 -1
- package/dist/{renderGroups-80H3DpTl.cjs → renderGroups-O4KmaMl9.cjs} +1 -1
- package/dist/renderPasses-Cg-zqmEz.cjs +21 -0
- package/dist/renderPasses-NnKZVfBy.js +1460 -0
- package/dist/scene-object.cjs +1 -1
- package/dist/scene-object.js +2 -2
- package/dist/screenTransform-BenfCtZt.js +44 -0
- package/dist/screenTransform-BiXdpVf0.cjs +1 -0
- package/dist/segmentation-9PhSvc-R.cjs +1 -0
- package/dist/segmentation-CeOTKemr.js +5 -0
- package/dist/segmentation2d/faceMemory.d.ts +28 -0
- package/dist/segmentation2d/faceRegions.d.ts +24 -0
- package/dist/segmentation2d/index.d.ts +9 -0
- package/dist/segmentation2d/maskUv.d.ts +23 -0
- package/dist/segmentation2d/rasterize.d.ts +14 -0
- package/dist/segmentation2d/types.d.ts +46 -0
- package/dist/selectors-C5G1PMYL.js +195 -0
- package/dist/selectors-Du_PsVnW.cjs +1 -0
- package/dist/{session-CpkiK5YA.cjs → session-BBr0yN8h.cjs} +7 -7
- package/dist/{session-DLFN_VII.js → session-Cy0m7l7-.js} +76 -76
- package/dist/settings-DRR7-snV.cjs +1 -0
- package/dist/settings-aQk845NJ.js +73 -0
- package/dist/subjects/index.d.ts +2 -0
- package/dist/subjects/select.d.ts +62 -0
- package/dist/subjects/types.d.ts +55 -0
- package/dist/tracking-config/apply.d.ts +57 -0
- package/dist/tracking-config/index.d.ts +7 -0
- package/dist/tracking-config/resolve.d.ts +25 -0
- package/dist/tracking-config/storage.d.ts +8 -0
- package/dist/tracking-config/types.d.ts +106 -0
- package/dist/tracking-config/useXRTrackingConfig.d.ts +38 -0
- package/dist/tracking.cjs +1 -1
- package/dist/tracking.js +1056 -383
- package/dist/types/compositor.d.ts +21 -0
- package/dist/types/holistic.d.ts +121 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/model.d.ts +22 -2
- package/dist/types/nodes.d.ts +27 -2
- package/dist/types/segmentation.d.ts +19 -0
- package/dist/types/session.d.ts +41 -3
- package/dist/useFaceInfo-Blf7FCu3.js +303 -0
- package/dist/useFaceInfo-C5mO8NQY.cjs +1 -0
- package/dist/useXRCapabilities-B1R2ghy-.cjs +1 -0
- package/dist/useXRCapabilities-C68v__wB.js +30 -0
- package/dist/utils/fns.d.ts +6 -3
- package/dist/utils/integrity.d.ts +4 -1
- package/dist/utils/updateThrottle.d.ts +2 -0
- package/dist/utils/useStableUniforms.d.ts +18 -0
- package/docs/api/adaptive-quality.mdx +104 -0
- package/docs/api/asset-lifecycle.mdx +78 -0
- package/docs/api/camera-permission.mdx +142 -0
- package/docs/api/coordinate-spaces.mdx +165 -0
- package/docs/api/cross-camera.mdx +88 -0
- package/docs/api/diagnostics-calibration.mdx +97 -0
- package/docs/api/face-effects.mdx +6 -0
- package/docs/api/face-mesh.mdx +4 -2
- package/docs/api/gestures.mdx +173 -0
- package/docs/api/holistic-tracker.mdx +159 -0
- package/docs/api/iris-tracking.mdx +242 -0
- package/docs/api/multi-subject.mdx +95 -0
- package/docs/api/person-cutout.mdx +136 -0
- package/docs/api/product-ar.mdx +111 -0
- package/docs/api/product-details.mdx +78 -0
- package/docs/api/screen-space-coordinates.mdx +4 -1
- package/docs/api/segmentation-overlay.mdx +301 -0
- package/docs/api/session-lifecycle.mdx +136 -0
- package/docs/api/trackers.mdx +5 -0
- package/docs/api/tracking-config.mdx +108 -0
- package/docs/docs.json +23 -1
- package/docs/examples/lip-shaders.mdx +224 -0
- package/docs/guides/lip-effect-textures.mdx +292 -0
- package/docs/guides/lip-uv-template.png +0 -0
- package/docs/guides/lip-uv-template.svg +1 -0
- package/package.json +13 -1
- package/dist/FaceMeshRenderer-C5l6VLdO.cjs +0 -155
- package/dist/FaceMeshRenderer-wjAHrJzP.js +0 -1270
- package/dist/FaceRetouch-BkJzoA79.cjs +0 -134
- package/dist/FaceRetouch-DwbKQJAN.js +0 -551
- package/dist/contexts-Dr62It_K.cjs +0 -1
- package/dist/index-9dlAQAhy.js +0 -1462
- package/dist/index-BpEf2BBb.cjs +0 -1
- package/dist/index-CyUUurQT.cjs +0 -1
- package/dist/index-DCiMbxC3.cjs +0 -1
- package/dist/index-DpI-qo5X.cjs +0 -17
- package/dist/index-DyVF4vEW.js +0 -111
- package/dist/internal-Cq-TEQ5Y.cjs +0 -1
- package/dist/renderLayers-lDtL0_43.cjs +0 -1
- package/dist/renderLayers-zrK2pv5O.js +0 -13
- package/dist/renderPasses-BOoBSr8z.cjs +0 -21
- package/dist/renderPasses-BcquyVtu.js +0 -1500
- package/dist/selectors-B8H97CKA.js +0 -59
- package/dist/selectors-CZLKT2Iv.cjs +0 -1
- package/dist/useFaceInfo-BJ8-_MOs.cjs +0 -1
- package/dist/useFaceInfo-Dk426LTu.js +0 -62
- package/dist/useFaceResults-CtetsO9M.js +0 -19
- package/dist/useFaceResults-wBJF3zyp.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("three");function U(h,t){if(t===u.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),h;if(t===u.TriangleFanDrawMode||t===u.TriangleStripDrawMode){let e=h.getIndex();if(e===null){const s=[],a=h.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)s.push(o);h.setIndex(s),e=h.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),h}const i=e.count-2,n=[];if(t===u.TriangleFanDrawMode)for(let s=1;s<=i;s++)n.push(e.getX(0)),n.push(e.getX(s)),n.push(e.getX(s+1));else for(let s=0;s<i;s++)s%2===0?(n.push(e.getX(s)),n.push(e.getX(s+1)),n.push(e.getX(s+2))):(n.push(e.getX(s+2)),n.push(e.getX(s+1)),n.push(e.getX(s)));n.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=h.clone();return r.setIndex(n),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),h}class q extends u.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new J(e)}),this.register(function(e){return new $(e)}),this.register(function(e){return new ce(e)}),this.register(function(e){return new le(e)}),this.register(function(e){return new ue(e)}),this.register(function(e){return new te(e)}),this.register(function(e){return new ne(e)}),this.register(function(e){return new se(e)}),this.register(function(e){return new re(e)}),this.register(function(e){return new Z(e)}),this.register(function(e){return new ie(e)}),this.register(function(e){return new ee(e)}),this.register(function(e){return new ae(e)}),this.register(function(e){return new oe(e)}),this.register(function(e){return new Q(e)}),this.register(function(e){return new fe(e)}),this.register(function(e){return new he(e)})}load(t,e,i,n){const r=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const c=u.LoaderUtils.extractUrlBase(t);s=u.LoaderUtils.resolveURL(c,this.path)}else s=u.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const a=function(c){n?n(c):console.error(c),r.manager.itemError(t),r.manager.itemEnd(t)},o=new u.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(c){try{r.parse(c,s,function(f){e(f),r.manager.itemEnd(t)},a)}catch(f){a(f)}},i,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,i,n){let r;const s={},a={},o=new TextDecoder;if(typeof t=="string")r=JSON.parse(t);else if(t instanceof ArrayBuffer)if(o.decode(new Uint8Array(t,0,4))===X){try{s[A.KHR_BINARY_GLTF]=new de(t)}catch(l){n&&n(l);return}r=JSON.parse(s[A.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(t));else r=t;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 c=new ye(r,{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 f=0;f<this.pluginCallbacks.length;f++){const l=this.pluginCallbacks[f](c);l.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[l.name]=l,s[l.name]=!0}if(r.extensionsUsed)for(let f=0;f<r.extensionsUsed.length;++f){const l=r.extensionsUsed[f],d=r.extensionsRequired||[];switch(l){case A.KHR_MATERIALS_UNLIT:s[l]=new Y;break;case A.KHR_DRACO_MESH_COMPRESSION:s[l]=new pe(r,this.dracoLoader);break;case A.KHR_TEXTURE_TRANSFORM:s[l]=new me;break;case A.KHR_MESH_QUANTIZATION:s[l]=new ge;break;default:d.indexOf(l)>=0&&a[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}c.setExtensions(s),c.setPlugins(a),c.parse(i,n)}parseAsync(t,e){const i=this;return new Promise(function(n,r){i.parse(t,e,n,r)})}}function W(){let h={};return{get:function(t){return h[t]},add:function(t,e){h[t]=e},remove:function(t){delete h[t]},removeAll:function(){h={}}}}const A={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 Q{constructor(t){this.parser=t,this.name=A.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let i=0,n=e.length;i<n;i++){const r=e[i];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const e=this.parser,i="light:"+t;let n=e.cache.get(i);if(n)return n;const r=e.json,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let c;const f=new u.Color(16777215);o.color!==void 0&&f.setRGB(o.color[0],o.color[1],o.color[2],u.LinearSRGBColorSpace);const l=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new u.DirectionalLight(f),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new u.PointLight(f),c.distance=l;break;case"spot":c=new u.SpotLight(f),c.distance=l,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),y(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(i,n),n}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,i=this.parser,r=i.json.nodes[t],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return i._getNodeRef(e.cache,a,o)})}}class Y{constructor(){this.name=A.KHR_MATERIALS_UNLIT}getMaterialType(){return u.MeshBasicMaterial}extendParams(t,e,i){const n=[];t.color=new u.Color(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const s=r.baseColorFactor;t.color.setRGB(s[0],s[1],s[2],u.LinearSRGBColorSpace),t.opacity=s[3]}r.baseColorTexture!==void 0&&n.push(i.assignTexture(t,"map",r.baseColorTexture,u.SRGBColorSpace))}return Promise.all(n)}}class Z{constructor(t){this.parser=t,this.name=A.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 r=n.extensions[this.name].emissiveStrength;return r!==void 0&&(e.emissiveIntensity=r),Promise.resolve()}}class J{constructor(t){this.parser=t,this.name=A.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&r.push(i.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&r.push(i.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(r.push(i.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const a=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new u.Vector2(a,a)}return Promise.all(r)}}class ${constructor(t){this.parser=t,this.name=A.KHR_MATERIALS_DISPERSION}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return e.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class ee{constructor(t){this.parser=t,this.name=A.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&r.push(i.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&r.push(i.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class te{constructor(t){this.parser=t,this.name=A.KHR_MATERIALS_SHEEN}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new u.Color(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=n.extensions[this.name];if(s.sheenColorFactor!==void 0){const a=s.sheenColorFactor;e.sheenColor.setRGB(a[0],a[1],a[2],u.LinearSRGBColorSpace)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&r.push(i.assignTexture(e,"sheenColorMap",s.sheenColorTexture,u.SRGBColorSpace)),s.sheenRoughnessTexture!==void 0&&r.push(i.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class ne{constructor(t){this.parser=t,this.name=A.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&r.push(i.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class se{constructor(t){this.parser=t,this.name=A.KHR_MATERIALS_VOLUME}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&r.push(i.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return e.attenuationColor=new u.Color().setRGB(a[0],a[1],a[2],u.LinearSRGBColorSpace),Promise.all(r)}}class re{constructor(t){this.parser=t,this.name=A.KHR_MATERIALS_IOR}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return e.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class ie{constructor(t){this.parser=t,this.name=A.KHR_MATERIALS_SPECULAR}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&r.push(i.assignTexture(e,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return e.specularColor=new u.Color().setRGB(a[0],a[1],a[2],u.LinearSRGBColorSpace),s.specularColorTexture!==void 0&&r.push(i.assignTexture(e,"specularColorMap",s.specularColorTexture,u.SRGBColorSpace)),Promise.all(r)}}class oe{constructor(t){this.parser=t,this.name=A.EXT_MATERIALS_BUMP}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&r.push(i.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(r)}}class ae{constructor(t){this.parser=t,this.name=A.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&r.push(i.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class ce{constructor(t){this.parser=t,this.name=A.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,i=e.json,n=i.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class le{constructor(t){this.parser=t,this.name=A.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(t,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.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 ue{constructor(t){this.parser=t,this.name=A.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(t,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.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 fe{constructor(t){this.name=A.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,i=e.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const n=i.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.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 r.then(function(a){const o=n.byteOffset||0,c=n.byteLength||0,f=n.count,l=n.byteStride,d=new Uint8Array(a,o,c);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(f,l,d,n.mode,n.filter).then(function(p){return p.buffer}):s.ready.then(function(){const p=new ArrayBuffer(f*l);return s.decodeGltfBuffer(new Uint8Array(p),f,l,d,n.mode,n.filter),p})})}else return null}}class he{constructor(t){this.name=A.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,i=e.nodes[t];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const n=e.meshes[i.mesh];for(const c of n.primitives)if(c.mode!==L.TRIANGLES&&c.mode!==L.TRIANGLE_STRIP&&c.mode!==L.TRIANGLE_FAN&&c.mode!==void 0)return null;const s=i.extensions[this.name].attributes,a=[],o={};for(const c in s)a.push(this.parser.getDependency("accessor",s[c]).then(f=>(o[c]=f,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{const f=c.pop(),l=f.isGroup?f.children:[f],d=c[0].count,p=[];for(const g of l){const R=new u.Matrix4,m=new u.Vector3,T=new u.Quaternion,E=new u.Vector3(1,1,1),M=new u.InstancedMesh(g.geometry,g.material,d);for(let x=0;x<d;x++)o.TRANSLATION&&m.fromBufferAttribute(o.TRANSLATION,x),o.ROTATION&&T.fromBufferAttribute(o.ROTATION,x),o.SCALE&&E.fromBufferAttribute(o.SCALE,x),M.setMatrixAt(x,R.compose(m,T,E));for(const x in o)if(x==="_COLOR_0"){const _=o[x];M.instanceColor=new u.InstancedBufferAttribute(_.array,_.itemSize,_.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&g.geometry.setAttribute(x,o[x]);u.Object3D.prototype.copy.call(M,g),this.parser.assignFinalMaterial(M),p.push(M)}return f.isGroup?(f.clear(),f.add(...p),f):p[0]}))}}const X="glTF",F=12,v={JSON:1313821514,BIN:5130562};class de{constructor(t){this.name=A.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,F),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==X)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-F,r=new DataView(t,F);let s=0;for(;s<n;){const a=r.getUint32(s,!0);s+=4;const o=r.getUint32(s,!0);if(s+=4,o===v.JSON){const c=new Uint8Array(t,F+s,a);this.content=i.decode(c)}else if(o===v.BIN){const c=F+s;this.body=t.slice(c,c+a)}s+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class pe{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=A.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const i=this.json,n=this.dracoLoader,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,a={},o={},c={};for(const f in s){const l=B[f]||f.toLowerCase();a[l]=s[f]}for(const f in t.attributes){const l=B[f]||f.toLowerCase();if(s[f]!==void 0){const d=i.accessors[t.attributes[f]],p=C[d.componentType];c[l]=p.name,o[l]=d.normalized===!0}}return e.getDependency("bufferView",r).then(function(f){return new Promise(function(l,d){n.decodeDracoFile(f,function(p){for(const g in p.attributes){const R=p.attributes[g],m=o[g];m!==void 0&&(R.normalized=m)}l(p)},a,c,u.LinearSRGBColorSpace,d)})})}}class me{constructor(){this.name=A.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 ge{constructor(){this.name=A.KHR_MESH_QUANTIZATION}}class z extends u.Interpolant{constructor(t,e,i,n){super(t,e,i,n)}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n*3+n;for(let s=0;s!==n;s++)e[s]=i[r+s];return e}interpolate_(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,f=n-e,l=(i-e)/f,d=l*l,p=d*l,g=t*c,R=g-c,m=-2*p+3*d,T=p-d,E=1-m,M=T-d+l;for(let x=0;x!==a;x++){const _=s[R+x+a],w=s[R+x+o]*f,S=s[g+x+a],O=s[g+x]*f;r[x]=E*_+M*w+m*S+T*O}return r}}const Ae=new u.Quaternion;class Te extends z{interpolate_(t,e,i,n){const r=super.interpolate_(t,e,i,n);return Ae.fromArray(r).normalize().toArray(r),r}}const L={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},C={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},j={9728:u.NearestFilter,9729:u.LinearFilter,9984:u.NearestMipmapNearestFilter,9985:u.LinearMipmapNearestFilter,9986:u.NearestMipmapLinearFilter,9987:u.LinearMipmapLinearFilter},K={33071:u.ClampToEdgeWrapping,33648:u.MirroredRepeatWrapping,10497:u.RepeatWrapping},P={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},B={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"},I={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Re={CUBICSPLINE:void 0,LINEAR:u.InterpolateLinear,STEP:u.InterpolateDiscrete},G={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function xe(h){return h.DefaultMaterial===void 0&&(h.DefaultMaterial=new u.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:u.FrontSide})),h.DefaultMaterial}function N(h,t,e){for(const i in e.extensions)h[i]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=e.extensions[i])}function y(h,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(h.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Ee(h,t,e){let i=!1,n=!1,r=!1;for(let c=0,f=t.length;c<f;c++){const l=t[c];if(l.POSITION!==void 0&&(i=!0),l.NORMAL!==void 0&&(n=!0),l.COLOR_0!==void 0&&(r=!0),i&&n&&r)break}if(!i&&!n&&!r)return Promise.resolve(h);const s=[],a=[],o=[];for(let c=0,f=t.length;c<f;c++){const l=t[c];if(i){const d=l.POSITION!==void 0?e.getDependency("accessor",l.POSITION):h.attributes.position;s.push(d)}if(n){const d=l.NORMAL!==void 0?e.getDependency("accessor",l.NORMAL):h.attributes.normal;a.push(d)}if(r){const d=l.COLOR_0!==void 0?e.getDependency("accessor",l.COLOR_0):h.attributes.color;o.push(d)}}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o)]).then(function(c){const f=c[0],l=c[1],d=c[2];return i&&(h.morphAttributes.position=f),n&&(h.morphAttributes.normal=l),r&&(h.morphAttributes.color=d),h.morphTargetsRelative=!0,h})}function Me(h,t){if(h.updateMorphTargets(),t.weights!==void 0)for(let e=0,i=t.weights.length;e<i;e++)h.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(h.morphTargetInfluences.length===e.length){h.morphTargetDictionary={};for(let i=0,n=e.length;i<n;i++)h.morphTargetDictionary[e[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Le(h){let t;const e=h.extensions&&h.extensions[A.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+k(e.attributes):t=h.indices+":"+k(h.attributes)+":"+h.mode,h.targets!==void 0)for(let i=0,n=h.targets.length;i<n;i++)t+=":"+k(h.targets[i]);return t}function k(h){let t="";const e=Object.keys(h).sort();for(let i=0,n=e.length;i<n;i++)t+=e[i]+":"+h[e[i]]+";";return t}function H(h){switch(h){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 Se(h){return h.search(/\.jpe?g($|\?)/i)>0||h.search(/^data\:image\/jpeg/)===0?"image/jpeg":h.search(/\.webp($|\?)/i)>0||h.search(/^data\:image\/webp/)===0?"image/webp":h.search(/\.ktx2($|\?)/i)>0||h.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const _e=new u.Matrix4;class ye{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new W,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 i=!1,n=-1,r=!1,s=-1;if(typeof navigator<"u"){const a=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);n=i&&o?parseInt(o[1],10):-1,r=a.indexOf("Firefox")>-1,s=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&n<17||r&&s<98?this.textureLoader=new u.TextureLoader(this.options.manager):this.textureLoader=new u.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new u.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 i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(s){const a={scene:s[0][n.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:n.asset,parser:i,userData:{}};return N(r,a,n),y(a,n),Promise.all(i._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||[],i=this.json.meshes||[];for(let n=0,r=e.length;n<r;n++){const s=e[n].joints;for(let a=0,o=s.length;a<o;a++)t[s[a]].isBone=!0}for(let n=0,r=t.length;n<r;n++){const s=t[n];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(i[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.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,i){if(t.refs[e]<=1)return i;const n=i.clone(),r=(s,a)=>{const o=this.associations.get(s);o!=null&&this.associations.set(a,o);for(const[c,f]of s.children.entries())r(f,a.children[c])};return r(i,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let i=0;i<e.length;i++){const n=t(e[i]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const i=[];for(let n=0;n<e.length;n++){const r=t(e[n]);r&&i.push(r)}return i}getDependency(t,e){const i=t+":"+e;let n=this.cache.get(i);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(r){return r.loadNode&&r.loadNode(e)});break;case"mesh":n=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t);break}this.cache.add(i,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const i=this,n=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(n.map(function(r,s){return i.getDependency(t,s)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],i=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[A.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(r,s){i.load(u.LoaderUtils.resolveURL(e.uri,n.path),r,void 0,function(){s(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(i){const n=e.byteLength||0,r=e.byteOffset||0;return i.slice(r,r+n)})}loadAccessor(t){const e=this,i=this.json,n=this.json.accessors[t];if(n.bufferView===void 0&&n.sparse===void 0){const s=P[n.type],a=C[n.componentType],o=n.normalized===!0,c=new a(n.count*s);return Promise.resolve(new u.BufferAttribute(c,s,o))}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(s){const a=s[0],o=P[n.type],c=C[n.componentType],f=c.BYTES_PER_ELEMENT,l=f*o,d=n.byteOffset||0,p=n.bufferView!==void 0?i.bufferViews[n.bufferView].byteStride:void 0,g=n.normalized===!0;let R,m;if(p&&p!==l){const T=Math.floor(d/p),E="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+T+":"+n.count;let M=e.cache.get(E);M||(R=new c(a,T*p,n.count*p/f),M=new u.InterleavedBuffer(R,p/f),e.cache.add(E,M)),m=new u.InterleavedBufferAttribute(M,o,d%p/f,g)}else a===null?R=new c(n.count*o):R=new c(a,d,n.count*o),m=new u.BufferAttribute(R,o,g);if(n.sparse!==void 0){const T=P.SCALAR,E=C[n.sparse.indices.componentType],M=n.sparse.indices.byteOffset||0,x=n.sparse.values.byteOffset||0,_=new E(s[1],M,n.sparse.count*T),w=new c(s[2],x,n.sparse.count*o);a!==null&&(m=new u.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let S=0,O=_.length;S<O;S++){const b=_[S];if(m.setX(b,w[S*o]),o>=2&&m.setY(b,w[S*o+1]),o>=3&&m.setZ(b,w[S*o+2]),o>=4&&m.setW(b,w[S*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(t){const e=this.json,i=this.options,r=e.textures[t].source,s=e.images[r];let a=this.textureLoader;if(s.uri){const o=i.manager.getHandler(s.uri);o!==null&&(a=o)}return this.loadTextureImage(t,r,a)}loadTextureImage(t,e,i){const n=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,i).then(function(f){f.flipY=!1,f.name=s.name||a.name||"",f.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(f.name=a.uri);const d=(r.samplers||{})[s.sampler]||{};return f.magFilter=j[d.magFilter]||u.LinearFilter,f.minFilter=j[d.minFilter]||u.LinearMipmapLinearFilter,f.wrapS=K[d.wrapS]||u.RepeatWrapping,f.wrapT=K[d.wrapT]||u.RepeatWrapping,f.generateMipmaps=!f.isCompressedTexture&&f.minFilter!==u.NearestFilter&&f.minFilter!==u.LinearFilter,n.associations.set(f,{textures:t}),f}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(t,e){const i=this,n=this.json,r=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(l=>l.clone());const s=n.images[t],a=self.URL||self.webkitURL;let o=s.uri||"",c=!1;if(s.bufferView!==void 0)o=i.getDependency("bufferView",s.bufferView).then(function(l){c=!0;const d=new Blob([l],{type:s.mimeType});return o=a.createObjectURL(d),o});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const f=Promise.resolve(o).then(function(l){return new Promise(function(d,p){let g=d;e.isImageBitmapLoader===!0&&(g=function(R){const m=new u.Texture(R);m.needsUpdate=!0,d(m)}),e.load(u.LoaderUtils.resolveURL(l,r.path),g,void 0,p)})}).then(function(l){return c===!0&&a.revokeObjectURL(o),y(l,s),l.userData.mimeType=s.mimeType||Se(s.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),l});return this.sourceCache[t]=f,f}assignTexture(t,e,i,n){const r=this;return this.getDependency("texture",i.index).then(function(s){if(!s)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(s=s.clone(),s.channel=i.texCoord),r.extensions[A.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[A.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=r.associations.get(s);s=r.extensions[A.KHR_TEXTURE_TRANSFORM].extendTexture(s,a),r.associations.set(s,o)}}return n!==void 0&&(s.colorSpace=n),t[e]=s,s})}assignFinalMaterial(t){const e=t.geometry;let i=t.material;const n=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,s=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+i.uuid;let o=this.cache.get(a);o||(o=new u.PointsMaterial,u.Material.prototype.copy.call(o,i),o.color.copy(i.color),o.map=i.map,o.sizeAttenuation=!1,this.cache.add(a,o)),i=o}else if(t.isLine){const a="LineBasicMaterial:"+i.uuid;let o=this.cache.get(a);o||(o=new u.LineBasicMaterial,u.Material.prototype.copy.call(o,i),o.color.copy(i.color),o.map=i.map,this.cache.add(a,o)),i=o}if(n||r||s){let a="ClonedMaterial:"+i.uuid+":";n&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),s&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=i.clone(),r&&(o.vertexColors=!0),s&&(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(i))),i=o}t.material=i}getMaterialType(){return u.MeshStandardMaterial}loadMaterial(t){const e=this,i=this.json,n=this.extensions,r=i.materials[t];let s;const a={},o=r.extensions||{},c=[];if(o[A.KHR_MATERIALS_UNLIT]){const l=n[A.KHR_MATERIALS_UNLIT];s=l.getMaterialType(),c.push(l.extendParams(a,r,e))}else{const l=r.pbrMetallicRoughness||{};if(a.color=new u.Color(1,1,1),a.opacity=1,Array.isArray(l.baseColorFactor)){const d=l.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],u.LinearSRGBColorSpace),a.opacity=d[3]}l.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",l.baseColorTexture,u.SRGBColorSpace)),a.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,a.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",l.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",l.metallicRoughnessTexture))),s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(t,a)})))}r.doubleSided===!0&&(a.side=u.DoubleSide);const f=r.alphaMode||G.OPAQUE;if(f===G.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,f===G.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&s!==u.MeshBasicMaterial&&(c.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new u.Vector2(1,1),r.normalTexture.scale!==void 0)){const l=r.normalTexture.scale;a.normalScale.set(l,l)}if(r.occlusionTexture!==void 0&&s!==u.MeshBasicMaterial&&(c.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&s!==u.MeshBasicMaterial){const l=r.emissiveFactor;a.emissive=new u.Color().setRGB(l[0],l[1],l[2],u.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&s!==u.MeshBasicMaterial&&c.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,u.SRGBColorSpace)),Promise.all(c).then(function(){const l=new s(a);return r.name&&(l.name=r.name),y(l,r),e.associations.set(l,{materials:t}),r.extensions&&N(n,l,r),l})}createUniqueName(t){const e=u.PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,i=this.extensions,n=this.primitiveCache;function r(a){return i[A.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return V(o,a,e)})}const s=[];for(let a=0,o=t.length;a<o;a++){const c=t[a],f=Le(c),l=n[f];if(l)s.push(l.promise);else{let d;c.extensions&&c.extensions[A.KHR_DRACO_MESH_COMPRESSION]?d=r(c):d=V(new u.BufferGeometry,c,e),n[f]={primitive:c,promise:d},s.push(d)}}return Promise.all(s)}loadMesh(t){const e=this,i=this.json,n=this.extensions,r=i.meshes[t],s=r.primitives,a=[];for(let o=0,c=s.length;o<c;o++){const f=s[o].material===void 0?xe(this.cache):this.getDependency("material",s[o].material);a.push(f)}return a.push(e.loadGeometries(s)),Promise.all(a).then(function(o){const c=o.slice(0,o.length-1),f=o[o.length-1],l=[];for(let p=0,g=f.length;p<g;p++){const R=f[p],m=s[p];let T;const E=c[p];if(m.mode===L.TRIANGLES||m.mode===L.TRIANGLE_STRIP||m.mode===L.TRIANGLE_FAN||m.mode===void 0)T=r.isSkinnedMesh===!0?new u.SkinnedMesh(R,E):new u.Mesh(R,E),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),m.mode===L.TRIANGLE_STRIP?T.geometry=U(T.geometry,u.TriangleStripDrawMode):m.mode===L.TRIANGLE_FAN&&(T.geometry=U(T.geometry,u.TriangleFanDrawMode));else if(m.mode===L.LINES)T=new u.LineSegments(R,E);else if(m.mode===L.LINE_STRIP)T=new u.Line(R,E);else if(m.mode===L.LINE_LOOP)T=new u.LineLoop(R,E);else if(m.mode===L.POINTS)T=new u.Points(R,E);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(T.geometry.morphAttributes).length>0&&Me(T,r),T.name=e.createUniqueName(r.name||"mesh_"+t),y(T,r),m.extensions&&N(n,T,m),e.assignFinalMaterial(T),l.push(T)}for(let p=0,g=l.length;p<g;p++)e.associations.set(l[p],{meshes:t,primitives:p});if(l.length===1)return r.extensions&&N(n,l[0],r),l[0];const d=new u.Group;r.extensions&&N(n,d,r),e.associations.set(d,{meshes:t});for(let p=0,g=l.length;p<g;p++)d.add(l[p]);return d})}loadCamera(t){let e;const i=this.json.cameras[t],n=i[i.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?e=new u.PerspectiveCamera(u.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):i.type==="orthographic"&&(e=new u.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(e.name=this.createUniqueName(i.name)),y(e,i),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],i=[];for(let n=0,r=e.joints.length;n<r;n++)i.push(this._loadNodeShallow(e.joints[n]));return e.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",e.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(n){const r=n.pop(),s=n,a=[],o=[];for(let c=0,f=s.length;c<f;c++){const l=s[c];if(l){a.push(l);const d=new u.Matrix4;r!==null&&d.fromArray(r.array,c*16),o.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new u.Skeleton(a,o)})}loadAnimation(t){const e=this.json,i=this,n=e.animations[t],r=n.name?n.name:"animation_"+t,s=[],a=[],o=[],c=[],f=[];for(let l=0,d=n.channels.length;l<d;l++){const p=n.channels[l],g=n.samplers[p.sampler],R=p.target,m=R.node,T=n.parameters!==void 0?n.parameters[g.input]:g.input,E=n.parameters!==void 0?n.parameters[g.output]:g.output;R.node!==void 0&&(s.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",T)),o.push(this.getDependency("accessor",E)),c.push(g),f.push(R))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(f)]).then(function(l){const d=l[0],p=l[1],g=l[2],R=l[3],m=l[4],T=[];for(let E=0,M=d.length;E<M;E++){const x=d[E],_=p[E],w=g[E],S=R[E],O=m[E];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const b=i._createAnimationTracks(x,_,w,S,O);if(b)for(let D=0;D<b.length;D++)T.push(b[D])}return new u.AnimationClip(r,void 0,T)})}createNodeMesh(t){const e=this.json,i=this,n=e.nodes[t];return n.mesh===void 0?null:i.getDependency("mesh",n.mesh).then(function(r){const s=i._getNodeRef(i.meshCache,n.mesh,r);return n.weights!==void 0&&s.traverse(function(a){if(a.isMesh)for(let o=0,c=n.weights.length;o<c;o++)a.morphTargetInfluences[o]=n.weights[o]}),s})}loadNode(t){const e=this.json,i=this,n=e.nodes[t],r=i._loadNodeShallow(t),s=[],a=n.children||[];for(let c=0,f=a.length;c<f;c++)s.push(i.getDependency("node",a[c]));const o=n.skin===void 0?Promise.resolve(null):i.getDependency("skin",n.skin);return Promise.all([r,Promise.all(s),o]).then(function(c){const f=c[0],l=c[1],d=c[2];d!==null&&f.traverse(function(p){p.isSkinnedMesh&&p.bind(d,_e)});for(let p=0,g=l.length;p<g;p++)f.add(l[p]);return f})}_loadNodeShallow(t){const e=this.json,i=this.extensions,n=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const r=e.nodes[t],s=r.name?n.createUniqueName(r.name):"",a=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(t)});return o&&a.push(o),r.camera!==void 0&&a.push(n.getDependency("camera",r.camera).then(function(c){return n._getNodeRef(n.cameraCache,r.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 f;if(r.isBone===!0?f=new u.Bone:c.length>1?f=new u.Group:c.length===1?f=c[0]:f=new u.Object3D,f!==c[0])for(let l=0,d=c.length;l<d;l++)f.add(c[l]);if(r.name&&(f.userData.name=r.name,f.name=s),y(f,r),r.extensions&&N(i,f,r),r.matrix!==void 0){const l=new u.Matrix4;l.fromArray(r.matrix),f.applyMatrix4(l)}else r.translation!==void 0&&f.position.fromArray(r.translation),r.rotation!==void 0&&f.quaternion.fromArray(r.rotation),r.scale!==void 0&&f.scale.fromArray(r.scale);return n.associations.has(f)||n.associations.set(f,{}),n.associations.get(f).nodes=t,f}),this.nodeCache[t]}loadScene(t){const e=this.extensions,i=this.json.scenes[t],n=this,r=new u.Group;i.name&&(r.name=n.createUniqueName(i.name)),y(r,i),i.extensions&&N(e,r,i);const s=i.nodes||[],a=[];for(let o=0,c=s.length;o<c;o++)a.push(n.getDependency("node",s[o]));return Promise.all(a).then(function(o){for(let f=0,l=o.length;f<l;f++)r.add(o[f]);const c=f=>{const l=new Map;for(const[d,p]of n.associations)(d instanceof u.Material||d instanceof u.Texture)&&l.set(d,p);return f.traverse(d=>{const p=n.associations.get(d);p!=null&&l.set(d,p)}),l};return n.associations=c(r),r})}_createAnimationTracks(t,e,i,n,r){const s=[],a=t.name?t.name:t.uuid,o=[];I[r.path]===I.weights?t.traverse(function(d){d.morphTargetInfluences&&o.push(d.name?d.name:d.uuid)}):o.push(a);let c;switch(I[r.path]){case I.weights:c=u.NumberKeyframeTrack;break;case I.rotation:c=u.QuaternionKeyframeTrack;break;case I.position:case I.scale:c=u.VectorKeyframeTrack;break;default:switch(i.itemSize){case 1:c=u.NumberKeyframeTrack;break;case 2:case 3:default:c=u.VectorKeyframeTrack;break}break}const f=n.interpolation!==void 0?Re[n.interpolation]:u.InterpolateLinear,l=this._getArrayFromAccessor(i);for(let d=0,p=o.length;d<p;d++){const g=new c(o[d]+"."+I[r.path],e.array,l,f);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),s.push(g)}return s}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const i=H(e.constructor),n=new Float32Array(e.length);for(let r=0,s=e.length;r<s;r++)n[r]=e[r]*i;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(i){const n=this instanceof u.QuaternionKeyframeTrack?Te:z;return new n(this.times,this.values,this.getValueSize()/3,i)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function we(h,t,e){const i=t.attributes,n=new u.Box3;if(i.POSITION!==void 0){const a=e.json.accessors[i.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(n.set(new u.Vector3(o[0],o[1],o[2]),new u.Vector3(c[0],c[1],c[2])),a.normalized){const f=H(C[a.componentType]);n.min.multiplyScalar(f),n.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=t.targets;if(r!==void 0){const a=new u.Vector3,o=new u.Vector3;for(let c=0,f=r.length;c<f;c++){const l=r[c];if(l.POSITION!==void 0){const d=e.json.accessors[l.POSITION],p=d.min,g=d.max;if(p!==void 0&&g!==void 0){if(o.setX(Math.max(Math.abs(p[0]),Math.abs(g[0]))),o.setY(Math.max(Math.abs(p[1]),Math.abs(g[1]))),o.setZ(Math.max(Math.abs(p[2]),Math.abs(g[2]))),d.normalized){const R=H(C[d.componentType]);o.multiplyScalar(R)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}h.boundingBox=n;const s=new u.Sphere;n.getCenter(s.center),s.radius=n.min.distanceTo(n.max)/2,h.boundingSphere=s}function V(h,t,e){const i=t.attributes,n=[];function r(s,a){return e.getDependency("accessor",s).then(function(o){h.setAttribute(a,o)})}for(const s in i){const a=B[s]||s.toLowerCase();a in h.attributes||n.push(r(i[s],a))}if(t.indices!==void 0&&!h.index){const s=e.getDependency("accessor",t.indices).then(function(a){h.setIndex(a)});n.push(s)}return u.ColorManagement.workingColorSpace!==u.LinearSRGBColorSpace&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${u.ColorManagement.workingColorSpace}" not supported.`),y(h,t),we(h,t,e),Promise.all(n).then(function(){return t.targets!==void 0?Ee(h,t.targets,e):h})}exports.GLTFLoader=q;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useFrame as q, useThree as Q, useLoader as Z } from "@react-three/fiber";
|
|
2
|
+
import { useMemo as F, useRef as u, useEffect as $, useState as W } from "react";
|
|
3
|
+
import * as d from "three";
|
|
4
|
+
import { s as V, T as ee } from "./index-Dw6tj2Mi.js";
|
|
5
|
+
import { X as te, u as re, F as ne, i as se, n as B } from "./index-CnGox6Xr.js";
|
|
6
|
+
import { c as oe, I as ce, u as H, a as ae, b as ie, r as ue } from "./providers-C0Dlhh9Z.js";
|
|
7
|
+
import { u as de } from "./index-CsUdQ-pn.js";
|
|
8
|
+
import { jsx as j, jsxs as le } from "react/jsx-runtime";
|
|
9
|
+
import { u as fe, R as me } from "./selectors-C5G1PMYL.js";
|
|
10
|
+
import { r as pe } from "./landmarkMask-CbTFzBYG.js";
|
|
11
|
+
const D = () => ({
|
|
12
|
+
pos: new d.Vector3(),
|
|
13
|
+
prevRaw: new d.Vector3(),
|
|
14
|
+
dxHat: new d.Vector3(),
|
|
15
|
+
initialized: !1
|
|
16
|
+
}), Ce = ({
|
|
17
|
+
faceIndex: l = 0,
|
|
18
|
+
numFaces: v,
|
|
19
|
+
active: f = !0,
|
|
20
|
+
targetFps: y,
|
|
21
|
+
holdMs: m = 250,
|
|
22
|
+
predictMs: C = 0,
|
|
23
|
+
smoothing: p = 0,
|
|
24
|
+
leadMs: z = 80
|
|
25
|
+
} = {}) => {
|
|
26
|
+
const r = Number.isFinite(l) ? Math.max(0, Math.round(l)) : 0, n = Math.max(v ?? r + 1, r + 1), N = F(
|
|
27
|
+
() => ({
|
|
28
|
+
numFaces: n,
|
|
29
|
+
...y !== void 0 && y > 0 ? { targetFps: y } : {}
|
|
30
|
+
}),
|
|
31
|
+
[n, y]
|
|
32
|
+
), { node: s, ready: M, error: A } = de(
|
|
33
|
+
te.FACE_TRACKER,
|
|
34
|
+
N,
|
|
35
|
+
f
|
|
36
|
+
), { session: c } = re(), t = F(() => oe(r), [r]), S = u(null);
|
|
37
|
+
S.current || (S.current = new ne({ holdMs: m, predictMs: C })), $(() => {
|
|
38
|
+
var x;
|
|
39
|
+
(x = S.current) == null || x.setOptions({ holdMs: Math.max(0, m), predictMs: Math.max(0, C) });
|
|
40
|
+
}, [m, C]);
|
|
41
|
+
const k = u({
|
|
42
|
+
left: { center: D(), radius: D() },
|
|
43
|
+
right: { center: D(), radius: D() }
|
|
44
|
+
}), h = u(new d.Vector3()), g = u(new ce()), b = u(null), L = u(-1 / 0), a = u(!1), [R, o] = W("loading");
|
|
45
|
+
return q((x, E) => {
|
|
46
|
+
var U;
|
|
47
|
+
const G = A ? "error" : M && s ? "ready" : "loading";
|
|
48
|
+
G !== R && o(G);
|
|
49
|
+
const T = performance.now(), I = f && s ? s.getDetectionResults() : void 0, X = (U = I == null ? void 0 : I.faceLandmarks) == null ? void 0 : U[r], _ = X && X.length > 0 ? X : void 0, K = S.current.update(_ ? [_] : [], T)[0];
|
|
50
|
+
if (!K) {
|
|
51
|
+
(t.detected || t.version === 0) && H(t, void 0, T, { faceIndex: r }), a.current = !1, g.current.reset();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const O = !_;
|
|
55
|
+
O || (L.current = T);
|
|
56
|
+
const Y = O ? Math.max(0, m > 0 ? 1 - (T - L.current) / m : 0) : 1, J = se(c.store.getSnapshot().sourceKind);
|
|
57
|
+
if (H(t, K, T, { faceIndex: r, held: O, faceConfidence: Y, mirrored: J }), t.detected && !O) {
|
|
58
|
+
const P = I !== b.current;
|
|
59
|
+
b.current = I, a.current || g.current.reset();
|
|
60
|
+
for (const w of ["left", "right"]) {
|
|
61
|
+
const e = t[w];
|
|
62
|
+
P && g.current.observe(w, e.center, T), g.current.apply(w, T, z, e.center), B(e.center, e.trackerCenter);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (p > 0 && t.detected) {
|
|
66
|
+
const P = !a.current;
|
|
67
|
+
for (const w of ["left", "right"]) {
|
|
68
|
+
const e = t[w], i = k.current[w];
|
|
69
|
+
P && (i.center.initialized = !1, i.radius.initialized = !1), h.current.set(e.center.x, e.center.y, e.center.z), V(i.center, h.current, E, p), e.center.x = i.center.pos.x, e.center.y = i.center.pos.y, e.center.z = i.center.pos.z, B(e.center, e.trackerCenter), h.current.set(e.radius, 0, 0), V(i.radius, h.current, E, p), e.radius = i.radius.pos.x;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
a.current = t.detected;
|
|
73
|
+
}), { result: t, ready: M && R === "ready", status: R, error: A };
|
|
74
|
+
}, Me = ({
|
|
75
|
+
mask: l,
|
|
76
|
+
texture: v,
|
|
77
|
+
material: f,
|
|
78
|
+
renderOrder: y = me.BACKGROUND + 10,
|
|
79
|
+
visible: m = !0,
|
|
80
|
+
...C
|
|
81
|
+
}) => {
|
|
82
|
+
const p = pe(C), { camera: z, size: r } = Q(), n = fe() ?? null, N = Z(
|
|
83
|
+
d.TextureLoader,
|
|
84
|
+
typeof v == "string" ? v : ee
|
|
85
|
+
), s = typeof v == "string" ? N : v ?? null;
|
|
86
|
+
s && s.colorSpace !== d.SRGBColorSpace && (s.colorSpace = d.SRGBColorSpace, s.needsUpdate = !0);
|
|
87
|
+
const { holder: M, sync: A } = ae(l), c = n == null ? void 0 : n.image, t = (c == null ? void 0 : c.width) ?? 0, S = (c == null ? void 0 : c.height) ?? 0, k = ie({
|
|
88
|
+
cameraTexture: n,
|
|
89
|
+
maskTexture: M.texture,
|
|
90
|
+
mask: l,
|
|
91
|
+
settings: p,
|
|
92
|
+
designTexture: s,
|
|
93
|
+
feedWidth: t,
|
|
94
|
+
feedHeight: S
|
|
95
|
+
}), h = u(null), [, g] = W(0);
|
|
96
|
+
q(() => {
|
|
97
|
+
const o = A();
|
|
98
|
+
h.current !== o && (h.current = o, k.uniforms.maskTexture.value = o, g((x) => x + 1));
|
|
99
|
+
});
|
|
100
|
+
const b = F(() => {
|
|
101
|
+
const o = z;
|
|
102
|
+
if (!o.isPerspectiveCamera) return [10, 10];
|
|
103
|
+
const x = (o.position.z || 5) + 1, E = 2 * Math.tan(o.fov * Math.PI / 360) * x;
|
|
104
|
+
return [E * (r.width / r.height), E];
|
|
105
|
+
}, [z, r]);
|
|
106
|
+
if (!n || !m) return null;
|
|
107
|
+
const L = {
|
|
108
|
+
cameraTexture: n,
|
|
109
|
+
maskTexture: M.texture,
|
|
110
|
+
maskTransform: k.uniforms.maskTransform.value,
|
|
111
|
+
// Empty until the mask has data, exactly like the built-in material.
|
|
112
|
+
labelIndices: ue(l, p.label),
|
|
113
|
+
mask: l,
|
|
114
|
+
settings: p
|
|
115
|
+
}, a = f ? typeof f == "function" ? f(L) : f : k, R = a instanceof d.Material ? a : void 0;
|
|
116
|
+
return /* @__PURE__ */ j("group", { position: [0, 0, -1], children: /* @__PURE__ */ le(
|
|
117
|
+
"mesh",
|
|
118
|
+
{
|
|
119
|
+
renderOrder: y,
|
|
120
|
+
frustumCulled: !1,
|
|
121
|
+
material: R,
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ j("planeGeometry", { args: b }),
|
|
124
|
+
R ? null : a
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
R ? "instance" : "node"
|
|
128
|
+
) });
|
|
129
|
+
};
|
|
130
|
+
export {
|
|
131
|
+
Me as S,
|
|
132
|
+
Ce as u
|
|
133
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const D=require("@react-three/fiber"),t=require("react"),Y=require("three"),H=require("./index-DsZwTfG0.cjs"),b=require("./index-CeVkgsag.cjs"),S=require("./providers-YNwkmNeK.cjs"),J=require("./index-OCPjOaeP.cjs"),G=require("react/jsx-runtime"),B=require("./selectors-Du_PsVnW.cjs"),Q=require("./landmarkMask-u7es2k4X.cjs");function Z(r){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const n in r)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(o,n,i.get?i:{enumerable:!0,get:()=>r[n]})}}return o.default=r,Object.freeze(o)}const p=Z(Y),j=()=>({pos:new p.Vector3,prevRaw:new p.Vector3,dxHat:new p.Vector3,initialized:!1}),ee=({faceIndex:r=0,numFaces:o,active:n=!0,targetFps:i,holdMs:R=250,predictMs:w=0,smoothing:T=0,leadMs:I=80}={})=>{const c=Number.isFinite(r)?Math.max(0,Math.round(r)):0,a=Math.max(o??c+1,c+1),L=t.useMemo(()=>({numFaces:a,...i!==void 0&&i>0?{targetFps:i}:{}}),[a,i]),{node:u,ready:E,error:z}=J.useXRModel(b.XRModel.FACE_TRACKER,L,n),{session:l}=b.useXRContext(),s=t.useMemo(()=>S.createIrisResult(c),[c]),v=t.useRef(null);v.current||(v.current=new b.FaceTrackMemory({holdMs:R,predictMs:w})),t.useEffect(()=>{var h;(h=v.current)==null||h.setOptions({holdMs:Math.max(0,R),predictMs:Math.max(0,w)})},[R,w]);const C=t.useRef({left:{center:j(),radius:j()},right:{center:j(),radius:j()}}),g=t.useRef(new p.Vector3),k=t.useRef(new S.IrisLead),A=t.useRef(null),P=t.useRef(-1/0),f=t.useRef(!1),[x,d]=t.useState("loading");return D.useFrame((h,O)=>{var V;const K=z?"error":E&&u?"ready":"loading";K!==x&&d(K);const y=performance.now(),q=n&&u?u.getDetectionResults():void 0,N=(V=q==null?void 0:q.faceLandmarks)==null?void 0:V[c],X=N&&N.length>0?N:void 0,U=v.current.update(X?[X]:[],y)[0];if(!U){(s.detected||s.version===0)&&S.updateIrisResult(s,void 0,y,{faceIndex:c}),f.current=!1,k.current.reset();return}const _=!X;_||(P.current=y);const $=_?Math.max(0,R>0?1-(y-P.current)/R:0):1,W=b.isMirroredSourceKind(l.store.getSnapshot().sourceKind);if(S.updateIrisResult(s,U,y,{faceIndex:c,held:_,faceConfidence:$,mirrored:W}),s.detected&&!_){const F=q!==A.current;A.current=q,f.current||k.current.reset();for(const M of["left","right"]){const e=s[M];F&&k.current.observe(M,e.center,y),k.current.apply(M,y,I,e.center),b.normalizedTrackerPointToTrackerPoint(e.center,e.trackerCenter)}}if(T>0&&s.detected){const F=!f.current;for(const M of["left","right"]){const e=s[M],m=C.current[M];F&&(m.center.initialized=!1,m.radius.initialized=!1),g.current.set(e.center.x,e.center.y,e.center.z),H.stepTrackingSmoothing(m.center,g.current,O,T),e.center.x=m.center.pos.x,e.center.y=m.center.pos.y,e.center.z=m.center.pos.z,b.normalizedTrackerPointToTrackerPoint(e.center,e.trackerCenter),g.current.set(e.radius,0,0),H.stepTrackingSmoothing(m.radius,g.current,O,T),e.radius=m.radius.pos.x}}f.current=s.detected}),{result:s,ready:E&&x==="ready",status:x,error:z}},te=({mask:r,texture:o,material:n,renderOrder:i=B.RENDER_LAYERS.BACKGROUND+10,visible:R=!0,...w})=>{const T=Q.resolveSegmentationOverlaySettings(w),{camera:I,size:c}=D.useThree(),a=B.useXRCameraTexture()??null,L=D.useLoader(p.TextureLoader,typeof o=="string"?o:H.TRANSPARENT_TEXTURE_DATA_URL),u=typeof o=="string"?L:o??null;u&&u.colorSpace!==p.SRGBColorSpace&&(u.colorSpace=p.SRGBColorSpace,u.needsUpdate=!0);const{holder:E,sync:z}=S.useSemanticMaskTexture(r),l=a==null?void 0:a.image,s=(l==null?void 0:l.width)??0,v=(l==null?void 0:l.height)??0,C=S.useSegmentationOverlayMaterial({cameraTexture:a,maskTexture:E.texture,mask:r,settings:T,designTexture:u,feedWidth:s,feedHeight:v}),g=t.useRef(null),[,k]=t.useState(0);D.useFrame(()=>{const d=z();g.current!==d&&(g.current=d,C.uniforms.maskTexture.value=d,k(h=>h+1))});const A=t.useMemo(()=>{const d=I;if(!d.isPerspectiveCamera)return[10,10];const h=(d.position.z||5)+1,O=2*Math.tan(d.fov*Math.PI/360)*h;return[O*(c.width/c.height),O]},[I,c]);if(!a||!R)return null;const P={cameraTexture:a,maskTexture:E.texture,maskTransform:C.uniforms.maskTransform.value,labelIndices:S.resolveActiveOverlayLabelIndices(r,T.label),mask:r,settings:T},f=n?typeof n=="function"?n(P):n:C,x=f instanceof p.Material?f:void 0;return G.jsx("group",{position:[0,0,-1],children:G.jsxs("mesh",{renderOrder:i,frustumCulled:!1,material:x,children:[G.jsx("planeGeometry",{args:A}),x?null:f]},x?"instance":"node")})};exports.SegmentationOverlay=te;exports.useIrisTracking=ee;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refcounted, deduplicating asset cache with a byte budget.
|
|
3
|
+
*
|
|
4
|
+
* One entry per `key`. The first `acquire` starts the load; concurrent
|
|
5
|
+
* acquires share the in-flight promise; owners are tracked by id so a
|
|
6
|
+
* re-render or a StrictMode double mount never double-counts. When the last
|
|
7
|
+
* owner releases, the value stays cached (unreferenced) until the budget
|
|
8
|
+
* needs room, `disposeUnreferenced()`, or `disposeAll()`. Only unreferenced
|
|
9
|
+
* entries are ever evicted, least recently used first, and each value is
|
|
10
|
+
* disposed exactly once.
|
|
11
|
+
*/
|
|
12
|
+
export type XRAssetDefinition<T> = {
|
|
13
|
+
/** Cache identity (usually the URL plus any option that changes the bytes). */
|
|
14
|
+
key: string;
|
|
15
|
+
/** Produce the value. Honour `signal` to stop a load nobody wants any more. */
|
|
16
|
+
load: (signal: AbortSignal) => Promise<T>;
|
|
17
|
+
/** Release GPU / media resources. Called exactly once per loaded value. */
|
|
18
|
+
dispose?: (value: T) => void;
|
|
19
|
+
/** Estimated resident bytes (GPU + CPU) for the budget; default 0. */
|
|
20
|
+
bytes?: (value: T) => number;
|
|
21
|
+
};
|
|
22
|
+
export type XRAssetStatus = "idle" | "loading" | "ready" | "error";
|
|
23
|
+
export type XRAssetEntryInfo = {
|
|
24
|
+
key: string;
|
|
25
|
+
status: XRAssetStatus;
|
|
26
|
+
bytes: number;
|
|
27
|
+
owners: number;
|
|
28
|
+
/** `performance.now()` of the last acquire / release. */
|
|
29
|
+
lastUsed: number;
|
|
30
|
+
error: Error | null;
|
|
31
|
+
};
|
|
32
|
+
export type XRAssetStats = {
|
|
33
|
+
assets: number;
|
|
34
|
+
referencedAssets: number;
|
|
35
|
+
loadingAssets: number;
|
|
36
|
+
erroredAssets: number;
|
|
37
|
+
/** Bytes of every loaded value, referenced or not. */
|
|
38
|
+
usageBytes: number;
|
|
39
|
+
/** Bytes held by unreferenced values (what eviction can reclaim). */
|
|
40
|
+
reclaimableBytes: number;
|
|
41
|
+
budgetBytes: number;
|
|
42
|
+
overBudget: boolean;
|
|
43
|
+
/** Values disposed by `evict()` — budget pressure or an explicit call — since creation. `disposeUnreferenced` / `disposeAll` do not count. */
|
|
44
|
+
evictions: number;
|
|
45
|
+
/** Loads served from an existing entry (hit) vs started (miss). */
|
|
46
|
+
hits: number;
|
|
47
|
+
misses: number;
|
|
48
|
+
};
|
|
49
|
+
export type XRAssetCacheOptions = {
|
|
50
|
+
/** Byte budget; eviction of unreferenced values starts above it. Default 256 MiB. `Infinity` disables. */
|
|
51
|
+
budgetBytes?: number;
|
|
52
|
+
/** Clock for `lastUsed` (tests). */
|
|
53
|
+
now?: () => number;
|
|
54
|
+
};
|
|
55
|
+
export declare const DEFAULT_ASSET_BUDGET_BYTES: number;
|
|
56
|
+
export declare class XRAssetCache {
|
|
57
|
+
private entries;
|
|
58
|
+
private listeners;
|
|
59
|
+
private budget;
|
|
60
|
+
private readonly now;
|
|
61
|
+
private evictions;
|
|
62
|
+
private hits;
|
|
63
|
+
private misses;
|
|
64
|
+
/** Memoised `getStats()` result; cleared on every change so `useSyncExternalStore` sees a stable snapshot. */
|
|
65
|
+
private statsSnapshot;
|
|
66
|
+
constructor(options?: XRAssetCacheOptions);
|
|
67
|
+
/** Acquire `asset` on behalf of `ownerId`; shares an in-flight or loaded value. */
|
|
68
|
+
acquire<T>(asset: XRAssetDefinition<T>, ownerId: string): Promise<T>;
|
|
69
|
+
/** Start loading without holding a reference (warm the cache). */
|
|
70
|
+
preload<T>(asset: XRAssetDefinition<T>): Promise<T>;
|
|
71
|
+
/** Drop `ownerId`'s reference. The value stays cached until evicted or disposed. */
|
|
72
|
+
release(key: string, ownerId: string): void;
|
|
73
|
+
/** Synchronous read of a loaded value (or `undefined`). Does not take a reference. */
|
|
74
|
+
get<T>(key: string): T | undefined;
|
|
75
|
+
has(key: string): boolean;
|
|
76
|
+
entry(key: string): XRAssetEntryInfo | undefined;
|
|
77
|
+
list(): XRAssetEntryInfo[];
|
|
78
|
+
setBudget(bytes: number): void;
|
|
79
|
+
/**
|
|
80
|
+
* Dispose unreferenced values, least recently used first, until usage is
|
|
81
|
+
* within the budget (or `bytesToFree` is reclaimed). Referenced values are
|
|
82
|
+
* never touched. Returns the bytes reclaimed.
|
|
83
|
+
*/
|
|
84
|
+
evict(bytesToFree?: number): number;
|
|
85
|
+
/** Dispose every unreferenced value (route change, scene teardown). Returns the bytes freed. */
|
|
86
|
+
disposeUnreferenced(): number;
|
|
87
|
+
/** Dispose everything, referenced or not (app / session shutdown). Owners are forgotten. */
|
|
88
|
+
disposeAll(): void;
|
|
89
|
+
/** Current statistics. The object is reused until the cache changes, so it is safe as a store snapshot. */
|
|
90
|
+
getStats(): XRAssetStats;
|
|
91
|
+
subscribe(listener: () => void): () => void;
|
|
92
|
+
private usage;
|
|
93
|
+
private enforceBudget;
|
|
94
|
+
private disposeEntry;
|
|
95
|
+
private notify;
|
|
96
|
+
}
|
|
97
|
+
export declare const createAssetCache: (options?: XRAssetCacheOptions) => XRAssetCache;
|
|
98
|
+
/** The app-wide cache `useXRAsset` uses when no `<XRAssetCacheProvider>` is mounted. */
|
|
99
|
+
export declare const getDefaultAssetCache: () => XRAssetCache;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
/** Resident bytes of a texture (RGBA, mip chain included when generated); 0 for an unloaded image. */
|
|
3
|
+
export declare const estimateTextureBytes: (texture: THREE.Texture | null | undefined) => number;
|
|
4
|
+
/** Bytes of every attribute buffer (and the index) of a geometry. */
|
|
5
|
+
export declare const estimateGeometryBytes: (geometry: THREE.BufferGeometry | null | undefined) => number;
|
|
6
|
+
/** Textures a material references (de-duplicated by the caller). */
|
|
7
|
+
export declare const materialTextures: (material: THREE.Material) => THREE.Texture[];
|
|
8
|
+
/** Sum of the geometries and textures reachable from an object, each counted once. */
|
|
9
|
+
export declare const estimateObjectBytes: (object: THREE.Object3D | null | undefined) => number;
|
|
10
|
+
/** Dispose every geometry, material and texture reachable from an object, each once. */
|
|
11
|
+
export declare const disposeObject3D: (object: THREE.Object3D | null | undefined) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DEFAULT_ASSET_BUDGET_BYTES, XRAssetCache, createAssetCache, getDefaultAssetCache, } from './cache';
|
|
2
|
+
export type { XRAssetCacheOptions, XRAssetDefinition, XRAssetEntryInfo, XRAssetStats, XRAssetStatus, } from './cache';
|
|
3
|
+
export { disposeObject3D, estimateGeometryBytes, estimateObjectBytes, estimateTextureBytes, materialTextures, } from './estimate';
|
|
4
|
+
export { defineGltfAsset, defineTextureAsset, defineVideoAsset } from './loaders';
|
|
5
|
+
export type { TextureAssetOptions, VideoAsset, VideoAssetOptions } from './loaders';
|
|
6
|
+
export { XRAssetCacheProvider, useXRAsset, useXRAssetCache, useXRAssetStats } from './react';
|
|
7
|
+
export type { UseXRAssetResult, XRAssetCacheProviderProps } from './react';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
2
|
+
import { XRAssetDefinition } from './cache';
|
|
3
|
+
import * as THREE from "three";
|
|
4
|
+
export type TextureAssetOptions = {
|
|
5
|
+
colorSpace?: THREE.ColorSpace;
|
|
6
|
+
generateMipmaps?: boolean;
|
|
7
|
+
flipY?: boolean;
|
|
8
|
+
/** Extra key suffix when the same URL is loaded with different options. */
|
|
9
|
+
variant?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* An image texture. Loaded with the SDK's verifying fetch (CDN assets are
|
|
13
|
+
* hash-checked), decoded off the main thread, disposed on eviction.
|
|
14
|
+
*/
|
|
15
|
+
export declare const defineTextureAsset: (url: string, options?: TextureAssetOptions) => XRAssetDefinition<THREE.Texture>;
|
|
16
|
+
/** A glTF / GLB scene via three's GLTFLoader over the verifying fetch. Disposes geometries, materials and textures. */
|
|
17
|
+
export declare const defineGltfAsset: (url: string) => XRAssetDefinition<GLTF>;
|
|
18
|
+
export type VideoAssetOptions = {
|
|
19
|
+
loop?: boolean;
|
|
20
|
+
muted?: boolean;
|
|
21
|
+
crossOrigin?: string;
|
|
22
|
+
};
|
|
23
|
+
export type VideoAsset = {
|
|
24
|
+
video: HTMLVideoElement;
|
|
25
|
+
texture: THREE.VideoTexture;
|
|
26
|
+
};
|
|
27
|
+
/** A looping, muted video element with its `VideoTexture`. Playback is the consumer's call. */
|
|
28
|
+
export declare const defineVideoAsset: (url: string, options?: VideoAssetOptions) => XRAssetDefinition<VideoAsset>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { XRAssetCache, XRAssetDefinition, XRAssetStats, XRAssetStatus } from './cache';
|
|
3
|
+
export type XRAssetCacheProviderProps = PropsWithChildren<{
|
|
4
|
+
/** The cache to use below; default the app-wide cache. */
|
|
5
|
+
cache?: XRAssetCache;
|
|
6
|
+
/**
|
|
7
|
+
* On unmount (a route change away from the AR screen) dispose every value
|
|
8
|
+
* nobody references any more. Default `true`. Referenced values are never
|
|
9
|
+
* touched; their owners release them as they unmount.
|
|
10
|
+
*/
|
|
11
|
+
disposeUnreferencedOnUnmount?: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
/** Scope a cache to a subtree and release unreferenced assets when it unmounts. */
|
|
14
|
+
export declare const XRAssetCacheProvider: ({ cache, disposeUnreferencedOnUnmount, children, }: XRAssetCacheProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
/** The cache in scope (provider or the app-wide default). */
|
|
16
|
+
export declare const useXRAssetCache: () => XRAssetCache;
|
|
17
|
+
export type UseXRAssetResult<T> = {
|
|
18
|
+
value: T | null;
|
|
19
|
+
status: XRAssetStatus;
|
|
20
|
+
error: Error | null;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Hold a reference to an asset while mounted. Two components asking for the
|
|
24
|
+
* same key share one load and one value; the reference is released on
|
|
25
|
+
* unmount (and when `enabled` turns false), after which the budget decides
|
|
26
|
+
* when the value is disposed. `asset.key` is the identity: build definitions
|
|
27
|
+
* with `defineTextureAsset` / `defineGltfAsset` / `defineVideoAsset` or your own.
|
|
28
|
+
*/
|
|
29
|
+
export declare const useXRAsset: <T>(asset: XRAssetDefinition<T> | null | undefined, options?: {
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
}) => UseXRAssetResult<T>;
|
|
32
|
+
/** Live cache statistics (re-renders on every cache change). */
|
|
33
|
+
export declare const useXRAssetStats: (cache?: XRAssetCache) => XRAssetStats;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { FeedPoint, FeedSourceKind } from '../coordinates/spaces';
|
|
2
|
+
import { XRBodyCalibration, XRCalibration, XRCalibrationPatch, XRFaceCalibration } from './types';
|
|
3
|
+
export declare const CALIBRATION_VERSION: 1;
|
|
4
|
+
export declare const DEFAULT_CALIBRATION: XRCalibration;
|
|
5
|
+
/** A fresh, mutable calibration with the defaults (optionally patched). */
|
|
6
|
+
export declare const createCalibration: (patch?: XRCalibrationPatch) => XRCalibration;
|
|
7
|
+
/**
|
|
8
|
+
* Return a new calibration with `patch` applied. Invalid values fall back to
|
|
9
|
+
* the defaults rather than throwing, so a corrupt persisted blob never breaks
|
|
10
|
+
* the app. Never mutates `current`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const updateCalibration: (current: XRCalibration, patch: XRCalibrationPatch, now?: number) => XRCalibration;
|
|
13
|
+
/** Back to the defaults (a new object). */
|
|
14
|
+
export declare const resetCalibration: (now?: number) => XRCalibration;
|
|
15
|
+
/** Whether the calibration applies a transform at all (orientation, mirror override, scale or offset). */
|
|
16
|
+
export declare const isIdentityCalibration: (calibration: XRCalibration) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether calibrated points should be flipped relative to the feed for this
|
|
19
|
+
* source. `"auto"` means "match the session", which mirrors only the webcam,
|
|
20
|
+
* so auto never flips a point (the feed is already mirrored); `true`/`false`
|
|
21
|
+
* flip only when they disagree with the session.
|
|
22
|
+
*/
|
|
23
|
+
export declare const resolveCalibrationMirror: (calibration: XRCalibration, sourceKind: FeedSourceKind) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Map a feed point (0..1, top-left origin) through the calibration: rotate by
|
|
26
|
+
* `orientation`, flip when the mirror override disagrees with the session,
|
|
27
|
+
* scale about the centre and add the offset. Pure; writes into `target` and
|
|
28
|
+
* never touches `point`, so raw tracker results stay untouched.
|
|
29
|
+
*/
|
|
30
|
+
export declare const applyCalibrationToFeedPoint: (point: FeedPoint, calibration: XRCalibration, sourceKind: FeedSourceKind, target?: FeedPoint) => FeedPoint;
|
|
31
|
+
type Landmark = {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
};
|
|
35
|
+
/** MediaPipe face-mesh indices the face measurement reads. */
|
|
36
|
+
export declare const FACE_CALIBRATION_LANDMARKS: Readonly<{
|
|
37
|
+
leftTemple: 234;
|
|
38
|
+
rightTemple: 454;
|
|
39
|
+
leftEyeOuter: 33;
|
|
40
|
+
rightEyeOuter: 263;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Measure the reference face from 468+ face landmarks in feed space (what
|
|
44
|
+
* `FaceInfo.landmarks` / `getRawFaceTrackingData().landmarks` hold). Returns
|
|
45
|
+
* `null` when the landmarks are missing.
|
|
46
|
+
*/
|
|
47
|
+
export declare const measureFaceCalibration: (landmarks: readonly Landmark[] | undefined, now?: number) => XRFaceCalibration | null;
|
|
48
|
+
/** MediaPipe pose indices the body measurement reads. */
|
|
49
|
+
export declare const BODY_CALIBRATION_LANDMARKS: Readonly<{
|
|
50
|
+
leftShoulder: 11;
|
|
51
|
+
rightShoulder: 12;
|
|
52
|
+
leftHip: 23;
|
|
53
|
+
rightHip: 24;
|
|
54
|
+
}>;
|
|
55
|
+
/** Measure the reference body from 33 pose landmarks in feed space. */
|
|
56
|
+
export declare const measureBodyCalibration: (landmarks: readonly Landmark[] | undefined, now?: number) => XRBodyCalibration | null;
|
|
57
|
+
/**
|
|
58
|
+
* How far the person is now, relative to the calibrated distance: `1` at the
|
|
59
|
+
* reference distance, `> 1` closer (the face reads larger), `< 1` farther.
|
|
60
|
+
* `null` without a face calibration or without a face. Uses the face width;
|
|
61
|
+
* the eye distance is the fallback when the temples are not both visible.
|
|
62
|
+
*/
|
|
63
|
+
export declare const estimateFaceDistance: (landmarks: readonly Landmark[] | undefined, calibration: XRCalibration) => number | null;
|
|
64
|
+
/**
|
|
65
|
+
* Scale factor that maps the calibrated body onto the current one (`1` when
|
|
66
|
+
* the shoulders read the same width as at calibration). `null` without a body
|
|
67
|
+
* calibration or without a body.
|
|
68
|
+
*/
|
|
69
|
+
export declare const estimateBodyScale: (landmarks: readonly Landmark[] | undefined, calibration: XRCalibration) => number | null;
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { XRBodyCalibration, XRCalibration, XRCalibrationContext, XRCalibrationPatch, XRFaceCalibration, } from './types';
|
|
2
|
+
export { BODY_CALIBRATION_LANDMARKS, CALIBRATION_VERSION, DEFAULT_CALIBRATION, FACE_CALIBRATION_LANDMARKS, applyCalibrationToFeedPoint, createCalibration, estimateBodyScale, estimateFaceDistance, isIdentityCalibration, measureBodyCalibration, measureFaceCalibration, resetCalibration, resolveCalibrationMirror, updateCalibration, } from './calibration';
|
|
3
|
+
export { CALIBRATION_STORAGE_KEY, clearCalibration, loadCalibration, saveCalibration, } from './storage';
|
|
4
|
+
export type { CalibrationStorage } from './storage';
|
|
5
|
+
export { useXRCalibration } from './useXRCalibration';
|
|
6
|
+
export type { UseXRCalibrationOptions, UseXRCalibrationResult } from './useXRCalibration';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { XRCalibration } from './types';
|
|
2
|
+
export declare const CALIBRATION_STORAGE_KEY = "vincentt.xr.calibration";
|
|
3
|
+
/** The subset of `Storage` the persistence helpers use; `localStorage` fits. */
|
|
4
|
+
export type CalibrationStorage = Pick<Storage, "getItem" | "setItem" | "removeItem">;
|
|
5
|
+
/**
|
|
6
|
+
* Read a persisted calibration. Returns `null` when nothing is stored, the
|
|
7
|
+
* blob is corrupt, or it was written by another `version` (never throws).
|
|
8
|
+
*/
|
|
9
|
+
export declare const loadCalibration: (key?: string, storage?: CalibrationStorage | null) => XRCalibration | null;
|
|
10
|
+
/** Persist a calibration. Returns `false` when storage is unavailable or full. */
|
|
11
|
+
export declare const saveCalibration: (calibration: XRCalibration, key?: string, storage?: CalibrationStorage | null) => boolean;
|
|
12
|
+
/** Remove the persisted calibration (no-op when storage is unavailable). */
|
|
13
|
+
export declare const clearCalibration: (key?: string, storage?: CalibrationStorage | null) => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { FeedSourceKind, SourceOrientation } from '../coordinates/spaces';
|
|
2
|
+
/**
|
|
3
|
+
* Reference face measurements captured while the person stands at their
|
|
4
|
+
* "normal" distance. Units are feed-width fractions (0..1), the same space as
|
|
5
|
+
* `FaceInfo.landmarks`, so they survive a resize but not a lens change.
|
|
6
|
+
*/
|
|
7
|
+
export type XRFaceCalibration = {
|
|
8
|
+
/** Temple-to-temple width (landmarks 234 ↔ 454). */
|
|
9
|
+
faceWidth: number;
|
|
10
|
+
/** Outer eye-corner distance (landmarks 33 ↔ 263). */
|
|
11
|
+
eyeDistance: number;
|
|
12
|
+
/** `performance.now()`-independent wall-clock stamp (ms since epoch). */
|
|
13
|
+
capturedAt: number;
|
|
14
|
+
};
|
|
15
|
+
/** Reference body proportions (feed-space fractions) for scaling body-anchored content. */
|
|
16
|
+
export type XRBodyCalibration = {
|
|
17
|
+
/** Shoulder-to-shoulder width (pose landmarks 11 ↔ 12). */
|
|
18
|
+
shoulderWidth: number;
|
|
19
|
+
/** Hip-to-hip width (pose landmarks 23 ↔ 24). */
|
|
20
|
+
hipWidth: number;
|
|
21
|
+
/** Mid-shoulder to mid-hip distance. */
|
|
22
|
+
torsoLength: number;
|
|
23
|
+
capturedAt: number;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Persistent device calibration. Nothing here changes what trackers report:
|
|
27
|
+
* it is applied only by `applyCalibrationToFeedPoint` and the derived helpers.
|
|
28
|
+
*/
|
|
29
|
+
export type XRCalibration = {
|
|
30
|
+
/** Bump when the shape changes; `loadCalibration` drops other versions. */
|
|
31
|
+
version: 1;
|
|
32
|
+
/** Clockwise rotation the raw frame needs before use (a sideways capture). */
|
|
33
|
+
orientation: SourceOrientation;
|
|
34
|
+
/** `"auto"` mirrors exactly when the session mirrors (webcam); booleans force it. */
|
|
35
|
+
mirrored: boolean | "auto";
|
|
36
|
+
/** Uniform scale about the feed centre; 1 = none. */
|
|
37
|
+
scale: number;
|
|
38
|
+
/** Horizontal / vertical nudge in feed units after scaling (0 = none). */
|
|
39
|
+
offset: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
43
|
+
face: XRFaceCalibration | null;
|
|
44
|
+
body: XRBodyCalibration | null;
|
|
45
|
+
/** Wall-clock ms of the last change. */
|
|
46
|
+
updatedAt: number;
|
|
47
|
+
};
|
|
48
|
+
/** The fields `updateCalibration` accepts. */
|
|
49
|
+
export type XRCalibrationPatch = Partial<Pick<XRCalibration, "orientation" | "mirrored" | "scale" | "offset" | "face" | "body">>;
|
|
50
|
+
/** Resolved mirror decision for one source kind. */
|
|
51
|
+
export type XRCalibrationContext = {
|
|
52
|
+
sourceKind: FeedSourceKind;
|
|
53
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { FeedPoint, FeedSourceKind } from '../coordinates/spaces';
|
|
2
|
+
import { CalibrationStorage } from './storage';
|
|
3
|
+
import { XRCalibration, XRCalibrationPatch } from './types';
|
|
4
|
+
type Landmark = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
export type UseXRCalibrationOptions = {
|
|
9
|
+
/** Persist to storage under this key (default `"vincentt.xr.calibration"`). */
|
|
10
|
+
storageKey?: string;
|
|
11
|
+
/** `false` keeps the calibration in memory only. Default `true`. */
|
|
12
|
+
persist?: boolean;
|
|
13
|
+
/** Storage to use instead of `localStorage` (tests, custom backends). */
|
|
14
|
+
storage?: CalibrationStorage | null;
|
|
15
|
+
/** Starting values when nothing is persisted. */
|
|
16
|
+
initial?: XRCalibrationPatch;
|
|
17
|
+
};
|
|
18
|
+
export type UseXRCalibrationResult = {
|
|
19
|
+
calibration: XRCalibration;
|
|
20
|
+
/** True once the persisted value (if any) has been read. */
|
|
21
|
+
hydrated: boolean;
|
|
22
|
+
/** Merge a patch (and persist). Returns the new calibration. */
|
|
23
|
+
update: (patch: XRCalibrationPatch) => XRCalibration;
|
|
24
|
+
/** Back to defaults; clears the persisted value. */
|
|
25
|
+
reset: () => XRCalibration;
|
|
26
|
+
/** Capture the reference face from feed-space landmarks. Returns `false` without a face. */
|
|
27
|
+
calibrateFace: (landmarks: readonly Landmark[] | undefined) => boolean;
|
|
28
|
+
/** Capture the reference body from feed-space pose landmarks. Returns `false` without a body. */
|
|
29
|
+
calibrateBody: (landmarks: readonly Landmark[] | undefined) => boolean;
|
|
30
|
+
/** `applyCalibrationToFeedPoint` bound to this calibration and the session's source kind. */
|
|
31
|
+
applyToFeedPoint: (point: FeedPoint, target?: FeedPoint) => FeedPoint;
|
|
32
|
+
/** `estimateFaceDistance` bound to this calibration. */
|
|
33
|
+
faceDistance: (landmarks: readonly Landmark[] | undefined) => number | null;
|
|
34
|
+
/** `estimateBodyScale` bound to this calibration. */
|
|
35
|
+
bodyScale: (landmarks: readonly Landmark[] | undefined) => number | null;
|
|
36
|
+
/** The session's current source kind (what `"auto"` mirroring follows). */
|
|
37
|
+
sourceKind: FeedSourceKind;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Device calibration state: measure, persist, reset and apply. Raw tracker
|
|
41
|
+
* output is never altered; call `applyToFeedPoint` (or the estimate helpers)
|
|
42
|
+
* where you want calibrated values. Needs an `<XRProvider>` for the source
|
|
43
|
+
* kind that `mirrored: "auto"` follows.
|
|
44
|
+
*/
|
|
45
|
+
export declare const useXRCalibration: (options?: UseXRCalibrationOptions) => UseXRCalibrationResult;
|
|
46
|
+
export {};
|