{"version":3,"file":"MDX_3DModelViewer.CDLiEO8k.mjs","names":["useState","useId"],"sources":["https:/framerusercontent.com/modules/xvtakONl1127vZqRikIF/WoKGdsj3ic1W7Z0qcbZr/MDX_3DModelViewer.js"],"sourcesContent":["/**\n * @license\n * MODAX Premium UI Library — Proprietary Software\n * Copyright (c) 2026 MODAX. All rights reserved.\n * Unauthorized copying, modification, or distribution is strictly prohibited.\n *\n * ──────────────────────────────────────────────────────────────\n * @component   MDX_3DModelViewer\n * @version     1.1.0\n * @author      MODAX Design Team\n * @see         https://modax.framer.website/mdx-components/mdx-3d-model-viewer\n * ──────────────────────────────────────────────────────────────\n *\n * @description\n * Interactive 3D model viewer for GLB/GLTF assets. Renders through a\n * dynamically loaded Three.js / React Three Fiber module, hosted and\n * versioned separately and imported at runtime, so Three.js and its\n * dependencies never enter the Framer project bundle. Includes orbit\n * controls, camera presets, environment lighting, a live materials\n * inspector, animation playback, and WebXR VR support — all controllable\n * by the end user viewing the page at runtime, with this component's own\n * property panel limited to designer-facing configuration.\n *\n * @features\n * - GLB/GLTF loading with automatic camera fit and centering\n * - Orbit controls (rotate, pan, zoom) with configurable auto-rotate\n * - Six camera presets: Front, Back, Left, Right, Top, Isometric\n * - Six environment presets (Studio, Forest, Night, Dawn, City, Warehouse)\n *   for lighting/reflections, with an optional designer toggle to also use\n *   the active preset as the visible background\n * - Materials Inspector: Quality presets, Roughness, Metalness, Color Tint,\n *   Transparency, and Emissive Glow — each isolated per instance, safe with\n *   multiple viewers on one page even when they share the same model URL\n * - Wireframe and single/double-sided rendering toggles\n * - Animation playback with an auto-detected animation picker\n * - Keyboard accessibility (arrow keys to orbit, +/- to zoom, R to reset)\n * - Theater mode, browser fullscreen, and WebXR immersive VR mode\n * - Toast notifications for load/error/state feedback\n *\n * @properties\n * - modelUrl (string): URL to a .glb or .gltf file\n * - modelWidth (number): Viewer width in pixels (200–1920, default 800)\n * - modelHeight (number): Viewer height in pixels (200–1080, default 500)\n * - backgroundColor (color): Background shown when no environment\n *   background is active (default #f5f5f5)\n * - autoRotate (boolean): Auto-rotate the model on load (default true)\n * - rotationSpeed (number): Auto-rotate speed, 0–2 (default 0.5)\n * - zoomable (boolean): Allow user zoom via scroll/pinch/keyboard (default true)\n * - playAnimation (boolean): Auto-play the model's first animation, if any\n *   (default true)\n * - enableEnvironmentBackground (boolean): When on, the Inspector's\n *   environment preset also sets the visible background instead of only\n *   affecting lighting/reflections (default false)\n */import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useIsStaticRenderer,addPropertyControls,ControlType}from\"framer\";import{useState,useEffect,useId}from\"react\";/**\n * @framerDisableUnlink\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight fixed\n * @framerIntrinsicWidth 800\n * @framerIntrinsicHeight 500\n */export default function MDX_3DModelViewer({style,modelWidth=800,modelHeight=500,...props}){const isStatic=useIsStaticRenderer();const[ViewerComponent,setViewerComponent]=useState(null);const[loadError,setLoadError]=useState(null);// Internal MODAX broadcast identity for MDX_ContentNavigator detection.\n// This is deliberately NOT a property control — it's an internal\n// integration contract between MODAX components, not a designer-facing\n// setting. The instance ID is auto-generated per mount (React's useId,\n// stable for the lifetime of this component instance) so multiple\n// viewers on the same page — even pointing at the same model URL — each\n// broadcast a unique identity to ContentNavigator without any manual\n// configuration.\nconst autoInstanceId=useId();const modaxName=\"MDX_3DModelViewer\";const modaxTitle=\"3D Model Viewer\";const modaxId=`mdx-3d-model-viewer-${autoInstanceId}`;const modelUrl=props.modelUrl??\"https://pub-55ae57a6090e4d21ac39f028d878d262.r2.dev/modax-3d/Fox.glb\";const backgroundColor=props.backgroundColor??\"#f5f5f5\";const autoRotate=props.autoRotate??true;const rotationSpeed=props.rotationSpeed??.5;const zoomable=props.zoomable??true;const playAnimation=props.playAnimation??true;const enableEnvironmentBackground=props.enableEnvironmentBackground??false;const isValidUrl=modelUrl&&(modelUrl.endsWith(\".glb\")||modelUrl.endsWith(\".gltf\"));const containerStyle={...style,width:modelWidth,height:modelHeight,borderRadius:12,overflow:\"hidden\",position:\"relative\",background:backgroundColor,boxShadow:\"0 4px 20px rgba(0,0,0,0.08)\"};// Load the viewer dynamically\nuseEffect(()=>{if(isStatic)return;let isMounted=true;const loadViewer=async()=>{try{console.log(\"MODAX: Loading viewer...\");const module=await import(\"https://modax-3d-proxy.kaleem-techie.workers.dev/\");console.log(\"MODAX: Module loaded:\",module);// The component is exported as default or named export\nconst Component=module.default||module.ModelViewerCore;if(!Component){throw new Error(\"No component found in module\");}if(isMounted){console.log(\"MODAX: Setting component:\",Component.name||\"Component\");setViewerComponent(()=>Component);}}catch(err){console.error(\"MODAX: Failed to load viewer:\",err);if(isMounted){setLoadError(err instanceof Error?err.message:\"Unknown error\");props.onModelError?.(err instanceof Error?err.message:\"Unknown error\");}}};loadViewer();return()=>{isMounted=false;};},[isStatic]);// Canvas mode: placeholder\nif(isStatic){return /*#__PURE__*/_jsx(\"div\",{\"data-modax-name\":modaxName,\"data-modax-title\":modaxTitle,\"data-modax-id\":modaxId,style:containerStyle,children:/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",width:\"100%\",height:\"100%\",background:backgroundColor},children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:48,marginBottom:16},children:\"🎨\"}),/*#__PURE__*/_jsx(\"p\",{style:{fontWeight:500,margin:0,fontSize:14,color:\"#666\"},children:\"3D Model Viewer\"}),/*#__PURE__*/_jsx(\"p\",{style:{fontSize:12,marginTop:8,opacity:.5,color:\"#666\"},children:!isValidUrl?\"Add a .glb or .gltf URL\":\"Drop on canvas and preview\"})]})});}// Error state\nif(loadError){return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,children:/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",width:\"100%\",height:\"100%\",background:backgroundColor},children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:48,marginBottom:16},children:\"⚠️\"}),/*#__PURE__*/_jsx(\"p\",{style:{fontWeight:500,fontSize:14,color:\"#dc2626\"},children:\"Failed to load 3D viewer\"}),/*#__PURE__*/_jsx(\"p\",{style:{fontSize:12,opacity:.6,color:\"#666\"},children:loadError})]})});}if(!isValidUrl){return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,children:/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",width:\"100%\",height:\"100%\",background:backgroundColor},children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:48,marginBottom:16},children:\"🔗\"}),/*#__PURE__*/_jsx(\"p\",{style:{fontWeight:500,margin:0,fontSize:14,color:\"#dc2626\"},children:\"Invalid Model URL\"}),/*#__PURE__*/_jsx(\"p\",{style:{fontSize:12,marginTop:8,opacity:.6,color:\"#666\"},children:\"URL must end with .glb or .gltf\"})]})});}// Loading state\nif(!ViewerComponent){return /*#__PURE__*/_jsxs(\"div\",{style:containerStyle,children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",width:\"100%\",height:\"100%\",background:backgroundColor},children:[/*#__PURE__*/_jsx(\"div\",{style:{width:32,height:32,border:\"4px solid #e5e7eb\",borderTopColor:\"#3b82f6\",borderRadius:\"50%\",animation:\"spin 1s linear infinite\",margin:\"0 auto 8px\"}}),/*#__PURE__*/_jsx(\"p\",{style:{fontSize:14,color:\"#666\",marginTop:8},children:\"Loading 3D viewer...\"})]}),/*#__PURE__*/_jsx(\"style\",{children:`\n                    @keyframes spin {\n                        from { transform: rotate(0deg); }\n                        to { transform: rotate(360deg); }\n                    }\n                `})]});}// Live/Preview mode: render the dynamically imported viewer\nreturn /*#__PURE__*/_jsx(\"div\",{\"data-modax-name\":modaxName,\"data-modax-title\":modaxTitle,\"data-modax-id\":modaxId,style:containerStyle,children:/*#__PURE__*/_jsx(ViewerComponent,{modelUrl:modelUrl,autoRotate:autoRotate,rotationSpeed:rotationSpeed,zoomable:zoomable,backgroundColor:backgroundColor,playAnimation:playAnimation,enableEnvironmentBackground:enableEnvironmentBackground,onLoad:props.onModelLoad,onError:props.onModelError})});}// ============================================================\n// DEFAULT PROPS\n// ============================================================\nMDX_3DModelViewer.defaultProps={modelUrl:\"https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf\",modelWidth:800,modelHeight:500,backgroundColor:\"#f5f5f5\",autoRotate:true,rotationSpeed:.5,zoomable:true,playAnimation:true,enableEnvironmentBackground:false};// ============================================================\n// PROPERTY CONTROLS\n// ============================================================\naddPropertyControls(MDX_3DModelViewer,{modelUrl:{type:ControlType.String,title:\"Model URL\",defaultValue:\"https://pub-55ae57a6090e4d21ac39f028d878d262.r2.dev/modax-3d/Fox.glb\",placeholder:\"https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf\"},modelWidth:{type:ControlType.Number,title:\"Width (px)\",defaultValue:800,min:200,max:1920,step:10,displayStepper:true},modelHeight:{type:ControlType.Number,title:\"Height (px)\",defaultValue:500,min:200,max:1080,step:10,displayStepper:true},backgroundColor:{type:ControlType.Color,title:\"Background Color\",defaultValue:\"#f5f5f5\"},autoRotate:{type:ControlType.Boolean,title:\"Auto-Rotate\",defaultValue:true},rotationSpeed:{type:ControlType.Number,title:\"Rotation Speed\",defaultValue:.5,min:0,max:2,step:.1},zoomable:{type:ControlType.Boolean,title:\"Allow Zoom\",defaultValue:true},playAnimation:{type:ControlType.Boolean,title:\"Play Animation\",defaultValue:true},enableEnvironmentBackground:{type:ControlType.Boolean,title:\"Env. Background\",description:\"When on, the Inspector's environment preset (studio, forest, night, etc.) also sets the visible background. When off, environment presets only affect lighting/reflections, and the Background Color above is used instead.\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"MDX_3DModelViewer\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"500\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"* @framerSupportedLayoutWidth any-prefer-fixed\",\"framerIntrinsicWidth\":\"800\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./MDX_3DModelViewer.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DG,SAAwB,EAAkB,CAAC,QAAM,aAAW,IAAI,cAAY,IAAI,GAAG,GAAO,CAAC,IAAM,EAAS,EAAoB,EAAO,CAAC,EAAgB,GAAoBA,EAAS,IAAI,EAAO,CAAC,EAAU,GAAcA,EAAS,IAAI,EAQjO,EAAeC,EAAM,EAAQ,EAAU,oBAA0B,EAAW,kBAAwB,EAAQ,uBAAuB,IAAuB,EAAS,EAAM,UAAU,uEAA6E,EAAgB,EAAM,iBAAiB,UAAgB,EAAW,EAAM,YAAY,GAAW,EAAc,EAAM,eAAe,GAAS,EAAS,EAAM,UAAU,GAAW,EAAc,EAAM,eAAe,GAAW,EAA4B,EAAM,6BAA6B,GAAY,EAAW,IAAW,EAAS,SAAS,MAAM,GAAG,EAAS,SAAS,OAAO,GAAS,EAAe,CAAC,GAAG,EAAM,MAAM,EAAW,OAAO,EAAY,aAAa,GAAG,SAAS,SAAS,SAAS,WAAW,WAAW,EAAgB,UAAU,6BAA6B,EAWtzB,OAVA,MAAc,CAAC,GAAG,EAAS,OAAO,IAAI,EAAU,GACia,OAAb,SADrX,CAAC,GAAG,CAAC,QAAQ,IAAI,0BAA0B,EAAE,IAAM,EAAO,MAAM,OAAO,uDAAqD,QAAQ,IAAI,wBAAwB,CAAM,EACrP,IAAM,EAAU,EAAO,SAAS,EAAO,gBAAgB,GAAG,CAAC,EAAW,MAAU,MAAM,8BAA8B,EAAM,IAAW,QAAQ,IAAI,4BAA4B,EAAU,MAAM,WAAW,EAAE,MAAuB,CAAS,EAAG,OAAO,EAAI,CAA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