Graphics Reference
In-Depth Information
Loading textures asynchronously
When you create Three.js scenes, you often need to load resources. There might be
textures you want to load for your objects, you might have some external models you
want to include in your scene, or maybe some CSV data that you want to use as an
input for your visualization. Three.js offers a number of different ways of loading these
resources asynchronously, which we'll explore in this and the following recipes.
To run these recipes and experiment with them, we included a simple sample in the
source folder of this chapter that shows this loading in action. If you open an example
01.11-load-async-resources.html in your browser, and open the JavaScript
console, you'll see the progress and the result of loading resources asynchronously.
Please note that since we are loading files directly from the browser, you need to have
either a local web server installed (see the Setting up a local web server with Python
recipe or the Setting up a local web server with Node.js recipe) or disable some secur-
ity checks as explained in the Solving cross-origin-domain error messages in Chrome
recipe or the Solving cross-origin-domain error messages in Firefox recipe.
In these first of the five recipes, we'll show you how you can load textures asynchron-
ously with Three.js.
Search WWH ::




Custom Search