@combos-fun/plugin-renderer-3d 0.1.15 → 0.1.17
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/agent-skill.md
CHANGED
|
@@ -1,138 +1,60 @@
|
|
|
1
1
|
# `@combos-fun/plugin-renderer-3d` — Agent notes
|
|
2
2
|
|
|
3
|
-
3D
|
|
3
|
+
3D foundation. Read before any `plugin-renderer-3d-*` leaf.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
- Replace or override materials on an existing visual → sibling `Material3D`
|
|
13
|
-
|
|
14
|
-
## Public API
|
|
15
|
-
|
|
16
|
-
The current package entry exports these runtime values:
|
|
5
|
+
- Primitive → `Graphics3D`
|
|
6
|
+
- One image → `Img3D`
|
|
7
|
+
- Labels and HUD → `Text3D` or `Img3D` on the engine canvas
|
|
8
|
+
- GLB / glTF / FBX / OBJ / STL / DAE / PLY → `Model3D`
|
|
9
|
+
- Repeated texture → `TilingSprite3D`
|
|
10
|
+
- Spritesheet → `SpriteAnimation3D`
|
|
11
|
+
- Material override → sibling `Material3D`
|
|
17
12
|
|
|
18
13
|
```ts
|
|
19
14
|
import {
|
|
20
|
-
Renderer3DSystem,
|
|
21
|
-
|
|
22
|
-
Render3D, Render3DSystem,
|
|
23
|
-
Camera3D, Camera3DSystem,
|
|
24
|
-
Light3D, Light3DSystem,
|
|
25
|
-
COMBOS_GAME_OBJECT_ID, COMBOS_TRANSFORM3D,
|
|
26
|
-
tagObject3D, gameObjectIdFromObject3D, gameObjectIdFromIntersection,
|
|
27
|
-
isTransform3DRoot,
|
|
28
|
-
requireNamedResource, textureFromNamedImage, textureFromResourceImage,
|
|
29
|
-
is3DSceneParent, has3DChildGameObjects,
|
|
30
|
-
readPose, poseKeyOf, copyPose, isIdentityPose, seedTransform3D,
|
|
31
|
-
VisualPoseBridge,
|
|
15
|
+
Renderer3DSystem, Transform3D, Transform3DSystem,
|
|
16
|
+
Render3D, Render3DSystem, Camera3D, Camera3DSystem, Light3D, Light3DSystem,
|
|
32
17
|
} from '@combos-fun/plugin-renderer-3d';
|
|
33
18
|
```
|
|
34
19
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
### `Renderer3DSystem`
|
|
38
|
-
|
|
39
|
-
`systemName = 'Renderer3DSystem'`. Init params:
|
|
40
|
-
|
|
41
|
-
| Field | Type | Default |
|
|
42
|
-
|-------|------|---------|
|
|
43
|
-
| `canvas` | `HTMLCanvasElement?` | — |
|
|
44
|
-
| `container` | `HTMLElement?` | — |
|
|
45
|
-
| `width` | `number` | `750` |
|
|
46
|
-
| `height` | `number` | `1334` |
|
|
47
|
-
| `antialias` | `boolean` | `true` |
|
|
48
|
-
| `backgroundColor` | `number` | `0x000000` |
|
|
49
|
-
| `backgroundAlpha` | `number` | `1` |
|
|
50
|
-
| `fog` | `boolean \| { color?, near?, far? }` | `false`; object defaults: background color / `8` / `40` |
|
|
51
|
-
| `hemisphereLight` | `boolean \| { skyColor?, groundColor?, intensity? }` | on; `0xffffff` / `0x444444` / `0.35` |
|
|
52
|
-
| `shadows` | `boolean` | `false` |
|
|
53
|
-
| `toneMapping` | `'none' \| 'aces' \| 'linear' \| 'reinhard' \| 'cineon'` | `'aces'` |
|
|
54
|
-
| `toneMappingExposure` | `number` | `1` |
|
|
55
|
-
| `ambientIntensity` | `number` | `0.6` |
|
|
56
|
-
| `directionalIntensity` | `number` | `0.8` |
|
|
57
|
-
|
|
58
|
-
Pass `canvas` to reuse an element. With no `canvas`, `container` appends the newly created renderer canvas; with neither, the canvas is created but not mounted. Defaults also include a perspective camera (FOV `75`, near `0.1`, far `1000`, z=`5`), ambient light, directional light at `(5, 10, 7.5)`, hemisphere light, `WebGLRenderer`, and `Clock`.
|
|
59
|
-
|
|
60
|
-
## Shared contracts for every leaf plugin
|
|
61
|
-
|
|
62
|
-
### System order
|
|
63
|
-
|
|
64
|
-
`Renderer3DSystem` must precede every 3D leaf system because each leaf registers with its `rendererManager` during `init`. Add `Transform3DSystem`, `Render3DSystem`, camera/light systems, drawable systems, then overlays such as `Material3DSystem`; add `Event3DSystem` for picking. `Transform3DSystem` is optional for root creation because `Renderer3DSystem` also ensures roots, but it remains the normal pose system.
|
|
65
|
-
|
|
66
|
-
```ts
|
|
67
|
-
new Game({
|
|
68
|
-
systems: [
|
|
69
|
-
new Renderer3DSystem({ canvas, width: 750, height: 1334, shadows: true }),
|
|
70
|
-
new Transform3DSystem(),
|
|
71
|
-
new Render3DSystem(),
|
|
72
|
-
new Camera3DSystem(),
|
|
73
|
-
new Light3DSystem(),
|
|
74
|
-
new Graphics3DSystem(),
|
|
75
|
-
new Img3DSystem(),
|
|
76
|
-
new Material3DSystem(),
|
|
77
|
-
new Event3DSystem(),
|
|
78
|
-
],
|
|
79
|
-
});
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Named resources
|
|
83
|
-
|
|
84
|
-
`resource` fields contain an engine resource **name**, not a URL or path. Register the appropriate `RESOURCE_TYPE` with `resource.addResource`; URLs belong in `src`. There is no URL fallback. `requireNamedResource` rejects empty or unknown names. Asset components currently skip ADD when their own `resource` is empty; image helpers build a Three `Texture` from `data.image`, leaving the 2D Pixi resource instance alone.
|
|
85
|
-
|
|
86
|
-
### Pose and hierarchy
|
|
87
|
-
|
|
88
|
-
`Transform3D` is the pose source of truth (`position*`, `rotation*`, `scale*`, plus computed world position/rotation). A Three `Group` root is created per non-Scene GameObject, so empty parents and local child transforms work.
|
|
89
|
-
|
|
90
|
-
Leaf visual pose fields are compatibility inputs. On first bridge sync, a non-identity visual pose seeds an identity sibling `Transform3D`; the visual object is then reset to identity under that root. Prefer writing `Transform3D` after setup. `attachVisual` tags the visual and parents it under the root; use it instead of `scene.add`.
|
|
91
|
-
|
|
92
|
-
### Async lifecycle
|
|
93
|
-
|
|
94
|
-
Asset-loading systems use a per-GameObject async id to reject stale work after
|
|
95
|
-
removal, replacement, or resource changes:
|
|
96
|
-
|
|
97
|
-
```ts
|
|
98
|
-
const asyncId = this.increaseAsyncId(gameObject.id);
|
|
99
|
-
const asset = await loadSomething();
|
|
100
|
-
if (!this.validateAsyncId(gameObject.id, asyncId)) return;
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Dispose assets created by rejected work. `Model3DSystem` is an exception: it
|
|
104
|
-
validates after attachment, so its skill documents the stale-clone risk.
|
|
20
|
+
`Renderer3DSystem.systemName = 'Renderer3DSystem'`. It must precede every 3D leaf. Then `Transform3DSystem`, `Render3DSystem`, camera/light, drawables, `Material3DSystem`, `Event3DSystem`.
|
|
105
21
|
|
|
106
|
-
|
|
22
|
+
| Param | Default |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| `width` / `height` | `750` / `1334` |
|
|
25
|
+
| `antialias` | `true` |
|
|
26
|
+
| `backgroundColor` / `backgroundAlpha` | `0x000000` / `1` |
|
|
27
|
+
| `fog` | `false` (object: background color / `8` / `40`) |
|
|
28
|
+
| `hemisphereLight` | on (`0xffffff` / `0x444444` / `0.35`) |
|
|
29
|
+
| `shadows` | `false` |
|
|
30
|
+
| `toneMapping` / `toneMappingExposure` | `'aces'` / `1` |
|
|
31
|
+
| `ambientIntensity` / `directionalIntensity` | `0.6` / `0.8` |
|
|
107
32
|
|
|
108
|
-
|
|
109
|
-
|-----------|-----------------------|
|
|
110
|
-
| `Render3D` | `visible: true`, `opacity: 1`, `renderOrder: 0`, `sortableChildren: false`. Every renderer update, `opacity` is written to **every mesh material under this GameObject's registered root Object3D subtree** (including nested child visuals), so it overrides visual/`Material3D` opacity for that frame. |
|
|
111
|
-
| `Camera3D` | Controls `fov`, `near`, `far`, `active`; `lookAt` is boolean with `lookAtX/Y/Z`. Without one, the fallback camera remains active. |
|
|
112
|
-
| `Light3D` | `type` defaults to `'directional'`; supports color/intensity/shadows and type-specific fields. The first `Light3D` removes all built-in default lights. |
|
|
33
|
+
Pass `canvas` to reuse it. Otherwise `container` mounts a new canvas. With neither, the canvas is created and not mounted. Default camera: FOV `75`, near `0.1`, far `1000`, `z = 5`, looking **-Z**, plus ambient, directional `(5, 10, 7.5)`, and hemisphere lights. `getSystem(Renderer3DSystem)` or `'Renderer3DSystem'`. Assets need a same-origin or CORS URL.
|
|
113
34
|
|
|
114
|
-
|
|
35
|
+
`resource` is an engine **name**. URLs go in `addResource` `src`.
|
|
115
36
|
|
|
116
|
-
|
|
37
|
+
`Transform3D` is the pose (`position*`, `rotation*`, `scale*`). Hierarchy is `addChild`. A non-identity visual pose seeds `Transform3D` once, then the visual resets to identity. Write pose on `Transform3D` after that. Parent visuals with `attachVisual`, not `scene.add`. `update` applies pose and leaf `rendererUpdate`; `lateUpdate` advances mixers and renders.
|
|
117
38
|
|
|
118
|
-
|
|
39
|
+
Default camera, no extra yaw, in `Component.update`:
|
|
119
40
|
|
|
120
|
-
|
|
41
|
+
| Intent | Write |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| into the scene | `positionZ -=` |
|
|
44
|
+
| toward the camera | `positionZ +=` |
|
|
45
|
+
| screen left | `positionX -=` |
|
|
46
|
+
| screen right | `positionX +=` |
|
|
121
47
|
|
|
122
|
-
|
|
48
|
+
`rotationY` is facing. Strafe stays on world X. Camera-relative: flatten look onto XZ as `forward`, then `right = forward × up`. Aim with `Camera3D` `lookAt` + `lookAtX/Y/Z` after `Camera3DSystem`. `Event3D` is pointer-only.
|
|
123
49
|
|
|
124
|
-
|
|
|
125
|
-
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
|
129
|
-
| `getSystem` is undefined | Use `game.getSystem(Renderer3DSystem)` or exact string `'Renderer3DSystem'` |
|
|
130
|
-
| Fast remove/re-add leaks or double-adds | Follow the async-id invalidation pattern |
|
|
131
|
-
| CORS failure | Serve assets from the same origin or a CORS-enabled URL registered in `src` |
|
|
50
|
+
| Component | |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `Render3D` | `visible`, `opacity` (default `1`), `renderOrder`, `sortableChildren`. `opacity` is written onto every mesh under this root each frame, including `Material3D`. |
|
|
53
|
+
| `Camera3D` | `fov`, `near`, `far`, `active`, `lookAt`. No `Camera3D`: the fallback camera stays active. |
|
|
54
|
+
| `Light3D` | `type` default `'directional'`. The first `Light3D` that runs removes the built-in lights. |
|
|
132
55
|
|
|
133
|
-
|
|
56
|
+
`shadows: true` makes official drawable meshes cast and receive shadows.
|
|
134
57
|
|
|
135
|
-
|
|
58
|
+
Asset loads must ignore stale results after remove or replace (`increaseAsyncId` / `validateAsyncId`). `Model3D` checks after attach.
|
|
136
59
|
|
|
137
|
-
|
|
138
|
-
- Run a 3D example and inspect WebGL/resource errors in the browser console.
|
|
60
|
+
Blank canvas: no `Renderer3DSystem`, canvas not mounted, or the game has not started. Nothing draws: missing leaf system. Invisible mesh: pose, camera distance, facing, lights, or the resource. `Render3D.opacity`, not `Render.alpha`. Physics: `plugin-cannon`. Custom renderers extend `Renderer3D`, register on `rendererManager`, and implement `componentChanged` / `rendererUpdate`. `tagObject3D` is only for bypassing `attachVisual`.
|
|
@@ -827,7 +827,7 @@ var Renderer3DSystem = Renderer3DSystem$1;
|
|
|
827
827
|
/** Auto-generated by scripts/build-package.mjs — do not edit. */
|
|
828
828
|
Object.assign(Renderer3DSystem, {
|
|
829
829
|
packageName: "@combos-fun/plugin-renderer-3d",
|
|
830
|
-
packageVersion: "0.1.
|
|
830
|
+
packageVersion: "0.1.17",
|
|
831
831
|
});
|
|
832
832
|
|
|
833
833
|
class Renderer3D extends engine.System {
|