Graphics Reference
In-Depth Information
How to do it...
1. Let's first take a look at what we're aiming for in this recipe. We want to load
resources synchronously, using the Q library, in the following manner:
loadModel(model)
.then(function(result) {return
loadTexture(texture)})
.then(function(result) {return
loadModel(m)})
.then(function(result) {return
loadTexture(texture)})
.then(function(result) {return
loadOthers(resource)})
.then(function(result) {return
loadModelWithProgress(m)})
.then(function(result) {return
loadModel(model)})
.then(function(result) {return
loadOthers(resource)})
.then(function(result) {return
loadModel(model)})
.then(function() {console.log("All
done with sequence")})
.catch(function(error) {
console.log("Error occurred in
sequence:",error);
})
.progress(function(e){
console.log("Progress event
received:", e);
});
2. What this code fragment means is that:
1. Firstly, we want to call loadModel(model) .
2. Once the model is loaded, we load, using the then function, a
texture using the loadTexture(texture) function. Once this tex-
Search WWH ::




Custom Search