Skip to content

Commit

Permalink
set maxlen to 80 and fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
biasmv committed Jan 17, 2015
1 parent ca15c1b commit 259725e
Show file tree
Hide file tree
Showing 16 changed files with 381 additions and 345 deletions.
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = function(grunt) {
curly : true,
eqeqeq : true,
forin : true,
maxlen: 80,
/*freeze : true, */
immed : true,
latedef : true,
Expand Down
3 changes: 2 additions & 1 deletion src/chain-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ derive(MeshChainData, IndexedVertexArray, {
chain : function() { return this._chain; }
});

MeshChainData.prototype.drawSymmetryRelated = LineChainData.prototype.drawSymmetryRelated;
MeshChainData.prototype.drawSymmetryRelated =
LineChainData.prototype.drawSymmetryRelated;


exports.LineChainData = LineChainData;
Expand Down
12 changes: 8 additions & 4 deletions src/custom-mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ DynamicIndexedVertexArray.prototype = {
},
addVertex : function(pos, normal, color, objId) {
this._numVerts += 1;
this._vertData.push(pos[0], pos[1], pos[2], normal[0], normal[1], normal[2],
color[0], color[1], color[2], color[3], objId);
this._vertData.push(pos[0], pos[1], pos[2],
normal[0], normal[1], normal[2],
color[0], color[1], color[2], color[3],
objId);
},
addTriangle : function(indexOne, indexTwo, indexThree) {
this._indexData.push(indexOne, indexTwo, indexThree);
Expand Down Expand Up @@ -133,8 +135,10 @@ derive(CustomMesh, SceneNode, {
if (this._va !== null) {
this._va.destroy();
}
this._va = new IndexedVertexArray(this._gl, this._data.numVerts(), this._data.numIndices(),
this._float32Allocator, this._uint16Allocator);
this._va = new IndexedVertexArray(this._gl, this._data.numVerts(),
this._data.numIndices(),
this._float32Allocator,
this._uint16Allocator);
// FIXME: find a better way to do this
this._va.setIndexData(this._data.indexData());
this._va.setVertData(this._data.vertData());
Expand Down
54 changes: 30 additions & 24 deletions src/geom-builders.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,17 @@ function TubeProfile(points, num, strength) {
TubeProfile.prototype = {
addTransformed : (function() {
var pos = vec3.create(), normal = vec3.create();
return function(vertArray, center, radius, rotation, color, first, offset, objId) {
var baseIndex = vertArray.numVerts() - this._arcs;
for (var i = 0; i < this._arcs; ++i) {
vec3.set(pos, radius * this._verts[3 * i],
radius * this._verts[3 * i + 1], 0.0);
return function(vertArray, center, radius, rotation, color,
first, offset, objId) {
var arcs = this._arcs;
var norms = this._normals;
var verts = this._verts;
var baseIndex = vertArray.numVerts() - arcs;
for (var i = 0; i < arcs; ++i) {
vec3.set(pos, radius * verts[3 * i], radius * verts[3 * i + 1], 0.0);
vec3.transformMat3(pos, pos, rotation);
vec3.add(pos, pos, center);
vec3.set(normal, this._normals[3 * i], this._normals[3 * i + 1], 0.0);
vec3.set(normal, norms[3 * i], norms[3 * i + 1], 0.0);
vec3.transformMat3(normal, normal, rotation);
vertArray.addVertex(pos, normal, color, objId);
}
Expand All @@ -152,13 +155,13 @@ TubeProfile.prototype = {
}
return;
}
for (i = 0; i < this._arcs; ++i) {
vertArray.addTriangle(baseIndex + ((i + offset) % this._arcs),
baseIndex + i + this._arcs,
baseIndex + ((i + 1) % this._arcs) + this._arcs);
vertArray.addTriangle(baseIndex + (i + offset) % this._arcs,
baseIndex + ((i + 1) % this._arcs) + this._arcs,
baseIndex + ((i + 1 + offset) % this._arcs));
for (i = 0; i < arcs; ++i) {
vertArray.addTriangle(baseIndex + ((i + offset) % arcs),
baseIndex + i + arcs,
baseIndex + ((i + 1) % arcs) + arcs);
vertArray.addTriangle(baseIndex + (i + offset) % arcs,
baseIndex + ((i + 1) % arcs) + arcs,
baseIndex + ((i + 1 + offset) % arcs));
}

};
Expand Down Expand Up @@ -210,21 +213,24 @@ ProtoCylinder.prototype = {
return function(va, center, length, radius, rotation, colorOne, colorTwo,
idOne, idTwo) {
var baseIndex = va.numVerts();
for (var i = 0; i < 2 * this._arcs; ++i) {
vec3.set(pos, radius * this._verts[3 * i], radius * this._verts[3 * i + 1],
length * this._verts[3 * i + 2]);
var verts = this._verts;
var norms = this._normals;
var arcs = this._arcs;
for (var i = 0; i < 2 * arcs; ++i) {
vec3.set(pos, radius * verts[3 * i], radius * verts[3 * i + 1],
length * verts[3 * i + 2]);
vec3.transformMat3(pos, pos, rotation);
vec3.add(pos, pos, center);
vec3.set(normal, this._normals[3 * i], this._normals[3 * i + 1],
this._normals[3 * i + 2]);
vec3.set(normal, norms[3 * i], norms[3 * i + 1], norms[3 * i + 2]);
vec3.transformMat3(normal, normal, rotation);
var objId = i < this._arcs ? idOne : idTwo;
va.addVertex(pos, normal, i < this._arcs ? colorOne : colorTwo, objId);
var objId = i < arcs ? idOne : idTwo;
va.addVertex(pos, normal, i < arcs ? colorOne : colorTwo, objId);
}
for (i = 0; i < this._indices.length / 3; ++i) {
va.addTriangle(baseIndex + this._indices[i * 3],
baseIndex + this._indices[i * 3 + 1],
baseIndex + this._indices[i * 3 + 2]);
var indices = this._indices;
for (i = 0; i < indices.length / 3; ++i) {
va.addTriangle(baseIndex + indices[i * 3],
baseIndex + indices[i * 3 + 1],
baseIndex + indices[i * 3 + 2]);
}
};
})()
Expand Down
3 changes: 2 additions & 1 deletion src/geom.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ var diagonalizer = (function() {
var thet = (D[k2 * 3 + k2] - D[k1 * 3 + k1]) / (2.0 * offDiag[k]);
var sgn = (thet > 0.0) ? 1.0 : -1.0;
thet *= sgn; // make it positive
var t = sgn / (thet + ((thet < 1.E6) ? Math.sqrt(thet * thet + 1.0) : thet));
var div = (thet + ((thet < 1.E6) ? Math.sqrt(thet * thet + 1.0) : thet));
var t = sgn / div;
var c = 1.0 / Math.sqrt(t * t + 1.0);
if(c === 1.0) {
// no room for improvement - reached machine precision.
Expand Down
37 changes: 20 additions & 17 deletions src/indexed-vertex-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,41 +107,44 @@ derive(IndexedVertexArray, VertexArrayBase, {
},

bindAttribs : function(shader) {
this._gl.enableVertexAttribArray(shader.posAttrib);
this._gl.vertexAttribPointer(shader.posAttrib, 3, this._gl.FLOAT, false,
this._FLOATS_PER_VERT * 4, this._POS_OFFSET * 4);
var gl = this._gl;
gl.enableVertexAttribArray(shader.posAttrib);
gl.vertexAttribPointer(shader.posAttrib, 3, gl.FLOAT, false,
this._FLOATS_PER_VERT * 4,
this._POS_OFFSET * 4);

if (shader.normalAttrib !== -1) {
this._gl.enableVertexAttribArray(shader.normalAttrib);
this._gl.vertexAttribPointer(shader.normalAttrib, 3, this._gl.FLOAT, false,
gl.enableVertexAttribArray(shader.normalAttrib);
gl.vertexAttribPointer(shader.normalAttrib, 3, gl.FLOAT, false,
this._FLOATS_PER_VERT * 4,
this._NORMAL_OFFSET * 4);
}

if (shader.colorAttrib !== -1) {
this._gl.vertexAttribPointer(shader.colorAttrib, 4, this._gl.FLOAT, false,
gl.vertexAttribPointer(shader.colorAttrib, 4, gl.FLOAT, false,
this._FLOATS_PER_VERT * 4,
this._COLOR_OFFSET * 4);
this._gl.enableVertexAttribArray(shader.colorAttrib);
gl.enableVertexAttribArray(shader.colorAttrib);
}
if (shader.objIdAttrib !== -1) {
this._gl.vertexAttribPointer(shader.objIdAttrib, 1, this._gl.FLOAT, false,
this._FLOATS_PER_VERT * 4, this._OBJID_OFFSET * 4);
this._gl.enableVertexAttribArray(shader.objIdAttrib);
gl.vertexAttribPointer(shader.objIdAttrib, 1, gl.FLOAT, false,
this._FLOATS_PER_VERT * 4,
this._OBJID_OFFSET * 4);
gl.enableVertexAttribArray(shader.objIdAttrib);
}
},

releaseAttribs : function(shader) {

this._gl.disableVertexAttribArray(shader.posAttrib);
var gl = this._gl;
gl.disableVertexAttribArray(shader.posAttrib);
if (shader.colorAttrib !== -1) {
this._gl.disableVertexAttribArray(shader.colorAttrib);
gl.disableVertexAttribArray(shader.colorAttrib);
}
if (shader.normalAttrib !== -1) {
this._gl.disableVertexAttribArray(shader.normalAttrib);
gl.disableVertexAttribArray(shader.normalAttrib);
}
if (shader.objIdAttrib !== -1) {
this._gl.disableVertexAttribArray(shader.objIdAttrib);
gl.disableVertexAttribArray(shader.objIdAttrib);
}
},

Expand All @@ -150,8 +153,8 @@ derive(IndexedVertexArray, VertexArrayBase, {
this.bindAttribs(shader);
},

// draws all triangles contained in the indexed vertex array using the provided
// shader. requires a call to bind() first.
// draws all triangles contained in the indexed vertex array using the
// provided shader. requires a call to bind() first.
draw : function() {
this._gl.drawElements(this._gl.TRIANGLES, this._numTriangles * 3,
this._gl.UNSIGNED_SHORT, 0);
Expand Down
10 changes: 7 additions & 3 deletions src/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Remark350Reader.prototype = {
var assemblies = [];
for (var c in this._assemblies) {
if (this._assemblies.hasOwnProperty(c)) {
// We are sure that obj[key] belongs to the object and was not inherited.
// We are sure that obj[key] belongs to the object and was not
// inherited.
assemblies.push(this._assemblies[c]);
}
}
Expand Down Expand Up @@ -231,8 +232,11 @@ PDBReader.prototype = {
return true;
},

// assigns the secondary structure information found in the helix sheet records,
// derives connectivity and assigns assembly information.
// called after parsing to perform any work that requires the complete
// structure to be present:
// (a) assigns the secondary structure information found in the helix
// sheet records, (b) derives connectivity and (c) assigns assembly
// information.
finish : function() {
var chain = null;
for (i = 0; i < this._sheets.length; ++i) {
Expand Down
3 changes: 2 additions & 1 deletion src/mol.js
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,8 @@ derive(Residue, ResidueBase, {
full : function() { return this; },

addAtom : function(name, pos, element) {
var atom = new Atom(this, name, pos, element, this.structure().nextAtomIndex());
var atom = new Atom(this, name, pos, element,
this.structure().nextAtomIndex());
this._atoms.push(atom);
return atom;
},
Expand Down

0 comments on commit 259725e

Please sign in to comment.