@selvajs/compute 3.1.0-beta.7 → 3.1.0-beta.9

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,4 +1,4 @@
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 _chunkCUQQ3ZBVcjs = require('./chunk-CUQQ3ZBV.cjs');var Rt={};_chunkCUQQ3ZBVcjs.a.call(void 0, Rt,{CONCRETE_MATERIAL:()=>De,EMISSIVE_MATERIAL:()=>Le,GLASS_MATERIAL:()=>Pe,METAL_MATERIAL:()=>Ie,PLASTIC_MATERIAL:()=>Oe,RUBBER_MATERIAL:()=>Be,SHARED_MATERIALS:()=>ge,WOOD_MATERIAL:()=>Ve});var _three = require('three'); var O = _interopRequireWildcard(_three); var k = _interopRequireWildcard(_three); var z = _interopRequireWildcard(_three); var U = _interopRequireWildcard(_three); var W = _interopRequireWildcard(_three); var oe = _interopRequireWildcard(_three); var We = _interopRequireWildcard(_three); var D = _interopRequireWildcard(_three); var fe = _interopRequireWildcard(_three); var E = _interopRequireWildcard(_three); var $ = _interopRequireWildcard(_three); var P = _interopRequireWildcard(_three);var Le=new O.MeshPhysicalMaterial({color:0,emissive:new O.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:O.FrontSide,dithering:!0}),Ie=new O.MeshPhysicalMaterial({color:new O.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:O.FrontSide,dithering:!0}),De=new O.MeshPhysicalMaterial({color:new O.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:O.FrontSide,dithering:!0}),Oe=new O.MeshPhysicalMaterial({color:new O.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:O.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Pe=new O.MeshPhysicalMaterial({color:new O.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,depthWrite:!1,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:O.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Be=new O.MeshPhysicalMaterial({color:new O.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:O.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Ve=new O.MeshPhysicalMaterial({color:new O.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:O.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),ge=new Set([Le,Ie,De,Oe,Pe,Be,Ve]);var q={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function Dr(e,n,t,r,i){if(Ht(e),n.length===0)return;n.forEach(d=>{e.add(d)});let o=ye(n),a=o.getCenter(new k.Vector3),s=o.getSize(new k.Vector3),l=Math.max(s.x,s.y,s.z);if(l/Math.min(s.x||1,s.y||1,s.z||1)>q.SCALE_RATIO_THRESHOLD||l>q.HUGE_THRESHOLD?(t.near=l*q.NEAR_PLANE_FACTOR.TINY,t.far=l*q.FAR_PLANE_FACTOR.HUGE):l>q.LARGE_THRESHOLD?(t.near=l*q.NEAR_PLANE_FACTOR.SMALL,t.far=l*q.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,l*q.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,l*q.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),!i){let d=l*q.INITIAL_DISTANCE_MULTIPLIER;t.position.set(a.x+d*.8,a.y+d,a.z+d*1.2),r.target.copy(a),r.update()}}function Fe(e){if(!e||typeof e!="string")return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Invalid color input: ${e}, using white`),new k.Color(16777215);let n=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(n))try{let r=n.startsWith("#")?n:`#${n}`;return new k.Color(r)}catch (e2){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Invalid hex color: ${e}, using white`),new k.Color(16777215)}if(n.includes(",")){let r=n.split(",").map(i=>parseInt(i.trim(),10));if(r.length===3&&r.every(i=>!isNaN(i)&&i>=0&&i<=255))return new k.Color(r[0]/255,r[1]/255,r[2]/255)}let t=n.toLowerCase();return t in k.Color.NAMES?new k.Color(k.Color.NAMES[t]):(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Invalid color string: ${e}, using white`),new k.Color(16777215))}function ke(e,n,t="z"){e.forEach(r=>{r.position[t]-=n})}function ye(e){let n=new k.Box3;return e.length===0||e.forEach(t=>{t.updateMatrixWorld(!0);let r=new k.Box3().setFromObject(t);n.union(r)}),n}var vt=new Set(["grid","floor","label-layer","measure"]);function wt(e){let n=e;for(;n;){if(typeof n.userData.id=="string"&&vt.has(n.userData.id))return!0;n=n.parent}return!1}function re(e){e.updateMatrixWorld(!0);let n=new k.Box3;return e.traverse(t=>{let r=t;t.visible&&!wt(t)&&r.geometry&&n.expandByObject(t)}),n}var xt=new Set(["floor","grid","label-layer"]);function Ht(e){[...e.children].forEach(t=>{xt.has(t.userData.id)||t.userData.source!=="user"&&(t.traverse(r=>{let i=r;if(!i.geometry&&!i.material)return;_optionalChain([i, 'access', _2 => _2.geometry, 'optionalAccess', _3 => _3.dispose, 'call', _4 => _4()]);let o=i.material;if(!o)return;(Array.isArray(o)?o:[o]).forEach(s=>{if(!ge.has(s)){for(let l of Object.values(s))l instanceof k.Texture&&l.dispose();s.dispose()}})}),t.removeFromParent())})}function Mt(e){let n=e.clone().normalize(),t=new z.Vector3(0,0,1),r=new z.Vector3(0,1,0),i=Math.abs(n.dot(t))>.9?r:t,o=new z.Vector3().crossVectors(n,i).normalize(),a=new z.Vector3().crossVectors(o,n).normalize();return{top:n.clone(),bottom:n.clone().negate(),front:a.clone(),back:a.clone().negate(),right:o.clone(),left:o.clone().negate(),iso:a.clone().multiplyScalar(1.2).add(o.clone()).add(n.clone()).normalize()}}function Ue(e){let{scene:n,perspective:t,controls:r,onActiveCameraChange:i}=e,o=(_nullishCoalesce(e.up, () => (t.up))).clone().normalize(),a=Mt(o),s=new z.OrthographicCamera(-1,1,1,-1,t.near,t.far);s.up.copy(o);let l="perspective",c=t.aspect,d=()=>l==="perspective"?t:s,m=null,u=()=>{_optionalChain([m, 'optionalAccess', _5 => _5.cancel, 'call', _6 => _6()]),m=null},f=()=>{let y=(l==="orthographic"?s:t).position.distanceTo(r.target)*Math.tan(t.fov*Math.PI/360),x=y*c;s.left=-x,s.right=x,s.top=y,s.bottom=-y,s.near=t.near,s.far=t.far,s.updateProjectionMatrix()},b=p=>{if(p!==l){if(u(),p==="orthographic")s.position.copy(t.position),s.up.copy(t.up),s.lookAt(r.target),s.zoom=1,f();else{let y=(s.top-s.bottom)/(2*s.zoom)/Math.tan(t.fov*Math.PI/360),x=s.position.clone().sub(r.target);x.lengthSq()<1e-12&&x.copy(o),x.normalize(),t.position.copy(r.target).add(x.multiplyScalar(y))}l=p,r.object=d(),r.update(),i(d())}},T=(p,v,y,x)=>{let A=t.fov*(Math.PI/180),B=v/(2*Math.tan(A/2))*1.5,G=Ct(y,o),F=p.clone().add(G.clone().multiplyScalar(B)),Y=d();l==="orthographic"&&(s.zoom=1),u(),x?m=St(Y,r,F,p,()=>{l==="orthographic"&&f()}):(Y.position.copy(F),r.target.copy(p),l==="orthographic"&&f(),r.update())},R=(p,v=!0)=>{let y=re(n),x=y.isEmpty()?r.target.clone():y.getCenter(new z.Vector3),A=y.isEmpty()?new z.Vector3(1,1,1):y.getSize(new z.Vector3),B=Math.max(A.x,A.y,A.z)||1;T(x,B,p,v)};return{getActiveCamera:d,getProjection:()=>l,setProjection:b,toggleProjection:()=>(b(l==="perspective"?"orthographic":"perspective"),l),setView:(p,v=!0)=>{R(a[p],v)},setViewDirection:R,frameBounds:(p,v=!0)=>{if(p.isEmpty())return;let y=p.getCenter(new z.Vector3),x=p.getSize(new z.Vector3),A=Math.max(x.x,x.y,x.z)||1,B=d().position.clone().sub(r.target);B.lengthSq()<1e-12&&B.copy(a.iso),T(y,A,B.normalize(),v)},setRotateEnabled:p=>{r.enableRotate=p},isRotateEnabled:()=>r.enableRotate,updateAspect:(p,v)=>{c=v===0?c:p/v,l==="orthographic"&&f()},dispose:u}}function Ct(e,n){let t=n.clone().normalize(),r=e.clone().normalize();if(Math.abs(r.dot(t))<.9999)return e;let i=Math.abs(t.dot(new z.Vector3(0,0,1)))>.9?new z.Vector3(0,1,0):new z.Vector3(0,0,1),o=new z.Vector3().crossVectors(t,i).normalize(),a=.5*Math.PI/180;return r.multiplyScalar(Math.cos(a)).add(o.multiplyScalar(Math.sin(a))).normalize()}var At=e=>1-Math.pow(1-e,3);function St(e,n,t,r,i,o=250){let a=e.position.clone(),s=n.target.clone(),l=performance.now(),c=null,d=()=>{c=null;let m=At(Math.min((performance.now()-l)/o,1));e.position.lerpVectors(a,t,m),n.target.lerpVectors(s,r,m),i(),n.update(),m<1&&(c=requestAnimationFrame(d))};return c=requestAnimationFrame(d),{cancel:()=>{c!==null&&(cancelAnimationFrame(c),c=null)}}}var Lt=`
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 _chunkCUQQ3ZBVcjs = require('./chunk-CUQQ3ZBV.cjs');var Rt={};_chunkCUQQ3ZBVcjs.a.call(void 0, Rt,{CONCRETE_MATERIAL:()=>De,EMISSIVE_MATERIAL:()=>Le,GLASS_MATERIAL:()=>Pe,METAL_MATERIAL:()=>Ie,PLASTIC_MATERIAL:()=>Oe,RUBBER_MATERIAL:()=>Ve,SHARED_MATERIALS:()=>ge,WOOD_MATERIAL:()=>Be});var _three = require('three'); var O = _interopRequireWildcard(_three); var k = _interopRequireWildcard(_three); var z = _interopRequireWildcard(_three); var U = _interopRequireWildcard(_three); var W = _interopRequireWildcard(_three); var oe = _interopRequireWildcard(_three); var We = _interopRequireWildcard(_three); var D = _interopRequireWildcard(_three); var fe = _interopRequireWildcard(_three); var E = _interopRequireWildcard(_three); var $ = _interopRequireWildcard(_three); var P = _interopRequireWildcard(_three);var Le=new O.MeshPhysicalMaterial({color:0,emissive:new O.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:O.FrontSide,dithering:!0}),Ie=new O.MeshPhysicalMaterial({color:new O.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:O.FrontSide,dithering:!0}),De=new O.MeshPhysicalMaterial({color:new O.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:O.FrontSide,dithering:!0}),Oe=new O.MeshPhysicalMaterial({color:new O.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:O.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Pe=new O.MeshPhysicalMaterial({color:new O.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,depthWrite:!1,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:O.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Ve=new O.MeshPhysicalMaterial({color:new O.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:O.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Be=new O.MeshPhysicalMaterial({color:new O.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:O.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),ge=new Set([Le,Ie,De,Oe,Pe,Ve,Be]);var q={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function Dr(e,n,t,r,i){if(wt(e),n.length===0)return;n.forEach(d=>{e.add(d)});let o=ye(n),a=o.getCenter(new k.Vector3),s=o.getSize(new k.Vector3),l=Math.max(s.x,s.y,s.z);if(l/Math.min(s.x||1,s.y||1,s.z||1)>q.SCALE_RATIO_THRESHOLD||l>q.HUGE_THRESHOLD?(t.near=l*q.NEAR_PLANE_FACTOR.TINY,t.far=l*q.FAR_PLANE_FACTOR.HUGE):l>q.LARGE_THRESHOLD?(t.near=l*q.NEAR_PLANE_FACTOR.SMALL,t.far=l*q.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,l*q.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,l*q.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),!i){let d=l*q.INITIAL_DISTANCE_MULTIPLIER;t.position.set(a.x+d*.8,a.y+d,a.z+d*1.2),r.target.copy(a),r.update()}}function Fe(e){if(!e||typeof e!="string")return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Invalid color input: ${e}, using white`),new k.Color(16777215);let n=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(n))try{let r=n.startsWith("#")?n:`#${n}`;return new k.Color(r)}catch (e2){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Invalid hex color: ${e}, using white`),new k.Color(16777215)}if(n.includes(",")){let r=n.split(",").map(i=>parseInt(i.trim(),10));if(r.length===3&&r.every(i=>!isNaN(i)&&i>=0&&i<=255))return new k.Color(r[0]/255,r[1]/255,r[2]/255)}let t=n.toLowerCase();return t in k.Color.NAMES?new k.Color(k.Color.NAMES[t]):(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Invalid color string: ${e}, using white`),new k.Color(16777215))}function ke(e,n,t="z"){e.forEach(r=>{r.position[t]-=n})}function ye(e){let n=new k.Box3;return e.length===0||e.forEach(t=>{t.updateMatrixWorld(!0);let r=new k.Box3().setFromObject(t);n.union(r)}),n}var vt=new Set(["grid","floor","label-layer","measure"]);function xt(e){let n=e;for(;n;){if(typeof n.userData.id=="string"&&vt.has(n.userData.id))return!0;n=n.parent}return!1}function re(e){e.updateMatrixWorld(!0);let n=new k.Box3;return e.traverse(t=>{let r=t;t.visible&&!xt(t)&&r.geometry&&n.expandByObject(t)}),n}var Ht=new Set(["floor","grid","label-layer"]);function wt(e){[...e.children].forEach(t=>{Ht.has(t.userData.id)||t.userData.source!=="user"&&(t.traverse(r=>{let i=r;if(!i.geometry&&!i.material)return;_optionalChain([i, 'access', _2 => _2.geometry, 'optionalAccess', _3 => _3.dispose, 'call', _4 => _4()]);let o=i.material;if(!o)return;(Array.isArray(o)?o:[o]).forEach(s=>{if(!ge.has(s)){for(let l of Object.values(s))l instanceof k.Texture&&l.dispose();s.dispose()}})}),t.removeFromParent())})}function Ct(e){let n=e.clone().normalize(),t=new z.Vector3(0,0,1),r=new z.Vector3(0,1,0),i=Math.abs(n.dot(t))>.9?r:t,o=new z.Vector3().crossVectors(n,i).normalize(),a=new z.Vector3().crossVectors(o,n).normalize();return{top:n.clone(),bottom:n.clone().negate(),front:a.clone(),back:a.clone().negate(),right:o.clone(),left:o.clone().negate(),iso:a.clone().multiplyScalar(1.2).add(o.clone()).add(n.clone()).normalize()}}function Ue(e){let{scene:n,perspective:t,controls:r,onActiveCameraChange:i}=e,o=(_nullishCoalesce(e.up, () => (t.up))).clone().normalize(),a=Ct(o),s=new z.OrthographicCamera(-1,1,1,-1,t.near,t.far);s.up.copy(o);let l="perspective",c=t.aspect,d=()=>l==="perspective"?t:s,m=null,u=()=>{_optionalChain([m, 'optionalAccess', _5 => _5.cancel, 'call', _6 => _6()]),m=null},f=()=>{let y=(l==="orthographic"?s:t).position.distanceTo(r.target)*Math.tan(t.fov*Math.PI/360),H=y*c;s.left=-H,s.right=H,s.top=y,s.bottom=-y,s.near=t.near,s.far=t.far,s.updateProjectionMatrix()},b=p=>{if(p!==l){if(u(),p==="orthographic")s.position.copy(t.position),s.up.copy(t.up),s.lookAt(r.target),s.zoom=1,f();else{let y=(s.top-s.bottom)/(2*s.zoom)/Math.tan(t.fov*Math.PI/360),H=s.position.clone().sub(r.target);H.lengthSq()<1e-12&&H.copy(o),H.normalize(),t.position.copy(r.target).add(H.multiplyScalar(y))}l=p,r.object=d(),r.update(),i(d())}},T=(p,v,y,H)=>{let A=t.fov*(Math.PI/180),V=v/(2*Math.tan(A/2))*1.5,G=Mt(y,o),F=p.clone().add(G.clone().multiplyScalar(V)),Y=d();l==="orthographic"&&(s.zoom=1),u(),H?m=St(Y,r,F,p,()=>{l==="orthographic"&&f()}):(Y.position.copy(F),r.target.copy(p),l==="orthographic"&&f(),r.update())},R=(p,v=!0)=>{let y=re(n),H=y.isEmpty()?r.target.clone():y.getCenter(new z.Vector3),A=y.isEmpty()?new z.Vector3(1,1,1):y.getSize(new z.Vector3),V=Math.max(A.x,A.y,A.z)||1;T(H,V,p,v)};return{getActiveCamera:d,getProjection:()=>l,setProjection:b,toggleProjection:()=>(b(l==="perspective"?"orthographic":"perspective"),l),setView:(p,v=!0)=>{R(a[p],v)},setViewDirection:R,frameBounds:(p,v=!0)=>{if(p.isEmpty())return;let y=p.getCenter(new z.Vector3),H=p.getSize(new z.Vector3),A=Math.max(H.x,H.y,H.z)||1,V=d().position.clone().sub(r.target);V.lengthSq()<1e-12&&V.copy(a.iso),T(y,A,V.normalize(),v)},setRotateEnabled:p=>{r.enableRotate=p},isRotateEnabled:()=>r.enableRotate,updateAspect:(p,v)=>{c=v===0?c:p/v,l==="orthographic"&&f()},dispose:u}}function Mt(e,n){let t=n.clone().normalize(),r=e.clone().normalize();if(Math.abs(r.dot(t))<.9999)return e;let i=Math.abs(t.dot(new z.Vector3(0,0,1)))>.9?new z.Vector3(0,1,0):new z.Vector3(0,0,1),o=new z.Vector3().crossVectors(t,i).normalize(),a=.5*Math.PI/180;return r.multiplyScalar(Math.cos(a)).add(o.multiplyScalar(Math.sin(a))).normalize()}var At=e=>1-Math.pow(1-e,3);function St(e,n,t,r,i,o=250){let a=e.position.clone(),s=n.target.clone(),l=performance.now(),c=null,d=()=>{c=null;let m=At(Math.min((performance.now()-l)/o,1));e.position.lerpVectors(a,t,m),n.target.lerpVectors(s,r,m),i(),n.update(),m<1&&(c=requestAnimationFrame(d))};return c=requestAnimationFrame(d),{cancel:()=>{c!==null&&(cancelAnimationFrame(c),c=null)}}}var Lt=`
2
2
  varying vec3 vWorldPos;
3
3
  void main() {
4
4
  vec4 world = modelMatrix * vec4(position, 1.0);
@@ -50,13 +50,13 @@
50
50
  if (alpha < 0.001) discard;
51
51
  gl_FragColor = vec4(color, alpha);
52
52
  }
53
- `;function ze(e={}){let{cellSize:n=1,majorEvery:t=10,cellColor:r=8947848,majorColor:i=4473924,fadeDistance:o=100,plane:a="y"}=e,s=a==="y"?new U.Vector2(0,2):a==="z"?new U.Vector2(0,1):new U.Vector2(1,2),l=o*2.5,c=new U.PlaneGeometry(l,l);a==="y"?c.rotateX(-Math.PI/2):a==="x"&&c.rotateY(Math.PI/2);let d=new U.ShaderMaterial({vertexShader:Lt,fragmentShader:It,transparent:!0,depthWrite:!1,side:U.DoubleSide,uniforms:{uAxes:{value:s},uCell:{value:n},uMajor:{value:t},uCellColor:{value:new U.Color(r)},uMajorColor:{value:new U.Color(i)},uCenter:{value:new U.Vector3},uFade:{value:o}}}),m=new U.Mesh(c,d);m.name="grid",m.userData.id="grid",m.renderOrder=-1;let u=new U.Vector3;return{object:m,update:f=>{a==="y"?(m.position.set(f.x,0,f.z),u.set(f.x,0,f.z)):a==="z"?(m.position.set(f.x,f.y,0),u.set(f.x,f.y,0)):(m.position.set(0,f.y,f.z),u.set(0,f.y,f.z)),d.uniforms.uCenter.value.copy(u)},setVisible:f=>{m.visible=f},dispose:()=>{m.removeFromParent(),c.dispose(),d.dispose()}}}var _ViewHelperjs = require('three/addons/helpers/ViewHelper.js');function _e(e){let{camera:n,domElement:t,controller:r}=e,i=new (0, _ViewHelperjs.ViewHelper)(n,t);i.setLabels("X","Y","Z");let o=!0,a=128,s=new W.Raycaster,l=new W.OrthographicCamera(-2,2,2,-2,0,4);l.position.set(0,0,2),l.updateMatrixWorld();let c={posX:new W.Vector3(1,0,0),negX:new W.Vector3(-1,0,0),posY:new W.Vector3(0,1,0),negY:new W.Vector3(0,-1,0),posZ:new W.Vector3(0,0,1),negZ:new W.Vector3(0,0,-1)},d=u=>{let f=t.getBoundingClientRect(),b=f.left+t.offsetWidth-a-i.location.right,T=f.top+t.offsetHeight-a-i.location.bottom,R=new W.Vector2((u.clientX-b)/a*2-1,-((u.clientY-T)/a)*2+1);if(Math.abs(R.x)>1||Math.abs(R.y)>1)return null;i.quaternion.copy(n.quaternion).invert(),i.updateMatrixWorld(),s.setFromCamera(R,l);let M=s.intersectObjects(i.children,!1);for(let h of M){let w=_optionalChain([h, 'access', _7 => _7.object, 'access', _8 => _8.userData, 'optionalAccess', _9 => _9.type]);if(typeof w=="string"&&w in c)return w}return null};return{render:u=>{if(!o)return;let f=u.autoClear;u.autoClear=!1,i.render(u),u.autoClear=f},update:()=>{},handleClick:u=>{if(!o)return!1;let f=d(u);return f?(r.getProjection()==="orthographic"&&r.setProjection("perspective"),r.setViewDirection(c[f],!1),!0):!1},isAnimating:!1,setVisible:u=>{o=u},isVisible:()=>o,dispose:()=>i.dispose()}}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 ue="edge-overlay",Bt=2236962,Vt=1.5,Ft=30,be=new WeakMap;function Ge(e,n={}){let t=new oe.Color(_nullishCoalesce(n.color, () => (Bt))),r=_nullishCoalesce(n.width, () => (Vt)),i=_nullishCoalesce(n.thresholdAngle, () => (Ft)),o=[];return e.traverse(a=>{if(!(a instanceof oe.Mesh)||a.userData.id==="floor"||a.userData.id==="grid"||a.userData.kind===ue||a.children.some(l=>_optionalChain([l, 'access', _10 => _10.userData, 'optionalAccess', _11 => _11.kind])===ue)||!a.geometry)return;let s=zt(a.geometry,t,r,i);a.add(s),o.push(s)}),o}function kt(e,n){let t=be.get(e);t||(t=new Map,be.set(e,t));let r=t.get(n);if(!r){let i=new oe.EdgesGeometry(e,n),o=new _LineSegmentsGeometryjs.LineSegmentsGeometry;o.setPositions(i.attributes.position.array),i.dispose(),r={geometry:o,refCount:0},t.set(n,r)}return r.refCount+=1,r.geometry}function Ut(e){let n=e.userData,t=n.edgeSource&&be.get(n.edgeSource),r=n.edgeThresholdAngle!=null?_optionalChain([t, 'optionalAccess', _12 => _12.get, 'call', _13 => _13(n.edgeThresholdAngle)]):void 0;if(!r||r.geometry!==e.geometry){e.geometry.dispose();return}r.refCount-=1,r.refCount<=0&&(r.geometry.dispose(),t.delete(n.edgeThresholdAngle))}function zt(e,n,t,r){let i=kt(e,r),o=new (0, _LineMaterialjs.LineMaterial)({color:n});o.linewidth=t,o.polygonOffset=!0,o.polygonOffsetFactor=-1,o.polygonOffsetUnits=-4;let a=new (0, _LineSegments2js.LineSegments2)(i,o);return a.userData.kind=ue,a.userData.edgeSource=e,a.userData.edgeThresholdAngle=r,a.raycast=()=>{},a}function _t(e){return _optionalChain([e, 'access', _14 => _14.userData, 'optionalAccess', _15 => _15.kind])===ue}function jr(e){let n=[];e.traverse(t=>{t instanceof _LineSegments2js.LineSegments2&&_t(t)&&n.push(t)});for(let t of n)Ut(t),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 _SMAAPassjs = require('three/addons/postprocessing/SMAAPass.js');var _OutputPassjs = require('three/addons/postprocessing/OutputPass.js');function Ne(e,n,t,r,i,o){let a=new (0, _EffectComposerjs.EffectComposer)(e),s=new (0, _RenderPassjs.RenderPass)(n,t);a.addPass(s);let l=new (0, _GTAOPassjs.GTAOPass)(n,t,r,i);l.blendIntensity=_nullishCoalesce(o.aoIntensity, () => (1)),l.updateGtaoMaterial({screenSpaceRadius:!0}),a.addPass(l);let c=new _SMAAPassjs.SMAAPass;a.addPass(c);let d=new _OutputPassjs.OutputPass;a.addPass(d),e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure;let m=_nullishCoalesce(o.aoPixelRatio, () => (1));return a.setSize(r,i),{render:u=>a.render(u),setSize:(u,f,b)=>{a.setPixelRatio(Math.min(b,m)),a.setSize(u,f)},setCamera:u=>{s.camera=u,l.camera=u;let f=u.isPerspectiveCamera?1:0;l.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==f&&(l.gtaoMaterial.defines.PERSPECTIVE_CAMERA=f,l.gtaoMaterial.needsUpdate=!0)},dispose:()=>{a.dispose(),l.dispose(),c.dispose(),d.dispose()}}}var _CSS2DRendererjs = require('three/addons/renderers/CSS2DRenderer.js');function $e(e,n){let t=new _CSS2DRendererjs.CSS2DRenderer,r=t.domElement;r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.overflow="hidden",r.style.pointerEvents="none",r.style.zIndex="30",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(r);let i={width:e.clientWidth||1,height:e.clientHeight||1};t.setSize(i.width,i.height);let o=new We.Group;o.name="label-layer",o.userData.id="label-layer",n.add(o);let a=new Set;return{addLabel:(l,c,d)=>{let m=document.createElement("div");m.textContent=l,d?m.className=d:Object.assign(m.style,{padding:"2px 6px",borderRadius:"4px",background:"rgba(20, 20, 20, 0.78)",color:"#fff",font:"12px/1.3 system-ui, sans-serif",whiteSpace:"pre",textAlign:"center",userSelect:"none"}),m.style.pointerEvents="none";let u=new (0, _CSS2DRendererjs.CSS2DObject)(m);return u.position.copy(c),o.add(u),a.add(u),{object:u,setPosition:f=>u.position.copy(f),setText:f=>{m.textContent=f},remove:()=>{u.removeFromParent(),m.remove(),a.delete(u)}}},render:(l,c)=>t.render(l,c),setSize:(l,c)=>t.setSize(l,c),dispose:()=>{a.forEach(l=>{l.removeFromParent(),l.element.remove()}),a.clear(),o.removeFromParent(),r.remove()}}}var _Line2js = require('three/addons/lines/Line2.js');var _LineGeometryjs = require('three/addons/lines/LineGeometry.js');var Jt=12,Qt=16763904,Ye=.015,Xe={Millimeters:{metersPerUnit:1/1e3,suffix:"mm"},Centimeters:{metersPerUnit:1/100,suffix:"cm"},Meters:{metersPerUnit:1,suffix:"m"},Inches:{metersPerUnit:1/39.37,suffix:"in"},Feet:{metersPerUnit:1/3.28084,suffix:"ft"}};function en(e){let n=e&&Xe[e]||Xe.Meters;return t=>`${(t/n.metersPerUnit).toPrecision(3)} ${n.suffix}`}function tn(e,n){if(e.isOrthographicCamera){let r=e;return Math.abs(r.top-r.bottom)/(r.zoom||1)*Ye}return((n?e.position.distanceTo(n):e.position.length())||1)*Ye}function nn(e){let n=e.object;if(n instanceof D.Mesh)return e.face?[e.face.a,e.face.b,e.face.c]:null;if(n instanceof D.Points)return e.index!=null?[e.index]:null;if(n instanceof D.Line){if(e.index==null)return null;let t=n.geometry.index;return t?e.index+1>=t.count?null:[t.getX(e.index),t.getX(e.index+1)]:[e.index,e.index+1]}return null}function rn(e,n,t,r){let i=e.point.clone(),o=e.object,a=nn(e);if(!a||!o.geometry)return i;let s=o.geometry.attributes.position;if(!s)return i;let l=u=>{let f=u.clone().project(n);return new D.Vector2((f.x+1)/2*t.width,(1-f.y)/2*t.height)},c=l(i),d=i,m=r;for(let u of a){if(u>=s.count)continue;let b=new D.Vector3().fromBufferAttribute(s,u).applyMatrix4(o.matrixWorld),T=l(b).distanceTo(c);T<m&&(m=T,d=b)}return d}function qe(e){let{canvas:n,scene:t,getActiveCamera:r,getViewTarget:i,labelLayer:o,options:a={}}=e,s=_nullishCoalesce(a.snapPixels, () => (Jt)),l=new D.Color(_nullishCoalesce(a.color, () => (Qt))),c=en(a.displayUnit),d=(S,H)=>`${c(S)}
54
- \u0394x ${c(H.x)} \u0394y ${c(H.y)} \u0394z ${c(H.z)}`,m=_nullishCoalesce(a.format, () => (d)),u=new D.Raycaster,f=new D.Vector2,b=!1,T=[],R=[],M=null,h=null,w=new D.PointsMaterial({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),L=new D.PointsMaterial({color:l,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),p=null,v=S=>{if(!S){p&&(p.visible=!1);return}if(!p){let H=new D.BufferGeometry;H.setAttribute("position",new D.Float32BufferAttribute([0,0,0],3)),p=new D.Points(H,L),p.renderOrder=1e3,p.userData.id="measure",p.raycast=()=>{},t.add(p)}p.position.copy(S),p.visible=!0},y=S=>{let H=new D.BufferGeometry;H.setAttribute("position",new D.Float32BufferAttribute([S.x,S.y,S.z],3));let j=new D.Points(H,w);return j.renderOrder=999,j.userData.id="measure",j.raycast=()=>{},t.add(j),j},x=()=>{T.length=0,R.forEach(S=>{S.geometry.dispose(),S.removeFromParent()}),R.length=0,M&&(M.geometry.dispose(),M.material.dispose(),M.removeFromParent(),M=null),_optionalChain([h, 'optionalAccess', _16 => _16.remove, 'call', _17 => _17()]),h=null},A=()=>{if(T.length!==2)return;let[S,H]=T,j=new _LineGeometryjs.LineGeometry;j.setPositions([S.x,S.y,S.z,H.x,H.y,H.z]);let K=new (0, _LineMaterialjs.LineMaterial)({color:l});K.linewidth=2,K.depthTest=!1,M=new (0, _Line2js.Line2)(j,K),M.renderOrder=998,M.userData.id="measure",M.raycast=()=>{},t.add(M);let Q=S.clone().add(H).multiplyScalar(.5),ee=new D.Vector3(Math.abs(H.x-S.x),Math.abs(H.y-S.y),Math.abs(H.z-S.z));h=o.addLabel(m(S.distanceTo(H),ee),Q,a.labelClassName)},B=S=>{let H=n.getBoundingClientRect();f.x=(S.clientX-H.left)/H.width*2-1,f.y=-((S.clientY-H.top)/H.height)*2+1;let j=r();u.setFromCamera(f,j);let K=tn(j,_optionalChain([i, 'optionalCall', _18 => _18()]));u.params.Line.threshold=K,u.params.Points.threshold=K;let Q=u.intersectObjects(t.children,!0).filter(ee=>ee.object.userData.id!=="measure"&&ee.object.userData.id!=="grid");return Q.length===0?null:rn(Q[0],j,{width:H.width,height:H.height},s)},G=null,F=0,Y=()=>{F&&(cancelAnimationFrame(F),F=0),G=null};return{setEnabled:S=>{b=S,S||(Y(),x(),v(null))},isEnabled:()=>b,handleClick:S=>{if(!b)return!1;T.length===2&&x();let H=B(S);return H===null||(T.push(H),R.push(y(H)),T.length===2&&A()),!0},handleMove:S=>{b&&(G=S,!F&&(F=requestAnimationFrame(()=>{F=0;let H=G;G=null,!(!b||!H)&&v(B(H))})))},clear:x,dispose:()=>{Y(),x(),p&&(p.geometry.dispose(),p.removeFromParent(),p=null),w.dispose(),L.dispose()}}}var on=64,an=256,X=new Map,ae=new Map,de=0,pe=class extends Error{constructor(n){super(`Texture load for ${n} resolved after clearTextureCache(); texture disposed.`),this.name="StaleTextureLoadError"}},me=1;function Ze(e){me=Math.max(1,e);for(let n of X.values())n.anisotropy!==me&&(n.anisotropy=me,n.needsUpdate=!0)}function Ke(e,n){let t=sn(n),r=X.get(t);if(r){X.delete(t),X.set(t,r),e.map=r,e.needsUpdate=!0;return}typeof document>"u"||un(n,t).then(i=>{e.map=i,e.needsUpdate=!0}).catch(i=>{i instanceof pe||_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Failed to load material texture ${n}:`,i)})}function ro(){de++;for(let e of X.values())e.dispose();X.clear(),ae.clear()}function sn(e){return e.length<=an?e:`data-uri:${ln(e).toString(16)}:${e.length}`}function ln(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return n>>>0}function cn(e,n){for(X.set(e,n);X.size>on;){let t=X.keys().next().value,r=X.get(t);X.delete(t),r.dispose()}}function un(e,n){let t=ae.get(n);if(!t){let r=de;t=new Promise((i,o)=>{new fe.TextureLoader().load(e,a=>{if(r!==de){a.dispose(),o(new pe(e));return}a.colorSpace=fe.SRGBColorSpace,a.anisotropy=me,cn(n,a),ae.delete(n),i(a)},void 0,a=>{r===de&&ae.delete(n),o(a)})}),ae.set(n,t)}return t}var _OrbitControlsjs = require('three/addons/controls/OrbitControls.js');var _HDRLoaderjs = require('three/addons/loaders/HDRLoader.js');var ie=new E.Vector3(0,0,1),pn="technical",Te={studio:{toneMapping:E.ACESFilmicToneMapping,toneMappingExposure:1,envMapIntensity:1.3,environmentIntensity:1.2,hemisphereIntensity:1,ambientIntensity:.3,cullBackfaces:!1,ambientOcclusion:!1},technical:{toneMapping:E.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:.5,environmentIntensity:1,hemisphereIntensity:0,ambientIntensity:1,cullBackfaces:!1,ambientOcclusion:!1},showcase:{toneMapping:E.ACESFilmicToneMapping,toneMappingExposure:1.05,envMapIntensity:1.6,environmentIntensity:1.35,hemisphereIntensity:1.2,ambientIntensity:.25,cullBackfaces:!1,ambientOcclusion:!1}};function fn(e){let n=Te[e];return{envMapIntensity:n.envMapIntensity,cullBackfaces:n.cullBackfaces}}function En(e){let n=Math.abs(e.x),t=Math.abs(e.y),r=Math.abs(e.z);return r>=n&&r>=t?"z":t>=n&&t>=r?"y":"x"}var yo=function(e,n){let t=hn(n||{}),r=_optionalChain([t, 'access', _19 => _19.environment, 'optionalAccess', _20 => _20.sceneUp])||ie,i=_nullishCoalesce(t.render.pixelRatio, () => (Math.min(window.devicePixelRatio,2))),o=yn(t),a=wn(t,e);a.up.copy(r);let s=xn(e,t,i);Ze(s.capabilities.getMaxAnisotropy());let l=Mn(a,e,t),c=Ue({scene:o,perspective:a,controls:l,onActiveCameraChange:()=>{},up:r}),d=()=>c.getActiveCamera(),m=!1;Tn(o,t,()=>m);let u=Rn(o,t),f=u.sun,b=()=>{f&&gn(f,re(o))};_optionalChain([t, 'access', _21 => _21.floor, 'optionalAccess', _22 => _22.enabled])&&vn(o,t);let T=t.grid.enabled?ze({cellSize:t.grid.cellSize,majorEvery:t.grid.majorEvery,cellColor:t.grid.cellColor,majorColor:t.grid.majorColor,fadeDistance:t.grid.fadeDistance,plane:t.grid.plane}):null;T&&o.add(T.object);let R=t.gizmo.enabled?_e({camera:a,domElement:e,controller:c}):null,M=_nullishCoalesce(e.parentElement, () => (e)),h=t.measure.enabled?$e(M,o):null,w=t.measure.enabled&&h?qe({canvas:e,scene:o,getActiveCamera:d,labelLayer:h,options:{snapPixels:t.measure.snapPixels,color:t.measure.color,labelClassName:t.measure.labelClassName,displayUnit:t.measure.displayUnit,format:t.measure.format}}):null,L=t.events.enableEventHandlers!==!1?Hn(e,o,c,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},p=5,v=0,y=0,x=g=>{v=g.clientX,y=g.clientY},A=g=>Math.hypot(g.clientX-v,g.clientY-y)>p,B=g=>{if(!A(g)){if(_optionalChain([w, 'optionalAccess', _23 => _23.handleClick, 'call', _24 => _24(g)])){g.stopImmediatePropagation();return}_optionalChain([R, 'optionalAccess', _25 => _25.handleClick, 'call', _26 => _26(g)])&&g.stopImmediatePropagation()}};(R||w)&&(e.addEventListener("mousedown",x,{capture:!0}),e.addEventListener("click",B,{capture:!0}));let G=g=>_optionalChain([w, 'optionalAccess', _27 => _27.handleMove, 'call', _28 => _28(g)]);w&&e.addEventListener("mousemove",G,{passive:!0});let F=g=>{Ge(g,{color:t.edges.color,width:t.edges.width,thresholdAngle:t.edges.thresholdAngle})},Y=e.parentElement,J=()=>Y?{width:Y.clientWidth,height:Y.clientHeight}:{width:window.innerWidth,height:window.innerHeight},V=null,S=()=>{let{width:g,height:I}=J(),N=Ne(s,o,d(),Math.max(1,g),Math.max(1,I),{toneMapping:_nullishCoalesce(t.render.toneMapping, () => (E.NeutralToneMapping)),toneMappingExposure:_nullishCoalesce(t.render.toneMappingExposure, () => (1)),aoIntensity:t.render.aoIntensity,aoPixelRatio:t.render.aoPixelRatio});return N.setSize(Math.max(1,g),Math.max(1,I),i),N},H=g=>{g&&!V?V=S():!g&&V&&(V.dispose(),V=null)};t.render.ambientOcclusion&&(V=S());let j=g=>{g.ambientIntensity!==void 0&&(u.ambient.intensity=g.ambientIntensity),g.hemisphereIntensity!==void 0&&!u.hemisphere&&g.hemisphereIntensity>0&&(u.hemisphere=new E.HemisphereLight(_nullishCoalesce(g.hemisphereSkyColor, () => (t.lighting.hemisphereSkyColor)),_nullishCoalesce(g.hemisphereGroundColor, () => (t.lighting.hemisphereGroundColor)),g.hemisphereIntensity),u.hemisphere.position.copy(_nullishCoalesce(t.environment.sceneUp, () => (ie))),o.add(u.hemisphere)),u.hemisphere&&(g.hemisphereIntensity!==void 0&&(u.hemisphere.intensity=g.hemisphereIntensity),g.hemisphereSkyColor!==void 0&&u.hemisphere.color.set(g.hemisphereSkyColor),g.hemisphereGroundColor!==void 0&&u.hemisphere.groundColor.set(g.hemisphereGroundColor))},K=g=>{t.environment.environmentIntensity=g,o.environmentIntensity=g},Q=g=>{t.render.toneMappingExposure=g,s.toneMappingExposure=g,V&&(H(!1),H(!0))},ee=g=>{t.render.aoIntensity=g,V&&(H(!1),H(!0))},mt=g=>{let I=Te[g];Me=g,s.toneMapping=I.toneMapping,s.toneMappingExposure=I.toneMappingExposure,t.render.toneMapping=I.toneMapping,t.render.toneMappingExposure=I.toneMappingExposure,j({hemisphereIntensity:I.hemisphereIntensity,ambientIntensity:I.ambientIntensity}),K(I.environmentIntensity),V&&H(!1),H(I.ambientOcclusion),o.traverse(N=>{if(N.userData.source!=="compute")return;let ce=N,bt=Array.isArray(ce.material)?ce.material:ce.material?[ce.material]:[];for(let Ae of bt)"envMapIntensity"in Ae&&(Ae.envMapIntensity=I.envMapIntensity)})},Me=t.look,pt=()=>fn(Me),{animate:ft,dispose:Et}=bn(s,o,a,d,c,l,J,i,t.events.onFrame,T,R,()=>V,h);ft(),o.up.set(r.x,r.y,r.z),b();let Ce=g=>{g.traverse(I=>{let N=I;!N.geometry&&!N.material||(_optionalChain([N, 'access', _29 => _29.geometry, 'optionalAccess', _30 => _30.dispose, 'call', _31 => _31()]),Array.isArray(N.material)?N.material.forEach(Ee):N.material&&Ee(N.material))})},ht=g=>{g.userData.source="user",o.add(g)},gt=g=>{g.removeFromParent(),Ce(g)},yt=()=>{o.children.filter(I=>I.userData.source==="user").forEach(I=>{I.removeFromParent(),Ce(I)})};return{scene:o,camera:a,controls:l,renderer:s,cameraController:c,grid:T,gizmo:R,measureTool:w,applyEdges:F,setAmbientOcclusion:H,setLook:mt,setFillLights:j,setEnvironmentIntensity:K,setToneMappingExposure:Q,setAoIntensity:ee,getMaterialAppearance:pt,updateShadowBounds:b,dispose:()=>{m||(m=!0,Et(),L.dispose(),(R||w)&&(e.removeEventListener("mousedown",x,{capture:!0}),e.removeEventListener("click",B,{capture:!0})),w&&e.removeEventListener("mousemove",G),_optionalChain([w, 'optionalAccess', _32 => _32.dispose, 'call', _33 => _33()]),_optionalChain([h, 'optionalAccess', _34 => _34.dispose, 'call', _35 => _35()]),_optionalChain([R, 'optionalAccess', _36 => _36.dispose, 'call', _37 => _37()]),_optionalChain([T, 'optionalAccess', _38 => _38.dispose, 'call', _39 => _39()]),_optionalChain([V, 'optionalAccess', _40 => _40.dispose, 'call', _41 => _41()]),c.dispose(),l.dispose(),s.dispose(),s.forceContextLoss(),o.traverse(g=>{let I=g;!I.geometry&&!I.material||(_optionalChain([I, 'access', _42 => _42.geometry, 'optionalAccess', _43 => _43.dispose, 'call', _44 => _44()]),Array.isArray(I.material)?I.material.forEach(Ee):I.material&&Ee(I.material))}),_optionalChain([o, 'access', _45 => _45.environment, 'optionalAccess', _46 => _46.dispose, 'call', _47 => _47()]),o.background instanceof E.Texture&&o.background.dispose())},fitToView:L.fitToView,clearSelection:L.clearSelection,addUserGeometry:ht,removeUserGeometry:gt,clearUserGeometry:yt}};function hn(e){let n=e.sceneScale||"m",r={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[n],i=_nullishCoalesce(e.look, () => (pn)),o=Te[i];return{sceneScale:n,look:i,camera:{position:_optionalChain([e, 'access', _48 => _48.camera, 'optionalAccess', _49 => _49.position])||new E.Vector3(-r.cameraDistance,-r.cameraDistance,r.cameraDistance),fov:_optionalChain([e, 'access', _50 => _50.camera, 'optionalAccess', _51 => _51.fov])||20,near:_optionalChain([e, 'access', _52 => _52.camera, 'optionalAccess', _53 => _53.near])||r.near,far:_optionalChain([e, 'access', _54 => _54.camera, 'optionalAccess', _55 => _55.far])||r.far,target:_optionalChain([e, 'access', _56 => _56.camera, 'optionalAccess', _57 => _57.target])||new E.Vector3(0,0,0)},lighting:{enableSunlight:_nullishCoalesce(_optionalChain([e, 'access', _58 => _58.lighting, 'optionalAccess', _59 => _59.enableSunlight]), () => (!0)),sunlightIntensity:_nullishCoalesce(_optionalChain([e, 'access', _60 => _60.lighting, 'optionalAccess', _61 => _61.sunlightIntensity]), () => (1)),sunlightPosition:_optionalChain([e, 'access', _62 => _62.lighting, 'optionalAccess', _63 => _63.sunlightPosition])||new E.Vector3(r.lightDistance,r.lightDistance,r.lightHeight),ambientLightColor:_optionalChain([e, 'access', _64 => _64.lighting, 'optionalAccess', _65 => _65.ambientLightColor])||new E.Color(4210752),ambientLightIntensity:_nullishCoalesce(_optionalChain([e, 'access', _66 => _66.lighting, 'optionalAccess', _67 => _67.ambientLightIntensity]), () => (o.ambientIntensity)),sunlightColor:_optionalChain([e, 'access', _68 => _68.lighting, 'optionalAccess', _69 => _69.sunlightColor])||16777215,enableHemisphereLight:_nullishCoalesce(_optionalChain([e, 'access', _70 => _70.lighting, 'optionalAccess', _71 => _71.enableHemisphereLight]), () => (o.hemisphereIntensity>0)),hemisphereSkyColor:_nullishCoalesce(_optionalChain([e, 'access', _72 => _72.lighting, 'optionalAccess', _73 => _73.hemisphereSkyColor]), () => (14673663)),hemisphereGroundColor:_nullishCoalesce(_optionalChain([e, 'access', _74 => _74.lighting, 'optionalAccess', _75 => _75.hemisphereGroundColor]), () => (7036754)),hemisphereIntensity:_nullishCoalesce(_optionalChain([e, 'access', _76 => _76.lighting, 'optionalAccess', _77 => _77.hemisphereIntensity]), () => (o.hemisphereIntensity))},environment:{hdrPath:_optionalChain([e, 'access', _78 => _78.environment, 'optionalAccess', _79 => _79.hdrPath])||"/baseHDR.hdr",backgroundColor:_optionalChain([e, 'access', _80 => _80.environment, 'optionalAccess', _81 => _81.backgroundColor])||new E.Color(15790320),enableEnvironmentLighting:_nullishCoalesce(_optionalChain([e, 'access', _82 => _82.environment, 'optionalAccess', _83 => _83.enableEnvironmentLighting]), () => (!0)),sceneUp:_optionalChain([e, 'access', _84 => _84.environment, 'optionalAccess', _85 => _85.sceneUp])||ie,showEnvironment:_nullishCoalesce(_optionalChain([e, 'access', _86 => _86.environment, 'optionalAccess', _87 => _87.showEnvironment]), () => (!1)),environmentIntensity:_nullishCoalesce(_optionalChain([e, 'access', _88 => _88.environment, 'optionalAccess', _89 => _89.environmentIntensity]), () => (o.environmentIntensity))},floor:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _90 => _90.floor, 'optionalAccess', _91 => _91.enabled]), () => (!1)),size:_optionalChain([e, 'access', _92 => _92.floor, 'optionalAccess', _93 => _93.size])||r.floorSize,color:_optionalChain([e, 'access', _94 => _94.floor, 'optionalAccess', _95 => _95.color])||new E.Color(8421504),roughness:_nullishCoalesce(_optionalChain([e, 'access', _96 => _96.floor, 'optionalAccess', _97 => _97.roughness]), () => (.7)),metalness:_nullishCoalesce(_optionalChain([e, 'access', _98 => _98.floor, 'optionalAccess', _99 => _99.metalness]), () => (0)),receiveShadow:_nullishCoalesce(_optionalChain([e, 'access', _100 => _100.floor, 'optionalAccess', _101 => _101.receiveShadow]), () => (!0))},render:{enableShadows:_nullishCoalesce(_optionalChain([e, 'access', _102 => _102.render, 'optionalAccess', _103 => _103.enableShadows]), () => (!0)),shadowMapSize:_optionalChain([e, 'access', _104 => _104.render, 'optionalAccess', _105 => _105.shadowMapSize])||2048,antialias:_nullishCoalesce(_optionalChain([e, 'access', _106 => _106.render, 'optionalAccess', _107 => _107.antialias]), () => (!0)),pixelRatio:_optionalChain([e, 'access', _108 => _108.render, 'optionalAccess', _109 => _109.pixelRatio])||Math.min(window.devicePixelRatio,2),toneMapping:_nullishCoalesce(_optionalChain([e, 'access', _110 => _110.render, 'optionalAccess', _111 => _111.toneMapping]), () => (o.toneMapping)),toneMappingExposure:_nullishCoalesce(_optionalChain([e, 'access', _112 => _112.render, 'optionalAccess', _113 => _113.toneMappingExposure]), () => (o.toneMappingExposure)),preserveDrawingBuffer:_nullishCoalesce(_optionalChain([e, 'access', _114 => _114.render, 'optionalAccess', _115 => _115.preserveDrawingBuffer]), () => (!1)),ambientOcclusion:_nullishCoalesce(_optionalChain([e, 'access', _116 => _116.render, 'optionalAccess', _117 => _117.ambientOcclusion]), () => (o.ambientOcclusion)),aoIntensity:_nullishCoalesce(_optionalChain([e, 'access', _118 => _118.render, 'optionalAccess', _119 => _119.aoIntensity]), () => (1)),aoPixelRatio:_nullishCoalesce(_optionalChain([e, 'access', _120 => _120.render, 'optionalAccess', _121 => _121.aoPixelRatio]), () => (1))},controls:{enableDamping:_nullishCoalesce(_optionalChain([e, 'access', _122 => _122.controls, 'optionalAccess', _123 => _123.enableDamping]), () => (!1)),dampingFactor:_optionalChain([e, 'access', _124 => _124.controls, 'optionalAccess', _125 => _125.dampingFactor])||.05,autoRotate:_nullishCoalesce(_optionalChain([e, 'access', _126 => _126.controls, 'optionalAccess', _127 => _127.autoRotate]), () => (!1)),autoRotateSpeed:_optionalChain([e, 'access', _128 => _128.controls, 'optionalAccess', _129 => _129.autoRotateSpeed])||.5,enableZoom:_nullishCoalesce(_optionalChain([e, 'access', _130 => _130.controls, 'optionalAccess', _131 => _131.enableZoom]), () => (!0)),enablePan:_nullishCoalesce(_optionalChain([e, 'access', _132 => _132.controls, 'optionalAccess', _133 => _133.enablePan]), () => (!0)),minDistance:_optionalChain([e, 'access', _134 => _134.controls, 'optionalAccess', _135 => _135.minDistance])||r.minDistance,maxDistance:_optionalChain([e, 'access', _136 => _136.controls, 'optionalAccess', _137 => _137.maxDistance])||1/0},grid:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _138 => _138.grid, 'optionalAccess', _139 => _139.enabled]), () => (!1)),cellSize:_nullishCoalesce(_optionalChain([e, 'access', _140 => _140.grid, 'optionalAccess', _141 => _141.cellSize]), () => (1)),majorEvery:_nullishCoalesce(_optionalChain([e, 'access', _142 => _142.grid, 'optionalAccess', _143 => _143.majorEvery]), () => (10)),cellColor:_nullishCoalesce(_optionalChain([e, 'access', _144 => _144.grid, 'optionalAccess', _145 => _145.cellColor]), () => (8947848)),majorColor:_nullishCoalesce(_optionalChain([e, 'access', _146 => _146.grid, 'optionalAccess', _147 => _147.majorColor]), () => (4473924)),fadeDistance:_nullishCoalesce(_optionalChain([e, 'access', _148 => _148.grid, 'optionalAccess', _149 => _149.fadeDistance]), () => (100)),plane:_nullishCoalesce(_optionalChain([e, 'access', _150 => _150.grid, 'optionalAccess', _151 => _151.plane]), () => (En(_nullishCoalesce(_optionalChain([e, 'access', _152 => _152.environment, 'optionalAccess', _153 => _153.sceneUp]), () => (ie)))))},gizmo:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _154 => _154.gizmo, 'optionalAccess', _155 => _155.enabled]), () => (!1))},edges:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _156 => _156.edges, 'optionalAccess', _157 => _157.enabled]), () => (!1)),color:_nullishCoalesce(_optionalChain([e, 'access', _158 => _158.edges, 'optionalAccess', _159 => _159.color]), () => (2236962)),width:_nullishCoalesce(_optionalChain([e, 'access', _160 => _160.edges, 'optionalAccess', _161 => _161.width]), () => (1.5)),thresholdAngle:_nullishCoalesce(_optionalChain([e, 'access', _162 => _162.edges, 'optionalAccess', _163 => _163.thresholdAngle]), () => (30))},measure:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _164 => _164.measure, 'optionalAccess', _165 => _165.enabled]), () => (!1)),snapPixels:_optionalChain([e, 'access', _166 => _166.measure, 'optionalAccess', _167 => _167.snapPixels]),color:_optionalChain([e, 'access', _168 => _168.measure, 'optionalAccess', _169 => _169.color]),labelClassName:_optionalChain([e, 'access', _170 => _170.measure, 'optionalAccess', _171 => _171.labelClassName]),displayUnit:_optionalChain([e, 'access', _172 => _172.measure, 'optionalAccess', _173 => _173.displayUnit]),format:_optionalChain([e, 'access', _174 => _174.measure, 'optionalAccess', _175 => _175.format])},events:{onBackgroundClicked:_optionalChain([e, 'access', _176 => _176.events, 'optionalAccess', _177 => _177.onBackgroundClicked]),onObjectSelected:_optionalChain([e, 'access', _178 => _178.events, 'optionalAccess', _179 => _179.onObjectSelected]),onMeshMetadataClicked:_optionalChain([e, 'access', _180 => _180.events, 'optionalAccess', _181 => _181.onMeshMetadataClicked]),onMeshDoubleClicked:_optionalChain([e, 'access', _182 => _182.events, 'optionalAccess', _183 => _183.onMeshDoubleClicked]),selectionColor:_optionalChain([e, 'access', _184 => _184.events, 'optionalAccess', _185 => _185.selectionColor])||"#ff0000",enableEventHandlers:_nullishCoalesce(_optionalChain([e, 'access', _186 => _186.events, 'optionalAccess', _187 => _187.enableEventHandlers]), () => (!0)),enableKeyboardControls:_nullishCoalesce(_optionalChain([e, 'access', _188 => _188.events, 'optionalAccess', _189 => _189.enableKeyboardControls]), () => (!0)),enableClickToFocus:_nullishCoalesce(_optionalChain([e, 'access', _190 => _190.events, 'optionalAccess', _191 => _191.enableClickToFocus]), () => (!0)),enableDoubleClickZoom:_nullishCoalesce(_optionalChain([e, 'access', _192 => _192.events, 'optionalAccess', _193 => _193.enableDoubleClickZoom]), () => (!0)),onReady:_optionalChain([e, 'access', _194 => _194.events, 'optionalAccess', _195 => _195.onReady]),onFrame:_optionalChain([e, 'access', _196 => _196.events, 'optionalAccess', _197 => _197.onFrame])}}}function Ee(e){for(let n of Object.values(e))n instanceof E.Texture&&n.dispose();e.dispose()}function gn(e,n){if(n.isEmpty())return;let t=n.getCenter(new E.Vector3),r=n.getSize(new E.Vector3).length()*.5*1.2,i=e.shadow.camera;i.left=-r,i.right=r,i.top=r,i.bottom=-r,e.target.position.copy(t),e.target.updateMatrixWorld();let o=e.position.distanceTo(t);i.near=Math.max(r*.01,o-r),i.far=o+r,i.updateProjectionMatrix()}function yn(e){let n=new E.Scene,t=typeof e.environment.backgroundColor=="string"?new E.Color(e.environment.backgroundColor):e.environment.backgroundColor;return n.background=t||null,n}function bn(e,n,t,r,i,o,a,s,l,c,d,m,u){let f=null,b=performance.now(),T=()=>{let{width:h,height:w}=a();if(h===0||w===0)return;let L=Math.floor(h*s),p=Math.floor(w*s);(e.domElement.width!==L||e.domElement.height!==p)&&(e.setPixelRatio(s),e.setSize(h,w,!1),t.aspect=h/w,t.updateProjectionMatrix(),i.updateAspect(h,w),_optionalChain([m, 'optionalCall', _198 => _198(), 'optionalAccess', _199 => _199.setSize, 'call', _200 => _200(h,w,s)]),_optionalChain([u, 'optionalAccess', _201 => _201.setSize, 'call', _202 => _202(h,w)]))},R=function(){f=requestAnimationFrame(R);let h=performance.now(),w=(h-b)/1e3;b=h,T(),(o.enableDamping||o.autoRotate)&&o.update(),c&&c.update(r().position),d&&d.update(w),_optionalChain([l, 'optionalCall', _203 => _203(w)]);let L=r(),p=_optionalChain([m, 'optionalCall', _204 => _204()]);p?(p.setCamera(L),p.render(w)):e.render(n,L),u&&u.render(n,L),d&&d.render(e)};return{animate:R,dispose:()=>{f!==null&&(cancelAnimationFrame(f),f=null)}}}function Tn(e,n,t){n.environment.enableEnvironmentLighting?new (0, _HDRLoaderjs.HDRLoader)().load(n.environment.hdrPath||"/baseHDR.hdr",function(r){if(t()){r.dispose();return}if(!_optionalChain([r, 'optionalAccess', _205 => _205.image])){_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("HDR loaded without image data; skipping environment map."),_optionalChain([r, 'optionalAccess', _206 => _206.dispose, 'call', _207 => _207()]),_optionalChain([n, 'access', _208 => _208.events, 'access', _209 => _209.onReady, 'optionalCall', _210 => _210()]);return}r.mapping=E.EquirectangularReflectionMapping,e.environment=r,e.environmentIntensity=_nullishCoalesce(n.environment.environmentIntensity, () => (1)),n.environment.showEnvironment&&(e.background=r),_optionalChain([n, 'access', _211 => _211.events, 'access', _212 => _212.onReady, 'optionalCall', _213 => _213()])},void 0,function(r){t()||(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("HDR texture could not be loaded, falling back to basic lighting:",r),_optionalChain([n, 'access', _214 => _214.events, 'access', _215 => _215.onReady, 'optionalCall', _216 => _216()]))}):_optionalChain([n, 'access', _217 => _217.events, 'access', _218 => _218.onReady, 'optionalCall', _219 => _219()])}function Rn(e,n){let t=new E.AmbientLight(n.lighting.ambientLightColor,n.lighting.ambientLightIntensity);e.add(t);let r=null;if(n.lighting.enableHemisphereLight){r=new E.HemisphereLight(n.lighting.hemisphereSkyColor,n.lighting.hemisphereGroundColor,n.lighting.hemisphereIntensity);let a=_nullishCoalesce(n.environment.sceneUp, () => (ie));r.position.copy(a),e.add(r)}if(!n.lighting.enableSunlight)return{ambient:t,hemisphere:r,sun:null};let i=new E.DirectionalLight(_nullishCoalesce(n.lighting.sunlightColor, () => (16777215)),n.lighting.sunlightIntensity),o=n.lighting.sunlightPosition;return o&&i.position.set(o.x,o.y,o.z),n.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=n.render.shadowMapSize||2048,i.shadow.mapSize.height=n.render.shadowMapSize||2048,i.shadow.bias=-1e-4,i.shadow.normalBias=.02,i.shadow.radius=4,e.add(i),e.add(i.target),{ambient:t,hemisphere:r,sun:i}):(e.add(i),{ambient:t,hemisphere:r,sun:null})}function vn(e,n){let t=n.floor.size,r=new E.PlaneGeometry(t,t),i=typeof n.floor.color=="string"?new E.Color(n.floor.color):n.floor.color,o=new E.MeshStandardMaterial({color:i,roughness:n.floor.roughness,metalness:n.floor.metalness,side:E.DoubleSide}),a=new E.Mesh(r,o);a.userData.id="floor",a.name="floor";let s=(_optionalChain([n, 'access', _220 => _220.environment, 'optionalAccess', _221 => _221.sceneUp])||ie).clone().normalize();a.quaternion.setFromUnitVectors(new E.Vector3(0,0,1),s),a.position.set(0,0,0),n.floor.receiveShadow&&n.render.enableShadows&&(a.receiveShadow=!0),e.add(a)}function wn(e,n){let t=n.parentElement,r=t?t.clientWidth:window.innerWidth,i=t?t.clientHeight:window.innerHeight,o=new E.PerspectiveCamera(e.camera.fov,r/i,e.camera.near,e.camera.far),a=e.camera.position;return a&&o.position.set(a.x,a.y,a.z),o}function xn(e,n,t){let r=new E.WebGLRenderer({antialias:n.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:n.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),i=e.parentElement,o=i?i.clientWidth:window.innerWidth,a=i?i.clientHeight:window.innerHeight;return i&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),r.setSize(o,a,!1),r.setPixelRatio(t),n.render.enableShadows&&(r.shadowMap.enabled=!0,r.shadowMap.type=E.VSMShadowMap),r.toneMapping=n.render.toneMapping,r.toneMappingExposure=_nullishCoalesce(n.render.toneMappingExposure, () => (1)),r.outputColorSpace=E.SRGBColorSpace,r.sortObjects=!0,r}function Hn(e,n,t,r){let i=new Set,o=new Map,a=new E.Raycaster,s=new E.Vector2,l=new E.Vector2,c=()=>t.getActiveCamera(),d=p=>{let v=p;for(;v;){if(!v.visible)return!1;v=v.parent}return!0},m=()=>{let p=re(n);if(p.isEmpty()){_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("No objects to fit to view");return}t.frameBounds(p,!1)},u=typeof r.events.selectionColor=="string"?new E.Color(r.events.selectionColor):r.events.selectionColor instanceof E.Color?r.events.selectionColor:new E.Color("#ff0000"),f=()=>{i.forEach(p=>{let v=p;if(o.has(p)){let y=o.get(p),x=v.material;x instanceof E.Material?x.dispose():Array.isArray(x)&&x.forEach(B=>B.dispose()),v.material=y,o.delete(p);let A=p;for(;A.parent;)A=A.parent;A!==n&&(y instanceof E.Material?y.dispose():y.forEach(B=>B.dispose()))}}),i.clear()},b=p=>{let v=p;if(!(v.material instanceof E.Material))return!1;o.set(p,v.material);let y=v.material.clone();return p instanceof E.Mesh&&"emissive"in y?y.emissive=u.clone():"color"in y&&(y.color=u.clone()),v.material=y,!0},T=()=>{let p=re(n),v=p.isEmpty()?1:p.getSize(new E.Vector3).length();a.params.Points.threshold=v*.01},R=p=>{l.set(p.clientX,p.clientY)},M=p=>{let v=new E.Vector2(p.clientX,p.clientY);if(l.distanceTo(v)>5)return;let y=e.getBoundingClientRect();s.x=(p.clientX-y.left)/y.width*2-1,s.y=-((p.clientY-y.top)/y.height)*2+1,T(),a.setFromCamera(s,c());let x=a.intersectObjects(n.children,!0).filter(A=>d(A.object));if(x.length>0){let A=x[0].object;i.has(A)||(f(),i.add(A),b(A),_optionalChain([r, 'access', _222 => _222.events, 'optionalAccess', _223 => _223.onObjectSelected, 'optionalCall', _224 => _224(A)]),A instanceof E.Mesh&&Object.keys(A.userData).length>0&&_optionalChain([r, 'access', _225 => _225.events, 'optionalAccess', _226 => _226.onMeshMetadataClicked, 'optionalCall', _227 => _227(A.userData)]))}else f(),_optionalChain([r, 'access', _228 => _228.events, 'optionalAccess', _229 => _229.onBackgroundClicked, 'optionalCall', _230 => _230({x:s.x,y:s.y})])},h=p=>{let v=e.getBoundingClientRect();s.x=(p.clientX-v.left)/v.width*2-1,s.y=-((p.clientY-v.top)/v.height)*2+1,T(),a.setFromCamera(s,c());let y=a.intersectObjects(n.children,!0).filter(B=>d(B.object));if(y.length===0)return;let x=y[0].object;if(_optionalChain([r, 'access', _231 => _231.events, 'optionalAccess', _232 => _232.onMeshDoubleClicked, 'optionalCall', _233 => _233(x)]),!_optionalChain([r, 'access', _234 => _234.events, 'optionalAccess', _235 => _235.enableDoubleClickZoom]))return;let A=new E.Box3().setFromObject(x);A.isEmpty()||t.frameBounds(A,!0)},w=p=>{if(_optionalChain([r, 'access', _236 => _236.events, 'optionalAccess', _237 => _237.enableKeyboardControls]))switch(p.key.toLowerCase()){case"f":p.preventDefault(),m();break;case"escape":p.preventDefault(),f();break;case" ":p.preventDefault(),m();break}};return _optionalChain([r, 'access', _238 => _238.events, 'optionalAccess', _239 => _239.enableClickToFocus])&&(e.addEventListener("mousedown",R),e.addEventListener("click",M),e.addEventListener("dblclick",h)),_optionalChain([r, 'access', _240 => _240.events, 'optionalAccess', _241 => _241.enableKeyboardControls])&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",w)),{dispose:()=>{e.removeEventListener("mousedown",R),e.removeEventListener("click",M),e.removeEventListener("dblclick",h),e.removeEventListener("keydown",w),f()},fitToView:m,clearSelection:f}}function Mn(e,n,t){let r=new (0, _OrbitControlsjs.OrbitControls)(e,n),i=t.camera.target;return i&&r.target.set(i.x,i.y,i.z),r.enableDamping=t.controls.enableDamping||!1,r.dampingFactor=t.controls.dampingFactor||.05,r.autoRotate=t.controls.autoRotate||!1,r.autoRotateSpeed=t.controls.autoRotateSpeed||.5,r.enableZoom=_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}function he(e,n,t,r=!0){return{x:e,y:n,z:t}}var Ln="#ffffff",Je=12,In=4e-4,Dn=12,On=.05;function Qe(e,n={}){if(!e||e.length===0)return[];let{rhino:t,applyTransforms:r=!0}=n,i=[];for(let o of e)switch(o.kind){case"curve":{let a=Bn(o,t,r);a&&i.push(a);break}case"point":{let a=Vn(o,r);a&&i.push(a);break}default:{let s=o;_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Skipping unknown display item kind: ${String(s.kind)}`);break}}return i}var Pn=2;function Bn(e,n,t){if(!n)return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("No rhino3dm instance provided; skipping curve display item."),null;let r=Fn(e.json,n);if(!r)return null;let i;try{i=kn(r,t)}catch(m){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Failed to tessellate curve display item; skipping.",m),null}finally{se(r)}if(i.length<2)return null;let o=[];for(let m of i)o.push(m.x,m.y,m.z);let a=new _LineGeometryjs.LineGeometry;a.setPositions(o);let s=et(e.color,e.opacity),l=new (0, _LineMaterialjs.LineMaterial)({color:s.color}),c=l;c.linewidth=_nullishCoalesce(e.width, () => (Pn)),c.transparent=s.transparent,c.opacity=s.opacity;let d=new (0, _Line2js.Line2)(a,l);return d.computeLineDistances(),d.name=e.name,d.userData={source:"compute",id:e.id,layer:e.layer,kind:"curve",metadata:e.metadata},d}function Vn(e,n){let{position:t}=e;if(!t||typeof t.X!="number"||!Number.isFinite(t.X)||typeof t.Y!="number"||!Number.isFinite(t.Y)||typeof t.Z!="number"||!Number.isFinite(t.Z))return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Skipping point display item with missing or non-finite position (id: ${String(e.id)}).`),null;let{x:r,y:i,z:o}=he(t.X,t.Y,t.Z,n),a=new $.BufferGeometry;a.setAttribute("position",new $.Float32BufferAttribute([r,i,o],3));let s=new $.PointsMaterial({...et(e.color,e.opacity),size:6,sizeAttenuation:!1}),l=new $.Points(a,s);return l.name=e.name,l.userData={source:"compute",id:e.id,layer:e.layer,kind:"point",metadata:e.metadata},l}function se(e){_optionalChain([e, 'optionalAccess', _242 => _242.delete, 'optionalCall', _243 => _243()])}function Fn(e,n){try{let t=JSON.parse(e),r=n.CommonObject.decode(t);return r&&typeof r.pointAt=="function"?r:(se(r),_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Decoded display-item JSON is not a curve; skipping."),null)}catch(t){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Failed to decode curve display item JSON:",t),null}}function kn(e,n){let t=Un(e,n);return t||zn(e,n)}function Un(e,n){if(!e.isPolyline())return null;let t=e.tryGetPolyline(),r=Array.isArray(t)?t[1]:t;if(!r||typeof r.count!="number"||r.count<2)return se(r),null;let i=[];for(let o=0;o<r.count;o++){let a=r.get(o),{x:s,y:l,z:c}=he(a[0],a[1],a[2],n);i.push(new $.Vector3(s,l,c))}return se(r),i}function zn(e,n){let t=e.domain,r=t[0],o=t[1]-r,a=m=>{let u=e.pointAt(m),{x:f,y:b,z:T}=he(u[0],u[1],u[2],n);return new $.Vector3(f,b,T)},s=_n(e),l=r,c=a(r),d=[c];for(let m=0;m<Je;m++){let u=r+o*(m+1)/Je,f=a(u);Re(l,c,u,f,a,s,Dn,d),d.push(f),l=u,c=f}return d}function Re(e,n,t,r,i,o,a,s){if(a<=0)return;let l=(e+t)/2,c=i(l),d=Gn(c,n,r),m=jn(n,c,r);d<=o&&m<=On||(Re(e,n,l,c,i,o,a-1,s),s.push(c),Re(l,c,t,r,i,o,a-1,s))}function _n(e){let n=e.getBoundingBox(),t=n.min,r=n.max;se(n);let i=Math.hypot(r[0]-t[0],r[1]-t[1],r[2]-t[2]);return Math.max(i*In,1e-6)}function jn(e,n,t){let r=n.x-e.x,i=n.y-e.y,o=n.z-e.z,a=t.x-n.x,s=t.y-n.y,l=t.z-n.z,c=Math.sqrt(r*r+i*i+o*o),d=Math.sqrt(a*a+s*s+l*l);if(c===0||d===0)return 0;let m=r*a+i*s+o*l,u=Math.max(-1,Math.min(1,m/(c*d)));return Math.acos(u)}function Gn(e,n,t){let r=t.x-n.x,i=t.y-n.y,o=t.z-n.z,a=r*r+i*i+o*o;if(a===0)return e.distanceTo(n);let s=e.x-n.x,l=e.y-n.y,c=e.z-n.z,d=Math.max(0,Math.min(1,(s*r+l*i+c*o)/a)),m=s-r*d,u=l-i*d,f=c-o*d;return Math.sqrt(m*m+u*u+f*f)}function et(e,n){let t=_nullishCoalesce(n, () => (1));return{color:new $.Color(_nullishCoalesce(e, () => (Ln))),transparent:t<1,opacity:t}}var _fflate = require('fflate');var tt=1096174675,Wn= exports.x =1515605075,nt= exports.y =3,rt= exports.z =1,we= exports.A =1,$n= exports.B =2,Yn= exports.C =4,Xn= exports.D =8,qn= exports.E =16,Lo= exports.F =0,Zn= exports.G =1,ot=12,it=56,Kn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;function xe(e){if(!Kn)throw new (0, _chunkCUQQ3ZBVcjs.d)("SLVA parsing requires a little-endian host: the zero-copy geometry readers view the wire bytes in host byte order.",_chunkCUQQ3ZBVcjs.c.ENVIRONMENT_ERROR);let n=tr(er(e)),t=new DataView(n.buffer,n.byteOffset,n.byteLength);if(n.byteLength<ot)throw _("Blob too small to contain SLVA header.",{expectedBytes:ot,availableBytes:n.byteLength});let r=0,i=t.getUint32(r,!0);if(r+=4,i!==tt)throw _(`Invalid SLVA magic: 0x${i.toString(16)}`,{expectedMagic:`0x${tt.toString(16)}`,actualMagic:`0x${i.toString(16)}`});let o=t.getUint32(r,!0);if(r+=4,o<rt||o>nt)throw _(`Unsupported SLVA version: ${o}`,{minSupportedVersion:rt,maxSupportedVersion:nt,actualVersion:o});let a=t.getUint32(r,!0);if(r+=4,r+a>n.byteLength)throw _("Insufficient data to read metadata JSON.",{expectedBytes:a,availableBytes:n.byteLength-r,offset:r});let s=n.subarray(r,r+a);r+=a;let l;try{l=JSON.parse(nr(s))}catch(V){throw _(`Failed to parse metadata JSON: ${V instanceof Error?V.message:String(V)}`,{metadataLen:a})}if(r+it>n.byteLength)throw _("Insufficient data to read geometry header.",{expectedBytes:it,availableBytes:n.byteLength-r,offset:r});let c=t.getUint32(r,!0);r+=4;let d=t.getFloat64(r,!0);r+=8;let m=t.getFloat64(r,!0);r+=8;let u=t.getFloat64(r,!0);r+=8;let f=t.getFloat64(r,!0);r+=8;let b=t.getFloat64(r,!0);r+=8;let T=t.getFloat64(r,!0);r+=8;let R=t.getUint32(r,!0);r+=4;let M=(c&we)!==0,h=(c&Yn)!==0,w=R*3,p=w*(M?4:2);if(r+p>n.byteLength)throw _("Insufficient data to read vertices.",{expectedBytes:p,availableBytes:n.byteLength-r,offset:r,useFloat32:M,vertexCount:R});let v=n.byteOffset+r,y;if(M?y=st(n.buffer,v,w):h?y=ar(ve(n.buffer,v,w)):y=rr(n.buffer,v,w),r+=p,r+4>n.byteLength)throw _("Insufficient data to read index count.",{expectedBytes:4,availableBytes:n.byteLength-r,offset:r});let x=t.getUint32(r,!0);r+=4;let A=(c&$n)!==0,G=x*(A?2:4);if(r+G>n.byteLength)throw _("Insufficient data to read indices.",{expectedBytes:G,availableBytes:n.byteLength-r,offset:r,indexCount:x,useUint16Indices:A});let F=A?ve(n.buffer,n.byteOffset+r,x):or(n.buffer,n.byteOffset+r,x);h&&(F=F instanceof Uint16Array?sr(F):lr(F)),ir(F,R),r+=G;let Y=null;if((c&Xn)!==0){let V=Jn(n,t,r,R,h);Y=V.uvs,r=V.offset}let J=null;return(c&qn)!==0&&(J=Qn(n,r,R,h)),{metadata:l,flags:c,vertices:y,indices:F,origin:[d,m,u],scale:[f,b,T],uvs:Y,colors:J}}var at=36;function Jn(e,n,t,r,i){if(t+at>e.byteLength)throw _("Insufficient data to read UV chunk header.",{expectedBytes:at,availableBytes:e.byteLength-t,offset:t});let o=n.getUint32(t,!0);t+=4;let a=n.getFloat64(t,!0);t+=8;let s=n.getFloat64(t,!0);t+=8;let l=n.getFloat64(t,!0);t+=8;let c=n.getFloat64(t,!0);t+=8;let d=r*2,m=o===Zn,u=d*(m?4:2);if(t+u>e.byteLength)throw _("Insufficient data to read UV chunk.",{expectedBytes:u,availableBytes:e.byteLength-t,offset:t,uvFormat:o,vertexCount:r});let f=e.byteOffset+t,b;if(m)b=st(e.buffer,f,d).slice();else{let T=ve(e.buffer,f,d);b=new Float32Array(d);let R=0,M=0;for(let h=0;h<d;h+=2)i?(R=R+Z(T[h])&65535,M=M+Z(T[h+1])&65535):(R=T[h],M=T[h+1]),b[h]=a+R*l,b[h+1]=s+M*c}return{uvs:b,offset:t+u}}function Qn(e,n,t,r){let i=t*3;if(n+i>e.byteLength)throw _("Insufficient data to read vertex-color chunk.",{expectedBytes:i,availableBytes:e.byteLength-n,offset:n,vertexCount:t});let o=e.subarray(n,n+i);if(!r)return o.slice();let a=new Uint8Array(i),s=0,l=0,c=0;for(let d=0;d<i;d+=3)s=s+Z(o[d])&255,l=l+Z(o[d+1])&255,c=c+Z(o[d+2])&255,a[d]=s,a[d+1]=l,a[d+2]=c;return a}function er(e){return typeof e=="string"?_chunkCUQQ3ZBVcjs.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)!==Wn)return e;let t=n.getUint32(4,!0),r=e.subarray(8),i=Math.max(r.byteLength*1032+1024,1<<20);if(t>i)throw _("SLVZ header declares an implausible uncompressed length",{uncompressedLen:t,deflatedBytes:r.byteLength,maxPlausibleLen:i});let o;try{o=_fflate.inflateSync.call(void 0, r,{out:new Uint8Array(t+1)})}catch(a){throw _(`Failed to inflate SLVZ blob: ${a instanceof Error?a.message:String(a)}`,{uncompressedLen:t,deflatedBytes:r.byteLength})}if(o.byteLength!==t)throw _("SLVZ payload inflated to a different size than the header declares.",{declaredLen:t,actualLen:o.byteLength,deflatedBytes:r.byteLength});return o}function nr(e){if(typeof TextDecoder<"u")return new TextDecoder("utf-8").decode(e);if(typeof globalThis.Buffer<"u")return globalThis.Buffer.from(e).toString("utf-8");throw new (0, _chunkCUQQ3ZBVcjs.d)("No UTF-8 decoder available in this environment.",_chunkCUQQ3ZBVcjs.c.INVALID_STATE)}function rr(e,n,t){if(t===0)return new Int16Array(0);if(n%2===0)return new Int16Array(e,n,t);let r=new Uint8Array(t*2);return r.set(new Uint8Array(e,n,t*2)),new Int16Array(r.buffer)}function st(e,n,t){if(t===0)return new Float32Array(0);if(n%4===0)return new Float32Array(e,n,t);let r=new Uint8Array(t*4);return r.set(new Uint8Array(e,n,t*4)),new Float32Array(r.buffer)}function ve(e,n,t){if(t===0)return new Uint16Array(0);if(n%2===0)return new Uint16Array(e,n,t);let r=new Uint8Array(t*2);return r.set(new Uint8Array(e,n,t*2)),new Uint16Array(r.buffer)}function or(e,n,t){if(t===0)return new Uint32Array(0);if(n%4===0)return new Uint32Array(e,n,t);let r=new Uint8Array(t*4);return r.set(new Uint8Array(e,n,t*4)),new Uint32Array(r.buffer)}function ir(e,n){if(e.length!==0&&!(e instanceof Uint16Array&&n>65535)){for(let t=0;t<e.length;t++)if(e[t]>=n)throw _("Index out of range of vertexCount.",{indexPosition:t,indexValue:e[t],vertexCount:n})}}function Z(e){return e>>>1^-(e&1)}function ar(e){let n=new Int16Array(e.length),t=0,r=0,i=0;for(let o=0;o<e.length;o+=3)t=t+Z(e[o])<<16>>16,r=r+Z(e[o+1])<<16>>16,i=i+Z(e[o+2])<<16>>16,n[o]=t,n[o+1]=r,n[o+2]=i;return n}function sr(e){let n=new Uint16Array(e.length),t=0;for(let r=0;r<e.length;r++)t=t+Z(e[r])&65535,n[r]=t;return n}function lr(e){let n=new Uint32Array(e.length),t=0;for(let r=0;r<e.length;r++)t=t+Z(e[r])>>>0,n[r]=t;return n}function _(e,n){return new (0, _chunkCUQQ3ZBVcjs.d)(e,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:n})}async function Fo(e,n){let{debug:t=!1}=_nullishCoalesce(n, () => ({})),r=t?performance.now():0,i,o=performance.now();try{i=JSON.parse(e)}catch(s){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).error("Error parsing mesh batch envelope JSON:",s),[]}let a=performance.now()-o;return await He(i,n,{parseTime:a,perfStart:r})}async function He(e,n,t){let{mergeByMaterial:r=!0,applyTransforms:i=!0,debug:o=!1,material:a}=_nullishCoalesce(n, () => ({})),{parseTime:s=0,perfStart:l=o?performance.now():0}=_nullishCoalesce(t, () => ({}));if(!e.compressedData)return[];let c=performance.now(),d=xe(e.compressedData),m=performance.now()-c,u=o?hr(e.compressedData):0;return lt(d,{mergeByMaterial:r,applyTransforms:i,debug:o,material:a,parseTime:s,decodeTime:m,perfStart:l,blobBytes:u,fallback:{materials:e.materials,groups:e.groups,sourceComponentId:e.sourceComponentId}})}async function ko(e,n){let{mergeByMaterial:t=!0,applyTransforms:r=!0,debug:i=!1,material:o}=_nullishCoalesce(n, () => ({})),a=i?performance.now():0,s=performance.now(),l=xe(e),c=performance.now()-s,d=e.byteLength;return lt(l,{mergeByMaterial:t,applyTransforms:r,debug:i,material:o,parseTime:0,decodeTime:c,perfStart:a,blobBytes:d})}function lt(e,n){let{mergeByMaterial:t,applyTransforms:r,debug:i,material:o,parseTime:a,decodeTime:s,perfStart:l,blobBytes:c,fallback:d}=n,m=_nullishCoalesce(_nullishCoalesce(e.metadata.materials, () => (_optionalChain([d, 'optionalAccess', _244 => _244.materials]))), () => ([])),u=_nullishCoalesce(_nullishCoalesce(e.metadata.groups, () => (_optionalChain([d, 'optionalAccess', _245 => _245.groups]))), () => ([])),f=_nullishCoalesce(_optionalChain([d, 'optionalAccess', _246 => _246.sourceComponentId]), () => (e.metadata.sourceComponentId)),b=(e.flags&we)!==0;cr(u,m.length,e.vertices.length/3,e.indices.length);let T=b?dr(e.vertices,r):ur(e.vertices,e.origin,e.scale,r);if(i){let L=e.vertices.byteLength+e.indices.byteLength;_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug("Mesh Batch Stats:"),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Materials: ${m.length} | Groups: ${u.length}`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Format: ${b?"float32":"int16 quantized"}`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Blob: ${(c/1024/1024).toFixed(2)} MB | Geometry on wire: ${(L/1024/1024).toFixed(2)} MB`)}let R=performance.now(),M=m.map(L=>mr(L,{vertexColors:e.colors!=null,appearance:o})),h=[];for(let L of u)if(t&&L.meshes.length>1){let p=fr(L,T,e.indices,M,e.uvs,e.colors);p.userData.sourceComponentId=_nullishCoalesce(f, () => (null)),h.push(p)}else{let p=Er(L,T,e.indices,M,e.uvs,e.colors);for(let v of p)v.userData.sourceComponentId=_nullishCoalesce(f, () => (null));h.push(...p)}let w=performance.now()-R;if(i){let L=performance.now()-l;_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug("Performance:"),a>0&&_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Parse JSON: ${a.toFixed(2)}ms`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Decode binary: ${s.toFixed(2)}ms`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Create Meshes: ${w.toFixed(2)}ms`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Total: ${L.toFixed(2)}ms`)}return Promise.resolve(h)}function le(e,n){return new (0, _chunkCUQQ3ZBVcjs.d)(e,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:n})}function cr(e,n,t,r){for(let i of e){if(!Number.isInteger(i.materialId)||i.materialId<0||i.materialId>=n)throw le("Group materialId out of range of the materials array.",{materialId:i.materialId,materialCount:n});for(let o of i.meshes){let a={vertexStart:o.vertexStart,vertexCount:o.vertexCount,indexStart:o.indexStart,indexCount:o.indexCount};for(let[s,l]of Object.entries(a))if(!Number.isInteger(l)||l<0)throw le(`Mesh metadata field "${s}" must be a non-negative integer.`,{meshName:o.name,field:s,value:l});if(o.vertexStart+o.vertexCount>t)throw le("Mesh vertex window exceeds the batch vertex buffer.",{meshName:o.name,vertexStart:o.vertexStart,vertexCount:o.vertexCount,totalVertexCount:t});if(o.indexStart+o.indexCount>r)throw le("Mesh index window exceeds the batch index buffer.",{meshName:o.name,indexStart:o.indexStart,indexCount:o.indexCount,totalIndexCount:r})}}}function ct(e,n){if(e<n.vertexStart||e>=n.vertexStart+n.vertexCount)throw le("Index references a vertex outside its mesh's vertex window.",{meshName:n.name,indexValue:e,vertexStart:n.vertexStart,vertexCount:n.vertexCount})}function ur(e,n,t,r){let i=new Float32Array(e.length),o=n[0],a=n[1],s=n[2],l=t[0],c=t[1],d=t[2];for(let m=0;m<e.length;m+=3)i[m]=o+(e[m]+32767)*l,i[m+1]=a+(e[m+1]+32767)*c,i[m+2]=s+(e[m+2]+32767)*d;return i}function dr(e,n){return e}function mr(e,n){let t=Fe(e.color),r=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _247 => _247.vertexColors]), () => (!1)),i=_optionalChain([n, 'optionalAccess', _248 => _248.appearance]),o=new P.MeshPhysicalMaterial({color:t,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,vertexColors:r,side:_optionalChain([i, 'optionalAccess', _249 => _249.cullBackfaces])?P.FrontSide:P.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0});return _optionalChain([i, 'optionalAccess', _250 => _250.envMapIntensity])!=null&&(o.envMapIntensity=i.envMapIntensity),r&&pr(o),e.map&&Ke(o,e.map),o}function pr(e){e.onBeforeCompile=n=>{n.vertexShader=n.vertexShader.replace("#include <color_vertex>",`#include <color_vertex>
53
+ `;function ze(e={}){let{cellSize:n=1,majorEvery:t=10,cellColor:r=8947848,majorColor:i=4473924,fadeDistance:o=100,plane:a="y"}=e,s=a==="y"?new U.Vector2(0,2):a==="z"?new U.Vector2(0,1):new U.Vector2(1,2),l=o*2.5,c=new U.PlaneGeometry(l,l);a==="y"?c.rotateX(-Math.PI/2):a==="x"&&c.rotateY(Math.PI/2);let d=new U.ShaderMaterial({vertexShader:Lt,fragmentShader:It,transparent:!0,depthWrite:!1,side:U.DoubleSide,uniforms:{uAxes:{value:s},uCell:{value:n},uMajor:{value:t},uCellColor:{value:new U.Color(r)},uMajorColor:{value:new U.Color(i)},uCenter:{value:new U.Vector3},uFade:{value:o}}}),m=new U.Mesh(c,d);m.name="grid",m.userData.id="grid",m.renderOrder=-1;let u=new U.Vector3;return{object:m,update:f=>{a==="y"?(m.position.set(f.x,0,f.z),u.set(f.x,0,f.z)):a==="z"?(m.position.set(f.x,f.y,0),u.set(f.x,f.y,0)):(m.position.set(0,f.y,f.z),u.set(0,f.y,f.z)),d.uniforms.uCenter.value.copy(u)},setVisible:f=>{m.visible=f},dispose:()=>{m.removeFromParent(),c.dispose(),d.dispose()}}}var _ViewHelperjs = require('three/addons/helpers/ViewHelper.js');function _e(e){let{camera:n,domElement:t,controller:r}=e,i=new (0, _ViewHelperjs.ViewHelper)(n,t);i.setLabels("X","Y","Z");let o=!0,a=128,s=new W.Raycaster,l=new W.OrthographicCamera(-2,2,2,-2,0,4);l.position.set(0,0,2),l.updateMatrixWorld();let c={posX:new W.Vector3(1,0,0),negX:new W.Vector3(-1,0,0),posY:new W.Vector3(0,1,0),negY:new W.Vector3(0,-1,0),posZ:new W.Vector3(0,0,1),negZ:new W.Vector3(0,0,-1)},d=u=>{let f=t.getBoundingClientRect(),b=f.left+t.offsetWidth-a-i.location.right,T=f.top+t.offsetHeight-a-i.location.bottom,R=new W.Vector2((u.clientX-b)/a*2-1,-((u.clientY-T)/a)*2+1);if(Math.abs(R.x)>1||Math.abs(R.y)>1)return null;i.quaternion.copy(n.quaternion).invert(),i.updateMatrixWorld(),s.setFromCamera(R,l);let C=s.intersectObjects(i.children,!1);for(let h of C){let x=_optionalChain([h, 'access', _7 => _7.object, 'access', _8 => _8.userData, 'optionalAccess', _9 => _9.type]);if(typeof x=="string"&&x in c)return x}return null};return{render:u=>{if(!o)return;let f=u.autoClear;u.autoClear=!1,i.render(u),u.autoClear=f},update:()=>{},handleClick:u=>{if(!o)return!1;let f=d(u);return f?(r.getProjection()==="orthographic"&&r.setProjection("perspective"),r.setViewDirection(c[f],!1),!0):!1},isAnimating:!1,setVisible:u=>{o=u},isVisible:()=>o,dispose:()=>i.dispose()}}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 ue="edge-overlay",Vt=2236962,Bt=1.5,Ft=30,be=new WeakMap;function Ge(e,n={}){let t=new oe.Color(_nullishCoalesce(n.color, () => (Vt))),r=_nullishCoalesce(n.width, () => (Bt)),i=_nullishCoalesce(n.thresholdAngle, () => (Ft)),o=[];return e.traverse(a=>{if(!(a instanceof oe.Mesh)||a.userData.id==="floor"||a.userData.id==="grid"||a.userData.kind===ue||a.children.some(l=>_optionalChain([l, 'access', _10 => _10.userData, 'optionalAccess', _11 => _11.kind])===ue)||!a.geometry)return;let s=zt(a.geometry,t,r,i);a.add(s),o.push(s)}),o}function kt(e,n){let t=be.get(e);t||(t=new Map,be.set(e,t));let r=t.get(n);if(!r){let i=new oe.EdgesGeometry(e,n),o=new _LineSegmentsGeometryjs.LineSegmentsGeometry;o.setPositions(i.attributes.position.array),i.dispose(),r={geometry:o,refCount:0},t.set(n,r)}return r.refCount+=1,r.geometry}function Ut(e){let n=e.userData,t=n.edgeSource&&be.get(n.edgeSource),r=n.edgeThresholdAngle!=null?_optionalChain([t, 'optionalAccess', _12 => _12.get, 'call', _13 => _13(n.edgeThresholdAngle)]):void 0;if(!r||r.geometry!==e.geometry){e.geometry.dispose();return}r.refCount-=1,r.refCount<=0&&(r.geometry.dispose(),t.delete(n.edgeThresholdAngle))}function zt(e,n,t,r){let i=kt(e,r),o=new (0, _LineMaterialjs.LineMaterial)({color:n});o.linewidth=t,o.polygonOffset=!0,o.polygonOffsetFactor=-1,o.polygonOffsetUnits=-4;let a=new (0, _LineSegments2js.LineSegments2)(i,o);return a.userData.kind=ue,a.userData.edgeSource=e,a.userData.edgeThresholdAngle=r,a.raycast=()=>{},a}function _t(e){return _optionalChain([e, 'access', _14 => _14.userData, 'optionalAccess', _15 => _15.kind])===ue}function jr(e){let n=[];e.traverse(t=>{t instanceof _LineSegments2js.LineSegments2&&_t(t)&&n.push(t)});for(let t of n)Ut(t),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 _SMAAPassjs = require('three/addons/postprocessing/SMAAPass.js');var _OutputPassjs = require('three/addons/postprocessing/OutputPass.js');function Ne(e,n,t,r,i,o){let a=new (0, _EffectComposerjs.EffectComposer)(e),s=new (0, _RenderPassjs.RenderPass)(n,t);a.addPass(s);let l=new (0, _GTAOPassjs.GTAOPass)(n,t,r,i);l.blendIntensity=_nullishCoalesce(o.aoIntensity, () => (1)),l.updateGtaoMaterial({screenSpaceRadius:!0}),a.addPass(l);let c=new _SMAAPassjs.SMAAPass;a.addPass(c);let d=new _OutputPassjs.OutputPass;a.addPass(d),e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure;let m=_nullishCoalesce(o.aoPixelRatio, () => (1));return a.setSize(r,i),{render:u=>a.render(u),setSize:(u,f,b)=>{a.setPixelRatio(Math.min(b,m)),a.setSize(u,f)},setCamera:u=>{s.camera=u,l.camera=u;let f=u.isPerspectiveCamera?1:0;l.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==f&&(l.gtaoMaterial.defines.PERSPECTIVE_CAMERA=f,l.gtaoMaterial.needsUpdate=!0)},dispose:()=>{a.dispose(),l.dispose(),c.dispose(),d.dispose()}}}var _CSS2DRendererjs = require('three/addons/renderers/CSS2DRenderer.js');function $e(e,n){let t=new _CSS2DRendererjs.CSS2DRenderer,r=t.domElement;r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.overflow="hidden",r.style.pointerEvents="none",r.style.zIndex="30",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(r);let i={width:e.clientWidth||1,height:e.clientHeight||1};t.setSize(i.width,i.height);let o=new We.Group;o.name="label-layer",o.userData.id="label-layer",n.add(o);let a=new Set;return{addLabel:(l,c,d)=>{let m=document.createElement("div");m.textContent=l,d?m.className=d:Object.assign(m.style,{padding:"2px 6px",borderRadius:"4px",background:"rgba(20, 20, 20, 0.78)",color:"#fff",font:"12px/1.3 system-ui, sans-serif",whiteSpace:"pre",textAlign:"center",userSelect:"none"}),m.style.pointerEvents="none";let u=new (0, _CSS2DRendererjs.CSS2DObject)(m);return u.position.copy(c),o.add(u),a.add(u),{object:u,setPosition:f=>u.position.copy(f),setText:f=>{m.textContent=f},remove:()=>{u.removeFromParent(),m.remove(),a.delete(u)}}},render:(l,c)=>t.render(l,c),setSize:(l,c)=>t.setSize(l,c),dispose:()=>{a.forEach(l=>{l.removeFromParent(),l.element.remove()}),a.clear(),o.removeFromParent(),r.remove()}}}var _Line2js = require('three/addons/lines/Line2.js');var _LineGeometryjs = require('three/addons/lines/LineGeometry.js');var Jt=12,Qt=16763904,Ye=.015,Xe={Millimeters:{metersPerUnit:1/1e3,suffix:"mm"},Centimeters:{metersPerUnit:1/100,suffix:"cm"},Meters:{metersPerUnit:1,suffix:"m"},Inches:{metersPerUnit:1/39.37,suffix:"in"},Feet:{metersPerUnit:1/3.28084,suffix:"ft"}};function en(e){let n=e&&Xe[e]||Xe.Meters;return t=>`${(t/n.metersPerUnit).toPrecision(3)} ${n.suffix}`}function tn(e,n){if(e.isOrthographicCamera){let r=e;return Math.abs(r.top-r.bottom)/(r.zoom||1)*Ye}return((n?e.position.distanceTo(n):e.position.length())||1)*Ye}function nn(e){let n=e.object;if(n instanceof D.Mesh)return e.face?[e.face.a,e.face.b,e.face.c]:null;if(n instanceof D.Points)return e.index!=null?[e.index]:null;if(n instanceof D.Line){if(e.index==null)return null;let t=n.geometry.index;return t?e.index+1>=t.count?null:[t.getX(e.index),t.getX(e.index+1)]:[e.index,e.index+1]}return null}function rn(e,n,t,r){let i=e.point.clone(),o=e.object,a=nn(e);if(!a||!o.geometry)return i;let s=o.geometry.attributes.position;if(!s)return i;let l=u=>{let f=u.clone().project(n);return new D.Vector2((f.x+1)/2*t.width,(1-f.y)/2*t.height)},c=l(i),d=i,m=r;for(let u of a){if(u>=s.count)continue;let b=new D.Vector3().fromBufferAttribute(s,u).applyMatrix4(o.matrixWorld),T=l(b).distanceTo(c);T<m&&(m=T,d=b)}return d}function qe(e){let{canvas:n,scene:t,getActiveCamera:r,getViewTarget:i,labelLayer:o,options:a={}}=e,s=_nullishCoalesce(a.snapPixels, () => (Jt)),l=new D.Color(_nullishCoalesce(a.color, () => (Qt))),c=en(a.displayUnit),d=(S,w)=>`${c(S)}
54
+ \u0394x ${c(w.x)} \u0394y ${c(w.y)} \u0394z ${c(w.z)}`,m=_nullishCoalesce(a.format, () => (d)),u=new D.Raycaster,f=new D.Vector2,b=!1,T=[],R=[],C=null,h=null,x=new D.PointsMaterial({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),L=new D.PointsMaterial({color:l,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),p=null,v=S=>{if(!S){p&&(p.visible=!1);return}if(!p){let w=new D.BufferGeometry;w.setAttribute("position",new D.Float32BufferAttribute([0,0,0],3)),p=new D.Points(w,L),p.renderOrder=1e3,p.userData.id="measure",p.raycast=()=>{},t.add(p)}p.position.copy(S),p.visible=!0},y=S=>{let w=new D.BufferGeometry;w.setAttribute("position",new D.Float32BufferAttribute([S.x,S.y,S.z],3));let j=new D.Points(w,x);return j.renderOrder=999,j.userData.id="measure",j.raycast=()=>{},t.add(j),j},H=()=>{T.length=0,R.forEach(S=>{S.geometry.dispose(),S.removeFromParent()}),R.length=0,C&&(C.geometry.dispose(),C.material.dispose(),C.removeFromParent(),C=null),_optionalChain([h, 'optionalAccess', _16 => _16.remove, 'call', _17 => _17()]),h=null},A=()=>{if(T.length!==2)return;let[S,w]=T,j=new _LineGeometryjs.LineGeometry;j.setPositions([S.x,S.y,S.z,w.x,w.y,w.z]);let K=new (0, _LineMaterialjs.LineMaterial)({color:l});K.linewidth=2,K.depthTest=!1,C=new (0, _Line2js.Line2)(j,K),C.renderOrder=998,C.userData.id="measure",C.raycast=()=>{},t.add(C);let Q=S.clone().add(w).multiplyScalar(.5),ee=new D.Vector3(Math.abs(w.x-S.x),Math.abs(w.y-S.y),Math.abs(w.z-S.z));h=o.addLabel(m(S.distanceTo(w),ee),Q,a.labelClassName)},V=S=>{let w=n.getBoundingClientRect();f.x=(S.clientX-w.left)/w.width*2-1,f.y=-((S.clientY-w.top)/w.height)*2+1;let j=r();u.setFromCamera(f,j);let K=tn(j,_optionalChain([i, 'optionalCall', _18 => _18()]));u.params.Line.threshold=K,u.params.Points.threshold=K;let Q=u.intersectObjects(t.children,!0).filter(ee=>ee.object.userData.id!=="measure"&&ee.object.userData.id!=="grid");return Q.length===0?null:rn(Q[0],j,{width:w.width,height:w.height},s)},G=null,F=0,Y=()=>{F&&(cancelAnimationFrame(F),F=0),G=null};return{setEnabled:S=>{b=S,S||(Y(),H(),v(null))},isEnabled:()=>b,handleClick:S=>{if(!b)return!1;T.length===2&&H();let w=V(S);return w===null||(T.push(w),R.push(y(w)),T.length===2&&A()),!0},handleMove:S=>{b&&(G=S,!F&&(F=requestAnimationFrame(()=>{F=0;let w=G;G=null,!(!b||!w)&&v(V(w))})))},clear:H,dispose:()=>{Y(),H(),p&&(p.geometry.dispose(),p.removeFromParent(),p=null),x.dispose(),L.dispose()}}}var on=64,an=256,X=new Map,ae=new Map,de=0,pe=class extends Error{constructor(n){super(`Texture load for ${n} resolved after clearTextureCache(); texture disposed.`),this.name="StaleTextureLoadError"}},me=1;function Ze(e){me=Math.max(1,e);for(let n of X.values())n.anisotropy!==me&&(n.anisotropy=me,n.needsUpdate=!0)}function Ke(e,n){let t=sn(n),r=X.get(t);if(r){X.delete(t),X.set(t,r),e.map=r,e.needsUpdate=!0;return}typeof document>"u"||un(n,t).then(i=>{e.map=i,e.needsUpdate=!0}).catch(i=>{i instanceof pe||_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Failed to load material texture ${n}:`,i)})}function ro(){de++;for(let e of X.values())e.dispose();X.clear(),ae.clear()}function sn(e){return e.length<=an?e:`data-uri:${ln(e).toString(16)}:${e.length}`}function ln(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return n>>>0}function cn(e,n){for(X.set(e,n);X.size>on;){let t=X.keys().next().value,r=X.get(t);X.delete(t),r.dispose()}}function un(e,n){let t=ae.get(n);if(!t){let r=de;t=new Promise((i,o)=>{new fe.TextureLoader().load(e,a=>{if(r!==de){a.dispose(),o(new pe(e));return}a.colorSpace=fe.SRGBColorSpace,a.anisotropy=me,cn(n,a),ae.delete(n),i(a)},void 0,a=>{r===de&&ae.delete(n),o(a)})}),ae.set(n,t)}return t}var _OrbitControlsjs = require('three/addons/controls/OrbitControls.js');var _HDRLoaderjs = require('three/addons/loaders/HDRLoader.js');var ie=new E.Vector3(0,0,1),pn="technical",Te={studio:{toneMapping:E.ACESFilmicToneMapping,toneMappingExposure:1,envMapIntensity:1.3,environmentIntensity:1.2,hemisphereIntensity:1,ambientIntensity:.3,cullBackfaces:!1,ambientOcclusion:!1},technical:{toneMapping:E.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:.5,environmentIntensity:1,hemisphereIntensity:0,ambientIntensity:1,cullBackfaces:!1,ambientOcclusion:!1},showcase:{toneMapping:E.ACESFilmicToneMapping,toneMappingExposure:1.05,envMapIntensity:1.6,environmentIntensity:1.35,hemisphereIntensity:1.2,ambientIntensity:.25,cullBackfaces:!1,ambientOcclusion:!1}};function fn(e){let n=Te[e];return{envMapIntensity:n.envMapIntensity,cullBackfaces:n.cullBackfaces}}function En(e){let n=Math.abs(e.x),t=Math.abs(e.y),r=Math.abs(e.z);return r>=n&&r>=t?"z":t>=n&&t>=r?"y":"x"}var yo=function(e,n){let t=hn(n||{}),r=_optionalChain([t, 'access', _19 => _19.environment, 'optionalAccess', _20 => _20.sceneUp])||ie,i=_nullishCoalesce(t.render.pixelRatio, () => (Math.min(window.devicePixelRatio,2))),o=yn(t),a=xn(t,e);a.up.copy(r);let s=Hn(e,t,i);Ze(s.capabilities.getMaxAnisotropy());let l=Cn(a,e,t),c=Ue({scene:o,perspective:a,controls:l,onActiveCameraChange:()=>{},up:r}),d=()=>c.getActiveCamera(),m=!1;Tn(o,t,()=>m);let u=Rn(o,t),f=u.sun,b=()=>{f&&gn(f,re(o))};_optionalChain([t, 'access', _21 => _21.floor, 'optionalAccess', _22 => _22.enabled])&&vn(o,t);let T=t.grid.enabled?ze({cellSize:t.grid.cellSize,majorEvery:t.grid.majorEvery,cellColor:t.grid.cellColor,majorColor:t.grid.majorColor,fadeDistance:t.grid.fadeDistance,plane:t.grid.plane}):null;T&&o.add(T.object);let R=t.gizmo.enabled?_e({camera:a,domElement:e,controller:c}):null,C=_nullishCoalesce(e.parentElement, () => (e)),h=t.measure.enabled?$e(C,o):null,x=t.measure.enabled&&h?qe({canvas:e,scene:o,getActiveCamera:d,labelLayer:h,options:{snapPixels:t.measure.snapPixels,color:t.measure.color,labelClassName:t.measure.labelClassName,displayUnit:t.measure.displayUnit,format:t.measure.format}}):null,L=t.events.enableEventHandlers!==!1?wn(e,o,c,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},p=5,v=0,y=0,H=g=>{v=g.clientX,y=g.clientY},A=g=>Math.hypot(g.clientX-v,g.clientY-y)>p,V=g=>{if(!A(g)){if(_optionalChain([x, 'optionalAccess', _23 => _23.handleClick, 'call', _24 => _24(g)])){g.stopImmediatePropagation();return}_optionalChain([R, 'optionalAccess', _25 => _25.handleClick, 'call', _26 => _26(g)])&&g.stopImmediatePropagation()}};(R||x)&&(e.addEventListener("mousedown",H,{capture:!0}),e.addEventListener("click",V,{capture:!0}));let G=g=>_optionalChain([x, 'optionalAccess', _27 => _27.handleMove, 'call', _28 => _28(g)]);x&&e.addEventListener("mousemove",G,{passive:!0});let F=g=>{Ge(g,{color:t.edges.color,width:t.edges.width,thresholdAngle:t.edges.thresholdAngle})},Y=e.parentElement,J=()=>Y?{width:Y.clientWidth,height:Y.clientHeight}:{width:window.innerWidth,height:window.innerHeight},B=null,S=()=>{let{width:g,height:I}=J(),N=Ne(s,o,d(),Math.max(1,g),Math.max(1,I),{toneMapping:_nullishCoalesce(t.render.toneMapping, () => (E.NeutralToneMapping)),toneMappingExposure:_nullishCoalesce(t.render.toneMappingExposure, () => (1)),aoIntensity:t.render.aoIntensity,aoPixelRatio:t.render.aoPixelRatio});return N.setSize(Math.max(1,g),Math.max(1,I),i),N},w=g=>{g&&!B?B=S():!g&&B&&(B.dispose(),B=null)};t.render.ambientOcclusion&&(B=S());let j=g=>{g.ambientIntensity!==void 0&&(u.ambient.intensity=g.ambientIntensity),g.hemisphereIntensity!==void 0&&!u.hemisphere&&g.hemisphereIntensity>0&&(u.hemisphere=new E.HemisphereLight(_nullishCoalesce(g.hemisphereSkyColor, () => (t.lighting.hemisphereSkyColor)),_nullishCoalesce(g.hemisphereGroundColor, () => (t.lighting.hemisphereGroundColor)),g.hemisphereIntensity),u.hemisphere.position.copy(_nullishCoalesce(t.environment.sceneUp, () => (ie))),o.add(u.hemisphere)),u.hemisphere&&(g.hemisphereIntensity!==void 0&&(u.hemisphere.intensity=g.hemisphereIntensity),g.hemisphereSkyColor!==void 0&&u.hemisphere.color.set(g.hemisphereSkyColor),g.hemisphereGroundColor!==void 0&&u.hemisphere.groundColor.set(g.hemisphereGroundColor))},K=g=>{t.environment.environmentIntensity=g,o.environmentIntensity=g},Q=g=>{t.render.toneMappingExposure=g,s.toneMappingExposure=g,B&&(w(!1),w(!0))},ee=g=>{t.render.aoIntensity=g,B&&(w(!1),w(!0))},mt=g=>{let I=Te[g];Ce=g,s.toneMapping=I.toneMapping,s.toneMappingExposure=I.toneMappingExposure,t.render.toneMapping=I.toneMapping,t.render.toneMappingExposure=I.toneMappingExposure,j({hemisphereIntensity:I.hemisphereIntensity,ambientIntensity:I.ambientIntensity}),K(I.environmentIntensity),B&&w(!1),w(I.ambientOcclusion),o.traverse(N=>{if(N.userData.source!=="compute")return;let ce=N,bt=Array.isArray(ce.material)?ce.material:ce.material?[ce.material]:[];for(let Ae of bt)"envMapIntensity"in Ae&&(Ae.envMapIntensity=I.envMapIntensity)})},Ce=t.look,pt=()=>fn(Ce),{animate:ft,dispose:Et}=bn(s,o,a,d,c,l,J,i,t.events.onFrame,T,R,()=>B,h);ft(),o.up.set(r.x,r.y,r.z),b();let Me=g=>{g.traverse(I=>{let N=I;!N.geometry&&!N.material||(_optionalChain([N, 'access', _29 => _29.geometry, 'optionalAccess', _30 => _30.dispose, 'call', _31 => _31()]),Array.isArray(N.material)?N.material.forEach(Ee):N.material&&Ee(N.material))})},ht=g=>{g.userData.source="user",o.add(g)},gt=g=>{g.removeFromParent(),Me(g)},yt=()=>{o.children.filter(I=>I.userData.source==="user").forEach(I=>{I.removeFromParent(),Me(I)})};return{scene:o,camera:a,controls:l,renderer:s,cameraController:c,grid:T,gizmo:R,measureTool:x,applyEdges:F,setAmbientOcclusion:w,setLook:mt,setFillLights:j,setEnvironmentIntensity:K,setToneMappingExposure:Q,setAoIntensity:ee,getMaterialAppearance:pt,updateShadowBounds:b,dispose:()=>{m||(m=!0,Et(),L.dispose(),(R||x)&&(e.removeEventListener("mousedown",H,{capture:!0}),e.removeEventListener("click",V,{capture:!0})),x&&e.removeEventListener("mousemove",G),_optionalChain([x, 'optionalAccess', _32 => _32.dispose, 'call', _33 => _33()]),_optionalChain([h, 'optionalAccess', _34 => _34.dispose, 'call', _35 => _35()]),_optionalChain([R, 'optionalAccess', _36 => _36.dispose, 'call', _37 => _37()]),_optionalChain([T, 'optionalAccess', _38 => _38.dispose, 'call', _39 => _39()]),_optionalChain([B, 'optionalAccess', _40 => _40.dispose, 'call', _41 => _41()]),c.dispose(),l.dispose(),s.dispose(),s.forceContextLoss(),o.traverse(g=>{let I=g;!I.geometry&&!I.material||(_optionalChain([I, 'access', _42 => _42.geometry, 'optionalAccess', _43 => _43.dispose, 'call', _44 => _44()]),Array.isArray(I.material)?I.material.forEach(Ee):I.material&&Ee(I.material))}),_optionalChain([o, 'access', _45 => _45.environment, 'optionalAccess', _46 => _46.dispose, 'call', _47 => _47()]),o.background instanceof E.Texture&&o.background.dispose())},fitToView:L.fitToView,clearSelection:L.clearSelection,addUserGeometry:ht,removeUserGeometry:gt,clearUserGeometry:yt}};function hn(e){let n=e.sceneScale||"m",r={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[n],i=_nullishCoalesce(e.look, () => (pn)),o=Te[i];return{sceneScale:n,look:i,camera:{position:_optionalChain([e, 'access', _48 => _48.camera, 'optionalAccess', _49 => _49.position])||new E.Vector3(-r.cameraDistance,-r.cameraDistance,r.cameraDistance),fov:_optionalChain([e, 'access', _50 => _50.camera, 'optionalAccess', _51 => _51.fov])||20,near:_optionalChain([e, 'access', _52 => _52.camera, 'optionalAccess', _53 => _53.near])||r.near,far:_optionalChain([e, 'access', _54 => _54.camera, 'optionalAccess', _55 => _55.far])||r.far,target:_optionalChain([e, 'access', _56 => _56.camera, 'optionalAccess', _57 => _57.target])||new E.Vector3(0,0,0)},lighting:{enableSunlight:_nullishCoalesce(_optionalChain([e, 'access', _58 => _58.lighting, 'optionalAccess', _59 => _59.enableSunlight]), () => (!0)),sunlightIntensity:_nullishCoalesce(_optionalChain([e, 'access', _60 => _60.lighting, 'optionalAccess', _61 => _61.sunlightIntensity]), () => (1)),sunlightPosition:_optionalChain([e, 'access', _62 => _62.lighting, 'optionalAccess', _63 => _63.sunlightPosition])||new E.Vector3(r.lightDistance,r.lightDistance,r.lightHeight),ambientLightColor:_optionalChain([e, 'access', _64 => _64.lighting, 'optionalAccess', _65 => _65.ambientLightColor])||new E.Color(4210752),ambientLightIntensity:_nullishCoalesce(_optionalChain([e, 'access', _66 => _66.lighting, 'optionalAccess', _67 => _67.ambientLightIntensity]), () => (o.ambientIntensity)),sunlightColor:_optionalChain([e, 'access', _68 => _68.lighting, 'optionalAccess', _69 => _69.sunlightColor])||16777215,enableHemisphereLight:_nullishCoalesce(_optionalChain([e, 'access', _70 => _70.lighting, 'optionalAccess', _71 => _71.enableHemisphereLight]), () => (o.hemisphereIntensity>0)),hemisphereSkyColor:_nullishCoalesce(_optionalChain([e, 'access', _72 => _72.lighting, 'optionalAccess', _73 => _73.hemisphereSkyColor]), () => (14673663)),hemisphereGroundColor:_nullishCoalesce(_optionalChain([e, 'access', _74 => _74.lighting, 'optionalAccess', _75 => _75.hemisphereGroundColor]), () => (7036754)),hemisphereIntensity:_nullishCoalesce(_optionalChain([e, 'access', _76 => _76.lighting, 'optionalAccess', _77 => _77.hemisphereIntensity]), () => (o.hemisphereIntensity))},environment:{hdrPath:_optionalChain([e, 'access', _78 => _78.environment, 'optionalAccess', _79 => _79.hdrPath])||"/baseHDR.hdr",backgroundColor:_optionalChain([e, 'access', _80 => _80.environment, 'optionalAccess', _81 => _81.backgroundColor])||new E.Color(15790320),enableEnvironmentLighting:_nullishCoalesce(_optionalChain([e, 'access', _82 => _82.environment, 'optionalAccess', _83 => _83.enableEnvironmentLighting]), () => (!0)),sceneUp:_optionalChain([e, 'access', _84 => _84.environment, 'optionalAccess', _85 => _85.sceneUp])||ie,showEnvironment:_nullishCoalesce(_optionalChain([e, 'access', _86 => _86.environment, 'optionalAccess', _87 => _87.showEnvironment]), () => (!1)),environmentIntensity:_nullishCoalesce(_optionalChain([e, 'access', _88 => _88.environment, 'optionalAccess', _89 => _89.environmentIntensity]), () => (o.environmentIntensity))},floor:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _90 => _90.floor, 'optionalAccess', _91 => _91.enabled]), () => (!1)),size:_optionalChain([e, 'access', _92 => _92.floor, 'optionalAccess', _93 => _93.size])||r.floorSize,color:_optionalChain([e, 'access', _94 => _94.floor, 'optionalAccess', _95 => _95.color])||new E.Color(8421504),roughness:_nullishCoalesce(_optionalChain([e, 'access', _96 => _96.floor, 'optionalAccess', _97 => _97.roughness]), () => (.7)),metalness:_nullishCoalesce(_optionalChain([e, 'access', _98 => _98.floor, 'optionalAccess', _99 => _99.metalness]), () => (0)),receiveShadow:_nullishCoalesce(_optionalChain([e, 'access', _100 => _100.floor, 'optionalAccess', _101 => _101.receiveShadow]), () => (!0))},render:{enableShadows:_nullishCoalesce(_optionalChain([e, 'access', _102 => _102.render, 'optionalAccess', _103 => _103.enableShadows]), () => (!0)),shadowMapSize:_optionalChain([e, 'access', _104 => _104.render, 'optionalAccess', _105 => _105.shadowMapSize])||2048,antialias:_nullishCoalesce(_optionalChain([e, 'access', _106 => _106.render, 'optionalAccess', _107 => _107.antialias]), () => (!0)),pixelRatio:_optionalChain([e, 'access', _108 => _108.render, 'optionalAccess', _109 => _109.pixelRatio])||Math.min(window.devicePixelRatio,2),toneMapping:_nullishCoalesce(_optionalChain([e, 'access', _110 => _110.render, 'optionalAccess', _111 => _111.toneMapping]), () => (o.toneMapping)),toneMappingExposure:_nullishCoalesce(_optionalChain([e, 'access', _112 => _112.render, 'optionalAccess', _113 => _113.toneMappingExposure]), () => (o.toneMappingExposure)),preserveDrawingBuffer:_nullishCoalesce(_optionalChain([e, 'access', _114 => _114.render, 'optionalAccess', _115 => _115.preserveDrawingBuffer]), () => (!1)),ambientOcclusion:_nullishCoalesce(_optionalChain([e, 'access', _116 => _116.render, 'optionalAccess', _117 => _117.ambientOcclusion]), () => (o.ambientOcclusion)),aoIntensity:_nullishCoalesce(_optionalChain([e, 'access', _118 => _118.render, 'optionalAccess', _119 => _119.aoIntensity]), () => (1)),aoPixelRatio:_nullishCoalesce(_optionalChain([e, 'access', _120 => _120.render, 'optionalAccess', _121 => _121.aoPixelRatio]), () => (1))},controls:{enableDamping:_nullishCoalesce(_optionalChain([e, 'access', _122 => _122.controls, 'optionalAccess', _123 => _123.enableDamping]), () => (!1)),dampingFactor:_optionalChain([e, 'access', _124 => _124.controls, 'optionalAccess', _125 => _125.dampingFactor])||.05,autoRotate:_nullishCoalesce(_optionalChain([e, 'access', _126 => _126.controls, 'optionalAccess', _127 => _127.autoRotate]), () => (!1)),autoRotateSpeed:_optionalChain([e, 'access', _128 => _128.controls, 'optionalAccess', _129 => _129.autoRotateSpeed])||.5,enableZoom:_nullishCoalesce(_optionalChain([e, 'access', _130 => _130.controls, 'optionalAccess', _131 => _131.enableZoom]), () => (!0)),enablePan:_nullishCoalesce(_optionalChain([e, 'access', _132 => _132.controls, 'optionalAccess', _133 => _133.enablePan]), () => (!0)),minDistance:_optionalChain([e, 'access', _134 => _134.controls, 'optionalAccess', _135 => _135.minDistance])||r.minDistance,maxDistance:_optionalChain([e, 'access', _136 => _136.controls, 'optionalAccess', _137 => _137.maxDistance])||1/0},grid:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _138 => _138.grid, 'optionalAccess', _139 => _139.enabled]), () => (!1)),cellSize:_nullishCoalesce(_optionalChain([e, 'access', _140 => _140.grid, 'optionalAccess', _141 => _141.cellSize]), () => (1)),majorEvery:_nullishCoalesce(_optionalChain([e, 'access', _142 => _142.grid, 'optionalAccess', _143 => _143.majorEvery]), () => (10)),cellColor:_nullishCoalesce(_optionalChain([e, 'access', _144 => _144.grid, 'optionalAccess', _145 => _145.cellColor]), () => (8947848)),majorColor:_nullishCoalesce(_optionalChain([e, 'access', _146 => _146.grid, 'optionalAccess', _147 => _147.majorColor]), () => (4473924)),fadeDistance:_nullishCoalesce(_optionalChain([e, 'access', _148 => _148.grid, 'optionalAccess', _149 => _149.fadeDistance]), () => (100)),plane:_nullishCoalesce(_optionalChain([e, 'access', _150 => _150.grid, 'optionalAccess', _151 => _151.plane]), () => (En(_nullishCoalesce(_optionalChain([e, 'access', _152 => _152.environment, 'optionalAccess', _153 => _153.sceneUp]), () => (ie)))))},gizmo:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _154 => _154.gizmo, 'optionalAccess', _155 => _155.enabled]), () => (!1))},edges:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _156 => _156.edges, 'optionalAccess', _157 => _157.enabled]), () => (!1)),color:_nullishCoalesce(_optionalChain([e, 'access', _158 => _158.edges, 'optionalAccess', _159 => _159.color]), () => (2236962)),width:_nullishCoalesce(_optionalChain([e, 'access', _160 => _160.edges, 'optionalAccess', _161 => _161.width]), () => (1.5)),thresholdAngle:_nullishCoalesce(_optionalChain([e, 'access', _162 => _162.edges, 'optionalAccess', _163 => _163.thresholdAngle]), () => (30))},measure:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _164 => _164.measure, 'optionalAccess', _165 => _165.enabled]), () => (!1)),snapPixels:_optionalChain([e, 'access', _166 => _166.measure, 'optionalAccess', _167 => _167.snapPixels]),color:_optionalChain([e, 'access', _168 => _168.measure, 'optionalAccess', _169 => _169.color]),labelClassName:_optionalChain([e, 'access', _170 => _170.measure, 'optionalAccess', _171 => _171.labelClassName]),displayUnit:_optionalChain([e, 'access', _172 => _172.measure, 'optionalAccess', _173 => _173.displayUnit]),format:_optionalChain([e, 'access', _174 => _174.measure, 'optionalAccess', _175 => _175.format])},events:{onBackgroundClicked:_optionalChain([e, 'access', _176 => _176.events, 'optionalAccess', _177 => _177.onBackgroundClicked]),onObjectSelected:_optionalChain([e, 'access', _178 => _178.events, 'optionalAccess', _179 => _179.onObjectSelected]),onMeshMetadataClicked:_optionalChain([e, 'access', _180 => _180.events, 'optionalAccess', _181 => _181.onMeshMetadataClicked]),onMeshDoubleClicked:_optionalChain([e, 'access', _182 => _182.events, 'optionalAccess', _183 => _183.onMeshDoubleClicked]),selectionColor:_optionalChain([e, 'access', _184 => _184.events, 'optionalAccess', _185 => _185.selectionColor])||"#ff0000",enableEventHandlers:_nullishCoalesce(_optionalChain([e, 'access', _186 => _186.events, 'optionalAccess', _187 => _187.enableEventHandlers]), () => (!0)),enableKeyboardControls:_nullishCoalesce(_optionalChain([e, 'access', _188 => _188.events, 'optionalAccess', _189 => _189.enableKeyboardControls]), () => (!0)),enableClickToFocus:_nullishCoalesce(_optionalChain([e, 'access', _190 => _190.events, 'optionalAccess', _191 => _191.enableClickToFocus]), () => (!0)),enableDoubleClickZoom:_nullishCoalesce(_optionalChain([e, 'access', _192 => _192.events, 'optionalAccess', _193 => _193.enableDoubleClickZoom]), () => (!0)),onReady:_optionalChain([e, 'access', _194 => _194.events, 'optionalAccess', _195 => _195.onReady]),onFrame:_optionalChain([e, 'access', _196 => _196.events, 'optionalAccess', _197 => _197.onFrame])}}}function Ee(e){for(let n of Object.values(e))n instanceof E.Texture&&n.dispose();e.dispose()}function gn(e,n){if(n.isEmpty())return;let t=n.getCenter(new E.Vector3),r=n.getSize(new E.Vector3).length()*.5*1.2,i=e.shadow.camera;i.left=-r,i.right=r,i.top=r,i.bottom=-r,e.target.position.copy(t),e.target.updateMatrixWorld();let o=e.position.distanceTo(t);i.near=Math.max(r*.01,o-r),i.far=o+r,i.updateProjectionMatrix()}function yn(e){let n=new E.Scene,t=typeof e.environment.backgroundColor=="string"?new E.Color(e.environment.backgroundColor):e.environment.backgroundColor;return n.background=t||null,n}function bn(e,n,t,r,i,o,a,s,l,c,d,m,u){let f=null,b=performance.now(),T=()=>{let{width:h,height:x}=a();if(h===0||x===0)return;let L=Math.floor(h*s),p=Math.floor(x*s);(e.domElement.width!==L||e.domElement.height!==p)&&(e.setPixelRatio(s),e.setSize(h,x,!1),t.aspect=h/x,t.updateProjectionMatrix(),i.updateAspect(h,x),_optionalChain([m, 'optionalCall', _198 => _198(), 'optionalAccess', _199 => _199.setSize, 'call', _200 => _200(h,x,s)]),_optionalChain([u, 'optionalAccess', _201 => _201.setSize, 'call', _202 => _202(h,x)]))},R=function(){f=requestAnimationFrame(R);let h=performance.now(),x=(h-b)/1e3;b=h,T(),(o.enableDamping||o.autoRotate)&&o.update(),c&&c.update(r().position),d&&d.update(x),_optionalChain([l, 'optionalCall', _203 => _203(x)]);let L=r(),p=_optionalChain([m, 'optionalCall', _204 => _204()]);p?(p.setCamera(L),p.render(x)):e.render(n,L),u&&u.render(n,L),d&&d.render(e)};return{animate:R,dispose:()=>{f!==null&&(cancelAnimationFrame(f),f=null)}}}function Tn(e,n,t){n.environment.enableEnvironmentLighting?new (0, _HDRLoaderjs.HDRLoader)().load(n.environment.hdrPath||"/baseHDR.hdr",function(r){if(t()){r.dispose();return}if(!_optionalChain([r, 'optionalAccess', _205 => _205.image])){_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("HDR loaded without image data; skipping environment map."),_optionalChain([r, 'optionalAccess', _206 => _206.dispose, 'call', _207 => _207()]),_optionalChain([n, 'access', _208 => _208.events, 'access', _209 => _209.onReady, 'optionalCall', _210 => _210()]);return}r.mapping=E.EquirectangularReflectionMapping,e.environment=r,e.environmentIntensity=_nullishCoalesce(n.environment.environmentIntensity, () => (1)),n.environment.showEnvironment&&(e.background=r),_optionalChain([n, 'access', _211 => _211.events, 'access', _212 => _212.onReady, 'optionalCall', _213 => _213()])},void 0,function(r){t()||(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("HDR texture could not be loaded, falling back to basic lighting:",r),_optionalChain([n, 'access', _214 => _214.events, 'access', _215 => _215.onReady, 'optionalCall', _216 => _216()]))}):_optionalChain([n, 'access', _217 => _217.events, 'access', _218 => _218.onReady, 'optionalCall', _219 => _219()])}function Rn(e,n){let t=new E.AmbientLight(n.lighting.ambientLightColor,n.lighting.ambientLightIntensity);e.add(t);let r=null;if(n.lighting.enableHemisphereLight){r=new E.HemisphereLight(n.lighting.hemisphereSkyColor,n.lighting.hemisphereGroundColor,n.lighting.hemisphereIntensity);let a=_nullishCoalesce(n.environment.sceneUp, () => (ie));r.position.copy(a),e.add(r)}if(!n.lighting.enableSunlight)return{ambient:t,hemisphere:r,sun:null};let i=new E.DirectionalLight(_nullishCoalesce(n.lighting.sunlightColor, () => (16777215)),n.lighting.sunlightIntensity),o=n.lighting.sunlightPosition;return o&&i.position.set(o.x,o.y,o.z),n.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=n.render.shadowMapSize||2048,i.shadow.mapSize.height=n.render.shadowMapSize||2048,i.shadow.bias=-1e-4,i.shadow.normalBias=.02,i.shadow.radius=4,e.add(i),e.add(i.target),{ambient:t,hemisphere:r,sun:i}):(e.add(i),{ambient:t,hemisphere:r,sun:null})}function vn(e,n){let t=n.floor.size,r=new E.PlaneGeometry(t,t),i=typeof n.floor.color=="string"?new E.Color(n.floor.color):n.floor.color,o=new E.MeshStandardMaterial({color:i,roughness:n.floor.roughness,metalness:n.floor.metalness,side:E.DoubleSide}),a=new E.Mesh(r,o);a.userData.id="floor",a.name="floor";let s=(_optionalChain([n, 'access', _220 => _220.environment, 'optionalAccess', _221 => _221.sceneUp])||ie).clone().normalize();a.quaternion.setFromUnitVectors(new E.Vector3(0,0,1),s),a.position.set(0,0,0),n.floor.receiveShadow&&n.render.enableShadows&&(a.receiveShadow=!0),e.add(a)}function xn(e,n){let t=n.parentElement,r=t?t.clientWidth:window.innerWidth,i=t?t.clientHeight:window.innerHeight,o=new E.PerspectiveCamera(e.camera.fov,r/i,e.camera.near,e.camera.far),a=e.camera.position;return a&&o.position.set(a.x,a.y,a.z),o}function Hn(e,n,t){let r=new E.WebGLRenderer({antialias:n.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:n.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),i=e.parentElement,o=i?i.clientWidth:window.innerWidth,a=i?i.clientHeight:window.innerHeight;return i&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),r.setSize(o,a,!1),r.setPixelRatio(t),n.render.enableShadows&&(r.shadowMap.enabled=!0,r.shadowMap.type=E.VSMShadowMap),r.toneMapping=n.render.toneMapping,r.toneMappingExposure=_nullishCoalesce(n.render.toneMappingExposure, () => (1)),r.outputColorSpace=E.SRGBColorSpace,r.sortObjects=!0,r}function wn(e,n,t,r){let i=new Set,o=new Map,a=new E.Raycaster,s=new E.Vector2,l=new E.Vector2,c=()=>t.getActiveCamera(),d=p=>{let v=p;for(;v;){if(!v.visible)return!1;v=v.parent}return!0},m=()=>{let p=re(n);if(p.isEmpty()){_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("No objects to fit to view");return}t.frameBounds(p,!1)},u=typeof r.events.selectionColor=="string"?new E.Color(r.events.selectionColor):r.events.selectionColor instanceof E.Color?r.events.selectionColor:new E.Color("#ff0000"),f=()=>{i.forEach(p=>{let v=p;if(o.has(p)){let y=o.get(p),H=v.material;H instanceof E.Material?H.dispose():Array.isArray(H)&&H.forEach(V=>V.dispose()),v.material=y,o.delete(p);let A=p;for(;A.parent;)A=A.parent;A!==n&&(y instanceof E.Material?y.dispose():y.forEach(V=>V.dispose()))}}),i.clear()},b=p=>{let v=p;if(!(v.material instanceof E.Material))return!1;o.set(p,v.material);let y=v.material.clone();return p instanceof E.Mesh&&"emissive"in y?y.emissive=u.clone():"color"in y&&(y.color=u.clone()),v.material=y,!0},T=()=>{let p=re(n),v=p.isEmpty()?1:p.getSize(new E.Vector3).length();a.params.Points.threshold=v*.01},R=p=>{l.set(p.clientX,p.clientY)},C=p=>{let v=new E.Vector2(p.clientX,p.clientY);if(l.distanceTo(v)>5)return;let y=e.getBoundingClientRect();s.x=(p.clientX-y.left)/y.width*2-1,s.y=-((p.clientY-y.top)/y.height)*2+1,T(),a.setFromCamera(s,c());let H=a.intersectObjects(n.children,!0).filter(A=>d(A.object));if(H.length>0){let A=H[0].object;i.has(A)||(f(),i.add(A),b(A),_optionalChain([r, 'access', _222 => _222.events, 'optionalAccess', _223 => _223.onObjectSelected, 'optionalCall', _224 => _224(A)]),A instanceof E.Mesh&&Object.keys(A.userData).length>0&&_optionalChain([r, 'access', _225 => _225.events, 'optionalAccess', _226 => _226.onMeshMetadataClicked, 'optionalCall', _227 => _227(A.userData)]))}else f(),_optionalChain([r, 'access', _228 => _228.events, 'optionalAccess', _229 => _229.onBackgroundClicked, 'optionalCall', _230 => _230({x:s.x,y:s.y})])},h=p=>{let v=e.getBoundingClientRect();s.x=(p.clientX-v.left)/v.width*2-1,s.y=-((p.clientY-v.top)/v.height)*2+1,T(),a.setFromCamera(s,c());let y=a.intersectObjects(n.children,!0).filter(V=>d(V.object));if(y.length===0)return;let H=y[0].object;if(_optionalChain([r, 'access', _231 => _231.events, 'optionalAccess', _232 => _232.onMeshDoubleClicked, 'optionalCall', _233 => _233(H)]),!_optionalChain([r, 'access', _234 => _234.events, 'optionalAccess', _235 => _235.enableDoubleClickZoom]))return;let A=new E.Box3().setFromObject(H);A.isEmpty()||t.frameBounds(A,!0)},x=p=>{if(_optionalChain([r, 'access', _236 => _236.events, 'optionalAccess', _237 => _237.enableKeyboardControls]))switch(p.key.toLowerCase()){case"f":p.preventDefault(),m();break;case"escape":p.preventDefault(),f();break;case" ":p.preventDefault(),m();break}};return _optionalChain([r, 'access', _238 => _238.events, 'optionalAccess', _239 => _239.enableClickToFocus])&&(e.addEventListener("mousedown",R),e.addEventListener("click",C),e.addEventListener("dblclick",h)),_optionalChain([r, 'access', _240 => _240.events, 'optionalAccess', _241 => _241.enableKeyboardControls])&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",x)),{dispose:()=>{e.removeEventListener("mousedown",R),e.removeEventListener("click",C),e.removeEventListener("dblclick",h),e.removeEventListener("keydown",x),f()},fitToView:m,clearSelection:f}}function Cn(e,n,t){let r=new (0, _OrbitControlsjs.OrbitControls)(e,n),i=t.camera.target;return i&&r.target.set(i.x,i.y,i.z),r.enableDamping=t.controls.enableDamping||!1,r.dampingFactor=t.controls.dampingFactor||.05,r.autoRotate=t.controls.autoRotate||!1,r.autoRotateSpeed=t.controls.autoRotateSpeed||.5,r.enableZoom=_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 To=["technical","studio","showcase"];function he(e,n,t,r=!0){return{x:e,y:n,z:t}}var Ln="#ffffff",Je=12,In=4e-4,Dn=12,On=.05;function Qe(e,n={}){if(!e||e.length===0)return[];let{rhino:t,applyTransforms:r=!0}=n,i=[];for(let o of e)switch(o.kind){case"curve":{let a=Vn(o,t,r);a&&i.push(a);break}case"point":{let a=Bn(o,r);a&&i.push(a);break}default:{let s=o;_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Skipping unknown display item kind: ${String(s.kind)}`);break}}return i}var Pn=2;function Vn(e,n,t){if(!n)return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("No rhino3dm instance provided; skipping curve display item."),null;let r=Fn(e.json,n);if(!r)return null;let i;try{i=kn(r,t)}catch(m){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Failed to tessellate curve display item; skipping.",m),null}finally{se(r)}if(i.length<2)return null;let o=[];for(let m of i)o.push(m.x,m.y,m.z);let a=new _LineGeometryjs.LineGeometry;a.setPositions(o);let s=et(e.color,e.opacity),l=new (0, _LineMaterialjs.LineMaterial)({color:s.color}),c=l;c.linewidth=_nullishCoalesce(e.width, () => (Pn)),c.transparent=s.transparent,c.opacity=s.opacity;let d=new (0, _Line2js.Line2)(a,l);return d.computeLineDistances(),d.name=e.name,d.userData={source:"compute",id:e.id,layer:e.layer,kind:"curve",metadata:e.metadata},d}function Bn(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 _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Skipping point display item with missing or non-finite position (id: ${String(e.id)}).`),null;let{x:r,y:i,z:o}=he(t.X,t.Y,t.Z,n),a=new $.BufferGeometry;a.setAttribute("position",new $.Float32BufferAttribute([r,i,o],3));let s=new $.PointsMaterial({...et(e.color,e.opacity),size:6,sizeAttenuation:!1}),l=new $.Points(a,s);return l.name=e.name,l.userData={source:"compute",id:e.id,layer:e.layer,kind:"point",metadata:e.metadata},l}function se(e){_optionalChain([e, 'optionalAccess', _242 => _242.delete, 'optionalCall', _243 => _243()])}function Fn(e,n){try{let t=JSON.parse(e),r=n.CommonObject.decode(t);return r&&typeof r.pointAt=="function"?r:(se(r),_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Decoded display-item JSON is not a curve; skipping."),null)}catch(t){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Failed to decode curve display item JSON:",t),null}}function kn(e,n){let t=Un(e,n);return t||zn(e,n)}function Un(e,n){if(!e.isPolyline())return null;let t=e.tryGetPolyline(),r=Array.isArray(t)?t[1]:t;if(!r||typeof r.count!="number"||r.count<2)return se(r),null;let i=[];for(let o=0;o<r.count;o++){let a=r.get(o),{x:s,y:l,z:c}=he(a[0],a[1],a[2],n);i.push(new $.Vector3(s,l,c))}return se(r),i}function zn(e,n){let t=e.domain,r=t[0],o=t[1]-r,a=m=>{let u=e.pointAt(m),{x:f,y:b,z:T}=he(u[0],u[1],u[2],n);return new $.Vector3(f,b,T)},s=_n(e),l=r,c=a(r),d=[c];for(let m=0;m<Je;m++){let u=r+o*(m+1)/Je,f=a(u);Re(l,c,u,f,a,s,Dn,d),d.push(f),l=u,c=f}return d}function Re(e,n,t,r,i,o,a,s){if(a<=0)return;let l=(e+t)/2,c=i(l),d=Gn(c,n,r),m=jn(n,c,r);d<=o&&m<=On||(Re(e,n,l,c,i,o,a-1,s),s.push(c),Re(l,c,t,r,i,o,a-1,s))}function _n(e){let n=e.getBoundingBox(),t=n.min,r=n.max;se(n);let i=Math.hypot(r[0]-t[0],r[1]-t[1],r[2]-t[2]);return Math.max(i*In,1e-6)}function jn(e,n,t){let r=n.x-e.x,i=n.y-e.y,o=n.z-e.z,a=t.x-n.x,s=t.y-n.y,l=t.z-n.z,c=Math.sqrt(r*r+i*i+o*o),d=Math.sqrt(a*a+s*s+l*l);if(c===0||d===0)return 0;let m=r*a+i*s+o*l,u=Math.max(-1,Math.min(1,m/(c*d)));return Math.acos(u)}function Gn(e,n,t){let r=t.x-n.x,i=t.y-n.y,o=t.z-n.z,a=r*r+i*i+o*o;if(a===0)return e.distanceTo(n);let s=e.x-n.x,l=e.y-n.y,c=e.z-n.z,d=Math.max(0,Math.min(1,(s*r+l*i+c*o)/a)),m=s-r*d,u=l-i*d,f=c-o*d;return Math.sqrt(m*m+u*u+f*f)}function et(e,n){let t=_nullishCoalesce(n, () => (1));return{color:new $.Color(_nullishCoalesce(e, () => (Ln))),transparent:t<1,opacity:t}}var _fflate = require('fflate');var tt=1096174675,Wn= exports.y =1515605075,nt= exports.z =3,rt= exports.A =1,xe= exports.B =1,$n= exports.C =2,Yn= exports.D =4,Xn= exports.E =8,qn= exports.F =16,Do= exports.G =0,Zn= exports.H =1,ot=12,it=56,Kn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;function He(e){if(!Kn)throw new (0, _chunkCUQQ3ZBVcjs.d)("SLVA parsing requires a little-endian host: the zero-copy geometry readers view the wire bytes in host byte order.",_chunkCUQQ3ZBVcjs.c.ENVIRONMENT_ERROR);let n=tr(er(e)),t=new DataView(n.buffer,n.byteOffset,n.byteLength);if(n.byteLength<ot)throw _("Blob too small to contain SLVA header.",{expectedBytes:ot,availableBytes:n.byteLength});let r=0,i=t.getUint32(r,!0);if(r+=4,i!==tt)throw _(`Invalid SLVA magic: 0x${i.toString(16)}`,{expectedMagic:`0x${tt.toString(16)}`,actualMagic:`0x${i.toString(16)}`});let o=t.getUint32(r,!0);if(r+=4,o<rt||o>nt)throw _(`Unsupported SLVA version: ${o}`,{minSupportedVersion:rt,maxSupportedVersion:nt,actualVersion:o});let a=t.getUint32(r,!0);if(r+=4,r+a>n.byteLength)throw _("Insufficient data to read metadata JSON.",{expectedBytes:a,availableBytes:n.byteLength-r,offset:r});let s=n.subarray(r,r+a);r+=a;let l;try{l=JSON.parse(nr(s))}catch(B){throw _(`Failed to parse metadata JSON: ${B instanceof Error?B.message:String(B)}`,{metadataLen:a})}if(r+it>n.byteLength)throw _("Insufficient data to read geometry header.",{expectedBytes:it,availableBytes:n.byteLength-r,offset:r});let c=t.getUint32(r,!0);r+=4;let d=t.getFloat64(r,!0);r+=8;let m=t.getFloat64(r,!0);r+=8;let u=t.getFloat64(r,!0);r+=8;let f=t.getFloat64(r,!0);r+=8;let b=t.getFloat64(r,!0);r+=8;let T=t.getFloat64(r,!0);r+=8;let R=t.getUint32(r,!0);r+=4;let C=(c&xe)!==0,h=(c&Yn)!==0,x=R*3,p=x*(C?4:2);if(r+p>n.byteLength)throw _("Insufficient data to read vertices.",{expectedBytes:p,availableBytes:n.byteLength-r,offset:r,useFloat32:C,vertexCount:R});let v=n.byteOffset+r,y;if(C?y=st(n.buffer,v,x):h?y=ar(ve(n.buffer,v,x)):y=rr(n.buffer,v,x),r+=p,r+4>n.byteLength)throw _("Insufficient data to read index count.",{expectedBytes:4,availableBytes:n.byteLength-r,offset:r});let H=t.getUint32(r,!0);r+=4;let A=(c&$n)!==0,G=H*(A?2:4);if(r+G>n.byteLength)throw _("Insufficient data to read indices.",{expectedBytes:G,availableBytes:n.byteLength-r,offset:r,indexCount:H,useUint16Indices:A});let F=A?ve(n.buffer,n.byteOffset+r,H):or(n.buffer,n.byteOffset+r,H);h&&(F=F instanceof Uint16Array?sr(F):lr(F)),ir(F,R),r+=G;let Y=null;if((c&Xn)!==0){let B=Jn(n,t,r,R,h);Y=B.uvs,r=B.offset}let J=null;return(c&qn)!==0&&(J=Qn(n,r,R,h)),{metadata:l,flags:c,vertices:y,indices:F,origin:[d,m,u],scale:[f,b,T],uvs:Y,colors:J}}var at=36;function Jn(e,n,t,r,i){if(t+at>e.byteLength)throw _("Insufficient data to read UV chunk header.",{expectedBytes:at,availableBytes:e.byteLength-t,offset:t});let o=n.getUint32(t,!0);t+=4;let a=n.getFloat64(t,!0);t+=8;let s=n.getFloat64(t,!0);t+=8;let l=n.getFloat64(t,!0);t+=8;let c=n.getFloat64(t,!0);t+=8;let d=r*2,m=o===Zn,u=d*(m?4:2);if(t+u>e.byteLength)throw _("Insufficient data to read UV chunk.",{expectedBytes:u,availableBytes:e.byteLength-t,offset:t,uvFormat:o,vertexCount:r});let f=e.byteOffset+t,b;if(m)b=st(e.buffer,f,d).slice();else{let T=ve(e.buffer,f,d);b=new Float32Array(d);let R=0,C=0;for(let h=0;h<d;h+=2)i?(R=R+Z(T[h])&65535,C=C+Z(T[h+1])&65535):(R=T[h],C=T[h+1]),b[h]=a+R*l,b[h+1]=s+C*c}return{uvs:b,offset:t+u}}function Qn(e,n,t,r){let i=t*3;if(n+i>e.byteLength)throw _("Insufficient data to read vertex-color chunk.",{expectedBytes:i,availableBytes:e.byteLength-n,offset:n,vertexCount:t});let o=e.subarray(n,n+i);if(!r)return o.slice();let a=new Uint8Array(i),s=0,l=0,c=0;for(let d=0;d<i;d+=3)s=s+Z(o[d])&255,l=l+Z(o[d+1])&255,c=c+Z(o[d+2])&255,a[d]=s,a[d+1]=l,a[d+2]=c;return a}function er(e){return typeof e=="string"?_chunkCUQQ3ZBVcjs.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)!==Wn)return e;let t=n.getUint32(4,!0),r=e.subarray(8),i=Math.max(r.byteLength*1032+1024,1<<20);if(t>i)throw _("SLVZ header declares an implausible uncompressed length",{uncompressedLen:t,deflatedBytes:r.byteLength,maxPlausibleLen:i});let o;try{o=_fflate.inflateSync.call(void 0, r,{out:new Uint8Array(t+1)})}catch(a){throw _(`Failed to inflate SLVZ blob: ${a instanceof Error?a.message:String(a)}`,{uncompressedLen:t,deflatedBytes:r.byteLength})}if(o.byteLength!==t)throw _("SLVZ payload inflated to a different size than the header declares.",{declaredLen:t,actualLen:o.byteLength,deflatedBytes:r.byteLength});return o}function nr(e){if(typeof TextDecoder<"u")return new TextDecoder("utf-8").decode(e);if(typeof globalThis.Buffer<"u")return globalThis.Buffer.from(e).toString("utf-8");throw new (0, _chunkCUQQ3ZBVcjs.d)("No UTF-8 decoder available in this environment.",_chunkCUQQ3ZBVcjs.c.INVALID_STATE)}function rr(e,n,t){if(t===0)return new Int16Array(0);if(n%2===0)return new Int16Array(e,n,t);let r=new Uint8Array(t*2);return r.set(new Uint8Array(e,n,t*2)),new Int16Array(r.buffer)}function st(e,n,t){if(t===0)return new Float32Array(0);if(n%4===0)return new Float32Array(e,n,t);let r=new Uint8Array(t*4);return r.set(new Uint8Array(e,n,t*4)),new Float32Array(r.buffer)}function ve(e,n,t){if(t===0)return new Uint16Array(0);if(n%2===0)return new Uint16Array(e,n,t);let r=new Uint8Array(t*2);return r.set(new Uint8Array(e,n,t*2)),new Uint16Array(r.buffer)}function or(e,n,t){if(t===0)return new Uint32Array(0);if(n%4===0)return new Uint32Array(e,n,t);let r=new Uint8Array(t*4);return r.set(new Uint8Array(e,n,t*4)),new Uint32Array(r.buffer)}function ir(e,n){if(e.length!==0&&!(e instanceof Uint16Array&&n>65535)){for(let t=0;t<e.length;t++)if(e[t]>=n)throw _("Index out of range of vertexCount.",{indexPosition:t,indexValue:e[t],vertexCount:n})}}function Z(e){return e>>>1^-(e&1)}function ar(e){let n=new Int16Array(e.length),t=0,r=0,i=0;for(let o=0;o<e.length;o+=3)t=t+Z(e[o])<<16>>16,r=r+Z(e[o+1])<<16>>16,i=i+Z(e[o+2])<<16>>16,n[o]=t,n[o+1]=r,n[o+2]=i;return n}function sr(e){let n=new Uint16Array(e.length),t=0;for(let r=0;r<e.length;r++)t=t+Z(e[r])&65535,n[r]=t;return n}function lr(e){let n=new Uint32Array(e.length),t=0;for(let r=0;r<e.length;r++)t=t+Z(e[r])>>>0,n[r]=t;return n}function _(e,n){return new (0, _chunkCUQQ3ZBVcjs.d)(e,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:n})}async function Uo(e,n){let{debug:t=!1}=_nullishCoalesce(n, () => ({})),r=t?performance.now():0,i,o=performance.now();try{i=JSON.parse(e)}catch(s){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).error("Error parsing mesh batch envelope JSON:",s),[]}let a=performance.now()-o;return await we(i,n,{parseTime:a,perfStart:r})}async function we(e,n,t){let{mergeByMaterial:r=!0,applyTransforms:i=!0,debug:o=!1,material:a}=_nullishCoalesce(n, () => ({})),{parseTime:s=0,perfStart:l=o?performance.now():0}=_nullishCoalesce(t, () => ({}));if(!e.compressedData)return[];let c=performance.now(),d=He(e.compressedData),m=performance.now()-c,u=o?hr(e.compressedData):0;return lt(d,{mergeByMaterial:r,applyTransforms:i,debug:o,material:a,parseTime:s,decodeTime:m,perfStart:l,blobBytes:u,fallback:{materials:e.materials,groups:e.groups,sourceComponentId:e.sourceComponentId}})}async function zo(e,n){let{mergeByMaterial:t=!0,applyTransforms:r=!0,debug:i=!1,material:o}=_nullishCoalesce(n, () => ({})),a=i?performance.now():0,s=performance.now(),l=He(e),c=performance.now()-s,d=e.byteLength;return lt(l,{mergeByMaterial:t,applyTransforms:r,debug:i,material:o,parseTime:0,decodeTime:c,perfStart:a,blobBytes:d})}function lt(e,n){let{mergeByMaterial:t,applyTransforms:r,debug:i,material:o,parseTime:a,decodeTime:s,perfStart:l,blobBytes:c,fallback:d}=n,m=_nullishCoalesce(_nullishCoalesce(e.metadata.materials, () => (_optionalChain([d, 'optionalAccess', _244 => _244.materials]))), () => ([])),u=_nullishCoalesce(_nullishCoalesce(e.metadata.groups, () => (_optionalChain([d, 'optionalAccess', _245 => _245.groups]))), () => ([])),f=_nullishCoalesce(_optionalChain([d, 'optionalAccess', _246 => _246.sourceComponentId]), () => (e.metadata.sourceComponentId)),b=(e.flags&xe)!==0;cr(u,m.length,e.vertices.length/3,e.indices.length);let T=b?dr(e.vertices,r):ur(e.vertices,e.origin,e.scale,r);if(i){let L=e.vertices.byteLength+e.indices.byteLength;_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug("Mesh Batch Stats:"),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Materials: ${m.length} | Groups: ${u.length}`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Format: ${b?"float32":"int16 quantized"}`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Blob: ${(c/1024/1024).toFixed(2)} MB | Geometry on wire: ${(L/1024/1024).toFixed(2)} MB`)}let R=performance.now(),C=m.map(L=>mr(L,{vertexColors:e.colors!=null,appearance:o})),h=[];for(let L of u)if(t&&L.meshes.length>1){let p=fr(L,T,e.indices,C,e.uvs,e.colors);p.userData.sourceComponentId=_nullishCoalesce(f, () => (null)),h.push(p)}else{let p=Er(L,T,e.indices,C,e.uvs,e.colors);for(let v of p)v.userData.sourceComponentId=_nullishCoalesce(f, () => (null));h.push(...p)}let x=performance.now()-R;if(i){let L=performance.now()-l;_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug("Performance:"),a>0&&_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Parse JSON: ${a.toFixed(2)}ms`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Decode binary: ${s.toFixed(2)}ms`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Create Meshes: ${x.toFixed(2)}ms`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Total: ${L.toFixed(2)}ms`)}return Promise.resolve(h)}function le(e,n){return new (0, _chunkCUQQ3ZBVcjs.d)(e,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:n})}function cr(e,n,t,r){for(let i of e){if(!Number.isInteger(i.materialId)||i.materialId<0||i.materialId>=n)throw le("Group materialId out of range of the materials array.",{materialId:i.materialId,materialCount:n});for(let o of i.meshes){let a={vertexStart:o.vertexStart,vertexCount:o.vertexCount,indexStart:o.indexStart,indexCount:o.indexCount};for(let[s,l]of Object.entries(a))if(!Number.isInteger(l)||l<0)throw le(`Mesh metadata field "${s}" must be a non-negative integer.`,{meshName:o.name,field:s,value:l});if(o.vertexStart+o.vertexCount>t)throw le("Mesh vertex window exceeds the batch vertex buffer.",{meshName:o.name,vertexStart:o.vertexStart,vertexCount:o.vertexCount,totalVertexCount:t});if(o.indexStart+o.indexCount>r)throw le("Mesh index window exceeds the batch index buffer.",{meshName:o.name,indexStart:o.indexStart,indexCount:o.indexCount,totalIndexCount:r})}}}function ct(e,n){if(e<n.vertexStart||e>=n.vertexStart+n.vertexCount)throw le("Index references a vertex outside its mesh's vertex window.",{meshName:n.name,indexValue:e,vertexStart:n.vertexStart,vertexCount:n.vertexCount})}function ur(e,n,t,r){let i=new Float32Array(e.length),o=n[0],a=n[1],s=n[2],l=t[0],c=t[1],d=t[2];for(let m=0;m<e.length;m+=3)i[m]=o+(e[m]+32767)*l,i[m+1]=a+(e[m+1]+32767)*c,i[m+2]=s+(e[m+2]+32767)*d;return i}function dr(e,n){return e}function mr(e,n){let t=Fe(e.color),r=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _247 => _247.vertexColors]), () => (!1)),i=_optionalChain([n, 'optionalAccess', _248 => _248.appearance]),o=new P.MeshPhysicalMaterial({color:t,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,vertexColors:r,side:_optionalChain([i, 'optionalAccess', _249 => _249.cullBackfaces])?P.FrontSide:P.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0});return _optionalChain([i, 'optionalAccess', _250 => _250.envMapIntensity])!=null&&(o.envMapIntensity=i.envMapIntensity),r&&pr(o),e.map&&Ke(o,e.map),o}function pr(e){e.onBeforeCompile=n=>{n.vertexShader=n.vertexShader.replace("#include <color_vertex>",`#include <color_vertex>
55
55
  #if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
56
56
  vColor.rgb = mix(
57
57
  vColor.rgb / 12.92,
58
58
  pow( ( vColor.rgb + 0.055 ) / 1.055, vec3( 2.4 ) ),
59
59
  step( vec3( 0.04045 ), vColor.rgb )
60
60
  );
61
- #endif`)}}function fr(e,n,t,r,i=null,o=null){let a=0,s=0;for(let h of e.meshes)a+=h.vertexCount,s+=h.indexCount;let l=new Float32Array(a*3),c=new Uint32Array(s),d=i?new Float32Array(a*2):null,m=o?new Uint8Array(a*3):null,u=0,f=0;for(let h of e.meshes){let w=h.vertexStart*3,L=h.vertexCount*3;if(l.set(n.subarray(w,w+L),u*3),d&&i){let y=h.vertexStart*2;d.set(i.subarray(y,y+h.vertexCount*2),u*2)}m&&o&&m.set(o.subarray(w,w+L),u*3);let p=t.subarray(h.indexStart,h.indexStart+h.indexCount),v=u-h.vertexStart;for(let y=0;y<p.length;y++){let x=p[y];ct(x,h),c[f+y]=x+v}u+=h.vertexCount,f+=h.indexCount}let b=new P.BufferGeometry;b.setAttribute("position",new P.BufferAttribute(l,3)),b.setIndex(new P.BufferAttribute(c,1)),d&&b.setAttribute("uv",new P.BufferAttribute(d,2)),m&&b.setAttribute("color",new P.BufferAttribute(m,3,!0)),b.computeVertexNormals();let T=new P.Mesh(b,r[e.materialId]),R=e.meshes[0],M=e.meshes.map(h=>h.name).filter(h=>h&&h.length>0);return T.name=M.length>0?M[0]:`merged_material_${e.materialId}`,T.castShadow=!0,T.receiveShadow=!0,T.userData={source:"compute",name:T.name,layer:_nullishCoalesce(_optionalChain([R, 'optionalAccess', _251 => _251.layer]), () => ("")),originalIndex:_nullishCoalesce(_optionalChain([R, 'optionalAccess', _252 => _252.originalIndex]), () => (0)),metadata:_nullishCoalesce(_optionalChain([R, 'optionalAccess', _253 => _253.metadata]), () => ({})),mergedFrom:e.meshes.slice(1).map(h=>({name:h.name,layer:h.layer,originalIndex:h.originalIndex}))},T}function Er(e,n,t,r,i=null,o=null){let a=[];for(let s of e.meshes){let l=s.vertexStart*3,c=s.vertexCount*3,d=n.slice(l,l+c),m=t.subarray(s.indexStart,s.indexStart+s.indexCount),u=new Uint32Array(m.length),f=s.vertexStart;for(let R=0;R<m.length;R++){let M=m[R];ct(M,s),u[R]=M-f}let b=new P.BufferGeometry;if(b.setAttribute("position",new P.BufferAttribute(d,3)),b.setIndex(new P.BufferAttribute(u,1)),i){let R=s.vertexStart*2,M=i.slice(R,R+s.vertexCount*2);b.setAttribute("uv",new P.BufferAttribute(M,2))}if(o){let R=o.slice(l,l+c);b.setAttribute("color",new P.BufferAttribute(R,3,!0))}b.computeVertexNormals();let T=new P.Mesh(b,r[e.materialId]);T.name=s.name,T.userData={source:"compute",name:s.name,layer:_nullishCoalesce(s.layer, () => ("")),originalIndex:s.originalIndex,metadata:_nullishCoalesce(s.metadata, () => ({}))},T.castShadow=!0,T.receiveShadow=!0,a.push(T)}return a}function hr(e){return Math.floor(e.length*3/4)}var ut={Angstroms:1e-10,Nanometers:1e-9,Microns:1e-6,Millimeters:.001,Centimeters:.01,Decimeters:.1,Meters:1,Dekameters:10,Hectometers:100,Kilometers:1e3,Megameters:1e6,Gigameters:1e9,Microinches:254e-10,Mils:254e-7,Inches:.0254,Feet:.3048,Yards:.9144,Miles:1609.344,NauticalMiles:1852},gr="Display",yr="DisplayBatch";function br(e){let n=e.split(".");return n.includes(gr)||n.includes(yr)}var dt=new Set;async function No(e,n){let t=performance.now(),r=[],{allowScaling:i=!0,allowAutoPosition:o=!0,rhino:a,debug:s=!1,parsing:l={}}=_nullishCoalesce(n, () => ({}));try{let c=i?Tr(e.modelunits):1;return await Rr(e,r,c,l,a,s),o&&Hr(r),r}catch(c){throw Mr(c,r),c}finally{s&&Ar(t)}}function Tr(e){let n=ut[e];return n!==void 0?n:(dt.has(e)||(dt.add(e),_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Unknown Rhino model unit "${e}" \u2014 geometry will not be scaled (factor 1). Known units: ${Object.keys(ut).join(", ")}.`)),1)}async function Rr(e,n,t,r,i,o){for(let a of e.values){let s=a.InnerTree;for(let l in s){let c=s[l];c&&await vr(c,n,t,r,i,o)}}}async function vr(e,n,t,r,i,o){for(let a of e){if(!br(a.type))continue;let s={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...r},l=wr(a.data);if(!l){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("Error parsing display batch envelope: invalid JSON");continue}let c=await He(l,s),d=Qe(l.items,{rhino:i,applyTransforms:s.applyTransforms}),m=[...c,...d];if(t!==1)for(let u of m)u.scale.set(t,t,t);n.push(...m),o&&_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(`Extracted ${c.length} meshes and ${d.length} items from batch`)}}function wr(e){return typeof e=="string"?xr(e):e}function xr(e){try{return JSON.parse(e)}catch (e3){return}}function Hr(e){if(e.length===0)return;let n=ye(e);ke(e,n.min.z,"z")}function Mr(e,n){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("An unexpected error occurred:",e),Cr(n)}function Cr(e){for(let n of e){let t=n;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(r=>r.dispose()):t.material.dispose())}}function Ar(e){let n=performance.now()-e;_chunkCUQQ3ZBVcjs.e.call(void 0, ).info("Time to process meshes:",`${n.toFixed(2)}ms`)}exports.a = Rt; exports.b = Dr; exports.c = Fe; exports.d = ke; exports.e = ye; exports.f = Ue; exports.g = ze; exports.h = _e; exports.i = ue; exports.j = Ge; exports.k = _t; exports.l = jr; exports.m = Ne; exports.n = $e; exports.o = rn; exports.p = qe; exports.q = on; exports.r = Ze; exports.s = ro; exports.t = fn; exports.u = yo; exports.v = Qe; exports.w = tt; exports.x = Wn; exports.y = nt; exports.z = rt; exports.A = we; exports.B = $n; exports.C = Yn; exports.D = Xn; exports.E = qn; exports.F = Lo; exports.G = Zn; exports.H = xe; exports.I = Fo; exports.J = He; exports.K = ko; exports.L = ut; exports.M = No;
62
- //# sourceMappingURL=chunk-AGU3SX3J.cjs.map
61
+ #endif`)}}function fr(e,n,t,r,i=null,o=null){let a=0,s=0;for(let h of e.meshes)a+=h.vertexCount,s+=h.indexCount;let l=new Float32Array(a*3),c=new Uint32Array(s),d=i?new Float32Array(a*2):null,m=o?new Uint8Array(a*3):null,u=0,f=0;for(let h of e.meshes){let x=h.vertexStart*3,L=h.vertexCount*3;if(l.set(n.subarray(x,x+L),u*3),d&&i){let y=h.vertexStart*2;d.set(i.subarray(y,y+h.vertexCount*2),u*2)}m&&o&&m.set(o.subarray(x,x+L),u*3);let p=t.subarray(h.indexStart,h.indexStart+h.indexCount),v=u-h.vertexStart;for(let y=0;y<p.length;y++){let H=p[y];ct(H,h),c[f+y]=H+v}u+=h.vertexCount,f+=h.indexCount}let b=new P.BufferGeometry;b.setAttribute("position",new P.BufferAttribute(l,3)),b.setIndex(new P.BufferAttribute(c,1)),d&&b.setAttribute("uv",new P.BufferAttribute(d,2)),m&&b.setAttribute("color",new P.BufferAttribute(m,3,!0)),b.computeVertexNormals();let T=new P.Mesh(b,r[e.materialId]),R=e.meshes[0],C=e.meshes.map(h=>h.name).filter(h=>h&&h.length>0);return T.name=C.length>0?C[0]:`merged_material_${e.materialId}`,T.castShadow=!0,T.receiveShadow=!0,T.userData={source:"compute",name:T.name,layer:_nullishCoalesce(_optionalChain([R, 'optionalAccess', _251 => _251.layer]), () => ("")),originalIndex:_nullishCoalesce(_optionalChain([R, 'optionalAccess', _252 => _252.originalIndex]), () => (0)),metadata:_nullishCoalesce(_optionalChain([R, 'optionalAccess', _253 => _253.metadata]), () => ({})),mergedFrom:e.meshes.slice(1).map(h=>({name:h.name,layer:h.layer,originalIndex:h.originalIndex}))},T}function Er(e,n,t,r,i=null,o=null){let a=[];for(let s of e.meshes){let l=s.vertexStart*3,c=s.vertexCount*3,d=n.slice(l,l+c),m=t.subarray(s.indexStart,s.indexStart+s.indexCount),u=new Uint32Array(m.length),f=s.vertexStart;for(let R=0;R<m.length;R++){let C=m[R];ct(C,s),u[R]=C-f}let b=new P.BufferGeometry;if(b.setAttribute("position",new P.BufferAttribute(d,3)),b.setIndex(new P.BufferAttribute(u,1)),i){let R=s.vertexStart*2,C=i.slice(R,R+s.vertexCount*2);b.setAttribute("uv",new P.BufferAttribute(C,2))}if(o){let R=o.slice(l,l+c);b.setAttribute("color",new P.BufferAttribute(R,3,!0))}b.computeVertexNormals();let T=new P.Mesh(b,r[e.materialId]);T.name=s.name,T.userData={source:"compute",name:s.name,layer:_nullishCoalesce(s.layer, () => ("")),originalIndex:s.originalIndex,metadata:_nullishCoalesce(s.metadata, () => ({}))},T.castShadow=!0,T.receiveShadow=!0,a.push(T)}return a}function hr(e){return Math.floor(e.length*3/4)}var ut={Angstroms:1e-10,Nanometers:1e-9,Microns:1e-6,Millimeters:.001,Centimeters:.01,Decimeters:.1,Meters:1,Dekameters:10,Hectometers:100,Kilometers:1e3,Megameters:1e6,Gigameters:1e9,Microinches:254e-10,Mils:254e-7,Inches:.0254,Feet:.3048,Yards:.9144,Miles:1609.344,NauticalMiles:1852},gr="Display",yr="DisplayBatch";function br(e){let n=e.split(".");return n.includes(gr)||n.includes(yr)}var dt=new Set;async function $o(e,n){let t=performance.now(),r=[],{allowScaling:i=!0,allowAutoPosition:o=!0,rhino:a,debug:s=!1,parsing:l={}}=_nullishCoalesce(n, () => ({}));try{let c=i?Tr(e.modelunits):1;return await Rr(e,r,c,l,a,s),o&&wr(r),r}catch(c){throw Cr(c,r),c}finally{s&&Ar(t)}}function Tr(e){let n=ut[e];return n!==void 0?n:(dt.has(e)||(dt.add(e),_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Unknown Rhino model unit "${e}" \u2014 geometry will not be scaled (factor 1). Known units: ${Object.keys(ut).join(", ")}.`)),1)}async function Rr(e,n,t,r,i,o){for(let a of e.values){let s=a.InnerTree;for(let l in s){let c=s[l];c&&await vr(c,n,t,r,i,o)}}}async function vr(e,n,t,r,i,o){for(let a of e){if(!br(a.type))continue;let s={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...r},l=xr(a.data);if(!l){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("Error parsing display batch envelope: invalid JSON");continue}let c=await we(l,s),d=Qe(l.items,{rhino:i,applyTransforms:s.applyTransforms}),m=[...c,...d];if(t!==1)for(let u of m)u.scale.set(t,t,t);n.push(...m),o&&_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(`Extracted ${c.length} meshes and ${d.length} items from batch`)}}function xr(e){return typeof e=="string"?Hr(e):e}function Hr(e){try{return JSON.parse(e)}catch (e3){return}}function wr(e){if(e.length===0)return;let n=ye(e);ke(e,n.min.z,"z")}function Cr(e,n){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("An unexpected error occurred:",e),Mr(n)}function Mr(e){for(let n of e){let t=n;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(r=>r.dispose()):t.material.dispose())}}function Ar(e){let n=performance.now()-e;_chunkCUQQ3ZBVcjs.e.call(void 0, ).info("Time to process meshes:",`${n.toFixed(2)}ms`)}exports.a = Rt; exports.b = Dr; exports.c = Fe; exports.d = ke; exports.e = ye; exports.f = Ue; exports.g = ze; exports.h = _e; exports.i = ue; exports.j = Ge; exports.k = _t; exports.l = jr; exports.m = Ne; exports.n = $e; exports.o = rn; exports.p = qe; exports.q = on; exports.r = Ze; exports.s = ro; exports.t = fn; exports.u = yo; exports.v = To; exports.w = Qe; exports.x = tt; exports.y = Wn; exports.z = nt; exports.A = rt; exports.B = xe; exports.C = $n; exports.D = Yn; exports.E = Xn; exports.F = qn; exports.G = Do; exports.H = Zn; exports.I = He; exports.J = Uo; exports.K = we; exports.L = zo; exports.M = ut; exports.N = $o;
62
+ //# sourceMappingURL=chunk-GFY3L653.cjs.map