@selvajs/compute 3.1.0-beta.12 → 3.1.0-beta.14

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