Add ECS architecture with plugin system for modular AR capture #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduces a data-oriented ECS (Entity-Component-System) core with plugin system for AR.js-core. Provides source capture plugins (webcam, video, image), device profiling, and a capture system. Existing
SourceandProfileclasses remain unchanged for backward compatibility.Core Architecture
src/core/ecs.js) - Entities, components, queries, resourcessrc/core/event-bus.js) - Pub/sub for decoupled messagingsrc/core/plugin-manager.js) - Register/enable/disable pluginssrc/core/engine.js) - Game loop and system orchestrationsrc/core/components.js) - Shared data structures:ProcessingConfig,CaptureState,FrameSourceRef,DeviceProfileSystems & Plugins
src/systems/capture-system.js) - Initializes capture plugin, manages state, emits lifecycle eventsplugins/source/) - Webcam (getUserMedia), video file, image captureplugins/profile/default-profile.js) - Auto-detects mobile/desktop, applies performance settingsUsage
Examples
Two working examples in
examples/basic-ecs/:index.html- Webcam capture demoimage-example.html- Image source demoExports
New ECS exports added to
src/index.jsalongside existing API. Session/SessionDebugUI temporarily disabled due to pre-existingthree.jsdependency issue.Documentation
docs/ecs-architecture.md- Complete architecture guideREADME.md- Updated with ECS quick startOriginal prompt
Goal
Introduce a modular, data-oriented core to AR.js-core using an ECS (Entity-Component-System) architecture and a plugin system. Provide initial source capture plugins (webcam, video, image), a default profile policy plugin, a capture system, and a minimal example app. Keep current classes (arjs-source.js, arjs-profile.js) intact but add legacy adapters that map the old API to the new internals to preserve backward compatibility. Add basic build wiring (ESM + dev server) and documentation.
Scope of this PR
Acceptance criteria
Implementation notes / skeletons to include
Below are minimal skeletons to implement (adapt file paths if needed). These are intentionally compact and can be refined later.
This pull request was created as a result of the following prompt from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.