-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
add TrOneIsOpaque option to MTLLoader #12862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add TrOneIsOpaque option to MTLLoader #12862
Conversation
|
I don't know... |
fff1a5f to
e140664
Compare
|
@mrdoob I have re-committed this modification. This modification won't change the default behavior of MTLLoader. Only add a new option to give us capability to switch the parsing of keyword Ts (Ts = 1 - d or Ts = d). Related documents is also updated. |
examples/js/loaders/MTLLoader.js
Outdated
| if ( n > 0 ) { | ||
|
|
||
| params.opacity = 1 - n; | ||
| if ( this.options && this.options.equalizeTransparency ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a code style issue. Please write it like this
if ( this.options && this.options.equalizeTransparency ) {
params.opacity = n;
} else {
params.opacity = 1 - n;
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I will update soon
|
Did you test this code? |
|
Maybe |
b4f9e56 to
9007c0b
Compare
examples/js/loaders/MTLLoader.js
Outdated
| params.opacity = 1 - n; | ||
| if ( this.options && this.options.TrOneIsOpaque ) { | ||
|
|
||
| params.opacity = n; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
params.transparent is set to true when options.TrOneIsOpaque = true and Tr = 1. ???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emmmm... good comment. I didn't notice it. fix soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
9007c0b to
64ecc25
Compare
docs/examples/loaders/MTLLoader.html
Outdated
| <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>TrOneIsOpaque: 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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about calling it invertTr or invertTrProperty?
if ( this.options && this.options.invertTr ) n = 1 - n;
if ( n < 1 ) {
params.opacity = n;
params.transparent = true;
} |
|
@eastpiger Any news on this PR? |
64ecc25 to
ad90938
Compare
|
Yep. |
|
Thanks! |
|
Merging this PR has made any obj model material with The problem looks fairly obvious to me. It was fine to add but should never have been changed to which completely reverse the logic and makes I'd be happy to submit a PR to fix this, unless I'm missing something? |
|
Yes please. A PR would be great 👌 |
#12861 (comment) implies "what it should have" is not well-defined. (Are the docs correct?) Consequently, |
|
@WestLangley Agreed. I have no need for I assume this PR was merged for a good reason, but I'd prefer reverting it unless @eastpiger or someone else can chime in with a good explanation of what's going on here? |
|
As implemented, |
|
Hi all. I'm glad to make more explanation about this problem. as I described in issue #12861, the definition of Tr option in .MTL file is confusing since it actually hasn't never been defined officially. There is a big controversy about it between academic and engineering application. I tried to ask Dr. John Burkardt, which holds the earliest webpage I can find given another different definition, and he didn't give a clear reason and answer about that. Since these two conflicting definition is both widely used in some big projects, (for example, d = Kr = 1 for opaque material is used in 3DS MAX and vcglib, which built meshLab, a good cloud point processing tool project), I give this PR to three.js hoping given a nondiscriminatory treat to them. On the other hand. I do totally agree that this change is not supposed to break the back compatibility. I feel very very sorry to bother your work these days. Because that we had some discussion about how to introduce this feature properly and I made reset-and-recommit three times before it was merged. I used the suggestion given by mrdoob in the final version. Unfortunately, because of my carelessness, I didn't re-check the code here and it do make an inverse effect. Yes, @RSpace , you are right, that code treats the Tr option in the inverse way. I will open a new PR fixing this soon. and I do want to express my apologize of my careless, and I'm truly very very sorry to @mrdoob @WestLangley @RSpace as well as anyone who was confused by my mistake. |
|
@eastpiger Thanks for the clarification. We all make mistakes, and I'm thankful to everyone who contributes to three.js, making it the fantastic library it is today. Your PR #13685 fixes the issue for me :) |
No worries!! 🙌 |
Fixes #12861