Graphics Reference
In-Depth Information
3. Note that the first console output also shows a valid texture object. Three.js
does this, so you can immediately assign this object as a texture to a ma-
terial. The actual image inside the texture, however, is only loaded after the
onLoadCallback function is called.
How it works...
Three.js provides a nice wrapper to load textures. Internally, Three.js uses the
standard way of loading resources from an XMLHTTPRequest web page With an
XMLHTTPRequest web page, you can make an HTTP request for a specific re-
source and process the result. If you don't want to use the Three.js provided func-
tionality, you can also implement an XMLHTTPRequest function yourself.
See also
• To run these examples and load resources asynchronously, we need to either
run a web server locally, as explained in the Setting up a local web server
using Python recipe or the Setting up a web server using Node.js recipe, or
disable some security settings, as explained in the Solving cross-origin-do-
main error messages in Chrome recipe or the Solving cross-origin-domain
error messages in Firefox recipe.
• Alternatively, if you don't want to load resources asynchronously, but wait for
all the resources to load, before you initialize your scene you can look at the
next Waiting until resources are loaded recipe.
Search WWH ::




Custom Search