@combos-fun/engine 0.0.39 → 0.0.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combos-fun/engine",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "description": "ECS microkernel",
5
5
  "main": "index.js",
6
6
  "module": "dist/engine.esm.js",
@@ -58,44 +58,73 @@ resource.loadConfig([
58
58
  ## Minimal 3D bootstrap
59
59
 
60
60
  ```ts
61
- import { Game, GameObject } from "@combos-fun/engine";
61
+ import {
62
+ Game,
63
+ GameObject,
64
+ resource,
65
+ RESOURCE_TYPE,
66
+ LOAD_EVENT,
67
+ } from "@combos-fun/engine";
62
68
  import { Renderer3DSystem } from "@combos-fun/plugin-renderer-3d";
63
69
  import {
64
70
  Graphics3D,
65
71
  Graphics3DSystem,
66
72
  } from "@combos-fun/plugin-renderer-3d-graphics";
73
+ import { Model3D, Model3DSystem } from "@combos-fun/plugin-renderer-3d-model";
74
+ import { Event3D, Event3DSystem } from "@combos-fun/plugin-renderer-3d-event";
67
75
 
68
- new Game({
69
- systems: [
70
- new Renderer3DSystem({
71
- canvas: document.querySelector("#canvas")!,
72
- width: 750,
73
- height: 1000,
74
- }),
75
- new Graphics3DSystem(),
76
- ],
77
- // Safe place to wire the scene graph: every system has finished init.
78
- onSystemsBootstrapComplete: (g) => {
79
- // 3D position / rotation / scale go through the component's own params
80
- // (positionX/Y/Z, rotationX/Y/Z, scaleX/Y/Z) — GameObject's TransformParams
81
- // is 2D-only (Vector2 + Size2) and is not read by 3D renderers.
82
- const box = new GameObject("box");
83
- box.addComponent(
84
- new Graphics3D({
85
- shape: "box",
86
- width: 1,
87
- height: 1,
88
- depth: 1,
89
- color: 0xff0000,
90
- positionX: 0,
91
- positionY: 1,
92
- positionZ: 0,
76
+ resource.once(LOAD_EVENT.COMPLETE, () => {
77
+ new Game({
78
+ systems: [
79
+ new Renderer3DSystem({
80
+ canvas: document.querySelector("#canvas")!,
81
+ width: 750,
82
+ height: 1334,
93
83
  }),
94
- );
95
- // Use addChild — not addGameObject — so transform parent + scene are both wired.
96
- g.scene.addChild(box);
97
- },
84
+ new Graphics3DSystem(),
85
+ new Model3DSystem(),
86
+ new Event3DSystem(),
87
+ ],
88
+ // Safe place to wire the scene graph: every system has finished init.
89
+ onSystemsBootstrapComplete: (g) => {
90
+ // 3D position / rotation / scale go through the component's own params
91
+ // (positionX/Y/Z, rotationX/Y/Z, scaleX/Y/Z) — GameObject's TransformParams
92
+ // is 2D-only (Vector2 + Size2) and is not read by 3D renderers.
93
+ const box = new GameObject("box");
94
+ box.addComponent(
95
+ new Graphics3D({
96
+ shape: "box",
97
+ width: 1,
98
+ height: 1,
99
+ depth: 1,
100
+ color: 0xff0000,
101
+ positionX: 0,
102
+ positionY: 1,
103
+ positionZ: 0,
104
+ }),
105
+ );
106
+ box.addComponent(new Event3D());
107
+ box.getComponent(Event3D)!.on("tap", () => {
108
+ /* handle */
109
+ });
110
+ // Use addChild — not addGameObject — so transform parent + scene are both wired.
111
+ g.scene.addChild(box);
112
+
113
+ const hero = new GameObject("hero");
114
+ hero.addComponent(new Model3D({ resource: "hero", positionY: 0 }));
115
+ g.scene.addChild(hero);
116
+ },
117
+ });
98
118
  });
119
+
120
+ resource.loadConfig([
121
+ {
122
+ name: "hero",
123
+ type: RESOURCE_TYPE.MODEL,
124
+ src: { model: { type: "glb", url: "https://cdn.example/hero.glb" } },
125
+ preload: true,
126
+ },
127
+ ]);
99
128
  ```
100
129
 
101
130
  ## Verification
@@ -10,7 +10,7 @@ Open only when the short `agent-skill` card is insufficient for a named symbol o
10
10
 
11
11
  ### Types
12
12
 
13
- `GameParams`, `PluginStruct`, `TransformParams`, `ComponentChanged`, `UpdateParams`, `ComponentParams`, `ObserverInfo`, `PureObserverInfo`, `ResourceBase`, `SystemConstructor`, `CombosGamePluginInitSuccessMessage`, `CombosGameReadyMessage`, `CombosGameStateChangedMessage`, `CombosGameSetPlayingMessage`.
13
+ `GameParams`, `PluginStruct`, `TransformParams`, `ComponentChanged`, `UpdateParams`, `ComponentParams`, `ObserverInfo`, `PureObserverInfo`, `ResourceBase`, `ResourceStruct`, `SystemConstructor`, `CombosGamePluginInitSuccessMessage`, `CombosGameReadyMessage`, `CombosGameStateChangedMessage`, `CombosGameSetPlayingMessage`.
14
14
 
15
15
  ### `GameParams`
16
16