Skip to content

Commit

Permalink
MarchingCubes clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Aug 13, 2015
1 parent e02d806 commit d84d1bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions examples/js/MarchingCubes.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors )
this.vlist = new Float32Array( 12 * 3 );
this.nlist = new Float32Array( 12 * 3 );

this.firstDraw = true;

// immediate render mode simulator

this.maxCount = 4096; // TODO: find the fastest size for this buffer
Expand Down Expand Up @@ -430,12 +428,14 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors )

this.end = function( renderCallback ) {

if ( this.count === 0 )
return;
if ( this.count === 0 ) return;

for ( var i = this.count * 3; i < this.positionArray.length; i ++ ) {

for ( var i = this.count * 3; i < this.positionArray.length; i ++ )
this.positionArray[ i ] = 0.0;

}

this.hasPositions = true;
this.hasNormals = true;

Expand Down Expand Up @@ -657,22 +657,22 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors )

// Triangulate. Yeah, this is slow.

var q, x, y, z, fx, fy, fz, y_offset, z_offset, smin2 = this.size - 2;
var smin2 = this.size - 2;

for ( z = 1; z < smin2; z ++ ) {
for ( var z = 1; z < smin2; z ++ ) {

z_offset = this.size2 * z;
fz = ( z - this.halfsize ) / this.halfsize; //+ 1
var z_offset = this.size2 * z;
var fz = ( z - this.halfsize ) / this.halfsize; //+ 1

for ( y = 1; y < smin2; y ++ ) {
for ( var y = 1; y < smin2; y ++ ) {

y_offset = z_offset + this.size * y;
fy = ( y - this.halfsize ) / this.halfsize; //+ 1
var y_offset = z_offset + this.size * y;
var fy = ( y - this.halfsize ) / this.halfsize; //+ 1

for ( x = 1; x < smin2; x ++ ) {
for ( var x = 1; x < smin2; x ++ ) {

fx = ( x - this.halfsize ) / this.halfsize; //+ 1
q = y_offset + x;
var fx = ( x - this.halfsize ) / this.halfsize; //+ 1
var q = y_offset + x;

this.polygonize( fx, fy, fz, q, this.isolation, renderCallback );

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_marchingcubes.html
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@

h.add( effectController, "speed", 0.1, 8.0, 0.05 );
h.add( effectController, "numBlobs", 1, 50, 1 );
h.add( effectController, "resolution", 14, 40, 1 );
h.add( effectController, "resolution", 14, 100, 1 );
h.add( effectController, "isolation", 10, 300, 1 );

h.add( effectController, "floor" );
Expand Down

0 comments on commit d84d1bc

Please sign in to comment.