{"id":13566721,"url":"https://github.com/DisownedWheat/BabylonJS-Game-Logic-Examples","last_synced_at":"2025-04-04T00:32:08.172Z","repository":{"id":42851196,"uuid":"261591771","full_name":"DisownedWheat/BabylonJS-Game-Logic-Examples","owner":"DisownedWheat","description":"A collection of small projects that show possible ways of handling game logic with BabylonJS","archived":false,"fork":false,"pushed_at":"2024-04-22T20:30:40.000Z","size":1606,"stargazers_count":28,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-01T13:36:52.084Z","etag":null,"topics":["babylonjs","gamedev","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DisownedWheat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-05T21:55:48.000Z","updated_at":"2024-05-22T06:53:39.000Z","dependencies_parsed_at":"2024-04-22T21:53:22.046Z","dependency_job_id":null,"html_url":"https://github.com/DisownedWheat/BabylonJS-Game-Logic-Examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DisownedWheat%2FBabylonJS-Game-Logic-Examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DisownedWheat%2FBabylonJS-Game-Logic-Examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DisownedWheat%2FBabylonJS-Game-Logic-Examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DisownedWheat%2FBabylonJS-Game-Logic-Examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DisownedWheat","download_url":"https://codeload.github.com/DisownedWheat/BabylonJS-Game-Logic-Examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223075381,"owners_count":17083506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babylonjs","gamedev","typescript"],"created_at":"2024-08-01T13:02:15.316Z","updated_at":"2024-11-04T21:30:51.706Z","avatar_url":"https://github.com/DisownedWheat.png","language":"TypeScript","funding_links":[],"categories":["Projects","TypeScript"],"sub_categories":[],"readme":"# BabylonJS Typescript Logic Examples\n\nThis repo is a collection of simple examples showing some ways of handling game logic within Babylon JS. This list is in no way exhaustive as Babylon is a very unopinionated framework.\n\nThese are also only my personal experiences so don't consider this an authoritative souce but more as an example to get you started on your own ideas.\n\n## Building Examples\n- Run `npm install`\n- Run `npm buildX`  where `X` is the number of the directory (1 is Inheritance, 2 is Behaviours \u0026 Observables, etc.)\n- Run `npm buildAll` to build all examples\n- Each example will have its output in its own `dist` directory\n\n# Observations\n\nPlease do note that these are my personal experiences and should in no way taken as gospel for or against these options.\n\n## Inheritance\n\n### Pros:\n- Works well with how the Babylon project is structured\n- Requires no external libraries\n- Basic OOP makes it easy to learn\n- Integrates well with Babylon scene tree\n- Easy to debug\n\n### Cons:\n- General problems with OOP inheritance model\n- Have to write a lot of your own logic to keep references to game objects\n- I just don't like it very much\n\n## Behaviours and Observables\n\n### Pros:\n- Integrates well with Babylon\n- Requires no external libraries\n- Very well thought out design\n- Very flexible in how to handle your logic\n- Easy to extend your own custom behaviours\n- Flexible options with how observers are scoped and when they are called\n- Very nice to work with in a typed language\n- Easy to attach and remove behaviours\n- Easy to debug\n\n### Cons:\n- Somewhat boilerplate-y\n- Querying objects for behaviours relies on strings which isn't quite as nice as querying class references\n- Potential performance concerns (not that I've run into any performance issues with it yet but it would be easy to create poor-performing code with lots of closures in a behavior class)\n\n## ECS\n\n### Pros:\n- Very intuitive once you've wrapped your head around the pattern\n- Apparently very performant\n- Forced to organise code reasonably well\n- Excellent separation of concerns\n- Querying components based on class reference is nice when working with TS (this is particular to the `tick-knock` library)\n- Easy to debug\n\n### Cons:\n- Very boilerplate-y\n- Takes a while to set up (but pays off massively on larger projects)\n- Takes some time to adjust how to manage logic when working in a new paradigm\n- Does not integrate with Babylon's scene tree very well (feels quite separate)\n\n## Event Based Architecture\n\n### Pros:\n- A lot of fun\n- Entities are mostly completely separated and only communicate via an event bus which prevents tight coupling\n- `nanoevents` library is a joy to use with TS\n- Easier to integrate into Babylon's scene tree than ECS but has similar advantages\n- Allows very rapid prototyping\n- Can integrate cleanly with all other systems on this list\n\n### Cons:\n- Harder to debug\n- Requires some rethinking of control flow logic\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDisownedWheat%2FBabylonJS-Game-Logic-Examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDisownedWheat%2FBabylonJS-Game-Logic-Examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDisownedWheat%2FBabylonJS-Game-Logic-Examples/lists"}