@selvajs/visualization 1.0.0-beta.2 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/render.cjs +4 -4
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +125 -6
- package/dist/render.d.ts +124 -5
- package/dist/render.js +4 -4
- package/dist/render.js.map +1 -1
- package/package.json +1 -1
package/dist/render.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
|
2
|
-
`)}const
|
|
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}}const x=`user`,S=`app:`;function C(e){return`${S}${e}`}function w(e){return typeof e!=`string`||!e.startsWith(S)?null:e.slice(4)||null}function T(e){let t=e.userData?.source;return t===`user`||w(t)!==null}function E(e,t){return t===void 0?T(e):e.userData?.source===C(t)}function D(e){let t=e.clone().normalize(),r=new n.Vector3(0,0,1),i=new n.Vector3(0,1,0),a=Math.abs(t.dot(r))>.9?i:r,o=new n.Vector3().crossVectors(a,t).normalize();return{up:t,forward:new n.Vector3().crossVectors(t,o).normalize(),right:o}}function O(e,t){let{forward:n,right:r,up:i}=D(e);return n.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(t)}function k(e,t,n){let{forward:r,right:i,up:a}=D(e);return i.clone().multiplyScalar(t).add(r.clone().multiplyScalar(t)).add(a.clone().multiplyScalar(n))}function A(e){let t=e.clone().normalize(),r=new n.Vector3(0,1,0);if(t.dot(r)>.9999)return new n.Euler;if(t.dot(r)<-.9999)return new n.Euler(Math.PI,0,0);let i=new n.Quaternion().setFromUnitVectors(r,t);return new n.Euler().setFromQuaternion(i)}function j(e){let t=Math.abs(e.x),n=Math.abs(e.y),r=Math.abs(e.z);return t>=n&&t>=r?`x`:n>=r?`y`:`z`}const M={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function N(e,r,i,a,o){if(L(e),r.length===0)return;r.forEach(t=>{e.add(t)});let s=t.a(r),c=s.getCenter(new n.Vector3),l=s.getSize(new n.Vector3),u=Math.max(l.x,l.y,l.z);if(u/Math.min(l.x||1,l.y||1,l.z||1)>M.SCALE_RATIO_THRESHOLD||u>M.HUGE_THRESHOLD?(i.near=u*M.NEAR_PLANE_FACTOR.TINY,i.far=u*M.FAR_PLANE_FACTOR.HUGE):u>M.LARGE_THRESHOLD?(i.near=u*M.NEAR_PLANE_FACTOR.SMALL,i.far=u*M.FAR_PLANE_FACTOR.LARGE):(i.near=Math.max(.01,u*M.NEAR_PLANE_FACTOR.NORMAL),i.far=Math.max(2e3,u*M.FAR_PLANE_FACTOR.NORMAL)),i.updateProjectionMatrix(),!o){let e=u*M.INITIAL_DISTANCE_MULTIPLIER;i.position.copy(c).add(O(i.up,e)),a.target.copy(c),a.update()}}const P=new Set([`grid`,`floor`,`label-layer`,`measure`]);function F(e){let t=e;for(;t;){if(typeof t.userData.id==`string`&&P.has(t.userData.id))return!0;t=t.parent}return!1}function I(e){e.updateMatrixWorld(!0);let t=new n.Box3;return e.traverse(e=>{let n=e;e.visible&&!F(e)&&n.geometry&&t.expandByObject(e)}),t}const ee=new Set([`floor`,`grid`,`label-layer`]);function L(e){[...e.children].forEach(e=>{ee.has(e.userData.id)||T(e)||(t.t(e),e.removeFromParent())})}function R(e){let{up:t,forward:n,right:r}=D(e),i=n.clone().negate(),a=r.clone();return{top:t.clone(),bottom:t.clone().negate(),front:i.clone(),back:i.clone().negate(),right:a.clone(),left:a.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(a.clone()).add(t.clone()).normalize()}}function te(e){let{scene:t,perspective:r,controls:i,onActiveCameraChange:a}=e,o=(e.up??r.up).clone().normalize(),s=R(o),c=new n.OrthographicCamera(-1,1,1,-1,r.near,r.far);c.up.copy(o);let l=`perspective`,u=r.aspect,d=()=>l===`perspective`?r:c,f=null,p=()=>{f?.cancel(),f=null},m=()=>{let e=(l===`orthographic`?c:r).position.distanceTo(i.target)*Math.tan(r.fov*Math.PI/360),t=e*u;c.left=-t,c.right=t,c.top=e,c.bottom=-e,c.near=r.near,c.far=r.far,c.updateProjectionMatrix()},h=e=>{if(e!==l){if(p(),e===`orthographic`)c.position.copy(r.position),c.up.copy(r.up),c.lookAt(i.target),c.zoom=1,m();else{let e=(c.top-c.bottom)/(2*c.zoom)/Math.tan(r.fov*Math.PI/360),t=c.position.clone().sub(i.target);t.lengthSq()<1e-12&&t.copy(o),t.normalize(),r.position.copy(i.target).add(t.multiplyScalar(e))}l=e,i.object=d(),i.update(),a(d())}},g=(e,t,n,a)=>{let s=r.fov*(Math.PI/180),u=t/(2*Math.tan(s/2))*1.5,h=z(n,o),g=e.clone().add(h.clone().multiplyScalar(u)),_=d();l===`orthographic`&&(c.zoom=1),p(),a?f=re(_,i,g,e,()=>{l===`orthographic`&&m()}):(_.position.copy(g),i.target.copy(e),l===`orthographic`&&m(),i.update())},_=(e,r=!0)=>{let a=I(t),o=a.isEmpty()?i.target.clone():a.getCenter(new n.Vector3),s=a.isEmpty()?new n.Vector3(1,1,1):a.getSize(new n.Vector3),c=Math.max(s.x,s.y,s.z)||1;g(o,c,e,r)};return{getActiveCamera:d,getProjection:()=>l,setProjection:h,toggleProjection:()=>(h(l===`perspective`?`orthographic`:`perspective`),l),setView:(e,t=!0)=>{_(s[e],t)},setViewDirection:_,frameBounds:(e,t=!0)=>{if(e.isEmpty())return;let r=e.getCenter(new n.Vector3),a=e.getSize(new n.Vector3),o=Math.max(a.x,a.y,a.z)||1,c=d().position.clone().sub(i.target);c.lengthSq()<1e-12&&c.copy(s.iso),g(r,o,c.normalize(),t)},setRotateEnabled:e=>{i.enableRotate=e},isRotateEnabled:()=>i.enableRotate,updateAspect:(e,t)=>{u=t===0?u:e/t,l===`orthographic`&&m()},dispose:p}}function z(e,t){let{up:n,forward:r}=D(t),i=e.clone().normalize();if(Math.abs(i.dot(n))<.9999)return e;let a=r.clone().negate(),o=.5*Math.PI/180;return i.multiplyScalar(Math.cos(o)).add(a.multiplyScalar(Math.sin(o))).normalize()}const ne=e=>1-(1-e)**3;function re(e,t,n,r,i,a=250){let o=e.position.clone(),s=t.target.clone(),c=performance.now(),l=null,u=()=>{l=null;let d=ne(Math.min((performance.now()-c)/a,1));e.position.lerpVectors(o,n,d),t.target.lerpVectors(s,r,d),i(),t.update(),d<1&&(l=requestAnimationFrame(u))};return l=requestAnimationFrame(u),{cancel:()=>{l!==null&&(cancelAnimationFrame(l),l=null)}}}function ie(e){let t=Math.floor(e.length/6);if(t===0)return 1/0;let n=Math.max(1,Math.ceil(t/4096)),r=[];for(let i=0;i<t;i+=n){let t=i*6,n=Math.hypot(e[t+3]-e[t],e[t+4]-e[t+1],e[t+5]-e[t+2]);n>0&&r.push(n)}return r.length===0?1/0:(r.sort((e,t)=>e-t),r[Math.min(r.length-1,Math.floor(r.length*.15))])}function B(e){let t=new s.LineSegmentsGeometry;return t.setPositions(e),{geometry:t,segmentCount:e.length/6,edgeSpacing:ie(e)}}function V(e,t,n){let r=1e4,i=67108864,a=Math.cos(Math.PI/180*n),o=e.length/3;if(o>=i)throw Error(`extractEdgeSegments: ${o} vertices exceeds 2^26 limit`);let s=new Float64Array(o),c=new Float64Array(o),l=new Float64Array(o);for(let t=0;t<o;t++)s[t]=Math.round(e[3*t]*r),c[t]=Math.round(e[3*t+1]*r),l[t]=Math.round(e[3*t+2]*r);let u=16;for(;u<o*2;)u<<=1;let d=u-1,f=new Int32Array(u).fill(-1),p=new Int32Array(o);for(let e=0;e<o;e++){let t=(Math.imul(s[e]|0,73856093)^Math.imul(c[e]|0,19349663)^Math.imul(l[e]|0,83492791))&d;for(;;){let n=f[t];if(n===-1){f[t]=e,p[e]=e;break}if(s[n]===s[e]&&c[n]===c[e]&&l[n]===l[e]){p[e]=n;break}t=t+1&d}}let m=new Float32Array(4096),h=0,g=(t,n)=>{if(h+6>m.length){let e=new Float32Array(m.length*2);e.set(m),m=e}m[h++]=e[3*t],m[h++]=e[3*t+1],m[h++]=e[3*t+2],m[h++]=e[3*n],m[h++]=e[3*n+1],m[h++]=e[3*n+2]},_=new Map,v=[],y=[],b=[],x=(t?t.length:o)/3;for(let n=0;n<x;n++){let r=t?t[3*n]:3*n,o=t?t[3*n+1]:3*n+1,s=t?t[3*n+2]:3*n+2,c=p[r],l=p[o],u=p[s];if(c===l||l===u||u===c)continue;let d=e[3*s]-e[3*o],f=e[3*s+1]-e[3*o+1],m=e[3*s+2]-e[3*o+2],h=e[3*r]-e[3*o],x=e[3*r+1]-e[3*o+1],S=e[3*r+2]-e[3*o+2],C=f*S-m*x,w=m*h-d*S,T=d*x-f*h,E=C*C+w*w+T*T;if(E>0){let e=1/Math.sqrt(E);C*=e,w*=e,T*=e}else C=0,w=0,T=0;for(let e=0;e<3;e++){let t,n,d,f;e===0?(t=r,n=o,d=c,f=l):e===1?(t=o,n=s,d=l,f=u):(t=s,n=r,d=u,f=c);let p=f*i+d,m=_.get(p);if(m!==void 0&&m!==-1)C*b[3*m]+w*b[3*m+1]+T*b[3*m+2]<=a&&g(t,n),_.set(p,-1);else{let e=d*i+f;if(!_.has(e)){let r=v.length;_.set(e,r),v.push(t),y.push(n),b.push(C,w,T)}}}}for(let e of _.values())e!==-1&&g(v[e],y[e]);return m.slice(0,h)}function H(){return[`const extract = ${V.toString()};`,`self.onmessage = (event) => {`,` const { id, positions, index, thresholdAngle } = event.data;`,` try {`,` const segments = extract(positions, index, thresholdAngle);`,` self.postMessage({ id, segments }, [segments.buffer]);`,` } catch (error) {`,` self.postMessage({ id, error: String((error && error.message) || error) });`,` }`,`};`].join(`
|
|
2
|
+
`)}const U=`edge-overlay`;function W(e){return{forcedColor:e.color==null?null:new n.Color(e.color),darken:n.MathUtils.clamp(e.darken??.75,0,1),width:e.width??1.5,thresholdAngle:e.thresholdAngle??44,distanceFade:e.distanceFade??!0,maxTriangles:e.maxTriangles??4e6,maxSegments:e.maxSegments??2e6}}function G(e){let t=e.getAttribute(`position`);return t?(e.index?e.index.count:t.count)/3:0}function K(e){let t=e.getAttribute(`position`);if(!t||t.isInterleavedBufferAttribute||t.itemSize!==3||!(t.array instanceof Float32Array)||t.count>=67108864)return null;let n=e.index;return n&&!(n.array instanceof Uint32Array)&&!(n.array instanceof Uint16Array)?null:{positions:t.array,index:n?n.array:null}}function ae(e,t){let n=4096,r=2166136261,i=e=>{r^=e,r=Math.imul(r,16777619)},a=new Uint32Array(e.positions.buffer,e.positions.byteOffset,e.positions.length),o=Math.min(n,a.length);for(let e=0;e<o;e++)i(a[e]);for(let e=Math.max(o,a.length-n);e<a.length;e++)i(a[e]);let s=0;if(e.index){s=e.index.length;let t=Math.min(n,s);for(let n=0;n<t;n++)i(e.index[n]);for(let r=Math.max(t,s-n);r<s;r++)i(e.index[r])}return`${t}:${e.positions.length}:${s}:${r>>>0}`}function oe(e,t){let r=new n.EdgesGeometry(e,t),i=r.attributes.position?r.attributes.position.array:new Float32Array;return r.dispose(),i}function q(e,t){let n=K(e);return n?V(n.positions,n.index,t):oe(e,t)}let J;const Y=new Map;let se=1;function ce(){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([H()],{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 le(e,t,n){return new Promise((r,i)=>{let a=se++;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 ue(e,t){let n=K(e);if(!n||G(e)<25e3)return Promise.resolve(q(e,t));let r=ae(n,t),i=X.get(r);if(i)return i;let a=ce();if(!a)return Promise.resolve(q(e,t));let o=le(a,n,t).catch(()=>V(n.positions,n.index,t)).finally(()=>{X.delete(r)});return X.set(r,o),o}function de(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 fe=class{options;byKey=new Map;constructor(e){this.options=e}for(e,t){let n=this.options.forcedColor??de(e,this.options.darken),r=n.getHex()*2+ +!!t,i=this.byKey.get(r);return i||(i=pe(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 pe(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 me(e,t,n){let r=new o.LineSegments2(e.geometry,t);return r.userData.kind=U,r.raycast=()=>{},n&&ve(r,e.edgeSpacing),r}const he=new n.Vector3,ge=new n.Vector3;function _e(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;he.copy(i.center).applyMatrix4(e.matrixWorld);let o=ge.setFromMatrixPosition(t.matrixWorld).distanceTo(he);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 ve(e,t){e.onBeforeRender=(r,i,a)=>{o.LineSegments2.prototype.onBeforeRender.call(e,r);let s=e.material,c=t*_e(e,a,s.resolution.y);s.opacity=n.MathUtils.clamp((c-1)/3,0,1)}}function ye(e){return e.userData?.kind===U}function be(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(G(e.geometry)>t){e.userData.edgesSkipped=`triangle-cap`,console.debug(`[edges] skipping mesh over triangle cap (${G(e.geometry)} > ${t})`);return}delete e.userData.edgesSkipped,r.push(e)}}),r}function xe(e,t,n,r){let i=r.distanceFade&&t.segmentCount<=r.maxSegments,a=me(t,n.for(e,i),i);return e.add(a),a}const Se=new WeakMap;function Z(e){return Se.get(e)??0}function Ce(e,t){for(let n=e;n;n=n.parent)if(n===t)return!0;return!1}async function we(e,t={}){let n=W(t),r=new fe(n),i=Z(e),a=[],o=be(e,n.maxTriangles).map(async t=>{let o=await ue(t.geometry,n.thresholdAngle);Z(e)===i&&Ce(t,e)&&(t.children.some(e=>e.userData?.kind===`edge-overlay`)||a.push(xe(t,B(o),r,n)))});return await Promise.all(o),r.disposeUnused(a),a}function Te(e){Se.set(e,Z(e)+1);let t=[];e.traverse(e=>{e instanceof o.LineSegments2&&ye(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 Ee(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 De(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);
|
|
@@ -50,7 +50,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
50
50
|
if (alpha < 0.001) discard;
|
|
51
51
|
gl_FragColor = vec4(color, alpha);
|
|
52
52
|
}
|
|
53
|
-
`,transparent:!0,depthWrite:!1,side:n.DoubleSide,uniforms:{uAxes:{value:c},uCell:{value:t},uMajor:{value:r},uCellColor:{value:new n.Color(i)},uMajorColor:{value:new n.Color(a)},uCenter:{value:new n.Vector3},uFade:{value:o}}}),f=new n.Mesh(u,d);f.name=`grid`,f.userData.id=`grid`,f.renderOrder=-1;let p=o,m=o*l,h=new n.Vector3;return{object:f,update:e=>{s===`y`?(f.position.set(e.x,0,e.z),h.set(e.x,0,e.z)):s===`z`?(f.position.set(e.x,e.y,0),h.set(e.x,e.y,0)):(f.position.set(0,e.y,e.z),h.set(0,e.y,e.z)),d.uniforms.uCenter.value.copy(h),f.scale.setScalar(m)},fitToContent:e=>{if(e.isEmpty())return;let t=e.getSize(new n.Vector3),r=(e,t)=>t===0?e.x:t===1?e.y:e.z,i=Math.max(r(t,c.x),r(t,c.y));!(i>0)||!Number.isFinite(i)||(d.uniforms.uCell.value=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:`
|
|
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=Ee(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 Oe(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 ke=.015,Ae={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 je(e){let t=e&&Ae[e]||Ae.Meters;return e=>`${(e/t.metersPerUnit).toPrecision(3)} ${t.suffix}`}function Me(e,t){if(e.isOrthographicCamera){let t=e;return Math.abs(t.top-t.bottom)/(t.zoom||1)*ke}return((t?e.position.distanceTo(t):e.position.length())||1)*ke}function Ne(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 Pe(e,t,r,i){let a=e.point.clone(),o=e.object,s=Ne(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 Fe(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=je(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=Me(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:Pe(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 Ie=[];function Le({camera:e,scene:t,groundNormals:r=()=>Ie}){let i=e.near,a=e.near,o=new n.Vector3,s=new n.Vector3;return{update:()=>{e.near!==a&&(i=e.near);let c=I(t),l=i;if(!c.isEmpty()){let t=c.getSize(s).length()*.5,a=e.position.distanceTo(c.getCenter(o))-t;for(let t of r())a=Math.min(a,Math.abs(e.position.dot(t)));l=n.MathUtils.clamp(a*.5,i,e.far*.01)}Math.abs(l-a)>a*.05&&(e.near=l,e.updateProjectionMatrix(),a=l)}}}function Re(){let e=[],t=null,n=()=>e.sort((e,t)=>t.priority-e.priority),r=t=>e.findIndex(e=>e.id===t),i=n=>{let i=r(n);i!==-1&&(e.splice(i,1),t===n&&(t=null))};return{register:({id:t,tool:r,priority:a=0})=>(i(t),e.push({id:t,tool:r,priority:a}),n(),()=>i(t)),unregister:i,get:t=>e[r(t)]?.tool??null,setActive:n=>{t=n;for(let t of e)t.tool.setEnabled?.(t.id===n)},getActive:()=>t,handleClick:t=>{for(let n of[...e])if(n.tool.handleClick(t))return!0;return!1},handleMove:t=>{for(let n of[...e])n.tool.handleMove?.(t)}}}function ze(e,t){let n=t.getBoundingClientRect();return{x:(e.clientX-n.left)/n.width*2-1,y:-((e.clientY-n.top)/n.height)*2+1}}function Be(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 Ve(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 He(e){let t=e.sceneScale||`m`,r={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[t],i=e.look??`technical`,a=y[i];return{sceneScale:t,look:i,camera:{position:e.camera?.position||O(e.environment?.sceneUp??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||k(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??j(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 Ue(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 We(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 Ge(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 Ke(e,r){t.t(e,r),e.environment?.dispose(),e.background instanceof n.Texture&&e.background.dispose()}const $={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new n.Vector2(1,1)},uColor:{value:new n.Color(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
|
|
54
54
|
varying vec2 vUv;
|
|
55
55
|
void main() {
|
|
56
56
|
vUv = uv;
|
|
@@ -104,5 +104,5 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
104
104
|
float edge = max(depthEdge, normalEdge) * uOpacity;
|
|
105
105
|
gl_FragColor = vec4(mix(color.rgb, uColor, edge), color.a);
|
|
106
106
|
}
|
|
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;
|
|
107
|
+
`};var qe=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 Je(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 qe(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 Ye(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=Je(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 Xe(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 Ze(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=A(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 Qe(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 $e(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=I(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=I(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 et(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 tt(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 nt(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 rt=function(e,r){let i=He(r||{}),a=i.environment?.sceneUp||Q,o=i.render.pixelRatio??Math.min(window.devicePixelRatio,2),s=Ge(i),c=We(i,e);c.up.copy(a);let l=nt(e,i,o);t.r(l.capabilities.getMaxAnisotropy()),r?.onMaxAnisotropy?.(l.capabilities.getMaxAnisotropy());let u=Xe(c,e,i),d=te({scene:s,perspective:c,controls:u,onActiveCameraChange:()=>{},up:a}),f=()=>d.getActiveCamera(),p=!1;Ze(s,l,i,()=>p);let m=et(s,i),h=m.sun,g=()=>{h&&tt(h,I(s))};i.floor?.enabled&&Qe(s,i);let _=i.floor?.enabled?s.children.find(e=>e.userData.id===`floor`)??null:null,v=i.grid.enabled?De({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(I(s))},b=i.gizmo.enabled?Be({camera:c,domElement:e,controller:d}):null,S=i.grid.plane??j(a),w=new n.Vector3(+(S===`x`),+(S===`y`),+(S===`z`)),T=a.clone().normalize(),D=i.camera.dynamicNear?Le({camera:c,scene:s,groundNormals:()=>{let e=[];return v?.object.visible&&e.push(w),i.floor.enabled&&_?.visible&&e.push(T),e}}):null,O=Oe(e.parentElement??e,s),k=i.measure.enabled?Fe({canvas:e,scene:s,getActiveCamera:f,labelLayer:O,options:{snapPixels:i.measure.snapPixels,color:i.measure.color,labelClassName:i.measure.labelClassName,displayUnit:i.measure.displayUnit,format:i.measure.format}}):null,A=i.events.enableEventHandlers===!1?{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}}:$e(e,s,d,i),M=Re();k&&M.register({id:`measure`,tool:k,priority:0}),b&&M.register({id:`gizmo`,tool:b,priority:-100});let N=0,P=0,F=e=>{N=e.clientX,P=e.clientY},ee=e=>Math.hypot(e.clientX-N,e.clientY-P)>5,L=e=>{ee(e)||M.handleClick(e)&&e.stopImmediatePropagation()};e.addEventListener(`mousedown`,F,{capture:!0}),e.addEventListener(`click`,L,{capture:!0});let R=e=>M.handleMove(e);e.addEventListener(`mousemove`,R,{passive:!0});let z=()=>{},ne=e=>{we(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(()=>{re(e),z()})},re=e=>{if(i.edges.screenSpaceFallback===!1)return;let t=!1;e.traverse(e=>{e.userData?.edgesSkipped===`triangle-cap`&&(t=!0)}),H.setEdgeFallback(t)},ie=e=>{Te(e),H.setEdgeFallback(!1),z()},B=e.parentElement,V=()=>B?{width:B.clientWidth,height:B.clientHeight}:{width:window.innerWidth,height:window.innerHeight},H=Ye({renderer:l,scene:s,getActiveCamera:f,getCanvasSize:V,pixelRatio:o,config:i,requestRender:()=>z()});H.sync();let U=Ue({scene:s,renderer:l,lights:m,config:i,pipeline:H,requestRender:()=>z()}),{animate:W,dispose:G,invalidate:K}=Ve(l,s,c,f,d,u,V,o,i.events.onFrame,v,b,()=>H.get(),O,D,i.render.onDemand??!0);return z=K,W(),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:k,labelLayer:O,tools:M,applyEdges:ne,clearEdges:ie,invalidate:K,setAmbientOcclusion:H.setAmbientOcclusion,setLook:U.setLook,setFillLights:U.setFillLights,setEnvironmentIntensity:U.setEnvironmentIntensity,setToneMappingExposure:U.setToneMappingExposure,setAoIntensity:U.setAoIntensity,getMaterialAppearance:U.getMaterialAppearance,updateShadowBounds:g,updateGridScale:y,dispose:()=>{p||(p=!0,G(),A.dispose(),e.removeEventListener(`mousedown`,F,{capture:!0}),e.removeEventListener(`click`,L,{capture:!0}),e.removeEventListener(`mousemove`,R),k?.dispose(),O?.dispose(),b?.dispose(),v?.dispose(),H.dispose(),d.dispose(),u.dispose(),l.dispose(),l.forceContextLoss(),Ke(s))},fitToView:A.fitToView,clearSelection:A.clearSelection,addUserGeometry:(e,t)=>{e.userData.source=t===void 0?x:C(t),s.add(e),z()},removeUserGeometry:e=>{e.removeFromParent(),t.t(e),z()},clearUserGeometry:e=>{s.children.filter(t=>E(t,e)).forEach(e=>{e.removeFromParent(),t.t(e)}),z()}}};exports.DEFAULT_LOOK=`technical`,exports.ErrorCodes=t.u,exports.LOOKS=v,exports.LOOK_PRESETS=y,exports.SOURCE_COMPUTE=`compute`,exports.SOURCE_USER=x,exports.VisualizationError=t.d,exports.appIdFromSource=w,exports.appSource=C,exports.enableDebugLogging=t.s,exports.getLogger=t.c,exports.initThree=rt,exports.isHostOwned=T,exports.isOwnedBy=E,exports.materialAppearanceForLook=b,exports.pickThreshold=Me,exports.pointerToNdc=ze,exports.setLogger=t.l,exports.snapToVertex=Pe,exports.updateScene=N;
|
|
108
108
|
//# sourceMappingURL=render.cjs.map
|