提交 4ac72ffc 编写于 作者: A alteredq

Added material name tracking in Loader.

上级 019a0f59
......@@ -560,8 +560,8 @@ if(f[0]!=1)a[c].wrapS=THREE.RepeatWrapping;if(f[1]!=1)a[c].wrapT=THREE.RepeatWra
i="MeshPhongMaterial":a.shading=="Basic"&&(i="MeshBasicMaterial"));if(a.blending)if(a.blending=="Additive")h.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")h.blending=THREE.SubtractiveBlending;else if(a.blending=="Multiply")h.blending=THREE.MultiplyBlending;if(a.transparent!==void 0||a.opacity<1)h.transparent=a.transparent;if(a.depthTest!==void 0)h.depthTest=a.depthTest;if(a.vertexColors!==void 0)if(a.vertexColors=="face")h.vertexColors=THREE.FaceColors;else if(a.vertexColors)h.vertexColors=
THREE.VertexColors;if(a.colorDiffuse)h.color=f(a.colorDiffuse);else if(a.DbgColor)h.color=a.DbgColor;if(a.colorSpecular)h.specular=f(a.colorSpecular);if(a.colorAmbient)h.ambient=f(a.colorAmbient);if(a.transparency)h.opacity=a.transparency;if(a.specularCoef)h.shininess=a.specularCoef;a.mapDiffuse&&b&&e(h,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&e(h,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&e(h,"normalMap",
a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap);a.mapSpecular&&b&&e(h,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var j=THREE.ShaderUtils.lib.normal,o=THREE.UniformsUtils.clone(j.uniforms),p=h.color;i=h.specular;k=h.ambient;var m=h.shininess;o.tNormal.texture=h.normalMap;if(a.mapNormalFactor)o.uNormalScale.value=a.mapNormalFactor;if(h.map)o.tDiffuse.texture=h.map,o.enableDiffuse.value=!0;if(h.specularMap)o.tSpecular.texture=
h.specularMap,o.enableSpecular.value=!0;if(h.lightMap)o.tAO.texture=h.lightMap,o.enableAO.value=!0;o.uDiffuseColor.value.setHex(p);o.uSpecularColor.value.setHex(i);o.uAmbientColor.value.setHex(k);o.uShininess.value=m;if(h.opacity)o.uOpacity.value=h.opacity;h=new THREE.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:o,lights:!0,fog:!0})}else h=new THREE[i](h);return h}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;
THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
h.specularMap,o.enableSpecular.value=!0;if(h.lightMap)o.tAO.texture=h.lightMap,o.enableAO.value=!0;o.uDiffuseColor.value.setHex(p);o.uSpecularColor.value.setHex(i);o.uAmbientColor.value.setHex(k);o.uShininess.value=m;if(h.opacity)o.uOpacity.value=h.opacity;h=new THREE.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:o,lights:!0,fog:!0})}else h=new THREE[i](h);if(a.DbgName!==void 0)h.name=a.DbgName;return h}};
THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
THREE.BinaryLoader.prototype.load=function(a,b,c,d){if(a instanceof Object)console.warn("DEPRECATED: BinaryLoader( parameters ) is now BinaryLoader( url, callback, texturePath, binaryPath )."),d=a,a=d.model,b=d.callback,c=d.texture_path,d=d.bin_path;var c=c?c:this.extractUrlbase(a),d=d?d:this.extractUrlbase(a),e=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,b,c,d,e)};
THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,e,f){var g=new XMLHttpRequest;g.onreadystatechange=function(){if(g.readyState==4)if(g.status==200||g.status==0)try{var h=JSON.parse(g.responseText);h.metadata===void 0||h.metadata.formatVersion===void 0||h.metadata.formatVersion!==3?console.error("Deprecated file format."):a.loadAjaxBuffers(h,c,e,d,f)}catch(i){console.error(i),console.warn("DEPRECATED: ["+b+"] seems to be using old model format")}else console.error("Couldn't load ["+b+"] ["+
g.status+"]")};g.open("GET",b,!0);g.overrideMimeType("text/plain; charset=x-user-defined");g.setRequestHeader("Content-Type","text/plain");g.send(null)};
......
......@@ -217,8 +217,8 @@ if(g[0]!=1)a[c].wrapS=THREE.RepeatWrapping;if(g[1]!=1)a[c].wrapT=THREE.RepeatWra
i="MeshPhongMaterial":a.shading=="Basic"&&(i="MeshBasicMaterial"));if(a.blending)if(a.blending=="Additive")h.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")h.blending=THREE.SubtractiveBlending;else if(a.blending=="Multiply")h.blending=THREE.MultiplyBlending;if(a.transparent!==void 0||a.opacity<1)h.transparent=a.transparent;if(a.depthTest!==void 0)h.depthTest=a.depthTest;if(a.vertexColors!==void 0)if(a.vertexColors=="face")h.vertexColors=THREE.FaceColors;else if(a.vertexColors)h.vertexColors=
THREE.VertexColors;if(a.colorDiffuse)h.color=g(a.colorDiffuse);else if(a.DbgColor)h.color=a.DbgColor;if(a.colorSpecular)h.specular=g(a.colorSpecular);if(a.colorAmbient)h.ambient=g(a.colorAmbient);if(a.transparency)h.opacity=a.transparency;if(a.specularCoef)h.shininess=a.specularCoef;a.mapDiffuse&&b&&e(h,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&e(h,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&e(h,"normalMap",
a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap);a.mapSpecular&&b&&e(h,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var j=THREE.ShaderUtils.lib.normal,q=THREE.UniformsUtils.clone(j.uniforms),p=h.color;i=h.specular;k=h.ambient;var m=h.shininess;q.tNormal.texture=h.normalMap;if(a.mapNormalFactor)q.uNormalScale.value=a.mapNormalFactor;if(h.map)q.tDiffuse.texture=h.map,q.enableDiffuse.value=!0;if(h.specularMap)q.tSpecular.texture=
h.specularMap,q.enableSpecular.value=!0;if(h.lightMap)q.tAO.texture=h.lightMap,q.enableAO.value=!0;q.uDiffuseColor.value.setHex(p);q.uSpecularColor.value.setHex(i);q.uAmbientColor.value.setHex(k);q.uShininess.value=m;if(h.opacity)q.uOpacity.value=h.opacity;h=new THREE.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:q,lights:!0,fog:!0})}else h=new THREE[i](h);return h}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;
THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
h.specularMap,q.enableSpecular.value=!0;if(h.lightMap)q.tAO.texture=h.lightMap,q.enableAO.value=!0;q.uDiffuseColor.value.setHex(p);q.uSpecularColor.value.setHex(i);q.uAmbientColor.value.setHex(k);q.uShininess.value=m;if(h.opacity)q.uOpacity.value=h.opacity;h=new THREE.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:q,lights:!0,fog:!0})}else h=new THREE[i](h);if(a.DbgName!==void 0)h.name=a.DbgName;return h}};
THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
THREE.BinaryLoader.prototype.load=function(a,b,c,d){if(a instanceof Object)console.warn("DEPRECATED: BinaryLoader( parameters ) is now BinaryLoader( url, callback, texturePath, binaryPath )."),d=a,a=d.model,b=d.callback,c=d.texture_path,d=d.bin_path;var c=c?c:this.extractUrlbase(a),d=d?d:this.extractUrlbase(a),e=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,b,c,d,e)};
THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,e,g){var f=new XMLHttpRequest;f.onreadystatechange=function(){if(f.readyState==4)if(f.status==200||f.status==0)try{var h=JSON.parse(f.responseText);h.metadata===void 0||h.metadata.formatVersion===void 0||h.metadata.formatVersion!==3?console.error("Deprecated file format."):a.loadAjaxBuffers(h,c,e,d,g)}catch(i){console.error(i),console.warn("DEPRECATED: ["+b+"] seems to be using old model format")}else console.error("Couldn't load ["+b+"] ["+
f.status+"]")};f.open("GET",b,!0);f.overrideMimeType("text/plain; charset=x-user-defined");f.setRequestHeader("Content-Type","text/plain");f.send(null)};
......
......@@ -369,6 +369,8 @@ THREE.Loader.prototype = {
}
if ( m.DbgName !== undefined ) material.name = m.DbgName;
return material;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册