private Transform LoadElement(PomlElement element, Transform parent)
        {
            var t = GenerateElement(element, parent);

            if (t == null)
            {
                return(null);
            }

            var pomlElementComponent = t.gameObject.AddComponent <PomlElementComponent>();

            pomlElementComponent.PomlElement = element;

            t.SetParent(parent, false);

            t.localPosition = element.Position;
            t.localRotation = element.Rotation;
            t.localScale    = element.Scale;

            var el = new Element()
            {
                GameObject = t.gameObject,
                Id         = element.Id
            };

            contentsStore.RegisterElement(el);

            // Load child elements
            foreach (var child in element.Children)
            {
                LoadElement(child, t);
            }

            return(t);
        }
        protected virtual Transform InstantiateModel(PomlElement element)
        {
            var go = new GameObject();

            // TODO create load gltf
            var gltf    = go.AddComponent <GltfEntity>();
            var srcPath = element.Src;

            gltf.Load(srcPath);
            return(go.transform);
        }
        protected PomlElement InitElement(XmlNode node, string basePath)
        {
            var elementType = GetElementType(node);

            switch (elementType)
            {
            case PomlElementType.Primitive:
                return(InitPrimitiveElement(node, basePath));

            case PomlElementType.Script:
                return(InitScriptElement(node, basePath));

            case PomlElementType.Text:
                return(InitTextElement(node));

            default:
                var pomlElement = new PomlElement(elementType);
                return(pomlElement);
            }
        }
        private Transform GenerateElement(PomlElement element, Transform parent)
        {
            switch (element.ElementType)
            {
            case PomlElementType.Element:
                return(InstantiateEmptyElement(element));

            case PomlElementType.Primitive:
                if (element is PomlPrimitiveElement primitiveElement)
                {
                    return(InstantiatePrimitive(primitiveElement));
                }
                break;

            case PomlElementType.Model:
                return(InstantiateModel(element));

            case PomlElementType.Text:
                if (element is PomlTextElement textElement)
                {
                    return(InstantiateText(textElement));
                }
                break;

            case PomlElementType.Script:
                if (element is PomlScriptElement scriptElement)
                {
                    AttachScript(scriptElement, parent);
                }
                break;

            default:
                break;
            }
            return(null);
        }
        protected virtual Transform InstantiateEmptyElement(PomlElement element)
        {
            var go = new GameObject();

            return(go.transform);
        }