@selvajs/visualization 1.0.0-beta.0 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +11 -10
  2. package/dist/gpu-dispose-Dkj-BKt4.js +2 -0
  3. package/dist/gpu-dispose-Dkj-BKt4.js.map +1 -0
  4. package/dist/gpu-dispose-DrN-ryj5.cjs +2 -0
  5. package/dist/gpu-dispose-DrN-ryj5.cjs.map +1 -0
  6. package/dist/index.cjs +0 -1
  7. package/dist/index.d.cts +1 -2
  8. package/dist/index.d.ts +1 -2
  9. package/dist/index.js +1 -1
  10. package/dist/parse.cjs +3 -3
  11. package/dist/parse.cjs.map +1 -1
  12. package/dist/parse.d.cts +135 -142
  13. package/dist/parse.d.ts +135 -142
  14. package/dist/parse.js +3 -3
  15. package/dist/parse.js.map +1 -1
  16. package/dist/render.cjs +8 -10
  17. package/dist/render.cjs.map +1 -1
  18. package/dist/render.d.cts +335 -333
  19. package/dist/render.d.ts +335 -333
  20. package/dist/render.js +8 -10
  21. package/dist/render.js.map +1 -1
  22. package/dist/rolldown-runtime-BocRIvOZ.cjs +1 -0
  23. package/dist/scene.cjs +1 -1
  24. package/dist/scene.cjs.map +1 -1
  25. package/dist/scene.d.cts +95 -95
  26. package/dist/scene.d.ts +95 -95
  27. package/dist/scene.js +1 -1
  28. package/dist/scene.js.map +1 -1
  29. package/dist/types-Di80Y609.d.cts +34 -0
  30. package/dist/types-Di80Y609.d.ts +34 -0
  31. package/package.json +14 -10
  32. package/dist/chunk-5XGN7UAV.js +0 -2
  33. package/dist/chunk-5XGN7UAV.js.map +0 -1
  34. package/dist/chunk-AQJPVUH3.cjs +0 -2
  35. package/dist/chunk-AQJPVUH3.cjs.map +0 -1
  36. package/dist/chunk-BYLIBOAU.cjs +0 -2
  37. package/dist/chunk-BYLIBOAU.cjs.map +0 -1
  38. package/dist/chunk-EXAI6IC5.js +0 -2
  39. package/dist/chunk-EXAI6IC5.js.map +0 -1
  40. package/dist/index.cjs.map +0 -1
  41. package/dist/index.js.map +0 -1
  42. package/dist/types-CdF9R3qA.d.cts +0 -41
  43. package/dist/types-CdF9R3qA.d.ts +0 -41
package/dist/render.js CHANGED
@@ -1,12 +1,12 @@
1
- import{a as Kt,b as Yt,c as me,d as Zt,e as $t,g as Qt,h as Le,i as Ee,j as Oe,m as Ge,p as Fe,q as Ue,s as Be,t as We,v as se}from"./chunk-EXAI6IC5.js";import{a as X}from"./chunk-5XGN7UAV.js";import*as Ut from"three";import*as ne from"three";import*as he from"three";import*as K from"three";function fe(e){let n=e.clone().normalize(),t=new K.Vector3(0,0,1),r=new K.Vector3(0,1,0),i=Math.abs(n.dot(t))>.9?r:t,o=new K.Vector3().crossVectors(i,n).normalize(),a=new K.Vector3().crossVectors(n,o).normalize();return{up:n,forward:a,right:o}}function ye(e,n){let{forward:t,right:r,up:i}=fe(e);return t.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(n)}function qe(e,n,t){let{forward:r,right:i,up:o}=fe(e);return i.clone().multiplyScalar(n).add(r.clone().multiplyScalar(n)).add(o.clone().multiplyScalar(t))}function Xe(e){let n=e.clone().normalize(),t=new K.Vector3(0,1,0);if(n.dot(t)>.9999)return new K.Euler;if(n.dot(t)<-.9999)return new K.Euler(Math.PI,0,0);let r=new K.Quaternion().setFromUnitVectors(t,n);return new K.Euler().setFromQuaternion(r)}function xe(e){let n=Math.abs(e.x),t=Math.abs(e.y),r=Math.abs(e.z);return n>=t&&n>=r?"x":t>=r?"y":"z"}var $={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function Jt(e,n,t,r,i){if(nr(e),n.length===0)return;n.forEach(f=>{e.add(f)});let o=Ge(n),a=o.getCenter(new he.Vector3),s=o.getSize(new he.Vector3),l=Math.max(s.x,s.y,s.z);if(l/Math.min(s.x||1,s.y||1,s.z||1)>$.SCALE_RATIO_THRESHOLD||l>$.HUGE_THRESHOLD?(t.near=l*$.NEAR_PLANE_FACTOR.TINY,t.far=l*$.FAR_PLANE_FACTOR.HUGE):l>$.LARGE_THRESHOLD?(t.near=l*$.NEAR_PLANE_FACTOR.SMALL,t.far=l*$.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,l*$.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,l*$.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),!i){let f=l*$.INITIAL_DISTANCE_MULTIPLIER;t.position.copy(a).add(ye(t.up,f)),r.target.copy(a),r.update()}}var er=new Set(["grid","floor","label-layer","measure"]);function tr(e){let n=e;for(;n;){if(typeof n.userData.id=="string"&&er.has(n.userData.id))return!0;n=n.parent}return!1}function Q(e){e.updateMatrixWorld(!0);let n=new he.Box3;return e.traverse(t=>{let r=t;t.visible&&!tr(t)&&r.geometry&&n.expandByObject(t)}),n}var rr=new Set(["floor","grid","label-layer"]);function nr(e){[...e.children].forEach(t=>{rr.has(t.userData.id)||t.userData.source!=="user"&&(se(t),t.removeFromParent())})}function or(e){let{up:n,forward:t,right:r}=fe(e),i=t.clone().negate(),o=r.clone();return{top:n.clone(),bottom:n.clone().negate(),front:i.clone(),back:i.clone().negate(),right:o.clone(),left:o.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(o.clone()).add(n.clone()).normalize()}}function Ke(e){let{scene:n,perspective:t,controls:r,onActiveCameraChange:i}=e,o=(e.up??t.up).clone().normalize(),a=or(o),s=new ne.OrthographicCamera(-1,1,1,-1,t.near,t.far);s.up.copy(o);let l="perspective",m=t.aspect,f=()=>l==="perspective"?t:s,E=null,g=()=>{E?.cancel(),E=null},u=()=>{let R=(l==="orthographic"?s:t).position.distanceTo(r.target)*Math.tan(t.fov*Math.PI/360),T=R*m;s.left=-T,s.right=T,s.top=R,s.bottom=-R,s.near=t.near,s.far=t.far,s.updateProjectionMatrix()},p=d=>{if(d!==l){if(g(),d==="orthographic")s.position.copy(t.position),s.up.copy(t.up),s.lookAt(r.target),s.zoom=1,u();else{let R=(s.top-s.bottom)/(2*s.zoom)/Math.tan(t.fov*Math.PI/360),T=s.position.clone().sub(r.target);T.lengthSq()<1e-12&&T.copy(o),T.normalize(),t.position.copy(r.target).add(T.multiplyScalar(R))}l=d,r.object=f(),r.update(),i(f())}},h=(d,c,R,T)=>{let x=t.fov*(Math.PI/180),M=c/(2*Math.tan(x/2))*1.5,P=ir(R,o),L=d.clone().add(P.clone().multiplyScalar(M)),Y=f();l==="orthographic"&&(s.zoom=1),g(),T?E=sr(Y,r,L,d,()=>{l==="orthographic"&&u()}):(Y.position.copy(L),r.target.copy(d),l==="orthographic"&&u(),r.update())},C=(d,c=!0)=>{let R=Q(n),T=R.isEmpty()?r.target.clone():R.getCenter(new ne.Vector3),x=R.isEmpty()?new ne.Vector3(1,1,1):R.getSize(new ne.Vector3),M=Math.max(x.x,x.y,x.z)||1;h(T,M,d,c)};return{getActiveCamera:f,getProjection:()=>l,setProjection:p,toggleProjection:()=>(p(l==="perspective"?"orthographic":"perspective"),l),setView:(d,c=!0)=>{C(a[d],c)},setViewDirection:C,frameBounds:(d,c=!0)=>{if(d.isEmpty())return;let R=d.getCenter(new ne.Vector3),T=d.getSize(new ne.Vector3),x=Math.max(T.x,T.y,T.z)||1,M=f().position.clone().sub(r.target);M.lengthSq()<1e-12&&M.copy(a.iso),h(R,x,M.normalize(),c)},setRotateEnabled:d=>{r.enableRotate=d},isRotateEnabled:()=>r.enableRotate,updateAspect:(d,c)=>{m=c===0?m:d/c,l==="orthographic"&&u()},dispose:g}}function ir(e,n){let{up:t,forward:r}=fe(n),i=e.clone().normalize();if(Math.abs(i.dot(t))<.9999)return e;let o=r.clone().negate(),a=.5*Math.PI/180;return i.multiplyScalar(Math.cos(a)).add(o.multiplyScalar(Math.sin(a))).normalize()}var ar=e=>1-Math.pow(1-e,3);function sr(e,n,t,r,i,o=250){let a=e.position.clone(),s=n.target.clone(),l=performance.now(),m=null,f=()=>{m=null;let E=ar(Math.min((performance.now()-l)/o,1));e.position.lerpVectors(a,t,E),n.target.lerpVectors(s,r,E),i(),n.update(),E<1&&(m=requestAnimationFrame(f))};return m=requestAnimationFrame(f),{cancel:()=>{m!==null&&(cancelAnimationFrame(m),m=null)}}}import*as mt from"three";import{LineSegments2 as Sr}from"three/addons/lines/LineSegments2.js";import{LineSegmentsGeometry as lr}from"three/addons/lines/LineSegmentsGeometry.js";var cr=.15,dr=4096;function ur(e){let n=Math.floor(e.length/6);if(n===0)return 1/0;let t=Math.max(1,Math.ceil(n/dr)),r=[];for(let i=0;i<n;i+=t){let o=i*6,a=Math.hypot(e[o+3]-e[o],e[o+4]-e[o+1],e[o+5]-e[o+2]);a>0&&r.push(a)}return r.length===0?1/0:(r.sort((i,o)=>i-o),r[Math.min(r.length-1,Math.floor(r.length*cr))])}function Ye(e){let n=new lr;return n.setPositions(e),{geometry:n,segmentCount:e.length/6,edgeSpacing:ur(e)}}import*as nt from"three";function He(e,n,t){let o=Math.cos(Math.PI/180*t),a=e.length/3;if(a>=67108864)throw new Error(`extractEdgeSegments: ${a} vertices exceeds 2^26 limit`);let s=new Float64Array(a),l=new Float64Array(a),m=new Float64Array(a);for(let c=0;c<a;c++)s[c]=Math.round(e[3*c]*1e4),l[c]=Math.round(e[3*c+1]*1e4),m[c]=Math.round(e[3*c+2]*1e4);let f=16;for(;f<a*2;)f<<=1;let E=f-1,g=new Int32Array(f).fill(-1),u=new Int32Array(a);for(let c=0;c<a;c++){let R=(Math.imul(s[c]|0,73856093)^Math.imul(l[c]|0,19349663)^Math.imul(m[c]|0,83492791))&E;for(;;){let T=g[R];if(T===-1){g[R]=c,u[c]=c;break}if(s[T]===s[c]&&l[T]===l[c]&&m[T]===m[c]){u[c]=T;break}R=R+1&E}}let p=new Float32Array(4096),h=0,C=(c,R)=>{if(h+6>p.length){let T=new Float32Array(p.length*2);T.set(p),p=T}p[h++]=e[3*c],p[h++]=e[3*c+1],p[h++]=e[3*c+2],p[h++]=e[3*R],p[h++]=e[3*R+1],p[h++]=e[3*R+2]},b=new Map,A=[],S=[],I=[],d=(n?n.length:a)/3;for(let c=0;c<d;c++){let R=n?n[3*c]:3*c,T=n?n[3*c+1]:3*c+1,x=n?n[3*c+2]:3*c+2,M=u[R],P=u[T],L=u[x];if(M===P||P===L||L===M)continue;let Y=e[3*x]-e[3*T],w=e[3*x+1]-e[3*T+1],k=e[3*x+2]-e[3*T+2],v=e[3*R]-e[3*T],y=e[3*R+1]-e[3*T+1],z=e[3*R+2]-e[3*T+2],j=w*z-k*y,V=k*v-Y*z,G=Y*y-w*v,be=j*j+V*V+G*G;if(be>0){let Z=1/Math.sqrt(be);j*=Z,V*=Z,G*=Z}else j=0,V=0,G=0;for(let Z=0;Z<3;Z++){let ee,re,U,q;Z===0?(ee=R,re=T,U=M,q=P):Z===1?(ee=T,re=x,U=P,q=L):(ee=x,re=R,U=L,q=M);let ve=q*67108864+U,ie=b.get(ve);if(ie!==void 0&&ie!==-1)j*I[3*ie]+V*I[3*ie+1]+G*I[3*ie+2]<=o&&C(ee,re),b.set(ve,-1);else{let ue=U*67108864+q;if(!b.has(ue)){let Pe=A.length;b.set(ue,Pe),A.push(ee),S.push(re),I.push(j,V,G)}}}}for(let c of b.values())c!==-1&&C(A[c],S[c]);return p.slice(0,h)}function Ze(){return[`const extract = ${He.toString()};`,"self.onmessage = (event) => {"," const { id, positions, index, thresholdAngle } = event.data;"," try {"," const segments = extract(positions, index, thresholdAngle);"," self.postMessage({ id, segments }, [segments.buffer]);"," } catch (error) {"," self.postMessage({ id, error: String((error && error.message) || error) });"," }","};"].join(`
2
- `)}import*as Ce from"three";var le="edge-overlay",we="triangle-cap",$e=2236962,mr=1.5,pr=44,Er=.75,fr=4e6,hr=2e6,Qe=25e3,Ie=128*1024*1024,Je=4,ke=1,et=0,tt=-1;function rt(e){return{forcedColor:e.color!=null?new Ce.Color(e.color):null,darken:Ce.MathUtils.clamp(e.darken??Er,0,1),width:e.width??mr,thresholdAngle:e.thresholdAngle??pr,distanceFade:e.distanceFade??!0,maxTriangles:e.maxTriangles??fr,maxSegments:e.maxSegments??hr}}function Me(e){let n=e.getAttribute("position");return n?(e.index?e.index.count:n.count)/3:0}function ot(e){let n=e.getAttribute("position");if(!n||n.isInterleavedBufferAttribute||n.itemSize!==3||!(n.array instanceof Float32Array)||n.count>=67108864)return null;let t=e.index;return t&&!(t.array instanceof Uint32Array)&&!(t.array instanceof Uint16Array)?null:{positions:n.array,index:t?t.array:null}}function it(e,n){let r=2166136261,i=l=>{r^=l,r=Math.imul(r,16777619)},o=new Uint32Array(e.positions.buffer,e.positions.byteOffset,e.positions.length),a=Math.min(4096,o.length);for(let l=0;l<a;l++)i(o[l]);for(let l=Math.max(a,o.length-4096);l<o.length;l++)i(o[l]);let s=0;if(e.index){s=e.index.length;let l=Math.min(4096,s);for(let m=0;m<l;m++)i(e.index[m]);for(let m=Math.max(l,s-4096);m<s;m++)i(e.index[m])}return`${n}:${e.positions.length}:${s}:${r>>>0}`}var J=new Map,ge=0;Ue(()=>{J.clear(),ge=0});function at(e){let n=J.get(e);return n&&(J.delete(e),J.set(e,n)),n}function st(e,n){if(n.byteLength>Ie)return;let t=J.get(e);for(t&&(ge-=t.byteLength,J.delete(e)),J.set(e,n),ge+=n.byteLength;ge>Ie;){let r=J.keys().next().value;ge-=J.get(r).byteLength,J.delete(r)}}function Rr(e,n){let t=new nt.EdgesGeometry(e,n),r=t.attributes.position?t.attributes.position.array:new Float32Array(0);return t.dispose(),r}function _e(e,n){let t=ot(e);if(!t)return Rr(e,n);let r=it(t,n),i=at(r);if(i)return i;let o=He(t.positions,t.index,n);return st(r,o),o}var ce,Re=new Map,Tr=1;function br(){if(ce!==void 0)return ce;if(typeof Worker>"u"||typeof Blob>"u"||typeof URL>"u"||typeof URL.createObjectURL!="function")return ce=null,null;try{let e=URL.createObjectURL(new Blob([Ze()],{type:"text/javascript"})),n=new Worker(e);n.onmessage=t=>{let{id:r,segments:i,error:o}=t.data,a=Re.get(r);a&&(Re.delete(r),i?a.resolve(i):a.reject(new Error(o??"edge extraction failed in worker")))},n.onerror=()=>{for(let t of Re.values())t.reject(new Error("edge extraction worker crashed"));Re.clear(),n.terminate(),ce=null},ce=n}catch{ce=null}return ce}function vr(e,n,t){return new Promise((r,i)=>{let o=Tr++;Re.set(o,{resolve:r,reject:i});let a=n.positions.slice(),s=n.index?n.index.slice():null,l=[a.buffer];s&&l.push(s.buffer),e.postMessage({id:o,positions:a,index:s,thresholdAngle:t},l)})}var ze=new Map;function lt(e,n){let t=ot(e);if(!t||Me(e)<Qe)return Promise.resolve(_e(e,n));let r=it(t,n),i=at(r);if(i)return Promise.resolve(i);let o=ze.get(r);if(o)return o;let a=br();if(!a)return Promise.resolve(_e(e,n));let s=vr(a,t,n).catch(()=>He(t.positions,t.index,n)).then(l=>(st(r,l),l)).finally(()=>{ze.delete(r)});return ze.set(r,s),s}import*as oe from"three";import{LineMaterial as yr}from"three/addons/lines/LineMaterial.js";import{LineSegments2 as dt}from"three/addons/lines/LineSegments2.js";function xr(e,n){let r=(Array.isArray(e.material)?e.material[0]:e.material)?.color;return r?r.clone().multiplyScalar(1-n):new oe.Color($e)}var Se=class{constructor(n){X(this,"options",n);X(this,"byKey",new Map)}for(n,t){let r=this.options.forcedColor??xr(n,this.options.darken),i=r.getHex()*2+(t?1:0),o=this.byKey.get(i);return o||(o=Hr(r,this.options.width,t),this.byKey.set(i,o)),o}disposeUnused(n){let t=new Set(n.map(r=>r.material));for(let r of this.byKey.values())t.has(r)||r.dispose()}};function Hr(e,n,t){let r=new yr({color:e});return r.linewidth=n,r.polygonOffset=!0,r.polygonOffsetFactor=et,r.polygonOffsetUnits=tt,t&&(r.transparent=!0),r}function ut(e,n,t){let r=new dt(e.geometry,n);return r.userData.kind=le,r.raycast=()=>{},t&&Mr(r,e.edgeSpacing),r}var ct=new oe.Vector3,Cr=new oe.Vector3;function wr(e,n,t){e.geometry.boundingSphere||e.geometry.computeBoundingSphere();let r=e.geometry.boundingSphere;if(!r)return 1/0;if(n.isPerspectiveCamera){let i=n;ct.copy(r.center).applyMatrix4(e.matrixWorld);let o=Cr.setFromMatrixPosition(n.matrixWorld).distanceTo(ct),a=r.radius*e.matrixWorld.getMaxScaleOnAxis();if(o<=a)return 1/0;let s=Math.tan(oe.MathUtils.degToRad(i.fov)*.5),l=2*o*s;return l>0?t/l:1/0}if(n.isOrthographicCamera){let i=n,o=(i.top-i.bottom)/i.zoom;return o>0?t/o:1/0}return 1/0}function Mr(e,n){e.onBeforeRender=(t,r,i)=>{dt.prototype.onBeforeRender.call(e,t);let o=e.material,a=wr(e,i,o.resolution.y),s=n*a;o.opacity=oe.MathUtils.clamp((s-ke)/(Je-ke),0,1)}}function Dr(e){return e.userData?.kind===le}function Ar(e,n){let t=[];return e.traverse(r=>{if(r instanceof mt.Mesh&&!(r.userData.id==="floor"||r.userData.id==="grid")&&r.userData.kind!==le&&!r.children.some(i=>i.userData?.kind===le)&&r.geometry){if(Me(r.geometry)>n){r.userData.edgesSkipped=we,console.debug(`[edges] skipping mesh over triangle cap (${Me(r.geometry)} > ${n})`);return}delete r.userData.edgesSkipped,t.push(r)}}),t}function Pr(e,n,t,r){let i=r.distanceFade&&n.segmentCount<=r.maxSegments,o=ut(n,t.for(e,i),i);return e.add(o),o}var pt=new WeakMap;function Ve(e){return pt.get(e)??0}function Lr(e,n){for(let t=e;t;t=t.parent)if(t===n)return!0;return!1}async function Et(e,n={}){let t=rt(n),r=new Se(t),i=Ve(e),o=[],a=Ar(e,t.maxTriangles).map(async s=>{let l=await lt(s.geometry,t.thresholdAngle);Ve(e)===i&&Lr(s,e)&&(s.children.some(m=>m.userData?.kind===le)||o.push(Pr(s,Ye(l),r,t)))});return await Promise.all(a),r.disposeUnused(o),o}function ft(e){pt.set(e,Ve(e)+1);let n=[];e.traverse(r=>{r instanceof Sr&&Dr(r)&&n.push(r)});let t=new Set;for(let r of n)r.geometry.dispose(),t.add(r.material),r.removeFromParent();return t.forEach(r=>r.dispose()),n.length}import*as _ from"three";function Or(e){if(!(e>0)||!Number.isFinite(e))return 1;let n=Math.floor(Math.log10(e)),t=Math.pow(10,n),r=e/t;return(r>=5?5:r>=2?2:1)*t}var Fr=`
1
+ import{a as e,c as t,d as n,l as r,r as i,s as a,t as o,u as s}from"./gpu-dispose-Dkj-BKt4.js";import*as c from"three";import{Line2 as l}from"three/addons/lines/Line2.js";import{LineGeometry as u}from"three/addons/lines/LineGeometry.js";import{LineMaterial as d}from"three/addons/lines/LineMaterial.js";import{LineSegments2 as f}from"three/addons/lines/LineSegments2.js";import{LineSegmentsGeometry as p}from"three/addons/lines/LineSegmentsGeometry.js";import{CSS2DObject as m,CSS2DRenderer as h}from"three/addons/renderers/CSS2DRenderer.js";import{ViewHelper as g}from"three/addons/helpers/ViewHelper.js";import{EffectComposer as _}from"three/addons/postprocessing/EffectComposer.js";import{RenderPass as v}from"three/addons/postprocessing/RenderPass.js";import{GTAOPass as y}from"three/addons/postprocessing/GTAOPass.js";import{SMAAPass as b}from"three/addons/postprocessing/SMAAPass.js";import{OutputPass as x}from"three/addons/postprocessing/OutputPass.js";import{FullScreenQuad as S,Pass as C}from"three/addons/postprocessing/Pass.js";import{OrbitControls as w}from"three/addons/controls/OrbitControls.js";import{HDRLoader as T}from"three/addons/loaders/HDRLoader.js";const E=[`technical`,`studio`,`showcase`],D=`technical`,O={studio:{toneMapping:c.ACESFilmicToneMapping,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.75,ambientIntensity:.4,cullBackfaces:!1,ambientOcclusion:!1},technical:{toneMapping:c.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:.9,environmentIntensity:1,hemisphereIntensity:.35,ambientIntensity:.25,cullBackfaces:!1,ambientOcclusion:!1},showcase:{toneMapping:c.ACESFilmicToneMapping,toneMappingExposure:1.15,envMapIntensity:1.4,environmentIntensity:1.25,hemisphereIntensity:.35,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!1}};function k(e){let t=O[e];return{envMapIntensity:t.envMapIntensity,cullBackfaces:t.cullBackfaces}}function A(e){let t=e.clone().normalize(),n=new c.Vector3(0,0,1),r=new c.Vector3(0,1,0),i=Math.abs(t.dot(n))>.9?r:n,a=new c.Vector3().crossVectors(i,t).normalize();return{up:t,forward:new c.Vector3().crossVectors(t,a).normalize(),right:a}}function j(e,t){let{forward:n,right:r,up:i}=A(e);return n.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(t)}function M(e,t,n){let{forward:r,right:i,up:a}=A(e);return i.clone().multiplyScalar(t).add(r.clone().multiplyScalar(t)).add(a.clone().multiplyScalar(n))}function ee(e){let t=e.clone().normalize(),n=new c.Vector3(0,1,0);if(t.dot(n)>.9999)return new c.Euler;if(t.dot(n)<-.9999)return new c.Euler(Math.PI,0,0);let r=new c.Quaternion().setFromUnitVectors(n,t);return new c.Euler().setFromQuaternion(r)}function te(e){let t=Math.abs(e.x),n=Math.abs(e.y),r=Math.abs(e.z);return t>=n&&t>=r?`x`:n>=r?`y`:`z`}const N={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 P(t,n,r,i,a){if(z(t),n.length===0)return;n.forEach(e=>{t.add(e)});let o=e(n),s=o.getCenter(new c.Vector3),l=o.getSize(new c.Vector3),u=Math.max(l.x,l.y,l.z);if(u/Math.min(l.x||1,l.y||1,l.z||1)>N.SCALE_RATIO_THRESHOLD||u>N.HUGE_THRESHOLD?(r.near=u*N.NEAR_PLANE_FACTOR.TINY,r.far=u*N.FAR_PLANE_FACTOR.HUGE):u>N.LARGE_THRESHOLD?(r.near=u*N.NEAR_PLANE_FACTOR.SMALL,r.far=u*N.FAR_PLANE_FACTOR.LARGE):(r.near=Math.max(.01,u*N.NEAR_PLANE_FACTOR.NORMAL),r.far=Math.max(2e3,u*N.FAR_PLANE_FACTOR.NORMAL)),r.updateProjectionMatrix(),!a){let e=u*N.INITIAL_DISTANCE_MULTIPLIER;r.position.copy(s).add(j(r.up,e)),i.target.copy(s),i.update()}}const F=new Set([`grid`,`floor`,`label-layer`,`measure`]);function I(e){let t=e;for(;t;){if(typeof t.userData.id==`string`&&F.has(t.userData.id))return!0;t=t.parent}return!1}function L(e){e.updateMatrixWorld(!0);let t=new c.Box3;return e.traverse(e=>{let n=e;e.visible&&!I(e)&&n.geometry&&t.expandByObject(e)}),t}const R=new Set([`floor`,`grid`,`label-layer`]);function z(e){[...e.children].forEach(e=>{R.has(e.userData.id)||e.userData.source!==`user`&&(o(e),e.removeFromParent())})}function B(e){let{up:t,forward:n,right:r}=A(e),i=n.clone().negate(),a=r.clone();return{top:t.clone(),bottom:t.clone().negate(),front:i.clone(),back:i.clone().negate(),right:a.clone(),left:a.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(a.clone()).add(t.clone()).normalize()}}function ne(e){let{scene:t,perspective:n,controls:r,onActiveCameraChange:i}=e,a=(e.up??n.up).clone().normalize(),o=B(a),s=new c.OrthographicCamera(-1,1,1,-1,n.near,n.far);s.up.copy(a);let l=`perspective`,u=n.aspect,d=()=>l===`perspective`?n:s,f=null,p=()=>{f?.cancel(),f=null},m=()=>{let e=(l===`orthographic`?s:n).position.distanceTo(r.target)*Math.tan(n.fov*Math.PI/360),t=e*u;s.left=-t,s.right=t,s.top=e,s.bottom=-e,s.near=n.near,s.far=n.far,s.updateProjectionMatrix()},h=e=>{if(e!==l){if(p(),e===`orthographic`)s.position.copy(n.position),s.up.copy(n.up),s.lookAt(r.target),s.zoom=1,m();else{let e=(s.top-s.bottom)/(2*s.zoom)/Math.tan(n.fov*Math.PI/360),t=s.position.clone().sub(r.target);t.lengthSq()<1e-12&&t.copy(a),t.normalize(),n.position.copy(r.target).add(t.multiplyScalar(e))}l=e,r.object=d(),r.update(),i(d())}},g=(e,t,i,o)=>{let c=n.fov*(Math.PI/180),u=t/(2*Math.tan(c/2))*1.5,h=V(i,a),g=e.clone().add(h.clone().multiplyScalar(u)),_=d();l===`orthographic`&&(s.zoom=1),p(),o?f=U(_,r,g,e,()=>{l===`orthographic`&&m()}):(_.position.copy(g),r.target.copy(e),l===`orthographic`&&m(),r.update())},_=(e,n=!0)=>{let i=L(t),a=i.isEmpty()?r.target.clone():i.getCenter(new c.Vector3),o=i.isEmpty()?new c.Vector3(1,1,1):i.getSize(new c.Vector3),s=Math.max(o.x,o.y,o.z)||1;g(a,s,e,n)};return{getActiveCamera:d,getProjection:()=>l,setProjection:h,toggleProjection:()=>(h(l===`perspective`?`orthographic`:`perspective`),l),setView:(e,t=!0)=>{_(o[e],t)},setViewDirection:_,frameBounds:(e,t=!0)=>{if(e.isEmpty())return;let n=e.getCenter(new c.Vector3),i=e.getSize(new c.Vector3),a=Math.max(i.x,i.y,i.z)||1,s=d().position.clone().sub(r.target);s.lengthSq()<1e-12&&s.copy(o.iso),g(n,a,s.normalize(),t)},setRotateEnabled:e=>{r.enableRotate=e},isRotateEnabled:()=>r.enableRotate,updateAspect:(e,t)=>{u=t===0?u:e/t,l===`orthographic`&&m()},dispose:p}}function V(e,t){let{up:n,forward:r}=A(t),i=e.clone().normalize();if(Math.abs(i.dot(n))<.9999)return e;let a=r.clone().negate(),o=.5*Math.PI/180;return i.multiplyScalar(Math.cos(o)).add(a.multiplyScalar(Math.sin(o))).normalize()}const H=e=>1-(1-e)**3;function U(e,t,n,r,i,a=250){let o=e.position.clone(),s=t.target.clone(),c=performance.now(),l=null,u=()=>{l=null;let d=H(Math.min((performance.now()-c)/a,1));e.position.lerpVectors(o,n,d),t.target.lerpVectors(s,r,d),i(),t.update(),d<1&&(l=requestAnimationFrame(u))};return l=requestAnimationFrame(u),{cancel:()=>{l!==null&&(cancelAnimationFrame(l),l=null)}}}function W(e){let t=Math.floor(e.length/6);if(t===0)return 1/0;let n=Math.max(1,Math.ceil(t/4096)),r=[];for(let i=0;i<t;i+=n){let t=i*6,n=Math.hypot(e[t+3]-e[t],e[t+4]-e[t+1],e[t+5]-e[t+2]);n>0&&r.push(n)}return r.length===0?1/0:(r.sort((e,t)=>e-t),r[Math.min(r.length-1,Math.floor(r.length*.15))])}function G(e){let t=new p;return t.setPositions(e),{geometry:t,segmentCount:e.length/6,edgeSpacing:W(e)}}function K(e,t,n){let r=1e4,i=67108864,a=Math.cos(Math.PI/180*n),o=e.length/3;if(o>=i)throw Error(`extractEdgeSegments: ${o} vertices exceeds 2^26 limit`);let s=new Float64Array(o),c=new Float64Array(o),l=new Float64Array(o);for(let t=0;t<o;t++)s[t]=Math.round(e[3*t]*r),c[t]=Math.round(e[3*t+1]*r),l[t]=Math.round(e[3*t+2]*r);let u=16;for(;u<o*2;)u<<=1;let d=u-1,f=new Int32Array(u).fill(-1),p=new Int32Array(o);for(let e=0;e<o;e++){let t=(Math.imul(s[e]|0,73856093)^Math.imul(c[e]|0,19349663)^Math.imul(l[e]|0,83492791))&d;for(;;){let n=f[t];if(n===-1){f[t]=e,p[e]=e;break}if(s[n]===s[e]&&c[n]===c[e]&&l[n]===l[e]){p[e]=n;break}t=t+1&d}}let m=new Float32Array(4096),h=0,g=(t,n)=>{if(h+6>m.length){let e=new Float32Array(m.length*2);e.set(m),m=e}m[h++]=e[3*t],m[h++]=e[3*t+1],m[h++]=e[3*t+2],m[h++]=e[3*n],m[h++]=e[3*n+1],m[h++]=e[3*n+2]},_=new Map,v=[],y=[],b=[],x=(t?t.length:o)/3;for(let n=0;n<x;n++){let r=t?t[3*n]:3*n,o=t?t[3*n+1]:3*n+1,s=t?t[3*n+2]:3*n+2,c=p[r],l=p[o],u=p[s];if(c===l||l===u||u===c)continue;let d=e[3*s]-e[3*o],f=e[3*s+1]-e[3*o+1],m=e[3*s+2]-e[3*o+2],h=e[3*r]-e[3*o],x=e[3*r+1]-e[3*o+1],S=e[3*r+2]-e[3*o+2],C=f*S-m*x,w=m*h-d*S,T=d*x-f*h,E=C*C+w*w+T*T;if(E>0){let e=1/Math.sqrt(E);C*=e,w*=e,T*=e}else C=0,w=0,T=0;for(let e=0;e<3;e++){let t,n,d,f;e===0?(t=r,n=o,d=c,f=l):e===1?(t=o,n=s,d=l,f=u):(t=s,n=r,d=u,f=c);let p=f*i+d,m=_.get(p);if(m!==void 0&&m!==-1)C*b[3*m]+w*b[3*m+1]+T*b[3*m+2]<=a&&g(t,n),_.set(p,-1);else{let e=d*i+f;if(!_.has(e)){let r=v.length;_.set(e,r),v.push(t),y.push(n),b.push(C,w,T)}}}}for(let e of _.values())e!==-1&&g(v[e],y[e]);return m.slice(0,h)}function re(){return[`const extract = ${K.toString()};`,`self.onmessage = (event) => {`,` const { id, positions, index, thresholdAngle } = event.data;`,` try {`,` const segments = extract(positions, index, thresholdAngle);`,` self.postMessage({ id, segments }, [segments.buffer]);`,` } catch (error) {`,` self.postMessage({ id, error: String((error && error.message) || error) });`,` }`,`};`].join(`
2
+ `)}const ie=`edge-overlay`;function ae(e){return{forcedColor:e.color==null?null:new c.Color(e.color),darken:c.MathUtils.clamp(e.darken??.75,0,1),width:e.width??1.5,thresholdAngle:e.thresholdAngle??44,distanceFade:e.distanceFade??!0,maxTriangles:e.maxTriangles??4e6,maxSegments:e.maxSegments??2e6}}function q(e){let t=e.getAttribute(`position`);return t?(e.index?e.index.count:t.count)/3:0}function oe(e){let t=e.getAttribute(`position`);if(!t||t.isInterleavedBufferAttribute||t.itemSize!==3||!(t.array instanceof Float32Array)||t.count>=67108864)return null;let n=e.index;return n&&!(n.array instanceof Uint32Array)&&!(n.array instanceof Uint16Array)?null:{positions:t.array,index:n?n.array:null}}function se(e,t){let n=4096,r=2166136261,i=e=>{r^=e,r=Math.imul(r,16777619)},a=new Uint32Array(e.positions.buffer,e.positions.byteOffset,e.positions.length),o=Math.min(n,a.length);for(let e=0;e<o;e++)i(a[e]);for(let e=Math.max(o,a.length-n);e<a.length;e++)i(a[e]);let s=0;if(e.index){s=e.index.length;let t=Math.min(n,s);for(let n=0;n<t;n++)i(e.index[n]);for(let r=Math.max(t,s-n);r<s;r++)i(e.index[r])}return`${t}:${e.positions.length}:${s}:${r>>>0}`}function ce(e,t){let n=new c.EdgesGeometry(e,t),r=n.attributes.position?n.attributes.position.array:new Float32Array;return n.dispose(),r}function le(e,t){let n=oe(e);return n?K(n.positions,n.index,t):ce(e,t)}let J;const Y=new Map;let ue=1;function de(){if(J!==void 0)return J;if(typeof Worker>`u`||typeof Blob>`u`||typeof URL>`u`||typeof URL.createObjectURL!=`function`)return J=null,null;try{let e=URL.createObjectURL(new Blob([re()],{type:`text/javascript`})),t=new Worker(e);t.onmessage=e=>{let{id:t,segments:n,error:r}=e.data,i=Y.get(t);i&&(Y.delete(t),n?i.resolve(n):i.reject(Error(r??`edge extraction failed in worker`)))},t.onerror=()=>{for(let e of Y.values())e.reject(Error(`edge extraction worker crashed`));Y.clear(),t.terminate(),J=null},J=t}catch{J=null}return J}function fe(e,t,n){return new Promise((r,i)=>{let a=ue++;Y.set(a,{resolve:r,reject:i});let o=t.positions.slice(),s=t.index?t.index.slice():null,c=[o.buffer];s&&c.push(s.buffer),e.postMessage({id:a,positions:o,index:s,thresholdAngle:n},c)})}const X=new Map;function pe(e,t){let n=oe(e);if(!n||q(e)<25e3)return Promise.resolve(le(e,t));let r=se(n,t),i=X.get(r);if(i)return i;let a=de();if(!a)return Promise.resolve(le(e,t));let o=fe(a,n,t).catch(()=>K(n.positions,n.index,t)).finally(()=>{X.delete(r)});return X.set(r,o),o}function me(e,t){let n=(Array.isArray(e.material)?e.material[0]:e.material)?.color;return n?n.clone().multiplyScalar(1-t):new c.Color(2236962)}var he=class{options;byKey=new Map;constructor(e){this.options=e}for(e,t){let n=this.options.forcedColor??me(e,this.options.darken),r=n.getHex()*2+ +!!t,i=this.byKey.get(r);return i||(i=ge(n,this.options.width,t),this.byKey.set(r,i)),i}disposeUnused(e){let t=new Set(e.map(e=>e.material));for(let e of this.byKey.values())t.has(e)||e.dispose()}};function ge(e,t,n){let r=new d({color:e});return r.linewidth=t,r.polygonOffset=!0,r.polygonOffsetFactor=0,r.polygonOffsetUnits=-1,n&&(r.transparent=!0),r}function _e(e,t,n){let r=new f(e.geometry,t);return r.userData.kind=ie,r.raycast=()=>{},n&&xe(r,e.edgeSpacing),r}const ve=new c.Vector3,ye=new c.Vector3;function be(e,t,n){e.geometry.boundingSphere||e.geometry.computeBoundingSphere();let r=e.geometry.boundingSphere;if(!r)return 1/0;if(t.isPerspectiveCamera){let i=t;ve.copy(r.center).applyMatrix4(e.matrixWorld);let a=ye.setFromMatrixPosition(t.matrixWorld).distanceTo(ve);if(a<=r.radius*e.matrixWorld.getMaxScaleOnAxis())return 1/0;let o=Math.tan(c.MathUtils.degToRad(i.fov)*.5),s=2*a*o;return s>0?n/s:1/0}if(t.isOrthographicCamera){let e=t,r=(e.top-e.bottom)/e.zoom;return r>0?n/r:1/0}return 1/0}function xe(e,t){e.onBeforeRender=(n,r,i)=>{f.prototype.onBeforeRender.call(e,n);let a=e.material,o=t*be(e,i,a.resolution.y);a.opacity=c.MathUtils.clamp((o-1)/3,0,1)}}function Se(e){return e.userData?.kind===ie}function Ce(e,t){let n=[];return e.traverse(e=>{if(e instanceof c.Mesh&&e.userData.id!==`floor`&&e.userData.id!==`grid`&&e.userData.kind!==`edge-overlay`&&!e.children.some(e=>e.userData?.kind===`edge-overlay`)&&e.geometry){if(q(e.geometry)>t){e.userData.edgesSkipped=`triangle-cap`,console.debug(`[edges] skipping mesh over triangle cap (${q(e.geometry)} > ${t})`);return}delete e.userData.edgesSkipped,n.push(e)}}),n}function we(e,t,n,r){let i=r.distanceFade&&t.segmentCount<=r.maxSegments,a=_e(t,n.for(e,i),i);return e.add(a),a}const Te=new WeakMap;function Z(e){return Te.get(e)??0}function Ee(e,t){for(let n=e;n;n=n.parent)if(n===t)return!0;return!1}async function De(e,t={}){let n=ae(t),r=new he(n),i=Z(e),a=[],o=Ce(e,n.maxTriangles).map(async t=>{let o=await pe(t.geometry,n.thresholdAngle);Z(e)===i&&Ee(t,e)&&(t.children.some(e=>e.userData?.kind===`edge-overlay`)||a.push(we(t,G(o),r,n)))});return await Promise.all(o),r.disposeUnused(a),a}function Oe(e){Te.set(e,Z(e)+1);let t=[];e.traverse(e=>{e instanceof f&&Se(e)&&t.push(e)});let n=new Set;for(let e of t)e.geometry.dispose(),n.add(e.material),e.removeFromParent();return n.forEach(e=>e.dispose()),t.length}function ke(e){if(!(e>0)||!Number.isFinite(e))return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n>=5?5:n>=2?2:1)*t}function Ae(e={}){let{cellSize:t=1,majorEvery:n=10,cellColor:r=8947848,majorColor:i=4473924,fadeDistance:a=100,plane:o=`y`}=e,s=o===`y`?new c.Vector2(0,2):o===`z`?new c.Vector2(0,1):new c.Vector2(1,2),l=2.5,u=new c.PlaneGeometry(1,1);o===`y`?u.rotateX(-Math.PI/2):o===`x`&&u.rotateY(Math.PI/2);let d=new c.ShaderMaterial({vertexShader:`
3
3
  varying vec3 vWorldPos;
4
4
  void main() {
5
5
  vec4 world = modelMatrix * vec4(position, 1.0);
6
6
  vWorldPos = world.xyz;
7
7
  gl_Position = projectionMatrix * viewMatrix * world;
8
8
  }
9
- `,Ir=`
9
+ `,fragmentShader:`
10
10
  precision highp float;
11
11
  varying vec3 vWorldPos;
12
12
 
@@ -18,8 +18,7 @@ import{a as Kt,b as Yt,c as me,d as Zt,e as $t,g as Qt,h as Le,i as Ee,j as Oe,m
18
18
  uniform vec3 uCenter; // fade center (camera position projected onto the plane)
19
19
  uniform float uFade;
20
20
 
21
- // Antialiased grid line intensity for a given spacing, using screen-space derivatives so lines
22
- // stay ~1px regardless of zoom (the standard "pristine grid" technique).
21
+ // Screen-space derivatives keep grid lines ~1px regardless of zoom ("pristine grid" technique).
23
22
  float gridLine(vec2 coord, float spacing) {
24
23
  vec2 c = coord / spacing;
25
24
  vec2 d = fwidth(c);
@@ -51,8 +50,7 @@ import{a as Kt,b as Yt,c as me,d as Zt,e as $t,g as Qt,h as Le,i as Ee,j as Oe,m
51
50
  if (alpha < 0.001) discard;
52
51
  gl_FragColor = vec4(color, alpha);
53
52
  }
54
- `;function ht(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 _.Vector2(0,2):a==="z"?new _.Vector2(0,1):new _.Vector2(1,2),l=2.5,m=new _.PlaneGeometry(1,1);a==="y"?m.rotateX(-Math.PI/2):a==="x"&&m.rotateY(Math.PI/2);let f=new _.ShaderMaterial({vertexShader:Fr,fragmentShader:Ir,transparent:!0,depthWrite:!1,side:_.DoubleSide,uniforms:{uAxes:{value:s},uCell:{value:n},uMajor:{value:t},uCellColor:{value:new _.Color(r)},uMajorColor:{value:new _.Color(i)},uCenter:{value:new _.Vector3},uFade:{value:o}}}),E=new _.Mesh(m,f);E.name="grid",E.userData.id="grid",E.renderOrder=-1;let g=o,u=o*l,p=new _.Vector3;return{object:E,update:h=>{a==="y"?(E.position.set(h.x,0,h.z),p.set(h.x,0,h.z)):a==="z"?(E.position.set(h.x,h.y,0),p.set(h.x,h.y,0)):(E.position.set(0,h.y,h.z),p.set(0,h.y,h.z)),f.uniforms.uCenter.value.copy(p),E.scale.setScalar(u)},fitToContent:h=>{if(h.isEmpty())return;let C=h.getSize(new _.Vector3),b=(I,d)=>d===0?I.x:d===1?I.y:I.z,A=Math.max(b(C,s.x),b(C,s.y));if(!(A>0)||!Number.isFinite(A))return;let S=20;f.uniforms.uCell.value=Or(A/S),g=A*2,f.uniforms.uFade.value=g,u=g*l},setVisible:h=>{E.visible=h},dispose:()=>{E.removeFromParent(),m.dispose(),f.dispose()}}}import*as gt from"three";import{CSS2DRenderer as kr,CSS2DObject as zr}from"three/addons/renderers/CSS2DRenderer.js";function Rt(e,n){let t=new kr,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 gt.Group;o.name="label-layer",o.userData.id="label-layer",n.add(o);let a=new Set;return{addLabel:(l,m,f)=>{let E=document.createElement("div");E.textContent=l,f?E.className=f:Object.assign(E.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"}),E.style.pointerEvents="none";let g=new zr(E);return g.position.copy(m),o.add(g),a.add(g),{object:g,setPosition:u=>g.position.copy(u),setText:u=>{E.textContent=u},remove:()=>{g.removeFromParent(),E.remove(),a.delete(g)}}},render:(l,m)=>t.render(l,m),setSize:(l,m)=>t.setSize(l,m),dispose:()=>{a.forEach(l=>{l.removeFromParent(),l.element.remove()}),a.clear(),o.removeFromParent(),r.remove()}}}import*as D from"three";import{Line2 as _r}from"three/addons/lines/Line2.js";import{LineGeometry as Vr}from"three/addons/lines/LineGeometry.js";import{LineMaterial as jr}from"three/addons/lines/LineMaterial.js";var Nr=12,Gr=16763904,Tt=.015,bt={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 Ur(e){let n=e&&bt[e]||bt.Meters;return t=>`${(t/n.metersPerUnit).toPrecision(3)} ${n.suffix}`}function Br(e,n){if(e.isOrthographicCamera){let r=e;return Math.abs(r.top-r.bottom)/(r.zoom||1)*Tt}return((n?e.position.distanceTo(n):e.position.length())||1)*Tt}function Wr(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 qr(e,n,t,r){let i=e.point.clone(),o=e.object,a=Wr(e);if(!a||!o.geometry)return i;let s=o.geometry.attributes.position;if(!s)return i;let l=g=>{let u=g.clone().project(n);return new D.Vector2((u.x+1)/2*t.width,(1-u.y)/2*t.height)},m=l(i),f=i,E=r;for(let g of a){if(g>=s.count)continue;let p=new D.Vector3().fromBufferAttribute(s,g).applyMatrix4(o.matrixWorld),h=l(p).distanceTo(m);h<E&&(E=h,f=p)}return f}function vt(e){let{canvas:n,scene:t,getActiveCamera:r,getViewTarget:i,labelLayer:o,options:a={}}=e,s=a.snapPixels??Nr,l=new D.Color(a.color??Gr),m=Ur(a.displayUnit),f=(v,y)=>`${m(v)}
55
- \u0394x ${m(y.x)} \u0394y ${m(y.y)} \u0394z ${m(y.z)}`,E=a.format??f,g=new D.Raycaster,u=new D.Vector2,p=!1,h=[],C=[],b=null,A=null,S=new D.PointsMaterial({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),I=new D.PointsMaterial({color:l,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),d=null,c=v=>{if(!v){d&&(d.visible=!1);return}if(!d){let y=new D.BufferGeometry;y.setAttribute("position",new D.Float32BufferAttribute([0,0,0],3)),d=new D.Points(y,I),d.renderOrder=1e3,d.userData.id="measure",d.raycast=()=>{},t.add(d)}d.position.copy(v),d.visible=!0},R=v=>{let y=new D.BufferGeometry;y.setAttribute("position",new D.Float32BufferAttribute([v.x,v.y,v.z],3));let z=new D.Points(y,S);return z.renderOrder=999,z.userData.id="measure",z.raycast=()=>{},t.add(z),z},T=()=>{h.length=0,C.forEach(v=>{v.geometry.dispose(),v.removeFromParent()}),C.length=0,b&&(b.geometry.dispose(),b.material.dispose(),b.removeFromParent(),b=null),A?.remove(),A=null},x=()=>{if(h.length!==2)return;let[v,y]=h,z=new Vr;z.setPositions([v.x,v.y,v.z,y.x,y.y,y.z]);let j=new jr({color:l});j.linewidth=2,j.depthTest=!1,b=new _r(z,j),b.renderOrder=998,b.userData.id="measure",b.raycast=()=>{},t.add(b);let V=v.clone().add(y).multiplyScalar(.5),G=new D.Vector3(Math.abs(y.x-v.x),Math.abs(y.y-v.y),Math.abs(y.z-v.z));A=o.addLabel(E(v.distanceTo(y),G),V,a.labelClassName)},M=v=>{let y=n.getBoundingClientRect();u.x=(v.clientX-y.left)/y.width*2-1,u.y=-((v.clientY-y.top)/y.height)*2+1;let z=r();g.setFromCamera(u,z);let j=Br(z,i?.());g.params.Line.threshold=j,g.params.Points.threshold=j;let V=g.intersectObjects(t.children,!0).filter(G=>G.object.userData.id!=="measure"&&G.object.userData.id!=="grid");return V.length===0?null:qr(V[0],z,{width:y.width,height:y.height},s)},P=null,L=0,Y=()=>{L&&(cancelAnimationFrame(L),L=0),P=null};return{setEnabled:v=>{p=v,v||(Y(),T(),c(null))},isEnabled:()=>p,handleClick:v=>{if(!p)return!1;h.length===2&&T();let y=M(v);return y===null||(h.push(y),C.push(R(y)),h.length===2&&x()),!0},handleMove:v=>{p&&(P=v,!L&&(L=requestAnimationFrame(()=>{L=0;let y=P;P=null,!(!p||!y)&&c(M(y))})))},clear:T,dispose:()=>{Y(),T(),d&&(d.geometry.dispose(),d.removeFromParent(),d=null),S.dispose(),I.dispose()}}}import*as Te from"three";var Xr=.5,Kr=.01,Yr=.05,Zr=[];function yt({camera:e,scene:n,groundNormals:t=()=>Zr}){let r=e.near,i=e.near,o=new Te.Vector3,a=new Te.Vector3;return{update:()=>{e.near!==i&&(r=e.near);let l=Q(n),m=r;if(!l.isEmpty()){let f=l.getSize(a).length()*.5,E=e.position.distanceTo(l.getCenter(o))-f;for(let g of t())E=Math.min(E,Math.abs(e.position.dot(g)));m=Te.MathUtils.clamp(E*Xr,r,e.far*Kr)}Math.abs(m-i)>i*Yr&&(e.near=m,e.updateProjectionMatrix(),i=m)}}}import*as B from"three";import{ViewHelper as $r}from"three/addons/helpers/ViewHelper.js";function xt(e){let{camera:n,domElement:t,controller:r}=e,i=new $r(n,t);i.setLabels("X","Y","Z");let o=!0,a=128,s=new B.Raycaster,l=new B.OrthographicCamera(-2,2,2,-2,0,4);l.position.set(0,0,2),l.updateMatrixWorld();let m={posX:new B.Vector3(1,0,0),negX:new B.Vector3(-1,0,0),posY:new B.Vector3(0,1,0),negY:new B.Vector3(0,-1,0),posZ:new B.Vector3(0,0,1),negZ:new B.Vector3(0,0,-1)},f=g=>{let u=t.getBoundingClientRect(),p=u.left+t.offsetWidth-a-i.location.right,h=u.top+t.offsetHeight-a-i.location.bottom,C=new B.Vector2((g.clientX-p)/a*2-1,-((g.clientY-h)/a)*2+1);if(Math.abs(C.x)>1||Math.abs(C.y)>1)return null;i.quaternion.copy(n.quaternion).invert(),i.updateMatrixWorld(),s.setFromCamera(C,l);let b=s.intersectObjects(i.children,!1);for(let A of b){let S=A.object.userData?.type;if(typeof S=="string"&&S in m)return S}return null};return{render:g=>{if(!o)return;let u=g.autoClear;g.autoClear=!1,i.render(g),g.autoClear=u},handleClick:g=>{if(!o)return!1;let u=f(g);return u?(r.getProjection()==="orthographic"&&r.setProjection("perspective"),r.setViewDirection(m[u],!1),!0):!1},setVisible:g=>{o=g},isVisible:()=>o,dispose:()=>i.dispose()}}import*as je from"three";function Ht(e,n,t,r,i,o,a,s,l,m,f,E,g,u,p=!0){let h=null,C=performance.now(),b=!0,A=0,S=500,I=new je.Matrix4,d=new je.Matrix4,c=null,R=()=>{b=!0},T=w=>{w.updateMatrixWorld();let k=c!==w||!I.equals(w.matrixWorld)||!d.equals(w.projectionMatrix);return k&&(c=w,I.copy(w.matrixWorld),d.copy(w.projectionMatrix)),k},x=e.domElement,M=["pointerdown","pointerup","wheel"];if(p)for(let w of M)x.addEventListener(w,R,{passive:!0});let P=()=>{let{width:w,height:k}=a();if(w===0||k===0)return;let v=Math.floor(w*s),y=Math.floor(k*s);(e.domElement.width!==v||e.domElement.height!==y)&&(e.setPixelRatio(s),e.setSize(w,k,!1),t.aspect=w/k,t.updateProjectionMatrix(),i.updateAspect(w,k),E?.()?.setSize(w,k,s),g?.setSize(w,k),R())},L=function(){h=requestAnimationFrame(L);let w=performance.now(),k=(w-C)/1e3;C=w,P(),(o.enableDamping||o.autoRotate)&&o.update(),m&&m.update(r().position),u&&u.update(),l?.(k);let v=r();if(p){if(!(b||T(v)||w-A>=S))return;b=!1,A=w}let y=E?.();y?(y.setCamera(v),y.render(k)):e.render(n,v),g&&g.render(n,v),f&&f.render(e)};return{animate:L,dispose:()=>{if(h!==null&&(cancelAnimationFrame(h),h=null),p)for(let w of M)x.removeEventListener(w,R)},invalidate:R}}import*as wt from"three";import*as de from"three";var W=new de.Vector3(0,0,1);function Ct(e){let n=e.sceneScale||"m",r={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[n],i=e.look??Le,o=Ee[i];return{sceneScale:n,look:i,camera:{position:e.camera?.position||ye(e.environment?.sceneUp??W,r.cameraDistance*Math.sqrt(3)),fov:e.camera?.fov||20,near:e.camera?.near||r.near,far:e.camera?.far||r.far,target:e.camera?.target||new de.Vector3(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??1,sunlightPosition:e.lighting?.sunlightPosition||qe(e.environment?.sceneUp??W,r.lightDistance,r.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new de.Color(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??o.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??o.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??o.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath||"/baseHDR.hdr",backgroundColor:e.environment?.backgroundColor||new de.Color(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||W,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??o.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||r.floorSize,color:e.floor?.color||new de.Color(8421504),roughness:e.floor?.roughness??.7,metalness:e.floor?.metalness??0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||2048,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping??o.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??o.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,ambientOcclusion:e.render?.ambientOcclusion??o.ambientOcclusion,aoIntensity:e.render?.aoIntensity??1,aoPixelRatio:e.render?.aoPixelRatio??1,onDemand:e.render?.onDemand??!0},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||r.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??!1,cellSize:e.grid?.cellSize??1,majorEvery:e.grid?.majorEvery??10,cellColor:e.grid?.cellColor??8947848,majorColor:e.grid?.majorColor??4473924,fadeDistance:e.grid?.fadeDistance??100,plane:e.grid?.plane??xe(e.environment?.sceneUp??W)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color,darken:e.edges?.darken,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??44,distanceFade:e.edges?.distanceFade??!0,maxTriangles:e.edges?.maxTriangles,maxSegments:e.edges?.maxSegments,screenSpaceFallback:e.edges?.screenSpaceFallback},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,displayUnit:e.measure?.displayUnit,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||"#ff0000",enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame},onMaxAnisotropy:e.onMaxAnisotropy}}function Mt(e){let{scene:n,renderer:t,lights:r,config:i,pipeline:o,requestRender:a}=e,s=i.look,l=u=>{u.ambientIntensity!==void 0&&(r.ambient.intensity=u.ambientIntensity),u.hemisphereIntensity!==void 0&&!r.hemisphere&&u.hemisphereIntensity>0&&(r.hemisphere=new wt.HemisphereLight(u.hemisphereSkyColor??i.lighting.hemisphereSkyColor,u.hemisphereGroundColor??i.lighting.hemisphereGroundColor,u.hemisphereIntensity),r.hemisphere.position.copy(i.environment.sceneUp??W),n.add(r.hemisphere)),r.hemisphere&&(u.hemisphereIntensity!==void 0&&(r.hemisphere.intensity=u.hemisphereIntensity),u.hemisphereSkyColor!==void 0&&r.hemisphere.color.set(u.hemisphereSkyColor),u.hemisphereGroundColor!==void 0&&r.hemisphere.groundColor.set(u.hemisphereGroundColor)),a()},m=u=>{i.environment.environmentIntensity=u,n.environmentIntensity=u,a()};return{setFillLights:l,setEnvironmentIntensity:m,setToneMappingExposure:u=>{i.render.toneMappingExposure=u,t.toneMappingExposure=u,o.get()&&o.rebuild()},setAoIntensity:u=>{i.render.aoIntensity=u,o.get()&&o.rebuild()},setLook:u=>{let p=Ee[u];s=u,t.toneMapping=p.toneMapping,t.toneMappingExposure=p.toneMappingExposure,i.render.toneMapping=p.toneMapping,i.render.toneMappingExposure=p.toneMappingExposure,l({hemisphereIntensity:p.hemisphereIntensity,ambientIntensity:p.ambientIntensity}),m(p.environmentIntensity);let h=o.get()!==null;o.setAmbientOcclusion(p.ambientOcclusion),h&&o.rebuild(),n.traverse(C=>{if(C.userData.source!=="compute")return;let b=C,A=Array.isArray(b.material)?b.material:b.material?[b.material]:[];for(let S of A)"envMapIntensity"in S&&(S.envMapIntensity=p.envMapIntensity)}),a()},getMaterialAppearance:()=>Oe(s)}}import*as St from"three";function Dt(e,n){let t=n.parentElement,r=t?t.clientWidth:window.innerWidth,i=t?t.clientHeight:window.innerHeight,o=new St.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}import*as De from"three";function At(e){let n=new De.Scene,t=typeof e.environment.backgroundColor=="string"?new De.Color(e.environment.backgroundColor):e.environment.backgroundColor;return n.background=t||null,n}import*as Pt from"three";function Lt(e,n){se(e,n),Fe(e.environment??void 0)&&e.environment?.dispose(),e.background instanceof Pt.Texture&&Fe(e.background)&&e.background.dispose()}import*as Ft from"three";import{EffectComposer as en}from"three/addons/postprocessing/EffectComposer.js";import{RenderPass as tn}from"three/addons/postprocessing/RenderPass.js";import{GTAOPass as rn}from"three/addons/postprocessing/GTAOPass.js";import{SMAAPass as nn}from"three/addons/postprocessing/SMAAPass.js";import{OutputPass as on}from"three/addons/postprocessing/OutputPass.js";import*as O from"three";import{Pass as Qr,FullScreenQuad as Jr}from"three/addons/postprocessing/Pass.js";var Ne={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new O.Vector2(1,1)},uColor:{value:new O.Color(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
53
+ `,transparent:!0,depthWrite:!1,side:c.DoubleSide,uniforms:{uAxes:{value:s},uCell:{value:t},uMajor:{value:n},uCellColor:{value:new c.Color(r)},uMajorColor:{value:new c.Color(i)},uCenter:{value:new c.Vector3},uFade:{value:a}}}),f=new c.Mesh(u,d);f.name=`grid`,f.userData.id=`grid`,f.renderOrder=-1;let p=a,m=a*l,h=new c.Vector3;return{object:f,update:e=>{o===`y`?(f.position.set(e.x,0,e.z),h.set(e.x,0,e.z)):o===`z`?(f.position.set(e.x,e.y,0),h.set(e.x,e.y,0)):(f.position.set(0,e.y,e.z),h.set(0,e.y,e.z)),d.uniforms.uCenter.value.copy(h),f.scale.setScalar(m)},fitToContent:e=>{if(e.isEmpty())return;let t=e.getSize(new c.Vector3),n=(e,t)=>t===0?e.x:t===1?e.y:e.z,r=Math.max(n(t,s.x),n(t,s.y));!(r>0)||!Number.isFinite(r)||(d.uniforms.uCell.value=ke(r/20),p=r*2,d.uniforms.uFade.value=p,m=p*l)},setVisible:e=>{f.visible=e},dispose:()=>{f.removeFromParent(),u.dispose(),d.dispose()}}}function je(e,t){let n=new h,r=n.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};n.setSize(i.width,i.height);let a=new c.Group;a.name=`label-layer`,a.userData.id=`label-layer`,t.add(a);let o=new Set;return{addLabel:(e,t,n)=>{let r=document.createElement(`div`);r.textContent=e,n?r.className=n:Object.assign(r.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`}),r.style.pointerEvents=`none`;let i=new m(r);return i.position.copy(t),a.add(i),o.add(i),{object:i,setPosition:e=>i.position.copy(e),setText:e=>{r.textContent=e},remove:()=>{i.removeFromParent(),r.remove(),o.delete(i)}}},render:(e,t)=>n.render(e,t),setSize:(e,t)=>n.setSize(e,t),dispose:()=>{o.forEach(e=>{e.removeFromParent(),e.element.remove()}),o.clear(),a.removeFromParent(),r.remove()}}}const Me=.015,Ne={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 Pe(e){let t=e&&Ne[e]||Ne.Meters;return e=>`${(e/t.metersPerUnit).toPrecision(3)} ${t.suffix}`}function Fe(e,t){if(e.isOrthographicCamera){let t=e;return Math.abs(t.top-t.bottom)/(t.zoom||1)*Me}return((t?e.position.distanceTo(t):e.position.length())||1)*Me}function Ie(e){let t=e.object;if(t instanceof c.Mesh)return e.face?[e.face.a,e.face.b,e.face.c]:null;if(t instanceof c.Points)return e.index==null?null:[e.index];if(t instanceof c.Line){if(e.index==null)return null;let n=t.geometry.index;return n?e.index+1>=n.count?null:[n.getX(e.index),n.getX(e.index+1)]:[e.index,e.index+1]}return null}function Le(e,t,n,r){let i=e.point.clone(),a=e.object,o=Ie(e);if(!o||!a.geometry)return i;let s=a.geometry.attributes.position;if(!s)return i;let l=e=>{let r=e.clone().project(t);return new c.Vector2((r.x+1)/2*n.width,(1-r.y)/2*n.height)},u=l(i),d=i,f=r;for(let e of o){if(e>=s.count)continue;let t=new c.Vector3().fromBufferAttribute(s,e).applyMatrix4(a.matrixWorld),n=l(t).distanceTo(u);n<f&&(f=n,d=t)}return d}function Re(e){let{canvas:t,scene:n,getActiveCamera:r,getViewTarget:i,labelLayer:a,options:o={}}=e,s=o.snapPixels??12,f=new c.Color(o.color??16763904),p=Pe(o.displayUnit),m=o.format??((e,t)=>`${p(e)}\nΔx ${p(t.x)} Δy ${p(t.y)} Δz ${p(t.z)}`),h=new c.Raycaster,g=new c.Vector2,_=!1,v=[],y=[],b=null,x=null,S=new c.PointsMaterial({color:f,size:8,sizeAttenuation:!1,depthTest:!1}),C=new c.PointsMaterial({color:f,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),w=null,T=e=>{if(!e){w&&(w.visible=!1);return}if(!w){let e=new c.BufferGeometry;e.setAttribute(`position`,new c.Float32BufferAttribute([0,0,0],3)),w=new c.Points(e,C),w.renderOrder=1e3,w.userData.id=`measure`,w.raycast=()=>{},n.add(w)}w.position.copy(e),w.visible=!0},E=e=>{let t=new c.BufferGeometry;t.setAttribute(`position`,new c.Float32BufferAttribute([e.x,e.y,e.z],3));let r=new c.Points(t,S);return r.renderOrder=999,r.userData.id=`measure`,r.raycast=()=>{},n.add(r),r},D=()=>{v.length=0,y.forEach(e=>{e.geometry.dispose(),e.removeFromParent()}),y.length=0,b&&=(b.geometry.dispose(),b.material.dispose(),b.removeFromParent(),null),x?.remove(),x=null},O=()=>{if(v.length!==2)return;let[e,t]=v,r=new u;r.setPositions([e.x,e.y,e.z,t.x,t.y,t.z]);let i=new d({color:f});i.linewidth=2,i.depthTest=!1,b=new l(r,i),b.renderOrder=998,b.userData.id=`measure`,b.raycast=()=>{},n.add(b);let s=e.clone().add(t).multiplyScalar(.5),p=new c.Vector3(Math.abs(t.x-e.x),Math.abs(t.y-e.y),Math.abs(t.z-e.z));x=a.addLabel(m(e.distanceTo(t),p),s,o.labelClassName)},k=e=>{let a=t.getBoundingClientRect();g.x=(e.clientX-a.left)/a.width*2-1,g.y=-((e.clientY-a.top)/a.height)*2+1;let o=r();h.setFromCamera(g,o);let c=Fe(o,i?.());h.params.Line.threshold=c,h.params.Points.threshold=c;let l=h.intersectObjects(n.children,!0).filter(e=>e.object.userData.id!==`measure`&&e.object.userData.id!==`grid`);return l.length===0?null:Le(l[0],o,{width:a.width,height:a.height},s)},A=null,j=0,M=()=>{j&&=(cancelAnimationFrame(j),0),A=null};return{setEnabled:e=>{_=e,e||(M(),D(),T(null))},isEnabled:()=>_,handleClick:e=>{if(!_)return!1;v.length===2&&D();let t=k(e);return t===null||(v.push(t),y.push(E(t)),v.length===2&&O(),!0)},handleMove:e=>{_&&(A=e,!j&&(j=requestAnimationFrame(()=>{j=0;let e=A;A=null,!(!_||!e)&&T(k(e))})))},clear:D,dispose:()=>{M(),D(),w&&=(w.geometry.dispose(),w.removeFromParent(),null),S.dispose(),C.dispose()}}}const ze=[];function Be({camera:e,scene:t,groundNormals:n=()=>ze}){let r=e.near,i=e.near,a=new c.Vector3,o=new c.Vector3;return{update:()=>{e.near!==i&&(r=e.near);let s=L(t),l=r;if(!s.isEmpty()){let t=s.getSize(o).length()*.5,i=e.position.distanceTo(s.getCenter(a))-t;for(let t of n())i=Math.min(i,Math.abs(e.position.dot(t)));l=c.MathUtils.clamp(i*.5,r,e.far*.01)}Math.abs(l-i)>i*.05&&(e.near=l,e.updateProjectionMatrix(),i=l)}}}function Ve(e){let{camera:t,domElement:n,controller:r}=e,i=new g(t,n);i.setLabels(`X`,`Y`,`Z`);let a=!0,o=new c.Raycaster,s=new c.OrthographicCamera(-2,2,2,-2,0,4);s.position.set(0,0,2),s.updateMatrixWorld();let l={posX:new c.Vector3(1,0,0),negX:new c.Vector3(-1,0,0),posY:new c.Vector3(0,1,0),negY:new c.Vector3(0,-1,0),posZ:new c.Vector3(0,0,1),negZ:new c.Vector3(0,0,-1)},u=e=>{let r=n.getBoundingClientRect(),a=r.left+n.offsetWidth-128-i.location.right,u=r.top+n.offsetHeight-128-i.location.bottom,d=new c.Vector2((e.clientX-a)/128*2-1,-((e.clientY-u)/128)*2+1);if(Math.abs(d.x)>1||Math.abs(d.y)>1)return null;i.quaternion.copy(t.quaternion).invert(),i.updateMatrixWorld(),o.setFromCamera(d,s);let f=o.intersectObjects(i.children,!1);for(let e of f){let t=e.object.userData?.type;if(typeof t==`string`&&t in l)return t}return null};return{render:e=>{if(!a)return;let t=e.autoClear;e.autoClear=!1,i.render(e),e.autoClear=t},handleClick:e=>{if(!a)return!1;let t=u(e);return t?(r.getProjection()===`orthographic`&&r.setProjection(`perspective`),r.setViewDirection(l[t],!1),!0):!1},setVisible:e=>{a=e},isVisible:()=>a,dispose:()=>i.dispose()}}function He(e,t,n,r,i,a,o,s,l,u,d,f,p,m,h=!0){let g=null,_=performance.now(),v=!0,y=0,b=new c.Matrix4,x=new c.Matrix4,S=null,C=()=>{v=!0},w=e=>{e.updateMatrixWorld();let t=S!==e||!b.equals(e.matrixWorld)||!x.equals(e.projectionMatrix);return t&&(S=e,b.copy(e.matrixWorld),x.copy(e.projectionMatrix)),t},T=e.domElement,E=[`pointerdown`,`pointerup`,`wheel`];if(h)for(let e of E)T.addEventListener(e,C,{passive:!0});let D=()=>{let{width:t,height:r}=o();if(t===0||r===0)return;let a=Math.floor(t*s),c=Math.floor(r*s);(e.domElement.width!==a||e.domElement.height!==c)&&(e.setPixelRatio(s),e.setSize(t,r,!1),n.aspect=t/r,n.updateProjectionMatrix(),i.updateAspect(t,r),f?.()?.setSize(t,r,s),p?.setSize(t,r),C())},O=function(){g=requestAnimationFrame(O);let n=performance.now(),i=(n-_)/1e3;_=n,D(),(a.enableDamping||a.autoRotate)&&a.update(),u&&u.update(r().position),m&&m.update(),l?.(i);let o=r();if(h){if(!(v||w(o)||n-y>=500))return;v=!1,y=n}let s=f?.();s?(s.setCamera(o),s.render(i)):e.render(t,o),p&&p.render(t,o),d&&d.render(e)};return{animate:O,dispose:()=>{if(g!==null&&(cancelAnimationFrame(g),g=null),h)for(let e of E)T.removeEventListener(e,C)},invalidate:C}}const Q=new c.Vector3(0,0,1);function Ue(e){let t=e.sceneScale||`m`,n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[t],r=e.look??`technical`,i=O[r];return{sceneScale:t,look:r,camera:{position:e.camera?.position||j(e.environment?.sceneUp??Q,n.cameraDistance*Math.sqrt(3)),fov:e.camera?.fov||20,near:e.camera?.near||n.near,far:e.camera?.far||n.far,target:e.camera?.target||new c.Vector3(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??1,sunlightPosition:e.lighting?.sunlightPosition||M(e.environment?.sceneUp??Q,n.lightDistance,n.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new c.Color(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??i.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??i.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??i.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath||`/baseHDR.hdr`,backgroundColor:e.environment?.backgroundColor||new c.Color(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||Q,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??i.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||n.floorSize,color:e.floor?.color||new c.Color(8421504),roughness:e.floor?.roughness??.7,metalness:e.floor?.metalness??0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||2048,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping??i.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??i.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,ambientOcclusion:e.render?.ambientOcclusion??i.ambientOcclusion,aoIntensity:e.render?.aoIntensity??1,aoPixelRatio:e.render?.aoPixelRatio??1,onDemand:e.render?.onDemand??!0},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||n.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??!1,cellSize:e.grid?.cellSize??1,majorEvery:e.grid?.majorEvery??10,cellColor:e.grid?.cellColor??8947848,majorColor:e.grid?.majorColor??4473924,fadeDistance:e.grid?.fadeDistance??100,plane:e.grid?.plane??te(e.environment?.sceneUp??Q)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color,darken:e.edges?.darken,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??44,distanceFade:e.edges?.distanceFade??!0,maxTriangles:e.edges?.maxTriangles,maxSegments:e.edges?.maxSegments,screenSpaceFallback:e.edges?.screenSpaceFallback},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,displayUnit:e.measure?.displayUnit,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||`#ff0000`,enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame},onMaxAnisotropy:e.onMaxAnisotropy}}function We(e){let{scene:t,renderer:n,lights:r,config:i,pipeline:a,requestRender:o}=e,s=i.look,l=e=>{e.ambientIntensity!==void 0&&(r.ambient.intensity=e.ambientIntensity),e.hemisphereIntensity!==void 0&&!r.hemisphere&&e.hemisphereIntensity>0&&(r.hemisphere=new c.HemisphereLight(e.hemisphereSkyColor??i.lighting.hemisphereSkyColor,e.hemisphereGroundColor??i.lighting.hemisphereGroundColor,e.hemisphereIntensity),r.hemisphere.position.copy(i.environment.sceneUp??Q),t.add(r.hemisphere)),r.hemisphere&&(e.hemisphereIntensity!==void 0&&(r.hemisphere.intensity=e.hemisphereIntensity),e.hemisphereSkyColor!==void 0&&r.hemisphere.color.set(e.hemisphereSkyColor),e.hemisphereGroundColor!==void 0&&r.hemisphere.groundColor.set(e.hemisphereGroundColor)),o()},u=e=>{i.environment.environmentIntensity=e,t.environmentIntensity=e,o()};return{setFillLights:l,setEnvironmentIntensity:u,setToneMappingExposure:e=>{i.render.toneMappingExposure=e,n.toneMappingExposure=e,a.get()&&a.rebuild()},setAoIntensity:e=>{i.render.aoIntensity=e,a.get()&&a.rebuild()},setLook:e=>{let r=O[e];s=e,n.toneMapping=r.toneMapping,n.toneMappingExposure=r.toneMappingExposure,i.render.toneMapping=r.toneMapping,i.render.toneMappingExposure=r.toneMappingExposure,l({hemisphereIntensity:r.hemisphereIntensity,ambientIntensity:r.ambientIntensity}),u(r.environmentIntensity);let c=a.get()!==null;a.setAmbientOcclusion(r.ambientOcclusion),c&&a.rebuild(),t.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,n=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of n)`envMapIntensity`in e&&(e.envMapIntensity=r.envMapIntensity)}),o()},getMaterialAppearance:()=>k(s)}}function Ge(e,t){let n=t.parentElement,r=n?n.clientWidth:window.innerWidth,i=n?n.clientHeight:window.innerHeight,a=new c.PerspectiveCamera(e.camera.fov,r/i,e.camera.near,e.camera.far),o=e.camera.position;return o&&a.position.set(o.x,o.y,o.z),a}function Ke(e){let t=new c.Scene;return t.background=(typeof e.environment.backgroundColor==`string`?new c.Color(e.environment.backgroundColor):e.environment.backgroundColor)||null,t}function qe(e,t){o(e,t),e.environment?.dispose(),e.background instanceof c.Texture&&e.background.dispose()}const $={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new c.Vector2(1,1)},uColor:{value:new c.Color(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
56
54
  varying vec2 vUv;
57
55
  void main() {
58
56
  vUv = uv;
@@ -91,8 +89,8 @@ import{a as Kt,b as Yt,c as me,d as Zt,e as $t,g as Qt,h as Le,i as Ee,j as Oe,m
91
89
  float z2 = viewZOf(texture2D(tDepth, vUv + offsetB).x);
92
90
  float z3 = viewZOf(texture2D(tDepth, vUv - offsetB).x);
93
91
  float zCenter = viewZOf(texture2D(tDepth, vUv).x);
94
- // Normalized by center depth, not absolute Z: keeps the response scale-invariant across
95
- // the viewer's mm-to-m scenes (an absolute threshold would be noise far away, blind up close).
92
+ // Normalized by center depth, not absolute Z: keeps the response scale-invariant (an
93
+ // absolute threshold would be noise far away, blind up close).
96
94
  float depthDelta = (abs(z0 - z1) + abs(z2 - z3)) / max(abs(zCenter), 1e-6);
97
95
  float depthEdge = step(uDepthThreshold, depthDelta);
98
96
 
@@ -106,5 +104,5 @@ import{a as Kt,b as Yt,c as me,d as Zt,e as $t,g as Qt,h as Le,i as Ee,j as Oe,m
106
104
  float edge = max(depthEdge, normalEdge) * uOpacity;
107
105
  gl_FragColor = vec4(mix(color.rgb, uColor, edge), color.a);
108
106
  }
109
- `},Ae=class extends Qr{constructor(t,r,i,o,a={}){super();X(this,"camera");X(this,"scene");X(this,"normalMaterial");X(this,"edgeMaterial");X(this,"fsQuad");X(this,"normalTarget",null);X(this,"width");X(this,"height");this.scene=t,this.camera=r,this.width=Math.max(1,i),this.height=Math.max(1,o),this.normalMaterial=new O.MeshNormalMaterial,this.normalMaterial.blending=O.NoBlending,this.edgeMaterial=new O.ShaderMaterial({uniforms:O.UniformsUtils.clone(Ne.uniforms),vertexShader:Ne.vertexShader,fragmentShader:Ne.fragmentShader});let s=this.edgeMaterial.uniforms;s.uColor.value=new O.Color(a.color??2236962),s.uOpacity.value=a.opacity??1,s.uNormalThreshold.value=a.normalThreshold??.4,s.uDepthThreshold.value=a.depthThreshold??.02,s.uThickness.value=a.thickness??1,this.fsQuad=new Jr(this.edgeMaterial),this.needsSwap=!0}acquireNormalTarget(){if(!this.normalTarget){let t=new O.DepthTexture(this.width,this.height);this.normalTarget=new O.WebGLRenderTarget(this.width,this.height,{minFilter:O.NearestFilter,magFilter:O.NearestFilter,depthTexture:t})}return this.normalTarget}setSize(t,r){this.width=Math.max(1,t),this.height=Math.max(1,r),this.normalTarget?.setSize(this.width,this.height)}render(t,r,i){let o=this.acquireNormalTarget(),a=t.getRenderTarget(),s=t.autoClear,l=t.getClearColor(new O.Color),m=t.getClearAlpha(),f=this.scene.overrideMaterial;t.setRenderTarget(o),t.setClearColor(7829503,1),t.autoClear=!0,this.scene.overrideMaterial=this.normalMaterial,t.render(this.scene,this.camera),this.scene.overrideMaterial=f,t.setClearColor(l,m),t.autoClear=s;let E=this.edgeMaterial.uniforms;E.tDiffuse.value=i.texture,E.tNormal.value=o.texture,E.tDepth.value=o.depthTexture,E.uResolution.value.set(this.width,this.height);let g=this.camera;E.uPerspective.value=g.isPerspectiveCamera?1:0,E.uNear.value=this.camera.near??.1,E.uFar.value=this.camera.far??1e3,t.setRenderTarget(this.renderToScreen?null:r),this.fsQuad.render(t),t.setRenderTarget(a)}dispose(){this.normalTarget?.dispose(),this.normalMaterial.dispose(),this.edgeMaterial.dispose(),this.fsQuad.dispose()}};function Ot(e,n,t,r,i,o){let a=new en(e),s=new tn(n,t);a.addPass(s);let l=null;(o.ambientOcclusion??!0)&&(l=new rn(n,t,r,i),l.blendIntensity=o.aoIntensity??1,l.updateGtaoMaterial({screenSpaceRadius:!0}),a.addPass(l));let m=typeof o.edgeDetection=="object"?o.edgeDetection:{},f=new Ae(n,t,r,i,m);f.enabled=!!o.edgeDetection,a.addPass(f);let E=new nn;a.addPass(E);let g=new on;a.addPass(g),e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure;let u=o.aoPixelRatio??1;return a.setSize(r,i),{render:p=>a.render(p),setSize:(p,h,C)=>{a.setPixelRatio(Math.min(C,u)),a.setSize(p,h)},setCamera:p=>{if(s.camera=p,f.camera=p,!l)return;l.camera=p;let h=p.isPerspectiveCamera?1:0;l.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==h&&(l.gtaoMaterial.defines.PERSPECTIVE_CAMERA=h,l.gtaoMaterial.needsUpdate=!0)},setEdgeDetection:p=>{f.enabled=p},edgeDetectionEnabled:()=>f.enabled,dispose:()=>{a.dispose(),l?.dispose(),f.dispose(),E.dispose(),g.dispose()}}}function It(e){let{renderer:n,scene:t,getActiveCamera:r,getCanvasSize:i,pixelRatio:o,config:a,requestRender:s}=e,l=null,m=!!a.render.ambientOcclusion,f=!1,E=!1,g=p=>{let{width:h,height:C}=i(),b=Ot(n,t,r(),Math.max(1,h),Math.max(1,C),{toneMapping:a.render.toneMapping??Ft.NeutralToneMapping,toneMappingExposure:a.render.toneMappingExposure??1,ambientOcclusion:p,aoIntensity:a.render.aoIntensity,aoPixelRatio:a.render.aoPixelRatio,edgeDetection:!1});return b.setSize(Math.max(1,h),Math.max(1,C),o),b},u=()=>{if(!(m||f)){l?.dispose(),l=null,s();return}(!l||E!==m)&&(l?.dispose(),l=g(m),E=m),l.setEdgeDetection(f),s()};return{get:()=>l,sync:u,rebuild:()=>{l?.dispose(),l=null,u()},setAmbientOcclusion:p=>{m=p,u()},setEdgeFallback:p=>{p!==f&&(f=p,u())},isEdgeFallbackActive:()=>f,dispose:()=>{l?.dispose(),l=null}}}import{OrbitControls as an}from"three/addons/controls/OrbitControls.js";function kt(e,n,t){let r=new an(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=t.controls.enableZoom??!0,r.enablePan=t.controls.enablePan??!0,r.minDistance=t.controls.minDistance||.001,r.maxDistance=t.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}import*as N from"three";import{HDRLoader as sn}from"three/addons/loaders/HDRLoader.js";function zt(e,n,t,r){t.environment.enableEnvironmentLighting?new sn().load(t.environment.hdrPath||"/baseHDR.hdr",function(i){if(r()){i.dispose();return}if(!i?.image){me().warn("HDR loaded without image data; skipping environment map."),i?.dispose(),t.events.onReady?.();return}i.mapping=N.EquirectangularReflectionMapping;let o=new N.PMREMGenerator(n);o.compileEquirectangularShader();let a=o.fromEquirectangular(i).texture;o.dispose(),e.environment=a,e.environmentIntensity=t.environment.environmentIntensity??1;let s=Xe(t.environment.sceneUp??W);e.environmentRotation.copy(s),t.environment.showEnvironment?(e.background=i,e.backgroundRotation.copy(s)):i.dispose(),t.events.onReady?.()},void 0,function(i){r()||(me().warn("HDR texture could not be loaded, falling back to basic lighting:",i),t.events.onReady?.())}):t.events.onReady?.()}function _t(e,n){let t=n.floor.size,r=new N.PlaneGeometry(t,t),i=typeof n.floor.color=="string"?new N.Color(n.floor.color):n.floor.color,o=new N.MeshStandardMaterial({color:i,roughness:n.floor.roughness,metalness:n.floor.metalness,side:N.DoubleSide}),a=new N.Mesh(r,o);a.userData.id="floor",a.name="floor";let s=(n.environment?.sceneUp||W).clone().normalize();a.quaternion.setFromUnitVectors(new N.Vector3(0,0,1),s),a.position.set(0,0,0),n.floor.receiveShadow&&n.render.enableShadows&&(a.receiveShadow=!0),e.add(a)}import*as F from"three";function Vt(e,n,t,r){let i=new Set,o=new Map,a=new F.Raycaster,s=new F.Vector2,l=new F.Vector2,m=()=>t.getActiveCamera(),f=d=>{let c=d;for(;c;){if(!c.visible)return!1;c=c.parent}return!0},E=()=>{let d=Q(n);if(d.isEmpty()){me().warn("No objects to fit to view");return}t.frameBounds(d,!1)},g=typeof r.events.selectionColor=="string"?new F.Color(r.events.selectionColor):r.events.selectionColor instanceof F.Color?r.events.selectionColor:new F.Color("#ff0000"),u=()=>{i.forEach(d=>{let c=d;if(o.has(d)){let R=o.get(d),T=c.material;T instanceof F.Material?T.dispose():Array.isArray(T)&&T.forEach(M=>M.dispose()),c.material=R,o.delete(d);let x=d;for(;x.parent;)x=x.parent;x!==n&&(R instanceof F.Material?R.dispose():R.forEach(M=>M.dispose()))}}),i.clear()},p=d=>{let c=d;if(!(c.material instanceof F.Material))return!1;o.set(d,c.material);let R=c.material.clone();return d instanceof F.Mesh&&"emissive"in R?R.emissive=g.clone():"color"in R&&(R.color=g.clone()),c.material=R,!0},h=()=>{let d=Q(n),c=d.isEmpty()?1:d.getSize(new F.Vector3).length();a.params.Points.threshold=c*.01},C=d=>{l.set(d.clientX,d.clientY)},b=d=>{let c=new F.Vector2(d.clientX,d.clientY);if(l.distanceTo(c)>5)return;let R=e.getBoundingClientRect();s.x=(d.clientX-R.left)/R.width*2-1,s.y=-((d.clientY-R.top)/R.height)*2+1,h(),a.setFromCamera(s,m());let T=a.intersectObjects(n.children,!0).filter(x=>f(x.object));if(T.length>0){let x=T[0].object;i.has(x)||(u(),i.add(x),p(x),r.events?.onObjectSelected?.(x),x instanceof F.Mesh&&Object.keys(x.userData).length>0&&r.events?.onMeshMetadataClicked?.(x.userData))}else u(),r.events?.onBackgroundClicked?.({x:s.x,y:s.y})},A=d=>{let c=e.getBoundingClientRect();s.x=(d.clientX-c.left)/c.width*2-1,s.y=-((d.clientY-c.top)/c.height)*2+1,h(),a.setFromCamera(s,m());let R=a.intersectObjects(n.children,!0).filter(M=>f(M.object));if(R.length===0)return;let T=R[0].object;if(r.events?.onMeshDoubleClicked?.(T),!r.events?.enableDoubleClickZoom)return;let x=new F.Box3().setFromObject(T);x.isEmpty()||t.frameBounds(x,!0)},S=d=>{if(r.events?.enableKeyboardControls)switch(d.key.toLowerCase()){case"f":d.preventDefault(),E();break;case"escape":d.preventDefault(),u();break;case" ":d.preventDefault(),E();break}};return r.events?.enableClickToFocus&&(e.addEventListener("mousedown",C),e.addEventListener("click",b),e.addEventListener("dblclick",A)),r.events?.enableKeyboardControls&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",S)),{dispose:()=>{e.removeEventListener("mousedown",C),e.removeEventListener("click",b),e.removeEventListener("dblclick",A),e.removeEventListener("keydown",S),u()},fitToView:E,clearSelection:u}}import*as te from"three";function jt(e,n){let t=new te.AmbientLight(n.lighting.ambientLightColor,n.lighting.ambientLightIntensity);e.add(t);let r=null;if(n.lighting.enableHemisphereLight){r=new te.HemisphereLight(n.lighting.hemisphereSkyColor,n.lighting.hemisphereGroundColor,n.lighting.hemisphereIntensity);let a=n.environment.sceneUp??W;r.position.copy(a),e.add(r)}if(!n.lighting.enableSunlight)return{ambient:t,hemisphere:r,sun:null};let i=new te.DirectionalLight(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 Nt(e,n){if(n.isEmpty())return;let t=n.getCenter(new te.Vector3),r=n.getSize(new te.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()}import*as pe from"three";function Gt(e,n,t){let r=new pe.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=pe.VSMShadowMap),r.toneMapping=n.render.toneMapping,r.toneMappingExposure=n.render.toneMappingExposure??1,r.outputColorSpace=pe.SRGBColorSpace,r.sortObjects=!0,r}var ln=function(e,n){let t=Ct(n||{}),r=t.environment?.sceneUp||W,i=t.render.pixelRatio??Math.min(window.devicePixelRatio,2),o=At(t),a=Dt(t,e);a.up.copy(r);let s=Gt(e,t,i);We(s.capabilities.getMaxAnisotropy()),n?.onMaxAnisotropy?.(s.capabilities.getMaxAnisotropy());let l=Be(),m=kt(a,e,t),f=Ke({scene:o,perspective:a,controls:m,onActiveCameraChange:()=>{},up:r}),E=()=>f.getActiveCamera(),g=!1;zt(o,s,t,()=>g);let u=jt(o,t),p=u.sun,h=()=>{p&&Nt(p,Q(o))};t.floor?.enabled&&_t(o,t);let C=t.floor?.enabled?o.children.find(H=>H.userData.id==="floor")??null:null,b=t.grid.enabled?ht({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;b&&o.add(b.object);let A=()=>{b&&b.fitToContent(Q(o))},S=t.gizmo.enabled?xt({camera:a,domElement:e,controller:f}):null,I=t.grid.plane??xe(r),d=new Ut.Vector3(I==="x"?1:0,I==="y"?1:0,I==="z"?1:0),c=r.clone().normalize(),R=()=>{let H=[];return b?.object.visible&&H.push(d),t.floor.enabled&&C?.visible&&H.push(c),H},T=t.camera.dynamicNear?yt({camera:a,scene:o,groundNormals:R}):null,x=e.parentElement??e,M=t.measure.enabled?Rt(x,o):null,P=t.measure.enabled&&M?vt({canvas:e,scene:o,getActiveCamera:E,labelLayer:M,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?Vt(e,o,f,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},Y=5,w=0,k=0,v=H=>{w=H.clientX,k=H.clientY},y=H=>Math.hypot(H.clientX-w,H.clientY-k)>Y,z=H=>{if(!y(H)){if(P?.handleClick(H)){H.stopImmediatePropagation();return}S?.handleClick(H)&&H.stopImmediatePropagation()}};(S||P)&&(e.addEventListener("mousedown",v,{capture:!0}),e.addEventListener("click",z,{capture:!0}));let j=H=>P?.handleMove(H);P&&e.addEventListener("mousemove",j,{passive:!0});let V=()=>{},G=H=>{Et(H,{color:t.edges.color,darken:t.edges.darken,width:t.edges.width,thresholdAngle:t.edges.thresholdAngle,distanceFade:t.edges.distanceFade,maxTriangles:t.edges.maxTriangles,maxSegments:t.edges.maxSegments}).then(()=>{be(H),V()})},be=H=>{if(t.edges.screenSpaceFallback===!1)return;let ae=!1;H.traverse(Xt=>{Xt.userData?.edgesSkipped===we&&(ae=!0)}),U.setEdgeFallback(ae)},Z=H=>{ft(H),U.setEdgeFallback(!1),V()},ee=e.parentElement,re=()=>ee?{width:ee.clientWidth,height:ee.clientHeight}:{width:window.innerWidth,height:window.innerHeight},U=It({renderer:s,scene:o,getActiveCamera:E,getCanvasSize:re,pixelRatio:i,config:t,requestRender:()=>V()});U.sync();let q=Mt({scene:o,renderer:s,lights:u,config:t,pipeline:U,requestRender:()=>V()}),{animate:ve,dispose:ie,invalidate:ue}=Ht(s,o,a,E,f,m,re,i,t.events.onFrame,b,S,()=>U.get(),M,T,t.render.onDemand??!0);V=ue,ve(),o.up.set(r.x,r.y,r.z),h(),A();let Pe=H=>{H.userData.source="user",o.add(H)},Bt=H=>{H.removeFromParent(),se(H)},Wt=()=>{o.children.filter(ae=>ae.userData.source==="user").forEach(ae=>{ae.removeFromParent(),se(ae)})},qt=()=>{g||(g=!0,ie(),L.dispose(),(S||P)&&(e.removeEventListener("mousedown",v,{capture:!0}),e.removeEventListener("click",z,{capture:!0})),P&&e.removeEventListener("mousemove",j),P?.dispose(),M?.dispose(),S?.dispose(),b?.dispose(),U.dispose(),f.dispose(),m.dispose(),s.dispose(),s.forceContextLoss(),Lt(o),l())};return{scene:o,camera:a,controls:m,renderer:s,cameraController:f,grid:b,gizmo:S,measureTool:P,applyEdges:G,clearEdges:Z,invalidate:ue,setAmbientOcclusion:U.setAmbientOcclusion,setLook:q.setLook,setFillLights:q.setFillLights,setEnvironmentIntensity:q.setEnvironmentIntensity,setToneMappingExposure:q.setToneMappingExposure,setAoIntensity:q.setAoIntensity,getMaterialAppearance:q.getMaterialAppearance,updateShadowBounds:h,updateGridScale:A,dispose:qt,fitToView:L.fitToView,clearSelection:L.clearSelection,addUserGeometry:Pe,removeUserGeometry:Bt,clearUserGeometry:Wt}};export{Le as DEFAULT_LOOK,Kt as ErrorCodes,Qt as LOOKS,Ee as LOOK_PRESETS,Yt as VisualizationError,$t as enableDebugLogging,me as getLogger,ln as initThree,Oe as materialAppearanceForLook,Zt as setLogger,Jt as updateScene};
107
+ `};var Je=class extends C{camera;scene;normalMaterial;edgeMaterial;fsQuad;normalTarget=null;width;height;constructor(e,t,n,r,i={}){super(),this.scene=e,this.camera=t,this.width=Math.max(1,n),this.height=Math.max(1,r),this.normalMaterial=new c.MeshNormalMaterial,this.normalMaterial.blending=c.NoBlending,this.edgeMaterial=new c.ShaderMaterial({uniforms:c.UniformsUtils.clone($.uniforms),vertexShader:$.vertexShader,fragmentShader:$.fragmentShader});let a=this.edgeMaterial.uniforms;a.uColor.value=new c.Color(i.color??2236962),a.uOpacity.value=i.opacity??1,a.uNormalThreshold.value=i.normalThreshold??.4,a.uDepthThreshold.value=i.depthThreshold??.02,a.uThickness.value=i.thickness??1,this.fsQuad=new S(this.edgeMaterial),this.needsSwap=!0}acquireNormalTarget(){if(!this.normalTarget){let e=new c.DepthTexture(this.width,this.height);this.normalTarget=new c.WebGLRenderTarget(this.width,this.height,{minFilter:c.NearestFilter,magFilter:c.NearestFilter,depthTexture:e})}return this.normalTarget}setSize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.normalTarget?.setSize(this.width,this.height)}render(e,t,n){let r=this.acquireNormalTarget(),i=e.getRenderTarget(),a=e.autoClear,o=e.getClearColor(new c.Color),s=e.getClearAlpha(),l=this.scene.overrideMaterial;e.setRenderTarget(r),e.setClearColor(7829503,1),e.autoClear=!0,this.scene.overrideMaterial=this.normalMaterial,e.render(this.scene,this.camera),this.scene.overrideMaterial=l,e.setClearColor(o,s),e.autoClear=a;let u=this.edgeMaterial.uniforms;u.tDiffuse.value=n.texture,u.tNormal.value=r.texture,u.tDepth.value=r.depthTexture,u.uResolution.value.set(this.width,this.height);let d=this.camera;u.uPerspective.value=+!!d.isPerspectiveCamera,u.uNear.value=this.camera.near??.1,u.uFar.value=this.camera.far??1e3,e.setRenderTarget(this.renderToScreen?null:t),this.fsQuad.render(e),e.setRenderTarget(i)}dispose(){this.normalTarget?.dispose(),this.normalMaterial.dispose(),this.edgeMaterial.dispose(),this.fsQuad.dispose()}};function Ye(e,t,n,r,i,a){let o=new _(e),s=new v(t,n);o.addPass(s);let c=null;(a.ambientOcclusion??!0)&&(c=new y(t,n,r,i),c.blendIntensity=a.aoIntensity??1,c.updateGtaoMaterial({screenSpaceRadius:!0}),o.addPass(c));let l=new Je(t,n,r,i,typeof a.edgeDetection==`object`?a.edgeDetection:{});l.enabled=!!a.edgeDetection,o.addPass(l);let u=new b;o.addPass(u);let d=new x;o.addPass(d),e.toneMapping=a.toneMapping,e.toneMappingExposure=a.toneMappingExposure;let f=a.aoPixelRatio??1;return o.setSize(r,i),{render:e=>o.render(e),setSize:(e,t,n)=>{o.setPixelRatio(Math.min(n,f)),o.setSize(e,t)},setCamera:e=>{if(s.camera=e,l.camera=e,!c)return;c.camera=e;let t=+!!e.isPerspectiveCamera;c.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==t&&(c.gtaoMaterial.defines.PERSPECTIVE_CAMERA=t,c.gtaoMaterial.needsUpdate=!0)},setEdgeDetection:e=>{l.enabled=e},edgeDetectionEnabled:()=>l.enabled,dispose:()=>{o.dispose(),c?.dispose(),l.dispose(),u.dispose(),d.dispose()}}}function Xe(e){let{renderer:t,scene:n,getActiveCamera:r,getCanvasSize:i,pixelRatio:a,config:o,requestRender:s}=e,l=null,u=!!o.render.ambientOcclusion,d=!1,f=!1,p=e=>{let{width:s,height:l}=i(),u=Ye(t,n,r(),Math.max(1,s),Math.max(1,l),{toneMapping:o.render.toneMapping??c.NeutralToneMapping,toneMappingExposure:o.render.toneMappingExposure??1,ambientOcclusion:e,aoIntensity:o.render.aoIntensity,aoPixelRatio:o.render.aoPixelRatio,edgeDetection:!1});return u.setSize(Math.max(1,s),Math.max(1,l),a),u},m=()=>{if(!(u||d)){l?.dispose(),l=null,s();return}(!l||f!==u)&&(l?.dispose(),l=p(u),f=u),l.setEdgeDetection(d),s()};return{get:()=>l,sync:m,rebuild:()=>{l?.dispose(),l=null,m()},setAmbientOcclusion:e=>{u=e,m()},setEdgeFallback:e=>{e!==d&&(d=e,m())},isEdgeFallbackActive:()=>d,dispose:()=>{l?.dispose(),l=null}}}function Ze(e,t,n){let r=new w(e,t),i=n.camera.target;return i&&r.target.set(i.x,i.y,i.z),r.enableDamping=n.controls.enableDamping||!1,r.dampingFactor=n.controls.dampingFactor||.05,r.autoRotate=n.controls.autoRotate||!1,r.autoRotateSpeed=n.controls.autoRotateSpeed||.5,r.enableZoom=n.controls.enableZoom??!0,r.enablePan=n.controls.enablePan??!0,r.minDistance=n.controls.minDistance||.001,r.maxDistance=n.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}function Qe(e,n,r,i){r.environment.enableEnvironmentLighting?new T().load(r.environment.hdrPath||`/baseHDR.hdr`,function(a){if(i()){a.dispose();return}if(!a?.image){t().warn(`HDR loaded without image data; skipping environment map.`),a?.dispose(),r.events.onReady?.();return}a.mapping=c.EquirectangularReflectionMapping;let o=new c.PMREMGenerator(n);o.compileEquirectangularShader();let s=o.fromEquirectangular(a).texture;o.dispose(),e.environment=s,e.environmentIntensity=r.environment.environmentIntensity??1;let l=ee(r.environment.sceneUp??Q);e.environmentRotation.copy(l),r.environment.showEnvironment?(e.background=a,e.backgroundRotation.copy(l)):a.dispose(),r.events.onReady?.()},void 0,function(e){i()||(t().warn(`HDR texture could not be loaded, falling back to basic lighting:`,e),r.events.onReady?.())}):r.events.onReady?.()}function $e(e,t){let n=t.floor.size,r=new c.PlaneGeometry(n,n),i=typeof t.floor.color==`string`?new c.Color(t.floor.color):t.floor.color,a=new c.MeshStandardMaterial({color:i,roughness:t.floor.roughness,metalness:t.floor.metalness,side:c.DoubleSide}),o=new c.Mesh(r,a);o.userData.id=`floor`,o.name=`floor`;let s=(t.environment?.sceneUp||Q).clone().normalize();o.quaternion.setFromUnitVectors(new c.Vector3(0,0,1),s),o.position.set(0,0,0),t.floor.receiveShadow&&t.render.enableShadows&&(o.receiveShadow=!0),e.add(o)}function et(e,n,r,i){let a=new Set,o=new Map,s=new c.Raycaster,l=new c.Vector2,u=new c.Vector2,d=()=>r.getActiveCamera(),f=e=>{let t=e;for(;t;){if(!t.visible)return!1;t=t.parent}return!0},p=()=>{let e=L(n);if(e.isEmpty()){t().warn(`No objects to fit to view`);return}r.frameBounds(e,!1)},m=typeof i.events.selectionColor==`string`?new c.Color(i.events.selectionColor):i.events.selectionColor instanceof c.Color?i.events.selectionColor:new c.Color(`#ff0000`),h=()=>{a.forEach(e=>{let t=e;if(o.has(e)){let r=o.get(e),i=t.material;i instanceof c.Material?i.dispose():Array.isArray(i)&&i.forEach(e=>e.dispose()),t.material=r,o.delete(e);let a=e;for(;a.parent;)a=a.parent;a!==n&&(r instanceof c.Material?r.dispose():r.forEach(e=>e.dispose()))}}),a.clear()},g=e=>{let t=e;if(!(t.material instanceof c.Material))return!1;o.set(e,t.material);let n=t.material.clone();return e instanceof c.Mesh&&`emissive`in n?n.emissive=m.clone():`color`in n&&(n.color=m.clone()),t.material=n,!0},_=()=>{let e=L(n),t=e.isEmpty()?1:e.getSize(new c.Vector3).length();s.params.Points.threshold=t*.01},v=e=>{u.set(e.clientX,e.clientY)},y=t=>{let r=new c.Vector2(t.clientX,t.clientY);if(u.distanceTo(r)>5)return;let o=e.getBoundingClientRect();l.x=(t.clientX-o.left)/o.width*2-1,l.y=-((t.clientY-o.top)/o.height)*2+1,_(),s.setFromCamera(l,d());let p=s.intersectObjects(n.children,!0).filter(e=>f(e.object));if(p.length>0){let e=p[0].object;a.has(e)||(h(),a.add(e),g(e),i.events?.onObjectSelected?.(e),e instanceof c.Mesh&&Object.keys(e.userData).length>0&&i.events?.onMeshMetadataClicked?.(e.userData))}else h(),i.events?.onBackgroundClicked?.({x:l.x,y:l.y})},b=t=>{let a=e.getBoundingClientRect();l.x=(t.clientX-a.left)/a.width*2-1,l.y=-((t.clientY-a.top)/a.height)*2+1,_(),s.setFromCamera(l,d());let o=s.intersectObjects(n.children,!0).filter(e=>f(e.object));if(o.length===0)return;let u=o[0].object;if(i.events?.onMeshDoubleClicked?.(u),!i.events?.enableDoubleClickZoom)return;let p=new c.Box3().setFromObject(u);p.isEmpty()||r.frameBounds(p,!0)},x=e=>{if(i.events?.enableKeyboardControls)switch(e.key.toLowerCase()){case`f`:e.preventDefault(),p();break;case`escape`:e.preventDefault(),h();break;case` `:e.preventDefault(),p()}};return i.events?.enableClickToFocus&&(e.addEventListener(`mousedown`,v),e.addEventListener(`click`,y),e.addEventListener(`dblclick`,b)),i.events?.enableKeyboardControls&&(e.setAttribute(`tabindex`,`0`),e.addEventListener(`keydown`,x)),{dispose:()=>{e.removeEventListener(`mousedown`,v),e.removeEventListener(`click`,y),e.removeEventListener(`dblclick`,b),e.removeEventListener(`keydown`,x),h()},fitToView:p,clearSelection:h}}function tt(e,t){let n=new c.AmbientLight(t.lighting.ambientLightColor,t.lighting.ambientLightIntensity);e.add(n);let r=null;if(t.lighting.enableHemisphereLight){r=new c.HemisphereLight(t.lighting.hemisphereSkyColor,t.lighting.hemisphereGroundColor,t.lighting.hemisphereIntensity);let n=t.environment.sceneUp??Q;r.position.copy(n),e.add(r)}if(!t.lighting.enableSunlight)return{ambient:n,hemisphere:r,sun:null};let i=new c.DirectionalLight(t.lighting.sunlightColor??16777215,t.lighting.sunlightIntensity),a=t.lighting.sunlightPosition;return a&&i.position.set(a.x,a.y,a.z),t.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=t.render.shadowMapSize||2048,i.shadow.mapSize.height=t.render.shadowMapSize||2048,i.shadow.bias=-1e-4,i.shadow.normalBias=.02,i.shadow.radius=4,e.add(i),e.add(i.target),{ambient:n,hemisphere:r,sun:i}):(e.add(i),{ambient:n,hemisphere:r,sun:null})}function nt(e,t){if(t.isEmpty())return;let n=t.getCenter(new c.Vector3),r=t.getSize(new c.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(n),e.target.updateMatrixWorld();let a=e.position.distanceTo(n);i.near=Math.max(r*.01,a-r),i.far=a+r,i.updateProjectionMatrix()}function rt(e,t,n){let r=new c.WebGLRenderer({antialias:t.render.antialias,canvas:e,alpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:t.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),i=e.parentElement,a=i?i.clientWidth:window.innerWidth,o=i?i.clientHeight:window.innerHeight;return i&&(e.style.width=`100%`,e.style.height=`100%`,e.style.display=`block`),r.setSize(a,o,!1),r.setPixelRatio(n),t.render.enableShadows&&(r.shadowMap.enabled=!0,r.shadowMap.type=c.VSMShadowMap),r.toneMapping=t.render.toneMapping,r.toneMappingExposure=t.render.toneMappingExposure??1,r.outputColorSpace=c.SRGBColorSpace,r.sortObjects=!0,r}const it=function(e,t){let n=Ue(t||{}),r=n.environment?.sceneUp||Q,a=n.render.pixelRatio??Math.min(window.devicePixelRatio,2),s=Ke(n),l=Ge(n,e);l.up.copy(r);let u=rt(e,n,a);i(u.capabilities.getMaxAnisotropy()),t?.onMaxAnisotropy?.(u.capabilities.getMaxAnisotropy());let d=Ze(l,e,n),f=ne({scene:s,perspective:l,controls:d,onActiveCameraChange:()=>{},up:r}),p=()=>f.getActiveCamera(),m=!1;Qe(s,u,n,()=>m);let h=tt(s,n),g=h.sun,_=()=>{g&&nt(g,L(s))};n.floor?.enabled&&$e(s,n);let v=n.floor?.enabled?s.children.find(e=>e.userData.id===`floor`)??null:null,y=n.grid.enabled?Ae({cellSize:n.grid.cellSize,majorEvery:n.grid.majorEvery,cellColor:n.grid.cellColor,majorColor:n.grid.majorColor,fadeDistance:n.grid.fadeDistance,plane:n.grid.plane}):null;y&&s.add(y.object);let b=()=>{y&&y.fitToContent(L(s))},x=n.gizmo.enabled?Ve({camera:l,domElement:e,controller:f}):null,S=n.grid.plane??te(r),C=new c.Vector3(+(S===`x`),+(S===`y`),+(S===`z`)),w=r.clone().normalize(),T=n.camera.dynamicNear?Be({camera:l,scene:s,groundNormals:()=>{let e=[];return y?.object.visible&&e.push(C),n.floor.enabled&&v?.visible&&e.push(w),e}}):null,E=e.parentElement??e,D=n.measure.enabled?je(E,s):null,O=n.measure.enabled&&D?Re({canvas:e,scene:s,getActiveCamera:p,labelLayer:D,options:{snapPixels:n.measure.snapPixels,color:n.measure.color,labelClassName:n.measure.labelClassName,displayUnit:n.measure.displayUnit,format:n.measure.format}}):null,k=n.events.enableEventHandlers===!1?{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}}:et(e,s,f,n),A=0,j=0,M=e=>{A=e.clientX,j=e.clientY},ee=e=>Math.hypot(e.clientX-A,e.clientY-j)>5,N=e=>{if(!ee(e)){if(O?.handleClick(e)){e.stopImmediatePropagation();return}x?.handleClick(e)&&e.stopImmediatePropagation()}};(x||O)&&(e.addEventListener(`mousedown`,M,{capture:!0}),e.addEventListener(`click`,N,{capture:!0}));let P=e=>O?.handleMove(e);O&&e.addEventListener(`mousemove`,P,{passive:!0});let F=()=>{},I=e=>{De(e,{color:n.edges.color,darken:n.edges.darken,width:n.edges.width,thresholdAngle:n.edges.thresholdAngle,distanceFade:n.edges.distanceFade,maxTriangles:n.edges.maxTriangles,maxSegments:n.edges.maxSegments}).then(()=>{R(e),F()})},R=e=>{if(n.edges.screenSpaceFallback===!1)return;let t=!1;e.traverse(e=>{e.userData?.edgesSkipped===`triangle-cap`&&(t=!0)}),H.setEdgeFallback(t)},z=e=>{Oe(e),H.setEdgeFallback(!1),F()},B=e.parentElement,V=()=>B?{width:B.clientWidth,height:B.clientHeight}:{width:window.innerWidth,height:window.innerHeight},H=Xe({renderer:u,scene:s,getActiveCamera:p,getCanvasSize:V,pixelRatio:a,config:n,requestRender:()=>F()});H.sync();let U=We({scene:s,renderer:u,lights:h,config:n,pipeline:H,requestRender:()=>F()}),{animate:W,dispose:G,invalidate:K}=He(u,s,l,p,f,d,V,a,n.events.onFrame,y,x,()=>H.get(),D,T,n.render.onDemand??!0);return F=K,W(),s.up.set(r.x,r.y,r.z),_(),b(),{scene:s,camera:l,controls:d,renderer:u,cameraController:f,grid:y,gizmo:x,measureTool:O,applyEdges:I,clearEdges:z,invalidate:K,setAmbientOcclusion:H.setAmbientOcclusion,setLook:U.setLook,setFillLights:U.setFillLights,setEnvironmentIntensity:U.setEnvironmentIntensity,setToneMappingExposure:U.setToneMappingExposure,setAoIntensity:U.setAoIntensity,getMaterialAppearance:U.getMaterialAppearance,updateShadowBounds:_,updateGridScale:b,dispose:()=>{m||(m=!0,G(),k.dispose(),(x||O)&&(e.removeEventListener(`mousedown`,M,{capture:!0}),e.removeEventListener(`click`,N,{capture:!0})),O&&e.removeEventListener(`mousemove`,P),O?.dispose(),D?.dispose(),x?.dispose(),y?.dispose(),H.dispose(),f.dispose(),d.dispose(),u.dispose(),u.forceContextLoss(),qe(s))},fitToView:k.fitToView,clearSelection:k.clearSelection,addUserGeometry:e=>{e.userData.source=`user`,s.add(e)},removeUserGeometry:e=>{e.removeFromParent(),o(e)},clearUserGeometry:()=>{s.children.filter(e=>e.userData.source===`user`).forEach(e=>{e.removeFromParent(),o(e)})}}};export{D as DEFAULT_LOOK,s as ErrorCodes,E as LOOKS,O as LOOK_PRESETS,n as VisualizationError,a as enableDebugLogging,t as getLogger,it as initThree,k as materialAppearanceForLook,r as setLogger,P as updateScene};
110
108
  //# sourceMappingURL=render.js.map