Pārlūkot izejas kodu

use arguments variable to simplify ThreeJS error/warning handlers per @mrdoob's comments here: https://github.com/mrdoob/three.js/pull/5791#issuecomment-67733222

Ben Houston 10 gadi atpakaļ
vecāks
revīzija
71944ab20f

+ 8 - 11
src/Three.js

@@ -25,25 +25,22 @@ if ( Math.sign === undefined ) {
 }
 
 
-THREE.ExceptionErrorHandler = function( message, optionalData ) {
-	console.error( message );
-	if( optionalData ) console.error( optionalData );
+THREE.ExceptionErrorHandler = function( message ) {
+	console.error( arguments );
 	var error = new Error( message );
-	error.optionalData = optionalData;
+	error.optionalData = arguments;
 	throw error;
 };
 
-THREE.ConsoleErrorHandler = function( message, optionalData ) {
-	console.error( message );
-	if( optionalData ) console.error( optionalData );
+THREE.ConsoleErrorHandler = function() {
+	console.error( arguments );
 };
 
-THREE.ConsoleWarningHandler = function( message, optionalData ) {
-	console.warn( message );
-	if( optionalData ) console.warn( optionalData );
+THREE.ConsoleWarningHandler = function() {
+	console.warn( arguments );
 };
 
-THREE.NullHandler = function( message, optionalData ) {
+THREE.NullHandler = function() {
 };
 
 // set the default error handlers

+ 2 - 2
src/core/Object3D.js

@@ -314,7 +314,7 @@ THREE.Object3D.prototype = {
 
 		if ( object === this ) {
 
-			THREE.error( "THREE.Object3D.add:", object, "can't be added as a child of itself." );
+			THREE.error( "THREE.Object3D.add: object can't be added as a child of itself.", object );
 			return this;
 
 		}
@@ -334,7 +334,7 @@ THREE.Object3D.prototype = {
 
 		} else {
 
-			THREE.error( "THREE.Object3D.add:", object, "is not an instance of THREE.Object3D." );
+			THREE.error( "THREE.Object3D.add: object not an instance of THREE.Object3D.", object );
 
 		}
 

+ 1 - 1
src/renderers/WebGLRenderer.js

@@ -5821,7 +5821,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			var context = canvas.getContext( '2d' );
 			context.drawImage( image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height );
 
-			THREE.warning( 'THREE.WebGLRenderer:' + image + 'is too big (' + image.width + 'x' + image.height + '). Resized to ' + canvas.width + 'x' + canvas.height + '.' );
+			THREE.warning( 'THREE.WebGLRenderer: image is too big (' + image.width + 'x' + image.height + '). Resized to ' + canvas.width + 'x' + canvas.height, image );
 
 			return canvas;
 

+ 2 - 5
src/renderers/webgl/WebGLProgram.js

@@ -338,16 +338,13 @@ THREE.WebGLProgram = ( function () {
 
 		if ( _gl.getProgramParameter( program, _gl.LINK_STATUS ) === false ) {
 
-			THREE.error( 'THREE.WebGLProgram: shader error: ' + _gl.getError(), {
-				'gl.VALIDATE_STATUS': _gl.getProgramParameter( program, _gl.VALIDATE_STATUS ),
-				'gl.getPRogramInfoLog': programLogInfo
-			});
+			THREE.error( 'THREE.WebGLProgram: shader error: ' + _gl.getError(), 'gl.VALIDATE_STATUS', _gl.getProgramParameter( program, _gl.VALIDATE_STATUS ), 'gl.getPRogramInfoLog', programLogInfo );
 
 		}
 		
 		if ( programLogInfo !== '' ) {
 
-			THREE.warning( 'THREE.WebGLProgram: gl.getProgramInfoLog()', programLogInfo );
+			THREE.warning( 'THREE.WebGLProgram: gl.getProgramInfoLog()' + programLogInfo );
 			// THREE.warning( _gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( glVertexShader ) );
 			// THREE.warning( _gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( glFragmentShader ) );
 

+ 1 - 2
src/renderers/webgl/WebGLShader.js

@@ -29,8 +29,7 @@ THREE.WebGLShader = ( function () {
 
 		if ( gl.getShaderInfoLog( shader ) !== '' ) {
 
-			THREE.warning( 'THREE.WebGLShader: gl.getShaderInfoLog()', gl.getShaderInfoLog( shader ) );
-			THREE.warning( addLineNumbers( string ) );
+			THREE.warning( 'THREE.WebGLShader: gl.getShaderInfoLog()', gl.getShaderInfoLog( shader ), addLineNumbers( string ) );
 
 		}