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

Understanding the basic ray casting concepts


There are many use cases where collision detection is detected too late in a game. Let's consider a case, in a game, where we have a door and if the player approaches it, you want the door to open automatically. If we use collision detection for this case, then the player has to first collide with the door, in order to open it; or alternatively, you can create a bigger bounding box (a rigid body with more depth) so that when the user approaches the door a collision is detected earlier. However, this approach does not cover the use case of the player not facing the door. For instance, if the player has its back towards the door, then a collision would be detected and the door would open. Collision detection does not consider directions.

Ray casting is also used to build the basic AI of a non-playing character. A moving player might need to alter its direction or speed automatically when there is another existing object moving in the same direction...