Book Image

Going the Distance with Babylon.js

By : Josh Elster
Book Image

Going the Distance with Babylon.js

By: Josh Elster

Overview of this book

Babylon.js allows anyone to effortlessly create and render 3D content in a web browser using the power of WebGL and JavaScript. 3D games and apps accessible via the web open numerous opportunities for both entertainment and profit. Developers working with Babylon.js will be able to put their knowledge to work with this guide to building a fully featured 3D game. The book provides a hands-on approach to implementation and associated methodologies that will have you up and running, and productive in no time. Complete with step-by-step explanations of essential concepts, practical examples, and links to fully working self-contained code snippets, you’ll start by learning about Babylon.js and the finished Space-Truckers game. You’ll also explore the development workflows involved in making the game. Focusing on a wide range of features in Babylon.js, you’ll iteratively add pieces of functionality and assets to the application being built. Once you’ve built out the basic game mechanics, you’ll learn how to bring the Space-Truckers environment to life with cut scenes, particle systems, animations, shadows, PBR materials, and more. By the end of this book, you’ll have learned how to structure your code, organize your workflow processes, and continuously deploy to a static website/PWA a game limited only by bandwidth and your imagination.
Table of Contents (20 chapters)
1
Part 1: Building the Application
7
Part 2: Constructing the Game
13
Part 3: Going the Distance

What this book covers

Chapter 1, The Space-Truckers Operation Manual, gives an overview of the world of Space-Truckers and 3D development with Babylon.js.

Chapter 2, Ramping up on Babylon.js, gets us started with (or refreshed on) Babylon.js with a simple 3D animated scene.

Chapter 3, Establishing the Development Workflow, puts a solid design-and-build time experience into place to allow rapid future development.

Chapter 4, Creating the Application, involves building a stateful application that will host the game.

Chapter 5, Adding a Cut Scene and Handling Input, takes us through imperatively creating an animated “cut scene” and learning how to handle user input of different types.

Chapter 6, Implementing the Game Mechanics, starts off the construction of the main route planning phase of the game. Here, we will augment the existing physics with orbital mechanics and simulated gravitational forces.

Chapter 7, Processing Route Data, involves adding random encounter tables that correspond to a space biome.

Chapter 8, Building the Driving Game, takes us through dynamically generating a route and allowing players to drive along it.

Chapter 9, Calculating and Displaying Scoring Results, deals with capturing and showing stats on player performance in a reusable dialog with the help of the GUI Editor.

Chapter 10, Improving the Environment with Lighting and Materials, covers how we can improve the look and feel of the game by enhancing key visual elements.

Chapter 11, Scratching the Surface of Shaders, discusses extended analogies explaining shaders and writing shader code that doesn’t involve writing any shader code.

Chapter 12, Measuring and Optimizing Performance, explains the heuristics and approaches for testing the runtime performance and the strategies for improvement, along with dynamic runtime optimization with the SceneOptimizer tool.

Chapter 13, Converting the Application to a PWA, explores preparing the application for installation as a Progressive Web Application (PWA). We then go through publishing this to a major App Store and adding support for offline usage.

Chapter 14, Extended Topics, Extended, looks at AR/VR with WebXR and Babylon Native before a foray into photorealistic raytracing and Babylon.js in a CMS or e-commerce scenario.