Example #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);
            });
        }
Example #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);
            });
        }
Example #3
0
        public bool AddTileset(Unity3DTilesetOptions options)
        {
            if (string.IsNullOrEmpty(options.Name))
            {
                options.Name = options.Url;
            }
            if (string.IsNullOrEmpty(options.Name) || string.IsNullOrEmpty(options.Url))
            {
                Debug.LogWarning("Attempt to add tileset with null or empty name or url failed.");
                return(false);
            }
            options.Url = MakeAbsoluteUrl(options.Url);
            if (nameToTileset.ContainsKey(options.Name))
            {
                Debug.LogWarning(String.Format("Attempt to add tileset with duplicate name {0} failed.", options.Name));
                return(false);
            }
            if (SceneOptions.GLTFShaderOverride != null && options.GLTFShaderOverride == null)
            {
                options.GLTFShaderOverride = SceneOptions.GLTFShaderOverride;
            }
            var tileset = new Unity3DTileset(options, this);

            tilesets.Add(tileset);
            nameToTileset[options.Name] = tileset;
            if (!TilesetOptions.Contains(options))
            {
                TilesetOptions.Add(options);
            }
            UpdateStats();
            return(true);
        }
        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);
            });
        }
        public bool AddTileset(string tilesetName, string tilesetURL, Matrix4x4 rootTransform)
        {
            Unity3DTilesetOptions options = new Unity3DTilesetOptions();

            options.Name      = tilesetName;
            options.Url       = tilesetURL;
            options.Show      = true;
            options.Transform = rootTransform;
            return(AddTileset(options));
        }
Example #6
0
 public void OnAfterDeserialize()
 {
     if (TilesetOptions.Count == 1 && numTilesetsWas == 0 && Thread.CurrentThread == mainThread)
     {
         //init first new element to defaults
         if (string.IsNullOrEmpty(TilesetOptions[0].Url))
         {
             TilesetOptions[0] = new Unity3DTilesetOptions();
         }
     }
     numTilesetsWas = TilesetOptions.Count;
 }
Example #7
0
 public bool AddTileset(string name, string url, Matrix4x4 rootTransform, bool show,
                        Unity3DTilesetOptions options = null)
 {
     options             = options ?? new Unity3DTilesetOptions();
     options.Name        = name;
     options.Url         = url;
     options.Translation = new Vector3(rootTransform.m03, rootTransform.m13, rootTransform.m23);
     options.Rotation    = rootTransform.rotation;
     options.Scale       = rootTransform.lossyScale;
     options.Show        = show;
     return(AddTileset(options));
 }
 public bool AddTileset(Unity3DTilesetOptions options)
 {
     if (Tilesets.ContainsKey(name))
     {
         Debug.LogWarning(String.Format("Attempt to add tileset with duplicate name {0} failed.", name));
         return(false);
     }
     if (OverrideShader != null)
     {
         options.GLTFShaderOverride = OverrideShader;
     }
     this.requestManager = this.requestManager ?? new RequestManager(MaxConcurrentRequests);
     Tilesets.Add(options.Name, new Unity3DTileset(options, this, requestManager, postDownloadQueue, LRUCache));
     updateOptionsAndStats();
     return(true);
 }
Example #9
0
        public Unity3DTilesetOptions GetTilesetOptions()
        {
            Unity3DTilesetOptions opts = new Unity3DTilesetOptions();

            opts.Name = this.Url;
            opts.Url  = this.Url;
            opts.Show = this.Show;
            opts.ShadowCastingMode              = this.ShadowCastingMode;
            opts.RecieveShadows                 = this.RecieveShadows;
            opts.CreateColliders                = this.CreateColliders;
            opts.MaximumScreenSpaceError        = this.MaximumScreenSpaceError;
            opts.SkipScreenSpaceErrorMultiplier = this.SkipScreenSpaceErrorMultiplier;
            opts.LoadSiblings          = this.LoadSiblings;
            opts.MaxDepth              = 0;
            opts.GLTFMultithreadedLoad = this.GLTFMultithreadedLoad;
            opts.GLTFMaximumLOD        = this.GLTFMaximumLOD;
            opts.GLTFShaderOverride    = this.GLTFShaderOverride;
            opts.DebugDrawBounds       = false;
            return(opts);
        }