Skip to content

Commit

Permalink
More clean up. (#23442)
Browse files Browse the repository at this point in the history
* More clean up.

* Update VTKLoader.js

Co-authored-by: mrdoob <info@mrdoob.com>
  • Loading branch information
Mugen87 and mrdoob authored Feb 7, 2022
1 parent f66f975 commit 1637e9d
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 86 deletions.
4 changes: 2 additions & 2 deletions examples/jsm/controls/experimental/CameraControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ var CameraControls = function ( object, domElement ) {

vec.set( 0, 1, 0 ).applyQuaternion( scope.object.quaternion );

var factor = ( scope.enableDamping ) ? scope.dampingFactor : 1;
const factor = ( scope.enableDamping ) ? scope.dampingFactor : 1;

q.setFromAxisAngle( vec, sphericalDelta.theta * factor );

Expand All @@ -172,7 +172,7 @@ var CameraControls = function ( object, domElement ) {

vec.set( 1, 0, 0 ).applyQuaternion( scope.object.quaternion );

var factor = ( scope.enableDamping ) ? scope.dampingFactor : 1;
const factor = ( scope.enableDamping ) ? scope.dampingFactor : 1;

q.setFromAxisAngle( vec, sphericalDelta.phi * factor );

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/effects/AsciiEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AsciiEffect {
this.render = function ( scene, camera ) {

renderer.render( scene, camera );
asciifyImage( renderer, oAscii );
asciifyImage( oAscii );

};

Expand Down Expand Up @@ -191,7 +191,7 @@ class AsciiEffect {

// convert img element to ascii

function asciifyImage( canvasRenderer, oAscii ) {
function asciifyImage( oAscii ) {

oCtx.clearRect( 0, 0, iWidth, iHeight );
oCtx.drawImage( oCanvasImg, 0, 0, iWidth, iHeight );
Expand Down
12 changes: 6 additions & 6 deletions examples/jsm/exporters/OBJExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,17 @@ class OBJExporter {

}

}
output += 'p ';

output += 'p ';
for ( let j = 1, l = vertices.count; j <= l; j ++ ) {

for ( let j = 1, l = vertices.count; j <= l; j ++ ) {
output += ( indexVertex + j ) + ' ';

output += ( indexVertex + j ) + ' ';
}

}
output += '\n';

output += '\n';
}

// update index
indexVertex += nbVertex;
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/exporters/PLYExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ class PLYExporter {
uvs.getX( i ) + ' ' +
uvs.getY( i );

} else if ( includeUVs !== false ) {
} else {

line += ' 0 0';

Expand Down
13 changes: 4 additions & 9 deletions examples/jsm/loaders/3MFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class ThreeMFLoader extends Loader {
let relsName;
let modelRelsName;
const modelPartNames = [];
const printTicketPartNames = [];
const texturesPartNames = [];

let modelRels;
Expand Down Expand Up @@ -134,10 +133,6 @@ class ThreeMFLoader extends Loader {

modelPartNames.push( file );

} else if ( file.match( /^3D\/Metadata\/.*\.xml$/ ) ) {

printTicketPartNames.push( file );

} else if ( file.match( /^3D\/Textures?\/.*/ ) ) {

texturesPartNames.push( file );
Expand Down Expand Up @@ -997,7 +992,7 @@ class ThreeMFLoader extends Loader {

}

function buildVertexColorMesh( colorgroup, triangleProperties, meshData, objects, objectData ) {
function buildVertexColorMesh( colorgroup, triangleProperties, meshData, objectData ) {

// geometry

Expand Down Expand Up @@ -1110,7 +1105,7 @@ class ThreeMFLoader extends Loader {

case 'vertexColors':
const colorgroup = modelData.resources.colorgroup[ resourceId ];
meshes.push( buildVertexColorMesh( colorgroup, triangleProperties, meshData, objects, objectData ) );
meshes.push( buildVertexColorMesh( colorgroup, triangleProperties, meshData, objectData ) );
break;

case 'default':
Expand Down Expand Up @@ -1154,7 +1149,7 @@ class ThreeMFLoader extends Loader {

}

function analyzeObject( modelData, meshData, objectData ) {
function analyzeObject( meshData, objectData ) {

const resourceMap = {};

Expand Down Expand Up @@ -1183,7 +1178,7 @@ class ThreeMFLoader extends Loader {

const group = new Group();

const resourceMap = analyzeObject( modelData, meshData, objectData );
const resourceMap = analyzeObject( meshData, objectData );
const meshes = buildMeshes( resourceMap, meshData, objects, modelData, textureData, objectData );

for ( let i = 0, l = meshes.length; i < l; i ++ ) {
Expand Down
16 changes: 8 additions & 8 deletions examples/jsm/loaders/EXRLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class EXRLoader extends DataTextureLoader {

}

function hufUnpackEncTable( uInt8Array, inDataView, inOffset, ni, im, iM, hcode ) {
function hufUnpackEncTable( uInt8Array, inOffset, ni, im, iM, hcode ) {

const p = inOffset;
let c = 0;
Expand Down Expand Up @@ -371,7 +371,7 @@ class EXRLoader extends DataTextureLoader {

const getCodeReturn = { c: 0, lc: 0 };

function getCode( po, rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outBufferOffset, outBufferEndOffset ) {
function getCode( po, rlc, c, lc, uInt8Array, inOffset, outBuffer, outBufferOffset, outBufferEndOffset ) {

if ( po == rlc ) {

Expand Down Expand Up @@ -595,7 +595,7 @@ class EXRLoader extends DataTextureLoader {

}

function hufDecode( encodingTable, decodingTable, uInt8Array, inDataView, inOffset, ni, rlc, no, outBuffer, outOffset ) {
function hufDecode( encodingTable, decodingTable, uInt8Array, inOffset, ni, rlc, no, outBuffer, outOffset ) {

let c = 0;
let lc = 0;
Expand All @@ -618,7 +618,7 @@ class EXRLoader extends DataTextureLoader {

lc -= pl.len;

getCode( pl.lit, rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset );
getCode( pl.lit, rlc, c, lc, uInt8Array, inOffset, outBuffer, outOffset, outBufferEndOffset );

c = getCodeReturn.c;
lc = getCodeReturn.lc;
Expand Down Expand Up @@ -652,7 +652,7 @@ class EXRLoader extends DataTextureLoader {

lc -= l;

getCode( pl.p[ j ], rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset );
getCode( pl.p[ j ], rlc, c, lc, uInt8Array, inOffset, outBuffer, outOffset, outBufferEndOffset );

c = getCodeReturn.c;
lc = getCodeReturn.lc;
Expand Down Expand Up @@ -690,7 +690,7 @@ class EXRLoader extends DataTextureLoader {

lc -= pl.len;

getCode( pl.lit, rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset );
getCode( pl.lit, rlc, c, lc, uInt8Array, inOffset, outBuffer, outOffset, outBufferEndOffset );

c = getCodeReturn.c;
lc = getCodeReturn.lc;
Expand Down Expand Up @@ -734,7 +734,7 @@ class EXRLoader extends DataTextureLoader {

const ni = nCompressed - ( inOffset.value - initialInOffset );

hufUnpackEncTable( uInt8Array, inDataView, inOffset, ni, im, iM, freq );
hufUnpackEncTable( uInt8Array, inOffset, ni, im, iM, freq );

if ( nBits > 8 * ( nCompressed - ( inOffset.value - initialInOffset ) ) ) {

Expand All @@ -744,7 +744,7 @@ class EXRLoader extends DataTextureLoader {

hufBuildDecTable( freq, im, iM, hdec );

hufDecode( freq, hdec, uInt8Array, inDataView, inOffset, nBits, iM, nRaw, outBuffer, outOffset );
hufDecode( freq, hdec, uInt8Array, inOffset, nBits, iM, nRaw, outBuffer, outOffset );

}

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/loaders/LogLuvLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ UTIF.decode = function ( buff, prm ) {
var bin = id == 'II' ? UTIF._binLE : UTIF._binBE;
bin.readUshort( data, offset ); offset += 2;

var ifdo = bin.readUint( data, offset ); offset += 4;
var ifdo = bin.readUint( data, offset );
var ifds = [];
while ( true ) {

Expand Down Expand Up @@ -339,7 +339,7 @@ UTIF._readIFD = function ( bin, data, offset, ifds, depth, prm ) {

ifd[ 't' + tag ] = arr;

if ( tag == 330 && ifd[ 't272' ] && ifd[ 't272' ][ 0 ] == 'DSLR-A100' ) { } else if ( tag == 330 || tag == 34665 || tag == 34853 || ( tag == 50740 && bin.readUshort( data, bin.readUint( arr, 0 ) ) < 300 ) || tag == 61440 ) {
if ( tag == 330 || tag == 34665 || tag == 34853 || ( tag == 50740 && bin.readUshort( data, bin.readUint( arr, 0 ) ) < 300 ) || tag == 61440 ) {

var oarr = tag == 50740 ? [ bin.readUint( arr, 0 ) ] : arr;
var subfd = [];
Expand Down
3 changes: 1 addition & 2 deletions examples/jsm/loaders/PCDLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ class PCDLoader extends Loader {
if ( PCDheader.version !== null )
PCDheader.version = parseFloat( PCDheader.version[ 1 ] );

if ( PCDheader.fields !== null )
PCDheader.fields = PCDheader.fields[ 1 ].split( ' ' );
PCDheader.fields = ( PCDheader.fields !== null ) ? PCDheader.fields[ 1 ].split( ' ' ) : [];

if ( PCDheader.type !== null )
PCDheader.type = PCDheader.type[ 1 ].split( ' ' );
Expand Down
23 changes: 13 additions & 10 deletions examples/jsm/loaders/RGBMLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ UPNG.toRGBA8 = function ( out ) {

frms.push( img.buffer.slice( 0 ) );

if ( frm.dispose == 0 ) {} else if ( frm.dispose == 1 ) UPNG._copyTile( empty, fw, fh, img, w, h, fx, fy, 0 );
if ( frm.dispose == 1 ) UPNG._copyTile( empty, fw, fh, img, w, h, fx, fy, 0 );
else if ( frm.dispose == 2 ) for ( var j = 0; j < len; j ++ ) img[ j ] = prev[ j ];

}
Expand Down Expand Up @@ -326,6 +326,7 @@ UPNG.decode = function ( buff ) {
var out = { tabs: {}, frames: [] };
var dd = new Uint8Array( data.length ), doff = 0; // put all IDAT data into it
var fd, foff = 0; // frames
var text, keyw, bfr;

var mgck = [ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a ];
for ( var i = 0; i < 8; i ++ ) if ( data[ i ] != mgck[ i ] ) throw new Error( 'The input is not a PNG file!' );
Expand Down Expand Up @@ -387,12 +388,12 @@ UPNG.decode = function ( buff ) {

if ( out.tabs[ type ] == null ) out.tabs[ type ] = {};
var nz = bin.nextZero( data, offset );
var keyw = bin.readASCII( data, offset, nz - offset );
var text, tl = offset + len - nz - 1;
keyw = bin.readASCII( data, offset, nz - offset );
var tl = offset + len - nz - 1;
if ( type == 'tEXt' ) text = bin.readASCII( data, nz + 1, tl );
else {

var bfr = UPNG.decode._inflate( data.slice( nz + 2, nz + 2 + tl ) );
bfr = UPNG.decode._inflate( data.slice( nz + 2, nz + 2 + tl ) );
text = bin.readUTF8( bfr, 0, bfr.length );

}
Expand All @@ -404,17 +405,17 @@ UPNG.decode = function ( buff ) {
if ( out.tabs[ type ] == null ) out.tabs[ type ] = {};
var nz = 0, off = offset;
nz = bin.nextZero( data, off );
var keyw = bin.readASCII( data, off, nz - off ); off = nz + 1;
keyw = bin.readASCII( data, off, nz - off ); off = nz + 1;
var cflag = data[ off ]; off += 2;
nz = bin.nextZero( data, off );
bin.readASCII( data, off, nz - off ); off = nz + 1;
nz = bin.nextZero( data, off );
bin.readUTF8( data, off, nz - off ); off = nz + 1;
var text, tl = len - ( off - offset );
var tl = len - ( off - offset );
if ( cflag == 0 ) text = bin.readUTF8( data, off, tl );
else {

var bfr = UPNG.decode._inflate( data.slice( off, off + tl ) );
bfr = UPNG.decode._inflate( data.slice( off, off + tl ) );
text = bin.readUTF8( bfr, 0, bfr.length );

}
Expand Down Expand Up @@ -809,6 +810,8 @@ UPNG.decode._readInterlace = function ( data, out ) {
UPNG.decode._filterZero( data, out, di, sw, sh );

var y = 0, row = starting_row[ pass ];
var val;

while ( row < h ) {

var col = starting_col[ pass ];
Expand All @@ -818,21 +821,21 @@ UPNG.decode._readInterlace = function ( data, out ) {

if ( bpp == 1 ) {

var val = data[ cdi >> 3 ]; val = ( val >> ( 7 - ( cdi & 7 ) ) ) & 1;
val = data[ cdi >> 3 ]; val = ( val >> ( 7 - ( cdi & 7 ) ) ) & 1;
img[ row * bpl + ( col >> 3 ) ] |= ( val << ( 7 - ( ( col & 7 ) << 0 ) ) );

}

if ( bpp == 2 ) {

var val = data[ cdi >> 3 ]; val = ( val >> ( 6 - ( cdi & 7 ) ) ) & 3;
val = data[ cdi >> 3 ]; val = ( val >> ( 6 - ( cdi & 7 ) ) ) & 3;
img[ row * bpl + ( col >> 2 ) ] |= ( val << ( 6 - ( ( col & 3 ) << 1 ) ) );

}

if ( bpp == 4 ) {

var val = data[ cdi >> 3 ]; val = ( val >> ( 4 - ( cdi & 7 ) ) ) & 15;
val = data[ cdi >> 3 ]; val = ( val >> ( 4 - ( cdi & 7 ) ) ) & 15;
img[ row * bpl + ( col >> 1 ) ] |= ( val << ( 4 - ( ( col & 1 ) << 2 ) ) );

}
Expand Down
3 changes: 0 additions & 3 deletions examples/jsm/loaders/VTKLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ class VTKLoader extends Loader {
let normals = [];
let indices = [];

// Going to make a big array of strings
const vtk = [];
let index = 0;

function findString( buffer, start ) {
Expand Down Expand Up @@ -386,7 +384,6 @@ class VTKLoader extends Loader {

} else if ( line.indexOf( 'POINTS' ) === 0 ) {

vtk.push( line );
// Add the points
const numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 );

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/renderers/SVGRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class SVGRenderer {

if ( _clipBox.intersectsBox( _elemBox ) === true ) {

renderLine( _v1, _v2, element, material );
renderLine( _v1, _v2, material );

}

Expand Down Expand Up @@ -397,7 +397,7 @@ class SVGRenderer {

}

function renderLine( v1, v2, element, material ) {
function renderLine( v1, v2, material ) {

const path = 'M' + convert( v1.positionScreen.x ) + ',' + convert( v1.positionScreen.y ) + 'L' + convert( v2.positionScreen.x ) + ',' + convert( v2.positionScreen.y );

Expand Down
2 changes: 0 additions & 2 deletions manual/examples/resources/lut-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ export function parseCSP(str) {
}

// read ranges
const ranges = [];
for (let i = 0; i < 3; ++i) {
++lineNdx;
const input = splitToNumbers(lines[lineNdx++]);
const output = splitToNumbers(lines[lineNdx++]);
ranges.push({input, output});
if (input.length !== 2 || output.length !== 2 ||
input[0] !== 0 || input[1] !== 1 ||
output[0] !== 0 || output[1] !== 1) {
Expand Down
Loading

0 comments on commit 1637e9d

Please sign in to comment.