memoscan
← all memos

Memo 0x14837899…b1f9df on Ethereum

w F.default.DataArray,this.lineTangentsOut=new F.default.DataArray,this.lineSides=new F.default.DataArray,this.vertexNormals=[],this.faces=[],this.uvs=[],this.edges=[],this.vertexColors=[],this.vertexStrokeColors=[],this.lineVertexColors=new F.default.DataArray,this.detailX=void 0!==e?e:1,this.detailY=void 0!==t?t:1,this.dirtyFlags={},this._hasFillTransparency=void 0,this._hasStrokeTransparency=void 0,r instanceof Function&&r.call(this)}var e,t,r;return e=o,(t=[{key:"calculateBoundingBox",value:function(){if(!this.boundingBoxCache){for(var e=new F.default.Vector(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),t=new F.default.Vector(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE),r=0;r<this.vertices.length;r++){var o=this.vertices[r];e.x=Math.min(e.x,o.x),e.y=Math.min(e.y,o.y),e.z=Math.min(e.z,o.z),t.x=Math.max(t.x,o.x),t.y=Math.max(t.y,o.y),t.z=Math.max(t.z,o.z)}var n=new F.default.Vector(t.x-e.x,t.y-e.y,t.z-e.z),s=new F.default.Vector((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2);this.boundingBoxCache={min:e,max:t,size:n,offset:s}}return this.boundingBoxCache}},{key:"reset",value:function(){this._hasFillTransparency=void 0,this._hasStrokeTransparency=void 0,this.lineVertices.clear(),this.lineTangentsIn.clear(),this.lineTangentsOut.clear(),this.lineSides.clear(),this.vertices.length=0,this.edges.length=0,this.vertexColors.length=0,this.vertexStrokeColors.length=0,this.lineVertexColors.clear(),this.vertexNormals.length=0,this.uvs.length=0,this.dirtyFlags={}}},{key:"hasFillTransparency",value:function(){if(void 0===this._hasFillTransparency){this._hasFillTransparency=!1;for(var e=0;e<this.vertexColors.length;e+=4)if(this.vertexColors[e+3]<1){this._hasFillTransparency=!0;break}}return this._hasFillTransparency}},{key:"hasStrokeTransparency",value:function(){if(void 0===this._hasStrokeTransparency){this._hasStrokeTransparency=!1;for(var e=0;e<this.lineVertexColors.length;e+=4)if(this.lineVertexColors[e+3]<1){this._hasStrokeTransparency=!0;break}}return this._hasStrokeTransparency}},{key:"clearColors",value:function(){return this.vertexColors=[],this}},{key:"saveObj",value:function(){var r=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"model.obj",o="";if(this.vertices.forEach(function(e){o+="v ".concat(e.x," ").concat(e.y," ").concat(e.z,"\n")}),this.uvs&&0<this.uvs.length)for(var t=0;t<this.uvs.length;t+=2)o+="vt ".concat(this.uvs[t]," ").concat(this.uvs[t+1],"\n");this.vertexNormals&&0<this.vertexNormals.length&&this.vertexNormals.forEach(function(e){o+="vn ".concat(e.x," ").concat(e.y," ").concat(e.z,"\n")}),this.faces.forEach(function(e){var t="f";e.forEach(function(e){t=t+" "+(e+1),(0<r.vertexNormals.length||0<r.uvs.length)&&(t+="/",0<r.uvs.length&&(t+=e+1),t+="/",0<r.vertexNormals.length&&(t+=e+1))}),o+=t+"\n"});var n=new Blob([o],{type:"text/plain"});F.default.prototype.downloadFile(n,e,"obj")}},{key:"saveStl",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"model.stl",t=(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).binary,t=void 0!==t&&t,r=e.substring(0,e.lastIndexOf(".")),o=[],n=!0,s=!1,i=void 0;try{for(var a,l=this.faces[Symbol.iterator]();!(n=(a=l.next()).done);n=!0){var u=a.value,c=F.default.Vector.sub(this.vertices[u[1]],this.vertices[u[0]]),d=F.default.Vector.sub(this.vertices[u[2]],this.vertices[u[0]]),h=c.y*d.z-c.z*d.y,f=c.z*d.x-c.x*d.z,p=c.x*d.y-c.y*d.x;o.push(new F.default.Vector(h,f,p).normalize())}}catch(e){s=!0,i=e}finally{try{n||null==l.return||l.return()}finally{if(s)throw i}}if(t){var m,y=80,s=2*this.faces.length+3*this.faces.length*4*4+80+4,i=new ArrayBuffer(s);(m=new DataView(i)).setUint32(y,this.faces.length,!0),y+=4;for(var g=0,v=Object.entries(this.faces);g<v.length;g++){var b=U(v[g],2),_=b[0],b=b[1],_=o[_],j=(m.setFloat32(y,_.x,!0),y+=4,m.setFloat32(y,_.y,!0),y+=4,m.setFloat32(y,_.z,!0),y+=4,!0),_=!1,x=void 0;try{for(var w,S=b[Symbol.iterator]();!(j=(w=S.next()).done);j=!0){var I=w.value,T=this.vertices[I];m.setFloat32(y,T.x,!0),y+=4,m.setFloat32(y,T.y,!0),y+=4,m.setFloat32(y,T.z,!0),y+=4}}catch(e){_=!0,x=e}finally{try{j||null==S.return||S.return()}finally{if(_)throw x}}m.setUint16(y,0,!0),y+=2}}else{m="solid "+r+"\n";for(var E=0,M=Object.entries(this.faces);E<M.length;E++){var k=U(M[E],2),O=k[0],k=k[1],O=o[O],C=(m=m+(" facet norm "+O.x+" "+O.y+" "+O.z+"\n")+" outer loop\n",!0),O=!1,P=void 0;try{for(var A,L=k[Symbol.iterator]();!(C=(A=L.next()).done);C=!0){var D=A.value,R=this.vertices[D];m+=" vertex "+R.x+" "+R.y+" "+R.z+"\n"}}catch(e){O=!0,P=e}finally{try{C||null==L.return||L.return()}finally{if(O)throw P}}m=m+" endloop\n"+" endfacet\n"}m+="endsolid "+r+"\n"}t=new Blob([m],{type:"text/plain"});F.default.prototype.downloadFile(t,e,"stl")}},{key:"flipU",value:function(){this.uvs=this.uvs.flat().map(function(e,t){return t%2==0?1-e:e})}},{key:"flipV",value:function(){this.uvs=this.uvs.flat().map(function(e,t){return t%2==0?e:1-e})}},{key:"computeFaces",value:function(){this.faces.length=0;for(var e,t,r,o=this.detailX+1,n=0;n<this.detailY;n++)for(var s=0;s<this.detailX;s++)t=(n+1)*o+s+1,this.faces.push([n*o+s,e=n*o+s+1,r=(n+1)*o+s]),this.faces.push([r,e,t]);return this}},{key:"_getFaceNormal",value:function(e){var e=this.faces[e],t=this.vertices[e[0]],r=this.vertices[e[1]],e=this.vertices[e[2]],r=F.default.Vector.sub(r,t),e=F.default.Vector.sub(e,t),t=F.default.Vector.cross(r,e),o=F.default.Vector.mag(t),r=o/(F.default.Vector.mag(r)*F.default.Vector.mag(e));return 0===r||isNaN(r)?(console.warn("p5.Geometry.prototype._getFaceNormal:","face has colinear sides or a repeated vertex"),t):(1<r&&(r=1),t.mult(Math.asin(r)/o))}},{key:"computeNormals",value:function(){var e,s=this,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:m.FLAT,r=(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).roundToPrecision,i=this.vertexNormals,o=this.vertices,n=this.faces;if(t===m.SMOOTH){for(var a={},l=[],u=Math.pow(10,void 0===r?3:r),c=function(e){return Math.round(e*u)/u},d=function(e){return"".concat(c(e.x),",").concat(c(e.y),",").concat(c(e.z))},h=0;h<o.length;h++){var f=o[h],p=d(f);void 0===a[p]&&(a[p]=l.length,l.push(f))}n.forEach(function(e){for(var t=0;t<3;++t){var r=e[t],r=o[r],r=d(r);e[t]=a[r]}}),this.edges.forEach(function(e){for(var t=0;t<2;++t){var r=e[t],r=o[r],r=d(r);e[t]=a[r]}}),this.vertices=o=l}for(e=i.length=0;e<o.length;++e)i.push(new F.default.Vector);for(n.forEach(function(e,t){for(var r=s._getFaceNormal(t),o=0;o<3;++o){var n=e[o];i[n].add(r)}}),e=0;e<o.length;++e)i[e].normalize();return this}},{key:"averageNormals",value:function(){for(var e=0;e<=this.detailY;e++){var t=this.detailX+1,r=F.default.Vector.add(this.vertexNormals[e*t],this.vertexNormals[e*t+this.detailX]),r=F.default.Vector.div(r,2);this.vertexNormals[e*t]=r,this.vertexNormals[e*t+this.detailX]=r}return this}},{key:"averagePoleNormals",value:function(){for(var e=new F.default.Vector(0,0,0),t=0;t<this.detailX;t++)e.add(this.vertexNormals[t]);for(var e=F.default.Vector.div(e,this.detailX),r=0;r<this.detailX;r++)this.vertexNormals[r]=e;e=new F.default.Vector(0,0,0);for(var o=this.vertices.length-1;o>this.vertices.length-1-this.detailX;o--)e.add(this.vertexNormals[o]);e=F.default.Vector.div(e,this.detailX);for(var n=this.vertices.length-1;n>this.vertices.length-1-this.detailX;n--)this.vertexNormals[n]=e;return this}},{key:"_makeTriangleEdges",value:function(){for(var e=this.edges.length=0;e<this.faces.length;e++)this.edges.push([this.faces[e][0],this.faces[e][1]]),this.edges.push([this.faces[e][1],this.faces[e][2]]),this.edges.push([this.faces[e][2],this.faces[e][0]]);return this}},{key:"_edgesToVertices",value:function(){this.lineVertices.clear(),this.lineTangentsIn.clear(),this.lineTangentsOut.clear(),this.lineSides.clear();for(var e,t=new Map,r=new Set,o=0;o<this.edges.length;o++){var n,s=this.edges[o-1],i=this.edges[o],a=this.vertices[i[0]],l=this.vertices[i[1]],u=0<this.vertexStrokeColors.length&&s?this.vertexStrokeColors.slice(4*s[1],4*(s[1]+1)):[0,0,0,0],c=0<this.vertexStrokeColors.length?this.vertexStrokeColors.slice(4*i[0],4*(i[0]+1)):[0,0,0,0],d=0<this.vertexStrokeColors.length?this.vertexStrokeColors.slice(4*i[1],4*(i[1]+1)):[0,0,0,0],h=l.copy().sub(a).normalize(),f=0<h.magSq();f&&this._addSegment(a,l,c,d,h),0<o&&s[1]===i[0]?r.has(i[0])||(r.add(i[0]),t.delete(i[0]),e&&f&&h.dot(e)<1-1e-8&&this._addJoin(a,e,h,c)):(f&&!r.has(i[0])&&((n=t.get(i[0]))?(this._addJoin(a,n.dir,h,c),t.delete(i[0]),r.add(i[0])):t.set(i[0],{point:a,dir:h.copy().mult(-1),color:c})),e&&!r.has(s[1])&&((n=t.get(s[1]))?(this._addJoin(this.vertices[s[1]],e,n.dir.copy().mult(-1),u),t.delete(s[1]),r.add(s[1])):t.set(s[1],{point:this.vertices[s[1]],dir:e,color:u}),e=void 0)),o!==this.edges.length-1||r.has(i[1])||((a=t.get(i[1]))?(this._addJoin(l,h,a.dir.copy().mult(-1),d),t.delete(i[1]),r.add(i[1])):t.set(i[1],{point:l,dir:h,color:d})),f&&(e=h)}var p=!0,m=!1,y=void 0;try{for(var g,v=t.values()[Symbol.iterator]();!(p=(g=v.next()).done);p=!0){var b=g.value,_=b.point,j=b.dir,x=b.color;this._addCap(_,j,x)}}catch(e){m=!0,y=e}finally{try{p||null==v.return||v.return()}finally{if(m)throw y}}return this}},{key:"_addSegment",value:function(e,t,r,o,n){var e=e.array(),t=t.array(),s=n.array();this.lineSides.push(1,1,-1,1,-1,-1);for(var i=0,a=[this.lineTangentsIn,this.lineTangentsOut];i<a.length;i++)for(var l=a[i],u=0;u<6;u++)l.push.apply(l,c(s));return(n=this.lineVertices).push.apply(n,c(e).concat(c(t),c(e),c(t),c(t),c(e))),(n=this.lineVertexColors).push.apply(n,c(r).concat(c(o),c(r),c(o),c(o),c(r))),this}},{key:"_addCap",value:function(e,t,r){for(var o,n=e.array(),s=t.array(),i=[0,0,0],a=0;a<6;a++)(o=this.lineVertices).push.apply(o,c(n)),(o=this.lineTangentsIn).push.apply(o,c(s)),(o=this.lineTangentsOut).push.apply(o,i),(o=this.lineVertexColors).push.apply(o,c(r));return this.lineSides.push(-1,2,-2,1,2,-1),this}},{key:"_addJoin",value:function(e,t,r,o){for(var n,s=e.array(),i=t.array(),a=r.array(),l=0;l<12;l++)(n=this.lineVertices).push.apply(n,c(s)),(n=this.lineTangentsIn).push.apply(n,c(i)),(n=this.lineTangentsOut).push.apply(n,c(a)),(n=this.lineVertexColors).push.apply(n,c(o));return this.lineSides.push(-1,-3,-2,-1,0,-3),this.lineSides.push(3,1,2,3,0,1),this}},{key:"normalize",value:function(){if(0<this.vertices.length){for(var e=this.vertices[0].copy(),t=this.vertices[0].copy(),r=0;r<this.vertices.length;r++)e.x=Math.max(e.x,this.vertices[r].x),t.x=Math.min(t.x,this.vertices[r].x),e.y=Math.max(e.y,this.vertices[r].y),t.y=Math.min(t.y,this.vertices[r].y),e.z=Math.max(e.z,this.vertices[r].z),t.z=Math.min(t.z,this.vertices[r].z);for(var o=F.default.Vector.lerp(e,t,.5),n=F.default.Vector.sub(e,t),s=200/Math.max(Math.max(n.x,n.y),n.z),i=0;i<this.vertices.length;i++)this.vertices[i].sub(o),this.vertices[i].mult(s)}return this}}])&&n(e.prototype,t),r&&n(e,r),o}();var s=F.default.Geometry;r.default=s},{"../core/constants":272,"../core/main":283,"core-js/modules/es.array-buffer.constructor":152,"core-js/modules/es.array.concat":153,"core-js/modules/es.array.flat":160,"core-js/modules/es.array.for-each":161,"core-js/modules/es.array.from":162,"core-js/modules/es.array.iterator":165,"core-js/modules/es.array.last-index-of":167,"core-js/modules/es.array.map":168,"core-js/modules/es.array.slice":169,"core-js/modules/es.array.unscopables.flat":173,"core-js/modules/es.map":175,"core-js/modules/es.number.constructor":179,"core-js/modules/es.object.entries":184,"core-js/modules/es.object.get-own-property-descriptor":186,"core-js/modules/es.object.to-string":190,"core-js/modules/es.regexp.to-string":196,"core-js/modules/es.set":197,"core-js/modules/es.string.iterator":200,"core-js/modules/es.string.sub":208,"core-js/modules/es.symbol":212,"core-js/modules/es.symbol.description":210,"core-js/modules/es.symbol.iterator":211,"core-js/modules/es.weak-map":244,"core-js/modules/web.dom-collections.for-each":245,"core-js/modules/web.dom-collections.iterator":246}],336:[function(e,t,r){"use strict";e("core-js/modules/es.array.iterator"),e("core-js/modules/es.object.to-string"),e("core-js/modules/es.typed-array.float32-array"),e("core-js/modules/es.typed-array.copy-within"),e("core-js/modules/es.typed-array.every"),e("core-js/modules/es.typed-array.fill"),e("core-js/modules/es.typed-array.filter"),e("core-js/modules/es.typed-array.find"),e("core-js/modules/es.typed-array.find-index"),e("core-js/modules/es.typed-array.for-each"),e("core-js/modules/es.typed-array.includes"),e("core-js/modules/es.typed-array.index-of"),e("core-js/modules/es.typed-array.iterator"),e("core-js/modules/es.typed-array.join"),e("core-js/modules/es.typed-array.last-index-of"),e("core-js/modules/es.typed-array.map"),e("core-js/modules/es.typed-array.reduce"),e("core-js/modules/es.typed-array.reduce-right"),e("core-js/modules/es.typed-array.reverse"),e("core-js/modules/es.typed-array.set"),e("core-js/modules/es.typed-array.slice"),e("core-js/modules/es.typed-array.some"),e("core-js/modules/es.typed-array.sort"),e("core-js/modules/es.typed-array.subarray"),e("core-js/modules/es.typed-array.to-locale-string"),e("core-js/modules/es.typed-array.to-string"),e("core-js/modules/es.array.iterator"),e("core-js/modules/es.object.to-string"),e("core-js/modules/es.typed-array.float32-array"),e("core-js/modules/es.typed-array.copy-within"),e("core-js/modules/es.typed-array.every"),e("core-js/modules/es.typed-array.fill"),e("core-js/modules/es.typed-array.filter"),e("core-js/modules/es.typed-array.find"),e("core-js/modules/es.typed-array.find-index"),e("core-js/modules/es.typed-array.for-each"),e("core-js/modules/es.typed-array.includes"),e("core-js/modules/es.typed-array.index-of"),e("core-js/modules/es.typed-array.iterator"),e("core-js/modules/es.typed-array.join"),e("core-js/modules/es.typed-array.last-index-of"),e("core-js/modules/es.typed-array.map"),e("core-js/modules/es.typed-array.reduce"),e("core-js/modules/es.typed-array.reduce-right"),e("core-js/modules/es.typed-array.reverse"),e("core-js/modules/es.typed-array.set"),e("core-js/modules/es.typed-array.slice"),e("core-js/modules/es.typed-array.some"),e("core-js/modules/es.typed-array.sort"),e("core-js/modules/es.typed-array.subarray"),e("core-js/modules/es.typed-array.to-locale-string"),e("core-js/modules/es.typed-array.to-string"),Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var O=(e=e("../core/main"))&&e.__esModule?e:{default:e};function n(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var s=Array,C=function(e){return Array.isArray(e)},e=("undefined"!=typeof Float32Array&&(s=Float32Array,C=function(e){return Array.isArray(e)||e instanceof Float32Array}),O.default.Matrix=function(){function r(){var e=this,t=r;if(e instanceof t)return arguments.length&&((e=arguments.length-1)<0||arguments.length<=e?void 0:arguments[e])instanceof O.default&&(this.p5=(t=arguments.length-1)<0||arguments.length<=t?void 0:arguments[t]),"mat3"===(arguments.length<=0?void 0:arguments[0])?this.mat3=Array.isArray(arguments.length<=1?void 0:arguments[1])?arguments.length<=1?void 0:arguments[1]:new s([1,0,0,0,1,0,0,0,1]):this.mat4=Array.isArray(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:new s([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this;throw new TypeError("Cannot call a class as a function")}var e,t,o;return e=r,o=[{key:"identity",value:function(e){return new O.default.Matrix(e)}}],(t=[{key:"reset",value:function(){return this.mat3?this.mat3.set([1,0,0,0,1,0,0,0,1]):this.mat4&&this.mat4.set([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this}},{key:"set",value:function(e){var t=arguments;if(e instanceof O.default.Matrix?t=e.mat4:C(e)&&(t=e),16!==t.length)O.default._friendlyError("Expected 16 values but received ".concat(t.length,"."),"p5.Matrix.set");else for(var r=0;r<16;r++)this.mat4[r]=t[r];return this}},{key:"get",value:function(){return new O.default.Matrix(this.mat4,this.p5)}},{key:"copy",value:function(){var e;return void 0!==this.mat3?((e=new O.default.Matrix("mat3",this.p5)).mat3[0]=this.mat3[0],e.mat3[1]=this.mat3[1],e.mat3[2]=this.mat3[2],e.mat3[3]=this.mat3[3],e.mat3[4]=this.mat3[4],e.mat3[5]=this.mat3[5],e.mat3[6]=this.mat3[6],e.mat3[7]=this.mat3[7],e.mat3[8]=this.mat3[8]):((e=new O.default.Matrix(this.p5)).mat4[0]=this.mat4[0],e.mat4[1]=this.mat4[1],e.mat4[2]=this.mat4[2],e.mat4[3]=this.mat4[3],e.mat4[4]=this.mat4[4],e.mat4[5]=this.mat4[5],e.mat4[6]=this.mat4[6],e.mat4[7]=this.mat4[7],e.mat4[8]=this.mat4[8],e.mat4[9]=this.mat4[9],e.mat4[10]=this.mat4[10],e.mat4[11]=this.mat4[11],e.mat4[12]=this.mat4[12],e.mat4[13]=this.mat4[13],e.mat4[14]=this.mat4[14],e.mat4[15]=this.mat4[15]),e}},{key:"transpose",value:function(e){var t,r,o,n,s,i;return e instanceof O.default.Matrix?(t=e.mat4[1],r=e.mat4[2],o=e.mat4[3],n=e.mat4[6],s=e.mat4[7],i=e.mat4[11],this.mat4[0]=e.mat4[0],this.mat4[1]=e.mat4[4],this.mat4[2]=e.mat4[8],this.mat4[3]=e.mat4[12],this.mat4[4]=t,this.mat4[5]=e.mat4[5],this.mat4[6]=e.mat4[9],this.mat4[7]=e.mat4[13],this.mat4[8]=r,this.mat4[9]=n,this.mat4[10]=e.mat4[10],this.mat4[11]=e.mat4[14],this.mat4[12]=o,this.mat4[13]=s,this.mat4[14]=i,this.mat4[15]=e.mat4[15]):C(e)&&(t=e[1],r=e[2],o=e[3],n=e[6],s=e[7],i=e[11],this.mat4[0]=e[0],this.mat4[1]=e[4],this.mat4[2]=e[8],this.mat4[3]=e[12],this.mat4[4]=t,this.mat4[5]=e[5],this.mat4[6]=e[9],this.mat4[7]=e[13],this.mat4[8]=r,this.mat4[9]=n,this.mat4[10]=e[10],this.mat4[11]=e[14],this.mat4[12]=o,this.mat4[13]=s,this.mat4[14]=i,this.mat4[15]=e[15]),this}},{key:"invert",value:function(e){e instanceof O.default.Matrix?(t=e.mat4[0],r=e.mat4[1],o=e.mat4[2],n=e.mat4[3],s=e.mat4[4],i=e.mat4[5],a=e.mat4[6],l=e.mat4[7],u=e.mat4[8],c=e.mat4[9],d=e.mat4[10],h=e.mat4[11],f=e.mat4[12],p=e.mat4[13],m=e.mat4[14],y=e.mat4[15]):C(e)&&(t=e[0],r=e[1],o=e[2],n=e[3],s=e[4],i=e[5],a=e[6],l=e[7],u=e[8],c=e[9],d=e[10],h=e[11],f=e[12],p=e[13],m=e[14],y=e[15]);var t,r,o,n,s,i,a,l,u,c,d,h,f,p,m,y,e=t*i-r*s,g=t*a-o*s,v=t*l-n*s,b=r*a-o*i,_=r*l-n*i,j=o*l-n*a,x=u*p-c*f,w=u*m-d*f,S=u*y-h*f,T=c*m-d*p,E=c*y-h*p,M=d*y-h*m,k=e*M-g*E+v*T+b*S-_*w+j*x;return k?(this.mat4[0]=(i*M-a*E+l*T)*(k=1/k),this.mat4[1]=(o*E-r*M-n*T)*k,this.mat4[2]=(p*j-m*_+y*b)*k,this.mat4[3]=(d*_-c*j-h*b)*k,this.mat4[4]=(a*S-s*M-l*w)*k,this.mat4[5]=(t*M-o*S+n*w)*k,this.mat4[6]=(m*v-f*j-y*g)*k,this.mat4[7]=(u*j-d*v+h*g)*k,this.mat4[8]=(s*E-i*S+l*x)*k,this.mat4[9]=(r*S-t*E-n*x)*k,this.mat4[10]=(f*_-p*v+y*e)*k,this.mat4[11]=(c*v-u*_-h*e)*k,this.mat4[12]=(i*w-s*T-a*x)*k,this.mat4[13]=(t*T-r*w+o*x)*k,this.mat4[14]=(p*g-f*b-m*e)*k,this.mat4[15]=(u*b-c*g+d*e)*k,this):null}},{key:"invert3x3",value:function(){var e=this.mat3[0],t=this.mat3[1],r=this.mat3[2],o=this.mat3[3],n=this.mat3[4],s=this.mat3[5],i=this.mat3[6],a=this.mat3[7],l=this.mat3[8],u=l*n-s*a,c=-l*o+s*i,d=a*o-n*i,h=e*u+t*c+r*d;return h?(this.mat3[0]=u*(h=1/h),this.mat3[1]=(-l*t+r*a)*h,this.mat3[2]=(s*t-r*n)*h,this.mat3[3]=c*h,this.mat3[4]=(l*e-r*i)*h,this.mat3[5]=(-s*e+r*o)*h,this.mat3[6]=d*h,this.mat3[7]=(-a*e+t*i)*h,this.mat3[8]=(n*e-t*o)*h,this):null}},{key:"transpose3x3",value:function(e){var t=(e=void 0===e?this.mat3:e)[1],r=e[2],o=e[5];return this.mat3[0]=e[0],this.mat3[1]=e[3],this.mat3[2]=e[6],this.mat3[3]=t,this.mat3[4]=e[4],this.mat3[5]=e[7],this.mat3[6]=r,this.mat3[7]=o,this.mat3[8]=e[8],this}},{key:"inverseTranspose",value:function(e){e=e.mat4,void 0===this.mat3?O.default._friendlyError("sorry, this function only works with mat3"):(this.mat3[0]=e[0],this.mat3[1]=e[1],this.mat3[2]=e[2],this.mat3[3]=e[4],this.mat3[4]=e[5],this.mat3[5]=e[6],this.mat3[6]=e[8],this.mat3[7]=e[9],this.mat3[8]=e[10]),e=this.invert3x3();if(e)e.transpose3x3(this.mat3);else for(var t=0;t<9;t++)this.mat3[t]=0;return this}},{key:"determinant",value:function(){var e=this.mat4[0]*this.mat4[5]-this.mat4[1]*this.mat4[4],t=this.mat4[0]*this.mat4[6]-this.mat4[2]*this.mat4[4],r=this.mat4[0]*this.mat4[7]-this.mat4[3]*this.mat4[4],o=this.mat4[1]*this.mat4[6]-this.mat4[2]*this.mat4[5],n=this.mat4[1]*this.mat4[7]-this.mat4[3]*this.mat4[5],s=this.mat4[2]*this.mat4[7]-this.mat4[3]*this.mat4[6],i=this.mat4[8]*this.mat4[13]-this.mat4[9]*this.mat4[12],a=this.mat4[8]*this.mat4[14]-this.mat4[10]*this.mat4[12],l=this.mat4[8]*this.mat4[15]-this.mat4[11]*this.mat4[12],u=this.mat4[9]*this.mat4[14]-this.mat4[10]*this.mat4[13],c=this.mat4[9]*this.mat4[15]-this.mat4[11]*this.mat4[13];return e*(this.mat4[10]*this.mat4[15]-this.mat4[11]*this.mat4[14])-t*c+r*u+o*l-n*a+s*i}},{key:"mult",value:function(e){var t;if(e===this||e===this.mat4)t=this.copy().mat4;else if(e instanceof O.default.Matrix)t=e.mat4;else if(C(e))t=e;else{if(16!==arguments.length)return;t=arguments}var e=this.mat4[0],r=this.mat4[1],o=this.mat4[2],n=this.mat4[3];return this.mat4[0]=e*t[0]+r*t[4]+o*t[8]+n*t[12],this.mat4[1]=e*t[1]+r*t[5]+o*t[9]+n*t[13],this.mat4[2]=e*t[2]+r*t[6]+o*t[10]+n*t[14],this.mat4[3]=e*t[3]+r*t[7]+o*t[11]+n*t[15],e=this.mat4[4],r=this.mat4[5],o=this.mat4[6],n=this.mat4[7],this.mat4[4]=e*t[0]+r*t[4]+o*t[8]+n*t[12],this.mat4[5]=e*t[1]+r*t[5]+o*t[9]+n*t[13],this.mat4[6]=e*t[2]+r*t[6]+o*t[10]+n*t[14],this.mat4[7]=e*t[3]+r*t[7]+o*t[11]+n*t[15],e=this.mat4[8],r=this.mat4[9],o=this.mat4[10],n=this.mat4[11],this.mat4[8]=e*t[0]+r*t[4]+o*t[8]+n*t[12],this.mat4[9]=e*t[1]+r*t[5]+o*t[9]+n*t[13],this.mat4[10]=e*t[2]+r*t[6]+o*t[10]+n*t[14],this.mat4[11]=e*t[3]+r*t[7]+o*t[11]+n*t[15],e=this.mat4[12],r=this.mat4[13],o=this.mat4[14],n=this.mat4[15],this.mat4[12]=e*t[0]+r*t[4]+o*t[8]+n*t[12],this.mat4[13]=e*t[1]+r*t[5]+o*t[9]+n*t[13],this.mat4[14]=e*t[2]+r*t[6]+o*t[10]+n*t[14],this.mat4[15]=e*t[3]+r*t[7]+o*t[11]+n*t[15],this}},{key:"apply",value:function(e){var t;if(e===this||e===this.mat4)t=this.copy().mat4;else if(e instanceof O.default.Matrix)t=e.mat4;else if(C(e))t=e;else{if(16!==arguments.length)return;t=arguments}var e=this.mat4,r=e[0],o=e[4],n=e[8],s=e[12],r=(e[0]=t[0]*r+t[1]*o+t[2]*n+t[3]*s,e[4]=t[4]*r+t[5]*o+t[6]*n+t[7]*s,e[8]=t[8]*r+t[9]*o+t[10]*n+t[11]*s,e[12]=t[12]*r+t[13]*o+t[14]*n+t[15]*s,e[1]),o=e[5],n=e[9],s=e[13],r=(e[1]=t[0]*r+t[1]*o+t[2]*n+t[3]*s,e[5]=t[4]*r+t[5]*o+t[6]*n+t[7]*s,e[9]=t[8]*r+t[9]*o+t[10]*n+t[11]*s,e[13]=t[12]*r+t[13]*o+t[14]*n+t[15]*s,e[2]),o=e[6],n=e[10],s=e[14],r=(e[2]=t[0]*r+t[1]*o+t[2]*n+t[3]*s,e[6]=t[4]*r+t[5]*o+t[6]*n+t[7]*s,e[10]=t[8]*r+t[9]*o+t[10]*n+t[11]*s,e[14]=t[12]*r+t[13]*o+t[14]*n+t[15]*s,e[3]),o=e[7],n=e[11],s=e[15];return e[3]=t[0]*r+t[1]*o+t[2]*n+t[3]*s,e[7]=t[4]*r+t[5]*o+t[6]*n+t[7]*s,e[11]=t[8]*r+t[9]*o+t[10]*n+t[11]*s,e[15]=t[12]*r+t[13]*o+t[14]*n+t[15]*s,this}},{key:"scale",value:function(e,t,r){return e instanceof O.default.Vector?(t=e.y,r=e.z,e=e.x):e instanceof Array&&(t=e[1],r=e[2],e=e[0]),this.mat4[0]*=e,this.mat4[1]*=e,this.mat4[2]*=e,this.mat4[3]*=e,this.mat4[4]*=t,this.mat4[5]*=t,this.mat4[6]*=t,this.mat4[7]*=t,this.mat4[8]*=r,this.mat4[9]*=r,this.mat4[10]*=r,this.mat4[11]*=r,this}},{key:"rotate",value:function(e,t,r,o){t instanceof O.default.Vector?(r=t.y,o=t.z,t=t.x):t instanceof Array&&(r=t[1],o=t[2],t=t[0]);var n=Math.sqrt(t*t+r*r+o*o),n=(t*=1/n,r*=1/n,o*=1/n,this.mat4[0]),s=this.mat4[1],i=this.mat4[2],a=this.mat4[3],l=this.mat4[4],u=this.mat4[5],c=this.mat4[6],d=this.mat4[7],h=this.mat4[8],f=this.mat4[9],p=this.mat4[10],m=this.mat4[11],y=Math.sin(e),e=Math.cos(e),g=1-e,v=t*t*g+e,b=r*t*g+o*y,_=o*t*g-r*y,j=t*r*g-o*y,x=r*r*g+e,w=o*r*g+t*y,S=t*o*g+r*y,r=r*o*g-t*y,t=o*o*g+e;return this.mat4[0]=n*v+l*b+h*_,this.mat4[1]=s*v+u*b+f*_,this.mat4[2]=i*v+c*b+p*_,this.mat4[3]=a*v+d*b+m*_,this.mat4[4]=n*j+l*x+h*w,this.mat4[5]=s*j+u*x+f*w,this.mat4[6]=i*j+c*x+p*w,this.mat4[7]=a*j+d*x+m*w,this.mat4[8]=n*S+l*r+h*t,this.mat4[9]=s*S+u*r+f*t,this.mat4[10]=i*S+c*r+p*t,this.mat4[11]=a*S+d*r+m*t,this}},{key:"translate",value:function(e){var t=e[0],r=e[1],e=e[2]||0;this.mat4[12]+=this.mat4[0]*t+this.mat4[4]*r+this.mat4[8]*e,this.mat4[13]+=this.mat4[1]*t+this.mat4[5]*r+this.mat4[9]*e,this.mat4[14]+=this.mat4[2]*t+this.mat4[6]*r+this.mat4[10]*e,this.mat4[15]+=this.mat4[3]*t+this.mat4[7]*r+this.mat4[11]*e}},{key:"rotateX",value:function(e){this.rotate(e,1,0,0)}},{key:"rotateY",value:function(e){this.rotate(e,0,1,0)}},{key:"rotateZ",value:function(e){this.rotate(e,0,0,1)}},{key:"perspective",value:function(e,t,r,o){var e=1/Math.tan(e/2),n=1/(r-o);return this.mat4[0]=e/t,this.mat4[1]=0,this.mat4[2]=0,this.mat4[3]=0,this.mat4[4]=0,this.mat4[5]=e,this.mat4[6]=0,this.mat4[7]=0,this.mat4[8]=0,this.mat4[9]=0,this.mat4[10]=(o+r)*n,this.mat4[11]=-1,this.mat4[12]=0,this.mat4[13]=0,this.mat4[14]=2*o*r*n,this.mat4[15]=0,this}},{key:"ortho",value:function(e,t,r,o,n,s){var i=1/(e-t),a=1/(r-o),l=1/(n-s);return this.mat4[0]=-2*i,this.mat4[1]=0,this.mat4[2]=0,this.mat4[3]=0,this.mat4[4]=0,this.mat4[5]=-2*a,this.mat4[6]=0,this.mat4[7]=0,this.mat4[8]=0,this.mat4[9]=0,this.mat4[10]=2*l,this.mat4[11]=0,this.mat4[12]=(e+t)*i,this.mat4[13]=(o+r)*a,this.mat4[14]=(s+n)*l,this.mat4[15]=1,this}},{key:"multiplyVec4",value:function(e,t,r,o){var n=new Array(4),s=this.mat4;return n[0]=s[0]*e+s[4]*t+s[8]*r+s[12]*o,n[1]=s[1]*e+s[5]*t+s[9]*r+s[13]*o,n[2]=s[2]*e+s[6]*t+s[10]*r+s[14]*o,n[3]=s[3]*e+s[7]*t+s[11]*r+s[15]*o,n}},{key:"multiplyPoint",value:function(e){var t=e.x,r=e.y,e=e.z,t=this.multiplyVec4(t,r,e,1);return new O.default.Vector(t[0],t[1],t[2])}},{key:"multiplyAndNormalizePoint",value:function(e){var t=e.x,r=e.y,e=e.z,t=this.multiplyVec4(t,r,e,1);return t[0]/=t[3],t[1]/=t[3],t[2]/=t[3],new O.default.Vector(t[0],t[1],t[2])}},{key:"multiplyDirection",value:function(e){var t=e.x,r=e.y,e=e.z,t=this.multiplyVec4(t,r,e,0);return new O.default.Vector(t[0],t[1],t[2])}},{key:"mult3x3",value:function(e){var t;if(e===this||e===this.mat3)t=this.copy().mat3;else if(e instanceof O.default.Matrix)t=e.mat3;else if(C(e))t=e;else{if(9!==arguments.length)return;t=arguments}var e=this.mat3[0],r=this.mat3[1],o=this.mat3[2];return this.mat3[0]=e*t[0]+r*t[3]+o*t[6],this.mat3[1]=e*t[1]+r*t[4]+o*t[7],this.mat3[2]=e*t[2]+r*t[5]+o*t[8],e=this.mat3[3],r=this.mat3[4],o=this.mat3[5],this.mat3[3]=e*t[0]+r*t[3]+o*t[6],this.mat3[4]=e*t[1]+r*t[4]+o*t[7],this.mat3[5]=e*t[2]+r*t[5]+o*t[8],e=this.mat3[6],r=this.mat3[7],o=this.mat3[8],this.mat3[6]=e*t[0]+r*t[3]+o*t[6],this.mat3[7]=e*t[1]+r*t[4]+o*t[7],this.mat3[8]=e*t[2]+r*t[5]+o*t[8],this}},{key:"column",value:function(e){return new O.default.Vector(this.mat3[3*e],this.mat3[3*e+1],this.mat3[3*e+2])}},{key:"row",value:function(e){return new O.default.Vector(this.mat3[e],this.mat3[e+3],this.mat3[e+6])}},{key:"diagonal",value:function(){return void 0!==this.mat3?[this.mat3[0],this.mat3[4],this.mat3[8]]:[this.mat4[0],this.mat4[5],this.mat4[10],this.mat4[15]]}},{key:"multiplyVec3",value:function(e,t){return(t=void 0===t?e.copy():t).x=this.row(0).dot(e),t.y=this.row(1).dot(e),t.z=this.row(2).dot(e),t}},{key:"createSubMatrix3x3",value:function(){var e=new O.default.Matrix("mat3");return e.mat3[0]=this.mat4[0],e.mat3[1]=this.mat4[1],e.mat3[2]=this.mat4[2],e.mat3[3]=this.mat4[4],e.mat3[4]=this.mat4[5],e.mat3[5]=this.mat4[6],e.mat3[6]=this.mat4[8],e.mat3[7]=this.mat4[9],e.mat3[8]=this.mat4[10],e}}])&&n(e.prototype,t),o&&n(e,o),r}(),O.default.Matrix);r.default=e},{"../core/main":283,"core-js/modules/es.array.iterator":165,"core-js/modules/es.object.to-string":190,"core-js/modules/es.typed-array.copy-within":213,"core-js/modules/es.typed-array.every":214,"core-js/modules/es.typed-array.fill":215,"core-js/modules/es.typed-array.filter":216,"core-js/modules/es.typed-array.find":218,"core-js/modules/es.typed-array.find-index":217,"core-js/modules/es.typed-array.float32-array":219,"core-js/modules/es.typed-array.for-each":221,"core-js/modules/es.typed-array.includes":222,"core-js/modules/es.typed-array.index-of":223,"core-js/modules/es.typed-array.iterator":226,"core-js/modules/es.typed-array.join":227,"core-js/modules/es.typed-array.last-index-of":228,"core-js/modules/es.typed-array.map":229,"core-js/modules/es.typed-array.reduce":231,"core-js/modules/es.typed-array.reduce-right":230,"core-js/modules/es.typed-array.reverse":232,"core-js/modules/es.typed-array.set":233,"core-js/modules/es.typed-array.slice":234,"core-js/modules/es.typed-array.some":235,"core-js/modules/es.typed-array.sort":236,"core-js/modules/es.typed-array.subarray":237,"core-js/modules/es.typed-array.to-locale-string":238,"core-js/modules/es.typed-array.to-string":239}],337:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var s=(e=e("../core/main"))&&e.__esModule?e:{default:e};function o(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}s.default.Quat=function(){function n(e,t,r,o){if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");this.w=e,this.vec=new s.default.Vector(t,r,o)}var e,t,r;return e=n,r=[{key:"fromAxisAngle",value:function(e,t,r,o){var n=Math.cos(e/2),t=new s.default.Vector(t,r,o).normalize().mult(Math.sin(e/2));return new s.default.Quat(n,t.x,t.y,t.z)}}],(t=[{key:"conjugate",value:function(){return new s.default.Quat(this.w,-this.vec.x,-this.vec.y,-this.vec.z)}},{key:"multiply",value:function(e){return new s.default.Quat(this.w*e.w-this.vec.x*e.vec.x-this.vec.y*e.vec.y-this.vec.z-e.vec.z,this.w*e.vec.x+this.vec.x*e.w+this.vec.y*e.vec.z-this.vec.z*e.vec.y,this.w*e.vec.y-this.vec.x*e.vec.z+this.vec.y*e.w+this.vec.z*e.vec.x,this.w*e.vec.z+this.vec.x*e.vec.y-this.vec.y*e.vec.x+this.vec.z*e.w)}},{key:"rotateVector",value:function(e){return new s.default.Vector.mult(e,this.w*this.w-this.vec.dot(this.vec)).add(s.default.Vector.mult(this.vec,2*e.dot(this.vec))).add(s.default.Vector.mult(this.vec,2*this.w).cross(e)).clampToZero()}},{key:"rotateBy",value:function(e){return e.multiply(this).multiply(e.conjugate()).vec.clampToZero()}}])&&o(e.prototype,t),r&&o(e,r),n}();e=s.default.Quat;r.default=e},{"../core/main":283}],338:[function(e,t,r){"use strict";e("core-js/modules/es.array.map"),e("core-js/modules/es.array.map"),Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;e=(e=e("../core/main"))&&e.__esModule?e:{default:e};function o(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}e.default.RenderBuffer=function(){function i(e,t,r,o,n,s){if(!(this instanceof i))throw new TypeError("Cannot call a class as a function");this.size=e,this.src=t,this.dst=r,this.attr=o,this._renderer=n,this.map=s}var e,t,r;return e=i,(t=[{key:"_prepareBuffer",value:function(e,t){var r,o,n,s=t.attributes,i=this._renderer.GL,a=e.model||e,s=s[this.attr];s&&(r=e[this.dst],0<(o=a[this.src]).length?((n=!r)&&(e[this.dst]=r=i.createBuffer()),i.bindBuffer(i.ARRAY_BUFFER,r),!n&&!1===a.dirtyFlags[this.src]||(n=(e=this.map)?e(o):o,this._renderer._bindBuffer(r,i.ARRAY_BUFFER,n),a.dirtyFlags[this.src]=!1),t.enableAttrib(s,this.size)):-1!==(e=s.location)&&this._renderer.registerEnabled.has(e)&&(i.disableVertexAttribArray(e),this._renderer.registerEnabled.delete(e)))}}])&&o(e.prototype,t),r&&o(e,r),i}();e=e.default.RenderBuffer;r.default=e},{"../core/main":283,"core-js/modules/es.array.map":168}],339:[function(e,t,r){"use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e){return(i="function"==typeof Symbol&&"symbol"===o(Symbol.iterator)?function(e){return o(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":o(e)})(e)}e("core-js/modules/es.symbol"),e("core-js/modules/es.symbol.description"),e("core-js/modules/es.symbol.iterator"),e("core-js/modules/es.array.concat"),e("core-js/modules/es.array.fill"),e("core-js/modules/es.array.find-index"),e("core-js/modules/es.array.from"),e("core-js/modules/es.array.iterator"),e("core-js/modules/es.array.map"),e("core-js/modules/es.array.slice"),e("core-js/modules/es.map"),e("core-js/modules/es.object.get-own-property-descriptor"),e("core-js/modules/es.object.to-string"),e("core-js/modules/es.regexp.to-string"),e("core-js/modules/es.string.iterator"),e("core-js/modules/es.weak-map"),e("core-js/modules/web.dom-collections.iterator"),e("core-js/modules/es.symbol"),e("core-js/modules/es.symbol.description"),e("core-js/modules/es.symbol.iterator"),e("core-js/modules/es.array.concat"),e("core-js/modules/es.array.fill"),e("core-js/modules/es.array.find-index"),e("core-js/modules/es.array.iterator"),e("core-js/modules/es.array.map"),e("core-js/modules/es.array.slice"),e("core-js/modules/es.map"),e("core-js/modules/es.object.to-string"),e("core-js/modules/es.string.iterator"),e("core-js/modules/web.dom-collections.iterator"),Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var l=(n=e("../core/main"))&&n.__esModule?n:{default:n},h=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==i(e)&&"function"!=typeof e)return{default:e};var t=a();if(t&&t.has(e))return t.get(e);var r,o={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in e){var s;Object.prototype.hasOwnProperty.call(e,r)&&((s=n?Object.getOwnPropertyDescriptor(e,r):null)&&(s.get||s.set)?Object.defineProperty(o,r,s):o[r]=e[r])}o.default=e,t&&t.set(e,o);return o}(e("../core/constants"));function a(){var e;return"function"!=typeof WeakMap?null:(e=new WeakMap,a=function(){return e},e)}function f(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}e("./p5.RenderBuffer"),l.default.RendererGL.prototype.beginShape=function(e){return this.immediateMode.shapeMode=void 0!==e?e:h.TESS,this.immediateMode.geometry.reset(),this.immediateMode.contourIndices=[],this};var u={vertices:1,vertexNormals:1,vertexColors:4,vertexStrokeColors:4,uvs:2},n=(l.default.RendererGL.prototype.beginContour=function(){if(this.immediateMode.shapeMode!==h.TESS)throw new Error("WebGL mode can only use contours with beginShape(TESS).");this.immediateMode.contourIndices.push(this.immediateMode.geometry.vertices.length)},l.default.RendererGL.prototype.vertex=function(e,t){if(this.immediateMode.shapeMode===h.QUADS&&this.immediateMode.geometry.vertices.length%6==3)for(var r in u){var o=u[r],r=this.immediateMode.geometry[r];r.push.apply(r,f(r.slice(r.length-3*o,r.length-2*o)).concat(f(r.slice(r.length-o,r.length))))}var n,s,i=n=s=0,a=(3===arguments.length?i=arguments[2]:4===arguments.length?(n=arguments[2],s=arguments[3]):5===arguments.length&&(i=arguments[2],n=arguments[3],s=arguments[4]),new l.default.Vector(e,t,i)),a=(this.immediateMode.geometry.vertices.push(a),this.immediateMode.geometry.vertexNormals.push(this._currentNormal),this.curFillColor||[.5,.5,.5,1]),a=(this.immediateMode.geometry.vertexColors.push(a[0],a[1],a[2],a[3]),this.curStrokeColor||[.5,.5,.5,1]);return this.immediateMode.geometry.vertexStrokeColors.push(a[0],a[1],a[2],a[3]),this.textureMode!==h.IMAGE||this.isProcessingVertices||(null!==this._tex?0<this._tex.width&&0<this._tex.height&&(n/=this._tex.width,s/=this._tex.height):void 0===this.userFillShader&&void 0===this.userStrokeShader&&void 0===this.userPointShader&&null===this._tex&&4<=arguments.length&&console.warn("You must first call texture() before using vertex() with image based u and v coordinates")),this.immediateMode.geometry.uvs.push(n,s),this.immediateMode._bezierVertex[0]=e,this.immediateMode._bezierVertex[1]=t,this.immediateMode._bezierVertex[2]=i,this.immediateMode._quadraticVertex[0]=e,this.immediateMode._quadraticVertex[1]=t,this.immediateMode._quadraticVertex[2]=i,this},l.default.RendererGL.prototype.normal=function(e,t,r){return e instanceof l.default.Vector?this._currentNormal=e:this._currentNormal=new l.default.Vector(e,t,r),this},l.default.RendererGL.prototype.endShape=function(e,t,r,o,n,s){var i,a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:1;return this.immediateMode.shapeMode===h.POINTS?this._drawPoints(this.immediateMode.geometry.vertices,this.immediateMode.buffers.point):(3===this.immediateMode.geometry.vertices.length&&this.immediateMode.shapeMode===h.TESS&&(this.immediateMode.shapeMode=h.TRIANGLES),this.isProcessingVertices=!0,this._processVertices.apply(this,arguments),i=this.isProcessingVertices=!1,this.immediateMode.shapeMode!==h.LINE_STRIP&&this.immediateMode.shapeMode!==h.LINES||(this.immediateMode.shapeMode=h.TRIANGLE_FAN,i=!0),this.immediateMode.shapeMode===h.QUADS?this.immediateMode.shapeMode=h.TRIANGLES:this.immediateMode.shapeMode===h.QUAD_STRIP&&(this.immediateMode.shapeMode=h.TRIANGLE_STRIP),this._doFill&&!i&&!this.geometryBuilder&&3<=this.immediateMode.geometry.vertices.length&&this._drawImmediateFill(a),this._doStroke&&!this.geometryBuilder&&1<=this.immediateMode.geometry.lineVertices.length&&this._drawImmediateStroke(),this.geometryBuilder&&this.geometryBuilder.addImmediate(),this.isBezier=!1,this.isQuadratic=!1,this.isCurve=!1,this.immediateMode._bezierVertex.length=0,this.immediateMode._quadraticVertex.length=0,this.immediateMode._curveVertex.length=0),this},l.default.RendererGL.prototype._processVertices=function(e){var t;0!==this.immediateMode.geometry.vertices.length&&(t=this._doStroke,e=e===h.CLOSE,t&&(this.immediateMode.geometry.edges=this._calculateEdges(this.immediateMode.shapeMode,this.immediateMode.geometry.vertices,e),this.geometryBuilder||this.immediateMode.geometry._edgesToVertices()),t=this.immediateMode.shapeMode===h.TESS,e=0<this.immediateMode.contourIndices.length,this._doFill&&(this.isBezier||this.isQuadratic||this.isCurve||t||e)&&this.immediateMode.shapeMode!==h.LINES&&this._tesselateShape())},l.default.RendererGL.prototype._calculateEdges=function(e,t,r){var o=[],n=0,s=this.immediateMode.contourIndices.slice(),i=0;switch(e){case h.TRIANGLE_STRIP:for(n=0;n<t.length-2;n++)o.push([n,n+1]),o.push([n,n+2]);o.push([n,n+1]);break;case h.TRIANGLE_FAN:for(n=1;n<t.length-1;n++)o.push([0,n]),o.push([n,n+1]);o.push([0,t.length-1]);break;case h.TRIANGLES:for(n=0;n<t.length-2;n+=3)o.push([n,n+1]),o.push([n+1,n+2]),o.push([n+2,n]);break;case h.LINES:for(n=0;n<t.length-1;n+=2)o.push([n,n+1]);break;case h.QUADS:for(n=0;n<t.length-5;n+=6)o.push([n,n+1]),o.push([n+1,n+2]),o.push([n+3,n+5]),o.push([n+4,n+5]);break;case h.QUAD_STRIP:for(n=0;n<t.length-2;n+=2)o.push([n,n+1]),o.push([n,n+2]),o.push([n+1,n+3]);o.push([n,n+1]);break;default:for(n=0;n<t.length;n++)n+1<t.length&&n+1!==s[0]?o.push([n,n+1]):((r||i)&&o.push([n,i]),0<s.length&&(i=s.shift()))}return e!==h.TESS&&r&&o.push([t.length-1,0]),o},l.default.RendererGL.prototype._tesselateShape=function(){for(var u=this,e=(this.immediateMode.shapeMode=h.TRIANGLES,[[]]),t=0;t<this.immediateMode.geometry.vertices.length;t++)0<this.immediateMode.contourIndices.length&&this.immediateMode.contourIndices[0]===t&&(this.immediateMode.contourIndices.shift(),e.push([])),e[e.length-1].push(this.immediateMode.geometry.vertices[t].x,this.immediateMode.geometry.vertices[t].y,this.immediateMode.geometry.vertices[t].z,this.immediateMode.geometry.uvs[2*t],this.immediateMode.geometry.uvs[2*t+1],this.immediateMode.geometry.vertexColors[4*t],this.immediateMode.geometry.vertexColors[4*t+1],this.immediateMode.geometry.vertexColors[4*t+2],this.immediateMode.geometry.vertexColors[4*t+3],this.immediateMode.geometry.vertexNormals[t].x,this.immediateMode.geometry.vertexNormals[t].y,this.immediateMode.geometry.vertexNormals[t].z);for(var c,r=this._triangulate(e),d=this.immediateMode.geometry.vertices,o=(this.immediateMode.geometry.vertices=[],this.immediateMode.geometry.vertexNormals=[],this.immediateMode.geometry.uvs=[],[]),n=0,s=r.length;n<s;n+=l.default.RendererGL.prototype.tessyVertexSize)o.push.apply(o,f(r.slice(n+5,n+9))),this.normal.apply(this,f(r.slice(n+9,n+12))),this.vertex.apply(this,f(r.slice(n,n+5)));this.geometryBuilder&&(c=new Map,this.immediateMode.geometry.edges=this.immediateMode.geometry.edges.map(function(e){return e.map(function(e){if(!c.has(e)){var t=d[e],r=u.immediateMode.geometry.vertices.findIndex(function(e){return t.x===e.x&&t.y===e.y&&t.z===e.z});if(-1===r){for(var o=1/0,n=0,s=0;s<u.immediateMode.geometry.vertices.length;s++){var i=u.immediateMode.geometry.vertices[s],a=t.x-i.x,l=t.y-i.y,i=t.z-i.z,a=a*a+l*l+i*i;a<o&&(o=a,n=s)}r=n}c.set(e,r)}return c.get(e)})})),this.immediateMode.geometry.vertexColors=o},l.default.RendererGL.prototype._drawImmediateFill=function(){var e,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,r=this.GL,o=(this._useVertexColor=0<this.immediateMode.geometry.vertexColors.length,e=this._getImmediateFillShader(),this._setFillUniforms(e),!0),n=!1,s=void 0;try{for(var i,a=this.immediateMode.buffers.fill[Symbol.iterator]();!(o=(i=a.next()).done);o=!0)i.value._prepareBuffer(this.immediateMode.geometry,e)}catch(e){n=!0,s=e}finally{try{o||null==a.return||a.return()}finally{if(n)throw s}}if(e.disableRemainingAttributes(),this._applyColorBlend(this.curFillColor,this.immediateMode.geometry.hasFillTransparency()),1===t)r.drawArrays(this.immediateMode.shapeMode,0,this.immediateMode.geometry.vertices.length);else try{r.drawArraysInstanced(this.immediateMode.shapeMode,0,this.immediateMode.geometry.vertices.length,t)}catch(e){console.log("🌸 p5.js says: Instancing is only supported in WebGL2 mode")}e.unbindShader()},l.default.RendererGL.prototype._drawImmediateStroke=function(){var e=this.GL,t=(this._useLineColor=0<this.immediateMode.geometry.vertexStrokeColors.length,this._getImmediateStrokeShader()),r=(this._setStrokeUniforms(t),!0),o=!1,n=void 0;try{for(var s,i=this.immediateMode.buffers.stroke[Symbol.iterator]();!(r=(s=i.next()).done);r=!0)s.value._prepareBuffer(this.immediateMode.geometry,t)}catch(e){o=!0,n=e}finally{try{r||null==i.return||i.return()}finally{if(o)throw n}}t.disableRemainingAttributes(),this._applyColorBlend(this.curStrokeColor,this.immediateMode.geometry.hasFillTransparency()),e.drawArrays(e.TRIANGLES,0,this.immediateMode.geometry.lineVertices.length/3),t.unbindShader()},l.default.RendererGL);r.default=n},{"../core/constants":272,"../core/main":283,"./p5.RenderBuffer":338,"core-js/modules/es.array.concat":153,"core-js/modules/es.array.fill":156,"core-js/modules/es.array.find-index":158,"core-js/modules/es.array.from":162,"core-js/modules/es.array.iterator":165,"core-js/modules/es.array.map":168,"core-js/modules/es.array.slice":169,"core-js/modules/es.map":175,"core-js/modules/es.object.get-own-property-descriptor":186,"core-js/modules/es.object.to-string":190,"core-js/modules/es.regexp.to-string":196,"core-js/modules/es.string.iterator":200,"core-js/modules/es.symbol":212,"core-js/modules/es.symbol.description":210,"core-js/modules/es.symbol.iterator":211,"core-js/modules/es.weak-map":244,"core-js/modules/web.dom-collections.iterator":246}],340:[function(e,t,r){"use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e){return(i="function"==typeof Symbol&&"symbol"===o(Symbol.iterator)?function(e){return o(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":o(e)})(e)}e("core-js/modules/es.symbol"),e("core-js/modules/es.symbol.description"),e("core-js/modules/es.symbol.iterator"),e("core-js/modules/es.array.fill"),e("core-js/modules/es.array.iterator"),e("core-js/modules/es.array.some"),e("core-js/modules/es.object.get-own-property-descriptor"),e("core-js/modules/es.object.keys"),e("core-js/modules/es.object.to-string"),e("core-js/modules/es.string.iterator"),e("core-js/modules/es.typed-array.float32-array"),e("core-js/modules/es.typed-array.uint16-array"),e("core-js/modules/es.typed-array.uint32-array"),e("core-js/modules/es.typed-array.copy-within"),e("core-js/modules/es.typed-array.every"),e("core-js/modules/es.typed-array.fill"),e("core-js/modules/es.typed-array.filter"),e("core-js/modules/es.typed-array.find"),e("core-js/modules/es.typed-array.find-index"),e("core-js/modules/es.typed-array.for-each"),e("core-js/modules/es.typed-array.includes"),e("core-js/modules/es.typed-array.index-of"),e("core-js/modules/es.typed-array.iterator"),e("core-js/modules/es.typed-array.join"),e("core-js/modules/es.typed-array.last-index-of"),e("core-js/modules/es.typed-array.map"),e("core-js/modules/es.typed-array.reduce"),e("core-js/modules/es.typed-array.reduce-right"),e("core-js/modules/es.typed-array.reverse"),e("core-js/modules/es.typed-array.set"),e("core-js/modules/es.typed-array.slice"),e("core-js/modules/es.typed-array.some"),e("core-js/modules/es.typed-array.sort"),e("core-js/modules/es.typed-array.subarray"),e("core-js/modules/es.typed-array.to-locale-string"),e("core-js/modules/es.typed-array.to-string"),e("core-js/modules/es.weak-map"),e("core-js/modules/web.dom-collections.iterator"),e("core-js/modules/es.symbol"),e("core-js/modules/es.symbol.description"),e("core-js/modules/es.symbol.iterator"),e("core-js/modules/es.array.fill"),e("core-js/modules/es.array.iterator"),e("core-js/modules/es.array.some"),e("core-js/modules/es.object.keys"),e("core-js/modules/es.object.to-string"),e("core-js/modules/es.string.iterator"),e("core-js/modules/es.typed-array.float32-array"),e("core-js/modules/es.typed-array.uint16-array"),e("core-js/modules/es.typed-array.uint32-array"),e("core-js/modules/es.typed-array.copy-within"),e("core-js/modules/es.typed-array.every"),e("core-js/modules/es.typed-array.fill"),e("core-js/modules/es.typed-array.filter"),e("core-js/modules/es.typed-array.find"),e("core-js/modules/es.typed-array.find-index"),e("core-js/modules/es.typed-array.for-each"),e("core-js/modules/es.typed-array.includes"),e("core-js/modules/es.typed-array.index-of"),e("core-js/modules/es.typed-array.iterator"),e("core-js/modules/es.typed-array.join"),e("core-js/modules/es.typed-array.last-index-of"),e("core-js/modules/es.typed-array.map"),e("core-js/modules/es.typed-array.reduce"),e("core-js/modules/es.typed-array.reduce-right"),e("core-js/modules/es.typed-array.reverse"),e("core-js/modules/es.typed-array.set"),e("core-js/modules/es.typed-array.slice"),e("core-js/modules/es.typed-array.some"),e("core-js/modules/es.typed-array.sort"),e("core-js/modules/es.typed-array.subarray"),e("core-js/modules/es.typed-array.to-locale-string"),e("core-js/modules/es.typed-array.to-string"),e("core-js/modules/web.dom-collections.iterator"),Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=(s=e("../core/main"))&&s.__esModule?s:{default:s},n=(e("./p5.RendererGL"),e("./p5.RenderBuffer"),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==i(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var r,o={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in e){var s;Object.prototype.hasOwnProperty.call(e,r)&&((s=n?Object.getOwnPropertyDescriptor(e,r):null)&&(s.get||s.set)?Object.defineProperty(o,r,s):o[r]=e[r])}o.default=e,t&&t.set(e,o);return o}(e("../core/constants")));function l(){var e;return"function"!=typeof WeakMap?null:(e=new WeakMap,l=function(){return e},e)}a.default.RendererGL.prototype.freeGeometry=function(e){e.gid?this._freeBuffers(e.gid):console.warn("The model you passed to freeGeometry does not have an id!")},a.default.RendererGL.prototype._initBufferDefaults=function(e){var t;return this._freeBuffers(e),1e3<Object.keys(this.retainedMode.geometry).length&&(t=Object.keys(this.retainedMode.geometry)[0],this._freeBuffers(t)),this.retainedMode.geometry[e]={}},a.default.RendererGL.prototype._freeBuffers=function(e){var a,l=this.retainedMode.geometry[e];function t(e){var t=!0,r=!1,o=void 0;try{for(var n,s=e[Symbol.iterator]();!(t=(n=s.next()).done);t=!0){var i=n.value;l[i.dst]&&(a.deleteBuffer(l[i.dst]),l[i.dst]=null)}}catch(e){r=!0,o=e}finally{try{t||null==s.