浏览代码

Examples clean up.

Mr.doob 12 年之前
父节点
当前提交
d28d02eea9

+ 8 - 8
examples/canvas_geometry_shapes.html

@@ -32,9 +32,9 @@
 
 			var container, stats;
 
-			var camera, scene, renderer, parent;
+			var camera, scene, renderer;
 
-			var text, plane;
+			var group, text, plane;
 
 			var targetRotation = 0;
 			var targetRotationOnMouseDown = 0;
@@ -58,9 +58,9 @@
 
 				scene = new THREE.Scene();
 
-				parent = new THREE.Object3D();
-				parent.position.y = 50;
-				scene.add( parent );
+				group = new THREE.Object3D();
+				group.position.y = 50;
+				scene.add( group );
 
 				function addShape( shape, color, x, y, z, rx, ry, rz, s ) {
 
@@ -73,7 +73,7 @@
 					mesh.position.set( x, y, z );
 					mesh.rotation.set( rx, ry, rz );
 					mesh.scale.set( s, s, s );
-					parent.add( mesh );
+					group.add( mesh );
 
 					// line
 
@@ -84,7 +84,7 @@
 					line.position.set( x, y, z );
 					line.rotation.set( rx, ry, rz );
 					line.scale.set( s, s, s );
-					parent.add( line );
+					group.add( line );
 
 				}
 
@@ -397,7 +397,7 @@
 
 			function render() {
 
-				parent.rotation.y += ( targetRotation - parent.rotation.y ) * 0.05;
+				group.rotation.y += ( targetRotation - group.rotation.y ) * 0.05;
 				renderer.render( scene, camera );
 
 			}

+ 6 - 6
examples/canvas_geometry_text.html

@@ -31,7 +31,7 @@
 
 			var camera, scene, renderer;
 
-			var text, parent;
+			var group, text;
 
 			var targetRotation = 0;
 			var targetRotationOnMouseDown = 0;
@@ -55,7 +55,7 @@
 				info.style.top = '10px';
 				info.style.width = '100%';
 				info.style.textAlign = 'center';
-				info.innerHTML = 'Simple Dynamic 3D Text Example by <a href="http://www.lab4games.net/zz85/blog">zz85</a><br/>Drag to spin the text';
+				info.innerHTML = 'Simple Dynamic 3D Text Example by <a href="http://www.lab4games.net/zz85/blog">zz85</a><br>Drag to spin the text';
 				container.appendChild( info );
 
 				camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 1, 1000 );
@@ -97,10 +97,10 @@
 				text.rotation.x = 0;
 				text.rotation.y = Math.PI * 2;
 
-				parent = new THREE.Object3D();
-				parent.add( text );
+				group = new THREE.Object3D();
+				group.add( text );
 
-				scene.add( parent );
+				scene.add( group );
 
 				renderer = new THREE.CanvasRenderer();
 				renderer.setSize( window.innerWidth, window.innerHeight );
@@ -212,7 +212,7 @@
 
 			function render() {
 
-				parent.rotation.y += ( targetRotation - parent.rotation.y ) * 0.05;
+				group.rotation.y += ( targetRotation - group.rotation.y ) * 0.05;
 				renderer.render( scene, camera );
 
 			}

+ 8 - 9
examples/canvas_particles_shapes.html

@@ -31,9 +31,9 @@
 
 			var container, stats;
 
-			var camera, scene, renderer, parent;
+			var camera, scene, renderer;
 
-			var text, plane;
+			var group, text, plane;
 
 			var targetRotation = 0;
 			var targetRotationOnMouseDown = 0;
@@ -69,6 +69,9 @@
 
 				scene = new THREE.Scene();
 
+				group = new THREE.Object3D();
+				scene.add( group );
+
 				// Get text from hash
 
 				var string = "THREE.JS";
@@ -106,16 +109,12 @@
 				text.rotation.x = 0;
 				text.rotation.y = Math.PI * 2;
 
-				parent = new THREE.Object3D();
-				parent.add( text );
+				group.add( text );
 
 
 				particleCloud = new THREE.Object3D(); // Just a group
 				particleCloud.y = 800;
-				parent.add( particleCloud );
-
-				scene.add( parent );
-
+				group.add( particleCloud );
 
 				// Create Particle Systems
 
@@ -335,7 +334,7 @@
 				// Pretty cool effect if you enable this
 				//particleCloud.rotation.y += 0.05;
 
-				parent.rotation.y += ( targetRotation - parent.rotation.y ) * 0.05;
+				group.rotation.y += ( targetRotation - group.rotation.y ) * 0.05;
 				renderer.render( scene, camera );
 
 			}

+ 13 - 13
examples/webgl_geometry_shapes.html

@@ -25,9 +25,9 @@
 
 			var container, stats;
 
-			var camera, scene, renderer, parent;
+			var camera, scene, renderer;
 
-			var text, plane;
+			var group, text, plane;
 
 			var targetRotation = 0;
 			var targetRotationOnMouseDown = 0;
@@ -63,9 +63,9 @@
 				light.position.set( 0, 0, 1 );
 				scene.add( light );
 
-				parent = new THREE.Object3D();
-				parent.position.y = 50;
-				scene.add( parent );
+				group = new THREE.Object3D();
+				group.position.y = 50;
+				scene.add( group );
 
 				function addShape( shape, extrudeSettings, color, x, y, z, rx, ry, rz, s ) {
 
@@ -80,7 +80,7 @@
 					mesh.position.set( x, y, z - 125 );
 					mesh.rotation.set( rx, ry, rz );
 					mesh.scale.set( s, s, s );
-					parent.add( mesh );
+					group.add( mesh );
 
 					// 3d shape
 
@@ -90,7 +90,7 @@
 					mesh.position.set( x, y, z - 75 );
 					mesh.rotation.set( rx, ry, rz );
 					mesh.scale.set( s, s, s );
-					parent.add( mesh );
+					group.add( mesh );
 
 					// solid line
 
@@ -98,7 +98,7 @@
 					line.position.set( x, y, z + 25 );
 					line.rotation.set( rx, ry, rz );
 					line.scale.set( s, s, s );
-					parent.add( line );
+					group.add( line );
 
 					// transparent line from real points
 
@@ -106,7 +106,7 @@
 					line.position.set( x, y, z + 75 );
 					line.rotation.set( rx, ry, rz );
 					line.scale.set( s, s, s );
-					parent.add( line );
+					group.add( line );
 
 					// vertices from real points
 
@@ -115,7 +115,7 @@
 					particles.position.set( x, y, z + 75 );
 					particles.rotation.set( rx, ry, rz );
 					particles.scale.set( s, s, s );
-					parent.add( particles );
+					group.add( particles );
 
 					// transparent line from equidistance sampled points
 
@@ -123,7 +123,7 @@
 					line.position.set( x, y, z + 125 );
 					line.rotation.set( rx, ry, rz );
 					line.scale.set( s, s, s );
-					parent.add( line );
+					group.add( line );
 
 					// equidistance sampled points
 
@@ -132,7 +132,7 @@
 					particles2.position.set( x, y, z + 125 );
 					particles2.rotation.set( rx, ry, rz );
 					particles2.scale.set( s, s, s );
-					parent.add( particles2 );
+					group.add( particles2 );
 
 				}
 
@@ -466,7 +466,7 @@
 
 			function render() {
 
-				parent.rotation.y += ( targetRotation - parent.rotation.y ) * 0.05;
+				group.rotation.y += ( targetRotation - group.rotation.y ) * 0.05;
 				renderer.render( scene, camera );
 
 			}

+ 9 - 9
examples/webgl_geometry_text.html

@@ -81,7 +81,7 @@
 			var composer;
 			var effectFXAA;
 
-			var textMesh1, textMesh2, textGeo, material, parent;
+			var group, textMesh1, textMesh2, textGeo, material;
 
 			var firstLetter = true;
 
@@ -227,10 +227,10 @@
 					new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ) // side
 				] );
 
-				parent = new THREE.Object3D();
-				parent.position.y = 100;
+				group = new THREE.Object3D();
+				group.position.y = 100;
 
-				scene.add( parent );
+				scene.add( group );
 
 				createText();
 
@@ -519,7 +519,7 @@
 				textMesh1.rotation.x = 0;
 				textMesh1.rotation.y = Math.PI * 2;
 
-				parent.add( textMesh1 );
+				group.add( textMesh1 );
 
 				if ( mirror ) {
 
@@ -532,7 +532,7 @@
 					textMesh2.rotation.x = Math.PI;
 					textMesh2.rotation.y = Math.PI * 2;
 
-					parent.add( textMesh2 );
+					group.add( textMesh2 );
 
 				}
 
@@ -542,8 +542,8 @@
 
 				updatePermalink();
 
-				parent.remove( textMesh1 );
-				if ( mirror ) parent.remove( textMesh2 );
+				group.remove( textMesh1 );
+				if ( mirror ) group.remove( textMesh2 );
 
 				if ( !text ) return;
 
@@ -627,7 +627,7 @@
 
 			function render() {
 
-				parent.rotation.y += ( targetRotation - parent.rotation.y ) * 0.05;
+				group.rotation.y += ( targetRotation - group.rotation.y ) * 0.05;
 
 				camera.lookAt( cameraTarget );
 

+ 13 - 14
examples/webgl_particles_shapes.html

@@ -83,9 +83,9 @@
 
 			var container, stats;
 
-			var camera, scene, renderer, parent;
+			var camera, scene, renderer;
 
-			var text, plane;
+			var group, text, plane;
 
 			var speed = 50;
 
@@ -197,9 +197,9 @@
 				text.rotation.x = 0;
 				text.rotation.y = Math.PI * 2;
 
-				parent = new THREE.Object3D();
-				parent.add( text );
-				scene.add( parent );
+				group = new THREE.Object3D();
+				group.add( text );
+				scene.add( group );
 
 				// Create particle objects for Three.js
 
@@ -331,15 +331,15 @@
 
 				var shaderMaterial = new THREE.ShaderMaterial( {
 
-					uniforms: 		uniforms,
-					attributes:     attributes,
+					uniforms: uniforms,
+					attributes: attributes,
 
-					vertexShader:   document.getElementById( 'vertexshader' ).textContent,
+					vertexShader: document.getElementById( 'vertexshader' ).textContent,
 					fragmentShader: document.getElementById( 'fragmentshader' ).textContent,
 
-					blending: 		THREE.AdditiveBlending,
-					depthWrite:		false,
-					transparent:	true
+					blending: THREE.AdditiveBlending,
+					depthWrite: false,
+					transparent: true
 
 				});
 
@@ -362,7 +362,7 @@
 
 				}
 
-				parent.add( particleCloud );
+				group.add( particleCloud );
 				particleCloud.y = 800;
 
 
@@ -661,14 +661,13 @@
 				// Pretty cool effect if you enable this
 				// particleCloud.rotation.y += 0.05;
 
-				parent.rotation.y += ( targetRotation - parent.rotation.y ) * 0.05;
+				group.rotation.y += ( targetRotation - group.rotation.y ) * 0.05;
 
 				renderer.clear();
 
 				// renderer.render( scene, camera );
 				composer.render( 0.1 );
 
-
 			}
 
 		</script>