提交 1373c391 编写于 作者: G Garrett Johnson

lint jsm js files

上级 0730b431
...@@ -21,6 +21,7 @@ import { MaterialHandler } from "./obj2/shared/MaterialHandler.js"; ...@@ -21,6 +21,7 @@ import { MaterialHandler } from "./obj2/shared/MaterialHandler.js";
* @constructor * @constructor
*/ */
const OBJLoader2 = function ( manager ) { const OBJLoader2 = function ( manager ) {
Loader.call( this, manager ); Loader.call( this, manager );
this.parser = new OBJLoader2Parser(); this.parser = new OBJLoader2Parser();
...@@ -35,9 +36,12 @@ const OBJLoader2 = function ( manager ) { ...@@ -35,9 +36,12 @@ const OBJLoader2 = function ( manager ) {
// as OBJLoader2 is no longer derived from OBJLoader2Parser, we need to override the default onAssetAvailable callback // as OBJLoader2 is no longer derived from OBJLoader2Parser, we need to override the default onAssetAvailable callback
let scope = this; let scope = this;
let defaultOnAssetAvailable = function ( payload ) { let defaultOnAssetAvailable = function ( payload ) {
scope._onAssetAvailable( payload )
scope._onAssetAvailable( payload );
}; };
this.parser.setCallbackOnAssetAvailable( defaultOnAssetAvailable ); this.parser.setCallbackOnAssetAvailable( defaultOnAssetAvailable );
}; };
OBJLoader2.OBJLOADER2_VERSION = '3.1.0'; OBJLoader2.OBJLOADER2_VERSION = '3.1.0';
...@@ -124,7 +128,7 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), { ...@@ -124,7 +128,7 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), {
*/ */
setBaseObject3d: function ( baseObject3d ) { setBaseObject3d: function ( baseObject3d ) {
this.baseObject3d = (baseObject3d === undefined || baseObject3d === null) ? this.baseObject3d : baseObject3d; this.baseObject3d = ( baseObject3d === undefined || baseObject3d === null ) ? this.baseObject3d : baseObject3d;
return this; return this;
}, },
...@@ -224,19 +228,18 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), { ...@@ -224,19 +228,18 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), {
load: function ( url, onLoad, onFileLoadProgress, onError, onMeshAlter ) { load: function ( url, onLoad, onFileLoadProgress, onError, onMeshAlter ) {
let scope = this; let scope = this;
if ( onLoad === null || onLoad === undefined || !(onLoad instanceof Function) ) { if ( onLoad === null || onLoad === undefined || ! ( onLoad instanceof Function ) ) {
let errorMessage = 'onLoad is not a function! Aborting...'; let errorMessage = 'onLoad is not a function! Aborting...';
scope.parser.callbacks.onError( errorMessage ); scope.parser.callbacks.onError( errorMessage );
throw errorMessage throw errorMessage;
} } else {
else {
this.parser.setCallbackOnLoad( onLoad ); this.parser.setCallbackOnLoad( onLoad );
} }
if ( onError === null || onError === undefined || !(onError instanceof Function) ) { if ( onError === null || onError === undefined || ! ( onError instanceof Function ) ) {
onError = function ( event ) { onError = function ( event ) {
...@@ -251,7 +254,7 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), { ...@@ -251,7 +254,7 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), {
}; };
} }
if ( !url ) { if ( ! url ) {
onError( 'An invalid url was provided. Unable to continue!' ); onError( 'An invalid url was provided. Unable to continue!' );
...@@ -266,19 +269,19 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), { ...@@ -266,19 +269,19 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), {
if ( urlPartsPath !== undefined && urlPartsPath !== null ) this.path = urlPartsPath; if ( urlPartsPath !== undefined && urlPartsPath !== null ) this.path = urlPartsPath;
} }
if ( onFileLoadProgress === null || onFileLoadProgress === undefined || !(onFileLoadProgress instanceof Function) ) { if ( onFileLoadProgress === null || onFileLoadProgress === undefined || ! ( onFileLoadProgress instanceof Function ) ) {
let numericalValueRef = 0; let numericalValueRef = 0;
let numericalValue = 0; let numericalValue = 0;
onFileLoadProgress = function ( event ) { onFileLoadProgress = function ( event ) {
if ( !event.lengthComputable ) return; if ( ! event.lengthComputable ) return;
numericalValue = event.loaded / event.total; numericalValue = event.loaded / event.total;
if ( numericalValue > numericalValueRef ) { if ( numericalValue > numericalValueRef ) {
numericalValueRef = numericalValue; numericalValueRef = numericalValue;
let output = 'Download of "' + url + '": ' + (numericalValue * 100).toFixed( 2 ) + '%'; let output = 'Download of "' + url + '": ' + ( numericalValue * 100 ).toFixed( 2 ) + '%';
scope.parser.callbacks.onProgress( 'progressLoad', output, numericalValue ); scope.parser.callbacks.onProgress( 'progressLoad', output, numericalValue );
} }
...@@ -331,7 +334,7 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), { ...@@ -331,7 +334,7 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), {
if ( this.parser.logging.enabled ) console.info( 'Parsing arrayBuffer...' ); if ( this.parser.logging.enabled ) console.info( 'Parsing arrayBuffer...' );
this.parser.execute( content ); this.parser.execute( content );
} else if ( typeof (content) === 'string' || content instanceof String ) { } else if ( typeof ( content ) === 'string' || content instanceof String ) {
if ( this.parser.logging.enabled ) console.info( 'Parsing text...' ); if ( this.parser.logging.enabled ) console.info( 'Parsing text...' );
this.parser.executeLegacy( content ); this.parser.executeLegacy( content );
......
...@@ -120,7 +120,7 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp ...@@ -120,7 +120,7 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp
load: function ( content, onLoad, onFileLoadProgress, onError, onMeshAlter ) { load: function ( content, onLoad, onFileLoadProgress, onError, onMeshAlter ) {
let scope = this; let scope = this;
function interceptOnLoad ( object3d, message ) { function interceptOnLoad( object3d, message ) {
if ( object3d.name === 'OBJLoader2ParallelDummy' ) { if ( object3d.name === 'OBJLoader2ParallelDummy' ) {
...@@ -130,8 +130,7 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp ...@@ -130,8 +130,7 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp
} }
} } else {
else {
onLoad( object3d, message ); onLoad( object3d, message );
...@@ -169,7 +168,9 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp ...@@ -169,7 +168,9 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp
}; };
function scopedOnLoad( message ) { function scopedOnLoad( message ) {
scope.parser.callbacks.onLoad( scope.baseObject3d, message ); scope.parser.callbacks.onLoad( scope.baseObject3d, message );
} }
this.workerExecutionSupport.updateCallbacks( scopedOnAssetAvailable, scopedOnLoad ); this.workerExecutionSupport.updateCallbacks( scopedOnAssetAvailable, scopedOnLoad );
...@@ -203,8 +204,8 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp ...@@ -203,8 +204,8 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp
let dummy = new Object3D(); let dummy = new Object3D();
dummy.name = 'OBJLoader2ParallelDummy'; dummy.name = 'OBJLoader2ParallelDummy';
return dummy; return dummy;
}
else { } else {
return OBJLoader2.prototype.parse.call( this, content ); return OBJLoader2.prototype.parse.call( this, content );
......
...@@ -114,7 +114,7 @@ MaterialHandler.prototype = { ...@@ -114,7 +114,7 @@ MaterialHandler.prototype = {
} else { } else {
if ( this.logging.enabled) { if ( this.logging.enabled ) {
console.info( 'Requested material "' + materialNameOrg + '" is not available!' ); console.info( 'Requested material "' + materialNameOrg + '" is not available!' );
...@@ -255,7 +255,9 @@ MaterialHandler.prototype = { ...@@ -255,7 +255,9 @@ MaterialHandler.prototype = {
* Removes all materials * Removes all materials
*/ */
clearMaterials: function () { clearMaterials: function () {
this.materials = {}; this.materials = {};
} }
}; };
......
...@@ -16,16 +16,24 @@ const OBJLoader2Parser = function () { ...@@ -16,16 +16,24 @@ const OBJLoader2Parser = function () {
let scope = this; let scope = this;
this.callbacks = { this.callbacks = {
onProgress: function ( text ) { onProgress: function ( text ) {
scope._onProgress( text )
scope._onProgress( text );
}, },
onAssetAvailable: function ( payload ) { onAssetAvailable: function ( payload ) {
scope._onAssetAvailable( payload )
scope._onAssetAvailable( payload );
}, },
onError: function ( errorMessage ) { onError: function ( errorMessage ) {
scope._onError( errorMessage )
scope._onError( errorMessage );
}, },
onLoad: function ( object3d, message ) { onLoad: function ( object3d, message ) {
scope._onLoad( object3d, message )
scope._onLoad( object3d, message );
}, },
}; };
this.contentRef = null; this.contentRef = null;
......
...@@ -24,7 +24,7 @@ ReflectNode.prototype.nodeType = "Reflect"; ...@@ -24,7 +24,7 @@ ReflectNode.prototype.nodeType = "Reflect";
ReflectNode.prototype.getUnique = function ( builder ) { ReflectNode.prototype.getUnique = function ( builder ) {
return !builder.context.viewNormal; return ! builder.context.viewNormal;
}; };
......
...@@ -209,7 +209,7 @@ FunctionNode.prototype.parse = function ( src, includes, extensions, keywords ) ...@@ -209,7 +209,7 @@ FunctionNode.prototype.parse = function ( src, includes, extensions, keywords )
} }
this.isInterface = this.src.indexOf('{') === -1; this.isInterface = this.src.indexOf( '{' ) === - 1;
} else { } else {
......
...@@ -33,11 +33,11 @@ StandardNode.prototype.build = function ( builder ) { ...@@ -33,11 +33,11 @@ StandardNode.prototype.build = function ( builder ) {
var code; var code;
builder.define('STANDARD'); builder.define( 'STANDARD' );
var useClearcoat = this.clearcoat || this.clearcoatRoughness || this.clearCoatNormal; var useClearcoat = this.clearcoat || this.clearcoatRoughness || this.clearCoatNormal;
if( useClearcoat ){ if ( useClearcoat ) {
builder.define( 'CLEARCOAT' ); builder.define( 'CLEARCOAT' );
...@@ -129,13 +129,13 @@ StandardNode.prototype.build = function ( builder ) { ...@@ -129,13 +129,13 @@ StandardNode.prototype.build = function ( builder ) {
} else { } else {
var specularRoughness = new ExpressionNode('material.specularRoughness', 'f' ); var specularRoughness = new ExpressionNode( 'material.specularRoughness', 'f' );
var clearcoatRoughness = new ExpressionNode('material.clearcoatRoughness', 'f' ); var clearcoatRoughness = new ExpressionNode( 'material.clearcoatRoughness', 'f' );
var contextEnvironment = { var contextEnvironment = {
roughness: specularRoughness, roughness: specularRoughness,
bias: new SpecularMIPLevelNode( specularRoughness ), bias: new SpecularMIPLevelNode( specularRoughness ),
viewNormal: new ExpressionNode('normal', 'v3'), viewNormal: new ExpressionNode( 'normal', 'v3' ),
gamma: true gamma: true
}; };
...@@ -146,7 +146,7 @@ StandardNode.prototype.build = function ( builder ) { ...@@ -146,7 +146,7 @@ StandardNode.prototype.build = function ( builder ) {
var contextClearcoatEnvironment = { var contextClearcoatEnvironment = {
roughness: clearcoatRoughness, roughness: clearcoatRoughness,
bias: new SpecularMIPLevelNode( clearcoatRoughness ), bias: new SpecularMIPLevelNode( clearcoatRoughness ),
viewNormal: new ExpressionNode('clearcoatNormal', 'v3'), viewNormal: new ExpressionNode( 'clearcoatNormal', 'v3' ),
gamma: true gamma: true
}; };
......
...@@ -22,10 +22,10 @@ NormalMapNode.Nodes = ( function () { ...@@ -22,10 +22,10 @@ NormalMapNode.Nodes = ( function () {
var perturbNormal2Arb = new FunctionNode( var perturbNormal2Arb = new FunctionNode(
// Per-Pixel Tangent Space Normal Mapping // Per-Pixel Tangent Space Normal Mapping
// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html
`vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 vUv, vec2 normalScale ) { `vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 vUv, vec2 normalScale ) {
// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988 // Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
......
...@@ -42,7 +42,7 @@ SpecularMIPLevelNode.prototype = Object.create( TempNode.prototype ); ...@@ -42,7 +42,7 @@ SpecularMIPLevelNode.prototype = Object.create( TempNode.prototype );
SpecularMIPLevelNode.prototype.constructor = SpecularMIPLevelNode; SpecularMIPLevelNode.prototype.constructor = SpecularMIPLevelNode;
SpecularMIPLevelNode.prototype.nodeType = "SpecularMIPLevel"; SpecularMIPLevelNode.prototype.nodeType = "SpecularMIPLevel";
SpecularMIPLevelNode.prototype.setTexture = function( texture ) { SpecularMIPLevelNode.prototype.setTexture = function ( texture ) {
this.texture = texture; this.texture = texture;
......
...@@ -26,7 +26,7 @@ SubSlotNode.prototype.generate = function ( builder, output ) { ...@@ -26,7 +26,7 @@ SubSlotNode.prototype.generate = function ( builder, output ) {
if ( this.slots[ builder.slot ] ) { if ( this.slots[ builder.slot ] ) {
return this.slots[ builder.slot ].build( builder, output ) return this.slots[ builder.slot ].build( builder, output );
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册