|
@@ -606,11 +606,19 @@ var BABYLON;
|
|
if (mesh.material) {
|
|
if (mesh.material) {
|
|
if (mesh.material instanceof BABYLON.StandardMaterial) {
|
|
if (mesh.material instanceof BABYLON.StandardMaterial) {
|
|
serializationObject.materials = serializationObject.materials || [];
|
|
serializationObject.materials = serializationObject.materials || [];
|
|
- serializationObject.materials.push(serializeMaterial(mesh.material));
|
|
|
|
|
|
+ if (!serializationObject.materials.some(function (mat) {
|
|
|
|
+ return mat.id == mesh.material.id;
|
|
|
|
+ })) {
|
|
|
|
+ serializationObject.materials.push(serializeMaterial(mesh.material));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else if (mesh.material instanceof BABYLON.MultiMaterial) {
|
|
else if (mesh.material instanceof BABYLON.MultiMaterial) {
|
|
serializationObject.multiMaterials = serializationObject.multiMaterials || [];
|
|
serializationObject.multiMaterials = serializationObject.multiMaterials || [];
|
|
- serializationObject.multiMaterials.push(serializeMultiMaterial(mesh.material));
|
|
|
|
|
|
+ if (!serializationObject.multiMaterials.some(function (mat) {
|
|
|
|
+ return mat.id == mesh.material.id;
|
|
|
|
+ })) {
|
|
|
|
+ serializationObject.multiMaterials.push(serializeMultiMaterial(mesh.material));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//serialize geometry
|
|
//serialize geometry
|
|
@@ -745,7 +753,6 @@ var BABYLON;
|
|
var serializationObject = {};
|
|
var serializationObject = {};
|
|
toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
|
|
toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
|
|
if (withParents || withChildren) {
|
|
if (withParents || withChildren) {
|
|
- //deliberate for loop! not for each, appended should be processed as well.
|
|
|
|
for (var i = 0; i < toSerialize.length; ++i) {
|
|
for (var i = 0; i < toSerialize.length; ++i) {
|
|
if (withChildren) {
|
|
if (withChildren) {
|
|
toSerialize[i].getDescendants().forEach(function (node) {
|
|
toSerialize[i].getDescendants().forEach(function (node) {
|