@selvajs/compute 3.1.0-beta.1 → 3.1.0-beta.2

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.
@@ -1,55 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkDRG5SLIPcjs = require('./chunk-DRG5SLIP.cjs');var _three = require('three'); var _ = _interopRequireWildcard(_three); var k = _interopRequireWildcard(_three); var B = _interopRequireWildcard(_three); var G = _interopRequireWildcard(_three); var J = _interopRequireWildcard(_three); var we = _interopRequireWildcard(_three); var S = _interopRequireWildcard(_three); var E = _interopRequireWildcard(_three); var L = _interopRequireWildcard(_three); var N = _interopRequireWildcard(_three); var ae = _interopRequireWildcard(_three); var V = _interopRequireWildcard(_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 Xr(e,n,t,r,o){if(Ge(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 pe(e){if(!e||typeof e!="string")return _chunkDRG5SLIPcjs.e.call(void 0, ).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 (e2){return _chunkDRG5SLIPcjs.e.call(void 0, ).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 (e3){return _chunkDRG5SLIPcjs.e.call(void 0, ).warn(`Invalid color string: ${e}, using white`),new _.Color(16777215)}}function Ee(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 je=new Set(["floor","grid","label-layer"]);function Ge(e){[...e.children].forEach(t=>{je.has(t.userData.id)||t.userData.source!=="user"&&(t.traverse(r=>{let o=r;if(!o.geometry&&!o.material)return;_optionalChain([o, 'access', _2 => _2.geometry, 'optionalAccess', _3 => _3.dispose, 'call', _4 => _4()]);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())})}function Ne(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 he(e){let{scene:n,perspective:t,controls:r,onActiveCameraChange:o}=e,a=(_nullishCoalesce(e.up, () => (t.up))).clone().normalize(),i=Ne(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 p=t.position.distanceTo(r.target)*Math.tan(t.fov*Math.PI/360),T=p*c;s.left=-T,s.right=T,s.top=p,s.bottom=-p,s.near=t.near,s.far=t.far,s.updateProjectionMatrix()},m=g=>{g!==l&&(g==="orthographic"?(s.position.copy(t.position),s.up.copy(t.up),s.lookAt(r.target),d()):t.position.copy(s.position),l=g,r.object=u(),r.update(),o(u()))},f=(g,p=!0)=>{let T=Ye(n),v=T.isEmpty()?r.target.clone():T.getCenter(new k.Vector3),O=T.isEmpty()?new k.Vector3(1,1,1):T.getSize(new k.Vector3),w=Math.max(O.x,O.y,O.z)||1,R=t.fov*(Math.PI/180),A=w/(2*Math.tan(R/2))*1.5,P=Xe(g,a),D=v.clone().add(P.clone().multiplyScalar(A)),F=u();p?Ze(F,r,D,v,()=>{l==="orthographic"&&d()}):(F.position.copy(D),r.target.copy(v),l==="orthographic"&&d(),r.update())};return{getActiveCamera:u,getProjection:()=>l,setProjection:m,toggleProjection:()=>(m(l==="perspective"?"orthographic":"perspective"),l),setView:(g,p=!0)=>{f(i[g],p)},setViewDirection:f,setRotateEnabled:g=>{r.enableRotate=g},isRotateEnabled:()=>r.enableRotate,updateAspect:(g,p)=>{c=p===0?c:g/p,l==="orthographic"&&d()}}}var We=new Set(["grid","floor","label-layer","measure"]);function $e(e){let n=e;for(;n;){if(typeof n.userData.id=="string"&&We.has(n.userData.id))return!0;n=n.parent}return!1}function Ye(e){let n=[];return e.traverse(t=>{let r=t;t.visible&&!$e(t)&&r.geometry&&n.push(t)}),K(n)}function Xe(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 qe=e=>1-Math.pow(1-e,3);function Ze(e,n,t,r,o,a=250){let i=e.position.clone(),s=n.target.clone(),l=performance.now(),c=()=>{let u=qe(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)}var Je=`
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
- `,Ke=`
9
- precision highp float;
10
- varying vec3 vWorldPos;
11
-
12
- uniform vec2 uAxes; // indices (0=x,1=y,2=z) of the two in-plane world axes
13
- uniform float uCell;
14
- uniform float uMajor;
15
- uniform vec3 uCellColor;
16
- uniform vec3 uMajorColor;
17
- uniform vec3 uCenter; // fade center (camera position), projected onto plane
18
- uniform float uFade;
19
-
20
- // Antialiased grid line intensity for a given spacing, using screen-space derivatives so lines
21
- // stay ~1px regardless of zoom (the standard "pristine grid" technique).
22
- float gridLine(vec2 coord, float spacing) {
23
- vec2 c = coord / spacing;
24
- vec2 d = fwidth(c);
25
- vec2 g = abs(fract(c - 0.5) - 0.5) / max(d, 1e-6);
26
- float line = min(g.x, g.y);
27
- return 1.0 - clamp(line, 0.0, 1.0);
28
- }
29
-
30
- // Index a vec3 by a float axis id (0/1/2) without dynamic indexing (WebGL1-safe).
31
- float axis(vec3 v, float i) {
32
- return i < 0.5 ? v.x : (i < 1.5 ? v.y : v.z);
33
- }
34
-
35
- void main() {
36
- // Pick the two in-plane world coordinates.
37
- vec2 coord = vec2(axis(vWorldPos, uAxes.x), axis(vWorldPos, uAxes.y));
38
-
39
- float minor = gridLine(coord, uCell);
40
- float major = gridLine(coord, uCell * uMajor);
41
-
42
- vec3 color = mix(uCellColor, uMajorColor, major);
43
- float alpha = max(minor, major);
44
-
45
- // Radial fade from the camera-projected center.
46
- float dist = distance(vWorldPos, uCenter);
47
- float fade = 1.0 - clamp(dist / uFade, 0.0, 1.0);
48
- alpha *= fade * fade;
49
-
50
- if (alpha < 0.001) discard;
51
- gl_FragColor = vec4(color, alpha);
52
- }
53
- `;function ge(e={}){let{cellSize:n=1,majorEvery:t=10,cellColor:r=8947848,majorColor:o=4473924,fadeDistance:a=100,plane:i="y"}=e,s=i==="y"?new B.Vector2(0,2):i==="z"?new B.Vector2(0,1):new B.Vector2(1,2),l=a*2.5,c=new B.PlaneGeometry(l,l);i==="y"?c.rotateX(-Math.PI/2):i==="x"&&c.rotateY(Math.PI/2);let u=new B.ShaderMaterial({vertexShader:Je,fragmentShader:Ke,transparent:!0,depthWrite:!1,side:B.DoubleSide,uniforms:{uAxes:{value:s},uCell:{value:n},uMajor:{value:t},uCellColor:{value:new B.Color(r)},uMajorColor:{value:new B.Color(o)},uCenter:{value:new B.Vector3},uFade:{value:a}}}),d=new B.Mesh(c,u);d.name="grid",d.userData.id="grid",d.renderOrder=-1;let m=new B.Vector3;return{object:d,update:f=>{i==="y"?(d.position.set(f.x,0,f.z),m.set(f.x,0,f.z)):i==="z"?(d.position.set(f.x,f.y,0),m.set(f.x,f.y,0)):(d.position.set(0,f.y,f.z),m.set(0,f.y,f.z)),u.uniforms.uCenter.value.copy(m)},setVisible:f=>{d.visible=f},dispose:()=>{c.dispose(),u.dispose()}}}var _ViewHelperjs = require('three/addons/helpers/ViewHelper.js');function ye(e){let{camera:n,domElement:t,controller:r}=e,o=new (0, _ViewHelperjs.ViewHelper)(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 f=t.getBoundingClientRect(),b=f.left+t.offsetWidth-i-o.location.right,H=f.top+t.offsetHeight-i-o.location.bottom,h=new G.Vector2((m.clientX-b)/i*2-1,-((m.clientY-H)/i)*2+1);if(Math.abs(h.x)>1||Math.abs(h.y)>1)return null;o.quaternion.copy(n.quaternion).invert(),o.updateMatrixWorld(),s.setFromCamera(h,l);let g=s.intersectObjects(o.children,!1);for(let p of g){let T=_optionalChain([p, 'access', _5 => _5.object, 'access', _6 => _6.userData, 'optionalAccess', _7 => _7.type]);if(typeof T=="string"&&T in c)return T}return null};return{render:m=>{if(!a)return;let f=m.autoClear;m.autoClear=!1,o.render(m),m.autoClear=f},update:m=>{o.animating&&o.update(m)},handleClick:m=>{if(!a)return!1;let f=u(m);return f?(r.getProjection()==="orthographic"&&r.setProjection("perspective"),r.setViewDirection(c[f],!1),!0):!1},get isAnimating(){return o.animating},setVisible:m=>{a=m},isVisible:()=>a,dispose:()=>o.dispose()}}var _LineSegmentsGeometryjs = require('three/addons/lines/LineSegmentsGeometry.js');var _LineSegments2js = require('three/addons/lines/LineSegments2.js');var _LineMaterialjs = require('three/addons/lines/LineMaterial.js');var te="edge-overlay",rt=2236962,nt=1.5,ot=30;function Te(e,n={}){let t=new J.Color(_nullishCoalesce(n.color, () => (rt))),r=_nullishCoalesce(n.width, () => (nt)),o=_nullishCoalesce(n.thresholdAngle, () => (ot)),a=[];return e.traverse(i=>{if(!(i instanceof J.Mesh)||i.userData.id==="floor"||i.userData.id==="grid"||i.userData.kind===te||i.children.some(l=>_optionalChain([l, 'access', _8 => _8.userData, 'optionalAccess', _9 => _9.kind])===te)||!i.geometry)return;let s=at(i.geometry,t,r,o);i.add(s),a.push(s)}),a}function at(e,n,t,r){let o=new J.EdgesGeometry(e,r),a=new _LineSegmentsGeometryjs.LineSegmentsGeometry;a.setPositions(Array.from(o.attributes.position.array)),o.dispose();let i=new (0, _LineMaterialjs.LineMaterial)({color:n});i.linewidth=t,i.polygonOffset=!0,i.polygonOffsetFactor=-1,i.polygonOffsetUnits=-1;let s=new (0, _LineSegments2js.LineSegments2)(a,i);return s.userData.kind=te,s.raycast=()=>{},s}function it(e){return _optionalChain([e, 'access', _10 => _10.userData, 'optionalAccess', _11 => _11.kind])===te}function on(e){let n=[];e.traverse(t=>{t instanceof _LineSegments2js.LineSegments2&&it(t)&&n.push(t)});for(let t of n)t.geometry.dispose(),t.material.dispose(),t.removeFromParent();return n.length}var _EffectComposerjs = require('three/addons/postprocessing/EffectComposer.js');var _RenderPassjs = require('three/addons/postprocessing/RenderPass.js');var _GTAOPassjs = require('three/addons/postprocessing/GTAOPass.js');var _OutputPassjs = require('three/addons/postprocessing/OutputPass.js');function Re(e,n,t,r,o,a){let i=new (0, _EffectComposerjs.EffectComposer)(e),s=new (0, _RenderPassjs.RenderPass)(n,t);i.addPass(s);let l=new (0, _GTAOPassjs.GTAOPass)(n,t,r,o);l.blendIntensity=_nullishCoalesce(a.aoIntensity, () => (1)),l.updateGtaoMaterial({screenSpaceRadius:!0}),i.addPass(l);let c=new _OutputPassjs.OutputPass;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()}}}var _CSS2DRendererjs = require('three/addons/renderers/CSS2DRenderer.js');function He(e,n){let t=new _CSS2DRendererjs.CSS2DRenderer,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 we.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 (0, _CSS2DRendererjs.CSS2DObject)(d);return m.position.copy(c),a.add(m),i.add(m),{object:m,setPosition:f=>m.position.copy(f),setText:f=>{d.textContent=f},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()}}}var _Line2js = require('three/addons/lines/Line2.js');var _LineGeometryjs = require('three/addons/lines/LineGeometry.js');var ht=12,gt=16763904,yt=.015,ve={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 bt(e){let n=e&&ve[e]||ve.Meters;return t=>`${(t/n.metersPerUnit).toPrecision(3)} ${n.suffix}`}function Tt(e){let n=e.object;return n instanceof S.Mesh?e.face?[e.face.a,e.face.b,e.face.c]:null:n instanceof S.Points?e.index!=null?[e.index]:null:n instanceof S.Line&&e.index!=null?[e.index,e.index+1]:null}function Rt(e,n,t,r){let o=e.point.clone(),a=e.object,i=Tt(e);if(!i||!a.geometry)return o;let s=a.geometry.attributes.position;if(!s)return o;let l=m=>{let f=m.clone().project(n);return new S.Vector2((f.x+1)/2*t.width,(1-f.y)/2*t.height)},c=l(o),u=o,d=r;for(let m of i){if(m>=s.count)continue;let b=new S.Vector3().fromBufferAttribute(s,m).applyMatrix4(a.matrixWorld),H=l(b).distanceTo(c);H<d&&(d=H,u=b)}return u}function xe(e){let{canvas:n,scene:t,getActiveCamera:r,labelLayer:o,options:a={}}=e,i=_nullishCoalesce(a.snapPixels, () => (ht)),s=new S.Color(_nullishCoalesce(a.color, () => (gt))),l=bt(a.displayUnit),c=(y,x)=>`${l(y)}
54
- \u0394x ${l(x.x)} \u0394y ${l(x.y)} \u0394z ${l(x.z)}`,u=_nullishCoalesce(a.format, () => (c)),d=new S.Raycaster,m=new S.Vector2,f=!1,b=[],H=[],h=null,g=null,p=new S.PointsMaterial({color:s,size:8,sizeAttenuation:!1,depthTest:!1}),T=new S.PointsMaterial({color:s,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),v=null,O=y=>{if(!y){v&&(v.visible=!1);return}if(!v){let x=new S.BufferGeometry;x.setAttribute("position",new S.Float32BufferAttribute([0,0,0],3)),v=new S.Points(x,T),v.renderOrder=1e3,v.userData.id="measure",v.raycast=()=>{},t.add(v)}v.position.copy(y),v.visible=!0},w=y=>{let x=new S.BufferGeometry;x.setAttribute("position",new S.Float32BufferAttribute([y.x,y.y,y.z],3));let I=new S.Points(x,p);return I.renderOrder=999,I.userData.id="measure",I.raycast=()=>{},t.add(I),I},R=()=>{b.length=0,H.forEach(y=>{y.geometry.dispose(),y.removeFromParent()}),H.length=0,h&&(h.geometry.dispose(),h.material.dispose(),h.removeFromParent(),h=null),_optionalChain([g, 'optionalAccess', _12 => _12.remove, 'call', _13 => _13()]),g=null},A=()=>{if(b.length!==2)return;let[y,x]=b,I=new _LineGeometryjs.LineGeometry;I.setPositions([y.x,y.y,y.z,x.x,x.y,x.z]);let z=new (0, _LineMaterialjs.LineMaterial)({color:s});z.linewidth=2,z.depthTest=!1,h=new (0, _Line2js.Line2)(I,z),h.renderOrder=998,h.userData.id="measure",h.raycast=()=>{},t.add(h);let q=y.clone().add(x).multiplyScalar(.5),X=new S.Vector3(Math.abs(x.x-y.x),Math.abs(x.y-y.y),Math.abs(x.z-y.z));g=o.addLabel(u(y.distanceTo(x),X),q,a.labelClassName)},P=y=>{let x=n.getBoundingClientRect();m.x=(y.clientX-x.left)/x.width*2-1,m.y=-((y.clientY-x.top)/x.height)*2+1;let I=r();d.setFromCamera(m,I);let q=I.position.length()*yt;d.params.Line.threshold=q,d.params.Points.threshold=q;let X=d.intersectObjects(t.children,!0).filter(Z=>Z.object.userData.id!=="measure"&&Z.object.userData.id!=="grid");return X.length===0?null:Rt(X[0],I,{width:x.width,height:x.height},i)};return{setEnabled:y=>{f=y,y||(R(),O(null))},isEnabled:()=>f,handleClick:y=>{if(!f)return!1;b.length===2&&R();let x=P(y);return x===null||(b.push(x),H.push(w(x)),b.length===2&&A()),!0},handleMove:y=>{f&&O(P(y))},clear:R,dispose:()=>{R(),v&&(v.geometry.dispose(),v.removeFromParent(),v=null),p.dispose(),T.dispose()}}}var _OrbitControlsjs = require('three/addons/controls/OrbitControls.js');var _HDRLoaderjs = require('three/addons/loaders/HDRLoader.js');var re=new E.Vector3(0,0,1);function vt(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 An=function(e,n){let t=xt(n||{}),r=_optionalChain([t, 'access', _14 => _14.environment, 'optionalAccess', _15 => _15.sceneUp])||re,o=St(t),a=Vt(t,e);a.up.copy(r);let i=Bt(e,t),s=Ut(a,e,t),l=he({scene:o,perspective:a,controls:s,onActiveCameraChange:()=>{},up:r}),c=()=>l.getActiveCamera();Pt(o,t);let u=Ot(o,t),d=()=>{u&&At(u,le(o))};_optionalChain([t, 'access', _16 => _16.floor, 'optionalAccess', _17 => _17.enabled])&&It(o,t);let m=t.grid.enabled?ge({cellSize:t.grid.cellSize,majorEvery:t.grid.majorEvery,cellColor:t.grid.cellColor,majorColor:t.grid.majorColor,fadeDistance:t.grid.fadeDistance,plane:t.grid.plane}):null;m&&o.add(m.object);let f=t.gizmo.enabled?ye({camera:a,domElement:e,controller:l}):null,b=_nullishCoalesce(e.parentElement, () => (e)),H=t.measure.enabled?He(b,o):null,h=t.measure.enabled&&H?xe({canvas:e,scene:o,getActiveCamera:c,labelLayer:H,options:{snapPixels:t.measure.snapPixels,color:t.measure.color,labelClassName:t.measure.labelClassName,displayUnit:t.measure.displayUnit,format:t.measure.format}}):null,g=t.events.enableEventHandlers!==!1?Ft(e,o,c,a,s,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},p=5,T=0,v=0,O=C=>{T=C.clientX,v=C.clientY},w=C=>Math.hypot(C.clientX-T,C.clientY-v)>p,R=C=>{if(!w(C)){if(_optionalChain([h, 'optionalAccess', _18 => _18.handleClick, 'call', _19 => _19(C)])){C.stopImmediatePropagation();return}_optionalChain([f, 'optionalAccess', _20 => _20.handleClick, 'call', _21 => _21(C)])&&C.stopImmediatePropagation()}};(f||h)&&(e.addEventListener("mousedown",O,{capture:!0}),e.addEventListener("click",R,{capture:!0}));let A=C=>_optionalChain([h, 'optionalAccess', _22 => _22.handleMove, 'call', _23 => _23(C)]);h&&e.addEventListener("mousemove",A,{passive:!0});let P=C=>{Te(C,{color:t.edges.color,width:t.edges.width,thresholdAngle:t.edges.thresholdAngle})},D=e.parentElement,F=()=>D?{width:D.clientWidth,height:D.clientHeight}:{width:window.innerWidth,height:window.innerHeight},y=null,x=()=>{let{width:C,height:U}=F(),W=Math.min(window.devicePixelRatio,2),ee=Re(i,o,c(),Math.max(1,C),Math.max(1,U),{toneMapping:_nullishCoalesce(t.render.toneMapping, () => (E.NeutralToneMapping)),toneMappingExposure:_nullishCoalesce(t.render.toneMappingExposure, () => (1)),aoIntensity:t.render.aoIntensity});return ee.setSize(Math.max(1,C),Math.max(1,U),W),ee},I=C=>{C&&!y?y=x():!C&&y&&(y.dispose(),y=null)};t.render.ambientOcclusion&&(y=x());let{animate:z,dispose:q}=Lt(i,o,a,c,l,s,F,t.events.onFrame,m,f,()=>y,H);z(),o.up.set(r.x,r.y,r.z),d();let X=C=>{C.traverse(U=>{let W=U;!W.geometry&&!W.material||(_optionalChain([W, 'access', _24 => _24.geometry, 'optionalAccess', _25 => _25.dispose, 'call', _26 => _26()]),Array.isArray(W.material)?W.material.forEach(ee=>ee.dispose()):_optionalChain([W, 'access', _27 => _27.material, 'optionalAccess', _28 => _28.dispose, 'call', _29 => _29()]))})},Z=C=>{C.userData.source="user",o.add(C)},ze=C=>{C.removeFromParent(),X(C)},_e=()=>{o.children.filter(U=>U.userData.source==="user").forEach(U=>{U.removeFromParent(),X(U)})};return{scene:o,camera:a,controls:s,renderer:i,cameraController:l,grid:m,gizmo:f,measureTool:h,applyEdges:P,setAmbientOcclusion:I,updateShadowBounds:d,dispose:()=>{q(),g.dispose(),(f||h)&&(e.removeEventListener("mousedown",O,{capture:!0}),e.removeEventListener("click",R,{capture:!0})),h&&e.removeEventListener("mousemove",A),_optionalChain([h, 'optionalAccess', _30 => _30.dispose, 'call', _31 => _31()]),_optionalChain([H, 'optionalAccess', _32 => _32.dispose, 'call', _33 => _33()]),_optionalChain([f, 'optionalAccess', _34 => _34.dispose, 'call', _35 => _35()]),_optionalChain([m, 'optionalAccess', _36 => _36.dispose, 'call', _37 => _37()]),_optionalChain([y, 'optionalAccess', _38 => _38.dispose, 'call', _39 => _39()]),s.dispose(),i.dispose(),o.traverse(C=>{let U=C;!U.geometry&&!U.material||(_optionalChain([U, 'access', _40 => _40.geometry, 'optionalAccess', _41 => _41.dispose, 'call', _42 => _42()]),Array.isArray(U.material)?U.material.forEach(W=>W.dispose()):_optionalChain([U, 'access', _43 => _43.material, 'optionalAccess', _44 => _44.dispose, 'call', _45 => _45()]))}),_optionalChain([o, 'access', _46 => _46.environment, 'optionalAccess', _47 => _47.dispose, 'call', _48 => _48()]),o.background instanceof E.Texture&&o.background.dispose()},fitToView:g.fitToView,clearSelection:g.clearSelection,addUserGeometry:Z,removeUserGeometry:ze,clearUserGeometry:_e}};function xt(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:_optionalChain([e, 'access', _49 => _49.camera, 'optionalAccess', _50 => _50.position])||new E.Vector3(-r.cameraDistance,-r.cameraDistance,r.cameraDistance),fov:_optionalChain([e, 'access', _51 => _51.camera, 'optionalAccess', _52 => _52.fov])||20,near:_optionalChain([e, 'access', _53 => _53.camera, 'optionalAccess', _54 => _54.near])||r.near,far:_optionalChain([e, 'access', _55 => _55.camera, 'optionalAccess', _56 => _56.far])||r.far,target:_optionalChain([e, 'access', _57 => _57.camera, 'optionalAccess', _58 => _58.target])||new E.Vector3(0,0,0)},lighting:{enableSunlight:_nullishCoalesce(_optionalChain([e, 'access', _59 => _59.lighting, 'optionalAccess', _60 => _60.enableSunlight]), () => (!0)),sunlightIntensity:_nullishCoalesce(_optionalChain([e, 'access', _61 => _61.lighting, 'optionalAccess', _62 => _62.sunlightIntensity]), () => (1)),sunlightPosition:_optionalChain([e, 'access', _63 => _63.lighting, 'optionalAccess', _64 => _64.sunlightPosition])||new E.Vector3(r.lightDistance,r.lightDistance,r.lightHeight),ambientLightColor:_optionalChain([e, 'access', _65 => _65.lighting, 'optionalAccess', _66 => _66.ambientLightColor])||new E.Color(4210752),ambientLightIntensity:_nullishCoalesce(_optionalChain([e, 'access', _67 => _67.lighting, 'optionalAccess', _68 => _68.ambientLightIntensity]), () => (1)),sunlightColor:_optionalChain([e, 'access', _69 => _69.lighting, 'optionalAccess', _70 => _70.sunlightColor])||16777215},environment:{hdrPath:_optionalChain([e, 'access', _71 => _71.environment, 'optionalAccess', _72 => _72.hdrPath])||"/baseHDR.hdr",backgroundColor:_optionalChain([e, 'access', _73 => _73.environment, 'optionalAccess', _74 => _74.backgroundColor])||new E.Color(15790320),enableEnvironmentLighting:_nullishCoalesce(_optionalChain([e, 'access', _75 => _75.environment, 'optionalAccess', _76 => _76.enableEnvironmentLighting]), () => (!0)),sceneUp:_optionalChain([e, 'access', _77 => _77.environment, 'optionalAccess', _78 => _78.sceneUp])||re,showEnvironment:_nullishCoalesce(_optionalChain([e, 'access', _79 => _79.environment, 'optionalAccess', _80 => _80.showEnvironment]), () => (!1))},floor:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _81 => _81.floor, 'optionalAccess', _82 => _82.enabled]), () => (!1)),size:_optionalChain([e, 'access', _83 => _83.floor, 'optionalAccess', _84 => _84.size])||r.floorSize,color:_optionalChain([e, 'access', _85 => _85.floor, 'optionalAccess', _86 => _86.color])||new E.Color(8421504),roughness:_nullishCoalesce(_optionalChain([e, 'access', _87 => _87.floor, 'optionalAccess', _88 => _88.roughness]), () => (.7)),metalness:_nullishCoalesce(_optionalChain([e, 'access', _89 => _89.floor, 'optionalAccess', _90 => _90.metalness]), () => (0)),receiveShadow:_nullishCoalesce(_optionalChain([e, 'access', _91 => _91.floor, 'optionalAccess', _92 => _92.receiveShadow]), () => (!0))},render:{enableShadows:_nullishCoalesce(_optionalChain([e, 'access', _93 => _93.render, 'optionalAccess', _94 => _94.enableShadows]), () => (!0)),shadowMapSize:_optionalChain([e, 'access', _95 => _95.render, 'optionalAccess', _96 => _96.shadowMapSize])||2048,antialias:_nullishCoalesce(_optionalChain([e, 'access', _97 => _97.render, 'optionalAccess', _98 => _98.antialias]), () => (!0)),pixelRatio:_optionalChain([e, 'access', _99 => _99.render, 'optionalAccess', _100 => _100.pixelRatio])||Math.min(window.devicePixelRatio,2),toneMapping:_optionalChain([e, 'access', _101 => _101.render, 'optionalAccess', _102 => _102.toneMapping])||E.NeutralToneMapping,toneMappingExposure:_nullishCoalesce(_optionalChain([e, 'access', _103 => _103.render, 'optionalAccess', _104 => _104.toneMappingExposure]), () => (1)),preserveDrawingBuffer:_nullishCoalesce(_optionalChain([e, 'access', _105 => _105.render, 'optionalAccess', _106 => _106.preserveDrawingBuffer]), () => (!1)),ambientOcclusion:_nullishCoalesce(_optionalChain([e, 'access', _107 => _107.render, 'optionalAccess', _108 => _108.ambientOcclusion]), () => (!1)),aoIntensity:_nullishCoalesce(_optionalChain([e, 'access', _109 => _109.render, 'optionalAccess', _110 => _110.aoIntensity]), () => (1))},controls:{enableDamping:_nullishCoalesce(_optionalChain([e, 'access', _111 => _111.controls, 'optionalAccess', _112 => _112.enableDamping]), () => (!1)),dampingFactor:_optionalChain([e, 'access', _113 => _113.controls, 'optionalAccess', _114 => _114.dampingFactor])||.05,autoRotate:_nullishCoalesce(_optionalChain([e, 'access', _115 => _115.controls, 'optionalAccess', _116 => _116.autoRotate]), () => (!1)),autoRotateSpeed:_optionalChain([e, 'access', _117 => _117.controls, 'optionalAccess', _118 => _118.autoRotateSpeed])||.5,enableZoom:_nullishCoalesce(_optionalChain([e, 'access', _119 => _119.controls, 'optionalAccess', _120 => _120.enableZoom]), () => (!0)),enablePan:_nullishCoalesce(_optionalChain([e, 'access', _121 => _121.controls, 'optionalAccess', _122 => _122.enablePan]), () => (!0)),minDistance:_optionalChain([e, 'access', _123 => _123.controls, 'optionalAccess', _124 => _124.minDistance])||r.minDistance,maxDistance:_optionalChain([e, 'access', _125 => _125.controls, 'optionalAccess', _126 => _126.maxDistance])||1/0},grid:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _127 => _127.grid, 'optionalAccess', _128 => _128.enabled]), () => (!1)),cellSize:_nullishCoalesce(_optionalChain([e, 'access', _129 => _129.grid, 'optionalAccess', _130 => _130.cellSize]), () => (1)),majorEvery:_nullishCoalesce(_optionalChain([e, 'access', _131 => _131.grid, 'optionalAccess', _132 => _132.majorEvery]), () => (10)),cellColor:_nullishCoalesce(_optionalChain([e, 'access', _133 => _133.grid, 'optionalAccess', _134 => _134.cellColor]), () => (8947848)),majorColor:_nullishCoalesce(_optionalChain([e, 'access', _135 => _135.grid, 'optionalAccess', _136 => _136.majorColor]), () => (4473924)),fadeDistance:_nullishCoalesce(_optionalChain([e, 'access', _137 => _137.grid, 'optionalAccess', _138 => _138.fadeDistance]), () => (100)),plane:_nullishCoalesce(_optionalChain([e, 'access', _139 => _139.grid, 'optionalAccess', _140 => _140.plane]), () => (vt(_nullishCoalesce(_optionalChain([e, 'access', _141 => _141.environment, 'optionalAccess', _142 => _142.sceneUp]), () => (re)))))},gizmo:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _143 => _143.gizmo, 'optionalAccess', _144 => _144.enabled]), () => (!1))},edges:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _145 => _145.edges, 'optionalAccess', _146 => _146.enabled]), () => (!1)),color:_nullishCoalesce(_optionalChain([e, 'access', _147 => _147.edges, 'optionalAccess', _148 => _148.color]), () => (2236962)),width:_nullishCoalesce(_optionalChain([e, 'access', _149 => _149.edges, 'optionalAccess', _150 => _150.width]), () => (1.5)),thresholdAngle:_nullishCoalesce(_optionalChain([e, 'access', _151 => _151.edges, 'optionalAccess', _152 => _152.thresholdAngle]), () => (30))},measure:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _153 => _153.measure, 'optionalAccess', _154 => _154.enabled]), () => (!1)),snapPixels:_optionalChain([e, 'access', _155 => _155.measure, 'optionalAccess', _156 => _156.snapPixels]),color:_optionalChain([e, 'access', _157 => _157.measure, 'optionalAccess', _158 => _158.color]),labelClassName:_optionalChain([e, 'access', _159 => _159.measure, 'optionalAccess', _160 => _160.labelClassName]),displayUnit:_optionalChain([e, 'access', _161 => _161.measure, 'optionalAccess', _162 => _162.displayUnit]),format:_optionalChain([e, 'access', _163 => _163.measure, 'optionalAccess', _164 => _164.format])},events:{onBackgroundClicked:_optionalChain([e, 'access', _165 => _165.events, 'optionalAccess', _166 => _166.onBackgroundClicked]),onObjectSelected:_optionalChain([e, 'access', _167 => _167.events, 'optionalAccess', _168 => _168.onObjectSelected]),onMeshMetadataClicked:_optionalChain([e, 'access', _169 => _169.events, 'optionalAccess', _170 => _170.onMeshMetadataClicked]),onMeshDoubleClicked:_optionalChain([e, 'access', _171 => _171.events, 'optionalAccess', _172 => _172.onMeshDoubleClicked]),selectionColor:_optionalChain([e, 'access', _173 => _173.events, 'optionalAccess', _174 => _174.selectionColor])||"#ff0000",enableEventHandlers:_nullishCoalesce(_optionalChain([e, 'access', _175 => _175.events, 'optionalAccess', _176 => _176.enableEventHandlers]), () => (!0)),enableKeyboardControls:_nullishCoalesce(_optionalChain([e, 'access', _177 => _177.events, 'optionalAccess', _178 => _178.enableKeyboardControls]), () => (!0)),enableClickToFocus:_nullishCoalesce(_optionalChain([e, 'access', _179 => _179.events, 'optionalAccess', _180 => _180.enableClickToFocus]), () => (!0)),enableDoubleClickZoom:_nullishCoalesce(_optionalChain([e, 'access', _181 => _181.events, 'optionalAccess', _182 => _182.enableDoubleClickZoom]), () => (!0)),onReady:_optionalChain([e, 'access', _183 => _183.events, 'optionalAccess', _184 => _184.onReady]),onFrame:_optionalChain([e, 'access', _185 => _185.events, 'optionalAccess', _186 => _186.onFrame])}}}var Mt=new Set(["grid","floor","label-layer","measure"]);function Ct(e){let n=e;for(;n;){if(typeof n.userData.id=="string"&&Mt.has(n.userData.id))return!0;n=n.parent}return!1}function le(e){let n=new E.Box3;return e.traverse(t=>{let r=t;t.visible&&!Ct(t)&&r.geometry&&n.expandByObject(t)}),n}function At(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 St(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 Dt(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 Lt(e,n,t,r,o,a,i,s,l,c,u,d){let m=null,f=performance.now(),b=()=>{let{width:g,height:p}=i();if(g===0||p===0)return;let T=Math.min(window.devicePixelRatio,2),v=Math.round(g*T),O=Math.round(p*T);(e.domElement.width!==v||e.domElement.height!==O)&&(e.setPixelRatio(T),e.setSize(g,p,!1),t.aspect=g/p,t.updateProjectionMatrix(),o.updateAspect(g,p),_optionalChain([u, 'optionalCall', _187 => _187(), 'optionalAccess', _188 => _188.setSize, 'call', _189 => _189(g,p,T)]),_optionalChain([d, 'optionalAccess', _190 => _190.setSize, 'call', _191 => _191(g,p)]))},H=function(){m=requestAnimationFrame(H);let g=performance.now(),p=(g-f)/1e3;f=g,b(),(a.enableDamping||a.autoRotate)&&a.update(),l&&l.update(r().position),c&&c.update(p),_optionalChain([s, 'optionalCall', _192 => _192(p)]);let T=r(),v=_optionalChain([u, 'optionalCall', _193 => _193()]);v?(v.setCamera(T),v.render(p)):e.render(n,T),d&&d.render(n,T),c&&c.render(e)};return{animate:H,dispose:()=>{m!==null&&(cancelAnimationFrame(m),m=null)}}}function Pt(e,n){n.environment.enableEnvironmentLighting?new (0, _HDRLoaderjs.HDRLoader)().load(n.environment.hdrPath||"/baseHDR.hdr",function(t){if(!_optionalChain([t, 'optionalAccess', _194 => _194.image])){_chunkDRG5SLIPcjs.e.call(void 0, ).warn("HDR loaded without image data; skipping environment map."),_optionalChain([n, 'access', _195 => _195.events, 'access', _196 => _196.onReady, 'optionalCall', _197 => _197()]);return}t.mapping=E.EquirectangularReflectionMapping,e.environment=t,n.environment.showEnvironment&&(e.background=t),_optionalChain([n, 'access', _198 => _198.events, 'access', _199 => _199.onReady, 'optionalCall', _200 => _200()])},void 0,function(t){_chunkDRG5SLIPcjs.e.call(void 0, ).warn("HDR texture could not be loaded, falling back to basic lighting:",t),_optionalChain([n, 'access', _201 => _201.events, 'access', _202 => _202.onReady, 'optionalCall', _203 => _203()])}):_optionalChain([n, 'access', _204 => _204.events, 'access', _205 => _205.onReady, 'optionalCall', _206 => _206()])}function Ot(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(_nullishCoalesce(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 It(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=(_optionalChain([n, 'access', _207 => _207.environment, 'optionalAccess', _208 => _208.sceneUp])||re).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 Vt(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 Bt(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=_nullishCoalesce(n.render.toneMappingExposure, () => (1)),t.outputColorSpace=E.SRGBColorSpace,t.sortObjects=!0,t}function Ft(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=w=>{let R=w;for(;R;){if(!R.visible)return!1;R=R.parent}return!0},m=()=>{let w=le(n);if(w.isEmpty()){_chunkDRG5SLIPcjs.e.call(void 0, ).warn("No objects to fit to view");return}let R=w.getCenter(new E.Vector3),A=w.getSize(new E.Vector3),P=Math.max(A.x,A.y,A.z),D=r.fov*(Math.PI/180),F=P/(2*Math.tan(D/2));F*=1.5;let y=r.position.clone().sub(o.target);y.lengthSq()<1e-12&&y.set(.8,1,1.2),y.normalize(),r.position.copy(R.clone().add(y.multiplyScalar(F))),o.target.copy(R),o.update()},f=typeof a.events.selectionColor=="string"?new E.Color(a.events.selectionColor):a.events.selectionColor instanceof E.Color?a.events.selectionColor:new E.Color("#ff0000"),b=()=>{i.forEach(w=>{let R=w;if(s.has(w)){let A=s.get(w),P=R.material;P instanceof E.Material?P.dispose():Array.isArray(P)&&P.forEach(D=>D.dispose()),R.material=A,s.delete(w)}}),i.clear()},H=w=>{let R=w;if(!(R.material instanceof E.Material))return!1;s.set(w,R.material);let A=R.material.clone();return w instanceof E.Mesh&&"emissive"in A?A.emissive=f.clone():"color"in A&&(A.color=f.clone()),R.material=A,!0},h=()=>{let w=le(n),R=w.isEmpty()?1:w.getSize(new E.Vector3).length();l.params.Points.threshold=R*.01},g=w=>{u.set(w.clientX,w.clientY)},p=w=>{let R=new E.Vector2(w.clientX,w.clientY);if(u.distanceTo(R)>5)return;let A=e.getBoundingClientRect();c.x=(w.clientX-A.left)/A.width*2-1,c.y=-((w.clientY-A.top)/A.height)*2+1,h(),l.setFromCamera(c,t());let P=l.intersectObjects(n.children,!0).filter(D=>d(D.object));if(P.length>0){let D=P[0].object;i.has(D)||(b(),i.add(D),H(D),_optionalChain([a, 'access', _209 => _209.events, 'optionalAccess', _210 => _210.onObjectSelected, 'optionalCall', _211 => _211(D)]),D instanceof E.Mesh&&Object.keys(D.userData).length>0&&_optionalChain([a, 'access', _212 => _212.events, 'optionalAccess', _213 => _213.onMeshMetadataClicked, 'optionalCall', _214 => _214(D.userData)]))}else b(),_optionalChain([a, 'access', _215 => _215.events, 'optionalAccess', _216 => _216.onBackgroundClicked, 'optionalCall', _217 => _217({x:c.x,y:c.y})])},T=w=>{let R=e.getBoundingClientRect();c.x=(w.clientX-R.left)/R.width*2-1,c.y=-((w.clientY-R.top)/R.height)*2+1,h(),l.setFromCamera(c,t());let A=l.intersectObjects(n.children,!0).filter(Z=>d(Z.object));if(A.length===0)return;let P=A[0].object;if(_optionalChain([a, 'access', _218 => _218.events, 'optionalAccess', _219 => _219.onMeshDoubleClicked, 'optionalCall', _220 => _220(P)]),!_optionalChain([a, 'access', _221 => _221.events, 'optionalAccess', _222 => _222.enableDoubleClickZoom]))return;let D=new E.Box3().setFromObject(P);if(D.isEmpty())return;let F=D.getCenter(new E.Vector3),y=D.getSize(new E.Vector3),x=Math.max(y.x,y.y,y.z),I=r.fov*(Math.PI/180),z=x/(2*Math.tan(I/2))*1.5,q=r.position.clone().sub(o.target).normalize(),X=F.clone().add(q.multiplyScalar(z));Dt(r,o,X,F)},v=w=>{if(_optionalChain([a, 'access', _223 => _223.events, 'optionalAccess', _224 => _224.enableKeyboardControls]))switch(w.key.toLowerCase()){case"f":w.preventDefault(),m();break;case"escape":w.preventDefault(),b();break;case" ":w.preventDefault(),m();break}};return _optionalChain([a, 'access', _225 => _225.events, 'optionalAccess', _226 => _226.enableClickToFocus])&&(e.addEventListener("mousedown",g),e.addEventListener("click",p),e.addEventListener("dblclick",T)),_optionalChain([a, 'access', _227 => _227.events, 'optionalAccess', _228 => _228.enableKeyboardControls])&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",v)),{dispose:()=>{e.removeEventListener("mousedown",g),e.removeEventListener("click",p),e.removeEventListener("dblclick",T),e.removeEventListener("keydown",v),b()},fitToView:m,clearSelection:b}}function Ut(e,n,t){let r=new (0, _OrbitControlsjs.OrbitControls)(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=_nullishCoalesce(t.controls.enableZoom, () => (!0)),r.enablePan=_nullishCoalesce(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 $t={};_chunkDRG5SLIPcjs.a.call(void 0, $t,{CONCRETE_MATERIAL:()=>kt,EMISSIVE_MATERIAL:()=>zt,GLASS_MATERIAL:()=>Gt,METAL_MATERIAL:()=>_t,PLASTIC_MATERIAL:()=>jt,RUBBER_MATERIAL:()=>Nt,WOOD_MATERIAL:()=>Wt});var zt=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}),_t=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}),kt=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}),jt=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}),Gt=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}),Nt=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}),Wt=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});function ne(e,n,t,r=!0){return{x:e,y:n,z:t}}var Zt="#ffffff",Me=12,Jt=4e-4,Kt=12,Qt=.05;function Ce(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=tr(a,t,r);i&&o.push(i);break}case"point":{o.push(rr(a,r));break}default:{let i=a;_chunkDRG5SLIPcjs.e.call(void 0, ).warn(`Skipping unknown display item kind: ${String(i.kind)}`);break}}return o}var er=2;function tr(e,n,t){if(!n)return _chunkDRG5SLIPcjs.e.call(void 0, ).warn("No rhino3dm instance provided; skipping curve display item."),null;let r=nr(e.json,n);if(!r)return null;let o=or(r,t);if(o.length<2)return null;let a=[];for(let d of o)a.push(d.x,d.y,d.z);let i=new _LineGeometryjs.LineGeometry;i.setPositions(a);let s=Ae(e.color,e.opacity),l=new (0, _LineMaterialjs.LineMaterial)({color:s.color}),c=l;c.linewidth=_nullishCoalesce(e.width, () => (er)),c.transparent=s.transparent,c.opacity=s.opacity;let u=new (0, _Line2js.Line2)(i,l);return u.computeLineDistances(),u.name=e.name,u.userData={source:"compute",id:e.id,layer:e.layer,kind:"curve",metadata:e.metadata},u}function rr(e,n){let{x:t,y:r,z:o}=ne(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({...Ae(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 nr(e,n){try{let t=JSON.parse(e),r=n.CommonObject.decode(t);return r&&typeof r.pointAt=="function"?r:(_chunkDRG5SLIPcjs.e.call(void 0, ).warn("Decoded display-item JSON is not a curve; skipping."),null)}catch(t){return _chunkDRG5SLIPcjs.e.call(void 0, ).warn("Failed to decode curve display item JSON:",t),null}}function or(e,n){let t=ar(e,n);return t||ir(e,n)}function ar(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 null;let o=[];for(let a=0;a<r.count;a++){let i=r.get(a),{x:s,y:l,z:c}=ne(i[0],i[1],i[2],n);o.push(new N.Vector3(s,l,c))}return o}function ir(e,n){let t=e.domain,r=t[0],a=t[1]-r,i=d=>{let m=e.pointAt(d),{x:f,y:b,z:H}=ne(m[0],m[1],m[2],n);return new N.Vector3(f,b,H)},s=sr(e),l=r,c=i(r),u=[c];for(let d=0;d<Me;d++){let m=r+a*(d+1)/Me,f=i(m);ce(l,c,m,f,i,s,Kt,u),u.push(f),l=m,c=f}return u}function ce(e,n,t,r,o,a,i,s){if(i<=0)return;let l=(e+t)/2,c=o(l),u=cr(c,n,r),d=lr(n,c,r);u<=a&&d<=Qt||(ce(e,n,l,c,o,a,i-1,s),s.push(c),ce(l,c,t,r,o,a,i-1,s))}function sr(e){let n=e.getBoundingBox(),t=n.min,r=n.max,o=Math.hypot(r[0]-t[0],r[1]-t[1],r[2]-t[2]);return Math.max(o*Jt,1e-6)}function lr(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 cr(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 Ae(e,n){let t=_nullishCoalesce(n, () => (1));return{color:new N.Color(_nullishCoalesce(e, () => (Zt))),transparent:t<1,opacity:t}}var _fflate = require('fflate');var Se=1096174675,dr=1515605075,De= exports.t =3,Le=1,de= exports.u =1,mr=2,fr= exports.v =4,pr= exports.w =8,Er= exports.x =16;var hr=1,Pe=12,Oe=56;function me(e){let n=Tr(br(e)),t=new DataView(n.buffer,n.byteOffset,n.byteLength);if(n.byteLength<Pe)throw j("Blob too small to contain SLVA header.",{expectedBytes:Pe,availableBytes:n.byteLength});let r=0,o=t.getUint32(r,!0);if(r+=4,o!==Se)throw j(`Invalid SLVA magic: 0x${o.toString(16)}`,{expectedMagic:`0x${Se.toString(16)}`,actualMagic:`0x${o.toString(16)}`});let a=t.getUint32(r,!0);if(r+=4,a<Le||a>De)throw j(`Unsupported SLVA version: ${a}`,{minSupportedVersion:Le,maxSupportedVersion:De,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(Rr(s))}catch(z){throw j(`Failed to parse metadata JSON: ${z instanceof Error?z.message:String(z)}`,{metadataLen:i})}if(r+Oe>n.byteLength)throw j("Insufficient data to read geometry header.",{expectedBytes:Oe,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 f=t.getFloat64(r,!0);r+=8;let b=t.getFloat64(r,!0);r+=8;let H=t.getFloat64(r,!0);r+=8;let h=t.getUint32(r,!0);r+=4;let g=(c&de)!==0,p=(c&fr)!==0,T=h*3,O=T*(g?4:2);if(r+O>n.byteLength)throw j("Insufficient data to read vertices.",{expectedBytes:O,availableBytes:n.byteLength-r,offset:r,useFloat32:g,vertexCount:h});let w=n.byteOffset+r,R;if(g?R=Ve(n.buffer,w,T):p?R=vr(ue(n.buffer,w,T)):R=wr(n.buffer,w,T),r+=O,r+4>n.byteLength)throw j("Insufficient data to read index count.",{expectedBytes:4,availableBytes:n.byteLength-r,offset:r});let A=t.getUint32(r,!0);r+=4;let P=(c&mr)!==0,F=A*(P?2:4);if(r+F>n.byteLength)throw j("Insufficient data to read indices.",{expectedBytes:F,availableBytes:n.byteLength-r,offset:r,indexCount:A,useUint16Indices:P});let y=P?ue(n.buffer,n.byteOffset+r,A):Hr(n.buffer,n.byteOffset+r,A);p&&(y=y instanceof Uint16Array?xr(y):Mr(y)),r+=F;let x=null;if((c&pr)!==0){let z=gr(n,t,r,h,p);x=z.uvs,r=z.offset}let I=null;return(c&Er)!==0&&(I=yr(n,r,h,p)),{metadata:l,flags:c,vertices:R,indices:y,origin:[u,d,m],scale:[f,b,H],uvs:x,colors:I}}var Ie=36;function gr(e,n,t,r,o){if(t+Ie>e.byteLength)throw j("Insufficient data to read UV chunk header.",{expectedBytes:Ie,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===hr,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 f=e.byteOffset+t,b;if(d)b=Ve(e.buffer,f,u).slice();else{let H=ue(e.buffer,f,u);b=new Float32Array(u);let h=0,g=0;for(let p=0;p<u;p+=2)o?(h=h+Y(H[p])&65535,g=g+Y(H[p+1])&65535):(h=H[p],g=H[p+1]),b[p]=i+h*l,b[p+1]=s+g*c}return{uvs:b,offset:t+m}}function yr(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 br(e){return typeof e=="string"?_chunkDRG5SLIPcjs.j.call(void 0, e):e instanceof Uint8Array?e:new Uint8Array(e)}function Tr(e){if(e.byteLength<8)return e;let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(n.getUint32(0,!0)!==dr)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 _fflate.inflateSync.call(void 0, 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 Rr(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 (0, _chunkDRG5SLIPcjs.d)("No UTF-8 decoder available in this environment.",_chunkDRG5SLIPcjs.c.INVALID_STATE)}function wr(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 Ve(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 ue(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 Hr(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 vr(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 xr(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 Mr(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 (0, _chunkDRG5SLIPcjs.d)(e,_chunkDRG5SLIPcjs.c.VALIDATION_ERROR,{context:n})}var oe=new Map,Q=new Map;function Be(e,n){let t=oe.get(n);if(t){e.map=t,e.needsUpdate=!0;return}typeof document>"u"||Cr(n).then(r=>{e.map=r,e.needsUpdate=!0}).catch(r=>{_chunkDRG5SLIPcjs.e.call(void 0, ).warn(`Failed to load material texture ${n}:`,r)})}function jn(){for(let e of oe.values())e.dispose();oe.clear(),Q.clear()}function Cr(e){let n=Q.get(e);return n||(n=new Promise((t,r)=>{new ae.TextureLoader().load(e,o=>{o.colorSpace=ae.SRGBColorSpace,oe.set(e,o),Q.delete(e),t(o)},void 0,o=>{Q.delete(e),r(o)})}),Q.set(e,n)),n}async function Fe(e,n){let{debug:t=!1}=_nullishCoalesce(n, () => ({})),r=t?performance.now():0;try{let o=performance.now(),a=JSON.parse(e),i=performance.now()-o;return await Ar(a,n,{parseTime:i,perfStart:r})}catch(o){return _chunkDRG5SLIPcjs.e.call(void 0, ).error("Error parsing mesh batch:",o),[]}}async function Ar(e,n,t){let{mergeByMaterial:r=!0,applyTransforms:o=!0,debug:a=!1}=_nullishCoalesce(n, () => ({})),{parseTime:i=0,perfStart:s=a?performance.now():0}=_nullishCoalesce(t, () => ({}));try{let l=performance.now(),c=me(e.compressedData),u=performance.now()-l,d=a?Ir(e.compressedData):0;return Ue(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 _chunkDRG5SLIPcjs.e.call(void 0, ).error("Error parsing mesh batch object:",l),[]}}async function Xn(e,n){let{mergeByMaterial:t=!0,applyTransforms:r=!0,debug:o=!1}=_nullishCoalesce(n, () => ({})),a=o?performance.now():0;try{let i=performance.now(),s=me(e),l=performance.now()-i,c=e.byteLength;return Ue(s,{mergeByMaterial:t,applyTransforms:r,debug:o,parseTime:0,decodeTime:l,perfStart:a,blobBytes:c})}catch(i){return _chunkDRG5SLIPcjs.e.call(void 0, ).error("Error parsing mesh batch blob:",i),[]}}function Ue(e,n){let{mergeByMaterial:t,applyTransforms:r,debug:o,parseTime:a,decodeTime:i,perfStart:s,blobBytes:l,fallback:c}=n,u=_nullishCoalesce(_nullishCoalesce(e.metadata.materials, () => (_optionalChain([c, 'optionalAccess', _229 => _229.materials]))), () => ([])),d=_nullishCoalesce(_nullishCoalesce(e.metadata.groups, () => (_optionalChain([c, 'optionalAccess', _230 => _230.groups]))), () => ([])),m=_nullishCoalesce(_optionalChain([c, 'optionalAccess', _231 => _231.sourceComponentId]), () => (e.metadata.sourceComponentId)),f=(e.flags&de)!==0,b=f?Dr(e.vertices,r):Sr(e.vertices,e.origin,e.scale,r);if(o){let T=e.vertices.byteLength+e.indices.byteLength;_chunkDRG5SLIPcjs.e.call(void 0, ).debug("Mesh Batch Stats:"),_chunkDRG5SLIPcjs.e.call(void 0, ).debug(` Materials: ${u.length} | Groups: ${d.length}`),_chunkDRG5SLIPcjs.e.call(void 0, ).debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),_chunkDRG5SLIPcjs.e.call(void 0, ).debug(` Format: ${f?"float32":"int16 quantized"}`),_chunkDRG5SLIPcjs.e.call(void 0, ).debug(` Blob: ${(l/1024/1024).toFixed(2)} MB | Geometry on wire: ${(T/1024/1024).toFixed(2)} MB`)}let H=performance.now(),h=u.map(T=>Lr(T,{vertexColors:e.colors!=null})),g=[];for(let T of d)if(t&&T.meshes.length>1){let v=Pr(T,b,e.indices,h,e.uvs,e.colors);v.userData.sourceComponentId=_nullishCoalesce(m, () => (null)),g.push(v)}else{let v=Or(T,b,e.indices,h,e.uvs,e.colors);for(let O of v)O.userData.sourceComponentId=_nullishCoalesce(m, () => (null));g.push(...v)}let p=performance.now()-H;if(o){let T=performance.now()-s;_chunkDRG5SLIPcjs.e.call(void 0, ).debug("Performance:"),a>0&&_chunkDRG5SLIPcjs.e.call(void 0, ).debug(` Parse JSON: ${a.toFixed(2)}ms`),_chunkDRG5SLIPcjs.e.call(void 0, ).debug(` Decode binary: ${i.toFixed(2)}ms`),_chunkDRG5SLIPcjs.e.call(void 0, ).debug(` Create Meshes: ${p.toFixed(2)}ms`),_chunkDRG5SLIPcjs.e.call(void 0, ).debug(` Total: ${T.toFixed(2)}ms`)}return Promise.resolve(g)}function Sr(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 Dr(e,n){return e}function Lr(e,n){let t=pe(e.color),r=new V.MeshPhysicalMaterial({color:t,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,vertexColors:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _232 => _232.vertexColors]), () => (!1)),side:V.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0});return e.map&&Be(r,e.map),r}function Pr(e,n,t,r,o=null,a=null){let i=0,s=0;for(let p of e.meshes)i+=p.vertexCount,s+=p.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,f=0;for(let p of e.meshes){let T=p.vertexStart*3,v=p.vertexCount*3;if(l.set(n.subarray(T,T+v),m*3),u&&o){let R=p.vertexStart*2;u.set(o.subarray(R,R+p.vertexCount*2),m*2)}d&&a&&d.set(a.subarray(T,T+v),m*3);let O=t.subarray(p.indexStart,p.indexStart+p.indexCount),w=m-p.vertexStart;if(w===0)c.set(O,f);else for(let R=0;R<O.length;R++)c[f+R]=O[R]+w;m+=p.vertexCount,f+=p.indexCount}let b=new V.BufferGeometry;b.setAttribute("position",new V.BufferAttribute(l,3)),b.setIndex(new V.BufferAttribute(c,1)),u&&b.setAttribute("uv",new V.BufferAttribute(u,2)),d&&b.setAttribute("color",new V.BufferAttribute(d,3,!0)),b.computeVertexNormals();let H=new V.Mesh(b,r[e.materialId]),h=e.meshes[0],g=e.meshes.map(p=>p.name).filter(p=>p&&p.length>0);return H.name=g.length>0?g[0]:`merged_material_${e.materialId}`,H.castShadow=!0,H.receiveShadow=!0,H.userData={source:"compute",name:H.name,layer:_nullishCoalesce(_optionalChain([h, 'optionalAccess', _233 => _233.layer]), () => ("")),originalIndex:_nullishCoalesce(_optionalChain([h, 'optionalAccess', _234 => _234.originalIndex]), () => (0)),metadata:_nullishCoalesce(_optionalChain([h, 'optionalAccess', _235 => _235.metadata]), () => ({})),mergedFrom:e.meshes.slice(1).map(p=>({name:p.name,layer:p.layer,originalIndex:p.originalIndex}))},H}function Or(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),f=s.vertexStart;for(let h=0;h<d.length;h++)m[h]=d[h]-f;let b=new V.BufferGeometry;if(b.setAttribute("position",new V.BufferAttribute(u,3)),b.setIndex(new V.BufferAttribute(m,1)),o){let h=s.vertexStart*2,g=o.slice(h,h+s.vertexCount*2);b.setAttribute("uv",new V.BufferAttribute(g,2))}if(a){let h=a.slice(l,l+c);b.setAttribute("color",new V.BufferAttribute(h,3,!0))}b.computeVertexNormals();let H=new V.Mesh(b,r[e.materialId]);H.name=s.name,H.userData={source:"compute",name:s.name,layer:_nullishCoalesce(s.layer, () => ("")),originalIndex:s.originalIndex,metadata:_nullishCoalesce(s.metadata, () => ({}))},H.castShadow=!0,H.receiveShadow=!0,i.push(H)}return i}function Ir(e){return Math.floor(e.length*3/4)}var Vr={Millimeters:1/1e3,Centimeters:1/100,Meters:1,Inches:1/39.37,Feet:1/3.28084},Br="Display";async function eo(e,n){let t=performance.now(),r=[],{allowScaling:o=!0,allowAutoPosition:a=!0,rhino:i,debug:s=!1,parsing:l={}}=_nullishCoalesce(n, () => ({}));try{let c=o?Fr(e.modelunits):1;return await Ur(e,r,c,l,i,s),a&&jr(r),r}catch(c){throw Gr(c,r),c}finally{s&&Wr(t)}}function Fr(e){return _nullishCoalesce(Vr[e], () => (1))}async function Ur(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 zr(c,n,t,r,o,a)}}}async function zr(e,n,t,r,o,a){for(let i of e){if(!i.type.includes(Br))continue;let s={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...r},l=await Fe(i.data,s),c=Ce(_r(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&&_chunkDRG5SLIPcjs.e.call(void 0, ).debug(`Extracted ${l.length} meshes and ${c.length} items from batch`)}}function _r(e){return_optionalChain([(typeof e=="string"?kr(e):e), 'optionalAccess', _236 => _236.items])}function kr(e){try{return JSON.parse(e)}catch (e4){return}}function jr(e){if(e.length===0)return;let n=K(e);Ee(e,n.min.z,"z")}function Gr(e,n){_chunkDRG5SLIPcjs.e.call(void 0, ).error("An unexpected error occurred:",e),Nr(n)}function Nr(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 Wr(e){let n=performance.now()-e;_chunkDRG5SLIPcjs.e.call(void 0, ).info("Time to process meshes:",`${n.toFixed(2)}ms`)}exports.a = Xr; exports.b = pe; exports.c = Ee; exports.d = K; exports.e = he; exports.f = ge; exports.g = ye; exports.h = te; exports.i = Te; exports.j = it; exports.k = on; exports.l = Re; exports.m = He; exports.n = Rt; exports.o = xe; exports.p = An; exports.q = $t; exports.r = Ce; exports.s = Se; exports.t = De; exports.u = de; exports.v = fr; exports.w = pr; exports.x = Er; exports.y = me; exports.z = jn; exports.A = Fe; exports.B = Ar; exports.C = Xn; exports.D = Vr; exports.E = eo;
55
- //# sourceMappingURL=chunk-QZ573TYU.cjs.map
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQZ573TYUcjs = require('./chunk-QZ573TYU.cjs');require('./chunk-DRG5SLIP.cjs');exports.BINARY_MESH_MAGIC = _chunkQZ573TYUcjs.s; exports.BINARY_MESH_VERSION = _chunkQZ573TYUcjs.t; exports.EDGE_USERDATA_KIND = _chunkQZ573TYUcjs.h; exports.FLAG_DELTA_ENCODED = _chunkQZ573TYUcjs.v; exports.FLAG_FLOAT32 = _chunkQZ573TYUcjs.u; exports.FLAG_HAS_UVS = _chunkQZ573TYUcjs.w; exports.FLAG_HAS_VERTEX_COLORS = _chunkQZ573TYUcjs.x; exports.Materials = _chunkQZ573TYUcjs.q; exports.SCALE_FACTORS = _chunkQZ573TYUcjs.D; exports.addEdges = _chunkQZ573TYUcjs.i; exports.applyOffset = _chunkQZ573TYUcjs.c; exports.clearTextureCache = _chunkQZ573TYUcjs.z; exports.computeCombinedBoundingBox = _chunkQZ573TYUcjs.d; exports.createCameraController = _chunkQZ573TYUcjs.e; exports.createGrid = _chunkQZ573TYUcjs.f; exports.createLabelLayer = _chunkQZ573TYUcjs.m; exports.createMeasureTool = _chunkQZ573TYUcjs.o; exports.createRenderPipeline = _chunkQZ573TYUcjs.l; exports.createViewGizmo = _chunkQZ573TYUcjs.g; exports.getThreeMeshesFromComputeResponse = _chunkQZ573TYUcjs.E; exports.initThree = _chunkQZ573TYUcjs.p; exports.isEdgeOverlay = _chunkQZ573TYUcjs.j; exports.parseBinaryMeshBatch = _chunkQZ573TYUcjs.y; exports.parseColor = _chunkQZ573TYUcjs.b; exports.parseDisplayItems = _chunkQZ573TYUcjs.r; exports.parseMeshBatch = _chunkQZ573TYUcjs.A; exports.parseMeshBatchBlob = _chunkQZ573TYUcjs.C; exports.parseMeshBatchObject = _chunkQZ573TYUcjs.B; exports.removeEdges = _chunkQZ573TYUcjs.k; exports.snapToVertex = _chunkQZ573TYUcjs.n; exports.updateScene = _chunkQZ573TYUcjs.a;
2
- //# sourceMappingURL=visualization-3E3Q76VG.cjs.map