three-low-poly 0.9.22 → 0.9.24
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 +331 -9
- package/dist/index.cjs +396 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1219 -281
- package/dist/index.iife.js +117 -13
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +6706 -0
- package/dist/index.mjs.map +1 -0
- package/dist/uv-grid.jpg +0 -0
- package/package.json +22 -20
- package/dist/index.cjs.js +0 -292
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js +0 -5240
- package/dist/index.es.js.map +0 -1
- package/dist/index.umd.js +0 -292
- package/dist/index.umd.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("three");function St(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const A=St(n);function bt(s,e,t,o){const a=s.position.clone(),r=a.clone().add(s.getWorldDirection(new n.Vector3).multiplyScalar(-e));let i=null;function l(c){i===null&&(i=c);const u=(c-i)/t;if(u>=1){s.position.copy(r),o&&o();return}s.position.lerpVectors(a,r,u),requestAnimationFrame(l)}requestAnimationFrame(l)}function Gt(s,e,t,o){const a=e.length-1;let r=null;function i(l){r===null&&(r=l);const h=(l-r)/t;if(h>=1){s.position.copy(e[e.length-1]),o&&o();return}const u=h*a,d=Math.floor(u),m=u-d,f=e[d],y=e[d+1];s.position.lerpVectors(f,y,m),s.lookAt(y),requestAnimationFrame(i)}requestAnimationFrame(i)}function Pt(s,e,t,o,a){let r=null;function i(l){r||(r=l);const h=(l-r)/o;if(h>=1){a&&a();return}const u=h*Math.PI*2,d=e.x+t*Math.cos(u),m=e.z+t*Math.sin(u);s.position.set(d,s.position.y,m),s.lookAt(e),requestAnimationFrame(i)}requestAnimationFrame(i)}function At(s,e,t,o,a,r){let i=null,l=0;function c(h){i===null&&(i=h);const u=h-i,d=o/a,m=u%d/d,f=Math.sin(m*Math.PI*2)*Math.PI/6,y=e.x+t*Math.sin(f),p=e.z+t*Math.cos(f);if(s.position.set(y,s.position.y,p),s.lookAt(e),u>=(l+1)*d&&l++,l>=a){r&&r();return}requestAnimationFrame(c)}requestAnimationFrame(c)}function Ct(s,e,t,o,a,r,i){let l=null;function c(h){l===null&&(l=h);const d=(h-l)/r;if(d>=1){i&&i();return}const m=d*Math.PI*2*a,f=e.x+t*Math.cos(m),y=e.z+t*Math.sin(m),p=e.y+o*d;s.position.set(f,p,y),s.lookAt(e),requestAnimationFrame(c)}requestAnimationFrame(c)}function Tt(s,e,t,o){const a=s.position.clone();let r=null;function i(l){if(r===null&&(r=l),(l-r)/t>=1){s.position.copy(a),o&&o();return}const u=new n.Vector3((Math.random()-.5)*e,(Math.random()-.5)*e,(Math.random()-.5)*e);s.position.copy(a).add(u),requestAnimationFrame(i)}requestAnimationFrame(i)}function Bt(s,e,t,o,a,r){const i=s.fov;s.fov=t,s.updateProjectionMatrix();let l=null;function c(h){l===null&&(l=h);const d=(h-l)/a;if(d>=1){s.fov=o,s.updateProjectionMatrix(),s.lookAt(e),s.fov=i,s.updateProjectionMatrix(),r&&r();return}s.fov=n.MathUtils.lerp(t,o,d),s.updateProjectionMatrix(),s.lookAt(e),requestAnimationFrame(c)}requestAnimationFrame(c)}const D={UP:new n.Vector3(0,1,0),DOWN:new n.Vector3(0,-1,0),LEFT:new n.Vector3(-1,0,0),RIGHT:new n.Vector3(1,0,0),FORWARD:new n.Vector3(0,0,1),BACKWARD:new n.Vector3(0,0,-1)},O={linear:(s,e)=>1-s/e,quadratic:(s,e)=>Math.pow(1-s/e,2),squareRoot:(s,e)=>Math.pow(1-s/e,.5),logarithmic:(s,e)=>Math.log(1+(e-s))/Math.log(1+e),sine:(s,e)=>Math.cos(s/e*Math.PI/2),exponential:(s,e)=>Math.exp(-s/e),cubic:(s,e)=>Math.pow(1-s/e,3),gaussian:(s,e)=>Math.exp(-Math.pow(s,2)/(2*Math.pow(e/3,2))),inverse:(s,e)=>e/(e+s),smoothstep:(s,e)=>{const t=Math.max(0,Math.min(1,1-s/e));return t*t*(3-2*t)}},It=(s,e,t,o,a=D.UP,r=O.linear)=>{const i=s.attributes.position;for(let l=0;l<i.count;l++){const c=new n.Vector3;c.fromBufferAttribute(i,l);const h=c.distanceTo(e);if(h<t){const d=r(h,t)*o;c.add(a.clone().multiplyScalar(d)),i.setXYZ(l,c.x,c.y,c.z)}}i.needsUpdate=!0},Et=(s,e,t,o,a,r=D.UP,i=O.linear)=>{const l=s.attributes.position;for(let c=0;c<l.count;c++){const h=new n.Vector3;h.fromBufferAttribute(l,c);const u=h.distanceTo(e);if(u<t){const m=i(u,t)*a,f=h.dot(r.normalize()),y=o-f;h.add(r.clone().multiplyScalar(y*m)),l.setXYZ(c,h.x,h.y,h.z)}}l.needsUpdate=!0},Ft=(s,e,t,o,a=D.UP,r=O.linear)=>{const i=s.attributes.position;for(let l=0;l<i.count;l++){const c=new n.Vector3;c.fromBufferAttribute(i,l);const h=c.distanceTo(e);if(h<t){const u=r(h,t),d=o*u,m=a.clone().normalize();c.x+=n.MathUtils.randFloatSpread(d)*m.x,c.y+=n.MathUtils.randFloatSpread(d)*m.y,c.z+=n.MathUtils.randFloatSpread(d)*m.z,i.setXYZ(l,c.x,c.y,c.z)}}i.needsUpdate=!0},Rt=(s,e,t,o)=>{const a=s.attributes.position,r=new n.Vector3;for(let i=0;i<a.count;i++){const l=new n.Vector3;if(l.fromBufferAttribute(a,i),l.distanceTo(e)<t){let h=new n.Vector3,u=0;for(let d=0;d<a.count;d++)r.fromBufferAttribute(a,d),r.distanceTo(l)<t&&(h.add(r),u++);u>0&&(h.divideScalar(u),l.lerp(h,o),a.setXYZ(i,l.x,l.y,l.z))}}a.needsUpdate=!0},kt=(s,e,t,o,a=!1,r=O.linear)=>{const i=s.attributes.position;for(let l=0;l<i.count;l++){const c=new n.Vector3;c.fromBufferAttribute(i,l);const h=c.distanceTo(e);if(h<t){const d=r(h,t)*o*(a?-1:1),m=c.clone().sub(e).normalize();c.add(m.multiplyScalar(d)),i.setXYZ(l,c.x,c.y,c.z)}}i.needsUpdate=!0},Vt=(s,e,t,o,a=D.UP,r=O.linear)=>{const i=s.attributes.position,l=new n.Quaternion;for(let c=0;c<i.count;c++){const h=new n.Vector3;h.fromBufferAttribute(i,c);const u=h.distanceTo(e);if(u<t){const m=r(u,t)*o;l.setFromAxisAngle(a,m),h.sub(e).applyQuaternion(l).add(e),i.setXYZ(c,h.x,h.y,h.z)}}i.needsUpdate=!0},j={X:new n.Vector3(1,0,0),Y:new n.Vector3(0,1,0),Z:new n.Vector3(0,0,1),XY:new n.Vector3(1,1,0).normalize(),XZ:new n.Vector3(1,0,1).normalize(),YZ:new n.Vector3(0,1,1).normalize(),XYZ:new n.Vector3(1,1,1).normalize()};var B=(s=>(s.LEFT="left",s.RIGHT="right",s.TOP="top",s.BOTTOM="bottom",s.FRONT="front",s.BACK="back",s))(B||{});const k={CADMIUM_RED:15073318,CARDINAL_RED:12981270,CHERRY_RED:14165028,CRIMSON:12986408,ALIZARIN_CRIMSON:11674146,DARK_RED:9109504,RUST:12731693,CORAL_ORANGE:16734003,TANGERINE:16733440,ORANGE_PEEL:16737792,CADMIUM_ORANGE:16744228,ORANGE:16753920,AMBER:16755200,CADMIUM_YELLOW:16766720,GOLD:16766720,YELLOW:16776960,LIME_GREEN:10798080,SPRING_GREEN:8965205,MOSS_GREEN:8956467,FERN_GREEN:4950843,FOREST_GREEN:2263842,SAP_GREEN:5274922,OLIVE_DRAB:5597999,VIRIDIAN_GREEN:43115,MINT_GREEN:8965290,AQUAMARINE:65450,PHTHALO_BLUE:3977,AETHER_BLUE:3447003,SKY_BLUE:8965375,CERULEAN_BLUE:6139362,AZURE:30719,OCEAN_BLUE:30654,ROYAL_BLUE:5592575,MIDNIGHT_BLUE:51,ULTRAMARINE_BLUE:4149685,COBALT_VIOLET:6950317,DEEP_VIOLET:11141375,CORAL_PINK:16724838,VIVID_MAGENTA:16720639,MAGENTA:16711935,HOT_PINK:16711850,PINK_SHERBET:16751052,SOFT_PINK:16762823,BURNT_SIENNA:15299665,BURNT_UMBER:9057060,SIENNA:9132587,SADDLE_BROWN:9127187,COFFEE_BROWN:6045747,DARK_UMBER:4929057,RAW_UMBER:8545860,YELLOW_OCHRE:12951919,RAW_SIENNA:13808780,TAUPE:9141627,ONYX:197379,CARBON:3026478,CHARCOAL:3355443,SLATE_GRAY:4210752,ASH_GRAY:4473924,GRAPHITE:5263440,STEEL_GRAY:5592405,DIM_GRAY:6908265,IRON:7829367,GRAY:8421504,STONE:8947848,SILVER:11184810,LIGHT_GRAY:13421772,PALE_GRAY:15658734,WHITE_SMOKE:16119285,TITANIUM_WHITE:16777215},V={sineIn:s=>1-Math.cos(s*Math.PI/2),sineOut:s=>Math.sin(s*Math.PI/2),sineInOut:s=>-.5*(Math.cos(Math.PI*s)-1),quadIn:s=>s*s,quadOut:s=>1-Math.pow(1-s,2),quadInOut:s=>s<.5?2*s*s:1-Math.pow(-2*s+2,2)/2,cubicIn:s=>s*s*s,cubicOut:s=>1-Math.pow(1-s,3),cubicInOut:s=>s<.5?4*s*s*s:1-Math.pow(-2*s+2,3)/2,quartIn:s=>s*s*s*s,quartOut:s=>1-Math.pow(1-s,4),quartInOut:s=>s<.5?8*s*s*s*s:1-Math.pow(-2*s+2,4)/2,quintIn:s=>s*s*s*s*s,quintOut:s=>1-Math.pow(1-s,5),quintInOut:s=>s<.5?16*s*s*s*s*s:1-Math.pow(-2*s+2,5)/2,expoIn:s=>s===0?0:Math.pow(2,10*s-10),expoOut:s=>s===1?1:1-Math.pow(2,-10*s),expoInOut:s=>s===0?0:s===1?1:s<.5?Math.pow(2,20*s-10)/2:(2-Math.pow(2,-20*s+10))/2,circIn:s=>1-Math.sqrt(1-Math.pow(s,2)),circOut:s=>Math.sqrt(1-Math.pow(s-1,2)),circInOut:s=>s<.5?(1-Math.sqrt(1-Math.pow(2*s,2)))/2:(Math.sqrt(1-Math.pow(-2*s+2,2))+1)/2,linear:s=>s,smoothstep:s=>s*s*(3-2*s),concave:s=>1-Math.pow(1-s,.3),convex:s=>Math.pow(s,.3),logarithmic:s=>Math.log(Math.max(.01,s))/Math.log(2),squareRoot:s=>Math.sqrt(s),inverse:s=>1-s,gaussian:s=>Math.exp(-Math.pow(s-.5,2)/(2*.5))},R={cubic:(s,e,t,o,a)=>{const r=Math.max(0,Math.min(1,s)),i=1-r;return i*i*i*e+3*i*i*r*t+3*i*r*r*o+r*r*r*a},damped:(s,e=1)=>{const t=Math.max(.001,e);return(1-Math.exp(-t*s))/(1-Math.exp(-t))},exponential:(s,e=1,t=1)=>{const o=Math.max(0,Math.min(1,s));return e*Math.pow(o,t)},logarithmic:(s,e=1,t=1)=>{const o=Math.max(.001,Math.min(1,s));return e*Math.log(t*o+1)},parabolic:(s,e=1,t=0,o=0)=>{const a=Math.max(0,Math.min(1,s));return e*a*a+t*a+o},quadratic:(s,e,t,o)=>{const a=Math.max(0,Math.min(1,s)),r=1-a;return r*r*e+2*r*a*t+a*a*o},sigmoid:(s,e=10)=>{const t=Math.max(0,Math.min(1,s));return 1/(1+Math.exp(-e*(t-.5)))},sinusoidal:s=>Math.sin(s*Math.PI*.5)};function v(s=0,e=1){return Math.random()*(e-s)+s}function zt(s=0,e=1){return Math.floor(Math.random()*(e-s+1))+s}function fe(s=.5,e=0,t=1){return e+(t-e)*Math.pow(Math.random(),s)}function pe(s=.5,e=0,t=1){return e+(t-e)*Math.pow(1-Math.random(),s)}class Dt extends n.InstancedMesh{width;height;depth;baseY;spread;px;py;pz;speed;dummy=new n.Object3D;constructor(e={}){const{count:t=24,width:o=1.5,height:a=3,depth:r=1.5,spread:i=.88,baseY:l=0,speedMin:c=.35,speedMax:h=.85,color:u=16777215,opacity:d=.6,emissiveIntensity:m=0,geometry:f=new n.SphereGeometry(.08,6,6),material:y}=e,p=y??new n.MeshStandardMaterial({color:u,emissive:u,emissiveIntensity:m,transparent:!0,opacity:d,roughness:.3,metalness:.1});super(f,p,t),this.instanceMatrix.setUsage(n.DynamicDrawUsage),this.frustumCulled=!1,this.width=o,this.height=a,this.depth=r,this.baseY=l,this.spread=Math.min(1,Math.max(0,i)),this.px=new Float32Array(t),this.py=new Float32Array(t),this.pz=new Float32Array(t),this.speed=new Float32Array(t);for(let M=0;M<t;M++)this.respawn(M,!0),this.speed[M]=v(c,h);this.writeMatrices()}update(e){const t=this.baseY+this.height;for(let o=0;o<this.count;o++)this.py[o]+=this.speed[o]*e,this.py[o]>t&&this.respawn(o,!1);this.writeMatrices()}dispose(){this.geometry.dispose();const e=Array.isArray(this.material)?this.material:[this.material];for(const t of e)t.dispose();return this}respawn(e,t){const o=this.width*.5*this.spread,a=this.depth*.5*this.spread;this.px[e]=v(-o,o),this.pz[e]=v(-a,a),this.py[e]=t?this.baseY+Math.random()*this.height:this.baseY+v(0,this.height*.15)}writeMatrices(){const e=this.dummy;for(let t=0;t<this.count;t++)e.position.set(this.px[t],this.py[t],this.pz[t]),e.updateMatrix(),this.setMatrixAt(t,e.matrix);this.instanceMatrix.needsUpdate=!0}}class X{seed;light;lightIntensity;flame;halo;haloOpacity;flameColor=new n.Color;elapsed=0;constructor({seed:e=Math.random()*100,light:t,lightIntensity:o=4,flame:a,flameColor:r=16755268,halo:i,haloOpacity:l=.75}={}){this.seed=e,this.light=t,this.lightIntensity=o,this.flame=a,this.flameColor.set(r),this.halo=i,this.haloOpacity=l}static factor(e,t){return .8+.2*Math.sin(e*9+t)+.08*Math.sin(e*23+t*2)}get level(){return X.factor(this.elapsed,this.seed)}update(e){this.elapsed+=e;const t=X.factor(this.elapsed,this.seed);this.light&&(this.light.intensity=this.lightIntensity*t),this.flame&&this.flame.color.copy(this.flameColor).multiplyScalar(.8+.4*t),this.halo&&this.halo.setOpacity(this.haloOpacity*t)}faceCamera(e){this.halo?.faceCamera(e)}}class Ot extends n.Object3D{patches=[];area;heightAt;texture;elapsed=0;constructor({count:e=14,area:t=16,perimeterCount:o=0,plotHalf:a=12,terrainHalf:r=16,cameraFacing:i={x:1,z:1},color:l="#9fb0c8",heightAt:c=()=>0}={}){super(),this.area=t,this.heightAt=c,this.texture=Ut(l);const h=Nt(i);for(let u=0;u<e;u++)this.patches.push(this.makeInteriorPatch());for(let u=0;u<o;u++)this.patches.push(this.makePerimeterPatch(a,r,h))}update(e){this.elapsed+=e;for(const t of this.patches){const o=t.mesh;o.position.x+=t.driftX*e,o.position.z+=t.driftZ*e,o.rotation.z+=t.spin*e,t.perimeter?(Yt(o,t.perimeter.edge,t.perimeter.plotHalf,t.perimeter.terrainHalf),o.position.y=this.heightAt(o.position.x,o.position.z)+.15+.35*(.5+.5*Math.sin(this.elapsed*.22+t.phase))):(o.position.x>this.area&&(o.position.x-=this.area*2),o.position.x<-this.area&&(o.position.x+=this.area*2),o.position.z>this.area&&(o.position.z-=this.area*2),o.position.z<-this.area&&(o.position.z+=this.area*2)),o.material.opacity=t.baseOpacity*(.6+.4*Math.sin(this.elapsed*.3+t.phase))}}dispose(){this.texture.dispose();for(const e of this.patches)e.mesh.geometry.dispose(),e.mesh.material.dispose();this.patches.length=0,this.clear()}makeInteriorPatch(){const e=v(8,16),t=v(.05,.16),o=v(-this.area,this.area),a=v(-this.area,this.area),r=this.makeMesh(e,t);return r.position.set(o,this.heightAt(o,a)+v(.3,1.2),a),this.add(r),{mesh:r,driftX:v(-.15,.15),driftZ:v(-.15,.15),spin:v(-.03,.03),baseOpacity:t,phase:v(0,Math.PI*2)}}makePerimeterPatch(e,t,o){const a=Lt(o),{x:r,z:i,driftX:l,driftZ:c}=_t(a,e,t),h=v(18,30),u=v(.1,.26),d=this.makeMesh(h,u);return d.position.set(r,this.heightAt(r,i)+v(.15,.55),i),this.add(d),{mesh:d,driftX:l,driftZ:c,spin:v(-.012,.012),baseOpacity:u,phase:v(0,Math.PI*2),perimeter:{edge:a,plotHalf:e,terrainHalf:t}}}makeMesh(e,t){const o=new n.Mesh(new n.PlaneGeometry(e,e),new n.MeshBasicMaterial({map:this.texture,transparent:!0,depthWrite:!1,opacity:t,toneMapped:!1}));return o.rotation.x=-Math.PI/2,o.rotation.z=v(0,Math.PI*2),o}}function Ut(s){const e=`#${new n.Color(s).getHexString()}`,t=document.createElement("canvas");t.width=t.height=256;const o=t.getContext("2d"),a=o.createRadialGradient(128,128,8,128,128,128);a.addColorStop(0,`${e}dd`),a.addColorStop(.45,`${e}66`),a.addColorStop(1,`${e}00`),o.fillStyle=a,o.fillRect(0,0,256,256);const r=new n.CanvasTexture(t);return r.colorSpace=n.SRGBColorSpace,r}function Nt(s){const e=[];return s.z>0&&e.push("n"),s.z<0&&e.push("s"),s.x>0&&e.push("w"),s.x<0&&e.push("e"),e.length?e:["n","w"]}function Lt(s){if(s.length===1)return s[0];const e=Math.random(),t=s.includes("n"),o=s.includes("w");return t&&o?e<.58?"n":"w":s[Math.floor(Math.random()*s.length)]}function _t(s,e,t){const o=v(.6,t-e-1.5),a=v(-t+3,t-3),r=v(.03,.09)*(Math.random()<.5?-1:1),i=v(.01,.04);switch(s){case"n":return{x:a,z:-e-o,driftX:r,driftZ:-i};case"s":return{x:a,z:e+o,driftX:-r,driftZ:i};case"e":return{x:e+o,z:a,driftX:i,driftZ:-r};case"w":return{x:-e-o,z:a,driftX:-i,driftZ:r}}}function Yt(s,e,t,o){const r=o-1,{x:i,z:l}=s.position;switch(e){case"n":{s.position.z=_(l,-r,-t+.8),i<-r+3&&(s.position.x=r-3),i>r-3&&(s.position.x=-r+3);break}case"s":{s.position.z=_(l,t-.8,r),i<-r+3&&(s.position.x=r-3),i>r-3&&(s.position.x=-r+3);break}case"e":{s.position.x=_(i,t-.8,r),l<-r+3&&(s.position.z=r-3),l>r-3&&(s.position.z=-r+3);break}case"w":{s.position.x=_(i,-r,-t+.8),l<-r+3&&(s.position.z=r-3),l>r-3&&(s.position.z=-r+3);break}}}function _(s,e,t){return Math.max(e,Math.min(t,s))}function he(s){const e=document.createElement("canvas");e.width=e.height=128;const t=e.getContext("2d"),o=`#${s.getHexString()}`,a=t.createRadialGradient(64,64,2,64,64,64);a.addColorStop(0,`${o}ff`),a.addColorStop(.25,`${o}aa`),a.addColorStop(1,`${o}00`),t.fillStyle=a,t.fillRect(0,0,128,128);const r=new n.CanvasTexture(e);return r.colorSpace=n.SRGBColorSpace,r}class Ht extends n.Object3D{mesh;texture;baseColor;constructor({color:e=16755268,size:t=1.2,opacity:o=.75}={}){super(),this.baseColor=new n.Color(e),this.texture=he(this.baseColor);const a=new n.MeshBasicMaterial({map:this.texture,color:this.baseColor,transparent:!0,opacity:o,blending:n.AdditiveBlending,depthWrite:!1,toneMapped:!1});this.mesh=new n.Mesh(new n.PlaneGeometry(t,t),a),this.add(this.mesh)}faceCamera(e){this.mesh.lookAt(e)}setOpacity(e){this.mesh.material.opacity=e}get opacity(){return this.mesh.material.opacity}setColor(e){this.baseColor.set(e),this.mesh.material.color.copy(this.baseColor),this.texture.dispose(),this.texture=he(this.baseColor),this.mesh.material.map=this.texture}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose(),this.texture.dispose()}}class qt{speed;minIntensity;maxIntensity;material;elapsed=0;constructor({material:e,speed:t=2,maxIntensity:o=.8,minIntensity:a=.2}){this.material=e,this.speed=t,this.maxIntensity=o,this.minIntensity=a}update(e){this.elapsed+=e;const t=Math.abs(Math.sin(this.elapsed*this.speed));this.material.emissiveIntensity=this.minIntensity+t*(this.maxIntensity-this.minIntensity)}}class Xt{level=0;light;peak;minGap;maxGap;spikes=[];clock=0;nextStrike;constructor({light:e,peak:t=12,minGap:o=3,maxGap:a=9}){this.light=e,this.peak=t,this.minGap=o,this.maxGap=a,this.nextStrike=v(o*.3,a)}update(e){this.clock+=e,this.clock>=this.nextStrike&&this.strike();let t=0;for(let o=this.spikes.length-1;o>=0;o--){const a=this.spikes[o],r=this.clock-a.at;if(r<0)continue;const i=a.amp*Math.exp(-r*9);i<.002&&r>0?this.spikes.splice(o,1):t+=i}this.level=Math.min(1.2,t),this.light.intensity=this.level*this.peak}quiet(){this.level=0,this.light.intensity=0}strike(){const e=Math.random()<.5?2:3;for(let t=0;t<e;t++)this.spikes.push({at:this.clock+t*v(.04,.12),amp:v(.5,1)});this.nextStrike=this.clock+v(this.minGap,this.maxGap)}}class ye extends n.BufferGeometry{constructor(e=.1){super();const t=[],o=[],a=[[0,1],[.5,.75],[.75,.25],[.5,-.5],[0,-1],[-.5,-.5],[-.75,.25],[-.5,.75]];for(let i=0;i<a.length;i++){const[l,c]=a[i];t.push(l*e,c*e,0)}for(let i=1;i<a.length-1;i++)o.push(0,i,i+1);o.push(0,a.length-1,1);const r=new n.Float32BufferAttribute(t,3);this.setAttribute("position",r),this.setIndex(o),this.computeVertexNormals()}}class Zt extends n.InstancedMesh{width;height;depth;floorY;flutter;px;py;pz;fallSpeed;driftX;driftZ;rotX;rotY;rotZ;phase;dummy=new n.Object3D;clock=0;constructor(e={}){const{count:t=120,width:o=16,height:a=8,depth:r=16,floorY:i=0,fallSpeedMin:l=.12,fallSpeedMax:c=.28,driftMin:h=.04,driftMax:u=.14,flutter:d=.35,color:m=[16766704,16774650,15775952],geometry:f=new ye,material:y}=e,p=(Array.isArray(m)?m:[m]).map(g=>new n.Color(g)),M=y??new n.MeshStandardMaterial({color:p.length===1?p[0].getHex():16777215,metalness:.05,roughness:.85,flatShading:!0,side:n.DoubleSide});super(f,M,t),this.instanceMatrix.setUsage(n.DynamicDrawUsage),this.frustumCulled=!1,this.width=o,this.height=a,this.depth=r,this.floorY=i,this.flutter=d,this.px=new Float32Array(t),this.py=new Float32Array(t),this.pz=new Float32Array(t),this.fallSpeed=new Float32Array(t),this.driftX=new Float32Array(t),this.driftZ=new Float32Array(t),this.rotX=new Float32Array(t),this.rotY=new Float32Array(t),this.rotZ=new Float32Array(t),this.phase=new Float32Array(t);for(let g=0;g<t;g++){this.respawn(g,!0),this.fallSpeed[g]=v(l,c);const x=v(h,u),S=v(0,Math.PI*2);this.driftX[g]=Math.cos(S)*x,this.driftZ[g]=Math.sin(S)*x,this.phase[g]=v(0,Math.PI*2),p.length>1&&this.setColorAt(g,p[Math.floor(Math.random()*p.length)])}this.instanceColor&&(this.instanceColor.needsUpdate=!0),this.writeMatrices()}update(e){this.clock+=e;for(let t=0;t<this.count;t++){const o=Math.sin(this.clock*1.6+this.phase[t])*this.flutter*.12;this.px[t]+=(this.driftX[t]+o)*e,this.py[t]-=this.fallSpeed[t]*e,this.pz[t]+=(this.driftZ[t]+Math.cos(this.clock*1.3+this.phase[t])*this.flutter*.08)*e,this.py[t]<this.floorY&&this.respawn(t,!1)}this.writeMatrices()}dispose(){this.geometry.dispose();const e=Array.isArray(this.material)?this.material:[this.material];for(const t of e)t.dispose();return this}respawn(e,t){this.px[e]=v(-this.width*.5,this.width*.5),this.pz[e]=v(-this.depth*.5,this.depth*.5),this.py[e]=t?this.floorY+v(this.height*.35,this.height):this.floorY+this.height+v(0,this.height*.25),this.rotX[e]=v(-.6,.6),this.rotY[e]=v(-Math.PI,Math.PI),this.rotZ[e]=v(-.8,.8)}writeMatrices(){const e=this.dummy;for(let t=0;t<this.count;t++){const o=Math.sin(this.clock*2.1+this.phase[t])*this.flutter,a=Math.cos(this.clock*1.7+this.phase[t])*this.flutter*.6;e.position.set(this.px[t],this.py[t],this.pz[t]),e.rotation.set(this.rotX[t]+o,this.rotY[t],this.rotZ[t]+a),e.updateMatrix(),this.setMatrixAt(t,e.matrix)}this.instanceMatrix.needsUpdate=!0}}function jt(){const s=document.createElement("canvas");s.width=8,s.height=64;const e=s.getContext("2d"),t=e.createLinearGradient(0,0,0,64);t.addColorStop(0,"rgba(255,255,255,0)"),t.addColorStop(.42,"rgba(255,255,255,0.55)"),t.addColorStop(.58,"rgba(255,255,255,0.55)"),t.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=t,e.fillRect(0,0,8,64);const o=new n.CanvasTexture(s);return o.colorSpace=n.SRGBColorSpace,o}class Wt extends n.InstancedMesh{intensity;maxCount;area;height;groundY;baseOpacity;windDirection;windStrength;fallDirection=new n.Vector3(0,-1,0);streakOrientation=new n.Quaternion;sx;sz;topY;len;speed;streakTexture;dummy=new n.Object3D;clock=0;constructor(e={}){const{count:t=1400,area:o=26,height:a=22,groundY:r=0,width:i=.009,color:l="#aebfd6",opacity:c=.16,lengthMin:h=.18,lengthMax:u=.42,speedMin:d=11,speedMax:m=19,windDirection:f=0,windStrength:y=0,intensity:p=.5,geometry:M=new n.PlaneGeometry(i,1),material:g}=e,x=g?void 0:jt(),S=g??new n.MeshBasicMaterial({color:new n.Color(l),map:x,transparent:!0,opacity:c,depthWrite:!1,toneMapped:!1,fog:!0,side:n.DoubleSide});super(M,S,t),this.instanceMatrix.setUsage(n.DynamicDrawUsage),this.frustumCulled=!1,this.maxCount=t,this.area=o,this.height=a,this.groundY=r,this.baseOpacity=c,this.windDirection=f,this.windStrength=Math.max(0,y),this.updateFallDirection(0),this.intensity=p,this.streakTexture=x,this.sx=new Float32Array(t),this.sz=new Float32Array(t),this.topY=new Float32Array(t),this.len=new Float32Array(t),this.speed=new Float32Array(t);for(let w=0;w<t;w++)this.sx[w]=v(-o,o),this.sz[w]=v(-o,o),this.topY[w]=v(r,r+a),this.len[w]=v(h,u),this.speed[w]=v(d,m);this.writeMatrices(),this.applyIntensity()}update(e){this.clock+=e;const t=this.windStrength>0?Math.sin(this.clock*.18)*.04*this.windStrength:0;this.updateFallDirection(t);const o=.85+this.intensity*.7,a=this.groundY+this.height,r=this.fallDirection.x,i=this.fallDirection.z,l=-this.fallDirection.y;for(let c=0;c<this.maxCount;c++){const h=this.speed[c]*o*e;this.sx[c]+=r*h,this.sz[c]+=i*h,this.topY[c]-=l*h,this.topY[c]<this.groundY-this.len[c]&&(this.topY[c]+=this.height),this.topY[c]>a&&(this.topY[c]-=this.height),this.sx[c]<-this.area?this.sx[c]+=this.area*2:this.sx[c]>this.area&&(this.sx[c]-=this.area*2),this.sz[c]<-this.area?this.sz[c]+=this.area*2:this.sz[c]>this.area&&(this.sz[c]-=this.area*2)}this.writeMatrices(),this.applyIntensity()}dispose(){this.geometry.dispose();const e=Array.isArray(this.material)?this.material:[this.material];for(const t of e)t.dispose();return this.streakTexture?.dispose(),this}applyIntensity(){this.count=Math.round(this.maxCount*Math.min(1,Math.max(0,.38+this.intensity*.62)));const e=this.material;e.opacity=this.baseOpacity*(.55+.65*this.intensity)}updateFallDirection(e){const t=this.windStrength+e;if(t<=0){this.fallDirection.set(0,-1,0),this.streakOrientation.identity();return}const o=t,a=1,r=1/Math.hypot(o,a);this.fallDirection.set(Math.cos(this.windDirection)*o*r,-a*r,Math.sin(this.windDirection)*o*r),this.streakOrientation.setFromUnitVectors(new n.Vector3(0,1,0),this.fallDirection)}writeMatrices(){const e=this.dummy;for(let t=0;t<this.maxCount;t++){const o=this.len[t];e.position.set(this.sx[t],this.topY[t]-o/2,this.sz[t]),e.quaternion.copy(this.streakOrientation),e.scale.set(1,o,1),e.updateMatrix(),this.setMatrixAt(t,e.matrix)}this.instanceMatrix.needsUpdate=!0}}class Kt extends n.Object3D{wisps=[];orbGeometry;orbMaterial;halfWidth;depth;heightMin;heightMax;driftX;driftY;driftZ;speedMin;speedMax;castLight;lightDistance;lightDecay;lightIntensity;lightPulseAmplitude;lightPulseSpeed;elapsed=0;constructor({count:e=3,width:t=16,depth:o=8,heightMin:a=1,heightMax:r=2,color:i=7208880,orbRadius:l=.08,driftX:c=1.6,driftY:h=.3,driftZ:u=1.6,speedMin:d=.3,speedMax:m=.7,castLight:f=!0,lightDistance:y=6,lightDecay:p=2,lightIntensity:M=2.5,lightPulseAmplitude:g=1.2,lightPulseSpeed:x=3}={}){super(),this.halfWidth=t/2,this.depth=o,this.heightMin=a,this.heightMax=r,this.driftX=c,this.driftY=h,this.driftZ=u,this.speedMin=d,this.speedMax=m,this.castLight=f,this.lightDistance=y,this.lightDecay=p,this.lightIntensity=M,this.lightPulseAmplitude=g,this.lightPulseSpeed=x,this.orbGeometry=new n.SphereGeometry(l,8,8),this.orbMaterial=new n.MeshBasicMaterial({color:new n.Color(i),toneMapped:!1});for(let S=0;S<e;S++){const w=new n.Vector3(v(-this.halfWidth,this.halfWidth),v(this.heightMin,this.heightMax),v(0,this.depth)),G=new n.Mesh(this.orbGeometry,this.orbMaterial);G.position.copy(w),this.add(G);let b;f&&(b=new n.PointLight(i,3,this.lightDistance,this.lightDecay),G.add(b)),this.wisps.push({orb:G,home:w,phase:v(0,Math.PI*2),speed:v(this.speedMin,this.speedMax),light:b})}}update(e){this.elapsed+=e;for(const t of this.wisps){const o=this.elapsed*t.speed+t.phase;t.orb.position.set(t.home.x+Math.sin(o)*this.driftX,t.home.y+Math.sin(o*1.7)*this.driftY,t.home.z+Math.cos(o*.8)*this.driftZ),t.light&&(t.light.intensity=this.lightIntensity+Math.sin(o*this.lightPulseSpeed)*this.lightPulseAmplitude)}}dispose(){this.orbGeometry.dispose(),this.orbMaterial.dispose();for(const e of this.wisps)e.light?.dispose();this.clear(),this.wisps.length=0}}class Me extends n.Shape{constructor(e=5,t=.5,o=1){super();const a=Math.PI*2/e,r=a/2,i=a/4;this.moveTo(Math.cos(0)*o,-Math.sin(0)*o);for(let l=1;l<=e;++l){let c=Math.cos(a*l-i*3)*(t/Math.cos(i)),h=-Math.sin(a*l-i*3)*(t/Math.cos(i)),u=Math.cos(a*l-r)*t,d=-Math.sin(a*l-r)*t;this.quadraticCurveTo(c,h,u,d),c=Math.cos(a*l-i)*(t/Math.cos(i)),h=-Math.sin(a*l-i)*(t/Math.cos(i)),u=Math.cos(a*l)*o,d=-Math.sin(a*l)*o,this.quadraticCurveTo(c,h,u,d)}this.closePath()}}class se extends n.ExtrudeGeometry{constructor(e=5,t=.5,o=1,a=.25){const r=new Me(e,t,o);super(r,{depth:a,bevelEnabled:!1})}}const Qt=new n.Vector3(0,0,0);function $t(s,e,t,o=128){const a=document.createElement("canvas");a.width=o,a.height=o;const r=a.getContext("2d"),i=o*.46,l=i*(e/t);r.translate(o/2,o/2),r.fillStyle="#ffffff",r.beginPath();for(let h=0;h<s*2;h++){const u=h%2===0?i:l,d=h/(s*2)*Math.PI*2-Math.PI/2,m=Math.cos(d)*u,f=Math.sin(d)*u;h===0?r.moveTo(m,f):r.lineTo(m,f)}r.closePath(),r.fill();const c=new n.CanvasTexture(a);return c.needsUpdate=!0,c}function ue(s){const e=Math.random(),t=Math.random(),o=Math.PI*2*e,a=Math.acos(2*t-1),r=Math.sin(a);return s.set(r*Math.cos(o),Math.cos(a),r*Math.sin(o))}function de(s){return(Array.isArray(s)?s:[s]).map(e=>new n.Color(e))}class Jt extends n.Object3D{style;field;twinkle;baseSize;baseScales;twinklePhases;spriteTexture;dummy=new n.Object3D;constructor(e={}){super(),this.style=e.style??"points";const{count:t=1500,radius:o=500,minRadius:a=o,maxRadius:r=o,sizeMin:i=.008,sizeMax:l=.025,color:c=[16777215,13293567,16774368],twinkle:h=!1,material:u,burst:d={},geometry:m}=e;this.frustumCulled=!1,this.twinkle=h;const f=Math.max(r-a,0),y=a+f*.5,p=(i+l)*.5;this.baseSize=y*p;const M={sides:d.sides??4,innerRadius:d.innerRadius??.6,outerRadius:d.outerRadius??1.9,depth:d.depth??.05};if(this.style==="burst"){h&&(this.baseScales=new Float32Array(t),this.twinklePhases=new Float32Array(t));const g=m??new se(M.sides,M.innerRadius,M.outerRadius,M.depth);this.field=this.createBurstField({count:t,minRadius:a,maxRadius:r,sizeMin:i,sizeMax:l,color:c,material:u,geometry:g})}else this.field=this.createPointsField({count:t,minRadius:a,maxRadius:r,sizeMin:i,sizeMax:l,color:c,material:u,burstShape:M});this.add(this.field)}get drawable(){return this.field}get geometry(){return this.field.geometry}get material(){return this.field.material}dispose(){this.geometry.dispose();const e=Array.isArray(this.material)?this.material:[this.material];for(const t of e)t.dispose();this.spriteTexture?.dispose()}update(e=performance.now()*.001){if(!this.twinkle)return;if(this.field instanceof n.Points){this.field.material.size=this.baseSize*(.8+.2*Math.sin(e*2.5));return}if(!this.baseScales||!this.twinklePhases)return;const t=new n.Matrix4,o=new n.Vector3,a=new n.Quaternion,r=new n.Vector3;for(let i=0;i<this.field.count;i++){this.field.getMatrixAt(i,t),t.decompose(o,a,r);const l=.75+.25*Math.sin(e*2.5+this.twinklePhases[i]),c=this.baseScales[i]*l;this.dummy.position.copy(o),this.dummy.quaternion.copy(a),this.dummy.scale.setScalar(c),this.dummy.updateMatrix(),this.field.setMatrixAt(i,this.dummy.matrix)}this.field.instanceMatrix.needsUpdate=!0}createPointsField({count:e,minRadius:t,maxRadius:o,sizeMin:a,sizeMax:r,color:i,material:l,burstShape:c}){const h=de(i),u=new n.Vector3,d=Math.max(o-t,0),m=t+d*.5,f=(a+r)/2,y=m*f,p=new Float32Array(e*3),M=h.length>1?new Float32Array(e*3):null;for(let w=0;w<e;w++){const G=t+Math.random()*d;if(ue(u).multiplyScalar(G),p[w*3]=u.x,p[w*3+1]=u.y,p[w*3+2]=u.z,M){const b=h[Math.floor(Math.random()*h.length)];M[w*3]=b.r,M[w*3+1]=b.g,M[w*3+2]=b.b}}const g=new n.BufferGeometry;g.setAttribute("position",new n.BufferAttribute(p,3)),M&&g.setAttribute("color",new n.BufferAttribute(M,3)),this.spriteTexture=$t(c.sides,c.innerRadius,c.outerRadius);const x=l??new n.PointsMaterial({map:this.spriteTexture,color:h.length===1?h[0].getHex():16777215,size:y,sizeAttenuation:!0,transparent:!0,alphaTest:.05,vertexColors:M!==null,depthWrite:!1,toneMapped:!1}),S=new n.Points(g,x);return S.frustumCulled=!1,S.renderOrder=1,S}createBurstField({count:e,minRadius:t,maxRadius:o,sizeMin:a,sizeMax:r,color:i,material:l,geometry:c}){const h=de(i),u=new n.Vector3,d=Math.max(o-t,0),m=c.clone();m.center(),m.computeBoundingSphere();const f=m.boundingSphere?.radius??1,y=l??new n.MeshBasicMaterial({color:h.length===1?h[0].getHex():16777215,side:n.DoubleSide,depthWrite:!1,toneMapped:!1}),p=new n.InstancedMesh(m,y,e);p.frustumCulled=!1,p.renderOrder=1;for(let M=0;M<e;M++){const g=t+Math.random()*d;ue(u).multiplyScalar(g);const x=a+Math.random()*(r-a),S=g*x/f;this.baseScales&&(this.baseScales[M]=S),this.twinklePhases&&(this.twinklePhases[M]=Math.random()*Math.PI*2),this.dummy.position.copy(u),this.dummy.lookAt(Qt),this.dummy.rotateZ(Math.random()*Math.PI*2),this.dummy.scale.setScalar(S),this.dummy.updateMatrix(),p.setMatrixAt(M,this.dummy.matrix),h.length>1&&p.setColorAt(M,h[Math.floor(Math.random()*h.length)])}return p.instanceMatrix.needsUpdate=!0,p.instanceColor&&(p.instanceColor.needsUpdate=!0),p}}const P=(s,e)=>{const t=s[0].index!==null,o=new Set(Object.keys(s[0].attributes)),a=new Set(Object.keys(s[0].morphAttributes)),r={},i={},l=s[0].morphTargetsRelative,c=new n.BufferGeometry;let h=0;if(s.forEach((u,d)=>{let m=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in u.attributes){if(!o.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;r[f]===void 0&&(r[f]=[]),r[f].push(u.attributes[f]),m++}if(m!==o.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(l!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in u.morphAttributes){if(!a.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;i[f]===void 0&&(i[f]=[]),i[f].push(u.morphAttributes[f])}if(c.userData.mergedUserData=c.userData.mergedUserData||[],c.userData.mergedUserData.push(u.userData),e){let f;if(u.index)f=u.index.count;else if(u.attributes.position!==void 0)f=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(h,f,d),h+=f}}),t){let u=0;const d=[];s.forEach(m=>{const f=m.index;for(let y=0;y<f.count;++y)d.push(f.getX(y)+u);u+=m.attributes.position.count}),c.setIndex(d)}for(let u in r){const d=me(r[u]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;c.setAttribute(u,d)}for(let u in i){const d=i[u][0].length;if(d===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[u]=[];for(let m=0;m<d;++m){const f=[];for(let p=0;p<i[u].length;++p)f.push(i[u][p][m]);const y=me(f);if(!y)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;c.morphAttributes[u].push(y)}}return c},me=s=>{let e,t,o,a=0;if(s.forEach(r=>{if(e===void 0&&(e=r.array.constructor),e!==r.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=r.itemSize),t!==r.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(o===void 0&&(o=r.normalized),o!==r.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;a+=r.array.length}),e&&t){const r=new e(a);let i=0;return s.forEach(l=>{r.set(l.array,i),i+=l.array.length}),new n.BufferAttribute(r,t,o)}};function es(s,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},o=s.getIndex(),a=s.getAttribute("position"),r=o?o.count:a.count;let i=0;const l=Object.keys(s.attributes),c={},h={},u=[],d=["getX","getY","getZ","getW"];for(let p=0,M=l.length;p<M;p++){const g=l[p];c[g]=[];const x=s.morphAttributes[g];x&&(h[g]=new Array(x.length).fill(0).map(()=>[]))}const m=Math.log10(1/e),f=Math.pow(10,m);for(let p=0;p<r;p++){const M=o?o.getX(p):p;let g="";for(let x=0,S=l.length;x<S;x++){const w=l[x],G=s.getAttribute(w),b=G.itemSize;for(let T=0;T<b;T++)g+=`${~~(G[d[T]](M)*f)},`}if(g in t)u.push(t[g]);else{for(let x=0,S=l.length;x<S;x++){const w=l[x],G=s.getAttribute(w),b=s.morphAttributes[w],T=G.itemSize,I=c[w],U=h[w];for(let E=0;E<T;E++){const F=d[E];if(I.push(G[F](M)),b)for(let C=0,L=b.length;C<L;C++)U[C].push(b[C][F](M))}}t[g]=i,u.push(i),i++}}const y=s.clone();for(let p=0,M=l.length;p<M;p++){const g=l[p],x=s.getAttribute(g),S=new x.array.constructor(c[g]),w=new n.BufferAttribute(S,x.itemSize,x.normalized);if(y.setAttribute(g,w),g in h)for(let G=0;G<h[g].length;G++){const b=s.morphAttributes[g][G],T=new b.array.constructor(h[g][G]),I=new n.BufferAttribute(T,b.itemSize,b.normalized);y.morphAttributes[g][G]=I}}return y.setIndex(u),y}class ts extends n.BufferGeometry{constructor(e=(a,r,i)=>i.set(a,r,Math.cos(a)*Math.sin(r)),t=8,o=8){super(),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:o};const a=[],r=[],i=[],l=[],c=1e-5,h=new n.Vector3,u=new n.Vector3,d=new n.Vector3,m=new n.Vector3,f=new n.Vector3,y=t+1;for(let p=0;p<=o;p++){const M=p/o;for(let g=0;g<=t;g++){const x=g/t;e(x,M,u),r.push(u.x,u.y,u.z),x-c>=0?(e(x-c,M,d),m.subVectors(u,d)):(e(x+c,M,d),m.subVectors(d,u)),M-c>=0?(e(x,M-c,d),f.subVectors(u,d)):(e(x,M+c,d),f.subVectors(d,u)),h.crossVectors(m,f).normalize(),i.push(h.x,h.y,h.z),l.push(x,M)}}for(let p=0;p<o;p++)for(let M=0;M<t;M++){const g=p*y+M,x=p*y+M+1,S=(p+1)*y+M+1,w=(p+1)*y+M;a.push(g,x,w),a.push(x,S,w)}this.setIndex(a),this.setAttribute("position",new n.Float32BufferAttribute(r,3)),this.setAttribute("normal",new n.Float32BufferAttribute(i,3)),this.setAttribute("uv",new n.Float32BufferAttribute(l,2))}}class oe extends n.BufferGeometry{constructor(e=1,t=1.5,o=.5,a=.05,r=.05){super();const i=e,l=t,c=o,h=a,u=r,d=[0,0,0,i,0,0,i,l,0,0,l,0,i,0,-c,0,0,-c,0,l,-c,i,l,-c,0,0,-c,0,0,0,0,l,0,0,l,-c,i,0,-h,h,0,-h,h,l,-h,i,l,-h,h,0,-c+h,i,0,-c+h,i,l,-c+h,h,l,-c+h,h,0,-h,h,0,-c+h,h,l,-c+h,h,l,-h,0,l,0,i,l,0,i,l,-h,h,l,-h,0,l,-c,h,l,-c+h,i,l,-c+h,i,l,-c,0,l,0,h,l,-h,h,l,-c+h,0,l,-c,0,0,0,h,0,-h,i,0,-h,i,0,0,0,0,-c,i,0,-c,i,0,-c+h,h,0,-c+h,0,0,0,0,0,-c,h,0,-c+h,h,0,-h,i,0,0,i,0,-h,i,l,-h,i,l,0,i,0,-c,i,l,-c,i,l,-c+h,i,0,-c+h],m=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0],f=e/(e*2+o),y=(e+o)/(e*2+o),p=[y,0,1,0,1,1,y,1,0,0,f,0,f,1,0,1,f,0,y,0,y,1,f,1,1,0,y,0,y,1,1,1,f,0,0,0,0,1,f,1,y,0,f,0,f,1,y,1,y,0,1,0,1,1,y,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1],M=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23,24,25,26,24,26,27,28,29,30,28,30,31,32,33,34,32,34,35,36,37,38,36,38,39,40,41,42,40,42,43,44,45,46,44,46,47,48,49,50,48,50,51,52,53,54,52,54,55],g=new Float32Array(d),x=new Float32Array(m),S=new Float32Array(p),w=new Uint16Array(M),G=new n.BufferGeometry;G.setAttribute("position",new n.BufferAttribute(g,3)),G.setAttribute("normal",new n.BufferAttribute(x,3)),G.setAttribute("uv",new n.BufferAttribute(S,2)),G.setIndex(new n.BufferAttribute(w,1));const b=new n.BoxGeometry(e-h-u,l-u*2,c-h*2);b.translate((e-h-u)/2+h,l/2,-c/2),this.copy(P([G,b],!0))}}function ge({scaleXMin:s=.4,scaleXMax:e=.7,scaleYMin:t=.3,scaleYMax:o=.95,scaleZMin:a=.1,scaleZMax:r=.5}={}){return new n.Vector3(v(s,e),fe(.25,t,o),pe(.8,a,r))}function re({coverMaterial:s,pagesMaterial:e,scales:t}){const o=new oe,a=new n.InstancedMesh(o,[s,e],t.length),r=new n.Matrix4;let i=0;for(let l=0;l<t.length;l++){const c=t[l],h=new n.Matrix4;h.makeScale(c.x,c.y,c.z),r.identity(),r.multiply(h),r.setPosition(.01+Math.random()*.1,0,i+c.z*.5),a.setMatrixAt(l,r),i+=c.z*.5}return a}function ss({coverMaterial:s,pagesMaterial:e,count:t=10,scaleXMin:o=.4,scaleXMax:a=.7,scaleYMin:r=.3,scaleYMax:i=.95,scaleZMin:l=.1,scaleZMax:c=.5}){const h=Array.from({length:t},()=>ge({scaleXMin:o,scaleXMax:a,scaleYMin:r,scaleYMax:i,scaleZMin:l,scaleZMax:c}));return re({coverMaterial:s,pagesMaterial:e,scales:h})}function os({coverMaterial:s,pagesMaterial:e,length:t=10,scaleXMin:o=.4,scaleXMax:a=.7,scaleYMin:r=.3,scaleYMax:i=.95,scaleZMin:l=.1,scaleZMax:c=.5}){const h=[];let u=t;for(;u>0;){const d=ge({scaleXMin:o,scaleXMax:a,scaleYMin:r,scaleYMax:i,scaleZMin:l,scaleZMax:c});d.z=Math.min(d.z,u),h.push(d),u-=d.z}return re({coverMaterial:s,pagesMaterial:e,scales:h})}class xe extends n.BufferGeometry{constructor({width:e=.8,height:t=.3,depth:o=.4}={}){super();const a=e/2,r=t/2,i=o/2,l=new Float32Array([-a,-r,i,a,-r,i,a,r,i,-a,r,i,-a,-r,-i,a,-r,-i,a,r,-i,-a,r,-i,-a,-r,-i,-a,-r,i,-a,r,i,-a,r,-i,a,-r,i,a,-r,-i,a,r,-i,a,r,i,-a,r,i,a,r,i,a,r,-i,-a,r,-i,-a,-r,i,a,-r,i,a,-r,-i,-a,-r,-i]),c=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,-1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0]),h=new Uint16Array([0,1,2,2,3,0,5,4,7,7,6,5,9,8,11,11,10,9,12,13,14,14,15,12,16,17,18,18,19,16,21,20,23,23,22,21]),u=new Float32Array([0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1]);this.setAttribute("position",new n.BufferAttribute(l,3)),this.setAttribute("normal",new n.BufferAttribute(c,3)),this.setAttribute("uv",new n.BufferAttribute(u,2)),this.setIndex(new n.BufferAttribute(h,1))}}function rs({wallWidth:s=10,wallHeight:e=8,brickWidth:t=.8,brickHeight:o=.3,brickDepth:a=.4,mortarGap:r=.05,offsetPattern:i=!0,brickColors:l=[9127187,10506797,7025680],colorVariation:c=!0,positionVariation:h=.02,rotationVariation:u=.01,material:d}={}){const m=d||new n.MeshStandardMaterial({color:9127187}),f=t+r,y=o+r,p=Math.floor(s/f),M=Math.floor(e/y),g=p*M,x=new xe({width:t,height:o,depth:a}),S=new n.InstancedMesh(x,m,g);let w;c&&l.length>0&&(w=new Float32Array(g*3));const G=new n.Matrix4,b=new n.Vector3,T=new n.Euler,I=new n.Quaternion,U=new n.Vector3(1,1,1);let E=0;for(let F=0;F<M;F++){const C=F*y-e/2+o/2;let L=0;i&&F%2===1&&(L=f/2);for(let K=0;K<p;K++){const le=K*f-s/2+t/2+L;if(!(Math.abs(le)>s/2)){if(b.set(le,C,0),h>0&&(b.x+=(Math.random()-.5)*h,b.y+=(Math.random()-.5)*h,b.z+=(Math.random()-.5)*h),T.set(0,0,0),u>0&&(T.x=(Math.random()-.5)*u,T.y=(Math.random()-.5)*u,T.z=(Math.random()-.5)*u),I.setFromEuler(T),G.compose(b,I,U),S.setMatrixAt(E,G),w){const vt=Math.floor(Math.random()*l.length),Q=new n.Color(l[vt]);w[E*3]=Q.r,w[E*3+1]=Q.g,w[E*3+2]=Q.b}E++}}}return w&&m instanceof n.MeshStandardMaterial&&(x.setAttribute("color",new n.InstancedBufferAttribute(w,3)),m.vertexColors=!0),S.count=E,S}class we extends n.Shape{constructor(e=1){super();for(let t=0;t<6;t++){const o=Math.PI/3*t,a=Math.cos(o)*e,r=Math.sin(o)*e;t===0?this.moveTo(a,r):this.lineTo(a,r)}this.closePath()}}class W extends n.ExtrudeGeometry{constructor(e=1,t=.01){const o=new we(e);super(o,{depth:t,bevelEnabled:!1})}}function ns(s){const{width:e,depth:t,height:o,count:a,gap:r,material:i}=s,l=i||new n.MeshStandardMaterial({color:16777215}),c=e/a,h=(c-r)*2/3,u=Math.sqrt(3)*h+r,d=Math.floor(t/u),m=a*d,f=new W(h,o);f.rotateX(-Math.PI/2);const y=new n.InstancedMesh(f,l,m),p=new n.Object3D;let M=0;for(let g=0;g<a;g++)for(let x=0;x<d;x++){const S=g*c,w=x*u+g%2*(u/2),G=S-a*c/2+c/2,b=w-d*u/2+u/2;p.position.set(G,0,b),p.updateMatrix(),y.setMatrixAt(M++,p.matrix)}return y.instanceMatrix.needsUpdate=!0,y}function as(s){const{width:e,depth:t,height:o,radius:a,gap:r,material:i}=s,l=i||new n.MeshStandardMaterial({color:16777215}),c=a*3/2+r,h=Math.sqrt(3)*a+r,u=Math.floor(e/c),d=Math.floor(t/h),m=u*d,f=new W(a,o);f.rotateX(-Math.PI/2);const y=new n.InstancedMesh(f,l,m),p=new n.Object3D;let M=0;for(let g=0;g<u;g++)for(let x=0;x<d;x++){const S=g*c,w=x*h+g%2*(h/2),G=S-u*c/2+c/2,b=w-d*h/2+h/2;p.position.set(G,0,b),p.updateMatrix(),y.setMatrixAt(M++,p.matrix)}return y.instanceMatrix.needsUpdate=!0,y}class is extends n.BufferGeometry{constructor(e=2,t=.3,o=.6,a=5,r=5,i=Math.PI/4){super();const l=[],c=[];for(let f=0;f<a;f++){const y=f*t,p=y+t,M=f*o,g=M+o;l.push(-e/2,y,M,e/2,y,M,e/2,p,M,-e/2,p,M,-e/2,p,M,e/2,p,M,e/2,p,g,-e/2,p,g);const x=f*8;c.push(x,x+1,x+2,x,x+2,x+3),c.push(x+4,x+5,x+6,x+4,x+6,x+7)}const h=a*t,u=a*o,d=e*2;l.push(-d/2,h,u,d/2,h,u,d/2,h,u+o,-d/2,h,u+o);const m=a*8;c.push(m,m+1,m+2,m,m+2,m+3);for(let f=0;f<2;f++){const y=f===0?1:-1;for(let p=0;p<r;p++){const M=h+p*t,g=M+t,x=y*(d/4),S=u+o,w=p*o*Math.cos(i),G=p*o*Math.sin(i),b=x+y*w-e/2*Math.cos(i),T=x+y*w+e/2*Math.cos(i),I=S+G,U=b+y*o*Math.cos(i),E=T+y*o*Math.cos(i),F=I+o*Math.sin(i);l.push(b,M,I,T,M,I,T,g,I,b,g,I,b,g,I,T,g,I,E,g,F,U,g,F);const C=m+4+f*r*8+p*8;c.push(C,C+1,C+2,C,C+2,C+3),c.push(C+4,C+5,C+6,C+4,C+6,C+7)}}this.setIndex(c),this.setAttribute("position",new n.Float32BufferAttribute(l,3)),this.computeVertexNormals()}}class ve extends n.BufferGeometry{constructor({width:e=5,height:t=3,depth:o=5,wallThickness:a=.05}={}){super();const r=e,i=t,l=o,c=a,h=[0,0,0,r,0,0,r,i,0,0,i,0,0,0,l,0,0,0,0,i,0,0,i,l,0,0,l,r,0,l,r,0,0,0,0,0,-c,-c,l,r,-c,l,r,0,l,0,0,l,r,-c,l,r,-c,-c,r,0,0,r,0,l,-c,-c,l,0,0,l,0,i,l,-c,i,l,r,0,0,r,-c,-c,r,i,-c,r,i,0,-c,i,l,0,i,l,0,i,0,-c,i,-c,0,i,0,r,i,0,r,i,-c,-c,i,-c,-c,-c,-c,r,-c,-c,r,-c,l,-c,-c,l,-c,-c,-c,-c,-c,l,-c,i,l,-c,i,-c,r,-c,-c,-c,-c,-c,-c,i,-c,r,i,-c],u=[0,1,3,1,2,3,4,5,7,5,6,7,8,9,11,9,10,11,12,13,15,13,14,15,16,17,19,17,18,19,20,21,23,21,22,23,24,25,27,25,26,27,28,29,31,29,30,31,32,33,35,33,34,35,36,37,39,37,38,39,40,41,43,41,42,43,44,45,47,45,46,47],d=[0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1],m=[.5,0,1,0,1,1,.5,1,0,0,.5,0,.5,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,c/r,0,c/r,0,0,1,0,1,c/r,0,c/r,0,0,c/r,0,c/r,1,0,1,1-c/r,0,1,0,1,1,1-c/r,1,0,0,c/r,0,c/r,1,0,1,0,1-c/r,1,1-c/r,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1],f=new Float32Array(h),y=new Float32Array(d),p=new Float32Array(m);this.setAttribute("position",new n.BufferAttribute(f,3)),this.setAttribute("normal",new n.BufferAttribute(y,3)),this.setAttribute("uv",new n.BufferAttribute(p,2)),this.setIndex(u),this.addGroup(0,12,0),this.addGroup(12,6,1),this.addGroup(18,54,2)}}class cs extends n.BufferGeometry{constructor(e=2,t=.3,o=.5,a=5,r=2){super();const i=[],l=[];for(let d=0;d<a;d++){const m=d*t,f=m+t,y=d*o,p=y+o;i.push(-e/2,m,y,e/2,m,y,e/2,f,y,-e/2,f,y,-e/2,f,y,e/2,f,y,e/2,f,p,-e/2,f,p);const M=d*8;l.push(M,M+1,M+2,M,M+2,M+3),l.push(M+4,M+5,M+6,M+4,M+6,M+7)}const c=a*t,h=a*o;i.push(-e/2,c,h,e/2,c,h,e/2,c,h+r,-e/2,c,h+r);const u=a*8;l.push(u,u+1,u+2,u,u+2,u+3);for(let d=0;d<a;d++){const m=c+d*t,f=m+t,y=-e/2-d*o,p=y-o;i.push(y,m,h+r,y,m,h+r-e,y,f,h+r-e,y,f,h+r,y,f,h+r,y,f,h+r-e,p,f,h+r-e,p,f,h+r);const M=u+4+d*8;l.push(M,M+1,M+2,M,M+2,M+3),l.push(M+4,M+5,M+6,M+4,M+6,M+7)}this.setIndex(l),this.setAttribute("position",new n.Float32BufferAttribute(i,3)),this.computeVertexNormals()}}class ls extends n.BufferGeometry{constructor(e=1,t=.4,o=.2,a=20,r=2,i=Math.PI/8){super();const l=[],c=[];let h=0;for(let u=0;u<a;u++){const d=r*Math.cos(h),m=r*Math.sin(h),f=u*o,y=f+o;l.push(d-e/2*Math.cos(h),f,m-e/2*Math.sin(h),d+e/2*Math.cos(h),f,m+e/2*Math.sin(h),d+e/2*Math.cos(h),y,m+e/2*Math.sin(h),d-e/2*Math.cos(h),y,m-e/2*Math.sin(h)),l.push(d-e/2*Math.cos(h),y,m-e/2*Math.sin(h),d+e/2*Math.cos(h),y,m+e/2*Math.sin(h),d+e/2*Math.cos(h)-t*Math.sin(h),y,m+e/2*Math.sin(h)+t*Math.cos(h),d-e/2*Math.cos(h)-t*Math.sin(h),y,m-e/2*Math.sin(h)+t*Math.cos(h));const p=u*8;c.push(p,p+1,p+2,p,p+2,p+3),c.push(p+4,p+5,p+6,p+4,p+6,p+7),h+=i}this.setIndex(c),this.setAttribute("position",new n.Float32BufferAttribute(l,3)),this.computeVertexNormals()}}class hs extends n.BufferGeometry{constructor(e=2,t=.3,o=.5,a=10){super();const r=[],i=[];for(let l=0;l<a;l++){const c=l*t,h=c+t,u=l*o,d=u+o;r.push(-e/2,c,u,e/2,c,u,e/2,h,u,-e/2,h,u,-e/2,h,u,e/2,h,u,e/2,h,d,-e/2,h,d);const m=l*8;i.push(m,m+1,m+2,m,m+2,m+3),i.push(m+4,m+6,m+5,m+4,m+7,m+6)}this.setIndex(i),this.setAttribute("position",new n.Float32BufferAttribute(r,3)),this.computeVertexNormals()}}class Se extends n.BufferGeometry{constructor(){super();const e=[new n.Vector2(0,0),new n.Vector2(1.2,0),new n.Vector2(1.5,1.5),new n.Vector2(1,3),new n.Vector2(.6,3.5),new n.Vector2(.5,3.5)],t=new n.LatheGeometry(e,10),o=new n.CylinderGeometry(.6,.5,.3,10);o.translate(0,3.5,0),this.copy(P([t,o],!0))}}function ne(s,e,t,o,a){const r=(o-e)/(t-s);return s+(a-e)/r}function be(s,e,t,o,a){const r=(o-e)/(t-s);return e+r*(a-s)}const us={calculateXFromSlopeIntercept:ne,calculateYFromSlopeIntercept:be};class Ge extends n.BufferGeometry{constructor(){super();const e=[new n.Vector2(0,0),new n.Vector2(.8,0),new n.Vector2(1,1.5),new n.Vector2(.5,2.2),new n.Vector2(.6,2.5),new n.Vector2(.5,2.5)],t=new n.LatheGeometry(e,10),o=new n.CylinderGeometry(.55,.45,.2,10);o.translate(0,2.5,0);const a=[new n.Vector2(0,0),new n.Vector2(.8,0),new n.Vector2(ne(.8,0,1,1.5,1),1),new n.Vector2(0,1)],r=new n.LatheGeometry(a,10);r.translate(0,.1,0),r.scale(.9,.9,.9),this.copy(P([t,o,r],!0))}}class Pe extends n.BufferGeometry{constructor({radius:e=.5,neckRadius:t=.2,height:o=3,neckHeight:a=1,segments:r=16}={}){super();const i=o-a,l=new n.CylinderGeometry(e,e,i,r);l.translate(0,i/2,0);const c=.3,h=new n.CylinderGeometry(t,e,c,r);h.translate(0,i+c/2,0);const u=new n.CylinderGeometry(t,t,a,r);u.translate(0,i+c+a/2,0),this.copy(P([l,h,u],!1))}}class Ae extends n.BufferGeometry{constructor(e=.4,t=1.2,o=.2){super();const a=t*.6,r=new n.BoxGeometry(e/2,a,o);r.translate(0,a/2,0);const i=e*1.5,l=new n.BoxGeometry(i,e/4,o);l.translate(0,a*.75,0),this.copy(P([r,l],!1)),this.computeVertexNormals()}}class Ce extends n.BufferGeometry{constructor(){super();const e=new n.BoxGeometry(5,1,5);e.translate(0,.5,0);const t=new n.BoxGeometry(4,3,4);t.translate(0,2.5,0);const o=[[-1.8,2.3,-2.2],[1.8,2.3,-2.2],[-1.8,2.3,2.2],[1.8,2.3,2.2]],a=[];o.forEach(h=>{const u=new n.CylinderGeometry(.2,.2,3.5,16);u.translate(h[0],h[1],h[2]),a.push(u)});const r=new n.ConeGeometry(3.5,2,4);r.rotateY(Math.PI/4),r.translate(0,5,0);const i=new n.Shape;i.moveTo(-1,0),i.lineTo(-1,2),i.absarc(0,2,1,Math.PI,0,!0),i.lineTo(1,0);const l={depth:.5,bevelEnabled:!1},c=new n.ExtrudeGeometry(i,l);c.translate(0,.5,1.7),c.setIndex([...Array(c.attributes.position.count).keys()]),this.copy(P([e,P([t,...a],!1),r,c],!0)),this.computeVertexNormals()}}class Te extends n.BufferGeometry{constructor(e=1.75,t=.75){super();const o=e*.05,a=e*.15,r=e*.15,i=e*.75;let l=0;const c=new n.BoxGeometry(t,o,t);c.translate(0,l+o/2,0),l+=o;const h=new n.BoxGeometry(t*.8,a,t*.8);h.translate(0,l+a/2,0),l+=a;const u=new n.BoxGeometry(t*.6,r,t*.6);u.translate(0,l+r/2,0),l+=r;const d=new n.BoxGeometry(t*.4,i,t*.4);d.translate(0,l+i/2,0),l+=i;const m=new n.ConeGeometry(t*.4/Math.sqrt(2),.1,4,1,!1,Math.PI/4);m.translate(0,l+.1/2,0),this.copy(P([c,h,u,d,m],!1)),this.computeVertexNormals()}}class Be extends n.BufferGeometry{constructor(e=.6,t=1,o=.2,a=.6){super();const r=t-a/2,i=new n.BoxGeometry(e,r,o);i.translate(0,r/2,0);const l=new n.CylinderGeometry(a/2,a/2,o,16,1,!1,0,Math.PI);l.rotateY(Math.PI/2),l.rotateX(Math.PI/2),l.translate(0,r,0),this.copy(P([i,l],!1)),this.computeVertexNormals()}}class Ie extends n.BufferGeometry{constructor(e=.5,t=.8,o=.15){super();const a=new n.BoxGeometry(e,t,o);a.translate(0,t/2,0),this.copy(a)}}class Ee extends n.BufferGeometry{constructor({height:e=2.25}={}){super();const t=new n.BoxGeometry(1.2,.5,1.2);t.translate(0,.25,0);const o=new n.BoxGeometry(1,e,1);o.translate(0,.5+e/2,0);const a=new n.BoxGeometry(1.4,.3,1.4);a.translate(0,.5+e+.15,0),this.copy(P([t,o,a],!1))}}class ae extends n.BufferGeometry{constructor({barHeight:e=2,barRadius:t=.05,spikeHeight:o=.3,spikeRadius:a=.075,spikeScaleZ:r=1,radialSegments:i=8}={}){super();const l=new n.CylinderGeometry(t,t,e,i);l.translate(0,e/2,0);const c=new n.ConeGeometry(a,o,i);c.translate(0,e+o/2,0),c.scale(1,1,r),this.copy(P([l,c],!1))}}class Fe extends n.BufferGeometry{constructor({count:e=20,spacing:t=.4,barHeight:o=2,barRadius:a=.05,spikeHeight:r=.3,spikeRadius:i=.075,spikeScaleZ:l=1,railHeight:c=.1,railDepth:h=.05,railOffset:u=0,radialSegments:d=8}={}){super();const m=[],f=new ae({barHeight:o,barRadius:a,spikeHeight:r,spikeRadius:i,spikeScaleZ:l,radialSegments:d}),y=new n.BoxGeometry(e*t,c,h);for(let g=0;g<e;g++){const x=f.clone();x.translate(g*t,0,0),m.push(x)}const p=y.clone();p.translate(t*(e-1)/2,o-u-c/2,0),m.push(p);const M=y.clone();M.translate(t*(e-1)/2,c/2,0),m.push(M),this.copy(P(m))}}class Re extends n.BufferGeometry{constructor({width:e=5,height:t=8,depth:o=1,shelves:a=4,frameThickness:r=.1,open:i=!1}={}){super();const l=t,c=e,h=o,u=new n.BoxGeometry(r,l,h),d=new n.BoxGeometry(c-2*r,r,h),m=u.clone();m.translate(-c/2+r/2,l/2,0);const f=u.clone();f.translate(c/2-r/2,l/2,0);const y=d.clone();y.translate(0,l-r/2,0);const p=d.clone();p.translate(0,r/2,0);const M=new n.BoxGeometry(c,l,r);M.translate(0,l/2,-h/2+r/2);const g=[],x=(l-r)/(a+1);for(let S=1;S<=a;S++){const w=d.clone();w.translate(0,r/2+S*x,0),g.push(w)}this.copy(P([m,f,y,p,...i?[]:[M],...g],!1))}}class ke extends n.BufferGeometry{constructor(){super();const e=new n.BoxGeometry(5,.3,3);e.translate(0,3.15,0);const t=[new n.Vector2(.2,0),new n.Vector2(.25,.5),new n.Vector2(.15,1.5),new n.Vector2(.3,3)],o=new n.LatheGeometry(t,32),r=P([[2.1,0,1.1],[-2.1,0,1.1],[2.1,0,-1.1],[-2.1,0,-1.1]].map(i=>{const l=o.clone();return l.translate(i[0],i[1],i[2]),l}));this.copy(P([e,r],!0))}}class ie extends ts{constructor({height:e=.25,radius:t=.05,segmentsU:o=16,segmentsV:a=16}={}){super((r,i,l)=>{const c=r*Math.PI*2,h=Math.sin(i*Math.PI),u=t*h*Math.cos(c),d=i*e,m=t*h*Math.sin(c);l.set(u,d,-m)},o,a)}}class Ve extends n.BufferGeometry{constructor({radiusTop:e=.2,radiusBottom:t=.2,height:o=1,flameHeight:a=.25,flameRadius:r=.05,segments:i=16}={}){super();const l=new n.CylinderGeometry(e,t,o,i);l.translate(0,o/2,0);const c=new ie({segmentsU:i,segmentsV:i,height:a,radius:r});c.translate(0,o,0),this.copy(P([l,c],!0))}}class ds extends n.BufferGeometry{constructor(e=1,t=2,o=.5,a=Math.PI/4){super();const r=t*Math.tan(a),i=e,l=t,c=o,h=[0,0,0,i,0,0,i+r,l,0,r,l,0,i,0,-c,0,0,-c,r,l,-c,i+r,l,-c,0,0,-c,0,0,0,r,l,0,r,l,-c,i,0,0,i,0,-c,i+r,l,-c,i+r,l,0,r,l,0,i+r,l,0,i+r,l,-c,r,l,-c,0,0,-c,i,0,-c,i,0,0,0,0,0],u=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,-1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0],d=[0,1,2,2,3,0,4,5,6,6,7,4,8,9,10,10,11,8,12,13,14,14,15,12,16,17,18,18,19,16,20,21,22,22,23,20],m=new Float32Array([0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1]),f=new Float32Array(h),y=new Float32Array(u),p=new Float32Array(m),M=new Uint16Array(d);this.setAttribute("position",new n.BufferAttribute(f,3)),this.setAttribute("normal",new n.BufferAttribute(y,3)),this.setAttribute("uv",new n.BufferAttribute(p,2)),this.setIndex(new n.BufferAttribute(M,1)),this.center()}}class ze extends n.BufferGeometry{constructor(){super();const e=[],t=[];for(let o=0;o<5;o++){const a=.8+Math.random()*.4,r=.8+Math.random()*.4,i=.8+Math.random()*.4,l=Math.random()*Math.PI,c=Math.random()*Math.PI,h=Math.random()*Math.PI,u=(Math.random()-.5)*4,d=0,m=(Math.random()-.5)*4,f=new n.DodecahedronGeometry(1,0);f.scale(a,r,i),f.rotateX(l),f.rotateY(c),f.rotateZ(h),f.translate(u,d,m),e.push(f);const y=new n.DodecahedronGeometry(1,0);y.scale(a*.9,r*.5,i*.9),y.rotateX(l),y.rotateY(c),y.rotateZ(h),y.translate(u,d+.3,m),t.push(y)}this.copy(P([P(e),P(t)],!0))}}function De(s,e=j.XYZ,t=.5,o=2){s.deleteAttribute("uv"),s.deleteAttribute("normal"),s=es(s),s.computeVertexNormals();const a=s.getAttribute("position");for(let r=0;r<a.count;r++){const i=new n.Vector3().fromBufferAttribute(a,r),l=Math.random()*(o-t)+t,c=e.clone().multiplyScalar(l);i.add(c),a.setXYZ(r,i.x,i.y,i.z)}return a.needsUpdate=!0,s.computeVertexNormals(),s}class Oe extends n.BufferGeometry{constructor(e=1,t=4,o=4){super();const a=new n.SphereGeometry(e,t,o);this.copy(De(a,j.XYZ,.5,1)),this.computeVertexNormals(),this.center()}}class Ue extends n.BufferGeometry{constructor(){super();const e=[];for(let t=0;t<5;t++){const o=new n.DodecahedronGeometry(1,0);o.scale(.8+Math.random()*.4,.8+Math.random()*.4,.8+Math.random()*.4),o.rotateX(Math.random()*Math.PI),o.rotateY(Math.random()*Math.PI),o.rotateZ(Math.random()*Math.PI),o.translate((Math.random()-.5)*4,0,(Math.random()-.5)*4),e.push(o)}this.copy(P(e))}}class Ne extends n.Shape{constructor(e=5,t=.5,o=1,a=5,r=.25){super();const i=Math.PI*2/e,l=i/4;this.moveTo(Math.cos(0)*o,-Math.sin(0)*o);for(let c=1;c<=e;++c)this.lineTo(Math.cos(i*c-l*3)*t,-Math.sin(i*c-l*3)*t),this.lineTo(Math.cos(i*c-l*2)*t,-Math.sin(i*c-l*2)*t),this.lineTo(Math.cos(i*c-l)*o,-Math.sin(i*c-l)*o),this.lineTo(Math.cos(i*c)*o,-Math.sin(i*c)*o);if(this.closePath(),r>0&&a>2){const c=new n.Path,h=Math.PI*2/a;c.moveTo(Math.cos(0)*r,-Math.sin(0)*r);for(let u=1;u<a;++u)c.lineTo(Math.cos(h*u)*r,-Math.sin(h*u)*r);c.lineTo(Math.cos(0)*r,-Math.sin(0)*r),this.holes.push(c)}}}class Le extends n.ExtrudeGeometry{constructor(e=5,t=.5,o=1,a=5,r=.25,i=.25){const l=new Ne(e,t,o,a,r);super(l,{depth:i,bevelEnabled:!1})}}class _e extends n.Shape{constructor(e=1,t=2.1,o=1.4,a=1.6){super(),this.moveTo(0,o*e/3),this.bezierCurveTo(-t*.375*e,o*e,-t*e,o*e/3,0,-a*e),this.bezierCurveTo(t*e,o*e/3,t*.375*e,o*e,0,o*e/3)}}class Ye extends n.ExtrudeGeometry{constructor(e=1,t=2.1,o=1.4,a=1.6,r=.25){const i=new _e(e,t,o,a);super(i,{depth:r,bevelEnabled:!1})}}class He extends n.Shape{constructor(e=5,t=.5,o=1){super();const a=Math.PI*2/e,r=a/2;this.moveTo(Math.cos(0)*o,Math.sin(0)*o);for(let i=1;i<=e;++i)this.lineTo(Math.cos(a*i-r)*t,Math.sin(a*i-r)*t),this.lineTo(Math.cos(a*i)*o,Math.sin(a*i)*o);this.closePath()}}class qe extends n.ExtrudeGeometry{constructor(e=5,t=.5,o=1,a=.25){const r=new He(e,t,o);super(r,{depth:a,bevelEnabled:!1})}}class Xe extends n.BufferGeometry{constructor(e=.1,t=.1,o=.4,a=8){super();const r=new n.CylinderGeometry(e*.6,t*.6,o,a);r.translate(0,0,0);const i=new n.SphereGeometry(e,a,a),l=i.clone(),c=i.clone(),h=i.clone(),u=i.clone();l.translate(0,o/2+e*.6,-e*.6),c.translate(0,o/2+e*.6,e*.6),h.translate(0,-o/2-t*.6,-t*.6),u.translate(0,-o/2-t*.6,t*.6),this.copy(P([r,l,c,h,u],!1))}}class Ze extends n.BufferGeometry{constructor({flaskRadius:e=1,neckRadius:t=.3,height:o=2.5,neckHeight:a=1,radialSegments:r=16}={}){super();const i=[new n.Vector2(0,0),new n.Vector2(e*.875,0),new n.Vector2(e,.1),new n.Vector2(t,o),new n.Vector2(t,o+a),new n.Vector2(t*1.1,o+a+.3)],l=new n.LatheGeometry(i,r);this.copy(P([l],!1))}}const ms=(s,e)=>s/(1-Math.cos(e)),ce=(s,e)=>s/(2*Math.sin(e)),je=(s,e)=>s*(1-Math.cos(e)),fs=(s,e)=>2*s*Math.sin(e),$=(s,e)=>{const t=2*e;return Math.asin(t/(2*s))},ps=(s,e,t)=>({x:s*Math.sin(t)*Math.cos(e),y:s*Math.sin(t)*Math.sin(e),z:s*Math.cos(t)}),ys=(s,e,t)=>{const o=Math.sqrt(s*s+e*e+t*t),a=Math.atan2(e,s),r=Math.acos(t/o);return{radius:o,theta:a,phi:r}};function We(s,e,t,o=0,a=0,r=32){const i=o?$(s,o):0,l=a?Math.PI-$(s,a):Math.PI,c=[];for(let h=0;h<=r;h++){const u=l-(l-i)/r*h,d=s*Math.sin(u),m=e*Math.cos(u)+t;c.push(new n.Vector2(d,m))}return[...c]}class Ke extends n.BufferGeometry{constructor(){super();const e=[...We(1,1,.5,.2,0,32),new n.Vector2(.2,3)],t=new n.LatheGeometry(e,32);this.copy(t)}}class Qe extends n.BufferGeometry{constructor(){super();const e=[new n.Vector2(1,0),new n.Vector2(1.2,.5),new n.Vector2(1.4,1.5),new n.Vector2(1.3,1.8),new n.Vector2(.8,1.8)],t=new n.LatheGeometry(e,12),o=new n.CircleGeometry(1,12);o.rotateX(-Math.PI/2),o.translate(0,0,0),this.copy(P([t,o],!1))}}class $e extends n.BufferGeometry{constructor({radius:e=.3,height:t=.4,count:o=3,thickness:a=.03,radialSegments:r=16}={}){super();const i=new n.TorusGeometry(e,a,8,r);i.rotateX(Math.PI/2),i.translate(0,t,0);const l=new n.CylinderGeometry(a*.6,a*.6,t,r),c=[];for(let h=0;h<o;h++){const u=h/o*Math.PI*2,d=l.clone();d.translate(Math.cos(u)*e,t/2,Math.sin(u)*e),c.push(d)}this.copy(P([i,...c],!1))}}class Je extends n.BufferGeometry{constructor(){super();const e=new n.CylinderGeometry(.5,.6,.3,16);e.translate(0,.15,0);const t=new n.CylinderGeometry(.15,.15,2,12,1,!0);t.translate(0,1.3,0);const o=new n.SphereGeometry(.3,16,16);o.translate(0,2.4,0),this.copy(P([e,P([t,o])],!0))}}class Z extends n.BufferGeometry{constructor(e=.2,t=.2,o=3,a=32,r=!0){super();const i=new n.CylinderGeometry(e,t,o,a,1,r),l=new n.SphereGeometry(t,a,a/2,0,Math.PI*2,Math.PI/2,Math.PI/2);l.translate(0,-(o/2),0),this.copy(P([i,l],!1))}}class et extends n.BufferGeometry{constructor({radius:e=3,height:t=.6,widthSegments:o=64,heightSegments:a=16,phiStart:r=0,phiLength:i=Math.PI*2}={}){super(),this.copy(new n.SphereGeometry(e,o,a,r,i,0,Math.PI/2)),this.scale(1,t/e,1)}}class tt extends n.BufferGeometry{constructor({radius:e=ce(5,Math.PI/10),widthSegments:t=64,heightSegments:o=32,phiStart:a=0,phiLength:r=Math.PI*2,thetaLength:i=Math.PI/10}={}){super(),this.copy(new n.SphereGeometry(e,t,o,a,r,0,i));const l=je(e,i);this.translate(0,-e+l,0)}}class st extends n.BufferGeometry{constructor({trunkRadiusTop:e=.25,trunkRadiusBottom:t=.4,trunkHeight:o=2.5,trunkSegments:a=14,leafSize:r=.8,leafCount:i=6,leafDetail:l=0,leafSpreadRadius:c=1.5}={}){super();const h=new n.CylinderGeometry(e,t,o,a);h.translate(0,o/2,0);const u=[];for(let d=0;d<i;d++){const m=new n.DodecahedronGeometry(r,l);m.translate((Math.random()-.5)*c,(Math.random()-.5)*r+o,(Math.random()-.5)*c),u.push(m)}this.copy(P([h.toNonIndexed(),P(u,!1)],!0)),this.computeVertexNormals()}}class Ms extends n.Mesh{constructor({width:e=5,height:t=3,depth:o=5,wallThickness:a=.05,interiorColor:r=k.WHITE_SMOKE,floorColor:i=k.RAW_SIENNA,exteriorColor:l=k.GRAY}={}){super(new ve({width:e,height:t,depth:o,wallThickness:a}),[new n.MeshStandardMaterial({color:r}),new n.MeshStandardMaterial({color:i}),new n.MeshStandardMaterial({color:l})])}}const ot={uniforms:{time:{value:0}},vertexShader:`
|
|
2
|
+
varying vec3 vNormal;
|
|
3
|
+
varying vec3 vPosition;
|
|
4
|
+
void main() {
|
|
5
|
+
vNormal = normalize(normal);
|
|
6
|
+
vPosition = position;
|
|
7
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
8
|
+
}
|
|
9
|
+
`,fragmentShader:`
|
|
10
|
+
varying vec3 vNormal;
|
|
11
|
+
varying vec3 vPosition;
|
|
12
|
+
|
|
13
|
+
// Simple 3D noise function
|
|
14
|
+
float hash(vec3 p) {
|
|
15
|
+
p = fract(p * 0.3183099 + vec3(0.71, 0.113, 0.419));
|
|
16
|
+
p *= 17.0;
|
|
17
|
+
return fract(p.x * p.y * p.z * (p.x + p.y + p.z));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
float noise(vec3 p) {
|
|
21
|
+
vec3 ip = floor(p);
|
|
22
|
+
vec3 fp = fract(p);
|
|
23
|
+
fp = fp * fp * (3.0 - 2.0 * fp); // Smoothstep
|
|
24
|
+
return mix(
|
|
25
|
+
mix(mix(hash(ip), hash(ip + vec3(1.0, 0.0, 0.0)), fp.x),
|
|
26
|
+
mix(hash(ip + vec3(0.0, 1.0, 0.0)), hash(ip + vec3(1.0, 1.0, 0.0)), fp.x), fp.y),
|
|
27
|
+
mix(mix(hash(ip + vec3(0.0, 0.0, 1.0)), hash(ip + vec3(1.0, 0.0, 1.0)), fp.x),
|
|
28
|
+
mix(hash(ip + vec3(0.0, 1.0, 1.0)), hash(ip + vec3(1.0, 1.0, 1.0)), fp.x), fp.y),
|
|
29
|
+
fp.z);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
void main() {
|
|
33
|
+
vec3 color = vec3(0.8, 0.8, 0.7); // Base moon color
|
|
34
|
+
float n = noise(vPosition * 0.5); // Apply noise with frequency
|
|
35
|
+
color *= 0.8 + 0.2 * n; // Modulate color by noise
|
|
36
|
+
gl_FragColor = vec4(color, 1.0);
|
|
37
|
+
}
|
|
38
|
+
`};class gs extends n.Mesh{constructor(){super(new n.SphereGeometry(5,32,32),new n.ShaderMaterial(ot))}}class xs extends n.Mesh{constructor({width:e=1,height:t=1.5,depth:o=.5,coverThickness:a=.05,pageIndent:r=.05,coverColor:i=k.DARK_RED,pageColor:l=k.TITANIUM_WHITE}={}){super(new oe(e,t,o,a,r),[new n.MeshStandardMaterial({color:i,metalness:.1,roughness:.7,flatShading:!0}),new n.MeshStandardMaterial({color:l,flatShading:!0})])}}class ws extends n.Mesh{constructor(){super(new Se,[new n.MeshStandardMaterial({color:8965290,transparent:!0,depthWrite:!1,opacity:.4,roughness:.1,metalness:.5,side:n.DoubleSide}),new n.MeshStandardMaterial({color:9127187,roughness:1})])}}class vs extends n.Mesh{constructor(){super(new Ge,[new n.MeshStandardMaterial({color:8965375,transparent:!0,depthWrite:!1,opacity:.5,roughness:.1,metalness:.3}),new n.MeshStandardMaterial({color:9127187,roughness:1}),new n.MeshStandardMaterial({color:k.PINK_SHERBET,transparent:!0,depthWrite:!1,opacity:.5})])}}class Ss extends n.Mesh{constructor(){super(new Pe,new n.MeshPhysicalMaterial({color:5597999,roughness:.1,transmission:.9,thickness:.2,metalness:0,clearcoat:1,clearcoatRoughness:.1}))}}class bs extends n.Mesh{constructor({width:e=.4,height:t=1.2,depth:o=.2}={}){super(new Ae(e,t,o),new n.MeshStandardMaterial({color:7829367,roughness:.8}))}}class Gs extends n.Mesh{constructor(){super(new Ce,[new n.MeshStandardMaterial({color:8421504,flatShading:!0}),new n.MeshStandardMaterial({color:6908265,flatShading:!0}),new n.MeshStandardMaterial({color:5263440,flatShading:!0}),new n.MeshStandardMaterial({color:4210752,flatShading:!0})])}}class Ps extends n.Mesh{constructor({totalHeight:e=1.75,baseWidth:t=.75}={}){super(new Te(e,t),new n.MeshStandardMaterial({color:7829367,roughness:.8}))}}class As extends n.Mesh{constructor(e=.6,t=1,o=.2,a=.6){super(new Be(e,t,o,a),new n.MeshStandardMaterial({color:7829367,roughness:.8}))}}class Cs extends n.Mesh{constructor(e=.5,t=.8,o=.15){super(new Ie(e,t,o),new n.MeshStandardMaterial({color:7829367,roughness:.8}))}}class Ts extends n.Mesh{constructor({height:e=2.25}={}){super(new Ee({height:e}),new n.MeshStandardMaterial({color:9141627,flatShading:!0}))}}class Bs extends n.Mesh{constructor({barHeight:e=2,barRadius:t=.05,spikeHeight:o=.3,spikeRadius:a=.075,spikeScaleZ:r=1,radialSegments:i=8}={}){super(new ae({barHeight:e,barRadius:t,spikeHeight:o,spikeRadius:a,spikeScaleZ:r,radialSegments:i}),new n.MeshStandardMaterial({color:3355443,metalness:.8,roughness:.4}))}}class Is extends n.Mesh{constructor({count:e=20,spacing:t=.4,barHeight:o=2,barRadius:a=.05,spikeHeight:r=.3,spikeRadius:i=.075,spikeScaleZ:l=1,railHeight:c=.1,railDepth:h=.05,railOffset:u=0,radialSegments:d=8}={}){super(new Fe({count:e,spacing:t,barHeight:o,barRadius:a,spikeHeight:r,spikeRadius:i,spikeScaleZ:l,railHeight:c,railDepth:h,railOffset:u,radialSegments:d}),new n.MeshStandardMaterial({color:3355443,metalness:.8,roughness:.4}))}}class Es extends n.Mesh{constructor({width:e=5,height:t=8,depth:o=1,shelves:a=4,frameThickness:r=.1,open:i=!1}={}){super(new Re({width:e,height:t,depth:o,shelves:a,frameThickness:r,open:i}),new n.MeshStandardMaterial({color:9127187}))}}class Fs extends n.Mesh{constructor(){super(new ke,[new n.MeshStandardMaterial({color:9132587}),new n.MeshStandardMaterial({color:4929057})])}}class Rs extends n.Mesh{constructor({radiusTop:e=.2,radiusBottom:t=.2,height:o=1,flameHeight:a=.25,flameRadius:r=.05,segments:i=16}={}){super(new Ve({radiusTop:e,radiusBottom:t,height:o,flameHeight:a,flameRadius:r,segments:i}),[new n.MeshStandardMaterial({color:16777215}),new n.MeshStandardMaterial({color:16766720,emissive:16753920,emissiveIntensity:.35})])}}class ks extends n.Mesh{constructor({height:e=.25,radius:t=.05,segmentsU:o=16,segmentsV:a=16}={}){super(new ie({segmentsU:o,segmentsV:a,height:e,radius:t}),new n.MeshStandardMaterial({color:16766720,emissive:16753920,emissiveIntensity:.35}))}}class Vs extends n.Group{constructor(e=1.3,t=.5){super();const o=new n.CylinderGeometry(t,t,.2,16),a=new n.MeshStandardMaterial({color:9127187,flatShading:!0}),r=new n.Mesh(o,a);r.position.set(0,0,0),this.add(r);const i=new n.CylinderGeometry(t*.9,t*.9,e),l=new n.MeshStandardMaterial({color:16766720,flatShading:!0,transparent:!0,opacity:.6}),c=new n.Mesh(i,l);c.position.set(0,e/2+.1,0),this.add(c);const h=new n.ConeGeometry(t*1.1,.5,8),u=new n.MeshStandardMaterial({color:9127187,flatShading:!0}),d=new n.Mesh(h,u);d.position.set(0,e+.35,0),this.add(d);const m=new n.TorusGeometry(t*.8,.05,8,16),f=new n.MeshStandardMaterial({color:9127187,flatShading:!0}),y=new n.Mesh(m,f);y.position.set(0,e+.85,0),this.add(y);const p=new n.PointLight(16755200,1.5,15);p.position.set(0,e/2+.1,0),p.castShadow=!0,this.add(p)}}class zs extends n.Mesh{constructor(){super(new ze,[new n.MeshStandardMaterial({color:8421504,flatShading:!0}),new n.MeshStandardMaterial({color:4950843,flatShading:!0,opacity:.8,transparent:!0})])}}class Ds extends n.Mesh{constructor(e=1,t=4,o=4){super(new Oe(e,t,o),new n.MeshStandardMaterial({color:8421504,flatShading:!0}))}}class Os extends n.Mesh{constructor(){super(new Ue,new n.MeshStandardMaterial({color:8421504,flatShading:!0}))}}class Us extends n.Group{constructor(){super();const e=new n.CylinderGeometry(.3,.4,.1,16),t=new n.MeshStandardMaterial({color:3355443,roughness:.6,metalness:.3}),o=new n.Mesh(e,t);o.position.y=.05;const a=new n.CylinderGeometry(.1,.1,.7,16),r=new n.MeshStandardMaterial({color:5592405,roughness:.5,metalness:.4}),i=new n.Mesh(a,r);i.position.y=.4;const l=new n.ConeGeometry(.075,.2,16),c=new n.MeshStandardMaterial({color:16733440,emissive:16733440,emissiveIntensity:.6,transparent:!0,opacity:.8}),h=new n.Mesh(l,c);h.position.y=.8,this.add(o,i,h)}}class Ns extends n.Group{constructor(){super();const e=new n.BoxGeometry(3,4,.1),t=new n.MeshStandardMaterial({color:3026478,roughness:.8,metalness:.6}),o=new n.BoxGeometry(.2,.5,.2),a=new n.MeshStandardMaterial({color:11184810,roughness:.5,metalness:.7}),r=new n.CylinderGeometry(.3,.3,.1,16),i=new n.MeshStandardMaterial({color:5592405,roughness:.7,metalness:.5}),l=new n.Mesh(e,t);for(let m=-1;m<=1;m++){const f=new n.Mesh(o,a);f.position.set(m,1.5,.1),l.add(f)}const c=new n.Mesh(r,i);c.rotation.x=Math.PI/2,c.position.set(0,.5,.15),l.add(c);const h=new n.SphereGeometry(.15,8,8),u=new n.MeshStandardMaterial({color:16711680,emissive:16711680,emissiveIntensity:.5}),d=new n.Mesh(h,u);d.position.set(0,-1,.1),l.add(d),this.add(l)}}class Ls extends n.Mesh{constructor({flaskRadius:e=1,neckRadius:t=.3,height:o=2.5,neckHeight:a=1,radialSegments:r=16}={}){super(new Ze({flaskRadius:e,neckRadius:t,height:o,neckHeight:a,radialSegments:r}),new n.MeshPhysicalMaterial({color:8965375,transparent:!0,opacity:.4,roughness:.1,metalness:.1,reflectivity:.8,transmission:.9,side:n.DoubleSide}))}}class _s extends n.Mesh{constructor(){super(new Ke,new n.MeshPhysicalMaterial({color:8965375,transparent:!0,depthWrite:!1,opacity:.4,roughness:.1,metalness:.1,reflectivity:.8,transmission:.9,side:n.DoubleSide}))}}class Ys extends n.Group{constructor(){super();const e=new n.BoxGeometry(2,3,.1),t=new n.MeshStandardMaterial({color:3355443,roughness:.8,metalness:.5}),o=new n.Mesh(e,t),a=new n.CylinderGeometry(.1,.1,.2,8),r=new n.CylinderGeometry(.05,.05,1,8),i=new n.MeshStandardMaterial({color:11184810,roughness:.5,metalness:.7});for(let l=-.5;l<=.5;l+=.5){const c=new n.Mesh(a,i);c.position.set(l,1,.1);const h=new n.Mesh(r,i);h.position.y=.5,c.add(h),this.add(c)}this.add(o)}}class Hs extends n.Group{constructor(){super();const e=new n.BoxGeometry(1,.2,.5),t=new n.MeshStandardMaterial({color:4473924,roughness:.6,metalness:.3}),o=new n.Mesh(e,t);o.position.y=.1;const a=new n.BoxGeometry(.2,1,.2),r=new n.Mesh(a,t);r.position.set(0,.6,-.2);const i=new n.CylinderGeometry(.1,.1,.4,8),l=new n.MeshStandardMaterial({color:3355443,roughness:.5,metalness:.6}),c=new n.Mesh(i,l);c.position.set(0,1.1,-.35),c.rotation.x=-Math.PI/4;const h=new n.BoxGeometry(.6,.1,.6),u=new n.MeshStandardMaterial({color:5592405,roughness:.8,metalness:.2}),d=new n.Mesh(h,u);d.position.set(0,.6,0),this.add(o,r,c,d)}}class qs extends n.Group{constructor(){super();const e=new Qe,t=new n.CylinderGeometry(.2,.3,1.5,8);t.translate(0,.75,0);const o=new n.MeshStandardMaterial({color:6045747,roughness:1,metalness:0,side:n.DoubleSide}),a=new n.MeshStandardMaterial({color:9132587,roughness:.8,metalness:.1}),r=new n.Mesh(e,o);r.castShadow=!0;const i=new n.Mesh(t,a);i.castShadow=!0,i.position.set(.3,1.3,0),i.rotation.z=Math.PI/4,this.add(r,i)}}class Xs extends n.Mesh{geometry;material;constructor({width:e=3,height:t=4,depth:o=.1}={}){super(),this.geometry=new n.BoxGeometry(e,t,o),this.material=new n.MeshStandardMaterial({color:3026478,roughness:.8,metalness:.6})}}class Zs extends n.Mesh{geometry;material;constructor({radius:e=.15,color:t=16762823,emissive:o=16711680,emissiveIntensity:a=.5}={}){super(),this.geometry=new n.SphereGeometry(e,8,8),this.material=new n.MeshStandardMaterial({color:t,emissive:o,emissiveIntensity:a})}}class js extends n.Group{constructor(){super();const e=100,t=.05,o=new n.CatmullRomCurve3(Array.from({length:e},(l,c)=>{const h=c*.2;return new n.Vector3(Math.cos(h)*.4,c*t,Math.sin(h)*.4)})),a=new n.TubeGeometry(o,200,.1,8,!1),r=new n.MeshStandardMaterial({color:8965375,transparent:!0,opacity:.3,roughness:.1,metalness:.2,emissive:8965375,emissiveIntensity:.2}),i=new n.Mesh(a,r);this.add(i)}}class Ws extends n.Mesh{constructor({radius:e=.3,height:t=.4,count:o=3,thickness:a=.03,radialSegments:r=16}={}){super(new $e({radius:e,height:t,count:o,thickness:a,radialSegments:r}),new n.MeshStandardMaterial({color:8947848,roughness:.7,metalness:.3}))}}class Ks extends n.Mesh{constructor(){super(new Je,[new n.MeshStandardMaterial({color:3355443,roughness:.6,metalness:.5}),new n.MeshStandardMaterial({color:16737792,roughness:.5,metalness:.8,side:n.DoubleSide})])}}class Qs extends n.Mesh{constructor(e=.2,t=.2,o=3,a=32){super(new Z(e,t,o,a),new n.MeshPhysicalMaterial({color:8965375,transparent:!0,opacity:.4,roughness:.1,metalness:.1,reflectivity:.8,transmission:.9,depthWrite:!1,side:n.DoubleSide}))}}class $s extends n.Group{constructor(e=3,t=[65450,16711850,11141375]){super();const o=new n.BoxGeometry(3,.2,1),a=new n.MeshStandardMaterial({color:9127187,roughness:.7,metalness:.3}),r=new n.Mesh(o,a);r.position.y=.5,r.castShadow=!0;const i=new Z(.1,.1,1,16),l=new n.MeshStandardMaterial({color:11184810,transparent:!0,opacity:.4,roughness:.1,metalness:.5,depthWrite:!1,side:n.DoubleSide});for(let c=0;c<e;c++){const h=new n.Mesh(i,l),u=(c-(e-1)/2)*.8;h.position.set(u,1,0),h.castShadow=!0,h.renderOrder=2;const d=new Z(.099,.099,.5,16,!1),m=t[c%t.length],f=new n.MeshStandardMaterial({color:m,emissive:m,emissiveIntensity:.5,transparent:!0,opacity:.6,depthWrite:!1,side:n.DoubleSide}),y=new n.Mesh(d,f);y.position.set(0,-.25,0),y.renderOrder=1,h.add(y),r.add(h)}this.add(r)}}class Js extends n.Mesh{constructor({sides:e=5,innerRadius:t=.5,outerRadius:o=1,depth:a=.25}={}){super(new se(e,t,o,a),new n.MeshStandardMaterial({color:16776960,emissive:16766720,emissiveIntensity:.25,metalness:.1,roughness:.3,flatShading:!0}))}}class eo extends n.Mesh{constructor({sides:e=5,innerRadius:t=.5,outerRadius:o=1,holeSides:a=5,holeRadius:r=.25,depth:i=.25}={}){super(new Le(e,t,o,a,r,i),new n.MeshStandardMaterial({color:11184810,metalness:.8,roughness:.2}))}}class to extends n.Mesh{constructor({size:e=1,width:t=2.1,height:o=1.4,tipDepth:a=1.6,depth:r=.25}={}){super(new Ye(e,t,o,a,r),new n.MeshStandardMaterial({color:12986408,emissive:12981270,emissiveIntensity:.25,metalness:.1,roughness:.3,flatShading:!0}))}}class so extends n.Mesh{constructor({radius:e=1,depth:t=.01}={}){super(new W(e,t),new n.MeshStandardMaterial({color:16777215,emissive:16777215,emissiveIntensity:.1,metalness:.1,roughness:.3,flatShading:!0}))}}class oo extends n.Mesh{constructor({points:e=5,innerRadius:t=.5,outerRadius:o=1,depth:a=.25}={}){super(new qe(e,t,o,a),new n.MeshStandardMaterial({color:16776960,emissive:16766720,emissiveIntensity:.25,metalness:.1,roughness:.3,flatShading:!0}))}}class ro extends n.Mesh{constructor(){super(new Xe,new n.MeshStandardMaterial({color:16777215}))}}class no extends n.Mesh{constructor({trunkRadiusTop:e=.25,trunkRadiusBottom:t=.4,trunkHeight:o=2.5,trunkSegments:a=14,trunkColor:r=9127187,leafSize:i=.8,leafCount:l=6,leafDetail:c=0,leafSpreadRadius:h=1.5,leafColor:u=2263842}={}){super(new st({trunkRadiusTop:e,trunkRadiusBottom:t,trunkHeight:o,trunkSegments:a,leafSize:i,leafCount:l,leafDetail:c,leafSpreadRadius:h}),[new n.MeshStandardMaterial({color:r,roughness:.9,metalness:0,flatShading:!0}),new n.MeshStandardMaterial({color:u,roughness:.8,metalness:0,flatShading:!0})])}}class ao extends n.Mesh{constructor({radius:e=3,height:t=.6,widthSegments:o=64,heightSegments:a=16,phiStart:r=0,phiLength:i=Math.PI*2}={}){super(new et({radius:e,height:t,widthSegments:o,heightSegments:a,phiStart:r,phiLength:i}),new n.MeshStandardMaterial({color:65280,flatShading:!0}))}}class io extends n.Mesh{constructor({radius:e=ce(5,Math.PI/10),widthSegments:t=64,heightSegments:o=32,phiStart:a=0,phiLength:r=Math.PI*2,thetaLength:i=Math.PI/10}={}){super(new tt({radius:e,widthSegments:t,heightSegments:o,phiStart:a,phiLength:r,thetaLength:i}),new n.MeshStandardMaterial({color:65280,flatShading:!0}))}}function co(s){if(!s)throw new Error("A material must be provided to add instance color support.");return s.onBeforeCompile=e=>{e.vertexShader=e.vertexShader.replace("void main() {",`attribute vec3 instanceColor;
|
|
39
|
+
varying vec3 vColor;
|
|
40
|
+
void main() {`),e.vertexShader=e.vertexShader.replace("#include <begin_vertex>",`#include <begin_vertex>
|
|
41
|
+
vColor = instanceColor;`),e.fragmentShader=e.fragmentShader.replace("void main() {",`varying vec3 vColor;
|
|
42
|
+
void main() {`),e.fragmentShader=e.fragmentShader.replace("#include <dithering_fragment>",`#include <dithering_fragment>
|
|
43
|
+
gl_FragColor.rgb = vColor * gl_FragColor.rgb;`)},s}function lo(s,{time:e=0,waveFrequency:t=.2,waveAmplitude:o=.5}={}){s.onBeforeCompile=a=>{a.uniforms.time={value:e},a.uniforms.waveFrequency={value:t},a.uniforms.waveAmplitude={value:o},a.vertexShader=`
|
|
44
|
+
uniform float time;
|
|
45
|
+
uniform float waveFrequency;
|
|
46
|
+
uniform float waveAmplitude;
|
|
47
|
+
|
|
48
|
+
vec3 waterDisplacement(vec3 position, vec3 normal) {
|
|
49
|
+
vec3 displaced = position;
|
|
50
|
+
|
|
51
|
+
// Displace along the normal direction instead of local y-axis
|
|
52
|
+
displaced += normal * (sin(position.x * waveFrequency + time) * waveAmplitude);
|
|
53
|
+
displaced += normal * (cos(position.z * waveFrequency + time) * waveAmplitude);
|
|
54
|
+
|
|
55
|
+
return displaced;
|
|
56
|
+
}
|
|
57
|
+
`+a.vertexShader,a.vertexShader=a.vertexShader.replace("#include <begin_vertex>",`
|
|
58
|
+
vec3 transformed = waterDisplacement(position, normal);
|
|
59
|
+
`),s.userData.shader=a}}function ho(s,e){s.userData.shader&&(s.userData.shader.uniforms.time.value+=e)}function uo(s,{time:e=0,intensity:t=1,axis:o=j.XYZ,scale:a=10}={}){s.onBeforeCompile=r=>{r.uniforms.time={value:e},r.uniforms.axis={value:o},r.uniforms.intensity={value:t},r.uniforms.scale={value:a},r.vertexShader=`
|
|
60
|
+
uniform float time;
|
|
61
|
+
uniform vec3 axis;
|
|
62
|
+
uniform float intensity;
|
|
63
|
+
uniform float scale;
|
|
64
|
+
|
|
65
|
+
float mod289(float x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
|
|
66
|
+
vec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
|
|
67
|
+
vec4 perm(vec4 x) { return mod289(((x * 34.0) + 1.0) * x); }
|
|
68
|
+
|
|
69
|
+
float noise(vec3 p) {
|
|
70
|
+
vec3 a = floor(p);
|
|
71
|
+
vec3 d = p - a;
|
|
72
|
+
d = d * d * (3.0 - 2.0 * d);
|
|
73
|
+
|
|
74
|
+
vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);
|
|
75
|
+
vec4 k1 = perm(b.xyxy);
|
|
76
|
+
vec4 k2 = perm(k1.xyxy + b.zzww);
|
|
77
|
+
|
|
78
|
+
vec4 c = k2 + a.zzzz;
|
|
79
|
+
vec4 k3 = perm(c);
|
|
80
|
+
vec4 k4 = perm(c + 1.0);
|
|
81
|
+
|
|
82
|
+
vec4 o1 = fract(k3 * (1.0 / 41.0));
|
|
83
|
+
vec4 o2 = fract(k4 * (1.0 / 41.0));
|
|
84
|
+
|
|
85
|
+
vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
|
|
86
|
+
vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
|
|
87
|
+
|
|
88
|
+
return o4.y * d.y + o4.x * (1.0 - d.y);
|
|
89
|
+
}
|
|
90
|
+
`+r.vertexShader,r.vertexShader=r.vertexShader.replace("#include <begin_vertex>",`
|
|
91
|
+
vec3 transformed = vec3(position);
|
|
92
|
+
float n = noise(transformed * scale + time);
|
|
93
|
+
transformed += normalize(axis) * n * intensity;
|
|
94
|
+
vec3 transformedNormal = normal;
|
|
95
|
+
`),s.userData.shader=r}}function mo(s,e){s.userData.shader&&(s.userData.shader.uniforms.time.value+=e)}const Y={uniforms:{turbidity:{value:10},rayleigh:{value:2},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new n.Vector3().setFromSphericalCoords(1,n.MathUtils.degToRad(90),n.MathUtils.degToRad(180))},up:{value:new n.Vector3(0,1,0)}},vertexShader:`
|
|
96
|
+
uniform vec3 sunPosition;
|
|
97
|
+
uniform float rayleigh;
|
|
98
|
+
uniform float turbidity;
|
|
99
|
+
uniform float mieCoefficient;
|
|
100
|
+
uniform vec3 up;
|
|
101
|
+
|
|
102
|
+
varying vec3 vWorldPosition;
|
|
103
|
+
varying vec3 vSunDirection;
|
|
104
|
+
varying float vSunfade;
|
|
105
|
+
varying vec3 vBetaR;
|
|
106
|
+
varying vec3 vBetaM;
|
|
107
|
+
varying float vSunE;
|
|
108
|
+
|
|
109
|
+
// constants for atmospheric scattering
|
|
110
|
+
const float e = 2.71828182845904523536028747135266249775724709369995957;
|
|
111
|
+
const float pi = 3.141592653589793238462643383279502884197169;
|
|
112
|
+
|
|
113
|
+
// wavelength of used primaries, according to preetham
|
|
114
|
+
const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );
|
|
115
|
+
// this pre-calculation replaces older TotalRayleigh(vec3 lambda) function:
|
|
116
|
+
// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))
|
|
117
|
+
const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );
|
|
118
|
+
|
|
119
|
+
// mie stuff
|
|
120
|
+
// K coefficient for the primaries
|
|
121
|
+
const float v = 4.0;
|
|
122
|
+
const vec3 K = vec3( 0.686, 0.678, 0.666 );
|
|
123
|
+
// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K
|
|
124
|
+
const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );
|
|
125
|
+
|
|
126
|
+
// earth shadow hack
|
|
127
|
+
// cutoffAngle = pi / 1.95;
|
|
128
|
+
const float cutoffAngle = 1.6110731556870734;
|
|
129
|
+
const float steepness = 1.5;
|
|
130
|
+
const float EE = 1000.0;
|
|
131
|
+
|
|
132
|
+
float sunIntensity( float zenithAngleCos ) {
|
|
133
|
+
zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );
|
|
134
|
+
return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
vec3 totalMie( float T ) {
|
|
138
|
+
float c = ( 0.2 * T ) * 10E-18;
|
|
139
|
+
return 0.434 * c * MieConst;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
void main() {
|
|
143
|
+
vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
|
|
144
|
+
vWorldPosition = worldPosition.xyz;
|
|
145
|
+
|
|
146
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
147
|
+
gl_Position.z = gl_Position.w; // set z to camera.far
|
|
148
|
+
|
|
149
|
+
vSunDirection = normalize( sunPosition );
|
|
150
|
+
|
|
151
|
+
vSunE = sunIntensity( dot( vSunDirection, up ) );
|
|
152
|
+
|
|
153
|
+
vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );
|
|
154
|
+
|
|
155
|
+
float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );
|
|
156
|
+
|
|
157
|
+
// extinction (absorption + out scattering)
|
|
158
|
+
// rayleigh coefficients
|
|
159
|
+
vBetaR = totalRayleigh * rayleighCoefficient;
|
|
160
|
+
|
|
161
|
+
// mie coefficients
|
|
162
|
+
vBetaM = totalMie( turbidity ) * mieCoefficient;
|
|
163
|
+
}
|
|
164
|
+
`,fragmentShader:`
|
|
165
|
+
varying vec3 vWorldPosition;
|
|
166
|
+
varying vec3 vSunDirection;
|
|
167
|
+
varying float vSunfade;
|
|
168
|
+
varying vec3 vBetaR;
|
|
169
|
+
varying vec3 vBetaM;
|
|
170
|
+
varying float vSunE;
|
|
171
|
+
|
|
172
|
+
uniform float mieDirectionalG;
|
|
173
|
+
uniform vec3 up;
|
|
174
|
+
|
|
175
|
+
// constants for atmospheric scattering
|
|
176
|
+
const float pi = 3.141592653589793238462643383279502884197169;
|
|
177
|
+
|
|
178
|
+
const float n = 1.0003; // refractive index of air
|
|
179
|
+
const float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)
|
|
180
|
+
|
|
181
|
+
// optical length at zenith for molecules
|
|
182
|
+
const float rayleighZenithLength = 8.4E3;
|
|
183
|
+
const float mieZenithLength = 1.25E3;
|
|
184
|
+
// 66 arc seconds -> degrees, and the cosine of that
|
|
185
|
+
const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;
|
|
186
|
+
|
|
187
|
+
// 3.0 / ( 16.0 * pi )
|
|
188
|
+
const float THREE_OVER_SIXTEENPI = 0.05968310365946075;
|
|
189
|
+
// 1.0 / ( 4.0 * pi )
|
|
190
|
+
const float ONE_OVER_FOURPI = 0.07957747154594767;
|
|
191
|
+
|
|
192
|
+
float rayleighPhase( float cosTheta ) {
|
|
193
|
+
return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
float hgPhase( float cosTheta, float g ) {
|
|
197
|
+
float g2 = pow( g, 2.0 );
|
|
198
|
+
float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );
|
|
199
|
+
return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
void main() {
|
|
203
|
+
vec3 direction = normalize( vWorldPosition - cameraPosition );
|
|
204
|
+
|
|
205
|
+
// optical length
|
|
206
|
+
// cutoff angle at 90 to avoid singularity in next formula.
|
|
207
|
+
float zenithAngle = acos( max( 0.0, dot( up, direction ) ) );
|
|
208
|
+
float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );
|
|
209
|
+
float sR = rayleighZenithLength * inverse;
|
|
210
|
+
float sM = mieZenithLength * inverse;
|
|
211
|
+
|
|
212
|
+
// combined extinction factor
|
|
213
|
+
vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );
|
|
214
|
+
|
|
215
|
+
// in scattering
|
|
216
|
+
float cosTheta = dot( direction, vSunDirection );
|
|
217
|
+
|
|
218
|
+
float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );
|
|
219
|
+
vec3 betaRTheta = vBetaR * rPhase;
|
|
220
|
+
|
|
221
|
+
float mPhase = hgPhase( cosTheta, mieDirectionalG );
|
|
222
|
+
vec3 betaMTheta = vBetaM * mPhase;
|
|
223
|
+
|
|
224
|
+
vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );
|
|
225
|
+
Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );
|
|
226
|
+
|
|
227
|
+
// night sky
|
|
228
|
+
float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]
|
|
229
|
+
float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]
|
|
230
|
+
vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );
|
|
231
|
+
vec3 L0 = vec3( 0.1 ) * Fex;
|
|
232
|
+
|
|
233
|
+
// composition + solar disc
|
|
234
|
+
float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );
|
|
235
|
+
L0 += ( vSunE * 19000.0 * Fex ) * sundisk;
|
|
236
|
+
|
|
237
|
+
vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );
|
|
238
|
+
|
|
239
|
+
vec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );
|
|
240
|
+
|
|
241
|
+
gl_FragColor = vec4( retColor, 1.0 );
|
|
242
|
+
|
|
243
|
+
#include <tonemapping_fragment>
|
|
244
|
+
#include <colorspace_fragment>
|
|
245
|
+
}
|
|
246
|
+
`},J={uniforms:{tDiffuse:{value:null},kernelSize:{value:0},resolution:{value:null}},vertexShader:`
|
|
247
|
+
varying vec2 vUv;
|
|
248
|
+
void main() {
|
|
249
|
+
vUv = uv;
|
|
250
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
251
|
+
}
|
|
252
|
+
`,fragmentShader:`
|
|
253
|
+
uniform sampler2D tDiffuse;
|
|
254
|
+
uniform float kernelSize;
|
|
255
|
+
uniform vec2 resolution;
|
|
256
|
+
varying vec2 vUv;
|
|
257
|
+
|
|
258
|
+
void main() {
|
|
259
|
+
vec2 texelSize = 1.0 / resolution;
|
|
260
|
+
vec4 color = vec4(0.0);
|
|
261
|
+
float total = 0.0;
|
|
262
|
+
|
|
263
|
+
// Box blur with dynamic kernel size
|
|
264
|
+
float radius = kernelSize;
|
|
265
|
+
for (float x = -10.0; x <= 10.0; x += 1.0) {
|
|
266
|
+
for (float y = -10.0; y <= 10.0; y += 1.0) {
|
|
267
|
+
float weight = 1.0 - (abs(x) + abs(y)) / (radius * 2.0 + 1.0);
|
|
268
|
+
if (weight > 0.0 && abs(x) <= radius && abs(y) <= radius) {
|
|
269
|
+
vec2 offset = vec2(x, y) * texelSize * 2.0;
|
|
270
|
+
color += texture2D(tDiffuse, vUv + offset) * weight;
|
|
271
|
+
total += weight;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
gl_FragColor = total > 0.0 ? color / total : texture2D(tDiffuse, vUv);
|
|
277
|
+
}
|
|
278
|
+
`},N={uniforms:{tDiffuseA:{value:null},tDiffuseB:{value:null},mixRatio:{value:0}},vertexShader:`
|
|
279
|
+
varying vec2 vUv;
|
|
280
|
+
void main() {
|
|
281
|
+
vUv = uv;
|
|
282
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
283
|
+
}
|
|
284
|
+
`,fragmentShader:`
|
|
285
|
+
uniform sampler2D tDiffuseA;
|
|
286
|
+
uniform sampler2D tDiffuseB;
|
|
287
|
+
uniform float mixRatio;
|
|
288
|
+
varying vec2 vUv;
|
|
289
|
+
|
|
290
|
+
vec3 linearTosRGB(vec3 color) {
|
|
291
|
+
return mix(
|
|
292
|
+
color * 12.92,
|
|
293
|
+
1.055 * pow(color, vec3(1.0 / 2.4)) - 0.055,
|
|
294
|
+
step(0.0031308, color)
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
void main() {
|
|
299
|
+
vec4 texelA = texture2D(tDiffuseA, vUv);
|
|
300
|
+
vec4 texelB = texture2D(tDiffuseB, vUv);
|
|
301
|
+
vec3 blendedColor = mix(texelA.rgb, texelB.rgb, mixRatio);
|
|
302
|
+
gl_FragColor = vec4(linearTosRGB(blendedColor), max(texelA.a, texelB.a));
|
|
303
|
+
}
|
|
304
|
+
`},H={uniforms:{topColor:{value:new n.Color(.5,.8,1)},bottomColor:{value:new n.Color(1,1,1)}},vertexShader:`
|
|
305
|
+
varying vec3 vPosition;
|
|
306
|
+
void main() {
|
|
307
|
+
vPosition = position;
|
|
308
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
309
|
+
}
|
|
310
|
+
`,fragmentShader:`
|
|
311
|
+
uniform vec3 topColor;
|
|
312
|
+
uniform vec3 bottomColor;
|
|
313
|
+
varying vec3 vPosition;
|
|
314
|
+
void main() {
|
|
315
|
+
float y = normalize(vPosition).y * 0.5 + 0.5; // Normalizing y to range 0 to 1
|
|
316
|
+
gl_FragColor = vec4(mix(bottomColor, topColor, y), 1.0);
|
|
317
|
+
}
|
|
318
|
+
`},ee={uniforms:{tDiffuse:{value:null},fadeAmount:{value:0},fadeColor:{value:null}},vertexShader:`
|
|
319
|
+
varying vec2 vUv;
|
|
320
|
+
void main() {
|
|
321
|
+
vUv = uv;
|
|
322
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
323
|
+
}
|
|
324
|
+
`,fragmentShader:`
|
|
325
|
+
uniform sampler2D tDiffuse;
|
|
326
|
+
uniform float fadeAmount;
|
|
327
|
+
uniform vec3 fadeColor;
|
|
328
|
+
varying vec2 vUv;
|
|
329
|
+
|
|
330
|
+
vec3 linearTosRGB(vec3 color) {
|
|
331
|
+
return mix(
|
|
332
|
+
color * 12.92,
|
|
333
|
+
1.055 * pow(color, vec3(1.0 / 2.4)) - 0.055,
|
|
334
|
+
step(0.0031308, color)
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
void main() {
|
|
339
|
+
vec4 texel = texture2D(tDiffuse, vUv);
|
|
340
|
+
vec3 blendedColor = mix(texel.rgb, fadeColor, fadeAmount);
|
|
341
|
+
gl_FragColor = vec4(linearTosRGB(blendedColor), 1.0);
|
|
342
|
+
}
|
|
343
|
+
`},te={uniforms:{tDiffuseA:{value:null},tDiffuseB:{value:null},mixRatio:{value:0},fadeColor:{value:null}},vertexShader:`
|
|
344
|
+
varying vec2 vUv;
|
|
345
|
+
void main() {
|
|
346
|
+
vUv = uv;
|
|
347
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
348
|
+
}
|
|
349
|
+
`,fragmentShader:`
|
|
350
|
+
uniform sampler2D tDiffuseA;
|
|
351
|
+
uniform sampler2D tDiffuseB;
|
|
352
|
+
uniform float mixRatio;
|
|
353
|
+
uniform vec3 fadeColor;
|
|
354
|
+
varying vec2 vUv;
|
|
355
|
+
|
|
356
|
+
vec3 linearTosRGB(vec3 color) {
|
|
357
|
+
return mix(
|
|
358
|
+
color * 12.92,
|
|
359
|
+
1.055 * pow(color, vec3(1.0 / 2.4)) - 0.055,
|
|
360
|
+
step(0.0031308, color)
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
void main() {
|
|
365
|
+
vec4 texelA = texture2D(tDiffuseA, vUv);
|
|
366
|
+
vec4 texelB = texture2D(tDiffuseB, vUv);
|
|
367
|
+
|
|
368
|
+
// Fade out to color, then fade in from color
|
|
369
|
+
float fadeOut = smoothstep(0.0, 0.5, mixRatio) * 2.0;
|
|
370
|
+
float fadeIn = smoothstep(0.5, 1.0, mixRatio) * 2.0 - 1.0;
|
|
371
|
+
|
|
372
|
+
vec3 colorA = mix(texelA.rgb, fadeColor, clamp(fadeOut, 0.0, 1.0));
|
|
373
|
+
vec3 colorB = mix(fadeColor, texelB.rgb, clamp(fadeIn, 0.0, 1.0));
|
|
374
|
+
|
|
375
|
+
vec3 blendedColor = mix(colorA, colorB, step(0.5, mixRatio));
|
|
376
|
+
gl_FragColor = vec4(linearTosRGB(blendedColor), 1.0);
|
|
377
|
+
}
|
|
378
|
+
`},q={uniforms:{topColor:{value:new n.Color(51)},bottomColor:{value:new n.Color(17)},offset:{value:33},exponent:{value:.6}},vertexShader:`
|
|
379
|
+
varying vec3 vWorldPosition;
|
|
380
|
+
void main() {
|
|
381
|
+
vec4 worldPosition = modelMatrix * vec4(position, 1.0);
|
|
382
|
+
vWorldPosition = worldPosition.xyz;
|
|
383
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
384
|
+
}
|
|
385
|
+
`,fragmentShader:`
|
|
386
|
+
uniform vec3 topColor;
|
|
387
|
+
uniform vec3 bottomColor;
|
|
388
|
+
uniform float offset;
|
|
389
|
+
uniform float exponent;
|
|
390
|
+
varying vec3 vWorldPosition;
|
|
391
|
+
void main() {
|
|
392
|
+
float h = normalize(vWorldPosition + offset).y;
|
|
393
|
+
gl_FragColor = vec4(mix(bottomColor, topColor, max(pow(max(h, 0.0), exponent), 0.0)), 1.0);
|
|
394
|
+
}
|
|
395
|
+
`};class fo extends n.Mesh{geometry;material;constructor(){super(),this.geometry=new n.BoxGeometry(1,1,1),this.material=new n.ShaderMaterial({uniforms:Y.uniforms,vertexShader:Y.vertexShader,fragmentShader:Y.fragmentShader,depthWrite:!1,side:n.BackSide}),this.scale.setScalar(45e4);const e=n.MathUtils.degToRad(89),t=n.MathUtils.degToRad(180),o=new n.Vector3().setFromSphericalCoords(1,e,t);this.material.uniforms.sunPosition.value=o}sunPosition(e,t){const o=new n.Vector3;o.setFromSphericalCoords(1,e,t),this.material.uniforms.sunPosition.value=o}}class po extends n.Mesh{geometry;material;constructor(e=1e3){super(),this.geometry=new n.BoxGeometry(e,e,e),this.material=new n.ShaderMaterial({uniforms:H.uniforms,vertexShader:H.vertexShader,fragmentShader:H.fragmentShader,side:n.BackSide})}}class yo extends n.Mesh{geometry;material;constructor(e=1e3){super(),this.geometry=new n.SphereGeometry(e,32,15),this.material=new n.ShaderMaterial({vertexShader:q.vertexShader,fragmentShader:q.fragmentShader,uniforms:q.uniforms,side:n.BackSide})}}const Mo=s=>{const e=new Uint8Array(4*s*s);for(let o=0;o<s*s;o++){const a=o*4,r=(o%s^Math.floor(o/s))&1?255:0;e[a]=r,e[a+1]=r,e[a+2]=r,e[a+3]=255}const t=new n.DataTexture(e,s,s,n.RGBAFormat,n.UnsignedByteType);return t.wrapS=n.RepeatWrapping,t.wrapT=n.RepeatWrapping,t.minFilter=n.NearestFilter,t.needsUpdate=!0,t};class go{perspectiveCamera;orthographicCamera;renderer;scene=null;currentCamera;targetCamera=null;transitionProgress=0;transitionDuration=1e3;transitionStartTime=0;isTransitioning=!1;easingFunction;renderTargetA;renderTargetB;blendScene;blendCamera;blendMaterial;onUpdateCallback;onCompleteCallback;constructor(e,t,o){this.perspectiveCamera=e,this.orthographicCamera=t,this.renderer=o,this.currentCamera=e,this.easingFunction=V.cubicInOut;const a=o.getSize(new A.Vector2);this.renderTargetA=new A.WebGLRenderTarget(a.x,a.y),this.renderTargetB=new A.WebGLRenderTarget(a.x,a.y),this.blendScene=new A.Scene,this.blendCamera=new A.OrthographicCamera(-1,1,1,-1,0,1),this.blendMaterial=new A.ShaderMaterial({uniforms:{tDiffuseA:{value:this.renderTargetA.texture},tDiffuseB:{value:this.renderTargetB.texture},mixRatio:{value:0}},vertexShader:N.vertexShader,fragmentShader:N.fragmentShader});const r=new A.PlaneGeometry(2,2),i=new A.Mesh(r,this.blendMaterial);this.blendScene.add(i)}transitionTo(e,t={}){this.currentCamera!==e&&(this.targetCamera=e,this.transitionDuration=t.duration??1e3,this.transitionStartTime=performance.now(),this.transitionProgress=0,this.isTransitioning=!0,this.onUpdateCallback=t.onUpdate,this.onCompleteCallback=t.onComplete,t.easing&&(typeof t.easing=="string"?this.easingFunction=V[t.easing]:this.easingFunction=t.easing))}update(e){if(this.scene=e,!this.isTransitioning)return this.currentCamera;const o=performance.now()-this.transitionStartTime,a=Math.min(o/this.transitionDuration,1);return this.transitionProgress=this.easingFunction(a),this.onUpdateCallback&&this.onUpdateCallback(this.transitionProgress),a>=1?(this.isTransitioning=!1,this.currentCamera=this.targetCamera,this.targetCamera=null,this.onCompleteCallback&&this.onCompleteCallback(),this.currentCamera):this.currentCamera}render(e){if(!this.isTransitioning||!this.targetCamera){this.renderer.render(e,this.currentCamera);return}this.renderer.setRenderTarget(this.renderTargetA),this.renderer.render(e,this.currentCamera),this.renderer.setRenderTarget(this.renderTargetB),this.renderer.render(e,this.targetCamera),this.blendMaterial.uniforms.mixRatio.value=this.transitionProgress,this.renderer.setRenderTarget(null),this.renderer.render(this.blendScene,this.blendCamera)}getCurrentCamera(){return this.currentCamera}getIsTransitioning(){return this.isTransitioning}getProgress(){return this.transitionProgress}setSize(e,t){this.renderTargetA.setSize(e,t),this.renderTargetB.setSize(e,t)}dispose(){this.renderTargetA.dispose(),this.renderTargetB.dispose(),this.blendMaterial.dispose()}}class xo{renderer;currentScene=null;targetScene=null;camera=null;transitionProgress=0;transitionDuration=1e3;transitionStartTime=0;isTransitioning=!1;transitionType=null;easingFunction;renderTargetA;renderTargetB;blendScene;blendCamera;fadeMaterial;crossfadeMaterial;fadeColor=new A.Color(0);onUpdateCallback;onCompleteCallback;constructor(e){this.renderer=e,this.easingFunction=V.cubicInOut;const t=e.getSize(new A.Vector2);this.renderTargetA=new A.WebGLRenderTarget(t.x,t.y),this.renderTargetB=new A.WebGLRenderTarget(t.x,t.y),this.blendScene=new A.Scene,this.blendCamera=new A.OrthographicCamera(-1,1,1,-1,0,1),this.fadeMaterial=new A.ShaderMaterial({uniforms:{tDiffuseA:{value:this.renderTargetA.texture},tDiffuseB:{value:this.renderTargetB.texture},mixRatio:{value:0},fadeColor:{value:new A.Color(0)}},vertexShader:te.vertexShader,fragmentShader:te.fragmentShader}),this.crossfadeMaterial=new A.ShaderMaterial({uniforms:{tDiffuseA:{value:this.renderTargetA.texture},tDiffuseB:{value:this.renderTargetB.texture},mixRatio:{value:0}},vertexShader:N.vertexShader,fragmentShader:N.fragmentShader});const o=new A.PlaneGeometry(2,2),a=new A.Mesh(o,this.fadeMaterial);this.blendScene.add(a)}fade(e,t,o,a={}){this.startTransition(e,t,o,"fade",a),a.color!==void 0&&(this.fadeColor.set(a.color),this.fadeMaterial.uniforms.fadeColor.value.copy(this.fadeColor));const r=this.blendScene.children[0];r.material=this.fadeMaterial}crossfade(e,t,o,a={}){this.startTransition(e,t,o,"crossfade",a);const r=this.blendScene.children[0];r.material=this.crossfadeMaterial}blur(e,t,o,a={}){this.fade(e,t,o,{...a,color:8421504})}startTransition(e,t,o,a,r){this.currentScene=e,this.targetScene=t,this.camera=o,this.transitionType=a,this.transitionDuration=r.duration??1e3,this.transitionStartTime=performance.now(),this.transitionProgress=0,this.isTransitioning=!0,this.onUpdateCallback=r.onUpdate,this.onCompleteCallback=r.onComplete,r.easing&&(typeof r.easing=="string"?this.easingFunction=V[r.easing]:this.easingFunction=r.easing)}update(){if(!this.isTransitioning)return;const t=performance.now()-this.transitionStartTime,o=Math.min(t/this.transitionDuration,1);this.transitionProgress=this.easingFunction(o),this.onUpdateCallback&&this.onUpdateCallback(this.transitionProgress),o>=1&&(this.isTransitioning=!1,this.currentScene=this.targetScene,this.targetScene=null,this.onCompleteCallback&&this.onCompleteCallback())}render(){if(!this.isTransitioning||!this.currentScene||!this.targetScene||!this.camera){this.currentScene&&this.camera&&(this.renderer.setRenderTarget(null),this.renderer.render(this.currentScene,this.camera));return}this.renderer.setRenderTarget(this.renderTargetA),this.renderer.render(this.currentScene,this.camera),this.renderer.setRenderTarget(this.renderTargetB),this.renderer.render(this.targetScene,this.camera),this.transitionType==="fade"?this.fadeMaterial.uniforms.mixRatio.value=this.transitionProgress:this.transitionType==="crossfade"&&(this.crossfadeMaterial.uniforms.mixRatio.value=this.transitionProgress),this.renderer.setRenderTarget(null),this.renderer.render(this.blendScene,this.blendCamera)}getCurrentScene(){return this.currentScene}getIsTransitioning(){return this.isTransitioning}getProgress(){return this.transitionProgress}setCurrentScene(e){this.currentScene=e}setSize(e,t){this.renderTargetA.setSize(e,t),this.renderTargetB.setSize(e,t)}dispose(){this.renderTargetA.dispose(),this.renderTargetB.dispose(),this.fadeMaterial.dispose(),this.crossfadeMaterial.dispose()}}class wo{renderer;composer;currentScene=null;targetScene=null;camera=null;transitionProgress=0;transitionDuration=1e3;transitionStartTime=0;isTransitioning=!1;transitionType=null;easingFunction;renderPass;bloomPass;glitchPass;blurPass;fadePass;maxBloomStrength=3;maxBlurAmount=10;maxGlitchIntensity=1;fadeColor=new A.Color(0);onUpdateCallback;onCompleteCallback;constructor(e,t,o){this.renderer=e,this.composer=t,this.easingFunction=V.cubicInOut,this.renderPass=t.passes.find(a=>a.constructor.name==="RenderPass"),o&&this.createDefaultPasses(o)}createDefaultPasses(e){try{const t={uniforms:{tDiffuse:{value:null},kernelSize:{value:0},resolution:{value:new A.Vector2(this.renderer.domElement.width,this.renderer.domElement.height)}},vertexShader:J.vertexShader,fragmentShader:J.fragmentShader};this.blurPass=new e(t),this.blurPass.enabled=!1,this.composer.addPass(this.blurPass);const o={uniforms:{tDiffuse:{value:null},fadeAmount:{value:0},fadeColor:{value:new A.Color(0)}},vertexShader:ee.vertexShader,fragmentShader:ee.fragmentShader};this.fadePass=new e(o),this.fadePass.enabled=!1,this.composer.addPass(this.fadePass)}catch(t){console.warn("SceneTransitionFX: Could not create default passes:",t)}}setBloomPass(e){this.bloomPass=e}setGlitchPass(e){this.glitchPass=e}setBlurPass(e){this.blurPass=e}setFadePass(e){this.fadePass=e}bloom(e,t,o,a={}){if(!this.bloomPass){console.warn("SceneTransitionFX: Bloom pass not set. Call setBloomPass() first.");return}this.maxBloomStrength=a.maxBloom??3,this.startTransition(e,t,o,"bloom",a),this.bloomPass.enabled=!0}blur(e,t,o,a={}){if(!this.blurPass){console.warn("SceneTransitionFX: Blur pass not set. Call setBlurPass() first.");return}this.maxBlurAmount=a.maxBlur??10,this.startTransition(e,t,o,"blur",a),this.blurPass.enabled=!0}fade(e,t,o,a={}){if(!this.fadePass){console.warn("SceneTransitionFX: Fade pass not set. Call setFadePass() first.");return}a.color!==void 0&&(this.fadeColor.set(a.color),this.fadePass.uniforms.fadeColor.value.copy(this.fadeColor)),this.startTransition(e,t,o,"fade",a),this.fadePass.enabled=!0}glitch(e,t,o,a={}){if(!this.glitchPass){console.warn("SceneTransitionFX: Glitch pass not set. Call setGlitchPass() first.");return}this.maxGlitchIntensity=a.maxIntensity??1,this.startTransition(e,t,o,"glitch",a),this.glitchPass.enabled=!0}startTransition(e,t,o,a,r){this.currentScene=e,this.targetScene=t,this.camera=o,this.transitionType=a,this.transitionDuration=r.duration??1e3,this.transitionStartTime=performance.now(),this.transitionProgress=0,this.isTransitioning=!0,this.onUpdateCallback=r.onUpdate,this.onCompleteCallback=r.onComplete,r.easing&&(typeof r.easing=="string"?this.easingFunction=V[r.easing]:this.easingFunction=r.easing),this.renderPass&&(this.renderPass.scene=e,this.renderPass.camera=o)}update(){if(!this.isTransitioning)return;const t=performance.now()-this.transitionStartTime,o=Math.min(t/this.transitionDuration,1);if(this.transitionProgress=this.easingFunction(o),this.transitionType==="bloom"&&this.bloomPass){const a=1-Math.abs(this.transitionProgress*2-1);this.bloomPass.strength=a*this.maxBloomStrength}else if(this.transitionType==="blur"&&this.blurPass){const a=1-Math.abs(this.transitionProgress*2-1);this.blurPass.uniforms.kernelSize.value=a*this.maxBlurAmount}else if(this.transitionType==="fade"&&this.fadePass){const a=this.transitionProgress<.5?this.transitionProgress*2:2-this.transitionProgress*2;this.fadePass.uniforms.fadeAmount.value=a}else if(this.transitionType==="glitch"&&this.glitchPass){const a=1-Math.abs(this.transitionProgress*2-1);this.glitchPass.enabled=a>.3}this.transitionProgress>=.5&&this.renderPass&&this.renderPass.scene===this.currentScene&&(this.renderPass.scene=this.targetScene),this.onUpdateCallback&&this.onUpdateCallback(this.transitionProgress),o>=1&&(this.isTransitioning=!1,this.currentScene=this.targetScene,this.targetScene=null,this.renderPass&&this.currentScene&&(this.renderPass.scene=this.currentScene),this.bloomPass&&(this.bloomPass.enabled=!1,this.bloomPass.strength=0),this.blurPass&&(this.blurPass.enabled=!1,this.blurPass.uniforms.kernelSize.value=0),this.fadePass&&(this.fadePass.enabled=!1,this.fadePass.uniforms.fadeAmount.value=0),this.glitchPass&&(this.glitchPass.enabled=!1),this.onCompleteCallback&&this.onCompleteCallback())}render(){this.composer.render()}getCurrentScene(){return this.currentScene}getIsTransitioning(){return this.isTransitioning}getProgress(){return this.transitionProgress}setCurrentScene(e){this.currentScene=e,this.renderPass&&(this.renderPass.scene=e)}setSize(e,t){this.composer.setSize(e,t),this.blurPass&&this.blurPass.uniforms&&this.blurPass.uniforms.resolution&&this.blurPass.uniforms.resolution.value.set(e,t)}dispose(){}}function vo(s,e){if(s.length===0)throw new Error("No objects provided for alignment.");const t=new n.Box3,o=new n.Vector3,a=s.map(i=>(t.setFromObject(i),i.getWorldPosition(o),{object:i,boundingBox:t.clone(),worldPosition:o.clone()})),r=a.reduce((i,{boundingBox:l})=>{switch(e){case B.LEFT:return Math.min(i,l.min.x);case B.RIGHT:return Math.max(i,l.max.x);case B.BOTTOM:return Math.min(i,l.min.y);case B.TOP:return Math.max(i,l.max.y);case B.BACK:return Math.min(i,l.min.z);case B.FRONT:return Math.max(i,l.max.z);default:throw new Error(`Unsupported side type: ${e}`)}},e===B.RIGHT||e===B.TOP||e===B.FRONT?-1/0:1/0);a.forEach(({object:i,boundingBox:l})=>{switch(e){case B.LEFT:i.position.x+=r-l.min.x;break;case B.RIGHT:i.position.x+=r-l.max.x;break;case B.BOTTOM:i.position.y+=r-l.min.y;break;case B.TOP:i.position.y+=r-l.max.y;break;case B.BACK:i.position.z+=r-l.min.z;break;case B.FRONT:i.position.z+=r-l.max.z;break}})}function So(s,e=D.RIGHT,t=0){const o=e.clone().normalize();let a=new n.Vector3;const r=new n.Box3;s.forEach(i=>{r.setFromObject(i);const c=new n.Vector3(r.max.x-r.min.x,r.max.y-r.min.y,r.max.z-r.min.z).dot(o),h=new n.Vector3;r.getCenter(h);const u=o.clone().multiplyScalar(c/2);i.position.copy(a.clone().add(u).sub(h).add(i.position)),a.add(o.clone().multiplyScalar(c+t))})}function bo(s,e,t=new n.Vector3(0,0,0)){const o=new n.Box3().setFromObject(s);if(o.isEmpty())console.warn("The object has no geometry or is not visible.");else{const a=o.min,r=new n.Vector3((a.x+o.max.x)/2,a.y,(a.z+o.max.z)/2);s.localToWorld(r);const i=e.clone().sub(r).add(t),l=s.worldToLocal(i.clone());s.position.add(l)}}function Go(s,e){const t=new n.Box3().setFromBufferAttribute(new n.Float32BufferAttribute(s.attributes.position.array,3));if(t.isEmpty())console.warn("The geometry is empty or invalid.");else{const o=t.min.y;s.translate(0,e-o,0)}}function Po(s,e,t=new n.Vector3(0,0,0)){const o=new n.Box3().setFromObject(s);if(o.isEmpty())console.warn("The InstancedMesh has no geometry or is not visible.");else{const a=o.min.y,r=new n.Vector3(0,e.y-a,0).add(t),i=s.worldToLocal(r.clone());s.position.add(i)}}function Ao(s,e,t,o=new n.Vector3(0,0,0)){const a=new n.Box3().setFromObject(s);if(a.isEmpty())console.warn("The instanced mesh has invalid geometry.");else{const r=a.min.y,i=new n.Matrix4;s.getMatrixAt(t,i);const l=new n.Vector3,c=new n.Quaternion,h=new n.Vector3;i.decompose(l,c,h);const u=s.worldToLocal(e.clone());l.y=u.y-r+o.y,i.compose(l,c,h),s.setMatrixAt(t,i),s.instanceMatrix.needsUpdate=!0}}function rt(s,e=new n.Vector3(0,0,0),t=new n.Vector3(0,0,0)){const a=new n.Box3().setFromObject(s).getCenter(new n.Vector3),r=new n.Vector3().addVectors(e,t),i=new n.Vector3().subVectors(r,a);s.position.add(i)}function nt(s,e=new n.Vector3(0,0,0),t=new n.Vector3(0,0,0)){const a=new n.Box3().setFromObject(s).getCenter(new n.Vector3),r=new n.Vector3().addVectors(e,t);s.translateX(r.x-a.x),s.translateY(r.y-a.y),s.translateZ(r.z-a.z),s.updateMatrixWorld(!0)}function at(s,e=new n.Vector3(0,0,0),t=new n.Vector3(0,0,0)){s.geometry.computeBoundingBox();const o=s.geometry.boundingBox;if(o){const a=o.getCenter(new n.Vector3),r=new n.Vector3().addVectors(e,t),i=new n.Vector3().subVectors(r,a);s.geometry.translate(i.x,i.y,i.z)}}const Co={object:rt,objectGeometry:nt,meshGeometry:at};function To(s){const e=parseInt(s.slice(1),16);return[e>>16&255,e>>8&255,e&255]}function Bo(s){const[e,t,o]=z(s);return ct(e,t,o)}function z(s){const e=s>>16&255,t=s>>8&255,o=s&255;return[e,t,o]}function Io(s,e,t){e/=100,t/=100;function o(c,h,u){return u<0&&(u+=1),u>1&&(u-=1),u<1/6?c+(h-c)*6*u:u<1/2?h:u<2/3?c+(h-c)*(2/3-u)*6:c}let a,r,i;if(e===0)a=r=i=t;else{const c=t<.5?t*(1+e):t+e-t*e,h=2*t-c;a=o(h,c,s/360+1/3),r=o(h,c,s/360),i=o(h,c,s/360-1/3)}const l=c=>Math.round(c*255);return[l(a),l(r),l(i)]}function it(s,e,t){e/=100,t/=100;const o=i=>(i+s/30)%12,a=e*Math.min(t,1-t),r=i=>t-a*Math.max(-1,Math.min(o(i)-3,Math.min(9-o(i),1)));return[r(0)*255,r(8)*255,r(4)*255]}function Eo(s,e,t){return[s/255,e/255,t/255]}function Fo(s,e,t){return s=Math.round(s),e=Math.round(e),t=Math.round(t),(s<<16)+(e<<8)+t}function ct(s,e,t){s/=255,e/=255,t/=255;const o=Math.max(s,e,t),a=Math.min(s,e,t),r=o-a;let i=0,l=0;const c=(o+a)/2;r!==0&&(o===s?i=((e-t)/r+(e<t?6:0))*60:o===e?i=((t-s)/r+2)*60:o===t&&(i=((s-e)/r+4)*60)),r!==0&&(l=r/(1-Math.abs(2*c-1))),i=Math.round(i),l=Math.round(l*100);const h=Math.round(c*100);return[i,l,h]}function lt(s,e){return Math.sqrt(Math.pow(s[0]-e[0],2)+Math.pow(s[1]-e[1],2)+Math.pow(s[2]-e[2],2))}function ht(s,e){return Math.abs(s[0]-e[0])+Math.abs(s[1]-e[1])+Math.abs(s[2]-e[2])}function Ro(s,e){const t=z(s);let o=null,a=1/0;for(const r of e){const i=z(r),l=lt(t,i);l<a&&(a=l,o=r)}return o}function ko(s,e){const t=z(s);let o=null,a=1/0;for(const r of e){const i=z(r),l=ht(t,i);l<a&&(a=l,o=r)}return o}function Vo(s){const e=(s+Math.floor(-30+Math.random()*61))%360,t=Math.floor(60+Math.random()*21),o=Math.floor(50+Math.random()*21);return it(e,t,o)}function zo(s,e){if(!e.geometry.isBufferGeometry)throw new Error("Mesh must have a BufferGeometry.");const o=e.geometry.getAttribute("position"),a=new n.Vector3,r=new n.Vector3;let i=1/0;for(let l=0;l<o.count;l++){r.fromBufferAttribute(o,l);const c=r.distanceTo(s);c<i&&(i=c,a.copy(r))}return e.localToWorld(a),a}function Do(s,e,t){return Math.max(0,Math.min(1,(s-e)/(t-e)))}function Oo(s,e,t,o,a,r=20,i=0,l=1){const c=[];for(let h=0;h<=r;h++){const u=h/r,d=s(Do(u,i,l)),m=e+d*(t-e),f=o+u*(a-o);c.push(new n.Vector2(m,f))}return c}const ut=(s,e,t,o,a=24)=>{let r=[];for(let i=0;i<=a;i++){const l=i/a,c=R.cubic(l,s.x,e.x,t.x,o.x),h=R.cubic(l,s.y,e.y,t.y,o.y);r.push(new n.Vector2(c,h))}return r},dt=(s,e,t,o=24)=>{let a=[];for(let r=0;r<=o;r++){const i=r/o,l=R.damped(i,t)*(e.x-s.x)+s.x,c=s.y+i*(e.y-s.y);a.push(new n.Vector2(l,c))}return a},mt=(s,e,t,o,a=24)=>{let r=[];for(let i=0;i<=a;i++){const l=i/a,c=R.exponential(l,t,o)*(e.x-s.x)+s.x,h=s.y+l*(e.y-s.y);r.push(new n.Vector2(c,h))}return r},ft=(s,e,t,o,a=24)=>{let r=[];for(let i=0;i<=a;i++){const l=i/a,c=R.logarithmic(l,t,o)*(e.x-s.x)+s.x,h=s.y+l*(e.y-s.y);r.push(new n.Vector2(c,h))}return r},pt=(s,e,t,o,a,r=24)=>{let i=[];for(let l=0;l<=r;l++){const c=l/r,h=t*c*c+o*c+a+s.x,u=s.y+c*(e.y-s.y);i.push(new n.Vector2(h,u))}return i},yt=(s,e,t,o=24)=>{let a=[];for(let r=0;r<=o;r++){const i=r/o,l=R.quadratic(i,s.x,e.x,t.x),c=R.quadratic(i,s.y,e.y,t.y);a.push(new n.Vector2(l,c))}return a},Mt=(s,e,t,o=24)=>{let a=[];for(let r=0;r<=o;r++){const i=r/o,l=R.sigmoid(i,t)*(e.x-s.x)+s.x,c=s.y+i*(e.y-s.y);a.push(new n.Vector2(l,c))}return a},Uo={createCubicCurvePoints:ut,createDampedCurvePoints:dt,createExponentialCurvePoints:mt,createLogarithmicCurvePoints:ft,createParabolicCurvePoints:pt,createQuadraticCurvePoints:yt,createSigmoidCurvePoints:Mt};function No(s,e,t,o,a,r=[0,0],i=[1,0],l=[0,1],c=[1,1]){const h=a||gt(s,e,t);return[{pos:s,norm:h,uv:r},{pos:e,norm:h,uv:i},{pos:o,norm:h,uv:c},{pos:s,norm:h,uv:r},{pos:o,norm:h,uv:c},{pos:t,norm:h,uv:l}]}function gt(s,e,t){const o=[e[0]-s[0],e[1]-s[1],e[2]-s[2]],a=[t[0]-s[0],t[1]-s[1],t[2]-s[2]],r=[o[1]*a[2]-o[2]*a[1],o[2]*a[0]-o[0]*a[2],o[0]*a[1]-o[1]*a[0]],i=Math.sqrt(r[0]**2+r[1]**2+r[2]**2);return r.map(l=>l/i)}function Lo(s,e,t){const o=e+Math.random()*(t-e);return setTimeout(s,o)}function _o(s,e,t){let o;function a(){const r=e+Math.random()*(t-e);o=setTimeout(()=>{s(),a()},r)}return a(),()=>clearTimeout(o)}function Yo(s,e){return s.map(([t,o,a])=>{switch(e){case"x":return[o,a];case"y":return[t,a];case"z":return[t,o];default:throw new Error(`Invalid axis: ${e}`)}})}function xt(s){const[e,t,o]=s,a=Math.abs(e),r=Math.abs(t),i=Math.abs(o);return a>=r&&a>=i?[o>0?o:-o,t]:r>=a&&r>=i?[e,o>0?o:-o]:[e,t]}function Ho(s){return s.map(e=>xt(e))}function qo(s){return s.map(([e,t,o])=>{const a=Math.atan2(o,e),r=Math.acos(t/Math.sqrt(e**2+t**2+o**2)),i=a/(2*Math.PI)+.5,l=1-r/Math.PI;return[i,l]})}function Xo(s){return s.map(([e,t,o])=>[Math.atan2(o,e)/(2*Math.PI)+.5,t])}function Zo(s){return s.map(([e,t,o])=>{const a=Math.sqrt(e**2+o**2);return[Math.atan2(o,e)/(2*Math.PI)+.5,a]})}function wt(s,e,t,o,a){return[(s[0]-e)/(t-e),(s[1]-o)/(a-o)]}function jo(s,e,t){const[o,a]=e,[r,i]=t;return s.map(l=>wt(l,o,r,a,i))}function Wo(s){const e=Math.min(...s.map(r=>r[0])),t=Math.max(...s.map(r=>r[0])),o=Math.min(...s.map(r=>r[1])),a=Math.max(...s.map(r=>r[1]));return{minBounds:[e,o],maxBounds:[t,a]}}exports.AtmosphericSkybox=fo;exports.Axis=j;exports.BifurcatedStaircaseGeometry=is;exports.Bone=ro;exports.BoneGeometry=Xe;exports.Book=xs;exports.BookGeometry=oe;exports.Bookshelf=Es;exports.BookshelfGeometry=Re;exports.BoxSide=B;exports.BrickGeometry=xe;exports.BunsenBurner=Us;exports.Burst=Js;exports.BurstGeometry=se;exports.BurstShape=Me;exports.CameraTransition=go;exports.Candle=Rs;exports.CandleGeometry=Ve;exports.Center=Co;exports.ColorPalette=k;exports.CrossHeadstone=bs;exports.CrossHeadstoneGeometry=Ae;exports.DaySkybox=po;exports.Desk=Fs;exports.DeskGeometry=ke;exports.Diorama=Ms;exports.DioramaGeometry=ve;exports.Direction=D;exports.Easing=V;exports.EffervescenceEffect=Dt;exports.ElectricPanel=Ns;exports.EllipticLeafGeometry=ye;exports.EmissivePulseEffect=qt;exports.ErlenmeyerFlask=Ls;exports.ErlenmeyerFlaskGeometry=Ze;exports.Falloff=O;exports.Flame=ks;exports.FlameFlickerEffect=X;exports.FlameGeometry=ie;exports.FlorenceFlask=_s;exports.FlorenceFlaskGeometry=Ke;exports.Gear=eo;exports.GearGeometry=Le;exports.GearShape=Ne;exports.GlowHalo=Ht;exports.GroundFogEffect=Ot;exports.Heart=to;exports.HeartGeometry=Ye;exports.HeartShape=_e;exports.Hexagon=so;exports.HexagonGeometry=W;exports.HexagonShape=we;exports.Hill=ao;exports.HillGeometry=et;exports.Jar=ws;exports.JarGeometry=Se;exports.LShapedStaircaseGeometry=cs;exports.Lantern=Vs;exports.LeverPanel=Ys;exports.LightningEffect=Xt;exports.LineEquations=us;exports.Mausoleum=Gs;exports.MausoleumGeometry=Ce;exports.Microscope=Hs;exports.Moon=gs;exports.MortarAndPestle=qs;exports.MortarGeometry=Qe;exports.MossyRocks=zs;exports.MossyRocksGeometry=ze;exports.Mound=io;exports.MoundGeometry=tt;exports.NightSkybox=yo;exports.ObeliskHeadstone=Ps;exports.ObeliskHeadstoneGeometry=Te;exports.Panel=Xs;exports.PanelLight=Zs;exports.ParallelogramBoxGeometry=ds;exports.ParametricCurve=R;exports.ParametricCurveUtils=Uo;exports.PetalDriftEffect=Zt;exports.PotionBottle=vs;exports.PotionBottleGeometry=Ge;exports.RainEffect=Wt;exports.Rock=Ds;exports.RockGeometry=Oe;exports.Rocks=Os;exports.RocksGeometry=Ue;exports.RoundedHeadstone=As;exports.RoundedHeadstoneGeometry=Be;exports.SceneTransition=xo;exports.SceneTransitionFX=wo;exports.SpiralStaircaseGeometry=ls;exports.SpiralTube=js;exports.SquareHeadstone=Cs;exports.SquareHeadstoneGeometry=Ie;exports.StaircaseGeometry=hs;exports.Stand=Ws;exports.StandGeometry=$e;exports.Star=oo;exports.StarFieldEffect=Jt;exports.StarGeometry=qe;exports.StarShape=He;exports.StoneFencePost=Ts;exports.StoneFencePostGeometry=Ee;exports.TeslaCoil=Ks;exports.TeslaCoilGeometry=Je;exports.TestTube=Qs;exports.TestTubeGeometry=Z;exports.TestTubeRack=$s;exports.Tree=no;exports.TreeGeometry=st;exports.WineBottle=Ss;exports.WineBottleGeometry=Pe;exports.WispEffect=Kt;exports.WroughtIronBar=Bs;exports.WroughtIronBarGeometry=ae;exports.WroughtIronFence=Is;exports.WroughtIronFenceGeometry=Fe;exports.addInstanceColor=co;exports.addNoiseDisplacement=uo;exports.addWaterDisplacement=lo;exports.alignBufferGeometryToSurface=Go;exports.alignInstancedMeshIndexToSurface=Ao;exports.alignInstancedMeshToSurface=Po;exports.alignObjectToSurface=bo;exports.alignToEdge=vo;exports.alignToRow=So;exports.appendSphericalCurve=We;exports.atmosphericShader=Y;exports.blurTransitionShader=J;exports.calculateChannelDifference=ht;exports.calculateDistance=lt;exports.calculateNormal=gt;exports.calculateUVBounds=Wo;exports.calculateXFromSlopeIntercept=ne;exports.calculateYFromSlopeIntercept=be;exports.cameraDollyAnimation=bt;exports.cameraFlythroughAnimation=Gt;exports.cameraOrbitAnimation=Pt;exports.cameraPendulumAnimation=At;exports.cameraSpiralAscensionAnimation=Ct;exports.cameraWobbleAnimation=Tt;exports.cameraZoomInAnimation=Bt;exports.capHeightFromRadius=je;exports.capWidthFromRadius=fs;exports.cartesianToSpherical=ys;exports.centerMeshGeometry=at;exports.centerObject=rt;exports.centerObjectGeometry=nt;exports.checkerboardTexture=Mo;exports.createBrickWall=rs;exports.createCubicCurvePoints=ut;exports.createDampedCurvePoints=dt;exports.createExponentialCurvePoints=mt;exports.createHexagonalTilesByCount=ns;exports.createHexagonalTilesByRadius=as;exports.createLogarithmicCurvePoints=ft;exports.createParabolicCurvePoints=pt;exports.createQuad=No;exports.createQuadraticCurvePoints=yt;exports.createSigmoidCurvePoints=Mt;exports.crossfadeShader=N;exports.cubicUVMapping=xt;exports.cubicUVMappingBatch=Ho;exports.cylindricalUVMapping=Xo;exports.daySkyShader=H;exports.displacementBrush=It;exports.fadeShader=ee;exports.fadeTransitionSceneShader=te;exports.findClosestColor=Ro;exports.findClosestColorChannelWise=ko;exports.findClosestPoint=zo;exports.flattenBrush=Et;exports.getAnalogousColors=Vo;exports.hexToHsl=Bo;exports.hexToRgb=z;exports.hslToHex=Io;exports.hslToRgb=it;exports.interpolateCurve=Oo;exports.logarithmicRandomMax=fe;exports.logarithmicRandomMin=pe;exports.moonShader=ot;exports.nightSkyShader=q;exports.noiseBrush=Ft;exports.normalizeRgb=Eo;exports.normalizeUV=wt;exports.normalizeUVBatch=jo;exports.parseHexCode=To;exports.planarUVMapping=Yo;exports.polarUVMapping=Zo;exports.radiusFromCapHeight=ms;exports.radiusFromCapWidth=ce;exports.randomFloat=v;exports.randomInteger=zt;exports.randomTransformVertices=De;exports.rgbToHex=Fo;exports.rgbToHsl=ct;exports.rowOfBooksByCount=ss;exports.rowOfBooksByLength=os;exports.rowOfBooksByScales=re;exports.setRandomInterval=_o;exports.setRandomTimeout=Lo;exports.smoothBrush=Rt;exports.sphericalToCartesian=ps;exports.sphericalUVMapping=qo;exports.spikeBrush=kt;exports.thetaLengthForRadius=$;exports.twistBrush=Vt;exports.updateNoiseDisplacementTime=mo;exports.updateWaterDisplacementTime=ho;
|
|
396
|
+
//# sourceMappingURL=index.cjs.map
|