@liveroom-tech/react-immersive 5.0.2 → 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 (45) hide show
  1. package/README.md +1030 -59
  2. package/dist/binding-builder.css +1 -1
  3. package/dist/binding-builder.js +17 -12
  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-HYFJ5DYJ.mjs +1 -0
  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 -11
  15. package/dist/hosted.mjs +1 -1
  16. package/dist/index.css +1 -1
  17. package/dist/index.d.mts +85 -10
  18. package/dist/index.d.ts +85 -10
  19. package/dist/index.js +15 -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-CbbJT85n.d.mts → modelViewerProps-CIZ2R_Fv.d.ts} +164 -43
  26. package/dist/{ModelViewer-DOexHkJC.d.ts → modelViewerProps-DoRiTZMn.d.mts} +164 -43
  27. package/dist/{objectCatalog-5W8n5xNQ.d.ts → rendererBackend-QwMzISTn.d.mts} +304 -5
  28. package/dist/{objectCatalog-5W8n5xNQ.d.mts → rendererBackend-QwMzISTn.d.ts} +304 -5
  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-3GX7DOGS.mjs +0 -3
  40. package/dist/chunk-AH5NAZWX.mjs +0 -27
  41. package/dist/chunk-BGYK4Y2Y.mjs +0 -1
  42. package/dist/chunk-WFEYRUZC.mjs +0 -1
  43. package/dist/chunk-XTLSAYAQ.mjs +0 -1
  44. package/dist/modelInfo-CEmmvVCH.d.mts +0 -17
  45. package/dist/modelInfo-CEmmvVCH.d.ts +0 -17
@@ -1 +0,0 @@
1
- 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:"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."}]),N="__custom__";function j(n){return b.find(e=>e.id===n)}var h=b.filter(n=>n.handling==="viewer").map(n=>n.id),C=new Set(["","New Action",...b.map(n=>n.label)]);function k(n){return C.has(n.trim())}function p(n,e){let i=Array.from({length:e.length+1},(o,t)=>t);for(let o=1;o<=n.length;o+=1){let t=[o];for(let a=1;a<=e.length;a+=1){let s=i[a-1]+(n[o-1]===e[a-1]?0:1);t[a]=Math.min(t[a-1]+1,i[a]+1,s)}i=t}return i[e.length]}function I(n){if(j(n))return null;let e=n.trim().toLowerCase();if(!e)return null;let i=e.replace(/[^a-z0-9]/g,""),o=null;for(let t of b){let a=Math.min(p(e,t.id),p(i,t.id.replace(/[^a-z0-9]/g,"")));(!o||a<o.distance)&&(o={id:t.id,distance:a})}return o&&o.distance<=2?o.id:null}function R(n){let e=n.trim();return e?/\.(hdr|exr|jpg|jpeg|png|webp)(?:[?#].*)?$/i.test(e):!1}var L=["none","directional","point","spot","hemisphere"],_=["pbr","matcap","uv-checker"],P=["apartment","city","dawn","forest","lobby","night","park","studio","sunset","warehouse"];var z=["sporadic","constantMild","constantWild"],G=["linear","radial","mirroredLinear"],F=["verySmall","small","medium","large","veryLarge","huge"],M={clips:[],autoplayClip:null},B={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}},U={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:B,animations:M,annotations:[]};var u=Symbol("react-immersive.model-node-id");function v(n,e){Object.defineProperty(n,u,{value:e,configurable:!0})}function f(n){let e=new Map;n.traverse(r=>{if(!r.name)return;let l=e.get(r.name);l?l.push(r):e.set(r.name,[r])});let i=Object.create(null),o=new WeakMap,t=new Map,a=new Set(Array.from(e,([r,l])=>l.length===1?r:null).filter(r=>r!==null)),s=new Set,c=(r,l)=>{v(r,l),i[l]=r,o.set(r,l),s.add(l)};for(let[r,l]of e)l.length===1&&c(l[0],r);for(let[r,l]of e){if(l.length<2)continue;let m=[];l.forEach((O,w)=>{let g=`${r} [${w+1}]`,d=g,x=2;for(;a.has(d)||s.has(d);)d=`${g}.${x++}`;c(O,d),m.push(d)}),t.set(r,m)}return{nodesById:i,idByNode:o,duplicateNames:t}}function $(n){return n[u]??n.name??null}function V(n,e){let i=null,o=[];return n.traverse(t=>{t[u]===e&&(i=t),t.name===e&&o.push(t)}),i??(o.length===1?o[0]:null)}function E(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 T(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 A(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 y(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 S(n){let e=A(n);return{id:E(n),modelObjectId:n,type:e,label:T(n),status:"normal",selectable:!0,hoverable:!0,visible:!0,style:{},actions:y(e),metrics:{},metadata:{}}}function Z(n){return Object.fromEntries(n.map(e=>[e,S(e)]))}function X(n){let e=new Set,i={};for(let o of n){let t=S(o),a=t.id||"object",s=a;for(let r=2;e.has(s);r++)s=`${a}-${r}`;e.add(s),t.id=s;let c=(t.actions??[]).filter(r=>h.includes(r.id));t.actions=c.length>0?c:y("other"),i[o]=t}return i}function q(n){let{nodesById:e}=f(n),i=[];for(let[o,t]of Object.entries(e)){let a=t;a.isMesh&&a.geometry&&t.name&&i.push(o)}return i.sort((o,t)=>o.localeCompare(t))}var Q=["front","back","double"],ee=["normal","additive"];function te(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)}export{b as a,N as b,j as c,h as d,k as e,I as f,te as g,R as h,L as i,_ as j,P as k,z as l,G as m,F as n,U as o,f as p,$ as q,V as r,T as s,A as t,S as u,Z as v,X as w,q as x,Q as y,ee as z};
@@ -1 +0,0 @@
1
- import{g as a}from"./chunk-BGYK4Y2Y.mjs";function f(n){return typeof n=="object"&&!Array.isArray(n)}function y(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 c(n,e){if(f(e))return Object.entries(n).filter(([,t])=>y(t,e)).map(([t])=>t);let r=(typeof e=="string"?[e]:e).map(t=>a(n,t)).filter(t=>t!==null);return[...new Set(r)]}function u(n,e){return c(n,e).map(i=>n[i]).filter(i=>i!==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 i=g(n)?{...n}:{};for(let r of Object.keys(e)){let t=e[r];i[r]=g(t)?o(i[r],t):t}return i}function b(n){return Array.isArray(n)&&n.length>0&&typeof n[0]!="string"}function h(n,e,i){let r=b(e)?e:[{ids:e,patch:i??{}}],t=n;for(let d of r)for(let s of c(t,d.ids)){let p=t[s];if(!p)continue;let B=o(p,d.patch);t===n&&(t={...n}),t[s]=B}return t}function S(n){return{style:{material:n}}}function k(n,e){return o(n,e)}var j={type:"point",color:"#ffffff",intensity:1,position:[0,0,0],distance:0,decay:2,attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0};function C(n){return{...j,...n}}function L(n){return n}export{c as a,u as b,h as c,S as d,k as e,C as f,L as g};
@@ -1 +0,0 @@
1
- import{Box3 as ie,BufferAttribute as ue,Mesh as le}from"three";import{acceleratedRaycast as pe,computeBoundsTree as ce,disposeBoundsTree as de,MeshBVH as fe}from"three-mesh-bvh";var k=!1,f=new WeakMap,m=new WeakMap;function me(){k||(le.prototype.raycast=pe,k=!0)}function Me(e){let t=new Set;return e.traverse(r=>{let n=r.geometry;!n||!n.attributes?.position||t.add(n)}),[...t]}function O(e){let t=0;for(let r of e){let n=r.index?r.index.count:r.attributes.position.count;t+=n/3}return t}var U=12e6;function vt(e){return he(e)>U}function he(e){let t=new Set;return e.traverse(r=>{let n=r.geometry;n?.attributes?.position&&t.add(n)}),O([...t])}function be(e,t){return new Promise((r,n)=>{let s=l=>{let p=l.data;if(!p||!p.error&&!p.serialized)return;if(e.removeEventListener("message",s),e.removeEventListener("error",a),p.error){n(new Error(String(p.error)));return}let{serialized:d}=p,A=fe.deserialize(d,t,{setIndex:!1});d.index&&(t.index?t.index.array=d.index:t.setIndex(new ue(d.index,1,!1))),t.boundingBox=A.getBoundingBox(new ie),r(A)},a=l=>{e.removeEventListener("message",s),e.removeEventListener("error",a),n(new Error(l.message||"BVH worker error"))};e.addEventListener("message",s),e.addEventListener("error",a);let o=t.index?t.index.array.slice():null,i=t.attributes.position.array.slice(),u=[i,...o?[o]:[]].map(l=>l.buffer);e.postMessage({index:o,position:i,options:{groups:[...t.groups]}},u)})}async function ge(){if(typeof window>"u"||typeof Worker>"u")return null;try{let{bvhWorkerCode:e}=await import("./bvhWorkerCode-6366A3UC.mjs"),t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),n=new Worker(r);return{worker:n,dispose:()=>{n.terminate(),URL.revokeObjectURL(r)}}}catch{return null}}async function ye(e,t){if(t)try{return await be(t,e)}catch{}let r=ce.call(e);return e.boundsTree=void 0,await new Promise(n=>setTimeout(n,0)),r}async function ve(e,t,r){if(e.boundsTree)return;if(t.buildPromise)return t.buildPromise;let n=(async()=>{let s=await r();t.references>0&&!e.boundsTree&&(e.boundsTree=s,t.ownedTree=s)})();return t.buildPromise=n.finally(()=>{t.buildPromise=void 0,t.references===0&&f.delete(e)}),t.buildPromise}async function xt(e,t){if(t?.aborted)return;let r=m.get(e);if(!r){if(r=Me(e),O(r)>U){m.set(e,[]);return}m.set(e,r);for(let s of r){let a=f.get(s)??{references:0};a.references+=1,f.set(s,a)}}if(r.length===0)return;me();let n=await ge();if(t?.aborted){n?.dispose();return}try{for(let s of r){if(t?.aborted)return;let a=f.get(s);a&&await ve(s,a,()=>ye(s,n?.worker))}}finally{n?.dispose()}}function St(e){let t=m.get(e);if(t){m.delete(e);for(let r of t){let n=f.get(r);n&&(n.references=Math.max(0,n.references-1),!(n.references>0)&&(n.ownedTree&&r.boundsTree===n.ownedTree&&(de.call(r),r.boundsTree=void 0),n.ownedTree=void 0,n.buildPromise||f.delete(r)))}}}import{strFromU8 as xe,strToU8 as Se,unzip as we}from"fflate";var z;function F(e){z=e}function M(e){z?.(e)}var Te=[".glb",".gltf",".obj",".fbx",".usdz",".zip"],De=["model/gltf-binary","model/gltf+json","model/vnd.usdz+zip","application/vnd.usdz+zip","application/zip","application/x-zip-compressed"],h=1024*1024,G=128*h,I=1024,j=128*h,_=256*h,N=200,Re=h,c=new Map,Lt=".glb,.gltf,.obj,.fbx,.usdz,.zip,model/gltf-binary,model/gltf+json,model/vnd.usdz+zip,application/vnd.usdz+zip,application/zip";function w(e){let t=e.split(/[?#]/,1)[0].toLowerCase();return t.endsWith(".obj")?"obj":t.endsWith(".fbx")?"fbx":t.endsWith(".usdz")?"usdz":t.endsWith(".gltf")?"gltf":"glb"}function V(e){return c.get(e)??{format:w(e)}}function Le(e){let t=e.name.toLowerCase();return Te.some(r=>t.endsWith(r))||De.includes(e.type)}async function Bt(e){if(!Le(e))throw new Error("Unsupported model file. Please upload a .glb, .gltf, .obj, .fbx, .usdz, or .zip asset.");let t=e.name.toLowerCase();if(t.endsWith(".usdz")||e.type==="model/vnd.usdz+zip"||e.type==="application/vnd.usdz+zip")return W(e,"usdz");if(t.endsWith(".zip")||Be(e.type))return Pe(e);if(t.endsWith(".gltf")||e.type==="model/gltf+json")return $(e);let r=w(e.name);return r==="gltf"?$(e):W(e,r)}function W(e,t){let r=URL.createObjectURL(e);return c.set(r,{format:t,entryPath:e.name}),{url:r,name:e.name,format:t,cleanup:()=>{M(r),c.delete(r),URL.revokeObjectURL(r)}}}function Be(e){return e==="application/zip"||e==="application/x-zip-compressed"}async function $(e){let t=await e.text(),r=K(t,e.name);for(let s of Z(r))if(!T(s))throw new Error(`${e.name} references external assets. Upload a .zip containing the .gltf file and its dependencies.`);let n=URL.createObjectURL(e);return c.set(n,{format:"gltf",entryPath:e.name}),{url:n,name:e.name,format:"gltf",cleanup:()=>{M(n),c.delete(n),URL.revokeObjectURL(n)}}}async function Pe(e){if(e.size>G)throw new Error(`Model zip is too large. The compressed archive must be ${S(G)} or smaller.`);let t=await Ce(new Uint8Array(await e.arrayBuffer())),r=new Map;for(let[o,i]of Object.entries(t)){let u=D(o);!u||X(u)||r.set(u,i)}let n=[...r.keys()].filter(o=>/\.(gltf|obj|fbx)$/i.test(o));if(n.length===0)throw new Error("Invalid model zip: no .gltf, .obj, or .fbx file found.");if(n.length>1)throw new Error("Invalid model zip: multiple model entry files found.");let s=n[0],a=w(s);if(a==="gltf")return Ae(e,s,r);if(a==="obj"||a==="fbx")return Ee(e,s,a,r);throw new Error(`Unsupported model entry ${s}.`)}function Ce(e){return new Promise((t,r)=>{let n=0,s=0,a=null,o=u=>(a??(a=new Error(`Invalid model zip: ${u}`)),!1);we(e,{filter:u=>{if(a)return!1;if(n+=1,n>I)return o(`archive contains more than ${I.toLocaleString()} entries.`);if(u.originalSize>j)return o(`${u.name} expands beyond the ${S(j)} per-file limit.`);if(s+=u.originalSize,s>_)return o(`expanded contents exceed ${S(_)}.`);if(u.originalSize>=Re&&(u.size===0||u.originalSize/u.size>N))return o(`${u.name} exceeds the ${N}:1 compression-ratio limit.`);let l=D(u.name);return!!l&&!X(l)}},(u,l)=>{a?r(a):u?r(new Error(`Invalid model zip: ${u.message}`)):t(l)})})}function S(e){return`${e/h} MiB`}function Ee(e,t,r,n){let s=[],a={};for(let[i,u]of n){let l=URL.createObjectURL(new Blob([u],{type:Y(i)}));s.push(l),a[i]=l}let o=a[t];if(!o)throw s.forEach(i=>URL.revokeObjectURL(i)),new Error(`Invalid model zip: could not read ${t}.`);return c.set(o,{format:r,entryPath:t,resourceUrls:a}),{url:o,name:e.name,format:r,cleanup:()=>{M(o),c.delete(o),s.forEach(i=>URL.revokeObjectURL(i))}}}function Ae(e,t,r){let n=r.get(t);if(!n)throw new Error("Invalid GLTF zip: no .gltf found.");let s=K(xe(n),t);ke(s,t);let a=Oe(t),o=[];try{H(s.buffers,a,r,o),H(s.images,a,r,o);let i=new Blob([Se(JSON.stringify(s))],{type:"model/gltf+json"}),u=URL.createObjectURL(i);return o.push(u),c.set(u,{format:"gltf",entryPath:t}),{url:u,name:e.name,format:"gltf",cleanup:()=>{M(u),c.delete(u),o.forEach(l=>URL.revokeObjectURL(l))}}}catch(i){throw o.forEach(u=>URL.revokeObjectURL(u)),i}}function H(e,t,r,n){for(let s of e??[]){if(typeof s.uri!="string"||T(s.uri))continue;let a=Ue(t,s.uri),o=r.get(a);if(!o)throw new Error(`Invalid GLTF zip: missing referenced asset ${s.uri}.`);let i=URL.createObjectURL(new Blob([o],{type:Y(a)}));n.push(i),s.uri=i}}function K(e,t){try{return JSON.parse(e)}catch{throw new Error(`${t} is not a valid .gltf JSON file.`)}}function Z(e){return[...e.buffers??[],...e.images??[]].map(t=>t.uri).filter(t=>typeof t=="string"&&t.length>0)}function ke(e,t){for(let r of Z(e)){if(T(r))continue;let n=/^[a-z][a-z0-9+.-]*:/i.test(r),s=r.startsWith("/")||r.startsWith("\\");if(n||s)throw new Error(`${t} references external assets. Include every dependency inside the uploaded .zip.`)}}function T(e){return e.startsWith("data:")}function D(e){let t=[];for(let r of e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(n=>n&&n!==".")){if(r===".."){t.pop();continue}t.push(r)}return t.join("/")}function X(e){let t=e.split("/");return e.endsWith("/")||t.includes("__MACOSX")||t.some(r=>r===".DS_Store"||r.startsWith("._"))}function Oe(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function Ue(e,t){let r=t.split(/[?#]/)[0],n=ze(r);return D(e?`${e}/${n}`:n)}function ze(e){try{return decodeURI(e)}catch{return e}}function Y(e){let t=e.toLowerCase();return t.endsWith(".obj")||t.endsWith(".mtl")?"text/plain":t.endsWith(".fbx")?"application/octet-stream":t.endsWith(".usdz")?"model/vnd.usdz+zip":t.endsWith(".bin")?"application/octet-stream":t.endsWith(".png")?"image/png":t.endsWith(".jpg")||t.endsWith(".jpeg")?"image/jpeg":t.endsWith(".webp")?"image/webp":t.endsWith(".avif")?"image/avif":t.endsWith(".ktx2")?"image/ktx2":"application/octet-stream"}import{useLoader as Q,useThree as $e}from"@react-three/fiber";import{FileLoader as He,Loader as Ve,LoadingManager as Ke}from"three";import{FBXLoader as Ze,GLTFLoader as Xe,MTLLoader as Ye,OBJLoader as Je}from"three-stdlib";import{USDLoader as qe}from"three/examples/jsm/loaders/USDLoader.js";import{useGLTF as Et}from"@react-three/drei";import{useThree as kt}from"@react-three/fiber";import{useMemo as Ut}from"react";import{SRGBColorSpace as Fe}from"three";import{DRACOLoader as Ge,KTX2Loader as Ie,MeshoptDecoder as je}from"three-stdlib";function _e(e){return{name:"RI_unlit_emissive_texture",async afterRoot(t){let r=e.json.materials??[],n=new Map;if(r.forEach(a=>{let o=!!a?.extensions?.KHR_materials_unlit,i=!!a?.pbrMetallicRoughness?.baseColorTexture;o&&!i&&a?.emissiveTexture&&a.name&&n.set(a.name,a.emissiveTexture.index)}),n.size===0||!t.scene)return;let s=new Map;await Promise.all([...n].map(async([a,o])=>{let i=await e.getDependency("texture",o);i&&(i.colorSpace=Fe,s.set(a,i))})),t.scene.traverse(a=>{let o=Array.isArray(a.material)?a.material:a.material?[a.material]:[];for(let i of o){let u=i.name?s.get(i.name):void 0;u&&!i.map&&(i.map=u,i.needsUpdate=!0)}})}}}var Ne="https://assets.react-immersive.liveroom.dev/three-r184/draco/",We="https://assets.react-immersive.liveroom.dev/three-r184/basis/";function J(e,t={},r){let{dracoDecoderPath:n=Ne,ktx2TranscoderPath:s=We,meshopt:a=!0}=t;if(n){let o=new Ge;o.setDecoderPath(n),e.setDRACOLoader(o)}if(a&&e.setMeshoptDecoder(je),s&&r){let o=new Ie().setTranscoderPath(s).detectSupport(r);e.setKTX2Loader(o)}e.register((o=>_e(o)))}var b=class extends Ve{constructor(){super(...arguments);this.options={source:{format:"glb"}}}configure(r){return this.options=r,this}load(r,n,s,a){this.loadAsset(r,s).then(n).catch(a)}async loadAsset(r,n){let s=et(this.options.source),{format:a}=this.options.source;if(a==="obj")return Qe(r,s,this.options.source,n);if(a==="fbx"){let u=R(this,new Ze(s)),l=nt(r,this.options.source);l&&u.setResourcePath(l);let p=await u.loadAsync(r,n);return L(p,"FBXMesh",!1),{scene:p,animations:p.animations??[]}}if(a==="usdz"){let l=await R(this,new qe(s)).loadAsync(r,n);return L(l,"USDZMesh",!1),{scene:l,animations:l.animations??[]}}let o=R(this,new Xe(s));J(o,this.options.decoderConfig,this.options.renderer);let i=await o.loadAsync(r,n);return{scene:i.scene,animations:i.animations??[]}}};F(e=>{Q.clear(b,e)});function Vt(e,t={},r,n){let s=$e(i=>i.gl),a=V(e),o=r?{...a,format:r}:a;return Q(b,e,i=>{i.configure({source:o,decoderConfig:t,renderer:s})},n)}async function Qe(e,t,r,n){let s=await q(e,t,n),a=new Je(t),o=tt(s);if(o){let u=rt(o,e,r);if(u)try{let l=await q(u.url,t),d=new Ye(t).parse(l,u.basePath);d.preload(),a.setMaterials(d)}catch(l){console.warn(`[react-immersive] Could not load OBJ material ${o}; rendering geometry with fallback materials.`,l)}}let i=a.parse(s);return L(i,"OBJMesh",!0),{scene:i,animations:[]}}function L(e,t,r){let n=new Set,s=0;e.traverse(a=>{if(!("isMesh"in a&&a.isMesh===!0)){a.name&&n.add(a.name);return}let i=a.name||`${t}_${++s}`;if(!r&&a.name){n.add(a.name);return}let u=i,l=2;for(;n.has(u);)u=`${i}_${l++}`;a.name=u,n.add(u)})}function q(e,t,r){let n=new He(t);return n.setResponseType("text"),n.loadAsync(e,r)}function R(e,t){return t.setCrossOrigin(e.crossOrigin),t.setWithCredentials(e.withCredentials),t.setRequestHeader(e.requestHeader),t}function et(e){let t=new Ke,r=e.resourceUrls;return r&&t.setURLModifier(n=>{if(/^(?:blob:|data:)/i.test(n))return n;let s=y(te(n).split(/[?#]/)[0]),a=r[s];if(a)return a;let o=g(e.entryPath??""),i=y(o?`${o}/${s}`:s);return r[i]??n}),t}function tt(e){return/^\s*mtllib\s+(.+?)\s*$/im.exec(e)?.[1]?.trim()||null}function rt(e,t,r){if(r.resourceUrls&&r.entryPath){let n=y(`${g(r.entryPath)}/${te(e)}`),s=r.resourceUrls[n];if(!s)return null;let a=g(n);return{url:s,basePath:a?`${a}/`:""}}try{let n=new URL(e,t).href;return{url:n,basePath:ee(n)}}catch{return null}}function nt(e,t){if(t.resourceUrls&&t.entryPath){let r=g(t.entryPath);return r?`${r}/`:""}return ee(e)}function ee(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t+1)}function g(e){let t=y(e),r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function y(e){let t=[];for(let r of e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(n=>n&&n!=="."))r===".."?t.pop():t.push(r);return t.join("/")}function te(e){try{return decodeURI(e)}catch{return e}}import{AdditiveBlending as st,BackSide as at,DoubleSide as ot,FrontSide as it,NoColorSpace as ut,NormalBlending as lt,SRGBColorSpace as pt,Vector2 as re}from"three";function ne(e){return!!(e&&typeof e=="object"&&"clone"in e&&"color"in e&&"metalness"in e&&"roughness"in e)}function se(e){return!!(e&&typeof e=="object"&&"isMeshPhysicalMaterial"in e&&e.isMeshPhysicalMaterial)}function rr(e){return!!(e&&"isMesh"in e&&e.isMesh)}var nr=["texture","metalnessMap","roughnessMap","emissiveMap","alphaMap","normalMap","bumpMap","aoMap","displacementMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","anisotropyMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap"],sr={texture:"map",metalnessMap:"metalnessMap",roughnessMap:"roughnessMap",emissiveMap:"emissiveMap",alphaMap:"alphaMap",normalMap:"normalMap",bumpMap:"bumpMap",aoMap:"aoMap",displacementMap:"displacementMap",clearcoatMap:"clearcoatMap",clearcoatRoughnessMap:"clearcoatRoughnessMap",clearcoatNormalMap:"clearcoatNormalMap",anisotropyMap:"anisotropyMap",transmissionMap:"transmissionMap",thicknessMap:"thicknessMap",sheenColorMap:"sheenColorMap",sheenRoughnessMap:"sheenRoughnessMap",specularIntensityMap:"specularIntensityMap",specularColorMap:"specularColorMap"},ct=new Set(["texture","emissiveMap","sheenColorMap","specularColorMap"]);function ar(e){return ct.has(e)?pt:ut}function or(e,t){return e?.[t]?.path}function ir(e,t){let r=e?.[t]?.offset;if(!r)return;let[n,s]=r;if(!(!Number.isFinite(n)||!Number.isFinite(s)))return n===0&&s===0?void 0:[n,s]}function ur(e,t){let r=e?.[t]?.scale;if(!(!Number.isFinite(r)||!r))return r===1?void 0:r}function lr(e,t){let r=e?.[t]?.rotation;if(!(!Number.isFinite(r)||!r))return r}function pr(e){return e==="back"?at:e==="double"?ot:it}function cr(e){return e==="additive"?st:lt}function v(e,t=1,r=t){if(e&&typeof e=="object"){let n=e;if(typeof n.x=="number"&&Number.isFinite(n.x)&&typeof n.y=="number"&&Number.isFinite(n.y))return new re(n.x,n.y)}return new re(t,r)}function dr(e){return Number.isFinite(e)&&e>0?e:1}function fr(e,t){return e?.animations.clips.find(r=>r.sourceName===t)}function mr(e){return e?.loopMode??"repeat"}import{Color as B,MeshPhysicalMaterial as dt,MeshStandardMaterial as ft,Texture as P}from"three";function gr(e){if(ne(e))return e;if(!e||typeof e!="object")return null;let t=e,r=new ft;typeof t.name=="string"&&(r.name=t.name),r.metalness=0,r.roughness=1,t.type==="MeshBasicMaterial"||t.isMeshBasicMaterial===!0?(r.color.set(0),r.emissiveIntensity=1,t.map instanceof P?(r.emissiveMap=t.map,r.emissive.set(16777215)):t.color instanceof B&&r.emissive.copy(t.color)):(t.color instanceof B&&r.color.copy(t.color),t.map instanceof P&&(r.map=t.map),t.emissive instanceof B&&r.emissive.copy(t.emissive),t.emissiveMap instanceof P&&(r.emissiveMap=t.emissiveMap));let s=["aoMap","aoMapIntensity","lightMap","lightMapIntensity","alphaMap","opacity","transparent","alphaTest","side","vertexColors","wireframe","depthTest","depthWrite","visible","toneMapped","fog"];for(let a of s)t[a]!==void 0&&(r[a]=t[a]);return r.needsUpdate=!0,r}function yr(e){if(se(e))return e.clone();let t=new dt;return t.name=e.name,t.color.copy(e.color),t.map=e.map,t.lightMap=e.lightMap,t.lightMapIntensity=e.lightMapIntensity,t.aoMap=e.aoMap,t.aoMapIntensity=e.aoMapIntensity,t.emissive.copy(e.emissive),t.emissiveIntensity=e.emissiveIntensity,t.emissiveMap=e.emissiveMap,t.bumpMap=e.bumpMap,t.bumpScale=e.bumpScale,t.normalMap=e.normalMap,t.normalMapType=e.normalMapType,t.normalScale.copy(v(e.normalScale)),t.displacementMap=e.displacementMap,t.displacementScale=e.displacementScale,t.displacementBias=e.displacementBias,t.roughness=e.roughness,t.roughnessMap=e.roughnessMap,t.metalness=e.metalness,t.metalnessMap=e.metalnessMap,t.alphaMap=e.alphaMap,t.envMap=e.envMap,t.envMapRotation.copy(e.envMapRotation),t.envMapIntensity=e.envMapIntensity,t.wireframe=e.wireframe,t.wireframeLinewidth=e.wireframeLinewidth,t.flatShading=e.flatShading,t.fog=e.fog,t.opacity=e.opacity,t.transparent=e.transparent,t.alphaHash=e.alphaHash,t.blendSrc=e.blendSrc,t.blendDst=e.blendDst,t.blendEquation=e.blendEquation,t.blendSrcAlpha=e.blendSrcAlpha,t.blendDstAlpha=e.blendDstAlpha,t.blendEquationAlpha=e.blendEquationAlpha,t.blending=e.blending,t.premultipliedAlpha=e.premultipliedAlpha,t.dithering=e.dithering,t.alphaTest=e.alphaTest,t.depthTest=e.depthTest,t.depthWrite=e.depthWrite,t.colorWrite=e.colorWrite,t.stencilWrite=e.stencilWrite,t.stencilWriteMask=e.stencilWriteMask,t.stencilFunc=e.stencilFunc,t.stencilRef=e.stencilRef,t.stencilFuncMask=e.stencilFuncMask,t.stencilFail=e.stencilFail,t.stencilZFail=e.stencilZFail,t.stencilZPass=e.stencilZPass,t.side=e.side,t.shadowSide=e.shadowSide,t.toneMapped=e.toneMapped,t.vertexColors=e.vertexColors,t.visible=e.visible,t.clippingPlanes=e.clippingPlanes,t.clipIntersection=e.clipIntersection,t.clipShadows=e.clipShadows,t.forceSinglePass=e.forceSinglePass,t.polygonOffset=e.polygonOffset,t.polygonOffsetFactor=e.polygonOffsetFactor,t.polygonOffsetUnits=e.polygonOffsetUnits,t}function vr(e){e.userData.baseColor=e.color.clone(),e.userData.baseMap=e.map??null,e.userData.baseMetalness=e.metalness,e.userData.baseMetalnessMap=e.metalnessMap??null,e.userData.baseRoughness=e.roughness,e.userData.baseRoughnessMap=e.roughnessMap??null,e.userData.baseEmissive=e.emissive.clone(),e.userData.baseEmissiveIntensity=e.emissiveIntensity,e.userData.baseEmissiveMap=e.emissiveMap??null,e.userData.baseOpacity=e.opacity,e.userData.baseTransparent=e.transparent,e.userData.baseAlphaMap=e.alphaMap??null,e.userData.baseAlphaTest=e.alphaTest,e.userData.baseAlphaHash=e.alphaHash,e.userData.baseDithering=e.dithering,e.userData.baseBlending=e.blending,e.userData.baseDepthWrite=e.depthWrite,e.userData.baseSide=e.side,e.userData.baseNormalMap=e.normalMap??null,e.userData.baseNormalScale=v(e.normalScale),e.userData.baseBumpMap=e.bumpMap??null,e.userData.baseBumpScale=e.bumpScale,e.userData.baseAoMap=e.aoMap??null,e.userData.baseAoMapIntensity=e.aoMapIntensity,e.userData.baseDisplacementMap=e.displacementMap??null,e.userData.baseDisplacementScale=e.displacementScale,e.userData.baseDisplacementBias=e.displacementBias,e.userData.baseClearcoat=e.clearcoat,e.userData.baseClearcoatMap=e.clearcoatMap??null,e.userData.baseClearcoatRoughness=e.clearcoatRoughness,e.userData.baseClearcoatRoughnessMap=e.clearcoatRoughnessMap??null,e.userData.baseClearcoatNormalMap=e.clearcoatNormalMap??null,e.userData.baseClearcoatNormalScale=v(e.clearcoatNormalScale),e.userData.baseSheen=e.sheen,e.userData.baseSheenColor=e.sheenColor.clone(),e.userData.baseSheenColorMap=e.sheenColorMap??null,e.userData.baseSheenRoughness=e.sheenRoughness,e.userData.baseSheenRoughnessMap=e.sheenRoughnessMap??null,e.userData.baseAnisotropy=e.anisotropy,e.userData.baseAnisotropyRotation=e.anisotropyRotation,e.userData.baseAnisotropyMap=e.anisotropyMap??null,e.userData.baseTransmission=e.transmission,e.userData.baseTransmissionMap=e.transmissionMap??null,e.userData.baseThickness=e.thickness,e.userData.baseThicknessMap=e.thicknessMap??null,e.userData.baseAttenuationColor=e.attenuationColor.clone(),e.userData.baseAttenuationDistance=e.attenuationDistance,e.userData.baseReflectivity=e.reflectivity,e.userData.baseSpecularIntensity=e.specularIntensity,e.userData.baseSpecularIntensityMap=e.specularIntensityMap??null,e.userData.baseSpecularColor=e.specularColor.clone(),e.userData.baseSpecularColorMap=e.specularColorMap??null,e.userData.baseFlatShading=e.flatShading,e.userData.baseEnvMapIntensity=e.envMapIntensity}function Sr(e){e.updateMatrixWorld(!0),e.traverse(t=>{let r=t;r.isSkinnedMesh&&(r.skeleton?.update(),r.computeBoundingBox?.(),r.computeBoundingSphere?.())})}import{useCallback as ae,useEffect as mt,useRef as Mt}from"react";import{useThree as ht}from"@react-three/fiber";function Rr(){let e=ht(s=>s.gl.domElement),t=Mt(void 0),r=ae(s=>{t.current===void 0&&(t.current=e.style.cursor),e.style.cursor=s},[e]),n=ae(()=>{let s=t.current;s!==void 0&&(e.style.cursor=s,t.current=void 0)},[e]);return mt(()=>()=>{n()},[n]),{setCanvasCursor:r,restoreCanvasCursor:n}}import{Box3 as bt,Vector3 as oe}from"three";function x(e){return[e.x,e.y,e.z]}function Pr(e){let t=new bt().setFromObject(e),r=0;return e.traverse(n=>{n.isMesh&&(r+=1)}),{bounds:{min:x(t.min),max:x(t.max),center:x(t.getCenter(new oe)),size:x(t.getSize(new oe))},objectCount:r}}import{jsx as C,jsxs as E}from"react/jsx-runtime";function Or({visible:e,message:t,tone:r="default",progress:n}){if(!e)return null;let s=typeof n=="number"&&Number.isFinite(n),a=s?Math.min(Math.max(n,0),100):0,o=Math.round(a);return E("div",{className:"bb-loadingOverlay",role:"status","aria-live":"polite",children:[s&&E("div",{className:"bb-loadingProgressRow",children:[C("div",{className:"bb-loadingProgress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":o,children:C("div",{className:"bb-loadingProgress__bar",style:{width:`${o}%`}})}),E("span",{className:"bb-loadingProgress__label",children:[o,"%"]})]}),C("span",{className:`bb-loadingMessage bb-status--${r}`,children:t})]})}export{U as a,vt as b,he as c,xt as d,St as e,Lt as f,w as g,Bt as h,Ne as i,We as j,Vt as k,rr as l,nr as m,sr as n,ar as o,or as p,ir as q,ur as r,lr as s,pr as t,cr as u,v,dr as w,fr as x,mr as y,gr as z,yr as A,vr as B,Sr as C,Rr as D,Pr as E,Or as F};
@@ -1,17 +0,0 @@
1
- type ModelFormat = "glb" | "gltf" | "obj" | "fbx" | "usdz";
2
-
3
- type ViewerModelBounds = {
4
- min: [number, number, number];
5
- max: [number, number, number];
6
- center: [number, number, number];
7
- size: [number, number, number];
8
- };
9
- /** What `onModelLoaded` reports about a model that finished loading. */
10
- type ViewerModelInfo = {
11
- /** Bounds in world space, where the viewer placed the model. */
12
- bounds: ViewerModelBounds;
13
- /** Number of meshes in the loaded scene. */
14
- objectCount: number;
15
- };
16
-
17
- export type { ModelFormat as M, ViewerModelBounds as V, ViewerModelInfo as a };
@@ -1,17 +0,0 @@
1
- type ModelFormat = "glb" | "gltf" | "obj" | "fbx" | "usdz";
2
-
3
- type ViewerModelBounds = {
4
- min: [number, number, number];
5
- max: [number, number, number];
6
- center: [number, number, number];
7
- size: [number, number, number];
8
- };
9
- /** What `onModelLoaded` reports about a model that finished loading. */
10
- type ViewerModelInfo = {
11
- /** Bounds in world space, where the viewer placed the model. */
12
- bounds: ViewerModelBounds;
13
- /** Number of meshes in the loaded scene. */
14
- objectCount: number;
15
- };
16
-
17
- export type { ModelFormat as M, ViewerModelBounds as V, ViewerModelInfo as a };