@combos-fun/engine 0.0.39 → 0.0.41
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/dist/engine.cjs.js +28 -1
- package/dist/engine.cjs.js.map +1 -1
- package/dist/engine.cjs.prod.js +1 -1
- package/dist/engine.d.ts +4 -3
- package/dist/engine.esm.js +28 -1
- package/dist/engine.esm.js.map +1 -1
- package/package.json +3 -3
- package/references/bootstrap-examples.md +59 -30
- package/references/public-api.md +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combos-fun/engine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
4
4
|
"description": "ECS microkernel",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/engine.esm.js",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
],
|
|
42
42
|
"author": "sun668 <q947692259@gmail.com>",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@combos-fun/inspector-decorator": "0.0.39",
|
|
45
44
|
"eventemitter3": "^5.0.4",
|
|
46
45
|
"lodash-es": "^4.17.21",
|
|
47
46
|
"resource-loader": "^4.0.0-rc4",
|
|
48
|
-
"sprite-timeline": "^1.10.2"
|
|
47
|
+
"sprite-timeline": "^1.10.2",
|
|
48
|
+
"@combos-fun/inspector-decorator": "0.0.41"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"tsx": "^4.20.3"
|
|
@@ -58,44 +58,73 @@ resource.loadConfig([
|
|
|
58
58
|
## Minimal 3D bootstrap
|
|
59
59
|
|
|
60
60
|
```ts
|
|
61
|
-
import {
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
96
|
-
|
|
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
|
package/references/public-api.md
CHANGED
|
@@ -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
|
|