@liveroom-tech/react-immersive 5.1.0 → 5.2.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 (44) hide show
  1. package/README.md +486 -57
  2. package/dist/binding-builder.css +1 -1
  3. package/dist/binding-builder.js +17 -13
  4. package/dist/binding-builder.mjs +1 -1
  5. package/dist/chunk-4NLJSD3S.mjs +1 -0
  6. package/dist/chunk-B7REIGDG.mjs +1 -0
  7. package/dist/{chunk-WN6GMMHF.mjs → chunk-HYFJ5DYJ.mjs} +1 -1
  8. package/dist/chunk-QC3NT76G.mjs +3 -0
  9. package/dist/chunk-T3M3BQ7H.mjs +32 -0
  10. package/dist/chunk-ZPK67UG7.mjs +1 -0
  11. package/dist/hosted.css +1 -1
  12. package/dist/hosted.d.mts +4 -3
  13. package/dist/hosted.d.ts +4 -3
  14. package/dist/hosted.js +16 -12
  15. package/dist/hosted.mjs +1 -1
  16. package/dist/index.css +1 -1
  17. package/dist/index.d.mts +39 -8
  18. package/dist/index.d.ts +39 -8
  19. package/dist/index.js +14 -10
  20. package/dist/index.mjs +1 -1
  21. package/dist/materialVariants-DnZe9eMC.d.mts +309 -0
  22. package/dist/materialVariants-DnZe9eMC.d.ts +309 -0
  23. package/dist/modelInfo-BYebMPdZ.d.mts +43 -0
  24. package/dist/modelInfo-XfUQO7C_.d.ts +43 -0
  25. package/dist/{ModelViewer-Bj-KjiDL.d.mts → modelViewerProps-CIZ2R_Fv.d.ts} +82 -10
  26. package/dist/{ModelViewer-BkQ73y6N.d.ts → modelViewerProps-DoRiTZMn.d.mts} +82 -10
  27. package/dist/{objectCatalog-BIeXURoq.d.ts → rendererBackend-QwMzISTn.d.mts} +32 -4
  28. package/dist/{objectCatalog-BIeXURoq.d.mts → rendererBackend-QwMzISTn.d.ts} +32 -4
  29. package/dist/simple-model-viewer.css +1 -1
  30. package/dist/simple-model-viewer.d.mts +32 -4
  31. package/dist/simple-model-viewer.d.ts +32 -4
  32. package/dist/simple-model-viewer.js +3 -3
  33. package/dist/simple-model-viewer.mjs +1 -1
  34. package/dist/utils.d.mts +5 -4
  35. package/dist/utils.d.ts +5 -4
  36. package/dist/utils.js +1 -1
  37. package/dist/utils.mjs +1 -1
  38. package/package.json +2 -1
  39. package/dist/chunk-32WCLPTZ.mjs +0 -1
  40. package/dist/chunk-CSGNL4XU.mjs +0 -3
  41. package/dist/chunk-F2ILTIPG.mjs +0 -28
  42. package/dist/chunk-V6GALFL5.mjs +0 -1
  43. package/dist/modelInfo-DnkmTGMd.d.mts +0 -23
  44. package/dist/modelInfo-DnkmTGMd.d.ts +0 -23
@@ -1 +1 @@
1
- "use client";import{a as je}from"./chunk-MMO7KCYU.mjs";import{B as De,C as ze,F as Re,G as Pe,H as Le,I as Te,a as _e,b as ke,c as Me,d as Ce,e as Se,f as Ne,h as Ee}from"./chunk-V6GALFL5.mjs";import"./chunk-JR557W27.mjs";import{useRef as L,useState as u,useCallback as f,useEffect as k,useMemo as Y,Component as ut,Suspense as oe}from"react";import{CameraControls as mt,Environment as vt}from"@react-three/drei";import{useFrame as Ke,useThree as W}from"@react-three/fiber";import{Canvas as gt}from"@react-three/fiber";import{Box3 as bt,MeshStandardMaterial as ht,PerspectiveCamera as ft,Vector3 as xt}from"three";import{SkeletonUtils as wt}from"three-stdlib";import{X as de,Check as He,Settings as yt,ChevronDown as _t,Boxes as kt,Trash2 as Mt,Upload as re,AlertTriangle as Ct}from"lucide-react";import{Fragment as Ae,jsx as e,jsxs as l}from"react/jsx-runtime";var Oe={color:"#93c5fd",intensity:.05},St=["apartment","city","dawn","forest","lobby","night","park","studio","sunset","warehouse"];function Nt(t){return!!(t&&"isMesh"in t&&t.isMesh)}function Ie(t,a){Array.isArray(t)?t.forEach(a):a(t)}function Et(t,a){if(!a)return;let o=a.camera;if(!(o instanceof ft))return;let r=new bt().setFromObject(t).getSize(new xt).length();!Number.isFinite(r)||r<=0||(o.near=r/100,o.far=r*100,o.updateProjectionMatrix(),a.maxDistance=r*10)}var le=class extends ut{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(o){this.props.onLoadError?.(o)}render(){return this.state.hasError?null:this.props.children}};function Dt({url:t,format:a,dracoDecoderPath:o,ktx2TranscoderPath:r,meshopt:s,hiddenKeys:g,selectedKey:M,panelHoveredKey:w,nodeRefsOut:c,onMeshesReady:T,onModelLoaded:I,onLoadProgress:B,onMeshClick:F,highlightOnHover:p}){let{scene:D}=De(t,{dracoDecoderPath:o,ktx2TranscoderPath:r,meshopt:s},a,B),C=W(i=>i.invalidate),{setCanvasCursor:z,restoreCanvasCursor:S}=Pe(),[N,j]=u(null),h=Y(()=>wt.clone(D),[D]),y=Y(()=>{let i={};return h.traverse(d=>{if(!Nt(d))return;let b=d.name||d.uuid;i[b]={key:b,label:d.name||d.type,ref:d}}),i},[h]),E=Y(()=>{let i={};for(let[d,{ref:b}]of Object.entries(y)){let O=(Array.isArray(b.material)?b.material:[b.material]).map(m=>{let x=(ze(m)??new ht).clone();return x.userData.baseColor=x.color.clone(),x.userData.baseMap=x.map,x.userData.baseEmissive=x.emissive.clone(),x.userData.baseEmissiveMap=x.emissiveMap,x.userData.baseEmissiveIntensity=x.emissiveIntensity,x});i[d]=Array.isArray(b.material)?O:O[0]}return i},[y]);k(()=>()=>{Object.values(E).forEach(i=>Ie(i,d=>d.dispose()))},[E]);let R=L(null);k(()=>{R.current!==t&&(R.current=t,h.updateWorldMatrix(!0,!0),Re(h),T(y),I(h))},[t,h,y,T,I]),k(()=>{let i=new AbortController;return Ce(h,i.signal),()=>{i.abort(),Se(h)}},[h]);let G=Y(()=>!ke(h),[h]);k(()=>{for(let[i,{ref:d}]of Object.entries(y))c.current[i]=d},[y,c]),k(()=>{!p&&N!==null&&(j(null),S())},[p,N,S]),k(()=>{for(let[i,{ref:d}]of Object.entries(y)){d.visible=!g.has(i);let b=E[i];if(!b)continue;d.material=b;let $=p&&N===i,O=p&&w===i;Ie(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,O||$){let A=!!m.userData.baseEmissiveMap;m.emissive.set(Oe.color),m.emissiveIntensity=A?m.userData.baseEmissiveIntensity:Oe.intensity}m.needsUpdate=!0})}C()},[y,E,N,M,w,p,g,C]);let U=i=>{let d=i;for(;d;){let b=d.name||d.uuid;if(y[b])return b;d=d.parent}return null},X=G?{onClick:i=>{let d=U(i.object);d&&(i.stopPropagation(),F(d))},...p?{onPointerOver:i=>{let d=U(i.object);d&&(i.stopPropagation(),z("pointer"),j(d))},onPointerOut:i=>{i.stopPropagation(),S(),j(null)}}:{}}:{};return e("primitive",{object:h,...X})}function zt({scene:t,controlsRef:a,refitOnResize:o,onInitialFitComplete:r}){let s=L(!1),g=W(c=>c.invalidate),M=W(c=>c.size),w=L(null);return k(()=>{s.current=!1,g()},[g,t]),Ke(()=>{if(!s.current){if(!t||!a.current){g();return}s.current=!0,Et(t,a.current),a.current.fitToBox(t,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{}).finally(r)}}),k(()=>{if(!(!o||!s.current||!t||!a.current))return w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{a.current?.fitToBox(t,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{}),g()},150),()=>{w.current&&clearTimeout(w.current)}},[M.width,M.height,o]),null}function Rt({exposure:t}){let a=W(r=>r.gl),o=W(r=>r.invalidate);return k(()=>{a.toneMappingExposure=t,o()},[a,t,o]),null}function Pt({enabled:t,controlsRef:a}){let o=W(r=>r.invalidate);return Ke((r,s)=>{!t||!a.current||(a.current.rotate(s*.2,0,!1),o())}),null}function Z(t){return Array.from(t.types).includes("Files")}function Be({label:t,checked:a,onChange:o}){return l("div",{className:"env-row",children:[e("span",{className:"env-row__label",children:t}),e("div",{className:"env-row__value",children:e("button",{className:"env-checkbox-btn",onClick:()=>o(!a),children:e("span",{className:`env-checkbox${a?" env-checkbox--checked":""}`,children:a&&e(He,{size:9,strokeWidth:2,color:"white"})})})})]})}function se({label:t,value:a,onChange:o}){return l("div",{className:"env-row",children:[e("span",{className:"env-row__label",children:t}),e("div",{className:"env-row__value",children:l("div",{className:"env-color-swatch",style:{background:a},children:[e("span",{className:"env-color-swatch__hex",children:a}),e("input",{type:"color",className:"env-color-swatch__input",value:a,onChange:r=>o(r.target.value)})]})})]})}function ie({label:t,value:a,min:o,max:r,step:s,onChange:g}){return l("div",{className:"env-row",children:[e("span",{className:"env-row__label",children:t}),l("div",{className:"env-row__value env-row__value--slider",children:[e("input",{type:"range",className:"env-slider",min:o,max:r,step:s,value:a,onChange:M=>g(Number(M.target.value))}),e("span",{className:"env-slider__value",children:a.toFixed(2)})]})]})}function Lt({label:t,value:a,options:o,onChange:r}){return l("div",{className:"env-row",children:[e("span",{className:"env-row__label",children:t}),e("div",{className:"env-row__value",children:e("select",{className:"env-select",value:a,onChange:s=>r(s.target.value),children:o.map(s=>e("option",{value:s,children:s},s))})})]})}function Fe({title:t,children:a}){let[o,r]=u(!1);return l("div",{className:"env-section",children:[l("button",{className:"env-section__header",onClick:()=>r(s=>!s),children:[e(_t,{size:12,strokeWidth:2,className:`env-section__chevron${o?" env-section__chevron--collapsed":""}`}),e("span",{children:t})]}),!o&&e("div",{className:"env-section__body",children:a})]})}function Tt({isOpen:t,onToggle:a,settings:o,onChange:r}){return l("div",{className:`left-panel-wrapper ${t?"left-panel-wrapper--open":"left-panel-wrapper--closed"}`,children:[!t&&e("button",{className:"side-panel__open-btn side-panel__open-btn--left",onClick:()=>a(!0),children:e(yt,{size:20,strokeWidth:1.8})}),l("div",{className:`side-panel side-panel--left ${t?"side-panel--open-left":"side-panel--closed-left"}`,"aria-hidden":!t,children:[e("div",{className:"side-panel__header",children:l("div",{className:"side-panel__header-top",children:[e("span",{className:"side-panel__eyebrow",children:"Scene Settings"}),e("button",{className:"side-panel__close-btn",onClick:()=>a(!1),title:"Close",children:e(de,{size:12,strokeWidth:1.6})})]})}),l("div",{className:"env-controls",children:[l(Fe,{title:"Background",children:[e(Be,{label:"Background",checked:o.backgroundEnabled,onChange:s=>r("backgroundEnabled",s)}),e(se,{label:"Background Color",value:o.backgroundColor,onChange:s=>r("backgroundColor",s)}),e(Lt,{label:"Environment",value:o.envPreset,options:St,onChange:s=>r("envPreset",s)}),e(Be,{label:"Auto Rotate",checked:o.autoRotate,onChange:s=>r("autoRotate",s)})]}),l(Fe,{title:"Lighting",children:[e(ie,{label:"Exposure",value:o.exposure,min:0,max:2,step:.05,onChange:s=>r("exposure",s)}),e(ie,{label:"Ambient Light Intensity",value:o.ambientIntensity,min:0,max:3,step:.05,onChange:s=>r("ambientIntensity",s)}),e(se,{label:"Ambient Light Color",value:o.ambientColor,onChange:s=>r("ambientColor",s)}),e(ie,{label:"Direct Light Intensity",value:o.directionalIntensity,min:0,max:5,step:.05,onChange:s=>r("directionalIntensity",s)}),e(se,{label:"Direct Light Color",value:o.directionalColor,onChange:s=>r("directionalColor",s)})]})]})]})]})}function jt({meshKeys:t,hiddenKeys:a,selectedKey:o,isOpen:r,onToggle:s,onFocus:g,onHover:M,onToggleVisibility:w}){let[c,T]=u(""),[I,B]=u(null),F=Object.values(t).filter(p=>p.label.toLowerCase().includes(c.toLowerCase()));return l("div",{className:`right-panel-wrapper ${r?"right-panel-wrapper--open":"right-panel-wrapper--closed"}`,children:[!r&&e("button",{className:"side-panel__open-btn",onClick:()=>s(!0),children:e(kt,{size:20,strokeWidth:1.8})}),l("div",{className:`side-panel ${r?"side-panel--open":"side-panel--closed"}`,"aria-hidden":!r,children:[l("div",{className:"side-panel__header",children:[l("div",{className:"side-panel__header-top",children:[e("span",{className:"side-panel__eyebrow",children:"SCENE OBJECTS"}),e("button",{className:"side-panel__close-btn",onClick:()=>s(!1),title:"Close",children:e(de,{size:12,strokeWidth:1.6})})]}),l("p",{className:"side-panel__title",children:[F.length," objects"]})]}),e("div",{className:"side-panel__search-wrap",children:e("input",{className:"side-panel__search",type:"text",placeholder:"Search objects",value:c,onChange:p=>T(p.target.value)})}),e("div",{className:"side-panel__list",children:F.map(({key:p,label:D})=>{let C=!a.has(p),z=o===p,S=I===p;return l("div",{onClick:()=>g(p),onMouseEnter:()=>{B(p),M(p)},onMouseLeave:()=>{B(null),M(null)},className:["side-panel__row",S?"side-panel__row--hovered":"",z?"side-panel__row--selected":""].filter(Boolean).join(" "),children:[e("span",{className:`side-panel__label${S||z?" side-panel__label--hovered":""}`,children:D}),e("button",{className:"side-panel__vis-btn",title:C?"Hide":"Show",onClick:N=>{N.stopPropagation(),w(p)},children:e("span",{className:`side-panel__checkbox${C?" side-panel__checkbox--checked":""}`,children:C&&e(He,{size:9,strokeWidth:5,color:"white"})})})]},p)})})]})]})}function Ve({modelUrl:t,modelFormat:a,dracoDecoderPath:o,ktx2TranscoderPath:r,meshopt:s=!0,backgroundColor:g="#1a1a1a",showSceneObjectsPanel:M=!0,showSceneSettingsPanel:w=!0,enableModelUpload:c=!1,zoomOnSelected:T=!1,highlightOnHover:I=!1,showLoadingOverlay:B=!0,refitOnResize:F=!0,backgroundEnabled:p=!1,autoRotate:D=!1,envPreset:C="city",exposure:z=1,ambientIntensity:S=.6,ambientColor:N="#ffffff",directionalIntensity:j=1.2,directionalColor:h="#ffffff",onModelLoaded:y,onLoadError:E}){je("simple-model-viewer","SimpleModelViewer");let R=L(null),G=L({}),U=L(null),X=L(null),i=L(0),[d,b]=u(null),[$,O]=u(null),[m,A]=u(!1),[x,pe]=u({}),[ce,ee]=u(new Set),[ue,te]=u(null),[We,me]=u(null),[ve,ge]=u(null),[Ue,be]=u(null),[Xe,q]=u(!1),[he,fe]=u(!1),[$e,xe]=u(!1),[Ge,J]=u(null),[qe,Q]=u(!1),[Je,Qe]=u(()=>typeof window>"u"?!0:window.innerWidth>900),[Ye,Ze]=u(()=>typeof window>"u"?!0:window.innerWidth>900),[_,ne]=u({backgroundEnabled:p,backgroundColor:g,autoRotate:D,envPreset:C,exposure:z,ambientIntensity:S,ambientColor:N,directionalIntensity:j,directionalColor:h}),P=c?ve:t,K=f(()=>{b(null),O(null),A(!1),pe({}),ee(new Set),te(null),me(null),q(!1),xe(!1),J(null)},[]),H=f(()=>{X.current?.cleanup(),X.current=null},[]),et=f(()=>{H(),ge(null),be(null),K(),ne({backgroundEnabled:p,backgroundColor:g,autoRotate:D,envPreset:C,exposure:z,ambientIntensity:S,ambientColor:N,directionalIntensity:j,directionalColor:h})},[N,S,D,g,p,h,j,C,z,K,H]),we=f(async n=>{fe(!0);try{let v=await Ee(n);H(),X.current=v,ge(v.url),be(v.name),K()}catch(v){q(!0),E?.(v)}finally{fe(!1)}},[E,K,H]),ae=f(n=>{let v=n?.[0];v&&we(v)},[we]);k(()=>()=>{H()},[H]);let tt=f((n,v)=>{ne(V=>({...V,[n]:v}))},[]);k(()=>{ne(n=>({...n,backgroundColor:g}))},[g]),k(()=>{K()},[P,K]);let nt=f(n=>{pe(n),ee(new Set),te(null)},[]),at=f(n=>{b(n),q(!1);let v=Me(n);O(v>_e?v:null),A(!1),J(null),y?.(Le(n))},[y]),ot=f(n=>{q(!0),J(null),E?.(n)},[E]),rt=f(n=>{n.lengthComputable&&n.total>0&&J(n.loaded/n.total*100)},[]),ye=f(n=>{if(te(n),!T)return;let v=G.current[n];!v||!R.current||R.current.fitToBox(v,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{})},[T]),st=f(n=>{ee(v=>{let V=new Set(v);return V.has(n)?V.delete(n):V.add(n),V})},[]),it=f(n=>{!c||!Z(n.dataTransfer)||(n.preventDefault(),n.stopPropagation(),i.current+=1,Q(!0))},[c]),lt=f(n=>{!c||!Z(n.dataTransfer)||(n.preventDefault(),n.stopPropagation(),n.dataTransfer.dropEffect="copy",Q(!0))},[c]),dt=f(n=>{!c||!Z(n.dataTransfer)||(n.preventDefault(),n.stopPropagation(),i.current=Math.max(0,i.current-1),i.current===0&&Q(!1))},[c]),pt=f(n=>{!c||!Z(n.dataTransfer)||(n.preventDefault(),n.stopPropagation(),i.current=0,Q(!1),ae(n.dataTransfer.files))},[c,ae]),ct=B&&(he||!!(P&&!Xe&&(!d||!$e)));return l("div",{className:"smv-root",style:{background:_.backgroundColor},onDragEnter:it,onDragOver:lt,onDragLeave:dt,onDrop:pt,children:[w&&P&&e(Tt,{isOpen:Ye,onToggle:Ze,settings:_,onChange:tt}),l("div",{className:"smv-canvasArea",children:[$!==null&&!m&&l("div",{className:"smv-largeModelBanner",children:[e(Ct,{size:14,className:"smv-largeModelBanner__icon"}),l("span",{children:["Very large model detected (",Math.round($/1e6),"M triangles) \u2014 it may render and move slowly on this device, and click/hover selection on the model is disabled. Use the scene objects panel to select parts."]}),e("button",{type:"button",className:"smv-largeModelBanner__dismiss",onClick:()=>A(!0),"aria-label":"Dismiss",children:e(de,{size:12})})]}),c?l(Ae,{children:[e("input",{ref:U,type:"file",accept:Ne,className:"smv-upload-input",onChange:n=>{ae(n.target.files),n.currentTarget.value=""}}),P?e("div",{className:"smv-upload-toolbar",children:l(Ae,{children:[e("span",{className:"smv-upload-toolbar__name",children:Ue??"Uploaded model"}),l("button",{type:"button",className:"smv-upload-toolbar__button smv-upload-toolbar__button--ghost",onClick:et,children:[e(Mt,{size:14}),"Clear"]})]})}):null]}):null,P?e(gt,{dpr:[1,2],frameloop:"demand",resize:{debounce:0,scroll:!1},raycaster:{firstHitOnly:!0},style:{background:_.backgroundColor},camera:{position:[0,0,5],fov:45,near:.1,far:1e3},children:l(oe,{fallback:null,children:[e("ambientLight",{intensity:_.ambientIntensity,color:_.ambientColor}),e("directionalLight",{position:[-4,5,7],intensity:_.directionalIntensity,color:_.directionalColor,castShadow:!0}),e("directionalLight",{position:[-5,5,5],intensity:.5}),e(oe,{fallback:null,children:e(vt,{preset:_.envPreset,background:_.backgroundEnabled})}),e(Rt,{exposure:_.exposure}),e(Pt,{enabled:_.autoRotate,controlsRef:R}),e(le,{onLoadError:ot,children:e(oe,{fallback:null,children:e(Dt,{url:P,format:ve?void 0:a,dracoDecoderPath:o,ktx2TranscoderPath:r,meshopt:s,hiddenKeys:ce,selectedKey:ue,panelHoveredKey:We,nodeRefsOut:G,onMeshesReady:nt,onModelLoaded:at,onLoadProgress:rt,onMeshClick:ye,highlightOnHover:I})})},P),e(zt,{scene:d,controlsRef:R,refitOnResize:F,onInitialFitComplete:()=>xe(!0)}),e(mt,{ref:R,makeDefault:!0,smoothTime:.3})]})}):e("div",{className:"smv-upload-empty-state",style:{background:_.backgroundColor},children:l("div",{className:"smv-upload-empty-state__card",children:[e("div",{className:"smv-upload-empty-state__icon",children:e(re,{size:24})}),l("p",{className:"smv-upload-empty-state__body",children:["Drag and drop ",e("code",{children:".glb"}),", ",e("code",{children:".gltf"}),","," ",e("code",{children:".obj"}),", ",e("code",{children:".fbx"}),", ",e("code",{children:".usdz"}),", or"," ",e("code",{children:".zip"})," here"]}),l("button",{type:"button",className:"smv-upload-empty-state__button",onClick:()=>U.current?.click(),children:[e(re,{size:15}),"Choose model"]})]})}),e(Te,{visible:ct,message:"Loading model...",progress:he?void 0:Ge??void 0}),c&&qe?e("div",{className:"smv-upload-drop-overlay",children:l("div",{className:"smv-upload-drop-overlay__card",children:[e(re,{size:20}),e("span",{children:"Release to load your model"})]})}):null]}),M&&P&&e(jt,{meshKeys:x,hiddenKeys:ce,selectedKey:ue,isOpen:Je,onToggle:Qe,onFocus:ye,onHover:me,onToggleVisibility:st})]})}export{Ve as SimpleModelViewer};
1
+ "use client";import{a as st}from"./chunk-MMO7KCYU.mjs";import{B as Ze,C as et,F as tt,G as nt,H as rt,I as at,J as ot,a as Ie,b as Z,c as Be,d as Fe,e as Ae,f as Ke,g as He,k as Ue,l as We,m as Xe,n as $e,s as Ge,t as qe,u as Ye,v as Je,x as Qe}from"./chunk-ZPK67UG7.mjs";import{a as Bt}from"./chunk-4NLJSD3S.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 Ke(h,i.signal),()=>{i.abort(),He(h)}},[h]);let q=ee(()=>!Fe(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=Ge({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;$e(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&&Xe(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 Qe(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=Ae(t);ye(v>Be?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:Je,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(Ye,{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(Ue,{captureRef:de}),e(We,{}),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(qe,{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};
package/dist/utils.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import { a2 as SceneLight, o as ObjectBinding, L as ObjectBindingType } from './objectCatalog-BIeXURoq.mjs';
2
- export { f as AnimationLoopMode, B as BindingEdit, D as DEFAULT_SCENE_CONFIG, j as DEFAULT_SECTION_CONFIG, k as DeepPartial, E as EnvironmentPreset, G as GlitchModeName, I as IsolatedObjectBindings, K as KernelSizeName, M as MATERIAL_BLENDING_MODES, m as MATERIAL_SIDES, n as ObjectActionEvent, p as ObjectBindingAction, q as ObjectBindingCameraState, r as ObjectBindingDecal, s as ObjectBindingMaterial, t as ObjectBindingMaterialBlendingMode, u as ObjectBindingMaterialSide, v as ObjectBindingPatch, w as ObjectBindingSelector, x as ObjectBindingStatus, y as ObjectBindingStyle, z as ObjectBindingTarget, F as ObjectBindingTextureChannel, H as ObjectBindingTextureSlot, J as ObjectBindingTransform, P as ObjectPointerEvent, Q as ObjectSurfacePoint, R as RampTypeName, S as SceneAnimationClipConfig, T as SceneAnimationConfig, U as SceneAnnotationMarker, V as SceneBackgroundConfig, W as SceneCameraConfig, X as SceneCinematicConfig, Y as SceneCinematicWaypoint, Z as SceneConfig, $ as SceneConfigPatch, a0 as SceneEnvironmentConfig, a1 as SceneGroundShadowConfig, a3 as SceneLightAttachment, a4 as SceneLightType, a5 as SceneLightingConfig, a6 as SceneModelConfig, a7 as SceneModelRenderer, a8 as ScenePostProcessingConfig, a9 as SceneSectionAxis, aa as SceneSectionConfig, ab as SceneShadowConfig, ac as SceneStyleColorScale, ad as SceneStyleCondition, ae as SceneStylePulse, af as SceneStyleRule, ag as SceneWireframeConfig, ah as StyledObjectBindings, ai as StyledObjectPulse, am as ViewerIsolation, an as ViewerObjectInfo, ap as applyIsolation, aq as applyStyleRules, ar as colorScaleValue, as as isolatedBindingKeys, at as material, au as patchBindings, av as patchSceneConfig, aw as selectBindingKeys, ax as selectBindings } from './objectCatalog-BIeXURoq.mjs';
1
+ import { a6 as SceneLight, o as ObjectBinding, L as ObjectBindingType } from './rendererBackend-QwMzISTn.mjs';
2
+ export { f as AnimationLoopMode, B as BindingEdit, D as DEFAULT_SCENE_CONFIG, j as DEFAULT_SECTION_CONFIG, k as DeepPartial, E as EnvironmentPreset, G as GlitchModeName, I as IsolatedObjectBindings, K as KernelSizeName, M as MATERIAL_BLENDING_MODES, m as MATERIAL_SIDES, n as ObjectActionEvent, p as ObjectBindingAction, q as ObjectBindingCameraState, r as ObjectBindingDecal, s as ObjectBindingMaterial, t as ObjectBindingMaterialBlendingMode, u as ObjectBindingMaterialSide, v as ObjectBindingPatch, w as ObjectBindingSelector, x as ObjectBindingStatus, y as ObjectBindingStyle, z as ObjectBindingTarget, F as ObjectBindingTextureChannel, H as ObjectBindingTextureSlot, J as ObjectBindingTransform, P as ObjectPointerEvent, Q as ObjectSurfacePoint, R as RampTypeName, S as RendererBackend, T as SceneAnimationClipConfig, U as SceneAnimationConfig, V as SceneAnnotationCameraView, W as SceneAnnotationImage, X as SceneAnnotationLink, Y as SceneAnnotationMarker, Z as SceneBackgroundConfig, _ as SceneCameraConfig, $ as SceneCinematicConfig, a0 as SceneCinematicWaypoint, a1 as SceneConfig, a3 as SceneConfigPatch, a4 as SceneEnvironmentConfig, a5 as SceneGroundShadowConfig, a7 as SceneLightAttachment, a8 as SceneLightType, a9 as SceneLightingConfig, aa as SceneModelConfig, ab as SceneModelRenderer, ac as ScenePostProcessingConfig, ad as SceneSectionAxis, ae as SceneSectionConfig, af as SceneShadowConfig, ag as SceneStyleColorScale, ah as SceneStyleCondition, ai as SceneStylePulse, aj as SceneStyleRule, ak as SceneWireframeConfig, al as StyledObjectBindings, am as StyledObjectPulse, aq as ViewerIsolation, ar as ViewerObjectInfo, at as applyIsolation, au as applyStyleRules, av as colorScaleValue, aw as isolatedBindingKeys, ax as material, ay as patchBindings, az as patchSceneConfig, aA as selectBindingKeys, aB as selectBindings } from './rendererBackend-QwMzISTn.mjs';
3
+ export { D as DEFAULT_MODEL_VIEWER_LABELS, M as MaterialVariantGroup, a as MaterialVariantOption, b as ModelViewerLabelKey, c as ModelViewerLabels, R as ReducedMotionSetting, d as chooseMaterialVariant } from './materialVariants-DnZe9eMC.mjs';
3
4
 
4
5
  /** A light's id plus whichever of its settings you want to set. */
5
6
  type SceneLightInput = Pick<SceneLight, "id"> & Partial<Omit<SceneLight, "id">>;
@@ -35,8 +36,8 @@ type ObjectBindingActionId<TBindings extends Record<string, ObjectBinding>, TKey
35
36
  } ? TId : never : never;
36
37
 
37
38
  declare function inferType(nodeName: string): ObjectBindingType;
38
- declare function createDefaultBinding(nodeName: string): ObjectBinding;
39
- declare function buildBindingsFromNodes(nodeNames: string[]): Record<string, ObjectBinding>;
39
+ declare function createDefaultBinding(nodeName: string, takesImage?: boolean): ObjectBinding;
40
+ declare function buildBindingsFromNodes(nodeNames: string[], withoutUvs?: ReadonlySet<string>): Record<string, ObjectBinding>;
40
41
 
41
42
  /**
42
43
  * The action ids the runtime actually recognises.
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { a2 as SceneLight, o as ObjectBinding, L as ObjectBindingType } from './objectCatalog-BIeXURoq.js';
2
- export { f as AnimationLoopMode, B as BindingEdit, D as DEFAULT_SCENE_CONFIG, j as DEFAULT_SECTION_CONFIG, k as DeepPartial, E as EnvironmentPreset, G as GlitchModeName, I as IsolatedObjectBindings, K as KernelSizeName, M as MATERIAL_BLENDING_MODES, m as MATERIAL_SIDES, n as ObjectActionEvent, p as ObjectBindingAction, q as ObjectBindingCameraState, r as ObjectBindingDecal, s as ObjectBindingMaterial, t as ObjectBindingMaterialBlendingMode, u as ObjectBindingMaterialSide, v as ObjectBindingPatch, w as ObjectBindingSelector, x as ObjectBindingStatus, y as ObjectBindingStyle, z as ObjectBindingTarget, F as ObjectBindingTextureChannel, H as ObjectBindingTextureSlot, J as ObjectBindingTransform, P as ObjectPointerEvent, Q as ObjectSurfacePoint, R as RampTypeName, S as SceneAnimationClipConfig, T as SceneAnimationConfig, U as SceneAnnotationMarker, V as SceneBackgroundConfig, W as SceneCameraConfig, X as SceneCinematicConfig, Y as SceneCinematicWaypoint, Z as SceneConfig, $ as SceneConfigPatch, a0 as SceneEnvironmentConfig, a1 as SceneGroundShadowConfig, a3 as SceneLightAttachment, a4 as SceneLightType, a5 as SceneLightingConfig, a6 as SceneModelConfig, a7 as SceneModelRenderer, a8 as ScenePostProcessingConfig, a9 as SceneSectionAxis, aa as SceneSectionConfig, ab as SceneShadowConfig, ac as SceneStyleColorScale, ad as SceneStyleCondition, ae as SceneStylePulse, af as SceneStyleRule, ag as SceneWireframeConfig, ah as StyledObjectBindings, ai as StyledObjectPulse, am as ViewerIsolation, an as ViewerObjectInfo, ap as applyIsolation, aq as applyStyleRules, ar as colorScaleValue, as as isolatedBindingKeys, at as material, au as patchBindings, av as patchSceneConfig, aw as selectBindingKeys, ax as selectBindings } from './objectCatalog-BIeXURoq.js';
1
+ import { a6 as SceneLight, o as ObjectBinding, L as ObjectBindingType } from './rendererBackend-QwMzISTn.js';
2
+ export { f as AnimationLoopMode, B as BindingEdit, D as DEFAULT_SCENE_CONFIG, j as DEFAULT_SECTION_CONFIG, k as DeepPartial, E as EnvironmentPreset, G as GlitchModeName, I as IsolatedObjectBindings, K as KernelSizeName, M as MATERIAL_BLENDING_MODES, m as MATERIAL_SIDES, n as ObjectActionEvent, p as ObjectBindingAction, q as ObjectBindingCameraState, r as ObjectBindingDecal, s as ObjectBindingMaterial, t as ObjectBindingMaterialBlendingMode, u as ObjectBindingMaterialSide, v as ObjectBindingPatch, w as ObjectBindingSelector, x as ObjectBindingStatus, y as ObjectBindingStyle, z as ObjectBindingTarget, F as ObjectBindingTextureChannel, H as ObjectBindingTextureSlot, J as ObjectBindingTransform, P as ObjectPointerEvent, Q as ObjectSurfacePoint, R as RampTypeName, S as RendererBackend, T as SceneAnimationClipConfig, U as SceneAnimationConfig, V as SceneAnnotationCameraView, W as SceneAnnotationImage, X as SceneAnnotationLink, Y as SceneAnnotationMarker, Z as SceneBackgroundConfig, _ as SceneCameraConfig, $ as SceneCinematicConfig, a0 as SceneCinematicWaypoint, a1 as SceneConfig, a3 as SceneConfigPatch, a4 as SceneEnvironmentConfig, a5 as SceneGroundShadowConfig, a7 as SceneLightAttachment, a8 as SceneLightType, a9 as SceneLightingConfig, aa as SceneModelConfig, ab as SceneModelRenderer, ac as ScenePostProcessingConfig, ad as SceneSectionAxis, ae as SceneSectionConfig, af as SceneShadowConfig, ag as SceneStyleColorScale, ah as SceneStyleCondition, ai as SceneStylePulse, aj as SceneStyleRule, ak as SceneWireframeConfig, al as StyledObjectBindings, am as StyledObjectPulse, aq as ViewerIsolation, ar as ViewerObjectInfo, at as applyIsolation, au as applyStyleRules, av as colorScaleValue, aw as isolatedBindingKeys, ax as material, ay as patchBindings, az as patchSceneConfig, aA as selectBindingKeys, aB as selectBindings } from './rendererBackend-QwMzISTn.js';
3
+ export { D as DEFAULT_MODEL_VIEWER_LABELS, M as MaterialVariantGroup, a as MaterialVariantOption, b as ModelViewerLabelKey, c as ModelViewerLabels, R as ReducedMotionSetting, d as chooseMaterialVariant } from './materialVariants-DnZe9eMC.js';
3
4
 
4
5
  /** A light's id plus whichever of its settings you want to set. */
5
6
  type SceneLightInput = Pick<SceneLight, "id"> & Partial<Omit<SceneLight, "id">>;
@@ -35,8 +36,8 @@ type ObjectBindingActionId<TBindings extends Record<string, ObjectBinding>, TKey
35
36
  } ? TId : never : never;
36
37
 
37
38
  declare function inferType(nodeName: string): ObjectBindingType;
38
- declare function createDefaultBinding(nodeName: string): ObjectBinding;
39
- declare function buildBindingsFromNodes(nodeNames: string[]): Record<string, ObjectBinding>;
39
+ declare function createDefaultBinding(nodeName: string, takesImage?: boolean): ObjectBinding;
40
+ declare function buildBindingsFromNodes(nodeNames: string[], withoutUvs?: ReadonlySet<string>): Record<string, ObjectBinding>;
40
41
 
41
42
  /**
42
43
  * The action ids the runtime actually recognises.
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- "use strict";var h=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var U=(n,e)=>{for(var t in e)h(n,t,{get:e[t],enumerable:!0})},W=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of V(e))!K.call(n,i)&&i!==t&&h(n,i,{get:()=>e[i],enumerable:!(o=F(e,i))||o.enumerable});return n};var H=n=>W(h({},"__esModule",{value:!0}),n);var ce={};U(ce,{ACTION_CATALOG:()=>p,DEFAULT_SCENE_CONFIG:()=>G,DEFAULT_SECTION_CONFIG:()=>z,MATERIAL_BLENDING_MODES:()=>D,MATERIAL_SIDES:()=>_,applyIsolation:()=>L,applyStyleRules:()=>R,buildBindingsFromNodes:()=>P,colorScaleValue:()=>O,createDefaultBinding:()=>x,defineObjectBindings:()=>C,findCatalogAction:()=>N,inferType:()=>j,isolatedBindingKeys:()=>B,material:()=>M,patchBindings:()=>A,patchSceneConfig:()=>E,sceneLight:()=>v,selectBindingKeys:()=>b,selectBindings:()=>T});module.exports=H(ce);function C(n){return n}function y(n){if(typeof n!="object"||n===null)return!1;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function m(n,e){if(!y(e))return e;let t=y(n)?{...n}:{};for(let o of Object.keys(e)){let i=e[o];t[o]=y(i)?m(t[o],i):i}return t}function w(n,e){if(n[e])return e;let t=Object.entries(n).find(([,i])=>i.id===e)?.[0];return t||(Object.entries(n).find(([,i])=>i.modelObjectId===e)?.[0]??null)}function Y(n){return typeof n=="object"&&!Array.isArray(n)}function $(n,e){return"group"in e?n.group===e.group:"tag"in e?n.tags?.includes(e.tag)??!1:(n.type??"other")===e.type}function b(n,e){if(Y(e))return Object.entries(n).filter(([,i])=>$(i,e)).map(([i])=>i);let o=(typeof e=="string"?[e]:e).map(i=>w(n,i)).filter(i=>i!==null);return[...new Set(o)]}function T(n,e){return b(n,e).map(t=>n[t]).filter(t=>t!==void 0)}function X(n){return Array.isArray(n)&&n.length>0&&typeof n[0]!="string"}function A(n,e,t){let o=X(e)?e:[{ids:e,patch:t??{}}],i=n;for(let c of o)for(let r of b(i,c.ids)){let l=i[r];if(!l)continue;let a=m(l,c.patch);i===n&&(i={...n}),i[r]=a}return i}function M(n){return{style:{material:n}}}function E(n,e){return m(n,e)}var Z={type:"point",color:"#ffffff",intensity:1,position:[0,0,0],distance:0,decay:2,attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0};function v(n){return{...Z,...n}}var q="#ff3b30",J=Object.freeze({}),k=n=>n;function Q(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function ee(n,e){let t=n.metadata;for(let o of e.split(".")){if(!Q(t))return;t=t[o]}return t}function ne(n,e){if("metric"in e){let t=n.metrics?.[e.metric];return!(typeof t!="number"||!Number.isFinite(t)||e.above!==void 0&&!(t>e.above)||e.below!==void 0&&!(t<e.below))}if("status"in e){let t=n.status??"normal";return Array.isArray(e.status)?e.status.includes(t):e.status===t}return ee(n,e.metadata)===e.equals}function te(n){let e=n.trim().replace(/^#/,""),t=e.length===3?e.split("").map(o=>o+o).join(""):e;return/^[0-9a-f]{6}$/i.test(t)?[0,2,4].map(o=>parseInt(t.slice(o,o+2),16)):null}var S=n=>`#${n.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`;function O(n,e){let t=n.map(([a,s])=>({at:a,rgb:te(s)})).filter(a=>Number.isFinite(a.at)&&a.rgb!==null).sort((a,s)=>a.at-s.at);if(t.length===0||!Number.isFinite(e))return null;if(e<=t[0].at)return S(t[0].rgb);let o=t[t.length-1];if(e>=o.at)return S(o.rgb);let i=t.findIndex(a=>a.at>=e),c=t[i-1],r=t[i],l=r.at===c.at?1:(e-c.at)/(r.at-c.at);return S(c.rgb.map((a,s)=>a+(r.rgb[s]-a)*l))}function R(n,e){if(!e?.length)return{bindings:n,pulses:J,sourceOf:k};let t=new Map,o={};for(let r of e){let l=r.target?b(n,r.target):Object.keys(n),a=r.when?Array.isArray(r.when)?r.when:[r.when]:[];for(let s of l){let f=n[s];if(!a.every(d=>ne(f,d)))continue;let u={...r.material};if(r.colorScale){let d=f.metrics?.[r.colorScale.metric],g=typeof d=="number"?O(r.colorScale.stops,d):null;g&&(u={...u,[r.colorScale.channel??"baseColor"]:g})}if(r.pulse){let d=r.pulse===!0?{}:r.pulse;o[s]={color:d.color??q,speed:d.speed!==void 0&&d.speed>0?d.speed:1};let g=u.emissiveIntensity??t.get(s)?.emissiveIntensity??f.style?.material?.emissiveIntensity;g!==void 0&&g>0||(u.emissiveIntensity=1)}Object.keys(u).length>0&&t.set(s,{...t.get(s),...u})}}if(t.size===0)return{bindings:n,pulses:o,sourceOf:k};let i={...n},c=new WeakMap;for(let[r,l]of t){let a=n[r],s={...a,style:{...a.style,material:{...a.style?.material,...l}}};i[r]=s,c.set(s,a)}return{bindings:i,pulses:o,sourceOf:r=>c.get(r)??r}}var ie=.12,I=new Set;function B(n,e){return e?new Set(b(n,e.target)):I}function L(n,e){let t=B(n.bindings,e);if(!e||t.size===0)return{...n,setAside:I};let o=Math.min(Math.max(e.ghostOpacity??ie,0),1),i={...n.bindings},c=new WeakMap,r=new Set;for(let[l,a]of Object.entries(n.bindings)){if(t.has(l))continue;r.add(l);let s=e.mode==="hide"?{...a,visible:!1}:{...a,style:{...a.style,material:{...a.style?.material,opacity:Math.min(a.style?.material?.opacity??1,o)}}};i[l]=s,c.set(s,n.sourceOf(a))}return{bindings:i,pulses:n.pulses,sourceOf:l=>c.get(l)??n.sourceOf(l),setAside:r}}var p=Object.freeze([{id:"change-color",label:"Change Color",handling:"viewer",description:"Opens a color picker docked under the action and commits the result to style.material.baseColor."},{id:"change-material",label:"Change Material",handling:"viewer",description:"Opens the material picker so the viewer can swap the object's texture."},{id:"add-text",label:"Add Text",handling:"viewer",description:"Opens a text box docked under the action; the viewer's user types, clicks the object to place it, and can resize, turn, move, or remove it. Saved to the binding's decals."},{id:"add-image",label:"Add Image",handling:"viewer",description:"Lets the viewer's user choose an image, click the object to place it, and resize, turn, move, or remove it. Saved to the binding's decals."},{id:"toggle-visibility",label:"Toggle Visibility",handling:"viewer",description:"Flips the binding's visible flag."},{id:"toggle-light",label:"Toggle Light",handling:"viewer",description:"Turns the scene lights attached to this object on or off, or the object's own glow when none is attached."},{id:"change-light-color",label:"Change Light Color",handling:"viewer",description:"Opens a color picker docked under the action for the scene lights attached to this object, or the object's own glow."},{id:"set-brightness",label:"Set Brightness",handling:"viewer",description:"Opens a brightness slider docked under the action for the scene lights attached to this object, or the object's own glow."}]);function N(n){return p.find(e=>e.id===n)}var Te=p.filter(n=>n.handling==="viewer").map(n=>n.id),Ae=new Set(["","New Action",...p.map(n=>n.label)]);function re(n){return n.trim().replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").replace(/[^a-zA-Z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase()}function oe(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase())}function j(n){let e=n.toLowerCase();return e.includes("light")?"light":e.includes("wheel")||e.includes("rim")||e.includes("tire")?"wheel":e.includes("glass")||e.includes("window")||e.includes("windshield")||e.includes("sunroof")?"glass":e.includes("seat")||e.includes("dashboard")||e.includes("console")||e.includes("doorpanel")?"interior":e.includes("floor")?"floor":e.includes("wall")?"wall":e.includes("door")?"door":e.includes("chair")||e.includes("table")||e.includes("sofa")||e.includes("bed")?"furniture":"other"}function ae(n){return n==="light"||n.endsWith("light")?[{id:"toggle-light",label:"Toggle Light",type:"command"},{id:"change-light-color",label:"Change Light Color",type:"command"},{id:"set-brightness",label:"Set Brightness",type:"command"}]:[{id:"change-color",label:"Change Color",type:"command"},{id:"change-material",label:"Change Material",type:"command"},{id:"toggle-visibility",label:"Toggle Visibility",type:"command"}]}function x(n){let e=j(n);return{id:re(n),modelObjectId:n,type:e,label:oe(n),status:"normal",selectable:!0,hoverable:!0,visible:!0,style:{},actions:ae(e),metrics:{},metadata:{}}}function P(n){return Object.fromEntries(n.map(e=>[e,x(e)]))}var _=["front","back","double"],D=["normal","additive"];var z={enabled:!1,axis:"y",position:.5,flip:!1},se={clips:[],autoplayClip:null},le={autofocus:{enabled:!1,focusDistance:5,focusRange:5,focalLength:.02,bokehScale:6,target:[0,0,0],mouse:!0,debug:0,manual:!1,smoothTime:.25},toneMapping:{enabled:!1,mode:"aces",exposure:1,resolution:256,whitePoint:4,middleGrey:.6,minLuminance:.01,averageLuminance:1,adaptationRate:1},brightnessContrast:{enabled:!1,brightness:0,contrast:0},hueSaturation:{enabled:!1,hue:0,saturation:0},colorAverage:{enabled:!1},dotScreen:{enabled:!1,angle:Math.PI/2,scale:1},glitch:{enabled:!1,mode:"sporadic",delay:[1.5,3.5],duration:[.6,1],strength:[.3,1],chromaticAberrationOffset:[0,0],columns:.05,ratio:.85},ssao:{enabled:!1,samples:30,rings:4,intensity:8,radius:.25,bias:.025,luminanceInfluence:.6,fade:.01,minRadiusScale:.33,worldDistanceThreshold:20,worldDistanceFalloff:5,worldProximityThreshold:6,worldProximityFalloff:3},bloom:{enabled:!1,intensity:.3,luminanceThreshold:.9,luminanceSmoothing:.2,mipmapBlur:!0,radius:0,levels:8},godRays:{enabled:!1,sunPosition:[5,10,5],samples:60,density:.96,decay:.9,weight:.4,exposure:.6,clampMax:1,blur:!0,kernelSize:"small"},grid:{enabled:!1,scale:1,lineWidth:0},noise:{enabled:!1,opacity:1,premultiply:!1},depthOfField:{enabled:!1,focusDistance:5,focusRange:5,focalLength:.02,bokehScale:6},chromaticAberration:{enabled:!1,offsetX:.002,offsetY:.002,radialModulation:!1,modulationOffset:.15},lensflare:{enabled:!1,lensPosition:[-25,6,-60],smoothTime:.07,glareSize:.2,flareSize:.01,flareSpeed:.01,flareShape:.01,animated:!0,anamorphic:!1,colorGain:"#141414",haloScale:.5,secondaryGhosts:!0,aditionalStreaks:!0,ghostScale:0,opacity:1,starBurst:!1},vignette:{enabled:!1,offset:.3,darkness:.3,eskil:!1},smaa:{enabled:!1},sepia:{enabled:!1,intensity:0},scanline:{enabled:!1,density:1.25},pixelation:{enabled:!1,granularity:5},outline:{enabled:!1,selectionLayer:10,edgeStrength:2.5,pulseSpeed:0,visibleEdgeColor:"#ffffff",hiddenEdgeColor:"#22090a",kernelSize:"large",blur:!1,xRay:!0},selectiveBloom:{enabled:!1,selectionLayer:10,intensity:1,luminanceThreshold:.9,luminanceSmoothing:.025,kernelSize:"large",mipmapBlur:!0,inverted:!1,ignoreBackground:!1},ramp:{enabled:!1,rampType:"linear",rampStart:[.5,.5],rampEnd:[1,1],startColor:"#000000",endColor:"#ffffff",opacity:.5,rampBias:.5,rampGain:.5,rampMask:!1,rampInvert:!1}},G={model:{rotation:[0,0,0],showAdvancedRotation:!1,renderer:"pbr",shading:"lit",autoRotate:!1,autoRotateSpeed:1,materialVariant:null},camera:{fieldOfView:50,showAdvancedSettings:!1},lighting:{ambient:{intensity:.25,color:"#ffffff"},lights:[{id:"light-hemi",type:"hemisphere",color:"#ffffff",intensity:.3,position:[0,1,0],attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0},{id:"light-key",type:"directional",color:"#ffffff",intensity:2.5,position:[6,12,6],attachedToCamera:!1,castShadow:!0,shadowBias:-5e-4,visible:!0},{id:"light-fill",type:"directional",color:"#ffffff",intensity:0,position:[-6,8,-6],attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0}]},shadows:{enabled:!0,mapSize:2048,bias:-5e-4,normalBias:.02,radius:3},environment:{source:"preset",preset:"apartment",customEnvironmentUrl:"",intensity:.25,rotation:0,shadowLight:{enabled:!1,intensity:2.5,bias:-5e-4}},wireframe:{enabled:!1,color:"#000000",opacity:1},background:{enabled:!1,type:"color",color:"#1c1c1d",imageUrl:""},groundShadows:{enabled:!1,mode:"shadowCatcher",intensity:.7,borderFade:1,height:0,size:10},postProcessing:le,animations:se,annotations:[]};0&&(module.exports={ACTION_CATALOG,DEFAULT_SCENE_CONFIG,DEFAULT_SECTION_CONFIG,MATERIAL_BLENDING_MODES,MATERIAL_SIDES,applyIsolation,applyStyleRules,buildBindingsFromNodes,colorScaleValue,createDefaultBinding,defineObjectBindings,findCatalogAction,inferType,isolatedBindingKeys,material,patchBindings,patchSceneConfig,sceneLight,selectBindingKeys,selectBindings});
1
+ "use strict";var h=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var W=(n,e)=>{for(var t in e)h(n,t,{get:e[t],enumerable:!0})},Y=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of H(e))!K.call(n,i)&&i!==t&&h(n,i,{get:()=>e[i],enumerable:!(r=U(e,i))||r.enumerable});return n};var $=n=>Y(h({},"__esModule",{value:!0}),n);var ue={};W(ue,{ACTION_CATALOG:()=>b,DEFAULT_MODEL_VIEWER_LABELS:()=>B,DEFAULT_SCENE_CONFIG:()=>z,DEFAULT_SECTION_CONFIG:()=>G,MATERIAL_BLENDING_MODES:()=>F,MATERIAL_SIDES:()=>_,applyIsolation:()=>V,applyStyleRules:()=>L,buildBindingsFromNodes:()=>N,chooseMaterialVariant:()=>P,colorScaleValue:()=>x,createDefaultBinding:()=>v,defineObjectBindings:()=>j,findCatalogAction:()=>D,inferType:()=>w,isolatedBindingKeys:()=>O,material:()=>M,patchBindings:()=>A,patchSceneConfig:()=>E,sceneLight:()=>k,selectBindingKeys:()=>u,selectBindings:()=>T});module.exports=$(ue);function j(n){return n}function y(n){if(typeof n!="object"||n===null)return!1;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function p(n,e){if(!y(e))return e;let t=y(n)?{...n}:{};for(let r of Object.keys(e)){let i=e[r];t[r]=y(i)?p(t[r],i):i}return t}function C(n,e){if(n[e])return e;let t=Object.entries(n).find(([,i])=>i.id===e)?.[0];return t||(Object.entries(n).find(([,i])=>i.modelObjectId===e)?.[0]??null)}function X(n){return typeof n=="object"&&!Array.isArray(n)}function q(n,e){return"group"in e?n.group===e.group:"tag"in e?n.tags?.includes(e.tag)??!1:(n.type??"other")===e.type}function u(n,e){if(X(e))return Object.entries(n).filter(([,i])=>q(i,e)).map(([i])=>i);let r=(typeof e=="string"?[e]:e).map(i=>C(n,i)).filter(i=>i!==null);return[...new Set(r)]}function T(n,e){return u(n,e).map(t=>n[t]).filter(t=>t!==void 0)}function Z(n){return Array.isArray(n)&&n.length>0&&typeof n[0]!="string"}function A(n,e,t){let r=Z(e)?e:[{ids:e,patch:t??{}}],i=n;for(let s of r)for(let o of u(i,s.ids)){let c=i[o];if(!c)continue;let a=p(c,s.patch);i===n&&(i={...n}),i[o]=a}return i}function M(n){return{style:{material:n}}}function E(n,e){return p(n,e)}var Q={type:"point",color:"#ffffff",intensity:1,position:[0,0,0],distance:0,decay:2,attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0};function k(n){return{...Q,...n}}var J="#ff3b30",ee=Object.freeze({}),R=n=>n;function ne(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function te(n,e){let t=n.metadata;for(let r of e.split(".")){if(!ne(t))return;t=t[r]}return t}function ie(n,e){if("metric"in e){let t=n.metrics?.[e.metric];return!(typeof t!="number"||!Number.isFinite(t)||e.above!==void 0&&!(t>e.above)||e.below!==void 0&&!(t<e.below))}if("status"in e){let t=n.status??"normal";return Array.isArray(e.status)?e.status.includes(t):e.status===t}return te(n,e.metadata)===e.equals}function oe(n){let e=n.trim().replace(/^#/,""),t=e.length===3?e.split("").map(r=>r+r).join(""):e;return/^[0-9a-f]{6}$/i.test(t)?[0,2,4].map(r=>parseInt(t.slice(r,r+2),16)):null}var S=n=>`#${n.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`;function x(n,e){let t=n.map(([a,l])=>({at:a,rgb:oe(l)})).filter(a=>Number.isFinite(a.at)&&a.rgb!==null).sort((a,l)=>a.at-l.at);if(t.length===0||!Number.isFinite(e))return null;if(e<=t[0].at)return S(t[0].rgb);let r=t[t.length-1];if(e>=r.at)return S(r.rgb);let i=t.findIndex(a=>a.at>=e),s=t[i-1],o=t[i],c=o.at===s.at?1:(e-s.at)/(o.at-s.at);return S(s.rgb.map((a,l)=>a+(o.rgb[l]-a)*c))}function L(n,e){if(!e?.length)return{bindings:n,pulses:ee,sourceOf:R};let t=new Map,r={};for(let o of e){let c=o.target?u(n,o.target):Object.keys(n),a=o.when?Array.isArray(o.when)?o.when:[o.when]:[];for(let l of c){let f=n[l];if(!a.every(d=>ie(f,d)))continue;let m={...o.material};if(o.colorScale){let d=f.metrics?.[o.colorScale.metric],g=typeof d=="number"?x(o.colorScale.stops,d):null;g&&(m={...m,[o.colorScale.channel??"baseColor"]:g})}if(o.pulse){let d=o.pulse===!0?{}:o.pulse;r[l]={color:d.color??J,speed:d.speed!==void 0&&d.speed>0?d.speed:1};let g=m.emissiveIntensity??t.get(l)?.emissiveIntensity??f.style?.material?.emissiveIntensity;g!==void 0&&g>0||(m.emissiveIntensity=1)}Object.keys(m).length>0&&t.set(l,{...t.get(l),...m})}}if(t.size===0)return{bindings:n,pulses:r,sourceOf:R};let i={...n},s=new WeakMap;for(let[o,c]of t){let a=n[o],l={...a,style:{...a.style,material:{...a.style?.material,...c}}};i[o]=l,s.set(l,a)}return{bindings:i,pulses:r,sourceOf:o=>s.get(o)??o}}function P(n,e,t){let r=t.find(s=>s.variants.some(o=>o.name===e)),i=new Set(r?.variants.map(s=>s.name)??[e]);return[...n.filter(s=>!i.has(s)),e]}var re=.12,I=new Set;function O(n,e){return e?new Set(u(n,e.target)):I}function V(n,e){let t=O(n.bindings,e);if(!e||t.size===0)return{...n,setAside:I};let r=Math.min(Math.max(e.ghostOpacity??re,0),1),i={...n.bindings},s=new WeakMap,o=new Set;for(let[c,a]of Object.entries(n.bindings)){if(t.has(c))continue;o.add(c);let l=e.mode==="hide"?{...a,visible:!1}:{...a,style:{...a.style,material:{...a.style?.material,opacity:Math.min(a.style?.material?.opacity??1,r)}}};i[c]=l,s.set(l,n.sourceOf(a))}return{bindings:i,pulses:n.pulses,sourceOf:c=>s.get(c)??n.sourceOf(c),setAside:o}}var b=Object.freeze([{id:"change-color",label:"Change Color",handling:"viewer",description:"Opens a color picker docked under the action and commits the result to style.material.baseColor."},{id:"change-material",label:"Change Material",handling:"viewer",description:"Opens the material picker so the viewer can swap the object's texture."},{id:"add-text",label:"Add Text",handling:"viewer",description:"Opens a text box docked under the action; the viewer's user types, clicks the object to place it, and can resize, turn, move, or remove it. Saved to the binding's decals."},{id:"add-image",label:"Add Image",handling:"viewer",description:"Lets the viewer's user choose an image, click the object to place it, and resize, turn, move, or remove it. Saved to the binding's decals."},{id:"toggle-visibility",label:"Toggle Visibility",handling:"viewer",description:"Flips the binding's visible flag."},{id:"toggle-light",label:"Toggle Light",handling:"viewer",description:"Turns the scene lights attached to this object on or off, or the object's own glow when none is attached."},{id:"change-light-color",label:"Change Light Color",handling:"viewer",description:"Opens a color picker docked under the action for the scene lights attached to this object, or the object's own glow."},{id:"set-brightness",label:"Set Brightness",handling:"viewer",description:"Opens a brightness slider docked under the action for the scene lights attached to this object, or the object's own glow."}]);function D(n){return b.find(e=>e.id===n)}var Me=b.filter(n=>n.handling==="viewer").map(n=>n.id),Ee=new Set(["","New Action",...b.map(n=>n.label)]);function ae(n){return n.trim().replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").replace(/[^a-zA-Z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase()}function se(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase())}function w(n){let e=n.toLowerCase();return e.includes("light")?"light":e.includes("wheel")||e.includes("rim")||e.includes("tire")?"wheel":e.includes("glass")||e.includes("window")||e.includes("windshield")||e.includes("sunroof")?"glass":e.includes("seat")||e.includes("dashboard")||e.includes("console")||e.includes("doorpanel")?"interior":e.includes("floor")?"floor":e.includes("wall")?"wall":e.includes("door")?"door":e.includes("chair")||e.includes("table")||e.includes("sofa")||e.includes("bed")?"furniture":"other"}function le(n,e=!0){return n==="light"||n.endsWith("light")?[{id:"toggle-light",label:"Toggle Light",type:"command"},{id:"change-light-color",label:"Change Light Color",type:"command"},{id:"set-brightness",label:"Set Brightness",type:"command"}]:[{id:"change-color",label:"Change Color",type:"command"},...e?[{id:"change-material",label:"Change Material",type:"command"}]:[],{id:"toggle-visibility",label:"Toggle Visibility",type:"command"}]}function v(n,e=!0){let t=w(n);return{id:ae(n),modelObjectId:n,type:t,label:se(n),status:"normal",selectable:!0,hoverable:!0,visible:!0,style:{},actions:le(t,e),metrics:{},metadata:{}}}function N(n,e){return Object.fromEntries(n.map(t=>[t,v(t,!e?.has(t))]))}var _=["front","back","double"],F=["normal","additive"];var G={enabled:!1,axis:"y",position:.5,flip:!1},ce={clips:[],autoplayClip:null},de={autofocus:{enabled:!1,focusDistance:5,focusRange:5,focalLength:.02,bokehScale:6,target:[0,0,0],mouse:!0,debug:0,manual:!1,smoothTime:.25},toneMapping:{enabled:!1,mode:"aces",exposure:1,resolution:256,whitePoint:4,middleGrey:.6,minLuminance:.01,averageLuminance:1,adaptationRate:1},brightnessContrast:{enabled:!1,brightness:0,contrast:0},hueSaturation:{enabled:!1,hue:0,saturation:0},colorAverage:{enabled:!1},dotScreen:{enabled:!1,angle:Math.PI/2,scale:1},glitch:{enabled:!1,mode:"sporadic",delay:[1.5,3.5],duration:[.6,1],strength:[.3,1],chromaticAberrationOffset:[0,0],columns:.05,ratio:.85},ssao:{enabled:!1,samples:30,rings:4,intensity:8,radius:.25,bias:.025,luminanceInfluence:.6,fade:.01,minRadiusScale:.33,worldDistanceThreshold:20,worldDistanceFalloff:5,worldProximityThreshold:6,worldProximityFalloff:3},bloom:{enabled:!1,intensity:.3,luminanceThreshold:.9,luminanceSmoothing:.2,mipmapBlur:!0,radius:0,levels:8},godRays:{enabled:!1,sunPosition:[5,10,5],samples:60,density:.96,decay:.9,weight:.4,exposure:.6,clampMax:1,blur:!0,kernelSize:"small"},grid:{enabled:!1,scale:1,lineWidth:0},noise:{enabled:!1,opacity:1,premultiply:!1},depthOfField:{enabled:!1,focusDistance:5,focusRange:5,focalLength:.02,bokehScale:6},chromaticAberration:{enabled:!1,offsetX:.002,offsetY:.002,radialModulation:!1,modulationOffset:.15},lensflare:{enabled:!1,lensPosition:[-25,6,-60],smoothTime:.07,glareSize:.2,flareSize:.01,flareSpeed:.01,flareShape:.01,animated:!0,anamorphic:!1,colorGain:"#141414",haloScale:.5,secondaryGhosts:!0,aditionalStreaks:!0,ghostScale:0,opacity:1,starBurst:!1},vignette:{enabled:!1,offset:.3,darkness:.3,eskil:!1},smaa:{enabled:!1},sepia:{enabled:!1,intensity:0},scanline:{enabled:!1,density:1.25},pixelation:{enabled:!1,granularity:5},outline:{enabled:!1,selectionLayer:10,edgeStrength:2.5,pulseSpeed:0,visibleEdgeColor:"#ffffff",hiddenEdgeColor:"#22090a",kernelSize:"large",blur:!1,xRay:!0},selectiveBloom:{enabled:!1,selectionLayer:10,intensity:1,luminanceThreshold:.9,luminanceSmoothing:.025,kernelSize:"large",mipmapBlur:!0,inverted:!1,ignoreBackground:!1},ramp:{enabled:!1,rampType:"linear",rampStart:[.5,.5],rampEnd:[1,1],startColor:"#000000",endColor:"#ffffff",opacity:.5,rampBias:.5,rampGain:.5,rampMask:!1,rampInvert:!1}},z={model:{rotation:[0,0,0],showAdvancedRotation:!1,renderer:"pbr",shading:"lit",autoRotate:!1,autoRotateSpeed:1},camera:{fieldOfView:50,showAdvancedSettings:!1},lighting:{ambient:{intensity:.25,color:"#ffffff"},lights:[{id:"light-hemi",type:"hemisphere",color:"#ffffff",intensity:.3,position:[0,1,0],attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0},{id:"light-key",type:"directional",color:"#ffffff",intensity:2.5,position:[6,12,6],attachedToCamera:!1,castShadow:!0,shadowBias:-5e-4,visible:!0},{id:"light-fill",type:"directional",color:"#ffffff",intensity:0,position:[-6,8,-6],attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0}]},shadows:{enabled:!0,mapSize:2048,bias:-5e-4,normalBias:.02,radius:3},environment:{source:"preset",preset:"apartment",customEnvironmentUrl:"",intensity:.25,rotation:0,shadowLight:{enabled:!1,intensity:2.5,bias:-5e-4}},wireframe:{enabled:!1,color:"#000000",opacity:1},background:{enabled:!1,type:"color",color:"#1c1c1d",imageUrl:""},groundShadows:{enabled:!1,mode:"shadowCatcher",intensity:.7,borderFade:1,height:0,size:10},postProcessing:de,animations:ce,annotations:[]};var B={verifyingLicense:"Verifying License",checkingYourLicenseKey:"Checking your license key...",invalidLicense:"Invalid License",licenseHasBeenRevokedOrHasExpired:"License has been revoked or has expired",failedToLoadPleaseContactTheSiteAdministrator:"Failed to load. Please contact the site administrator.",contextRestoringTitle:"Reloading viewer\u2026",contextLostTitle:"3D view interrupted",contextRestoringMessage:"Rebuilding the 3D view. Please wait\u2026",contextLostMessage:"The graphics connection was interrupted. The viewer will rebuild when it returns, or you can reload it now.",reloadViewer:"Reload viewer",texturePositioningHint:"Drag to move \xB7 Scroll to zoom \xB7 Click elsewhere to finish",texturePositioningStartHint:"Double-click to move or zoom",dismiss:"Dismiss",missingUVsAreShownInMagenta:"Missing UVs are shown in magenta.",viewThisModelInARWithAppleQuickLook:"View this model in AR with Apple Quick Look",viewInAR:"View in AR",openThisExperienceOnAPhoneForAR:"Open this experience on a phone for AR",openOnPhone:"Open on phone",viewThisModelInYourSpace:"View this model in your space",viewThisModelInVR:"View this model in VR",closePhoneHandoff:"Close phone handoff",arScanCode:"Scan the code and choose AR.",qrCodeToOpenThisModelOnAPhone:"QR code to open this model on a phone",disableUVChecker:"Disable UV checker",enableUVChecker:"Enable UV checker",explodedView:"Exploded view",explodeAmount:"Explode amount",removeSectionCut:"Remove section cut",sectionCut:"Section cut",sectionAxis:"Section axis",sectionPosition:"Section position",keepTheOtherSide:"Keep the other side",pauseCinematic:"Pause cinematic",playCinematic:"Play cinematic",stopCinematicAndResetCamera:"Stop cinematic and reset camera",cancel:"Cancel",annotationCategories:"Annotation categories",annotations:"Annotations",all:"All",uncategorized:"Uncategorized",decalDragHint:"Drag the decal on the object. Release to save; Escape to cancel.",showAll:"Show all",materialVariants:"Material variants",startGuidedTour:"Start guided tour",guidedTour:"Guided Tour",previousAnnotation:"Previous annotation",previous:"Prev",stopGuidedTour:"Stop guided tour",nextAnnotation:"Next annotation",next:"Next",exitFullscreen:"Exit fullscreen",enterFullscreen:"Enter fullscreen",resetCameraView:"Reset camera view",orbitControl:"Orbit Control",pointLock:"Point Lock",cameraController:"Camera controller",cameraControllerSettings:"Camera controller settings",downloadGLB:"Download GLB",downloadPNG:"Download PNG",downloadUVLayout:"Download UV Layout",videoFormat:"Video format",auto:"Auto",recordTurntableVideo:"Record turntable video",recordCinematicVideo:"Record cinematic video",videoUnsupported:"Video recording is not supported in this browser.",downloadOptions:"Download options",exporting:"Exporting\u2026",download:"Download",annotationTitlePlaceholder:"Title *",description:"Description",ok:"OK",arRelocate:"Relocate",tapToPlace:"Tap to place",closeAnnotation:"Close annotation",learnMore:"Learn more",stopMeasuring:"Stop measuring",startMeasuring:"Start measuring",toggleBoundingDimensions:"Toggle bounding dimensions",measurementTool:"Measurement tool",distance:"Distance",angle:"Angle",area:"Area",pointToPlane:"Point to plane",measurementSnapping:"Measurement snapping",noSnapping:"No snapping",snapAuto:"Snap: auto",snapVertex:"Snap: vertex",snapEdge:"Snap: edge",undoMeasurementPoint:"Undo measurement point",clearMeasurements:"Clear measurements",finishArea:"Finish area",openSceneObjectsPanel:"Open scene objects panel",sceneObjects:"SCENE OBJECTS",searchNodesLabels:"Search nodes, labels",closeSceneObjectsPanel:"Close scene objects panel",objectNavigator:"Objects in the 3D view",compareBefore:"Before",compareAfter:"After",compareDivider:"Comparison divider",viewIn3D:"View in 3D",objectNavigatorHint:"Arrow keys browse \xB7 Enter selects \xB7 Esc clears",selectionCleared:"Selection cleared",cameraKeyboardHelp:"3D view. Arrow keys orbit, Shift with Up or Down zooms, and W, A, S, D, Space and C move the camera.",isolate:"Isolate",hide:"Hide",show:"Show",closePanel:"Close panel",actions:"Actions",openPanel:"Open panel",close:"Close",position:"Position",decalNudgeHint:"Click to fine-tune \xB7 Hold to move",decalNudgeControls:"Move decal in small steps",text:"Text",yourText:"Your text",textToAdd:"Text to add",textColour:"Text colour",addText:"Add text",image:"Image",chooseImage:"Choose image",imageToAdd:"Image to add",added:"Added",colour:"Colour",size:"Size",turn:"Turn",rotation:"Rotation",dragTheDecalAcrossTheObjectsSurface:"Drag the decal across the object's surface",move:"Move",remove:"Remove",noneAddedYet:"None added yet",done:"Done",moveForward:"Move forward",moveLeft:"Move left",moveRight:"Move right",moveBackward:"Move backward",sceneSettings:"Scene Settings",background:"Background",backgroundColor:"Background Color",environment:"Environment",autoRotate:"Auto Rotate",lighting:"Lighting",exposure:"Exposure",ambientLightIntensity:"Ambient Light Intensity",ambientLightColor:"Ambient Light Color",directLightIntensity:"Direct Light Intensity",directLightColor:"Direct Light Color",searchObjects:"Search objects",uploadedModel:"Uploaded model",clear:"Clear",chooseModel:"Choose model",loadingModel:"Loading model...",releaseToLoadYourModel:"Release to load your model",arFindSurface:"Move your device over a flat surface",arReleaseToPlace:"Release to place",arGestureHint:"Pinch to resize \xB7 Twist to rotate",angleFirstArmHint:"Pick the first arm",angleVertexHint:"Pick the angle's vertex",angleSecondArmHint:"Pick the second arm",angleNewHint:"Pick a point to start a new angle",areaNewHint:"Pick a point to start a new area",areaCornersHint:"Pick polygon corners in order, then Finish area",pointToPlaneFaceHint:"Pick the reference face",pointToPlanePointHint:"Pick a point to measure its perpendicular distance",pointToPlaneNewHint:"Pick a face to start a new measurement",distanceHint:"Pick points on the model to measure distances",visibleEntries:"{count} visible entries",objectCount:"{count} objects",annotationMarker:"Annotation {id}: {title}",recordingVideo:"Recording video \xB7 {progress}%",isolatedObjects:"Isolated: {count} objects",largeModelWarning:"Very large model ({millions}M triangles) \u2014 it may render and move slowly on this device, and click/hover selection on the model is disabled. Use the objects panel to select parts.",preparingLargeModel:"Preparing large model ({millions}M triangles) \u2014 the first display can take a while on this device...",enterAR:"Enter AR",enterVR:"Enter VR",decalImage:"Image {index}",decalText:"Text {index}",decalAdded:"{count} added",up:"up",down:"down",left:"left",right:"right",moveDecal:"Move decal {direction}",moveDecalOnSurface:"Move {direction} on the visible surface",showAllObject:"Show all {name}",isolateObject:"Isolate {name}",isolatedObject:"Isolated: {name}",hideObject:"Hide {name}",showObject:"Show {name}",objectSelected:"{name} selected",objectNavigatorPosition:"{position} of {count}",compareDividerValue:"{before} {percent}%, {after} {rest}%",bindingMismatchOne:"1 object binding doesn't match this model",bindingMismatchMany:"{count} object bindings don't match this model",simpleLargeModelWarning:"Very large model detected ({millions}M triangles) \u2014 it may render and move slowly on this device, and click/hover selection on the model is disabled. Use the scene objects panel to select parts.",dropModelHint:"Drag and drop {formats} here",loadErrorTitle:"This model couldn't be loaded",loadErrorNotFound:"Nothing was found at this address ({status}). Check that modelUrl points to the file.",loadErrorDenied:"The server refused access to the file ({status}). Check that the file is public, or that a signed URL hasn't expired.",loadErrorStatus:"The server responded with {status} when the file was requested.",loadErrorNetwork:"The download was blocked or failed. Check that the URL is correct and, if the file is on another domain, that its server allows cross-origin requests (CORS) from this site.",loadErrorHtml:"The server sent back a web page instead of a model. There's probably no file at this path: many servers answer a missing file with their index.html.",loadErrorInvalidFile:"The file couldn't be read as {format}. Check that it's a valid {format} file.",loadErrorInvalidExplicitFormat:"The file couldn't be read as {format}. Check that it's a valid {format} file and that modelFormat matches it.",loadErrorMissingFormat:"The file couldn't be read as {format}. The URL has no file extension, so set modelFormat to the file's format.",loadErrorPointCloud:"This PLY file is a point cloud: it has points but no faces, and the viewer shows meshes. Turn it into a mesh first, for example with MeshLab or Blender.",measurementReferenceFaceRequired:"Pick a triangle face to define the reference plane.",measurementTooManyPoints:"Finish or clear this measurement before adding more points.",measurementAngleDistinct:"Pick a point away from the angle's vertex.",areaMinimumPoints:"Pick at least three points to finish the area.",areaDistinctPoints:"Area points must be distinct.",areaStraightLine:"Area points must not lie on one straight line.",areaNotPlanar:"Area points must lie on one plane.",areaEdgesCross:"Area edges must not cross or touch each other.",areaZero:"The polygon has no measurable area.",decalSurfaceMissing:"Could not find a surface on this object for the decal.",decalDirectionMissing:"No visible surface in that direction. Try another arrow or rotate the view.",fullscreenExitFailed:"Could not exit fullscreen. Press Escape to exit.",fullscreenEnterFailed:"Could not enter fullscreen. Check your browser or iframe fullscreen permissions and try again.",uvCoordinatesMissing:"This model does not contain UV coordinates.",uvExportFailed:"Could not create the UV layout archive.",videoExportFailed:"Could not export the video.",videoNotReady:"Viewer not ready for video export.",videoExitXR:"Exit the XR session before recording a video.",videoAlreadyRecording:"A video export is already in progress.",videoPathRequired:"Enable a cinematic camera path before recording it.",videoDurationInvalid:"Video duration must be greater than 0 and at most 300 seconds.",videoFrameRateInvalid:"Video frame rate must be between 1 and 60.",videoBitrateInvalid:"Video bitrate must be a positive number.",videoContextLost:"Video export stopped because the WebGL context was lost.",videoTimedOut:"Video export timed out. Keep the viewer tab visible while recording.",videoEncodingFailed:"The browser could not encode the video.",videoEmpty:"The browser produced an empty video.",videoDidNotStart:"Video recording did not start.",videoWebMUnsupported:"Video recording as WEBM is not supported in this browser.",videoMP4Unsupported:"Video recording as MP4 is not supported in this browser.",videoGIFUnsupported:"Video recording as GIF is not supported in this browser.",videoGifWidthInvalid:"GIF width must be a whole number of pixels from 16 to 4096.",environmentApartment:"apartment",environmentCity:"city",environmentDawn:"dawn",environmentForest:"forest",environmentLobby:"lobby",environmentNight:"night",environmentPark:"park",environmentStudio:"studio",environmentSunset:"sunset",environmentWarehouse:"warehouse",color:"Color",material:"Material",texturePreview:"texture preview",noTextureApplied:"No texture applied",noTextureCoordinates:"This part has no texture coordinates, so an image can't be placed on it.",replaceImage:"Replace image",uploadImage:"Upload image",removeTexture:"Remove texture",texturePosition:"Texture position",offsetX:"Offset X",offsetY:"Offset Y",confirmTexturePosition:"Confirm this texture position and exit positioning mode",donePositioning:"Done positioning",textureOffsetHint:"Double-click the object in the preview to drag its texture directly (scroll to zoom), or edit its offset numerically.",actionToggleLight:"Toggle Light",actionChangeLightColor:"Change Light Color",actionSetBrightness:"Set Brightness",actionChangeColor:"Change Color",actionChangeMaterial:"Change Material",actionToggleVisibility:"Toggle Visibility"};var Ie=new Map(Object.entries(B).map(([n,e])=>[e,n]));0&&(module.exports={ACTION_CATALOG,DEFAULT_MODEL_VIEWER_LABELS,DEFAULT_SCENE_CONFIG,DEFAULT_SECTION_CONFIG,MATERIAL_BLENDING_MODES,MATERIAL_SIDES,applyIsolation,applyStyleRules,buildBindingsFromNodes,chooseMaterialVariant,colorScaleValue,createDefaultBinding,defineObjectBindings,findCatalogAction,inferType,isolatedBindingKeys,material,patchBindings,patchSceneConfig,sceneLight,selectBindingKeys,selectBindings});
package/dist/utils.mjs CHANGED
@@ -1 +1 @@
1
- import{a as s,b as f,c as m,d as B,e as C}from"./chunk-WN6GMMHF.mjs";import{A as l,C as d,D as p,E as S,H as y,I as O,a as e,c as n,p as t,q as i,u as o,v as c,x as r,y as g,z as a}from"./chunk-32WCLPTZ.mjs";import"./chunk-JR557W27.mjs";export{e as ACTION_CATALOG,i as DEFAULT_SCENE_CONFIG,t as DEFAULT_SECTION_CONFIG,O as MATERIAL_BLENDING_MODES,y as MATERIAL_SIDES,l as applyIsolation,g as applyStyleRules,S as buildBindingsFromNodes,r as colorScaleValue,p as createDefaultBinding,C as defineObjectBindings,n as findCatalogAction,d as inferType,a as isolatedBindingKeys,f as material,s as patchBindings,m as patchSceneConfig,B as sceneLight,o as selectBindingKeys,c as selectBindings};
1
+ import{a as m,b as B,c as y,d as C,e as O}from"./chunk-HYFJ5DYJ.mjs";import{A as p,C as S,D as s,E as f,I as b,J as u,a as n,c as t,p as i,q as o,u as c,v as a,x as l,y as d,z as g}from"./chunk-B7REIGDG.mjs";import{a as e,w as r}from"./chunk-4NLJSD3S.mjs";import"./chunk-JR557W27.mjs";export{n as ACTION_CATALOG,e as DEFAULT_MODEL_VIEWER_LABELS,o as DEFAULT_SCENE_CONFIG,i as DEFAULT_SECTION_CONFIG,u as MATERIAL_BLENDING_MODES,b as MATERIAL_SIDES,p as applyIsolation,d as applyStyleRules,f as buildBindingsFromNodes,r as chooseMaterialVariant,l as colorScaleValue,s as createDefaultBinding,O as defineObjectBindings,t as findCatalogAction,S as inferType,g as isolatedBindingKeys,B as material,m as patchBindings,y as patchSceneConfig,C as sceneLight,c as selectBindingKeys,a as selectBindings};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveroom-tech/react-immersive",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -70,6 +70,7 @@
70
70
  "@react-three/xr": "^6.6.30",
71
71
  "3d-tiles-renderer": "^0.5.2",
72
72
  "fflate": "^0.8.3",
73
+ "gifenc": "^1.0.3",
73
74
  "lucide-react": "^1.16.0",
74
75
  "postprocessing": "^6.39.1",
75
76
  "qrcode.react": "^4.2.0",
@@ -1 +0,0 @@
1
- var f=Object.freeze([{id:"change-color",label:"Change Color",handling:"viewer",description:"Opens a color picker docked under the action and commits the result to style.material.baseColor."},{id:"change-material",label:"Change Material",handling:"viewer",description:"Opens the material picker so the viewer can swap the object's texture."},{id:"add-text",label:"Add Text",handling:"viewer",description:"Opens a text box docked under the action; the viewer's user types, clicks the object to place it, and can resize, turn, move, or remove it. Saved to the binding's decals."},{id:"add-image",label:"Add Image",handling:"viewer",description:"Lets the viewer's user choose an image, click the object to place it, and resize, turn, move, or remove it. Saved to the binding's decals."},{id:"toggle-visibility",label:"Toggle Visibility",handling:"viewer",description:"Flips the binding's visible flag."},{id:"toggle-light",label:"Toggle Light",handling:"viewer",description:"Turns the scene lights attached to this object on or off, or the object's own glow when none is attached."},{id:"change-light-color",label:"Change Light Color",handling:"viewer",description:"Opens a color picker docked under the action for the scene lights attached to this object, or the object's own glow."},{id:"set-brightness",label:"Set Brightness",handling:"viewer",description:"Opens a brightness slider docked under the action for the scene lights attached to this object, or the object's own glow."}]),H="__custom__";function T(n){return f.find(e=>e.id===n)}var O=f.filter(n=>n.handling==="viewer").map(n=>n.id),A=new Set(["","New Action",...f.map(n=>n.label)]);function Y(n){return A.has(n.trim())}function S(n,e){let t=Array.from({length:e.length+1},(o,r)=>r);for(let o=1;o<=n.length;o+=1){let r=[o];for(let l=1;l<=e.length;l+=1){let a=t[l-1]+(n[o-1]===e[l-1]?0:1);r[l]=Math.min(r[l-1]+1,t[l]+1,a)}t=r}return t[e.length]}function X(n){if(T(n))return null;let e=n.trim().toLowerCase();if(!e)return null;let t=e.replace(/[^a-z0-9]/g,""),o=null;for(let r of f){let l=Math.min(S(e,r.id),S(t,r.id.replace(/[^a-z0-9]/g,"")));(!o||l<o.distance)&&(o={id:r.id,distance:l})}return o&&o.distance<=2?o.id:null}function q(n){let e=n.trim();return e?/\.(hdr|exr|jpg|jpeg|png|webp)(?:[?#].*)?$/i.test(e):!1}var J=["none","directional","point","spot","hemisphere"],Q=["pbr","matcap","uv-checker"],ee=["apartment","city","dawn","forest","lobby","night","park","studio","sunset","warehouse"];var ne=["sporadic","constantMild","constantWild"],te=["linear","radial","mirroredLinear"],re=["verySmall","small","medium","large","veryLarge","huge"],ie=["x","y","z"],oe={enabled:!1,axis:"y",position:.5,flip:!1},E={clips:[],autoplayClip:null},k={autofocus:{enabled:!1,focusDistance:5,focusRange:5,focalLength:.02,bokehScale:6,target:[0,0,0],mouse:!0,debug:0,manual:!1,smoothTime:.25},toneMapping:{enabled:!1,mode:"aces",exposure:1,resolution:256,whitePoint:4,middleGrey:.6,minLuminance:.01,averageLuminance:1,adaptationRate:1},brightnessContrast:{enabled:!1,brightness:0,contrast:0},hueSaturation:{enabled:!1,hue:0,saturation:0},colorAverage:{enabled:!1},dotScreen:{enabled:!1,angle:Math.PI/2,scale:1},glitch:{enabled:!1,mode:"sporadic",delay:[1.5,3.5],duration:[.6,1],strength:[.3,1],chromaticAberrationOffset:[0,0],columns:.05,ratio:.85},ssao:{enabled:!1,samples:30,rings:4,intensity:8,radius:.25,bias:.025,luminanceInfluence:.6,fade:.01,minRadiusScale:.33,worldDistanceThreshold:20,worldDistanceFalloff:5,worldProximityThreshold:6,worldProximityFalloff:3},bloom:{enabled:!1,intensity:.3,luminanceThreshold:.9,luminanceSmoothing:.2,mipmapBlur:!0,radius:0,levels:8},godRays:{enabled:!1,sunPosition:[5,10,5],samples:60,density:.96,decay:.9,weight:.4,exposure:.6,clampMax:1,blur:!0,kernelSize:"small"},grid:{enabled:!1,scale:1,lineWidth:0},noise:{enabled:!1,opacity:1,premultiply:!1},depthOfField:{enabled:!1,focusDistance:5,focusRange:5,focalLength:.02,bokehScale:6},chromaticAberration:{enabled:!1,offsetX:.002,offsetY:.002,radialModulation:!1,modulationOffset:.15},lensflare:{enabled:!1,lensPosition:[-25,6,-60],smoothTime:.07,glareSize:.2,flareSize:.01,flareSpeed:.01,flareShape:.01,animated:!0,anamorphic:!1,colorGain:"#141414",haloScale:.5,secondaryGhosts:!0,aditionalStreaks:!0,ghostScale:0,opacity:1,starBurst:!1},vignette:{enabled:!1,offset:.3,darkness:.3,eskil:!1},smaa:{enabled:!1},sepia:{enabled:!1,intensity:0},scanline:{enabled:!1,density:1.25},pixelation:{enabled:!1,granularity:5},outline:{enabled:!1,selectionLayer:10,edgeStrength:2.5,pulseSpeed:0,visibleEdgeColor:"#ffffff",hiddenEdgeColor:"#22090a",kernelSize:"large",blur:!1,xRay:!0},selectiveBloom:{enabled:!1,selectionLayer:10,intensity:1,luminanceThreshold:.9,luminanceSmoothing:.025,kernelSize:"large",mipmapBlur:!0,inverted:!1,ignoreBackground:!1},ramp:{enabled:!1,rampType:"linear",rampStart:[.5,.5],rampEnd:[1,1],startColor:"#000000",endColor:"#ffffff",opacity:.5,rampBias:.5,rampGain:.5,rampMask:!1,rampInvert:!1}},ae={model:{rotation:[0,0,0],showAdvancedRotation:!1,renderer:"pbr",shading:"lit",autoRotate:!1,autoRotateSpeed:1,materialVariant:null},camera:{fieldOfView:50,showAdvancedSettings:!1},lighting:{ambient:{intensity:.25,color:"#ffffff"},lights:[{id:"light-hemi",type:"hemisphere",color:"#ffffff",intensity:.3,position:[0,1,0],attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0},{id:"light-key",type:"directional",color:"#ffffff",intensity:2.5,position:[6,12,6],attachedToCamera:!1,castShadow:!0,shadowBias:-5e-4,visible:!0},{id:"light-fill",type:"directional",color:"#ffffff",intensity:0,position:[-6,8,-6],attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0}]},shadows:{enabled:!0,mapSize:2048,bias:-5e-4,normalBias:.02,radius:3},environment:{source:"preset",preset:"apartment",customEnvironmentUrl:"",intensity:.25,rotation:0,shadowLight:{enabled:!1,intensity:2.5,bias:-5e-4}},wireframe:{enabled:!1,color:"#000000",opacity:1},background:{enabled:!1,type:"color",color:"#1c1c1d",imageUrl:""},groundShadows:{enabled:!1,mode:"shadowCatcher",intensity:.7,borderFade:1,height:0,size:10},postProcessing:k,animations:E,annotations:[]};function j(n,e){if(n[e])return e;let t=Object.entries(n).find(([,r])=>r.id===e)?.[0];return t||(Object.entries(n).find(([,r])=>r.modelObjectId===e)?.[0]??null)}function I(n){return typeof n=="object"&&!Array.isArray(n)}function N(n,e){return"group"in e?n.group===e.group:"tag"in e?n.tags?.includes(e.tag)??!1:(n.type??"other")===e.type}function p(n,e){if(I(e))return Object.entries(n).filter(([,r])=>N(r,e)).map(([r])=>r);let o=(typeof e=="string"?[e]:e).map(r=>j(n,r)).filter(r=>r!==null);return[...new Set(o)]}function de(n,e){return p(n,e).map(t=>n[t]).filter(t=>t!==void 0)}var R="#ff3b30",D=Object.freeze({}),B=n=>n;function L(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function _(n,e){let t=n.metadata;for(let o of e.split(".")){if(!L(t))return;t=t[o]}return t}function P(n,e){if("metric"in e){let t=n.metrics?.[e.metric];return!(typeof t!="number"||!Number.isFinite(t)||e.above!==void 0&&!(t>e.above)||e.below!==void 0&&!(t<e.below))}if("status"in e){let t=n.status??"normal";return Array.isArray(e.status)?e.status.includes(t):e.status===t}return _(n,e.metadata)===e.equals}function z(n){let e=n.trim().replace(/^#/,""),t=e.length===3?e.split("").map(o=>o+o).join(""):e;return/^[0-9a-f]{6}$/i.test(t)?[0,2,4].map(o=>parseInt(t.slice(o,o+2),16)):null}var h=n=>`#${n.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`;function G(n,e){let t=n.map(([i,s])=>({at:i,rgb:z(s)})).filter(i=>Number.isFinite(i.at)&&i.rgb!==null).sort((i,s)=>i.at-s.at);if(t.length===0||!Number.isFinite(e))return null;if(e<=t[0].at)return h(t[0].rgb);let o=t[t.length-1];if(e>=o.at)return h(o.rgb);let r=t.findIndex(i=>i.at>=e),l=t[r-1],a=t[r],c=a.at===l.at?1:(e-l.at)/(a.at-l.at);return h(l.rgb.map((i,s)=>i+(a.rgb[s]-i)*c))}function me(n,e){if(!e?.length)return{bindings:n,pulses:D,sourceOf:B};let t=new Map,o={};for(let a of e){let c=a.target?p(n,a.target):Object.keys(n),i=a.when?Array.isArray(a.when)?a.when:[a.when]:[];for(let s of c){let m=n[s];if(!i.every(d=>P(m,d)))continue;let u={...a.material};if(a.colorScale){let d=m.metrics?.[a.colorScale.metric],b=typeof d=="number"?G(a.colorScale.stops,d):null;b&&(u={...u,[a.colorScale.channel??"baseColor"]:b})}if(a.pulse){let d=a.pulse===!0?{}:a.pulse;o[s]={color:d.color??R,speed:d.speed!==void 0&&d.speed>0?d.speed:1};let b=u.emissiveIntensity??t.get(s)?.emissiveIntensity??m.style?.material?.emissiveIntensity;b!==void 0&&b>0||(u.emissiveIntensity=1)}Object.keys(u).length>0&&t.set(s,{...t.get(s),...u})}}if(t.size===0)return{bindings:n,pulses:o,sourceOf:B};let r={...n},l=new WeakMap;for(let[a,c]of t){let i=n[a],s={...i,style:{...i.style,material:{...i.style?.material,...c}}};r[a]=s,l.set(s,i)}return{bindings:r,pulses:o,sourceOf:a=>l.get(a)??a}}var F=.12,x=new Set;function V(n,e){return e?new Set(p(n,e.target)):x}function fe(n,e){let t=V(n.bindings,e);if(!e||t.size===0)return{...n,setAside:x};let o=Math.min(Math.max(e.ghostOpacity??F,0),1),r={...n.bindings},l=new WeakMap,a=new Set;for(let[c,i]of Object.entries(n.bindings)){if(t.has(c))continue;a.add(c);let s=e.mode==="hide"?{...i,visible:!1}:{...i,style:{...i.style,material:{...i.style?.material,opacity:Math.min(i.style?.material?.opacity??1,o)}}};r[c]=s,l.set(s,n.sourceOf(i))}return{bindings:r,pulses:n.pulses,sourceOf:c=>l.get(c)??n.sourceOf(c),setAside:a}}var y=Symbol("react-immersive.model-node-id");function U(n,e){Object.defineProperty(n,y,{value:e,configurable:!0})}function w(n){let e=new Map;n.traverse(i=>{if(!i.name)return;let s=e.get(i.name);s?s.push(i):e.set(i.name,[i])});let t=Object.create(null),o=new WeakMap,r=new Map,l=new Set(Array.from(e,([i,s])=>s.length===1?i:null).filter(i=>i!==null)),a=new Set,c=(i,s)=>{U(i,s),t[s]=i,o.set(i,s),a.add(s)};for(let[i,s]of e)s.length===1&&c(s[0],i);for(let[i,s]of e){if(s.length<2)continue;let m=[];s.forEach((u,d)=>{let b=`${i} [${d+1}]`,g=b,v=2;for(;l.has(g)||a.has(g);)g=`${b}.${v++}`;c(u,g),m.push(g)}),r.set(i,m)}return{nodesById:t,idByNode:o,duplicateNames:r}}function ye(n){return n[y]??n.name??null}function Se(n,e){let t=null,o=[];return n.traverse(r=>{r[y]===e&&(t=r),r.name===e&&o.push(r)}),t??(o.length===1?o[0]:null)}function W(n){return n.trim().replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").replace(/[^a-zA-Z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase()}function $(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase())}function K(n){let e=n.toLowerCase();return e.includes("light")?"light":e.includes("wheel")||e.includes("rim")||e.includes("tire")?"wheel":e.includes("glass")||e.includes("window")||e.includes("windshield")||e.includes("sunroof")?"glass":e.includes("seat")||e.includes("dashboard")||e.includes("console")||e.includes("doorpanel")?"interior":e.includes("floor")?"floor":e.includes("wall")?"wall":e.includes("door")?"door":e.includes("chair")||e.includes("table")||e.includes("sofa")||e.includes("bed")?"furniture":"other"}function C(n){return n==="light"||n.endsWith("light")?[{id:"toggle-light",label:"Toggle Light",type:"command"},{id:"change-light-color",label:"Change Light Color",type:"command"},{id:"set-brightness",label:"Set Brightness",type:"command"}]:[{id:"change-color",label:"Change Color",type:"command"},{id:"change-material",label:"Change Material",type:"command"},{id:"toggle-visibility",label:"Toggle Visibility",type:"command"}]}function M(n){let e=K(n);return{id:W(n),modelObjectId:n,type:e,label:$(n),status:"normal",selectable:!0,hoverable:!0,visible:!0,style:{},actions:C(e),metrics:{},metadata:{}}}function xe(n){return Object.fromEntries(n.map(e=>[e,M(e)]))}function we(n){let e=new Set,t={};for(let o of n){let r=M(o),l=r.id||"object",a=l;for(let i=2;e.has(a);i++)a=`${l}-${i}`;e.add(a),r.id=a;let c=(r.actions??[]).filter(i=>O.includes(i.id));r.actions=c.length>0?c:C("other"),t[o]=r}return t}function Ce(n){let{nodesById:e}=w(n),t=[];for(let[o,r]of Object.entries(e)){let l=r;l.isMesh&&l.geometry&&r.name&&t.push(o)}return t.sort((o,r)=>o.localeCompare(r))}var ve=["front","back","double"],Te=["normal","additive"];export{f as a,H as b,T as c,O as d,Y as e,X as f,j as g,q as h,J as i,Q as j,ee as k,ne as l,te as m,re as n,ie as o,oe as p,ae as q,w as r,ye as s,Se as t,p as u,de as v,P as w,G as x,me as y,V as z,fe as A,$ as B,K as C,M as D,xe as E,we as F,Ce as G,ve as H,Te as I};