diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml index a788959..aaf5f7e 100644 --- a/.github/workflows/deploy-pages.yml +++ b/.github/workflows/deploy-pages.yml @@ -5,6 +5,7 @@ on: branches: - main - cursor/virtual-phone-gift-6027 + - cursor/spaceship-interior-demo-38d1 workflow_dispatch: permissions: @@ -26,10 +27,23 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + cache-dependency-path: spaceship/package-lock.json + + - name: Build spaceship game + run: | + npm ci --prefix spaceship + npm run build --prefix spaceship + - name: Prepare site run: | mkdir -p dist cp -R index.html browser-phone dist/ + cp -R spaceship/dist dist/spaceship cp CNAME dist/CNAME - name: Setup Pages diff --git a/play/assets/index-DaZoFckZ.js b/play/assets/index-DaZoFckZ.js new file mode 100644 index 0000000..011cc4a --- /dev/null +++ b/play/assets/index-DaZoFckZ.js @@ -0,0 +1,5177 @@ +(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=1e3,t=1001,n=1002,r=1003,i=1004,a=1005,o=1006,s=1007,c=1008,l=1009,u=1010,d=1011,f=1012,p=1013,m=1014,h=1015,g=1016,_=1017,v=1018,y=1020,b=35902,x=35899,S=1021,C=1022,w=1023,T=1026,E=1027,D=1028,O=1029,k=1030,A=1031,j=1033,M=33776,N=33777,ee=33778,P=33779,F=35840,te=35841,ne=35842,re=35843,ie=36196,I=37492,ae=37496,oe=37488,L=37489,se=37490,ce=37491,le=37808,ue=37809,de=37810,fe=37811,pe=37812,me=37813,he=37814,ge=37815,_e=37816,ve=37817,ye=37818,be=37819,xe=37820,Se=37821,Ce=36492,we=36494,Te=36495,Ee=36283,De=36284,R=36285,Oe=36286,ke=2300,Ae=2301,z=2302,je=2303,B=2400,V=2401,Me=2402,Ne=3200,Pe=`srgb`,Fe=`srgb-linear`,Ie=`linear`,Le=`srgb`,Re=7680,ze=35044,Be=2e3;function Ve(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function He(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ue(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function We(){let e=Ue(`canvas`);return e.style.display=`block`,e}var Ge={},Ke=null;function qe(...e){let t=`THREE.`+e.shift();Ke?Ke(`log`,t,...e):console.log(t,...e)}function Je(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function H(...e){e=Je(e);let t=`THREE.`+e.shift();if(Ke)Ke(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function U(...e){e=Je(e);let t=`THREE.`+e.shift();if(Ke)Ke(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function Ye(...e){let t=e.join(` `);t in Ge||(Ge[t]=!0,H(...e))}function Xe(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var Ze={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},Qe=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n>8&255]+$e[e>>16&255]+$e[e>>24&255]+`-`+$e[t&255]+$e[t>>8&255]+`-`+$e[t>>16&15|64]+$e[t>>24&255]+`-`+$e[n&63|128]+$e[n>>8&255]+`-`+$e[n>>16&255]+$e[n>>24&255]+$e[r&255]+$e[r>>8&255]+$e[r>>16&255]+$e[r>>24&255]).toLowerCase()}function W(e,t,n){return Math.max(t,Math.min(n,e))}function rt(e,t){return(e%t+t)%t}function it(e,t,n){return(1-n)*e+n*t}function at(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function ot(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var G=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=W(this.x,e.x,t.x),this.y=W(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=W(this.x,e,t),this.y=W(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(W(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(W(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},st=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:H(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(W(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},K=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(lt.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(lt.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=W(this.x,e.x,t.x),this.y=W(this.y,e.y,t.y),this.z=W(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=W(this.x,e,t),this.y=W(this.y,e,t),this.z=W(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(W(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ct.copy(this).projectOnVector(e),this.sub(ct)}reflect(e){return this.sub(ct.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(W(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},ct=new K,lt=new st,q=class e{static{e.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(ut.makeScale(e,t)),this}rotate(e){return this.premultiply(ut.makeRotation(-e)),this}translate(e,t){return this.premultiply(ut.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},ut=new q,dt=new q().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ft=new q().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function pt(){let e={enabled:!0,workingColorSpace:Fe,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=mt(e.r),e.g=mt(e.g),e.b=mt(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=ht(e.r),e.g=ht(e.g),e.b=ht(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Ie:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return Ye(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return Ye(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Fe]:{primaries:t,whitePoint:r,transfer:Ie,toXYZ:dt,fromXYZ:ft,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Pe},outputColorSpaceConfig:{drawingBufferColorSpace:Pe}},[Pe]:{primaries:t,whitePoint:r,transfer:Le,toXYZ:dt,fromXYZ:ft,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Pe}}}),e}var J=pt();function mt(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function ht(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var gt,_t=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{gt===void 0&&(gt=Ue(`canvas`)),gt.width=e.width,gt.height=e.height;let t=gt.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=gt}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=Ue(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(St).x}get height(){return this.source.getSize(St).y}get depth(){return this.source.getSize(St).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){H(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){H(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(r){if(this.mapping!==300)return r;if(r.applyMatrix3(this.matrix),r.x<0||r.x>1)switch(this.wrapS){case e:r.x-=Math.floor(r.x);break;case t:r.x=r.x<0?0:1;break;case n:Math.abs(Math.floor(r.x)%2)===1?r.x=Math.ceil(r.x)-r.x:r.x-=Math.floor(r.x);break}if(r.y<0||r.y>1)switch(this.wrapT){case e:r.y-=Math.floor(r.y);break;case t:r.y=r.y<0?0:1;break;case n:Math.abs(Math.floor(r.y)%2)===1?r.y=Math.ceil(r.y)-r.y:r.y-=Math.floor(r.y);break}return this.flipY&&(r.y=1-r.y),r}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Ct.DEFAULT_IMAGE=null,Ct.DEFAULT_MAPPING=300,Ct.DEFAULT_ANISOTROPY=1;var wt=class e{static{e.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)s&&e>_?e_?s1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(rn)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new nn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},on={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},sn={h:0,s:0,l:0},cn={h:0,s:0,l:0};function ln(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var X=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Pe){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,J.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=J.workingColorSpace){return this.r=e,this.g=t,this.b=n,J.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=J.workingColorSpace){if(e=rt(e,1),t=W(t,0,1),n=W(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=ln(i,r,e+1/3),this.g=ln(i,r,e),this.b=ln(i,r,e-1/3)}return J.colorSpaceToWorking(this,r),this}setStyle(e,t=Pe){function n(t){t!==void 0&&parseFloat(t)<1&&H(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:H(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);H(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Pe){let n=on[e.toLowerCase()];return n===void 0?H(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mt(e.r),this.g=mt(e.g),this.b=mt(e.b),this}copyLinearToSRGB(e){return this.r=ht(e.r),this.g=ht(e.g),this.b=ht(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Pe){return J.workingToColorSpace(un.copy(this),e),Math.round(W(un.r*255,0,255))*65536+Math.round(W(un.g*255,0,255))*256+Math.round(W(un.b*255,0,255))}getHexString(e=Pe){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=J.workingColorSpace){J.workingToColorSpace(un.copy(this),t);let n=un.r,r=un.g,i=un.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},pn=new K,mn=new K,hn=new K,gn=new K,_n=new K,vn=new K,yn=new K,bn=new K,xn=new K,Sn=new K,Cn=new wt,wn=new wt,Tn=new wt,En=class e{constructor(e=new K,t=new K,n=new K){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),pn.subVectors(e,t),r.cross(pn);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){pn.subVectors(r,t),mn.subVectors(n,t),hn.subVectors(e,t);let a=pn.dot(pn),o=pn.dot(mn),s=pn.dot(hn),c=mn.dot(mn),l=mn.dot(hn),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,gn)===null?!1:gn.x>=0&&gn.y>=0&&gn.x+gn.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,gn)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,gn.x),s.addScaledVector(a,gn.y),s.addScaledVector(o,gn.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Cn.setScalar(0),wn.setScalar(0),Tn.setScalar(0),Cn.fromBufferAttribute(e,t),wn.fromBufferAttribute(e,n),Tn.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Cn,i.x),a.addScaledVector(wn,i.y),a.addScaledVector(Tn,i.z),a}static isFrontFacing(e,t,n,r){return pn.subVectors(n,t),mn.subVectors(e,t),pn.cross(mn).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return pn.subVectors(this.c,this.b),mn.subVectors(this.a,this.b),pn.cross(mn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;_n.subVectors(r,n),vn.subVectors(i,n),bn.subVectors(e,n);let s=_n.dot(bn),c=vn.dot(bn);if(s<=0&&c<=0)return t.copy(n);xn.subVectors(e,r);let l=_n.dot(xn),u=vn.dot(xn);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(_n,a);Sn.subVectors(e,i);let f=_n.dot(Sn),p=vn.dot(Sn);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(vn,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return yn.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(yn,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(_n,a).addScaledVector(vn,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Dn=class{constructor(e=new K(1/0,1/0,1/0),t=new K(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,kn),kn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ln),Rn.subVectors(this.max,Ln),jn.subVectors(e.a,Ln),Mn.subVectors(e.b,Ln),Nn.subVectors(e.c,Ln),Pn.subVectors(Mn,jn),Fn.subVectors(Nn,Mn),In.subVectors(jn,Nn);let t=[0,-Pn.z,Pn.y,0,-Fn.z,Fn.y,0,-In.z,In.y,Pn.z,0,-Pn.x,Fn.z,0,-Fn.x,In.z,0,-In.x,-Pn.y,Pn.x,0,-Fn.y,Fn.x,0,-In.y,In.x,0];return!Vn(t,jn,Mn,Nn,Rn)||(t=[1,0,0,0,1,0,0,0,1],!Vn(t,jn,Mn,Nn,Rn))?!1:(zn.crossVectors(Pn,Fn),t=[zn.x,zn.y,zn.z],Vn(t,jn,Mn,Nn,Rn))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(kn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(On[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),On[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),On[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),On[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),On[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),On[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),On[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),On[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(On),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},On=[new K,new K,new K,new K,new K,new K,new K,new K],kn=new K,An=new Dn,jn=new K,Mn=new K,Nn=new K,Pn=new K,Fn=new K,In=new K,Ln=new K,Rn=new K,zn=new K,Bn=new K;function Vn(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){Bn.fromArray(e,a);let o=i.x*Math.abs(Bn.x)+i.y*Math.abs(Bn.y)+i.z*Math.abs(Bn.z),s=t.dot(Bn),c=n.dot(Bn),l=r.dot(Bn);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var Hn=new K,Un=new G,Wn=0,Gn=class extends Qe{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Wn++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=ze,this.updateRanges=[],this.gpuType=h,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Xn.subVectors(e,this.center);let t=Xn.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(Xn,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Zn.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Xn.copy(e.center).add(Zn)),this.expandByPoint(Xn.copy(e.center).sub(Zn))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},$n=0,er=new Y,tr=new tn,nr=new K,rr=new Dn,ir=new Dn,ar=new K,or=class e extends Qe{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$n++}),this.uuid=nt(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Ve(e)?qn:Kn)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new q().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return er.makeRotationFromQuaternion(e),this.applyMatrix4(er),this}rotateX(e){return er.makeRotationX(e),this.applyMatrix4(er),this}rotateY(e){return er.makeRotationY(e),this.applyMatrix4(er),this}rotateZ(e){return er.makeRotationZ(e),this.applyMatrix4(er),this}translate(e,t,n){return er.makeTranslation(e,t,n),this.applyMatrix4(er),this}scale(e,t,n){return er.makeScale(e,t,n),this.applyMatrix4(er),this}lookAt(e){return tr.lookAt(e),tr.updateMatrix(),this.applyMatrix4(tr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(nr).negate(),this.translate(nr.x,nr.y,nr.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;nt.count&&H(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Dn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){U(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new K(-1/0,-1/0,-1/0),new K(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){H(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){H(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},fr=class extends dr{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new X(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},pr,mr=new K,hr=new K,gr=new K,_r=new G,vr=new G,yr=new Y,br=new K,xr=new K,Sr=new K,Cr=new G,wr=new G,Tr=new G,Er=class extends tn{constructor(e=new fr){if(super(),this.isSprite=!0,this.type=`Sprite`,pr===void 0){pr=new or;let e=new sr(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);pr.setIndex([0,1,2,0,2,3]),pr.setAttribute(`position`,new lr(e,3,0,!1)),pr.setAttribute(`uv`,new lr(e,2,3,!1))}this.geometry=pr,this.material=e,this.center=new G(.5,.5),this.count=1}raycast(e,t){e.camera===null&&U(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),hr.setFromMatrixScale(this.matrixWorld),yr.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),gr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&hr.multiplyScalar(-gr.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;Dr(br.set(-.5,-.5,0),gr,a,hr,r,i),Dr(xr.set(.5,-.5,0),gr,a,hr,r,i),Dr(Sr.set(.5,.5,0),gr,a,hr,r,i),Cr.set(0,0),wr.set(1,0),Tr.set(1,1);let o=e.ray.intersectTriangle(br,xr,Sr,!1,mr);if(o===null&&(Dr(xr.set(-.5,.5,0),gr,a,hr,r,i),wr.set(0,1),o=e.ray.intersectTriangle(br,Sr,xr,!1,mr),o===null))return;let s=e.ray.origin.distanceTo(mr);se.far||t.push({distance:s,point:mr.clone(),uv:En.getInterpolation(mr,br,xr,Sr,Cr,wr,Tr,new G),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function Dr(e,t,n,r,i,a){_r.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?vr.copy(_r):(vr.x=a*_r.x-i*_r.y,vr.y=i*_r.x+a*_r.y),e.copy(t),e.x+=vr.x,e.y+=vr.y,e.applyMatrix4(yr)}var Or=new K,kr=new K,Ar=new K,jr=new K,Mr=new K,Nr=new K,Pr=new K,Fr=class{constructor(e=new K,t=new K(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Or)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Or.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Or.copy(this.origin).addScaledVector(this.direction,t),Or.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){kr.copy(e).add(t).multiplyScalar(.5),Ar.copy(t).sub(e).normalize(),jr.copy(this.origin).sub(kr);let i=e.distanceTo(t)*.5,a=-this.direction.dot(Ar),o=jr.dot(this.direction),s=-jr.dot(Ar),c=jr.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(kr).addScaledVector(Ar,d),f}intersectSphere(e,t){Or.subVectors(e.center,this.origin);let n=Or.dot(this.direction),r=Or.dot(Or)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Or)!==null}intersectTriangle(e,t,n,r,i){Mr.subVectors(t,e),Nr.subVectors(n,e),Pr.crossVectors(Mr,Nr);let a=this.direction.dot(Pr),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;jr.subVectors(this.origin,e);let s=o*this.direction.dot(Nr.crossVectors(jr,Nr));if(s<0)return null;let c=o*this.direction.dot(Mr.cross(jr));if(c<0||s+c>a)return null;let l=-o*jr.dot(Pr);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ir=class extends dr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new X(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Rt,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Lr=new Y,Rr=new Fr,zr=new Qn,Br=new K,Vr=new K,Hr=new K,Ur=new K,Wr=new K,Gr=new K,Kr=new K,qr=new K,Jr=class extends tn{constructor(e=new or,t=new Ir){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2))&&(Lr.copy(i).invert(),Rr.copy(e.ray).applyMatrix4(Lr),!(n.boundingBox!==null&&Rr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Rr)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;in.far?null:{distance:l,point:qr.clone(),object:e}}function Xr(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Vr),e.getVertexPosition(c,Hr),e.getVertexPosition(l,Ur);let u=Yr(e,t,n,r,Vr,Hr,Ur,Kr);if(u){let e=new K;En.getBarycoord(Kr,Vr,Hr,Ur,e),i&&(u.uv=En.getInterpolatedAttribute(i,s,c,l,e,new G)),a&&(u.uv1=En.getInterpolatedAttribute(a,s,c,l,e,new G)),o&&(u.normal=En.getInterpolatedAttribute(o,s,c,l,e,new K),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new K,materialIndex:0};En.getNormal(Vr,Hr,Ur,t.normal),u.face=t,u.barycoord=e}return u}var Zr=class extends Ct{constructor(e=null,t=1,n=1,i,a,o,s,c,l=r,u=r,d,f){super(null,o,s,c,l,u,i,a,d,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Qr=class extends Gn{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},$r=new Y,ei=new Y,ti=[],ni=new Dn,ri=new Y,ii=new Jr,ai=new Qn,oi=class extends Jr{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Qr(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||li.getNormalMatrix(e),r=this.coplanarPoint(si).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},di=new Qn,fi=new G(.5,.5),pi=new K,mi=class{constructor(e=new ui,t=new ui,n=new ui,r=new ui,i=new ui,a=new ui){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Be,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),di.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),di.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(di)}intersectsSprite(e){return di.center.set(0,0,0),di.radius=.7071067811865476+fi.distanceTo(e.center),di.applyMatrix4(e.matrixWorld),this.intersectsSphere(di)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,pi.y=r.normal.y>0?e.max.y:e.min.y,pi.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(pi)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},hi=class extends dr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new X(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},gi=new K,_i=new K,vi=new Y,yi=new Fr,bi=new Qn,xi=new K,Si=new K,Ci=class extends tn{constructor(e=new or,t=new hi){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er)return;xi.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(xi);if(!(ct.far))return{distance:c,point:Si.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Ti=new K,Ei=new K,Di=class extends Ci{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;ei.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var Fi=class extends Ct{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Ii=class extends Ct{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Li=class extends Ct{constructor(e,t,n=m,i,a,o,s=r,c=r,l,u=T,d=1){if(u!==1026&&u!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:d},i,a,o,s,c,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new yt(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Ri=class extends Li{constructor(e,t=m,n=301,i,a,o=r,s=r,c,l=T){let u={width:e,height:e,depth:1},d=[u,u,u,u,u,u];super(e,e,t,n,i,a,o,s,c,l),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},zi=class extends Ct{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Bi=class e extends or{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new Jn(c,3)),this.setAttribute(`normal`,new Jn(l,3)),this.setAttribute(`uv`,new Jn(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new K;for(let a=0;a0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new Jn(u,3)),this.setAttribute(`normal`,new Jn(d,3)),this.setAttribute(`uv`,new Jn(f,2));function _(){let a=new K,_=new K,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new G,m=new K,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new G:new K);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new K,r=[],i=[],a=[],o=new K,s=new Y;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new K)}i[0]=new K,a[0]=new K;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(W(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(W(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Ji=class extends qi{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new G){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Yi=class extends Ji{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function Xi(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var Zi=new K,Qi=new K,$i=new Xi,ea=new Xi,ta=new Xi,na=class extends qi{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new K){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(Qi.subVectors(r[0],r[1]).add(r[0]),c=Qi);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(ra(o,s.x,c.x,l.x,u.x),ra(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Ca=class extends Sa{constructor(e){super(e),this.uuid=nt(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;at&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return Da(a,o,n,s,c,l,0),o}function Ta(e,t,n,r,i){let a;if(i===no(e,t,n,r)>0)for(let i=t;i=t;i-=r)a=$a(i/r|0,e[i],e[i+1],a);return a&&Ga(a,a.next)&&(eo(a),a=a.next),a}function Ea(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(Ga(n,n.next)||Wa(n.prev,n,n.next)===0)){if(eo(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function Da(e,t,n,r,i,a,o){if(!e)return;!o&&a&&La(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?ka(e,r,i,a):Oa(e)){t.push(c.i,e.i,l.i),eo(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=Aa(Ea(e),t),Da(e,t,n,r,i,a,2)):o===2&&ja(e,t,n,r,i,a):Da(Ea(e),t,n,r,i,a,1);break}}}function Oa(e){let t=e.prev,n=e,r=e.next;if(Wa(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&Ha(i,s,a,c,o,l,m.x,m.y)&&Wa(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function ka(e,t,n,r){let i=e.prev,a=e,o=e.next;if(Wa(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=za(p,m,t,n,r),v=za(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Ha(s,u,c,d,l,f,y.x,y.y)&&Wa(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Ha(s,u,c,d,l,f,b.x,b.y)&&Wa(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Ha(s,u,c,d,l,f,y.x,y.y)&&Wa(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Ha(s,u,c,d,l,f,b.x,b.y)&&Wa(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Aa(e,t){let n=e;do{let r=n.prev,i=n.next.next;!Ga(r,i)&&Ka(r,n,n.next,i)&&Xa(r,i)&&Xa(i,r)&&(t.push(r.i,n.i,i.i),eo(n),eo(n.next),n=e=i),n=n.next}while(n!==e);return Ea(n)}function ja(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Ua(o,e)){let s=Qa(o,e);o=Ea(o,o.next),s=Ea(s,s.next),Da(o,t,n,r,i,a,0),Da(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function Ma(e,t,n,r){let i=[];for(let n=0,a=t.length;n=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x=n.x&&n.x>=c&&r!==n.x&&Va(io.x||n.x===o.x&&Ia(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function Ia(e,t){return Wa(e.prev,e,t.prev)<0&&Wa(t.next,e,e.next)<0}function La(e,t,n,r){let i=e;do i.z===0&&(i.z=za(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,Ra(i)}function Ra(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function za(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Ba(e){let t=e,n=e;do(t.x=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Ha(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&Va(e,t,n,r,i,a,o,s)}function Ua(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Ya(e,t)&&(Xa(e,t)&&Xa(t,e)&&Za(e,t)&&(Wa(e.prev,e,t.prev)||Wa(e,t.prev,t))||Ga(e,t)&&Wa(e.prev,e,e.next)>0&&Wa(t.prev,t,t.next)>0)}function Wa(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Ga(e,t){return e.x===t.x&&e.y===t.y}function Ka(e,t,n,r){let i=Ja(Wa(e,t,n)),a=Ja(Wa(e,t,r)),o=Ja(Wa(n,r,e)),s=Ja(Wa(n,r,t));return!!(i!==a&&o!==s||i===0&&qa(e,n,t)||a===0&&qa(e,r,t)||o===0&&qa(n,e,r)||s===0&&qa(n,t,r))}function qa(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Ja(e){return e>0?1:e<0?-1:0}function Ya(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Ka(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Xa(e,t){return Wa(e.prev,e,e.next)<0?Wa(e,t,e.next)>=0&&Wa(e,e.prev,t)>=0:Wa(e,t,e.prev)<0||Wa(e,e.next,t)<0}function Za(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Qa(e,t){let n=to(e.i,e.x,e.y),r=to(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function $a(e,t,n,r){let i=to(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function eo(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function to(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function no(e,t,n,r){let i=0;for(let a=t,o=n-r;a2&&e[t-1].equals(e[0])&&e.pop()}function oo(e,t){for(let n=0;n2**-52){let d=Math.sqrt(u),f=Math.sqrt(c*c+l*l),p=t.x-s/d,m=t.y+o/d,h=n.x-l/f,g=n.y+c/f,_=((h-p)*l-(g-m)*c)/(o*l-s*c);r=p+o*_-e.x,i=m+s*_-e.y;let v=r*r+i*i;if(v<=2)return new G(r,i);a=Math.sqrt(v/2)}else{let e=!1;o>2**-52?c>2**-52&&(e=!0):o<-(2**-52)?c<-(2**-52)&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new G(r/a,i/a)}let j=[];for(let e=0,t=D.length,n=t-1,r=e+1;e=0;e--){let t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=D.length;e=0;){let r=n,i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+p*2;e0)&&f.push(t,i,c),(e!==n-1||s0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},wo=class extends Co{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},To=class extends dr{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new X(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new G(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Rt,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:``},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Eo=class extends dr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type=`MeshLambertMaterial`,this.color=new X(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new G(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Rt,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Do=class extends dr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=Ne,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Oo=class extends dr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type=`MeshDistanceMaterial`,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function ko(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}var Ao=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e=i)){let o=t[1];e=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n>>1;et;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(U(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(U(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){U(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){U(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&He(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){U(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===z,i=e.length-1,a=1;for(let o=1;o0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Fo.prototype.ValueTypeName=``,Fo.prototype.TimeBufferType=Float32Array,Fo.prototype.ValueBufferType=Float32Array,Fo.prototype.DefaultInterpolation=Ae;var Io=class extends Fo{constructor(e,t,n){super(e,t,n)}};Io.prototype.ValueTypeName=`bool`,Io.prototype.ValueBufferType=Array,Io.prototype.DefaultInterpolation=ke,Io.prototype.InterpolantFactoryMethodLinear=void 0,Io.prototype.InterpolantFactoryMethodSmooth=void 0;var Lo=class extends Fo{constructor(e,t,n,r){super(e,t,n,r)}};Lo.prototype.ValueTypeName=`color`;var Ro=class extends Fo{constructor(e,t,n,r){super(e,t,n,r)}};Ro.prototype.ValueTypeName=`number`;var zo=class extends Ao{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)st.slerpFlat(i,0,a,c-o,a,c,s);return i}},Bo=class extends Fo{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new zo(this.times,this.values,this.getValueSize(),e)}};Bo.prototype.ValueTypeName=`quaternion`,Bo.prototype.InterpolantFactoryMethodSmooth=void 0;var Vo=class extends Fo{constructor(e,t,n){super(e,t,n)}};Vo.prototype.ValueTypeName=`string`,Vo.prototype.ValueBufferType=Array,Vo.prototype.DefaultInterpolation=ke,Vo.prototype.InterpolantFactoryMethodLinear=void 0,Vo.prototype.InterpolantFactoryMethodSmooth=void 0;var Ho=class extends Fo{constructor(e,t,n,r){super(e,t,n,r)}};Ho.prototype.ValueTypeName=`vector`;var Uo=new class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;te.start-t.start);let t=0;for(let e=1;e 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,color_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,color_pars_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,color_pars_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,color_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec4( 1.0 ); +#endif +#ifdef USE_COLOR_ALPHA + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,common:`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,cube_uv_reflection_fragment:`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,defaultnormal_vertex:`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,colorspace_fragment:`gl_FragColor = linearToOutputTexel( gl_FragColor );`,colorspace_pars_fragment:`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,envmap_fragment:`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,envmap_pars_fragment:`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,envmap_pars_vertex:`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,envmap_physical_pars_fragment:`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,envmap_vertex:`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,fog_vertex:`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,fog_pars_vertex:`#ifdef USE_FOG + varying float vFogDepth; +#endif`,fog_fragment:`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,fog_pars_fragment:`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,gradientmap_pars_fragment:`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,lights_lambert_fragment:`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,lights_lambert_pars_fragment:`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,lights_pars_begin:`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,lights_toon_fragment:`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment:`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,lights_phong_fragment:`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,lights_phong_pars_fragment:`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,lights_physical_fragment:`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,lights_physical_pars_fragment:`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,lights_fragment_begin:` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,lights_fragment_maps:`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,lights_fragment_end:`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,lightprobes_pars_fragment:`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,logdepthbuf_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,map_fragment:`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,map_pars_fragment:`#ifdef USE_MAP + uniform sampler2D map; +#endif`,map_particle_fragment:`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,map_particle_pars_fragment:`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,metalnessmap_fragment:`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,morphinstance_vertex:`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,morphcolor_vertex:`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,morphnormal_vertex:`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,morphtarget_pars_vertex:`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,morphtarget_vertex:`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,normal_fragment_begin:`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,normal_fragment_maps:`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,normal_pars_fragment:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_pars_vertex:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_vertex:`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,normalmap_pars_fragment:`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,clearcoat_normal_fragment_begin:`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,clearcoat_pars_fragment:`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,iridescence_pars_fragment:`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,opaque_fragment:`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,packing:`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,project_vertex:`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,dithering_fragment:`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,dithering_pars_fragment:`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,roughnessmap_fragment:`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,shadowmap_pars_fragment:`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,shadowmap_pars_vertex:`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,shadowmap_vertex:`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,shadowmask_pars_fragment:`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,skinbase_vertex:`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,skinning_pars_vertex:`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,skinning_vertex:`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,skinnormal_vertex:`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,specularmap_fragment:`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,tonemapping_fragment:`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,tonemapping_pars_fragment:`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,transmission_fragment:`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,transmission_pars_fragment:`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,uv_pars_fragment:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,uv_pars_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,uv_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,worldpos_vertex:`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`,background_vert:`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,background_frag:`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,backgroundCube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,cube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,cube_frag:`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,depth_vert:`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,depth_frag:`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,distance_vert:`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,distance_frag:`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,equirect_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,equirect_frag:`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,linedashed_vert:`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,linedashed_frag:`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,meshbasic_vert:`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,meshbasic_frag:`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,meshlambert_vert:`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,meshlambert_frag:`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,meshmatcap_vert:`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,meshmatcap_frag:`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,meshnormal_vert:`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,meshnormal_frag:`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,meshphong_vert:`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,meshphong_frag:`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,meshphysical_vert:`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,meshphysical_frag:`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,meshtoon_vert:`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,meshtoon_frag:`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,points_vert:`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,points_frag:`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,shadow_vert:`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,shadow_frag:`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,sprite_vert:`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,sprite_frag:`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`},Q={common:{diffuse:{value:new X(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new q},alphaMap:{value:null},alphaMapTransform:{value:new q},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new q}},envmap:{envMap:{value:null},envMapRotation:{value:new q},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new q}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new q}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new q},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new q},normalScale:{value:new G(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new q},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new q}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new q}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new q}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new X(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new K},probesMax:{value:new K},probesResolution:{value:new K}},points:{diffuse:{value:new X(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new q},alphaTest:{value:0},uvTransform:{value:new q}},sprite:{diffuse:{value:new X(16777215)},opacity:{value:1},center:{value:new G(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new q},alphaMap:{value:null},alphaMapTransform:{value:new q},alphaTest:{value:0}}},Rs={basic:{uniforms:go([Q.common,Q.specularmap,Q.envmap,Q.aomap,Q.lightmap,Q.fog]),vertexShader:Z.meshbasic_vert,fragmentShader:Z.meshbasic_frag},lambert:{uniforms:go([Q.common,Q.specularmap,Q.envmap,Q.aomap,Q.lightmap,Q.emissivemap,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.fog,Q.lights,{emissive:{value:new X(0)},envMapIntensity:{value:1}}]),vertexShader:Z.meshlambert_vert,fragmentShader:Z.meshlambert_frag},phong:{uniforms:go([Q.common,Q.specularmap,Q.envmap,Q.aomap,Q.lightmap,Q.emissivemap,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.fog,Q.lights,{emissive:{value:new X(0)},specular:{value:new X(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Z.meshphong_vert,fragmentShader:Z.meshphong_frag},standard:{uniforms:go([Q.common,Q.envmap,Q.aomap,Q.lightmap,Q.emissivemap,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.roughnessmap,Q.metalnessmap,Q.fog,Q.lights,{emissive:{value:new X(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Z.meshphysical_vert,fragmentShader:Z.meshphysical_frag},toon:{uniforms:go([Q.common,Q.aomap,Q.lightmap,Q.emissivemap,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.gradientmap,Q.fog,Q.lights,{emissive:{value:new X(0)}}]),vertexShader:Z.meshtoon_vert,fragmentShader:Z.meshtoon_frag},matcap:{uniforms:go([Q.common,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.fog,{matcap:{value:null}}]),vertexShader:Z.meshmatcap_vert,fragmentShader:Z.meshmatcap_frag},points:{uniforms:go([Q.points,Q.fog]),vertexShader:Z.points_vert,fragmentShader:Z.points_frag},dashed:{uniforms:go([Q.common,Q.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Z.linedashed_vert,fragmentShader:Z.linedashed_frag},depth:{uniforms:go([Q.common,Q.displacementmap]),vertexShader:Z.depth_vert,fragmentShader:Z.depth_frag},normal:{uniforms:go([Q.common,Q.bumpmap,Q.normalmap,Q.displacementmap,{opacity:{value:1}}]),vertexShader:Z.meshnormal_vert,fragmentShader:Z.meshnormal_frag},sprite:{uniforms:go([Q.sprite,Q.fog]),vertexShader:Z.sprite_vert,fragmentShader:Z.sprite_frag},background:{uniforms:{uvTransform:{value:new q},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Z.background_vert,fragmentShader:Z.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new q}},vertexShader:Z.backgroundCube_vert,fragmentShader:Z.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Z.cube_vert,fragmentShader:Z.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Z.equirect_vert,fragmentShader:Z.equirect_frag},distance:{uniforms:go([Q.common,Q.displacementmap,{referencePosition:{value:new K},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Z.distance_vert,fragmentShader:Z.distance_frag},shadow:{uniforms:go([Q.lights,Q.fog,{color:{value:new X(0)},opacity:{value:1}}]),vertexShader:Z.shadow_vert,fragmentShader:Z.shadow_frag}};Rs.physical={uniforms:go([Rs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new q},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new q},clearcoatNormalScale:{value:new G(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new q},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new q},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new q},sheen:{value:0},sheenColor:{value:new X(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new q},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new q},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new q},transmissionSamplerSize:{value:new G},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new q},attenuationDistance:{value:0},attenuationColor:{value:new X(0)},specularColor:{value:new X(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new q},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new q},anisotropyVector:{value:new G},anisotropyMap:{value:null},anisotropyMapTransform:{value:new q}}]),vertexShader:Z.meshphysical_vert,fragmentShader:Z.meshphysical_frag};var zs={r:0,b:0,g:0},Bs=new Y,Vs=new q;Vs.set(-1,0,0,0,1,0,0,0,1);function Hs(e,t,n,r,i,a){let o=new X(0),s=i===!0?0:1,c,l,u=null,d=0,f=null;function p(e){let n=e.isScene===!0?e.background:null;if(n&&n.isTexture){let r=e.backgroundBlurriness>0;n=t.get(n,r)}return n}function m(t){let r=!1,i=p(t);i===null?g(o,s):i&&i.isColor&&(g(i,1),r=!0);let c=e.xr.getEnvironmentBlendMode();c===`additive`?n.buffers.color.setClear(0,0,0,1,a):c===`alpha-blend`&&n.buffers.color.setClear(0,0,0,0,a),(e.autoClear||r)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))}function h(t,n){let i=p(n);i&&(i.isCubeTexture||i.mapping===306)?(l===void 0&&(l=new Jr(new Bi(1,1,1),new Co({name:`BackgroundCubeMaterial`,uniforms:ho(Rs.backgroundCube.uniforms),vertexShader:Rs.backgroundCube.vertexShader,fragmentShader:Rs.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute(`normal`),l.geometry.deleteAttribute(`uv`),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=i,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Bs.makeRotationFromEuler(n.backgroundRotation)).transpose(),i.isCubeTexture&&i.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Vs),l.material.toneMapped=J.getTransfer(i.colorSpace)!==Le,(u!==i||d!==i.version||f!==e.toneMapping)&&(l.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):i&&i.isTexture&&(c===void 0&&(c=new Jr(new uo(2,2),new Co({name:`BackgroundMaterial`,uniforms:ho(Rs.background.uniforms),vertexShader:Rs.background.vertexShader,fragmentShader:Rs.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute(`normal`),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=i,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.toneMapped=J.getTransfer(i.colorSpace)!==Le,i.matrixAutoUpdate===!0&&i.updateMatrix(),c.material.uniforms.uvTransform.value.copy(i.matrix),(u!==i||d!==i.version||f!==e.toneMapping)&&(c.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null))}function g(t,r){t.getRGB(zs,yo(e)),n.buffers.color.setClear(zs.r,zs.g,zs.b,r,a)}function _(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),s=t,g(o,s)},getClearAlpha:function(){return s},setClearAlpha:function(e){s=e,g(o,s)},render:m,addToRenderList:h,dispose:_}}function Us(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=f(null),a=i,o=!1;function s(n,r,i,s,c){let u=!1,f=d(n,s,i,r);a!==f&&(a=f,l(a.object)),u=p(n,s,i,c),u&&m(n,s,i,c),c!==null&&t.update(c,e.ELEMENT_ARRAY_BUFFER),(u||o)&&(o=!1,b(n,r,i,s),c!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(c).buffer))}function c(){return e.createVertexArray()}function l(t){return e.bindVertexArray(t)}function u(t){return e.deleteVertexArray(t)}function d(e,t,n,i){let a=i.wireframe===!0,o=r[t.id];o===void 0&&(o={},r[t.id]=o);let s=e.isInstancedMesh===!0?e.id:0,l=o[s];l===void 0&&(l={},o[s]=l);let u=l[n.id];u===void 0&&(u={},l[n.id]=u);let d=u[a];return d===void 0&&(d=f(c()),u[a]=d),d}function f(e){let t=[],r=[],i=[];for(let e=0;e=0){let n=i[t],r=o[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;s++}return a.attributesNum!==s||a.index!==r}function m(e,t,n,r){let i={},o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=o[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}a.attributes=i,a.attributesNum=s,a.index=r}function h(){let e=a.newAttributes;for(let t=0,n=e.length;t=0){let s=o[r];if(s===void 0&&(r===`instanceMatrix`&&n.instanceMatrix&&(s=n.instanceMatrix),r===`instanceColor`&&n.instanceColor&&(s=n.instanceColor)),s!==void 0){let r=s.normalized,o=s.itemSize,c=t.get(s);if(c===void 0)continue;let l=c.buffer,u=c.type,d=c.bytesPerElement,f=u===e.INT||u===e.UNSIGNED_INT||s.gpuType===1013;if(s.isInterleavedBufferAttribute){let t=s.data,c=t.stride,p=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let l=n.precision===void 0?`highp`:n.precision,u=c(l);u!==l&&(H(`WebGLRenderer:`,l,`not supported, using`,u,`instead.`),l=u);let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has(`EXT_clip_control`);n.reversedDepthBuffer===!0&&f===!1&&H(`WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`);let p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),_=e.getParameter(e.MAX_VERTEX_ATTRIBS),v=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),y=e.getParameter(e.MAX_VARYING_VECTORS),b=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),x=e.getParameter(e.MAX_SAMPLES),S=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:s,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:m,maxTextureSize:h,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:v,maxVaryings:y,maxFragmentUniforms:b,maxSamples:x,samples:S}}function Ks(e){let t=this,n=null,r=0,i=!1,a=!1,o=new ui,s=new q,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=dc(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=uc(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?l:0,l,l),c.setRenderTarget(r),p&&c.render(d,a),c.render(e,a)}c.toneMapping=u,c.autoClear=l,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=dc()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=uc());let i=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=i;let o=i.uniforms;o.envMap.value=e;let s=this._cubeSize;sc(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Zs)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;td-qs?n-d+qs:0),m=4*(this._cubeSize-f);s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,sc(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,Zs),s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,sc(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,Zs)}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&U(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=c.uniforms,d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*Ys-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):Ys;m>Ys&&H(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ys}`);let h=[],g=0;for(let e=0;e_-qs?r-_+qs:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,Zs)}};function ac(e){let t=[],n=[],r=[],i=e,a=e-qs+1+Js.length;for(let o=0;oe-qs?s=Js[o-e+qs-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];f.set(r,18*e),p.set(d,12*e);let i=[e,e,e,e,e,e];m.set(i,6*e)}let h=new or;h.setAttribute(`position`,new Gn(f,3)),h.setAttribute(`uv`,new Gn(p,2)),h.setAttribute(`faceIndex`,new Gn(m,1)),r.push(new Jr(h,null)),i>qs&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function oc(e,t,n){let r=new Et(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function sc(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function cc(e,t,n){return new Co({name:`PMREMGGXConvolution`,defines:{GGX_SAMPLES:Xs,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:fc(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:0,depthTest:!1,depthWrite:!1})}function lc(e,t,n){let r=new Float32Array(Ys),i=new K(0,1,0);return new Co({name:`SphericalGaussianBlur`,defines:{n:Ys,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:fc(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function uc(){return new Co({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:fc(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function dc(){return new Co({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:fc(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function fc(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}var pc=class extends Et{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Fi(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},r=new Bi(5,5,5),i=new Co({name:`CubemapFromEquirect`,uniforms:ho(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new Jr(r,i),s=t.minFilter;return t.minFilter===1008&&(t.minFilter=o),new ms(1,10,this).update(e,a),t.minFilter=s,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}};function mc(e){let t=new WeakMap,n=new WeakMap,r=null;function i(e,t=!1){return e==null?null:t?o(e):a(e)}function a(n){if(n&&n.isTexture){let r=n.mapping;if(r===303||r===304)if(t.has(n)){let e=t.get(n).texture;return s(e,n.mapping)}else{let r=n.image;if(r&&r.height>0){let i=new pc(r.height);return i.fromEquirectangularTexture(e,n),t.set(n,i),n.addEventListener(`dispose`,l),s(i.texture,n.mapping)}else return null}}return n}function o(t){if(t&&t.isTexture){let i=t.mapping,a=i===303||i===304,o=i===301||i===302;if(a||o){let i=n.get(t),s=i===void 0?0:i.texture.pmremVersion;if(t.isRenderTargetTexture&&t.pmremVersion!==s)return r===null&&(r=new ic(e)),i=a?r.fromEquirectangular(t,i):r.fromCubemap(t,i),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),i.texture;if(i!==void 0)return i.texture;{let s=t.image;return a&&s&&s.height>0||o&&s&&c(s)?(r===null&&(r=new ic(e)),i=a?r.fromEquirectangular(t):r.fromCubemap(t),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),t.addEventListener(`dispose`,u),i.texture):null}}}return t}function s(e,t){return t===303?e.mapping=301:t===304&&(e.mapping=302),e}function c(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function l(e){let n=e.target;n.removeEventListener(`dispose`,l);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function u(e){let t=e.target;t.removeEventListener(`dispose`,u);let r=n.get(t);r!==void 0&&(n.delete(t),r.dispose())}function d(){t=new WeakMap,n=new WeakMap,r!==null&&(r.dispose(),r=null)}return{get:i,dispose:d}}function hc(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r=e.getExtension(n);return t[n]=r,r}return{has:function(e){return n(e)!==null},init:function(){n(`EXT_color_buffer_float`),n(`WEBGL_clip_cull_distance`),n(`OES_texture_float_linear`),n(`EXT_color_buffer_half_float`),n(`WEBGL_multisampled_render_to_texture`),n(`WEBGL_render_shared_exponent`)},get:function(e){let t=n(e);return t===null&&Ye(`WebGLRenderer: `+e+` extension not supported.`),t}}}function gc(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener(`dispose`,o),delete i[s.id];let c=a.get(s);c&&(t.remove(c),a.delete(s)),r.releaseStatesOfGeometry(s),s.isInstancedBufferGeometry===!0&&delete s._maxInstanceCount,n.memory.geometries--}function s(e,t){return i[t.id]===!0?t:(t.addEventListener(`dispose`,o),i[t.id]=!0,n.memory.geometries++,t)}function c(n){let r=n.attributes;for(let n in r)t.update(r[n],e.ARRAY_BUFFER)}function l(e){let n=[],r=e.index,i=e.attributes.position,o=0;if(i===void 0)return;if(r!==null){let e=r.array;o=r.version;for(let t=0,r=e.length;t=65535?qn:Kn)(n,1);s.version=o;let c=a.get(e);c&&t.remove(c),a.set(e,s)}function u(e){let t=a.get(e);if(t){let n=e.index;n!==null&&t.versiont.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let g=new Float32Array(p*m*4*u),_=new Dt(g,p,m,u);_.type=h,_.needsUpdate=!0;let v=f*4;for(let t=0;t + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),l=new Jr(s,c),u=new cs(-1,1,1,-1,0,1),d=null,f=null,p=!1,m,h=null,_=[],v=!1;this.setSize=function(e,t){a.setSize(e,t),o.setSize(e,t);for(let n=0;n<_.length;n++){let r=_[n];r.setSize&&r.setSize(e,t)}},this.setEffects=function(e){_=e,v=_.length>0&&_[0].isRenderPass===!0;let t=a.width,n=a.height;for(let e=0;e<_.length;e++){let r=_[e];r.setSize&&r.setSize(t,n)}},this.begin=function(e,t){if(p||e.toneMapping===0&&_.length===0)return!1;if(h=t,t!==null){let e=t.width,n=t.height;(a.width!==e||a.height!==n)&&this.setSize(e,n)}return v===!1&&e.setRenderTarget(a),m=e.toneMapping,e.toneMapping=0,!0},this.hasRenderPass=function(){return v},this.end=function(e,t){e.toneMapping=m,p=!0;let n=a,r=o;for(let i=0;i<_.length;i++){let a=_[i];if(a.enabled!==!1&&(a.render(e,r,n,t),a.needsSwap!==!1)){let e=n;n=r,r=e}}if(d!==e.outputColorSpace||f!==e.toneMapping){d=e.outputColorSpace,f=e.toneMapping,c.defines={},J.getTransfer(d)===`srgb`&&(c.defines.SRGB_TRANSFER=``);let t=xc[f];t&&(c.defines[t]=``),c.needsUpdate=!0}c.uniforms.tDiffuse.value=n.texture,e.setRenderTarget(h),e.render(l,u),h=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),s.dispose(),c.dispose()}}var Cc=new Ct,wc=new Li(1,1),Tc=new Dt,Ec=new Ot,Dc=new Fi,Oc=[],kc=[],Ac=new Float32Array(16),jc=new Float32Array(9),Mc=new Float32Array(4);function Nc(e,t,n){let r=e[0];if(r<=0||r>0)return e;let i=t*n,a=Oc[i];if(a===void 0&&(a=new Float32Array(i),Oc[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function Pc(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n0&&(this.seq=r.concat(i))}setValue(e,t,n,r){let i=this.map[t];i!==void 0&&i.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let a=t[i],o=n[a.id];o.needsUpdate!==!1&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let i=e[r];i.id in t&&n.push(i)}return n}};function Al(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var jl=37297,Ml=0;function Nl(e,t){let n=e.split(` +`),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e`:` `} ${i}: ${n[e]}`)}return r.join(` +`)}var Pl=new q;function Fl(e){J._getMatrix(Pl,J.workingColorSpace,e);let t=`mat3( ${Pl.elements.map(e=>e.toFixed(4))} )`;switch(J.getTransfer(e)){case Ie:return[t,`LinearTransferOETF`];case Le:return[t,`sRGBTransferOETF`];default:return H(`WebGLProgram: Unsupported color space: `,e),[t,`LinearTransferOETF`]}}function Il(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` + +`+i+` + +`+Nl(e.getShaderSource(t),r)}else return i}function Ll(e,t){let n=Fl(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,`}`].join(` +`)}var Rl={1:`Linear`,2:`Reinhard`,3:`Cineon`,4:`ACESFilmic`,6:`AgX`,7:`Neutral`,5:`Custom`};function zl(e,t){let n=Rl[t];return n===void 0?(H(`WebGLProgram: Unsupported toneMapping:`,t),`vec3 `+e+`( vec3 color ) { return LinearToneMapping( color ); }`):`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}var Bl=new K;function Vl(){return J.getLuminanceCoefficients(Bl),[`float luminance( const in vec3 rgb ) {`,` const vec3 weights = vec3( ${Bl.x.toFixed(4)}, ${Bl.y.toFixed(4)}, ${Bl.z.toFixed(4)} );`,` return dot( weights, rgb );`,`}`].join(` +`)}function Hl(e){return[e.extensionClipCullDistance?`#extension GL_ANGLE_clip_cull_distance : require`:``,e.extensionMultiDraw?`#extension GL_ANGLE_multi_draw : require`:``].filter(Gl).join(` +`)}function Ul(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(` +`)}function Wl(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function Yl(e){return e.replace(Jl,Zl)}var Xl=new Map;function Zl(e,t){let n=Z[t];if(n===void 0){let e=Xl.get(t);if(e!==void 0)n=Z[e],H(`WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`Can not resolve #include <`+t+`>`)}return Yl(n)}var Ql=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function $l(e){return e.replace(Ql,eu)}function eu(e,t,n,r){let i=``;for(let e=parseInt(t);e0&&(g+=` +`),_=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(Gl).join(` +`),_.length>0&&(_+=` +`)):(g=[tu(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.extensionClipCullDistance?`#define USE_CLIP_DISTANCE`:``,n.batching?`#define USE_BATCHING`:``,n.batchingColor?`#define USE_BATCHING_COLOR`:``,n.instancing?`#define USE_INSTANCING`:``,n.instancingColor?`#define USE_INSTANCING_COLOR`:``,n.instancingMorph?`#define USE_INSTANCING_MORPH`:``,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.displacementMap?`#define USE_DISPLACEMENTMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.mapUv?`#define MAP_UV `+n.mapUv:``,n.alphaMapUv?`#define ALPHAMAP_UV `+n.alphaMapUv:``,n.lightMapUv?`#define LIGHTMAP_UV `+n.lightMapUv:``,n.aoMapUv?`#define AOMAP_UV `+n.aoMapUv:``,n.emissiveMapUv?`#define EMISSIVEMAP_UV `+n.emissiveMapUv:``,n.bumpMapUv?`#define BUMPMAP_UV `+n.bumpMapUv:``,n.normalMapUv?`#define NORMALMAP_UV `+n.normalMapUv:``,n.displacementMapUv?`#define DISPLACEMENTMAP_UV `+n.displacementMapUv:``,n.metalnessMapUv?`#define METALNESSMAP_UV `+n.metalnessMapUv:``,n.roughnessMapUv?`#define ROUGHNESSMAP_UV `+n.roughnessMapUv:``,n.anisotropyMapUv?`#define ANISOTROPYMAP_UV `+n.anisotropyMapUv:``,n.clearcoatMapUv?`#define CLEARCOATMAP_UV `+n.clearcoatMapUv:``,n.clearcoatNormalMapUv?`#define CLEARCOAT_NORMALMAP_UV `+n.clearcoatNormalMapUv:``,n.clearcoatRoughnessMapUv?`#define CLEARCOAT_ROUGHNESSMAP_UV `+n.clearcoatRoughnessMapUv:``,n.iridescenceMapUv?`#define IRIDESCENCEMAP_UV `+n.iridescenceMapUv:``,n.iridescenceThicknessMapUv?`#define IRIDESCENCE_THICKNESSMAP_UV `+n.iridescenceThicknessMapUv:``,n.sheenColorMapUv?`#define SHEEN_COLORMAP_UV `+n.sheenColorMapUv:``,n.sheenRoughnessMapUv?`#define SHEEN_ROUGHNESSMAP_UV `+n.sheenRoughnessMapUv:``,n.specularMapUv?`#define SPECULARMAP_UV `+n.specularMapUv:``,n.specularColorMapUv?`#define SPECULAR_COLORMAP_UV `+n.specularColorMapUv:``,n.specularIntensityMapUv?`#define SPECULAR_INTENSITYMAP_UV `+n.specularIntensityMapUv:``,n.transmissionMapUv?`#define TRANSMISSIONMAP_UV `+n.transmissionMapUv:``,n.thicknessMapUv?`#define THICKNESSMAP_UV `+n.thicknessMapUv:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexNormals?`#define HAS_NORMAL`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&n.flatShading===!1?`#define USE_MORPHNORMALS`:``,n.morphColors?`#define USE_MORPHCOLORS`:``,n.morphTargetsCount>0?`#define MORPHTARGETS_TEXTURE_STRIDE `+n.morphTextureStride:``,n.morphTargetsCount>0?`#define MORPHTARGETS_COUNT `+n.morphTargetsCount:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 modelMatrix;`,`uniform mat4 modelViewMatrix;`,`uniform mat4 projectionMatrix;`,`uniform mat4 viewMatrix;`,`uniform mat3 normalMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,`#ifdef USE_INSTANCING`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`#ifdef USE_INSTANCING_MORPH`,` uniform sampler2D morphTexture;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_UV1`,` attribute vec2 uv1;`,`#endif`,`#ifdef USE_UV2`,` attribute vec2 uv2;`,`#endif`,`#ifdef USE_UV3`,` attribute vec2 uv3;`,`#endif`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#if defined( USE_COLOR_ALPHA )`,` attribute vec4 color;`,`#elif defined( USE_COLOR )`,` attribute vec3 color;`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,` +`].filter(Gl).join(` +`),_=[tu(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.alphaToCoverage?`#define ALPHA_TO_COVERAGE`:``,n.map?`#define USE_MAP`:``,n.matcap?`#define USE_MATCAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.maxMip+`.0`:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.packedNormalMap?`#define USE_PACKED_NORMALMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoat?`#define USE_CLEARCOAT`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.dispersion?`#define USE_DISPERSION`:``,n.iridescence?`#define USE_IRIDESCENCE`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaTest?`#define USE_ALPHATEST`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.sheen?`#define USE_SHEEN`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor?`#define USE_COLOR`:``,n.vertexAlphas||n.batchingColor?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.numLightProbeGrids>0?`#define USE_LIGHT_PROBES_GRID`:``,n.decodeVideoTexture?`#define DECODE_VIDEO_TEXTURE`:``,n.decodeVideoTextureEmissive?`#define DECODE_VIDEO_TEXTURE_EMISSIVE`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:Z.tonemapping_pars_fragment,n.toneMapping===0?``:zl(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,Z.colorspace_pars_fragment,Ll(`linearToOutputTexel`,n.outputColorSpace),Vl(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` +`].filter(Gl).join(` +`)),o=Yl(o),o=Kl(o,n),o=ql(o,n),s=Yl(s),s=Kl(s,n),s=ql(s,n),o=$l(o),s=$l(s),n.isRawShaderMaterial!==!0&&(v=`#version 300 es +`,g=[p,`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(` +`)+` +`+g,_=[`#define varying in`,n.glslVersion===`300 es`?``:`layout(location = 0) out highp vec4 pc_fragColor;`,n.glslVersion===`300 es`?``:`#define gl_FragColor pc_fragColor`,`#define gl_FragDepthEXT gl_FragDepth`,`#define texture2D texture`,`#define textureCube texture`,`#define texture2DProj textureProj`,`#define texture2DLodEXT textureLod`,`#define texture2DProjLodEXT textureProjLod`,`#define textureCubeLodEXT textureLod`,`#define texture2DGradEXT textureGrad`,`#define texture2DProjGradEXT textureProjGrad`,`#define textureCubeGradEXT textureGrad`].join(` +`)+` +`+_);let y=v+g+o,b=v+_+s,x=Al(i,i.VERTEX_SHADER,y),S=Al(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.morphTargets===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h)||``,r=i.getShaderInfoLog(x)||``,a=i.getShaderInfoLog(S)||``,o=n.trim(),s=r.trim(),c=a.trim(),l=!0,u=!0;if(i.getProgramParameter(h,i.LINK_STATUS)===!1)if(l=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=Il(i,x,`vertex`),n=Il(i,S,`fragment`);U(`THREE.WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+` + +Material Name: `+t.name+` +Material Type: `+t.type+` + +Program Info Log: `+o+` +`+e+` +`+n)}else o===``?(s===``||c===``)&&(u=!1):H(`WebGLProgram: Program Info Log:`,o);u&&(t.diagnostics={runnable:l,programLog:o,vertexShader:{log:s,prefix:g},fragmentShader:{log:c,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new kl(i,h),T=Wl(i,h)}let w;this.getUniforms=function(){return w===void 0&&C(this),w};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(h,jl)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Ml++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var fu=0,pu=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(i)===!1&&(a.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new mu(e),t.set(e,n)),n}},mu=class{constructor(e){this.id=fu++,this.code=e,this.usedTimes=0}};function hu(e){return e===1030||e===37490||e===36285}function gu(e,t,n,r,i,a){let o=new zt,s=new pu,c=new Set,l=[],u=new Map,d=r.logarithmicDepthBuffer,f=r.precision,p={MeshDepthMaterial:`depth`,MeshDistanceMaterial:`distance`,MeshNormalMaterial:`normal`,MeshBasicMaterial:`basic`,MeshLambertMaterial:`lambert`,MeshPhongMaterial:`phong`,MeshToonMaterial:`toon`,MeshStandardMaterial:`physical`,MeshPhysicalMaterial:`physical`,MeshMatcapMaterial:`matcap`,LineBasicMaterial:`basic`,LineDashedMaterial:`dashed`,PointsMaterial:`points`,ShadowMaterial:`shadow`,SpriteMaterial:`sprite`};function m(e){return c.add(e),e===0?`uv`:`uv${e}`}function h(i,o,l,u,h,g){let _=u.fog,v=h.geometry,y=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?u.environment:null,b=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,x=t.get(i.envMap||y,b),S=x&&x.mapping===306?x.image.height:null,C=p[i.type];i.precision!==null&&(f=r.getMaxPrecision(i.precision),f!==i.precision&&H(`WebGLProgram.getParameters:`,i.precision,`not supported, using`,f,`instead.`));let w=v.morphAttributes.position||v.morphAttributes.normal||v.morphAttributes.color,T=w===void 0?0:w.length,E=0;v.morphAttributes.position!==void 0&&(E=1),v.morphAttributes.normal!==void 0&&(E=2),v.morphAttributes.color!==void 0&&(E=3);let D,O,k,A;if(C){let e=Rs[C];D=e.vertexShader,O=e.fragmentShader}else D=i.vertexShader,O=i.fragmentShader,s.update(i),k=s.getVertexShaderID(i),A=s.getFragmentShaderID(i);let j=e.getRenderTarget(),M=e.state.buffers.depth.getReversed(),N=h.isInstancedMesh===!0,ee=h.isBatchedMesh===!0,P=!!i.map,F=!!i.matcap,te=!!x,ne=!!i.aoMap,re=!!i.lightMap,ie=!!i.bumpMap,I=!!i.normalMap,ae=!!i.displacementMap,oe=!!i.emissiveMap,L=!!i.metalnessMap,se=!!i.roughnessMap,ce=i.anisotropy>0,le=i.clearcoat>0,ue=i.dispersion>0,de=i.iridescence>0,fe=i.sheen>0,pe=i.transmission>0,me=ce&&!!i.anisotropyMap,he=le&&!!i.clearcoatMap,ge=le&&!!i.clearcoatNormalMap,_e=le&&!!i.clearcoatRoughnessMap,ve=de&&!!i.iridescenceMap,ye=de&&!!i.iridescenceThicknessMap,be=fe&&!!i.sheenColorMap,xe=fe&&!!i.sheenRoughnessMap,Se=!!i.specularMap,Ce=!!i.specularColorMap,we=!!i.specularIntensityMap,Te=pe&&!!i.transmissionMap,Ee=pe&&!!i.thicknessMap,De=!!i.gradientMap,R=!!i.alphaMap,Oe=i.alphaTest>0,ke=!!i.alphaHash,Ae=!!i.extensions,z=0;i.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(z=e.toneMapping);let je={shaderID:C,shaderType:i.type,shaderName:i.name,vertexShader:D,fragmentShader:O,defines:i.defines,customVertexShaderID:k,customFragmentShaderID:A,isRawShaderMaterial:i.isRawShaderMaterial===!0,glslVersion:i.glslVersion,precision:f,batching:ee,batchingColor:ee&&h._colorsTexture!==null,instancing:N,instancingColor:N&&h.instanceColor!==null,instancingMorph:N&&h.morphTexture!==null,outputColorSpace:j===null?e.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:J.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:P,matcap:F,envMap:te,envMapMode:te&&x.mapping,envMapCubeUVHeight:S,aoMap:ne,lightMap:re,bumpMap:ie,normalMap:I,displacementMap:ae,emissiveMap:oe,normalMapObjectSpace:I&&i.normalMapType===1,normalMapTangentSpace:I&&i.normalMapType===0,packedNormalMap:I&&i.normalMapType===0&&hu(i.normalMap.format),metalnessMap:L,roughnessMap:se,anisotropy:ce,anisotropyMap:me,clearcoat:le,clearcoatMap:he,clearcoatNormalMap:ge,clearcoatRoughnessMap:_e,dispersion:ue,iridescence:de,iridescenceMap:ve,iridescenceThicknessMap:ye,sheen:fe,sheenColorMap:be,sheenRoughnessMap:xe,specularMap:Se,specularColorMap:Ce,specularIntensityMap:we,transmission:pe,transmissionMap:Te,thicknessMap:Ee,gradientMap:De,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:R,alphaTest:Oe,alphaHash:ke,combine:i.combine,mapUv:P&&m(i.map.channel),aoMapUv:ne&&m(i.aoMap.channel),lightMapUv:re&&m(i.lightMap.channel),bumpMapUv:ie&&m(i.bumpMap.channel),normalMapUv:I&&m(i.normalMap.channel),displacementMapUv:ae&&m(i.displacementMap.channel),emissiveMapUv:oe&&m(i.emissiveMap.channel),metalnessMapUv:L&&m(i.metalnessMap.channel),roughnessMapUv:se&&m(i.roughnessMap.channel),anisotropyMapUv:me&&m(i.anisotropyMap.channel),clearcoatMapUv:he&&m(i.clearcoatMap.channel),clearcoatNormalMapUv:ge&&m(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:_e&&m(i.clearcoatRoughnessMap.channel),iridescenceMapUv:ve&&m(i.iridescenceMap.channel),iridescenceThicknessMapUv:ye&&m(i.iridescenceThicknessMap.channel),sheenColorMapUv:be&&m(i.sheenColorMap.channel),sheenRoughnessMapUv:xe&&m(i.sheenRoughnessMap.channel),specularMapUv:Se&&m(i.specularMap.channel),specularColorMapUv:Ce&&m(i.specularColorMap.channel),specularIntensityMapUv:we&&m(i.specularIntensityMap.channel),transmissionMapUv:Te&&m(i.transmissionMap.channel),thicknessMapUv:Ee&&m(i.thicknessMap.channel),alphaMapUv:R&&m(i.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(I||ce),vertexNormals:!!v.attributes.normal,vertexColors:i.vertexColors,vertexAlphas:i.vertexColors===!0&&!!v.attributes.color&&v.attributes.color.itemSize===4,pointsUvs:h.isPoints===!0&&!!v.attributes.uv&&(P||R),fog:!!_,useFog:i.fog===!0,fogExp2:!!_&&_.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||v.attributes.normal===void 0&&I===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:M,skinning:h.isSkinnedMesh===!0,morphTargets:v.morphAttributes.position!==void 0,morphNormals:v.morphAttributes.normal!==void 0,morphColors:v.morphAttributes.color!==void 0,morphTargetsCount:T,morphTextureStride:E,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:z,decodeVideoTexture:P&&i.map.isVideoTexture===!0&&J.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:oe&&i.emissiveMap.isVideoTexture===!0&&J.getTransfer(i.emissiveMap.colorSpace)===`srgb`,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===2,flipSided:i.side===1,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:Ae&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(Ae&&i.extensions.multiDraw===!0||ee)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return je.vertexUv1s=c.has(1),je.vertexUv2s=c.has(2),je.vertexUv3s=c.has(3),c.clear(),je}function g(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(_(n,t),v(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function _(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function v(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),e.push(o.mask)}function y(e){let t=p[e.type],n;if(t){let e=Rs[t];n=bo.clone(e.uniforms)}else n=e.uniforms;return n}function b(t,n){let r=u.get(n);return r===void 0?(r=new du(e,n,t,i),l.push(r),u.set(n,r)):++r.usedTimes,r}function x(e){if(--e.usedTimes===0){let t=l.indexOf(e);l[t]=l[l.length-1],l.pop(),u.delete(e.cacheKey),e.destroy()}}function S(e){s.remove(e)}function C(){s.dispose()}return{getParameters:h,getProgramCacheKey:g,getUniforms:y,acquireProgram:b,releaseProgram:x,releaseShaderCache:S,programs:l,dispose:C}}function _u(){let e=new WeakMap;function t(t){return e.has(t)}function n(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}function r(t){e.delete(t)}function i(t,n,r){e.get(t)[n]=r}function a(){e=new WeakMap}return{has:t,get:n,remove:r,update:i,dispose:a}}function vu(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.material.id===t.material.id?e.materialVariant===t.materialVariant?e.z===t.z?e.id-t.id:e.z-t.z:e.materialVariant-t.materialVariant:e.material.id-t.material.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function yu(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function bu(){let e=[],t=0,n=[],r=[],i=[];function a(){t=0,n.length=0,r.length=0,i.length=0}function o(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function s(n,r,i,a,s,c){let l=e[t];return l===void 0?(l={id:n.id,object:n,geometry:r,material:i,materialVariant:o(n),groupOrder:a,renderOrder:n.renderOrder,z:s,group:c},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.materialVariant=o(n),l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=c),t++,l}function c(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.push(u):a.transparent===!0?i.push(u):n.push(u)}function l(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function u(e,t){n.length>1&&n.sort(e||vu),r.length>1&&r.sort(t||yu),i.length>1&&i.sort(t||yu)}function d(){for(let n=t,r=e.length;n=r.length?(i=new bu,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function Su(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={direction:new K,color:new X};break;case`SpotLight`:n={position:new K,direction:new K,color:new X,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new K,color:new X,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new K,skyColor:new X,groundColor:new X};break;case`RectAreaLight`:n={color:new X,position:new K,halfWidth:new K,halfHeight:new K};break}return e[t.id]=n,n}}}function Cu(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new G};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new G};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new G,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}var wu=0;function Tu(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function Eu(e){let t=new Su,n=Cu(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new K);let i=new K,a=new Y,o=new Y;function s(i){let a=0,o=0,s=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;i.sort(Tu);for(let e=0,y=i.length;e0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=Q.LTC_FLOAT_1,r.rectAreaLTC2=Q.LTC_FLOAT_2):(r.rectAreaLTC1=Q.LTC_HALF_1,r.rectAreaLTC2=Q.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let y=r.hash;(y.directionalLength!==c||y.pointLength!==l||y.spotLength!==u||y.rectAreaLength!==d||y.hemiLength!==f||y.numDirectionalShadows!==p||y.numPointShadows!==m||y.numSpotShadows!==h||y.numSpotMaps!==g||y.numLightProbes!==v)&&(r.directional.length=c,r.spot.length=u,r.rectArea.length=d,r.point.length=l,r.hemi.length=f,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=h,r.spotShadowMap.length=h,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=m,r.spotLightMatrix.length=h+g-_,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=_,r.numLightProbes=v,y.directionalLength=c,y.pointLength=l,y.spotLength=u,y.rectAreaLength=d,y.hemiLength=f,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=h,y.numSpotMaps=g,y.numLightProbes=v,r.version=wu++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=t.matrixWorldInverse;for(let t=0,f=e.length;t=i.length?(a=new Du(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var ku=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,Au=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); + gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); +}`,ju=[new K(1,0,0),new K(-1,0,0),new K(0,1,0),new K(0,-1,0),new K(0,0,1),new K(0,0,-1)],Mu=[new K(0,-1,0),new K(0,-1,0),new K(0,0,1),new K(0,0,-1),new K(0,-1,0),new K(0,-1,0)],Nu=new Y,Pu=new K,Fu=new K;function Iu(e,t,n){let i=new mi,a=new G,s=new G,c=new wt,l=new Do,u=new Oo,d={},f=n.maxTextureSize,p={0:1,1:0,2:2},_=new Co({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new G},radius:{value:4}},vertexShader:ku,fragmentShader:Au}),v=_.clone();v.defines.HORIZONTAL_PASS=1;let y=new or;y.setAttribute(`position`,new Gn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let b=new Jr(y,_),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let S=this.type;this.render=function(t,n,l){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||t.length===0)return;this.type===2&&(H(`WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead.`),this.type=1);let u=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),_=e.state;_.setBlending(0),_.buffers.depth.getReversed()===!0?_.buffers.color.setClear(0,0,0,0):_.buffers.color.setClear(1,1,1,1),_.buffers.depth.setTest(!0),_.setScissorTest(!1);let v=S!==this.type;v&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let u=0,d=t.length;uf||a.y>f)&&(a.x>f&&(s.x=Math.floor(f/y.x),a.x=s.x*y.x,p.mapSize.x=s.x),a.y>f&&(s.y=Math.floor(f/y.y),a.y=s.y*y.y,p.mapSize.y=s.y));let b=e.state.buffers.depth.getReversed();if(p.camera._reversedDepth=b,p.map===null||v===!0){if(p.map!==null&&(p.map.depthTexture!==null&&(p.map.depthTexture.dispose(),p.map.depthTexture=null),p.map.dispose()),this.type===3){if(d.isPointLight){H(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}p.map=new Et(a.x,a.y,{format:k,type:g,minFilter:o,magFilter:o,generateMipmaps:!1}),p.map.texture.name=d.name+`.shadowMap`,p.map.depthTexture=new Li(a.x,a.y,h),p.map.depthTexture.name=d.name+`.shadowMapDepth`,p.map.depthTexture.format=T,p.map.depthTexture.compareFunction=null,p.map.depthTexture.minFilter=r,p.map.depthTexture.magFilter=r}else d.isPointLight?(p.map=new pc(a.x),p.map.depthTexture=new Ri(a.x,m)):(p.map=new Et(a.x,a.y),p.map.depthTexture=new Li(a.x,a.y,m)),p.map.depthTexture.name=d.name+`.shadowMap`,p.map.depthTexture.format=T,this.type===1?(p.map.depthTexture.compareFunction=b?518:515,p.map.depthTexture.minFilter=o,p.map.depthTexture.magFilter=o):(p.map.depthTexture.compareFunction=null,p.map.depthTexture.minFilter=r,p.map.depthTexture.magFilter=r);p.camera.updateProjectionMatrix()}let x=p.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t0||n.map&&n.alphaTest>0||n.alphaToCoverage===!0){let e=a.uuid,t=n.uuid,r=d[e];r===void 0&&(r={},d[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,D)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?p[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaToCoverage===!0?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function E(n,r,a,o,s){if(n.visible===!1)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let i=t.update(n),c=n.material;if(Array.isArray(c)){let t=i.groups;for(let l=0,u=t.length;l=2):(ee=parseFloat(/^WebGL (\d)/.exec(P)[1]),N=ee>=1);let F=null,te={},ne=e.getParameter(e.SCISSOR_BOX),re=e.getParameter(e.VIEWPORT),ie=new wt().fromArray(ne),I=new wt().fromArray(re);function ae(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o`u`?!1:/OculusBrowser/g.test(navigator.userAgent),v=new G,y=new WeakMap,b=new Set,x,S=new WeakMap,C=!1;try{C=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function w(e,t){return C?new OffscreenCanvas(e,t):Ue(`canvas`)}function T(e,t,n){let r=1,i=je(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1)if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);x===void 0&&(x=w(n,a));let o=t?w(n,a):x;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),H(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}else return`data`in e&&H(`WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e;return e}function D(e){return e.generateMipmaps}function O(e){l.generateMipmap(e)}function k(e){return e.isWebGLCubeRenderTarget?l.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?l.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?l.TEXTURE_2D_ARRAY:l.TEXTURE_2D}function A(e,t,n,r,i,a=!1){if(e!==null){if(l[e]!==void 0)return l[e];H(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+e+`'`)}let o;r&&(o=u.get(`EXT_texture_norm16`),o||H(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let s=t;if(t===l.RED&&(n===l.FLOAT&&(s=l.R32F),n===l.HALF_FLOAT&&(s=l.R16F),n===l.UNSIGNED_BYTE&&(s=l.R8),n===l.UNSIGNED_SHORT&&o&&(s=o.R16_EXT),n===l.SHORT&&o&&(s=o.R16_SNORM_EXT)),t===l.RED_INTEGER&&(n===l.UNSIGNED_BYTE&&(s=l.R8UI),n===l.UNSIGNED_SHORT&&(s=l.R16UI),n===l.UNSIGNED_INT&&(s=l.R32UI),n===l.BYTE&&(s=l.R8I),n===l.SHORT&&(s=l.R16I),n===l.INT&&(s=l.R32I)),t===l.RG&&(n===l.FLOAT&&(s=l.RG32F),n===l.HALF_FLOAT&&(s=l.RG16F),n===l.UNSIGNED_BYTE&&(s=l.RG8),n===l.UNSIGNED_SHORT&&o&&(s=o.RG16_EXT),n===l.SHORT&&o&&(s=o.RG16_SNORM_EXT)),t===l.RG_INTEGER&&(n===l.UNSIGNED_BYTE&&(s=l.RG8UI),n===l.UNSIGNED_SHORT&&(s=l.RG16UI),n===l.UNSIGNED_INT&&(s=l.RG32UI),n===l.BYTE&&(s=l.RG8I),n===l.SHORT&&(s=l.RG16I),n===l.INT&&(s=l.RG32I)),t===l.RGB_INTEGER&&(n===l.UNSIGNED_BYTE&&(s=l.RGB8UI),n===l.UNSIGNED_SHORT&&(s=l.RGB16UI),n===l.UNSIGNED_INT&&(s=l.RGB32UI),n===l.BYTE&&(s=l.RGB8I),n===l.SHORT&&(s=l.RGB16I),n===l.INT&&(s=l.RGB32I)),t===l.RGBA_INTEGER&&(n===l.UNSIGNED_BYTE&&(s=l.RGBA8UI),n===l.UNSIGNED_SHORT&&(s=l.RGBA16UI),n===l.UNSIGNED_INT&&(s=l.RGBA32UI),n===l.BYTE&&(s=l.RGBA8I),n===l.SHORT&&(s=l.RGBA16I),n===l.INT&&(s=l.RGBA32I)),t===l.RGB&&(n===l.UNSIGNED_SHORT&&o&&(s=o.RGB16_EXT),n===l.SHORT&&o&&(s=o.RGB16_SNORM_EXT),n===l.UNSIGNED_INT_5_9_9_9_REV&&(s=l.RGB9_E5),n===l.UNSIGNED_INT_10F_11F_11F_REV&&(s=l.R11F_G11F_B10F)),t===l.RGBA){let e=a?Ie:J.getTransfer(i);n===l.FLOAT&&(s=l.RGBA32F),n===l.HALF_FLOAT&&(s=l.RGBA16F),n===l.UNSIGNED_BYTE&&(s=e===`srgb`?l.SRGB8_ALPHA8:l.RGBA8),n===l.UNSIGNED_SHORT&&o&&(s=o.RGBA16_EXT),n===l.SHORT&&o&&(s=o.RGBA16_SNORM_EXT),n===l.UNSIGNED_SHORT_4_4_4_4&&(s=l.RGBA4),n===l.UNSIGNED_SHORT_5_5_5_1&&(s=l.RGB5_A1)}return(s===l.R16F||s===l.R32F||s===l.RG16F||s===l.RG32F||s===l.RGBA16F||s===l.RGBA32F)&&u.get(`EXT_color_buffer_float`),s}function j(e,t){let n;return e?t===null||t===1014||t===1020?n=l.DEPTH24_STENCIL8:t===1015?n=l.DEPTH32F_STENCIL8:t===1012&&(n=l.DEPTH24_STENCIL8,H(`DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.`)):t===null||t===1014||t===1020?n=l.DEPTH_COMPONENT24:t===1015?n=l.DEPTH_COMPONENT32F:t===1012&&(n=l.DEPTH_COMPONENT16),n}function M(e,t){return D(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function N(e){let t=e.target;t.removeEventListener(`dispose`,N),P(t),t.isVideoTexture&&y.delete(t),t.isHTMLTexture&&b.delete(t)}function ee(e){let t=e.target;t.removeEventListener(`dispose`,ee),te(t)}function P(e){let t=f.get(e);if(t.__webglInit===void 0)return;let n=e.source,r=S.get(n);if(r){let i=r[t.__cacheKey];i.usedTimes--,i.usedTimes===0&&F(e),Object.keys(r).length===0&&S.delete(n)}f.remove(e)}function F(e){let t=f.get(e);l.deleteTexture(t.__webglTexture);let n=e.source,r=S.get(n);delete r[t.__cacheKey],h.memory.textures--}function te(e){let t=f.get(e);if(e.depthTexture&&(e.depthTexture.dispose(),f.remove(e.depthTexture)),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(t.__webglFramebuffer[e]))for(let n=0;n=p.maxTextures&&H(`WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+p.maxTextures),ne+=1,e}function oe(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function L(e,t){let n=f.get(e);if(e.isVideoTexture&&Ae(e),e.isRenderTargetTexture===!1&&e.isExternalTexture!==!0&&e.version>0&&n.__version!==e.version){let r=e.image;if(r===null)H(`WebGLRenderer: Texture marked for update but no image data found.`);else if(r.complete===!1)H(`WebGLRenderer: Texture marked for update but image is incomplete`);else{_e(n,e,t);return}}else e.isExternalTexture&&(n.__webglTexture=e.sourceTexture?e.sourceTexture:null);d.bindTexture(l.TEXTURE_2D,n.__webglTexture,l.TEXTURE0+t)}function se(e,t){let n=f.get(e);if(e.isRenderTargetTexture===!1&&e.version>0&&n.__version!==e.version){_e(n,e,t);return}else e.isExternalTexture&&(n.__webglTexture=e.sourceTexture?e.sourceTexture:null);d.bindTexture(l.TEXTURE_2D_ARRAY,n.__webglTexture,l.TEXTURE0+t)}function ce(e,t){let n=f.get(e);if(e.isRenderTargetTexture===!1&&e.version>0&&n.__version!==e.version){_e(n,e,t);return}d.bindTexture(l.TEXTURE_3D,n.__webglTexture,l.TEXTURE0+t)}function le(e,t){let n=f.get(e);if(e.isCubeDepthTexture!==!0&&e.version>0&&n.__version!==e.version){ve(n,e,t);return}d.bindTexture(l.TEXTURE_CUBE_MAP,n.__webglTexture,l.TEXTURE0+t)}let ue={[e]:l.REPEAT,[t]:l.CLAMP_TO_EDGE,[n]:l.MIRRORED_REPEAT},de={[r]:l.NEAREST,[i]:l.NEAREST_MIPMAP_NEAREST,[a]:l.NEAREST_MIPMAP_LINEAR,[o]:l.LINEAR,[s]:l.LINEAR_MIPMAP_NEAREST,[c]:l.LINEAR_MIPMAP_LINEAR},fe={512:l.NEVER,519:l.ALWAYS,513:l.LESS,515:l.LEQUAL,514:l.EQUAL,518:l.GEQUAL,516:l.GREATER,517:l.NOTEQUAL};function pe(e,t){if(t.type===1015&&u.has(`OES_texture_float_linear`)===!1&&(t.magFilter===1006||t.magFilter===1007||t.magFilter===1005||t.magFilter===1008||t.minFilter===1006||t.minFilter===1007||t.minFilter===1005||t.minFilter===1008)&&H(`WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),l.texParameteri(e,l.TEXTURE_WRAP_S,ue[t.wrapS]),l.texParameteri(e,l.TEXTURE_WRAP_T,ue[t.wrapT]),(e===l.TEXTURE_3D||e===l.TEXTURE_2D_ARRAY)&&l.texParameteri(e,l.TEXTURE_WRAP_R,ue[t.wrapR]),l.texParameteri(e,l.TEXTURE_MAG_FILTER,de[t.magFilter]),l.texParameteri(e,l.TEXTURE_MIN_FILTER,de[t.minFilter]),t.compareFunction&&(l.texParameteri(e,l.TEXTURE_COMPARE_MODE,l.COMPARE_REF_TO_TEXTURE),l.texParameteri(e,l.TEXTURE_COMPARE_FUNC,fe[t.compareFunction])),u.has(`EXT_texture_filter_anisotropic`)===!0){if(t.magFilter===1003||t.minFilter!==1005&&t.minFilter!==1008||t.type===1015&&u.has(`OES_texture_float_linear`)===!1)return;if(t.anisotropy>1||f.get(t).__currentAnisotropy){let n=u.get(`EXT_texture_filter_anisotropic`);l.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,p.getMaxAnisotropy())),f.get(t).__currentAnisotropy=t.anisotropy}}}function me(e,t){let n=!1;e.__webglInit===void 0&&(e.__webglInit=!0,t.addEventListener(`dispose`,N));let r=t.source,i=S.get(r);i===void 0&&(i={},S.set(r,i));let a=oe(t);if(a!==e.__cacheKey){i[a]===void 0&&(i[a]={texture:l.createTexture(),usedTimes:0},h.memory.textures++,n=!0),i[a].usedTimes++;let r=i[e.__cacheKey];r!==void 0&&(i[e.__cacheKey].usedTimes--,r.usedTimes===0&&F(t)),e.__cacheKey=a,e.__webglTexture=i[a].texture}return n}function he(e,t,n){return Math.floor(Math.floor(e/n)/t)}function ge(e,t,n,r){let i=e.updateRanges;if(i.length===0)d.texSubImage2D(l.TEXTURE_2D,0,0,0,t.width,t.height,n,r,t.data);else{i.sort((e,t)=>e.start-t.start);let a=0;for(let e=1;e0){g&&_&&d.texStorage2D(l.TEXTURE_2D,y,u,h[0].width,h[0].height);for(let e=0,t=h.length;e0){let e=Ps(f.width,f.height,t.format,t.type);for(let r of t.layerUpdates){let t=f.data.subarray(r*e/f.data.BYTES_PER_ELEMENT,(r+1)*e/f.data.BYTES_PER_ELEMENT);d.compressedTexSubImage3D(l.TEXTURE_2D_ARRAY,n,0,0,r,f.width,f.height,1,s,t)}t.clearLayerUpdates()}else d.compressedTexSubImage3D(l.TEXTURE_2D_ARRAY,n,0,0,0,f.width,f.height,e.depth,s,f.data)}else d.compressedTexImage3D(l.TEXTURE_2D_ARRAY,n,u,f.width,f.height,e.depth,0,f.data,0,0);else H(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`);else g?v&&d.texSubImage3D(l.TEXTURE_2D_ARRAY,n,0,0,0,f.width,f.height,e.depth,s,c,f.data):d.texImage3D(l.TEXTURE_2D_ARRAY,n,u,f.width,f.height,e.depth,0,s,c,f.data)}else{g&&_&&d.texStorage2D(l.TEXTURE_2D,y,u,h[0].width,h[0].height);for(let e=0,n=h.length;e0){let n=Ps(e.width,e.height,t.format,t.type);for(let r of t.layerUpdates){let t=e.data.subarray(r*n/e.data.BYTES_PER_ELEMENT,(r+1)*n/e.data.BYTES_PER_ELEMENT);d.texSubImage3D(l.TEXTURE_2D_ARRAY,0,0,0,r,e.width,e.height,1,s,c,t)}t.clearLayerUpdates()}else d.texSubImage3D(l.TEXTURE_2D_ARRAY,0,0,0,0,e.width,e.height,e.depth,s,c,e.data)}else d.texImage3D(l.TEXTURE_2D_ARRAY,0,u,e.width,e.height,e.depth,0,s,c,e.data);else if(t.isData3DTexture)g?(_&&d.texStorage3D(l.TEXTURE_3D,y,u,e.width,e.height,e.depth),v&&d.texSubImage3D(l.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,s,c,e.data)):d.texImage3D(l.TEXTURE_3D,0,u,e.width,e.height,e.depth,0,s,c,e.data);else if(t.isFramebufferTexture){if(_)if(g)d.texStorage2D(l.TEXTURE_2D,y,u,e.width,e.height);else{let t=e.width,n=e.height;for(let e=0;e>=1,n>>=1}}else if(t.isHTMLTexture){if(`texElementImage2D`in l){let n=l.canvas;if(n.hasAttribute(`layoutsubtree`)||n.setAttribute(`layoutsubtree`,`true`),e.parentNode!==n){n.appendChild(e),b.add(t),n.onpaint=e=>{let t=e.changedElements;for(let e of b)t.includes(e.image)&&(e.needsUpdate=!0)},n.requestPaint();return}let r=l.RGBA,i=l.RGBA,a=l.UNSIGNED_BYTE;l.texElementImage2D(l.TEXTURE_2D,0,r,i,a,e),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE)}}else if(h.length>0){if(g&&_){let e=je(h[0]);d.texStorage2D(l.TEXTURE_2D,y,u,e.width,e.height)}for(let e=0,t=h.length;e0&&S++;let e=je(f[0]);d.texStorage2D(l.TEXTURE_CUBE_MAP,S,v,e.width,e.height)}for(let e=0;e<6;e++)if(u){y?x&&d.texSubImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,f[e].width,f[e].height,g,_,f[e].data):d.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,v,f[e].width,f[e].height,0,g,_,f[e].data);for(let t=0;t>a),n=Math.max(1,t.height>>a);i===l.TEXTURE_3D||i===l.TEXTURE_2D_ARRAY?d.texImage3D(i,a,c,e,n,t.depth,0,o,s,null):d.texImage2D(i,a,c,e,n,0,o,s,null)}d.bindFramebuffer(l.FRAMEBUFFER,e),ke(t)?g.framebufferTexture2DMultisampleEXT(l.FRAMEBUFFER,r,i,p.__webglTexture,0,Oe(t)):(i===l.TEXTURE_2D||i>=l.TEXTURE_CUBE_MAP_POSITIVE_X&&i<=l.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&l.framebufferTexture2D(l.FRAMEBUFFER,r,i,p.__webglTexture,a),d.bindFramebuffer(l.FRAMEBUFFER,null)}function be(e,t,n){if(l.bindRenderbuffer(l.RENDERBUFFER,e),t.depthBuffer){let r=t.depthTexture,i=r&&r.isDepthTexture?r.type:null,a=j(t.stencilBuffer,i),o=t.stencilBuffer?l.DEPTH_STENCIL_ATTACHMENT:l.DEPTH_ATTACHMENT;ke(t)?g.renderbufferStorageMultisampleEXT(l.RENDERBUFFER,Oe(t),a,t.width,t.height):n?l.renderbufferStorageMultisample(l.RENDERBUFFER,Oe(t),a,t.width,t.height):l.renderbufferStorage(l.RENDERBUFFER,a,t.width,t.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,o,l.RENDERBUFFER,e)}else{let e=t.textures;for(let r=0;r{delete t.__boundDepthTexture,delete t.__depthDisposeCallback,n.removeEventListener(`dispose`,e)};n.addEventListener(`dispose`,e),t.__depthDisposeCallback=e}t.__boundDepthTexture=n}if(e.depthTexture&&!t.__autoAllocateDepthBuffer)if(n)for(let n=0;n<6;n++)xe(t.__webglFramebuffer[n],e,n);else{let n=e.texture.mipmaps;n&&n.length>0?xe(t.__webglFramebuffer[0],e,0):xe(t.__webglFramebuffer,e,0)}else if(n){t.__webglDepthbuffer=[];for(let n=0;n<6;n++)if(d.bindFramebuffer(l.FRAMEBUFFER,t.__webglFramebuffer[n]),t.__webglDepthbuffer[n]===void 0)t.__webglDepthbuffer[n]=l.createRenderbuffer(),be(t.__webglDepthbuffer[n],e,!1);else{let r=e.stencilBuffer?l.DEPTH_STENCIL_ATTACHMENT:l.DEPTH_ATTACHMENT,i=t.__webglDepthbuffer[n];l.bindRenderbuffer(l.RENDERBUFFER,i),l.framebufferRenderbuffer(l.FRAMEBUFFER,r,l.RENDERBUFFER,i)}}else{let n=e.texture.mipmaps;if(n&&n.length>0?d.bindFramebuffer(l.FRAMEBUFFER,t.__webglFramebuffer[0]):d.bindFramebuffer(l.FRAMEBUFFER,t.__webglFramebuffer),t.__webglDepthbuffer===void 0)t.__webglDepthbuffer=l.createRenderbuffer(),be(t.__webglDepthbuffer,e,!1);else{let n=e.stencilBuffer?l.DEPTH_STENCIL_ATTACHMENT:l.DEPTH_ATTACHMENT,r=t.__webglDepthbuffer;l.bindRenderbuffer(l.RENDERBUFFER,r),l.framebufferRenderbuffer(l.FRAMEBUFFER,n,l.RENDERBUFFER,r)}}d.bindFramebuffer(l.FRAMEBUFFER,null)}function Ce(e,t,n){let r=f.get(e);t!==void 0&&ye(r.__webglFramebuffer,e,e.texture,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,0),n!==void 0&&Se(e)}function we(e){let t=e.texture,n=f.get(e),r=f.get(t);e.addEventListener(`dispose`,ee);let i=e.textures,a=e.isWebGLCubeRenderTarget===!0,o=i.length>1;if(o||(r.__webglTexture===void 0&&(r.__webglTexture=l.createTexture()),r.__version=t.version,h.memory.textures++),a){n.__webglFramebuffer=[];for(let e=0;e<6;e++)if(t.mipmaps&&t.mipmaps.length>0){n.__webglFramebuffer[e]=[];for(let r=0;r0){n.__webglFramebuffer=[];for(let e=0;e0&&ke(e)===!1){n.__webglMultisampledFramebuffer=l.createFramebuffer(),n.__webglColorRenderbuffer=[],d.bindFramebuffer(l.FRAMEBUFFER,n.__webglMultisampledFramebuffer);for(let t=0;t0)for(let i=0;i0)for(let r=0;r0){if(ke(e)===!1){let t=e.textures,n=e.width,r=e.height,i=l.COLOR_BUFFER_BIT,a=e.stencilBuffer?l.DEPTH_STENCIL_ATTACHMENT:l.DEPTH_ATTACHMENT,o=f.get(e),s=t.length>1;if(s)for(let e=0;e0?d.bindFramebuffer(l.DRAW_FRAMEBUFFER,o.__webglFramebuffer[0]):d.bindFramebuffer(l.DRAW_FRAMEBUFFER,o.__webglFramebuffer);for(let c=0;c0&&u.has(`WEBGL_multisampled_render_to_texture`)===!0&&t.__useRenderToTexture!==!1}function Ae(e){let t=h.render.frame;y.get(e)!==t&&(y.set(e,t),e.update())}function z(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(J.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&H(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):U(`WebGLTextures: Unsupported texture color space:`,n)),t}function je(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(v.width=e.naturalWidth||e.width,v.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(v.width=e.displayWidth,v.height=e.displayHeight):(v.width=e.width,v.height=e.height),v}this.allocateTextureUnit=ae,this.resetTextureUnits=re,this.getTextureUnits=ie,this.setTextureUnits=I,this.setTexture2D=L,this.setTexture2DArray=se,this.setTexture3D=ce,this.setTextureCube=le,this.rebindTextures=Ce,this.setupRenderTarget=we,this.updateRenderTargetMipmap=Te,this.updateMultisampleRenderTarget=R,this.setupDepthRenderbuffer=Se,this.setupFrameBufferTexture=ye,this.useMultisampledRTT=ke,this.isReversedDepthBuffer=function(){return d.buffers.depth.getReversed()}}function zu(e,t){function n(n,r=``){let i,a=J.getTransfer(r);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===35899)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return e.HALF_FLOAT;if(n===1021)return e.ALPHA;if(n===1022)return e.RGB;if(n===1023)return e.RGBA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779)if(a===`srgb`)if(i=t.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(n===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(i=t.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(n===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===35840||n===35841||n===35842||n===35843)if(i=t.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(n===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===36196||n===37492||n===37496||n===37488||n===37489||n===37490||n===37491)if(i=t.get(`WEBGL_compressed_texture_etc`),i!==null){if(n===36196||n===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(n===37488)return i.COMPRESSED_R11_EAC;if(n===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(n===37490)return i.COMPRESSED_RG11_EAC;if(n===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821)if(i=t.get(`WEBGL_compressed_texture_astc`),i!==null){if(n===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===36492||n===36494||n===36495)if(i=t.get(`EXT_texture_compression_bptc`),i!==null){if(n===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===36283||n===36284||n===36285||n===36286)if(i=t.get(`EXT_texture_compression_rgtc`),i!==null){if(n===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===1020?e.UNSIGNED_INT_24_8:e[n]===void 0?null:e[n]}return{convert:n}}var Bu=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Vu=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`,Hu=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new zi(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new Co({vertexShader:Bu,fragmentShader:Vu,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Jr(new uo(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Uu=class extends Qe{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,u=null,d=null,f=null,p=null,h=null,g=typeof XRWebGLBinding<`u`,_=new Hu,v={},b=t.getContextAttributes(),x=null,S=null,C=[],D=[],O=new G,k=null,A=new rs;A.viewport=new wt;let j=new rs;j.viewport=new wt;let M=[A,j],N=new hs,ee=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=C[e];return t===void 0&&(t=new an,C[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=C[e];return t===void 0&&(t=new an,C[e]=t),t.getGripSpace()},this.getHand=function(e){let t=C[e];return t===void 0&&(t=new an,C[e]=t),t.getHandSpace()};function F(e){let t=D.indexOf(e.inputSource);if(t===-1)return;let n=C[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function te(){r.removeEventListener(`select`,F),r.removeEventListener(`selectstart`,F),r.removeEventListener(`selectend`,F),r.removeEventListener(`squeeze`,F),r.removeEventListener(`squeezestart`,F),r.removeEventListener(`squeezeend`,F),r.removeEventListener(`end`,te),r.removeEventListener(`inputsourceschange`,ne);for(let e=0;e=0&&(D[r]=null,C[r].disconnect(n))}for(let t=0;t=D.length){D.push(n),r=e;break}else if(D[e]===null){D[e]=n,r=e;break}if(r===-1)break}let i=C[r];i&&i.connect(n)}}let re=new K,ie=new K;function I(e,t,n){re.setFromMatrixPosition(t.matrixWorld),ie.setFromMatrixPosition(n.matrixWorld);let r=re.distanceTo(ie),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function ae(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;_.texture!==null&&(_.depthNear>0&&(t=_.depthNear),_.depthFar>0&&(n=_.depthFar)),N.near=j.near=A.near=t,N.far=j.far=A.far=n,(ee!==N.near||P!==N.far)&&(r.updateRenderState({depthNear:N.near,depthFar:N.far}),ee=N.near,P=N.far),N.layers.mask=e.layers.mask|6,A.layers.mask=N.layers.mask&-5,j.layers.mask=N.layers.mask&-3;let i=e.parent,a=N.cameras;ae(N,i);for(let e=0;e0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,e.envMapRotation.value.setFromMatrix4(Wu.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(Gu),e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function qu(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?H(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(t.boundary=16,t.storage=e.byteLength):H(`WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var Ju=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Yu=null;function Xu(){return Yu===null&&(Yu=new Zr(Ju,16,16,k,g),Yu.name=`DFG_LUT`,Yu.minFilter=o,Yu.magFilter=o,Yu.wrapS=t,Yu.wrapT=t,Yu.generateMipmaps=!1,Yu.needsUpdate=!0),Yu}var Zu=class{constructor(e={}){let{canvas:t=We(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:u=!1,powerPreference:d=`default`,failIfMajorPerformanceCaveat:p=!1,reversedDepthBuffer:h=!1,outputBufferType:b=l}=e;this.isWebGLRenderer=!0;let x;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);x=n.getContextAttributes().alpha}else x=a;let S=b,C=new Set([j,A,O]),w=new Set([l,m,f,y,_,v]),T=new Uint32Array(4),E=new Int32Array(4),D=new K,k=null,M=null,N=[],ee=[],P=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let F=this,te=!1,ne=null;this._outputColorSpace=Pe;let re=0,ie=0,I=null,ae=-1,oe=null,L=new wt,se=new wt,ce=null,le=new X(0),ue=0,de=t.width,fe=t.height,pe=1,me=null,he=null,ge=new wt(0,0,de,fe),_e=new wt(0,0,de,fe),ve=!1,ye=new mi,be=!1,xe=!1,Se=new Y,Ce=new K,we=new wt,Te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ee=!1;function De(){return I===null?pe:1}let R=n;function Oe(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:p};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r184`),t.addEventListener(`webglcontextlost`,nt,!1),t.addEventListener(`webglcontextrestored`,W,!1),t.addEventListener(`webglcontextcreationerror`,rt,!1),R===null){let t=`webgl2`;if(R=Oe(t,e),R===null)throw Oe(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw U(`WebGLRenderer: `+e.message),e}let ke,Ae,z,je,B,V,Me,Ne,Fe,Ie,Le,Re,ze,Ve,He,Ue,Ge,Ke,Je,Ye,Ze,Qe,$e;function et(){ke=new hc(R),ke.init(),Ze=new zu(R,ke),Ae=new Gs(R,ke,e,Ze),z=new Lu(R,ke),Ae.reversedDepthBuffer&&h&&z.buffers.depth.setReversed(!0),je=new vc(R),B=new _u,V=new Ru(R,ke,z,B,Ae,Ze,je),Me=new mc(F),Ne=new Ls(R),Qe=new Us(R,Ne),Fe=new gc(R,Ne,je,Qe),Ie=new bc(R,Fe,Ne,Qe,je),Ke=new yc(R,Ae,V),He=new Ks(B),Le=new gu(F,Me,ke,Ae,Qe,He),Re=new Ku(F,B),ze=new xu,Ve=new Ou(ke),Ge=new Hs(F,Me,z,Ie,x,s),Ue=new Iu(F,Ie,Ae),$e=new qu(R,je,Ae,z),Je=new Ws(R,ke,je),Ye=new _c(R,ke,je),je.programs=Le.programs,F.capabilities=Ae,F.extensions=ke,F.properties=B,F.renderLists=ze,F.shadowMap=Ue,F.state=z,F.info=je}et(),S!==1009&&(P=new Sc(S,t.width,t.height,r,i));let tt=new Uu(F,R);this.xr=tt,this.getContext=function(){return R},this.getContextAttributes=function(){return R.getContextAttributes()},this.forceContextLoss=function(){let e=ke.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=ke.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return pe},this.setPixelRatio=function(e){e!==void 0&&(pe=e,this.setSize(de,fe,!1))},this.getSize=function(e){return e.set(de,fe)},this.setSize=function(e,n,r=!0){if(tt.isPresenting){H(`WebGLRenderer: Can't change size while VR device is presenting.`);return}de=e,fe=n,t.width=Math.floor(e*pe),t.height=Math.floor(n*pe),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),P!==null&&P.setSize(t.width,t.height),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(de*pe,fe*pe).floor()},this.setDrawingBufferSize=function(e,n,r){de=e,fe=n,pe=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(S===1009){U(`THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t{function n(){if(r.forEach(function(e){B.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}ke.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let st=null;function ct(e){st&&st(e)}function lt(){ut.stop()}function q(){ut.start()}let ut=new Is;ut.setAnimationLoop(ct),typeof self<`u`&&ut.setContext(self),this.setAnimationLoop=function(e){st=e,tt.setAnimationLoop(e),e===null?ut.stop():ut.start()},tt.addEventListener(`sessionstart`,lt),tt.addEventListener(`sessionend`,q),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){U(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(te===!0)return;ne!==null&&ne.renderStart(e,t);let n=tt.enabled===!0&&tt.isPresenting===!0,r=P!==null&&(I===null||n)&&P.begin(F,I);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),tt.enabled===!0&&tt.isPresenting===!0&&(P===null||P.isCompositing()===!1)&&(tt.cameraAutoUpdate===!0&&tt.updateCamera(t),t=tt.getCamera()),e.isScene===!0&&e.onBeforeRender(F,e,t,I),M=Ve.get(e,ee.length),M.init(t),M.state.textureUnits=V.getTextureUnits(),ee.push(M),Se.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ye.setFromProjectionMatrix(Se,Be,t.reversedDepth),xe=this.localClippingEnabled,be=He.init(this.clippingPlanes,xe),k=ze.get(e,N.length),k.init(),N.push(k),tt.enabled===!0&&tt.isPresenting===!0){let e=F.xr.getDepthSensingMesh();e!==null&&dt(e,t,-1/0,F.sortObjects)}dt(e,t,0,F.sortObjects),k.finish(),F.sortObjects===!0&&k.sort(me,he),Ee=tt.enabled===!1||tt.isPresenting===!1||tt.hasDepthSensing()===!1,Ee&&Ge.addToRenderList(k,e),this.info.render.frame++,be===!0&&He.beginShadows();let i=M.state.shadowsArray;if(Ue.render(i,e,t),be===!0&&He.endShadows(),this.info.autoReset===!0&&this.info.reset(),(r&&P.hasRenderPass())===!1){let n=k.opaque,r=k.transmissive;if(M.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t0&&pt(n,r,e,t),Ee&&Ge.render(e),ft(k,e,t)}I!==null&&ie===0&&(V.updateMultisampleRenderTarget(I),V.updateRenderTargetMipmap(I)),r&&P.end(F),e.isScene===!0&&e.onAfterRender(F,e,t),Qe.resetDefaultState(),ae=-1,oe=null,ee.pop(),ee.length>0?(M=ee[ee.length-1],V.setTextureUnits(M.state.textureUnits),be===!0&&He.setGlobalState(F.clippingPlanes,M.state.camera)):M=null,N.pop(),k=N.length>0?N[N.length-1]:null,ne!==null&&ne.renderEnd()};function dt(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLightProbeGrid)M.pushLightProbeGrid(e);else if(e.isLight)M.pushLight(e),e.castShadow&&M.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||ye.intersectsSprite(e)){r&&we.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Se);let t=Ie.update(e),i=e.material;i.visible&&k.push(e,t,i,n,we.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||ye.intersectsObject(e))){let t=Ie.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),we.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),we.copy(e.boundingSphere.center)),we.applyMatrix4(e.matrixWorld).applyMatrix4(Se)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a0&&mt(i,t,n),a.length>0&&mt(a,t,n),o.length>0&&mt(o,t,n),z.buffers.depth.setTest(!0),z.buffers.depth.setMask(!0),z.buffers.color.setMask(!0),z.setPolygonOffset(!1)}function pt(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[r.id]===void 0){let e=ke.has(`EXT_color_buffer_half_float`)||ke.has(`EXT_color_buffer_float`);M.state.transmissionRenderTarget[r.id]=new Et(1,1,{generateMipmaps:!0,type:e?g:l,minFilter:c,samples:Math.max(4,Ae.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:J.workingColorSpace})}let a=M.state.transmissionRenderTarget[r.id],o=r.viewport||L;a.setSize(o.z*F.transmissionResolutionScale,o.w*F.transmissionResolutionScale);let s=F.getRenderTarget(),u=F.getActiveCubeFace(),d=F.getActiveMipmapLevel();F.setRenderTarget(a),F.getClearColor(le),ue=F.getClearAlpha(),ue<1&&F.setClearColor(16777215,.5),F.clear(),Ee&&Ge.render(n);let f=F.toneMapping;F.toneMapping=0;let p=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),M.setupLightsView(r),be===!0&&He.setGlobalState(F.clippingPlanes,r),mt(e,n,r),V.updateMultisampleRenderTarget(a),V.updateRenderTargetMipmap(a),ke.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i0,r.currentProgram=d,r.uniformsList=null,d}function _t(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=kl.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function vt(e,t){let n=B.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function yt(e,t){if(e.length===0)return null;if(e.length===1)return e[0].texture===null?null:e[0];D.setFromMatrixPosition(t.matrixWorld);for(let t=0,n=e.length;t0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(I===null||I.isXRRenderTarget===!0)&&(h=F.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=B.get(r),y=M.state.lights;if(be===!0&&(xe===!0||e!==oe)){let t=e===oe&&r.id===ae;He.setState(r,e,t)}let b=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?b=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?b=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==He.numPlanes||v.numIntersection!==He.numIntersection)?b=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.toneMapping===h&&v.morphTargetsCount===_?!!v.lightProbeGrid!=M.state.lightProbeGridArray.length>0&&(b=!0):b=!0:b=!0:b=!0:(b=!0,v.__version=r.version);let x=v.currentProgram;b===!0&&(x=gt(r,t,i),ne&&r.isNodeMaterial&&ne.onUpdateProgram(r,x,v));let S=!1,C=!1,w=!1,T=x.getUniforms(),E=v.uniforms;if(z.useProgram(x.program)&&(S=!0,C=!0,w=!0),r.id!==ae&&(ae=r.id,C=!0),v.needsLights){let e=yt(M.state.lightProbeGridArray,i);v.lightProbeGrid!==e&&(v.lightProbeGrid=e,C=!0)}if(S||oe!==e){z.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),T.setValue(R,`projectionMatrix`,e.projectionMatrix),T.setValue(R,`viewMatrix`,e.matrixWorldInverse);let t=T.map.cameraPosition;t!==void 0&&t.setValue(R,Ce.setFromMatrixPosition(e.matrixWorld)),Ae.logarithmicDepthBuffer&&T.setValue(R,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&T.setValue(R,`isOrthographic`,e.isOrthographicCamera===!0),oe!==e&&(oe=e,C=!0,w=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&T.setValue(R,`directionalShadowMap`,y.state.directionalShadowMap,V),y.state.spotShadowMap.length>0&&T.setValue(R,`spotShadowMap`,y.state.spotShadowMap,V),y.state.pointShadowMap.length>0&&T.setValue(R,`pointShadowMap`,y.state.pointShadowMap,V)),i.isSkinnedMesh){T.setOptional(R,i,`bindMatrix`),T.setOptional(R,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),T.setValue(R,`boneTexture`,e.boneTexture,V))}i.isBatchedMesh&&(T.setOptional(R,i,`batchingTexture`),T.setValue(R,`batchingTexture`,i._matricesTexture,V),T.setOptional(R,i,`batchingIdTexture`),T.setValue(R,`batchingIdTexture`,i._indirectTexture,V),T.setOptional(R,i,`batchingColorTexture`),i._colorsTexture!==null&&T.setValue(R,`batchingColorTexture`,i._colorsTexture,V));let D=n.morphAttributes;if((D.position!==void 0||D.normal!==void 0||D.color!==void 0)&&Ke.update(i,n,x),(C||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,T.setValue(R,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(E.envMapIntensity.value=t.environmentIntensity),E.dfgLUT!==void 0&&(E.dfgLUT.value=Xu()),C){if(T.setValue(R,`toneMappingExposure`,F.toneMappingExposure),v.needsLights&&xt(E,w),a&&r.fog===!0&&Re.refreshFogUniforms(E,a),Re.refreshMaterialUniforms(E,r,pe,fe,M.state.transmissionRenderTarget[e.id]),v.needsLights&&v.lightProbeGrid){let e=v.lightProbeGrid;E.probesSH.value=e.texture,E.probesMin.value.copy(e.boundingBox.min),E.probesMax.value.copy(e.boundingBox.max),E.probesResolution.value.copy(e.resolution)}kl.upload(R,_t(v),E,V)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(kl.upload(R,_t(v),E,V),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&T.setValue(R,`center`,i.center),T.setValue(R,`modelViewMatrix`,i.modelViewMatrix),T.setValue(R,`normalMatrix`,i.normalMatrix),T.setValue(R,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&V.useMultisampledRTT(e)===!1?B.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,L.copy(e.viewport),se.copy(e.scissor),ce=e.scissorTest}else L.copy(ge).multiplyScalar(pe).floor(),se.copy(_e).multiplyScalar(pe).floor(),ce=ve;if(n!==0&&(r=Ct),z.bindFramebuffer(R.FRAMEBUFFER,r)&&z.drawBuffers(e,r),z.viewport(L),z.scissor(se),z.setScissorTest(ce),i){let r=B.get(e.texture);R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t1&&R.readBuffer(R.COLOR_ATTACHMENT0+s),!Ae.textureFormatReadable(c)){U(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!Ae.textureTypeReadable(l)){U(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&R.readPixels(t,n,r,i,Ze.convert(c),Ze.convert(l),a)}finally{let e=I===null?null:B.get(I).__webglFramebuffer;z.bindFramebuffer(R.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=B.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){z.bindFramebuffer(R.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&R.readBuffer(R.COLOR_ATTACHMENT0+s),!Ae.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!Ae.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=R.createBuffer();R.bindBuffer(R.PIXEL_PACK_BUFFER,d),R.bufferData(R.PIXEL_PACK_BUFFER,a.byteLength,R.STREAM_READ),R.readPixels(t,n,r,i,Ze.convert(l),Ze.convert(u),0);let f=I===null?null:B.get(I).__webglFramebuffer;z.bindFramebuffer(R.FRAMEBUFFER,f);let p=R.fenceSync(R.SYNC_GPU_COMMANDS_COMPLETE,0);return R.flush(),await Xe(R,p,4),R.bindBuffer(R.PIXEL_PACK_BUFFER,d),R.getBufferSubData(R.PIXEL_PACK_BUFFER,0,a),R.deleteBuffer(d),R.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;V.setTexture2D(e,0),R.copyTexSubImage2D(R.TEXTURE_2D,n,0,0,o,s,i,a),z.unbindTexture()};let Tt=R.createFramebuffer(),Dt=R.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=Ze.convert(t.format),_=Ze.convert(t.type),v;t.isData3DTexture?(V.setTexture3D(t,0),v=R.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(V.setTexture2DArray(t,0),v=R.TEXTURE_2D_ARRAY):(V.setTexture2D(t,0),v=R.TEXTURE_2D),z.activeTexture(R.TEXTURE0),z.pixelStorei(R.UNPACK_FLIP_Y_WEBGL,t.flipY),z.pixelStorei(R.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),z.pixelStorei(R.UNPACK_ALIGNMENT,t.unpackAlignment);let y=z.getParameter(R.UNPACK_ROW_LENGTH),b=z.getParameter(R.UNPACK_IMAGE_HEIGHT),x=z.getParameter(R.UNPACK_SKIP_PIXELS),S=z.getParameter(R.UNPACK_SKIP_ROWS),C=z.getParameter(R.UNPACK_SKIP_IMAGES);z.pixelStorei(R.UNPACK_ROW_LENGTH,h.width),z.pixelStorei(R.UNPACK_IMAGE_HEIGHT,h.height),z.pixelStorei(R.UNPACK_SKIP_PIXELS,l),z.pixelStorei(R.UNPACK_SKIP_ROWS,u),z.pixelStorei(R.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=B.get(e),r=B.get(t),h=B.get(n.__renderTarget),g=B.get(r.__renderTarget);z.bindFramebuffer(R.READ_FRAMEBUFFER,h.__webglFramebuffer),z.bindFramebuffer(R.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function $u(e){return new Eo({color:0,emissive:16777215,emissiveIntensity:e})}function ed(e){let t=e>>>0;return function(){t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function td(e,t=e){let n=document.createElement(`canvas`);return n.width=e,n.height=t,[n,n.getContext(`2d`,{willReadFrequently:!0})]}function nd(t,{srgb:n=!0,repeat:r=null}={}){let i=new Ii(t);return i.wrapS=i.wrapT=e,n&&(i.colorSpace=Pe),i.anisotropy=8,r&&i.repeat.set(r[0],r[1]),i}function rd(e,t,n=5,r=1){let[i,a]=td(t);a.fillStyle=`#808080`,a.fillRect(0,0,t,t);for(let i=0;ii[((t+r)%r*n+(e+n)%n)*4]/255;for(let e=0;e1?255:(1/o*.5+.5)*255,s.data[l+3]=255}return o.putImageData(s,0,0),a}function ad(e,t,n,r,i,a,o,s=90){e.save(),e.strokeStyle=a;for(let a=0;a0?60:140},${i>0?60:140},${i>0?60:140},${n*1.4})`,s.beginPath(),s.moveTo(0,t),s.lineTo(r,t),s.stroke()}let u=rd(e,128,4);return a.globalCompositeOperation=`multiply`,a.globalAlpha=.32,a.drawImage(u,0,0,r,r),a.globalCompositeOperation=`source-over`,a.globalAlpha=1,od(a,e,16,r,r,`rgba(30,26,20,A)`,.4,60),ad(a,e,90,r,r,`rgba(210,212,218,0.9)`,.45,70),ad(a,e,50,r,r,`rgba(25,25,28,0.8)`,.4,50),ad(s,e,90,r,r,`rgba(55,55,55,1)`,.5,70),s.globalCompositeOperation=`lighten`,s.globalAlpha=.45,s.drawImage(u,0,0,r,r),s.globalCompositeOperation=`source-over`,s.globalAlpha=1,od(s,e,16,r,r,`rgba(200,200,200,A)`,.5,60),{map:nd(i),roughnessMap:nd(o,{srgb:!1}),normalMap:nd(id(rd(e,256,5),.8),{srgb:!1})}}function ud(e,{size:t=1024}={}){let[n,r]=td(t),[i,a]=td(t),[o,s]=td(t);r.fillStyle=`rgb(70,72,78)`,r.fillRect(0,0,t,t),a.fillStyle=`#808080`,a.fillRect(0,0,t,t),s.fillStyle=`#787878`,s.fillRect(0,0,t,t);let c=t/24;for(let e=0;e<24;e++)for(let n=0;n<24;n++){let i=n*c+c/2+(e%2?c/2:0),o=e*c+c/2,s=(n+e)%2?.78:-.78;r.save(),a.save(),r.translate(i%t,o),r.rotate(s),a.translate(i%t,o),a.rotate(s),r.fillStyle=`rgba(86,88,94,0.9)`,r.fillRect(-9,-3,18,6),r.fillStyle=`rgba(30,31,34,0.55)`,r.fillRect(-9,2,18,2),a.fillStyle=`#b4b4b4`,a.fillRect(-9,-3,18,6),r.restore(),a.restore()}for(let e of[0,t/2,t])r.strokeStyle=`rgba(10,11,13,0.95)`,r.lineWidth=6,r.beginPath(),r.moveTo(e,0),r.lineTo(e,t),r.stroke(),r.beginPath(),r.moveTo(0,e),r.lineTo(t,e),r.stroke(),a.strokeStyle=`#262626`,a.lineWidth=7,a.beginPath(),a.moveTo(e,0),a.lineTo(e,t),a.stroke(),a.beginPath(),a.moveTo(0,e),a.lineTo(t,e),a.stroke();for(let e of[0,t/2,t])for(let n of[t*.08,t*.42,t*.58,t*.92])sd(r,a,Math.min(Math.max(e+(e===0?14:e===t?-14:0),8),t-8),n,5);let l=r.createLinearGradient(0,0,t,0);l.addColorStop(0,`rgba(150,150,154,0)`),l.addColorStop(.5,`rgba(150,150,154,0.07)`),l.addColorStop(1,`rgba(150,150,154,0)`),r.fillStyle=l,r.fillRect(0,0,t,t);let u=s.createLinearGradient(0,0,t,0);u.addColorStop(0,`rgba(64,64,64,0)`),u.addColorStop(.5,`rgba(64,64,64,0.5)`),u.addColorStop(1,`rgba(64,64,64,0)`),s.fillStyle=u,s.fillRect(0,0,t,t);let d=rd(e,256,5);return r.globalCompositeOperation=`multiply`,r.globalAlpha=.4,r.drawImage(d,0,0,t,t),r.globalCompositeOperation=`source-over`,r.globalAlpha=1,od(r,e,30,t,t,`rgba(22,20,16,A)`,.5,80),ad(r,e,130,t,t,`rgba(180,182,188,0.8)`,.4,90),ad(s,e,130,t,t,`rgba(60,60,60,1)`,.5,90),{map:nd(n),roughnessMap:nd(o,{srgb:!1}),normalMap:nd(id(i,2.2),{srgb:!1})}}function dd(e,{color:t=`#cfc6b4`,size:n=256}={}){let[r,i]=td(n);i.fillStyle=t,i.fillRect(0,0,n,n);for(let e=0;e0;e-=c/3)a.strokeStyle=`rgba(36,222,214,0.4)`,a.lineWidth=1.5,a.beginPath(),a.arc(t,i,e,0,7),a.stroke();a.beginPath(),a.moveTo(t-c,i),a.lineTo(t+c,i),a.stroke(),a.beginPath(),a.moveTo(t,i-c),a.lineTo(t,i+c),a.stroke(),a.createConicGradient,a.fillStyle=`rgba(36,222,214,0.18)`,a.beginPath(),a.moveTo(t,i),a.arc(t,i,c,-.5,.45),a.closePath(),a.fill();for(let n=0;n<5;n++){a.fillStyle=n===2?`rgba(255,150,60,0.95)`:`rgba(36,222,214,0.9)`;let r=e()*6.28,o=e()*c*.9;a.beginPath(),a.arc(t+Math.cos(r)*o,i+Math.sin(r)*o,3.5,0,7),a.fill()}for(let t=0;t<9;t++)a.fillStyle=(t===3?s:o)+(.35+e()*.55)+`)`,a.fillRect(n*.62,30+t*28,30+e()*(n*.3),9)}else if(t===`eng`)for(let t=0;t<8;t++){let i=(.25+e()*.65)*(r-80);a.fillStyle=t===5?`rgba(255,150,60,0.9)`:`rgba(36,222,214,0.8)`,a.fillRect(30+t*((n-60)/8),r-36-i,(n-60)/8-10,i),a.fillStyle=`rgba(36,222,214,0.25)`,a.fillRect(30+t*((n-60)/8),40,(n-60)/8-10,r-76)}else if(t===`wave`){a.strokeStyle=`rgba(36,222,214,0.9)`,a.lineWidth=2.5,a.beginPath();for(let t=14;tn-40)break}}a.fillStyle=`rgba(0,0,0,0.22)`;for(let e=0;e>>0),{base:[40,8,.4]}),u=ld(t),d=ld(t,{tone:58}),f=ud(t),p=dd(t,{color:`#cbc2ae`}),m=dd(t,{color:`#a04e1c`}),h=fd(t),g=pd(t),_={hull:new To({map:c.map,roughnessMap:c.roughnessMap,normalMap:c.normalMap,roughness:1,metalness:.22,envMapIntensity:.7,normalScale:new G(.8,.8)}),hullLower:new To({map:l.map,roughnessMap:l.roughnessMap,normalMap:l.normalMap,roughness:1,metalness:.3,envMapIntensity:.6,normalScale:new G(.8,.8)}),metal:new To({map:u.map,roughnessMap:u.roughnessMap,normalMap:u.normalMap,roughness:.85,metalness:.95,envMapIntensity:1,normalScale:new G(.5,.5)}),metalDark:new To({map:d.map,roughnessMap:d.roughnessMap,normalMap:d.normalMap,roughness:.9,metalness:.9,envMapIntensity:.9,normalScale:new G(.6,.6)}),metalTube:new To({map:d.map,roughnessMap:d.roughnessMap,roughness:.9,metalness:.9,envMapIntensity:.7,side:2}),floor:new To({map:f.map,roughnessMap:f.roughnessMap,normalMap:f.normalMap,roughness:.9,metalness:.55,envMapIntensity:1,normalScale:new G(1.1,1.1)}),rubber:new To({color:1908256,roughness:.92,metalness:0,envMapIntensity:.25}),fabricWhite:new To({map:p.map,normalMap:p.normalMap,roughness:.96,metalness:0,envMapIntensity:.3}),fabricOrange:new To({map:m.map,normalMap:m.normalMap,roughness:.96,metalness:0,envMapIntensity:.3}),grate:new To({map:h.map,alphaMap:h.alphaMap,alphaTest:.5,roughness:.8,metalness:.9,side:2,envMapIntensity:.6}),hazard:new To({map:g,roughness:.7,metalness:.3,envMapIntensity:.5}),glass:new To({color:6983584,roughness:.08,metalness:0,transparent:!0,opacity:.06,envMapIntensity:.3,depthWrite:!1,side:2}),mirror:new To({color:13161688,roughness:.05,metalness:1,envMapIntensity:1.8}),plastic:new To({color:14210248,roughness:.5,metalness:.1,envMapIntensity:.4}),stripWarm:new To({color:1118481,emissive:16767400,emissiveIntensity:1.5,roughness:.4}),stripTeal:new To({color:332047,emissive:1692880,emissiveIntensity:2.4,roughness:.4}),stripOrange:new To({color:1116163,emissive:16742944,emissiveIntensity:1.5,roughness:.4}),ledRed:new To({color:1115140,emissive:16724e3,emissiveIntensity:1.6,roughness:.4}),stripTealDim:new To({color:332047,emissive:1692880,emissiveIntensity:1,roughness:.4})};o.push({mat:_.stripTealDim,day:1,night:1.4}),o.push({mat:_.stripWarm,day:1.5,night:.35}),o.push({mat:_.stripTeal,day:2.4,night:3}),o.push({mat:_.stripOrange,day:1.5,night:1});let v={};for(let e of[`nav`,`eng`,`wave`,`text`])v[e]=new To({color:0,emissive:16777215,emissiveMap:md(t,e),emissiveIntensity:1.5,roughness:.25,metalness:0}),o.push({mat:v[e],day:1.5,night:.9});let y=1/4.8,b=1/2.5,x=.12,S=2.5;function C(e,t,n,i,a,o,c,l={}){let u=new Bi(t,n,i);l.hullUV?Ed(u,t,n,i,y,b,l.ou||0,l.ov||0):l.texel&&Ed(u,t,n,i,l.texel,l.texel),$.compose(Cd.set(a,o,c),Sd.setFromEuler(xd.set(l.rx||0,l.ry||0,l.rz||0)),wd),u.applyMatrix4($),l.collide&&(u.computeBoundingBox(),r.push(u.boundingBox.clone())),s.add(e,u)}function w(e,t,n,i,a,o,c,l,u={}){let d=new Vi(t,n,i,a,1,u.open||!1);u.texel&&Dd(d,u.texel*Math.PI*2*t,u.texel*i),$.compose(Cd.set(o,c,l),Sd.setFromEuler(xd.set(u.rx||0,u.ry||0,u.rz||0)),wd),d.applyMatrix4($),u.collide&&(d.computeBoundingBox(),r.push(d.boundingBox.clone())),s.add(e,d)}function T(e,t,n,r,i,a,o={}){let c=new mo(t,n,8,24,o.arc||Math.PI*2);$.compose(Cd.set(r,i,a),Sd.setFromEuler(xd.set(o.rx||0,o.ry||0,o.rz||0)),wd),c.applyMatrix4($),s.add(e,c)}function E(e,t,n,i,a,o){r.push(new Dn(new K(e,t,n),new K(i,a,o)))}function D(e,t,n,r,i,a,o,c,l=0,u=0){let d=new Ca;d.moveTo(-t/2,0),d.lineTo(t/2,0),d.lineTo(t/2,n),d.lineTo(-t/2,n),d.closePath();let f=new Sa;f.absarc(0,r,i,0,Math.PI*2,!0),d.holes.push(f);let p=new so(d,{depth:x,bevelEnabled:!1,curveSegments:24});Dd(p,y,b,l,u),p.translate(0,0,-.12/2),$.compose(Cd.set(a,0,o),Sd.setFromEuler(xd.set(0,c,0)),wd),p.applyMatrix4($),s.add(e,p)}function O(e,t,n,i){let a=n-t,o=(t+n)/2;C(_.hullLower,x,.5,a,e,.25,o,{collide:!0,texel:.5});let c=new Bi(a,S-.5,x);Ed(c,a,S-.5,x,y,b,(t+8)*y,.5*b),$.compose(Cd.set(e,1.5,o),Sd.setFromEuler(xd.set(0,i,0)),wd),c.applyMatrix4($),c.computeBoundingBox(),r.push(c.boundingBox.clone()),s.add(_.hull,c)}function k(e,t,n,i=!1){let a=n-t,o=(t+n)/2;C(_.hullLower,a,.5,x,o,.25,e,{collide:!0,texel:.5});let c=new Bi(a,S-.5,x);Ed(c,a,S-.5,x,y,b,(t+8)*y,.5*b),$.compose(Cd.set(o,1.5,e),Sd.setFromEuler(xd.set(0,i?Math.PI:0,0)),wd),c.applyMatrix4($),c.computeBoundingBox(),r.push(c.boundingBox.clone()),s.add(_.hull,c)}function A(e,t,n){T(_.metal,.46,.07,e-n*.02,1.6,t,{ry:Math.PI/2}),T(_.metalDark,.38,.035,e-n*.08,1.6,t,{ry:Math.PI/2});let r=new Vi(.4,.4,.02,24);$.compose(Cd.set(e+n*.1,1.6,t),Sd.setFromEuler(xd.set(0,0,Math.PI/2)),wd),r.applyMatrix4($),s.add(_.glass,r);for(let r=0;r<8;r++){let i=r/8*Math.PI*2+.39;w(_.metalDark,.028,.028,.05,8,e-n*.05,1.6+Math.cos(i)*.51,t+Math.sin(i)*.51,{rz:Math.PI/2})}w(_.metalTube,.42,.42,.3,18,e+n*.06,1.6,t,{rz:Math.PI/2,open:!0})}let j=1.2;{let e=new Bi(1.6,.1,16);Ed(e,1.6,.1,16,1/2.4,1/2.4),$.makeTranslation(0,-.05,0),e.applyMatrix4($),s.add(_.floor,e)}for(let e of[-1,1]){C(_.metalDark,.4,.1,16,e*1,-.1,0,{texel:1}),C(_.stripTeal,.34,.02,15.6,e*1,-.062,0,{});let t=new Bi(.4,.012,16);Ed(t,.4,.012,16,2.5,2.5),$.makeTranslation(e*1,-.006,0),t.applyMatrix4($),s.add(_.grate,t);let n=e>0?[[-7.8,1.55],[2.85,7.8]]:[[-7.8,-4.05],[-2.75,3.05],[4.15,7.8]];for(let[t,r]of n)C(_.stripTeal,.025,.03,r-t,e*1.21,.04,(t+r)/2,{})}C(_.hullLower,2.4,.1,16.4,0,2.55,0,{hullUV:!0});let M=1.26;O(M,-8,-4.6,-Math.PI/2),D(_.hull,1.2,S,1.6,.43,M,-4,-Math.PI/2),E(j,0,-4.6,1.3199999999999998,S,-3.4),O(M,-3.4,1.65,-Math.PI/2),O(M,2.75,8,-Math.PI/2),O(-1.26,-8,-3.95,Math.PI/2),O(-1.26,-2.85,.1,Math.PI/2),D(_.hull,1.2,S,1.6,.43,-1.26,.7,Math.PI/2),E(-1.2-x,0,.1,-1.2,S,1.3),O(-1.26,1.3,3.15,Math.PI/2),O(-1.26,4.05,8,Math.PI/2);function N(e,t,n){let r=e*M,i=n-t,a=(t+n)/2;C(_.hull,x,S-2.1,i,r,4.6/2,a,{collide:!0,hullUV:!0}),C(_.metalDark,.3,2.16,.18,r,1.05,t-.06,{texel:1}),C(_.metalDark,.3,2.16,.18,r,1.05,n+.06,{texel:1}),C(_.metalDark,.3,.14,i+.36,r,2.16,a,{texel:1}),C(_.hazard,.015,1.8,.1,r-e*.155,.95,t-.06,{}),C(_.hazard,.015,1.8,.1,r-e*.155,.95,n+.06,{}),C(_.stripOrange,.03,.06,.45,r-e*.145,2.32,a,{}),C(_.metalDark,.44,.02,i+.2,r,.01,a,{texel:2})}N(1,1.65,2.75),N(-1,-3.95,-2.85),N(-1,3.15,4.05);for(let e=-7;e<=7;e+=2)if(!(Math.abs(e-2.2)<.8||Math.abs(e+3.4)<.8||Math.abs(e-3.6)<.8)&&!(Math.abs(e+4)<.7||Math.abs(e-.7)<.7)){for(let t of[-1,1])C(_.metal,.18,S,.22,t*(j-.09),S/2,e,{texel:1,collide:!0}),C(_.metal,.5,.18,.22,t*(j-.28),S-.22,e,{rz:t*.6,texel:1}),C(_.metalDark,.22,.3,.26,t*(j-.09),.15,e,{texel:1});C(_.metal,2.4,.16,.22,0,S-.08,e,{texel:1}),C(_.stripTeal,.04,.18,.05,-.9999999999999999,1.65,e,{}),C(_.stripOrange,.04,.05,.05,j-.09-.11,1.65,e,{})}for(let e=-6;e<=6;e+=3){C(_.metalDark,.7,.07,1.4,0,S-.035,e,{texel:1}),C(_.stripWarm,.4,.02,1.05,0,S-.075,e,{});for(let t=-2;t<=2;t++)C(_.metalDark,.46,.025,.05,0,S-.085,e+t*.22,{})}for(let e of[-6,0,6]){let t=new as(16767400,18,7,1.25,.7,2);t.position.set(0,S-.15,e),t.target.position.set(0,0,e),n.add(t,t.target),a.push({light:t,day:18,night:2})}{let e=new ss(2774432,0,12,2);e.position.set(0,S-.3,0),n.add(e),a.push({light:e,day:0,night:9})}for(let e of[-1,1]){let t=[.055,.04,.07];for(let n=0;n<3;n++){let r=t[n],i=e*(j-.18-n*.14);w(n===1?_.metalDark:_.metal,r,r,16,10,i,S-.16-(n===2?.11:0),0,{rx:Math.PI/2,texel:1})}for(let t=-7;t<=7;t+=2)C(_.metalDark,.46,.06,.08,e*(j-.32),S-.18,t,{texel:1})}let ee={1:[[1.45,2.95],[-4.75,-3.25]],[-1]:[[-4.15,-2.65],[2.95,4.25],[.1,1.3]]},P=(e,t,n)=>ee[e].some(([e,r])=>te);for(let e=-7;e<8;e+=2)for(let t of[-1,1]){let n=e+1,r=t*(j-.04);P(t,n-.9,n+.9)||(w(_.metalDark,.025,.025,1.7,8,r,.95,n,{rx:Math.PI/2}),w(_.metalDark,.018,.018,1.7,8,r,1.03,n,{rx:Math.PI/2}),(t>0?(e+7)%4:(e+9)%4)==0&&!P(t,n-.3,n+.3)&&(C(_.metal,.07,.34,.5,r,1.3,n,{texel:2}),C(_.stripTeal,.02,.04,.04,r-t*.05,1.4,n-.15,{}),C(_.ledRed,.02,.04,.04,r-t*.05,1.4,n,{})))}A(M,-4,1),A(-1.26,.7,-1),C(_.hazard,1.6,.006,.18,0,.003,-7.72,{}),C(_.hazard,1.6,.006,.18,0,.003,7.6,{}),w(_.rubber,.014,.014,3.6,6,-.72,.014,5.4,{rx:Math.PI/2}),w(_.rubber,.014,.014,.5,6,-.95,.014,5.18,{rx:Math.PI/2,ry:1.1});for(let e of[4.2,5.6,6.8])C(_.metalDark,.06,.025,.05,-.72,.012,e,{});for(let[e,t]of[[-4.5,-1],[-.5,1],[3.4,-1]]){let n=t*.45;C(_.metalDark,.05,.16,.05,n-.14,S-.1,e,{}),C(_.metalDark,.05,.16,.05,n+.14,S-.1,e,{}),C(_.metal,.34,.045,.05,n,S-.2,e,{texel:2})}C(_.metalDark,.52,.52,.52,.82,.26,7.3,{ry:.12,texel:1,collide:!0}),C(_.hullLower,.42,.42,.42,.8,.73,7.32,{ry:-.2,hullUV:!0}),C(_.hazard,.53,.1,.53,.82,.3,7.3,{ry:.12}),C(_.hullLower,.46,.4,.46,-.85,.2,6.9,{ry:.35,hullUV:!0,collide:!0}),C(_.stripOrange,.05,.03,.05,-.85,.42,6.9,{ry:.35});{let e=-1.22,t=5.2;C(_.rubber,.1,.9,.7,e,1.15,t,{}),w(_.metal,.03,.03,.8,8,-1.19,1.15,t-.15,{}),w(_.metalDark,.022,.022,.8,8,-1.19,1.15,5.22,{}),w(_.metalDark,.016,.016,.8,8,-1.18,1.15,5.36,{}),C(_.stripTeal,.03,.04,.04,-1.18,1.45,5.44,{}),C(_.ledRed,.03,.04,.04,-1.18,1.32,5.44,{}),C(_.metalDark,.04,.96,.76,e-.04,1.15,t,{texel:1}),C(_.hull,.04,.8,.6,-1,.42,t-.5,{rz:-.28,ry:.1,hullUV:!0,collide:!0})}{let e=-8-x/2;C(_.hull,1,S,x,-1.2,S/2,e,{hullUV:!0,collide:!0}),C(_.hull,1,S,x,1.2,S/2,e,{hullUV:!0,collide:!0}),C(_.hull,1.4,S-2.1,x,0,4.6/2,e,{hullUV:!0}),C(_.metalDark,.34,2.2,.3,-.78,1.05,e,{collide:!0,texel:1}),C(_.metalDark,.34,2.2,.3,.78,1.05,e,{collide:!0,texel:1}),C(_.metalDark,1.9,.18,.3,0,2.18,e,{texel:1}),C(_.stripWarm,1.3,.05,.06,0,2.12,e-.16,{}),C(_.hull,1,S,x,-1.95,S/2,e-.12,{hullUV:!0,collide:!0}),C(_.hull,1,S,x,1.95,S/2,e-.12,{hullUV:!0,collide:!0});{let e=new Bi(4.6,.1,5.6);Ed(e,4.6,.1,5.6,1/2.4,1/2.4),$.makeTranslation(0,-.05,-10.8),e.applyMatrix4($),s.add(_.floor,e)}C(_.hullLower,4.6,.1,5.6,0,2.55,-10.8,{hullUV:!0});for(let e of[-1,1])C(_.hull,.12,S,5.2,e*1.95,S/2,-10.5,{ry:e*.2,hullUV:!0,collide:!0});let r=-12.9;C(_.hullLower,4.2,.92,.45,0,.46,-12.85,{hullUV:!0,collide:!0}),C(_.hullLower,4.2,.4,.6,0,S-.2,-12.8,{hullUV:!0});for(let e of[{x:0,w:1.06,ry:0},{x:-1.08,w:1.1,ry:.22},{x:1.08,w:1.1,ry:-.22}]){let t=r+Math.abs(e.x)*.12,n=new Bi(e.w,1.46,.04);$.compose(Cd.set(e.x,1.62,t),Sd.setFromEuler(xd.set(-.2,e.ry,0)),wd),n.applyMatrix4($),s.add(_.glass,n)}for(let e of[-1,1])C(_.metalDark,.1,1.62,.18,e*.55,1.6,-12.870000000000001,{rx:-.2,ry:e*.1,texel:1});for(let e of[-1,1])C(_.hull,.55,S,.7,e*1.78,S/2,-12.55,{ry:e*.45,hullUV:!0,collide:!0});E(-2.2,0,r-.5,2.2,S,-12.6),C(_.metalDark,3.4,.16,.9,0,.97,-12.15,{rx:-.18,texel:1}),C(_.hullLower,3.4,.55,.7,0,.62,-12.05,{hullUV:!0,collide:!0});{let e=new Bi(3,.46,.1);Ed(e,3,.46,.1,1,1),$.compose(Cd.set(0,1.21,-12.42),Sd.setFromEuler(xd.set(-.42,0,0)),wd),e.applyMatrix4($),s.add(_.metalDark,e)}for(let e of[{x:-1.05,kind:`nav`,w:.62},{x:-.35,kind:`wave`,w:.6},{x:.35,kind:`eng`,w:.6},{x:1.05,kind:`text`,w:.62}]){let t=new Bi(e.w,.34,.02);$.compose(Cd.set(e.x,1.22,-12.36),Sd.setFromEuler(xd.set(-.42,0,0)),wd),t.applyMatrix4($),s.add(v[e.kind],t)}{let e=new K(0,Math.cos(.18),-Math.sin(.18)),n=new K(0,Math.sin(.18),Math.cos(.18)),r=new K(0,.97,-12.15);for(let i=0;i<26;i++){let i=-1.5+t()*3,a=-.38+t()*.74,o=[_.stripTeal,_.stripOrange,_.ledRed][t()*3|0],s=r.clone().addScaledVector(e,.09).addScaledVector(n,a);C(o,.035,.025,.035,i,s.y,s.z,{rx:-.18})}}C(_.metalDark,.5,.7,.8,0,.35,-11.3,{collide:!0,texel:1}),C(_.metal,.4,.06,.7,0,.73,-11.3,{texel:1});for(let e of[-1,1])w(_.metalDark,.02,.02,.26,8,e*.1,.85,-11.35,{rx:-.5}),C(_.stripOrange,.07,.05,.07,e*.1,.96,-11.42,{});for(let e of[-1,1]){let t=e*.62,n=-10.7;w(_.metalDark,.09,.13,.35,10,t,.18,n,{}),C(_.rubber,.56,.13,.55,t,.42,n,{collide:!0}),C(_.fabricOrange,.5,.07,.48,t,.52,n,{texel:2}),C(_.rubber,.56,.75,.14,t,.82,-10.399999999999999,{rx:.1,collide:!0}),C(_.fabricOrange,.48,.6,.06,t,.84,-10.465,{rx:.1,texel:2}),C(_.rubber,.3,.2,.1,t,1.28,-10.36,{rx:.1});for(let e of[-1,1])C(_.metalDark,.06,.05,.4,t+e*.3,.62,-10.649999999999999,{texel:2})}C(_.metalDark,1.4,.06,.6,0,S-.28,-11.9,{rx:.3,texel:1});{let e=new K(0,Math.cos(.3),Math.sin(.3)),n=new K(0,-Math.sin(.3),Math.cos(.3)),r=new K(0,S-.28,-11.9);for(let i=0;i<12;i++){let a=[_.stripTeal,_.stripWarm,_.stripOrange][t()*3|0],o=i/6|0,s=r.clone().addScaledVector(e,-.04).addScaledVector(n,o===0?-.14:.12);C(a,.04,.02,.04,-.6+i%6*.24,s.y,s.z,{rx:.3})}}for(let e of[-1,1]){C(_.hullLower,.5,.85,1.8,e*1.58,.42,-10.6,{ry:e*.2,hullUV:!0,collide:!0});let t=new Bi(.44,.3,.02);$.compose(Cd.set(e*1.47,.885,-10.6),Sd.setFromEuler(xd.set(-1.25,e*.2,0)),wd),t.applyMatrix4($),s.add(v[e>0?`eng`:`text`],t)}C(_.stripWarm,.6,.02,.3,0,S-.06,-9,{});let i=new ss(16765088,9,6,2);i.position.set(0,S-.4,-9.2),n.add(i),a.push({light:i,day:9,night:1.2});let o=new ss(2806476,3,3,2);o.position.set(0,1.25,-11.9),n.add(o),a.push({light:o,day:3,night:2.2});let c=new ss(10471656,4,5,2);c.position.set(0,1.6,-12.4),n.add(c),a.push({light:c,day:4,night:4})}{let e=8.06;C(_.hull,2.6,S,x,0,S/2,e,{hullUV:!0,collide:!0}),T(_.metal,.78,.1,0,1.25,e-.12,{}),w(_.metalDark,.72,.72,.08,24,0,1.25,e-.1,{rx:Math.PI/2,texel:1});for(let t=0;t<6;t++){let n=t/6*Math.PI*2;C(_.metal,.1,.62,.06,Math.cos(n)*.35,1.25+Math.sin(n)*.35,e-.16,{rz:n+Math.PI/2,texel:2})}T(_.metal,.2,.035,0,1.25,e-.22,{}),w(_.metalDark,.05,.05,.16,8,0,1.25,e-.18,{rx:Math.PI/2}),C(_.hazard,2.3,.18,.03,0,2.32,e-.09,{}),C(_.ledRed,.1,.06,.05,-.9,2.14,e-.1,{}),C(_.stripOrange,.1,.06,.05,.9,2.14,e-.1,{});for(let t of[-1,1])w(_.metal,.06,.06,1.6,10,t*1,1.9,e-.16,{rz:t*1,texel:1}),w(_.metal,.06,.06,1.2,10,t*.5,.5,e-.16,{rz:t*2.2,texel:1}),T(_.metal,.09,.02,t*.9,.7,e-.24,{});E(-1.3,0,7.85,1.3,S,8.3)}{let e=1.3199999999999998,t=5.6,r=1.2,o=6.4,c=6.92/2,l=7.6000000000000005/2;{let n=new Bi(4.4799999999999995,.1,5.4);Ed(n,t-e,.1,o-r,1/2.4,1/2.4),$.makeTranslation(c,-.05,l),n.applyMatrix4($),s.add(_.floor,n)}w(_.fabricOrange,.8,.8,.025,20,3,.012,3.4,{texel:1}),C(_.hullLower,4.4799999999999995,.1,5.4,c,2.55,l,{hullUV:!0});let u=5.659999999999999;O(u,r,3.8,Math.PI/2),D(_.hull,1.2,S,1.6,.43,u,4.4,Math.PI/2),E(t,0,3.8,5.72,S,5),O(u,5,o,Math.PI/2),A(u,4.4,1),k(6.46,e-.15,5.75,!0),k(r-x/2,e-.15,5.75,!1);let d=4.35,f=5.75;C(_.metalDark,2.3,.4,1.15,d,.2,f,{collide:!0,texel:1}),C(_.fabricWhite,2.24,.18,1.05,d,.49,f,{texel:2}),C(_.fabricOrange,1.5,.08,1.07,d-.38,.6,f,{texel:2}),C(_.fabricWhite,.5,.12,.7,5.17,.61,f,{ry:.08,texel:2});for(let e=0;e<3;e++)C(_.hullLower,.68,.26,.04,d-.72+e*.74,.18,f-.595,{hullUV:!0}),C(_.metal,.3,.03,.03,d-.72+e*.74,.18,f-.615,{});C(_.stripTeal,.03,.03,1.1,5.59,1.45,f,{}),C(_.metalDark,.3,.04,1.1,5.46,1.25,f,{texel:1}),w(_.metal,.06,.06,.18,10,5.46,1.36,f-.3,{texel:2}),C(_.fabricOrange,.14,.18,.1,5.46,1.36,6,{ry:.4,texel:2}),C(_.hullLower,.4,.55,1.4,5.45,2.05,5.85,{hullUV:!0}),C(_.metal,.03,.2,.03,5.24,2.05,f-.3,{}),C(_.metal,.03,.2,.03,5.24,2.05,6.25,{}),C(_.stripOrange,.02,.03,1.2,5.26,1.81,5.85,{});for(let e=0;e<3;e++){let t=2.2+e*.78;C(_.hullLower,.72,1.9,.5,t,.95,1.44,{collide:!0,hullUV:!0,ou:e*.3}),C(_.metal,.05,.3,.03,t+.25,1,1.7,{});for(let e=0;e<4;e++)C(_.metalDark,.4,.025,.02,t,1.62-e*.07,1.6949999999999998,{});C(e===1?_.stripTeal:_.stripOrange,.08,.03,.02,t-.2,1.78,1.6949999999999998,{})}C(_.metal,.6,.05,1.1,5.25,.78,2.4,{collide:!0,texel:1}),C(_.hullLower,.5,.76,.5,5.3,.38,2.7,{hullUV:!0,collide:!0});{let e=new Bi(.02,.5,.8);$.makeTranslation(5.595,1.6,2.4),e.applyMatrix4($),s.add(v.text,e)}w(_.metalDark,.18,.22,.45,12,4.5,.22,2.4,{collide:!0}),w(_.fabricOrange,.2,.2,.06,12,4.5,.48,2.4,{texel:2}),w(_.metalDark,.025,.04,.5,8,5.32,1.9,6.12,{rz:.5}),w(_.metal,.09,.13,.16,10,5.2,2.1,6.1,{rz:.7,open:!0}),C(_.stripWarm,.06,.04,.06,5.2,2.05,6.1,{});let p=new as(16763024,20,8,.95,.55,1.6);p.position.set(5.12,2.15,6.05),p.target.position.set(4,.5,5.5),p.castShadow=!0,p.shadow.mapSize.set(512,512),p.shadow.bias=-.0015,p.shadow.normalBias=.02,n.add(p,p.target),a.push({light:p,day:20,night:4}),C(_.stripWarm,.5,.02,.5,3,S-.04,3.2,{});let m=new ss(16767400,9,6.5,2);m.position.set(3,S-.45,3.2),n.add(m),a.push({light:m,day:9,night:1});let h=new ss(1671380,0,7,2);h.position.set(4.5,1,5.5),n.add(h),a.push({light:h,day:0,night:5}),w(_.metalDark,.03,.03,4.2,8,1.37,2.3,4.1000000000000005,{rx:Math.PI/2}),C(_.metal,.08,.3,.4,1.35,2.1,4,{texel:2}),C(_.metalDark,.7,.07,1.2,3,S-.035,3.2,{texel:1}),C(_.metalDark,.5,.06,.7,4.6,S-.03,2,{texel:2});for(let e=0;e<4;e++)C(_.metal,.4,.02,.07,4.6,S-.065,1.75+e*.16,{});w(_.metal,.045,.045,4,8,3.4,S-.1,4.6,{rz:Math.PI/2,texel:1}),w(_.plastic,.035,.035,.09,10,5.2,.85,2.2,{}),C(_.rubber,.11,.14,.3,3.4,.07,5.2,{ry:.3}),C(_.rubber,.11,.14,.3,3.65,.07,5.05,{ry:-.15}),i.push({id:`bed`,prompt:`E: Sleep`,center:new K(d,.55,f),size:new K(2.4,.7,1.25)})}{let e=-5.2,r=-5.6,o=-1.2,c=-6.52/2,l=-6.8/2;{let t=new Bi(4.08,.1,4.6);Ed(t,-1.3199999999999998-e,.1,o-r,1/2.4,1/2.4),$.makeTranslation(c,-.05,l),t.applyMatrix4($),s.add(_.floor,t)}C(_.hullLower,4.08,.1,4.6,c,2.55,l,{hullUV:!0}),O(e-x/2,r,o,Math.PI/2),k(r-x/2,e-.15,-1.17,!1),k(-1.14,e-.15,-1.17,!0);let u=.62;C(_.hullLower,u,.76,3.6,-4.890000000000001,.48,l,{collide:!0,hullUV:!0}),C(_.metal,.6799999999999999,.05,3.66,-4.890000000000001,.88,l,{texel:1}),C(_.rubber,u-.05,.1,3.6,-4.915,.05,l,{}),C(_.stripOrange,.02,.04,3.3,-4.575,.83,l,{});for(let e=0;e<5;e++)C(_.metal,.03,.03,.3,-4.575,.68,-4.8999999999999995+e*.7,{});C(_.metalDark,.4,.04,.5,-4.890000000000001,.9,-4.5,{texel:1}),w(_.metal,.025,.025,.3,8,-5,1,-4.3,{rz:-.5}),C(_.rubber,.5,.012,.8,-4.890000000000001,.906,-3.2,{});for(let e of[-.2,.2])T(_.stripOrange,.11,.018,-4.890000000000001,.915,-3.2+e,{rx:Math.PI/2});w(_.metalDark,.13,.13,.05,14,-4.890000000000001,.94,-3,{open:!1}),w(_.metalDark,.015,.015,.22,6,-4.69,.96,-3,{rz:Math.PI/2}),w(_.plastic,.035,.035,.09,10,-4.840000000000001,.95,-4,{}),w(_.plastic,.035,.035,.09,10,-5.010000000000001,.95,-3.85,{}),C(_.hullLower,.45,.75,3.4,-5,1.95,l,{hullUV:!0});for(let e=0;e<4;e++)C(_.metal,.03,.25,.03,-4.765000000000001,1.95,-4.75+e*.85,{});C(_.stripTealDim,.012,.02,3.2,-4.772,1.56,l,{}),C(_.metal,1.6,.04,.35,-2,1.5,-5.4399999999999995,{texel:1});for(let e=0;e<5;e++){let n=.16+t()*.18;w(e%2?_.metal:_.plastic,.07,.07,n,10,-2.7+e*.36,1.52+n/2,-5.42,{texel:2})}w(_.metalDark,.06,.1,.74,10,-2.6,.37,-2.3,{}),w(_.metal,.55,.55,.05,20,-2.6,.76,-2.3,{texel:1,collide:!0});for(let[e,t]of[[-3.3,-2],[-2,-2.8]])w(_.metalDark,.16,.2,.45,12,e,.22,t,{collide:!0}),w(_.fabricOrange,.18,.18,.06,12,e,.48,t,{texel:2});{let e=new Bi(.9,.55,.02);$.compose(Cd.set(-3,1.65,-1.195),Sd.setFromEuler(xd.set(0,Math.PI,0)),wd),e.applyMatrix4($),s.add(v.wave,e)}w(_.metalDark,.012,.012,.5,6,-2.6,S-.25,-2.3,{}),w(_.metal,.16,.05,.18,12,-2.6,S-.55,-2.3,{open:!0}),C(_.stripWarm,.1,.03,.1,-2.6,S-.62,-2.3,{});let d=new as(16763024,24,7,1.15,.6,1.5);d.position.set(-2.6,S-.6,-2.3),d.target.position.set(-2.6,0,-2.3),d.castShadow=!0,d.shadow.mapSize.set(512,512),d.shadow.bias=-.0015,d.shadow.normalBias=.02,n.add(d,d.target),a.push({light:d,day:24,night:3});let f=new ss(16767400,8,6,2);f.position.set(-4.2,2.1,-3.4),n.add(f),a.push({light:f,day:8,night:.9}),i.push({id:`galley`,prompt:`E: Eat`,center:new K(-4.890000000000001,.7,-3.2),size:new K(.9,.9,1.3)})}{let e=2.6,t=5.4,r=-5.32/2;{let n=new Bi(2.8800000000000003,.1,3.0000000000000004);Ed(n,2.68,.1,t-e,1/2.4,1/2.4),$.makeTranslation(r,-.05,4),n.applyMatrix4($),s.add(_.floor,n)}C(_.hullLower,2.8800000000000003,.1,3.0000000000000004,r,2.55,4,{hullUV:!0}),O(-4-x/2,e,t,Math.PI/2),k(e-x/2,-4.15,-1.17,!1),k(5.46,-4.15,-1.17,!0),C(_.hullLower,.45,.8,.9,-3.79,.45,4.6,{collide:!0,hullUV:!0}),C(_.metal,.5,.06,.95,-3.77,.88,4.6,{texel:1}),w(_.metalDark,.16,.2,.1,16,-3.74,.93,4.6,{open:!0}),w(_.metal,.02,.02,.25,8,-3.88,1.05,4.6,{rz:-.6}),C(_.mirror,.02,.7,.6,-3.96,1.55,4.6,{}),C(_.metalDark,.04,.78,.68,-3.985,1.55,4.6,{texel:1}),C(_.stripTeal,.03,.03,.6,-3.95,1.95,4.6,{}),C(_.hullLower,.5,.42,.42,-3.7,.21,3.1,{collide:!0,hullUV:!0}),w(_.plastic,.19,.21,.06,14,-3.7,.45,3.1,{}),C(_.hullLower,.16,.6,.5,-3.95,.72,3.1,{hullUV:!0}),C(_.stripTeal,.03,.04,.04,-3.865,.85,3.1,{}),C(_.rubber,.9,.04,.9,-1.85,.02,4.85,{}),w(_.metal,.07,.07,.04,12,-1.85,2.3,4.85,{}),w(_.metalDark,.02,.02,2.3,8,-1.45,1.15,4.95,{});{let e=new Bi(.04,2,.9);$.makeTranslation(-2.32,1,4.85),e.applyMatrix4($),s.add(_.glass,e),E(-2.36,0,4.4,-2.28,2,5.3)}C(_.stripTeal,.4,.02,.4,r,S-.04,4,{});let o=new ss(10479840,8,5.5,2);o.position.set(r,S-.3,4),n.add(o),a.push({light:o,day:8,night:2.8}),i.push({id:`bathroom`,prompt:`E: Freshen up`,center:new K(-3.65,.9,4.6),size:new K(.8,1.2,1.1)})}return s.build(n),e.add(n),{group:n,colliders:r,interactables:i,lights:a,emissives:o,mats:_}}var kd=new K(.55,.28,.79).normalize();function Ad(e,t,n=1.4){return new Co({uniforms:{map:{value:e},sunDir:{value:kd.clone()},rimColor:{value:new X(t)},rimStrength:{value:n}},vertexShader:` + varying vec2 vUv; + varying vec3 vNormalW; + varying vec3 vPosW; + void main() { + vUv = uv; + vNormalW = normalize(mat3(modelMatrix) * normal); + vec4 wp = modelMatrix * vec4(position, 1.0); + vPosW = wp.xyz; + gl_Position = projectionMatrix * viewMatrix * wp; + } + `,fragmentShader:` + uniform sampler2D map; + uniform vec3 sunDir; + uniform vec3 rimColor; + uniform float rimStrength; + varying vec2 vUv; + varying vec3 vNormalW; + varying vec3 vPosW; + void main() { + vec3 n = normalize(vNormalW); + vec3 viewDir = normalize(cameraPosition - vPosW); + vec3 tex = texture2D(map, vUv).rgb; + float d = clamp(dot(n, sunDir) * 1.15 + 0.18, 0.0, 1.0); + d = pow(d, 0.8); + vec3 col = tex * (d * 1.35 + 0.05); + float fres = pow(1.0 - clamp(dot(n, viewDir), 0.0, 1.0), 3.0); + col += rimColor * fres * rimStrength * (d * 0.85 + 0.15); + gl_FragColor = vec4(col, 1.0); + #include + } + `})}function jd(e,t=1){return new Co({uniforms:{atmColor:{value:new X(e)},sunDir:{value:kd.clone()},intensity:{value:t}},vertexShader:` + varying vec3 vNormalW; + varying vec3 vPosW; + void main() { + vNormalW = normalize(mat3(modelMatrix) * normal); + vec4 wp = modelMatrix * vec4(position, 1.0); + vPosW = wp.xyz; + gl_Position = projectionMatrix * viewMatrix * wp; + } + `,fragmentShader:` + uniform vec3 atmColor; + uniform vec3 sunDir; + uniform float intensity; + varying vec3 vNormalW; + varying vec3 vPosW; + void main() { + vec3 n = normalize(vNormalW); + vec3 viewDir = normalize(cameraPosition - vPosW); + float fres = 1.0 - clamp(dot(n, viewDir), 0.0, 1.0); + float a = pow(fres, 3.4); + float lit = clamp(dot(n, sunDir) * 1.2 + 0.25, 0.05, 1.0); + vec3 col = atmColor * a * intensity * lit; + gl_FragColor = vec4(col, a * lit); + #include + } + `,transparent:!0,blending:2,depthWrite:!1,side:0})}function Md(e,t){let n=new nn,r=_d(),i=[];for(let e of[{count:1300,box:700,size:3.4,speed:30,opacity:1},{count:700,box:900,size:2.4,speed:15,opacity:.85},{count:280,box:1200,size:1.7,speed:7,opacity:.7}]){let a=new Float32Array(e.count*3),o=new Float32Array(e.count*3),s=new X;for(let n=0;ni&&(r[t]-=i*2);t.geometry.attributes.position.needsUpdate=!0}{let t=s.geometry.attributes.position.array;for(let n=0;n180&&(t[n+2]-=360,t[n+5]-=360);s.geometry.attributes.position.needsUpdate=!0}{let e=Math.PI+t*(Math.PI*2/340);d.position.set(Math.cos(e)*980,-120,Math.sin(e)*980+40),l.rotation.y=t*.01}{let e=Math.PI*1.46+t*(Math.PI*2/480),n=1e3;h.position.set(Math.cos(e)*n,55,Math.sin(e)*n-120),p.rotation.y=t*.02}x.position.set(1550,90,-380+t*1.4)}return{root:n,update:w}}var Nd=1.7,Pd=.32,Fd=2.6,Id=26,Ld=class{constructor(e,t,n){this.camera=e,this.dom=t,this.colliders=n,this.position=new K(0,0,6),this.velocity=new K,this.yaw=Math.PI,this.pitch=0,this.keys=new Set,this.locked=!1,this.bobPhase=0,this.bobAmount=0,this.time=0,this.frozen=!1,this.eyeOverride=null,this.onLockChange=null,t.ownerDocument.addEventListener(`keydown`,e=>{this.keys.add(e.code)}),t.ownerDocument.addEventListener(`keyup`,e=>this.keys.delete(e.code)),t.ownerDocument.addEventListener(`pointerlockchange`,()=>{this.locked=document.pointerLockElement===t,this.onLockChange&&this.onLockChange(this.locked)}),t.ownerDocument.addEventListener(`mousemove`,e=>{!this.locked||this.frozen||Math.abs(e.movementX)>180||Math.abs(e.movementY)>180||(this.yaw-=e.movementX*.0023,this.pitch-=e.movementY*.0023,this.pitch=Math.max(-1.45,Math.min(1.45,this.pitch)))})}lock(){try{let e=this.dom.requestPointerLock({unadjustedMovement:!0});e&&typeof e.catch==`function`&&e.catch(()=>this.dom.requestPointerLock())}catch{this.dom.requestPointerLock()}}setPose(e,t,n){this.position.set(e.x,0,e.z),this.yaw=t,this.pitch=n,this.velocity.set(0,0,0)}update(e){if(this.time+=e,this.frozen){this.applyCamera(0);return}let t=0,n=0;this.keys.has(`KeyW`)&&--n,this.keys.has(`KeyS`)&&(n+=1),this.keys.has(`KeyA`)&&--t,this.keys.has(`KeyD`)&&(t+=1);let r=(t!==0||n!==0)&&this.locked,i=Math.sin(this.yaw),a=Math.cos(this.yaw),o=new G(t*a+n*i,-t*i+n*a);o.lengthSq()>0&&o.normalize().multiplyScalar(Fd);let s=this.velocity;s.x+=(o.x-s.x)*Math.min(1,Id*e*.4),s.z+=(o.y-s.z)*Math.min(1,Id*e*.4),r||(s.x*=1e-4**e,s.z*=1e-4**e),this.position.x+=s.x*e,this.position.z+=s.z*e,this.resolveCollisions();let c=Math.hypot(s.x,s.z),l=Math.min(1,c/Fd);this.bobAmount+=(l-this.bobAmount)*Math.min(1,8*e),this.bobPhase+=e*(6.5+c*1.6)*(this.bobAmount>.02),this.applyCamera(e)}applyCamera(e){let t=Math.sin(this.bobPhase*2)*.028*this.bobAmount,n=Math.sin(this.bobPhase)*.016*this.bobAmount,r=Math.sin(this.time*1.7)*.004,i=this.frozen?0:(Math.sin(this.time*31.7)+Math.sin(this.time*47.3))*9e-4,a=this.frozen&&this.eyeOverride!==null?this.eyeOverride:Nd;this.camera.position.set(this.position.x+n*Math.cos(this.yaw),a+(this.frozen?0:t+r+i),this.position.z-n*Math.sin(this.yaw)),this.camera.rotation.order=`YXZ`,this.camera.rotation.set(this.pitch,this.yaw,0)}resolveCollisions(){let e=this.position;for(let t=0;t<3;t++){let t=!1;for(let n of this.colliders){if(n.max.y<.25||n.min.y>1.75)continue;let r=n.min.x-Pd,i=n.max.x+Pd,a=n.min.z-Pd,o=n.max.z+Pd;if(e.x<=r||e.x>=i||e.z<=a||e.z>=o)continue;let s=e.x-r,c=i-e.x,l=e.z-a,u=o-e.z,d=Math.min(s,c,l,u);d===s?e.x=r:d===c?e.x=i:d===l?e.z=a:e.z=o,t=!0}if(!t)break}}},Rd=class{constructor(e,t,n){this.camera=t,this.ship=n,this.raycaster=new js,this.raycaster.far=3,this.center=new G(0,0),this.hovered=null,this.busy=!1,this.restCycle=!1,this.cycleT=1,this.cycleTarget=1,this.shipHours=14.533333333333333,this.lastMeal=`NOMINAL`,this.promptEl=document.getElementById(`prompt`),this.statusEl=document.getElementById(`status`),this.messageEl=document.getElementById(`message`),this.fadeEl=document.getElementById(`fade`),this.reticleEl=document.getElementById(`reticle`),this.statusNote=``,this.statusNoteUntil=0,this.time=0,this.targets=[];for(let t of n.interactables){let n=new Bi(t.size.x,t.size.y,t.size.z),r=new Jr(n,new Ir({color:16757866,transparent:!0,opacity:0,depthWrite:!1,side:2,blending:2}));r.position.copy(t.center),r.userData.interactable=t,e.add(r);let i=new Di(new Ki(n),new hi({color:16757866,transparent:!0,opacity:0}));i.position.copy(t.center),e.add(i),r.userData.edges=i,this.targets.push(r)}document.addEventListener(`keydown`,e=>{e.code===`KeyE`&&this.tryInteract()}),this.updateStatus()}fadeBlack(e,t,n=1300){this.busy=!0,this.fadeEl.classList.add(`on`),setTimeout(()=>{e&&e(),t&&(this.messageEl.textContent=t,this.messageEl.classList.add(`on`)),setTimeout(()=>{this.fadeEl.classList.remove(`on`),setTimeout(()=>{this.messageEl.classList.remove(`on`),this.busy=!1},900)},n)},750)}note(e,t=5){this.statusNote=e,this.statusNoteUntil=this.time+t,this.updateStatus()}tryInteract(){if(this.busy||!this.hovered)return;let e=this.hovered.userData.interactable.id;if(e===`bed`){let e=!this.restCycle;this.fadeBlack(()=>{this.restCycle=e,this.cycleTarget=+!e,this.shipHours=(this.shipHours+8)%24,this.note(e?`REST CYCLE ENGAGED`:`DAY CYCLE RESTORED`,6)},`8 HOURS PASS`)}else e===`galley`?(this.busy=!0,this.note(`YOU EAT. ENERGY RESTORED.`,6),this.messageEl.textContent=`ENERGY RESTORED`,this.messageEl.classList.add(`on`),setTimeout(()=>{this.messageEl.classList.remove(`on`),this.busy=!1},1400)):e===`bathroom`&&this.fadeBlack(()=>{this.note(`REFRESHED.`,6)},`REFRESHED`,900)}updateStatus(){let e=Math.floor(this.shipHours),t=Math.floor((this.shipHours-e)*60),n=`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`,r=this.restCycle?`REST CYCLE`:`CRUISE`,i=this.statusNote&&this.time${this.statusNote}`:``;this.statusEl.innerHTML=`MCV-7 DRIFTER · T+${n} · ${r}${i}`}update(e,t){this.time=t,this.shipHours=(this.shipHours+e/240)%24,this.cycleT+=(this.cycleTarget-this.cycleT)*Math.min(1,e*1.8);let n=this.cycleT;for(let e of this.ship.lights)e.light.intensity=e.night+(e.day-e.night)*n;for(let e of this.ship.emissives)e.mat.emissiveIntensity=e.night+(e.day-e.night)*n;this.raycaster.setFromCamera(this.center,this.camera);let r=this.raycaster.intersectObjects(this.targets,!1),i=r.length>0?r[0].object:null;if(i!==this.hovered&&(this.hovered&&(this.hovered.material.opacity=0,this.hovered.userData.edges.material.opacity=0),this.hovered=i,i?(this.promptEl.textContent=i.userData.interactable.prompt,this.promptEl.classList.add(`on`),this.reticleEl.classList.add(`hot`)):(this.promptEl.classList.remove(`on`),this.reticleEl.classList.remove(`hot`))),this.hovered){let e=.008+Math.sin(t*5)*.005;this.hovered.material.opacity=e,this.hovered.userData.edges.material.opacity=.4+Math.sin(t*5)*.15}(t*2|0)!=((t-e)*2|0)&&this.updateStatus()}},zd={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + uniform float opacity; + + uniform sampler2D tDiffuse; + + varying vec2 vUv; + + void main() { + + vec4 texel = texture2D( tDiffuse, vUv ); + gl_FragColor = opacity * texel; + + + }`},Bd=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},Vd=new cs(-1,1,1,-1,0,1),Hd=new class extends or{constructor(){super(),this.setAttribute(`position`,new Jn([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new Jn([0,2,0,0,2,0],2))}},Ud=class{constructor(e){this._mesh=new Jr(Hd,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Vd)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},Wd=class extends Bd{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Co?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=bo.clone(e.uniforms),this.material=new Co({name:e.name===void 0?`unspecified`:e.name,defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new Ud(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},Gd=class extends Bd{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),i=e.state;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),i.buffers.stencil.setClear(o),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}},Kd=class extends Bd{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},qd=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new G);this._width=n.width,this._height=n.height,t=new Et(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:g}),t.texture.name=`EffectComposer.rt1`}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name=`EffectComposer.rt2`,this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new Wd(zd),this.copyPass.material.blending=0,this.timer=new gs}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t + + varying vec2 vUv; + + uniform sampler2D colorTexture; + uniform vec2 invSize; + uniform vec2 direction; + uniform float gaussianCoefficients[KERNEL_RADIUS]; + + void main() { + + float weightSum = gaussianCoefficients[0]; + vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum; + + for ( int i = 1; i < KERNEL_RADIUS; i ++ ) { + + float x = float( i ); + float w = gaussianCoefficients[i]; + vec2 uvOffset = direction * invSize * x; + vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb; + vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb; + diffuseSum += ( sample1 + sample2 ) * w; + + } + + gl_FragColor = vec4( diffuseSum, 1.0 ); + + }`})}_getCompositeMaterial(e){return new Co({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + varying vec2 vUv; + + uniform sampler2D blurTexture1; + uniform sampler2D blurTexture2; + uniform sampler2D blurTexture3; + uniform sampler2D blurTexture4; + uniform sampler2D blurTexture5; + uniform float bloomStrength; + uniform float bloomRadius; + uniform float bloomFactors[NUM_MIPS]; + uniform vec3 bloomTintColors[NUM_MIPS]; + + float lerpBloomFactor( const in float factor ) { + + float mirrorFactor = 1.2 - factor; + return mix( factor, mirrorFactor, bloomRadius ); + + } + + void main() { + + // 3.0 for backwards compatibility with previous alpha-based intensity + vec3 bloom = 3.0 * bloomStrength * ( + lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb + + lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb + + lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb + + lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb + + lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb + ); + + float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) ); + gl_FragColor = vec4( bloom, bloomAlpha ); + + }`})}};Xd.BlurDirectionX=new G(1,0),Xd.BlurDirectionY=new G(0,1);var Zd={name:`OutputShader`,uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:` + precision highp float; + + uniform mat4 modelViewMatrix; + uniform mat4 projectionMatrix; + + attribute vec3 position; + attribute vec2 uv; + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + precision highp float; + + uniform sampler2D tDiffuse; + + #include + #include + + varying vec2 vUv; + + void main() { + + gl_FragColor = texture2D( tDiffuse, vUv ); + + // tone mapping + + #ifdef LINEAR_TONE_MAPPING + + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + + #elif defined( REINHARD_TONE_MAPPING ) + + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + + #elif defined( CINEON_TONE_MAPPING ) + + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + + #elif defined( ACES_FILMIC_TONE_MAPPING ) + + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + + #elif defined( AGX_TONE_MAPPING ) + + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + + #elif defined( NEUTRAL_TONE_MAPPING ) + + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + + #elif defined( CUSTOM_TONE_MAPPING ) + + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + + #endif + + // color space + + #ifdef SRGB_TRANSFER + + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + + #endif + + }`},Qd=class extends Bd{constructor(){super(),this.isOutputPass=!0,this.uniforms=bo.clone(Zd.uniforms),this.material=new wo({name:Zd.name,uniforms:this.uniforms,vertexShader:Zd.vertexShader,fragmentShader:Zd.fragmentShader}),this._fsQuad=new Ud(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},J.getTransfer(this._outputColorSpace)===`srgb`&&(this.material.defines.SRGB_TRANSFER=``),this._toneMapping===1?this.material.defines.LINEAR_TONE_MAPPING=``:this._toneMapping===2?this.material.defines.REINHARD_TONE_MAPPING=``:this._toneMapping===3?this.material.defines.CINEON_TONE_MAPPING=``:this._toneMapping===4?this.material.defines.ACES_FILMIC_TONE_MAPPING=``:this._toneMapping===6?this.material.defines.AGX_TONE_MAPPING=``:this._toneMapping===7?this.material.defines.NEUTRAL_TONE_MAPPING=``:this._toneMapping===5&&(this.material.defines.CUSTOM_TONE_MAPPING=``),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},$d=new class extends or{boundingSphere=new Qn;constructor(){super(),this.setAttribute(`position`,new Gn(new Float32Array([-1,-1,3,-1,-1,3]),2)),this.setAttribute(`uv`,new Gn(new Float32Array([0,0,2,0,0,2]),2))}computeBoundingSphere(){}},ef=new cs,tf=class{constructor(e){this._mesh=new Jr($d,e),this._mesh.frustumCulled=!1}render(e){e.render(this._mesh,ef)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}},nf={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new Y},viewMat:{value:new Y},projViewMat:{value:new Y},projectionMatrixInv:{value:new Y},viewMatrixInv:{value:new Y},cameraPos:{value:new K},resolution:{value:new G},biasAdjustment:{value:new G},time:{value:0},samples:{value:[]},bluenoise:{value:null},distanceFalloff:{value:1},radius:{value:5},near:{value:.1},far:{value:1e3},ortho:{value:!1},screenSpaceRadius:{value:!1},frame:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:` +varying vec2 vUv; +void main() { + vUv = uv; + gl_Position = vec4(position, 1); +}`,fragmentShader:` + #define SAMPLES 16 + #define FSAMPLES 16.0 +uniform sampler2D sceneDiffuse; +uniform highp sampler2D sceneNormal; +uniform highp sampler2D sceneDepth; +uniform mat4 projectionMatrixInv; +uniform mat4 viewMatrixInv; +uniform mat4 projMat; +uniform mat4 viewMat; +uniform mat4 projViewMat; +uniform vec3 cameraPos; +uniform vec2 resolution; +uniform vec2 biasAdjustment; +uniform float time; +uniform vec3[SAMPLES] samples; +uniform float radius; +uniform float distanceFalloff; +uniform float near; +uniform float far; +uniform float frame; +uniform bool ortho; +uniform bool screenSpaceRadius; +uniform sampler2D bluenoise; + varying vec2 vUv; + highp float linearize_depth(highp float d, highp float zNear,highp float zFar) + { + return (zFar * zNear) / (zFar - d * (zFar - zNear)); + } + highp float linearize_depth_ortho(highp float d, highp float nearZ, highp float farZ) { + return nearZ + (farZ - nearZ) * d; + } + highp float linearize_depth_log(highp float d, highp float nearZ,highp float farZ) { + float depth = pow(2.0, d * log2(farZ + 1.0)) - 1.0; + float a = farZ / (farZ - nearZ); + float b = farZ * nearZ / (nearZ - farZ); + float linDepth = a + b / depth; + /*return ortho ? linearize_depth_ortho( + linDepth, + nearZ, + farZ + ) :linearize_depth(linDepth, nearZ, farZ);*/ + #ifdef ORTHO + + return linearize_depth_ortho(d, nearZ, farZ); + + #else + return linearize_depth(linDepth, nearZ, farZ); + #endif + } + + vec3 getWorldPosLog(vec3 posS) { + vec2 uv = posS.xy; + float z = posS.z; + float nearZ =near; + float farZ = far; + float depth = pow(2.0, z * log2(farZ + 1.0)) - 1.0; + float a = farZ / (farZ - nearZ); + float b = farZ * nearZ / (nearZ - farZ); + float linDepth = a + b / depth; + vec4 clipVec = vec4(uv, linDepth, 1.0) * 2.0 - 1.0; + vec4 wpos = projectionMatrixInv * clipVec; + return wpos.xyz / wpos.w; + } + vec3 getWorldPos(float depth, vec2 coord) { + #ifdef LOGDEPTH + #ifndef ORTHO + return getWorldPosLog(vec3(coord, depth)); + #endif + #endif + float z = depth * 2.0 - 1.0; + vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0); + vec4 viewSpacePosition = projectionMatrixInv * clipSpacePosition; + // Perspective division + vec4 worldSpacePosition = viewSpacePosition; + worldSpacePosition.xyz /= worldSpacePosition.w; + return worldSpacePosition.xyz; + } + + vec3 computeNormal(vec3 worldPos, vec2 vUv) { + ivec2 p = ivec2(vUv * resolution); + #ifdef REVERSEDEPTH + float c0 = 1.0 - texelFetch(sceneDepth, p, 0).x; + float l2 = 1.0 - texelFetch(sceneDepth, p - ivec2(2, 0), 0).x; + float l1 = 1.0 - texelFetch(sceneDepth, p - ivec2(1, 0), 0).x; + float r1 = 1.0 - texelFetch(sceneDepth, p + ivec2(1, 0), 0).x; + float r2 = 1.0 - texelFetch(sceneDepth, p + ivec2(2, 0), 0).x; + float b2 = 1.0 - texelFetch(sceneDepth, p - ivec2(0, 2), 0).x; + float b1 = 1.0 - texelFetch(sceneDepth, p - ivec2(0, 1), 0).x; + float t1 = 1.0 - texelFetch(sceneDepth, p + ivec2(0, 1), 0).x; + float t2 = 1.0 - texelFetch(sceneDepth, p + ivec2(0, 2), 0).x; + #else + float c0 = texelFetch(sceneDepth, p, 0).x; + float l2 = texelFetch(sceneDepth, p - ivec2(2, 0), 0).x; + float l1 = texelFetch(sceneDepth, p - ivec2(1, 0), 0).x; + float r1 = texelFetch(sceneDepth, p + ivec2(1, 0), 0).x; + float r2 = texelFetch(sceneDepth, p + ivec2(2, 0), 0).x; + float b2 = texelFetch(sceneDepth, p - ivec2(0, 2), 0).x; + float b1 = texelFetch(sceneDepth, p - ivec2(0, 1), 0).x; + float t1 = texelFetch(sceneDepth, p + ivec2(0, 1), 0).x; + float t2 = texelFetch(sceneDepth, p + ivec2(0, 2), 0).x; + #endif + + float dl = abs((2.0 * l1 - l2) - c0); + float dr = abs((2.0 * r1 - r2) - c0); + float db = abs((2.0 * b1 - b2) - c0); + float dt = abs((2.0 * t1 - t2) - c0); + + vec3 ce = getWorldPos(c0, vUv).xyz; + + vec3 dpdx = (dl < dr) ? ce - getWorldPos(l1, (vUv - vec2(1.0 / resolution.x, 0.0))).xyz + : -ce + getWorldPos(r1, (vUv + vec2(1.0 / resolution.x, 0.0))).xyz; + vec3 dpdy = (db < dt) ? ce - getWorldPos(b1, (vUv - vec2(0.0, 1.0 / resolution.y))).xyz + : -ce + getWorldPos(t1, (vUv + vec2(0.0, 1.0 / resolution.y))).xyz; + + return normalize(cross(dpdx, dpdy)); +} + +mat3 makeRotationZ(float theta) { + float c = cos(theta); + float s = sin(theta); + return mat3(c, - s, 0, + s, c, 0, + 0, 0, 1); + } + +void main() { + vec4 diffuse = texture2D(sceneDiffuse, vUv); + #ifdef REVERSEDEPTH + float depth = 1.0 - texture2D(sceneDepth, vUv).x; + #else + float depth = texture2D(sceneDepth, vUv).x; + #endif + if (depth == 1.0) { + gl_FragColor = vec4(vec3(1.0), 1.0); + return; + } + vec3 worldPos = getWorldPos(depth, vUv); + #ifdef HALFRES + vec3 normal = texture2D(sceneNormal, vUv).rgb; + #else + vec3 normal = computeNormal(worldPos, vUv); + #endif + vec4 noise = texture2D(bluenoise, gl_FragCoord.xy / 128.0); + vec2 harmoniousNumbers = vec2( + 1.618033988749895, + 1.324717957244746 + ); + noise.rg += harmoniousNumbers * frame; + noise.rg = fract(noise.rg); + vec3 helperVec = vec3(0.0, 1.0, 0.0); + if (dot(helperVec, normal) > 0.99) { + helperVec = vec3(1.0, 0.0, 0.0); + } + vec3 tangent = normalize(cross(helperVec, normal)); + vec3 bitangent = cross(normal, tangent); + mediump mat3 tbn = mat3(tangent, bitangent, normal) * makeRotationZ( noise.r * 3.1415962 * 2.0) ; + + mediump float occluded = 0.0; + mediump float totalWeight = 0.0; + float radiusToUse = screenSpaceRadius ? distance( + worldPos, + getWorldPos(depth, vUv + + vec2(radius, 0.0) / resolution) + ) : radius; + float distanceFalloffToUse =screenSpaceRadius ? + radiusToUse * distanceFalloff + : radiusToUse * distanceFalloff * 0.2; + float bias = (min( + 0.1, + distanceFalloffToUse * 0.1 + ) / near) * fwidth(distance(worldPos, cameraPos)) / radiusToUse; + bias = biasAdjustment.x + biasAdjustment.y * bias; + mediump float offsetMove = noise.g; + mediump float offsetMoveInv = 1.0 / FSAMPLES; + float farTimesNear = far * near; + float farMinusNear = far - near; + + for(int i = 0; i < SAMPLES; i++) { + mediump vec3 sampleDirection = tbn * samples[i]; + + float moveAmt = fract(offsetMove); + offsetMove += offsetMoveInv; + vec3 samplePos = worldPos + radiusToUse * moveAmt * sampleDirection; + vec4 offset = projMat * vec4(samplePos, 1.0); + offset.xyz /= offset.w; + offset.xyz = offset.xyz * 0.5 + 0.5; + + if (all(greaterThan(offset.xyz * (1.0 - offset.xyz), vec3(0.0)))) { + #ifdef REVERSEDEPTH + float sampleDepth = 1.0 - textureLod(sceneDepth, offset.xy, 0.0).x; + #else + float sampleDepth = textureLod(sceneDepth, offset.xy, 0.0).x; + #endif + + /*#ifdef LOGDEPTH + float distSample = linearize_depth_log(sampleDepth, near, far); + #else + #ifdef ORTHO + float distSample = near + farMinusNear * sampleDepth; + #else + float distSample = (farTimesNear) / (far - sampleDepth * farMinusNear); + #endif + #endif*/ + #ifdef ORTHO + float distSample = near + sampleDepth * farMinusNear; + #else + #ifdef LOGDEPTH + float distSample = linearize_depth_log(sampleDepth, near, far); + #else + float distSample = (farTimesNear) / (far - sampleDepth * farMinusNear); + #endif + #endif + + #ifdef ORTHO + float distWorld = near + offset.z * farMinusNear; + #else + float distWorld = (farTimesNear) / (far - offset.z * farMinusNear); + #endif + + mediump float rangeCheck = smoothstep(0.0, 1.0, distanceFalloffToUse / (abs(distSample - distWorld))); + vec2 diff = gl_FragCoord.xy - floor(offset.xy * resolution); + occluded += rangeCheck * float(distSample != distWorld) * float(sampleDepth != depth) * step(distSample + bias, distWorld) * step( + 1.0, + dot(diff, diff) + ); + + totalWeight ++; + } + } + float occ = clamp(1.0 - occluded / (totalWeight == 0.0 ? 1.0 : totalWeight), 0.0, 1.0); + gl_FragColor = vec4(occ, 0.5 + 0.5 * normal); +}`},rf={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},tDiffuse:{value:null},transparencyDWFalse:{value:null},transparencyDWTrue:{value:null},transparencyDWTrueDepth:{value:null},transparencyAware:{value:!1},projMat:{value:new Y},viewMat:{value:new Y},projectionMatrixInv:{value:new Y},viewMatrixInv:{value:new Y},cameraPos:{value:new K},resolution:{value:new G},color:{value:new K(0,0,0)},blueNoise:{value:null},downsampledDepth:{value:null},time:{value:0},intensity:{value:10},renderMode:{value:0},gammaCorrection:{value:!1},ortho:{value:!1},near:{value:.1},far:{value:1e3},screenSpaceRadius:{value:!1},radius:{value:0},distanceFalloff:{value:1},fog:{value:!1},fogExp:{value:!1},fogDensity:{value:0},fogNear:{value:1/0},fogFar:{value:1/0},colorMultiply:{value:!0},aoTones:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:` + varying vec2 vUv; + void main() { + vUv = uv; + gl_Position = vec4(position, 1); + }`,fragmentShader:` + uniform sampler2D sceneDiffuse; + uniform highp sampler2D sceneDepth; + uniform highp sampler2D downsampledDepth; + uniform highp sampler2D transparencyDWFalse; + uniform highp sampler2D transparencyDWTrue; + uniform highp sampler2D transparencyDWTrueDepth; + uniform sampler2D tDiffuse; + uniform sampler2D blueNoise; + uniform vec2 resolution; + uniform vec3 color; + uniform mat4 projectionMatrixInv; + uniform mat4 viewMatrixInv; + uniform float intensity; + uniform float renderMode; + uniform float near; + uniform float far; + uniform float aoTones; + uniform bool gammaCorrection; + uniform bool ortho; + uniform bool screenSpaceRadius; + uniform bool fog; + uniform bool fogExp; + uniform bool colorMultiply; + uniform bool transparencyAware; + uniform float fogDensity; + uniform float fogNear; + uniform float fogFar; + uniform float radius; + uniform float distanceFalloff; + uniform vec3 cameraPos; + varying vec2 vUv; + highp float linearize_depth(highp float d, highp float zNear,highp float zFar) + { + return (zFar * zNear) / (zFar - d * (zFar - zNear)); + } + highp float linearize_depth_ortho(highp float d, highp float nearZ, highp float farZ) { + return nearZ + (farZ - nearZ) * d; + } + highp float linearize_depth_log(highp float d, highp float nearZ,highp float farZ) { + float depth = pow(2.0, d * log2(farZ + 1.0)) - 1.0; + float a = farZ / (farZ - nearZ); + float b = farZ * nearZ / (nearZ - farZ); + float linDepth = a + b / depth; + return ortho ? linearize_depth_ortho( + linDepth, + nearZ, + farZ + ) :linearize_depth(linDepth, nearZ, farZ); + } + vec3 getWorldPosLog(vec3 posS) { + vec2 uv = posS.xy; + float z = posS.z; + float nearZ =near; + float farZ = far; + float depth = pow(2.0, z * log2(farZ + 1.0)) - 1.0; + float a = farZ / (farZ - nearZ); + float b = farZ * nearZ / (nearZ - farZ); + float linDepth = a + b / depth; + vec4 clipVec = vec4(uv, linDepth, 1.0) * 2.0 - 1.0; + vec4 wpos = projectionMatrixInv * clipVec; + return wpos.xyz / wpos.w; + } + vec3 getWorldPos(float depth, vec2 coord) { + #ifdef LOGDEPTH + #ifndef ORTHO + return getWorldPosLog(vec3(coord, depth)); + #endif + #endif + // } + float z = depth * 2.0 - 1.0; + vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0); + vec4 viewSpacePosition = projectionMatrixInv * clipSpacePosition; + // Perspective division + vec4 worldSpacePosition = viewSpacePosition; + worldSpacePosition.xyz /= worldSpacePosition.w; + return worldSpacePosition.xyz; + } + + vec3 computeNormal(vec3 worldPos, vec2 vUv) { + ivec2 p = ivec2(vUv * resolution); + #ifdef REVERSEDEPTH + float c0 = 1.0 - texelFetch(sceneDepth, p, 0).x; + float l2 = 1.0 - texelFetch(sceneDepth, p - ivec2(2, 0), 0).x; + float l1 = 1.0 - texelFetch(sceneDepth, p - ivec2(1, 0), 0).x; + float r1 = 1.0 - texelFetch(sceneDepth, p + ivec2(1, 0), 0).x; + float r2 = 1.0 - texelFetch(sceneDepth, p + ivec2(2, 0), 0).x; + float b2 = 1.0 - texelFetch(sceneDepth, p - ivec2(0, 2), 0).x; + float b1 = 1.0 - texelFetch(sceneDepth, p - ivec2(0, 1), 0).x; + float t1 = 1.0 - texelFetch(sceneDepth, p + ivec2(0, 1), 0).x; + float t2 = 1.0 - texelFetch(sceneDepth, p + ivec2(0, 2), 0).x; + #else + float c0 = texelFetch(sceneDepth, p, 0).x; + float l2 = texelFetch(sceneDepth, p - ivec2(2, 0), 0).x; + float l1 = texelFetch(sceneDepth, p - ivec2(1, 0), 0).x; + float r1 = texelFetch(sceneDepth, p + ivec2(1, 0), 0).x; + float r2 = texelFetch(sceneDepth, p + ivec2(2, 0), 0).x; + float b2 = texelFetch(sceneDepth, p - ivec2(0, 2), 0).x; + float b1 = texelFetch(sceneDepth, p - ivec2(0, 1), 0).x; + float t1 = texelFetch(sceneDepth, p + ivec2(0, 1), 0).x; + float t2 = texelFetch(sceneDepth, p + ivec2(0, 2), 0).x; + #endif + + float dl = abs((2.0 * l1 - l2) - c0); + float dr = abs((2.0 * r1 - r2) - c0); + float db = abs((2.0 * b1 - b2) - c0); + float dt = abs((2.0 * t1 - t2) - c0); + + vec3 ce = getWorldPos(c0, vUv).xyz; + + vec3 dpdx = (dl < dr) ? ce - getWorldPos(l1, (vUv - vec2(1.0 / resolution.x, 0.0))).xyz + : -ce + getWorldPos(r1, (vUv + vec2(1.0 / resolution.x, 0.0))).xyz; + vec3 dpdy = (db < dt) ? ce - getWorldPos(b1, (vUv - vec2(0.0, 1.0 / resolution.y))).xyz + : -ce + getWorldPos(t1, (vUv + vec2(0.0, 1.0 / resolution.y))).xyz; + + return normalize(cross(dpdx, dpdy)); + } + + #include + #include + void main() { + //vec4 texel = texture2D(tDiffuse, vUv);//vec3(0.0); + vec4 sceneTexel = texture2D(sceneDiffuse, vUv); + #ifdef REVERSEDEPTH + float depth = 1.0 - texture2D(sceneDepth, vUv).x; + #else + float depth = texture2D(sceneDepth, vUv).x; + #endif + #ifdef HALFRES + vec4 texel; + if (depth == 1.0) { + texel = vec4(0.0, 0.0, 0.0, 1.0); + } else { + vec3 worldPos = getWorldPos(depth, vUv); + vec3 normal = computeNormal(getWorldPos(depth, vUv), vUv); + // vec4 texel = texture2D(tDiffuse, vUv); + // Find closest depth; + float totalWeight = 0.0; + float radiusToUse = screenSpaceRadius ? distance( + worldPos, + getWorldPos(depth, vUv + + vec2(radius, 0.0) / resolution) + ) : radius; + float distanceFalloffToUse =screenSpaceRadius ? + radiusToUse * distanceFalloff + : distanceFalloff; + for(float x = -1.0; x <= 1.0; x++) { + for(float y = -1.0; y <= 1.0; y++) { + vec2 offset = vec2(x, y); + ivec2 p = ivec2( + (vUv * resolution * 0.5) + offset + ); + vec2 pUv = vec2(p) / (resolution * 0.5); + float sampleDepth = texelFetch(downsampledDepth,p, 0).x; + vec4 sampleInfo = texelFetch(tDiffuse, p, 0); + vec3 normalSample = sampleInfo.gba * 2.0 - 1.0; + vec3 worldPosSample = getWorldPos(sampleDepth, pUv); + float tangentPlaneDist = abs(dot(worldPosSample - worldPos, normal)); + float rangeCheck = exp(-1.0 * tangentPlaneDist * (1.0 / distanceFalloffToUse)) * max(dot(normal, normalSample), 0.0); + float weight = rangeCheck; + totalWeight += weight; + texel += sampleInfo * weight; + } + } + if (totalWeight == 0.0) { + texel = texture2D(tDiffuse, vUv); + } else { + texel /= totalWeight; + } + } + #else + vec4 texel = texture2D(tDiffuse, vUv); + #endif + + #ifdef LOGDEPTH + texel.r = clamp(texel.r, 0.0, 1.0); + if (texel.r == 0.0) { + texel.r = 1.0; + } + #endif + + float finalAo = pow(texel.r, intensity); + if (aoTones > 0.0) { + finalAo = ceil(finalAo * aoTones) / aoTones; + } + float fogFactor; + float fogDepth = distance( + cameraPos, + getWorldPos(depth, vUv) + ); + if (fog) { + if (fogExp) { + fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth ); + } else { + fogFactor = smoothstep( fogNear, fogFar, fogDepth ); + } + } + if (transparencyAware) { + float transparencyDWOff = texture2D(transparencyDWFalse, vUv).a; + float transparencyDWOn = texture2D(transparencyDWTrue, vUv).a; + float adjustmentFactorOff = transparencyDWOff; + #ifdef REVERSEDEPTH + float depthSample = 1.0 - texture2D(sceneDepth, vUv).r; + float trueDepthSample = 1.0 - texture2D(transparencyDWTrueDepth, vUv).r; + #else + float depthSample = texture2D(sceneDepth, vUv).r; + float trueDepthSample = texture2D(transparencyDWTrueDepth, vUv).r; + #endif + float adjustmentFactorOn = (1.0 - transparencyDWOn) * ( + trueDepthSample == depthSample ? 1.0 : 0.0 + ); + float adjustmentFactor = max(adjustmentFactorOff, adjustmentFactorOn); + finalAo = mix(finalAo, 1.0, adjustmentFactor); + } + finalAo = mix(finalAo, 1.0, fogFactor); + vec3 aoApplied = color * mix(vec3(1.0), sceneTexel.rgb, float(colorMultiply)); + if (renderMode == 0.0) { + gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a); + } else if (renderMode == 1.0) { + gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a); + } else if (renderMode == 2.0) { + gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a); + } else if (renderMode == 3.0) { + if (vUv.x < 0.5) { + gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a); + } else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) { + gl_FragColor = vec4(1.0); + } else { + gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a); + } + } else if (renderMode == 4.0) { + if (vUv.x < 0.5) { + gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a); + } else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) { + gl_FragColor = vec4(1.0); + } else { + gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a); + } + } + #include + if (gammaCorrection) { + gl_FragColor = sRGBTransferOETF(gl_FragColor); + } + } + `},af={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},tDiffuse:{value:null},projMat:{value:new Y},viewMat:{value:new Y},projectionMatrixInv:{value:new Y},viewMatrixInv:{value:new Y},cameraPos:{value:new K},resolution:{value:new G},time:{value:0},r:{value:5},blueNoise:{value:null},radius:{value:12},worldRadius:{value:5},index:{value:0},poissonDisk:{value:[]},distanceFalloff:{value:1},near:{value:.1},far:{value:1e3},screenSpaceRadius:{value:!1}},depthWrite:!1,depthTest:!1,vertexShader:` + varying vec2 vUv; + void main() { + vUv = uv; + gl_Position = vec4(position, 1.0); + }`,fragmentShader:` + uniform sampler2D sceneDiffuse; + uniform highp sampler2D sceneDepth; + uniform sampler2D tDiffuse; + uniform sampler2D blueNoise; + uniform mat4 projectionMatrixInv; + uniform mat4 viewMatrixInv; + uniform vec2 resolution; + uniform float r; + uniform float radius; + uniform float worldRadius; + uniform float index; + uniform float near; + uniform float far; + uniform float distanceFalloff; + uniform bool screenSpaceRadius; + varying vec2 vUv; + + highp float linearize_depth(highp float d, highp float zNear,highp float zFar) + { + highp float z_n = 2.0 * d - 1.0; + return 2.0 * zNear * zFar / (zFar + zNear - z_n * (zFar - zNear)); + } + highp float linearize_depth_log(highp float d, highp float nearZ,highp float farZ) { + float depth = pow(2.0, d * log2(farZ + 1.0)) - 1.0; + float a = farZ / (farZ - nearZ); + float b = farZ * nearZ / (nearZ - farZ); + float linDepth = a + b / depth; + return linearize_depth(linDepth, nearZ, farZ); + } + highp float linearize_depth_ortho(highp float d, highp float nearZ, highp float farZ) { + return nearZ + (farZ - nearZ) * d; + } + vec3 getWorldPosLog(vec3 posS) { + vec2 uv = posS.xy; + float z = posS.z; + float nearZ =near; + float farZ = far; + float depth = pow(2.0, z * log2(farZ + 1.0)) - 1.0; + float a = farZ / (farZ - nearZ); + float b = farZ * nearZ / (nearZ - farZ); + float linDepth = a + b / depth; + vec4 clipVec = vec4(uv, linDepth, 1.0) * 2.0 - 1.0; + vec4 wpos = projectionMatrixInv * clipVec; + return wpos.xyz / wpos.w; + } + vec3 getWorldPos(float depth, vec2 coord) { + #ifdef LOGDEPTH + #ifndef ORTHO + return getWorldPosLog(vec3(coord, depth)); + #endif + #endif + + float z = depth * 2.0 - 1.0; + vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0); + vec4 viewSpacePosition = projectionMatrixInv * clipSpacePosition; + // Perspective division + vec4 worldSpacePosition = viewSpacePosition; + worldSpacePosition.xyz /= worldSpacePosition.w; + return worldSpacePosition.xyz; + } + #include + #define NUM_SAMPLES 16 + uniform vec2 poissonDisk[NUM_SAMPLES]; + void main() { + const float pi = 3.14159; + vec2 texelSize = vec2(1.0 / resolution.x, 1.0 / resolution.y); + vec2 uv = vUv; + vec4 data = texture2D(tDiffuse, vUv); + float occlusion = data.r; + float baseOcc = data.r; + vec3 normal = data.gba * 2.0 - 1.0; + float count = 1.0; + float d = texture2D(sceneDepth, vUv).x; + if (d == 1.0) { + gl_FragColor = data; + return; + } + vec3 worldPos = getWorldPos(d, vUv); + float size = radius; + float angle; + if (index == 0.0) { + angle = texture2D(blueNoise, gl_FragCoord.xy / 128.0).w * PI2; + } else if (index == 1.0) { + angle = texture2D(blueNoise, gl_FragCoord.xy / 128.0).z * PI2; + } else if (index == 2.0) { + angle = texture2D(blueNoise, gl_FragCoord.xy / 128.0).y * PI2; + } else { + angle = texture2D(blueNoise, gl_FragCoord.xy / 128.0).x * PI2; + } + + mat2 rotationMatrix = mat2(cos(angle), -sin(angle), sin(angle), cos(angle)); + float radiusToUse = screenSpaceRadius ? distance( + worldPos, + getWorldPos(d, vUv + + vec2(worldRadius, 0.0) / resolution) + ) : worldRadius; + float distanceFalloffToUse =screenSpaceRadius ? + radiusToUse * distanceFalloff + : radiusToUse * distanceFalloff * 0.2; + + float invDistance = (1.0 / distanceFalloffToUse); + for(int i = 0; i < NUM_SAMPLES; i++) { + vec2 offset = (rotationMatrix * poissonDisk[i]) * texelSize * size; + vec4 dataSample = texture2D(tDiffuse, uv + offset); + float occSample = dataSample.r; + vec3 normalSample = dataSample.gba * 2.0 - 1.0; + float dSample = texture2D(sceneDepth, uv + offset).x; + vec3 worldPosSample = getWorldPos(dSample, uv + offset); + float tangentPlaneDist = abs(dot(worldPosSample - worldPos, normal)); + float rangeCheck = float(dSample != 1.0) * exp(-1.0 * tangentPlaneDist * invDistance ) * max(dot(normal, normalSample), 0.0); + occlusion += occSample * rangeCheck; + count += rangeCheck; + } + if (count > 0.0) { + occlusion /= count; + } + occlusion = clamp(occlusion, 0.0, 1.0); + if (occlusion == 0.0) { + occlusion = 1.0; + } + gl_FragColor = vec4(occlusion, 0.5 + 0.5 * normal); + } + `},of={uniforms:{sceneDepth:{value:null},resolution:{value:new G},near:{value:.1},far:{value:1e3},viewMatrixInv:{value:new Y},projectionMatrixInv:{value:new Y},logDepth:{value:!1},ortho:{value:!1}},depthWrite:!1,depthTest:!1,vertexShader:` + varying vec2 vUv; + void main() { + vUv = uv; + gl_Position = vec4(position, 1); + }`,fragmentShader:` + uniform highp sampler2D sceneDepth; + uniform vec2 resolution; + uniform float near; + uniform float far; + uniform bool logDepth; + uniform bool ortho; + uniform mat4 viewMatrixInv; + uniform mat4 projectionMatrixInv; + varying vec2 vUv; + layout(location = 1) out vec4 gNormal; + vec3 getWorldPosLog(vec3 posS) { + vec2 uv = posS.xy; + float z = posS.z; + float nearZ =near; + float farZ = far; + float depth = pow(2.0, z * log2(farZ + 1.0)) - 1.0; + float a = farZ / (farZ - nearZ); + float b = farZ * nearZ / (nearZ - farZ); + float linDepth = a + b / depth; + vec4 clipVec = vec4(uv, linDepth, 1.0) * 2.0 - 1.0; + vec4 wpos = projectionMatrixInv * clipVec; + return wpos.xyz / wpos.w; + } + vec3 getWorldPos(float depth, vec2 coord) { + if (logDepth && !ortho) { + return getWorldPosLog(vec3(coord, depth)); + } + float z = depth * 2.0 - 1.0; + vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0); + vec4 viewSpacePosition = projectionMatrixInv * clipSpacePosition; + // Perspective division + vec4 worldSpacePosition = viewSpacePosition; + worldSpacePosition.xyz /= worldSpacePosition.w; + return worldSpacePosition.xyz; + } + + vec3 computeNormal(vec3 worldPos, vec2 vUv) { + ivec2 p = ivec2(vUv * resolution); + #ifdef REVERSEDEPTH + float c0 = 1.0 - texelFetch(sceneDepth, p, 0).x; + float l2 = 1.0 - texelFetch(sceneDepth, p - ivec2(2, 0), 0).x; + float l1 = 1.0 - texelFetch(sceneDepth, p - ivec2(1, 0), 0).x; + float r1 = 1.0 - texelFetch(sceneDepth, p + ivec2(1, 0), 0).x; + float r2 = 1.0 - texelFetch(sceneDepth, p + ivec2(2, 0), 0).x; + float b2 = 1.0 - texelFetch(sceneDepth, p - ivec2(0, 2), 0).x; + float b1 = 1.0 - texelFetch(sceneDepth, p - ivec2(0, 1), 0).x; + float t1 = 1.0 - texelFetch(sceneDepth, p + ivec2(0, 1), 0).x; + float t2 = 1.0 - texelFetch(sceneDepth, p + ivec2(0, 2), 0).x; + #else + float c0 = texelFetch(sceneDepth, p, 0).x; + float l2 = texelFetch(sceneDepth, p - ivec2(2, 0), 0).x; + float l1 = texelFetch(sceneDepth, p - ivec2(1, 0), 0).x; + float r1 = texelFetch(sceneDepth, p + ivec2(1, 0), 0).x; + float r2 = texelFetch(sceneDepth, p + ivec2(2, 0), 0).x; + float b2 = texelFetch(sceneDepth, p - ivec2(0, 2), 0).x; + float b1 = texelFetch(sceneDepth, p - ivec2(0, 1), 0).x; + float t1 = texelFetch(sceneDepth, p + ivec2(0, 1), 0).x; + float t2 = texelFetch(sceneDepth, p + ivec2(0, 2), 0).x; + #endif + + float dl = abs((2.0 * l1 - l2) - c0); + float dr = abs((2.0 * r1 - r2) - c0); + float db = abs((2.0 * b1 - b2) - c0); + float dt = abs((2.0 * t1 - t2) - c0); + + vec3 ce = getWorldPos(c0, vUv).xyz; + + vec3 dpdx = (dl < dr) ? ce - getWorldPos(l1, (vUv - vec2(1.0 / resolution.x, 0.0))).xyz + : -ce + getWorldPos(r1, (vUv + vec2(1.0 / resolution.x, 0.0))).xyz; + vec3 dpdy = (db < dt) ? ce - getWorldPos(b1, (vUv - vec2(0.0, 1.0 / resolution.y))).xyz + : -ce + getWorldPos(t1, (vUv + vec2(0.0, 1.0 / resolution.y))).xyz; + + return normalize(cross(dpdx, dpdy)); + } + void main() { + vec2 uv = vUv - vec2(0.5) / resolution; + vec2 pixelSize = vec2(1.0) / resolution; + highp vec2[4] uvSamples; + uvSamples[0] = uv; + uvSamples[1] = uv + vec2(pixelSize.x, 0.0); + uvSamples[2] = uv + vec2(0.0, pixelSize.y); + uvSamples[3] = uv + pixelSize; + #ifdef REVERSEDEPTH + float depth00 = 1.0 - texture2D(sceneDepth, uvSamples[0]).r; + float depth10 = 1.0 - texture2D(sceneDepth, uvSamples[1]).r; + float depth01 = 1.0 - texture2D(sceneDepth, uvSamples[2]).r; + float depth11 = 1.0 - texture2D(sceneDepth, uvSamples[3]).r; + #else + float depth00 = texture2D(sceneDepth, uvSamples[0]).r; + float depth10 = texture2D(sceneDepth, uvSamples[1]).r; + float depth01 = texture2D(sceneDepth, uvSamples[2]).r; + float depth11 = texture2D(sceneDepth, uvSamples[3]).r; + #endif + float minDepth = min(min(depth00, depth10), min(depth01, depth11)); + float maxDepth = max(max(depth00, depth10), max(depth01, depth11)); + float targetDepth = minDepth; + // Checkerboard pattern to avoid artifacts + if (mod(gl_FragCoord.x + gl_FragCoord.y, 2.0) > 0.5) { + targetDepth = maxDepth; + } + int chosenIndex = 0; + float[4] samples; + samples[0] = depth00; + samples[1] = depth10; + samples[2] = depth01; + samples[3] = depth11; + for(int i = 0; i < 4; ++i) { + if (samples[i] == targetDepth) { + chosenIndex = i; + break; + } + } + gl_FragColor = vec4(samples[chosenIndex], 0.0, 0.0, 1.0); + gNormal = vec4(computeNormal( + getWorldPos(samples[chosenIndex], uvSamples[chosenIndex]), uvSamples[chosenIndex] + ), 0.0); + }`},sf=Uint8Array.from(atob(`5L7pP4UXrOIr/VZ1G3f6p89FIWU7lqc7J3DPxKjJUXODJoHQzf/aNVM+ABlvhXeBGN7iC0WkmTjEaAqOItB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wf3MvqUv35r2jTKvpPWBUWNm5fytX/QJwp6qkIOsSx7Y67BSCbCDVLM8/VcMG+T0j+INrgL9sfT1ICtACH8BI0G6ViUZPVzzCmQHW2oVIwZjAoFl6+meO/pD8teO1E+1y03mCpYfW9S8qhtH2GhlFlebPf4NbezVv9xbXKWz0xezRNQWqUqtYRTUbuzK7KTvjG4rQHfzBpVmK4wDLnSIwdSzTSk1fPNeY0WOpPZTLlvQ59xwgfFrb326vT2hS1JAZ9E6sujFtKTiJ7bxI6o4cBhDaX+adXREThhR+MwA4TqD7rga/o9iY7d6TVRe14CS2S3iSQsD0R6ApnhG/2Wa0A0AY2NtWTjmabdKU+KgIRDP9RQYVjXiF1qC+xyNVG03I9vpmEpY/G/zC4nLOKgXAZ/uTikHI9Afbkhfgfgo9arWbix5eH7WUo9RQygDzwCnVSjbXc7MihEufVj6WGbK963pw8VjY3RS8IH1cy2yZbIcKLO5CgAUcXJfF2+McnDLKtXxyZaf7SPA6KJq+zF2NHyfoeTOwHhGqNcnHVr1hT73pcoyXyfvCYBnG1Bp/aR9t8hoI7CXM3UZOisWGA1SHZ2jf7k9GlRnp3mF/c1AV+JjvUsnZrsybEOQJg/dn/9eJkyykQHjbF56zgcPX6DdMG03WKUMlYz+uOZ+5DZy9E9MZOZ9GMoLFdrIPPQQLjv+GlCMpoyHPXkzIODjHAID2PrnaRpqWVHh0rnieDILKq+Emrd5RnjgE9pDUXWTmHaKuqqYlcgEz4zbi46dbWrAAFBjsQq1rLHIiPJEcwFLCOY4JNlXRXQJqCUKXk2d1RSBGzDP6HDSpo863BhVRFFF6uIpjQV7j5ebFe3UkkO/+coIo2BTAcgBqOtQ134s9a4QJvofuqBYMGOBMsWZ+sn/2AOxDx6SfAnDFGw==`),e=>e.charCodeAt(0)),cf=parseInt(`184`.replace(/\D+/g,``))>=162?class extends Et{constructor(e=1,t=1,n=1,r={}){super(e,t,{...r,count:n}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}:class extends Et{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGLMultipleRenderTargets=!0;let i=this.texture;this.texture=[];for(let e=0;e{lf(e,t,n)},1)}var uf={Default:1,Log:2,Reverse:3},df=class extends Bd{constructor(t,n,i=512,a=512){super(),this.width=i,this.height=a,this.clear=!0,this.camera=n,this.scene=t,this.configuration=new Proxy({aoSamples:16,aoRadius:5,aoTones:0,denoiseSamples:8,denoiseRadius:12,distanceFalloff:1,intensity:5,denoiseIterations:2,renderMode:0,biasOffset:0,biasMultiplier:0,color:new X(0,0,0),gammaCorrection:!0,depthBufferType:uf.Default,screenSpaceRadius:!1,halfRes:!1,depthAwareUpsampling:!0,autoRenderBeauty:!0,colorMultiply:!0,transparencyAware:!1,stencil:!1,accumulate:!1},{set:(e,t,n)=>{let i=e[t];return e[t]=n,n.equals?n.equals(i)||this.firstFrame():i!==n&&this.firstFrame(),t===`aoSamples`&&i!==n&&this.configureAOPass(this.configuration.depthBufferType,this.camera.isOrthographicCamera),t===`denoiseSamples`&&i!==n&&this.configureDenoisePass(this.configuration.depthBufferType,this.camera.isOrthographicCamera),t===`halfRes`&&i!==n&&(this.configureAOPass(this.configuration.depthBufferType,this.camera.isOrthographicCamera),this.configureHalfResTargets(),this.configureEffectCompositer(this.configuration.depthBufferType,this.camera.isOrthographicCamera),this.setSize(this.width,this.height)),t===`depthAwareUpsampling`&&i!==n&&this.configureEffectCompositer(this.configuration.depthBufferType,this.camera.isOrthographicCamera),t===`transparencyAware`&&i!==n&&(this.autoDetectTransparency=!1,this.configureTransparencyTarget()),t===`stencil`&&i!==n&&(this.beautyRenderTarget.dispose(),this.beautyRenderTarget=new Et(this.width,this.height,{minFilter:o,magFilter:r,type:g,format:w,stencilBuffer:n}),this.beautyRenderTarget.depthTexture=new Li(this.width,this.height,n?y:m),this.beautyRenderTarget.depthTexture.format=n?E:T),!0}}),this.samples=[],this.samplesDenoise=[],this.autoDetectTransparency=!0,this.frame=0,this.lastViewMatrix=new Y,this.lastProjectionMatrix=new Y,this.beautyRenderTarget=new Et(this.width,this.height,{minFilter:o,magFilter:r,type:g,format:w,stencilBuffer:!1}),this.beautyRenderTarget.depthTexture=new Li(this.width,this.height,m),this.beautyRenderTarget.depthTexture.format=T,this.configureEffectCompositer(this.configuration.depthBufferType,this.camera.isOrthographicCamera),this.configureSampleDependentPasses(),this.configureHalfResTargets(),this.detectTransparency(),this.configureTransparencyTarget(),this.writeTargetInternal=new Et(this.width,this.height,{minFilter:o,magFilter:o,depthBuffer:!1,format:w}),this.readTargetInternal=new Et(this.width,this.height,{minFilter:o,magFilter:o,depthBuffer:!1,format:w}),this.accumulationRenderTarget=new Et(this.width,this.height,{minFilter:o,magFilter:o,depthBuffer:!1,format:w,type:g,stencilBuffer:!1,depthBuffer:!1,alpha:!0}),this.bluenoise=new Zr(sf,128,128),this.accumulationQuad=new tf(new Co({uniforms:{frame:{value:0},tDiffuse:{value:null}},transparent:!0,opacity:1,vertexShader:` + varying vec2 vUv; + void main() { + vUv = uv; + gl_Position = vec4(position, 1); + }`,fragmentShader:` + uniform sampler2D tDiffuse; + uniform float frame; + varying vec2 vUv; + void main() { + vec4 color = texture2D(tDiffuse, vUv); + gl_FragColor = vec4(color.rgb, 1.0 / (frame + 1.0)); + } + `})),this.bluenoise.colorSpace=``,this.bluenoise.wrapS=e,this.bluenoise.wrapT=e,this.bluenoise.minFilter=r,this.bluenoise.magFilter=r,this.bluenoise.needsUpdate=!0,this.lastTime=0,this.timeRollingAverage=.99,this._r=new G,this._c=new X}configureHalfResTargets(){if(this.firstFrame(),this.configuration.halfRes){this.depthDownsampleTarget=new cf(this.width/2,this.height/2,2),this.depthDownsampleTarget.textures[0].format=D,this.depthDownsampleTarget.textures[0].type=h,this.depthDownsampleTarget.textures[0].minFilter=r,this.depthDownsampleTarget.textures[0].magFilter=r,this.depthDownsampleTarget.textures[0].depthBuffer=!1,this.depthDownsampleTarget.textures[1].format=w,this.depthDownsampleTarget.textures[1].type=g,this.depthDownsampleTarget.textures[1].minFilter=r,this.depthDownsampleTarget.textures[1].magFilter=r,this.depthDownsampleTarget.textures[1].depthBuffer=!1;let e={...of};this.configuration.depthBufferType===uf.Reverse&&(e.fragmentShader=`#define REVERSEDEPTH +`+e.fragmentShader),this.depthDownsampleQuad=new tf(new Co(e))}else this.depthDownsampleTarget&&=(this.depthDownsampleTarget.dispose(),null),this.depthDownsampleQuad&&=(this.depthDownsampleQuad.dispose(),null)}detectTransparency(){if(this.autoDetectTransparency){let e=!1;this.scene.traverse(t=>{t.material&&t.material.transparent&&(e=!0)}),this.configuration.transparencyAware=e}}configureTransparencyTarget(){this.configuration.transparencyAware?(this.transparencyRenderTargetDWFalse=new Et(this.width,this.height,{minFilter:o,magFilter:r,type:g,format:w}),this.transparencyRenderTargetDWTrue=new Et(this.width,this.height,{minFilter:o,magFilter:r,type:g,format:w}),this.transparencyRenderTargetDWTrue.depthTexture=new Li(this.width,this.height,m),this.depthCopyPass=new tf(new Co({uniforms:{depthTexture:{value:this.depthTexture},reverseDepthBuffer:{value:this.configuration.depthBufferType===uf.Reverse}},vertexShader:` + varying vec2 vUv; + void main() { + vUv = uv; + gl_Position = vec4(position, 1); + }`,fragmentShader:` + uniform sampler2D depthTexture; + uniform bool reverseDepthBuffer; + varying vec2 vUv; + void main() { + if (reverseDepthBuffer) { + float d = 1.0 - texture2D(depthTexture, vUv).r; + + d += 0.00001; + gl_FragDepth = 1.0 - d; + } else { + float d = texture2D(depthTexture, vUv).r; + d += 0.00001; + gl_FragDepth = d; + } + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); + } + `}))):(this.transparencyRenderTargetDWFalse&&=(this.transparencyRenderTargetDWFalse.dispose(),null),this.transparencyRenderTargetDWTrue&&=(this.transparencyRenderTargetDWTrue.dispose(),null),this.depthCopyPass&&=(this.depthCopyPass.dispose(),null))}renderTransparency(e){let t=this.scene.background,n=e.getClearColor(new X),r=e.getClearAlpha(),i=new Map,a=e.autoClearDepth;this.scene.traverse(e=>{i.set(e,e.visible)}),this.scene.background=null,e.autoClearDepth=!1,e.setClearColor(new X(0,0,0),0),this.depthCopyPass.material.uniforms.depthTexture.value=this.beautyRenderTarget.depthTexture,this.depthCopyPass.material.uniforms.reverseDepthBuffer.value=this.configuration.depthBufferType===uf.Reverse,e.setRenderTarget(this.transparencyRenderTargetDWFalse),this.scene.traverse(e=>{e.material&&(e.visible=i.get(e)&&(e.material.transparent&&!e.material.depthWrite&&!e.userData.treatAsOpaque||!!e.userData.cannotReceiveAO))}),e.clear(!0,!0,!0),this.depthCopyPass.render(e),e.render(this.scene,this.camera),e.setRenderTarget(this.transparencyRenderTargetDWTrue),this.scene.traverse(e=>{e.material&&(e.visible=i.get(e)&&e.material.transparent&&e.material.depthWrite&&!e.userData.treatAsOpaque)}),e.clear(!0,!0,!0),this.depthCopyPass.render(e),e.render(this.scene,this.camera),this.scene.traverse(e=>{e.visible=i.get(e)}),e.setClearColor(n,r),this.scene.background=t,e.autoClearDepth=a}configureSampleDependentPasses(){this.firstFrame(),this.configureAOPass(this.configuration.depthBufferType,this.camera.isOrthographicCamera),this.configureDenoisePass(this.configuration.depthBufferType,this.camera.isOrthographicCamera)}configureAOPass(e=uf.Default,t=!1){this.firstFrame(),this.samples=this.generateHemisphereSamples(this.configuration.aoSamples);let n={...nf};n.fragmentShader=n.fragmentShader.replace(`16`,this.configuration.aoSamples).replace(`16.0`,this.configuration.aoSamples+`.0`),e===uf.Log?n.fragmentShader=`#define LOGDEPTH +`+n.fragmentShader:e===uf.Reverse&&(n.fragmentShader=`#define REVERSEDEPTH +`+n.fragmentShader),t&&(n.fragmentShader=`#define ORTHO +`+n.fragmentShader),this.configuration.halfRes&&(n.fragmentShader=`#define HALFRES +`+n.fragmentShader),this.effectShaderQuad?(this.effectShaderQuad.material.dispose(),this.effectShaderQuad.material=new Co(n)):this.effectShaderQuad=new tf(new Co(n))}configureDenoisePass(e=uf.Default,t=!1){this.firstFrame(),this.samplesDenoise=this.generateDenoiseSamples(this.configuration.denoiseSamples,11);let n={...af};n.fragmentShader=n.fragmentShader.replace(`16`,this.configuration.denoiseSamples),e===uf.Log?n.fragmentShader=`#define LOGDEPTH +`+n.fragmentShader:e===uf.Reverse&&(n.fragmentShader=`#define REVERSEDEPTH +`+n.fragmentShader),t&&(n.fragmentShader=`#define ORTHO +`+n.fragmentShader),this.poissonBlurQuad?(this.poissonBlurQuad.material.dispose(),this.poissonBlurQuad.material=new Co(n)):this.poissonBlurQuad=new tf(new Co(n))}configureEffectCompositer(e=uf.Default,t=!1){this.firstFrame();let n={...rf};e===uf.Log?n.fragmentShader=`#define LOGDEPTH +`+n.fragmentShader:e===uf.Reverse&&(n.fragmentShader=`#define REVERSEDEPTH +`+n.fragmentShader),t&&(n.fragmentShader=`#define ORTHO +`+n.fragmentShader),this.configuration.halfRes&&this.configuration.depthAwareUpsampling&&(n.fragmentShader=`#define HALFRES +`+n.fragmentShader),this.effectCompositerQuad?(this.effectCompositerQuad.material.dispose(),this.effectCompositerQuad.material=new Co(n)):this.effectCompositerQuad=new tf(new Co(n))}generateHemisphereSamples(e){let t=[];for(let n=0;nCf.lock()),Cf.onLockChange=e=>{_f.classList.toggle(`hidden`,e)}),window.addEventListener(`resize`,()=>{bf.aspect=window.innerWidth/window.innerHeight,bf.updateProjectionMatrix(),vf.setSize(window.innerWidth,window.innerHeight),Tf.resize(window.innerWidth,window.innerHeight)});var Ef={cockpit:{pos:[0,1.7,-9],look:[0,1.15,-12.6]},corridor:{pos:[0,1.7,7.4],look:[0,1.35,-8]},quarters:{pos:[2.05,1.7,2],look:[4.6,.7,5.7]},window:{pos:[-.15,1.62,.7],look:[-3,1.55,.75]}},Df=0,Of=0,kf=0,Af=0;vf.info.autoReset=!1;var jf=!1;window.debugAPI={ready:!1,frames:()=>Df,pause(){jf=!0},resume(){jf=!1},capture(e=.92){return Tf.composer.render(),vf.domElement.toDataURL(`image/jpeg`,e)},setView(e){let t=Ef[e];if(!t)return!1;Cf.frozen=!0,bf.position.set(...t.pos),bf.lookAt(new K(...t.look)),Cf.position.set(t.pos[0],0,t.pos[2]);let n=new Rt().setFromQuaternion(bf.quaternion,`YXZ`);return Cf.yaw=n.y,Cf.pitch=n.x,Cf.bobAmount=0,!0},free(){Cf.frozen=!1},customView(e,t,n,r,i,a){Cf.frozen=!0,bf.position.set(e,t,n),bf.lookAt(new K(r,i,a)),Cf.position.set(e,0,n);let o=new Rt().setFromQuaternion(bf.quaternion,`YXZ`);Cf.yaw=o.y,Cf.pitch=o.x,Cf.eyeOverride=t,Cf.bobAmount=0},stats(){return{fps:Af,drawCalls:vf.info.render.calls,triangles:vf.info.render.triangles}},hoverTarget(){return wf.hovered?wf.hovered.userData.interactable.id:null},pick(){let e=new js;return e.setFromCamera(new G(0,0),bf),e.intersectObjects(xf.group.children,!1).slice(0,6).map(e=>{let t=e.object.material;return{dist:+e.distance.toFixed(3),point:e.point.toArray().map(e=>+e.toFixed(2)),color:t.color?t.color.getHexString():null,emissive:t.emissive?t.emissive.getHexString():null,rough:t.roughness,metal:t.metalness,hasMap:!!t.map,transparent:t.transparent,type:t.type}})},press(e){document.dispatchEvent(new KeyboardEvent(`keydown`,{code:e}))},teleport(e,t,n,r){Cf.frozen=!1,Cf.setPose({x:e,z:t},n,r)},playerPos(){return[Cf.position.x,Cf.position.z,Cf.yaw]},setKey(e,t){t?Cf.keys.add(e):Cf.keys.delete(e)},forceLock(e){Cf.locked=e},inspect(){let e=[];for(let t of xf.group.children){if(!t.isMesh)continue;let n=t.material,r=t.geometry,i={color:n.color?n.color.getHexString():null,verts:r.attributes.position.count,hasNormal:!!r.attributes.normal,hasUV:!!r.attributes.uv,attrs:Object.keys(r.attributes),indexed:!!r.index};if(n.color&&n.color.getHexString()===`1d1e20`){let e=r.attributes.position,t=r.attributes.normal,n=[];for(let r=0;r.5&&a<1.3){let s=new K(i,a,o),c=new K(e.getX(r+1),e.getY(r+1),e.getZ(r+1)),l=new K(e.getX(r+2),e.getY(r+2),e.getZ(r+2)).clone().sub(c).cross(s.clone().sub(c)).normalize(),u=new K(t.getX(r),t.getY(r),t.getZ(r));if(n.push({tri:r/3,at:s.toArray().map(e=>+e.toFixed(2)),storedN:u.toArray().map(e=>+e.toFixed(2)),storedLen:+u.length().toFixed(3),geomN:l.toArray().map(e=>+e.toFixed(2)),agree:+l.dot(u.clone().normalize()).toFixed(2)}),n.length>=6)break}}i.probes=n}e.push(i)}return e}};var Mf=performance.now(),Nf=0;function Pf(){requestAnimationFrame(Pf);let e=performance.now(),t=(e-Mf)/1e3;Mf=e;let n=Math.min(t,.05);jf||(Nf+=n,vf.info.reset(),Cf.update(n),Sf.update(n,Nf),wf.update(n,Nf),Tf.update(Nf),Tf.composer.render(),Of+=t,kf++,Of>=.5&&(Af=Math.round(kf/Of*10)/10,Of=0,kf=0),Df++,Df===12&&(window.debugAPI.ready=!0))}Pf(); \ No newline at end of file diff --git a/play/index.html b/play/index.html new file mode 100644 index 0000000..2e366c5 --- /dev/null +++ b/play/index.html @@ -0,0 +1,96 @@ + + + + + + Drifter — Ship Interior + + + + +
+
+
+
+
+
+
+
+
+

DRIFTER · MCV-7

+

CLICK TO BOARD

+

WASD MOVE  ·  MOUSE LOOK  ·  E INTERACT

+
+ + diff --git a/spaceship/.gitignore b/spaceship/.gitignore new file mode 100644 index 0000000..b947077 --- /dev/null +++ b/spaceship/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +dist/ diff --git a/spaceship/PROGRESS.md b/spaceship/PROGRESS.md new file mode 100644 index 0000000..8b79e90 --- /dev/null +++ b/spaceship/PROGRESS.md @@ -0,0 +1,295 @@ +# PROGRESS — Drifter MCV-7 (first-person ship interior) + +Self-evaluating loop. Each iteration: implement → screenshot (tools/shots.mjs) → +judge against rubric → fix list → repeat. Stop: all rubric items pass twice in a +row, or iteration 12. + +## Rubric +1. Lighting reads intentional (key/fill, glowing emissives, not flat) +2. Materials read physical (metal/painted/fabric, reflections, roughness variation) +3. Detail density (no large undetailed surfaces) +4. Post stack balanced (ACES, bloom, AO, vignette, grain; no blown/crushed) +5. Space view sells motion (planet + rim glow, obvious parallax) +6. Cohesive palette across all shots +7. Tech clean (60fps, no z-fighting/acne/missing faces) +8. Cold-look test (corridor shot reads as real indie space game) +9. Interactions work (lock, prompts, 3 interactions, fades, status) + +--- + +## Iteration 1 +Built everything: 6 modules, procedural textures, kit-bashed interior (corridor, +cockpit, quarters, galley, bathroom), 3-layer starfield + 2 planets + nebulae, +post stack (N8AO/bloom/ACES/grain/vignette), shots harness. Playwright headless +works via SwiftShader (~0.5 fps there; capture via canvas toDataURL — page +screenshots hang in compositor). Draw calls ~200, tris ~110k → real-GPU 60 fps +is not in question. + +Scores (harsh): +1. Lighting intentional — **FAIL**. Whole interior is washed out, near-white; + no key/fill contrast; bloom smears everything bright. +2. Materials physical — **FAIL**. Glass is an opaque white mirror (env blowout). + Painted panels wash to pure white; metals OK-ish. +3. Detail density — **FAIL**. Cockpit side walls + quarters walls read bare at + this exposure; greebles exist but get nuked by the washout. +4. Post balanced — **FAIL**. Massive blown highlights (window = white sheet, + corridor end = white blob). Grain/vignette fine, AO invisible under flat light. +5. Space sells motion — **FAIL**. Cockpit viewport is a glowing white wall; + porthole shows faint planet behind mirror glass; no stars visible. +6. Cohesive palette — **PASS** (off-white/orange/teal/gray holds up in all 4). +7. Tech clean — **PASS** (no z-fight/acne/missing faces seen; budget light). +8. Cold-look — **FAIL** (reads "overexposed Three.js demo"). +9. Interactions — **FAIL**. Hover ray missed all 3 (test aims pointed too high); + prompts/fades implemented but unproven. + +Fix list for iter 2 (worst first): +- Exposure 1.1→0.95, env 0.25→0.12, ambient down, ceiling lights dimmer; aim + for moody contrast, AO visible, emissives glowing not flooding. +- Glass: metalness 0.9→0, opacity 0.05, envMapIntensity 0.3 — must be invisible. +- Space through windows: brighter stars, bigger/closer planets, stronger rim. +- Darken hull albedo (0.78→0.66 lightness), heavier grime/seams; darker floor. +- Bloom: threshold 0.85, strength 0.4; dim screens/strips so they glow only. +- Fix interaction test aim angles (pitch was too shallow, missed hover boxes). + +## Iteration 2 +Relit (exposure 0.95, env 0.10, bloom 0.38/0.88), glass now transparent +dielectric, stars pixel-sized, planets bigger; interaction aims fixed. + +Scores: +1. Lighting — **FAIL** (better: warm/cool reads, but corridor end still blows + out white; cockpit has odd teal cast over whole ceiling from console light). +2. Materials — **FAIL** (panels/metal/fabric read, but seat+blanket orange washes + to beige; emissive cooktop rings wash to cream; counter metal OK). +3. Detail density — **FAIL** (quarters ceiling + wall above bed bare; cockpit + sill band bare; corridor good). +4. Post — **FAIL** (bloom still floods corridor far end; otherwise balanced, + AO now visible at panel seams). +5. Space motion — **FAIL** (moon visible from cockpit but ghostly — we placed + bodies on the dark side of the sun; gas giant washed pale behind porthole; + stars sparse in shots). +6. Palette — **PASS** (consistent, though orange drifts tan). +7. Tech — **PASS** (200 calls / 116k tris; no artifacts spotted). +8. Cold-look — **FAIL** (corridor close; quarters reads "clean dollhouse"). +9. Interactions — **PASS** (all 3 hover→prompt→fire with messages + status, + verified in stats.json + screenshots; highlight box is hideous butter slab). + +Fix list for iter 3: +- Flip sun behind-starboard so planet faces toward ship are lit; gas giant → + port side; moon ahead lit; add ringed crescent starboard. Window view → left + porthole. Saturate planet bands. +- Kill cockpit teal cast (console light 5→2, range 2.6). +- Corridor: strips 2.4→1.8 emissive, lights 7, bloom .38/.88, fog .035. +- Quarters: cabinet above bed, ceiling housings/vent/pipe, lamp out of porthole + sightline, headboard strip flush to wall; deeper orange fabric. +- Hover highlight: additive, opacity ~0.05 + edges. +- Cooktop rings/sign lights: lower emissive so color stays saturated. + +## Iteration 3 +Sun flipped, planets repositioned + ringed crescent added, quarters detailed, +hover toned down. Shots showed lit moon from cockpit, but the global "wash" +persisted. Spent the iteration root-causing it with A/B probes (red/blue/green +material swaps, sun off, AO off, bloom off): **N8AOPass was gamma-correcting +its output while OutputPass converts to sRGB again — the entire frame was +double-gamma'd since iteration 1.** Every light level we tuned was compensating +for that. Fixed with `n8ao.configuration.gammaCorrection = false`, then re-raised +lighting (exposure 1.05, env 0.16, practical lights +40%). + +Scores: not formally scored — the pipeline fix invalidates the iter-3 captures +(judged from probes: palette/saturation massively better, oranges finally read +orange, rubber reads black). Interactions still pass (verified in stats.json). +Carrying over open items: +- Re-verify all 4 views under the corrected pipeline. +- Corridor far-end bloom, planet wash, quarters porthole framing. + +## Iteration 4 +First captures with the corrected (single-gamma) pipeline + rebalanced lights. + +Scores: +1. Lighting — **FAIL** (cockpit/quarters/window now read deliberate and moody; + corridor ruined by a giant warm bloom flood from the ceiling fixtures). +2. Materials — **FAIL** (metals/paint/fabric all read physical at last — + porthole ring is genuinely good — but deck floor crushes to black, tread + detail gone). +3. Detail density — **PASS** (paneling, greebles, pipes in every shot; no bare + surface at these framings). +4. Post — **FAIL** (corridor bloom flood = blown highlight region; elsewhere + balanced; grain/vignette/AO all visible and sane). +5. Space motion — **PASS** (cockpit: lit moon + rim + stars; window: saturated + banded gas giant fills porthole; parallax layers run in motion). + …borderline: gas giant so close no stars visible around it in window shot. +6. Palette — **PASS** (burnt orange / off-white / teal / gunmetal everywhere). +7. Tech — **PASS** (194-231 calls, ~115k tris; no z-fight/acne visible). +8. Cold-look — **FAIL** (corridor flood; galley under-cabinet teal flare). +9. Interactions — **PASS** (json + screenshots; cooktop rings glow orange now). + +Fix list for iter 5: +- Bloom 0.30/0.5/0.90; warm strips 1.7; should kill the corridor flood. +- Floor albedo 46→58 + envMapIntensity 1.1 so tread reads in dark rooms. +- Gas giant to R=980 (porthole gets planet limb + rim + stars, not a wall of + bands); rim 2.4. +- Galley brighter (pendant 24, fill 8); hover overlay opacity 0.02. +- AO 3.0 (quarters ceiling blotch). + +## Iteration 5 +Bloom calmed, floors lifted, gas giant pushed out (porthole now frames the +whole planet with limb + glow — looks great), galley brightened. + +Scores: +1. Lighting — **FAIL**. Corridor STILL floods warm at the ceiling: the point + lights sit 0.25 m under the ceiling, inverse-square nukes the nearby panels. + Cockpit/quarters/window read intentional. +2. Materials — **PASS** (porthole metal, painted panels w/ wear, orange fabric, + black rubber; visible roughness variation on counters/floors). +3. Detail density — **PASS**. +4. Post — **FAIL** (corridor ceiling region effectively blown; everything else + balanced). +5. Space motion — **PASS** (planet + rim + stars through porthole; moon ahead; + parallax layers + streaks in motion). +6. Palette — **PASS**. +7. Tech — **PASS**. +8. Cold-look — **FAIL** (corridor is the cold-look shot and it has the flood; + rest of frame is genuinely close). +9. Interactions — **PASS**. + +Fix list for iter 6: +- Corridor: replace ceiling point lights with downward SpotLights (fixtures + stay emissive, light pools on the deck instead of nuking the ceiling). +- Floor metalness 0.55 + albedo lift again (deck still crushes under spots). +- Teal strips 2.4 + wall-base edge strips so the trench glow actually reads. +- Cockpit: add cool window-spill fill light; console glow 3. +- Quarters ceiling light lowered/strengthened slightly. + +## Iteration 6 +Corridor switched to downlight spots + edge strips: the shot finally has pools +of light, teal floor lines, readable depth. Cockpit gained cool window spill. + +Scores: +1. Lighting — **FAIL** (close: corridor's nearest two ceiling fixtures still + bloom into one hot mass at top of frame; everything else deliberate). +2. Materials — **PASS**. +3. Detail density — **PASS**. +4. Post — **FAIL** (same single hot region; rest balanced). +5. Space motion — **PASS** (gas giant framed with limb + glow in porthole now). +6. Palette — **PASS**. +7. Tech — **PASS** (~230 calls / 118k tris worst case). +8. Cold-look — **FAIL** (fixture bloom + galley teal flare + scene still reads + slightly sterile/empty — no loose props anywhere). +9. Interactions — **PASS**. + +Fix list for iter 7: +- Fixture emissives 1.5 + diffuser slats over the light quads (smaller bright + area = less bloom); galley under-cabinet strip on a dim teal material. +- Hover overlay faces nearly invisible (0.008), edges only. +- Lived-in props: crates by engineering hatch, open maintenance recess with + pipes/LEDs + leaning panel, pan on cooktop, mugs, boots by the bed. + +## Iteration 7 +Fixture diffuser slats + dimmer strips fixed the corridor blowout; props in. + +Scores: +1. Lighting — **PASS** (corridor: defined fixtures, warm pools, teal accents, + readable falloff; cockpit and quarters keep key/fill/accent separation). +2. Materials — **PASS** (metal ring, painted panels, fabric, rubber, glass all + distinct; roughness breakup visible on counter/floor/walls). +3. Detail density — **PASS** (recess, props, conduits, ribs, grates, decals). +4. Post — **PASS** (no blown regions, no crushed blacks, AO/grain/vignette + present but not loud). +5. Space motion — **PASS** (gas giant framed in porthole w/ limb glow + stars; + moon ahead of cockpit; layered parallax + streaks in motion). +6. Palette — **PASS**. +7. Tech — **PASS** (239 calls / 120k tris worst view; no artifacts in shots). +8. Cold-look — **FAIL** (hesitated: corridor still perfectly mirror-symmetric + — identical rails/boxes both sides — and the deck centre is empty). +9. Interactions — **PASS** (all three verified again; highlight now subtle). + +Fix list for iter 8 (cold-look only, do not disturb passing items): +- Stagger junction boxes per side; hazard threshold stripes on the deck at the + bulkheads; rubber cable run + clamps along the deck from the open recess; + overhead grab handles alternating sides. + +## Iteration 8 — first full pass +Symmetry broken (staggered junction boxes, one-sided recess + leaning panel, +deck cable run, alternating grab handles, threshold stripes). + +Scores: +1. Lighting — **PASS** (warm pools + teal accents + cool space light; falloff + reads deliberately in all four shots). +2. Materials — **PASS** (worn metal / painted panel / fabric / rubber / glass; + reflections on porthole ring and deck; roughness breakup everywhere). +3. Detail density — **PASS** (no bare surface in any framing). +4. Post — **PASS** (ACES + bloom contained to emissives, AO grounded, grain + + vignette subtle; no blown regions, no crushed blacks). +5. Space motion — **PASS** (banded gas giant with limb glow + stars in the + porthole; lit moon with atmosphere rim ahead of the cockpit; 3-layer + parallax + near-hull streaks sell flight in motion). +6. Palette — **PASS** (burnt orange / bone white / teal / gunmetal, all shots). +7. Tech — **PASS** (worst view 239 calls / 122k tris, 1×1024 + 2×512 shadow + maps; no z-fighting/acne/missing faces in any capture. SwiftShader cannot + measure real fps; this budget is comfortably 60fps-class on a mid-range + laptop GPU). +8. Cold-look — **PASS** (no hesitation this time: corridor reads as a game + screenshot — lived-in, lit, art-directed). +9. Interactions — **PASS** (hover→prompt→E→fade/message/status verified for + bed/galley/sink; highlight reads as thin edge wireframe). + +9/9. Stopping condition requires a second consecutive full pass → iteration 9 +re-captures with zero code changes to confirm stability. + +## Iteration 9 — second consecutive full pass (STOP) +Zero code changes; re-captured all views + interaction smoke tests. All four +shots hold up (the gas giant had drifted slightly in the porthole between +runs — incidental confirmation that the space motion is live). All three +interactions re-verified. **9/9 again → stopping condition met.** + +--- + +# FINAL SUMMARY + +## What passed (and why I believe it) +- **Lighting**: every room has a deliberate key (corridor downlight spots, + quarters reading lamp, galley pendant, cockpit console + cool window spill), + warm practicals against cool space light, and emissive accents that glow + without flooding. The rest-cycle toggle re-grades the whole interior. +- **Materials**: five distinct PBR families (worn painted hull, dark painted + band, brushed/worn metal, fabric/rubber, glass) — all canvas-procedural with + matching roughness + normal maps; PMREM environment gives metals real + reflections. +- **Detail density**: panel grids with stencils/vents/accent stripes, corridor + ribs, ceiling pipe runs with clamps, wall conduits + junction boxes, floor + trench grates with teal glow, threshold hazard stripes, crates, an open + maintenance recess, grab handles, props (pan, mugs, boots). +- **Post**: ACES + UnrealBloom (0.30/0.5/0.90) + N8AO + vignette + grain + + exp fog. The critical fix of the whole project: N8AO was gamma-correcting + inside the chain while OutputPass converted to sRGB again — everything + before iteration 4 was tuned against a double-gamma'd frame. +- **Space**: 3-layer drifting starfield + near-hull speed streaks, banded gas + giant (custom shader: sun-lit bands + fresnel rim + additive atmosphere + shell) sliding past the port porthole on a 340 s orbit, lit moon ahead of + the cockpit, ringed crescent far starboard, nebula sprites, sun glow. +- **Interactions**: raycast hover + edge highlight + prompt; bed (fade, + "8 hours pass", rest-cycle lighting), galley ("Energy restored"), bathroom + (fade, "Refreshed"); one-line HUD status with ship clock. +- **Tech budget**: worst view 239 draw calls / ~122 k tris, one 1024 shadow + map + two 512 spot shadows, AO at half res. 60 fps on a mid-range laptop GPU + is comfortably within budget (SwiftShader CI can't measure real fps). + +## What is still weak +- The fabric quilt seams read slightly oversized up close on the bed. +- Quarters ceiling has a soft AO blotch near the vent housing. +- The porthole "depth tube" interior is plain; at extreme angles it reads flat. +- Stars are uniform points — no bright cross-flare hero stars. +- Head-bob/rumble is tuned by feel, never validated by a human play session. +- HUD (DOM) isn't in the canvas captures; interaction proof relies on DOM + state JSON + lighting change visible in renders. + +## With five more iterations I would +1. Bake an interior-specific PMREM (render a cube probe in the corridor) so + metals reflect the actual orange/teal interior instead of RoomEnvironment. +2. Animate the screens (canvas redraw at 2-4 Hz: scrolling text, radar sweep) + and add a slow camera-facing dust mote particle layer in the light pools. +3. Give the gas giant a proper day/night city-light texture + cloud-shadow + layer, and add a slow ship roll (0.5°) so the starfield drifts in all axes. +4. Replace AABB collision with capsule-vs-OBB so the leaning panel and angled + cockpit walls collide exactly. +5. Footstep-synced bob + soft audio (engine hum loop, footsteps, UI blips) — + sound is half the cold-look test in practice. diff --git a/spaceship/README.md b/spaceship/README.md new file mode 100644 index 0000000..04e51a9 --- /dev/null +++ b/spaceship/README.md @@ -0,0 +1,23 @@ +# Drifter MCV-7 — first-person ship interior demo + +A small first-person walkable spaceship interior (Three.js + Vite). Everything is +procedural: canvas-generated PBR textures, kit-bashed geometry, shader planets. + +## Run + +```bash +npm install +npm run dev +``` + +Click to grab pointer lock. WASD + mouse, `E` to interact (bed / galley / bathroom sink). + +## Screenshot harness + +```bash +node tools/shots.mjs +``` + +Spawns vite + headless Chromium (SwiftShader), captures deterministic views +(`cockpit`, `corridor`, `quarters`, `window`) plus interaction smoke tests into +`shots/iter_/`. diff --git a/spaceship/drifter-source-bundle.txt b/spaceship/drifter-source-bundle.txt new file mode 100644 index 0000000..4e7dc64 --- /dev/null +++ b/spaceship/drifter-source-bundle.txt @@ -0,0 +1,2695 @@ +DRIFTER MCV-7 — first-person spaceship interior demo (Three.js + Vite) +======================================================================= + +This single file contains the COMPLETE source of the project. Each file is +delimited by a marker line of the form: + + ===== FILE: ===== + +INSTRUCTIONS (for Claude Code or any coding agent): +1. Split this bundle into separate files at the marker lines, preserving the + relative paths exactly. +2. From the project root run: + npm install + npm run dev # local dev server + npm run build # production build -> dist/ +3. The game is 100% procedural: no external assets; all textures/models are + generated in code. Dependencies: three, n8ao (via npm). + +Controls: WASD move, mouse look (pointer lock), E interact. +Architecture: src/main.js boots renderer/scene and the frame loop; +src/ship.js builds all interior geometry/materials/lights (merged by +material via Batch); src/space.js builds the starfield/planets outside; +src/player.js is the FPS controller (capsule vs AABB colliders); +src/interact.js handles raycast interactions; src/post.js is the +EffectComposer pipeline (N8AO, bloom, vignette/grain); src/textures.js +generates all canvas-based PBR textures. + + +===== FILE: package.json ===== + +{ + "name": "spaceship-interior", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "shots": "node tools/shots.mjs" + }, + "dependencies": { + "n8ao": "^1.10.1", + "postprocessing": "^6.39.1", + "three": "^0.184.0", + "vite": "^8.0.16" + }, + "devDependencies": { + "playwright": "^1.60.0" + } +} + +===== FILE: vite.config.js ===== + +import { defineConfig } from 'vite'; + +export default defineConfig({ + // relative base so the build works when served from a subpath like /spaceship/ + base: './', +}); + +===== FILE: index.html ===== + + + + + + + Drifter — Ship Interior + + + +
+
+
+
+
+
+
+
+
+

DRIFTER · MCV-7

+

CLICK TO BOARD

+

WASD MOVE  ·  MOUSE LOOK  ·  E INTERACT

+
+ + + + +===== FILE: src/main.js ===== + +import * as THREE from 'three'; +import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js'; +import { mulberry32 } from './textures.js'; +import { buildShip } from './ship.js'; +import { buildSpace, SUN_DIR } from './space.js'; +import { Player } from './player.js'; +import { Interactions } from './interact.js'; +import { createPost } from './post.js'; + +const SEED = 1337; +const DEBUG = location.hash.includes('debug'); + +const app = document.getElementById('app'); +const startEl = document.getElementById('start'); + +const renderer = new THREE.WebGLRenderer({ antialias: false, powerPreference: 'high-performance' }); +renderer.setSize(window.innerWidth, window.innerHeight); +renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75)); +renderer.shadowMap.enabled = true; +renderer.shadowMap.type = THREE.PCFShadowMap; +app.appendChild(renderer.domElement); + +const scene = new THREE.Scene(); +scene.background = new THREE.Color(0x010204); +scene.fog = new THREE.FogExp2(0x0a0d12, 0.035); + +const camera = new THREE.PerspectiveCamera(72, window.innerWidth / window.innerHeight, 0.05, 5000); + +// PMREM environment so metals reflect something real +{ + const pmrem = new THREE.PMREMGenerator(renderer); + const envScene = new RoomEnvironment(); + scene.environment = pmrem.fromScene(envScene, 0.04).texture; + scene.environmentIntensity = 0.16; + pmrem.dispose(); +} + +// build world +const rand = mulberry32(SEED); +const ship = buildShip(scene, rand); +const space = buildSpace(scene, mulberry32(SEED + 7)); + +// cool space key light through the cockpit viewport +{ + const NOSUN = location.hash.includes('nosun'); + const sun = new THREE.DirectionalLight(0xbcd8ff, NOSUN ? 0 : 2.0); + sun.position.copy(SUN_DIR).multiplyScalar(40); + sun.target.position.set(0, 1, -10); + sun.castShadow = true; + sun.shadow.mapSize.set(1024, 1024); + sun.shadow.camera.left = -8; + sun.shadow.camera.right = 8; + sun.shadow.camera.top = 8; + sun.shadow.camera.bottom = -8; + sun.shadow.camera.near = 10; + sun.shadow.camera.far = 70; + sun.shadow.bias = -0.0008; + sun.shadow.normalBias = 0.03; + scene.add(sun, sun.target); + if (!NOSUN) ship.lights.push({ light: sun, day: 2.0, night: 2.0 }); + // faint ambient so blacks never fully crush + const amb = new THREE.AmbientLight(0x47505e, 0.5); + scene.add(amb); + ship.lights.push({ light: amb, day: 0.5, night: 0.34 }); +} + +const player = new Player(camera, renderer.domElement, ship.colliders); +const interact = new Interactions(scene, camera, ship); +const post = createPost(renderer, scene, camera); + +// ------------------------------------------------------------------ start UI +if (DEBUG) { + startEl.classList.add('hidden'); +} else { + startEl.addEventListener('click', () => player.lock()); + player.onLockChange = (locked) => { + startEl.classList.toggle('hidden', locked); + }; +} + +window.addEventListener('resize', () => { + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + renderer.setSize(window.innerWidth, window.innerHeight); + post.resize(window.innerWidth, window.innerHeight); +}); + +// ------------------------------------------------------------------ debug API +const VIEWS = { + cockpit: { pos: [0.0, 1.7, -9.0], look: [0, 1.15, -12.6] }, + corridor: { pos: [0.0, 1.7, 7.4], look: [0, 1.35, -8] }, + quarters: { pos: [2.05, 1.7, 2.0], look: [4.6, 0.7, 5.7] }, + window: { pos: [-0.15, 1.62, 0.70], look: [-3.0, 1.55, 0.75] }, +}; + +let frames = 0; +let fpsAccum = 0, fpsCount = 0, fpsValue = 0; + +renderer.info.autoReset = false; + +let paused = false; + +window.debugAPI = { + ready: false, + frames: () => frames, + pause() { paused = true; }, + resume() { paused = false; }, + // Render one frame synchronously and return JPEG data URL (headless capture). + capture(quality = 0.92) { + post.composer.render(); + return renderer.domElement.toDataURL('image/jpeg', quality); + }, + setView(name) { + const v = VIEWS[name]; + if (!v) return false; + player.frozen = true; + camera.position.set(...v.pos); + camera.lookAt(new THREE.Vector3(...v.look)); + // sync player state so it doesn't snap back + player.position.set(v.pos[0], 0, v.pos[2]); + const e = new THREE.Euler().setFromQuaternion(camera.quaternion, 'YXZ'); + player.yaw = e.y; + player.pitch = e.x; + player.bobAmount = 0; + return true; + }, + free() { player.frozen = false; }, + customView(x, y, z, lx, ly, lz) { + player.frozen = true; + camera.position.set(x, y, z); + camera.lookAt(new THREE.Vector3(lx, ly, lz)); + player.position.set(x, 0, z); + const e = new THREE.Euler().setFromQuaternion(camera.quaternion, 'YXZ'); + player.yaw = e.y; + player.pitch = e.x; + player.eyeOverride = y; + player.bobAmount = 0; + }, + stats() { + return { + fps: fpsValue, + drawCalls: renderer.info.render.calls, + triangles: renderer.info.render.triangles, + }; + }, + hoverTarget() { + return interact.hovered ? interact.hovered.userData.interactable.id : null; + }, + pick() { + const rc = new THREE.Raycaster(); + rc.setFromCamera(new THREE.Vector2(0, 0), camera); + const hits = rc.intersectObjects(ship.group.children, false); + return hits.slice(0, 6).map((h) => { + const m = h.object.material; + return { + dist: +h.distance.toFixed(3), + point: h.point.toArray().map((v) => +v.toFixed(2)), + color: m.color ? m.color.getHexString() : null, + emissive: m.emissive ? m.emissive.getHexString() : null, + rough: m.roughness, metal: m.metalness, + hasMap: !!m.map, transparent: m.transparent, + type: m.type, + }; + }); + }, + press(code) { + document.dispatchEvent(new KeyboardEvent('keydown', { code })); + }, + teleport(x, z, yaw, pitch) { + player.frozen = false; + player.setPose({ x, z }, yaw, pitch); + }, + playerPos() { + return [player.position.x, player.position.z, player.yaw]; + }, + setKey(code, down) { + if (down) player.keys.add(code); else player.keys.delete(code); + }, + forceLock(v) { player.locked = v; }, + inspect() { + const out = []; + for (const ch of ship.group.children) { + if (!ch.isMesh) continue; + const m = ch.material; + const g = ch.geometry; + const rec = { + color: m.color ? m.color.getHexString() : null, + verts: g.attributes.position.count, + hasNormal: !!g.attributes.normal, + hasUV: !!g.attributes.uv, + attrs: Object.keys(g.attributes), + indexed: !!g.index, + }; + // sanity: for first triangle near a probe point, compare geometric vs stored normal + if (m.color && m.color.getHexString() === '1d1e20') { + const pos = g.attributes.position, nor = g.attributes.normal; + const probes = []; + for (let i = 0; i < pos.count; i += 3) { + const ax = pos.getX(i), ay = pos.getY(i), az = pos.getZ(i); + if (Math.abs(ax + 0.62) < 0.4 && Math.abs(az + 10.35) < 0.3 && ay > 0.5 && ay < 1.3) { + const A = new THREE.Vector3(ax, ay, az); + const B = new THREE.Vector3(pos.getX(i + 1), pos.getY(i + 1), pos.getZ(i + 1)); + const C = new THREE.Vector3(pos.getX(i + 2), pos.getY(i + 2), pos.getZ(i + 2)); + const geom = C.clone().sub(B).cross(A.clone().sub(B)).normalize(); + const stored = new THREE.Vector3(nor.getX(i), nor.getY(i), nor.getZ(i)); + probes.push({ + tri: i / 3, + at: A.toArray().map((v) => +v.toFixed(2)), + storedN: stored.toArray().map((v) => +v.toFixed(2)), + storedLen: +stored.length().toFixed(3), + geomN: geom.toArray().map((v) => +v.toFixed(2)), + agree: +geom.dot(stored.clone().normalize()).toFixed(2), + }); + if (probes.length >= 6) break; + } + } + rec.probes = probes; + } + out.push(rec); + } + return out; + }, +}; + +// ------------------------------------------------------------------ main loop +let lastT = performance.now(); +let elapsed = 0; + +function tick() { + requestAnimationFrame(tick); + const now = performance.now(); + const realDt = (now - lastT) / 1000; + lastT = now; + const dt = Math.min(realDt, 0.05); + if (paused) return; + elapsed += dt; + renderer.info.reset(); + + player.update(dt); + space.update(dt, elapsed); + interact.update(dt, elapsed); + post.update(elapsed); + + post.composer.render(); + + fpsAccum += realDt; fpsCount++; + if (fpsAccum >= 0.5) { + fpsValue = Math.round((fpsCount / fpsAccum) * 10) / 10; + fpsAccum = 0; fpsCount = 0; + } + frames++; + if (frames === 12) window.debugAPI.ready = true; +} +tick(); + +===== FILE: src/textures.js ===== + +// Procedural canvas texture generation. Everything in the game is drawn here. +import * as THREE from 'three'; + +export function mulberry32(seed) { + let a = seed >>> 0; + return function () { + a |= 0; a = (a + 0x6D2B79F5) | 0; + let t = Math.imul(a ^ (a >>> 15), 1 | a); + t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; + return ((t ^ (t >>> 14)) >>> 0) / 4294967296; + }; +} + +export function cv(w, h = w) { + const c = document.createElement('canvas'); + c.width = w; c.height = h; + return [c, c.getContext('2d', { willReadFrequently: true })]; +} + +export function tex(canvas, { srgb = true, repeat = null } = {}) { + const t = new THREE.CanvasTexture(canvas); + t.wrapS = t.wrapT = THREE.RepeatWrapping; + if (srgb) t.colorSpace = THREE.SRGBColorSpace; + t.anisotropy = 8; + if (repeat) t.repeat.set(repeat[0], repeat[1]); + return t; +} + +// Layered value-noise canvas (grayscale, centered around mid gray). +export function noiseCanvas(rand, size, octaves = 5, contrast = 1) { + const [c, ctx] = cv(size); + ctx.fillStyle = '#808080'; + ctx.fillRect(0, 0, size, size); + for (let o = 0; o < octaves; o++) { + const res = 4 << o; + const [oc, octx] = cv(res); + const img = octx.createImageData(res, res); + for (let i = 0; i < res * res; i++) { + const v = (rand() * 255) | 0; + img.data[i * 4] = v; img.data[i * 4 + 1] = v; img.data[i * 4 + 2] = v; img.data[i * 4 + 3] = 255; + } + octx.putImageData(img, 0, 0); + ctx.globalAlpha = 0.55 / (o + 1.2) * contrast; + ctx.imageSmoothingEnabled = true; + ctx.drawImage(oc, 0, 0, size, size); + } + ctx.globalAlpha = 1; + return c; +} + +// Sobel height -> tangent-space normal map. +export function normalFromHeight(heightCanvas, strength = 2.5) { + const w = heightCanvas.width, h = heightCanvas.height; + const sctx = heightCanvas.getContext('2d'); + const src = sctx.getImageData(0, 0, w, h).data; + const [c, ctx] = cv(w, h); + const out = ctx.createImageData(w, h); + const hAt = (x, y) => src[(((y + h) % h) * w + ((x + w) % w)) * 4] / 255; + for (let y = 0; y < h; y++) { + for (let x = 0; x < w; x++) { + const dx = (hAt(x + 1, y) - hAt(x - 1, y)) * strength; + const dy = (hAt(x, y + 1) - hAt(x, y - 1)) * strength; + const len = Math.sqrt(dx * dx + dy * dy + 1); + const i = (y * w + x) * 4; + out.data[i] = ((-dx / len) * 0.5 + 0.5) * 255; + out.data[i + 1] = ((dy / len) * 0.5 + 0.5) * 255; + out.data[i + 2] = (1 / len) * 0.5 + 0.5 > 1 ? 255 : ((1 / len) * 0.5 + 0.5) * 255; + out.data[i + 3] = 255; + } + } + ctx.putImageData(out, 0, 0); + return c; +} + +function scratches(ctx, rand, n, w, h, color, alpha, maxLen = 90) { + ctx.save(); + ctx.strokeStyle = color; + for (let i = 0; i < n; i++) { + ctx.globalAlpha = alpha * (0.3 + rand() * 0.7); + ctx.lineWidth = rand() < 0.8 ? 1 : 2; + const x = rand() * w, y = rand() * h; + const a = rand() * Math.PI * 2, l = 6 + rand() * maxLen; + ctx.beginPath(); + ctx.moveTo(x, y); + ctx.lineTo(x + Math.cos(a) * l, y + Math.sin(a) * l); + ctx.stroke(); + } + ctx.restore(); +} + +function stains(ctx, rand, n, w, h, color, alpha, maxR = 60) { + ctx.save(); + for (let i = 0; i < n; i++) { + const x = rand() * w, y = rand() * h, r = 8 + rand() * maxR; + const g = ctx.createRadialGradient(x, y, 0, x, y, r); + const a = alpha * (0.3 + rand() * 0.7); + g.addColorStop(0, color.replace('A', a.toFixed(3))); + g.addColorStop(1, color.replace('A', '0')); + ctx.fillStyle = g; + ctx.fillRect(x - r, y - r, r * 2, r * 2); + } + ctx.restore(); +} + +function bolt(ctx, hctx, x, y, r = 4) { + ctx.fillStyle = 'rgba(40,42,46,0.85)'; + ctx.beginPath(); ctx.arc(x, y, r, 0, 7); ctx.fill(); + ctx.fillStyle = 'rgba(150,150,155,0.9)'; + ctx.beginPath(); ctx.arc(x - r * 0.25, y - r * 0.25, r * 0.55, 0, 7); ctx.fill(); + if (hctx) { + hctx.fillStyle = '#2a2a2a'; + hctx.beginPath(); hctx.arc(x, y, r + 1, 0, 7); hctx.fill(); + hctx.fillStyle = '#b0b0b0'; + hctx.beginPath(); hctx.arc(x, y, r * 0.6, 0, 7); hctx.fill(); + } +} + +// --------------------------------------------------------------------------- +// Painted hull panels. Texture covers 4.8m x 2.5m (4 cols x 2 rows of panels). +// --------------------------------------------------------------------------- +export function makeHullMaps(rand, { base = [42, 12, 0.62], accent = '#b85c1e', size = 1024 } = {}) { + const W = size, H = Math.round(size * (2.5 / 4.8)); + const [c, ctx] = cv(W, H); + const [hc, hctx] = cv(W, H); + const [rc, rctx] = cv(W, H); + + hctx.fillStyle = '#7a7a7a'; hctx.fillRect(0, 0, W, H); + rctx.fillStyle = '#9c9c9c'; rctx.fillRect(0, 0, W, H); + + const cols = 4, rows = 2; + const pw = W / cols, ph = H / rows; + + for (let i = 0; i < cols; i++) { + for (let j = 0; j < rows; j++) { + const x = i * pw, y = j * ph; + const [hh, ss, ll] = base; + const dl = (rand() - 0.5) * 0.07; + const isAccent = rand() < 0.10; + ctx.fillStyle = isAccent ? accent : `hsl(${hh + (rand() - 0.5) * 8}, ${ss}%, ${(ll + dl) * 100}%)`; + ctx.fillRect(x, y, pw, ph); + + // panel inner inset + bevel + ctx.strokeStyle = 'rgba(0,0,0,0.32)'; + ctx.lineWidth = 3; + ctx.strokeRect(x + 10, y + 10, pw - 20, ph - 20); + ctx.strokeStyle = 'rgba(255,255,255,0.10)'; + ctx.lineWidth = 1.5; + ctx.strokeRect(x + 13, y + 13, pw - 26, ph - 26); + + hctx.fillStyle = '#6a6a6a'; + hctx.fillRect(x + 10, y + 10, pw - 20, ph - 20); + hctx.fillStyle = '#7e7e7e'; + hctx.fillRect(x + 16, y + 16, pw - 32, ph - 32); + + // some panels get a vent or a stripe or a label block + const det = rand(); + if (det < 0.22) { + // vent slots + const vx = x + pw * 0.25, vy = y + ph * (0.3 + rand() * 0.35), vw = pw * 0.5; + for (let k = 0; k < 5; k++) { + ctx.fillStyle = 'rgba(20,22,25,0.85)'; + ctx.fillRect(vx, vy + k * 9, vw, 4.5); + hctx.fillStyle = '#404040'; + hctx.fillRect(vx, vy + k * 9, vw, 4.5); + } + } else if (det < 0.40) { + // accent stripe + ctx.fillStyle = rand() < 0.6 ? accent : '#3d6e6c'; + const sy = y + ph * (0.18 + rand() * 0.5); + ctx.fillRect(x + 16, sy, pw - 32, 10 + rand() * 8); + ctx.globalAlpha = 0.25; + ctx.fillStyle = '#1c1c1c'; + for (let k = 0; k < 14; k++) ctx.fillRect(x + 16 + rand() * (pw - 36), sy + rand() * 14, 3 + rand() * 6, 2); + ctx.globalAlpha = 1; + } else if (det < 0.52) { + // stenciled label block + ctx.fillStyle = 'rgba(35,38,42,0.78)'; + const lx = x + pw * (0.1 + rand() * 0.4), ly = y + ph * (0.15 + rand() * 0.55); + for (let k = 0; k < 3 + rand() * 4; k++) { + ctx.fillRect(lx + k * 11, ly, 7, 12 + rand() * 6); + } + if (rand() < 0.5) { + ctx.fillStyle = accent; + ctx.fillRect(lx - 4, ly + 22, 30 + rand() * 30, 4); + } + } + + // corner bolts + bolt(ctx, hctx, x + 16, y + 16, 4); + bolt(ctx, hctx, x + pw - 16, y + 16, 4); + bolt(ctx, hctx, x + 16, y + ph - 16, 4); + bolt(ctx, hctx, x + pw - 16, y + ph - 16, 4); + + // roughness: painted = mid, with per-panel variation + rctx.fillStyle = `rgb(${140 + ((rand() * 40) | 0)},0,0)`; + const rv = 145 + ((rand() - 0.5) * 50) | 0; + rctx.fillStyle = `rgb(${rv},${rv},${rv})`; + rctx.fillRect(x + 2, y + 2, pw - 4, ph - 4); + } + } + + // seams between panels + ctx.strokeStyle = 'rgba(12,13,15,0.9)'; + ctx.lineWidth = 4; + hctx.strokeStyle = '#1e1e1e'; + hctx.lineWidth = 5; + for (let i = 0; i <= cols; i++) { + ctx.beginPath(); ctx.moveTo(i * pw, 0); ctx.lineTo(i * pw, H); ctx.stroke(); + hctx.beginPath(); hctx.moveTo(i * pw, 0); hctx.lineTo(i * pw, H); hctx.stroke(); + } + for (let j = 0; j <= rows; j++) { + ctx.beginPath(); ctx.moveTo(0, j * ph); ctx.lineTo(W, j * ph); ctx.stroke(); + hctx.beginPath(); hctx.moveTo(0, j * ph); hctx.lineTo(W, j * ph); hctx.stroke(); + } + + // grime: multiply noise, stronger near seams + const n = noiseCanvas(rand, 256, 5); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.38; + ctx.drawImage(n, 0, 0, W, H); + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + stains(ctx, rand, 26, W, H, 'rgba(48,40,30,A)', 0.34, 70); + stains(ctx, rand, 12, W, H, 'rgba(20,22,26,A)', 0.22, 40); + scratches(ctx, rand, 70, W, H, 'rgba(190,192,196,0.8)', 0.5, 60); + scratches(ctx, rand, 40, W, H, 'rgba(30,30,32,0.7)', 0.35, 80); + + // scratches make it shinier; grime rougher + scratches(rctx, rand, 70, W, H, 'rgba(70,70,70,1)', 0.5, 60); + rctx.globalCompositeOperation = 'lighten'; + rctx.globalAlpha = 0.35; + rctx.drawImage(n, 0, 0, W, H); + rctx.globalCompositeOperation = 'source-over'; + rctx.globalAlpha = 1; + + return { + map: tex(c), + roughnessMap: tex(rc, { srgb: false }), + normalMap: tex(normalFromHeight(hc, 2.0), { srgb: false }), + }; +} + +// --------------------------------------------------------------------------- +// Worn structural metal, 1m x 1m. +// --------------------------------------------------------------------------- +export function makeMetalMaps(rand, { tone = 96, brushed = true, size = 512 } = {}) { + const [c, ctx] = cv(size); + const [rc, rctx] = cv(size); + const [hc, hctx] = cv(size); + ctx.fillStyle = `rgb(${tone},${tone + 2},${tone + 6})`; + ctx.fillRect(0, 0, size, size); + hctx.fillStyle = '#808080'; hctx.fillRect(0, 0, size, size); + rctx.fillStyle = '#6e6e6e'; rctx.fillRect(0, 0, size, size); + + if (brushed) { + for (let i = 0; i < 420; i++) { + const y = rand() * size; + const a = 0.04 + rand() * 0.10; + const lum = rand() < 0.5 ? 255 : 0; + ctx.strokeStyle = `rgba(${lum},${lum},${lum},${a})`; + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.moveTo(0, y); ctx.lineTo(size, y); + ctx.stroke(); + rctx.strokeStyle = `rgba(${lum > 0 ? 60 : 140},${lum > 0 ? 60 : 140},${lum > 0 ? 60 : 140},${a * 1.4})`; + rctx.beginPath(); rctx.moveTo(0, y); rctx.lineTo(size, y); rctx.stroke(); + } + } + + const n = noiseCanvas(rand, 128, 4); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.32; + ctx.drawImage(n, 0, 0, size, size); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + + stains(ctx, rand, 16, size, size, 'rgba(30,26,20,A)', 0.4, 60); + scratches(ctx, rand, 90, size, size, 'rgba(210,212,218,0.9)', 0.45, 70); + scratches(ctx, rand, 50, size, size, 'rgba(25,25,28,0.8)', 0.4, 50); + scratches(rctx, rand, 90, size, size, 'rgba(55,55,55,1)', 0.5, 70); + rctx.globalCompositeOperation = 'lighten'; + rctx.globalAlpha = 0.45; + rctx.drawImage(n, 0, 0, size, size); + rctx.globalCompositeOperation = 'source-over'; + rctx.globalAlpha = 1; + stains(rctx, rand, 16, size, size, 'rgba(200,200,200,A)', 0.5, 60); + + return { + map: tex(c), + roughnessMap: tex(rc, { srgb: false }), + normalMap: tex(normalFromHeight(noiseCanvas(rand, 256, 5), 0.8), { srgb: false }), + }; +} + +// --------------------------------------------------------------------------- +// Deck floor: tread plate, 2.4m x 2.4m (2x2 plates of 1.2m). +// --------------------------------------------------------------------------- +export function makeFloorMaps(rand, { size = 1024 } = {}) { + const [c, ctx] = cv(size); + const [hc, hctx] = cv(size); + const [rc, rctx] = cv(size); + ctx.fillStyle = 'rgb(70,72,78)'; + ctx.fillRect(0, 0, size, size); + hctx.fillStyle = '#808080'; hctx.fillRect(0, 0, size, size); + rctx.fillStyle = '#787878'; rctx.fillRect(0, 0, size, size); + + // tread ovals + const step = size / 24; + for (let j = 0; j < 24; j++) { + for (let i = 0; i < 24; i++) { + const x = i * step + step / 2 + (j % 2 ? step / 2 : 0); + const y = j * step + step / 2; + const ang = (i + j) % 2 ? 0.78 : -0.78; + ctx.save(); hctx.save(); + ctx.translate(x % size, y); ctx.rotate(ang); + hctx.translate(x % size, y); hctx.rotate(ang); + ctx.fillStyle = 'rgba(86,88,94,0.9)'; + ctx.fillRect(-9, -3, 18, 6); + ctx.fillStyle = 'rgba(30,31,34,0.55)'; + ctx.fillRect(-9, 2, 18, 2); + hctx.fillStyle = '#b4b4b4'; + hctx.fillRect(-9, -3, 18, 6); + ctx.restore(); hctx.restore(); + } + } + + // plate seams every half texture (1.2 m) + for (const p of [0, size / 2, size]) { + ctx.strokeStyle = 'rgba(10,11,13,0.95)'; ctx.lineWidth = 6; + ctx.beginPath(); ctx.moveTo(p, 0); ctx.lineTo(p, size); ctx.stroke(); + ctx.beginPath(); ctx.moveTo(0, p); ctx.lineTo(size, p); ctx.stroke(); + hctx.strokeStyle = '#262626'; hctx.lineWidth = 7; + hctx.beginPath(); hctx.moveTo(p, 0); hctx.lineTo(p, size); hctx.stroke(); + hctx.beginPath(); hctx.moveTo(0, p); hctx.lineTo(size, p); hctx.stroke(); + } + for (const p of [0, size / 2, size]) { + for (const q of [size * 0.08, size * 0.42, size * 0.58, size * 0.92]) { + bolt(ctx, hctx, Math.min(Math.max(p + (p === 0 ? 14 : p === size ? -14 : 0), 8), size - 8), q, 5); + } + } + + // central wear path (lighter, smoother) — runs along V + const wear = ctx.createLinearGradient(0, 0, size, 0); + wear.addColorStop(0.0, 'rgba(150,150,154,0)'); + wear.addColorStop(0.5, 'rgba(150,150,154,0.07)'); + wear.addColorStop(1.0, 'rgba(150,150,154,0)'); + ctx.fillStyle = wear; + ctx.fillRect(0, 0, size, size); + const wearR = rctx.createLinearGradient(0, 0, size, 0); + wearR.addColorStop(0.0, 'rgba(64,64,64,0)'); + wearR.addColorStop(0.5, 'rgba(64,64,64,0.5)'); + wearR.addColorStop(1.0, 'rgba(64,64,64,0)'); + rctx.fillStyle = wearR; + rctx.fillRect(0, 0, size, size); + + const n = noiseCanvas(rand, 256, 5); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.4; + ctx.drawImage(n, 0, 0, size, size); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + stains(ctx, rand, 30, size, size, 'rgba(22,20,16,A)', 0.5, 80); + scratches(ctx, rand, 130, size, size, 'rgba(180,182,188,0.8)', 0.4, 90); + scratches(rctx, rand, 130, size, size, 'rgba(60,60,60,1)', 0.5, 90); + + return { + map: tex(c), + roughnessMap: tex(rc, { srgb: false }), + normalMap: tex(normalFromHeight(hc, 2.2), { srgb: false }), + }; +} + +// --------------------------------------------------------------------------- +// Fabric (mattress / blanket / cushion). 0.5m tile. +// --------------------------------------------------------------------------- +export function makeFabricMaps(rand, { color = '#cfc6b4', size = 256 } = {}) { + const [c, ctx] = cv(size); + ctx.fillStyle = color; + ctx.fillRect(0, 0, size, size); + // weave + for (let y = 0; y < size; y += 3) { + ctx.fillStyle = `rgba(0,0,0,${0.05 + (y % 6 === 0 ? 0.05 : 0)})`; + ctx.fillRect(0, y, size, 1); + } + for (let x = 0; x < size; x += 3) { + ctx.fillStyle = 'rgba(255,255,255,0.045)'; + ctx.fillRect(x, 0, 1, size); + } + const n = noiseCanvas(rand, 64, 3); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.22; + ctx.drawImage(n, 0, 0, size, size); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + // quilt seams + ctx.strokeStyle = 'rgba(0,0,0,0.20)'; + ctx.lineWidth = 2; + for (const p of [0, size / 2]) { + ctx.beginPath(); ctx.moveTo(p, 0); ctx.lineTo(p, size); ctx.stroke(); + ctx.beginPath(); ctx.moveTo(0, p); ctx.lineTo(size, p); ctx.stroke(); + } + const [hcq, hq] = cv(size); + hq.fillStyle = '#888'; hq.fillRect(0, 0, size, size); + hq.strokeStyle = '#404040'; hq.lineWidth = 3; + for (const p of [0, size / 2]) { + hq.beginPath(); hq.moveTo(p, 0); hq.lineTo(p, size); hq.stroke(); + hq.beginPath(); hq.moveTo(0, p); hq.lineTo(size, p); hq.stroke(); + } + hq.globalAlpha = 0.6; hq.drawImage(noiseCanvas(rand, 128, 4), 0, 0, size, size); + return { + map: tex(c), + normalMap: tex(normalFromHeight(hcq, 1.2), { srgb: false }), + }; +} + +// --------------------------------------------------------------------------- +// Floor grate alpha pattern. +// --------------------------------------------------------------------------- +export function makeGrateMaps(rand, { size = 256 } = {}) { + const [c, ctx] = cv(size); + const [ac, actx] = cv(size); + actx.fillStyle = '#000'; actx.fillRect(0, 0, size, size); + ctx.fillStyle = 'rgb(52,54,58)'; ctx.fillRect(0, 0, size, size); + const bar = size / 8; + actx.fillStyle = '#fff'; + for (let i = 0; i < 8; i++) { + actx.fillRect(0, i * bar, size, bar * 0.42); + actx.fillRect(i * bar, 0, bar * 0.42, size); + } + const n = noiseCanvas(rand, 64, 3); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.5; + ctx.drawImage(n, 0, 0, size, size); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + scratches(ctx, rand, 40, size, size, 'rgba(190,190,195,0.8)', 0.5, 40); + return { map: tex(c), alphaMap: tex(ac, { srgb: false }) }; +} + +// --------------------------------------------------------------------------- +// Hazard stripes (door trims), 1m x 0.25m strip. +// --------------------------------------------------------------------------- +export function makeHazardMap(rand, { size = 512 } = {}) { + const H = size / 4; + const [c, ctx] = cv(size, H); + ctx.fillStyle = '#c46a1f'; + ctx.fillRect(0, 0, size, H); + ctx.fillStyle = '#16181b'; + for (let x = -H; x < size + H; x += H) { + ctx.beginPath(); + ctx.moveTo(x, H); ctx.lineTo(x + H * 0.6, H); ctx.lineTo(x + H * 0.6 + H, 0); ctx.lineTo(x + H, 0); + ctx.closePath(); ctx.fill(); + } + const n = noiseCanvas(rand, 64, 3); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.35; + ctx.drawImage(n, 0, 0, size, H); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + scratches(ctx, rand, 30, size, H, 'rgba(200,200,205,0.9)', 0.6, 50); + return tex(c); +} + +// --------------------------------------------------------------------------- +// Cockpit / wall screens (emissive UI). +// --------------------------------------------------------------------------- +export function makeScreenMap(rand, kind = 'nav', { w = 512, h = 320 } = {}) { + const [c, ctx] = cv(w, h); + ctx.fillStyle = '#04090d'; + ctx.fillRect(0, 0, w, h); + ctx.strokeStyle = 'rgba(25,212,208,0.5)'; + ctx.lineWidth = 3; + ctx.strokeRect(6, 6, w - 12, h - 12); + const teal = 'rgba(36,222,214,', orange = 'rgba(255,150,60,'; + if (kind === 'nav') { + // radar circle + blips + const cx = w * 0.30, cy = h * 0.52, R = h * 0.34; + for (let r = R; r > 0; r -= R / 3) { + ctx.strokeStyle = teal + '0.4)'; ctx.lineWidth = 1.5; + ctx.beginPath(); ctx.arc(cx, cy, r, 0, 7); ctx.stroke(); + } + ctx.beginPath(); ctx.moveTo(cx - R, cy); ctx.lineTo(cx + R, cy); ctx.stroke(); + ctx.beginPath(); ctx.moveTo(cx, cy - R); ctx.lineTo(cx, cy + R); ctx.stroke(); + const grad = ctx.createConicGradient ? null : null; + ctx.fillStyle = teal + '0.18)'; + ctx.beginPath(); ctx.moveTo(cx, cy); ctx.arc(cx, cy, R, -0.5, 0.45); ctx.closePath(); ctx.fill(); + for (let i = 0; i < 5; i++) { + ctx.fillStyle = i === 2 ? orange + '0.95)' : teal + '0.9)'; + const a = rand() * 6.28, r = rand() * R * 0.9; + ctx.beginPath(); ctx.arc(cx + Math.cos(a) * r, cy + Math.sin(a) * r, 3.5, 0, 7); ctx.fill(); + } + // text column + for (let i = 0; i < 9; i++) { + ctx.fillStyle = (i === 3 ? orange : teal) + (0.35 + rand() * 0.55) + ')'; + ctx.fillRect(w * 0.62, 30 + i * 28, 30 + rand() * (w * 0.3), 9); + } + } else if (kind === 'eng') { + // bar graphs + const n = 8; + for (let i = 0; i < n; i++) { + const bh = (0.25 + rand() * 0.65) * (h - 80); + ctx.fillStyle = i === 5 ? orange + '0.9)' : teal + '0.8)'; + ctx.fillRect(30 + i * ((w - 60) / n), h - 36 - bh, (w - 60) / n - 10, bh); + ctx.fillStyle = teal + '0.25)'; + ctx.fillRect(30 + i * ((w - 60) / n), 40, (w - 60) / n - 10, h - 76); + } + } else if (kind === 'wave') { + ctx.strokeStyle = teal + '0.9)'; + ctx.lineWidth = 2.5; + ctx.beginPath(); + for (let x = 14; x < w - 14; x += 4) { + const y = h * 0.5 + Math.sin(x * 0.05) * h * 0.18 + (rand() - 0.5) * h * 0.1; + x === 14 ? ctx.moveTo(x, y) : ctx.lineTo(x, y); + } + ctx.stroke(); + ctx.strokeStyle = orange + '0.7)'; + ctx.beginPath(); + for (let x = 14; x < w - 14; x += 6) { + const y = h * 0.72 + Math.cos(x * 0.03) * h * 0.08; + x === 14 ? ctx.moveTo(x, y) : ctx.lineTo(x, y); + } + ctx.stroke(); + for (let i = 0; i < 4; i++) { + ctx.fillStyle = teal + '0.6)'; + ctx.fillRect(20 + i * (w / 4.4), 18, w / 6, 8); + } + } else { // 'text' terminal + for (let i = 0; i < 12; i++) { + ctx.fillStyle = (rand() < 0.15 ? orange : teal) + (0.3 + rand() * 0.6) + ')'; + let x = 20; + const words = 2 + (rand() * 5) | 0; + for (let k = 0; k < words; k++) { + const ww = 14 + rand() * 70; + ctx.fillRect(x, 20 + i * ((h - 40) / 12), ww, 8); + x += ww + 12; + if (x > w - 40) break; + } + } + } + // scanlines + ctx.fillStyle = 'rgba(0,0,0,0.22)'; + for (let y = 0; y < h; y += 4) ctx.fillRect(0, y, w, 1.5); + return tex(c); +} + +// --------------------------------------------------------------------------- +// Space: gas giant texture (equirect bands). +// --------------------------------------------------------------------------- +export function makePlanetMap(rand, { hueA = 16, hueB = 36, size = 1024 } = {}) { + const W = size, H = size / 2; + const [c, ctx] = cv(W, H); + // banded base + let y = 0; + while (y < H) { + const bh = H * (0.03 + rand() * 0.10); + const t = y / H; + const hue = hueA + (hueB - hueA) * (0.5 + 0.5 * Math.sin(t * 9 + rand() * 2)); + const sat = 44 + rand() * 30; + const lit = 34 + rand() * 32 - Math.abs(t - 0.5) * 24; + ctx.fillStyle = `hsl(${hue}, ${sat}%, ${lit}%)`; + ctx.fillRect(0, y, W, bh + 1); + y += bh; + } + // turbulence: horizontal smearing of noise + const n = noiseCanvas(rand, 256, 5); + for (let i = 0; i < 7; i++) { + ctx.globalAlpha = 0.10; + ctx.globalCompositeOperation = i % 2 ? 'overlay' : 'multiply'; + ctx.drawImage(n, -i * 37, 0, W * 2.2, H); + } + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + // storm ovals + for (let i = 0; i < 7; i++) { + const x = rand() * W, yy = H * (0.25 + rand() * 0.5); + const rw = 18 + rand() * 60, rh = rw * (0.3 + rand() * 0.3); + const g = ctx.createRadialGradient(x, yy, 0, x, yy, rw); + g.addColorStop(0, `hsla(${hueB + 10}, 50%, ${55 + rand() * 18}%, 0.55)`); + g.addColorStop(1, 'hsla(30, 40%, 50%, 0)'); + ctx.save(); + ctx.translate(x, yy); ctx.scale(1, rh / rw); ctx.translate(-x, -yy); + ctx.fillStyle = g; + ctx.fillRect(x - rw, yy - rw, rw * 2, rw * 2); + ctx.restore(); + } + const t = tex(c); + t.wrapS = THREE.RepeatWrapping; + t.wrapT = THREE.ClampToEdgeWrapping; + return t; +} + +export function makeRockyMap(rand, { size = 512 } = {}) { + const W = size, H = size / 2; + const [c, ctx] = cv(W, H); + ctx.fillStyle = 'hsl(206, 18%, 38%)'; + ctx.fillRect(0, 0, W, H); + const n = noiseCanvas(rand, 256, 6); + ctx.globalCompositeOperation = 'overlay'; + ctx.globalAlpha = 0.9; + ctx.drawImage(n, 0, 0, W, H); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.5; + ctx.drawImage(n, -W * 0.3, 0, W * 1.8, H); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + // craters + for (let i = 0; i < 40; i++) { + const x = rand() * W, y = rand() * H, r = 2 + rand() * 14; + ctx.fillStyle = 'rgba(20,24,30,0.35)'; + ctx.beginPath(); ctx.arc(x, y, r, 0, 7); ctx.fill(); + ctx.fillStyle = 'rgba(190,200,210,0.25)'; + ctx.beginPath(); ctx.arc(x, y - r * 0.35, r * 0.75, 0, 7); ctx.fill(); + } + // ice caps + const g = ctx.createLinearGradient(0, 0, 0, H); + g.addColorStop(0, 'rgba(225,235,240,0.9)'); + g.addColorStop(0.12, 'rgba(225,235,240,0)'); + g.addColorStop(0.88, 'rgba(225,235,240,0)'); + g.addColorStop(1, 'rgba(225,235,240,0.85)'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, W, H); + const t = tex(c); + t.wrapS = THREE.RepeatWrapping; + t.wrapT = THREE.ClampToEdgeWrapping; + return t; +} + +// Soft round sprite for stars. +export function makeStarSprite() { + const [c, ctx] = cv(64); + const g = ctx.createRadialGradient(32, 32, 0, 32, 32, 32); + g.addColorStop(0, 'rgba(255,255,255,1)'); + g.addColorStop(0.25, 'rgba(255,255,255,0.85)'); + g.addColorStop(0.6, 'rgba(255,255,255,0.18)'); + g.addColorStop(1, 'rgba(255,255,255,0)'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 64, 64); + return tex(c, { srgb: false }); +} + +// Nebula cloud billboard. +export function makeNebulaSprite(rand, colA = [185, 70, 50], colB = [22, 80, 60], size = 512) { + const [c, ctx] = cv(size); + const blobs = 60; + for (let i = 0; i < blobs; i++) { + const t = i / blobs; + const ang = rand() * 6.28; + const dist = Math.pow(rand(), 1.6) * size * 0.32; + const x = size / 2 + Math.cos(ang) * dist; + const y = size / 2 + Math.sin(ang) * dist * 0.7; + const r = size * (0.04 + rand() * 0.14) * (1 - dist / (size * 0.45)); + const [h1, s1, l1] = rand() < 0.5 ? colA : colB; + const g = ctx.createRadialGradient(x, y, 0, x, y, Math.max(r, 2)); + g.addColorStop(0, `hsla(${h1 + (rand() - 0.5) * 24}, ${s1}%, ${l1}%, ${0.05 + rand() * 0.07})`); + g.addColorStop(1, `hsla(${h1}, ${s1}%, ${l1 * 0.6}%, 0)`); + ctx.fillStyle = g; + ctx.fillRect(0, 0, size, size); + } + // embedded stars + for (let i = 0; i < 30; i++) { + const x = rand() * size, y = rand() * size; + ctx.fillStyle = `rgba(255,255,255,${0.2 + rand() * 0.5})`; + ctx.fillRect(x, y, 1.5, 1.5); + } + return tex(c); +} + +===== FILE: src/ship.js ===== + +// Ship interior: geometry kit-bash, PBR materials, lights, colliders, interactables. +import * as THREE from 'three'; +import { mergeGeometries } from 'three/addons/utils/BufferGeometryUtils.js'; +import { + makeHullMaps, makeMetalMaps, makeFloorMaps, makeFabricMaps, + makeGrateMaps, makeHazardMap, makeScreenMap, mulberry32, +} from './textures.js'; + +const E = new THREE.Euler(); +const Q = new THREE.Quaternion(); +const V = new THREE.Vector3(); +const ONE = new THREE.Vector3(1, 1, 1); +const M = new THREE.Matrix4(); + +class Batch { + constructor() { this.byMat = new Map(); } + add(mat, geo) { + if (geo.index) { + const ni = geo.toNonIndexed(); + geo.dispose(); + geo = ni; + } + if (!this.byMat.has(mat)) this.byMat.set(mat, []); + this.byMat.get(mat).push(geo); + } + build(group) { + for (const [mat, geos] of this.byMat) { + const merged = mergeGeometries(geos, false); + const mesh = new THREE.Mesh(merged, mat); + mesh.castShadow = !mat.transparent; + mesh.receiveShadow = true; + group.add(mesh); + for (const g of geos) g.dispose(); + } + } +} + +// Scale BoxGeometry per-face UVs to uniform world texel density. +function uvBoxWorld(g, w, h, d, su, sv, ou = 0, ov = 0) { + const uv = g.attributes.uv; + const dims = [[d, h], [d, h], [w, d], [w, d], [w, h], [w, h]]; + for (let f = 0; f < 6; f++) { + const [du, dv] = dims[f]; + for (let v = 0; v < 4; v++) { + const i = f * 4 + v; + uv.setXY(i, uv.getX(i) * du * su + ou, uv.getY(i) * dv * sv + ov); + } + } + uv.needsUpdate = true; +} + +function uvScale(g, su, sv, ou = 0, ov = 0) { + const uv = g.attributes.uv; + for (let i = 0; i < uv.count; i++) { + uv.setXY(i, uv.getX(i) * su + ou, uv.getY(i) * sv + ov); + } + uv.needsUpdate = true; +} + +export function buildShip(scene, rand) { + const group = new THREE.Group(); + const colliders = []; + const interactables = []; + const lights = []; // { light, day, night } + const emissives = []; // { mat, day, night } + const batch = new Batch(); + + // ---------------------------------------------------------------- materials + const hull = makeHullMaps(rand); + const hullLower = makeHullMaps(mulberry32((rand() * 0xffffffff) >>> 0), { base: [40, 8, 0.40] }); + const metal = makeMetalMaps(rand); + const metalDark = makeMetalMaps(rand, { tone: 58 }); + const floorMaps = makeFloorMaps(rand); + const fabricW = makeFabricMaps(rand, { color: '#cbc2ae' }); + const fabricO = makeFabricMaps(rand, { color: '#a04e1c' }); + const grate = makeGrateMaps(rand); + const hazardMap = makeHazardMap(rand); + + const mats = { + hull: new THREE.MeshStandardMaterial({ + map: hull.map, roughnessMap: hull.roughnessMap, normalMap: hull.normalMap, + roughness: 1, metalness: 0.22, envMapIntensity: 0.7, + normalScale: new THREE.Vector2(0.8, 0.8), + }), + hullLower: new THREE.MeshStandardMaterial({ + map: hullLower.map, roughnessMap: hullLower.roughnessMap, normalMap: hullLower.normalMap, + roughness: 1, metalness: 0.3, envMapIntensity: 0.6, + normalScale: new THREE.Vector2(0.8, 0.8), + }), + metal: new THREE.MeshStandardMaterial({ + map: metal.map, roughnessMap: metal.roughnessMap, normalMap: metal.normalMap, + roughness: 0.85, metalness: 0.95, envMapIntensity: 1.0, + normalScale: new THREE.Vector2(0.5, 0.5), + }), + metalDark: new THREE.MeshStandardMaterial({ + map: metalDark.map, roughnessMap: metalDark.roughnessMap, normalMap: metalDark.normalMap, + roughness: 0.9, metalness: 0.9, envMapIntensity: 0.9, + normalScale: new THREE.Vector2(0.6, 0.6), + }), + metalTube: new THREE.MeshStandardMaterial({ + map: metalDark.map, roughnessMap: metalDark.roughnessMap, + roughness: 0.9, metalness: 0.9, envMapIntensity: 0.7, side: THREE.DoubleSide, + }), + floor: new THREE.MeshStandardMaterial({ + map: floorMaps.map, roughnessMap: floorMaps.roughnessMap, normalMap: floorMaps.normalMap, + roughness: 0.9, metalness: 0.55, envMapIntensity: 1.0, + normalScale: new THREE.Vector2(1.1, 1.1), + }), + rubber: new THREE.MeshStandardMaterial({ + color: 0x1d1e20, roughness: 0.92, metalness: 0.0, envMapIntensity: 0.25, + }), + fabricWhite: new THREE.MeshStandardMaterial({ + map: fabricW.map, normalMap: fabricW.normalMap, + roughness: 0.96, metalness: 0, envMapIntensity: 0.3, + }), + fabricOrange: new THREE.MeshStandardMaterial({ + map: fabricO.map, normalMap: fabricO.normalMap, + roughness: 0.96, metalness: 0, envMapIntensity: 0.3, + }), + grate: new THREE.MeshStandardMaterial({ + map: grate.map, alphaMap: grate.alphaMap, alphaTest: 0.5, + roughness: 0.8, metalness: 0.9, side: THREE.DoubleSide, envMapIntensity: 0.6, + }), + hazard: new THREE.MeshStandardMaterial({ + map: hazardMap, roughness: 0.7, metalness: 0.3, envMapIntensity: 0.5, + }), + glass: new THREE.MeshStandardMaterial({ + color: 0x6a8fa0, roughness: 0.08, metalness: 0.0, + transparent: true, opacity: 0.06, envMapIntensity: 0.3, + depthWrite: false, side: THREE.DoubleSide, + }), + mirror: new THREE.MeshStandardMaterial({ + color: 0xc8d4d8, roughness: 0.05, metalness: 1.0, envMapIntensity: 1.8, + }), + plastic: new THREE.MeshStandardMaterial({ + color: 0xd8d4c8, roughness: 0.5, metalness: 0.1, envMapIntensity: 0.4, + }), + // emissives + stripWarm: new THREE.MeshStandardMaterial({ + color: 0x111111, emissive: 0xffd9a8, emissiveIntensity: 1.5, roughness: 0.4, + }), + stripTeal: new THREE.MeshStandardMaterial({ + color: 0x05110f, emissive: 0x19d4d0, emissiveIntensity: 2.4, roughness: 0.4, + }), + stripOrange: new THREE.MeshStandardMaterial({ + color: 0x110803, emissive: 0xff7a20, emissiveIntensity: 1.5, roughness: 0.4, + }), + ledRed: new THREE.MeshStandardMaterial({ + color: 0x110404, emissive: 0xff3020, emissiveIntensity: 1.6, roughness: 0.4, + }), + stripTealDim: new THREE.MeshStandardMaterial({ + color: 0x05110f, emissive: 0x19d4d0, emissiveIntensity: 1.0, roughness: 0.4, + }), + }; + emissives.push({ mat: mats.stripTealDim, day: 1.0, night: 1.4 }); + emissives.push({ mat: mats.stripWarm, day: 1.5, night: 0.35 }); + emissives.push({ mat: mats.stripTeal, day: 2.4, night: 3.0 }); + emissives.push({ mat: mats.stripOrange, day: 1.5, night: 1.0 }); + + const screenMats = {}; + for (const kind of ['nav', 'eng', 'wave', 'text']) { + const m = makeScreenMap(rand, kind); + screenMats[kind] = new THREE.MeshStandardMaterial({ + color: 0x000000, emissive: 0xffffff, emissiveMap: m, emissiveIntensity: 1.5, + roughness: 0.25, metalness: 0.0, + }); + emissives.push({ mat: screenMats[kind], day: 1.5, night: 0.9 }); + } + + // ------------------------------------------------------------ geometry utils + const HSU = 1 / 4.8, HSV = 1 / 2.5; // hull texture: 4.8m x 2.5m + const WALL_T = 0.12; + const CEIL = 2.5; + + function box(mat, w, h, d, x, y, z, o = {}) { + const g = new THREE.BoxGeometry(w, h, d); + if (o.hullUV) uvBoxWorld(g, w, h, d, HSU, HSV, o.ou || 0, o.ov || 0); + else if (o.texel) uvBoxWorld(g, w, h, d, o.texel, o.texel); + M.compose(V.set(x, y, z), Q.setFromEuler(E.set(o.rx || 0, o.ry || 0, o.rz || 0)), ONE); + g.applyMatrix4(M); + if (o.collide) { + g.computeBoundingBox(); + colliders.push(g.boundingBox.clone()); + } + batch.add(mat, g); + } + function cyl(mat, rTop, rBot, h, segs, x, y, z, o = {}) { + const g = new THREE.CylinderGeometry(rTop, rBot, h, segs, 1, o.open || false); + if (o.texel) uvScale(g, o.texel * Math.PI * 2 * rTop, o.texel * h); + M.compose(V.set(x, y, z), Q.setFromEuler(E.set(o.rx || 0, o.ry || 0, o.rz || 0)), ONE); + g.applyMatrix4(M); + if (o.collide) { g.computeBoundingBox(); colliders.push(g.boundingBox.clone()); } + batch.add(mat, g); + } + function torus(mat, R, r, x, y, z, o = {}) { + const g = new THREE.TorusGeometry(R, r, 8, 24, o.arc || Math.PI * 2); + M.compose(V.set(x, y, z), Q.setFromEuler(E.set(o.rx || 0, o.ry || 0, o.rz || 0)), ONE); + g.applyMatrix4(M); + batch.add(mat, g); + } + function collideBox(x1, y1, z1, x2, y2, z2) { + colliders.push(new THREE.Box3(new THREE.Vector3(x1, y1, z1), new THREE.Vector3(x2, y2, z2))); + } + + // Wall panel with a circular hole (for portholes). Local: spans length along + // +X, height from 0, hole at (0, holeY). Rotated by ry then moved to (x,0,z). + function holedPanel(mat, len, hgt, holeY, holeR, x, z, ry, uOff = 0, vOff = 0) { + const shape = new THREE.Shape(); + shape.moveTo(-len / 2, 0); + shape.lineTo(len / 2, 0); + shape.lineTo(len / 2, hgt); + shape.lineTo(-len / 2, hgt); + shape.closePath(); + const hole = new THREE.Path(); + hole.absarc(0, holeY, holeR, 0, Math.PI * 2, true); + shape.holes.push(hole); + const g = new THREE.ExtrudeGeometry(shape, { depth: WALL_T, bevelEnabled: false, curveSegments: 24 }); + uvScale(g, HSU, HSV, uOff, vOff); + g.translate(0, 0, -WALL_T / 2); + M.compose(V.set(x, 0, z), Q.setFromEuler(E.set(0, ry, 0)), ONE); + g.applyMatrix4(M); + batch.add(mat, g); + } + + // Plain wall span (lower dark band + upper hull) along Z at given x. + function wallSpanZ(x, z0, z1, ry) { + const len = z1 - z0, zc = (z0 + z1) / 2; + box(mats.hullLower, WALL_T, 0.5, len, x, 0.25, zc, { collide: true, texel: 0.5 }); + const g = new THREE.BoxGeometry(len, CEIL - 0.5, WALL_T); + uvBoxWorld(g, len, CEIL - 0.5, WALL_T, HSU, HSV, (z0 + 8) * HSU, 0.5 * HSV); + M.compose(V.set(x, (CEIL - 0.5) / 2 + 0.5, zc), Q.setFromEuler(E.set(0, ry, 0)), ONE); + g.applyMatrix4(M); + g.computeBoundingBox(); + colliders.push(g.boundingBox.clone()); + batch.add(mats.hull, g); + } + // Plain wall span along X at given z. + function wallSpanX(z, x0, x1, flip = false) { + const len = x1 - x0, xc = (x0 + x1) / 2; + box(mats.hullLower, len, 0.5, WALL_T, xc, 0.25, z, { collide: true, texel: 0.5 }); + const g = new THREE.BoxGeometry(len, CEIL - 0.5, WALL_T); + uvBoxWorld(g, len, CEIL - 0.5, WALL_T, HSU, HSV, (x0 + 8) * HSU, 0.5 * HSV); + M.compose(V.set(xc, (CEIL - 0.5) / 2 + 0.5, z), Q.setFromEuler(E.set(0, flip ? Math.PI : 0, 0)), ONE); + g.applyMatrix4(M); + g.computeBoundingBox(); + colliders.push(g.boundingBox.clone()); + batch.add(mats.hull, g); + } + + // Porthole assembly at a wall position. `dir` is outward normal sign on X. + function porthole(x, z, dir) { + torus(mats.metal, 0.46, 0.07, x - dir * 0.02, 1.6, z, { ry: Math.PI / 2 }); + torus(mats.metalDark, 0.38, 0.035, x - dir * 0.08, 1.6, z, { ry: Math.PI / 2 }); + const g = new THREE.CylinderGeometry(0.40, 0.40, 0.02, 24); + M.compose(V.set(x + dir * 0.10, 1.6, z), Q.setFromEuler(E.set(0, 0, Math.PI / 2)), ONE); + g.applyMatrix4(M); + batch.add(mats.glass, g); + for (let i = 0; i < 8; i++) { + const a = (i / 8) * Math.PI * 2 + 0.39; + cyl(mats.metalDark, 0.028, 0.028, 0.05, 8, x - dir * 0.05, 1.6 + Math.cos(a) * 0.51, z + Math.sin(a) * 0.51, { rz: Math.PI / 2 }); + } + // depth tube through the wall + cyl(mats.metalTube, 0.42, 0.42, 0.30, 18, x + dir * 0.06, 1.6, z, { rz: Math.PI / 2, open: true }); + } + + // ========================================================================= + // CORRIDOR x[-1.2,1.2] z[-8,8] + // ========================================================================= + const CW = 1.2; + + { + // width 1.6 / length 16.0: butt-joints against the trenches and the + // cockpit floor instead of overlapping them coplanar at y=0 + const g = new THREE.BoxGeometry(1.6, 0.1, 16.0); + uvBoxWorld(g, 1.6, 0.1, 16.0, 1 / 2.4, 1 / 2.4); + M.makeTranslation(0, -0.05, 0); + g.applyMatrix4(M); + batch.add(mats.floor, g); + } + // side floor trenches with teal glow + grates + for (const s of [-1, 1]) { + box(mats.metalDark, 0.4, 0.1, 16.0, s * 1.0, -0.1, 0, { texel: 1 }); + box(mats.stripTeal, 0.34, 0.02, 15.6, s * 1.0, -0.062, 0, {}); + const g = new THREE.BoxGeometry(0.4, 0.012, 16.0); + uvBoxWorld(g, 0.4, 0.012, 16.0, 2.5, 2.5); + M.makeTranslation(s * 1.0, -0.006, 0); + g.applyMatrix4(M); + batch.add(mats.grate, g); + // wall-base edge light strips, broken at the doorways, embedded into the wall + const stripSegs = s > 0 + ? [[-7.8, 1.55], [2.85, 7.8]] + : [[-7.8, -4.05], [-2.75, 3.05], [4.15, 7.8]]; + for (const [z0, z1] of stripSegs) { + box(mats.stripTeal, 0.025, 0.03, z1 - z0, s * (CW + 0.01), 0.04, (z0 + z1) / 2, {}); + } + } + box(mats.hullLower, 2.4, 0.1, 16.4, 0, CEIL + 0.05, 0, { hullUV: true }); + + // Corridor walls. + // Right (x=+1.2, faces -x): quarters door z[1.65,2.75]; porthole z=-4. + // Left (x=-1.2, faces +x): galley door z[-3.95,-2.85]; bathroom door z[3.15,4.05]; porthole z=0.7. + const RWX = CW + WALL_T / 2; + // right wall + wallSpanZ(RWX, -8, -4.6, -Math.PI / 2); + holedPanel(mats.hull, 1.2, CEIL, 1.6, 0.43, RWX, -4.0, -Math.PI / 2); + collideBox(CW, 0, -4.6, CW + WALL_T, CEIL, -3.4); + wallSpanZ(RWX, -3.4, 1.65, -Math.PI / 2); + wallSpanZ(RWX, 2.75, 8, -Math.PI / 2); + // left wall + wallSpanZ(-RWX, -8, -3.95, Math.PI / 2); + wallSpanZ(-RWX, -2.85, 0.1, Math.PI / 2); + holedPanel(mats.hull, 1.2, CEIL, 1.6, 0.43, -RWX, 0.7, Math.PI / 2); + collideBox(-CW - WALL_T, 0, 0.1, -CW, CEIL, 1.3); + wallSpanZ(-RWX, 1.3, 3.15, Math.PI / 2); + wallSpanZ(-RWX, 4.05, 8, Math.PI / 2); + + // door headers + frames + hazard trims + function doorTrim(side, z0, z1) { + const x = side * RWX; + const len = z1 - z0, zc = (z0 + z1) / 2; + box(mats.hull, WALL_T, CEIL - 2.1, len, x, (CEIL + 2.1) / 2, zc, { collide: true, hullUV: true }); + // posts overlap 3 cm into the wall cut so no face is coplanar with the cut plane + box(mats.metalDark, 0.3, 2.16, 0.18, x, 1.05, z0 - 0.06, { texel: 1 }); + box(mats.metalDark, 0.3, 2.16, 0.18, x, 1.05, z1 + 0.06, { texel: 1 }); + box(mats.metalDark, 0.3, 0.14, len + 0.36, x, 2.16, zc, { texel: 1 }); + // vertical hazard strips on door posts (corridor side) + box(mats.hazard, 0.015, 1.8, 0.1, x - side * 0.155, 0.95, z0 - 0.06, {}); + box(mats.hazard, 0.015, 1.8, 0.1, x - side * 0.155, 0.95, z1 + 0.06, {}); + // door sign light above + box(mats.stripOrange, 0.03, 0.06, 0.45, x - side * 0.145, 2.32, zc, {}); + // threshold sill plate (covers the floor seam through the doorway) + box(mats.metalDark, 0.44, 0.02, len + 0.2, x, 0.01, zc, { texel: 2 }); + } + doorTrim(1, 1.65, 2.75); + doorTrim(-1, -3.95, -2.85); + doorTrim(-1, 3.15, 4.05); + + // corridor ribs every 2 m + for (let z = -7; z <= 7; z += 2) { + if (Math.abs(z - 2.2) < 0.8 || Math.abs(z + 3.4) < 0.8 || Math.abs(z - 3.6) < 0.8) continue; + if (Math.abs(z + 4) < 0.7 || Math.abs(z - 0.7) < 0.7) continue; // portholes + for (const s of [-1, 1]) { + box(mats.metal, 0.18, CEIL, 0.22, s * (CW - 0.09), CEIL / 2, z, { texel: 1, collide: true }); + box(mats.metal, 0.5, 0.18, 0.22, s * (CW - 0.28), CEIL - 0.22, z, { rz: s * 0.6, texel: 1 }); + box(mats.metalDark, 0.22, 0.3, 0.26, s * (CW - 0.09), 0.15, z, { texel: 1 }); + } + box(mats.metal, 2.4, 0.16, 0.22, 0, CEIL - 0.08, z, { texel: 1 }); + box(mats.stripTeal, 0.04, 0.18, 0.05, -(CW - 0.09) + 0.11, 1.65, z, {}); + box(mats.stripOrange, 0.04, 0.05, 0.05, (CW - 0.09) - 0.11, 1.65, z, {}); + } + + // ceiling light fixtures (with diffuser slats to break up the glow quad) + for (let z = -6; z <= 6; z += 3) { + // housing spans y 2.43..2.5; strip pokes ~1.5cm below it (top embedded) + box(mats.metalDark, 0.7, 0.07, 1.4, 0, CEIL - 0.035, z, { texel: 1 }); + box(mats.stripWarm, 0.4, 0.02, 1.05, 0, CEIL - 0.075, z, {}); + for (let k = -2; k <= 2; k++) { + box(mats.metalDark, 0.46, 0.025, 0.05, 0, CEIL - 0.085, z + k * 0.22, {}); + } + } + for (const z of [-6, 0, 6]) { + // downlight spots: ceiling fixtures read as emissive, light pools on the deck + const pl = new THREE.SpotLight(0xffd9a8, 18, 7, 1.25, 0.7, 2); + pl.position.set(0, CEIL - 0.15, z); + pl.target.position.set(0, 0, z); + group.add(pl, pl.target); + lights.push({ light: pl, day: 18, night: 2.0 }); + } + { + const nl = new THREE.PointLight(0x2a55a0, 0, 12, 2); + nl.position.set(0, CEIL - 0.3, 0); + group.add(nl); + lights.push({ light: nl, day: 0, night: 9 }); + } + + // ceiling pipe runs + clamps + for (const s of [-1, 1]) { + const radii = [0.055, 0.04, 0.07]; + for (let i = 0; i < 3; i++) { + const r = radii[i]; + const px = s * (CW - 0.18 - i * 0.14); + cyl(i === 1 ? mats.metalDark : mats.metal, r, r, 16.0, 10, px, CEIL - 0.16 - (i === 2 ? 0.11 : 0), 0, { rx: Math.PI / 2, texel: 1 }); + } + for (let z = -7; z <= 7; z += 2) { + box(mats.metalDark, 0.46, 0.06, 0.08, s * (CW - 0.32), CEIL - 0.18, z, { texel: 1 }); + } + } + + // wall conduits + junction boxes between ribs. + // Openings (doors with frames, portholes) per side — nothing may overlap these. + const wallOpenings = { + // right wall: quarters door frame + porthole + 1: [[1.45, 2.95], [-4.75, -3.25]], + // left wall: galley door, bathroom door, porthole + [-1]: [[-4.15, -2.65], [2.95, 4.25], [0.1, 1.3]], + }; + const overlapsOpening = (s, z0, z1) => + wallOpenings[s].some(([b0, b1]) => z0 < b1 && z1 > b0); + for (let z = -7; z < 8; z += 2) { + for (const s of [-1, 1]) { + const zc = z + 1; + const x = s * (CW - 0.04); + // conduit pair spans zc ± 0.85 + if (!overlapsOpening(s, zc - 0.9, zc + 0.9)) { + cyl(mats.metalDark, 0.025, 0.025, 1.7, 8, x, 0.95, zc, { rx: Math.PI / 2 }); + cyl(mats.metalDark, 0.018, 0.018, 1.7, 8, x, 1.03, zc, { rx: Math.PI / 2 }); + // junction boxes staggered per side to break the mirror symmetry + if ((s > 0 ? (z + 7) % 4 : (z + 9) % 4) === 0 && !overlapsOpening(s, zc - 0.3, zc + 0.3)) { + box(mats.metal, 0.07, 0.34, 0.5, x, 1.3, zc, { texel: 2 }); + box(mats.stripTeal, 0.02, 0.04, 0.04, x - s * 0.05, 1.4, zc - 0.15, {}); + box(mats.ledRed, 0.02, 0.04, 0.04, x - s * 0.05, 1.4, zc, {}); + } + } + } + } + + porthole(RWX, -4.0, 1); + porthole(-RWX, 0.7, -1); + + // hazard threshold stripes on the deck at both bulkheads (within the floor + // slab so they don't hang over the side trenches) + box(mats.hazard, 1.6, 0.006, 0.18, 0, 0.003, -7.72, {}); + box(mats.hazard, 1.6, 0.006, 0.18, 0, 0.003, 7.6, {}); + // floor cable run from the maintenance recess toward engineering + cyl(mats.rubber, 0.014, 0.014, 3.6, 6, -0.72, 0.014, 5.4, { rx: Math.PI / 2 }); + cyl(mats.rubber, 0.014, 0.014, 0.5, 6, -0.95, 0.014, 5.18, { rx: Math.PI / 2, ry: 1.1 }); + for (const cz of [4.2, 5.6, 6.8]) box(mats.metalDark, 0.06, 0.025, 0.05, -0.72, 0.012, cz, {}); + // overhead grab handles, alternating sides + for (const [hz, hs] of [[-4.5, -1], [-0.5, 1], [3.4, -1]]) { + const hx = hs * 0.45; + box(mats.metalDark, 0.05, 0.16, 0.05, hx - 0.14, CEIL - 0.1, hz, {}); + box(mats.metalDark, 0.05, 0.16, 0.05, hx + 0.14, CEIL - 0.1, hz, {}); + box(mats.metal, 0.34, 0.045, 0.05, hx, CEIL - 0.2, hz, { texel: 2 }); + } + + // lived-in props: crate stack near the engineering hatch + box(mats.metalDark, 0.52, 0.52, 0.52, 0.82, 0.26, 7.3, { ry: 0.12, texel: 1, collide: true }); + box(mats.hullLower, 0.42, 0.42, 0.42, 0.80, 0.73, 7.32, { ry: -0.2, hullUV: true }); + box(mats.hazard, 0.53, 0.1, 0.53, 0.82, 0.30, 7.3, { ry: 0.12 }); + box(mats.hullLower, 0.46, 0.4, 0.46, -0.85, 0.2, 6.9, { ry: 0.35, hullUV: true, collide: true }); + box(mats.stripOrange, 0.05, 0.03, 0.05, -0.85, 0.42, 6.9, { ry: 0.35 }); + + // open maintenance recess on the left wall (panel leaning below) + { + const px = -CW - 0.02, pz = 5.2; + box(mats.rubber, 0.1, 0.9, 0.7, px, 1.15, pz, {}); + cyl(mats.metal, 0.03, 0.03, 0.8, 8, px + 0.03, 1.15, pz - 0.15, {}); + cyl(mats.metalDark, 0.022, 0.022, 0.8, 8, px + 0.03, 1.15, pz + 0.02, {}); + cyl(mats.metalDark, 0.016, 0.016, 0.8, 8, px + 0.04, 1.15, pz + 0.16, {}); + box(mats.stripTeal, 0.03, 0.04, 0.04, px + 0.04, 1.45, pz + 0.24, {}); + box(mats.ledRed, 0.03, 0.04, 0.04, px + 0.04, 1.32, pz + 0.24, {}); + box(mats.metalDark, 0.04, 0.96, 0.76, px - 0.04, 1.15, pz, { texel: 1 }); + // leaning panel + box(mats.hull, 0.04, 0.8, 0.6, px + 0.22, 0.42, pz - 0.5, { rz: -0.28, ry: 0.1, hullUV: true, collide: true }); + } + + // ============================ COCKPIT z[-13.4,-8] ============================ + { + const bz = -8 - WALL_T / 2; + // bulkhead with center opening x[-0.7,0.7] + box(mats.hull, 1.0, CEIL, WALL_T, -1.2, CEIL / 2, bz, { hullUV: true, collide: true }); + box(mats.hull, 1.0, CEIL, WALL_T, 1.2, CEIL / 2, bz, { hullUV: true, collide: true }); + box(mats.hull, 1.4, CEIL - 2.1, WALL_T, 0, (CEIL + 2.1) / 2, bz, { hullUV: true }); + box(mats.metalDark, 0.34, 2.2, 0.3, -0.78, 1.05, bz, { collide: true, texel: 1 }); + box(mats.metalDark, 0.34, 2.2, 0.3, 0.78, 1.05, bz, { collide: true, texel: 1 }); + box(mats.metalDark, 1.9, 0.18, 0.3, 0, 2.18, bz, { texel: 1 }); + box(mats.stripWarm, 1.3, 0.05, 0.06, 0, 2.12, bz - 0.16, {}); + // corner fillers behind bulkhead (cockpit is wider than corridor) + box(mats.hull, 1.0, CEIL, WALL_T, -1.95, CEIL / 2, bz - 0.12, { hullUV: true, collide: true }); + box(mats.hull, 1.0, CEIL, WALL_T, 1.95, CEIL / 2, bz - 0.12, { hullUV: true, collide: true }); + + // floor / ceiling + { + const g = new THREE.BoxGeometry(4.6, 0.1, 5.6); + uvBoxWorld(g, 4.6, 0.1, 5.6, 1 / 2.4, 1 / 2.4); + M.makeTranslation(0, -0.05, -10.8); + g.applyMatrix4(M); + batch.add(mats.floor, g); + } + box(mats.hullLower, 4.6, 0.1, 5.6, 0, CEIL + 0.05, -10.8, { hullUV: true }); + + // tapered side walls + for (const s of [-1, 1]) { + box(mats.hull, 0.12, CEIL, 5.2, s * 1.95, CEIL / 2, -10.5, { ry: s * 0.2, hullUV: true, collide: true }); + } + + // nose: sill, header, glass panels, mullions, corner posts + const noseZ = -12.9; + box(mats.hullLower, 4.2, 0.92, 0.45, 0, 0.46, noseZ + 0.05, { hullUV: true, collide: true }); + box(mats.hullLower, 4.2, 0.4, 0.6, 0, CEIL - 0.2, noseZ + 0.1, { hullUV: true }); + // raked glass: 3 near-coplanar panels + const panels = [ + { x: 0, w: 1.06, ry: 0 }, + { x: -1.08, w: 1.1, ry: 0.22 }, + { x: 1.08, w: 1.1, ry: -0.22 }, + ]; + for (const p of panels) { + const zoff = noseZ + Math.abs(p.x) * 0.12; + const g = new THREE.BoxGeometry(p.w, 1.46, 0.04); + M.compose(V.set(p.x, 1.62, zoff), Q.setFromEuler(E.set(-0.20, p.ry, 0)), ONE); + g.applyMatrix4(M); + batch.add(mats.glass, g); + } + // mullions between panels + for (const s of [-1, 1]) { + box(mats.metalDark, 0.10, 1.62, 0.18, s * 0.55, 1.6, noseZ + 0.03, { rx: -0.20, ry: s * 0.1, texel: 1 }); + } + // corner posts sealing the angled edges + for (const s of [-1, 1]) { + box(mats.hull, 0.55, CEIL, 0.7, s * 1.78, CEIL / 2, noseZ + 0.35, { ry: s * 0.45, hullUV: true, collide: true }); + } + collideBox(-2.2, 0, noseZ - 0.5, 2.2, CEIL, noseZ + 0.3); + + // dashboard + box(mats.metalDark, 3.4, 0.16, 0.9, 0, 0.97, -12.15, { rx: -0.18, texel: 1 }); + box(mats.hullLower, 3.4, 0.55, 0.7, 0, 0.62, -12.05, { hullUV: true, collide: true }); + // screen housing bank behind the screens + { + const g = new THREE.BoxGeometry(3.0, 0.46, 0.1); + uvBoxWorld(g, 3.0, 0.46, 0.1, 1, 1); + M.compose(V.set(0, 1.21, -12.42), Q.setFromEuler(E.set(-0.42, 0, 0)), ONE); + g.applyMatrix4(M); + batch.add(mats.metalDark, g); + } + const dashScreens = [ + { x: -1.05, kind: 'nav', w: 0.62 }, { x: -0.35, kind: 'wave', w: 0.6 }, + { x: 0.35, kind: 'eng', w: 0.6 }, { x: 1.05, kind: 'text', w: 0.62 }, + ]; + for (const s of dashScreens) { + const g = new THREE.BoxGeometry(s.w, 0.34, 0.02); + M.compose(V.set(s.x, 1.22, -12.36), Q.setFromEuler(E.set(-0.42, 0, 0)), ONE); + g.applyMatrix4(M); + batch.add(screenMats[s.kind], g); + } + // buttons sit on the sloped dash plate via its local axes (matching rx so + // no face intersects the slope at a shallow angle) + { + const dashY = new THREE.Vector3(0, Math.cos(0.18), -Math.sin(0.18)); + const dashZ = new THREE.Vector3(0, Math.sin(0.18), Math.cos(0.18)); + const dashC = new THREE.Vector3(0, 0.97, -12.15); + for (let i = 0; i < 26; i++) { + const u = -1.5 + rand() * 3.0; + const v = -0.38 + rand() * 0.74; + const mat = [mats.stripTeal, mats.stripOrange, mats.ledRed][rand() * 3 | 0]; + const p = dashC.clone().addScaledVector(dashY, 0.09).addScaledVector(dashZ, v); + box(mat, 0.035, 0.025, 0.035, u, p.y, p.z, { rx: -0.18 }); + } + } + // center pedestal + throttle levers + box(mats.metalDark, 0.5, 0.7, 0.8, 0, 0.35, -11.3, { collide: true, texel: 1 }); + box(mats.metal, 0.4, 0.06, 0.7, 0, 0.73, -11.3, { texel: 1 }); + for (const s of [-1, 1]) { + cyl(mats.metalDark, 0.02, 0.02, 0.26, 8, s * 0.1, 0.85, -11.35, { rx: -0.5 }); + box(mats.stripOrange, 0.07, 0.05, 0.07, s * 0.1, 0.96, -11.42, {}); + } + + // pilot seats + for (const s of [-1, 1]) { + const sx = s * 0.62, sz = -10.7; + cyl(mats.metalDark, 0.09, 0.13, 0.35, 10, sx, 0.18, sz, {}); + box(mats.rubber, 0.56, 0.13, 0.55, sx, 0.42, sz, { collide: true }); + box(mats.fabricOrange, 0.5, 0.07, 0.48, sx, 0.52, sz, { texel: 2 }); + box(mats.rubber, 0.56, 0.75, 0.14, sx, 0.82, sz + 0.3, { rx: 0.1, collide: true }); + box(mats.fabricOrange, 0.48, 0.6, 0.06, sx, 0.84, sz + 0.235, { rx: 0.1, texel: 2 }); + box(mats.rubber, 0.3, 0.2, 0.1, sx, 1.28, sz + 0.34, { rx: 0.1 }); + for (const a of [-1, 1]) box(mats.metalDark, 0.06, 0.05, 0.4, sx + a * 0.3, 0.62, sz + 0.05, { texel: 2 }); + } + + // overhead switch panel — switches placed on the panel's tilted underside + // using its local axes so they sit flush on the slope + box(mats.metalDark, 1.4, 0.06, 0.6, 0, CEIL - 0.28, -11.9, { rx: 0.3, texel: 1 }); + { + const panY = new THREE.Vector3(0, Math.cos(0.3), Math.sin(0.3)); + const panZ = new THREE.Vector3(0, -Math.sin(0.3), Math.cos(0.3)); + const panC = new THREE.Vector3(0, CEIL - 0.28, -11.9); + for (let i = 0; i < 12; i++) { + const mat = [mats.stripTeal, mats.stripWarm, mats.stripOrange][rand() * 3 | 0]; + const row = (i / 6) | 0; + const p = panC.clone() + .addScaledVector(panY, -0.04) + .addScaledVector(panZ, row === 0 ? -0.14 : 0.12); + box(mat, 0.04, 0.02, 0.04, -0.6 + (i % 6) * 0.24, p.y, p.z, { rx: 0.3 }); + } + } + + // side consoles + for (const s of [-1, 1]) { + box(mats.hullLower, 0.5, 0.85, 1.8, s * 1.58, 0.42, -10.6, { ry: s * 0.2, hullUV: true, collide: true }); + const g = new THREE.BoxGeometry(0.44, 0.3, 0.02); + M.compose(V.set(s * 1.47, 0.885, -10.6), Q.setFromEuler(E.set(-1.25, s * 0.2, 0)), ONE); + g.applyMatrix4(M); + batch.add(screenMats[s > 0 ? 'eng' : 'text'], g); + } + + // lights + box(mats.stripWarm, 0.6, 0.02, 0.3, 0, CEIL - 0.06, -9.0, {}); + const cl = new THREE.PointLight(0xffd0a0, 9, 6, 2); + cl.position.set(0, CEIL - 0.4, -9.2); + group.add(cl); + lights.push({ light: cl, day: 9, night: 1.2 }); + const cg = new THREE.PointLight(0x2ad2cc, 3, 3, 2); + cg.position.set(0, 1.25, -11.9); + group.add(cg); + lights.push({ light: cg, day: 3, night: 2.2 }); + // cool space fill spilling in through the viewport + const wf = new THREE.PointLight(0x9fc8e8, 4, 5, 2); + wf.position.set(0, 1.6, -12.4); + group.add(wf); + lights.push({ light: wf, day: 4, night: 4 }); + } + + // ============================ REAR BULKHEAD z=8 ============================ + { + const z = 8 + WALL_T / 2; + box(mats.hull, 2.6, CEIL, WALL_T, 0, CEIL / 2, z, { hullUV: true, collide: true }); + torus(mats.metal, 0.78, 0.1, 0, 1.25, z - 0.12, {}); + cyl(mats.metalDark, 0.72, 0.72, 0.08, 24, 0, 1.25, z - 0.1, { rx: Math.PI / 2, texel: 1 }); + for (let i = 0; i < 6; i++) { + const a = (i / 6) * Math.PI * 2; + box(mats.metal, 0.1, 0.62, 0.06, Math.cos(a) * 0.35, 1.25 + Math.sin(a) * 0.35, z - 0.16, { rz: a + Math.PI / 2, texel: 2 }); + } + torus(mats.metal, 0.2, 0.035, 0, 1.25, z - 0.22, {}); + cyl(mats.metalDark, 0.05, 0.05, 0.16, 8, 0, 1.25, z - 0.18, { rx: Math.PI / 2 }); + // hazard band above hatch + box(mats.hazard, 2.3, 0.18, 0.03, 0, 2.32, z - 0.09, {}); + box(mats.ledRed, 0.1, 0.06, 0.05, -0.9, 2.14, z - 0.1, {}); + box(mats.stripOrange, 0.1, 0.06, 0.05, 0.9, 2.14, z - 0.1, {}); + for (const s of [-1, 1]) { + cyl(mats.metal, 0.06, 0.06, 1.6, 10, s * 1.0, 1.9, z - 0.16, { rz: s * 1.0, texel: 1 }); + cyl(mats.metal, 0.06, 0.06, 1.2, 10, s * 0.5, 0.5, z - 0.16, { rz: s * 2.2, texel: 1 }); + torus(mats.metal, 0.09, 0.02, s * 0.9, 0.7, z - 0.24, {}); + } + collideBox(-1.3, 0, 7.85, 1.3, CEIL, 8.3); + } + + // ============================ CREW QUARTERS x[1.2,5.6] z[1.2,6.4] ========== + { + const x0 = 1.2 + WALL_T, x1 = 5.6, z0 = 1.2, z1 = 6.4; + const cxm = (x0 + x1) / 2, czm = (z0 + z1) / 2; + { + const g = new THREE.BoxGeometry(x1 - x0 + 0.2, 0.1, z1 - z0 + 0.2); + uvBoxWorld(g, x1 - x0, 0.1, z1 - z0, 1 / 2.4, 1 / 2.4); + M.makeTranslation(cxm, -0.05, czm); + g.applyMatrix4(M); + batch.add(mats.floor, g); + } + cyl(mats.fabricOrange, 0.8, 0.8, 0.025, 20, 3.0, 0.012, 3.4, { texel: 1 }); + box(mats.hullLower, x1 - x0 + 0.2, 0.1, z1 - z0 + 0.2, cxm, CEIL + 0.05, czm, { hullUV: true }); + + // outer wall x=5.6 with porthole at z=4.4 + const OWX = x1 + WALL_T / 2; + wallSpanZ(OWX, z0, 3.8, Math.PI / 2); + holedPanel(mats.hull, 1.2, CEIL, 1.6, 0.43, OWX, 4.4, Math.PI / 2); + collideBox(x1, 0, 3.8, x1 + WALL_T, CEIL, 5.0); + wallSpanZ(OWX, 5.0, z1, Math.PI / 2); + porthole(OWX, 4.4, 1); + // far + near walls + wallSpanX(z1 + WALL_T / 2, x0 - 0.15, x1 + 0.15, true); + wallSpanX(z0 - WALL_T / 2, x0 - 0.15, x1 + 0.15, false); + + // bunk against far wall + const bedX = 4.35, bedZ = 5.75; + box(mats.metalDark, 2.3, 0.4, 1.15, bedX, 0.2, bedZ, { collide: true, texel: 1 }); + box(mats.fabricWhite, 2.24, 0.18, 1.05, bedX, 0.49, bedZ, { texel: 2 }); + box(mats.fabricOrange, 1.5, 0.08, 1.07, bedX - 0.38, 0.60, bedZ, { texel: 2 }); + box(mats.fabricWhite, 0.5, 0.12, 0.7, bedX + 0.82, 0.61, bedZ, { ry: 0.08, texel: 2 }); + for (let i = 0; i < 3; i++) { + box(mats.hullLower, 0.68, 0.26, 0.04, bedX - 0.72 + i * 0.74, 0.18, bedZ - 0.595, { hullUV: true }); + box(mats.metal, 0.3, 0.03, 0.03, bedX - 0.72 + i * 0.74, 0.18, bedZ - 0.615, {}); + } + box(mats.stripTeal, 0.03, 0.03, 1.1, 5.59, 1.45, bedZ, {}); + box(mats.metalDark, 0.3, 0.04, 1.1, 5.46, 1.25, bedZ, { texel: 1 }); + cyl(mats.metal, 0.06, 0.06, 0.18, 10, 5.46, 1.36, bedZ - 0.3, { texel: 2 }); + box(mats.fabricOrange, 0.14, 0.18, 0.1, 5.46, 1.36, bedZ + 0.25, { ry: 0.4, texel: 2 }); + // wall cabinet above the bed + box(mats.hullLower, 0.4, 0.55, 1.4, 5.45, 2.05, bedZ + 0.1, { hullUV: true }); + box(mats.metal, 0.03, 0.2, 0.03, 5.24, 2.05, bedZ - 0.3, {}); + box(mats.metal, 0.03, 0.2, 0.03, 5.24, 2.05, bedZ + 0.5, {}); + box(mats.stripOrange, 0.02, 0.03, 1.2, 5.26, 1.81, bedZ + 0.1, {}); + + // lockers along near wall (backs embedded into the wall) + for (let i = 0; i < 3; i++) { + const lx = 2.2 + i * 0.78; + box(mats.hullLower, 0.72, 1.9, 0.5, lx, 0.95, z0 + 0.24, { collide: true, hullUV: true, ou: i * 0.3 }); + box(mats.metal, 0.05, 0.3, 0.03, lx + 0.25, 1.0, z0 + 0.5, {}); + for (let k = 0; k < 4; k++) box(mats.metalDark, 0.4, 0.025, 0.02, lx, 1.62 - k * 0.07, z0 + 0.495, {}); + box(i === 1 ? mats.stripTeal : mats.stripOrange, 0.08, 0.03, 0.02, lx - 0.2, 1.78, z0 + 0.495, {}); + } + + // desk + stool + wall screen + box(mats.metal, 0.6, 0.05, 1.1, 5.25, 0.78, 2.4, { collide: true, texel: 1 }); + box(mats.hullLower, 0.5, 0.76, 0.5, 5.3, 0.38, 2.7, { hullUV: true, collide: true }); + { + const qs = new THREE.BoxGeometry(0.02, 0.5, 0.8); + M.makeTranslation(5.595, 1.6, 2.4); + qs.applyMatrix4(M); + batch.add(screenMats['text'], qs); + } + cyl(mats.metalDark, 0.18, 0.22, 0.45, 12, 4.5, 0.22, 2.4, { collide: true }); + cyl(mats.fabricOrange, 0.2, 0.2, 0.06, 12, 4.5, 0.48, 2.4, { texel: 2 }); + + // reading lamp (warm key) in the far corner, clear of the porthole + cyl(mats.metalDark, 0.025, 0.04, 0.5, 8, 5.32, 1.9, 6.12, { rz: 0.5 }); + cyl(mats.metal, 0.09, 0.13, 0.16, 10, 5.2, 2.1, 6.1, { rz: 0.7, open: true }); + box(mats.stripWarm, 0.06, 0.04, 0.06, 5.2, 2.05, 6.1, {}); + const lamp = new THREE.SpotLight(0xffc890, 20, 8, 0.95, 0.55, 1.6); + lamp.position.set(5.12, 2.15, 6.05); + lamp.target.position.set(4.0, 0.5, 5.5); + lamp.castShadow = true; + lamp.shadow.mapSize.set(512, 512); + lamp.shadow.bias = -0.0015; + lamp.shadow.normalBias = 0.02; + group.add(lamp, lamp.target); + lights.push({ light: lamp, day: 20, night: 4 }); + box(mats.stripWarm, 0.5, 0.02, 0.5, 3.0, CEIL - 0.04, 3.2, {}); + const ql = new THREE.PointLight(0xffd9a8, 9, 6.5, 2); + ql.position.set(3.0, CEIL - 0.45, 3.2); + group.add(ql); + lights.push({ light: ql, day: 9, night: 1.0 }); + const qn = new THREE.PointLight(0x1980d4, 0, 7, 2); + qn.position.set(4.5, 1.0, 5.5); + group.add(qn); + lights.push({ light: qn, day: 0, night: 5 }); + + // greebles: conduit, junction, ceiling light housing + vent + cyl(mats.metalDark, 0.03, 0.03, 4.2, 8, 1.37, 2.3, czm + 0.3, { rx: Math.PI / 2 }); + box(mats.metal, 0.08, 0.3, 0.4, 1.35, 2.1, 4.0, { texel: 2 }); + box(mats.metalDark, 0.7, 0.07, 1.2, 3.0, CEIL - 0.035, 3.2, { texel: 1 }); + box(mats.metalDark, 0.5, 0.06, 0.7, 4.6, CEIL - 0.03, 2.0, { texel: 2 }); + for (let k = 0; k < 4; k++) box(mats.metal, 0.4, 0.02, 0.07, 4.6, CEIL - 0.065, 1.75 + k * 0.16, {}); + cyl(mats.metal, 0.045, 0.045, 4.0, 8, 3.4, CEIL - 0.1, 4.6, { rz: Math.PI / 2, texel: 1 }); + + // mug on desk, boots by the bed + cyl(mats.plastic, 0.035, 0.035, 0.09, 10, 5.2, 0.85, 2.2, {}); + box(mats.rubber, 0.11, 0.14, 0.3, 3.4, 0.07, 5.2, { ry: 0.3 }); + box(mats.rubber, 0.11, 0.14, 0.3, 3.65, 0.07, 5.05, { ry: -0.15 }); + + interactables.push({ + id: 'bed', + prompt: 'E: Sleep', + center: new THREE.Vector3(bedX, 0.55, bedZ), + size: new THREE.Vector3(2.4, 0.7, 1.25), + }); + } + + // ============================ GALLEY x[-5.2,-1.2] z[-5.6,-1.2] ============= + { + const x0 = -5.2, x1 = -1.2 - WALL_T, z0 = -5.6, z1 = -1.2; + const cxm = (x0 + x1) / 2, czm = (z0 + z1) / 2; + { + const g = new THREE.BoxGeometry(x1 - x0 + 0.2, 0.1, z1 - z0 + 0.2); + uvBoxWorld(g, x1 - x0, 0.1, z1 - z0, 1 / 2.4, 1 / 2.4); + M.makeTranslation(cxm, -0.05, czm); + g.applyMatrix4(M); + batch.add(mats.floor, g); + } + box(mats.hullLower, x1 - x0 + 0.2, 0.1, z1 - z0 + 0.2, cxm, CEIL + 0.05, czm, { hullUV: true }); + wallSpanZ(x0 - WALL_T / 2, z0, z1, Math.PI / 2); + wallSpanX(z0 - WALL_T / 2, x0 - 0.15, x1 + 0.15, false); + wallSpanX(z1 + WALL_T / 2, x0 - 0.15, x1 + 0.15, true); + + // counter run along x0 wall (body starts above the recessed toe-kick so + // their front faces are never coplanar) + const cD = 0.62; + box(mats.hullLower, cD, 0.76, 3.6, x0 + cD / 2, 0.48, czm, { collide: true, hullUV: true }); + box(mats.metal, cD + 0.06, 0.05, 3.66, x0 + cD / 2, 0.88, czm, { texel: 1 }); + box(mats.rubber, cD - 0.05, 0.1, 3.6, x0 + (cD - 0.05) / 2, 0.05, czm, {}); + box(mats.stripOrange, 0.02, 0.04, 3.3, x0 + cD + 0.005, 0.83, czm, {}); + for (let i = 0; i < 5; i++) { + box(mats.metal, 0.03, 0.03, 0.3, x0 + cD + 0.005, 0.68, z0 + 0.7 + i * 0.7, {}); + } + // sink + box(mats.metalDark, 0.4, 0.04, 0.5, x0 + cD / 2, 0.9, -4.5, { texel: 1 }); + cyl(mats.metal, 0.025, 0.025, 0.3, 8, x0 + 0.2, 1.0, -4.3, { rz: -0.5 }); + // cooktop with glowing rings + a pan left out + box(mats.rubber, 0.5, 0.012, 0.8, x0 + cD / 2, 0.906, -3.2, {}); + for (const dz of [-0.2, 0.2]) { + torus(mats.stripOrange, 0.11, 0.018, x0 + cD / 2, 0.915, -3.2 + dz, { rx: Math.PI / 2 }); + } + cyl(mats.metalDark, 0.13, 0.13, 0.05, 14, x0 + cD / 2, 0.94, -3.0, { open: false }); + cyl(mats.metalDark, 0.015, 0.015, 0.22, 6, x0 + cD / 2 + 0.2, 0.96, -3.0, { rz: Math.PI / 2 }); + cyl(mats.plastic, 0.035, 0.035, 0.09, 10, x0 + cD / 2 + 0.05, 0.95, -4.0, {}); + cyl(mats.plastic, 0.035, 0.035, 0.09, 10, x0 + cD / 2 - 0.12, 0.95, -3.85, {}); + // overhead cabinets + under-cabinet teal strip (backs embedded in the wall) + box(mats.hullLower, 0.45, 0.75, 3.4, x0 + 0.2, 1.95, czm, { hullUV: true }); + for (let i = 0; i < 4; i++) { + box(mats.metal, 0.03, 0.25, 0.03, x0 + 0.435, 1.95, z0 + 0.85 + i * 0.85, {}); + } + box(mats.stripTealDim, 0.012, 0.02, 3.2, x0 + 0.428, 1.56, czm, {}); + + // shelf with canisters on z0 wall (back embedded in the wall) + box(mats.metal, 1.6, 0.04, 0.35, -2.0, 1.5, z0 + 0.16, { texel: 1 }); + for (let i = 0; i < 5; i++) { + const ch = 0.16 + rand() * 0.18; + cyl(i % 2 ? mats.metal : mats.plastic, 0.07, 0.07, ch, 10, -2.7 + i * 0.36, 1.52 + ch / 2, z0 + 0.18, { texel: 2 }); + } + + // table + stools + cyl(mats.metalDark, 0.06, 0.1, 0.74, 10, -2.6, 0.37, -2.3, {}); + cyl(mats.metal, 0.55, 0.55, 0.05, 20, -2.6, 0.76, -2.3, { texel: 1, collide: true }); + for (const [sx, sz] of [[-3.3, -2.0], [-2.0, -2.8]]) { + cyl(mats.metalDark, 0.16, 0.2, 0.45, 12, sx, 0.22, sz, { collide: true }); + cyl(mats.fabricOrange, 0.18, 0.18, 0.06, 12, sx, 0.48, sz, { texel: 2 }); + } + + // wall menu screen (back embedded 5 mm into the wall) + { + const ms = new THREE.BoxGeometry(0.9, 0.55, 0.02); + M.compose(V.set(-3.0, 1.65, z1 + 0.005), Q.setFromEuler(E.set(0, Math.PI, 0)), ONE); + ms.applyMatrix4(M); + batch.add(screenMats['wave'], ms); + } + + // pendant lamp over table + cyl(mats.metalDark, 0.012, 0.012, 0.5, 6, -2.6, CEIL - 0.25, -2.3, {}); + cyl(mats.metal, 0.16, 0.05, 0.18, 12, -2.6, CEIL - 0.55, -2.3, { open: true }); + box(mats.stripWarm, 0.1, 0.03, 0.1, -2.6, CEIL - 0.62, -2.3, {}); + const pend = new THREE.SpotLight(0xffc890, 24, 7, 1.15, 0.6, 1.5); + pend.position.set(-2.6, CEIL - 0.6, -2.3); + pend.target.position.set(-2.6, 0, -2.3); + pend.castShadow = true; + pend.shadow.mapSize.set(512, 512); + pend.shadow.bias = -0.0015; + pend.shadow.normalBias = 0.02; + group.add(pend, pend.target); + lights.push({ light: pend, day: 24, night: 3 }); + const gFill = new THREE.PointLight(0xffd9a8, 8, 6, 2); + gFill.position.set(-4.2, 2.1, -3.4); + group.add(gFill); + lights.push({ light: gFill, day: 8, night: 0.9 }); + + interactables.push({ + id: 'galley', + prompt: 'E: Eat', + center: new THREE.Vector3(x0 + cD / 2, 0.7, -3.2), + size: new THREE.Vector3(0.9, 0.9, 1.3), + }); + } + + // ============================ BATHROOM x[-4.0,-1.2] z[2.6,5.4] ============= + { + const x0 = -4.0, x1 = -1.2 - WALL_T, z0 = 2.6, z1 = 5.4; + const cxm = (x0 + x1) / 2, czm = (z0 + z1) / 2; + { + const g = new THREE.BoxGeometry(x1 - x0 + 0.2, 0.1, z1 - z0 + 0.2); + uvBoxWorld(g, x1 - x0, 0.1, z1 - z0, 1 / 2.4, 1 / 2.4); + M.makeTranslation(cxm, -0.05, czm); + g.applyMatrix4(M); + batch.add(mats.floor, g); + } + box(mats.hullLower, x1 - x0 + 0.2, 0.1, z1 - z0 + 0.2, cxm, CEIL + 0.05, czm, { hullUV: true }); + wallSpanZ(x0 - WALL_T / 2, z0, z1, Math.PI / 2); + wallSpanX(z0 - WALL_T / 2, x0 - 0.15, x1 + 0.15, false); + wallSpanX(z1 + WALL_T / 2, x0 - 0.15, x1 + 0.15, true); + + // sink unit (backs embedded into the wall) + box(mats.hullLower, 0.45, 0.8, 0.9, x0 + 0.21, 0.45, 4.6, { collide: true, hullUV: true }); + box(mats.metal, 0.5, 0.06, 0.95, x0 + 0.23, 0.88, 4.6, { texel: 1 }); + cyl(mats.metalDark, 0.16, 0.2, 0.1, 16, x0 + 0.26, 0.93, 4.6, { open: true }); + cyl(mats.metal, 0.02, 0.02, 0.25, 8, x0 + 0.12, 1.05, 4.6, { rz: -0.6 }); + box(mats.mirror, 0.02, 0.7, 0.6, x0 + 0.04, 1.55, 4.6, {}); + box(mats.metalDark, 0.04, 0.78, 0.68, x0 + 0.015, 1.55, 4.6, { texel: 1 }); + box(mats.stripTeal, 0.03, 0.03, 0.6, x0 + 0.05, 1.95, 4.6, {}); + + // toilet unit (tank embedded into the wall) + box(mats.hullLower, 0.5, 0.42, 0.42, x0 + 0.3, 0.21, 3.1, { collide: true, hullUV: true }); + cyl(mats.plastic, 0.19, 0.21, 0.06, 14, x0 + 0.3, 0.45, 3.1, {}); + box(mats.hullLower, 0.16, 0.6, 0.5, x0 + 0.05, 0.72, 3.1, { hullUV: true }); + box(mats.stripTeal, 0.03, 0.04, 0.04, x0 + 0.135, 0.85, 3.1, {}); + + // shower pod corner + box(mats.rubber, 0.9, 0.04, 0.9, -1.85, 0.02, 4.85, {}); + cyl(mats.metal, 0.07, 0.07, 0.04, 12, -1.85, 2.3, 4.85, {}); + cyl(mats.metalDark, 0.02, 0.02, 2.3, 8, -1.45, 1.15, 4.95, {}); + { + const g = new THREE.BoxGeometry(0.04, 2.0, 0.9); + M.makeTranslation(-2.32, 1.0, 4.85); + g.applyMatrix4(M); + batch.add(mats.glass, g); + collideBox(-2.36, 0, 4.4, -2.28, 2.0, 5.3); + } + + // cool light + box(mats.stripTeal, 0.4, 0.02, 0.4, cxm, CEIL - 0.04, czm, {}); + const bl = new THREE.PointLight(0x9fe8e0, 8, 5.5, 2); + bl.position.set(cxm, CEIL - 0.3, czm); + group.add(bl); + lights.push({ light: bl, day: 8, night: 2.8 }); + + interactables.push({ + id: 'bathroom', + prompt: 'E: Freshen up', + center: new THREE.Vector3(x0 + 0.35, 0.9, 4.6), + size: new THREE.Vector3(0.8, 1.2, 1.1), + }); + } + + batch.build(group); + scene.add(group); + + return { group, colliders, interactables, lights, emissives, mats }; +} + +===== FILE: src/space.js ===== + +// Exterior space: parallax starfield, planets with atmosphere rim, nebulae, sun. +import * as THREE from 'three'; +import { makeStarSprite, makeNebulaSprite, makePlanetMap, makeRockyMap } from './textures.js'; + +// Sun sits behind-starboard-high so bodies ahead/port show lit faces to the ship. +const SUN_DIR = new THREE.Vector3(0.55, 0.28, 0.79).normalize(); +export { SUN_DIR }; + +function planetMaterial(map, rimColor, rimStrength = 1.4) { + return new THREE.ShaderMaterial({ + uniforms: { + map: { value: map }, + sunDir: { value: SUN_DIR.clone() }, + rimColor: { value: new THREE.Color(rimColor) }, + rimStrength: { value: rimStrength }, + }, + vertexShader: /* glsl */` + varying vec2 vUv; + varying vec3 vNormalW; + varying vec3 vPosW; + void main() { + vUv = uv; + vNormalW = normalize(mat3(modelMatrix) * normal); + vec4 wp = modelMatrix * vec4(position, 1.0); + vPosW = wp.xyz; + gl_Position = projectionMatrix * viewMatrix * wp; + } + `, + fragmentShader: /* glsl */` + uniform sampler2D map; + uniform vec3 sunDir; + uniform vec3 rimColor; + uniform float rimStrength; + varying vec2 vUv; + varying vec3 vNormalW; + varying vec3 vPosW; + void main() { + vec3 n = normalize(vNormalW); + vec3 viewDir = normalize(cameraPosition - vPosW); + vec3 tex = texture2D(map, vUv).rgb; + float d = clamp(dot(n, sunDir) * 1.15 + 0.18, 0.0, 1.0); + d = pow(d, 0.8); + vec3 col = tex * (d * 1.35 + 0.05); + float fres = pow(1.0 - clamp(dot(n, viewDir), 0.0, 1.0), 3.0); + col += rimColor * fres * rimStrength * (d * 0.85 + 0.15); + gl_FragColor = vec4(col, 1.0); + #include + } + `, + }); +} + +function atmosphereMaterial(color, intensity = 1.0) { + return new THREE.ShaderMaterial({ + uniforms: { + atmColor: { value: new THREE.Color(color) }, + sunDir: { value: SUN_DIR.clone() }, + intensity: { value: intensity }, + }, + vertexShader: /* glsl */` + varying vec3 vNormalW; + varying vec3 vPosW; + void main() { + vNormalW = normalize(mat3(modelMatrix) * normal); + vec4 wp = modelMatrix * vec4(position, 1.0); + vPosW = wp.xyz; + gl_Position = projectionMatrix * viewMatrix * wp; + } + `, + fragmentShader: /* glsl */` + uniform vec3 atmColor; + uniform vec3 sunDir; + uniform float intensity; + varying vec3 vNormalW; + varying vec3 vPosW; + void main() { + vec3 n = normalize(vNormalW); + vec3 viewDir = normalize(cameraPosition - vPosW); + float fres = 1.0 - clamp(dot(n, viewDir), 0.0, 1.0); + float a = pow(fres, 3.4); + float lit = clamp(dot(n, sunDir) * 1.2 + 0.25, 0.05, 1.0); + vec3 col = atmColor * a * intensity * lit; + gl_FragColor = vec4(col, a * lit); + #include + } + `, + transparent: true, + blending: THREE.AdditiveBlending, + depthWrite: false, + side: THREE.FrontSide, + }); +} + +export function buildSpace(scene, rand) { + const root = new THREE.Group(); + const starSprite = makeStarSprite(); + + // -------- parallax starfield: 3 drifting layers, wrap on Z + const layers = []; + const layerDefs = [ + { count: 1300, box: 700, size: 3.4, speed: 30, opacity: 1.0 }, + { count: 700, box: 900, size: 2.4, speed: 15, opacity: 0.85 }, + { count: 280, box: 1200, size: 1.7, speed: 7, opacity: 0.7 }, + ]; + for (const def of layerDefs) { + const pos = new Float32Array(def.count * 3); + const col = new Float32Array(def.count * 3); + const c = new THREE.Color(); + for (let i = 0; i < def.count; i++) { + pos[i * 3] = (rand() - 0.5) * def.box * 2; + pos[i * 3 + 1] = (rand() - 0.5) * def.box * 2; + pos[i * 3 + 2] = (rand() - 0.5) * def.box * 2; + const t = rand(); + if (t < 0.12) c.setHSL(0.07, 0.7, 0.75); // warm orange star + else if (t < 0.3) c.setHSL(0.55, 0.5, 0.8); // blue-white + else c.setHSL(0.12, 0.08, 0.62 + rand() * 0.3); // white + col[i * 3] = c.r; col[i * 3 + 1] = c.g; col[i * 3 + 2] = c.b; + } + const g = new THREE.BufferGeometry(); + g.setAttribute('position', new THREE.BufferAttribute(pos, 3)); + g.setAttribute('color', new THREE.BufferAttribute(col, 3)); + const m = new THREE.PointsMaterial({ + size: def.size, map: starSprite, vertexColors: true, + transparent: true, opacity: def.opacity, depthWrite: false, + blending: THREE.AdditiveBlending, sizeAttenuation: false, fog: false, + }); + const pts = new THREE.Points(g, m); + pts.frustumCulled = false; + root.add(pts); + layers.push({ pts, def }); + } + + // -------- speed streaks close to the hull (sell motion) + const streakCount = 90; + const streakPos = new Float32Array(streakCount * 2 * 3); + for (let i = 0; i < streakCount; i++) { + const x = (rand() - 0.5) * 120; + const y = (rand() - 0.5) * 80; + const z = (rand() - 0.5) * 300; + const len = 4 + rand() * 9; + streakPos[i * 6] = x; streakPos[i * 6 + 1] = y; streakPos[i * 6 + 2] = z; + streakPos[i * 6 + 3] = x; streakPos[i * 6 + 4] = y; streakPos[i * 6 + 5] = z + len; + } + const streakGeo = new THREE.BufferGeometry(); + streakGeo.setAttribute('position', new THREE.BufferAttribute(streakPos, 3)); + const streakMat = new THREE.LineBasicMaterial({ + color: 0xbfd8e8, transparent: true, opacity: 0.28, + blending: THREE.AdditiveBlending, fog: false, depthWrite: false, + }); + const streaks = new THREE.LineSegments(streakGeo, streakMat); + streaks.frustumCulled = false; + root.add(streaks); + + // -------- gas giant abeam port, slides past the left porthole + const gasMap = makePlanetMap(rand, { hueA: 14, hueB: 38 }); + const gas = new THREE.Mesh( + new THREE.SphereGeometry(260, 48, 32), + planetMaterial(gasMap, 0xffb46a, 2.4) + ); + const gasAtm = new THREE.Mesh( + new THREE.SphereGeometry(260 * 1.045, 48, 32), + atmosphereMaterial(0xff9a50, 2.2) + ); + const gasGroup = new THREE.Group(); + gasGroup.add(gas, gasAtm); + root.add(gasGroup); + + // -------- rocky moon ahead, visible through the cockpit viewport + const rockMap = makeRockyMap(rand); + const rock = new THREE.Mesh( + new THREE.SphereGeometry(150, 40, 28), + planetMaterial(rockMap, 0x8fd8e8, 1.5) + ); + const rockAtm = new THREE.Mesh( + new THREE.SphereGeometry(150 * 1.05, 40, 28), + atmosphereMaterial(0x6fc8e8, 1.5) + ); + const rockGroup = new THREE.Group(); + rockGroup.add(rock, rockAtm); + root.add(rockGroup); + + // -------- ringed crescent planet far starboard (rim-lit silhouette) + const ringedMat = planetMaterial(makePlanetMap(rand, { hueA: 200, hueB: 230, size: 512 }), 0x9fd8f0, 2.6); + const ringed = new THREE.Mesh(new THREE.SphereGeometry(170, 40, 28), ringedMat); + const ringedAtm = new THREE.Mesh( + new THREE.SphereGeometry(170 * 1.05, 40, 28), + atmosphereMaterial(0x7fc8e8, 2.0) + ); + // ring disc + const ringGeo = new THREE.RingGeometry(220, 360, 64); + { + // radial UV for ring shading + const pos = ringGeo.attributes.position; + const uv = ringGeo.attributes.uv; + for (let i = 0; i < pos.count; i++) { + const r = Math.hypot(pos.getX(i), pos.getY(i)); + uv.setXY(i, (r - 220) / 140, 0.5); + } + } + const ringMat = new THREE.MeshBasicMaterial({ + color: 0x8fb8c8, transparent: true, opacity: 0.30, + side: THREE.DoubleSide, fog: false, depthWrite: false, + }); + const ringMesh = new THREE.Mesh(ringGeo, ringMat); + ringMesh.rotation.x = Math.PI / 2.25; + ringMesh.rotation.y = 0.35; + const ringedGroup = new THREE.Group(); + ringedGroup.add(ringed, ringedAtm, ringMesh); + root.add(ringedGroup); + + // -------- nebula billboards + const nebDefs = [ + { col: [[14, 75, 55], [28, 80, 62]], pos: [900, 250, -1600], scale: 1500 }, + { col: [[180, 55, 45], [200, 60, 55]], pos: [-1400, -150, -900], scale: 1300 }, + { col: [[185, 60, 50], [16, 70, 55]], pos: [1500, 80, 600], scale: 1500 }, + { col: [[210, 45, 40], [180, 50, 45]], pos: [-600, 380, 1500], scale: 1100 }, + ]; + const nebulas = []; + for (const nd of nebDefs) { + const sm = new THREE.SpriteMaterial({ + map: makeNebulaSprite(rand, nd.col[0], nd.col[1]), + transparent: true, opacity: 0.85, depthWrite: false, + blending: THREE.AdditiveBlending, fog: false, + }); + const sp = new THREE.Sprite(sm); + sp.position.set(...nd.pos); + sp.scale.setScalar(nd.scale); + root.add(sp); + nebulas.push(sp); + } + + // -------- distant sun glow + { + const sunMat = new THREE.SpriteMaterial({ + map: makeStarSprite(), color: 0xfff2d8, transparent: true, + opacity: 0.95, depthWrite: false, blending: THREE.AdditiveBlending, fog: false, + }); + const sun = new THREE.Sprite(sunMat); + sun.position.copy(SUN_DIR).multiplyScalar(2400); + sun.scale.setScalar(260); + root.add(sun); + } + + scene.add(root); + + // animation state + let t0 = 0; + function update(dt, t) { + t0 = t; + // star drift (ship flying toward -Z, stars stream toward +Z) + for (const { pts, def } of layers) { + const arr = pts.geometry.attributes.position.array; + const lim = def.box; + for (let i = 2; i < arr.length; i += 3) { + arr[i] += def.speed * dt; + if (arr[i] > lim) arr[i] -= lim * 2; + } + pts.geometry.attributes.position.needsUpdate = true; + } + { + const arr = streaks.geometry.attributes.position.array; + for (let i = 0; i < arr.length; i += 6) { + arr[i + 2] += 150 * dt; + arr[i + 5] += 150 * dt; + if (arr[i + 2] > 180) { arr[i + 2] -= 360; arr[i + 5] -= 360; } + } + streaks.geometry.attributes.position.needsUpdate = true; + } + + // gas giant: slow orbit, abeam port at t=0, sliding aft past the left + // porthole over ~80 s + { + const ang = Math.PI + t * (Math.PI * 2 / 340); + const R = 980; + gasGroup.position.set(Math.cos(ang) * R, -120, Math.sin(ang) * R + 40); + gas.rotation.y = t * 0.01; + } + // rocky moon ahead, drifting starboard slowly across the viewport + { + const ang = Math.PI * 1.46 + t * (Math.PI * 2 / 480); + const R = 1000; + rockGroup.position.set(Math.cos(ang) * R, 55, Math.sin(ang) * R - 120); + rock.rotation.y = t * 0.02; + } + // ringed crescent: far starboard, slow aft drift + ringedGroup.position.set(1550, 90, -380 + t * 1.4); + } + + return { root, update }; +} + +===== FILE: src/player.js ===== + +// First-person controller: pointer lock, WASD, head bob, capsule-vs-AABB collision. +import * as THREE from 'three'; + +const EYE = 1.7; +const RADIUS = 0.32; +const WALK_SPEED = 2.6; +const ACCEL = 26; + +export class Player { + constructor(camera, dom, colliders) { + this.camera = camera; + this.dom = dom; + this.colliders = colliders; + + this.position = new THREE.Vector3(0, 0, 6.0); // feet + this.velocity = new THREE.Vector3(); + this.yaw = Math.PI; // facing -Z (toward cockpit)... yaw=0 faces -Z here + this.pitch = 0; + this.keys = new Set(); + this.locked = false; + this.bobPhase = 0; + this.bobAmount = 0; + this.time = 0; + this.frozen = false; // debug camera mode + this.eyeOverride = null; + + this.onLockChange = null; + + dom.ownerDocument.addEventListener('keydown', (e) => { + this.keys.add(e.code); + }); + dom.ownerDocument.addEventListener('keyup', (e) => this.keys.delete(e.code)); + + dom.ownerDocument.addEventListener('pointerlockchange', () => { + this.locked = document.pointerLockElement === dom; + if (this.onLockChange) this.onLockChange(this.locked); + }); + dom.ownerDocument.addEventListener('mousemove', (e) => { + if (!this.locked || this.frozen) return; + // Chrome (esp. on Windows) occasionally injects huge spurious deltas + // under pointer lock; discard anything that can't be a real mouse move. + if (Math.abs(e.movementX) > 180 || Math.abs(e.movementY) > 180) return; + this.yaw -= e.movementX * 0.0023; + this.pitch -= e.movementY * 0.0023; + this.pitch = Math.max(-1.45, Math.min(1.45, this.pitch)); + }); + } + + lock() { + // unadjustedMovement bypasses OS pointer acceleration (removes jitter); + // it throws synchronously or rejects on unsupported platforms. + try { + const p = this.dom.requestPointerLock({ unadjustedMovement: true }); + if (p && typeof p.catch === 'function') { + p.catch(() => this.dom.requestPointerLock()); + } + } catch { + this.dom.requestPointerLock(); + } + } + + setPose(pos, yaw, pitch) { + this.position.set(pos.x, 0, pos.z); + this.yaw = yaw; + this.pitch = pitch; + this.velocity.set(0, 0, 0); + } + + update(dt) { + this.time += dt; + if (this.frozen) { + this.applyCamera(0); + return; + } + + // input direction in local space + let fx = 0, fz = 0; + if (this.keys.has('KeyW')) fz -= 1; + if (this.keys.has('KeyS')) fz += 1; + if (this.keys.has('KeyA')) fx -= 1; + if (this.keys.has('KeyD')) fx += 1; + const moving = (fx !== 0 || fz !== 0) && this.locked; + + const sin = Math.sin(this.yaw), cos = Math.cos(this.yaw); + // rotate local input (fx, fz) by yaw: with yaw=0 facing -Z, + // forward (fz=-1) must map to (-sin, -cos) + const wishX = fx * cos + fz * sin; + const wishZ = -fx * sin + fz * cos; + const wish = new THREE.Vector2(wishX, wishZ); + if (wish.lengthSq() > 0) wish.normalize().multiplyScalar(WALK_SPEED); + + // accelerate toward wish velocity + const v = this.velocity; + v.x += (wish.x - v.x) * Math.min(1, ACCEL * dt * 0.4); + v.z += (wish.y - v.z) * Math.min(1, ACCEL * dt * 0.4); + if (!moving) { + v.x *= Math.pow(0.0001, dt); + v.z *= Math.pow(0.0001, dt); + } + + this.position.x += v.x * dt; + this.position.z += v.z * dt; + this.resolveCollisions(); + + // head bob + const speed = Math.hypot(v.x, v.z); + const target = Math.min(1, speed / WALK_SPEED); + this.bobAmount += (target - this.bobAmount) * Math.min(1, 8 * dt); + this.bobPhase += dt * (6.5 + speed * 1.6) * (this.bobAmount > 0.02 ? 1 : 0); + + this.applyCamera(dt); + } + + applyCamera(dt) { + const bobY = Math.sin(this.bobPhase * 2) * 0.028 * this.bobAmount; + const bobX = Math.sin(this.bobPhase) * 0.016 * this.bobAmount; + // idle breathing + engine rumble + const breathe = Math.sin(this.time * 1.7) * 0.004; + const rumble = this.frozen ? 0 : (Math.sin(this.time * 31.7) + Math.sin(this.time * 47.3)) * 0.0009; + + const eye = this.frozen && this.eyeOverride !== null ? this.eyeOverride : EYE; + this.camera.position.set( + this.position.x + bobX * Math.cos(this.yaw), + eye + (this.frozen ? 0 : bobY + breathe + rumble), + this.position.z - bobX * Math.sin(this.yaw) + ); + this.camera.rotation.order = 'YXZ'; + // position-only bob: no roll/tilt on the camera rotation + this.camera.rotation.set(this.pitch, this.yaw, 0); + } + + resolveCollisions() { + const p = this.position; + for (let pass = 0; pass < 3; pass++) { + let pushed = false; + for (const b of this.colliders) { + // vertical overlap with player capsule (feet 0 .. head 1.8) + if (b.max.y < 0.25 || b.min.y > 1.75) continue; + const ex0 = b.min.x - RADIUS, ex1 = b.max.x + RADIUS; + const ez0 = b.min.z - RADIUS, ez1 = b.max.z + RADIUS; + if (p.x <= ex0 || p.x >= ex1 || p.z <= ez0 || p.z >= ez1) continue; + // push out along smallest penetration + const dxl = p.x - ex0, dxr = ex1 - p.x; + const dzl = p.z - ez0, dzr = ez1 - p.z; + const m = Math.min(dxl, dxr, dzl, dzr); + if (m === dxl) p.x = ex0; + else if (m === dxr) p.x = ex1; + else if (m === dzl) p.z = ez0; + else p.z = ez1; + pushed = true; + } + if (!pushed) break; + } + } +} + +===== FILE: src/interact.js ===== + +// Raycast interactions: hover highlight, prompts, fades, status, rest cycle. +import * as THREE from 'three'; + +export class Interactions { + constructor(scene, camera, ship) { + this.camera = camera; + this.ship = ship; + this.raycaster = new THREE.Raycaster(); + this.raycaster.far = 3.0; + this.center = new THREE.Vector2(0, 0); + this.hovered = null; + this.busy = false; + this.restCycle = false; + this.cycleT = 1; // 1 = day, 0 = night + this.cycleTarget = 1; + this.shipHours = 14 + 32 / 60; + this.lastMeal = 'NOMINAL'; + + this.promptEl = document.getElementById('prompt'); + this.statusEl = document.getElementById('status'); + this.messageEl = document.getElementById('message'); + this.fadeEl = document.getElementById('fade'); + this.reticleEl = document.getElementById('reticle'); + this.statusNote = ''; + this.statusNoteUntil = 0; + this.time = 0; + + // hover volumes + this.targets = []; + for (const it of ship.interactables) { + const geo = new THREE.BoxGeometry(it.size.x, it.size.y, it.size.z); + const mat = new THREE.MeshBasicMaterial({ + color: 0xffb46a, transparent: true, opacity: 0, + depthWrite: false, side: THREE.DoubleSide, + blending: THREE.AdditiveBlending, + }); + const mesh = new THREE.Mesh(geo, mat); + mesh.position.copy(it.center); + mesh.userData.interactable = it; + scene.add(mesh); + // glowing edge outline shown on hover + const edges = new THREE.LineSegments( + new THREE.EdgesGeometry(geo), + new THREE.LineBasicMaterial({ color: 0xffb46a, transparent: true, opacity: 0 }) + ); + edges.position.copy(it.center); + scene.add(edges); + mesh.userData.edges = edges; + this.targets.push(mesh); + } + + document.addEventListener('keydown', (e) => { + if (e.code === 'KeyE') this.tryInteract(); + }); + + this.updateStatus(); + } + + fadeBlack(midFn, message, holdMs = 1300) { + this.busy = true; + this.fadeEl.classList.add('on'); + setTimeout(() => { + if (midFn) midFn(); + if (message) { + this.messageEl.textContent = message; + this.messageEl.classList.add('on'); + } + setTimeout(() => { + this.fadeEl.classList.remove('on'); + setTimeout(() => { + this.messageEl.classList.remove('on'); + this.busy = false; + }, 900); + }, holdMs); + }, 750); + } + + note(text, seconds = 5) { + this.statusNote = text; + this.statusNoteUntil = this.time + seconds; + this.updateStatus(); + } + + tryInteract() { + if (this.busy || !this.hovered) return; + const id = this.hovered.userData.interactable.id; + if (id === 'bed') { + const toNight = !this.restCycle; + this.fadeBlack(() => { + this.restCycle = toNight; + this.cycleTarget = toNight ? 0 : 1; + this.shipHours = (this.shipHours + 8) % 24; + this.note(toNight ? 'REST CYCLE ENGAGED' : 'DAY CYCLE RESTORED', 6); + }, '8 HOURS PASS'); + } else if (id === 'galley') { + this.busy = true; + this.note('YOU EAT. ENERGY RESTORED.', 6); + this.messageEl.textContent = 'ENERGY RESTORED'; + this.messageEl.classList.add('on'); + setTimeout(() => { + this.messageEl.classList.remove('on'); + this.busy = false; + }, 1400); + } else if (id === 'bathroom') { + this.fadeBlack(() => { + this.note('REFRESHED.', 6); + }, 'REFRESHED', 900); + } + } + + updateStatus() { + const h = Math.floor(this.shipHours); + const m = Math.floor((this.shipHours - h) * 60); + const clock = `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`; + const cycle = this.restCycle ? 'REST CYCLE' : 'CRUISE'; + const note = this.statusNote && this.time < this.statusNoteUntil ? ` · ${this.statusNote}` : ''; + this.statusEl.innerHTML = `MCV-7 DRIFTER · T+${clock} · ${cycle}${note}`; + } + + update(dt, t) { + this.time = t; + this.shipHours = (this.shipHours + dt / 240) % 24; // 1 game-hour per 4 min + + // lighting cycle lerp + this.cycleT += (this.cycleTarget - this.cycleT) * Math.min(1, dt * 1.8); + const k = this.cycleT; + for (const L of this.ship.lights) { + L.light.intensity = L.night + (L.day - L.night) * k; + } + for (const Em of this.ship.emissives) { + Em.mat.emissiveIntensity = Em.night + (Em.day - Em.night) * k; + } + + // hover raycast + this.raycaster.setFromCamera(this.center, this.camera); + const hits = this.raycaster.intersectObjects(this.targets, false); + const hit = hits.length > 0 ? hits[0].object : null; + if (hit !== this.hovered) { + if (this.hovered) { + this.hovered.material.opacity = 0; + this.hovered.userData.edges.material.opacity = 0; + } + this.hovered = hit; + if (hit) { + this.promptEl.textContent = hit.userData.interactable.prompt; + this.promptEl.classList.add('on'); + this.reticleEl.classList.add('hot'); + } else { + this.promptEl.classList.remove('on'); + this.reticleEl.classList.remove('hot'); + } + } + if (this.hovered) { + const pulse = 0.008 + Math.sin(t * 5) * 0.005; + this.hovered.material.opacity = pulse; + this.hovered.userData.edges.material.opacity = 0.4 + Math.sin(t * 5) * 0.15; + } + + if ((t * 2 | 0) !== ((t - dt) * 2 | 0)) this.updateStatus(); + } +} + +===== FILE: src/post.js ===== + +// Post-processing: N8AO, bloom, ACES output, vignette + film grain. +import * as THREE from 'three'; +import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js'; +import { RenderPass } from 'three/addons/postprocessing/RenderPass.js'; +import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js'; +import { OutputPass } from 'three/addons/postprocessing/OutputPass.js'; +import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js'; +import { N8AOPass } from 'n8ao'; + +const GrainVignetteShader = { + uniforms: { + tDiffuse: { value: null }, + time: { value: 0 }, + grain: { value: 0.045 }, + vignette: { value: 0.42 }, + }, + vertexShader: /* glsl */` + varying vec2 vUv; + void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + } + `, + fragmentShader: /* glsl */` + uniform sampler2D tDiffuse; + uniform float time; + uniform float grain; + uniform float vignette; + varying vec2 vUv; + float hash(vec2 p) { + return fract(sin(dot(p, vec2(127.1, 311.7)) + time * 17.0) * 43758.5453); + } + void main() { + vec4 col = texture2D(tDiffuse, vUv); + // vignette + vec2 d = vUv - 0.5; + float v = 1.0 - dot(d, d) * vignette * 2.2; + col.rgb *= clamp(v, 0.0, 1.0); + // film grain (luminance-weighted, subtle) + float g = (hash(vUv * vec2(1920.0, 1080.0)) - 0.5) * grain; + col.rgb += g * (0.4 + 0.6 * (1.0 - clamp(dot(col.rgb, vec3(0.333)), 0.0, 1.0))); + gl_FragColor = col; + } + `, +}; + +export function createPost(renderer, scene, camera) { + renderer.toneMapping = THREE.ACESFilmicToneMapping; + renderer.toneMappingExposure = 1.05; + renderer.outputColorSpace = THREE.SRGBColorSpace; + + const size = renderer.getSize(new THREE.Vector2()); + const composer = new EffectComposer(renderer); + composer.setPixelRatio(renderer.getPixelRatio()); + + composer.addPass(new RenderPass(scene, camera)); + + const n8ao = new N8AOPass(scene, camera, size.x, size.y); + n8ao.configuration.aoRadius = 0.9; + n8ao.configuration.distanceFalloff = 2.5; + n8ao.configuration.intensity = 3.2; + n8ao.configuration.halfRes = true; + // OutputPass handles sRGB conversion; without this the frame gets gamma'd twice + n8ao.configuration.gammaCorrection = false; + n8ao.setQualityMode('Medium'); + if (!location.hash.includes('noao')) composer.addPass(n8ao); + + const bloom = new UnrealBloomPass(new THREE.Vector2(size.x, size.y), 0.30, 0.5, 0.9); + if (!location.hash.includes('nobloom')) composer.addPass(bloom); + + composer.addPass(new OutputPass()); + + const grainPass = new ShaderPass(GrainVignetteShader); + composer.addPass(grainPass); + + function resize(w, h) { + composer.setSize(w, h); + n8ao.setSize(w, h); + bloom.setSize(w, h); + } + + function update(t) { + grainPass.uniforms.time.value = t % 100; + } + + return { composer, resize, update, n8ao, bloom, grainPass }; +} diff --git a/spaceship/index.html b/spaceship/index.html new file mode 100644 index 0000000..d1a9bc8 --- /dev/null +++ b/spaceship/index.html @@ -0,0 +1,96 @@ + + + + + + Drifter — Ship Interior + + + +
+
+
+
+
+
+
+
+
+

DRIFTER · MCV-7

+

CLICK TO BOARD

+

WASD MOVE  ·  MOUSE LOOK  ·  E INTERACT

+
+ + + diff --git a/spaceship/package-lock.json b/spaceship/package-lock.json new file mode 100644 index 0000000..8a44bdf --- /dev/null +++ b/spaceship/package-lock.json @@ -0,0 +1,904 @@ +{ + "name": "spaceship-interior", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "spaceship-interior", + "version": "0.1.0", + "dependencies": { + "n8ao": "^1.10.1", + "postprocessing": "^6.39.1", + "three": "^0.184.0", + "vite": "^8.0.16" + }, + "devDependencies": { + "playwright": "^1.60.0" + } + }, + "node_modules/@emnapi/core": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz", + "integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==", + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.1", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz", + "integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz", + "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.5.tgz", + "integrity": "sha512-AWPoBRJ9tsnVhor4sjO7rkni+7p+2IAEFj6cx06UgP10jkQHqay/36uRV/bFkgrh18D9vb4cr8Q0Pthskgzy+Q==", + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1", + "@emnapi/runtime": "^1.7.1" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.133.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.133.0.tgz", + "integrity": "sha512-KzkdCd6Uxqnf6l3HOw1xfatAlUURA0g14cvBYFyJ5SaNOQbOUvBr9PKArcPcrNIeRsBdgcUzOGrhKveVpvOIGA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/Boshen" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.3.tgz", + "integrity": "sha512-454rs7jHngixp/NMxd5srYD57OnzSlZ/eFTETjORQHLwJG1lRtmNOJcBerZlfu4GjKqeq8aCCIQrMdHyhI51Hw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.3.tgz", + "integrity": "sha512-PcAhP+ynjURNyy8SKGl5DQP94aGuB/7JrXJb/t7P+hanXvQVMWzUvRRhBAcg/lNRadBhoUPqSoP4xw5tR/KBEA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.3.tgz", + "integrity": "sha512-9YpfeUvSE2RS7wysJ81uOZkXJz7f7Q55H2Gvp3VEw/EsahqDtrphrZ0EwDLK5vvKOzaCrBsjF8JmnMLcUt78Gg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.3.tgz", + "integrity": "sha512-yB1IlAsSNHncV6SCTL27/MVGR5htvQsoGxIv5KMGXALp+Ll1wYsn+x98M9MW7qa+NdSbvrrY7ANI4wLJ0n1e6g==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.3.tgz", + "integrity": "sha512-Yi30IVAAfLUCy2MseFjbB1jAMDl1VMCAas5StnYp8da9+CKvMd2H2cbEjWcw5NPaPqzvYkVIaF1nNUG+b7u/sw==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.3.tgz", + "integrity": "sha512-jsO7R8To+AdlYgUmN5sHSCZbfhtMBkO0WUx8iORQnPcMMdgr7qM2DQmMwgabs3GhNztdmoKkMKQFHD6DTMCIQw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.3.tgz", + "integrity": "sha512-VWkUHwWriDciit80wleYwKILoR/KMvxh/IdwS/paX+ZgpuRpCrKLUdadJbc0NpBEiyhpYawsJ73j9aCvOH+f7Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.3.tgz", + "integrity": "sha512-5f1laC0SlIR0yDbFCd8acUhvJIag6N3zC5P7oUPN6wX0aOma+uKJ0wBDH5aq7I1PVI2ttTlhJwzwRIBnLiSGEg==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.3.tgz", + "integrity": "sha512-Iq4ko0r4XsgbrF/LunNgHtAGLRRVE2kXonAXQ/MV0mC6jQpMOhW1SvtZja2EhC/kd05++bP78dsqBeIQyYJ6Yg==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.3.tgz", + "integrity": "sha512-B8m6tD5+/N5FeNQFbKlLA/2yVq9ycQP1SeedyEYYKWBNR3ZQbkvIUcNnDNM03lO1l5F2roiiFJGgvoLLyZXtSg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.3.tgz", + "integrity": "sha512-pSdpdUJHkuCxun9LE7jvgUB9qsRgaiyNNCX7m/AvHTcq67AiT/Yhoxvw5zPfhrM8k/BfP8ce/hMOpthKDpEUow==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.3.tgz", + "integrity": "sha512-OXXS3RKJgX2uLwM+gYyuH5omcH8fL1LJs96pZGgtetVCahON57+d4SJHzTgZiOjxgGkSnpXpOsWuPDGAKAigEg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.3.tgz", + "integrity": "sha512-JTtb8BWFynicNSoPrehsCzBtOKjZ6jhMiPFEmOiuXg1Fl8dn2KHQob+GuPSGR0dryQa1PQJbzjF3dqO/whhjLg==", + "cpu": [ + "wasm32" + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "1.10.0", + "@emnapi/runtime": "1.10.0", + "@napi-rs/wasm-runtime": "^1.1.4" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.3.tgz", + "integrity": "sha512-gEdFFEN70A/jxb2svrWsN3aDL7OUtmvlOy+6fa2jxG8K0wQ1ZbdeLGnidov6Yu5/733dI5ySfzFlQ/cb0bSz1g==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.3.tgz", + "integrity": "sha512-eXB7CHuaQdqmJcc3koCNtNPmT/bj2gc999kUFgBxG8Ac0NdgXc4rkCHhqrgrhN3zddvvvrgzj1e90SuSfmyIXA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", + "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "license": "MIT" + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.2.tgz", + "integrity": "sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/lightningcss": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", + "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.32.0", + "lightningcss-darwin-arm64": "1.32.0", + "lightningcss-darwin-x64": "1.32.0", + "lightningcss-freebsd-x64": "1.32.0", + "lightningcss-linux-arm-gnueabihf": "1.32.0", + "lightningcss-linux-arm64-gnu": "1.32.0", + "lightningcss-linux-arm64-musl": "1.32.0", + "lightningcss-linux-x64-gnu": "1.32.0", + "lightningcss-linux-x64-musl": "1.32.0", + "lightningcss-win32-arm64-msvc": "1.32.0", + "lightningcss-win32-x64-msvc": "1.32.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz", + "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz", + "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz", + "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz", + "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz", + "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==", + "cpu": [ + "arm" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz", + "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz", + "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz", + "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz", + "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz", + "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz", + "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/n8ao": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/n8ao/-/n8ao-1.10.1.tgz", + "integrity": "sha512-hhI1pC+BfOZBV1KMwynBrVlIm8wqLxj/abAWhF2nZ0qQKyzTSQa1QtLVS2veRiuoBQXojxobcnp0oe+PUoxf/w==", + "license": "ISC", + "peerDependencies": { + "postprocessing": ">=6.30.0", + "three": ">=0.137" + } + }, + "node_modules/nanoid": { + "version": "3.3.12", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.12.tgz", + "integrity": "sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/playwright": { + "version": "1.60.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.60.0.tgz", + "integrity": "sha512-hheHdokM8cdqCb0lcE3s+zT4t4W+vvjpGxsZlDnikarzx8tSzMebh3UiFtgqwFwnTnjYQcsyMF8ei2mCO/tpeA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.60.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.60.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.60.0.tgz", + "integrity": "sha512-9bW6zvX/m0lEbgTKJ6YppOKx8H3VOPBMOCFh2irXFOT4BbHgrx5hPjwJYLT40Lu+4qtD36qKc/Hn56StUW57IA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/postcss": { + "version": "8.5.15", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.15.tgz", + "integrity": "sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.12", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postprocessing": { + "version": "6.39.1", + "resolved": "https://registry.npmjs.org/postprocessing/-/postprocessing-6.39.1.tgz", + "integrity": "sha512-R2dG2zy+BAx3USl5EHw+PvnrlbT5PKnZVp3se0HCR0pWH8WQdh742yNG4YWOsq6c0bFpffk0Gd2RqPeoP/wKng==", + "license": "Zlib", + "peerDependencies": { + "three": ">= 0.168.0 < 0.185.0" + } + }, + "node_modules/rolldown": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.3.tgz", + "integrity": "sha512-i00lAJ2ks1BYr7rjNjKC7BcqAS7nVfiT3QX1SI5aY+AFHblCmaUf9OE9dbdzDvW6dJxbi2ZCZiy9v3CcwOiX3g==", + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.133.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm64": "1.0.3", + "@rolldown/binding-darwin-arm64": "1.0.3", + "@rolldown/binding-darwin-x64": "1.0.3", + "@rolldown/binding-freebsd-x64": "1.0.3", + "@rolldown/binding-linux-arm-gnueabihf": "1.0.3", + "@rolldown/binding-linux-arm64-gnu": "1.0.3", + "@rolldown/binding-linux-arm64-musl": "1.0.3", + "@rolldown/binding-linux-ppc64-gnu": "1.0.3", + "@rolldown/binding-linux-s390x-gnu": "1.0.3", + "@rolldown/binding-linux-x64-gnu": "1.0.3", + "@rolldown/binding-linux-x64-musl": "1.0.3", + "@rolldown/binding-openharmony-arm64": "1.0.3", + "@rolldown/binding-wasm32-wasi": "1.0.3", + "@rolldown/binding-win32-arm64-msvc": "1.0.3", + "@rolldown/binding-win32-x64-msvc": "1.0.3" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/three": { + "version": "0.184.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.184.0.tgz", + "integrity": "sha512-wtTRjG92pM5eUg/KuUnHsqSAlPM296brTOcLgMRqEeylYTh/CdtvKUvCyyCQTzFuStieWxvZb8mVTMvdPyUpxg==", + "license": "MIT" + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD", + "optional": true + }, + "node_modules/vite": { + "version": "8.0.16", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.0.16.tgz", + "integrity": "sha512-h9bXPmJichP5fLmVQo3PyaGSDE2n3aPuomeAlVRm0JLmt4rY6zmPKd59HYI4LNW8oTK7tlTsuC7l/m7awx9Jcw==", + "license": "MIT", + "dependencies": { + "lightningcss": "^1.32.0", + "picomatch": "^4.0.4", + "postcss": "^8.5.15", + "rolldown": "1.0.3", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.1.18", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + } + } +} diff --git a/spaceship/package.json b/spaceship/package.json new file mode 100644 index 0000000..f9033de --- /dev/null +++ b/spaceship/package.json @@ -0,0 +1,21 @@ +{ + "name": "spaceship-interior", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "shots": "node tools/shots.mjs" + }, + "dependencies": { + "n8ao": "^1.10.1", + "postprocessing": "^6.39.1", + "three": "^0.184.0", + "vite": "^8.0.16" + }, + "devDependencies": { + "playwright": "^1.60.0" + } +} diff --git a/spaceship/shots/iter_1/cockpit.jpg b/spaceship/shots/iter_1/cockpit.jpg new file mode 100644 index 0000000..f152de0 Binary files /dev/null and b/spaceship/shots/iter_1/cockpit.jpg differ diff --git a/spaceship/shots/iter_1/corridor.jpg b/spaceship/shots/iter_1/corridor.jpg new file mode 100644 index 0000000..0aa37fd Binary files /dev/null and b/spaceship/shots/iter_1/corridor.jpg differ diff --git a/spaceship/shots/iter_1/quarters.jpg b/spaceship/shots/iter_1/quarters.jpg new file mode 100644 index 0000000..70fc39b Binary files /dev/null and b/spaceship/shots/iter_1/quarters.jpg differ diff --git a/spaceship/shots/iter_1/stats.json b/spaceship/shots/iter_1/stats.json new file mode 100644 index 0000000..f52e874 --- /dev/null +++ b/spaceship/shots/iter_1/stats.json @@ -0,0 +1,53 @@ +{ + "stats": { + "cockpit": { + "fps": 0, + "drawCalls": 195, + "triangles": 107657 + }, + "corridor": { + "fps": 0, + "drawCalls": 232, + "triangles": 108681 + }, + "quarters": { + "fps": 0, + "drawCalls": 203, + "triangles": 112163 + }, + "window": { + "fps": 0, + "drawCalls": 196, + "triangles": 112443 + } + }, + "interactResults": { + "bed": { + "hover": null, + "prompt": { + "text": "E: Freshen up", + "on": false + }, + "fired": false, + "midState": null + }, + "galley": { + "hover": null, + "prompt": { + "text": "E: Freshen up", + "on": false + }, + "fired": false, + "midState": null + }, + "bathroom": { + "hover": null, + "prompt": { + "text": "E: Freshen up", + "on": false + }, + "fired": false, + "midState": null + } + } +} \ No newline at end of file diff --git a/spaceship/shots/iter_1/window.jpg b/spaceship/shots/iter_1/window.jpg new file mode 100644 index 0000000..e4c18ae Binary files /dev/null and b/spaceship/shots/iter_1/window.jpg differ diff --git a/spaceship/shots/iter_10/cockpit.jpg b/spaceship/shots/iter_10/cockpit.jpg new file mode 100644 index 0000000..6d16500 Binary files /dev/null and b/spaceship/shots/iter_10/cockpit.jpg differ diff --git a/spaceship/shots/iter_10/corridor.jpg b/spaceship/shots/iter_10/corridor.jpg new file mode 100644 index 0000000..9bcef9d Binary files /dev/null and b/spaceship/shots/iter_10/corridor.jpg differ diff --git a/spaceship/shots/iter_10/interact_bathroom.jpg b/spaceship/shots/iter_10/interact_bathroom.jpg new file mode 100644 index 0000000..fd6db37 Binary files /dev/null and b/spaceship/shots/iter_10/interact_bathroom.jpg differ diff --git a/spaceship/shots/iter_10/interact_bed.jpg b/spaceship/shots/iter_10/interact_bed.jpg new file mode 100644 index 0000000..4af8a03 Binary files /dev/null and b/spaceship/shots/iter_10/interact_bed.jpg differ diff --git a/spaceship/shots/iter_10/interact_galley.jpg b/spaceship/shots/iter_10/interact_galley.jpg new file mode 100644 index 0000000..afb2c2a Binary files /dev/null and b/spaceship/shots/iter_10/interact_galley.jpg differ diff --git a/spaceship/shots/iter_10/quarters.jpg b/spaceship/shots/iter_10/quarters.jpg new file mode 100644 index 0000000..3234fb3 Binary files /dev/null and b/spaceship/shots/iter_10/quarters.jpg differ diff --git a/spaceship/shots/iter_10/stats.json b/spaceship/shots/iter_10/stats.json new file mode 100644 index 0000000..2287acc --- /dev/null +++ b/spaceship/shots/iter_10/stats.json @@ -0,0 +1,65 @@ +{ + "stats": { + "cockpit": { + "fps": 0, + "drawCalls": 200, + "triangles": 119355 + }, + "corridor": { + "fps": 0, + "drawCalls": 239, + "triangles": 120715 + }, + "quarters": { + "fps": 0, + "drawCalls": 211, + "triangles": 109657 + }, + "window": { + "fps": 0, + "drawCalls": 226, + "triangles": 124651 + } + }, + "interactResults": { + "bed": { + "hover": "bed", + "prompt": { + "text": "E: Sleep", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "8 HOURS PASS", + "status": "MCV-7 DRIFTER · T+22:32 · REST CYCLE · REST CYCLE ENGAGED" + } + }, + "galley": { + "hover": "galley", + "prompt": { + "text": "E: Eat", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "ENERGY RESTORED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · YOU EAT. ENERGY RESTORED." + } + }, + "bathroom": { + "hover": "bathroom", + "prompt": { + "text": "E: Freshen up", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "REFRESHED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · REFRESHED." + } + } + } +} \ No newline at end of file diff --git a/spaceship/shots/iter_10/window.jpg b/spaceship/shots/iter_10/window.jpg new file mode 100644 index 0000000..d6d25c4 Binary files /dev/null and b/spaceship/shots/iter_10/window.jpg differ diff --git a/spaceship/shots/iter_2/cockpit.jpg b/spaceship/shots/iter_2/cockpit.jpg new file mode 100644 index 0000000..cbd661c Binary files /dev/null and b/spaceship/shots/iter_2/cockpit.jpg differ diff --git a/spaceship/shots/iter_2/corridor.jpg b/spaceship/shots/iter_2/corridor.jpg new file mode 100644 index 0000000..5e8db9f Binary files /dev/null and b/spaceship/shots/iter_2/corridor.jpg differ diff --git a/spaceship/shots/iter_2/interact_bathroom.jpg b/spaceship/shots/iter_2/interact_bathroom.jpg new file mode 100644 index 0000000..2f8a172 Binary files /dev/null and b/spaceship/shots/iter_2/interact_bathroom.jpg differ diff --git a/spaceship/shots/iter_2/interact_bed.jpg b/spaceship/shots/iter_2/interact_bed.jpg new file mode 100644 index 0000000..488d108 Binary files /dev/null and b/spaceship/shots/iter_2/interact_bed.jpg differ diff --git a/spaceship/shots/iter_2/interact_galley.jpg b/spaceship/shots/iter_2/interact_galley.jpg new file mode 100644 index 0000000..8de4345 Binary files /dev/null and b/spaceship/shots/iter_2/interact_galley.jpg differ diff --git a/spaceship/shots/iter_2/quarters.jpg b/spaceship/shots/iter_2/quarters.jpg new file mode 100644 index 0000000..ca01b0b Binary files /dev/null and b/spaceship/shots/iter_2/quarters.jpg differ diff --git a/spaceship/shots/iter_2/stats.json b/spaceship/shots/iter_2/stats.json new file mode 100644 index 0000000..fd3c3ec --- /dev/null +++ b/spaceship/shots/iter_2/stats.json @@ -0,0 +1,65 @@ +{ + "stats": { + "cockpit": { + "fps": 0, + "drawCalls": 195, + "triangles": 111593 + }, + "corridor": { + "fps": 0, + "drawCalls": 232, + "triangles": 112617 + }, + "quarters": { + "fps": 0, + "drawCalls": 203, + "triangles": 116099 + }, + "window": { + "fps": 0, + "drawCalls": 199, + "triangles": 116385 + } + }, + "interactResults": { + "bed": { + "hover": "bed", + "prompt": { + "text": "E: Sleep", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "8 HOURS PASS", + "status": "MCV-7 DRIFTER · T+22:32 · REST CYCLE · REST CYCLE ENGAGED" + } + }, + "galley": { + "hover": "galley", + "prompt": { + "text": "E: Eat", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "ENERGY RESTORED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · YOU EAT. ENERGY RESTORED." + } + }, + "bathroom": { + "hover": "bathroom", + "prompt": { + "text": "E: Freshen up", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "REFRESHED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · REFRESHED." + } + } + } +} \ No newline at end of file diff --git a/spaceship/shots/iter_2/window.jpg b/spaceship/shots/iter_2/window.jpg new file mode 100644 index 0000000..6476f73 Binary files /dev/null and b/spaceship/shots/iter_2/window.jpg differ diff --git a/spaceship/shots/iter_3/cockpit.jpg b/spaceship/shots/iter_3/cockpit.jpg new file mode 100644 index 0000000..1707669 Binary files /dev/null and b/spaceship/shots/iter_3/cockpit.jpg differ diff --git a/spaceship/shots/iter_3/corridor.jpg b/spaceship/shots/iter_3/corridor.jpg new file mode 100644 index 0000000..ce0a1fe Binary files /dev/null and b/spaceship/shots/iter_3/corridor.jpg differ diff --git a/spaceship/shots/iter_3/interact_bathroom.jpg b/spaceship/shots/iter_3/interact_bathroom.jpg new file mode 100644 index 0000000..698b387 Binary files /dev/null and b/spaceship/shots/iter_3/interact_bathroom.jpg differ diff --git a/spaceship/shots/iter_3/interact_bed.jpg b/spaceship/shots/iter_3/interact_bed.jpg new file mode 100644 index 0000000..b28aa7d Binary files /dev/null and b/spaceship/shots/iter_3/interact_bed.jpg differ diff --git a/spaceship/shots/iter_3/interact_galley.jpg b/spaceship/shots/iter_3/interact_galley.jpg new file mode 100644 index 0000000..995c9c2 Binary files /dev/null and b/spaceship/shots/iter_3/interact_galley.jpg differ diff --git a/spaceship/shots/iter_3/quarters.jpg b/spaceship/shots/iter_3/quarters.jpg new file mode 100644 index 0000000..d34734d Binary files /dev/null and b/spaceship/shots/iter_3/quarters.jpg differ diff --git a/spaceship/shots/iter_3/stats.json b/spaceship/shots/iter_3/stats.json new file mode 100644 index 0000000..0305872 --- /dev/null +++ b/spaceship/shots/iter_3/stats.json @@ -0,0 +1,65 @@ +{ + "stats": { + "cockpit": { + "fps": 0, + "drawCalls": 194, + "triangles": 112875 + }, + "corridor": { + "fps": 0, + "drawCalls": 231, + "triangles": 113899 + }, + "quarters": { + "fps": 0, + "drawCalls": 203, + "triangles": 102513 + }, + "window": { + "fps": 0, + "drawCalls": 218, + "triangles": 117835 + } + }, + "interactResults": { + "bed": { + "hover": "bed", + "prompt": { + "text": "E: Sleep", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "8 HOURS PASS", + "status": "MCV-7 DRIFTER · T+22:32 · REST CYCLE · REST CYCLE ENGAGED" + } + }, + "galley": { + "hover": "galley", + "prompt": { + "text": "E: Eat", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "ENERGY RESTORED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · YOU EAT. ENERGY RESTORED." + } + }, + "bathroom": { + "hover": "bathroom", + "prompt": { + "text": "E: Freshen up", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "REFRESHED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · REFRESHED." + } + } + } +} \ No newline at end of file diff --git a/spaceship/shots/iter_3/window.jpg b/spaceship/shots/iter_3/window.jpg new file mode 100644 index 0000000..7e22f98 Binary files /dev/null and b/spaceship/shots/iter_3/window.jpg differ diff --git a/spaceship/shots/iter_4/cockpit.jpg b/spaceship/shots/iter_4/cockpit.jpg new file mode 100644 index 0000000..a046f78 Binary files /dev/null and b/spaceship/shots/iter_4/cockpit.jpg differ diff --git a/spaceship/shots/iter_4/corridor.jpg b/spaceship/shots/iter_4/corridor.jpg new file mode 100644 index 0000000..a35a1c0 Binary files /dev/null and b/spaceship/shots/iter_4/corridor.jpg differ diff --git a/spaceship/shots/iter_4/interact_bathroom.jpg b/spaceship/shots/iter_4/interact_bathroom.jpg new file mode 100644 index 0000000..8387137 Binary files /dev/null and b/spaceship/shots/iter_4/interact_bathroom.jpg differ diff --git a/spaceship/shots/iter_4/interact_bed.jpg b/spaceship/shots/iter_4/interact_bed.jpg new file mode 100644 index 0000000..1bc98ea Binary files /dev/null and b/spaceship/shots/iter_4/interact_bed.jpg differ diff --git a/spaceship/shots/iter_4/interact_galley.jpg b/spaceship/shots/iter_4/interact_galley.jpg new file mode 100644 index 0000000..f2cfb81 Binary files /dev/null and b/spaceship/shots/iter_4/interact_galley.jpg differ diff --git a/spaceship/shots/iter_4/quarters.jpg b/spaceship/shots/iter_4/quarters.jpg new file mode 100644 index 0000000..f7b638a Binary files /dev/null and b/spaceship/shots/iter_4/quarters.jpg differ diff --git a/spaceship/shots/iter_4/stats.json b/spaceship/shots/iter_4/stats.json new file mode 100644 index 0000000..0305872 --- /dev/null +++ b/spaceship/shots/iter_4/stats.json @@ -0,0 +1,65 @@ +{ + "stats": { + "cockpit": { + "fps": 0, + "drawCalls": 194, + "triangles": 112875 + }, + "corridor": { + "fps": 0, + "drawCalls": 231, + "triangles": 113899 + }, + "quarters": { + "fps": 0, + "drawCalls": 203, + "triangles": 102513 + }, + "window": { + "fps": 0, + "drawCalls": 218, + "triangles": 117835 + } + }, + "interactResults": { + "bed": { + "hover": "bed", + "prompt": { + "text": "E: Sleep", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "8 HOURS PASS", + "status": "MCV-7 DRIFTER · T+22:32 · REST CYCLE · REST CYCLE ENGAGED" + } + }, + "galley": { + "hover": "galley", + "prompt": { + "text": "E: Eat", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "ENERGY RESTORED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · YOU EAT. ENERGY RESTORED." + } + }, + "bathroom": { + "hover": "bathroom", + "prompt": { + "text": "E: Freshen up", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "REFRESHED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · REFRESHED." + } + } + } +} \ No newline at end of file diff --git a/spaceship/shots/iter_4/window.jpg b/spaceship/shots/iter_4/window.jpg new file mode 100644 index 0000000..801d90c Binary files /dev/null and b/spaceship/shots/iter_4/window.jpg differ diff --git a/spaceship/shots/iter_5/cockpit.jpg b/spaceship/shots/iter_5/cockpit.jpg new file mode 100644 index 0000000..9e6bc60 Binary files /dev/null and b/spaceship/shots/iter_5/cockpit.jpg differ diff --git a/spaceship/shots/iter_5/corridor.jpg b/spaceship/shots/iter_5/corridor.jpg new file mode 100644 index 0000000..1c3f2e4 Binary files /dev/null and b/spaceship/shots/iter_5/corridor.jpg differ diff --git a/spaceship/shots/iter_5/interact_bathroom.jpg b/spaceship/shots/iter_5/interact_bathroom.jpg new file mode 100644 index 0000000..95454f9 Binary files /dev/null and b/spaceship/shots/iter_5/interact_bathroom.jpg differ diff --git a/spaceship/shots/iter_5/interact_bed.jpg b/spaceship/shots/iter_5/interact_bed.jpg new file mode 100644 index 0000000..716430b Binary files /dev/null and b/spaceship/shots/iter_5/interact_bed.jpg differ diff --git a/spaceship/shots/iter_5/interact_galley.jpg b/spaceship/shots/iter_5/interact_galley.jpg new file mode 100644 index 0000000..1794a9a Binary files /dev/null and b/spaceship/shots/iter_5/interact_galley.jpg differ diff --git a/spaceship/shots/iter_5/quarters.jpg b/spaceship/shots/iter_5/quarters.jpg new file mode 100644 index 0000000..927c875 Binary files /dev/null and b/spaceship/shots/iter_5/quarters.jpg differ diff --git a/spaceship/shots/iter_5/stats.json b/spaceship/shots/iter_5/stats.json new file mode 100644 index 0000000..0305872 --- /dev/null +++ b/spaceship/shots/iter_5/stats.json @@ -0,0 +1,65 @@ +{ + "stats": { + "cockpit": { + "fps": 0, + "drawCalls": 194, + "triangles": 112875 + }, + "corridor": { + "fps": 0, + "drawCalls": 231, + "triangles": 113899 + }, + "quarters": { + "fps": 0, + "drawCalls": 203, + "triangles": 102513 + }, + "window": { + "fps": 0, + "drawCalls": 218, + "triangles": 117835 + } + }, + "interactResults": { + "bed": { + "hover": "bed", + "prompt": { + "text": "E: Sleep", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "8 HOURS PASS", + "status": "MCV-7 DRIFTER · T+22:32 · REST CYCLE · REST CYCLE ENGAGED" + } + }, + "galley": { + "hover": "galley", + "prompt": { + "text": "E: Eat", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "ENERGY RESTORED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · YOU EAT. ENERGY RESTORED." + } + }, + "bathroom": { + "hover": "bathroom", + "prompt": { + "text": "E: Freshen up", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "REFRESHED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · REFRESHED." + } + } + } +} \ No newline at end of file diff --git a/spaceship/shots/iter_5/window.jpg b/spaceship/shots/iter_5/window.jpg new file mode 100644 index 0000000..23d5bdf Binary files /dev/null and b/spaceship/shots/iter_5/window.jpg differ diff --git a/spaceship/shots/iter_6/cockpit.jpg b/spaceship/shots/iter_6/cockpit.jpg new file mode 100644 index 0000000..38f868e Binary files /dev/null and b/spaceship/shots/iter_6/cockpit.jpg differ diff --git a/spaceship/shots/iter_6/corridor.jpg b/spaceship/shots/iter_6/corridor.jpg new file mode 100644 index 0000000..5d12f7f Binary files /dev/null and b/spaceship/shots/iter_6/corridor.jpg differ diff --git a/spaceship/shots/iter_6/interact_bathroom.jpg b/spaceship/shots/iter_6/interact_bathroom.jpg new file mode 100644 index 0000000..4da2971 Binary files /dev/null and b/spaceship/shots/iter_6/interact_bathroom.jpg differ diff --git a/spaceship/shots/iter_6/interact_bed.jpg b/spaceship/shots/iter_6/interact_bed.jpg new file mode 100644 index 0000000..e01f66b Binary files /dev/null and b/spaceship/shots/iter_6/interact_bed.jpg differ diff --git a/spaceship/shots/iter_6/interact_galley.jpg b/spaceship/shots/iter_6/interact_galley.jpg new file mode 100644 index 0000000..82a7870 Binary files /dev/null and b/spaceship/shots/iter_6/interact_galley.jpg differ diff --git a/spaceship/shots/iter_6/quarters.jpg b/spaceship/shots/iter_6/quarters.jpg new file mode 100644 index 0000000..553eebd Binary files /dev/null and b/spaceship/shots/iter_6/quarters.jpg differ diff --git a/spaceship/shots/iter_6/stats.json b/spaceship/shots/iter_6/stats.json new file mode 100644 index 0000000..d5bdaca --- /dev/null +++ b/spaceship/shots/iter_6/stats.json @@ -0,0 +1,65 @@ +{ + "stats": { + "cockpit": { + "fps": 0, + "drawCalls": 194, + "triangles": 113067 + }, + "corridor": { + "fps": 0, + "drawCalls": 231, + "triangles": 114091 + }, + "quarters": { + "fps": 0, + "drawCalls": 203, + "triangles": 102705 + }, + "window": { + "fps": 0, + "drawCalls": 218, + "triangles": 118027 + } + }, + "interactResults": { + "bed": { + "hover": "bed", + "prompt": { + "text": "E: Sleep", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "8 HOURS PASS", + "status": "MCV-7 DRIFTER · T+22:32 · REST CYCLE · REST CYCLE ENGAGED" + } + }, + "galley": { + "hover": "galley", + "prompt": { + "text": "E: Eat", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "ENERGY RESTORED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · YOU EAT. ENERGY RESTORED." + } + }, + "bathroom": { + "hover": "bathroom", + "prompt": { + "text": "E: Freshen up", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "REFRESHED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · REFRESHED." + } + } + } +} \ No newline at end of file diff --git a/spaceship/shots/iter_6/window.jpg b/spaceship/shots/iter_6/window.jpg new file mode 100644 index 0000000..4ca71f0 Binary files /dev/null and b/spaceship/shots/iter_6/window.jpg differ diff --git a/spaceship/shots/iter_7/cockpit.jpg b/spaceship/shots/iter_7/cockpit.jpg new file mode 100644 index 0000000..4072a29 Binary files /dev/null and b/spaceship/shots/iter_7/cockpit.jpg differ diff --git a/spaceship/shots/iter_7/corridor.jpg b/spaceship/shots/iter_7/corridor.jpg new file mode 100644 index 0000000..e5d1469 Binary files /dev/null and b/spaceship/shots/iter_7/corridor.jpg differ diff --git a/spaceship/shots/iter_7/interact_bathroom.jpg b/spaceship/shots/iter_7/interact_bathroom.jpg new file mode 100644 index 0000000..8a10fdc Binary files /dev/null and b/spaceship/shots/iter_7/interact_bathroom.jpg differ diff --git a/spaceship/shots/iter_7/interact_bed.jpg b/spaceship/shots/iter_7/interact_bed.jpg new file mode 100644 index 0000000..06c1035 Binary files /dev/null and b/spaceship/shots/iter_7/interact_bed.jpg differ diff --git a/spaceship/shots/iter_7/interact_galley.jpg b/spaceship/shots/iter_7/interact_galley.jpg new file mode 100644 index 0000000..b2de6b5 Binary files /dev/null and b/spaceship/shots/iter_7/interact_galley.jpg differ diff --git a/spaceship/shots/iter_7/quarters.jpg b/spaceship/shots/iter_7/quarters.jpg new file mode 100644 index 0000000..be0c666 Binary files /dev/null and b/spaceship/shots/iter_7/quarters.jpg differ diff --git a/spaceship/shots/iter_7/stats.json b/spaceship/shots/iter_7/stats.json new file mode 100644 index 0000000..8c73755 --- /dev/null +++ b/spaceship/shots/iter_7/stats.json @@ -0,0 +1,65 @@ +{ + "stats": { + "cockpit": { + "fps": 0, + "drawCalls": 200, + "triangles": 118699 + }, + "corridor": { + "fps": 0, + "drawCalls": 239, + "triangles": 120011 + }, + "quarters": { + "fps": 0, + "drawCalls": 211, + "triangles": 108953 + }, + "window": { + "fps": 0, + "drawCalls": 226, + "triangles": 123947 + } + }, + "interactResults": { + "bed": { + "hover": "bed", + "prompt": { + "text": "E: Sleep", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "8 HOURS PASS", + "status": "MCV-7 DRIFTER · T+22:32 · REST CYCLE · REST CYCLE ENGAGED" + } + }, + "galley": { + "hover": "galley", + "prompt": { + "text": "E: Eat", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "ENERGY RESTORED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · YOU EAT. ENERGY RESTORED." + } + }, + "bathroom": { + "hover": "bathroom", + "prompt": { + "text": "E: Freshen up", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "REFRESHED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · REFRESHED." + } + } + } +} \ No newline at end of file diff --git a/spaceship/shots/iter_7/window.jpg b/spaceship/shots/iter_7/window.jpg new file mode 100644 index 0000000..a357825 Binary files /dev/null and b/spaceship/shots/iter_7/window.jpg differ diff --git a/spaceship/shots/iter_8/cockpit.jpg b/spaceship/shots/iter_8/cockpit.jpg new file mode 100644 index 0000000..64a7eaf Binary files /dev/null and b/spaceship/shots/iter_8/cockpit.jpg differ diff --git a/spaceship/shots/iter_8/corridor.jpg b/spaceship/shots/iter_8/corridor.jpg new file mode 100644 index 0000000..e13f721 Binary files /dev/null and b/spaceship/shots/iter_8/corridor.jpg differ diff --git a/spaceship/shots/iter_8/interact_bathroom.jpg b/spaceship/shots/iter_8/interact_bathroom.jpg new file mode 100644 index 0000000..bb6aab1 Binary files /dev/null and b/spaceship/shots/iter_8/interact_bathroom.jpg differ diff --git a/spaceship/shots/iter_8/interact_bed.jpg b/spaceship/shots/iter_8/interact_bed.jpg new file mode 100644 index 0000000..f0348e3 Binary files /dev/null and b/spaceship/shots/iter_8/interact_bed.jpg differ diff --git a/spaceship/shots/iter_8/interact_galley.jpg b/spaceship/shots/iter_8/interact_galley.jpg new file mode 100644 index 0000000..70c2443 Binary files /dev/null and b/spaceship/shots/iter_8/interact_galley.jpg differ diff --git a/spaceship/shots/iter_8/quarters.jpg b/spaceship/shots/iter_8/quarters.jpg new file mode 100644 index 0000000..0a20202 Binary files /dev/null and b/spaceship/shots/iter_8/quarters.jpg differ diff --git a/spaceship/shots/iter_8/stats.json b/spaceship/shots/iter_8/stats.json new file mode 100644 index 0000000..f32e714 --- /dev/null +++ b/spaceship/shots/iter_8/stats.json @@ -0,0 +1,65 @@ +{ + "stats": { + "cockpit": { + "fps": 0, + "drawCalls": 200, + "triangles": 120379 + }, + "corridor": { + "fps": 0, + "drawCalls": 239, + "triangles": 121739 + }, + "quarters": { + "fps": 0, + "drawCalls": 211, + "triangles": 110681 + }, + "window": { + "fps": 0, + "drawCalls": 226, + "triangles": 125675 + } + }, + "interactResults": { + "bed": { + "hover": "bed", + "prompt": { + "text": "E: Sleep", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "8 HOURS PASS", + "status": "MCV-7 DRIFTER · T+22:32 · REST CYCLE · REST CYCLE ENGAGED" + } + }, + "galley": { + "hover": "galley", + "prompt": { + "text": "E: Eat", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "ENERGY RESTORED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · YOU EAT. ENERGY RESTORED." + } + }, + "bathroom": { + "hover": "bathroom", + "prompt": { + "text": "E: Freshen up", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "REFRESHED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · REFRESHED." + } + } + } +} \ No newline at end of file diff --git a/spaceship/shots/iter_8/window.jpg b/spaceship/shots/iter_8/window.jpg new file mode 100644 index 0000000..9d924e6 Binary files /dev/null and b/spaceship/shots/iter_8/window.jpg differ diff --git a/spaceship/shots/iter_9/cockpit.jpg b/spaceship/shots/iter_9/cockpit.jpg new file mode 100644 index 0000000..9b2e685 Binary files /dev/null and b/spaceship/shots/iter_9/cockpit.jpg differ diff --git a/spaceship/shots/iter_9/corridor.jpg b/spaceship/shots/iter_9/corridor.jpg new file mode 100644 index 0000000..b658e59 Binary files /dev/null and b/spaceship/shots/iter_9/corridor.jpg differ diff --git a/spaceship/shots/iter_9/interact_bathroom.jpg b/spaceship/shots/iter_9/interact_bathroom.jpg new file mode 100644 index 0000000..d52f047 Binary files /dev/null and b/spaceship/shots/iter_9/interact_bathroom.jpg differ diff --git a/spaceship/shots/iter_9/interact_bed.jpg b/spaceship/shots/iter_9/interact_bed.jpg new file mode 100644 index 0000000..a684112 Binary files /dev/null and b/spaceship/shots/iter_9/interact_bed.jpg differ diff --git a/spaceship/shots/iter_9/interact_galley.jpg b/spaceship/shots/iter_9/interact_galley.jpg new file mode 100644 index 0000000..0a508dc Binary files /dev/null and b/spaceship/shots/iter_9/interact_galley.jpg differ diff --git a/spaceship/shots/iter_9/quarters.jpg b/spaceship/shots/iter_9/quarters.jpg new file mode 100644 index 0000000..5e9fee7 Binary files /dev/null and b/spaceship/shots/iter_9/quarters.jpg differ diff --git a/spaceship/shots/iter_9/stats.json b/spaceship/shots/iter_9/stats.json new file mode 100644 index 0000000..f32e714 --- /dev/null +++ b/spaceship/shots/iter_9/stats.json @@ -0,0 +1,65 @@ +{ + "stats": { + "cockpit": { + "fps": 0, + "drawCalls": 200, + "triangles": 120379 + }, + "corridor": { + "fps": 0, + "drawCalls": 239, + "triangles": 121739 + }, + "quarters": { + "fps": 0, + "drawCalls": 211, + "triangles": 110681 + }, + "window": { + "fps": 0, + "drawCalls": 226, + "triangles": 125675 + } + }, + "interactResults": { + "bed": { + "hover": "bed", + "prompt": { + "text": "E: Sleep", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "8 HOURS PASS", + "status": "MCV-7 DRIFTER · T+22:32 · REST CYCLE · REST CYCLE ENGAGED" + } + }, + "galley": { + "hover": "galley", + "prompt": { + "text": "E: Eat", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "ENERGY RESTORED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · YOU EAT. ENERGY RESTORED." + } + }, + "bathroom": { + "hover": "bathroom", + "prompt": { + "text": "E: Freshen up", + "on": true + }, + "fired": true, + "midState": { + "fade": false, + "message": "REFRESHED", + "status": "MCV-7 DRIFTER · T+22:33 · REST CYCLE · REFRESHED." + } + } + } +} \ No newline at end of file diff --git a/spaceship/shots/iter_9/window.jpg b/spaceship/shots/iter_9/window.jpg new file mode 100644 index 0000000..d03279a Binary files /dev/null and b/spaceship/shots/iter_9/window.jpg differ diff --git a/spaceship/shots/probe/corridorlit.jpg b/spaceship/shots/probe/corridorlit.jpg new file mode 100644 index 0000000..7eb6e29 Binary files /dev/null and b/spaceship/shots/probe/corridorlit.jpg differ diff --git a/spaceship/shots/probe/doorway.jpg b/spaceship/shots/probe/doorway.jpg new file mode 100644 index 0000000..dc930b4 Binary files /dev/null and b/spaceship/shots/probe/doorway.jpg differ diff --git a/spaceship/shots/probe/galleydoor.jpg b/spaceship/shots/probe/galleydoor.jpg new file mode 100644 index 0000000..6c23ff7 Binary files /dev/null and b/spaceship/shots/probe/galleydoor.jpg differ diff --git a/spaceship/shots/probe/pickback.jpg b/spaceship/shots/probe/pickback.jpg new file mode 100644 index 0000000..f8ff127 Binary files /dev/null and b/spaceship/shots/probe/pickback.jpg differ diff --git a/spaceship/shots/probe/pickback2.jpg b/spaceship/shots/probe/pickback2.jpg new file mode 100644 index 0000000..88699d3 Binary files /dev/null and b/spaceship/shots/probe/pickback2.jpg differ diff --git a/spaceship/shots/probe/quartersdoor.jpg b/spaceship/shots/probe/quartersdoor.jpg new file mode 100644 index 0000000..4b31918 Binary files /dev/null and b/spaceship/shots/probe/quartersdoor.jpg differ diff --git a/spaceship/shots/probe/seatback.jpg b/spaceship/shots/probe/seatback.jpg new file mode 100644 index 0000000..8b19e2c Binary files /dev/null and b/spaceship/shots/probe/seatback.jpg differ diff --git a/spaceship/shots/probe/seatback_blue.jpg b/spaceship/shots/probe/seatback_blue.jpg new file mode 100644 index 0000000..2606447 Binary files /dev/null and b/spaceship/shots/probe/seatback_blue.jpg differ diff --git a/spaceship/shots/probe/seatback_green.jpg b/spaceship/shots/probe/seatback_green.jpg new file mode 100644 index 0000000..0c93b3b Binary files /dev/null and b/spaceship/shots/probe/seatback_green.jpg differ diff --git a/spaceship/shots/probe/seatback_noao.jpg b/spaceship/shots/probe/seatback_noao.jpg new file mode 100644 index 0000000..fdfeb63 Binary files /dev/null and b/spaceship/shots/probe/seatback_noao.jpg differ diff --git a/spaceship/shots/probe/seatback_nobloom.jpg b/spaceship/shots/probe/seatback_nobloom.jpg new file mode 100644 index 0000000..3a19929 Binary files /dev/null and b/spaceship/shots/probe/seatback_nobloom.jpg differ diff --git a/spaceship/shots/probe/seatback_nosun.jpg b/spaceship/shots/probe/seatback_nosun.jpg new file mode 100644 index 0000000..90b189c Binary files /dev/null and b/spaceship/shots/probe/seatback_nosun.jpg differ diff --git a/spaceship/shots/probe/seatback_red.jpg b/spaceship/shots/probe/seatback_red.jpg new file mode 100644 index 0000000..90593f3 Binary files /dev/null and b/spaceship/shots/probe/seatback_red.jpg differ diff --git a/spaceship/shots/probe/seatcheck.jpg b/spaceship/shots/probe/seatcheck.jpg new file mode 100644 index 0000000..91b6c5b Binary files /dev/null and b/spaceship/shots/probe/seatcheck.jpg differ diff --git a/spaceship/src/interact.js b/spaceship/src/interact.js new file mode 100644 index 0000000..7f4e0e4 --- /dev/null +++ b/spaceship/src/interact.js @@ -0,0 +1,161 @@ +// Raycast interactions: hover highlight, prompts, fades, status, rest cycle. +import * as THREE from 'three'; + +export class Interactions { + constructor(scene, camera, ship) { + this.camera = camera; + this.ship = ship; + this.raycaster = new THREE.Raycaster(); + this.raycaster.far = 3.0; + this.center = new THREE.Vector2(0, 0); + this.hovered = null; + this.busy = false; + this.restCycle = false; + this.cycleT = 1; // 1 = day, 0 = night + this.cycleTarget = 1; + this.shipHours = 14 + 32 / 60; + this.lastMeal = 'NOMINAL'; + + this.promptEl = document.getElementById('prompt'); + this.statusEl = document.getElementById('status'); + this.messageEl = document.getElementById('message'); + this.fadeEl = document.getElementById('fade'); + this.reticleEl = document.getElementById('reticle'); + this.statusNote = ''; + this.statusNoteUntil = 0; + this.time = 0; + + // hover volumes + this.targets = []; + for (const it of ship.interactables) { + const geo = new THREE.BoxGeometry(it.size.x, it.size.y, it.size.z); + const mat = new THREE.MeshBasicMaterial({ + color: 0xffb46a, transparent: true, opacity: 0, + depthWrite: false, side: THREE.DoubleSide, + blending: THREE.AdditiveBlending, + }); + const mesh = new THREE.Mesh(geo, mat); + mesh.position.copy(it.center); + mesh.userData.interactable = it; + scene.add(mesh); + // glowing edge outline shown on hover + const edges = new THREE.LineSegments( + new THREE.EdgesGeometry(geo), + new THREE.LineBasicMaterial({ color: 0xffb46a, transparent: true, opacity: 0 }) + ); + edges.position.copy(it.center); + scene.add(edges); + mesh.userData.edges = edges; + this.targets.push(mesh); + } + + document.addEventListener('keydown', (e) => { + if (e.code === 'KeyE') this.tryInteract(); + }); + + this.updateStatus(); + } + + fadeBlack(midFn, message, holdMs = 1300) { + this.busy = true; + this.fadeEl.classList.add('on'); + setTimeout(() => { + if (midFn) midFn(); + if (message) { + this.messageEl.textContent = message; + this.messageEl.classList.add('on'); + } + setTimeout(() => { + this.fadeEl.classList.remove('on'); + setTimeout(() => { + this.messageEl.classList.remove('on'); + this.busy = false; + }, 900); + }, holdMs); + }, 750); + } + + note(text, seconds = 5) { + this.statusNote = text; + this.statusNoteUntil = this.time + seconds; + this.updateStatus(); + } + + tryInteract() { + if (this.busy || !this.hovered) return; + const id = this.hovered.userData.interactable.id; + if (id === 'bed') { + const toNight = !this.restCycle; + this.fadeBlack(() => { + this.restCycle = toNight; + this.cycleTarget = toNight ? 0 : 1; + this.shipHours = (this.shipHours + 8) % 24; + this.note(toNight ? 'REST CYCLE ENGAGED' : 'DAY CYCLE RESTORED', 6); + }, '8 HOURS PASS'); + } else if (id === 'galley') { + this.busy = true; + this.note('YOU EAT. ENERGY RESTORED.', 6); + this.messageEl.textContent = 'ENERGY RESTORED'; + this.messageEl.classList.add('on'); + setTimeout(() => { + this.messageEl.classList.remove('on'); + this.busy = false; + }, 1400); + } else if (id === 'bathroom') { + this.fadeBlack(() => { + this.note('REFRESHED.', 6); + }, 'REFRESHED', 900); + } + } + + updateStatus() { + const h = Math.floor(this.shipHours); + const m = Math.floor((this.shipHours - h) * 60); + const clock = `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`; + const cycle = this.restCycle ? 'REST CYCLE' : 'CRUISE'; + const note = this.statusNote && this.time < this.statusNoteUntil ? ` · ${this.statusNote}` : ''; + this.statusEl.innerHTML = `MCV-7 DRIFTER · T+${clock} · ${cycle}${note}`; + } + + update(dt, t) { + this.time = t; + this.shipHours = (this.shipHours + dt / 240) % 24; // 1 game-hour per 4 min + + // lighting cycle lerp + this.cycleT += (this.cycleTarget - this.cycleT) * Math.min(1, dt * 1.8); + const k = this.cycleT; + for (const L of this.ship.lights) { + L.light.intensity = L.night + (L.day - L.night) * k; + } + for (const Em of this.ship.emissives) { + Em.mat.emissiveIntensity = Em.night + (Em.day - Em.night) * k; + } + + // hover raycast + this.raycaster.setFromCamera(this.center, this.camera); + const hits = this.raycaster.intersectObjects(this.targets, false); + const hit = hits.length > 0 ? hits[0].object : null; + if (hit !== this.hovered) { + if (this.hovered) { + this.hovered.material.opacity = 0; + this.hovered.userData.edges.material.opacity = 0; + } + this.hovered = hit; + if (hit) { + this.promptEl.textContent = hit.userData.interactable.prompt; + this.promptEl.classList.add('on'); + this.reticleEl.classList.add('hot'); + } else { + this.promptEl.classList.remove('on'); + this.reticleEl.classList.remove('hot'); + } + } + if (this.hovered) { + const pulse = 0.008 + Math.sin(t * 5) * 0.005; + this.hovered.material.opacity = pulse; + this.hovered.userData.edges.material.opacity = 0.4 + Math.sin(t * 5) * 0.15; + } + + if ((t * 2 | 0) !== ((t - dt) * 2 | 0)) this.updateStatus(); + } +} diff --git a/spaceship/src/main.js b/spaceship/src/main.js new file mode 100644 index 0000000..87aacd5 --- /dev/null +++ b/spaceship/src/main.js @@ -0,0 +1,254 @@ +import * as THREE from 'three'; +import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js'; +import { mulberry32 } from './textures.js'; +import { buildShip } from './ship.js'; +import { buildSpace, SUN_DIR } from './space.js'; +import { Player } from './player.js'; +import { Interactions } from './interact.js'; +import { createPost } from './post.js'; + +const SEED = 1337; +const DEBUG = location.hash.includes('debug'); + +const app = document.getElementById('app'); +const startEl = document.getElementById('start'); + +const renderer = new THREE.WebGLRenderer({ antialias: false, powerPreference: 'high-performance' }); +renderer.setSize(window.innerWidth, window.innerHeight); +renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75)); +renderer.shadowMap.enabled = true; +renderer.shadowMap.type = THREE.PCFShadowMap; +app.appendChild(renderer.domElement); + +const scene = new THREE.Scene(); +scene.background = new THREE.Color(0x010204); +scene.fog = new THREE.FogExp2(0x0a0d12, 0.035); + +const camera = new THREE.PerspectiveCamera(72, window.innerWidth / window.innerHeight, 0.05, 5000); + +// PMREM environment so metals reflect something real +{ + const pmrem = new THREE.PMREMGenerator(renderer); + const envScene = new RoomEnvironment(); + scene.environment = pmrem.fromScene(envScene, 0.04).texture; + scene.environmentIntensity = 0.16; + pmrem.dispose(); +} + +// build world +const rand = mulberry32(SEED); +const ship = buildShip(scene, rand); +const space = buildSpace(scene, mulberry32(SEED + 7)); + +// cool space key light through the cockpit viewport +{ + const NOSUN = location.hash.includes('nosun'); + const sun = new THREE.DirectionalLight(0xbcd8ff, NOSUN ? 0 : 2.0); + sun.position.copy(SUN_DIR).multiplyScalar(40); + sun.target.position.set(0, 1, -10); + sun.castShadow = true; + sun.shadow.mapSize.set(1024, 1024); + sun.shadow.camera.left = -8; + sun.shadow.camera.right = 8; + sun.shadow.camera.top = 8; + sun.shadow.camera.bottom = -8; + sun.shadow.camera.near = 10; + sun.shadow.camera.far = 70; + sun.shadow.bias = -0.0008; + sun.shadow.normalBias = 0.03; + scene.add(sun, sun.target); + if (!NOSUN) ship.lights.push({ light: sun, day: 2.0, night: 2.0 }); + // faint ambient so blacks never fully crush + const amb = new THREE.AmbientLight(0x47505e, 0.5); + scene.add(amb); + ship.lights.push({ light: amb, day: 0.5, night: 0.34 }); +} + +const player = new Player(camera, renderer.domElement, ship.colliders); +const interact = new Interactions(scene, camera, ship); +const post = createPost(renderer, scene, camera); + +// ------------------------------------------------------------------ start UI +if (DEBUG) { + startEl.classList.add('hidden'); +} else { + startEl.addEventListener('click', () => player.lock()); + player.onLockChange = (locked) => { + startEl.classList.toggle('hidden', locked); + }; +} + +window.addEventListener('resize', () => { + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + renderer.setSize(window.innerWidth, window.innerHeight); + post.resize(window.innerWidth, window.innerHeight); +}); + +// ------------------------------------------------------------------ debug API +const VIEWS = { + cockpit: { pos: [0.0, 1.7, -9.0], look: [0, 1.15, -12.6] }, + corridor: { pos: [0.0, 1.7, 7.4], look: [0, 1.35, -8] }, + quarters: { pos: [2.05, 1.7, 2.0], look: [4.6, 0.7, 5.7] }, + window: { pos: [-0.15, 1.62, 0.70], look: [-3.0, 1.55, 0.75] }, +}; + +let frames = 0; +let fpsAccum = 0, fpsCount = 0, fpsValue = 0; + +renderer.info.autoReset = false; + +let paused = false; + +window.debugAPI = { + ready: false, + frames: () => frames, + pause() { paused = true; }, + resume() { paused = false; }, + // Render one frame synchronously and return JPEG data URL (headless capture). + capture(quality = 0.92) { + post.composer.render(); + return renderer.domElement.toDataURL('image/jpeg', quality); + }, + setView(name) { + const v = VIEWS[name]; + if (!v) return false; + player.frozen = true; + camera.position.set(...v.pos); + camera.lookAt(new THREE.Vector3(...v.look)); + // sync player state so it doesn't snap back + player.position.set(v.pos[0], 0, v.pos[2]); + const e = new THREE.Euler().setFromQuaternion(camera.quaternion, 'YXZ'); + player.yaw = e.y; + player.pitch = e.x; + player.bobAmount = 0; + return true; + }, + free() { player.frozen = false; }, + customView(x, y, z, lx, ly, lz) { + player.frozen = true; + camera.position.set(x, y, z); + camera.lookAt(new THREE.Vector3(lx, ly, lz)); + player.position.set(x, 0, z); + const e = new THREE.Euler().setFromQuaternion(camera.quaternion, 'YXZ'); + player.yaw = e.y; + player.pitch = e.x; + player.eyeOverride = y; + player.bobAmount = 0; + }, + stats() { + return { + fps: fpsValue, + drawCalls: renderer.info.render.calls, + triangles: renderer.info.render.triangles, + }; + }, + hoverTarget() { + return interact.hovered ? interact.hovered.userData.interactable.id : null; + }, + pick() { + const rc = new THREE.Raycaster(); + rc.setFromCamera(new THREE.Vector2(0, 0), camera); + const hits = rc.intersectObjects(ship.group.children, false); + return hits.slice(0, 6).map((h) => { + const m = h.object.material; + return { + dist: +h.distance.toFixed(3), + point: h.point.toArray().map((v) => +v.toFixed(2)), + color: m.color ? m.color.getHexString() : null, + emissive: m.emissive ? m.emissive.getHexString() : null, + rough: m.roughness, metal: m.metalness, + hasMap: !!m.map, transparent: m.transparent, + type: m.type, + }; + }); + }, + press(code) { + document.dispatchEvent(new KeyboardEvent('keydown', { code })); + }, + teleport(x, z, yaw, pitch) { + player.frozen = false; + player.setPose({ x, z }, yaw, pitch); + }, + playerPos() { + return [player.position.x, player.position.z, player.yaw]; + }, + setKey(code, down) { + if (down) player.keys.add(code); else player.keys.delete(code); + }, + forceLock(v) { player.locked = v; }, + inspect() { + const out = []; + for (const ch of ship.group.children) { + if (!ch.isMesh) continue; + const m = ch.material; + const g = ch.geometry; + const rec = { + color: m.color ? m.color.getHexString() : null, + verts: g.attributes.position.count, + hasNormal: !!g.attributes.normal, + hasUV: !!g.attributes.uv, + attrs: Object.keys(g.attributes), + indexed: !!g.index, + }; + // sanity: for first triangle near a probe point, compare geometric vs stored normal + if (m.color && m.color.getHexString() === '1d1e20') { + const pos = g.attributes.position, nor = g.attributes.normal; + const probes = []; + for (let i = 0; i < pos.count; i += 3) { + const ax = pos.getX(i), ay = pos.getY(i), az = pos.getZ(i); + if (Math.abs(ax + 0.62) < 0.4 && Math.abs(az + 10.35) < 0.3 && ay > 0.5 && ay < 1.3) { + const A = new THREE.Vector3(ax, ay, az); + const B = new THREE.Vector3(pos.getX(i + 1), pos.getY(i + 1), pos.getZ(i + 1)); + const C = new THREE.Vector3(pos.getX(i + 2), pos.getY(i + 2), pos.getZ(i + 2)); + const geom = C.clone().sub(B).cross(A.clone().sub(B)).normalize(); + const stored = new THREE.Vector3(nor.getX(i), nor.getY(i), nor.getZ(i)); + probes.push({ + tri: i / 3, + at: A.toArray().map((v) => +v.toFixed(2)), + storedN: stored.toArray().map((v) => +v.toFixed(2)), + storedLen: +stored.length().toFixed(3), + geomN: geom.toArray().map((v) => +v.toFixed(2)), + agree: +geom.dot(stored.clone().normalize()).toFixed(2), + }); + if (probes.length >= 6) break; + } + } + rec.probes = probes; + } + out.push(rec); + } + return out; + }, +}; + +// ------------------------------------------------------------------ main loop +let lastT = performance.now(); +let elapsed = 0; + +function tick() { + requestAnimationFrame(tick); + const now = performance.now(); + const realDt = (now - lastT) / 1000; + lastT = now; + const dt = Math.min(realDt, 0.05); + if (paused) return; + elapsed += dt; + renderer.info.reset(); + + player.update(dt); + space.update(dt, elapsed); + interact.update(dt, elapsed); + post.update(elapsed); + + post.composer.render(); + + fpsAccum += realDt; fpsCount++; + if (fpsAccum >= 0.5) { + fpsValue = Math.round((fpsCount / fpsAccum) * 10) / 10; + fpsAccum = 0; fpsCount = 0; + } + frames++; + if (frames === 12) window.debugAPI.ready = true; +} +tick(); diff --git a/spaceship/src/player.js b/spaceship/src/player.js new file mode 100644 index 0000000..b7c7bae --- /dev/null +++ b/spaceship/src/player.js @@ -0,0 +1,155 @@ +// First-person controller: pointer lock, WASD, head bob, capsule-vs-AABB collision. +import * as THREE from 'three'; + +const EYE = 1.7; +const RADIUS = 0.32; +const WALK_SPEED = 2.6; +const ACCEL = 26; + +export class Player { + constructor(camera, dom, colliders) { + this.camera = camera; + this.dom = dom; + this.colliders = colliders; + + this.position = new THREE.Vector3(0, 0, 6.0); // feet + this.velocity = new THREE.Vector3(); + this.yaw = Math.PI; // facing -Z (toward cockpit)... yaw=0 faces -Z here + this.pitch = 0; + this.keys = new Set(); + this.locked = false; + this.bobPhase = 0; + this.bobAmount = 0; + this.time = 0; + this.frozen = false; // debug camera mode + this.eyeOverride = null; + + this.onLockChange = null; + + dom.ownerDocument.addEventListener('keydown', (e) => { + this.keys.add(e.code); + }); + dom.ownerDocument.addEventListener('keyup', (e) => this.keys.delete(e.code)); + + dom.ownerDocument.addEventListener('pointerlockchange', () => { + this.locked = document.pointerLockElement === dom; + if (this.onLockChange) this.onLockChange(this.locked); + }); + dom.ownerDocument.addEventListener('mousemove', (e) => { + if (!this.locked || this.frozen) return; + // Chrome (esp. on Windows) occasionally injects huge spurious deltas + // under pointer lock; discard anything that can't be a real mouse move. + if (Math.abs(e.movementX) > 180 || Math.abs(e.movementY) > 180) return; + this.yaw -= e.movementX * 0.0023; + this.pitch -= e.movementY * 0.0023; + this.pitch = Math.max(-1.45, Math.min(1.45, this.pitch)); + }); + } + + lock() { + // unadjustedMovement bypasses OS pointer acceleration (removes jitter); + // it throws synchronously or rejects on unsupported platforms. + try { + const p = this.dom.requestPointerLock({ unadjustedMovement: true }); + if (p && typeof p.catch === 'function') { + p.catch(() => this.dom.requestPointerLock()); + } + } catch { + this.dom.requestPointerLock(); + } + } + + setPose(pos, yaw, pitch) { + this.position.set(pos.x, 0, pos.z); + this.yaw = yaw; + this.pitch = pitch; + this.velocity.set(0, 0, 0); + } + + update(dt) { + this.time += dt; + if (this.frozen) { + this.applyCamera(0); + return; + } + + // input direction in local space + let fx = 0, fz = 0; + if (this.keys.has('KeyW')) fz -= 1; + if (this.keys.has('KeyS')) fz += 1; + if (this.keys.has('KeyA')) fx -= 1; + if (this.keys.has('KeyD')) fx += 1; + const moving = (fx !== 0 || fz !== 0) && this.locked; + + const sin = Math.sin(this.yaw), cos = Math.cos(this.yaw); + // rotate local input (fx, fz) by yaw: with yaw=0 facing -Z, + // forward (fz=-1) must map to (-sin, -cos) + const wishX = fx * cos + fz * sin; + const wishZ = -fx * sin + fz * cos; + const wish = new THREE.Vector2(wishX, wishZ); + if (wish.lengthSq() > 0) wish.normalize().multiplyScalar(WALK_SPEED); + + // accelerate toward wish velocity + const v = this.velocity; + v.x += (wish.x - v.x) * Math.min(1, ACCEL * dt * 0.4); + v.z += (wish.y - v.z) * Math.min(1, ACCEL * dt * 0.4); + if (!moving) { + v.x *= Math.pow(0.0001, dt); + v.z *= Math.pow(0.0001, dt); + } + + this.position.x += v.x * dt; + this.position.z += v.z * dt; + this.resolveCollisions(); + + // head bob + const speed = Math.hypot(v.x, v.z); + const target = Math.min(1, speed / WALK_SPEED); + this.bobAmount += (target - this.bobAmount) * Math.min(1, 8 * dt); + this.bobPhase += dt * (6.5 + speed * 1.6) * (this.bobAmount > 0.02 ? 1 : 0); + + this.applyCamera(dt); + } + + applyCamera(dt) { + const bobY = Math.sin(this.bobPhase * 2) * 0.028 * this.bobAmount; + const bobX = Math.sin(this.bobPhase) * 0.016 * this.bobAmount; + // idle breathing + engine rumble + const breathe = Math.sin(this.time * 1.7) * 0.004; + const rumble = this.frozen ? 0 : (Math.sin(this.time * 31.7) + Math.sin(this.time * 47.3)) * 0.0009; + + const eye = this.frozen && this.eyeOverride !== null ? this.eyeOverride : EYE; + this.camera.position.set( + this.position.x + bobX * Math.cos(this.yaw), + eye + (this.frozen ? 0 : bobY + breathe + rumble), + this.position.z - bobX * Math.sin(this.yaw) + ); + this.camera.rotation.order = 'YXZ'; + // position-only bob: no roll/tilt on the camera rotation + this.camera.rotation.set(this.pitch, this.yaw, 0); + } + + resolveCollisions() { + const p = this.position; + for (let pass = 0; pass < 3; pass++) { + let pushed = false; + for (const b of this.colliders) { + // vertical overlap with player capsule (feet 0 .. head 1.8) + if (b.max.y < 0.25 || b.min.y > 1.75) continue; + const ex0 = b.min.x - RADIUS, ex1 = b.max.x + RADIUS; + const ez0 = b.min.z - RADIUS, ez1 = b.max.z + RADIUS; + if (p.x <= ex0 || p.x >= ex1 || p.z <= ez0 || p.z >= ez1) continue; + // push out along smallest penetration + const dxl = p.x - ex0, dxr = ex1 - p.x; + const dzl = p.z - ez0, dzr = ez1 - p.z; + const m = Math.min(dxl, dxr, dzl, dzr); + if (m === dxl) p.x = ex0; + else if (m === dxr) p.x = ex1; + else if (m === dzl) p.z = ez0; + else p.z = ez1; + pushed = true; + } + if (!pushed) break; + } + } +} diff --git a/spaceship/src/post.js b/spaceship/src/post.js new file mode 100644 index 0000000..4a06a2b --- /dev/null +++ b/spaceship/src/post.js @@ -0,0 +1,87 @@ +// Post-processing: N8AO, bloom, ACES output, vignette + film grain. +import * as THREE from 'three'; +import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js'; +import { RenderPass } from 'three/addons/postprocessing/RenderPass.js'; +import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js'; +import { OutputPass } from 'three/addons/postprocessing/OutputPass.js'; +import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js'; +import { N8AOPass } from 'n8ao'; + +const GrainVignetteShader = { + uniforms: { + tDiffuse: { value: null }, + time: { value: 0 }, + grain: { value: 0.045 }, + vignette: { value: 0.42 }, + }, + vertexShader: /* glsl */` + varying vec2 vUv; + void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + } + `, + fragmentShader: /* glsl */` + uniform sampler2D tDiffuse; + uniform float time; + uniform float grain; + uniform float vignette; + varying vec2 vUv; + float hash(vec2 p) { + return fract(sin(dot(p, vec2(127.1, 311.7)) + time * 17.0) * 43758.5453); + } + void main() { + vec4 col = texture2D(tDiffuse, vUv); + // vignette + vec2 d = vUv - 0.5; + float v = 1.0 - dot(d, d) * vignette * 2.2; + col.rgb *= clamp(v, 0.0, 1.0); + // film grain (luminance-weighted, subtle) + float g = (hash(vUv * vec2(1920.0, 1080.0)) - 0.5) * grain; + col.rgb += g * (0.4 + 0.6 * (1.0 - clamp(dot(col.rgb, vec3(0.333)), 0.0, 1.0))); + gl_FragColor = col; + } + `, +}; + +export function createPost(renderer, scene, camera) { + renderer.toneMapping = THREE.ACESFilmicToneMapping; + renderer.toneMappingExposure = 1.05; + renderer.outputColorSpace = THREE.SRGBColorSpace; + + const size = renderer.getSize(new THREE.Vector2()); + const composer = new EffectComposer(renderer); + composer.setPixelRatio(renderer.getPixelRatio()); + + composer.addPass(new RenderPass(scene, camera)); + + const n8ao = new N8AOPass(scene, camera, size.x, size.y); + n8ao.configuration.aoRadius = 0.9; + n8ao.configuration.distanceFalloff = 2.5; + n8ao.configuration.intensity = 3.2; + n8ao.configuration.halfRes = true; + // OutputPass handles sRGB conversion; without this the frame gets gamma'd twice + n8ao.configuration.gammaCorrection = false; + n8ao.setQualityMode('Medium'); + if (!location.hash.includes('noao')) composer.addPass(n8ao); + + const bloom = new UnrealBloomPass(new THREE.Vector2(size.x, size.y), 0.30, 0.5, 0.9); + if (!location.hash.includes('nobloom')) composer.addPass(bloom); + + composer.addPass(new OutputPass()); + + const grainPass = new ShaderPass(GrainVignetteShader); + composer.addPass(grainPass); + + function resize(w, h) { + composer.setSize(w, h); + n8ao.setSize(w, h); + bloom.setSize(w, h); + } + + function update(t) { + grainPass.uniforms.time.value = t % 100; + } + + return { composer, resize, update, n8ao, bloom, grainPass }; +} diff --git a/spaceship/src/ship.js b/spaceship/src/ship.js new file mode 100644 index 0000000..c1c56bd --- /dev/null +++ b/spaceship/src/ship.js @@ -0,0 +1,902 @@ +// Ship interior: geometry kit-bash, PBR materials, lights, colliders, interactables. +import * as THREE from 'three'; +import { mergeGeometries } from 'three/addons/utils/BufferGeometryUtils.js'; +import { + makeHullMaps, makeMetalMaps, makeFloorMaps, makeFabricMaps, + makeGrateMaps, makeHazardMap, makeScreenMap, mulberry32, +} from './textures.js'; + +const E = new THREE.Euler(); +const Q = new THREE.Quaternion(); +const V = new THREE.Vector3(); +const ONE = new THREE.Vector3(1, 1, 1); +const M = new THREE.Matrix4(); + +class Batch { + constructor() { this.byMat = new Map(); } + add(mat, geo) { + if (geo.index) { + const ni = geo.toNonIndexed(); + geo.dispose(); + geo = ni; + } + if (!this.byMat.has(mat)) this.byMat.set(mat, []); + this.byMat.get(mat).push(geo); + } + build(group) { + for (const [mat, geos] of this.byMat) { + const merged = mergeGeometries(geos, false); + const mesh = new THREE.Mesh(merged, mat); + mesh.castShadow = !mat.transparent; + mesh.receiveShadow = true; + group.add(mesh); + for (const g of geos) g.dispose(); + } + } +} + +// Scale BoxGeometry per-face UVs to uniform world texel density. +function uvBoxWorld(g, w, h, d, su, sv, ou = 0, ov = 0) { + const uv = g.attributes.uv; + const dims = [[d, h], [d, h], [w, d], [w, d], [w, h], [w, h]]; + for (let f = 0; f < 6; f++) { + const [du, dv] = dims[f]; + for (let v = 0; v < 4; v++) { + const i = f * 4 + v; + uv.setXY(i, uv.getX(i) * du * su + ou, uv.getY(i) * dv * sv + ov); + } + } + uv.needsUpdate = true; +} + +function uvScale(g, su, sv, ou = 0, ov = 0) { + const uv = g.attributes.uv; + for (let i = 0; i < uv.count; i++) { + uv.setXY(i, uv.getX(i) * su + ou, uv.getY(i) * sv + ov); + } + uv.needsUpdate = true; +} + +export function buildShip(scene, rand) { + const group = new THREE.Group(); + const colliders = []; + const interactables = []; + const lights = []; // { light, day, night } + const emissives = []; // { mat, day, night } + const batch = new Batch(); + + // ---------------------------------------------------------------- materials + const hull = makeHullMaps(rand); + const hullLower = makeHullMaps(mulberry32((rand() * 0xffffffff) >>> 0), { base: [40, 8, 0.40] }); + const metal = makeMetalMaps(rand); + const metalDark = makeMetalMaps(rand, { tone: 58 }); + const floorMaps = makeFloorMaps(rand); + const fabricW = makeFabricMaps(rand, { color: '#cbc2ae' }); + const fabricO = makeFabricMaps(rand, { color: '#a04e1c' }); + const grate = makeGrateMaps(rand); + const hazardMap = makeHazardMap(rand); + + const mats = { + hull: new THREE.MeshStandardMaterial({ + map: hull.map, roughnessMap: hull.roughnessMap, normalMap: hull.normalMap, + roughness: 1, metalness: 0.22, envMapIntensity: 0.7, + normalScale: new THREE.Vector2(0.8, 0.8), + }), + hullLower: new THREE.MeshStandardMaterial({ + map: hullLower.map, roughnessMap: hullLower.roughnessMap, normalMap: hullLower.normalMap, + roughness: 1, metalness: 0.3, envMapIntensity: 0.6, + normalScale: new THREE.Vector2(0.8, 0.8), + }), + metal: new THREE.MeshStandardMaterial({ + map: metal.map, roughnessMap: metal.roughnessMap, normalMap: metal.normalMap, + roughness: 0.85, metalness: 0.95, envMapIntensity: 1.0, + normalScale: new THREE.Vector2(0.5, 0.5), + }), + metalDark: new THREE.MeshStandardMaterial({ + map: metalDark.map, roughnessMap: metalDark.roughnessMap, normalMap: metalDark.normalMap, + roughness: 0.9, metalness: 0.9, envMapIntensity: 0.9, + normalScale: new THREE.Vector2(0.6, 0.6), + }), + metalTube: new THREE.MeshStandardMaterial({ + map: metalDark.map, roughnessMap: metalDark.roughnessMap, + roughness: 0.9, metalness: 0.9, envMapIntensity: 0.7, side: THREE.DoubleSide, + }), + floor: new THREE.MeshStandardMaterial({ + map: floorMaps.map, roughnessMap: floorMaps.roughnessMap, normalMap: floorMaps.normalMap, + roughness: 0.9, metalness: 0.55, envMapIntensity: 1.0, + normalScale: new THREE.Vector2(1.1, 1.1), + }), + rubber: new THREE.MeshStandardMaterial({ + color: 0x1d1e20, roughness: 0.92, metalness: 0.0, envMapIntensity: 0.25, + }), + fabricWhite: new THREE.MeshStandardMaterial({ + map: fabricW.map, normalMap: fabricW.normalMap, + roughness: 0.96, metalness: 0, envMapIntensity: 0.3, + }), + fabricOrange: new THREE.MeshStandardMaterial({ + map: fabricO.map, normalMap: fabricO.normalMap, + roughness: 0.96, metalness: 0, envMapIntensity: 0.3, + }), + grate: new THREE.MeshStandardMaterial({ + map: grate.map, alphaMap: grate.alphaMap, alphaTest: 0.5, + roughness: 0.8, metalness: 0.9, side: THREE.DoubleSide, envMapIntensity: 0.6, + }), + hazard: new THREE.MeshStandardMaterial({ + map: hazardMap, roughness: 0.7, metalness: 0.3, envMapIntensity: 0.5, + }), + glass: new THREE.MeshStandardMaterial({ + color: 0x6a8fa0, roughness: 0.08, metalness: 0.0, + transparent: true, opacity: 0.06, envMapIntensity: 0.3, + depthWrite: false, side: THREE.DoubleSide, + }), + mirror: new THREE.MeshStandardMaterial({ + color: 0xc8d4d8, roughness: 0.05, metalness: 1.0, envMapIntensity: 1.8, + }), + plastic: new THREE.MeshStandardMaterial({ + color: 0xd8d4c8, roughness: 0.5, metalness: 0.1, envMapIntensity: 0.4, + }), + // emissives + stripWarm: new THREE.MeshStandardMaterial({ + color: 0x111111, emissive: 0xffd9a8, emissiveIntensity: 1.5, roughness: 0.4, + }), + stripTeal: new THREE.MeshStandardMaterial({ + color: 0x05110f, emissive: 0x19d4d0, emissiveIntensity: 2.4, roughness: 0.4, + }), + stripOrange: new THREE.MeshStandardMaterial({ + color: 0x110803, emissive: 0xff7a20, emissiveIntensity: 1.5, roughness: 0.4, + }), + ledRed: new THREE.MeshStandardMaterial({ + color: 0x110404, emissive: 0xff3020, emissiveIntensity: 1.6, roughness: 0.4, + }), + stripTealDim: new THREE.MeshStandardMaterial({ + color: 0x05110f, emissive: 0x19d4d0, emissiveIntensity: 1.0, roughness: 0.4, + }), + }; + emissives.push({ mat: mats.stripTealDim, day: 1.0, night: 1.4 }); + emissives.push({ mat: mats.stripWarm, day: 1.5, night: 0.35 }); + emissives.push({ mat: mats.stripTeal, day: 2.4, night: 3.0 }); + emissives.push({ mat: mats.stripOrange, day: 1.5, night: 1.0 }); + + const screenMats = {}; + for (const kind of ['nav', 'eng', 'wave', 'text']) { + const m = makeScreenMap(rand, kind); + screenMats[kind] = new THREE.MeshStandardMaterial({ + color: 0x000000, emissive: 0xffffff, emissiveMap: m, emissiveIntensity: 1.5, + roughness: 0.25, metalness: 0.0, + }); + emissives.push({ mat: screenMats[kind], day: 1.5, night: 0.9 }); + } + + // ------------------------------------------------------------ geometry utils + const HSU = 1 / 4.8, HSV = 1 / 2.5; // hull texture: 4.8m x 2.5m + const WALL_T = 0.12; + const CEIL = 2.5; + + function box(mat, w, h, d, x, y, z, o = {}) { + const g = new THREE.BoxGeometry(w, h, d); + if (o.hullUV) uvBoxWorld(g, w, h, d, HSU, HSV, o.ou || 0, o.ov || 0); + else if (o.texel) uvBoxWorld(g, w, h, d, o.texel, o.texel); + M.compose(V.set(x, y, z), Q.setFromEuler(E.set(o.rx || 0, o.ry || 0, o.rz || 0)), ONE); + g.applyMatrix4(M); + if (o.collide) { + g.computeBoundingBox(); + colliders.push(g.boundingBox.clone()); + } + batch.add(mat, g); + } + function cyl(mat, rTop, rBot, h, segs, x, y, z, o = {}) { + const g = new THREE.CylinderGeometry(rTop, rBot, h, segs, 1, o.open || false); + if (o.texel) uvScale(g, o.texel * Math.PI * 2 * rTop, o.texel * h); + M.compose(V.set(x, y, z), Q.setFromEuler(E.set(o.rx || 0, o.ry || 0, o.rz || 0)), ONE); + g.applyMatrix4(M); + if (o.collide) { g.computeBoundingBox(); colliders.push(g.boundingBox.clone()); } + batch.add(mat, g); + } + function torus(mat, R, r, x, y, z, o = {}) { + const g = new THREE.TorusGeometry(R, r, 8, 24, o.arc || Math.PI * 2); + M.compose(V.set(x, y, z), Q.setFromEuler(E.set(o.rx || 0, o.ry || 0, o.rz || 0)), ONE); + g.applyMatrix4(M); + batch.add(mat, g); + } + function collideBox(x1, y1, z1, x2, y2, z2) { + colliders.push(new THREE.Box3(new THREE.Vector3(x1, y1, z1), new THREE.Vector3(x2, y2, z2))); + } + + // Wall panel with a circular hole (for portholes). Local: spans length along + // +X, height from 0, hole at (0, holeY). Rotated by ry then moved to (x,0,z). + function holedPanel(mat, len, hgt, holeY, holeR, x, z, ry, uOff = 0, vOff = 0) { + const shape = new THREE.Shape(); + shape.moveTo(-len / 2, 0); + shape.lineTo(len / 2, 0); + shape.lineTo(len / 2, hgt); + shape.lineTo(-len / 2, hgt); + shape.closePath(); + const hole = new THREE.Path(); + hole.absarc(0, holeY, holeR, 0, Math.PI * 2, true); + shape.holes.push(hole); + const g = new THREE.ExtrudeGeometry(shape, { depth: WALL_T, bevelEnabled: false, curveSegments: 24 }); + uvScale(g, HSU, HSV, uOff, vOff); + g.translate(0, 0, -WALL_T / 2); + M.compose(V.set(x, 0, z), Q.setFromEuler(E.set(0, ry, 0)), ONE); + g.applyMatrix4(M); + batch.add(mat, g); + } + + // Plain wall span (lower dark band + upper hull) along Z at given x. + function wallSpanZ(x, z0, z1, ry) { + const len = z1 - z0, zc = (z0 + z1) / 2; + box(mats.hullLower, WALL_T, 0.5, len, x, 0.25, zc, { collide: true, texel: 0.5 }); + const g = new THREE.BoxGeometry(len, CEIL - 0.5, WALL_T); + uvBoxWorld(g, len, CEIL - 0.5, WALL_T, HSU, HSV, (z0 + 8) * HSU, 0.5 * HSV); + M.compose(V.set(x, (CEIL - 0.5) / 2 + 0.5, zc), Q.setFromEuler(E.set(0, ry, 0)), ONE); + g.applyMatrix4(M); + g.computeBoundingBox(); + colliders.push(g.boundingBox.clone()); + batch.add(mats.hull, g); + } + // Plain wall span along X at given z. + function wallSpanX(z, x0, x1, flip = false) { + const len = x1 - x0, xc = (x0 + x1) / 2; + box(mats.hullLower, len, 0.5, WALL_T, xc, 0.25, z, { collide: true, texel: 0.5 }); + const g = new THREE.BoxGeometry(len, CEIL - 0.5, WALL_T); + uvBoxWorld(g, len, CEIL - 0.5, WALL_T, HSU, HSV, (x0 + 8) * HSU, 0.5 * HSV); + M.compose(V.set(xc, (CEIL - 0.5) / 2 + 0.5, z), Q.setFromEuler(E.set(0, flip ? Math.PI : 0, 0)), ONE); + g.applyMatrix4(M); + g.computeBoundingBox(); + colliders.push(g.boundingBox.clone()); + batch.add(mats.hull, g); + } + + // Porthole assembly at a wall position. `dir` is outward normal sign on X. + function porthole(x, z, dir) { + torus(mats.metal, 0.46, 0.07, x - dir * 0.02, 1.6, z, { ry: Math.PI / 2 }); + torus(mats.metalDark, 0.38, 0.035, x - dir * 0.08, 1.6, z, { ry: Math.PI / 2 }); + const g = new THREE.CylinderGeometry(0.40, 0.40, 0.02, 24); + M.compose(V.set(x + dir * 0.10, 1.6, z), Q.setFromEuler(E.set(0, 0, Math.PI / 2)), ONE); + g.applyMatrix4(M); + batch.add(mats.glass, g); + for (let i = 0; i < 8; i++) { + const a = (i / 8) * Math.PI * 2 + 0.39; + cyl(mats.metalDark, 0.028, 0.028, 0.05, 8, x - dir * 0.05, 1.6 + Math.cos(a) * 0.51, z + Math.sin(a) * 0.51, { rz: Math.PI / 2 }); + } + // depth tube through the wall + cyl(mats.metalTube, 0.42, 0.42, 0.30, 18, x + dir * 0.06, 1.6, z, { rz: Math.PI / 2, open: true }); + } + + // ========================================================================= + // CORRIDOR x[-1.2,1.2] z[-8,8] + // ========================================================================= + const CW = 1.2; + + { + // width 1.6 / length 16.0: butt-joints against the trenches and the + // cockpit floor instead of overlapping them coplanar at y=0 + const g = new THREE.BoxGeometry(1.6, 0.1, 16.0); + uvBoxWorld(g, 1.6, 0.1, 16.0, 1 / 2.4, 1 / 2.4); + M.makeTranslation(0, -0.05, 0); + g.applyMatrix4(M); + batch.add(mats.floor, g); + } + // side floor trenches with teal glow + grates + for (const s of [-1, 1]) { + box(mats.metalDark, 0.4, 0.1, 16.0, s * 1.0, -0.1, 0, { texel: 1 }); + box(mats.stripTeal, 0.34, 0.02, 15.6, s * 1.0, -0.062, 0, {}); + const g = new THREE.BoxGeometry(0.4, 0.012, 16.0); + uvBoxWorld(g, 0.4, 0.012, 16.0, 2.5, 2.5); + M.makeTranslation(s * 1.0, -0.006, 0); + g.applyMatrix4(M); + batch.add(mats.grate, g); + // wall-base edge light strips, broken at the doorways, embedded into the wall + const stripSegs = s > 0 + ? [[-7.8, 1.55], [2.85, 7.8]] + : [[-7.8, -4.05], [-2.75, 3.05], [4.15, 7.8]]; + for (const [z0, z1] of stripSegs) { + box(mats.stripTeal, 0.025, 0.03, z1 - z0, s * (CW + 0.01), 0.04, (z0 + z1) / 2, {}); + } + } + box(mats.hullLower, 2.4, 0.1, 16.4, 0, CEIL + 0.05, 0, { hullUV: true }); + + // Corridor walls. + // Right (x=+1.2, faces -x): quarters door z[1.65,2.75]; porthole z=-4. + // Left (x=-1.2, faces +x): galley door z[-3.95,-2.85]; bathroom door z[3.15,4.05]; porthole z=0.7. + const RWX = CW + WALL_T / 2; + // right wall + wallSpanZ(RWX, -8, -4.6, -Math.PI / 2); + holedPanel(mats.hull, 1.2, CEIL, 1.6, 0.43, RWX, -4.0, -Math.PI / 2); + collideBox(CW, 0, -4.6, CW + WALL_T, CEIL, -3.4); + wallSpanZ(RWX, -3.4, 1.65, -Math.PI / 2); + wallSpanZ(RWX, 2.75, 8, -Math.PI / 2); + // left wall + wallSpanZ(-RWX, -8, -3.95, Math.PI / 2); + wallSpanZ(-RWX, -2.85, 0.1, Math.PI / 2); + holedPanel(mats.hull, 1.2, CEIL, 1.6, 0.43, -RWX, 0.7, Math.PI / 2); + collideBox(-CW - WALL_T, 0, 0.1, -CW, CEIL, 1.3); + wallSpanZ(-RWX, 1.3, 3.15, Math.PI / 2); + wallSpanZ(-RWX, 4.05, 8, Math.PI / 2); + + // door headers + frames + hazard trims + function doorTrim(side, z0, z1) { + const x = side * RWX; + const len = z1 - z0, zc = (z0 + z1) / 2; + box(mats.hull, WALL_T, CEIL - 2.1, len, x, (CEIL + 2.1) / 2, zc, { collide: true, hullUV: true }); + // posts overlap 3 cm into the wall cut so no face is coplanar with the cut plane + box(mats.metalDark, 0.3, 2.16, 0.18, x, 1.05, z0 - 0.06, { texel: 1 }); + box(mats.metalDark, 0.3, 2.16, 0.18, x, 1.05, z1 + 0.06, { texel: 1 }); + box(mats.metalDark, 0.3, 0.14, len + 0.36, x, 2.16, zc, { texel: 1 }); + // vertical hazard strips on door posts (corridor side) + box(mats.hazard, 0.015, 1.8, 0.1, x - side * 0.155, 0.95, z0 - 0.06, {}); + box(mats.hazard, 0.015, 1.8, 0.1, x - side * 0.155, 0.95, z1 + 0.06, {}); + // door sign light above + box(mats.stripOrange, 0.03, 0.06, 0.45, x - side * 0.145, 2.32, zc, {}); + // threshold sill plate (covers the floor seam through the doorway) + box(mats.metalDark, 0.44, 0.02, len + 0.2, x, 0.01, zc, { texel: 2 }); + } + doorTrim(1, 1.65, 2.75); + doorTrim(-1, -3.95, -2.85); + doorTrim(-1, 3.15, 4.05); + + // corridor ribs every 2 m + for (let z = -7; z <= 7; z += 2) { + if (Math.abs(z - 2.2) < 0.8 || Math.abs(z + 3.4) < 0.8 || Math.abs(z - 3.6) < 0.8) continue; + if (Math.abs(z + 4) < 0.7 || Math.abs(z - 0.7) < 0.7) continue; // portholes + for (const s of [-1, 1]) { + box(mats.metal, 0.18, CEIL, 0.22, s * (CW - 0.09), CEIL / 2, z, { texel: 1, collide: true }); + box(mats.metal, 0.5, 0.18, 0.22, s * (CW - 0.28), CEIL - 0.22, z, { rz: s * 0.6, texel: 1 }); + box(mats.metalDark, 0.22, 0.3, 0.26, s * (CW - 0.09), 0.15, z, { texel: 1 }); + } + box(mats.metal, 2.4, 0.16, 0.22, 0, CEIL - 0.08, z, { texel: 1 }); + box(mats.stripTeal, 0.04, 0.18, 0.05, -(CW - 0.09) + 0.11, 1.65, z, {}); + box(mats.stripOrange, 0.04, 0.05, 0.05, (CW - 0.09) - 0.11, 1.65, z, {}); + } + + // ceiling light fixtures (with diffuser slats to break up the glow quad) + for (let z = -6; z <= 6; z += 3) { + // housing spans y 2.43..2.5; strip pokes ~1.5cm below it (top embedded) + box(mats.metalDark, 0.7, 0.07, 1.4, 0, CEIL - 0.035, z, { texel: 1 }); + box(mats.stripWarm, 0.4, 0.02, 1.05, 0, CEIL - 0.075, z, {}); + for (let k = -2; k <= 2; k++) { + box(mats.metalDark, 0.46, 0.025, 0.05, 0, CEIL - 0.085, z + k * 0.22, {}); + } + } + for (const z of [-6, 0, 6]) { + // downlight spots: ceiling fixtures read as emissive, light pools on the deck + const pl = new THREE.SpotLight(0xffd9a8, 18, 7, 1.25, 0.7, 2); + pl.position.set(0, CEIL - 0.15, z); + pl.target.position.set(0, 0, z); + group.add(pl, pl.target); + lights.push({ light: pl, day: 18, night: 2.0 }); + } + { + const nl = new THREE.PointLight(0x2a55a0, 0, 12, 2); + nl.position.set(0, CEIL - 0.3, 0); + group.add(nl); + lights.push({ light: nl, day: 0, night: 9 }); + } + + // ceiling pipe runs + clamps + for (const s of [-1, 1]) { + const radii = [0.055, 0.04, 0.07]; + for (let i = 0; i < 3; i++) { + const r = radii[i]; + const px = s * (CW - 0.18 - i * 0.14); + cyl(i === 1 ? mats.metalDark : mats.metal, r, r, 16.0, 10, px, CEIL - 0.16 - (i === 2 ? 0.11 : 0), 0, { rx: Math.PI / 2, texel: 1 }); + } + for (let z = -7; z <= 7; z += 2) { + box(mats.metalDark, 0.46, 0.06, 0.08, s * (CW - 0.32), CEIL - 0.18, z, { texel: 1 }); + } + } + + // wall conduits + junction boxes between ribs. + // Openings (doors with frames, portholes) per side — nothing may overlap these. + const wallOpenings = { + // right wall: quarters door frame + porthole + 1: [[1.45, 2.95], [-4.75, -3.25]], + // left wall: galley door, bathroom door, porthole + [-1]: [[-4.15, -2.65], [2.95, 4.25], [0.1, 1.3]], + }; + const overlapsOpening = (s, z0, z1) => + wallOpenings[s].some(([b0, b1]) => z0 < b1 && z1 > b0); + for (let z = -7; z < 8; z += 2) { + for (const s of [-1, 1]) { + const zc = z + 1; + const x = s * (CW - 0.04); + // conduit pair spans zc ± 0.85 + if (!overlapsOpening(s, zc - 0.9, zc + 0.9)) { + cyl(mats.metalDark, 0.025, 0.025, 1.7, 8, x, 0.95, zc, { rx: Math.PI / 2 }); + cyl(mats.metalDark, 0.018, 0.018, 1.7, 8, x, 1.03, zc, { rx: Math.PI / 2 }); + // junction boxes staggered per side to break the mirror symmetry + if ((s > 0 ? (z + 7) % 4 : (z + 9) % 4) === 0 && !overlapsOpening(s, zc - 0.3, zc + 0.3)) { + box(mats.metal, 0.07, 0.34, 0.5, x, 1.3, zc, { texel: 2 }); + box(mats.stripTeal, 0.02, 0.04, 0.04, x - s * 0.05, 1.4, zc - 0.15, {}); + box(mats.ledRed, 0.02, 0.04, 0.04, x - s * 0.05, 1.4, zc, {}); + } + } + } + } + + porthole(RWX, -4.0, 1); + porthole(-RWX, 0.7, -1); + + // hazard threshold stripes on the deck at both bulkheads (within the floor + // slab so they don't hang over the side trenches) + box(mats.hazard, 1.6, 0.006, 0.18, 0, 0.003, -7.72, {}); + box(mats.hazard, 1.6, 0.006, 0.18, 0, 0.003, 7.6, {}); + // floor cable run from the maintenance recess toward engineering + cyl(mats.rubber, 0.014, 0.014, 3.6, 6, -0.72, 0.014, 5.4, { rx: Math.PI / 2 }); + cyl(mats.rubber, 0.014, 0.014, 0.5, 6, -0.95, 0.014, 5.18, { rx: Math.PI / 2, ry: 1.1 }); + for (const cz of [4.2, 5.6, 6.8]) box(mats.metalDark, 0.06, 0.025, 0.05, -0.72, 0.012, cz, {}); + // overhead grab handles, alternating sides + for (const [hz, hs] of [[-4.5, -1], [-0.5, 1], [3.4, -1]]) { + const hx = hs * 0.45; + box(mats.metalDark, 0.05, 0.16, 0.05, hx - 0.14, CEIL - 0.1, hz, {}); + box(mats.metalDark, 0.05, 0.16, 0.05, hx + 0.14, CEIL - 0.1, hz, {}); + box(mats.metal, 0.34, 0.045, 0.05, hx, CEIL - 0.2, hz, { texel: 2 }); + } + + // lived-in props: crate stack near the engineering hatch + box(mats.metalDark, 0.52, 0.52, 0.52, 0.82, 0.26, 7.3, { ry: 0.12, texel: 1, collide: true }); + box(mats.hullLower, 0.42, 0.42, 0.42, 0.80, 0.73, 7.32, { ry: -0.2, hullUV: true }); + box(mats.hazard, 0.53, 0.1, 0.53, 0.82, 0.30, 7.3, { ry: 0.12 }); + box(mats.hullLower, 0.46, 0.4, 0.46, -0.85, 0.2, 6.9, { ry: 0.35, hullUV: true, collide: true }); + box(mats.stripOrange, 0.05, 0.03, 0.05, -0.85, 0.42, 6.9, { ry: 0.35 }); + + // open maintenance recess on the left wall (panel leaning below) + { + const px = -CW - 0.02, pz = 5.2; + box(mats.rubber, 0.1, 0.9, 0.7, px, 1.15, pz, {}); + cyl(mats.metal, 0.03, 0.03, 0.8, 8, px + 0.03, 1.15, pz - 0.15, {}); + cyl(mats.metalDark, 0.022, 0.022, 0.8, 8, px + 0.03, 1.15, pz + 0.02, {}); + cyl(mats.metalDark, 0.016, 0.016, 0.8, 8, px + 0.04, 1.15, pz + 0.16, {}); + box(mats.stripTeal, 0.03, 0.04, 0.04, px + 0.04, 1.45, pz + 0.24, {}); + box(mats.ledRed, 0.03, 0.04, 0.04, px + 0.04, 1.32, pz + 0.24, {}); + box(mats.metalDark, 0.04, 0.96, 0.76, px - 0.04, 1.15, pz, { texel: 1 }); + // leaning panel + box(mats.hull, 0.04, 0.8, 0.6, px + 0.22, 0.42, pz - 0.5, { rz: -0.28, ry: 0.1, hullUV: true, collide: true }); + } + + // ============================ COCKPIT z[-13.4,-8] ============================ + { + const bz = -8 - WALL_T / 2; + // bulkhead with center opening x[-0.7,0.7] + box(mats.hull, 1.0, CEIL, WALL_T, -1.2, CEIL / 2, bz, { hullUV: true, collide: true }); + box(mats.hull, 1.0, CEIL, WALL_T, 1.2, CEIL / 2, bz, { hullUV: true, collide: true }); + box(mats.hull, 1.4, CEIL - 2.1, WALL_T, 0, (CEIL + 2.1) / 2, bz, { hullUV: true }); + box(mats.metalDark, 0.34, 2.2, 0.3, -0.78, 1.05, bz, { collide: true, texel: 1 }); + box(mats.metalDark, 0.34, 2.2, 0.3, 0.78, 1.05, bz, { collide: true, texel: 1 }); + box(mats.metalDark, 1.9, 0.18, 0.3, 0, 2.18, bz, { texel: 1 }); + box(mats.stripWarm, 1.3, 0.05, 0.06, 0, 2.12, bz - 0.16, {}); + // corner fillers behind bulkhead (cockpit is wider than corridor) + box(mats.hull, 1.0, CEIL, WALL_T, -1.95, CEIL / 2, bz - 0.12, { hullUV: true, collide: true }); + box(mats.hull, 1.0, CEIL, WALL_T, 1.95, CEIL / 2, bz - 0.12, { hullUV: true, collide: true }); + + // floor / ceiling + { + const g = new THREE.BoxGeometry(4.6, 0.1, 5.6); + uvBoxWorld(g, 4.6, 0.1, 5.6, 1 / 2.4, 1 / 2.4); + M.makeTranslation(0, -0.05, -10.8); + g.applyMatrix4(M); + batch.add(mats.floor, g); + } + box(mats.hullLower, 4.6, 0.1, 5.6, 0, CEIL + 0.05, -10.8, { hullUV: true }); + + // tapered side walls + for (const s of [-1, 1]) { + box(mats.hull, 0.12, CEIL, 5.2, s * 1.95, CEIL / 2, -10.5, { ry: s * 0.2, hullUV: true, collide: true }); + } + + // nose: sill, header, glass panels, mullions, corner posts + const noseZ = -12.9; + box(mats.hullLower, 4.2, 0.92, 0.45, 0, 0.46, noseZ + 0.05, { hullUV: true, collide: true }); + box(mats.hullLower, 4.2, 0.4, 0.6, 0, CEIL - 0.2, noseZ + 0.1, { hullUV: true }); + // raked glass: 3 near-coplanar panels + const panels = [ + { x: 0, w: 1.06, ry: 0 }, + { x: -1.08, w: 1.1, ry: 0.22 }, + { x: 1.08, w: 1.1, ry: -0.22 }, + ]; + for (const p of panels) { + const zoff = noseZ + Math.abs(p.x) * 0.12; + const g = new THREE.BoxGeometry(p.w, 1.46, 0.04); + M.compose(V.set(p.x, 1.62, zoff), Q.setFromEuler(E.set(-0.20, p.ry, 0)), ONE); + g.applyMatrix4(M); + batch.add(mats.glass, g); + } + // mullions between panels + for (const s of [-1, 1]) { + box(mats.metalDark, 0.10, 1.62, 0.18, s * 0.55, 1.6, noseZ + 0.03, { rx: -0.20, ry: s * 0.1, texel: 1 }); + } + // corner posts sealing the angled edges + for (const s of [-1, 1]) { + box(mats.hull, 0.55, CEIL, 0.7, s * 1.78, CEIL / 2, noseZ + 0.35, { ry: s * 0.45, hullUV: true, collide: true }); + } + collideBox(-2.2, 0, noseZ - 0.5, 2.2, CEIL, noseZ + 0.3); + + // dashboard + box(mats.metalDark, 3.4, 0.16, 0.9, 0, 0.97, -12.15, { rx: -0.18, texel: 1 }); + box(mats.hullLower, 3.4, 0.55, 0.7, 0, 0.62, -12.05, { hullUV: true, collide: true }); + // screen housing bank behind the screens + { + const g = new THREE.BoxGeometry(3.0, 0.46, 0.1); + uvBoxWorld(g, 3.0, 0.46, 0.1, 1, 1); + M.compose(V.set(0, 1.21, -12.42), Q.setFromEuler(E.set(-0.42, 0, 0)), ONE); + g.applyMatrix4(M); + batch.add(mats.metalDark, g); + } + const dashScreens = [ + { x: -1.05, kind: 'nav', w: 0.62 }, { x: -0.35, kind: 'wave', w: 0.6 }, + { x: 0.35, kind: 'eng', w: 0.6 }, { x: 1.05, kind: 'text', w: 0.62 }, + ]; + for (const s of dashScreens) { + const g = new THREE.BoxGeometry(s.w, 0.34, 0.02); + M.compose(V.set(s.x, 1.22, -12.36), Q.setFromEuler(E.set(-0.42, 0, 0)), ONE); + g.applyMatrix4(M); + batch.add(screenMats[s.kind], g); + } + // buttons sit on the sloped dash plate via its local axes (matching rx so + // no face intersects the slope at a shallow angle) + { + const dashY = new THREE.Vector3(0, Math.cos(0.18), -Math.sin(0.18)); + const dashZ = new THREE.Vector3(0, Math.sin(0.18), Math.cos(0.18)); + const dashC = new THREE.Vector3(0, 0.97, -12.15); + for (let i = 0; i < 26; i++) { + const u = -1.5 + rand() * 3.0; + const v = -0.38 + rand() * 0.74; + const mat = [mats.stripTeal, mats.stripOrange, mats.ledRed][rand() * 3 | 0]; + const p = dashC.clone().addScaledVector(dashY, 0.09).addScaledVector(dashZ, v); + box(mat, 0.035, 0.025, 0.035, u, p.y, p.z, { rx: -0.18 }); + } + } + // center pedestal + throttle levers + box(mats.metalDark, 0.5, 0.7, 0.8, 0, 0.35, -11.3, { collide: true, texel: 1 }); + box(mats.metal, 0.4, 0.06, 0.7, 0, 0.73, -11.3, { texel: 1 }); + for (const s of [-1, 1]) { + cyl(mats.metalDark, 0.02, 0.02, 0.26, 8, s * 0.1, 0.85, -11.35, { rx: -0.5 }); + box(mats.stripOrange, 0.07, 0.05, 0.07, s * 0.1, 0.96, -11.42, {}); + } + + // pilot seats + for (const s of [-1, 1]) { + const sx = s * 0.62, sz = -10.7; + cyl(mats.metalDark, 0.09, 0.13, 0.35, 10, sx, 0.18, sz, {}); + box(mats.rubber, 0.56, 0.13, 0.55, sx, 0.42, sz, { collide: true }); + box(mats.fabricOrange, 0.5, 0.07, 0.48, sx, 0.52, sz, { texel: 2 }); + box(mats.rubber, 0.56, 0.75, 0.14, sx, 0.82, sz + 0.3, { rx: 0.1, collide: true }); + box(mats.fabricOrange, 0.48, 0.6, 0.06, sx, 0.84, sz + 0.235, { rx: 0.1, texel: 2 }); + box(mats.rubber, 0.3, 0.2, 0.1, sx, 1.28, sz + 0.34, { rx: 0.1 }); + for (const a of [-1, 1]) box(mats.metalDark, 0.06, 0.05, 0.4, sx + a * 0.3, 0.62, sz + 0.05, { texel: 2 }); + } + + // overhead switch panel — switches placed on the panel's tilted underside + // using its local axes so they sit flush on the slope + box(mats.metalDark, 1.4, 0.06, 0.6, 0, CEIL - 0.28, -11.9, { rx: 0.3, texel: 1 }); + { + const panY = new THREE.Vector3(0, Math.cos(0.3), Math.sin(0.3)); + const panZ = new THREE.Vector3(0, -Math.sin(0.3), Math.cos(0.3)); + const panC = new THREE.Vector3(0, CEIL - 0.28, -11.9); + for (let i = 0; i < 12; i++) { + const mat = [mats.stripTeal, mats.stripWarm, mats.stripOrange][rand() * 3 | 0]; + const row = (i / 6) | 0; + const p = panC.clone() + .addScaledVector(panY, -0.04) + .addScaledVector(panZ, row === 0 ? -0.14 : 0.12); + box(mat, 0.04, 0.02, 0.04, -0.6 + (i % 6) * 0.24, p.y, p.z, { rx: 0.3 }); + } + } + + // side consoles + for (const s of [-1, 1]) { + box(mats.hullLower, 0.5, 0.85, 1.8, s * 1.58, 0.42, -10.6, { ry: s * 0.2, hullUV: true, collide: true }); + const g = new THREE.BoxGeometry(0.44, 0.3, 0.02); + M.compose(V.set(s * 1.47, 0.885, -10.6), Q.setFromEuler(E.set(-1.25, s * 0.2, 0)), ONE); + g.applyMatrix4(M); + batch.add(screenMats[s > 0 ? 'eng' : 'text'], g); + } + + // lights + box(mats.stripWarm, 0.6, 0.02, 0.3, 0, CEIL - 0.06, -9.0, {}); + const cl = new THREE.PointLight(0xffd0a0, 9, 6, 2); + cl.position.set(0, CEIL - 0.4, -9.2); + group.add(cl); + lights.push({ light: cl, day: 9, night: 1.2 }); + const cg = new THREE.PointLight(0x2ad2cc, 3, 3, 2); + cg.position.set(0, 1.25, -11.9); + group.add(cg); + lights.push({ light: cg, day: 3, night: 2.2 }); + // cool space fill spilling in through the viewport + const wf = new THREE.PointLight(0x9fc8e8, 4, 5, 2); + wf.position.set(0, 1.6, -12.4); + group.add(wf); + lights.push({ light: wf, day: 4, night: 4 }); + } + + // ============================ REAR BULKHEAD z=8 ============================ + { + const z = 8 + WALL_T / 2; + box(mats.hull, 2.6, CEIL, WALL_T, 0, CEIL / 2, z, { hullUV: true, collide: true }); + torus(mats.metal, 0.78, 0.1, 0, 1.25, z - 0.12, {}); + cyl(mats.metalDark, 0.72, 0.72, 0.08, 24, 0, 1.25, z - 0.1, { rx: Math.PI / 2, texel: 1 }); + for (let i = 0; i < 6; i++) { + const a = (i / 6) * Math.PI * 2; + box(mats.metal, 0.1, 0.62, 0.06, Math.cos(a) * 0.35, 1.25 + Math.sin(a) * 0.35, z - 0.16, { rz: a + Math.PI / 2, texel: 2 }); + } + torus(mats.metal, 0.2, 0.035, 0, 1.25, z - 0.22, {}); + cyl(mats.metalDark, 0.05, 0.05, 0.16, 8, 0, 1.25, z - 0.18, { rx: Math.PI / 2 }); + // hazard band above hatch + box(mats.hazard, 2.3, 0.18, 0.03, 0, 2.32, z - 0.09, {}); + box(mats.ledRed, 0.1, 0.06, 0.05, -0.9, 2.14, z - 0.1, {}); + box(mats.stripOrange, 0.1, 0.06, 0.05, 0.9, 2.14, z - 0.1, {}); + for (const s of [-1, 1]) { + cyl(mats.metal, 0.06, 0.06, 1.6, 10, s * 1.0, 1.9, z - 0.16, { rz: s * 1.0, texel: 1 }); + cyl(mats.metal, 0.06, 0.06, 1.2, 10, s * 0.5, 0.5, z - 0.16, { rz: s * 2.2, texel: 1 }); + torus(mats.metal, 0.09, 0.02, s * 0.9, 0.7, z - 0.24, {}); + } + collideBox(-1.3, 0, 7.85, 1.3, CEIL, 8.3); + } + + // ============================ CREW QUARTERS x[1.2,5.6] z[1.2,6.4] ========== + { + const x0 = 1.2 + WALL_T, x1 = 5.6, z0 = 1.2, z1 = 6.4; + const cxm = (x0 + x1) / 2, czm = (z0 + z1) / 2; + { + const g = new THREE.BoxGeometry(x1 - x0 + 0.2, 0.1, z1 - z0 + 0.2); + uvBoxWorld(g, x1 - x0, 0.1, z1 - z0, 1 / 2.4, 1 / 2.4); + M.makeTranslation(cxm, -0.05, czm); + g.applyMatrix4(M); + batch.add(mats.floor, g); + } + cyl(mats.fabricOrange, 0.8, 0.8, 0.025, 20, 3.0, 0.012, 3.4, { texel: 1 }); + box(mats.hullLower, x1 - x0 + 0.2, 0.1, z1 - z0 + 0.2, cxm, CEIL + 0.05, czm, { hullUV: true }); + + // outer wall x=5.6 with porthole at z=4.4 + const OWX = x1 + WALL_T / 2; + wallSpanZ(OWX, z0, 3.8, Math.PI / 2); + holedPanel(mats.hull, 1.2, CEIL, 1.6, 0.43, OWX, 4.4, Math.PI / 2); + collideBox(x1, 0, 3.8, x1 + WALL_T, CEIL, 5.0); + wallSpanZ(OWX, 5.0, z1, Math.PI / 2); + porthole(OWX, 4.4, 1); + // far + near walls + wallSpanX(z1 + WALL_T / 2, x0 - 0.15, x1 + 0.15, true); + wallSpanX(z0 - WALL_T / 2, x0 - 0.15, x1 + 0.15, false); + + // bunk against far wall + const bedX = 4.35, bedZ = 5.75; + box(mats.metalDark, 2.3, 0.4, 1.15, bedX, 0.2, bedZ, { collide: true, texel: 1 }); + box(mats.fabricWhite, 2.24, 0.18, 1.05, bedX, 0.49, bedZ, { texel: 2 }); + box(mats.fabricOrange, 1.5, 0.08, 1.07, bedX - 0.38, 0.60, bedZ, { texel: 2 }); + box(mats.fabricWhite, 0.5, 0.12, 0.7, bedX + 0.82, 0.61, bedZ, { ry: 0.08, texel: 2 }); + for (let i = 0; i < 3; i++) { + box(mats.hullLower, 0.68, 0.26, 0.04, bedX - 0.72 + i * 0.74, 0.18, bedZ - 0.595, { hullUV: true }); + box(mats.metal, 0.3, 0.03, 0.03, bedX - 0.72 + i * 0.74, 0.18, bedZ - 0.615, {}); + } + box(mats.stripTeal, 0.03, 0.03, 1.1, 5.59, 1.45, bedZ, {}); + box(mats.metalDark, 0.3, 0.04, 1.1, 5.46, 1.25, bedZ, { texel: 1 }); + cyl(mats.metal, 0.06, 0.06, 0.18, 10, 5.46, 1.36, bedZ - 0.3, { texel: 2 }); + box(mats.fabricOrange, 0.14, 0.18, 0.1, 5.46, 1.36, bedZ + 0.25, { ry: 0.4, texel: 2 }); + // wall cabinet above the bed + box(mats.hullLower, 0.4, 0.55, 1.4, 5.45, 2.05, bedZ + 0.1, { hullUV: true }); + box(mats.metal, 0.03, 0.2, 0.03, 5.24, 2.05, bedZ - 0.3, {}); + box(mats.metal, 0.03, 0.2, 0.03, 5.24, 2.05, bedZ + 0.5, {}); + box(mats.stripOrange, 0.02, 0.03, 1.2, 5.26, 1.81, bedZ + 0.1, {}); + + // lockers along near wall (backs embedded into the wall) + for (let i = 0; i < 3; i++) { + const lx = 2.2 + i * 0.78; + box(mats.hullLower, 0.72, 1.9, 0.5, lx, 0.95, z0 + 0.24, { collide: true, hullUV: true, ou: i * 0.3 }); + box(mats.metal, 0.05, 0.3, 0.03, lx + 0.25, 1.0, z0 + 0.5, {}); + for (let k = 0; k < 4; k++) box(mats.metalDark, 0.4, 0.025, 0.02, lx, 1.62 - k * 0.07, z0 + 0.495, {}); + box(i === 1 ? mats.stripTeal : mats.stripOrange, 0.08, 0.03, 0.02, lx - 0.2, 1.78, z0 + 0.495, {}); + } + + // desk + stool + wall screen + box(mats.metal, 0.6, 0.05, 1.1, 5.25, 0.78, 2.4, { collide: true, texel: 1 }); + box(mats.hullLower, 0.5, 0.76, 0.5, 5.3, 0.38, 2.7, { hullUV: true, collide: true }); + { + const qs = new THREE.BoxGeometry(0.02, 0.5, 0.8); + M.makeTranslation(5.595, 1.6, 2.4); + qs.applyMatrix4(M); + batch.add(screenMats['text'], qs); + } + cyl(mats.metalDark, 0.18, 0.22, 0.45, 12, 4.5, 0.22, 2.4, { collide: true }); + cyl(mats.fabricOrange, 0.2, 0.2, 0.06, 12, 4.5, 0.48, 2.4, { texel: 2 }); + + // reading lamp (warm key) in the far corner, clear of the porthole + cyl(mats.metalDark, 0.025, 0.04, 0.5, 8, 5.32, 1.9, 6.12, { rz: 0.5 }); + cyl(mats.metal, 0.09, 0.13, 0.16, 10, 5.2, 2.1, 6.1, { rz: 0.7, open: true }); + box(mats.stripWarm, 0.06, 0.04, 0.06, 5.2, 2.05, 6.1, {}); + const lamp = new THREE.SpotLight(0xffc890, 20, 8, 0.95, 0.55, 1.6); + lamp.position.set(5.12, 2.15, 6.05); + lamp.target.position.set(4.0, 0.5, 5.5); + lamp.castShadow = true; + lamp.shadow.mapSize.set(512, 512); + lamp.shadow.bias = -0.0015; + lamp.shadow.normalBias = 0.02; + group.add(lamp, lamp.target); + lights.push({ light: lamp, day: 20, night: 4 }); + box(mats.stripWarm, 0.5, 0.02, 0.5, 3.0, CEIL - 0.04, 3.2, {}); + const ql = new THREE.PointLight(0xffd9a8, 9, 6.5, 2); + ql.position.set(3.0, CEIL - 0.45, 3.2); + group.add(ql); + lights.push({ light: ql, day: 9, night: 1.0 }); + const qn = new THREE.PointLight(0x1980d4, 0, 7, 2); + qn.position.set(4.5, 1.0, 5.5); + group.add(qn); + lights.push({ light: qn, day: 0, night: 5 }); + + // greebles: conduit, junction, ceiling light housing + vent + cyl(mats.metalDark, 0.03, 0.03, 4.2, 8, 1.37, 2.3, czm + 0.3, { rx: Math.PI / 2 }); + box(mats.metal, 0.08, 0.3, 0.4, 1.35, 2.1, 4.0, { texel: 2 }); + box(mats.metalDark, 0.7, 0.07, 1.2, 3.0, CEIL - 0.035, 3.2, { texel: 1 }); + box(mats.metalDark, 0.5, 0.06, 0.7, 4.6, CEIL - 0.03, 2.0, { texel: 2 }); + for (let k = 0; k < 4; k++) box(mats.metal, 0.4, 0.02, 0.07, 4.6, CEIL - 0.065, 1.75 + k * 0.16, {}); + cyl(mats.metal, 0.045, 0.045, 4.0, 8, 3.4, CEIL - 0.1, 4.6, { rz: Math.PI / 2, texel: 1 }); + + // mug on desk, boots by the bed + cyl(mats.plastic, 0.035, 0.035, 0.09, 10, 5.2, 0.85, 2.2, {}); + box(mats.rubber, 0.11, 0.14, 0.3, 3.4, 0.07, 5.2, { ry: 0.3 }); + box(mats.rubber, 0.11, 0.14, 0.3, 3.65, 0.07, 5.05, { ry: -0.15 }); + + interactables.push({ + id: 'bed', + prompt: 'E: Sleep', + center: new THREE.Vector3(bedX, 0.55, bedZ), + size: new THREE.Vector3(2.4, 0.7, 1.25), + }); + } + + // ============================ GALLEY x[-5.2,-1.2] z[-5.6,-1.2] ============= + { + const x0 = -5.2, x1 = -1.2 - WALL_T, z0 = -5.6, z1 = -1.2; + const cxm = (x0 + x1) / 2, czm = (z0 + z1) / 2; + { + const g = new THREE.BoxGeometry(x1 - x0 + 0.2, 0.1, z1 - z0 + 0.2); + uvBoxWorld(g, x1 - x0, 0.1, z1 - z0, 1 / 2.4, 1 / 2.4); + M.makeTranslation(cxm, -0.05, czm); + g.applyMatrix4(M); + batch.add(mats.floor, g); + } + box(mats.hullLower, x1 - x0 + 0.2, 0.1, z1 - z0 + 0.2, cxm, CEIL + 0.05, czm, { hullUV: true }); + wallSpanZ(x0 - WALL_T / 2, z0, z1, Math.PI / 2); + wallSpanX(z0 - WALL_T / 2, x0 - 0.15, x1 + 0.15, false); + wallSpanX(z1 + WALL_T / 2, x0 - 0.15, x1 + 0.15, true); + + // counter run along x0 wall (body starts above the recessed toe-kick so + // their front faces are never coplanar) + const cD = 0.62; + box(mats.hullLower, cD, 0.76, 3.6, x0 + cD / 2, 0.48, czm, { collide: true, hullUV: true }); + box(mats.metal, cD + 0.06, 0.05, 3.66, x0 + cD / 2, 0.88, czm, { texel: 1 }); + box(mats.rubber, cD - 0.05, 0.1, 3.6, x0 + (cD - 0.05) / 2, 0.05, czm, {}); + box(mats.stripOrange, 0.02, 0.04, 3.3, x0 + cD + 0.005, 0.83, czm, {}); + for (let i = 0; i < 5; i++) { + box(mats.metal, 0.03, 0.03, 0.3, x0 + cD + 0.005, 0.68, z0 + 0.7 + i * 0.7, {}); + } + // sink + box(mats.metalDark, 0.4, 0.04, 0.5, x0 + cD / 2, 0.9, -4.5, { texel: 1 }); + cyl(mats.metal, 0.025, 0.025, 0.3, 8, x0 + 0.2, 1.0, -4.3, { rz: -0.5 }); + // cooktop with glowing rings + a pan left out + box(mats.rubber, 0.5, 0.012, 0.8, x0 + cD / 2, 0.906, -3.2, {}); + for (const dz of [-0.2, 0.2]) { + torus(mats.stripOrange, 0.11, 0.018, x0 + cD / 2, 0.915, -3.2 + dz, { rx: Math.PI / 2 }); + } + cyl(mats.metalDark, 0.13, 0.13, 0.05, 14, x0 + cD / 2, 0.94, -3.0, { open: false }); + cyl(mats.metalDark, 0.015, 0.015, 0.22, 6, x0 + cD / 2 + 0.2, 0.96, -3.0, { rz: Math.PI / 2 }); + cyl(mats.plastic, 0.035, 0.035, 0.09, 10, x0 + cD / 2 + 0.05, 0.95, -4.0, {}); + cyl(mats.plastic, 0.035, 0.035, 0.09, 10, x0 + cD / 2 - 0.12, 0.95, -3.85, {}); + // overhead cabinets + under-cabinet teal strip (backs embedded in the wall) + box(mats.hullLower, 0.45, 0.75, 3.4, x0 + 0.2, 1.95, czm, { hullUV: true }); + for (let i = 0; i < 4; i++) { + box(mats.metal, 0.03, 0.25, 0.03, x0 + 0.435, 1.95, z0 + 0.85 + i * 0.85, {}); + } + box(mats.stripTealDim, 0.012, 0.02, 3.2, x0 + 0.428, 1.56, czm, {}); + + // shelf with canisters on z0 wall (back embedded in the wall) + box(mats.metal, 1.6, 0.04, 0.35, -2.0, 1.5, z0 + 0.16, { texel: 1 }); + for (let i = 0; i < 5; i++) { + const ch = 0.16 + rand() * 0.18; + cyl(i % 2 ? mats.metal : mats.plastic, 0.07, 0.07, ch, 10, -2.7 + i * 0.36, 1.52 + ch / 2, z0 + 0.18, { texel: 2 }); + } + + // table + stools + cyl(mats.metalDark, 0.06, 0.1, 0.74, 10, -2.6, 0.37, -2.3, {}); + cyl(mats.metal, 0.55, 0.55, 0.05, 20, -2.6, 0.76, -2.3, { texel: 1, collide: true }); + for (const [sx, sz] of [[-3.3, -2.0], [-2.0, -2.8]]) { + cyl(mats.metalDark, 0.16, 0.2, 0.45, 12, sx, 0.22, sz, { collide: true }); + cyl(mats.fabricOrange, 0.18, 0.18, 0.06, 12, sx, 0.48, sz, { texel: 2 }); + } + + // wall menu screen (back embedded 5 mm into the wall) + { + const ms = new THREE.BoxGeometry(0.9, 0.55, 0.02); + M.compose(V.set(-3.0, 1.65, z1 + 0.005), Q.setFromEuler(E.set(0, Math.PI, 0)), ONE); + ms.applyMatrix4(M); + batch.add(screenMats['wave'], ms); + } + + // pendant lamp over table + cyl(mats.metalDark, 0.012, 0.012, 0.5, 6, -2.6, CEIL - 0.25, -2.3, {}); + cyl(mats.metal, 0.16, 0.05, 0.18, 12, -2.6, CEIL - 0.55, -2.3, { open: true }); + box(mats.stripWarm, 0.1, 0.03, 0.1, -2.6, CEIL - 0.62, -2.3, {}); + const pend = new THREE.SpotLight(0xffc890, 24, 7, 1.15, 0.6, 1.5); + pend.position.set(-2.6, CEIL - 0.6, -2.3); + pend.target.position.set(-2.6, 0, -2.3); + pend.castShadow = true; + pend.shadow.mapSize.set(512, 512); + pend.shadow.bias = -0.0015; + pend.shadow.normalBias = 0.02; + group.add(pend, pend.target); + lights.push({ light: pend, day: 24, night: 3 }); + const gFill = new THREE.PointLight(0xffd9a8, 8, 6, 2); + gFill.position.set(-4.2, 2.1, -3.4); + group.add(gFill); + lights.push({ light: gFill, day: 8, night: 0.9 }); + + interactables.push({ + id: 'galley', + prompt: 'E: Eat', + center: new THREE.Vector3(x0 + cD / 2, 0.7, -3.2), + size: new THREE.Vector3(0.9, 0.9, 1.3), + }); + } + + // ============================ BATHROOM x[-4.0,-1.2] z[2.6,5.4] ============= + { + const x0 = -4.0, x1 = -1.2 - WALL_T, z0 = 2.6, z1 = 5.4; + const cxm = (x0 + x1) / 2, czm = (z0 + z1) / 2; + { + const g = new THREE.BoxGeometry(x1 - x0 + 0.2, 0.1, z1 - z0 + 0.2); + uvBoxWorld(g, x1 - x0, 0.1, z1 - z0, 1 / 2.4, 1 / 2.4); + M.makeTranslation(cxm, -0.05, czm); + g.applyMatrix4(M); + batch.add(mats.floor, g); + } + box(mats.hullLower, x1 - x0 + 0.2, 0.1, z1 - z0 + 0.2, cxm, CEIL + 0.05, czm, { hullUV: true }); + wallSpanZ(x0 - WALL_T / 2, z0, z1, Math.PI / 2); + wallSpanX(z0 - WALL_T / 2, x0 - 0.15, x1 + 0.15, false); + wallSpanX(z1 + WALL_T / 2, x0 - 0.15, x1 + 0.15, true); + + // sink unit (backs embedded into the wall) + box(mats.hullLower, 0.45, 0.8, 0.9, x0 + 0.21, 0.45, 4.6, { collide: true, hullUV: true }); + box(mats.metal, 0.5, 0.06, 0.95, x0 + 0.23, 0.88, 4.6, { texel: 1 }); + cyl(mats.metalDark, 0.16, 0.2, 0.1, 16, x0 + 0.26, 0.93, 4.6, { open: true }); + cyl(mats.metal, 0.02, 0.02, 0.25, 8, x0 + 0.12, 1.05, 4.6, { rz: -0.6 }); + box(mats.mirror, 0.02, 0.7, 0.6, x0 + 0.04, 1.55, 4.6, {}); + box(mats.metalDark, 0.04, 0.78, 0.68, x0 + 0.015, 1.55, 4.6, { texel: 1 }); + box(mats.stripTeal, 0.03, 0.03, 0.6, x0 + 0.05, 1.95, 4.6, {}); + + // toilet unit (tank embedded into the wall) + box(mats.hullLower, 0.5, 0.42, 0.42, x0 + 0.3, 0.21, 3.1, { collide: true, hullUV: true }); + cyl(mats.plastic, 0.19, 0.21, 0.06, 14, x0 + 0.3, 0.45, 3.1, {}); + box(mats.hullLower, 0.16, 0.6, 0.5, x0 + 0.05, 0.72, 3.1, { hullUV: true }); + box(mats.stripTeal, 0.03, 0.04, 0.04, x0 + 0.135, 0.85, 3.1, {}); + + // shower pod corner + box(mats.rubber, 0.9, 0.04, 0.9, -1.85, 0.02, 4.85, {}); + cyl(mats.metal, 0.07, 0.07, 0.04, 12, -1.85, 2.3, 4.85, {}); + cyl(mats.metalDark, 0.02, 0.02, 2.3, 8, -1.45, 1.15, 4.95, {}); + { + const g = new THREE.BoxGeometry(0.04, 2.0, 0.9); + M.makeTranslation(-2.32, 1.0, 4.85); + g.applyMatrix4(M); + batch.add(mats.glass, g); + collideBox(-2.36, 0, 4.4, -2.28, 2.0, 5.3); + } + + // cool light + box(mats.stripTeal, 0.4, 0.02, 0.4, cxm, CEIL - 0.04, czm, {}); + const bl = new THREE.PointLight(0x9fe8e0, 8, 5.5, 2); + bl.position.set(cxm, CEIL - 0.3, czm); + group.add(bl); + lights.push({ light: bl, day: 8, night: 2.8 }); + + interactables.push({ + id: 'bathroom', + prompt: 'E: Freshen up', + center: new THREE.Vector3(x0 + 0.35, 0.9, 4.6), + size: new THREE.Vector3(0.8, 1.2, 1.1), + }); + } + + batch.build(group); + scene.add(group); + + return { group, colliders, interactables, lights, emissives, mats }; +} diff --git a/spaceship/src/space.js b/spaceship/src/space.js new file mode 100644 index 0000000..626453a --- /dev/null +++ b/spaceship/src/space.js @@ -0,0 +1,290 @@ +// Exterior space: parallax starfield, planets with atmosphere rim, nebulae, sun. +import * as THREE from 'three'; +import { makeStarSprite, makeNebulaSprite, makePlanetMap, makeRockyMap } from './textures.js'; + +// Sun sits behind-starboard-high so bodies ahead/port show lit faces to the ship. +const SUN_DIR = new THREE.Vector3(0.55, 0.28, 0.79).normalize(); +export { SUN_DIR }; + +function planetMaterial(map, rimColor, rimStrength = 1.4) { + return new THREE.ShaderMaterial({ + uniforms: { + map: { value: map }, + sunDir: { value: SUN_DIR.clone() }, + rimColor: { value: new THREE.Color(rimColor) }, + rimStrength: { value: rimStrength }, + }, + vertexShader: /* glsl */` + varying vec2 vUv; + varying vec3 vNormalW; + varying vec3 vPosW; + void main() { + vUv = uv; + vNormalW = normalize(mat3(modelMatrix) * normal); + vec4 wp = modelMatrix * vec4(position, 1.0); + vPosW = wp.xyz; + gl_Position = projectionMatrix * viewMatrix * wp; + } + `, + fragmentShader: /* glsl */` + uniform sampler2D map; + uniform vec3 sunDir; + uniform vec3 rimColor; + uniform float rimStrength; + varying vec2 vUv; + varying vec3 vNormalW; + varying vec3 vPosW; + void main() { + vec3 n = normalize(vNormalW); + vec3 viewDir = normalize(cameraPosition - vPosW); + vec3 tex = texture2D(map, vUv).rgb; + float d = clamp(dot(n, sunDir) * 1.15 + 0.18, 0.0, 1.0); + d = pow(d, 0.8); + vec3 col = tex * (d * 1.35 + 0.05); + float fres = pow(1.0 - clamp(dot(n, viewDir), 0.0, 1.0), 3.0); + col += rimColor * fres * rimStrength * (d * 0.85 + 0.15); + gl_FragColor = vec4(col, 1.0); + #include + } + `, + }); +} + +function atmosphereMaterial(color, intensity = 1.0) { + return new THREE.ShaderMaterial({ + uniforms: { + atmColor: { value: new THREE.Color(color) }, + sunDir: { value: SUN_DIR.clone() }, + intensity: { value: intensity }, + }, + vertexShader: /* glsl */` + varying vec3 vNormalW; + varying vec3 vPosW; + void main() { + vNormalW = normalize(mat3(modelMatrix) * normal); + vec4 wp = modelMatrix * vec4(position, 1.0); + vPosW = wp.xyz; + gl_Position = projectionMatrix * viewMatrix * wp; + } + `, + fragmentShader: /* glsl */` + uniform vec3 atmColor; + uniform vec3 sunDir; + uniform float intensity; + varying vec3 vNormalW; + varying vec3 vPosW; + void main() { + vec3 n = normalize(vNormalW); + vec3 viewDir = normalize(cameraPosition - vPosW); + float fres = 1.0 - clamp(dot(n, viewDir), 0.0, 1.0); + float a = pow(fres, 3.4); + float lit = clamp(dot(n, sunDir) * 1.2 + 0.25, 0.05, 1.0); + vec3 col = atmColor * a * intensity * lit; + gl_FragColor = vec4(col, a * lit); + #include + } + `, + transparent: true, + blending: THREE.AdditiveBlending, + depthWrite: false, + side: THREE.FrontSide, + }); +} + +export function buildSpace(scene, rand) { + const root = new THREE.Group(); + const starSprite = makeStarSprite(); + + // -------- parallax starfield: 3 drifting layers, wrap on Z + const layers = []; + const layerDefs = [ + { count: 1300, box: 700, size: 3.4, speed: 30, opacity: 1.0 }, + { count: 700, box: 900, size: 2.4, speed: 15, opacity: 0.85 }, + { count: 280, box: 1200, size: 1.7, speed: 7, opacity: 0.7 }, + ]; + for (const def of layerDefs) { + const pos = new Float32Array(def.count * 3); + const col = new Float32Array(def.count * 3); + const c = new THREE.Color(); + for (let i = 0; i < def.count; i++) { + pos[i * 3] = (rand() - 0.5) * def.box * 2; + pos[i * 3 + 1] = (rand() - 0.5) * def.box * 2; + pos[i * 3 + 2] = (rand() - 0.5) * def.box * 2; + const t = rand(); + if (t < 0.12) c.setHSL(0.07, 0.7, 0.75); // warm orange star + else if (t < 0.3) c.setHSL(0.55, 0.5, 0.8); // blue-white + else c.setHSL(0.12, 0.08, 0.62 + rand() * 0.3); // white + col[i * 3] = c.r; col[i * 3 + 1] = c.g; col[i * 3 + 2] = c.b; + } + const g = new THREE.BufferGeometry(); + g.setAttribute('position', new THREE.BufferAttribute(pos, 3)); + g.setAttribute('color', new THREE.BufferAttribute(col, 3)); + const m = new THREE.PointsMaterial({ + size: def.size, map: starSprite, vertexColors: true, + transparent: true, opacity: def.opacity, depthWrite: false, + blending: THREE.AdditiveBlending, sizeAttenuation: false, fog: false, + }); + const pts = new THREE.Points(g, m); + pts.frustumCulled = false; + root.add(pts); + layers.push({ pts, def }); + } + + // -------- speed streaks close to the hull (sell motion) + const streakCount = 90; + const streakPos = new Float32Array(streakCount * 2 * 3); + for (let i = 0; i < streakCount; i++) { + const x = (rand() - 0.5) * 120; + const y = (rand() - 0.5) * 80; + const z = (rand() - 0.5) * 300; + const len = 4 + rand() * 9; + streakPos[i * 6] = x; streakPos[i * 6 + 1] = y; streakPos[i * 6 + 2] = z; + streakPos[i * 6 + 3] = x; streakPos[i * 6 + 4] = y; streakPos[i * 6 + 5] = z + len; + } + const streakGeo = new THREE.BufferGeometry(); + streakGeo.setAttribute('position', new THREE.BufferAttribute(streakPos, 3)); + const streakMat = new THREE.LineBasicMaterial({ + color: 0xbfd8e8, transparent: true, opacity: 0.28, + blending: THREE.AdditiveBlending, fog: false, depthWrite: false, + }); + const streaks = new THREE.LineSegments(streakGeo, streakMat); + streaks.frustumCulled = false; + root.add(streaks); + + // -------- gas giant abeam port, slides past the left porthole + const gasMap = makePlanetMap(rand, { hueA: 14, hueB: 38 }); + const gas = new THREE.Mesh( + new THREE.SphereGeometry(260, 48, 32), + planetMaterial(gasMap, 0xffb46a, 2.4) + ); + const gasAtm = new THREE.Mesh( + new THREE.SphereGeometry(260 * 1.045, 48, 32), + atmosphereMaterial(0xff9a50, 2.2) + ); + const gasGroup = new THREE.Group(); + gasGroup.add(gas, gasAtm); + root.add(gasGroup); + + // -------- rocky moon ahead, visible through the cockpit viewport + const rockMap = makeRockyMap(rand); + const rock = new THREE.Mesh( + new THREE.SphereGeometry(150, 40, 28), + planetMaterial(rockMap, 0x8fd8e8, 1.5) + ); + const rockAtm = new THREE.Mesh( + new THREE.SphereGeometry(150 * 1.05, 40, 28), + atmosphereMaterial(0x6fc8e8, 1.5) + ); + const rockGroup = new THREE.Group(); + rockGroup.add(rock, rockAtm); + root.add(rockGroup); + + // -------- ringed crescent planet far starboard (rim-lit silhouette) + const ringedMat = planetMaterial(makePlanetMap(rand, { hueA: 200, hueB: 230, size: 512 }), 0x9fd8f0, 2.6); + const ringed = new THREE.Mesh(new THREE.SphereGeometry(170, 40, 28), ringedMat); + const ringedAtm = new THREE.Mesh( + new THREE.SphereGeometry(170 * 1.05, 40, 28), + atmosphereMaterial(0x7fc8e8, 2.0) + ); + // ring disc + const ringGeo = new THREE.RingGeometry(220, 360, 64); + { + // radial UV for ring shading + const pos = ringGeo.attributes.position; + const uv = ringGeo.attributes.uv; + for (let i = 0; i < pos.count; i++) { + const r = Math.hypot(pos.getX(i), pos.getY(i)); + uv.setXY(i, (r - 220) / 140, 0.5); + } + } + const ringMat = new THREE.MeshBasicMaterial({ + color: 0x8fb8c8, transparent: true, opacity: 0.30, + side: THREE.DoubleSide, fog: false, depthWrite: false, + }); + const ringMesh = new THREE.Mesh(ringGeo, ringMat); + ringMesh.rotation.x = Math.PI / 2.25; + ringMesh.rotation.y = 0.35; + const ringedGroup = new THREE.Group(); + ringedGroup.add(ringed, ringedAtm, ringMesh); + root.add(ringedGroup); + + // -------- nebula billboards + const nebDefs = [ + { col: [[14, 75, 55], [28, 80, 62]], pos: [900, 250, -1600], scale: 1500 }, + { col: [[180, 55, 45], [200, 60, 55]], pos: [-1400, -150, -900], scale: 1300 }, + { col: [[185, 60, 50], [16, 70, 55]], pos: [1500, 80, 600], scale: 1500 }, + { col: [[210, 45, 40], [180, 50, 45]], pos: [-600, 380, 1500], scale: 1100 }, + ]; + const nebulas = []; + for (const nd of nebDefs) { + const sm = new THREE.SpriteMaterial({ + map: makeNebulaSprite(rand, nd.col[0], nd.col[1]), + transparent: true, opacity: 0.85, depthWrite: false, + blending: THREE.AdditiveBlending, fog: false, + }); + const sp = new THREE.Sprite(sm); + sp.position.set(...nd.pos); + sp.scale.setScalar(nd.scale); + root.add(sp); + nebulas.push(sp); + } + + // -------- distant sun glow + { + const sunMat = new THREE.SpriteMaterial({ + map: makeStarSprite(), color: 0xfff2d8, transparent: true, + opacity: 0.95, depthWrite: false, blending: THREE.AdditiveBlending, fog: false, + }); + const sun = new THREE.Sprite(sunMat); + sun.position.copy(SUN_DIR).multiplyScalar(2400); + sun.scale.setScalar(260); + root.add(sun); + } + + scene.add(root); + + // animation state + let t0 = 0; + function update(dt, t) { + t0 = t; + // star drift (ship flying toward -Z, stars stream toward +Z) + for (const { pts, def } of layers) { + const arr = pts.geometry.attributes.position.array; + const lim = def.box; + for (let i = 2; i < arr.length; i += 3) { + arr[i] += def.speed * dt; + if (arr[i] > lim) arr[i] -= lim * 2; + } + pts.geometry.attributes.position.needsUpdate = true; + } + { + const arr = streaks.geometry.attributes.position.array; + for (let i = 0; i < arr.length; i += 6) { + arr[i + 2] += 150 * dt; + arr[i + 5] += 150 * dt; + if (arr[i + 2] > 180) { arr[i + 2] -= 360; arr[i + 5] -= 360; } + } + streaks.geometry.attributes.position.needsUpdate = true; + } + + // gas giant: slow orbit, abeam port at t=0, sliding aft past the left + // porthole over ~80 s + { + const ang = Math.PI + t * (Math.PI * 2 / 340); + const R = 980; + gasGroup.position.set(Math.cos(ang) * R, -120, Math.sin(ang) * R + 40); + gas.rotation.y = t * 0.01; + } + // rocky moon ahead, drifting starboard slowly across the viewport + { + const ang = Math.PI * 1.46 + t * (Math.PI * 2 / 480); + const R = 1000; + rockGroup.position.set(Math.cos(ang) * R, 55, Math.sin(ang) * R - 120); + rock.rotation.y = t * 0.02; + } + // ringed crescent: far starboard, slow aft drift + ringedGroup.position.set(1550, 90, -380 + t * 1.4); + } + + return { root, update }; +} diff --git a/spaceship/src/textures.js b/spaceship/src/textures.js new file mode 100644 index 0000000..c64cc23 --- /dev/null +++ b/spaceship/src/textures.js @@ -0,0 +1,666 @@ +// Procedural canvas texture generation. Everything in the game is drawn here. +import * as THREE from 'three'; + +export function mulberry32(seed) { + let a = seed >>> 0; + return function () { + a |= 0; a = (a + 0x6D2B79F5) | 0; + let t = Math.imul(a ^ (a >>> 15), 1 | a); + t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; + return ((t ^ (t >>> 14)) >>> 0) / 4294967296; + }; +} + +export function cv(w, h = w) { + const c = document.createElement('canvas'); + c.width = w; c.height = h; + return [c, c.getContext('2d', { willReadFrequently: true })]; +} + +export function tex(canvas, { srgb = true, repeat = null } = {}) { + const t = new THREE.CanvasTexture(canvas); + t.wrapS = t.wrapT = THREE.RepeatWrapping; + if (srgb) t.colorSpace = THREE.SRGBColorSpace; + t.anisotropy = 8; + if (repeat) t.repeat.set(repeat[0], repeat[1]); + return t; +} + +// Layered value-noise canvas (grayscale, centered around mid gray). +export function noiseCanvas(rand, size, octaves = 5, contrast = 1) { + const [c, ctx] = cv(size); + ctx.fillStyle = '#808080'; + ctx.fillRect(0, 0, size, size); + for (let o = 0; o < octaves; o++) { + const res = 4 << o; + const [oc, octx] = cv(res); + const img = octx.createImageData(res, res); + for (let i = 0; i < res * res; i++) { + const v = (rand() * 255) | 0; + img.data[i * 4] = v; img.data[i * 4 + 1] = v; img.data[i * 4 + 2] = v; img.data[i * 4 + 3] = 255; + } + octx.putImageData(img, 0, 0); + ctx.globalAlpha = 0.55 / (o + 1.2) * contrast; + ctx.imageSmoothingEnabled = true; + ctx.drawImage(oc, 0, 0, size, size); + } + ctx.globalAlpha = 1; + return c; +} + +// Sobel height -> tangent-space normal map. +export function normalFromHeight(heightCanvas, strength = 2.5) { + const w = heightCanvas.width, h = heightCanvas.height; + const sctx = heightCanvas.getContext('2d'); + const src = sctx.getImageData(0, 0, w, h).data; + const [c, ctx] = cv(w, h); + const out = ctx.createImageData(w, h); + const hAt = (x, y) => src[(((y + h) % h) * w + ((x + w) % w)) * 4] / 255; + for (let y = 0; y < h; y++) { + for (let x = 0; x < w; x++) { + const dx = (hAt(x + 1, y) - hAt(x - 1, y)) * strength; + const dy = (hAt(x, y + 1) - hAt(x, y - 1)) * strength; + const len = Math.sqrt(dx * dx + dy * dy + 1); + const i = (y * w + x) * 4; + out.data[i] = ((-dx / len) * 0.5 + 0.5) * 255; + out.data[i + 1] = ((dy / len) * 0.5 + 0.5) * 255; + out.data[i + 2] = (1 / len) * 0.5 + 0.5 > 1 ? 255 : ((1 / len) * 0.5 + 0.5) * 255; + out.data[i + 3] = 255; + } + } + ctx.putImageData(out, 0, 0); + return c; +} + +function scratches(ctx, rand, n, w, h, color, alpha, maxLen = 90) { + ctx.save(); + ctx.strokeStyle = color; + for (let i = 0; i < n; i++) { + ctx.globalAlpha = alpha * (0.3 + rand() * 0.7); + ctx.lineWidth = rand() < 0.8 ? 1 : 2; + const x = rand() * w, y = rand() * h; + const a = rand() * Math.PI * 2, l = 6 + rand() * maxLen; + ctx.beginPath(); + ctx.moveTo(x, y); + ctx.lineTo(x + Math.cos(a) * l, y + Math.sin(a) * l); + ctx.stroke(); + } + ctx.restore(); +} + +function stains(ctx, rand, n, w, h, color, alpha, maxR = 60) { + ctx.save(); + for (let i = 0; i < n; i++) { + const x = rand() * w, y = rand() * h, r = 8 + rand() * maxR; + const g = ctx.createRadialGradient(x, y, 0, x, y, r); + const a = alpha * (0.3 + rand() * 0.7); + g.addColorStop(0, color.replace('A', a.toFixed(3))); + g.addColorStop(1, color.replace('A', '0')); + ctx.fillStyle = g; + ctx.fillRect(x - r, y - r, r * 2, r * 2); + } + ctx.restore(); +} + +function bolt(ctx, hctx, x, y, r = 4) { + ctx.fillStyle = 'rgba(40,42,46,0.85)'; + ctx.beginPath(); ctx.arc(x, y, r, 0, 7); ctx.fill(); + ctx.fillStyle = 'rgba(150,150,155,0.9)'; + ctx.beginPath(); ctx.arc(x - r * 0.25, y - r * 0.25, r * 0.55, 0, 7); ctx.fill(); + if (hctx) { + hctx.fillStyle = '#2a2a2a'; + hctx.beginPath(); hctx.arc(x, y, r + 1, 0, 7); hctx.fill(); + hctx.fillStyle = '#b0b0b0'; + hctx.beginPath(); hctx.arc(x, y, r * 0.6, 0, 7); hctx.fill(); + } +} + +// --------------------------------------------------------------------------- +// Painted hull panels. Texture covers 4.8m x 2.5m (4 cols x 2 rows of panels). +// --------------------------------------------------------------------------- +export function makeHullMaps(rand, { base = [42, 12, 0.62], accent = '#b85c1e', size = 1024 } = {}) { + const W = size, H = Math.round(size * (2.5 / 4.8)); + const [c, ctx] = cv(W, H); + const [hc, hctx] = cv(W, H); + const [rc, rctx] = cv(W, H); + + hctx.fillStyle = '#7a7a7a'; hctx.fillRect(0, 0, W, H); + rctx.fillStyle = '#9c9c9c'; rctx.fillRect(0, 0, W, H); + + const cols = 4, rows = 2; + const pw = W / cols, ph = H / rows; + + for (let i = 0; i < cols; i++) { + for (let j = 0; j < rows; j++) { + const x = i * pw, y = j * ph; + const [hh, ss, ll] = base; + const dl = (rand() - 0.5) * 0.07; + const isAccent = rand() < 0.10; + ctx.fillStyle = isAccent ? accent : `hsl(${hh + (rand() - 0.5) * 8}, ${ss}%, ${(ll + dl) * 100}%)`; + ctx.fillRect(x, y, pw, ph); + + // panel inner inset + bevel + ctx.strokeStyle = 'rgba(0,0,0,0.32)'; + ctx.lineWidth = 3; + ctx.strokeRect(x + 10, y + 10, pw - 20, ph - 20); + ctx.strokeStyle = 'rgba(255,255,255,0.10)'; + ctx.lineWidth = 1.5; + ctx.strokeRect(x + 13, y + 13, pw - 26, ph - 26); + + hctx.fillStyle = '#6a6a6a'; + hctx.fillRect(x + 10, y + 10, pw - 20, ph - 20); + hctx.fillStyle = '#7e7e7e'; + hctx.fillRect(x + 16, y + 16, pw - 32, ph - 32); + + // some panels get a vent or a stripe or a label block + const det = rand(); + if (det < 0.22) { + // vent slots + const vx = x + pw * 0.25, vy = y + ph * (0.3 + rand() * 0.35), vw = pw * 0.5; + for (let k = 0; k < 5; k++) { + ctx.fillStyle = 'rgba(20,22,25,0.85)'; + ctx.fillRect(vx, vy + k * 9, vw, 4.5); + hctx.fillStyle = '#404040'; + hctx.fillRect(vx, vy + k * 9, vw, 4.5); + } + } else if (det < 0.40) { + // accent stripe + ctx.fillStyle = rand() < 0.6 ? accent : '#3d6e6c'; + const sy = y + ph * (0.18 + rand() * 0.5); + ctx.fillRect(x + 16, sy, pw - 32, 10 + rand() * 8); + ctx.globalAlpha = 0.25; + ctx.fillStyle = '#1c1c1c'; + for (let k = 0; k < 14; k++) ctx.fillRect(x + 16 + rand() * (pw - 36), sy + rand() * 14, 3 + rand() * 6, 2); + ctx.globalAlpha = 1; + } else if (det < 0.52) { + // stenciled label block + ctx.fillStyle = 'rgba(35,38,42,0.78)'; + const lx = x + pw * (0.1 + rand() * 0.4), ly = y + ph * (0.15 + rand() * 0.55); + for (let k = 0; k < 3 + rand() * 4; k++) { + ctx.fillRect(lx + k * 11, ly, 7, 12 + rand() * 6); + } + if (rand() < 0.5) { + ctx.fillStyle = accent; + ctx.fillRect(lx - 4, ly + 22, 30 + rand() * 30, 4); + } + } + + // corner bolts + bolt(ctx, hctx, x + 16, y + 16, 4); + bolt(ctx, hctx, x + pw - 16, y + 16, 4); + bolt(ctx, hctx, x + 16, y + ph - 16, 4); + bolt(ctx, hctx, x + pw - 16, y + ph - 16, 4); + + // roughness: painted = mid, with per-panel variation + rctx.fillStyle = `rgb(${140 + ((rand() * 40) | 0)},0,0)`; + const rv = 145 + ((rand() - 0.5) * 50) | 0; + rctx.fillStyle = `rgb(${rv},${rv},${rv})`; + rctx.fillRect(x + 2, y + 2, pw - 4, ph - 4); + } + } + + // seams between panels + ctx.strokeStyle = 'rgba(12,13,15,0.9)'; + ctx.lineWidth = 4; + hctx.strokeStyle = '#1e1e1e'; + hctx.lineWidth = 5; + for (let i = 0; i <= cols; i++) { + ctx.beginPath(); ctx.moveTo(i * pw, 0); ctx.lineTo(i * pw, H); ctx.stroke(); + hctx.beginPath(); hctx.moveTo(i * pw, 0); hctx.lineTo(i * pw, H); hctx.stroke(); + } + for (let j = 0; j <= rows; j++) { + ctx.beginPath(); ctx.moveTo(0, j * ph); ctx.lineTo(W, j * ph); ctx.stroke(); + hctx.beginPath(); hctx.moveTo(0, j * ph); hctx.lineTo(W, j * ph); hctx.stroke(); + } + + // grime: multiply noise, stronger near seams + const n = noiseCanvas(rand, 256, 5); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.38; + ctx.drawImage(n, 0, 0, W, H); + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + stains(ctx, rand, 26, W, H, 'rgba(48,40,30,A)', 0.34, 70); + stains(ctx, rand, 12, W, H, 'rgba(20,22,26,A)', 0.22, 40); + scratches(ctx, rand, 70, W, H, 'rgba(190,192,196,0.8)', 0.5, 60); + scratches(ctx, rand, 40, W, H, 'rgba(30,30,32,0.7)', 0.35, 80); + + // scratches make it shinier; grime rougher + scratches(rctx, rand, 70, W, H, 'rgba(70,70,70,1)', 0.5, 60); + rctx.globalCompositeOperation = 'lighten'; + rctx.globalAlpha = 0.35; + rctx.drawImage(n, 0, 0, W, H); + rctx.globalCompositeOperation = 'source-over'; + rctx.globalAlpha = 1; + + return { + map: tex(c), + roughnessMap: tex(rc, { srgb: false }), + normalMap: tex(normalFromHeight(hc, 2.0), { srgb: false }), + }; +} + +// --------------------------------------------------------------------------- +// Worn structural metal, 1m x 1m. +// --------------------------------------------------------------------------- +export function makeMetalMaps(rand, { tone = 96, brushed = true, size = 512 } = {}) { + const [c, ctx] = cv(size); + const [rc, rctx] = cv(size); + const [hc, hctx] = cv(size); + ctx.fillStyle = `rgb(${tone},${tone + 2},${tone + 6})`; + ctx.fillRect(0, 0, size, size); + hctx.fillStyle = '#808080'; hctx.fillRect(0, 0, size, size); + rctx.fillStyle = '#6e6e6e'; rctx.fillRect(0, 0, size, size); + + if (brushed) { + for (let i = 0; i < 420; i++) { + const y = rand() * size; + const a = 0.04 + rand() * 0.10; + const lum = rand() < 0.5 ? 255 : 0; + ctx.strokeStyle = `rgba(${lum},${lum},${lum},${a})`; + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.moveTo(0, y); ctx.lineTo(size, y); + ctx.stroke(); + rctx.strokeStyle = `rgba(${lum > 0 ? 60 : 140},${lum > 0 ? 60 : 140},${lum > 0 ? 60 : 140},${a * 1.4})`; + rctx.beginPath(); rctx.moveTo(0, y); rctx.lineTo(size, y); rctx.stroke(); + } + } + + const n = noiseCanvas(rand, 128, 4); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.32; + ctx.drawImage(n, 0, 0, size, size); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + + stains(ctx, rand, 16, size, size, 'rgba(30,26,20,A)', 0.4, 60); + scratches(ctx, rand, 90, size, size, 'rgba(210,212,218,0.9)', 0.45, 70); + scratches(ctx, rand, 50, size, size, 'rgba(25,25,28,0.8)', 0.4, 50); + scratches(rctx, rand, 90, size, size, 'rgba(55,55,55,1)', 0.5, 70); + rctx.globalCompositeOperation = 'lighten'; + rctx.globalAlpha = 0.45; + rctx.drawImage(n, 0, 0, size, size); + rctx.globalCompositeOperation = 'source-over'; + rctx.globalAlpha = 1; + stains(rctx, rand, 16, size, size, 'rgba(200,200,200,A)', 0.5, 60); + + return { + map: tex(c), + roughnessMap: tex(rc, { srgb: false }), + normalMap: tex(normalFromHeight(noiseCanvas(rand, 256, 5), 0.8), { srgb: false }), + }; +} + +// --------------------------------------------------------------------------- +// Deck floor: tread plate, 2.4m x 2.4m (2x2 plates of 1.2m). +// --------------------------------------------------------------------------- +export function makeFloorMaps(rand, { size = 1024 } = {}) { + const [c, ctx] = cv(size); + const [hc, hctx] = cv(size); + const [rc, rctx] = cv(size); + ctx.fillStyle = 'rgb(70,72,78)'; + ctx.fillRect(0, 0, size, size); + hctx.fillStyle = '#808080'; hctx.fillRect(0, 0, size, size); + rctx.fillStyle = '#787878'; rctx.fillRect(0, 0, size, size); + + // tread ovals + const step = size / 24; + for (let j = 0; j < 24; j++) { + for (let i = 0; i < 24; i++) { + const x = i * step + step / 2 + (j % 2 ? step / 2 : 0); + const y = j * step + step / 2; + const ang = (i + j) % 2 ? 0.78 : -0.78; + ctx.save(); hctx.save(); + ctx.translate(x % size, y); ctx.rotate(ang); + hctx.translate(x % size, y); hctx.rotate(ang); + ctx.fillStyle = 'rgba(86,88,94,0.9)'; + ctx.fillRect(-9, -3, 18, 6); + ctx.fillStyle = 'rgba(30,31,34,0.55)'; + ctx.fillRect(-9, 2, 18, 2); + hctx.fillStyle = '#b4b4b4'; + hctx.fillRect(-9, -3, 18, 6); + ctx.restore(); hctx.restore(); + } + } + + // plate seams every half texture (1.2 m) + for (const p of [0, size / 2, size]) { + ctx.strokeStyle = 'rgba(10,11,13,0.95)'; ctx.lineWidth = 6; + ctx.beginPath(); ctx.moveTo(p, 0); ctx.lineTo(p, size); ctx.stroke(); + ctx.beginPath(); ctx.moveTo(0, p); ctx.lineTo(size, p); ctx.stroke(); + hctx.strokeStyle = '#262626'; hctx.lineWidth = 7; + hctx.beginPath(); hctx.moveTo(p, 0); hctx.lineTo(p, size); hctx.stroke(); + hctx.beginPath(); hctx.moveTo(0, p); hctx.lineTo(size, p); hctx.stroke(); + } + for (const p of [0, size / 2, size]) { + for (const q of [size * 0.08, size * 0.42, size * 0.58, size * 0.92]) { + bolt(ctx, hctx, Math.min(Math.max(p + (p === 0 ? 14 : p === size ? -14 : 0), 8), size - 8), q, 5); + } + } + + // central wear path (lighter, smoother) — runs along V + const wear = ctx.createLinearGradient(0, 0, size, 0); + wear.addColorStop(0.0, 'rgba(150,150,154,0)'); + wear.addColorStop(0.5, 'rgba(150,150,154,0.07)'); + wear.addColorStop(1.0, 'rgba(150,150,154,0)'); + ctx.fillStyle = wear; + ctx.fillRect(0, 0, size, size); + const wearR = rctx.createLinearGradient(0, 0, size, 0); + wearR.addColorStop(0.0, 'rgba(64,64,64,0)'); + wearR.addColorStop(0.5, 'rgba(64,64,64,0.5)'); + wearR.addColorStop(1.0, 'rgba(64,64,64,0)'); + rctx.fillStyle = wearR; + rctx.fillRect(0, 0, size, size); + + const n = noiseCanvas(rand, 256, 5); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.4; + ctx.drawImage(n, 0, 0, size, size); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + stains(ctx, rand, 30, size, size, 'rgba(22,20,16,A)', 0.5, 80); + scratches(ctx, rand, 130, size, size, 'rgba(180,182,188,0.8)', 0.4, 90); + scratches(rctx, rand, 130, size, size, 'rgba(60,60,60,1)', 0.5, 90); + + return { + map: tex(c), + roughnessMap: tex(rc, { srgb: false }), + normalMap: tex(normalFromHeight(hc, 2.2), { srgb: false }), + }; +} + +// --------------------------------------------------------------------------- +// Fabric (mattress / blanket / cushion). 0.5m tile. +// --------------------------------------------------------------------------- +export function makeFabricMaps(rand, { color = '#cfc6b4', size = 256 } = {}) { + const [c, ctx] = cv(size); + ctx.fillStyle = color; + ctx.fillRect(0, 0, size, size); + // weave + for (let y = 0; y < size; y += 3) { + ctx.fillStyle = `rgba(0,0,0,${0.05 + (y % 6 === 0 ? 0.05 : 0)})`; + ctx.fillRect(0, y, size, 1); + } + for (let x = 0; x < size; x += 3) { + ctx.fillStyle = 'rgba(255,255,255,0.045)'; + ctx.fillRect(x, 0, 1, size); + } + const n = noiseCanvas(rand, 64, 3); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.22; + ctx.drawImage(n, 0, 0, size, size); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + // quilt seams + ctx.strokeStyle = 'rgba(0,0,0,0.20)'; + ctx.lineWidth = 2; + for (const p of [0, size / 2]) { + ctx.beginPath(); ctx.moveTo(p, 0); ctx.lineTo(p, size); ctx.stroke(); + ctx.beginPath(); ctx.moveTo(0, p); ctx.lineTo(size, p); ctx.stroke(); + } + const [hcq, hq] = cv(size); + hq.fillStyle = '#888'; hq.fillRect(0, 0, size, size); + hq.strokeStyle = '#404040'; hq.lineWidth = 3; + for (const p of [0, size / 2]) { + hq.beginPath(); hq.moveTo(p, 0); hq.lineTo(p, size); hq.stroke(); + hq.beginPath(); hq.moveTo(0, p); hq.lineTo(size, p); hq.stroke(); + } + hq.globalAlpha = 0.6; hq.drawImage(noiseCanvas(rand, 128, 4), 0, 0, size, size); + return { + map: tex(c), + normalMap: tex(normalFromHeight(hcq, 1.2), { srgb: false }), + }; +} + +// --------------------------------------------------------------------------- +// Floor grate alpha pattern. +// --------------------------------------------------------------------------- +export function makeGrateMaps(rand, { size = 256 } = {}) { + const [c, ctx] = cv(size); + const [ac, actx] = cv(size); + actx.fillStyle = '#000'; actx.fillRect(0, 0, size, size); + ctx.fillStyle = 'rgb(52,54,58)'; ctx.fillRect(0, 0, size, size); + const bar = size / 8; + actx.fillStyle = '#fff'; + for (let i = 0; i < 8; i++) { + actx.fillRect(0, i * bar, size, bar * 0.42); + actx.fillRect(i * bar, 0, bar * 0.42, size); + } + const n = noiseCanvas(rand, 64, 3); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.5; + ctx.drawImage(n, 0, 0, size, size); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + scratches(ctx, rand, 40, size, size, 'rgba(190,190,195,0.8)', 0.5, 40); + return { map: tex(c), alphaMap: tex(ac, { srgb: false }) }; +} + +// --------------------------------------------------------------------------- +// Hazard stripes (door trims), 1m x 0.25m strip. +// --------------------------------------------------------------------------- +export function makeHazardMap(rand, { size = 512 } = {}) { + const H = size / 4; + const [c, ctx] = cv(size, H); + ctx.fillStyle = '#c46a1f'; + ctx.fillRect(0, 0, size, H); + ctx.fillStyle = '#16181b'; + for (let x = -H; x < size + H; x += H) { + ctx.beginPath(); + ctx.moveTo(x, H); ctx.lineTo(x + H * 0.6, H); ctx.lineTo(x + H * 0.6 + H, 0); ctx.lineTo(x + H, 0); + ctx.closePath(); ctx.fill(); + } + const n = noiseCanvas(rand, 64, 3); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.35; + ctx.drawImage(n, 0, 0, size, H); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + scratches(ctx, rand, 30, size, H, 'rgba(200,200,205,0.9)', 0.6, 50); + return tex(c); +} + +// --------------------------------------------------------------------------- +// Cockpit / wall screens (emissive UI). +// --------------------------------------------------------------------------- +export function makeScreenMap(rand, kind = 'nav', { w = 512, h = 320 } = {}) { + const [c, ctx] = cv(w, h); + ctx.fillStyle = '#04090d'; + ctx.fillRect(0, 0, w, h); + ctx.strokeStyle = 'rgba(25,212,208,0.5)'; + ctx.lineWidth = 3; + ctx.strokeRect(6, 6, w - 12, h - 12); + const teal = 'rgba(36,222,214,', orange = 'rgba(255,150,60,'; + if (kind === 'nav') { + // radar circle + blips + const cx = w * 0.30, cy = h * 0.52, R = h * 0.34; + for (let r = R; r > 0; r -= R / 3) { + ctx.strokeStyle = teal + '0.4)'; ctx.lineWidth = 1.5; + ctx.beginPath(); ctx.arc(cx, cy, r, 0, 7); ctx.stroke(); + } + ctx.beginPath(); ctx.moveTo(cx - R, cy); ctx.lineTo(cx + R, cy); ctx.stroke(); + ctx.beginPath(); ctx.moveTo(cx, cy - R); ctx.lineTo(cx, cy + R); ctx.stroke(); + const grad = ctx.createConicGradient ? null : null; + ctx.fillStyle = teal + '0.18)'; + ctx.beginPath(); ctx.moveTo(cx, cy); ctx.arc(cx, cy, R, -0.5, 0.45); ctx.closePath(); ctx.fill(); + for (let i = 0; i < 5; i++) { + ctx.fillStyle = i === 2 ? orange + '0.95)' : teal + '0.9)'; + const a = rand() * 6.28, r = rand() * R * 0.9; + ctx.beginPath(); ctx.arc(cx + Math.cos(a) * r, cy + Math.sin(a) * r, 3.5, 0, 7); ctx.fill(); + } + // text column + for (let i = 0; i < 9; i++) { + ctx.fillStyle = (i === 3 ? orange : teal) + (0.35 + rand() * 0.55) + ')'; + ctx.fillRect(w * 0.62, 30 + i * 28, 30 + rand() * (w * 0.3), 9); + } + } else if (kind === 'eng') { + // bar graphs + const n = 8; + for (let i = 0; i < n; i++) { + const bh = (0.25 + rand() * 0.65) * (h - 80); + ctx.fillStyle = i === 5 ? orange + '0.9)' : teal + '0.8)'; + ctx.fillRect(30 + i * ((w - 60) / n), h - 36 - bh, (w - 60) / n - 10, bh); + ctx.fillStyle = teal + '0.25)'; + ctx.fillRect(30 + i * ((w - 60) / n), 40, (w - 60) / n - 10, h - 76); + } + } else if (kind === 'wave') { + ctx.strokeStyle = teal + '0.9)'; + ctx.lineWidth = 2.5; + ctx.beginPath(); + for (let x = 14; x < w - 14; x += 4) { + const y = h * 0.5 + Math.sin(x * 0.05) * h * 0.18 + (rand() - 0.5) * h * 0.1; + x === 14 ? ctx.moveTo(x, y) : ctx.lineTo(x, y); + } + ctx.stroke(); + ctx.strokeStyle = orange + '0.7)'; + ctx.beginPath(); + for (let x = 14; x < w - 14; x += 6) { + const y = h * 0.72 + Math.cos(x * 0.03) * h * 0.08; + x === 14 ? ctx.moveTo(x, y) : ctx.lineTo(x, y); + } + ctx.stroke(); + for (let i = 0; i < 4; i++) { + ctx.fillStyle = teal + '0.6)'; + ctx.fillRect(20 + i * (w / 4.4), 18, w / 6, 8); + } + } else { // 'text' terminal + for (let i = 0; i < 12; i++) { + ctx.fillStyle = (rand() < 0.15 ? orange : teal) + (0.3 + rand() * 0.6) + ')'; + let x = 20; + const words = 2 + (rand() * 5) | 0; + for (let k = 0; k < words; k++) { + const ww = 14 + rand() * 70; + ctx.fillRect(x, 20 + i * ((h - 40) / 12), ww, 8); + x += ww + 12; + if (x > w - 40) break; + } + } + } + // scanlines + ctx.fillStyle = 'rgba(0,0,0,0.22)'; + for (let y = 0; y < h; y += 4) ctx.fillRect(0, y, w, 1.5); + return tex(c); +} + +// --------------------------------------------------------------------------- +// Space: gas giant texture (equirect bands). +// --------------------------------------------------------------------------- +export function makePlanetMap(rand, { hueA = 16, hueB = 36, size = 1024 } = {}) { + const W = size, H = size / 2; + const [c, ctx] = cv(W, H); + // banded base + let y = 0; + while (y < H) { + const bh = H * (0.03 + rand() * 0.10); + const t = y / H; + const hue = hueA + (hueB - hueA) * (0.5 + 0.5 * Math.sin(t * 9 + rand() * 2)); + const sat = 44 + rand() * 30; + const lit = 34 + rand() * 32 - Math.abs(t - 0.5) * 24; + ctx.fillStyle = `hsl(${hue}, ${sat}%, ${lit}%)`; + ctx.fillRect(0, y, W, bh + 1); + y += bh; + } + // turbulence: horizontal smearing of noise + const n = noiseCanvas(rand, 256, 5); + for (let i = 0; i < 7; i++) { + ctx.globalAlpha = 0.10; + ctx.globalCompositeOperation = i % 2 ? 'overlay' : 'multiply'; + ctx.drawImage(n, -i * 37, 0, W * 2.2, H); + } + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + // storm ovals + for (let i = 0; i < 7; i++) { + const x = rand() * W, yy = H * (0.25 + rand() * 0.5); + const rw = 18 + rand() * 60, rh = rw * (0.3 + rand() * 0.3); + const g = ctx.createRadialGradient(x, yy, 0, x, yy, rw); + g.addColorStop(0, `hsla(${hueB + 10}, 50%, ${55 + rand() * 18}%, 0.55)`); + g.addColorStop(1, 'hsla(30, 40%, 50%, 0)'); + ctx.save(); + ctx.translate(x, yy); ctx.scale(1, rh / rw); ctx.translate(-x, -yy); + ctx.fillStyle = g; + ctx.fillRect(x - rw, yy - rw, rw * 2, rw * 2); + ctx.restore(); + } + const t = tex(c); + t.wrapS = THREE.RepeatWrapping; + t.wrapT = THREE.ClampToEdgeWrapping; + return t; +} + +export function makeRockyMap(rand, { size = 512 } = {}) { + const W = size, H = size / 2; + const [c, ctx] = cv(W, H); + ctx.fillStyle = 'hsl(206, 18%, 38%)'; + ctx.fillRect(0, 0, W, H); + const n = noiseCanvas(rand, 256, 6); + ctx.globalCompositeOperation = 'overlay'; + ctx.globalAlpha = 0.9; + ctx.drawImage(n, 0, 0, W, H); + ctx.globalCompositeOperation = 'multiply'; + ctx.globalAlpha = 0.5; + ctx.drawImage(n, -W * 0.3, 0, W * 1.8, H); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + // craters + for (let i = 0; i < 40; i++) { + const x = rand() * W, y = rand() * H, r = 2 + rand() * 14; + ctx.fillStyle = 'rgba(20,24,30,0.35)'; + ctx.beginPath(); ctx.arc(x, y, r, 0, 7); ctx.fill(); + ctx.fillStyle = 'rgba(190,200,210,0.25)'; + ctx.beginPath(); ctx.arc(x, y - r * 0.35, r * 0.75, 0, 7); ctx.fill(); + } + // ice caps + const g = ctx.createLinearGradient(0, 0, 0, H); + g.addColorStop(0, 'rgba(225,235,240,0.9)'); + g.addColorStop(0.12, 'rgba(225,235,240,0)'); + g.addColorStop(0.88, 'rgba(225,235,240,0)'); + g.addColorStop(1, 'rgba(225,235,240,0.85)'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, W, H); + const t = tex(c); + t.wrapS = THREE.RepeatWrapping; + t.wrapT = THREE.ClampToEdgeWrapping; + return t; +} + +// Soft round sprite for stars. +export function makeStarSprite() { + const [c, ctx] = cv(64); + const g = ctx.createRadialGradient(32, 32, 0, 32, 32, 32); + g.addColorStop(0, 'rgba(255,255,255,1)'); + g.addColorStop(0.25, 'rgba(255,255,255,0.85)'); + g.addColorStop(0.6, 'rgba(255,255,255,0.18)'); + g.addColorStop(1, 'rgba(255,255,255,0)'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 64, 64); + return tex(c, { srgb: false }); +} + +// Nebula cloud billboard. +export function makeNebulaSprite(rand, colA = [185, 70, 50], colB = [22, 80, 60], size = 512) { + const [c, ctx] = cv(size); + const blobs = 60; + for (let i = 0; i < blobs; i++) { + const t = i / blobs; + const ang = rand() * 6.28; + const dist = Math.pow(rand(), 1.6) * size * 0.32; + const x = size / 2 + Math.cos(ang) * dist; + const y = size / 2 + Math.sin(ang) * dist * 0.7; + const r = size * (0.04 + rand() * 0.14) * (1 - dist / (size * 0.45)); + const [h1, s1, l1] = rand() < 0.5 ? colA : colB; + const g = ctx.createRadialGradient(x, y, 0, x, y, Math.max(r, 2)); + g.addColorStop(0, `hsla(${h1 + (rand() - 0.5) * 24}, ${s1}%, ${l1}%, ${0.05 + rand() * 0.07})`); + g.addColorStop(1, `hsla(${h1}, ${s1}%, ${l1 * 0.6}%, 0)`); + ctx.fillStyle = g; + ctx.fillRect(0, 0, size, size); + } + // embedded stars + for (let i = 0; i < 30; i++) { + const x = rand() * size, y = rand() * size; + ctx.fillStyle = `rgba(255,255,255,${0.2 + rand() * 0.5})`; + ctx.fillRect(x, y, 1.5, 1.5); + } + return tex(c); +} diff --git a/spaceship/tools/cdntest.mjs b/spaceship/tools/cdntest.mjs new file mode 100644 index 0000000..748f030 --- /dev/null +++ b/spaceship/tools/cdntest.mjs @@ -0,0 +1,38 @@ +import { chromium } from 'playwright'; +import fs from 'fs'; + +const url = process.argv[2]; +const browser = await chromium.launch({ args: [ + '--use-gl=angle', '--use-angle=swiftshader', '--enable-unsafe-swiftshader', + '--disable-features=UserAgentClientHint', + '--disable-blink-features=AutomationControlled', +] }); +const page = await browser.newPage({ + viewport: { width: 1024, height: 576 }, + userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36', +}); +const errors = []; +page.on('pageerror', (e) => errors.push('pageerror: ' + e.message)); +page.on('console', (m) => { if (m.type() === 'error') errors.push('console: ' + m.text()); }); +page.on('response', (r) => { + if (r.status() >= 400) errors.push(`http ${r.status()}: ${r.url()}`); +}); + +const responses = []; +page.on('response', (r) => responses.push(`${r.status()} ${r.headers()['content-type'] || '?'} ${r.url()}`)); + +const resp = await page.goto(url, { waitUntil: 'load', timeout: 90000 }); +console.log('document status:', resp.status(), resp.headers()['content-type']); +try { + await page.waitForFunction(() => window.debugAPI && window.debugAPI.frames() > 0, null, { timeout: 240000 }); + const frames = await page.evaluate(() => window.debugAPI.frames()); + const data = await page.evaluate(() => window.debugAPI.capture()); + fs.writeFileSync('shots/probe/cdn.jpg', Buffer.from(data.split(',')[1], 'base64')); + console.log('BOOT_OK frames rendered:', frames); +} catch { + console.log('BOOT_TIMEOUT'); + console.log('debugAPI present:', await page.evaluate(() => !!window.debugAPI)); +} +console.log('responses:'); for (const r of responses) console.log(' ', r); +console.log('errors:', errors.length ? errors : 'none'); +await browser.close(); diff --git a/spaceship/tools/checkbuild.mjs b/spaceship/tools/checkbuild.mjs new file mode 100644 index 0000000..61aa943 --- /dev/null +++ b/spaceship/tools/checkbuild.mjs @@ -0,0 +1,29 @@ +// Sanity check: production build boots and renders frames. +import { chromium } from 'playwright'; +import { spawn } from 'node:child_process'; +import { fileURLToPath } from 'node:url'; +import path from 'node:path'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const root = path.join(__dirname, '..'); +const PORT = 5195; + +const server = spawn('npx', ['vite', 'preview', '--port', String(PORT), '--strictPort'], { cwd: root, stdio: 'pipe', detached: true }); +await new Promise((res, rej) => { + server.stdout.on('data', (d) => { if (d.toString().includes('Local:')) setTimeout(res, 300); }); + setTimeout(() => rej(new Error('preview timeout')), 20000); +}); +const browser = await chromium.launch({ + args: ['--enable-unsafe-swiftshader', '--use-angle=swiftshader', '--disable-dev-shm-usage', '--no-sandbox'], +}); +try { + const page = await browser.newPage({ viewport: { width: 640, height: 360 } }); + page.on('pageerror', (e) => console.log('[pageerror]', e.message)); + await page.goto(`http://localhost:${PORT}/#debug`, { waitUntil: 'load' }); + await page.waitForFunction(() => window.debugAPI && window.debugAPI.ready, null, { timeout: 120000 }); + console.log('BUILD_OK: app booted and rendered frames'); +} finally { + await browser.close().catch(() => {}); + try { process.kill(-server.pid, 'SIGKILL'); } catch { server.kill('SIGKILL'); } + setTimeout(() => process.exit(0), 300).unref(); +} diff --git a/spaceship/tools/inspect.mjs b/spaceship/tools/inspect.mjs new file mode 100644 index 0000000..1cfb725 --- /dev/null +++ b/spaceship/tools/inspect.mjs @@ -0,0 +1,29 @@ +import { chromium } from 'playwright'; +import { spawn } from 'node:child_process'; +import { fileURLToPath } from 'node:url'; +import path from 'node:path'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const root = path.join(__dirname, '..'); +const PORT = 5191; + +const server = spawn('npx', ['vite', '--port', String(PORT), '--strictPort'], { cwd: root, stdio: 'pipe', detached: true }); +await new Promise((res, rej) => { + server.stdout.on('data', (d) => { if (d.toString().includes('Local:')) setTimeout(res, 400); }); + setTimeout(() => rej(new Error('vite timeout')), 20000); +}); +const browser = await chromium.launch({ + args: ['--enable-unsafe-swiftshader', '--use-angle=swiftshader', '--disable-dev-shm-usage', '--no-sandbox'], +}); +try { + const page = await browser.newPage({ viewport: { width: 320, height: 200 } }); + page.on('pageerror', (e) => console.log('[pageerror]', e.message)); + await page.goto(`http://localhost:${PORT}/#debug`, { waitUntil: 'load' }); + await page.waitForFunction(() => window.debugAPI && window.debugAPI.ready, null, { timeout: 120000 }); + const info = await page.evaluate(() => window.debugAPI.inspect()); + console.log(JSON.stringify(info, null, 1)); +} finally { + await browser.close().catch(() => {}); + try { process.kill(-server.pid, 'SIGKILL'); } catch { server.kill('SIGKILL'); } + setTimeout(() => process.exit(0), 300).unref(); +} diff --git a/spaceship/tools/movetest.mjs b/spaceship/tools/movetest.mjs new file mode 100644 index 0000000..423ea7c --- /dev/null +++ b/spaceship/tools/movetest.mjs @@ -0,0 +1,59 @@ +// Verify WASD maps to the camera's facing for all four cardinal yaws. +import { chromium } from 'playwright'; +import { spawn } from 'node:child_process'; +import { fileURLToPath } from 'node:url'; +import path from 'node:path'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const root = path.join(__dirname, '..'); +const PORT = 5196; + +const server = spawn('npx', ['vite', '--port', String(PORT), '--strictPort'], { cwd: root, stdio: 'pipe', detached: true }); +await new Promise((res, rej) => { + server.stdout.on('data', (d) => { if (d.toString().includes('Local:')) setTimeout(res, 300); }); + setTimeout(() => rej(new Error('vite timeout')), 20000); +}); +const browser = await chromium.launch({ + args: ['--enable-unsafe-swiftshader', '--use-angle=swiftshader', '--disable-dev-shm-usage', '--no-sandbox'], +}); +let fail = 0; +try { + const page = await browser.newPage({ viewport: { width: 320, height: 200 } }); + page.on('pageerror', (e) => console.log('[pageerror]', e.message)); + await page.goto(`http://localhost:${PORT}/#debug`, { waitUntil: 'load' }); + await page.waitForFunction(() => window.debugAPI && window.debugAPI.ready, null, { timeout: 120000 }); + await page.evaluate(() => window.debugAPI.forceLock(true)); + + // yaw=0 faces -Z; expected forward = (-sin(yaw), -cos(yaw)) + const cases = [ + { yaw: 0, name: 'facing -Z' }, + { yaw: Math.PI, name: 'facing +Z' }, + { yaw: Math.PI / 2, name: 'facing -X' }, + { yaw: -Math.PI / 2, name: 'facing +X' }, + ]; + for (const c of cases) { + for (const [key, lx, lz] of [['KeyW', 0, -1], ['KeyS', 0, 1], ['KeyA', -1, 0], ['KeyD', 1, 0]]) { + // start mid-corridor; expected world dir = R_y(yaw) * local + const cos = Math.cos(c.yaw), sin = Math.sin(c.yaw); + const ex = lx * cos + lz * sin, ez = -lx * sin + lz * cos; + await page.evaluate(({ yaw }) => window.debugAPI.teleport(0, 0, yaw, 0), { yaw: c.yaw }); + const p0 = await page.evaluate(() => window.debugAPI.playerPos()); + await page.evaluate((k) => window.debugAPI.setKey(k, true), key); + const f0 = await page.evaluate(() => window.debugAPI.frames()); + await page.waitForFunction((f) => window.debugAPI.frames() >= f + 4, f0, { timeout: 60000, polling: 200 }); + await page.evaluate((k) => window.debugAPI.setKey(k, false), key); + const p1 = await page.evaluate(() => window.debugAPI.playerPos()); + const dx = p1[0] - p0[0], dz = p1[1] - p0[1]; + const len = Math.hypot(dx, dz); + const dot = len > 1e-4 ? (dx * ex + dz * ez) / len : 0; + const ok = dot > 0.95; + if (!ok) fail++; + console.log(`${c.name} ${key}: moved (${dx.toFixed(2)}, ${dz.toFixed(2)}) expected dir (${ex.toFixed(1)}, ${ez.toFixed(1)}) dot=${dot.toFixed(2)} ${ok ? 'OK' : 'WRONG'}`); + } + } + console.log(fail === 0 ? 'MOVETEST_PASS' : `MOVETEST_FAIL (${fail})`); +} finally { + await browser.close().catch(() => {}); + try { process.kill(-server.pid, 'SIGKILL'); } catch { server.kill('SIGKILL'); } + setTimeout(() => process.exit(fail === 0 ? 0 : 1), 300).unref(); +} diff --git a/spaceship/tools/oneshot.mjs b/spaceship/tools/oneshot.mjs new file mode 100644 index 0000000..b44e62a --- /dev/null +++ b/spaceship/tools/oneshot.mjs @@ -0,0 +1,48 @@ +// Single debug view capture: node tools/oneshot.mjs [x y z lx ly lz] +import { chromium } from 'playwright'; +import { spawn } from 'node:child_process'; +import { writeFileSync, mkdirSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import path from 'node:path'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const root = path.join(__dirname, '..'); +const name = process.argv[2] || 'cockpit'; +const custom = process.argv.length >= 9 ? process.argv.slice(3, 9).map(Number) : null; +const PORT = 5190; + +const server = spawn('npx', ['vite', '--port', String(PORT), '--strictPort'], { cwd: root, stdio: 'pipe', detached: true }); +await new Promise((res, rej) => { + server.stdout.on('data', (d) => { if (d.toString().includes('Local:')) setTimeout(res, 400); }); + setTimeout(() => rej(new Error('vite timeout')), 20000); +}); +const browser = await chromium.launch({ + args: ['--enable-unsafe-swiftshader', '--use-angle=swiftshader', '--disable-dev-shm-usage', '--no-sandbox'], +}); +try { + const page = await browser.newPage({ viewport: { width: 1280, height: 720 } }); + page.on('pageerror', (e) => console.log('[pageerror]', e.message)); + await page.goto(`http://localhost:${PORT}/#debug${process.env.HASHFLAGS || ''}`, { waitUntil: 'load' }); + await page.waitForFunction(() => window.debugAPI && window.debugAPI.ready, null, { timeout: 120000 }); + if (custom) { + await page.evaluate(([x, y, z, lx, ly, lz]) => { + window.debugAPI.setView('cockpit'); + const cam = window.debugAPI; + window.debugAPI.customView(x, y, z, lx, ly, lz); + }, custom); + } else { + await page.evaluate((n) => window.debugAPI.setView(n), name); + } + const start = await page.evaluate(() => window.debugAPI.frames()); + await page.waitForFunction((s) => window.debugAPI.frames() >= s + 3, start, { timeout: 120000, polling: 250 }); + console.log('pick:', JSON.stringify(await page.evaluate(() => window.debugAPI.pick()))); + const dataUrl = await page.evaluate(() => window.debugAPI.capture(0.9)); + mkdirSync(path.join(root, 'shots', 'probe'), { recursive: true }); + const out = path.join(root, 'shots', 'probe', `${name}.jpg`); + writeFileSync(out, Buffer.from(dataUrl.split(',')[1], 'base64')); + console.log('saved', out); +} finally { + await browser.close().catch(() => {}); + try { process.kill(-server.pid, 'SIGKILL'); } catch { server.kill('SIGKILL'); } + setTimeout(() => process.exit(0), 300).unref(); +} diff --git a/spaceship/tools/probe.mjs b/spaceship/tools/probe.mjs new file mode 100644 index 0000000..496e170 --- /dev/null +++ b/spaceship/tools/probe.mjs @@ -0,0 +1,40 @@ +// Quick perf probe in headless chromium. +import { chromium } from 'playwright'; +import { spawn } from 'node:child_process'; +import { fileURLToPath } from 'node:url'; +import path from 'node:path'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const root = path.join(__dirname, '..'); +const PORT = 5189; + +const server = spawn('npx', ['vite', '--port', String(PORT), '--strictPort'], { cwd: root, stdio: 'pipe' }); +await new Promise((res, rej) => { + server.stdout.on('data', (d) => { if (d.toString().includes('Local:')) setTimeout(res, 400); }); + server.stderr.on('data', (d) => process.stderr.write(d)); + setTimeout(() => rej(new Error('vite timeout')), 20000); +}); + +const browser = await chromium.launch({ + args: ['--enable-unsafe-swiftshader', '--use-angle=swiftshader', '--disable-dev-shm-usage', '--no-sandbox'], +}); +const page = await browser.newPage({ viewport: { width: 1280, height: 720 } }); +page.on('console', (m) => console.log('[console]', m.type(), m.text().slice(0, 300))); +page.on('pageerror', (e) => console.log('[pageerror]', e.message)); +const t0 = Date.now(); +await page.goto(`http://localhost:${PORT}/#debug`, { waitUntil: 'load' }); +console.log('loaded in', Date.now() - t0, 'ms'); +try { + await page.waitForFunction(() => window.debugAPI && window.debugAPI.ready, null, { timeout: 90000 }); + console.log('ready in', Date.now() - t0, 'ms'); + for (let i = 0; i < 5; i++) { + await page.waitForTimeout(2000); + const stats = await page.evaluate(() => ({ ...window.debugAPI.stats(), frames: window.debugAPI.frames() })); + console.log(`t=${Date.now() - t0}ms`, JSON.stringify(stats)); + } +} catch (e) { + console.log('FAILED:', e.message); +} +await browser.close(); +server.kill('SIGTERM'); +process.exit(0); diff --git a/spaceship/tools/shots.mjs b/spaceship/tools/shots.mjs new file mode 100644 index 0000000..74a7626 --- /dev/null +++ b/spaceship/tools/shots.mjs @@ -0,0 +1,127 @@ +// Headless screenshot harness. Usage: node tools/shots.mjs +import { chromium } from 'playwright'; +import { spawn } from 'node:child_process'; +import { mkdirSync, writeFileSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import path from 'node:path'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const root = path.join(__dirname, '..'); +const iter = process.argv[2] || 'dev'; +const outDir = path.join(root, 'shots', `iter_${iter}`); +mkdirSync(outDir, { recursive: true }); + +const PORT = 5189; + +function startServer() { + return new Promise((resolve, reject) => { + const proc = spawn('npx', ['vite', '--port', String(PORT), '--strictPort'], { + cwd: root, stdio: ['ignore', 'pipe', 'pipe'], detached: true, + }); + let ready = false; + const onData = (d) => { + const s = d.toString(); + if (!ready && (s.includes('Local:') || s.includes('ready in'))) { + ready = true; + setTimeout(() => resolve(proc), 400); + } + }; + proc.stdout.on('data', onData); + proc.stderr.on('data', onData); + proc.on('exit', (code) => { if (!ready) reject(new Error(`vite exited ${code}`)); }); + setTimeout(() => { if (!ready) reject(new Error('vite timeout')); }, 30000); + }); +} + +const server = await startServer(); + +const browser = await chromium.launch({ + args: [ + '--enable-unsafe-swiftshader', + '--use-angle=swiftshader', + '--disable-dev-shm-usage', + '--no-sandbox', + ], +}); + +try { + const page = await browser.newPage({ viewport: { width: 1600, height: 900 } }); + page.on('console', (msg) => { + if (msg.type() === 'error') console.log('[page error]', msg.text()); + }); + page.on('pageerror', (err) => console.log('[page exception]', err.message)); + + await page.goto(`http://localhost:${PORT}/#debug`, { waitUntil: 'load' }); + await page.waitForFunction(() => window.debugAPI && window.debugAPI.ready, null, { timeout: 120000 }); + + // SwiftShader renders < 1 fps; wait on rendered-frame count rather than wall + // time so "wait 2 seconds to settle" still means "several frames settled". + async function settleFrames(n, timeout = 120000) { + const start = await page.evaluate(() => window.debugAPI.frames()); + await page.waitForFunction( + ({ start, n }) => window.debugAPI.frames() >= start + n, + { start, n }, { timeout, polling: 250 } + ); + } + + async function snap(file) { + const dataUrl = await page.evaluate(() => window.debugAPI.capture(0.9)); + const b64 = dataUrl.split(',')[1]; + writeFileSync(path.join(outDir, file), Buffer.from(b64, 'base64')); + } + + const views = ['cockpit', 'corridor', 'quarters', 'window']; + const stats = {}; + for (const v of views) { + await page.evaluate((name) => window.debugAPI.setView(name), v); + await page.waitForTimeout(2000); + await settleFrames(4); + await snap(`${v}.jpg`); + stats[v] = await page.evaluate(() => window.debugAPI.stats()); + console.log(`shot: ${v}`, JSON.stringify(stats[v])); + } + + // --- interaction smoke test --- + const interactions = [ + { id: 'bed', x: 3.4, z: 4.2, yaw: -2.59, pitch: -0.55 }, + { id: 'galley', x: -3.9, z: -3.2, yaw: Math.PI / 2, pitch: -0.7 }, + { id: 'bathroom', x: -2.6, z: 3.9, yaw: 2.16, pitch: -0.57 }, + ]; + const interactResults = {}; + for (const it of interactions) { + await page.evaluate(({ x, z, yaw, pitch }) => window.debugAPI.teleport(x, z, yaw, pitch), it); + await settleFrames(3); + const hover = await page.evaluate(() => window.debugAPI.hoverTarget()); + const prompt = await page.evaluate(() => ({ + text: document.getElementById('prompt').textContent, + on: document.getElementById('prompt').classList.contains('on'), + })); + let fired = false, midState = null; + if (hover === it.id) { + await page.evaluate(() => window.debugAPI.press('KeyE')); + await page.waitForTimeout(1100); + await settleFrames(2); + fired = true; + midState = await page.evaluate(() => ({ + fade: document.getElementById('fade').classList.contains('on'), + message: document.getElementById('message').textContent, + status: document.getElementById('status').textContent, + })); + await snap(`interact_${it.id}.jpg`); + await page.waitForTimeout(2600); + await settleFrames(2); + } + interactResults[it.id] = { hover, prompt, fired, midState }; + console.log(`interact ${it.id}:`, JSON.stringify(interactResults[it.id])); + } + + writeFileSync( + path.join(outDir, 'stats.json'), + JSON.stringify({ stats, interactResults }, null, 2) + ); + console.log(`done -> ${outDir}`); +} finally { + await browser.close().catch(() => {}); + try { process.kill(-server.pid, 'SIGKILL'); } catch { server.kill('SIGKILL'); } + setTimeout(() => process.exit(0), 500).unref(); +} diff --git a/spaceship/vite.config.js b/spaceship/vite.config.js new file mode 100644 index 0000000..7f044e2 --- /dev/null +++ b/spaceship/vite.config.js @@ -0,0 +1,6 @@ +import { defineConfig } from 'vite'; + +export default defineConfig({ + // relative base so the build works when served from a subpath like /spaceship/ + base: './', +});