|
1 | 1 | # AR.js-core |
2 | 2 |
|
3 | | -An attempt to convert the Ar.js threex library into an agnostic library that can be used with any 3D library. |
| 3 | +A renderer-agnostic AR library built on a modern Entity-Component-System (ECS) architecture with a plugin system. |
4 | 4 |
|
5 | | -## New: ECS Architecture |
| 5 | +## ECS-Only Core |
6 | 6 |
|
7 | | -AR.js Core now includes a modern Entity-Component-System (ECS) architecture with a plugin system! This provides: |
| 7 | +**Migration Note:** As of version 0.2.0, AR.js-core is **ECS-only**. The legacy API (Source, Profile, Session, SessionDebugUI classes) has been removed from the core library to focus on: |
8 | 8 |
|
9 | 9 | - Modular design with a clean plugin system |
10 | 10 | - Data-oriented ECS for efficient processing |
11 | 11 | - Event-driven architecture with pub/sub messaging |
12 | | -- Backward compatible with existing Source and Profile APIs |
| 12 | +- Renderer-agnostic foundation for AR.js-next |
| 13 | + |
| 14 | +**Renderer integrations** (e.g., Three.js) now live in external repositories: |
| 15 | + |
| 16 | +- [arjs-plugin-threejs](https://github.com/AR-js-org/arjs-plugin-threejs) - Three.js integration plugin |
| 17 | + |
| 18 | +If you need the legacy API, please use version 0.1.x or migrate to the new ECS architecture documented below. |
13 | 19 |
|
14 | 20 | ### Quick Start with ECS |
15 | 21 |
|
16 | 22 | ```javascript |
17 | | -import { Engine, CaptureSystem, SOURCE_TYPES } from 'ar.js-core'; |
18 | | -import { webcamPlugin } from './plugins/source/webcam.js'; |
19 | | -import { defaultProfilePlugin } from './plugins/profile/default-policy.js'; |
| 23 | +import { |
| 24 | + Engine, |
| 25 | + CaptureSystem, |
| 26 | + SOURCE_TYPES, |
| 27 | + webcamPlugin, |
| 28 | + defaultProfilePlugin, |
| 29 | +} from 'ar.js-core'; |
20 | 30 |
|
21 | 31 | // Create engine and register plugins |
22 | 32 | const engine = new Engine(); |
@@ -47,9 +57,7 @@ Detection plugins (e.g., ArtoolkitPlugin) expect frames to arrive as `ImageBitma |
47 | 57 | ### Basic integration |
48 | 58 |
|
49 | 59 | ```js |
50 | | -import { CaptureSystem } from './src/systems/capture-system.js'; |
51 | | -import { SOURCE_TYPES } from './src/core/components.js'; |
52 | | -import { FramePumpSystem } from './src/systems/frame-pump-system.js'; |
| 60 | +import { CaptureSystem, SOURCE_TYPES, FramePumpSystem } from 'ar.js-core'; |
53 | 61 |
|
54 | 62 | // 1) Initialize capture (provides a playing <video>) |
55 | 63 | await CaptureSystem.initialize( |
@@ -98,24 +106,44 @@ FramePumpSystem.stop(ctx); |
98 | 106 | - Capture System: Unified interface for webcam, video, and image sources |
99 | 107 | - Profile Policies: Automatic device detection and performance tuning |
100 | 108 |
|
101 | | -## Build library bundle with Vite |
| 109 | +## Distribution and imports |
102 | 110 |
|
103 | | -AR.js Core can be bundled with Vite in library mode to produce importable ESM and CommonJS files. |
| 111 | +AR.js Core is distributed as both ESM and CommonJS modules: |
104 | 112 |
|
105 | | -**Commands** |
| 113 | +- **ESM (recommended)**: `dist/arjs-core.mjs` - Use with modern bundlers and browsers |
| 114 | +- **CommonJS**: `dist/arjs-core.js` - Use with Node.js or older bundlers |
106 | 115 |
|
107 | | -```bash |
108 | | -npm run build:vite |
| 116 | +### Import examples |
| 117 | + |
| 118 | +**ESM (Browser/Vite/Webpack 5+):** |
| 119 | + |
| 120 | +```javascript |
| 121 | +import { Engine, CaptureSystem, webcamPlugin } from 'ar.js-core'; |
| 122 | +``` |
| 123 | + |
| 124 | +**CommonJS (Node.js):** |
| 125 | + |
| 126 | +```javascript |
| 127 | +const { Engine, CaptureSystem, webcamPlugin } = require('ar.js-core'); |
109 | 128 | ``` |
110 | 129 |
|
111 | | -**Outputs** (written to dist/) |
| 130 | +**Direct script tag (not recommended for production):** |
112 | 131 |
|
113 | | -- `dist/arjs-core.mjs` (ESM — used by `exports.import` / `module`) |
114 | | -- `dist/arjs-core.js` (CommonJS — used by `exports.require` / `main`) |
| 132 | +```html |
| 133 | +<script type="module"> |
| 134 | + import { Engine } from './node_modules/ar.js-core/dist/arjs-core.mjs'; |
| 135 | +</script> |
| 136 | +``` |
| 137 | + |
| 138 | +### Build from source |
| 139 | + |
| 140 | +```bash |
| 141 | +npm run build:vite |
| 142 | +``` |
115 | 143 |
|
116 | | -**Notes** |
| 144 | +This builds both `dist/arjs-core.mjs` (ESM) and `dist/arjs-core.js` (CommonJS). |
117 | 145 |
|
118 | | -- Webpack scripts remain for legacy/dev workflows; Vite handles the library bundles. |
| 146 | +**Note:** Webpack scripts remain for legacy/dev workflows; Vite handles the library bundles. |
119 | 147 |
|
120 | 148 | ## Documentation |
121 | 149 |
|
@@ -268,13 +296,3 @@ Use this checklist when the example or your integration doesn’t behave as expe |
268 | 296 |
|
269 | 297 | - Prefer `HTMLVideoElement.requestVideoFrameCallback` when available; it syncs to decoder frames. |
270 | 298 | - If needed, throttle frame emission in the pump to reduce CPU usage (e.g., skip frames). |
271 | | - |
272 | | -## Legacy API |
273 | | - |
274 | | -The original Source and Profile classes are still available and fully supported: |
275 | | - |
276 | | -```javascript |
277 | | -import { Source, Profile } from 'arjs-core'; |
278 | | -``` |
279 | | - |
280 | | -See existing documentation for legacy API usage. |
|
0 commit comments