@liveroom-tech/react-immersive 6.0.2 → 6.1.0

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.
Files changed (67) hide show
  1. package/README.md +24 -0
  2. package/dist/AnimationsTab-NUJTEMZ5.mjs +1 -0
  3. package/dist/AnnotationsTab-OHRVWRKI.mjs +1 -0
  4. package/dist/CinematicTab-IJAY2BS6.mjs +1 -0
  5. package/dist/ConfigureTab-UQRRATCY.mjs +6 -0
  6. package/dist/RulesTab-YVBZGJZX.mjs +1 -0
  7. package/dist/SequencesTab-IC5LWQ6N.css +1 -0
  8. package/dist/SequencesTab-RPJAG26Z.mjs +1 -0
  9. package/dist/binding-builder.css +1 -1
  10. package/dist/binding-builder.d.mts +3 -3
  11. package/dist/binding-builder.d.ts +3 -3
  12. package/dist/binding-builder.js +76 -23
  13. package/dist/binding-builder.mjs +1 -1
  14. package/dist/chunk-2DV2UCQH.mjs +1 -0
  15. package/dist/chunk-37YITTIK.mjs +1 -0
  16. package/dist/chunk-5FLX45O5.mjs +2 -0
  17. package/dist/chunk-6CTCV2Q5.mjs +1 -0
  18. package/dist/chunk-7JCFNZJM.mjs +1 -0
  19. package/dist/chunk-7OWHW66D.mjs +1 -0
  20. package/dist/chunk-AL6UIGWP.mjs +1 -0
  21. package/dist/chunk-BNKTI3CY.mjs +1 -0
  22. package/dist/chunk-CCBFMNAU.mjs +1 -0
  23. package/dist/chunk-E24EFHB5.mjs +1 -0
  24. package/dist/chunk-EV6THDXD.mjs +1 -0
  25. package/dist/chunk-F5QSXMME.mjs +1 -0
  26. package/dist/chunk-FGAJ2UT7.mjs +1 -0
  27. package/dist/chunk-FXV4CLAK.mjs +1 -0
  28. package/dist/chunk-GV4ZRXL6.mjs +1 -0
  29. package/dist/chunk-KHN55ZM7.mjs +3 -0
  30. package/dist/chunk-LX3GXQNU.mjs +1 -0
  31. package/dist/chunk-OPZJDP7T.mjs +1 -0
  32. package/dist/chunk-OREKYGO3.mjs +83 -0
  33. package/dist/chunk-PBVBZYOG.mjs +47 -0
  34. package/dist/chunk-T6AYLPCC.mjs +1 -0
  35. package/dist/hosted.css +1 -1
  36. package/dist/hosted.d.mts +22 -6
  37. package/dist/hosted.d.ts +22 -6
  38. package/dist/hosted.js +75 -22
  39. package/dist/hosted.mjs +1 -1
  40. package/dist/index.css +1 -1
  41. package/dist/index.d.mts +66 -6
  42. package/dist/index.d.ts +66 -6
  43. package/dist/index.js +69 -21
  44. package/dist/index.mjs +1 -1
  45. package/dist/{modelFileResolver-Co7j1tdQ.d.mts → modelFileResolver-BEW_95id.d.mts} +52 -7
  46. package/dist/{modelFileResolver-Co7j1tdQ.d.ts → modelFileResolver-BEW_95id.d.ts} +52 -7
  47. package/dist/{modelViewerProps-BibuMND7.d.ts → modelViewerProps-C7saa0i2.d.mts} +173 -3
  48. package/dist/{modelViewerProps-Ce4-wb57.d.mts → modelViewerProps-CbK_4uZj.d.ts} +173 -3
  49. package/dist/{publicProps-BaJHCDa_.d.mts → publicProps-NKTiohZO.d.mts} +1 -1
  50. package/dist/{publicProps-CP18d_mt.d.ts → publicProps-z7cJhUH8.d.ts} +1 -1
  51. package/dist/simple-model-viewer.css +1 -1
  52. package/dist/simple-model-viewer.d.mts +25 -3
  53. package/dist/simple-model-viewer.d.ts +25 -3
  54. package/dist/simple-model-viewer.js +49 -3
  55. package/dist/simple-model-viewer.mjs +1 -1
  56. package/dist/utils.d.mts +47 -4
  57. package/dist/utils.d.ts +47 -4
  58. package/dist/utils.js +2 -2
  59. package/dist/utils.mjs +1 -1
  60. package/package.json +5 -1
  61. package/dist/chunk-33SUWPXC.mjs +0 -3
  62. package/dist/chunk-4JMJALRO.mjs +0 -2
  63. package/dist/chunk-EIBW7ZJE.mjs +0 -81
  64. package/dist/chunk-KFTJMFYF.mjs +0 -1
  65. package/dist/chunk-OTSCPJWF.mjs +0 -1
  66. package/dist/chunk-P2JZ5Z7I.mjs +0 -1
  67. package/dist/chunk-V7WZUWJ5.mjs +0 -1
@@ -1 +1 @@
1
- "use client";import{a as st}from"./chunk-MMO7KCYU.mjs";import{C as Ze,D as et,G as tt,H as nt,I as rt,J as at,K as ot,a as Ie,b as Z,g as Be,j as Fe,k as Ae,l as Ke,m as He,n as Ue,o as We,s as Xe,t as $e,u as Ge,v as qe,w as Ye,x as Je,y as Qe}from"./chunk-OTSCPJWF.mjs";import{j as Bt}from"./chunk-V7WZUWJ5.mjs";import"./chunk-JR557W27.mjs";import{useRef as S,useState as u,useCallback as x,useEffect as k,useMemo as ee,Component as Ft,Suspense as me}from"react";import{CameraControls as At,Environment as Kt}from"@react-three/drei";import{useFrame as mt,useThree as $}from"@react-three/fiber";import{Canvas as Ht}from"@react-three/fiber";import{Box3 as Ut,MeshStandardMaterial as Wt,PerspectiveCamera as Xt,Vector3 as fe}from"three";import{SkeletonUtils as $t}from"three-stdlib";import{X as xe,Check as vt,Settings as Gt,ChevronDown as qt,Boxes as Yt,Trash2 as Jt,Upload as ve,AlertTriangle as Qt}from"lucide-react";import{Fragment as ut,jsx as e,jsxs as p}from"react/jsx-runtime";var it={color:"#93c5fd",intensity:.05},lt=["apartment","city","dawn","forest","lobby","night","park","studio","sunset","warehouse"];function Zt(n){return!!(n&&"isMesh"in n&&n.isMesh)}function dt(n,r){Array.isArray(n)?n.forEach(r):r(n)}function en(n,r){if(!r)return;let s=r.camera;if(!(s instanceof Xt))return;let a=new Ut().setFromObject(n).getSize(new fe).length();!Number.isFinite(a)||a<=0||(s.near=a/100,s.far=a*100,s.updateProjectionMatrix(),r.maxDistance=a*10)}var he=class extends Ft{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(s){this.props.onLoadError?.(s)}render(){return this.state.hasError?null:this.props.children}};function tn({url:n,format:r,dracoDecoderPath:s,ktx2TranscoderPath:a,meshopt:l,hiddenKeys:o,selectedKey:w,panelHoveredKey:z,nodeRefsOut:c,onMeshesReady:y,onModelLoaded:K,onLoadProgress:_,onMeshClick:D,highlightOnHover:L}){let{scene:g}=Ze(n,{dracoDecoderPath:s,ktx2TranscoderPath:a,meshopt:l},r,_),B=$(i=>i.invalidate),{setCanvasCursor:E,restoreCanvasCursor:T}=nt(),[N,V]=u(null),h=ee(()=>$t.clone(g),[g]),M=ee(()=>{let i={};return h.traverse(d=>{if(!Zt(d))return;let b=d.name||d.uuid;i[b]={key:b,label:d.name||d.type,ref:d}}),i},[h]),j=ee(()=>{let i={};for(let[d,{ref:b}]of Object.entries(M)){let A=(Array.isArray(b.material)?b.material:[b.material]).map(m=>{let f=(et(m)??new Wt).clone();return f.userData.baseColor=f.color.clone(),f.userData.baseMap=f.map,f.userData.baseEmissive=f.emissive.clone(),f.userData.baseEmissiveMap=f.emissiveMap,f.userData.baseEmissiveIntensity=f.emissiveIntensity,f});i[d]=Array.isArray(b.material)?A:A[0]}return i},[M]);k(()=>()=>{Object.values(j).forEach(i=>dt(i,d=>d.dispose()))},[j]);let H=S(null);k(()=>{H.current!==n&&(H.current=n,h.updateWorldMatrix(!0,!0),tt(h),y(M),K(h))},[n,h,M,y,K]),k(()=>{let i=new AbortController;return Ue(h,i.signal),()=>{i.abort(),We(h)}},[h]);let q=ee(()=>!Ke(h),[h]);k(()=>{for(let[i,{ref:d}]of Object.entries(M))c.current[i]=d},[M,c]),k(()=>{!L&&N!==null&&(V(null),T())},[L,N,T]),k(()=>{for(let[i,{ref:d}]of Object.entries(M)){d.visible=!o.has(i);let b=j[i];if(!b)continue;d.material=b;let O=L&&N===i,A=L&&z===i;dt(b,m=>{if(m.color.copy(m.userData.baseColor),m.map=m.userData.baseMap??null,m.emissive.copy(m.userData.baseEmissive),m.emissiveMap=m.userData.baseEmissiveMap??null,m.emissiveIntensity=m.userData.baseEmissiveIntensity,A||O){let U=!!m.userData.baseEmissiveMap;m.emissive.set(it.color),m.emissiveIntensity=U?m.userData.baseEmissiveIntensity:it.intensity}m.needsUpdate=!0})}B()},[M,j,N,w,z,L,o,B]);let F=i=>{let d=i;for(;d;){let b=d.name||d.uuid;if(M[b])return b;d=d.parent}return null},ne=q?{onClick:i=>{let d=F(i.object);d&&(i.stopPropagation(),D(d))},...L?{onPointerOver:i=>{let d=F(i.object);d&&(i.stopPropagation(),E("pointer"),V(d))},onPointerOut:i=>{i.stopPropagation(),T(),V(null)}}:{}}:{};return e("primitive",{object:h,...ne})}function nn({scene:n,controlsRef:r,refitOnResize:s,onInitialFitComplete:a,resumeViewRef:l}){let o=S(!1),w=$(y=>y.invalidate),z=$(y=>y.size),c=S(null);return k(()=>{o.current=!1,w()},[w,n]),mt(()=>{if(o.current)return;if(!n||!r.current){w();return}o.current=!0,en(n,r.current);let y=l.current;if(y){l.current=null,r.current.setLookAt(...y.position,...y.target,!1).catch(()=>{}).finally(a);return}r.current.fitToBox(n,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{}).finally(a)}),k(()=>{if(!(!s||!o.current||!n||!r.current))return c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{r.current?.fitToBox(n,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{}),w()},150),()=>{c.current&&clearTimeout(c.current)}},[z.width,z.height,s]),null}function rn({exposure:n}){let r=$(a=>a.gl),s=$(a=>a.invalidate);return k(()=>{r.toneMappingExposure=n,s()},[r,n,s]),null}function an({enabled:n,controlsRef:r}){let s=$(a=>a.invalidate);return mt((a,l)=>{!n||!r.current||(r.current.rotate(l*.2,0,!1),s())}),null}function te(n){return Array.from(n.types).includes("Files")}function pt({label:n,checked:r,onChange:s}){return p("div",{className:"env-row",children:[e("span",{className:"env-row__label",children:n}),e("div",{className:"env-row__value",children:e("button",{className:"env-checkbox-btn",onClick:()=>s(!r),children:e("span",{className:`env-checkbox${r?" env-checkbox--checked":""}`,children:r&&e(vt,{size:9,strokeWidth:2,color:"white"})})})})]})}function ge({label:n,value:r,onChange:s}){return p("div",{className:"env-row",children:[e("span",{className:"env-row__label",children:n}),e("div",{className:"env-row__value",children:p("div",{className:"env-color-swatch",style:{background:r},children:[e("span",{className:"env-color-swatch__hex",children:r}),e("input",{type:"color",className:"env-color-swatch__input",value:r,onChange:a=>s(a.target.value)})]})})]})}function be({label:n,value:r,min:s,max:a,step:l,onChange:o}){return p("div",{className:"env-row",children:[e("span",{className:"env-row__label",children:n}),p("div",{className:"env-row__value env-row__value--slider",children:[e("input",{type:"range",className:"env-slider",min:s,max:a,step:l,value:r,onChange:w=>o(Number(w.target.value))}),e("span",{className:"env-slider__value",children:r.toFixed(2)})]})]})}function on({label:n,optionLabels:r,value:s,options:a,onChange:l}){return p("div",{className:"env-row",children:[e("span",{className:"env-row__label",children:n}),e("div",{className:"env-row__value",children:e("select",{className:"env-select",value:s,onChange:o=>l(o.target.value),children:a.map(o=>e("option",{value:o,children:r?.[o]??o},o))})})]})}function ct({title:n,children:r}){let[s,a]=u(!1);return p("div",{className:"env-section",children:[p("button",{className:"env-section__header",onClick:()=>a(l=>!l),children:[e(qt,{size:12,strokeWidth:2,className:`env-section__chevron${s?" env-section__chevron--collapsed":""}`}),e("span",{children:n})]}),!s&&e("div",{className:"env-section__body",children:r})]})}function sn({isOpen:n,onToggle:r,settings:s,onChange:a}){let l=Z();return p("div",{className:`left-panel-wrapper ${n?"left-panel-wrapper--open":"left-panel-wrapper--closed"}`,children:[!n&&e("button",{className:"side-panel__open-btn side-panel__open-btn--left",onClick:()=>r(!0),children:e(Gt,{size:20,strokeWidth:1.8})}),p("div",{className:`side-panel side-panel--left ${n?"side-panel--open-left":"side-panel--closed-left"}`,"aria-hidden":!n,children:[e("div",{className:"side-panel__header",children:p("div",{className:"side-panel__header-top",children:[e("span",{className:"side-panel__eyebrow",children:l("sceneSettings")}),e("button",{className:"side-panel__close-btn",onClick:()=>r(!1),title:l("close"),children:e(xe,{size:12,strokeWidth:1.6})})]})}),p("div",{className:"env-controls",children:[p(ct,{title:l("background"),children:[e(pt,{label:l("background"),checked:s.backgroundEnabled,onChange:o=>a("backgroundEnabled",o)}),e(ge,{label:l("backgroundColor"),value:s.backgroundColor,onChange:o=>a("backgroundColor",o)}),e(on,{label:l("environment"),value:s.envPreset,options:lt,optionLabels:Object.fromEntries(lt.map(o=>[o,l(`environment${o[0].toUpperCase()}${o.slice(1)}`)])),onChange:o=>a("envPreset",o)}),e(pt,{label:l("autoRotate"),checked:s.autoRotate,onChange:o=>a("autoRotate",o)})]}),p(ct,{title:l("lighting"),children:[e(be,{label:l("exposure"),value:s.exposure,min:0,max:2,step:.05,onChange:o=>a("exposure",o)}),e(be,{label:l("ambientLightIntensity"),value:s.ambientIntensity,min:0,max:3,step:.05,onChange:o=>a("ambientIntensity",o)}),e(ge,{label:l("ambientLightColor"),value:s.ambientColor,onChange:o=>a("ambientColor",o)}),e(be,{label:l("directLightIntensity"),value:s.directionalIntensity,min:0,max:5,step:.05,onChange:o=>a("directionalIntensity",o)}),e(ge,{label:l("directLightColor"),value:s.directionalColor,onChange:o=>a("directionalColor",o)})]})]})]})]})}function ln({meshKeys:n,hiddenKeys:r,selectedKey:s,isOpen:a,onToggle:l,onFocus:o,onHover:w,onToggleVisibility:z}){let c=Z(),[y,K]=u(""),[_,D]=u(null),L=Object.values(n).filter(g=>g.label.toLowerCase().includes(y.toLowerCase()));return p("div",{className:`right-panel-wrapper ${a?"right-panel-wrapper--open":"right-panel-wrapper--closed"}`,children:[!a&&e("button",{className:"side-panel__open-btn",onClick:()=>l(!0),children:e(Yt,{size:20,strokeWidth:1.8})}),p("div",{className:`side-panel ${a?"side-panel--open":"side-panel--closed"}`,"aria-hidden":!a,children:[p("div",{className:"side-panel__header",children:[p("div",{className:"side-panel__header-top",children:[e("span",{className:"side-panel__eyebrow",children:c("sceneObjects")}),e("button",{className:"side-panel__close-btn",onClick:()=>l(!1),title:c("close"),children:e(xe,{size:12,strokeWidth:1.6})})]}),e("p",{className:"side-panel__title",children:c("objectCount",{count:L.length})})]}),e("div",{className:"side-panel__search-wrap",children:e("input",{className:"side-panel__search",type:"text",placeholder:c("searchObjects"),value:y,onChange:g=>K(g.target.value)})}),e("div",{className:"side-panel__list",children:L.map(({key:g,label:B})=>{let E=!r.has(g),T=s===g,N=_===g;return p("div",{onClick:()=>o(g),onMouseEnter:()=>{D(g),w(g)},onMouseLeave:()=>{D(null),w(null)},className:["side-panel__row",N?"side-panel__row--hovered":"",T?"side-panel__row--selected":""].filter(Boolean).join(" "),children:[e("button",{type:"button",className:`side-panel__label side-panel__labelButton${N||T?" side-panel__label--hovered":""}`,"aria-current":T?"true":void 0,onFocus:()=>{D(g),w(g)},onBlur:()=>{D(null),w(null)},children:B}),e("button",{type:"button",className:"side-panel__vis-btn",title:c(E?"hide":"show"),"aria-label":c(E?"hideObject":"showObject",{name:B}),onClick:V=>{V.stopPropagation(),z(g)},children:e("span",{className:`side-panel__checkbox${E?" side-panel__checkbox--checked":""}`,children:E&&e(vt,{size:9,strokeWidth:5,color:"white"})})})]},g)})})]})]})}function gt(n){return e(Ie,{labels:n.labels,children:e(dn,{...n})})}function dn({modelUrl:n,poster:r,loading:s,reveal:a,modelFormat:l,dracoDecoderPath:o,ktx2TranscoderPath:w,meshopt:z=!0,backgroundColor:c="#1a1a1a",showSceneObjectsPanel:y=!0,showSceneSettingsPanel:K=!0,enableModelUpload:_=!1,zoomOnSelected:D=!1,highlightOnHover:L=!1,showLoadingOverlay:g=!0,refitOnResize:B=!0,backgroundEnabled:E=!1,autoRotate:T=!1,envPreset:N="city",exposure:V=1,ambientIntensity:h=.6,ambientColor:M="#ffffff",directionalIntensity:j=1.2,directionalColor:H="#ffffff",onModelLoaded:q,onLoadError:F,reducedMotion:ne="user"}){let i=Z(),d=at(ne),b=T&&!d;st("simple-model-viewer","SimpleModelViewer");let O=S(null),A=S({}),m=S(null),U=S(null),f=S(0),[re,ae]=u(null),[we,ye]=u(null),[bt,oe]=u(!1),[ft,_e]=u({}),[ke,Me]=u(new Set),[Ce,Re]=u(null),[ht,Se]=u(null),[Le,Ne]=u(null),[xt,Ee]=u(null),[wt,Y]=u(!1),[Pe,ze]=u(!1),[se,ie]=u(!1),[yt,J]=u(null),[_t,Q]=u(!1),[kt,Mt]=u(()=>typeof window>"u"?!0:window.innerWidth>900),[Ct,Rt]=u(()=>typeof window>"u"?!0:window.innerWidth>900),[C,le]=u({backgroundEnabled:E,backgroundColor:c,autoRotate:b,envPreset:N,exposure:V,ambientIntensity:h,ambientColor:M,directionalIntensity:j,directionalColor:H}),R=_?Le:n,De=S(null),de=S(null),pe=S(null),[G,Te]=u(null);k(()=>()=>{G&&URL.revokeObjectURL(G)},[G]);let Ve=S(R);Ve.current=R;let ce=S(null),I=Ye({loading:s,reveal:a,rootRef:De,onPark:()=>{ce.current=de.current?.gl??null;let t=O.current;if(t&&se){pe.current={position:t.getPosition(new fe).toArray(),target:t.getTarget(new fe).toArray()};let v=R;qe(de.current).then(P=>{P&&(v===Ve.current?Te(P):URL.revokeObjectURL(P))})}ae(null),ie(!1)}});k(()=>{if(I.live)return;let t=ce.current;ce.current=null,t&&Ge(t)},[I.live]);let W=x(()=>{pe.current=null,Te(null),ae(null),ye(null),oe(!1),_e({}),Me(new Set),Re(null),Se(null),Y(!1),ie(!1),J(null)},[]),X=x(()=>{U.current?.cleanup(),U.current=null},[]),St=x(()=>{X(),Ne(null),Ee(null),W(),le({backgroundEnabled:E,backgroundColor:c,autoRotate:b,envPreset:N,exposure:V,ambientIntensity:h,ambientColor:M,directionalIntensity:j,directionalColor:H})},[M,h,b,c,E,H,j,N,V,W,X]),Oe=x(async t=>{ze(!0);try{let v=await Fe(t);X(),U.current=v,Ne(v.url),Ee(v.name),W()}catch(v){Y(!0),F?.(v)}finally{ze(!1)}},[F,W,X]),ue=x(t=>{let v=t?.[0];v&&Oe(v)},[Oe]);k(()=>()=>{X()},[X]);let Lt=x((t,v)=>{le(P=>({...P,[t]:v}))},[]);k(()=>{le(t=>({...t,backgroundColor:c}))},[c]),k(()=>{W()},[R,W]);let Nt=x(t=>{_e(t)},[]),Et=x(t=>{ae(t),Y(!1);let v=He(t);ye(v>Ae?v:null),oe(!1),J(null),q?.(rt(t))},[q]),Pt=x(t=>{Y(!0),J(null),F?.(t)},[F]),zt=x(t=>{t.lengthComputable&&t.total>0&&J(t.loaded/t.total*100)},[]),je=x(t=>{if(Re(t),!D)return;let v=A.current[t];!v||!O.current||O.current.fitToBox(v,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{})},[D]),Dt=x(t=>{Me(v=>{let P=new Set(v);return P.has(t)?P.delete(t):P.add(t),P})},[]),Tt=x(t=>{!_||!te(t.dataTransfer)||(t.preventDefault(),t.stopPropagation(),f.current+=1,Q(!0))},[_]),Vt=x(t=>{!_||!te(t.dataTransfer)||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect="copy",Q(!0))},[_]),Ot=x(t=>{!_||!te(t.dataTransfer)||(t.preventDefault(),t.stopPropagation(),f.current=Math.max(0,f.current-1),f.current===0&&Q(!1))},[_]),jt=x(t=>{!_||!te(t.dataTransfer)||(t.preventDefault(),t.stopPropagation(),f.current=0,Q(!1),ue(t.dataTransfer.files))},[_,ue]),It=g&&(Pe||!!(R&&I.live&&!wt&&(!re||!se)));return p("div",{className:"smv-root",ref:De,"data-reduced-motion":d?"":void 0,style:{background:C.backgroundColor},onDragEnter:Tt,onDragOver:Vt,onDragLeave:Ot,onDrop:jt,children:[K&&R&&e(sn,{isOpen:Ct,onToggle:Rt,settings:C,onChange:Lt}),p("div",{className:"smv-canvasArea",children:[we!==null&&!bt&&p("div",{className:"smv-largeModelBanner",children:[e(Qt,{size:14,className:"smv-largeModelBanner__icon"}),e("span",{children:i("simpleLargeModelWarning",{millions:Math.round(we/1e6)})}),e("button",{type:"button",className:"smv-largeModelBanner__dismiss",onClick:()=>oe(!0),"aria-label":i("dismiss"),children:e(xe,{size:12})})]}),_?p(ut,{children:[e("input",{ref:m,type:"file",accept:Be,className:"smv-upload-input",onChange:t=>{ue(t.target.files),t.currentTarget.value=""}}),R?e("div",{className:"smv-upload-toolbar",children:p(ut,{children:[e("span",{className:"smv-upload-toolbar__name",children:xt??i("uploadedModel")}),p("button",{type:"button",className:"smv-upload-toolbar__button smv-upload-toolbar__button--ghost",onClick:St,children:[e(Jt,{size:14}),i("clear")]})]})}):null]}):null,R&&!I.live?e(Qe,{className:"ri-viewerPlaceholder--inset",background:C.backgroundColor,poster:G??r,onReveal:I.awaitingReveal?I.reveal:void 0}):R?p(Ht,{dpr:[1,2],frameloop:I.visible?"demand":"never",resize:{debounce:0,scroll:!1},raycaster:{firstHitOnly:!0},style:{background:C.backgroundColor},camera:{position:[0,0,5],fov:45,near:.1,far:1e3},children:[e(Xe,{captureRef:de}),e($e,{}),p(me,{fallback:null,children:[e("ambientLight",{intensity:C.ambientIntensity,color:C.ambientColor}),e("directionalLight",{position:[-4,5,7],intensity:C.directionalIntensity,color:C.directionalColor,castShadow:!0}),e("directionalLight",{position:[-5,5,5],intensity:.5}),e(me,{fallback:null,children:e(Kt,{preset:C.envPreset,background:C.backgroundEnabled})}),e(rn,{exposure:C.exposure}),e(an,{enabled:C.autoRotate,controlsRef:O}),e(he,{onLoadError:Pt,children:e(me,{fallback:null,children:e(tn,{url:R,format:Le?void 0:l,dracoDecoderPath:o,ktx2TranscoderPath:w,meshopt:z,hiddenKeys:ke,selectedKey:Ce,panelHoveredKey:ht,nodeRefsOut:A,onMeshesReady:Nt,onModelLoaded:Et,onLoadProgress:zt,onMeshClick:je,highlightOnHover:L})})},R),e(nn,{scene:re,controlsRef:O,refitOnResize:B,onInitialFitComplete:()=>ie(!0),resumeViewRef:pe}),e(At,{ref:O,makeDefault:!0,smoothTime:d?0:.3})]})]}):e("div",{className:"smv-upload-empty-state",style:{background:C.backgroundColor},children:p("div",{className:"smv-upload-empty-state__card",children:[e("div",{className:"smv-upload-empty-state__icon",children:e(ve,{size:24})}),e("p",{className:"smv-upload-empty-state__body",children:i("dropModelHint",{formats:".glb, .gltf, .obj, .fbx, .usdz, .stl, .ply, .zip"})}),p("button",{type:"button",className:"smv-upload-empty-state__button",onClick:()=>m.current?.click(),children:[e(ve,{size:15}),i("chooseModel")]})]})}),R&&I.live?e(Je,{src:G??r,hidden:!!(re&&se)}):null,e(ot,{visible:It,message:i("loadingModel"),progress:Pe?void 0:yt??void 0}),_&&_t?e("div",{className:"smv-upload-drop-overlay",children:p("div",{className:"smv-upload-drop-overlay__card",children:[e(ve,{size:20}),e("span",{children:i("releaseToLoadYourModel")})]})}):null]}),y&&R&&e(ln,{meshKeys:ft,hiddenKeys:ke,selectedKey:Ce,isOpen:kt,onToggle:Mt,onFocus:je,onHover:Se,onToggleVisibility:Dt})]})}export{Bt as DEFAULT_MODEL_VIEWER_LABELS,gt as SimpleModelViewer};
1
+ "use client";import{a as Rr}from"./chunk-MMO7KCYU.mjs";import{A as fr,C as gr,G as br,I as hr,M as xr,N as wr,Q as yr,R as _r,S as kr,T as Sr,h as nr,k as tr,l as ar,m as or,n as Re,o as ir,p as sr,t as lr,u as dr,v as cr,w as pr,x as ur,y as mr,z as vr}from"./chunk-PBVBZYOG.mjs";import{a as rr,b as me}from"./chunk-T6AYLPCC.mjs";import{a as Mr}from"./chunk-37YITTIK.mjs";import"./chunk-EV6THDXD.mjs";import{a as mn}from"./chunk-6CTCV2Q5.mjs";import"./chunk-BNKTI3CY.mjs";import"./chunk-JR557W27.mjs";import{useRef as N,useState as g,useCallback as y,useEffect as _,useMemo as H,Component as vn,Suspense as Ce}from"react";import{CameraControls as fn,Environment as gn}from"@react-three/drei";import{useFrame as Tr,useThree as G}from"@react-three/fiber";import{Canvas as bn}from"@react-three/fiber";import{ACESFilmicToneMapping as hn,AgXToneMapping as xn,Box3 as ze,Color as wn,MeshStandardMaterial as yn,NeutralToneMapping as _n,NoToneMapping as kn,PerspectiveCamera as Dr,Vector3 as Y}from"three";import{SkeletonUtils as Mn}from"three-stdlib";import{X as Pe,Check as Vr,Settings as Sn,ChevronDown as Rn,Boxes as Cn,RotateCcw as Nn,Trash2 as Ln,Upload as Ne,AlertTriangle as En}from"lucide-react";import{Fragment as Pr,jsx as e,jsxs as d}from"react/jsx-runtime";var Cr={color:"#93c5fd",intensity:.05},Nr=["apartment","city","dawn","forest","lobby","night","park","studio","sunset","warehouse"],Or={aces:hn,agx:xn,neutral:_n,none:kn};function Te(r){return!!(r&&"isMesh"in r&&r.isMesh)}function Lr(r,i){Array.isArray(r)?r.forEach(i):i(r)}function zn(r,i){if(!i)return;let a=i.camera;if(!(a instanceof Dr))return;let l=new ze().setFromObject(r).getSize(new Y).length();!Number.isFinite(l)||l<=0||(a.near=l/100,a.far=l*100,a.updateProjectionMatrix(),i.maxDistance=l*10)}var Ee=class extends vn{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(a){this.props.onLoadError?.(a)}render(){return this.state.hasError?null:this.props.children}};function Pn({url:r,format:i,dracoDecoderPath:a,ktx2TranscoderPath:l,meshopt:s,hiddenKeys:c,selectedKey:o,panelHoveredKey:n,nodeRefsOut:u,onMeshesReady:x,onModelLoaded:U,onLoadProgress:k,onMeshClick:T,highlightOnHover:L}){let{scene:h}=xr(r,{dracoDecoderPath:a,ktx2TranscoderPath:l,meshopt:s},i,k),B=G(p=>p.invalidate),{setCanvasCursor:D,restoreCanvasCursor:V}=_r(),[z,j]=g(null),M=H(()=>Mn.clone(h),[h]),E=H(()=>{let p={};return M.traverse(m=>{if(!Te(m))return;let w=m.name||m.uuid;p[w]={key:w,label:m.name||m.type,ref:m}}),p},[M]),A=H(()=>{let p={};for(let[m,{ref:w}]of Object.entries(E)){let K=(Array.isArray(w.material)?w.material:[w.material]).map(b=>{let S=(wr(b)??new yn).clone();return S.userData.baseColor=S.color.clone(),S.userData.baseMap=S.map,S.userData.baseEmissive=S.emissive.clone(),S.userData.baseEmissiveMap=S.emissiveMap,S.userData.baseEmissiveIntensity=S.emissiveIntensity,S});p[m]=Array.isArray(w.material)?K:K[0]}return p},[E]);_(()=>()=>{Object.values(A).forEach(p=>Lr(p,m=>m.dispose()))},[A]);let J=N(null);_(()=>{J.current!==r&&(J.current=r,M.updateWorldMatrix(!0,!0),yr(M),x(E),U(M))},[r,M,E,x,U]),_(()=>{let p=new AbortController;return ir(M,p.signal),()=>{p.abort(),sr(M)}},[M]);let oe=H(()=>!or(M),[M]);_(()=>{for(let[p,{ref:m}]of Object.entries(E))u.current[p]=m},[E,u]),_(()=>{!L&&z!==null&&(j(null),V())},[L,z,V]),_(()=>{for(let[p,{ref:m}]of Object.entries(E)){m.visible=!c.has(p);let w=A[p];if(!w)continue;m.material=w;let Z=L&&z===p,K=L&&n===p;Lr(w,b=>{if(b.color.copy(b.userData.baseColor),b.map=b.userData.baseMap??null,b.emissive.copy(b.userData.baseEmissive),b.emissiveMap=b.userData.baseEmissiveMap??null,b.emissiveIntensity=b.userData.baseEmissiveIntensity,K||Z){let ee=!!b.userData.baseEmissiveMap;b.emissive.set(Cr.color),b.emissiveIntensity=ee?b.userData.baseEmissiveIntensity:Cr.intensity}b.needsUpdate=!0})}B()},[E,A,z,o,n,L,c,B]);let Q=p=>{let m=p;for(;m;){let w=m.name||m.uuid;if(E[w])return w;m=m.parent}return null},ie=oe?{onClick:p=>{let m=Q(p.object);m&&(p.stopPropagation(),T(m))},...L?{onPointerOver:p=>{let m=Q(p.object);m&&(p.stopPropagation(),D("pointer"),j(m))},onPointerOut:p=>{p.stopPropagation(),V(),j(null)}}:{}}:{};return e("primitive",{object:M,...ie})}function Tn({scene:r,controlsRef:i,refitOnResize:a,onInitialFitComplete:l,resumeViewRef:s}){let c=N(!1),o=G(x=>x.invalidate),n=G(x=>x.size),u=N(null);return _(()=>{c.current=!1,o()},[o,r]),Tr(()=>{if(c.current)return;if(!r||!i.current){o();return}c.current=!0,zn(r,i.current);let x=s.current;if(x){s.current=null,i.current.setLookAt(...x.position,...x.target,!1).catch(()=>{}).finally(l);return}i.current.fitToBox(r,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{}).finally(l)}),_(()=>{if(!(!a||!c.current||!r||!i.current))return u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{i.current?.fitToBox(r,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{}),o()},150),()=>{u.current&&clearTimeout(u.current)}},[n.width,n.height,a]),null}function Dn({scene:r,exposure:i,toneMapping:a,fov:l,wireframe:s}){let c=G(u=>u.gl),o=G(u=>u.camera),n=G(u=>u.invalidate);return _(()=>{c.toneMappingExposure=i,n()},[c,i,n]),_(()=>{o instanceof Dr&&(o.fov=l,o.updateProjectionMatrix(),n())},[o,l,n]),_(()=>{c.toneMapping=Or[a],r?.traverse(u=>{if(Te(u))for(let x of[u.material].flat())x.wireframe=s,x.needsUpdate=!0}),n()},[c,r,a,s,n]),null}function Vn({enabled:r,speed:i,controlsRef:a}){let l=G(s=>s.invalidate);return Tr((s,c)=>{!r||!a.current||(a.current.rotate(c*.2*i,0,!1),l())}),null}function ve(r){return Array.from(r.types).includes("Files")}function te({label:r,checked:i,onChange:a}){return d("div",{className:"ri-env-row",children:[e("span",{className:"ri-env-row__label",title:r,children:r}),e("div",{className:"ri-env-row__value",children:e("button",{type:"button",className:"ri-env-checkbox-btn",role:"checkbox","aria-checked":i,"aria-label":r,onClick:()=>a(!i),children:e("span",{className:`ri-env-checkbox${i?" ri-env-checkbox--checked":""}`,children:i&&e(Vr,{size:10,strokeWidth:2.5,"aria-hidden":"true"})})})})]})}function Le({label:r,value:i,onChange:a}){return d("div",{className:"ri-env-row",children:[e("span",{className:"ri-env-row__label",title:r,children:r}),e("div",{className:"ri-env-row__value",children:d("label",{className:"ri-env-color-swatch",children:[e("span",{className:"ri-env-color-swatch__chip",style:{background:i}}),e("span",{className:"ri-env-color-swatch__hex",children:i}),e("input",{type:"color",className:"ri-env-color-swatch__input","aria-label":r,value:i,onChange:l=>a(l.target.value)})]})})]})}function O({label:r,value:i,min:a,max:l,step:s,format:c=n=>n.toFixed(2),onChange:o}){return d("div",{className:"ri-env-row",children:[e("span",{className:"ri-env-row__label",title:r,children:r}),d("div",{className:"ri-env-row__value ri-env-row__value--slider",children:[e("input",{type:"range",className:"ri-env-slider","aria-label":r,min:a,max:l,step:s,value:i,onChange:n=>o(Number(n.target.value))}),e("span",{className:"ri-env-slider__value",children:c(i)})]})]})}function Er({label:r,optionLabels:i,value:a,options:l,onChange:s}){return d("div",{className:"ri-env-row",children:[e("span",{className:"ri-env-row__label",title:r,children:r}),e("div",{className:"ri-env-row__value",children:e("select",{className:"ri-env-select","aria-label":r,value:a,onChange:c=>s(c.target.value),children:l.map(c=>e("option",{value:c,children:i?.[c]??c},c))})})]})}function fe({label:r,value:i}){return d("div",{className:"ri-env-row",children:[e("span",{className:"ri-env-row__label",title:r,children:r}),e("span",{className:"ri-env-row__info",children:i})]})}var zr=r=>`${Math.round(r)}\xB0`;function ae({title:r,children:i}){let[a,l]=g(!1);return d("div",{className:"ri-env-section",children:[d("button",{type:"button",className:"ri-env-section__header","aria-expanded":!a,onClick:()=>l(s=>!s),children:[e(Rn,{size:12,strokeWidth:2,className:`ri-env-section__chevron${a?" env-section__chevron--collapsed":""}`}),e("span",{children:r})]}),!a&&e("div",{className:"ri-env-section__body",children:i})]})}function On({isOpen:r,onToggle:i,settings:a,modelInfo:l,onChange:s,onReset:c}){let o=me();return d("div",{className:`ri-left-panel-wrapper ${r?"ri-left-panel-wrapper--open":"ri-left-panel-wrapper--closed"}`,children:[!r&&e("button",{className:"ri-side-panel__open-btn ri-side-panel__open-btn--left",onClick:()=>i(!0),children:e(Sn,{size:20,strokeWidth:1.8})}),d("div",{className:`ri-side-panel ri-side-panel--left ${r?"ri-side-panel--open-left":"ri-side-panel--closed-left"}`,"aria-hidden":!r,children:[e("div",{className:"ri-side-panel__header",children:d("div",{className:"ri-side-panel__header-top",children:[e("span",{className:"ri-side-panel__eyebrow",children:o("sceneSettings")}),e("button",{className:"ri-side-panel__close-btn",onClick:()=>i(!1),title:o("close"),children:e(Pe,{size:12,strokeWidth:1.6})})]})}),d("div",{className:"ri-env-controls",children:[d(ae,{title:o("environment"),children:[e(Er,{label:o("environmentPreset"),value:a.envPreset,options:Nr,optionLabels:Object.fromEntries(Nr.map(n=>[n,o(`environment${n[0].toUpperCase()}${n.slice(1)}`)])),onChange:n=>s("envPreset",n)}),e(O,{label:o("environmentIntensity"),value:a.envIntensity,min:0,max:3,step:.05,onChange:n=>s("envIntensity",n)}),e(O,{label:o("rotation"),value:a.envRotation,min:0,max:360,step:1,format:zr,onChange:n=>s("envRotation",n)}),e(te,{label:o("showEnvironmentAsBackground"),checked:a.backgroundEnabled,onChange:n=>s("backgroundEnabled",n)}),a.backgroundEnabled?e(O,{label:o("backgroundBlur"),value:a.backgroundBlur,min:0,max:1,step:.01,onChange:n=>s("backgroundBlur",n)}):e(Le,{label:o("backgroundColor"),value:a.backgroundColor,onChange:n=>s("backgroundColor",n)})]}),d(ae,{title:o("lighting"),children:[e(O,{label:o("exposure"),value:a.exposure,min:0,max:2,step:.05,onChange:n=>s("exposure",n)}),e(Er,{label:o("toneMapping"),value:a.toneMapping,options:Object.keys(Or),optionLabels:{aces:o("toneMappingAces"),agx:o("toneMappingAgx"),neutral:o("toneMappingNeutral"),none:o("toneMappingNone")},onChange:n=>s("toneMapping",n)}),e(O,{label:o("ambientLightIntensity"),value:a.ambientIntensity,min:0,max:3,step:.05,onChange:n=>s("ambientIntensity",n)}),e(Le,{label:o("ambientLightColor"),value:a.ambientColor,onChange:n=>s("ambientColor",n)}),e(O,{label:o("directLightIntensity"),value:a.directionalIntensity,min:0,max:5,step:.05,onChange:n=>s("directionalIntensity",n)}),e(Le,{label:o("directLightColor"),value:a.directionalColor,onChange:n=>s("directionalColor",n)})]}),d(ae,{title:o("ground"),children:[e(te,{label:o("groundShadow"),checked:a.groundShadow,onChange:n=>s("groundShadow",n)}),a.groundShadow&&e(O,{label:o("groundShadowOpacity"),value:a.groundShadowOpacity,min:0,max:1,step:.01,onChange:n=>s("groundShadowOpacity",n)}),e(te,{label:o("floorGrid"),checked:a.showFloorGrid,onChange:n=>s("showFloorGrid",n)})]}),d(ae,{title:o("display"),children:[e(te,{label:o("wireframe"),checked:a.wireframe,onChange:n=>s("wireframe",n)}),e(te,{label:o("autoRotate"),checked:a.autoRotate,onChange:n=>s("autoRotate",n)}),a.autoRotate&&e(O,{label:o("autoRotateSpeed"),value:a.autoRotateSpeed,min:.1,max:5,step:.1,onChange:n=>s("autoRotateSpeed",n)}),e(O,{label:o("fieldOfView"),value:a.fov,min:15,max:90,step:1,format:zr,onChange:n=>s("fov",n)})]}),l&&d(ae,{title:o("modelInfo"),children:[e(fe,{label:o("modelInfoObjects"),value:l.objects.toLocaleString()}),e(fe,{label:o("modelInfoTriangles"),value:l.triangles.toLocaleString()}),e(fe,{label:o("modelInfoMaterials"),value:l.materials.toLocaleString()}),e(fe,{label:o("size"),value:l.size})]}),e("div",{className:"ri-env-footer",children:d("button",{type:"button",className:"ri-env-reset",onClick:c,children:[e(Nn,{size:12,"aria-hidden":"true"}),o("resetSettings")]})})]})]})]})}function jn(r){let i=0,a=new Set;r.traverse(s=>{if(Te(s)){i+=1;for(let c of[s.material].flat())a.add(c.name||c.uuid)}});let l=new ze().setFromObject(r).getSize(new Y);return{objects:i,triangles:Re(r),materials:a.size,size:[l.x,l.y,l.z].map(s=>Number(s.toPrecision(3))).join(" \xD7 ")}}function In({meshKeys:r,hiddenKeys:i,selectedKey:a,isOpen:l,onToggle:s,onFocus:c,onHover:o,onToggleVisibility:n}){let u=me(),[x,U]=g(""),[k,T]=g(null),L=Object.values(r).filter(h=>h.label.toLowerCase().includes(x.toLowerCase()));return d("div",{className:`ri-right-panel-wrapper ${l?"ri-right-panel-wrapper--open":"ri-right-panel-wrapper--closed"}`,children:[!l&&e("button",{className:"ri-side-panel__open-btn",onClick:()=>s(!0),children:e(Cn,{size:20,strokeWidth:1.8})}),d("div",{className:`ri-side-panel ${l?"ri-side-panel--open":"ri-side-panel--closed"}`,"aria-hidden":!l,children:[e("div",{className:"ri-side-panel__header",children:d("div",{className:"ri-side-panel__header-top",children:[e("span",{className:"ri-side-panel__eyebrow",children:u("sceneObjects")}),e("span",{className:"ri-side-panel__title","aria-label":u("objectCount",{count:L.length}),children:L.length}),e("button",{className:"ri-side-panel__close-btn",onClick:()=>s(!1),title:u("close"),children:e(Pe,{size:12,strokeWidth:1.6})})]})}),e("div",{className:"ri-side-panel__search-wrap",children:e("input",{className:"ri-side-panel__search",type:"text",placeholder:u("searchObjects"),value:x,onChange:h=>U(h.target.value)})}),e("div",{className:"ri-side-panel__list",children:L.map(({key:h,label:B})=>{let D=!i.has(h),V=a===h,z=k===h;return d("div",{onClick:()=>c(h),onMouseEnter:()=>{T(h),o(h)},onMouseLeave:()=>{T(null),o(null)},className:["ri-side-panel__row",z?"ri-side-panel__row--hovered":"",V?"ri-side-panel__row--selected":""].filter(Boolean).join(" "),children:[e("button",{type:"button",className:`ri-side-panel__label ri-side-panel__labelButton${z||V?" ri-side-panel__label--hovered":""}`,"aria-current":V?"true":void 0,onFocus:()=>{T(h),o(h)},onBlur:()=>{T(null),o(null)},children:B}),e("button",{type:"button",className:"ri-side-panel__vis-btn",title:u(D?"hide":"show"),"aria-label":u(D?"hideObject":"showObject",{name:B}),onClick:j=>{j.stopPropagation(),n(h)},children:e("span",{className:`ri-side-panel__checkbox${D?" ri-side-panel__checkbox--checked":""}`,children:D&&e(Vr,{size:9,strokeWidth:5,color:"white"})})})]},h)})})]})]})}function jr(r){return e(rr,{labels:r.labels,children:e(Fn,{...r})})}function Fn({modelUrl:r,poster:i,loading:a,reveal:l,modelFormat:s,dracoDecoderPath:c,ktx2TranscoderPath:o,meshopt:n=!0,backgroundColor:u="#1a1a1a",showSceneObjectsPanel:x=!0,showSceneSettingsPanel:U=!0,enableModelUpload:k=!1,zoomOnSelected:T=!1,highlightOnHover:L=!1,showLoadingOverlay:h=!0,refitOnResize:B=!0,backgroundEnabled:D=!1,autoRotate:V=!1,envPreset:z="city",exposure:j=1,ambientIntensity:M=.6,ambientColor:E="#ffffff",directionalIntensity:A=1.2,directionalColor:J="#ffffff",envIntensity:oe=1,envRotation:Q=0,backgroundBlur:ie=0,toneMapping:p="aces",groundShadow:m=!1,groundShadowOpacity:w=.5,showFloorGrid:Z=!1,wireframe:K=!1,autoRotateSpeed:b=1,fov:ee=45,onModelLoaded:S,onLoadError:se,reducedMotion:Ir="user"}){let I=me(),ge=Mr(Ir),De=V&&!ge;Rr("simple-model-viewer","SimpleModelViewer");let W=N(null),Ve=N({}),Oe=N(null),be=N(null),re=N(0),[R,he]=g(null),[je,Ie]=g(null),[Fr,xe]=g(!1),[Br,Fe]=g({}),[Be,Ae]=g(new Set),[Ke,He]=g(null),[Ar,Ge]=g(null),[Ue,We]=g(null),[Kr,Xe]=g(null),[Hr,le]=g(!1),[$e,qe]=g(!1),[we,ye]=g(!1),[Gr,de]=g(null),Ur=gr(Gr),[Wr,ce]=g(!1),[Xr,$r]=g(()=>typeof window>"u"?!0:window.innerWidth>900),[qr,Yr]=g(()=>typeof window>"u"?!0:window.innerWidth>900),pe=H(()=>({backgroundEnabled:D,backgroundColor:u,autoRotate:De,envPreset:z,exposure:j,ambientIntensity:M,ambientColor:E,directionalIntensity:A,directionalColor:J,envIntensity:oe,envRotation:Q,backgroundBlur:ie,toneMapping:p,groundShadow:m,groundShadowOpacity:w,showFloorGrid:Z,wireframe:K,autoRotateSpeed:b,fov:ee}),[D,u,De,z,j,M,E,A,J,oe,Q,ie,p,m,w,Z,K,b,ee]),[v,ue]=g(pe),C=k?Ue:r,Ye=N(null),_e=N(null),ke=N(null),[ne,Je]=g(null);_(()=>()=>{ne&&URL.revokeObjectURL(ne)},[ne]);let Qe=N(C);Qe.current=C;let Me=N(null),F=mr({loading:a,reveal:l,rootRef:Ye,onPark:()=>{Me.current=_e.current?.gl??null;let t=W.current;if(t&&we){ke.current={position:t.getPosition(new Y).toArray(),target:t.getTarget(new Y).toArray()};let f=C;ur(_e.current).then(P=>{P&&(f===Qe.current?Je(P):URL.revokeObjectURL(P))})}he(null),ye(!1)}});_(()=>{if(F.live)return;let t=Me.current;Me.current=null,t&&pr(t)},[F.live]);let X=y(()=>{ke.current=null,Je(null),he(null),Ie(null),xe(!1),Fe({}),Ae(new Set),He(null),Ge(null),le(!1),ye(!1),de(null)},[]),$=y(()=>{be.current?.cleanup(),be.current=null},[]),Jr=y(()=>{$(),We(null),Xe(null),X(),ue(pe)},[pe,X,$]),Ze=y(async t=>{qe(!0);try{let f=await tr(t);$(),be.current=f,We(f.url),Xe(f.name),X()}catch(f){le(!0),se?.(f)}finally{qe(!1)}},[se,X,$]),Se=y(t=>{let f=t?.[0];f&&Ze(f)},[Ze]);_(()=>()=>{$()},[$]);let Qr=y(()=>R,[R]),Zr=!v.backgroundEnabled&&new wn(v.backgroundColor).getHSL({h:0,s:0,l:0}).l>.5?"#000000":"#ffffff",en=H(()=>R?jn(R):null,[R]),q=H(()=>{if(!R)return null;let t=new ze().setFromObject(R);if(t.isEmpty())return null;let f=t.getSize(new Y);return{y:t.min.y,center:t.getCenter(new Y),size:Math.max(f.x,f.y,f.z)}},[R]),rn=y((t,f)=>{ue(P=>({...P,[t]:f}))},[]);_(()=>{ue(t=>({...t,backgroundColor:u}))},[u]),_(()=>{X()},[C,X]);let nn=y(t=>{Fe(t)},[]),tn=y(t=>{he(t),le(!1);let f=Re(t);Ie(f>ar?f:null),xe(!1),de(null),S?.(kr(t))},[S]),an=y(t=>{le(!0),de(null),se?.(t)},[se]),on=y(t=>{t.lengthComputable&&t.total>0&&de(t.loaded/t.total*100)},[]),er=y(t=>{if(He(t),!T)return;let f=Ve.current[t];!f||!W.current||W.current.fitToBox(f,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{})},[T]),sn=y(t=>{Ae(f=>{let P=new Set(f);return P.has(t)?P.delete(t):P.add(t),P})},[]),ln=y(t=>{!k||!ve(t.dataTransfer)||(t.preventDefault(),t.stopPropagation(),re.current+=1,ce(!0))},[k]),dn=y(t=>{!k||!ve(t.dataTransfer)||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect="copy",ce(!0))},[k]),cn=y(t=>{!k||!ve(t.dataTransfer)||(t.preventDefault(),t.stopPropagation(),re.current=Math.max(0,re.current-1),re.current===0&&ce(!1))},[k]),pn=y(t=>{!k||!ve(t.dataTransfer)||(t.preventDefault(),t.stopPropagation(),re.current=0,ce(!1),Se(t.dataTransfer.files))},[k,Se]),un=h&&($e||!!(C&&F.live&&!Hr&&(!R||!we)));return d("div",{className:"smv-root",ref:Ye,"data-reduced-motion":ge?"":void 0,style:{background:v.backgroundColor},onDragEnter:ln,onDragOver:dn,onDragLeave:cn,onDrop:pn,children:[U&&C&&e(On,{isOpen:qr,onToggle:Yr,settings:v,modelInfo:en,onReset:()=>ue(pe),onChange:rn}),d("div",{className:"smv-canvasArea",children:[je!==null&&!Fr&&d("div",{className:"smv-largeModelBanner",children:[e(En,{size:14,className:"smv-largeModelBanner__icon"}),e("span",{children:I("simpleLargeModelWarning",{millions:Math.round(je/1e6)})}),e("button",{type:"button",className:"smv-largeModelBanner__dismiss",onClick:()=>xe(!0),"aria-label":I("dismiss"),children:e(Pe,{size:12})})]}),k?d(Pr,{children:[e("input",{ref:Oe,type:"file",accept:nr,className:"smv-upload-input",onChange:t=>{Se(t.target.files),t.currentTarget.value=""}}),C?e("div",{className:"smv-upload-toolbar",children:d(Pr,{children:[e("span",{className:"smv-upload-toolbar__name",children:Kr??I("uploadedModel")}),d("button",{type:"button",className:"smv-upload-toolbar__button smv-upload-toolbar__button--ghost",onClick:Jr,children:[e(Ln,{size:14}),I("clear")]})]})}):null]}):null,C&&!F.live?e(fr,{className:"ri-viewerPlaceholder--inset",background:v.backgroundColor,poster:ne??i,onReveal:F.awaitingReveal?F.reveal:void 0}):C?d(bn,{dpr:[1,2],frameloop:F.visible?"demand":"never",resize:{debounce:0,scroll:!1},raycaster:{firstHitOnly:!0},style:{background:v.backgroundColor},camera:{position:[0,0,5],fov:45,near:.1,far:1e3},children:[e(dr,{captureRef:_e}),e(cr,{}),d(Ce,{fallback:null,children:[e("ambientLight",{intensity:v.ambientIntensity,color:v.ambientColor}),e("directionalLight",{position:[-4,5,7],intensity:v.directionalIntensity,color:v.directionalColor,castShadow:!0}),e("directionalLight",{position:[-5,5,5],intensity:.5}),e(Ce,{fallback:null,children:e(gn,{preset:v.envPreset,background:v.backgroundEnabled,environmentIntensity:v.envIntensity,backgroundIntensity:v.envIntensity,backgroundBlurriness:v.backgroundBlur})}),e(hr,{rotation:v.envRotation}),e(Dn,{scene:R,exposure:v.exposure,toneMapping:v.toneMapping,fov:v.fov,wireframe:v.wireframe}),e(Vn,{enabled:v.autoRotate,speed:v.autoRotateSpeed,controlsRef:W}),v.groundShadow&&q&&e(br,{position:[q.center.x,q.y,q.center.z],scale:q.size*2,opacity:v.groundShadowOpacity,blur:2,far:q.size,resolution:1024,color:"#000000"}),v.showFloorGrid&&e(lr,{getTarget:Qr,revision:R,lineColor:Zr}),e(Ee,{onLoadError:an,children:e(Ce,{fallback:null,children:e(Pn,{url:C,format:Ue?void 0:s,dracoDecoderPath:c,ktx2TranscoderPath:o,meshopt:n,hiddenKeys:Be,selectedKey:Ke,panelHoveredKey:Ar,nodeRefsOut:Ve,onMeshesReady:nn,onModelLoaded:tn,onLoadProgress:on,onMeshClick:er,highlightOnHover:L})})},C),e(Tn,{scene:R,controlsRef:W,refitOnResize:B,onInitialFitComplete:()=>ye(!0),resumeViewRef:ke}),e(fn,{ref:W,makeDefault:!0,smoothTime:ge?0:.3})]})]}):e("div",{className:"smv-upload-empty-state",style:{background:v.backgroundColor},children:d("div",{className:"smv-upload-empty-state__card",children:[e("div",{className:"smv-upload-empty-state__icon",children:e(Ne,{size:24})}),e("p",{className:"smv-upload-empty-state__body",children:I("dropModelHint",{formats:".glb, .gltf, .obj, .fbx, .usdz, .stl, .ply, .zip"})}),d("button",{type:"button",className:"smv-upload-empty-state__button",onClick:()=>Oe.current?.click(),children:[e(Ne,{size:15}),I("chooseModel")]})]})}),C&&F.live?e(vr,{src:ne??i,hidden:!!(R&&we)}):null,e(Sr,{visible:un,message:I("loadingModel"),progress:$e?void 0:Ur??void 0}),k&&Wr?e("div",{className:"smv-upload-drop-overlay",children:d("div",{className:"smv-upload-drop-overlay__card",children:[e(Ne,{size:20}),e("span",{children:I("releaseToLoadYourModel")})]})}):null]}),x&&C&&e(In,{meshKeys:Br,hiddenKeys:Be,selectedKey:Ke,isOpen:Xr,onToggle:$r,onFocus:er,onHover:Ge,onToggleVisibility:sn})]})}export{mn as DEFAULT_MODEL_VIEWER_LABELS,jr as SimpleModelViewer};
package/dist/utils.d.mts CHANGED
@@ -1,6 +1,7 @@
1
- import { b0 as SceneLight, ao as ObjectBinding, aD as ObjectBindingType, a9 as MeasurementUnit, a6 as MeasurementSettings, aL as SavedMeasurement, a3 as MeasurementPoint, a5 as MeasurementResult, a8 as MeasurementTool, a2 as MeasurementCollection, ay as ObjectBindingStyle, az as ObjectBindingTarget, V as InspectAssetOptions, q as AssetDiagnosticsReport, e as ARSnapshotSource, A as ARExportOptions, d as ARSnapshot, bv as ShareableViewerState, bM as ViewerStateStorage, bn as SequenceEasing, bd as SceneSequence, bs as SequenceTrack, bt as SequenceValue, bo as SequenceKeyframe, b8 as SceneSectionConfig, bb as SceneSectionSettings } from './modelViewerProps-Ce4-wb57.mjs';
2
- export { a as ARHandoffOptions, b as ARHandoffRequest, c as ARHandoffStatus, l as AnimationLoopMode, p as AssetDiagnosticIssue, r as AssetDiagnosticsSource, s as AssetTextureDiagnostic, t as AssetTransform, B as BindingEdit, E as ComparisonCategory, F as ComparisonChange, G as ComparisonHighlight, H as ComparisonObject, I as ComparisonStatus, J as ConfigurationComparisonInput, K as ConfigurationComparisonReport, N as DEFAULT_SCENE_CONFIG, O as DEFAULT_SECTION_CONFIG, Q as DeepPartial, R as EnvironmentPreset, S as GlitchModeName, W as IsolatedObjectBindings, Y as KernelSizeName, Z as MATERIAL_BLENDING_MODES, _ as MATERIAL_SIDES, $ as MAX_VIEWER_STATE_BYTES, a1 as MeasurementAnchor, a4 as MeasurementPosition, a7 as MeasurementStatus, an as ObjectActionEvent, ap as ObjectBindingAction, aq as ObjectBindingCameraState, ar as ObjectBindingDecal, as as ObjectBindingMaterial, at as ObjectBindingMaterialBlendingMode, au as ObjectBindingMaterialSide, av as ObjectBindingPatch, aw as ObjectBindingSelector, ax as ObjectBindingStatus, aA as ObjectBindingTextureChannel, aB as ObjectBindingTextureSlot, aC as ObjectBindingTransform, aF as ObjectPointerEvent, aG as ObjectSurfacePoint, aJ as RampTypeName, aK as RendererBackend, aM as SceneAnimationClipConfig, aN as SceneAnimationConfig, aO as SceneAnnotationCameraView, aP as SceneAnnotationImage, aQ as SceneAnnotationLink, aR as SceneAnnotationMarker, aS as SceneBackgroundConfig, aT as SceneCameraConfig, aU as SceneCinematicConfig, aV as SceneCinematicWaypoint, aX as SceneConfig, aZ as SceneConfigPatch, a_ as SceneEnvironmentConfig, a$ as SceneGroundShadowConfig, b1 as SceneLightAttachment, b2 as SceneLightType, b3 as SceneLightingConfig, b4 as SceneModelConfig, b5 as SceneModelRenderer, b6 as ScenePostProcessingConfig, b7 as SceneSectionAxis, bc as SceneSelectionSet, be as SceneShadowConfig, bf as SceneStyleColorScale, bg as SceneStyleCondition, bh as SceneStylePulse, bi as SceneStyleRule, bj as SceneWireframeConfig, bk as SemanticComparisonOptions, bl as SequenceCameraView, bm as SequenceControls, bp as SequenceObjectProperty, bq as SequencePlaybackState, br as SequenceTarget, bu as SequenceVector3, bw as StreamingDiagnostics, bx as StyledObjectBindings, by as StyledObjectPulse, bG as ViewerConfiguration, bI as ViewerIsolation, bJ as ViewerObjectInfo, bL as ViewerRuntimeStats, bP as applyIsolation, bQ as applyStyleRules, bR as colorScaleValue, bS as compareViewerConfigurations, bT as groundAsset, bU as isolatedBindingKeys, bV as material, bW as parseAssetTransform, bX as parseSelectionSets, bY as parseViewerState, bZ as patchBindings, b_ as patchSceneConfig, b$ as prepareViewerState, c0 as selectBindingKeys, c1 as selectBindings, c2 as serializeViewerState, c3 as snapAssetToGrid } from './modelViewerProps-Ce4-wb57.mjs';
3
- export { D as DEFAULT_MODEL_VIEWER_LABELS, M as MaterialVariantGroup, a as MaterialVariantOption, c as ModelViewerLabelKey, d as ModelViewerLabels, R as ReducedMotionSetting, h as chooseMaterialVariant } from './modelFileResolver-Co7j1tdQ.mjs';
1
+ import { bl as SceneLight, ao as ObjectBinding, aD as ObjectBindingType, a9 as MeasurementUnit, a6 as MeasurementSettings, b4 as SavedMeasurement, a3 as MeasurementPoint, a5 as MeasurementResult, a8 as MeasurementTool, a2 as MeasurementCollection, ay as ObjectBindingStyle, az as ObjectBindingTarget, bs as SceneProductConfig, aS as ProductDefinition, b0 as ProductSelections, aQ as ProductConfiguration, b1 as ProductSku, aT as ProductDefinitionWarning, aK as ProductAvailability, aZ as ProductOptionState, a_ as ProductPrice, V as InspectAssetOptions, q as AssetDiagnosticsReport, e as ARSnapshotSource, A as ARExportOptions, d as ARSnapshot, bR as ShareableViewerState, c7 as ViewerStateStorage, bJ as SequenceEasing, bz as SceneSequence, bO as SequenceTrack, bP as SequenceValue, bK as SequenceKeyframe, bu as SceneSectionConfig, bx as SceneSectionSettings } from './modelViewerProps-C7saa0i2.mjs';
2
+ export { a as ARHandoffOptions, b as ARHandoffRequest, c as ARHandoffStatus, l as AnimationLoopMode, p as AssetDiagnosticIssue, r as AssetDiagnosticsSource, s as AssetTextureDiagnostic, t as AssetTransform, B as BindingEdit, E as ComparisonCategory, F as ComparisonChange, G as ComparisonHighlight, H as ComparisonObject, I as ComparisonStatus, J as ConfigurationComparisonInput, K as ConfigurationComparisonReport, N as DEFAULT_SCENE_CONFIG, O as DEFAULT_SECTION_CONFIG, Q as DeepPartial, R as EnvironmentPreset, S as GlitchModeName, W as IsolatedObjectBindings, Y as KernelSizeName, Z as MATERIAL_BLENDING_MODES, _ as MATERIAL_SIDES, $ as MAX_VIEWER_STATE_BYTES, a1 as MeasurementAnchor, a4 as MeasurementPosition, a7 as MeasurementStatus, an as ObjectActionEvent, ap as ObjectBindingAction, aq as ObjectBindingCameraState, ar as ObjectBindingDecal, as as ObjectBindingMaterial, at as ObjectBindingMaterialBlendingMode, au as ObjectBindingMaterialSide, av as ObjectBindingPatch, aw as ObjectBindingSelector, ax as ObjectBindingStatus, aA as ObjectBindingTextureChannel, aB as ObjectBindingTextureSlot, aC as ObjectBindingTransform, aF as ObjectPointerEvent, aG as ObjectSurfacePoint, aJ as ProductAppearance, aL as ProductCheckoutContext, aM as ProductCheckoutLink, aN as ProductCommerceAdapter, aO as ProductCommerceContext, aP as ProductCommerceResult, aR as ProductConfigurationIssue, aU as ProductGroupDisplay, aV as ProductOption, aW as ProductOptionGroup, aX as ProductOptionRef, aY as ProductOptionRule, a$ as ProductPricing, b2 as RampTypeName, b3 as RendererBackend, b5 as SceneAnimationClipConfig, b6 as SceneAnimationConfig, b7 as SceneAnnotationCameraView, b8 as SceneAnnotationImage, b9 as SceneAnnotationLink, ba as SceneAnnotationMarker, bb as SceneBackgroundConfig, bc as SceneCameraConfig, bd as SceneCinematicConfig, be as SceneCinematicWaypoint, bg as SceneConfig, bi as SceneConfigPatch, bj as SceneEnvironmentConfig, bk as SceneGroundShadowConfig, bm as SceneLightAttachment, bn as SceneLightType, bo as SceneLightingConfig, bp as SceneModelConfig, bq as SceneModelRenderer, br as ScenePostProcessingConfig, bt as SceneSectionAxis, by as SceneSelectionSet, bA as SceneShadowConfig, bB as SceneStyleColorScale, bC as SceneStyleCondition, bD as SceneStylePulse, bE as SceneStyleRule, bF as SceneWireframeConfig, bG as SemanticComparisonOptions, bH as SequenceCameraView, bI as SequenceControls, bL as SequenceObjectProperty, bM as SequencePlaybackState, bN as SequenceTarget, bQ as SequenceVector3, bS as StreamingDiagnostics, bT as StyledObjectBindings, bU as StyledObjectPulse, c0 as ViewerConfiguration, c2 as ViewerIsolation, c3 as ViewerObjectInfo, c6 as ViewerRuntimeStats, ca as applyIsolation, cb as applyStyleRules, cc as colorScaleValue, cd as compareViewerConfigurations, ce as groundAsset, cf as isolatedBindingKeys, cg as material, ch as parseAssetTransform, ci as parseSelectionSets, cj as parseViewerState, ck as patchBindings, cl as patchSceneConfig, cm as prepareViewerState, cn as selectBindingKeys, co as selectBindings, cp as serializeViewerState, cq as snapAssetToGrid } from './modelViewerProps-C7saa0i2.mjs';
3
+ import { M as MaterialVariantGroup } from './modelFileResolver-BEW_95id.mjs';
4
+ export { D as DEFAULT_MODEL_VIEWER_LABELS, a as MaterialVariantOption, c as ModelViewerLabelKey, d as ModelViewerLabels, R as ReducedMotionSetting, h as chooseMaterialVariant } from './modelFileResolver-BEW_95id.mjs';
4
5
  import { Object3D } from 'three';
5
6
  import 'react';
6
7
  import '@react-three/drei';
@@ -99,6 +100,48 @@ declare function copyBindingStyle(binding: ObjectBinding): ObjectBindingStyle;
99
100
  /** Replaces authored style overrides on every target, preserving all other fields. */
100
101
  declare function pasteBindingStyle(bindings: Record<string, ObjectBinding>, target: ObjectBindingTarget, style: ObjectBindingStyle): Record<string, ObjectBinding>;
101
102
 
103
+ declare function parseProductDefinition(input: unknown): ProductDefinition;
104
+ declare function defaultProductSelections(product: ProductDefinition): ProductSelections;
105
+ declare function evaluateProductConfiguration(product: ProductDefinition, input?: ProductSelections, quantity?: number): ProductConfiguration;
106
+ /**
107
+ * The fewest other choices to change so that a blocked option can be chosen, or
108
+ * null if no combination allows it. Breadth-first over the groups each conflict
109
+ * names, so it stays small on any real product.
110
+ */
111
+ declare function resolveProductSelections(product: ProductDefinition, selections: ProductSelections, groupId: string, optionId: string, quantity?: number): ProductSelections | null;
112
+ /** A price from the definition's own pricing, or null if it has none. */
113
+ declare function productPriceFromDefinition(product: ProductDefinition, configuration: ProductConfiguration): ProductPrice | null;
114
+ /** Formats minor units in a currency, such as 24900 USD as "$249.00". */
115
+ declare function formatProductPrice(amountMinor: number, currency: string, signed?: boolean): string;
116
+ /**
117
+ * The link that buys this configuration, or null while it can't be bought. Every
118
+ * value is URL-encoded, so a label or SKU can't change where the link goes.
119
+ */
120
+ declare function productCheckoutUrl(product: ProductDefinition, configuration: ProductConfiguration): string | null;
121
+ /** Choices as short text for a link: "finish:oak,seat:linen". Unset groups are left out. */
122
+ declare function encodeProductSelections(selections: ProductSelections): string;
123
+ /** Reads choices from a link. Anything this product doesn't have is ignored, not an error. */
124
+ declare function decodeProductSelections(text: string, product: ProductDefinition): ProductSelections;
125
+ /**
126
+ * An SKU table with one row for each allowed combination, built by joining each
127
+ * choice's own SKU with a separator. Combinations with a choice that has no SKU
128
+ * are left out, as are those the rules forbid.
129
+ */
130
+ declare function generateProductSkus(product: ProductDefinition, separator?: string): ProductSku[];
131
+ /** What won't work as the author expects: shown while editing, never to shoppers. */
132
+ declare function productDefinitionWarnings(product: ProductDefinition, bindings?: Record<string, ObjectBinding>, variantNames?: readonly string[]): ProductDefinitionWarning[];
133
+ /** Availability considers both directions of each rule and explains blocked choices. */
134
+ declare function productOptionStates(product: ProductDefinition, selections: ProductSelections, availability?: ProductAvailability, quantity?: number): ProductOptionState[];
135
+ declare function parseSceneProduct(input: unknown): SceneProductConfig;
136
+ /** A portable configuration never contains prices, adapter functions, or credentials. */
137
+ declare function serializeProductConfiguration(configuration: ProductConfiguration): string;
138
+ declare function parseProductConfiguration(input: unknown, product: ProductDefinition): ProductConfiguration;
139
+ /** Always start from the base bindings so changing/removing an option removes its old overrides. */
140
+ declare function applyProductOptions(bindings: Record<string, ObjectBinding>, product?: SceneProductConfig, baseVariants?: readonly string[], variantGroups?: readonly MaterialVariantGroup[]): {
141
+ objectBindings: Record<string, ObjectBinding>;
142
+ activeVariants: string[];
143
+ };
144
+
102
145
  /** Inspect loaded data without fetching, rendering, modifying, or disposing it. */
103
146
  declare function inspectAsset(scene: Object3D, options?: InspectAssetOptions): AssetDiagnosticsReport;
104
147
 
@@ -120,4 +163,4 @@ declare function parseSectionConfig(input: unknown): SceneSectionConfig;
120
163
  /** Detach a reusable snapshot without nesting the preset library. */
121
164
  declare function sectionSnapshot(section: SceneSectionConfig): SceneSectionSettings;
122
165
 
123
- export { ACTION_CATALOG, ARExportOptions, ARSnapshot, ARSnapshotSource, type ActionCatalogEntry, type ActionHandling, AssetDiagnosticsReport, InspectAssetOptions, MEASUREMENT_UNITS, MeasurementCollection, MeasurementPoint, MeasurementResult, MeasurementSettings, MeasurementTool, MeasurementUnit, ObjectBinding, type ObjectBindingActionId, type ObjectBindingKey, ObjectBindingStyle, ObjectBindingTarget, ObjectBindingType, SEQUENCE_EASINGS, SEQUENCE_OBJECT_PROPERTIES, SavedMeasurement, SceneLight, type SceneLightInput, SceneSectionConfig, SceneSequence, SequenceEasing, SequenceKeyframe, SequenceTrack, SequenceValue, ShareableViewerState, type ViewerHierarchyNode, ViewerStateStorage, buildBindingsFromNodes, calibrateMeasurements, collectObjectHierarchy, copyBindingStyle, createARHandoffUrl, createDefaultBinding, defineObjectBindings, exportConfiguredUSDZ, findCatalogAction, inferType, inspectAsset, measurementResult, measurementScale, measurementValue, measurementsToCsv, parseMeasurements, parseSectionConfig, parseSequences, pasteBindingStyle, readARHandoffUrl, sampleSequenceTrack, sceneLight, sectionSnapshot, serializeMeasurements, upsertSequenceKeyframe };
166
+ export { ACTION_CATALOG, ARExportOptions, ARSnapshot, ARSnapshotSource, type ActionCatalogEntry, type ActionHandling, AssetDiagnosticsReport, InspectAssetOptions, MEASUREMENT_UNITS, MaterialVariantGroup, MeasurementCollection, MeasurementPoint, MeasurementResult, MeasurementSettings, MeasurementTool, MeasurementUnit, ObjectBinding, type ObjectBindingActionId, type ObjectBindingKey, ObjectBindingStyle, ObjectBindingTarget, ObjectBindingType, ProductAvailability, ProductConfiguration, ProductDefinition, ProductDefinitionWarning, ProductOptionState, ProductPrice, ProductSelections, ProductSku, SEQUENCE_EASINGS, SEQUENCE_OBJECT_PROPERTIES, SavedMeasurement, SceneLight, type SceneLightInput, SceneProductConfig, SceneSectionConfig, SceneSequence, SequenceEasing, SequenceKeyframe, SequenceTrack, SequenceValue, ShareableViewerState, type ViewerHierarchyNode, ViewerStateStorage, applyProductOptions, buildBindingsFromNodes, calibrateMeasurements, collectObjectHierarchy, copyBindingStyle, createARHandoffUrl, createDefaultBinding, decodeProductSelections, defaultProductSelections, defineObjectBindings, encodeProductSelections, evaluateProductConfiguration, exportConfiguredUSDZ, findCatalogAction, formatProductPrice, generateProductSkus, inferType, inspectAsset, measurementResult, measurementScale, measurementValue, measurementsToCsv, parseMeasurements, parseProductConfiguration, parseProductDefinition, parseSceneProduct, parseSectionConfig, parseSequences, pasteBindingStyle, productCheckoutUrl, productDefinitionWarnings, productOptionStates, productPriceFromDefinition, readARHandoffUrl, resolveProductSelections, sampleSequenceTrack, sceneLight, sectionSnapshot, serializeMeasurements, serializeProductConfiguration, upsertSequenceKeyframe };
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { b0 as SceneLight, ao as ObjectBinding, aD as ObjectBindingType, a9 as MeasurementUnit, a6 as MeasurementSettings, aL as SavedMeasurement, a3 as MeasurementPoint, a5 as MeasurementResult, a8 as MeasurementTool, a2 as MeasurementCollection, ay as ObjectBindingStyle, az as ObjectBindingTarget, V as InspectAssetOptions, q as AssetDiagnosticsReport, e as ARSnapshotSource, A as ARExportOptions, d as ARSnapshot, bv as ShareableViewerState, bM as ViewerStateStorage, bn as SequenceEasing, bd as SceneSequence, bs as SequenceTrack, bt as SequenceValue, bo as SequenceKeyframe, b8 as SceneSectionConfig, bb as SceneSectionSettings } from './modelViewerProps-BibuMND7.js';
2
- export { a as ARHandoffOptions, b as ARHandoffRequest, c as ARHandoffStatus, l as AnimationLoopMode, p as AssetDiagnosticIssue, r as AssetDiagnosticsSource, s as AssetTextureDiagnostic, t as AssetTransform, B as BindingEdit, E as ComparisonCategory, F as ComparisonChange, G as ComparisonHighlight, H as ComparisonObject, I as ComparisonStatus, J as ConfigurationComparisonInput, K as ConfigurationComparisonReport, N as DEFAULT_SCENE_CONFIG, O as DEFAULT_SECTION_CONFIG, Q as DeepPartial, R as EnvironmentPreset, S as GlitchModeName, W as IsolatedObjectBindings, Y as KernelSizeName, Z as MATERIAL_BLENDING_MODES, _ as MATERIAL_SIDES, $ as MAX_VIEWER_STATE_BYTES, a1 as MeasurementAnchor, a4 as MeasurementPosition, a7 as MeasurementStatus, an as ObjectActionEvent, ap as ObjectBindingAction, aq as ObjectBindingCameraState, ar as ObjectBindingDecal, as as ObjectBindingMaterial, at as ObjectBindingMaterialBlendingMode, au as ObjectBindingMaterialSide, av as ObjectBindingPatch, aw as ObjectBindingSelector, ax as ObjectBindingStatus, aA as ObjectBindingTextureChannel, aB as ObjectBindingTextureSlot, aC as ObjectBindingTransform, aF as ObjectPointerEvent, aG as ObjectSurfacePoint, aJ as RampTypeName, aK as RendererBackend, aM as SceneAnimationClipConfig, aN as SceneAnimationConfig, aO as SceneAnnotationCameraView, aP as SceneAnnotationImage, aQ as SceneAnnotationLink, aR as SceneAnnotationMarker, aS as SceneBackgroundConfig, aT as SceneCameraConfig, aU as SceneCinematicConfig, aV as SceneCinematicWaypoint, aX as SceneConfig, aZ as SceneConfigPatch, a_ as SceneEnvironmentConfig, a$ as SceneGroundShadowConfig, b1 as SceneLightAttachment, b2 as SceneLightType, b3 as SceneLightingConfig, b4 as SceneModelConfig, b5 as SceneModelRenderer, b6 as ScenePostProcessingConfig, b7 as SceneSectionAxis, bc as SceneSelectionSet, be as SceneShadowConfig, bf as SceneStyleColorScale, bg as SceneStyleCondition, bh as SceneStylePulse, bi as SceneStyleRule, bj as SceneWireframeConfig, bk as SemanticComparisonOptions, bl as SequenceCameraView, bm as SequenceControls, bp as SequenceObjectProperty, bq as SequencePlaybackState, br as SequenceTarget, bu as SequenceVector3, bw as StreamingDiagnostics, bx as StyledObjectBindings, by as StyledObjectPulse, bG as ViewerConfiguration, bI as ViewerIsolation, bJ as ViewerObjectInfo, bL as ViewerRuntimeStats, bP as applyIsolation, bQ as applyStyleRules, bR as colorScaleValue, bS as compareViewerConfigurations, bT as groundAsset, bU as isolatedBindingKeys, bV as material, bW as parseAssetTransform, bX as parseSelectionSets, bY as parseViewerState, bZ as patchBindings, b_ as patchSceneConfig, b$ as prepareViewerState, c0 as selectBindingKeys, c1 as selectBindings, c2 as serializeViewerState, c3 as snapAssetToGrid } from './modelViewerProps-BibuMND7.js';
3
- export { D as DEFAULT_MODEL_VIEWER_LABELS, M as MaterialVariantGroup, a as MaterialVariantOption, c as ModelViewerLabelKey, d as ModelViewerLabels, R as ReducedMotionSetting, h as chooseMaterialVariant } from './modelFileResolver-Co7j1tdQ.js';
1
+ import { bl as SceneLight, ao as ObjectBinding, aD as ObjectBindingType, a9 as MeasurementUnit, a6 as MeasurementSettings, b4 as SavedMeasurement, a3 as MeasurementPoint, a5 as MeasurementResult, a8 as MeasurementTool, a2 as MeasurementCollection, ay as ObjectBindingStyle, az as ObjectBindingTarget, bs as SceneProductConfig, aS as ProductDefinition, b0 as ProductSelections, aQ as ProductConfiguration, b1 as ProductSku, aT as ProductDefinitionWarning, aK as ProductAvailability, aZ as ProductOptionState, a_ as ProductPrice, V as InspectAssetOptions, q as AssetDiagnosticsReport, e as ARSnapshotSource, A as ARExportOptions, d as ARSnapshot, bR as ShareableViewerState, c7 as ViewerStateStorage, bJ as SequenceEasing, bz as SceneSequence, bO as SequenceTrack, bP as SequenceValue, bK as SequenceKeyframe, bu as SceneSectionConfig, bx as SceneSectionSettings } from './modelViewerProps-CbK_4uZj.js';
2
+ export { a as ARHandoffOptions, b as ARHandoffRequest, c as ARHandoffStatus, l as AnimationLoopMode, p as AssetDiagnosticIssue, r as AssetDiagnosticsSource, s as AssetTextureDiagnostic, t as AssetTransform, B as BindingEdit, E as ComparisonCategory, F as ComparisonChange, G as ComparisonHighlight, H as ComparisonObject, I as ComparisonStatus, J as ConfigurationComparisonInput, K as ConfigurationComparisonReport, N as DEFAULT_SCENE_CONFIG, O as DEFAULT_SECTION_CONFIG, Q as DeepPartial, R as EnvironmentPreset, S as GlitchModeName, W as IsolatedObjectBindings, Y as KernelSizeName, Z as MATERIAL_BLENDING_MODES, _ as MATERIAL_SIDES, $ as MAX_VIEWER_STATE_BYTES, a1 as MeasurementAnchor, a4 as MeasurementPosition, a7 as MeasurementStatus, an as ObjectActionEvent, ap as ObjectBindingAction, aq as ObjectBindingCameraState, ar as ObjectBindingDecal, as as ObjectBindingMaterial, at as ObjectBindingMaterialBlendingMode, au as ObjectBindingMaterialSide, av as ObjectBindingPatch, aw as ObjectBindingSelector, ax as ObjectBindingStatus, aA as ObjectBindingTextureChannel, aB as ObjectBindingTextureSlot, aC as ObjectBindingTransform, aF as ObjectPointerEvent, aG as ObjectSurfacePoint, aJ as ProductAppearance, aL as ProductCheckoutContext, aM as ProductCheckoutLink, aN as ProductCommerceAdapter, aO as ProductCommerceContext, aP as ProductCommerceResult, aR as ProductConfigurationIssue, aU as ProductGroupDisplay, aV as ProductOption, aW as ProductOptionGroup, aX as ProductOptionRef, aY as ProductOptionRule, a$ as ProductPricing, b2 as RampTypeName, b3 as RendererBackend, b5 as SceneAnimationClipConfig, b6 as SceneAnimationConfig, b7 as SceneAnnotationCameraView, b8 as SceneAnnotationImage, b9 as SceneAnnotationLink, ba as SceneAnnotationMarker, bb as SceneBackgroundConfig, bc as SceneCameraConfig, bd as SceneCinematicConfig, be as SceneCinematicWaypoint, bg as SceneConfig, bi as SceneConfigPatch, bj as SceneEnvironmentConfig, bk as SceneGroundShadowConfig, bm as SceneLightAttachment, bn as SceneLightType, bo as SceneLightingConfig, bp as SceneModelConfig, bq as SceneModelRenderer, br as ScenePostProcessingConfig, bt as SceneSectionAxis, by as SceneSelectionSet, bA as SceneShadowConfig, bB as SceneStyleColorScale, bC as SceneStyleCondition, bD as SceneStylePulse, bE as SceneStyleRule, bF as SceneWireframeConfig, bG as SemanticComparisonOptions, bH as SequenceCameraView, bI as SequenceControls, bL as SequenceObjectProperty, bM as SequencePlaybackState, bN as SequenceTarget, bQ as SequenceVector3, bS as StreamingDiagnostics, bT as StyledObjectBindings, bU as StyledObjectPulse, c0 as ViewerConfiguration, c2 as ViewerIsolation, c3 as ViewerObjectInfo, c6 as ViewerRuntimeStats, ca as applyIsolation, cb as applyStyleRules, cc as colorScaleValue, cd as compareViewerConfigurations, ce as groundAsset, cf as isolatedBindingKeys, cg as material, ch as parseAssetTransform, ci as parseSelectionSets, cj as parseViewerState, ck as patchBindings, cl as patchSceneConfig, cm as prepareViewerState, cn as selectBindingKeys, co as selectBindings, cp as serializeViewerState, cq as snapAssetToGrid } from './modelViewerProps-CbK_4uZj.js';
3
+ import { M as MaterialVariantGroup } from './modelFileResolver-BEW_95id.js';
4
+ export { D as DEFAULT_MODEL_VIEWER_LABELS, a as MaterialVariantOption, c as ModelViewerLabelKey, d as ModelViewerLabels, R as ReducedMotionSetting, h as chooseMaterialVariant } from './modelFileResolver-BEW_95id.js';
4
5
  import { Object3D } from 'three';
5
6
  import 'react';
6
7
  import '@react-three/drei';
@@ -99,6 +100,48 @@ declare function copyBindingStyle(binding: ObjectBinding): ObjectBindingStyle;
99
100
  /** Replaces authored style overrides on every target, preserving all other fields. */
100
101
  declare function pasteBindingStyle(bindings: Record<string, ObjectBinding>, target: ObjectBindingTarget, style: ObjectBindingStyle): Record<string, ObjectBinding>;
101
102
 
103
+ declare function parseProductDefinition(input: unknown): ProductDefinition;
104
+ declare function defaultProductSelections(product: ProductDefinition): ProductSelections;
105
+ declare function evaluateProductConfiguration(product: ProductDefinition, input?: ProductSelections, quantity?: number): ProductConfiguration;
106
+ /**
107
+ * The fewest other choices to change so that a blocked option can be chosen, or
108
+ * null if no combination allows it. Breadth-first over the groups each conflict
109
+ * names, so it stays small on any real product.
110
+ */
111
+ declare function resolveProductSelections(product: ProductDefinition, selections: ProductSelections, groupId: string, optionId: string, quantity?: number): ProductSelections | null;
112
+ /** A price from the definition's own pricing, or null if it has none. */
113
+ declare function productPriceFromDefinition(product: ProductDefinition, configuration: ProductConfiguration): ProductPrice | null;
114
+ /** Formats minor units in a currency, such as 24900 USD as "$249.00". */
115
+ declare function formatProductPrice(amountMinor: number, currency: string, signed?: boolean): string;
116
+ /**
117
+ * The link that buys this configuration, or null while it can't be bought. Every
118
+ * value is URL-encoded, so a label or SKU can't change where the link goes.
119
+ */
120
+ declare function productCheckoutUrl(product: ProductDefinition, configuration: ProductConfiguration): string | null;
121
+ /** Choices as short text for a link: "finish:oak,seat:linen". Unset groups are left out. */
122
+ declare function encodeProductSelections(selections: ProductSelections): string;
123
+ /** Reads choices from a link. Anything this product doesn't have is ignored, not an error. */
124
+ declare function decodeProductSelections(text: string, product: ProductDefinition): ProductSelections;
125
+ /**
126
+ * An SKU table with one row for each allowed combination, built by joining each
127
+ * choice's own SKU with a separator. Combinations with a choice that has no SKU
128
+ * are left out, as are those the rules forbid.
129
+ */
130
+ declare function generateProductSkus(product: ProductDefinition, separator?: string): ProductSku[];
131
+ /** What won't work as the author expects: shown while editing, never to shoppers. */
132
+ declare function productDefinitionWarnings(product: ProductDefinition, bindings?: Record<string, ObjectBinding>, variantNames?: readonly string[]): ProductDefinitionWarning[];
133
+ /** Availability considers both directions of each rule and explains blocked choices. */
134
+ declare function productOptionStates(product: ProductDefinition, selections: ProductSelections, availability?: ProductAvailability, quantity?: number): ProductOptionState[];
135
+ declare function parseSceneProduct(input: unknown): SceneProductConfig;
136
+ /** A portable configuration never contains prices, adapter functions, or credentials. */
137
+ declare function serializeProductConfiguration(configuration: ProductConfiguration): string;
138
+ declare function parseProductConfiguration(input: unknown, product: ProductDefinition): ProductConfiguration;
139
+ /** Always start from the base bindings so changing/removing an option removes its old overrides. */
140
+ declare function applyProductOptions(bindings: Record<string, ObjectBinding>, product?: SceneProductConfig, baseVariants?: readonly string[], variantGroups?: readonly MaterialVariantGroup[]): {
141
+ objectBindings: Record<string, ObjectBinding>;
142
+ activeVariants: string[];
143
+ };
144
+
102
145
  /** Inspect loaded data without fetching, rendering, modifying, or disposing it. */
103
146
  declare function inspectAsset(scene: Object3D, options?: InspectAssetOptions): AssetDiagnosticsReport;
104
147
 
@@ -120,4 +163,4 @@ declare function parseSectionConfig(input: unknown): SceneSectionConfig;
120
163
  /** Detach a reusable snapshot without nesting the preset library. */
121
164
  declare function sectionSnapshot(section: SceneSectionConfig): SceneSectionSettings;
122
165
 
123
- export { ACTION_CATALOG, ARExportOptions, ARSnapshot, ARSnapshotSource, type ActionCatalogEntry, type ActionHandling, AssetDiagnosticsReport, InspectAssetOptions, MEASUREMENT_UNITS, MeasurementCollection, MeasurementPoint, MeasurementResult, MeasurementSettings, MeasurementTool, MeasurementUnit, ObjectBinding, type ObjectBindingActionId, type ObjectBindingKey, ObjectBindingStyle, ObjectBindingTarget, ObjectBindingType, SEQUENCE_EASINGS, SEQUENCE_OBJECT_PROPERTIES, SavedMeasurement, SceneLight, type SceneLightInput, SceneSectionConfig, SceneSequence, SequenceEasing, SequenceKeyframe, SequenceTrack, SequenceValue, ShareableViewerState, type ViewerHierarchyNode, ViewerStateStorage, buildBindingsFromNodes, calibrateMeasurements, collectObjectHierarchy, copyBindingStyle, createARHandoffUrl, createDefaultBinding, defineObjectBindings, exportConfiguredUSDZ, findCatalogAction, inferType, inspectAsset, measurementResult, measurementScale, measurementValue, measurementsToCsv, parseMeasurements, parseSectionConfig, parseSequences, pasteBindingStyle, readARHandoffUrl, sampleSequenceTrack, sceneLight, sectionSnapshot, serializeMeasurements, upsertSequenceKeyframe };
166
+ export { ACTION_CATALOG, ARExportOptions, ARSnapshot, ARSnapshotSource, type ActionCatalogEntry, type ActionHandling, AssetDiagnosticsReport, InspectAssetOptions, MEASUREMENT_UNITS, MaterialVariantGroup, MeasurementCollection, MeasurementPoint, MeasurementResult, MeasurementSettings, MeasurementTool, MeasurementUnit, ObjectBinding, type ObjectBindingActionId, type ObjectBindingKey, ObjectBindingStyle, ObjectBindingTarget, ObjectBindingType, ProductAvailability, ProductConfiguration, ProductDefinition, ProductDefinitionWarning, ProductOptionState, ProductPrice, ProductSelections, ProductSku, SEQUENCE_EASINGS, SEQUENCE_OBJECT_PROPERTIES, SavedMeasurement, SceneLight, type SceneLightInput, SceneProductConfig, SceneSectionConfig, SceneSequence, SequenceEasing, SequenceKeyframe, SequenceTrack, SequenceValue, ShareableViewerState, type ViewerHierarchyNode, ViewerStateStorage, applyProductOptions, buildBindingsFromNodes, calibrateMeasurements, collectObjectHierarchy, copyBindingStyle, createARHandoffUrl, createDefaultBinding, decodeProductSelections, defaultProductSelections, defineObjectBindings, encodeProductSelections, evaluateProductConfiguration, exportConfiguredUSDZ, findCatalogAction, formatProductPrice, generateProductSkus, inferType, inspectAsset, measurementResult, measurementScale, measurementValue, measurementsToCsv, parseMeasurements, parseProductConfiguration, parseProductDefinition, parseSceneProduct, parseSectionConfig, parseSequences, pasteBindingStyle, productCheckoutUrl, productDefinitionWarnings, productOptionStates, productPriceFromDefinition, readARHandoffUrl, resolveProductSelections, sampleSequenceTrack, sceneLight, sectionSnapshot, serializeMeasurements, serializeProductConfiguration, upsertSequenceKeyframe };