From 611efcba7f500b009ff0c223c050f29cd3910ee4 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Tue, 17 Nov 2015 16:32:07 -0500 Subject: [PATCH] jslint/jshint fixes --- editor/js/Menubar.File.js | 20 ++++++++++++++++---- examples/js/renderers/CanvasRenderer.js | 8 ++++---- src/audio/Audio.js | 6 ++++-- src/audio/AudioBuffer.js | 2 +- src/audio/AudioListener.js | 2 +- src/audio/PositionalAudio.js | 2 -- src/cameras/OrthographicCamera.js | 10 +++++----- src/cameras/PerspectiveCamera.js | 10 +++++----- src/core/BufferGeometry.js | 20 ++++++++++---------- src/core/Geometry.js | 2 +- 10 files changed, 47 insertions(+), 35 deletions(-) diff --git a/editor/js/Menubar.File.js b/editor/js/Menubar.File.js index 30c4a693a3..7b448c9479 100644 --- a/editor/js/Menubar.File.js +++ b/editor/js/Menubar.File.js @@ -88,10 +88,14 @@ Menubar.File = function ( editor ) { var output = geometry.toJSON(); try { + output = JSON.stringify( output, null, '\t' ); output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' ); + } catch ( e ) { + output = JSON.stringify( output ); + } exportString( output, 'geometry.json' ); @@ -118,10 +122,14 @@ Menubar.File = function ( editor ) { var output = object.toJSON(); try { + output = JSON.stringify( output, null, '\t' ); output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' ); + } catch ( e ) { + output = JSON.stringify( output ); + } exportString( output, 'model.json' ); @@ -139,10 +147,14 @@ Menubar.File = function ( editor ) { var output = editor.scene.toJSON(); try { + output = JSON.stringify( output, null, '\t' ); output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' ); + } catch ( e ) { + output = JSON.stringify( output ); + } exportString( output, 'scene.json' ); @@ -294,12 +306,12 @@ Menubar.File = function ( editor ) { link.download = filename || 'data.json'; link.target = '_blank'; - var event = document.createEvent("MouseEvents"); + var event = document.createEvent( 'MouseEvents' ); event.initMouseEvent( - "click", true, false, window, 0, 0, 0, 0, 0 - , false, false, false, false, 0, null + 'click', true, false, window, 0, 0, 0, 0, 0, + false, false, false, false, 0, null ); - link.dispatchEvent(event); + link.dispatchEvent( event ); }; diff --git a/examples/js/renderers/CanvasRenderer.js b/examples/js/renderers/CanvasRenderer.js index 71d575071e..b5e7f93e82 100644 --- a/examples/js/renderers/CanvasRenderer.js +++ b/examples/js/renderers/CanvasRenderer.js @@ -116,7 +116,7 @@ THREE.CanvasRenderer = function ( parameters ) { if ( _context.setLineDash === undefined ) { - _context.setLineDash = function () {} + _context.setLineDash = function () {}; } @@ -821,7 +821,7 @@ THREE.CanvasRenderer = function ( parameters ) { return { canvas: undefined, version: texture.version - } + }; } @@ -832,7 +832,7 @@ THREE.CanvasRenderer = function ( parameters ) { return { canvas: undefined, version: 0 - } + }; } @@ -866,7 +866,7 @@ THREE.CanvasRenderer = function ( parameters ) { return { canvas: _context.createPattern( canvas, repeat ), version: texture.version - } + }; } diff --git a/src/audio/Audio.js b/src/audio/Audio.js index 9e53aa463a..521bb69ea9 100644 --- a/src/audio/Audio.js +++ b/src/audio/Audio.js @@ -62,11 +62,13 @@ THREE.Audio.prototype.setBuffer = function ( audioBuffer ) { var scope = this; - audioBuffer.onReady(function(buffer) { + audioBuffer.onReady( function( buffer ) { + scope.source.buffer = buffer; scope.sourceType = 'buffer'; if ( scope.autoplay ) scope.play(); - }); + + } ); return this; diff --git a/src/audio/AudioBuffer.js b/src/audio/AudioBuffer.js index 53fb940ffa..c280ec6995 100644 --- a/src/audio/AudioBuffer.js +++ b/src/audio/AudioBuffer.js @@ -26,7 +26,7 @@ THREE.AudioBuffer.prototype.load = function ( file ) { for ( var i = 0; i < scope.readyCallbacks.length; i ++ ) { - scope.readyCallbacks[i](scope.buffer); + scope.readyCallbacks[ i ]( scope.buffer ); } diff --git a/src/audio/AudioListener.js b/src/audio/AudioListener.js index 50142a985e..e342f7d047 100644 --- a/src/audio/AudioListener.js +++ b/src/audio/AudioListener.js @@ -37,7 +37,7 @@ THREE.AudioListener.prototype.removeFilter = function ( ) { } -} +}; THREE.AudioListener.prototype.setFilter = function ( value ) { diff --git a/src/audio/PositionalAudio.js b/src/audio/PositionalAudio.js index b26de9e269..e8cf04250c 100644 --- a/src/audio/PositionalAudio.js +++ b/src/audio/PositionalAudio.js @@ -20,7 +20,6 @@ THREE.PositionalAudio.prototype.getOutput = function () { }; - THREE.PositionalAudio.prototype.setRefDistance = function ( value ) { this.panner.refDistance = value; @@ -69,7 +68,6 @@ THREE.PositionalAudio.prototype.getMaxDistance = function () { }; - THREE.PositionalAudio.prototype.updateMatrixWorld = ( function () { var position = new THREE.Vector3(); diff --git a/src/cameras/OrthographicCamera.js b/src/cameras/OrthographicCamera.js index a8461fc47b..00175cf299 100644 --- a/src/cameras/OrthographicCamera.js +++ b/src/cameras/OrthographicCamera.js @@ -37,20 +37,20 @@ THREE.OrthographicCamera.prototype.updateProjectionMatrix = function () { }; THREE.OrthographicCamera.prototype.copy = function ( source ) { - + THREE.Camera.prototype.copy.call( this, source ); - + this.left = source.left; this.right = source.right; this.top = source.top; this.bottom = source.bottom; this.near = source.near; this.far = source.far; - + this.zoom = source.zoom; - + return this; - + }; THREE.OrthographicCamera.prototype.toJSON = function ( meta ) { diff --git a/src/cameras/PerspectiveCamera.js b/src/cameras/PerspectiveCamera.js index a7fe40165e..1d9411f59b 100644 --- a/src/cameras/PerspectiveCamera.js +++ b/src/cameras/PerspectiveCamera.js @@ -123,18 +123,18 @@ THREE.PerspectiveCamera.prototype.updateProjectionMatrix = function () { }; THREE.PerspectiveCamera.prototype.copy = function ( source ) { - + THREE.Camera.prototype.copy.call( this, source ); - + this.fov = source.fov; this.aspect = source.aspect; this.near = source.near; this.far = source.far; - + this.zoom = source.zoom; - + return this; - + }; THREE.PerspectiveCamera.prototype.toJSON = function ( meta ) { diff --git a/src/core/BufferGeometry.js b/src/core/BufferGeometry.js index f98a6e409f..f4117b643e 100644 --- a/src/core/BufferGeometry.js +++ b/src/core/BufferGeometry.js @@ -436,16 +436,16 @@ THREE.BufferGeometry.prototype = { if ( geometry.uvsNeedUpdate ) { - var attribute = this.attributes.uv; + var attribute = this.attributes.uv; - if ( attribute !== undefined ) { + if ( attribute !== undefined ) { - attribute.copyVector2sArray( geometry.uvs ); - attribute.needsUpdate = true; + attribute.copyVector2sArray( geometry.uvs ); + attribute.needsUpdate = true; - } + } - geometry.uvsNeedUpdate = false; + geometry.uvsNeedUpdate = false; } @@ -710,11 +710,11 @@ THREE.BufferGeometry.prototype = { // reset existing normals to zero - var normals = attributes.normal.array; + var array = attributes.normal.array; - for ( var i = 0, il = normals.length; i < il; i ++ ) { + for ( var i = 0, il = array.length; i < il; i ++ ) { - normals[ i ] = 0; + array[ i ] = 0; } @@ -826,7 +826,7 @@ THREE.BufferGeometry.prototype = { computeOffsets: function ( size ) { - console.warn( 'THREE.BufferGeometry: .computeOffsets() has been removed.'); + console.warn( 'THREE.BufferGeometry: .computeOffsets() has been removed.' ); }, diff --git a/src/core/Geometry.js b/src/core/Geometry.js index 334578c30f..7ba9977a73 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -226,7 +226,7 @@ THREE.Geometry.prototype = { var tempUVs = []; var tempUVs2 = []; - for ( var i = 0, j = 0; i < vertices.length; i += 3, j += 2) { + for ( var i = 0, j = 0; i < vertices.length; i += 3, j += 2 ) { scope.vertices.push( new THREE.Vector3( vertices[ i ], vertices[ i + 1 ], vertices[ i + 2 ] ) ); -- GitLab