Bläddra i källkod

Added material.visible property. Fixes #1763.

Mr.doob 13 år sedan
förälder
incheckning
20f0b819ea

+ 2 - 0
src/materials/Material.js

@@ -31,6 +31,8 @@ THREE.Material = function ( parameters ) {
 
 	this.overdraw = parameters.overdraw !== undefined ? parameters.overdraw : false; // Boolean for fixing antialiasing gaps in CanvasRenderer
 
+	this.visible = true;
+
 	this.needsUpdate = true;
 
 }

+ 1 - 1
src/renderers/CanvasRenderer.js

@@ -206,7 +206,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 			material = element.material;
 			material = material instanceof THREE.MeshFaceMaterial ? element.faceMaterial : material;
 
-			if ( material == null || material.opacity == 0 ) continue;
+			if ( material === null || material.visible === false ) continue;
 
 			_bboxRect.empty();
 

+ 1 - 1
src/renderers/SVGRenderer.js

@@ -111,7 +111,7 @@ THREE.SVGRenderer = function () {
 			material = element.material;
 			material = material instanceof THREE.MeshFaceMaterial ? element.faceMaterial : material;
 
-			if ( material == null || material.opacity == 0 ) continue;
+			if ( material === null || material.visible === false ) continue;
 
 			_bboxRect.empty();
 

+ 4 - 0
src/renderers/WebGLRenderer.js

@@ -2886,6 +2886,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	this.renderBufferDirect = function ( camera, lights, fog, material, geometryGroup, object ) {
 
+		if ( material.visible === false ) return;
+
 		var program, attributes, linewidth, primitives, a, attribute;
 
 		program = setProgram( camera, lights, fog, material, object );
@@ -2976,6 +2978,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	this.renderBuffer = function ( camera, lights, fog, material, geometryGroup, object ) {
 
+		if ( material.visible === false ) return;
+
 		var program, attributes, linewidth, primitives, a, attribute, i, il;
 
 		program = setProgram( camera, lights, fog, material, object );