Browse Source

Fixed morph sorting to be by influence.

alteredq 13 years ago
parent
commit
d0b2930f83
3 changed files with 104 additions and 95 deletions
  1. 20 20
      build/Three.js
  2. 70 70
      build/custom/ThreeWebGL.js
  3. 14 5
      src/renderers/WebGLRenderer.js

+ 20 - 20
build/Three.js

@@ -287,8 +287,8 @@ var k=a.colors,j=k.length,l=a.__vertexArray,m=a.__colorArray,n=a.__sortArray,o=a
 if(h.boundTo===void 0||h.boundTo==="vertices"){f=0;e=h.value.length;if(h.size===1)for(d=0;d<e;d++){g=n[d][1];h.array[d]=h.value[g]}else if(h.size===2)for(d=0;d<e;d++){g=n[d][1];g=h.value[g];h.array[f]=g.x;h.array[f+1]=g.y;f=f+2}else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++){g=n[d][1];g=h.value[g];h.array[f]=g.r;h.array[f+1]=g.g;h.array[f+2]=g.b;f=f+3}else for(d=0;d<e;d++){g=n[d][1];g=h.value[g];h.array[f]=g.x;h.array[f+1]=g.y;h.array[f+2]=g.z;f=f+3}else if(h.size===4)for(d=0;d<e;d++){g=n[d][1];
 if(h.boundTo===void 0||h.boundTo==="vertices"){f=0;e=h.value.length;if(h.size===1)for(d=0;d<e;d++){g=n[d][1];h.array[d]=h.value[g]}else if(h.size===2)for(d=0;d<e;d++){g=n[d][1];g=h.value[g];h.array[f]=g.x;h.array[f+1]=g.y;f=f+2}else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++){g=n[d][1];g=h.value[g];h.array[f]=g.r;h.array[f+1]=g.g;h.array[f+2]=g.b;f=f+3}else for(d=0;d<e;d++){g=n[d][1];g=h.value[g];h.array[f]=g.x;h.array[f+1]=g.y;h.array[f+2]=g.z;f=f+3}else if(h.size===4)for(d=0;d<e;d++){g=n[d][1];
 g=h.value[g];h.array[f]=g.x;h.array[f+1]=g.y;h.array[f+2]=g.z;h.array[f+3]=g.w;f=f+4}}}}}else{if(o)for(d=0;d<g;d++){e=h[d];f=d*3;l[f]=e.x;l[f+1]=e.y;l[f+2]=e.z}if(p)for(d=0;d<j;d++){e=k[d];f=d*3;m[f]=e.r;m[f+1]=e.g;m[f+2]=e.b}if(q){k=0;for(j=q.length;k<j;k++){h=q[k];if(h.needsUpdate&&(h.boundTo===void 0||h.boundTo==="vertices")){e=h.value.length;f=0;if(h.size===1)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(h.size===2)for(d=0;d<e;d++){g=h.value[d];h.array[f]=g.x;h.array[f+1]=g.y;f=f+2}else if(h.size===
 g=h.value[g];h.array[f]=g.x;h.array[f+1]=g.y;h.array[f+2]=g.z;h.array[f+3]=g.w;f=f+4}}}}}else{if(o)for(d=0;d<g;d++){e=h[d];f=d*3;l[f]=e.x;l[f+1]=e.y;l[f+2]=e.z}if(p)for(d=0;d<j;d++){e=k[d];f=d*3;m[f]=e.r;m[f+1]=e.g;m[f+2]=e.b}if(q){k=0;for(j=q.length;k<j;k++){h=q[k];if(h.needsUpdate&&(h.boundTo===void 0||h.boundTo==="vertices")){e=h.value.length;f=0;if(h.size===1)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(h.size===2)for(d=0;d<e;d++){g=h.value[d];h.array[f]=g.x;h.array[f+1]=g.y;f=f+2}else if(h.size===
 3)if(h.type==="c")for(d=0;d<e;d++){g=h.value[d];h.array[f]=g.r;h.array[f+1]=g.g;h.array[f+2]=g.b;f=f+3}else for(d=0;d<e;d++){g=h.value[d];h.array[f]=g.x;h.array[f+1]=g.y;h.array[f+2]=g.z;f=f+3}else if(h.size===4)for(d=0;d<e;d++){g=h.value[d];h.array[f]=g.x;h.array[f+1]=g.y;h.array[f+2]=g.z;h.array[f+3]=g.w;f=f+4}}}}}if(o||c.sortParticles){i.bindBuffer(i.ARRAY_BUFFER,a.__webglVertexBuffer);i.bufferData(i.ARRAY_BUFFER,l,b)}if(p||c.sortParticles){i.bindBuffer(i.ARRAY_BUFFER,a.__webglColorBuffer);i.bufferData(i.ARRAY_BUFFER,
 3)if(h.type==="c")for(d=0;d<e;d++){g=h.value[d];h.array[f]=g.r;h.array[f+1]=g.g;h.array[f+2]=g.b;f=f+3}else for(d=0;d<e;d++){g=h.value[d];h.array[f]=g.x;h.array[f+1]=g.y;h.array[f+2]=g.z;f=f+3}else if(h.size===4)for(d=0;d<e;d++){g=h.value[d];h.array[f]=g.x;h.array[f+1]=g.y;h.array[f+2]=g.z;h.array[f+3]=g.w;f=f+4}}}}}if(o||c.sortParticles){i.bindBuffer(i.ARRAY_BUFFER,a.__webglVertexBuffer);i.bufferData(i.ARRAY_BUFFER,l,b)}if(p||c.sortParticles){i.bindBuffer(i.ARRAY_BUFFER,a.__webglColorBuffer);i.bufferData(i.ARRAY_BUFFER,
-m,b)}if(q){k=0;for(j=q.length;k<j;k++){h=q[k];if(h.needsUpdate||c.sortParticles){i.bindBuffer(i.ARRAY_BUFFER,h.buffer);i.bufferData(i.ARRAY_BUFFER,h.array,b)}}}}function g(a,b){return b.z-a.z}function h(a,b){return a-b}function k(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++){$=M=null;H=ea=Y=Q=Ma=na=Z=-1;Na=true;a[d].render(b,c,Db,$a);$=M=null;H=ea=Y=Q=Ma=na=Z=-1;Na=true}}function j(a,b,c,d,e,f,g,h){var i,k,j,l;if(b){k=a.length-1;l=b=-1}else{k=0;b=a.length;l=1}for(var m=k;m!==b;m=m+l){i=a[m];
-if(i.render){k=i.object;j=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;g&&G.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);G.setDepthTest(i.depthTest);G.setDepthWrite(i.depthWrite);t(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}G.setObjectFaces(k);j instanceof THREE.BufferGeometry?G.renderBufferDirect(d,e,f,i,j,k):G.renderBuffer(d,e,f,i,j,k)}}}function l(a,b,c,d,e,f,g){for(var h,i,k=0,j=a.length;k<j;k++){h=a[k];i=h.object;if(i.visible){if(g)h=g;else{h=h[b];if(!h)continue;
+m,b)}if(q){k=0;for(j=q.length;k<j;k++){h=q[k];if(h.needsUpdate||c.sortParticles){i.bindBuffer(i.ARRAY_BUFFER,h.buffer);i.bufferData(i.ARRAY_BUFFER,h.array,b)}}}}function g(a,b){return b.z-a.z}function h(a,b){return b[1]-a[1]}function k(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++){$=M=null;H=ea=Y=Q=Ma=na=Z=-1;Na=true;a[d].render(b,c,Db,$a);$=M=null;H=ea=Y=Q=Ma=na=Z=-1;Na=true}}function j(a,b,c,d,e,f,g,h){var i,k,j,l;if(b){k=a.length-1;l=b=-1}else{k=0;b=a.length;l=1}for(var m=k;m!==b;m=m+l){i=
+a[m];if(i.render){k=i.object;j=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;g&&G.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);G.setDepthTest(i.depthTest);G.setDepthWrite(i.depthWrite);t(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}G.setObjectFaces(k);j instanceof THREE.BufferGeometry?G.renderBufferDirect(d,e,f,i,j,k):G.renderBuffer(d,e,f,i,j,k)}}}function l(a,b,c,d,e,f,g){for(var h,i,k=0,j=a.length;k<j;k++){h=a[k];i=h.object;if(i.visible){if(g)h=g;else{h=h[b];if(!h)continue;
 f&&G.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);G.setDepthTest(h.depthTest);G.setDepthWrite(h.depthWrite);t(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}G.renderImmediateObject(c,d,e,h,i)}}}function o(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function m(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function p(a){for(var b in a.attributes)a.attributes[b].needsUpdate=false}function q(a,b){for(var c=a.length-
 f&&G.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);G.setDepthTest(h.depthTest);G.setDepthWrite(h.depthWrite);t(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}G.renderImmediateObject(c,d,e,h,i)}}}function o(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function m(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function p(a){for(var b in a.attributes)a.attributes[b].needsUpdate=false}function q(a,b){for(var c=a.length-
 1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function r(a,b,c,d,e){if(!d.program||d.needsUpdate){G.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(G.maxMorphTargets);for(var f=0,g=G.maxMorphTargets;f<g;f++)e.__webglMorphTargetInfluences[f]=0}var h=false,f=d.program,g=f.uniforms,k=d.uniforms;if(f!==M){i.useProgram(f);M=f;h=true}if(d.id!==H){H=
 1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function r(a,b,c,d,e){if(!d.program||d.needsUpdate){G.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(G.maxMorphTargets);for(var f=0,g=G.maxMorphTargets;f<g;f++)e.__webglMorphTargetInfluences[f]=0}var h=false,f=d.program,g=f.uniforms,k=d.uniforms;if(f!==M){i.useProgram(f);M=f;h=true}if(d.id!==H){H=
 d.id;h=true}if(h||a!==$){i.uniformMatrix4fv(g.projectionMatrix,false,a._projectionMatrixArray);a!==$&&($=a)}if(h){if(c&&d.fog){k.fogColor.value=c.color;if(c instanceof THREE.Fog){k.fogNear.value=c.near;k.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)k.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(Na){for(var j,l=0,m=0,n=0,o,p,q,r=oa,u=r.directional.colors,t=r.directional.positions,v=r.point.colors,x=r.point.positions,
 d.id;h=true}if(h||a!==$){i.uniformMatrix4fv(g.projectionMatrix,false,a._projectionMatrixArray);a!==$&&($=a)}if(h){if(c&&d.fog){k.fogColor.value=c.color;if(c instanceof THREE.Fog){k.fogNear.value=c.near;k.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)k.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(Na){for(var j,l=0,m=0,n=0,o,p,q,r=oa,u=r.directional.colors,t=r.directional.positions,v=r.point.colors,x=r.point.positions,
@@ -330,24 +330,24 @@ i.deleteRenderbuffer(a.__webglRenderbuffer)}}};this.updateShadowMap=function(a,b
 e.vertexNormalBuffer);i.vertexAttribPointer(a.normal,e.vertexNormalBuffer.itemSize,i.FLOAT,false,0,f[d].index*12)}if(a.uv>=0&&e.vertexUvBuffer)if(e.vertexUvBuffer){i.bindBuffer(i.ARRAY_BUFFER,e.vertexUvBuffer);i.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,i.FLOAT,false,0,f[d].index*8);i.enableVertexAttribArray(a.uv)}else i.disableVertexAttribArray(a.uv);if(a.color>=0&&e.vertexColorBuffer){i.bindBuffer(i.ARRAY_BUFFER,e.vertexColorBuffer);i.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,
 e.vertexNormalBuffer);i.vertexAttribPointer(a.normal,e.vertexNormalBuffer.itemSize,i.FLOAT,false,0,f[d].index*12)}if(a.uv>=0&&e.vertexUvBuffer)if(e.vertexUvBuffer){i.bindBuffer(i.ARRAY_BUFFER,e.vertexUvBuffer);i.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,i.FLOAT,false,0,f[d].index*8);i.enableVertexAttribArray(a.uv)}else i.disableVertexAttribArray(a.uv);if(a.color>=0&&e.vertexColorBuffer){i.bindBuffer(i.ARRAY_BUFFER,e.vertexColorBuffer);i.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,
 i.FLOAT,false,0,f[d].index*16)}i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)}i.drawElements(i.TRIANGLES,f[d].count,i.UNSIGNED_SHORT,f[d].start*2);G.info.render.calls++;G.info.render.vertices=G.info.render.vertices+f[d].count;G.info.render.faces=G.info.render.faces+f[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==false){var g,k,c=r(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==ea){ea=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){i.bindBuffer(i.ARRAY_BUFFER,
 i.FLOAT,false,0,f[d].index*16)}i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)}i.drawElements(i.TRIANGLES,f[d].count,i.UNSIGNED_SHORT,f[d].start*2);G.info.render.calls++;G.info.render.vertices=G.info.render.vertices+f[d].count;G.info.render.faces=G.info.render.faces+f[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==false){var g,k,c=r(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==ea){ea=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){i.bindBuffer(i.ARRAY_BUFFER,
 e.__webglVertexBuffer);i.vertexAttribPointer(b.position,3,i.FLOAT,false,0,0)}}else if(f.morphTargetBase){c=d.program.attributes;if(f.morphTargetBase!==-1){i.bindBuffer(i.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]);i.vertexAttribPointer(c.position,3,i.FLOAT,false,0,0)}else if(c.position>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglVertexBuffer);i.vertexAttribPointer(c.position,3,i.FLOAT,false,0,0)}if(f.morphTargetForcedOrder.length){var j=0;k=f.morphTargetForcedOrder;for(g=f.morphTargetInfluences;j<
 e.__webglVertexBuffer);i.vertexAttribPointer(b.position,3,i.FLOAT,false,0,0)}}else if(f.morphTargetBase){c=d.program.attributes;if(f.morphTargetBase!==-1){i.bindBuffer(i.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]);i.vertexAttribPointer(c.position,3,i.FLOAT,false,0,0)}else if(c.position>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglVertexBuffer);i.vertexAttribPointer(c.position,3,i.FLOAT,false,0,0)}if(f.morphTargetForcedOrder.length){var j=0;k=f.morphTargetForcedOrder;for(g=f.morphTargetInfluences;j<
-d.numSupportedMorphTargets&&j<k.length;){i.bindBuffer(i.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[k[j]]);i.vertexAttribPointer(c["morphTarget"+j],3,i.FLOAT,false,0,0);if(d.morphNormals){i.bindBuffer(i.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[k[j]]);i.vertexAttribPointer(c["morphNormal"+j],3,i.FLOAT,false,0,0)}f.__webglMorphTargetInfluences[j]=g[k[j]];j++}}else{k=[];g=f.morphTargetInfluences;var l,m=g.length;for(l=0;l<m;l++){j=g[l];j>0&&k.push(l)}if(k.length>d.numSupportedMorphTargets){k.sort(h);
-k.length=d.numSupportedMorphTargets}else k.length>d.numSupportedMorphNormals?k.sort(h):k.length===0&&k.push(0);for(j=0;j<d.numSupportedMorphTargets;){l=k[j];if(l!==void 0||j===0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l]);i.vertexAttribPointer(c["morphTarget"+j],3,i.FLOAT,false,0,0);if(d.morphNormals){i.bindBuffer(i.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[l]);i.vertexAttribPointer(c["morphNormal"+j],3,i.FLOAT,false,0,0)}f.__webglMorphTargetInfluences[j]=g[l]}else{i.vertexAttribPointer(c["morphTarget"+
-j],3,i.FLOAT,false,0,0);d.morphNormals&&i.vertexAttribPointer(c["morphNormal"+j],3,i.FLOAT,false,0,0);f.__webglMorphTargetInfluences[j]=0}j++}}d.program.uniforms.morphTargetInfluences!==null&&i.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){g=0;for(k=e.__webglCustomAttributesList.length;g<k;g++){c=e.__webglCustomAttributesList[g];if(b[c.buffer.belongsToAttribute]>=0){i.bindBuffer(i.ARRAY_BUFFER,c.buffer);i.vertexAttribPointer(b[c.buffer.belongsToAttribute],
-c.size,i.FLOAT,false,0,0)}}}if(b.color>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglColorBuffer);i.vertexAttribPointer(b.color,3,i.FLOAT,false,0,0)}if(b.normal>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglNormalBuffer);i.vertexAttribPointer(b.normal,3,i.FLOAT,false,0,0)}if(b.tangent>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglTangentBuffer);i.vertexAttribPointer(b.tangent,4,i.FLOAT,false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){i.bindBuffer(i.ARRAY_BUFFER,e.__webglUVBuffer);i.vertexAttribPointer(b.uv,2,i.FLOAT,
-false,0,0);i.enableVertexAttribArray(b.uv)}else i.disableVertexAttribArray(b.uv);if(b.uv2>=0)if(e.__webglUV2Buffer){i.bindBuffer(i.ARRAY_BUFFER,e.__webglUV2Buffer);i.vertexAttribPointer(b.uv2,2,i.FLOAT,false,0,0);i.enableVertexAttribArray(b.uv2)}else i.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglSkinVertexABuffer);i.vertexAttribPointer(b.skinVertexA,4,i.FLOAT,false,0,0);i.bindBuffer(i.ARRAY_BUFFER,
-e.__webglSkinVertexBBuffer);i.vertexAttribPointer(b.skinVertexB,4,i.FLOAT,false,0,0);i.bindBuffer(i.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);i.vertexAttribPointer(b.skinIndex,4,i.FLOAT,false,0,0);i.bindBuffer(i.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);i.vertexAttribPointer(b.skinWeight,4,i.FLOAT,false,0,0)}}if(f instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==Ya){i.lineWidth(d);Ya=d}a&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);i.drawElements(i.LINES,e.__webglLineCount,
-i.UNSIGNED_SHORT,0)}else{a&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer);i.drawElements(i.TRIANGLES,e.__webglFaceCount,i.UNSIGNED_SHORT,0)}G.info.render.calls++;G.info.render.vertices=G.info.render.vertices+e.__webglFaceCount;G.info.render.faces=G.info.render.faces+e.__webglFaceCount/3}else if(f instanceof THREE.Line){f=f.type===THREE.LineStrip?i.LINE_STRIP:i.LINES;d=d.linewidth;if(d!==Ya){i.lineWidth(d);Ya=d}i.drawArrays(f,0,e.__webglLineCount);G.info.render.calls++}else if(f instanceof
-THREE.ParticleSystem){i.drawArrays(i.POINTS,0,e.__webglParticleCount);G.info.render.calls++;G.info.render.points=G.info.render.points+e.__webglParticleCount}else if(f instanceof THREE.Ribbon){i.drawArrays(i.TRIANGLE_STRIP,0,e.__webglVertexCount);G.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,h,m,n=a.__lights,o=a.fog;H=-1;Na=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=
-new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);xa.multiply(b.projectionMatrix,b.matrixWorldInverse);Da.setFromMatrix(xa);this.autoUpdateObjects&&this.initWebGLObjects(a);k(this.renderPluginsPre,a,b);G.info.render.calls=0;G.info.render.vertices=0;G.info.render.faces=0;G.info.render.points=
-0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;d=0;for(e=m.length;d<e;d++){f=m[d];h=f.object;f.render=false;if(h.visible&&(!(h instanceof THREE.Mesh||h instanceof THREE.ParticleSystem)||!h.frustumCulled||Da.contains(h))){u(h,b);var p=f,q=p.object,r=p.buffer,s=void 0,s=s=void 0,s=q.material;if(s instanceof THREE.MeshFaceMaterial){s=r.materialIndex;if(s>=0){s=q.geometry.materials[s];if(s.transparent){p.transparent=
-s;p.opaque=null}else{p.opaque=s;p.transparent=null}}}else if(s)if(s.transparent){p.transparent=s;p.opaque=null}else{p.opaque=s;p.transparent=null}f.render=true;if(this.sortObjects)if(h.renderDepth)f.z=h.renderDepth;else{ka.copy(h.matrixWorld.getPosition());xa.multiplyVector3(ka);f.z=ka.z}}}this.sortObjects&&m.sort(g);m=a.__webglObjectsImmediate;d=0;for(e=m.length;d<e;d++){f=m[d];h=f.object;if(h.visible){u(h,b);h=f.object.material;if(h.transparent){f.transparent=h;f.opaque=null}else{f.opaque=h;f.transparent=
-null}}}if(a.overrideMaterial){d=a.overrideMaterial;this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst);this.setDepthTest(d.depthTest);this.setDepthWrite(d.depthWrite);t(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits);j(a.__webglObjects,false,"",b,n,o,true,d);l(a.__webglObjectsImmediate,"",b,n,o,false,d)}else{this.setBlending(THREE.NormalBlending);j(a.__webglObjects,true,"opaque",b,n,o,false);l(a.__webglObjectsImmediate,"opaque",b,n,o,false);j(a.__webglObjects,false,"transparent",
-b,n,o,true);l(a.__webglObjectsImmediate,"transparent",b,n,o,true)}k(this.renderPluginsPost,a,b);if(c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter)if(c instanceof THREE.WebGLRenderTargetCube){i.bindTexture(i.TEXTURE_CUBE_MAP,c.__webglTexture);i.generateMipmap(i.TEXTURE_CUBE_MAP);i.bindTexture(i.TEXTURE_CUBE_MAP,null)}else{i.bindTexture(i.TEXTURE_2D,c.__webglTexture);i.generateMipmap(i.TEXTURE_2D);i.bindTexture(i.TEXTURE_2D,null)}this.setDepthTest(true);this.setDepthWrite(true)};
-this.renderImmediateObject=function(a,b,c,d,e){var f=r(a,b,c,d,e);ea=-1;G.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(f,i,Da):e.render(function(a){G.renderBufferImmediate(a,f,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects){a.__webglObjects=[];a.__webglObjectsImmediate=[];a.__webglSprites=[];a.__webglFlares=[]}for(;a.__objectsAdded.length;){var g=a.__objectsAdded[0],h=a,k=void 0,j=void 0,l=void 0;if(!g.__webglInit){g.__webglInit=true;g._modelViewMatrix=
-new THREE.Matrix4;g._normalMatrix=new THREE.Matrix3;if(g instanceof THREE.Mesh){j=g.geometry;if(j instanceof THREE.Geometry){if(j.geometryGroups===void 0){var r=j,s=void 0,u=void 0,t=void 0,v=void 0,x=void 0,y=void 0,z=void 0,B={},C=r.morphTargets.length,H=r.morphNormals.length;r.geometryGroups={};s=0;for(u=r.faces.length;s<u;s++){t=r.faces[s];v=t.materialIndex;y=v!==void 0?v:-1;B[y]===void 0&&(B[y]={hash:y,counter:0});z=B[y].hash+"_"+B[y].counter;r.geometryGroups[z]===void 0&&(r.geometryGroups[z]=
-{faces3:[],faces4:[],materialIndex:v,vertices:0,numMorphTargets:C,numMorphNormals:H});x=t instanceof THREE.Face3?3:4;if(r.geometryGroups[z].vertices+x>65535){B[y].counter=B[y].counter+1;z=B[y].hash+"_"+B[y].counter;r.geometryGroups[z]===void 0&&(r.geometryGroups[z]={faces3:[],faces4:[],materialIndex:v,vertices:0,numMorphTargets:C,numMorphNormals:H})}t instanceof THREE.Face3?r.geometryGroups[z].faces3.push(s):r.geometryGroups[z].faces4.push(s);r.geometryGroups[z].vertices=r.geometryGroups[z].vertices+
-x}r.geometryGroupsList=[];var F=void 0;for(F in r.geometryGroups){r.geometryGroups[F].id=wa++;r.geometryGroupsList.push(r.geometryGroups[F])}}for(k in j.geometryGroups){l=j.geometryGroups[k];if(!l.__webglVertexBuffer){var D=l;D.__webglVertexBuffer=i.createBuffer();D.__webglNormalBuffer=i.createBuffer();D.__webglTangentBuffer=i.createBuffer();D.__webglColorBuffer=i.createBuffer();D.__webglUVBuffer=i.createBuffer();D.__webglUV2Buffer=i.createBuffer();D.__webglSkinVertexABuffer=i.createBuffer();D.__webglSkinVertexBBuffer=
-i.createBuffer();D.__webglSkinIndicesBuffer=i.createBuffer();D.__webglSkinWeightsBuffer=i.createBuffer();D.__webglFaceBuffer=i.createBuffer();D.__webglLineBuffer=i.createBuffer();var Y=void 0,I=void 0;if(D.numMorphTargets){D.__webglMorphTargetsBuffers=[];Y=0;for(I=D.numMorphTargets;Y<I;Y++)D.__webglMorphTargetsBuffers.push(i.createBuffer())}if(D.numMorphNormals){D.__webglMorphNormalsBuffers=[];Y=0;for(I=D.numMorphNormals;Y<I;Y++)D.__webglMorphNormalsBuffers.push(i.createBuffer())}G.info.memory.geometries++;
+d.numSupportedMorphTargets&&j<k.length;){i.bindBuffer(i.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[k[j]]);i.vertexAttribPointer(c["morphTarget"+j],3,i.FLOAT,false,0,0);if(d.morphNormals){i.bindBuffer(i.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[k[j]]);i.vertexAttribPointer(c["morphNormal"+j],3,i.FLOAT,false,0,0)}f.__webglMorphTargetInfluences[j]=g[k[j]];j++}}else{k=[];g=f.morphTargetInfluences;var l,m=g.length;for(l=0;l<m;l++){j=g[l];j>0&&k.push([l,j])}if(k.length>d.numSupportedMorphTargets){k.sort(h);
+k.length=d.numSupportedMorphTargets}else k.length>d.numSupportedMorphNormals?k.sort(h):k.length===0&&k.push([0,0]);for(j=0;j<d.numSupportedMorphTargets;){l=j<k.length?k[j][0]:void 0;if(l!==void 0||j===0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l]);i.vertexAttribPointer(c["morphTarget"+j],3,i.FLOAT,false,0,0);if(d.morphNormals){i.bindBuffer(i.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[l]);i.vertexAttribPointer(c["morphNormal"+j],3,i.FLOAT,false,0,0)}f.__webglMorphTargetInfluences[j]=
+g[l]}else{i.vertexAttribPointer(c["morphTarget"+j],3,i.FLOAT,false,0,0);d.morphNormals&&i.vertexAttribPointer(c["morphNormal"+j],3,i.FLOAT,false,0,0);f.__webglMorphTargetInfluences[j]=0}j++}}d.program.uniforms.morphTargetInfluences!==null&&i.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){g=0;for(k=e.__webglCustomAttributesList.length;g<k;g++){c=e.__webglCustomAttributesList[g];if(b[c.buffer.belongsToAttribute]>=0){i.bindBuffer(i.ARRAY_BUFFER,
+c.buffer);i.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,i.FLOAT,false,0,0)}}}if(b.color>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglColorBuffer);i.vertexAttribPointer(b.color,3,i.FLOAT,false,0,0)}if(b.normal>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglNormalBuffer);i.vertexAttribPointer(b.normal,3,i.FLOAT,false,0,0)}if(b.tangent>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglTangentBuffer);i.vertexAttribPointer(b.tangent,4,i.FLOAT,false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){i.bindBuffer(i.ARRAY_BUFFER,
+e.__webglUVBuffer);i.vertexAttribPointer(b.uv,2,i.FLOAT,false,0,0);i.enableVertexAttribArray(b.uv)}else i.disableVertexAttribArray(b.uv);if(b.uv2>=0)if(e.__webglUV2Buffer){i.bindBuffer(i.ARRAY_BUFFER,e.__webglUV2Buffer);i.vertexAttribPointer(b.uv2,2,i.FLOAT,false,0,0);i.enableVertexAttribArray(b.uv2)}else i.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglSkinVertexABuffer);i.vertexAttribPointer(b.skinVertexA,
+4,i.FLOAT,false,0,0);i.bindBuffer(i.ARRAY_BUFFER,e.__webglSkinVertexBBuffer);i.vertexAttribPointer(b.skinVertexB,4,i.FLOAT,false,0,0);i.bindBuffer(i.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);i.vertexAttribPointer(b.skinIndex,4,i.FLOAT,false,0,0);i.bindBuffer(i.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);i.vertexAttribPointer(b.skinWeight,4,i.FLOAT,false,0,0)}}if(f instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==Ya){i.lineWidth(d);Ya=d}a&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);
+i.drawElements(i.LINES,e.__webglLineCount,i.UNSIGNED_SHORT,0)}else{a&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer);i.drawElements(i.TRIANGLES,e.__webglFaceCount,i.UNSIGNED_SHORT,0)}G.info.render.calls++;G.info.render.vertices=G.info.render.vertices+e.__webglFaceCount;G.info.render.faces=G.info.render.faces+e.__webglFaceCount/3}else if(f instanceof THREE.Line){f=f.type===THREE.LineStrip?i.LINE_STRIP:i.LINES;d=d.linewidth;if(d!==Ya){i.lineWidth(d);Ya=d}i.drawArrays(f,0,e.__webglLineCount);
+G.info.render.calls++}else if(f instanceof THREE.ParticleSystem){i.drawArrays(i.POINTS,0,e.__webglParticleCount);G.info.render.calls++;G.info.render.points=G.info.render.points+e.__webglParticleCount}else if(f instanceof THREE.Ribbon){i.drawArrays(i.TRIANGLE_STRIP,0,e.__webglVertexCount);G.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,h,m,n=a.__lights,o=a.fog;H=-1;Na=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&
+a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);xa.multiply(b.projectionMatrix,b.matrixWorldInverse);Da.setFromMatrix(xa);this.autoUpdateObjects&&this.initWebGLObjects(a);k(this.renderPluginsPre,a,b);G.info.render.calls=0;G.info.render.vertices=
+0;G.info.render.faces=0;G.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;d=0;for(e=m.length;d<e;d++){f=m[d];h=f.object;f.render=false;if(h.visible&&(!(h instanceof THREE.Mesh||h instanceof THREE.ParticleSystem)||!h.frustumCulled||Da.contains(h))){u(h,b);var p=f,q=p.object,r=p.buffer,s=void 0,s=s=void 0,s=q.material;if(s instanceof THREE.MeshFaceMaterial){s=r.materialIndex;if(s>=0){s=q.geometry.materials[s];
+if(s.transparent){p.transparent=s;p.opaque=null}else{p.opaque=s;p.transparent=null}}}else if(s)if(s.transparent){p.transparent=s;p.opaque=null}else{p.opaque=s;p.transparent=null}f.render=true;if(this.sortObjects)if(h.renderDepth)f.z=h.renderDepth;else{ka.copy(h.matrixWorld.getPosition());xa.multiplyVector3(ka);f.z=ka.z}}}this.sortObjects&&m.sort(g);m=a.__webglObjectsImmediate;d=0;for(e=m.length;d<e;d++){f=m[d];h=f.object;if(h.visible){u(h,b);h=f.object.material;if(h.transparent){f.transparent=h;f.opaque=
+null}else{f.opaque=h;f.transparent=null}}}if(a.overrideMaterial){d=a.overrideMaterial;this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst);this.setDepthTest(d.depthTest);this.setDepthWrite(d.depthWrite);t(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits);j(a.__webglObjects,false,"",b,n,o,true,d);l(a.__webglObjectsImmediate,"",b,n,o,false,d)}else{this.setBlending(THREE.NormalBlending);j(a.__webglObjects,true,"opaque",b,n,o,false);l(a.__webglObjectsImmediate,"opaque",b,n,o,false);
+j(a.__webglObjects,false,"transparent",b,n,o,true);l(a.__webglObjectsImmediate,"transparent",b,n,o,true)}k(this.renderPluginsPost,a,b);if(c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter)if(c instanceof THREE.WebGLRenderTargetCube){i.bindTexture(i.TEXTURE_CUBE_MAP,c.__webglTexture);i.generateMipmap(i.TEXTURE_CUBE_MAP);i.bindTexture(i.TEXTURE_CUBE_MAP,null)}else{i.bindTexture(i.TEXTURE_2D,c.__webglTexture);i.generateMipmap(i.TEXTURE_2D);i.bindTexture(i.TEXTURE_2D,
+null)}this.setDepthTest(true);this.setDepthWrite(true)};this.renderImmediateObject=function(a,b,c,d,e){var f=r(a,b,c,d,e);ea=-1;G.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(f,i,Da):e.render(function(a){G.renderBufferImmediate(a,f,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects){a.__webglObjects=[];a.__webglObjectsImmediate=[];a.__webglSprites=[];a.__webglFlares=[]}for(;a.__objectsAdded.length;){var g=a.__objectsAdded[0],h=a,k=void 0,j=void 0,l=void 0;
+if(!g.__webglInit){g.__webglInit=true;g._modelViewMatrix=new THREE.Matrix4;g._normalMatrix=new THREE.Matrix3;if(g instanceof THREE.Mesh){j=g.geometry;if(j instanceof THREE.Geometry){if(j.geometryGroups===void 0){var r=j,s=void 0,u=void 0,t=void 0,v=void 0,x=void 0,y=void 0,z=void 0,B={},C=r.morphTargets.length,H=r.morphNormals.length;r.geometryGroups={};s=0;for(u=r.faces.length;s<u;s++){t=r.faces[s];v=t.materialIndex;y=v!==void 0?v:-1;B[y]===void 0&&(B[y]={hash:y,counter:0});z=B[y].hash+"_"+B[y].counter;
+r.geometryGroups[z]===void 0&&(r.geometryGroups[z]={faces3:[],faces4:[],materialIndex:v,vertices:0,numMorphTargets:C,numMorphNormals:H});x=t instanceof THREE.Face3?3:4;if(r.geometryGroups[z].vertices+x>65535){B[y].counter=B[y].counter+1;z=B[y].hash+"_"+B[y].counter;r.geometryGroups[z]===void 0&&(r.geometryGroups[z]={faces3:[],faces4:[],materialIndex:v,vertices:0,numMorphTargets:C,numMorphNormals:H})}t instanceof THREE.Face3?r.geometryGroups[z].faces3.push(s):r.geometryGroups[z].faces4.push(s);r.geometryGroups[z].vertices=
+r.geometryGroups[z].vertices+x}r.geometryGroupsList=[];var F=void 0;for(F in r.geometryGroups){r.geometryGroups[F].id=wa++;r.geometryGroupsList.push(r.geometryGroups[F])}}for(k in j.geometryGroups){l=j.geometryGroups[k];if(!l.__webglVertexBuffer){var D=l;D.__webglVertexBuffer=i.createBuffer();D.__webglNormalBuffer=i.createBuffer();D.__webglTangentBuffer=i.createBuffer();D.__webglColorBuffer=i.createBuffer();D.__webglUVBuffer=i.createBuffer();D.__webglUV2Buffer=i.createBuffer();D.__webglSkinVertexABuffer=
+i.createBuffer();D.__webglSkinVertexBBuffer=i.createBuffer();D.__webglSkinIndicesBuffer=i.createBuffer();D.__webglSkinWeightsBuffer=i.createBuffer();D.__webglFaceBuffer=i.createBuffer();D.__webglLineBuffer=i.createBuffer();var Y=void 0,I=void 0;if(D.numMorphTargets){D.__webglMorphTargetsBuffers=[];Y=0;for(I=D.numMorphTargets;Y<I;Y++)D.__webglMorphTargetsBuffers.push(i.createBuffer())}if(D.numMorphNormals){D.__webglMorphNormalsBuffers=[];Y=0;for(I=D.numMorphNormals;Y<I;Y++)D.__webglMorphNormalsBuffers.push(i.createBuffer())}G.info.memory.geometries++;
 var P=l,K=g,O=K.geometry,M=P.faces3,Q=P.faces4,L=M.length*3+Q.length*4,Z=M.length*1+Q.length*2,S=M.length*3+Q.length*4,T=c(K,P),da=e(T),ea=d(T),X=T.vertexColors?T.vertexColors:false;P.__vertexArray=new Float32Array(L*3);if(ea)P.__normalArray=new Float32Array(L*3);if(O.hasTangents)P.__tangentArray=new Float32Array(L*4);if(X)P.__colorArray=new Float32Array(L*3);if(da){if(O.faceUvs.length>0||O.faceVertexUvs.length>0)P.__uvArray=new Float32Array(L*2);if(O.faceUvs.length>1||O.faceVertexUvs.length>1)P.__uv2Array=
 var P=l,K=g,O=K.geometry,M=P.faces3,Q=P.faces4,L=M.length*3+Q.length*4,Z=M.length*1+Q.length*2,S=M.length*3+Q.length*4,T=c(K,P),da=e(T),ea=d(T),X=T.vertexColors?T.vertexColors:false;P.__vertexArray=new Float32Array(L*3);if(ea)P.__normalArray=new Float32Array(L*3);if(O.hasTangents)P.__tangentArray=new Float32Array(L*4);if(X)P.__colorArray=new Float32Array(L*3);if(da){if(O.faceUvs.length>0||O.faceVertexUvs.length>0)P.__uvArray=new Float32Array(L*2);if(O.faceUvs.length>1||O.faceVertexUvs.length>1)P.__uv2Array=
 new Float32Array(L*2)}if(K.geometry.skinWeights.length&&K.geometry.skinIndices.length){P.__skinVertexAArray=new Float32Array(L*4);P.__skinVertexBArray=new Float32Array(L*4);P.__skinIndexArray=new Float32Array(L*4);P.__skinWeightArray=new Float32Array(L*4)}P.__faceArray=new Uint16Array(Z*3);P.__lineArray=new Uint16Array(S*2);var $=void 0,ga=void 0;if(P.numMorphTargets){P.__morphTargetsArrays=[];$=0;for(ga=P.numMorphTargets;$<ga;$++)P.__morphTargetsArrays.push(new Float32Array(L*3))}if(P.numMorphNormals){P.__morphNormalsArrays=
 new Float32Array(L*2)}if(K.geometry.skinWeights.length&&K.geometry.skinIndices.length){P.__skinVertexAArray=new Float32Array(L*4);P.__skinVertexBArray=new Float32Array(L*4);P.__skinIndexArray=new Float32Array(L*4);P.__skinWeightArray=new Float32Array(L*4)}P.__faceArray=new Uint16Array(Z*3);P.__lineArray=new Uint16Array(S*2);var $=void 0,ga=void 0;if(P.numMorphTargets){P.__morphTargetsArrays=[];$=0;for(ga=P.numMorphTargets;$<ga;$++)P.__morphTargetsArrays.push(new Float32Array(L*3))}if(P.numMorphNormals){P.__morphNormalsArrays=
 [];$=0;for(ga=P.numMorphNormals;$<ga;$++)P.__morphNormalsArrays.push(new Float32Array(L*3))}P.__webglFaceCount=Z*3;P.__webglLineCount=S*2;if(T.attributes){if(P.__webglCustomAttributesList===void 0)P.__webglCustomAttributesList=[];var Ma=void 0;for(Ma in T.attributes){var Qa=T.attributes[Ma],na={},Ra;for(Ra in Qa)na[Ra]=Qa[Ra];if(!na.__webglInitialized||na.createUniqueBuffers){na.__webglInitialized=true;var ka=1;na.type==="v2"?ka=2:na.type==="v3"?ka=3:na.type==="v4"?ka=4:na.type==="c"&&(ka=3);na.size=
 [];$=0;for(ga=P.numMorphNormals;$<ga;$++)P.__morphNormalsArrays.push(new Float32Array(L*3))}P.__webglFaceCount=Z*3;P.__webglLineCount=S*2;if(T.attributes){if(P.__webglCustomAttributesList===void 0)P.__webglCustomAttributesList=[];var Ma=void 0;for(Ma in T.attributes){var Qa=T.attributes[Ma],na={},Ra;for(Ra in Qa)na[Ra]=Qa[Ra];if(!na.__webglInitialized||na.createUniqueBuffers){na.__webglInitialized=true;var ka=1;na.type==="v2"?ka=2:na.type==="v3"?ka=3:na.type==="v4"?ka=4:na.type==="c"&&(ka=3);na.size=

+ 70 - 70
build/custom/ThreeWebGL.js

@@ -251,11 +251,11 @@ var j=a.colors,l=j.length,k=a.__vertexArray,m=a.__colorArray,n=a.__sortArray,p=a
 if(i.boundTo===void 0||i.boundTo==="vertices"){g=0;e=i.value.length;if(i.size===1)for(d=0;d<e;d++){h=n[d][1];i.array[d]=i.value[h]}else if(i.size===2)for(d=0;d<e;d++){h=n[d][1];h=i.value[h];i.array[g]=h.x;i.array[g+1]=h.y;g=g+2}else if(i.size===3)if(i.type==="c")for(d=0;d<e;d++){h=n[d][1];h=i.value[h];i.array[g]=h.r;i.array[g+1]=h.g;i.array[g+2]=h.b;g=g+3}else for(d=0;d<e;d++){h=n[d][1];h=i.value[h];i.array[g]=h.x;i.array[g+1]=h.y;i.array[g+2]=h.z;g=g+3}else if(i.size===4)for(d=0;d<e;d++){h=n[d][1];
 if(i.boundTo===void 0||i.boundTo==="vertices"){g=0;e=i.value.length;if(i.size===1)for(d=0;d<e;d++){h=n[d][1];i.array[d]=i.value[h]}else if(i.size===2)for(d=0;d<e;d++){h=n[d][1];h=i.value[h];i.array[g]=h.x;i.array[g+1]=h.y;g=g+2}else if(i.size===3)if(i.type==="c")for(d=0;d<e;d++){h=n[d][1];h=i.value[h];i.array[g]=h.r;i.array[g+1]=h.g;i.array[g+2]=h.b;g=g+3}else for(d=0;d<e;d++){h=n[d][1];h=i.value[h];i.array[g]=h.x;i.array[g+1]=h.y;i.array[g+2]=h.z;g=g+3}else if(i.size===4)for(d=0;d<e;d++){h=n[d][1];
 h=i.value[h];i.array[g]=h.x;i.array[g+1]=h.y;i.array[g+2]=h.z;i.array[g+3]=h.w;g=g+4}}}}}else{if(p)for(d=0;d<h;d++){e=i[d];g=d*3;k[g]=e.x;k[g+1]=e.y;k[g+2]=e.z}if(o)for(d=0;d<l;d++){e=j[d];g=d*3;m[g]=e.r;m[g+1]=e.g;m[g+2]=e.b}if(q){j=0;for(l=q.length;j<l;j++){i=q[j];if(i.needsUpdate&&(i.boundTo===void 0||i.boundTo==="vertices")){e=i.value.length;g=0;if(i.size===1)for(d=0;d<e;d++)i.array[d]=i.value[d];else if(i.size===2)for(d=0;d<e;d++){h=i.value[d];i.array[g]=h.x;i.array[g+1]=h.y;g=g+2}else if(i.size===
 h=i.value[h];i.array[g]=h.x;i.array[g+1]=h.y;i.array[g+2]=h.z;i.array[g+3]=h.w;g=g+4}}}}}else{if(p)for(d=0;d<h;d++){e=i[d];g=d*3;k[g]=e.x;k[g+1]=e.y;k[g+2]=e.z}if(o)for(d=0;d<l;d++){e=j[d];g=d*3;m[g]=e.r;m[g+1]=e.g;m[g+2]=e.b}if(q){j=0;for(l=q.length;j<l;j++){i=q[j];if(i.needsUpdate&&(i.boundTo===void 0||i.boundTo==="vertices")){e=i.value.length;g=0;if(i.size===1)for(d=0;d<e;d++)i.array[d]=i.value[d];else if(i.size===2)for(d=0;d<e;d++){h=i.value[d];i.array[g]=h.x;i.array[g+1]=h.y;g=g+2}else if(i.size===
 3)if(i.type==="c")for(d=0;d<e;d++){h=i.value[d];i.array[g]=h.r;i.array[g+1]=h.g;i.array[g+2]=h.b;g=g+3}else for(d=0;d<e;d++){h=i.value[d];i.array[g]=h.x;i.array[g+1]=h.y;i.array[g+2]=h.z;g=g+3}else if(i.size===4)for(d=0;d<e;d++){h=i.value[d];i.array[g]=h.x;i.array[g+1]=h.y;i.array[g+2]=h.z;i.array[g+3]=h.w;g=g+4}}}}}if(p||c.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,a.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,k,b)}if(o||c.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,a.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,
 3)if(i.type==="c")for(d=0;d<e;d++){h=i.value[d];i.array[g]=h.r;i.array[g+1]=h.g;i.array[g+2]=h.b;g=g+3}else for(d=0;d<e;d++){h=i.value[d];i.array[g]=h.x;i.array[g+1]=h.y;i.array[g+2]=h.z;g=g+3}else if(i.size===4)for(d=0;d<e;d++){h=i.value[d];i.array[g]=h.x;i.array[g+1]=h.y;i.array[g+2]=h.z;i.array[g+3]=h.w;g=g+4}}}}}if(p||c.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,a.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,k,b)}if(o||c.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,a.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,
-m,b)}if(q){j=0;for(l=q.length;j<l;j++){i=q[j];if(i.needsUpdate||c.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,i.buffer);f.bufferData(f.ARRAY_BUFFER,i.array,b)}}}}function h(a,b){return b.z-a.z}function k(a,b){return a-b}function m(a,b,c){if(a.length)for(var d=0,f=a.length;d<f;d++){$=F=null;R=ga=za=S=Xa=Fa=Ia=-1;nb=true;a[d].render(b,c,tc,$b);$=F=null;R=ga=za=S=Xa=Fa=Ia=-1;nb=true}}function j(a,b,c,d,f,e,g,h){var i,j,l,k;if(b){j=a.length-1;k=b=-1}else{j=0;b=a.length;k=1}for(var m=j;m!==b;m=m+k){i=a[m];
-if(i.render){j=i.object;l=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;g&&E.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);E.setDepthTest(i.depthTest);E.setDepthWrite(i.depthWrite);r(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}E.setObjectFaces(j);l instanceof THREE.BufferGeometry?E.renderBufferDirect(d,f,e,i,l,j):E.renderBuffer(d,f,e,i,l,j)}}}function i(a,b,c,d,f,e,g){for(var i,h,j=0,l=a.length;j<l;j++){i=a[j];h=i.object;if(h.visible){if(g)i=g;else{i=i[b];if(!i)continue;
-e&&E.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);E.setDepthTest(i.depthTest);E.setDepthWrite(i.depthWrite);r(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}E.renderImmediateObject(c,d,f,i,h)}}}function p(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function l(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function v(a){for(var b in a.attributes)a.attributes[b].needsUpdate=false}function o(a,b){for(var c=a.length-
-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function q(a,b,c,d,e){if(!d.program||d.needsUpdate){E.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(E.maxMorphTargets);for(var g=0,i=E.maxMorphTargets;g<i;g++)e.__webglMorphTargetInfluences[g]=0}var h=false,g=d.program,i=g.uniforms,j=d.uniforms;if(g!==F){f.useProgram(g);F=g;h=true}if(d.id!==R){R=
-d.id;h=true}if(h||a!==$){f.uniformMatrix4fv(i.projectionMatrix,false,a._projectionMatrixArray);a!==$&&($=a)}if(h){if(c&&d.fog){j.fogColor.value=c.color;if(c instanceof THREE.Fog){j.fogNear.value=c.near;j.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(nb){for(var l,k=0,m=0,n=0,p,o,q,r=ac,v=r.directional.colors,s=r.directional.positions,w=r.point.colors,z=r.point.positions,
+m,b)}if(q){j=0;for(l=q.length;j<l;j++){i=q[j];if(i.needsUpdate||c.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,i.buffer);f.bufferData(f.ARRAY_BUFFER,i.array,b)}}}}function h(a,b){return b.z-a.z}function k(a,b){return b[1]-a[1]}function m(a,b,c){if(a.length)for(var d=0,f=a.length;d<f;d++){$=F=null;R=ga=za=S=Xa=Fa=Ia=-1;nb=true;a[d].render(b,c,tc,$b);$=F=null;R=ga=za=S=Xa=Fa=Ia=-1;nb=true}}function j(a,b,c,d,f,e,g,h){var i,j,l,k;if(b){j=a.length-1;k=b=-1}else{j=0;b=a.length;k=1}for(var m=j;m!==b;m=m+
+k){i=a[m];if(i.render){j=i.object;l=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;g&&E.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);E.setDepthTest(i.depthTest);E.setDepthWrite(i.depthWrite);r(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}E.setObjectFaces(j);l instanceof THREE.BufferGeometry?E.renderBufferDirect(d,f,e,i,l,j):E.renderBuffer(d,f,e,i,l,j)}}}function i(a,b,c,d,f,e,g){for(var i,h,j=0,l=a.length;j<l;j++){i=a[j];h=i.object;if(h.visible){if(g)i=g;else{i=i[b];
+if(!i)continue;e&&E.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);E.setDepthTest(i.depthTest);E.setDepthWrite(i.depthWrite);r(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}E.renderImmediateObject(c,d,f,i,h)}}}function p(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function l(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function v(a){for(var b in a.attributes)a.attributes[b].needsUpdate=false}function o(a,b){for(var c=
+a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function q(a,b,c,d,e){if(!d.program||d.needsUpdate){E.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(E.maxMorphTargets);for(var g=0,i=E.maxMorphTargets;g<i;g++)e.__webglMorphTargetInfluences[g]=0}var h=false,g=d.program,i=g.uniforms,j=d.uniforms;if(g!==F){f.useProgram(g);F=g;h=true}if(d.id!==
+R){R=d.id;h=true}if(h||a!==$){f.uniformMatrix4fv(i.projectionMatrix,false,a._projectionMatrixArray);a!==$&&($=a)}if(h){if(c&&d.fog){j.fogColor.value=c.color;if(c instanceof THREE.Fog){j.fogNear.value=c.near;j.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(nb){for(var l,k=0,m=0,n=0,p,o,q,r=ac,v=r.directional.colors,s=r.directional.positions,w=r.point.colors,z=r.point.positions,
 I=r.point.distances,D=r.spot.colors,K=r.spot.positions,L=r.spot.distances,H=r.spot.directions,P=r.spot.angles,W=r.spot.exponents,U=0,X=0,S=0,Q=q=0,c=Q=0,h=b.length;c<h;c++){l=b[c];if(!l.onlyShadow){p=l.color;o=l.intensity;q=l.distance;if(l instanceof THREE.AmbientLight)if(E.gammaInput){k=k+p.r*p.r;m=m+p.g*p.g;n=n+p.b*p.b}else{k=k+p.r;m=m+p.g;n=n+p.b}else if(l instanceof THREE.DirectionalLight){q=U*3;if(E.gammaInput){v[q]=p.r*p.r*o*o;v[q+1]=p.g*p.g*o*o;v[q+2]=p.b*p.b*o*o}else{v[q]=p.r*o;v[q+1]=p.g*
 I=r.point.distances,D=r.spot.colors,K=r.spot.positions,L=r.spot.distances,H=r.spot.directions,P=r.spot.angles,W=r.spot.exponents,U=0,X=0,S=0,Q=q=0,c=Q=0,h=b.length;c<h;c++){l=b[c];if(!l.onlyShadow){p=l.color;o=l.intensity;q=l.distance;if(l instanceof THREE.AmbientLight)if(E.gammaInput){k=k+p.r*p.r;m=m+p.g*p.g;n=n+p.b*p.b}else{k=k+p.r;m=m+p.g;n=n+p.b}else if(l instanceof THREE.DirectionalLight){q=U*3;if(E.gammaInput){v[q]=p.r*p.r*o*o;v[q+1]=p.g*p.g*o*o;v[q+2]=p.b*p.b*o*o}else{v[q]=p.r*o;v[q+1]=p.g*
 o;v[q+2]=p.b*o}Aa.copy(l.matrixWorld.getPosition());Aa.subSelf(l.target.matrixWorld.getPosition());Aa.normalize();s[q]=Aa.x;s[q+1]=Aa.y;s[q+2]=Aa.z;U=U+1}else if(l instanceof THREE.PointLight){Q=X*3;if(E.gammaInput){w[Q]=p.r*p.r*o*o;w[Q+1]=p.g*p.g*o*o;w[Q+2]=p.b*p.b*o*o}else{w[Q]=p.r*o;w[Q+1]=p.g*o;w[Q+2]=p.b*o}p=l.matrixWorld.getPosition();z[Q]=p.x;z[Q+1]=p.y;z[Q+2]=p.z;I[X]=q;X=X+1}else if(l instanceof THREE.SpotLight){Q=S*3;if(E.gammaInput){D[Q]=p.r*p.r*o*o;D[Q+1]=p.g*p.g*o*o;D[Q+2]=p.b*p.b*o*
 o;v[q+2]=p.b*o}Aa.copy(l.matrixWorld.getPosition());Aa.subSelf(l.target.matrixWorld.getPosition());Aa.normalize();s[q]=Aa.x;s[q+1]=Aa.y;s[q+2]=Aa.z;U=U+1}else if(l instanceof THREE.PointLight){Q=X*3;if(E.gammaInput){w[Q]=p.r*p.r*o*o;w[Q+1]=p.g*p.g*o*o;w[Q+2]=p.b*p.b*o*o}else{w[Q]=p.r*o;w[Q+1]=p.g*o;w[Q+2]=p.b*o}p=l.matrixWorld.getPosition();z[Q]=p.x;z[Q+1]=p.y;z[Q+2]=p.z;I[X]=q;X=X+1}else if(l instanceof THREE.SpotLight){Q=S*3;if(E.gammaInput){D[Q]=p.r*p.r*o*o;D[Q+1]=p.g*p.g*o*o;D[Q+2]=p.b*p.b*o*
 o}else{D[Q]=p.r*o;D[Q+1]=p.g*o;D[Q+2]=p.b*o}p=l.matrixWorld.getPosition();K[Q]=p.x;K[Q+1]=p.y;K[Q+2]=p.z;L[S]=q;Aa.copy(p);Aa.subSelf(l.target.matrixWorld.getPosition());Aa.normalize();H[Q]=Aa.x;H[Q+1]=Aa.y;H[Q+2]=Aa.z;P[S]=Math.cos(l.angle);W[S]=l.exponent;S=S+1}}}c=U*3;for(h=v.length;c<h;c++)v[c]=0;c=X*3;for(h=w.length;c<h;c++)w[c]=0;c=S*3;for(h=D.length;c<h;c++)D[c]=0;r.directional.length=U;r.point.length=X;r.spot.length=S;r.ambient[0]=k;r.ambient[1]=m;r.ambient[2]=n;nb=false}c=ac;j.ambientLightColor.value=
 o}else{D[Q]=p.r*o;D[Q+1]=p.g*o;D[Q+2]=p.b*o}p=l.matrixWorld.getPosition();K[Q]=p.x;K[Q+1]=p.y;K[Q+2]=p.z;L[S]=q;Aa.copy(p);Aa.subSelf(l.target.matrixWorld.getPosition());Aa.normalize();H[Q]=Aa.x;H[Q+1]=Aa.y;H[Q+2]=Aa.z;P[S]=Math.cos(l.angle);W[S]=l.exponent;S=S+1}}}c=U*3;for(h=v.length;c<h;c++)v[c]=0;c=X*3;for(h=w.length;c<h;c++)w[c]=0;c=S*3;for(h=D.length;c<h;c++)D[c]=0;r.directional.length=U;r.point.length=X;r.spot.length=S;r.ambient[0]=k;r.ambient[1]=m;r.ambient[2]=n;nb=false}c=ac;j.ambientLightColor.value=
@@ -295,71 +295,71 @@ if(a.normal>=0&&e.vertexNormalBuffer){f.bindBuffer(f.ARRAY_BUFFER,e.vertexNormal
 f.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,f.FLOAT,false,0,g[d].index*16)}f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)}f.drawElements(f.TRIANGLES,g[d].count,f.UNSIGNED_SHORT,g[d].start*2);E.info.render.calls++;E.info.render.vertices=E.info.render.vertices+g[d].count;E.info.render.faces=E.info.render.faces+g[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,g){if(d.visible!==false){var h,i,c=q(a,b,c,d,g),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);
 f.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,f.FLOAT,false,0,g[d].index*16)}f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)}f.drawElements(f.TRIANGLES,g[d].count,f.UNSIGNED_SHORT,g[d].start*2);E.info.render.calls++;E.info.render.vertices=E.info.render.vertices+g[d].count;E.info.render.faces=E.info.render.faces+g[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,g){if(d.visible!==false){var h,i,c=q(a,b,c,d,g),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);
 if(c!==ga){ga=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){f.bindBuffer(f.ARRAY_BUFFER,e.__webglVertexBuffer);f.vertexAttribPointer(b.position,3,f.FLOAT,false,0,0)}}else if(g.morphTargetBase){c=d.program.attributes;if(g.morphTargetBase!==-1){f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[g.morphTargetBase]);f.vertexAttribPointer(c.position,3,f.FLOAT,false,0,0)}else if(c.position>=0){f.bindBuffer(f.ARRAY_BUFFER,e.__webglVertexBuffer);f.vertexAttribPointer(c.position,3,f.FLOAT,false,
 if(c!==ga){ga=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){f.bindBuffer(f.ARRAY_BUFFER,e.__webglVertexBuffer);f.vertexAttribPointer(b.position,3,f.FLOAT,false,0,0)}}else if(g.morphTargetBase){c=d.program.attributes;if(g.morphTargetBase!==-1){f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[g.morphTargetBase]);f.vertexAttribPointer(c.position,3,f.FLOAT,false,0,0)}else if(c.position>=0){f.bindBuffer(f.ARRAY_BUFFER,e.__webglVertexBuffer);f.vertexAttribPointer(c.position,3,f.FLOAT,false,
 0,0)}if(g.morphTargetForcedOrder.length){var j=0;i=g.morphTargetForcedOrder;for(h=g.morphTargetInfluences;j<d.numSupportedMorphTargets&&j<i.length;){f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[j]]);f.vertexAttribPointer(c["morphTarget"+j],3,f.FLOAT,false,0,0);if(d.morphNormals){f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[i[j]]);f.vertexAttribPointer(c["morphNormal"+j],3,f.FLOAT,false,0,0)}g.__webglMorphTargetInfluences[j]=h[i[j]];j++}}else{i=[];h=g.morphTargetInfluences;
 0,0)}if(g.morphTargetForcedOrder.length){var j=0;i=g.morphTargetForcedOrder;for(h=g.morphTargetInfluences;j<d.numSupportedMorphTargets&&j<i.length;){f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[j]]);f.vertexAttribPointer(c["morphTarget"+j],3,f.FLOAT,false,0,0);if(d.morphNormals){f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[i[j]]);f.vertexAttribPointer(c["morphNormal"+j],3,f.FLOAT,false,0,0)}g.__webglMorphTargetInfluences[j]=h[i[j]];j++}}else{i=[];h=g.morphTargetInfluences;
-var l,m=h.length;for(l=0;l<m;l++){j=h[l];j>0&&i.push(l)}if(i.length>d.numSupportedMorphTargets){i.sort(k);i.length=d.numSupportedMorphTargets}else i.length>d.numSupportedMorphNormals?i.sort(k):i.length===0&&i.push(0);for(j=0;j<d.numSupportedMorphTargets;){l=i[j];if(l!==void 0||j===0){f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l]);f.vertexAttribPointer(c["morphTarget"+j],3,f.FLOAT,false,0,0);if(d.morphNormals){f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[l]);f.vertexAttribPointer(c["morphNormal"+
-j],3,f.FLOAT,false,0,0)}g.__webglMorphTargetInfluences[j]=h[l]}else{f.vertexAttribPointer(c["morphTarget"+j],3,f.FLOAT,false,0,0);d.morphNormals&&f.vertexAttribPointer(c["morphNormal"+j],3,f.FLOAT,false,0,0);g.__webglMorphTargetInfluences[j]=0}j++}}d.program.uniforms.morphTargetInfluences!==null&&f.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){h=0;for(i=e.__webglCustomAttributesList.length;h<i;h++){c=e.__webglCustomAttributesList[h];
-if(b[c.buffer.belongsToAttribute]>=0){f.bindBuffer(f.ARRAY_BUFFER,c.buffer);f.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,f.FLOAT,false,0,0)}}}if(b.color>=0){f.bindBuffer(f.ARRAY_BUFFER,e.__webglColorBuffer);f.vertexAttribPointer(b.color,3,f.FLOAT,false,0,0)}if(b.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,e.__webglNormalBuffer);f.vertexAttribPointer(b.normal,3,f.FLOAT,false,0,0)}if(b.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,e.__webglTangentBuffer);f.vertexAttribPointer(b.tangent,4,f.FLOAT,
-false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,e.__webglUVBuffer);f.vertexAttribPointer(b.uv,2,f.FLOAT,false,0,0);f.enableVertexAttribArray(b.uv)}else f.disableVertexAttribArray(b.uv);if(b.uv2>=0)if(e.__webglUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,e.__webglUV2Buffer);f.vertexAttribPointer(b.uv2,2,f.FLOAT,false,0,0);f.enableVertexAttribArray(b.uv2)}else f.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER,
-e.__webglSkinVertexABuffer);f.vertexAttribPointer(b.skinVertexA,4,f.FLOAT,false,0,0);f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinVertexBBuffer);f.vertexAttribPointer(b.skinVertexB,4,f.FLOAT,false,0,0);f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);f.vertexAttribPointer(b.skinIndex,4,f.FLOAT,false,0,0);f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);f.vertexAttribPointer(b.skinWeight,4,f.FLOAT,false,0,0)}}if(g instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==tb){f.lineWidth(d);
-tb=d}a&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);f.drawElements(f.LINES,e.__webglLineCount,f.UNSIGNED_SHORT,0)}else{a&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer);f.drawElements(f.TRIANGLES,e.__webglFaceCount,f.UNSIGNED_SHORT,0)}E.info.render.calls++;E.info.render.vertices=E.info.render.vertices+e.__webglFaceCount;E.info.render.faces=E.info.render.faces+e.__webglFaceCount/3}else if(g instanceof THREE.Line){g=g.type===THREE.LineStrip?f.LINE_STRIP:f.LINES;d=d.linewidth;
-if(d!==tb){f.lineWidth(d);tb=d}f.drawArrays(g,0,e.__webglLineCount);E.info.render.calls++}else if(g instanceof THREE.ParticleSystem){f.drawArrays(f.POINTS,0,e.__webglParticleCount);E.info.render.calls++;E.info.render.points=E.info.render.points+e.__webglParticleCount}else if(g instanceof THREE.Ribbon){f.drawArrays(f.TRIANGLE_STRIP,0,e.__webglVertexCount);E.info.render.calls++}}};this.render=function(a,b,c,d){var e,g,l,k,n=a.__lights,p=a.fog;R=-1;nb=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");
-a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Ib.multiply(b.projectionMatrix,b.matrixWorldInverse);Kb.setFromMatrix(Ib);this.autoUpdateObjects&&this.initWebGLObjects(a);m(this.renderPluginsPre,
-a,b);E.info.render.calls=0;E.info.render.vertices=0;E.info.render.faces=0;E.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);k=a.__webglObjects;d=0;for(e=k.length;d<e;d++){g=k[d];l=g.object;g.render=false;if(l.visible&&(!(l instanceof THREE.Mesh||l instanceof THREE.ParticleSystem)||!l.frustumCulled||Kb.contains(l))){w(l,b);var o=g,q=o.object,v=o.buffer,s=void 0,s=s=void 0,s=q.material;if(s instanceof THREE.MeshFaceMaterial){s=
-v.materialIndex;if(s>=0){s=q.geometry.materials[s];if(s.transparent){o.transparent=s;o.opaque=null}else{o.opaque=s;o.transparent=null}}}else if(s)if(s.transparent){o.transparent=s;o.opaque=null}else{o.opaque=s;o.transparent=null}g.render=true;if(this.sortObjects)if(l.renderDepth)g.z=l.renderDepth;else{Na.copy(l.matrixWorld.getPosition());Ib.multiplyVector3(Na);g.z=Na.z}}}this.sortObjects&&k.sort(h);k=a.__webglObjectsImmediate;d=0;for(e=k.length;d<e;d++){g=k[d];l=g.object;if(l.visible){w(l,b);l=g.object.material;
-if(l.transparent){g.transparent=l;g.opaque=null}else{g.opaque=l;g.transparent=null}}}if(a.overrideMaterial){d=a.overrideMaterial;this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst);this.setDepthTest(d.depthTest);this.setDepthWrite(d.depthWrite);r(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits);j(a.__webglObjects,false,"",b,n,p,true,d);i(a.__webglObjectsImmediate,"",b,n,p,false,d)}else{this.setBlending(THREE.NormalBlending);j(a.__webglObjects,true,"opaque",b,n,p,false);i(a.__webglObjectsImmediate,
-"opaque",b,n,p,false);j(a.__webglObjects,false,"transparent",b,n,p,true);i(a.__webglObjectsImmediate,"transparent",b,n,p,true)}m(this.renderPluginsPost,a,b);if(c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter)if(c instanceof THREE.WebGLRenderTargetCube){f.bindTexture(f.TEXTURE_CUBE_MAP,c.__webglTexture);f.generateMipmap(f.TEXTURE_CUBE_MAP);f.bindTexture(f.TEXTURE_CUBE_MAP,null)}else{f.bindTexture(f.TEXTURE_2D,c.__webglTexture);f.generateMipmap(f.TEXTURE_2D);
-f.bindTexture(f.TEXTURE_2D,null)}this.setDepthTest(true);this.setDepthWrite(true)};this.renderImmediateObject=function(a,b,c,d,e){var g=q(a,b,c,d,e);ga=-1;E.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(g,f,Kb):e.render(function(a){E.renderBufferImmediate(a,g,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects){a.__webglObjects=[];a.__webglObjectsImmediate=[];a.__webglSprites=[];a.__webglFlares=[]}for(;a.__objectsAdded.length;){var h=a.__objectsAdded[0],i=
-a,j=void 0,k=void 0,m=void 0;if(!h.__webglInit){h.__webglInit=true;h._modelViewMatrix=new THREE.Matrix4;h._normalMatrix=new THREE.Matrix3;if(h instanceof THREE.Mesh){k=h.geometry;if(k instanceof THREE.Geometry){if(k.geometryGroups===void 0){var r=k,q=void 0,s=void 0,w=void 0,z=void 0,C=void 0,A=void 0,D=void 0,F={},I=r.morphTargets.length,K=r.morphNormals.length;r.geometryGroups={};q=0;for(s=r.faces.length;q<s;q++){w=r.faces[q];z=w.materialIndex;A=z!==void 0?z:-1;F[A]===void 0&&(F[A]={hash:A,counter:0});
-D=F[A].hash+"_"+F[A].counter;r.geometryGroups[D]===void 0&&(r.geometryGroups[D]={faces3:[],faces4:[],materialIndex:z,vertices:0,numMorphTargets:I,numMorphNormals:K});C=w instanceof THREE.Face3?3:4;if(r.geometryGroups[D].vertices+C>65535){F[A].counter=F[A].counter+1;D=F[A].hash+"_"+F[A].counter;r.geometryGroups[D]===void 0&&(r.geometryGroups[D]={faces3:[],faces4:[],materialIndex:z,vertices:0,numMorphTargets:I,numMorphNormals:K})}w instanceof THREE.Face3?r.geometryGroups[D].faces3.push(q):r.geometryGroups[D].faces4.push(q);
-r.geometryGroups[D].vertices=r.geometryGroups[D].vertices+C}r.geometryGroupsList=[];var L=void 0;for(L in r.geometryGroups){r.geometryGroups[L].id=Ea++;r.geometryGroupsList.push(r.geometryGroups[L])}}for(j in k.geometryGroups){m=k.geometryGroups[j];if(!m.__webglVertexBuffer){var H=m;H.__webglVertexBuffer=f.createBuffer();H.__webglNormalBuffer=f.createBuffer();H.__webglTangentBuffer=f.createBuffer();H.__webglColorBuffer=f.createBuffer();H.__webglUVBuffer=f.createBuffer();H.__webglUV2Buffer=f.createBuffer();
-H.__webglSkinVertexABuffer=f.createBuffer();H.__webglSkinVertexBBuffer=f.createBuffer();H.__webglSkinIndicesBuffer=f.createBuffer();H.__webglSkinWeightsBuffer=f.createBuffer();H.__webglFaceBuffer=f.createBuffer();H.__webglLineBuffer=f.createBuffer();var P=void 0,Q=void 0;if(H.numMorphTargets){H.__webglMorphTargetsBuffers=[];P=0;for(Q=H.numMorphTargets;P<Q;P++)H.__webglMorphTargetsBuffers.push(f.createBuffer())}if(H.numMorphNormals){H.__webglMorphNormalsBuffers=[];P=0;for(Q=H.numMorphNormals;P<Q;P++)H.__webglMorphNormalsBuffers.push(f.createBuffer())}E.info.memory.geometries++;
-var G=m,U=h,S=U.geometry,W=G.faces3,X=G.faces4,R=W.length*3+X.length*4,fa=W.length*1+X.length*2,ga=W.length*3+X.length*4,$=c(U,G),za=e($),Da=d($),Ia=$.vertexColors?$.vertexColors:false;G.__vertexArray=new Float32Array(R*3);if(Da)G.__normalArray=new Float32Array(R*3);if(S.hasTangents)G.__tangentArray=new Float32Array(R*4);if(Ia)G.__colorArray=new Float32Array(R*3);if(za){if(S.faceUvs.length>0||S.faceVertexUvs.length>0)G.__uvArray=new Float32Array(R*2);if(S.faceUvs.length>1||S.faceVertexUvs.length>
-1)G.__uv2Array=new Float32Array(R*2)}if(U.geometry.skinWeights.length&&U.geometry.skinIndices.length){G.__skinVertexAArray=new Float32Array(R*4);G.__skinVertexBArray=new Float32Array(R*4);G.__skinIndexArray=new Float32Array(R*4);G.__skinWeightArray=new Float32Array(R*4)}G.__faceArray=new Uint16Array(fa*3);G.__lineArray=new Uint16Array(ga*2);var Aa=void 0,Fa=void 0;if(G.numMorphTargets){G.__morphTargetsArrays=[];Aa=0;for(Fa=G.numMorphTargets;Aa<Fa;Aa++)G.__morphTargetsArrays.push(new Float32Array(R*
-3))}if(G.numMorphNormals){G.__morphNormalsArrays=[];Aa=0;for(Fa=G.numMorphNormals;Aa<Fa;Aa++)G.__morphNormalsArrays.push(new Float32Array(R*3))}G.__webglFaceCount=fa*3;G.__webglLineCount=ga*2;if($.attributes){if(G.__webglCustomAttributesList===void 0)G.__webglCustomAttributesList=[];var Ra=void 0;for(Ra in $.attributes){var Sa=$.attributes[Ra],Ma={},Ua;for(Ua in Sa)Ma[Ua]=Sa[Ua];if(!Ma.__webglInitialized||Ma.createUniqueBuffers){Ma.__webglInitialized=true;var Na=1;Ma.type==="v2"?Na=2:Ma.type==="v3"?
-Na=3:Ma.type==="v4"?Na=4:Ma.type==="c"&&(Na=3);Ma.size=Na;Ma.array=new Float32Array(R*Na);Ma.buffer=f.createBuffer();Ma.buffer.belongsToAttribute=Ra;Sa.needsUpdate=true;Ma.__original=Sa}G.__webglCustomAttributesList.push(Ma)}}G.__inittedArrays=true;k.verticesNeedUpdate=true;k.morphTargetsNeedUpdate=true;k.elementsNeedUpdate=true;k.uvsNeedUpdate=true;k.normalsNeedUpdate=true;k.tangetsNeedUpdate=true;k.colorsNeedUpdate=true}}}}else if(h instanceof THREE.Ribbon){k=h.geometry;if(!k.__webglVertexBuffer){var nb=
-k;nb.__webglVertexBuffer=f.createBuffer();nb.__webglColorBuffer=f.createBuffer();E.info.memory.geometries++;var Xa=k,tb=Xa.vertices.length;Xa.__vertexArray=new Float32Array(tb*3);Xa.__colorArray=new Float32Array(tb*3);Xa.__webglVertexCount=tb;k.verticesNeedUpdate=true;k.colorsNeedUpdate=true}}else if(h instanceof THREE.Line){k=h.geometry;if(!k.__webglVertexBuffer){var Ib=k;Ib.__webglVertexBuffer=f.createBuffer();Ib.__webglColorBuffer=f.createBuffer();E.info.memory.geometries++;var dc=k,Zb=h,Hb=dc.vertices.length;
-dc.__vertexArray=new Float32Array(Hb*3);dc.__colorArray=new Float32Array(Hb*3);dc.__webglLineCount=Hb;b(dc,Zb);k.verticesNeedUpdate=true;k.colorsNeedUpdate=true}}else if(h instanceof THREE.ParticleSystem){k=h.geometry;if(!k.__webglVertexBuffer){var Qb=k;Qb.__webglVertexBuffer=f.createBuffer();Qb.__webglColorBuffer=f.createBuffer();E.info.geometries++;var Rb=k,bc=h,Jb=Rb.vertices.length;Rb.__vertexArray=new Float32Array(Jb*3);Rb.__colorArray=new Float32Array(Jb*3);Rb.__sortArray=[];Rb.__webglParticleCount=
-Jb;b(Rb,bc);k.verticesNeedUpdate=true;k.colorsNeedUpdate=true}}}if(!h.__webglActive){if(h instanceof THREE.Mesh){k=h.geometry;if(k instanceof THREE.BufferGeometry)p(i.__webglObjects,k,h);else for(j in k.geometryGroups){m=k.geometryGroups[j];p(i.__webglObjects,m,h)}}else if(h instanceof THREE.Ribbon||h instanceof THREE.Line||h instanceof THREE.ParticleSystem){k=h.geometry;p(i.__webglObjects,k,h)}else h instanceof THREE.ImmediateRenderObject||h.immediateRenderCallback?i.__webglObjectsImmediate.push({object:h,
-opaque:null,transparent:null}):h instanceof THREE.Sprite?i.__webglSprites.push(h):h instanceof THREE.LensFlare&&i.__webglFlares.push(h);h.__webglActive=true}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var Oa=a.__objectsRemoved[0],uc=a;Oa instanceof THREE.Mesh||Oa instanceof THREE.ParticleSystem||Oa instanceof THREE.Ribbon||Oa instanceof THREE.Line?o(uc.__webglObjects,Oa):Oa instanceof THREE.Sprite?n(uc.__webglSprites,Oa):Oa instanceof THREE.LensFlare?n(uc.__webglFlares,Oa):(Oa instanceof
-THREE.ImmediateRenderObject||Oa.immediateRenderCallback)&&o(uc.__webglObjectsImmediate,Oa);Oa.__webglActive=false;a.__objectsRemoved.splice(0,1)}for(var Kb=0,qc=a.__webglObjects.length;Kb<qc;Kb++){var Va=a.__webglObjects[Kb].object,Z=Va.geometry,ec=void 0,Sb=void 0,Ga=void 0;if(Va instanceof THREE.Mesh)if(Z instanceof THREE.BufferGeometry){Z.verticesNeedUpdate=false;Z.elementsNeedUpdate=false;Z.uvsNeedUpdate=false;Z.normalsNeedUpdate=false;Z.colorsNeedUpdate=false}else{for(var Kc=0,rc=Z.geometryGroupsList.length;Kc<
-rc;Kc++){ec=Z.geometryGroupsList[Kc];Ga=c(Va,ec);Sb=Ga.attributes&&l(Ga);if(Z.verticesNeedUpdate||Z.morphTargetsNeedUpdate||Z.elementsNeedUpdate||Z.uvsNeedUpdate||Z.normalsNeedUpdate||Z.colorsNeedUpdate||Z.tangetsNeedUpdate||Sb){var V=ec,sc=Va,Ja=f.DYNAMIC_DRAW,tc=!Z.dynamic,Lb=Ga;if(V.__inittedArrays){var $b=d(Lb),Lc=Lb.vertexColors?Lb.vertexColors:false,ac=e(Lb),vc=$b===THREE.SmoothShading,x=void 0,J=void 0,Ta=void 0,B=void 0,Tb=void 0,ub=void 0,Wa=void 0,wc=void 0,ob=void 0,Ub=void 0,Vb=void 0,
-M=void 0,N=void 0,O=void 0,da=void 0,Ya=void 0,Za=void 0,$a=void 0,fc=void 0,ab=void 0,bb=void 0,cb=void 0,gc=void 0,db=void 0,eb=void 0,fb=void 0,hc=void 0,gb=void 0,hb=void 0,ib=void 0,ic=void 0,jb=void 0,kb=void 0,lb=void 0,jc=void 0,vb=void 0,wb=void 0,xb=void 0,xc=void 0,yb=void 0,zb=void 0,Ab=void 0,yc=void 0,aa=void 0,cc=void 0,Bb=void 0,Wb=void 0,Xb=void 0,ua=void 0,Tc=void 0,sa=void 0,ta=void 0,Cb=void 0,pb=void 0,oa=0,ra=0,qb=0,rb=0,Pa=0,ya=0,ea=0,Ba=0,pa=0,y=0,T=0,u=0,Ka=void 0,va=V.__vertexArray,
-kc=V.__uvArray,lc=V.__uv2Array,Qa=V.__normalArray,ia=V.__tangentArray,wa=V.__colorArray,ja=V.__skinVertexAArray,ka=V.__skinVertexBArray,la=V.__skinIndexArray,ma=V.__skinWeightArray,Mc=V.__morphTargetsArrays,Nc=V.__morphNormalsArrays,Oc=V.__webglCustomAttributesList,t=void 0,mb=V.__faceArray,La=V.__lineArray,Ca=sc.geometry,Jc=Ca.elementsNeedUpdate,Uc=Ca.uvsNeedUpdate,ad=Ca.normalsNeedUpdate,bd=Ca.tangetsNeedUpdate,cd=Ca.colorsNeedUpdate,dd=Ca.morphTargetsNeedUpdate,Mb=Ca.vertices,ba=V.faces3,ca=V.faces4,
-qa=Ca.faces,Pc=Ca.faceVertexUvs[0],Qc=Ca.faceVertexUvs[1],Nb=Ca.skinVerticesA,Ob=Ca.skinVerticesB,Pb=Ca.skinIndices,Db=Ca.skinWeights,Eb=Ca.morphTargets,zc=Ca.morphNormals;if(Ca.verticesNeedUpdate){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];M=Mb[B.a];N=Mb[B.b];O=Mb[B.c];va[ra]=M.x;va[ra+1]=M.y;va[ra+2]=M.z;va[ra+3]=N.x;va[ra+4]=N.y;va[ra+5]=N.z;va[ra+6]=O.x;va[ra+7]=O.y;va[ra+8]=O.z;ra=ra+9}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];M=Mb[B.a];N=Mb[B.b];O=Mb[B.c];da=Mb[B.d];va[ra]=M.x;va[ra+1]=M.y;va[ra+
-2]=M.z;va[ra+3]=N.x;va[ra+4]=N.y;va[ra+5]=N.z;va[ra+6]=O.x;va[ra+7]=O.y;va[ra+8]=O.z;va[ra+9]=da.x;va[ra+10]=da.y;va[ra+11]=da.z;ra=ra+12}f.bindBuffer(f.ARRAY_BUFFER,V.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,va,Ja)}if(dd){ua=0;for(Tc=Eb.length;ua<Tc;ua++){x=T=0;for(J=ba.length;x<J;x++){Cb=ba[x];B=qa[Cb];M=Eb[ua].vertices[B.a];N=Eb[ua].vertices[B.b];O=Eb[ua].vertices[B.c];sa=Mc[ua];sa[T]=M.x;sa[T+1]=M.y;sa[T+2]=M.z;sa[T+3]=N.x;sa[T+4]=N.y;sa[T+5]=N.z;sa[T+6]=O.x;sa[T+7]=O.y;sa[T+8]=O.z;if(Lb.morphNormals){if(vc){pb=
-zc[ua].vertexNormals[Cb];ab=pb.a;bb=pb.b;cb=pb.c}else cb=bb=ab=zc[ua].faceNormals[Cb];ta=Nc[ua];ta[T]=ab.x;ta[T+1]=ab.y;ta[T+2]=ab.z;ta[T+3]=bb.x;ta[T+4]=bb.y;ta[T+5]=bb.z;ta[T+6]=cb.x;ta[T+7]=cb.y;ta[T+8]=cb.z}T=T+9}x=0;for(J=ca.length;x<J;x++){Cb=ca[x];B=qa[Cb];M=Eb[ua].vertices[B.a];N=Eb[ua].vertices[B.b];O=Eb[ua].vertices[B.c];da=Eb[ua].vertices[B.d];sa=Mc[ua];sa[T]=M.x;sa[T+1]=M.y;sa[T+2]=M.z;sa[T+3]=N.x;sa[T+4]=N.y;sa[T+5]=N.z;sa[T+6]=O.x;sa[T+7]=O.y;sa[T+8]=O.z;sa[T+9]=da.x;sa[T+10]=da.y;sa[T+
-11]=da.z;if(Lb.morphNormals){if(vc){pb=zc[ua].vertexNormals[Cb];ab=pb.a;bb=pb.b;cb=pb.c;gc=pb.d}else gc=cb=bb=ab=zc[ua].faceNormals[Cb];ta=Nc[ua];ta[T]=ab.x;ta[T+1]=ab.y;ta[T+2]=ab.z;ta[T+3]=bb.x;ta[T+4]=bb.y;ta[T+5]=bb.z;ta[T+6]=cb.x;ta[T+7]=cb.y;ta[T+8]=cb.z;ta[T+9]=gc.x;ta[T+10]=gc.y;ta[T+11]=gc.z}T=T+12}f.bindBuffer(f.ARRAY_BUFFER,V.__webglMorphTargetsBuffers[ua]);f.bufferData(f.ARRAY_BUFFER,Mc[ua],Ja);if(Lb.morphNormals){f.bindBuffer(f.ARRAY_BUFFER,V.__webglMorphNormalsBuffers[ua]);f.bufferData(f.ARRAY_BUFFER,
-Nc[ua],Ja)}}}if(Db.length){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];gb=Db[B.a];hb=Db[B.b];ib=Db[B.c];ma[y]=gb.x;ma[y+1]=gb.y;ma[y+2]=gb.z;ma[y+3]=gb.w;ma[y+4]=hb.x;ma[y+5]=hb.y;ma[y+6]=hb.z;ma[y+7]=hb.w;ma[y+8]=ib.x;ma[y+9]=ib.y;ma[y+10]=ib.z;ma[y+11]=ib.w;jb=Pb[B.a];kb=Pb[B.b];lb=Pb[B.c];la[y]=jb.x;la[y+1]=jb.y;la[y+2]=jb.z;la[y+3]=jb.w;la[y+4]=kb.x;la[y+5]=kb.y;la[y+6]=kb.z;la[y+7]=kb.w;la[y+8]=lb.x;la[y+9]=lb.y;la[y+10]=lb.z;la[y+11]=lb.w;vb=Nb[B.a];wb=Nb[B.b];xb=Nb[B.c];ja[y]=vb.x;ja[y+1]=vb.y;
-ja[y+2]=vb.z;ja[y+3]=1;ja[y+4]=wb.x;ja[y+5]=wb.y;ja[y+6]=wb.z;ja[y+7]=1;ja[y+8]=xb.x;ja[y+9]=xb.y;ja[y+10]=xb.z;ja[y+11]=1;yb=Ob[B.a];zb=Ob[B.b];Ab=Ob[B.c];ka[y]=yb.x;ka[y+1]=yb.y;ka[y+2]=yb.z;ka[y+3]=1;ka[y+4]=zb.x;ka[y+5]=zb.y;ka[y+6]=zb.z;ka[y+7]=1;ka[y+8]=Ab.x;ka[y+9]=Ab.y;ka[y+10]=Ab.z;ka[y+11]=1;y=y+12}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];gb=Db[B.a];hb=Db[B.b];ib=Db[B.c];ic=Db[B.d];ma[y]=gb.x;ma[y+1]=gb.y;ma[y+2]=gb.z;ma[y+3]=gb.w;ma[y+4]=hb.x;ma[y+5]=hb.y;ma[y+6]=hb.z;ma[y+7]=hb.w;ma[y+
-8]=ib.x;ma[y+9]=ib.y;ma[y+10]=ib.z;ma[y+11]=ib.w;ma[y+12]=ic.x;ma[y+13]=ic.y;ma[y+14]=ic.z;ma[y+15]=ic.w;jb=Pb[B.a];kb=Pb[B.b];lb=Pb[B.c];jc=Pb[B.d];la[y]=jb.x;la[y+1]=jb.y;la[y+2]=jb.z;la[y+3]=jb.w;la[y+4]=kb.x;la[y+5]=kb.y;la[y+6]=kb.z;la[y+7]=kb.w;la[y+8]=lb.x;la[y+9]=lb.y;la[y+10]=lb.z;la[y+11]=lb.w;la[y+12]=jc.x;la[y+13]=jc.y;la[y+14]=jc.z;la[y+15]=jc.w;vb=Nb[B.a];wb=Nb[B.b];xb=Nb[B.c];xc=Nb[B.d];ja[y]=vb.x;ja[y+1]=vb.y;ja[y+2]=vb.z;ja[y+3]=1;ja[y+4]=wb.x;ja[y+5]=wb.y;ja[y+6]=wb.z;ja[y+7]=1;
-ja[y+8]=xb.x;ja[y+9]=xb.y;ja[y+10]=xb.z;ja[y+11]=1;ja[y+12]=xc.x;ja[y+13]=xc.y;ja[y+14]=xc.z;ja[y+15]=1;yb=Ob[B.a];zb=Ob[B.b];Ab=Ob[B.c];yc=Ob[B.d];ka[y]=yb.x;ka[y+1]=yb.y;ka[y+2]=yb.z;ka[y+3]=1;ka[y+4]=zb.x;ka[y+5]=zb.y;ka[y+6]=zb.z;ka[y+7]=1;ka[y+8]=Ab.x;ka[y+9]=Ab.y;ka[y+10]=Ab.z;ka[y+11]=1;ka[y+12]=yc.x;ka[y+13]=yc.y;ka[y+14]=yc.z;ka[y+15]=1;y=y+16}if(y>0){f.bindBuffer(f.ARRAY_BUFFER,V.__webglSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,ja,Ja);f.bindBuffer(f.ARRAY_BUFFER,V.__webglSkinVertexBBuffer);
-f.bufferData(f.ARRAY_BUFFER,ka,Ja);f.bindBuffer(f.ARRAY_BUFFER,V.__webglSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,la,Ja);f.bindBuffer(f.ARRAY_BUFFER,V.__webglSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,ma,Ja)}}if(cd&&Lc){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];Wa=B.vertexColors;wc=B.color;if(Wa.length===3&&Lc===THREE.VertexColors){db=Wa[0];eb=Wa[1];fb=Wa[2]}else fb=eb=db=wc;wa[pa]=db.r;wa[pa+1]=db.g;wa[pa+2]=db.b;wa[pa+3]=eb.r;wa[pa+4]=eb.g;wa[pa+5]=eb.b;wa[pa+6]=fb.r;wa[pa+7]=fb.g;wa[pa+
-8]=fb.b;pa=pa+9}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];Wa=B.vertexColors;wc=B.color;if(Wa.length===4&&Lc===THREE.VertexColors){db=Wa[0];eb=Wa[1];fb=Wa[2];hc=Wa[3]}else hc=fb=eb=db=wc;wa[pa]=db.r;wa[pa+1]=db.g;wa[pa+2]=db.b;wa[pa+3]=eb.r;wa[pa+4]=eb.g;wa[pa+5]=eb.b;wa[pa+6]=fb.r;wa[pa+7]=fb.g;wa[pa+8]=fb.b;wa[pa+9]=hc.r;wa[pa+10]=hc.g;wa[pa+11]=hc.b;pa=pa+12}if(pa>0){f.bindBuffer(f.ARRAY_BUFFER,V.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,wa,Ja)}}if(bd&&Ca.hasTangents){x=0;for(J=ba.length;x<
-J;x++){B=qa[ba[x]];ob=B.vertexTangents;Ya=ob[0];Za=ob[1];$a=ob[2];ia[ea]=Ya.x;ia[ea+1]=Ya.y;ia[ea+2]=Ya.z;ia[ea+3]=Ya.w;ia[ea+4]=Za.x;ia[ea+5]=Za.y;ia[ea+6]=Za.z;ia[ea+7]=Za.w;ia[ea+8]=$a.x;ia[ea+9]=$a.y;ia[ea+10]=$a.z;ia[ea+11]=$a.w;ea=ea+12}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];ob=B.vertexTangents;Ya=ob[0];Za=ob[1];$a=ob[2];fc=ob[3];ia[ea]=Ya.x;ia[ea+1]=Ya.y;ia[ea+2]=Ya.z;ia[ea+3]=Ya.w;ia[ea+4]=Za.x;ia[ea+5]=Za.y;ia[ea+6]=Za.z;ia[ea+7]=Za.w;ia[ea+8]=$a.x;ia[ea+9]=$a.y;ia[ea+10]=$a.z;ia[ea+11]=
-$a.w;ia[ea+12]=fc.x;ia[ea+13]=fc.y;ia[ea+14]=fc.z;ia[ea+15]=fc.w;ea=ea+16}f.bindBuffer(f.ARRAY_BUFFER,V.__webglTangentBuffer);f.bufferData(f.ARRAY_BUFFER,ia,Ja)}if(ad&&$b){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];Tb=B.vertexNormals;ub=B.normal;if(Tb.length===3&&vc)for(aa=0;aa<3;aa++){Bb=Tb[aa];Qa[ya]=Bb.x;Qa[ya+1]=Bb.y;Qa[ya+2]=Bb.z;ya=ya+3}else for(aa=0;aa<3;aa++){Qa[ya]=ub.x;Qa[ya+1]=ub.y;Qa[ya+2]=ub.z;ya=ya+3}}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];Tb=B.vertexNormals;ub=B.normal;if(Tb.length===
-4&&vc)for(aa=0;aa<4;aa++){Bb=Tb[aa];Qa[ya]=Bb.x;Qa[ya+1]=Bb.y;Qa[ya+2]=Bb.z;ya=ya+3}else for(aa=0;aa<4;aa++){Qa[ya]=ub.x;Qa[ya+1]=ub.y;Qa[ya+2]=ub.z;ya=ya+3}}f.bindBuffer(f.ARRAY_BUFFER,V.__webglNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Qa,Ja)}if(Uc&&Pc&&ac){x=0;for(J=ba.length;x<J;x++){Ta=ba[x];B=qa[Ta];Ub=Pc[Ta];if(Ub!==void 0)for(aa=0;aa<3;aa++){Wb=Ub[aa];kc[qb]=Wb.u;kc[qb+1]=Wb.v;qb=qb+2}}x=0;for(J=ca.length;x<J;x++){Ta=ca[x];B=qa[Ta];Ub=Pc[Ta];if(Ub!==void 0)for(aa=0;aa<4;aa++){Wb=Ub[aa];kc[qb]=
-Wb.u;kc[qb+1]=Wb.v;qb=qb+2}}if(qb>0){f.bindBuffer(f.ARRAY_BUFFER,V.__webglUVBuffer);f.bufferData(f.ARRAY_BUFFER,kc,Ja)}}if(Uc&&Qc&&ac){x=0;for(J=ba.length;x<J;x++){Ta=ba[x];B=qa[Ta];Vb=Qc[Ta];if(Vb!==void 0)for(aa=0;aa<3;aa++){Xb=Vb[aa];lc[rb]=Xb.u;lc[rb+1]=Xb.v;rb=rb+2}}x=0;for(J=ca.length;x<J;x++){Ta=ca[x];B=qa[Ta];Vb=Qc[Ta];if(Vb!==void 0)for(aa=0;aa<4;aa++){Xb=Vb[aa];lc[rb]=Xb.u;lc[rb+1]=Xb.v;rb=rb+2}}if(rb>0){f.bindBuffer(f.ARRAY_BUFFER,V.__webglUV2Buffer);f.bufferData(f.ARRAY_BUFFER,lc,Ja)}}if(Jc){x=
-0;for(J=ba.length;x<J;x++){B=qa[ba[x]];mb[Pa]=oa;mb[Pa+1]=oa+1;mb[Pa+2]=oa+2;Pa=Pa+3;La[Ba]=oa;La[Ba+1]=oa+1;La[Ba+2]=oa;La[Ba+3]=oa+2;La[Ba+4]=oa+1;La[Ba+5]=oa+2;Ba=Ba+6;oa=oa+3}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];mb[Pa]=oa;mb[Pa+1]=oa+1;mb[Pa+2]=oa+3;mb[Pa+3]=oa+1;mb[Pa+4]=oa+2;mb[Pa+5]=oa+3;Pa=Pa+6;La[Ba]=oa;La[Ba+1]=oa+1;La[Ba+2]=oa;La[Ba+3]=oa+3;La[Ba+4]=oa+1;La[Ba+5]=oa+2;La[Ba+6]=oa+2;La[Ba+7]=oa+3;Ba=Ba+8;oa=oa+4}f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,V.__webglFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,
-mb,Ja);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,V.__webglLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,La,Ja)}if(Oc){aa=0;for(cc=Oc.length;aa<cc;aa++){t=Oc[aa];if(t.__original.needsUpdate){u=0;if(t.size===1)if(t.boundTo===void 0||t.boundTo==="vertices"){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];t.array[u]=t.value[B.a];t.array[u+1]=t.value[B.b];t.array[u+2]=t.value[B.c];u=u+3}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];t.array[u]=t.value[B.a];t.array[u+1]=t.value[B.b];t.array[u+2]=t.value[B.c];t.array[u+
-3]=t.value[B.d];u=u+4}}else{if(t.boundTo==="faces"){x=0;for(J=ba.length;x<J;x++){Ka=t.value[ba[x]];t.array[u]=Ka;t.array[u+1]=Ka;t.array[u+2]=Ka;u=u+3}x=0;for(J=ca.length;x<J;x++){Ka=t.value[ca[x]];t.array[u]=Ka;t.array[u+1]=Ka;t.array[u+2]=Ka;t.array[u+3]=Ka;u=u+4}}}else if(t.size===2)if(t.boundTo===void 0||t.boundTo==="vertices"){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];M=t.value[B.a];N=t.value[B.b];O=t.value[B.c];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=N.x;t.array[u+3]=N.y;t.array[u+4]=O.x;
-t.array[u+5]=O.y;u=u+6}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];M=t.value[B.a];N=t.value[B.b];O=t.value[B.c];da=t.value[B.d];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=N.x;t.array[u+3]=N.y;t.array[u+4]=O.x;t.array[u+5]=O.y;t.array[u+6]=da.x;t.array[u+7]=da.y;u=u+8}}else{if(t.boundTo==="faces"){x=0;for(J=ba.length;x<J;x++){O=N=M=Ka=t.value[ba[x]];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=N.x;t.array[u+3]=N.y;t.array[u+4]=O.x;t.array[u+5]=O.y;u=u+6}x=0;for(J=ca.length;x<J;x++){da=O=N=M=Ka=t.value[ca[x]];
-t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=N.x;t.array[u+3]=N.y;t.array[u+4]=O.x;t.array[u+5]=O.y;t.array[u+6]=da.x;t.array[u+7]=da.y;u=u+8}}}else if(t.size===3){var Y;Y=t.type==="c"?["r","g","b"]:["x","y","z"];if(t.boundTo===void 0||t.boundTo==="vertices"){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];M=t.value[B.a];N=t.value[B.b];O=t.value[B.c];t.array[u]=M[Y[0]];t.array[u+1]=M[Y[1]];t.array[u+2]=M[Y[2]];t.array[u+3]=N[Y[0]];t.array[u+4]=N[Y[1]];t.array[u+5]=N[Y[2]];t.array[u+6]=O[Y[0]];t.array[u+
-7]=O[Y[1]];t.array[u+8]=O[Y[2]];u=u+9}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];M=t.value[B.a];N=t.value[B.b];O=t.value[B.c];da=t.value[B.d];t.array[u]=M[Y[0]];t.array[u+1]=M[Y[1]];t.array[u+2]=M[Y[2]];t.array[u+3]=N[Y[0]];t.array[u+4]=N[Y[1]];t.array[u+5]=N[Y[2]];t.array[u+6]=O[Y[0]];t.array[u+7]=O[Y[1]];t.array[u+8]=O[Y[2]];t.array[u+9]=da[Y[0]];t.array[u+10]=da[Y[1]];t.array[u+11]=da[Y[2]];u=u+12}}else if(t.boundTo==="faces"){x=0;for(J=ba.length;x<J;x++){O=N=M=Ka=t.value[ba[x]];t.array[u]=M[Y[0]];
-t.array[u+1]=M[Y[1]];t.array[u+2]=M[Y[2]];t.array[u+3]=N[Y[0]];t.array[u+4]=N[Y[1]];t.array[u+5]=N[Y[2]];t.array[u+6]=O[Y[0]];t.array[u+7]=O[Y[1]];t.array[u+8]=O[Y[2]];u=u+9}x=0;for(J=ca.length;x<J;x++){da=O=N=M=Ka=t.value[ca[x]];t.array[u]=M[Y[0]];t.array[u+1]=M[Y[1]];t.array[u+2]=M[Y[2]];t.array[u+3]=N[Y[0]];t.array[u+4]=N[Y[1]];t.array[u+5]=N[Y[2]];t.array[u+6]=O[Y[0]];t.array[u+7]=O[Y[1]];t.array[u+8]=O[Y[2]];t.array[u+9]=da[Y[0]];t.array[u+10]=da[Y[1]];t.array[u+11]=da[Y[2]];u=u+12}}}else if(t.size===
-4)if(t.boundTo===void 0||t.boundTo==="vertices"){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];M=t.value[B.a];N=t.value[B.b];O=t.value[B.c];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=M.z;t.array[u+3]=M.w;t.array[u+4]=N.x;t.array[u+5]=N.y;t.array[u+6]=N.z;t.array[u+7]=N.w;t.array[u+8]=O.x;t.array[u+9]=O.y;t.array[u+10]=O.z;t.array[u+11]=O.w;u=u+12}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];M=t.value[B.a];N=t.value[B.b];O=t.value[B.c];da=t.value[B.d];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=M.z;t.array[u+
-3]=M.w;t.array[u+4]=N.x;t.array[u+5]=N.y;t.array[u+6]=N.z;t.array[u+7]=N.w;t.array[u+8]=O.x;t.array[u+9]=O.y;t.array[u+10]=O.z;t.array[u+11]=O.w;t.array[u+12]=da.x;t.array[u+13]=da.y;t.array[u+14]=da.z;t.array[u+15]=da.w;u=u+16}}else if(t.boundTo==="faces"){x=0;for(J=ba.length;x<J;x++){O=N=M=Ka=t.value[ba[x]];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=M.z;t.array[u+3]=M.w;t.array[u+4]=N.x;t.array[u+5]=N.y;t.array[u+6]=N.z;t.array[u+7]=N.w;t.array[u+8]=O.x;t.array[u+9]=O.y;t.array[u+10]=O.z;t.array[u+
-11]=O.w;u=u+12}x=0;for(J=ca.length;x<J;x++){da=O=N=M=Ka=t.value[ca[x]];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=M.z;t.array[u+3]=M.w;t.array[u+4]=N.x;t.array[u+5]=N.y;t.array[u+6]=N.z;t.array[u+7]=N.w;t.array[u+8]=O.x;t.array[u+9]=O.y;t.array[u+10]=O.z;t.array[u+11]=O.w;t.array[u+12]=da.x;t.array[u+13]=da.y;t.array[u+14]=da.z;t.array[u+15]=da.w;u=u+16}}f.bindBuffer(f.ARRAY_BUFFER,t.buffer);f.bufferData(f.ARRAY_BUFFER,t.array,Ja)}}}if(tc){delete V.__inittedArrays;delete V.__colorArray;delete V.__normalArray;
-delete V.__tangentArray;delete V.__uvArray;delete V.__uv2Array;delete V.__faceArray;delete V.__vertexArray;delete V.__lineArray;delete V.__skinVertexAArray;delete V.__skinVertexBArray;delete V.__skinIndexArray;delete V.__skinWeightArray}}}}Z.verticesNeedUpdate=false;Z.morphTargetsNeedUpdate=false;Z.elementsNeedUpdate=false;Z.uvsNeedUpdate=false;Z.normalsNeedUpdate=false;Z.colorsNeedUpdate=false;Z.tangetsNeedUpdate=false;Ga.attributes&&v(Ga)}else if(Va instanceof THREE.Ribbon){if(Z.verticesNeedUpdate||
-Z.colorsNeedUpdate){var Fb=Z,Vc=f.DYNAMIC_DRAW,mc=void 0,nc=void 0,Ac=void 0,Gb=void 0,Bc=void 0,Wc=Fb.vertices,Xc=Fb.colors,ed=Wc.length,fd=Xc.length,Cc=Fb.__vertexArray,Dc=Fb.__colorArray,gd=Fb.colorsNeedUpdate;if(Fb.verticesNeedUpdate){for(mc=0;mc<ed;mc++){Ac=Wc[mc];Gb=mc*3;Cc[Gb]=Ac.x;Cc[Gb+1]=Ac.y;Cc[Gb+2]=Ac.z}f.bindBuffer(f.ARRAY_BUFFER,Fb.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,Cc,Vc)}if(gd){for(nc=0;nc<fd;nc++){Bc=Xc[nc];Gb=nc*3;Dc[Gb]=Bc.r;Dc[Gb+1]=Bc.g;Dc[Gb+2]=Bc.b}f.bindBuffer(f.ARRAY_BUFFER,
-Fb.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,Dc,Vc)}}Z.verticesNeedUpdate=false;Z.colorsNeedUpdate=false}else if(Va instanceof THREE.Line){Ga=c(Va,ec);Sb=Ga.attributes&&l(Ga);if(Z.verticesNeedUpdate||Z.colorsNeedUpdate||Sb){var sb=Z,Rc=f.DYNAMIC_DRAW,oc=void 0,pc=void 0,Ec=void 0,na=void 0,Fc=void 0,Yc=sb.vertices,Zc=sb.colors,hd=Yc.length,id=Zc.length,Gc=sb.__vertexArray,Hc=sb.__colorArray,jd=sb.colorsNeedUpdate,Sc=sb.__webglCustomAttributesList,Ic=void 0,$c=void 0,xa=void 0,Yb=void 0,Ha=void 0,
-ha=void 0;if(sb.verticesNeedUpdate){for(oc=0;oc<hd;oc++){Ec=Yc[oc];na=oc*3;Gc[na]=Ec.x;Gc[na+1]=Ec.y;Gc[na+2]=Ec.z}f.bindBuffer(f.ARRAY_BUFFER,sb.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,Gc,Rc)}if(jd){for(pc=0;pc<id;pc++){Fc=Zc[pc];na=pc*3;Hc[na]=Fc.r;Hc[na+1]=Fc.g;Hc[na+2]=Fc.b}f.bindBuffer(f.ARRAY_BUFFER,sb.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,Hc,Rc)}if(Sc){Ic=0;for($c=Sc.length;Ic<$c;Ic++){ha=Sc[Ic];if(ha.needsUpdate&&(ha.boundTo===void 0||ha.boundTo==="vertices")){na=0;Yb=ha.value.length;
-if(ha.size===1)for(xa=0;xa<Yb;xa++)ha.array[xa]=ha.value[xa];else if(ha.size===2)for(xa=0;xa<Yb;xa++){Ha=ha.value[xa];ha.array[na]=Ha.x;ha.array[na+1]=Ha.y;na=na+2}else if(ha.size===3)if(ha.type==="c")for(xa=0;xa<Yb;xa++){Ha=ha.value[xa];ha.array[na]=Ha.r;ha.array[na+1]=Ha.g;ha.array[na+2]=Ha.b;na=na+3}else for(xa=0;xa<Yb;xa++){Ha=ha.value[xa];ha.array[na]=Ha.x;ha.array[na+1]=Ha.y;ha.array[na+2]=Ha.z;na=na+3}else if(ha.size===4)for(xa=0;xa<Yb;xa++){Ha=ha.value[xa];ha.array[na]=Ha.x;ha.array[na+1]=
-Ha.y;ha.array[na+2]=Ha.z;ha.array[na+3]=Ha.w;na=na+4}f.bindBuffer(f.ARRAY_BUFFER,ha.buffer);f.bufferData(f.ARRAY_BUFFER,ha.array,Rc)}}}}Z.verticesNeedUpdate=false;Z.colorsNeedUpdate=false;Ga.attributes&&v(Ga)}else if(Va instanceof THREE.ParticleSystem){Ga=c(Va,ec);Sb=Ga.attributes&&l(Ga);(Z.verticesNeedUpdate||Z.colorsNeedUpdate||Va.sortParticles||Sb)&&g(Z,f.DYNAMIC_DRAW,Va);Z.verticesNeedUpdate=false;Z.colorsNeedUpdate=false;Ga.attributes&&v(Ga)}}};this.initMaterial=function(a,b,c,d){var e,g,h;a instanceof
-THREE.MeshDepthMaterial?h="depth":a instanceof THREE.MeshNormalMaterial?h="normal":a instanceof THREE.MeshBasicMaterial?h="basic":a instanceof THREE.MeshLambertMaterial?h="lambert":a instanceof THREE.MeshPhongMaterial?h="phong":a instanceof THREE.LineBasicMaterial?h="basic":a instanceof THREE.ParticleBasicMaterial&&(h="particle_basic");if(h){var i=THREE.ShaderLib[h];a.uniforms=THREE.UniformsUtils.clone(i.uniforms);a.vertexShader=i.vertexShader;a.fragmentShader=i.fragmentShader}var j,k,l,m,n;j=m=n=
-i=0;for(k=b.length;j<k;j++){l=b[j];if(!l.onlyShadow){l instanceof THREE.DirectionalLight&&m++;l instanceof THREE.PointLight&&n++;l instanceof THREE.SpotLight&&i++}}if(n+i+m<=X){k=m;l=n;m=i}else{k=Math.ceil(X*m/(n+m));m=l=X-k}var p=0,i=0;for(n=b.length;i<n;i++){j=b[i];if(j.castShadow){j instanceof THREE.SpotLight&&p++;j instanceof THREE.DirectionalLight&&!j.shadowCascade&&p++}}var r=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)r=d.bones.length;var o;a:{n=a.fragmentShader;j=a.vertexShader;var i=
-a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,maxBones:r,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:k,maxPointLights:l,maxSpotLights:m,maxShadows:p,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,
-shadowMapCascade:this.shadowMapCascade,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:d&&d.doubleSided},q,d=[];if(h)d.push(h);else{d.push(n);d.push(j)}for(q in c){d.push(q);d.push(c[q])}h=d.join();q=0;for(d=fa.length;q<d;q++)if(fa[q].code===h){o=fa[q].program;break a}q=f.createProgram();d=["precision "+I+" float;",cc>0?"#define VERTEX_TEXTURES":"",E.gammaInput?"#define GAMMA_INPUT":"",E.gammaOutput?"#define GAMMA_OUTPUT":"",E.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":
-"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",
-c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+var l,m=h.length;for(l=0;l<m;l++){j=h[l];j>0&&i.push([l,j])}if(i.length>d.numSupportedMorphTargets){i.sort(k);i.length=d.numSupportedMorphTargets}else i.length>d.numSupportedMorphNormals?i.sort(k):i.length===0&&i.push([0,0]);for(j=0;j<d.numSupportedMorphTargets;){l=j<i.length?i[j][0]:void 0;if(l!==void 0||j===0){f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l]);f.vertexAttribPointer(c["morphTarget"+j],3,f.FLOAT,false,0,0);if(d.morphNormals){f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[l]);
+f.vertexAttribPointer(c["morphNormal"+j],3,f.FLOAT,false,0,0)}g.__webglMorphTargetInfluences[j]=h[l]}else{f.vertexAttribPointer(c["morphTarget"+j],3,f.FLOAT,false,0,0);d.morphNormals&&f.vertexAttribPointer(c["morphNormal"+j],3,f.FLOAT,false,0,0);g.__webglMorphTargetInfluences[j]=0}j++}}d.program.uniforms.morphTargetInfluences!==null&&f.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){h=0;for(i=e.__webglCustomAttributesList.length;h<
+i;h++){c=e.__webglCustomAttributesList[h];if(b[c.buffer.belongsToAttribute]>=0){f.bindBuffer(f.ARRAY_BUFFER,c.buffer);f.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,f.FLOAT,false,0,0)}}}if(b.color>=0){f.bindBuffer(f.ARRAY_BUFFER,e.__webglColorBuffer);f.vertexAttribPointer(b.color,3,f.FLOAT,false,0,0)}if(b.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,e.__webglNormalBuffer);f.vertexAttribPointer(b.normal,3,f.FLOAT,false,0,0)}if(b.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,e.__webglTangentBuffer);
+f.vertexAttribPointer(b.tangent,4,f.FLOAT,false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,e.__webglUVBuffer);f.vertexAttribPointer(b.uv,2,f.FLOAT,false,0,0);f.enableVertexAttribArray(b.uv)}else f.disableVertexAttribArray(b.uv);if(b.uv2>=0)if(e.__webglUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,e.__webglUV2Buffer);f.vertexAttribPointer(b.uv2,2,f.FLOAT,false,0,0);f.enableVertexAttribArray(b.uv2)}else f.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=
+0&&b.skinIndex>=0&&b.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinVertexABuffer);f.vertexAttribPointer(b.skinVertexA,4,f.FLOAT,false,0,0);f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinVertexBBuffer);f.vertexAttribPointer(b.skinVertexB,4,f.FLOAT,false,0,0);f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);f.vertexAttribPointer(b.skinIndex,4,f.FLOAT,false,0,0);f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);f.vertexAttribPointer(b.skinWeight,4,f.FLOAT,false,0,0)}}if(g instanceof
+THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==tb){f.lineWidth(d);tb=d}a&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);f.drawElements(f.LINES,e.__webglLineCount,f.UNSIGNED_SHORT,0)}else{a&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer);f.drawElements(f.TRIANGLES,e.__webglFaceCount,f.UNSIGNED_SHORT,0)}E.info.render.calls++;E.info.render.vertices=E.info.render.vertices+e.__webglFaceCount;E.info.render.faces=E.info.render.faces+e.__webglFaceCount/3}else if(g instanceof
+THREE.Line){g=g.type===THREE.LineStrip?f.LINE_STRIP:f.LINES;d=d.linewidth;if(d!==tb){f.lineWidth(d);tb=d}f.drawArrays(g,0,e.__webglLineCount);E.info.render.calls++}else if(g instanceof THREE.ParticleSystem){f.drawArrays(f.POINTS,0,e.__webglParticleCount);E.info.render.calls++;E.info.render.points=E.info.render.points+e.__webglParticleCount}else if(g instanceof THREE.Ribbon){f.drawArrays(f.TRIANGLE_STRIP,0,e.__webglVertexCount);E.info.render.calls++}}};this.render=function(a,b,c,d){var e,g,l,k,n=a.__lights,
+p=a.fog;R=-1;nb=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Ib.multiply(b.projectionMatrix,
+b.matrixWorldInverse);Kb.setFromMatrix(Ib);this.autoUpdateObjects&&this.initWebGLObjects(a);m(this.renderPluginsPre,a,b);E.info.render.calls=0;E.info.render.vertices=0;E.info.render.faces=0;E.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);k=a.__webglObjects;d=0;for(e=k.length;d<e;d++){g=k[d];l=g.object;g.render=false;if(l.visible&&(!(l instanceof THREE.Mesh||l instanceof THREE.ParticleSystem)||!l.frustumCulled||
+Kb.contains(l))){w(l,b);var o=g,q=o.object,v=o.buffer,s=void 0,s=s=void 0,s=q.material;if(s instanceof THREE.MeshFaceMaterial){s=v.materialIndex;if(s>=0){s=q.geometry.materials[s];if(s.transparent){o.transparent=s;o.opaque=null}else{o.opaque=s;o.transparent=null}}}else if(s)if(s.transparent){o.transparent=s;o.opaque=null}else{o.opaque=s;o.transparent=null}g.render=true;if(this.sortObjects)if(l.renderDepth)g.z=l.renderDepth;else{Na.copy(l.matrixWorld.getPosition());Ib.multiplyVector3(Na);g.z=Na.z}}}this.sortObjects&&
+k.sort(h);k=a.__webglObjectsImmediate;d=0;for(e=k.length;d<e;d++){g=k[d];l=g.object;if(l.visible){w(l,b);l=g.object.material;if(l.transparent){g.transparent=l;g.opaque=null}else{g.opaque=l;g.transparent=null}}}if(a.overrideMaterial){d=a.overrideMaterial;this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst);this.setDepthTest(d.depthTest);this.setDepthWrite(d.depthWrite);r(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits);j(a.__webglObjects,false,"",b,n,p,true,d);i(a.__webglObjectsImmediate,
+"",b,n,p,false,d)}else{this.setBlending(THREE.NormalBlending);j(a.__webglObjects,true,"opaque",b,n,p,false);i(a.__webglObjectsImmediate,"opaque",b,n,p,false);j(a.__webglObjects,false,"transparent",b,n,p,true);i(a.__webglObjectsImmediate,"transparent",b,n,p,true)}m(this.renderPluginsPost,a,b);if(c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter)if(c instanceof THREE.WebGLRenderTargetCube){f.bindTexture(f.TEXTURE_CUBE_MAP,c.__webglTexture);f.generateMipmap(f.TEXTURE_CUBE_MAP);
+f.bindTexture(f.TEXTURE_CUBE_MAP,null)}else{f.bindTexture(f.TEXTURE_2D,c.__webglTexture);f.generateMipmap(f.TEXTURE_2D);f.bindTexture(f.TEXTURE_2D,null)}this.setDepthTest(true);this.setDepthWrite(true)};this.renderImmediateObject=function(a,b,c,d,e){var g=q(a,b,c,d,e);ga=-1;E.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(g,f,Kb):e.render(function(a){E.renderBufferImmediate(a,g,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects){a.__webglObjects=[];a.__webglObjectsImmediate=
+[];a.__webglSprites=[];a.__webglFlares=[]}for(;a.__objectsAdded.length;){var h=a.__objectsAdded[0],i=a,j=void 0,k=void 0,m=void 0;if(!h.__webglInit){h.__webglInit=true;h._modelViewMatrix=new THREE.Matrix4;h._normalMatrix=new THREE.Matrix3;if(h instanceof THREE.Mesh){k=h.geometry;if(k instanceof THREE.Geometry){if(k.geometryGroups===void 0){var r=k,q=void 0,s=void 0,w=void 0,z=void 0,C=void 0,A=void 0,D=void 0,F={},I=r.morphTargets.length,K=r.morphNormals.length;r.geometryGroups={};q=0;for(s=r.faces.length;q<
+s;q++){w=r.faces[q];z=w.materialIndex;A=z!==void 0?z:-1;F[A]===void 0&&(F[A]={hash:A,counter:0});D=F[A].hash+"_"+F[A].counter;r.geometryGroups[D]===void 0&&(r.geometryGroups[D]={faces3:[],faces4:[],materialIndex:z,vertices:0,numMorphTargets:I,numMorphNormals:K});C=w instanceof THREE.Face3?3:4;if(r.geometryGroups[D].vertices+C>65535){F[A].counter=F[A].counter+1;D=F[A].hash+"_"+F[A].counter;r.geometryGroups[D]===void 0&&(r.geometryGroups[D]={faces3:[],faces4:[],materialIndex:z,vertices:0,numMorphTargets:I,
+numMorphNormals:K})}w instanceof THREE.Face3?r.geometryGroups[D].faces3.push(q):r.geometryGroups[D].faces4.push(q);r.geometryGroups[D].vertices=r.geometryGroups[D].vertices+C}r.geometryGroupsList=[];var L=void 0;for(L in r.geometryGroups){r.geometryGroups[L].id=Ea++;r.geometryGroupsList.push(r.geometryGroups[L])}}for(j in k.geometryGroups){m=k.geometryGroups[j];if(!m.__webglVertexBuffer){var H=m;H.__webglVertexBuffer=f.createBuffer();H.__webglNormalBuffer=f.createBuffer();H.__webglTangentBuffer=f.createBuffer();
+H.__webglColorBuffer=f.createBuffer();H.__webglUVBuffer=f.createBuffer();H.__webglUV2Buffer=f.createBuffer();H.__webglSkinVertexABuffer=f.createBuffer();H.__webglSkinVertexBBuffer=f.createBuffer();H.__webglSkinIndicesBuffer=f.createBuffer();H.__webglSkinWeightsBuffer=f.createBuffer();H.__webglFaceBuffer=f.createBuffer();H.__webglLineBuffer=f.createBuffer();var P=void 0,Q=void 0;if(H.numMorphTargets){H.__webglMorphTargetsBuffers=[];P=0;for(Q=H.numMorphTargets;P<Q;P++)H.__webglMorphTargetsBuffers.push(f.createBuffer())}if(H.numMorphNormals){H.__webglMorphNormalsBuffers=
+[];P=0;for(Q=H.numMorphNormals;P<Q;P++)H.__webglMorphNormalsBuffers.push(f.createBuffer())}E.info.memory.geometries++;var G=m,U=h,S=U.geometry,W=G.faces3,X=G.faces4,R=W.length*3+X.length*4,fa=W.length*1+X.length*2,ga=W.length*3+X.length*4,$=c(U,G),za=e($),Da=d($),Ia=$.vertexColors?$.vertexColors:false;G.__vertexArray=new Float32Array(R*3);if(Da)G.__normalArray=new Float32Array(R*3);if(S.hasTangents)G.__tangentArray=new Float32Array(R*4);if(Ia)G.__colorArray=new Float32Array(R*3);if(za){if(S.faceUvs.length>
+0||S.faceVertexUvs.length>0)G.__uvArray=new Float32Array(R*2);if(S.faceUvs.length>1||S.faceVertexUvs.length>1)G.__uv2Array=new Float32Array(R*2)}if(U.geometry.skinWeights.length&&U.geometry.skinIndices.length){G.__skinVertexAArray=new Float32Array(R*4);G.__skinVertexBArray=new Float32Array(R*4);G.__skinIndexArray=new Float32Array(R*4);G.__skinWeightArray=new Float32Array(R*4)}G.__faceArray=new Uint16Array(fa*3);G.__lineArray=new Uint16Array(ga*2);var Aa=void 0,Fa=void 0;if(G.numMorphTargets){G.__morphTargetsArrays=
+[];Aa=0;for(Fa=G.numMorphTargets;Aa<Fa;Aa++)G.__morphTargetsArrays.push(new Float32Array(R*3))}if(G.numMorphNormals){G.__morphNormalsArrays=[];Aa=0;for(Fa=G.numMorphNormals;Aa<Fa;Aa++)G.__morphNormalsArrays.push(new Float32Array(R*3))}G.__webglFaceCount=fa*3;G.__webglLineCount=ga*2;if($.attributes){if(G.__webglCustomAttributesList===void 0)G.__webglCustomAttributesList=[];var Ra=void 0;for(Ra in $.attributes){var Sa=$.attributes[Ra],Ma={},Ua;for(Ua in Sa)Ma[Ua]=Sa[Ua];if(!Ma.__webglInitialized||Ma.createUniqueBuffers){Ma.__webglInitialized=
+true;var Na=1;Ma.type==="v2"?Na=2:Ma.type==="v3"?Na=3:Ma.type==="v4"?Na=4:Ma.type==="c"&&(Na=3);Ma.size=Na;Ma.array=new Float32Array(R*Na);Ma.buffer=f.createBuffer();Ma.buffer.belongsToAttribute=Ra;Sa.needsUpdate=true;Ma.__original=Sa}G.__webglCustomAttributesList.push(Ma)}}G.__inittedArrays=true;k.verticesNeedUpdate=true;k.morphTargetsNeedUpdate=true;k.elementsNeedUpdate=true;k.uvsNeedUpdate=true;k.normalsNeedUpdate=true;k.tangetsNeedUpdate=true;k.colorsNeedUpdate=true}}}}else if(h instanceof THREE.Ribbon){k=
+h.geometry;if(!k.__webglVertexBuffer){var nb=k;nb.__webglVertexBuffer=f.createBuffer();nb.__webglColorBuffer=f.createBuffer();E.info.memory.geometries++;var Xa=k,tb=Xa.vertices.length;Xa.__vertexArray=new Float32Array(tb*3);Xa.__colorArray=new Float32Array(tb*3);Xa.__webglVertexCount=tb;k.verticesNeedUpdate=true;k.colorsNeedUpdate=true}}else if(h instanceof THREE.Line){k=h.geometry;if(!k.__webglVertexBuffer){var Ib=k;Ib.__webglVertexBuffer=f.createBuffer();Ib.__webglColorBuffer=f.createBuffer();E.info.memory.geometries++;
+var dc=k,Zb=h,Hb=dc.vertices.length;dc.__vertexArray=new Float32Array(Hb*3);dc.__colorArray=new Float32Array(Hb*3);dc.__webglLineCount=Hb;b(dc,Zb);k.verticesNeedUpdate=true;k.colorsNeedUpdate=true}}else if(h instanceof THREE.ParticleSystem){k=h.geometry;if(!k.__webglVertexBuffer){var Qb=k;Qb.__webglVertexBuffer=f.createBuffer();Qb.__webglColorBuffer=f.createBuffer();E.info.geometries++;var Rb=k,bc=h,Jb=Rb.vertices.length;Rb.__vertexArray=new Float32Array(Jb*3);Rb.__colorArray=new Float32Array(Jb*
+3);Rb.__sortArray=[];Rb.__webglParticleCount=Jb;b(Rb,bc);k.verticesNeedUpdate=true;k.colorsNeedUpdate=true}}}if(!h.__webglActive){if(h instanceof THREE.Mesh){k=h.geometry;if(k instanceof THREE.BufferGeometry)p(i.__webglObjects,k,h);else for(j in k.geometryGroups){m=k.geometryGroups[j];p(i.__webglObjects,m,h)}}else if(h instanceof THREE.Ribbon||h instanceof THREE.Line||h instanceof THREE.ParticleSystem){k=h.geometry;p(i.__webglObjects,k,h)}else h instanceof THREE.ImmediateRenderObject||h.immediateRenderCallback?
+i.__webglObjectsImmediate.push({object:h,opaque:null,transparent:null}):h instanceof THREE.Sprite?i.__webglSprites.push(h):h instanceof THREE.LensFlare&&i.__webglFlares.push(h);h.__webglActive=true}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var Oa=a.__objectsRemoved[0],uc=a;Oa instanceof THREE.Mesh||Oa instanceof THREE.ParticleSystem||Oa instanceof THREE.Ribbon||Oa instanceof THREE.Line?o(uc.__webglObjects,Oa):Oa instanceof THREE.Sprite?n(uc.__webglSprites,Oa):Oa instanceof THREE.LensFlare?
+n(uc.__webglFlares,Oa):(Oa instanceof THREE.ImmediateRenderObject||Oa.immediateRenderCallback)&&o(uc.__webglObjectsImmediate,Oa);Oa.__webglActive=false;a.__objectsRemoved.splice(0,1)}for(var Kb=0,qc=a.__webglObjects.length;Kb<qc;Kb++){var Va=a.__webglObjects[Kb].object,Z=Va.geometry,ec=void 0,Sb=void 0,Ga=void 0;if(Va instanceof THREE.Mesh)if(Z instanceof THREE.BufferGeometry){Z.verticesNeedUpdate=false;Z.elementsNeedUpdate=false;Z.uvsNeedUpdate=false;Z.normalsNeedUpdate=false;Z.colorsNeedUpdate=
+false}else{for(var Kc=0,rc=Z.geometryGroupsList.length;Kc<rc;Kc++){ec=Z.geometryGroupsList[Kc];Ga=c(Va,ec);Sb=Ga.attributes&&l(Ga);if(Z.verticesNeedUpdate||Z.morphTargetsNeedUpdate||Z.elementsNeedUpdate||Z.uvsNeedUpdate||Z.normalsNeedUpdate||Z.colorsNeedUpdate||Z.tangetsNeedUpdate||Sb){var V=ec,sc=Va,Ja=f.DYNAMIC_DRAW,tc=!Z.dynamic,Lb=Ga;if(V.__inittedArrays){var $b=d(Lb),Lc=Lb.vertexColors?Lb.vertexColors:false,ac=e(Lb),vc=$b===THREE.SmoothShading,x=void 0,J=void 0,Ta=void 0,B=void 0,Tb=void 0,ub=
+void 0,Wa=void 0,wc=void 0,ob=void 0,Ub=void 0,Vb=void 0,M=void 0,N=void 0,O=void 0,da=void 0,Ya=void 0,Za=void 0,$a=void 0,fc=void 0,ab=void 0,bb=void 0,cb=void 0,gc=void 0,db=void 0,eb=void 0,fb=void 0,hc=void 0,gb=void 0,hb=void 0,ib=void 0,ic=void 0,jb=void 0,kb=void 0,lb=void 0,jc=void 0,vb=void 0,wb=void 0,xb=void 0,xc=void 0,yb=void 0,zb=void 0,Ab=void 0,yc=void 0,aa=void 0,cc=void 0,Bb=void 0,Wb=void 0,Xb=void 0,ua=void 0,Tc=void 0,sa=void 0,ta=void 0,Cb=void 0,pb=void 0,oa=0,ra=0,qb=0,rb=
+0,Pa=0,ya=0,ea=0,Ba=0,pa=0,y=0,T=0,u=0,Ka=void 0,va=V.__vertexArray,kc=V.__uvArray,lc=V.__uv2Array,Qa=V.__normalArray,ia=V.__tangentArray,wa=V.__colorArray,ja=V.__skinVertexAArray,ka=V.__skinVertexBArray,la=V.__skinIndexArray,ma=V.__skinWeightArray,Mc=V.__morphTargetsArrays,Nc=V.__morphNormalsArrays,Oc=V.__webglCustomAttributesList,t=void 0,mb=V.__faceArray,La=V.__lineArray,Ca=sc.geometry,Jc=Ca.elementsNeedUpdate,Uc=Ca.uvsNeedUpdate,ad=Ca.normalsNeedUpdate,bd=Ca.tangetsNeedUpdate,cd=Ca.colorsNeedUpdate,
+dd=Ca.morphTargetsNeedUpdate,Mb=Ca.vertices,ba=V.faces3,ca=V.faces4,qa=Ca.faces,Pc=Ca.faceVertexUvs[0],Qc=Ca.faceVertexUvs[1],Nb=Ca.skinVerticesA,Ob=Ca.skinVerticesB,Pb=Ca.skinIndices,Db=Ca.skinWeights,Eb=Ca.morphTargets,zc=Ca.morphNormals;if(Ca.verticesNeedUpdate){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];M=Mb[B.a];N=Mb[B.b];O=Mb[B.c];va[ra]=M.x;va[ra+1]=M.y;va[ra+2]=M.z;va[ra+3]=N.x;va[ra+4]=N.y;va[ra+5]=N.z;va[ra+6]=O.x;va[ra+7]=O.y;va[ra+8]=O.z;ra=ra+9}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];
+M=Mb[B.a];N=Mb[B.b];O=Mb[B.c];da=Mb[B.d];va[ra]=M.x;va[ra+1]=M.y;va[ra+2]=M.z;va[ra+3]=N.x;va[ra+4]=N.y;va[ra+5]=N.z;va[ra+6]=O.x;va[ra+7]=O.y;va[ra+8]=O.z;va[ra+9]=da.x;va[ra+10]=da.y;va[ra+11]=da.z;ra=ra+12}f.bindBuffer(f.ARRAY_BUFFER,V.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,va,Ja)}if(dd){ua=0;for(Tc=Eb.length;ua<Tc;ua++){x=T=0;for(J=ba.length;x<J;x++){Cb=ba[x];B=qa[Cb];M=Eb[ua].vertices[B.a];N=Eb[ua].vertices[B.b];O=Eb[ua].vertices[B.c];sa=Mc[ua];sa[T]=M.x;sa[T+1]=M.y;sa[T+2]=M.z;sa[T+
+3]=N.x;sa[T+4]=N.y;sa[T+5]=N.z;sa[T+6]=O.x;sa[T+7]=O.y;sa[T+8]=O.z;if(Lb.morphNormals){if(vc){pb=zc[ua].vertexNormals[Cb];ab=pb.a;bb=pb.b;cb=pb.c}else cb=bb=ab=zc[ua].faceNormals[Cb];ta=Nc[ua];ta[T]=ab.x;ta[T+1]=ab.y;ta[T+2]=ab.z;ta[T+3]=bb.x;ta[T+4]=bb.y;ta[T+5]=bb.z;ta[T+6]=cb.x;ta[T+7]=cb.y;ta[T+8]=cb.z}T=T+9}x=0;for(J=ca.length;x<J;x++){Cb=ca[x];B=qa[Cb];M=Eb[ua].vertices[B.a];N=Eb[ua].vertices[B.b];O=Eb[ua].vertices[B.c];da=Eb[ua].vertices[B.d];sa=Mc[ua];sa[T]=M.x;sa[T+1]=M.y;sa[T+2]=M.z;sa[T+
+3]=N.x;sa[T+4]=N.y;sa[T+5]=N.z;sa[T+6]=O.x;sa[T+7]=O.y;sa[T+8]=O.z;sa[T+9]=da.x;sa[T+10]=da.y;sa[T+11]=da.z;if(Lb.morphNormals){if(vc){pb=zc[ua].vertexNormals[Cb];ab=pb.a;bb=pb.b;cb=pb.c;gc=pb.d}else gc=cb=bb=ab=zc[ua].faceNormals[Cb];ta=Nc[ua];ta[T]=ab.x;ta[T+1]=ab.y;ta[T+2]=ab.z;ta[T+3]=bb.x;ta[T+4]=bb.y;ta[T+5]=bb.z;ta[T+6]=cb.x;ta[T+7]=cb.y;ta[T+8]=cb.z;ta[T+9]=gc.x;ta[T+10]=gc.y;ta[T+11]=gc.z}T=T+12}f.bindBuffer(f.ARRAY_BUFFER,V.__webglMorphTargetsBuffers[ua]);f.bufferData(f.ARRAY_BUFFER,Mc[ua],
+Ja);if(Lb.morphNormals){f.bindBuffer(f.ARRAY_BUFFER,V.__webglMorphNormalsBuffers[ua]);f.bufferData(f.ARRAY_BUFFER,Nc[ua],Ja)}}}if(Db.length){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];gb=Db[B.a];hb=Db[B.b];ib=Db[B.c];ma[y]=gb.x;ma[y+1]=gb.y;ma[y+2]=gb.z;ma[y+3]=gb.w;ma[y+4]=hb.x;ma[y+5]=hb.y;ma[y+6]=hb.z;ma[y+7]=hb.w;ma[y+8]=ib.x;ma[y+9]=ib.y;ma[y+10]=ib.z;ma[y+11]=ib.w;jb=Pb[B.a];kb=Pb[B.b];lb=Pb[B.c];la[y]=jb.x;la[y+1]=jb.y;la[y+2]=jb.z;la[y+3]=jb.w;la[y+4]=kb.x;la[y+5]=kb.y;la[y+6]=kb.z;la[y+7]=
+kb.w;la[y+8]=lb.x;la[y+9]=lb.y;la[y+10]=lb.z;la[y+11]=lb.w;vb=Nb[B.a];wb=Nb[B.b];xb=Nb[B.c];ja[y]=vb.x;ja[y+1]=vb.y;ja[y+2]=vb.z;ja[y+3]=1;ja[y+4]=wb.x;ja[y+5]=wb.y;ja[y+6]=wb.z;ja[y+7]=1;ja[y+8]=xb.x;ja[y+9]=xb.y;ja[y+10]=xb.z;ja[y+11]=1;yb=Ob[B.a];zb=Ob[B.b];Ab=Ob[B.c];ka[y]=yb.x;ka[y+1]=yb.y;ka[y+2]=yb.z;ka[y+3]=1;ka[y+4]=zb.x;ka[y+5]=zb.y;ka[y+6]=zb.z;ka[y+7]=1;ka[y+8]=Ab.x;ka[y+9]=Ab.y;ka[y+10]=Ab.z;ka[y+11]=1;y=y+12}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];gb=Db[B.a];hb=Db[B.b];ib=Db[B.c];ic=
+Db[B.d];ma[y]=gb.x;ma[y+1]=gb.y;ma[y+2]=gb.z;ma[y+3]=gb.w;ma[y+4]=hb.x;ma[y+5]=hb.y;ma[y+6]=hb.z;ma[y+7]=hb.w;ma[y+8]=ib.x;ma[y+9]=ib.y;ma[y+10]=ib.z;ma[y+11]=ib.w;ma[y+12]=ic.x;ma[y+13]=ic.y;ma[y+14]=ic.z;ma[y+15]=ic.w;jb=Pb[B.a];kb=Pb[B.b];lb=Pb[B.c];jc=Pb[B.d];la[y]=jb.x;la[y+1]=jb.y;la[y+2]=jb.z;la[y+3]=jb.w;la[y+4]=kb.x;la[y+5]=kb.y;la[y+6]=kb.z;la[y+7]=kb.w;la[y+8]=lb.x;la[y+9]=lb.y;la[y+10]=lb.z;la[y+11]=lb.w;la[y+12]=jc.x;la[y+13]=jc.y;la[y+14]=jc.z;la[y+15]=jc.w;vb=Nb[B.a];wb=Nb[B.b];xb=
+Nb[B.c];xc=Nb[B.d];ja[y]=vb.x;ja[y+1]=vb.y;ja[y+2]=vb.z;ja[y+3]=1;ja[y+4]=wb.x;ja[y+5]=wb.y;ja[y+6]=wb.z;ja[y+7]=1;ja[y+8]=xb.x;ja[y+9]=xb.y;ja[y+10]=xb.z;ja[y+11]=1;ja[y+12]=xc.x;ja[y+13]=xc.y;ja[y+14]=xc.z;ja[y+15]=1;yb=Ob[B.a];zb=Ob[B.b];Ab=Ob[B.c];yc=Ob[B.d];ka[y]=yb.x;ka[y+1]=yb.y;ka[y+2]=yb.z;ka[y+3]=1;ka[y+4]=zb.x;ka[y+5]=zb.y;ka[y+6]=zb.z;ka[y+7]=1;ka[y+8]=Ab.x;ka[y+9]=Ab.y;ka[y+10]=Ab.z;ka[y+11]=1;ka[y+12]=yc.x;ka[y+13]=yc.y;ka[y+14]=yc.z;ka[y+15]=1;y=y+16}if(y>0){f.bindBuffer(f.ARRAY_BUFFER,
+V.__webglSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,ja,Ja);f.bindBuffer(f.ARRAY_BUFFER,V.__webglSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,ka,Ja);f.bindBuffer(f.ARRAY_BUFFER,V.__webglSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,la,Ja);f.bindBuffer(f.ARRAY_BUFFER,V.__webglSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,ma,Ja)}}if(cd&&Lc){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];Wa=B.vertexColors;wc=B.color;if(Wa.length===3&&Lc===THREE.VertexColors){db=Wa[0];eb=Wa[1];fb=Wa[2]}else fb=eb=db=
+wc;wa[pa]=db.r;wa[pa+1]=db.g;wa[pa+2]=db.b;wa[pa+3]=eb.r;wa[pa+4]=eb.g;wa[pa+5]=eb.b;wa[pa+6]=fb.r;wa[pa+7]=fb.g;wa[pa+8]=fb.b;pa=pa+9}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];Wa=B.vertexColors;wc=B.color;if(Wa.length===4&&Lc===THREE.VertexColors){db=Wa[0];eb=Wa[1];fb=Wa[2];hc=Wa[3]}else hc=fb=eb=db=wc;wa[pa]=db.r;wa[pa+1]=db.g;wa[pa+2]=db.b;wa[pa+3]=eb.r;wa[pa+4]=eb.g;wa[pa+5]=eb.b;wa[pa+6]=fb.r;wa[pa+7]=fb.g;wa[pa+8]=fb.b;wa[pa+9]=hc.r;wa[pa+10]=hc.g;wa[pa+11]=hc.b;pa=pa+12}if(pa>0){f.bindBuffer(f.ARRAY_BUFFER,
+V.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,wa,Ja)}}if(bd&&Ca.hasTangents){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];ob=B.vertexTangents;Ya=ob[0];Za=ob[1];$a=ob[2];ia[ea]=Ya.x;ia[ea+1]=Ya.y;ia[ea+2]=Ya.z;ia[ea+3]=Ya.w;ia[ea+4]=Za.x;ia[ea+5]=Za.y;ia[ea+6]=Za.z;ia[ea+7]=Za.w;ia[ea+8]=$a.x;ia[ea+9]=$a.y;ia[ea+10]=$a.z;ia[ea+11]=$a.w;ea=ea+12}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];ob=B.vertexTangents;Ya=ob[0];Za=ob[1];$a=ob[2];fc=ob[3];ia[ea]=Ya.x;ia[ea+1]=Ya.y;ia[ea+2]=Ya.z;ia[ea+3]=Ya.w;ia[ea+
+4]=Za.x;ia[ea+5]=Za.y;ia[ea+6]=Za.z;ia[ea+7]=Za.w;ia[ea+8]=$a.x;ia[ea+9]=$a.y;ia[ea+10]=$a.z;ia[ea+11]=$a.w;ia[ea+12]=fc.x;ia[ea+13]=fc.y;ia[ea+14]=fc.z;ia[ea+15]=fc.w;ea=ea+16}f.bindBuffer(f.ARRAY_BUFFER,V.__webglTangentBuffer);f.bufferData(f.ARRAY_BUFFER,ia,Ja)}if(ad&&$b){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];Tb=B.vertexNormals;ub=B.normal;if(Tb.length===3&&vc)for(aa=0;aa<3;aa++){Bb=Tb[aa];Qa[ya]=Bb.x;Qa[ya+1]=Bb.y;Qa[ya+2]=Bb.z;ya=ya+3}else for(aa=0;aa<3;aa++){Qa[ya]=ub.x;Qa[ya+1]=ub.y;Qa[ya+
+2]=ub.z;ya=ya+3}}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];Tb=B.vertexNormals;ub=B.normal;if(Tb.length===4&&vc)for(aa=0;aa<4;aa++){Bb=Tb[aa];Qa[ya]=Bb.x;Qa[ya+1]=Bb.y;Qa[ya+2]=Bb.z;ya=ya+3}else for(aa=0;aa<4;aa++){Qa[ya]=ub.x;Qa[ya+1]=ub.y;Qa[ya+2]=ub.z;ya=ya+3}}f.bindBuffer(f.ARRAY_BUFFER,V.__webglNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Qa,Ja)}if(Uc&&Pc&&ac){x=0;for(J=ba.length;x<J;x++){Ta=ba[x];B=qa[Ta];Ub=Pc[Ta];if(Ub!==void 0)for(aa=0;aa<3;aa++){Wb=Ub[aa];kc[qb]=Wb.u;kc[qb+1]=Wb.v;qb=qb+2}}x=
+0;for(J=ca.length;x<J;x++){Ta=ca[x];B=qa[Ta];Ub=Pc[Ta];if(Ub!==void 0)for(aa=0;aa<4;aa++){Wb=Ub[aa];kc[qb]=Wb.u;kc[qb+1]=Wb.v;qb=qb+2}}if(qb>0){f.bindBuffer(f.ARRAY_BUFFER,V.__webglUVBuffer);f.bufferData(f.ARRAY_BUFFER,kc,Ja)}}if(Uc&&Qc&&ac){x=0;for(J=ba.length;x<J;x++){Ta=ba[x];B=qa[Ta];Vb=Qc[Ta];if(Vb!==void 0)for(aa=0;aa<3;aa++){Xb=Vb[aa];lc[rb]=Xb.u;lc[rb+1]=Xb.v;rb=rb+2}}x=0;for(J=ca.length;x<J;x++){Ta=ca[x];B=qa[Ta];Vb=Qc[Ta];if(Vb!==void 0)for(aa=0;aa<4;aa++){Xb=Vb[aa];lc[rb]=Xb.u;lc[rb+1]=
+Xb.v;rb=rb+2}}if(rb>0){f.bindBuffer(f.ARRAY_BUFFER,V.__webglUV2Buffer);f.bufferData(f.ARRAY_BUFFER,lc,Ja)}}if(Jc){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];mb[Pa]=oa;mb[Pa+1]=oa+1;mb[Pa+2]=oa+2;Pa=Pa+3;La[Ba]=oa;La[Ba+1]=oa+1;La[Ba+2]=oa;La[Ba+3]=oa+2;La[Ba+4]=oa+1;La[Ba+5]=oa+2;Ba=Ba+6;oa=oa+3}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];mb[Pa]=oa;mb[Pa+1]=oa+1;mb[Pa+2]=oa+3;mb[Pa+3]=oa+1;mb[Pa+4]=oa+2;mb[Pa+5]=oa+3;Pa=Pa+6;La[Ba]=oa;La[Ba+1]=oa+1;La[Ba+2]=oa;La[Ba+3]=oa+3;La[Ba+4]=oa+1;La[Ba+5]=oa+2;
+La[Ba+6]=oa+2;La[Ba+7]=oa+3;Ba=Ba+8;oa=oa+4}f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,V.__webglFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,mb,Ja);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,V.__webglLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,La,Ja)}if(Oc){aa=0;for(cc=Oc.length;aa<cc;aa++){t=Oc[aa];if(t.__original.needsUpdate){u=0;if(t.size===1)if(t.boundTo===void 0||t.boundTo==="vertices"){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];t.array[u]=t.value[B.a];t.array[u+1]=t.value[B.b];t.array[u+2]=t.value[B.c];
+u=u+3}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];t.array[u]=t.value[B.a];t.array[u+1]=t.value[B.b];t.array[u+2]=t.value[B.c];t.array[u+3]=t.value[B.d];u=u+4}}else{if(t.boundTo==="faces"){x=0;for(J=ba.length;x<J;x++){Ka=t.value[ba[x]];t.array[u]=Ka;t.array[u+1]=Ka;t.array[u+2]=Ka;u=u+3}x=0;for(J=ca.length;x<J;x++){Ka=t.value[ca[x]];t.array[u]=Ka;t.array[u+1]=Ka;t.array[u+2]=Ka;t.array[u+3]=Ka;u=u+4}}}else if(t.size===2)if(t.boundTo===void 0||t.boundTo==="vertices"){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];
+M=t.value[B.a];N=t.value[B.b];O=t.value[B.c];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=N.x;t.array[u+3]=N.y;t.array[u+4]=O.x;t.array[u+5]=O.y;u=u+6}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];M=t.value[B.a];N=t.value[B.b];O=t.value[B.c];da=t.value[B.d];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=N.x;t.array[u+3]=N.y;t.array[u+4]=O.x;t.array[u+5]=O.y;t.array[u+6]=da.x;t.array[u+7]=da.y;u=u+8}}else{if(t.boundTo==="faces"){x=0;for(J=ba.length;x<J;x++){O=N=M=Ka=t.value[ba[x]];t.array[u]=M.x;t.array[u+
+1]=M.y;t.array[u+2]=N.x;t.array[u+3]=N.y;t.array[u+4]=O.x;t.array[u+5]=O.y;u=u+6}x=0;for(J=ca.length;x<J;x++){da=O=N=M=Ka=t.value[ca[x]];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=N.x;t.array[u+3]=N.y;t.array[u+4]=O.x;t.array[u+5]=O.y;t.array[u+6]=da.x;t.array[u+7]=da.y;u=u+8}}}else if(t.size===3){var Y;Y=t.type==="c"?["r","g","b"]:["x","y","z"];if(t.boundTo===void 0||t.boundTo==="vertices"){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];M=t.value[B.a];N=t.value[B.b];O=t.value[B.c];t.array[u]=M[Y[0]];
+t.array[u+1]=M[Y[1]];t.array[u+2]=M[Y[2]];t.array[u+3]=N[Y[0]];t.array[u+4]=N[Y[1]];t.array[u+5]=N[Y[2]];t.array[u+6]=O[Y[0]];t.array[u+7]=O[Y[1]];t.array[u+8]=O[Y[2]];u=u+9}x=0;for(J=ca.length;x<J;x++){B=qa[ca[x]];M=t.value[B.a];N=t.value[B.b];O=t.value[B.c];da=t.value[B.d];t.array[u]=M[Y[0]];t.array[u+1]=M[Y[1]];t.array[u+2]=M[Y[2]];t.array[u+3]=N[Y[0]];t.array[u+4]=N[Y[1]];t.array[u+5]=N[Y[2]];t.array[u+6]=O[Y[0]];t.array[u+7]=O[Y[1]];t.array[u+8]=O[Y[2]];t.array[u+9]=da[Y[0]];t.array[u+10]=da[Y[1]];
+t.array[u+11]=da[Y[2]];u=u+12}}else if(t.boundTo==="faces"){x=0;for(J=ba.length;x<J;x++){O=N=M=Ka=t.value[ba[x]];t.array[u]=M[Y[0]];t.array[u+1]=M[Y[1]];t.array[u+2]=M[Y[2]];t.array[u+3]=N[Y[0]];t.array[u+4]=N[Y[1]];t.array[u+5]=N[Y[2]];t.array[u+6]=O[Y[0]];t.array[u+7]=O[Y[1]];t.array[u+8]=O[Y[2]];u=u+9}x=0;for(J=ca.length;x<J;x++){da=O=N=M=Ka=t.value[ca[x]];t.array[u]=M[Y[0]];t.array[u+1]=M[Y[1]];t.array[u+2]=M[Y[2]];t.array[u+3]=N[Y[0]];t.array[u+4]=N[Y[1]];t.array[u+5]=N[Y[2]];t.array[u+6]=O[Y[0]];
+t.array[u+7]=O[Y[1]];t.array[u+8]=O[Y[2]];t.array[u+9]=da[Y[0]];t.array[u+10]=da[Y[1]];t.array[u+11]=da[Y[2]];u=u+12}}}else if(t.size===4)if(t.boundTo===void 0||t.boundTo==="vertices"){x=0;for(J=ba.length;x<J;x++){B=qa[ba[x]];M=t.value[B.a];N=t.value[B.b];O=t.value[B.c];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=M.z;t.array[u+3]=M.w;t.array[u+4]=N.x;t.array[u+5]=N.y;t.array[u+6]=N.z;t.array[u+7]=N.w;t.array[u+8]=O.x;t.array[u+9]=O.y;t.array[u+10]=O.z;t.array[u+11]=O.w;u=u+12}x=0;for(J=ca.length;x<
+J;x++){B=qa[ca[x]];M=t.value[B.a];N=t.value[B.b];O=t.value[B.c];da=t.value[B.d];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=M.z;t.array[u+3]=M.w;t.array[u+4]=N.x;t.array[u+5]=N.y;t.array[u+6]=N.z;t.array[u+7]=N.w;t.array[u+8]=O.x;t.array[u+9]=O.y;t.array[u+10]=O.z;t.array[u+11]=O.w;t.array[u+12]=da.x;t.array[u+13]=da.y;t.array[u+14]=da.z;t.array[u+15]=da.w;u=u+16}}else if(t.boundTo==="faces"){x=0;for(J=ba.length;x<J;x++){O=N=M=Ka=t.value[ba[x]];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=M.z;t.array[u+
+3]=M.w;t.array[u+4]=N.x;t.array[u+5]=N.y;t.array[u+6]=N.z;t.array[u+7]=N.w;t.array[u+8]=O.x;t.array[u+9]=O.y;t.array[u+10]=O.z;t.array[u+11]=O.w;u=u+12}x=0;for(J=ca.length;x<J;x++){da=O=N=M=Ka=t.value[ca[x]];t.array[u]=M.x;t.array[u+1]=M.y;t.array[u+2]=M.z;t.array[u+3]=M.w;t.array[u+4]=N.x;t.array[u+5]=N.y;t.array[u+6]=N.z;t.array[u+7]=N.w;t.array[u+8]=O.x;t.array[u+9]=O.y;t.array[u+10]=O.z;t.array[u+11]=O.w;t.array[u+12]=da.x;t.array[u+13]=da.y;t.array[u+14]=da.z;t.array[u+15]=da.w;u=u+16}}f.bindBuffer(f.ARRAY_BUFFER,
+t.buffer);f.bufferData(f.ARRAY_BUFFER,t.array,Ja)}}}if(tc){delete V.__inittedArrays;delete V.__colorArray;delete V.__normalArray;delete V.__tangentArray;delete V.__uvArray;delete V.__uv2Array;delete V.__faceArray;delete V.__vertexArray;delete V.__lineArray;delete V.__skinVertexAArray;delete V.__skinVertexBArray;delete V.__skinIndexArray;delete V.__skinWeightArray}}}}Z.verticesNeedUpdate=false;Z.morphTargetsNeedUpdate=false;Z.elementsNeedUpdate=false;Z.uvsNeedUpdate=false;Z.normalsNeedUpdate=false;
+Z.colorsNeedUpdate=false;Z.tangetsNeedUpdate=false;Ga.attributes&&v(Ga)}else if(Va instanceof THREE.Ribbon){if(Z.verticesNeedUpdate||Z.colorsNeedUpdate){var Fb=Z,Vc=f.DYNAMIC_DRAW,mc=void 0,nc=void 0,Ac=void 0,Gb=void 0,Bc=void 0,Wc=Fb.vertices,Xc=Fb.colors,ed=Wc.length,fd=Xc.length,Cc=Fb.__vertexArray,Dc=Fb.__colorArray,gd=Fb.colorsNeedUpdate;if(Fb.verticesNeedUpdate){for(mc=0;mc<ed;mc++){Ac=Wc[mc];Gb=mc*3;Cc[Gb]=Ac.x;Cc[Gb+1]=Ac.y;Cc[Gb+2]=Ac.z}f.bindBuffer(f.ARRAY_BUFFER,Fb.__webglVertexBuffer);
+f.bufferData(f.ARRAY_BUFFER,Cc,Vc)}if(gd){for(nc=0;nc<fd;nc++){Bc=Xc[nc];Gb=nc*3;Dc[Gb]=Bc.r;Dc[Gb+1]=Bc.g;Dc[Gb+2]=Bc.b}f.bindBuffer(f.ARRAY_BUFFER,Fb.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,Dc,Vc)}}Z.verticesNeedUpdate=false;Z.colorsNeedUpdate=false}else if(Va instanceof THREE.Line){Ga=c(Va,ec);Sb=Ga.attributes&&l(Ga);if(Z.verticesNeedUpdate||Z.colorsNeedUpdate||Sb){var sb=Z,Rc=f.DYNAMIC_DRAW,oc=void 0,pc=void 0,Ec=void 0,na=void 0,Fc=void 0,Yc=sb.vertices,Zc=sb.colors,hd=Yc.length,id=Zc.length,
+Gc=sb.__vertexArray,Hc=sb.__colorArray,jd=sb.colorsNeedUpdate,Sc=sb.__webglCustomAttributesList,Ic=void 0,$c=void 0,xa=void 0,Yb=void 0,Ha=void 0,ha=void 0;if(sb.verticesNeedUpdate){for(oc=0;oc<hd;oc++){Ec=Yc[oc];na=oc*3;Gc[na]=Ec.x;Gc[na+1]=Ec.y;Gc[na+2]=Ec.z}f.bindBuffer(f.ARRAY_BUFFER,sb.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,Gc,Rc)}if(jd){for(pc=0;pc<id;pc++){Fc=Zc[pc];na=pc*3;Hc[na]=Fc.r;Hc[na+1]=Fc.g;Hc[na+2]=Fc.b}f.bindBuffer(f.ARRAY_BUFFER,sb.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,
+Hc,Rc)}if(Sc){Ic=0;for($c=Sc.length;Ic<$c;Ic++){ha=Sc[Ic];if(ha.needsUpdate&&(ha.boundTo===void 0||ha.boundTo==="vertices")){na=0;Yb=ha.value.length;if(ha.size===1)for(xa=0;xa<Yb;xa++)ha.array[xa]=ha.value[xa];else if(ha.size===2)for(xa=0;xa<Yb;xa++){Ha=ha.value[xa];ha.array[na]=Ha.x;ha.array[na+1]=Ha.y;na=na+2}else if(ha.size===3)if(ha.type==="c")for(xa=0;xa<Yb;xa++){Ha=ha.value[xa];ha.array[na]=Ha.r;ha.array[na+1]=Ha.g;ha.array[na+2]=Ha.b;na=na+3}else for(xa=0;xa<Yb;xa++){Ha=ha.value[xa];ha.array[na]=
+Ha.x;ha.array[na+1]=Ha.y;ha.array[na+2]=Ha.z;na=na+3}else if(ha.size===4)for(xa=0;xa<Yb;xa++){Ha=ha.value[xa];ha.array[na]=Ha.x;ha.array[na+1]=Ha.y;ha.array[na+2]=Ha.z;ha.array[na+3]=Ha.w;na=na+4}f.bindBuffer(f.ARRAY_BUFFER,ha.buffer);f.bufferData(f.ARRAY_BUFFER,ha.array,Rc)}}}}Z.verticesNeedUpdate=false;Z.colorsNeedUpdate=false;Ga.attributes&&v(Ga)}else if(Va instanceof THREE.ParticleSystem){Ga=c(Va,ec);Sb=Ga.attributes&&l(Ga);(Z.verticesNeedUpdate||Z.colorsNeedUpdate||Va.sortParticles||Sb)&&g(Z,
+f.DYNAMIC_DRAW,Va);Z.verticesNeedUpdate=false;Z.colorsNeedUpdate=false;Ga.attributes&&v(Ga)}}};this.initMaterial=function(a,b,c,d){var e,g,h;a instanceof THREE.MeshDepthMaterial?h="depth":a instanceof THREE.MeshNormalMaterial?h="normal":a instanceof THREE.MeshBasicMaterial?h="basic":a instanceof THREE.MeshLambertMaterial?h="lambert":a instanceof THREE.MeshPhongMaterial?h="phong":a instanceof THREE.LineBasicMaterial?h="basic":a instanceof THREE.ParticleBasicMaterial&&(h="particle_basic");if(h){var i=
+THREE.ShaderLib[h];a.uniforms=THREE.UniformsUtils.clone(i.uniforms);a.vertexShader=i.vertexShader;a.fragmentShader=i.fragmentShader}var j,k,l,m,n;j=m=n=i=0;for(k=b.length;j<k;j++){l=b[j];if(!l.onlyShadow){l instanceof THREE.DirectionalLight&&m++;l instanceof THREE.PointLight&&n++;l instanceof THREE.SpotLight&&i++}}if(n+i+m<=X){k=m;l=n;m=i}else{k=Math.ceil(X*m/(n+m));m=l=X-k}var p=0,i=0;for(n=b.length;i<n;i++){j=b[i];if(j.castShadow){j instanceof THREE.SpotLight&&p++;j instanceof THREE.DirectionalLight&&
+!j.shadowCascade&&p++}}var r=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)r=d.bones.length;var o;a:{n=a.fragmentShader;j=a.vertexShader;var i=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,maxBones:r,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:k,maxPointLights:l,
+maxSpotLights:m,maxShadows:p,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,shadowMapCascade:this.shadowMapCascade,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:d&&d.doubleSided},q,d=[];if(h)d.push(h);else{d.push(n);d.push(j)}for(q in c){d.push(q);d.push(c[q])}h=d.join();q=0;for(d=fa.length;q<d;q++)if(fa[q].code===h){o=fa[q].program;break a}q=f.createProgram();d=["precision "+
+I+" float;",cc>0?"#define VERTEX_TEXTURES":"",E.gammaInput?"#define GAMMA_INPUT":"",E.gammaOutput?"#define GAMMA_OUTPUT":"",E.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":
+"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
 k=["precision "+I+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",E.gammaInput?"#define GAMMA_INPUT":"",E.gammaOutput?"#define GAMMA_OUTPUT":"",E.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":
 k=["precision "+I+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",E.gammaInput?"#define GAMMA_INPUT":"",E.gammaOutput?"#define GAMMA_OUTPUT":"",E.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":
 "",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");
 "",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");
 f.attachShader(q,D("fragment",k+n));f.attachShader(q,D("vertex",d+j));f.linkProgram(q);f.getProgramParameter(q,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(q,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");q.uniforms={};q.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","boneGlobalMatrices","morphTargetInfluences"];for(s in i)d.push(s);s=d;d=0;for(i=s.length;d<i;d++){n=
 f.attachShader(q,D("fragment",k+n));f.attachShader(q,D("vertex",d+j));f.linkProgram(q);f.getProgramParameter(q,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(q,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");q.uniforms={};q.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","boneGlobalMatrices","morphTargetInfluences"];for(s in i)d.push(s);s=d;d=0;for(i=s.length;d<i;d++){n=

+ 14 - 5
src/renderers/WebGLRenderer.js

@@ -3247,7 +3247,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 				if ( influence > 0 ) {
 				if ( influence > 0 ) {
 
 
-					activeInfluenceIndices.push( i );
+					activeInfluenceIndices.push( [ i, influence ] );
 
 
 				}
 				}
 
 
@@ -3264,7 +3264,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			} else if ( activeInfluenceIndices.length === 0 ) {
 			} else if ( activeInfluenceIndices.length === 0 ) {
 
 
-				activeInfluenceIndices.push( 0 );
+				activeInfluenceIndices.push( [ 0, 0 ] );
 
 
 			};
 			};
 
 
@@ -3272,7 +3272,15 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			while ( m < material.numSupportedMorphTargets ) {
 			while ( m < material.numSupportedMorphTargets ) {
 
 
-				influenceIndex = activeInfluenceIndices[ m ];
+				if ( m < activeInfluenceIndices.length ) {
+
+					influenceIndex = activeInfluenceIndices[ m ][ 0 ];
+
+				} else {
+
+					influenceIndex = undefined;
+
+				}
 
 
 				if ( influenceIndex !== undefined || m === 0 ) {
 				if ( influenceIndex !== undefined || m === 0 ) {
 
 
@@ -3296,6 +3304,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 					if ( material.morphNormals ) {
 					if ( material.morphNormals ) {
 
 
 						_gl.vertexAttribPointer( attributes[ "morphNormal" + m ], 3, _gl.FLOAT, false, 0, 0 );
 						_gl.vertexAttribPointer( attributes[ "morphNormal" + m ], 3, _gl.FLOAT, false, 0, 0 );
+
 					}
 					}
 
 
 					object.__webglMorphTargetInfluences[ m ] = 0;
 					object.__webglMorphTargetInfluences[ m ] = 0;
@@ -3326,9 +3335,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
-	function numericalSort( a, b ) {
+	function numericalSort ( a, b ) {
 
 
-		return a - b;
+		return b[ 1 ] - a[ 1 ];
 
 
 	};
 	};