|
@@ -187,16 +187,16 @@ b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_M
|
|
|
f.image.loaded){f.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,f.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,f.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(f.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(f.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(f.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,i(f.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+
|
|
|
h);b.bindTexture(b.TEXTURE_2D,f.__webGLTexture)}}}return l};this.renderBuffer=function(d,n,h,f,k,l){d=this.setProgram(d,n,h,f,l).attributes;b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.vertexAttribPointer(d.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.position);if(d.color>=0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);b.vertexAttribPointer(d.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.color)}if(d.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLNormalBuffer);
|
|
|
b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.normal)}if(d.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLTangentBuffer);b.vertexAttribPointer(d.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.tangent)}if(d.uv>=0)if(k.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUVBuffer);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv)}else b.disableVertexAttribArray(d.uv);if(d.uv2>=0)if(k.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,
|
|
|
-k.__webGLUV2Buffer);b.vertexAttribPointer(d.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv2)}else b.disableVertexAttribArray(d.uv2);if(f.wireframe||f instanceof THREE.LineBasicMaterial){d=f.wireframe_linewidth!==undefined?f.wireframe_linewidth:f.linewidth!==undefined?f.linewidth:1;f=f instanceof THREE.LineBasicMaterial&&l.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(d);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.drawElements(f,k.__webGLLineCount,b.UNSIGNED_SHORT,
|
|
|
-0)}else if(f instanceof THREE.ParticleBasicMaterial)b.drawArrays(b.POINTS,0,k.__webGLParticleCount);else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,k.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(d,n,h,f,k,l,t){var o,q,v,x,u;v=0;for(x=f.materials.length;v<x;v++){o=f.materials[v];if(o instanceof THREE.MeshFaceMaterial){o=0;for(q=k.materials.length;o<q;o++)if((u=k.materials[o])&&u.blending==l&&u.opacity<1==t){this.setBlending(u.blending);this.setDepthTest(u.depth_test);
|
|
|
-this.renderBuffer(d,n,h,u,k,f)}}else if((u=o)&&u.blending==l&&u.opacity<1==t){this.setBlending(u.blending);this.setDepthTest(u.depth_test);this.renderBuffer(d,n,h,u,k,f)}}};this.renderPassImmediate=function(d,n,h,f,k,l){var t,o,q,v;t=0;for(o=f.materials.length;t<o;t++)if((q=f.materials[t])&&q.blending==k&&q.opacity<1==l){this.setBlending(q.blending);this.setDepthTest(q.depth_test);v=this.setProgram(d,n,h,q,f);f.render(function(x){var u=v;if(!x.__webGLVertexBuffer)x.__webGLVertexBuffer=b.createBuffer();
|
|
|
-if(!x.__webGLNormalBuffer)x.__webGLNormalBuffer=b.createBuffer();if(x.hasPos){b.bindBuffer(b.ARRAY_BUFFER,x.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,x.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(u.attributes.position);b.vertexAttribPointer(u.attributes.position,3,b.FLOAT,false,0,0)}if(x.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,x.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,x.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(u.attributes.normal);b.vertexAttribPointer(u.attributes.normal,
|
|
|
-3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,x.count);x.count=0})}};this.render=function(d,n,h,f){var k,l,t,o,q=d.lights,v=d.fog;n.autoUpdateMatrix&&n.updateMatrix();w.set(n.matrix.flatten());A.set(n.projectionMatrix.flatten());r.multiply(n.projectionMatrix,n.matrix);p[0].set(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);p[1].set(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);p[2].set(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);p[3].set(r.n41-r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);
|
|
|
-p[4].set(r.n41-r.n31,r.n42-r.n32,r.n43-r.n33,r.n44-r.n34);p[5].set(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);for(k=0;k<5;k++){o=p[k];o.divideScalar(Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z))}this.initWebGLObjects(d,n);f=f!==undefined?f:true;if(h&&!h.__webGLFramebuffer){h.__webGLFramebuffer=b.createFramebuffer();h.__webGLRenderbuffer=b.createRenderbuffer();h.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,h.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,
|
|
|
-h.width,h.height);b.bindTexture(b.TEXTURE_2D,h.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(h.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(h.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(h.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,i(h.min_filter));b.texImage2D(b.TEXTURE_2D,0,i(h.format),h.width,h.height,0,i(h.format),i(h.type),null);b.bindFramebuffer(b.FRAMEBUFFER,h.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,
|
|
|
-b.TEXTURE_2D,h.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,h.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(h){k=h.__webGLFramebuffer;o=h.width;t=h.height}else{k=null;o=j.width;t=j.height}if(k!=m){b.bindFramebuffer(b.FRAMEBUFFER,k);b.viewport(0,0,o,t);f&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);m=k}this.autoClear&&this.clear();k=d.__webGLObjects.length;for(f=
|
|
|
-0;f<k;f++){t=d.__webGLObjects[f];o=t.object;if(l=o.visible){if(!(l=!(o instanceof THREE.Mesh)))a:{l=void 0;for(var x=o.matrix,u=-o.geometry.boundingSphere.radius*Math.max(o.scale.x,Math.max(o.scale.y,o.scale.z)),z=0;z<6;z++){l=p[z].x*x.n14+p[z].y*x.n24+p[z].z*x.n34+p[z].w;if(l<=u){l=false;break a}}l=true}l=l}if(l){if(o.autoUpdateMatrix){o.updateMatrix();o._objectMatrixArray.set(o.matrix.flatten())}this.setupMatrices(o,n);t.render=true}else t.render=false}l=d.__webGLObjectsImmediate.length;for(f=0;f<
|
|
|
-l;f++){o=d.__webGLObjectsImmediate[f].object;if(o.visible){if(o.autoUpdateMatrix){o.updateMatrix();o._objectMatrixArray.set(o.matrix.flatten())}this.setupMatrices(o,n)}}for(f=0;f<k;f++){t=d.__webGLObjects[f];if(t.render){o=t.object;t=t.buffer;e(o);this.renderPass(n,q,v,o,t,THREE.NormalBlending,false)}}for(f=0;f<l;f++){o=d.__webGLObjectsImmediate[f].object;if(o.visible){e(o);this.renderPassImmediate(n,q,v,o,THREE.NormalBlending,false)}}for(f=0;f<k;f++){t=d.__webGLObjects[f];if(t.render){o=t.object;
|
|
|
+k.__webGLUV2Buffer);b.vertexAttribPointer(d.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv2)}else b.disableVertexAttribArray(d.uv2);if(l instanceof THREE.Mesh)if(f.wireframe){b.lineWidth(f.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.drawElements(b.LINES,k.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,k.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(l instanceof THREE.Line){l=
|
|
|
+l.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(f.linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.drawElements(l,k.__webGLLineCount,b.UNSIGNED_SHORT,0)}else l instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,k.__webGLParticleCount)};this.renderPass=function(d,n,h,f,k,l,t){var o,q,v,x,u;v=0;for(x=f.materials.length;v<x;v++){o=f.materials[v];if(o instanceof THREE.MeshFaceMaterial){o=0;for(q=k.materials.length;o<q;o++)if((u=k.materials[o])&&u.blending==l&&u.opacity<
|
|
|
+1==t){this.setBlending(u.blending);this.setDepthTest(u.depth_test);this.renderBuffer(d,n,h,u,k,f)}}else if((u=o)&&u.blending==l&&u.opacity<1==t){this.setBlending(u.blending);this.setDepthTest(u.depth_test);this.renderBuffer(d,n,h,u,k,f)}}};this.renderPassImmediate=function(d,n,h,f,k,l){var t,o,q,v;t=0;for(o=f.materials.length;t<o;t++)if((q=f.materials[t])&&q.blending==k&&q.opacity<1==l){this.setBlending(q.blending);this.setDepthTest(q.depth_test);v=this.setProgram(d,n,h,q,f);f.render(function(x){var u=
|
|
|
+v;if(!x.__webGLVertexBuffer)x.__webGLVertexBuffer=b.createBuffer();if(!x.__webGLNormalBuffer)x.__webGLNormalBuffer=b.createBuffer();if(x.hasPos){b.bindBuffer(b.ARRAY_BUFFER,x.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,x.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(u.attributes.position);b.vertexAttribPointer(u.attributes.position,3,b.FLOAT,false,0,0)}if(x.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,x.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,x.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(u.attributes.normal);
|
|
|
+b.vertexAttribPointer(u.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,x.count);x.count=0})}};this.render=function(d,n,h,f){var k,l,t,o,q=d.lights,v=d.fog;n.autoUpdateMatrix&&n.updateMatrix();w.set(n.matrix.flatten());A.set(n.projectionMatrix.flatten());r.multiply(n.projectionMatrix,n.matrix);p[0].set(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);p[1].set(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);p[2].set(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);p[3].set(r.n41-
|
|
|
+r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);p[4].set(r.n41-r.n31,r.n42-r.n32,r.n43-r.n33,r.n44-r.n34);p[5].set(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);for(k=0;k<5;k++){o=p[k];o.divideScalar(Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z))}this.initWebGLObjects(d,n);f=f!==undefined?f:true;if(h&&!h.__webGLFramebuffer){h.__webGLFramebuffer=b.createFramebuffer();h.__webGLRenderbuffer=b.createRenderbuffer();h.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,h.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,
|
|
|
+b.DEPTH_COMPONENT16,h.width,h.height);b.bindTexture(b.TEXTURE_2D,h.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(h.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(h.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(h.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,i(h.min_filter));b.texImage2D(b.TEXTURE_2D,0,i(h.format),h.width,h.height,0,i(h.format),i(h.type),null);b.bindFramebuffer(b.FRAMEBUFFER,h.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,
|
|
|
+b.COLOR_ATTACHMENT0,b.TEXTURE_2D,h.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,h.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(h){k=h.__webGLFramebuffer;o=h.width;t=h.height}else{k=null;o=j.width;t=j.height}if(k!=m){b.bindFramebuffer(b.FRAMEBUFFER,k);b.viewport(0,0,o,t);f&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);m=k}this.autoClear&&this.clear();k=d.__webGLObjects.length;
|
|
|
+for(f=0;f<k;f++){t=d.__webGLObjects[f];o=t.object;if(l=o.visible){if(!(l=!(o instanceof THREE.Mesh)))a:{l=void 0;for(var x=o.matrix,u=-o.geometry.boundingSphere.radius*Math.max(o.scale.x,Math.max(o.scale.y,o.scale.z)),z=0;z<6;z++){l=p[z].x*x.n14+p[z].y*x.n24+p[z].z*x.n34+p[z].w;if(l<=u){l=false;break a}}l=true}l=l}if(l){if(o.autoUpdateMatrix){o.updateMatrix();o._objectMatrixArray.set(o.matrix.flatten())}this.setupMatrices(o,n);t.render=true}else t.render=false}l=d.__webGLObjectsImmediate.length;for(f=
|
|
|
+0;f<l;f++){o=d.__webGLObjectsImmediate[f].object;if(o.visible){if(o.autoUpdateMatrix){o.updateMatrix();o._objectMatrixArray.set(o.matrix.flatten())}this.setupMatrices(o,n)}}for(f=0;f<k;f++){t=d.__webGLObjects[f];if(t.render){o=t.object;t=t.buffer;e(o);this.renderPass(n,q,v,o,t,THREE.NormalBlending,false)}}for(f=0;f<l;f++){o=d.__webGLObjectsImmediate[f].object;if(o.visible){e(o);this.renderPassImmediate(n,q,v,o,THREE.NormalBlending,false)}}for(f=0;f<k;f++){t=d.__webGLObjects[f];if(t.render){o=t.object;
|
|
|
t=t.buffer;e(o);this.renderPass(n,q,v,o,t,THREE.AdditiveBlending,false);this.renderPass(n,q,v,o,t,THREE.SubtractiveBlending,false);this.renderPass(n,q,v,o,t,THREE.AdditiveBlending,true);this.renderPass(n,q,v,o,t,THREE.SubtractiveBlending,true);this.renderPass(n,q,v,o,t,THREE.NormalBlending,true);this.renderPass(n,q,v,o,t,THREE.BillboardBlending,false)}}for(f=0;f<l;f++){o=d.__webGLObjectsImmediate[f].object;if(o.visible){e(o);this.renderPassImmediate(n,q,v,o,THREE.NormalBlending,true)}}if(h&&h.min_filter!==
|
|
|
THREE.NearestFilter&&h.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,h.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(d,n){function h(u,z,B,N){if(u[z]==undefined){d.__webGLObjects.push({buffer:B,object:N});u[z]=1}}function f(u,z,B){if(u[z]==undefined){d.__webGLObjectsImmediate.push({object:B});u[z]=1}}var k,l,t,o,q,v,x;if(!d.__webGLObjects){d.__webGLObjects=[];d.__webGLObjectsMap={};d.__webGLObjectsImmediate=[]}k=0;for(l=
|
|
|
d.objects.length;k<l;k++){t=d.objects[k];q=t.geometry;if(d.__webGLObjectsMap[t.id]==undefined){d.__webGLObjectsMap[t.id]={};t._modelViewMatrix=new THREE.Matrix4;t._normalMatrixArray=new Float32Array(9);t._modelViewMatrixArray=new Float32Array(16);t._objectMatrixArray=new Float32Array(16);t._objectMatrixArray.set(t.matrix.flatten())}x=d.__webGLObjectsMap[t.id];if(t instanceof THREE.Mesh){for(o in q.geometryChunks){v=q.geometryChunks[o];if(!v.__webGLVertexBuffer){this.createMeshBuffers(v);this.initMeshBuffers(v,
|