Просмотр исходного кода

Improve styling, generate module using modularize.js

Justin 6 лет назад
Родитель
Сommit
8f1651e093

+ 13 - 13
examples/js/loaders/STLLoader.js

@@ -149,7 +149,7 @@ THREE.STLLoader.prototype = {
 					( reader.getUint8( index + 5 ) == 0x3D /*'='*/ ) ) {
 
 					hasColors = true;
-					colors = new Float32Array(faces * 3 * 3);
+					colors = new Float32Array( faces * 3 * 3 );
 
 					defaultR = reader.getUint8( index + 6 ) / 255;
 					defaultG = reader.getUint8( index + 7 ) / 255;
@@ -165,8 +165,8 @@ THREE.STLLoader.prototype = {
 
 			var geometry = new THREE.BufferGeometry();
 
-			var vertices = new Float32Array(faces * 3 * 3);
-			var normals = new Float32Array(faces * 3 * 3);
+			var vertices = new Float32Array( faces * 3 * 3 );
+			var normals = new Float32Array( faces * 3 * 3 );
 
 			for ( var face = 0; face < faces; face ++ ) {
 
@@ -200,21 +200,21 @@ THREE.STLLoader.prototype = {
 				for ( var i = 1; i <= 3; i ++ ) {
 
 					var vertexstart = start + i * 12;
-					var componentIdx = (face * 3 * 3) + ((i - 1) * 3);
+					var componentIdx = ( face * 3 * 3 ) + ( ( i - 1 ) * 3 );
 					
-					vertices[componentIdx] = reader.getFloat32( vertexstart, true );
-					vertices[componentIdx + 1] = reader.getFloat32( vertexstart + 4, true );
-					vertices[componentIdx + 2] = reader.getFloat32( vertexstart + 8, true );
+					vertices[ componentIdx ] = reader.getFloat32( vertexstart, true );
+					vertices[ componentIdx + 1 ] = reader.getFloat32( vertexstart + 4, true );
+					vertices[ componentIdx + 2 ] = reader.getFloat32( vertexstart + 8, true );
 
-					normals[componentIdx] = normalX;
-					normals[componentIdx + 1] = normalY;
-					normals[componentIdx + 2] = normalZ;
+					normals[ componentIdx ] = normalX;
+					normals[ componentIdx + 1 ] = normalY;
+					normals[ componentIdx + 2 ] = normalZ;
 
 					if ( hasColors ) {
 
-						colors[componentIdx] = r;
-						colors[componentIdx + 1] = g;
-						colors[componentIdx + 2] = b;
+						colors[ componentIdx ] = r;
+						colors[ componentIdx + 1 ] = g;
+						colors[ componentIdx + 2 ] = b;
 
 					}
 

+ 1 - 0
examples/jsm/loaders/GLTFLoader.js

@@ -2205,6 +2205,7 @@ var GLTFLoader = ( function () {
 				pointsMaterial.color.copy( material.color );
 				pointsMaterial.map = material.map;
 				pointsMaterial.lights = false; // PointsMaterial doesn't support lights yet
+				pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px
 
 				this.cache.add( cacheKey, pointsMaterial );
 

+ 17 - 17
examples/jsm/loaders/STLLoader.js

@@ -159,7 +159,7 @@ STLLoader.prototype = {
 					( reader.getUint8( index + 5 ) == 0x3D /*'='*/ ) ) {
 
 					hasColors = true;
-					colors = new Float32Array(faces * 3 * 3);
+					colors = new Float32Array( faces * 3 * 3 );
 
 					defaultR = reader.getUint8( index + 6 ) / 255;
 					defaultG = reader.getUint8( index + 7 ) / 255;
@@ -173,10 +173,10 @@ STLLoader.prototype = {
 			var dataOffset = 84;
 			var faceLength = 12 * 4 + 2;
 
-			var geometry = new THREE.BufferGeometry();
+			var geometry = new BufferGeometry();
 
-			var vertices = new Float32Array(faces * 3 * 3);
-			var normals = new Float32Array(faces * 3 * 3);
+			var vertices = new Float32Array( faces * 3 * 3 );
+			var normals = new Float32Array( faces * 3 * 3 );
 
 			for ( var face = 0; face < faces; face ++ ) {
 
@@ -210,21 +210,21 @@ STLLoader.prototype = {
 				for ( var i = 1; i <= 3; i ++ ) {
 
 					var vertexstart = start + i * 12;
-					var componentIdx = (face * 3 * 3) + ((i - 1) * 3);
+					var componentIdx = ( face * 3 * 3 ) + ( ( i - 1 ) * 3 );
 					
-					vertices[componentIdx] = reader.getFloat32( vertexstart, true );
-					vertices[componentIdx + 1] = reader.getFloat32( vertexstart + 4, true );
-					vertices[componentIdx + 2] = reader.getFloat32( vertexstart + 8, true );
+					vertices[ componentIdx ] = reader.getFloat32( vertexstart, true );
+					vertices[ componentIdx + 1 ] = reader.getFloat32( vertexstart + 4, true );
+					vertices[ componentIdx + 2 ] = reader.getFloat32( vertexstart + 8, true );
 
-					normals[componentIdx] = normalX;
-					normals[componentIdx + 1] = normalY;
-					normals[componentIdx + 2] = normalZ;
+					normals[ componentIdx ] = normalX;
+					normals[ componentIdx + 1 ] = normalY;
+					normals[ componentIdx + 2 ] = normalZ;
 
 					if ( hasColors ) {
 
-						colors[componentIdx] = r;
-						colors[componentIdx + 1] = g;
-						colors[componentIdx + 2] = b;
+						colors[ componentIdx ] = r;
+						colors[ componentIdx + 1 ] = g;
+						colors[ componentIdx + 2 ] = b;
 
 					}
 
@@ -232,12 +232,12 @@ STLLoader.prototype = {
 
 			}
 
-			geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
-			geometry.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
+			geometry.addAttribute( 'position', new BufferAttribute( vertices, 3 ) );
+			geometry.addAttribute( 'normal', new BufferAttribute( normals, 3 ) );
 
 			if ( hasColors ) {
 
-				geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) );
+				geometry.addAttribute( 'color', new BufferAttribute( colors, 3 ) );
 				geometry.hasColors = true;
 				geometry.alpha = alpha;