@combos-fun/engine 0.0.38 → 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/dist/engine.cjs.js +231 -3
- package/dist/engine.cjs.js.map +1 -1
- package/dist/engine.cjs.prod.js +1 -1
- package/dist/engine.d.ts +78 -4
- package/dist/engine.esm.js +230 -4
- package/dist/engine.esm.js.map +1 -1
- package/package.json +7 -3
- package/references/bootstrap-examples.md +59 -32
- package/references/public-api.md +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combos-fun/engine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"description": "ECS microkernel",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/engine.esm.js",
|
|
@@ -41,13 +41,17 @@
|
|
|
41
41
|
],
|
|
42
42
|
"author": "sun668 <q947692259@gmail.com>",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@combos-fun/inspector-decorator": "0.0.
|
|
44
|
+
"@combos-fun/inspector-decorator": "0.0.39",
|
|
45
45
|
"eventemitter3": "^5.0.4",
|
|
46
46
|
"lodash-es": "^4.17.21",
|
|
47
47
|
"resource-loader": "^4.0.0-rc4",
|
|
48
48
|
"sprite-timeline": "^1.10.2"
|
|
49
49
|
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"tsx": "^4.20.3"
|
|
52
|
+
},
|
|
50
53
|
"scripts": {
|
|
51
|
-
"build": "node ../../scripts/build-package.mjs"
|
|
54
|
+
"build": "node ../../scripts/build-package.mjs",
|
|
55
|
+
"test": "node --import tsx --test test/normalizeResourceSrc.test.ts test/normalizeSpritesheetData.test.ts"
|
|
52
56
|
}
|
|
53
57
|
}
|
|
@@ -55,49 +55,76 @@ resource.loadConfig([
|
|
|
55
55
|
]);
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
`ResourceBase` requires both `type: RESOURCE_TYPE` and a nested `src` object keyed by media slot (`image` / `json` / `audio` / `video` / `tex` / `ske` / …) where each slot is `{ type, url }`. A flat `src: 'logo.png'` is invalid.
|
|
59
|
-
|
|
60
58
|
## Minimal 3D bootstrap
|
|
61
59
|
|
|
62
60
|
```ts
|
|
63
|
-
import {
|
|
61
|
+
import {
|
|
62
|
+
Game,
|
|
63
|
+
GameObject,
|
|
64
|
+
resource,
|
|
65
|
+
RESOURCE_TYPE,
|
|
66
|
+
LOAD_EVENT,
|
|
67
|
+
} from "@combos-fun/engine";
|
|
64
68
|
import { Renderer3DSystem } from "@combos-fun/plugin-renderer-3d";
|
|
65
69
|
import {
|
|
66
70
|
Graphics3D,
|
|
67
71
|
Graphics3DSystem,
|
|
68
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";
|
|
69
75
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
new Graphics3DSystem(),
|
|
78
|
-
],
|
|
79
|
-
// Safe place to wire the scene graph: every system has finished init.
|
|
80
|
-
onSystemsBootstrapComplete: (g) => {
|
|
81
|
-
// 3D position / rotation / scale go through the component's own params
|
|
82
|
-
// (positionX/Y/Z, rotationX/Y/Z, scaleX/Y/Z) — GameObject's TransformParams
|
|
83
|
-
// is 2D-only (Vector2 + Size2) and is not read by 3D renderers.
|
|
84
|
-
const box = new GameObject("box");
|
|
85
|
-
box.addComponent(
|
|
86
|
-
new Graphics3D({
|
|
87
|
-
shape: "box",
|
|
88
|
-
width: 1,
|
|
89
|
-
height: 1,
|
|
90
|
-
depth: 1,
|
|
91
|
-
color: 0xff0000,
|
|
92
|
-
positionX: 0,
|
|
93
|
-
positionY: 1,
|
|
94
|
-
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,
|
|
95
83
|
}),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
+
});
|
|
100
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
|
+
]);
|
|
101
128
|
```
|
|
102
129
|
|
|
103
130
|
## Verification
|
package/references/public-api.md
CHANGED
|
@@ -6,11 +6,11 @@ Open only when the short `agent-skill` card is insufficient for a named symbol o
|
|
|
6
6
|
|
|
7
7
|
### Values
|
|
8
8
|
|
|
9
|
-
`Game`, `Scene`, `GameObject`, `Component`, `System`, `Transform`, `resource`, `resourceLoader`, `decorators`, `IDEProp`, `componentObserver`, `LOAD_EVENT`, `RESOURCE_TYPE`, `OBSERVER_TYPE`, `LOAD_SCENE_MODE`, `RESOURCE_TYPE_STRATEGY`, `version`, `COMBOS_GAME_PLUGIN_INIT_SUCCESS`, `COMBOS_GAME_READY`, `COMBOS_GAME_SET_PLAYING`, `COMBOS_GAME_STATE_CHANGED`, `postParentPluginInitSuccess`, `postParentGameReady`, `postParentGameState`, `parseSetPlayingMessage`, `DEFAULT_ALLOWED_MESSAGE_HOST_SUFFIXES`, `isAllowedMessageOrigin`, `mergeAllowedMessageOrigins`.
|
|
9
|
+
`Game`, `Scene`, `GameObject`, `Component`, `System`, `Transform`, `resource`, `resourceLoader`, `decorators`, `IDEProp`, `componentObserver`, `LOAD_EVENT`, `RESOURCE_TYPE`, `OBSERVER_TYPE`, `LOAD_SCENE_MODE`, `RESOURCE_TYPE_STRATEGY`, `normalizeResourceSrc`, `normalizeSpritesheetData`, `version`, `COMBOS_GAME_PLUGIN_INIT_SUCCESS`, `COMBOS_GAME_READY`, `COMBOS_GAME_SET_PLAYING`, `COMBOS_GAME_STATE_CHANGED`, `postParentPluginInitSuccess`, `postParentGameReady`, `postParentGameState`, `parseSetPlayingMessage`, `DEFAULT_ALLOWED_MESSAGE_HOST_SUFFIXES`, `isAllowedMessageOrigin`, `mergeAllowedMessageOrigins`.
|
|
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
|
|