Material: transparent=true has no effect on glTF materials (since r132)
See original GitHub issueWith Three.js r132 I can no longer make my models transparent. I export Models in Blender (2.92.0) as .glb file. I then import via GLTFLoader and set the opacity in JavaScript. I am also unable to make the object transparent using the three.js editor (drag and drop .glb in the editor).
Steps to reproduce the behavior:
- Export “Blender cube” as .glb file
- Load the .glb via GLTFLoader
- Set opacity/transparency on the MeshStandardMaterial
(expect that model ist transparent)
Code
new GLTFLoader().load("cube.glb", (gltf) => {
const cube = gltf.scene.getObjectByName("Cube");
if (
cube instanceof THREE.Mesh &&
cube.material instanceof THREE.MeshStandardMaterial
) {
scene.add(cube);
cube.material.opacity = 0.5;
cube.material.color.set("#0000ff");
cube.material.transparent = true;
cube.material.depthWrite = false;
cube.material.side = THREE.FrontSide;
}
});
Expected behavior
With r131, the sample project looks like this:
https://codesandbox.io/s/threejs-transparency-r131-rth6g
Screenshots
With r132, the sample project looks like this:
https://codesandbox.io/s/threejs-transparency-r132-1hs0v
Platform:
- Device: Desktop
- OS: MacOS
- Browser: Chrome
- Three.js version: r132.2
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:19 (3 by maintainers)
Top Results From Across the Web
Materials not rendering when using GLTFLoader - three.js forum
Using an online renderer (gltf-viewer.donmccurdy.com) to test my model and materials has no effect as the materials are not displayed.
Read more >Three js glTF imported model's material contains unexpected ...
The property material.format was a temporary change in a few versions of three.js, and has been removed in three.js r137.
Read more >How to export glTF file with Transparent Textures from Blender
In this blender tutorial, we take a look at how to export a GLTF file with texture transparency.Software and/or plugins used in this ......
Read more >Understanding how Materials work with glTF models - YouTube
Any questions? Join us in discord: https://discord.com/invite/dFJncWwHunNote: The beginning of this stream is missing audio, but it kicks in ...
Read more >How to fix missing materials and textures when exporting a ...
In short, if your glTF files exported from Blender don't have textures… ... house had a material assigned, but the material had no...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In the latest version you may also need to set
material.format = THREE.RGBAFormat
to enable transparency. I’m not sure whether that change will remain in future versions though, see https://github.com/mrdoob/three.js/pull/22428#issuecomment-911819793.to summarise
material.transparent
: Boolean // master transparency control BUT_alphaTest
will still work if this is falsematerial.opacity
: Float 0-1 // Only works if material.format=THREE.RGBAFormatmaterial.alphaMap
: greyscale opacity map // works ifmaterial.transparent=true
&material.format
isTHREE.RGBAFormat
NOTE: GLTF exporter does not export this channel & USDZ exporter does.Alpha channel of
material.map
// ( transparent png image) will work ifmaterial.transparent=true
&material.format
is irrelevant herematerial.format
:THREE.format
// IsTHREE.RGBFormat
for imported gltf files and isTHREE.RGBAFormat
when a newTHREE.MeshStandardMaterial
is created .material._alphaTest
: Float 0-1 // clips the transparent part before this threshold value. Side note: this wasmaterial.alphaTest
before now itsmaterial._alphaTest
but usingmatrial.alphaTest
still worksis this correct ?