@combos-fun/plugin-renderer 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -1
- package/agent-skill.md +131 -0
- package/combos-plugin.json +17 -0
- package/package.json +18 -4
package/README.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
1
|
# @combos-fun/plugin-renderer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
@combos-fun/plugin-renderer — part of the Combos Fun engine monorepo.
|
|
4
|
+
|
|
5
|
+
Keywords: `pixi`, `rendering`, `canvas`, `2d`, `renderer-base`, `container`.
|
|
6
|
+
|
|
7
|
+
## Documentation
|
|
8
|
+
|
|
9
|
+
- Per-package agent / developer notes: [`agent-skill.md`](./agent-skill.md)
|
|
10
|
+
- Machine-readable manifest: [`combos-plugin.json`](./combos-plugin.json)
|
|
11
|
+
(validated against `schemas/combos-plugin.schema.json` in the repo
|
|
12
|
+
root)
|
|
13
|
+
- Entry skill (single source of truth for AI agents working with this
|
|
14
|
+
monorepo): `skills/combos-engine-development/SKILL.md`
|
|
15
|
+
|
|
16
|
+
When consumed from npm, the manifest and agent notes are exposed as
|
|
17
|
+
stable subpaths:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import manifest from '@combos-fun/plugin-renderer/plugin-manifest';
|
|
21
|
+
// or fetch the markdown directly:
|
|
22
|
+
// require.resolve('@combos-fun/plugin-renderer/agent-skill')
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
Internal workspace package, part of the Combos Fun engine monorepo.
|
package/agent-skill.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# `@combos-fun/plugin-renderer` — Agent notes
|
|
2
|
+
|
|
3
|
+
2D rendering foundation for Combos Fun. Wraps Pixi v8 via
|
|
4
|
+
`@combos-fun/renderer-adapter` and exposes the `RendererSystem`,
|
|
5
|
+
`Renderer` base class, and the `containerManager` / `rendererManager`
|
|
6
|
+
machinery that all 2D rendering sub-plugins extend.
|
|
7
|
+
|
|
8
|
+
## When to read
|
|
9
|
+
|
|
10
|
+
Read for any 2D rendering task: setting up a canvas, blank-canvas
|
|
11
|
+
debugging, custom 2D renderer plugins, `Container` parenting / sorting.
|
|
12
|
+
All `plugin-renderer-*` 2D sub-plugins assume this file is already
|
|
13
|
+
loaded.
|
|
14
|
+
|
|
15
|
+
## Public API
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {
|
|
19
|
+
RendererSystem,
|
|
20
|
+
Renderer,
|
|
21
|
+
RendererManager,
|
|
22
|
+
ContainerManager,
|
|
23
|
+
RENDERER_TYPE,
|
|
24
|
+
} from '@combos-fun/plugin-renderer';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### `RendererSystem`
|
|
28
|
+
|
|
29
|
+
`systemName = 'Renderer'`. Init params:
|
|
30
|
+
|
|
31
|
+
| Field | Type | Default | Notes |
|
|
32
|
+
|-------|------|---------|-------|
|
|
33
|
+
| `canvas` | `HTMLCanvasElement` | — | **Required** |
|
|
34
|
+
| `width` | `number` | — | Logical canvas width |
|
|
35
|
+
| `height` | `number` | — | Logical canvas height |
|
|
36
|
+
| `transparent` | `boolean` | `false` | |
|
|
37
|
+
| `resolution` | `number` | — | Match `PhysicsSystem.resolution` |
|
|
38
|
+
| `enableScroll` | `boolean` | `false` | |
|
|
39
|
+
| `renderType` | `RENDERER_TYPE` | `UNKNOWN` | `WEBGL`, `CANVAS`, or `UNKNOWN` |
|
|
40
|
+
|
|
41
|
+
System exposes `rendererManager` (collects all `Renderer` subclasses) and
|
|
42
|
+
`containerManager` (per-`GameObject.id` Pixi `Container`).
|
|
43
|
+
|
|
44
|
+
### `Renderer` base class
|
|
45
|
+
|
|
46
|
+
Extend this for any custom 2D rendering plugin. Required overrides:
|
|
47
|
+
|
|
48
|
+
- `init()` — call `this.rendererSystem = this.game.getSystem(RendererSystem)`
|
|
49
|
+
then `this.rendererSystem.rendererManager.register(this)`.
|
|
50
|
+
- `componentChanged(changed)` — handle `OBSERVER_TYPE.ADD | CHANGE | REMOVE`,
|
|
51
|
+
manipulate Pixi display objects via
|
|
52
|
+
`this.rendererSystem.containerManager.getContainer(gameObject.id)`.
|
|
53
|
+
- `rendererUpdate(gameObject)` — per-frame sync (transform, alpha, etc.).
|
|
54
|
+
|
|
55
|
+
Combine with `@decorators.componentObserver({ MyFeature: ['prop'] })` from
|
|
56
|
+
`@combos-fun/engine`.
|
|
57
|
+
|
|
58
|
+
### `containerManager.getContainer(gameObject.id)`
|
|
59
|
+
|
|
60
|
+
Returns the per-GameObject `Container` from `@combos-fun/renderer-adapter`.
|
|
61
|
+
Always parent your display objects under this container, never directly to
|
|
62
|
+
the Pixi stage.
|
|
63
|
+
|
|
64
|
+
## Required setup
|
|
65
|
+
|
|
66
|
+
`RendererSystem` **must** be the first system (or among the first) added to
|
|
67
|
+
`Game.systems`, before any other 2D rendering / event / a11y sub-system that
|
|
68
|
+
calls `getSystem(RendererSystem)` in `init`.
|
|
69
|
+
|
|
70
|
+
Typical 2D system order:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
new Game({
|
|
74
|
+
systems: [
|
|
75
|
+
new RendererSystem({ canvas, width, height }),
|
|
76
|
+
new RenderSystem(), // visibility / alpha / zIndex
|
|
77
|
+
new ImgSystem(), // images
|
|
78
|
+
new TextSystem(), // text
|
|
79
|
+
new EventSystem(), // pointer events
|
|
80
|
+
// ...physics, audio, a11y
|
|
81
|
+
],
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Runtime behaviour
|
|
86
|
+
|
|
87
|
+
- Each `Renderer` subclass self-registers via `rendererManager.register(this)`
|
|
88
|
+
in its `init`. The base system iterates all registered renderers each
|
|
89
|
+
frame.
|
|
90
|
+
- `containerManager` lazily creates a Pixi `Container` per `GameObject` on
|
|
91
|
+
first access and removes it when the `GameObject` is destroyed.
|
|
92
|
+
- Don't mix conflicting drawables on a single `GameObject` (`Img` + `Sprite`
|
|
93
|
+
+ `SpriteAnimation` on the same node fights for the same container slot).
|
|
94
|
+
Split across separate `GameObject`s.
|
|
95
|
+
|
|
96
|
+
## Common pitfalls
|
|
97
|
+
|
|
98
|
+
| Symptom | Fix |
|
|
99
|
+
|---------|-----|
|
|
100
|
+
| Blank canvas | Add `RendererSystem` to `systems`, ensure `autoStart: true` or call `game.start()` |
|
|
101
|
+
| Nothing draws | Add the matching sub-system (`ImgSystem`, `TextSystem`, etc.) before adding the component |
|
|
102
|
+
| Invisible / wrong alpha | Add `RenderSystem` from `plugin-renderer-render` for `visible` / `alpha` / `zIndex` |
|
|
103
|
+
| Blurry / wrong scale | Match `resolution` between `RendererSystem` and `PhysicsSystem` |
|
|
104
|
+
| `getSystem` undefined | Use class reference, not string: `game.getSystem(RendererSystem)` |
|
|
105
|
+
| Stacked drawables fight | Split Img / Sprite / SpriteAnimation / NinePatch onto separate `GameObject`s |
|
|
106
|
+
|
|
107
|
+
## Minimal example
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { Game } from '@combos-fun/engine';
|
|
111
|
+
import { RendererSystem } from '@combos-fun/plugin-renderer';
|
|
112
|
+
|
|
113
|
+
new Game({
|
|
114
|
+
systems: [
|
|
115
|
+
new RendererSystem({
|
|
116
|
+
canvas: document.querySelector('#canvas')!,
|
|
117
|
+
width: 750,
|
|
118
|
+
height: 1334,
|
|
119
|
+
}),
|
|
120
|
+
],
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
This alone is just an empty Pixi stage. Add `plugin-renderer-render`,
|
|
125
|
+
`plugin-renderer-img`, etc. and matching components to render anything.
|
|
126
|
+
|
|
127
|
+
## Verification
|
|
128
|
+
|
|
129
|
+
- `pnpm --filter @combos-fun/plugin-renderer run build`
|
|
130
|
+
- Run an example app from `examples/` and check for blank canvas / Pixi
|
|
131
|
+
WebGL errors in the browser console.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@combos-fun/plugin-renderer",
|
|
3
|
+
"pluginId": "renderer",
|
|
4
|
+
"category": "rendering",
|
|
5
|
+
"dimension": "2d",
|
|
6
|
+
"isCore": false,
|
|
7
|
+
"keywords": ["pixi", "rendering", "canvas", "2d", "renderer-base", "container"],
|
|
8
|
+
"agentSkill": "./agent-skill.md",
|
|
9
|
+
"requires": ["@combos-fun/engine", "@combos-fun/renderer-adapter"],
|
|
10
|
+
"exports": [
|
|
11
|
+
"RendererSystem",
|
|
12
|
+
"Renderer",
|
|
13
|
+
"RendererManager",
|
|
14
|
+
"ContainerManager",
|
|
15
|
+
"RENDERER_TYPE"
|
|
16
|
+
]
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combos-fun/plugin-renderer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "@combos-fun/plugin-renderer",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer.esm.js",
|
|
@@ -8,8 +8,22 @@
|
|
|
8
8
|
"unpkg": "dist/CombosFun.plugin.renderer.min.js",
|
|
9
9
|
"files": [
|
|
10
10
|
"index.js",
|
|
11
|
-
"dist"
|
|
11
|
+
"dist",
|
|
12
|
+
"agent-skill.md",
|
|
13
|
+
"combos-plugin.json"
|
|
12
14
|
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./dist/plugin-renderer.esm.js",
|
|
18
|
+
"require": "./index.js",
|
|
19
|
+
"types": "./dist/plugin-renderer.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./plugin-manifest": "./combos-plugin.json",
|
|
22
|
+
"./agent-skill": "./agent-skill.md"
|
|
23
|
+
},
|
|
24
|
+
"combos": {
|
|
25
|
+
"pluginManifest": "./combos-plugin.json"
|
|
26
|
+
},
|
|
13
27
|
"types": "dist/plugin-renderer.d.ts",
|
|
14
28
|
"keywords": [
|
|
15
29
|
"combos-fun",
|
|
@@ -21,8 +35,8 @@
|
|
|
21
35
|
"lodash-es": "^4.17.21",
|
|
22
36
|
"pixi.js": "^8.18.1",
|
|
23
37
|
"resource-loader": "^4.0.0-rc4",
|
|
24
|
-
"@combos-fun/
|
|
25
|
-
"@combos-fun/
|
|
38
|
+
"@combos-fun/renderer-adapter": "0.0.7",
|
|
39
|
+
"@combos-fun/engine": "0.0.7"
|
|
26
40
|
},
|
|
27
41
|
"scripts": {
|
|
28
42
|
"build": "node ../../scripts/build-package.mjs"
|