Example #1
0
        /// <summary>
        /// Creates a complete clone of this <see cref="ModelRoot"/> instance.
        /// </summary>
        /// <returns>A new <see cref="ModelRoot"/> instance.</returns>
        /// <remarks>
        /// Deep cloning is performed as a brute force operation; by serializing
        /// the whole model to GLTF into memory, and then deserializing it back.
        /// </remarks>
        public ModelRoot DeepClone()
        {
            var dict     = new Dictionary <string, ArraySegment <Byte> >();
            var settings = WriteSettings.ForDeepClone(dict);

            System.Diagnostics.Debug.Assert(settings._NoCloneWatchdog, "invalid clone settings");

            this.Write(settings, "deepclone");

            return(ModelRoot.ReadFromDictionary(dict, "deepclone.gltf"));
        }