MaterialLoader changes transparent to true when alphaMap present
See original GitHub issueDescription of the problem
MaterialLoader changes the loaded material’s transparent property to true
if there is an alphaMap defined. This might be desirable when transparent is undefined so that transparent doesn’t default to false. However, when transparent is explicitly defined as false
in the material JSON, it should probably be recognized as false
by MaterialLoader.
Here is the code from MaterialLoader.js
if ( json.alphaMap !== undefined ) {
material.alphaMap = getTexture( json.alphaMap );
material.transparent = true;
}
The following is a potential solution to this
if ( json.alphaMap !== undefined ) {
material.alphaMap = getTexture( json.alphaMap );
if (json.transparent !== undefined) {
material.transparent = json.transparent;
}
else {
material.transparent = true;
}
}
This example shows why you might want to have transparent = false with an alphaMap. This material uses alphaTest to create sharp edges with the AlphaMap. If transparent = true, the edges start to fade and no longer look clean.
{
"uuid": "9ebca7f1-90b0-49d2-8a87-94a7b381811f","type": "PointsMaterial",
"color": 15728768,
"size": 0.3,
"sizeAttenuation": true,
"alphaMap": "da9f3d50-e5d3-4384-a594-861c5ab02a6d",
"transparent": false,
"alphaTest": 0.5
}
Here is what the fix looks like when I test it. It provides the clean edges that you might want in a data visualization, for instance.
current (transparent=true):
proposed (transparent=false):
Three.js version
- Dev
- r113
Browser
- All of them
OS
- All of them
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Sure I’ll file a PR.
Exactly. If you export and then import, and don’t get what you started with, then something is wrong.
Would you like to file a PR?