Browse Source

Editor: AlphaTest support.

Mr.doob 10 years ago
parent
commit
59a8e2ec34
3 changed files with 25 additions and 1 deletions
  1. 23 0
      editor/js/Sidebar.Material.js
  2. 1 1
      src/loaders/MaterialLoader.js
  3. 1 0
      src/materials/Material.js

+ 23 - 0
editor/js/Sidebar.Material.js

@@ -346,6 +346,16 @@ Sidebar.Material = function ( editor ) {
 
 	container.add( materialTransparentRow );
 
+	// alpha test
+
+	var materialAlphaTestRow = new UI.Panel();
+	var materialAlphaTest = new UI.Number().setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
+
+	materialAlphaTestRow.add( new UI.Text( 'Alpha Test' ).setWidth( '90px' ) );
+	materialAlphaTestRow.add( materialAlphaTest );
+
+	container.add( materialAlphaTestRow );
+
 	// wireframe
 
 	var materialWireframeRow = new UI.Panel();
@@ -606,6 +616,12 @@ Sidebar.Material = function ( editor ) {
 
 			}
 
+			if ( material.alphaTest !== undefined ) {
+
+				material.alphaTest = materialAlphaTest.getValue();
+
+			}
+
 			if ( material.wireframe !== undefined ) {
 
 				material.wireframe = materialWireframe.getValue();
@@ -658,6 +674,7 @@ Sidebar.Material = function ( editor ) {
 			'blending': materialBlendingRow,
 			'opacity': materialOpacityRow,
 			'transparent': materialTransparentRow,
+			'alphaTest': materialAlphaTestRow,
 			'wireframe': materialWireframeRow
 		};
 
@@ -858,6 +875,12 @@ Sidebar.Material = function ( editor ) {
 
 		}
 
+		if ( material.alphaTest !== undefined ) {
+
+			materialAlphaTest.setValue( material.alphaTest );
+
+		}
+
 		if ( material.wireframe !== undefined ) {
 
 			materialWireframe.setValue( material.wireframe );

+ 1 - 1
src/loaders/MaterialLoader.js

@@ -50,8 +50,8 @@ THREE.MaterialLoader.prototype = {
 		if ( json.side !== undefined ) material.side = json.side;
 		if ( json.opacity !== undefined ) material.opacity = json.opacity;
 		if ( json.transparent !== undefined ) material.transparent = json.transparent;
-		if ( json.wireframe !== undefined ) material.wireframe = json.wireframe;
 		if ( json.alphaTest !== undefined ) material.alphaTest = json.alphaTest;
+		if ( json.wireframe !== undefined ) material.wireframe = json.wireframe;
 
 		// for PointCloudMaterial
 		if ( json.size !== undefined ) material.size = json.size;

+ 1 - 0
src/materials/Material.js

@@ -161,6 +161,7 @@ THREE.Material.prototype = {
 
 		if ( this.opacity < 1 ) data.opacity = this.opacity;
 		if ( this.transparent === true ) data.transparent = this.transparent;
+		if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;
 		if ( this.wireframe === true ) data.wireframe = this.wireframe;
 
 		return data;