Ver código fonte

Examples: Clean up

Mugen87 7 anos atrás
pai
commit
10891f0f62

+ 2 - 2
examples/canvas_lines_colors.html

@@ -85,7 +85,7 @@
 					points = hilbert2D( new THREE.Vector3( 0, 0, 0 ), 400, 4 ),
 					colors2 = [];
 
-				for ( i = 0; i < points.length; i ++ ) {
+				for ( var i = 0; i < points.length; i ++ ) {
 
 					geometry2.vertices.push( points[ i ] );
 
@@ -102,7 +102,7 @@
 					points = hilbert3D( new THREE.Vector3( 0, 0, 0 ), 200, 2, 0, 1, 2, 3, 4, 5, 6, 7 ),
 					colors3 = [];
 
-				for ( i = 0; i < points.length; i ++ ) {
+				for ( var i = 0; i < points.length; i ++ ) {
 
 					geometry3.vertices.push( points[ i ] );
 

+ 1 - 1
examples/css2d_label.html

@@ -70,7 +70,7 @@
 
 				scene2 = new THREE.Scene();
 
-				dirLight = new THREE.DirectionalLight( 0xffffff );
+				var dirLight = new THREE.DirectionalLight( 0xffffff );
 				dirLight.position.set( 0, 0, 1 );
 				scene.add( dirLight );
 

+ 5 - 5
examples/misc_controls_pointerlock.html

@@ -249,7 +249,7 @@
 
 				var position = floorGeometry.attributes.position;
 
-				for ( var i = 0; i < position.count; i ++ ) {
+				for ( var i = 0, l = position.count; i < l; i ++ ) {
 
 					vertex.fromBufferAttribute( position, i );
 
@@ -263,10 +263,10 @@
 
 				floorGeometry = floorGeometry.toNonIndexed(); // ensure each face has unique vertices
 
-				count = floorGeometry.attributes.position.count;
+				position = floorGeometry.attributes.position;
 				var colors = [];
 
-				for ( var i = 0; i < count; i ++ ) {
+				for ( var i = 0, l = position.count; i < l; i ++ ) {
 
 					color.setHSL( Math.random() * 0.3 + 0.5, 0.75, Math.random() * 0.25 + 0.75 );
 					colors.push( color.r, color.g, color.b );
@@ -285,10 +285,10 @@
 				var boxGeometry = new THREE.BoxBufferGeometry( 20, 20, 20 );
 				boxGeometry = boxGeometry.toNonIndexed(); // ensure each face has unique vertices
 
-				count = boxGeometry.attributes.position.count;
+				position = boxGeometry.attributes.position;
 				colors = [];
 
-				for ( var i = 0; i < count; i ++ ) {
+				for ( var i = 0, l = position.count; i < l; i ++ ) {
 
 					color.setHSL( Math.random() * 0.3 + 0.5, 0.75, Math.random() * 0.25 + 0.75 );
 					colors.push( color.r, color.g, color.b );

+ 1 - 1
examples/misc_exporter_stl.html

@@ -42,7 +42,7 @@
 
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
 
-			var scene, camera, renderer, exporter;
+			var scene, camera, renderer, exporter, mesh;
 
 			init();
 			animate();

+ 2 - 2
examples/webgl_morphtargets_sphere.html

@@ -104,7 +104,7 @@
 
 					} );
 
-					points = new THREE.Points( mesh.geometry, pointsMaterial );
+					var points = new THREE.Points( mesh.geometry, pointsMaterial );
 
 					points.morphTargetInfluences = mesh.morphTargetInfluences;
 					points.morphTargetDictionary = mesh.morphTargetDictionary;
@@ -122,7 +122,7 @@
 
 				//
 
-				controls = new THREE.OrbitControls( camera, renderer.domElement );
+				var controls = new THREE.OrbitControls( camera, renderer.domElement );
 				controls.minDistance = 1;
 				controls.maxDistance = 20;
 

+ 1 - 1
examples/webgl_points_sprites.html

@@ -75,7 +75,7 @@
 				var sprite4 = textureLoader.load( 'textures/sprites/snowflake4.png' );
 				var sprite5 = textureLoader.load( 'textures/sprites/snowflake5.png' );
 
-				for ( i = 0; i < 10000; i ++ ) {
+				for ( var i = 0; i < 10000; i ++ ) {
 
 					var x = Math.random() * 2000 - 1000;
 					var y = Math.random() * 2000 - 1000;

+ 3 - 3
examples/webgl_postprocessing_dof2.html

@@ -120,7 +120,7 @@ Use WEBGL Depth buffer support?
 				var shader = THREE.ShaderLib[ 'cube' ];
 				shader.uniforms[ 'tCube' ].value = textureCube;
 
-				material = new THREE.ShaderMaterial( {
+				var skyMaterial = new THREE.ShaderMaterial( {
 
 					fragmentShader: shader.fragmentShader,
 					vertexShader: shader.vertexShader,
@@ -130,8 +130,8 @@ Use WEBGL Depth buffer support?
 
 				} );
 
-				mesh = new THREE.Mesh( new THREE.BoxBufferGeometry( 1000, 1000, 1000 ), material );
-				scene.add( mesh );
+				var sky = new THREE.Mesh( new THREE.BoxBufferGeometry( 1000, 1000, 1000 ), skyMaterial );
+				scene.add( sky );
 
 				// plane particles