Mr.doob 3 anni fa
parent
commit
d5d5832192
4 ha cambiato i file con 93 aggiunte e 34 eliminazioni
  1. 28 11
      build/three.cjs
  2. 28 11
      build/three.js
  3. 0 0
      build/three.min.js
  4. 37 12
      build/three.module.js

+ 28 - 11
build/three.cjs

@@ -13944,10 +13944,16 @@ function getShaderErrors(gl, shader, type) {
 	const status = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
 	const errors = gl.getShaderInfoLog(shader).trim();
 	if (status && errors === '') return '';
-	const errorLine = parseInt(/ERROR: 0:(\d+)/.exec(errors)[1]); // --enable-privileged-webgl-extension
-	// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );
+	const errorMatches = /ERROR: 0:(\d+)/.exec(errors);
 
-	return type.toUpperCase() + '\n\n' + errors + '\n\n' + handleSource(gl.getShaderSource(shader), errorLine);
+	if (errorMatches) {
+		// --enable-privileged-webgl-extension
+		// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );
+		const errorLine = parseInt(errorMatches[0]);
+		return type.toUpperCase() + '\n\n' + errors + '\n\n' + handleSource(gl.getShaderSource(shader), errorLine);
+	} else {
+		return errors;
+	}
 }
 
 function getTexelEncodingFunction(functionName, encoding) {
@@ -17149,10 +17155,12 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
 				} //
 
 
-				if (useTexStorage && allocateMemory) {
-					state.texStorage2D(_gl.TEXTURE_2D, 1, glInternalFormat, image.width, image.height);
-				} else {
-					state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
+				if (allocateMemory) {
+					if (useTexStorage) {
+						state.texStorage2D(_gl.TEXTURE_2D, 1, glInternalFormat, image.width, image.height);
+					} else {
+						state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
+					}
 				}
 			} else if (texture.isDataTexture) {
 				// use manually created mipmaps if available
@@ -17232,10 +17240,19 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
 					state.texImage3D(_gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
 				}
 			} else if (texture.isFramebufferTexture) {
-				if (useTexStorage && allocateMemory) {
-					state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);
-				} else {
-					state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
+				if (allocateMemory) {
+					if (useTexStorage) {
+						state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);
+					} else {
+						let width = image.width,
+								height = image.height;
+
+						for (let i = 0; i < levels; i++) {
+							state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, width, height, 0, glFormat, glType, null);
+							width >>= 1;
+							height >>= 1;
+						}
+					}
 				}
 			} else {
 				// regular Texture (image, video, canvas)

+ 28 - 11
build/three.js

@@ -13946,10 +13946,16 @@
 		const status = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
 		const errors = gl.getShaderInfoLog(shader).trim();
 		if (status && errors === '') return '';
-		const errorLine = parseInt(/ERROR: 0:(\d+)/.exec(errors)[1]); // --enable-privileged-webgl-extension
-		// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );
+		const errorMatches = /ERROR: 0:(\d+)/.exec(errors);
 
-		return type.toUpperCase() + '\n\n' + errors + '\n\n' + handleSource(gl.getShaderSource(shader), errorLine);
+		if (errorMatches) {
+			// --enable-privileged-webgl-extension
+			// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );
+			const errorLine = parseInt(errorMatches[0]);
+			return type.toUpperCase() + '\n\n' + errors + '\n\n' + handleSource(gl.getShaderSource(shader), errorLine);
+		} else {
+			return errors;
+		}
 	}
 
 	function getTexelEncodingFunction(functionName, encoding) {
@@ -17151,10 +17157,12 @@
 					} //
 
 
-					if (useTexStorage && allocateMemory) {
-						state.texStorage2D(_gl.TEXTURE_2D, 1, glInternalFormat, image.width, image.height);
-					} else {
-						state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
+					if (allocateMemory) {
+						if (useTexStorage) {
+							state.texStorage2D(_gl.TEXTURE_2D, 1, glInternalFormat, image.width, image.height);
+						} else {
+							state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
+						}
 					}
 				} else if (texture.isDataTexture) {
 					// use manually created mipmaps if available
@@ -17234,10 +17242,19 @@
 						state.texImage3D(_gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
 					}
 				} else if (texture.isFramebufferTexture) {
-					if (useTexStorage && allocateMemory) {
-						state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);
-					} else {
-						state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
+					if (allocateMemory) {
+						if (useTexStorage) {
+							state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);
+						} else {
+							let width = image.width,
+									height = image.height;
+
+							for (let i = 0; i < levels; i++) {
+								state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, width, height, 0, glFormat, glType, null);
+								width >>= 1;
+								height >>= 1;
+							}
+						}
 					}
 				} else {
 					// regular Texture (image, video, canvas)

File diff suppressed because it is too large
+ 0 - 0
build/three.min.js


+ 37 - 12
build/three.module.js

@@ -18231,12 +18231,20 @@ function getShaderErrors( gl, shader, type ) {
 
 	if ( status && errors === '' ) return '';
 
-	const errorLine = parseInt( /ERROR: 0:(\d+)/.exec( errors )[ 1 ] );
+	const errorMatches = /ERROR: 0:(\d+)/.exec( errors );
+	if ( errorMatches ) {
 
-	// --enable-privileged-webgl-extension
-	// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );
+		// --enable-privileged-webgl-extension
+		// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );
 
-	return type.toUpperCase() + '\n\n' + errors + '\n\n' + handleSource( gl.getShaderSource( shader ), errorLine );
+		const errorLine = parseInt( errorMatches[ 0 ] );
+		return type.toUpperCase() + '\n\n' + errors + '\n\n' + handleSource( gl.getShaderSource( shader ), errorLine );
+
+	} else {
+
+		return errors;
+
+	}
 
 }
 
@@ -23130,13 +23138,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 				//
 
-				if ( useTexStorage && allocateMemory ) {
+				if ( allocateMemory ) {
 
-					state.texStorage2D( 3553, 1, glInternalFormat, image.width, image.height );
+					if ( useTexStorage ) {
 
-				} else {
+						state.texStorage2D( 3553, 1, glInternalFormat, image.width, image.height );
+
+					} else {
+
+						state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
 
-					state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
+					}
 
 				}
 
@@ -23278,13 +23290,26 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 			} else if ( texture.isFramebufferTexture ) {
 
-				if ( useTexStorage && allocateMemory ) {
+				if ( allocateMemory ) {
 
-					state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height );
+					if ( useTexStorage ) {
 
-				} else {
+						state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height );
+
+					} else {
+
+						let width = image.width, height = image.height;
 
-					state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
+						for ( let i = 0; i < levels; i ++ ) {
+
+							state.texImage2D( 3553, i, glInternalFormat, width, height, 0, glFormat, glType, null );
+
+							width >>= 1;
+							height >>= 1;
+
+						}
+
+					}
 
 				}
 

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