three-low-poly 0.9.21 → 0.9.23
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 +12 -1
- package/dist/index.cjs +356 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +580 -63
- package/dist/index.iife.js +79 -10
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +5695 -0
- package/dist/index.mjs.map +1 -0
- package/dist/uv-grid.jpg +0 -0
- package/package.json +17 -19
- package/dist/index.cjs.js +0 -287
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js +0 -5147
- package/dist/index.es.js.map +0 -1
- package/dist/index.umd.js +0 -287
- package/dist/index.umd.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# Three.js Low Poly
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Create or enhance stylized low-poly scenes entirely through code using procedurally generated geometries, prefabricated models, and factory utilities.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
**Three Low Poly** provides a toolkit for building low-poly environments in [Three.js](https://threejs.org) with minimal manual modeling.
|
|
8
|
+
It combines **procedural generation** (algorithmic geometry creation) with **parametric modeling** (user-defined parameters) to produce consistent, customizable results.
|
|
9
|
+
|
|
10
|
+
### Core Principles
|
|
11
|
+
- **Procedural Generation** – Create geometry algorithmically rather than by hand.
|
|
12
|
+
- **Parametric Modeling** – Adjust model attributes (size, color, detail, variation) via options.
|
|
13
|
+
- **Prefabricated Models** – Drop-in objects like trees, rocks, or books ready for scenes.
|
|
14
|
+
- **Factory Utilities** – Generate arrays, grids, or randomized layouts of models with a single call.
|
|
4
15
|
|
|
5
16
|

|
|
6
17
|
_Example Library scene_
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("three");function Xt(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const G=Xt(s);function Yt(t,e,n,o){const a=t.position.clone(),r=a.clone().add(t.getWorldDirection(new s.Vector3).multiplyScalar(-e));let i=null;function l(c){i===null&&(i=c);const h=(c-i)/n;if(h>=1){t.position.copy(r),o&&o();return}t.position.lerpVectors(a,r,h),requestAnimationFrame(l)}requestAnimationFrame(l)}function jt(t,e,n,o){const a=e.length-1;let r=null;function i(l){r===null&&(r=l);const u=(l-r)/n;if(u>=1){t.position.copy(e[e.length-1]),o&&o();return}const h=u*a,m=Math.floor(h),d=h-m,f=e[m],p=e[m+1];t.position.lerpVectors(f,p,d),t.lookAt(p),requestAnimationFrame(i)}requestAnimationFrame(i)}function Zt(t,e,n,o,a){let r=null;function i(l){r||(r=l);const u=(l-r)/o;if(u>=1){a&&a();return}const h=u*Math.PI*2,m=e.x+n*Math.cos(h),d=e.z+n*Math.sin(h);t.position.set(m,t.position.y,d),t.lookAt(e),requestAnimationFrame(i)}requestAnimationFrame(i)}function Kt(t,e,n,o,a,r){let i=null,l=0;function c(u){i===null&&(i=u);const h=u-i,m=o/a,d=h%m/m,f=Math.sin(d*Math.PI*2)*Math.PI/6,p=e.x+n*Math.sin(f),M=e.z+n*Math.cos(f);if(t.position.set(p,t.position.y,M),t.lookAt(e),h>=(l+1)*m&&l++,l>=a){r&&r();return}requestAnimationFrame(c)}requestAnimationFrame(c)}function Wt(t,e,n,o,a,r,i){let l=null;function c(u){l===null&&(l=u);const m=(u-l)/r;if(m>=1){i&&i();return}const d=m*Math.PI*2*a,f=e.x+n*Math.cos(d),p=e.z+n*Math.sin(d),M=e.y+o*m;t.position.set(f,M,p),t.lookAt(e),requestAnimationFrame(c)}requestAnimationFrame(c)}function Qt(t,e,n,o){const a=t.position.clone();let r=null;function i(l){if(r===null&&(r=l),(l-r)/n>=1){t.position.copy(a),o&&o();return}const h=new s.Vector3((Math.random()-.5)*e,(Math.random()-.5)*e,(Math.random()-.5)*e);t.position.copy(a).add(h),requestAnimationFrame(i)}requestAnimationFrame(i)}function Jt(t,e,n,o,a,r){const i=t.fov;t.fov=n,t.updateProjectionMatrix();let l=null;function c(u){l===null&&(l=u);const m=(u-l)/a;if(m>=1){t.fov=o,t.updateProjectionMatrix(),t.lookAt(e),t.fov=i,t.updateProjectionMatrix(),r&&r();return}t.fov=s.MathUtils.lerp(n,o,m),t.updateProjectionMatrix(),t.lookAt(e),requestAnimationFrame(c)}requestAnimationFrame(c)}class $t{speed;maxIntensity;minIntensity;material;constructor(e){const{speed:n=2,maxIntensity:o=.8,minIntensity:a=.2}=e;this.speed=n,this.maxIntensity=o,this.minIntensity=a,this.material=e.material}update(e=0){this.material.emissiveIntensity=this.minIntensity+Math.abs(Math.sin(e*this.speed))*(this.maxIntensity-this.minIntensity)}}function _(t=0,e=1){return Math.random()*(e-t)+t}function en(t=0,e=1){return Math.floor(Math.random()*(e-t+1))+t}function ee(t=.5,e=0,n=1){return e+(n-e)*Math.pow(Math.random(),t)}function te(t=.5,e=0,n=1){return e+(n-e)*Math.pow(1-Math.random(),t)}class tn{light;minIntensity;maxIntensity;x;y;z;jitterX;jitterY;jitterZ;constructor({light:e,minIntensity:n=.8,maxIntensity:o=1.2,x:a=0,y:r=0,z:i=0,jitterX:l=.02,jitterY:c=0,jitterZ:u=.02}={}){this.light=e,this.minIntensity=n,this.maxIntensity=o,this.x=a,this.y=r,this.z=i,this.jitterX=l,this.jitterY=c,this.jitterZ=u}update(){this.light&&(this.light.intensity=_(this.minIntensity,this.maxIntensity),this.light.position.x=Math.random()*this.jitterX-this.jitterX/2+this.x,this.light.position.y=Math.random()*this.jitterY-this.jitterY/2+this.y,this.light.position.z=Math.random()*this.jitterZ-this.jitterZ/2+this.z)}}function ne(t,e,n){const o=e+Math.random()*(n-e);return setTimeout(t,o)}function nn(t,e,n){let o;function a(){const r=e+Math.random()*(n-e);o=setTimeout(()=>{t(),a()},r)}return a(),()=>clearTimeout(o)}class on{light;minIntensity;maxIntensity;minDuration;maxDuration;constructor({light:e,minIntensity:n=15,maxIntensity:o=20,minDuration:a=50,maxDuration:r=250}={}){this.light=e,this.minIntensity=n,this.maxIntensity=o,this.minDuration=a,this.maxDuration=r}triggerLightning(){this.light&&(this.light.intensity=_(this.minIntensity,this.maxIntensity)),ne(()=>{this.light&&(this.light.intensity=0)},this.minDuration,this.maxDuration)}update(){Math.random()>.98&&this.triggerLightning()}}const F={UP:new s.Vector3(0,1,0),DOWN:new s.Vector3(0,-1,0),LEFT:new s.Vector3(-1,0,0),RIGHT:new s.Vector3(1,0,0),FORWARD:new s.Vector3(0,0,1),BACKWARD:new s.Vector3(0,0,-1)},O={LINEAR:(t,e)=>1-t/e,QUADRATIC:(t,e)=>Math.pow(1-t/e,2),SQUARE_ROOT:(t,e)=>Math.pow(1-t/e,.5),LOGARITHMIC:(t,e)=>Math.log(1+(e-t))/Math.log(1+e),SINE:(t,e)=>Math.cos(t/e*Math.PI/2),EXPONENTIAL:(t,e)=>Math.exp(-t/e),CUBIC:(t,e)=>Math.pow(1-t/e,3),GAUSSIAN:(t,e)=>Math.exp(-Math.pow(t,2)/(2*Math.pow(e/3,2))),INVERSE:(t,e)=>e/(e+t),SMOOTHSTEP:(t,e)=>{const n=Math.max(0,Math.min(1,1-t/e));return n*n*(3-2*n)}},rn=(t,e,n,o,a=F.UP,r=O.LINEAR)=>{const i=t.attributes.position;for(let l=0;l<i.count;l++){const c=new s.Vector3;c.fromBufferAttribute(i,l);const u=c.distanceTo(e);if(u<n){const m=r(u,n)*o;c.add(a.clone().multiplyScalar(m)),i.setXYZ(l,c.x,c.y,c.z)}}i.needsUpdate=!0},sn=(t,e,n,o,a,r=F.UP,i=O.LINEAR)=>{const l=t.attributes.position;for(let c=0;c<l.count;c++){const u=new s.Vector3;u.fromBufferAttribute(l,c);const h=u.distanceTo(e);if(h<n){const d=i(h,n)*a,f=u.dot(r.normalize()),p=o-f;u.add(r.clone().multiplyScalar(p*d)),l.setXYZ(c,u.x,u.y,u.z)}}l.needsUpdate=!0},an=(t,e,n,o,a=F.UP,r=O.LINEAR)=>{const i=t.attributes.position;for(let l=0;l<i.count;l++){const c=new s.Vector3;c.fromBufferAttribute(i,l);const u=c.distanceTo(e);if(u<n){const h=r(u,n),m=o*h,d=a.clone().normalize();c.x+=s.MathUtils.randFloatSpread(m)*d.x,c.y+=s.MathUtils.randFloatSpread(m)*d.y,c.z+=s.MathUtils.randFloatSpread(m)*d.z,i.setXYZ(l,c.x,c.y,c.z)}}i.needsUpdate=!0},cn=(t,e,n,o)=>{const a=t.attributes.position,r=new s.Vector3;for(let i=0;i<a.count;i++){const l=new s.Vector3;if(l.fromBufferAttribute(a,i),l.distanceTo(e)<n){let u=new s.Vector3,h=0;for(let m=0;m<a.count;m++)r.fromBufferAttribute(a,m),r.distanceTo(l)<n&&(u.add(r),h++);h>0&&(u.divideScalar(h),l.lerp(u,o),a.setXYZ(i,l.x,l.y,l.z))}}a.needsUpdate=!0},ln=(t,e,n,o,a=!1,r=O.LINEAR)=>{const i=t.attributes.position;for(let l=0;l<i.count;l++){const c=new s.Vector3;c.fromBufferAttribute(i,l);const u=c.distanceTo(e);if(u<n){const m=r(u,n)*o*(a?-1:1),d=c.clone().sub(e).normalize();c.add(d.multiplyScalar(m)),i.setXYZ(l,c.x,c.y,c.z)}}i.needsUpdate=!0},un=(t,e,n,o,a=F.UP,r=O.LINEAR)=>{const i=t.attributes.position,l=new s.Quaternion;for(let c=0;c<i.count;c++){const u=new s.Vector3;u.fromBufferAttribute(i,c);const h=u.distanceTo(e);if(h<n){const d=r(h,n)*o;l.setFromAxisAngle(a,d),u.sub(e).applyQuaternion(l).add(e),i.setXYZ(c,u.x,u.y,u.z)}}i.needsUpdate=!0},H={X:new s.Vector3(1,0,0),Y:new s.Vector3(0,1,0),Z:new s.Vector3(0,0,1),XY:new s.Vector3(1,1,0).normalize(),XZ:new s.Vector3(1,0,1).normalize(),YZ:new s.Vector3(0,1,1).normalize(),XYZ:new s.Vector3(1,1,1).normalize()};var A=(t=>(t.LEFT="left",t.RIGHT="right",t.TOP="top",t.BOTTOM="bottom",t.FRONT="front",t.BACK="back",t))(A||{});const E={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},oe=t=>1-Math.cos(t*Math.PI/2),re=t=>Math.sin(t*Math.PI/2),se=t=>-.5*(Math.cos(Math.PI*t)-1),ae=t=>t*t,ie=t=>1-Math.pow(1-t,2),ce=t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,le=t=>t*t*t,ue=t=>1-Math.pow(1-t,3),he=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,me=t=>t*t*t*t,de=t=>1-Math.pow(1-t,4),fe=t=>t<.5?8*t*t*t*t:1-Math.pow(-2*t+2,4)/2,pe=t=>t*t*t*t*t,Me=t=>1-Math.pow(1-t,5),ye=t=>t<.5?16*t*t*t*t*t:1-Math.pow(-2*t+2,5)/2,ge=t=>t===0?0:Math.pow(2,10*t-10),xe=t=>t===1?1:1-Math.pow(2,-10*t),we=t=>t===0?0:t===1?1:t<.5?Math.pow(2,20*t-10)/2:(2-Math.pow(2,-20*t+10))/2,ve=t=>1-Math.sqrt(1-Math.pow(t,2)),be=t=>Math.sqrt(1-Math.pow(t-1,2)),Se=t=>t<.5?(1-Math.sqrt(1-Math.pow(2*t,2)))/2:(Math.sqrt(1-Math.pow(-2*t+2,2))+1)/2,Ge=t=>t,Pe=t=>t*t*(3-2*t),Te=t=>1-Math.pow(1-t,.3),Ae=t=>Math.pow(t,.3),Be=t=>Math.log(Math.max(.01,t))/Math.log(2),Ce=t=>Math.sqrt(t),Ie=t=>1-t,Ee=t=>Math.exp(-Math.pow(t-.5,2)/(2*.5)),R={sineIn:oe,sineOut:re,sineInOut:se,quadIn:ae,quadOut:ie,quadInOut:ce,cubicIn:le,cubicOut:ue,cubicInOut:he,quartIn:me,quartOut:de,quartInOut:fe,quintIn:pe,quintOut:Me,quintInOut:ye,expoIn:ge,expoOut:xe,expoInOut:we,circIn:ve,circOut:be,circInOut:Se,linear:Ge,smoothstep:Pe,concave:Te,convex:Ae,logarithmic:Be,squareRoot:Ce,inverse:Ie,gaussian:Ee},Re=(t,e,n,o,a)=>{const r=Math.max(0,Math.min(1,t)),i=1-r;return i*i*i*e+3*i*i*r*n+3*i*r*r*o+r*r*r*a},Ve=(t,e=1)=>{const n=Math.max(.001,e);return(1-Math.exp(-n*t))/(1-Math.exp(-n))},Fe=(t,e=1,n=1)=>{const o=Math.max(0,Math.min(1,t));return e*Math.pow(o,n)},Oe=(t,e=1,n=1)=>{const o=Math.max(.001,Math.min(1,t));return e*Math.log(n*o+1)},Ue=(t,e=1,n=0,o=0)=>{const a=Math.max(0,Math.min(1,t));return e*a*a+n*a+o},De=(t,e,n,o)=>{const a=Math.max(0,Math.min(1,t)),r=1-a;return r*r*e+2*r*a*n+a*a*o},ke=(t,e=10)=>{const n=Math.max(0,Math.min(1,t));return 1/(1+Math.exp(-e*(n-.5)))},hn=t=>Math.sin(t*Math.PI*.5),I={CUBIC:Re,DAMPED:Ve,EXPONENTIAL:Fe,LOGARITHMIC:Oe,PARABOLIC:Ue,QUADRATIC:De,SIGMOID:ke,SINUSOIDAL:hn};class mn extends s.InstancedMesh{bubblePositions=[];velocities=[];width;height;depth;constructor(e={}){const{count:n=20,width:o=1.5,height:a=3,depth:r=1.5,geometry:i=new s.SphereGeometry(.1,6,6),material:l=new s.MeshStandardMaterial({color:16777215,transparent:!0,opacity:.6,roughness:.3,metalness:.3})}=e;super(i,l,n),this.height=a,this.width=o,this.depth=r;for(let c=0;c<this.count;c++){const u=new s.Vector3((Math.random()-.5)*o,Math.random()*(a-1)+.5,(Math.random()-.5)*r);this.bubblePositions.push(u),this.velocities.push(.01+Math.random()*.02),this.updateInstanceMatrix(c)}}updateInstanceMatrix(e){const n=this.bubblePositions[e],o=new s.Matrix4().setPosition(n);this.setMatrixAt(e,o),this.instanceMatrix.needsUpdate=!0}update(){for(let e=0;e<this.count;e++){const n=this.bubblePositions[e];n.y+=this.velocities[e],n.y>this.height&&(n.x=(Math.random()-.5)*this.width,n.y=0,n.z=(Math.random()-.5)*this.depth),this.updateInstanceMatrix(e)}}}class ze extends s.BufferGeometry{constructor(e=.1){super();const n=[],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];n.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 s.Float32BufferAttribute(n,3);this.setAttribute("position",r),this.setIndex(o),this.computeVertexNormals()}}class dn extends s.InstancedMesh{dummyMatrix;velocities;width;height;depth;constructor(e={}){const{count:n=200,width:o=20,height:a=10,depth:r=20,geometry:i=new ze,material:l=new s.MeshStandardMaterial({color:8956467,metalness:.1,roughness:.8,flatShading:!0,side:s.DoubleSide})}=e;super(i,l,n),this.dummyMatrix=new s.Matrix4,this.velocities=[],this.width=o,this.height=a,this.depth=r;for(let c=0;c<n;c++){const u=(Math.random()-.5)*o,h=Math.random()*(a-1)+.5,m=(Math.random()-.5)*r,d=(Math.random()-.5)*Math.PI,f=(Math.random()-.5)*Math.PI,p=(Math.random()-.5)*Math.PI;this.dummyMatrix.makeRotationFromEuler(new s.Euler(d,f,p)),this.dummyMatrix.setPosition(u,h,m),this.setMatrixAt(c,this.dummyMatrix);const M=new s.Vector3((Math.random()-.5)*.01,-.005,(Math.random()-.5)*.01);this.velocities.push(M)}this.instanceMatrix.needsUpdate=!0}update(){for(let e=0;e<this.count;e++){const n=new s.Matrix4;this.getMatrixAt(e,n);const o=new s.Vector3;o.setFromMatrixPosition(n);const a=this.velocities[e];o.add(a),o.y<0&&(o.set((Math.random()-.5)*this.width,Math.random()*(this.height-1)+.5,(Math.random()-.5)*this.depth),a.set((Math.random()-.5)*.01,-.005,(Math.random()-.5)*.01)),n.setPosition(o),this.setMatrixAt(e,n)}this.instanceMatrix.needsUpdate=!0}}const w=(t,e)=>{const n=t[0].index!==null,o=new Set(Object.keys(t[0].attributes)),a=new Set(Object.keys(t[0].morphAttributes)),r={},i={},l=t[0].morphTargetsRelative,c=new s.BufferGeometry;let u=0;if(t.forEach((h,m)=>{let d=0;if(n!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+m+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in h.attributes){if(!o.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+m+'. 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(h.attributes[f]),d++}if(d!==o.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+m+". Make sure all geometries have the same number of attributes."),null;if(l!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+m+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!a.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+m+". .morphAttributes must be consistent throughout all geometries."),null;i[f]===void 0&&(i[f]=[]),i[f].push(h.morphAttributes[f])}if(c.userData.mergedUserData=c.userData.mergedUserData||[],c.userData.mergedUserData.push(h.userData),e){let f;if(h.index)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+m+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,f,m),u+=f}}),n){let h=0;const m=[];t.forEach(d=>{const f=d.index;for(let p=0;p<f.count;++p)m.push(f.getX(p)+h);h+=d.attributes.position.count}),c.setIndex(m)}for(let h in r){const m=$(r[h]);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+h+" attribute."),null;c.setAttribute(h,m)}for(let h in i){const m=i[h][0].length;if(m===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[h]=[];for(let d=0;d<m;++d){const f=[];for(let M=0;M<i[h].length;++M)f.push(i[h][M][d]);const p=$(f);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+h+" morphAttribute."),null;c.morphAttributes[h].push(p)}}return c},$=t=>{let e,n,o,a=0;if(t.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(n===void 0&&(n=r.itemSize),n!==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&&n){const r=new e(a);let i=0;return t.forEach(l=>{r.set(l.array,i),i+=l.array.length}),new s.BufferAttribute(r,n,o)}};function fn(t,e=1e-4){e=Math.max(e,Number.EPSILON);const n={},o=t.getIndex(),a=t.getAttribute("position"),r=o?o.count:a.count;let i=0;const l=Object.keys(t.attributes),c={},u={},h=[],m=["getX","getY","getZ","getW"];for(let M=0,y=l.length;M<y;M++){const x=l[M];c[x]=[];const g=t.morphAttributes[x];g&&(u[x]=new Array(g.length).fill(0).map(()=>[]))}const d=Math.log10(1/e),f=Math.pow(10,d);for(let M=0;M<r;M++){const y=o?o.getX(M):M;let x="";for(let g=0,P=l.length;g<P;g++){const v=l[g],b=t.getAttribute(v),S=b.itemSize;for(let B=0;B<S;B++)x+=`${~~(b[m[B]](y)*f)},`}if(x in n)h.push(n[x]);else{for(let g=0,P=l.length;g<P;g++){const v=l[g],b=t.getAttribute(v),S=t.morphAttributes[v],B=b.itemSize,C=c[v],X=u[v];for(let U=0;U<B;U++){const D=m[U];if(C.push(b[D](y)),S)for(let T=0,qt=S.length;T<qt;T++)X[T].push(S[T][D](y))}}n[x]=i,h.push(i),i++}}const p=t.clone();for(let M=0,y=l.length;M<y;M++){const x=l[M],g=t.getAttribute(x),P=new g.array.constructor(c[x]),v=new s.BufferAttribute(P,g.itemSize,g.normalized);if(p.setAttribute(x,v),x in u)for(let b=0;b<u[x].length;b++){const S=t.morphAttributes[x][b],B=new S.array.constructor(u[x][b]),C=new s.BufferAttribute(B,S.itemSize,S.normalized);p.morphAttributes[x][b]=C}}return p.setIndex(h),p}class pn extends s.BufferGeometry{constructor(e=(a,r,i)=>i.set(a,r,Math.cos(a)*Math.sin(r)),n=8,o=8){super(),this.type="ParametricGeometry",this.parameters={func:e,slices:n,stacks:o};const a=[],r=[],i=[],l=[],c=1e-5,u=new s.Vector3,h=new s.Vector3,m=new s.Vector3,d=new s.Vector3,f=new s.Vector3,p=n+1;for(let M=0;M<=o;M++){const y=M/o;for(let x=0;x<=n;x++){const g=x/n;e(g,y,h),r.push(h.x,h.y,h.z),g-c>=0?(e(g-c,y,m),d.subVectors(h,m)):(e(g+c,y,m),d.subVectors(m,h)),y-c>=0?(e(g,y-c,m),f.subVectors(h,m)):(e(g,y+c,m),f.subVectors(m,h)),u.crossVectors(d,f).normalize(),i.push(u.x,u.y,u.z),l.push(g,y)}}for(let M=0;M<o;M++)for(let y=0;y<n;y++){const x=M*p+y,g=M*p+y+1,P=(M+1)*p+y+1,v=(M+1)*p+y;a.push(x,g,v),a.push(g,P,v)}this.setIndex(a),this.setAttribute("position",new s.Float32BufferAttribute(r,3)),this.setAttribute("normal",new s.Float32BufferAttribute(i,3)),this.setAttribute("uv",new s.Float32BufferAttribute(l,2))}}class j extends s.BufferGeometry{constructor(e=1,n=1.5,o=.5,a=.05,r=.05){super();const i=e,l=n,c=o,u=a,h=r,m=[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,-u,u,0,-u,u,l,-u,i,l,-u,u,0,-c+u,i,0,-c+u,i,l,-c+u,u,l,-c+u,u,0,-u,u,0,-c+u,u,l,-c+u,u,l,-u,0,l,0,i,l,0,i,l,-u,u,l,-u,0,l,-c,u,l,-c+u,i,l,-c+u,i,l,-c,0,l,0,u,l,-u,u,l,-c+u,0,l,-c,0,0,0,u,0,-u,i,0,-u,i,0,0,0,0,-c,i,0,-c,i,0,-c+u,u,0,-c+u,0,0,0,0,0,-c,u,0,-c+u,u,0,-u,i,0,0,i,0,-u,i,l,-u,i,l,0,i,0,-c,i,l,-c,i,l,-c+u,i,0,-c+u],d=[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),p=(e+o)/(e*2+o),M=[p,0,1,0,1,1,p,1,0,0,f,0,f,1,0,1,f,0,p,0,p,1,f,1,1,0,p,0,p,1,1,1,f,0,0,0,0,1,f,1,p,0,f,0,f,1,p,1,p,0,1,0,1,1,p,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],y=[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],x=new Float32Array(m),g=new Float32Array(d),P=new Float32Array(M),v=new Uint16Array(y),b=new s.BufferGeometry;b.setAttribute("position",new s.BufferAttribute(x,3)),b.setAttribute("normal",new s.BufferAttribute(g,3)),b.setAttribute("uv",new s.BufferAttribute(P,2)),b.setIndex(new s.BufferAttribute(v,1));const S=new s.BoxGeometry(e-u-h,l-h*2,c-u*2);S.translate((e-u-h)/2+u,l/2,-c/2),this.copy(w([b,S],!0))}}function Ne({scaleXMin:t=.4,scaleXMax:e=.7,scaleYMin:n=.3,scaleYMax:o=.95,scaleZMin:a=.1,scaleZMax:r=.5}={}){return new s.Vector3(_(t,e),ee(.25,n,o),te(.8,a,r))}function Z({coverMaterial:t,pagesMaterial:e,scales:n}){const o=new j,a=new s.InstancedMesh(o,[t,e],n.length),r=new s.Matrix4;let i=0;for(let l=0;l<n.length;l++){const c=n[l],u=new s.Matrix4;u.makeScale(c.x,c.y,c.z),r.identity(),r.multiply(u),r.setPosition(.01+Math.random()*.1,0,i+c.z*.5),a.setMatrixAt(l,r),i+=c.z*.5}return a}function Mn({coverMaterial:t,pagesMaterial:e,count:n=10,scaleXMin:o=.4,scaleXMax:a=.7,scaleYMin:r=.3,scaleYMax:i=.95,scaleZMin:l=.1,scaleZMax:c=.5}){const u=Array.from({length:n},()=>Ne({scaleXMin:o,scaleXMax:a,scaleYMin:r,scaleYMax:i,scaleZMin:l,scaleZMax:c}));return Z({coverMaterial:t,pagesMaterial:e,scales:u})}function yn({coverMaterial:t,pagesMaterial:e,length:n=10,scaleXMin:o=.4,scaleXMax:a=.7,scaleYMin:r=.3,scaleYMax:i=.95,scaleZMin:l=.1,scaleZMax:c=.5}){const u=[];let h=n;for(;h>0;){const m=Ne({scaleXMin:o,scaleXMax:a,scaleYMin:r,scaleYMax:i,scaleZMin:l,scaleZMax:c});m.z=Math.min(m.z,h),u.push(m),h-=m.z}return Z({coverMaterial:t,pagesMaterial:e,scales:u})}class Le extends s.Shape{constructor(e=1){super();for(let n=0;n<6;n++){const o=Math.PI/3*n,a=Math.cos(o)*e,r=Math.sin(o)*e;n===0?this.moveTo(a,r):this.lineTo(a,r)}this.closePath()}}class q extends s.ExtrudeGeometry{constructor(e=1,n=.01){const o=new Le(e);super(o,{depth:n,bevelEnabled:!1})}}function gn(t){const{width:e,depth:n,height:o,count:a,gap:r,material:i}=t,l=i||new s.MeshStandardMaterial({color:16777215}),c=e/a,u=(c-r)*2/3,h=Math.sqrt(3)*u+r,m=Math.floor(n/h),d=a*m,f=new q(u,o);f.rotateX(-Math.PI/2);const p=new s.InstancedMesh(f,l,d),M=new s.Object3D;let y=0;for(let x=0;x<a;x++)for(let g=0;g<m;g++){const P=x*c,v=g*h+x%2*(h/2),b=P-a*c/2+c/2,S=v-m*h/2+h/2;M.position.set(b,0,S),M.updateMatrix(),p.setMatrixAt(y++,M.matrix)}return p.instanceMatrix.needsUpdate=!0,p}function xn(t){const{width:e,depth:n,height:o,radius:a,gap:r,material:i}=t,l=i||new s.MeshStandardMaterial({color:16777215}),c=a*3/2+r,u=Math.sqrt(3)*a+r,h=Math.floor(e/c),m=Math.floor(n/u),d=h*m,f=new q(a,o);f.rotateX(-Math.PI/2);const p=new s.InstancedMesh(f,l,d),M=new s.Object3D;let y=0;for(let x=0;x<h;x++)for(let g=0;g<m;g++){const P=x*c,v=g*u+x%2*(u/2),b=P-h*c/2+c/2,S=v-m*u/2+u/2;M.position.set(b,0,S),M.updateMatrix(),p.setMatrixAt(y++,M.matrix)}return p.instanceMatrix.needsUpdate=!0,p}class wn extends s.BufferGeometry{constructor(e=2,n=.3,o=.6,a=5,r=5,i=Math.PI/4){super();const l=[],c=[];for(let f=0;f<a;f++){const p=f*n,M=p+n,y=f*o,x=y+o;l.push(-e/2,p,y,e/2,p,y,e/2,M,y,-e/2,M,y,-e/2,M,y,e/2,M,y,e/2,M,x,-e/2,M,x);const g=f*8;c.push(g,g+1,g+2,g,g+2,g+3),c.push(g+4,g+5,g+6,g+4,g+6,g+7)}const u=a*n,h=a*o,m=e*2;l.push(-m/2,u,h,m/2,u,h,m/2,u,h+o,-m/2,u,h+o);const d=a*8;c.push(d,d+1,d+2,d,d+2,d+3);for(let f=0;f<2;f++){const p=f===0?1:-1;for(let M=0;M<r;M++){const y=u+M*n,x=y+n,g=p*(m/4),P=h+o,v=M*o*Math.cos(i),b=M*o*Math.sin(i),S=g+p*v-e/2*Math.cos(i),B=g+p*v+e/2*Math.cos(i),C=P+b,X=S+p*o*Math.cos(i),U=B+p*o*Math.cos(i),D=C+o*Math.sin(i);l.push(S,y,C,B,y,C,B,x,C,S,x,C,S,x,C,B,x,C,U,x,D,X,x,D);const T=d+4+f*r*8+M*8;c.push(T,T+1,T+2,T,T+2,T+3),c.push(T+4,T+5,T+6,T+4,T+6,T+7)}}this.setIndex(c),this.setAttribute("position",new s.Float32BufferAttribute(l,3)),this.computeVertexNormals()}}class _e extends s.BufferGeometry{constructor({width:e=5,height:n=3,depth:o=5,wallThickness:a=.05}={}){super();const r=e,i=n,l=o,c=a,u=[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],h=[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],m=[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],d=[.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(u),p=new Float32Array(m),M=new Float32Array(d);this.setAttribute("position",new s.BufferAttribute(f,3)),this.setAttribute("normal",new s.BufferAttribute(p,3)),this.setAttribute("uv",new s.BufferAttribute(M,2)),this.setIndex(h),this.addGroup(0,12,0),this.addGroup(12,6,1),this.addGroup(18,54,2)}}class vn extends s.BufferGeometry{constructor(e=2,n=.3,o=.5,a=5,r=2){super();const i=[],l=[];for(let m=0;m<a;m++){const d=m*n,f=d+n,p=m*o,M=p+o;i.push(-e/2,d,p,e/2,d,p,e/2,f,p,-e/2,f,p,-e/2,f,p,e/2,f,p,e/2,f,M,-e/2,f,M);const y=m*8;l.push(y,y+1,y+2,y,y+2,y+3),l.push(y+4,y+5,y+6,y+4,y+6,y+7)}const c=a*n,u=a*o;i.push(-e/2,c,u,e/2,c,u,e/2,c,u+r,-e/2,c,u+r);const h=a*8;l.push(h,h+1,h+2,h,h+2,h+3);for(let m=0;m<a;m++){const d=c+m*n,f=d+n,p=-e/2-m*o,M=p-o;i.push(p,d,u+r,p,d,u+r-e,p,f,u+r-e,p,f,u+r,p,f,u+r,p,f,u+r-e,M,f,u+r-e,M,f,u+r);const y=h+4+m*8;l.push(y,y+1,y+2,y,y+2,y+3),l.push(y+4,y+5,y+6,y+4,y+6,y+7)}this.setIndex(l),this.setAttribute("position",new s.Float32BufferAttribute(i,3)),this.computeVertexNormals()}}class bn extends s.BufferGeometry{constructor(e=1,n=.4,o=.2,a=20,r=2,i=Math.PI/8){super();const l=[],c=[];let u=0;for(let h=0;h<a;h++){const m=r*Math.cos(u),d=r*Math.sin(u),f=h*o,p=f+o;l.push(m-e/2*Math.cos(u),f,d-e/2*Math.sin(u),m+e/2*Math.cos(u),f,d+e/2*Math.sin(u),m+e/2*Math.cos(u),p,d+e/2*Math.sin(u),m-e/2*Math.cos(u),p,d-e/2*Math.sin(u)),l.push(m-e/2*Math.cos(u),p,d-e/2*Math.sin(u),m+e/2*Math.cos(u),p,d+e/2*Math.sin(u),m+e/2*Math.cos(u)-n*Math.sin(u),p,d+e/2*Math.sin(u)+n*Math.cos(u),m-e/2*Math.cos(u)-n*Math.sin(u),p,d-e/2*Math.sin(u)+n*Math.cos(u));const M=h*8;c.push(M,M+1,M+2,M,M+2,M+3),c.push(M+4,M+5,M+6,M+4,M+6,M+7),u+=i}this.setIndex(c),this.setAttribute("position",new s.Float32BufferAttribute(l,3)),this.computeVertexNormals()}}class Sn extends s.BufferGeometry{constructor(e=2,n=.3,o=.5,a=10){super();const r=[],i=[];for(let l=0;l<a;l++){const c=l*n,u=c+n,h=l*o,m=h+o;r.push(-e/2,c,h,e/2,c,h,e/2,u,h,-e/2,u,h,-e/2,u,h,e/2,u,h,e/2,u,m,-e/2,u,m);const d=l*8;i.push(d,d+1,d+2,d,d+2,d+3),i.push(d+4,d+6,d+5,d+4,d+7,d+6)}this.setIndex(i),this.setAttribute("position",new s.Float32BufferAttribute(r,3)),this.computeVertexNormals()}}class He extends s.BufferGeometry{constructor(){super();const e=[new s.Vector2(0,0),new s.Vector2(1.2,0),new s.Vector2(1.5,1.5),new s.Vector2(1,3),new s.Vector2(.6,3.5),new s.Vector2(.5,3.5)],n=new s.LatheGeometry(e,10),o=new s.CylinderGeometry(.6,.5,.3,10);o.translate(0,3.5,0),this.copy(w([n,o],!0))}}function K(t,e,n,o,a){const r=(o-e)/(n-t);return t+(a-e)/r}function qe(t,e,n,o,a){const r=(o-e)/(n-t);return e+r*(a-t)}const Gn={calculateXFromSlopeIntercept:K,calculateYFromSlopeIntercept:qe};class Xe extends s.BufferGeometry{constructor(){super();const e=[new s.Vector2(0,0),new s.Vector2(.8,0),new s.Vector2(1,1.5),new s.Vector2(.5,2.2),new s.Vector2(.6,2.5),new s.Vector2(.5,2.5)],n=new s.LatheGeometry(e,10),o=new s.CylinderGeometry(.55,.45,.2,10);o.translate(0,2.5,0);const a=[new s.Vector2(0,0),new s.Vector2(.8,0),new s.Vector2(K(.8,0,1,1.5,1),1),new s.Vector2(0,1)],r=new s.LatheGeometry(a,10);r.translate(0,.1,0),r.scale(.9,.9,.9),this.copy(w([n,o,r],!0))}}class Ye extends s.BufferGeometry{constructor({radius:e=.5,neckRadius:n=.2,height:o=3,neckHeight:a=1,segments:r=16}={}){super();const i=o-a,l=new s.CylinderGeometry(e,e,i,r);l.translate(0,i/2,0);const c=.3,u=new s.CylinderGeometry(n,e,c,r);u.translate(0,i+c/2,0);const h=new s.CylinderGeometry(n,n,a,r);h.translate(0,i+c+a/2,0),this.copy(w([l,u,h],!1))}}class je extends s.BufferGeometry{constructor(e=.4,n=1.2,o=.2){super();const a=n*.6,r=new s.BoxGeometry(e/2,a,o);r.translate(0,a/2,0);const i=e*1.5,l=new s.BoxGeometry(i,e/4,o);l.translate(0,a*.75,0),this.copy(w([r,l],!1)),this.computeVertexNormals()}}class Ze extends s.BufferGeometry{constructor(){super();const e=new s.BoxGeometry(5,1,5);e.translate(0,.5,0);const n=new s.BoxGeometry(4,3,4);n.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(u=>{const h=new s.CylinderGeometry(.2,.2,3.5,16);h.translate(u[0],u[1],u[2]),a.push(h)});const r=new s.ConeGeometry(3.5,2,4);r.rotateY(Math.PI/4),r.translate(0,5,0);const i=new s.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 s.ExtrudeGeometry(i,l);c.translate(0,.5,1.7),c.setIndex([...Array(c.attributes.position.count).keys()]),this.copy(w([e,w([n,...a],!1),r,c],!0)),this.computeVertexNormals()}}class Ke extends s.BufferGeometry{constructor(e=1.75,n=.75){super();const o=e*.05,a=e*.15,r=e*.15,i=e*.75;let l=0;const c=new s.BoxGeometry(n,o,n);c.translate(0,l+o/2,0),l+=o;const u=new s.BoxGeometry(n*.8,a,n*.8);u.translate(0,l+a/2,0),l+=a;const h=new s.BoxGeometry(n*.6,r,n*.6);h.translate(0,l+r/2,0),l+=r;const m=new s.BoxGeometry(n*.4,i,n*.4);m.translate(0,l+i/2,0),l+=i;const d=new s.ConeGeometry(n*.4/Math.sqrt(2),.1,4,1,!1,Math.PI/4);d.translate(0,l+.1/2,0),this.copy(w([c,u,h,m,d],!1)),this.computeVertexNormals()}}class We extends s.BufferGeometry{constructor(e=.6,n=1,o=.2,a=.6){super();const r=n-a/2,i=new s.BoxGeometry(e,r,o);i.translate(0,r/2,0);const l=new s.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(w([i,l],!1)),this.computeVertexNormals()}}class Qe extends s.BufferGeometry{constructor(e=.5,n=.8,o=.15){super();const a=new s.BoxGeometry(e,n,o);a.translate(0,n/2,0),this.copy(a)}}class Je extends s.BufferGeometry{constructor({height:e=2.25}={}){super();const n=new s.BoxGeometry(1.2,.5,1.2);n.translate(0,.25,0);const o=new s.BoxGeometry(1,e,1);o.translate(0,.5+e/2,0);const a=new s.BoxGeometry(1.4,.3,1.4);a.translate(0,.5+e+.15,0),this.copy(w([n,o,a],!1))}}class W extends s.BufferGeometry{constructor({barHeight:e=2,barRadius:n=.05,spikeHeight:o=.3,spikeRadius:a=.075,spikeScaleZ:r=1,radialSegments:i=8}={}){super();const l=new s.CylinderGeometry(n,n,e,i);l.translate(0,e/2,0);const c=new s.ConeGeometry(a,o,i);c.translate(0,e+o/2,0),c.scale(1,1,r),this.copy(w([l,c],!1))}}class $e extends s.BufferGeometry{constructor({count:e=20,spacing:n=.4,barHeight:o=2,barRadius:a=.05,spikeHeight:r=.3,spikeRadius:i=.075,spikeScaleZ:l=1,railHeight:c=.1,railDepth:u=.05,railOffset:h=0,radialSegments:m=8}={}){super();const d=[],f=new W({barHeight:o,barRadius:a,spikeHeight:r,spikeRadius:i,spikeScaleZ:l,radialSegments:m}),p=new s.BoxGeometry(e*n,c,u);for(let x=0;x<e;x++){const g=f.clone();g.translate(x*n,0,0),d.push(g)}const M=p.clone();M.translate(n*(e-1)/2,o-h-c/2,0),d.push(M);const y=p.clone();y.translate(n*(e-1)/2,c/2,0),d.push(y),this.copy(w(d))}}class et extends s.BufferGeometry{constructor({width:e=5,height:n=8,depth:o=1,shelves:a=4,frameThickness:r=.1,open:i=!1}={}){super();const l=n,c=e,u=o,h=new s.BoxGeometry(r,l,u),m=new s.BoxGeometry(c-2*r,r,u),d=h.clone();d.translate(-c/2+r/2,l/2,0);const f=h.clone();f.translate(c/2-r/2,l/2,0);const p=m.clone();p.translate(0,l-r/2,0);const M=m.clone();M.translate(0,r/2,0);const y=new s.BoxGeometry(c,l,r);y.translate(0,l/2,-u/2+r/2);const x=[],g=(l-r)/(a+1);for(let P=1;P<=a;P++){const v=m.clone();v.translate(0,r/2+P*g,0),x.push(v)}this.copy(w([d,f,p,M,...i?[]:[y],...x],!1))}}class tt extends s.BufferGeometry{constructor(){super();const e=new s.BoxGeometry(5,.3,3);e.translate(0,3.15,0);const n=[new s.Vector2(.2,0),new s.Vector2(.25,.5),new s.Vector2(.15,1.5),new s.Vector2(.3,3)],o=new s.LatheGeometry(n,32),r=w([[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(w([e,r],!0))}}class Q extends pn{constructor({height:e=.25,radius:n=.05,segmentsU:o=16,segmentsV:a=16}={}){super((r,i,l)=>{const c=r*Math.PI*2,u=Math.sin(i*Math.PI),h=n*u*Math.cos(c),m=i*e,d=n*u*Math.sin(c);l.set(h,m,-d)},o,a)}}class nt extends s.BufferGeometry{constructor({radiusTop:e=.2,radiusBottom:n=.2,height:o=1,flameHeight:a=.25,flameRadius:r=.05,segments:i=16}={}){super();const l=new s.CylinderGeometry(e,n,o,i);l.translate(0,o/2,0);const c=new Q({segmentsU:i,segmentsV:i,height:a,radius:r});c.translate(0,o,0),this.copy(w([l,c],!0))}}class Pn extends s.BufferGeometry{constructor(e=1,n=2,o=.5,a=Math.PI/4){super();const r=n*Math.tan(a),i=e,l=n,c=o,u=[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],h=[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],m=[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],d=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(u),p=new Float32Array(h),M=new Float32Array(d),y=new Uint16Array(m);this.setAttribute("position",new s.BufferAttribute(f,3)),this.setAttribute("normal",new s.BufferAttribute(p,3)),this.setAttribute("uv",new s.BufferAttribute(M,2)),this.setIndex(new s.BufferAttribute(y,1)),this.center()}}class ot extends s.BufferGeometry{constructor(){super();const e=[],n=[];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,u=Math.random()*Math.PI,h=(Math.random()-.5)*4,m=0,d=(Math.random()-.5)*4,f=new s.DodecahedronGeometry(1,0);f.scale(a,r,i),f.rotateX(l),f.rotateY(c),f.rotateZ(u),f.translate(h,m,d),e.push(f);const p=new s.DodecahedronGeometry(1,0);p.scale(a*.9,r*.5,i*.9),p.rotateX(l),p.rotateY(c),p.rotateZ(u),p.translate(h,m+.3,d),n.push(p)}this.copy(w([w(e),w(n)],!0))}}function rt(t,e=H.XYZ,n=.5,o=2){t.deleteAttribute("uv"),t.deleteAttribute("normal"),t=fn(t),t.computeVertexNormals();const a=t.getAttribute("position");for(let r=0;r<a.count;r++){const i=new s.Vector3().fromBufferAttribute(a,r),l=Math.random()*(o-n)+n,c=e.clone().multiplyScalar(l);i.add(c),a.setXYZ(r,i.x,i.y,i.z)}return a.needsUpdate=!0,t.computeVertexNormals(),t}class st extends s.BufferGeometry{constructor(e=1,n=4,o=4){super();const a=new s.SphereGeometry(e,n,o);this.copy(rt(a,H.XYZ,.5,1)),this.computeVertexNormals(),this.center()}}class at extends s.BufferGeometry{constructor(){super();const e=[];for(let n=0;n<5;n++){const o=new s.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(w(e))}}class it extends s.Shape{constructor(e=5,n=.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)*(n/Math.cos(i)),u=-Math.sin(a*l-i*3)*(n/Math.cos(i)),h=Math.cos(a*l-r)*n,m=-Math.sin(a*l-r)*n;this.quadraticCurveTo(c,u,h,m),c=Math.cos(a*l-i)*(n/Math.cos(i)),u=-Math.sin(a*l-i)*(n/Math.cos(i)),h=Math.cos(a*l)*o,m=-Math.sin(a*l)*o,this.quadraticCurveTo(c,u,h,m)}this.closePath()}}class ct extends s.ExtrudeGeometry{constructor(e=5,n=.5,o=1,a=.25){const r=new it(e,n,o);super(r,{depth:a,bevelEnabled:!1})}}class lt extends s.Shape{constructor(e=5,n=.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)*n,-Math.sin(i*c-l*3)*n),this.lineTo(Math.cos(i*c-l*2)*n,-Math.sin(i*c-l*2)*n),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 s.Path,u=Math.PI*2/a;c.moveTo(Math.cos(0)*r,-Math.sin(0)*r);for(let h=1;h<a;++h)c.lineTo(Math.cos(u*h)*r,-Math.sin(u*h)*r);c.lineTo(Math.cos(0)*r,-Math.sin(0)*r),this.holes.push(c)}}}class ut extends s.ExtrudeGeometry{constructor(e=5,n=.5,o=1,a=5,r=.25,i=.25){const l=new lt(e,n,o,a,r);super(l,{depth:i,bevelEnabled:!1})}}class ht extends s.Shape{constructor(e=1,n=2.1,o=1.4,a=1.6){super(),this.moveTo(0,o*e/3),this.bezierCurveTo(-n*.375*e,o*e,-n*e,o*e/3,0,-a*e),this.bezierCurveTo(n*e,o*e/3,n*.375*e,o*e,0,o*e/3)}}class mt extends s.ExtrudeGeometry{constructor(e=1,n=2.1,o=1.4,a=1.6,r=.25){const i=new ht(e,n,o,a);super(i,{depth:r,bevelEnabled:!1})}}class dt extends s.Shape{constructor(e=5,n=.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)*n,Math.sin(a*i-r)*n),this.lineTo(Math.cos(a*i)*o,Math.sin(a*i)*o);this.closePath()}}class ft extends s.ExtrudeGeometry{constructor(e=5,n=.5,o=1,a=.25){const r=new dt(e,n,o);super(r,{depth:a,bevelEnabled:!1})}}class pt extends s.BufferGeometry{constructor(e=.1,n=.1,o=.4,a=8){super();const r=new s.CylinderGeometry(e*.6,n*.6,o,a);r.translate(0,0,0);const i=new s.SphereGeometry(e,a,a),l=i.clone(),c=i.clone(),u=i.clone(),h=i.clone();l.translate(0,o/2+e*.6,-e*.6),c.translate(0,o/2+e*.6,e*.6),u.translate(0,-o/2-n*.6,-n*.6),h.translate(0,-o/2-n*.6,n*.6),this.copy(w([r,l,c,u,h],!1))}}class Mt extends s.BufferGeometry{constructor({flaskRadius:e=1,neckRadius:n=.3,height:o=2.5,neckHeight:a=1,radialSegments:r=16}={}){super();const i=[new s.Vector2(0,0),new s.Vector2(e*.875,0),new s.Vector2(e,.1),new s.Vector2(n,o),new s.Vector2(n,o+a),new s.Vector2(n*1.1,o+a+.3)],l=new s.LatheGeometry(i,r);this.copy(w([l],!1))}}const Tn=(t,e)=>t/(1-Math.cos(e)),J=(t,e)=>t/(2*Math.sin(e)),yt=(t,e)=>t*(1-Math.cos(e)),An=(t,e)=>2*t*Math.sin(e),Y=(t,e)=>{const n=2*e;return Math.asin(n/(2*t))},Bn=(t,e,n)=>({x:t*Math.sin(n)*Math.cos(e),y:t*Math.sin(n)*Math.sin(e),z:t*Math.cos(n)}),Cn=(t,e,n)=>{const o=Math.sqrt(t*t+e*e+n*n),a=Math.atan2(e,t),r=Math.acos(n/o);return{radius:o,theta:a,phi:r}};function gt(t,e,n,o=0,a=0,r=32){const i=o?Y(t,o):0,l=a?Math.PI-Y(t,a):Math.PI,c=[];for(let u=0;u<=r;u++){const h=l-(l-i)/r*u,m=t*Math.sin(h),d=e*Math.cos(h)+n;c.push(new s.Vector2(m,d))}return[...c]}class xt extends s.BufferGeometry{constructor(){super();const e=[...gt(1,1,.5,.2,0,32),new s.Vector2(.2,3)],n=new s.LatheGeometry(e,32);this.copy(n)}}class wt extends s.BufferGeometry{constructor(){super();const e=[new s.Vector2(1,0),new s.Vector2(1.2,.5),new s.Vector2(1.4,1.5),new s.Vector2(1.3,1.8),new s.Vector2(.8,1.8)],n=new s.LatheGeometry(e,12),o=new s.CircleGeometry(1,12);o.rotateX(-Math.PI/2),o.translate(0,0,0),this.copy(w([n,o],!1))}}class vt extends s.BufferGeometry{constructor({radius:e=.3,height:n=.4,count:o=3,thickness:a=.03,radialSegments:r=16}={}){super();const i=new s.TorusGeometry(e,a,8,r);i.rotateX(Math.PI/2),i.translate(0,n,0);const l=new s.CylinderGeometry(a*.6,a*.6,n,r),c=[];for(let u=0;u<o;u++){const h=u/o*Math.PI*2,m=l.clone();m.translate(Math.cos(h)*e,n/2,Math.sin(h)*e),c.push(m)}this.copy(w([i,...c],!1))}}class bt extends s.BufferGeometry{constructor(){super();const e=new s.CylinderGeometry(.5,.6,.3,16);e.translate(0,.15,0);const n=new s.CylinderGeometry(.15,.15,2,12,1,!0);n.translate(0,1.3,0);const o=new s.SphereGeometry(.3,16,16);o.translate(0,2.4,0),this.copy(w([e,w([n,o])],!0))}}class L extends s.BufferGeometry{constructor(e=.2,n=.2,o=3,a=32,r=!0){super();const i=new s.CylinderGeometry(e,n,o,a,1,r),l=new s.SphereGeometry(n,a,a/2,0,Math.PI*2,Math.PI/2,Math.PI/2);l.translate(0,-(o/2),0),this.copy(w([i,l],!1))}}class St extends s.BufferGeometry{constructor({radius:e=3,height:n=.6,widthSegments:o=64,heightSegments:a=16,phiStart:r=0,phiLength:i=Math.PI*2}={}){super(),this.copy(new s.SphereGeometry(e,o,a,r,i,0,Math.PI/2)),this.scale(1,n/e,1)}}class Gt extends s.BufferGeometry{constructor({radius:e=J(5,Math.PI/10),widthSegments:n=64,heightSegments:o=32,phiStart:a=0,phiLength:r=Math.PI*2,thetaLength:i=Math.PI/10}={}){super(),this.copy(new s.SphereGeometry(e,n,o,a,r,0,i));const l=yt(e,i);this.translate(0,-e+l,0)}}class Pt extends s.BufferGeometry{constructor({trunkRadiusTop:e=.25,trunkRadiusBottom:n=.4,trunkHeight:o=2.5,trunkSegments:a=14,leafSize:r=.8,leafCount:i=6,leafDetail:l=0,leafSpreadRadius:c=1.5}={}){super();const u=new s.CylinderGeometry(e,n,o,a);u.translate(0,o/2,0);const h=[];for(let m=0;m<i;m++){const d=new s.DodecahedronGeometry(r,l);d.translate((Math.random()-.5)*c,(Math.random()-.5)*r+o,(Math.random()-.5)*c),h.push(d)}this.copy(w([u.toNonIndexed(),w(h,!1)],!0)),this.computeVertexNormals()}}class In extends s.Mesh{constructor({width:e=5,height:n=3,depth:o=5,wallThickness:a=.05,interiorColor:r=E.WHITE_SMOKE,floorColor:i=E.RAW_SIENNA,exteriorColor:l=E.GRAY}={}){super(new _e({width:e,height:n,depth:o,wallThickness:a}),[new s.MeshStandardMaterial({color:r}),new s.MeshStandardMaterial({color:i}),new s.MeshStandardMaterial({color:l})])}}const Tt={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 En extends s.Mesh{constructor(){super(new s.SphereGeometry(5,32,32),new s.ShaderMaterial(Tt))}}class Rn extends s.Mesh{constructor({width:e=1,height:n=1.5,depth:o=.5,coverThickness:a=.05,pageIndent:r=.05,coverColor:i=E.DARK_RED,pageColor:l=E.TITANIUM_WHITE}={}){super(new j(e,n,o,a,r),[new s.MeshStandardMaterial({color:i,metalness:.1,roughness:.7,flatShading:!0}),new s.MeshStandardMaterial({color:l,flatShading:!0})])}}class Vn extends s.Mesh{constructor(){super(new He,[new s.MeshStandardMaterial({color:8965290,transparent:!0,depthWrite:!1,opacity:.4,roughness:.1,metalness:.5}),new s.MeshStandardMaterial({color:9127187,roughness:1})])}}class Fn extends s.Mesh{constructor(){super(new Xe,[new s.MeshStandardMaterial({color:8965375,transparent:!0,depthWrite:!1,opacity:.5,roughness:.1,metalness:.3}),new s.MeshStandardMaterial({color:9127187,roughness:1}),new s.MeshStandardMaterial({color:E.PINK_SHERBET,transparent:!0,depthWrite:!1,opacity:.5})])}}class On extends s.Mesh{constructor(){super(new Ye,new s.MeshPhysicalMaterial({color:5597999,roughness:.1,transmission:.9,thickness:.2,metalness:0,clearcoat:1,clearcoatRoughness:.1}))}}class Un extends s.Mesh{constructor({width:e=.4,height:n=1.2,depth:o=.2}={}){super(new je(e,n,o),new s.MeshStandardMaterial({color:7829367,roughness:.8}))}}class Dn extends s.Mesh{constructor(){super(new Ze,[new s.MeshStandardMaterial({color:8421504,flatShading:!0}),new s.MeshStandardMaterial({color:6908265,flatShading:!0}),new s.MeshStandardMaterial({color:5263440,flatShading:!0}),new s.MeshStandardMaterial({color:4210752,flatShading:!0})])}}class kn extends s.Mesh{constructor({totalHeight:e=1.75,baseWidth:n=.75}={}){super(new Ke(e,n),new s.MeshStandardMaterial({color:7829367,roughness:.8}))}}class zn extends s.Mesh{constructor(e=.6,n=1,o=.2,a=.6){super(new We(e,n,o,a),new s.MeshStandardMaterial({color:7829367,roughness:.8}))}}class Nn extends s.Mesh{constructor(e=.5,n=.8,o=.15){super(new Qe(e,n,o),new s.MeshStandardMaterial({color:7829367,roughness:.8}))}}class Ln extends s.Mesh{constructor({height:e=2.25}={}){super(new Je({height:e}),new s.MeshStandardMaterial({color:9141627,flatShading:!0}))}}class _n extends s.Mesh{constructor({barHeight:e=2,barRadius:n=.05,spikeHeight:o=.3,spikeRadius:a=.075,spikeScaleZ:r=1,radialSegments:i=8}={}){super(new W({barHeight:e,barRadius:n,spikeHeight:o,spikeRadius:a,spikeScaleZ:r,radialSegments:i}),new s.MeshStandardMaterial({color:3355443,metalness:.8,roughness:.4}))}}class Hn extends s.Mesh{constructor({count:e=20,spacing:n=.4,barHeight:o=2,barRadius:a=.05,spikeHeight:r=.3,spikeRadius:i=.075,spikeScaleZ:l=1,railHeight:c=.1,railDepth:u=.05,railOffset:h=0,radialSegments:m=8}={}){super(new $e({count:e,spacing:n,barHeight:o,barRadius:a,spikeHeight:r,spikeRadius:i,spikeScaleZ:l,railHeight:c,railDepth:u,railOffset:h,radialSegments:m}),new s.MeshStandardMaterial({color:3355443,metalness:.8,roughness:.4}))}}class qn extends s.Mesh{constructor({width:e=5,height:n=8,depth:o=1,shelves:a=4,frameThickness:r=.1,open:i=!1}={}){super(new et({width:e,height:n,depth:o,shelves:a,frameThickness:r,open:i}),new s.MeshStandardMaterial({color:9127187}))}}class Xn extends s.Mesh{constructor(){super(new tt,[new s.MeshStandardMaterial({color:9132587}),new s.MeshStandardMaterial({color:4929057})])}}class Yn extends s.Mesh{constructor({radiusTop:e=.2,radiusBottom:n=.2,height:o=1,flameHeight:a=.25,flameRadius:r=.05,segments:i=16}={}){super(new nt({radiusTop:e,radiusBottom:n,height:o,flameHeight:a,flameRadius:r,segments:i}),[new s.MeshStandardMaterial({color:16777215}),new s.MeshStandardMaterial({color:16766720,emissive:16753920,emissiveIntensity:.35})])}}class jn extends s.Mesh{constructor({height:e=.25,radius:n=.05,segmentsU:o=16,segmentsV:a=16}={}){super(new Q({segmentsU:o,segmentsV:a,height:e,radius:n}),new s.MeshStandardMaterial({color:16766720,emissive:16753920,emissiveIntensity:.35}))}}class Zn extends s.Group{constructor(e=1.3,n=.5){super();const o=new s.CylinderGeometry(n,n,.2,16),a=new s.MeshStandardMaterial({color:9127187,flatShading:!0}),r=new s.Mesh(o,a);r.position.set(0,0,0),this.add(r);const i=new s.CylinderGeometry(n*.9,n*.9,e),l=new s.MeshStandardMaterial({color:16766720,flatShading:!0,transparent:!0,opacity:.6}),c=new s.Mesh(i,l);c.position.set(0,e/2+.1,0),this.add(c);const u=new s.ConeGeometry(n*1.1,.5,8),h=new s.MeshStandardMaterial({color:9127187,flatShading:!0}),m=new s.Mesh(u,h);m.position.set(0,e+.35,0),this.add(m);const d=new s.TorusGeometry(n*.8,.05,8,16),f=new s.MeshStandardMaterial({color:9127187,flatShading:!0}),p=new s.Mesh(d,f);p.position.set(0,e+.85,0),this.add(p);const M=new s.PointLight(16755200,1.5,15);M.position.set(0,e/2+.1,0),M.castShadow=!0,this.add(M)}}class Kn extends s.Mesh{constructor(){super(new ot,[new s.MeshStandardMaterial({color:8421504,flatShading:!0}),new s.MeshStandardMaterial({color:4950843,flatShading:!0,opacity:.8,transparent:!0})])}}class Wn extends s.Mesh{constructor(e=1,n=4,o=4){super(new st(e,n,o),new s.MeshStandardMaterial({color:8421504,flatShading:!0}))}}class Qn extends s.Mesh{constructor(){super(new at,new s.MeshStandardMaterial({color:8421504,flatShading:!0}))}}class Jn extends s.Group{constructor(){super();const e=new s.CylinderGeometry(.3,.4,.1,16),n=new s.MeshStandardMaterial({color:3355443,roughness:.6,metalness:.3}),o=new s.Mesh(e,n);o.position.y=.05;const a=new s.CylinderGeometry(.1,.1,.7,16),r=new s.MeshStandardMaterial({color:5592405,roughness:.5,metalness:.4}),i=new s.Mesh(a,r);i.position.y=.4;const l=new s.ConeGeometry(.075,.2,16),c=new s.MeshStandardMaterial({color:16733440,emissive:16733440,emissiveIntensity:.6,transparent:!0,opacity:.8}),u=new s.Mesh(l,c);u.position.y=.8,this.add(o,i,u)}}class $n extends s.Group{constructor(){super();const e=new s.BoxGeometry(3,4,.1),n=new s.MeshStandardMaterial({color:3026478,roughness:.8,metalness:.6}),o=new s.BoxGeometry(.2,.5,.2),a=new s.MeshStandardMaterial({color:11184810,roughness:.5,metalness:.7}),r=new s.CylinderGeometry(.3,.3,.1,16),i=new s.MeshStandardMaterial({color:5592405,roughness:.7,metalness:.5}),l=new s.Mesh(e,n);for(let y=-1;y<=1;y++){const x=new s.Mesh(o,a);x.position.set(y,1.5,.1),l.add(x)}const c=new s.Mesh(r,i);c.rotation.x=Math.PI/2,c.position.set(0,.5,.15),l.add(c);const u=new s.SphereGeometry(.15,8,8),h=new s.MeshStandardMaterial({color:16711680,emissive:16711680,emissiveIntensity:.5}),m=new s.Mesh(u,h);m.position.set(0,-1,.1),l.add(m),this.add(l);let d=.015,f=.8,p=.2;function M(){requestAnimationFrame(M);const y=p+Math.abs(Math.sin(Date.now()*d))*(f-p);m.material.emissiveIntensity=y}M()}}class eo extends s.Mesh{constructor({flaskRadius:e=1,neckRadius:n=.3,height:o=2.5,neckHeight:a=1,radialSegments:r=16}={}){super(new Mt({flaskRadius:e,neckRadius:n,height:o,neckHeight:a,radialSegments:r}),new s.MeshPhysicalMaterial({color:8965375,transparent:!0,opacity:.4,roughness:.1,metalness:.1,reflectivity:.8,transmission:.9,side:s.DoubleSide}))}}class to extends s.Mesh{constructor(){super(new xt,new s.MeshPhysicalMaterial({color:8965375,transparent:!0,depthWrite:!1,opacity:.4,roughness:.1,metalness:.1,reflectivity:.8,transmission:.9,side:s.DoubleSide}))}}class no extends s.Group{constructor(){super();const e=new s.BoxGeometry(2,3,.1),n=new s.MeshStandardMaterial({color:3355443,roughness:.8,metalness:.5}),o=new s.Mesh(e,n),a=new s.CylinderGeometry(.1,.1,.2,8),r=new s.CylinderGeometry(.05,.05,1,8),i=new s.MeshStandardMaterial({color:11184810,roughness:.5,metalness:.7});for(let l=-.5;l<=.5;l+=.5){const c=new s.Mesh(a,i);c.position.set(l,1,.1);const u=new s.Mesh(r,i);u.position.y=.5,c.add(u),this.add(c)}this.add(o)}}class oo extends s.Group{constructor(){super();const e=new s.BoxGeometry(1,.2,.5),n=new s.MeshStandardMaterial({color:4473924,roughness:.6,metalness:.3}),o=new s.Mesh(e,n);o.position.y=.1;const a=new s.BoxGeometry(.2,1,.2),r=new s.Mesh(a,n);r.position.set(0,.6,-.2);const i=new s.CylinderGeometry(.1,.1,.4,8),l=new s.MeshStandardMaterial({color:3355443,roughness:.5,metalness:.6}),c=new s.Mesh(i,l);c.position.set(0,1.1,-.35),c.rotation.x=-Math.PI/4;const u=new s.BoxGeometry(.6,.1,.6),h=new s.MeshStandardMaterial({color:5592405,roughness:.8,metalness:.2}),m=new s.Mesh(u,h);m.position.set(0,.6,0),this.add(o,r,c,m)}}class ro extends s.Group{constructor(){super();const e=new wt,n=new s.CylinderGeometry(.2,.3,1.5,8);n.translate(0,.75,0);const o=new s.MeshStandardMaterial({color:6045747,roughness:1,metalness:0,side:s.DoubleSide}),a=new s.MeshStandardMaterial({color:9132587,roughness:.8,metalness:.1}),r=new s.Mesh(e,o);r.castShadow=!0;const i=new s.Mesh(n,a);i.castShadow=!0,i.position.set(.3,1.3,0),i.rotation.z=Math.PI/4,this.add(r,i)}}class so extends s.Mesh{geometry;material;constructor({width:e=3,height:n=4,depth:o=.1}={}){super(),this.geometry=new s.BoxGeometry(e,n,o),this.material=new s.MeshStandardMaterial({color:3026478,roughness:.8,metalness:.6})}}class ao extends s.Mesh{geometry;material;constructor({radius:e=.15,color:n=16762823,emissive:o=16711680,emissiveIntensity:a=.5}={}){super(),this.geometry=new s.SphereGeometry(e,8,8),this.material=new s.MeshStandardMaterial({color:n,emissive:o,emissiveIntensity:a})}}class io extends s.Group{constructor(){super();const e=100,n=.05,o=new s.CatmullRomCurve3(Array.from({length:e},(u,h)=>{const m=h*.2;return new s.Vector3(Math.cos(m)*.4,h*n,Math.sin(m)*.4)})),a=new s.TubeGeometry(o,200,.1,8,!1),r=new s.MeshStandardMaterial({color:8965375,transparent:!0,opacity:.3,roughness:.1,metalness:.2,emissive:8965375}),i=new s.Mesh(a,r);this.add(i);function l(){r.emissiveIntensity=.2+Math.sin(Date.now()*.005)*.1}function c(){requestAnimationFrame(c),l()}c()}}class co extends s.Mesh{constructor({radius:e=.3,height:n=.4,count:o=3,thickness:a=.03,radialSegments:r=16}={}){super(new vt({radius:e,height:n,count:o,thickness:a,radialSegments:r}),new s.MeshStandardMaterial({color:8947848,roughness:.7,metalness:.3}))}}class lo extends s.Mesh{constructor(){super(new bt,[new s.MeshStandardMaterial({color:3355443,roughness:.6,metalness:.5}),new s.MeshStandardMaterial({color:16737792,roughness:.5,metalness:.8,side:s.DoubleSide})])}}class uo extends s.Mesh{constructor(e=.2,n=.2,o=3,a=32){super(new L(e,n,o,a),new s.MeshPhysicalMaterial({color:8965375,transparent:!0,opacity:.4,roughness:.1,metalness:.1,reflectivity:.8,transmission:.9,depthWrite:!1,side:s.DoubleSide}))}}class ho extends s.Group{constructor(e=3,n=[65450,16711850,11141375]){super();const o=new s.BoxGeometry(3,.2,1),a=new s.MeshStandardMaterial({color:9127187,roughness:.7,metalness:.3}),r=new s.Mesh(o,a);r.position.y=.5,r.castShadow=!0;const i=new L(.1,.1,1,16),l=new s.MeshStandardMaterial({color:11184810,transparent:!0,opacity:.4,roughness:.1,metalness:.5,depthWrite:!1,side:s.DoubleSide});for(let c=0;c<e;c++){const u=new s.Mesh(i,l),h=(c-(e-1)/2)*.8;u.position.set(h,1,0),u.castShadow=!0;const m=new L(.099,.099,.5,16,!1),d=n[c%n.length],f=new s.MeshStandardMaterial({color:d,emissive:d,emissiveIntensity:.5,transparent:!0,opacity:.6}),p=new s.Mesh(m,f);p.position.set(0,-.25,0),u.add(p),r.add(u)}this.add(r)}}class mo extends s.Mesh{constructor({sides:e=5,innerRadius:n=.5,outerRadius:o=1,depth:a=.25}={}){super(new ct(e,n,o,a),new s.MeshStandardMaterial({color:16776960,emissive:16766720,emissiveIntensity:.25,metalness:.1,roughness:.3,flatShading:!0}))}}class fo extends s.Mesh{constructor({sides:e=5,innerRadius:n=.5,outerRadius:o=1,holeSides:a=5,holeRadius:r=.25,depth:i=.25}={}){super(new ut(e,n,o,a,r,i),new s.MeshStandardMaterial({color:11184810,metalness:.8,roughness:.2}))}}class po extends s.Mesh{constructor({size:e=1,width:n=2.1,height:o=1.4,tipDepth:a=1.6,depth:r=.25}={}){super(new mt(e,n,o,a,r),new s.MeshStandardMaterial({color:12986408,emissive:12981270,emissiveIntensity:.25,metalness:.1,roughness:.3,flatShading:!0}))}}class Mo extends s.Mesh{constructor({radius:e=1,depth:n=.01}={}){super(new q(e,n),new s.MeshStandardMaterial({color:16777215,emissive:16777215,emissiveIntensity:.1,metalness:.1,roughness:.3,flatShading:!0}))}}class yo extends s.Mesh{constructor({points:e=5,innerRadius:n=.5,outerRadius:o=1,depth:a=.25}={}){super(new ft(e,n,o,a),new s.MeshStandardMaterial({color:16776960,emissive:16766720,emissiveIntensity:.25,metalness:.1,roughness:.3,flatShading:!0}))}}class go extends s.Mesh{constructor(){super(new pt,new s.MeshStandardMaterial({color:16777215}))}}class xo extends s.Mesh{constructor({trunkRadiusTop:e=.25,trunkRadiusBottom:n=.4,trunkHeight:o=2.5,trunkSegments:a=14,trunkColor:r=9127187,leafSize:i=.8,leafCount:l=6,leafDetail:c=0,leafSpreadRadius:u=1.5,leafColor:h=2263842}={}){super(new Pt({trunkRadiusTop:e,trunkRadiusBottom:n,trunkHeight:o,trunkSegments:a,leafSize:i,leafCount:l,leafDetail:c,leafSpreadRadius:u}),[new s.MeshStandardMaterial({color:r,roughness:.9,metalness:0,flatShading:!0}),new s.MeshStandardMaterial({color:h,roughness:.8,metalness:0,flatShading:!0})])}}class wo extends s.Mesh{constructor({radius:e=3,height:n=.6,widthSegments:o=64,heightSegments:a=16,phiStart:r=0,phiLength:i=Math.PI*2}={}){super(new St({radius:e,height:n,widthSegments:o,heightSegments:a,phiStart:r,phiLength:i}),new s.MeshStandardMaterial({color:65280,flatShading:!0}))}}class vo extends s.Mesh{constructor({radius:e=J(5,Math.PI/10),widthSegments:n=64,heightSegments:o=32,phiStart:a=0,phiLength:r=Math.PI*2,thetaLength:i=Math.PI/10}={}){super(new Gt({radius:e,widthSegments:n,heightSegments:o,phiStart:a,phiLength:r,thetaLength:i}),new s.MeshStandardMaterial({color:65280,flatShading:!0}))}}function bo(t){if(!t)throw new Error("A material must be provided to add instance color support.");return t.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;`)},t}function So(t,{time:e=0,waveFrequency:n=.2,waveAmplitude:o=.5}={}){t.onBeforeCompile=a=>{a.uniforms.time={value:e},a.uniforms.waveFrequency={value:n},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
|
+
`),t.userData.shader=a}}function Go(t,e){t.userData.shader&&(t.userData.shader.uniforms.time.value+=e)}function Po(t,{time:e=0,intensity:n=1,axis:o=H.XYZ,scale:a=10}={}){t.onBeforeCompile=r=>{r.uniforms.time={value:e},r.uniforms.axis={value:o},r.uniforms.intensity={value:n},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
|
+
`),t.userData.shader=r}}function To(t,e){t.userData.shader&&(t.userData.shader.uniforms.time.value+=e)}const k={uniforms:{turbidity:{value:10},rayleigh:{value:2},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new s.Vector3().setFromSphericalCoords(1,s.MathUtils.degToRad(90),s.MathUtils.degToRad(180))},up:{value:new s.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
|
+
`},z={uniforms:{topColor:{value:new s.Color(.5,.8,1)},bottomColor:{value:new s.Color(1,1,1)}},vertexShader:`
|
|
247
|
+
varying vec3 vPosition;
|
|
248
|
+
void main() {
|
|
249
|
+
vPosition = position;
|
|
250
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
251
|
+
}
|
|
252
|
+
`,fragmentShader:`
|
|
253
|
+
uniform vec3 topColor;
|
|
254
|
+
uniform vec3 bottomColor;
|
|
255
|
+
varying vec3 vPosition;
|
|
256
|
+
void main() {
|
|
257
|
+
float y = normalize(vPosition).y * 0.5 + 0.5; // Normalizing y to range 0 to 1
|
|
258
|
+
gl_FragColor = vec4(mix(bottomColor, topColor, y), 1.0);
|
|
259
|
+
}
|
|
260
|
+
`},Ao={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
261
|
+
varying vec2 vUv;
|
|
262
|
+
void main() {
|
|
263
|
+
vUv = uv;
|
|
264
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
265
|
+
}
|
|
266
|
+
`,fragmentShader:`
|
|
267
|
+
uniform float opacity;
|
|
268
|
+
uniform sampler2D tDiffuse;
|
|
269
|
+
varying vec2 vUv;
|
|
270
|
+
void main() {
|
|
271
|
+
vec4 texel = texture2D(tDiffuse, vUv);
|
|
272
|
+
gl_FragColor = opacity * texel;
|
|
273
|
+
}
|
|
274
|
+
`},N={uniforms:{topColor:{value:new s.Color(51)},bottomColor:{value:new s.Color(17)},offset:{value:33},exponent:{value:.6}},vertexShader:`
|
|
275
|
+
varying vec3 vWorldPosition;
|
|
276
|
+
void main() {
|
|
277
|
+
vec4 worldPosition = modelMatrix * vec4(position, 1.0);
|
|
278
|
+
vWorldPosition = worldPosition.xyz;
|
|
279
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
280
|
+
}
|
|
281
|
+
`,fragmentShader:`
|
|
282
|
+
uniform vec3 topColor;
|
|
283
|
+
uniform vec3 bottomColor;
|
|
284
|
+
uniform float offset;
|
|
285
|
+
uniform float exponent;
|
|
286
|
+
varying vec3 vWorldPosition;
|
|
287
|
+
void main() {
|
|
288
|
+
float h = normalize(vWorldPosition + offset).y;
|
|
289
|
+
gl_FragColor = vec4(mix(bottomColor, topColor, max(pow(max(h, 0.0), exponent), 0.0)), 1.0);
|
|
290
|
+
}
|
|
291
|
+
`};class Bo extends s.Mesh{geometry;material;constructor(){super(),this.geometry=new s.BoxGeometry(1,1,1),this.material=new s.ShaderMaterial({uniforms:k.uniforms,vertexShader:k.vertexShader,fragmentShader:k.fragmentShader,depthWrite:!1,side:s.BackSide}),this.scale.setScalar(45e4);const e=s.MathUtils.degToRad(89),n=s.MathUtils.degToRad(180),o=new s.Vector3().setFromSphericalCoords(1,e,n);this.material.uniforms.sunPosition.value=o}sunPosition(e,n){const o=new s.Vector3;o.setFromSphericalCoords(1,e,n),this.material.uniforms.sunPosition.value=o}}class Co extends s.Mesh{geometry;material;constructor(e=1e3){super(),this.geometry=new s.BoxGeometry(e,e,e),this.material=new s.ShaderMaterial({uniforms:z.uniforms,vertexShader:z.vertexShader,fragmentShader:z.fragmentShader,side:s.BackSide})}}class Io extends s.Mesh{geometry;material;constructor(e=1e3){super(),this.geometry=new s.SphereGeometry(e,32,15),this.material=new s.ShaderMaterial({vertexShader:N.vertexShader,fragmentShader:N.fragmentShader,uniforms:N.uniforms,side:s.BackSide})}}const Eo=t=>{const e=new Uint8Array(4*t*t);for(let o=0;o<t*t;o++){const a=o*4,r=(o%t^Math.floor(o/t))&1?255:0;e[a]=r,e[a+1]=r,e[a+2]=r,e[a+3]=255}const n=new s.DataTexture(e,t,t,s.RGBAFormat,s.UnsignedByteType);return n.wrapS=s.RepeatWrapping,n.wrapT=s.RepeatWrapping,n.minFilter=s.NearestFilter,n.needsUpdate=!0,n};class Ro{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,n,o){this.perspectiveCamera=e,this.orthographicCamera=n,this.renderer=o,this.currentCamera=e,this.easingFunction=R.cubicInOut;const a=o.getSize(new G.Vector2);this.renderTargetA=new G.WebGLRenderTarget(a.x,a.y),this.renderTargetB=new G.WebGLRenderTarget(a.x,a.y),this.blendScene=new G.Scene,this.blendCamera=new G.OrthographicCamera(-1,1,1,-1,0,1),this.blendMaterial=new G.ShaderMaterial({uniforms:{tDiffuseA:{value:this.renderTargetA.texture},tDiffuseB:{value:this.renderTargetB.texture},mixRatio:{value:0}},vertexShader:`
|
|
292
|
+
varying vec2 vUv;
|
|
293
|
+
void main() {
|
|
294
|
+
vUv = uv;
|
|
295
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
296
|
+
}
|
|
297
|
+
`,fragmentShader:`
|
|
298
|
+
uniform sampler2D tDiffuseA;
|
|
299
|
+
uniform sampler2D tDiffuseB;
|
|
300
|
+
uniform float mixRatio;
|
|
301
|
+
varying vec2 vUv;
|
|
302
|
+
|
|
303
|
+
void main() {
|
|
304
|
+
vec4 texelA = texture2D(tDiffuseA, vUv);
|
|
305
|
+
vec4 texelB = texture2D(tDiffuseB, vUv);
|
|
306
|
+
// Use smoother blending that preserves brightness
|
|
307
|
+
float blend = mixRatio;
|
|
308
|
+
gl_FragColor = texelA * (1.0 - blend) + texelB * blend;
|
|
309
|
+
// Maintain proper alpha
|
|
310
|
+
gl_FragColor.a = max(texelA.a, texelB.a);
|
|
311
|
+
}
|
|
312
|
+
`});const r=new G.PlaneGeometry(2,2),i=new G.Mesh(r,this.blendMaterial);this.blendScene.add(i)}transitionTo(e,n={}){this.currentCamera!==e&&(this.targetCamera=e,this.transitionDuration=n.duration??1e3,this.transitionStartTime=performance.now(),this.transitionProgress=0,this.isTransitioning=!0,this.onUpdateCallback=n.onUpdate,this.onCompleteCallback=n.onComplete,n.easing&&(typeof n.easing=="string"?this.easingFunction=R[n.easing]:this.easingFunction=n.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,n){this.renderTargetA.setSize(e,n),this.renderTargetB.setSize(e,n)}dispose(){this.renderTargetA.dispose(),this.renderTargetB.dispose(),this.blendMaterial.dispose()}}class Vo{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 G.Color(0);onUpdateCallback;onCompleteCallback;constructor(e){this.renderer=e,this.easingFunction=R.cubicInOut;const n=e.getSize(new G.Vector2);this.renderTargetA=new G.WebGLRenderTarget(n.x,n.y),this.renderTargetB=new G.WebGLRenderTarget(n.x,n.y),this.blendScene=new G.Scene,this.blendCamera=new G.OrthographicCamera(-1,1,1,-1,0,1),this.fadeMaterial=new G.ShaderMaterial({uniforms:{tDiffuseA:{value:this.renderTargetA.texture},tDiffuseB:{value:this.renderTargetB.texture},mixRatio:{value:0},fadeColor:{value:new G.Color(0)}},vertexShader:`
|
|
313
|
+
varying vec2 vUv;
|
|
314
|
+
void main() {
|
|
315
|
+
vUv = uv;
|
|
316
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
317
|
+
}
|
|
318
|
+
`,fragmentShader:`
|
|
319
|
+
uniform sampler2D tDiffuseA;
|
|
320
|
+
uniform sampler2D tDiffuseB;
|
|
321
|
+
uniform float mixRatio;
|
|
322
|
+
uniform vec3 fadeColor;
|
|
323
|
+
varying vec2 vUv;
|
|
324
|
+
|
|
325
|
+
void main() {
|
|
326
|
+
vec4 texelA = texture2D(tDiffuseA, vUv);
|
|
327
|
+
vec4 texelB = texture2D(tDiffuseB, vUv);
|
|
328
|
+
|
|
329
|
+
// Fade out to color, then fade in from color
|
|
330
|
+
float fadeOut = smoothstep(0.0, 0.5, mixRatio) * 2.0;
|
|
331
|
+
float fadeIn = smoothstep(0.5, 1.0, mixRatio) * 2.0 - 1.0;
|
|
332
|
+
|
|
333
|
+
vec3 colorA = mix(texelA.rgb, fadeColor, clamp(fadeOut, 0.0, 1.0));
|
|
334
|
+
vec3 colorB = mix(fadeColor, texelB.rgb, clamp(fadeIn, 0.0, 1.0));
|
|
335
|
+
|
|
336
|
+
gl_FragColor = vec4(mix(colorA, colorB, step(0.5, mixRatio)), 1.0);
|
|
337
|
+
}
|
|
338
|
+
`}),this.crossfadeMaterial=new G.ShaderMaterial({uniforms:{tDiffuseA:{value:this.renderTargetA.texture},tDiffuseB:{value:this.renderTargetB.texture},mixRatio:{value:0}},vertexShader:`
|
|
339
|
+
varying vec2 vUv;
|
|
340
|
+
void main() {
|
|
341
|
+
vUv = uv;
|
|
342
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
343
|
+
}
|
|
344
|
+
`,fragmentShader:`
|
|
345
|
+
uniform sampler2D tDiffuseA;
|
|
346
|
+
uniform sampler2D tDiffuseB;
|
|
347
|
+
uniform float mixRatio;
|
|
348
|
+
varying vec2 vUv;
|
|
349
|
+
|
|
350
|
+
void main() {
|
|
351
|
+
vec4 texelA = texture2D(tDiffuseA, vUv);
|
|
352
|
+
vec4 texelB = texture2D(tDiffuseB, vUv);
|
|
353
|
+
gl_FragColor = mix(texelA, texelB, mixRatio);
|
|
354
|
+
}
|
|
355
|
+
`});const o=new G.PlaneGeometry(2,2),a=new G.Mesh(o,this.fadeMaterial);this.blendScene.add(a)}fade(e,n,o,a={}){this.startTransition(e,n,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,n,o,a={}){this.startTransition(e,n,o,"crossfade",a);const r=this.blendScene.children[0];r.material=this.crossfadeMaterial}blur(e,n,o,a={}){this.fade(e,n,o,{...a,color:8421504})}startTransition(e,n,o,a,r){this.currentScene=e,this.targetScene=n,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=R[r.easing]:this.easingFunction=r.easing)}update(){if(!this.isTransitioning)return;const n=performance.now()-this.transitionStartTime,o=Math.min(n/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,n){this.renderTargetA.setSize(e,n),this.renderTargetB.setSize(e,n)}dispose(){this.renderTargetA.dispose(),this.renderTargetB.dispose(),this.fadeMaterial.dispose(),this.crossfadeMaterial.dispose()}}class Fo{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 G.Color(0);onUpdateCallback;onCompleteCallback;constructor(e,n){this.renderer=e,this.composer=n,this.easingFunction=R.cubicInOut,this.renderPass=n.passes.find(o=>o.constructor.name==="RenderPass")}setBloomPass(e){this.bloomPass=e}setGlitchPass(e){this.glitchPass=e}setBlurPass(e){this.blurPass=e}setFadePass(e){this.fadePass=e}bloom(e,n,o,a={}){if(!this.bloomPass){console.warn("SceneTransitionFX: Bloom pass not set. Call setBloomPass() first.");return}this.maxBloomStrength=a.maxBloom??3,this.startTransition(e,n,o,"bloom",a),this.bloomPass.enabled=!0}blur(e,n,o,a={}){if(!this.blurPass){console.warn("SceneTransitionFX: Blur pass not set. Call setBlurPass() first.");return}this.maxBlurAmount=a.maxBlur??10,this.startTransition(e,n,o,"blur",a),this.blurPass.enabled=!0}fade(e,n,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,n,o,"fade",a),this.fadePass.enabled=!0}glitch(e,n,o,a={}){if(!this.glitchPass){console.warn("SceneTransitionFX: Glitch pass not set. Call setGlitchPass() first.");return}this.maxGlitchIntensity=a.maxIntensity??1,this.startTransition(e,n,o,"glitch",a),this.glitchPass.enabled=!0}startTransition(e,n,o,a,r){this.currentScene=e,this.targetScene=n,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=R[r.easing]:this.easingFunction=r.easing),this.renderPass&&(this.renderPass.scene=e,this.renderPass.camera=o)}update(){if(!this.isTransitioning)return;const n=performance.now()-this.transitionStartTime,o=Math.min(n/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,n){this.composer.setSize(e,n)}dispose(){}}function Oo(t,e){if(t.length===0)throw new Error("No objects provided for alignment.");const n=new s.Box3,o=new s.Vector3,a=t.map(i=>(n.setFromObject(i),i.getWorldPosition(o),{object:i,boundingBox:n.clone(),worldPosition:o.clone()})),r=a.reduce((i,{boundingBox:l})=>{switch(e){case A.LEFT:return Math.min(i,l.min.x);case A.RIGHT:return Math.max(i,l.max.x);case A.BOTTOM:return Math.min(i,l.min.y);case A.TOP:return Math.max(i,l.max.y);case A.BACK:return Math.min(i,l.min.z);case A.FRONT:return Math.max(i,l.max.z);default:throw new Error(`Unsupported side type: ${e}`)}},e===A.RIGHT||e===A.TOP||e===A.FRONT?-1/0:1/0);a.forEach(({object:i,boundingBox:l})=>{switch(e){case A.LEFT:i.position.x+=r-l.min.x;break;case A.RIGHT:i.position.x+=r-l.max.x;break;case A.BOTTOM:i.position.y+=r-l.min.y;break;case A.TOP:i.position.y+=r-l.max.y;break;case A.BACK:i.position.z+=r-l.min.z;break;case A.FRONT:i.position.z+=r-l.max.z;break}})}function Uo(t,e=F.RIGHT,n=0){const o=e.clone().normalize();let a=new s.Vector3;const r=new s.Box3;t.forEach(i=>{r.setFromObject(i);const c=new s.Vector3(r.max.x-r.min.x,r.max.y-r.min.y,r.max.z-r.min.z).dot(o),u=new s.Vector3;r.getCenter(u);const h=o.clone().multiplyScalar(c/2);i.position.copy(a.clone().add(h).sub(u).add(i.position)),a.add(o.clone().multiplyScalar(c+n))})}function Do(t,e,n=new s.Vector3(0,0,0)){const o=new s.Box3().setFromObject(t);if(o.isEmpty())console.warn("The object has no geometry or is not visible.");else{const a=o.min,r=new s.Vector3((a.x+o.max.x)/2,a.y,(a.z+o.max.z)/2);t.localToWorld(r);const i=e.clone().sub(r).add(n),l=t.worldToLocal(i.clone());t.position.add(l)}}function ko(t,e){const n=new s.Box3().setFromBufferAttribute(new s.Float32BufferAttribute(t.attributes.position.array,3));if(n.isEmpty())console.warn("The geometry is empty or invalid.");else{const o=n.min.y;t.translate(0,e-o,0)}}function zo(t,e,n=new s.Vector3(0,0,0)){const o=new s.Box3().setFromObject(t);if(o.isEmpty())console.warn("The InstancedMesh has no geometry or is not visible.");else{const a=o.min.y,r=new s.Vector3(0,e.y-a,0).add(n),i=t.worldToLocal(r.clone());t.position.add(i)}}function No(t,e,n,o=new s.Vector3(0,0,0)){const a=new s.Box3().setFromObject(t);if(a.isEmpty())console.warn("The instanced mesh has invalid geometry.");else{const r=a.min.y,i=new s.Matrix4;t.getMatrixAt(n,i);const l=new s.Vector3,c=new s.Quaternion,u=new s.Vector3;i.decompose(l,c,u);const h=t.worldToLocal(e.clone());l.y=h.y-r+o.y,i.compose(l,c,u),t.setMatrixAt(n,i),t.instanceMatrix.needsUpdate=!0}}function At(t,e=new s.Vector3(0,0,0),n=new s.Vector3(0,0,0)){const a=new s.Box3().setFromObject(t).getCenter(new s.Vector3),r=new s.Vector3().addVectors(e,n),i=new s.Vector3().subVectors(r,a);t.position.add(i)}function Bt(t,e=new s.Vector3(0,0,0),n=new s.Vector3(0,0,0)){const a=new s.Box3().setFromObject(t).getCenter(new s.Vector3),r=new s.Vector3().addVectors(e,n);t.translateX(r.x-a.x),t.translateY(r.y-a.y),t.translateZ(r.z-a.z),t.updateMatrixWorld(!0)}function Ct(t,e=new s.Vector3(0,0,0),n=new s.Vector3(0,0,0)){t.geometry.computeBoundingBox();const o=t.geometry.boundingBox;if(o){const a=o.getCenter(new s.Vector3),r=new s.Vector3().addVectors(e,n),i=new s.Vector3().subVectors(r,a);t.geometry.translate(i.x,i.y,i.z)}}const Lo={object:At,objectGeometry:Bt,meshGeometry:Ct};function _o(t){const e=parseInt(t.slice(1),16);return[e>>16&255,e>>8&255,e&255]}function Ho(t){const[e,n,o]=V(t);return Et(e,n,o)}function V(t){const e=t>>16&255,n=t>>8&255,o=t&255;return[e,n,o]}function qo(t,e,n){e/=100,n/=100;function o(c,u,h){return h<0&&(h+=1),h>1&&(h-=1),h<1/6?c+(u-c)*6*h:h<1/2?u:h<2/3?c+(u-c)*(2/3-h)*6:c}let a,r,i;if(e===0)a=r=i=n;else{const c=n<.5?n*(1+e):n+e-n*e,u=2*n-c;a=o(u,c,t/360+1/3),r=o(u,c,t/360),i=o(u,c,t/360-1/3)}const l=c=>Math.round(c*255);return[l(a),l(r),l(i)]}function It(t,e,n){e/=100,n/=100;const o=i=>(i+t/30)%12,a=e*Math.min(n,1-n),r=i=>n-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 Xo(t,e,n){return[t/255,e/255,n/255]}function Yo(t,e,n){return t=Math.round(t),e=Math.round(e),n=Math.round(n),(t<<16)+(e<<8)+n}function Et(t,e,n){t/=255,e/=255,n/=255;const o=Math.max(t,e,n),a=Math.min(t,e,n),r=o-a;let i=0,l=0;const c=(o+a)/2;r!==0&&(o===t?i=((e-n)/r+(e<n?6:0))*60:o===e?i=((n-t)/r+2)*60:o===n&&(i=((t-e)/r+4)*60)),r!==0&&(l=r/(1-Math.abs(2*c-1))),i=Math.round(i),l=Math.round(l*100);const u=Math.round(c*100);return[i,l,u]}function Rt(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}function Vt(t,e){return Math.abs(t[0]-e[0])+Math.abs(t[1]-e[1])+Math.abs(t[2]-e[2])}function jo(t,e){const n=V(t);let o=null,a=1/0;for(const r of e){const i=V(r),l=Rt(n,i);l<a&&(a=l,o=r)}return o}function Zo(t,e){const n=V(t);let o=null,a=1/0;for(const r of e){const i=V(r),l=Vt(n,i);l<a&&(a=l,o=r)}return o}function Ko(t){const e=(t+Math.floor(-30+Math.random()*61))%360,n=Math.floor(60+Math.random()*21),o=Math.floor(50+Math.random()*21);return It(e,n,o)}function Wo(t,e){if(!e.geometry.isBufferGeometry)throw new Error("Mesh must have a BufferGeometry.");const o=e.geometry.getAttribute("position"),a=new s.Vector3,r=new s.Vector3;let i=1/0;for(let l=0;l<o.count;l++){r.fromBufferAttribute(o,l);const c=r.distanceTo(t);c<i&&(i=c,a.copy(r))}return e.localToWorld(a),a}function Qo(t,e,n){return Math.max(0,Math.min(1,(t-e)/(n-e)))}function Jo(t,e,n,o,a,r=20,i=0,l=1){const c=[];for(let u=0;u<=r;u++){const h=u/r,m=t(Qo(h,i,l)),d=e+m*(n-e),f=o+h*(a-o);c.push(new s.Vector2(d,f))}return c}const Ft=(t,e,n,o,a=24)=>{let r=[];for(let i=0;i<=a;i++){const l=i/a,c=I.CUBIC(l,t.x,e.x,n.x,o.x),u=I.CUBIC(l,t.y,e.y,n.y,o.y);r.push(new s.Vector2(c,u))}return r},Ot=(t,e,n,o=24)=>{let a=[];for(let r=0;r<=o;r++){const i=r/o,l=I.DAMPED(i,n)*(e.x-t.x)+t.x,c=t.y+i*(e.y-t.y);a.push(new s.Vector2(l,c))}return a},Ut=(t,e,n,o,a=24)=>{let r=[];for(let i=0;i<=a;i++){const l=i/a,c=I.EXPONENTIAL(l,n,o)*(e.x-t.x)+t.x,u=t.y+l*(e.y-t.y);r.push(new s.Vector2(c,u))}return r},Dt=(t,e,n,o,a=24)=>{let r=[];for(let i=0;i<=a;i++){const l=i/a,c=I.LOGARITHMIC(l,n,o)*(e.x-t.x)+t.x,u=t.y+l*(e.y-t.y);r.push(new s.Vector2(c,u))}return r},kt=(t,e,n,o,a,r=24)=>{let i=[];for(let l=0;l<=r;l++){const c=l/r,u=n*c*c+o*c+a+t.x,h=t.y+c*(e.y-t.y);i.push(new s.Vector2(u,h))}return i},zt=(t,e,n,o=24)=>{let a=[];for(let r=0;r<=o;r++){const i=r/o,l=I.QUADRATIC(i,t.x,e.x,n.x),c=I.QUADRATIC(i,t.y,e.y,n.y);a.push(new s.Vector2(l,c))}return a},Nt=(t,e,n,o=24)=>{let a=[];for(let r=0;r<=o;r++){const i=r/o,l=I.SIGMOID(i,n)*(e.x-t.x)+t.x,c=t.y+i*(e.y-t.y);a.push(new s.Vector2(l,c))}return a},$o={createCubicCurvePoints:Ft,createDampedCurvePoints:Ot,createExponentialCurvePoints:Ut,createLogarithmicCurvePoints:Dt,createParabolicCurvePoints:kt,createQuadraticCurvePoints:zt,createSigmoidCurvePoints:Nt};function er(t,e,n,o,a,r=[0,0],i=[1,0],l=[0,1],c=[1,1]){const u=a||Lt(t,e,n);return[{pos:t,norm:u,uv:r},{pos:e,norm:u,uv:i},{pos:o,norm:u,uv:c},{pos:t,norm:u,uv:r},{pos:o,norm:u,uv:c},{pos:n,norm:u,uv:l}]}function Lt(t,e,n){const o=[e[0]-t[0],e[1]-t[1],e[2]-t[2]],a=[n[0]-t[0],n[1]-t[1],n[2]-t[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 tr(t,e){return t.map(([n,o,a])=>{switch(e){case"x":return[o,a];case"y":return[n,a];case"z":return[n,o];default:throw new Error(`Invalid axis: ${e}`)}})}function _t(t){const[e,n,o]=t,a=Math.abs(e),r=Math.abs(n),i=Math.abs(o);return a>=r&&a>=i?[o>0?o:-o,n]:r>=a&&r>=i?[e,o>0?o:-o]:[e,n]}function nr(t){return t.map(e=>_t(e))}function or(t){return t.map(([e,n,o])=>{const a=Math.atan2(o,e),r=Math.acos(n/Math.sqrt(e**2+n**2+o**2)),i=a/(2*Math.PI)+.5,l=1-r/Math.PI;return[i,l]})}function rr(t){return t.map(([e,n,o])=>[Math.atan2(o,e)/(2*Math.PI)+.5,n])}function sr(t){return t.map(([e,n,o])=>{const a=Math.sqrt(e**2+o**2);return[Math.atan2(o,e)/(2*Math.PI)+.5,a]})}function Ht(t,e,n,o,a){return[(t[0]-e)/(n-e),(t[1]-o)/(a-o)]}function ar(t,e,n){const[o,a]=e,[r,i]=n;return t.map(l=>Ht(l,o,r,a,i))}function ir(t){const e=Math.min(...t.map(r=>r[0])),n=Math.max(...t.map(r=>r[0])),o=Math.min(...t.map(r=>r[1])),a=Math.max(...t.map(r=>r[1]));return{minBounds:[e,o],maxBounds:[n,a]}}exports.AtmosphericSkybox=Bo;exports.Axis=H;exports.BifurcatedStaircaseGeometry=wn;exports.Bone=go;exports.BoneGeometry=pt;exports.Book=Rn;exports.BookGeometry=j;exports.Bookshelf=qn;exports.BookshelfGeometry=et;exports.BoxSide=A;exports.BubblingEffect=mn;exports.BunsenBurner=Jn;exports.Burst=mo;exports.BurstGeometry=ct;exports.BurstShape=it;exports.CameraTransition=Ro;exports.Candle=Yn;exports.CandleGeometry=nt;exports.Center=Lo;exports.ColorPalette=E;exports.CrossHeadstone=Un;exports.CrossHeadstoneGeometry=je;exports.DaySkybox=Co;exports.Desk=Xn;exports.DeskGeometry=tt;exports.Diorama=In;exports.DioramaGeometry=_e;exports.Direction=F;exports.Easing=R;exports.ElectricPanel=$n;exports.EllipticLeafGeometry=ze;exports.EmissivePulseAnimation=$t;exports.ErlenmeyerFlask=eo;exports.ErlenmeyerFlaskGeometry=Mt;exports.Falloff=O;exports.Flame=jn;exports.FlameGeometry=Q;exports.FlorenceFlask=to;exports.FlorenceFlaskGeometry=xt;exports.Gear=fo;exports.GearGeometry=ut;exports.GearShape=lt;exports.Heart=po;exports.HeartGeometry=mt;exports.HeartShape=ht;exports.Hexagon=Mo;exports.HexagonGeometry=q;exports.HexagonShape=Le;exports.Hill=wo;exports.HillGeometry=St;exports.Jar=Vn;exports.JarGeometry=He;exports.LShapedStaircaseGeometry=vn;exports.Lantern=Zn;exports.LeafEffect=dn;exports.LeverPanel=no;exports.LightFlickerAnimation=tn;exports.LightningAnimation=on;exports.LineEquations=Gn;exports.Mausoleum=Dn;exports.MausoleumGeometry=Ze;exports.Microscope=oo;exports.Moon=En;exports.MortarAndPestle=ro;exports.MortarGeometry=wt;exports.MossyRocks=Kn;exports.MossyRocksGeometry=ot;exports.Mound=vo;exports.MoundGeometry=Gt;exports.NightSkybox=Io;exports.ObeliskHeadstone=kn;exports.ObeliskHeadstoneGeometry=Ke;exports.Panel=so;exports.PanelLight=ao;exports.ParallelogramBoxGeometry=Pn;exports.ParametricCurve=I;exports.ParametricCurveUtils=$o;exports.PotionBottle=Fn;exports.PotionBottleGeometry=Xe;exports.Rock=Wn;exports.RockGeometry=st;exports.Rocks=Qn;exports.RocksGeometry=at;exports.RoundedHeadstone=zn;exports.RoundedHeadstoneGeometry=We;exports.SceneTransition=Vo;exports.SceneTransitionFX=Fo;exports.SpiralStaircaseGeometry=bn;exports.SpiralTube=io;exports.SquareHeadstone=Nn;exports.SquareHeadstoneGeometry=Qe;exports.StaircaseGeometry=Sn;exports.Stand=co;exports.StandGeometry=vt;exports.Star=yo;exports.StarGeometry=ft;exports.StarShape=dt;exports.StoneFencePost=Ln;exports.StoneFencePostGeometry=Je;exports.TeslaCoil=lo;exports.TeslaCoilGeometry=bt;exports.TestTube=uo;exports.TestTubeGeometry=L;exports.TestTubeRack=ho;exports.Tree=xo;exports.TreeGeometry=Pt;exports.WineBottle=On;exports.WineBottleGeometry=Ye;exports.WroughtIronBar=_n;exports.WroughtIronBarGeometry=W;exports.WroughtIronFence=Hn;exports.WroughtIronFenceGeometry=$e;exports.addInstanceColor=bo;exports.addNoiseDisplacement=Po;exports.addWaterDisplacement=So;exports.alignBufferGeometryToSurface=ko;exports.alignInstancedMeshIndexToSurface=No;exports.alignInstancedMeshToSurface=zo;exports.alignObjectToSurface=Do;exports.alignToEdge=Oo;exports.alignToRow=Uo;exports.appendSphericalCurve=gt;exports.atmosphericShader=k;exports.calculateChannelDifference=Vt;exports.calculateDistance=Rt;exports.calculateNormal=Lt;exports.calculateUVBounds=ir;exports.calculateXFromSlopeIntercept=K;exports.calculateYFromSlopeIntercept=qe;exports.cameraDollyAnimation=Yt;exports.cameraFlythroughAnimation=jt;exports.cameraOrbitAnimation=Zt;exports.cameraPendulumAnimation=Kt;exports.cameraSpiralAscensionAnimation=Wt;exports.cameraWobbleAnimation=Qt;exports.cameraZoomInAnimation=Jt;exports.capHeightFromRadius=yt;exports.capWidthFromRadius=An;exports.cartesianToSpherical=Cn;exports.centerMeshGeometry=Ct;exports.centerObject=At;exports.centerObjectGeometry=Bt;exports.checkerboardTexture=Eo;exports.circIn=ve;exports.circInOut=Se;exports.circOut=be;exports.concave=Te;exports.convex=Ae;exports.createCubicCurvePoints=Ft;exports.createDampedCurvePoints=Ot;exports.createExponentialCurvePoints=Ut;exports.createHexagonalTilesByCount=gn;exports.createHexagonalTilesByRadius=xn;exports.createLogarithmicCurvePoints=Dt;exports.createParabolicCurvePoints=kt;exports.createQuad=er;exports.createQuadraticCurvePoints=zt;exports.createSigmoidCurvePoints=Nt;exports.cubicCurve=Re;exports.cubicIn=le;exports.cubicInOut=he;exports.cubicOut=ue;exports.cubicUVMapping=_t;exports.cubicUVMappingBatch=nr;exports.cylindricalUVMapping=rr;exports.dampedCurve=Ve;exports.daySkyShader=z;exports.displacementBrush=rn;exports.expoIn=ge;exports.expoInOut=we;exports.expoOut=xe;exports.exponentialCurve=Fe;exports.fadeShader=Ao;exports.findClosestColor=jo;exports.findClosestColorChannelWise=Zo;exports.findClosestPoint=Wo;exports.flattenBrush=sn;exports.gaussian=Ee;exports.getAnalogousColors=Ko;exports.hexToHsl=Ho;exports.hexToRgb=V;exports.hslToHex=qo;exports.hslToRgb=It;exports.interpolateCurve=Jo;exports.inverse=Ie;exports.linear=Ge;exports.logarithmic=Be;exports.logarithmicCurve=Oe;exports.logarithmicRandomMax=ee;exports.logarithmicRandomMin=te;exports.moonShader=Tt;exports.nightSkyShader=N;exports.noiseBrush=an;exports.normalizeRgb=Xo;exports.normalizeUV=Ht;exports.normalizeUVBatch=ar;exports.parabolicCurve=Ue;exports.parseHexCode=_o;exports.planarUVMapping=tr;exports.polarUVMapping=sr;exports.quadIn=ae;exports.quadInOut=ce;exports.quadOut=ie;exports.quadraticCurve=De;exports.quartIn=me;exports.quartInOut=fe;exports.quartOut=de;exports.quintIn=pe;exports.quintInOut=ye;exports.quintOut=Me;exports.radiusFromCapHeight=Tn;exports.radiusFromCapWidth=J;exports.randomFloat=_;exports.randomInteger=en;exports.randomTransformVertices=rt;exports.rgbToHex=Yo;exports.rgbToHsl=Et;exports.rowOfBooksByCount=Mn;exports.rowOfBooksByLength=yn;exports.rowOfBooksByScales=Z;exports.setRandomInterval=nn;exports.setRandomTimeout=ne;exports.sigmoidCurve=ke;exports.sineIn=oe;exports.sineInOut=se;exports.sineOut=re;exports.smoothBrush=cn;exports.smoothstep=Pe;exports.sphericalToCartesian=Bn;exports.sphericalUVMapping=or;exports.spikeBrush=ln;exports.squareRoot=Ce;exports.thetaLengthForRadius=Y;exports.twistBrush=un;exports.updateNoiseDisplacementTime=To;exports.updateWaterDisplacementTime=Go;
|
|
356
|
+
//# sourceMappingURL=index.cjs.map
|