Thdk的负荷功能基本上与,载于三.js。
If you look at the source for the THREE.ImageUtils.loadTexture function you can see it is identical to the one above except for some small changes. We have extra parameters for texture mapping and a callback as well. The callback is placed inside the Image objects onload event. This means we can utilize this to hold off on creating objects until we have their textures and making sure all of
them are loaded before we animate.
loadTexture: function ( path, mapping, callback ) {
var image = new Image(), texture = new THREE.Texture( image, mapping );
image.onload = function () { texture.needsUpdate = true; if ( callback ) callback( this ); };
image.crossOrigin = this.crossOrigin;
image.src = path;
return texture;
},
借助你可能以下列方式利用这一呼吁来实现你想要的东西:
THREE.ImageUtils.loadTexture(path1, null, function () {
THREE.ImageUtils.loadTexture(path2, null, function () {
THREE.ImageUtils.loadTexture(path3, null, function () { renderingEnabled = true; }) }) });
然后用<代码>(如果(提交)代码>接通电话。 或者,如果你妥善确定一切,你就可以简单地把 last子从最后的警示中 call。