Просмотр исходного кода

Fixed bug related to morphColors in JSONLoader. Changed reading of custom attributes from geometry group to material to let material instead of geometry rule of the source of data.

Mikael Emtinger 15 лет назад
Родитель
Сommit
40eae8ae10
2 измененных файлов с 22 добавлено и 2 удалено
  1. 1 1
      src/extras/io/JSONLoader.js
  2. 21 1
      src/renderers/WebGLRenderer.js

+ 1 - 1
src/extras/io/JSONLoader.js

@@ -367,7 +367,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 				for ( c = 0, cl = srcColors.length; c < cl; c += 3 ) {
 
 					color = new THREE.Color( 0xffaa00 );
-					color.setRGB( srcColors[ v ], srcColors[ v + 1 ], srcColors[ v + 2 ] );
+					color.setRGB( srcColors[ c ], srcColors[ c + 1 ], srcColors[ c + 2 ] );
 					dstColors.push( color );
 
 				}

+ 21 - 1
src/renderers/WebGLRenderer.js

@@ -665,6 +665,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 						attribute.needsUpdate = true;
 						attribute.array = new Float32Array( nvertices * size );
 						attribute.buffer = _gl.createBuffer();
+						attribute.buffer.belongsToAttribute = a;
 						
 					}
 
@@ -2484,7 +2485,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		// custom attributes
 
-		if ( geometryGroup.__webglCustomAttributes ) {
+/*		if ( geometryGroup.__webglCustomAttributes ) {
 
 			for( a in geometryGroup.__webglCustomAttributes ) {
 
@@ -2499,9 +2500,28 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			}
 
+		}*/
+
+
+		if ( material.attributes ) {
+
+			for( a in material.attributes ) {
+
+				if( attributes[ a ] >= 0 ) {
+
+					attribute = material.attributes[ a ];
+
+					_gl.bindBuffer( _gl.ARRAY_BUFFER, attribute.buffer );
+					_gl.vertexAttribPointer( attributes[ a ], attribute.size, _gl.FLOAT, false, 0, 0 );
+
+				}
+
+			}
+
 		}
 
 
+
 		// colors
 
 		if ( attributes.color >= 0 ) {

粤ICP备19079148号