2
0
Эх сурвалжийг харах

InstancedMesh: Honor instanceColor in toJSON() and ObjectLoader. (#21486)

* Keep instanceColor for InstancedMesh in toJSON and ObjectLoader

* instanceColor ignored if not present
Michael Harvey 4 жил өмнө
parent
commit
46c947c509

+ 1 - 0
src/core/Object3D.js

@@ -700,6 +700,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 			object.type = 'InstancedMesh';
 			object.type = 'InstancedMesh';
 			object.count = this.count;
 			object.count = this.count;
 			object.instanceMatrix = this.instanceMatrix.toJSON();
 			object.instanceMatrix = this.instanceMatrix.toJSON();
+			if ( this.instanceColor !== null ) object.instanceColor = this.instanceColor.toJSON();
 
 
 		}
 		}
 
 

+ 2 - 0
src/loaders/ObjectLoader.js

@@ -961,9 +961,11 @@ class ObjectLoader extends Loader {
 				material = getMaterial( data.material );
 				material = getMaterial( data.material );
 				const count = data.count;
 				const count = data.count;
 				const instanceMatrix = data.instanceMatrix;
 				const instanceMatrix = data.instanceMatrix;
+				const instanceColor = data.instanceColor;
 
 
 				object = new InstancedMesh( geometry, material, count );
 				object = new InstancedMesh( geometry, material, count );
 				object.instanceMatrix = new BufferAttribute( new Float32Array( instanceMatrix.array ), 16 );
 				object.instanceMatrix = new BufferAttribute( new Float32Array( instanceMatrix.array ), 16 );
+				if ( instanceColor !== undefined ) object.instanceColor = new BufferAttribute( new Float32Array( instanceColor.array ), 3 );
 
 
 				break;
 				break;