0xe4f517a4…f7b9sent to0x0a1bbd57…3676·#19,210,141·view on Etherscan
const Vr=[];function pr(){requestAnimationFrame(pr);for(const r of Vr)r()}pr();class R{constructor(){this._entities=[]}add(t){this._entities.push(t)}remove(t){const e=this._entities.indexOf(t);e!==-1&&this._entities.splice(e,1)}dispatch(...t){for(const e of this._entities)e(...t)}}const u={screen:{width:0,height:0},size:{width:2160,height:3840},dpr:1,sketch:null,renderer:null,gl:null,onRender:new R,rand:Math.random};class ie{constructor(){this.useA=!1;let t=function(e){let s=parseInt(e.substr(0,8),16),i=parseInt(e.substr(8,8),16),n=parseInt(e.substr(16,8),16),a=parseInt(e.substr(24,8),16);return function(){s|=0,i|=0,n|=0,a|=0;let l=(s+i|0)+a|0;return a=a+1|0,s=i^i>>>9,i=n+(n<<3)|0,n=n<<21|n>>>11,n=n+l|0,(l>>>0)/4294967296}};this.prngA=new t(tokenData.hash.substr(2,32)),this.prngB=new t(tokenData.hash.substr(34,32));for(let e=0;e<1e6;e+=2)this.prngA(),this.prngB()}random_dec=()=>(this.useA=!this.useA,this.useA?this.prngA():this.prngB());random_num=(t,e)=>t+(e-t)*this.random_dec();random_int=(t,e)=>Math.floor(this.random_num(t,e+1));random_bool=t=>this.random_dec()<t;random_choice=t=>t[this.random_int(0,t.length-1)]}function Fr(r=null){window.tokenData||(window.genTokenData=function(s){let i={},n="0x";for(var a=0;a<64;a++)n+=Math.floor(Math.random()*16).toString(16);return i.hash=n,i.tokenId=(s*1e6+Math.floor(Math.random()*1e3)).toString(),i},window.tokenData=genTokenData(123),r&&(tokenData.hash=r));const t=new ie(tokenData);u.rand=t.random_dec}function Rr(){const r=genTokenData(3122021);r.hash="0xs03122021m13021990z";const t=new ie(r);u.prerand=t.random_dec}function fr(){const r=new ie(tokenData);u.rand=r.random_dec}function Ur(r){tokenData.hash=r,fr()}function Nr(){tokenData=genTokenData(123)}const Ir={init:Fr,reset:fr,setHash:Ur,generateNewHash:Nr,createPrerand:Rr};function $r(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r}function Hr(r,t,e,s){return r[0]=t,r[1]=e,r[2]=s,r}class V extends Array{constructor(t=0,e=t,s=t){return super(t,e,s),this}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(t){this[0]=t}set y(t){this[1]=t}set z(t){this[2]=t}set(t,e=t,s=t){return t.length?this.copy(t):(Hr(this,t,e,s),this)}copy(t){return $r(this,t),this}}new V;let Or=1,Wr=1,be=!1;class ne{constructor(t,e={}){t.canvas||console.error("gl not passed as first argument to Geometry"),this.gl=t,this.attributes=e,this.id=Or++,this.VAOs={},this.drawRange={start:0,count:0},this.instancedCount=0,this.gl.renderer.bindVertexArray(null),this.gl.renderer.currentGeometry=null,this.glState=this.gl.renderer.state;for(let s in e)this.addAttribute(s,e[s])}addAttribute(t,e){this.attributes[t]=e,e.id=Wr++,e.size=e.size||1,e.type=e.type||(e.data.constructor===Float32Array?this.gl.FLOAT:e.data.constructor===Uint16Array?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT),e.target=t==="index"?this.gl.ELEMENT_ARRAY_BUFFER:this.gl.ARRAY_BUFFER,e.normalized=e.normalized||!1,e.stride=e.stride||0,e.offset=e.offset||0,e.count=e.count||(e.stride?e.data.byteLength/e.stride:e.data.length/e.size),e.divisor=e.instanced||0,e.needsUpdate=!1,e.usage=e.usage||this.gl.STATIC_DRAW,e.buffer||this.updateAttribute(e),this.drawRange.count=Math.max(this.drawRange.count,e.count)}updateAttribute(t){const e=!t.buffer;e&&(t.buffer=this.gl.createBuffer()),this.glState.boundBuffer!==t.buffer&&(this.gl.bindBuffer(t.target,t.buffer),this.glState.boundBuffer=t.buffer),e?this.gl.bufferData(t.target,t.data,t.usage):this.gl.bufferSubData(t.target,0,t.data),t.needsUpdate=!1}setIndex(t){this.addAttribute("index",t)}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}setInstancedCount(t){this.instancedCount=t}createVAO(t){this.VAOs[t.attributeOrder]=this.gl.renderer.createVertexArray(),this.gl.renderer.bindVertexArray(this.VAOs[t.attributeOrder]),this.bindAttributes(t)}bindAttributes(t){t.attributeLocations.forEach((e,{name:s,type:i})=>{if(!this.attributes[s]){console.warn(`active attribute ${s} not being supplied`);return}const n=this.attributes[s];this.gl.bindBuffer(n.target,n.buffer),this.glState.boundBuffer=n.buffer;let a=1;i===35674&&(a=2),i===35675&&(a=3),i===35676&&(a=4);const l=n.size/a,h=a===1?0:a*a*4,c=a===1?0:a*4;for(let _=0;_<a;_++)this.gl.vertexAttribPointer(e+_,l,n.type,n.normalized,n.stride+h,n.offset+_*c),this.gl.enableVertexAttribArray(e+_),this.gl.renderer.vertexAttribDivisor(e+_,n.divisor)}),this.attributes.index&&this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.attributes.index.buffer)}draw({_pr:t,mode:e=this.gl.TRIANGLES}){this.gl.renderer.currentGeometry!==`${this.id}_${t.attributeOrder}`&&(this.VAOs[t.attributeOrder]||this.createVAO(t),this.gl.renderer.bindVertexArray(this.VAOs[t.attributeOrder]),this.gl.renderer.currentGeometry=`${this.id}_${t.attributeOrder}`),t.attributeLocations.forEach((i,{name:n})=>{const a=this.attributes[n];a.needsUpdate&&this.updateAttribute(a)});let s=2;this.attributes.index?.type===this.gl.UNSIGNED_INT&&(s=4),this.attributes.index?this.gl.drawElements(e,this.drawRange.count,this.attributes.index.type,this.attributes.index.offset+this.drawRange.start*s):this.gl.drawArrays(e,this.drawRange.start,this.drawRange.count)}getPosition(){const t=this.attributes.position;if(t.data)return t;if(!be)return be=!0}remove(){for(let t in this.VAOs)this.gl.renderer.deleteVertexArray(this.VAOs[t]),delete this.VAOs[t];for(let t in this.attributes)this.gl.deleteBuffer(this.attributes[t].buffer),delete this.attributes[t]}}let Gr=1;const me={};class wt{constructor(t,{vertex:e,fragment:s,UNF:i={},transparent:n=!1,cullFace:a=t.BACK,frontFace:l=t.CCW,depthTest:h=!0,depthWrite:c=!0,depthFunc:_=t.LESS}={}){t.canvas||console.error("gl not passed as first argument to Program"),this.gl=t,this.UNF=i,this.id=Gr++,e||console.warn("vertex shader not supplied"),s||console.warn("fragment shader not supplied"),this.transparent=n,this.cullFace=a,this.frontFace=l,this.depthTest=h,this.depthWrite=c,this.depthFunc=_,this.blendFunc={},this.blendEquation={},this.transparent&&!this.blendFunc.src&&(this.gl.renderer.premultipliedAlpha?this.setBlendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA):this.setBlendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA));const v=t.createShader(t.VERTEX_SHADER);t.shaderSource(v,e),t.compileShader(v),t.getShaderInfoLog(v)!==""&&console.warn(`${t.getShaderInfoLog(v)}
Vertex Shader
${xe(e)}`);const f=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(f,s),t.compileShader(f),t.getShaderInfoLog(f)!==""&&console.warn(`${t.getShaderInfoLog(f)}
Fragment Shader
${xe(s)}`),this._pr=t.createProgram(),t.attachShader(this._pr,v),t.attachShader(this._pr,f),t.linkProgram(this._pr),!t.getProgramParameter(this._pr,t.LINK_STATUS))return console.warn(t.getProgramInfoLog(this._pr));t.deleteShader(v),t.deleteShader(f),this.uniformLocations=new Map;let A=t.getProgramParameter(this._pr,t.ACTIVE_UNIFORMS);for(let g=0;g<A;g++){let p=t.getActiveUniform(this._pr,g);this.uniformLocations.set(p,t.getUniformLocation(this._pr,p.name));const m=p.name.match(/(\w+)/g);p.uniformName=m[0],m.length===3?(p.isStructArray=!0,p.structIndex=Number(m[1]),p.structProperty=m[2]):m.length===2&&isNaN(Number(m[1]))&&(p.isStruct=!0,p.structProperty=m[1])}this.attributeLocations=new Map;const b=[],C=t.getProgramParameter(this._pr,t.ACTIVE_ATTRIBUTES);for(let g=0;g<C;g++){const p=t.getActiveAttrib(this._pr,g),m=t.getAttribLocation(this._pr,p.name);m!==-1&&(b[m]=p.name,this.attributeLocations.set(p,m))}this.attributeOrder=b.join("")}setBlendFunc(t,e,s,i){this.blendFunc.src=t,this.blendFunc.dst=e,this.blendFunc.srcAlpha=s,this.blendFunc.dstAlpha=i,t&&(this.transparent=!0)}setBlendEquation(t,e){this.blendEquation.modeRGB=t,this.blendEquation.modeAlpha=e}applyState(){this.depthTest?this.gl.renderer.enable(this.gl.DEPTH_TEST):this.gl.renderer.disable(this.gl.DEPTH_TEST),this.cullFace?this.gl.renderer.enable(this.gl.CULL_FACE):this.gl.renderer.disable(this.gl.CULL_FACE),this.blendFunc.src?this.gl.renderer.enable(this.gl.BLEND):this.gl.renderer.disable(this.gl.BLEND),this.cullFace&&this.gl.renderer.setCullFace(this.cullFace),this.gl.renderer.setFrontFace(this.frontFace),this.gl.renderer.setDepthMask(this.depthWrite),this.gl.renderer.setDepthFunc(this.depthFunc),this.blendFunc.src&&this.gl.renderer.setBlendFunc(this.blendFunc.src,this.blendFunc.dst,this.blendFunc.srcAlpha,this.blendFunc.dstAlpha),this.gl.renderer.setBlendEquation(this.blendEquation.modeRGB,this.blendEquation.modeAlpha)}use({flipFaces:t=!1}={}){let e=-1;this.gl.renderer.state.currentProgram===this.id||(this.gl.useProgram(this._pr),this.gl.renderer.state.currentProgram=this.id),this.uniformLocations.forEach((i,n)=>{let a=n.uniformName,l=this.UNF[a];if(l.value.texture)return e=e+1,l.value.update(e),ee(this.gl,n.type,i,e);if(l.value.length&&l.value[0].texture){const h=[];return l.value.forEach(c=>{e=e+1,c.update(e),h.push(e)}),ee(this.gl,n.type,i,h)}ee(this.gl,n.type,i,l.value)}),this.applyState(),t&&this.gl.renderer.setFrontFace(this.frontFace===this.gl.CCW?this.gl.CW:this.gl.CCW)}remove(){this.gl.deleteProgram(this._pr)}}function ee(r,t,e,s){s=s.length?jr(s):s;const i=r.renderer.state.uniformLocations.get(e);if(s.length)if(i===void 0||i.length!==s.length)r.renderer.state.uniformLocations.set(e,s.slice(0));else{if(qr(i,s))return;i.set?i.set(s):Kr(i,s),r.renderer.state.uniformLocations.set(e,i)}else{if(i===s)return;r.renderer.state.uniformLocations.set(e,s)}switch(t){case 5126:return s.length?r.uniform1fv(e,s):r.uniform1f(e,s);case 35664:return r.uniform2fv(e,s);case 35665:return r.uniform3fv(e,s);case 35666:return r.uniform4fv(e,s);case 35670:case 5124:case 35678:case 35680:return s.length?r.uniform1iv(e,s):r.uniform1i(e,s);case 35671:case 35667:return r.uniform2iv(e,s);case 35672:case 35668:return r.uniform3iv(e,s);case 35673:case 35669:return r.uniform4iv(e,s);case 35674:return r.uniformMatrix2fv(e,!1,s);case 35675:return r.uniformMatrix3fv(e,!1,s);case 35676:return r.uniformMatrix4fv(e,!1,s)}}function xe(r){let t=r.split(`
`);for(let e=0;e<t.length;e++)t[e]=e+1+": "+t[e];return t.join(`
`)}function jr(r){const t=r.length,e=r[0].length;if(e===void 0)return r;const s=t*e;let i=me[s];i||(me[s]=i=new Float32Array(s));for(let n=0;n<t;n++)i.set(r[n],n*e);return i}function qr(r,t){if(r.length!==t.length)return!1;for(let e=0,s=r.length;e<s;e++)if(r[e]!==t[e])return!1;return!0}function Kr(r,t){for(let e=0,s=r.length;e<s;e++)r[e]=t[e]}new V;let Xr=1;class Yr{constructor({canvas:t=document.createElement("canvas"),width:e=300,height:s=150,dpr:i=1,alpha:n=!1,depth:a=!0,stencil:l=!1,antialias:h=!1,premultipliedAlpha:c=!1,preserveDrawingBuffer:_=!1,powerPreference:v="default",autoClear:f=!0,webgl:A=2}={}){const b={alpha:n,depth:a,stencil:l,antialias:h,premultipliedAlpha:c,preserveDrawingBuffer:_,powerPreference:v};this.dpr=i,this.alpha=n,this.color=!0,this.depth=a,this.stencil=l,this.premultipliedAlpha=c,this.autoClear=f,this.id=Xr++,A===2&&(this.gl=t.getContext("webgl2",b)),this.isWebgl2=!!this.gl,this.gl||(this.gl=t.getContext("webgl",b)),this.gl||console.error("unable to create webgl context"),this.gl.renderer=this,this.setSize(e,s),this.state={},this.state.blendFunc={src:this.gl.ONE,dst:this.gl.ZERO},this.state.blendEquation={modeRGB:this.gl.FUNC_ADD},this.state.cullFace=null,this.state.frontFace=this.gl.CCW,this.state.depthMask=!0,this.state.depthFunc=this.gl.LESS,this.state.premultiplyAlpha=!1,this.state.flipY=!1,this.state.unpackAlignment=4,this.state.framebuffer=null,this.state.viewport={x:0,y:0,width:null,height:null},this.state.textureUnits=[],this.state.activeTextureUnit=0,this.state.boundBuffer=null,this.state.uniformLocations=new Map,this.state.currentProgram=null,this.extensions={},this.isWebgl2&&(this.getExtension("EXT_color_buffer_float"),this.getExtension("OES_texture_float_linear")),this.vertexAttribDivisor=this.getExtension("ANGLE_instanced_arrays","vertexAttribDivisor","vertexAttribDivisorANGLE"),this.drawArraysInstanced=this.getExtension("ANGLE_instanced_arrays","drawArraysInstanced","drawArraysInstancedANGLE"),this.drawElementsInstanced=this.getExtension("ANGLE_instanced_arrays","drawElementsInstanced","drawElementsInstancedANGLE"),this.createVertexArray=this.getExtension("OES_vertex_array_object","createVertexArray","createVertexArrayOES"),this.bindVertexArray=this.getExtension("OES_vertex_array_object","bindVertexArray","bindVertexArrayOES"),this.deleteVertexArray=this.getExtension("OES_vertex_array_object","deleteVertexArray","deleteVertexArrayOES"),this.drawBuffers=this.getExtension("WEBGL_draw_buffers","drawBuffers","drawBuffersWEBGL"),this.parameters={},this.parameters.maxTextureUnits=this.gl.getParameter(this.gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),this.parameters.maxAnisotropy=this.getExtension("EXT_texture_filter_anisotropic")?this.gl.getParameter(this.getExtension("EXT_texture_filter_anisotropic").MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}setSize(t,e){this.width=t,this.height=e,this.gl.canvas.width=t*this.dpr,this.gl.canvas.height=e*this.dpr,this.gl.canvas.style&&Object.assign(this.gl.canvas.style,{width:t+"px",height:e+"px"})}setViewport(t,e,s=0,i=0){this.state.viewport.width===t&&this.state.viewport.height===e||(this.state.viewport.width=t,this.state.viewport.height=e,this.state.viewport.x=s,this.state.viewport.y=i,this.gl.viewport(s,i,t,e))}setScissor(t,e,s=0,i=0){this.gl.scissor(s,i,t,e)}enable(t){this.state[t]!==!0&&(this.gl.enable(t),this.state[t]=!0)}disable(t){this.state[t]!==!1&&(this.gl.disable(t),this.state[t]=!1)}setBlendFunc(t,e,s,i){this.state.blendFunc.src===t&&this.state.blendFunc.dst===e&&this.state.blendFunc.srcAlpha===s&&this.state.blendFunc.dstAlpha===i||(this.state.blendFunc.src=t,this.state.blendFunc.dst=e,this.state.blendFunc.srcAlpha=s,this.state.blendFunc.dstAlpha=i,s!==void 0?this.gl.blendFuncSeparate(t,e,s,i):this.gl.blendFunc(t,e))}setBlendEquation(t,e){t=t||this.gl.FUNC_ADD,!(this.state.blendEquation.modeRGB===t&&this.state.blendEquation.modeAlpha===e)&&(this.state.blendEquation.modeRGB=t,this.state.blendEquation.modeAlpha=e,e!==void 0?this.gl.blendEquationSeparate(t,e):this.gl.blendEquation(t))}setCullFace(t){this.state.cullFace!==t&&(this.state.cullFace=t,this.gl.cullFace(t))}setFrontFace(t){this.state.frontFace!==t&&(this.state.frontFace=t,this.gl.frontFace(t))}setDepthMask(t){this.state.depthMask!==t&&(this.state.depthMask=t,this.gl.depthMask(t))}setDepthFunc(t){this.state.depthFunc!==t&&(this.state.depthFunc=t,this.gl.depthFunc(t))}activeTexture(t){this.state.activeTextureUnit!==t&&(this.state.activeTextureUnit=t,this.gl.activeTexture(this.gl.TEXTURE0+t))}bindFramebuffer({target:t=this.gl.FRAMEBUFFER,buffer:e=null}={}){this.state.framebuffer!==e&&(this.state.framebuffer=e,this.gl.bindFramebuffer(t,e))}getExtension(t,e,s){return e&&this.gl[e]?this.gl[e].bind(this.gl):(this.extensions[t]||(this.extensions[t]=this.gl.getExtension(t)),e?this.extensions[t]?this.extensions[t][s].bind(this.extensions[t]):null:this.extensions[t])}getRenderList({scene:t,camera:e,frustumCull:s,sort:i}){let n=[];return t.traverse(a=>{if(!a.visible)return!0;a.draw&&n.push(a)}),n}render({scene:t,camera:e,target:s=null,update:i=!0,sort:n=!0,frustumCull:a=!0,clear:l}){s===null?(this.bindFramebuffer(),this.setViewport(this.width*this.dpr,this.height*this.dpr)):(this.bindFramebuffer(s),this.setViewport(s.width,s.height)),(l||this.autoClear&&l!==!1)&&(this.depth&&(!s||s.depth)&&(this.enable(this.gl.DEPTH_TEST),this.setDepthMask(!0)),this.gl.clear((this.color?this.gl.COLOR_BUFFER_BIT:0)|(this.depth?this.gl.DEPTH_BUFFER_BIT:0)|(this.stencil?this.gl.STENCIL_BUFFER_BIT:0))),i&&t.updateMatrixWorld(),e&&e.updateMatrixWorld(),this.getRenderList({scene:t,camera:e,frustumCull:a,sort:n}).forEach(c=>{c.draw({camera:e})})}}class Zr extends Array{constructor(t=0,e=0,s=0,i=1){return super(t,e,s,i),this.och=()=>{},this}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}get w(){return this[3]}set x(t){this[0]=t,this.och()}set y(t){this[1]=t,this.och()}set z(t){this[2]=t,this.och()}set w(t){this[3]=t,this.och()}}function Qr(r,t,e,s,i){let n=1/Math.tan(t/2),a=1/(s-i);return r[0]=n/e,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=n,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=(i+s)*a,r[11]=-1,r[12]=0,r[13]=0,r[14]=2*i*s*a,r[15]=0,r}class H extends Array{constructor(t=1,e=0,s=0,i=0,n=0,a=1,l=0,h=0,c=0,_=0,v=1,f=0,A=0,b=0,C=0,g=1){return super(t,e,s,i,n,a,l,h,c,_,v,f,A,b,C,g),this}get x(){return this[12]}get y(){return this[13]}get z(){return this[14]}get w(){return this[15]}set x(t){this[12]=t}set y(t){this[13]=t}set z(t){this[14]=t}set w(t){this[15]=t}multiply(t,e){return this}identity(){}copy(t){return this}fromPerspective({fov:t,aspect:e,near:s,far:i}={}){return Qr(this,t,e,s,i),this}setPosition(t){return this.x=t[0],this.y=t[1],this.z=t[2],this}compose(t,e,s){return this}getRotation(t){return this}getTranslation(t){return this}getScaling(t){return this}}new H;class Jr extends Array{constructor(t=0,e=t,s=t,i="YXZ"){return super(t,e,s),this.order=i,this.och=()=>{},this}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(t){this[0]=t,this.och()}set y(t){this[1]=t,this.och()}set z(t){this[2]=t,this.och()}set(t,e=t,s=t){return t.length?this.copy(t):(this[0]=t,this[1]=e,this[2]=s,this.och(),this)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.och(),this}reorder(t){}fromRotationMatrix(t,e=this.order){}fromQuaternion(t,e=this.order){}fromArray(t,e=0){}toArray(t=[],e=0){}}class Zt{constructor(){this.parent=null,this.children=[],this.visible=!0,this.matrix=new H,this.WMX=new H,this.matrixAutoUpdate=!0,this.position=new V,this.quaternion=new Zr,this.scale=new V(1),this.rotation=new Jr,this.up=new V(0,1,0),this.rotation.och=()=>this.quaternion.fromEuler(this.rotation),this.quaternion.och=()=>this.rotation.fromQuaternion(this.quaternion)}setParent(t,e=!0){this.parent&&t!==this.parent&&this.parent.removeChild(this,!1),this.parent=t,e&&t&&t.addChild(this,!1)}addChild(t,e=!0){~this.children.indexOf(t)||this.children.push(t),e&&t.setParent(this,!1)}removeChild(t,e=!0){~this.children.indexOf(t)&&this.children.splice(this.children.indexOf(t),1),e&&t.setParent(null,!1)}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.WMXNeedsUpdate||t)&&(this.parent===null?this.WMX.copy(this.matrix):this.WMX.multiply(this.parent.WMX,this.matrix),this.WMXNeedsUpdate=!1,t=!0);for(let e=0,s=this.children.length;e<s;e++)this.children[e].updateMatrixWorld(t)}updateMatrix(){this.matrix.compose(this.quaternion,this.position,this.scale),this.WMXNeedsUpdate=!0}traverse(t){if(!t(this))for(let e=0,s=this.children.length;e<s;e++)this.children[e].traverse(t)}lookAt(t,e=!1){this.matrix.getRotation(this.quaternion),this.rotation.fromQuaternion(this.quaternion)}}const ti=new H;class gr extends Zt{constructor(t,{near:e=.1,far:s=100,fov:i=45,aspect:n=1,left:a,right:l,bottom:h,top:c,zoom:_=1}={}){super(),Object.assign(this,{near:e,far:s,fov:i,aspect:n,left:a,right:l,bottom:h,top:c,zoom:_}),this.projectionMatrix=new H,this.viewMatrix=new H,this.projectionViewMatrix=new H,this.worldPosition=new V,this.type="perspective",this.perspective()}perspective({near:t=this.near,far:e=this.far,fov:s=this.fov,aspect:i=this.aspect}={}){return Object.assign(this,{near:t,far:e,fov:s,aspect:i}),this.projectionMatrix.fromPerspective({fov:s*(Math.PI/180),aspect:i,near:t,far:e}),this.type="perspective",this}updateMatrixWorld(){return super.updateMatrixWorld(),this.WMX.getTranslation(this.worldPosition),this.projectionViewMatrix.multiply(this.projectionMatrix,this.viewMatrix),this}lookAt(t){return super.lookAt(t,!0),this}project(t){return t.applyMatrix4(this.viewMatrix),t.applyMatrix4(this.projectionMatrix),this}unproject(t){return t.applyMatrix4(ti.inverse(this.projectionMatrix)),t.applyMatrix4(this.WMX),this}}class ei extends Array{constructor(t=1,e=0,s=0,i=0,n=1,a=0,l=0,h=0,c=1){return super(t,e,s,i,n,a,l,h,c),this}set(t,e,s,i,n,a,l,h,c){return t.length?this.copy(t):this}translate(t,e=this){return this}rotate(t,e=this){return this}scale(t,e=this){return this}multiply(t,e){return this}identity(){return this}copy(t){return this}fromMatrix4(t){return this}fromQuaternion(t){return this}fromBasis(t,e,s){return this}inverse(t=this){return this}getNormalMatrix(t){return this}}let si=0;class yt extends Zt{constructor(t,{geometry:e,_pr:s,mode:i=t.TRIANGLES,frustumCulled:n=!0,renderOrder:a=0}={}){super(),t.canvas||console.error("gl not passed as first argument to Mesh"),this.gl=t,this.id=si++,this.geometry=e,this._pr=s,this.mode=i,this.frustumCulled=n,this.renderOrder=a,this.modelViewMatrix=new H,this.normalMatrix=new ei}draw({camera:t}={}){t&&(this._pr.UNF.modelMatrix||Object.assign(this._pr.UNF,{modelMatrix:{value:null},viewMatrix:{value:null},modelViewMatrix:{value:null},normalMatrix:{value:null},projectionMatrix:{value:null},cameraPosition:{value:null}}),this._pr.UNF.projectionMatrix.value=t.projectionMatrix,this._pr.UNF.cameraPosition.value=t.worldPosition,this._pr.UNF.viewMatrix.value=t.viewMatrix,this.modelViewMatrix.multiply(t.viewMatrix,this.WMX),this.normalMatrix.getNormalMatrix(this.modelViewMatrix),this._pr.UNF.modelMatrix.value=this.WMX,this._pr.UNF.modelViewMatrix.value=this.modelViewMatrix,this._pr.UNF.normalMatrix.value=this.normalMatrix),this._pr.use(),this.geometry.draw({mode:this.mode,_pr:this._pr})}}const ri=new Uint8Array(4);let ii=1;class Qt{constructor(t,{image:e,target:s=t.TEXTURE_2D,type:i=t.UNSIGNED_BYTE,format:n=t.RGBA,internalFormat:a=n,wrapS:l=t.CLAMP_TO_EDGE,wrapT:h=t.CLAMP_TO_EDGE,generateMipmaps:c=!0,minFilter:_=c?t.NEAREST_MIPMAP_LINEAR:t.LINEAR,magFilter:v=t.LINEAR,premultiplyAlpha:f=!1,unpackAlignment:A=4,flipY:b=s==t.TEXTURE_2D,anisotropy:C=0,level:g=0,width:p,height:m=p}={}){this.gl=t,this.id=ii++,this.image=e,this.target=s,this.type=i,this.format=n,this.internalFormat=a,this.minFilter=_,this.magFilter=v,this.wrapS=l,this.wrapT=h,this.generateMipmaps=c,this.premultiplyAlpha=f,this.unpackAlignment=A,this.flipY=b,this.anisotropy=Math.min(C,this.gl.renderer.parameters.maxAnisotropy),this.level=g,this.width=p,this.height=m,this.texture=this.gl.createTexture(),this.store={image:null},this.glState=this.gl.renderer.state,this.state={},this.state.minFilter=this.gl.NEAREST_MIPMAP_LINEAR,this.state.magFilter=this.gl.LINEAR,this.state.wrapS=this.gl.REPEAT,this.state.wrapT=this.gl.REPEAT,this.state.anisotropy=0}bind(){this.glState.textureUnits[this.glState.activeTextureUnit]!==this.id&&(this.gl.bindTexture(this.target,this.texture),this.glState.textureUnits[this.glState.activeTextureUnit]=this.id)}update(t=0){const e=!(this.image===this.store.image&&!this.needsUpdate);(e||this.glState.textureUnits[t]!==this.id)&&(this.gl.renderer.activeTexture(t),this.bind()),e&&(this.needsUpdate=!1,this.flipY!==this.glState.flipY&&(this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,this.flipY),this.glState.flipY=this.flipY),this.premultiplyAlpha!==this.glState.premultiplyAlpha&&(this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),this.glState.premultiplyAlpha=this.premultiplyAlpha),this.unpackAlignment!==this.glState.unpackAlignment&&(this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,this.unpackAlignment),this.glState.unpackAlignment=this.unpackAlignment),this.minFilter!==this.state.minFilter&&(this.gl.texParameteri(this.target,this.gl.TEXTURE_MIN_FILTER,this.minFilter),this.state.minFilter=this.minFilter),this.magFilter!==this.state.magFilter&&(this.gl.texParameteri(this.target,this.gl.TEXTURE_MAG_FILTER,this.magFilter),this.state.magFilter=this.magFilter),this.wrapS!==this.state.wrapS&&(this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_S,this.wrapS),this.state.wrapS=this.wrapS),this.wrapT!==this.state.wrapT&&(this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_T,this.wrapT),this.state.wrapT=this.wrapT),this.image?(this.image.width&&(this.width=this.image.width,this.height=this.image.height),ArrayBuffer.isView(this.image)?this.gl.texImage2D(this.target,this.level,this.internalFormat,this.width,this.height,0,this.format,this.type,this.image)