Browse Source

add invertTrProperty option to MTLLoader

eastpiger 7 years ago
parent
commit
ad9093801b
2 changed files with 9 additions and 6 deletions
  1. 5 4
      docs/examples/loaders/MTLLoader.html
  2. 4 2
      examples/js/loaders/MTLLoader.js

+ 5 - 4
docs/examples/loaders/MTLLoader.html

@@ -13,7 +13,7 @@
 
 		<div class="desc">A loader for loading an <em>.mtl</em> resource, used internaly by [page:OBJMTLLoader] and [page:UTF8Loader].<br />
 		The Material Template Library format (MTL) or .MTL File Format is a companion file format to .OBJ that describes surface shading
-		(material) properties of objects within one or more .OBJ files. 		
+		(material) properties of objects within one or more .OBJ files.
 		</div>
 
 		<h2>Constructor</h2>
@@ -69,7 +69,7 @@
 		<div>
 			Set to true if you need to load textures from a different origin.
 		</div>
-	
+
 
 		<h3>[method:null setMaterialOptions]( [page:Object options] )</h3>
 		<div>
@@ -79,12 +79,13 @@
 				<li>wrap: What type of wrapping to apply for textures. THREE.RepeatWrapping (default), THREE.ClampToEdgeWrapping, THREE.MirroredRepeatWrapping</li>
 				<li>normalizeRGB: RGBs need to be normalized to 0-1 from 0-255. Default: false, assumed to be already normalized</li>
 				<li>ignoreZeroRGBs: Ignore values of RGBs (Ka,Kd,Ks) that are all 0's. Default: false</li>
+				<li>invertTrProperty: Use values 1 of Tr field for fully opaque. This option is useful for obj exported from 3ds MAX, vcglib or meshlab. Default: false</li>
 			</ul>
 		</div>
 		<div>
 			Set of options on how to construct the materials
 		</div>
-	
+
 
 		<h3>[method:MTLLoaderMaterialCreator parse]( [page:String text] )</h3>
 		<div>
@@ -93,7 +94,7 @@
 		<div>
 			Parse a <em>mtl</em> text structure and return a [page:MTLLoaderMaterialCreator] instance.<br />
 		</div>
-		
+
 
 		<h2>Source</h2>
 

+ 4 - 2
examples/js/loaders/MTLLoader.js

@@ -462,9 +462,11 @@ THREE.MTLLoader.MaterialCreator.prototype = {
 				case 'tr':
 					n = parseFloat( value );
 
-					if ( n > 0 ) {
+					if ( this.options && this.options.invertTrProperty ) n = 1 - n;
 
-						params.opacity = 1 - n;
+					if ( n < 1 ) {
+
+						params.opacity = n;
 						params.transparent = true;
 
 					}