Babylon JS Day 4
Today I completed the final two chapters of the Babylon JS Getting Started guide. These chapters focused mostly on lighting and cameras, but also briefly touched on GUI. Today’s interesting items are
- Babylon JS has all the common 3D lighting types that I would expect. It has point, directional, spot, and hemispheric (ambient) lights.
- Hemispheric lights don’t cast shadows, so for most scenes where I want shadows, I’ll need to add a directional light.
- Adding shadows is a bit more involved than other platforms I’ve worked in. In addition to adding a light source that can cast shadows, I’ll need to add a `
ShadowGenerator
` to the scene. Then I need to add meshes that can cast shadows to the generater via the `addShadowCaster` method. Objects that need to receive shadows need to have the `receiveShadows
` property flag set to true. - Babylon JS has several camera types. I’ve been using the `ArcRotateCamera` for most of the demo scenes so far. Interestingly, this camera can be attached to an object as a child to create a basic third-person camera view.
- There is also a handy camera called `FollowCamera` that does what it says on the tin. Instead of attaching the camera to an object, I can just pass it the name of a mesh to track. This is useful when I want to have a camera track several objects over time in a scene.
This concludes my tour of the basics of Babylon JS. At this point I have a better idea of what Babylon JS has to offer and I’m started to get a feel for how it implements common features, how the API is structured. Tomorrow I’m going to dive into my first “project day” where I’ll try to build something (or several things) with what I’ve learned this week.