public static int ExportTexture(glTF gltf, int bufferIndex, Texture texture, glTFTextureTypes textureType)
        {
            var bytesWithMime = GetBytesWithMime(texture, textureType);;

            // add view
            var view      = gltf.buffers[bufferIndex].Append(bytesWithMime.Bytes, glBufferTarget.NONE);
            var viewIndex = gltf.AddBufferView(view);

            // add image
            var imageIndex = gltf.images.Count;

            gltf.images.Add(new glTFImage
            {
                name       = texture.name,
                bufferView = viewIndex,
                mimeType   = bytesWithMime.Mime,
            });

            // add sampler
            var samplerIndex = gltf.samplers.Count;
            var sampler      = TextureSamplerUtil.Export(texture);

            gltf.samplers.Add(sampler);

            // add texture
            gltf.textures.Add(new glTFTexture
            {
                sampler = samplerIndex,
                source  = imageIndex,
            });

            return(imageIndex);
        }
        public IEnumerator ProcessOnMainThreadCoroutine(glTF gltf)
        {
            using (m_textureLoader)
            {
                var textureType = TextureIO.GetglTFTextureType(gltf, m_textureIndex);
                var colorSpace  = TextureIO.GetColorSpace(textureType);
                var isLinear    = colorSpace == RenderTextureReadWrite.Linear;
                yield return(m_textureLoader.ProcessOnMainThread(isLinear));

                TextureSamplerUtil.SetSampler(Texture, gltf.GetSamplerFromTextureIndex(m_textureIndex));
            }
        }