Skip to content

Commit

Permalink
Revert to previous calculation for tube normals
Browse files Browse the repository at this point in the history
Browser caching played a tricked me into thinking the new
approach looks as good as the old one.
  • Loading branch information
biasmv committed Feb 13, 2015
1 parent ad6e8bd commit 33523ee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/gfx/geom-builders.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ function TubeProfile(points, num, strength) {

var normal = vec3.create();
for (var i = 0; i < this._arcs; ++i) {
normal[0] = this._verts[3 * i + 0];
normal[1] = this._verts[3 * i + 1];
var i_prev = i === 0 ? this._arcs - 1 : i - 1;
var i_next = i === this._arcs - 1 ? 0 : i + 1;
normal[0] = this._verts[3 * i_next + 1] - this._verts[3 * i_prev + 1];
normal[1] = this._verts[3 * i_prev] - this._verts[3 * i_next];
vec3.normalize(normal, normal);
this._normals[3 * i] = normal[0];
this._normals[3 * i + 1] = normal[1];
Expand Down

0 comments on commit 33523ee

Please sign in to comment.