bolt-engine/demos/fireworks/lithree.min.js
2015-01-24 17:56:37 +03:30

1 line
20 KiB
JavaScript

!function(a){"use strict";function b(){var a=void 0===arguments[0]?1:arguments[0],b=void 0===arguments[1]?20:arguments[1],c=new t;c.vertices.push(0,0,0),c.vertexIndex=[],c.vertexNormals=[];var d=Math.PI/(b-1);b*=2;for(var e=0,f=1;b>f;e+=d,f++)c.vertices.push(Math.cos(e)*a,Math.sin(e)*a,0);for(var f=0;f<c.vertices.length;f++)c.vertexNormals.push(0,0,1);for(var f=0;f<c.vertices.length/3;f++)c.vertexIndex.push(f);return c.darwingFunction=i.drawingFunctions.ELEMENTS,c.drawingMode=i.drawingMode.TRIANGLE_FAN,c}function c(){var a=new t;return a.vertices=[-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1],a.vertexIndex=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23],a.vertexNormals=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0],a.darwingFunction=i.drawingFunctions.ELEMENTS,a.drawingMode=i.drawingMode.TRIANGLES,a}function d(){var a=void 0===arguments[0]?2:arguments[0],b=void 0===arguments[1]?1:arguments[1],c=void 0===arguments[2]?1:arguments[2],d=void 0===arguments[3]?20:arguments[3],e=new t;e.vertexIndex=[],e.vertexNormals=[];var f=Math.PI/(d-1);d*=2;for(var g=a/2,h=a/-2,j=0,k=1;d>=k;j+=f,k++){var l=new r(Math.cos(j)*b,Math.sin(j)*b,g),m=new r(Math.cos(j)*c,Math.sin(j)*c,h),n=l.cross(m);e.vertexNormals.push(n.x,n.y,n.z),e.vertexNormals.push(n.x,n.y,n.z),e.vertices.push(l.x,l.y,l.z),e.vertices.push(m.x,m.y,m.z)}for(var k=0;k<e.vertices.length/3;k++)e.vertexIndex.push(k);return e.darwingFunction=i.drawingFunctions.ELEMENTS,e.drawingMode=i.drawingMode.TRIANGLE_STRIP,e}function e(){for(var a=void 0===arguments[0]?1:arguments[0],b=void 0===arguments[1]?30:arguments[1],c=void 0===arguments[2]?30:arguments[2],d=new t,e=[],f=[],g=[],h=0;b>=h;h++)for(var j=h*Math.PI/b,k=Math.sin(j),l=Math.cos(j),m=0;c>=m;m++){var n=2*m*Math.PI/c,o=Math.sin(n),p=Math.cos(n),q=p*k,r=l,s=o*k,u=1-m/c,v=1-h/b;f.push(q),f.push(r),f.push(s),g.push(u),g.push(v),e.push(a*q),e.push(a*r),e.push(a*s)}for(var w=[],h=0;b>h;h++)for(var m=0;c>m;m++){var x=h*(c+1)+m,y=x+c+1;w.push(x),w.push(y),w.push(x+1),w.push(y),w.push(y+1),w.push(x+1)}return d.vertexIndex=w,d.vertexNormals=f,d.vertices=e,d.darwingFunction=i.drawingFunctions.ELEMENTS,d.drawingMode=i.drawingMode.TRIANGLES,d}var f=function(a,b,c){b&&Object.defineProperties(a,b),c&&Object.defineProperties(a.prototype,c)},g=function(){function a(){var a=void 0===arguments[0]?.785398:arguments[0],b=void 0===arguments[1]?1:arguments[1],c=void 0===arguments[2]?.1:arguments[2],d=void 0===arguments[3]?100:arguments[3];this.fovy=a,this.aspect=b,this.near=c,this.far=d,this.matrix=new q,this.lookAt=[0,0,0],this.position=[0,0,5],this.up=[0,1,0],this._zoom=1}return f(a,null,{zoom:{set:function(a){if(1>a)throw"Zoom should be equal or greater than 1";this._zoom=a},get:function(){return this._zoom},enumerable:!0,configurable:!0},updatePerspective:{value:function(){var a=2*Math.atan(Math.tan(.5*this.fovy)/this._zoom);this.matrix.perspective(a,this.aspect,this.near,this.far)},writable:!0,enumerable:!0,configurable:!0}}),a}(),f=function(a,b,c){b&&Object.defineProperties(a,b),c&&Object.defineProperties(a.prototype,c)},h=function(){function a(){{var a=void 0===arguments[0]?1:arguments[0],b=void 0===arguments[1]?1:arguments[1],c=void 0===arguments[2]?1:arguments[2];void 0===arguments[3]?1:arguments[3]}this.array=[a,b,c]}return f(a,null,{hex:{set:function(a){var b=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;a=a.replace(b,function(a,b,c,d){return b+b+c+c+d+d});var c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);this.array[0]=parseInt(c[1],16)/255,this.array[1]=parseInt(c[2],16)/255,this.array[2]=parseInt(c[3],16)/255},get:function(){var a=function(a){var b=a.toString(16);return 1==b.length?"0"+b:b};return"#"+a(this.array[0])+a(this.array[1])+a(this.array[2])},enumerable:!0,configurable:!0},rgb:{value:function(a,b,c){return this.array[0]=a,this.array[1]=b,this.array[2]=c,this},writable:!0,enumerable:!0,configurable:!0},alpha:{value:function b(b){return this.array[3]=b,this},writable:!0,enumerable:!0,configurable:!0},rgba:{value:function(a,b,c,d){return this.rgb(a,b,c),this.alpha(d),this},writable:!0,enumerable:!0,configurable:!0},toArray:{value:function(){return this.array},writable:!0,enumerable:!0,configurable:!0}}),a}(),i={};if(WebGLRenderingContext){var j=WebGLRenderingContext;i={support:!0,drawingMode:{POINTS:j.POINTS,LINES:j.LINES,LINE_LOOP:j.LINE_LOOP,LINE_STRIP:j.LINE_STRIP,TRIANGLES:j.TRIANGLES,TRIANGLE_FAN:j.TRIANGLE_FAN,TRIANGLE_STRIP:j.TRIANGLE_STRIP},drawingFunctions:{ARRAYS:1,ELEMENTS:0}}}else i.support=!1;var f=function(a,b,c){b&&Object.defineProperties(a,b),c&&Object.defineProperties(a.prototype,c)},k=function(){function a(){this.children=[],this.lights=[]}return f(a,null,{add:{value:function(a){a instanceof m?this.lights.push(a):this.children.push(a)},writable:!0,enumerable:!0,configurable:!0},remove:{value:function(a){a instanceof m?this.lights.splice(this.lights.indexOf(a),1):this.children.splice(this.children.indexOf(a),1)},writable:!0,enumerable:!0,configurable:!0}}),a}(),l=0,m=function(){this.color=new h(1,1,1),this.direction=new r(1,1,1),this.index=l++},f=function(a,b,c){b&&Object.defineProperties(a,b),c&&Object.defineProperties(a.prototype,c)},n=function(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(a.__proto__=b)},o=function(a){function b(){for(var a=9;a--;)this.push(0)}return n(b,a),f(b,null,{transpose:{value:function(){var a=this[1],b=this[2],c=this[5];return this[1]=this[3],this[2]=this[6],this[3]=a,this[5]=this[7],this[6]=b,this[7]=c,this},writable:!0,enumerable:!0,configurable:!0},toArray:{value:function(){for(var a=[],b=9;b--;)a[b]=this[b];return a},writable:!0,enumerable:!0,configurable:!0}}),b}(Array),f=function(a,b,c){b&&Object.defineProperties(a,b),c&&Object.defineProperties(a.prototype,c)},n=function(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(a.__proto__=b)},p=1e-5,q=function(a){function b(){for(var a=16;a--;)this.push(0)}return n(b,a),f(b,null,{identity:{value:function(){for(var a=16;a--;)this[a]=a%5===0?1:0;return this},writable:!0,enumerable:!0,configurable:!0},determinant:{value:function(){var a=this[0],b=this[1],c=this[2],d=this[3],e=this[4],f=this[5],g=this[6],h=this[7],i=this[8],j=this[9],k=this[10],l=this[11],m=this[12],n=this[13],o=this[14],p=this[15],q=a*f-b*e,r=a*g-c*e,s=a*h-d*e,t=b*g-c*f,u=b*h-d*f,v=c*h-d*g,w=i*n-j*m,x=i*o-k*m,y=i*p-l*m,z=j*o-k*n,A=j*p-l*n,B=k*p-l*o;return q*B-r*A+s*z+t*y-u*x+v*w},writable:!0,enumerable:!0,configurable:!0},perspective:{value:function(a,b,c,d){var e=1/Math.tan(a/2),f=1/(c-d);return this[0]=e/b,this[1]=0,this[2]=0,this[3]=0,this[4]=0,this[5]=e,this[6]=0,this[7]=0,this[8]=0,this[9]=0,this[10]=(d+c)*f,this[11]=-1,this[12]=0,this[13]=0,this[14]=2*d*c*f,this[15]=0,this},writable:!0,enumerable:!0,configurable:!0},lookAt:{value:function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n=a[0],o=a[1],q=a[2],r=c[0],s=c[1],t=c[2],u=b[0],v=b[1],w=b[2];return Math.abs(n-u)<p&&Math.abs(o-v)<p&&Math.abs(q-w)<p?this.identity():(j=n-u,k=o-v,l=q-w,m=1/Math.sqrt(j*j+k*k+l*l),j*=m,k*=m,l*=m,d=s*l-t*k,e=t*j-r*l,f=r*k-s*j,m=Math.sqrt(d*d+e*e+f*f),m?(m=1/m,d*=m,e*=m,f*=m):(d=0,e=0,f=0),g=k*f-l*e,h=l*d-j*f,i=j*e-k*d,m=Math.sqrt(g*g+h*h+i*i),m?(m=1/m,g*=m,h*=m,i*=m):(g=0,h=0,i=0),this[0]=d,this[1]=g,this[2]=j,this[3]=0,this[4]=e,this[5]=h,this[6]=k,this[7]=0,this[8]=f,this[9]=i,this[10]=l,this[11]=0,this[12]=-(d*n+e*o+f*q),this[13]=-(g*n+h*o+i*q),this[14]=-(j*n+k*o+l*q),this[15]=1,this)},writable:!0,enumerable:!0,configurable:!0},translate:{value:function(a){return this[12]=this[0]*a.x+this[4]*a.y+this[8]*a.z+this[12],this[13]=this[1]*a.x+this[5]*a.y+this[9]*a.z+this[13],this[14]=this[2]*a.x+this[6]*a.y+this[10]*a.z+this[14],this[15]=this[3]*a.x+this[7]*a.y+this[11]*a.z+this[15],this},writable:!0,enumerable:!0,configurable:!0},rotate:{value:function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A=b.clone();return A.normalize(),c=Math.sin(a),d=Math.cos(a),e=1-d,f=this[0],g=this[1],h=this[2],i=this[3],j=this[4],k=this[5],l=this[6],m=this[7],n=this[8],o=this[9],p=this[10],q=this[11],r=A.x*A.x*e+d,s=A.y*A.x*e+A.z*c,t=A.z*A.x*e-A.y*c,u=A.x*A.y*e-A.z*c,v=A.y*A.y*e+d,w=A.z*A.y*e+A.x*c,x=A.x*A.z*e+A.y*c,y=A.y*A.z*e-A.x*c,z=A.z*A.z*e+d,this[0]=f*r+j*s+n*t,this[1]=g*r+k*s+o*t,this[2]=h*r+l*s+p*t,this[3]=i*r+m*s+q*t,this[4]=f*u+j*v+n*w,this[5]=g*u+k*v+o*w,this[6]=h*u+l*v+p*w,this[7]=i*u+m*v+q*w,this[8]=f*x+j*y+n*z,this[9]=g*x+k*y+o*z,this[10]=h*x+l*y+p*z,this[11]=i*x+m*y+q*z,this},writable:!0,enumerable:!0,configurable:!0},toInverseMat3:{value:function(){var a=this[0],b=this[1],c=this[2],d=this[4],e=this[5],f=this[6],g=this[8],h=this[9],i=this[10],j=i*e-f*h,k=-i*d+f*g,l=h*d-e*g,m=a*j+b*k+c*l;if(!m)return null;var n=1/m,p=new o;return p[0]=j*n,p[1]=(-i*b+c*h)*n,p[2]=(f*b-c*e)*n,p[3]=k*n,p[4]=(i*a-c*g)*n,p[5]=(-f*a+c*d)*n,p[6]=l*n,p[7]=(-h*a+b*g)*n,p[8]=(e*a-b*d)*n,p},writable:!0,enumerable:!0,configurable:!0},rotateX:{value:function(a){this.rotate(a,new r(1,0,0))},writable:!0,enumerable:!0,configurable:!0},rotateY:{value:function(a){this.rotate(a,new r(0,1,0))},writable:!0,enumerable:!0,configurable:!0},rotateZ:{value:function(a){this.rotate(a,new r(0,0,1))},writable:!0,enumerable:!0,configurable:!0},toArray:{value:function(){for(var a=[],b=16;b--;)a[b]=this[b];return a},writable:!0,enumerable:!0,configurable:!0}}),b}(Array),f=function(a,b,c){b&&Object.defineProperties(a,b),c&&Object.defineProperties(a.prototype,c)},r=function(){function a(){var a=void 0===arguments[0]?0:arguments[0],b=void 0===arguments[1]?0:arguments[1],c=void 0===arguments[2]?0:arguments[2];this.x=a,this.y=b,this.z=c}return f(a,null,{clone:{value:function(){return new a(this.x,this.y,this.z)},writable:!0,enumerable:!0,configurable:!0},set:{value:function(a,b,c){this.x=a,this.y=b,this.z=c},writable:!0,enumerable:!0,configurable:!0},add:{value:function(b){b instanceof a?(this.x+=b.x,this.y+=b.y,this.z+=b.z):(this.x+=b,this.y+=b,this.z+=b)},writable:!0,enumerable:!0,configurable:!0},subtract:{value:function(b){b instanceof a?(this.x-=b.x,this.y-=b.y,this.z-=b.z):this.add(-b)},writable:!0,enumerable:!0,configurable:!0},multiply:{value:function(b){b instanceof a?(this.x*=b.x,this.y*=b.y,this.z*=b.z):(this.x*=b,this.y*=b,this.z*=b)},writable:!0,enumerable:!0,configurable:!0},divide:{value:function(b){b instanceof a?(this.x/=b.x,this.y/=b.y,this.z/=b.z):this.multiply(1/b)},writable:!0,enumerable:!0,configurable:!0},distance:{value:function(a){var b=a.x-this.x,c=a.y-this.y,d=a.z-this.z;return Math.sqrt(b*b+c*c+d*d)},writable:!0,enumerable:!0,configurable:!0},getLength:{value:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},writable:!0,enumerable:!0,configurable:!0},normalize:{value:function(){this.divide(this.getLength())},writable:!0,enumerable:!0,configurable:!0},dot:{value:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},writable:!0,enumerable:!0,configurable:!0},cross:{value:function(b){return new a(this.y*b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*b.y-this.y*b.x)},writable:!0,enumerable:!0,configurable:!0},toArray:{value:function(){return[this.x,this.y,this.z]},writable:!0,enumerable:!0,configurable:!0}}),a}(),f=function(a,b,c){b&&Object.defineProperties(a,b),c&&Object.defineProperties(a.prototype,c)},s=0,t=function(){function a(){this.scale=new r,this.position=new r,this.rotation=new r,this.vertices=[],this.vertexNormals=!1,this.vertexIndex=!1,this.vertexColor=!1,this.textureCoords=!1,this.index=s++,this.buffers={},this.drawingMode=i.drawingMode.TRIANGLES,this.darwingFunction=0,this.color=new h,this.shader=!1}return f(a,null,{getMatrix:{value:function(a){var b=new q;return b.lookAt(a.position,a.lookAt,a.up),b.translate(this.position),b.rotateX(this.rotation.x),b.rotateY(this.rotation.y),b.rotateZ(this.rotation.z),b},writable:!0,enumerable:!0,configurable:!0}}),a}(),u=function(){var a=void 0===arguments[0]?640:arguments[0],b=void 0===arguments[1]?480:arguments[1];this.width=a,this.height=b},f=function(a,b,c){b&&Object.defineProperties(a,b),c&&Object.defineProperties(a.prototype,c)},v=function z(a,b,c){var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d){var e=Object.getPrototypeOf(a);return null===e?void 0:z(e,b,c)}if("value"in d&&d.writable)return d.value;var f=d.get;return void 0===f?void 0:f.call(c)},n=function(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(a.__proto__=b)},w=function(a){function b(a,c,d){var e=void 0===arguments[3]?null:arguments[3];v(Object.getPrototypeOf(b.prototype),"constructor",this).call(this,a,c),this.world=d,this.camera=new g,this.camera.aspect=this.width/this.height,this.camera.updatePerspective(),this.canvas=document.createElement("canvas"),this.canvas.setAttribute("width",this.width),this.canvas.setAttribute("height",this.height),this.color=e,this.initGl()}return n(b,a),f(b,null,{initGl:{value:function(){this.gl=this.canvas.getContext("experimental-webgl"),this.gl.viewportWidth=this.canvas.width,this.gl.viewportHeight=this.canvas.height,null!==this.color&&this.gl.clearColor.apply(this.gl,this.color.array),this.gl.enable(this.gl.DEPTH_TEST)},writable:!0,enumerable:!0,configurable:!0},initShapes:{value:function(){for(var a=this.world.children.length;a--;){var b=this.world.children[a];b.shader=new x(this,b),b.buffers.vertices=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,b.buffers.vertices),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(b.vertices),this.gl.STATIC_DRAW),b.buffers.vertices.itemSize=3,b.buffers.vertices.numItems=b.vertices.length/3,b.vertexColor&&(b.buffers.vertexColor=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,b.buffers.vertexColor),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(b.vertexColor),this.gl.STATIC_DRAW),b.buffers.vertexColor.itemSize=4,b.buffers.vertexColor.numItems=b.vertexColor.length),b.vertexNormals&&(b.buffers.normals=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,b.buffers.normals),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(b.vertexNormals),this.gl.STATIC_DRAW),b.buffers.normals.itemSize=3,b.buffers.normals.numItems=b.vertexNormals.length),b.vertexIndex&&(b.buffers.vertexIndex=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,b.buffers.vertexIndex),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(b.vertexIndex),this.gl.STATIC_DRAW),b.buffers.vertexIndex.itemSize=1,b.buffers.vertexIndex.numItems=b.vertexIndex.length)}},writable:!0,enumerable:!0,configurable:!0},draw:{value:function(){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(var a=this.world.children.length;a--;){var b=this.world.children[a],c=b.buffers;b.shader.use(),b.shader.assignValues(),b.darwingFunction===i.drawingFunctions.ELEMENTS?this.gl.drawElements(b.drawingMode,c.vertexIndex.numItems,this.gl.UNSIGNED_SHORT,0):b.darwingFunction===i.drawingFunctions.ARRAYS&&this.gl.drawArrays(b.drawingMode,0,c.vertices.numItems)}},writable:!0,enumerable:!0,configurable:!0}}),b}(u),f=function(a,b,c){b&&Object.defineProperties(a,b),c&&Object.defineProperties(a.prototype,c)},x=function(){function a(a,b){this.object=b,this.renderer=a,this.uniforms={},this.attributes={},this.program=!1,this.gl=a.gl,this.create()}return f(a,null,{vertex:{value:function(){var a="",b="";a+=y.vertex.pars["default"],b+=y.vertex.main["default"];for(var c in this.renderer.world.lights){var d=this.renderer.world.lights[c],e=d.index;a+=y.vertex.pars.directionalLight(e),b+=y.vertex.main.directionalLight(e)}var f=""+a+" void main() { "+b+" }";return this.compile(f,WebGLRenderingContext.VERTEX_SHADER)},writable:!0,enumerable:!0,configurable:!0},fragment:{value:function(){var a="",b="";a+=y.fragment.pars["default"],a+=y.fragment.pars.color,b+=y.fragment.main.color,this.renderer.world.lights.length>0&&(a+=y.fragment.pars.directionalLight,b+=y.fragment.main.directionalLight);var c=""+a+" void main() { "+b+" }";return this.compile(c,WebGLRenderingContext.FRAGMENT_SHADER)},writable:!0,enumerable:!0,configurable:!0},assignValues:{value:function(){var a=this.object,b=a.buffers;this.gl.bindBuffer(this.gl.ARRAY_BUFFER,b.vertices),this.attributeValue("aVertexPosition",b.vertices);try{this.gl.bindBuffer(this.gl.ARRAY_BUFFER,b.normals),this.attributeValue("aVertexNormal",b.normals)}catch(c){}var d=a.getMatrix(this.renderer.camera);this.uniformValue("uPMatrix",this.renderer.camera.matrix.toArray()),this.uniformValue("uMVMatrix",a.getMatrix(this.renderer.camera).toArray()),this.uniformValue("uvColor",a.color.toArray());for(var e in this.renderer.world.lights){var f=this.renderer.world.lights[e],g=f.index;this.uniformValue("uLightingDirection"+g,f.direction.toArray()),this.uniformValue("uDirectionalColor"+g,f.color.array)}var h=d.toInverseMat3().transpose();this.uniformValue("uNMatrix",h.toArray())},writable:!0,enumerable:!0,configurable:!0},uniformLocation:{value:function(a){this.uniforms[a]=this.gl.getUniformLocation(this.program,a)},writable:!0,enumerable:!0,configurable:!0},attributeLocation:{value:function(a){if(this.attributes[a]=this.gl.getAttribLocation(this.program,a),-1===this.attributes[a])throw"Attribute "+a+" cannot be located";this.gl.enableVertexAttribArray(this.attributes[a])},writable:!0,enumerable:!0,configurable:!0},uniformValue:{value:function(a,b){var c=this.gl;"undefined"==typeof this.uniforms[a]&&this.uniformLocation(a),4===b.length?c.uniform4fv(this.uniforms[a],b):3===b.length?c.uniform3fv(this.uniforms[a],b):9===b.length?c.uniformMatrix3fv(this.uniforms[a],!1,b):16===b.length&&c.uniformMatrix4fv(this.uniforms[a],!1,b)},writable:!0,enumerable:!0,configurable:!0},attributeValue:{value:function(a,b){this.gl;"undefined"==typeof this.attributes[a]&&this.attributeLocation(a),-1!==this.attributes[a]&&this.gl.vertexAttribPointer(this.attributes[a],b.itemSize,this.gl.FLOAT,!1,0,0)},writable:!0,enumerable:!0,configurable:!0},use:{value:function(){this.gl.useProgram(this.program)},writable:!0,enumerable:!0,configurable:!0},compile:{value:function(a,b){var c=this.gl,d=c.createShader(b);c.shaderSource(d,a),c.compileShader(d);var e=c.getShaderParameter(d,c.COMPILE_STATUS);if(!e)throw"Could not compile shader:"+c.getShaderInfoLog(d);return d},writable:!0,enumerable:!0,configurable:!0},create:{value:function(){var a=this.gl,b=a.createProgram();a.attachShader(b,this.vertex()),a.attachShader(b,this.fragment()),a.linkProgram(b);var c=a.getProgramParameter(b,a.LINK_STATUS);if(!c)throw"Program failed to link:"+a.getProgramInfoLog(b);return this.program=b,b},writable:!0,enumerable:!0,configurable:!0}}),a}(),y={vertex:{pars:{"default":"attribute vec3 aVertexNormal; attribute vec3 aVertexPosition; uniform mat4 uMVMatrix; uniform mat4 uPMatrix; uniform mat3 uNMatrix;",directionalLight:function(a){return"varying vec3 vLightWeighting; uniform vec3 uLightingDirection"+a+"; uniform vec3 uDirectionalColor"+a+";"}},main:{"default":"gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);",directionalLight:function(a){return"vec3 transformedNormal = uNMatrix * aVertexNormal; float directionalLightWeighting"+a+" = max(dot(transformedNormal, uLightingDirection"+a+"), 0.0); vLightWeighting = uDirectionalColor"+a+" * directionalLightWeighting"+a+";"}}},fragment:{pars:{"default":"precision mediump float;",color:"uniform vec3 uvColor;",directionalLight:"varying vec3 vLightWeighting;"},main:{color:"",directionalLight:"gl_FragColor = vec4(vLightWeighting + uvColor, 1.0);"}}};a.LiThree={Renderer:u,WebGLRenderer:w,World:k,Object3D:t,Camera:g,Color:h,Math:{Vector3:r,Matrix4:q},DirectionalLight:m,ObjectFactory:{Circle:b,Cylinder:d,Cube:c,Sphere:e}}}(this);