Browse Source

MTLLoader: Added Tr support. Removed invertTransparency option. See #7520

Mr.doob 9 years ago
parent
commit
011c8d3e4c
2 changed files with 13 additions and 28 deletions
  1. 1 1
      docs/api/loaders/MTLLoader.html
  2. 12 27
      examples/js/loaders/MTLLoader.js

+ 1 - 1
docs/api/loaders/MTLLoader.html

@@ -19,7 +19,7 @@
 		<h3>[name]( [page:String baseUrl], [page:Object options], [page:String crossOrigin] )</h3>
 		<div>
 		[page:String baseUrl] — The base url from which to find subsequent resources.<br />
-		[page:Object options] — Options passed to the created material (side, wrap, normalizeRGB, ignoreZeroRGBs, invertTransparency).<br />
+		[page:Object options] — Options passed to the created material (side, wrap, normalizeRGB, ignoreZeroRGBs).<br />
 		[page:String crossOrigin] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.<br />
 		</div>
 		<div>

+ 12 - 27
examples/js/loaders/MTLLoader.js

@@ -124,8 +124,6 @@ THREE.MTLLoader.prototype = {
  *                                Default: false, assumed to be already normalized
  *                  ignoreZeroRGBs: Ignore values of RGBs (Ka,Kd,Ks) that are all 0's
  *                                  Default: false
- *                  invertTransparency: If transparency need to be inverted (inversion is needed if d = 0 is fully opaque)
- *                                      Default: false (d = 1 is fully opaque)
  * @constructor
  */
 
@@ -218,20 +216,6 @@ THREE.MTLLoader.MaterialCreator.prototype = {
 
 						break;
 
-					case 'd':
-
-						// According to MTL format (http://paulbourke.net/dataformats/mtl/):
-						//   d is dissolve for current material
-						//   factor of 1.0 is fully opaque, a factor of 0 is fully dissolved (completely transparent)
-
-						if ( this.options && this.options.invertTransparency ) {
-
-							value = 1 - value;
-
-						}
-
-						break;
-
 					default:
 
 						break;
@@ -327,12 +311,6 @@ THREE.MTLLoader.MaterialCreator.prototype = {
 
 					break;
 
-				case 'ka':
-
-					// Ambient color (color under shadow) using RGB values
-
-					break;
-
 				case 'ks':
 
 					// Specular color (color when light is reflected from shiny surface) using RGB values
@@ -361,14 +339,21 @@ THREE.MTLLoader.MaterialCreator.prototype = {
 
 				case 'd':
 
-					// According to MTL format (http://paulbourke.net/dataformats/mtl/):
-					//   d is dissolve for current material
-					//   factor of 1.0 is fully opaque, a factor of 0 is fully dissolved (completely transparent)
-
 					if ( value < 1 ) {
 
-						params[ 'transparent' ] = true;
 						params[ 'opacity' ] = value;
+						params[ 'transparent' ] = true;
+
+					}
+
+					break;
+
+				case 'Tr':
+
+					if ( value > 0 ) {
+
+						params[ 'opacity' ] = 1 - value;
+						params[ 'transparent' ] = true;
 
 					}