@selvajs/compute 3.1.0-beta.15 → 3.1.0-beta.16

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.
@@ -1,120 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkH3FZW6OXcjs = require('./chunk-H3FZW6OX.cjs');var kn={};_chunkH3FZW6OXcjs.a.call(void 0, kn,{CONCRETE_MATERIAL:()=>Tt,EMISSIVE_MATERIAL:()=>yt,GLASS_MATERIAL:()=>xt,METAL_MATERIAL:()=>bt,PLASTIC_MATERIAL:()=>Rt,RUBBER_MATERIAL:()=>vt,SHARED_MATERIALS:()=>Ye,WOOD_MATERIAL:()=>wt});var _three = require('three'); var z = _interopRequireWildcard(_three); var re = _interopRequireWildcard(_three); var q = _interopRequireWildcard(_three); var pe = _interopRequireWildcard(_three); var W = _interopRequireWildcard(_three); var Q = _interopRequireWildcard(_three); var Z = _interopRequireWildcard(_three); var N = _interopRequireWildcard(_three); var Xt = _interopRequireWildcard(_three); var V = _interopRequireWildcard(_three); var ze = _interopRequireWildcard(_three); var w = _interopRequireWildcard(_three); var He = _interopRequireWildcard(_three); var ee = _interopRequireWildcard(_three); var _ = _interopRequireWildcard(_three);var yt=new z.MeshPhysicalMaterial({color:0,emissive:new z.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:z.FrontSide,dithering:!0}),bt=new z.MeshPhysicalMaterial({color:new z.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:z.FrontSide,dithering:!0}),Tt=new z.MeshPhysicalMaterial({color:new z.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:z.FrontSide,dithering:!0}),Rt=new z.MeshPhysicalMaterial({color:new z.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:z.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),xt=new z.MeshPhysicalMaterial({color:new z.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,depthWrite:!1,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:z.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),vt=new z.MeshPhysicalMaterial({color:new z.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:z.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),wt=new z.MeshPhysicalMaterial({color:new z.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:z.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Ye=new Set([yt,bt,Tt,Rt,xt,vt,wt]);function xe(e){let n=e.clone().normalize(),t=new re.Vector3(0,0,1),r=new re.Vector3(0,1,0),a=Math.abs(n.dot(t))>.9?r:t,o=new re.Vector3().crossVectors(a,n).normalize(),i=new re.Vector3().crossVectors(n,o).normalize();return{up:n,forward:i,right:o}}function Le(e,n){let{forward:t,right:r,up:a}=xe(e);return t.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(a).normalize().multiplyScalar(n)}function Mt(e,n,t){let{forward:r,right:a,up:o}=xe(e);return a.clone().multiplyScalar(n).add(r.clone().multiplyScalar(n)).add(o.clone().multiplyScalar(t))}function Ht(e){let n=e.clone().normalize(),t=new re.Vector3(0,1,0);if(n.dot(t)>.9999)return new re.Euler;if(n.dot(t)<-.9999)return new re.Euler(Math.PI,0,0);let r=new re.Quaternion().setFromUnitVectors(t,n);return new re.Euler().setFromQuaternion(r)}function Xe(e){let n=Math.abs(e.x),t=Math.abs(e.y),r=Math.abs(e.z);return n>=t&&n>=r?"x":t>=r?"y":"z"}var ae={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function Ha(e,n,t,r,a){if(zn(e),n.length===0)return;n.forEach(u=>{e.add(u)});let o=Ke(n),i=o.getCenter(new q.Vector3),l=o.getSize(new q.Vector3),s=Math.max(l.x,l.y,l.z);if(s/Math.min(l.x||1,l.y||1,l.z||1)>ae.SCALE_RATIO_THRESHOLD||s>ae.HUGE_THRESHOLD?(t.near=s*ae.NEAR_PLANE_FACTOR.TINY,t.far=s*ae.FAR_PLANE_FACTOR.HUGE):s>ae.LARGE_THRESHOLD?(t.near=s*ae.NEAR_PLANE_FACTOR.SMALL,t.far=s*ae.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,s*ae.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,s*ae.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),!a){let u=s*ae.INITIAL_DISTANCE_MULTIPLIER;t.position.copy(i).add(Le(t.up,u)),r.target.copy(i),r.update()}}function Ct(e){if(!e||typeof e!="string")return _chunkH3FZW6OXcjs.e.call(void 0, ).warn(`Invalid color input: ${e}, using white`),new q.Color(16777215);let n=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(n))try{let r=n.startsWith("#")?n:`#${n}`;return new q.Color(r)}catch (e2){return _chunkH3FZW6OXcjs.e.call(void 0, ).warn(`Invalid hex color: ${e}, using white`),new q.Color(16777215)}if(n.includes(",")){let r=n.split(",").map(a=>parseInt(a.trim(),10));if(r.length===3&&r.every(a=>!isNaN(a)&&a>=0&&a<=255))return new q.Color(r[0]/255,r[1]/255,r[2]/255)}let t=n.toLowerCase();return t in q.Color.NAMES?new q.Color(q.Color.NAMES[t]):(_chunkH3FZW6OXcjs.e.call(void 0, ).warn(`Invalid color string: ${e}, using white`),new q.Color(16777215))}function At(e,n,t="z"){e.forEach(r=>{r.position[t]-=n})}function Ke(e){let n=new q.Box3;return e.length===0||e.forEach(t=>{t.updateMatrixWorld(!0);let r=new q.Box3().setFromObject(t);n.union(r)}),n}var Un=new Set(["grid","floor","label-layer","measure"]);function Vn(e){let n=e;for(;n;){if(typeof n.userData.id=="string"&&Un.has(n.userData.id))return!0;n=n.parent}return!1}function le(e){e.updateMatrixWorld(!0);let n=new q.Box3;return e.traverse(t=>{let r=t;t.visible&&!Vn(t)&&r.geometry&&n.expandByObject(t)}),n}var _n=new Set(["floor","grid","label-layer"]),Oe="selvaGeometryCache";function zn(e){[...e.children].forEach(t=>{_n.has(t.userData.id)||t.userData.source!=="user"&&(t.traverse(r=>{let a=r;if(!a.geometry&&!a.material)return;_optionalChain([a, 'access', _2 => _2.geometry, 'optionalAccess', _3 => _3.userData, 'optionalAccess', _4 => _4[Oe]])||_optionalChain([a, 'access', _5 => _5.geometry, 'optionalAccess', _6 => _6.dispose, 'call', _7 => _7()]);let o=a.material;if(!o)return;(Array.isArray(o)?o:[o]).forEach(l=>{if(!Ye.has(l)){for(let s of Object.values(l))s instanceof q.Texture&&s.dispose();l.dispose()}})}),t.removeFromParent())})}function Gn(e){let{up:n,forward:t,right:r}=xe(e),a=t.clone().negate(),o=r.clone();return{top:n.clone(),bottom:n.clone().negate(),front:a.clone(),back:a.clone().negate(),right:o.clone(),left:o.clone().negate(),iso:a.clone().multiplyScalar(1.2).add(o.clone()).add(n.clone()).normalize()}}function St(e){let{scene:n,perspective:t,controls:r,onActiveCameraChange:a}=e,o=(_nullishCoalesce(e.up, () => (t.up))).clone().normalize(),i=Gn(o),l=new pe.OrthographicCamera(-1,1,1,-1,t.near,t.far);l.up.copy(o);let s="perspective",c=t.aspect,u=()=>s==="perspective"?t:l,d=null,E=()=>{_optionalChain([d, 'optionalAccess', _8 => _8.cancel, 'call', _9 => _9()]),d=null},T=()=>{let h=(s==="orthographic"?l:t).position.distanceTo(r.target)*Math.tan(t.fov*Math.PI/360),b=h*c;l.left=-b,l.right=b,l.top=h,l.bottom=-h,l.near=t.near,l.far=t.far,l.updateProjectionMatrix()},v=p=>{if(p!==s){if(E(),p==="orthographic")l.position.copy(t.position),l.up.copy(t.up),l.lookAt(r.target),l.zoom=1,T();else{let h=(l.top-l.bottom)/(2*l.zoom)/Math.tan(t.fov*Math.PI/360),b=l.position.clone().sub(r.target);b.lengthSq()<1e-12&&b.copy(o),b.normalize(),t.position.copy(r.target).add(b.multiplyScalar(h))}s=p,r.object=u(),r.update(),a(u())}},y=(p,f,h,b)=>{let H=t.fov*(Math.PI/180),C=f/(2*Math.tan(H/2))*1.5,L=Nn(h,o),P=p.clone().add(L.clone().multiplyScalar(C)),k=u();s==="orthographic"&&(l.zoom=1),E(),b?d=Wn(k,r,P,p,()=>{s==="orthographic"&&T()}):(k.position.copy(P),r.target.copy(p),s==="orthographic"&&T(),r.update())},m=(p,f=!0)=>{let h=le(n),b=h.isEmpty()?r.target.clone():h.getCenter(new pe.Vector3),H=h.isEmpty()?new pe.Vector3(1,1,1):h.getSize(new pe.Vector3),C=Math.max(H.x,H.y,H.z)||1;y(b,C,p,f)};return{getActiveCamera:u,getProjection:()=>s,setProjection:v,toggleProjection:()=>(v(s==="perspective"?"orthographic":"perspective"),s),setView:(p,f=!0)=>{m(i[p],f)},setViewDirection:m,frameBounds:(p,f=!0)=>{if(p.isEmpty())return;let h=p.getCenter(new pe.Vector3),b=p.getSize(new pe.Vector3),H=Math.max(b.x,b.y,b.z)||1,C=u().position.clone().sub(r.target);C.lengthSq()<1e-12&&C.copy(i.iso),y(h,H,C.normalize(),f)},setRotateEnabled:p=>{r.enableRotate=p},isRotateEnabled:()=>r.enableRotate,updateAspect:(p,f)=>{c=f===0?c:p/f,s==="orthographic"&&T()},dispose:E}}function Nn(e,n){let{up:t,forward:r}=xe(n),a=e.clone().normalize();if(Math.abs(a.dot(t))<.9999)return e;let o=r.clone().negate(),i=.5*Math.PI/180;return a.multiplyScalar(Math.cos(i)).add(o.multiplyScalar(Math.sin(i))).normalize()}var jn=e=>1-Math.pow(1-e,3);function Wn(e,n,t,r,a,o=250){let i=e.position.clone(),l=n.target.clone(),s=performance.now(),c=null,u=()=>{c=null;let d=jn(Math.min((performance.now()-s)/o,1));e.position.lerpVectors(i,t,d),n.target.lerpVectors(l,r,d),a(),n.update(),d<1&&(c=requestAnimationFrame(u))};return c=requestAnimationFrame(u),{cancel:()=>{c!==null&&(cancelAnimationFrame(c),c=null)}}}function $n(e){if(!(e>0)||!Number.isFinite(e))return 1;let n=Math.floor(Math.log10(e)),t=Math.pow(10,n),r=e/t;return(r>=5?5:r>=2?2:1)*t}var qn=`
2
- varying vec3 vWorldPos;
3
- void main() {
4
- vec4 world = modelMatrix * vec4(position, 1.0);
5
- vWorldPos = world.xyz;
6
- gl_Position = projectionMatrix * viewMatrix * world;
7
- }
8
- `,Yn=`
9
- precision highp float;
10
- varying vec3 vWorldPos;
11
-
12
- uniform vec2 uAxes; // indices (0=x,1=y,2=z) of the two in-plane world axes
13
- uniform float uCell;
14
- uniform float uMajor;
15
- uniform vec3 uCellColor;
16
- uniform vec3 uMajorColor;
17
- uniform vec3 uCenter; // fade center (camera position), projected onto plane
18
- uniform float uFade;
19
-
20
- // Antialiased grid line intensity for a given spacing, using screen-space derivatives so lines
21
- // stay ~1px regardless of zoom (the standard "pristine grid" technique).
22
- float gridLine(vec2 coord, float spacing) {
23
- vec2 c = coord / spacing;
24
- vec2 d = fwidth(c);
25
- vec2 g = abs(fract(c - 0.5) - 0.5) / max(d, 1e-6);
26
- float line = min(g.x, g.y);
27
- return 1.0 - clamp(line, 0.0, 1.0);
28
- }
29
-
30
- // Index a vec3 by a float axis id (0/1/2) without dynamic indexing (WebGL1-safe).
31
- float axis(vec3 v, float i) {
32
- return i < 0.5 ? v.x : (i < 1.5 ? v.y : v.z);
33
- }
34
-
35
- void main() {
36
- // Pick the two in-plane world coordinates.
37
- vec2 coord = vec2(axis(vWorldPos, uAxes.x), axis(vWorldPos, uAxes.y));
38
-
39
- float minor = gridLine(coord, uCell);
40
- float major = gridLine(coord, uCell * uMajor);
41
-
42
- vec3 color = mix(uCellColor, uMajorColor, major);
43
- float alpha = max(minor, major);
44
-
45
- // Radial fade from the camera-projected center.
46
- float dist = distance(vWorldPos, uCenter);
47
- float fade = 1.0 - clamp(dist / uFade, 0.0, 1.0);
48
- alpha *= fade * fade;
49
-
50
- if (alpha < 0.001) discard;
51
- gl_FragColor = vec4(color, alpha);
52
- }
53
- `;function Dt(e={}){let{cellSize:n=1,majorEvery:t=10,cellColor:r=8947848,majorColor:a=4473924,fadeDistance:o=100,plane:i="y"}=e,l=i==="y"?new W.Vector2(0,2):i==="z"?new W.Vector2(0,1):new W.Vector2(1,2),s=2.5,c=new W.PlaneGeometry(1,1);i==="y"?c.rotateX(-Math.PI/2):i==="x"&&c.rotateY(Math.PI/2);let u=new W.ShaderMaterial({vertexShader:qn,fragmentShader:Yn,transparent:!0,depthWrite:!1,side:W.DoubleSide,uniforms:{uAxes:{value:l},uCell:{value:n},uMajor:{value:t},uCellColor:{value:new W.Color(r)},uMajorColor:{value:new W.Color(a)},uCenter:{value:new W.Vector3},uFade:{value:o}}}),d=new W.Mesh(c,u);d.name="grid",d.userData.id="grid",d.renderOrder=-1;let E=o,T=o*s,v=new W.Vector3;return{object:d,update:y=>{i==="y"?(d.position.set(y.x,0,y.z),v.set(y.x,0,y.z)):i==="z"?(d.position.set(y.x,y.y,0),v.set(y.x,y.y,0)):(d.position.set(0,y.y,y.z),v.set(0,y.y,y.z)),u.uniforms.uCenter.value.copy(v),d.scale.setScalar(T)},fitToContent:y=>{if(y.isEmpty())return;let m=y.getSize(new W.Vector3),g=(M,p)=>p===0?M.x:p===1?M.y:M.z,R=Math.max(g(m,l.x),g(m,l.y));if(!(R>0)||!Number.isFinite(R))return;let x=20;u.uniforms.uCell.value=$n(R/x),E=R*2,u.uniforms.uFade.value=E,T=E*s},setVisible:y=>{d.visible=y},dispose:()=>{d.removeFromParent(),c.dispose(),u.dispose()}}}var _ViewHelperjs = require('three/addons/helpers/ViewHelper.js');function Lt(e){let{camera:n,domElement:t,controller:r}=e,a=new (0, _ViewHelperjs.ViewHelper)(n,t);a.setLabels("X","Y","Z");let o=!0,i=128,l=new Q.Raycaster,s=new Q.OrthographicCamera(-2,2,2,-2,0,4);s.position.set(0,0,2),s.updateMatrixWorld();let c={posX:new Q.Vector3(1,0,0),negX:new Q.Vector3(-1,0,0),posY:new Q.Vector3(0,1,0),negY:new Q.Vector3(0,-1,0),posZ:new Q.Vector3(0,0,1),negZ:new Q.Vector3(0,0,-1)},u=E=>{let T=t.getBoundingClientRect(),v=T.left+t.offsetWidth-i-a.location.right,y=T.top+t.offsetHeight-i-a.location.bottom,m=new Q.Vector2((E.clientX-v)/i*2-1,-((E.clientY-y)/i)*2+1);if(Math.abs(m.x)>1||Math.abs(m.y)>1)return null;a.quaternion.copy(n.quaternion).invert(),a.updateMatrixWorld(),l.setFromCamera(m,s);let g=l.intersectObjects(a.children,!1);for(let R of g){let x=_optionalChain([R, 'access', _10 => _10.object, 'access', _11 => _11.userData, 'optionalAccess', _12 => _12.type]);if(typeof x=="string"&&x in c)return x}return null};return{render:E=>{if(!o)return;let T=E.autoClear;E.autoClear=!1,a.render(E),E.autoClear=T},update:()=>{},handleClick:E=>{if(!o)return!1;let T=u(E);return T?(r.getProjection()==="orthographic"&&r.setProjection("perspective"),r.setViewDirection(c[T],!1),!0):!1},isAnimating:!1,setVisible:E=>{o=E},isVisible:()=>o,dispose:()=>a.dispose()}}var _LineSegmentsGeometryjs = require('three/addons/lines/LineSegmentsGeometry.js');var _LineSegments2js = require('three/addons/lines/LineSegments2.js');var _LineMaterialjs = require('three/addons/lines/LineMaterial.js');function Ie(e,n,t){let o=Math.cos(Math.PI/180*t),i=e.length/3;if(i>=67108864)throw new Error(`extractEdgeSegments: ${i} vertices exceeds 2^26 limit`);let l=new Float64Array(i),s=new Float64Array(i),c=new Float64Array(i);for(let f=0;f<i;f++)l[f]=Math.round(e[3*f]*1e4),s[f]=Math.round(e[3*f+1]*1e4),c[f]=Math.round(e[3*f+2]*1e4);let u=16;for(;u<i*2;)u<<=1;let d=u-1,E=new Int32Array(u).fill(-1),T=new Int32Array(i);for(let f=0;f<i;f++){let h=(Math.imul(l[f]|0,73856093)^Math.imul(s[f]|0,19349663)^Math.imul(c[f]|0,83492791))&d;for(;;){let b=E[h];if(b===-1){E[h]=f,T[f]=f;break}if(l[b]===l[f]&&s[b]===s[f]&&c[b]===c[f]){T[f]=b;break}h=h+1&d}}let v=new Float32Array(4096),y=0,m=(f,h)=>{if(y+6>v.length){let b=new Float32Array(v.length*2);b.set(v),v=b}v[y++]=e[3*f],v[y++]=e[3*f+1],v[y++]=e[3*f+2],v[y++]=e[3*h],v[y++]=e[3*h+1],v[y++]=e[3*h+2]},g=new Map,R=[],x=[],M=[],p=(n?n.length:i)/3;for(let f=0;f<p;f++){let h=n?n[3*f]:3*f,b=n?n[3*f+1]:3*f+1,H=n?n[3*f+2]:3*f+2,C=T[h],L=T[b],P=T[H];if(C===L||L===P||P===C)continue;let k=e[3*H]-e[3*b],O=e[3*H+1]-e[3*b+1],I=e[3*H+2]-e[3*b+2],S=e[3*h]-e[3*b],D=e[3*h+1]-e[3*b+1],G=e[3*h+2]-e[3*b+2],j=O*G-I*D,$=I*S-k*G,U=k*D-O*S,J=j*j+$*$+U*U;if(J>0){let X=1/Math.sqrt(J);j*=X,$*=X,U*=X}else j=0,$=0,U=0;for(let X=0;X<3;X++){let me,Ee,te,se;X===0?(me=h,Ee=b,te=C,se=L):X===1?(me=b,Ee=H,te=L,se=P):(me=H,Ee=h,te=P,se=C);let De=se*67108864+te,fe=g.get(De);if(fe!==void 0&&fe!==-1)j*M[3*fe]+$*M[3*fe+1]+U*M[3*fe+2]<=o&&m(me,Ee),g.set(De,-1);else{let be=te*67108864+se;if(!g.has(be)){let qe=R.length;g.set(be,qe),R.push(me),x.push(Ee),M.push(j,$,U)}}}}for(let f of g.values())f!==-1&&m(R[f],x[f]);return v.slice(0,y)}function Ot(){return[`const extract = ${Ie.toString()};`,"self.onmessage = (event) => {"," const { id, positions, index, thresholdAngle } = event.data;"," try {"," const segments = extract(positions, index, thresholdAngle);"," self.postMessage({ id, segments }, [segments.buffer]);"," } catch (error) {"," self.postMessage({ id, error: String((error && error.message) || error) });"," }","};"].join(`
54
- `)}var we="edge-overlay",rt= exports.o ="triangle-cap",Qn=2236962,er=1.5,tr=44,nr=.75,rr=4e6,or=2e6,ar=25e3,It=128*1024*1024,ir=80,Pt=20,sr=1,lr=2;function Bt(e,n){let t=Array.isArray(e.material)?e.material:[e.material];for(let r of t)r&&(r.polygonOffset=n,r.polygonOffsetFactor=n?sr:0,r.polygonOffsetUnits=n?lr:0)}function Je(e){let n=e.getAttribute("position");return n?(e.index?e.index.count:n.count)/3:0}function kt(e){let n=e.getAttribute("position");if(!n||n.isInterleavedBufferAttribute||n.itemSize!==3||!(n.array instanceof Float32Array)||n.count>=67108864)return null;let t=e.index;return t&&!(t.array instanceof Uint32Array)&&!(t.array instanceof Uint16Array)?null:{positions:n.array,index:t?t.array:null}}function Ut(e,n){let r=2166136261,a=s=>{r^=s,r=Math.imul(r,16777619)},o=new Uint32Array(e.positions.buffer,e.positions.byteOffset,e.positions.length),i=Math.min(4096,o.length);for(let s=0;s<i;s++)a(o[s]);for(let s=Math.max(i,o.length-4096);s<o.length;s++)a(o[s]);let l=0;if(e.index){l=e.index.length;let s=Math.min(4096,l);for(let c=0;c<s;c++)a(e.index[c]);for(let c=Math.max(s,l-4096);c<l;c++)a(e.index[c])}return`${n}:${e.positions.length}:${l}:${r>>>0}`}var ce=new Map,Pe=0;function Vt(e){let n=ce.get(e);return n&&(ce.delete(e),ce.set(e,n)),n}function _t(e,n){if(n.byteLength>It)return;let t=ce.get(e);for(t&&(Pe-=t.byteLength,ce.delete(e)),ce.set(e,n),Pe+=n.byteLength;Pe>It;){let r=ce.keys().next().value;Pe-=ce.get(r).byteLength,ce.delete(r)}}function cr(e,n){let t=new Z.EdgesGeometry(e,n),r=t.attributes.position?t.attributes.position.array:new Float32Array(0);return t.dispose(),r}function Qe(e,n){let t=kt(e);if(!t)return cr(e,n);let r=Ut(t,n),a=Vt(r);if(a)return a;let o=Ie(t.positions,t.index,n);return _t(r,o),o}var ge,ve=new Map,ur=1;function dr(){if(ge!==void 0)return ge;if(typeof Worker>"u"||typeof Blob>"u"||typeof URL>"u"||typeof URL.createObjectURL!="function")return ge=null,null;try{let e=URL.createObjectURL(new Blob([Ot()],{type:"text/javascript"})),n=new Worker(e);n.onmessage=t=>{let{id:r,segments:a,error:o}=t.data,i=ve.get(r);i&&(ve.delete(r),a?i.resolve(a):i.reject(new Error(_nullishCoalesce(o, () => ("edge extraction failed in worker")))))},n.onerror=()=>{for(let t of ve.values())t.reject(new Error("edge extraction worker crashed"));ve.clear(),n.terminate(),ge=null},ge=n}catch (e3){ge=null}return ge}function mr(e,n,t){return new Promise((r,a)=>{let o=ur++;ve.set(o,{resolve:r,reject:a});let i=n.positions.slice(),l=n.index?n.index.slice():null,s=[i.buffer];l&&s.push(l.buffer),e.postMessage({id:o,positions:i,index:l,thresholdAngle:t},s)})}var Ze=new Map;function fr(e,n){let t=kt(e);if(!t||Je(e)<ar)return Promise.resolve(Qe(e,n));let r=Ut(t,n),a=Vt(r);if(a)return Promise.resolve(a);let o=Ze.get(r);if(o)return o;let i=dr();if(!i)return Promise.resolve(Qe(e,n));let l=mr(i,t,n).catch(()=>Ie(t.positions,t.index,n)).then(s=>(_t(r,s),s)).finally(()=>{Ze.delete(r)});return Ze.set(r,l),l}var Fe=new WeakMap;function et(e,n){return _optionalChain([Fe, 'access', _13 => _13.get, 'call', _14 => _14(e), 'optionalAccess', _15 => _15.get, 'call', _16 => _16(n)])}function zt(e,n,t){let r=Fe.get(e);r||(r=new Map,Fe.set(e,r));let a=new _LineSegmentsGeometryjs.LineSegmentsGeometry;a.setPositions(t);let o={geometry:a,refCount:0,segmentCount:t.length/6};return r.set(n,o),o}function pr(e){let n=e.userData,t=n.edgeSource&&Fe.get(n.edgeSource),r=n.edgeThresholdAngle!=null?_optionalChain([t, 'optionalAccess', _17 => _17.get, 'call', _18 => _18(n.edgeThresholdAngle)]):void 0;if(!r||r.geometry!==e.geometry){e.geometry.dispose();return}r.refCount-=1,r.refCount<=0&&(r.geometry.dispose(),t.delete(n.edgeThresholdAngle))}function Gt(e){return{forcedColor:e.color!=null?new Z.Color(e.color):null,darken:Z.MathUtils.clamp(_nullishCoalesce(e.darken, () => (nr)),0,1),width:_nullishCoalesce(e.width, () => (er)),thresholdAngle:_nullishCoalesce(e.thresholdAngle, () => (tr)),distanceFade:_nullishCoalesce(e.distanceFade, () => (!0)),maxTriangles:_nullishCoalesce(e.maxTriangles, () => (rr)),maxSegments:_nullishCoalesce(e.maxSegments, () => (or))}}function Er(e,n){let r=_optionalChain([(Array.isArray(e.material)?e.material[0]:e.material), 'optionalAccess', _19 => _19.color]);return r?r.clone().multiplyScalar(1-n):new Z.Color(Qn)}var Be=class{constructor(n){_chunkH3FZW6OXcjs.b.call(void 0, this,"options",n);_chunkH3FZW6OXcjs.b.call(void 0, this,"byKey",new Map)}for(n,t){let r=_nullishCoalesce(this.options.forcedColor, () => (Er(n,this.options.darken))),a=r.getHex()*2+(t?1:0),o=this.byKey.get(a);return o||(o=hr(r,this.options.width,t),this.byKey.set(a,o)),o}disposeUnused(n){let t=new Set(n.map(r=>r.material));for(let r of this.byKey.values())t.has(r)||r.dispose()}};function hr(e,n,t){let r=new (0, _LineMaterialjs.LineMaterial)({color:e});return r.linewidth=n,t&&(r.transparent=!0),r}function gr(e,n,t,r,a){n.refCount+=1;let o=new (0, _LineSegments2js.LineSegments2)(n.geometry,t);return o.userData.kind=we,o.userData.edgeSource=e,o.userData.edgeThresholdAngle=r,o.raycast=()=>{},a&&Tr(o),o}var Ft=new Z.Vector3,yr=new Z.Vector3;function br(e,n,t){e.geometry.boundingSphere||e.geometry.computeBoundingSphere();let r=e.geometry.boundingSphere;if(!r||r.radius<=0)return 1/0;let a=r.radius*e.matrixWorld.getMaxScaleOnAxis();if(Ft.copy(r.center).applyMatrix4(e.matrixWorld),n.isPerspectiveCamera){let o=n,i=yr.setFromMatrixPosition(n.matrixWorld).distanceTo(Ft);if(i<=a)return 1/0;let l=Math.tan(Z.MathUtils.degToRad(o.fov)*.5);return a/(i*l)*t}if(n.isOrthographicCamera){let o=n,i=(o.top-o.bottom)/o.zoom;return i>0?2*a/i*t:1/0}return 1/0}function Tr(e){e.onBeforeRender=(n,t,r)=>{_LineSegments2js.LineSegments2.prototype.onBeforeRender.call(e,n);let a=e.material,o=br(e,r,a.resolution.y);a.opacity=Z.MathUtils.clamp((o-Pt)/(ir-Pt),0,1)}}function Rr(e){return _optionalChain([e, 'access', _20 => _20.userData, 'optionalAccess', _21 => _21.kind])===we}function Nt(e,n){let t=[];return e.traverse(r=>{if(r instanceof Z.Mesh&&!(r.userData.id==="floor"||r.userData.id==="grid")&&r.userData.kind!==we&&!r.children.some(a=>_optionalChain([a, 'access', _22 => _22.userData, 'optionalAccess', _23 => _23.kind])===we)&&r.geometry){if(Je(r.geometry)>n){r.userData.edgesSkipped=rt,console.debug(`[edges] skipping mesh over triangle cap (${Je(r.geometry)} > ${n})`);return}delete r.userData.edgesSkipped,t.push(r)}}),t}function jt(e,n,t,r){let a=r.distanceFade&&n.segmentCount<=r.maxSegments,o=gr(e.geometry,n,t.for(e,a),r.thresholdAngle,a);return e.add(o),Bt(e,!0),o}function Va(e,n={}){let t=Gt(n),r=new Be(t),a=[];for(let o of Nt(e,t.maxTriangles)){let i=_nullishCoalesce(et(o.geometry,t.thresholdAngle), () => (zt(o.geometry,t.thresholdAngle,Qe(o.geometry,t.thresholdAngle))));a.push(jt(o,i,r,t))}return r.disposeUnused(a),a}var Wt=new WeakMap;function tt(e){return _nullishCoalesce(Wt.get(e), () => (0))}function xr(e,n){for(let t=e;t;t=t.parent)if(t===n)return!0;return!1}async function $t(e,n={}){let t=Gt(n),r=new Be(t),a=tt(e),o=[],i=Nt(e,t.maxTriangles).map(async l=>{let s=et(l.geometry,t.thresholdAngle);if(!s){let c=await fr(l.geometry,t.thresholdAngle);if(tt(e)!==a||!xr(l,e)||l.children.some(u=>_optionalChain([u, 'access', _24 => _24.userData, 'optionalAccess', _25 => _25.kind])===we))return;s=et(l.geometry,t.thresholdAngle),s||(s=zt(l.geometry,t.thresholdAngle,c))}o.push(jt(l,s,r,t))});return await Promise.all(i),r.disposeUnused(o),o}function qt(e){Wt.set(e,tt(e)+1);let n=[];e.traverse(r=>{r instanceof _LineSegments2js.LineSegments2&&Rr(r)&&n.push(r)});let t=new Set;for(let r of n)pr(r),t.add(r.material),r.parent instanceof Z.Mesh&&Bt(r.parent,!1),r.removeFromParent();return t.forEach(r=>r.dispose()),n.length}var _Passjs = require('three/addons/postprocessing/Pass.js');var ot={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new N.Vector2(1,1)},uColor:{value:new N.Color(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
55
- varying vec2 vUv;
56
- void main() {
57
- vUv = uv;
58
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
59
- }
60
- `,fragmentShader:`
61
- uniform sampler2D tDiffuse;
62
- uniform sampler2D tNormal;
63
- uniform sampler2D tDepth;
64
- uniform vec2 uResolution;
65
- uniform vec3 uColor;
66
- uniform float uOpacity;
67
- uniform float uNormalThreshold;
68
- uniform float uDepthThreshold;
69
- uniform float uThickness;
70
- uniform float uNear;
71
- uniform float uFar;
72
- uniform float uPerspective;
73
- varying vec2 vUv;
74
-
75
- float viewZOf(const in float depth) {
76
- float perspective = (uNear * uFar) / ((uFar - uNear) * depth - uFar);
77
- float orthographic = -(depth * (uFar - uNear) + uNear);
78
- return mix(orthographic, perspective, uPerspective);
79
- }
80
-
81
- void main() {
82
- vec4 color = texture2D(tDiffuse, vUv);
83
- vec2 texel = uThickness / uResolution;
84
-
85
- // Roberts cross over the two diagonal pairs.
86
- vec2 offsetA = vec2(texel.x, texel.y);
87
- vec2 offsetB = vec2(texel.x, -texel.y);
88
-
89
- float z0 = viewZOf(texture2D(tDepth, vUv + offsetA).x);
90
- float z1 = viewZOf(texture2D(tDepth, vUv - offsetA).x);
91
- float z2 = viewZOf(texture2D(tDepth, vUv + offsetB).x);
92
- float z3 = viewZOf(texture2D(tDepth, vUv - offsetB).x);
93
- float zCenter = viewZOf(texture2D(tDepth, vUv).x);
94
- // Relative difference: a constant threshold in absolute Z turns distant geometry into
95
- // noise (depth precision) and near geometry blind; normalizing by the center depth keeps
96
- // the response scale-invariant across the viewer's mm\u2192m scenes.
97
- float depthDelta = (abs(z0 - z1) + abs(z2 - z3)) / max(abs(zCenter), 1e-6);
98
- float depthEdge = step(uDepthThreshold, depthDelta);
99
-
100
- vec3 n0 = texture2D(tNormal, vUv + offsetA).rgb * 2.0 - 1.0;
101
- vec3 n1 = texture2D(tNormal, vUv - offsetA).rgb * 2.0 - 1.0;
102
- vec3 n2 = texture2D(tNormal, vUv + offsetB).rgb * 2.0 - 1.0;
103
- vec3 n3 = texture2D(tNormal, vUv - offsetB).rgb * 2.0 - 1.0;
104
- float normalDelta = (1.0 - dot(n0, n1)) + (1.0 - dot(n2, n3));
105
- float normalEdge = step(uNormalThreshold, normalDelta);
106
-
107
- float edge = max(depthEdge, normalEdge) * uOpacity;
108
- gl_FragColor = vec4(mix(color.rgb, uColor, edge), color.a);
109
- }
110
- `},ke= exports.t =class extends _Passjs.Pass{constructor(t,r,a,o,i={}){super();_chunkH3FZW6OXcjs.b.call(void 0, this,"camera");_chunkH3FZW6OXcjs.b.call(void 0, this,"scene");_chunkH3FZW6OXcjs.b.call(void 0, this,"normalMaterial");_chunkH3FZW6OXcjs.b.call(void 0, this,"edgeMaterial");_chunkH3FZW6OXcjs.b.call(void 0, this,"fsQuad");_chunkH3FZW6OXcjs.b.call(void 0, this,"normalTarget",null);_chunkH3FZW6OXcjs.b.call(void 0, this,"width");_chunkH3FZW6OXcjs.b.call(void 0, this,"height");this.scene=t,this.camera=r,this.width=Math.max(1,a),this.height=Math.max(1,o),this.normalMaterial=new N.MeshNormalMaterial,this.normalMaterial.blending=N.NoBlending,this.edgeMaterial=new N.ShaderMaterial({uniforms:N.UniformsUtils.clone(ot.uniforms),vertexShader:ot.vertexShader,fragmentShader:ot.fragmentShader});let l=this.edgeMaterial.uniforms;l.uColor.value=new N.Color(_nullishCoalesce(i.color, () => (2236962))),l.uOpacity.value=_nullishCoalesce(i.opacity, () => (1)),l.uNormalThreshold.value=_nullishCoalesce(i.normalThreshold, () => (.4)),l.uDepthThreshold.value=_nullishCoalesce(i.depthThreshold, () => (.02)),l.uThickness.value=_nullishCoalesce(i.thickness, () => (1)),this.fsQuad=new (0, _Passjs.FullScreenQuad)(this.edgeMaterial),this.needsSwap=!0}acquireNormalTarget(){if(!this.normalTarget){let t=new N.DepthTexture(this.width,this.height);this.normalTarget=new N.WebGLRenderTarget(this.width,this.height,{minFilter:N.NearestFilter,magFilter:N.NearestFilter,depthTexture:t})}return this.normalTarget}setSize(t,r){this.width=Math.max(1,t),this.height=Math.max(1,r),_optionalChain([this, 'access', _26 => _26.normalTarget, 'optionalAccess', _27 => _27.setSize, 'call', _28 => _28(this.width,this.height)])}render(t,r,a){let o=this.acquireNormalTarget(),i=t.getRenderTarget(),l=t.autoClear,s=t.getClearColor(new N.Color),c=t.getClearAlpha(),u=this.scene.overrideMaterial;t.setRenderTarget(o),t.setClearColor(7829503,1),t.autoClear=!0,this.scene.overrideMaterial=this.normalMaterial,t.render(this.scene,this.camera),this.scene.overrideMaterial=u,t.setClearColor(s,c),t.autoClear=l;let d=this.edgeMaterial.uniforms;d.tDiffuse.value=a.texture,d.tNormal.value=o.texture,d.tDepth.value=o.depthTexture,d.uResolution.value.set(this.width,this.height);let E=this.camera;d.uPerspective.value=E.isPerspectiveCamera?1:0,d.uNear.value=_nullishCoalesce(this.camera.near, () => (.1)),d.uFar.value=_nullishCoalesce(this.camera.far, () => (1e3)),t.setRenderTarget(this.renderToScreen?null:r),this.fsQuad.render(t),t.setRenderTarget(i)}dispose(){_optionalChain([this, 'access', _29 => _29.normalTarget, 'optionalAccess', _30 => _30.dispose, 'call', _31 => _31()]),this.normalMaterial.dispose(),this.edgeMaterial.dispose(),this.fsQuad.dispose()}};var _EffectComposerjs = require('three/addons/postprocessing/EffectComposer.js');var _RenderPassjs = require('three/addons/postprocessing/RenderPass.js');var _GTAOPassjs = require('three/addons/postprocessing/GTAOPass.js');var _SMAAPassjs = require('three/addons/postprocessing/SMAAPass.js');var _OutputPassjs = require('three/addons/postprocessing/OutputPass.js');function Yt(e,n,t,r,a,o){let i=new (0, _EffectComposerjs.EffectComposer)(e),l=new (0, _RenderPassjs.RenderPass)(n,t);i.addPass(l);let s=null;(_nullishCoalesce(o.ambientOcclusion, () => (!0)))&&(s=new (0, _GTAOPassjs.GTAOPass)(n,t,r,a),s.blendIntensity=_nullishCoalesce(o.aoIntensity, () => (1)),s.updateGtaoMaterial({screenSpaceRadius:!0}),i.addPass(s));let c=typeof o.edgeDetection=="object"?o.edgeDetection:{},u=new ke(n,t,r,a,c);u.enabled=!!o.edgeDetection,i.addPass(u);let d=new _SMAAPassjs.SMAAPass;i.addPass(d);let E=new _OutputPassjs.OutputPass;i.addPass(E),e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure;let T=_nullishCoalesce(o.aoPixelRatio, () => (1));return i.setSize(r,a),{render:v=>i.render(v),setSize:(v,y,m)=>{i.setPixelRatio(Math.min(m,T)),i.setSize(v,y)},setCamera:v=>{if(l.camera=v,u.camera=v,!s)return;s.camera=v;let y=v.isPerspectiveCamera?1:0;s.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==y&&(s.gtaoMaterial.defines.PERSPECTIVE_CAMERA=y,s.gtaoMaterial.needsUpdate=!0)},setEdgeDetection:v=>{u.enabled=v},edgeDetectionEnabled:()=>u.enabled,dispose:()=>{i.dispose(),_optionalChain([s, 'optionalAccess', _32 => _32.dispose, 'call', _33 => _33()]),u.dispose(),d.dispose(),E.dispose()}}}var _CSS2DRendererjs = require('three/addons/renderers/CSS2DRenderer.js');function Kt(e,n){let t=new _CSS2DRendererjs.CSS2DRenderer,r=t.domElement;r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.overflow="hidden",r.style.pointerEvents="none",r.style.zIndex="30",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(r);let a={width:e.clientWidth||1,height:e.clientHeight||1};t.setSize(a.width,a.height);let o=new Xt.Group;o.name="label-layer",o.userData.id="label-layer",n.add(o);let i=new Set;return{addLabel:(s,c,u)=>{let d=document.createElement("div");d.textContent=s,u?d.className=u:Object.assign(d.style,{padding:"2px 6px",borderRadius:"4px",background:"rgba(20, 20, 20, 0.78)",color:"#fff",font:"12px/1.3 system-ui, sans-serif",whiteSpace:"pre",textAlign:"center",userSelect:"none"}),d.style.pointerEvents="none";let E=new (0, _CSS2DRendererjs.CSS2DObject)(d);return E.position.copy(c),o.add(E),i.add(E),{object:E,setPosition:T=>E.position.copy(T),setText:T=>{d.textContent=T},remove:()=>{E.removeFromParent(),d.remove(),i.delete(E)}}},render:(s,c)=>t.render(s,c),setSize:(s,c)=>t.setSize(s,c),dispose:()=>{i.forEach(s=>{s.removeFromParent(),s.element.remove()}),i.clear(),o.removeFromParent(),r.remove()}}}var _Line2js = require('three/addons/lines/Line2.js');var _LineGeometryjs = require('three/addons/lines/LineGeometry.js');var Fr=12,Br=16763904,Zt=.015,Jt={Millimeters:{metersPerUnit:1/1e3,suffix:"mm"},Centimeters:{metersPerUnit:1/100,suffix:"cm"},Meters:{metersPerUnit:1,suffix:"m"},Inches:{metersPerUnit:1/39.37,suffix:"in"},Feet:{metersPerUnit:1/3.28084,suffix:"ft"}};function kr(e){let n=e&&Jt[e]||Jt.Meters;return t=>`${(t/n.metersPerUnit).toPrecision(3)} ${n.suffix}`}function Ur(e,n){if(e.isOrthographicCamera){let r=e;return Math.abs(r.top-r.bottom)/(r.zoom||1)*Zt}return((n?e.position.distanceTo(n):e.position.length())||1)*Zt}function Vr(e){let n=e.object;if(n instanceof V.Mesh)return e.face?[e.face.a,e.face.b,e.face.c]:null;if(n instanceof V.Points)return e.index!=null?[e.index]:null;if(n instanceof V.Line){if(e.index==null)return null;let t=n.geometry.index;return t?e.index+1>=t.count?null:[t.getX(e.index),t.getX(e.index+1)]:[e.index,e.index+1]}return null}function _r(e,n,t,r){let a=e.point.clone(),o=e.object,i=Vr(e);if(!i||!o.geometry)return a;let l=o.geometry.attributes.position;if(!l)return a;let s=E=>{let T=E.clone().project(n);return new V.Vector2((T.x+1)/2*t.width,(1-T.y)/2*t.height)},c=s(a),u=a,d=r;for(let E of i){if(E>=l.count)continue;let v=new V.Vector3().fromBufferAttribute(l,E).applyMatrix4(o.matrixWorld),y=s(v).distanceTo(c);y<d&&(d=y,u=v)}return u}function Qt(e){let{canvas:n,scene:t,getActiveCamera:r,getViewTarget:a,labelLayer:o,options:i={}}=e,l=_nullishCoalesce(i.snapPixels, () => (Fr)),s=new V.Color(_nullishCoalesce(i.color, () => (Br))),c=kr(i.displayUnit),u=(S,D)=>`${c(S)}
111
- \u0394x ${c(D.x)} \u0394y ${c(D.y)} \u0394z ${c(D.z)}`,d=_nullishCoalesce(i.format, () => (u)),E=new V.Raycaster,T=new V.Vector2,v=!1,y=[],m=[],g=null,R=null,x=new V.PointsMaterial({color:s,size:8,sizeAttenuation:!1,depthTest:!1}),M=new V.PointsMaterial({color:s,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),p=null,f=S=>{if(!S){p&&(p.visible=!1);return}if(!p){let D=new V.BufferGeometry;D.setAttribute("position",new V.Float32BufferAttribute([0,0,0],3)),p=new V.Points(D,M),p.renderOrder=1e3,p.userData.id="measure",p.raycast=()=>{},t.add(p)}p.position.copy(S),p.visible=!0},h=S=>{let D=new V.BufferGeometry;D.setAttribute("position",new V.Float32BufferAttribute([S.x,S.y,S.z],3));let G=new V.Points(D,x);return G.renderOrder=999,G.userData.id="measure",G.raycast=()=>{},t.add(G),G},b=()=>{y.length=0,m.forEach(S=>{S.geometry.dispose(),S.removeFromParent()}),m.length=0,g&&(g.geometry.dispose(),g.material.dispose(),g.removeFromParent(),g=null),_optionalChain([R, 'optionalAccess', _34 => _34.remove, 'call', _35 => _35()]),R=null},H=()=>{if(y.length!==2)return;let[S,D]=y,G=new _LineGeometryjs.LineGeometry;G.setPositions([S.x,S.y,S.z,D.x,D.y,D.z]);let j=new (0, _LineMaterialjs.LineMaterial)({color:s});j.linewidth=2,j.depthTest=!1,g=new (0, _Line2js.Line2)(G,j),g.renderOrder=998,g.userData.id="measure",g.raycast=()=>{},t.add(g);let $=S.clone().add(D).multiplyScalar(.5),U=new V.Vector3(Math.abs(D.x-S.x),Math.abs(D.y-S.y),Math.abs(D.z-S.z));R=o.addLabel(d(S.distanceTo(D),U),$,i.labelClassName)},C=S=>{let D=n.getBoundingClientRect();T.x=(S.clientX-D.left)/D.width*2-1,T.y=-((S.clientY-D.top)/D.height)*2+1;let G=r();E.setFromCamera(T,G);let j=Ur(G,_optionalChain([a, 'optionalCall', _36 => _36()]));E.params.Line.threshold=j,E.params.Points.threshold=j;let $=E.intersectObjects(t.children,!0).filter(U=>U.object.userData.id!=="measure"&&U.object.userData.id!=="grid");return $.length===0?null:_r($[0],G,{width:D.width,height:D.height},l)},L=null,P=0,k=()=>{P&&(cancelAnimationFrame(P),P=0),L=null};return{setEnabled:S=>{v=S,S||(k(),b(),f(null))},isEnabled:()=>v,handleClick:S=>{if(!v)return!1;y.length===2&&b();let D=C(S);return D===null||(y.push(D),m.push(h(D)),y.length===2&&H()),!0},handleMove:S=>{v&&(L=S,!P&&(P=requestAnimationFrame(()=>{P=0;let D=L;L=null,!(!v||!D)&&f(C(D))})))},clear:b,dispose:()=>{k(),b(),p&&(p.geometry.dispose(),p.removeFromParent(),p=null),x.dispose(),M.dispose()}}}var zr=64,Gr=256,oe=new Map,Me=new Map,Ue=0,_e=class extends Error{constructor(n){super(`Texture load for ${n} resolved after clearTextureCache(); texture disposed.`),this.name="StaleTextureLoadError"}},Ve=1;function en(e){Ve=Math.max(1,e);for(let n of oe.values())n.anisotropy!==Ve&&(n.anisotropy=Ve,n.needsUpdate=!0)}function tn(e,n){let t=Nr(n),r=oe.get(t);if(r){oe.delete(t),oe.set(t,r),e.map=r,e.needsUpdate=!0;return}typeof document>"u"||$r(n,t).then(a=>{e.map=a,e.needsUpdate=!0}).catch(a=>{a instanceof _e||_chunkH3FZW6OXcjs.e.call(void 0, ).warn(`Failed to load material texture ${n}:`,a)})}function ai(){Ue++;for(let e of oe.values())e.dispose();oe.clear(),Me.clear()}function Nr(e){return e.length<=Gr?e:`data-uri:${jr(e).toString(16)}:${e.length}`}function jr(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return n>>>0}function Wr(e,n){for(oe.set(e,n);oe.size>zr;){let t=oe.keys().next().value,r=oe.get(t);oe.delete(t),r.dispose()}}function $r(e,n){let t=Me.get(n);if(!t){let r=Ue;t=new Promise((a,o)=>{new ze.TextureLoader().load(e,i=>{if(r!==Ue){i.dispose(),o(new _e(e));return}i.colorSpace=ze.SRGBColorSpace,i.anisotropy=Ve,Wr(n,i),Me.delete(n),a(i)},void 0,i=>{r===Ue&&Me.delete(n),o(i)})}),Me.set(n,t)}return t}var _OrbitControlsjs = require('three/addons/controls/OrbitControls.js');var _HDRLoaderjs = require('three/addons/loaders/HDRLoader.js');var qr=.5,Yr=.01,Xr=.05;function nn({camera:e,scene:n,groundNormals:t=[]}){let r=e.near,a=e.near,o=new He.Vector3,i=new He.Vector3;return{update:()=>{e.near!==a&&(r=e.near);let s=le(n),c=r;if(!s.isEmpty()){let u=s.getSize(i).length()*.5,d=e.position.distanceTo(s.getCenter(o))-u;for(let E of t)d=Math.min(d,Math.abs(e.position.dot(E)));c=He.MathUtils.clamp(d*qr,r,e.far*Yr)}Math.abs(c-a)>a*Xr&&(e.near=c,e.updateProjectionMatrix(),a=c)}}}var ue=new w.Vector3(0,0,1),Jr="technical",at={studio:{toneMapping:w.ACESFilmicToneMapping,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.75,ambientIntensity:.4,cullBackfaces:!1,ambientOcclusion:!1},technical:{toneMapping:w.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:.9,environmentIntensity:1,hemisphereIntensity:.35,ambientIntensity:.25,cullBackfaces:!1,ambientOcclusion:!1},showcase:{toneMapping:w.ACESFilmicToneMapping,toneMappingExposure:1.15,envMapIntensity:1.4,environmentIntensity:1.25,hemisphereIntensity:.35,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!1}};function Qr(e){let n=at[e];return{envMapIntensity:n.envMapIntensity,cullBackfaces:n.cullBackfaces}}var vi=function(e,n){let t=eo(n||{}),r=_optionalChain([t, 'access', _37 => _37.environment, 'optionalAccess', _38 => _38.sceneUp])||ue,a=_nullishCoalesce(t.render.pixelRatio, () => (Math.min(window.devicePixelRatio,2))),o=no(t),i=so(t,e);i.up.copy(r);let l=lo(e,t,a);en(l.capabilities.getMaxAnisotropy());let s=uo(i,e,t),c=St({scene:o,perspective:i,controls:s,onActiveCameraChange:()=>{},up:r}),u=()=>c.getActiveCamera(),d=!1;oo(o,l,t,()=>d);let E=ao(o,t),T=E.sun,v=()=>{T&&to(T,le(o))};_optionalChain([t, 'access', _39 => _39.floor, 'optionalAccess', _40 => _40.enabled])&&io(o,t);let y=t.grid.enabled?Dt({cellSize:t.grid.cellSize,majorEvery:t.grid.majorEvery,cellColor:t.grid.cellColor,majorColor:t.grid.majorColor,fadeDistance:t.grid.fadeDistance,plane:t.grid.plane}):null;y&&o.add(y.object);let m=()=>{y&&y.fitToContent(le(o))},g=t.gizmo.enabled?Lt({camera:i,domElement:e,controller:c}):null,R=[];if(y){let A=_nullishCoalesce(t.grid.plane, () => (Xe(r)));R.push(new w.Vector3(A==="x"?1:0,A==="y"?1:0,A==="z"?1:0))}t.floor.enabled&&R.push(r.clone().normalize());let x=t.camera.dynamicNear?nn({camera:i,scene:o,groundNormals:R}):null,M=_nullishCoalesce(e.parentElement, () => (e)),p=t.measure.enabled?Kt(M,o):null,f=t.measure.enabled&&p?Qt({canvas:e,scene:o,getActiveCamera:u,labelLayer:p,options:{snapPixels:t.measure.snapPixels,color:t.measure.color,labelClassName:t.measure.labelClassName,displayUnit:t.measure.displayUnit,format:t.measure.format}}):null,h=t.events.enableEventHandlers!==!1?co(e,o,c,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},b=5,H=0,C=0,L=A=>{H=A.clientX,C=A.clientY},P=A=>Math.hypot(A.clientX-H,A.clientY-C)>b,k=A=>{if(!P(A)){if(_optionalChain([f, 'optionalAccess', _41 => _41.handleClick, 'call', _42 => _42(A)])){A.stopImmediatePropagation();return}_optionalChain([g, 'optionalAccess', _43 => _43.handleClick, 'call', _44 => _44(A)])&&A.stopImmediatePropagation()}};(g||f)&&(e.addEventListener("mousedown",L,{capture:!0}),e.addEventListener("click",k,{capture:!0}));let O=A=>_optionalChain([f, 'optionalAccess', _45 => _45.handleMove, 'call', _46 => _46(A)]);f&&e.addEventListener("mousemove",O,{passive:!0});let I=()=>{},S=A=>{$t(A,{color:t.edges.color,darken:t.edges.darken,width:t.edges.width,thresholdAngle:t.edges.thresholdAngle,distanceFade:t.edges.distanceFade,maxTriangles:t.edges.maxTriangles,maxSegments:t.edges.maxSegments}).then(()=>{D(A),I()})},D=A=>{if(t.edges.screenSpaceFallback===!1)return;let B=!1;A.traverse(K=>{_optionalChain([K, 'access', _47 => _47.userData, 'optionalAccess', _48 => _48.edgesSkipped])===rt&&(B=!0)}),B!==X&&(X=B,te())},G=A=>{qt(A),X&&(X=!1,te()),I()},j=e.parentElement,$=()=>j?{width:j.clientWidth,height:j.clientHeight}:{width:window.innerWidth,height:window.innerHeight},U=null,J=!!t.render.ambientOcclusion,X=!1,me=!1,Ee=A=>{let{width:B,height:K}=$(),he=Yt(l,o,u(),Math.max(1,B),Math.max(1,K),{toneMapping:_nullishCoalesce(t.render.toneMapping, () => (w.NeutralToneMapping)),toneMappingExposure:_nullishCoalesce(t.render.toneMappingExposure, () => (1)),ambientOcclusion:A,aoIntensity:t.render.aoIntensity,aoPixelRatio:t.render.aoPixelRatio,edgeDetection:!1});return he.setSize(Math.max(1,B),Math.max(1,K),a),he},te=()=>{if(!(J||X)){_optionalChain([U, 'optionalAccess', _49 => _49.dispose, 'call', _50 => _50()]),U=null,I();return}(!U||me!==J)&&(_optionalChain([U, 'optionalAccess', _51 => _51.dispose, 'call', _52 => _52()]),U=Ee(J),me=J),U.setEdgeDetection(X),I()},se=()=>{_optionalChain([U, 'optionalAccess', _53 => _53.dispose, 'call', _54 => _54()]),U=null,te()},De=A=>{J=A,te()};te();let fe=A=>{A.ambientIntensity!==void 0&&(E.ambient.intensity=A.ambientIntensity),A.hemisphereIntensity!==void 0&&!E.hemisphere&&A.hemisphereIntensity>0&&(E.hemisphere=new w.HemisphereLight(_nullishCoalesce(A.hemisphereSkyColor, () => (t.lighting.hemisphereSkyColor)),_nullishCoalesce(A.hemisphereGroundColor, () => (t.lighting.hemisphereGroundColor)),A.hemisphereIntensity),E.hemisphere.position.copy(_nullishCoalesce(t.environment.sceneUp, () => (ue))),o.add(E.hemisphere)),E.hemisphere&&(A.hemisphereIntensity!==void 0&&(E.hemisphere.intensity=A.hemisphereIntensity),A.hemisphereSkyColor!==void 0&&E.hemisphere.color.set(A.hemisphereSkyColor),A.hemisphereGroundColor!==void 0&&E.hemisphere.groundColor.set(A.hemisphereGroundColor)),I()},be=A=>{t.environment.environmentIntensity=A,o.environmentIntensity=A,I()},qe=A=>{t.render.toneMappingExposure=A,l.toneMappingExposure=A,U&&se()},Cn=A=>{t.render.aoIntensity=A,U&&se()},An=A=>{let B=at[A];ft=A,l.toneMapping=B.toneMapping,l.toneMappingExposure=B.toneMappingExposure,t.render.toneMapping=B.toneMapping,t.render.toneMappingExposure=B.toneMappingExposure,fe({hemisphereIntensity:B.hemisphereIntensity,ambientIntensity:B.ambientIntensity}),be(B.environmentIntensity),J=B.ambientOcclusion,U?se():te(),o.traverse(K=>{if(K.userData.source!=="compute")return;let he=K,Fn=Array.isArray(he.material)?he.material:he.material?[he.material]:[];for(let ht of Fn)"envMapIntensity"in ht&&(ht.envMapIntensity=B.envMapIntensity)}),I()},ft=t.look,Sn=()=>Qr(ft),{animate:Dn,dispose:Ln,invalidate:pt}=ro(l,o,i,u,c,s,$,a,t.events.onFrame,y,g,()=>U,p,x,_nullishCoalesce(t.render.onDemand, () => (!0)));I=pt,Dn(),o.up.set(r.x,r.y,r.z),v(),m();let Et=A=>{A.traverse(B=>{let K=B;!K.geometry&&!K.material||(_optionalChain([K, 'access', _55 => _55.geometry, 'optionalAccess', _56 => _56.dispose, 'call', _57 => _57()]),Array.isArray(K.material)?K.material.forEach(Ge):K.material&&Ge(K.material))})},On=A=>{A.userData.source="user",o.add(A)},In=A=>{A.removeFromParent(),Et(A)},Pn=()=>{o.children.filter(B=>B.userData.source==="user").forEach(B=>{B.removeFromParent(),Et(B)})};return{scene:o,camera:i,controls:s,renderer:l,cameraController:c,grid:y,gizmo:g,measureTool:f,applyEdges:S,clearEdges:G,invalidate:pt,setAmbientOcclusion:De,setLook:An,setFillLights:fe,setEnvironmentIntensity:be,setToneMappingExposure:qe,setAoIntensity:Cn,getMaterialAppearance:Sn,updateShadowBounds:v,updateGridScale:m,dispose:()=>{d||(d=!0,Ln(),h.dispose(),(g||f)&&(e.removeEventListener("mousedown",L,{capture:!0}),e.removeEventListener("click",k,{capture:!0})),f&&e.removeEventListener("mousemove",O),_optionalChain([f, 'optionalAccess', _58 => _58.dispose, 'call', _59 => _59()]),_optionalChain([p, 'optionalAccess', _60 => _60.dispose, 'call', _61 => _61()]),_optionalChain([g, 'optionalAccess', _62 => _62.dispose, 'call', _63 => _63()]),_optionalChain([y, 'optionalAccess', _64 => _64.dispose, 'call', _65 => _65()]),_optionalChain([U, 'optionalAccess', _66 => _66.dispose, 'call', _67 => _67()]),c.dispose(),s.dispose(),l.dispose(),l.forceContextLoss(),o.traverse(A=>{let B=A;!B.geometry&&!B.material||(_optionalChain([B, 'access', _68 => _68.geometry, 'optionalAccess', _69 => _69.dispose, 'call', _70 => _70()]),Array.isArray(B.material)?B.material.forEach(Ge):B.material&&Ge(B.material))}),_optionalChain([o, 'access', _71 => _71.environment, 'optionalAccess', _72 => _72.dispose, 'call', _73 => _73()]),o.background instanceof w.Texture&&o.background.dispose())},fitToView:h.fitToView,clearSelection:h.clearSelection,addUserGeometry:On,removeUserGeometry:In,clearUserGeometry:Pn}};function eo(e){let n=e.sceneScale||"m",r={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[n],a=_nullishCoalesce(e.look, () => (Jr)),o=at[a];return{sceneScale:n,look:a,camera:{position:_optionalChain([e, 'access', _74 => _74.camera, 'optionalAccess', _75 => _75.position])||Le(_nullishCoalesce(_optionalChain([e, 'access', _76 => _76.environment, 'optionalAccess', _77 => _77.sceneUp]), () => (ue)),r.cameraDistance*Math.sqrt(3)),fov:_optionalChain([e, 'access', _78 => _78.camera, 'optionalAccess', _79 => _79.fov])||20,near:_optionalChain([e, 'access', _80 => _80.camera, 'optionalAccess', _81 => _81.near])||r.near,far:_optionalChain([e, 'access', _82 => _82.camera, 'optionalAccess', _83 => _83.far])||r.far,target:_optionalChain([e, 'access', _84 => _84.camera, 'optionalAccess', _85 => _85.target])||new w.Vector3(0,0,0),dynamicNear:_nullishCoalesce(_optionalChain([e, 'access', _86 => _86.camera, 'optionalAccess', _87 => _87.dynamicNear]), () => (!0))},lighting:{enableSunlight:_nullishCoalesce(_optionalChain([e, 'access', _88 => _88.lighting, 'optionalAccess', _89 => _89.enableSunlight]), () => (!0)),sunlightIntensity:_nullishCoalesce(_optionalChain([e, 'access', _90 => _90.lighting, 'optionalAccess', _91 => _91.sunlightIntensity]), () => (1)),sunlightPosition:_optionalChain([e, 'access', _92 => _92.lighting, 'optionalAccess', _93 => _93.sunlightPosition])||Mt(_nullishCoalesce(_optionalChain([e, 'access', _94 => _94.environment, 'optionalAccess', _95 => _95.sceneUp]), () => (ue)),r.lightDistance,r.lightHeight),ambientLightColor:_optionalChain([e, 'access', _96 => _96.lighting, 'optionalAccess', _97 => _97.ambientLightColor])||new w.Color(4210752),ambientLightIntensity:_nullishCoalesce(_optionalChain([e, 'access', _98 => _98.lighting, 'optionalAccess', _99 => _99.ambientLightIntensity]), () => (o.ambientIntensity)),sunlightColor:_optionalChain([e, 'access', _100 => _100.lighting, 'optionalAccess', _101 => _101.sunlightColor])||16777215,enableHemisphereLight:_nullishCoalesce(_optionalChain([e, 'access', _102 => _102.lighting, 'optionalAccess', _103 => _103.enableHemisphereLight]), () => (o.hemisphereIntensity>0)),hemisphereSkyColor:_nullishCoalesce(_optionalChain([e, 'access', _104 => _104.lighting, 'optionalAccess', _105 => _105.hemisphereSkyColor]), () => (14673663)),hemisphereGroundColor:_nullishCoalesce(_optionalChain([e, 'access', _106 => _106.lighting, 'optionalAccess', _107 => _107.hemisphereGroundColor]), () => (7036754)),hemisphereIntensity:_nullishCoalesce(_optionalChain([e, 'access', _108 => _108.lighting, 'optionalAccess', _109 => _109.hemisphereIntensity]), () => (o.hemisphereIntensity))},environment:{hdrPath:_optionalChain([e, 'access', _110 => _110.environment, 'optionalAccess', _111 => _111.hdrPath])||"/baseHDR.hdr",backgroundColor:_optionalChain([e, 'access', _112 => _112.environment, 'optionalAccess', _113 => _113.backgroundColor])||new w.Color(15790320),enableEnvironmentLighting:_nullishCoalesce(_optionalChain([e, 'access', _114 => _114.environment, 'optionalAccess', _115 => _115.enableEnvironmentLighting]), () => (!0)),sceneUp:_optionalChain([e, 'access', _116 => _116.environment, 'optionalAccess', _117 => _117.sceneUp])||ue,showEnvironment:_nullishCoalesce(_optionalChain([e, 'access', _118 => _118.environment, 'optionalAccess', _119 => _119.showEnvironment]), () => (!1)),environmentIntensity:_nullishCoalesce(_optionalChain([e, 'access', _120 => _120.environment, 'optionalAccess', _121 => _121.environmentIntensity]), () => (o.environmentIntensity))},floor:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _122 => _122.floor, 'optionalAccess', _123 => _123.enabled]), () => (!1)),size:_optionalChain([e, 'access', _124 => _124.floor, 'optionalAccess', _125 => _125.size])||r.floorSize,color:_optionalChain([e, 'access', _126 => _126.floor, 'optionalAccess', _127 => _127.color])||new w.Color(8421504),roughness:_nullishCoalesce(_optionalChain([e, 'access', _128 => _128.floor, 'optionalAccess', _129 => _129.roughness]), () => (.7)),metalness:_nullishCoalesce(_optionalChain([e, 'access', _130 => _130.floor, 'optionalAccess', _131 => _131.metalness]), () => (0)),receiveShadow:_nullishCoalesce(_optionalChain([e, 'access', _132 => _132.floor, 'optionalAccess', _133 => _133.receiveShadow]), () => (!0))},render:{enableShadows:_nullishCoalesce(_optionalChain([e, 'access', _134 => _134.render, 'optionalAccess', _135 => _135.enableShadows]), () => (!0)),shadowMapSize:_optionalChain([e, 'access', _136 => _136.render, 'optionalAccess', _137 => _137.shadowMapSize])||2048,antialias:_nullishCoalesce(_optionalChain([e, 'access', _138 => _138.render, 'optionalAccess', _139 => _139.antialias]), () => (!0)),pixelRatio:_optionalChain([e, 'access', _140 => _140.render, 'optionalAccess', _141 => _141.pixelRatio])||Math.min(window.devicePixelRatio,2),toneMapping:_nullishCoalesce(_optionalChain([e, 'access', _142 => _142.render, 'optionalAccess', _143 => _143.toneMapping]), () => (o.toneMapping)),toneMappingExposure:_nullishCoalesce(_optionalChain([e, 'access', _144 => _144.render, 'optionalAccess', _145 => _145.toneMappingExposure]), () => (o.toneMappingExposure)),preserveDrawingBuffer:_nullishCoalesce(_optionalChain([e, 'access', _146 => _146.render, 'optionalAccess', _147 => _147.preserveDrawingBuffer]), () => (!1)),ambientOcclusion:_nullishCoalesce(_optionalChain([e, 'access', _148 => _148.render, 'optionalAccess', _149 => _149.ambientOcclusion]), () => (o.ambientOcclusion)),aoIntensity:_nullishCoalesce(_optionalChain([e, 'access', _150 => _150.render, 'optionalAccess', _151 => _151.aoIntensity]), () => (1)),aoPixelRatio:_nullishCoalesce(_optionalChain([e, 'access', _152 => _152.render, 'optionalAccess', _153 => _153.aoPixelRatio]), () => (1)),onDemand:_nullishCoalesce(_optionalChain([e, 'access', _154 => _154.render, 'optionalAccess', _155 => _155.onDemand]), () => (!0))},controls:{enableDamping:_nullishCoalesce(_optionalChain([e, 'access', _156 => _156.controls, 'optionalAccess', _157 => _157.enableDamping]), () => (!1)),dampingFactor:_optionalChain([e, 'access', _158 => _158.controls, 'optionalAccess', _159 => _159.dampingFactor])||.05,autoRotate:_nullishCoalesce(_optionalChain([e, 'access', _160 => _160.controls, 'optionalAccess', _161 => _161.autoRotate]), () => (!1)),autoRotateSpeed:_optionalChain([e, 'access', _162 => _162.controls, 'optionalAccess', _163 => _163.autoRotateSpeed])||.5,enableZoom:_nullishCoalesce(_optionalChain([e, 'access', _164 => _164.controls, 'optionalAccess', _165 => _165.enableZoom]), () => (!0)),enablePan:_nullishCoalesce(_optionalChain([e, 'access', _166 => _166.controls, 'optionalAccess', _167 => _167.enablePan]), () => (!0)),minDistance:_optionalChain([e, 'access', _168 => _168.controls, 'optionalAccess', _169 => _169.minDistance])||r.minDistance,maxDistance:_optionalChain([e, 'access', _170 => _170.controls, 'optionalAccess', _171 => _171.maxDistance])||1/0},grid:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _172 => _172.grid, 'optionalAccess', _173 => _173.enabled]), () => (!1)),cellSize:_nullishCoalesce(_optionalChain([e, 'access', _174 => _174.grid, 'optionalAccess', _175 => _175.cellSize]), () => (1)),majorEvery:_nullishCoalesce(_optionalChain([e, 'access', _176 => _176.grid, 'optionalAccess', _177 => _177.majorEvery]), () => (10)),cellColor:_nullishCoalesce(_optionalChain([e, 'access', _178 => _178.grid, 'optionalAccess', _179 => _179.cellColor]), () => (8947848)),majorColor:_nullishCoalesce(_optionalChain([e, 'access', _180 => _180.grid, 'optionalAccess', _181 => _181.majorColor]), () => (4473924)),fadeDistance:_nullishCoalesce(_optionalChain([e, 'access', _182 => _182.grid, 'optionalAccess', _183 => _183.fadeDistance]), () => (100)),plane:_nullishCoalesce(_optionalChain([e, 'access', _184 => _184.grid, 'optionalAccess', _185 => _185.plane]), () => (Xe(_nullishCoalesce(_optionalChain([e, 'access', _186 => _186.environment, 'optionalAccess', _187 => _187.sceneUp]), () => (ue)))))},gizmo:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _188 => _188.gizmo, 'optionalAccess', _189 => _189.enabled]), () => (!1))},edges:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _190 => _190.edges, 'optionalAccess', _191 => _191.enabled]), () => (!1)),color:_optionalChain([e, 'access', _192 => _192.edges, 'optionalAccess', _193 => _193.color]),darken:_optionalChain([e, 'access', _194 => _194.edges, 'optionalAccess', _195 => _195.darken]),width:_nullishCoalesce(_optionalChain([e, 'access', _196 => _196.edges, 'optionalAccess', _197 => _197.width]), () => (1.5)),thresholdAngle:_nullishCoalesce(_optionalChain([e, 'access', _198 => _198.edges, 'optionalAccess', _199 => _199.thresholdAngle]), () => (44)),distanceFade:_nullishCoalesce(_optionalChain([e, 'access', _200 => _200.edges, 'optionalAccess', _201 => _201.distanceFade]), () => (!0))},measure:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _202 => _202.measure, 'optionalAccess', _203 => _203.enabled]), () => (!1)),snapPixels:_optionalChain([e, 'access', _204 => _204.measure, 'optionalAccess', _205 => _205.snapPixels]),color:_optionalChain([e, 'access', _206 => _206.measure, 'optionalAccess', _207 => _207.color]),labelClassName:_optionalChain([e, 'access', _208 => _208.measure, 'optionalAccess', _209 => _209.labelClassName]),displayUnit:_optionalChain([e, 'access', _210 => _210.measure, 'optionalAccess', _211 => _211.displayUnit]),format:_optionalChain([e, 'access', _212 => _212.measure, 'optionalAccess', _213 => _213.format])},events:{onBackgroundClicked:_optionalChain([e, 'access', _214 => _214.events, 'optionalAccess', _215 => _215.onBackgroundClicked]),onObjectSelected:_optionalChain([e, 'access', _216 => _216.events, 'optionalAccess', _217 => _217.onObjectSelected]),onMeshMetadataClicked:_optionalChain([e, 'access', _218 => _218.events, 'optionalAccess', _219 => _219.onMeshMetadataClicked]),onMeshDoubleClicked:_optionalChain([e, 'access', _220 => _220.events, 'optionalAccess', _221 => _221.onMeshDoubleClicked]),selectionColor:_optionalChain([e, 'access', _222 => _222.events, 'optionalAccess', _223 => _223.selectionColor])||"#ff0000",enableEventHandlers:_nullishCoalesce(_optionalChain([e, 'access', _224 => _224.events, 'optionalAccess', _225 => _225.enableEventHandlers]), () => (!0)),enableKeyboardControls:_nullishCoalesce(_optionalChain([e, 'access', _226 => _226.events, 'optionalAccess', _227 => _227.enableKeyboardControls]), () => (!0)),enableClickToFocus:_nullishCoalesce(_optionalChain([e, 'access', _228 => _228.events, 'optionalAccess', _229 => _229.enableClickToFocus]), () => (!0)),enableDoubleClickZoom:_nullishCoalesce(_optionalChain([e, 'access', _230 => _230.events, 'optionalAccess', _231 => _231.enableDoubleClickZoom]), () => (!0)),onReady:_optionalChain([e, 'access', _232 => _232.events, 'optionalAccess', _233 => _233.onReady]),onFrame:_optionalChain([e, 'access', _234 => _234.events, 'optionalAccess', _235 => _235.onFrame])}}}function Ge(e){for(let n of Object.values(e))n instanceof w.Texture&&n.dispose();e.dispose()}function to(e,n){if(n.isEmpty())return;let t=n.getCenter(new w.Vector3),r=n.getSize(new w.Vector3).length()*.5*1.2,a=e.shadow.camera;a.left=-r,a.right=r,a.top=r,a.bottom=-r,e.target.position.copy(t),e.target.updateMatrixWorld();let o=e.position.distanceTo(t);a.near=Math.max(r*.01,o-r),a.far=o+r,a.updateProjectionMatrix()}function no(e){let n=new w.Scene,t=typeof e.environment.backgroundColor=="string"?new w.Color(e.environment.backgroundColor):e.environment.backgroundColor;return n.background=t||null,n}function ro(e,n,t,r,a,o,i,l,s,c,u,d,E,T,v=!0){let y=null,m=performance.now(),g=!0,R=0,x=500,M=new w.Matrix4,p=new w.Matrix4,f=null,h=()=>{g=!0},b=O=>{O.updateMatrixWorld();let I=f!==O||!M.equals(O.matrixWorld)||!p.equals(O.projectionMatrix);return I&&(f=O,M.copy(O.matrixWorld),p.copy(O.projectionMatrix)),I},H=e.domElement,C=["pointerdown","pointerup","wheel"];if(v)for(let O of C)H.addEventListener(O,h,{passive:!0});let L=()=>{let{width:O,height:I}=i();if(O===0||I===0)return;let S=Math.floor(O*l),D=Math.floor(I*l);(e.domElement.width!==S||e.domElement.height!==D)&&(e.setPixelRatio(l),e.setSize(O,I,!1),t.aspect=O/I,t.updateProjectionMatrix(),a.updateAspect(O,I),_optionalChain([d, 'optionalCall', _236 => _236(), 'optionalAccess', _237 => _237.setSize, 'call', _238 => _238(O,I,l)]),_optionalChain([E, 'optionalAccess', _239 => _239.setSize, 'call', _240 => _240(O,I)]),h())},P=function(){y=requestAnimationFrame(P);let O=performance.now(),I=(O-m)/1e3;m=O,L(),(o.enableDamping||o.autoRotate)&&o.update(),c&&c.update(r().position),u&&u.update(I),T&&T.update(),_optionalChain([s, 'optionalCall', _241 => _241(I)]);let S=r();if(v){if(!(g||b(S)||O-R>=x))return;g=!1,R=O}let D=_optionalChain([d, 'optionalCall', _242 => _242()]);D?(D.setCamera(S),D.render(I)):e.render(n,S),E&&E.render(n,S),u&&u.render(e)};return{animate:P,dispose:()=>{if(y!==null&&(cancelAnimationFrame(y),y=null),v)for(let O of C)H.removeEventListener(O,h)},invalidate:h}}function oo(e,n,t,r){t.environment.enableEnvironmentLighting?new (0, _HDRLoaderjs.HDRLoader)().load(t.environment.hdrPath||"/baseHDR.hdr",function(a){if(r()){a.dispose();return}if(!_optionalChain([a, 'optionalAccess', _243 => _243.image])){_chunkH3FZW6OXcjs.e.call(void 0, ).warn("HDR loaded without image data; skipping environment map."),_optionalChain([a, 'optionalAccess', _244 => _244.dispose, 'call', _245 => _245()]),_optionalChain([t, 'access', _246 => _246.events, 'access', _247 => _247.onReady, 'optionalCall', _248 => _248()]);return}a.mapping=w.EquirectangularReflectionMapping;let o=new w.PMREMGenerator(n);o.compileEquirectangularShader();let i=o.fromEquirectangular(a).texture;o.dispose(),e.environment=i,e.environmentIntensity=_nullishCoalesce(t.environment.environmentIntensity, () => (1));let l=Ht(_nullishCoalesce(t.environment.sceneUp, () => (ue)));e.environmentRotation.copy(l),t.environment.showEnvironment?(e.background=a,e.backgroundRotation.copy(l)):a.dispose(),_optionalChain([t, 'access', _249 => _249.events, 'access', _250 => _250.onReady, 'optionalCall', _251 => _251()])},void 0,function(a){r()||(_chunkH3FZW6OXcjs.e.call(void 0, ).warn("HDR texture could not be loaded, falling back to basic lighting:",a),_optionalChain([t, 'access', _252 => _252.events, 'access', _253 => _253.onReady, 'optionalCall', _254 => _254()]))}):_optionalChain([t, 'access', _255 => _255.events, 'access', _256 => _256.onReady, 'optionalCall', _257 => _257()])}function ao(e,n){let t=new w.AmbientLight(n.lighting.ambientLightColor,n.lighting.ambientLightIntensity);e.add(t);let r=null;if(n.lighting.enableHemisphereLight){r=new w.HemisphereLight(n.lighting.hemisphereSkyColor,n.lighting.hemisphereGroundColor,n.lighting.hemisphereIntensity);let i=_nullishCoalesce(n.environment.sceneUp, () => (ue));r.position.copy(i),e.add(r)}if(!n.lighting.enableSunlight)return{ambient:t,hemisphere:r,sun:null};let a=new w.DirectionalLight(_nullishCoalesce(n.lighting.sunlightColor, () => (16777215)),n.lighting.sunlightIntensity),o=n.lighting.sunlightPosition;return o&&a.position.set(o.x,o.y,o.z),n.render.enableShadows?(a.castShadow=!0,a.shadow.mapSize.width=n.render.shadowMapSize||2048,a.shadow.mapSize.height=n.render.shadowMapSize||2048,a.shadow.bias=-1e-4,a.shadow.normalBias=.02,a.shadow.radius=4,e.add(a),e.add(a.target),{ambient:t,hemisphere:r,sun:a}):(e.add(a),{ambient:t,hemisphere:r,sun:null})}function io(e,n){let t=n.floor.size,r=new w.PlaneGeometry(t,t),a=typeof n.floor.color=="string"?new w.Color(n.floor.color):n.floor.color,o=new w.MeshStandardMaterial({color:a,roughness:n.floor.roughness,metalness:n.floor.metalness,side:w.DoubleSide}),i=new w.Mesh(r,o);i.userData.id="floor",i.name="floor";let l=(_optionalChain([n, 'access', _258 => _258.environment, 'optionalAccess', _259 => _259.sceneUp])||ue).clone().normalize();i.quaternion.setFromUnitVectors(new w.Vector3(0,0,1),l),i.position.set(0,0,0),n.floor.receiveShadow&&n.render.enableShadows&&(i.receiveShadow=!0),e.add(i)}function so(e,n){let t=n.parentElement,r=t?t.clientWidth:window.innerWidth,a=t?t.clientHeight:window.innerHeight,o=new w.PerspectiveCamera(e.camera.fov,r/a,e.camera.near,e.camera.far),i=e.camera.position;return i&&o.position.set(i.x,i.y,i.z),o}function lo(e,n,t){let r=new w.WebGLRenderer({antialias:n.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:n.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),a=e.parentElement,o=a?a.clientWidth:window.innerWidth,i=a?a.clientHeight:window.innerHeight;return a&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),r.setSize(o,i,!1),r.setPixelRatio(t),n.render.enableShadows&&(r.shadowMap.enabled=!0,r.shadowMap.type=w.VSMShadowMap),r.toneMapping=n.render.toneMapping,r.toneMappingExposure=_nullishCoalesce(n.render.toneMappingExposure, () => (1)),r.outputColorSpace=w.SRGBColorSpace,r.sortObjects=!0,r}function co(e,n,t,r){let a=new Set,o=new Map,i=new w.Raycaster,l=new w.Vector2,s=new w.Vector2,c=()=>t.getActiveCamera(),u=p=>{let f=p;for(;f;){if(!f.visible)return!1;f=f.parent}return!0},d=()=>{let p=le(n);if(p.isEmpty()){_chunkH3FZW6OXcjs.e.call(void 0, ).warn("No objects to fit to view");return}t.frameBounds(p,!1)},E=typeof r.events.selectionColor=="string"?new w.Color(r.events.selectionColor):r.events.selectionColor instanceof w.Color?r.events.selectionColor:new w.Color("#ff0000"),T=()=>{a.forEach(p=>{let f=p;if(o.has(p)){let h=o.get(p),b=f.material;b instanceof w.Material?b.dispose():Array.isArray(b)&&b.forEach(C=>C.dispose()),f.material=h,o.delete(p);let H=p;for(;H.parent;)H=H.parent;H!==n&&(h instanceof w.Material?h.dispose():h.forEach(C=>C.dispose()))}}),a.clear()},v=p=>{let f=p;if(!(f.material instanceof w.Material))return!1;o.set(p,f.material);let h=f.material.clone();return p instanceof w.Mesh&&"emissive"in h?h.emissive=E.clone():"color"in h&&(h.color=E.clone()),f.material=h,!0},y=()=>{let p=le(n),f=p.isEmpty()?1:p.getSize(new w.Vector3).length();i.params.Points.threshold=f*.01},m=p=>{s.set(p.clientX,p.clientY)},g=p=>{let f=new w.Vector2(p.clientX,p.clientY);if(s.distanceTo(f)>5)return;let h=e.getBoundingClientRect();l.x=(p.clientX-h.left)/h.width*2-1,l.y=-((p.clientY-h.top)/h.height)*2+1,y(),i.setFromCamera(l,c());let b=i.intersectObjects(n.children,!0).filter(H=>u(H.object));if(b.length>0){let H=b[0].object;a.has(H)||(T(),a.add(H),v(H),_optionalChain([r, 'access', _260 => _260.events, 'optionalAccess', _261 => _261.onObjectSelected, 'optionalCall', _262 => _262(H)]),H instanceof w.Mesh&&Object.keys(H.userData).length>0&&_optionalChain([r, 'access', _263 => _263.events, 'optionalAccess', _264 => _264.onMeshMetadataClicked, 'optionalCall', _265 => _265(H.userData)]))}else T(),_optionalChain([r, 'access', _266 => _266.events, 'optionalAccess', _267 => _267.onBackgroundClicked, 'optionalCall', _268 => _268({x:l.x,y:l.y})])},R=p=>{let f=e.getBoundingClientRect();l.x=(p.clientX-f.left)/f.width*2-1,l.y=-((p.clientY-f.top)/f.height)*2+1,y(),i.setFromCamera(l,c());let h=i.intersectObjects(n.children,!0).filter(C=>u(C.object));if(h.length===0)return;let b=h[0].object;if(_optionalChain([r, 'access', _269 => _269.events, 'optionalAccess', _270 => _270.onMeshDoubleClicked, 'optionalCall', _271 => _271(b)]),!_optionalChain([r, 'access', _272 => _272.events, 'optionalAccess', _273 => _273.enableDoubleClickZoom]))return;let H=new w.Box3().setFromObject(b);H.isEmpty()||t.frameBounds(H,!0)},x=p=>{if(_optionalChain([r, 'access', _274 => _274.events, 'optionalAccess', _275 => _275.enableKeyboardControls]))switch(p.key.toLowerCase()){case"f":p.preventDefault(),d();break;case"escape":p.preventDefault(),T();break;case" ":p.preventDefault(),d();break}};return _optionalChain([r, 'access', _276 => _276.events, 'optionalAccess', _277 => _277.enableClickToFocus])&&(e.addEventListener("mousedown",m),e.addEventListener("click",g),e.addEventListener("dblclick",R)),_optionalChain([r, 'access', _278 => _278.events, 'optionalAccess', _279 => _279.enableKeyboardControls])&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",x)),{dispose:()=>{e.removeEventListener("mousedown",m),e.removeEventListener("click",g),e.removeEventListener("dblclick",R),e.removeEventListener("keydown",x),T()},fitToView:d,clearSelection:T}}function uo(e,n,t){let r=new (0, _OrbitControlsjs.OrbitControls)(e,n),a=t.camera.target;return a&&r.target.set(a.x,a.y,a.z),r.enableDamping=t.controls.enableDamping||!1,r.dampingFactor=t.controls.dampingFactor||.05,r.autoRotate=t.controls.autoRotate||!1,r.autoRotateSpeed=t.controls.autoRotateSpeed||.5,r.enableZoom=_nullishCoalesce(t.controls.enableZoom, () => (!0)),r.enablePan=_nullishCoalesce(t.controls.enablePan, () => (!0)),r.minDistance=t.controls.minDistance||.001,r.maxDistance=t.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}var Mi=["technical","studio","showcase"];function Ne(e,n,t,r=!0){return{x:e,y:n,z:t}}var Eo="#ffffff",rn=12,ho=4e-4,go=12,yo=.05;function on(e,n={}){if(!e||e.length===0)return[];let{rhino:t,applyTransforms:r=!0}=n,a=[];for(let o of e)switch(o.kind){case"curve":{let i=To(o,t,r);i&&a.push(i);break}case"point":{let i=Ro(o,r);i&&a.push(i);break}default:{let l=o;_chunkH3FZW6OXcjs.e.call(void 0, ).warn(`Skipping unknown display item kind: ${String(l.kind)}`);break}}return a}var bo=2;function To(e,n,t){if(!n)return _chunkH3FZW6OXcjs.e.call(void 0, ).warn("No rhino3dm instance provided; skipping curve display item."),null;let r=xo(e.json,n);if(!r)return null;let a;try{a=vo(r,t)}catch(d){return _chunkH3FZW6OXcjs.e.call(void 0, ).warn("Failed to tessellate curve display item; skipping.",d),null}finally{Ce(r)}if(a.length<2)return null;let o=[];for(let d of a)o.push(d.x,d.y,d.z);let i=new _LineGeometryjs.LineGeometry;i.setPositions(o);let l=an(e.color,e.opacity),s=new (0, _LineMaterialjs.LineMaterial)({color:l.color}),c=s;c.linewidth=_nullishCoalesce(e.width, () => (bo)),c.transparent=l.transparent,c.opacity=l.opacity;let u=new (0, _Line2js.Line2)(i,s);return u.computeLineDistances(),u.name=e.name,u.userData={source:"compute",id:e.id,layer:e.layer,kind:"curve",metadata:e.metadata},u}function Ro(e,n){let{position:t}=e;if(!t||typeof t.X!="number"||!Number.isFinite(t.X)||typeof t.Y!="number"||!Number.isFinite(t.Y)||typeof t.Z!="number"||!Number.isFinite(t.Z))return _chunkH3FZW6OXcjs.e.call(void 0, ).warn(`Skipping point display item with missing or non-finite position (id: ${String(e.id)}).`),null;let{x:r,y:a,z:o}=Ne(t.X,t.Y,t.Z,n),i=new ee.BufferGeometry;i.setAttribute("position",new ee.Float32BufferAttribute([r,a,o],3));let l=new ee.PointsMaterial({...an(e.color,e.opacity),size:6,sizeAttenuation:!1}),s=new ee.Points(i,l);return s.name=e.name,s.userData={source:"compute",id:e.id,layer:e.layer,kind:"point",metadata:e.metadata},s}function Ce(e){_optionalChain([e, 'optionalAccess', _280 => _280.delete, 'optionalCall', _281 => _281()])}function xo(e,n){try{let t=JSON.parse(e),r=n.CommonObject.decode(t);return r&&typeof r.pointAt=="function"?r:(Ce(r),_chunkH3FZW6OXcjs.e.call(void 0, ).warn("Decoded display-item JSON is not a curve; skipping."),null)}catch(t){return _chunkH3FZW6OXcjs.e.call(void 0, ).warn("Failed to decode curve display item JSON:",t),null}}function vo(e,n){let t=wo(e,n);return t||Mo(e,n)}function wo(e,n){if(!e.isPolyline())return null;let t=e.tryGetPolyline(),r=Array.isArray(t)?t[1]:t;if(!r||typeof r.count!="number"||r.count<2)return Ce(r),null;let a=[];for(let o=0;o<r.count;o++){let i=r.get(o),{x:l,y:s,z:c}=Ne(i[0],i[1],i[2],n);a.push(new ee.Vector3(l,s,c))}return Ce(r),a}function Mo(e,n){let t=e.domain,r=t[0],o=t[1]-r,i=d=>{let E=e.pointAt(d),{x:T,y:v,z:y}=Ne(E[0],E[1],E[2],n);return new ee.Vector3(T,v,y)},l=Ho(e),s=r,c=i(r),u=[c];for(let d=0;d<rn;d++){let E=r+o*(d+1)/rn,T=i(E);it(s,c,E,T,i,l,go,u),u.push(T),s=E,c=T}return u}function it(e,n,t,r,a,o,i,l){if(i<=0)return;let s=(e+t)/2,c=a(s),u=Ao(c,n,r),d=Co(n,c,r);u<=o&&d<=yo||(it(e,n,s,c,a,o,i-1,l),l.push(c),it(s,c,t,r,a,o,i-1,l))}function Ho(e){let n=e.getBoundingBox(),t=n.min,r=n.max;Ce(n);let a=Math.hypot(r[0]-t[0],r[1]-t[1],r[2]-t[2]);return Math.max(a*ho,1e-6)}function Co(e,n,t){let r=n.x-e.x,a=n.y-e.y,o=n.z-e.z,i=t.x-n.x,l=t.y-n.y,s=t.z-n.z,c=Math.sqrt(r*r+a*a+o*o),u=Math.sqrt(i*i+l*l+s*s);if(c===0||u===0)return 0;let d=r*i+a*l+o*s,E=Math.max(-1,Math.min(1,d/(c*u)));return Math.acos(E)}function Ao(e,n,t){let r=t.x-n.x,a=t.y-n.y,o=t.z-n.z,i=r*r+a*a+o*o;if(i===0)return e.distanceTo(n);let l=e.x-n.x,s=e.y-n.y,c=e.z-n.z,u=Math.max(0,Math.min(1,(l*r+s*a+c*o)/i)),d=l-r*u,E=s-a*u,T=c-o*u;return Math.sqrt(d*d+E*E+T*T)}function an(e,n){let t=_nullishCoalesce(n, () => (1));return{color:new ee.Color(_nullishCoalesce(e, () => (Eo))),transparent:t<1,opacity:t}}var _fflate = require('fflate');var sn=1096174675,Do= exports.G =1515605075,ln= exports.H =3,cn= exports.I =1,lt= exports.J =1,Lo= exports.K =2,Oo= exports.L =4,Io= exports.M =8,Po= exports.N =16,ki= exports.O =0,Fo= exports.P =1,un=12,dn=56,Bo=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;function ct(e){let n=ut(e),t;n.isFloat32?t=n.vertexData:n.deltaEncoded?t=Wo(n.vertexData):t=n.vertexData;let r=n.indexData;return n.deltaEncoded&&(r=r instanceof Uint16Array?$o(r):qo(r)),jo(r,n.vertexCount),{metadata:n.metadata,flags:n.flags,vertices:t,indices:r,origin:n.origin,scale:n.scale,uvs:n.uvs,colors:n.colors}}function ut(e){if(!Bo)throw new (0, _chunkH3FZW6OXcjs.d)("SLVA parsing requires a little-endian host: the zero-copy geometry readers view the wire bytes in host byte order.",_chunkH3FZW6OXcjs.c.ENVIRONMENT_ERROR);let n=_o(Vo(e)),t=new DataView(n.buffer,n.byteOffset,n.byteLength);if(n.byteLength<un)throw Y("Blob too small to contain SLVA header.",{expectedBytes:un,availableBytes:n.byteLength});let r=0,a=t.getUint32(r,!0);if(r+=4,a!==sn)throw Y(`Invalid SLVA magic: 0x${a.toString(16)}`,{expectedMagic:`0x${sn.toString(16)}`,actualMagic:`0x${a.toString(16)}`});let o=t.getUint32(r,!0);if(r+=4,o<cn||o>ln)throw Y(`Unsupported SLVA version: ${o}`,{minSupportedVersion:cn,maxSupportedVersion:ln,actualVersion:o});let i=t.getUint32(r,!0);if(r+=4,r+i>n.byteLength)throw Y("Insufficient data to read metadata JSON.",{expectedBytes:i,availableBytes:n.byteLength-r,offset:r});let l=n.subarray(r,r+i);r+=i;let s;try{s=JSON.parse(zo(l))}catch(I){throw Y(`Failed to parse metadata JSON: ${I instanceof Error?I.message:String(I)}`,{metadataLen:i})}if(r+dn>n.byteLength)throw Y("Insufficient data to read geometry header.",{expectedBytes:dn,availableBytes:n.byteLength-r,offset:r});let c=t.getUint32(r,!0);r+=4;let u=t.getFloat64(r,!0);r+=8;let d=t.getFloat64(r,!0);r+=8;let E=t.getFloat64(r,!0);r+=8;let T=t.getFloat64(r,!0);r+=8;let v=t.getFloat64(r,!0);r+=8;let y=t.getFloat64(r,!0);r+=8;let m=t.getUint32(r,!0);r+=4;let g=(c&lt)!==0,R=(c&Oo)!==0,x=m*3,p=x*(g?4:2);if(r+p>n.byteLength)throw Y("Insufficient data to read vertices.",{expectedBytes:p,availableBytes:n.byteLength-r,offset:r,useFloat32:g,vertexCount:m});let f=n.byteOffset+r,h;if(g?h=fn(n.buffer,f,x):R?h=st(n.buffer,f,x):h=Go(n.buffer,f,x),r+=p,r+4>n.byteLength)throw Y("Insufficient data to read index count.",{expectedBytes:4,availableBytes:n.byteLength-r,offset:r});let b=t.getUint32(r,!0);r+=4;let H=(c&Lo)!==0,L=b*(H?2:4);if(r+L>n.byteLength)throw Y("Insufficient data to read indices.",{expectedBytes:L,availableBytes:n.byteLength-r,offset:r,indexCount:b,useUint16Indices:H});let P=H?st(n.buffer,n.byteOffset+r,b):No(n.buffer,n.byteOffset+r,b);r+=L;let k=null;if((c&Io)!==0){let I=ko(n,t,r,m,R);k=I.uvs,r=I.offset}let O=null;return(c&Po)!==0&&(O=Uo(n,r,m,R)),{metadata:s,flags:c,vertexData:h,indexData:P,isFloat32:g,deltaEncoded:R,vertexCount:m,origin:[u,d,E],scale:[T,v,y],uvs:k,colors:O}}var mn=36;function ko(e,n,t,r,a){if(t+mn>e.byteLength)throw Y("Insufficient data to read UV chunk header.",{expectedBytes:mn,availableBytes:e.byteLength-t,offset:t});let o=n.getUint32(t,!0);t+=4;let i=n.getFloat64(t,!0);t+=8;let l=n.getFloat64(t,!0);t+=8;let s=n.getFloat64(t,!0);t+=8;let c=n.getFloat64(t,!0);t+=8;let u=r*2,d=o===Fo,E=u*(d?4:2);if(t+E>e.byteLength)throw Y("Insufficient data to read UV chunk.",{expectedBytes:E,availableBytes:e.byteLength-t,offset:t,uvFormat:o,vertexCount:r});let T=e.byteOffset+t,v;if(d)v=fn(e.buffer,T,u).slice();else{let y=st(e.buffer,T,u);v=new Float32Array(u);let m=0,g=0;for(let R=0;R<u;R+=2)a?(m=m+ie(y[R])&65535,g=g+ie(y[R+1])&65535):(m=y[R],g=y[R+1]),v[R]=i+m*s,v[R+1]=l+g*c}return{uvs:v,offset:t+E}}function Uo(e,n,t,r){let a=t*3;if(n+a>e.byteLength)throw Y("Insufficient data to read vertex-color chunk.",{expectedBytes:a,availableBytes:e.byteLength-n,offset:n,vertexCount:t});let o=e.subarray(n,n+a);if(!r)return o.slice();let i=new Uint8Array(a),l=0,s=0,c=0;for(let u=0;u<a;u+=3)l=l+ie(o[u])&255,s=s+ie(o[u+1])&255,c=c+ie(o[u+2])&255,i[u]=l,i[u+1]=s,i[u+2]=c;return i}function Vo(e){return typeof e=="string"?_chunkH3FZW6OXcjs.j.call(void 0, e):e instanceof Uint8Array?e:new Uint8Array(e)}function _o(e){if(e.byteLength<8)return e;let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(n.getUint32(0,!0)!==Do)return e;let t=n.getUint32(4,!0),r=e.subarray(8),a=Math.max(r.byteLength*1032+1024,1<<20);if(t>a)throw Y("SLVZ header declares an implausible uncompressed length",{uncompressedLen:t,deflatedBytes:r.byteLength,maxPlausibleLen:a});let o;try{o=_fflate.inflateSync.call(void 0, r,{out:new Uint8Array(t+1)})}catch(i){throw Y(`Failed to inflate SLVZ blob: ${i instanceof Error?i.message:String(i)}`,{uncompressedLen:t,deflatedBytes:r.byteLength})}if(o.byteLength!==t)throw Y("SLVZ payload inflated to a different size than the header declares.",{declaredLen:t,actualLen:o.byteLength,deflatedBytes:r.byteLength});return o}function zo(e){if(typeof TextDecoder<"u")return new TextDecoder("utf-8").decode(e);if(typeof globalThis.Buffer<"u")return globalThis.Buffer.from(e).toString("utf-8");throw new (0, _chunkH3FZW6OXcjs.d)("No UTF-8 decoder available in this environment.",_chunkH3FZW6OXcjs.c.INVALID_STATE)}function Go(e,n,t){if(t===0)return new Int16Array(0);if(n%2===0)return new Int16Array(e,n,t);let r=new Uint8Array(t*2);return r.set(new Uint8Array(e,n,t*2)),new Int16Array(r.buffer)}function fn(e,n,t){if(t===0)return new Float32Array(0);if(n%4===0)return new Float32Array(e,n,t);let r=new Uint8Array(t*4);return r.set(new Uint8Array(e,n,t*4)),new Float32Array(r.buffer)}function st(e,n,t){if(t===0)return new Uint16Array(0);if(n%2===0)return new Uint16Array(e,n,t);let r=new Uint8Array(t*2);return r.set(new Uint8Array(e,n,t*2)),new Uint16Array(r.buffer)}function No(e,n,t){if(t===0)return new Uint32Array(0);if(n%4===0)return new Uint32Array(e,n,t);let r=new Uint8Array(t*4);return r.set(new Uint8Array(e,n,t*4)),new Uint32Array(r.buffer)}function jo(e,n){if(e.length!==0&&!(e instanceof Uint16Array&&n>65535)){for(let t=0;t<e.length;t++)if(e[t]>=n)throw Y("Index out of range of vertexCount.",{indexPosition:t,indexValue:e[t],vertexCount:n})}}function ie(e){return e>>>1^-(e&1)}function Wo(e){let n=new Int16Array(e.length),t=0,r=0,a=0;for(let o=0;o<e.length;o+=3)t=t+ie(e[o])<<16>>16,r=r+ie(e[o+1])<<16>>16,a=a+ie(e[o+2])<<16>>16,n[o]=t,n[o+1]=r,n[o+2]=a;return n}function $o(e){let n=new Uint16Array(e.length),t=0;for(let r=0;r<e.length;r++)t=t+ie(e[r])&65535,n[r]=t;return n}function qo(e){let n=new Uint32Array(e.length),t=0;for(let r=0;r<e.length;r++)t=t+ie(e[r])>>>0,n[r]=t;return n}function Y(e,n){return new (0, _chunkH3FZW6OXcjs.d)(e,_chunkH3FZW6OXcjs.c.VALIDATION_ERROR,{context:n})}var pn=256*1024*1024,je=1024,de=new Map,dt=0;function En(e,n){let t=2166136261,r=a=>{t^=a,t=Math.imul(t,16777619)};for(let a=0;a<n.length;a++)r(n.charCodeAt(a));for(let a of e){if(!a){r(57005);continue}let o=a.byteLength;if(r(o),(a.byteOffset&3)===0&&(o&3)===0){let i=new Uint32Array(a.buffer,a.byteOffset,o>>2),l=Math.min(je,i.length);for(let s=0;s<l;s++)r(i[s]);for(let s=Math.max(l,i.length-je);s<i.length;s++)r(i[s])}else{let i=new Uint8Array(a.buffer,a.byteOffset,o),l=Math.min(je*4,i.length);for(let s=0;s<l;s++)r(i[s]);for(let s=Math.max(l,i.length-je*4);s<i.length;s++)r(i[s])}}return`${(t>>>0).toString(36)}:${e.length}`}function Yo(e){let n=_nullishCoalesce(_optionalChain([e, 'access', _282 => _282.index, 'optionalAccess', _283 => _283.array, 'access', _284 => _284.byteLength]), () => (0));for(let t of Object.values(e.attributes))n+=t.array.byteLength;return n}function We(e){let n=de.get(e);if(n)return de.delete(e),de.set(e,n),n.geometry}function $e(e,n){let t=Yo(n);if(!(t>pn||(n.userData[Oe]=!0,de.get(e))))for(de.set(e,{geometry:n,bytes:t}),dt+=t;dt>pn&&de.size>1;){let a=de.keys().next().value,o=de.get(a);de.delete(a),dt-=o.bytes,delete o.geometry.userData[Oe],o.geometry.dispose()}}function Xo(e){let{isFloat32:n,deltaEncoded:t,origin:r,scale:a,uvs:o,colors:i,jobs:l}=e,s=m=>m>>>1^-(m&1),c;if(n)c=e.vertexData;else{let m;if(t){let h=e.vertexData;m=new Int16Array(h.length);let b=0,H=0,C=0;for(let L=0;L<h.length;L+=3)b=b+s(h[L])<<16>>16,H=H+s(h[L+1])<<16>>16,C=C+s(h[L+2])<<16>>16,m[L]=b,m[L+1]=H,m[L+2]=C}else m=e.vertexData;c=new Float32Array(m.length);let g=r[0],R=r[1],x=r[2],M=a[0],p=a[1],f=a[2];for(let h=0;h<m.length;h+=3)c[h]=g+(m[h]+32767)*M,c[h+1]=R+(m[h+1]+32767)*p,c[h+2]=x+(m[h+2]+32767)*f}let u;if(t){let m=e.indexData;if(m instanceof Uint16Array){let g=new Uint16Array(m.length),R=0;for(let x=0;x<m.length;x++)R=R+s(m[x])&65535,g[x]=R;u=g}else{let g=new Uint32Array(m.length),R=0;for(let x=0;x<m.length;x++)R=R+s(m[x])>>>0,g[x]=R;u=g}}else u=e.indexData;let d=c.length/3;for(let m=0;m<u.length;m++)if(u[m]>=d)throw new Error(`Index ${u[m]} out of range of vertexCount ${d}`);let E=1024,T=(m,g)=>{let R=2166136261,x=M=>{R^=M,R=Math.imul(R,16777619)};for(let M=0;M<g.length;M++)x(g.charCodeAt(M));for(let M of m){if(!M){x(57005);continue}let p=M.byteLength;if(x(p),(M.byteOffset&3)===0&&(p&3)===0){let f=new Uint32Array(M.buffer,M.byteOffset,p>>2),h=Math.min(E,f.length);for(let b=0;b<h;b++)x(f[b]);for(let b=Math.max(h,f.length-E);b<f.length;b++)x(f[b])}else{let f=new Uint8Array(M.buffer,M.byteOffset,p),h=Math.min(E*4,f.length);for(let b=0;b<h;b++)x(f[b]);for(let b=Math.max(h,f.length-E*4);b<f.length;b++)x(f[b])}}return`${(R>>>0).toString(36)}:${m.length}`},v=(m,g)=>{let R=[],x=m;for(let M of g){x+=`|${M.vertexStart},${M.vertexCount},${M.indexStart},${M.indexCount}`;let p=M.vertexStart*3,f=p+M.vertexCount*3;R.push(c.subarray(p,f)),R.push(u.subarray(M.indexStart,M.indexStart+M.indexCount)),R.push(o?o.subarray(M.vertexStart*2,(M.vertexStart+M.vertexCount)*2):null),R.push(i?i.subarray(p,f):null)}return T(R,x)},y=[];for(let m of l){let g=0,R=0;for(let C of m.windows)g+=C.vertexCount,R+=C.indexCount;let x=new Float32Array(g*3),M=new Uint32Array(R),p=o?new Float32Array(g*2):null,f=i?new Uint8Array(g*3):null,h=0,b=0;for(let C of m.windows){let L=C.vertexStart*3;x.set(c.subarray(L,L+C.vertexCount*3),h*3),p&&o&&p.set(o.subarray(C.vertexStart*2,(C.vertexStart+C.vertexCount)*2),h*2),f&&i&&f.set(i.subarray(L,L+C.vertexCount*3),h*3);let P=C.vertexStart,k=C.vertexStart+C.vertexCount,O=h-C.vertexStart;for(let I=0;I<C.indexCount;I++){let S=u[C.indexStart+I];if(S<P||S>=k)throw new Error(`Index ${S} outside vertex window [${P}, ${k})`);M[b+I]=S+O}h+=C.vertexCount,b+=C.indexCount}let H=new Float32Array(g*3);for(let C=0;C<M.length;C+=3){let L=M[C]*3,P=M[C+1]*3,k=M[C+2]*3,O=x[k]-x[P],I=x[k+1]-x[P+1],S=x[k+2]-x[P+2],D=x[L]-x[P],G=x[L+1]-x[P+1],j=x[L+2]-x[P+2],$=I*j-S*G,U=S*D-O*j,J=O*G-I*D;H[L]+=$,H[L+1]+=U,H[L+2]+=J,H[P]+=$,H[P+1]+=U,H[P+2]+=J,H[k]+=$,H[k+1]+=U,H[k+2]+=J}for(let C=0;C<H.length;C+=3){let L=H[C],P=H[C+1],k=H[C+2],O=Math.sqrt(L*L+P*P+k*k)||1;H[C]=L/O,H[C+1]=P/O,H[C+2]=k/O}y.push({key:v(m.kind,m.windows),positions:x,normals:H,indices:M,uvs:p,colors:f})}return y}function hn(){return[`const assemble = ${Xo.toString()};`,"self.onmessage = (event) => {"," const { id, input } = event.data;"," try {"," const geometries = assemble(input);"," const transfer = [];"," for (const g of geometries) {"," transfer.push(g.positions.buffer, g.normals.buffer, g.indices.buffer);"," if (g.uvs) transfer.push(g.uvs.buffer);"," if (g.colors) transfer.push(g.colors.buffer);"," }"," self.postMessage({ id, geometries }, transfer);"," } catch (error) {"," self.postMessage({ id, error: String((error && error.message) || error) });"," }","};"].join(`
112
- `)}async function Xi(e,n){let{debug:t=!1}=_nullishCoalesce(n, () => ({})),r=t?performance.now():0,a,o=performance.now();try{a=JSON.parse(e)}catch(l){return _chunkH3FZW6OXcjs.e.call(void 0, ).error("Error parsing mesh batch envelope JSON:",l),[]}let i=performance.now()-o;return await mt(a,n,{parseTime:i,perfStart:r})}async function mt(e,n,t){let{mergeByMaterial:r=!0,applyTransforms:a=!0,debug:o=!1,material:i}=_nullishCoalesce(n, () => ({})),{parseTime:l=0,perfStart:s=o?performance.now():0}=_nullishCoalesce(t, () => ({}));if(!e.compressedData)return[];let c=await Rn(e.compressedData,{mergeByMaterial:r,applyTransforms:a,debug:o,material:i,fallback:{materials:e.materials,groups:e.groups,sourceComponentId:e.sourceComponentId}});if(c)return c;let u=performance.now(),d=ct(e.compressedData),E=performance.now()-u,T=o?la(e.compressedData):0;return gn(d,{mergeByMaterial:r,applyTransforms:a,debug:o,material:i,parseTime:l,decodeTime:E,perfStart:s,blobBytes:T,fallback:{materials:e.materials,groups:e.groups,sourceComponentId:e.sourceComponentId}})}async function Ki(e,n){let{mergeByMaterial:t=!0,applyTransforms:r=!0,debug:a=!1,material:o}=_nullishCoalesce(n, () => ({})),i=a?performance.now():0,l=await Rn(e,{mergeByMaterial:t,applyTransforms:r,debug:a,material:o});if(l)return l;let s=performance.now(),c=ct(e),u=performance.now()-s,d=e.byteLength;return gn(c,{mergeByMaterial:t,applyTransforms:r,debug:a,material:o,parseTime:0,decodeTime:u,perfStart:i,blobBytes:d})}function gn(e,n){let{mergeByMaterial:t,applyTransforms:r,debug:a,material:o,parseTime:i,decodeTime:l,perfStart:s,blobBytes:c,fallback:u}=n,d=_nullishCoalesce(_nullishCoalesce(e.metadata.materials, () => (_optionalChain([u, 'optionalAccess', _285 => _285.materials]))), () => ([])),E=_nullishCoalesce(_nullishCoalesce(e.metadata.groups, () => (_optionalChain([u, 'optionalAccess', _286 => _286.groups]))), () => ([])),T=_nullishCoalesce(_optionalChain([u, 'optionalAccess', _287 => _287.sourceComponentId]), () => (e.metadata.sourceComponentId)),v=(e.flags&lt)!==0;yn(E,d.length,e.vertices.length/3,e.indices.length);let y=v?Zo(e.vertices,r):Ko(e.vertices,e.origin,e.scale,r);if(a){let M=e.vertices.byteLength+e.indices.byteLength;_chunkH3FZW6OXcjs.e.call(void 0, ).debug("Mesh Batch Stats:"),_chunkH3FZW6OXcjs.e.call(void 0, ).debug(` Materials: ${d.length} | Groups: ${E.length}`),_chunkH3FZW6OXcjs.e.call(void 0, ).debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),_chunkH3FZW6OXcjs.e.call(void 0, ).debug(` Format: ${v?"float32":"int16 quantized"}`),_chunkH3FZW6OXcjs.e.call(void 0, ).debug(` Blob: ${(c/1024/1024).toFixed(2)} MB | Geometry on wire: ${(M/1024/1024).toFixed(2)} MB`)}let m=performance.now(),g=d.map(M=>xn(M,{vertexColors:e.colors!=null,appearance:o})),R=[];for(let M of E)if(t&&M.meshes.length>1){let p=ia(M,y,e.indices,g,e.uvs,e.colors);p.userData.sourceComponentId=_nullishCoalesce(T, () => (null)),R.push(p)}else{let p=sa(M,y,e.indices,g,e.uvs,e.colors);for(let f of p)f.userData.sourceComponentId=_nullishCoalesce(T, () => (null));R.push(...p)}let x=performance.now()-m;if(a){let M=performance.now()-s;_chunkH3FZW6OXcjs.e.call(void 0, ).debug("Performance:"),i>0&&_chunkH3FZW6OXcjs.e.call(void 0, ).debug(` Parse JSON: ${i.toFixed(2)}ms`),_chunkH3FZW6OXcjs.e.call(void 0, ).debug(` Decode binary: ${l.toFixed(2)}ms`),_chunkH3FZW6OXcjs.e.call(void 0, ).debug(` Create Meshes: ${x.toFixed(2)}ms`),_chunkH3FZW6OXcjs.e.call(void 0, ).debug(` Total: ${M.toFixed(2)}ms`)}return Promise.resolve(R)}function Ae(e,n){return new (0, _chunkH3FZW6OXcjs.d)(e,_chunkH3FZW6OXcjs.c.VALIDATION_ERROR,{context:n})}function yn(e,n,t,r){for(let a of e){if(!Number.isInteger(a.materialId)||a.materialId<0||a.materialId>=n)throw Ae("Group materialId out of range of the materials array.",{materialId:a.materialId,materialCount:n});for(let o of a.meshes){let i={vertexStart:o.vertexStart,vertexCount:o.vertexCount,indexStart:o.indexStart,indexCount:o.indexCount};for(let[l,s]of Object.entries(i))if(!Number.isInteger(s)||s<0)throw Ae(`Mesh metadata field "${l}" must be a non-negative integer.`,{meshName:o.name,field:l,value:s});if(o.vertexStart+o.vertexCount>t)throw Ae("Mesh vertex window exceeds the batch vertex buffer.",{meshName:o.name,vertexStart:o.vertexStart,vertexCount:o.vertexCount,totalVertexCount:t});if(o.indexStart+o.indexCount>r)throw Ae("Mesh index window exceeds the batch index buffer.",{meshName:o.name,indexStart:o.indexStart,indexCount:o.indexCount,totalIndexCount:r})}}}function bn(e,n){return Ae("Index references a vertex outside its mesh's vertex window.",{meshName:n.name,indexValue:e,vertexStart:n.vertexStart,vertexCount:n.vertexCount})}function Tn(e,n,t,r,a,o){let i=[],l=e;for(let s of n){l+=`|${s.vertexStart},${s.vertexCount},${s.indexStart},${s.indexCount}`;let c=s.vertexStart*3,u=c+s.vertexCount*3;i.push(t.subarray(c,u)),i.push(r.subarray(s.indexStart,s.indexStart+s.indexCount)),i.push(a?a.subarray(s.vertexStart*2,(s.vertexStart+s.vertexCount)*2):null),i.push(o?o.subarray(c,u):null)}return En(i,l)}function Ko(e,n,t,r){let a=new Float32Array(e.length),o=n[0],i=n[1],l=n[2],s=t[0],c=t[1],u=t[2];for(let d=0;d<e.length;d+=3)a[d]=o+(e[d]+32767)*s,a[d+1]=i+(e[d+1]+32767)*c,a[d+2]=l+(e[d+2]+32767)*u;return a}function Zo(e,n){return e}var Jo=5e4,ye,Se=new Map,Qo=1;function ea(){if(ye!==void 0)return ye;if(typeof Worker>"u"||typeof Blob>"u"||typeof URL>"u"||typeof URL.createObjectURL!="function")return ye=null,null;try{let e=URL.createObjectURL(new Blob([hn()],{type:"text/javascript"})),n=new Worker(e);n.onmessage=t=>{let{id:r,geometries:a,error:o}=t.data,i=Se.get(r);i&&(Se.delete(r),a?i.resolve(a):i.reject(new Error(_nullishCoalesce(o, () => ("mesh assembly failed in worker")))))},n.onerror=()=>{for(let t of Se.values())t.reject(new Error("mesh assembly worker crashed"));Se.clear(),n.terminate(),ye=null},ye=n}catch (e4){ye=null}return ye}function ta(e,n,t){return new Promise((r,a)=>{let o=Qo++;Se.set(o,{resolve:r,reject:a}),e.postMessage({id:o,input:n},t)})}async function Rn(e,n){if(typeof Worker>"u")return null;let t=ut(e);if(t.indexData.length/3<Jo)return null;let r=ea();if(!r)return null;let a=_nullishCoalesce(_nullishCoalesce(t.metadata.materials, () => (_optionalChain([n, 'access', _288 => _288.fallback, 'optionalAccess', _289 => _289.materials]))), () => ([])),o=_nullishCoalesce(_nullishCoalesce(t.metadata.groups, () => (_optionalChain([n, 'access', _290 => _290.fallback, 'optionalAccess', _291 => _291.groups]))), () => ([])),i=_nullishCoalesce(_optionalChain([n, 'access', _292 => _292.fallback, 'optionalAccess', _293 => _293.sourceComponentId]), () => (t.metadata.sourceComponentId));yn(o,a.length,t.vertexCount,t.indexData.length);let l=m=>({vertexStart:m.vertexStart,vertexCount:m.vertexCount,indexStart:m.indexStart,indexCount:m.indexCount}),s=[],c=[];for(let m of o)if(n.mergeByMaterial&&m.meshes.length>1)s.push({kind:"merged",windows:m.meshes.map(l)}),c.push({kind:"merged",group:m});else for(let g of m.meshes)s.push({kind:"single",windows:[l(g)]}),c.push({kind:"single",group:m,meshMeta:g});let u=t.vertexData.slice(),d=t.indexData.slice(),E=[u.buffer,d.buffer];t.uvs&&E.push(t.uvs.buffer),t.colors&&E.push(t.colors.buffer);let T;try{T=await ta(r,{vertexData:u,isFloat32:t.isFloat32,deltaEncoded:t.deltaEncoded,origin:t.origin,scale:t.scale,indexData:d,uvs:t.uvs,colors:t.colors,jobs:s},E)}catch(m){return _chunkH3FZW6OXcjs.e.call(void 0, ).warn("Mesh assembly worker failed; falling back to main-thread parse.",m),null}if(T.length!==s.length)return null;let v=a.map(m=>xn(m,{vertexColors:t.colors!=null,appearance:n.material})),y=[];for(let m=0;m<T.length;m++){let g=T[m],R=c[m],x=We(g.key);x||(x=new _.BufferGeometry,x.setAttribute("position",new _.BufferAttribute(g.positions,3)),x.setAttribute("normal",new _.BufferAttribute(g.normals,3)),x.setIndex(new _.BufferAttribute(g.indices,1)),g.uvs&&x.setAttribute("uv",new _.BufferAttribute(g.uvs,2)),g.colors&&x.setAttribute("color",new _.BufferAttribute(g.colors,3,!0)),$e(g.key,x));let M=R.kind==="merged"?vn(x,R.group,v):wn(x,R.meshMeta,R.group,v);M.userData.sourceComponentId=_nullishCoalesce(i, () => (null)),y.push(M)}return n.debug&&_chunkH3FZW6OXcjs.e.call(void 0, ).debug(`Mesh batch assembled off-thread: ${y.length} meshes, ${t.indexData.length/3} triangles`),y}var na=.5,ra=.5,oa=.3;function xn(e,n){let t=Ct(e.color),r=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _294 => _294.vertexColors]), () => (!1)),a=_optionalChain([n, 'optionalAccess', _295 => _295.appearance]),o=new _.MeshPhysicalMaterial({color:t,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,vertexColors:r,side:_optionalChain([a, 'optionalAccess', _296 => _296.cullBackfaces])?_.FrontSide:_.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0});return _optionalChain([a, 'optionalAccess', _297 => _297.envMapIntensity])!=null&&(o.envMapIntensity=a.envMapIntensity),e.metalness>na&&(o.clearcoat=ra,o.clearcoatRoughness=oa),r&&aa(o),e.map&&tn(o,e.map),o}function aa(e){e.onBeforeCompile=n=>{n.vertexShader=n.vertexShader.replace("#include <color_vertex>",`#include <color_vertex>
113
- #if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
114
- vColor.rgb = mix(
115
- vColor.rgb / 12.92,
116
- pow( ( vColor.rgb + 0.055 ) / 1.055, vec3( 2.4 ) ),
117
- step( vec3( 0.04045 ), vColor.rgb )
118
- );
119
- #endif`)}}function ia(e,n,t,r,a=null,o=null){let i=Tn("merged",e.meshes,n,t,a,o),l=We(i);if(!l){let s=0,c=0;for(let m of e.meshes)s+=m.vertexCount,c+=m.indexCount;let u=new Float32Array(s*3),d=new Uint32Array(c),E=a?new Float32Array(s*2):null,T=o?new Uint8Array(s*3):null,v=0,y=0;for(let m of e.meshes){let g=m.vertexStart*3,R=m.vertexCount*3;if(u.set(n.subarray(g,g+R),v*3),E&&a){let h=m.vertexStart*2;E.set(a.subarray(h,h+m.vertexCount*2),v*2)}T&&o&&T.set(o.subarray(g,g+R),v*3);let x=t.subarray(m.indexStart,m.indexStart+m.indexCount),M=v-m.vertexStart,p=m.vertexStart,f=m.vertexStart+m.vertexCount;for(let h=0;h<x.length;h++){let b=x[h];if(b<p||b>=f)throw bn(b,m);d[y+h]=b+M}v+=m.vertexCount,y+=m.indexCount}l=new _.BufferGeometry,l.setAttribute("position",new _.BufferAttribute(u,3)),l.setIndex(new _.BufferAttribute(d,1)),E&&l.setAttribute("uv",new _.BufferAttribute(E,2)),T&&l.setAttribute("color",new _.BufferAttribute(T,3,!0)),l.computeVertexNormals(),$e(i,l)}return vn(l,e,r)}function vn(e,n,t){let r=new _.Mesh(e,t[n.materialId]),a=n.meshes[0],o=n.meshes.map(i=>i.name).filter(i=>i&&i.length>0);return r.name=o.length>0?o[0]:`merged_material_${n.materialId}`,r.castShadow=!0,r.receiveShadow=!0,r.userData={source:"compute",name:r.name,layer:_nullishCoalesce(_optionalChain([a, 'optionalAccess', _298 => _298.layer]), () => ("")),originalIndex:_nullishCoalesce(_optionalChain([a, 'optionalAccess', _299 => _299.originalIndex]), () => (0)),metadata:_nullishCoalesce(_optionalChain([a, 'optionalAccess', _300 => _300.metadata]), () => ({})),mergedFrom:n.meshes.slice(1).map(i=>({name:i.name,layer:i.layer,originalIndex:i.originalIndex}))},r}function sa(e,n,t,r,a=null,o=null){let i=[];for(let l of e.meshes){let s=l.vertexStart*3,c=l.vertexCount*3,u=Tn("single",[l],n,t,a,o),d=We(u);if(!d){let E=n.slice(s,s+c),T=t.subarray(l.indexStart,l.indexStart+l.indexCount),v=new Uint32Array(T.length),y=l.vertexStart,m=l.vertexStart+l.vertexCount;for(let g=0;g<T.length;g++){let R=T[g];if(R<y||R>=m)throw bn(R,l);v[g]=R-y}if(d=new _.BufferGeometry,d.setAttribute("position",new _.BufferAttribute(E,3)),d.setIndex(new _.BufferAttribute(v,1)),a){let g=l.vertexStart*2,R=a.slice(g,g+l.vertexCount*2);d.setAttribute("uv",new _.BufferAttribute(R,2))}if(o){let g=o.slice(s,s+c);d.setAttribute("color",new _.BufferAttribute(g,3,!0))}d.computeVertexNormals(),$e(u,d)}i.push(wn(d,l,e,r))}return i}function wn(e,n,t,r){let a=new _.Mesh(e,r[t.materialId]);return a.name=n.name,a.userData={source:"compute",name:n.name,layer:_nullishCoalesce(n.layer, () => ("")),originalIndex:n.originalIndex,metadata:_nullishCoalesce(n.metadata, () => ({}))},a.castShadow=!0,a.receiveShadow=!0,a}function la(e){return Math.floor(e.length*3/4)}var Mn={Angstroms:1e-10,Nanometers:1e-9,Microns:1e-6,Millimeters:.001,Centimeters:.01,Decimeters:.1,Meters:1,Dekameters:10,Hectometers:100,Kilometers:1e3,Megameters:1e6,Gigameters:1e9,Microinches:254e-10,Mils:254e-7,Inches:.0254,Feet:.3048,Yards:.9144,Miles:1609.344,NauticalMiles:1852},ca="Display",ua="DisplayBatch";function da(e){let n=e.split(".");return n.includes(ca)||n.includes(ua)}var Hn=new Set;async function ns(e,n){let t=performance.now(),r=[],{allowScaling:a=!0,allowAutoPosition:o=!1,groundAxis:i="z",rhino:l,debug:s=!1,parsing:c={}}=_nullishCoalesce(n, () => ({}));try{let u=a?ma(e.modelunits):1;return await fa(e,r,u,c,l,s),o&&ga(r,i),r}catch(u){throw ya(u,r),u}finally{s&&Ta(t)}}function ma(e){let n=Mn[e];return n!==void 0?n:(Hn.has(e)||(Hn.add(e),_chunkH3FZW6OXcjs.e.call(void 0, ).warn(`Unknown Rhino model unit "${e}" \u2014 geometry will not be scaled (factor 1). Known units: ${Object.keys(Mn).join(", ")}.`)),1)}async function fa(e,n,t,r,a,o){for(let i of e.values){let l=i.InnerTree;for(let s in l){let c=l[s];c&&await pa(c,n,t,r,a,o)}}}async function pa(e,n,t,r,a,o){for(let i of e){if(!da(i.type))continue;let l={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...r},s=Ea(i.data);if(!s){_chunkH3FZW6OXcjs.e.call(void 0, ).error("Error parsing display batch envelope: invalid JSON");continue}let c=await mt(s,l),u=on(s.items,{rhino:a,applyTransforms:l.applyTransforms}),d=[...c,...u];if(t!==1)for(let E of d)E.scale.set(t,t,t);n.push(...d),o&&_chunkH3FZW6OXcjs.e.call(void 0, ).debug(`Extracted ${c.length} meshes and ${u.length} items from batch`)}}function Ea(e){return typeof e=="string"?ha(e):e}function ha(e){try{return JSON.parse(e)}catch (e5){return}}function ga(e,n){if(e.length===0)return;let t=Ke(e);At(e,t.min[n],n)}function ya(e,n){_chunkH3FZW6OXcjs.e.call(void 0, ).error("An unexpected error occurred:",e),ba(n)}function ba(e){for(let n of e){let t=n;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(r=>r.dispose()):t.material.dispose())}}function Ta(e){let n=performance.now()-e;_chunkH3FZW6OXcjs.e.call(void 0, ).info("Time to process meshes:",`${n.toFixed(2)}ms`)}exports.a = kn; exports.b = xe; exports.c = Le; exports.d = Mt; exports.e = Ht; exports.f = Xe; exports.g = Ha; exports.h = Ct; exports.i = At; exports.j = Ke; exports.k = St; exports.l = Dt; exports.m = Lt; exports.n = we; exports.o = rt; exports.p = Rr; exports.q = Va; exports.r = $t; exports.s = qt; exports.t = ke; exports.u = Yt; exports.v = Kt; exports.w = _r; exports.x = Qt; exports.y = zr; exports.z = en; exports.A = ai; exports.B = Qr; exports.C = vi; exports.D = Mi; exports.E = on; exports.F = sn; exports.G = Do; exports.H = ln; exports.I = cn; exports.J = lt; exports.K = Lo; exports.L = Oo; exports.M = Io; exports.N = Po; exports.O = ki; exports.P = Fo; exports.Q = ct; exports.R = Xi; exports.S = mt; exports.T = Ki; exports.U = Mn; exports.V = ns;
120
- //# sourceMappingURL=chunk-3QSC23Y2.cjs.map