如何删除图像解码调用的冻结

How to remove freezes which are called by image decoding

当我开始在游戏中移动时,我看到一些冻结,这只发生过一次,在使用开发工具记录后,我看到图像解码调用了冻结(据我所知,它正在为我的几何体解码纹理)。那么有什么方法可以 "precode" 图片,并且开始游戏时不会卡顿吗?

recorder screen

缓解此问题的一种解决方案是使用 ImageBitmap. With this API, the image decode is going to happen in a separate thread without blocking the animation loop. In three.js you can use ImageBitmapLoader 作为 ImageLoader 的更高效替代品。查看以下示例以查看加载程序的运行情况:

https://threejs.org/examples/webgl_loader_imagebitmap.html