Graphics Reference
In-Depth Information
function onProgressCallback(progress) {
console.log("Progress", progress);
}
function onErrorCallback(error) {
console.log("Error", error)
}
Note
In the following sections and recipes, we'll reference these callbacks when we
use the Three.js provided functionality to load resources.
How to do it...
1. To load a texture asynchronously, we use the loadTexture function from
THREE.ImageUtils :
function loadTexture(texture) {
var texture =
THREE.ImageUtils.loadTexture(textureURL,
null, onLoadCallback, onErrorCallback);
console.log("texture after
loadTexture call", texture);
}
2. The loadTexture function from THREE.ImageUtils takes the following
four arguments:
• The first one points to the location of the image you want to load
• The second one can be used to provide a custom UV mapping (a UV
mapping is used to determine which part of a texture to apply to a
specific face)
• The third argument is the callback to be used when the textures have
been loaded
• The final argument is the callback to be used in case of an error
Search WWH ::




Custom Search