@zylem/game-lib 0.3.15 → 0.3.17
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 +38 -13
- package/dist/.vite/manifest.json +665 -2
- package/dist/actions.d.ts +4 -0
- package/dist/actions.js +10 -0
- package/dist/behaviors.d.ts +3 -0
- package/dist/behaviors.js +8 -0
- package/dist/camera.d.ts +3 -0
- package/dist/camera.js +6 -0
- package/dist/core.d.ts +5 -0
- package/dist/core.js +11 -0
- package/dist/entities.d.ts +8 -0
- package/dist/entities.js +19 -0
- package/dist/lib/actions/behaviors/actions.js +35 -0
- package/dist/lib/actions/behaviors/boundaries/boundary.d.ts +1 -1
- package/dist/lib/actions/behaviors/boundaries/boundary.js +40 -0
- package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.js +100 -0
- package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.js +37 -0
- package/dist/lib/actions/behaviors/ricochet/ricochet.d.ts +2 -0
- package/dist/lib/actions/behaviors/ricochet/ricochet.js +6 -0
- package/dist/lib/actions/capabilities/moveable.js +108 -0
- package/dist/lib/actions/capabilities/rotatable.js +82 -0
- package/dist/lib/actions/capabilities/transformable.js +9 -0
- package/dist/lib/actions/global-change.js +40 -0
- package/dist/lib/camera/camera.js +19 -0
- package/dist/lib/camera/fixed-2d.js +30 -0
- package/dist/lib/camera/perspective.js +10 -0
- package/dist/lib/camera/third-person.js +42 -0
- package/dist/lib/camera/zylem-camera.js +145 -0
- package/dist/lib/collision/collision-builder.js +46 -0
- package/dist/lib/collision/collision-delegate.js +6 -0
- package/dist/lib/collision/utils.js +24 -0
- package/dist/lib/collision/world.js +77 -0
- package/dist/lib/core/base-node-life-cycle.d.ts +14 -0
- package/dist/lib/core/base-node.d.ts +6 -2
- package/dist/lib/core/base-node.js +62 -0
- package/dist/lib/core/entity-asset-loader.js +57 -0
- package/dist/lib/core/lazy-loader.d.ts +2 -2
- package/dist/lib/core/lifecycle-base.js +20 -0
- package/dist/lib/core/preset-shader.js +30 -0
- package/dist/lib/core/three-addons/Timer.js +103 -0
- package/dist/lib/core/utility/nodes.d.ts +11 -0
- package/dist/lib/core/utility/nodes.js +27 -0
- package/dist/lib/core/utility/strings.d.ts +2 -0
- package/dist/lib/core/utility/strings.js +14 -0
- package/dist/lib/core/{utility.d.ts → utility/vector.d.ts} +0 -2
- package/dist/lib/core/utility/vector.js +8 -0
- package/dist/lib/core/vessel.d.ts +3 -1
- package/dist/lib/core/vessel.js +27 -0
- package/dist/lib/debug/console/console-state.js +11 -0
- package/dist/lib/debug/debug-state.js +40 -0
- package/dist/lib/device/aspect-ratio.d.ts +37 -0
- package/dist/lib/device/aspect-ratio.js +44 -0
- package/dist/lib/entities/actor.js +125 -0
- package/dist/lib/entities/box.js +68 -0
- package/dist/lib/entities/builder.js +79 -0
- package/dist/lib/entities/create.js +31 -0
- package/dist/lib/entities/delegates/animation.js +58 -0
- package/dist/lib/entities/delegates/debug.js +72 -0
- package/dist/lib/entities/delegates/loader.js +19 -0
- package/dist/lib/entities/destroy.js +15 -0
- package/dist/lib/entities/entity.d.ts +3 -1
- package/dist/lib/entities/entity.js +120 -0
- package/dist/lib/entities/plane.js +81 -0
- package/dist/lib/entities/rect.js +160 -0
- package/dist/lib/entities/sphere.js +68 -0
- package/dist/lib/entities/sprite.js +118 -0
- package/dist/lib/entities/text.js +111 -0
- package/dist/lib/entities/zone.js +103 -0
- package/dist/lib/game/game-blueprint.d.ts +44 -0
- package/dist/lib/game/game-canvas.d.ts +34 -0
- package/dist/lib/game/game-canvas.js +57 -0
- package/dist/lib/game/game-config.d.ts +47 -0
- package/dist/lib/game/game-config.js +53 -0
- package/dist/lib/game/game-default.d.ts +18 -0
- package/dist/lib/game/game-default.js +24 -0
- package/dist/lib/game/game-state.js +17 -0
- package/dist/lib/game/game.d.ts +2 -5
- package/dist/lib/game/game.js +133 -0
- package/dist/lib/game/zylem-game.d.ts +12 -1
- package/dist/lib/game/zylem-game.js +133 -0
- package/dist/lib/graphics/geometries/XZPlaneGeometry.js +34 -0
- package/dist/lib/graphics/material.d.ts +1 -1
- package/dist/lib/graphics/material.js +64 -0
- package/dist/lib/graphics/mesh.js +14 -0
- package/dist/lib/graphics/render-pass.js +56 -0
- package/dist/lib/graphics/shaders/fragment/debug.glsl.js +23 -0
- package/dist/lib/graphics/shaders/fragment/fire.glsl.js +52 -0
- package/dist/lib/graphics/shaders/fragment/standard.glsl.js +11 -0
- package/dist/lib/graphics/shaders/fragment/stars.glsl.js +44 -0
- package/dist/lib/graphics/shaders/vertex/debug.glsl.js +15 -0
- package/dist/lib/graphics/shaders/vertex/object-shader.glsl.js +11 -0
- package/dist/lib/graphics/shaders/vertex/standard.glsl.js +9 -0
- package/dist/lib/graphics/zylem-scene.d.ts +7 -7
- package/dist/lib/graphics/zylem-scene.js +75 -0
- package/dist/lib/input/gamepad-provider.js +58 -0
- package/dist/lib/input/input-manager.js +70 -0
- package/dist/lib/input/keyboard-provider.js +120 -0
- package/dist/lib/stage/debug-entity-cursor.js +53 -0
- package/dist/lib/stage/entity-spawner.js +27 -0
- package/dist/lib/stage/stage-blueprint.d.ts +44 -0
- package/dist/lib/stage/stage-blueprint.js +56 -0
- package/dist/lib/stage/stage-debug-delegate.js +100 -0
- package/dist/lib/stage/stage-default.d.ts +9 -0
- package/dist/lib/stage/stage-default.js +42 -0
- package/dist/lib/stage/stage-state.js +36 -0
- package/dist/lib/stage/stage.d.ts +2 -2
- package/dist/lib/stage/stage.js +60 -0
- package/dist/lib/stage/zylem-stage.d.ts +4 -3
- package/dist/lib/stage/zylem-stage.js +268 -0
- package/dist/lib/systems/transformable.system.js +43 -0
- package/dist/main.d.ts +6 -15
- package/dist/main.js +56 -45933
- package/dist/stage.d.ts +6 -0
- package/dist/stage.js +22 -0
- package/dist/tests/stage/stage-blueprint.spec.d.ts +1 -0
- package/package.json +35 -1
- package/dist/lib/actions/behaviors/index.d.ts +0 -1
- package/dist/lib/core/game-canvas.d.ts +0 -4
- package/dist/main.cjs +0 -4023
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { createWorld as c, addEntity as f, addComponent as u, removeEntity as p } from "bitecs";
|
|
2
|
+
import { Vector3 as o, Color as d, Vector2 as m } from "three";
|
|
3
|
+
import { ZylemWorld as h } from "../collision/world.js";
|
|
4
|
+
import { ZylemScene as y } from "../graphics/zylem-scene.js";
|
|
5
|
+
import { setStageBackgroundColor as g, setStageBackgroundImage as E, setStageVariables as w, resetStageVariables as b } from "./stage-state.js";
|
|
6
|
+
import { ZylemBlueColor as S } from "../core/utility/vector.js";
|
|
7
|
+
import { debugState as a } from "../debug/debug-state.js";
|
|
8
|
+
import { getGlobalState as l } from "../game/game-state.js";
|
|
9
|
+
import { LifeCycleBase as v } from "../core/lifecycle-base.js";
|
|
10
|
+
import M from "../systems/transformable.system.js";
|
|
11
|
+
import { BaseNode as _ } from "../core/base-node.js";
|
|
12
|
+
import { nanoid as C } from "nanoid";
|
|
13
|
+
import { ZylemCamera as B } from "../camera/zylem-camera.js";
|
|
14
|
+
import { Perspectives as O } from "../camera/perspective.js";
|
|
15
|
+
import { CameraWrapper as P } from "../camera/camera.js";
|
|
16
|
+
import { StageDebugDelegate as R } from "./stage-debug-delegate.js";
|
|
17
|
+
import { GameEntity as W } from "../entities/entity.js";
|
|
18
|
+
const k = "Stage";
|
|
19
|
+
class Y extends v {
|
|
20
|
+
type = k;
|
|
21
|
+
state = {
|
|
22
|
+
backgroundColor: S,
|
|
23
|
+
backgroundImage: null,
|
|
24
|
+
inputs: {
|
|
25
|
+
p1: ["gamepad-1", "keyboard"],
|
|
26
|
+
p2: ["gamepad-2", "keyboard"]
|
|
27
|
+
},
|
|
28
|
+
gravity: new o(0, 0, 0),
|
|
29
|
+
variables: {},
|
|
30
|
+
entities: []
|
|
31
|
+
};
|
|
32
|
+
gravity;
|
|
33
|
+
world;
|
|
34
|
+
scene;
|
|
35
|
+
children = [];
|
|
36
|
+
_childrenMap = /* @__PURE__ */ new Map();
|
|
37
|
+
_removalMap = /* @__PURE__ */ new Map();
|
|
38
|
+
pendingEntities = [];
|
|
39
|
+
pendingPromises = [];
|
|
40
|
+
isLoaded = !1;
|
|
41
|
+
_debugMap = /* @__PURE__ */ new Map();
|
|
42
|
+
entityAddedHandlers = [];
|
|
43
|
+
ecs = c();
|
|
44
|
+
testSystem = null;
|
|
45
|
+
transformSystem = null;
|
|
46
|
+
debugDelegate = null;
|
|
47
|
+
uuid;
|
|
48
|
+
wrapperRef = null;
|
|
49
|
+
camera;
|
|
50
|
+
cameraRef = null;
|
|
51
|
+
/**
|
|
52
|
+
* Create a new stage.
|
|
53
|
+
* @param options Stage options: partial config, camera, and initial entities or factories
|
|
54
|
+
*/
|
|
55
|
+
constructor(e = []) {
|
|
56
|
+
super(), this.world = null, this.scene = null, this.uuid = C();
|
|
57
|
+
const { config: t, entities: i, asyncEntities: s, camera: r } = this.parseOptions(e);
|
|
58
|
+
this.camera = r, this.children = i, this.pendingEntities = s, this.saveState({ ...this.state, ...t, entities: [] }), this.gravity = t.gravity ?? new o(0, 0, 0);
|
|
59
|
+
}
|
|
60
|
+
parseOptions(e) {
|
|
61
|
+
let t = {};
|
|
62
|
+
const i = [], s = [];
|
|
63
|
+
let r;
|
|
64
|
+
for (const n of e)
|
|
65
|
+
this.isCameraWrapper(n) ? r = n : this.isBaseNode(n) ? i.push(n) : this.isEntityInput(n) ? s.push(n) : this.isZylemStageConfig(n) && (t = { ...t, ...n });
|
|
66
|
+
return { config: t, entities: i, asyncEntities: s, camera: r };
|
|
67
|
+
}
|
|
68
|
+
isZylemStageConfig(e) {
|
|
69
|
+
return e && typeof e == "object" && !(e instanceof _) && !(e instanceof P);
|
|
70
|
+
}
|
|
71
|
+
isBaseNode(e) {
|
|
72
|
+
return e && typeof e == "object" && typeof e.create == "function";
|
|
73
|
+
}
|
|
74
|
+
isCameraWrapper(e) {
|
|
75
|
+
return e && typeof e == "object" && e.constructor.name === "CameraWrapper";
|
|
76
|
+
}
|
|
77
|
+
isEntityInput(e) {
|
|
78
|
+
return e ? !!(this.isBaseNode(e) || typeof e == "function" || typeof e == "object" && typeof e.then == "function") : !1;
|
|
79
|
+
}
|
|
80
|
+
isThenable(e) {
|
|
81
|
+
return !!e && typeof e.then == "function";
|
|
82
|
+
}
|
|
83
|
+
handleEntityImmediatelyOrQueue(e) {
|
|
84
|
+
this.isLoaded ? this.spawnEntity(e) : this.children.push(e);
|
|
85
|
+
}
|
|
86
|
+
handlePromiseWithSpawnOnResolve(e) {
|
|
87
|
+
this.isLoaded ? e.then((t) => this.spawnEntity(t)).catch((t) => console.error("Failed to build async entity", t)) : this.pendingPromises.push(e);
|
|
88
|
+
}
|
|
89
|
+
saveState(e) {
|
|
90
|
+
this.state = e;
|
|
91
|
+
}
|
|
92
|
+
setState() {
|
|
93
|
+
const { backgroundColor: e, backgroundImage: t } = this.state, i = e instanceof d ? e : new d(e);
|
|
94
|
+
g(i), E(t), w(this.state.variables ?? {});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Load and initialize the stage's scene and world.
|
|
98
|
+
* @param id DOM element id for the renderer container
|
|
99
|
+
* @param camera Optional camera override
|
|
100
|
+
*/
|
|
101
|
+
async load(e, t) {
|
|
102
|
+
this.setState();
|
|
103
|
+
const i = t || (this.camera ? this.camera.cameraRef : this.createDefaultCamera());
|
|
104
|
+
this.cameraRef = i, this.scene = new y(e, i, this.state);
|
|
105
|
+
const s = await h.loadPhysics(this.gravity ?? new o(0, 0, 0));
|
|
106
|
+
this.world = new h(s), this.scene.setup();
|
|
107
|
+
for (let r of this.children)
|
|
108
|
+
this.spawnEntity(r);
|
|
109
|
+
if (this.pendingEntities.length && (this.enqueue(...this.pendingEntities), this.pendingEntities = []), this.pendingPromises.length) {
|
|
110
|
+
for (const r of this.pendingPromises)
|
|
111
|
+
r.then((n) => this.spawnEntity(n)).catch((n) => console.error("Failed to resolve pending stage entity", n));
|
|
112
|
+
this.pendingPromises = [];
|
|
113
|
+
}
|
|
114
|
+
this.transformSystem = M(this), this.isLoaded = !0;
|
|
115
|
+
}
|
|
116
|
+
createDefaultCamera() {
|
|
117
|
+
const e = window.innerWidth, t = window.innerHeight, i = new m(e, t);
|
|
118
|
+
return new B(O.ThirdPerson, i);
|
|
119
|
+
}
|
|
120
|
+
_setup(e) {
|
|
121
|
+
if (!this.scene || !this.world) {
|
|
122
|
+
this.logMissingEntities();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
a.on && (this.debugDelegate = new R(this));
|
|
126
|
+
}
|
|
127
|
+
_update(e) {
|
|
128
|
+
const { delta: t } = e;
|
|
129
|
+
if (!this.scene || !this.world) {
|
|
130
|
+
this.logMissingEntities();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
this.world.update(e), this.transformSystem(this.ecs), this._childrenMap.forEach((i, s) => {
|
|
134
|
+
i.nodeUpdate({
|
|
135
|
+
...e,
|
|
136
|
+
me: i
|
|
137
|
+
}), i.markedForRemoval && this.removeEntityByUuid(i.uuid);
|
|
138
|
+
}), this.scene.update({ delta: t });
|
|
139
|
+
}
|
|
140
|
+
outOfLoop() {
|
|
141
|
+
this.debugUpdate();
|
|
142
|
+
}
|
|
143
|
+
/** Update debug overlays and helpers if enabled. */
|
|
144
|
+
debugUpdate() {
|
|
145
|
+
a.on && this.debugDelegate?.update();
|
|
146
|
+
}
|
|
147
|
+
/** Cleanup owned resources when the stage is destroyed. */
|
|
148
|
+
_destroy(e) {
|
|
149
|
+
this._childrenMap.forEach((t) => {
|
|
150
|
+
try {
|
|
151
|
+
t.nodeDestroy({ me: t, globals: l() });
|
|
152
|
+
} catch {
|
|
153
|
+
}
|
|
154
|
+
}), this._childrenMap.clear(), this._removalMap.clear(), this._debugMap.clear(), this.world?.destroy(), this.scene?.destroy(), this.debugDelegate?.dispose(), this.isLoaded = !1, this.world = null, this.scene = null, this.cameraRef = null, b();
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Create, register, and add an entity to the scene/world.
|
|
158
|
+
* Safe to call only after `load` when scene/world exist.
|
|
159
|
+
*/
|
|
160
|
+
async spawnEntity(e) {
|
|
161
|
+
if (!this.scene || !this.world)
|
|
162
|
+
return;
|
|
163
|
+
const t = e.create(), i = f(this.ecs);
|
|
164
|
+
if (t.eid = i, this.scene.addEntity(t), e.behaviors)
|
|
165
|
+
for (let s of e.behaviors) {
|
|
166
|
+
u(this.ecs, s.component, t.eid);
|
|
167
|
+
const r = Object.keys(s.values);
|
|
168
|
+
for (const n of r)
|
|
169
|
+
s.component[n][t.eid] = s.values[n];
|
|
170
|
+
}
|
|
171
|
+
t.colliderDesc && this.world.addEntity(t), e.nodeSetup({
|
|
172
|
+
me: e,
|
|
173
|
+
globals: l(),
|
|
174
|
+
camera: this.scene.zylemCamera
|
|
175
|
+
}), this.addEntityToStage(t);
|
|
176
|
+
}
|
|
177
|
+
buildEntityState(e) {
|
|
178
|
+
return e instanceof W ? { ...e.buildInfo() } : {
|
|
179
|
+
uuid: e.uuid,
|
|
180
|
+
name: e.name,
|
|
181
|
+
eid: e.eid
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/** Add the entity to internal maps and notify listeners. */
|
|
185
|
+
addEntityToStage(e) {
|
|
186
|
+
this._childrenMap.set(e.eid, e), a.on && this._debugMap.set(e.uuid, e);
|
|
187
|
+
for (const t of this.entityAddedHandlers)
|
|
188
|
+
try {
|
|
189
|
+
t(e);
|
|
190
|
+
} catch (i) {
|
|
191
|
+
console.error("onEntityAdded handler failed", i);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Subscribe to entity-added events.
|
|
196
|
+
* @param callback Invoked for each entity when added
|
|
197
|
+
* @param options.replayExisting If true and stage already loaded, replays existing entities
|
|
198
|
+
* @returns Unsubscribe function
|
|
199
|
+
*/
|
|
200
|
+
onEntityAdded(e, t) {
|
|
201
|
+
return this.entityAddedHandlers.push(e), t?.replayExisting && this.isLoaded && this._childrenMap.forEach((i) => {
|
|
202
|
+
try {
|
|
203
|
+
e(i);
|
|
204
|
+
} catch (s) {
|
|
205
|
+
console.error("onEntityAdded replay failed", s);
|
|
206
|
+
}
|
|
207
|
+
}), () => {
|
|
208
|
+
this.entityAddedHandlers = this.entityAddedHandlers.filter((i) => i !== e);
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Remove an entity and its resources by its UUID.
|
|
213
|
+
* @returns true if removed, false if not found or stage not ready
|
|
214
|
+
*/
|
|
215
|
+
removeEntityByUuid(e) {
|
|
216
|
+
if (!this.scene || !this.world)
|
|
217
|
+
return !1;
|
|
218
|
+
const i = this.world.collisionMap.get(e) ?? this._debugMap.get(e);
|
|
219
|
+
if (!i)
|
|
220
|
+
return !1;
|
|
221
|
+
this.world.destroyEntity(i), i.group ? this.scene.scene.remove(i.group) : i.mesh && this.scene.scene.remove(i.mesh), p(this.ecs, i.eid);
|
|
222
|
+
let s = null;
|
|
223
|
+
return this._childrenMap.forEach((r, n) => {
|
|
224
|
+
r.uuid === e && (s = n);
|
|
225
|
+
}), s !== null && this._childrenMap.delete(s), this._debugMap.delete(e), !0;
|
|
226
|
+
}
|
|
227
|
+
/** Get an entity by its name; returns null if not found. */
|
|
228
|
+
getEntityByName(e) {
|
|
229
|
+
const i = Object.entries(Object.fromEntries(this._childrenMap)).map((s) => s[1]).find((s) => s.name === e);
|
|
230
|
+
return i || console.warn(`Entity ${e} not found`), i ?? null;
|
|
231
|
+
}
|
|
232
|
+
logMissingEntities() {
|
|
233
|
+
console.warn("Zylem world or scene is null");
|
|
234
|
+
}
|
|
235
|
+
/** Resize renderer viewport. */
|
|
236
|
+
resize(e, t) {
|
|
237
|
+
this.scene && this.scene.updateRenderer(e, t);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Enqueue items to be spawned. Items can be:
|
|
241
|
+
* - BaseNode instances (immediate or deferred until load)
|
|
242
|
+
* - Factory functions returning BaseNode or Promise<BaseNode>
|
|
243
|
+
* - Promises resolving to BaseNode
|
|
244
|
+
*/
|
|
245
|
+
enqueue(...e) {
|
|
246
|
+
for (const t of e)
|
|
247
|
+
if (t) {
|
|
248
|
+
if (this.isBaseNode(t)) {
|
|
249
|
+
this.handleEntityImmediatelyOrQueue(t);
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
if (typeof t == "function") {
|
|
253
|
+
try {
|
|
254
|
+
const i = t();
|
|
255
|
+
this.isBaseNode(i) ? this.handleEntityImmediatelyOrQueue(i) : this.isThenable(i) && this.handlePromiseWithSpawnOnResolve(i);
|
|
256
|
+
} catch (i) {
|
|
257
|
+
console.error("Error executing entity factory", i);
|
|
258
|
+
}
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
this.isThenable(t) && this.handlePromiseWithSpawnOnResolve(t);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
export {
|
|
266
|
+
k as STAGE_TYPE,
|
|
267
|
+
Y as ZylemStage
|
|
268
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineComponent as s, defineQuery as Q, defineSystem as R, Types as e } from "bitecs";
|
|
2
|
+
import { Quaternion as v } from "three";
|
|
3
|
+
const n = s({
|
|
4
|
+
x: e.f32,
|
|
5
|
+
y: e.f32,
|
|
6
|
+
z: e.f32
|
|
7
|
+
}), i = s({
|
|
8
|
+
x: e.f32,
|
|
9
|
+
y: e.f32,
|
|
10
|
+
z: e.f32,
|
|
11
|
+
w: e.f32
|
|
12
|
+
}), k = s({
|
|
13
|
+
x: e.f32,
|
|
14
|
+
y: e.f32,
|
|
15
|
+
z: e.f32
|
|
16
|
+
});
|
|
17
|
+
function E(y) {
|
|
18
|
+
const c = Q([n, i]), f = y._childrenMap;
|
|
19
|
+
return R((r) => {
|
|
20
|
+
const m = c(r);
|
|
21
|
+
if (f === void 0)
|
|
22
|
+
return r;
|
|
23
|
+
for (const [u, p] of f) {
|
|
24
|
+
const o = m[u], t = p;
|
|
25
|
+
if (t === void 0 || !t?.body || t.markedForRemoval)
|
|
26
|
+
continue;
|
|
27
|
+
const { x, y: d, z } = t.body.translation();
|
|
28
|
+
if (n.x[o] = x, n.y[o] = d, n.z[o] = z, t.group ? t.group.position.set(n.x[o], n.y[o], n.z[o]) : t.mesh && t.mesh.position.set(n.x[o], n.y[o], n.z[o]), t.controlledRotation)
|
|
29
|
+
continue;
|
|
30
|
+
const { x: l, y: g, z: h, w } = t.body.rotation();
|
|
31
|
+
i.x[o] = l, i.y[o] = g, i.z[o] = h, i.w[o] = w;
|
|
32
|
+
const a = new v(i.x[o], i.y[o], i.z[o], i.w[o]);
|
|
33
|
+
t.group ? t.group.setRotationFromQuaternion(a) : t.mesh && t.mesh.setRotationFromQuaternion(a);
|
|
34
|
+
}
|
|
35
|
+
return r;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
E as default,
|
|
40
|
+
n as position,
|
|
41
|
+
i as rotation,
|
|
42
|
+
k as scale
|
|
43
|
+
};
|
package/dist/main.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { game } from './lib/game/game';
|
|
2
2
|
export type { ZylemGameConfig } from './lib/game/game-interfaces';
|
|
3
|
+
export { gameConfig } from './lib/game/game-config';
|
|
3
4
|
export { stage } from './lib/stage/stage';
|
|
4
5
|
export { entitySpawner } from './lib/stage/entity-spawner';
|
|
5
6
|
export type { StageOptions } from './lib/stage/zylem-stage';
|
|
@@ -7,7 +8,7 @@ export { vessel } from './lib/core/vessel';
|
|
|
7
8
|
export { camera } from './lib/camera/camera';
|
|
8
9
|
export type { PerspectiveType } from './lib/camera/perspective';
|
|
9
10
|
export { Perspectives } from './lib/camera/perspective';
|
|
10
|
-
export type { Vect3 } from './lib/core/utility';
|
|
11
|
+
export type { Vect3 } from './lib/core/utility/vector';
|
|
11
12
|
export { box } from './lib/entities/box';
|
|
12
13
|
export { sphere } from './lib/entities/sphere';
|
|
13
14
|
export { sprite } from './lib/entities/sprite';
|
|
@@ -15,26 +16,16 @@ export { plane } from './lib/entities/plane';
|
|
|
15
16
|
export { zone } from './lib/entities/zone';
|
|
16
17
|
export { actor } from './lib/entities/actor';
|
|
17
18
|
export { text } from './lib/entities/text';
|
|
19
|
+
export { rect } from './lib/entities/rect';
|
|
18
20
|
export { ZylemBox } from './lib/entities/box';
|
|
19
21
|
export { makeMoveable } from './lib/actions/capabilities/moveable';
|
|
20
22
|
export { makeRotatable } from './lib/actions/capabilities/rotatable';
|
|
21
23
|
export { makeTransformable } from './lib/actions/capabilities/transformable';
|
|
22
|
-
export
|
|
24
|
+
export { ricochet2DInBounds } from './lib/actions/behaviors/ricochet/ricochet-2d-in-bounds';
|
|
25
|
+
export { ricochet2DCollision } from './lib/actions/behaviors/ricochet/ricochet-2d-collision';
|
|
26
|
+
export { boundary2d } from './lib/actions/behaviors/boundaries/boundary';
|
|
23
27
|
export { destroy } from './lib/entities/destroy';
|
|
24
28
|
export { Howl } from 'howler';
|
|
25
29
|
export * as THREE from 'three';
|
|
26
30
|
export * as RAPIER from '@dimforge/rapier3d-compat';
|
|
27
31
|
export { globalChange, globalChanges, variableChange, variableChanges } from './lib/actions/global-change';
|
|
28
|
-
declare const Zylem: {
|
|
29
|
-
Util: {
|
|
30
|
-
wait(delay: number, callback: Function): void;
|
|
31
|
-
actionOnPress: (isPressed: boolean, callback: Function) => void;
|
|
32
|
-
actionOnRelease: (isPressed: boolean, callback: Function) => void;
|
|
33
|
-
actionWithCooldown: ({ timer, immediate }: {
|
|
34
|
-
timer: number;
|
|
35
|
-
immediate?: boolean;
|
|
36
|
-
}, callback: Function, update: Function) => void;
|
|
37
|
-
actionWithThrottle: (timer: number, callback: Function) => void;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export { Zylem };
|