@liveroom-tech/react-immersive 5.3.0 → 6.0.1
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.
- package/dist/binding-builder.css +1 -1
- package/dist/binding-builder.d.mts +5 -1
- package/dist/binding-builder.d.ts +5 -1
- package/dist/binding-builder.js +23 -20
- package/dist/binding-builder.mjs +1 -1
- package/dist/chunk-2JFUMJUP.mjs +1 -0
- package/dist/chunk-4JMJALRO.mjs +2 -0
- package/dist/chunk-OTSCPJWF.mjs +1 -0
- package/dist/chunk-P2JZ5Z7I.mjs +1 -0
- package/dist/chunk-UGPR4EPP.mjs +81 -0
- package/dist/chunk-V7WZUWJ5.mjs +1 -0
- package/dist/chunk-VQGYZOMX.mjs +3 -0
- package/dist/hosted.css +1 -1
- package/dist/hosted.d.mts +44 -17
- package/dist/hosted.d.ts +44 -17
- package/dist/hosted.js +22 -19
- package/dist/hosted.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.mts +70 -12
- package/dist/index.d.ts +70 -12
- package/dist/index.js +21 -18
- package/dist/index.mjs +1 -1
- package/dist/{materialVariants-DjTuiWmN.d.mts → modelFileResolver-Co7j1tdQ.d.mts} +122 -29
- package/dist/{materialVariants-DjTuiWmN.d.ts → modelFileResolver-Co7j1tdQ.d.ts} +122 -29
- package/dist/modelViewerProps-BibuMND7.d.ts +1988 -0
- package/dist/modelViewerProps-Ce4-wb57.d.mts +1988 -0
- package/dist/{publicProps-tJuWZgT3.d.ts → publicProps-BaJHCDa_.d.mts} +7 -0
- package/dist/{publicProps-tJuWZgT3.d.mts → publicProps-CP18d_mt.d.ts} +7 -0
- package/dist/simple-model-viewer.d.mts +2 -4
- package/dist/simple-model-viewer.d.ts +2 -4
- package/dist/simple-model-viewer.js +3 -3
- package/dist/simple-model-viewer.mjs +1 -1
- package/dist/utils.d.mts +62 -4
- package/dist/utils.d.ts +62 -4
- package/dist/utils.js +2 -1
- package/dist/utils.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-4FDMYUGT.mjs +0 -3
- package/dist/chunk-CV4E7DOO.mjs +0 -79
- package/dist/chunk-F4WT3HEK.mjs +0 -1
- package/dist/chunk-FPJZDEON.mjs +0 -1
- package/dist/chunk-JHKMRMJH.mjs +0 -1
- package/dist/chunk-TW2M4UXT.mjs +0 -1
- package/dist/chunk-W24UP6NM.mjs +0 -1
- package/dist/modelInfo-BQ5UZu95.d.ts +0 -43
- package/dist/modelInfo-CcYpydB7.d.mts +0 -43
- package/dist/modelViewerProps-BalkRDni.d.ts +0 -618
- package/dist/modelViewerProps-DdsJDRB7.d.mts +0 -618
- package/dist/rendererBackend-C_Jb4_Jy.d.mts +0 -917
- package/dist/rendererBackend-C_Jb4_Jy.d.ts +0 -917
package/dist/binding-builder.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{a as i,c as
|
|
1
|
+
"use client";import{a as i,b as t,c as a}from"./chunk-2JFUMJUP.mjs";import{a as d}from"./chunk-MMO7KCYU.mjs";import{c as f}from"./chunk-VQGYZOMX.mjs";import"./chunk-UGPR4EPP.mjs";import"./chunk-OTSCPJWF.mjs";import{sa as r,ta as o}from"./chunk-4JMJALRO.mjs";import"./chunk-V7WZUWJ5.mjs";import"./chunk-JR557W27.mjs";import{useEffect as m,useState as B}from"react";import{jsx as l}from"react/jsx-runtime";function s(e){d("binding-builder","BindingBuilder");let[u,c]=B(!1);return m(()=>{let n=()=>c(e.arHandoff!==!1&&r(e.arHandoff)?.autoRestore!==!1&&o(window.location.href));return n(),window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[e.arHandoff]),u?l(a,{modelUrl:"",licenseKey:e.licenseKey,enableXR:!0,arHandoff:e.arHandoff??!0,mobileHandoffUrl:e.mobileHandoffUrl,dracoDecoderPath:e.dracoDecoderPath,ktx2TranscoderPath:e.ktx2TranscoderPath,meshopt:e.meshopt}):l(f,{...t(e,i)})}export{s as BindingBuilder};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-MMO7KCYU.mjs";import{H as n}from"./chunk-UGPR4EPP.mjs";var a={licenseKey:!0,arHandoff:!0,mobileHandoffUrl:!0,dracoDecoderPath:!0,ktx2TranscoderPath:!0,meshopt:!0,hideLicenseCheckingOverlay:!0},d={licenseValidationUrl:!0,onObjectEditLeaseChange:!0,onSelectionClear:!0,onSceneLoaded:!0,onTexturePositioningChange:!0,endTexturePositioningRef:!0};function f(e,t){let o={};for(let r of Object.keys(t))r in e&&(o[r]=e[r]);return o}function s(e,t){let o={...e};for(let r of Object.keys(t))delete o[r];return o}import{jsx as c}from"react/jsx-runtime";function l(e){return i("model-viewer","ModelViewer"),c(n,{...s(e,d)})}export{a,f as b,l as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as pe,e as Je,h as Ze,s as Qe}from"./chunk-V7WZUWJ5.mjs";import{Color as en}from"three";var Xn=["position","rotation","scale","visible","baseColor","emissive","opacity","roughness","metalness","emissiveIntensity"],Jn=["linear","ease-in","ease-out","ease-in-out","step"],Zn=new Set(["position","rotation","scale"]),Qn=new Set(["baseColor","emissive"]),W=e=>typeof e=="string"&&e.length>0&&e.length<=256,K=e=>typeof e=="number"&&Number.isFinite(e),ke=e=>Array.isArray(e)&&e.length===3&&e.every(K);function oe(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function H(e){throw new Error(`Invalid sequences: ${e}`)}function et(e){return e.kind==="object"?JSON.stringify([e.kind,e.objectId,e.property]):e.kind==="clip"?JSON.stringify([e.kind,e.clip]):"camera"}function nt(e,n){if(n.kind==="camera")return oe(e)&&ke(e.position)&&ke(e.target)&&(e.fov===null||K(e.fov)&&e.fov>0&&e.fov<180)&&K(e.zoom)&&e.zoom>0;if(n.kind==="clip")return K(e)&&e>=0;let t=n.property;return Zn.has(t)?ke(e)&&(t!=="scale"||e.every(r=>r!==0)):Qn.has(t)?typeof e=="string"&&/^#[\da-f]{6}$/i.test(e):t==="visible"?typeof e=="boolean":K(e)&&e>=0&&(t==="emissiveIntensity"||e<=1)}function nn(e){(!Array.isArray(e)||e.length>64)&&H("expected up to 64 sequences.");let n=new Set,t=0;return e.map(r=>{(!oe(r)||!W(r.id)||n.has(r.id)||!(typeof r.name=="string"&&W(r.name.trim()))||!K(r.duration)||r.duration<.1||r.duration>3600||typeof r.loop!="boolean"||typeof r.autoPlay!="boolean"||!Array.isArray(r.tracks)||r.tracks.length>128)&&H("each sequence needs a unique id, name, 0.1\u20133600 second duration, loop/autoplay flags and up to 128 tracks."),n.add(r.id);let o=new Set,i=new Set,a=r.tracks.map(s=>{(!oe(s)||!W(s.id)||o.has(s.id)||!(typeof s.name=="string"&&W(s.name.trim()))||!oe(s.target)||!Array.isArray(s.keyframes)||s.keyframes.length>2048||s.muted!==void 0&&typeof s.muted!="boolean")&&H("invalid or duplicate track."),o.add(s.id);let c;s.target.kind==="camera"?c={kind:"camera"}:s.target.kind==="clip"&&W(s.target.clip)?c={kind:"clip",clip:s.target.clip}:s.target.kind==="object"&&W(s.target.objectId)&&Xn.includes(s.target.property)?c={kind:"object",objectId:s.target.objectId,property:s.target.property}:H("unknown track target or property.");let l=et(c);i.has(l)&&H("only one track may own each target property in a sequence."),i.add(l);let f=new Set,m=new Set,d=s.keyframes.map(u=>{++t>2e4&&H("too many keyframes."),(!oe(u)||!W(u.id)||f.has(u.id)||!K(u.time)||u.time<0||u.time>r.duration||m.has(u.time)||u.easing!==void 0&&!Jn.includes(u.easing)||!nt(u.value,c))&&H("keyframes need unique ids/times, valid values and times inside the sequence."),f.add(u.id),m.add(u.time);let g=u.value,h=c.kind==="camera"?{position:[...g.position],target:[...g.target],fov:g.fov,zoom:g.zoom}:Array.isArray(u.value)?[...u.value]:u.value;return{id:u.id,time:u.time,value:h,...u.easing?{easing:u.easing}:{}}}).sort((u,g)=>u.time-g.time);return{id:s.id,name:s.name.trim(),target:c,keyframes:d,...s.muted!==void 0?{muted:s.muted}:{}}});return{id:r.id,name:r.name.trim(),duration:r.duration,loop:r.loop,autoPlay:r.autoPlay,tracks:a}})}function tt(e,n="ease-in-out"){let t=Math.max(0,Math.min(1,e));return n==="step"?0:n==="ease-in"?t*t:n==="ease-out"?1-(1-t)**2:n==="ease-in-out"?t*t*(3-2*t):t}var be=(e,n,t)=>e+(n-e)*t,Be=(e,n,t)=>e.map((r,o)=>be(r,n[o],t));function dr(e,n){if(e.muted||!e.keyframes.length||!Number.isFinite(n))return null;let t=e.keyframes;if(n<t[0].time)return null;let r=t[0],o;for(let c of t)if(c.time<=n)r=c;else{o=c;break}if(!o||typeof r.value=="boolean")return structuredClone(r.value);let i=tt((n-r.time)/(o.time-r.time),r.easing);if(typeof r.value=="number"&&typeof o.value=="number")return be(r.value,o.value,i);if(typeof r.value=="string"&&typeof o.value=="string")return`#${new en(r.value).lerp(new en(o.value),i).getHexString()}`;if(Array.isArray(r.value)&&Array.isArray(o.value))return Be(r.value,o.value,i);let a=r.value,s=o.value;return{position:Be(a.position,s.position,i),target:Be(a.target,s.target,i),fov:a.fov!==null&&s.fov!==null?be(a.fov,s.fov,i):a.fov,zoom:be(a.zoom,s.zoom,i)}}function ur(e,n){return{...e,keyframes:[...e.keyframes.filter(t=>t.id!==n.id&&Math.abs(t.time-n.time)>1e-6),n].sort((t,r)=>t.time-r.time)}}function fr(e){let n=e.trim();return n?/\.(hdr|exr|jpg|jpeg|png|webp)(?:[?#].*)?$/i.test(n):!1}var gr=["none","directional","point","spot","hemisphere"],pr=["pbr","matcap","uv-checker"],br=["apartment","city","dawn","forest","lobby","night","park","studio","sunset","warehouse"];var yr=["sporadic","constantMild","constantWild"],hr=["linear","radial","mirroredLinear"],Sr=["verySmall","small","medium","large","veryLarge","huge"];var Ee={enabled:!1,axis:"y",position:.5,flip:!1},rt={clips:[],autoplayClip:null},ot={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}},ne={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:ot,animations:rt,annotations:[]};function ie(e){let n=f=>{throw new Error(`Invalid section: ${f}`)},t=f=>f&&typeof f=="object"&&!Array.isArray(f)?f:n("expected an object"),r=f=>typeof f=="string"&&f.trim().length>0&&f.length<=200?f:n("expected a nonempty name or id (up to 200 characters)"),o=f=>typeof f=="number"&&Number.isFinite(f)&&f>=0&&f<=1?f:n("position must be between 0 and 1"),i=f=>!Array.isArray(f)||f.length!==3||!f.every(m=>typeof m=="number"&&Number.isFinite(m))||Math.hypot(...f)<1e-8?n("normal must be a finite, nonzero vector"):[...f],a=f=>{let m=t(f);return!["x","y","z"].includes(m.axis)||typeof m.enabled!="boolean"||typeof m.flip!="boolean"?n("invalid plane"):{enabled:m.enabled,axis:m.axis,position:o(m.position),flip:m.flip,...m.normal!==void 0?{normal:i(m.normal)}:{}}},s=f=>{let m=t(f),d=a(m);if(m.mode!==void 0){if(!["plane","planes","box"].includes(m.mode))return n("invalid mode");d.mode=m.mode}if(m.planes!==void 0){if(!Array.isArray(m.planes)||m.planes.length>6)return n("at most six planes are supported");let u=new Set;d.planes=m.planes.map(g=>{let h=t(g),p=r(h.id);return u.has(p)?n("duplicate plane id"):(u.add(p),{...a(h),id:p,name:r(h.name)})})}if(m.activePlaneId!==void 0&&(d.activePlaneId=r(m.activePlaneId)),m.invertBox!==void 0){if(typeof m.invertBox!="boolean")return n("invalid box inversion");d.invertBox=m.invertBox}if(m.box!==void 0){let u=t(m.box),g=b=>!Array.isArray(b)||b.length!==3?n("invalid box bounds"):b.map(o),h=g(u.min),p=g(u.max);if(h.some((b,y)=>b>=p[y]))return n("box minimum must be below its maximum on every axis");d.box={min:h,max:p}}return d},c=t(e),l=s(c);if(c.presets!==void 0){if(!Array.isArray(c.presets)||c.presets.length>32)return n("at most 32 presets are supported");let f=new Set;l.presets=c.presets.map(m=>{let d=t(m),u=r(d.id);return f.has(u)?n("duplicate preset id"):(f.add(u),{id:u,name:r(d.name),settings:s(d.settings)})})}return l}function Or(e){let{presets:n,...t}=ie(e);return t}function Ar(e){try{return ie(e)}catch{return Ee}}function Mr(e,n){if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Invalid section: expected an object");let t=["enabled","axis","position","flip"].every(r=>Object.prototype.hasOwnProperty.call(n,r));return ie(t?n:{...Ee,...e,...n})}import{Box3 as tn,Matrix4 as he,Quaternion as it,Vector3 as ye,Euler as st}from"three";var vr={version:1,placements:{},gridSize:1};function Re(e){return e.id??e.url}function se(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Expected an asset transform object.");let n={};for(let t of["position","rotation","scale"]){let r=e[t];if(r!==void 0){if(!Array.isArray(r)||r.length!==3||!r.every(o=>typeof o=="number"&&Number.isFinite(o))||t==="scale"&&r.some(o=>o===0))throw new Error(`Invalid asset ${t}: expected three finite ${t==="scale"?"nonzero ":""}numbers.`);n[t]=[...r]}}return n}function Ir(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid scene composition.");let n=e;if(n.version!==1||!Number.isFinite(n.gridSize)||n.gridSize<=0||!n.placements||typeof n.placements!="object"||Array.isArray(n.placements)||Object.keys(n.placements).length>256)throw new Error("Invalid scene composition version, grid size or placements (maximum 256).");let t={};for(let[r,o]of Object.entries(n.placements)){if(!r||["__proto__","constructor","prototype"].includes(r))throw new Error("Invalid asset instance ID.");let i=se(o);if(o.label!==void 0&&(typeof o.label!="string"||o.label.length>512))throw new Error("Invalid asset label.");for(let a of["visible","deleted"])if(o[a]!==void 0&&typeof o[a]!="boolean")throw new Error(`Invalid asset ${a}.`);t[r]={...i,...o.label!==void 0?{label:o.label}:{},...o.visible!==void 0?{visible:o.visible}:{},...o.deleted!==void 0?{deleted:o.deleted}:{}}}return{version:1,gridSize:n.gridSize,placements:t}}function Tr(e,n){if(!Number.isFinite(n)||n<=0)throw new Error("Grid size must be positive.");let t=se(e),[r,o,i]=t.position??[0,0,0];return{...t,position:[Math.round(r/n)*n,o,Math.round(i/n)*n]}}function kr(e,n){let t=se(e),r=t.position??[0,0,0],o=new he().compose(new ye(...r),new it().setFromEuler(new st(...t.rotation??[0,0,0])),new ye(...t.scale??[1,1,1])),i=new tn(new ye(...n.min),new ye(...n.max)).applyMatrix4(o);if(!Number.isFinite(i.min.y))throw new Error("Cannot place an asset with empty bounds.");return{...t,position:[r[0],r[1]-i.min.y,r[2]]}}function Br(e){e.updateWorldMatrix(!0,!0);let n=new he().copy(e.parent?.parent?.matrixWorld??new he).invert(),t=new tn;return e.traverse(r=>{let o=r;o.geometry&&(o.geometry.computeBoundingBox(),o.geometry.boundingBox&&t.union(o.geometry.boundingBox.clone().applyMatrix4(new he().multiplyMatrices(n,o.matrixWorld))))}),t.isEmpty()||![...t.min.toArray(),...t.max.toArray()].every(Number.isFinite)?null:{min:t.min.toArray(),max:t.max.toArray()}}import{BufferGeometry as at,Float32BufferAttribute as ct,Matrix4 as on,Mesh as Ne,ShapeUtils as lt,Vector2 as sn,Vector3 as I,Vector4 as dt}from"three";function an(e){if(e.length!==3)return null;let n=new I(...e[0]).sub(new I(...e[1])),t=new I(...e[2]).sub(new I(...e[1]));return n.lengthSq()===0||t.lengthSq()===0?null:Math.acos(Math.max(-1,Math.min(1,n.normalize().dot(t.normalize()))))*180/Math.PI}function cn(e,n){if(!e.normal)return null;let t=new I(...e.normal);if(t.lengthSq()===0)return null;t.normalize();let r=new I(...n),o=r.clone().sub(new I(...e.position)).dot(t);return{distance:Math.abs(o),projection:r.addScaledVector(t,-o).toArray()}}function ln(e){if(e.length<3)return{error:"Pick at least three points to finish the area."};let n=new I(...e[0]),t=e.map(p=>new I(...p).sub(n)),r=Math.max(...t.map(p=>p.length()));if(r===0)return{error:"Area points must be distinct."};let o=new I;for(let p=1;p<t.length-1;p+=1){let b=t[p].clone().cross(t[p+1]);b.lengthSq()>o.lengthSq()&&o.copy(b)}if(o.length()<=r*r*1e-10)return{error:"Area points must not lie on one straight line."};o.normalize();let i=Math.max(r*1e-5,Number.EPSILON*Math.max(...e.flat().map(Math.abs))*32);if(t.some(p=>Math.abs(p.dot(o))>i))return{error:"Area points must lie on one plane."};let a=t.find(p=>p.length()>r*1e-10).clone().normalize(),s=o.clone().cross(a).normalize(),c=t.map(p=>new sn(p.dot(a),p.dot(s))),l=(p,b,y)=>(b.x-p.x)*(y.y-p.y)-(b.y-p.y)*(y.x-p.x),f=r*r*1e-10,m=(p,b,y)=>Math.abs(l(p,b,y))<=f&&y.x>=Math.min(p.x,b.x)-r*1e-10&&y.x<=Math.max(p.x,b.x)+r*1e-10&&y.y>=Math.min(p.y,b.y)-r*1e-10&&y.y<=Math.max(p.y,b.y)+r*1e-10;for(let p=0;p<c.length;p+=1){let b=c[p],y=c[(p+1)%c.length];if(b.distanceTo(y)<=r*1e-10)return{error:"Area points must be distinct."};for(let w=p+1;w<c.length;w+=1){if(w===p+1||p===0&&w===c.length-1)continue;let O=c[w],x=c[(w+1)%c.length],A=l(b,y,O),E=l(b,y,x),R=l(O,x,b),re=l(O,x,y);if(A*E<0&&R*re<0||m(b,y,O)||m(b,y,x)||m(O,x,b)||m(O,x,y))return{error:"Area edges must not cross or touch each other."}}}let d=0,u=0,g=0;for(let p=0;p<c.length;p+=1){let b=c[p],y=c[(p+1)%c.length],w=b.x*y.y-y.x*b.y;d+=w,u+=(b.x+y.x)*w,g+=(b.y+y.y)*w}if(Math.abs(d)<=f)return{error:"The polygon has no measurable area."};let h=n.clone().addScaledVector(a,u/(3*d)).addScaledVector(s,g/(3*d));return{area:Math.abs(d)/2,center:h.toArray(),triangles:lt.triangulateShape(c,[])}}function Pe(e,n){if(e.length<2)return 0;let t=0;for(let r=1;r<e.length;r+=1)t+=new I(...e[r]).distanceTo(new I(...e[r-1]));return n&&(t+=new I(...e[e.length-1]).distanceTo(new I(...e[0]))),t}var ut=1e-5;function mt(e,n){let t=e.getAttribute("position"),r=e.getIndex(),o=t.count,i=Math.max(n,1e-9),a=(g,h,p)=>`${Math.round(g/i)}_${Math.round(h/i)}_${Math.round(p/i)}`,s=new Int32Array(o),c=[],l=new Map;for(let g=0;g<o;g+=1){let h=t.getX(g),p=t.getY(g),b=t.getZ(g),y=a(h,p,b),w=l.get(y);w===void 0&&(w=c.length,c.push(new I(h,p,b)),l.set(y,w)),s[g]=w}let f=c.map(()=>new Map),m=(g,h)=>{if(g===h)return;let p=c[g].distanceTo(c[h]);f[g].has(h)||f[g].set(h,p),f[h].has(g)||f[h].set(g,p)},d=(r?r.count:o)/3,u=g=>r?r.getX(g):g;for(let g=0;g<d;g+=1)m(s[u(g*3)],s[u(g*3+1)]),m(s[u(g*3+1)],s[u(g*3+2)]),m(s[u(g*3+2)],s[u(g*3)]);return{weldedId:s,weldedPosition:c,neighbors:f}}function ft(e,n,t){let r=new Map([[n,0]]),o=[n];for(let i=0;i<t&&o.length>0;i+=1){let a=[];for(let s of o){let c=r.get(s)??0;for(let[l,f]of e[s]??[])r.has(l)||(r.set(l,c+f),a.push(l))}o=a}return r}function gt(e){let t=(Math.abs(e.y)<.9?new I(0,1,0):new I(1,0,0)).clone().cross(e).normalize(),r=e.clone().cross(t).normalize();return[t,r]}function pt(e,n,t){let[r,o]=gt(n),i=0,a=0,s=0;for(let h of t){let p=h.clone().sub(e),b=p.dot(r),y=p.dot(o);i+=b*b,a+=b*y,s+=y*y}let c=i+s,l=i*s-a*a,f=Math.sqrt(Math.max(0,c*c/4-l)),m=c/2+f,d=1,u=0;Math.abs(a)>1e-12?(d=m-s,u=a):s>i&&(d=0,u=1);let g=Math.hypot(d,u)||1;return r.clone().multiplyScalar(d/g).add(o.clone().multiplyScalar(u/g)).normalize()}function bt(e,n,t,r){let o=e.getAttribute("position"),i=e.getIndex(),a=o.count,s=(i?i.count:a)/3,c=d=>i?i.getX(d):d,l=d=>new I(o.getX(d),o.getY(d),o.getZ(d)).applyMatrix4(n),f=d=>d.clone().sub(t).dot(r),m=[];for(let d=0;d<s;d+=1){let u=l(c(d*3)),g=l(c(d*3+1)),h=l(c(d*3+2)),p=f(u),b=f(g),y=f(h),w=[],O=(x,A,E,R)=>{A>0!=R>0&&w.push(x.clone().lerp(E,A/(A-R)))};O(u,p,g,b),O(g,b,h,y),O(h,y,u,p),w.length===2&&m.push([w[0],w[1]])}return m}function yt(e,n){let t=Math.max(n,1e-9),r=d=>`${Math.round(d.x/t)}_${Math.round(d.y/t)}_${Math.round(d.z/t)}`,o=new Map,i=[],a=d=>{let u=r(d),g=o.get(u);return g===void 0&&(g=i.length,i.push(d),o.set(u,g)),g},s=[],c=d=>{for(;s.length<=d;)s.push(new Map)};for(let[d,u]of e){let g=a(d),h=a(u);g!==h&&(c(g),c(h),s[g].set(h,(s[g].get(h)??0)+1),s[h].set(g,(s[h].get(g)??0)+1))}let l=(d,u)=>d<u?`${d}_${u}`:`${u}_${d}`,f=new Set,m=[];for(let d=0;d<s.length;d+=1)for(let u of s[d]?.keys()??[]){if(f.has(l(d,u)))continue;let g=[d],h=d,p=u;f.add(l(h,p));let b=0;for(;p!==d&&p>=0&&b<s.length+4;){g.push(p);let y=[...s[p].keys()].filter(O=>O!==h),w;if(y.length<=1)w=y[0];else{let O=i[p].clone().sub(i[h]).normalize(),x=-1/0;for(let A of y){let E=i[A].clone().sub(i[p]).normalize(),R=O.dot(E);R>x&&(x=R,w=A)}}if(w===void 0){p=-1;break}f.add(l(p,w)),h=p,p=w,b+=1}p===d&&g.length>=3&&m.push(g.map(y=>i[y]))}return m}function rn(e,n){let t=1/0;for(let r of e)t=Math.min(t,r.distanceTo(n));return t}function ht(e,n){let t=0,r=1/0;return e.forEach((o,i)=>{let a=o.distanceTo(n);a<r&&(r=a,t=i)}),[...e.slice(t),...e.slice(0,t)]}function dn(e,n,t,r,o){let i=bt(e,n,r,o);if(i.length===0)return{error:"Couldn't trace a loop around this point."};let a=yt(i,t*n.getMaxScaleOnAxis());if(a.length===0)return{error:"The surface here doesn't form a closed loop around this point (it may be near an open edge)."};let s=a[0],c=rn(s,r);for(let f of a.slice(1)){let m=rn(f,r);m<c&&(c=m,s=f)}let l=ht(s,r).map(f=>f.toArray());return{points:l,length:Pe(l,!0)}}function un(e){if(!(e.object instanceof Ne)||!e.face)return null;let n=e.object,t=n.geometry;if(n.isSkinnedMesh||n.morphTargetInfluences?.some(i=>i!==0)){let i=t.getAttribute("position"),a=new ct(new Float32Array(i.count*3),3),s=new I;for(let c=0;c<i.count;c++)n.getVertexPosition(c,s),a.setXYZ(c,s.x,s.y,s.z);t=new at().setAttribute("position",a).setIndex(t.getIndex())}let r=n.matrixWorld.clone();if(e.instanceId!==void 0&&"getMatrixAt"in n){let i=new on;n.getMatrixAt(e.instanceId,i),r.multiply(i)}t.computeBoundingSphere();let o=t.boundingSphere&&t.boundingSphere.radius>0?t.boundingSphere.radius:1;return{face:e.face,geometry:t,matrix:r,weldTolerance:o*ut}}function Nr(e,n=6){let t=un(e);if(!t)return{error:"Pick a point on the mesh surface to trace a loop around it."};let{face:r,geometry:o,matrix:i,weldTolerance:a}=t,s=mn(e);if(!s)return{error:"Pick a point on the mesh surface to trace a loop around it."};let c=s[1].clone().sub(s[0]).cross(s[2].clone().sub(s[0]));if(c.lengthSq()===0)return{error:"Couldn't determine the surface direction at this point."};c.normalize();let{weldedId:l,weldedPosition:f,neighbors:m}=mt(o,a),d=o.getAttribute("position"),u=e.point.clone().applyMatrix4(i.clone().invert()),g=[r.a,r.b,r.c],h=g[0],p=1/0;for(let A of g){let R=new I(d.getX(A),d.getY(A),d.getZ(A)).distanceTo(u);R<p&&(p=R,h=A)}let b=l[h],y=f[b].clone().applyMatrix4(i),w=ft(m,b,n),O=[];for(let A of w.keys())O.push(f[A].clone().applyMatrix4(i));if(O.length<6)return{error:"Not enough surface detail near this point to trace a loop. Try a different spot."};let x=pt(y,c,O);return dn(o,i,a,e.point.clone(),x)}function Pr(e,n=new I(0,1,0)){let t=un(e);if(!t)return{error:"Pick a point on the mesh surface to trace a loop around it."};let{geometry:r,matrix:o,weldTolerance:i}=t,a=n.clone().normalize();return a.lengthSq()===0?{error:"Couldn't determine a horizontal direction."}:dn(r,o,i,e.point.clone(),a)}function mn(e){if(!(e.object instanceof Ne)||!e.face)return null;let n=e.object,t=n.matrixWorld.clone();if(e.instanceId!==void 0&&"getMatrixAt"in n){let r=new on;n.getMatrixAt(e.instanceId,r),t.multiply(r)}return[e.face.a,e.face.b,e.face.c].map(r=>n.getVertexPosition(r,new I).applyMatrix4(t))}function Vr(e){if(!(e.object instanceof Ne))return!1;for(let t=e.object;t;t=t.parent)if(!t.visible||t.userData.riEditorGizmo||t.userData.riDecal)return!1;return(Array.isArray(e.object.material)?e.object.material:[e.object.material])[e.face?.materialIndex??0]?.visible!==!1}function Lr(e,n,t,r,o,i=12){let a=mn(e),s=a?a[1].clone().sub(a[0]).cross(a[2].clone().sub(a[0])).normalize():null,c={position:e.point.toArray(),...s&&s.lengthSq()>0?{normal:s.toArray()}:{},...a?{faceVertices:a.map(d=>d.toArray())}:{}};if(!a||o==="none")return c;let l=d=>{let u=new dt(d.x,d.y,d.z,1).applyMatrix4(n.matrixWorldInverse).applyMatrix4(n.projectionMatrix);return u.w<=0||u.z/u.w<-1||u.z/u.w>1?null:{screen:new sn((u.x/u.w+1)*r.width/2,(1-u.y/u.w)*r.height/2),w:u.w}},f=a.map(l),m=i;if((o==="vertex"||o==="auto")&&(f.forEach((d,u)=>{let g=d?.screen.distanceTo(t)??1/0;g<=m&&(m=g,c.position=a[u].toArray(),c.snapped="vertex")}),c.snapped))return c;if(o==="edge"||o==="auto")for(let d=0;d<3;d+=1){let u=(d+1)%3,g=f[d],h=f[u];if(!g||!h)continue;let p=h.screen.clone().sub(g.screen);if(p.lengthSq()===0)continue;let b=Math.max(0,Math.min(1,t.clone().sub(g.screen).dot(p)/p.lengthSq())),y=g.screen.clone().addScaledVector(p,b).distanceTo(t);if(y<=m){m=y;let w=b*g.w/((1-b)*h.w+b*g.w);c.position=a[d].clone().lerp(a[u],w).toArray(),c.snapped="edge"}}return c}var St=["m","cm","mm","in","ft"],Ve={m:1,cm:.01,mm:.001,in:.0254,ft:.3048},xt=["distance","angle","area","pointToPlane","wrap","wrapHorizontal"];function Le(e){return St.includes(e)}function wt(e={},n="m"){let t=e.displayUnit??n,r=e.metersPerUnit??Ve[e.sourceUnit??"m"];if(!Number.isFinite(r)||r<=0)throw new Error("Measurement scale must be a positive finite number.");return{displayUnit:t,metersPerUnit:r,factor:Le(t)?r/Ve[t]:1}}function Ur(e){try{return new URL(e,typeof window<"u"?window.location?.href:void 0).href}catch{return e}}function Dr(e,n,t,r={}){if(!Le(t)||!Number.isFinite(e)||e<=0||!Number.isFinite(n)||n<=0)throw new Error("Calibration needs two distinct points and a positive known distance.");let o=n*Ve[t]/e;if(!Number.isFinite(o)||o<=0)throw new Error("Calibration scale is outside the supported range.");return{...r,metersPerUnit:o}}function fn(e,n){let t=n.map(r=>r.position);if(e==="angle"){let r=an(t);return r===null?null:{value:r,dimension:0}}if(e==="area"){let r=ln(t);return"error"in r?null:{value:r.area,dimension:2}}if(e==="pointToPlane"){let r=n.length===2?cn(n[0],n[1].position):null;return r?{value:r.distance,dimension:1}:null}return n.length<(e==="distance"?2:3)?null:{value:Pe(t,e!=="distance"),dimension:1}}function Ot(e,n={},t="m",r=e.points,o=e.approximate?"approximate":"ready"){let i=fn(e.tool,r),{factor:a,displayUnit:s}=wt(n,t),c=o==="ready"||o==="approximate",l=c&&i?i.value*a**i.dimension:null;return{id:e.id,status:c?i&&l!==null&&Number.isFinite(l)?o:"invalid":o,rawValue:c&&i&&Number.isFinite(i.value)?i.value:null,value:l!==null&&Number.isFinite(l)?l:null,unit:e.tool==="angle"?"\xB0":e.tool==="area"?`${s}\xB2`:s}}function ae(e){function n(){throw new Error("Invalid measurements: expected settings and valid named measurements with finite points.")}let t=s=>!!s&&typeof s=="object"&&!Array.isArray(s),r=s=>Array.isArray(s)&&s.length===3&&s.every(c=>typeof c=="number"&&Number.isFinite(c));typeof e=="string"&&(e.length>5*1024*1024&&n(),e=JSON.parse(e)),(!t(e)||e.version!==void 0&&e.version!==1||!t(e.settings)||!Array.isArray(e.items)||e.items.length>256)&&n();let o={};for(let s of["sourceUnit","displayUnit"])e.settings[s]!==void 0&&(Le(e.settings[s])||n(),o[s]=e.settings[s]);e.settings.metersPerUnit!==void 0&&((typeof e.settings.metersPerUnit!="number"||!Number.isFinite(e.settings.metersPerUnit)||e.settings.metersPerUnit<=0)&&n(),o.metersPerUnit=e.settings.metersPerUnit);let i=new Set,a=e.items.map(s=>{(!t(s)||typeof s.id!="string"||!s.id||i.has(s.id)||typeof s.name!="string"||!s.name.trim()||typeof s.modelId!="string"||!s.modelId||!xt.includes(s.tool)||!Array.isArray(s.points)||s.points.length>8192||typeof s.createdAt!="string"||!Number.isFinite(Date.parse(s.createdAt)))&&n(),i.add(s.id),s.tilesetUrl!==void 0&&s.tilesetUrl!==null&&typeof s.tilesetUrl!="string"&&n(),(s.visible!==void 0&&typeof s.visible!="boolean"||s.approximate!==void 0&&typeof s.approximate!="boolean")&&n();let c=new Set,l=s.points.map(m=>{if((!t(m)||typeof m.id!="number"||!Number.isFinite(m.id)||!r(m.position))&&n(),c.has(m.id)&&n(),c.add(m.id),m.normal!==void 0&&!r(m.normal)&&n(),m.faceVertices!==void 0&&(!Array.isArray(m.faceVertices)||m.faceVertices.length!==3||!m.faceVertices.every(r))&&n(),m.snapped!==void 0&&!["vertex","edge"].includes(m.snapped)&&n(),m.anchor!==void 0){let u=m.anchor;(!t(u)||typeof u.nodeId!="string"||!u.nodeId||!r(u.localPosition)||typeof u.geometrySignature!="string"||typeof u.poseSignature!="string")&&n(),u.localNormal!==void 0&&!r(u.localNormal)&&n(),u.localFaceVertices!==void 0&&(!Array.isArray(u.localFaceVertices)||u.localFaceVertices.length!==3||!u.localFaceVertices.every(r))&&n(),u.instanceId!==void 0&&(!Number.isInteger(u.instanceId)||u.instanceId<0)&&n()}let d=m.anchor;return{id:m.id,position:[...m.position],...m.normal?{normal:[...m.normal]}:{},...m.faceVertices?{faceVertices:m.faceVertices.map(u=>[...u])}:{},...m.snapped?{snapped:m.snapped}:{},...d?{anchor:{nodeId:d.nodeId,localPosition:[...d.localPosition],geometrySignature:d.geometrySignature,poseSignature:d.poseSignature,...d.localNormal?{localNormal:[...d.localNormal]}:{},...d.localFaceVertices?{localFaceVertices:d.localFaceVertices.map(u=>[...u])}:{},...d.instanceId!==void 0?{instanceId:d.instanceId}:{}}}:{}}}),f={id:s.id,name:s.name,modelId:s.modelId,tool:s.tool,points:l,createdAt:s.createdAt,...s.tilesetUrl!==void 0?{tilesetUrl:s.tilesetUrl}:{},...s.visible!==void 0?{visible:s.visible}:{},...s.approximate!==void 0?{approximate:s.approximate}:{}};return fn(f.tool,l)||n(),f});return{settings:o,items:a}}function $r(e){return JSON.stringify({version:1,...ae(e)},null,2)}function Fr(e,n,t="m"){let r=ae(e),o=new Map(n?.map(a=>[a.id,a])),i=a=>{let s=String(a??"");return/^[=+@-]/.test(s)&&(s=`'${s}`),`"${s.replace(/"/g,'""')}"`};return[["id","name","modelId","type","status","value","unit","createdAt"],...r.items.map(a=>{let s=o.get(a.id)??Ot(a,r.settings,t);return[a.id,a.name,a.modelId,a.tool,s.status,s.value,s.unit,a.createdAt]})].map(a=>a.map(i).join(",")).join(`\r
|
|
2
|
+
`)}function gn(e){if(!Array.isArray(e)||e.length>128)throw new Error("Invalid selections: expected up to 128 named selection sets.");let n=new Set;return e.map(t=>{if(!t||typeof t!="object"||typeof t.id!="string"||!t.id||n.has(t.id)||typeof t.name!="string"||!t.name.trim()||t.name.length>200||!Array.isArray(t.objectIds)||t.objectIds.length>1e5||t.objectIds.some(r=>typeof r!="string"||!r))throw new Error("Invalid selections: each set needs a unique id, a name, and model object ids.");return n.add(t.id),{id:t.id,name:t.name.trim(),objectIds:[...new Set(t.objectIds)]}})}import{CanvasTexture as pn,Color as bn,ImageLoader as At,NoColorSpace as xe,RepeatWrapping as Se,SRGBColorSpace as $e,Texture as Mt}from"three";var Y=new Map,Ue={color:"#93c5fd",intensity:.07},Hr=new bn(Ue.color).multiplyScalar(Ue.intensity),Kr=new bn(Ue.color),Yr=.28,te=new Map,De=new Map;function jt(e){return`${e.name}|${e.size}|${e.lastModified}`}function Xr(e){let n=jt(e),t=e.name.lastIndexOf("."),r=t>0?e.name.slice(0,t):e.name,o=t>0?e.name.slice(t):"",i=`materials/${e.name}`,a=2;for(;;){let s=De.get(i);if(s===void 0||s===n)return De.set(i,n),i;i=`materials/${r}-${a}${o}`,a+=1}}function we(e){return te.get(e)}function yn(e,n){let t=++e.loadGeneration;e.loaded=!1,e.failed=!1;let r=()=>{if(e.loadGeneration!==t)return;e.loaded=!0;let o=e.pending;e.pending=[];for(let i of o)i()};new At().load(n,o=>{e.loadGeneration===t&&(e.texture.image=o,e.texture.needsUpdate=!0,r())},void 0,()=>{e.loadGeneration===t&&(e.failed=!0,console.warn(`Failed to load texture: ${n}`),r())})}function hn(e,n){for(let t of[$e,xe]){let r=Y.get(ce(e,t));r&&yn(r,n)}}function Jr(e,n){let t=te.get(e);t&&t!==n&&t.startsWith("blob:")&&URL.revokeObjectURL(t),te.set(e,n),hn(e,n)}function Zr(e){let n=te.get(e);n&&(n.startsWith("blob:")&&URL.revokeObjectURL(n),te.delete(e),De.delete(e),hn(e,e))}function ce(e,n){return`${n}|${e}`}function Ct(e,n=xe,t){let r=ce(e,n),o=Y.get(r);if(o)return t&&!o.loaded&&o.pending.push(t),o.texture;let i=te.get(e)??e,a={texture:new Mt,refCount:0,loaded:!1,pending:t?[t]:[],loadGeneration:0};return a.texture.flipY=!1,a.texture.colorSpace=n,Y.set(r,a),yn(a,i),a.texture}function Qr(e,n=xe,t){let r=Ct(e,n,t);return Y.get(ce(e,n)).refCount+=1,r}function eo(e,n=xe){let t=Y.get(ce(e,n));t&&(t.refCount-=1,t.refCount<=0&&(t.loadGeneration+=1,t.pending=[],t.texture.dispose(),Y.delete(ce(e,n))))}function no(e,n,t,r,o,i=1,a=0){let s=e.offsetTextures??(e.offsetTextures={}),c=s[n],l=c;if(!l||l.sourcePath!==r||l.base!==t){c?.texture.dispose();let m=t.clone();m.wrapS=Se,m.wrapT=Se,m.center.set(.5,.5),m.needsUpdate=!0,l={texture:m,sourcePath:r,base:t},s[n]=l}let f=i>0?i:1;return l.texture.offset.set(o[0],o[1]),l.texture.repeat.set(1/f,1/f),l.texture.rotation=a,l.texture}function to(e,n){let t=e.offsetTextures,r=t?.[n];r&&(r.texture.dispose(),delete t[n])}function ro(e){let n=e.offsetTextures;if(n){for(let t of Object.values(n))t.texture.dispose();delete e.offsetTextures}}var _e=null;function oo(){if(_e)return _e;let e=256,n=document.createElement("canvas");n.width=e,n.height=e;let t=n.getContext("2d"),r=t.createRadialGradient(e*.35,e*.35,e*.02,e*.5,e*.5,e*.55);r.addColorStop(0,"#ffffff"),r.addColorStop(.4,"#b5b5b5"),r.addColorStop(1,"#3a3a3a"),t.fillStyle=r,t.fillRect(0,0,e,e);let o=new pn(n);return o.colorSpace=$e,_e=o,o}var ze=null;function io(){if(ze)return ze;let e=1024,n=8,t=e/n,r=["#ef4444","#f59e0b","#22c55e","#6366f1"],o=document.createElement("canvas");o.width=e,o.height=e;let i=o.getContext("2d");i.textAlign="center",i.textBaseline="middle";for(let s=0;s<n;s+=1)for(let c=0;c<n;c+=1){let l=c*t,f=s*t,m=(Math.floor(c/2)+Math.floor(s/2))%4;i.fillStyle=r[m],i.fillRect(l,f,t,t),i.strokeStyle="rgba(0, 0, 0, 0.28)",i.lineWidth=2;for(let y=1;y<4;y+=1){let w=y*t/4;i.beginPath(),i.moveTo(l+w,f),i.lineTo(l+w,f+t),i.moveTo(l,f+w),i.lineTo(l+t,f+w),i.stroke()}i.strokeStyle="#09090b",i.lineWidth=7,i.strokeRect(l,f,t,t);let d=l+t*.23,u=f+t*.72,g=l+t*.72,h=f+t*.23;i.lineCap="round",i.lineJoin="round",i.beginPath(),i.moveTo(d,u),i.lineTo(g,h),i.lineTo(g-t*.2,h),i.moveTo(g,h),i.lineTo(g,h+t*.2),i.stroke();let p=s*n+c+1;i.font=`700 ${Math.round(t*.2)}px ui-monospace, SFMono-Regular, Menlo, monospace`,i.fillStyle="#ffffff",i.strokeStyle="rgba(0, 0, 0, 0.85)",i.lineWidth=6;let b=String(p).padStart(2,"0");i.strokeText(b,l+t/2,f+t*.82),i.fillText(b,l+t/2,f+t*.82)}let a=new pn(o);return a.colorSpace=$e,a.wrapS=Se,a.wrapT=Se,a.flipY=!1,a.anisotropy=8,a.needsUpdate=!0,ze=a,a}function Sn(e){for(let n of Y.values())if(n.texture.source===e.source&&(!n.loaded||n.failed))return!0;return!1}var X=5*1024*1024,vt=["activeModelId","modelUrl","modelFormat","tilesetUrl","models","mergeModels","sceneConfig","isolation","multiSelectedKeys","activeAnnotation","annotationCategories","backgroundColor","shadows","cinematic","cameraControllerType","objectTransformSpace","arScaleMode","usdzUrl","measurements","measurementSettings","measurementUnit","measurementModelId"];function S(e,n){throw new Error(`Invalid viewer state at ${e}: ${n}`)}function T(e,n){(!e||typeof e!="object"||Array.isArray(e))&&S(n,"expected an object.")}function le(e,n){(!Array.isArray(e)||!e.every(t=>typeof t=="string"))&&S(n,"expected strings.")}function _(e,n,t){(!Array.isArray(e)||e.length!==n||!e.every(r=>typeof r=="number"&&Number.isFinite(r)))&&S(t,`expected ${n} finite numbers.`)}function It(e){let n=new Set,t=0;function r(o,i,a){if((++t>2e5||a>64)&&S(i,"configuration is too complex."),o===null||typeof o=="string"||typeof o=="boolean"||typeof o=="number"&&Number.isFinite(o))return o;(typeof o!="object"||!o)&&S(i,"expected JSON data (finite numbers, no functions)."),n.has(o)&&S(i,"cyclic data."),!Array.isArray(o)&&Object.getPrototypeOf(o)!==Object.prototype&&Object.getPrototypeOf(o)!==null&&S(i,"expected plain JSON data."),n.add(o);let s=Array.isArray(o)?[]:{};for(let[c,l]of Object.entries(o))["__proto__","constructor","prototype"].includes(c)&&S(`${i}.${c}`,"reserved property."),l!==void 0?s[c]=r(l,`${i}.${c}`,a+1):Array.isArray(o)&&S(i,"undefined array entry.");return n.delete(o),s}return r(e,"state",0)}function z(e,n,t,r,o=!1,i){let a=e[n];if(a==null||a==="")return;typeof a!="string"&&S(t,"expected a URL.");let s=o?we(a)??a:a;if(s.trim().startsWith("blob:")){if(o&&i){i.set(a,{source:s,path:t});return}S(t,o?"this image is temporary. Use getStateAsync() for JSON or createShareUrl() to include it.":"upload this model/environment asset to a durable URL before saving or sharing.")}if(s!==a&&(a=s,e[n]=s),o&&/^data:image\//i.test(a))return;let c;try{c=new URL(a,r??"https://relative.invalid/")}catch{S(t,"invalid asset URL.")}["http:","https:"].includes(c.protocol)||S(t,"use an HTTP(S) asset URL."),r&&(e[n]=c.href)}function Tt(e,n){T(e,n),_(e.position,3,`${n}.position`),_(e.target,3,`${n}.target`),(typeof e.zoom!="number"||e.zoom<=0)&&S(n,"zoom must be positive."),e.fov!==null&&(typeof e.fov!="number"||e.fov<=0||e.fov>=180)&&S(n,"fov must be null or between 0 and 180.");for(let t of["azimuthAngle","polarAngle"])e[t]!==void 0&&typeof e[t]!="number"&&S(n,`${t} must be a number.`)}function On(e,n,t,r){T(e,n),(typeof e.id!="number"||typeof e.title!="string"||typeof e.description!="string")&&S(n,"expected an annotation id, title and description.");for(let o of["worldPosition","localPosition"])_(e[o],3,`${n}.${o}`);e.images!==void 0&&(Array.isArray(e.images)||S(n,"images must be an array."),e.images.forEach(o=>{T(o,n),z(o,"src",n,t,!0,r)})),e.links!==void 0&&(Array.isArray(e.links)||S(n,"links must be an array."),e.links.forEach(o=>{T(o,n),z(o,"href",n,t,!1,r)}))}function An(e,n){T(e,n),e.waypoints!==void 0&&(Array.isArray(e.waypoints)||S(n,"expected waypoints."),e.waypoints.forEach(t=>{T(t,n),_(t.position,3,n),_(t.target,3,n)}));for(let t of["enabled","loop","autoPlay"])e[t]!==void 0&&typeof e[t]!="boolean"&&S(n,`${t} must be boolean.`);e.duration!==void 0&&(typeof e.duration!="number"||e.duration<=0)&&S(n,"duration must be positive.")}function Fe(e,n,t){if(n!==null)if(Array.isArray(n))Array.isArray(e)||S(t,"expected an array."),n.length&&e.forEach(r=>Fe(r,n[0],t));else if(typeof n=="object"){T(e,t);for(let[r,o]of Object.entries(n))Fe(e[r],o,`${t}.${r}`)}else typeof e!=typeof n&&S(t,`expected ${typeof n}.`)}function xn(e,n,t,r){if(Fe(e,ne,n),e.measurements!==void 0&&(e.measurements=ae(e.measurements)),e.sequences!==void 0&&(e.sequences=nn(e.sequences)),e.selectionSets!==void 0&&(e.selectionSets=gn(e.selectionSets)),_(e.model.rotation,3,`${n}.model.rotation`),e.lighting.lights.forEach(o=>_(o.position,3,`${n}.lighting.lights`)),e.annotations.forEach(o=>On(o,`${n}.annotations`,t,r)),e.animations.autoplayClip!==null&&typeof e.animations.autoplayClip!="string"&&S(n,"invalid autoplay clip."),e.animations.clips.forEach(o=>{T(o,n),(typeof o.sourceName!="string"||typeof o.displayName!="string"||typeof o.hidden!="boolean"||typeof o.speed!="number"||!["repeat","once","ping-pong"].includes(o.loopMode))&&S(n,"invalid animation clip settings.")}),e.cinematic!==void 0&&An(e.cinematic,`${n}.cinematic`),e.styleRules!==void 0&&!Array.isArray(e.styleRules)&&S(n,"styleRules must be an array."),z(e.environment,"customEnvironmentUrl",`${n}.environment`,t,!1,r),z(e.background,"imageUrl",`${n}.background`,t,!0,r),e.model.activeVariants!==void 0&&le(e.model.activeVariants,n),e.section!==void 0)try{e.section=ie(e.section)}catch(o){S(`${n}.section`,o.message)}}function Mn(e,n,t,r){T(e,n);for(let[o,i]of Object.entries(e)){let a=`${n}.${o}`;T(i,a),(typeof i.id!="string"||typeof i.modelObjectId!="string")&&S(a,"expected binding id and modelObjectId.");for(let s of["label","group","type","status"])i[s]!==void 0&&typeof i[s]!="string"&&S(a,`${s} must be a string.`);i.tags!==void 0&&le(i.tags,a),i.metadata!==void 0&&T(i.metadata,`${a}.metadata`),i.metrics!==void 0&&(T(i.metrics,a),Object.values(i.metrics).some(s=>typeof s!="number")&&S(a,"metrics must be numbers.")),i.actions!==void 0&&(Array.isArray(i.actions)||S(a,"actions must be an array."),i.actions.forEach(s=>{T(s,a),(typeof s.id!="string"||typeof s.label!="string"||s.type!=="command"||s.effects!==void 0&&!Array.isArray(s.effects))&&S(a,"invalid action.")}));for(let s of["visible","removed","selectable","hoverable"])i[s]!==void 0&&typeof i[s]!="boolean"&&S(a,`${s} must be boolean.`);if(i.transform!==void 0){T(i.transform,a);for(let s of["position","rotation","scale","shear"])i.transform[s]!==void 0&&_(i.transform[s],3,`${a}.transform.${s}`);i.transform.pivot!==void 0&&(T(i.transform.pivot,a),_(i.transform.pivot.point,3,a),_(i.transform.pivot.offset,3,a))}if(i.style!==void 0&&(T(i.style,a),i.style.material!==void 0)){T(i.style.material,a);for(let[s,c]of Object.entries(i.style.material))c&&typeof c=="object"&&!Array.isArray(c)&&"path"in c&&z(c,"path",`${a}.style.material.${s}.path`,t,!0,r)}i.decals!==void 0&&(Array.isArray(i.decals)||S(a,"decals must be an array."),i.decals.forEach(s=>{T(s,a),(typeof s.id!="string"||typeof s.size!="number"||s.size<=0)&&S(a,"invalid decal."),_(s.position,3,a),_(s.normal,3,a),z(s,"image",a,t,!0,r)}))}}function wn(e,n,t,r){Array.isArray(e)||S(n,"expected merge sources."),e.forEach(o=>{T(o,n),(typeof o.url!="string"||!o.url||typeof o.namePrefix!="string")&&S(n,"expected source URL and prefix."),z(o,"url",n,t,!1,r)})}function kt(e,n,t){T(e,"configuration");let r=Object.fromEntries(vt.filter(o=>e[o]!==void 0).map(o=>[o,e[o]]));(typeof r.modelUrl!="string"||!r.modelUrl)&&S("configuration.modelUrl","expected the active model URL.");for(let o of["modelUrl","tilesetUrl","usdzUrl"])z(r,o,`configuration.${o}`,n,!1,t);if(r.sceneConfig!==void 0&&xn(r.sceneConfig,"configuration.sceneConfig",n,t),r.mergeModels!==void 0&&wn(r.mergeModels,"configuration.mergeModels",n,t),r.models!==void 0){(!Array.isArray(r.models)||r.models.length===0)&&S("configuration.models","expected model entries.");let o=new Set,i=new Set;r.models.forEach(a=>{T(a,"model"),(typeof a.url!="string"||!a.url)&&S("model.url","expected a URL."),z(a,"url","model.url",n,!1,t),a.id!==void 0&&(typeof a.id!="string"||!a.id.trim())&&S("model.id","expected a nonempty instance ID.");let s=Re({id:a.id,url:a.url});i.has(s)&&S("configuration.models","instance identities must be unique; assign IDs when reusing a URL."),i.add(s),a.transform!==void 0&&(a.transform=se(a.transform)),a.visible!==void 0&&typeof a.visible!="boolean"&&S("model.visible","expected boolean."),o.add(a.url),Mn(a.objectBindings,"model.objectBindings",n,t),a.sceneConfig!==void 0&&xn(a.sceneConfig,"model.sceneConfig",n,t),a.mergeModels!==void 0&&wn(a.mergeModels,"model.mergeModels",n,t)}),r.activeModelId!==void 0&&(typeof r.activeModelId!="string"||!i.has(r.activeModelId))&&S("configuration.activeModelId","active instance is not in models."),r.activeModelId!==void 0&&r.models.find(a=>Re(a)===r.activeModelId)?.url!==r.modelUrl&&S("configuration.modelUrl","source does not match the active instance."),o.has(r.modelUrl)||S("configuration.modelUrl","active model is not in models.")}if(r.multiSelectedKeys!==void 0&&le(r.multiSelectedKeys,"configuration.multiSelectedKeys"),r.annotationCategories!==void 0&&r.annotationCategories!==null&&le(r.annotationCategories,"configuration.annotationCategories"),r.activeAnnotation!==void 0&&r.activeAnnotation!==null&&On(r.activeAnnotation,"configuration.activeAnnotation",n,t),r.measurements!==void 0||r.measurementSettings!==void 0){let o=ae({items:r.measurements??[],settings:r.measurementSettings??{}});r.measurements!==void 0&&(r.measurements=o.items),r.measurementSettings!==void 0&&(r.measurementSettings=o.settings)}r.measurementModelId!==void 0&&typeof r.measurementModelId!="string"&&S("configuration.measurementModelId","expected a stable id."),r.measurementUnit!==void 0&&typeof r.measurementUnit!="string"&&S("configuration.measurementUnit","expected a unit label.");for(let o of["backgroundColor"])r[o]!==void 0&&typeof r[o]!="string"&&S(o,"expected a string.");r.shadows!==void 0&&typeof r.shadows!="boolean"&&S("shadows","expected boolean.");for(let[o,i]of Object.entries({modelFormat:["glb","gltf","obj","fbx","usdz","stl","ply"],cameraControllerType:["orbit","pointerLock"],objectTransformSpace:["world","local"],arScaleMode:["normalized","real-world"]}))r[o]!==void 0&&!i.includes(r[o])&&S(o,"unsupported value.");if(r.cinematic!==void 0&&An(r.cinematic,"cinematic"),r.isolation!==void 0&&r.isolation!==null){let{target:o,mode:i,ghostOpacity:a}=r.isolation;typeof o=="string"||Array.isArray(o)&&o.every(s=>typeof s=="string")||o&&typeof o=="object"&&["group","tag","type"].some(s=>typeof o[s]=="string")||S("configuration.isolation","invalid target."),i!==void 0&&!["ghost","hide"].includes(i)&&S("configuration.isolation","invalid mode."),a!==void 0&&(typeof a!="number"||a<0||a>1)&&S("configuration.isolation","opacity must be between 0 and 1.")}return r}function jn(e,n,t,r){if(!(!e||typeof e!="object"))for(let[o,i]of Object.entries(e))o!=="metadata"&&(typeof i=="string"&&["url","modelUrl","tilesetUrl","usdzUrl","path","image","src","href","imageUrl","customEnvironmentUrl"].includes(o)?z(e,o,`${n}.${o}`,t,["path","image","src","imageUrl"].includes(o),r):jn(i,`${n}.${o}`,t,r))}function Cn(e,n,t){typeof e=="string"&&(new TextEncoder().encode(e).length>X&&S("state","exceeds the 5 MiB limit."),e=JSON.parse(e));let r=It(e);T(r,"state"),new TextEncoder().encode(JSON.stringify(r)).length>X&&S("state","exceeds the 5 MiB limit."),r.version!==void 0&&r.version!==1&&S("version","unsupported version."),r.version===void 0&&(r.objectBindings!==void 0||r.configuration!==void 0)&&S("version","full configurations require version 1.");let o={};return r.version!==void 0&&(o.version=1),r.camera!==void 0&&(Tt(r.camera,"camera"),o.camera=r.camera),r.hidden!==void 0&&(le(r.hidden,"hidden"),o.hidden=r.hidden),r.selected!==void 0&&(r.selected!==null&&typeof r.selected!="string"&&S("selected","expected an object id or null."),o.selected=r.selected),r.objectBindings!==void 0&&(Mn(r.objectBindings,"objectBindings",n,t),o.objectBindings=r.objectBindings),r.configuration!==void 0&&(o.configuration=kt(r.configuration,n,t)),jn(o,"state",n,t),new TextEncoder().encode(JSON.stringify(o)).length>X&&S("state","exceeds the 5 MiB limit."),o}function po(e,n){return JSON.stringify(Oe(e,n))}function Oe(e,n){return Cn(e,n)}async function vn(e,n){let t=new Map,r=Cn(e,n,t),o=new Map,i=new Map;for(let[s,{source:c,path:l}]of t){let f=o.get(c);f||(f=(async()=>{let m;try{m=await fetch(c)}catch{S(l,"this temporary image is no longer available. Reload or reselect it before saving.")}m.ok||S(l,"could not read the temporary image. Reload or reselect it before saving.");let d=await m.blob();d.size>X*3/4&&S(l,"embedded image exceeds the 5 MiB configuration limit. Use a hosted image URL.");let u=new Uint8Array(await d.arrayBuffer()),g=d.type.split(";")[0].toLowerCase(),h=g.startsWith("image/")?g:Bt(u);h||S(l,"temporary asset is not a supported image. Use a hosted asset URL.");let p="";for(let b=0;b<u.length;b+=32768)p+=String.fromCharCode(...u.subarray(b,b+32768));return`data:${h};base64,${btoa(p)}`})(),o.set(c,f)),i.set(s,await f)}function a(s){if(!(!s||typeof s!="object"))for(let[c,l]of Object.entries(s))c!=="metadata"&&(["path","image","src","imageUrl"].includes(c)&&typeof l=="string"&&i.has(l)?s[c]=i.get(l):a(l))}return a(r),Oe(r,n)}function Bt(e){let n=(t,r)=>String.fromCharCode(...e.subarray(t,r));if(e[0]===137&&n(1,4)==="PNG")return"image/png";if(e[0]===255&&e[1]===216&&e[2]===255)return"image/jpeg";if(n(0,3)==="GIF")return"image/gif";if(n(0,4)==="RIFF"&&n(8,12)==="WEBP")return"image/webp";if(n(4,8)==="ftyp"&&["avif","avis"].includes(n(8,12)))return"image/avif";if(/<svg[\s>]/i.test(new TextDecoder().decode(e.subarray(0,1024))))return"image/svg+xml"}import{strFromU8 as Et,strToU8 as In,unzlibSync as Rt,zlibSync as Nt}from"fflate";var Ae="ri-ar",Me="ri-ar-id",Tn=4096,Pt=2200,Vt=In(JSON.stringify(ne)).byteLength;function kn(e){return e==="localhost"||e.endsWith(".localhost")||/^127\./.test(e)||e==="[::1]"||e==="0.0.0.0"}function Bn(e){if(typeof e=="string"&&/^https?:\/\//i.test(e)&&kn(new URL(e).hostname))throw new Error("An asset URL points to this computer. Use model and texture URLs reachable from the phone.");if(e&&typeof e=="object")for(let n of Object.values(e))Bn(n)}function wo(e){return e&&typeof e=="object"?e:void 0}function Oo(e){let n=new URLSearchParams(new URL(e,"https://viewer.invalid/").hash.slice(1));return n.has(Ae)||n.has(Me)}function Lt(e,n){let t=new URL(e,n);if(!["https:","http:"].includes(t.protocol))throw new Error("AR handoff requires an HTTP(S) URL.");return t.toString()}function Ao(e,n="",t=2048){let r=new Set,o=i=>{if(typeof i=="string")return we(i)??i;if(i===null||typeof i!="object")return i;if(r.has(i))throw new Error("AR configuration cannot contain cycles.");r.add(i);let a=Array.isArray(i)?i.map(o):Object.fromEntries(Object.keys(i).sort().map(s=>[s,o(i[s])]));return r.delete(i),a};return JSON.stringify([n,t,o({...e,camera:void 0})])}function En(e,n){if(JSON.stringify(e)!==JSON.stringify(n))return e&&n&&typeof e=="object"&&typeof n=="object"&&!Array.isArray(e)&&!Array.isArray(n)?Object.fromEntries(Object.entries(e).map(([t,r])=>[t,En(r,n[t])]).filter(([,t])=>t!==void 0)):e}function Rn(e,n,t=0){if(t>64)throw new Error("AR configuration is too deeply nested.");if(e&&n&&typeof e=="object"&&typeof n=="object"&&!Array.isArray(e)&&!Array.isArray(n)){let r=e,o=n;return Object.fromEntries([...new Set([...Object.keys(o),...Object.keys(r)])].map(i=>[i,Object.prototype.hasOwnProperty.call(r,i)?Rn(r[i],o[i],t+1):o[i]]))}return e}function Nn(e,n){let t=structuredClone(e);if(t.configuration){t.configuration.sceneConfig&&(t.configuration.sceneConfig=n(t.configuration.sceneConfig));for(let r of t.configuration.models??[])r.sceneConfig&&(r.sceneConfig=n(r.sceneConfig))}return t}function de(e){e?.throwIfAborted()}async function Mo(e,n,t,r){de(r);let o=new URL(Lt(n));if(kn(o.hostname))throw new Error("Phone links need a viewer URL reachable from your phone. Download the USDZ for local uploads, or provide a public viewer URL.");let i=await vn(e,o.toString());de(r),Bn(i);let a=new URLSearchParams(o.hash.slice(1));if(a.delete(Ae),a.delete(Me),a.delete("view"),a.delete("viewId"),a.delete("view-id"),t){let s=await t.save(i);if(de(r),typeof s!="string"||!s||s.length>512)throw new Error("AR storage returned an invalid configuration ID.");a.set(Me,s)}else{let s=Nt(In(JSON.stringify({ar:1,state:Nn(i,l=>En(l,ne)??{})})),{level:9});if(s.byteLength>Tn)throw new Error("This configuration needs an AR storage adapter to share on a phone. The USDZ download is still available.");let c="";for(let l of s)c+=String.fromCharCode(l);a.set(Ae,btoa(c).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""))}if(o.hash=a.toString(),o.toString().length>Pt)throw new Error("This configuration is too large for a reliable QR code. Use an AR storage adapter or download the USDZ.");return o.toString()}async function jo(e,n,t){let r=new URL(e),o=new URLSearchParams(r.hash.slice(1)),i=o.get(Me),a=o.get(Ae);if(i!==null&&a!==null)throw new Error("AR link contains conflicting configurations.");if(i===null&&a===null)return null;de(t);let s;if(i!==null){if(!n)throw new Error("This AR link requires the application's configuration storage adapter.");if(!i||i.length>512)throw new Error("Invalid AR configuration ID.");s=await n.load(i)}else{if(!a||a.length>Math.ceil(Tn*4/3)||!/^[\w-]+$/.test(a))throw new Error("Invalid or oversized AR link.");let l=atob(a.replace(/-/g,"+").replace(/_/g,"/")),f=Uint8Array.from(l,u=>u.charCodeAt(0)),m=Rt(f);if(m.byteLength>X)throw new Error("AR configuration exceeds the 5 MiB limit.");let d=JSON.parse(Et(m));if(d?.ar===1&&d.state){let u=d.state.configuration,g=(u?.sceneConfig?1:0)+(Array.isArray(u?.models)?u.models.filter(h=>h?.sceneConfig).length:0);if(m.byteLength+g*Vt>X)throw new Error("Expanded AR configuration exceeds the 5 MiB limit.");s=Nn(d.state,h=>Rn(h,ne))}else s=d}de(t);let c=Oe(s,r.toString());if(c.version!==1||!c.configuration)throw new Error("AR handoff requires a complete versioned viewer configuration.");return c}var Ge=new WeakMap;function vo(e,n){n?Ge.set(e,n):Ge.delete(e)}function Pn(e){e.traverse(n=>{let t=Ge.get(n);if(t)throw new Error(t)})}import{Box3 as zt,BufferAttribute as Vn,BufferGeometry as Ln,Color as Ut,DoubleSide as Dt,FrontSide as He,Group as _n,Matrix4 as $t,Mesh as Ft,Vector3 as je}from"three";import{PropertyBinding as qe}from"three";var We=Symbol("react-immersive.model-node-id");function _t(e,n){Object.defineProperty(e,We,{value:n,configurable:!0})}function ue(e){let n=new Map;e.traverse(c=>{if(!c.name)return;let l=n.get(c.name);l?l.push(c):n.set(c.name,[c])});let t=Object.create(null),r=new WeakMap,o=new Map,i=new Set(Array.from(n,([c,l])=>l.length===1?c:null).filter(c=>c!==null)),a=new Set,s=(c,l)=>{_t(c,l),t[l]=c,r.set(c,l),a.add(l)};for(let[c,l]of n)l.length===1&&s(l[0],c);for(let[c,l]of n){if(l.length<2)continue;let f=[];l.forEach((m,d)=>{let u=`${c} [${d+1}]`,g=u,h=2;for(;i.has(g)||a.has(g);)g=`${u}.${h++}`;s(m,g),f.push(g)}),o.set(c,f)}return{nodesById:t,idByNode:r,duplicateNames:o}}function me(e){return e[We]??e.name??null}function ko(e,n){let t=n.replace(/\.[^./\\]+$/,"");e.traverse(r=>{r.name&&(r.name=qe.sanitizeNodeName(`${t}_${r.name}`))})}function Bo(e,n){let t=n.replace(/\.[^./\\]+$/,""),r=e.clone();for(let o of r.tracks){let a=qe.parseTrackName(o.name).nodeName??"",s=qe.sanitizeNodeName(`${t}_${a}`);o.name=s+o.name.slice(a.length)}return r}function Eo(e,n){let t=null,r=[];return e.traverse(o=>{o[We]===n&&(t=o),o.name===n&&r.push(o)}),t??(r.length===1?r[0]:null)}function Gt(e,n={}){n.signal?.throwIfAborted();let t=new _n,r=new _n;t.add(r);let o=new Set,i=[],a=[],s=[],c=new Map,l=0,f=0,m=()=>{i.forEach(d=>d.dispose()),a.forEach(d=>d.dispose()),s.forEach(d=>d.dispose())};try{for(let{scene:p,objectBindings:b={},materialOverrides:y={}}of e){Pn(p),p.updateWorldMatrix(!0,!0);let w=new Map(Object.entries(b).map(([O,x])=>[x.modelObjectId??O,O]));p.traverse(O=>{let x=O;if(!x.isMesh||!x.geometry)return;for(let P=O;P;P=P.parent){let F=me(P)??P.name??P.uuid;if(!P.visible||b[w.get(F)??F]?.visible===!1||b[w.get(F)??F]?.removed)return}let A=me(x)??x.name??x.uuid,E=y[w.get(A)??A]??x.material;if(!E)throw new Error(`Material for ${A} is not ready. Wait for the model to finish loading.`);let R=Array.isArray(E)?E:[E],re=x.isInstancedMesh?x.count:1;if(x.userData.riDecal&&pe(x)&&x.parent){let P=Je(x.parent);P&&x.bindMatrixInverse.copy(P)}let k=pe(x)?Ze(x):x.geometry.clone();try{if(!pe(x)&&x.morphTargetInfluences?.some(U=>U!==0)){let U=k.getAttribute("position"),$=new je;for(let V=0;V<U.count;V++)x.getVertexPosition(V,$),U.setXYZ(V,$.x,$.y,$.z);k.morphAttributes={},k.computeVertexNormals()}if(!k.getAttribute("position"))throw new Error(`Mesh ${A} has no positions.`);let P=k.index?.count??k.getAttribute("position").count,F=Array.isArray(E)?k.groups:[{start:0,count:P,materialIndex:0}];if(!F.length)throw new Error(`Mesh ${A} has multiple materials without geometry groups.`);for(let U=0;U<re;U++){let $=x.matrixWorld.clone();if(x.isInstancedMesh){let V=new $t;x.getMatrixAt(U,V),$.multiply(V)}for(let V of F){let fe=R[V.materialIndex??0];if(!fe)throw new Error(`A material group on ${A} is missing its material.`);if(!fe.visible)continue;let G=fe;if(!G.isMeshStandardMaterial||G.wireframe||G.vertexColors)throw new Error(`AR snapshot cannot preserve ${fe.type}${G.wireframe?" wireframe":G.vertexColors?" vertex colors":""} on ${A}. Use a PBR material or provide arHandoff.createUSDZ.`);let Q=Math.max(V.start,k.drawRange.start),Ie=Math.min(P,V.start+V.count,k.drawRange.start+k.drawRange.count);if(Ie<=Q)continue;if(Q%3||(Ie-Q)%3)throw new Error(`Mesh ${A} has an incomplete triangle range.`);let B=new Ln;i.push(B);let D=Array.from({length:Ie-Q},(M,C)=>k.index?k.index.getX(Q+C):Q+C);if($.determinant()<0)for(let M=0;M<D.length;M+=3)[D[M+1],D[M+2]]=[D[M+2],D[M+1]];for(let[M,C]of Object.entries(k.attributes)){let j=new Float32Array(D.length*C.itemSize);for(let v=0;v<D.length;v++)for(let L=0;L<C.itemSize;L++)j[v*C.itemSize+L]=C.getComponent(D[v],L);B.setAttribute(M,new Vn(j,C.itemSize))}B.setIndex(D.map((M,C)=>C)),B.applyMatrix4($);let ge=B.getAttribute("position");for(let M=0;M<ge.count;M++)if(![ge.getX(M),ge.getY(M),ge.getZ(M)].every(Number.isFinite))throw new Error(`Mesh ${A} contains invalid coordinates.`);B.getAttribute("normal")||B.computeVertexNormals();let N=G.clone();a.push(N);let Ye=G.userData.reactImmersiveConfiguredEmissive;if(Ye?.isColor&&N.emissive.copy(Ye),N.side===Dt){let M=B.toNonIndexed();i.push(M);let C=M.getAttribute("position").count,j=new Ln;i.push(j);for(let[v,L]of Object.entries(M.attributes)){let Te=new Float32Array(C*L.itemSize*2);for(let q=0;q<C;q++)for(let ee=0;ee<L.itemSize;ee++){Te[q*L.itemSize+ee]=L.getComponent(q,ee);let Yn=Math.floor(q/3)*3+(2-q%3);Te[(C+q)*L.itemSize+ee]=L.getComponent(Yn,ee)*(v==="normal"?-1:1)}j.setAttribute(v,new Vn(Te,L.itemSize))}N.side=He,B.copy(j)}else if(N.side!==He){let M=B.getIndex();for(let j=0;j<M.count;j+=3){let v=M.getX(j+1);M.setX(j+1,M.getX(j+2)),M.setX(j+2,v)}let C=B.getAttribute("normal");for(let j=0;j<C.count;j++)C.setXYZ(j,-C.getX(j),-C.getY(j),-C.getZ(j));N.side=He}if(x.isInstancedMesh&&x.instanceColor){let M=new Ut;x.getColorAt(U,M),N.color.multiply(M)}for(let[M,C]of Object.entries(N)){if(!C?.isTexture)continue;let j=C;if(Sn(j)||!j.image||j.image.complete===!1)throw new Error(`Texture on ${A} is not ready. Wait for image loading or replace failed textures before preparing AR.`);let v=c.get(j);if(v||(v=j.clone(),c.set(j,v),s.push(v)),N[M]=v,!B.getAttribute(v.channel?`uv${v.channel}`:"uv"))throw new Error(`Texture on ${A} needs UV coordinates missing from this geometry.`)}if(x.userData.riDecal){B.computeBoundingBox();let M=Math.max(1e-6,B.boundingBox.getSize(new je).length()*1e-4),C=B.getAttribute("position"),j=B.getAttribute("normal");for(let v=0;v<C.count;v++)C.setXYZ(v,C.getX(v)+j.getX(v)*M,C.getY(v)+j.getY(v)*M,C.getZ(v)+j.getZ(v)*M)}let Xe=new Ft(B,N);Xe.name=`AR_${l++}`,r.add(Xe),f+=(B.index?.count??B.getAttribute("position").count)/3,(N.clearcoat||N.transmission||N.iridescence||N.anisotropy)&&o.add("Advanced PBR effects may look different in Quick Look.")}}}finally{k.dispose()}})}if(!l||!f)throw new Error("There is no visible model geometry to send to AR.");let d=new zt().setFromObject(r),u=d.getSize(new je),g=d.getCenter(new je),h=n.scaleMode==="real-world"?1:1/Math.max(u.x,u.y,u.z,1e-9);return r.position.set(-g.x*h,-d.min.y*h,-g.z*h),r.scale.setScalar(h),t.updateMatrixWorld(!0),o.add("USDZ is a static snapshot. Viewer lighting, background, post-processing, annotations and measurement overlays stay in the web viewer."),{root:t,meshCount:l,triangleCount:f,scale:h,warnings:[...o],textures:s,dispose:m}}catch(d){throw m(),d}}async function $o(e,n={}){let t=n.maxTextureSize??2048;if(!Number.isInteger(t)||t<256||t>4096)throw new Error("AR maxTextureSize must be an integer from 256 to 4096.");let r=Gt(e,n),o=[];try{let{USDZExporter:i}=await import("three/examples/jsm/exporters/USDZExporter.js");n.signal?.throwIfAborted();for(let s of r.textures){if(!s.isCompressedTexture)continue;let{decompress:c}=await import("three/examples/jsm/utils/WebGLTextureUtils.js"),l=c(s,t);o.push(l),r.root.traverse(f=>{let m=f.material;if(m)for(let d of Object.keys(m))m[d]===s&&(m[d]=l)})}let a=await new i().parseAsync(r.root,{onlyVisible:!0,quickLookCompatible:!0,maxTextureSize:t});return n.signal?.throwIfAborted(),{blob:new Blob([new Uint8Array(a)],{type:"model/vnd.usdz+zip"}),meshCount:r.meshCount,triangleCount:r.triangleCount,scale:r.scale,warnings:r.warnings}}catch(i){throw n.signal?.aborted?i:new Error(`Could not prepare the configured USDZ: ${i instanceof Error?i.message:"export failed"}. Textures must allow cross-origin canvas access.`)}finally{r.dispose(),o.forEach(i=>i.dispose())}}var Ce=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."}]),Go="__custom__";function qt(e){return Ce.find(n=>n.id===e)}var Un=Ce.filter(e=>e.handling==="viewer").map(e=>e.id),Wt=new Set(["","New Action",...Ce.map(e=>e.label)]);function qo(e){return Wt.has(e.trim())}function zn(e,n){let t=Array.from({length:n.length+1},(r,o)=>o);for(let r=1;r<=e.length;r+=1){let o=[r];for(let i=1;i<=n.length;i+=1){let a=t[i-1]+(e[r-1]===n[i-1]?0:1);o[i]=Math.min(o[i-1]+1,t[i]+1,a)}t=o}return t[n.length]}function Wo(e){if(qt(e))return null;let n=e.trim().toLowerCase();if(!n)return null;let t=n.replace(/[^a-z0-9]/g,""),r=null;for(let o of Ce){let i=Math.min(zn(n,o.id),zn(t,o.id.replace(/[^a-z0-9]/g,"")));(!r||i<r.distance)&&(r={id:o.id,distance:i})}return r&&r.distance<=2?r.id:null}function Dn(e,n){if(e[n])return n;let t=Object.entries(e).find(([,o])=>o.id===n)?.[0];return t||(Object.entries(e).find(([,o])=>o.modelObjectId===n)?.[0]??null)}function Ht(e){return typeof e=="object"&&!Array.isArray(e)}function Kt(e,n){return"group"in n?e.group===n.group:"tag"in n?e.tags?.includes(n.tag)??!1:(e.type??"other")===n.type}function J(e,n){if(Ht(n))return Object.entries(e).filter(([,o])=>Kt(o,n)).map(([o])=>o);let r=(typeof n=="string"?[n]:n).map(o=>Dn(e,o)).filter(o=>o!==null);return[...new Set(r)]}function Xo(e,n){return J(e,n).map(t=>e[t]).filter(t=>t!==void 0)}var Yt="#ff3b30",Xt=Object.freeze({}),$n=e=>e;function Jt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Zt(e,n){let t=e.metadata;for(let r of n.split(".")){if(!Jt(t))return;t=t[r]}return t}function Qt(e,n){if("metric"in n){let t=e.metrics?.[n.metric];return!(typeof t!="number"||!Number.isFinite(t)||n.above!==void 0&&!(t>n.above)||n.below!==void 0&&!(t<n.below))}if("status"in n){let t=e.status??"normal";return Array.isArray(n.status)?n.status.includes(t):n.status===t}return Zt(e,n.metadata)===n.equals}function er(e){let n=e.trim().replace(/^#/,""),t=n.length===3?n.split("").map(r=>r+r).join(""):n;return/^[0-9a-f]{6}$/i.test(t)?[0,2,4].map(r=>parseInt(t.slice(r,r+2),16)):null}var Ke=e=>`#${e.map(n=>Math.round(n).toString(16).padStart(2,"0")).join("")}`;function nr(e,n){let t=e.map(([c,l])=>({at:c,rgb:er(l)})).filter(c=>Number.isFinite(c.at)&&c.rgb!==null).sort((c,l)=>c.at-l.at);if(t.length===0||!Number.isFinite(n))return null;if(n<=t[0].at)return Ke(t[0].rgb);let r=t[t.length-1];if(n>=r.at)return Ke(r.rgb);let o=t.findIndex(c=>c.at>=n),i=t[o-1],a=t[o],s=a.at===i.at?1:(n-i.at)/(a.at-i.at);return Ke(i.rgb.map((c,l)=>c+(a.rgb[l]-c)*s))}function Qo(e,n){if(!n?.length)return{bindings:e,pulses:Xt,sourceOf:$n};let t=new Map,r={};for(let a of n){let s=a.target?J(e,a.target):Object.keys(e),c=a.when?Array.isArray(a.when)?a.when:[a.when]:[];for(let l of s){let f=e[l];if(!c.every(d=>Qt(f,d)))continue;let m={...a.material};if(a.colorScale){let d=f.metrics?.[a.colorScale.metric],u=typeof d=="number"?nr(a.colorScale.stops,d):null;u&&(m={...m,[a.colorScale.channel??"baseColor"]:u})}if(a.pulse){let d=a.pulse===!0?{}:a.pulse;r[l]={color:d.color??Yt,speed:d.speed!==void 0&&d.speed>0?d.speed:1};let u=m.emissiveIntensity??t.get(l)?.emissiveIntensity??f.style?.material?.emissiveIntensity;u!==void 0&&u>0||(m.emissiveIntensity=1)}Object.keys(m).length>0&&t.set(l,{...t.get(l),...m})}}if(t.size===0)return{bindings:e,pulses:r,sourceOf:$n};let o={...e},i=new WeakMap;for(let[a,s]of t){let c=e[a],l={...c,style:{...c.style,material:{...c.style?.material,...s}}};o[a]=l,i.set(l,c)}return{bindings:o,pulses:r,sourceOf:a=>i.get(a)??a}}var tr=.12,Fn=new Set;function rr(e,n){return n?new Set(J(e,n.target)):Fn}function ti(e,n){let t=rr(e.bindings,n);if(!n||t.size===0)return{...e,setAside:Fn};let r=Math.min(Math.max(n.ghostOpacity??tr,0),1),o={...e.bindings},i=new WeakMap,a=new Set;for(let[s,c]of Object.entries(e.bindings)){if(t.has(s))continue;a.add(s);let l=n.mode==="hide"?{...c,visible:!1}:{...c,style:{...c.style,material:{...c.style?.material,opacity:Math.min(c.style?.material?.opacity??1,r)}}};o[s]=l,i.set(l,e.sourceOf(c))}return{bindings:o,pulses:e.pulses,sourceOf:s=>i.get(s)??e.sourceOf(s),setAside:a}}function or(e){return e.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 ir(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,n=>n.toUpperCase())}function sr(e){let n=e.toLowerCase();return n.includes("light")?"light":n.includes("wheel")||n.includes("rim")||n.includes("tire")?"wheel":n.includes("glass")||n.includes("window")||n.includes("windshield")||n.includes("sunroof")?"glass":n.includes("seat")||n.includes("dashboard")||n.includes("console")||n.includes("doorpanel")?"interior":n.includes("floor")?"floor":n.includes("wall")?"wall":n.includes("door")?"door":n.includes("chair")||n.includes("table")||n.includes("sofa")||n.includes("bed")?"furniture":"other"}function Gn(e,n=!0){return e==="light"||e.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"},...n?[{id:"change-material",label:"Change Material",type:"command"}]:[],{id:"toggle-visibility",label:"Toggle Visibility",type:"command"}]}function qn(e,n=!0){let t=sr(e);return{id:or(e),modelObjectId:e,type:t,label:ir(e),status:"normal",selectable:!0,hoverable:!0,visible:!0,style:{},actions:Gn(t,n),metrics:{},metadata:{}}}function ai(e,n){return Object.fromEntries(e.map(t=>[t,qn(t,!n?.has(t))]))}function ci(e,n){let t=new Set,r={};for(let o of e){let i=qn(o,!n?.has(o)),a=i.id||"object",s=a;for(let l=2;t.has(s);l++)s=`${a}-${l}`;t.add(s),i.id=s;let c=(i.actions??[]).filter(l=>Un.includes(l.id));i.actions=c.length>0?c:Gn("other",!n?.has(o)),r[o]=i}return r}function li(e){let n=new Set;for(let[t,r]of Object.entries(ue(e).nodesById))Qe(r)||n.add(t);return n}function di(e){let{nodesById:n}=ue(e),t=[];for(let[r,o]of Object.entries(n)){let i=o;i.isMesh&&i.geometry&&o.name&&t.push(r)}return t.sort((r,o)=>r.localeCompare(o))}var Kn={id:"identity",modelObjectId:"identity",label:"identity",type:"identity",group:"identity",tags:"identity",style:"appearance",decals:"appearance",transform:"transform",visible:"visibility",removed:"visibility",status:"visibility",selectable:"behavior",hoverable:"behavior",actions:"behavior",cameraState:"behavior",metadata:"data",metrics:"data"},ar=Object.keys(Kn),cr=new Set(["__proto__","prototype","constructor"]);function Z(e,n=new Set){if(e==null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number"){if(!Number.isFinite(e))throw new Error("Comparison values must be finite JSON data");return e}if(typeof e!="object"||n.has(e))throw new Error("Comparison values must be acyclic JSON data");n.add(e);let t=Array.isArray(e)?e.map(r=>Z(r,n)):Object.fromEntries(Object.entries(e).filter(([r,o])=>!cr.has(r)&&o!==void 0).map(([r,o])=>[r,Z(o,n)]));return n.delete(e),t}var Wn=e=>e&&typeof e=="object"&&!Array.isArray(e)&&!Object.keys(e).length;function Hn(e,n){let t=Z(e);t.visible=e.visible??!0,t.selectable=e.selectable??!0,t.hoverable=e.hoverable??!0,t.status=e.status??"normal",t.type=e.type??"other",t.tags=[...new Set(e.tags??[])].sort(),Wn(t.transform)&&delete t.transform,t.metadata=Object.fromEntries(Object.entries(e.metadata??{}).filter(([r])=>!n.includes(r)));for(let r of["metrics","style","metadata"])Wn(t[r])&&delete t[r];for(let r of["actions","decals"])Array.isArray(t[r])&&!t[r].length&&delete t[r];return t}function ve(e,n,t,r,o,i){if(Object.is(e,n)||typeof e=="number"&&typeof n=="number"&&Math.abs(e-n)<=o)return;let a=s=>!!s&&typeof s=="object"&&!Array.isArray(s);if(a(e)&&a(n)){for(let s of[...new Set([...Object.keys(e),...Object.keys(n)])].sort())ve(e[s],n[s],`${t}.${s}`,r,o,i);return}if(Array.isArray(e)&&Array.isArray(n)&&e.length===n.length){for(let s=0;s<e.length;s++)ve(e[s],n[s],`${t}[${s}]`,r,o,i);return}i.push({path:t,category:r,...e!==void 0?{before:Z(e)}:{},...n!==void 0?{after:Z(n)}:{}})}function mi(e,n,t={}){let r=t.tolerance??1e-6;if(!Number.isFinite(r)||r<0)throw new Error("Comparison tolerance must be finite and nonnegative");let o=Object.entries(e.objectBindings).filter(([,b])=>!b.removed),i=Object.entries(n.objectBindings).filter(([,b])=>!b.removed),a=new Map(o),s=new Map(i),c=new Set,l=new Set,f=[],m=b=>{let y=t.matchBy??"modelObjectId",w=typeof y=="object"?b.metadata?.[y.metadataKey]:b[y];return typeof w=="string"&&w.length>0||typeof w=="number"?`${typeof w}:${w}`:null};function d(b,y,w){let O=b===void 0?void 0:a.get(b),x=y===void 0?void 0:s.get(y),A=[];if(O||x){let R=O?Hn(O,t.ignoreMetadataKeys??[]):{},re=x?Hn(x,t.ignoreMetadataKeys??[]):{};for(let k of ar)ve(R[k],re[k],k,Kn[k],r,A)}let E=O?x?A.length?"modified":"unchanged":"removed":"added";f.push({id:JSON.stringify([b??null,y??null]),identity:w,label:x?.label??O?.label??x?.modelObjectId??O?.modelObjectId??w,status:E,beforeKey:b,afterKey:y,beforeObjectId:O?.modelObjectId,afterObjectId:x?.modelObjectId,changes:A}),b!==void 0&&c.add(b),y!==void 0&&l.add(y)}let u=new Set;for(let[b,y]of Object.entries(t.mapping??{})){if(!a.has(b)||!s.has(y)||u.has(y))throw new Error("Comparison mapping must reference existing, unique binding keys");u.add(y),d(b,y,`mapped:${b}`)}let g=new Map;for(let[b,y,w]of[[o,c,"a"],[i,l,"b"]])for(let[O,x]of b){if(y.has(O))continue;let A=m(x);if(A===null){f.push({id:JSON.stringify([w,O]),identity:"",label:x.label??x.modelObjectId,status:"ambiguous",...w==="a"?{beforeKey:O,beforeObjectId:x.modelObjectId}:{afterKey:O,afterObjectId:x.modelObjectId},changes:[],message:"Missing match identity. Supply an explicit mapping or another match field."});continue}let E=g.get(A)??{a:[],b:[]};E[w].push(O),g.set(A,E)}for(let[b,y]of g){if(y.a.length<=1&&y.b.length<=1){d(y.a[0],y.b[0],b);continue}for(let w of["a","b"])for(let O of y[w]){let x=(w==="a"?a:s).get(O);f.push({id:JSON.stringify([w,O]),identity:b,label:x.label??x.modelObjectId,status:"ambiguous",...w==="a"?{beforeKey:O,beforeObjectId:x.modelObjectId}:{afterKey:O,afterObjectId:x.modelObjectId},changes:[],message:"Duplicate match identity. Supply an explicit one-to-one mapping."})}}f.sort((b,y)=>b.label.localeCompare(y.label)||b.id.localeCompare(y.id));let h=[];ve(Z(e.sceneConfig??{}),Z(n.sceneConfig??{}),"sceneConfig","scene",r,h);let p={added:0,removed:0,modified:0,unchanged:0,ambiguous:0};for(let b of f)p[b.status]++;return{version:1,objects:f,counts:p,sceneChanges:h}}function fi(e,n,t){let r={added:"#22c55e",removed:"#f87171",modified:"#fbbf24",unchanged:"#94a3b8",ambiguous:"#c084fc"};return e.objects.flatMap(o=>{let i=n==="before"?o.beforeObjectId:o.afterObjectId;return i&&(o.status!=="unchanged"||o.id===t)?[{objectId:i,color:o.id===t?"#22d3ee":r[o.status]}]:[]})}var pi=["front","back","double"],bi=["normal","additive"];function Si(e){ue(e);let n=[],t=[{node:e,path:"0",parentId:null}];for(;t.length;){let{node:o,path:i,parentId:a}=t.pop(),s=`node:${i}`,c=o.isMesh&&o.name?me(o):null;n.push({id:s,parentId:a,name:o.name||o.type||"Group",...c?{objectId:c}:{}});for(let l=o.children.length-1;l>=0;l--)t.push({node:o.children[l],path:`${i}/${l}`,parentId:s})}let r=new Set;for(let o=n.length-1;o>=0;o--){let i=n[o];(i.objectId||r.has(i.id))&&(r.add(i.id),i.parentId&&r.add(i.parentId))}return n.filter(o=>r.has(o.id))}function Oi(e){return structuredClone(e.style??{})}function Ai(e,n,t){let r=J(e,n).filter(i=>!e[i].removed);if(!r.length)return e;let o={...e};for(let i of r)o[i]={...e[i],style:structuredClone(t)};return o}export{ue as a,me as b,ko as c,Bo as d,Eo as e,Xn as f,Jn as g,et as h,nt as i,nn as j,dr as k,ur as l,Dn as m,Ue as n,Hr as o,Kr as p,Yr as q,Xr as r,we as s,Jr as t,Zr as u,Ct as v,Qr as w,eo as x,no as y,to as z,ro as A,oo as B,io as C,fr as D,gr as E,pr as F,br as G,yr as H,hr as I,Sr as J,Ee as K,ne as L,ie as M,Or as N,Ar as O,Mr as P,vr as Q,Re as R,se as S,Ir as T,Tr as U,kr as V,Br as W,an as X,cn as Y,ln as Z,Pe as _,Nr as $,Pr as aa,Vr as ba,Lr as ca,St as da,Le as ea,wt as fa,Ur as ga,Dr as ha,fn as ia,Ot as ja,ae as ka,$r as la,Fr as ma,gn as na,X as oa,po as pa,Oe as qa,vn as ra,wo as sa,Oo as ta,Lt as ua,Ao as va,Mo as wa,jo as xa,vo as ya,Pn as za,$o as Aa,Ce as Ba,Go as Ca,qt as Da,Un as Ea,qo as Fa,Wo as Ga,J as Ha,Xo as Ia,Qt as Ja,nr as Ka,Qo as La,rr as Ma,ti as Na,sr as Oa,qn as Pa,ai as Qa,ci as Ra,li as Sa,di as Ta,mi as Ua,fi as Va,pi as Wa,bi as Xa,Si as Ya,Oi as Za,Ai as _a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as w,N as ne,O as se,P as oe,a as Y,e as K,k as q,l as J,m as E,o as Q,p as ee,t as te,u as re}from"./chunk-V7WZUWJ5.mjs";import{createContext as nt,useContext as st,useMemo as ot}from"react";import{jsx as at}from"react/jsx-runtime";var ae=nt(void 0);function Hr({labels:e,children:t}){return at(ae.Provider,{value:e,children:t})}function ie(){let e=st(ae);return ot(()=>Object.assign((t,r)=>q(e,t,r),{message:t=>J(e,t)}),[e])}import{strFromU8 as it,strToU8 as ut,unzip as lt}from"fflate";var ue;function le(e){ue=e}function v(e){ue?.(e)}var ct=[".glb",".gltf",".obj",".fbx",".usdz",".stl",".ply",".zip"],pt=["model/gltf-binary","model/gltf+json","model/vnd.usdz+zip","application/vnd.usdz+zip","application/zip","application/x-zip-compressed"],y=1024*1024,ce=128*y,pe=1024,de=128*y,fe=256*y,me=200,dt=y,b=new Map,Jr=".glb,.gltf,.obj,.fbx,.usdz,.stl,.ply,.zip,model/gltf-binary,model/gltf+json,model/vnd.usdz+zip,application/vnd.usdz+zip,application/zip";function k(e){let t=e.split(/[?#]/,1)[0].toLowerCase();return t.endsWith(".obj")?"obj":t.endsWith(".fbx")?"fbx":t.endsWith(".usdz")?"usdz":t.endsWith(".stl")?"stl":t.endsWith(".ply")?"ply":t.endsWith(".gltf")?"gltf":"glb"}function ve(e){return b.get(e)??{format:k(e)}}function ft(e){let t=e.name.toLowerCase();return ct.some(r=>t.endsWith(r))||pt.includes(e.type)}async function Qr(e){if(!ft(e))throw new Error("Unsupported model file. Please upload a .glb, .gltf, .obj, .fbx, .usdz, .stl, .ply, 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 be(e,"usdz");if(t.endsWith(".zip")||mt(e.type))return bt(e);if(t.endsWith(".gltf")||e.type==="model/gltf+json")return he(e);let r=k(e.name);return r==="gltf"?he(e):be(e,r)}function be(e,t){let r=URL.createObjectURL(e);return b.set(r,{format:t,entryPath:e.name,sourceBytes:e.size}),{url:r,name:e.name,format:t,cleanup:()=>{v(r),b.delete(r),URL.revokeObjectURL(r)}}}function mt(e){return e==="application/zip"||e==="application/x-zip-compressed"}async function he(e){let t=await e.text(),r=ye(t,e.name);for(let s of Me(r))if(!C(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 b.set(n,{format:"gltf",entryPath:e.name,sourceBytes:e.size}),{url:n,name:e.name,format:"gltf",cleanup:()=>{v(n),b.delete(n),URL.revokeObjectURL(n)}}}async function bt(e){if(e.size>ce)throw new Error(`Model zip is too large. The compressed archive must be ${T(ce)} or smaller.`);let t=await ht(new Uint8Array(await e.arrayBuffer())),r=new Map;for(let[a,i]of Object.entries(t)){let u=U(a);!u||we(u)||r.set(u,i)}let n=[...r.keys()].filter(a=>/\.(gltf|obj|fbx|stl|ply)$/i.test(a));if(n.length===0)throw new Error("Invalid model zip: no .gltf, .obj, .fbx, .stl, or .ply file found.");if(n.length>1)throw new Error("Invalid model zip: multiple model entry files found.");let s=n[0],o=k(s);if(o==="gltf")return vt(e,s,r);if(o==="obj"||o==="fbx"||o==="stl"||o==="ply")return gt(e,s,o,r);throw new Error(`Unsupported model entry ${s}.`)}function ht(e){return new Promise((t,r)=>{let n=0,s=0,o=null,a=u=>(o??(o=new Error(`Invalid model zip: ${u}`)),!1);lt(e,{filter:u=>{if(o)return!1;if(n+=1,n>pe)return a(`archive contains more than ${pe.toLocaleString()} entries.`);if(u.originalSize>de)return a(`${u.name} expands beyond the ${T(de)} per-file limit.`);if(s+=u.originalSize,s>fe)return a(`expanded contents exceed ${T(fe)}.`);if(u.originalSize>=dt&&(u.size===0||u.originalSize/u.size>me))return a(`${u.name} exceeds the ${me}:1 compression-ratio limit.`);let l=U(u.name);return!!l&&!we(l)}},(u,l)=>{o?r(o):u?r(new Error(`Invalid model zip: ${u.message}`)):t(l)})})}function T(e){return`${e/y} MiB`}function gt(e,t,r,n){let s=[],o={};for(let[i,u]of n){let l=URL.createObjectURL(new Blob([u],{type:xe(i)}));s.push(l),o[i]=l}let a=o[t];if(!a)throw s.forEach(i=>URL.revokeObjectURL(i)),new Error(`Invalid model zip: could not read ${t}.`);return b.set(a,{format:r,entryPath:t,resourceUrls:o}),{url:a,name:e.name,format:r,cleanup:()=>{v(a),b.delete(a),s.forEach(i=>URL.revokeObjectURL(i))}}}function vt(e,t,r){let n=r.get(t);if(!n)throw new Error("Invalid GLTF zip: no .gltf found.");let s=ye(it(n),t);yt(s,t);let o=Mt(t),a=[];try{ge(s.buffers,o,r,a),ge(s.images,o,r,a);let i=new Blob([ut(JSON.stringify(s))],{type:"model/gltf+json"}),u=URL.createObjectURL(i);return a.push(u),b.set(u,{format:"gltf",entryPath:t}),{url:u,name:e.name,format:"gltf",cleanup:()=>{v(u),b.delete(u),a.forEach(l=>URL.revokeObjectURL(l))}}}catch(i){throw a.forEach(u=>URL.revokeObjectURL(u)),i}}function ge(e,t,r,n){for(let s of e??[]){if(typeof s.uri!="string"||C(s.uri))continue;let o=wt(t,s.uri),a=r.get(o);if(!a)throw new Error(`Invalid GLTF zip: missing referenced asset ${s.uri}.`);let i=URL.createObjectURL(new Blob([a],{type:xe(o)}));n.push(i),s.uri=i}}function ye(e,t){try{return JSON.parse(e)}catch{throw new Error(`${t} is not a valid .gltf JSON file.`)}}function Me(e){return[...e.buffers??[],...e.images??[]].map(t=>t.uri).filter(t=>typeof t=="string"&&t.length>0)}function yt(e,t){for(let r of Me(e)){if(C(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 C(e){return e.startsWith("data:")}function U(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 we(e){let t=e.split("/");return e.endsWith("/")||t.includes("__MACOSX")||t.some(r=>r===".DS_Store"||r.startsWith("._"))}function Mt(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function wt(e,t){let r=t.split(/[?#]/)[0],n=xt(r);return U(e?`${e}/${n}`:n)}function xt(e){try{return decodeURI(e)}catch{return e}}function xe(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{Box3 as St,BufferAttribute as Pt,Mesh as Lt}from"three";import{acceleratedRaycast as Rt,computeBoundsTree as At,disposeBoundsTree as Bt,MeshBVH as Dt}from"three-mesh-bvh";var Se=!1,h=new WeakMap,M=new WeakMap;function Et(){Se||(Lt.prototype.raycast=Rt,Se=!0)}function Tt(e){let t=new Set;return e.traverse(r=>{let n=r.geometry;!n||!n.attributes?.position||t.add(n)}),[...t]}function Pe(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 Le=12e6;function nn(e){return kt(e)>Le}function kt(e){let t=new Set;return e.traverse(r=>{let n=r.geometry;n?.attributes?.position&&t.add(n)}),Pe([...t])}function Ct(e,t){return new Promise((r,n)=>{let s=l=>{let c=l.data;if(!c||!c.error&&!c.serialized)return;if(e.removeEventListener("message",s),e.removeEventListener("error",o),c.error){n(new Error(String(c.error)));return}let{serialized:p}=c,d=Dt.deserialize(p,t,{setIndex:!1});p.index&&(t.index?t.index.array=p.index:t.setIndex(new Pt(p.index,1,!1))),t.boundingBox=d.getBoundingBox(new St),r(d)},o=l=>{e.removeEventListener("message",s),e.removeEventListener("error",o),n(new Error(l.message||"BVH worker error"))};e.addEventListener("message",s),e.addEventListener("error",o);let a=t.index?t.index.array.slice():null,i=t.attributes.position.array.slice(),u=[i,...a?[a]:[]].map(l=>l.buffer);e.postMessage({index:a,position:i,options:{groups:[...t.groups]}},u)})}async function Ut(){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 Ot(e,t){if(t)try{return await Ct(t,e)}catch{}let r=At.call(e);return e.boundsTree=void 0,await new Promise(n=>setTimeout(n,0)),r}async function Gt(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&&h.delete(e)}),t.buildPromise}async function sn(e,t){if(t?.aborted)return;let r=M.get(e);if(!r){if(r=Tt(e),Pe(r)>Le){M.set(e,[]);return}M.set(e,r);for(let s of r){let o=h.get(s)??{references:0};o.references+=1,h.set(s,o)}}if(r.length===0)return;Et();let n=await Ut();if(t?.aborted){n?.dispose();return}try{for(let s of r){if(t?.aborted)return;let o=h.get(s);o&&await Gt(s,o,()=>Ot(s,n?.worker))}}finally{n?.dispose()}}function on(e){let t=M.get(e);if(t){M.delete(e);for(let r of t){let n=h.get(r);n&&(n.references=Math.max(0,n.references-1),!(n.references>0)&&(n.ownedTree&&r.boundsTree===n.ownedTree&&(Bt.call(r),r.boundsTree=void 0),n.ownedTree=void 0,n.buildPromise||h.delete(r)))}}}import{useThree as O}from"@react-three/fiber";import{useEffect as Be}from"react";import{useEffect as zt,useState as It}from"react";function x(e){return!!e?.isWebGPURenderer}var Re;function Ft(){return Re??(Re=(async()=>{let e=typeof navigator>"u"?void 0:navigator.gpu;if(!e)return!1;try{return!!await e.requestAdapter()}catch{return!1}})()),Re}var Ae=!1;function ln(e){let[t,r]=It(null);return zt(()=>{if(!e)return;let n=!1;return Ft().then(s=>{n||(!s&&!Ae&&(Ae=!0,console.info("[react-immersive] WebGPU isn't available in this browser; using WebGL.")),r(s))}),()=>{n=!0}},[e]),e?t===null?null:t?"webgpu":"webgl":"webgl"}async function cn(e){let{WebGPURenderer:t}=await import("three/webgpu"),r=new t({canvas:e.canvas,antialias:e.antialias??!0,alpha:e.alpha??!0});return await r.init(),r}function bn({captureRef:e}){let{gl:t,scene:r,camera:n,invalidate:s,get:o}=O();return Be(()=>{if(!e)return;let a=()=>{let i=o();i.advance(i.frameloop==="never"?i.clock.elapsedTime:performance.now())};return e.current={gl:t,scene:r,camera:n,invalidate:s,drawNow:a},()=>{e.current=null}},[e,t,r,n,s,o]),null}function hn(){let e=O(r=>r.frameloop),t=O(r=>r.invalidate);return Be(()=>{e!=="never"&&t()},[e,t]),null}function gn(e){e.dispose(),"forceContextLoss"in e&&!x(e)&&(e.forceContextLoss(),e.forceContextLoss=()=>{})}function vn(e){if(!e)return Promise.resolve(null);try{e.drawNow();let t=e.gl.domElement;return new Promise(r=>{t.toBlob(n=>r(n?URL.createObjectURL(n):null),"image/webp",.85)})}catch{return Promise.resolve(null)}}import{useEffect as Yt,useState as Kt}from"react";import{useEffect as Wt,useState as De}from"react";var Vt="200px",Ee=new Map;function Te(e,t,r){let n=Ee.get(t);if(!n){let a=new Map;n={observer:new IntersectionObserver(u=>{for(let l of u)a.get(l.target)?.(l.isIntersecting)},{rootMargin:t}),watchers:a},Ee.set(t,n)}let{observer:s,watchers:o}=n;return o.set(e,r),s.observe(e),()=>{o.delete(e),s.unobserve(e)}}function ke(e){let t=typeof IntersectionObserver<"u",[r,n]=De(!t),[s,o]=De(!t);return Wt(()=>{let a=e.current;if(!a||!t)return;let i=Te(a,Vt,n),u=Te(a,"0px",o);return()=>{i(),u()}},[e,t]),{near:r,visible:s}}import{useEffect as Ce,useRef as Ue,useState as Nt}from"react";function G(){return typeof navigator>"u"?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function _t(){if(typeof navigator>"u")return!1;let e=navigator.userAgent;return/iPhone|iPad|iPod/i.test(e)?!0:navigator.platform==="MacIntel"&&typeof navigator.maxTouchPoints=="number"&&navigator.maxTouchPoints>1}function xn(){return G()||_t()}function jt(){if(typeof window>"u"||typeof navigator>"u")return!1;let e=a=>typeof window.matchMedia=="function"&&window.matchMedia(a).matches,t=e("(pointer: coarse)")||e("(any-pointer: coarse)"),r=e("(hover: none)")||e("(any-hover: none)"),n=navigator.maxTouchPoints>0,s=typeof window.screen<"u"&&Math.min(window.screen.width,window.screen.height)<=1024,o=G();return t||o||n&&r||n&&s}function z(){if(!jt())return!1;if(G())return!0;let e=navigator.deviceMemory;return!(typeof e=="number"&&e>=8)}function Sn(e="auto"){switch(e){case"high":return!1;case"low":return!0;default:return z()}}function $t(e,t){let r=new Set,n=s=>{for(let o of s){if(r.size>=t)return;r.add(o.id)}};return n(e.filter(s=>s.wanted).sort((s,o)=>Number(o.visible)-Number(s.visible)||Number(o.live)-Number(s.live)||s.since-o.since)),n(e.filter(s=>!s.wanted&&s.live).sort((s,o)=>o.since-s.since)),r}var Ht=12,Zt=6,S=new Map,Xt=1,I=!1,Oe;function Ge(){I||(I=!0,queueMicrotask(()=>{I=!1,Oe??(Oe=z()?Zt:Ht);let e=$t([...S.values()],Oe);for(let t of S.values()){let r=e.has(t.id);r!==t.live&&(t.live=r,t.onLiveChange(r))}}))}function ze({managed:e,wanted:t,visible:r,onPark:n}){let[s,o]=Nt(!1),a=Ue(n);a.current=n;let i=Ue(null);return Ce(()=>{if(!e)return;let u={id:Xt++,wanted:!1,visible:!1,live:!1,since:performance.now(),onLiveChange:l=>{l||a.current?.(),o(l)}};return S.set(u.id,u),i.current=u,()=>{S.delete(u.id),i.current=null,o(!1),Ge()}},[e]),Ce(()=>{let u=i.current;!u||u.wanted===t&&u.visible===r||(u.wanted!==t&&(u.since=performance.now()),u.wanted=t,u.visible=r,Ge())},[e,t,r]),e?s:t}function Tn({loading:e="lazy",reveal:t="auto",rootRef:r,onPark:n}){let{near:s,visible:o}=ke(r),[a,i]=Kt(t==="auto");return Yt(()=>{t==="auto"&&i(!0)},[t]),{live:ze({managed:e==="lazy",wanted:a&&(e==="eager"||s),visible:o,onPark:n}),visible:o,awaitingReveal:!a,reveal:()=>i(!0)}}import{Box as qt}from"lucide-react";import{jsx as F,jsxs as Ie}from"react/jsx-runtime";function Jt({src:e,hidden:t=!1}){return e?F("img",{className:`ri-poster${t?" ri-poster--hidden":""}`,src:e,alt:"","aria-hidden":"true",draggable:!1,decoding:"async"}):null}function In({className:e,background:t,poster:r,onReveal:n}){let s=ie();return Ie("div",{className:`${e} ri-viewerPlaceholder`,style:{background:t},children:[F(Jt,{src:r}),n?Ie("button",{type:"button",className:"ri-revealButton",onClick:n,children:[F(qt,{size:16,"aria-hidden":"true"}),s("viewIn3D")]}):null]})}import{BufferGeometry as Qt,Float32BufferAttribute as er,Group as We,Mesh as W,MeshStandardMaterial as tr}from"three";import{STLLoader as rr}from"three/examples/jsm/loaders/STLLoader.js";import{PLYLoader as nr}from"three/examples/jsm/loaders/PLYLoader.js";var sr=12106948,Ve="This PLY file is a point cloud: it has vertices but no faces.",P=class extends Error{constructor(){super(Ve),this.name="PointCloudError"}};function Nn(e){return e instanceof P||e instanceof Error&&e.message.includes(Ve)}function _e(e,t){let r=e.split(/[?#]/,1)[0],n=r.slice(r.lastIndexOf("/")+1);try{n=decodeURIComponent(n)}catch{}return n.replace(/\.[^.]*$/,"").trim()||t}function V(e){return new tr({color:e?16777215:sr,vertexColors:e,metalness:0,roughness:.6})}function Fe(e,t,r){let n=e.itemSize;return new er(e.array.slice(t*n,(t+r)*n),n)}function je(e,t){let r=new rr().parse(e),n=!!r.hasColors,s=new We;if(r.groups.length>1){let i=r.userData.groupNames??[],u=r.getAttribute("position"),l=r.getAttribute("normal");return r.groups.forEach((c,p)=>{let d=new Qt;d.setAttribute("position",Fe(u,c.start,c.count)),l&&d.setAttribute("normal",Fe(l,c.start,c.count));let f=new W(d,V(!1));f.name=i[p]?.trim()||`${t} ${p+1}`,s.add(f)}),r.dispose(),s}r.clearGroups();let o=V(n);n&&r.alpha!==void 0&&r.alpha<1&&(o.opacity=r.alpha,o.transparent=!0);let a=new W(r,o);return a.name=t,s.add(a),s}function or(e){let r=new TextDecoder().decode(new Uint8Array(e,0,Math.min(e.byteLength,65536))).split("end_header",1)[0],n=/^\s*element\s+face\s+(\d+)/m.exec(r);return!!(n&&Number(n[1])>0)}function Ne(e,t){if(!or(e))throw new P;let r=new nr().parse(e);r.getAttribute("normal")||r.computeVertexNormals();let n=new W(r,V(!!r.getAttribute("color")));n.name=t;let s=new We;return s.add(n),s}import{useLoader as Ze,useThree as mr}from"@react-three/fiber";import{FileLoader as Xe,Loader as br,LoadingManager as hr}from"three";import{FBXLoader as gr,GLTFLoader as vr,MTLLoader as yr,OBJLoader as Mr}from"three-stdlib";import{USDLoader as wr}from"three/examples/jsm/loaders/USDLoader.js";import{useGLTF as Zn}from"@react-three/drei";import{useThree as Yn}from"@react-three/fiber";import{useMemo as qn}from"react";import{SRGBColorSpace as ar}from"three";import{DRACOLoader as ir,KTX2Loader as ur,MeshoptDecoder as lr}from"three-stdlib";function cr(e){return{name:"RI_unlit_emissive_texture",async afterRoot(t){let r=e.json.materials??[],n=new Map;if(r.forEach(o=>{let a=!!o?.extensions?.KHR_materials_unlit,i=!!o?.pbrMetallicRoughness?.baseColorTexture;a&&!i&&o?.emissiveTexture&&o.name&&n.set(o.name,o.emissiveTexture.index)}),n.size===0||!t.scene)return;let s=new Map;await Promise.all([...n].map(async([o,a])=>{let i=await e.getDependency("texture",a);i&&(i.colorSpace=ar,s.set(o,i))})),t.scene.traverse(o=>{let a=Array.isArray(o.material)?o.material:o.material?[o.material]:[];for(let i of a){let u=i.name?s.get(i.name):void 0;u&&!i.map&&(i.map=u,i.needsUpdate=!0)}})}}}var pr="https://assets.react-immersive.liveroom.dev/three-r184/draco/",dr="https://assets.react-immersive.liveroom.dev/three-r184/basis/";function fr(e,t){if(!x(t))return e.detectSupport(t);let r=t,n=s=>r.hasFeature(s);return e.workerConfig={astcSupported:n("texture-compression-astc"),etc1Supported:n("texture-compression-etc1"),etc2Supported:n("texture-compression-etc2"),dxtSupported:n("texture-compression-s3tc"),bptcSupported:n("texture-compression-bc"),pvrtcSupported:n("texture-compression-pvrtc")},e}function $e(e,t={},r){let{dracoDecoderPath:n=pr,ktx2TranscoderPath:s=dr,meshopt:o=!0}=t;if(n){let a=new ir;a.setDecoderPath(n),e.setDRACOLoader(a)}if(o&&e.setMeshoptDecoder(lr),s&&r){let a=fr(new ur().setTranscoderPath(s),r);e.setKTX2Loader(a)}e.register((a=>cr(a)))}var R=class extends br{constructor(){super(...arguments);this.options={source:{format:"glb"}}}configure(r){return this.options=r,this}load(r,n,s,o){let a=performance.now(),i={format:this.options.source.format,name:this.options.source.entryPath??Q(r),sourceBytes:this.options.source.sourceBytes??null,failedResources:[]},u=l=>{i.sourceBytes===null&&l.lengthComputable&&l.total>0&&(i.sourceBytes=l.total),s?.(l)};this.loadAsset(r,u,i).then(l=>{i.loadDurationMs=Math.max(0,performance.now()-a),E(l.scene,i),n(l)}).catch(l=>{i.loadDurationMs=Math.max(0,performance.now()-a),l&&typeof l=="object"&&E(l,i),o?.(l)})}async loadAsset(r,n,s){let o=Pr(this.options.source);o.onError=l=>{let c=Object.entries(this.options.source.resourceUrls??{}).find(([,d])=>d===l)?.[0],p=ee(c??l);s.failedResources.includes(p)||s.failedResources.push(p)};let{format:a}=this.options.source;if(a==="obj")return xr(r,o,this.options.source,n);if(a==="fbx"){let l=_(this,new gr(o)),c=Ar(r,this.options.source);c&&l.setResourcePath(c);let p=await l.loadAsync(r,n);return L(p,"FBXMesh",!1),{scene:p,animations:p.animations??[]}}if(a==="stl"||a==="ply"){let l=await Sr(r,o,n),c=_e(this.options.source.entryPath??r,a==="stl"?"STL model":"PLY model"),p=a==="stl"?je(l,c):Ne(l,c);return L(p,a==="stl"?"STLMesh":"PLYMesh",!0),{scene:p,animations:[]}}if(a==="usdz"){let c=await _(this,new wr(o)).loadAsync(r,n);return L(c,"USDZMesh",!1),{scene:c,animations:c.animations??[]}}let i=_(this,new vr(o));$e(i,this.options.decoderConfig,this.options.renderer),i.register(l=>{let c=l.json,p=d=>Array.isArray(d)?d.filter(f=>typeof f=="string"):[];return s.extensionsUsed=p(c.extensionsUsed),s.extensionsRequired=p(c.extensionsRequired),{name:"RI_asset_diagnostics",beforeRoot:()=>null}});let u=await i.loadAsync(r,n);return{scene:u.scene,animations:u.animations??[],materialVariants:ne(u)}}};le(e=>{Ze.clear(R,e)});function ds(e,t={},r,n){let s=mr(i=>i.gl),o=ve(e),a=r?{...o,format:r}:o;return Ze(R,e,i=>{i.configure({source:a,decoderConfig:t,renderer:s})},n)}async function xr(e,t,r,n){let s=await He(e,t,n),o=new Mr(t),a=Lr(s);if(a){let u=Rr(a,e,r);if(u)try{let l=await He(u.url,t),p=new yr(t).parse(l,u.basePath);p.preload(),o.setMaterials(p)}catch(l){console.warn(`[react-immersive] Could not load OBJ material ${a}; rendering geometry with fallback materials.`,l)}}let i=o.parse(s);return L(i,"OBJMesh",!0),{scene:i,animations:[]}}function L(e,t,r){let n=new Set,s=0;e.traverse(o=>{if(!("isMesh"in o&&o.isMesh===!0)){o.name&&n.add(o.name);return}let i=o.name||`${t}_${++s}`;if(!r&&o.name){n.add(o.name);return}let u=i,l=2;for(;n.has(u);)u=`${i}_${l++}`;o.name=u,n.add(u)})}function He(e,t,r){let n=new Xe(t);return n.setResponseType("text"),n.loadAsync(e,r)}function Sr(e,t,r){let n=new Xe(t);return n.setResponseType("arraybuffer"),n.loadAsync(e,r)}function _(e,t){return t.setCrossOrigin(e.crossOrigin),t.setWithCredentials(e.withCredentials),t.setRequestHeader(e.requestHeader),t}function Pr(e){let t=new hr,r=e.resourceUrls;return r&&t.setURLModifier(n=>{if(/^(?:blob:|data:)/i.test(n))return n;let s=B(Ke(n).split(/[?#]/)[0]),o=r[s];if(o)return o;let a=A(e.entryPath??""),i=B(a?`${a}/${s}`:s);return r[i]??n}),t}function Lr(e){return/^\s*mtllib\s+(.+?)\s*$/im.exec(e)?.[1]?.trim()||null}function Rr(e,t,r){if(r.resourceUrls&&r.entryPath){let n=B(`${A(r.entryPath)}/${Ke(e)}`),s=r.resourceUrls[n];if(!s)return null;let o=A(n);return{url:s,basePath:o?`${o}/`:""}}try{let n=new URL(e,t).href;return{url:n,basePath:Ye(n)}}catch{return null}}function Ar(e,t){if(t.resourceUrls&&t.entryPath){let r=A(t.entryPath);return r?`${r}/`:""}return Ye(e)}function Ye(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t+1)}function A(e){let t=B(e),r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function B(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 Ke(e){try{return decodeURI(e)}catch{return e}}import{Color as j,MeshPhysicalMaterial as Br,MeshStandardMaterial as Dr,Texture as N}from"three";function hs(e){if(te(e))return e;if(!e||typeof e!="object")return null;let t=e,r=new Dr;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 N?(r.emissiveMap=t.map,r.emissive.set(16777215)):t.color instanceof j&&r.emissive.copy(t.color)):(t.color instanceof j&&r.color.copy(t.color),t.map instanceof N&&(r.map=t.map),t.emissive instanceof j&&r.emissive.copy(t.emissive),t.emissiveMap instanceof N&&(r.emissiveMap=t.emissiveMap));let s=["aoMap","aoMapIntensity","lightMap","lightMapIntensity","alphaMap","opacity","transparent","alphaTest","side","vertexColors","wireframe","depthTest","depthWrite","visible","toneMapped","fog"];for(let o of s)t[o]!==void 0&&(r[o]=t[o]);return r.needsUpdate=!0,r}function gs(e){if(re(e))return e.clone();let t=new Br;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(w(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 vs(e){e.userData.baseColor=e.color.clone(),e.userData.baseMap=e.map??null,e.userData.baseVertexColors=e.vertexColors,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=w(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=w(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}import{Box3 as $,Matrix4 as Er,Sphere as Tr,Vector3 as H}from"three";var qe=new WeakMap,Je=new H,kr=new H,Cr=new H,Ur=new $,Qe=new Er;function g(e){return"data"in e?e.data.version:e.version}function Or(e){var u;let{geometry:t,skeleton:r}=e,n=t.getAttribute("position"),s=t.getAttribute("skinIndex"),o=t.getAttribute("skinWeight"),a=qe.get(e);if(a?.geometry===t&&a.position===n&&a.indices===s&&a.weights===o&&a.skeleton===r&&a.bindMatrix.equals(e.bindMatrix)&&a.versions[0]===g(n)&&a.versions[1]===g(s)&&a.versions[2]===g(o)&&a.inverses.length===r.boneInverses.length&&a.inverses.every((l,c)=>l.equals(r.boneInverses[c])))return a;let i={geometry:t,position:n,indices:s,weights:o,skeleton:r,versions:[g(n),g(s),g(o)],bindMatrix:e.bindMatrix.clone(),inverses:r.boneInverses.map(l=>l.clone()),bones:[],weightDeviation:0};e:for(let l=0;l<n.count;l++){Je.fromBufferAttribute(n,l).applyMatrix4(e.bindMatrix);let c=0;for(let d=0;d<4;d++){let f=o.getComponent(l,d);if(f===0)continue;let m=s.getComponent(l,d);if(!Number.isFinite(f)||f<0||!Number.isInteger(m)||!r.bones[m]||!i.inverses[m]){i.bones=null;break e}c+=f,((u=i.bones)[m]??(u[m]=new $)).expandByPoint(kr.copy(Je).applyMatrix4(i.inverses[m]))}let p=Math.abs(c-1);if(p>1e-4){i.bones=null;break}i.weightDeviation=Math.max(i.weightDeviation,p)}return qe.set(e,i),i}function xs(e,{precise:t=!1,updateFallbacks:r=!0}={}){e.updateMatrixWorld(!0),e.traverse(n=>{if(!Y(n))return;let s=n;if(!s.skeleton)return;let o=K(s);o&&s.bindMatrixInverse.copy(o);let i=!!s.geometry.morphAttributes.position?.length?null:Or(s);if(!t&&!i?.bones&&!r&&s.boundingBox&&s.boundingSphere)return;let u=s.boundingBox??(s.boundingBox=new $),l=s.boundingSphere??(s.boundingSphere=new Tr);if(u.makeEmpty(),t||!i?.bones){let c=s.geometry.getAttribute("position");for(let p=0;p<c.count;p++)u.expandByPoint(s.getVertexPosition(p,Cr))}else{for(let c=0;c<i.bones.length;c++){let p=i.bones[c];p&&(Qe.multiplyMatrices(s.bindMatrixInverse,s.skeleton.bones[c].matrixWorld),u.union(Ur.copy(p).applyMatrix4(Qe)))}if(!u.isEmpty()){let c=u.min,p=u.max,d=s.bindMatrixInverse.elements,f=Math.max(1,Math.abs(c.x),Math.abs(c.y),Math.abs(c.z),Math.abs(p.x),Math.abs(p.y),Math.abs(p.z)),m=Math.max(Math.abs(c.x-d[12]),Math.abs(p.x-d[12]),Math.abs(c.y-d[13]),Math.abs(p.y-d[13]),Math.abs(c.z-d[14]),Math.abs(p.z-d[14]));u.expandByScalar(i.weightDeviation*m+f*1e-10)}}u.getBoundingSphere(l)})}import{useCallback as et,useEffect as Gr,useRef as zr}from"react";import{useThree as Ir}from"@react-three/fiber";function Rs(){let e=Ir(s=>s.gl.domElement),t=zr(void 0),r=et(s=>{t.current===void 0&&(t.current=e.style.cursor),e.style.cursor=s},[e]),n=et(()=>{let s=t.current;s!==void 0&&(e.style.cursor=s,t.current=void 0)},[e]);return Gr(()=>()=>{n()},[n]),{setCanvasCursor:r,restoreCanvasCursor:n}}import{Box3 as Fr,Vector3 as tt}from"three";function D(e){return[e.x,e.y,e.z]}function Es(e){let t=new Fr().setFromObject(e),r=0;return e.traverse(n=>{n.isMesh&&(r+=1)}),{bounds:{min:D(t.min),max:D(t.max),center:D(t.getCenter(new tt)),size:D(t.getSize(new tt))},objectCount:r,materialVariants:se(e),materialVariantGroups:oe(e)}}import{useSyncExternalStore as Wr}from"react";var rt="(prefers-reduced-motion: reduce)";function Vr(e){if(typeof window>"u"||!window.matchMedia)return()=>{};let t=window.matchMedia(rt);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}var _r=()=>typeof window<"u"&&!!window.matchMedia?.(rt).matches;function Cs(e="user"){let t=Wr(Vr,_r,()=>!1);return e==="always"?!0:e==="never"?!1:t}import{jsx as Z,jsxs as X}from"react/jsx-runtime";function Is({visible:e,message:t,tone:r="default",progress:n}){if(!e)return null;let s=typeof n=="number"&&Number.isFinite(n),o=s?Math.min(Math.max(n,0),100):0,a=Math.round(o);return X("div",{className:"bb-loadingOverlay",role:"status","aria-live":"polite",children:[s&&X("div",{className:"bb-loadingProgressRow",children:[Z("div",{className:"bb-loadingProgress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":a,children:Z("div",{className:"bb-loadingProgress__bar",style:{width:`${a}%`}})}),X("span",{className:"bb-loadingProgress__label",children:[a,"%"]})]}),r!=="success"&&Z("span",{className:`bb-loadingMessage bb-status--${r}`,children:t})]})}export{Hr as a,ie as b,_t as c,xn as d,z as e,Sn as f,Jr as g,k as h,ve as i,Qr as j,Le as k,nn as l,kt as m,sn as n,on as o,x as p,ln as q,cn as r,bn as s,hn as t,gn as u,vn as v,Tn as w,Jt as x,In as y,Nn as z,pr as A,dr as B,ds as C,hs as D,gs as E,vs as F,xs as G,Rs as H,Es as I,Cs as J,Is as K};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ha as p}from"./chunk-4JMJALRO.mjs";function c(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(!c(e))return e;let i=c(n)?{...n}:{};for(let r of Object.keys(e)){let t=e[r];i[r]=c(t)?o(i[r],t):t}return i}function f(n){return Array.isArray(n)&&n.length>0&&typeof n[0]!="string"}function O(n,e,i){let r=f(e)?e:[{ids:e,patch:i??{}}],t=n;for(let d of r)for(let g of p(t,d.ids)){let s=t[g];if(!s)continue;let a=o(s,d.patch);t===n&&(t={...n}),t[g]=a}return t}function u(n){return{style:{material:n}}}function x(n,e){return o(n,e)}var B={type:"point",color:"#ffffff",intensity:1,position:[0,0,0],distance:0,decay:2,attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0};function h(n){return{...B,...n}}function P(n){return n}export{O as a,u as b,x as c,h as d,P as e};
|