소스 검색

Updated builds.

Mr.doob 11 년 전
부모
커밋
2e76fba144
3개의 변경된 파일409개의 추가작업 그리고 360개의 파일을 삭제
  1. 76 26
      build/three.js
  2. 332 333
      build/three.min.js
  3. 1 1
      src/core/BufferGeometry.js

+ 76 - 26
build/three.js

@@ -9228,7 +9228,7 @@ THREE.BufferGeometry.prototype = {
 
 
 	constructor: THREE.BufferGeometry,
 	constructor: THREE.BufferGeometry,
 
 
-	addAttribute: function( name, type, numItems, itemSize ) {
+	addAttribute: function ( name, type, numItems, itemSize ) {
 
 
 		this.attributes[ name ] = {
 		this.attributes[ name ] = {
 
 
@@ -22128,6 +22128,45 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
+	// used by renderBufferDirect for THREE.Line
+	function setupLinesVertexAttributes( material, programAttributes, geometryAttributes, startIndex ) {
+
+		var attributeItem, attributeName, attributePointer, attributeSize;
+
+		for ( attributeName in programAttributes ) {
+
+			attributePointer = programAttributes[ attributeName ];
+			attributeItem = geometryAttributes[ attributeName ];
+			
+			if ( attributePointer >= 0 ) {
+
+				if ( attributeItem ) {
+
+					attributeSize = attributeItem.itemSize;
+					_gl.bindBuffer( _gl.ARRAY_BUFFER, attributeItem.buffer );
+					enableAttribute( attributePointer );
+					_gl.vertexAttribPointer( attributePointer, attributeSize, _gl.FLOAT, false, 0, startIndex * attributeSize * 4 ); // 4 bytes per Float32
+
+				} else if ( material.defaultAttributeValues ) {
+
+					if ( material.defaultAttributeValues[ attributeName ].length === 2 ) {
+
+						_gl.vertexAttrib2fv( attributePointer, material.defaultAttributeValues[ attributeName ] );
+
+					} else if ( material.defaultAttributeValues[ attributeName ].length === 3 ) {
+
+						_gl.vertexAttrib3fv( attributePointer, material.defaultAttributeValues[ attributeName ] );
+
+					}
+
+				}
+
+			}
+
+		}
+
+	}
+
 	function setDirectBuffers ( geometry, hint, dispose ) {
 	function setDirectBuffers ( geometry, hint, dispose ) {
 
 
 		var attributes = geometry.attributes;
 		var attributes = geometry.attributes;
@@ -22467,54 +22506,65 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		} else if ( object instanceof THREE.Line ) {
 		} else if ( object instanceof THREE.Line ) {
 
 
-			if ( updateBuffers ) {
+			var primitives = ( object.type === THREE.LineStrip ) ? _gl.LINE_STRIP : _gl.LINES;
 
 
-				for ( attributeName in programAttributes ) {
+			setLineWidth( material.linewidth );
 
 
-					attributePointer = programAttributes[ attributeName ];
-					attributeItem = geometryAttributes[ attributeName ];
-					
-					if ( attributePointer >= 0 ) {
+			var index = geometryAttributes[ "index" ];
 
 
-						if ( attributeItem ) {
+			// indexed lines
+			
+			if ( index ) {
 
 
-							attributeSize = attributeItem.itemSize;
-							_gl.bindBuffer( _gl.ARRAY_BUFFER, attributeItem.buffer );
-							enableAttribute( attributePointer );
-							_gl.vertexAttribPointer( attributePointer, attributeSize, _gl.FLOAT, false, 0, 0 );
+				var offsets = geometry.offsets;
 
 
-						} else if ( material.defaultAttributeValues && material.defaultAttributeValues[ attributeName ] ) {
+				// if there is more than 1 chunk
+				// must set attribute pointers to use new offsets for each chunk
+				// even if geometry and materials didn't change
 
 
-							if ( material.defaultAttributeValues[ attributeName ].length === 2 ) {
+				if ( offsets.length > 1 ) updateBuffers = true;
 
 
-								_gl.vertexAttrib2fv( attributePointer, material.defaultAttributeValues[ attributeName ] );
+				for ( var i = 0, il = offsets.length; i < il; i ++ ) {
 
 
-							} else if ( material.defaultAttributeValues[ attributeName ].length === 3 ) {
+					var startIndex = offsets[ i ].index;
 
 
-								_gl.vertexAttrib3fv( attributePointer, material.defaultAttributeValues[ attributeName ] );
+					if ( updateBuffers ) {
 
 
-							}
+						setupLinesVertexAttributes(material, programAttributes, geometryAttributes, startIndex);
 
 
-						}
+						// indices
+						_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, index.buffer );
 
 
 					}
 					}
 
 
+					// render indexed lines
+
+					_gl.drawElements( _gl.LINES, offsets[ i ].count, _gl.UNSIGNED_SHORT, offsets[ i ].start * 2 ); // 2 bytes per Uint16Array
+
+					_this.info.render.calls ++;
+					_this.info.render.vertices += offsets[ i ].count; // not really true, here vertices can be shared
+
 				}
 				}
 
 
 			}
 			}
 
 
-			// render lines
+			// non-indexed lines
 
 
-			var primitives = ( object.type === THREE.LineStrip ) ? _gl.LINE_STRIP : _gl.LINES;
+			else {
 
 
-			setLineWidth( material.linewidth );
+				if ( updateBuffers ) {
 
 
-			var position = geometryAttributes[ "position" ];
+					setupLinesVertexAttributes(material, programAttributes, geometryAttributes, 0);
+				}
+
+				var position = geometryAttributes[ "position" ];
+
+				_gl.drawArrays( primitives, 0, position.numItems / 3 );
+				_this.info.render.calls ++;
+				_this.info.render.points += position.numItems;
+			}
 
 
-			_gl.drawArrays( primitives, 0, position.numItems / 3 );
 
 
-			_this.info.render.calls ++;
-			_this.info.render.points += position.numItems;
 
 
 		}
 		}
 
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 332 - 333
build/three.min.js


+ 1 - 1
src/core/BufferGeometry.js

@@ -38,7 +38,7 @@ THREE.BufferGeometry.prototype = {
 
 
 	constructor: THREE.BufferGeometry,
 	constructor: THREE.BufferGeometry,
 
 
-	addAttribute: function( name, type, numItems, itemSize ) {
+	addAttribute: function ( name, type, numItems, itemSize ) {
 
 
 		this.attributes[ name ] = {
 		this.attributes[ name ] = {
 
 

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.