Exemple #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);
            });
        }
Exemple #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);
            });
        }
        public Unity3DTileset(Unity3DTilesetOptions options, MonoBehaviour behaviour, RequestManager requestManager)
        {
            this.Options        = options;
            this.Behaviour      = behaviour;
            this.RequestManager = requestManager;
            this.traversal      = new Unity3DTilesetTraversal(this);
            this.LRUContent     = new LRUCache <Unity3DTile>();
            this.DeepestDepth   = 0;

            // TODO: Detect data Uri?
            if (Path.GetExtension(options.Url) == ".json")
            {
                this.tilesetUrl = this.Options.Url;
                this.basePath   = UriHelper.GetBaseUri(this.Options.Url, true);
            }
            else
            {
                this.basePath   = this.Options.Url;
                this.tilesetUrl = UriHelper.JoinUrls(this.Options.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);
            });
        }