@selvajs/compute 3.0.0 → 3.0.1-beta.0
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.
- package/dist/chunk-AUAMZCIL.cjs +2 -0
- package/dist/chunk-AUAMZCIL.cjs.map +1 -0
- package/dist/chunk-FMMK2QTR.js +4 -0
- package/dist/chunk-FMMK2QTR.js.map +1 -0
- package/dist/chunk-G3SQHFDY.js +55 -0
- package/dist/{chunk-V5KVO4JJ.js.map → chunk-G3SQHFDY.js.map} +1 -1
- package/dist/chunk-G5XWFITM.js +2 -0
- package/dist/chunk-G5XWFITM.js.map +1 -0
- package/dist/chunk-LBRCTJ7W.cjs +4 -0
- package/dist/chunk-LBRCTJ7W.cjs.map +1 -0
- package/dist/chunk-MBCMFI2R.cjs +55 -0
- package/dist/{chunk-KS4A7AEU.cjs.map → chunk-MBCMFI2R.cjs.map} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +10 -1
- package/dist/core.d.ts +10 -1
- package/dist/core.js +1 -1
- package/dist/grasshopper.cjs +1 -1
- package/dist/grasshopper.d.cts +2 -2
- package/dist/grasshopper.d.ts +2 -2
- package/dist/grasshopper.js +1 -1
- package/dist/{handle-files-Bu2qmaPj.d.ts → handle-files-9pkEgDIp.d.cts} +2 -2
- package/dist/{handle-files-Bu2qmaPj.d.cts → handle-files-9pkEgDIp.d.ts} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/visualization-LTWBUHLN.cjs +2 -0
- package/dist/visualization-LTWBUHLN.cjs.map +1 -0
- package/dist/visualization-SU3XQ35P.js +2 -0
- package/dist/visualization.cjs +1 -1
- package/dist/visualization.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-6LCAIDQV.cjs +0 -4
- package/dist/chunk-6LCAIDQV.cjs.map +0 -1
- package/dist/chunk-FHX52FTY.cjs +0 -2
- package/dist/chunk-FHX52FTY.cjs.map +0 -1
- package/dist/chunk-KS4A7AEU.cjs +0 -55
- package/dist/chunk-O55PTKMV.js +0 -4
- package/dist/chunk-O55PTKMV.js.map +0 -1
- package/dist/chunk-V5KVO4JJ.js +0 -55
- package/dist/chunk-X7RGK5IZ.js +0 -2
- package/dist/chunk-X7RGK5IZ.js.map +0 -1
- package/dist/visualization-3VKXKTBW.js +0 -2
- package/dist/visualization-H4P23BWC.cjs +0 -2
- package/dist/visualization-H4P23BWC.cjs.map +0 -1
- /package/dist/{visualization-3VKXKTBW.js.map → visualization-SU3XQ35P.js.map} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import{a as Ve,c as re,d as oe,e as C,j as ce}from"./chunk-FMMK2QTR.js";import*as z from"three";var W={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 zn(e,r,t,n,a){if(Fe(e),r.length===0)return;r.forEach(d=>{e.add(d)});let o=J(r),i=o.getCenter(new z.Vector3),l=o.getSize(new z.Vector3),s=Math.max(l.x,l.y,l.z);if(s/Math.min(l.x||1,l.y||1,l.z||1)>W.SCALE_RATIO_THRESHOLD||s>W.HUGE_THRESHOLD?(t.near=s*W.NEAR_PLANE_FACTOR.TINY,t.far=s*W.FAR_PLANE_FACTOR.HUGE):s>W.LARGE_THRESHOLD?(t.near=s*W.NEAR_PLANE_FACTOR.SMALL,t.far=s*W.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,s*W.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,s*W.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),a)n.minDistance=t.near*2,n.maxDistance=t.far*.9;else{let d=s*W.INITIAL_DISTANCE_MULTIPLIER;t.position.set(i.x+d*.8,i.y+d,i.z+d*1.2),n.target.copy(i),n.minDistance=t.near*2,n.maxDistance=t.far*.9,n.update()}}function ue(e){if(!e||typeof e!="string")return C().warn(`Invalid color input: ${e}, using white`),new z.Color(16777215);let r=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(r))try{let t=r.startsWith("#")?r:`#${r}`;return new z.Color(t)}catch{return C().warn(`Invalid hex color: ${e}, using white`),new z.Color(16777215)}if(r.includes(",")){let t=r.split(",").map(n=>parseInt(n.trim(),10));if(t.length===3&&t.every(n=>!isNaN(n)&&n>=0&&n<=255))return new z.Color(t[0]/255,t[1]/255,t[2]/255)}try{return new z.Color(r.toLowerCase())}catch{return C().warn(`Invalid color string: ${e}, using white`),new z.Color(16777215)}}function de(e,r,t="z"){e.forEach(n=>{n.position[t]-=r})}function J(e){let r=new z.Box3;return e.length===0||e.forEach(t=>{t.updateMatrixWorld(!0);let n=new z.Box3().setFromObject(t);r.union(n)}),r}var Be=new Set(["floor","grid","label-layer"]);function Fe(e){[...e.children].forEach(t=>{Be.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(l=>{for(let s of Object.values(l))s instanceof z.Texture&&s.dispose();l.dispose()})}),t.removeFromParent())})}import*as j from"three";function ze(e){let r=e.clone().normalize(),t=new j.Vector3(0,0,1),n=new j.Vector3(0,1,0),a=Math.abs(r.dot(t))>.9?n:t,o=new j.Vector3().crossVectors(r,a).normalize(),i=new j.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 me(e){let{scene:r,perspective:t,controls:n,onActiveCameraChange:a}=e,o=(e.up??t.up).clone().normalize(),i=ze(o),l=new j.OrthographicCamera(-1,1,1,-1,t.near,t.far);l.up.copy(o);let s="perspective",c=t.aspect,d=()=>s==="perspective"?t:l,u=()=>{let R=t.position.distanceTo(n.target)*Math.tan(t.fov*Math.PI/360),y=R*c;l.left=-y,l.right=y,l.top=R,l.bottom=-R,l.near=t.near,l.far=t.far,l.updateProjectionMatrix()},m=g=>{g!==s&&(g==="orthographic"?(l.position.copy(t.position),l.up.copy(t.up),l.lookAt(n.target),u()):t.position.copy(l.position),s=g,n.object=d(),n.update(),a(d()))},p=(g,R=!0)=>{let y=ke(r),H=y.isEmpty()?n.target.clone():y.getCenter(new j.Vector3),O=y.isEmpty()?new j.Vector3(1,1,1):y.getSize(new j.Vector3),b=Math.max(O.x,O.y,O.z)||1,T=t.fov*(Math.PI/180),x=b/(2*Math.tan(T/2))*1.5,P=_e(g,o),D=H.clone().add(P.clone().multiplyScalar(x)),F=d();R?Ne(F,n,D,H,()=>{s==="orthographic"&&u()}):(F.position.copy(D),n.target.copy(H),s==="orthographic"&&u(),n.update())};return{getActiveCamera:d,getProjection:()=>s,setProjection:m,toggleProjection:()=>(m(s==="perspective"?"orthographic":"perspective"),s),setView:(g,R=!0)=>{p(i[g],R)},setViewDirection:p,setRotateEnabled:g=>{n.enableRotate=g},isRotateEnabled:()=>n.enableRotate,updateAspect:(g,R)=>{c=R===0?c:g/R,s==="orthographic"&&u()}}}var Ue=new Set(["grid","floor","label-layer","measure"]);function je(e){let r=e;for(;r;){if(typeof r.userData.id=="string"&&Ue.has(r.userData.id))return!0;r=r.parent}return!1}function ke(e){let r=[];return e.traverse(t=>{let n=t;t.visible&&!je(t)&&n.geometry&&r.push(t)}),J(r)}function _e(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 j.Vector3(0,0,1)))>.9?new j.Vector3(0,1,0):new j.Vector3(0,0,1),o=new j.Vector3().crossVectors(t,a).normalize(),i=.5*Math.PI/180;return n.multiplyScalar(Math.cos(i)).add(o.multiplyScalar(Math.sin(i))).normalize()}var Ge=e=>1-Math.pow(1-e,3);function Ne(e,r,t,n,a,o=250){let i=e.position.clone(),l=r.target.clone(),s=performance.now(),c=()=>{let d=Ge(Math.min((performance.now()-s)/o,1));e.position.lerpVectors(i,t,d),r.target.lerpVectors(l,n,d),a(),r.update(),d<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}import*as I from"three";var We=`
|
|
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
|
+
`,$e=`
|
|
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 pe(e={}){let{cellSize:r=1,majorEvery:t=10,cellColor:n=8947848,majorColor:a=4473924,fadeDistance:o=100,plane:i="y"}=e,l=i==="y"?new I.Vector2(0,2):i==="z"?new I.Vector2(0,1):new I.Vector2(1,2),s=o*2.5,c=new I.PlaneGeometry(s,s);i==="y"?c.rotateX(-Math.PI/2):i==="x"&&c.rotateY(Math.PI/2);let d=new I.ShaderMaterial({vertexShader:We,fragmentShader:$e,transparent:!0,depthWrite:!1,side:I.DoubleSide,uniforms:{uAxes:{value:l},uCell:{value:r},uMajor:{value:t},uCellColor:{value:new I.Color(n)},uMajorColor:{value:new I.Color(a)},uCenter:{value:new I.Vector3},uFade:{value:o}}}),u=new I.Mesh(c,d);u.name="grid",u.userData.id="grid",u.renderOrder=-1;let m=new I.Vector3;return{object:u,update:p=>{i==="y"?(u.position.set(p.x,0,p.z),m.set(p.x,0,p.z)):i==="z"?(u.position.set(p.x,p.y,0),m.set(p.x,p.y,0)):(u.position.set(0,p.y,p.z),m.set(0,p.y,p.z)),d.uniforms.uCenter.value.copy(m)},setVisible:p=>{u.visible=p},dispose:()=>{c.dispose(),d.dispose()}}}import*as k from"three";import{ViewHelper as Ye}from"three/addons/helpers/ViewHelper.js";function fe(e){let{camera:r,domElement:t,controller:n}=e,a=new Ye(r,t);a.setLabels("X","Y","Z");let o=!0,i=128,l=new k.Raycaster,s=new k.OrthographicCamera(-2,2,2,-2,0,4);s.position.set(0,0,2);let c={posX:new k.Vector3(1,0,0),negX:new k.Vector3(-1,0,0),posY:new k.Vector3(0,1,0),negY:new k.Vector3(0,-1,0),posZ:new k.Vector3(0,0,1),negZ:new k.Vector3(0,0,-1)},d=m=>{let p=t.getBoundingClientRect(),E=p.left+t.offsetWidth-i-a.location.right,A=p.top+t.offsetHeight-i-a.location.bottom,v=new k.Vector2((m.clientX-E)/i*2-1,-((m.clientY-A)/i)*2+1);if(Math.abs(v.x)>1||Math.abs(v.y)>1)return null;a.quaternion.copy(r.quaternion).invert(),a.updateMatrixWorld(),l.setFromCamera(v,s);let g=l.intersectObjects(a.children,!1);for(let R of g){let y=R.object.userData?.type;if(typeof y=="string"&&y in c)return y}return null};return{render:m=>{if(!o)return;let p=m.autoClear;m.autoClear=!1,a.render(m),m.autoClear=p},update:m=>{a.animating&&a.update(m)},handleClick:m=>{if(!o)return!1;let p=d(m);return p?(n.getProjection()==="orthographic"&&n.setProjection("perspective"),n.setViewDirection(c[p],!1),!0):!1},get isAnimating(){return a.animating},setVisible:m=>{o=m},isVisible:()=>o,dispose:()=>a.dispose()}}import*as Z from"three";import{LineSegmentsGeometry as Xe}from"three/addons/lines/LineSegmentsGeometry.js";import{LineSegments2 as Ee}from"three/addons/lines/LineSegments2.js";import{LineMaterial as qe}from"three/addons/lines/LineMaterial.js";var ee="edge-overlay",Ze=2236962,Je=1.5,Ke=30;function he(e,r={}){let t=new Z.Color(r.color??Ze),n=r.width??Je,a=r.thresholdAngle??Ke,o=[];return e.traverse(i=>{if(!(i instanceof Z.Mesh)||i.userData.id==="floor"||i.userData.id==="grid"||i.userData.kind===ee||i.children.some(s=>s.userData?.kind===ee)||!i.geometry)return;let l=Qe(i.geometry,t,n,a);i.add(l),o.push(l)}),o}function Qe(e,r,t,n){let a=new Z.EdgesGeometry(e,n),o=new Xe;o.setPositions(Array.from(a.attributes.position.array)),a.dispose();let i=new qe({color:r});i.linewidth=t,i.polygonOffset=!0,i.polygonOffsetFactor=-1,i.polygonOffsetUnits=-1;let l=new Ee(o,i);return l.userData.kind=ee,l.raycast=()=>{},l}function et(e){return e.userData?.kind===ee}function Xn(e){let r=[];e.traverse(t=>{t instanceof Ee&&et(t)&&r.push(t)});for(let t of r)t.geometry.dispose(),t.material.dispose(),t.removeFromParent();return r.length}import{EffectComposer as tt}from"three/addons/postprocessing/EffectComposer.js";import{RenderPass as nt}from"three/addons/postprocessing/RenderPass.js";import{GTAOPass as rt}from"three/addons/postprocessing/GTAOPass.js";import{OutputPass as ot}from"three/addons/postprocessing/OutputPass.js";function ge(e,r,t,n,a,o){let i=new tt(e),l=new nt(r,t);i.addPass(l);let s=new rt(r,t,n,a);s.blendIntensity=o.aoIntensity??1,s.updateGtaoMaterial({screenSpaceRadius:!0}),i.addPass(s);let c=new ot;return i.addPass(c),e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure,i.setSize(n,a),{render:d=>i.render(d),setSize:(d,u,m)=>{i.setPixelRatio(m),i.setSize(d,u),s.setSize(d,u)},setCamera:d=>{l.camera=d,s.camera=d},dispose:()=>{i.dispose(),s.dispose(),c.dispose()}}}import*as ye from"three";import{CSS2DRenderer as at,CSS2DObject as it}from"three/addons/renderers/CSS2DRenderer.js";function be(e,r){let t=new at,n=t.domElement;n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%",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 ye.Group;o.name="label-layer",o.userData.id="label-layer",r.add(o);let i=new Set;return{addLabel:(s,c,d)=>{let u=document.createElement("div");u.textContent=s,d?u.className=d:Object.assign(u.style,{padding:"2px 6px",borderRadius:"4px",background:"rgba(20, 20, 20, 0.78)",color:"#fff",font:"12px/1.3 system-ui, sans-serif",whiteSpace:"pre",textAlign:"center",userSelect:"none"}),u.style.pointerEvents="none";let m=new it(u);return m.position.copy(c),o.add(m),i.add(m),{object:m,setPosition:p=>m.position.copy(p),setText:p=>{u.textContent=p},remove:()=>{m.removeFromParent(),u.remove(),i.delete(m)}}},render:(s,c)=>t.render(s,c),setSize:(s,c)=>t.setSize(s,c),dispose:()=>{i.forEach(s=>{s.removeFromParent(),s.element.remove()}),i.clear(),o.removeFromParent(),n.remove()}}}import*as S from"three";import{Line2 as st}from"three/addons/lines/Line2.js";import{LineGeometry as lt}from"three/addons/lines/LineGeometry.js";import{LineMaterial as ct}from"three/addons/lines/LineMaterial.js";var ut=12,dt=16763904,mt=.015,Re={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 pt(e){let r=e&&Re[e]||Re.Meters;return t=>`${(t/r.metersPerUnit).toPrecision(3)} ${r.suffix}`}function ft(e){let r=e.object;return r instanceof S.Mesh?e.face?[e.face.a,e.face.b,e.face.c]:null:r instanceof S.Points?e.index!=null?[e.index]:null:r instanceof S.Line&&e.index!=null?[e.index,e.index+1]:null}function Et(e,r,t,n){let a=e.point.clone(),o=e.object,i=ft(e);if(!i||!o.geometry)return a;let l=o.geometry.attributes.position;if(!l)return a;let s=m=>{let p=m.clone().project(r);return new S.Vector2((p.x+1)/2*t.width,(1-p.y)/2*t.height)},c=s(a),d=a,u=n;for(let m of i){if(m>=l.count)continue;let E=new S.Vector3().fromBufferAttribute(l,m).applyMatrix4(o.matrixWorld),A=s(E).distanceTo(c);A<u&&(u=A,d=E)}return d}function Te(e){let{canvas:r,scene:t,getActiveCamera:n,labelLayer:a,options:o={}}=e,i=o.snapPixels??ut,l=new S.Color(o.color??dt),s=pt(o.displayUnit),c=(h,w)=>`${s(h)}
|
|
54
|
+
\u0394x ${s(w.x)} \u0394y ${s(w.y)} \u0394z ${s(w.z)}`,d=o.format??c,u=new S.Raycaster,m=new S.Vector2,p=!1,E=[],A=[],v=null,g=null,R=new S.PointsMaterial({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),y=new S.PointsMaterial({color:l,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),H=null,O=h=>{if(!h){H&&(H.visible=!1);return}if(!H){let w=new S.BufferGeometry;w.setAttribute("position",new S.Float32BufferAttribute([0,0,0],3)),H=new S.Points(w,y),H.renderOrder=1e3,H.userData.id="measure",H.raycast=()=>{},t.add(H)}H.position.copy(h),H.visible=!0},b=h=>{let w=new S.BufferGeometry;w.setAttribute("position",new S.Float32BufferAttribute([h.x,h.y,h.z],3));let V=new S.Points(w,R);return V.renderOrder=999,V.userData.id="measure",V.raycast=()=>{},t.add(V),V},T=()=>{E.length=0,A.forEach(h=>{h.geometry.dispose(),h.removeFromParent()}),A.length=0,v&&(v.geometry.dispose(),v.material.dispose(),v.removeFromParent(),v=null),g?.remove(),g=null},x=()=>{if(E.length!==2)return;let[h,w]=E,V=new lt;V.setPositions([h.x,h.y,h.z,w.x,w.y,w.z]);let Y=new ct({color:l});Y.linewidth=2,Y.depthTest=!1,v=new st(V,Y),v.renderOrder=998,v.userData.id="measure",v.raycast=()=>{},t.add(v);let X=h.clone().add(w).multiplyScalar(.5),$=new S.Vector3(Math.abs(w.x-h.x),Math.abs(w.y-h.y),Math.abs(w.z-h.z));g=a.addLabel(d(h.distanceTo(w),$),X,o.labelClassName)},P=h=>{let w=r.getBoundingClientRect();m.x=(h.clientX-w.left)/w.width*2-1,m.y=-((h.clientY-w.top)/w.height)*2+1;let V=n();u.setFromCamera(m,V);let X=V.position.length()*mt;u.params.Line.threshold=X,u.params.Points.threshold=X;let $=u.intersectObjects(t.children,!0).filter(q=>q.object.userData.id!=="measure"&&q.object.userData.id!=="grid");return $.length===0?null:Et($[0],V,{width:w.width,height:w.height},i)};return{setEnabled:h=>{p=h,h||(T(),O(null))},isEnabled:()=>p,handleClick:h=>{if(!p)return!1;E.length===2&&T();let w=P(h);return w===null||(E.push(w),A.push(b(w)),E.length===2&&x()),!0},handleMove:h=>{p&&O(P(h))},clear:T,dispose:()=>{T(),H&&(H.geometry.dispose(),H.removeFromParent(),H=null),R.dispose(),y.dispose()}}}import*as f from"three";import{OrbitControls as ht}from"three/addons/controls/OrbitControls.js";import{HDRLoader as gt}from"three/addons/loaders/HDRLoader.js";var te=new f.Vector3(0,0,1);function yt(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 gr=function(e,r){let t=bt(r||{}),n=t.environment?.sceneUp||te,a=Ht(t),o=St(t,e);o.up.copy(n);let i=Dt(e,t),l=Pt(o,e,t),s=me({scene:a,perspective:o,controls:l,onActiveCameraChange:()=>{},up:n}),c=()=>s.getActiveCamera();xt(a,t);let d=Ct(a,t),u=()=>{d&&wt(d,ae(a))};t.floor?.enabled&&At(a,t);let m=t.grid.enabled?pe({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;m&&a.add(m.object);let p=t.gizmo.enabled?fe({camera:o,domElement:e,controller:s}):null,E=e.parentElement??e,A=t.measure.enabled?be(E,a):null,v=t.measure.enabled&&A?Te({canvas:e,scene:a,getActiveCamera:c,labelLayer:A,options:{snapPixels:t.measure.snapPixels,color:t.measure.color,labelClassName:t.measure.labelClassName,displayUnit:t.measure.displayUnit,format:t.measure.format}}):null,g=t.events.enableEventHandlers!==!1?Lt(e,a,c,o,l,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},R=5,y=0,H=0,O=M=>{y=M.clientX,H=M.clientY},b=M=>Math.hypot(M.clientX-y,M.clientY-H)>R,T=M=>{if(!b(M)){if(v?.handleClick(M)){M.stopImmediatePropagation();return}p?.handleClick(M)&&M.stopImmediatePropagation()}};(p||v)&&(e.addEventListener("mousedown",O,{capture:!0}),e.addEventListener("click",T,{capture:!0}));let x=M=>v?.handleMove(M);v&&e.addEventListener("mousemove",x,{passive:!0});let P=M=>{he(M,{color:t.edges.color,width:t.edges.width,thresholdAngle:t.edges.thresholdAngle})},D=e.parentElement,F=()=>D?{width:D.clientWidth,height:D.clientHeight}:{width:window.innerWidth,height:window.innerHeight},h=null,w=()=>{let{width:M,height:B}=F(),N=Math.min(window.devicePixelRatio,2),Q=ge(i,a,c(),Math.max(1,M),Math.max(1,B),{toneMapping:t.render.toneMapping??f.NeutralToneMapping,toneMappingExposure:t.render.toneMappingExposure??1,aoIntensity:t.render.aoIntensity});return Q.setSize(Math.max(1,M),Math.max(1,B),N),Q},V=M=>{M&&!h?h=w():!M&&h&&(h.dispose(),h=null)};t.render.ambientOcclusion&&(h=w());let{animate:Y,dispose:X}=Mt(i,a,o,c,s,l,F,t.events.onFrame,m,p,()=>h,A);Y(),a.up.set(n.x,n.y,n.z),u();let $=M=>{M.traverse(B=>{let N=B;!N.geometry&&!N.material||(N.geometry?.dispose(),Array.isArray(N.material)?N.material.forEach(Q=>Q.dispose()):N.material?.dispose())})},q=M=>{M.userData.source="user",a.add(M)},Oe=M=>{M.removeFromParent(),$(M)},Ie=()=>{a.children.filter(B=>B.userData.source==="user").forEach(B=>{B.removeFromParent(),$(B)})};return{scene:a,camera:o,controls:l,renderer:i,cameraController:s,grid:m,gizmo:p,measureTool:v,applyEdges:P,setAmbientOcclusion:V,updateShadowBounds:u,dispose:()=>{X(),g.dispose(),(p||v)&&(e.removeEventListener("mousedown",O,{capture:!0}),e.removeEventListener("click",T,{capture:!0})),v&&e.removeEventListener("mousemove",x),v?.dispose(),A?.dispose(),p?.dispose(),m?.dispose(),h?.dispose(),l.dispose(),i.dispose(),a.traverse(M=>{let B=M;!B.geometry&&!B.material||(B.geometry?.dispose(),Array.isArray(B.material)?B.material.forEach(N=>N.dispose()):B.material?.dispose())}),a.environment?.dispose(),a.background instanceof f.Texture&&a.background.dispose()},fitToView:g.fitToView,clearSelection:g.clearSelection,addUserGeometry:q,removeUserGeometry:Oe,clearUserGeometry:Ie}};function bt(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];return{sceneScale:r,camera:{position:e.camera?.position||new f.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 f.Vector3(0,0,0)},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??1,sunlightPosition:e.lighting?.sunlightPosition||new f.Vector3(n.lightDistance,n.lightDistance,n.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new f.Color(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??1,sunlightColor:e.lighting?.sunlightColor||16777215},environment:{hdrPath:e.environment?.hdrPath||"/baseHDR.hdr",backgroundColor:e.environment?.backgroundColor||new f.Color(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||te,showEnvironment:e.environment?.showEnvironment??!1},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||n.floorSize,color:e.floor?.color||new f.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||f.NeutralToneMapping,toneMappingExposure:e.render?.toneMappingExposure??1,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,ambientOcclusion:e.render?.ambientOcclusion??!1,aoIntensity:e.render?.aoIntensity??1},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||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??yt(e.environment?.sceneUp??te)},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}}}var Rt=new Set(["grid","floor","label-layer","measure"]);function Tt(e){let r=e;for(;r;){if(typeof r.userData.id=="string"&&Rt.has(r.userData.id))return!0;r=r.parent}return!1}function ae(e){let r=new f.Box3;return e.traverse(t=>{let n=t;t.visible&&!Tt(t)&&n.geometry&&r.expandByObject(t)}),r}function wt(e,r){if(r.isEmpty())return;let t=r.getCenter(new f.Vector3),n=r.getSize(new f.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 Ht(e){let r=new f.Scene,t=typeof e.environment.backgroundColor=="string"?new f.Color(e.environment.backgroundColor):e.environment.backgroundColor;return r.background=t||null,r}function vt(e,r,t,n,a=200){let o=e.position.clone(),i=r.target.clone(),l=performance.now(),s=d=>1-Math.pow(1-d,3),c=()=>{let d=performance.now()-l,u=s(Math.min(d/a,1));e.position.lerpVectors(o,t,u),r.target.lerpVectors(i,n,u),r.update(),u<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}function Mt(e,r,t,n,a,o,i,l,s,c,d,u){let m=null,p=performance.now(),E=()=>{let{width:g,height:R}=i();if(g===0||R===0)return;let y=Math.min(window.devicePixelRatio,2),H=Math.round(g*y),O=Math.round(R*y);(e.domElement.width!==H||e.domElement.height!==O)&&(e.setPixelRatio(y),e.setSize(g,R,!1),t.aspect=g/R,t.updateProjectionMatrix(),a.updateAspect(g,R),d?.()?.setSize(g,R,y),u?.setSize(g,R))},A=function(){m=requestAnimationFrame(A);let g=performance.now(),R=(g-p)/1e3;p=g,E(),(o.enableDamping||o.autoRotate)&&o.update(),s&&s.update(n().position),c&&c.update(R),l?.(R);let y=n(),H=d?.();H?(H.setCamera(y),H.render(R)):e.render(r,y),u&&u.render(r,y),c&&c.render(e)};return{animate:A,dispose:()=>{m!==null&&(cancelAnimationFrame(m),m=null)}}}function xt(e,r){r.environment.enableEnvironmentLighting?new gt().load(r.environment.hdrPath||"/baseHDR.hdr",function(t){if(!t?.image){C().warn("HDR loaded without image data; skipping environment map."),r.events.onReady?.();return}t.mapping=f.EquirectangularReflectionMapping,e.environment=t,r.environment.showEnvironment&&(e.background=t),r.events.onReady?.()},void 0,function(t){C().warn("HDR texture could not be loaded, falling back to basic lighting:",t),r.events.onReady?.()}):r.events.onReady?.()}function Ct(e,r){let t=new f.AmbientLight(r.lighting.ambientLightColor,r.lighting.ambientLightIntensity);if(e.add(t),!r.lighting.enableSunlight)return null;let n=new f.DirectionalLight(r.lighting.sunlightColor??16777215,r.lighting.sunlightIntensity),a=r.lighting.sunlightPosition;return a&&n.position.set(a.x,a.y,a.z),r.render.enableShadows?(n.castShadow=!0,n.shadow.mapSize.width=r.render.shadowMapSize||2048,n.shadow.mapSize.height=r.render.shadowMapSize||2048,n.shadow.bias=-1e-4,n.shadow.normalBias=.02,n.shadow.radius=4,e.add(n),e.add(n.target),n):(e.add(n),null)}function At(e,r){let t=r.floor.size,n=new f.PlaneGeometry(t,t),a=typeof r.floor.color=="string"?new f.Color(r.floor.color):r.floor.color,o=new f.MeshStandardMaterial({color:a,roughness:r.floor.roughness,metalness:r.floor.metalness,side:f.DoubleSide}),i=new f.Mesh(n,o);i.userData.id="floor",i.name="floor";let l=(r.environment?.sceneUp||te).clone().normalize();i.quaternion.setFromUnitVectors(new f.Vector3(0,0,1),l),i.position.set(0,0,0),r.floor.receiveShadow&&r.render.enableShadows&&(i.receiveShadow=!0),e.add(i)}function St(e,r){let t=r.parentElement,n=t?t.clientWidth:window.innerWidth,a=t?t.clientHeight:window.innerHeight,o=new f.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 Dt(e,r){let t=new f.WebGLRenderer({antialias:r.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:r.render.preserveDrawingBuffer,logarithmicDepthBuffer:!0}),n=e.parentElement,a=n?n.clientWidth:window.innerWidth,o=n?n.clientHeight:window.innerHeight;return n&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),t.setSize(a,o,!1),t.setPixelRatio(r.render.pixelRatio||Math.min(window.devicePixelRatio,2)),r.render.enableShadows&&(t.shadowMap.enabled=!0,t.shadowMap.type=f.VSMShadowMap),t.toneMapping=r.render.toneMapping,t.toneMappingExposure=r.render.toneMappingExposure??1,t.outputColorSpace=f.SRGBColorSpace,t.sortObjects=!0,t}function Lt(e,r,t,n,a,o){let i=new Set,l=new Map,s=new f.Raycaster,c=new f.Vector2,d=new f.Vector2,u=b=>{let T=b;for(;T;){if(!T.visible)return!1;T=T.parent}return!0},m=()=>{let b=ae(r);if(b.isEmpty()){C().warn("No objects to fit to view");return}let T=b.getCenter(new f.Vector3),x=b.getSize(new f.Vector3),P=Math.max(x.x,x.y,x.z),D=n.fov*(Math.PI/180),F=P/(2*Math.tan(D/2));F*=1.5;let h=n.position.clone().sub(a.target);h.lengthSq()<1e-12&&h.set(.8,1,1.2),h.normalize(),n.position.copy(T.clone().add(h.multiplyScalar(F))),a.target.copy(T),a.update()},p=typeof o.events.selectionColor=="string"?new f.Color(o.events.selectionColor):o.events.selectionColor instanceof f.Color?o.events.selectionColor:new f.Color("#ff0000"),E=()=>{i.forEach(b=>{let T=b;if(l.has(b)){let x=l.get(b),P=T.material;P instanceof f.Material?P.dispose():Array.isArray(P)&&P.forEach(D=>D.dispose()),T.material=x,l.delete(b)}}),i.clear()},A=b=>{let T=b;if(!(T.material instanceof f.Material))return!1;l.set(b,T.material);let x=T.material.clone();return b instanceof f.Mesh&&"emissive"in x?x.emissive=p.clone():"color"in x&&(x.color=p.clone()),T.material=x,!0},v=()=>{let b=ae(r),T=b.isEmpty()?1:b.getSize(new f.Vector3).length();s.params.Points.threshold=T*.01},g=b=>{d.set(b.clientX,b.clientY)},R=b=>{let T=new f.Vector2(b.clientX,b.clientY);if(d.distanceTo(T)>5)return;let x=e.getBoundingClientRect();c.x=(b.clientX-x.left)/x.width*2-1,c.y=-((b.clientY-x.top)/x.height)*2+1,v(),s.setFromCamera(c,t());let P=s.intersectObjects(r.children,!0).filter(D=>u(D.object));if(P.length>0){let D=P[0].object;i.has(D)||(E(),i.add(D),A(D),o.events?.onObjectSelected?.(D),D instanceof f.Mesh&&Object.keys(D.userData).length>0&&o.events?.onMeshMetadataClicked?.(D.userData))}else E(),o.events?.onBackgroundClicked?.({x:c.x,y:c.y})},y=b=>{let T=e.getBoundingClientRect();c.x=(b.clientX-T.left)/T.width*2-1,c.y=-((b.clientY-T.top)/T.height)*2+1,v(),s.setFromCamera(c,t());let x=s.intersectObjects(r.children,!0).filter(q=>u(q.object));if(x.length===0)return;let P=x[0].object;if(o.events?.onMeshDoubleClicked?.(P),!o.events?.enableDoubleClickZoom)return;let D=new f.Box3().setFromObject(P);if(D.isEmpty())return;let F=D.getCenter(new f.Vector3),h=D.getSize(new f.Vector3),w=Math.max(h.x,h.y,h.z),V=n.fov*(Math.PI/180),Y=w/(2*Math.tan(V/2))*1.5,X=n.position.clone().sub(a.target).normalize(),$=F.clone().add(X.multiplyScalar(Y));vt(n,a,$,F)},H=b=>{if(o.events?.enableKeyboardControls)switch(b.key.toLowerCase()){case"f":b.preventDefault(),m();break;case"escape":b.preventDefault(),E();break;case" ":b.preventDefault(),m();break}};return o.events?.enableClickToFocus&&(e.addEventListener("mousedown",g),e.addEventListener("click",R),e.addEventListener("dblclick",y)),o.events?.enableKeyboardControls&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",H)),{dispose:()=>{e.removeEventListener("mousedown",g),e.removeEventListener("click",R),e.removeEventListener("dblclick",y),e.removeEventListener("keydown",H),E()},fitToView:m,clearSelection:E}}function Pt(e,r,t){let n=new ht(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 jt={};Ve(jt,{CONCRETE_MATERIAL:()=>Vt,EMISSIVE_MATERIAL:()=>Ot,GLASS_MATERIAL:()=>Ft,METAL_MATERIAL:()=>It,PLASTIC_MATERIAL:()=>Bt,RUBBER_MATERIAL:()=>zt,WOOD_MATERIAL:()=>Ut});import*as L from"three";var Ot=new L.MeshPhysicalMaterial({color:0,emissive:new L.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,side:L.FrontSide,dithering:!0}),It=new L.MeshPhysicalMaterial({color:new L.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,side:L.FrontSide,dithering:!0}),Vt=new L.MeshPhysicalMaterial({color:new L.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:.5,depthTest:!0,polygonOffset:!0,side:L.FrontSide,dithering:!0}),Bt=new L.MeshPhysicalMaterial({color:new L.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:L.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Ft=new L.MeshPhysicalMaterial({color:new L.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,opacity:.3,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:L.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),zt=new L.MeshPhysicalMaterial({color:new L.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:L.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Ut=new L.MeshPhysicalMaterial({color:new L.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:L.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});import*as _ from"three";import{Line2 as kt}from"three/addons/lines/Line2.js";import{LineGeometry as _t}from"three/addons/lines/LineGeometry.js";import{LineMaterial as Gt}from"three/addons/lines/LineMaterial.js";function ne(e,r,t,n=!0){return{x:e,y:r,z:t}}var Nt="#ffffff",we=12,Wt=4e-4,$t=12,Yt=.05;function He(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=qt(o,t,n);i&&a.push(i);break}case"point":{a.push(Zt(o,n));break}default:{let i=o;C().warn(`Skipping unknown display item kind: ${String(i.kind)}`);break}}return a}var Xt=2;function qt(e,r,t){if(!r)return C().warn("No rhino3dm instance provided; skipping curve display item."),null;let n=Jt(e.json,r);if(!n)return null;let a=Kt(n,t);if(a.length<2)return null;let o=[];for(let u of a)o.push(u.x,u.y,u.z);let i=new _t;i.setPositions(o);let l=ve(e.color,e.opacity),s=new Gt({color:l.color}),c=s;c.linewidth=e.width??Xt,c.transparent=l.transparent,c.opacity=l.opacity;let d=new kt(i,s);return d.computeLineDistances(),d.name=e.name,d.userData={source:"compute",id:e.id,layer:e.layer,kind:"curve",metadata:e.metadata},d}function Zt(e,r){let{x:t,y:n,z:a}=ne(e.position.X,e.position.Y,e.position.Z,r),o=new _.BufferGeometry;o.setAttribute("position",new _.Float32BufferAttribute([t,n,a],3));let i=new _.PointsMaterial({...ve(e.color,e.opacity),size:6,sizeAttenuation:!1}),l=new _.Points(o,i);return l.name=e.name,l.userData={source:"compute",id:e.id,layer:e.layer,kind:"point",metadata:e.metadata},l}function Jt(e,r){try{let t=JSON.parse(e),n=r.CommonObject.decode(t);return n&&typeof n.pointAt=="function"?n:(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 Kt(e,r){let t=Qt(e,r);return t||en(e,r)}function Qt(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 null;let a=[];for(let o=0;o<n.count;o++){let i=n.get(o),{x:l,y:s,z:c}=ne(i[0],i[1],i[2],r);a.push(new _.Vector3(l,s,c))}return a}function en(e,r){let t=e.domain,n=t[0],o=t[1]-n,i=u=>{let m=e.pointAt(u),{x:p,y:E,z:A}=ne(m[0],m[1],m[2],r);return new _.Vector3(p,E,A)},l=tn(e),s=n,c=i(n),d=[c];for(let u=0;u<we;u++){let m=n+o*(u+1)/we,p=i(m);ie(s,c,m,p,i,l,$t,d),d.push(p),s=m,c=p}return d}function ie(e,r,t,n,a,o,i,l){if(i<=0)return;let s=(e+t)/2,c=a(s),d=rn(c,r,n),u=nn(r,c,n);d<=o&&u<=Yt||(ie(e,r,s,c,a,o,i-1,l),l.push(c),ie(s,c,t,n,a,o,i-1,l))}function tn(e){let r=e.getBoundingBox(),t=r.min,n=r.max,a=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]);return Math.max(a*Wt,1e-6)}function nn(e,r,t){let n=r.clone().sub(e),a=t.clone().sub(r),o=n.length(),i=a.length();if(o===0||i===0)return 0;let l=Math.max(-1,Math.min(1,n.dot(a)/(o*i)));return Math.acos(l)}function rn(e,r,t){let n=t.clone().sub(r),a=n.lengthSq();if(a===0)return e.distanceTo(r);let o=Math.max(0,Math.min(1,e.clone().sub(r).dot(n)/a)),i=r.clone().addScaledVector(n,o);return e.distanceTo(i)}function ve(e,r){let t=r??1;return{color:new _.Color(e??Nt),transparent:t<1,opacity:t}}import{inflateSync as on}from"fflate";var Me=1096174675,an=1515605075,xe=3,Ce=1,se=1,sn=2,ln=4,Ae=12,Se=56;function le(e){let r=un(cn(e)),t=new DataView(r.buffer,r.byteOffset,r.byteLength);if(r.byteLength<Ae)throw G("Blob too small to contain SLVA header.",{expectedBytes:Ae,availableBytes:r.byteLength});let n=0,a=t.getUint32(n,!0);if(n+=4,a!==Me)throw G(`Invalid SLVA magic: 0x${a.toString(16)}`,{expectedMagic:`0x${Me.toString(16)}`,actualMagic:`0x${a.toString(16)}`});let o=t.getUint32(n,!0);if(n+=4,o<Ce||o>xe)throw G(`Unsupported SLVA version: ${o}`,{minSupportedVersion:Ce,maxSupportedVersion:xe,actualVersion:o});let i=t.getUint32(n,!0);if(n+=4,n+i>r.byteLength)throw G("Insufficient data to read metadata JSON.",{expectedBytes:i,availableBytes:r.byteLength-n,offset:n});let l=r.subarray(n,n+i);n+=i;let s;try{s=JSON.parse(dn(l))}catch(w){throw G(`Failed to parse metadata JSON: ${w instanceof Error?w.message:String(w)}`,{metadataLen:i})}if(n+Se>r.byteLength)throw G("Insufficient data to read geometry header.",{expectedBytes:Se,availableBytes:r.byteLength-n,offset:n});let c=t.getUint32(n,!0);n+=4;let d=t.getFloat64(n,!0);n+=8;let u=t.getFloat64(n,!0);n+=8;let m=t.getFloat64(n,!0);n+=8;let p=t.getFloat64(n,!0);n+=8;let E=t.getFloat64(n,!0);n+=8;let A=t.getFloat64(n,!0);n+=8;let v=t.getUint32(n,!0);n+=4;let g=(c&se)!==0,R=(c&ln)!==0,y=v*3,O=y*(g?4:2);if(n+O>r.byteLength)throw G("Insufficient data to read vertices.",{expectedBytes:O,availableBytes:r.byteLength-n,offset:n,useFloat32:g,vertexCount:v});let b=r.byteOffset+n,T;if(g?T=pn(r.buffer,b,y):R?T=En(De(r.buffer,b,y)):T=mn(r.buffer,b,y),n+=O,n+4>r.byteLength)throw G("Insufficient data to read index count.",{expectedBytes:4,availableBytes:r.byteLength-n,offset:n});let x=t.getUint32(n,!0);n+=4;let P=(c&sn)!==0,F=x*(P?2:4);if(n+F>r.byteLength)throw G("Insufficient data to read indices.",{expectedBytes:F,availableBytes:r.byteLength-n,offset:n,indexCount:x,useUint16Indices:P});let h=P?De(r.buffer,r.byteOffset+n,x):fn(r.buffer,r.byteOffset+n,x);return R&&(h=h instanceof Uint16Array?hn(h):gn(h)),{metadata:s,flags:c,vertices:T,indices:h,origin:[d,u,m],scale:[p,E,A]}}function cn(e){return typeof e=="string"?ce(e):e instanceof Uint8Array?e:new Uint8Array(e)}function un(e){if(e.byteLength<8)return e;let r=new DataView(e.buffer,e.byteOffset,e.byteLength);if(r.getUint32(0,!0)!==an)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 G("SLVZ header declares an implausible uncompressed length",{uncompressedLen:t,deflatedBytes:n.byteLength,maxPlausibleLen:a});try{return on(n,{out:new Uint8Array(t)})}catch(o){throw G(`Failed to inflate SLVZ blob: ${o instanceof Error?o.message:String(o)}`,{uncompressedLen:t,deflatedBytes:n.byteLength})}}function dn(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 mn(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 pn(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 De(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 fn(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 K(e){return e>>>1^-(e&1)}function En(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 hn(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 gn(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 G(e,r){return new oe(e,re.VALIDATION_ERROR,{context:r})}import*as U from"three";async function Le(e,r){let{debug:t=!1}=r??{},n=t?performance.now():0;try{let a=performance.now(),o=JSON.parse(e),i=performance.now()-a;return await yn(o,r,{parseTime:i,perfStart:n})}catch(a){return C().error("Error parsing mesh batch:",a),[]}}async function yn(e,r,t){let{mergeByMaterial:n=!0,applyTransforms:a=!0,debug:o=!1}=r??{},{parseTime:i=0,perfStart:l=o?performance.now():0}=t??{};try{let s=performance.now(),c=le(e.compressedData),d=performance.now()-s,u=o?vn(e.compressedData):0;return Pe(c,{mergeByMaterial:n,applyTransforms:a,debug:o,parseTime:i,decodeTime:d,perfStart:l,blobBytes:u,fallback:{materials:e.materials,groups:e.groups,sourceComponentId:e.sourceComponentId}})}catch(s){return C().error("Error parsing mesh batch object:",s),[]}}async function Or(e,r){let{mergeByMaterial:t=!0,applyTransforms:n=!0,debug:a=!1}=r??{},o=a?performance.now():0;try{let i=performance.now(),l=le(e),s=performance.now()-i,c=e.byteLength;return Pe(l,{mergeByMaterial:t,applyTransforms:n,debug:a,parseTime:0,decodeTime:s,perfStart:o,blobBytes:c})}catch(i){return C().error("Error parsing mesh batch blob:",i),[]}}function Pe(e,r){let{mergeByMaterial:t,applyTransforms:n,debug:a,parseTime:o,decodeTime:i,perfStart:l,blobBytes:s,fallback:c}=r,d=e.metadata.materials??c?.materials??[],u=e.metadata.groups??c?.groups??[],m=c?.sourceComponentId??e.metadata.sourceComponentId,p=(e.flags&se)!==0,E=p?Rn(e.vertices,n):bn(e.vertices,e.origin,e.scale,n);if(a){let y=e.vertices.byteLength+e.indices.byteLength;C().debug("Mesh Batch Stats:"),C().debug(` Materials: ${d.length} | Groups: ${u.length}`),C().debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),C().debug(` Format: ${p?"float32":"int16 quantized"}`),C().debug(` Blob: ${(s/1024/1024).toFixed(2)} MB | Geometry on wire: ${(y/1024/1024).toFixed(2)} MB`)}let A=performance.now(),v=d.map(Tn),g=[];for(let y of u)if(t&&y.meshes.length>1){let H=wn(y,E,e.indices,v);H.userData.sourceComponentId=m??null,g.push(H)}else{let H=Hn(y,E,e.indices,v);for(let O of H)O.userData.sourceComponentId=m??null;g.push(...H)}let R=performance.now()-A;if(a){let y=performance.now()-l;C().debug("Performance:"),o>0&&C().debug(` Parse JSON: ${o.toFixed(2)}ms`),C().debug(` Decode binary: ${i.toFixed(2)}ms`),C().debug(` Create Meshes: ${R.toFixed(2)}ms`),C().debug(` Total: ${y.toFixed(2)}ms`)}return Promise.resolve(g)}function bn(e,r,t,n){let a=new Float32Array(e.length),o=r[0],i=r[1],l=r[2],s=t[0],c=t[1],d=t[2];for(let u=0;u<e.length;u+=3)a[u]=o+(e[u]+32767)*s,a[u+1]=i+(e[u+1]+32767)*c,a[u+2]=l+(e[u+2]+32767)*d;return a}function Rn(e,r){return e}function Tn(e){let r=ue(e.color);return new U.MeshPhysicalMaterial({color:r,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,side:U.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0})}function wn(e,r,t,n){let a=0,o=0;for(let E of e.meshes)a+=E.vertexCount,o+=E.indexCount;let i=new Float32Array(a*3),l=new Uint32Array(o),s=0,c=0;for(let E of e.meshes){let A=E.vertexStart*3,v=E.vertexCount*3;i.set(r.subarray(A,A+v),s*3);let g=t.subarray(E.indexStart,E.indexStart+E.indexCount),R=s-E.vertexStart;if(R===0)l.set(g,c);else for(let y=0;y<g.length;y++)l[c+y]=g[y]+R;s+=E.vertexCount,c+=E.indexCount}let d=new U.BufferGeometry;d.setAttribute("position",new U.BufferAttribute(i,3)),d.setIndex(new U.BufferAttribute(l,1)),d.computeVertexNormals();let u=new U.Mesh(d,n[e.materialId]),m=e.meshes[0],p=e.meshes.map(E=>E.name).filter(E=>E&&E.length>0);return u.name=p.length>0?p[0]:`merged_material_${e.materialId}`,u.castShadow=!0,u.receiveShadow=!0,u.userData={source:"compute",name:u.name,layer:m?.layer??"",originalIndex:m?.originalIndex??0,metadata:m?.metadata??{},mergedFrom:e.meshes.slice(1).map(E=>({name:E.name,layer:E.layer,originalIndex:E.originalIndex}))},u}function Hn(e,r,t,n){let a=[];for(let o of e.meshes){let i=o.vertexStart*3,l=o.vertexCount*3,s=r.slice(i,i+l),c=t.subarray(o.indexStart,o.indexStart+o.indexCount),d=new Uint32Array(c.length),u=o.vertexStart;for(let E=0;E<c.length;E++)d[E]=c[E]-u;let m=new U.BufferGeometry;m.setAttribute("position",new U.BufferAttribute(s,3)),m.setIndex(new U.BufferAttribute(d,1)),m.computeVertexNormals();let p=new U.Mesh(m,n[e.materialId]);p.name=o.name,p.userData={source:"compute",name:o.name,layer:o.layer??"",originalIndex:o.originalIndex,metadata:o.metadata??{}},p.castShadow=!0,p.receiveShadow=!0,a.push(p)}return a}function vn(e){return Math.floor(e.length*3/4)}var Mn={Millimeters:1/1e3,Centimeters:1/100,Meters:1,Inches:1/39.37,Feet:1/3.28084},xn="Display";async function Ur(e,r){let t=performance.now(),n=[],{allowScaling:a=!0,allowAutoPosition:o=!0,rhino:i,debug:l=!1,parsing:s={}}=r??{};try{let c=a?Cn(e.modelunits):1;return await An(e,n,c,s,i,l),o&&Pn(n),n}catch(c){throw On(c,n),c}finally{l&&Vn(t)}}function Cn(e){return Mn[e]??1}async function An(e,r,t,n,a,o){for(let i of e.values){let l=i.InnerTree;for(let s in l){let c=l[s];c&&await Sn(c,r,t,n,a,o)}}}async function Sn(e,r,t,n,a,o){for(let i of e){if(!i.type.includes(xn))continue;let l={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...n},s=await Le(i.data,l),c=He(Dn(i.data),{rhino:a,applyTransforms:l.applyTransforms}),d=[...s,...c];if(t!==1)for(let u of d)u.scale.set(t,t,t);r.push(...d),o&&C().debug(`Extracted ${s.length} meshes and ${c.length} items from batch`)}}function Dn(e){return(typeof e=="string"?Ln(e):e)?.items}function Ln(e){try{return JSON.parse(e)}catch{return}}function Pn(e){if(e.length===0)return;let r=J(e);de(e,r.min.z,"z")}function On(e,r){C().error("An unexpected error occurred:",e),In(r)}function In(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 Vn(e){let r=performance.now()-e;C().info("Time to process meshes:",`${r.toFixed(2)}ms`)}export{zn as a,ue as b,de as c,J as d,me as e,pe as f,fe as g,ee as h,he as i,et as j,Xn as k,ge as l,be as m,Et as n,Te as o,gr as p,jt as q,He as r,Me as s,xe as t,se as u,ln as v,le as w,Le as x,yn as y,Or as z,Mn as A,Ur as B};
|
|
55
|
+
//# sourceMappingURL=chunk-G3SQHFDY.js.map
|