0

I'm having difficulty with something that should be fairly simple. I have a single geometry through the json loader. I want to duplicate this geometry and apply a modified version of the material to each. I've tried traversing through the grouped obects. Both need to share the materials from the json file. The only difference will be the value of the materials[9].map and the materials[9].emmissiveMap. Any help or guidance would be extremely apprecieated.

loader.load('chris/7.json', function(geometry, materials) {
for (var k in materials) {
materials[9].map = ballerina;
materials[9].emissiveMap = ballerina;
}
mesh = new THREE.Mesh(geometry, materials);
mesh.scale.x = mesh.scale.y = mesh.scale.z = 282.75;
mesh.translation = geometry.center();
mesh.rotateZ(90);
mesh.geometry.uvsNeedUpdate = true;
mesh.material.needsUpdate = true;

iphone2 = new THREE.Mesh(geometry, materials);
iphone2.scale.x = iphone2.scale.y = iphone2.scale.z = 282.75;
iphone2.translation = geometry.center();
iphone2.rotateZ(-24.7);
iphone2.position.z = -120;
iphone2.position.x = -120;

iphone2.geometry.uvsNeedUpdate = true;
iphone2.material.needsUpdate = true;


group.add( iphone2 );
group.add( mesh );
scene.add( group );

});
crissin
  • 3
  • 1
  • 4
  • What exactly is not working? What are you seeing/expecting? Are you getting any errors? _(Also, you have a loop, but you're not looping anything. Also [don't use for...in for arrays](https://stackoverflow.com/a/500531/3889100).))_ – TheJim01 Jul 21 '17 at 20:22
  • Thanks Jim! I actually solved my problem a few hours after posting. The issue I was getting was when I would create a new array from the existing material array, and apply it to the second mesh, both meshes would share this change. Basically, there was a need for two duplicate material arrays, with a difference only in the map and emissiveMap. – crissin Jul 22 '17 at 03:29
  • If you've solved your problem, please either delete this post, or submit an answer and accept it. – TheJim01 Jul 22 '17 at 07:51

0 Answers0