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