Skip to content

Commit e8145dc

Browse files
authored
Merge pull request #17542 from gkjohnson/jsm-linting
Linting: Lint JSM Example Files
2 parents a291e9f + 1373c39 commit e8145dc

File tree

11 files changed

+75
-61
lines changed

11 files changed

+75
-61
lines changed

examples/jsm/loaders/OBJLoader2.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { MaterialHandler } from "./obj2/shared/MaterialHandler.js";
2121
* @constructor
2222
*/
2323
const OBJLoader2 = function ( manager ) {
24+
2425
Loader.call( this, manager );
2526

2627
this.parser = new OBJLoader2Parser();
@@ -35,9 +36,12 @@ const OBJLoader2 = function ( manager ) {
3536
// as OBJLoader2 is no longer derived from OBJLoader2Parser, we need to override the default onAssetAvailable callback
3637
let scope = this;
3738
let defaultOnAssetAvailable = function ( payload ) {
38-
scope._onAssetAvailable( payload )
39+
40+
scope._onAssetAvailable( payload );
41+
3942
};
4043
this.parser.setCallbackOnAssetAvailable( defaultOnAssetAvailable );
44+
4145
};
4246

4347
OBJLoader2.OBJLOADER2_VERSION = '3.1.0';
@@ -124,7 +128,7 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), {
124128
*/
125129
setBaseObject3d: function ( baseObject3d ) {
126130

127-
this.baseObject3d = (baseObject3d === undefined || baseObject3d === null) ? this.baseObject3d : baseObject3d;
131+
this.baseObject3d = ( baseObject3d === undefined || baseObject3d === null ) ? this.baseObject3d : baseObject3d;
128132
return this;
129133

130134
},
@@ -224,19 +228,18 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), {
224228
load: function ( url, onLoad, onFileLoadProgress, onError, onMeshAlter ) {
225229

226230
let scope = this;
227-
if ( onLoad === null || onLoad === undefined || !(onLoad instanceof Function) ) {
231+
if ( onLoad === null || onLoad === undefined || ! ( onLoad instanceof Function ) ) {
228232

229233
let errorMessage = 'onLoad is not a function! Aborting...';
230234
scope.parser.callbacks.onError( errorMessage );
231-
throw errorMessage
235+
throw errorMessage;
232236

233-
}
234-
else {
237+
} else {
235238

236239
this.parser.setCallbackOnLoad( onLoad );
237240

238241
}
239-
if ( onError === null || onError === undefined || !(onError instanceof Function) ) {
242+
if ( onError === null || onError === undefined || ! ( onError instanceof Function ) ) {
240243

241244
onError = function ( event ) {
242245

@@ -251,7 +254,7 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), {
251254
};
252255

253256
}
254-
if ( !url ) {
257+
if ( ! url ) {
255258

256259
onError( 'An invalid url was provided. Unable to continue!' );
257260

@@ -266,19 +269,19 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), {
266269
if ( urlPartsPath !== undefined && urlPartsPath !== null ) this.path = urlPartsPath;
267270

268271
}
269-
if ( onFileLoadProgress === null || onFileLoadProgress === undefined || !(onFileLoadProgress instanceof Function) ) {
272+
if ( onFileLoadProgress === null || onFileLoadProgress === undefined || ! ( onFileLoadProgress instanceof Function ) ) {
270273

271274
let numericalValueRef = 0;
272275
let numericalValue = 0;
273276
onFileLoadProgress = function ( event ) {
274277

275-
if ( !event.lengthComputable ) return;
278+
if ( ! event.lengthComputable ) return;
276279

277280
numericalValue = event.loaded / event.total;
278281
if ( numericalValue > numericalValueRef ) {
279282

280283
numericalValueRef = numericalValue;
281-
let output = 'Download of "' + url + '": ' + (numericalValue * 100).toFixed( 2 ) + '%';
284+
let output = 'Download of "' + url + '": ' + ( numericalValue * 100 ).toFixed( 2 ) + '%';
282285
scope.parser.callbacks.onProgress( 'progressLoad', output, numericalValue );
283286

284287
}
@@ -331,7 +334,7 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), {
331334
if ( this.parser.logging.enabled ) console.info( 'Parsing arrayBuffer...' );
332335
this.parser.execute( content );
333336

334-
} else if ( typeof (content) === 'string' || content instanceof String ) {
337+
} else if ( typeof ( content ) === 'string' || content instanceof String ) {
335338

336339
if ( this.parser.logging.enabled ) console.info( 'Parsing text...' );
337340
this.parser.executeLegacy( content );

examples/jsm/loaders/OBJLoader2Parallel.js

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp
120120
load: function ( content, onLoad, onFileLoadProgress, onError, onMeshAlter ) {
121121

122122
let scope = this;
123-
function interceptOnLoad ( object3d, message ) {
123+
function interceptOnLoad( object3d, message ) {
124124

125125
if ( object3d.name === 'OBJLoader2ParallelDummy' ) {
126126

@@ -130,8 +130,7 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp
130130

131131
}
132132

133-
}
134-
else {
133+
} else {
135134

136135
onLoad( object3d, message );
137136

@@ -169,7 +168,9 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp
169168

170169
};
171170
function scopedOnLoad( message ) {
171+
172172
scope.parser.callbacks.onLoad( scope.baseObject3d, message );
173+
173174
}
174175

175176
this.workerExecutionSupport.updateCallbacks( scopedOnAssetAvailable, scopedOnLoad );
@@ -180,31 +181,31 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp
180181
this.materialHandler.createDefaultMaterials( false );
181182

182183
this.workerExecutionSupport.executeParallel(
183-
{
184-
params: {
185-
modelName: this.modelName,
186-
instanceNo: this.instanceNo,
187-
useIndices: this.parser.useIndices,
188-
disregardNormals: this.parser.disregardNormals,
189-
materialPerSmoothingGroup: this.parser.materialPerSmoothingGroup,
190-
useOAsMesh: this.parser.useOAsMesh,
191-
},
192-
materials: this.materialHandler.getMaterialsJSON(),
193-
data: {
194-
input: content,
195-
options: null
196-
},
197-
logging: {
198-
enabled: this.parser.logging.enabled,
199-
debug: this.parser.logging.debug
200-
}
201-
} );
184+
{
185+
params: {
186+
modelName: this.modelName,
187+
instanceNo: this.instanceNo,
188+
useIndices: this.parser.useIndices,
189+
disregardNormals: this.parser.disregardNormals,
190+
materialPerSmoothingGroup: this.parser.materialPerSmoothingGroup,
191+
useOAsMesh: this.parser.useOAsMesh,
192+
},
193+
materials: this.materialHandler.getMaterialsJSON(),
194+
data: {
195+
input: content,
196+
options: null
197+
},
198+
logging: {
199+
enabled: this.parser.logging.enabled,
200+
debug: this.parser.logging.debug
201+
}
202+
} );
202203

203204
let dummy = new Object3D();
204205
dummy.name = 'OBJLoader2ParallelDummy';
205206
return dummy;
206-
}
207-
else {
207+
208+
} else {
208209

209210
return OBJLoader2.prototype.parse.call( this, content );
210211

examples/jsm/loaders/obj2/shared/MaterialHandler.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ MaterialHandler.prototype = {
114114

115115
} else {
116116

117-
if ( this.logging.enabled) {
117+
if ( this.logging.enabled ) {
118118

119119
console.info( 'Requested material "' + materialNameOrg + '" is not available!' );
120120

@@ -255,7 +255,9 @@ MaterialHandler.prototype = {
255255
* Removes all materials
256256
*/
257257
clearMaterials: function () {
258+
258259
this.materials = {};
260+
259261
}
260262

261263
};

examples/jsm/loaders/obj2/worker/parallel/OBJLoader2Parser.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,24 @@ const OBJLoader2Parser = function () {
1616
let scope = this;
1717
this.callbacks = {
1818
onProgress: function ( text ) {
19-
scope._onProgress( text )
19+
20+
scope._onProgress( text );
21+
2022
},
2123
onAssetAvailable: function ( payload ) {
22-
scope._onAssetAvailable( payload )
24+
25+
scope._onAssetAvailable( payload );
26+
2327
},
2428
onError: function ( errorMessage ) {
25-
scope._onError( errorMessage )
29+
30+
scope._onError( errorMessage );
31+
2632
},
2733
onLoad: function ( object3d, message ) {
28-
scope._onLoad( object3d, message )
34+
35+
scope._onLoad( object3d, message );
36+
2937
},
3038
};
3139
this.contentRef = null;

examples/jsm/nodes/accessors/NormalNode.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ NormalNode.prototype.generate = function ( builder, output ) {
4545
case NormalNode.LOCAL:
4646

4747
if ( builder.isShader( 'vertex' ) ) {
48-
48+
4949
result = 'objectNormal';
50-
50+
5151
} else {
52-
52+
5353
builder.requires.normal = true;
54-
54+
5555
result = 'vObjectNormal';
56-
56+
5757
}
5858

5959
break;

examples/jsm/nodes/accessors/ReflectNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ReflectNode.prototype.nodeType = "Reflect";
2424

2525
ReflectNode.prototype.getUnique = function ( builder ) {
2626

27-
return !builder.context.viewNormal;
27+
return ! builder.context.viewNormal;
2828

2929
};
3030

examples/jsm/nodes/core/FunctionNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ FunctionNode.prototype.parse = function ( src, includes, extensions, keywords )
209209

210210
}
211211

212-
this.isInterface = this.src.indexOf('{') === -1;
212+
this.isInterface = this.src.indexOf( '{' ) === - 1;
213213

214214
} else {
215215

examples/jsm/nodes/materials/nodes/StandardNode.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ StandardNode.prototype.build = function ( builder ) {
3333

3434
var code;
3535

36-
builder.define('STANDARD');
36+
builder.define( 'STANDARD' );
3737

3838
var useClearcoat = this.clearcoat || this.clearcoatRoughness || this.clearCoatNormal;
3939

40-
if( useClearcoat ){
40+
if ( useClearcoat ) {
4141

4242
builder.define( 'CLEARCOAT' );
4343

@@ -129,13 +129,13 @@ StandardNode.prototype.build = function ( builder ) {
129129

130130
} else {
131131

132-
var specularRoughness = new ExpressionNode('material.specularRoughness', 'f' );
133-
var clearcoatRoughness = new ExpressionNode('material.clearcoatRoughness', 'f' );
132+
var specularRoughness = new ExpressionNode( 'material.specularRoughness', 'f' );
133+
var clearcoatRoughness = new ExpressionNode( 'material.clearcoatRoughness', 'f' );
134134

135135
var contextEnvironment = {
136136
roughness: specularRoughness,
137137
bias: new SpecularMIPLevelNode( specularRoughness ),
138-
viewNormal: new ExpressionNode('normal', 'v3'),
138+
viewNormal: new ExpressionNode( 'normal', 'v3' ),
139139
gamma: true
140140
};
141141

@@ -146,7 +146,7 @@ StandardNode.prototype.build = function ( builder ) {
146146
var contextClearcoatEnvironment = {
147147
roughness: clearcoatRoughness,
148148
bias: new SpecularMIPLevelNode( clearcoatRoughness ),
149-
viewNormal: new ExpressionNode('clearcoatNormal', 'v3'),
149+
viewNormal: new ExpressionNode( 'clearcoatNormal', 'v3' ),
150150
gamma: true
151151
};
152152

examples/jsm/nodes/misc/NormalMapNode.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ function NormalMapNode( value, scale ) {
2020

2121
NormalMapNode.Nodes = ( function () {
2222

23-
var perturbNormal2Arb = new FunctionNode(
23+
var perturbNormal2Arb = new FunctionNode(
2424

25-
// Per-Pixel Tangent Space Normal Mapping
26-
// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html
27-
28-
`vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 vUv, vec2 normalScale ) {
25+
// Per-Pixel Tangent Space Normal Mapping
26+
// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html
27+
28+
`vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 vUv, vec2 normalScale ) {
2929
3030
// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
3131

examples/jsm/nodes/utils/SpecularMIPLevelNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ SpecularMIPLevelNode.prototype = Object.create( TempNode.prototype );
4242
SpecularMIPLevelNode.prototype.constructor = SpecularMIPLevelNode;
4343
SpecularMIPLevelNode.prototype.nodeType = "SpecularMIPLevel";
4444

45-
SpecularMIPLevelNode.prototype.setTexture = function( texture ) {
45+
SpecularMIPLevelNode.prototype.setTexture = function ( texture ) {
4646

4747
this.texture = texture;
4848

0 commit comments

Comments
 (0)