@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.
- package/README.md +11 -10
- package/dist/gpu-dispose-Dkj-BKt4.js +2 -0
- package/dist/gpu-dispose-Dkj-BKt4.js.map +1 -0
- package/dist/gpu-dispose-DrN-ryj5.cjs +2 -0
- package/dist/gpu-dispose-DrN-ryj5.cjs.map +1 -0
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/parse.cjs +3 -3
- package/dist/parse.cjs.map +1 -1
- package/dist/parse.d.cts +135 -142
- package/dist/parse.d.ts +135 -142
- package/dist/parse.js +3 -3
- package/dist/parse.js.map +1 -1
- package/dist/render.cjs +8 -10
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +335 -333
- package/dist/render.d.ts +335 -333
- package/dist/render.js +8 -10
- package/dist/render.js.map +1 -1
- package/dist/rolldown-runtime-BocRIvOZ.cjs +1 -0
- package/dist/scene.cjs +1 -1
- package/dist/scene.cjs.map +1 -1
- package/dist/scene.d.cts +95 -95
- package/dist/scene.d.ts +95 -95
- package/dist/scene.js +1 -1
- package/dist/scene.js.map +1 -1
- package/dist/types-Di80Y609.d.cts +34 -0
- package/dist/types-Di80Y609.d.ts +34 -0
- package/package.json +14 -10
- package/dist/chunk-5XGN7UAV.js +0 -2
- package/dist/chunk-5XGN7UAV.js.map +0 -1
- package/dist/chunk-AQJPVUH3.cjs +0 -2
- package/dist/chunk-AQJPVUH3.cjs.map +0 -1
- package/dist/chunk-BYLIBOAU.cjs +0 -2
- package/dist/chunk-BYLIBOAU.cjs.map +0 -1
- package/dist/chunk-EXAI6IC5.js +0 -2
- package/dist/chunk-EXAI6IC5.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types-CdF9R3qA.d.cts +0 -41
- package/dist/types-CdF9R3qA.d.ts +0 -41
package/dist/render.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
`)}
|
|
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`],y={studio:{toneMapping:n.ACESFilmicToneMapping,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.75,ambientIntensity:.4,cullBackfaces:!1,ambientOcclusion:!1},technical:{toneMapping:n.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:.9,environmentIntensity:1,hemisphereIntensity:.35,ambientIntensity:.25,cullBackfaces:!1,ambientOcclusion:!1},showcase:{toneMapping:n.ACESFilmicToneMapping,toneMappingExposure:1.15,envMapIntensity:1.4,environmentIntensity:1.25,hemisphereIntensity:.35,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!1}};function b(e){let t=y[e];return{envMapIntensity:t.envMapIntensity,cullBackfaces:t.cullBackfaces}}function x(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 S(e,t){let{forward:n,right:r,up:i}=x(e);return n.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(t)}function C(e,t,n){let{forward:r,right:i,up:a}=x(e);return i.clone().multiplyScalar(t).add(r.clone().multiplyScalar(t)).add(a.clone().multiplyScalar(n))}function w(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 T(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 E={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 D(e,r,i,a,o){if(M(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)>E.SCALE_RATIO_THRESHOLD||u>E.HUGE_THRESHOLD?(i.near=u*E.NEAR_PLANE_FACTOR.TINY,i.far=u*E.FAR_PLANE_FACTOR.HUGE):u>E.LARGE_THRESHOLD?(i.near=u*E.NEAR_PLANE_FACTOR.SMALL,i.far=u*E.FAR_PLANE_FACTOR.LARGE):(i.near=Math.max(.01,u*E.NEAR_PLANE_FACTOR.NORMAL),i.far=Math.max(2e3,u*E.FAR_PLANE_FACTOR.NORMAL)),i.updateProjectionMatrix(),!o){let e=u*E.INITIAL_DISTANCE_MULTIPLIER;i.position.copy(c).add(S(i.up,e)),a.target.copy(c),a.update()}}const O=new Set([`grid`,`floor`,`label-layer`,`measure`]);function k(e){let t=e;for(;t;){if(typeof t.userData.id==`string`&&O.has(t.userData.id))return!0;t=t.parent}return!1}function A(e){e.updateMatrixWorld(!0);let t=new n.Box3;return e.traverse(e=>{let n=e;e.visible&&!k(e)&&n.geometry&&t.expandByObject(e)}),t}const j=new Set([`floor`,`grid`,`label-layer`]);function M(e){[...e.children].forEach(e=>{j.has(e.userData.id)||e.userData.source!==`user`&&(t.t(e),e.removeFromParent())})}function N(e){let{up:t,forward:n,right:r}=x(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 ee(e){let{scene:t,perspective:r,controls:i,onActiveCameraChange:a}=e,o=(e.up??r.up).clone().normalize(),s=N(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=P(n,o),g=e.clone().add(h.clone().multiplyScalar(u)),_=d();l===`orthographic`&&(c.zoom=1),p(),a?f=I(_,i,g,e,()=>{l===`orthographic`&&m()}):(_.position.copy(g),i.target.copy(e),l===`orthographic`&&m(),i.update())},_=(e,r=!0)=>{let a=A(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 P(e,t){let{up:n,forward:r}=x(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 F=e=>1-(1-e)**3;function I(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=F(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 L(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 R(e){let t=new s.LineSegmentsGeometry;return t.setPositions(e),{geometry:t,segmentCount:e.length/6,edgeSpacing:L(e)}}function z(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 B(){return[`const extract = ${z.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 V=`edge-overlay`;function H(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}}function U(e){let t=e.getAttribute(`position`);return t?(e.index?e.index.count:t.count)/3:0}function W(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 G(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 K(e,t){let r=new n.EdgesGeometry(e,t),i=r.attributes.position?r.attributes.position.array:new Float32Array;return r.dispose(),i}function q(e,t){let n=W(e);return n?z(n.positions,n.index,t):K(e,t)}let J;const Y=new Map;let te=1;function ne(){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([B()],{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 re(e,t,n){return new Promise((r,i)=>{let a=te++;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 ie(e,t){let n=W(e);if(!n||U(e)<25e3)return Promise.resolve(q(e,t));let r=G(n,t),i=X.get(r);if(i)return i;let a=ne();if(!a)return Promise.resolve(q(e,t));let o=re(a,n,t).catch(()=>z(n.positions,n.index,t)).finally(()=>{X.delete(r)});return X.set(r,o),o}function ae(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 oe=class{options;byKey=new Map;constructor(e){this.options=e}for(e,t){let n=this.options.forcedColor??ae(e,this.options.darken),r=n.getHex()*2+ +!!t,i=this.byKey.get(r);return i||(i=se(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 se(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 ce(e,t,n){let r=new o.LineSegments2(e.geometry,t);return r.userData.kind=V,r.raycast=()=>{},n&&fe(r,e.edgeSpacing),r}const le=new n.Vector3,ue=new n.Vector3;function de(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;le.copy(i.center).applyMatrix4(e.matrixWorld);let o=ue.setFromMatrixPosition(t.matrixWorld).distanceTo(le);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 fe(e,t){e.onBeforeRender=(r,i,a)=>{o.LineSegments2.prototype.onBeforeRender.call(e,r);let s=e.material,c=t*de(e,a,s.resolution.y);s.opacity=n.MathUtils.clamp((c-1)/3,0,1)}}function pe(e){return e.userData?.kind===V}function me(e,t){let r=[];return e.traverse(e=>{if(e instanceof n.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(U(e.geometry)>t){e.userData.edgesSkipped=`triangle-cap`,console.debug(`[edges] skipping mesh over triangle cap (${U(e.geometry)} > ${t})`);return}delete e.userData.edgesSkipped,r.push(e)}}),r}function he(e,t,n,r){let i=r.distanceFade&&t.segmentCount<=r.maxSegments,a=ce(t,n.for(e,i),i);return e.add(a),a}const ge=new WeakMap;function Z(e){return ge.get(e)??0}function _e(e,t){for(let n=e;n;n=n.parent)if(n===t)return!0;return!1}async function ve(e,t={}){let n=H(t),r=new oe(n),i=Z(e),a=[],o=me(e,n.maxTriangles).map(async t=>{let o=await ie(t.geometry,n.thresholdAngle);Z(e)===i&&_e(t,e)&&(t.children.some(e=>e.userData?.kind===`edge-overlay`)||a.push(he(t,R(o),r,n)))});return await Promise.all(o),r.disposeUnused(a),a}function ye(e){ge.set(e,Z(e)+1);let t=[];e.traverse(e=>{e instanceof o.LineSegments2&&pe(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 be(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 xe(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() {
|
|
5
5
|
vec4 world = modelMatrix * vec4(position, 1.0);
|
|
6
6
|
vWorldPos = world.xyz;
|
|
7
7
|
gl_Position = projectionMatrix * viewMatrix * world;
|
|
8
8
|
}
|
|
9
|
-
`,
|
|
9
|
+
`,fragmentShader:`
|
|
10
10
|
precision highp float;
|
|
11
11
|
varying vec3 vWorldPos;
|
|
12
12
|
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
uniform vec3 uCenter; // fade center (camera position projected onto the plane)
|
|
19
19
|
uniform float uFade;
|
|
20
20
|
|
|
21
|
-
//
|
|
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 @@
|
|
|
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()}}}var _CSS2DRendererjs = require('three/addons/renderers/CSS2DRenderer.js');function Rt(e,n){let t=new _CSS2DRendererjs.CSS2DRenderer,r=t.domElement;r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.overflow="hidden",r.style.pointerEvents="none",r.style.zIndex="30",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(r);let i={width:e.clientWidth||1,height:e.clientHeight||1};t.setSize(i.width,i.height);let o=new 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 (0, _CSS2DRendererjs.CSS2DObject)(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()}}}var _Line2js = require('three/addons/lines/Line2.js');var _LineGeometryjs = require('three/addons/lines/LineGeometry.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=_nullishCoalesce(a.snapPixels, () => (Nr)),l=new D.Color(_nullishCoalesce(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=_nullishCoalesce(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),_optionalChain([A, 'optionalAccess', _11 => _11.remove, 'call', _12 => _12()]),A=null},x=()=>{if(h.length!==2)return;let[v,y]=h,z=new _LineGeometryjs.LineGeometry;z.setPositions([v.x,v.y,v.z,y.x,y.y,y.z]);let j=new (0, _LineMaterialjs.LineMaterial)({color:l});j.linewidth=2,j.depthTest=!1,b=new (0, _Line2js.Line2)(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,_optionalChain([i, 'optionalCall', _13 => _13()]));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()}}}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)}}}var _ViewHelperjs = require('three/addons/helpers/ViewHelper.js');function xt(e){let{camera:n,domElement:t,controller:r}=e,i=new (0, _ViewHelperjs.ViewHelper)(n,t);i.setLabels("X","Y","Z");let o=!0,a=128,s=new 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=_optionalChain([A, 'access', _14 => _14.object, 'access', _15 => _15.userData, 'optionalAccess', _16 => _16.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()}}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),_optionalChain([E, 'optionalCall', _17 => _17(), 'optionalAccess', _18 => _18.setSize, 'call', _19 => _19(w,k,s)]),_optionalChain([g, 'optionalAccess', _20 => _20.setSize, 'call', _21 => _21(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(),_optionalChain([l, 'optionalCall', _22 => _22(k)]);let v=r();if(p){if(!(b||T(v)||w-A>=S))return;b=!1,A=w}let y=_optionalChain([E, 'optionalCall', _23 => _23()]);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}}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=_nullishCoalesce(e.look, () => (_chunkAQJPVUH3cjs.h)),o=_chunkAQJPVUH3cjs.i[i];return{sceneScale:n,look:i,camera:{position:_optionalChain([e, 'access', _24 => _24.camera, 'optionalAccess', _25 => _25.position])||ye(_nullishCoalesce(_optionalChain([e, 'access', _26 => _26.environment, 'optionalAccess', _27 => _27.sceneUp]), () => (W)),r.cameraDistance*Math.sqrt(3)),fov:_optionalChain([e, 'access', _28 => _28.camera, 'optionalAccess', _29 => _29.fov])||20,near:_optionalChain([e, 'access', _30 => _30.camera, 'optionalAccess', _31 => _31.near])||r.near,far:_optionalChain([e, 'access', _32 => _32.camera, 'optionalAccess', _33 => _33.far])||r.far,target:_optionalChain([e, 'access', _34 => _34.camera, 'optionalAccess', _35 => _35.target])||new de.Vector3(0,0,0),dynamicNear:_nullishCoalesce(_optionalChain([e, 'access', _36 => _36.camera, 'optionalAccess', _37 => _37.dynamicNear]), () => (!0))},lighting:{enableSunlight:_nullishCoalesce(_optionalChain([e, 'access', _38 => _38.lighting, 'optionalAccess', _39 => _39.enableSunlight]), () => (!0)),sunlightIntensity:_nullishCoalesce(_optionalChain([e, 'access', _40 => _40.lighting, 'optionalAccess', _41 => _41.sunlightIntensity]), () => (1)),sunlightPosition:_optionalChain([e, 'access', _42 => _42.lighting, 'optionalAccess', _43 => _43.sunlightPosition])||qe(_nullishCoalesce(_optionalChain([e, 'access', _44 => _44.environment, 'optionalAccess', _45 => _45.sceneUp]), () => (W)),r.lightDistance,r.lightHeight),ambientLightColor:_optionalChain([e, 'access', _46 => _46.lighting, 'optionalAccess', _47 => _47.ambientLightColor])||new de.Color(4210752),ambientLightIntensity:_nullishCoalesce(_optionalChain([e, 'access', _48 => _48.lighting, 'optionalAccess', _49 => _49.ambientLightIntensity]), () => (o.ambientIntensity)),sunlightColor:_optionalChain([e, 'access', _50 => _50.lighting, 'optionalAccess', _51 => _51.sunlightColor])||16777215,enableHemisphereLight:_nullishCoalesce(_optionalChain([e, 'access', _52 => _52.lighting, 'optionalAccess', _53 => _53.enableHemisphereLight]), () => (o.hemisphereIntensity>0)),hemisphereSkyColor:_nullishCoalesce(_optionalChain([e, 'access', _54 => _54.lighting, 'optionalAccess', _55 => _55.hemisphereSkyColor]), () => (14673663)),hemisphereGroundColor:_nullishCoalesce(_optionalChain([e, 'access', _56 => _56.lighting, 'optionalAccess', _57 => _57.hemisphereGroundColor]), () => (7036754)),hemisphereIntensity:_nullishCoalesce(_optionalChain([e, 'access', _58 => _58.lighting, 'optionalAccess', _59 => _59.hemisphereIntensity]), () => (o.hemisphereIntensity))},environment:{hdrPath:_optionalChain([e, 'access', _60 => _60.environment, 'optionalAccess', _61 => _61.hdrPath])||"/baseHDR.hdr",backgroundColor:_optionalChain([e, 'access', _62 => _62.environment, 'optionalAccess', _63 => _63.backgroundColor])||new de.Color(15790320),enableEnvironmentLighting:_nullishCoalesce(_optionalChain([e, 'access', _64 => _64.environment, 'optionalAccess', _65 => _65.enableEnvironmentLighting]), () => (!0)),sceneUp:_optionalChain([e, 'access', _66 => _66.environment, 'optionalAccess', _67 => _67.sceneUp])||W,showEnvironment:_nullishCoalesce(_optionalChain([e, 'access', _68 => _68.environment, 'optionalAccess', _69 => _69.showEnvironment]), () => (!1)),environmentIntensity:_nullishCoalesce(_optionalChain([e, 'access', _70 => _70.environment, 'optionalAccess', _71 => _71.environmentIntensity]), () => (o.environmentIntensity))},floor:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _72 => _72.floor, 'optionalAccess', _73 => _73.enabled]), () => (!1)),size:_optionalChain([e, 'access', _74 => _74.floor, 'optionalAccess', _75 => _75.size])||r.floorSize,color:_optionalChain([e, 'access', _76 => _76.floor, 'optionalAccess', _77 => _77.color])||new de.Color(8421504),roughness:_nullishCoalesce(_optionalChain([e, 'access', _78 => _78.floor, 'optionalAccess', _79 => _79.roughness]), () => (.7)),metalness:_nullishCoalesce(_optionalChain([e, 'access', _80 => _80.floor, 'optionalAccess', _81 => _81.metalness]), () => (0)),receiveShadow:_nullishCoalesce(_optionalChain([e, 'access', _82 => _82.floor, 'optionalAccess', _83 => _83.receiveShadow]), () => (!0))},render:{enableShadows:_nullishCoalesce(_optionalChain([e, 'access', _84 => _84.render, 'optionalAccess', _85 => _85.enableShadows]), () => (!0)),shadowMapSize:_optionalChain([e, 'access', _86 => _86.render, 'optionalAccess', _87 => _87.shadowMapSize])||2048,antialias:_nullishCoalesce(_optionalChain([e, 'access', _88 => _88.render, 'optionalAccess', _89 => _89.antialias]), () => (!0)),pixelRatio:_optionalChain([e, 'access', _90 => _90.render, 'optionalAccess', _91 => _91.pixelRatio])||Math.min(window.devicePixelRatio,2),toneMapping:_nullishCoalesce(_optionalChain([e, 'access', _92 => _92.render, 'optionalAccess', _93 => _93.toneMapping]), () => (o.toneMapping)),toneMappingExposure:_nullishCoalesce(_optionalChain([e, 'access', _94 => _94.render, 'optionalAccess', _95 => _95.toneMappingExposure]), () => (o.toneMappingExposure)),preserveDrawingBuffer:_nullishCoalesce(_optionalChain([e, 'access', _96 => _96.render, 'optionalAccess', _97 => _97.preserveDrawingBuffer]), () => (!1)),ambientOcclusion:_nullishCoalesce(_optionalChain([e, 'access', _98 => _98.render, 'optionalAccess', _99 => _99.ambientOcclusion]), () => (o.ambientOcclusion)),aoIntensity:_nullishCoalesce(_optionalChain([e, 'access', _100 => _100.render, 'optionalAccess', _101 => _101.aoIntensity]), () => (1)),aoPixelRatio:_nullishCoalesce(_optionalChain([e, 'access', _102 => _102.render, 'optionalAccess', _103 => _103.aoPixelRatio]), () => (1)),onDemand:_nullishCoalesce(_optionalChain([e, 'access', _104 => _104.render, 'optionalAccess', _105 => _105.onDemand]), () => (!0))},controls:{enableDamping:_nullishCoalesce(_optionalChain([e, 'access', _106 => _106.controls, 'optionalAccess', _107 => _107.enableDamping]), () => (!1)),dampingFactor:_optionalChain([e, 'access', _108 => _108.controls, 'optionalAccess', _109 => _109.dampingFactor])||.05,autoRotate:_nullishCoalesce(_optionalChain([e, 'access', _110 => _110.controls, 'optionalAccess', _111 => _111.autoRotate]), () => (!1)),autoRotateSpeed:_optionalChain([e, 'access', _112 => _112.controls, 'optionalAccess', _113 => _113.autoRotateSpeed])||.5,enableZoom:_nullishCoalesce(_optionalChain([e, 'access', _114 => _114.controls, 'optionalAccess', _115 => _115.enableZoom]), () => (!0)),enablePan:_nullishCoalesce(_optionalChain([e, 'access', _116 => _116.controls, 'optionalAccess', _117 => _117.enablePan]), () => (!0)),minDistance:_optionalChain([e, 'access', _118 => _118.controls, 'optionalAccess', _119 => _119.minDistance])||r.minDistance,maxDistance:_optionalChain([e, 'access', _120 => _120.controls, 'optionalAccess', _121 => _121.maxDistance])||1/0},grid:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _122 => _122.grid, 'optionalAccess', _123 => _123.enabled]), () => (!1)),cellSize:_nullishCoalesce(_optionalChain([e, 'access', _124 => _124.grid, 'optionalAccess', _125 => _125.cellSize]), () => (1)),majorEvery:_nullishCoalesce(_optionalChain([e, 'access', _126 => _126.grid, 'optionalAccess', _127 => _127.majorEvery]), () => (10)),cellColor:_nullishCoalesce(_optionalChain([e, 'access', _128 => _128.grid, 'optionalAccess', _129 => _129.cellColor]), () => (8947848)),majorColor:_nullishCoalesce(_optionalChain([e, 'access', _130 => _130.grid, 'optionalAccess', _131 => _131.majorColor]), () => (4473924)),fadeDistance:_nullishCoalesce(_optionalChain([e, 'access', _132 => _132.grid, 'optionalAccess', _133 => _133.fadeDistance]), () => (100)),plane:_nullishCoalesce(_optionalChain([e, 'access', _134 => _134.grid, 'optionalAccess', _135 => _135.plane]), () => (xe(_nullishCoalesce(_optionalChain([e, 'access', _136 => _136.environment, 'optionalAccess', _137 => _137.sceneUp]), () => (W)))))},gizmo:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _138 => _138.gizmo, 'optionalAccess', _139 => _139.enabled]), () => (!1))},edges:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _140 => _140.edges, 'optionalAccess', _141 => _141.enabled]), () => (!1)),color:_optionalChain([e, 'access', _142 => _142.edges, 'optionalAccess', _143 => _143.color]),darken:_optionalChain([e, 'access', _144 => _144.edges, 'optionalAccess', _145 => _145.darken]),width:_nullishCoalesce(_optionalChain([e, 'access', _146 => _146.edges, 'optionalAccess', _147 => _147.width]), () => (1.5)),thresholdAngle:_nullishCoalesce(_optionalChain([e, 'access', _148 => _148.edges, 'optionalAccess', _149 => _149.thresholdAngle]), () => (44)),distanceFade:_nullishCoalesce(_optionalChain([e, 'access', _150 => _150.edges, 'optionalAccess', _151 => _151.distanceFade]), () => (!0)),maxTriangles:_optionalChain([e, 'access', _152 => _152.edges, 'optionalAccess', _153 => _153.maxTriangles]),maxSegments:_optionalChain([e, 'access', _154 => _154.edges, 'optionalAccess', _155 => _155.maxSegments]),screenSpaceFallback:_optionalChain([e, 'access', _156 => _156.edges, 'optionalAccess', _157 => _157.screenSpaceFallback])},measure:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _158 => _158.measure, 'optionalAccess', _159 => _159.enabled]), () => (!1)),snapPixels:_optionalChain([e, 'access', _160 => _160.measure, 'optionalAccess', _161 => _161.snapPixels]),color:_optionalChain([e, 'access', _162 => _162.measure, 'optionalAccess', _163 => _163.color]),labelClassName:_optionalChain([e, 'access', _164 => _164.measure, 'optionalAccess', _165 => _165.labelClassName]),displayUnit:_optionalChain([e, 'access', _166 => _166.measure, 'optionalAccess', _167 => _167.displayUnit]),format:_optionalChain([e, 'access', _168 => _168.measure, 'optionalAccess', _169 => _169.format])},events:{onBackgroundClicked:_optionalChain([e, 'access', _170 => _170.events, 'optionalAccess', _171 => _171.onBackgroundClicked]),onObjectSelected:_optionalChain([e, 'access', _172 => _172.events, 'optionalAccess', _173 => _173.onObjectSelected]),onMeshMetadataClicked:_optionalChain([e, 'access', _174 => _174.events, 'optionalAccess', _175 => _175.onMeshMetadataClicked]),onMeshDoubleClicked:_optionalChain([e, 'access', _176 => _176.events, 'optionalAccess', _177 => _177.onMeshDoubleClicked]),selectionColor:_optionalChain([e, 'access', _178 => _178.events, 'optionalAccess', _179 => _179.selectionColor])||"#ff0000",enableEventHandlers:_nullishCoalesce(_optionalChain([e, 'access', _180 => _180.events, 'optionalAccess', _181 => _181.enableEventHandlers]), () => (!0)),enableKeyboardControls:_nullishCoalesce(_optionalChain([e, 'access', _182 => _182.events, 'optionalAccess', _183 => _183.enableKeyboardControls]), () => (!0)),enableClickToFocus:_nullishCoalesce(_optionalChain([e, 'access', _184 => _184.events, 'optionalAccess', _185 => _185.enableClickToFocus]), () => (!0)),enableDoubleClickZoom:_nullishCoalesce(_optionalChain([e, 'access', _186 => _186.events, 'optionalAccess', _187 => _187.enableDoubleClickZoom]), () => (!0)),onReady:_optionalChain([e, 'access', _188 => _188.events, 'optionalAccess', _189 => _189.onReady]),onFrame:_optionalChain([e, 'access', _190 => _190.events, 'optionalAccess', _191 => _191.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(_nullishCoalesce(u.hemisphereSkyColor, () => (i.lighting.hemisphereSkyColor)),_nullishCoalesce(u.hemisphereGroundColor, () => (i.lighting.hemisphereGroundColor)),u.hemisphereIntensity),r.hemisphere.position.copy(_nullishCoalesce(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=_chunkAQJPVUH3cjs.i[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:()=>_chunkAQJPVUH3cjs.j.call(void 0, s)}}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}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}function Lt(e,n){_chunkAQJPVUH3cjs.v.call(void 0, e,n),_chunkAQJPVUH3cjs.p.call(void 0, _nullishCoalesce(e.environment, () => (void 0)))&&_optionalChain([e, 'access', _192 => _192.environment, 'optionalAccess', _193 => _193.dispose, 'call', _194 => _194()]),e.background instanceof Pt.Texture&&_chunkAQJPVUH3cjs.p.call(void 0, e.background)&&e.background.dispose()}var _EffectComposerjs = require('three/addons/postprocessing/EffectComposer.js');var _RenderPassjs = require('three/addons/postprocessing/RenderPass.js');var _GTAOPassjs = require('three/addons/postprocessing/GTAOPass.js');var _SMAAPassjs = require('three/addons/postprocessing/SMAAPass.js');var _OutputPassjs = require('three/addons/postprocessing/OutputPass.js');var _Passjs = require('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: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=be(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 Se(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 Ce=.015,we={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 Te(e){let t=e&&we[e]||we.Meters;return e=>`${(e/t.metersPerUnit).toPrecision(3)} ${t.suffix}`}function Ee(e,t){if(e.isOrthographicCamera){let t=e;return Math.abs(t.top-t.bottom)/(t.zoom||1)*Ce}return((t?e.position.distanceTo(t):e.position.length())||1)*Ce}function De(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 Oe(e,t,r,i){let a=e.point.clone(),o=e.object,s=De(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 ke(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=Te(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=Ee(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:Oe(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 Ae=[];function je({camera:e,scene:t,groundNormals:r=()=>Ae}){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=A(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 Me(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 Ne(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=function(){g=requestAnimationFrame(O);let n=performance.now(),r=(n-_)/1e3;_=n,D(),(o.enableDamping||o.autoRotate)&&o.update(),u&&u.update(i().position),m&&m.update(),l?.(r);let a=i();if(h){if(!(v||w(a)||n-y>=500))return;v=!1,y=n}let s=f?.();s?(s.setCamera(a),s.render(r)):e.render(t,a),p&&p.render(t,a),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 n.Vector3(0,0,1);function Pe(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||S(e.environment?.sceneUp??Q,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??1,sunlightPosition:e.lighting?.sunlightPosition||C(e.environment?.sceneUp??Q,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||Q,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??T(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 Fe(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??Q),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);let i=o.get()!==null;o.setAmbientOcclusion(n.ambientOcclusion),i&&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)}),s()},getMaterialAppearance:()=>b(c)}}function Ie(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 Le(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 Re(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:`
|
|
56
54
|
varying vec2 vUv;
|
|
57
55
|
void main() {
|
|
58
56
|
vUv = uv;
|
|
@@ -91,8 +89,8 @@
|
|
|
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
|
|
95
|
-
//
|
|
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 @@
|
|
|
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 _Passjs.Pass{constructor(t,r,i,o,a={}){super();_chunkBYLIBOAUcjs.a.call(void 0, this,"camera");_chunkBYLIBOAUcjs.a.call(void 0, this,"scene");_chunkBYLIBOAUcjs.a.call(void 0, this,"normalMaterial");_chunkBYLIBOAUcjs.a.call(void 0, this,"edgeMaterial");_chunkBYLIBOAUcjs.a.call(void 0, this,"fsQuad");_chunkBYLIBOAUcjs.a.call(void 0, this,"normalTarget",null);_chunkBYLIBOAUcjs.a.call(void 0, this,"width");_chunkBYLIBOAUcjs.a.call(void 0, 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(_nullishCoalesce(a.color, () => (2236962))),s.uOpacity.value=_nullishCoalesce(a.opacity, () => (1)),s.uNormalThreshold.value=_nullishCoalesce(a.normalThreshold, () => (.4)),s.uDepthThreshold.value=_nullishCoalesce(a.depthThreshold, () => (.02)),s.uThickness.value=_nullishCoalesce(a.thickness, () => (1)),this.fsQuad=new (0, _Passjs.FullScreenQuad)(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),_optionalChain([this, 'access', _195 => _195.normalTarget, 'optionalAccess', _196 => _196.setSize, 'call', _197 => _197(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=_nullishCoalesce(this.camera.near, () => (.1)),E.uFar.value=_nullishCoalesce(this.camera.far, () => (1e3)),t.setRenderTarget(this.renderToScreen?null:r),this.fsQuad.render(t),t.setRenderTarget(a)}dispose(){_optionalChain([this, 'access', _198 => _198.normalTarget, 'optionalAccess', _199 => _199.dispose, 'call', _200 => _200()]),this.normalMaterial.dispose(),this.edgeMaterial.dispose(),this.fsQuad.dispose()}};function Ot(e,n,t,r,i,o){let a=new (0, _EffectComposerjs.EffectComposer)(e),s=new (0, _RenderPassjs.RenderPass)(n,t);a.addPass(s);let l=null;(_nullishCoalesce(o.ambientOcclusion, () => (!0)))&&(l=new (0, _GTAOPassjs.GTAOPass)(n,t,r,i),l.blendIntensity=_nullishCoalesce(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 _SMAAPassjs.SMAAPass;a.addPass(E);let g=new _OutputPassjs.OutputPass;a.addPass(g),e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure;let u=_nullishCoalesce(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(),_optionalChain([l, 'optionalAccess', _201 => _201.dispose, 'call', _202 => _202()]),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:_nullishCoalesce(a.render.toneMapping, () => (Ft.NeutralToneMapping)),toneMappingExposure:_nullishCoalesce(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)){_optionalChain([l, 'optionalAccess', _203 => _203.dispose, 'call', _204 => _204()]),l=null,s();return}(!l||E!==m)&&(_optionalChain([l, 'optionalAccess', _205 => _205.dispose, 'call', _206 => _206()]),l=g(m),E=m),l.setEdgeDetection(f),s()};return{get:()=>l,sync:u,rebuild:()=>{_optionalChain([l, 'optionalAccess', _207 => _207.dispose, 'call', _208 => _208()]),l=null,u()},setAmbientOcclusion:p=>{m=p,u()},setEdgeFallback:p=>{p!==f&&(f=p,u())},isEdgeFallbackActive:()=>f,dispose:()=>{_optionalChain([l, 'optionalAccess', _209 => _209.dispose, 'call', _210 => _210()]),l=null}}}var _OrbitControlsjs = require('three/addons/controls/OrbitControls.js');function kt(e,n,t){let r=new (0, _OrbitControlsjs.OrbitControls)(e,n),i=t.camera.target;return i&&r.target.set(i.x,i.y,i.z),r.enableDamping=t.controls.enableDamping||!1,r.dampingFactor=t.controls.dampingFactor||.05,r.autoRotate=t.controls.autoRotate||!1,r.autoRotateSpeed=t.controls.autoRotateSpeed||.5,r.enableZoom=_nullishCoalesce(t.controls.enableZoom, () => (!0)),r.enablePan=_nullishCoalesce(t.controls.enablePan, () => (!0)),r.minDistance=t.controls.minDistance||.001,r.maxDistance=t.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}var _HDRLoaderjs = require('three/addons/loaders/HDRLoader.js');function zt(e,n,t,r){t.environment.enableEnvironmentLighting?new (0, _HDRLoaderjs.HDRLoader)().load(t.environment.hdrPath||"/baseHDR.hdr",function(i){if(r()){i.dispose();return}if(!_optionalChain([i, 'optionalAccess', _211 => _211.image])){_chunkAQJPVUH3cjs.c.call(void 0, ).warn("HDR loaded without image data; skipping environment map."),_optionalChain([i, 'optionalAccess', _212 => _212.dispose, 'call', _213 => _213()]),_optionalChain([t, 'access', _214 => _214.events, 'access', _215 => _215.onReady, 'optionalCall', _216 => _216()]);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=_nullishCoalesce(t.environment.environmentIntensity, () => (1));let s=Xe(_nullishCoalesce(t.environment.sceneUp, () => (W)));e.environmentRotation.copy(s),t.environment.showEnvironment?(e.background=i,e.backgroundRotation.copy(s)):i.dispose(),_optionalChain([t, 'access', _217 => _217.events, 'access', _218 => _218.onReady, 'optionalCall', _219 => _219()])},void 0,function(i){r()||(_chunkAQJPVUH3cjs.c.call(void 0, ).warn("HDR texture could not be loaded, falling back to basic lighting:",i),_optionalChain([t, 'access', _220 => _220.events, 'access', _221 => _221.onReady, 'optionalCall', _222 => _222()]))}):_optionalChain([t, 'access', _223 => _223.events, 'access', _224 => _224.onReady, 'optionalCall', _225 => _225()])}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=(_optionalChain([n, 'access', _226 => _226.environment, 'optionalAccess', _227 => _227.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)}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()){_chunkAQJPVUH3cjs.c.call(void 0, ).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),_optionalChain([r, 'access', _228 => _228.events, 'optionalAccess', _229 => _229.onObjectSelected, 'optionalCall', _230 => _230(x)]),x instanceof F.Mesh&&Object.keys(x.userData).length>0&&_optionalChain([r, 'access', _231 => _231.events, 'optionalAccess', _232 => _232.onMeshMetadataClicked, 'optionalCall', _233 => _233(x.userData)]))}else u(),_optionalChain([r, 'access', _234 => _234.events, 'optionalAccess', _235 => _235.onBackgroundClicked, 'optionalCall', _236 => _236({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(_optionalChain([r, 'access', _237 => _237.events, 'optionalAccess', _238 => _238.onMeshDoubleClicked, 'optionalCall', _239 => _239(T)]),!_optionalChain([r, 'access', _240 => _240.events, 'optionalAccess', _241 => _241.enableDoubleClickZoom]))return;let x=new F.Box3().setFromObject(T);x.isEmpty()||t.frameBounds(x,!0)},S=d=>{if(_optionalChain([r, 'access', _242 => _242.events, 'optionalAccess', _243 => _243.enableKeyboardControls]))switch(d.key.toLowerCase()){case"f":d.preventDefault(),E();break;case"escape":d.preventDefault(),u();break;case" ":d.preventDefault(),E();break}};return _optionalChain([r, 'access', _244 => _244.events, 'optionalAccess', _245 => _245.enableClickToFocus])&&(e.addEventListener("mousedown",C),e.addEventListener("click",b),e.addEventListener("dblclick",A)),_optionalChain([r, 'access', _246 => _246.events, 'optionalAccess', _247 => _247.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}}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=_nullishCoalesce(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(_nullishCoalesce(n.lighting.sunlightColor, () => (16777215)),n.lighting.sunlightIntensity),o=n.lighting.sunlightPosition;return o&&i.position.set(o.x,o.y,o.z),n.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=n.render.shadowMapSize||2048,i.shadow.mapSize.height=n.render.shadowMapSize||2048,i.shadow.bias=-1e-4,i.shadow.normalBias=.02,i.shadow.radius=4,e.add(i),e.add(i.target),{ambient:t,hemisphere:r,sun:i}):(e.add(i),{ambient:t,hemisphere:r,sun:null})}function 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()}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=_nullishCoalesce(n.render.toneMappingExposure, () => (1)),r.outputColorSpace=pe.SRGBColorSpace,r.sortObjects=!0,r}var ln=function(e,n){let t=Ct(n||{}),r=_optionalChain([t, 'access', _248 => _248.environment, 'optionalAccess', _249 => _249.sceneUp])||W,i=_nullishCoalesce(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);_chunkAQJPVUH3cjs.t.call(void 0, s.capabilities.getMaxAnisotropy()),_optionalChain([n, 'optionalAccess', _250 => _250.onMaxAnisotropy, 'optionalCall', _251 => _251(s.capabilities.getMaxAnisotropy())]);let l=_chunkAQJPVUH3cjs.s.call(void 0, ),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))};_optionalChain([t, 'access', _252 => _252.floor, 'optionalAccess', _253 => _253.enabled])&&_t(o,t);let C=_optionalChain([t, 'access', _254 => _254.floor, 'optionalAccess', _255 => _255.enabled])?_nullishCoalesce(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=_nullishCoalesce(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 _optionalChain([b, 'optionalAccess', _256 => _256.object, 'access', _257 => _257.visible])&&H.push(d),t.floor.enabled&&_optionalChain([C, 'optionalAccess', _258 => _258.visible])&&H.push(c),H},T=t.camera.dynamicNear?yt({camera:a,scene:o,groundNormals:R}):null,x=_nullishCoalesce(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(_optionalChain([P, 'optionalAccess', _259 => _259.handleClick, 'call', _260 => _260(H)])){H.stopImmediatePropagation();return}_optionalChain([S, 'optionalAccess', _261 => _261.handleClick, 'call', _262 => _262(H)])&&H.stopImmediatePropagation()}};(S||P)&&(e.addEventListener("mousedown",v,{capture:!0}),e.addEventListener("click",z,{capture:!0}));let j=H=>_optionalChain([P, 'optionalAccess', _263 => _263.handleMove, 'call', _264 => _264(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=>{_optionalChain([Xt, 'access', _265 => _265.userData, 'optionalAccess', _266 => _266.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,_nullishCoalesce(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(),_chunkAQJPVUH3cjs.v.call(void 0, H)},Wt=()=>{o.children.filter(ae=>ae.userData.source==="user").forEach(ae=>{ae.removeFromParent(),_chunkAQJPVUH3cjs.v.call(void 0, 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),_optionalChain([P, 'optionalAccess', _267 => _267.dispose, 'call', _268 => _268()]),_optionalChain([M, 'optionalAccess', _269 => _269.dispose, 'call', _270 => _270()]),_optionalChain([S, 'optionalAccess', _271 => _271.dispose, 'call', _272 => _272()]),_optionalChain([b, 'optionalAccess', _273 => _273.dispose, 'call', _274 => _274()]),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}};exports.DEFAULT_LOOK = _chunkAQJPVUH3cjs.h; exports.ErrorCodes = _chunkAQJPVUH3cjs.a; exports.LOOKS = _chunkAQJPVUH3cjs.g; exports.LOOK_PRESETS = _chunkAQJPVUH3cjs.i; exports.VisualizationError = _chunkAQJPVUH3cjs.b; exports.enableDebugLogging = _chunkAQJPVUH3cjs.e; exports.getLogger = _chunkAQJPVUH3cjs.c; exports.initThree = ln; exports.materialAppearanceForLook = _chunkAQJPVUH3cjs.j; exports.setLogger = _chunkAQJPVUH3cjs.d; exports.updateScene = Jt;
|
|
107
|
+
`};var ze=class extends h.Pass{camera;scene;normalMaterial;edgeMaterial;fsQuad;normalTarget=null;width;height;constructor(e,t,r,i,a={}){super(),this.scene=e,this.camera=t,this.width=Math.max(1,r),this.height=Math.max(1,i),this.normalMaterial=new n.MeshNormalMaterial,this.normalMaterial.blending=n.NoBlending,this.edgeMaterial=new n.ShaderMaterial({uniforms:n.UniformsUtils.clone($.uniforms),vertexShader:$.vertexShader,fragmentShader:$.fragmentShader});let o=this.edgeMaterial.uniforms;o.uColor.value=new n.Color(a.color??2236962),o.uOpacity.value=a.opacity??1,o.uNormalThreshold.value=a.normalThreshold??.4,o.uDepthThreshold.value=a.depthThreshold??.02,o.uThickness.value=a.thickness??1,this.fsQuad=new h.FullScreenQuad(this.edgeMaterial),this.needsSwap=!0}acquireNormalTarget(){if(!this.normalTarget){let e=new n.DepthTexture(this.width,this.height);this.normalTarget=new n.WebGLRenderTarget(this.width,this.height,{minFilter:n.NearestFilter,magFilter:n.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,r){let i=this.acquireNormalTarget(),a=e.getRenderTarget(),o=e.autoClear,s=e.getClearColor(new n.Color),c=e.getClearAlpha(),l=this.scene.overrideMaterial;e.setRenderTarget(i),e.setClearColor(7829503,1),e.autoClear=!0,this.scene.overrideMaterial=this.normalMaterial,e.render(this.scene,this.camera),this.scene.overrideMaterial=l,e.setClearColor(s,c),e.autoClear=o;let u=this.edgeMaterial.uniforms;u.tDiffuse.value=r.texture,u.tNormal.value=i.texture,u.tDepth.value=i.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(a)}dispose(){this.normalTarget?.dispose(),this.normalMaterial.dispose(),this.edgeMaterial.dispose(),this.fsQuad.dispose()}};function Be(e,t,n,r,i,a){let o=new u.EffectComposer(e),s=new d.RenderPass(t,n);o.addPass(s);let c=null;(a.ambientOcclusion??!0)&&(c=new f.GTAOPass(t,n,r,i),c.blendIntensity=a.aoIntensity??1,c.updateGtaoMaterial({screenSpaceRadius:!0}),o.addPass(c));let l=new ze(t,n,r,i,typeof a.edgeDetection==`object`?a.edgeDetection:{});l.enabled=!!a.edgeDetection,o.addPass(l);let h=new p.SMAAPass;o.addPass(h);let g=new m.OutputPass;o.addPass(g),e.toneMapping=a.toneMapping,e.toneMappingExposure=a.toneMappingExposure;let _=a.aoPixelRatio??1;return o.setSize(r,i),{render:e=>o.render(e),setSize:(e,t,n)=>{o.setPixelRatio(Math.min(n,_)),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(),h.dispose(),g.dispose()}}}function Ve(e){let{renderer:t,scene:r,getActiveCamera:i,getCanvasSize:a,pixelRatio:o,config:s,requestRender:c}=e,l=null,u=!!s.render.ambientOcclusion,d=!1,f=!1,p=e=>{let{width:c,height:l}=a(),u=Be(t,r,i(),Math.max(1,c),Math.max(1,l),{toneMapping:s.render.toneMapping??n.NeutralToneMapping,toneMappingExposure:s.render.toneMappingExposure??1,ambientOcclusion:e,aoIntensity:s.render.aoIntensity,aoPixelRatio:s.render.aoPixelRatio,edgeDetection:!1});return u.setSize(Math.max(1,c),Math.max(1,l),o),u},m=()=>{if(!(u||d)){l?.dispose(),l=null,c();return}(!l||f!==u)&&(l?.dispose(),l=p(u),f=u),l.setEdgeDetection(d),c()};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 He(e,t,n){let r=new g.OrbitControls(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 Ue(e,r,i,a){i.environment.enableEnvironmentLighting?new _.HDRLoader().load(i.environment.hdrPath||`/baseHDR.hdr`,function(o){if(a()){o.dispose();return}if(!o?.image){t.c().warn(`HDR loaded without image data; skipping environment map.`),o?.dispose(),i.events.onReady?.();return}o.mapping=n.EquirectangularReflectionMapping;let s=new n.PMREMGenerator(r);s.compileEquirectangularShader();let c=s.fromEquirectangular(o).texture;s.dispose(),e.environment=c,e.environmentIntensity=i.environment.environmentIntensity??1;let l=w(i.environment.sceneUp??Q);e.environmentRotation.copy(l),i.environment.showEnvironment?(e.background=o,e.backgroundRotation.copy(l)):o.dispose(),i.events.onReady?.()},void 0,function(e){a()||(t.c().warn(`HDR texture could not be loaded, falling back to basic lighting:`,e),i.events.onReady?.())}):i.events.onReady?.()}function We(e,t){let r=t.floor.size,i=new n.PlaneGeometry(r,r),a=typeof t.floor.color==`string`?new n.Color(t.floor.color):t.floor.color,o=new n.MeshStandardMaterial({color:a,roughness:t.floor.roughness,metalness:t.floor.metalness,side:n.DoubleSide}),s=new n.Mesh(i,o);s.userData.id=`floor`,s.name=`floor`;let c=(t.environment?.sceneUp||Q).clone().normalize();s.quaternion.setFromUnitVectors(new n.Vector3(0,0,1),c),s.position.set(0,0,0),t.floor.receiveShadow&&t.render.enableShadows&&(s.receiveShadow=!0),e.add(s)}function Ge(e,r,i,a){let o=new Set,s=new Map,c=new n.Raycaster,l=new n.Vector2,u=new n.Vector2,d=()=>i.getActiveCamera(),f=e=>{let t=e;for(;t;){if(!t.visible)return!1;t=t.parent}return!0},p=()=>{let e=A(r);if(e.isEmpty()){t.c().warn(`No objects to fit to view`);return}i.frameBounds(e,!1)},m=typeof a.events.selectionColor==`string`?new n.Color(a.events.selectionColor):a.events.selectionColor instanceof n.Color?a.events.selectionColor:new n.Color(`#ff0000`),h=()=>{o.forEach(e=>{let t=e;if(s.has(e)){let i=s.get(e),a=t.material;a instanceof n.Material?a.dispose():Array.isArray(a)&&a.forEach(e=>e.dispose()),t.material=i,s.delete(e);let o=e;for(;o.parent;)o=o.parent;o!==r&&(i instanceof n.Material?i.dispose():i.forEach(e=>e.dispose()))}}),o.clear()},g=e=>{let t=e;if(!(t.material instanceof n.Material))return!1;s.set(e,t.material);let r=t.material.clone();return e instanceof n.Mesh&&`emissive`in r?r.emissive=m.clone():`color`in r&&(r.color=m.clone()),t.material=r,!0},_=()=>{let e=A(r),t=e.isEmpty()?1:e.getSize(new n.Vector3).length();c.params.Points.threshold=t*.01},v=e=>{u.set(e.clientX,e.clientY)},y=t=>{let i=new n.Vector2(t.clientX,t.clientY);if(u.distanceTo(i)>5)return;let s=e.getBoundingClientRect();l.x=(t.clientX-s.left)/s.width*2-1,l.y=-((t.clientY-s.top)/s.height)*2+1,_(),c.setFromCamera(l,d());let p=c.intersectObjects(r.children,!0).filter(e=>f(e.object));if(p.length>0){let e=p[0].object;o.has(e)||(h(),o.add(e),g(e),a.events?.onObjectSelected?.(e),e instanceof n.Mesh&&Object.keys(e.userData).length>0&&a.events?.onMeshMetadataClicked?.(e.userData))}else h(),a.events?.onBackgroundClicked?.({x:l.x,y:l.y})},b=t=>{let o=e.getBoundingClientRect();l.x=(t.clientX-o.left)/o.width*2-1,l.y=-((t.clientY-o.top)/o.height)*2+1,_(),c.setFromCamera(l,d());let s=c.intersectObjects(r.children,!0).filter(e=>f(e.object));if(s.length===0)return;let u=s[0].object;if(a.events?.onMeshDoubleClicked?.(u),!a.events?.enableDoubleClickZoom)return;let p=new n.Box3().setFromObject(u);p.isEmpty()||i.frameBounds(p,!0)},x=e=>{if(a.events?.enableKeyboardControls)switch(e.key.toLowerCase()){case`f`:e.preventDefault(),p();break;case`escape`:e.preventDefault(),h();break;case` `:e.preventDefault(),p()}};return a.events?.enableClickToFocus&&(e.addEventListener(`mousedown`,v),e.addEventListener(`click`,y),e.addEventListener(`dblclick`,b)),a.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 Ke(e,t){let r=new n.AmbientLight(t.lighting.ambientLightColor,t.lighting.ambientLightIntensity);e.add(r);let i=null;if(t.lighting.enableHemisphereLight){i=new n.HemisphereLight(t.lighting.hemisphereSkyColor,t.lighting.hemisphereGroundColor,t.lighting.hemisphereIntensity);let r=t.environment.sceneUp??Q;i.position.copy(r),e.add(i)}if(!t.lighting.enableSunlight)return{ambient:r,hemisphere:i,sun:null};let a=new n.DirectionalLight(t.lighting.sunlightColor??16777215,t.lighting.sunlightIntensity),o=t.lighting.sunlightPosition;return o&&a.position.set(o.x,o.y,o.z),t.render.enableShadows?(a.castShadow=!0,a.shadow.mapSize.width=t.render.shadowMapSize||2048,a.shadow.mapSize.height=t.render.shadowMapSize||2048,a.shadow.bias=-1e-4,a.shadow.normalBias=.02,a.shadow.radius=4,e.add(a),e.add(a.target),{ambient:r,hemisphere:i,sun:a}):(e.add(a),{ambient:r,hemisphere:i,sun:null})}function qe(e,t){if(t.isEmpty())return;let r=t.getCenter(new n.Vector3),i=t.getSize(new n.Vector3).length()*.5*1.2,a=e.shadow.camera;a.left=-i,a.right=i,a.top=i,a.bottom=-i,e.target.position.copy(r),e.target.updateMatrixWorld();let o=e.position.distanceTo(r);a.near=Math.max(i*.01,o-i),a.far=o+i,a.updateProjectionMatrix()}function Je(e,t,r){let i=new n.WebGLRenderer({antialias:t.render.antialias,canvas:e,alpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:t.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),a=e.parentElement,o=a?a.clientWidth:window.innerWidth,s=a?a.clientHeight:window.innerHeight;return a&&(e.style.width=`100%`,e.style.height=`100%`,e.style.display=`block`),i.setSize(o,s,!1),i.setPixelRatio(r),t.render.enableShadows&&(i.shadowMap.enabled=!0,i.shadowMap.type=n.VSMShadowMap),i.toneMapping=t.render.toneMapping,i.toneMappingExposure=t.render.toneMappingExposure??1,i.outputColorSpace=n.SRGBColorSpace,i.sortObjects=!0,i}const Ye=function(e,r){let i=Pe(r||{}),a=i.environment?.sceneUp||Q,o=i.render.pixelRatio??Math.min(window.devicePixelRatio,2),s=Le(i),c=Ie(i,e);c.up.copy(a);let l=Je(e,i,o);t.r(l.capabilities.getMaxAnisotropy()),r?.onMaxAnisotropy?.(l.capabilities.getMaxAnisotropy());let u=He(c,e,i),d=ee({scene:s,perspective:c,controls:u,onActiveCameraChange:()=>{},up:a}),f=()=>d.getActiveCamera(),p=!1;Ue(s,l,i,()=>p);let m=Ke(s,i),h=m.sun,g=()=>{h&&qe(h,A(s))};i.floor?.enabled&&We(s,i);let _=i.floor?.enabled?s.children.find(e=>e.userData.id===`floor`)??null:null,v=i.grid.enabled?xe({cellSize:i.grid.cellSize,majorEvery:i.grid.majorEvery,cellColor:i.grid.cellColor,majorColor:i.grid.majorColor,fadeDistance:i.grid.fadeDistance,plane:i.grid.plane}):null;v&&s.add(v.object);let y=()=>{v&&v.fitToContent(A(s))},b=i.gizmo.enabled?Me({camera:c,domElement:e,controller:d}):null,x=i.grid.plane??T(a),S=new n.Vector3(+(x===`x`),+(x===`y`),+(x===`z`)),C=a.clone().normalize(),w=i.camera.dynamicNear?je({camera:c,scene:s,groundNormals:()=>{let e=[];return v?.object.visible&&e.push(S),i.floor.enabled&&_?.visible&&e.push(C),e}}):null,E=e.parentElement??e,D=i.measure.enabled?Se(E,s):null,O=i.measure.enabled&&D?ke({canvas:e,scene:s,getActiveCamera:f,labelLayer:D,options:{snapPixels:i.measure.snapPixels,color:i.measure.color,labelClassName:i.measure.labelClassName,displayUnit:i.measure.displayUnit,format:i.measure.format}}):null,k=i.events.enableEventHandlers===!1?{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}}:Ge(e,s,d,i),j=0,M=0,N=e=>{j=e.clientX,M=e.clientY},P=e=>Math.hypot(e.clientX-j,e.clientY-M)>5,F=e=>{if(!P(e)){if(O?.handleClick(e)){e.stopImmediatePropagation();return}b?.handleClick(e)&&e.stopImmediatePropagation()}};(b||O)&&(e.addEventListener(`mousedown`,N,{capture:!0}),e.addEventListener(`click`,F,{capture:!0}));let I=e=>O?.handleMove(e);O&&e.addEventListener(`mousemove`,I,{passive:!0});let L=()=>{},R=e=>{ve(e,{color:i.edges.color,darken:i.edges.darken,width:i.edges.width,thresholdAngle:i.edges.thresholdAngle,distanceFade:i.edges.distanceFade,maxTriangles:i.edges.maxTriangles,maxSegments:i.edges.maxSegments}).then(()=>{z(e),L()})},z=e=>{if(i.edges.screenSpaceFallback===!1)return;let t=!1;e.traverse(e=>{e.userData?.edgesSkipped===`triangle-cap`&&(t=!0)}),U.setEdgeFallback(t)},B=e=>{ye(e),U.setEdgeFallback(!1),L()},V=e.parentElement,H=()=>V?{width:V.clientWidth,height:V.clientHeight}:{width:window.innerWidth,height:window.innerHeight},U=Ve({renderer:l,scene:s,getActiveCamera:f,getCanvasSize:H,pixelRatio:o,config:i,requestRender:()=>L()});U.sync();let W=Fe({scene:s,renderer:l,lights:m,config:i,pipeline:U,requestRender:()=>L()}),{animate:G,dispose:K,invalidate:q}=Ne(l,s,c,f,d,u,H,o,i.events.onFrame,v,b,()=>U.get(),D,w,i.render.onDemand??!0);return L=q,G(),s.up.set(a.x,a.y,a.z),g(),y(),{scene:s,camera:c,controls:u,renderer:l,cameraController:d,grid:v,gizmo:b,measureTool:O,applyEdges:R,clearEdges:B,invalidate:q,setAmbientOcclusion:U.setAmbientOcclusion,setLook:W.setLook,setFillLights:W.setFillLights,setEnvironmentIntensity:W.setEnvironmentIntensity,setToneMappingExposure:W.setToneMappingExposure,setAoIntensity:W.setAoIntensity,getMaterialAppearance:W.getMaterialAppearance,updateShadowBounds:g,updateGridScale:y,dispose:()=>{p||(p=!0,K(),k.dispose(),(b||O)&&(e.removeEventListener(`mousedown`,N,{capture:!0}),e.removeEventListener(`click`,F,{capture:!0})),O&&e.removeEventListener(`mousemove`,I),O?.dispose(),D?.dispose(),b?.dispose(),v?.dispose(),U.dispose(),d.dispose(),u.dispose(),l.dispose(),l.forceContextLoss(),Re(s))},fitToView:k.fitToView,clearSelection:k.clearSelection,addUserGeometry:e=>{e.userData.source=`user`,s.add(e)},removeUserGeometry:e=>{e.removeFromParent(),t.t(e)},clearUserGeometry:()=>{s.children.filter(e=>e.userData.source===`user`).forEach(e=>{e.removeFromParent(),t.t(e)})}}};exports.DEFAULT_LOOK=`technical`,exports.ErrorCodes=t.u,exports.LOOKS=v,exports.LOOK_PRESETS=y,exports.VisualizationError=t.d,exports.enableDebugLogging=t.s,exports.getLogger=t.c,exports.initThree=Ye,exports.materialAppearanceForLook=b,exports.setLogger=t.l,exports.updateScene=D;
|
|
110
108
|
//# sourceMappingURL=render.cjs.map
|