提交 f849be93 编写于 作者: M Mr.doob

Updated builds.

上级 af6018ed
......@@ -27068,6 +27068,12 @@ THREE.GeometryUtils = {
var uv = uvs2[ i ], uvCopy = [];
if ( uv === undefined ) {
continue;
}
for ( var j = 0, jl = uv.length; j < jl; j ++ ) {
uvCopy.push( new THREE.Vector2( uv[ j ].x, uv[ j ].y ) );
......@@ -36535,7 +36541,7 @@ THREE.ShadowMapPlugin = function () {
virtualLight.originalCamera = camera;
var gyro = new THREE.Gyroscope();
gyro.position = light.shadowCascadeOffset;
gyro.position.copy( light.shadowCascadeOffset );
gyro.add( virtualLight );
gyro.add( virtualLight.target );
......
......@@ -522,7 +522,7 @@ b=["precision "+e.precision+" float;","precision "+e.precision+" int;",e.bumpMap
"#define "+p:"",e.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",e.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");h=new THREE.WebGLShader(f,f.VERTEX_SHADER,u+h);g=new THREE.WebGLShader(f,f.FRAGMENT_SHADER,b+g);f.attachShader(n,h);f.attachShader(n,g);void 0!==d&&f.bindAttribLocation(n,0,d);f.linkProgram(n);!1===f.getProgramParameter(n,f.LINK_STATUS)&&(console.error("Could not initialise shader"),console.error("gl.VALIDATE_STATUS",
f.getProgramParameter(n,f.VALIDATE_STATUS)),console.error("gl.getError()",f.getError()));""!==f.getProgramInfoLog(n)&&console.error("gl.getProgramInfoLog()",f.getProgramInfoLog(n));f.deleteShader(h);f.deleteShader(g);d="viewMatrix modelViewMatrix projectionMatrix normalMatrix modelMatrix cameraPosition morphTargetInfluences".split(" ");e.useVertexTexture?(d.push("boneTexture"),d.push("boneTextureWidth"),d.push("boneTextureHeight")):d.push("boneGlobalMatrices");for(var q in k)d.push(q);k=d;q={};d=
0;for(b=k.length;d<b;d++)p=k[d],q[p]=f.getUniformLocation(n,p);this.uniforms=q;d="position normal uv uv2 tangent color skinIndex skinWeight lineDistance".split(" ");for(k=0;k<e.maxMorphTargets;k++)d.push("morphTarget"+k);for(k=0;k<e.maxMorphNormals;k++)d.push("morphNormal"+k);for(var v in l)d.push(v);e=d;l={};v=0;for(k=e.length;v<k;v++)q=e[v],l[q]=f.getAttribLocation(n,q);this.attributes=l;this.id=a++;this.code=c;this.usedTimes=1;this.program=n;this.vertexShader=h;this.fragmentShader=g;return this}}();THREE.WebGLShader=function(){var a=function(a){a=a.split("\n");for(var c=0;c<a.length;c++)a[c]=c+1+": "+a[c];return a.join("\n")};return function(b,c,d){c=b.createShader(c);b.shaderSource(c,d);b.compileShader(c);!1===b.getShaderParameter(c,b.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile.");""!==b.getShaderInfoLog(c)&&(console.error("THREE.WebGLShader:","gl.getShaderInfoLog()",b.getShaderInfoLog(c)),console.error(a(d)));return c}}();THREE.RenderableVertex=function(){this.position=new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};THREE.RenderableFace=function(){this.id=0;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.normalModel=new THREE.Vector3;this.vertexNormalsModel=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.vertexNormalsLength=0;this.material=this.color=null;this.uvs=[[]];this.z=0};THREE.RenderableObject=function(){this.id=0;this.object=null;this.z=0};THREE.RenderableSprite=function(){this.id=0;this.object=null;this.rotation=this.z=this.y=this.x=0;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.id=0;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.vertexColors=[new THREE.Color,new THREE.Color];this.material=null;this.z=0};THREE.GeometryUtils={merge:function(a,b,c){var d,e,f=a.vertices.length,g=b instanceof THREE.Mesh?b.geometry:b,h=a.vertices,k=g.vertices,l=a.faces,n=g.faces;a=a.faceVertexUvs[0];g=g.faceVertexUvs[0];void 0===c&&(c=0);b instanceof THREE.Mesh&&(b.matrixAutoUpdate&&b.updateMatrix(),d=b.matrix,e=(new THREE.Matrix3).getNormalMatrix(d));b=0;for(var p=k.length;b<p;b++){var r=k[b].clone();d&&r.applyMatrix4(d);h.push(r)}b=0;for(p=n.length;b<p;b++){var k=n[b],s,u=k.vertexNormals,q=k.vertexColors,r=new THREE.Face3(k.a+
f,k.b+f,k.c+f);r.normal.copy(k.normal);e&&r.normal.applyMatrix3(e).normalize();d=0;for(h=u.length;d<h;d++)s=u[d].clone(),e&&s.applyMatrix3(e).normalize(),r.vertexNormals.push(s);r.color.copy(k.color);d=0;for(h=q.length;d<h;d++)s=q[d],r.vertexColors.push(s.clone());r.materialIndex=k.materialIndex+c;l.push(r)}b=0;for(p=g.length;b<p;b++){c=g[b];e=[];d=0;for(h=c.length;d<h;d++)e.push(new THREE.Vector2(c[d].x,c[d].y));a.push(e)}},randomPointInTriangle:function(){var a=new THREE.Vector3;return function(b,
f,k.b+f,k.c+f);r.normal.copy(k.normal);e&&r.normal.applyMatrix3(e).normalize();d=0;for(h=u.length;d<h;d++)s=u[d].clone(),e&&s.applyMatrix3(e).normalize(),r.vertexNormals.push(s);r.color.copy(k.color);d=0;for(h=q.length;d<h;d++)s=q[d],r.vertexColors.push(s.clone());r.materialIndex=k.materialIndex+c;l.push(r)}b=0;for(p=g.length;b<p;b++)if(c=g[b],e=[],void 0!==c){d=0;for(h=c.length;d<h;d++)e.push(new THREE.Vector2(c[d].x,c[d].y));a.push(e)}},randomPointInTriangle:function(){var a=new THREE.Vector3;return function(b,
c,d){var e=new THREE.Vector3,f=THREE.Math.random16(),g=THREE.Math.random16();1<f+g&&(f=1-f,g=1-g);var h=1-f-g;e.copy(b);e.multiplyScalar(f);a.copy(c);a.multiplyScalar(g);e.add(a);a.copy(d);a.multiplyScalar(h);e.add(a);return e}}(),randomPointInFace:function(a,b,c){return THREE.GeometryUtils.randomPointInTriangle(b.vertices[a.a],b.vertices[a.b],b.vertices[a.c])},randomPointsInGeometry:function(a,b){function c(a){function b(c,d){if(d<c)return c;var e=c+Math.floor((d-c)/2);return l[e]>a?b(c,e-1):l[e]<
a?b(e+1,d):e}return b(0,l.length-1)}var d,e,f=a.faces,g=a.vertices,h=f.length,k=0,l=[],n,p,r;for(e=0;e<h;e++)d=f[e],n=g[d.a],p=g[d.b],r=g[d.c],d._area=THREE.GeometryUtils.triangleArea(n,p,r),k+=d._area,l[e]=k;d=[];for(e=0;e<b;e++)g=THREE.Math.random16()*k,g=c(g),d[e]=THREE.GeometryUtils.randomPointInFace(f[g],a,!0);return d},triangleArea:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d,e){a.subVectors(d,c);b.subVectors(e,c);a.cross(b);return 0.5*a.length()}}(),center:function(a){a.computeBoundingBox();
var b=a.boundingBox,c=new THREE.Vector3;c.addVectors(b.min,b.max);c.multiplyScalar(-0.5);a.applyMatrix((new THREE.Matrix4).makeTranslation(c.x,c.y,c.z));a.computeBoundingBox();return c}};THREE.ImageUtils={crossOrigin:void 0,loadTexture:function(a,b,c,d){d=new THREE.ImageLoader;d.crossOrigin=this.crossOrigin;var e=new THREE.Texture(void 0,b);b=d.load(a,function(){e.needsUpdate=!0;c&&c(e)});e.image=b;e.sourceFile=a;return e},loadCompressedTexture:function(a,b,c,d){var e=new THREE.CompressedTexture;e.mapping=b;var f=new XMLHttpRequest;f.onload=function(){var a=THREE.ImageUtils.parseDDS(f.response,!0);e.format=a.format;e.mipmaps=a.mipmaps;e.image.width=a.width;e.image.height=a.height;
......@@ -698,14 +698,14 @@ N.opacity),b.uniform3f(y.color,N.color.r,N.color.g,N.color.b),c.setBlending(N.bl
vertexShader:g.vertexShader,uniforms:h,skinning:!0});f=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:!0,skinning:!0});c._shadowPass=!0;d._shadowPass=!0;e._shadowPass=!0;f._shadowPass=!0};this.render=function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(p,r){var s,u,q,v,w,t,x,H,G,P=[];v=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);a.frontFace(a.CCW);b.shadowMapCullFace===THREE.CullFaceFront?
a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(!0);s=0;for(u=p.__lights.length;s<u;s++)if(q=p.__lights[s],q.castShadow)if(q instanceof THREE.DirectionalLight&&q.shadowCascade)for(w=0;w<q.shadowCascadeCount;w++){var F;if(q.shadowCascadeArray[w])F=q.shadowCascadeArray[w];else{G=q;x=w;F=new THREE.DirectionalLight;F.isVirtual=!0;F.onlyShadow=!0;F.castShadow=!0;F.shadowCameraNear=G.shadowCameraNear;F.shadowCameraFar=G.shadowCameraFar;F.shadowCameraLeft=G.shadowCameraLeft;F.shadowCameraRight=G.shadowCameraRight;
F.shadowCameraBottom=G.shadowCameraBottom;F.shadowCameraTop=G.shadowCameraTop;F.shadowCameraVisible=G.shadowCameraVisible;F.shadowDarkness=G.shadowDarkness;F.shadowBias=G.shadowCascadeBias[x];F.shadowMapWidth=G.shadowCascadeWidth[x];F.shadowMapHeight=G.shadowCascadeHeight[x];F.pointsWorld=[];F.pointsFrustum=[];H=F.pointsWorld;t=F.pointsFrustum;for(var C=0;8>C;C++)H[C]=new THREE.Vector3,t[C]=new THREE.Vector3;H=G.shadowCascadeNearZ[x];G=G.shadowCascadeFarZ[x];t[0].set(-1,-1,H);t[1].set(1,-1,H);t[2].set(-1,
1,H);t[3].set(1,1,H);t[4].set(-1,-1,G);t[5].set(1,-1,G);t[6].set(-1,1,G);t[7].set(1,1,G);F.originalCamera=r;t=new THREE.Gyroscope;t.position=q.shadowCascadeOffset;t.add(F);t.add(F.target);r.add(t);q.shadowCascadeArray[w]=F;console.log("Created virtualLight",F)}x=q;H=w;G=x.shadowCascadeArray[H];G.position.copy(x.position);G.target.position.copy(x.target.position);G.lookAt(G.target);G.shadowCameraVisible=x.shadowCameraVisible;G.shadowDarkness=x.shadowDarkness;G.shadowBias=x.shadowCascadeBias[H];t=x.shadowCascadeNearZ[H];
x=x.shadowCascadeFarZ[H];G=G.pointsFrustum;G[0].z=t;G[1].z=t;G[2].z=t;G[3].z=t;G[4].z=x;G[5].z=x;G[6].z=x;G[7].z=x;P[v]=F;v++}else P[v]=q,v++;s=0;for(u=P.length;s<u;s++){q=P[s];q.shadowMap||(w=THREE.LinearFilter,b.shadowMapType===THREE.PCFSoftShadowMap&&(w=THREE.NearestFilter),q.shadowMap=new THREE.WebGLRenderTarget(q.shadowMapWidth,q.shadowMapHeight,{minFilter:w,magFilter:w,format:THREE.RGBAFormat}),q.shadowMapSize=new THREE.Vector2(q.shadowMapWidth,q.shadowMapHeight),q.shadowMatrix=new THREE.Matrix4);
if(!q.shadowCamera){if(q instanceof THREE.SpotLight)q.shadowCamera=new THREE.PerspectiveCamera(q.shadowCameraFov,q.shadowMapWidth/q.shadowMapHeight,q.shadowCameraNear,q.shadowCameraFar);else if(q instanceof THREE.DirectionalLight)q.shadowCamera=new THREE.OrthographicCamera(q.shadowCameraLeft,q.shadowCameraRight,q.shadowCameraTop,q.shadowCameraBottom,q.shadowCameraNear,q.shadowCameraFar);else{console.error("Unsupported light type for shadow");continue}p.add(q.shadowCamera);!0===p.autoUpdate&&p.updateMatrixWorld()}q.shadowCameraVisible&&
!q.cameraHelper&&(q.cameraHelper=new THREE.CameraHelper(q.shadowCamera),q.shadowCamera.add(q.cameraHelper));if(q.isVirtual&&F.originalCamera==r){w=r;v=q.shadowCamera;t=q.pointsFrustum;G=q.pointsWorld;k.set(Infinity,Infinity,Infinity);l.set(-Infinity,-Infinity,-Infinity);for(x=0;8>x;x++)H=G[x],H.copy(t[x]),THREE.ShadowMapPlugin.__projector.unprojectVector(H,w),H.applyMatrix4(v.matrixWorldInverse),H.x<k.x&&(k.x=H.x),H.x>l.x&&(l.x=H.x),H.y<k.y&&(k.y=H.y),H.y>l.y&&(l.y=H.y),H.z<k.z&&(k.z=H.z),H.z>l.z&&
(l.z=H.z);v.left=k.x;v.right=l.x;v.top=l.y;v.bottom=k.y;v.updateProjectionMatrix()}v=q.shadowMap;t=q.shadowMatrix;w=q.shadowCamera;w.position.setFromMatrixPosition(q.matrixWorld);n.setFromMatrixPosition(q.target.matrixWorld);w.lookAt(n);w.updateMatrixWorld();w.matrixWorldInverse.getInverse(w.matrixWorld);q.cameraHelper&&(q.cameraHelper.visible=q.shadowCameraVisible);q.shadowCameraVisible&&q.cameraHelper.update();t.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);t.multiply(w.projectionMatrix);t.multiply(w.matrixWorldInverse);
h.multiplyMatrices(w.projectionMatrix,w.matrixWorldInverse);g.setFromMatrix(h);b.setRenderTarget(v);b.clear();G=p.__webglObjects;q=0;for(v=G.length;q<v;q++)x=G[q],t=x.object,x.render=!1,!t.visible||!t.castShadow||(t instanceof THREE.Mesh||t instanceof THREE.ParticleSystem)&&t.frustumCulled&&!g.intersectsObject(t)||(t._modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,t.matrixWorld),x.render=!0);q=0;for(v=G.length;q<v;q++)x=G[q],x.render&&(t=x.object,x=x.buffer,C=t.material instanceof THREE.MeshFaceMaterial?
t.material.materials[0]:t.material,H=void 0!==t.geometry.morphTargets&&0<t.geometry.morphTargets.length&&C.morphTargets,C=t instanceof THREE.SkinnedMesh&&C.skinning,H=t.customDepthMaterial?t.customDepthMaterial:C?H?f:e:H?d:c,x instanceof THREE.BufferGeometry?b.renderBufferDirect(w,p.__lights,null,H,x,t):b.renderBuffer(w,p.__lights,null,H,x,t));G=p.__webglObjectsImmediate;q=0;for(v=G.length;q<v;q++)x=G[q],t=x.object,t.visible&&t.castShadow&&(t._modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,
t.matrixWorld),b.renderImmediateObject(w,p.__lights,null,c,t))}s=b.getClearColor();u=b.getClearAlpha();a.clearColor(s.r,s.g,s.b,u);a.enable(a.BLEND);b.shadowMapCullFace===THREE.CullFaceFront&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;THREE.SpritePlugin=function(){var a,b,c,d,e,f,g,h,k,l,n,p,r,s,u,q,v;function w(a,b){return a.z!==b.z?b.z-a.z:b.id-a.id}var t,x,H,G,P,F,C,K;this.init=function(w){t=w.context;x=w;G=new Float32Array([-0.5,-0.5,0,0,0.5,-0.5,1,0,0.5,0.5,1,1,-0.5,0.5,0,1]);P=new Uint16Array([0,1,2,0,2,3]);F=t.createBuffer();C=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,F);t.bufferData(t.ARRAY_BUFFER,G,t.STATIC_DRAW);t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,C);t.bufferData(t.ELEMENT_ARRAY_BUFFER,P,t.STATIC_DRAW);w=t.createProgram();
1,H);t[3].set(1,1,H);t[4].set(-1,-1,G);t[5].set(1,-1,G);t[6].set(-1,1,G);t[7].set(1,1,G);F.originalCamera=r;t=new THREE.Gyroscope;t.position.copy(q.shadowCascadeOffset);t.add(F);t.add(F.target);r.add(t);q.shadowCascadeArray[w]=F;console.log("Created virtualLight",F)}x=q;H=w;G=x.shadowCascadeArray[H];G.position.copy(x.position);G.target.position.copy(x.target.position);G.lookAt(G.target);G.shadowCameraVisible=x.shadowCameraVisible;G.shadowDarkness=x.shadowDarkness;G.shadowBias=x.shadowCascadeBias[H];
t=x.shadowCascadeNearZ[H];x=x.shadowCascadeFarZ[H];G=G.pointsFrustum;G[0].z=t;G[1].z=t;G[2].z=t;G[3].z=t;G[4].z=x;G[5].z=x;G[6].z=x;G[7].z=x;P[v]=F;v++}else P[v]=q,v++;s=0;for(u=P.length;s<u;s++){q=P[s];q.shadowMap||(w=THREE.LinearFilter,b.shadowMapType===THREE.PCFSoftShadowMap&&(w=THREE.NearestFilter),q.shadowMap=new THREE.WebGLRenderTarget(q.shadowMapWidth,q.shadowMapHeight,{minFilter:w,magFilter:w,format:THREE.RGBAFormat}),q.shadowMapSize=new THREE.Vector2(q.shadowMapWidth,q.shadowMapHeight),q.shadowMatrix=
new THREE.Matrix4);if(!q.shadowCamera){if(q instanceof THREE.SpotLight)q.shadowCamera=new THREE.PerspectiveCamera(q.shadowCameraFov,q.shadowMapWidth/q.shadowMapHeight,q.shadowCameraNear,q.shadowCameraFar);else if(q instanceof THREE.DirectionalLight)q.shadowCamera=new THREE.OrthographicCamera(q.shadowCameraLeft,q.shadowCameraRight,q.shadowCameraTop,q.shadowCameraBottom,q.shadowCameraNear,q.shadowCameraFar);else{console.error("Unsupported light type for shadow");continue}p.add(q.shadowCamera);!0===
p.autoUpdate&&p.updateMatrixWorld()}q.shadowCameraVisible&&!q.cameraHelper&&(q.cameraHelper=new THREE.CameraHelper(q.shadowCamera),q.shadowCamera.add(q.cameraHelper));if(q.isVirtual&&F.originalCamera==r){w=r;v=q.shadowCamera;t=q.pointsFrustum;G=q.pointsWorld;k.set(Infinity,Infinity,Infinity);l.set(-Infinity,-Infinity,-Infinity);for(x=0;8>x;x++)H=G[x],H.copy(t[x]),THREE.ShadowMapPlugin.__projector.unprojectVector(H,w),H.applyMatrix4(v.matrixWorldInverse),H.x<k.x&&(k.x=H.x),H.x>l.x&&(l.x=H.x),H.y<k.y&&
(k.y=H.y),H.y>l.y&&(l.y=H.y),H.z<k.z&&(k.z=H.z),H.z>l.z&&(l.z=H.z);v.left=k.x;v.right=l.x;v.top=l.y;v.bottom=k.y;v.updateProjectionMatrix()}v=q.shadowMap;t=q.shadowMatrix;w=q.shadowCamera;w.position.setFromMatrixPosition(q.matrixWorld);n.setFromMatrixPosition(q.target.matrixWorld);w.lookAt(n);w.updateMatrixWorld();w.matrixWorldInverse.getInverse(w.matrixWorld);q.cameraHelper&&(q.cameraHelper.visible=q.shadowCameraVisible);q.shadowCameraVisible&&q.cameraHelper.update();t.set(0.5,0,0,0.5,0,0.5,0,0.5,
0,0,0.5,0.5,0,0,0,1);t.multiply(w.projectionMatrix);t.multiply(w.matrixWorldInverse);h.multiplyMatrices(w.projectionMatrix,w.matrixWorldInverse);g.setFromMatrix(h);b.setRenderTarget(v);b.clear();G=p.__webglObjects;q=0;for(v=G.length;q<v;q++)x=G[q],t=x.object,x.render=!1,!t.visible||!t.castShadow||(t instanceof THREE.Mesh||t instanceof THREE.ParticleSystem)&&t.frustumCulled&&!g.intersectsObject(t)||(t._modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,t.matrixWorld),x.render=!0);q=0;for(v=G.length;q<
v;q++)x=G[q],x.render&&(t=x.object,x=x.buffer,C=t.material instanceof THREE.MeshFaceMaterial?t.material.materials[0]:t.material,H=void 0!==t.geometry.morphTargets&&0<t.geometry.morphTargets.length&&C.morphTargets,C=t instanceof THREE.SkinnedMesh&&C.skinning,H=t.customDepthMaterial?t.customDepthMaterial:C?H?f:e:H?d:c,x instanceof THREE.BufferGeometry?b.renderBufferDirect(w,p.__lights,null,H,x,t):b.renderBuffer(w,p.__lights,null,H,x,t));G=p.__webglObjectsImmediate;q=0;for(v=G.length;q<v;q++)x=G[q],
t=x.object,t.visible&&t.castShadow&&(t._modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,t.matrixWorld),b.renderImmediateObject(w,p.__lights,null,c,t))}s=b.getClearColor();u=b.getClearAlpha();a.clearColor(s.r,s.g,s.b,u);a.enable(a.BLEND);b.shadowMapCullFace===THREE.CullFaceFront&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;THREE.SpritePlugin=function(){var a,b,c,d,e,f,g,h,k,l,n,p,r,s,u,q,v;function w(a,b){return a.z!==b.z?b.z-a.z:b.id-a.id}var t,x,H,G,P,F,C,K;this.init=function(w){t=w.context;x=w;G=new Float32Array([-0.5,-0.5,0,0,0.5,-0.5,1,0,0.5,0.5,1,1,-0.5,0.5,0,1]);P=new Uint16Array([0,1,2,0,2,3]);F=t.createBuffer();C=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,F);t.bufferData(t.ARRAY_BUFFER,G,t.STATIC_DRAW);t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,C);t.bufferData(t.ELEMENT_ARRAY_BUFFER,P,t.STATIC_DRAW);w=t.createProgram();
var y=t.createShader(t.VERTEX_SHADER),J=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(y,["precision "+x.getPrecision()+" float;","uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position * scale;\nvec2 rotatedPosition;\nrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\nrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\nvec4 finalPosition;\nfinalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition;\nfinalPosition = projectionMatrix * finalPosition;\ngl_Position = finalPosition;\n}"].join("\n"));
t.shaderSource(J,["precision "+x.getPrecision()+" float;","uniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\nif ( texture.a < alphaTest ) discard;\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\nif ( fogType > 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n"));
t.compileShader(y);t.compileShader(J);t.attachShader(w,y);t.attachShader(w,J);t.linkProgram(w);K=w;q=t.getAttribLocation(K,"position");v=t.getAttribLocation(K,"uv");a=t.getUniformLocation(K,"uvOffset");b=t.getUniformLocation(K,"uvScale");c=t.getUniformLocation(K,"rotation");d=t.getUniformLocation(K,"scale");e=t.getUniformLocation(K,"color");f=t.getUniformLocation(K,"map");g=t.getUniformLocation(K,"opacity");h=t.getUniformLocation(K,"modelViewMatrix");k=t.getUniformLocation(K,"projectionMatrix");l=
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册