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

The Space-Truckers Operation Manual

It’s not considered to be a very emotionally evolved stance to judge a book by its cover, but have you seen the cover of this book? If it’s something you like, then please, by all means, do judge this book by its cover, you counter-culture influencer, you – carry on reading!

If for some reason you don’t like the cover, then bully for you for literally turning over a new page to see what’s inside – unlike some superficial cretins. We’re above that sort of petty judgment, after all.

Note

Sometimes, relevant information will be presented in these Note boxes. Other times, these same boxes will contain completely irrelevant but possibly irreverent information. At all times, or at none (sometimes), should you pay attention to what’s in these boxes.

Regardless of whether you’re on Team Cover or Team Content, it’s clear you’re incredibly smart and well mannered for the simple fact that you’ve started reading this book. We’re about to embark on a journey together over the next 14 chapters. This is not the type of journey that you might encounter flipping through channels while you search for something to watch before bedtime. This is a journey across the wide and vast terrain that is the Babylon.js ecosystem. It isn’t a safari, but it is a sojourn. One thing it is not, however, is an Odyssey. Primarily because you don’t have to actually go anywhere, and you get to go back to your regular life whenever you’re not reading this book, but perhaps for other reasons too.

Important Note

Like its less-distinguished cousin the Note, Important Note boxes will occasionally make an appearance. Generally, these are used for Things You Might Regret Not Knowing About Before…

We are going to cover a huge amount of ground over the course of our sojourn, our journey, but you won’t be traveling unprepared. Our overall objective here is to build a game hosted by and in a generic web application. Over the course of three separate parts, we’re going to progressively do three things:

  • Create and set up an application and development workflow that gives Space-Truckers: The Video Game! a place to live
  • Layer on additional functionality to our application (hosting Space-Truckers: The Video Game!)
  • Zoom out on the level of detail to take on a wide range of enhancements and add to our good knowledge

Each chapter will build on the work established in the previous chapter. It’s possible that the code in one chapter will need to be modified in subsequent chapters, and that should be looked at as a reflection of our evolving understanding of how the application needs to be structured to accomplish the goal at hand. Every chapter (save this one) contains links to the game’s code in the same context as the chapter’s text, in addition to live demos and Playground links specific to the content.

While we are building upon the application, we will also be providing fewer and fewer line-by-line code details in favor of providing extra context and/or information relating to how something works “under the hood.” Don’t worry, the code and Playground samples are still there to help you find your way! We’ll be exploring concepts that in themselves can occupy entire texts longer than this not-very-short book, and we’ll be doing so with less room to expand on those same topics. As a result, we will be looking to cover some areas at a high level while others will be discussed to a greater depth.

We’re going to start by walking through the game from the standpoint of the player, then we’ll move on to look at the underlying game and application design. As a finisher, we wrap this first travel segment up with a tour of the Space-Truckers GitHub repository and other online resources. Let’s start with the ending, in classic literary fashion.

Note

For the movie version of this scene, picture a shimmering dissolve with appropriate sound effects as we transition to a different world…