فهرست منبع

Examples: Clean up some geometry entities

Mugen87 7 سال پیش
والد
کامیت
05db81a53d

+ 20 - 33
examples/js/ParametricGeometries.js

@@ -36,7 +36,7 @@ THREE.ParametricGeometries = {
 
 	plane: function ( width, height ) {
 
-		return function( u, v, optionalTarget ) {
+		return function ( u, v, optionalTarget ) {
 
 			var result = optionalTarget || new THREE.Vector3();
 
@@ -50,7 +50,7 @@ THREE.ParametricGeometries = {
 
 	},
 
-	mobius: function( u, t, optionalTarget ) {
+	mobius: function ( u, t, optionalTarget ) {
 
 		var result = optionalTarget || new THREE.Vector3();
 
@@ -71,7 +71,7 @@ THREE.ParametricGeometries = {
 
 	},
 
-	mobius3d: function( u, t, optionalTarget ) {
+	mobius3d: function ( u, t, optionalTarget ) {
 
 		var result = optionalTarget || new THREE.Vector3();
 
@@ -104,7 +104,7 @@ THREE.ParametricGeometries = {
  *
  *********************************************/
 
-THREE.ParametricGeometries.TubeGeometry = function( path, segments, radius, segmentsRadius, closed, debug ) {
+THREE.ParametricGeometries.TubeGeometry = function ( path, segments, radius, segmentsRadius, closed, debug ) {
 
 	this.path = path;
 	this.segments = segments || 64;
@@ -113,17 +113,7 @@ THREE.ParametricGeometries.TubeGeometry = function( path, segments, radius, segm
 	this.closed = closed || false;
 	if ( debug ) this.debug = new THREE.Object3D();
 
-
-	var scope = this,
-
-		tangent, normal, binormal,
-
-		numpoints = this.segments + 1,
-
-		x, y, z, tx, ty, tz, u, v,
-
-		cx, cy, pos,
-		i, j, ip, jp, a, b, c, d, uva, uvb, uvc, uvd;
+	var scope = this, numpoints = this.segments + 1;
 
 	var frames = path.computeFrenetFrames( segments, closed ),
 		tangents = frames.tangents,
@@ -131,26 +121,25 @@ THREE.ParametricGeometries.TubeGeometry = function( path, segments, radius, segm
 		binormals = frames.binormals;
 
 	// proxy internals
+
 	this.tangents = tangents;
 	this.normals = normals;
 	this.binormals = binormals;
 
-
-
-	var ParametricTube = function( u, v, optionalTarget ) {
+	var ParametricTube = function ( u, v, optionalTarget ) {
 
 		var result = optionalTarget || new THREE.Vector3();
 
 		v *= 2 * Math.PI;
 
-		i = u * ( numpoints - 1 );
+		var i = u * ( numpoints - 1 );
 		i = Math.floor( i );
 
-		pos = path.getPointAt( u );
+		var pos = path.getPointAt( u );
 
-		tangent = tangents[ i ];
-		normal = normals[ i ];
-		binormal = binormals[ i ];
+		var tangent = tangents[ i ];
+		var normal = normals[ i ];
+		var binormal = binormals[ i ];
 
 		if ( scope.debug ) {
 
@@ -160,8 +149,8 @@ THREE.ParametricGeometries.TubeGeometry = function( path, segments, radius, segm
 
 		}
 
-		cx = - scope.radius * Math.cos( v ); // TODO: Hack: Negating it so it faces outside.
-		cy = scope.radius * Math.sin( v );
+		var cx = - scope.radius * Math.cos( v ); // TODO: Hack: Negating it so it faces outside.
+		var cy = scope.radius * Math.sin( v );
 
 		pos.x += cx * normal.x + cy * binormal.x;
 		pos.y += cx * normal.y + cy * binormal.y;
@@ -179,15 +168,13 @@ THREE.ParametricGeometries.TubeGeometry.prototype = Object.create( THREE.Geometr
 THREE.ParametricGeometries.TubeGeometry.prototype.constructor = THREE.ParametricGeometries.TubeGeometry;
 
 
- /*********************************************
+/*********************************************
   *
   * Parametric Replacement for TorusKnotGeometry
   *
   *********************************************/
 THREE.ParametricGeometries.TorusKnotGeometry = function ( radius, tube, segmentsT, segmentsR, p, q ) {
 
-	var scope = this;
-
 	this.radius = radius || 200;
 	this.tube = tube || 40;
 	this.segmentsT = segmentsT || 64;
@@ -204,7 +191,7 @@ THREE.ParametricGeometries.TorusKnotGeometry = function ( radius, tube, segments
 	TorusKnotCurve.prototype = Object.create( THREE.Curve.prototype );
 	TorusKnotCurve.prototype.constructor = TorusKnotCurve;
 
-	TorusKnotCurve.prototype.getPoint = function( t ){
+	TorusKnotCurve.prototype.getPoint = function ( t ) {
 
 		t *= Math.PI * 2;
 
@@ -230,12 +217,12 @@ THREE.ParametricGeometries.TorusKnotGeometry.prototype = Object.create( THREE.Ge
 THREE.ParametricGeometries.TorusKnotGeometry.prototype.constructor = THREE.ParametricGeometries.TorusKnotGeometry;
 
 
- /*********************************************
+/*********************************************
   *
   * Parametric Replacement for SphereGeometry
   *
   *********************************************/
-THREE.ParametricGeometries.SphereGeometry = function( size, u, v ) {
+THREE.ParametricGeometries.SphereGeometry = function ( size, u, v ) {
 
 	function sphere( u, v, optionalTarget ) {
 
@@ -260,13 +247,13 @@ THREE.ParametricGeometries.SphereGeometry.prototype = Object.create( THREE.Geome
 THREE.ParametricGeometries.SphereGeometry.prototype.constructor = THREE.ParametricGeometries.SphereGeometry;
 
 
- /*********************************************
+/*********************************************
   *
   * Parametric Replacement for PlaneGeometry
   *
   *********************************************/
 
-THREE.ParametricGeometries.PlaneGeometry = function( width, depth, segmentsWidth, segmentsDepth ) {
+THREE.ParametricGeometries.PlaneGeometry = function ( width, depth, segmentsWidth, segmentsDepth ) {
 
 	function plane( u, v, optionalTarget ) {
 

+ 8 - 9
examples/js/QuickHull.js

@@ -5,7 +5,7 @@
  *
  */
 
-( function() {
+( function () {
 
 	var Visible = 0;
 	var Deleted = 1;
@@ -348,7 +348,7 @@
 
 			// compute the min/max vertex on all six directions
 
-			for ( i = 0, l = this.vertices.length; i < l ; i ++ ) {
+			for ( i = 0, l = this.vertices.length; i < l; i ++ ) {
 
 				var vertex = this.vertices[ i ];
 				var point = vertex.point;
@@ -400,7 +400,7 @@
 
 			var line3, plane, closestPoint;
 
-			return function computeInitialHull () {
+			return function computeInitialHull() {
 
 				if ( line3 === undefined ) {
 
@@ -562,7 +562,7 @@
 
 				for ( i = 0, l = vertices.length; i < l; i ++ ) {
 
-					vertex = vertices[i];
+					vertex = vertices[ i ];
 
 					if ( vertex !== v0 && vertex !== v1 && vertex !== v2 && vertex !== v3 ) {
 
@@ -785,7 +785,6 @@
 		addVertexToHull: function ( eyeVertex ) {
 
 			var horizon = [];
-			var i, face;
 
 			this.unassigned.clear();
 
@@ -856,7 +855,7 @@
 
 	Object.assign( Face, {
 
-		create: function( a, b, c ) {
+		create: function ( a, b, c ) {
 
 			var face = new Face();
 
@@ -908,7 +907,7 @@
 
 			var triangle;
 
-			return function compute () {
+			return function compute() {
 
 				if ( triangle === undefined ) triangle = new THREE.Triangle();
 
@@ -1202,7 +1201,7 @@
 
 		},
 
-		isEmpty: function() {
+		isEmpty: function () {
 
 			return this.head === null;
 
@@ -1215,4 +1214,4 @@
 	THREE.QuickHull = QuickHull;
 
 
-} ) ();
+} )();

+ 2 - 2
examples/js/geometries/ConvexGeometry.js

@@ -2,7 +2,7 @@
  * @author Mugen87 / https://github.com/Mugen87
  */
 
-( function() {
+( function () {
 
 	// ConvexGeometry
 
@@ -82,4 +82,4 @@
 	THREE.ConvexGeometry = ConvexGeometry;
 	THREE.ConvexBufferGeometry = ConvexBufferGeometry;
 
-} ) ();
+} )();

+ 23 - 23
examples/js/geometries/DecalGeometry.js

@@ -16,9 +16,9 @@
  *
  */
 
-( function() {
+( function () {
 
-  function DecalGeometry( mesh, position, orientation, size ) {
+	function DecalGeometry( mesh, position, orientation, size ) {
 
   	THREE.BufferGeometry.call( this );
 
@@ -54,7 +54,7 @@
 
   	function generate() {
 
-  		var i, j;
+  		var i;
   		var geometry = new THREE.BufferGeometry();
   		var decalVertices = [];
 
@@ -113,12 +113,12 @@
 
   		// second, clip the geometry so that it doesn't extend out from the projector
 
-  		decalVertices = clipGeometry( decalVertices, plane.set(   1,   0,   0 ) );
-  		decalVertices = clipGeometry( decalVertices, plane.set( - 1,   0,   0 ) );
-  		decalVertices = clipGeometry( decalVertices, plane.set(   0,   1,   0 ) );
-  		decalVertices = clipGeometry( decalVertices, plane.set(   0, - 1,   0 ) );
-  		decalVertices = clipGeometry( decalVertices, plane.set(   0,   0,   1 ) );
-  		decalVertices = clipGeometry( decalVertices, plane.set(   0,   0, - 1 ) );
+  		decalVertices = clipGeometry( decalVertices, plane.set( 1, 0, 0 ) );
+  		decalVertices = clipGeometry( decalVertices, plane.set( - 1, 0, 0 ) );
+  		decalVertices = clipGeometry( decalVertices, plane.set( 0, 1, 0 ) );
+  		decalVertices = clipGeometry( decalVertices, plane.set( 0, - 1, 0 ) );
+  		decalVertices = clipGeometry( decalVertices, plane.set( 0, 0, 1 ) );
+  		decalVertices = clipGeometry( decalVertices, plane.set( 0, 0, - 1 ) );
 
   		// third, generate final vertices, normals and uvs
 
@@ -332,28 +332,28 @@
 
   	}
 
-  }
+	}
 
-  DecalGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-  DecalGeometry.prototype.constructor = DecalGeometry;
+	DecalGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
+	DecalGeometry.prototype.constructor = DecalGeometry;
 
-  // helper
+	// helper
 
-  function DecalVertex( position, normal ) {
+	function DecalVertex( position, normal ) {
 
-  	this.position = position;
-  	this.normal = normal;
+		this.position = position;
+		this.normal = normal;
 
-  }
+	}
 
-  DecalVertex.prototype.clone = function() {
+	DecalVertex.prototype.clone = function () {
 
-  	return new DecalVertex( this.position.clone(), this.normal.clone() );
+		return new DecalVertex( this.position.clone(), this.normal.clone() );
 
-  };
+	};
 
-  // export
+	// export
 
-  THREE.DecalGeometry = DecalGeometry;
+	THREE.DecalGeometry = DecalGeometry;
 
-} ) ();
+} )();

+ 7 - 7
examples/js/geometries/hilbert2D.js

@@ -18,9 +18,9 @@
 function hilbert2D( center, size, iterations, v0, v1, v2, v3 ) {
 
 	// Default Vars
-	var center     = undefined !== center ? center : new THREE.Vector3( 0, 0, 0 ),
-		size       = undefined !== size ? size : 10,
-		half       = size / 2,
+	var center = undefined !== center ? center : new THREE.Vector3( 0, 0, 0 ),
+		size = undefined !== size ? size : 10,
+		half = size / 2,
 		iterations = undefined !== iterations ? iterations : 1,
 		v0 = undefined !== v0 ? v0 : 0,
 		v1 = undefined !== v1 ? v1 : 1,
@@ -47,10 +47,10 @@ function hilbert2D( center, size, iterations, v0, v1, v2, v3 ) {
 
 		var tmp = [];
 
-		Array.prototype.push.apply( tmp, hilbert2D ( vec[ 0 ], half, iterations, v0, v3, v2, v1 ) );
-		Array.prototype.push.apply( tmp, hilbert2D ( vec[ 1 ], half, iterations, v0, v1, v2, v3 ) );
-		Array.prototype.push.apply( tmp, hilbert2D ( vec[ 2 ], half, iterations, v0, v1, v2, v3 ) );
-		Array.prototype.push.apply( tmp, hilbert2D ( vec[ 3 ], half, iterations, v2, v1, v0, v3 ) );
+		Array.prototype.push.apply( tmp, hilbert2D( vec[ 0 ], half, iterations, v0, v3, v2, v1 ) );
+		Array.prototype.push.apply( tmp, hilbert2D( vec[ 1 ], half, iterations, v0, v1, v2, v3 ) );
+		Array.prototype.push.apply( tmp, hilbert2D( vec[ 2 ], half, iterations, v0, v1, v2, v3 ) );
+		Array.prototype.push.apply( tmp, hilbert2D( vec[ 3 ], half, iterations, v2, v1, v0, v3 ) );
 
 		// Return recursive call
 		return tmp;

+ 11 - 11
examples/js/geometries/hilbert3D.js

@@ -27,9 +27,9 @@
 function hilbert3D( center, size, iterations, v0, v1, v2, v3, v4, v5, v6, v7 ) {
 
 	// Default Vars
-	var center     = undefined !== center ? center : new THREE.Vector3( 0, 0, 0 ),
-		size       = undefined !== size ? size : 10,
-		half       = size / 2,
+	var center = undefined !== center ? center : new THREE.Vector3( 0, 0, 0 ),
+		size = undefined !== size ? size : 10,
+		half = size / 2,
 		iterations = undefined !== iterations ? iterations : 1,
 		v0 = undefined !== v0 ? v0 : 0,
 		v1 = undefined !== v1 ? v1 : 1,
@@ -68,14 +68,14 @@ function hilbert3D( center, size, iterations, v0, v1, v2, v3, v4, v5, v6, v7 ) {
 
 		var tmp = [];
 
-		Array.prototype.push.apply( tmp, hilbert3D ( vec[ 0 ], half, iterations, v0, v3, v4, v7, v6, v5, v2, v1 ) );
-		Array.prototype.push.apply( tmp, hilbert3D ( vec[ 1 ], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3 ) );
-		Array.prototype.push.apply( tmp, hilbert3D ( vec[ 2 ], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3 ) );
-		Array.prototype.push.apply( tmp, hilbert3D ( vec[ 3 ], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5 ) );
-		Array.prototype.push.apply( tmp, hilbert3D ( vec[ 4 ], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5 ) );
-		Array.prototype.push.apply( tmp, hilbert3D ( vec[ 5 ], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7 ) );
-		Array.prototype.push.apply( tmp, hilbert3D ( vec[ 6 ], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7 ) );
-		Array.prototype.push.apply( tmp, hilbert3D ( vec[ 7 ], half, iterations, v6, v5, v2, v1, v0, v3, v4, v7 ) );
+		Array.prototype.push.apply( tmp, hilbert3D( vec[ 0 ], half, iterations, v0, v3, v4, v7, v6, v5, v2, v1 ) );
+		Array.prototype.push.apply( tmp, hilbert3D( vec[ 1 ], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3 ) );
+		Array.prototype.push.apply( tmp, hilbert3D( vec[ 2 ], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3 ) );
+		Array.prototype.push.apply( tmp, hilbert3D( vec[ 3 ], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5 ) );
+		Array.prototype.push.apply( tmp, hilbert3D( vec[ 4 ], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5 ) );
+		Array.prototype.push.apply( tmp, hilbert3D( vec[ 5 ], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7 ) );
+		Array.prototype.push.apply( tmp, hilbert3D( vec[ 6 ], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7 ) );
+		Array.prototype.push.apply( tmp, hilbert3D( vec[ 7 ], half, iterations, v6, v5, v2, v1, v0, v3, v4, v7 ) );
 
 		// Return recursive call
 		return tmp;