@liveroom-tech/react-immersive 4.3.0 → 5.0.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 (46) hide show
  1. package/README.md +697 -83
  2. package/dist/ModelViewer-CbbJT85n.d.mts +448 -0
  3. package/dist/ModelViewer-DOexHkJC.d.ts +448 -0
  4. package/dist/binding-builder.css +1 -0
  5. package/dist/binding-builder.d.mts +6 -0
  6. package/dist/binding-builder.d.ts +6 -0
  7. package/dist/binding-builder.js +3694 -0
  8. package/dist/binding-builder.mjs +1 -0
  9. package/dist/chunk-7EW6JZ46.mjs +27 -0
  10. package/dist/chunk-BGYK4Y2Y.mjs +1 -0
  11. package/dist/chunk-MMO7KCYU.mjs +3 -0
  12. package/dist/chunk-NVY7N7CU.mjs +3 -0
  13. package/dist/chunk-SEESCGUS.mjs +1 -0
  14. package/dist/chunk-WFEYRUZC.mjs +1 -0
  15. package/dist/chunk-XTLSAYAQ.mjs +1 -0
  16. package/dist/hosted.css +1 -1
  17. package/dist/hosted.d.mts +33 -13
  18. package/dist/hosted.d.ts +33 -13
  19. package/dist/hosted.js +11 -8
  20. package/dist/hosted.mjs +1 -1
  21. package/dist/index.css +1 -1
  22. package/dist/index.d.mts +107 -83
  23. package/dist/index.d.ts +107 -83
  24. package/dist/index.js +11 -8
  25. package/dist/index.mjs +1 -1
  26. package/dist/modelInfo-CEmmvVCH.d.mts +17 -0
  27. package/dist/modelInfo-CEmmvVCH.d.ts +17 -0
  28. package/dist/{objectBinding-CBRYMYk6.d.ts → objectCatalog-5W8n5xNQ.d.mts} +55 -3
  29. package/dist/{objectBinding-CBRYMYk6.d.mts → objectCatalog-5W8n5xNQ.d.ts} +55 -3
  30. package/dist/publicProps-tJuWZgT3.d.mts +12 -0
  31. package/dist/publicProps-tJuWZgT3.d.ts +12 -0
  32. package/dist/simple-model-viewer.css +1 -0
  33. package/dist/simple-model-viewer.d.mts +38 -0
  34. package/dist/simple-model-viewer.d.ts +38 -0
  35. package/dist/simple-model-viewer.js +3666 -0
  36. package/dist/simple-model-viewer.mjs +1 -0
  37. package/dist/utils.d.mts +49 -3
  38. package/dist/utils.d.ts +49 -3
  39. package/dist/utils.js +1 -1
  40. package/dist/utils.mjs +1 -1
  41. package/package.json +28 -18
  42. package/dist/chunk-7X37KAPE.mjs +0 -1
  43. package/dist/chunk-GYB4BOVW.mjs +0 -26
  44. package/dist/chunk-K7DMBJBJ.mjs +0 -1
  45. package/dist/publicProps-BST1E8an.d.mts +0 -349
  46. package/dist/publicProps-Bv3_PCP0.d.ts +0 -349
@@ -0,0 +1 @@
1
+ "use client";import{a as je}from"./chunk-MMO7KCYU.mjs";import{C as Re,D as Pe,E as Le,F as Te,a as _e,b as ke,c as Me,d as Ce,e as Se,f as Ne,h as Ee,k as De,z as ze}from"./chunk-XTLSAYAQ.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};
package/dist/utils.d.mts CHANGED
@@ -1,5 +1,24 @@
1
- import { f as ObjectBinding } from './objectBinding-CBRYMYk6.mjs';
2
- export { b as AnimationLoopMode, B as BindingEdit, D as DEFAULT_SCENE_CONFIG, M as MATERIAL_BLENDING_MODES, d as MATERIAL_SIDES, e as ObjectActionEvent, g as ObjectBindingAction, h as ObjectBindingMaterial, i as ObjectBindingMaterialBlendingMode, j as ObjectBindingMaterialSide, k as ObjectBindingPatch, l as ObjectBindingSelector, m as ObjectBindingTarget, n as ObjectBindingTextureChannel, o as ObjectBindingTextureSlot, p as ObjectBindingTransform, S as SceneAnimationClipConfig, r as SceneAnimationConfig, t as SceneCinematicConfig, u as SceneCinematicWaypoint, v as SceneConfig, x as SceneConfigPatch, y as SceneLight, z as SceneLightAttachment, E as SceneLightType, F as SceneModelRenderer, H as material, I as patchBindings, J as patchSceneConfig, K as selectBindingKeys, L as selectBindings } from './objectBinding-CBRYMYk6.mjs';
1
+ import { T as SceneLight, g as ObjectBinding, u as ObjectBindingType } from './objectCatalog-5W8n5xNQ.mjs';
2
+ export { b as AnimationLoopMode, B as BindingEdit, D as DEFAULT_SCENE_CONFIG, d as DeepPartial, E as EnvironmentPreset, G as GlitchModeName, K as KernelSizeName, M as MATERIAL_BLENDING_MODES, e as MATERIAL_SIDES, f as ObjectActionEvent, h as ObjectBindingAction, i as ObjectBindingCameraState, j as ObjectBindingMaterial, k as ObjectBindingMaterialBlendingMode, l as ObjectBindingMaterialSide, m as ObjectBindingPatch, n as ObjectBindingSelector, o as ObjectBindingStatus, p as ObjectBindingStyle, q as ObjectBindingTarget, r as ObjectBindingTextureChannel, s as ObjectBindingTextureSlot, t as ObjectBindingTransform, w as ObjectPointerEvent, R as RampTypeName, S as SceneAnimationClipConfig, x as SceneAnimationConfig, y as SceneAnnotationMarker, z as SceneBackgroundConfig, F as SceneCameraConfig, H as SceneCinematicConfig, I as SceneCinematicWaypoint, J as SceneConfig, N as SceneConfigPatch, P as SceneEnvironmentConfig, Q as SceneGroundShadowConfig, U as SceneLightAttachment, V as SceneLightType, W as SceneLightingConfig, X as SceneModelConfig, Y as SceneModelRenderer, Z as ScenePostProcessingConfig, _ as SceneShadowConfig, $ as SceneWireframeConfig, a2 as ViewerObjectInfo, a4 as material, a5 as patchBindings, a6 as patchSceneConfig, a7 as selectBindingKeys, a8 as selectBindings } from './objectCatalog-5W8n5xNQ.mjs';
3
+
4
+ /** A light's id plus whichever of its settings you want to set. */
5
+ type SceneLightInput = Pick<SceneLight, "id"> & Partial<Omit<SceneLight, "id">>;
6
+ /**
7
+ * A complete scene light from just the settings you care about; the rest take
8
+ * their defaults (a white, visible, non-shadowing point light at the origin).
9
+ * Use it to list lights in `sceneConfig.lighting.lights`:
10
+ *
11
+ * ```ts
12
+ * patchSceneConfig(DEFAULT_SCENE_CONFIG, {
13
+ * lighting: {
14
+ * lights: [
15
+ * sceneLight({ id: "key", type: "directional", position: [4, 8, 4], castShadow: true }),
16
+ * ],
17
+ * },
18
+ * });
19
+ * ```
20
+ */
21
+ declare function sceneLight(light: SceneLightInput): SceneLight;
3
22
 
4
23
  /**
5
24
  * Validates an object-bindings literal while preserving its exact keys and
@@ -15,4 +34,31 @@ type ObjectBindingActionId<TBindings extends Record<string, ObjectBinding>, TKey
15
34
  id: infer TId extends string;
16
35
  } ? TId : never : never;
17
36
 
18
- export { ObjectBinding, type ObjectBindingActionId, type ObjectBindingKey, defineObjectBindings };
37
+ declare function inferType(nodeName: string): ObjectBindingType;
38
+ declare function createDefaultBinding(nodeName: string): ObjectBinding;
39
+ declare function buildBindingsFromNodes(nodeNames: string[]): Record<string, ObjectBinding>;
40
+
41
+ /**
42
+ * The action ids the runtime actually recognises.
43
+ *
44
+ * `ObjectBindingAction["id"]` is a widened string union, so any typo type-checks
45
+ * and then falls through ModelViewer's `handleAction` switch to `default: break`
46
+ * — the button renders and silently does nothing. This catalog is what the
47
+ * Binding Builder offers in a dropdown so authors pick instead of type.
48
+ */
49
+ type ActionHandling = "viewer" | "host";
50
+ type ActionCatalogEntry = {
51
+ id: string;
52
+ label: string;
53
+ /**
54
+ * "viewer" — ModelViewer's own `handleAction` switch implements the behaviour.
55
+ * "host" — a naming convention only; the viewer just forwards it to the
56
+ * consumer's `onAction` callback, which must implement it.
57
+ */
58
+ handling: ActionHandling;
59
+ description: string;
60
+ };
61
+ declare const ACTION_CATALOG: readonly ActionCatalogEntry[];
62
+ declare function findCatalogAction(id: string): ActionCatalogEntry | undefined;
63
+
64
+ export { ACTION_CATALOG, type ActionCatalogEntry, type ActionHandling, ObjectBinding, type ObjectBindingActionId, type ObjectBindingKey, ObjectBindingType, SceneLight, type SceneLightInput, buildBindingsFromNodes, createDefaultBinding, defineObjectBindings, findCatalogAction, inferType, sceneLight };
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,24 @@
1
- import { f as ObjectBinding } from './objectBinding-CBRYMYk6.js';
2
- export { b as AnimationLoopMode, B as BindingEdit, D as DEFAULT_SCENE_CONFIG, M as MATERIAL_BLENDING_MODES, d as MATERIAL_SIDES, e as ObjectActionEvent, g as ObjectBindingAction, h as ObjectBindingMaterial, i as ObjectBindingMaterialBlendingMode, j as ObjectBindingMaterialSide, k as ObjectBindingPatch, l as ObjectBindingSelector, m as ObjectBindingTarget, n as ObjectBindingTextureChannel, o as ObjectBindingTextureSlot, p as ObjectBindingTransform, S as SceneAnimationClipConfig, r as SceneAnimationConfig, t as SceneCinematicConfig, u as SceneCinematicWaypoint, v as SceneConfig, x as SceneConfigPatch, y as SceneLight, z as SceneLightAttachment, E as SceneLightType, F as SceneModelRenderer, H as material, I as patchBindings, J as patchSceneConfig, K as selectBindingKeys, L as selectBindings } from './objectBinding-CBRYMYk6.js';
1
+ import { T as SceneLight, g as ObjectBinding, u as ObjectBindingType } from './objectCatalog-5W8n5xNQ.js';
2
+ export { b as AnimationLoopMode, B as BindingEdit, D as DEFAULT_SCENE_CONFIG, d as DeepPartial, E as EnvironmentPreset, G as GlitchModeName, K as KernelSizeName, M as MATERIAL_BLENDING_MODES, e as MATERIAL_SIDES, f as ObjectActionEvent, h as ObjectBindingAction, i as ObjectBindingCameraState, j as ObjectBindingMaterial, k as ObjectBindingMaterialBlendingMode, l as ObjectBindingMaterialSide, m as ObjectBindingPatch, n as ObjectBindingSelector, o as ObjectBindingStatus, p as ObjectBindingStyle, q as ObjectBindingTarget, r as ObjectBindingTextureChannel, s as ObjectBindingTextureSlot, t as ObjectBindingTransform, w as ObjectPointerEvent, R as RampTypeName, S as SceneAnimationClipConfig, x as SceneAnimationConfig, y as SceneAnnotationMarker, z as SceneBackgroundConfig, F as SceneCameraConfig, H as SceneCinematicConfig, I as SceneCinematicWaypoint, J as SceneConfig, N as SceneConfigPatch, P as SceneEnvironmentConfig, Q as SceneGroundShadowConfig, U as SceneLightAttachment, V as SceneLightType, W as SceneLightingConfig, X as SceneModelConfig, Y as SceneModelRenderer, Z as ScenePostProcessingConfig, _ as SceneShadowConfig, $ as SceneWireframeConfig, a2 as ViewerObjectInfo, a4 as material, a5 as patchBindings, a6 as patchSceneConfig, a7 as selectBindingKeys, a8 as selectBindings } from './objectCatalog-5W8n5xNQ.js';
3
+
4
+ /** A light's id plus whichever of its settings you want to set. */
5
+ type SceneLightInput = Pick<SceneLight, "id"> & Partial<Omit<SceneLight, "id">>;
6
+ /**
7
+ * A complete scene light from just the settings you care about; the rest take
8
+ * their defaults (a white, visible, non-shadowing point light at the origin).
9
+ * Use it to list lights in `sceneConfig.lighting.lights`:
10
+ *
11
+ * ```ts
12
+ * patchSceneConfig(DEFAULT_SCENE_CONFIG, {
13
+ * lighting: {
14
+ * lights: [
15
+ * sceneLight({ id: "key", type: "directional", position: [4, 8, 4], castShadow: true }),
16
+ * ],
17
+ * },
18
+ * });
19
+ * ```
20
+ */
21
+ declare function sceneLight(light: SceneLightInput): SceneLight;
3
22
 
4
23
  /**
5
24
  * Validates an object-bindings literal while preserving its exact keys and
@@ -15,4 +34,31 @@ type ObjectBindingActionId<TBindings extends Record<string, ObjectBinding>, TKey
15
34
  id: infer TId extends string;
16
35
  } ? TId : never : never;
17
36
 
18
- export { ObjectBinding, type ObjectBindingActionId, type ObjectBindingKey, defineObjectBindings };
37
+ declare function inferType(nodeName: string): ObjectBindingType;
38
+ declare function createDefaultBinding(nodeName: string): ObjectBinding;
39
+ declare function buildBindingsFromNodes(nodeNames: string[]): Record<string, ObjectBinding>;
40
+
41
+ /**
42
+ * The action ids the runtime actually recognises.
43
+ *
44
+ * `ObjectBindingAction["id"]` is a widened string union, so any typo type-checks
45
+ * and then falls through ModelViewer's `handleAction` switch to `default: break`
46
+ * — the button renders and silently does nothing. This catalog is what the
47
+ * Binding Builder offers in a dropdown so authors pick instead of type.
48
+ */
49
+ type ActionHandling = "viewer" | "host";
50
+ type ActionCatalogEntry = {
51
+ id: string;
52
+ label: string;
53
+ /**
54
+ * "viewer" — ModelViewer's own `handleAction` switch implements the behaviour.
55
+ * "host" — a naming convention only; the viewer just forwards it to the
56
+ * consumer's `onAction` callback, which must implement it.
57
+ */
58
+ handling: ActionHandling;
59
+ description: string;
60
+ };
61
+ declare const ACTION_CATALOG: readonly ActionCatalogEntry[];
62
+ declare function findCatalogAction(id: string): ActionCatalogEntry | undefined;
63
+
64
+ export { ACTION_CATALOG, type ActionCatalogEntry, type ActionHandling, ObjectBinding, type ObjectBindingActionId, type ObjectBindingKey, ObjectBindingType, SceneLight, type SceneLightInput, buildBindingsFromNodes, createDefaultBinding, defineObjectBindings, findCatalogAction, inferType, sceneLight };
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var C=(e,n)=>{for(var i in n)s(e,i,{get:n[i],enumerable:!0})},w=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of j(n))!T.call(e,t)&&t!==i&&s(e,t,{get:()=>n[t],enumerable:!(o=x(n,t))||o.enumerable});return e};var M=e=>w(s({},"__esModule",{value:!0}),e);var L={};C(L,{DEFAULT_SCENE_CONFIG:()=>B,MATERIAL_BLENDING_MODES:()=>S,MATERIAL_SIDES:()=>y,defineObjectBindings:()=>m,material:()=>f,patchBindings:()=>p,patchSceneConfig:()=>h,selectBindingKeys:()=>a,selectBindings:()=>g});module.exports=M(L);function m(e){return e}function l(e){if(typeof e!="object"||e===null)return!1;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function r(e,n){if(!l(n))return n;let i=l(e)?{...e}:{};for(let o of Object.keys(n)){let t=n[o];i[o]=l(t)?r(i[o],t):t}return i}function u(e,n){if(e[n])return n;let i=Object.entries(e).find(([,t])=>t.id===n)?.[0];return i||(Object.entries(e).find(([,t])=>t.modelObjectId===n)?.[0]??null)}function E(e){return typeof e=="object"&&!Array.isArray(e)}function A(e,n){return"group"in n?e.group===n.group:"tag"in n?e.tags?.includes(n.tag)??!1:e.type===n.type}function a(e,n){if(E(n))return Object.entries(e).filter(([,t])=>A(t,n)).map(([t])=>t);let o=(typeof n=="string"?[n]:n).map(t=>u(e,t)).filter(t=>t!==null);return[...new Set(o)]}function g(e,n){return a(e,n).map(i=>e[i]).filter(i=>i!==void 0)}function k(e){return Array.isArray(e)&&e.length>0&&typeof e[0]!="string"}function p(e,n,i){let o=k(n)?n:[{ids:n,patch:i??{}}],t=e;for(let c of o)for(let d of a(t,c.ids)){let b=t[d];if(!b)continue;let O=r(b,c.patch);t===e&&(t={...e}),t[d]=O}return t}function f(e){return{style:{material:e}}}function h(e,n){return r(e,n)}var y=["front","back","double"],S=["normal","additive"];var v={clips:[],autoplayClip:null},R={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}},B={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:R,animations:v,annotations:[]};0&&(module.exports={DEFAULT_SCENE_CONFIG,MATERIAL_BLENDING_MODES,MATERIAL_SIDES,defineObjectBindings,material,patchBindings,patchSceneConfig,selectBindingKeys,selectBindings});
1
+ "use strict";var l=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var k=(n,e)=>{for(var i in e)l(n,i,{get:e[i],enumerable:!0})},L=(n,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of M(e))!v.call(n,t)&&t!==i&&l(n,t,{get:()=>e[t],enumerable:!(o=E(e,t))||o.enumerable});return n};var R=n=>L(l({},"__esModule",{value:!0}),n);var V={};k(V,{ACTION_CATALOG:()=>s,DEFAULT_SCENE_CONFIG:()=>w,MATERIAL_BLENDING_MODES:()=>T,MATERIAL_SIDES:()=>C,buildBindingsFromNodes:()=>j,createDefaultBinding:()=>b,defineObjectBindings:()=>p,findCatalogAction:()=>x,inferType:()=>d,material:()=>S,patchBindings:()=>y,patchSceneConfig:()=>B,sceneLight:()=>O,selectBindingKeys:()=>a,selectBindings:()=>h});module.exports=R(V);function p(n){return n}function c(n){if(typeof n!="object"||n===null)return!1;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function r(n,e){if(!c(e))return e;let i=c(n)?{...n}:{};for(let o of Object.keys(e)){let t=e[o];i[o]=c(t)?r(i[o],t):t}return i}function f(n,e){if(n[e])return e;let i=Object.entries(n).find(([,t])=>t.id===e)?.[0];return i||(Object.entries(n).find(([,t])=>t.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 a(n,e){if(I(e))return Object.entries(n).filter(([,t])=>N(t,e)).map(([t])=>t);let o=(typeof e=="string"?[e]:e).map(t=>f(n,t)).filter(t=>t!==null);return[...new Set(o)]}function h(n,e){return a(n,e).map(i=>n[i]).filter(i=>i!==void 0)}function P(n){return Array.isArray(n)&&n.length>0&&typeof n[0]!="string"}function y(n,e,i){let o=P(e)?e:[{ids:e,patch:i??{}}],t=n;for(let g of o)for(let m of a(t,g.ids)){let u=t[m];if(!u)continue;let A=r(u,g.patch);t===n&&(t={...n}),t[m]=A}return t}function S(n){return{style:{material:n}}}function B(n,e){return r(n,e)}var _={type:"point",color:"#ffffff",intensity:1,position:[0,0,0],distance:0,decay:2,attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0};function O(n){return{..._,...n}}var s=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:"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 x(n){return s.find(e=>e.id===n)}var te=s.filter(n=>n.handling==="viewer").map(n=>n.id),ie=new Set(["","New Action",...s.map(n=>n.label)]);function D(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 z(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 d(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 G(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 b(n){let e=d(n);return{id:D(n),modelObjectId:n,type:e,label:z(n),status:"normal",selectable:!0,hoverable:!0,visible:!0,style:{},actions:G(e),metrics:{},metadata:{}}}function j(n){return Object.fromEntries(n.map(e=>[e,b(e)]))}var C=["front","back","double"],T=["normal","additive"];var F={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}},w={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:K,animations:F,annotations:[]};0&&(module.exports={ACTION_CATALOG,DEFAULT_SCENE_CONFIG,MATERIAL_BLENDING_MODES,MATERIAL_SIDES,buildBindingsFromNodes,createDefaultBinding,defineObjectBindings,findCatalogAction,inferType,material,patchBindings,patchSceneConfig,sceneLight,selectBindingKeys,selectBindings});
package/dist/utils.mjs CHANGED
@@ -1 +1 @@
1
- import{a as t,b as o,c,d as r,e as g,f as d}from"./chunk-7X37KAPE.mjs";import{h as e,j as n,k as i}from"./chunk-K7DMBJBJ.mjs";import"./chunk-JR557W27.mjs";export{e as DEFAULT_SCENE_CONFIG,i as MATERIAL_BLENDING_MODES,n as MATERIAL_SIDES,g as defineObjectBindings,r as material,c as patchBindings,d as patchSceneConfig,t as selectBindingKeys,o as selectBindings};
1
+ import{a as r,b as g,c as a,d,e as p,f,g as m}from"./chunk-WFEYRUZC.mjs";import{a as e,c as n,o as i,t,u as o,v as c,y as S,z as l}from"./chunk-BGYK4Y2Y.mjs";import"./chunk-JR557W27.mjs";export{e as ACTION_CATALOG,i as DEFAULT_SCENE_CONFIG,l as MATERIAL_BLENDING_MODES,S as MATERIAL_SIDES,c as buildBindingsFromNodes,o as createDefaultBinding,m as defineObjectBindings,n as findCatalogAction,t as inferType,d as material,a as patchBindings,p as patchSceneConfig,f as sceneLight,r as selectBindingKeys,g as selectBindings};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveroom-tech/react-immersive",
3
- "version": "4.3.0",
3
+ "version": "5.0.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -11,6 +11,16 @@
11
11
  "import": "./dist/index.mjs",
12
12
  "require": "./dist/index.js"
13
13
  },
14
+ "./simple-model-viewer": {
15
+ "types": "./dist/simple-model-viewer.d.ts",
16
+ "import": "./dist/simple-model-viewer.mjs",
17
+ "require": "./dist/simple-model-viewer.js"
18
+ },
19
+ "./binding-builder": {
20
+ "types": "./dist/binding-builder.d.ts",
21
+ "import": "./dist/binding-builder.mjs",
22
+ "require": "./dist/binding-builder.js"
23
+ },
14
24
  "./utils": {
15
25
  "types": "./dist/utils.d.ts",
16
26
  "import": "./dist/utils.mjs",
@@ -22,6 +32,8 @@
22
32
  "require": "./dist/hosted.js"
23
33
  },
24
34
  "./styles.css": "./dist/index.css",
35
+ "./simple-model-viewer.css": "./dist/simple-model-viewer.css",
36
+ "./binding-builder.css": "./dist/binding-builder.css",
25
37
  "./decoders/*": "./dist/decoders/*"
26
38
  },
27
39
  "sideEffects": [
@@ -35,48 +47,46 @@
35
47
  "postbuild": "node scripts/copy-decoders.mjs",
36
48
  "dev": "vite",
37
49
  "preview": "vite preview",
38
- "publish:patch": "npm run verify && npm version patch && npm run build && npm publish --ignore-scripts",
39
- "publish:minor": "npm run verify && npm version minor && npm run build && npm publish --ignore-scripts",
40
- "publish:major": "npm run verify && npm version major && npm run build && npm publish --ignore-scripts",
50
+ "publish:patch": "npm run verify && npm version patch && npm run build && npm run check:types && npm publish --ignore-scripts",
51
+ "publish:minor": "npm run verify && npm version minor && npm run build && npm run check:types && npm publish --ignore-scripts",
52
+ "publish:major": "npm run verify && npm version major && npm run build && npm run check:types && npm publish --ignore-scripts",
41
53
  "prepublishOnly": "npm run verify",
42
54
  "prebuild": "node scripts/build-bvh-worker.mjs",
43
55
  "predev": "node scripts/build-bvh-worker.mjs",
44
56
  "test": "tsx --test \"src/**/*.test.ts\"",
45
57
  "typecheck": "tsc --noEmit -p .",
46
- "verify": "npm run typecheck && npm test"
58
+ "verify": "npm run typecheck && npm test",
59
+ "check:types": "tsc -p scripts/check-types && node scripts/check-types/exports.mjs"
47
60
  },
48
61
  "peerDependencies": {
49
- "@react-three/drei": "^10.7.7",
50
62
  "@react-three/fiber": "^9.6.1",
51
- "@react-three/postprocessing": "^3.0.4",
52
- "@react-three/xr": "^6.6.30",
53
- "postprocessing": "^6.39.1",
54
- "react": ">=17",
55
- "react-dom": ">=17",
63
+ "react": "^19.0.0",
64
+ "react-dom": "^19.0.0",
56
65
  "three": "^0.184.0"
57
66
  },
58
67
  "dependencies": {
68
+ "@react-three/drei": "^10.7.7",
69
+ "@react-three/postprocessing": "^3.0.4",
70
+ "@react-three/xr": "^6.6.30",
59
71
  "3d-tiles-renderer": "^0.5.2",
60
72
  "fflate": "^0.8.3",
61
73
  "lucide-react": "^1.16.0",
74
+ "postprocessing": "^6.39.1",
62
75
  "qrcode.react": "^4.2.0",
63
76
  "react-colorful": "^5.7.0",
64
77
  "three-mesh-bvh": "^0.8.3",
65
78
  "three-stdlib": "^2.36.0"
66
79
  },
67
80
  "devDependencies": {
68
- "@react-three/drei": "^10.7.7",
69
81
  "@react-three/fiber": "^9.6.1",
70
- "@react-three/postprocessing": "^3.0.4",
71
- "@react-three/xr": "^6.6.30",
72
82
  "@types/node": "^26.4.1",
73
- "@types/react": "^18.0.0",
83
+ "@types/react": "~19.2.0",
84
+ "@types/react-dom": "~19.2.0",
74
85
  "@types/three": "^0.184.1",
75
86
  "@vitejs/plugin-react": "^6.0.2",
76
87
  "esbuild": "^0.27.7",
77
- "postprocessing": "^6.39.1",
78
- "react": ">=17",
79
- "react-dom": ">=17",
88
+ "react": "~19.2.0",
89
+ "react-dom": "~19.2.0",
80
90
  "three": "^0.184.0",
81
91
  "three-stdlib": "^2.36.0",
82
92
  "tsup": "^8.0.0",
@@ -1 +0,0 @@
1
- import{i as B}from"./chunk-K7DMBJBJ.mjs";function f(n){return typeof n=="object"&&!Array.isArray(n)}function j(n,e){return"group"in e?n.group===e.group:"tag"in e?n.tags?.includes(e.tag)??!1:n.type===e.type}function c(n,e){if(f(e))return Object.entries(n).filter(([,i])=>j(i,e)).map(([i])=>i);let r=(typeof e=="string"?[e]:e).map(i=>B(n,i)).filter(i=>i!==null);return[...new Set(r)]}function O(n,e){return c(n,e).map(t=>n[t]).filter(t=>t!==void 0)}function g(n){if(typeof n!="object"||n===null)return!1;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function o(n,e){if(!g(e))return e;let t=g(n)?{...n}:{};for(let r of Object.keys(e)){let i=e[r];t[r]=g(i)?o(t[r],i):i}return t}function y(n){return Array.isArray(n)&&n.length>0&&typeof n[0]!="string"}function m(n,e,t){let r=y(e)?e:[{ids:e,patch:t??{}}],i=n;for(let d of r)for(let s of c(i,d.ids)){let p=i[s];if(!p)continue;let a=o(p,d.patch);i===n&&(i={...n}),i[s]=a}return i}function S(n){return{style:{material:n}}}function P(n){return n}function K(n,e){return o(n,e)}export{c as a,O as b,m as c,S as d,P as e,K as f};