Browse Source

MMDLoader: Skip transparency check for CompressedTexture. (#21878)

* CompressedTextureLoader: put first mipmap data into image to simulate ImageData.

* Revert "CompressedTextureLoader: put first mipmap data into image to simulate ImageData."

This reverts commit ceb3cb373aaec8789588f7ebe0e26185f6908ed5.

* MMDLoader: Skip transparency check for CompressedTexture.

* MMDLoader: Improve instance check.
bill42362 4 years ago
parent
commit
0a0c21542c
2 changed files with 31 additions and 1 deletions
  1. 0 0
      examples/js/loaders/MMDLoader.js
  2. 31 1
      examples/jsm/loaders/MMDLoader.js

File diff suppressed because it is too large
+ 0 - 0
examples/js/loaders/MMDLoader.js


+ 31 - 1
examples/jsm/loaders/MMDLoader.js

@@ -28,7 +28,12 @@ import {
 	TextureLoader,
 	Uint16BufferAttribute,
 	Vector3,
-	VectorKeyframeTrack
+	VectorKeyframeTrack,
+	RGB_S3TC_DXT1_Format,
+	RGB_PVRTC_4BPPV1_Format,
+	RGB_PVRTC_2BPPV1_Format,
+	RGB_ETC1_Format,
+	RGB_ETC2_Format
 } from '../../../build/three.module.js';
 import { TGALoader } from '../loaders/TGALoader.js';
 import { MMDParser } from '../libs/mmdparser.module.js';
@@ -365,6 +370,14 @@ const DEFAULT_TOON_TEXTURES = [
 	'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII='
 ];
 
+const NON_ALPHA_CHANNEL_FORMATS = [
+	RGB_S3TC_DXT1_Format,
+	RGB_PVRTC_4BPPV1_Format,
+	RGB_PVRTC_2BPPV1_Format,
+	RGB_ETC1_Format,
+	RGB_ETC2_Format
+];
+
 // Builders. They build Three.js object from Object data parsed by MMDParser.
 
 /**
@@ -1518,6 +1531,23 @@ class MaterialBuilder {
 
 			}
 
+			if ( texture.isCompressedTexture === true ) {
+
+				if ( NON_ALPHA_CHANNEL_FORMATS.includes( texture.format ) ) {
+
+					map.transparent = false;
+
+				} else {
+
+					// any other way to check transparency of CompressedTexture?
+					map.transparent = true;
+
+				}
+
+				return;
+
+			}
+
 			const imageData = texture.image.data !== undefined
 				? texture.image
 				: createImageData( texture.image );

Some files were not shown because too many files changed in this diff