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