فهرست منبع

Geometry.copy() and .merge() do not handle geometry.colors (#9627)

* copy colors in Geometry.copy();

* merge colors

* correct  declaration
aardgoose 9 سال پیش
والد
کامیت
068472f62d
1فایلهای تغییر یافته به همراه20 افزوده شده و 1 حذف شده
  1. 20 1
      src/core/Geometry.js

+ 20 - 1
src/core/Geometry.js

@@ -683,7 +683,9 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
 		faces1 = this.faces,
 		faces2 = geometry.faces,
 		uvs1 = this.faceVertexUvs[ 0 ],
-		uvs2 = geometry.faceVertexUvs[ 0 ];
+		uvs2 = geometry.faceVertexUvs[ 0 ],
+		colors1 = this.colors,
+		colors2 = geometry.colors;
 
 		if ( materialIndexOffset === undefined ) materialIndexOffset = 0;
 
@@ -707,6 +709,14 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
 
 		}
 
+		// colors
+
+		for ( var i = 0, il = colors2.length; i < il; i ++ ) {
+
+			colors1.push( colors2[ i ].clone() );
+
+		}
+
 		// faces
 
 		for ( i = 0, il = faces2.length; i < il; i ++ ) {
@@ -1159,6 +1169,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
 		this.vertices = [];
 		this.faces = [];
 		this.faceVertexUvs = [ [] ];
+		this.colors = [];
 
 		var vertices = source.vertices;
 
@@ -1168,6 +1179,14 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
 
 		}
 
+		var colors = source.colors;
+
+		for ( var i = 0, il = colors.length; i < il; i ++ ) {
+
+			this.colors.push( colors[ i ].clone() );
+
+		}
+
 		var faces = source.faces;
 
 		for ( var i = 0, il = faces.length; i < il; i ++ ) {