Răsfoiți Sursa

Merge pull request #17546 from shrekshao/basis-alpha-support

BasisTextureLoader: ASTC and PVRTC alpha support update
Mr.doob 5 ani în urmă
părinte
comite
c3d5c00a96

+ 1 - 1
examples/js/libs/basis/README.md

@@ -36,7 +36,7 @@ basisLoader.load( 'diffuse.basis', function ( texture ) {
 ```
 ```
 
 
 For further documentation about the Basis compressor and transcoder, refer to
 For further documentation about the Basis compressor and transcoder, refer to
-the [Basis GitHub repository](https://github.com/BinomialLLC/basis_universal). The JavaScript wrapper requires one modification from the version provided in the Basis repository – the declaration on the first line is changed from `var Module` to `Module`, to accomodate lazy initialization in a Web Worker ([details](https://github.com/mrdoob/three.js/issues/16524)).
+the [Basis GitHub repository](https://github.com/BinomialLLC/basis_universal).
 
 
 ## License
 ## License
 
 

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
examples/js/libs/basis/basis_transcoder.js


BIN
examples/js/libs/basis/basis_transcoder.wasm


+ 71 - 55
examples/js/loaders/BasisTextureLoader.js

@@ -4,8 +4,6 @@
  * @author Shrek Shao / https://github.com/shrekshao
  * @author Shrek Shao / https://github.com/shrekshao
  */
  */
 
 
-/* global Module, createBasisModule */
-
 /**
 /**
  * Loader for Basis Universal GPU Texture Codec.
  * Loader for Basis Universal GPU Texture Codec.
  *
  *
@@ -32,6 +30,7 @@ THREE.BasisTextureLoader = function ( manager ) {
 	this.workerSourceURL = '';
 	this.workerSourceURL = '';
 	this.workerConfig = {
 	this.workerConfig = {
 		format: null,
 		format: null,
+		astcSupported: false,
 		etcSupported: false,
 		etcSupported: false,
 		dxtSupported: false,
 		dxtSupported: false,
 		pvrtcSupported: false,
 		pvrtcSupported: false,
@@ -63,22 +62,27 @@ THREE.BasisTextureLoader.prototype = Object.assign( Object.create( THREE.Loader.
 
 
 		var config = this.workerConfig;
 		var config = this.workerConfig;
 
 
+		config.astcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_astc' );
 		config.etcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_etc1' );
 		config.etcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_etc1' );
 		config.dxtSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_s3tc' );
 		config.dxtSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_s3tc' );
 		config.pvrtcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_pvrtc' )
 		config.pvrtcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_pvrtc' )
 			|| !! renderer.extensions.get( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );
 			|| !! renderer.extensions.get( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );
 
 
-		if ( config.etcSupported ) {
+		if ( config.astcSupported ) {
 
 
-			config.format = THREE.BasisTextureLoader.BASIS_FORMAT.cTFETC1;
+			config.format = THREE.BasisTextureLoader.BASIS_FORMAT.cTFASTC_4x4;
 
 
 		} else if ( config.dxtSupported ) {
 		} else if ( config.dxtSupported ) {
 
 
-			config.format = THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC1;
+			config.format = THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC3;
 
 
 		} else if ( config.pvrtcSupported ) {
 		} else if ( config.pvrtcSupported ) {
 
 
-			config.format = THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_OPAQUE_ONLY;
+			config.format = THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA;
+
+		} else if ( config.etcSupported ) {
+
+			config.format = THREE.BasisTextureLoader.BASIS_FORMAT.cTFETC1;
 
 
 		} else {
 		} else {
 
 
@@ -136,25 +140,30 @@ THREE.BasisTextureLoader.prototype = Object.assign( Object.create( THREE.Loader.
 
 
 				var config = this.workerConfig;
 				var config = this.workerConfig;
 
 
-				var { width, height, mipmaps } = message;
+				var { width, height, hasAlpha, mipmaps, format } = message;
 
 
 				var texture;
 				var texture;
 
 
-				if ( config.etcSupported ) {
-
-					texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.RGB_ETC1_Format );
-
-				} else if ( config.dxtSupported ) {
-
-					texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.BasisTextureLoader.DXT_FORMAT_MAP[ config.format ], THREE.UnsignedByteType );
-
-				} else if ( config.pvrtcSupported ) {
-
-					texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.RGB_PVRTC_4BPPV1_Format );
-
-				} else {
-
-					throw new Error( 'THREE.BasisTextureLoader: No supported format available.' );
+				switch ( format ) {
+
+					case THREE.BasisTextureLoader.BASIS_FORMAT.cTFASTC_4x4:
+						texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.RGBA_ASTC_4x4_Format );
+						break;
+					case THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC1:
+					case THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC3:
+						texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.BasisTextureLoader.DXT_FORMAT_MAP[ config.format ], THREE.UnsignedByteType );
+						break;
+					case THREE.BasisTextureLoader.BASIS_FORMAT.cTFETC1:
+						texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.RGB_ETC1_Format );
+						break;
+					case THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB:
+						texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.RGB_PVRTC_4BPPV1_Format );
+						break;
+					case THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA:
+						texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.RGBA_PVRTC_4BPPV1_Format );
+						break;
+					default:
+						throw new Error( 'THREE.BasisTextureLoader: No supported format available.' );
 
 
 				}
 				}
 
 
@@ -214,12 +223,7 @@ THREE.BasisTextureLoader.prototype = Object.assign( Object.create( THREE.Loader.
 
 
 					var body = [
 					var body = [
 						'/* basis_transcoder.js */',
 						'/* basis_transcoder.js */',
-						'var Module;',
-						'function createBasisModule () {',
-						'  ' + jsContent,
-						'  return Module;',
-						'}',
-						'',
+						jsContent,
 						'/* worker */',
 						'/* worker */',
 						fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) )
 						fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) )
 					].join( '\n' );
 					].join( '\n' );
@@ -312,13 +316,22 @@ THREE.BasisTextureLoader.prototype = Object.assign( Object.create( THREE.Loader.
 
 
 THREE.BasisTextureLoader.BASIS_FORMAT = {
 THREE.BasisTextureLoader.BASIS_FORMAT = {
 	cTFETC1: 0,
 	cTFETC1: 0,
-	cTFBC1: 1,
-	cTFBC4: 2,
-	cTFPVRTC1_4_OPAQUE_ONLY: 3,
-	cTFBC7_M6_OPAQUE_ONLY: 4,
-	cTFETC2: 5,
-	cTFBC3: 6,
-	cTFBC5: 7,
+	cTFETC2: 1,
+	cTFBC1: 2,
+	cTFBC3: 3,
+	cTFBC4: 4,
+	cTFBC5: 5,
+	cTFBC7_M6_OPAQUE_ONLY: 6,
+	cTFBC7_M5: 7,
+	cTFPVRTC1_4_RGB: 8,
+	cTFPVRTC1_4_RGBA: 9,
+	cTFASTC_4x4: 10,
+	cTFATC_RGB: 11,
+	cTFATC_RGBA_INTERPOLATED_ALPHA: 12,
+	cTFRGBA32: 13,
+	cTFRGB565: 14,
+	cTFBGR565: 15,
+	cTFRGBA4444: 16,
 };
 };
 
 
 // DXT formats, from:
 // DXT formats, from:
@@ -359,7 +372,7 @@ THREE.BasisTextureLoader.BasisWorker = function () {
 
 
 					try {
 					try {
 
 
-						var { width, height, mipmaps } = transcode( message.buffer );
+						var { width, height, hasAlpha, mipmaps, format } = transcode( message.buffer );
 
 
 						var buffers = [];
 						var buffers = [];
 
 
@@ -369,7 +382,7 @@ THREE.BasisTextureLoader.BasisWorker = function () {
 
 
 						}
 						}
 
 
-						self.postMessage( { type: 'transcode', id: message.id, width, height, mipmaps }, buffers );
+						self.postMessage( { type: 'transcode', id: message.id, width, height, hasAlpha, mipmaps, format }, buffers );
 
 
 					} catch ( error ) {
 					} catch ( error ) {
 
 
@@ -388,19 +401,15 @@ THREE.BasisTextureLoader.BasisWorker = function () {
 
 
 	function init( wasmBinary ) {
 	function init( wasmBinary ) {
 
 
+		var BasisModule;
 		transcoderPending = new Promise( ( resolve ) => {
 		transcoderPending = new Promise( ( resolve ) => {
 
 
-			// The 'Module' global is used by the Basis wrapper, which will check for
-			// the 'wasmBinary' property before trying to load the file itself.
-
-			// TODO(donmccurdy): This only works with a modified version of the
-			// emscripten-generated wrapper. The default seems to have a bug making it
-			// impossible to override the WASM binary.
-			Module = { wasmBinary, onRuntimeInitialized: resolve };
+			BasisModule = { wasmBinary, onRuntimeInitialized: resolve };
+			BASIS( BasisModule );
 
 
 		} ).then( () => {
 		} ).then( () => {
 
 
-			var { BasisFile, initializeBasis } = Module;
+			var { BasisFile, initializeBasis } = BasisModule;
 
 
 			_BasisFile = BasisFile;
 			_BasisFile = BasisFile;
 
 
@@ -408,8 +417,6 @@ THREE.BasisTextureLoader.BasisWorker = function () {
 
 
 		} );
 		} );
 
 
-		createBasisModule();
-
 	}
 	}
 
 
 	function transcode( buffer ) {
 	function transcode( buffer ) {
@@ -419,6 +426,7 @@ THREE.BasisTextureLoader.BasisWorker = function () {
 		var width = basisFile.getImageWidth( 0, 0 );
 		var width = basisFile.getImageWidth( 0, 0 );
 		var height = basisFile.getImageHeight( 0, 0 );
 		var height = basisFile.getImageHeight( 0, 0 );
 		var levels = basisFile.getNumLevels( 0 );
 		var levels = basisFile.getNumLevels( 0 );
+		var hasAlpha = basisFile.getHasAlpha();
 
 
 		function cleanup() {
 		function cleanup() {
 
 
@@ -427,6 +435,20 @@ THREE.BasisTextureLoader.BasisWorker = function () {
 
 
 		}
 		}
 
 
+		if ( ! hasAlpha ) {
+
+			switch ( config.format ) {
+
+				case 9: // Hardcoded: THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA
+					config.format = 8; // Hardcoded: THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB;
+					break;
+				default:
+					break;
+
+			}
+
+		}
+
 		if ( ! width || ! height || ! levels ) {
 		if ( ! width || ! height || ! levels ) {
 
 
 			cleanup();
 			cleanup();
@@ -441,12 +463,6 @@ THREE.BasisTextureLoader.BasisWorker = function () {
 
 
 		}
 		}
 
 
-		if ( basisFile.getHasAlpha() ) {
-
-			console.warn( 'THREE.BasisTextureLoader: Alpha not yet implemented.' );
-
-		}
-
 		var mipmaps = [];
 		var mipmaps = [];
 
 
 		for ( var mip = 0; mip < levels; mip ++ ) {
 		for ( var mip = 0; mip < levels; mip ++ ) {
@@ -460,7 +476,7 @@ THREE.BasisTextureLoader.BasisWorker = function () {
 				0,
 				0,
 				mip,
 				mip,
 				config.format,
 				config.format,
-				config.etcSupported ? 0 : ( config.dxtSupported ? 1 : 0 ),
+				hasAlpha,
 				0
 				0
 			);
 			);
 
 
@@ -477,7 +493,7 @@ THREE.BasisTextureLoader.BasisWorker = function () {
 
 
 		cleanup();
 		cleanup();
 
 
-		return { width, height, mipmaps };
+		return { width, height, hasAlpha, mipmaps, format: config.format };
 
 
 	}
 	}
 
 

+ 1 - 0
examples/jsm/loaders/BasisTextureLoader.d.ts

@@ -14,6 +14,7 @@ export class BasisTextureLoader extends Loader {
 
 
 	workerConfig: {
 	workerConfig: {
 		format: number;
 		format: number;
+		astcSupported: boolean;
 		etcSupported: boolean;
 		etcSupported: boolean;
 		dxtSupported: boolean;
 		dxtSupported: boolean;
 		pvrtcSupported: boolean;
 		pvrtcSupported: boolean;

+ 73 - 55
examples/jsm/loaders/BasisTextureLoader.js

@@ -10,13 +10,13 @@ import {
 	LinearFilter,
 	LinearFilter,
 	LinearMipmapLinearFilter,
 	LinearMipmapLinearFilter,
 	Loader,
 	Loader,
+	RGBA_ASTC_4x4_Format,
+	RGBA_PVRTC_4BPPV1_Format,
 	RGB_ETC1_Format,
 	RGB_ETC1_Format,
 	RGB_PVRTC_4BPPV1_Format,
 	RGB_PVRTC_4BPPV1_Format,
 	UnsignedByteType
 	UnsignedByteType
 } from "../../../build/three.module.js";
 } from "../../../build/three.module.js";
 
 
-/* global Module, createBasisModule */
-
 /**
 /**
  * Loader for Basis Universal GPU Texture Codec.
  * Loader for Basis Universal GPU Texture Codec.
  *
  *
@@ -43,6 +43,7 @@ var BasisTextureLoader = function ( manager ) {
 	this.workerSourceURL = '';
 	this.workerSourceURL = '';
 	this.workerConfig = {
 	this.workerConfig = {
 		format: null,
 		format: null,
+		astcSupported: false,
 		etcSupported: false,
 		etcSupported: false,
 		dxtSupported: false,
 		dxtSupported: false,
 		pvrtcSupported: false,
 		pvrtcSupported: false,
@@ -74,22 +75,27 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 
 		var config = this.workerConfig;
 		var config = this.workerConfig;
 
 
+		config.astcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_astc' );
 		config.etcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_etc1' );
 		config.etcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_etc1' );
 		config.dxtSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_s3tc' );
 		config.dxtSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_s3tc' );
 		config.pvrtcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_pvrtc' )
 		config.pvrtcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_pvrtc' )
 			|| !! renderer.extensions.get( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );
 			|| !! renderer.extensions.get( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );
 
 
-		if ( config.etcSupported ) {
+		if ( config.astcSupported ) {
 
 
-			config.format = BasisTextureLoader.BASIS_FORMAT.cTFETC1;
+			config.format = BasisTextureLoader.BASIS_FORMAT.cTFASTC_4x4;
 
 
 		} else if ( config.dxtSupported ) {
 		} else if ( config.dxtSupported ) {
 
 
-			config.format = BasisTextureLoader.BASIS_FORMAT.cTFBC1;
+			config.format = BasisTextureLoader.BASIS_FORMAT.cTFBC3;
 
 
 		} else if ( config.pvrtcSupported ) {
 		} else if ( config.pvrtcSupported ) {
 
 
-			config.format = BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_OPAQUE_ONLY;
+			config.format = BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA;
+
+		} else if ( config.etcSupported ) {
+
+			config.format = BasisTextureLoader.BASIS_FORMAT.cTFETC1;
 
 
 		} else {
 		} else {
 
 
@@ -147,25 +153,30 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 
 				var config = this.workerConfig;
 				var config = this.workerConfig;
 
 
-				var { width, height, mipmaps } = message;
+				var { width, height, hasAlpha, mipmaps, format } = message;
 
 
 				var texture;
 				var texture;
 
 
-				if ( config.etcSupported ) {
-
-					texture = new CompressedTexture( mipmaps, width, height, RGB_ETC1_Format );
-
-				} else if ( config.dxtSupported ) {
-
-					texture = new CompressedTexture( mipmaps, width, height, BasisTextureLoader.DXT_FORMAT_MAP[ config.format ], UnsignedByteType );
-
-				} else if ( config.pvrtcSupported ) {
-
-					texture = new CompressedTexture( mipmaps, width, height, RGB_PVRTC_4BPPV1_Format );
-
-				} else {
-
-					throw new Error( 'THREE.BasisTextureLoader: No supported format available.' );
+				switch ( format ) {
+
+					case BasisTextureLoader.BASIS_FORMAT.cTFASTC_4x4:
+						texture = new CompressedTexture( mipmaps, width, height, RGBA_ASTC_4x4_Format );
+						break;
+					case BasisTextureLoader.BASIS_FORMAT.cTFBC1:
+					case BasisTextureLoader.BASIS_FORMAT.cTFBC3:
+						texture = new CompressedTexture( mipmaps, width, height, BasisTextureLoader.DXT_FORMAT_MAP[ config.format ], UnsignedByteType );
+						break;
+					case BasisTextureLoader.BASIS_FORMAT.cTFETC1:
+						texture = new CompressedTexture( mipmaps, width, height, RGB_ETC1_Format );
+						break;
+					case BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB:
+						texture = new CompressedTexture( mipmaps, width, height, RGB_PVRTC_4BPPV1_Format );
+						break;
+					case BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA:
+						texture = new CompressedTexture( mipmaps, width, height, RGBA_PVRTC_4BPPV1_Format );
+						break;
+					default:
+						throw new Error( 'THREE.BasisTextureLoader: No supported format available.' );
 
 
 				}
 				}
 
 
@@ -225,12 +236,7 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 
 					var body = [
 					var body = [
 						'/* basis_transcoder.js */',
 						'/* basis_transcoder.js */',
-						'var Module;',
-						'function createBasisModule () {',
-						'  ' + jsContent,
-						'  return Module;',
-						'}',
-						'',
+						jsContent,
 						'/* worker */',
 						'/* worker */',
 						fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) )
 						fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) )
 					].join( '\n' );
 					].join( '\n' );
@@ -323,13 +329,22 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 
 BasisTextureLoader.BASIS_FORMAT = {
 BasisTextureLoader.BASIS_FORMAT = {
 	cTFETC1: 0,
 	cTFETC1: 0,
-	cTFBC1: 1,
-	cTFBC4: 2,
-	cTFPVRTC1_4_OPAQUE_ONLY: 3,
-	cTFBC7_M6_OPAQUE_ONLY: 4,
-	cTFETC2: 5,
-	cTFBC3: 6,
-	cTFBC5: 7,
+	cTFETC2: 1,
+	cTFBC1: 2,
+	cTFBC3: 3,
+	cTFBC4: 4,
+	cTFBC5: 5,
+	cTFBC7_M6_OPAQUE_ONLY: 6,
+	cTFBC7_M5: 7,
+	cTFPVRTC1_4_RGB: 8,
+	cTFPVRTC1_4_RGBA: 9,
+	cTFASTC_4x4: 10,
+	cTFATC_RGB: 11,
+	cTFATC_RGBA_INTERPOLATED_ALPHA: 12,
+	cTFRGBA32: 13,
+	cTFRGB565: 14,
+	cTFBGR565: 15,
+	cTFRGBA4444: 16,
 };
 };
 
 
 // DXT formats, from:
 // DXT formats, from:
@@ -370,7 +385,7 @@ BasisTextureLoader.BasisWorker = function () {
 
 
 					try {
 					try {
 
 
-						var { width, height, mipmaps } = transcode( message.buffer );
+						var { width, height, hasAlpha, mipmaps, format } = transcode( message.buffer );
 
 
 						var buffers = [];
 						var buffers = [];
 
 
@@ -380,7 +395,7 @@ BasisTextureLoader.BasisWorker = function () {
 
 
 						}
 						}
 
 
-						self.postMessage( { type: 'transcode', id: message.id, width, height, mipmaps }, buffers );
+						self.postMessage( { type: 'transcode', id: message.id, width, height, hasAlpha, mipmaps, format }, buffers );
 
 
 					} catch ( error ) {
 					} catch ( error ) {
 
 
@@ -399,19 +414,15 @@ BasisTextureLoader.BasisWorker = function () {
 
 
 	function init( wasmBinary ) {
 	function init( wasmBinary ) {
 
 
+		var BasisModule;
 		transcoderPending = new Promise( ( resolve ) => {
 		transcoderPending = new Promise( ( resolve ) => {
 
 
-			// The 'Module' global is used by the Basis wrapper, which will check for
-			// the 'wasmBinary' property before trying to load the file itself.
-
-			// TODO(donmccurdy): This only works with a modified version of the
-			// emscripten-generated wrapper. The default seems to have a bug making it
-			// impossible to override the WASM binary.
-			Module = { wasmBinary, onRuntimeInitialized: resolve };
+			BasisModule = { wasmBinary, onRuntimeInitialized: resolve };
+			BASIS( BasisModule );
 
 
 		} ).then( () => {
 		} ).then( () => {
 
 
-			var { BasisFile, initializeBasis } = Module;
+			var { BasisFile, initializeBasis } = BasisModule;
 
 
 			_BasisFile = BasisFile;
 			_BasisFile = BasisFile;
 
 
@@ -419,8 +430,6 @@ BasisTextureLoader.BasisWorker = function () {
 
 
 		} );
 		} );
 
 
-		createBasisModule();
-
 	}
 	}
 
 
 	function transcode( buffer ) {
 	function transcode( buffer ) {
@@ -430,6 +439,7 @@ BasisTextureLoader.BasisWorker = function () {
 		var width = basisFile.getImageWidth( 0, 0 );
 		var width = basisFile.getImageWidth( 0, 0 );
 		var height = basisFile.getImageHeight( 0, 0 );
 		var height = basisFile.getImageHeight( 0, 0 );
 		var levels = basisFile.getNumLevels( 0 );
 		var levels = basisFile.getNumLevels( 0 );
+		var hasAlpha = basisFile.getHasAlpha();
 
 
 		function cleanup() {
 		function cleanup() {
 
 
@@ -438,6 +448,20 @@ BasisTextureLoader.BasisWorker = function () {
 
 
 		}
 		}
 
 
+		if ( ! hasAlpha ) {
+
+			switch ( config.format ) {
+
+				case 9: // Hardcoded: BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA
+					config.format = 8; // Hardcoded: BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB;
+					break;
+				default:
+					break;
+
+			}
+
+		}
+
 		if ( ! width || ! height || ! levels ) {
 		if ( ! width || ! height || ! levels ) {
 
 
 			cleanup();
 			cleanup();
@@ -452,12 +476,6 @@ BasisTextureLoader.BasisWorker = function () {
 
 
 		}
 		}
 
 
-		if ( basisFile.getHasAlpha() ) {
-
-			console.warn( 'THREE.BasisTextureLoader: Alpha not yet implemented.' );
-
-		}
-
 		var mipmaps = [];
 		var mipmaps = [];
 
 
 		for ( var mip = 0; mip < levels; mip ++ ) {
 		for ( var mip = 0; mip < levels; mip ++ ) {
@@ -471,7 +489,7 @@ BasisTextureLoader.BasisWorker = function () {
 				0,
 				0,
 				mip,
 				mip,
 				config.format,
 				config.format,
-				config.etcSupported ? 0 : ( config.dxtSupported ? 1 : 0 ),
+				hasAlpha,
 				0
 				0
 			);
 			);
 
 
@@ -488,7 +506,7 @@ BasisTextureLoader.BasisWorker = function () {
 
 
 		cleanup();
 		cleanup();
 
 
-		return { width, height, mipmaps };
+		return { width, height, hasAlpha, mipmaps, format: config.format };
 
 
 	}
 	}
 
 

+ 0 - 1
examples/webgl_loader_texture_basis.html

@@ -51,7 +51,6 @@
 				var loader = new BasisTextureLoader();
 				var loader = new BasisTextureLoader();
 				loader.setTranscoderPath( 'js/libs/basis/' );
 				loader.setTranscoderPath( 'js/libs/basis/' );
 				loader.detectSupport( renderer );
 				loader.detectSupport( renderer );
-
 				loader.load( 'textures/compressed/PavingStones.basis', function ( texture ) {
 				loader.load( 'textures/compressed/PavingStones.basis', function ( texture ) {
 
 
 					texture.encoding = THREE.sRGBEncoding;
 					texture.encoding = THREE.sRGBEncoding;

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff