Ejemplo n.º 1
0
        /// <summary>
        /// </summary>
        public virtual void _checkDelayState()
        {
            var that  = this;
            var scene = this.getScene();

            if (this._geometry != null)
            {
                this._geometry.load(scene);
            }
            else if (that.delayLoadState == Engine.DELAYLOADSTATE_NOTLOADED)
            {
                that.delayLoadState = Engine.DELAYLOADSTATE_LOADING;
                scene._addPendingData(that);
                Tools.LoadFile(
                    this.delayLoadingFile,
                    (data) =>
                {
                    // TODO: finish it
                    this._delayLoadingFunction(JsmnParser.Parse(data), this);
                    this.delayLoadState = Engine.DELAYLOADSTATE_LOADED;
                    scene._removePendingData(this);
                },
                    (max, pos) => { },
                    scene.database);
            }
        }
Ejemplo n.º 2
0
        public static JsmnParserValue Parse(string data)
        {
#if _DEBUG
            BABYLON.Tools.Log(string.Format("JSON Parsing: {0}...", data.Substring(0, Math.Min(1000, data.Length))));
#endif

            var parser = new JsmnParser(256);
            //var r = parser.Parse("{ \"name\" : \"Jack\", \"age\" : 27 }");
            var r = parser.ParseJson(data);

#if _DEBUG
            BABYLON.Tools.Log(string.Format("Parsed tokens: {1}, error: {0}", (int)r, parser.Tokens.Length));
#endif

            var parsedData = new JsmnParserValue(0, parser.Tokens);
            return(parsedData);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// </summary>
        /// <param name="scene">
        /// </param>
        /// <param name="onLoaded">
        /// </param>
        public virtual void load(Scene scene, System.Action onLoaded = null)
        {
            if (this.delayLoadState == Engine.DELAYLOADSTATE_LOADING)
            {
                return;
            }

            if (this.isReady())
            {
                if (onLoaded != null)
                {
                    onLoaded();
                }

                return;
            }

            this.delayLoadState = Engine.DELAYLOADSTATE_LOADING;
            scene._addPendingData(this);
            Tools.LoadFile(
                this.delayLoadingFile,
                (string data) =>
            {
                this._delayLoadingFunction(JsmnParser.Parse(data), this);
                this.delayLoadState = Engine.DELAYLOADSTATE_LOADED;
                this._delayInfo     = new Array <VertexBufferKind>();
                scene._removePendingData(this);
                var meshes      = this._meshes;
                var numOfMeshes = meshes.Length;
                for (var index = 0; index < numOfMeshes; index++)
                {
                    this._applyToMesh(meshes[index]);
                }

                if (onLoaded != null)
                {
                    onLoaded();
                }
            },
                (max, pos) => { },
                scene.database);
        }