Game Development Reference
In-Depth Information
Applying a texture to the scene
Open the parseJSON.js file from the primitive folder of the code bundle in your
favorite editor.
In this file, we add the following line of code to recreate the vertices and
texture coordinates:
geometry.verticesFromFaceUvs(data.vertices,data.uvs,0);
We invoke this function just before creating the indices array from the faces array,
because the previous function also reindexes the indices of vertices array.
The explanation to the previous function/code is
in Chapter 4 , Applying Textures , in the Parsing UV
coordinates from the JSON file section.
Let's first understand the basic strategy that we will follow. Most designers would
prefer to create a single texture that will contain the textures of multiple objects. In
our case, we have the terrain_1024.jpg file from the model\obj folder of the code
bundle, as shown in the following screenshot:
 
Search WWH ::




Custom Search