|
@@ -276,13 +276,12 @@ T.vertexBuffer);n.bufferData(n.ARRAY_BUFFER,T.vertices,n.STATIC_DRAW);n.bindBuff
|
|
|
T.uniforms.affectedByDistance=n.getUniformLocation(T.program,"affectedByDistance");T.uniforms.screenPosition=n.getUniformLocation(T.program,"screenPosition");T.uniforms.modelViewMatrix=n.getUniformLocation(T.program,"modelViewMatrix");T.uniforms.projectionMatrix=n.getUniformLocation(T.program,"projectionMatrix");var Ba=!1;this.setSize=function(b,c){za.width=b;za.height=c;this.setViewport(0,0,za.width,za.height)};this.setViewport=function(b,c,e,f){W=b;da=c;fa=e;la=f;n.viewport(W,da,fa,la)};this.setScissor=
|
|
|
function(b,c,e,f){n.scissor(b,c,e,f)};this.enableScissorTest=function(b){b?n.enable(n.SCISSOR_TEST):n.disable(n.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){aa=b;n.depthMask(b)};this.setClearColorHex=function(b,c){sa.setHex(b);na=c;n.clearColor(sa.r,sa.g,sa.b,na)};this.setClearColor=function(b,c){sa.copy(b);na=c;n.clearColor(sa.r,sa.g,sa.b,na)};this.clear=function(){n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT|n.STENCIL_BUFFER_BIT)};this.getContext=function(){return n};this.deallocateObject=
|
|
|
function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c=b.geometry.geometryGroups[g];n.deleteBuffer(c.__webglVertexBuffer);n.deleteBuffer(c.__webglNormalBuffer);n.deleteBuffer(c.__webglTangentBuffer);n.deleteBuffer(c.__webglColorBuffer);n.deleteBuffer(c.__webglUVBuffer);n.deleteBuffer(c.__webglUV2Buffer);n.deleteBuffer(c.__webglSkinVertexABuffer);
|
|
|
-n.deleteBuffer(c.__webglSkinVertexBBuffer);n.deleteBuffer(c.__webglSkinIndicesBuffer);n.deleteBuffer(c.__webglSkinWeightsBuffer);n.deleteBuffer(c.__webglFaceBuffer);n.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets){var e=void 0,f=void 0;c.__webglMorphTargetsBuffers=[];e=0;for(f=c.numMorphTargets;e<f;e++)n.deleteBuffer(c.__webglMorphTargetsBuffers[e])}}else if(b instanceof THREE.Ribbon)b=b.geometry,n.deleteBuffer(b.__webglVertexBuffer),n.deleteBuffer(b.__webglColorBuffer);else if(b instanceof
|
|
|
-THREE.Line)b=b.geometry,n.deleteBuffer(b.__webglVertexBuffer),n.deleteBuffer(b.__webglColorBuffer);else if(b instanceof THREE.ParticleSystem)b=b.geometry,n.deleteBuffer(b.__webglVertexBuffer),n.deleteBuffer(b.__webglColorBuffer)};this.deallocateTexture=function(b){if(b.__webglInit)b.__webglInit=!1,n.deleteTexture(b.__webglTexture)};this.initMaterial=function(b,c,e,f){var h,j,k;b instanceof THREE.MeshDepthMaterial?k="depth":b instanceof THREE.MeshNormalMaterial?k="normal":b instanceof THREE.MeshBasicMaterial?
|
|
|
-k="basic":b instanceof THREE.MeshLambertMaterial?k="lambert":b instanceof THREE.MeshPhongMaterial?k="phong":b instanceof THREE.LineBasicMaterial?k="basic":b instanceof THREE.ParticleBasicMaterial&&(k="particle_basic");if(k){var m=THREE.ShaderLib[k];b.uniforms=THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var o,u,v;o=v=m=0;for(u=c.length;o<u;o++)j=c[o],j instanceof THREE.SpotLight&&v++,j instanceof THREE.DirectionalLight&&v++,j instanceof THREE.PointLight&&
|
|
|
-m++;m+v<=_maxLights?o=v:(o=Math.ceil(_maxLights*v/(m+v)),m=_maxLights-o);j={directional:o,point:m};m=v=0;for(o=c.length;m<o;m++)u=c[m],u instanceof THREE.SpotLight&&u.castShadow&&v++;var p=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)p=f.bones.length;var t;a:{o=b.fragmentShader;u=b.vertexShader;var m=b.uniforms,c=b.attributes,e={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:e,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,
|
|
|
-maxMorphTargets:this.maxMorphTargets,maxDirLights:j.directional,maxPointLights:j.point,maxBones:p,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:v,alphaTest:b.alphaTest},w,f=[];k?f.push(k):(f.push(o),f.push(u));for(w in e)f.push(w),f.push(e[w]);k=f.join();w=0;for(f=V.length;w<f;w++)if(V[w].code==k){t=V[w].program;break a}w=n.createProgram();f=[ta?"#define VERTEX_TEXTURES":"",
|
|
|
-"#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,"#define MAX_BONES "+e.maxBones,e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":
|
|
|
-"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\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;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
|
|
|
+n.deleteBuffer(c.__webglSkinVertexBBuffer);n.deleteBuffer(c.__webglSkinIndicesBuffer);n.deleteBuffer(c.__webglSkinWeightsBuffer);n.deleteBuffer(c.__webglFaceBuffer);n.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var e=0,f=c.numMorphTargets;e<f;e++)n.deleteBuffer(c.__webglMorphTargetsBuffers[e])}else if(b instanceof THREE.Ribbon)b=b.geometry,n.deleteBuffer(b.__webglVertexBuffer),n.deleteBuffer(b.__webglColorBuffer);else if(b instanceof THREE.Line)b=b.geometry,n.deleteBuffer(b.__webglVertexBuffer),
|
|
|
+n.deleteBuffer(b.__webglColorBuffer);else if(b instanceof THREE.ParticleSystem)b=b.geometry,n.deleteBuffer(b.__webglVertexBuffer),n.deleteBuffer(b.__webglColorBuffer)};this.deallocateTexture=function(b){if(b.__webglInit)b.__webglInit=!1,n.deleteTexture(b.__webglTexture)};this.initMaterial=function(b,c,e,f){var h,j,k;b instanceof THREE.MeshDepthMaterial?k="depth":b instanceof THREE.MeshNormalMaterial?k="normal":b instanceof THREE.MeshBasicMaterial?k="basic":b instanceof THREE.MeshLambertMaterial?k=
|
|
|
+"lambert":b instanceof THREE.MeshPhongMaterial?k="phong":b instanceof THREE.LineBasicMaterial?k="basic":b instanceof THREE.ParticleBasicMaterial&&(k="particle_basic");if(k){var m=THREE.ShaderLib[k];b.uniforms=THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var o,u,v;o=v=m=0;for(u=c.length;o<u;o++)j=c[o],j instanceof THREE.SpotLight&&v++,j instanceof THREE.DirectionalLight&&v++,j instanceof THREE.PointLight&&m++;m+v<=_maxLights?o=v:(o=Math.ceil(_maxLights*
|
|
|
+v/(m+v)),m=_maxLights-o);j={directional:o,point:m};m=v=0;for(o=c.length;m<o;m++)u=c[m],u instanceof THREE.SpotLight&&u.castShadow&&v++;var p=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)p=f.bones.length;var t;a:{o=b.fragmentShader;u=b.vertexShader;var m=b.uniforms,c=b.attributes,e={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:e,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:j.directional,
|
|
|
+maxPointLights:j.point,maxBones:p,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:v,alphaTest:b.alphaTest},w,f=[];k?f.push(k):(f.push(o),f.push(u));for(w in e)f.push(w),f.push(e[w]);k=f.join();w=0;for(f=V.length;w<f;w++)if(V[w].code==k){t=V[w].program;break a}w=n.createProgram();f=[ta?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+
|
|
|
+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,"#define MAX_BONES "+e.maxBones,e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\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;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
|
|
|
j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,e.alphaTest?"#define ALPHATEST "+e.alphaTest:"",e.fog?"#define USE_FOG":"",e.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":
|
|
|
"",e.shadowMapSoft?"#define SHADOWMAP_WIDTH "+e.shadowMapWidth.toFixed(1):"",e.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+e.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");n.attachShader(w,F("fragment",j+o));n.attachShader(w,F("vertex",f+u));n.linkProgram(w);n.getProgramParameter(w,n.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+n.getProgramParameter(w,n.VALIDATE_STATUS)+", gl error ["+n.getError()+"]");w.uniforms=
|
|
|
{};w.attributes={};var y,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(y in m)f.push(y);y=f;f=0;for(m=y.length;f<m;f++)o=y[f],w.uniforms[o]=n.getUniformLocation(w,o);f=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(y=0;y<e.maxMorphTargets;y++)f.push("morphTarget"+y);for(t in c)f.push(t);t=f;y=0;for(c=t.length;y<c;y++)e=
|