private static void ResolveMultipleInheritedContainer(IIContainerObject container) { string helperPropBuffer = string.Empty; container.BabylonContainerHelper().GetUserPropBuffer(ref helperPropBuffer); List <IINode> containerHierarchy = new List <IINode>() { container.ContainerNode }; containerHierarchy.AddRange(container.ContainerNode.ContainerNodeTree(false)); int containerID = 1; container.ContainerNode.GetUserPropInt("babylonjs_ContainerID", ref containerID); //the first istance of the multiples containers, the one without _ID_* //mContainer ->referenceBrotherContainer //mContainer_ID_2 int idIndex = container.ContainerNode.Name.IndexOf("_ID_"); if (idIndex < 0) { return; } string refBrotherName = container.ContainerNode.Name.Substring(0, idIndex); IINode refBrotherContainerObject = Loader.Core.GetINodeByName(refBrotherName); //if there is no brother, there is nothing to resolve if (refBrotherContainerObject == null) { return; } //manage multiple containers inherithed from the same source foreach (IINode n in containerHierarchy) { if (n.IsBabylonContainerHelper()) { continue; } //change the guid of the node //replace the guid in the babylon helper string oldGuid = n.GetStringProperty("babylonjs_GUID", Guid.NewGuid().ToString()); n.DeleteProperty("babylonjs_GUID"); Guid newGuid = n.GetGuid(); helperPropBuffer = helperPropBuffer.Replace(oldGuid, newGuid.ToString()); if (containerID > 1 && !n.Name.EndsWith("_ID_" + containerID)) { string originalName = n.Name; n.Name = $"{n.Name}_ID_{containerID}"; IINode source = refBrotherContainerObject.FindChildNode(originalName); IMtl mat = source.Mtl; if (mat != null) { n.Mtl = mat; } } } //replace animationList guid to have distinct list of AnimationGroup for each container string animationListStr = string.Empty; container.BabylonContainerHelper().GetUserPropString(s_AnimationListPropertyName, ref animationListStr); if (!string.IsNullOrEmpty(animationListStr)) { string[] animationGroupGuid = animationListStr.Split(AnimationGroup.s_PropertySeparator); foreach (string guidStr in animationGroupGuid) { Guid newAnimGroupGuid = Guid.NewGuid(); helperPropBuffer = helperPropBuffer.Replace(guidStr, newAnimGroupGuid.ToString()); } container.BabylonContainerHelper().SetUserPropBuffer(helperPropBuffer); //add ID of container to animationGroup name to identify animation in viewer container.BabylonContainerHelper().GetUserPropString(s_AnimationListPropertyName, ref animationListStr); string[] newAnimationGroupGuid = animationListStr.Split(AnimationGroup.s_PropertySeparator); if (containerID > 1) { foreach (string guidStr in newAnimationGroupGuid) { string propertiesString = string.Empty; if (!container.BabylonContainerHelper().GetUserPropString(guidStr, ref propertiesString)) { return; } string[] properties = propertiesString.Split(AnimationGroup.s_PropertySeparator); if (properties.Length < 4) { throw new Exception("Invalid number of properties, can't deserialize."); } string name = properties[0]; if (!string.IsNullOrEmpty(name) && !name.EndsWith("_ID_" + containerID)) { propertiesString = propertiesString.Replace(name, name + "_ID_" + containerID); container.BabylonContainerHelper().SetUserPropString(guidStr, propertiesString); } } } } }