提交 61520f0d 编写于 作者: M Mr.doob

Fixed some more lgtm.com alerts.

上级 96a2f631
......@@ -273,7 +273,7 @@ History.prototype = {
if ( cmd === undefined || id === cmd.id ) break;
cmd = this.undo();
this.undo();
}
......
......@@ -307,8 +307,7 @@ THREE.Water.prototype.updateTextureMatrix = function () {
q.w = ( 1.0 + projectionMatrix.elements[ 10 ] ) / projectionMatrix.elements[ 14 ];
// Calculate the scaled plane vector
var c = new THREE.Vector4();
c = this.clipPlane.multiplyScalar( 2.0 / this.clipPlane.dot( q ) );
var c = this.clipPlane.multiplyScalar( 2.0 / this.clipPlane.dot( q ) );
// Replacing the third row of the projection matrix
projectionMatrix.elements[ 2 ] = c.x;
......
......@@ -479,7 +479,7 @@ THREE.TeapotBufferGeometry = function ( size, segments, bottom, lid, body, fitLi
var tcoord;
var sstep, tstep;
var vertPerRow, eps;
var vertPerRow;
var s, t, sval, tval, p;
var dsval = 0;
......@@ -532,8 +532,6 @@ THREE.TeapotBufferGeometry = function ( size, segments, bottom, lid, body, fitLi
vertPerRow = segments + 1;
eps = 0.0000001;
var surfCount = 0;
var vertCount = 0;
......
......@@ -288,7 +288,6 @@
mtx,
materials, mat, mat_id,
num_materials,
materials_parsed,
parent,
i;
......@@ -301,7 +300,6 @@
geometries = this.getBlock( data_id );
materials = [];
materials_parsed = 0;
for ( i = 0; i < num_materials; i ++ ) {
......
......@@ -493,16 +493,6 @@
}
function aiAnimation() {
this.mName = "";
this.mDuration = 0;
this.mTicksPerSecond = 0;
this.mNumChannels = 0;
this.mChannels = [];
}
function sortWeights( indexes, weights ) {
var pairs = [];
......
......@@ -92,7 +92,7 @@ THREE.BinaryLoader.prototype = {
start_quad_flat, start_quad_smooth, start_quad_flat_uv, start_quad_smooth_uv,
tri_size, quad_size,
len_tri_flat, len_tri_smooth, len_tri_flat_uv, len_tri_smooth_uv,
len_quad_flat, len_quad_smooth, len_quad_flat_uv, len_quad_smooth_uv;
len_quad_flat, len_quad_smooth, len_quad_flat_uv;
THREE.Geometry.call( this );
......@@ -119,7 +119,6 @@ THREE.BinaryLoader.prototype = {
len_quad_flat = md.nquad_flat * ( quad_size );
len_quad_smooth = md.nquad_smooth * ( quad_size + md.normal_index_bytes * 4 );
len_quad_flat_uv = md.nquad_flat_uv * ( quad_size + md.uv_index_bytes * 4 );
len_quad_smooth_uv = md.nquad_smooth_uv * ( quad_size + md.normal_index_bytes * 4 + md.uv_index_bytes * 4 );
// read buffers
......
......@@ -682,11 +682,11 @@ THREE.ColladaLoader = function () {
}
function applySkin ( geometry, instanceCtrl, frame ) {
function applySkin( geometry, instanceCtrl, frame ) {
var skinController = controllers[ instanceCtrl.url ];
if ( frame === undefined ) frame = 40;
frame = frame !== undefined ? frame : 40;
var skinController = controllers[ instanceCtrl.url ];
if ( !skinController || !skinController.skin ) {
......@@ -2171,13 +2171,11 @@ THREE.ColladaLoader = function () {
var dotSyntax = (sid.indexOf(".") >= 0);
var arrSyntax = (sid.indexOf("(") >= 0);
var arrIndices;
var member;
if ( dotSyntax ) {
parts = sid.split(".");
sid = parts.shift();
member = parts.shift();
} else if ( arrSyntax ) {
......@@ -2871,7 +2869,7 @@ THREE.ColladaLoader = function () {
var j, k, pList = primitive.p, inputs = primitive.inputs;
var input, index, idx32;
var source, numParams;
var vcIndex = 0, vcount = 3, maxOffset = 0;
var vcount, vcIndex = 0, maxOffset = 0;
var texture_sets = [];
for ( j = 0; j < inputs.length; j ++ ) {
......
......@@ -367,13 +367,6 @@ THREE.NRRDLoader.prototype = {
} else {
var v = headerObject.vectors;
var origin = headerObject.space_origin;
if ( ! origin ) {
origin = [ 0, 0, 0 ];
}
volume.matrix.set( _spaceX * v[ 0 ][ 0 ], _spaceX * v[ 1 ][ 0 ], _spaceX * v[ 2 ][ 0 ], 0,
_spaceY * v[ 0 ][ 1 ], _spaceY * v[ 1 ][ 1 ], _spaceY * v[ 2 ][ 1 ], 0,
......
/*
/*
* PVRLoader
* Author: pierre lepers
* Date: 17/09/2014 11:09
......@@ -36,7 +36,7 @@ THREE.PVRLoader.parse = function ( buffer, loadMipmaps ) {
return THREE.PVRLoader._parseV3( pvrDatas );
}
}
// PVR v2
else if ( header[ 11 ] === 0x21525650 ) {
......@@ -51,10 +51,10 @@ THREE.PVRLoader.parse = function ( buffer, loadMipmaps ) {
};
THREE.PVRLoader._parseV3 = function ( pvrDatas ) {
var header = pvrDatas.header;
var bpp, format;
var metaLen = header[ 12 ],
pixelFormat = header[ 2 ],
......@@ -109,7 +109,7 @@ THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
numMipmaps = header[ 3 ],
flags = header[ 4 ],
dataLength = header[ 5 ],
bpp = header[ 6 ],
// bpp = header[ 6 ],
bitmaskRed = header[ 7 ],
bitmaskGreen = header[ 8 ],
bitmaskBlue = header[ 9 ],
......@@ -141,7 +141,7 @@ THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
} else
throw new Error( "pvrtc - unknown format " + formatFlags );
pvrDatas.dataPtr = headerLength;
......@@ -162,14 +162,14 @@ THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
THREE.PVRLoader._extract = function ( pvrDatas ) {
var pvr = {
mipmaps: [],
width: pvrDatas.width,
height: pvrDatas.height,
format: pvrDatas.format,
mipmapCount: pvrDatas.numMipmaps,
isCubemap : pvrDatas.isCubemap
mipmaps: [],
width: pvrDatas.width,
height: pvrDatas.height,
format: pvrDatas.format,
mipmapCount: pvrDatas.numMipmaps,
isCubemap : pvrDatas.isCubemap
};
var buffer = pvrDatas.buffer;
......@@ -246,10 +246,10 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
var byteArray = new Uint8Array( buffer, dataOffset, dataSize );
var mipmap = {
data: byteArray,
width: sWidth,
height: sHeight
var mipmap = {
data: byteArray,
width: sWidth,
height: sHeight
};
pvr.mipmaps[ surfIndex * pvrDatas.numMipmaps + mipLevel ] = mipmap;
......
......@@ -114,22 +114,20 @@ THREE.VRMLLoader.prototype = {
*/
var paintFaces = function ( geometry, radius, angles, colors, directionIsDown ) {
var f, n, p, vertexIndex, color;
var direction = directionIsDown ? 1 : - 1;
var faceIndices = [ 'a', 'b', 'c', 'd' ];
var coord = [ ], aColor, bColor, t = 1, A = {}, B = {}, applyColor = false, colorIndex;
var coord = [], A = {}, B = {}, applyColor = false;
for ( var k = 0; k < angles.length; k ++ ) {
var vec = { };
// push the vector at which the color changes
vec.y = direction * ( Math.cos( angles[ k ] ) * radius );
vec.x = direction * ( Math.sin( angles[ k ] ) * radius );
var vec = {
x: direction * ( Math.cos( angles[ k ] ) * radius ),
y: direction * ( Math.sin( angles[ k ] ) * radius )
};
coord.push( vec );
......@@ -138,15 +136,15 @@ THREE.VRMLLoader.prototype = {
// painting the colors on the faces
for ( var i = 0; i < geometry.faces.length ; i ++ ) {
f = geometry.faces[ i ];
var f = geometry.faces[ i ];
n = ( f instanceof THREE.Face3 ) ? 3 : 4;
var n = ( f instanceof THREE.Face3 ) ? 3 : 4;
for ( var j = 0; j < n; j ++ ) {
vertexIndex = f[ faceIndices[ j ] ];
var vertexIndex = f[ faceIndices[ j ] ];
p = geometry.vertices[ vertexIndex ];
var p = geometry.vertices[ vertexIndex ];
for ( var index = 0; index < colors.length; index ++ ) {
......@@ -174,15 +172,14 @@ THREE.VRMLLoader.prototype = {
if ( applyColor ) {
bColor = colors[ index + 1 ];
aColor = colors[ index ];
var aColor = colors[ index ];
var bColor = colors[ index + 1 ];
// below is simple linear interpolation
t = Math.abs( p.y - A.y ) / ( A.y - B.y );
var t = Math.abs( p.y - A.y ) / ( A.y - B.y );
// to make it faster, you can only calculate this if the y coord changes, the color is the same for points with the same y
color = interpolateColors( aColor, bColor, t );
var color = interpolateColors( aColor, bColor, t );
f.vertexColors[ j ] = color;
......@@ -190,7 +187,7 @@ THREE.VRMLLoader.prototype = {
} else if ( undefined === f.vertexColors[ j ] ) {
colorIndex = directionIsDown ? colors.length - 1 : 0;
var colorIndex = directionIsDown ? colors.length - 1 : 0;
f.vertexColors[ j ] = colors[ colorIndex ];
}
......@@ -1025,8 +1022,6 @@ THREE.VRMLLoader.prototype = {
for ( var i = 0, l = data.children.length; i < l; i ++ ) {
var child = data.children[ i ];
parseNode( data.children[ i ], object );
}
......
......@@ -20,11 +20,10 @@ THREE.Lut = function ( colormap, numberofcolors ) {
var min = this.map[ j ][ 0 ];
var max = this.map[ j + 1 ][ 0 ];
var color = new THREE.Color( 0xffffff );
var minColor = new THREE.Color( 0xffffff ).setHex( this.map[ j ][ 1 ] );
var maxColor = new THREE.Color( 0xffffff ).setHex( this.map[ j + 1 ][ 1 ] );
color = minColor.lerp( maxColor, ( i - min ) / ( max - min ) );
var color = minColor.lerp( maxColor, ( i - min ) / ( max - min ) );
this.lut.push( color );
......@@ -176,10 +175,11 @@ THREE.Lut.prototype = {
var min = this.map[ j - 1 ][ 0 ];
var max = this.map[ j ][ 0 ];
var color = new THREE.Color( 0xffffff );
var minColor = new THREE.Color( 0xffffff ).setHex( this.map[ j - 1 ][ 1 ] );
var maxColor = new THREE.Color( 0xffffff ).setHex( this.map[ j ][ 1 ] );
color = minColor.lerp( maxColor, ( i - min ) / ( max - min ) );
var color = minColor.lerp( maxColor, ( i - min ) / ( max - min ) );
data[ k * 4 ] = Math.round( color.r * 255 );
data[ k * 4 + 1 ] = Math.round( color.g * 255 );
......
......@@ -242,7 +242,6 @@ function compute_vertex_normals( geometry ) {
}
var tmpx, tmpy, tmpz;
var t_len;
for ( var i = 0, il = oldFaces.length; i < il; i++ ) {
......@@ -268,10 +267,6 @@ function compute_vertex_normals( geometry ) {
full_weights[ 1 ] = ( my_weight / newNormalFaces.buffer[ oldFaces.register[ 0 ].b ] );
full_weights[ 2 ] = ( my_weight / newNormalFaces.buffer[ oldFaces.register[ 0 ].c ] );
tmpx = newNormals.register[ 3 ].x * full_weights[ 0 ];
tmpy = newNormals.register[ 3 ].y * full_weights[ 0 ];
tmpz = newNormals.register[ 3 ].z * full_weights[ 0 ];
newNormals.buffer[ ( oldFaces.register[ 0 ].a * 3 ) + 0 ] += newNormals.register[ 3 ].x * full_weights[ 0 ];
newNormals.buffer[ ( oldFaces.register[ 0 ].a * 3 ) + 1 ] += newNormals.register[ 3 ].y * full_weights[ 0 ];
newNormals.buffer[ ( oldFaces.register[ 0 ].a * 3 ) + 2 ] += newNormals.register[ 3 ].z * full_weights[ 0 ];
......
......@@ -80,12 +80,10 @@ self.onmessage = function( e ) {
* @author zz95 / http://github.com/zz85
*/
THREE.RaytracingRendererWorker = function ( parameters ) {
THREE.RaytracingRendererWorker = function () {
console.log( 'THREE.RaytracingRendererWorker', THREE.REVISION );
parameters = parameters || {};
var scope = this;
var maxRecursionDepth = 3;
......
......@@ -312,8 +312,6 @@
}
var last = performance.now();
var gpuCompute;
var velocityVariable;
var positionVariable;
......@@ -600,12 +598,6 @@
function render() {
var now = performance.now();
var delta = (now - last) / 1000;
if (delta > 1) delta = 1; // safety cap on large deltas
last = now;
gpuCompute.compute();
particleUniforms.texturePosition.value = gpuCompute.getCurrentRenderTarget( positionVariable ).texture;
......
......@@ -577,8 +577,6 @@
var colorA = new THREE.ColorNode( 0xFFFFFF );
var colorB = new THREE.ColorNode( 0x0054df );
var uv = new THREE.UVNode();
var timeScale = new THREE.OperatorNode(
time,
speed,
......@@ -1901,7 +1899,7 @@
var setMyVar = new THREE.FunctionNode( [
"float setMyVar( vec3 pos ) {",
// set "myVar" in vertex shader in this example,
// set "myVar" in vertex shader in this example,
// can be used in fragment shader too or in rest of the current shader
" myVar = pos;",
// it is not accept "void" functions for now!
......
......@@ -109,9 +109,7 @@
// MATERIALS
var diffuse = 0xbbbbbb, specular = 0x070707, shininess = 50;
specular = 0x555555;
var diffuse = 0xbbbbbb, specular = 0x555555, shininess = 50;
var shader = THREE.ShaderSkin[ "skin" ];
......
......@@ -496,7 +496,7 @@ Use WEBGL Depth buffer support?
}
for (var i=0;i<leaves;i++) {
plane = planes[i];
var plane = planes[i];
plane.rotation.x += plane.rotation.dx;
plane.rotation.y += plane.rotation.dy;
plane.rotation.z += plane.rotation.dz;
......
......@@ -77,10 +77,10 @@
scene.add( object );
var geometry = new THREE.SphereGeometry( 1, 4, 4 );
var material = new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading } );
for ( var i = 0; i < 100; i ++ ) {
material = new THREE.MeshPhongMaterial( { color: 0xffffff * Math.random(), shading: THREE.FlatShading } );
var material = new THREE.MeshPhongMaterial( { color: 0xffffff * Math.random(), shading: THREE.FlatShading } );
var mesh = new THREE.Mesh( geometry, material );
mesh.position.set( Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5 ).normalize();
......
......@@ -56,7 +56,6 @@ function ExtrudeBufferGeometry( shapes, options ) {
if ( typeof ( shapes ) === "undefined" ) {
shapes = [];
return;
}
......@@ -211,8 +210,6 @@ ExtrudeBufferGeometry.prototype.addShape = function ( shape, options ) {
}
reverse = false; // If vertices are in order now, we shouldn't need to worry about them again (hopefully)!
}
......@@ -256,7 +253,7 @@ ExtrudeBufferGeometry.prototype.addShape = function ( shape, options ) {
// inPt' is the intersection of the two lines parallel to the two
// adjacent edges of inPt at a distance of 1 unit on the left side.
var v_trans_x, v_trans_y, shrink_by = 1; // resulting translation vector for inPt
var v_trans_x, v_trans_y, shrink_by; // resulting translation vector for inPt
// good reading for geometry algorithms (here: line-line intersection)
// http://geomalgorithms.com/a05-_intersect-1.html
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册