15 lines
413 KiB
JavaScript
15 lines
413 KiB
JavaScript
|
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.clay={})}(this,function(t){"use strict";function e(){}function r(t,e){return t[e]}function n(t,e,r){t[e]=r}function i(t,e,r){return(e-t)*r+t}function a(t,e,r,n,a){var o=t.length;if(1==a)for(var s=0;s<o;s++)n[s]=i(t[s],e[s],r);else for(var u=t[0].length,s=0;s<o;s++)for(var l=0;l<u;l++)n[s][l]=i(t[s][l],e[s][l],r)}function o(t){return void 0!==t&&("string"!=typeof t&&"number"==typeof t.length)}function s(t){if(o(t)){var e=t.length;if(o(t[0])){for(var r=[],n=0;n<e;n++)r.push(ge.call(t[n]));return r}return ge.call(t)}return t}function u(t,e,r,n,i,a,o,s,u){var h=t.length;if(1==u)for(var c=0;c<h;c++)s[c]=l(t[c],e[c],r[c],n[c],i,a,o);else for(var f=t[0].length,c=0;c<h;c++)for(var d=0;d<f;d++)s[c][d]=l(t[c][d],e[c][d],r[c][d],n[c][d],i,a,o)}function l(t,e,r,n,i,a,o){var s=.5*(r-t),u=.5*(n-e);return(2*(e-r)+s+u)*o+(-3*(e-r)-2*s-u)*a+s*i+e}function h(t,e,r){var n=t.length,i=e.length;if(n!==i){if(n>i)t.length=i;else for(var a=n;a<i;a++)t.push(1===r?e[a]:ge.call(e[a]))}for(var o=t[0]&&t[0].length,a=0;a<t.length;a++)if(1===r)isNaN(t[a])&&(t[a]=e[a]);else for(var s=0;s<o;s++)isNaN(t[a][s])&&(t[a][s]=e[a][s])}function c(t,e,r){if(t===e)return!0;var n=t.length;if(n!==e.length)return!1;if(1===r){for(var i=0;i<n;i++)if(t[i]!==e[i])return!1}else for(var a=t[0].length,i=0;i<n;i++)for(var o=0;o<a;o++)if(t[i][o]!==e[i][o])return!1;return!0}function f(t,e,r,n,s,f,d){var p=t._getter,m=t._setter,_="spline"===e,g=n.length;if(g){var v=n[0].value,y=o(v),T=y&&o(v[0])?2:1;n.sort(function(t,e){return t.time-e.time});for(var x=[],E=[],A=[],b=n[0].value,S=!0,M=0;M<g;M++){x.push(n[M].time/d);var w=n[M].value;y&&c(w,b,T)||!y&&w===b||(S=!1),b=w,E.push(w),A.push(n[M].easing)}if(!S){for(var C=E[g-1],M=0;M<g-1;M++)y?h(E[M],C,T):isNaN(E[M])&&!isNaN(C)&&(E[M]=C);y&&h(p(t._target,s),C,T);var R,M,L,N,P,I,O,D=0,B=0,U=function(t,e){if(e<B){for(R=Math.min(D+1,g-1),M=R;M>=0&&!(x[M]<=e);M--);M=Math.min(M,g-2)}else{for(M=D;M<g&&!(x[M]>e);M++);M=Math.min(M-1,g-2)}D=M,B=e;var r=x[M+1]-x[M];0!==r&&(L=(e-x[M])/r,L=Math.max(Math.min(1,L),0),L=A[M+1](L),_?(P=E[M],N=E[0===M?M:M-1],I=E[M>g-2?g-1:M+1],O=E[M>g-3?g-1:M+2],f?m(t,s,f(p(t,s),N,P,I,O,L)):y?u(N,P,I,O,L,L*L,L*L*L,p(t,s),T):m(t,s,l(N,P,I,O,L,L*L,L*L*L))):f?m(t,s,f(p(t,s),E[M],E[M+1],L)):y?a(E[M],E[M+1],L,p(t,s),T):m(t,s,i(E[M],E[M+1],L)))},F=new _e({target:t._target,life:d,loop:t._loop,delay:t._delay,onframe:U,onfinish:r});return e&&"spline"!==e&&F.setEasing(e),F}}}function d(t,e,i,a,o){this._tracks={},this._target=t,this._loop=e||!1,this._getter=i||r,this._setter=a||n,this._interpolater=o||null,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[],this._maxTime=0,this._lastKFTime=0}function p(t){return t}function m(t){var e,r,n,i,a,o,s=Number.POSITIVE_INFINITY,u=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;for(e=t.length;e--;)t[e][0]<s&&(s=t[e][0]),t[e][0]>l&&(l=t[e][0]),t[e][1]<u&&(u=t[e][1]),t[e][1]>h&&(h=t[e][1]);return r=l-s,n=h-u,i=Math.max(r,n),a=s+.5*r,o=u+.5*n,[[a-20*i,o-i],[a,o+20*i],[a+20*i,o-i]]}function _(t,e,r,n){var i,a,o,s,u,l,h,c,f,d,p=t[e][0],m=t[e][1],_=t[r][0],g=t[r][1],v=t[n][0],y=t[n][1],T=Math.abs(m-g),x=Math.abs(g-y);if(T<Te&&x<Te)throw new Error("Eek! Coincident points!");return T<Te?(s=-(v-_)/(y-g),l=(_+v)/2,c=(g+y)/2,i=(_+p)/2,a=s*(i-l)+c):x<Te?(o=-(_-p)/(g-m),u=(p+_)/2,h=(m+g)/2,i=(v+_)/2,a=o*(i-u)+h):(o=-(_-p)/(g-m),s=-(v-_)/(y-g),u=(p+_)/2,l=(_+v)/2,h=(m+g)/2,c=(g+y)/2,i=(o*u-s*l+c-h)/(o-s),a=T>x?o*(i-u)+h:s*(i-l)+c),f=_-i,d=g-a,{i:e,j:r,k:n,x:i,y:a,r:f*f+d*d}}function g(t){var e,r,n,i,a,o;for(r=t.length;r;)for(i=t[--r],n=t[--r],e=r;e;)if(o=t[--e],a=t[--e],n===a&&i===o||n===o&&i===a){t.splice(r,2),t.splice(e,2);break}}function v(t,e,r,n,i,a){var o=e[i],s=e[i+1],u=e[i+2];return t[0]=o+n*(r[a]-o),t[1]=s+n*(r[a+1]-s),t[2]=u+n*(r[a+2]-u),t}function y(t,e,r,n,i,a){var o,s,u,l,h,c=e[0+i],f=e[1+i],d=e[2+i],p=e[3+i],m=r[0+a],_=r[1+a],g=r[2+a],v=r[3+a];return s=c*m+f*_+d*g+p*v,s<0&&(s=-s,m=-m,_=-_,g=-g,v=-v)
|
||
|
|
;var p=(this.position-h.position)/(c.position-h.position),m=f.output instanceof _e?f.output:f,_=d.output instanceof _e?d.output:d;this.output.blend1D(m,_,p)}},ye.prototype.clone=function(t){var e=_e.prototype.clone.call(this);e.output=this.output.clone();for(var r=0;r<this.inputs.length;r++){var n=t?this.inputs[r].clip.clone(!0):this.inputs[r].clip;e.addInput(this.inputs[r].position,n,this.inputs[r].offset)}return e},ye.prototype._findKey=function(t){var e=-1,r=this.inputs,n=r.length;if(this._cachePosition<t)for(var i=this._cacheKey;i<n-1;i++)t>=r[i].position&&t<r[i+1].position&&(e=i);else for(var a=Math.min(n-2,this._cacheKey),i=a;i>=0;i--)t>=r[i].position&&t<r[i+1].position&&(e=i);return e>=0&&(this._cacheKey=e,this._cachePosition=t),e};var Te=1/1048576,xe={triangulate:function(t,e){var r,n,i,a,o,s,u,l,h,c,f,d,p=t.length;if(p<3)return[];if(t=t.slice(0),e)for(r=p;r--;)t[r]=t[r][e];for(i=new Array(p),r=p;r--;)i[r]=r;for(i.sort(function(e,r){var n=t[r][0]-t[e][0];return 0!==n?n:e-r}),a=m(t),t.push(a[0],a[1],a[2]),o=[_(t,p+0,p+1,p+2)],s=[],u=[],r=i.length;r--;u.length=0){for(d=i[r],n=o.length;n--;)l=t[d][0]-o[n].x,l>0&&l*l>o[n].r?(s.push(o[n]),o.splice(n,1)):(h=t[d][1]-o[n].y,l*l+h*h-o[n].r>Te||(u.push(o[n].i,o[n].j,o[n].j,o[n].k,o[n].k,o[n].i),o.splice(n,1)));for(g(u),n=u.length;n;)f=u[--n],c=u[--n],o.push(_(t,c,f,d))}for(r=o.length;r--;)s.push(o[r]);for(o.length=0,r=s.length;r--;)s[r].i<p&&s[r].j<p&&s[r].k<p&&o.push(s[r].i,s[r].j,s[r].k);return o},contains:function(t,e){if(e[0]<t[0][0]&&e[0]<t[1][0]&&e[0]<t[2][0]||e[0]>t[0][0]&&e[0]>t[1][0]&&e[0]>t[2][0]||e[1]<t[0][1]&&e[1]<t[1][1]&&e[1]<t[2][1]||e[1]>t[0][1]&&e[1]>t[1][1]&&e[1]>t[2][1])return null;var r=t[1][0]-t[0][0],n=t[2][0]-t[0][0],i=t[1][1]-t[0][1],a=t[2][1]-t[0][1],o=r*a-n*i;if(0===o)return null;var s=(a*(e[0]-t[0][0])-n*(e[1]-t[0][1]))/o,u=(r*(e[1]-t[0][1])-i*(e[0]-t[0][0]))/o;return s<0||u<0||s+u>1?null:[s,u]}},Ee=Array,Ae=Math.random,be={};be.create=function(){var t=new Ee(2);return t[0]=0,t[1]=0,t},be.clone=function(t){var e=new Ee(2);return e[0]=t[0],e[1]=t[1],e},be.fromValues=function(t,e){var r=new Ee(2);return r[0]=t,r[1]=e,r},be.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},be.set=function(t,e,r){return t[0]=e,t[1]=r,t},be.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},be.subtract=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t},be.sub=be.subtract,be.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t},be.mul=be.multiply,be.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t},be.div=be.divide,be.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},be.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},be.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},be.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t},be.distance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1];return Math.sqrt(r*r+n*n)},be.dist=be.distance,be.squaredDistance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n},be.sqrDist=be.squaredDistance,be.length=function(t){var e=t[0],r=t[1];return Math.sqrt(e*e+r*r)},be.len=be.length,be.squaredLength=function(t){var e=t[0],r=t[1];return e*e+r*r},be.sqrLen=be.squaredLength,be.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},be.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},be.normalize=function(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i),t},be.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},be.cross=function(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t},be.lerp=function(t,e,r,n){var i=e[0],a=e[1];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t},be.random=function(t,e){e=e||1;var r=2*GLMAT_RANDOM()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},be.transformMat2=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t},be.transformMat2d=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i+r[4],t[1]=r[1]*n+r[3]*i+r[5],t},be.transformMat3=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[3]*i+r[6],t[1]=r[1]*n+r[
|
||
|
|
;if(!(t.getContext("webgl")||t.getContext("experimental-webgl")))throw new Error}catch(t){He=!1}return He},Ve.Int8Array="undefined"==typeof Int8Array?Array:Int8Array,Ve.Uint8Array="undefined"==typeof Uint8Array?Array:Uint8Array,Ve.Uint16Array="undefined"==typeof Uint16Array?Array:Uint16Array,Ve.Uint32Array="undefined"==typeof Uint32Array?Array:Uint32Array,Ve.Int16Array="undefined"==typeof Int16Array?Array:Int16Array,Ve.Float32Array="undefined"==typeof Float32Array?Array:Float32Array,Ve.Float64Array="undefined"==typeof Float64Array?Array:Float64Array;var We={};"undefined"!=typeof window?We=window:"undefined"!=typeof global&&(We=global),Ve.requestAnimationFrame=We.requestAnimationFrame||We.msRequestAnimationFrame||We.mozRequestAnimationFrame||We.webkitRequestAnimationFrame||function(t){setTimeout(t,16)},Ve.createCanvas=function(){return document.createElement("canvas")},Ve.createImage=function(){return new We.Image},Ve.request={get:Ge.get},Ve.addEventListener=function(t,e,r,n){t.addEventListener(e,r,n)},Ve.removeEventListener=function(t,e,r){t.removeEventListener(e,r)};var ze=ke.extend(function(){return{stage:null,_clips:[],_running:!1,_time:0,_paused:!1,_pausedTime:0}},{addAnimator:function(t){t.animation=this;for(var e=t.getClips(),r=0;r<e.length;r++)this.addClip(e[r])},addClip:function(t){this._clips.indexOf(t)<0&&this._clips.push(t)},removeClip:function(t){var e=this._clips.indexOf(t);e>=0&&this._clips.splice(e,1)},removeAnimator:function(t){for(var e=t.getClips(),r=0;r<e.length;r++)this.removeClip(e[r]);t.animation=null},_update:function(){for(var t=Date.now()-this._pausedTime,e=t-this._time,r=this._clips,n=r.length,i=[],a=[],o=0;o<n;o++){var s=r[o],u=s.step(t,e,!1);u&&(i.push(u),a.push(s))}for(var o=0;o<n;)r[o]._needsRemove?(r[o]=r[n-1],r.pop(),n--):o++;n=i.length;for(var o=0;o<n;o++)a[o].fire(i[o]);this._time=t,this.trigger("frame",e),this.stage&&this.stage.render&&this.stage.render()},start:function(){function t(){e._running&&(r(t),e._paused||e._update())}var e=this;this._running=!0,this._time=Date.now(),this._pausedTime=0;var r=Ve.requestAnimationFrame;r(t)},stop:function(){this._running=!1},pause:function(){this._paused||(this._pauseStart=Date.now(),this._paused=!0)},resume:function(){this._paused&&(this._pausedTime+=Date.now()-this._pauseStart,this._paused=!1)},removeClipsAll:function(){this._clips=[]},animate:function(t,e){e=e||{};var r=new d(t,e.loop,e.getter,e.setter,e.interpolater);return r.animation=this,r}}),Xe=function(t){t=t||{},_e.call(this,t),this.tracks=t.tracks||[],this.calcLifeFromTracks()};Xe.prototype=Object.create(_e.prototype),Xe.prototype.constructor=Xe,Xe.prototype.step=function(t,e,r){var n=_e.prototype.step.call(this,t,e,!0);if("finish"!==n){var t=this.getElapsedTime();this._range&&(t=this._range[0]+t),this.setTime(t)}return r||"paused"===n||this.fire("frame"),n},Xe.prototype.setRange=function(t){this.calcLifeFromTracks(),this._range=t,t&&(t[1]=Math.min(t[1],this.life),t[0]=Math.min(t[0],this.life),this.life=t[1]-t[0])},Xe.prototype.setTime=function(t){for(var e=0;e<this.tracks.length;e++)this.tracks[e].setTime(t)},Xe.prototype.calcLifeFromTracks=function(){this.life=0;for(var t=0;t<this.tracks.length;t++)this.life=Math.max(this.life,this.tracks[t].getMaxTime())},Xe.prototype.addTrack=function(t){this.tracks.push(t),this.calcLifeFromTracks()},Xe.prototype.removeTarck=function(t){var e=this.tracks.indexOf(t);e>=0&&this.tracks.splice(e,1)},Xe.prototype.getSubClip=function(t,e,r){for(var n=new Xe({name:this.name}),i=0;i<this.tracks.length;i++){var a=this.tracks[i].getSubTrack(t,e);n.addTrack(a)}return void 0!==r&&n.setLoop(r),n.life=e-t,n},Xe.prototype.blend1D=function(t,e,r){for(var n=0;n<this.tracks.length;n++){var i=t.tracks[n],a=e.tracks[n];this.tracks[n].blend1D(i,a,r)}},Xe.prototype.additiveBlend=function(t,e){for(var r=0;r<this.tracks.length;r++){var n=t.tracks[r],i=e.tracks[r];this.tracks[r].additiveBlend(n,i)}},Xe.prototype.subtractiveBlend=function(t,e){for(var r=0;r<this.tracks.length;r++){var n=t.tracks[r],i=e.tracks[r];this.tracks[r].subtractiveBlend(n,i)}},Xe.prototype.blend2D=fu
|
||
|
|
""}var e=this,r="vertex";this._vertexCode=this._vertexCode.replace(hr,t),r="fragment",this._fragmentCode=this._fragmentCode.replace(hr,t)},clone:function(){var t=vr[this._shaderID];return new Q(t.vertex,t.fragment)}},Object.defineProperty&&(Object.defineProperty(Q.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(Q.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(Q.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(Q.prototype,"uniforms",{get:function(){return this._uniformList}}));var yr=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;Q.parseImport=function(t){return t=t.replace(yr,function(t,e,r){var t=Q.source(r);return t?Q.parseImport(t):(console.error('Shader chunk "'+r+'" not existed in library'),"")})};var Tr=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;Q.import=function(t){t.replace(Tr,function(t,e,r,n){var n=n.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"");if(n){for(var i,a=r.split("."),o=Q.codes,s=0;s<a.length-1;)i=a[s++],o[i]||(o[i]={}),o=o[i];i=a[s],o[i]=n}return n})},Q.codes={},Q.source=function(t){for(var e=t.split("."),r=Q.codes,n=0;r&&n<e.length;){r=r[e[n++]]}return"string"!=typeof r?(console.error('Shader "'+t+'" not existed in library'),""):r};var xr="@export clay.prez.vertex\nuniform mat4 WVP : WORLDVIEWPROJECTION;\nattribute vec3 pos : POSITION;\nattribute vec2 uv : TEXCOORD_0;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec4 P = vec4(pos, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = WVP * P;\n v_Texcoord = uv * uvRepeat + uvOffset;\n}\n@end\n@export clay.prez.fragment\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end",Er={};Er.create=function(){var t=new Ee(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},Er.clone=function(t){var e=new Ee(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},Er.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},Er.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},Er.transpose=function(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],a=e[6],o=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=a,t[11]=e[14],t[12]=i,t[13]=o,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t},Er.invert=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],u=e[6],l=e[7],h=e[8],c=e[9],f=e[10],d=e[11],p=e[12],m=e[13],_=e[14],g=e[15],v=r*s-n*o,y=r*u-i*o,T=r*l-a*o,x=n*u-i*s,E=n*l-a*s,A=i*l-a*u,b=h*m-c*p,S=h*_-f*p,M=h*g-d*p,w=c*_-f*m,C=c*g-d*m,R=f*g-d*_,L=v*R-y*C+T*w+x*M-E*S+A*b;return L?(L=1/L,t[0]=(s*R-u*C+l*w)*L,t[1]=(i*C-n*R-a*w)*L,t[2]=(m*A-_*E+g*x)*L,t[3]=(f*E-c*A-d*x)*L,t[4]=(u*M-o*R-l*S)*L,t[5]=(r*R-i*M+a*S)*L,t[6]=(_*T-p*A-g*y)*L,t[7]=(h*A-f*T+d*y)*L,t[8]=(o*C-s*M+l*b)*L,t[9]=(n*M-r*C-a*b)*L,t[10]=(p*E-m*T+g*v)*L,t[11]=(c*T-h*E-d*v)*L,t[12]=(s*S-o*w-u*b)*L,t[13]=(r*w-n*S+i*b)*L,t[14]=(m*y-p*x-_*v)*L,t[15]=(h*x-c*y+f*v)*L,t):null},Er.adjoint=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],u=e[6],l=e[7],h=e[8],c=e[9],f=e[10],d=e[11],p=e[12],m=
|
||
|
|
d[2]=Nr(s,u)):(d[1]=Nr(-h,i),d[2]=0);break;case"ZXY":d[0]=Pr(ot(c,-1,1)),Ir(c)<.99999?(d[1]=Nr(-h,f),d[2]=Nr(-a,u)):(d[1]=0,d[2]=Nr(s,i));break;case"ZYX":d[1]=Pr(-ot(h,-1,1)),Ir(h)<.99999?(d[0]=Nr(c,f),d[2]=Nr(s,i)):(d[0]=0,d[2]=Nr(-a,u));break;case"YZX":d[2]=Pr(ot(s,-1,1)),Ir(s)<.99999?(d[0]=Nr(-l,u),d[1]=Nr(-h,i)):(d[0]=0,d[1]=Nr(o,f));break;case"XZY":d[2]=Pr(-ot(a,-1,1)),Ir(a)<.99999?(d[0]=Nr(c,u),d[1]=Nr(o,i)):(d[0]=Nr(-l,f),d[1]=0);break;default:console.warn("Unkown order: "+r)}return t._dirty=!0,t},Object.defineProperties(Cr,{POSITIVE_X:{get:function(){return new Cr(1,0,0)}},NEGATIVE_X:{get:function(){return new Cr(-1,0,0)}},POSITIVE_Y:{get:function(){return new Cr(0,1,0)}},NEGATIVE_Y:{get:function(){return new Cr(0,-1,0)}},POSITIVE_Z:{get:function(){return new Cr(0,0,1)}},NEGATIVE_Z:{get:function(){return new Cr(0,0,-1)}},UP:{get:function(){return new Cr(0,1,0)}},ZERO:{get:function(){return new Cr}}});var Or=function(t,e,r,n){t=t||0,e=e||0,r=r||0,n=void 0===n?1:n,this.array=Ne.fromValues(t,e,r,n),this._dirty=!0};Or.prototype={constructor:Or,add:function(t){return Ne.add(this.array,this.array,t.array),this._dirty=!0,this},calculateW:function(){return Ne.calculateW(this.array,this.array),this._dirty=!0,this},set:function(t,e,r,n){return this.array[0]=t,this.array[1]=e,this.array[2]=r,this.array[3]=n,this._dirty=!0,this},setArray:function(t){return this.array[0]=t[0],this.array[1]=t[1],this.array[2]=t[2],this.array[3]=t[3],this._dirty=!0,this},clone:function(){return new Or(this.x,this.y,this.z,this.w)},conjugate:function(){return Ne.conjugate(this.array,this.array),this._dirty=!0,this},copy:function(t){return Ne.copy(this.array,t.array),this._dirty=!0,this},dot:function(t){return Ne.dot(this.array,t.array)},fromMat3:function(t){return Ne.fromMat3(this.array,t.array),this._dirty=!0,this},fromMat4:function(){var t=Le.create();return function(e){return Le.fromMat4(t,e.array),Le.transpose(t,t),Ne.fromMat3(this.array,t),this._dirty=!0,this}}(),identity:function(){return Ne.identity(this.array),this._dirty=!0,this},invert:function(){return Ne.invert(this.array,this.array),this._dirty=!0,this},len:function(){return Ne.len(this.array)},length:function(){return Ne.length(this.array)},lerp:function(t,e,r){return Ne.lerp(this.array,t.array,e.array,r),this._dirty=!0,this},mul:function(t){return Ne.mul(this.array,this.array,t.array),this._dirty=!0,this},mulLeft:function(t){return Ne.multiply(this.array,t.array,this.array),this._dirty=!0,this},multiply:function(t){return Ne.multiply(this.array,this.array,t.array),this._dirty=!0,this},multiplyLeft:function(t){return Ne.multiply(this.array,t.array,this.array),this._dirty=!0,this},normalize:function(){return Ne.normalize(this.array,this.array),this._dirty=!0,this},rotateX:function(t){return Ne.rotateX(this.array,this.array,t),this._dirty=!0,this},rotateY:function(t){return Ne.rotateY(this.array,this.array,t),this._dirty=!0,this},rotateZ:function(t){return Ne.rotateZ(this.array,this.array,t),this._dirty=!0,this},rotationTo:function(t,e){return Ne.rotationTo(this.array,t.array,e.array),this._dirty=!0,this},setAxes:function(t,e,r){return Ne.setAxes(this.array,t.array,e.array,r.array),this._dirty=!0,this},setAxisAngle:function(t,e){return Ne.setAxisAngle(this.array,t.array,e),this._dirty=!0,this},slerp:function(t,e,r){return Ne.slerp(this.array,t.array,e.array,r),this._dirty=!0,this},sqrLen:function(){return Ne.sqrLen(this.array)},squaredLength:function(){return Ne.squaredLength(this.array)},fromEuler:function(t,e){return Or.fromEuler(this,t,e)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var Dr=Object.defineProperty;if(Dr){var Br=Or.prototype;Dr(Br,"x",{get:function(){return this.array[0]},set:function(t){this.array[0]=t,this._dirty=!0}}),Dr(Br,"y",{get:function(){return this.array[1]},set:function(t){this.array[1]=t,this._dirty=!0}}),Dr(Br,"z",{get:function(){return this.array[2]},set:function(t){this.array[2]=t,this._dirty=!0}}),Dr(Br,"w",{get:function(){return this.array[3]},set:func
|
||
|
|
var r=t.__uid__,n=this._renderLists.get(r);n||(n=new ut,this._renderLists.put(r,n)),n.startCount(),e&&(this.viewBoundingBoxLastFrame.min.set(1/0,1/0,1/0),this.viewBoundingBoxLastFrame.max.set(-1/0,-1/0,-1/0));var i=this.material&&this.material.transparent||!1;return this._doUpdateRenderList(this,t,i,n,e),n.endCount(),n},getRenderList:function(t){return this._renderLists.get(t.__uid__)},_doUpdateRenderList:function(t,e,r,n,i){if(!t.invisible)for(var a=0;a<t._children.length;a++){var o=t._children[a];if(o.isRenderable()){var s=o.isSkinnedMesh()?nn:o.worldTransform.array,u=o.geometry;Er.multiplyAffine(an,e.viewMatrix.array,s),(i&&!u.boundingBox||!this.isFrustumCulled(o,e,an))&&n.add(o,o.material.transparent||r)}o._children.length>0&&this._doUpdateRenderList(o,e,r,n,i)}},isFrustumCulled:function(){var t=new Vr,e=new Ur;return function(r,n,i){var a=r.boundingBox;if(a||(a=r.skeleton&&r.skeleton.boundingBox?r.skeleton.boundingBox:r.geometry.boundingBox),!a)return!1;if(e.array=i,t.transformFrom(a,e),r.castShadow&&this.viewBoundingBoxLastFrame.union(t),r.frustumCulling){if(!t.intersectBoundingBox(n.frustum.boundingBox))return!0;e.array=n.projectionMatrix.array,t.max.array[2]>0&&t.min.array[2]<0&&(t.max.array[2]=-1e-20),t.applyProjection(e);var o=t.min.array,s=t.max.array;if(s[0]<-1||o[0]>1||s[1]<-1||o[1]>1||s[2]<-1||o[2]>1)return!0}return!1}}(),_updateLightUniforms:function(){var t=this.lights;t.sort(lt);var e=this._lightUniforms;for(var r in e)for(var n in e[r])e[r][n].value.length=0;for(var i=0;i<t.length;i++){var a=t[i];if(!a.invisible){var r=a.group;for(var n in a.uniformTemplates){var o=a.uniformTemplates[n],s=o.value(a);if(null!=s){e[r]||(e[r]={}),e[r][n]||(e[r][n]={type:"",value:[]});var u=e[r][n];switch(u.type=o.type+"v",o.type){case"1i":case"1f":case"t":u.value.push(s);break;case"2f":case"3f":case"4f":for(var l=0;l<s.length;l++)u.value.push(s[l]);break;default:console.error("Unkown light uniform type "+o.type)}}}}}},getLightGroups:function(){var t=[];for(var e in this._lightNumber)t.push(e);return t},getNumberChangedLightGroups:function(){var t=[];for(var e in this._lightNumber)this.isLightNumberChanged(e)&&t.push(e);return t},isLightNumberChanged:function(t){var e=this._previousLightNumber,r=this._lightNumber;for(var n in r[t]){if(!e[t])return!0;if(r[t][n]!==e[t][n])return!0}for(var n in e[t]){if(!r[t])return!0;if(r[t][n]!==e[t][n])return!0}return!1},getLightsNumbers:function(t){return this._lightNumber[t]},getProgramKey:function(t){return this._lightProgramKeys[t]},setLightUniforms:function(){function t(t,e,r){for(var n in t){var i=t[n];if("tv"===i.type){if(!e.hasUniform(n))continue;for(var a=[],o=0;o<i.value.length;o++){var s=i.value[o],u=e.takeCurrentTextureSlot(r,s);a.push(u)}e.setUniform(r.gl,"1iv",n,a)}else e.setUniform(r.gl,i.type,n,i.value)}}return function(e,r,n){t(this._lightUniforms[r],e,n),t(this.shadowUniforms,e,n)}}(),dispose:function(){this.material=null,this._opaqueList=[],this._transparentList=[],this.lights=[],this._lightUniforms={},this._lightNumber={},this._nodeRepository={}}}),un=function(){this._contextId=0,this._caches=[],this._context={}};un.prototype={use:function(t,e){var r=this._caches;r[t]||(r[t]={},e&&(r[t]=e())),this._contextId=t,this._context=r[t]},put:function(t,e){this._context[t]=e},get:function(t){return this._context[t]},dirty:function(t){t=t||"";var e="__dt__"+t;this.put(e,!0)},dirtyAll:function(t){t=t||"";for(var e="__dt__"+t,r=this._caches,n=0;n<r.length;n++)r[n]&&(r[n][e]=!0)},fresh:function(t){t=t||"";var e="__dt__"+t;this.put(e,!1)},freshAll:function(t){t=t||"";for(var e="__dt__"+t,r=this._caches,n=0;n<r.length;n++)r[n]&&(r[n][e]=!1)},isDirty:function(t){t=t||"";var e="__dt__"+t,r=this._context;return!r.hasOwnProperty(e)||!0===r[e]},deleteContext:function(t){delete this._caches[t],this._context={}},delete:function(t){delete this._context[t]},clearAll:function(){this._caches={}},getContext:function(){return this._context},eachContext:function(t,e){Object.keys(this._caches).forEach(function(r){t&&t.call(e,r)})},miss:function(t){return!this._context.hasOwnProperty(t)}},un.prototyp
|
||
|
|
}),Nn="\n@export clay.standard.chunk.varying\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nvarying vec3 v_Barycentric;\n#if defined(PARALLAXOCCLUSIONMAP_ENABLED) || defined(NORMALMAP_ENABLED)\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n#if defined(AOMAP_ENABLED)\nvarying vec2 v_Texcoord2;\n#endif\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n@end\n@export clay.standard.chunk.light_header\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n#ifdef POINT_LIGHT_COUNT\n@import clay.header.point_light\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n#ifdef SPOT_LIGHT_COUNT\n@import clay.header.spot_light\n#endif\n@end\n@export clay.standard.vertex\n#define SHADER_NAME standard\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\nuniform vec2 uvRepeat = vec2(1.0, 1.0);\nuniform vec2 uvOffset = vec2(0.0, 0.0);\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n#if defined(AOMAP_ENABLED)\nattribute vec2 texcoord2 : TEXCOORD_1;\n#endif\nattribute vec3 normal : NORMAL;\nattribute vec4 tangent : TANGENT;\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\n#endif\nattribute vec3 barycentric;\n@import clay.standard.chunk.varying\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvoid main()\n{\n vec4 skinnedPosition = vec4(position, 1.0);\n vec4 skinnedNormal = vec4(normal, 0.0);\n vec4 skinnedTangent = vec4(tangent.xyz, 0.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n skinnedPosition = skinMatrixWS * skinnedPosition;\n skinnedNormal = skinMatrixWS * skinnedNormal;\n skinnedTangent = skinMatrixWS * skinnedTangent;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n skinnedPosition = instanceMat * skinnedPosition;\n skinnedNormal = instanceMat * skinnedNormal;\n skinnedTangent = instanceMat * skinnedTangent;\n#endif\n gl_Position = worldViewProjection * skinnedPosition;\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_WorldPosition = (world * skinnedPosition).xyz;\n v_Barycentric = barycentric;\n v_Normal = normalize((worldInverseTranspose * skinnedNormal).xyz);\n#if defined(PARALLAXOCCLUSIONMAP_ENABLED) || defined(NORMALMAP_ENABLED)\n v_Tangent = normalize((worldInverseTranspose * skinnedTangent).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n#if defined(AOMAP_ENABLED)\n v_Texcoord2 = texcoord2;\n#endif\n}\n@end\n@export clay.standard.fragment\n#define PI 3.14159265358979\n#define GLOSSINESS_CHANNEL 0\n#define ROUGHNESS_CHANNEL 0\n#define METALNESS_CHANNEL 1\n#define DIFFUSEMAP_ALPHA_ALPHA\n@import clay.standard.chunk.varying\nuniform mat4 viewInverse : VIEWINVERSE;\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\n#endif\nuniform float normalScale: 1.0;\n#ifdef DIFFUSEMAP_ENABLED\nuniform sampler2D diffuseMap;\n#endif\n#ifdef SPECULARMAP_ENABLED\nuniform sampler2D specularMap;\n#endif\n#ifdef USE_ROUGHNESS\nuniform float roughness : 0.5;\n #ifdef ROUGHNESSMAP_ENABLED\nuniform sampler2D roughnessMap;\n #endif\n#else\nuniform float glossiness: 0.5;\n #ifdef GLOSSINESSMAP_ENABLED\nuniform sampler2D glossinessMap;\n #endif\n#endif\n#ifdef METALNESSMAP_ENABLED\nuniform sampler2D metalnessMap;\n#endif\n#ifdef OCCLUSIONMAP_ENABLED\nuniform sampler2D occlusionMap;\n#endif\n#ifdef ENVIRONMENTMAP_ENABLED\nuniform samplerCube environmentMap;\n #ifdef PARALLAX_CORRECTED\nuniform vec3 environmentBoxMin;\nuniform vec3 environmentBoxMax;\n #endif\n#endif\n#ifdef BRDFLOOKUP_ENABLED\nuniform sampler2D brdfLookup;\n#endif\n#ifdef EMISSIVEMAP_ENABLED\nuniform sampler2D emissiveMap;\n#endif\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n#ifdef AOMAP_ENABLED\nunifor
|
||
|
|
Q.import("@export clay.basic.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position : POSITION;\nattribute vec3 barycentric;\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec2 v_Texcoord;\nvarying vec3 v_Barycentric;\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\nvoid main()\n{\n vec4 skinnedPosition = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n skinnedPosition = skinMatrixWS * skinnedPosition;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n skinnedPosition = instanceMat * skinnedPosition;\n#endif\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_Barycentric = barycentric;\n gl_Position = worldViewProjection * skinnedPosition;\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n}\n@end\n@export clay.basic.fragment\n#define DIFFUSEMAP_ALPHA_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D diffuseMap;\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform vec3 emission : [0.0, 0.0, 0.0];\nuniform float alpha : 1.0;\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\nuniform float lineWidth : 0.0;\nuniform vec4 lineColor : [0.0, 0.0, 0.0, 0.6];\nvarying vec3 v_Barycentric;\n@import clay.util.edge_factor\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n gl_FragColor = vec4(color, alpha);\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(gl_FragColor);\n#endif\n#ifdef DIFFUSEMAP_ENABLED\n vec4 texel = decodeHDR(texture2D(diffuseMap, v_Texcoord));\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#if defined(DIFFUSEMAP_ALPHA_ALPHA)\n gl_FragColor.a = texel.a;\n#endif\n gl_FragColor.rgb *= texel.rgb;\n#endif\n gl_FragColor.rgb += emission;\n if( lineWidth > 0.)\n {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor(lineWidth)) * lineColor.a);\n }\n#ifdef ALPHA_TEST\n if (gl_FragColor.a < alphaCutoff) {\n discard;\n }\n#endif\n#ifdef TONEMAPPING\n gl_FragColor.rgb = ACESToneMapping(gl_FragColor.rgb);\n#endif\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n}\n@end"),Q.import("\n@export clay.lambert.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\nattribute vec3 barycentric;\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nvarying vec3 v_Barycentric;\nvoid main()\n{\n vec4 skinnedPosition = vec4(position, 1.0);\n vec4 skinnedNormal = vec4(normal, 0.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n skinnedPosition = skinMatrixWS * skinnedPosition;\n skinnedNormal = skinMatrixWS * skinnedNormal;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n skinnedPosition = instanceMat * skinnedPosition;\n skinnedNormal = instanceMat * skinnedNormal;\n#endif\n gl_Position = worldViewProjection * skinnedPosition;\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_Normal = normalize((worldInverseTranspose * skinnedNormal).xyz);\n v_WorldPosition = ( world * skinnedPosition ).xyz;\n v_Barycentric = barycentric;\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n}\n@end\n@export clay.lambert.fragment\n#define DIFFUSEMAP_ALPHA_ALPHA\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nuniform sampler2D diffuseMap;\nuniform sampler2D alphaMap;\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform vec3 emission : [0
|
||
|
|
}),li=new Ln,hi=ke.extend(function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}},function(){var t=new Q(Q.source("clay.compositor.vertex"),this.fragment),e=new nr({shader:t});e.enableTexturesAll(),this.material=e},{setUniform:function(t,e){this.material.setUniform(t,e)},getUniform:function(t){var e=this.material.uniforms[t];if(e)return e.value},attachOutput:function(t,e){this.outputs||(this.outputs={}),e=e||Ye.COLOR_ATTACHMENT0,this.outputs[e]=t},detachOutput:function(t){for(var e in this.outputs)this.outputs[e]===t&&(this.outputs[e]=null)},bind:function(t,e){if(this.outputs)for(var r in this.outputs){var n=this.outputs[r];n&&e.attach(n,r)}e&&e.bind(t)},unbind:function(t,e){e.unbind(t)},render:function(t,e){var r=t.gl;if(e){this.bind(t,e);var n=t.getGLExtension("EXT_draw_buffers");if(n&&this.outputs){var i=[];for(var a in this.outputs)(a=+a)>=r.COLOR_ATTACHMENT0&&a<=r.COLOR_ATTACHMENT0+8&&i.push(a);n.drawBuffersEXT(i)}}this.trigger("beforerender",this,t);var o=this.clearDepth?r.DEPTH_BUFFER_BIT:0;if(r.depthMask(!0),this.clearColor){o|=r.COLOR_BUFFER_BIT,r.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&r.clearColor(s[0],s[1],s[2],s[3])}r.clear(o),this.blendWithPrevious?(r.enable(r.BLEND),this.material.transparent=!0):(r.disable(r.BLEND),this.material.transparent=!1),this.renderQuad(t),this.trigger("afterrender",this,t),e&&this.unbind(t,e)},renderQuad:function(t){ui.material=this.material,t.renderPass([ui],li)},dispose:function(t){}});Q.import(qn);var ci=Cn.extend(function(){var t=new Q({vertex:Q.source("clay.skybox.vertex"),fragment:Q.source("clay.skybox.fragment")}),e=new nr({shader:t,depthMask:!1});return{scene:null,geometry:new gn,material:e,environmentMap:null,culling:!1,_dummyCamera:new Rn}},function(){var t=this.scene;t&&this.attachScene(t),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)},{attachScene:function(t){this.scene&&this.detachScene(),t.skybox=this,this.scene=t,t.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&(this.scene.off("beforerender",this._beforeRenderScene),this.scene.skybox=null),this.scene=null},dispose:function(t){this.detachScene(),this.geometry.dispose(t)},setEnvironmentMap:function(t){"texture2D"===t.textureType?(this.material.define("EQUIRECTANGULAR"),t.minFilter=Tn.LINEAR):this.material.undefine("EQUIRECTANGULAR"),this.material.set("environmentMap",t)},getEnvironmentMap:function(){return this.material.get("environmentMap")},_beforeRenderScene:function(t,e,r){this.renderSkybox(t,r)},renderSkybox:function(t,e){var r=this._dummyCamera;r.aspect=t.getViewportAspect(),r.fov=e.fov||50,r.updateProjectionMatrix(),Ur.invert(r.invProjectionMatrix,r.projectionMatrix),r.worldTransform.copy(e.worldTransform),r.viewMatrix.copy(e.viewMatrix),this.position.copy(e.getWorldPosition()),this.update(),t.gl.disable(t.gl.BLEND),this.material.get("lod")>0?this.material.define("fragment","LOD"):this.material.undefine("fragment","LOD"),t.renderPass([this],r)}}),fi=["px","nx","py","ny","pz","nz"],di=ke.extend(function(){var t={position:new Cr,far:1e3,near:.1,texture:null,shadowMapPass:null},e=t._cameras={px:new Rn({fov:90}),nx:new Rn({fov:90}),py:new Rn({fov:90}),ny:new Rn({fov:90}),pz:new Rn({fov:90}),nz:new Rn({fov:90})};return e.px.lookAt(Cr.POSITIVE_X,Cr.NEGATIVE_Y),e.nx.lookAt(Cr.NEGATIVE_X,Cr.NEGATIVE_Y),e.py.lookAt(Cr.POSITIVE_Y,Cr.POSITIVE_Z),e.ny.lookAt(Cr.NEGATIVE_Y,Cr.NEGATIVE_Z),e.pz.lookAt(Cr.POSITIVE_Z,Cr.NEGATIVE_Y),e.nz.lookAt(Cr.NEGATIVE_Z,Cr.NEGATIVE_Y),t._frameBuffer=new oi,t},{getCamera:function(t){return this._cameras[t]},render:function(t,e,r){var n=t.gl;r||e.update();for(var i=this.texture.width,a=2*Math.atan(i/(i-.5))/Math.PI*180,o=0;o<6;o++){var s=fi[o],u=this._cameras[s];if(Cr.copy(u.position,this.position),u.far=this.far,u.near=this.near,u.fov=a,this.shadowMapPass){u.update();var l=e.getBoundingBox();l.applyTransform(u.viewMatrix),e.viewBoundingBoxLastFrame.copy(l),this.shadowMapPass.render(t,e,u,!0)}this._frameBuffer.attach(this.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE
|
||
|
|
D[1]=Math.min(D[1],1),n.ortho(O[0],D[0],O[1],D[1],1,-1),y.projectionMatrix.multiplyLeft(n);var B=h.shadowResolution||512;s.setViewport((h.shadowCascade-S-1)*B,0,B,B,1);var U=u.updateRenderList(y);s.renderPass(U.opaque,y,m),this.softShadow===Ni.VSM&&this._gaussianFilter(s,R,R.width);var F=new Ur;F.copy(y.viewMatrix).multiplyLeft(y.projectionMatrix),f.push(F.array),y.projectionMatrix.copy(o)}this._frameBuffer.unbind(s),s.setViewport(L)}}(),renderSpotLightShadow:function(t,e,r,n,i){var a=this._getTexture(r),o=this._getSpotLightCamera(r),s=t.gl;this._frameBuffer.attach(a),this._frameBuffer.bind(t),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT);var u=this._getDepthMaterial(r),l={getMaterial:function(t){return t.shadowDepthMaterial||u},isMaterialChanged:It,getUniform:Pt,ifRender:function(t){return t.castShadow},sortCompare:Mr.opaqueSortCompare},h=e.updateRenderList(o);t.renderPass(h.opaque,o,l),this._frameBuffer.unbind(t),this.softShadow===Ni.VSM&&this._gaussianFilter(t,a,a.width);var c=new Ur;c.copy(o.worldTransform).invert().multiplyLeft(o.projectionMatrix),i.push(a),n.push(c.array)},renderPointLightShadow:function(t,e,r,n){var i=this._getTexture(r),a=t.gl;n.push(i);var o=this._getDepthMaterial(r),s={getMaterial:function(t){return t.shadowDepthMaterial||o},getUniform:Pt,sortCompare:Mr.opaqueSortCompare},u={px:[],py:[],pz:[],nx:[],ny:[],nz:[]},l=new Vr,h=r.getWorldPosition().array,c=new Vr,f=r.range;c.min.setArray(h),c.max.setArray(h);var d=new Cr(f,f,f);c.max.add(d),c.min.sub(d);var p={px:!1,py:!1,pz:!1,nx:!1,ny:!1,nz:!1};e.traverse(function(t){if(t.isRenderable()&&t.castShadow){var e=t.geometry;if(!e.boundingBox){for(var r=0;r<Li.length;r++)u[Li[r]].push(t);return}if(l.transformFrom(e.boundingBox,t.worldTransform),!l.intersectBoundingBox(c))return;l.updateVertices();for(var r=0;r<Li.length;r++)p[Li[r]]=!1;for(var r=0;r<8;r++){var n=l.vertices[r],i=n[0]-h[0],a=n[1]-h[1],o=n[2]-h[2],s=Math.abs(i),f=Math.abs(a),d=Math.abs(o);s>f?s>d?p[i>0?"px":"nx"]=!0:p[o>0?"pz":"nz"]=!0:f>d?p[a>0?"py":"ny"]=!0:p[o>0?"pz":"nz"]=!0}for(var r=0;r<Li.length;r++)p[Li[r]]&&u[Li[r]].push(t)}});for(var m=0;m<6;m++){var _=Li[m],g=this._getPointLightCamera(r,_);this._frameBuffer.attach(i,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+m),this._frameBuffer.bind(t),a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT),t.renderPass(u[_],g,s)}this._frameBuffer.unbind(t)},_getDepthMaterial:function(t){var e=this._lightMaterials[t.__uid__],r="POINT_LIGHT"===t.type;if(!e){var n=r?"clay.sm.distance.":"clay.sm.depth.";e=new nr({precision:this.precision,shader:new Q(Q.source(n+"vertex"),Q.source(n+"fragment"))}),this._lightMaterials[t.__uid__]=e}return null!=t.shadowSlopeScale&&e.setUniform("slopeScale",t.shadowSlopeScale),null!=t.shadowBias&&e.setUniform("bias",t.shadowBias),this.softShadow===Ni.VSM?e.define("fragment","USE_VSM"):e.undefine("fragment","USE_VSM"),r&&(e.set("lightPosition",t.getWorldPosition().array),e.set("range",t.range)),e},_gaussianFilter:function(t,e,r){var n={width:r,height:r,type:Tn.FLOAT},i=this._texturePool.get(n);this._frameBuffer.attach(i),this._frameBuffer.bind(t),this._gaussianPassH.setUniform("texture",e),this._gaussianPassH.setUniform("textureWidth",r),this._gaussianPassH.render(t),this._frameBuffer.attach(e),this._gaussianPassV.setUniform("texture",i),this._gaussianPassV.setUniform("textureHeight",r),this._gaussianPassV.render(t),this._frameBuffer.unbind(t),this._texturePool.put(i)},_getTexture:function(t,e){var r=t.__uid__,n=this._textures[r],i=t.shadowResolution||512;return e=e||1,n||(n="POINT_LIGHT"===t.type?new Mn:new An,n.width=i*e,n.height=i,this.softShadow===Ni.VSM?(n.type=Tn.FLOAT,n.anisotropic=4):(n.minFilter=Ye.NEAREST,n.magFilter=Ye.NEAREST,n.useMipmap=!1),this._textures[r]=n),n},_getPointLightCamera:function(t,e){this._lightCameras.point||(this._lightCameras.point={px:new Rn,nx:new Rn,py:new Rn,ny:new Rn,pz:new Rn,nz:new Rn});var r=this._lightCameras.point[e];switch(r.far=t.range,r.fov=90,r.position.set(0,0,0),e){case"px":r.lookAt(Cr.POSITIVE_X,Cr.NEGATIVE_Y);break;case"nx":r.lookAt(Cr.NEGATIVE_X,Cr.NEGATIVE_Y);break;case
|
||
|
|
}),qi="@export clay.compositor.coloradjust\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float exposure : 0.0;\nuniform float gamma : 1.0;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);\n color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n color = clamp( color * pow(2.0, exposure), 0.0, 1.0);\n color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);\n float luminance = dot( color, w );\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.brightness\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = tex.rgb + vec3(brightness);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.contrast\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float contrast : 1.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = (tex.rgb-vec3(0.5))*contrast+vec3(0.5);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.exposure\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float exposure : 0.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb * pow(2.0, exposure);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.gamma\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float gamma : 1.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = pow(tex.rgb, vec3(gamma));\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.saturation\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb;\n float luminance = dot(color, w);\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end",Yi="@export clay.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export clay.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export clay.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main (void)\n{\n @import clay.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n",Ki="@export clay.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n float luminance = dot(tex.rgb, w);\n luminance = log(luminance + 0.001);\n gl_FragColor = encodeHDR(vec4(vec3(luminance), 1.0));\n}\n@end\n@export clay.compositor.hdr.l
|
||
|
|
;e.__prevSkinMatricesArray&&e.__prevSkinMatricesArray.length===u.length||(e.__prevSkinMatricesArray=new Float32Array(u.length)),e.__prevSkinMatricesArray.set(u)}}e.__prevWorldViewProjection=e.__prevWorldViewProjection||Er.create(),r?Er.copy(e.__prevWorldViewProjection,A):Er.multiply(e.__prevWorldViewProjection,A,e.worldTransform.array)},getUniform:function(t,e,r){return"prevWorldViewProjection"===r?t.__prevWorldViewProjection:"prevSkinMatrix"===r?t.__prevSkinMatricesArray:"prevSkinMatricesTexture"===r?t.__prevSkinMatricesTexture:"firstRender"===r?!t.__prevWorldViewProjection:e.get(r)},isMaterialChanged:function(){return!0},sortCompare:t.opaqueSortCompare};t.renderPass(d,r,T)}t.bindSceneRendering(null),s.unbind(t)},renderDebug:function(t,e,r,n){var i={normal:0,depth:1,position:2,glossiness:3,metalness:4,albedo:5,velocity:6};null==i[r]&&(console.warn('Unkown type "'+r+'"'),r="normal"),t.saveClear(),t.saveViewport(),t.clearBit=t.gl.DEPTH_BUFFER_BIT,n&&t.setViewport(n);var a=new Ur;Ur.multiply(a,e.worldTransform,e.invProjectionMatrix);var o=this._debugPass;o.setUniform("viewportSize",[t.getWidth(),t.getHeight()]),o.setUniform("gBufferTexture1",this._gBufferTex1),o.setUniform("gBufferTexture2",this._gBufferTex2),o.setUniform("gBufferTexture3",this._gBufferTex3),o.setUniform("gBufferTexture4",this._gBufferTex4),o.setUniform("debug",i[r]),o.setUniform("viewProjectionInv",a.array),o.render(t),t.restoreViewport(),t.restoreClear()},getTargetTexture1:function(){return this._gBufferTex1},getTargetTexture2:function(){return this._gBufferTex2},getTargetTexture3:function(){return this._gBufferTex3},getTargetTexture4:function(){return this._gBufferTex4},dispose:function(t){this._gBufferTex1.dispose(t),this._gBufferTex2.dispose(t),this._gBufferTex3.dispose(t),this._defaultNormalMap.dispose(t),this._defaultRoughnessMap.dispose(t),this._defaultMetalnessMap.dispose(t),this._defaultDiffuseMap.dispose(t),this._frameBuffer.dispose(t)}}),ua=pn.extend({dynamic:!1,topRadius:0,bottomRadius:1,height:2,capSegments:20,heightSegments:1},function(){this.build()},{build:function(){var t=[],e=[],r=[];t.length=0,e.length=0,r.length=0;for(var n=2*Math.PI/this.capSegments,i=[],a=[],o=this.topRadius,s=this.bottomRadius,u=this.height/2,l=Ce.fromValues(0,u,0),h=Ce.fromValues(0,-u,0),c=0;c<this.capSegments;c++){var f=c*n,d=o*Math.sin(f),p=o*Math.cos(f);i.push(Ce.fromValues(d,u,p)),d=s*Math.sin(f),p=s*Math.cos(f),a.push(Ce.fromValues(d,-u,p))}t.push(l),e.push(be.fromValues(0,1));for(var m=this.capSegments,c=0;c<m;c++)t.push(i[c]),e.push(be.fromValues(c/m,0)),r.push([0,c+1,(c+1)%m+1]);var _=t.length;t.push(h),e.push(be.fromValues(0,1));for(var c=0;c<m;c++)t.push(a[c]),e.push(be.fromValues(c/m,0)),r.push([_,_+((c+1)%m+1),_+c+1]);_=t.length;for(var g=this.heightSegments,c=0;c<m;c++)for(var v=0;v<g+1;v++){var y=v/g;t.push(Ce.lerp(Ce.create(),i[c],a[c],y)),e.push(be.fromValues(c/m,y))}for(var c=0;c<m;c++)for(var v=0;v<g;v++){var T=c*(g+1)+v,x=(c+1)%m*(g+1)+v,E=(c+1)%m*(g+1)+v+1,A=c*(g+1)+v+1;r.push([_+x,_+T,_+A]),r.push([_+A,_+E,_+x])}this.attributes.position.fromArray(t),this.attributes.texcoord0.fromArray(e),this.initIndicesFromArray(r),this.generateVertexNormals(),this.boundingBox=new Vr;var b=Math.max(this.topRadius,this.bottomRadius);this.boundingBox.min.set(-b,-this.height/2,-b),this.boundingBox.max.set(b,this.height/2,b)}}),la=pn.extend({dynamic:!1,radius:1,height:2,capSegments:50,heightSegments:1},function(){this.build()},{build:function(){var t=new ua({topRadius:this.radius,bottomRadius:this.radius,capSegments:this.capSegments,heightSegments:this.heightSegments,height:this.height});this.attributes.position.value=t.attributes.position.value,this.attributes.normal.value=t.attributes.normal.value,this.attributes.texcoord0.value=t.attributes.texcoord0.value,this.indices=t.indices,this.boundingBox=t.boundingBox}});Q.import(xr),Q.import(jn),Q.import("@export clay.deferred.light_volume.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_Position;\nvoid main()\n{\n gl_Position = worldViewProjection *
|
||
|
|
return fa.rotate(this.array,this.array,t),this._dirty=!0,this},scale:function(t){return fa.scale(this.array,this.array,t.array),this._dirty=!0,this},translate:function(t){return fa.translate(this.array,this.array,t.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},Ta.copy=function(t,e){return fa.copy(t.array,e.array),t._dirty=!0,t},Ta.determinant=function(t){return fa.determinant(t.array)},Ta.identity=function(t){return fa.identity(t.array),t._dirty=!0,t},Ta.invert=function(t,e){return fa.invert(t.array,e.array),t._dirty=!0,t},Ta.mul=function(t,e,r){return fa.mul(t.array,e.array,r.array),t._dirty=!0,t},Ta.multiply=Ta.mul,Ta.rotate=function(t,e,r){return fa.rotate(t.array,e.array,r),t._dirty=!0,t},Ta.scale=function(t,e,r){return fa.scale(t.array,e.array,r.array),t._dirty=!0,t},Ta.translate=function(t,e,r){return fa.translate(t.array,e.array,r.array),t._dirty=!0,t};var xa=function(){this.array=Le.create(),this._dirty=!0};xa.prototype={constructor:xa,setArray:function(t){for(var e=0;e<this.array.length;e++)this.array[e]=t[e];return this._dirty=!0,this},adjoint:function(){return Le.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new xa).copy(this)},copy:function(t){return Le.copy(this.array,t.array),this._dirty=!0,this},determinant:function(){return Le.determinant(this.array)},fromMat2d:function(t){return Le.fromMat2d(this.array,t.array),this._dirty=!0,this},fromMat4:function(t){return Le.fromMat4(this.array,t.array),this._dirty=!0,this},fromQuat:function(t){return Le.fromQuat(this.array,t.array),this._dirty=!0,this},identity:function(){return Le.identity(this.array),this._dirty=!0,this},invert:function(){return Le.invert(this.array,this.array),this._dirty=!0,this},mul:function(t){return Le.mul(this.array,this.array,t.array),this._dirty=!0,this},mulLeft:function(t){return Le.mul(this.array,t.array,this.array),this._dirty=!0,this},multiply:function(t){return Le.multiply(this.array,this.array,t.array),this._dirty=!0,this},multiplyLeft:function(t){return Le.multiply(this.array,t.array,this.array),this._dirty=!0,this},rotate:function(t){return Le.rotate(this.array,this.array,t),this._dirty=!0,this},scale:function(t){return Le.scale(this.array,this.array,t.array),this._dirty=!0,this},translate:function(t){return Le.translate(this.array,this.array,t.array),this._dirty=!0,this},normalFromMat4:function(t){return Le.normalFromMat4(this.array,t.array),this._dirty=!0,this},transpose:function(){return Le.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},xa.adjoint=function(t,e){return Le.adjoint(t.array,e.array),t._dirty=!0,t},xa.copy=function(t,e){return Le.copy(t.array,e.array),t._dirty=!0,t},xa.determinant=function(t){return Le.determinant(t.array)},xa.identity=function(t){return Le.identity(t.array),t._dirty=!0,t},xa.invert=function(t,e){return Le.invert(t.array,e.array),t},xa.mul=function(t,e,r){return Le.mul(t.array,e.array,r.array),t._dirty=!0,t},xa.multiply=xa.mul,xa.fromMat2d=function(t,e){return Le.fromMat2d(t.array,e.array),t._dirty=!0,t},xa.fromMat4=function(t,e){return Le.fromMat4(t.array,e.array),t._dirty=!0,t},xa.fromQuat=function(t,e){return Le.fromQuat(t.array,e.array),t._dirty=!0,t},xa.normalFromMat4=function(t,e){return Le.normalFromMat4(t.array,e.array),t._dirty=!0,t},xa.rotate=function(t,e,r){return Le.rotate(t.array,e.array,r),t._dirty=!0,t},xa.scale=function(t,e,r){return Le.scale(t.array,e.array,r.array),t._dirty=!0,t},xa.transpose=function(t,e){return Le.transpose(t.array,e.array),t._dirty=!0,t},xa.translate=function(t,e,r){return Le.translate(t.array,e.array,r.array),t._dirty=!0,t};var Ea=function(){};Ea.prototype.get=function(t){};var Aa=function(t){this.get=function(){return t}};Aa.prototype=new Ea,Aa.prototype.constructor=Aa;var ba=function(t){var e=t.constructor;this.get=function(r){return r||(r=new e),r.copy(t),r
|
||
|
|
this._distance=Math.max(Math.min(t,this.maxDistance),this.minDistance)},_setOrthoSize:function(t){this._orthoSize=Math.max(Math.min(t,this.maxOrthographicSize),this.minOrthographicSize);var e=this.target,r=this._orthoSize,n=r*this.orthographicAspect;e.left=-n/2,e.right=n/2,e.top=r/2,e.bottom=-r/2},_updatePan:function(t){var e=this._panVelocity,r=this._distance,n=this.target,i=n.worldTransform.y,a=n.worldTransform.x;this._center.scaleAndAdd(a,-e.x*r/200).scaleAndAdd(i,-e.y*r/200),this._vectorDamping(e,0),e.x=e.y=0},_updateTransform:function(){var t=this.target,e=new Cr,r=this._theta+Math.PI/2,n=this._phi+Math.PI/2,i=Math.sin(r);e.x=i*Math.cos(n),e.y=-Math.cos(r),e.z=i*Math.sin(n),t.position.copy(this._center).scaleAndAdd(e,this._distance),t.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var t=this.autoRotateAfterStill,e=this;!isNaN(t)&&t>0&&(this._stillTimeout=setTimeout(function(){e._rotating=!0},1e3*t))},_vectorDamping:function(t,e){var r=t.len();r*=e,r<1e-4&&(r=0),t.normalize().scale(r)},decomposeTransform:function(){if(this.target){this.target.updateWorldTransform();var t=this.target.worldTransform.z,e=Math.asin(t.y),r=Math.atan2(t.x,t.z);this._theta=e,this._phi=-r,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this._setDistance(this.target.position.dist(this._center)),this.target instanceof Rn||this._setOrthoSize(this.target.top-this.target.bottom)}},_mouseDownHandler:function(t){if(!this._isAnimating()){var e=t.clientX,r=t.clientY;if(t.targetTouches){var n=t.targetTouches[0];e=n.clientX,r=n.clientY,this._mode="rotate",this._processGesture(t,"start")}else t.button===ja[this.rotateMouseButton]?this._mode="rotate":t.button===ja[this.panMouseButton]?(this._mode="pan",t.preventDefault()):this._mode=null;var i=this.domElement;Ve.addEventListener(i,"touchmove",this._mouseMoveHandler),Ve.addEventListener(i,"touchend",this._mouseUpHandler),Ve.addEventListener(i,"mousemove",this._mouseMoveHandler),Ve.addEventListener(i,"mouseup",this._mouseUpHandler),Ve.addEventListener(i,"mouseout",this._mouseUpHandler),this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=e,this._mouseY=r}},_mouseMoveHandler:function(t){if(!this._isAnimating()){var e,r=t.clientX,n=t.clientY;if(t.targetTouches){var i=t.targetTouches[0];r=i.clientX,n=i.clientY,e=this._processGesture(t,"change")}var a=ce(this.panSensitivity),o=ce(this.rotateSensitivity);e||("rotate"===this._mode?(this._rotateVelocity.y+=(r-this._mouseX)/this.domElement.clientWidth*2*o[0],this._rotateVelocity.x+=(n-this._mouseY)/this.domElement.clientHeight*2*o[1]):"pan"===this._mode&&(this._panVelocity.x+=(r-this._mouseX)/this.domElement.clientWidth*a[0]*400,this._panVelocity.y+=(-n+this._mouseY)/this.domElement.clientHeight*a[1]*400)),this._mouseX=r,this._mouseY=n,t.preventDefault&&t.preventDefault()}},_mouseWheelHandler:function(t){if(!this._isAnimating()){var e=t.deltaY;0!==e&&this._zoomHandler(t,e>0?1:-1)}},_pinchHandler:function(t){this._isAnimating()||this._zoomHandler(t,t.pinchScale>1?.4:-.4)},_zoomHandler:function(t,e){var r;r=this.target instanceof Rn?Math.max(Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance))/20,.5):Math.max(Math.max(Math.min(this._orthoSize-this.minOrthographicSize,this.maxOrthographicSize-this._orthoSize))/20,.5),this._zoomSpeed=(e>0?-1:1)*r*this.zoomSensitivity,this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),t.preventDefault&&t.preventDefault()},_mouseUpHandler:function(t){var e=this.domElement;Ve.removeEventListener(e,"touchmove",this._mouseMoveHandler),Ve.removeEventListener(e,"touchend",this._mouseUpHandler),Ve.removeEventListener(e,"mousemove",this._mouseMoveHandler),Ve.removeEventListener(e,"mouseup",this._mouseUpHandler),Ve.removeEventListener(e,"mouseout",this._mouseUpHandler),this._processGesture(t,"end")},_addAnimator:function(t){var e=this._animators;return e.push(t),t.done(function(){var r=e.indexOf(t);r>=0&&e.splice(r,1)}),t},_processGesture
|