@craigfeldspar/gamable-ecs
v0.9.1
Published
Entity Component System library for Babylon.js
Maintainers
Readme
@craigfeldspar/gamable-ecs
Entity Component System library for Babylon.js applications.
Development
This package is part of the Gamable monorepo and uses PNPM workspaces for local development.
Local Development Setup
Install dependencies (from the monorepo root):
pnpm installBuild the ECS library:
npm run build:ecsWatch mode for development:
npm run dev:ecs
Usage in Gamable App
The ECS library is automatically linked as a workspace dependency in the Gamable app. You can import it directly:
import { World, Entity, Component, System } from "@craigfeldspar/gamable-ecs";
// Create a new world
const world = new World();
// Use ECS components
const entity = new Entity();
// ... etcUsage in Code Editor
The ECS types are automatically available in the Monaco code editor. You can use them in your TypeScript files:
// This will have full TypeScript intellisense
import { World } from "@craigfeldspar/gamable-ecs";
const world = new World();Publishing to NPM
To publish this package to NPM for external use:
Build the package:
npm run build:ecsPublish:
npm run publish:ecs
Package Structure
src/- Source TypeScript filesdist/- Compiled JavaScript and type definitions (generated)package.json- Package configurationtsconfig.json- TypeScript configuration
Workspace Integration
This package uses the workspace:* protocol in the Gamable app's package.json, which means:
- During development: Uses the local package from
packages/ecs - In production: Can be replaced with the published NPM version by changing
workspace:*to the actual version number
To switch to the NPM version, update the Gamable app's package.json:
{
"dependencies": {
"@craigfeldspar/gamable-ecs": "^0.1.0" // Instead of "workspace:*"
}
}