public static RenderModel3D Error(string name)
        {
            var element = new MeshGeometryModel3D
            {
                Geometry = errorGeometry,
                Material = errorMaterial
            };

            var model = new RenderModel3D(name, Enumerable.Empty <Region>(), Enumerable.Empty <InstanceGroup>());

            model.Children.Add(element);

            return(model);
        }
        public ObjectModel3D(ModelFactory factory, ModelConfig config, string name, string defaultVariant)
        {
            this.config         = config;
            ModelName           = name;
            this.defaultVariant = config.Variants.FirstOrDefault(v => v.Name == defaultVariant) ?? config.Variants.FirstOrDefault();
            attachments         = new Dictionary <string, List <ObjectModel3D> >();

            if (config.RenderModelTag == null)
            {
                baseModel = RenderModel3D.Error("null");
            }
            else
            {
                baseModel = factory.CreateRenderModel(config.RenderModelTag.Id);
            }

            foreach (var variant in config.Variants)
            {
                var children = new List <ObjectModel3D>();
                foreach (var attachment in variant.Attachments.Where(att => att.ChildTag != null))
                {
                    var child = factory.CreateObjectModel(attachment.ChildTag.Id);
                    if (child.config.RenderModelTag == null)
                    {
                        continue;
                    }

                    var parentProps = factory.GetProperties(config.RenderModelTag.Id);
                    var childProps  = factory.GetProperties(child.config.RenderModelTag.Id);
                    child.Transform = GetAttachmentTransform(parentProps, attachment.ParentMarker, childProps, attachment.ChildMarker);

                    child.SetVariant(attachment.ChildVariant);
                    children.Add(child);
                }

                attachments.Add(variant.Name, children);
            }

            SetVariant(DefaultVariant);
        }