Browse Source

WebGLRenderer: Using WireframeGeometry when material.wireframe. See #6957.

Mr.doob 10 years ago
parent
commit
1fbd6c2f73
2 changed files with 13 additions and 1 deletions
  1. 9 0
      src/renderers/WebGLRenderer.js
  2. 4 1
      src/renderers/webgl/WebGLObjects.js

+ 9 - 0
src/renderers/WebGLRenderer.js

@@ -1022,6 +1022,15 @@ THREE.WebGLRenderer = function ( parameters ) {
 			mode = _gl.LINES;
 			mode = _gl.LINES;
 			state.setLineWidth( material.wireframeLinewidth * pixelRatio );
 			state.setLineWidth( material.wireframeLinewidth * pixelRatio );
 
 
+			if ( geometry._wireframe === undefined ) {
+
+				geometry._wireframe = new THREE.WireframeGeometry( geometry );
+				objects.updateAttribute( geometry._wireframe.attributes.position );
+
+			}
+
+			geometry = geometry._wireframe;
+
 		}
 		}
 
 
 		var index = geometry.attributes.index;
 		var index = geometry.attributes.index;

+ 4 - 1
src/renderers/webgl/WebGLObjects.js

@@ -76,7 +76,7 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
 
 
 	};
 	};
 
 
-	this.update = function ( object ) {
+	function update( object ) {
 
 
 		// TODO: Avoid updating twice (when using shadowMap). Maybe add frame counter.
 		// TODO: Avoid updating twice (when using shadowMap). Maybe add frame counter.
 
 
@@ -197,6 +197,9 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
 
 
 	};
 	};
 
 
+	this.update = update;
+	this.updateAttribute = updateAttribute;
+
 	this.clear = function () {
 	this.clear = function () {
 
 
 		objects = {};
 		objects = {};