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

Loading the scene


Our objective is to create a scene of 5000 AD similar to the following screenshot:

We will use these objects to draw the scene. These objects were created using Blender and exported as shown in Chapter 2, Colors and Shading Languages.

Open the 03-Loading-Scene.html file in your favorite editor. If you observe the scene, you will see that there are four buildings, six street lamps, and two railings. Hence, we added the cloneObjects function that clones the objects and adds them to the scene. The cloneObjects function invokes the function clone of the SceneObject's class, which invokes the clone function of the Geometry class. The following is the code snippet from the 03-Loading-Scene.html file:

function start() {
........................................
  addStageObject("model/obj/terrain.json",[0.0,0.0,0.0],0.00,0.0,0.0);
  addStageObject("model/obj/building.json",[55.0,0.0,170],0.0,0.0,0.0);
  addStageObject("model/obj/giantPillar.json",[-60.0,0.0,-200],0.0,0.0,0.0);
 ...