public static Matrix GetMatrix(WindowImpl window)
        {
            if (window.Is2D)
            {
                throw new InvalidOperationException();
            }
            var sprite = GetSprite(window);

            return(sprite.Entity.Transform.WorldMatrix);
        }
 public static void ChangeSpace(WindowImpl window, bool newIs2D)
 {
     if (window.Is2D == newIs2D)
     {
         return;
     }
     RemoveWindow(window);
     window.Is2D = newIs2D;
     AddWindow(window);
 }
 public static SpriteComponent GetSprite(WindowImpl window)
 {
     if (WorldPages.TryGetValue(window, out var sprite))
     {
         return(sprite);
     }
     else
     {
         return(Create3DUIPage(window));
     }
 }
 public static void AddWindow(WindowImpl window)
 {
     if (window.Is2D)
     {
         var uiPage = GetUIPage(window.RenderGroup);
         var canvas = (Canvas)uiPage.Page.RootElement;
         canvas.Children.Add(window.RenderingElement);
     }
     else
     {
         _ = Create3DUIPage(window);
     }
 }
        private static SpriteComponent Create3DUIPage(WindowImpl window)
        {
            var entity = new Entity("Avalonia Screen Page " + window.RenderGroup);
            var sprite = new SpriteComponent
            {
                RenderGroup    = window.RenderGroup,
                SpriteProvider = window.RenderingElement.Source
            };

            WorldPages.Add(window, sprite);
            entity.Add(sprite);
            Container3D.AddChild(entity);
            return(sprite);
        }
 public static void ChangeRenderGroup(WindowImpl window, RenderGroup newRenderGroup)
 {
     if (window.Is2D)
     {
         RemoveWindow(window);
         window.RenderGroup = newRenderGroup;
         AddWindow(window);
     }
     else
     {
         var sprite = GetSprite(window);
         window.RenderGroup = newRenderGroup;
         sprite.RenderGroup = newRenderGroup;
     }
 }
 public static void RemoveWindow(WindowImpl window)
 {
     if (window.Is2D)
     {
         var uiPage = GetUIPage(window.RenderGroup);
         var canvas = (Canvas)uiPage.Page.RootElement;
         canvas.Children.Remove(window.RenderingElement);
     }
     else
     {
         var uiPage = GetSprite(window);
         WorldPages.Remove(window);
         Container3D.RemoveChild(uiPage.Entity);
         uiPage.Entity.Dispose();
     }
 }
        public static void ChangeRotation(WindowImpl window, Quaternion?newRotation)
        {
            var sprite = GetSprite(window);

            sprite.Entity.Transform.Rotation = newRotation ?? new Quaternion();
        }
        public static void ChangePosition(WindowImpl window, Vector3?newPosition)
        {
            var sprite = GetSprite(window);

            sprite.Entity.Transform.Position = newPosition ?? new Vector3();
        }