Esempio n. 1
0
        public Unity3DTileset(Unity3DTilesetOptions tilesetOptions, AbstractTilesetBehaviour behaviour)
        {
            TilesetOptions  = tilesetOptions;
            Behaviour       = behaviour;
            RequestManager  = behaviour.RequestManager;
            ProcessingQueue = behaviour.ProcessingQueue;
            TileCache       = behaviour.TileCache;
            Traversal       = new Unity3DTilesetTraversal(this, behaviour.SceneOptions);
            DeepestDepth    = 0;

            string url        = UrlUtils.ReplaceDataProtocol(tilesetOptions.Url);
            string tilesetUrl = url;

            if (!UrlUtils.GetLastPathSegment(url).EndsWith(".json", StringComparison.OrdinalIgnoreCase))
            {
                tilesetUrl = UrlUtils.JoinUrls(url, "tileset.json");
            }

            LoadTilesetJson(tilesetUrl).Then(json =>
            {
                // Load Tileset (main tileset or a reference tileset)
                schemaTileset = Schema.Tileset.FromJson(json);
                Root          = LoadTileset(tilesetUrl, schemaTileset, null);
            }).Catch(error =>
            {
                Debug.LogError(error.Message + "\n" + error.StackTrace);
            });
        }
Esempio n. 2
0
        public Unity3DTileset(Unity3DTilesetOptions tilesetOptions, AbstractTilesetBehaviour behaviour)
        {
            this.TilesetOptions  = tilesetOptions;
            this.Behaviour       = behaviour;
            this.RequestManager  = behaviour.RequestManager;
            this.ProcessingQueue = behaviour.ProcessingQueue;
            this.LRUContent      = behaviour.LRUCache;
            this.Traversal       = new Unity3DTilesetTraversal(this, behaviour.SceneOptions);
            this.DeepestDepth    = 0;

            string url = UrlUtils.ReplaceDataProtocol(tilesetOptions.Url);

            if (UrlUtils.GetLastPathSegment(url).EndsWith(".json", StringComparison.OrdinalIgnoreCase))
            {
                this.basePath   = UrlUtils.GetBaseUri(url);
                this.tilesetUrl = url;
            }
            else
            {
                this.basePath   = url;
                this.tilesetUrl = UrlUtils.JoinUrls(url, "tileset.json");
            }

            LoadTilesetJson(this.tilesetUrl).Then(json =>
            {
                // Load Tileset (main tileset or a reference tileset)
                this.tileset = Schema.Tileset.FromJson(json);
                this.Root    = LoadTileset(this.tilesetUrl, this.tileset, null);
                this.readyPromise.Resolve(this);
            }).Catch(error =>
            {
                Debug.LogError(error.Message + "\n" + error.StackTrace);
            });
        }
Esempio n. 3
0
        public Unity3DTileset(Unity3DTilesetOptions tilesetOptions, AbstractTilesetBehaviour behaviour,
                              RequestManager requestManager, Queue <Unity3DTile> processingQueue, LRUCache <Unity3DTile> cache = null)
        {
            this.TilesetOptions  = tilesetOptions;
            this.Behaviour       = behaviour;
            this.RequestManager  = requestManager;
            this.ProcessingQueue = processingQueue;
            this.traversal       = new Unity3DTilesetTraversal(this, behaviour.SceneOptions);
            this.LRUContent      = cache ?? new LRUCache <Unity3DTile>();
            this.DeepestDepth    = 0;

            // TODO: Detect data Uri?
            if (Path.GetExtension(tilesetOptions.Url) == ".json")
            {
                this.tilesetUrl = this.TilesetOptions.Url;
                this.basePath   = UriHelper.GetBaseUri(this.TilesetOptions.Url, true);
            }
            else
            {
                this.basePath   = this.TilesetOptions.Url;
                this.tilesetUrl = UriHelper.JoinUrls(this.TilesetOptions.Url, "tileset.json", true);
            }
            LoadTilesetJson(this.tilesetUrl).Then(json =>
            {
                // Load Tileset (main tileset or a reference tileset)
                this.tileset = Schema.Tileset.FromJson(json);
                this.Root    = LoadTileset(this.tilesetUrl, this.tileset, null);
                this.readyPromise.Resolve(this);
            }).Catch(error =>
            {
                Debug.LogError(error.Message + "\n" + error.StackTrace);
            });
        }