Przeglądaj źródła

optional spherical option

sunag 8 lat temu
rodzic
commit
d392a82cc5

+ 31 - 6
examples/js/nodes/materials/SpriteNode.js

@@ -7,6 +7,7 @@ THREE.SpriteNode = function () {
 	THREE.GLNode.call( this );
 	THREE.GLNode.call( this );
 
 
 	this.color = new THREE.ColorNode( 0xEEEEEE );
 	this.color = new THREE.ColorNode( 0xEEEEEE );
+	this.spherical = true;
 
 
 };
 };
 
 
@@ -59,18 +60,42 @@ THREE.SpriteNode.prototype.build = function ( builder ) {
 			// ignore position from modelMatrix (use vary position)
 			// ignore position from modelMatrix (use vary position)
 			'modelMtx[3][0] = 0.0;',
 			'modelMtx[3][0] = 0.0;',
 			'modelMtx[3][1] = 0.0;',
 			'modelMtx[3][1] = 0.0;',
-			'modelMtx[3][2] = 0.0;',
+			'modelMtx[3][2] = 0.0;'
+);
 
 
+		if ( ! this.spherical ) {
+
+			output.push(
+
+			'modelMtx[1][1] = 1.0;'
+
+			);
+
+		}
+
+		output.push(
 			// http://www.geeks3d.com/20140807/billboarding-vertex-shader-glsl/
 			// http://www.geeks3d.com/20140807/billboarding-vertex-shader-glsl/
 			// First colunm.
 			// First colunm.
 			'modelViewMtx[0][0] = 1.0;',
 			'modelViewMtx[0][0] = 1.0;',
 			'modelViewMtx[0][1] = 0.0;',
 			'modelViewMtx[0][1] = 0.0;',
-			'modelViewMtx[0][2] = 0.0;',
+			'modelViewMtx[0][2] = 0.0;'
+
+		);
+
+		if ( this.spherical ) {
+
+			output.push(
+
+				// Second colunm.
+				'modelViewMtx[1][0] = 0.0;',
+				'modelViewMtx[1][1] = 1.0;',
+				'modelViewMtx[1][2] = 0.0;'
 
 
-			// Second colunm.
-			'modelViewMtx[1][0] = 0.0;',
-			'modelViewMtx[1][1] = 1.0;',
-			'modelViewMtx[1][2] = 0.0;',
+			);
+
+		}
+
+		output.push(
 
 
 			// Thrid colunm.
 			// Thrid colunm.
 			'modelViewMtx[2][0] = 0.0;',
 			'modelViewMtx[2][0] = 0.0;',

+ 1 - 1
examples/js/nodes/materials/SpriteNodeMaterial.js

@@ -14,4 +14,4 @@ THREE.SpriteNodeMaterial.prototype = Object.create( THREE.NodeMaterial.prototype
 THREE.SpriteNodeMaterial.prototype.constructor = THREE.SpriteNodeMaterial;
 THREE.SpriteNodeMaterial.prototype.constructor = THREE.SpriteNodeMaterial;
 
 
 THREE.NodeMaterial.addShortcuts( THREE.SpriteNodeMaterial.prototype, 'node',
 THREE.NodeMaterial.addShortcuts( THREE.SpriteNodeMaterial.prototype, 'node',
-[ 'color', 'alpha', 'transform' ] );
+[ 'color', 'alpha', 'transform', 'spherical' ] );

+ 1 - 0
examples/webgl_sprites_nodes.html

@@ -200,6 +200,7 @@
 			sprite2.material.color = new THREE.TextureNode( walkingManTexture );
 			sprite2.material.color = new THREE.TextureNode( walkingManTexture );
 			sprite2.material.color.coord = createHorizontalSpriteSheetNode( 8, 30 );
 			sprite2.material.color.coord = createHorizontalSpriteSheetNode( 8, 30 );
 			sprite2.material.color = new THREE.Math1Node( sprite2.material.color, THREE.Math1Node.INVERT );
 			sprite2.material.color = new THREE.Math1Node( sprite2.material.color, THREE.Math1Node.INVERT );
+			sprite2.material.spherical = false; // look at camera horizontally only, very used to vegetation
 			sprite2.material.build();
 			sprite2.material.build();
 
 
 			var sineWaveFunction = new THREE.FunctionNode( [
 			var sineWaveFunction = new THREE.FunctionNode( [