Babylon.js project start-organization

I think those are really great questions. One important thing for me as well is the Developer Experience. So, I also always work on projects with hot module reloading (Fast Refresh/etc), so changes made in my editor are reflected in my scene as soon as I save. Having that work out well involves also managing state of your scene.

Something like a yeoman generator/CLI would be very cool to have, but I think it mainly useful for scaffolding an initial project.

I did some experimentation with Snowpack community templates, which have both JavaScript and TypeScript templates:
Snowpack community template - Demos and projects - Babylon.js (babylonjs.com)

If you did want to try out React - I have templates in JavaScript and Typescript - the JavaScript one uses a state management library:
TypeScript + Create React App Starter Kit (github.com)
JavaScript + Create React App Starter Kit (github.com)
Those above projects use a declarative renderer, but I have imperative examples too like here:
babylonjs vanilla typescript (github.com)

The declarative React projects are the ultimate way to enforce Composition. You can dynamically attach behaviors and really anything to objects and with state management and the reconciler doing the heavy lifting it can be a really good way to manage a scene from application state transparently and also all objects are managed and tracked automatically…

I did follow a Mozilla ECS implementation as well (and it has a Babylon demo):
Introducing ECSY: an Entity Component System framework for the Web (mozvr.com)

The general question about “Composition over Inheritance” is really a fundamental aspect found even back in the original gang of four book and to me it’s really developer preference and system design needs. In JavaScript we are lucky we have mixins and can do some interesting things with inheritance, but I will still choose composition when it makes sense from years of programming without multiple inheritance. If you look at behaviors (ie: Camera) in Babylon, which is in large part built using Inheritance, you can see they are dynamic behaviours and many other run-time polymorphic changes (which is the intent of composition as a pattern). If you are using inheritance then TypeScript is essential as it will let you know when an interface isn’t fully implemented or an abstract method not implemented, etc - whereas JavaScript will fail at runtime.

6 Likes