Book Image

WebGL Game Development

By : Sumeet Arora
Book Image

WebGL Game Development

By: Sumeet Arora

Overview of this book

<p>WebGL, the web implementation of Open GL, is a JavaScript API used to render interactive 3D graphics within any compatible web browser, without the need for plugins. It helps you create detailed, high-quality graphical 3D objects easily. WebGL elements can be mixed with other HTML elements and composites to create high-quality, interactive, creative, innovative graphical 3D objects.</p> <p>This book begins with collecting coins in Super Mario, killing soldiers in Contra, and then quickly evolves to working out strategies in World of Warcraft. You will be guided through creating animated characters, image processing, and adding effects as part of the web page canvas to the 2D/3D graphics. Pour life into your gaming characters and learn how to create special effects seen in the most powerful 3D games. Each chapter begins by showing you the underlying mathematics and its programmatic implementation, ending with the creation of a complete game scene to build a wonderful virtual world.</p>
Table of Contents (17 chapters)
WebGL Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Animating a rigged JSON model


Well, we did not take much effort to load a static model, rather we took more effort to animate the model. Hence, let's first understand how animation data is encoded in a JSON file.

JSON model – animation data

Open model/obj/mrgreen.json in your text editor. In the file, you will find an element animation. When the file is viewed in any JSON viewer, you will see name, fps, length, and hierarchy as the animation object's child elements. To understand our JSON file, we used an online viewer (http://jsonviewer.stack.hu/). We loaded our JSON file in the viewer as shown in the following screenshot:

The other child elements are obvious but the most interesting element is hierarchy. The hierarchy element is an array; the length of this array is equal to the length of bones. Each array element has animation data for the corresponding bone index. The hierarchy array element holds the keyframes (keys) element, which holds DOF (position, rotation, and scale) values for that...