@selvajs/visualization 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{gpu-dispose-DrN-ryj5.cjs → gpu-dispose-08qVHlV6.cjs} +2 -2
- package/dist/{gpu-dispose-DrN-ryj5.cjs.map → gpu-dispose-08qVHlV6.cjs.map} +1 -1
- package/dist/{gpu-dispose-Dkj-BKt4.js → gpu-dispose-Cm4qCZiL.js} +2 -2
- package/dist/{gpu-dispose-Dkj-BKt4.js.map → gpu-dispose-Cm4qCZiL.js.map} +1 -1
- package/dist/parse.cjs +1 -1
- package/dist/parse.d.cts +8 -8
- package/dist/parse.d.ts +8 -8
- package/dist/parse.js +1 -1
- package/dist/render.cjs +2 -2
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +20 -20
- package/dist/render.d.ts +20 -20
- package/dist/render.js +2 -2
- package/dist/render.js.map +1 -1
- package/dist/scene.d.cts +6 -6
- package/dist/scene.d.ts +6 -6
- package/package.json +8 -8
package/dist/render.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./gpu-dispose-DrN-ryj5.cjs");let n=require("three");n=e.t(n,1);let r=require("three/addons/lines/Line2.js"),i=require("three/addons/lines/LineGeometry.js"),a=require("three/addons/lines/LineMaterial.js"),o=require("three/addons/lines/LineSegments2.js"),s=require("three/addons/lines/LineSegmentsGeometry.js"),c=require("three/addons/renderers/CSS2DRenderer.js"),l=require("three/addons/helpers/ViewHelper.js"),u=require("three/addons/postprocessing/EffectComposer.js"),d=require("three/addons/postprocessing/RenderPass.js"),f=require("three/addons/postprocessing/GTAOPass.js"),p=require("three/addons/postprocessing/SMAAPass.js"),m=require("three/addons/postprocessing/OutputPass.js"),h=require("three/addons/postprocessing/Pass.js"),g=require("three/addons/controls/OrbitControls.js"),_=require("three/addons/loaders/HDRLoader.js");const v=[`technical`,`studio`,`showcase`,`arctic`,`xray`,`lineart`,`wireframe`],y={studio:{toneMapping:n.ACESFilmicToneMapping,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:.85,hemisphereIntensity:.5,ambientIntensity:.25,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:1.6},technical:{toneMapping:n.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:.55,environmentIntensity:.6,hemisphereIntensity:.25,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2.2},showcase:{toneMapping:n.ACESFilmicToneMapping,toneMappingExposure:1.15,envMapIntensity:1.4,environmentIntensity:1,hemisphereIntensity:.2,ambientIntensity:.1,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2.6},arctic:{toneMapping:n.NeutralToneMapping,toneMappingExposure:1.05,envMapIntensity:.85,environmentIntensity:1.1,hemisphereIntensity:.3,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2,materialOverride:{color:15659509,metalness:0,roughness:.75}},xray:{toneMapping:n.NeutralToneMapping,toneMappingExposure:1.3,envMapIntensity:.4,environmentIntensity:.8,hemisphereIntensity:.6,ambientIntensity:.6,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:.6,materialOverride:{color:10470632,metalness:0,roughness:.9,opacity:.28,depthWrite:!1}},lineart:{toneMapping:n.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.6,ambientIntensity:3.2,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:0,requiresEdges:!0,materialOverride:{color:16251130,metalness:0,roughness:1}},wireframe:{toneMapping:n.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.4,ambientIntensity:2,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:0,materialOverride:{color:2830648,metalness:0,roughness:1,wireframe:!0}}};function b(e){let t=y[e];return{envMapIntensity:t.envMapIntensity,cullBackfaces:t.cullBackfaces}}const x=`user`,S=`app:`;function C(e){return`${S}${e}`}function w(e){return typeof e!=`string`||!e.startsWith(S)?null:e.slice(4)||null}function T(e){let t=e.userData?.source;return t===`user`||w(t)!==null}function E(e,t){return t===void 0?T(e):e.userData?.source===C(t)}function D(e){let t=e.clone().normalize(),r=new n.Vector3(0,0,1),i=new n.Vector3(0,1,0),a=Math.abs(t.dot(r))>.9?i:r,o=new n.Vector3().crossVectors(a,t).normalize();return{up:t,forward:new n.Vector3().crossVectors(t,o).normalize(),right:o}}function O(e,t){let{forward:n,right:r,up:i}=D(e);return n.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(t)}function k(e,t,n){let{forward:r,right:i,up:a}=D(e);return i.clone().multiplyScalar(t).add(r.clone().multiplyScalar(t)).add(a.clone().multiplyScalar(n))}function A(e){let t=e.clone().normalize(),r=new n.Vector3(0,1,0);if(t.dot(r)>.9999)return new n.Euler;if(t.dot(r)<-.9999)return new n.Euler(Math.PI,0,0);let i=new n.Quaternion().setFromUnitVectors(r,t);return new n.Euler().setFromQuaternion(i)}function j(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 M={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 N(e,r,i,a,o){if(L(e),r.length===0)return;r.forEach(t=>{e.add(t)});let s=t.a(r),c=s.getCenter(new n.Vector3),l=s.getSize(new n.Vector3),u=Math.max(l.x,l.y,l.z);if(u/Math.min(l.x||1,l.y||1,l.z||1)>M.SCALE_RATIO_THRESHOLD||u>M.HUGE_THRESHOLD?(i.near=u*M.NEAR_PLANE_FACTOR.TINY,i.far=u*M.FAR_PLANE_FACTOR.HUGE):u>M.LARGE_THRESHOLD?(i.near=u*M.NEAR_PLANE_FACTOR.SMALL,i.far=u*M.FAR_PLANE_FACTOR.LARGE):(i.near=Math.max(.01,u*M.NEAR_PLANE_FACTOR.NORMAL),i.far=Math.max(2e3,u*M.FAR_PLANE_FACTOR.NORMAL)),i.updateProjectionMatrix(),!o){let e=u*M.INITIAL_DISTANCE_MULTIPLIER;i.position.copy(c).add(O(i.up,e)),a.target.copy(c),a.update()}}const P=new Set([`grid`,`floor`,`label-layer`,`measure`]);function F(e){let t=e;for(;t;){if(typeof t.userData.id==`string`&&P.has(t.userData.id))return!0;t=t.parent}return!1}function I(e){e.updateMatrixWorld(!0);let t=new n.Box3;return e.traverse(e=>{let n=e;e.visible&&!F(e)&&n.geometry&&t.expandByObject(e)}),t}const ee=new Set([`floor`,`grid`,`label-layer`]);function L(e){[...e.children].forEach(e=>{ee.has(e.userData.id)||T(e)||(t.t(e),e.removeFromParent())})}function R(e){let{up:t,forward:n,right:r}=D(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 te(e){let{scene:t,perspective:r,controls:i,onActiveCameraChange:a}=e,o=(e.up??r.up).clone().normalize(),s=R(o),c=new n.OrthographicCamera(-1,1,1,-1,r.near,r.far);c.up.copy(o);let l=`perspective`,u=r.aspect,d=()=>l===`perspective`?r:c,f=null,p=()=>{f?.cancel(),f=null},m=()=>{let e=(l===`orthographic`?c:r).position.distanceTo(i.target)*Math.tan(r.fov*Math.PI/360),t=e*u;c.left=-t,c.right=t,c.top=e,c.bottom=-e,c.near=r.near,c.far=r.far,c.updateProjectionMatrix()},h=e=>{if(e!==l){if(p(),e===`orthographic`)c.position.copy(r.position),c.up.copy(r.up),c.lookAt(i.target),c.zoom=1,m();else{let e=(c.top-c.bottom)/(2*c.zoom)/Math.tan(r.fov*Math.PI/360),t=c.position.clone().sub(i.target);t.lengthSq()<1e-12&&t.copy(o),t.normalize(),r.position.copy(i.target).add(t.multiplyScalar(e))}l=e,i.object=d(),i.update(),a(d())}},g=(e,t,n,a)=>{let s=r.fov*(Math.PI/180),u=t/(2*Math.tan(s/2))*1.5,h=z(n,o),g=e.clone().add(h.clone().multiplyScalar(u)),_=d();l===`orthographic`&&(c.zoom=1),p(),a?f=re(_,i,g,e,()=>{l===`orthographic`&&m()}):(_.position.copy(g),i.target.copy(e),l===`orthographic`&&m(),i.update())},_=(e,r=!0)=>{let a=I(t),o=a.isEmpty()?i.target.clone():a.getCenter(new n.Vector3),s=a.isEmpty()?new n.Vector3(1,1,1):a.getSize(new n.Vector3),c=Math.max(s.x,s.y,s.z)||1;g(o,c,e,r)};return{getActiveCamera:d,getProjection:()=>l,setProjection:h,toggleProjection:()=>(h(l===`perspective`?`orthographic`:`perspective`),l),setView:(e,t=!0)=>{_(s[e],t)},setViewDirection:_,frameBounds:(e,t=!0)=>{if(e.isEmpty())return;let r=e.getCenter(new n.Vector3),a=e.getSize(new n.Vector3),o=Math.max(a.x,a.y,a.z)||1,c=d().position.clone().sub(i.target);c.lengthSq()<1e-12&&c.copy(s.iso),g(r,o,c.normalize(),t)},setRotateEnabled:e=>{i.enableRotate=e},isRotateEnabled:()=>i.enableRotate,updateAspect:(e,t)=>{u=t===0?u:e/t,l===`orthographic`&&m()},dispose:p}}function z(e,t){let{up:n,forward:r}=D(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 ne=e=>1-(1-e)**3;function re(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=ne(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 ie(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 B(e){let t=new s.LineSegmentsGeometry;return t.setPositions(e),{geometry:t,segmentCount:e.length/6,edgeSpacing:ie(e)}}function V(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 H(){return[`const extract = ${V.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(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./gpu-dispose-08qVHlV6.cjs");let n=require("three");n=e.t(n,1);let r=require("three/addons/lines/Line2.js"),i=require("three/addons/lines/LineGeometry.js"),a=require("three/addons/lines/LineMaterial.js"),o=require("three/addons/lines/LineSegments2.js"),s=require("three/addons/lines/LineSegmentsGeometry.js"),c=require("three/addons/renderers/CSS2DRenderer.js"),l=require("three/addons/helpers/ViewHelper.js"),u=require("three/addons/postprocessing/EffectComposer.js"),d=require("three/addons/postprocessing/RenderPass.js"),f=require("three/addons/postprocessing/GTAOPass.js"),p=require("three/addons/postprocessing/SMAAPass.js"),m=require("three/addons/postprocessing/OutputPass.js"),h=require("three/addons/postprocessing/Pass.js"),g=require("three/addons/controls/OrbitControls.js"),_=require("three/addons/loaders/HDRLoader.js");const v=[`technical`,`studio`,`showcase`,`arctic`,`xray`,`lineart`,`wireframe`],y={studio:{toneMapping:n.ACESFilmicToneMapping,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:.85,hemisphereIntensity:.5,ambientIntensity:.25,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:1.6},technical:{toneMapping:n.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:.55,environmentIntensity:.6,hemisphereIntensity:.25,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2.2},showcase:{toneMapping:n.ACESFilmicToneMapping,toneMappingExposure:1.15,envMapIntensity:1.4,environmentIntensity:1,hemisphereIntensity:.2,ambientIntensity:.1,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2.6},arctic:{toneMapping:n.NeutralToneMapping,toneMappingExposure:1.05,envMapIntensity:.85,environmentIntensity:1.1,hemisphereIntensity:.3,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2,materialOverride:{color:15659509,metalness:0,roughness:.75}},xray:{toneMapping:n.NeutralToneMapping,toneMappingExposure:1.3,envMapIntensity:.4,environmentIntensity:.8,hemisphereIntensity:.6,ambientIntensity:.6,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:.6,materialOverride:{color:10470632,metalness:0,roughness:.9,opacity:.28,depthWrite:!1}},lineart:{toneMapping:n.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.6,ambientIntensity:3.2,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:0,requiresEdges:!0,materialOverride:{color:16251130,metalness:0,roughness:1}},wireframe:{toneMapping:n.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.4,ambientIntensity:2,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:0,materialOverride:{color:2830648,metalness:0,roughness:1,wireframe:!0}}};function b(e){let t=y[e];return{envMapIntensity:t.envMapIntensity,cullBackfaces:t.cullBackfaces}}const x=`user`,S=`app:`;function C(e){return`${S}${e}`}function w(e){return typeof e!=`string`||!e.startsWith(S)?null:e.slice(4)||null}function T(e){let t=e.userData?.source;return t===`user`||w(t)!==null}function E(e,t){return t===void 0?T(e):e.userData?.source===C(t)}function D(e){let t=e.clone().normalize(),r=new n.Vector3(0,0,1),i=new n.Vector3(0,1,0),a=Math.abs(t.dot(r))>.9?i:r,o=new n.Vector3().crossVectors(a,t).normalize();return{up:t,forward:new n.Vector3().crossVectors(t,o).normalize(),right:o}}function O(e,t){let{forward:n,right:r,up:i}=D(e);return n.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(t)}function k(e,t,n){let{forward:r,right:i,up:a}=D(e);return i.clone().multiplyScalar(t).add(r.clone().multiplyScalar(t)).add(a.clone().multiplyScalar(n))}function A(e){let t=e.clone().normalize(),r=new n.Vector3(0,1,0);if(t.dot(r)>.9999)return new n.Euler;if(t.dot(r)<-.9999)return new n.Euler(Math.PI,0,0);let i=new n.Quaternion().setFromUnitVectors(r,t);return new n.Euler().setFromQuaternion(i)}function j(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 M={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 N(e,r,i,a,o){if(L(e),r.length===0)return;r.forEach(t=>{e.add(t)});let s=t.a(r),c=s.getCenter(new n.Vector3),l=s.getSize(new n.Vector3),u=Math.max(l.x,l.y,l.z);if(u/Math.min(l.x||1,l.y||1,l.z||1)>M.SCALE_RATIO_THRESHOLD||u>M.HUGE_THRESHOLD?(i.near=u*M.NEAR_PLANE_FACTOR.TINY,i.far=u*M.FAR_PLANE_FACTOR.HUGE):u>M.LARGE_THRESHOLD?(i.near=u*M.NEAR_PLANE_FACTOR.SMALL,i.far=u*M.FAR_PLANE_FACTOR.LARGE):(i.near=Math.max(.01,u*M.NEAR_PLANE_FACTOR.NORMAL),i.far=Math.max(2e3,u*M.FAR_PLANE_FACTOR.NORMAL)),i.updateProjectionMatrix(),!o){let e=u*M.INITIAL_DISTANCE_MULTIPLIER;i.position.copy(c).add(O(i.up,e)),a.target.copy(c),a.update()}}const P=new Set([`grid`,`floor`,`label-layer`,`measure`]);function F(e){let t=e;for(;t;){if(typeof t.userData.id==`string`&&P.has(t.userData.id))return!0;t=t.parent}return!1}function I(e){e.updateMatrixWorld(!0);let t=new n.Box3;return e.traverse(e=>{let n=e;e.visible&&!F(e)&&n.geometry&&t.expandByObject(e)}),t}const ee=new Set([`floor`,`grid`,`label-layer`]);function L(e){[...e.children].forEach(e=>{ee.has(e.userData.id)||T(e)||(t.t(e),e.removeFromParent())})}function R(e){let{up:t,forward:n,right:r}=D(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 te(e){let{scene:t,perspective:r,controls:i,onActiveCameraChange:a}=e,o=(e.up??r.up).clone().normalize(),s=R(o),c=new n.OrthographicCamera(-1,1,1,-1,r.near,r.far);c.up.copy(o);let l=`perspective`,u=r.aspect,d=()=>l===`perspective`?r:c,f=null,p=()=>{f?.cancel(),f=null},m=()=>{let e=(l===`orthographic`?c:r).position.distanceTo(i.target)*Math.tan(r.fov*Math.PI/360),t=e*u;c.left=-t,c.right=t,c.top=e,c.bottom=-e,c.near=r.near,c.far=r.far,c.updateProjectionMatrix()},h=e=>{if(e!==l){if(p(),e===`orthographic`)c.position.copy(r.position),c.up.copy(r.up),c.lookAt(i.target),c.zoom=1,m();else{let e=(c.top-c.bottom)/(2*c.zoom)/Math.tan(r.fov*Math.PI/360),t=c.position.clone().sub(i.target);t.lengthSq()<1e-12&&t.copy(o),t.normalize(),r.position.copy(i.target).add(t.multiplyScalar(e))}l=e,i.object=d(),i.update(),a(d())}},g=(e,t,n,a)=>{let s=r.fov*(Math.PI/180),u=t/(2*Math.tan(s/2))*1.5,h=z(n,o),g=e.clone().add(h.clone().multiplyScalar(u)),_=d();l===`orthographic`&&(c.zoom=1),p(),a?f=re(_,i,g,e,()=>{l===`orthographic`&&m()}):(_.position.copy(g),i.target.copy(e),l===`orthographic`&&m(),i.update())},_=(e,r=!0)=>{let a=I(t),o=a.isEmpty()?i.target.clone():a.getCenter(new n.Vector3),s=a.isEmpty()?new n.Vector3(1,1,1):a.getSize(new n.Vector3),c=Math.max(s.x,s.y,s.z)||1;g(o,c,e,r)};return{getActiveCamera:d,getProjection:()=>l,setProjection:h,toggleProjection:()=>(h(l===`perspective`?`orthographic`:`perspective`),l),setView:(e,t=!0)=>{_(s[e],t)},setViewDirection:_,frameBounds:(e,t=!0)=>{if(e.isEmpty())return;let r=e.getCenter(new n.Vector3),a=e.getSize(new n.Vector3),o=Math.max(a.x,a.y,a.z)||1,c=d().position.clone().sub(i.target);c.lengthSq()<1e-12&&c.copy(s.iso),g(r,o,c.normalize(),t)},setRotateEnabled:e=>{i.enableRotate=e},isRotateEnabled:()=>i.enableRotate,updateAspect:(e,t)=>{u=t===0?u:e/t,l===`orthographic`&&m()},dispose:p}}function z(e,t){let{up:n,forward:r}=D(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 ne=e=>1-(1-e)**3;function re(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=ne(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 ie(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 B(e){let t=new s.LineSegmentsGeometry;return t.setPositions(e),{geometry:t,segmentCount:e.length/6,edgeSpacing:ie(e)}}function V(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 H(){return[`const extract = ${V.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
2
|
`)}const U=`edge-overlay`;function W(e){return{forcedColor:e.color==null?null:new n.Color(e.color),darken:n.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,maxOverlays:e.maxOverlays??1500}}function G(e){let t=e.getAttribute(`position`);return t?(e.index?e.index.count:t.count)/3:0}function K(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 ae(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 oe(e,t){let r=new n.EdgesGeometry(e,t),i=r.attributes.position?r.attributes.position.array:new Float32Array;return r.dispose(),i}function se(e,t){let n=K(e);return n?V(n.positions,n.index,t):oe(e,t)}let q;const J=new Map;let ce=1;function le(){if(q!==void 0)return q;if(typeof Worker>`u`||typeof Blob>`u`||typeof URL>`u`||typeof URL.createObjectURL!=`function`)return q=null,null;try{let e=URL.createObjectURL(new Blob([H()],{type:`text/javascript`})),t=new Worker(e);t.onmessage=e=>{let{id:t,segments:n,error:r}=e.data,i=J.get(t);i&&(J.delete(t),n?i.resolve(n):i.reject(Error(r??`edge extraction failed in worker`)))},t.onerror=()=>{for(let e of J.values())e.reject(Error(`edge extraction worker crashed`));J.clear(),t.terminate(),q=null},q=t}catch{q=null}return q}function ue(e,t,n){return new Promise((r,i)=>{let a=ce++;J.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 Y=new Map;function de(e,t){let n=K(e);if(!n||G(e)<25e3)return Promise.resolve(se(e,t));let r=ae(n,t),i=Y.get(r);if(i)return i;let a=le();if(!a)return Promise.resolve(se(e,t));let o=ue(a,n,t).catch(()=>V(n.positions,n.index,t)).finally(()=>{Y.delete(r)});return Y.set(r,o),o}function fe(e,t){let r=(Array.isArray(e.material)?e.material[0]:e.material)?.color;return r?r.clone().multiplyScalar(1-t):new n.Color(2236962)}var pe=class{options;byKey=new Map;constructor(e){this.options=e}for(e,t){let n=this.options.forcedColor??fe(e,this.options.darken),r=n.getHex()*2+ +!!t,i=this.byKey.get(r);return i||(i=me(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 me(e,t,n){let r=new a.LineMaterial({color:e});return r.linewidth=t,r.polygonOffset=!0,r.polygonOffsetFactor=0,r.polygonOffsetUnits=-1,n&&(r.transparent=!0),r}function he(e,t,n){let r=new o.LineSegments2(e.geometry,t);return r.userData.kind=U,r.raycast=()=>{},n&&ye(r,e.edgeSpacing),r}const ge=new n.Vector3,_e=new n.Vector3;function ve(e,t,r){e.geometry.boundingSphere||e.geometry.computeBoundingSphere();let i=e.geometry.boundingSphere;if(!i)return 1/0;if(t.isPerspectiveCamera){let a=t;ge.copy(i.center).applyMatrix4(e.matrixWorld);let o=_e.setFromMatrixPosition(t.matrixWorld).distanceTo(ge);if(o<=i.radius*e.matrixWorld.getMaxScaleOnAxis())return 1/0;let s=Math.tan(n.MathUtils.degToRad(a.fov)*.5),c=2*o*s;return c>0?r/c:1/0}if(t.isOrthographicCamera){let e=t,n=(e.top-e.bottom)/e.zoom;return n>0?r/n:1/0}return 1/0}function ye(e,t){e.onBeforeRender=(r,i,a)=>{o.LineSegments2.prototype.onBeforeRender.call(e,r);let s=e.material,c=t*ve(e,a,s.resolution.y);s.opacity=n.MathUtils.clamp((c-1)/3,0,1)}}function be(e){return e.userData?.kind===U}function xe(e,t){let r=[],i=0;e.traverse(e=>{if(e instanceof n.Mesh&&e.userData.id!==`floor`&&e.userData.id!==`grid`&&e.userData.kind!==`edge-overlay`){if(e.children.some(e=>e.userData?.kind===`edge-overlay`)){i++;return}if(e.geometry){if(G(e.geometry)>t.maxTriangles){e.userData.edgesSkipped=`triangle-cap`;return}r.push(e)}}});let a=Math.max(0,t.maxOverlays-i),o=r.slice(0,a);for(let e of o)delete e.userData.edgesSkipped;for(let e of r.slice(a))e.userData.edgesSkipped=`overlay-budget`;return r.length>a&&console.debug(`[edges] overlay budget reached: ${r.length} meshes want overlays, ${a} allowed — the rest fall back to the screen-space edge pass.`),o}function Se(e,t,n,r){let i=r.distanceFade&&t.segmentCount<=r.maxSegments,a=he(t,n.for(e,i),i);return e.add(a),a}const Ce=new WeakMap;function X(e){return Ce.get(e)??0}function we(e,t){for(let n=e;n;n=n.parent)if(n===t)return!0;return!1}async function Te(e,t={}){let n=W(t),r=new pe(n),i=X(e),a=[],o=xe(e,n).map(async t=>{let o=await de(t.geometry,n.thresholdAngle);X(e)===i&&we(t,e)&&(t.children.some(e=>e.userData?.kind===`edge-overlay`)||a.push(Se(t,B(o),r,n)))});return await Promise.all(o),r.disposeUnused(a),a}function Ee(e){Ce.set(e,X(e)+1);let t=[];e.traverse(e=>{e instanceof o.LineSegments2&&be(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 De(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 Oe(e={}){let{cellSize:t=1,majorEvery:r=10,cellColor:i=8947848,majorColor:a=4473924,fadeDistance:o=100,plane:s=`y`}=e,c=s===`y`?new n.Vector2(0,2):s===`z`?new n.Vector2(0,1):new n.Vector2(1,2),l=2.5,u=new n.PlaneGeometry(1,1);s===`y`?u.rotateX(-Math.PI/2):s===`x`&&u.rotateY(Math.PI/2);let d=new n.ShaderMaterial({vertexShader:`
|
|
3
3
|
varying vec3 vWorldPos;
|
|
4
4
|
void main() {
|
|
@@ -50,7 +50,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
50
50
|
if (alpha < 0.001) discard;
|
|
51
51
|
gl_FragColor = vec4(color, alpha);
|
|
52
52
|
}
|
|
53
|
-
`,transparent:!0,depthWrite:!1,side:n.DoubleSide,uniforms:{uAxes:{value:c},uCell:{value:t},uMajor:{value:r},uCellColor:{value:new n.Color(i)},uMajorColor:{value:new n.Color(a)},uCenter:{value:new n.Vector3},uFade:{value:o}}}),f=new n.Mesh(u,d);f.name=`grid`,f.userData.id=`grid`,f.renderOrder=-1;let p=o,m=o*l,h=new n.Vector3;return{object:f,update:e=>{s===`y`?(f.position.set(e.x,0,e.z),h.set(e.x,0,e.z)):s===`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 n.Vector3),r=(e,t)=>t===0?e.x:t===1?e.y:e.z,i=Math.max(r(t,c.x),r(t,c.y));!(i>0)||!Number.isFinite(i)||(d.uniforms.uCell.value=De(i/20),p=i*2,d.uniforms.uFade.value=p,m=p*l)},setVisible:e=>{f.visible=e},dispose:()=>{f.removeFromParent(),u.dispose(),d.dispose()}}}function ke(e,t){let r=new c.CSS2DRenderer,i=r.domElement;i.style.position=`absolute`,i.style.top=`0`,i.style.left=`0`,i.style.overflow=`hidden`,i.style.pointerEvents=`none`,i.style.zIndex=`30`,getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.appendChild(i);let a={width:e.clientWidth||1,height:e.clientHeight||1};r.setSize(a.width,a.height);let o=new n.Group;o.name=`label-layer`,o.userData.id=`label-layer`,t.add(o);let s=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 c.CSS2DObject(r);return i.position.copy(t),o.add(i),s.add(i),{object:i,setPosition:e=>i.position.copy(e),setText:e=>{r.textContent=e},remove:()=>{i.removeFromParent(),r.remove(),s.delete(i)}}},render:(e,t)=>r.render(e,t),setSize:(e,t)=>r.setSize(e,t),dispose:()=>{s.forEach(e=>{e.removeFromParent(),e.element.remove()}),s.clear(),o.removeFromParent(),i.remove()}}}const Ae=.015,je={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 Me(e){let t=e&&je[e]||je.Meters;return e=>`${(e/t.metersPerUnit).toPrecision(3)} ${t.suffix}`}function Ne(e,t){if(e.isOrthographicCamera){let t=e;return Math.abs(t.top-t.bottom)/(t.zoom||1)*Ae}return((t?e.position.distanceTo(t):e.position.length())||1)*Ae}function Pe(e){let t=e.object;if(t instanceof n.Mesh)return e.face?[e.face.a,e.face.b,e.face.c]:null;if(t instanceof n.Points)return e.index==null?null:[e.index];if(t instanceof n.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 Fe(e,t,r,i){let a=e.point.clone(),o=e.object,s=Pe(e);if(!s||!o.geometry)return a;let c=o.geometry.attributes.position;if(!c)return a;let l=e=>{let i=e.clone().project(t);return new n.Vector2((i.x+1)/2*r.width,(1-i.y)/2*r.height)},u=l(a),d=a,f=i;for(let e of s){if(e>=c.count)continue;let t=new n.Vector3().fromBufferAttribute(c,e).applyMatrix4(o.matrixWorld),r=l(t).distanceTo(u);r<f&&(f=r,d=t)}return d}function Ie(e){let{canvas:t,scene:o,getActiveCamera:s,getViewTarget:c,labelLayer:l,options:u={}}=e,d=u.snapPixels??12,f=new n.Color(u.color??16763904),p=Me(u.displayUnit),m=u.format??((e,t)=>`${p(e)}\nΔx ${p(t.x)} Δy ${p(t.y)} Δz ${p(t.z)}`),h=new n.Raycaster,g=new n.Vector2,_=!1,v=[],y=[],b=null,x=null,S=new n.PointsMaterial({color:f,size:8,sizeAttenuation:!1,depthTest:!1}),C=new n.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 n.BufferGeometry;e.setAttribute(`position`,new n.Float32BufferAttribute([0,0,0],3)),w=new n.Points(e,C),w.renderOrder=1e3,w.userData.id=`measure`,w.raycast=()=>{},o.add(w)}w.position.copy(e),w.visible=!0},E=e=>{let t=new n.BufferGeometry;t.setAttribute(`position`,new n.Float32BufferAttribute([e.x,e.y,e.z],3));let r=new n.Points(t,S);return r.renderOrder=999,r.userData.id=`measure`,r.raycast=()=>{},o.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,s=new i.LineGeometry;s.setPositions([e.x,e.y,e.z,t.x,t.y,t.z]);let c=new a.LineMaterial({color:f});c.linewidth=2,c.depthTest=!1,b=new r.Line2(s,c),b.renderOrder=998,b.userData.id=`measure`,b.raycast=()=>{},o.add(b);let d=e.clone().add(t).multiplyScalar(.5),p=new n.Vector3(Math.abs(t.x-e.x),Math.abs(t.y-e.y),Math.abs(t.z-e.z));x=l.addLabel(m(e.distanceTo(t),p),d,u.labelClassName)},k=e=>{let n=t.getBoundingClientRect();g.x=(e.clientX-n.left)/n.width*2-1,g.y=-((e.clientY-n.top)/n.height)*2+1;let r=s();h.setFromCamera(g,r);let i=Ne(r,c?.());h.params.Line.threshold=i,h.params.Points.threshold=i;let a=h.intersectObjects(o.children,!0).filter(e=>e.object.userData.id!==`measure`&&e.object.userData.id!==`grid`);return a.length===0?null:Fe(a[0],r,{width:n.width,height:n.height},d)},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 Le=[];function Re({camera:e,scene:t,groundNormals:r=()=>Le}){let i=e.near,a=e.near,o=new n.Vector3,s=new n.Vector3;return{update:()=>{e.near!==a&&(i=e.near);let c=I(t),l=i;if(!c.isEmpty()){let t=c.getSize(s).length()*.5,a=e.position.distanceTo(c.getCenter(o))-t;for(let t of r())a=Math.min(a,Math.abs(e.position.dot(t)));l=n.MathUtils.clamp(a*.5,i,e.far*.01)}Math.abs(l-a)>a*.05&&(e.near=l,e.updateProjectionMatrix(),a=l)}}}function ze(){let e=[],t=null,n=()=>e.sort((e,t)=>t.priority-e.priority),r=t=>e.findIndex(e=>e.id===t),i=n=>{let i=r(n);i!==-1&&(e.splice(i,1),t===n&&(t=null))};return{register:({id:t,tool:r,priority:a=0})=>(i(t),e.push({id:t,tool:r,priority:a}),n(),()=>i(t)),unregister:i,get:t=>e[r(t)]?.tool??null,setActive:n=>{t=n;for(let t of e)t.tool.setEnabled?.(t.id===n)},getActive:()=>t,handleClick:t=>{for(let n of[...e])if(n.tool.handleClick(t))return!0;return!1},handleMove:t=>{for(let n of[...e])n.tool.handleMove?.(t)}}}function Be(e,t){let n=t.getBoundingClientRect();return{x:(e.clientX-n.left)/n.width*2-1,y:-((e.clientY-n.top)/n.height)*2+1}}function Ve(e){let{camera:t,domElement:r,controller:i}=e,a=new l.ViewHelper(t,r);a.setLabels(`X`,`Y`,`Z`);let o=!0,s=new n.Raycaster,c=new n.OrthographicCamera(-2,2,2,-2,0,4);c.position.set(0,0,2),c.updateMatrixWorld();let u={posX:new n.Vector3(1,0,0),negX:new n.Vector3(-1,0,0),posY:new n.Vector3(0,1,0),negY:new n.Vector3(0,-1,0),posZ:new n.Vector3(0,0,1),negZ:new n.Vector3(0,0,-1)},d=e=>{let i=r.getBoundingClientRect(),o=i.left+r.offsetWidth-128-a.location.right,l=i.top+r.offsetHeight-128-a.location.bottom,d=new n.Vector2((e.clientX-o)/128*2-1,-((e.clientY-l)/128)*2+1);if(Math.abs(d.x)>1||Math.abs(d.y)>1)return null;a.quaternion.copy(t.quaternion).invert(),a.updateMatrixWorld(),s.setFromCamera(d,c);let f=s.intersectObjects(a.children,!1);for(let e of f){let t=e.object.userData?.type;if(typeof t==`string`&&t in u)return t}return null};return{render:e=>{if(!o)return;let t=e.autoClear;e.autoClear=!1,a.render(e),e.autoClear=t},handleClick:e=>{if(!o)return!1;let t=d(e);return t?(i.getProjection()===`orthographic`&&i.setProjection(`perspective`),i.setViewDirection(u[t],!1),!0):!1},setVisible:e=>{o=e},isVisible:()=>o,dispose:()=>a.dispose()}}function He(e,t,r,i,a,o,s,c,l,u,d,f,p,m,h=!0){let g=null,_=performance.now(),v=!0,y=0,b=new n.Matrix4,x=new n.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:n}=s();if(t===0||n===0)return;let i=Math.floor(t*c),o=Math.floor(n*c);(e.domElement.width!==i||e.domElement.height!==o)&&(e.setPixelRatio(c),e.setSize(t,n,!1),r.aspect=t/n,r.updateProjectionMatrix(),a.updateAspect(t,n),f?.()?.setSize(t,n,c),p?.setSize(t,n),C())},O=(n,r)=>{let i=f?.();i?(i.setCamera(n),i.render(r)):e.render(t,n),p&&p.render(t,n),d&&d.render(e)},k=()=>{O(i(),0)},A=function(){g=requestAnimationFrame(A);let e=performance.now(),t=(e-_)/1e3;_=e,D(),(o.enableDamping||o.autoRotate)&&o.update(),u&&u.update(i().position),m&&m.update(),l?.(t);let n=i();if(h){if(!(v||w(n)||e-y>=500))return;v=!1,y=e}O(n,t)};return{animate:A,dispose:()=>{if(g!==null&&(cancelAnimationFrame(g),g=null),h)for(let e of E)T.removeEventListener(e,C)},invalidate:C,renderNow:k}}const Z=new n.Vector3(0,0,1);function Ue(e){let t=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}}[t],i=e.look??`technical`,a=y[i];return{sceneScale:t,look:i,camera:{position:e.camera?.position||O(e.environment?.sceneUp??Z,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 n.Vector3(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??a.sunlightIntensity,sunlightPosition:e.lighting?.sunlightPosition||k(e.environment?.sceneUp??Z,r.lightDistance,r.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new n.Color(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??a.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??a.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??a.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath||`/baseHDR.hdr`,backgroundColor:e.environment?.backgroundColor||new n.Color(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||Z,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??a.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||r.floorSize,color:e.floor?.color||new n.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??a.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??a.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,ambientOcclusion:e.render?.ambientOcclusion??a.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??j(e.environment?.sceneUp??Z)},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,maxOverlays:e.edges?.maxOverlays,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}}const Q=`__selvaLookBaseline`;function We(e,t){e.color?.setHex(t.color),e.metalness!==void 0&&(e.metalness=t.metalness),e.roughness!==void 0&&(e.roughness=t.roughness),e.opacity=t.opacity,e.transparent=t.transparent,e.depthWrite=t.depthWrite,e.wireframe!==void 0&&(e.wireframe=t.wireframe)}function Ge(e){let t=e[Q];t&&(We(e,t),delete e[Q])}function Ke(e,t){let n=e;if(!t){Ge(n),n.needsUpdate=!0;return}n[Q]?We(n,n[Q]):n[Q]={color:n.color?.getHex()??16777215,metalness:n.metalness??0,roughness:n.roughness??1,opacity:n.opacity,transparent:n.transparent,depthWrite:n.depthWrite,wireframe:n.wireframe??!1},t.color!==void 0&&n.color?.setHex(t.color),t.metalness!==void 0&&n.metalness!==void 0&&(n.metalness=t.metalness),t.roughness!==void 0&&n.roughness!==void 0&&(n.roughness=t.roughness),t.opacity!==void 0&&(n.opacity=t.opacity,n.transparent=t.opacity<1),t.depthWrite!==void 0&&(n.depthWrite=t.depthWrite),t.wireframe!==void 0&&n.wireframe!==void 0&&(n.wireframe=t.wireframe),n.needsUpdate=!0}function qe(e){let{scene:t,renderer:r,lights:i,config:a,pipeline:o,requestRender:s}=e,c=a.look,l=e=>{e.ambientIntensity!==void 0&&(i.ambient.intensity=e.ambientIntensity),e.hemisphereIntensity!==void 0&&!i.hemisphere&&e.hemisphereIntensity>0&&(i.hemisphere=new n.HemisphereLight(e.hemisphereSkyColor??a.lighting.hemisphereSkyColor,e.hemisphereGroundColor??a.lighting.hemisphereGroundColor,e.hemisphereIntensity),i.hemisphere.position.copy(a.environment.sceneUp??Z),t.add(i.hemisphere)),i.hemisphere&&(e.hemisphereIntensity!==void 0&&(i.hemisphere.intensity=e.hemisphereIntensity),e.hemisphereSkyColor!==void 0&&i.hemisphere.color.set(e.hemisphereSkyColor),e.hemisphereGroundColor!==void 0&&i.hemisphere.groundColor.set(e.hemisphereGroundColor)),s()},u=e=>{a.environment.environmentIntensity=e,t.environmentIntensity=e,s()};return{setFillLights:l,setEnvironmentIntensity:u,setToneMappingExposure:e=>{a.render.toneMappingExposure=e,r.toneMappingExposure=e,o.get()&&o.rebuild()},setAoIntensity:e=>{a.render.aoIntensity=e,o.get()&&o.rebuild()},setLook:e=>{let n=y[e];c=e,r.toneMapping=n.toneMapping,r.toneMappingExposure=n.toneMappingExposure,a.render.toneMapping=n.toneMapping,a.render.toneMappingExposure=n.toneMappingExposure,l({hemisphereIntensity:n.hemisphereIntensity,ambientIntensity:n.ambientIntensity}),u(n.environmentIntensity),i.sun&&(i.sun.intensity=n.sunlightIntensity,a.lighting.sunlightIntensity=n.sunlightIntensity);let d=o.get()!==null;o.setAmbientOcclusion(n.ambientOcclusion),d&&o.rebuild(),t.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,r=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of r)`envMapIntensity`in e&&(e.envMapIntensity=n.envMapIntensity),Ke(e,n.materialOverride)}),s()},getMaterialAppearance:()=>b(c)}}function Je(e,t){let r=t.parentElement,i=r?r.clientWidth:window.innerWidth,a=r?r.clientHeight:window.innerHeight,o=new n.PerspectiveCamera(e.camera.fov,i/a,e.camera.near,e.camera.far),s=e.camera.position;return s&&o.position.set(s.x,s.y,s.z),o}function Ye(e){let t=new n.Scene;return t.background=(typeof e.environment.backgroundColor==`string`?new n.Color(e.environment.backgroundColor):e.environment.backgroundColor)||null,t}function Xe(e,r){t.t(e,r),e.environment?.dispose(),e.background instanceof n.Texture&&e.background.dispose()}const $={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new n.Vector2(1,1)},uColor:{value:new n.Color(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
|
|
53
|
+
`,transparent:!0,depthWrite:!1,side:n.DoubleSide,uniforms:{uAxes:{value:c},uCell:{value:t},uMajor:{value:r},uCellColor:{value:new n.Color(i)},uMajorColor:{value:new n.Color(a)},uCenter:{value:new n.Vector3},uFade:{value:o}}}),f=new n.Mesh(u,d);f.name=`grid`,f.userData.id=`grid`,f.renderOrder=-1;let p=o,m=o*l,h=new n.Vector3;return{object:f,update:e=>{s===`y`?(f.position.set(e.x,0,e.z),h.set(e.x,0,e.z)):s===`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 n.Vector3),r=(e,t)=>t===0?e.x:t===1?e.y:e.z,i=Math.max(r(t,c.x),r(t,c.y));i>0&&Number.isFinite(i)&&(d.uniforms.uCell.value=De(i/20),p=i*2,d.uniforms.uFade.value=p,m=p*l)},setVisible:e=>{f.visible=e},dispose:()=>{f.removeFromParent(),u.dispose(),d.dispose()}}}function ke(e,t){let r=new c.CSS2DRenderer,i=r.domElement;i.style.position=`absolute`,i.style.top=`0`,i.style.left=`0`,i.style.overflow=`hidden`,i.style.pointerEvents=`none`,i.style.zIndex=`30`,getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.appendChild(i);let a={width:e.clientWidth||1,height:e.clientHeight||1};r.setSize(a.width,a.height);let o=new n.Group;o.name=`label-layer`,o.userData.id=`label-layer`,t.add(o);let s=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 c.CSS2DObject(r);return i.position.copy(t),o.add(i),s.add(i),{object:i,setPosition:e=>i.position.copy(e),setText:e=>{r.textContent=e},remove:()=>{i.removeFromParent(),r.remove(),s.delete(i)}}},render:(e,t)=>r.render(e,t),setSize:(e,t)=>r.setSize(e,t),dispose:()=>{s.forEach(e=>{e.removeFromParent(),e.element.remove()}),s.clear(),o.removeFromParent(),i.remove()}}}const Ae=.015,je={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 Me(e){let t=e&&je[e]||je.Meters;return e=>`${(e/t.metersPerUnit).toPrecision(3)} ${t.suffix}`}function Ne(e,t){if(e.isOrthographicCamera){let t=e;return Math.abs(t.top-t.bottom)/(t.zoom||1)*Ae}return((t?e.position.distanceTo(t):e.position.length())||1)*Ae}function Pe(e){let t=e.object;if(t instanceof n.Mesh)return e.face?[e.face.a,e.face.b,e.face.c]:null;if(t instanceof n.Points)return e.index==null?null:[e.index];if(t instanceof n.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 Fe(e,t,r,i){let a=e.point.clone(),o=e.object,s=Pe(e);if(!s||!o.geometry)return a;let c=o.geometry.attributes.position;if(!c)return a;let l=e=>{let i=e.clone().project(t);return new n.Vector2((i.x+1)/2*r.width,(1-i.y)/2*r.height)},u=l(a),d=a,f=i;for(let e of s){if(e>=c.count)continue;let t=new n.Vector3().fromBufferAttribute(c,e).applyMatrix4(o.matrixWorld),r=l(t).distanceTo(u);r<f&&(f=r,d=t)}return d}function Ie(e){let{canvas:t,scene:o,getActiveCamera:s,getViewTarget:c,labelLayer:l,options:u={}}=e,d=u.snapPixels??12,f=new n.Color(u.color??16763904),p=Me(u.displayUnit),m=u.format??((e,t)=>`${p(e)}\nΔx ${p(t.x)} Δy ${p(t.y)} Δz ${p(t.z)}`),h=new n.Raycaster,g=new n.Vector2,_=!1,v=[],y=[],b=null,x=null,S=new n.PointsMaterial({color:f,size:8,sizeAttenuation:!1,depthTest:!1}),C=new n.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 n.BufferGeometry;e.setAttribute(`position`,new n.Float32BufferAttribute([0,0,0],3)),w=new n.Points(e,C),w.renderOrder=1e3,w.userData.id=`measure`,w.raycast=()=>{},o.add(w)}w.position.copy(e),w.visible=!0},E=e=>{let t=new n.BufferGeometry;t.setAttribute(`position`,new n.Float32BufferAttribute([e.x,e.y,e.z],3));let r=new n.Points(t,S);return r.renderOrder=999,r.userData.id=`measure`,r.raycast=()=>{},o.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,s=new i.LineGeometry;s.setPositions([e.x,e.y,e.z,t.x,t.y,t.z]);let c=new a.LineMaterial({color:f});c.linewidth=2,c.depthTest=!1,b=new r.Line2(s,c),b.renderOrder=998,b.userData.id=`measure`,b.raycast=()=>{},o.add(b);let d=e.clone().add(t).multiplyScalar(.5),p=new n.Vector3(Math.abs(t.x-e.x),Math.abs(t.y-e.y),Math.abs(t.z-e.z));x=l.addLabel(m(e.distanceTo(t),p),d,u.labelClassName)},k=e=>{let n=t.getBoundingClientRect();g.x=(e.clientX-n.left)/n.width*2-1,g.y=-((e.clientY-n.top)/n.height)*2+1;let r=s();h.setFromCamera(g,r);let i=Ne(r,c?.());h.params.Line.threshold=i,h.params.Points.threshold=i;let a=h.intersectObjects(o.children,!0).filter(e=>e.object.userData.id!==`measure`&&e.object.userData.id!==`grid`);return a.length===0?null:Fe(a[0],r,{width:n.width,height:n.height},d)},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 Le=[];function Re({camera:e,scene:t,groundNormals:r=()=>Le}){let i=e.near,a=e.near,o=new n.Vector3,s=new n.Vector3;return{update:()=>{e.near!==a&&(i=e.near);let c=I(t),l=i;if(!c.isEmpty()){let t=c.getSize(s).length()*.5,a=e.position.distanceTo(c.getCenter(o))-t;for(let t of r())a=Math.min(a,Math.abs(e.position.dot(t)));l=n.MathUtils.clamp(a*.5,i,e.far*.01)}Math.abs(l-a)>a*.05&&(e.near=l,e.updateProjectionMatrix(),a=l)}}}function ze(){let e=[],t=null,n=()=>e.sort((e,t)=>t.priority-e.priority),r=t=>e.findIndex(e=>e.id===t),i=n=>{let i=r(n);i!==-1&&(e.splice(i,1),t===n&&(t=null))};return{register:({id:t,tool:r,priority:a=0})=>(i(t),e.push({id:t,tool:r,priority:a}),n(),()=>i(t)),unregister:i,get:t=>e[r(t)]?.tool??null,setActive:n=>{t=n;for(let t of e)t.tool.setEnabled?.(t.id===n)},getActive:()=>t,handleClick:t=>{for(let n of[...e])if(n.tool.handleClick(t))return!0;return!1},handleMove:t=>{for(let n of[...e])n.tool.handleMove?.(t)}}}function Be(e,t){let n=t.getBoundingClientRect();return{x:(e.clientX-n.left)/n.width*2-1,y:-((e.clientY-n.top)/n.height)*2+1}}function Ve(e){let{camera:t,domElement:r,controller:i}=e,a=new l.ViewHelper(t,r);a.setLabels(`X`,`Y`,`Z`);let o=!0,s=new n.Raycaster,c=new n.OrthographicCamera(-2,2,2,-2,0,4);c.position.set(0,0,2),c.updateMatrixWorld();let u={posX:new n.Vector3(1,0,0),negX:new n.Vector3(-1,0,0),posY:new n.Vector3(0,1,0),negY:new n.Vector3(0,-1,0),posZ:new n.Vector3(0,0,1),negZ:new n.Vector3(0,0,-1)},d=e=>{let i=r.getBoundingClientRect(),o=i.left+r.offsetWidth-128-a.location.right,l=i.top+r.offsetHeight-128-a.location.bottom,d=new n.Vector2((e.clientX-o)/128*2-1,-((e.clientY-l)/128)*2+1);if(Math.abs(d.x)>1||Math.abs(d.y)>1)return null;a.quaternion.copy(t.quaternion).invert(),a.updateMatrixWorld(),s.setFromCamera(d,c);let f=s.intersectObjects(a.children,!1);for(let e of f){let t=e.object.userData?.type;if(typeof t==`string`&&t in u)return t}return null};return{render:e=>{if(!o)return;let t=e.autoClear;e.autoClear=!1,a.render(e),e.autoClear=t},handleClick:e=>{if(!o)return!1;let t=d(e);return t?(i.getProjection()===`orthographic`&&i.setProjection(`perspective`),i.setViewDirection(u[t],!1),!0):!1},setVisible:e=>{o=e},isVisible:()=>o,dispose:()=>a.dispose()}}function He(e,t,r,i,a,o,s,c,l,u,d,f,p,m,h=!0){let g=null,_=performance.now(),v=!0,y=0,b=new n.Matrix4,x=new n.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:n}=s();if(t===0||n===0)return;let i=Math.floor(t*c),o=Math.floor(n*c);(e.domElement.width!==i||e.domElement.height!==o)&&(e.setPixelRatio(c),e.setSize(t,n,!1),r.aspect=t/n,r.updateProjectionMatrix(),a.updateAspect(t,n),f?.()?.setSize(t,n,c),p?.setSize(t,n),C())},O=(n,r)=>{let i=f?.();i?(i.setCamera(n),i.render(r)):e.render(t,n),p&&p.render(t,n),d&&d.render(e)},k=()=>{O(i(),0)},A=function(){g=requestAnimationFrame(A);let e=performance.now(),t=(e-_)/1e3;_=e,D(),(o.enableDamping||o.autoRotate)&&o.update(),u&&u.update(i().position),m&&m.update(),l?.(t);let n=i();if(h){if(!(v||w(n)||e-y>=500))return;v=!1,y=e}O(n,t)};return{animate:A,dispose:()=>{if(g!==null&&(cancelAnimationFrame(g),g=null),h)for(let e of E)T.removeEventListener(e,C)},invalidate:C,renderNow:k}}const Z=new n.Vector3(0,0,1);function Ue(e){let t=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}}[t],i=e.look??`technical`,a=y[i];return{sceneScale:t,look:i,camera:{position:e.camera?.position||O(e.environment?.sceneUp??Z,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 n.Vector3(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??a.sunlightIntensity,sunlightPosition:e.lighting?.sunlightPosition||k(e.environment?.sceneUp??Z,r.lightDistance,r.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new n.Color(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??a.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??a.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??a.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath||`/baseHDR.hdr`,backgroundColor:e.environment?.backgroundColor||new n.Color(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||Z,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??a.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||r.floorSize,color:e.floor?.color||new n.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??a.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??a.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,ambientOcclusion:e.render?.ambientOcclusion??a.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??j(e.environment?.sceneUp??Z)},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,maxOverlays:e.edges?.maxOverlays,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}}const Q=`__selvaLookBaseline`;function We(e,t){e.color?.setHex(t.color),e.metalness!==void 0&&(e.metalness=t.metalness),e.roughness!==void 0&&(e.roughness=t.roughness),e.opacity=t.opacity,e.transparent=t.transparent,e.depthWrite=t.depthWrite,e.wireframe!==void 0&&(e.wireframe=t.wireframe)}function Ge(e){let t=e[Q];t&&(We(e,t),delete e[Q])}function Ke(e,t){let n=e;if(!t){Ge(n),n.needsUpdate=!0;return}n[Q]?We(n,n[Q]):n[Q]={color:n.color?.getHex()??16777215,metalness:n.metalness??0,roughness:n.roughness??1,opacity:n.opacity,transparent:n.transparent,depthWrite:n.depthWrite,wireframe:n.wireframe??!1},t.color!==void 0&&n.color?.setHex(t.color),t.metalness!==void 0&&n.metalness!==void 0&&(n.metalness=t.metalness),t.roughness!==void 0&&n.roughness!==void 0&&(n.roughness=t.roughness),t.opacity!==void 0&&(n.opacity=t.opacity,n.transparent=t.opacity<1),t.depthWrite!==void 0&&(n.depthWrite=t.depthWrite),t.wireframe!==void 0&&n.wireframe!==void 0&&(n.wireframe=t.wireframe),n.needsUpdate=!0}function qe(e){let{scene:t,renderer:r,lights:i,config:a,pipeline:o,requestRender:s}=e,c=a.look,l=e=>{e.ambientIntensity!==void 0&&(i.ambient.intensity=e.ambientIntensity),e.hemisphereIntensity!==void 0&&!i.hemisphere&&e.hemisphereIntensity>0&&(i.hemisphere=new n.HemisphereLight(e.hemisphereSkyColor??a.lighting.hemisphereSkyColor,e.hemisphereGroundColor??a.lighting.hemisphereGroundColor,e.hemisphereIntensity),i.hemisphere.position.copy(a.environment.sceneUp??Z),t.add(i.hemisphere)),i.hemisphere&&(e.hemisphereIntensity!==void 0&&(i.hemisphere.intensity=e.hemisphereIntensity),e.hemisphereSkyColor!==void 0&&i.hemisphere.color.set(e.hemisphereSkyColor),e.hemisphereGroundColor!==void 0&&i.hemisphere.groundColor.set(e.hemisphereGroundColor)),s()},u=e=>{a.environment.environmentIntensity=e,t.environmentIntensity=e,s()};return{setFillLights:l,setEnvironmentIntensity:u,setToneMappingExposure:e=>{a.render.toneMappingExposure=e,r.toneMappingExposure=e,o.get()&&o.rebuild()},setAoIntensity:e=>{a.render.aoIntensity=e,o.get()&&o.rebuild()},setLook:e=>{let n=y[e];c=e,r.toneMapping=n.toneMapping,r.toneMappingExposure=n.toneMappingExposure,a.render.toneMapping=n.toneMapping,a.render.toneMappingExposure=n.toneMappingExposure,l({hemisphereIntensity:n.hemisphereIntensity,ambientIntensity:n.ambientIntensity}),u(n.environmentIntensity),i.sun&&(i.sun.intensity=n.sunlightIntensity,a.lighting.sunlightIntensity=n.sunlightIntensity);let d=o.get()!==null;o.setAmbientOcclusion(n.ambientOcclusion),d&&o.rebuild(),t.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,r=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of r)`envMapIntensity`in e&&(e.envMapIntensity=n.envMapIntensity),Ke(e,n.materialOverride)}),s()},getMaterialAppearance:()=>b(c)}}function Je(e,t){let r=t.parentElement,i=r?r.clientWidth:window.innerWidth,a=r?r.clientHeight:window.innerHeight,o=new n.PerspectiveCamera(e.camera.fov,i/a,e.camera.near,e.camera.far),s=e.camera.position;return s&&o.position.set(s.x,s.y,s.z),o}function Ye(e){let t=new n.Scene;return t.background=(typeof e.environment.backgroundColor==`string`?new n.Color(e.environment.backgroundColor):e.environment.backgroundColor)||null,t}function Xe(e,r){t.t(e,r),e.environment?.dispose(),e.background instanceof n.Texture&&e.background.dispose()}const $={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new n.Vector2(1,1)},uColor:{value:new n.Color(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
|
|
54
54
|
varying vec2 vUv;
|
|
55
55
|
void main() {
|
|
56
56
|
vUv = uv;
|