Skip to content

Commit

Permalink
Replaced instanceof Array with Array.isArray(). See #5886.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed May 15, 2015
1 parent 4f53ea6 commit 2665e37
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion editor/js/Viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var Viewport = function ( editor ) {

raycaster.setFromCamera( mouse, camera );

if ( object instanceof Array ) {
if ( Array.isArray( object ) ) {

return raycaster.intersectObjects( object );

Expand Down
4 changes: 2 additions & 2 deletions examples/js/effects/VREffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand Down Expand Up @@ -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 );

Expand Down
16 changes: 8 additions & 8 deletions examples/js/loaders/STLLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ THREE.STLLoader.prototype = {
}, onProgress, onError );

},

parse: function ( data ) {

var isBinary = function () {
Expand All @@ -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,
Expand All @@ -74,9 +74,9 @@ THREE.STLLoader.prototype = {
for ( var index = 0; index < fileLength; index ++ ) {

if ( reader.getUint8(index, false) > 127 ) {

return true;

}

}
Expand Down Expand Up @@ -255,7 +255,7 @@ THREE.STLLoader.prototype = {
} else {
return buf;
}

}

};
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions examples/js/loaders/deprecated/SceneLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 = [];
Expand Down
4 changes: 2 additions & 2 deletions src/core/Face3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down
2 changes: 1 addition & 1 deletion src/core/Raycaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/extras/geometries/ExtrudeGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion src/extras/geometries/ShapeGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion src/loaders/CompressedTextureLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/loaders/ObjectLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] );
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/shaders/UniformsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 2665e37

Please sign in to comment.