@selvajs/compute 3.1.0-beta.5 → 3.1.0-beta.7

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