@zylem/game-lib 0.7.0 → 0.8.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 +15 -1
- package/dist/actions.d.ts +71 -8
- package/dist/actions.js +1 -1
- package/dist/api/game-lib.api.json +54074 -0
- package/dist/api/game-lib.api.md +4544 -0
- package/dist/api/game-lib.d.ts +8258 -0
- package/dist/api/game-lib.typedoc.json +345421 -0
- package/dist/audio.js +1 -1
- package/dist/{base-node-life-cycle-CnJ-7zX-.d.ts → base-node-life-cycle-D2NuN1VB.d.ts} +12 -4
- package/dist/behavior.d.ts +2 -3
- package/dist/behavior.js +1 -1
- package/dist/blueprints-TbGY-h53.d.ts +162 -0
- package/dist/chunk-7FR5JSQ2.js +1 -0
- package/dist/chunk-7GYFZKK7.js +1 -0
- package/dist/chunk-7WRQ2UAN.js +1 -0
- package/dist/chunk-BH53MBAZ.js +1 -0
- package/dist/chunk-BIGH6D34.js +0 -0
- package/dist/chunk-CM5YRNBJ.js +19 -0
- package/dist/chunk-COM6HJ2L.js +1 -0
- package/dist/chunk-D2PATZCC.js +1 -0
- package/dist/chunk-DFLI7ICU.js +0 -0
- package/dist/chunk-E3UBSUPX.js +1 -0
- package/dist/chunk-FKIKN7RP.js +24 -0
- package/dist/chunk-G4HONLWC.js +1 -0
- package/dist/chunk-IKWE2W6L.js +1 -0
- package/dist/chunk-IPWUDOV5.js +1 -0
- package/dist/chunk-JEHFHUH4.js +0 -0
- package/dist/chunk-JNKPTL77.js +1 -0
- package/dist/chunk-JQKS42G4.js +1 -0
- package/dist/chunk-M3XNO56P.js +1 -0
- package/dist/chunk-ORIDWL3T.js +0 -0
- package/dist/chunk-QB3NL7VQ.js +1 -0
- package/dist/chunk-TAUWDQZF.js +9 -0
- package/dist/chunk-VS2D4B3W.js +1 -0
- package/dist/chunk-WQ3WMMZD.js +1 -0
- package/dist/chunk-XK63E4SX.js +1 -0
- package/dist/chunk-XNDS4YFR.js +1 -0
- package/dist/chunk-XNHVRFAK.js +1 -0
- package/dist/chunk-ZRT3ZQVH.js +1 -0
- package/dist/collision-builder-jF-toPIl.d.ts +38 -0
- package/dist/core.d.ts +45 -30
- package/dist/core.js +1 -24
- package/dist/debug-state-BPT6jEog.d.ts +17 -0
- package/dist/debug.d.ts +71 -19
- package/dist/debug.js +1 -1
- package/dist/{default-controls-BGc61yYl.d.ts → default-controls-0-vCnli7.d.ts} +3 -3
- package/dist/{entity-DNkYKfdp.d.ts → entity-BdSI8CL3.d.ts} +63 -444
- package/dist/entity-DZbFQ1Wg.d.ts +28 -0
- package/dist/{entity-type-map-C94h2TDW.d.ts → entity-type-map-Bd69SpAS.d.ts} +153 -6
- package/dist/entity.d.ts +11 -8
- package/dist/entity.js +1 -1
- package/dist/events.d.ts +10 -1
- package/dist/events.js +1 -1
- package/dist/{game-Cuj5gy7U.d.ts → game-C1FHVqXl.d.ts} +429 -133
- package/dist/game-default-QHROHW2O.js +1 -0
- package/dist/{game-interfaces-tfpM5NBk.d.ts → game-interfaces-mchNYSZE.d.ts} +2 -2
- package/dist/globals.d.ts +12 -1
- package/dist/globals.js +1 -1
- package/dist/graphics.d.ts +16 -46
- package/dist/graphics.js +1 -1
- package/dist/input-ui.d.ts +5 -4
- package/dist/input-ui.js +1 -1
- package/dist/input.d.ts +4 -3
- package/dist/input.js +1 -1
- package/dist/{material-Wz83vTTp.d.ts → material-9vJ6SZaI.d.ts} +25 -50
- package/dist/public.d.ts +38 -0
- package/dist/public.js +1 -0
- package/dist/runtime.d.ts +7 -381
- package/dist/runtime.js +1 -1
- package/dist/schema/entity.schema.json +244 -0
- package/dist/schema/game-config.schema.json +625 -0
- package/dist/schema/input-config.schema.json +499 -0
- package/dist/schema/stage-config.schema.json +93 -0
- package/dist/schema/stage.schema.json +271 -0
- package/dist/schema.d.ts +538 -0
- package/dist/schema.js +1 -0
- package/dist/stage-transition-CmGpV4tc.d.ts +46 -0
- package/dist/vector-CiSHbivc.d.ts +133 -0
- package/dist/web-components.d.ts +15 -12
- package/dist/web-components.js +1 -9
- package/dist/{zylem-stage-runtime-Cs-UDEVU.d.ts → zylem-camera-C3bn6BTI.d.ts} +62 -264
- package/package.json +28 -20
- package/dist/chunk-73VZQZUL.js +0 -1
- package/dist/chunk-A34ZG3L4.js +0 -1
- package/dist/chunk-CDPY4VOQ.js +0 -1
- package/dist/chunk-DR6XXZE7.js +0 -19
- package/dist/chunk-FM5TBEPO.js +0 -1
- package/dist/chunk-G2IIMSUH.js +0 -1
- package/dist/chunk-NIH5CONO.js +0 -1
- package/dist/chunk-ONWXGBWB.js +0 -1
- package/dist/chunk-QEDQDR27.js +0 -1
- package/dist/chunk-WKHW2QO2.js +0 -1
- package/dist/chunk-YHKXQ2ZN.js +0 -1
- package/dist/game-default-PZLLHYL7.js +0 -1
- package/dist/world-C9zdyl5d.d.ts +0 -103
package/README.md
CHANGED
|
@@ -15,10 +15,24 @@ This library is intended for hobbyist developers who want to play with 3D web te
|
|
|
15
15
|
The goal is to give you tools to build simple 3D games. It's basically comprised of:
|
|
16
16
|
|
|
17
17
|
- Rendering via ThreeJS with some capability to handle postprocessing built-in. [ThreeJS](https://threejs.org/)
|
|
18
|
-
- Collision handling, triggers, and rigid body physics via
|
|
18
|
+
- Collision handling, triggers, and rigid body physics simulated in WebAssembly (Rapier compiled to WASM via [@zylem/runtime](https://www.npmjs.com/package/@zylem/runtime), driven through [@zylem/behaviors](https://www.npmjs.com/package/@zylem/behaviors))
|
|
19
19
|
- Game state management with Valtio [Valtio](https://valtio.dev/)
|
|
20
20
|
- Simplified input handling (gamepad, keyboard, mouse)
|
|
21
21
|
|
|
22
|
+
**Architecture layers**
|
|
23
|
+
|
|
24
|
+
Zylem is split into three packages, each a strict layer over the one below:
|
|
25
|
+
|
|
26
|
+
| Layer | Package | Owns |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| Game framework | `@zylem/game-lib` | Three.js rendering, input, assets, stages, game state |
|
|
29
|
+
| Simulation | `@zylem/behaviors` | `createSimulation()`, entity registry, behavior FSMs, event translation, runtime ownership |
|
|
30
|
+
| Runtime | `@zylem/runtime` | WASM module: ECS + Rapier physics, slot-indexed input/render/snapshot/event buffers |
|
|
31
|
+
|
|
32
|
+
Each frame, game-lib forwards behavior inputs into the simulation, calls `simulation.update(delta)` (fixed-timestep physics inside WASM), then syncs interpolated render poses onto Three.js objects. Disposal follows the same chain: `Game.dispose()` → `Simulation.dispose()` → WASM stage destroy.
|
|
33
|
+
|
|
34
|
+
Games normally never touch the runtime directly; for debug tooling there is an escape hatch: `game.experimental.getRuntime()` returns the underlying `Simulation`.
|
|
35
|
+
|
|
22
36
|
> Note: This project is still in alpha. There are unfinished features and some APIs that may change.
|
|
23
37
|
|
|
24
38
|
## Installation
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { A as Action, G as GameEntity } from './entity-
|
|
2
|
-
export {
|
|
1
|
+
import { A as Action, G as GameEntity } from './entity-BdSI8CL3.js';
|
|
2
|
+
export { x as getRotation, i as rotateEuler, r as rotateInDirection, j as rotateX, k as rotateY, h as rotateYEuler, l as rotateZ, w as setRotation, q as setRotationDegrees, u as setRotationDegreesX, t as setRotationDegreesY, v as setRotationDegreesZ, n as setRotationX, m as setRotationY, o as setRotationZ } from './entity-BdSI8CL3.js';
|
|
3
3
|
import { Object3D } from 'three';
|
|
4
4
|
import { TransformState } from '@zylem/behaviors/core';
|
|
5
|
-
export { TransformState, createTransformStore, getPosition, getVelocity, move, moveForwardXY, moveX, moveXY, moveXZ, moveY, moveZ,
|
|
6
|
-
import
|
|
7
|
-
import './material-
|
|
5
|
+
export { TransformState, createTransformStore, getPosition, getVelocity, move, moveForwardXY, moveX, moveXY, moveXZ, moveY, moveZ, resetVelocity, setPosition, setPositionX, setPositionY, setPositionZ, wrapAround3D, wrapAroundXY } from '@zylem/behaviors/core';
|
|
6
|
+
import './vector-CiSHbivc.js';
|
|
7
|
+
import './material-9vJ6SZaI.js';
|
|
8
8
|
import 'three/webgpu';
|
|
9
|
-
import './
|
|
9
|
+
import './collision-builder-jF-toPIl.js';
|
|
10
|
+
import './base-node-life-cycle-D2NuN1VB.js';
|
|
11
|
+
import './stage-transition-CmGpV4tc.js';
|
|
10
12
|
import './events.js';
|
|
11
13
|
import 'mitt';
|
|
12
14
|
|
|
@@ -256,11 +258,72 @@ declare function repeat(action: Action, times: number): Action;
|
|
|
256
258
|
declare function repeatForever(action: Action): Action;
|
|
257
259
|
|
|
258
260
|
/**
|
|
259
|
-
*
|
|
261
|
+
* Structural slice of the simulation body facade used to flush transform
|
|
262
|
+
* intents. `SimulationBody` satisfies this shape.
|
|
263
|
+
*/
|
|
264
|
+
interface TransformableBodyLike {
|
|
265
|
+
linvel(): {
|
|
266
|
+
x: number;
|
|
267
|
+
y: number;
|
|
268
|
+
z: number;
|
|
269
|
+
};
|
|
270
|
+
translation(): {
|
|
271
|
+
x: number;
|
|
272
|
+
y: number;
|
|
273
|
+
z: number;
|
|
274
|
+
};
|
|
275
|
+
setLinvel(velocity: {
|
|
276
|
+
x: number;
|
|
277
|
+
y: number;
|
|
278
|
+
z: number;
|
|
279
|
+
}, wakeUp: boolean): void;
|
|
280
|
+
setTranslation(translation: {
|
|
281
|
+
x: number;
|
|
282
|
+
y: number;
|
|
283
|
+
z: number;
|
|
284
|
+
}, wakeUp: boolean): void;
|
|
285
|
+
setRotation(rotation: {
|
|
286
|
+
x: number;
|
|
287
|
+
y: number;
|
|
288
|
+
z: number;
|
|
289
|
+
w: number;
|
|
290
|
+
}, wakeUp: boolean): void;
|
|
291
|
+
setAngvel(velocity: {
|
|
292
|
+
x: number;
|
|
293
|
+
y: number;
|
|
294
|
+
z: number;
|
|
295
|
+
}, wakeUp: boolean): void;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Minimal slice of the WASM stage runtime used to apply transform intents via
|
|
299
|
+
* FFI. Kept structural so this module need not import the full runtime type.
|
|
300
|
+
*/
|
|
301
|
+
interface RuntimeTransformTarget {
|
|
302
|
+
getLinearVelocity(slot: number, out?: [number, number, number]): [number, number, number] | null;
|
|
303
|
+
setLinearVelocity(slot: number, x: number, y: number, z: number): boolean;
|
|
304
|
+
setAngularVelocity(slot: number, x: number, y: number, z: number): boolean;
|
|
305
|
+
setRotation(slot: number, x: number, y: number, z: number, w: number): boolean;
|
|
306
|
+
setPosition(slot: number, x: number, y: number, z: number): boolean;
|
|
307
|
+
getPose(slot: number): {
|
|
308
|
+
position: [number, number, number];
|
|
309
|
+
rotation: [number, number, number, number];
|
|
310
|
+
} | null;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Entity that can have transformations applied from a store.
|
|
314
|
+
*
|
|
315
|
+
* When `body` (the simulation body facade) is present the intents flush
|
|
316
|
+
* through it; otherwise, if the entity carries a live WASM slot
|
|
317
|
+
* (`runtimeHandle` >= 0 + `wasmStageRef`), they flush through the runtime's
|
|
318
|
+
* FFI setters directly.
|
|
260
319
|
*/
|
|
261
320
|
interface TransformableEntity {
|
|
262
|
-
body:
|
|
321
|
+
body: TransformableBodyLike | null;
|
|
263
322
|
transformStore?: TransformState;
|
|
323
|
+
/** Live WASM slot handle, or -1 when not runtime-attached. */
|
|
324
|
+
runtimeHandle?: number;
|
|
325
|
+
/** Runtime adapter the entity is attached to, if any. */
|
|
326
|
+
wasmStageRef?: RuntimeTransformTarget | null;
|
|
264
327
|
}
|
|
265
328
|
/**
|
|
266
329
|
* Apply accumulated transformations from the store to the physics body.
|
package/dist/actions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as Q,B as R,C as S,D as T,E as U,a as q,b as r,c as s,d as t,e as u,f as v,g as w,h as x,i as y,j as z,k as A,l as B,m as C,n as D,o as E,p as F,q as G,r as H,s as I,t as J,u as K,v as L,w as M,x as N,y as O,z as P}from"./chunk-IPWUDOV5.js";import{a as p}from"./chunk-BH53MBAZ.js";import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-XRP4JJXL.js";export{p as applyTransformChanges,v as callFunc,E as createTransformStore,u as delay,w as fadeOpacity,N as getPosition,o as getRotation,O as getVelocity,F as move,r as moveBy,M as moveForwardXY,s as moveTo,G as moveX,J as moveXY,K as moveXZ,H as moveY,I as moveZ,y as onPress,z as onRelease,B as parallel,C as repeat,D as repeatForever,q as resetEntityOpacity,L as resetVelocity,t as rotateBy,c as rotateEuler,a as rotateInDirection,e as rotateX,d as rotateY,b as rotateYEuler,f as rotateZ,A as sequence,P as setPosition,Q as setPositionX,R as setPositionY,S as setPositionZ,m as setRotation,n as setRotationDegrees,j as setRotationDegreesX,h as setRotationDegreesY,l as setRotationDegreesZ,i as setRotationX,g as setRotationY,k as setRotationZ,x as throttle,U as wrapAround3D,T as wrapAroundXY};
|