@combos-fun/plugin-renderer-3d-graphics 0.0.40 → 0.0.42

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.
Files changed (2) hide show
  1. package/agent-skill.md +35 -0
  2. package/package.json +5 -5
package/agent-skill.md CHANGED
@@ -6,6 +6,8 @@ Procedural 3D primitive shapes for the 3D pipeline. Produces a `THREE.Mesh` with
6
6
 
7
7
  Read for any procedural primitive: box, sphere, cylinder, plane, cone, torus, debug placeholders, simple terrain.
8
8
 
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
+
9
11
  ## Public API
10
12
 
11
13
  ```ts
@@ -56,6 +58,39 @@ box.addComponent(new Graphics3D({
56
58
  }));
57
59
  ```
58
60
 
61
+ ## Per-frame pose + chase camera
62
+
63
+ `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.
64
+
65
+ | Wrong | Correct |
66
+ |-------|---------|
67
+ | Static placemarker cube → “no rotation / don’t know how to change pose each frame” | Assign `graphics.rotationY` / `positionX` / `positionZ` in `update` |
68
+ | Hide WebGL `#canvas` and cover the viewport with Canvas 2D / DOM fake perspective | Keep `#canvas` visible and interactive; keep drawing with `Graphics3D` / `Model3D` |
69
+ | `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 `Graphics3D` (or `Model3D` / `Img3D`) fields |
71
+
72
+ ```ts
73
+ class ChaseCraft extends Component {
74
+ static componentName = 'ChaseCraft';
75
+ heading = 0;
76
+ update(frame: UpdateParams) {
77
+ const mesh = this.gameObject.getComponent(Graphics3D);
78
+ const camera = this.game.getSystem(Renderer3DSystem).threeContext.camera;
79
+ const dt = frame.deltaTime / 1000;
80
+ this.heading += dt * 0.4;
81
+ mesh.rotationY = this.heading;
82
+ mesh.positionX += Math.sin(this.heading) * 6 * dt;
83
+ mesh.positionZ += Math.cos(this.heading) * 6 * dt;
84
+ camera.position.set(
85
+ mesh.positionX - Math.sin(this.heading) * 8,
86
+ mesh.positionY + 3,
87
+ mesh.positionZ - Math.cos(this.heading) * 8,
88
+ );
89
+ camera.lookAt(mesh.positionX, mesh.positionY, mesh.positionZ);
90
+ }
91
+ }
92
+ ```
93
+
59
94
  ## Verification
60
95
 
61
96
  `pnpm --filter @combos-fun/plugin-renderer-3d-graphics run build`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combos-fun/plugin-renderer-3d-graphics",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "description": "Procedural 3D primitive shapes",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-3d-graphics.esm.js",
@@ -26,10 +26,10 @@
26
26
  "pluginManifest": "./combos-plugin.json"
27
27
  },
28
28
  "dependencies": {
29
- "@combos-fun/engine": "0.0.39",
30
- "@combos-fun/inspector-decorator": "0.0.39",
31
- "@combos-fun/plugin-renderer-3d": "0.0.39",
32
- "three": "^0.172.0"
29
+ "three": "^0.172.0",
30
+ "@combos-fun/engine": "0.0.42",
31
+ "@combos-fun/inspector-decorator": "0.0.42",
32
+ "@combos-fun/plugin-renderer-3d": "0.0.42"
33
33
  },
34
34
  "keywords": [
35
35
  "combos-fun",