@selvajs/compute 3.0.1 → 3.1.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/chunk-2KQHHQZW.js +2 -0
  2. package/dist/chunk-2KQHHQZW.js.map +1 -0
  3. package/dist/chunk-7XMD5YXP.cjs +62 -0
  4. package/dist/chunk-7XMD5YXP.cjs.map +1 -0
  5. package/dist/chunk-CUQQ3ZBV.cjs +4 -0
  6. package/dist/chunk-CUQQ3ZBV.cjs.map +1 -0
  7. package/dist/chunk-HOWV4A5D.cjs +2 -0
  8. package/dist/chunk-HOWV4A5D.cjs.map +1 -0
  9. package/dist/chunk-PX2YTSHJ.js +62 -0
  10. package/dist/chunk-PX2YTSHJ.js.map +1 -0
  11. package/dist/chunk-WPB2LKCD.js +4 -0
  12. package/dist/chunk-WPB2LKCD.js.map +1 -0
  13. package/dist/core.cjs +1 -1
  14. package/dist/core.cjs.map +1 -1
  15. package/dist/core.d.cts +49 -3
  16. package/dist/core.d.ts +49 -3
  17. package/dist/core.js +1 -1
  18. package/dist/grasshopper.cjs +1 -1
  19. package/dist/grasshopper.cjs.map +1 -1
  20. package/dist/grasshopper.d.cts +222 -32
  21. package/dist/grasshopper.d.ts +222 -32
  22. package/dist/grasshopper.js +1 -1
  23. package/dist/{handle-files-Bu2qmaPj.d.ts → handle-files-BISo_wob.d.cts} +53 -69
  24. package/dist/{handle-files-Bu2qmaPj.d.cts → handle-files-BISo_wob.d.ts} +53 -69
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +4 -4
  28. package/dist/index.d.ts +4 -4
  29. package/dist/index.js +1 -1
  30. package/dist/types-BGhtYxZ-.d.cts +45 -0
  31. package/dist/types-BGhtYxZ-.d.ts +45 -0
  32. package/dist/{types-DxT3hSkx.d.ts → types-C8XWc4Ab.d.cts} +99 -67
  33. package/dist/{types-D-HQ-gWI.d.cts → types-Dtok-mVq.d.ts} +99 -67
  34. package/dist/visualization-4RSUYQG2.cjs +2 -0
  35. package/dist/visualization-4RSUYQG2.cjs.map +1 -0
  36. package/dist/visualization-MOYO6MDN.js +2 -0
  37. package/dist/visualization.cjs +1 -1
  38. package/dist/visualization.cjs.map +1 -1
  39. package/dist/visualization.d.cts +200 -37
  40. package/dist/visualization.d.ts +200 -37
  41. package/dist/visualization.js +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunk-6LCAIDQV.cjs +0 -4
  44. package/dist/chunk-6LCAIDQV.cjs.map +0 -1
  45. package/dist/chunk-CFBKO3HX.cjs +0 -2
  46. package/dist/chunk-CFBKO3HX.cjs.map +0 -1
  47. package/dist/chunk-JF5MZTOU.cjs +0 -55
  48. package/dist/chunk-JF5MZTOU.cjs.map +0 -1
  49. package/dist/chunk-LUP3B2DK.js +0 -55
  50. package/dist/chunk-LUP3B2DK.js.map +0 -1
  51. package/dist/chunk-O55PTKMV.js +0 -4
  52. package/dist/chunk-O55PTKMV.js.map +0 -1
  53. package/dist/chunk-UAL4YXRX.js +0 -2
  54. package/dist/chunk-UAL4YXRX.js.map +0 -1
  55. package/dist/types-ChF690kY.d.cts +0 -88
  56. package/dist/types-ChF690kY.d.ts +0 -88
  57. package/dist/visualization-LZ4XZPYZ.cjs +0 -2
  58. package/dist/visualization-LZ4XZPYZ.cjs.map +0 -1
  59. package/dist/visualization-SV4BTHXJ.js +0 -2
  60. /package/dist/{visualization-SV4BTHXJ.js.map → visualization-MOYO6MDN.js.map} +0 -0
@@ -0,0 +1,62 @@
1
+ import{a as Mt,c as ne,d as re,e as A,j as Ie}from"./chunk-WPB2LKCD.js";var At={};Mt(At,{CONCRETE_MATERIAL:()=>Pe,EMISSIVE_MATERIAL:()=>Oe,GLASS_MATERIAL:()=>Ve,METAL_MATERIAL:()=>De,PLASTIC_MATERIAL:()=>Fe,RUBBER_MATERIAL:()=>Be,SHARED_MATERIALS:()=>ye,WOOD_MATERIAL:()=>ke});import*as D from"three";var Oe=new D.MeshPhysicalMaterial({color:0,emissive:new D.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:D.FrontSide,dithering:!0}),De=new D.MeshPhysicalMaterial({color:new D.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:D.FrontSide,dithering:!0}),Pe=new D.MeshPhysicalMaterial({color:new D.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:D.FrontSide,dithering:!0}),Fe=new D.MeshPhysicalMaterial({color:new D.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:D.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Ve=new D.MeshPhysicalMaterial({color:new D.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:D.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Be=new D.MeshPhysicalMaterial({color:new D.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:D.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),ke=new D.MeshPhysicalMaterial({color:new D.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:D.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),ye=new Set([Oe,De,Pe,Fe,Ve,Be,ke]);import*as B from"three";var K={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 qr(e,r,t,n,i){if(Ot(e),r.length===0)return;r.forEach(u=>{e.add(u)});let o=be(r),a=o.getCenter(new B.Vector3),s=o.getSize(new B.Vector3),l=Math.max(s.x,s.y,s.z);if(l/Math.min(s.x||1,s.y||1,s.z||1)>K.SCALE_RATIO_THRESHOLD||l>K.HUGE_THRESHOLD?(t.near=l*K.NEAR_PLANE_FACTOR.TINY,t.far=l*K.FAR_PLANE_FACTOR.HUGE):l>K.LARGE_THRESHOLD?(t.near=l*K.NEAR_PLANE_FACTOR.SMALL,t.far=l*K.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,l*K.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,l*K.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),!i){let u=l*K.INITIAL_DISTANCE_MULTIPLIER;t.position.set(a.x+u*.8,a.y+u,a.z+u*1.2),n.target.copy(a),n.update()}}function Ue(e){if(!e||typeof e!="string")return A().warn(`Invalid color input: ${e}, using white`),new B.Color(16777215);let r=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(r))try{let n=r.startsWith("#")?r:`#${r}`;return new B.Color(n)}catch{return A().warn(`Invalid hex color: ${e}, using white`),new B.Color(16777215)}if(r.includes(",")){let n=r.split(",").map(i=>parseInt(i.trim(),10));if(n.length===3&&n.every(i=>!isNaN(i)&&i>=0&&i<=255))return new B.Color(n[0]/255,n[1]/255,n[2]/255)}let t=r.toLowerCase();return t in B.Color.NAMES?new B.Color(B.Color.NAMES[t]):(A().warn(`Invalid color string: ${e}, using white`),new B.Color(16777215))}function ze(e,r,t="z"){e.forEach(n=>{n.position[t]-=r})}function be(e){let r=new B.Box3;return e.length===0||e.forEach(t=>{t.updateMatrixWorld(!0);let n=new B.Box3().setFromObject(t);r.union(n)}),r}var St=new Set(["grid","floor","label-layer","measure"]);function Lt(e){let r=e;for(;r;){if(typeof r.userData.id=="string"&&St.has(r.userData.id))return!0;r=r.parent}return!1}function Q(e){e.updateMatrixWorld(!0);let r=new B.Box3;return e.traverse(t=>{let n=t;t.visible&&!Lt(t)&&n.geometry&&r.expandByObject(t)}),r}var It=new Set(["floor","grid","label-layer"]);function Ot(e){[...e.children].forEach(t=>{It.has(t.userData.id)||t.userData.source!=="user"&&(t.traverse(n=>{let i=n;if(!i.geometry&&!i.material)return;i.geometry?.dispose();let o=i.material;if(!o)return;(Array.isArray(o)?o:[o]).forEach(s=>{if(!ye.has(s)){for(let l of Object.values(s))l instanceof B.Texture&&l.dispose();s.dispose()}})}),t.removeFromParent())})}import*as U from"three";function Dt(e){let r=e.clone().normalize(),t=new U.Vector3(0,0,1),n=new U.Vector3(0,1,0),i=Math.abs(r.dot(t))>.9?n:t,o=new U.Vector3().crossVectors(r,i).normalize(),a=new U.Vector3().crossVectors(o,r).normalize();return{top:r.clone(),bottom:r.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(r.clone()).normalize()}}function _e(e){let{scene:r,perspective:t,controls:n,onActiveCameraChange:i}=e,o=(e.up??t.up).clone().normalize(),a=Dt(o),s=new U.OrthographicCamera(-1,1,1,-1,t.near,t.far);s.up.copy(o);let l="perspective",c=t.aspect,u=()=>l==="perspective"?t:s,m=null,d=()=>{m?.cancel(),m=null},f=()=>{let R=(l==="orthographic"?s:t).position.distanceTo(n.target)*Math.tan(t.fov*Math.PI/360),w=R*c;s.left=-w,s.right=w,s.top=R,s.bottom=-R,s.near=t.near,s.far=t.far,s.updateProjectionMatrix()},b=p=>{if(p!==l){if(d(),p==="orthographic")s.position.copy(t.position),s.up.copy(t.up),s.lookAt(n.target),s.zoom=1,f();else{let R=(s.top-s.bottom)/(2*s.zoom)/Math.tan(t.fov*Math.PI/360),w=s.position.clone().sub(n.target);w.lengthSq()<1e-12&&w.copy(o),w.normalize(),t.position.copy(n.target).add(w.multiplyScalar(R))}l=p,n.object=u(),n.update(),i(u())}},T=(p,g,R,w)=>{let S=t.fov*(Math.PI/180),F=g/(2*Math.tan(S/2))*1.5,Y=Pt(R,o),V=p.clone().add(Y.clone().multiplyScalar(F)),X=u();l==="orthographic"&&(s.zoom=1),d(),w?m=Vt(X,n,V,p,()=>{l==="orthographic"&&f()}):(X.position.copy(V),n.target.copy(p),l==="orthographic"&&f(),n.update())},H=(p,g=!0)=>{let R=Q(r),w=R.isEmpty()?n.target.clone():R.getCenter(new U.Vector3),S=R.isEmpty()?new U.Vector3(1,1,1):R.getSize(new U.Vector3),F=Math.max(S.x,S.y,S.z)||1;T(w,F,p,g)};return{getActiveCamera:u,getProjection:()=>l,setProjection:b,toggleProjection:()=>(b(l==="perspective"?"orthographic":"perspective"),l),setView:(p,g=!0)=>{H(a[p],g)},setViewDirection:H,frameBounds:(p,g=!0)=>{if(p.isEmpty())return;let R=p.getCenter(new U.Vector3),w=p.getSize(new U.Vector3),S=Math.max(w.x,w.y,w.z)||1,F=u().position.clone().sub(n.target);F.lengthSq()<1e-12&&F.copy(a.iso),T(R,S,F.normalize(),g)},setRotateEnabled:p=>{n.enableRotate=p},isRotateEnabled:()=>n.enableRotate,updateAspect:(p,g)=>{c=g===0?c:p/g,l==="orthographic"&&f()},dispose:d}}function Pt(e,r){let t=r.clone().normalize(),n=e.clone().normalize();if(Math.abs(n.dot(t))<.9999)return e;let i=Math.abs(t.dot(new U.Vector3(0,0,1)))>.9?new U.Vector3(0,1,0):new U.Vector3(0,0,1),o=new U.Vector3().crossVectors(t,i).normalize(),a=.5*Math.PI/180;return n.multiplyScalar(Math.cos(a)).add(o.multiplyScalar(Math.sin(a))).normalize()}var Ft=e=>1-Math.pow(1-e,3);function Vt(e,r,t,n,i,o=250){let a=e.position.clone(),s=r.target.clone(),l=performance.now(),c=null,u=()=>{c=null;let m=Ft(Math.min((performance.now()-l)/o,1));e.position.lerpVectors(a,t,m),r.target.lerpVectors(s,n,m),i(),r.update(),m<1&&(c=requestAnimationFrame(u))};return c=requestAnimationFrame(u),{cancel:()=>{c!==null&&(cancelAnimationFrame(c),c=null)}}}import*as k from"three";var Bt=`
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
+ `,kt=`
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 je(e={}){let{cellSize:r=1,majorEvery:t=10,cellColor:n=8947848,majorColor:i=4473924,fadeDistance:o=100,plane:a="y"}=e,s=a==="y"?new k.Vector2(0,2):a==="z"?new k.Vector2(0,1):new k.Vector2(1,2),l=o*2.5,c=new k.PlaneGeometry(l,l);a==="y"?c.rotateX(-Math.PI/2):a==="x"&&c.rotateY(Math.PI/2);let u=new k.ShaderMaterial({vertexShader:Bt,fragmentShader:kt,transparent:!0,depthWrite:!1,side:k.DoubleSide,uniforms:{uAxes:{value:s},uCell:{value:r},uMajor:{value:t},uCellColor:{value:new k.Color(n)},uMajorColor:{value:new k.Color(i)},uCenter:{value:new k.Vector3},uFade:{value:o}}}),m=new k.Mesh(c,u);m.name="grid",m.userData.id="grid",m.renderOrder=-1;let d=new k.Vector3;return{object:m,update:f=>{a==="y"?(m.position.set(f.x,0,f.z),d.set(f.x,0,f.z)):a==="z"?(m.position.set(f.x,f.y,0),d.set(f.x,f.y,0)):(m.position.set(0,f.y,f.z),d.set(0,f.y,f.z)),u.uniforms.uCenter.value.copy(d)},setVisible:f=>{m.visible=f},dispose:()=>{m.removeFromParent(),c.dispose(),u.dispose()}}}import*as G from"three";import{ViewHelper as Ut}from"three/addons/helpers/ViewHelper.js";function Ne(e){let{camera:r,domElement:t,controller:n}=e,i=new Ut(r,t);i.setLabels("X","Y","Z");let o=!0,a=128,s=new G.Raycaster,l=new G.OrthographicCamera(-2,2,2,-2,0,4);l.position.set(0,0,2),l.updateMatrixWorld();let c={posX:new G.Vector3(1,0,0),negX:new G.Vector3(-1,0,0),posY:new G.Vector3(0,1,0),negY:new G.Vector3(0,-1,0),posZ:new G.Vector3(0,0,1),negZ:new G.Vector3(0,0,-1)},u=d=>{let f=t.getBoundingClientRect(),b=f.left+t.offsetWidth-a-i.location.right,T=f.top+t.offsetHeight-a-i.location.bottom,H=new G.Vector2((d.clientX-b)/a*2-1,-((d.clientY-T)/a)*2+1);if(Math.abs(H.x)>1||Math.abs(H.y)>1)return null;i.quaternion.copy(r.quaternion).invert(),i.updateMatrixWorld(),s.setFromCamera(H,l);let x=s.intersectObjects(i.children,!1);for(let y of x){let C=y.object.userData?.type;if(typeof C=="string"&&C in c)return C}return null};return{render:d=>{if(!o)return;let f=d.autoClear;d.autoClear=!1,i.render(d),d.autoClear=f},update:()=>{},handleClick:d=>{if(!o)return!1;let f=u(d);return f?(n.getProjection()==="orthographic"&&n.setProjection("perspective"),n.setViewDirection(c[f],!1),!0):!1},isAnimating:!1,setVisible:d=>{o=d},isVisible:()=>o,dispose:()=>i.dispose()}}import*as W from"three";import{LineSegmentsGeometry as zt}from"three/addons/lines/LineSegmentsGeometry.js";import{LineSegments2 as Re}from"three/addons/lines/LineSegments2.js";import{LineMaterial as _t}from"three/addons/lines/LineMaterial.js";var de="edge-overlay",jt=2236962,Nt=1.5,Gt=30,Wt=80,Ge=20,$t=1,Yt=2;function $e(e,r){let t=Array.isArray(e.material)?e.material:[e.material];for(let n of t)n&&(n.polygonOffset=r,n.polygonOffsetFactor=r?$t:0,n.polygonOffsetUnits=r?Yt:0)}var Te=new WeakMap;function Ye(e,r={}){let t=new W.Color(r.color??jt),n=r.width??Nt,i=r.thresholdAngle??Gt,o=r.distanceFade??!0,a=Zt(t,n,o),s=[];return e.traverse(l=>{if(!(l instanceof W.Mesh)||l.userData.id==="floor"||l.userData.id==="grid"||l.userData.kind===de||l.children.some(u=>u.userData?.kind===de)||!l.geometry)return;let c=Kt(l.geometry,a,i,o);l.add(c),$e(l,!0),s.push(c)}),s.length===0&&a.dispose(),s}function Xt(e,r){let t=Te.get(e);t||(t=new Map,Te.set(e,t));let n=t.get(r);if(!n){let i=new W.EdgesGeometry(e,r),o=new zt;o.setPositions(i.attributes.position.array),i.dispose(),n={geometry:o,refCount:0},t.set(r,n)}return n.refCount+=1,n.geometry}function qt(e){let r=e.userData,t=r.edgeSource&&Te.get(r.edgeSource),n=r.edgeThresholdAngle!=null?t?.get(r.edgeThresholdAngle):void 0;if(!n||n.geometry!==e.geometry){e.geometry.dispose();return}n.refCount-=1,n.refCount<=0&&(n.geometry.dispose(),t.delete(r.edgeThresholdAngle))}function Zt(e,r,t){let n=new _t({color:e});return n.linewidth=r,t&&(n.transparent=!0),n}function Kt(e,r,t,n){let i=Xt(e,t),o=new Re(i,r);return o.userData.kind=de,o.userData.edgeSource=e,o.userData.edgeThresholdAngle=t,o.raycast=()=>{},n&&en(o),o}var We=new W.Vector3,Jt=new W.Vector3;function Qt(e,r,t){e.geometry.boundingSphere||e.geometry.computeBoundingSphere();let n=e.geometry.boundingSphere;if(!n||n.radius<=0)return 1/0;let i=n.radius*e.matrixWorld.getMaxScaleOnAxis();if(We.copy(n.center).applyMatrix4(e.matrixWorld),r.isPerspectiveCamera){let o=r,a=Jt.setFromMatrixPosition(r.matrixWorld).distanceTo(We);if(a<=i)return 1/0;let s=Math.tan(W.MathUtils.degToRad(o.fov)*.5);return i/(a*s)*t}if(r.isOrthographicCamera){let o=r,a=(o.top-o.bottom)/o.zoom;return a>0?2*i/a*t:1/0}return 1/0}function en(e){e.onBeforeRender=(r,t,n)=>{Re.prototype.onBeforeRender.call(e,r);let i=e.material,o=Qt(e,n,i.resolution.y);i.opacity=W.MathUtils.clamp((o-Ge)/(Wt-Ge),0,1)}}function tn(e){return e.userData?.kind===de}function io(e){let r=[];e.traverse(n=>{n instanceof Re&&tn(n)&&r.push(n)});let t=new Set;for(let n of r)qt(n),t.add(n.material),n.parent instanceof W.Mesh&&$e(n.parent,!1),n.removeFromParent();return t.forEach(n=>n.dispose()),r.length}import{EffectComposer as nn}from"three/addons/postprocessing/EffectComposer.js";import{RenderPass as rn}from"three/addons/postprocessing/RenderPass.js";import{GTAOPass as on}from"three/addons/postprocessing/GTAOPass.js";import{SMAAPass as an}from"three/addons/postprocessing/SMAAPass.js";import{OutputPass as sn}from"three/addons/postprocessing/OutputPass.js";function Xe(e,r,t,n,i,o){let a=new nn(e),s=new rn(r,t);a.addPass(s);let l=new on(r,t,n,i);l.blendIntensity=o.aoIntensity??1,l.updateGtaoMaterial({screenSpaceRadius:!0}),a.addPass(l);let c=new an;a.addPass(c);let u=new sn;a.addPass(u),e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure;let m=o.aoPixelRatio??1;return a.setSize(n,i),{render:d=>a.render(d),setSize:(d,f,b)=>{a.setPixelRatio(Math.min(b,m)),a.setSize(d,f)},setCamera:d=>{s.camera=d,l.camera=d;let f=d.isPerspectiveCamera?1:0;l.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==f&&(l.gtaoMaterial.defines.PERSPECTIVE_CAMERA=f,l.gtaoMaterial.needsUpdate=!0)},dispose:()=>{a.dispose(),l.dispose(),c.dispose(),u.dispose()}}}import*as qe from"three";import{CSS2DRenderer as ln,CSS2DObject as cn}from"three/addons/renderers/CSS2DRenderer.js";function Ze(e,r){let t=new ln,n=t.domElement;n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.overflow="hidden",n.style.pointerEvents="none",n.style.zIndex="30",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(n);let i={width:e.clientWidth||1,height:e.clientHeight||1};t.setSize(i.width,i.height);let o=new qe.Group;o.name="label-layer",o.userData.id="label-layer",r.add(o);let a=new Set;return{addLabel:(l,c,u)=>{let m=document.createElement("div");m.textContent=l,u?m.className=u:Object.assign(m.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"}),m.style.pointerEvents="none";let d=new cn(m);return d.position.copy(c),o.add(d),a.add(d),{object:d,setPosition:f=>d.position.copy(f),setText:f=>{m.textContent=f},remove:()=>{d.removeFromParent(),m.remove(),a.delete(d)}}},render:(l,c)=>t.render(l,c),setSize:(l,c)=>t.setSize(l,c),dispose:()=>{a.forEach(l=>{l.removeFromParent(),l.element.remove()}),a.clear(),o.removeFromParent(),n.remove()}}}import*as O from"three";import{Line2 as un}from"three/addons/lines/Line2.js";import{LineGeometry as dn}from"three/addons/lines/LineGeometry.js";import{LineMaterial as mn}from"three/addons/lines/LineMaterial.js";var pn=12,fn=16763904,Ke=.015,Je={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 En(e){let r=e&&Je[e]||Je.Meters;return t=>`${(t/r.metersPerUnit).toPrecision(3)} ${r.suffix}`}function hn(e,r){if(e.isOrthographicCamera){let n=e;return Math.abs(n.top-n.bottom)/(n.zoom||1)*Ke}return((r?e.position.distanceTo(r):e.position.length())||1)*Ke}function gn(e){let r=e.object;if(r instanceof O.Mesh)return e.face?[e.face.a,e.face.b,e.face.c]:null;if(r instanceof O.Points)return e.index!=null?[e.index]:null;if(r instanceof O.Line){if(e.index==null)return null;let t=r.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 yn(e,r,t,n){let i=e.point.clone(),o=e.object,a=gn(e);if(!a||!o.geometry)return i;let s=o.geometry.attributes.position;if(!s)return i;let l=d=>{let f=d.clone().project(r);return new O.Vector2((f.x+1)/2*t.width,(1-f.y)/2*t.height)},c=l(i),u=i,m=n;for(let d of a){if(d>=s.count)continue;let b=new O.Vector3().fromBufferAttribute(s,d).applyMatrix4(o.matrixWorld),T=l(b).distanceTo(c);T<m&&(m=T,u=b)}return u}function Qe(e){let{canvas:r,scene:t,getActiveCamera:n,getViewTarget:i,labelLayer:o,options:a={}}=e,s=a.snapPixels??pn,l=new O.Color(a.color??fn),c=En(a.displayUnit),u=(L,v)=>`${c(L)}
54
+ \u0394x ${c(v.x)} \u0394y ${c(v.y)} \u0394z ${c(v.z)}`,m=a.format??u,d=new O.Raycaster,f=new O.Vector2,b=!1,T=[],H=[],x=null,y=null,C=new O.PointsMaterial({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),M=new O.PointsMaterial({color:l,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),p=null,g=L=>{if(!L){p&&(p.visible=!1);return}if(!p){let v=new O.BufferGeometry;v.setAttribute("position",new O.Float32BufferAttribute([0,0,0],3)),p=new O.Points(v,M),p.renderOrder=1e3,p.userData.id="measure",p.raycast=()=>{},t.add(p)}p.position.copy(L),p.visible=!0},R=L=>{let v=new O.BufferGeometry;v.setAttribute("position",new O.Float32BufferAttribute([L.x,L.y,L.z],3));let _=new O.Points(v,C);return _.renderOrder=999,_.userData.id="measure",_.raycast=()=>{},t.add(_),_},w=()=>{T.length=0,H.forEach(L=>{L.geometry.dispose(),L.removeFromParent()}),H.length=0,x&&(x.geometry.dispose(),x.material.dispose(),x.removeFromParent(),x=null),y?.remove(),y=null},S=()=>{if(T.length!==2)return;let[L,v]=T,_=new dn;_.setPositions([L.x,L.y,L.z,v.x,v.y,v.z]);let j=new mn({color:l});j.linewidth=2,j.depthTest=!1,x=new un(_,j),x.renderOrder=998,x.userData.id="measure",x.raycast=()=>{},t.add(x);let ee=L.clone().add(v).multiplyScalar(.5),te=new O.Vector3(Math.abs(v.x-L.x),Math.abs(v.y-L.y),Math.abs(v.z-L.z));y=o.addLabel(m(L.distanceTo(v),te),ee,a.labelClassName)},F=L=>{let v=r.getBoundingClientRect();f.x=(L.clientX-v.left)/v.width*2-1,f.y=-((L.clientY-v.top)/v.height)*2+1;let _=n();d.setFromCamera(f,_);let j=hn(_,i?.());d.params.Line.threshold=j,d.params.Points.threshold=j;let ee=d.intersectObjects(t.children,!0).filter(te=>te.object.userData.id!=="measure"&&te.object.userData.id!=="grid");return ee.length===0?null:yn(ee[0],_,{width:v.width,height:v.height},s)},Y=null,V=0,X=()=>{V&&(cancelAnimationFrame(V),V=0),Y=null};return{setEnabled:L=>{b=L,L||(X(),w(),g(null))},isEnabled:()=>b,handleClick:L=>{if(!b)return!1;T.length===2&&w();let v=F(L);return v===null||(T.push(v),H.push(R(v)),T.length===2&&S()),!0},handleMove:L=>{b&&(Y=L,!V&&(V=requestAnimationFrame(()=>{V=0;let v=Y;Y=null,!(!b||!v)&&g(F(v))})))},clear:w,dispose:()=>{X(),w(),p&&(p.geometry.dispose(),p.removeFromParent(),p=null),C.dispose(),M.dispose()}}}import*as Ee from"three";var bn=64,Tn=256,Z=new Map,ae=new Map,me=0,fe=class extends Error{constructor(r){super(`Texture load for ${r} resolved after clearTextureCache(); texture disposed.`),this.name="StaleTextureLoadError"}},pe=1;function et(e){pe=Math.max(1,e);for(let r of Z.values())r.anisotropy!==pe&&(r.anisotropy=pe,r.needsUpdate=!0)}function tt(e,r){let t=Rn(r),n=Z.get(t);if(n){Z.delete(t),Z.set(t,n),e.map=n,e.needsUpdate=!0;return}typeof document>"u"||xn(r,t).then(i=>{e.map=i,e.needsUpdate=!0}).catch(i=>{i instanceof fe||A().warn(`Failed to load material texture ${r}:`,i)})}function Ro(){me++;for(let e of Z.values())e.dispose();Z.clear(),ae.clear()}function Rn(e){return e.length<=Tn?e:`data-uri:${Hn(e).toString(16)}:${e.length}`}function Hn(e){let r=2166136261;for(let t=0;t<e.length;t++)r^=e.charCodeAt(t),r=Math.imul(r,16777619);return r>>>0}function vn(e,r){for(Z.set(e,r);Z.size>bn;){let t=Z.keys().next().value,n=Z.get(t);Z.delete(t),n.dispose()}}function xn(e,r){let t=ae.get(r);if(!t){let n=me;t=new Promise((i,o)=>{new Ee.TextureLoader().load(e,a=>{if(n!==me){a.dispose(),o(new fe(e));return}a.colorSpace=Ee.SRGBColorSpace,a.anisotropy=pe,vn(r,a),ae.delete(r),i(a)},void 0,a=>{n===me&&ae.delete(r),o(a)})}),ae.set(r,t)}return t}import*as E from"three";import{OrbitControls as An}from"three/addons/controls/OrbitControls.js";import{HDRLoader as Sn}from"three/addons/loaders/HDRLoader.js";import*as se from"three";var wn=.5,Cn=.01,Mn=.05;function nt({camera:e,scene:r,groundNormals:t=[]}){let n=e.near,i=e.near,o=new se.Vector3,a=new se.Vector3;return{update:()=>{e.near!==i&&(n=e.near);let l=Q(r),c=n;if(!l.isEmpty()){let u=l.getSize(a).length()*.5,m=e.position.distanceTo(l.getCenter(o))-u;for(let d of t)m=Math.min(m,Math.abs(e.position.dot(d)));c=se.MathUtils.clamp(m*wn,n,e.far*Cn)}Math.abs(c-i)>i*Mn&&(e.near=c,e.updateProjectionMatrix(),i=c)}}}var oe=new E.Vector3(0,0,1),Ln="technical",He={studio:{toneMapping:E.ACESFilmicToneMapping,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.75,ambientIntensity:.4,cullBackfaces:!1,ambientOcclusion:!1},technical:{toneMapping:E.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:.5,environmentIntensity:1,hemisphereIntensity:0,ambientIntensity:1,cullBackfaces:!1,ambientOcclusion:!1},showcase:{toneMapping:E.ACESFilmicToneMapping,toneMappingExposure:1.15,envMapIntensity:1.4,environmentIntensity:1.25,hemisphereIntensity:.35,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!1}};function In(e){let r=He[e];return{envMapIntensity:r.envMapIntensity,cullBackfaces:r.cullBackfaces}}function On(e){let r=Math.abs(e.x),t=Math.abs(e.y),n=Math.abs(e.z);return n>=r&&n>=t?"z":t>=r&&t>=n?"y":"x"}var ko=function(e,r){let t=Dn(r||{}),n=t.environment?.sceneUp||oe,i=t.render.pixelRatio??Math.min(window.devicePixelRatio,2),o=Fn(t),a=zn(t,e);a.up.copy(n);let s=_n(e,t,i);et(s.capabilities.getMaxAnisotropy());let l=Nn(a,e,t),c=_e({scene:o,perspective:a,controls:l,onActiveCameraChange:()=>{},up:n}),u=()=>c.getActiveCamera(),m=!1;Bn(o,t,()=>m);let d=kn(o,t),f=d.sun,b=()=>{f&&Pn(f,Q(o))};t.floor?.enabled&&Un(o,t);let T=t.grid.enabled?je({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;T&&o.add(T.object);let H=t.gizmo.enabled?Ne({camera:a,domElement:e,controller:c}):null,x=[];if(T){let h=t.grid.plane??"z";x.push(new E.Vector3(h==="x"?1:0,h==="y"?1:0,h==="z"?1:0))}t.floor.enabled&&x.push(n.clone().normalize());let y=t.camera.dynamicNear?nt({camera:a,scene:o,groundNormals:x}):null,C=e.parentElement??e,M=t.measure.enabled?Ze(C,o):null,p=t.measure.enabled&&M?Qe({canvas:e,scene:o,getActiveCamera:u,labelLayer:M,options:{snapPixels:t.measure.snapPixels,color:t.measure.color,labelClassName:t.measure.labelClassName,displayUnit:t.measure.displayUnit,format:t.measure.format}}):null,g=t.events.enableEventHandlers!==!1?jn(e,o,c,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},R=5,w=0,S=0,F=h=>{w=h.clientX,S=h.clientY},Y=h=>Math.hypot(h.clientX-w,h.clientY-S)>R,V=h=>{if(!Y(h)){if(p?.handleClick(h)){h.stopImmediatePropagation();return}H?.handleClick(h)&&h.stopImmediatePropagation()}};(H||p)&&(e.addEventListener("mousedown",F,{capture:!0}),e.addEventListener("click",V,{capture:!0}));let X=h=>p?.handleMove(h);p&&e.addEventListener("mousemove",X,{passive:!0});let ie=h=>{Ye(h,{color:t.edges.color,width:t.edges.width,thresholdAngle:t.edges.thresholdAngle,distanceFade:t.edges.distanceFade})},q=e.parentElement,L=()=>q?{width:q.clientWidth,height:q.clientHeight}:{width:window.innerWidth,height:window.innerHeight},v=null,_=()=>{let{width:h,height:I}=L(),N=Xe(s,o,u(),Math.max(1,h),Math.max(1,I),{toneMapping:t.render.toneMapping??E.NeutralToneMapping,toneMappingExposure:t.render.toneMappingExposure??1,aoIntensity:t.render.aoIntensity,aoPixelRatio:t.render.aoPixelRatio});return N.setSize(Math.max(1,h),Math.max(1,I),i),N},j=h=>{h&&!v?v=_():!h&&v&&(v.dispose(),v=null)};t.render.ambientOcclusion&&(v=_());let ee=h=>{h.ambientIntensity!==void 0&&(d.ambient.intensity=h.ambientIntensity),h.hemisphereIntensity!==void 0&&!d.hemisphere&&h.hemisphereIntensity>0&&(d.hemisphere=new E.HemisphereLight(h.hemisphereSkyColor??t.lighting.hemisphereSkyColor,h.hemisphereGroundColor??t.lighting.hemisphereGroundColor,h.hemisphereIntensity),d.hemisphere.position.copy(t.environment.sceneUp??oe),o.add(d.hemisphere)),d.hemisphere&&(h.hemisphereIntensity!==void 0&&(d.hemisphere.intensity=h.hemisphereIntensity),h.hemisphereSkyColor!==void 0&&d.hemisphere.color.set(h.hemisphereSkyColor),h.hemisphereGroundColor!==void 0&&d.hemisphere.groundColor.set(h.hemisphereGroundColor))},te=h=>{t.environment.environmentIntensity=h,o.environmentIntensity=h},gt=h=>{t.render.toneMappingExposure=h,s.toneMappingExposure=h,v&&(j(!1),j(!0))},yt=h=>{t.render.aoIntensity=h,v&&(j(!1),j(!0))},bt=h=>{let I=He[h];Ae=h,s.toneMapping=I.toneMapping,s.toneMappingExposure=I.toneMappingExposure,t.render.toneMapping=I.toneMapping,t.render.toneMappingExposure=I.toneMappingExposure,ee({hemisphereIntensity:I.hemisphereIntensity,ambientIntensity:I.ambientIntensity}),te(I.environmentIntensity),v&&j(!1),j(I.ambientOcclusion),o.traverse(N=>{if(N.userData.source!=="compute")return;let ue=N,Ct=Array.isArray(ue.material)?ue.material:ue.material?[ue.material]:[];for(let Le of Ct)"envMapIntensity"in Le&&(Le.envMapIntensity=I.envMapIntensity)})},Ae=t.look,Tt=()=>In(Ae),{animate:Rt,dispose:Ht}=Vn(s,o,a,u,c,l,L,i,t.events.onFrame,T,H,()=>v,M,y);Rt(),o.up.set(n.x,n.y,n.z),b();let Se=h=>{h.traverse(I=>{let N=I;!N.geometry&&!N.material||(N.geometry?.dispose(),Array.isArray(N.material)?N.material.forEach(he):N.material&&he(N.material))})},vt=h=>{h.userData.source="user",o.add(h)},xt=h=>{h.removeFromParent(),Se(h)},wt=()=>{o.children.filter(I=>I.userData.source==="user").forEach(I=>{I.removeFromParent(),Se(I)})};return{scene:o,camera:a,controls:l,renderer:s,cameraController:c,grid:T,gizmo:H,measureTool:p,applyEdges:ie,setAmbientOcclusion:j,setLook:bt,setFillLights:ee,setEnvironmentIntensity:te,setToneMappingExposure:gt,setAoIntensity:yt,getMaterialAppearance:Tt,updateShadowBounds:b,dispose:()=>{m||(m=!0,Ht(),g.dispose(),(H||p)&&(e.removeEventListener("mousedown",F,{capture:!0}),e.removeEventListener("click",V,{capture:!0})),p&&e.removeEventListener("mousemove",X),p?.dispose(),M?.dispose(),H?.dispose(),T?.dispose(),v?.dispose(),c.dispose(),l.dispose(),s.dispose(),s.forceContextLoss(),o.traverse(h=>{let I=h;!I.geometry&&!I.material||(I.geometry?.dispose(),Array.isArray(I.material)?I.material.forEach(he):I.material&&he(I.material))}),o.environment?.dispose(),o.background instanceof E.Texture&&o.background.dispose())},fitToView:g.fitToView,clearSelection:g.clearSelection,addUserGeometry:vt,removeUserGeometry:xt,clearUserGeometry:wt}};function Dn(e){let r=e.sceneScale||"m",n={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}}[r],i=e.look??Ln,o=He[i];return{sceneScale:r,look:i,camera:{position:e.camera?.position||new E.Vector3(-n.cameraDistance,-n.cameraDistance,n.cameraDistance),fov:e.camera?.fov||20,near:e.camera?.near||n.near,far:e.camera?.far||n.far,target:e.camera?.target||new E.Vector3(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??1,sunlightPosition:e.lighting?.sunlightPosition||new E.Vector3(n.lightDistance,n.lightDistance,n.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new E.Color(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??o.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??o.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??o.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath||"/baseHDR.hdr",backgroundColor:e.environment?.backgroundColor||new E.Color(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||oe,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??o.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||n.floorSize,color:e.floor?.color||new E.Color(8421504),roughness:e.floor?.roughness??.7,metalness:e.floor?.metalness??0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||2048,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping??o.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??o.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,ambientOcclusion:e.render?.ambientOcclusion??o.ambientOcclusion,aoIntensity:e.render?.aoIntensity??1,aoPixelRatio:e.render?.aoPixelRatio??1},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||n.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??!1,cellSize:e.grid?.cellSize??1,majorEvery:e.grid?.majorEvery??10,cellColor:e.grid?.cellColor??8947848,majorColor:e.grid?.majorColor??4473924,fadeDistance:e.grid?.fadeDistance??100,plane:e.grid?.plane??On(e.environment?.sceneUp??oe)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color??2236962,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??30,distanceFade:e.edges?.distanceFade??!0},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,displayUnit:e.measure?.displayUnit,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||"#ff0000",enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame}}}function he(e){for(let r of Object.values(e))r instanceof E.Texture&&r.dispose();e.dispose()}function Pn(e,r){if(r.isEmpty())return;let t=r.getCenter(new E.Vector3),n=r.getSize(new E.Vector3).length()*.5*1.2,i=e.shadow.camera;i.left=-n,i.right=n,i.top=n,i.bottom=-n,e.target.position.copy(t),e.target.updateMatrixWorld();let o=e.position.distanceTo(t);i.near=Math.max(n*.01,o-n),i.far=o+n,i.updateProjectionMatrix()}function Fn(e){let r=new E.Scene,t=typeof e.environment.backgroundColor=="string"?new E.Color(e.environment.backgroundColor):e.environment.backgroundColor;return r.background=t||null,r}function Vn(e,r,t,n,i,o,a,s,l,c,u,m,d,f){let b=null,T=performance.now(),H=()=>{let{width:C,height:M}=a();if(C===0||M===0)return;let p=Math.floor(C*s),g=Math.floor(M*s);(e.domElement.width!==p||e.domElement.height!==g)&&(e.setPixelRatio(s),e.setSize(C,M,!1),t.aspect=C/M,t.updateProjectionMatrix(),i.updateAspect(C,M),m?.()?.setSize(C,M,s),d?.setSize(C,M))},x=function(){b=requestAnimationFrame(x);let C=performance.now(),M=(C-T)/1e3;T=C,H(),(o.enableDamping||o.autoRotate)&&o.update(),c&&c.update(n().position),u&&u.update(M),f&&f.update(),l?.(M);let p=n(),g=m?.();g?(g.setCamera(p),g.render(M)):e.render(r,p),d&&d.render(r,p),u&&u.render(e)};return{animate:x,dispose:()=>{b!==null&&(cancelAnimationFrame(b),b=null)}}}function Bn(e,r,t){r.environment.enableEnvironmentLighting?new Sn().load(r.environment.hdrPath||"/baseHDR.hdr",function(n){if(t()){n.dispose();return}if(!n?.image){A().warn("HDR loaded without image data; skipping environment map."),n?.dispose(),r.events.onReady?.();return}n.mapping=E.EquirectangularReflectionMapping,e.environment=n,e.environmentIntensity=r.environment.environmentIntensity??1,r.environment.showEnvironment&&(e.background=n),r.events.onReady?.()},void 0,function(n){t()||(A().warn("HDR texture could not be loaded, falling back to basic lighting:",n),r.events.onReady?.())}):r.events.onReady?.()}function kn(e,r){let t=new E.AmbientLight(r.lighting.ambientLightColor,r.lighting.ambientLightIntensity);e.add(t);let n=null;if(r.lighting.enableHemisphereLight){n=new E.HemisphereLight(r.lighting.hemisphereSkyColor,r.lighting.hemisphereGroundColor,r.lighting.hemisphereIntensity);let a=r.environment.sceneUp??oe;n.position.copy(a),e.add(n)}if(!r.lighting.enableSunlight)return{ambient:t,hemisphere:n,sun:null};let i=new E.DirectionalLight(r.lighting.sunlightColor??16777215,r.lighting.sunlightIntensity),o=r.lighting.sunlightPosition;return o&&i.position.set(o.x,o.y,o.z),r.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=r.render.shadowMapSize||2048,i.shadow.mapSize.height=r.render.shadowMapSize||2048,i.shadow.bias=-1e-4,i.shadow.normalBias=.02,i.shadow.radius=4,e.add(i),e.add(i.target),{ambient:t,hemisphere:n,sun:i}):(e.add(i),{ambient:t,hemisphere:n,sun:null})}function Un(e,r){let t=r.floor.size,n=new E.PlaneGeometry(t,t),i=typeof r.floor.color=="string"?new E.Color(r.floor.color):r.floor.color,o=new E.MeshStandardMaterial({color:i,roughness:r.floor.roughness,metalness:r.floor.metalness,side:E.DoubleSide}),a=new E.Mesh(n,o);a.userData.id="floor",a.name="floor";let s=(r.environment?.sceneUp||oe).clone().normalize();a.quaternion.setFromUnitVectors(new E.Vector3(0,0,1),s),a.position.set(0,0,0),r.floor.receiveShadow&&r.render.enableShadows&&(a.receiveShadow=!0),e.add(a)}function zn(e,r){let t=r.parentElement,n=t?t.clientWidth:window.innerWidth,i=t?t.clientHeight:window.innerHeight,o=new E.PerspectiveCamera(e.camera.fov,n/i,e.camera.near,e.camera.far),a=e.camera.position;return a&&o.position.set(a.x,a.y,a.z),o}function _n(e,r,t){let n=new E.WebGLRenderer({antialias:r.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:r.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),i=e.parentElement,o=i?i.clientWidth:window.innerWidth,a=i?i.clientHeight:window.innerHeight;return i&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),n.setSize(o,a,!1),n.setPixelRatio(t),r.render.enableShadows&&(n.shadowMap.enabled=!0,n.shadowMap.type=E.VSMShadowMap),n.toneMapping=r.render.toneMapping,n.toneMappingExposure=r.render.toneMappingExposure??1,n.outputColorSpace=E.SRGBColorSpace,n.sortObjects=!0,n}function jn(e,r,t,n){let i=new Set,o=new Map,a=new E.Raycaster,s=new E.Vector2,l=new E.Vector2,c=()=>t.getActiveCamera(),u=p=>{let g=p;for(;g;){if(!g.visible)return!1;g=g.parent}return!0},m=()=>{let p=Q(r);if(p.isEmpty()){A().warn("No objects to fit to view");return}t.frameBounds(p,!1)},d=typeof n.events.selectionColor=="string"?new E.Color(n.events.selectionColor):n.events.selectionColor instanceof E.Color?n.events.selectionColor:new E.Color("#ff0000"),f=()=>{i.forEach(p=>{let g=p;if(o.has(p)){let R=o.get(p),w=g.material;w instanceof E.Material?w.dispose():Array.isArray(w)&&w.forEach(F=>F.dispose()),g.material=R,o.delete(p);let S=p;for(;S.parent;)S=S.parent;S!==r&&(R instanceof E.Material?R.dispose():R.forEach(F=>F.dispose()))}}),i.clear()},b=p=>{let g=p;if(!(g.material instanceof E.Material))return!1;o.set(p,g.material);let R=g.material.clone();return p instanceof E.Mesh&&"emissive"in R?R.emissive=d.clone():"color"in R&&(R.color=d.clone()),g.material=R,!0},T=()=>{let p=Q(r),g=p.isEmpty()?1:p.getSize(new E.Vector3).length();a.params.Points.threshold=g*.01},H=p=>{l.set(p.clientX,p.clientY)},x=p=>{let g=new E.Vector2(p.clientX,p.clientY);if(l.distanceTo(g)>5)return;let R=e.getBoundingClientRect();s.x=(p.clientX-R.left)/R.width*2-1,s.y=-((p.clientY-R.top)/R.height)*2+1,T(),a.setFromCamera(s,c());let w=a.intersectObjects(r.children,!0).filter(S=>u(S.object));if(w.length>0){let S=w[0].object;i.has(S)||(f(),i.add(S),b(S),n.events?.onObjectSelected?.(S),S instanceof E.Mesh&&Object.keys(S.userData).length>0&&n.events?.onMeshMetadataClicked?.(S.userData))}else f(),n.events?.onBackgroundClicked?.({x:s.x,y:s.y})},y=p=>{let g=e.getBoundingClientRect();s.x=(p.clientX-g.left)/g.width*2-1,s.y=-((p.clientY-g.top)/g.height)*2+1,T(),a.setFromCamera(s,c());let R=a.intersectObjects(r.children,!0).filter(F=>u(F.object));if(R.length===0)return;let w=R[0].object;if(n.events?.onMeshDoubleClicked?.(w),!n.events?.enableDoubleClickZoom)return;let S=new E.Box3().setFromObject(w);S.isEmpty()||t.frameBounds(S,!0)},C=p=>{if(n.events?.enableKeyboardControls)switch(p.key.toLowerCase()){case"f":p.preventDefault(),m();break;case"escape":p.preventDefault(),f();break;case" ":p.preventDefault(),m();break}};return n.events?.enableClickToFocus&&(e.addEventListener("mousedown",H),e.addEventListener("click",x),e.addEventListener("dblclick",y)),n.events?.enableKeyboardControls&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",C)),{dispose:()=>{e.removeEventListener("mousedown",H),e.removeEventListener("click",x),e.removeEventListener("dblclick",y),e.removeEventListener("keydown",C),f()},fitToView:m,clearSelection:f}}function Nn(e,r,t){let n=new An(e,r),i=t.camera.target;return i&&n.target.set(i.x,i.y,i.z),n.enableDamping=t.controls.enableDamping||!1,n.dampingFactor=t.controls.dampingFactor||.05,n.autoRotate=t.controls.autoRotate||!1,n.autoRotateSpeed=t.controls.autoRotateSpeed||.5,n.enableZoom=t.controls.enableZoom??!0,n.enablePan=t.controls.enablePan??!0,n.minDistance=t.controls.minDistance||.001,n.maxDistance=t.controls.maxDistance||1/0,n.screenSpacePanning=!1,n.maxPolarAngle=Math.PI,n.update(),n}var zo=["technical","studio","showcase"];import*as $ from"three";import{Line2 as Gn}from"three/addons/lines/Line2.js";import{LineGeometry as Wn}from"three/addons/lines/LineGeometry.js";import{LineMaterial as $n}from"three/addons/lines/LineMaterial.js";function ge(e,r,t,n=!0){return{x:e,y:r,z:t}}var Yn="#ffffff",rt=12,Xn=4e-4,qn=12,Zn=.05;function ot(e,r={}){if(!e||e.length===0)return[];let{rhino:t,applyTransforms:n=!0}=r,i=[];for(let o of e)switch(o.kind){case"curve":{let a=Jn(o,t,n);a&&i.push(a);break}case"point":{let a=Qn(o,n);a&&i.push(a);break}default:{let s=o;A().warn(`Skipping unknown display item kind: ${String(s.kind)}`);break}}return i}var Kn=2;function Jn(e,r,t){if(!r)return A().warn("No rhino3dm instance provided; skipping curve display item."),null;let n=er(e.json,r);if(!n)return null;let i;try{i=tr(n,t)}catch(m){return A().warn("Failed to tessellate curve display item; skipping.",m),null}finally{le(n)}if(i.length<2)return null;let o=[];for(let m of i)o.push(m.x,m.y,m.z);let a=new Wn;a.setPositions(o);let s=it(e.color,e.opacity),l=new $n({color:s.color}),c=l;c.linewidth=e.width??Kn,c.transparent=s.transparent,c.opacity=s.opacity;let u=new Gn(a,l);return u.computeLineDistances(),u.name=e.name,u.userData={source:"compute",id:e.id,layer:e.layer,kind:"curve",metadata:e.metadata},u}function Qn(e,r){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 A().warn(`Skipping point display item with missing or non-finite position (id: ${String(e.id)}).`),null;let{x:n,y:i,z:o}=ge(t.X,t.Y,t.Z,r),a=new $.BufferGeometry;a.setAttribute("position",new $.Float32BufferAttribute([n,i,o],3));let s=new $.PointsMaterial({...it(e.color,e.opacity),size:6,sizeAttenuation:!1}),l=new $.Points(a,s);return l.name=e.name,l.userData={source:"compute",id:e.id,layer:e.layer,kind:"point",metadata:e.metadata},l}function le(e){e?.delete?.()}function er(e,r){try{let t=JSON.parse(e),n=r.CommonObject.decode(t);return n&&typeof n.pointAt=="function"?n:(le(n),A().warn("Decoded display-item JSON is not a curve; skipping."),null)}catch(t){return A().warn("Failed to decode curve display item JSON:",t),null}}function tr(e,r){let t=nr(e,r);return t||rr(e,r)}function nr(e,r){if(!e.isPolyline())return null;let t=e.tryGetPolyline(),n=Array.isArray(t)?t[1]:t;if(!n||typeof n.count!="number"||n.count<2)return le(n),null;let i=[];for(let o=0;o<n.count;o++){let a=n.get(o),{x:s,y:l,z:c}=ge(a[0],a[1],a[2],r);i.push(new $.Vector3(s,l,c))}return le(n),i}function rr(e,r){let t=e.domain,n=t[0],o=t[1]-n,a=m=>{let d=e.pointAt(m),{x:f,y:b,z:T}=ge(d[0],d[1],d[2],r);return new $.Vector3(f,b,T)},s=or(e),l=n,c=a(n),u=[c];for(let m=0;m<rt;m++){let d=n+o*(m+1)/rt,f=a(d);ve(l,c,d,f,a,s,qn,u),u.push(f),l=d,c=f}return u}function ve(e,r,t,n,i,o,a,s){if(a<=0)return;let l=(e+t)/2,c=i(l),u=ar(c,r,n),m=ir(r,c,n);u<=o&&m<=Zn||(ve(e,r,l,c,i,o,a-1,s),s.push(c),ve(l,c,t,n,i,o,a-1,s))}function or(e){let r=e.getBoundingBox(),t=r.min,n=r.max;le(r);let i=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]);return Math.max(i*Xn,1e-6)}function ir(e,r,t){let n=r.x-e.x,i=r.y-e.y,o=r.z-e.z,a=t.x-r.x,s=t.y-r.y,l=t.z-r.z,c=Math.sqrt(n*n+i*i+o*o),u=Math.sqrt(a*a+s*s+l*l);if(c===0||u===0)return 0;let m=n*a+i*s+o*l,d=Math.max(-1,Math.min(1,m/(c*u)));return Math.acos(d)}function ar(e,r,t){let n=t.x-r.x,i=t.y-r.y,o=t.z-r.z,a=n*n+i*i+o*o;if(a===0)return e.distanceTo(r);let s=e.x-r.x,l=e.y-r.y,c=e.z-r.z,u=Math.max(0,Math.min(1,(s*n+l*i+c*o)/a)),m=s-n*u,d=l-i*u,f=c-o*u;return Math.sqrt(m*m+d*d+f*f)}function it(e,r){let t=r??1;return{color:new $.Color(e??Yn),transparent:t<1,opacity:t}}import{inflateSync as sr}from"fflate";var at=1096174675,lr=1515605075,st=3,lt=1,we=1,cr=2,ur=4,dr=8,mr=16,Jo=0,pr=1,ct=12,ut=56,fr=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;function Ce(e){if(!fr)throw new re("SLVA parsing requires a little-endian host: the zero-copy geometry readers view the wire bytes in host byte order.",ne.ENVIRONMENT_ERROR);let r=yr(gr(e)),t=new DataView(r.buffer,r.byteOffset,r.byteLength);if(r.byteLength<ct)throw z("Blob too small to contain SLVA header.",{expectedBytes:ct,availableBytes:r.byteLength});let n=0,i=t.getUint32(n,!0);if(n+=4,i!==at)throw z(`Invalid SLVA magic: 0x${i.toString(16)}`,{expectedMagic:`0x${at.toString(16)}`,actualMagic:`0x${i.toString(16)}`});let o=t.getUint32(n,!0);if(n+=4,o<lt||o>st)throw z(`Unsupported SLVA version: ${o}`,{minSupportedVersion:lt,maxSupportedVersion:st,actualVersion:o});let a=t.getUint32(n,!0);if(n+=4,n+a>r.byteLength)throw z("Insufficient data to read metadata JSON.",{expectedBytes:a,availableBytes:r.byteLength-n,offset:n});let s=r.subarray(n,n+a);n+=a;let l;try{l=JSON.parse(br(s))}catch(q){throw z(`Failed to parse metadata JSON: ${q instanceof Error?q.message:String(q)}`,{metadataLen:a})}if(n+ut>r.byteLength)throw z("Insufficient data to read geometry header.",{expectedBytes:ut,availableBytes:r.byteLength-n,offset:n});let c=t.getUint32(n,!0);n+=4;let u=t.getFloat64(n,!0);n+=8;let m=t.getFloat64(n,!0);n+=8;let d=t.getFloat64(n,!0);n+=8;let f=t.getFloat64(n,!0);n+=8;let b=t.getFloat64(n,!0);n+=8;let T=t.getFloat64(n,!0);n+=8;let H=t.getUint32(n,!0);n+=4;let x=(c&we)!==0,y=(c&ur)!==0,C=H*3,p=C*(x?4:2);if(n+p>r.byteLength)throw z("Insufficient data to read vertices.",{expectedBytes:p,availableBytes:r.byteLength-n,offset:n,useFloat32:x,vertexCount:H});let g=r.byteOffset+n,R;if(x?R=mt(r.buffer,g,C):y?R=vr(xe(r.buffer,g,C)):R=Tr(r.buffer,g,C),n+=p,n+4>r.byteLength)throw z("Insufficient data to read index count.",{expectedBytes:4,availableBytes:r.byteLength-n,offset:n});let w=t.getUint32(n,!0);n+=4;let S=(c&cr)!==0,Y=w*(S?2:4);if(n+Y>r.byteLength)throw z("Insufficient data to read indices.",{expectedBytes:Y,availableBytes:r.byteLength-n,offset:n,indexCount:w,useUint16Indices:S});let V=S?xe(r.buffer,r.byteOffset+n,w):Rr(r.buffer,r.byteOffset+n,w);y&&(V=V instanceof Uint16Array?xr(V):wr(V)),Hr(V,H),n+=Y;let X=null;if((c&dr)!==0){let q=Er(r,t,n,H,y);X=q.uvs,n=q.offset}let ie=null;return(c&mr)!==0&&(ie=hr(r,n,H,y)),{metadata:l,flags:c,vertices:R,indices:V,origin:[u,m,d],scale:[f,b,T],uvs:X,colors:ie}}var dt=36;function Er(e,r,t,n,i){if(t+dt>e.byteLength)throw z("Insufficient data to read UV chunk header.",{expectedBytes:dt,availableBytes:e.byteLength-t,offset:t});let o=r.getUint32(t,!0);t+=4;let a=r.getFloat64(t,!0);t+=8;let s=r.getFloat64(t,!0);t+=8;let l=r.getFloat64(t,!0);t+=8;let c=r.getFloat64(t,!0);t+=8;let u=n*2,m=o===pr,d=u*(m?4:2);if(t+d>e.byteLength)throw z("Insufficient data to read UV chunk.",{expectedBytes:d,availableBytes:e.byteLength-t,offset:t,uvFormat:o,vertexCount:n});let f=e.byteOffset+t,b;if(m)b=mt(e.buffer,f,u).slice();else{let T=xe(e.buffer,f,u);b=new Float32Array(u);let H=0,x=0;for(let y=0;y<u;y+=2)i?(H=H+J(T[y])&65535,x=x+J(T[y+1])&65535):(H=T[y],x=T[y+1]),b[y]=a+H*l,b[y+1]=s+x*c}return{uvs:b,offset:t+d}}function hr(e,r,t,n){let i=t*3;if(r+i>e.byteLength)throw z("Insufficient data to read vertex-color chunk.",{expectedBytes:i,availableBytes:e.byteLength-r,offset:r,vertexCount:t});let o=e.subarray(r,r+i);if(!n)return o.slice();let a=new Uint8Array(i),s=0,l=0,c=0;for(let u=0;u<i;u+=3)s=s+J(o[u])&255,l=l+J(o[u+1])&255,c=c+J(o[u+2])&255,a[u]=s,a[u+1]=l,a[u+2]=c;return a}function gr(e){return typeof e=="string"?Ie(e):e instanceof Uint8Array?e:new Uint8Array(e)}function yr(e){if(e.byteLength<8)return e;let r=new DataView(e.buffer,e.byteOffset,e.byteLength);if(r.getUint32(0,!0)!==lr)return e;let t=r.getUint32(4,!0),n=e.subarray(8),i=Math.max(n.byteLength*1032+1024,1<<20);if(t>i)throw z("SLVZ header declares an implausible uncompressed length",{uncompressedLen:t,deflatedBytes:n.byteLength,maxPlausibleLen:i});let o;try{o=sr(n,{out:new Uint8Array(t+1)})}catch(a){throw z(`Failed to inflate SLVZ blob: ${a instanceof Error?a.message:String(a)}`,{uncompressedLen:t,deflatedBytes:n.byteLength})}if(o.byteLength!==t)throw z("SLVZ payload inflated to a different size than the header declares.",{declaredLen:t,actualLen:o.byteLength,deflatedBytes:n.byteLength});return o}function br(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 re("No UTF-8 decoder available in this environment.",ne.INVALID_STATE)}function Tr(e,r,t){if(t===0)return new Int16Array(0);if(r%2===0)return new Int16Array(e,r,t);let n=new Uint8Array(t*2);return n.set(new Uint8Array(e,r,t*2)),new Int16Array(n.buffer)}function mt(e,r,t){if(t===0)return new Float32Array(0);if(r%4===0)return new Float32Array(e,r,t);let n=new Uint8Array(t*4);return n.set(new Uint8Array(e,r,t*4)),new Float32Array(n.buffer)}function xe(e,r,t){if(t===0)return new Uint16Array(0);if(r%2===0)return new Uint16Array(e,r,t);let n=new Uint8Array(t*2);return n.set(new Uint8Array(e,r,t*2)),new Uint16Array(n.buffer)}function Rr(e,r,t){if(t===0)return new Uint32Array(0);if(r%4===0)return new Uint32Array(e,r,t);let n=new Uint8Array(t*4);return n.set(new Uint8Array(e,r,t*4)),new Uint32Array(n.buffer)}function Hr(e,r){if(e.length!==0&&!(e instanceof Uint16Array&&r>65535)){for(let t=0;t<e.length;t++)if(e[t]>=r)throw z("Index out of range of vertexCount.",{indexPosition:t,indexValue:e[t],vertexCount:r})}}function J(e){return e>>>1^-(e&1)}function vr(e){let r=new Int16Array(e.length),t=0,n=0,i=0;for(let o=0;o<e.length;o+=3)t=t+J(e[o])<<16>>16,n=n+J(e[o+1])<<16>>16,i=i+J(e[o+2])<<16>>16,r[o]=t,r[o+1]=n,r[o+2]=i;return r}function xr(e){let r=new Uint16Array(e.length),t=0;for(let n=0;n<e.length;n++)t=t+J(e[n])&65535,r[n]=t;return r}function wr(e){let r=new Uint32Array(e.length),t=0;for(let n=0;n<e.length;n++)t=t+J(e[n])>>>0,r[n]=t;return r}function z(e,r){return new re(e,ne.VALIDATION_ERROR,{context:r})}import*as P from"three";async function ii(e,r){let{debug:t=!1}=r??{},n=t?performance.now():0,i,o=performance.now();try{i=JSON.parse(e)}catch(s){return A().error("Error parsing mesh batch envelope JSON:",s),[]}let a=performance.now()-o;return await Me(i,r,{parseTime:a,perfStart:n})}async function Me(e,r,t){let{mergeByMaterial:n=!0,applyTransforms:i=!0,debug:o=!1,material:a}=r??{},{parseTime:s=0,perfStart:l=o?performance.now():0}=t??{};if(!e.compressedData)return[];let c=performance.now(),u=Ce(e.compressedData),m=performance.now()-c,d=o?Dr(e.compressedData):0;return pt(u,{mergeByMaterial:n,applyTransforms:i,debug:o,material:a,parseTime:s,decodeTime:m,perfStart:l,blobBytes:d,fallback:{materials:e.materials,groups:e.groups,sourceComponentId:e.sourceComponentId}})}async function ai(e,r){let{mergeByMaterial:t=!0,applyTransforms:n=!0,debug:i=!1,material:o}=r??{},a=i?performance.now():0,s=performance.now(),l=Ce(e),c=performance.now()-s,u=e.byteLength;return pt(l,{mergeByMaterial:t,applyTransforms:n,debug:i,material:o,parseTime:0,decodeTime:c,perfStart:a,blobBytes:u})}function pt(e,r){let{mergeByMaterial:t,applyTransforms:n,debug:i,material:o,parseTime:a,decodeTime:s,perfStart:l,blobBytes:c,fallback:u}=r,m=e.metadata.materials??u?.materials??[],d=e.metadata.groups??u?.groups??[],f=u?.sourceComponentId??e.metadata.sourceComponentId,b=(e.flags&we)!==0;Cr(d,m.length,e.vertices.length/3,e.indices.length);let T=b?Ar(e.vertices,n):Mr(e.vertices,e.origin,e.scale,n);if(i){let M=e.vertices.byteLength+e.indices.byteLength;A().debug("Mesh Batch Stats:"),A().debug(` Materials: ${m.length} | Groups: ${d.length}`),A().debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),A().debug(` Format: ${b?"float32":"int16 quantized"}`),A().debug(` Blob: ${(c/1024/1024).toFixed(2)} MB | Geometry on wire: ${(M/1024/1024).toFixed(2)} MB`)}let H=performance.now(),x=m.map(M=>Sr(M,{vertexColors:e.colors!=null,appearance:o})),y=[];for(let M of d)if(t&&M.meshes.length>1){let p=Ir(M,T,e.indices,x,e.uvs,e.colors);p.userData.sourceComponentId=f??null,y.push(p)}else{let p=Or(M,T,e.indices,x,e.uvs,e.colors);for(let g of p)g.userData.sourceComponentId=f??null;y.push(...p)}let C=performance.now()-H;if(i){let M=performance.now()-l;A().debug("Performance:"),a>0&&A().debug(` Parse JSON: ${a.toFixed(2)}ms`),A().debug(` Decode binary: ${s.toFixed(2)}ms`),A().debug(` Create Meshes: ${C.toFixed(2)}ms`),A().debug(` Total: ${M.toFixed(2)}ms`)}return Promise.resolve(y)}function ce(e,r){return new re(e,ne.VALIDATION_ERROR,{context:r})}function Cr(e,r,t,n){for(let i of e){if(!Number.isInteger(i.materialId)||i.materialId<0||i.materialId>=r)throw ce("Group materialId out of range of the materials array.",{materialId:i.materialId,materialCount:r});for(let o of i.meshes){let a={vertexStart:o.vertexStart,vertexCount:o.vertexCount,indexStart:o.indexStart,indexCount:o.indexCount};for(let[s,l]of Object.entries(a))if(!Number.isInteger(l)||l<0)throw ce(`Mesh metadata field "${s}" must be a non-negative integer.`,{meshName:o.name,field:s,value:l});if(o.vertexStart+o.vertexCount>t)throw ce("Mesh vertex window exceeds the batch vertex buffer.",{meshName:o.name,vertexStart:o.vertexStart,vertexCount:o.vertexCount,totalVertexCount:t});if(o.indexStart+o.indexCount>n)throw ce("Mesh index window exceeds the batch index buffer.",{meshName:o.name,indexStart:o.indexStart,indexCount:o.indexCount,totalIndexCount:n})}}}function ft(e,r){if(e<r.vertexStart||e>=r.vertexStart+r.vertexCount)throw ce("Index references a vertex outside its mesh's vertex window.",{meshName:r.name,indexValue:e,vertexStart:r.vertexStart,vertexCount:r.vertexCount})}function Mr(e,r,t,n){let i=new Float32Array(e.length),o=r[0],a=r[1],s=r[2],l=t[0],c=t[1],u=t[2];for(let m=0;m<e.length;m+=3)i[m]=o+(e[m]+32767)*l,i[m+1]=a+(e[m+1]+32767)*c,i[m+2]=s+(e[m+2]+32767)*u;return i}function Ar(e,r){return e}function Sr(e,r){let t=Ue(e.color),n=r?.vertexColors??!1,i=r?.appearance,o=new P.MeshPhysicalMaterial({color:t,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,vertexColors:n,side:i?.cullBackfaces?P.FrontSide:P.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0});return i?.envMapIntensity!=null&&(o.envMapIntensity=i.envMapIntensity),n&&Lr(o),e.map&&tt(o,e.map),o}function Lr(e){e.onBeforeCompile=r=>{r.vertexShader=r.vertexShader.replace("#include <color_vertex>",`#include <color_vertex>
55
+ #if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
56
+ vColor.rgb = mix(
57
+ vColor.rgb / 12.92,
58
+ pow( ( vColor.rgb + 0.055 ) / 1.055, vec3( 2.4 ) ),
59
+ step( vec3( 0.04045 ), vColor.rgb )
60
+ );
61
+ #endif`)}}function Ir(e,r,t,n,i=null,o=null){let a=0,s=0;for(let y of e.meshes)a+=y.vertexCount,s+=y.indexCount;let l=new Float32Array(a*3),c=new Uint32Array(s),u=i?new Float32Array(a*2):null,m=o?new Uint8Array(a*3):null,d=0,f=0;for(let y of e.meshes){let C=y.vertexStart*3,M=y.vertexCount*3;if(l.set(r.subarray(C,C+M),d*3),u&&i){let R=y.vertexStart*2;u.set(i.subarray(R,R+y.vertexCount*2),d*2)}m&&o&&m.set(o.subarray(C,C+M),d*3);let p=t.subarray(y.indexStart,y.indexStart+y.indexCount),g=d-y.vertexStart;for(let R=0;R<p.length;R++){let w=p[R];ft(w,y),c[f+R]=w+g}d+=y.vertexCount,f+=y.indexCount}let b=new P.BufferGeometry;b.setAttribute("position",new P.BufferAttribute(l,3)),b.setIndex(new P.BufferAttribute(c,1)),u&&b.setAttribute("uv",new P.BufferAttribute(u,2)),m&&b.setAttribute("color",new P.BufferAttribute(m,3,!0)),b.computeVertexNormals();let T=new P.Mesh(b,n[e.materialId]),H=e.meshes[0],x=e.meshes.map(y=>y.name).filter(y=>y&&y.length>0);return T.name=x.length>0?x[0]:`merged_material_${e.materialId}`,T.castShadow=!0,T.receiveShadow=!0,T.userData={source:"compute",name:T.name,layer:H?.layer??"",originalIndex:H?.originalIndex??0,metadata:H?.metadata??{},mergedFrom:e.meshes.slice(1).map(y=>({name:y.name,layer:y.layer,originalIndex:y.originalIndex}))},T}function Or(e,r,t,n,i=null,o=null){let a=[];for(let s of e.meshes){let l=s.vertexStart*3,c=s.vertexCount*3,u=r.slice(l,l+c),m=t.subarray(s.indexStart,s.indexStart+s.indexCount),d=new Uint32Array(m.length),f=s.vertexStart;for(let H=0;H<m.length;H++){let x=m[H];ft(x,s),d[H]=x-f}let b=new P.BufferGeometry;if(b.setAttribute("position",new P.BufferAttribute(u,3)),b.setIndex(new P.BufferAttribute(d,1)),i){let H=s.vertexStart*2,x=i.slice(H,H+s.vertexCount*2);b.setAttribute("uv",new P.BufferAttribute(x,2))}if(o){let H=o.slice(l,l+c);b.setAttribute("color",new P.BufferAttribute(H,3,!0))}b.computeVertexNormals();let T=new P.Mesh(b,n[e.materialId]);T.name=s.name,T.userData={source:"compute",name:s.name,layer:s.layer??"",originalIndex:s.originalIndex,metadata:s.metadata??{}},T.castShadow=!0,T.receiveShadow=!0,a.push(T)}return a}function Dr(e){return Math.floor(e.length*3/4)}var Et={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},Pr="Display",Fr="DisplayBatch";function Vr(e){let r=e.split(".");return r.includes(Pr)||r.includes(Fr)}var ht=new Set;async function mi(e,r){let t=performance.now(),n=[],{allowScaling:i=!0,allowAutoPosition:o=!0,rhino:a,debug:s=!1,parsing:l={}}=r??{};try{let c=i?Br(e.modelunits):1;return await kr(e,n,c,l,a,s),o&&jr(n),n}catch(c){throw Nr(c,n),c}finally{s&&Wr(t)}}function Br(e){let r=Et[e];return r!==void 0?r:(ht.has(e)||(ht.add(e),A().warn(`Unknown Rhino model unit "${e}" \u2014 geometry will not be scaled (factor 1). Known units: ${Object.keys(Et).join(", ")}.`)),1)}async function kr(e,r,t,n,i,o){for(let a of e.values){let s=a.InnerTree;for(let l in s){let c=s[l];c&&await Ur(c,r,t,n,i,o)}}}async function Ur(e,r,t,n,i,o){for(let a of e){if(!Vr(a.type))continue;let s={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...n},l=zr(a.data);if(!l){A().error("Error parsing display batch envelope: invalid JSON");continue}let c=await Me(l,s),u=ot(l.items,{rhino:i,applyTransforms:s.applyTransforms}),m=[...c,...u];if(t!==1)for(let d of m)d.scale.set(t,t,t);r.push(...m),o&&A().debug(`Extracted ${c.length} meshes and ${u.length} items from batch`)}}function zr(e){return typeof e=="string"?_r(e):e}function _r(e){try{return JSON.parse(e)}catch{return}}function jr(e){if(e.length===0)return;let r=be(e);ze(e,r.min.z,"z")}function Nr(e,r){A().error("An unexpected error occurred:",e),Gr(r)}function Gr(e){for(let r of e){let t=r;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(n=>n.dispose()):t.material.dispose())}}function Wr(e){let r=performance.now()-e;A().info("Time to process meshes:",`${r.toFixed(2)}ms`)}export{At as a,qr as b,Ue as c,ze as d,be as e,_e as f,je as g,Ne as h,de as i,Ye as j,tn as k,io as l,Xe as m,Ze as n,yn as o,Qe as p,bn as q,et as r,Ro as s,In as t,ko as u,zo as v,ot as w,at as x,lr as y,st as z,lt as A,we as B,cr as C,ur as D,dr as E,mr as F,Jo as G,pr as H,Ce as I,ii as J,Me as K,ai as L,Et as M,mi as N};
62
+ //# sourceMappingURL=chunk-PX2YTSHJ.js.map