O'Reilly logo

WebGL Game Development by Sumeet Arora

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Rendering objects exported from Blender

If you have reached this far, you have learned the main recipe to fight mutated Mr. Green. Understanding the JSON format and then recreating the vertices and indices arrays is exciting and at the same time, is your biggest weapon to build the most beautiful objects with textures. So let's quickly walk through the code to load JSON objects.

Changes in our JSON parser

Open primitive/parseJSON.js in your editor. This file has two major changes. The first change populates the faceUvs and faceVertexUVs arrays of the Geometry class with the JSON data, as shown in the following code snippet:

fi = geometry.faces.length; if ( hasFaceUv ) { for ( i = 0; i < nUvLayers; i++ ) { uvLayer = data.uvs[ i ]; uvIndex = faces[ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required