@selvajs/compute 3.1.0-beta.13 → 3.1.0-beta.15
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-6R4EL3ZJ.cjs → chunk-25TNL6LY.cjs} +2 -2
- package/dist/chunk-25TNL6LY.cjs.map +1 -0
- package/dist/chunk-3QSC23Y2.cjs +120 -0
- package/dist/chunk-3QSC23Y2.cjs.map +1 -0
- package/dist/chunk-H3FZW6OX.cjs.map +1 -1
- package/dist/{chunk-6TMSTNHN.js → chunk-J4NKIVF3.js} +2 -2
- package/dist/chunk-KJVV3L5H.js +120 -0
- package/dist/chunk-KJVV3L5H.js.map +1 -0
- package/dist/core.cjs.map +1 -1
- package/dist/grasshopper.cjs +1 -1
- package/dist/grasshopper.cjs.map +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.cjs.map +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-Dtok-mVq.d.ts → types-4FMvnx2j.d.ts} +14 -1
- package/dist/{types-C8XWc4Ab.d.cts → types-BpOl6U02.d.cts} +14 -1
- package/dist/visualization-2TKA3LVK.cjs +2 -0
- package/dist/visualization-2TKA3LVK.cjs.map +1 -0
- package/dist/visualization-XWX3PR4N.js +2 -0
- package/dist/visualization.cjs +1 -1
- package/dist/visualization.cjs.map +1 -1
- package/dist/visualization.d.cts +100 -9
- package/dist/visualization.d.ts +100 -9
- package/dist/visualization.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-6R4EL3ZJ.cjs.map +0 -1
- package/dist/chunk-GLOTP5TC.cjs +0 -120
- package/dist/chunk-GLOTP5TC.cjs.map +0 -1
- package/dist/chunk-NVMSD4CC.js +0 -120
- package/dist/chunk-NVMSD4CC.js.map +0 -1
- package/dist/visualization-BIHTM2KJ.js +0 -2
- package/dist/visualization-FLDYIZ3F.cjs +0 -2
- package/dist/visualization-FLDYIZ3F.cjs.map +0 -1
- /package/dist/{chunk-6TMSTNHN.js.map → chunk-J4NKIVF3.js.map} +0 -0
- /package/dist/{visualization-BIHTM2KJ.js.map → visualization-XWX3PR4N.js.map} +0 -0
package/dist/chunk-NVMSD4CC.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import{a as Dn,b as re,c as ye,d as be,e as F,j as ft}from"./chunk-Y3M7P3BW.js";var Ln={};Dn(Ln,{CONCRETE_MATERIAL:()=>ht,EMISSIVE_MATERIAL:()=>pt,GLASS_MATERIAL:()=>yt,METAL_MATERIAL:()=>Et,PLASTIC_MATERIAL:()=>gt,RUBBER_MATERIAL:()=>bt,SHARED_MATERIALS:()=>We,WOOD_MATERIAL:()=>Tt});import*as z from"three";var pt=new z.MeshPhysicalMaterial({color:0,emissive:new z.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:z.FrontSide,dithering:!0}),Et=new z.MeshPhysicalMaterial({color:new z.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:z.FrontSide,dithering:!0}),ht=new z.MeshPhysicalMaterial({color:new z.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:z.FrontSide,dithering:!0}),gt=new z.MeshPhysicalMaterial({color:new z.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:z.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),yt=new z.MeshPhysicalMaterial({color:new z.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,depthWrite:!1,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:z.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),bt=new z.MeshPhysicalMaterial({color:new z.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:z.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Tt=new z.MeshPhysicalMaterial({color:new z.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:z.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),We=new Set([pt,Et,ht,gt,yt,bt,Tt]);import*as q from"three";var ae={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 ba(e,n,t,r,a){if(Fn(e),n.length===0)return;n.forEach(u=>{e.add(u)});let o=$e(n),i=o.getCenter(new q.Vector3),l=o.getSize(new q.Vector3),s=Math.max(l.x,l.y,l.z);if(s/Math.min(l.x||1,l.y||1,l.z||1)>ae.SCALE_RATIO_THRESHOLD||s>ae.HUGE_THRESHOLD?(t.near=s*ae.NEAR_PLANE_FACTOR.TINY,t.far=s*ae.FAR_PLANE_FACTOR.HUGE):s>ae.LARGE_THRESHOLD?(t.near=s*ae.NEAR_PLANE_FACTOR.SMALL,t.far=s*ae.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,s*ae.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,s*ae.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),!a){let u=s*ae.INITIAL_DISTANCE_MULTIPLIER;t.position.set(i.x+u*.8,i.y+u,i.z+u*1.2),r.target.copy(i),r.update()}}function Rt(e){if(!e||typeof e!="string")return F().warn(`Invalid color input: ${e}, using white`),new q.Color(16777215);let n=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(n))try{let r=n.startsWith("#")?n:`#${n}`;return new q.Color(r)}catch{return F().warn(`Invalid hex color: ${e}, using white`),new q.Color(16777215)}if(n.includes(",")){let r=n.split(",").map(a=>parseInt(a.trim(),10));if(r.length===3&&r.every(a=>!isNaN(a)&&a>=0&&a<=255))return new q.Color(r[0]/255,r[1]/255,r[2]/255)}let t=n.toLowerCase();return t in q.Color.NAMES?new q.Color(q.Color.NAMES[t]):(F().warn(`Invalid color string: ${e}, using white`),new q.Color(16777215))}function xt(e,n,t="z"){e.forEach(r=>{r.position[t]-=n})}function $e(e){let n=new q.Box3;return e.length===0||e.forEach(t=>{t.updateMatrixWorld(!0);let r=new q.Box3().setFromObject(t);n.union(r)}),n}var On=new Set(["grid","floor","label-layer","measure"]);function In(e){let n=e;for(;n;){if(typeof n.userData.id=="string"&&On.has(n.userData.id))return!0;n=n.parent}return!1}function le(e){e.updateMatrixWorld(!0);let n=new q.Box3;return e.traverse(t=>{let r=t;t.visible&&!In(t)&&r.geometry&&n.expandByObject(t)}),n}var Pn=new Set(["floor","grid","label-layer"]),Se="selvaGeometryCache";function Fn(e){[...e.children].forEach(t=>{Pn.has(t.userData.id)||t.userData.source!=="user"&&(t.traverse(r=>{let a=r;if(!a.geometry&&!a.material)return;a.geometry?.userData?.[Se]||a.geometry?.dispose();let o=a.material;if(!o)return;(Array.isArray(o)?o:[o]).forEach(l=>{if(!We.has(l)){for(let s of Object.values(l))s instanceof q.Texture&&s.dispose();l.dispose()}})}),t.removeFromParent())})}import*as Y from"three";function Bn(e){let n=e.clone().normalize(),t=new Y.Vector3(0,0,1),r=new Y.Vector3(0,1,0),a=Math.abs(n.dot(t))>.9?r:t,o=new Y.Vector3().crossVectors(n,a).normalize(),i=new Y.Vector3().crossVectors(o,n).normalize();return{top:n.clone(),bottom:n.clone().negate(),front:i.clone(),back:i.clone().negate(),right:o.clone(),left:o.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(o.clone()).add(n.clone()).normalize()}}function vt(e){let{scene:n,perspective:t,controls:r,onActiveCameraChange:a}=e,o=(e.up??t.up).clone().normalize(),i=Bn(o),l=new Y.OrthographicCamera(-1,1,1,-1,t.near,t.far);l.up.copy(o);let s="perspective",c=t.aspect,u=()=>s==="perspective"?t:l,d=null,E=()=>{d?.cancel(),d=null},T=()=>{let h=(s==="orthographic"?l:t).position.distanceTo(r.target)*Math.tan(t.fov*Math.PI/360),b=h*c;l.left=-b,l.right=b,l.top=h,l.bottom=-h,l.near=t.near,l.far=t.far,l.updateProjectionMatrix()},v=p=>{if(p!==s){if(E(),p==="orthographic")l.position.copy(t.position),l.up.copy(t.up),l.lookAt(r.target),l.zoom=1,T();else{let h=(l.top-l.bottom)/(2*l.zoom)/Math.tan(t.fov*Math.PI/360),b=l.position.clone().sub(r.target);b.lengthSq()<1e-12&&b.copy(o),b.normalize(),t.position.copy(r.target).add(b.multiplyScalar(h))}s=p,r.object=u(),r.update(),a(u())}},y=(p,f,h,b)=>{let C=t.fov*(Math.PI/180),H=f/(2*Math.tan(C/2))*1.5,L=kn(h,o),P=p.clone().add(L.clone().multiplyScalar(H)),k=u();s==="orthographic"&&(l.zoom=1),E(),b?d=_n(k,r,P,p,()=>{s==="orthographic"&&T()}):(k.position.copy(P),r.target.copy(p),s==="orthographic"&&T(),r.update())},m=(p,f=!0)=>{let h=le(n),b=h.isEmpty()?r.target.clone():h.getCenter(new Y.Vector3),C=h.isEmpty()?new Y.Vector3(1,1,1):h.getSize(new Y.Vector3),H=Math.max(C.x,C.y,C.z)||1;y(b,H,p,f)};return{getActiveCamera:u,getProjection:()=>s,setProjection:v,toggleProjection:()=>(v(s==="perspective"?"orthographic":"perspective"),s),setView:(p,f=!0)=>{m(i[p],f)},setViewDirection:m,frameBounds:(p,f=!0)=>{if(p.isEmpty())return;let h=p.getCenter(new Y.Vector3),b=p.getSize(new Y.Vector3),C=Math.max(b.x,b.y,b.z)||1,H=u().position.clone().sub(r.target);H.lengthSq()<1e-12&&H.copy(i.iso),y(h,C,H.normalize(),f)},setRotateEnabled:p=>{r.enableRotate=p},isRotateEnabled:()=>r.enableRotate,updateAspect:(p,f)=>{c=f===0?c:p/f,s==="orthographic"&&T()},dispose:E}}function kn(e,n){let t=n.clone().normalize(),r=e.clone().normalize();if(Math.abs(r.dot(t))<.9999)return e;let a=Math.abs(t.dot(new Y.Vector3(0,0,1)))>.9?new Y.Vector3(0,1,0):new Y.Vector3(0,0,1),o=new Y.Vector3().crossVectors(t,a).normalize(),i=.5*Math.PI/180;return r.multiplyScalar(Math.cos(i)).add(o.multiplyScalar(Math.sin(i))).normalize()}var Un=e=>1-Math.pow(1-e,3);function _n(e,n,t,r,a,o=250){let i=e.position.clone(),l=n.target.clone(),s=performance.now(),c=null,u=()=>{c=null;let d=Un(Math.min((performance.now()-s)/o,1));e.position.lerpVectors(i,t,d),n.target.lerpVectors(l,r,d),a(),n.update(),d<1&&(c=requestAnimationFrame(u))};return c=requestAnimationFrame(u),{cancel:()=>{c!==null&&(cancelAnimationFrame(c),c=null)}}}import*as W from"three";function Vn(e){if(!(e>0)||!Number.isFinite(e))return 1;let n=Math.floor(Math.log10(e)),t=Math.pow(10,n),r=e/t;return(r>=5?5:r>=2?2:1)*t}var zn=`
|
|
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
|
-
`,Gn=`
|
|
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 wt(e={}){let{cellSize:n=1,majorEvery:t=10,cellColor:r=8947848,majorColor:a=4473924,fadeDistance:o=100,plane:i="y"}=e,l=i==="y"?new W.Vector2(0,2):i==="z"?new W.Vector2(0,1):new W.Vector2(1,2),s=2.5,c=new W.PlaneGeometry(1,1);i==="y"?c.rotateX(-Math.PI/2):i==="x"&&c.rotateY(Math.PI/2);let u=new W.ShaderMaterial({vertexShader:zn,fragmentShader:Gn,transparent:!0,depthWrite:!1,side:W.DoubleSide,uniforms:{uAxes:{value:l},uCell:{value:n},uMajor:{value:t},uCellColor:{value:new W.Color(r)},uMajorColor:{value:new W.Color(a)},uCenter:{value:new W.Vector3},uFade:{value:o}}}),d=new W.Mesh(c,u);d.name="grid",d.userData.id="grid",d.renderOrder=-1;let E=o,T=o*s,v=new W.Vector3;return{object:d,update:y=>{i==="y"?(d.position.set(y.x,0,y.z),v.set(y.x,0,y.z)):i==="z"?(d.position.set(y.x,y.y,0),v.set(y.x,y.y,0)):(d.position.set(0,y.y,y.z),v.set(0,y.y,y.z)),u.uniforms.uCenter.value.copy(v),d.scale.setScalar(T)},fitToContent:y=>{if(y.isEmpty())return;let m=y.getSize(new W.Vector3),g=(M,p)=>p===0?M.x:p===1?M.y:M.z,R=Math.max(g(m,l.x),g(m,l.y));if(!(R>0)||!Number.isFinite(R))return;let x=20;u.uniforms.uCell.value=Vn(R/x),E=R*2,u.uniforms.uFade.value=E,T=E*s},setVisible:y=>{d.visible=y},dispose:()=>{d.removeFromParent(),c.dispose(),u.dispose()}}}import*as ee from"three";import{ViewHelper as Nn}from"three/addons/helpers/ViewHelper.js";function Mt(e){let{camera:n,domElement:t,controller:r}=e,a=new Nn(n,t);a.setLabels("X","Y","Z");let o=!0,i=128,l=new ee.Raycaster,s=new ee.OrthographicCamera(-2,2,2,-2,0,4);s.position.set(0,0,2),s.updateMatrixWorld();let c={posX:new ee.Vector3(1,0,0),negX:new ee.Vector3(-1,0,0),posY:new ee.Vector3(0,1,0),negY:new ee.Vector3(0,-1,0),posZ:new ee.Vector3(0,0,1),negZ:new ee.Vector3(0,0,-1)},u=E=>{let T=t.getBoundingClientRect(),v=T.left+t.offsetWidth-i-a.location.right,y=T.top+t.offsetHeight-i-a.location.bottom,m=new ee.Vector2((E.clientX-v)/i*2-1,-((E.clientY-y)/i)*2+1);if(Math.abs(m.x)>1||Math.abs(m.y)>1)return null;a.quaternion.copy(n.quaternion).invert(),a.updateMatrixWorld(),l.setFromCamera(m,s);let g=l.intersectObjects(a.children,!1);for(let R of g){let x=R.object.userData?.type;if(typeof x=="string"&&x in c)return x}return null};return{render:E=>{if(!o)return;let T=E.autoClear;E.autoClear=!1,a.render(E),E.autoClear=T},update:()=>{},handleClick:E=>{if(!o)return!1;let T=u(E);return T?(r.getProjection()==="orthographic"&&r.setProjection("perspective"),r.setViewDirection(c[T],!1),!0):!1},isAnimating:!1,setVisible:E=>{o=E},isVisible:()=>o,dispose:()=>a.dispose()}}import*as J from"three";import{LineSegmentsGeometry as Wn}from"three/addons/lines/LineSegmentsGeometry.js";import{LineSegments2 as Je}from"three/addons/lines/LineSegments2.js";import{LineMaterial as $n}from"three/addons/lines/LineMaterial.js";function De(e,n,t){let o=Math.cos(Math.PI/180*t),i=e.length/3;if(i>=67108864)throw new Error(`extractEdgeSegments: ${i} vertices exceeds 2^26 limit`);let l=new Float64Array(i),s=new Float64Array(i),c=new Float64Array(i);for(let f=0;f<i;f++)l[f]=Math.round(e[3*f]*1e4),s[f]=Math.round(e[3*f+1]*1e4),c[f]=Math.round(e[3*f+2]*1e4);let u=16;for(;u<i*2;)u<<=1;let d=u-1,E=new Int32Array(u).fill(-1),T=new Int32Array(i);for(let f=0;f<i;f++){let h=(Math.imul(l[f]|0,73856093)^Math.imul(s[f]|0,19349663)^Math.imul(c[f]|0,83492791))&d;for(;;){let b=E[h];if(b===-1){E[h]=f,T[f]=f;break}if(l[b]===l[f]&&s[b]===s[f]&&c[b]===c[f]){T[f]=b;break}h=h+1&d}}let v=new Float32Array(4096),y=0,m=(f,h)=>{if(y+6>v.length){let b=new Float32Array(v.length*2);b.set(v),v=b}v[y++]=e[3*f],v[y++]=e[3*f+1],v[y++]=e[3*f+2],v[y++]=e[3*h],v[y++]=e[3*h+1],v[y++]=e[3*h+2]},g=new Map,R=[],x=[],M=[],p=(n?n.length:i)/3;for(let f=0;f<p;f++){let h=n?n[3*f]:3*f,b=n?n[3*f+1]:3*f+1,C=n?n[3*f+2]:3*f+2,H=T[h],L=T[b],P=T[C];if(H===L||L===P||P===H)continue;let k=e[3*C]-e[3*b],O=e[3*C+1]-e[3*b+1],I=e[3*C+2]-e[3*b+2],S=e[3*h]-e[3*b],D=e[3*h+1]-e[3*b+1],G=e[3*h+2]-e[3*b+2],j=O*G-I*D,$=I*S-k*G,U=k*D-O*S,Q=j*j+$*$+U*U;if(Q>0){let K=1/Math.sqrt(Q);j*=K,$*=K,U*=K}else j=0,$=0,U=0;for(let K=0;K<3;K++){let de,fe,ne,se;K===0?(de=h,fe=b,ne=H,se=L):K===1?(de=b,fe=C,ne=L,se=P):(de=C,fe=h,ne=P,se=H);let Ae=se*67108864+ne,me=g.get(Ae);if(me!==void 0&&me!==-1)j*M[3*me]+$*M[3*me+1]+U*M[3*me+2]<=o&&m(de,fe),g.set(Ae,-1);else{let ge=ne*67108864+se;if(!g.has(ge)){let je=R.length;g.set(ge,je),R.push(de),x.push(fe),M.push(j,$,U)}}}}for(let f of g.values())f!==-1&&m(R[f],x[f]);return v.slice(0,y)}function Ct(){return[`const extract = ${De.toString()};`,"self.onmessage = (event) => {"," const { id, positions, index, thresholdAngle } = event.data;"," try {"," const segments = extract(positions, index, thresholdAngle);"," self.postMessage({ id, segments }, [segments.buffer]);"," } catch (error) {"," self.postMessage({ id, error: String((error && error.message) || error) });"," }","};"].join(`
|
|
54
|
-
`)}var xe="edge-overlay",Qe="triangle-cap",qn=2236962,Yn=1.5,Xn=44,Kn=.75,Zn=4e6,Jn=2e6,Qn=25e3,Ht=128*1024*1024,er=80,At=20,tr=1,nr=2;function Dt(e,n){let t=Array.isArray(e.material)?e.material:[e.material];for(let r of t)r&&(r.polygonOffset=n,r.polygonOffsetFactor=n?tr:0,r.polygonOffsetUnits=n?nr:0)}function Ye(e){let n=e.getAttribute("position");return n?(e.index?e.index.count:n.count)/3:0}function Lt(e){let n=e.getAttribute("position");if(!n||n.isInterleavedBufferAttribute||n.itemSize!==3||!(n.array instanceof Float32Array)||n.count>=67108864)return null;let t=e.index;return t&&!(t.array instanceof Uint32Array)&&!(t.array instanceof Uint16Array)?null:{positions:n.array,index:t?t.array:null}}function Ot(e,n){let r=2166136261,a=s=>{r^=s,r=Math.imul(r,16777619)},o=new Uint32Array(e.positions.buffer,e.positions.byteOffset,e.positions.length),i=Math.min(4096,o.length);for(let s=0;s<i;s++)a(o[s]);for(let s=Math.max(i,o.length-4096);s<o.length;s++)a(o[s]);let l=0;if(e.index){l=e.index.length;let s=Math.min(4096,l);for(let c=0;c<s;c++)a(e.index[c]);for(let c=Math.max(s,l-4096);c<l;c++)a(e.index[c])}return`${n}:${e.positions.length}:${l}:${r>>>0}`}var ce=new Map,Le=0;function It(e){let n=ce.get(e);return n&&(ce.delete(e),ce.set(e,n)),n}function Pt(e,n){if(n.byteLength>Ht)return;let t=ce.get(e);for(t&&(Le-=t.byteLength,ce.delete(e)),ce.set(e,n),Le+=n.byteLength;Le>Ht;){let r=ce.keys().next().value;Le-=ce.get(r).byteLength,ce.delete(r)}}function rr(e,n){let t=new J.EdgesGeometry(e,n),r=t.attributes.position?t.attributes.position.array:new Float32Array(0);return t.dispose(),r}function Xe(e,n){let t=Lt(e);if(!t)return rr(e,n);let r=Ot(t,n),a=It(r);if(a)return a;let o=De(t.positions,t.index,n);return Pt(r,o),o}var Ee,Re=new Map,or=1;function ar(){if(Ee!==void 0)return Ee;if(typeof Worker>"u"||typeof Blob>"u"||typeof URL>"u"||typeof URL.createObjectURL!="function")return Ee=null,null;try{let e=URL.createObjectURL(new Blob([Ct()],{type:"text/javascript"})),n=new Worker(e);n.onmessage=t=>{let{id:r,segments:a,error:o}=t.data,i=Re.get(r);i&&(Re.delete(r),a?i.resolve(a):i.reject(new Error(o??"edge extraction failed in worker")))},n.onerror=()=>{for(let t of Re.values())t.reject(new Error("edge extraction worker crashed"));Re.clear(),n.terminate(),Ee=null},Ee=n}catch{Ee=null}return Ee}function ir(e,n,t){return new Promise((r,a)=>{let o=or++;Re.set(o,{resolve:r,reject:a});let i=n.positions.slice(),l=n.index?n.index.slice():null,s=[i.buffer];l&&s.push(l.buffer),e.postMessage({id:o,positions:i,index:l,thresholdAngle:t},s)})}var qe=new Map;function sr(e,n){let t=Lt(e);if(!t||Ye(e)<Qn)return Promise.resolve(Xe(e,n));let r=Ot(t,n),a=It(r);if(a)return Promise.resolve(a);let o=qe.get(r);if(o)return o;let i=ar();if(!i)return Promise.resolve(Xe(e,n));let l=ir(i,t,n).catch(()=>De(t.positions,t.index,n)).then(s=>(Pt(r,s),s)).finally(()=>{qe.delete(r)});return qe.set(r,l),l}var Oe=new WeakMap;function Ke(e,n){return Oe.get(e)?.get(n)}function Ft(e,n,t){let r=Oe.get(e);r||(r=new Map,Oe.set(e,r));let a=new Wn;a.setPositions(t);let o={geometry:a,refCount:0,segmentCount:t.length/6};return r.set(n,o),o}function lr(e){let n=e.userData,t=n.edgeSource&&Oe.get(n.edgeSource),r=n.edgeThresholdAngle!=null?t?.get(n.edgeThresholdAngle):void 0;if(!r||r.geometry!==e.geometry){e.geometry.dispose();return}r.refCount-=1,r.refCount<=0&&(r.geometry.dispose(),t.delete(n.edgeThresholdAngle))}function Bt(e){return{forcedColor:e.color!=null?new J.Color(e.color):null,darken:J.MathUtils.clamp(e.darken??Kn,0,1),width:e.width??Yn,thresholdAngle:e.thresholdAngle??Xn,distanceFade:e.distanceFade??!0,maxTriangles:e.maxTriangles??Zn,maxSegments:e.maxSegments??Jn}}function cr(e,n){let r=(Array.isArray(e.material)?e.material[0]:e.material)?.color;return r?r.clone().multiplyScalar(1-n):new J.Color(qn)}var Ie=class{constructor(n){re(this,"options",n);re(this,"byKey",new Map)}for(n,t){let r=this.options.forcedColor??cr(n,this.options.darken),a=r.getHex()*2+(t?1:0),o=this.byKey.get(a);return o||(o=ur(r,this.options.width,t),this.byKey.set(a,o)),o}disposeUnused(n){let t=new Set(n.map(r=>r.material));for(let r of this.byKey.values())t.has(r)||r.dispose()}};function ur(e,n,t){let r=new $n({color:e});return r.linewidth=n,t&&(r.transparent=!0),r}function dr(e,n,t,r,a){n.refCount+=1;let o=new Je(n.geometry,t);return o.userData.kind=xe,o.userData.edgeSource=e,o.userData.edgeThresholdAngle=r,o.raycast=()=>{},a&&pr(o),o}var St=new J.Vector3,mr=new J.Vector3;function fr(e,n,t){e.geometry.boundingSphere||e.geometry.computeBoundingSphere();let r=e.geometry.boundingSphere;if(!r||r.radius<=0)return 1/0;let a=r.radius*e.matrixWorld.getMaxScaleOnAxis();if(St.copy(r.center).applyMatrix4(e.matrixWorld),n.isPerspectiveCamera){let o=n,i=mr.setFromMatrixPosition(n.matrixWorld).distanceTo(St);if(i<=a)return 1/0;let l=Math.tan(J.MathUtils.degToRad(o.fov)*.5);return a/(i*l)*t}if(n.isOrthographicCamera){let o=n,i=(o.top-o.bottom)/o.zoom;return i>0?2*a/i*t:1/0}return 1/0}function pr(e){e.onBeforeRender=(n,t,r)=>{Je.prototype.onBeforeRender.call(e,n);let a=e.material,o=fr(e,r,a.resolution.y);a.opacity=J.MathUtils.clamp((o-At)/(er-At),0,1)}}function Er(e){return e.userData?.kind===xe}function kt(e,n){let t=[];return e.traverse(r=>{if(r instanceof J.Mesh&&!(r.userData.id==="floor"||r.userData.id==="grid")&&r.userData.kind!==xe&&!r.children.some(a=>a.userData?.kind===xe)&&r.geometry){if(Ye(r.geometry)>n){r.userData.edgesSkipped=Qe,console.debug(`[edges] skipping mesh over triangle cap (${Ye(r.geometry)} > ${n})`);return}delete r.userData.edgesSkipped,t.push(r)}}),t}function Ut(e,n,t,r){let a=r.distanceFade&&n.segmentCount<=r.maxSegments,o=dr(e.geometry,n,t.for(e,a),r.thresholdAngle,a);return e.add(o),Dt(e,!0),o}function La(e,n={}){let t=Bt(n),r=new Ie(t),a=[];for(let o of kt(e,t.maxTriangles)){let i=Ke(o.geometry,t.thresholdAngle)??Ft(o.geometry,t.thresholdAngle,Xe(o.geometry,t.thresholdAngle));a.push(Ut(o,i,r,t))}return r.disposeUnused(a),a}var _t=new WeakMap;function Ze(e){return _t.get(e)??0}function hr(e,n){for(let t=e;t;t=t.parent)if(t===n)return!0;return!1}async function Vt(e,n={}){let t=Bt(n),r=new Ie(t),a=Ze(e),o=[],i=kt(e,t.maxTriangles).map(async l=>{let s=Ke(l.geometry,t.thresholdAngle);if(!s){let c=await sr(l.geometry,t.thresholdAngle);if(Ze(e)!==a||!hr(l,e)||l.children.some(u=>u.userData?.kind===xe))return;s=Ke(l.geometry,t.thresholdAngle),s||(s=Ft(l.geometry,t.thresholdAngle,c))}o.push(Ut(l,s,r,t))});return await Promise.all(i),r.disposeUnused(o),o}function zt(e){_t.set(e,Ze(e)+1);let n=[];e.traverse(r=>{r instanceof Je&&Er(r)&&n.push(r)});let t=new Set;for(let r of n)lr(r),t.add(r.material),r.parent instanceof J.Mesh&&Dt(r.parent,!1),r.removeFromParent();return t.forEach(r=>r.dispose()),n.length}import*as N from"three";import{Pass as gr,FullScreenQuad as yr}from"three/addons/postprocessing/Pass.js";var et={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new N.Vector2(1,1)},uColor:{value:new N.Color(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
|
|
55
|
-
varying vec2 vUv;
|
|
56
|
-
void main() {
|
|
57
|
-
vUv = uv;
|
|
58
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
59
|
-
}
|
|
60
|
-
`,fragmentShader:`
|
|
61
|
-
uniform sampler2D tDiffuse;
|
|
62
|
-
uniform sampler2D tNormal;
|
|
63
|
-
uniform sampler2D tDepth;
|
|
64
|
-
uniform vec2 uResolution;
|
|
65
|
-
uniform vec3 uColor;
|
|
66
|
-
uniform float uOpacity;
|
|
67
|
-
uniform float uNormalThreshold;
|
|
68
|
-
uniform float uDepthThreshold;
|
|
69
|
-
uniform float uThickness;
|
|
70
|
-
uniform float uNear;
|
|
71
|
-
uniform float uFar;
|
|
72
|
-
uniform float uPerspective;
|
|
73
|
-
varying vec2 vUv;
|
|
74
|
-
|
|
75
|
-
float viewZOf(const in float depth) {
|
|
76
|
-
float perspective = (uNear * uFar) / ((uFar - uNear) * depth - uFar);
|
|
77
|
-
float orthographic = -(depth * (uFar - uNear) + uNear);
|
|
78
|
-
return mix(orthographic, perspective, uPerspective);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
void main() {
|
|
82
|
-
vec4 color = texture2D(tDiffuse, vUv);
|
|
83
|
-
vec2 texel = uThickness / uResolution;
|
|
84
|
-
|
|
85
|
-
// Roberts cross over the two diagonal pairs.
|
|
86
|
-
vec2 offsetA = vec2(texel.x, texel.y);
|
|
87
|
-
vec2 offsetB = vec2(texel.x, -texel.y);
|
|
88
|
-
|
|
89
|
-
float z0 = viewZOf(texture2D(tDepth, vUv + offsetA).x);
|
|
90
|
-
float z1 = viewZOf(texture2D(tDepth, vUv - offsetA).x);
|
|
91
|
-
float z2 = viewZOf(texture2D(tDepth, vUv + offsetB).x);
|
|
92
|
-
float z3 = viewZOf(texture2D(tDepth, vUv - offsetB).x);
|
|
93
|
-
float zCenter = viewZOf(texture2D(tDepth, vUv).x);
|
|
94
|
-
// Relative difference: a constant threshold in absolute Z turns distant geometry into
|
|
95
|
-
// noise (depth precision) and near geometry blind; normalizing by the center depth keeps
|
|
96
|
-
// the response scale-invariant across the viewer's mm\u2192m scenes.
|
|
97
|
-
float depthDelta = (abs(z0 - z1) + abs(z2 - z3)) / max(abs(zCenter), 1e-6);
|
|
98
|
-
float depthEdge = step(uDepthThreshold, depthDelta);
|
|
99
|
-
|
|
100
|
-
vec3 n0 = texture2D(tNormal, vUv + offsetA).rgb * 2.0 - 1.0;
|
|
101
|
-
vec3 n1 = texture2D(tNormal, vUv - offsetA).rgb * 2.0 - 1.0;
|
|
102
|
-
vec3 n2 = texture2D(tNormal, vUv + offsetB).rgb * 2.0 - 1.0;
|
|
103
|
-
vec3 n3 = texture2D(tNormal, vUv - offsetB).rgb * 2.0 - 1.0;
|
|
104
|
-
float normalDelta = (1.0 - dot(n0, n1)) + (1.0 - dot(n2, n3));
|
|
105
|
-
float normalEdge = step(uNormalThreshold, normalDelta);
|
|
106
|
-
|
|
107
|
-
float edge = max(depthEdge, normalEdge) * uOpacity;
|
|
108
|
-
gl_FragColor = vec4(mix(color.rgb, uColor, edge), color.a);
|
|
109
|
-
}
|
|
110
|
-
`},Pe=class extends gr{constructor(t,r,a,o,i={}){super();re(this,"camera");re(this,"scene");re(this,"normalMaterial");re(this,"edgeMaterial");re(this,"fsQuad");re(this,"normalTarget",null);re(this,"width");re(this,"height");this.scene=t,this.camera=r,this.width=Math.max(1,a),this.height=Math.max(1,o),this.normalMaterial=new N.MeshNormalMaterial,this.normalMaterial.blending=N.NoBlending,this.edgeMaterial=new N.ShaderMaterial({uniforms:N.UniformsUtils.clone(et.uniforms),vertexShader:et.vertexShader,fragmentShader:et.fragmentShader});let l=this.edgeMaterial.uniforms;l.uColor.value=new N.Color(i.color??2236962),l.uOpacity.value=i.opacity??1,l.uNormalThreshold.value=i.normalThreshold??.4,l.uDepthThreshold.value=i.depthThreshold??.02,l.uThickness.value=i.thickness??1,this.fsQuad=new yr(this.edgeMaterial),this.needsSwap=!0}acquireNormalTarget(){if(!this.normalTarget){let t=new N.DepthTexture(this.width,this.height);this.normalTarget=new N.WebGLRenderTarget(this.width,this.height,{minFilter:N.NearestFilter,magFilter:N.NearestFilter,depthTexture:t})}return this.normalTarget}setSize(t,r){this.width=Math.max(1,t),this.height=Math.max(1,r),this.normalTarget?.setSize(this.width,this.height)}render(t,r,a){let o=this.acquireNormalTarget(),i=t.getRenderTarget(),l=t.autoClear,s=t.getClearColor(new N.Color),c=t.getClearAlpha(),u=this.scene.overrideMaterial;t.setRenderTarget(o),t.setClearColor(7829503,1),t.autoClear=!0,this.scene.overrideMaterial=this.normalMaterial,t.render(this.scene,this.camera),this.scene.overrideMaterial=u,t.setClearColor(s,c),t.autoClear=l;let d=this.edgeMaterial.uniforms;d.tDiffuse.value=a.texture,d.tNormal.value=o.texture,d.tDepth.value=o.depthTexture,d.uResolution.value.set(this.width,this.height);let E=this.camera;d.uPerspective.value=E.isPerspectiveCamera?1:0,d.uNear.value=this.camera.near??.1,d.uFar.value=this.camera.far??1e3,t.setRenderTarget(this.renderToScreen?null:r),this.fsQuad.render(t),t.setRenderTarget(i)}dispose(){this.normalTarget?.dispose(),this.normalMaterial.dispose(),this.edgeMaterial.dispose(),this.fsQuad.dispose()}};import{EffectComposer as br}from"three/addons/postprocessing/EffectComposer.js";import{RenderPass as Tr}from"three/addons/postprocessing/RenderPass.js";import{GTAOPass as Rr}from"three/addons/postprocessing/GTAOPass.js";import{SMAAPass as xr}from"three/addons/postprocessing/SMAAPass.js";import{OutputPass as vr}from"three/addons/postprocessing/OutputPass.js";function Gt(e,n,t,r,a,o){let i=new br(e),l=new Tr(n,t);i.addPass(l);let s=null;(o.ambientOcclusion??!0)&&(s=new Rr(n,t,r,a),s.blendIntensity=o.aoIntensity??1,s.updateGtaoMaterial({screenSpaceRadius:!0}),i.addPass(s));let c=typeof o.edgeDetection=="object"?o.edgeDetection:{},u=new Pe(n,t,r,a,c);u.enabled=!!o.edgeDetection,i.addPass(u);let d=new xr;i.addPass(d);let E=new vr;i.addPass(E),e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure;let T=o.aoPixelRatio??1;return i.setSize(r,a),{render:v=>i.render(v),setSize:(v,y,m)=>{i.setPixelRatio(Math.min(m,T)),i.setSize(v,y)},setCamera:v=>{if(l.camera=v,u.camera=v,!s)return;s.camera=v;let y=v.isPerspectiveCamera?1:0;s.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==y&&(s.gtaoMaterial.defines.PERSPECTIVE_CAMERA=y,s.gtaoMaterial.needsUpdate=!0)},setEdgeDetection:v=>{u.enabled=v},edgeDetectionEnabled:()=>u.enabled,dispose:()=>{i.dispose(),s?.dispose(),u.dispose(),d.dispose(),E.dispose()}}}import*as Nt from"three";import{CSS2DRenderer as wr,CSS2DObject as Mr}from"three/addons/renderers/CSS2DRenderer.js";function jt(e,n){let t=new wr,r=t.domElement;r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.overflow="hidden",r.style.pointerEvents="none",r.style.zIndex="30",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(r);let a={width:e.clientWidth||1,height:e.clientHeight||1};t.setSize(a.width,a.height);let o=new Nt.Group;o.name="label-layer",o.userData.id="label-layer",n.add(o);let i=new Set;return{addLabel:(s,c,u)=>{let d=document.createElement("div");d.textContent=s,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 E=new Mr(d);return E.position.copy(c),o.add(E),i.add(E),{object:E,setPosition:T=>E.position.copy(T),setText:T=>{d.textContent=T},remove:()=>{E.removeFromParent(),d.remove(),i.delete(E)}}},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(),r.remove()}}}import*as _ from"three";import{Line2 as Cr}from"three/addons/lines/Line2.js";import{LineGeometry as Hr}from"three/addons/lines/LineGeometry.js";import{LineMaterial as Ar}from"three/addons/lines/LineMaterial.js";var Sr=12,Dr=16763904,Wt=.015,$t={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 Lr(e){let n=e&&$t[e]||$t.Meters;return t=>`${(t/n.metersPerUnit).toPrecision(3)} ${n.suffix}`}function Or(e,n){if(e.isOrthographicCamera){let r=e;return Math.abs(r.top-r.bottom)/(r.zoom||1)*Wt}return((n?e.position.distanceTo(n):e.position.length())||1)*Wt}function Ir(e){let n=e.object;if(n instanceof _.Mesh)return e.face?[e.face.a,e.face.b,e.face.c]:null;if(n instanceof _.Points)return e.index!=null?[e.index]:null;if(n instanceof _.Line){if(e.index==null)return null;let t=n.geometry.index;return t?e.index+1>=t.count?null:[t.getX(e.index),t.getX(e.index+1)]:[e.index,e.index+1]}return null}function Pr(e,n,t,r){let a=e.point.clone(),o=e.object,i=Ir(e);if(!i||!o.geometry)return a;let l=o.geometry.attributes.position;if(!l)return a;let s=E=>{let T=E.clone().project(n);return new _.Vector2((T.x+1)/2*t.width,(1-T.y)/2*t.height)},c=s(a),u=a,d=r;for(let E of i){if(E>=l.count)continue;let v=new _.Vector3().fromBufferAttribute(l,E).applyMatrix4(o.matrixWorld),y=s(v).distanceTo(c);y<d&&(d=y,u=v)}return u}function qt(e){let{canvas:n,scene:t,getActiveCamera:r,getViewTarget:a,labelLayer:o,options:i={}}=e,l=i.snapPixels??Sr,s=new _.Color(i.color??Dr),c=Lr(i.displayUnit),u=(S,D)=>`${c(S)}
|
|
111
|
-
\u0394x ${c(D.x)} \u0394y ${c(D.y)} \u0394z ${c(D.z)}`,d=i.format??u,E=new _.Raycaster,T=new _.Vector2,v=!1,y=[],m=[],g=null,R=null,x=new _.PointsMaterial({color:s,size:8,sizeAttenuation:!1,depthTest:!1}),M=new _.PointsMaterial({color:s,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),p=null,f=S=>{if(!S){p&&(p.visible=!1);return}if(!p){let D=new _.BufferGeometry;D.setAttribute("position",new _.Float32BufferAttribute([0,0,0],3)),p=new _.Points(D,M),p.renderOrder=1e3,p.userData.id="measure",p.raycast=()=>{},t.add(p)}p.position.copy(S),p.visible=!0},h=S=>{let D=new _.BufferGeometry;D.setAttribute("position",new _.Float32BufferAttribute([S.x,S.y,S.z],3));let G=new _.Points(D,x);return G.renderOrder=999,G.userData.id="measure",G.raycast=()=>{},t.add(G),G},b=()=>{y.length=0,m.forEach(S=>{S.geometry.dispose(),S.removeFromParent()}),m.length=0,g&&(g.geometry.dispose(),g.material.dispose(),g.removeFromParent(),g=null),R?.remove(),R=null},C=()=>{if(y.length!==2)return;let[S,D]=y,G=new Hr;G.setPositions([S.x,S.y,S.z,D.x,D.y,D.z]);let j=new Ar({color:s});j.linewidth=2,j.depthTest=!1,g=new Cr(G,j),g.renderOrder=998,g.userData.id="measure",g.raycast=()=>{},t.add(g);let $=S.clone().add(D).multiplyScalar(.5),U=new _.Vector3(Math.abs(D.x-S.x),Math.abs(D.y-S.y),Math.abs(D.z-S.z));R=o.addLabel(d(S.distanceTo(D),U),$,i.labelClassName)},H=S=>{let D=n.getBoundingClientRect();T.x=(S.clientX-D.left)/D.width*2-1,T.y=-((S.clientY-D.top)/D.height)*2+1;let G=r();E.setFromCamera(T,G);let j=Or(G,a?.());E.params.Line.threshold=j,E.params.Points.threshold=j;let $=E.intersectObjects(t.children,!0).filter(U=>U.object.userData.id!=="measure"&&U.object.userData.id!=="grid");return $.length===0?null:Pr($[0],G,{width:D.width,height:D.height},l)},L=null,P=0,k=()=>{P&&(cancelAnimationFrame(P),P=0),L=null};return{setEnabled:S=>{v=S,S||(k(),b(),f(null))},isEnabled:()=>v,handleClick:S=>{if(!v)return!1;y.length===2&&b();let D=H(S);return D===null||(y.push(D),m.push(h(D)),y.length===2&&C()),!0},handleMove:S=>{v&&(L=S,!P&&(P=requestAnimationFrame(()=>{P=0;let D=L;L=null,!(!v||!D)&&f(H(D))})))},clear:b,dispose:()=>{k(),b(),p&&(p.geometry.dispose(),p.removeFromParent(),p=null),x.dispose(),M.dispose()}}}import*as Ue from"three";var Fr=64,Br=256,oe=new Map,ve=new Map,Fe=0,ke=class extends Error{constructor(n){super(`Texture load for ${n} resolved after clearTextureCache(); texture disposed.`),this.name="StaleTextureLoadError"}},Be=1;function Yt(e){Be=Math.max(1,e);for(let n of oe.values())n.anisotropy!==Be&&(n.anisotropy=Be,n.needsUpdate=!0)}function Xt(e,n){let t=kr(n),r=oe.get(t);if(r){oe.delete(t),oe.set(t,r),e.map=r,e.needsUpdate=!0;return}typeof document>"u"||Vr(n,t).then(a=>{e.map=a,e.needsUpdate=!0}).catch(a=>{a instanceof ke||F().warn(`Failed to load material texture ${n}:`,a)})}function Za(){Fe++;for(let e of oe.values())e.dispose();oe.clear(),ve.clear()}function kr(e){return e.length<=Br?e:`data-uri:${Ur(e).toString(16)}:${e.length}`}function Ur(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return n>>>0}function _r(e,n){for(oe.set(e,n);oe.size>Fr;){let t=oe.keys().next().value,r=oe.get(t);oe.delete(t),r.dispose()}}function Vr(e,n){let t=ve.get(n);if(!t){let r=Fe;t=new Promise((a,o)=>{new Ue.TextureLoader().load(e,i=>{if(r!==Fe){i.dispose(),o(new ke(e));return}i.colorSpace=Ue.SRGBColorSpace,i.anisotropy=Be,_r(n,i),ve.delete(n),a(i)},void 0,i=>{r===Fe&&ve.delete(n),o(i)})}),ve.set(n,t)}return t}import*as w from"three";import{OrbitControls as jr}from"three/addons/controls/OrbitControls.js";import{HDRLoader as Wr}from"three/addons/loaders/HDRLoader.js";import*as we from"three";var zr=.5,Gr=.01,Nr=.05;function Kt({camera:e,scene:n,groundNormals:t=[]}){let r=e.near,a=e.near,o=new we.Vector3,i=new we.Vector3;return{update:()=>{e.near!==a&&(r=e.near);let s=le(n),c=r;if(!s.isEmpty()){let u=s.getSize(i).length()*.5,d=e.position.distanceTo(s.getCenter(o))-u;for(let E of t)d=Math.min(d,Math.abs(e.position.dot(E)));c=we.MathUtils.clamp(d*zr,r,e.far*Gr)}Math.abs(c-a)>a*Nr&&(e.near=c,e.updateProjectionMatrix(),a=c)}}}var Te=new w.Vector3(0,0,1),$r="technical",tt={studio:{toneMapping:w.ACESFilmicToneMapping,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.75,ambientIntensity:.4,cullBackfaces:!1,ambientOcclusion:!1},technical:{toneMapping:w.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:.9,environmentIntensity:1,hemisphereIntensity:.35,ambientIntensity:.25,cullBackfaces:!1,ambientOcclusion:!1},showcase:{toneMapping:w.ACESFilmicToneMapping,toneMappingExposure:1.15,envMapIntensity:1.4,environmentIntensity:1.25,hemisphereIntensity:.35,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!1}};function qr(e){let n=tt[e];return{envMapIntensity:n.envMapIntensity,cullBackfaces:n.cullBackfaces}}function Yr(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 pi=function(e,n){let t=Xr(n||{}),r=t.environment?.sceneUp||Te,a=t.render.pixelRatio??Math.min(window.devicePixelRatio,2),o=Zr(t),i=no(t,e);i.up.copy(r);let l=ro(e,t,a);Yt(l.capabilities.getMaxAnisotropy());let s=ao(i,e,t),c=vt({scene:o,perspective:i,controls:s,onActiveCameraChange:()=>{},up:r}),u=()=>c.getActiveCamera(),d=!1;Qr(o,l,t,()=>d);let E=eo(o,t),T=E.sun,v=()=>{T&&Kr(T,le(o))};t.floor?.enabled&&to(o,t);let y=t.grid.enabled?wt({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;y&&o.add(y.object);let m=()=>{y&&y.fitToContent(le(o))},g=t.gizmo.enabled?Mt({camera:i,domElement:e,controller:c}):null,R=[];if(y){let A=t.grid.plane??"z";R.push(new w.Vector3(A==="x"?1:0,A==="y"?1:0,A==="z"?1:0))}t.floor.enabled&&R.push(r.clone().normalize());let x=t.camera.dynamicNear?Kt({camera:i,scene:o,groundNormals:R}):null,M=e.parentElement??e,p=t.measure.enabled?jt(M,o):null,f=t.measure.enabled&&p?qt({canvas:e,scene:o,getActiveCamera:u,labelLayer:p,options:{snapPixels:t.measure.snapPixels,color:t.measure.color,labelClassName:t.measure.labelClassName,displayUnit:t.measure.displayUnit,format:t.measure.format}}):null,h=t.events.enableEventHandlers!==!1?oo(e,o,c,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},b=5,C=0,H=0,L=A=>{C=A.clientX,H=A.clientY},P=A=>Math.hypot(A.clientX-C,A.clientY-H)>b,k=A=>{if(!P(A)){if(f?.handleClick(A)){A.stopImmediatePropagation();return}g?.handleClick(A)&&A.stopImmediatePropagation()}};(g||f)&&(e.addEventListener("mousedown",L,{capture:!0}),e.addEventListener("click",k,{capture:!0}));let O=A=>f?.handleMove(A);f&&e.addEventListener("mousemove",O,{passive:!0});let I=()=>{},S=A=>{Vt(A,{color:t.edges.color,darken:t.edges.darken,width:t.edges.width,thresholdAngle:t.edges.thresholdAngle,distanceFade:t.edges.distanceFade,maxTriangles:t.edges.maxTriangles,maxSegments:t.edges.maxSegments}).then(()=>{D(A),I()})},D=A=>{if(t.edges.screenSpaceFallback===!1)return;let B=!1;A.traverse(Z=>{Z.userData?.edgesSkipped===Qe&&(B=!0)}),B!==K&&(K=B,ne())},G=A=>{zt(A),K&&(K=!1,ne()),I()},j=e.parentElement,$=()=>j?{width:j.clientWidth,height:j.clientHeight}:{width:window.innerWidth,height:window.innerHeight},U=null,Q=!!t.render.ambientOcclusion,K=!1,de=!1,fe=A=>{let{width:B,height:Z}=$(),pe=Gt(l,o,u(),Math.max(1,B),Math.max(1,Z),{toneMapping:t.render.toneMapping??w.NeutralToneMapping,toneMappingExposure:t.render.toneMappingExposure??1,ambientOcclusion:A,aoIntensity:t.render.aoIntensity,aoPixelRatio:t.render.aoPixelRatio,edgeDetection:!1});return pe.setSize(Math.max(1,B),Math.max(1,Z),a),pe},ne=()=>{if(!(Q||K)){U?.dispose(),U=null,I();return}(!U||de!==Q)&&(U?.dispose(),U=fe(Q),de=Q),U.setEdgeDetection(K),I()},se=()=>{U?.dispose(),U=null,ne()},Ae=A=>{Q=A,ne()};ne();let me=A=>{A.ambientIntensity!==void 0&&(E.ambient.intensity=A.ambientIntensity),A.hemisphereIntensity!==void 0&&!E.hemisphere&&A.hemisphereIntensity>0&&(E.hemisphere=new w.HemisphereLight(A.hemisphereSkyColor??t.lighting.hemisphereSkyColor,A.hemisphereGroundColor??t.lighting.hemisphereGroundColor,A.hemisphereIntensity),E.hemisphere.position.copy(t.environment.sceneUp??Te),o.add(E.hemisphere)),E.hemisphere&&(A.hemisphereIntensity!==void 0&&(E.hemisphere.intensity=A.hemisphereIntensity),A.hemisphereSkyColor!==void 0&&E.hemisphere.color.set(A.hemisphereSkyColor),A.hemisphereGroundColor!==void 0&&E.hemisphere.groundColor.set(A.hemisphereGroundColor)),I()},ge=A=>{t.environment.environmentIntensity=A,o.environmentIntensity=A,I()},je=A=>{t.render.toneMappingExposure=A,l.toneMappingExposure=A,U&&se()},Rn=A=>{t.render.aoIntensity=A,U&&se()},xn=A=>{let B=tt[A];ct=A,l.toneMapping=B.toneMapping,l.toneMappingExposure=B.toneMappingExposure,t.render.toneMapping=B.toneMapping,t.render.toneMappingExposure=B.toneMappingExposure,me({hemisphereIntensity:B.hemisphereIntensity,ambientIntensity:B.ambientIntensity}),ge(B.environmentIntensity),Q=B.ambientOcclusion,U?se():ne(),o.traverse(Z=>{if(Z.userData.source!=="compute")return;let pe=Z,Sn=Array.isArray(pe.material)?pe.material:pe.material?[pe.material]:[];for(let mt of Sn)"envMapIntensity"in mt&&(mt.envMapIntensity=B.envMapIntensity)}),I()},ct=t.look,vn=()=>qr(ct),{animate:wn,dispose:Mn,invalidate:ut}=Jr(l,o,i,u,c,s,$,a,t.events.onFrame,y,g,()=>U,p,x,t.render.onDemand??!0);I=ut,wn(),o.up.set(r.x,r.y,r.z),v(),m();let dt=A=>{A.traverse(B=>{let Z=B;!Z.geometry&&!Z.material||(Z.geometry?.dispose(),Array.isArray(Z.material)?Z.material.forEach(_e):Z.material&&_e(Z.material))})},Cn=A=>{A.userData.source="user",o.add(A)},Hn=A=>{A.removeFromParent(),dt(A)},An=()=>{o.children.filter(B=>B.userData.source==="user").forEach(B=>{B.removeFromParent(),dt(B)})};return{scene:o,camera:i,controls:s,renderer:l,cameraController:c,grid:y,gizmo:g,measureTool:f,applyEdges:S,clearEdges:G,invalidate:ut,setAmbientOcclusion:Ae,setLook:xn,setFillLights:me,setEnvironmentIntensity:ge,setToneMappingExposure:je,setAoIntensity:Rn,getMaterialAppearance:vn,updateShadowBounds:v,updateGridScale:m,dispose:()=>{d||(d=!0,Mn(),h.dispose(),(g||f)&&(e.removeEventListener("mousedown",L,{capture:!0}),e.removeEventListener("click",k,{capture:!0})),f&&e.removeEventListener("mousemove",O),f?.dispose(),p?.dispose(),g?.dispose(),y?.dispose(),U?.dispose(),c.dispose(),s.dispose(),l.dispose(),l.forceContextLoss(),o.traverse(A=>{let B=A;!B.geometry&&!B.material||(B.geometry?.dispose(),Array.isArray(B.material)?B.material.forEach(_e):B.material&&_e(B.material))}),o.environment?.dispose(),o.background instanceof w.Texture&&o.background.dispose())},fitToView:h.fitToView,clearSelection:h.clearSelection,addUserGeometry:Cn,removeUserGeometry:Hn,clearUserGeometry:An}};function Xr(e){let n=e.sceneScale||"m",r={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[n],a=e.look??$r,o=tt[a];return{sceneScale:n,look:a,camera:{position:e.camera?.position||new w.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 w.Vector3(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??1,sunlightPosition:e.lighting?.sunlightPosition||new w.Vector3(r.lightDistance,r.lightDistance,r.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new w.Color(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??o.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??o.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??o.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath||"/baseHDR.hdr",backgroundColor:e.environment?.backgroundColor||new w.Color(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||Te,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??o.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||r.floorSize,color:e.floor?.color||new w.Color(8421504),roughness:e.floor?.roughness??.7,metalness:e.floor?.metalness??0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||2048,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping??o.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??o.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,ambientOcclusion:e.render?.ambientOcclusion??o.ambientOcclusion,aoIntensity:e.render?.aoIntensity??1,aoPixelRatio:e.render?.aoPixelRatio??1,onDemand:e.render?.onDemand??!0},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??Yr(e.environment?.sceneUp??Te)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color,darken:e.edges?.darken,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??44,distanceFade:e.edges?.distanceFade??!0},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,displayUnit:e.measure?.displayUnit,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||"#ff0000",enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame}}}function _e(e){for(let n of Object.values(e))n instanceof w.Texture&&n.dispose();e.dispose()}function Kr(e,n){if(n.isEmpty())return;let t=n.getCenter(new w.Vector3),r=n.getSize(new w.Vector3).length()*.5*1.2,a=e.shadow.camera;a.left=-r,a.right=r,a.top=r,a.bottom=-r,e.target.position.copy(t),e.target.updateMatrixWorld();let o=e.position.distanceTo(t);a.near=Math.max(r*.01,o-r),a.far=o+r,a.updateProjectionMatrix()}function Zr(e){let n=new w.Scene,t=typeof e.environment.backgroundColor=="string"?new w.Color(e.environment.backgroundColor):e.environment.backgroundColor;return n.background=t||null,n}function Jr(e,n,t,r,a,o,i,l,s,c,u,d,E,T,v=!0){let y=null,m=performance.now(),g=!0,R=0,x=500,M=new w.Matrix4,p=new w.Matrix4,f=null,h=()=>{g=!0},b=O=>{O.updateMatrixWorld();let I=f!==O||!M.equals(O.matrixWorld)||!p.equals(O.projectionMatrix);return I&&(f=O,M.copy(O.matrixWorld),p.copy(O.projectionMatrix)),I},C=e.domElement,H=["pointerdown","pointerup","wheel"];if(v)for(let O of H)C.addEventListener(O,h,{passive:!0});let L=()=>{let{width:O,height:I}=i();if(O===0||I===0)return;let S=Math.floor(O*l),D=Math.floor(I*l);(e.domElement.width!==S||e.domElement.height!==D)&&(e.setPixelRatio(l),e.setSize(O,I,!1),t.aspect=O/I,t.updateProjectionMatrix(),a.updateAspect(O,I),d?.()?.setSize(O,I,l),E?.setSize(O,I),h())},P=function(){y=requestAnimationFrame(P);let O=performance.now(),I=(O-m)/1e3;m=O,L(),(o.enableDamping||o.autoRotate)&&o.update(),c&&c.update(r().position),u&&u.update(I),T&&T.update(),s?.(I);let S=r();if(v){if(!(g||b(S)||O-R>=x))return;g=!1,R=O}let D=d?.();D?(D.setCamera(S),D.render(I)):e.render(n,S),E&&E.render(n,S),u&&u.render(e)};return{animate:P,dispose:()=>{if(y!==null&&(cancelAnimationFrame(y),y=null),v)for(let O of H)C.removeEventListener(O,h)},invalidate:h}}function Qr(e,n,t,r){t.environment.enableEnvironmentLighting?new Wr().load(t.environment.hdrPath||"/baseHDR.hdr",function(a){if(r()){a.dispose();return}if(!a?.image){F().warn("HDR loaded without image data; skipping environment map."),a?.dispose(),t.events.onReady?.();return}a.mapping=w.EquirectangularReflectionMapping;let o=new w.PMREMGenerator(n);o.compileEquirectangularShader();let i=o.fromEquirectangular(a).texture;o.dispose(),e.environment=i,e.environmentIntensity=t.environment.environmentIntensity??1,t.environment.showEnvironment?e.background=a:a.dispose(),t.events.onReady?.()},void 0,function(a){r()||(F().warn("HDR texture could not be loaded, falling back to basic lighting:",a),t.events.onReady?.())}):t.events.onReady?.()}function eo(e,n){let t=new w.AmbientLight(n.lighting.ambientLightColor,n.lighting.ambientLightIntensity);e.add(t);let r=null;if(n.lighting.enableHemisphereLight){r=new w.HemisphereLight(n.lighting.hemisphereSkyColor,n.lighting.hemisphereGroundColor,n.lighting.hemisphereIntensity);let i=n.environment.sceneUp??Te;r.position.copy(i),e.add(r)}if(!n.lighting.enableSunlight)return{ambient:t,hemisphere:r,sun:null};let a=new w.DirectionalLight(n.lighting.sunlightColor??16777215,n.lighting.sunlightIntensity),o=n.lighting.sunlightPosition;return o&&a.position.set(o.x,o.y,o.z),n.render.enableShadows?(a.castShadow=!0,a.shadow.mapSize.width=n.render.shadowMapSize||2048,a.shadow.mapSize.height=n.render.shadowMapSize||2048,a.shadow.bias=-1e-4,a.shadow.normalBias=.02,a.shadow.radius=4,e.add(a),e.add(a.target),{ambient:t,hemisphere:r,sun:a}):(e.add(a),{ambient:t,hemisphere:r,sun:null})}function to(e,n){let t=n.floor.size,r=new w.PlaneGeometry(t,t),a=typeof n.floor.color=="string"?new w.Color(n.floor.color):n.floor.color,o=new w.MeshStandardMaterial({color:a,roughness:n.floor.roughness,metalness:n.floor.metalness,side:w.DoubleSide}),i=new w.Mesh(r,o);i.userData.id="floor",i.name="floor";let l=(n.environment?.sceneUp||Te).clone().normalize();i.quaternion.setFromUnitVectors(new w.Vector3(0,0,1),l),i.position.set(0,0,0),n.floor.receiveShadow&&n.render.enableShadows&&(i.receiveShadow=!0),e.add(i)}function no(e,n){let t=n.parentElement,r=t?t.clientWidth:window.innerWidth,a=t?t.clientHeight:window.innerHeight,o=new w.PerspectiveCamera(e.camera.fov,r/a,e.camera.near,e.camera.far),i=e.camera.position;return i&&o.position.set(i.x,i.y,i.z),o}function ro(e,n,t){let r=new w.WebGLRenderer({antialias:n.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:n.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),a=e.parentElement,o=a?a.clientWidth:window.innerWidth,i=a?a.clientHeight:window.innerHeight;return a&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),r.setSize(o,i,!1),r.setPixelRatio(t),n.render.enableShadows&&(r.shadowMap.enabled=!0,r.shadowMap.type=w.VSMShadowMap),r.toneMapping=n.render.toneMapping,r.toneMappingExposure=n.render.toneMappingExposure??1,r.outputColorSpace=w.SRGBColorSpace,r.sortObjects=!0,r}function oo(e,n,t,r){let a=new Set,o=new Map,i=new w.Raycaster,l=new w.Vector2,s=new w.Vector2,c=()=>t.getActiveCamera(),u=p=>{let f=p;for(;f;){if(!f.visible)return!1;f=f.parent}return!0},d=()=>{let p=le(n);if(p.isEmpty()){F().warn("No objects to fit to view");return}t.frameBounds(p,!1)},E=typeof r.events.selectionColor=="string"?new w.Color(r.events.selectionColor):r.events.selectionColor instanceof w.Color?r.events.selectionColor:new w.Color("#ff0000"),T=()=>{a.forEach(p=>{let f=p;if(o.has(p)){let h=o.get(p),b=f.material;b instanceof w.Material?b.dispose():Array.isArray(b)&&b.forEach(H=>H.dispose()),f.material=h,o.delete(p);let C=p;for(;C.parent;)C=C.parent;C!==n&&(h instanceof w.Material?h.dispose():h.forEach(H=>H.dispose()))}}),a.clear()},v=p=>{let f=p;if(!(f.material instanceof w.Material))return!1;o.set(p,f.material);let h=f.material.clone();return p instanceof w.Mesh&&"emissive"in h?h.emissive=E.clone():"color"in h&&(h.color=E.clone()),f.material=h,!0},y=()=>{let p=le(n),f=p.isEmpty()?1:p.getSize(new w.Vector3).length();i.params.Points.threshold=f*.01},m=p=>{s.set(p.clientX,p.clientY)},g=p=>{let f=new w.Vector2(p.clientX,p.clientY);if(s.distanceTo(f)>5)return;let h=e.getBoundingClientRect();l.x=(p.clientX-h.left)/h.width*2-1,l.y=-((p.clientY-h.top)/h.height)*2+1,y(),i.setFromCamera(l,c());let b=i.intersectObjects(n.children,!0).filter(C=>u(C.object));if(b.length>0){let C=b[0].object;a.has(C)||(T(),a.add(C),v(C),r.events?.onObjectSelected?.(C),C instanceof w.Mesh&&Object.keys(C.userData).length>0&&r.events?.onMeshMetadataClicked?.(C.userData))}else T(),r.events?.onBackgroundClicked?.({x:l.x,y:l.y})},R=p=>{let f=e.getBoundingClientRect();l.x=(p.clientX-f.left)/f.width*2-1,l.y=-((p.clientY-f.top)/f.height)*2+1,y(),i.setFromCamera(l,c());let h=i.intersectObjects(n.children,!0).filter(H=>u(H.object));if(h.length===0)return;let b=h[0].object;if(r.events?.onMeshDoubleClicked?.(b),!r.events?.enableDoubleClickZoom)return;let C=new w.Box3().setFromObject(b);C.isEmpty()||t.frameBounds(C,!0)},x=p=>{if(r.events?.enableKeyboardControls)switch(p.key.toLowerCase()){case"f":p.preventDefault(),d();break;case"escape":p.preventDefault(),T();break;case" ":p.preventDefault(),d();break}};return r.events?.enableClickToFocus&&(e.addEventListener("mousedown",m),e.addEventListener("click",g),e.addEventListener("dblclick",R)),r.events?.enableKeyboardControls&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",x)),{dispose:()=>{e.removeEventListener("mousedown",m),e.removeEventListener("click",g),e.removeEventListener("dblclick",R),e.removeEventListener("keydown",x),T()},fitToView:d,clearSelection:T}}function ao(e,n,t){let r=new jr(e,n),a=t.camera.target;return a&&r.target.set(a.x,a.y,a.z),r.enableDamping=t.controls.enableDamping||!1,r.dampingFactor=t.controls.dampingFactor||.05,r.autoRotate=t.controls.autoRotate||!1,r.autoRotateSpeed=t.controls.autoRotateSpeed||.5,r.enableZoom=t.controls.enableZoom??!0,r.enablePan=t.controls.enablePan??!0,r.minDistance=t.controls.minDistance||.001,r.maxDistance=t.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}var hi=["technical","studio","showcase"];import*as te from"three";import{Line2 as io}from"three/addons/lines/Line2.js";import{LineGeometry as so}from"three/addons/lines/LineGeometry.js";import{LineMaterial as lo}from"three/addons/lines/LineMaterial.js";function Ve(e,n,t,r=!0){return{x:e,y:n,z:t}}var co="#ffffff",Zt=12,uo=4e-4,mo=12,fo=.05;function Jt(e,n={}){if(!e||e.length===0)return[];let{rhino:t,applyTransforms:r=!0}=n,a=[];for(let o of e)switch(o.kind){case"curve":{let i=Eo(o,t,r);i&&a.push(i);break}case"point":{let i=ho(o,r);i&&a.push(i);break}default:{let l=o;F().warn(`Skipping unknown display item kind: ${String(l.kind)}`);break}}return a}var po=2;function Eo(e,n,t){if(!n)return F().warn("No rhino3dm instance provided; skipping curve display item."),null;let r=go(e.json,n);if(!r)return null;let a;try{a=yo(r,t)}catch(d){return F().warn("Failed to tessellate curve display item; skipping.",d),null}finally{Me(r)}if(a.length<2)return null;let o=[];for(let d of a)o.push(d.x,d.y,d.z);let i=new so;i.setPositions(o);let l=Qt(e.color,e.opacity),s=new lo({color:l.color}),c=s;c.linewidth=e.width??po,c.transparent=l.transparent,c.opacity=l.opacity;let u=new io(i,s);return u.computeLineDistances(),u.name=e.name,u.userData={source:"compute",id:e.id,layer:e.layer,kind:"curve",metadata:e.metadata},u}function ho(e,n){let{position:t}=e;if(!t||typeof t.X!="number"||!Number.isFinite(t.X)||typeof t.Y!="number"||!Number.isFinite(t.Y)||typeof t.Z!="number"||!Number.isFinite(t.Z))return F().warn(`Skipping point display item with missing or non-finite position (id: ${String(e.id)}).`),null;let{x:r,y:a,z:o}=Ve(t.X,t.Y,t.Z,n),i=new te.BufferGeometry;i.setAttribute("position",new te.Float32BufferAttribute([r,a,o],3));let l=new te.PointsMaterial({...Qt(e.color,e.opacity),size:6,sizeAttenuation:!1}),s=new te.Points(i,l);return s.name=e.name,s.userData={source:"compute",id:e.id,layer:e.layer,kind:"point",metadata:e.metadata},s}function Me(e){e?.delete?.()}function go(e,n){try{let t=JSON.parse(e),r=n.CommonObject.decode(t);return r&&typeof r.pointAt=="function"?r:(Me(r),F().warn("Decoded display-item JSON is not a curve; skipping."),null)}catch(t){return F().warn("Failed to decode curve display item JSON:",t),null}}function yo(e,n){let t=bo(e,n);return t||To(e,n)}function bo(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 Me(r),null;let a=[];for(let o=0;o<r.count;o++){let i=r.get(o),{x:l,y:s,z:c}=Ve(i[0],i[1],i[2],n);a.push(new te.Vector3(l,s,c))}return Me(r),a}function To(e,n){let t=e.domain,r=t[0],o=t[1]-r,i=d=>{let E=e.pointAt(d),{x:T,y:v,z:y}=Ve(E[0],E[1],E[2],n);return new te.Vector3(T,v,y)},l=Ro(e),s=r,c=i(r),u=[c];for(let d=0;d<Zt;d++){let E=r+o*(d+1)/Zt,T=i(E);nt(s,c,E,T,i,l,mo,u),u.push(T),s=E,c=T}return u}function nt(e,n,t,r,a,o,i,l){if(i<=0)return;let s=(e+t)/2,c=a(s),u=vo(c,n,r),d=xo(n,c,r);u<=o&&d<=fo||(nt(e,n,s,c,a,o,i-1,l),l.push(c),nt(s,c,t,r,a,o,i-1,l))}function Ro(e){let n=e.getBoundingBox(),t=n.min,r=n.max;Me(n);let a=Math.hypot(r[0]-t[0],r[1]-t[1],r[2]-t[2]);return Math.max(a*uo,1e-6)}function xo(e,n,t){let r=n.x-e.x,a=n.y-e.y,o=n.z-e.z,i=t.x-n.x,l=t.y-n.y,s=t.z-n.z,c=Math.sqrt(r*r+a*a+o*o),u=Math.sqrt(i*i+l*l+s*s);if(c===0||u===0)return 0;let d=r*i+a*l+o*s,E=Math.max(-1,Math.min(1,d/(c*u)));return Math.acos(E)}function vo(e,n,t){let r=t.x-n.x,a=t.y-n.y,o=t.z-n.z,i=r*r+a*a+o*o;if(i===0)return e.distanceTo(n);let l=e.x-n.x,s=e.y-n.y,c=e.z-n.z,u=Math.max(0,Math.min(1,(l*r+s*a+c*o)/i)),d=l-r*u,E=s-a*u,T=c-o*u;return Math.sqrt(d*d+E*E+T*T)}function Qt(e,n){let t=n??1;return{color:new te.Color(e??co),transparent:t<1,opacity:t}}import{inflateSync as wo}from"fflate";var en=1096174675,Mo=1515605075,tn=3,nn=1,ot=1,Co=2,Ho=4,Ao=8,So=16,Ai=0,Do=1,rn=12,on=56,Lo=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;function at(e){let n=it(e),t;n.isFloat32?t=n.vertexData:n.deltaEncoded?t=Vo(n.vertexData):t=n.vertexData;let r=n.indexData;return n.deltaEncoded&&(r=r instanceof Uint16Array?zo(r):Go(r)),_o(r,n.vertexCount),{metadata:n.metadata,flags:n.flags,vertices:t,indices:r,origin:n.origin,scale:n.scale,uvs:n.uvs,colors:n.colors}}function it(e){if(!Lo)throw new be("SLVA parsing requires a little-endian host: the zero-copy geometry readers view the wire bytes in host byte order.",ye.ENVIRONMENT_ERROR);let n=Fo(Po(e)),t=new DataView(n.buffer,n.byteOffset,n.byteLength);if(n.byteLength<rn)throw X("Blob too small to contain SLVA header.",{expectedBytes:rn,availableBytes:n.byteLength});let r=0,a=t.getUint32(r,!0);if(r+=4,a!==en)throw X(`Invalid SLVA magic: 0x${a.toString(16)}`,{expectedMagic:`0x${en.toString(16)}`,actualMagic:`0x${a.toString(16)}`});let o=t.getUint32(r,!0);if(r+=4,o<nn||o>tn)throw X(`Unsupported SLVA version: ${o}`,{minSupportedVersion:nn,maxSupportedVersion:tn,actualVersion:o});let i=t.getUint32(r,!0);if(r+=4,r+i>n.byteLength)throw X("Insufficient data to read metadata JSON.",{expectedBytes:i,availableBytes:n.byteLength-r,offset:r});let l=n.subarray(r,r+i);r+=i;let s;try{s=JSON.parse(Bo(l))}catch(I){throw X(`Failed to parse metadata JSON: ${I instanceof Error?I.message:String(I)}`,{metadataLen:i})}if(r+on>n.byteLength)throw X("Insufficient data to read geometry header.",{expectedBytes:on,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 E=t.getFloat64(r,!0);r+=8;let T=t.getFloat64(r,!0);r+=8;let v=t.getFloat64(r,!0);r+=8;let y=t.getFloat64(r,!0);r+=8;let m=t.getUint32(r,!0);r+=4;let g=(c&ot)!==0,R=(c&Ho)!==0,x=m*3,p=x*(g?4:2);if(r+p>n.byteLength)throw X("Insufficient data to read vertices.",{expectedBytes:p,availableBytes:n.byteLength-r,offset:r,useFloat32:g,vertexCount:m});let f=n.byteOffset+r,h;if(g?h=sn(n.buffer,f,x):R?h=rt(n.buffer,f,x):h=ko(n.buffer,f,x),r+=p,r+4>n.byteLength)throw X("Insufficient data to read index count.",{expectedBytes:4,availableBytes:n.byteLength-r,offset:r});let b=t.getUint32(r,!0);r+=4;let C=(c&Co)!==0,L=b*(C?2:4);if(r+L>n.byteLength)throw X("Insufficient data to read indices.",{expectedBytes:L,availableBytes:n.byteLength-r,offset:r,indexCount:b,useUint16Indices:C});let P=C?rt(n.buffer,n.byteOffset+r,b):Uo(n.buffer,n.byteOffset+r,b);r+=L;let k=null;if((c&Ao)!==0){let I=Oo(n,t,r,m,R);k=I.uvs,r=I.offset}let O=null;return(c&So)!==0&&(O=Io(n,r,m,R)),{metadata:s,flags:c,vertexData:h,indexData:P,isFloat32:g,deltaEncoded:R,vertexCount:m,origin:[u,d,E],scale:[T,v,y],uvs:k,colors:O}}var an=36;function Oo(e,n,t,r,a){if(t+an>e.byteLength)throw X("Insufficient data to read UV chunk header.",{expectedBytes:an,availableBytes:e.byteLength-t,offset:t});let o=n.getUint32(t,!0);t+=4;let i=n.getFloat64(t,!0);t+=8;let l=n.getFloat64(t,!0);t+=8;let s=n.getFloat64(t,!0);t+=8;let c=n.getFloat64(t,!0);t+=8;let u=r*2,d=o===Do,E=u*(d?4:2);if(t+E>e.byteLength)throw X("Insufficient data to read UV chunk.",{expectedBytes:E,availableBytes:e.byteLength-t,offset:t,uvFormat:o,vertexCount:r});let T=e.byteOffset+t,v;if(d)v=sn(e.buffer,T,u).slice();else{let y=rt(e.buffer,T,u);v=new Float32Array(u);let m=0,g=0;for(let R=0;R<u;R+=2)a?(m=m+ie(y[R])&65535,g=g+ie(y[R+1])&65535):(m=y[R],g=y[R+1]),v[R]=i+m*s,v[R+1]=l+g*c}return{uvs:v,offset:t+E}}function Io(e,n,t,r){let a=t*3;if(n+a>e.byteLength)throw X("Insufficient data to read vertex-color chunk.",{expectedBytes:a,availableBytes:e.byteLength-n,offset:n,vertexCount:t});let o=e.subarray(n,n+a);if(!r)return o.slice();let i=new Uint8Array(a),l=0,s=0,c=0;for(let u=0;u<a;u+=3)l=l+ie(o[u])&255,s=s+ie(o[u+1])&255,c=c+ie(o[u+2])&255,i[u]=l,i[u+1]=s,i[u+2]=c;return i}function Po(e){return typeof e=="string"?ft(e):e instanceof Uint8Array?e:new Uint8Array(e)}function Fo(e){if(e.byteLength<8)return e;let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(n.getUint32(0,!0)!==Mo)return e;let t=n.getUint32(4,!0),r=e.subarray(8),a=Math.max(r.byteLength*1032+1024,1<<20);if(t>a)throw X("SLVZ header declares an implausible uncompressed length",{uncompressedLen:t,deflatedBytes:r.byteLength,maxPlausibleLen:a});let o;try{o=wo(r,{out:new Uint8Array(t+1)})}catch(i){throw X(`Failed to inflate SLVZ blob: ${i instanceof Error?i.message:String(i)}`,{uncompressedLen:t,deflatedBytes:r.byteLength})}if(o.byteLength!==t)throw X("SLVZ payload inflated to a different size than the header declares.",{declaredLen:t,actualLen:o.byteLength,deflatedBytes:r.byteLength});return o}function Bo(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 be("No UTF-8 decoder available in this environment.",ye.INVALID_STATE)}function ko(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 sn(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 rt(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 Uo(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 _o(e,n){if(e.length!==0&&!(e instanceof Uint16Array&&n>65535)){for(let t=0;t<e.length;t++)if(e[t]>=n)throw X("Index out of range of vertexCount.",{indexPosition:t,indexValue:e[t],vertexCount:n})}}function ie(e){return e>>>1^-(e&1)}function Vo(e){let n=new Int16Array(e.length),t=0,r=0,a=0;for(let o=0;o<e.length;o+=3)t=t+ie(e[o])<<16>>16,r=r+ie(e[o+1])<<16>>16,a=a+ie(e[o+2])<<16>>16,n[o]=t,n[o+1]=r,n[o+2]=a;return n}function zo(e){let n=new Uint16Array(e.length),t=0;for(let r=0;r<e.length;r++)t=t+ie(e[r])&65535,n[r]=t;return n}function Go(e){let n=new Uint32Array(e.length),t=0;for(let r=0;r<e.length;r++)t=t+ie(e[r])>>>0,n[r]=t;return n}function X(e,n){return new be(e,ye.VALIDATION_ERROR,{context:n})}import*as V from"three";var ln=256*1024*1024,ze=1024,ue=new Map,st=0;function cn(e,n){let t=2166136261,r=a=>{t^=a,t=Math.imul(t,16777619)};for(let a=0;a<n.length;a++)r(n.charCodeAt(a));for(let a of e){if(!a){r(57005);continue}let o=a.byteLength;if(r(o),(a.byteOffset&3)===0&&(o&3)===0){let i=new Uint32Array(a.buffer,a.byteOffset,o>>2),l=Math.min(ze,i.length);for(let s=0;s<l;s++)r(i[s]);for(let s=Math.max(l,i.length-ze);s<i.length;s++)r(i[s])}else{let i=new Uint8Array(a.buffer,a.byteOffset,o),l=Math.min(ze*4,i.length);for(let s=0;s<l;s++)r(i[s]);for(let s=Math.max(l,i.length-ze*4);s<i.length;s++)r(i[s])}}return`${(t>>>0).toString(36)}:${e.length}`}function No(e){let n=e.index?.array.byteLength??0;for(let t of Object.values(e.attributes))n+=t.array.byteLength;return n}function Ge(e){let n=ue.get(e);if(n)return ue.delete(e),ue.set(e,n),n.geometry}function Ne(e,n){let t=No(n);if(!(t>ln||(n.userData[Se]=!0,ue.get(e))))for(ue.set(e,{geometry:n,bytes:t}),st+=t;st>ln&&ue.size>1;){let a=ue.keys().next().value,o=ue.get(a);ue.delete(a),st-=o.bytes,delete o.geometry.userData[Se],o.geometry.dispose()}}function jo(e){let{isFloat32:n,deltaEncoded:t,origin:r,scale:a,uvs:o,colors:i,jobs:l}=e,s=m=>m>>>1^-(m&1),c;if(n)c=e.vertexData;else{let m;if(t){let h=e.vertexData;m=new Int16Array(h.length);let b=0,C=0,H=0;for(let L=0;L<h.length;L+=3)b=b+s(h[L])<<16>>16,C=C+s(h[L+1])<<16>>16,H=H+s(h[L+2])<<16>>16,m[L]=b,m[L+1]=C,m[L+2]=H}else m=e.vertexData;c=new Float32Array(m.length);let g=r[0],R=r[1],x=r[2],M=a[0],p=a[1],f=a[2];for(let h=0;h<m.length;h+=3)c[h]=g+(m[h]+32767)*M,c[h+1]=R+(m[h+1]+32767)*p,c[h+2]=x+(m[h+2]+32767)*f}let u;if(t){let m=e.indexData;if(m instanceof Uint16Array){let g=new Uint16Array(m.length),R=0;for(let x=0;x<m.length;x++)R=R+s(m[x])&65535,g[x]=R;u=g}else{let g=new Uint32Array(m.length),R=0;for(let x=0;x<m.length;x++)R=R+s(m[x])>>>0,g[x]=R;u=g}}else u=e.indexData;let d=c.length/3;for(let m=0;m<u.length;m++)if(u[m]>=d)throw new Error(`Index ${u[m]} out of range of vertexCount ${d}`);let E=1024,T=(m,g)=>{let R=2166136261,x=M=>{R^=M,R=Math.imul(R,16777619)};for(let M=0;M<g.length;M++)x(g.charCodeAt(M));for(let M of m){if(!M){x(57005);continue}let p=M.byteLength;if(x(p),(M.byteOffset&3)===0&&(p&3)===0){let f=new Uint32Array(M.buffer,M.byteOffset,p>>2),h=Math.min(E,f.length);for(let b=0;b<h;b++)x(f[b]);for(let b=Math.max(h,f.length-E);b<f.length;b++)x(f[b])}else{let f=new Uint8Array(M.buffer,M.byteOffset,p),h=Math.min(E*4,f.length);for(let b=0;b<h;b++)x(f[b]);for(let b=Math.max(h,f.length-E*4);b<f.length;b++)x(f[b])}}return`${(R>>>0).toString(36)}:${m.length}`},v=(m,g)=>{let R=[],x=m;for(let M of g){x+=`|${M.vertexStart},${M.vertexCount},${M.indexStart},${M.indexCount}`;let p=M.vertexStart*3,f=p+M.vertexCount*3;R.push(c.subarray(p,f)),R.push(u.subarray(M.indexStart,M.indexStart+M.indexCount)),R.push(o?o.subarray(M.vertexStart*2,(M.vertexStart+M.vertexCount)*2):null),R.push(i?i.subarray(p,f):null)}return T(R,x)},y=[];for(let m of l){let g=0,R=0;for(let H of m.windows)g+=H.vertexCount,R+=H.indexCount;let x=new Float32Array(g*3),M=new Uint32Array(R),p=o?new Float32Array(g*2):null,f=i?new Uint8Array(g*3):null,h=0,b=0;for(let H of m.windows){let L=H.vertexStart*3;x.set(c.subarray(L,L+H.vertexCount*3),h*3),p&&o&&p.set(o.subarray(H.vertexStart*2,(H.vertexStart+H.vertexCount)*2),h*2),f&&i&&f.set(i.subarray(L,L+H.vertexCount*3),h*3);let P=H.vertexStart,k=H.vertexStart+H.vertexCount,O=h-H.vertexStart;for(let I=0;I<H.indexCount;I++){let S=u[H.indexStart+I];if(S<P||S>=k)throw new Error(`Index ${S} outside vertex window [${P}, ${k})`);M[b+I]=S+O}h+=H.vertexCount,b+=H.indexCount}let C=new Float32Array(g*3);for(let H=0;H<M.length;H+=3){let L=M[H]*3,P=M[H+1]*3,k=M[H+2]*3,O=x[k]-x[P],I=x[k+1]-x[P+1],S=x[k+2]-x[P+2],D=x[L]-x[P],G=x[L+1]-x[P+1],j=x[L+2]-x[P+2],$=I*j-S*G,U=S*D-O*j,Q=O*G-I*D;C[L]+=$,C[L+1]+=U,C[L+2]+=Q,C[P]+=$,C[P+1]+=U,C[P+2]+=Q,C[k]+=$,C[k+1]+=U,C[k+2]+=Q}for(let H=0;H<C.length;H+=3){let L=C[H],P=C[H+1],k=C[H+2],O=Math.sqrt(L*L+P*P+k*k)||1;C[H]=L/O,C[H+1]=P/O,C[H+2]=k/O}y.push({key:v(m.kind,m.windows),positions:x,normals:C,indices:M,uvs:p,colors:f})}return y}function un(){return[`const assemble = ${jo.toString()};`,"self.onmessage = (event) => {"," const { id, input } = event.data;"," try {"," const geometries = assemble(input);"," const transfer = [];"," for (const g of geometries) {"," transfer.push(g.positions.buffer, g.normals.buffer, g.indices.buffer);"," if (g.uvs) transfer.push(g.uvs.buffer);"," if (g.colors) transfer.push(g.colors.buffer);"," }"," self.postMessage({ id, geometries }, transfer);"," } catch (error) {"," self.postMessage({ id, error: String((error && error.message) || error) });"," }","};"].join(`
|
|
112
|
-
`)}async function Vi(e,n){let{debug:t=!1}=n??{},r=t?performance.now():0,a,o=performance.now();try{a=JSON.parse(e)}catch(l){return F().error("Error parsing mesh batch envelope JSON:",l),[]}let i=performance.now()-o;return await lt(a,n,{parseTime:i,perfStart:r})}async function lt(e,n,t){let{mergeByMaterial:r=!0,applyTransforms:a=!0,debug:o=!1,material:i}=n??{},{parseTime:l=0,perfStart:s=o?performance.now():0}=t??{};if(!e.compressedData)return[];let c=await En(e.compressedData,{mergeByMaterial:r,applyTransforms:a,debug:o,material:i,fallback:{materials:e.materials,groups:e.groups,sourceComponentId:e.sourceComponentId}});if(c)return c;let u=performance.now(),d=at(e.compressedData),E=performance.now()-u,T=o?ra(e.compressedData):0;return dn(d,{mergeByMaterial:r,applyTransforms:a,debug:o,material:i,parseTime:l,decodeTime:E,perfStart:s,blobBytes:T,fallback:{materials:e.materials,groups:e.groups,sourceComponentId:e.sourceComponentId}})}async function zi(e,n){let{mergeByMaterial:t=!0,applyTransforms:r=!0,debug:a=!1,material:o}=n??{},i=a?performance.now():0,l=await En(e,{mergeByMaterial:t,applyTransforms:r,debug:a,material:o});if(l)return l;let s=performance.now(),c=at(e),u=performance.now()-s,d=e.byteLength;return dn(c,{mergeByMaterial:t,applyTransforms:r,debug:a,material:o,parseTime:0,decodeTime:u,perfStart:i,blobBytes:d})}function dn(e,n){let{mergeByMaterial:t,applyTransforms:r,debug:a,material:o,parseTime:i,decodeTime:l,perfStart:s,blobBytes:c,fallback:u}=n,d=e.metadata.materials??u?.materials??[],E=e.metadata.groups??u?.groups??[],T=u?.sourceComponentId??e.metadata.sourceComponentId,v=(e.flags&ot)!==0;mn(E,d.length,e.vertices.length/3,e.indices.length);let y=v?$o(e.vertices,r):Wo(e.vertices,e.origin,e.scale,r);if(a){let M=e.vertices.byteLength+e.indices.byteLength;F().debug("Mesh Batch Stats:"),F().debug(` Materials: ${d.length} | Groups: ${E.length}`),F().debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),F().debug(` Format: ${v?"float32":"int16 quantized"}`),F().debug(` Blob: ${(c/1024/1024).toFixed(2)} MB | Geometry on wire: ${(M/1024/1024).toFixed(2)} MB`)}let m=performance.now(),g=d.map(M=>hn(M,{vertexColors:e.colors!=null,appearance:o})),R=[];for(let M of E)if(t&&M.meshes.length>1){let p=ta(M,y,e.indices,g,e.uvs,e.colors);p.userData.sourceComponentId=T??null,R.push(p)}else{let p=na(M,y,e.indices,g,e.uvs,e.colors);for(let f of p)f.userData.sourceComponentId=T??null;R.push(...p)}let x=performance.now()-m;if(a){let M=performance.now()-s;F().debug("Performance:"),i>0&&F().debug(` Parse JSON: ${i.toFixed(2)}ms`),F().debug(` Decode binary: ${l.toFixed(2)}ms`),F().debug(` Create Meshes: ${x.toFixed(2)}ms`),F().debug(` Total: ${M.toFixed(2)}ms`)}return Promise.resolve(R)}function Ce(e,n){return new be(e,ye.VALIDATION_ERROR,{context:n})}function mn(e,n,t,r){for(let a of e){if(!Number.isInteger(a.materialId)||a.materialId<0||a.materialId>=n)throw Ce("Group materialId out of range of the materials array.",{materialId:a.materialId,materialCount:n});for(let o of a.meshes){let i={vertexStart:o.vertexStart,vertexCount:o.vertexCount,indexStart:o.indexStart,indexCount:o.indexCount};for(let[l,s]of Object.entries(i))if(!Number.isInteger(s)||s<0)throw Ce(`Mesh metadata field "${l}" must be a non-negative integer.`,{meshName:o.name,field:l,value:s});if(o.vertexStart+o.vertexCount>t)throw Ce("Mesh vertex window exceeds the batch vertex buffer.",{meshName:o.name,vertexStart:o.vertexStart,vertexCount:o.vertexCount,totalVertexCount:t});if(o.indexStart+o.indexCount>r)throw Ce("Mesh index window exceeds the batch index buffer.",{meshName:o.name,indexStart:o.indexStart,indexCount:o.indexCount,totalIndexCount:r})}}}function fn(e,n){return Ce("Index references a vertex outside its mesh's vertex window.",{meshName:n.name,indexValue:e,vertexStart:n.vertexStart,vertexCount:n.vertexCount})}function pn(e,n,t,r,a,o){let i=[],l=e;for(let s of n){l+=`|${s.vertexStart},${s.vertexCount},${s.indexStart},${s.indexCount}`;let c=s.vertexStart*3,u=c+s.vertexCount*3;i.push(t.subarray(c,u)),i.push(r.subarray(s.indexStart,s.indexStart+s.indexCount)),i.push(a?a.subarray(s.vertexStart*2,(s.vertexStart+s.vertexCount)*2):null),i.push(o?o.subarray(c,u):null)}return cn(i,l)}function Wo(e,n,t,r){let a=new Float32Array(e.length),o=n[0],i=n[1],l=n[2],s=t[0],c=t[1],u=t[2];for(let d=0;d<e.length;d+=3)a[d]=o+(e[d]+32767)*s,a[d+1]=i+(e[d+1]+32767)*c,a[d+2]=l+(e[d+2]+32767)*u;return a}function $o(e,n){return e}var qo=5e4,he,He=new Map,Yo=1;function Xo(){if(he!==void 0)return he;if(typeof Worker>"u"||typeof Blob>"u"||typeof URL>"u"||typeof URL.createObjectURL!="function")return he=null,null;try{let e=URL.createObjectURL(new Blob([un()],{type:"text/javascript"})),n=new Worker(e);n.onmessage=t=>{let{id:r,geometries:a,error:o}=t.data,i=He.get(r);i&&(He.delete(r),a?i.resolve(a):i.reject(new Error(o??"mesh assembly failed in worker")))},n.onerror=()=>{for(let t of He.values())t.reject(new Error("mesh assembly worker crashed"));He.clear(),n.terminate(),he=null},he=n}catch{he=null}return he}function Ko(e,n,t){return new Promise((r,a)=>{let o=Yo++;He.set(o,{resolve:r,reject:a}),e.postMessage({id:o,input:n},t)})}async function En(e,n){if(typeof Worker>"u")return null;let t=it(e);if(t.indexData.length/3<qo)return null;let r=Xo();if(!r)return null;let a=t.metadata.materials??n.fallback?.materials??[],o=t.metadata.groups??n.fallback?.groups??[],i=n.fallback?.sourceComponentId??t.metadata.sourceComponentId;mn(o,a.length,t.vertexCount,t.indexData.length);let l=m=>({vertexStart:m.vertexStart,vertexCount:m.vertexCount,indexStart:m.indexStart,indexCount:m.indexCount}),s=[],c=[];for(let m of o)if(n.mergeByMaterial&&m.meshes.length>1)s.push({kind:"merged",windows:m.meshes.map(l)}),c.push({kind:"merged",group:m});else for(let g of m.meshes)s.push({kind:"single",windows:[l(g)]}),c.push({kind:"single",group:m,meshMeta:g});let u=t.vertexData.slice(),d=t.indexData.slice(),E=[u.buffer,d.buffer];t.uvs&&E.push(t.uvs.buffer),t.colors&&E.push(t.colors.buffer);let T;try{T=await Ko(r,{vertexData:u,isFloat32:t.isFloat32,deltaEncoded:t.deltaEncoded,origin:t.origin,scale:t.scale,indexData:d,uvs:t.uvs,colors:t.colors,jobs:s},E)}catch(m){return F().warn("Mesh assembly worker failed; falling back to main-thread parse.",m),null}if(T.length!==s.length)return null;let v=a.map(m=>hn(m,{vertexColors:t.colors!=null,appearance:n.material})),y=[];for(let m=0;m<T.length;m++){let g=T[m],R=c[m],x=Ge(g.key);x||(x=new V.BufferGeometry,x.setAttribute("position",new V.BufferAttribute(g.positions,3)),x.setAttribute("normal",new V.BufferAttribute(g.normals,3)),x.setIndex(new V.BufferAttribute(g.indices,1)),g.uvs&&x.setAttribute("uv",new V.BufferAttribute(g.uvs,2)),g.colors&&x.setAttribute("color",new V.BufferAttribute(g.colors,3,!0)),Ne(g.key,x));let M=R.kind==="merged"?gn(x,R.group,v):yn(x,R.meshMeta,R.group,v);M.userData.sourceComponentId=i??null,y.push(M)}return n.debug&&F().debug(`Mesh batch assembled off-thread: ${y.length} meshes, ${t.indexData.length/3} triangles`),y}var Zo=.5,Jo=.5,Qo=.3;function hn(e,n){let t=Rt(e.color),r=n?.vertexColors??!1,a=n?.appearance,o=new V.MeshPhysicalMaterial({color:t,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,vertexColors:r,side:a?.cullBackfaces?V.FrontSide:V.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0});return a?.envMapIntensity!=null&&(o.envMapIntensity=a.envMapIntensity),e.metalness>Zo&&(o.clearcoat=Jo,o.clearcoatRoughness=Qo),r&&ea(o),e.map&&Xt(o,e.map),o}function ea(e){e.onBeforeCompile=n=>{n.vertexShader=n.vertexShader.replace("#include <color_vertex>",`#include <color_vertex>
|
|
113
|
-
#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
114
|
-
vColor.rgb = mix(
|
|
115
|
-
vColor.rgb / 12.92,
|
|
116
|
-
pow( ( vColor.rgb + 0.055 ) / 1.055, vec3( 2.4 ) ),
|
|
117
|
-
step( vec3( 0.04045 ), vColor.rgb )
|
|
118
|
-
);
|
|
119
|
-
#endif`)}}function ta(e,n,t,r,a=null,o=null){let i=pn("merged",e.meshes,n,t,a,o),l=Ge(i);if(!l){let s=0,c=0;for(let m of e.meshes)s+=m.vertexCount,c+=m.indexCount;let u=new Float32Array(s*3),d=new Uint32Array(c),E=a?new Float32Array(s*2):null,T=o?new Uint8Array(s*3):null,v=0,y=0;for(let m of e.meshes){let g=m.vertexStart*3,R=m.vertexCount*3;if(u.set(n.subarray(g,g+R),v*3),E&&a){let h=m.vertexStart*2;E.set(a.subarray(h,h+m.vertexCount*2),v*2)}T&&o&&T.set(o.subarray(g,g+R),v*3);let x=t.subarray(m.indexStart,m.indexStart+m.indexCount),M=v-m.vertexStart,p=m.vertexStart,f=m.vertexStart+m.vertexCount;for(let h=0;h<x.length;h++){let b=x[h];if(b<p||b>=f)throw fn(b,m);d[y+h]=b+M}v+=m.vertexCount,y+=m.indexCount}l=new V.BufferGeometry,l.setAttribute("position",new V.BufferAttribute(u,3)),l.setIndex(new V.BufferAttribute(d,1)),E&&l.setAttribute("uv",new V.BufferAttribute(E,2)),T&&l.setAttribute("color",new V.BufferAttribute(T,3,!0)),l.computeVertexNormals(),Ne(i,l)}return gn(l,e,r)}function gn(e,n,t){let r=new V.Mesh(e,t[n.materialId]),a=n.meshes[0],o=n.meshes.map(i=>i.name).filter(i=>i&&i.length>0);return r.name=o.length>0?o[0]:`merged_material_${n.materialId}`,r.castShadow=!0,r.receiveShadow=!0,r.userData={source:"compute",name:r.name,layer:a?.layer??"",originalIndex:a?.originalIndex??0,metadata:a?.metadata??{},mergedFrom:n.meshes.slice(1).map(i=>({name:i.name,layer:i.layer,originalIndex:i.originalIndex}))},r}function na(e,n,t,r,a=null,o=null){let i=[];for(let l of e.meshes){let s=l.vertexStart*3,c=l.vertexCount*3,u=pn("single",[l],n,t,a,o),d=Ge(u);if(!d){let E=n.slice(s,s+c),T=t.subarray(l.indexStart,l.indexStart+l.indexCount),v=new Uint32Array(T.length),y=l.vertexStart,m=l.vertexStart+l.vertexCount;for(let g=0;g<T.length;g++){let R=T[g];if(R<y||R>=m)throw fn(R,l);v[g]=R-y}if(d=new V.BufferGeometry,d.setAttribute("position",new V.BufferAttribute(E,3)),d.setIndex(new V.BufferAttribute(v,1)),a){let g=l.vertexStart*2,R=a.slice(g,g+l.vertexCount*2);d.setAttribute("uv",new V.BufferAttribute(R,2))}if(o){let g=o.slice(s,s+c);d.setAttribute("color",new V.BufferAttribute(g,3,!0))}d.computeVertexNormals(),Ne(u,d)}i.push(yn(d,l,e,r))}return i}function yn(e,n,t,r){let a=new V.Mesh(e,r[t.materialId]);return a.name=n.name,a.userData={source:"compute",name:n.name,layer:n.layer??"",originalIndex:n.originalIndex,metadata:n.metadata??{}},a.castShadow=!0,a.receiveShadow=!0,a}function ra(e){return Math.floor(e.length*3/4)}var bn={Angstroms:1e-10,Nanometers:1e-9,Microns:1e-6,Millimeters:.001,Centimeters:.01,Decimeters:.1,Meters:1,Dekameters:10,Hectometers:100,Kilometers:1e3,Megameters:1e6,Gigameters:1e9,Microinches:254e-10,Mils:254e-7,Inches:.0254,Feet:.3048,Yards:.9144,Miles:1609.344,NauticalMiles:1852},oa="Display",aa="DisplayBatch";function ia(e){let n=e.split(".");return n.includes(oa)||n.includes(aa)}var Tn=new Set;async function qi(e,n){let t=performance.now(),r=[],{allowScaling:a=!0,allowAutoPosition:o=!0,rhino:i,debug:l=!1,parsing:s={}}=n??{};try{let c=a?sa(e.modelunits):1;return await la(e,r,c,s,i,l),o&&ma(r),r}catch(c){throw fa(c,r),c}finally{l&&Ea(t)}}function sa(e){let n=bn[e];return n!==void 0?n:(Tn.has(e)||(Tn.add(e),F().warn(`Unknown Rhino model unit "${e}" \u2014 geometry will not be scaled (factor 1). Known units: ${Object.keys(bn).join(", ")}.`)),1)}async function la(e,n,t,r,a,o){for(let i of e.values){let l=i.InnerTree;for(let s in l){let c=l[s];c&&await ca(c,n,t,r,a,o)}}}async function ca(e,n,t,r,a,o){for(let i of e){if(!ia(i.type))continue;let l={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...r},s=ua(i.data);if(!s){F().error("Error parsing display batch envelope: invalid JSON");continue}let c=await lt(s,l),u=Jt(s.items,{rhino:a,applyTransforms:l.applyTransforms}),d=[...c,...u];if(t!==1)for(let E of d)E.scale.set(t,t,t);n.push(...d),o&&F().debug(`Extracted ${c.length} meshes and ${u.length} items from batch`)}}function ua(e){return typeof e=="string"?da(e):e}function da(e){try{return JSON.parse(e)}catch{return}}function ma(e){if(e.length===0)return;let n=$e(e);xt(e,n.min.z,"z")}function fa(e,n){F().error("An unexpected error occurred:",e),pa(n)}function pa(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 Ea(e){let n=performance.now()-e;F().info("Time to process meshes:",`${n.toFixed(2)}ms`)}export{Ln as a,ba as b,Rt as c,xt as d,$e as e,vt as f,wt as g,Mt as h,xe as i,Qe as j,Er as k,La as l,Vt as m,zt as n,Pe as o,Gt as p,jt as q,Pr as r,qt as s,Fr as t,Yt as u,Za as v,qr as w,pi as x,hi as y,Jt as z,en as A,Mo as B,tn as C,nn as D,ot as E,Co as F,Ho as G,Ao as H,So as I,Ai as J,Do as K,at as L,Vi as M,lt as N,zi as O,bn as P,qi as Q};
|
|
120
|
-
//# sourceMappingURL=chunk-NVMSD4CC.js.map
|