@jolly-pixel/engine 1.0.0 → 1.1.0
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 +221 -209
- package/dist/actor/ActorComponent.d.ts +1 -0
- package/dist/actor/ActorComponent.d.ts.map +1 -1
- package/dist/actor/ActorComponent.js +14 -0
- package/dist/actor/ActorComponent.js.map +1 -1
- package/dist/actor/Signal.d.ts +2 -0
- package/dist/actor/Signal.d.ts.map +1 -1
- package/dist/actor/Signal.js +13 -5
- package/dist/actor/Signal.js.map +1 -1
- package/dist/components/script/Behavior.js +0 -1
- package/dist/components/script/Behavior.js.map +1 -1
- package/dist/components/script/BehaviorDecorators.d.ts +0 -1
- package/dist/components/script/BehaviorDecorators.d.ts.map +1 -1
- package/dist/components/script/BehaviorDecorators.js +1 -2
- package/dist/components/script/BehaviorDecorators.js.map +1 -1
- package/dist/components/script/BehaviorInitializer.d.ts.map +1 -1
- package/dist/components/script/BehaviorInitializer.js +0 -8
- package/dist/components/script/BehaviorInitializer.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/systems/GameInstance.js.map +1 -1
- package/dist/systems/rendering/GameRenderer.d.ts +18 -1
- package/dist/systems/rendering/GameRenderer.d.ts.map +1 -1
- package/dist/systems/rendering/ThreeRenderer.d.ts +2 -14
- package/dist/systems/rendering/ThreeRenderer.d.ts.map +1 -1
- package/dist/systems/rendering/ThreeRenderer.js.map +1 -1
- package/dist/ui/UINode.d.ts +46 -0
- package/dist/ui/UINode.d.ts.map +1 -0
- package/dist/ui/UINode.js +86 -0
- package/dist/ui/UINode.js.map +1 -0
- package/dist/ui/UIRenderer.d.ts +19 -0
- package/dist/ui/UIRenderer.d.ts.map +1 -0
- package/dist/ui/UIRenderer.js +78 -0
- package/dist/ui/UIRenderer.js.map +1 -0
- package/dist/ui/UISprite.d.ts +32 -0
- package/dist/ui/UISprite.d.ts.map +1 -0
- package/dist/ui/UISprite.js +109 -0
- package/dist/ui/UISprite.js.map +1 -0
- package/dist/ui/UIText.d.ts +37 -0
- package/dist/ui/UIText.d.ts.map +1 -0
- package/dist/ui/UIText.js +53 -0
- package/dist/ui/UIText.js.map +1 -0
- package/dist/ui/index.d.ts +5 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +5 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/utils/types.d.ts +4 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,209 +1,221 @@
|
|
|
1
|
-
<p align="center"><h1 align="center">
|
|
2
|
-
engine
|
|
3
|
-
</h1>
|
|
4
|
-
|
|
5
|
-
<p align="center">
|
|
6
|
-
JollyPixel Three.js engine
|
|
7
|
-
</p>
|
|
8
|
-
|
|
9
|
-
## 📌 About
|
|
10
|
-
|
|
11
|
-
Minimal and opinionated [ECS](https://en.wikipedia.org/wiki/Entity_component_system) built on top of Three.js.
|
|
12
|
-
|
|
13
|
-
> [!NOTE]
|
|
14
|
-
> JollyPixel is heavily inspired by [Superpowers](https://github.com/superpowers) for the naming (such as Actor instead of Entity).
|
|
15
|
-
|
|
16
|
-
## 💡 Features
|
|
17
|
-
|
|
18
|
-
- Actor/Component architecture with scene tree
|
|
19
|
-
- Godot-like [Signals](https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html) for Actors and Components
|
|
20
|
-
- Behavior scripts
|
|
21
|
-
- Input controls (mouse, keyboard, gamepads, touchpad)
|
|
22
|
-
- Built-in renderers (3D models, 3D text, sprites, …)
|
|
23
|
-
- Asset management
|
|
24
|
-
- Audio (background music, sound library, spatial audio)
|
|
25
|
-
|
|
26
|
-
## 💃 Getting Started
|
|
27
|
-
|
|
28
|
-
This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
$ npm i @jolly-pixel/engine
|
|
32
|
-
# or
|
|
33
|
-
$ yarn add @jolly-pixel/engine
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## 📚 API
|
|
37
|
-
|
|
38
|
-
### ⚙️ Systems
|
|
39
|
-
|
|
40
|
-
Systems are responsible for driving the game loop, orchestrating rendering, and managing shared
|
|
41
|
-
resources such as assets. They operate on actors and their components
|
|
42
|
-
each frame.
|
|
43
|
-
|
|
44
|
-
- [GameInstance](./docs/systems/game-instance.md) — top-level orchestrator that ties the renderer, scene,
|
|
45
|
-
input, and audio into a unified game loop.
|
|
46
|
-
- [GameRenderer](./docs/systems/game-renderer.md) — abstracts the Three.js render pipeline and supports
|
|
47
|
-
direct and post-processing render strategies.
|
|
48
|
-
- [Scene](./docs/systems/scene.md) — the ECS world manager that owns the actor tree and drives
|
|
49
|
-
per-frame lifecycle (awake → start → update → destroy).
|
|
50
|
-
- [Asset](./docs/asset.md) — lazy-loading asset pipeline with a
|
|
51
|
-
registry of loaders, a queue, and a cache.
|
|
52
|
-
|
|
53
|
-
```ts
|
|
54
|
-
import { Systems, Actor } from "@jolly-pixel/engine";
|
|
55
|
-
|
|
56
|
-
const scene = new Systems.SceneEngine();
|
|
57
|
-
const renderer = new Systems.ThreeRenderer(canvas, {
|
|
58
|
-
scene,
|
|
59
|
-
renderMode: "direct"
|
|
60
|
-
});
|
|
61
|
-
const game = new Systems.GameInstance(renderer, {
|
|
62
|
-
enableOnExit: true,
|
|
63
|
-
scene
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
game.connect();
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
> [!TIP]
|
|
70
|
-
> [@jolly-pixel/runtime](../runtime/README.md) manage most of that for you
|
|
71
|
-
|
|
72
|
-
### 🎭 Actor
|
|
73
|
-
|
|
74
|
-
An Actor is a named node in the scene tree that holds a Transform, a list of Components, and a
|
|
75
|
-
dictionary of Behaviors. The engine uses the name *Actor* (inspired by
|
|
76
|
-
[Superpowers](https://github.com/superpowers)) instead of the
|
|
77
|
-
traditional *Entity* term.
|
|
78
|
-
|
|
79
|
-
- [ActorTree](./docs/actor/actor-tree.md) — tree structure that
|
|
80
|
-
manages parent-child actor relationships and provides pattern-based
|
|
81
|
-
lookups.
|
|
82
|
-
- [Actor](./docs/actor/actor.md) — the entity itself, holding its
|
|
83
|
-
transform, components, and behaviors.
|
|
84
|
-
- [Transform](./docs/actor/actor-transform.md) — built-in component
|
|
85
|
-
wrapping a Three.js Object3D and exposing a complete local/global
|
|
86
|
-
transform API (position, orientation, scale, movement).
|
|
87
|
-
|
|
88
|
-
```ts
|
|
89
|
-
const player = new Actor(gameInstance, { name: "player" });
|
|
90
|
-
player.transform.setLocalPosition(0, 1, 0);
|
|
91
|
-
|
|
92
|
-
const child = new Actor(gameInstance, {
|
|
93
|
-
name: "weapon",
|
|
94
|
-
parent: player
|
|
95
|
-
});
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### 🧩 Components
|
|
99
|
-
|
|
100
|
-
Components are pure data and logic units attached to an Actor. They come in three flavours:
|
|
101
|
-
|
|
102
|
-
- [ActorComponent](./docs/actor/actor-component.md) — the base class all components extend (behaviors and renderers are ActorComponent).
|
|
103
|
-
- [Renderers](./docs/components/renderers.md) — visual components (sprites, models, text, tiled maps) that know how to draw themselves.
|
|
104
|
-
- [Camera Controls](./docs/components/camera-3d-controls.md)
|
|
105
|
-
- [Behavior](./docs/components/behavior.md) — script components with a property system and decorator-driven initialization.
|
|
106
|
-
- [Signals](./docs/components/signal.md) — lightweight pub/sub event emitter for actor-level communication (Godot-inspired signals).
|
|
107
|
-
|
|
108
|
-
```ts
|
|
109
|
-
import {
|
|
110
|
-
Behavior, ModelRenderer, Input,
|
|
111
|
-
Signal, SceneProperty, type SignalEvent
|
|
112
|
-
} from "@jolly-pixel/engine";
|
|
113
|
-
|
|
114
|
-
class PlayerBehavior extends Behavior {
|
|
115
|
-
@Signal()
|
|
116
|
-
onHit: SignalEvent;
|
|
117
|
-
|
|
118
|
-
@SceneProperty({ type: "number" })
|
|
119
|
-
speed = 0.05;
|
|
120
|
-
|
|
121
|
-
@Input.listen("keyboard.down")
|
|
122
|
-
onKeyDown() {
|
|
123
|
-
console.log("key pressed");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
update() {
|
|
127
|
-
if (this.actor.gameInstance.input.isKeyDown("ArrowUp")) {
|
|
128
|
-
this.actor.transform.moveForward(this.speed);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
new Actor(gameInstance, { name: "player" })
|
|
134
|
-
.registerComponent(ModelRenderer, { path: "models/Player.glb" })
|
|
135
|
-
.registerComponent(PlayerBehavior);
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### 🎮 Device Controls
|
|
139
|
-
|
|
140
|
-
Aggregates all physical devices (mouse, keyboard, gamepads, touchpad, screen) behind a unified
|
|
141
|
-
query API so that behaviors can react to player actions without
|
|
142
|
-
coupling to a specific device.
|
|
143
|
-
|
|
144
|
-
- [Input](./docs/controls/input.md) — central input manager
|
|
145
|
-
- [Mouse](./docs/controls/mouse.md)
|
|
146
|
-
- [Keyboard](./docs/controls/keyboard.md)
|
|
147
|
-
- [Gamepad](./docs/controls/gamepad.md)
|
|
148
|
-
- [Touchpad](./docs/controls/touchpad.md)
|
|
149
|
-
- [Screen](./docs/controls/screen.md)
|
|
150
|
-
- [CombinedInput](./docs/controls/combinedinput.md) — composable input conditions (AND, OR, NOT, sequence)
|
|
151
|
-
for complex key bindings.
|
|
152
|
-
|
|
153
|
-
```ts
|
|
154
|
-
import { InputCombination } from "@jolly-pixel/engine";
|
|
155
|
-
|
|
156
|
-
const { input } = gameInstance;
|
|
157
|
-
|
|
158
|
-
if (input.isKeyDown("Space")) {
|
|
159
|
-
console.log("jump!");
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const dashCombo = InputCombination.all(
|
|
163
|
-
InputCombination.key("ShiftLeft"),
|
|
164
|
-
InputCombination.key("ArrowRight")
|
|
165
|
-
);
|
|
166
|
-
if (dashCombo.evaluate(input)) {
|
|
167
|
-
console.log("dash!");
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### 🔊 Audio
|
|
172
|
-
|
|
173
|
-
Manages sound playback across the engine. It provides a global volume controller, a factory for creating audio sources, and a playlist-based background music manager.
|
|
174
|
-
|
|
175
|
-
- [Audio](./docs/audio/audio.md) — global audio controller owning the
|
|
176
|
-
AudioContext and master volume.
|
|
177
|
-
- [AudioBackground](./docs/audio/audio-background.md) —
|
|
178
|
-
playlist-based background music with sequential track playback,
|
|
179
|
-
pause/resume/stop, and playlist chaining.
|
|
180
|
-
|
|
181
|
-
```ts
|
|
182
|
-
import { GlobalAudioManager, AudioBackground } from "@jolly-pixel/engine";
|
|
183
|
-
|
|
184
|
-
const audioManager = GlobalAudioManager.fromGameInstance(gameInstance);
|
|
185
|
-
const bg = new AudioBackground({
|
|
186
|
-
audioManager,
|
|
187
|
-
autoPlay: true,
|
|
188
|
-
playlists: [{
|
|
189
|
-
name: "main",
|
|
190
|
-
onEnd: "loop",
|
|
191
|
-
tracks: [
|
|
192
|
-
{ name: "theme", path: "audio/theme.mp3" }
|
|
193
|
-
]
|
|
194
|
-
}]
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
gameInstance.audio.observe(bg);
|
|
198
|
-
gameInstance.audio.volume = 0.5;
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
###
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
1
|
+
<p align="center"><h1 align="center">
|
|
2
|
+
engine
|
|
3
|
+
</h1>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
JollyPixel Three.js engine
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
## 📌 About
|
|
10
|
+
|
|
11
|
+
Minimal and opinionated [ECS](https://en.wikipedia.org/wiki/Entity_component_system) built on top of Three.js.
|
|
12
|
+
|
|
13
|
+
> [!NOTE]
|
|
14
|
+
> JollyPixel is heavily inspired by [Superpowers](https://github.com/superpowers) for the naming (such as Actor instead of Entity).
|
|
15
|
+
|
|
16
|
+
## 💡 Features
|
|
17
|
+
|
|
18
|
+
- Actor/Component architecture with scene tree
|
|
19
|
+
- Godot-like [Signals](https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html) for Actors and Components
|
|
20
|
+
- Behavior scripts
|
|
21
|
+
- Input controls (mouse, keyboard, gamepads, touchpad)
|
|
22
|
+
- Built-in renderers (3D models, 3D text, sprites, …)
|
|
23
|
+
- Asset management
|
|
24
|
+
- Audio (background music, sound library, spatial audio)
|
|
25
|
+
|
|
26
|
+
## 💃 Getting Started
|
|
27
|
+
|
|
28
|
+
This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
$ npm i @jolly-pixel/engine
|
|
32
|
+
# or
|
|
33
|
+
$ yarn add @jolly-pixel/engine
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 📚 API
|
|
37
|
+
|
|
38
|
+
### ⚙️ Systems
|
|
39
|
+
|
|
40
|
+
Systems are responsible for driving the game loop, orchestrating rendering, and managing shared
|
|
41
|
+
resources such as assets. They operate on actors and their components
|
|
42
|
+
each frame.
|
|
43
|
+
|
|
44
|
+
- [GameInstance](./docs/systems/game-instance.md) — top-level orchestrator that ties the renderer, scene,
|
|
45
|
+
input, and audio into a unified game loop.
|
|
46
|
+
- [GameRenderer](./docs/systems/game-renderer.md) — abstracts the Three.js render pipeline and supports
|
|
47
|
+
direct and post-processing render strategies.
|
|
48
|
+
- [Scene](./docs/systems/scene.md) — the ECS world manager that owns the actor tree and drives
|
|
49
|
+
per-frame lifecycle (awake → start → update → destroy).
|
|
50
|
+
- [Asset](./docs/asset.md) — lazy-loading asset pipeline with a
|
|
51
|
+
registry of loaders, a queue, and a cache.
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { Systems, Actor } from "@jolly-pixel/engine";
|
|
55
|
+
|
|
56
|
+
const scene = new Systems.SceneEngine();
|
|
57
|
+
const renderer = new Systems.ThreeRenderer(canvas, {
|
|
58
|
+
scene,
|
|
59
|
+
renderMode: "direct"
|
|
60
|
+
});
|
|
61
|
+
const game = new Systems.GameInstance(renderer, {
|
|
62
|
+
enableOnExit: true,
|
|
63
|
+
scene
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
game.connect();
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> [!TIP]
|
|
70
|
+
> [@jolly-pixel/runtime](../runtime/README.md) manage most of that for you
|
|
71
|
+
|
|
72
|
+
### 🎭 Actor
|
|
73
|
+
|
|
74
|
+
An Actor is a named node in the scene tree that holds a Transform, a list of Components, and a
|
|
75
|
+
dictionary of Behaviors. The engine uses the name *Actor* (inspired by
|
|
76
|
+
[Superpowers](https://github.com/superpowers)) instead of the
|
|
77
|
+
traditional *Entity* term.
|
|
78
|
+
|
|
79
|
+
- [ActorTree](./docs/actor/actor-tree.md) — tree structure that
|
|
80
|
+
manages parent-child actor relationships and provides pattern-based
|
|
81
|
+
lookups.
|
|
82
|
+
- [Actor](./docs/actor/actor.md) — the entity itself, holding its
|
|
83
|
+
transform, components, and behaviors.
|
|
84
|
+
- [Transform](./docs/actor/actor-transform.md) — built-in component
|
|
85
|
+
wrapping a Three.js Object3D and exposing a complete local/global
|
|
86
|
+
transform API (position, orientation, scale, movement).
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
const player = new Actor(gameInstance, { name: "player" });
|
|
90
|
+
player.transform.setLocalPosition(0, 1, 0);
|
|
91
|
+
|
|
92
|
+
const child = new Actor(gameInstance, {
|
|
93
|
+
name: "weapon",
|
|
94
|
+
parent: player
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 🧩 Components
|
|
99
|
+
|
|
100
|
+
Components are pure data and logic units attached to an Actor. They come in three flavours:
|
|
101
|
+
|
|
102
|
+
- [ActorComponent](./docs/actor/actor-component.md) — the base class all components extend (behaviors and renderers are ActorComponent).
|
|
103
|
+
- [Renderers](./docs/components/renderers.md) — visual components (sprites, models, text, tiled maps) that know how to draw themselves.
|
|
104
|
+
- [Camera Controls](./docs/components/camera-3d-controls.md)
|
|
105
|
+
- [Behavior](./docs/components/behavior.md) — script components with a property system and decorator-driven initialization.
|
|
106
|
+
- [Signals](./docs/components/signal.md) — lightweight pub/sub event emitter for actor-level communication (Godot-inspired signals).
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import {
|
|
110
|
+
Behavior, ModelRenderer, Input,
|
|
111
|
+
Signal, SceneProperty, type SignalEvent
|
|
112
|
+
} from "@jolly-pixel/engine";
|
|
113
|
+
|
|
114
|
+
class PlayerBehavior extends Behavior {
|
|
115
|
+
@Signal()
|
|
116
|
+
onHit: SignalEvent;
|
|
117
|
+
|
|
118
|
+
@SceneProperty({ type: "number" })
|
|
119
|
+
speed = 0.05;
|
|
120
|
+
|
|
121
|
+
@Input.listen("keyboard.down")
|
|
122
|
+
onKeyDown() {
|
|
123
|
+
console.log("key pressed");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
update() {
|
|
127
|
+
if (this.actor.gameInstance.input.isKeyDown("ArrowUp")) {
|
|
128
|
+
this.actor.transform.moveForward(this.speed);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
new Actor(gameInstance, { name: "player" })
|
|
134
|
+
.registerComponent(ModelRenderer, { path: "models/Player.glb" })
|
|
135
|
+
.registerComponent(PlayerBehavior);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 🎮 Device Controls
|
|
139
|
+
|
|
140
|
+
Aggregates all physical devices (mouse, keyboard, gamepads, touchpad, screen) behind a unified
|
|
141
|
+
query API so that behaviors can react to player actions without
|
|
142
|
+
coupling to a specific device.
|
|
143
|
+
|
|
144
|
+
- [Input](./docs/controls/input.md) — central input manager
|
|
145
|
+
- [Mouse](./docs/controls/mouse.md)
|
|
146
|
+
- [Keyboard](./docs/controls/keyboard.md)
|
|
147
|
+
- [Gamepad](./docs/controls/gamepad.md)
|
|
148
|
+
- [Touchpad](./docs/controls/touchpad.md)
|
|
149
|
+
- [Screen](./docs/controls/screen.md)
|
|
150
|
+
- [CombinedInput](./docs/controls/combinedinput.md) — composable input conditions (AND, OR, NOT, sequence)
|
|
151
|
+
for complex key bindings.
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { InputCombination } from "@jolly-pixel/engine";
|
|
155
|
+
|
|
156
|
+
const { input } = gameInstance;
|
|
157
|
+
|
|
158
|
+
if (input.isKeyDown("Space")) {
|
|
159
|
+
console.log("jump!");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const dashCombo = InputCombination.all(
|
|
163
|
+
InputCombination.key("ShiftLeft"),
|
|
164
|
+
InputCombination.key("ArrowRight")
|
|
165
|
+
);
|
|
166
|
+
if (dashCombo.evaluate(input)) {
|
|
167
|
+
console.log("dash!");
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 🔊 Audio
|
|
172
|
+
|
|
173
|
+
Manages sound playback across the engine. It provides a global volume controller, a factory for creating audio sources, and a playlist-based background music manager.
|
|
174
|
+
|
|
175
|
+
- [Audio](./docs/audio/audio.md) — global audio controller owning the
|
|
176
|
+
AudioContext and master volume.
|
|
177
|
+
- [AudioBackground](./docs/audio/audio-background.md) —
|
|
178
|
+
playlist-based background music with sequential track playback,
|
|
179
|
+
pause/resume/stop, and playlist chaining.
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
import { GlobalAudioManager, AudioBackground } from "@jolly-pixel/engine";
|
|
183
|
+
|
|
184
|
+
const audioManager = GlobalAudioManager.fromGameInstance(gameInstance);
|
|
185
|
+
const bg = new AudioBackground({
|
|
186
|
+
audioManager,
|
|
187
|
+
autoPlay: true,
|
|
188
|
+
playlists: [{
|
|
189
|
+
name: "main",
|
|
190
|
+
onEnd: "loop",
|
|
191
|
+
tracks: [
|
|
192
|
+
{ name: "theme", path: "audio/theme.mp3" }
|
|
193
|
+
]
|
|
194
|
+
}]
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
gameInstance.audio.observe(bg);
|
|
198
|
+
gameInstance.audio.volume = 0.5;
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### 🖼️ UI
|
|
202
|
+
|
|
203
|
+
An orthographic 2D overlay drawn on top of the 3D scene.
|
|
204
|
+
UI elements are anchored to screen edges and support pointer interaction through signals.
|
|
205
|
+
|
|
206
|
+
- [UIRenderer](./docs/ui/ui-renderer.md) — orthographic camera and
|
|
207
|
+
CSS2D overlay that drives the UI layer.
|
|
208
|
+
- [UINode](./docs/ui/ui-node.md) — base positioning component with
|
|
209
|
+
anchor, offset, and pivot.
|
|
210
|
+
- [UISprite](./docs/ui/ui-sprite.md) — interactive sprite with
|
|
211
|
+
style, hover states, text labels, and pointer signals.
|
|
212
|
+
|
|
213
|
+
### 📦 Internals
|
|
214
|
+
|
|
215
|
+
- [Adapters](./docs/internals/adapters.md)
|
|
216
|
+
- [Audio](./docs/internals/audio.md)
|
|
217
|
+
- [FixedTimeStep](./docs/internals/fixed-time-step.md)
|
|
218
|
+
|
|
219
|
+
## License
|
|
220
|
+
|
|
221
|
+
MIT
|
|
@@ -9,6 +9,7 @@ export type ActorComponentEvents = {
|
|
|
9
9
|
metadataInitialized: [];
|
|
10
10
|
};
|
|
11
11
|
export declare class ActorComponent extends EventEmitter<ActorComponentEvents> implements Component {
|
|
12
|
+
#private;
|
|
12
13
|
actor: Actor;
|
|
13
14
|
typeName: FreeComponentEnum;
|
|
14
15
|
pendingForDestruction: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorComponent.d.ts","sourceRoot":"","sources":["../../src/actor/ActorComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ActorComponent.d.ts","sourceRoot":"","sources":["../../src/actor/ActorComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,mBAAmB,EAAE,EAAE,CAAC;CACzB,CAAC;AAEF,qBAAa,cAAe,SAAQ,YAAY,CAAC,oBAAoB,CAAE,YAAW,SAAS;;IACzF,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,iBAAiB,CAAC;IAE5B,qBAAqB,UAAS;gBAG5B,OAAO,EAAE,qBAAqB;IA0BhC,WAAW;IAIX,OAAO;CAWR"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { EventEmitter } from "@posva/event-emitter";
|
|
3
3
|
// Import Internal Dependencies
|
|
4
4
|
import { Actor } from "./Actor.js";
|
|
5
|
+
import { getSignalMetadata, SignalEvent } from "./Signal.js";
|
|
5
6
|
export class ActorComponent extends EventEmitter {
|
|
6
7
|
actor;
|
|
7
8
|
typeName;
|
|
@@ -12,6 +13,19 @@ export class ActorComponent extends EventEmitter {
|
|
|
12
13
|
this.typeName = options.typeName;
|
|
13
14
|
this.actor.components.push(this);
|
|
14
15
|
this.actor.gameInstance.scene.componentsToBeStarted.push(this);
|
|
16
|
+
// Defer the initialization of signal decorators to ensure
|
|
17
|
+
// that the component instance is fully constructed
|
|
18
|
+
queueMicrotask(() => this.#initSignalDecorators());
|
|
19
|
+
}
|
|
20
|
+
#initSignalDecorators() {
|
|
21
|
+
const proto = Object.getPrototypeOf(this);
|
|
22
|
+
const metadata = getSignalMetadata(proto);
|
|
23
|
+
if (metadata) {
|
|
24
|
+
for (const propertyName of metadata.signals) {
|
|
25
|
+
this[propertyName] = new SignalEvent();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
this.emit("metadataInitialized");
|
|
15
29
|
}
|
|
16
30
|
isDestroyed() {
|
|
17
31
|
return this.pendingForDestruction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorComponent.js","sourceRoot":"","sources":["../../src/actor/ActorComponent.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,+BAA+B;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ActorComponent.js","sourceRoot":"","sources":["../../src/actor/ActorComponent.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,+BAA+B;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAe7D,MAAM,OAAO,cAAe,SAAQ,YAAkC;IACpE,KAAK,CAAQ;IACb,QAAQ,CAAoB;IAE5B,qBAAqB,GAAG,KAAK,CAAC;IAE9B,YACE,OAA8B;QAE9B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAEjC,IAA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AAC;QACzC,CAAC;IACH,CAAC;CACF"}
|
package/dist/actor/Signal.d.ts
CHANGED
|
@@ -11,4 +11,6 @@ export declare class SignalEvent<T extends unknown[] = []> {
|
|
|
11
11
|
clear(): void;
|
|
12
12
|
}
|
|
13
13
|
export declare function Signal(): PropertyDecorator;
|
|
14
|
+
export declare function getSignalMetadata(object: Object): ActorComponentSignalMetadata | undefined;
|
|
15
|
+
export declare function createSignalMetadata(): ActorComponentSignalMetadata;
|
|
14
16
|
//# sourceMappingURL=Signal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../src/actor/Signal.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../src/actor/Signal.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;AAK1B,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;AAEzE,MAAM,MAAM,4BAA4B,GAAG;IACzC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACtB,CAAC;AAEF,qBAAa,WAAW,CAAC,CAAC,SAAS,OAAO,EAAE,GAAG,EAAE;IAC/C,OAAO,CAAC,SAAS,CAA2B;IAE5C,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;IAMf,OAAO,CACL,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;IAK7B,UAAU,CACR,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;IAQ7B,KAAK;CAGN;AAED,wBAAgB,MAAM,IAAI,iBAAiB,CAoB1C;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,GACb,4BAA4B,GAAG,SAAS,CAE1C;AAED,wBAAgB,oBAAoB,IAAI,4BAA4B,CAInE"}
|
package/dist/actor/Signal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Import Third-party Dependencies
|
|
2
2
|
import "reflect-metadata";
|
|
3
|
-
//
|
|
4
|
-
|
|
3
|
+
// CONSTANTS
|
|
4
|
+
const kSignalMetadata = Symbol.for("SignalMetadata");
|
|
5
5
|
export class SignalEvent {
|
|
6
6
|
listeners = [];
|
|
7
7
|
emit(...args) {
|
|
@@ -24,15 +24,23 @@ export class SignalEvent {
|
|
|
24
24
|
}
|
|
25
25
|
export function Signal() {
|
|
26
26
|
return function fn(object, propertyName) {
|
|
27
|
-
const metadata =
|
|
27
|
+
const metadata = getSignalMetadata(object);
|
|
28
28
|
if (metadata) {
|
|
29
29
|
metadata.signals.add(propertyName.toString());
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
const metadata =
|
|
32
|
+
const metadata = createSignalMetadata();
|
|
33
33
|
metadata.signals.add(propertyName.toString());
|
|
34
|
-
Reflect.defineMetadata(
|
|
34
|
+
Reflect.defineMetadata(kSignalMetadata, metadata, object);
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
+
export function getSignalMetadata(object) {
|
|
39
|
+
return Reflect.getMetadata(kSignalMetadata, object);
|
|
40
|
+
}
|
|
41
|
+
export function createSignalMetadata() {
|
|
42
|
+
return {
|
|
43
|
+
signals: new Set()
|
|
44
|
+
};
|
|
45
|
+
}
|
|
38
46
|
//# sourceMappingURL=Signal.js.map
|
package/dist/actor/Signal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Signal.js","sourceRoot":"","sources":["../../src/actor/Signal.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,kBAAkB,CAAC;AAE1B
|
|
1
|
+
{"version":3,"file":"Signal.js","sourceRoot":"","sources":["../../src/actor/Signal.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,kBAAkB,CAAC;AAE1B,YAAY;AACZ,MAAM,eAAe,GAAG,MAAM,C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AAO,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO;QACL,OAAO,EAAE,IAAI,GAAG,EAAE;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -46,7 +46,6 @@ function initializeBehaviorMetadata(behavior) {
|
|
|
46
46
|
// Delay the loading to ensure that all properties are initialized
|
|
47
47
|
setTimeout(() => {
|
|
48
48
|
BehaviorInitializer.for(behavior)?.load();
|
|
49
|
-
behavior.emit("metadataInitialized");
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
//# sourceMappingURL=Behavior.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Behavior.js","sourceRoot":"","sources":["../../../src/components/script/Behavior.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,+BAA+B;AAC/B,OAAO,EACL,KAAK,EACL,cAAc,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAiB/D,MAAM,OAAO,QAEX,SAAQ,cAAc;IACtB,WAAW,GAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAErC,YACE,KAAY,EACZ,UAA2B,EAAE;QAE7B,KAAK,CAAC;YACJ,KAAK;YACL,QAAQ,EAAE,gBAAgB;SAC3B,CAAC,CAAC;QACH,MAAM,EAAE,WAAW,GAAG,0BAA0B,EAAE,GAAG,OAAO,CAAC;QAE7D,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YAClD,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,CAAC;aACI,CAAC;YACJ,IAAI,CAAC,KAAK,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AC;QAEnD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3D,CAAC;IAEQ,OAAO;QACd,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC/B,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YAClD,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACjE,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YACnD,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;QAED,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AAED,SAAS,0BAA0B,CACjC,QAAkB;IAElB,kEAAkE;IAClE,UAAU,CAAC,GAAG,EAAE;QACd,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -16,7 +16,6 @@ export type BehaviorPropertyMetadata = {
|
|
|
16
16
|
export type BehaviorMetadata = {
|
|
17
17
|
properties: Map<BehaviorKey, BehaviorPropertyMetadata>;
|
|
18
18
|
components: Map<BehaviorKey, SceneActorComponentType>;
|
|
19
|
-
signals: Set<string>;
|
|
20
19
|
};
|
|
21
20
|
export declare function SceneProperty(options: ScenePropertyOptions): PropertyDecorator;
|
|
22
21
|
export declare namespace SceneProperty {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BehaviorDecorators.d.ts","sourceRoot":"","sources":["../../../src/components/script/BehaviorDecorators.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,UAAU,GACV,SAAS,GACT,WAAW,GACX,SAAS,GACT,SAAS,GACT,SAAS,GACT,OAAO,CAAC;AAEZ,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1C,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,GAAG,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAC;IACvD,UAAU,EAAE,GAAG,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"BehaviorDecorators.d.ts","sourceRoot":"","sources":["../../../src/components/script/BehaviorDecorators.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,UAAU,GACV,SAAS,GACT,WAAW,GACX,SAAS,GACT,SAAS,GACT,SAAS,GACT,OAAO,CAAC;AAEZ,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1C,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,GAAG,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAC;IACvD,UAAU,EAAE,GAAG,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;CACvD,CAAC;AAEF,wBAAgB,aAAa,CAC3B,OAAO,EAAE,oBAAoB,GAC5B,iBAAiB,CA8BnB;yBAhCe,aAAa;;;AAmC7B,MAAM,MAAM,uBAAuB,GAC/B,OAAO,aAAa,GACpB,OAAO,cAAc,GACrB,OAAO,YAAY,GACnB,OAAO,gBAAgB,GACvB,OAAO,cAAc,GACrB,GAAG,CAAC;AAER,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,uBAAuB,IAGlC,QAAQ,MAAM,EACd,cAAc,WAAW,KACxB,IAAI,CAiBR;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,GACb,gBAAgB,GAAG,SAAS,CAE9B;AAED,wBAAgB,sBAAsB,IAAI,gBAAgB,CAKzD"}
|
|
@@ -40,8 +40,7 @@ export function getBehaviorMetadata(object) {
|
|
|
40
40
|
export function createBehaviorMetadata() {
|
|
41
41
|
return {
|
|
42
42
|
properties: new Map(),
|
|
43
|
-
components: new Map()
|
|
44
|
-
signals: new Set()
|
|
43
|
+
components: new Map()
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
46
|
//# sourceMappingURL=BehaviorDecorators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BehaviorDecorators.js","sourceRoot":"","sources":["../../../src/components/script/BehaviorDecorators.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"BehaviorDecorators.js","sourceRoot":"","sources":["../../../src/components/script/BehaviorDecorators.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,kBAAkB,CAAC;AA0C1B,MAAM,UAAU,aAAa,CAC3B,OAA6B;IAE7B,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAEzB,OAAO,SAAS,EAAE,CAChB,MAAc,EACd,YAAyB;QAEzB,MAAM,EAAE,KAAK,GAAG,YAAY,CAAC,QAAQ,EAAE,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;QAEtE,MAAM,aAAa,GAA6B;YAC9C,IAAI;YACJ,KAAK;YACL,WAAW;SACZ,CAAC;QAEF,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;QACvD,CAAC;aACI,CAAC;YACJ,MAAM,QAAQ,GAAG,sBAAsB,EAAE,CAAC;YAC1C,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;YAErD,OAAO,CAAC,cAAc,CACpB,aAAa,CAAC,QAAQ,EACtB,QAAQ,EACR,MAAM,CACP,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AACD,aAAa,CAAC,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;AAUxD,MAAM,UAAU,mBAAmB,CACjC,WAAoC;IAEpC,OAAO,SAAS,EAAE,CAChB,MAAc,EACd,YAAyB;QAEzB,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAE7C,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;QACrD,CAAC;aACI,CAAC;YACJ,MAAM,QAAQ,GAAG,sBAAsB,EAAE,CAAC;YAC1C,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;YAEnD,OAAO,CAAC,cAAc,CACpB,aAAa,CAAC,QAAQ,EACtB,QAAQ,EACR,MAAM,CACP,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,MAAc;IAEd,OAAO,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,OAAO;QACL,UAAU,EAAE,IAAI,GAAG,EAAE;QACrB,UAAU,EAAE,IAAI,GAAG,EAAE;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BehaviorInitializer.d.ts","sourceRoot":"","sources":["../../../src/components/script/BehaviorInitializer.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"BehaviorInitializer.d.ts","sourceRoot":"","sources":["../../../src/components/script/BehaviorInitializer.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,CAAC;AAO1B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAgBhE,MAAM,WAAW,0BAA0B;IACzC,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,qBAAa,mBAAmB;;IAK9B,MAAM,CAAC,GAAG,CACR,QAAQ,EAAE,QAAQ,GACjB,mBAAmB,GAAG,IAAI;gBAW3B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,GAAE,0BAA+B;IAS1C,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,IAAI,IAAI;CAgFb"}
|
|
@@ -3,7 +3,6 @@ import * as THREE from "three";
|
|
|
3
3
|
import "reflect-metadata";
|
|
4
4
|
// Import Internal Dependencies
|
|
5
5
|
import { Input } from "../../controls/Input.class.js";
|
|
6
|
-
import { SignalEvent } from "../../actor/Signal.js";
|
|
7
6
|
import { Behavior } from "./Behavior.js";
|
|
8
7
|
import { getBehaviorMetadata } from "./BehaviorDecorators.js";
|
|
9
8
|
import {} from "../../adapters/console.js";
|
|
@@ -42,17 +41,10 @@ export class BehaviorInitializer {
|
|
|
42
41
|
return this.#behavior.constructor.name;
|
|
43
42
|
}
|
|
44
43
|
load() {
|
|
45
|
-
this.#bindSignalHandlers();
|
|
46
44
|
this.#resolveProperties();
|
|
47
45
|
this.#resolveActorComponents();
|
|
48
46
|
this.#resolveInputListeners();
|
|
49
47
|
}
|
|
50
|
-
#bindSignalHandlers() {
|
|
51
|
-
const { signals } = this.#metadata;
|
|
52
|
-
for (const propertyName of signals) {
|
|
53
|
-
this.#behavior[propertyName] = new SignalEvent();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
48
|
#resolveInputListeners() {
|
|
57
49
|
const { input } = this.#behavior.actor.gameInstance;
|
|
58
50
|
const metadata = Reflect.getMetadata(Input.Metadata, this.#behavior) ?? [];
|