Skip to content

Commit ad90938

Browse files
committed
add invertTrProperty option to MTLLoader
1 parent d381e6c commit ad90938

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

docs/examples/loaders/MTLLoader.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1>[name]</h1>
1313

1414
<div class="desc">A loader for loading an <em>.mtl</em> resource, used internaly by [page:OBJMTLLoader] and [page:UTF8Loader].<br />
1515
The Material Template Library format (MTL) or .MTL File Format is a companion file format to .OBJ that describes surface shading
16-
(material) properties of objects within one or more .OBJ files.
16+
(material) properties of objects within one or more .OBJ files.
1717
</div>
1818

1919
<h2>Constructor</h2>
@@ -69,7 +69,7 @@ <h3>[method:null setCrossOrigin]( [page:boolean useCrossOrigin] )</h3>
6969
<div>
7070
Set to true if you need to load textures from a different origin.
7171
</div>
72-
72+
7373

7474
<h3>[method:null setMaterialOptions]( [page:Object options] )</h3>
7575
<div>
@@ -79,12 +79,13 @@ <h3>[method:null setMaterialOptions]( [page:Object options] )</h3>
7979
<li>wrap: What type of wrapping to apply for textures. THREE.RepeatWrapping (default), THREE.ClampToEdgeWrapping, THREE.MirroredRepeatWrapping</li>
8080
<li>normalizeRGB: RGBs need to be normalized to 0-1 from 0-255. Default: false, assumed to be already normalized</li>
8181
<li>ignoreZeroRGBs: Ignore values of RGBs (Ka,Kd,Ks) that are all 0's. Default: false</li>
82+
<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>
8283
</ul>
8384
</div>
8485
<div>
8586
Set of options on how to construct the materials
8687
</div>
87-
88+
8889

8990
<h3>[method:MTLLoaderMaterialCreator parse]( [page:String text] )</h3>
9091
<div>
@@ -93,7 +94,7 @@ <h3>[method:MTLLoaderMaterialCreator parse]( [page:String text] )</h3>
9394
<div>
9495
Parse a <em>mtl</em> text structure and return a [page:MTLLoaderMaterialCreator] instance.<br />
9596
</div>
96-
97+
9798

9899
<h2>Source</h2>
99100

examples/js/loaders/MTLLoader.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,11 @@ THREE.MTLLoader.MaterialCreator.prototype = {
462462
case 'tr':
463463
n = parseFloat( value );
464464

465-
if ( n > 0 ) {
465+
if ( this.options && this.options.invertTrProperty ) n = 1 - n;
466466

467-
params.opacity = 1 - n;
467+
if ( n < 1 ) {
468+
469+
params.opacity = n;
468470
params.transparent = true;
469471

470472
}

0 commit comments

Comments
 (0)