{"version":3,"file":"ARModelViewer.Lk0MSw_n.mjs","names":["useState","useRef","modelViewer","useCallback","useMemo"],"sources":["https:/framerusercontent.com/modules/s2NKSKnMskTHPVmv9zto/2lAPZwD0XfgL4OwttHGr/ARModelViewer.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import React,{useEffect,useState,useCallback,useMemo,useRef}from\"react\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @copyright ©framersnippets.com\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 200\n * @framerDisableUnlink\n **/export default function ARModelViewer(props){const[isScriptLoaded,setIsScriptLoaded]=useState(false);const modelViewerRef=useRef(null);useEffect(()=>{if(!window.modelViewerScript){window.modelViewerScript=document.createElement(\"script\");window.modelViewerScript.src=\"https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js\";window.modelViewerScript.type=\"module\";window.modelViewerScript.onload=()=>setIsScriptLoaded(true);document.head.appendChild(window.modelViewerScript);}else{setIsScriptLoaded(true);}return()=>{};},[]);useEffect(()=>{const handleWheel=event=>{if(modelViewerRef.current){event.preventDefault();const modelViewer=modelViewerRef.current;const delta=event.deltaY;// Adjust the camera orbit based on wheel movement\nconst orbit=modelViewer.getCameraOrbit();const newOrbit={...orbit,radius:orbit.radius+delta*.02};modelViewer.cameraOrbit=`${newOrbit.theta}rad ${newOrbit.phi}rad ${newOrbit.radius}m`;}};const modelViewer=modelViewerRef.current;if(modelViewer){modelViewer.addEventListener(\"wheel\",handleWheel,{passive:false});}return()=>{if(modelViewer){modelViewer.removeEventListener(\"wheel\",handleWheel);}};},[]);const getMinCameraOrbit=useCallback(()=>`auto auto 0m`,[]);const getMaxCameraOrbit=useCallback(()=>`auto auto 20m`,[]);const getInitialCameraOrbit=useCallback(()=>{const initialDistance=(20-props.size/100*20).toFixed(2);return`auto auto ${initialDistance}m`;},[props.size]);const getModelSource=useCallback(()=>{return props.source===\"URL\"?props.modelURL||\"https://modelviewer.dev/shared-assets/models/Astronaut.glb\":props.model||\"https://modelviewer.dev/shared-assets/models/Astronaut.glb\";},[props.source,props.modelURL,props.model]);const modelViewerProps=useMemo(()=>({ref:modelViewerRef,key:props.model||\"default-model\",src:getModelSource(),alt:\"A 3D model\",\"camera-controls\":true,ar:true,\"ar-modes\":\"scene-viewer quick-look webxr\",\"auto-rotate\":props.autoRotate?\"true\":undefined,style:{width:\"100%\",height:\"100%\"},\"min-camera-orbit\":getMinCameraOrbit(),\"max-camera-orbit\":getMaxCameraOrbit(),\"camera-orbit\":getInitialCameraOrbit()}),[props.model,getModelSource,props.autoRotate,getMinCameraOrbit,getMaxCameraOrbit,getInitialCameraOrbit]);if(!isScriptLoaded)return null;return /*#__PURE__*/_jsx(motion.div,{style:{display:\"flex\",alignItems:\"center\",justifyContent:\"center\",overflow:\"hidden\",width:props.style.width||\"400px\",height:props.style.height||\"300px\",...props.style},children:/*#__PURE__*/React.createElement(\"model-viewer\",modelViewerProps)});}ARModelViewer.defaultProps={model:\"https://modelviewer.dev/shared-assets/models/Astronaut.glb\",modelURL:\"https://modelviewer.dev/shared-assets/models/Astronaut.glb\",autoRotate:true,size:50,source:\"File\"};addPropertyControls(ARModelViewer,{source:{type:ControlType.SegmentedEnum,options:[\"URL\",\"File\"],optionTitles:[\"URL\",\"File\"],title:\"Source\"},model:{type:ControlType.File,allowedFileTypes:[\"glb\"],title:\"‎\",description:\".glb only\",hidden:props=>props.source===\"URL\"},modelURL:{type:ControlType.String,title:\"‎\",description:\".glb only\",hidden:props=>props.source===\"File\"},size:{type:ControlType.Number,defaultValue:50,min:0,max:100,unit:\"%\",title:\"Size\",description:\"Render size\"},autoRotate:{type:ControlType.Boolean,title:\"Auto Rotate\",defaultValue:true,description:`\nImportant: Update the component in Framer (Assets > Components > Click purple update button) to prevent crashes.\n`}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ARModelViewer\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicHeight\":\"200\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerDisableUnlink\":\"\",\"framerIntrinsicWidth\":\"200\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ARModelViewer.map"],"mappings":"4QAOI,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,EAAe,GAAmBA,EAAS,GAAM,CAAO,EAAeC,EAAO,KAAK,CAAC,OAAmB,EAAO,kBAAsV,EAAkB,GAAK,EAA1V,EAAO,kBAAkB,SAAS,cAAc,SAAS,CAAC,EAAO,kBAAkB,IAAI,+EAA+E,EAAO,kBAAkB,KAAK,SAAS,EAAO,kBAAkB,WAAW,EAAkB,GAAK,CAAC,SAAS,KAAK,YAAY,EAAO,kBAAkB,MAA0C,IAAK,EAAE,CAAC,CAAC,MAAc,CAAC,IAAM,EAAY,GAAO,CAAC,GAAG,EAAe,QAAQ,CAAC,EAAM,gBAAgB,CAAC,IAAMC,EAAY,EAAe,QAAc,EAAM,EAAM,OACvrB,EAAMA,EAAY,gBAAgB,CAAO,EAAS,CAAC,GAAG,EAAM,OAAO,EAAM,OAAO,EAAM,IAAI,CAAC,EAAY,YAAY,GAAG,EAAS,MAAM,MAAM,EAAS,IAAI,MAAM,EAAS,OAAO,KAAY,EAAY,EAAe,QAA2F,OAAhF,GAAa,EAAY,iBAAiB,QAAQ,EAAY,CAAC,QAAQ,GAAM,CAAC,KAAY,CAAI,GAAa,EAAY,oBAAoB,QAAQ,EAAY,GAAM,EAAE,CAAC,CAAC,IAAM,EAAkBC,MAAgB,eAAe,EAAE,CAAC,CAAO,EAAkBA,MAAgB,gBAAgB,EAAE,CAAC,CAAO,EAAsBA,MAA+E,cAAvC,GAAG,EAAM,KAAK,IAAI,IAAI,QAAQ,EAAE,CAAoC,GAAK,CAAC,EAAM,KAAK,CAA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