我正在使用GLGE(类似于WebGL)将图像加载到纹理地图上。然而为了加快加载速度,我首先加载低分辨率图像(这样会更快),然后想在加载完大图像后将src更改为高分辨率图像。目前我的做法如下:
var texture = new GLGE.texture();
function updateTexture(){
var image=new Image();
image.src = "models/testLargeMap_map0.jpg"; // load image
image.onload = function(){
texture.image("models/testLargeMap_map0.jpg"); // supposedly swap image on load (not working as I thought)
}
}
然而,在更改src期间,模型及其所有功能都会冻结。我该如何异步加载图像,并在加载完成后将其切换到更高质量的纹理,以实现平滑的瞬时纹理变化?
image.onload
,你可以尝试使用$(document).ready()
,就像这里的例子一样:https://dev59.com/mEnSa4cB1Zd3GeqPKxW4 - JMax