@selvajs/compute 3.1.0-beta.2 → 3.1.0-beta.4

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 (51) hide show
  1. package/dist/chunk-33753HSV.cjs +2 -0
  2. package/dist/{chunk-6WCVFKOV.cjs.map → chunk-33753HSV.cjs.map} +1 -1
  3. package/dist/chunk-4JNRO7TX.cjs +62 -0
  4. package/dist/chunk-4JNRO7TX.cjs.map +1 -0
  5. package/dist/chunk-6V6SUB4V.js +62 -0
  6. package/dist/chunk-6V6SUB4V.js.map +1 -0
  7. package/dist/chunk-D7A3YIYD.cjs +4 -0
  8. package/dist/chunk-D7A3YIYD.cjs.map +1 -0
  9. package/dist/chunk-EMXDP7KY.js +4 -0
  10. package/dist/chunk-EMXDP7KY.js.map +1 -0
  11. package/dist/chunk-MDFVHHH6.js +2 -0
  12. package/dist/chunk-MDFVHHH6.js.map +1 -0
  13. package/dist/core.cjs +1 -1
  14. package/dist/core.d.cts +2 -2
  15. package/dist/core.d.ts +2 -2
  16. package/dist/core.js +1 -1
  17. package/dist/grasshopper.cjs +1 -1
  18. package/dist/grasshopper.d.cts +4 -4
  19. package/dist/grasshopper.d.ts +4 -4
  20. package/dist/grasshopper.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.cts +2 -2
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +1 -1
  25. package/dist/{types-DK2-skCK.d.cts → types-BBSF_ISX.d.ts} +33 -4
  26. package/dist/{types-jb_K_a0s.d.ts → types-DxPi5SEx.d.cts} +33 -4
  27. package/dist/{types-ChF690kY.d.cts → types-V7G83j5m.d.cts} +12 -0
  28. package/dist/{types-ChF690kY.d.ts → types-V7G83j5m.d.ts} +12 -0
  29. package/dist/visualization-3XYZHAIV.js +2 -0
  30. package/dist/visualization-DEAMRV7R.cjs +2 -0
  31. package/dist/visualization-DEAMRV7R.cjs.map +1 -0
  32. package/dist/visualization.cjs +1 -1
  33. package/dist/visualization.d.cts +45 -8
  34. package/dist/visualization.d.ts +45 -8
  35. package/dist/visualization.js +1 -1
  36. package/package.json +3 -3
  37. package/dist/chunk-6WCVFKOV.cjs +0 -2
  38. package/dist/chunk-DRG5SLIP.cjs +0 -4
  39. package/dist/chunk-DRG5SLIP.cjs.map +0 -1
  40. package/dist/chunk-GL3B6EDO.cjs +0 -55
  41. package/dist/chunk-GL3B6EDO.cjs.map +0 -1
  42. package/dist/chunk-H4QOWA4L.js +0 -2
  43. package/dist/chunk-H4QOWA4L.js.map +0 -1
  44. package/dist/chunk-J3MFKB33.js +0 -4
  45. package/dist/chunk-J3MFKB33.js.map +0 -1
  46. package/dist/chunk-YWMDSXXD.js +0 -55
  47. package/dist/chunk-YWMDSXXD.js.map +0 -1
  48. package/dist/visualization-5KESJOFC.js +0 -2
  49. package/dist/visualization-KNQ2NANO.cjs +0 -2
  50. package/dist/visualization-KNQ2NANO.cjs.map +0 -1
  51. /package/dist/{visualization-5KESJOFC.js.map → visualization-3XYZHAIV.js.map} +0 -0
@@ -0,0 +1,62 @@
1
+ import{a as Je,c as le,d as ce,e as A,j as be}from"./chunk-EMXDP7KY.js";import*as k from"three";var Y={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 sn(e,n,t,r,o){if(Qe(e),n.length===0)return;n.forEach(d=>{e.add(d)});let a=Q(n),i=a.getCenter(new k.Vector3),s=a.getSize(new k.Vector3),l=Math.max(s.x,s.y,s.z);if(l/Math.min(s.x||1,s.y||1,s.z||1)>Y.SCALE_RATIO_THRESHOLD||l>Y.HUGE_THRESHOLD?(t.near=l*Y.NEAR_PLANE_FACTOR.TINY,t.far=l*Y.FAR_PLANE_FACTOR.HUGE):l>Y.LARGE_THRESHOLD?(t.near=l*Y.NEAR_PLANE_FACTOR.SMALL,t.far=l*Y.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,l*Y.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,l*Y.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),o)r.minDistance=t.near*2,r.maxDistance=t.far*.9;else{let d=l*Y.INITIAL_DISTANCE_MULTIPLIER;t.position.set(i.x+d*.8,i.y+d,i.z+d*1.2),r.target.copy(i),r.minDistance=t.near*2,r.maxDistance=t.far*.9,r.update()}}function Re(e){if(!e||typeof e!="string")return A().warn(`Invalid color input: ${e}, using white`),new k.Color(16777215);let n=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(n))try{let t=n.startsWith("#")?n:`#${n}`;return new k.Color(t)}catch{return A().warn(`Invalid hex color: ${e}, using white`),new k.Color(16777215)}if(n.includes(",")){let t=n.split(",").map(r=>parseInt(r.trim(),10));if(t.length===3&&t.every(r=>!isNaN(r)&&r>=0&&r<=255))return new k.Color(t[0]/255,t[1]/255,t[2]/255)}try{return new k.Color(n.toLowerCase())}catch{return A().warn(`Invalid color string: ${e}, using white`),new k.Color(16777215)}}function Te(e,n,t="z"){e.forEach(r=>{r.position[t]-=n})}function Q(e){let n=new k.Box3;return e.length===0||e.forEach(t=>{t.updateMatrixWorld(!0);let r=new k.Box3().setFromObject(t);n.union(r)}),n}var Ke=new Set(["floor","grid","label-layer"]);function Qe(e){[...e.children].forEach(t=>{Ke.has(t.userData.id)||t.userData.source!=="user"&&(t.traverse(r=>{let o=r;if(!o.geometry&&!o.material)return;o.geometry?.dispose();let a=o.material;if(!a)return;(Array.isArray(a)?a:[a]).forEach(s=>{for(let l of Object.values(s))l instanceof k.Texture&&l.dispose();s.dispose()})}),t.removeFromParent())})}import*as j from"three";function et(e){let n=e.clone().normalize(),t=new j.Vector3(0,0,1),r=new j.Vector3(0,1,0),o=Math.abs(n.dot(t))>.9?r:t,a=new j.Vector3().crossVectors(n,o).normalize(),i=new j.Vector3().crossVectors(a,n).normalize();return{top:n.clone(),bottom:n.clone().negate(),front:i.clone(),back:i.clone().negate(),right:a.clone(),left:a.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(a.clone()).add(n.clone()).normalize()}}function we(e){let{scene:n,perspective:t,controls:r,onActiveCameraChange:o}=e,a=(e.up??t.up).clone().normalize(),i=et(a),s=new j.OrthographicCamera(-1,1,1,-1,t.near,t.far);s.up.copy(a);let l="perspective",c=t.aspect,d=()=>l==="perspective"?t:s,u=()=>{let p=t.position.distanceTo(r.target)*Math.tan(t.fov*Math.PI/360),M=p*c;s.left=-M,s.right=M,s.top=p,s.bottom=-p,s.near=t.near,s.far=t.far,s.updateProjectionMatrix()},m=h=>{h!==l&&(h==="orthographic"?(s.position.copy(t.position),s.up.copy(t.up),s.lookAt(r.target),u()):t.position.copy(s.position),l=h,r.object=d(),r.update(),o(d()))},f=(h,p=!0)=>{let M=nt(n),w=M.isEmpty()?r.target.clone():M.getCenter(new j.Vector3),L=M.isEmpty()?new j.Vector3(1,1,1):M.getSize(new j.Vector3),b=Math.max(L.x,L.y,L.z)||1,T=t.fov*(Math.PI/180),C=b/(2*Math.tan(T/2))*1.5,I=ot(h,a),S=w.clone().add(I.clone().multiplyScalar(C)),V=d();p?it(V,r,S,w,()=>{l==="orthographic"&&u()}):(V.position.copy(S),r.target.copy(w),l==="orthographic"&&u(),r.update())};return{getActiveCamera:d,getProjection:()=>l,setProjection:m,toggleProjection:()=>(m(l==="perspective"?"orthographic":"perspective"),l),setView:(h,p=!0)=>{f(i[h],p)},setViewDirection:f,setRotateEnabled:h=>{r.enableRotate=h},isRotateEnabled:()=>r.enableRotate,updateAspect:(h,p)=>{c=p===0?c:h/p,l==="orthographic"&&u()}}}var tt=new Set(["grid","floor","label-layer","measure"]);function rt(e){let n=e;for(;n;){if(typeof n.userData.id=="string"&&tt.has(n.userData.id))return!0;n=n.parent}return!1}function nt(e){let n=[];return e.traverse(t=>{let r=t;t.visible&&!rt(t)&&r.geometry&&n.push(t)}),Q(n)}function ot(e,n){let t=n.clone().normalize(),r=e.clone().normalize();if(Math.abs(r.dot(t))<.9999)return e;let o=Math.abs(t.dot(new j.Vector3(0,0,1)))>.9?new j.Vector3(0,1,0):new j.Vector3(0,0,1),a=new j.Vector3().crossVectors(t,o).normalize(),i=.5*Math.PI/180;return r.multiplyScalar(Math.cos(i)).add(a.multiplyScalar(Math.sin(i))).normalize()}var at=e=>1-Math.pow(1-e,3);function it(e,n,t,r,o,a=250){let i=e.position.clone(),s=n.target.clone(),l=performance.now(),c=()=>{let d=at(Math.min((performance.now()-l)/a,1));e.position.lerpVectors(i,t,d),n.target.lerpVectors(s,r,d),o(),n.update(),d<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}import*as z from"three";var st=`
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
+ `,lt=`
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 He(e={}){let{cellSize:n=1,majorEvery:t=10,cellColor:r=8947848,majorColor:o=4473924,fadeDistance:a=100,plane:i="y"}=e,s=i==="y"?new z.Vector2(0,2):i==="z"?new z.Vector2(0,1):new z.Vector2(1,2),l=a*2.5,c=new z.PlaneGeometry(l,l);i==="y"?c.rotateX(-Math.PI/2):i==="x"&&c.rotateY(Math.PI/2);let d=new z.ShaderMaterial({vertexShader:st,fragmentShader:lt,transparent:!0,depthWrite:!1,side:z.DoubleSide,uniforms:{uAxes:{value:s},uCell:{value:n},uMajor:{value:t},uCellColor:{value:new z.Color(r)},uMajorColor:{value:new z.Color(o)},uCenter:{value:new z.Vector3},uFade:{value:a}}}),u=new z.Mesh(c,d);u.name="grid",u.userData.id="grid",u.renderOrder=-1;let m=new z.Vector3;return{object:u,update:f=>{i==="y"?(u.position.set(f.x,0,f.z),m.set(f.x,0,f.z)):i==="z"?(u.position.set(f.x,f.y,0),m.set(f.x,f.y,0)):(u.position.set(0,f.y,f.z),m.set(0,f.y,f.z)),d.uniforms.uCenter.value.copy(m)},setVisible:f=>{u.visible=f},dispose:()=>{c.dispose(),d.dispose()}}}import*as N from"three";import{ViewHelper as ct}from"three/addons/helpers/ViewHelper.js";function ve(e){let{camera:n,domElement:t,controller:r}=e,o=new ct(n,t);o.setLabels("X","Y","Z");let a=!0,i=128,s=new N.Raycaster,l=new N.OrthographicCamera(-2,2,2,-2,0,4);l.position.set(0,0,2),l.updateMatrixWorld();let c={posX:new N.Vector3(1,0,0),negX:new N.Vector3(-1,0,0),posY:new N.Vector3(0,1,0),negY:new N.Vector3(0,-1,0),posZ:new N.Vector3(0,0,1),negZ:new N.Vector3(0,0,-1)},d=m=>{let f=t.getBoundingClientRect(),y=f.left+t.offsetWidth-i-o.location.right,v=f.top+t.offsetHeight-i-o.location.bottom,g=new N.Vector2((m.clientX-y)/i*2-1,-((m.clientY-v)/i)*2+1);if(Math.abs(g.x)>1||Math.abs(g.y)>1)return null;o.quaternion.copy(n.quaternion).invert(),o.updateMatrixWorld(),s.setFromCamera(g,l);let h=s.intersectObjects(o.children,!1);for(let p of h){let M=p.object.userData?.type;if(typeof M=="string"&&M in c)return M}return null};return{render:m=>{if(!a)return;let f=m.autoClear;m.autoClear=!1,o.render(m),m.autoClear=f},update:m=>{o.animating&&o.update(m)},handleClick:m=>{if(!a)return!1;let f=d(m);return f?(r.getProjection()==="orthographic"&&r.setProjection("perspective"),r.setViewDirection(c[f],!1),!0):!1},get isAnimating(){return o.animating},setVisible:m=>{a=m},isVisible:()=>a,dispose:()=>o.dispose()}}import*as K from"three";import{LineSegmentsGeometry as ut}from"three/addons/lines/LineSegmentsGeometry.js";import{LineSegments2 as Me}from"three/addons/lines/LineSegments2.js";import{LineMaterial as dt}from"three/addons/lines/LineMaterial.js";var ne="edge-overlay",mt=2236962,pt=1.5,ft=30;function xe(e,n={}){let t=new K.Color(n.color??mt),r=n.width??pt,o=n.thresholdAngle??ft,a=[];return e.traverse(i=>{if(!(i instanceof K.Mesh)||i.userData.id==="floor"||i.userData.id==="grid"||i.userData.kind===ne||i.children.some(l=>l.userData?.kind===ne)||!i.geometry)return;let s=Et(i.geometry,t,r,o);i.add(s),a.push(s)}),a}function Et(e,n,t,r){let o=new K.EdgesGeometry(e,r),a=new ut;a.setPositions(o.attributes.position.array),o.dispose();let i=new dt({color:n});i.linewidth=t,i.polygonOffset=!0,i.polygonOffsetFactor=-1,i.polygonOffsetUnits=-1;let s=new Me(a,i);return s.userData.kind=ne,s.raycast=()=>{},s}function ht(e){return e.userData?.kind===ne}function yn(e){let n=[];e.traverse(t=>{t instanceof Me&&ht(t)&&n.push(t)});for(let t of n)t.geometry.dispose(),t.material.dispose(),t.removeFromParent();return n.length}import{EffectComposer as yt}from"three/addons/postprocessing/EffectComposer.js";import{RenderPass as gt}from"three/addons/postprocessing/RenderPass.js";import{GTAOPass as bt}from"three/addons/postprocessing/GTAOPass.js";import{SMAAPass as Rt}from"three/addons/postprocessing/SMAAPass.js";import{OutputPass as Tt}from"three/addons/postprocessing/OutputPass.js";function Ce(e,n,t,r,o,a){let i=new yt(e),s=new gt(n,t);i.addPass(s);let l=new bt(n,t,r,o);l.blendIntensity=a.aoIntensity??1,l.updateGtaoMaterial({screenSpaceRadius:!0}),i.addPass(l);let c=new Rt;i.addPass(c);let d=new Tt;return i.addPass(d),e.toneMapping=a.toneMapping,e.toneMappingExposure=a.toneMappingExposure,i.setSize(r,o),{render:u=>i.render(u),setSize:(u,m,f)=>{i.setPixelRatio(f),i.setSize(u,m)},setCamera:u=>{s.camera=u,l.camera=u},dispose:()=>{i.dispose(),l.dispose(),c.dispose(),d.dispose()}}}import*as Ae from"three";import{CSS2DRenderer as wt,CSS2DObject as Ht}from"three/addons/renderers/CSS2DRenderer.js";function Se(e,n){let t=new wt,r=t.domElement;r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.width="100%",r.style.height="100%",r.style.overflow="hidden",r.style.pointerEvents="none",r.style.zIndex="30",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(r);let o={width:e.clientWidth||1,height:e.clientHeight||1};t.setSize(o.width,o.height);let a=new Ae.Group;a.name="label-layer",a.userData.id="label-layer",n.add(a);let i=new Set;return{addLabel:(l,c,d)=>{let u=document.createElement("div");u.textContent=l,d?u.className=d:Object.assign(u.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"}),u.style.pointerEvents="none";let m=new Ht(u);return m.position.copy(c),a.add(m),i.add(m),{object:m,setPosition:f=>m.position.copy(f),setText:f=>{u.textContent=f},remove:()=>{m.removeFromParent(),u.remove(),i.delete(m)}}},render:(l,c)=>t.render(l,c),setSize:(l,c)=>t.setSize(l,c),dispose:()=>{i.forEach(l=>{l.removeFromParent(),l.element.remove()}),i.clear(),a.removeFromParent(),r.remove()}}}import*as D from"three";import{Line2 as vt}from"three/addons/lines/Line2.js";import{LineGeometry as Mt}from"three/addons/lines/LineGeometry.js";import{LineMaterial as xt}from"three/addons/lines/LineMaterial.js";var Ct=12,At=16763904,St=.015,De={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 Dt(e){let n=e&&De[e]||De.Meters;return t=>`${(t/n.metersPerUnit).toPrecision(3)} ${n.suffix}`}function Lt(e){let n=e.object;return n instanceof D.Mesh?e.face?[e.face.a,e.face.b,e.face.c]:null:n instanceof D.Points?e.index!=null?[e.index]:null:n instanceof D.Line&&e.index!=null?[e.index,e.index+1]:null}function Ot(e,n,t,r){let o=e.point.clone(),a=e.object,i=Lt(e);if(!i||!a.geometry)return o;let s=a.geometry.attributes.position;if(!s)return o;let l=m=>{let f=m.clone().project(n);return new D.Vector2((f.x+1)/2*t.width,(1-f.y)/2*t.height)},c=l(o),d=o,u=r;for(let m of i){if(m>=s.count)continue;let y=new D.Vector3().fromBufferAttribute(s,m).applyMatrix4(a.matrixWorld),v=l(y).distanceTo(c);v<u&&(u=v,d=y)}return d}function Le(e){let{canvas:n,scene:t,getActiveCamera:r,labelLayer:o,options:a={}}=e,i=a.snapPixels??Ct,s=new D.Color(a.color??At),l=Dt(a.displayUnit),c=(R,H)=>`${l(R)}
54
+ \u0394x ${l(H.x)} \u0394y ${l(H.y)} \u0394z ${l(H.z)}`,d=a.format??c,u=new D.Raycaster,m=new D.Vector2,f=!1,y=[],v=[],g=null,h=null,p=new D.PointsMaterial({color:s,size:8,sizeAttenuation:!1,depthTest:!1}),M=new D.PointsMaterial({color:s,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),w=null,L=R=>{if(!R){w&&(w.visible=!1);return}if(!w){let H=new D.BufferGeometry;H.setAttribute("position",new D.Float32BufferAttribute([0,0,0],3)),w=new D.Points(H,M),w.renderOrder=1e3,w.userData.id="measure",w.raycast=()=>{},t.add(w)}w.position.copy(R),w.visible=!0},b=R=>{let H=new D.BufferGeometry;H.setAttribute("position",new D.Float32BufferAttribute([R.x,R.y,R.z],3));let F=new D.Points(H,p);return F.renderOrder=999,F.userData.id="measure",F.raycast=()=>{},t.add(F),F},T=()=>{y.length=0,v.forEach(R=>{R.geometry.dispose(),R.removeFromParent()}),v.length=0,g&&(g.geometry.dispose(),g.material.dispose(),g.removeFromParent(),g=null),h?.remove(),h=null},C=()=>{if(y.length!==2)return;let[R,H]=y,F=new Mt;F.setPositions([R.x,R.y,R.z,H.x,H.y,H.z]);let U=new xt({color:s});U.linewidth=2,U.depthTest=!1,g=new vt(F,U),g.renderOrder=998,g.userData.id="measure",g.raycast=()=>{},t.add(g);let Z=R.clone().add(H).multiplyScalar(.5),$=new D.Vector3(Math.abs(H.x-R.x),Math.abs(H.y-R.y),Math.abs(H.z-R.z));h=o.addLabel(d(R.distanceTo(H),$),Z,a.labelClassName)},I=R=>{let H=n.getBoundingClientRect();m.x=(R.clientX-H.left)/H.width*2-1,m.y=-((R.clientY-H.top)/H.height)*2+1;let F=r();u.setFromCamera(m,F);let Z=F.position.length()*St;u.params.Line.threshold=Z,u.params.Points.threshold=Z;let $=u.intersectObjects(t.children,!0).filter(J=>J.object.userData.id!=="measure"&&J.object.userData.id!=="grid");return $.length===0?null:Ot($[0],F,{width:H.width,height:H.height},i)};return{setEnabled:R=>{f=R,R||(T(),L(null))},isEnabled:()=>f,handleClick:R=>{if(!f)return!1;y.length===2&&T();let H=I(R);return H===null||(y.push(H),v.push(b(H)),y.length===2&&C()),!0},handleMove:R=>{f&&L(I(R))},clear:T,dispose:()=>{T(),w&&(w.geometry.dispose(),w.removeFromParent(),w=null),p.dispose(),M.dispose()}}}import*as ae from"three";var te=new Map,ee=new Map,oe=1;function Oe(e){oe=Math.max(1,e);for(let n of te.values())n.anisotropy!==oe&&(n.anisotropy=oe,n.needsUpdate=!0)}function Pe(e,n){let t=te.get(n);if(t){e.map=t,e.needsUpdate=!0;return}typeof document>"u"||Pt(n).then(r=>{e.map=r,e.needsUpdate=!0}).catch(r=>{A().warn(`Failed to load material texture ${n}:`,r)})}function On(){for(let e of te.values())e.dispose();te.clear(),ee.clear()}function Pt(e){let n=ee.get(e);return n||(n=new Promise((t,r)=>{new ae.TextureLoader().load(e,o=>{o.colorSpace=ae.SRGBColorSpace,o.anisotropy=oe,te.set(e,o),ee.delete(e),t(o)},void 0,o=>{ee.delete(e),r(o)})}),ee.set(e,n)),n}import*as E from"three";import{OrbitControls as It}from"three/addons/controls/OrbitControls.js";import{HDRLoader as Vt}from"three/addons/loaders/HDRLoader.js";var ie=new E.Vector3(0,0,1),de={technical:{toneMapping:E.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:.5,cullBackfaces:!1,ambientOcclusion:!0,edges:!0,grid:!0},rendered:{toneMapping:E.ACESFilmicToneMapping,toneMappingExposure:1,envMapIntensity:1.3,cullBackfaces:!1,ambientOcclusion:!0,edges:!1,grid:!1}};function Bt(e){let n=de[e];return{envMapIntensity:n.envMapIntensity,cullBackfaces:n.cullBackfaces}}function Ft(e){let n=Math.abs(e.x),t=Math.abs(e.y),r=Math.abs(e.z);return r>=n&&r>=t?"z":t>=n&&t>=r?"y":"x"}var Wn=function(e,n){let t=Ut(n||{}),r=t.environment?.sceneUp||ie,o=jt(t),a=Xt(t,e);a.up.copy(r);let i=qt(e,t);Oe(i.capabilities.getMaxAnisotropy());let s=Jt(a,e,t),l=we({scene:o,perspective:a,controls:s,onActiveCameraChange:()=>{},up:r}),c=()=>l.getActiveCamera(),d=!1;Wt(o,t,()=>d);let u=$t(o,t),m=()=>{u&&kt(u,ue(o))};t.floor?.enabled&&Yt(o,t);let f=t.grid.enabled?He({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;f&&o.add(f.object);let y=t.gizmo.enabled?ve({camera:a,domElement:e,controller:l}):null,v=e.parentElement??e,g=t.measure.enabled?Se(v,o):null,h=t.measure.enabled&&g?Le({canvas:e,scene:o,getActiveCamera:c,labelLayer:g,options:{snapPixels:t.measure.snapPixels,color:t.measure.color,labelClassName:t.measure.labelClassName,displayUnit:t.measure.displayUnit,format:t.measure.format}}):null,p=t.events.enableEventHandlers!==!1?Zt(e,o,c,a,s,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},M=5,w=0,L=0,b=x=>{w=x.clientX,L=x.clientY},T=x=>Math.hypot(x.clientX-w,x.clientY-L)>M,C=x=>{if(!T(x)){if(h?.handleClick(x)){x.stopImmediatePropagation();return}y?.handleClick(x)&&x.stopImmediatePropagation()}};(y||h)&&(e.addEventListener("mousedown",b,{capture:!0}),e.addEventListener("click",C,{capture:!0}));let I=x=>h?.handleMove(x);h&&e.addEventListener("mousemove",I,{passive:!0});let S=x=>{xe(x,{color:t.edges.color,width:t.edges.width,thresholdAngle:t.edges.thresholdAngle})},V=e.parentElement,R=()=>V?{width:V.clientWidth,height:V.clientHeight}:{width:window.innerWidth,height:window.innerHeight},H=null,F=()=>{let{width:x,height:O}=R(),_=Math.min(window.devicePixelRatio,2),q=Ce(i,o,c(),Math.max(1,x),Math.max(1,O),{toneMapping:t.render.toneMapping??E.NeutralToneMapping,toneMappingExposure:t.render.toneMappingExposure??1,aoIntensity:t.render.aoIntensity});return q.setSize(Math.max(1,x),Math.max(1,O),_),q},U=x=>{x&&!H?H=F():!x&&H&&(H.dispose(),H=null)};t.render.ambientOcclusion&&(H=F());let Z=x=>{let O=de[x];$=x,i.toneMapping=O.toneMapping,i.toneMappingExposure=O.toneMappingExposure,t.render.toneMapping=O.toneMapping,t.render.toneMappingExposure=O.toneMappingExposure,H&&U(!1),U(O.ambientOcclusion),o.traverse(_=>{if(_.userData.source!=="compute")return;let q=_,Ze=Array.isArray(q.material)?q.material:q.material?[q.material]:[];for(let ge of Ze)"envMapIntensity"in ge&&(ge.envMapIntensity=O.envMapIntensity)}),o.traverse(_=>{_.userData.kind==="edge-overlay"&&(_.visible=O.edges)}),f&&(f.object.visible=O.grid)},$=n?.renderStyle??null,J=()=>$?Bt($):void 0,{animate:We,dispose:$e}=Nt(i,o,a,c,l,s,R,t.events.onFrame,f,y,()=>H,g);We(),o.up.set(r.x,r.y,r.z),m();let ye=x=>{x.traverse(O=>{let _=O;!_.geometry&&!_.material||(_.geometry?.dispose(),Array.isArray(_.material)?_.material.forEach(q=>q.dispose()):_.material?.dispose())})},Ye=x=>{x.userData.source="user",o.add(x)},Xe=x=>{x.removeFromParent(),ye(x)},qe=()=>{o.children.filter(O=>O.userData.source==="user").forEach(O=>{O.removeFromParent(),ye(O)})};return{scene:o,camera:a,controls:s,renderer:i,cameraController:l,grid:f,gizmo:y,measureTool:h,applyEdges:S,setAmbientOcclusion:U,setRenderStyle:Z,getMaterialAppearance:J,updateShadowBounds:m,dispose:()=>{d=!0,$e(),p.dispose(),(y||h)&&(e.removeEventListener("mousedown",b,{capture:!0}),e.removeEventListener("click",C,{capture:!0})),h&&e.removeEventListener("mousemove",I),h?.dispose(),g?.dispose(),y?.dispose(),f?.dispose(),H?.dispose(),s.dispose(),i.dispose(),i.forceContextLoss(),o.traverse(x=>{let O=x;!O.geometry&&!O.material||(O.geometry?.dispose(),Array.isArray(O.material)?O.material.forEach(_=>_.dispose()):O.material?.dispose())}),o.environment?.dispose(),o.background instanceof E.Texture&&o.background.dispose()},fitToView:p.fitToView,clearSelection:p.clearSelection,addUserGeometry:Ye,removeUserGeometry:Xe,clearUserGeometry:qe}};function Ut(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],o=e.renderStyle?de[e.renderStyle]:null;return{sceneScale:n,renderStyle:e.renderStyle??"technical",camera:{position:e.camera?.position||new E.Vector3(-r.cameraDistance,-r.cameraDistance,r.cameraDistance),fov:e.camera?.fov||20,near:e.camera?.near||r.near,far:e.camera?.far||r.far,target:e.camera?.target||new E.Vector3(0,0,0)},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??1,sunlightPosition:e.lighting?.sunlightPosition||new E.Vector3(r.lightDistance,r.lightDistance,r.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new E.Color(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??1,sunlightColor:e.lighting?.sunlightColor||16777215},environment:{hdrPath:e.environment?.hdrPath||"/baseHDR.hdr",backgroundColor:e.environment?.backgroundColor||new E.Color(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||ie,showEnvironment:e.environment?.showEnvironment??!1},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||r.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||E.NeutralToneMapping,toneMappingExposure:e.render?.toneMappingExposure??o?.toneMappingExposure??1,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,ambientOcclusion:e.render?.ambientOcclusion??o?.ambientOcclusion??!1,aoIntensity:e.render?.aoIntensity??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||r.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??o?.grid??!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??Ft(e.environment?.sceneUp??ie)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??o?.edges??!1,color:e.edges?.color??2236962,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??30},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}}}var zt=new Set(["grid","floor","label-layer","measure"]);function _t(e){let n=e;for(;n;){if(typeof n.userData.id=="string"&&zt.has(n.userData.id))return!0;n=n.parent}return!1}function ue(e){let n=new E.Box3;return e.traverse(t=>{let r=t;t.visible&&!_t(t)&&r.geometry&&n.expandByObject(t)}),n}function kt(e,n){if(n.isEmpty())return;let t=n.getCenter(new E.Vector3),r=n.getSize(new E.Vector3).length()*.5*1.2,o=e.shadow.camera;o.left=-r,o.right=r,o.top=r,o.bottom=-r,e.target.position.copy(t),e.target.updateMatrixWorld();let a=e.position.distanceTo(t);o.near=Math.max(r*.01,a-r),o.far=a+r,o.updateProjectionMatrix()}function jt(e){let n=new E.Scene,t=typeof e.environment.backgroundColor=="string"?new E.Color(e.environment.backgroundColor):e.environment.backgroundColor;return n.background=t||null,n}function Gt(e,n,t,r,o=200){let a=e.position.clone(),i=n.target.clone(),s=performance.now(),l=d=>1-Math.pow(1-d,3),c=()=>{let d=performance.now()-s,u=l(Math.min(d/o,1));e.position.lerpVectors(a,t,u),n.target.lerpVectors(i,r,u),n.update(),u<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}function Nt(e,n,t,r,o,a,i,s,l,c,d,u){let m=null,f=performance.now(),y=()=>{let{width:h,height:p}=i();if(h===0||p===0)return;let M=Math.min(window.devicePixelRatio,2),w=Math.floor(h*M),L=Math.floor(p*M);(e.domElement.width!==w||e.domElement.height!==L)&&(e.setPixelRatio(M),e.setSize(h,p,!1),t.aspect=h/p,t.updateProjectionMatrix(),o.updateAspect(h,p),d?.()?.setSize(h,p,M),u?.setSize(h,p))},v=function(){m=requestAnimationFrame(v);let h=performance.now(),p=(h-f)/1e3;f=h,y(),(a.enableDamping||a.autoRotate)&&a.update(),l&&l.update(r().position),c&&c.update(p),s?.(p);let M=r(),w=d?.();w?(w.setCamera(M),w.render(p)):e.render(n,M),u&&u.render(n,M),c&&c.render(e)};return{animate:v,dispose:()=>{m!==null&&(cancelAnimationFrame(m),m=null)}}}function Wt(e,n,t){n.environment.enableEnvironmentLighting?new Vt().load(n.environment.hdrPath||"/baseHDR.hdr",function(r){if(t()){r.dispose();return}if(!r?.image){A().warn("HDR loaded without image data; skipping environment map."),n.events.onReady?.();return}r.mapping=E.EquirectangularReflectionMapping,e.environment=r,n.environment.showEnvironment&&(e.background=r),n.events.onReady?.()},void 0,function(r){t()||(A().warn("HDR texture could not be loaded, falling back to basic lighting:",r),n.events.onReady?.())}):n.events.onReady?.()}function $t(e,n){let t=new E.AmbientLight(n.lighting.ambientLightColor,n.lighting.ambientLightIntensity);if(e.add(t),!n.lighting.enableSunlight)return null;let r=new E.DirectionalLight(n.lighting.sunlightColor??16777215,n.lighting.sunlightIntensity),o=n.lighting.sunlightPosition;return o&&r.position.set(o.x,o.y,o.z),n.render.enableShadows?(r.castShadow=!0,r.shadow.mapSize.width=n.render.shadowMapSize||2048,r.shadow.mapSize.height=n.render.shadowMapSize||2048,r.shadow.bias=-1e-4,r.shadow.normalBias=.02,r.shadow.radius=4,e.add(r),e.add(r.target),r):(e.add(r),null)}function Yt(e,n){let t=n.floor.size,r=new E.PlaneGeometry(t,t),o=typeof n.floor.color=="string"?new E.Color(n.floor.color):n.floor.color,a=new E.MeshStandardMaterial({color:o,roughness:n.floor.roughness,metalness:n.floor.metalness,side:E.DoubleSide}),i=new E.Mesh(r,a);i.userData.id="floor",i.name="floor";let s=(n.environment?.sceneUp||ie).clone().normalize();i.quaternion.setFromUnitVectors(new E.Vector3(0,0,1),s),i.position.set(0,0,0),n.floor.receiveShadow&&n.render.enableShadows&&(i.receiveShadow=!0),e.add(i)}function Xt(e,n){let t=n.parentElement,r=t?t.clientWidth:window.innerWidth,o=t?t.clientHeight:window.innerHeight,a=new E.PerspectiveCamera(e.camera.fov,r/o,e.camera.near,e.camera.far),i=e.camera.position;return i&&a.position.set(i.x,i.y,i.z),a}function qt(e,n){let t=new E.WebGLRenderer({antialias:n.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:n.render.preserveDrawingBuffer,logarithmicDepthBuffer:!0}),r=e.parentElement,o=r?r.clientWidth:window.innerWidth,a=r?r.clientHeight:window.innerHeight;return r&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),t.setSize(o,a,!1),t.setPixelRatio(n.render.pixelRatio||Math.min(window.devicePixelRatio,2)),n.render.enableShadows&&(t.shadowMap.enabled=!0,t.shadowMap.type=E.VSMShadowMap),t.toneMapping=n.render.toneMapping,t.toneMappingExposure=n.render.toneMappingExposure??1,t.outputColorSpace=E.SRGBColorSpace,t.sortObjects=!0,t}function Zt(e,n,t,r,o,a){let i=new Set,s=new Map,l=new E.Raycaster,c=new E.Vector2,d=new E.Vector2,u=b=>{let T=b;for(;T;){if(!T.visible)return!1;T=T.parent}return!0},m=()=>{let b=ue(n);if(b.isEmpty()){A().warn("No objects to fit to view");return}let T=b.getCenter(new E.Vector3),C=b.getSize(new E.Vector3),I=Math.max(C.x,C.y,C.z),S=r.fov*(Math.PI/180),V=I/(2*Math.tan(S/2));V*=1.5;let R=r.position.clone().sub(o.target);R.lengthSq()<1e-12&&R.set(.8,1,1.2),R.normalize(),r.position.copy(T.clone().add(R.multiplyScalar(V))),o.target.copy(T),o.update()},f=typeof a.events.selectionColor=="string"?new E.Color(a.events.selectionColor):a.events.selectionColor instanceof E.Color?a.events.selectionColor:new E.Color("#ff0000"),y=()=>{i.forEach(b=>{let T=b;if(s.has(b)){let C=s.get(b),I=T.material;I instanceof E.Material?I.dispose():Array.isArray(I)&&I.forEach(V=>V.dispose()),T.material=C,s.delete(b);let S=b;for(;S.parent;)S=S.parent;S!==n&&(C instanceof E.Material?C.dispose():C.forEach(V=>V.dispose()))}}),i.clear()},v=b=>{let T=b;if(!(T.material instanceof E.Material))return!1;s.set(b,T.material);let C=T.material.clone();return b instanceof E.Mesh&&"emissive"in C?C.emissive=f.clone():"color"in C&&(C.color=f.clone()),T.material=C,!0},g=()=>{let b=ue(n),T=b.isEmpty()?1:b.getSize(new E.Vector3).length();l.params.Points.threshold=T*.01},h=b=>{d.set(b.clientX,b.clientY)},p=b=>{let T=new E.Vector2(b.clientX,b.clientY);if(d.distanceTo(T)>5)return;let C=e.getBoundingClientRect();c.x=(b.clientX-C.left)/C.width*2-1,c.y=-((b.clientY-C.top)/C.height)*2+1,g(),l.setFromCamera(c,t());let I=l.intersectObjects(n.children,!0).filter(S=>u(S.object));if(I.length>0){let S=I[0].object;i.has(S)||(y(),i.add(S),v(S),a.events?.onObjectSelected?.(S),S instanceof E.Mesh&&Object.keys(S.userData).length>0&&a.events?.onMeshMetadataClicked?.(S.userData))}else y(),a.events?.onBackgroundClicked?.({x:c.x,y:c.y})},M=b=>{let T=e.getBoundingClientRect();c.x=(b.clientX-T.left)/T.width*2-1,c.y=-((b.clientY-T.top)/T.height)*2+1,g(),l.setFromCamera(c,t());let C=l.intersectObjects(n.children,!0).filter(J=>u(J.object));if(C.length===0)return;let I=C[0].object;if(a.events?.onMeshDoubleClicked?.(I),!a.events?.enableDoubleClickZoom)return;let S=new E.Box3().setFromObject(I);if(S.isEmpty())return;let V=S.getCenter(new E.Vector3),R=S.getSize(new E.Vector3),H=Math.max(R.x,R.y,R.z),F=r.fov*(Math.PI/180),U=H/(2*Math.tan(F/2))*1.5,Z=r.position.clone().sub(o.target).normalize(),$=V.clone().add(Z.multiplyScalar(U));Gt(r,o,$,V)},w=b=>{if(a.events?.enableKeyboardControls)switch(b.key.toLowerCase()){case"f":b.preventDefault(),m();break;case"escape":b.preventDefault(),y();break;case" ":b.preventDefault(),m();break}};return a.events?.enableClickToFocus&&(e.addEventListener("mousedown",h),e.addEventListener("click",p),e.addEventListener("dblclick",M)),a.events?.enableKeyboardControls&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",w)),{dispose:()=>{e.removeEventListener("mousedown",h),e.removeEventListener("click",p),e.removeEventListener("dblclick",M),e.removeEventListener("keydown",w),y()},fitToView:m,clearSelection:y}}function Jt(e,n,t){let r=new It(e,n),o=t.camera.target;return o&&r.target.set(o.x,o.y,o.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=t.controls.enableZoom??!0,r.enablePan=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 ar={};Je(ar,{CONCRETE_MATERIAL:()=>er,EMISSIVE_MATERIAL:()=>Kt,GLASS_MATERIAL:()=>rr,METAL_MATERIAL:()=>Qt,PLASTIC_MATERIAL:()=>tr,RUBBER_MATERIAL:()=>nr,WOOD_MATERIAL:()=>or});import*as P from"three";var Kt=new P.MeshPhysicalMaterial({color:0,emissive:new P.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,side:P.FrontSide,dithering:!0}),Qt=new P.MeshPhysicalMaterial({color:new P.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,side:P.FrontSide,dithering:!0}),er=new P.MeshPhysicalMaterial({color:new P.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:.5,depthTest:!0,polygonOffset:!0,side:P.FrontSide,dithering:!0}),tr=new P.MeshPhysicalMaterial({color:new P.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:P.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),rr=new P.MeshPhysicalMaterial({color:new P.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,opacity:.3,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:P.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),nr=new P.MeshPhysicalMaterial({color:new P.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:P.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),or=new P.MeshPhysicalMaterial({color:new P.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:P.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});import*as W from"three";import{Line2 as ir}from"three/addons/lines/Line2.js";import{LineGeometry as sr}from"three/addons/lines/LineGeometry.js";import{LineMaterial as lr}from"three/addons/lines/LineMaterial.js";function se(e,n,t,r=!0){return{x:e,y:n,z:t}}var cr="#ffffff",Ie=12,ur=4e-4,dr=12,mr=.05;function Ve(e,n={}){if(!e||e.length===0)return[];let{rhino:t,applyTransforms:r=!0}=n,o=[];for(let a of e)switch(a.kind){case"curve":{let i=fr(a,t,r);i&&o.push(i);break}case"point":{o.push(Er(a,r));break}default:{let i=a;A().warn(`Skipping unknown display item kind: ${String(i.kind)}`);break}}return o}var pr=2;function fr(e,n,t){if(!n)return A().warn("No rhino3dm instance provided; skipping curve display item."),null;let r=hr(e.json,n);if(!r)return null;let o;try{o=yr(r,t)}finally{re(r)}if(o.length<2)return null;let a=[];for(let u of o)a.push(u.x,u.y,u.z);let i=new sr;i.setPositions(a);let s=Be(e.color,e.opacity),l=new lr({color:s.color}),c=l;c.linewidth=e.width??pr,c.transparent=s.transparent,c.opacity=s.opacity;let d=new ir(i,l);return d.computeLineDistances(),d.name=e.name,d.userData={source:"compute",id:e.id,layer:e.layer,kind:"curve",metadata:e.metadata},d}function Er(e,n){let{x:t,y:r,z:o}=se(e.position.X,e.position.Y,e.position.Z,n),a=new W.BufferGeometry;a.setAttribute("position",new W.Float32BufferAttribute([t,r,o],3));let i=new W.PointsMaterial({...Be(e.color,e.opacity),size:6,sizeAttenuation:!1}),s=new W.Points(a,i);return s.name=e.name,s.userData={source:"compute",id:e.id,layer:e.layer,kind:"point",metadata:e.metadata},s}function re(e){e?.delete?.()}function hr(e,n){try{let t=JSON.parse(e),r=n.CommonObject.decode(t);return r&&typeof r.pointAt=="function"?r:(re(r),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 yr(e,n){let t=gr(e,n);return t||br(e,n)}function gr(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 re(r),null;let o=[];for(let a=0;a<r.count;a++){let i=r.get(a),{x:s,y:l,z:c}=se(i[0],i[1],i[2],n);o.push(new W.Vector3(s,l,c))}return re(r),o}function br(e,n){let t=e.domain,r=t[0],a=t[1]-r,i=u=>{let m=e.pointAt(u),{x:f,y,z:v}=se(m[0],m[1],m[2],n);return new W.Vector3(f,y,v)},s=Rr(e),l=r,c=i(r),d=[c];for(let u=0;u<Ie;u++){let m=r+a*(u+1)/Ie,f=i(m);me(l,c,m,f,i,s,dr,d),d.push(f),l=m,c=f}return d}function me(e,n,t,r,o,a,i,s){if(i<=0)return;let l=(e+t)/2,c=o(l),d=wr(c,n,r),u=Tr(n,c,r);d<=a&&u<=mr||(me(e,n,l,c,o,a,i-1,s),s.push(c),me(l,c,t,r,o,a,i-1,s))}function Rr(e){let n=e.getBoundingBox(),t=n.min,r=n.max;re(n);let o=Math.hypot(r[0]-t[0],r[1]-t[1],r[2]-t[2]);return Math.max(o*ur,1e-6)}function Tr(e,n,t){let r=n.clone().sub(e),o=t.clone().sub(n),a=r.length(),i=o.length();if(a===0||i===0)return 0;let s=Math.max(-1,Math.min(1,r.dot(o)/(a*i)));return Math.acos(s)}function wr(e,n,t){let r=t.clone().sub(n),o=r.lengthSq();if(o===0)return e.distanceTo(n);let a=Math.max(0,Math.min(1,e.clone().sub(n).dot(r)/o)),i=n.clone().addScaledVector(r,a);return e.distanceTo(i)}function Be(e,n){let t=n??1;return{color:new W.Color(e??cr),transparent:t<1,opacity:t}}import{inflateSync as Hr}from"fflate";var Fe=1096174675,vr=1515605075,Ue=3,ze=1,fe=1,Mr=2,xr=4,Cr=8,Ar=16;var Sr=1,_e=12,ke=56;function Ee(e){let n=Pr(Or(e)),t=new DataView(n.buffer,n.byteOffset,n.byteLength);if(n.byteLength<_e)throw G("Blob too small to contain SLVA header.",{expectedBytes:_e,availableBytes:n.byteLength});let r=0,o=t.getUint32(r,!0);if(r+=4,o!==Fe)throw G(`Invalid SLVA magic: 0x${o.toString(16)}`,{expectedMagic:`0x${Fe.toString(16)}`,actualMagic:`0x${o.toString(16)}`});let a=t.getUint32(r,!0);if(r+=4,a<ze||a>Ue)throw G(`Unsupported SLVA version: ${a}`,{minSupportedVersion:ze,maxSupportedVersion:Ue,actualVersion:a});let i=t.getUint32(r,!0);if(r+=4,r+i>n.byteLength)throw G("Insufficient data to read metadata JSON.",{expectedBytes:i,availableBytes:n.byteLength-r,offset:r});let s=n.subarray(r,r+i);r+=i;let l;try{l=JSON.parse(Ir(s))}catch(U){throw G(`Failed to parse metadata JSON: ${U instanceof Error?U.message:String(U)}`,{metadataLen:i})}if(r+ke>n.byteLength)throw G("Insufficient data to read geometry header.",{expectedBytes:ke,availableBytes:n.byteLength-r,offset:r});let c=t.getUint32(r,!0);r+=4;let d=t.getFloat64(r,!0);r+=8;let u=t.getFloat64(r,!0);r+=8;let m=t.getFloat64(r,!0);r+=8;let f=t.getFloat64(r,!0);r+=8;let y=t.getFloat64(r,!0);r+=8;let v=t.getFloat64(r,!0);r+=8;let g=t.getUint32(r,!0);r+=4;let h=(c&fe)!==0,p=(c&xr)!==0,M=g*3,L=M*(h?4:2);if(r+L>n.byteLength)throw G("Insufficient data to read vertices.",{expectedBytes:L,availableBytes:n.byteLength-r,offset:r,useFloat32:h,vertexCount:g});let b=n.byteOffset+r,T;if(h?T=Ge(n.buffer,b,M):p?T=Fr(pe(n.buffer,b,M)):T=Vr(n.buffer,b,M),r+=L,r+4>n.byteLength)throw G("Insufficient data to read index count.",{expectedBytes:4,availableBytes:n.byteLength-r,offset:r});let C=t.getUint32(r,!0);r+=4;let I=(c&Mr)!==0,V=C*(I?2:4);if(r+V>n.byteLength)throw G("Insufficient data to read indices.",{expectedBytes:V,availableBytes:n.byteLength-r,offset:r,indexCount:C,useUint16Indices:I});let R=I?pe(n.buffer,n.byteOffset+r,C):Br(n.buffer,n.byteOffset+r,C);p&&(R=R instanceof Uint16Array?Ur(R):zr(R)),r+=V;let H=null;if((c&Cr)!==0){let U=Dr(n,t,r,g,p);H=U.uvs,r=U.offset}let F=null;return(c&Ar)!==0&&(F=Lr(n,r,g,p)),{metadata:l,flags:c,vertices:T,indices:R,origin:[d,u,m],scale:[f,y,v],uvs:H,colors:F}}var je=36;function Dr(e,n,t,r,o){if(t+je>e.byteLength)throw G("Insufficient data to read UV chunk header.",{expectedBytes:je,availableBytes:e.byteLength-t,offset:t});let a=n.getUint32(t,!0);t+=4;let i=n.getFloat64(t,!0);t+=8;let s=n.getFloat64(t,!0);t+=8;let l=n.getFloat64(t,!0);t+=8;let c=n.getFloat64(t,!0);t+=8;let d=r*2,u=a===Sr,m=d*(u?4:2);if(t+m>e.byteLength)throw G("Insufficient data to read UV chunk.",{expectedBytes:m,availableBytes:e.byteLength-t,offset:t,uvFormat:a,vertexCount:r});let f=e.byteOffset+t,y;if(u)y=Ge(e.buffer,f,d).slice();else{let v=pe(e.buffer,f,d);y=new Float32Array(d);let g=0,h=0;for(let p=0;p<d;p+=2)o?(g=g+X(v[p])&65535,h=h+X(v[p+1])&65535):(g=v[p],h=v[p+1]),y[p]=i+g*l,y[p+1]=s+h*c}return{uvs:y,offset:t+m}}function Lr(e,n,t,r){let o=t*3;if(n+o>e.byteLength)throw G("Insufficient data to read vertex-color chunk.",{expectedBytes:o,availableBytes:e.byteLength-n,offset:n,vertexCount:t});let a=e.subarray(n,n+o);if(!r)return a.slice();let i=new Uint8Array(o),s=0,l=0,c=0;for(let d=0;d<o;d+=3)s=s+X(a[d])&255,l=l+X(a[d+1])&255,c=c+X(a[d+2])&255,i[d]=s,i[d+1]=l,i[d+2]=c;return i}function Or(e){return typeof e=="string"?be(e):e instanceof Uint8Array?e:new Uint8Array(e)}function Pr(e){if(e.byteLength<8)return e;let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(n.getUint32(0,!0)!==vr)return e;let t=n.getUint32(4,!0),r=e.subarray(8),o=Math.max(r.byteLength*1032+1024,1<<20);if(t>o)throw G("SLVZ header declares an implausible uncompressed length",{uncompressedLen:t,deflatedBytes:r.byteLength,maxPlausibleLen:o});try{return Hr(r,{out:new Uint8Array(t)})}catch(a){throw G(`Failed to inflate SLVZ blob: ${a instanceof Error?a.message:String(a)}`,{uncompressedLen:t,deflatedBytes:r.byteLength})}}function Ir(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 ce("No UTF-8 decoder available in this environment.",le.INVALID_STATE)}function Vr(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 Ge(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 pe(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 Br(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 X(e){return e>>>1^-(e&1)}function Fr(e){let n=new Int16Array(e.length),t=0,r=0,o=0;for(let a=0;a<e.length;a+=3)t=t+X(e[a])<<16>>16,r=r+X(e[a+1])<<16>>16,o=o+X(e[a+2])<<16>>16,n[a]=t,n[a+1]=r,n[a+2]=o;return n}function Ur(e){let n=new Uint16Array(e.length),t=0;for(let r=0;r<e.length;r++)t=t+X(e[r])&65535,n[r]=t;return n}function zr(e){let n=new Uint32Array(e.length),t=0;for(let r=0;r<e.length;r++)t=t+X(e[r])>>>0,n[r]=t;return n}function G(e,n){return new ce(e,le.VALIDATION_ERROR,{context:n})}import*as B from"three";async function lo(e,n){let{debug:t=!1}=n??{},r=t?performance.now():0;try{let o=performance.now(),a=JSON.parse(e),i=performance.now()-o;return await he(a,n,{parseTime:i,perfStart:r})}catch(o){return A().error("Error parsing mesh batch:",o),[]}}async function he(e,n,t){let{mergeByMaterial:r=!0,applyTransforms:o=!0,debug:a=!1,material:i}=n??{},{parseTime:s=0,perfStart:l=a?performance.now():0}=t??{};try{let c=performance.now(),d=Ee(e.compressedData),u=performance.now()-c,m=a?$r(e.compressedData):0;return Ne(d,{mergeByMaterial:r,applyTransforms:o,debug:a,material:i,parseTime:s,decodeTime:u,perfStart:l,blobBytes:m,fallback:{materials:e.materials,groups:e.groups,sourceComponentId:e.sourceComponentId}})}catch(c){return A().error("Error parsing mesh batch object:",c),[]}}async function co(e,n){let{mergeByMaterial:t=!0,applyTransforms:r=!0,debug:o=!1,material:a}=n??{},i=o?performance.now():0;try{let s=performance.now(),l=Ee(e),c=performance.now()-s,d=e.byteLength;return Ne(l,{mergeByMaterial:t,applyTransforms:r,debug:o,material:a,parseTime:0,decodeTime:c,perfStart:i,blobBytes:d})}catch(s){return A().error("Error parsing mesh batch blob:",s),[]}}function Ne(e,n){let{mergeByMaterial:t,applyTransforms:r,debug:o,material:a,parseTime:i,decodeTime:s,perfStart:l,blobBytes:c,fallback:d}=n,u=e.metadata.materials??d?.materials??[],m=e.metadata.groups??d?.groups??[],f=d?.sourceComponentId??e.metadata.sourceComponentId,y=(e.flags&fe)!==0,v=y?kr(e.vertices,r):_r(e.vertices,e.origin,e.scale,r);if(o){let w=e.vertices.byteLength+e.indices.byteLength;A().debug("Mesh Batch Stats:"),A().debug(` Materials: ${u.length} | Groups: ${m.length}`),A().debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),A().debug(` Format: ${y?"float32":"int16 quantized"}`),A().debug(` Blob: ${(c/1024/1024).toFixed(2)} MB | Geometry on wire: ${(w/1024/1024).toFixed(2)} MB`)}let g=performance.now(),h=u.map(w=>jr(w,{vertexColors:e.colors!=null,appearance:a})),p=[];for(let w of m)if(t&&w.meshes.length>1){let L=Nr(w,v,e.indices,h,e.uvs,e.colors);L.userData.sourceComponentId=f??null,p.push(L)}else{let L=Wr(w,v,e.indices,h,e.uvs,e.colors);for(let b of L)b.userData.sourceComponentId=f??null;p.push(...L)}let M=performance.now()-g;if(o){let w=performance.now()-l;A().debug("Performance:"),i>0&&A().debug(` Parse JSON: ${i.toFixed(2)}ms`),A().debug(` Decode binary: ${s.toFixed(2)}ms`),A().debug(` Create Meshes: ${M.toFixed(2)}ms`),A().debug(` Total: ${w.toFixed(2)}ms`)}return Promise.resolve(p)}function _r(e,n,t,r){let o=new Float32Array(e.length),a=n[0],i=n[1],s=n[2],l=t[0],c=t[1],d=t[2];for(let u=0;u<e.length;u+=3)o[u]=a+(e[u]+32767)*l,o[u+1]=i+(e[u+1]+32767)*c,o[u+2]=s+(e[u+2]+32767)*d;return o}function kr(e,n){return e}function jr(e,n){let t=Re(e.color),r=n?.vertexColors??!1,o=n?.appearance,a=new B.MeshPhysicalMaterial({color:t,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,vertexColors:r,side:o?.cullBackfaces?B.FrontSide:B.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0});return o?.envMapIntensity!=null&&(a.envMapIntensity=o.envMapIntensity),r&&Gr(a),e.map&&Pe(a,e.map),a}function Gr(e){e.onBeforeCompile=n=>{n.vertexShader=n.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 Nr(e,n,t,r,o=null,a=null){let i=0,s=0;for(let p of e.meshes)i+=p.vertexCount,s+=p.indexCount;let l=new Float32Array(i*3),c=new Uint32Array(s),d=o?new Float32Array(i*2):null,u=a?new Uint8Array(i*3):null,m=0,f=0;for(let p of e.meshes){let M=p.vertexStart*3,w=p.vertexCount*3;if(l.set(n.subarray(M,M+w),m*3),d&&o){let T=p.vertexStart*2;d.set(o.subarray(T,T+p.vertexCount*2),m*2)}u&&a&&u.set(a.subarray(M,M+w),m*3);let L=t.subarray(p.indexStart,p.indexStart+p.indexCount),b=m-p.vertexStart;if(b===0)c.set(L,f);else for(let T=0;T<L.length;T++)c[f+T]=L[T]+b;m+=p.vertexCount,f+=p.indexCount}let y=new B.BufferGeometry;y.setAttribute("position",new B.BufferAttribute(l,3)),y.setIndex(new B.BufferAttribute(c,1)),d&&y.setAttribute("uv",new B.BufferAttribute(d,2)),u&&y.setAttribute("color",new B.BufferAttribute(u,3,!0)),y.computeVertexNormals();let v=new B.Mesh(y,r[e.materialId]),g=e.meshes[0],h=e.meshes.map(p=>p.name).filter(p=>p&&p.length>0);return v.name=h.length>0?h[0]:`merged_material_${e.materialId}`,v.castShadow=!0,v.receiveShadow=!0,v.userData={source:"compute",name:v.name,layer:g?.layer??"",originalIndex:g?.originalIndex??0,metadata:g?.metadata??{},mergedFrom:e.meshes.slice(1).map(p=>({name:p.name,layer:p.layer,originalIndex:p.originalIndex}))},v}function Wr(e,n,t,r,o=null,a=null){let i=[];for(let s of e.meshes){let l=s.vertexStart*3,c=s.vertexCount*3,d=n.slice(l,l+c),u=t.subarray(s.indexStart,s.indexStart+s.indexCount),m=new Uint32Array(u.length),f=s.vertexStart;for(let g=0;g<u.length;g++)m[g]=u[g]-f;let y=new B.BufferGeometry;if(y.setAttribute("position",new B.BufferAttribute(d,3)),y.setIndex(new B.BufferAttribute(m,1)),o){let g=s.vertexStart*2,h=o.slice(g,g+s.vertexCount*2);y.setAttribute("uv",new B.BufferAttribute(h,2))}if(a){let g=a.slice(l,l+c);y.setAttribute("color",new B.BufferAttribute(g,3,!0))}y.computeVertexNormals();let v=new B.Mesh(y,r[e.materialId]);v.name=s.name,v.userData={source:"compute",name:s.name,layer:s.layer??"",originalIndex:s.originalIndex,metadata:s.metadata??{}},v.castShadow=!0,v.receiveShadow=!0,i.push(v)}return i}function $r(e){return Math.floor(e.length*3/4)}var Yr={Millimeters:1/1e3,Centimeters:1/100,Meters:1,Inches:1/39.37,Feet:1/3.28084},Xr="Display";async function ho(e,n){let t=performance.now(),r=[],{allowScaling:o=!0,allowAutoPosition:a=!0,rhino:i,debug:s=!1,parsing:l={}}=n??{};try{let c=o?qr(e.modelunits):1;return await Zr(e,r,c,l,i,s),a&&en(r),r}catch(c){throw tn(c,r),c}finally{s&&nn(t)}}function qr(e){return Yr[e]??1}async function Zr(e,n,t,r,o,a){for(let i of e.values){let s=i.InnerTree;for(let l in s){let c=s[l];c&&await Jr(c,n,t,r,o,a)}}}async function Jr(e,n,t,r,o,a){for(let i of e){if(!i.type.includes(Xr))continue;let s={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...r},l=Kr(i.data);if(!l){A().error("Error parsing display batch envelope: invalid JSON");continue}let c=await he(l,s),d=Ve(l.items,{rhino:o,applyTransforms:s.applyTransforms}),u=[...c,...d];if(t!==1)for(let m of u)m.scale.set(t,t,t);n.push(...u),a&&A().debug(`Extracted ${c.length} meshes and ${d.length} items from batch`)}}function Kr(e){return typeof e=="string"?Qr(e):e}function Qr(e){try{return JSON.parse(e)}catch{return}}function en(e){if(e.length===0)return;let n=Q(e);Te(e,n.min.z,"z")}function tn(e,n){A().error("An unexpected error occurred:",e),rn(n)}function rn(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 nn(e){let n=performance.now()-e;A().info("Time to process meshes:",`${n.toFixed(2)}ms`)}export{sn as a,Re as b,Te as c,Q as d,we as e,He as f,ve as g,ne as h,xe as i,ht as j,yn as k,Ce as l,Se as m,Ot as n,Le as o,Oe as p,On as q,Bt as r,Wn as s,ar as t,Ve as u,Fe as v,Ue as w,fe as x,xr as y,Cr as z,Ar as A,Ee as B,lo as C,he as D,co as E,Yr as F,ho as G};
62
+ //# sourceMappingURL=chunk-6V6SUB4V.js.map