|
@@ -144,16 +144,16 @@ b.STATIC_DRAW);m.__webGLNormalBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFE
|
|
|
b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,new Uint16Array(i),b.STATIC_DRAW);m.__webGLFaceCount=v.length;m.__webGLLineCount=i.length}};this.renderBuffer=function(e,g){var n,h,l,q,p,s,A,D,B,m;if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){n=e.color;h=e.opacity;q=e.wireframe;p=e.wireframe_linewidth;A=e.map;D=e.env_map;s=e.combine==THREE.Mix;l=e.reflectivity;m=e.env_map&&e.env_map.mapping==
|
|
|
THREE.RefractionMap;B=e.refraction_ratio;b.uniform4f(d.mColor,n.r*h,n.g*h,n.b*h,h);b.uniform1i(d.mixEnvMap,s);b.uniform1f(d.mReflectivity,l);b.uniform1i(d.useRefract,m);b.uniform1f(d.mRefractionRatio,B)}if(e instanceof THREE.MeshNormalMaterial){h=e.opacity;b.uniform1f(d.mOpacity,h);b.uniform1i(d.material,4)}else if(e instanceof THREE.MeshDepthMaterial){h=e.opacity;q=e.wireframe;p=e.wireframe_linewidth;b.uniform1f(d.mOpacity,h);b.uniform1f(d.m2Near,e.__2near);b.uniform1f(d.mFarPlusNear,e.__farPlusNear);
|
|
|
b.uniform1f(d.mFarMinusNear,e.__farMinusNear);b.uniform1i(d.material,3)}else if(e instanceof THREE.MeshPhongMaterial){n=e.ambient;l=e.specular;s=e.shininess;b.uniform4f(d.mAmbient,n.r,n.g,n.b,h);b.uniform4f(d.mSpecular,l.r,l.g,l.b,h);b.uniform1f(d.mShininess,s);b.uniform1i(d.material,2)}else if(e instanceof THREE.MeshLambertMaterial)b.uniform1i(d.material,1);else e instanceof THREE.MeshBasicMaterial&&b.uniform1i(d.material,0);if(A){if(!e.__webGLTexture&&e.map.image.loaded){e.__webGLTexture=b.createTexture();
|
|
|
-b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.map.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.uniform1i(d.tMap,0);b.uniform1i(d.enableMap,1)}else b.uniform1i(d.enableMap,0);if(D){if(e.env_map&&e.env_map instanceof
|
|
|
-THREE.TextureCube&&e.env_map.image.length==6){if(!e.__webGLTextureCube&&!e.__cubeMapInitialized&&e.env_map.image.loadCount==6){e.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,e.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);
|
|
|
-b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[0]);b.texImage2D(b.TEXTURE_CUBE_MAP_NEGATIVE_X,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[1]);b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_Y,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[2]);b.texImage2D(b.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[3]);b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_Z,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[4]);b.texImage2D(b.TEXTURE_CUBE_MAP_NEGATIVE_Z,
|
|
|
-0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[5]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);e.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_CUBE_MAP,e.__webGLTextureCube);b.uniform1i(d.tCube,1)}b.uniform1i(d.enableCubeMap,1)}else b.uniform1i(d.enableCubeMap,0);b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(d.position,3,b.FLOAT,false,0,0);b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,
|
|
|
-3,b.FLOAT,false,0,0);if(A){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.enableVertexAttribArray(d.uv);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0)}else b.disableVertexAttribArray(d.uv);if(q){b.lineWidth(p);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(e,g,n){var h,l,
|
|
|
-q,p,s;q=0;for(p=e.material.length;q<p;q++){h=e.material[q];if(h instanceof THREE.MeshFaceMaterial){h=0;for(l=g.material.length;h<l;h++)if((s=g.material[h])&&s.blending==n){this.setBlending(s.blending);this.renderBuffer(s,g)}}else if((s=h)&&s.blending==n){this.setBlending(s.blending);this.renderBuffer(s,g)}}};this.render=function(e,g){var n,h;this.initWebGLObjects(e);this.autoClear&&this.clear();g.autoUpdateMatrix&&g.updateMatrix();b.uniform3f(d.cameraPosition,g.position.x,g.position.y,g.position.z);
|
|
|
-this.setupLights(e);n=0;for(h=e.__webGLObjects.length;n<h;n++){webGLObject=e.__webGLObjects[n];this.setupMatrices(webGLObject.__object,g);this.renderPass(webGLObject.__object,webGLObject,THREE.NormalBlending)}n=0;for(h=e.__webGLObjects.length;n<h;n++){webGLObject=e.__webGLObjects[n];this.setupMatrices(webGLObject.__object,g);this.renderPass(webGLObject.__object,webGLObject,THREE.AdditiveBlending);this.renderPass(webGLObject.__object,webGLObject,THREE.SubtractiveBlending)}};this.initWebGLObjects=function(e){var g,
|
|
|
-n,h,l,q;if(!e.__webGLObjects)e.__webGLObjects=[];g=0;for(n=e.objects.length;g<n;g++){h=e.objects[g];if(h instanceof THREE.Mesh)for(l in h.materialFaceGroup){q=h.materialFaceGroup[l];if(!q.__webGLVertexBuffer){this.createBuffers(h,l);q.__object=h;e.__webGLObjects.push(q)}}}};this.setupMatrices=function(e,g){e.autoUpdateMatrix&&e.updateMatrix();j.multiply(g.matrix,e.matrix);d.viewMatrixArray=new Float32Array(g.matrix.flatten());d.modelViewMatrixArray=new Float32Array(j.flatten());d.projectionMatrixArray=
|
|
|
-new Float32Array(g.projectionMatrix.flatten());o=THREE.Matrix4.makeInvert3x3(j).transpose();d.normalMatrixArray=new Float32Array(o.m);b.uniformMatrix4fv(d.viewMatrix,false,d.viewMatrixArray);b.uniformMatrix4fv(d.modelViewMatrix,false,d.modelViewMatrixArray);b.uniformMatrix4fv(d.projectionMatrix,false,d.projectionMatrixArray);b.uniformMatrix3fv(d.normalMatrix,false,d.normalMatrixArray);b.uniformMatrix4fv(d.objMatrix,false,new Float32Array(e.matrix.flatten()))};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);
|
|
|
-b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,g){if(e){!g||g=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)}};
|
|
|
+b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.map.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);
|
|
|
+b.uniform1i(d.tMap,0);b.uniform1i(d.enableMap,1)}else b.uniform1i(d.enableMap,0);if(D){if(e.env_map&&e.env_map instanceof THREE.TextureCube&&e.env_map.image.length==6){if(!e.__webGLTextureCube&&!e.__cubeMapInitialized&&e.env_map.image.loadCount==6){e.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,e.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,
|
|
|
+b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[0]);b.texImage2D(b.TEXTURE_CUBE_MAP_NEGATIVE_X,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[1]);b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_Y,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[2]);b.texImage2D(b.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[3]);b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_Z,
|
|
|
+0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[4]);b.texImage2D(b.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[5]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);e.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_CUBE_MAP,e.__webGLTextureCube);b.uniform1i(d.tCube,1)}b.uniform1i(d.enableCubeMap,1)}else b.uniform1i(d.enableCubeMap,0);b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(d.position,
|
|
|
+3,b.FLOAT,false,0,0);b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);if(A){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.enableVertexAttribArray(d.uv);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0)}else b.disableVertexAttribArray(d.uv);if(q){b.lineWidth(p);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,
|
|
|
+g.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(e,g,n){var h,l,q,p,s;q=0;for(p=e.material.length;q<p;q++){h=e.material[q];if(h instanceof THREE.MeshFaceMaterial){h=0;for(l=g.material.length;h<l;h++)if((s=g.material[h])&&s.blending==n){this.setBlending(s.blending);this.renderBuffer(s,g)}}else if((s=h)&&s.blending==n){this.setBlending(s.blending);this.renderBuffer(s,g)}}};this.render=function(e,g){var n,h;this.initWebGLObjects(e);this.autoClear&&this.clear();g.autoUpdateMatrix&&g.updateMatrix();
|
|
|
+b.uniform3f(d.cameraPosition,g.position.x,g.position.y,g.position.z);this.setupLights(e);n=0;for(h=e.__webGLObjects.length;n<h;n++){webGLObject=e.__webGLObjects[n];this.setupMatrices(webGLObject.__object,g);this.renderPass(webGLObject.__object,webGLObject,THREE.NormalBlending)}n=0;for(h=e.__webGLObjects.length;n<h;n++){webGLObject=e.__webGLObjects[n];this.setupMatrices(webGLObject.__object,g);this.renderPass(webGLObject.__object,webGLObject,THREE.AdditiveBlending);this.renderPass(webGLObject.__object,
|
|
|
+webGLObject,THREE.SubtractiveBlending)}};this.initWebGLObjects=function(e){var g,n,h,l,q;if(!e.__webGLObjects)e.__webGLObjects=[];g=0;for(n=e.objects.length;g<n;g++){h=e.objects[g];if(h instanceof THREE.Mesh)for(l in h.materialFaceGroup){q=h.materialFaceGroup[l];if(!q.__webGLVertexBuffer){this.createBuffers(h,l);q.__object=h;e.__webGLObjects.push(q)}}}};this.setupMatrices=function(e,g){e.autoUpdateMatrix&&e.updateMatrix();j.multiply(g.matrix,e.matrix);d.viewMatrixArray=new Float32Array(g.matrix.flatten());
|
|
|
+d.modelViewMatrixArray=new Float32Array(j.flatten());d.projectionMatrixArray=new Float32Array(g.projectionMatrix.flatten());o=THREE.Matrix4.makeInvert3x3(j).transpose();d.normalMatrixArray=new Float32Array(o.m);b.uniformMatrix4fv(d.viewMatrix,false,d.viewMatrixArray);b.uniformMatrix4fv(d.modelViewMatrix,false,d.modelViewMatrixArray);b.uniformMatrix4fv(d.projectionMatrix,false,d.projectionMatrixArray);b.uniformMatrix3fv(d.normalMatrix,false,d.normalMatrixArray);b.uniformMatrix4fv(d.objMatrix,false,
|
|
|
+new Float32Array(e.matrix.flatten()))};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,g){if(e){!g||g=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)}};
|
|
|
THREE.RenderableFace3=function(){this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.material=this.color=this.z=null};
|
|
|
THREE.RenderableFace4=function(){this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.v4=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.material=this.color=this.z=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=this.color=null};
|
|
|
THREE.RenderableLine=function(){this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=this.color=this.z=null};
|