Bladeren bron

BufferGeometry: Added setDrawRange(). See #7057.

Mr.doob 10 jaren geleden
bovenliggende
commit
dd1cec7287
2 gewijzigde bestanden met toevoegingen van 15 en 4 verwijderingen
  1. 9 0
      src/core/BufferGeometry.js
  2. 6 4
      src/renderers/WebGLRenderer.js

+ 9 - 0
src/core/BufferGeometry.js

@@ -22,6 +22,8 @@ THREE.BufferGeometry = function () {
 	this.boundingBox = null;
 	this.boundingSphere = null;
 
+	this.drawRange = { start: 0, count: Infinity };
+
 };
 
 THREE.BufferGeometry.prototype = {
@@ -121,6 +123,13 @@ THREE.BufferGeometry.prototype = {
 
 	},
 
+	setDrawRange: function ( start, count ) {
+
+		this.drawRange.start = start;
+		this.drawRange.count = count;
+
+	},
+
 	applyMatrix: function ( matrix ) {
 
 		var position = this.attributes.position;

+ 6 - 4
src/renderers/WebGLRenderer.js

@@ -837,7 +837,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			if ( index !== null ) {
 
-				count = index.array.length;
+				count = index.count;
 
 			} else if ( position instanceof THREE.InterleavedBufferAttribute ) {
 
@@ -845,13 +845,15 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			} else {
 
-				count = position.array.length / 3;
+				count = position.count;
 
 			}
 
+			var drawRange = geometry.drawRange;
+
 			group = {
-				start: 0,
-				count: count
+				start: drawRange.start,
+				count: Math.min( drawRange.count, count )
 			};
 
 		}