@combos-fun/plugin-renderer-3d-graphics 0.0.42 → 0.0.45
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 +1 -1
- package/agent-skill.md +43 -11
- package/combos-plugin.json +1 -1
- package/dist/plugin-renderer-3d-graphics.cjs.js +656 -62
- package/dist/plugin-renderer-3d-graphics.cjs.js.map +1 -1
- package/dist/plugin-renderer-3d-graphics.cjs.prod.js +1 -1
- package/dist/plugin-renderer-3d-graphics.d.ts +36 -6
- package/dist/plugin-renderer-3d-graphics.esm.js +658 -64
- package/dist/plugin-renderer-3d-graphics.esm.js.map +1 -1
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
@combos-fun/plugin-renderer-3d-graphics — part of the Combos Fun engine monorepo.
|
|
4
4
|
|
|
5
|
-
Keywords: `3d`, `graphics`, `primitives`, `box`, `sphere`, `cylinder`, `plane`.
|
|
5
|
+
Keywords: `3d`, `graphics`, `primitives`, `box`, `sphere`, `cylinder`, `plane`, `cone`, `torus`, `capsule`.
|
|
6
6
|
|
|
7
7
|
## Documentation
|
|
8
8
|
|
package/agent-skill.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# `@combos-fun/plugin-renderer-3d-graphics` — Agent notes
|
|
2
2
|
|
|
3
|
-
Procedural 3D
|
|
3
|
+
Procedural 3D primitives for the 3D pipeline. One `Graphics3D` becomes either a shared `InstancedMesh` (identical singles) or a `Group` of meshes (`parts`).
|
|
4
4
|
|
|
5
5
|
## When to read
|
|
6
6
|
|
|
7
|
-
Read for any procedural primitive: box, sphere, cylinder, plane, cone, torus, debug placeholders, simple terrain.
|
|
7
|
+
Read for any procedural primitive: box, sphere, cylinder, plane, cone, torus, capsule, debug placeholders, simple terrain, compound furniture.
|
|
8
8
|
|
|
9
9
|
Read **before** guessing that 3D has no rotation or no per-frame pose — do not wait for a compile error. Pose fields and a chase-camera pattern are below.
|
|
10
10
|
|
|
11
11
|
## Public API
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { Graphics3D, Graphics3DSystem, type Graphics3DParams } from '@combos-fun/plugin-renderer-3d-graphics';
|
|
14
|
+
import { Graphics3D, Graphics3DSystem, type Graphics3DParams, type Graphics3DPartParams } from '@combos-fun/plugin-renderer-3d-graphics';
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
`componentName = 'Graphics3D'`, `systemName = 'Graphics3DSystem'`.
|
|
@@ -20,31 +20,46 @@ import { Graphics3D, Graphics3DSystem, type Graphics3DParams } from '@combos-fun
|
|
|
20
20
|
|
|
21
21
|
| Field | Type | Default |
|
|
22
22
|
|-------|------|---------|
|
|
23
|
-
| `shape` | `'box' \| 'sphere' \| 'cylinder' \| 'plane' \| 'cone' \| 'torus'` | `'box'` |
|
|
23
|
+
| `shape` | `'box' \| 'sphere' \| 'cylinder' \| 'plane' \| 'cone' \| 'torus' \| 'capsule'` | `'box'` |
|
|
24
24
|
| `color` | `number` | `0x00ff00` |
|
|
25
25
|
| `wireframe` | `boolean` | `false` |
|
|
26
26
|
| `width` / `height` / `depth` | `number` | `1` |
|
|
27
27
|
| `radius` | `number` | `0.5` |
|
|
28
|
-
| `segments` | `number` | `
|
|
28
|
+
| `segments` | `number` | `12` |
|
|
29
|
+
| `tube` | `number` | `0` → `0.4 × radius` (torus only) |
|
|
29
30
|
| `positionX` / `Y` / `Z` | `number` | `0` |
|
|
30
31
|
| `rotationX` / `Y` / `Z` | `number` | `0` |
|
|
31
32
|
| `scaleX` / `Y` / `Z` | `number` | `1` |
|
|
32
33
|
| `opacity` | `number` | `1` |
|
|
34
|
+
| `roughness` / `metalness` | `number` | `1` / `0` (`standard` only) |
|
|
35
|
+
| `emissive` | `number` | `0` (hex) |
|
|
36
|
+
| `map` | `string` | `''` (engine `IMAGE` name) |
|
|
37
|
+
| `doubleSide` | `boolean` | `false` |
|
|
38
|
+
| `material` | `'standard' \| 'basic' \| 'lambert' \| 'toon'` | `'standard'` |
|
|
39
|
+
| `instanced` | `boolean` | `true` |
|
|
40
|
+
| `parts` | `Graphics3DPartParams[]` | — |
|
|
33
41
|
|
|
34
|
-
|
|
42
|
+
`parts` replaces the single primitive. Each part can override shape / color / map / local pose. The component pose still moves the whole group.
|
|
43
|
+
|
|
44
|
+
Shape → Three.js geometry: `box → BoxGeometry`, `sphere → SphereGeometry`, `cylinder → CylinderGeometry`, `plane → PlaneGeometry` (uses `segments` as width/height segs), `cone → ConeGeometry`, `torus → TorusGeometry`, `capsule → CapsuleGeometry` (`height` is total height).
|
|
45
|
+
|
|
46
|
+
Identical singles (same geometry + material, `instanced !== false`, no `parts`) share one `InstancedMesh`. Geometry and materials are cached.
|
|
35
47
|
|
|
36
48
|
## Required setup
|
|
37
49
|
|
|
38
|
-
`Renderer3DSystem` then `Graphics3DSystem`.
|
|
50
|
+
`Renderer3DSystem` then `Graphics3DSystem`. For `map`, register `RESOURCE_TYPE.IMAGE` first. Pose can live on sibling `Transform3D` (preferred once a hierarchy exists); `Graphics3D.position*` still seeds / updates it.
|
|
39
51
|
|
|
40
52
|
## Common pitfalls
|
|
41
53
|
|
|
42
54
|
| Symptom | Fix |
|
|
43
55
|
|---------|-----|
|
|
44
|
-
| Plane invisible from one side |
|
|
45
|
-
| Sphere very dark |
|
|
56
|
+
| Plane invisible from one side | Set `doubleSide: true`, or rotate so the camera sees the front |
|
|
57
|
+
| Sphere very dark | Raise lights / `Renderer3DSystem` hemisphere, or use `material: 'basic'` |
|
|
46
58
|
| Wireframe shimmer | `wireframe: true` — that's by design |
|
|
47
|
-
| Sync drift with `Physics3D` |
|
|
59
|
+
| Sync drift with `Physics3D` | Same `GameObject`; `Physics3D.update()` writes positions back |
|
|
60
|
+
| `map` throws `Unknown resource` | Use the engine resource name, not a URL |
|
|
61
|
+
| Compound house as 3 GameObjects | Prefer one `Graphics3D` with `parts`, or `parent.addChild(child)` so the child mesh hangs off the parent |
|
|
62
|
+
| Child does not follow parent | `car.addChild(wheel)` — child `position*` are local. Do not also write world-space pose onto the wheel each frame unless it has its own `Physics3D` |
|
|
48
63
|
|
|
49
64
|
## Minimal example
|
|
50
65
|
|
|
@@ -54,10 +69,27 @@ box.addComponent(new Graphics3D({
|
|
|
54
69
|
shape: 'box',
|
|
55
70
|
width: 1, height: 1, depth: 1,
|
|
56
71
|
color: 0xff0000,
|
|
72
|
+
roughness: 0.8,
|
|
57
73
|
positionX: 0, positionY: 1, positionZ: 0,
|
|
58
74
|
}));
|
|
59
75
|
```
|
|
60
76
|
|
|
77
|
+
```ts
|
|
78
|
+
const house = new GameObject('house');
|
|
79
|
+
house.addComponent(new Graphics3D({
|
|
80
|
+
parts: [
|
|
81
|
+
{ shape: 'box', width: 2, height: 1.2, depth: 2, color: 0xc4a574 },
|
|
82
|
+
{ shape: 'cone', radius: 1.4, height: 1, color: 0x8b2942, positionY: 1.1 },
|
|
83
|
+
],
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
const car = new GameObject('car');
|
|
87
|
+
car.addComponent(new Graphics3D({ shape: 'box', width: 2, height: 0.6, depth: 1, color: 0x3366ff }));
|
|
88
|
+
const wheel = new GameObject('wheel');
|
|
89
|
+
wheel.addComponent(new Graphics3D({ shape: 'cylinder', radius: 0.3, height: 0.2, color: 0x222222, rotationZ: Math.PI / 2, positionX: 0.7, positionY: -0.2 }));
|
|
90
|
+
car.addChild(wheel);
|
|
91
|
+
```
|
|
92
|
+
|
|
61
93
|
## Per-frame pose + chase camera
|
|
62
94
|
|
|
63
95
|
`rotationX/Y/Z` and `positionX/Y/Z` are writable every tick. Use `Component.update` (`deltaTime` is milliseconds). Camera: `this.game.getSystem(Renderer3DSystem).threeContext.camera`. Do not hide `#canvas` or draw a second Canvas 2D game.
|
|
@@ -67,7 +99,7 @@ box.addComponent(new Graphics3D({
|
|
|
67
99
|
| Static placemarker cube → “no rotation / don’t know how to change pose each frame” | Assign `graphics.rotationY` / `positionX` / `positionZ` in `update` |
|
|
68
100
|
| Hide WebGL `#canvas` and cover the viewport with Canvas 2D / DOM fake perspective | Keep `#canvas` visible and interactive; keep drawing with `Graphics3D` / `Model3D` |
|
|
69
101
|
| `setInterval` / extra `requestAnimationFrame` to move the mesh | `Component.update` so pause/resume follows `Game.ticker` |
|
|
70
|
-
| 2D `TransformParams` on a 3D GameObject | Pose lives on `
|
|
102
|
+
| 2D `TransformParams` on a 3D GameObject | Pose lives on `Transform3D` (or `Graphics3D` / `Model3D` / `Img3D` fields, which seed `Transform3D`) |
|
|
71
103
|
|
|
72
104
|
```ts
|
|
73
105
|
class ChaseCraft extends Component {
|
package/combos-plugin.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"category": "rendering",
|
|
5
5
|
"dimension": "3d",
|
|
6
6
|
"isCore": false,
|
|
7
|
-
"keywords": ["3d", "graphics", "primitives", "box", "sphere", "cylinder", "plane"],
|
|
7
|
+
"keywords": ["3d", "graphics", "primitives", "box", "sphere", "cylinder", "plane", "cone", "torus", "capsule"],
|
|
8
8
|
"agentSkill": "./agent-skill.md",
|
|
9
9
|
"requires": ["@combos-fun/engine", "@combos-fun/plugin-renderer-3d"],
|
|
10
10
|
"exports": ["Graphics3D", "Graphics3DSystem"]
|