Browse Source

Updated examples builds.

Mr.doob 3 years ago
parent
commit
127064586e

+ 0 - 2
examples/js/loaders/HDRCubeTextureLoader.js

@@ -30,7 +30,6 @@
 
 				case THREE.FloatType:
 					texture.encoding = THREE.LinearEncoding;
-					texture.format = THREE.RGBFormat;
 					texture.minFilter = THREE.LinearFilter;
 					texture.magFilter = THREE.LinearFilter;
 					texture.generateMipmaps = false;
@@ -38,7 +37,6 @@
 
 				case THREE.HalfFloatType:
 					texture.encoding = THREE.LinearEncoding;
-					texture.format = THREE.RGBFormat;
 					texture.minFilter = THREE.LinearFilter;
 					texture.magFilter = THREE.LinearFilter;
 					texture.generateMipmaps = false;

+ 3 - 4
examples/js/loaders/LUTCubeLoader.js

@@ -62,7 +62,7 @@
 						// more precision than can be captured with Uint8Array.
 						const sizeToken = split[ 1 ];
 						size = parseFloat( sizeToken );
-						data = new Uint8Array( size * size * size * 3 );
+						data = new Uint8Array( size * size * size * 4 );
 						break;
 
 					case 'DOMAIN_MIN':
@@ -91,7 +91,8 @@
 						data[ currIndex + 0 ] = r * 255;
 						data[ currIndex + 1 ] = g * 255;
 						data[ currIndex + 2 ] = b * 255;
-						currIndex += 3;
+						data[ currIndex + 3 ] = 255;
+						currIndex += 4;
 
 				}
 
@@ -101,7 +102,6 @@
 			texture.image.data = data;
 			texture.image.width = size;
 			texture.image.height = size * size;
-			texture.format = THREE.RGBFormat;
 			texture.type = THREE.UnsignedByteType;
 			texture.magFilter = THREE.LinearFilter;
 			texture.minFilter = THREE.LinearFilter;
@@ -114,7 +114,6 @@
 			texture3D.image.width = size;
 			texture3D.image.height = size;
 			texture3D.image.depth = size;
-			texture3D.format = THREE.RGBFormat;
 			texture3D.type = THREE.UnsignedByteType;
 			texture3D.magFilter = THREE.LinearFilter;
 			texture3D.minFilter = THREE.LinearFilter;

+ 6 - 6
examples/js/loaders/RGBELoader.js

@@ -343,6 +343,7 @@
 				destArray[ destOffset + 0 ] = sourceArray[ sourceOffset + 0 ] * scale;
 				destArray[ destOffset + 1 ] = sourceArray[ sourceOffset + 1 ] * scale;
 				destArray[ destOffset + 2 ] = sourceArray[ sourceOffset + 2 ] * scale;
+				destArray[ destOffset + 3 ] = 1;
 
 			};
 
@@ -354,6 +355,7 @@
 				destArray[ destOffset + 0 ] = THREE.DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 0 ] * scale, 65504 ) );
 				destArray[ destOffset + 1 ] = THREE.DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 1 ] * scale, 65504 ) );
 				destArray[ destOffset + 2 ] = THREE.DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 2 ] * scale, 65504 ) );
+				destArray[ destOffset + 3 ] = THREE.DataUtils.toHalfFloat( 1 );
 
 			};
 
@@ -376,31 +378,29 @@
 
 						case THREE.FloatType:
 							numElements = image_rgba_data.length / 4;
-							const floatArray = new Float32Array( numElements * 3 );
+							const floatArray = new Float32Array( numElements * 4 );
 
 							for ( let j = 0; j < numElements; j ++ ) {
 
-								RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 3 );
+								RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 4 );
 
 							}
 
 							data = floatArray;
-							format = THREE.RGBFormat;
 							type = THREE.FloatType;
 							break;
 
 						case THREE.HalfFloatType:
 							numElements = image_rgba_data.length / 4;
-							const halfArray = new Uint16Array( numElements * 3 );
+							const halfArray = new Uint16Array( numElements * 4 );
 
 							for ( let j = 0; j < numElements; j ++ ) {
 
-								RGBEByteToRGBHalf( image_rgba_data, j * 4, halfArray, j * 3 );
+								RGBEByteToRGBHalf( image_rgba_data, j * 4, halfArray, j * 4 );
 
 							}
 
 							data = halfArray;
-							format = THREE.RGBFormat;
 							type = THREE.HalfFloatType;
 							break;
 

+ 9 - 21
examples/js/loaders/VRMLLoader.js

@@ -1166,6 +1166,7 @@
 						color.r = value;
 						color.g = value;
 						color.b = value;
+						color.a = 1;
 						break;
 
 					case TEXTURE_TYPE.INTENSITY_ALPHA:
@@ -1182,6 +1183,7 @@
 						color.r = parseInt( '0x' + hex.substring( 2, 4 ) );
 						color.g = parseInt( '0x' + hex.substring( 4, 6 ) );
 						color.b = parseInt( '0x' + hex.substring( 6, 8 ) );
+						color.a = 1;
 						break;
 
 					case TEXTURE_TYPE.RGBA:
@@ -1247,10 +1249,8 @@
 							const width = fieldValues[ 0 ];
 							const height = fieldValues[ 1 ];
 							const num_components = fieldValues[ 2 ];
-							const useAlpha = num_components === 2 || num_components === 4;
 							const textureType = getTextureType( num_components );
-							const size = ( useAlpha === true ? 4 : 3 ) * ( width * height );
-							const data = new Uint8Array( size );
+							const data = new Uint8Array( 4 * width * height );
 							const color = {
 								r: 0,
 								g: 0,
@@ -1261,27 +1261,15 @@
 							for ( let j = 3, k = 0, jl = fieldValues.length; j < jl; j ++, k ++ ) {
 
 								parseHexColor( fieldValues[ j ], textureType, color );
-
-								if ( useAlpha === true ) {
-
-									const stride = k * 4;
-									data[ stride + 0 ] = color.r;
-									data[ stride + 1 ] = color.g;
-									data[ stride + 2 ] = color.b;
-									data[ stride + 3 ] = color.a;
-
-								} else {
-
-									const stride = k * 3;
-									data[ stride + 0 ] = color.r;
-									data[ stride + 1 ] = color.g;
-									data[ stride + 2 ] = color.b;
-
-								}
+								const stride = k * 4;
+								data[ stride + 0 ] = color.r;
+								data[ stride + 1 ] = color.g;
+								data[ stride + 2 ] = color.b;
+								data[ stride + 3 ] = color.a;
 
 							}
 
-							texture = new THREE.DataTexture( data, width, height, useAlpha === true ? THREE.RGBAFormat : THREE.RGBFormat );
+							texture = new THREE.DataTexture( data, width, height );
 							texture.needsUpdate = true;
 							texture.__type = textureType; // needed for material modifications