Browse Source

Replaced instanceof Array with Array.isArray(). See #5886.

Mr.doob 10 years ago
parent
commit
2665e375bf

+ 1 - 1
editor/js/Viewport.js

@@ -89,7 +89,7 @@ var Viewport = function ( editor ) {
 
 		raycaster.setFromCamera( mouse, camera );
 
-		if ( object instanceof Array ) {
+		if ( Array.isArray( object ) ) {
 
 			return raycaster.intersectObjects( object );
 

+ 2 - 2
examples/js/effects/VREffect.js

@@ -115,7 +115,7 @@ THREE.VREffect = function ( renderer, onError ) {
 
 			var sceneL, sceneR;
 
-			if ( scene instanceof Array ) {
+			if ( Array.isArray( scene ) ) {
 
 				sceneL = scene[ 0 ];
 				sceneR = scene[ 1 ];
@@ -162,7 +162,7 @@ THREE.VREffect = function ( renderer, onError ) {
 
 		// Regular render mode if not HMD
 
-		if ( scene instanceof Array ) scene = scene[ 0 ];
+		if ( Array.isArray( scene ) ) scene = scene[ 0 ];
 
 		renderer.render( scene, camera );
 

+ 8 - 8
examples/js/loaders/STLLoader.js

@@ -51,7 +51,7 @@ THREE.STLLoader.prototype = {
 		}, onProgress, onError );
 
 	},
-	
+
 	parse: function ( data ) {
 
 		var isBinary = function () {
@@ -61,11 +61,11 @@ THREE.STLLoader.prototype = {
 			face_size = (32 / 8 * 3) + ((32 / 8 * 3) * 3) + (16 / 8);
 			n_faces = reader.getUint32(80, true);
 			expect = 80 + (32 / 8) + (n_faces * face_size);
-			
+
 			if ( expect === reader.byteLength ) {
-				
+
 				return true;
-				
+
 			}
 
 			// some binary files will have different size from expected,
@@ -74,9 +74,9 @@ THREE.STLLoader.prototype = {
 			for ( var index = 0; index < fileLength; index ++ ) {
 
 				if ( reader.getUint8(index, false) > 127 ) {
-					
+
 					return true;
-					
+
 				}
 
 			}
@@ -255,7 +255,7 @@ THREE.STLLoader.prototype = {
 		} else {
 			return buf;
 		}
-		
+
 	}
 
 };
@@ -337,7 +337,7 @@ if ( typeof DataView === 'undefined') {
 
 			if (!littleEndian && length > 1) {
 
-				if (!(result instanceof Array)) {
+				if ( Array.isArray( result ) === false ) {
 
 					result = Array.prototype.slice.call(result);
 

+ 2 - 2
examples/js/loaders/deprecated/SceneLoader.js

@@ -887,7 +887,7 @@ THREE.SceneLoader.prototype = {
 
 			textureJSON = data.textures[ textureID ];
 
-			if ( textureJSON.url instanceof Array ) {
+			if ( Array.isArray( textureJSON.url ) ) {
 
 				counter_textures += textureJSON.url.length;
 
@@ -921,7 +921,7 @@ THREE.SceneLoader.prototype = {
 
 			var texture;
 
-			if ( textureJSON.url instanceof Array ) {
+			if ( Array.isArray( textureJSON.url ) ) {
 
 				var count = textureJSON.url.length;
 				var url_array = [];

+ 2 - 2
src/core/Face3.js

@@ -10,10 +10,10 @@ THREE.Face3 = function ( a, b, c, normal, color ) {
 	this.c = c;
 
 	this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
-	this.vertexNormals = normal instanceof Array ? normal : [];
+	this.vertexNormals = Array.isArray( normal ) ? normal : [];
 
 	this.color = color instanceof THREE.Color ? color : new THREE.Color();
-	this.vertexColors = color instanceof Array ? color : [];
+	this.vertexColors = Array.isArray( color ) ? color : [];
 
 	this.vertexTangents = [];
 

+ 1 - 1
src/core/Raycaster.js

@@ -101,7 +101,7 @@
 
 			var intersects = [];
 
-			if ( objects instanceof Array === false ) {
+			if ( Array.isArray( objects ) === false ) {
 
 				console.warn( 'THREE.Raycaster.intersectObjects: objects is not an Array.' );
 				return intersects;

+ 1 - 1
src/extras/geometries/ExtrudeGeometry.js

@@ -33,7 +33,7 @@ THREE.ExtrudeGeometry = function ( shapes, options ) {
 
 	this.type = 'ExtrudeGeometry';
 
-	shapes = shapes instanceof Array ? shapes : [ shapes ];
+	shapes = Array.isArray( shapes ) ? shapes : [ shapes ];
 
 	this.addShapeList( shapes, options );
 

+ 1 - 1
src/extras/geometries/ShapeGeometry.js

@@ -20,7 +20,7 @@ THREE.ShapeGeometry = function ( shapes, options ) {
 
 	this.type = 'ShapeGeometry';
 
-	if ( shapes instanceof Array === false ) shapes = [ shapes ];
+	if ( Array.isArray( shapes ) === false ) shapes = [ shapes ];
 
 	this.addShapeList( shapes, options );
 

+ 1 - 1
src/loaders/CompressedTextureLoader.js

@@ -28,7 +28,7 @@ THREE.CompressedTextureLoader.prototype = {
 		var loader = new THREE.XHRLoader();
 		loader.setResponseType( 'arraybuffer' );
 
-		if ( url instanceof Array ) {
+		if ( Array.isArray( url ) ) {
 
 			var loaded = 0;
 

+ 1 - 1
src/loaders/ObjectLoader.js

@@ -373,7 +373,7 @@ THREE.ObjectLoader.prototype = {
 				if ( data.minFilter !== undefined ) texture.minFilter = parseConstant( data.minFilter );
 				if ( data.magFilter !== undefined ) texture.magFilter = parseConstant( data.magFilter );
 				if ( data.anisotropy !== undefined ) texture.anisotropy = data.anisotropy;
-				if ( data.wrap instanceof Array ) {
+				if ( Array.isArray( data.wrap ) ) {
 
 					texture.wrapS = parseConstant( data.wrap[ 0 ] );
 					texture.wrapT = parseConstant( data.wrap[ 1 ] );

+ 1 - 1
src/renderers/WebGLRenderer.js

@@ -3010,7 +3010,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 					if ( ! texture ) continue;
 
 					if ( texture instanceof THREE.CubeTexture ||
-						 ( texture.image instanceof Array && texture.image.length === 6 ) ) { // CompressedTexture can have Array in image :/
+						 ( Array.isArray( texture.image ) && texture.image.length === 6 ) ) { // CompressedTexture can have Array in image :/
 
 						setCubeTexture( texture, textureUnit );
 

+ 1 - 1
src/renderers/shaders/UniformsUtils.js

@@ -46,7 +46,7 @@ THREE.UniformsUtils = {
 
 					uniforms_dst[ u ][ p ] = parameter_src.clone();
 
-				} else if ( parameter_src instanceof Array ) {
+				} else if ( Array.isArray( parameter_src ) ) {
 
 					uniforms_dst[ u ][ p ] = parameter_src.slice();