@zylem/game-lib 0.3.16 → 0.4.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 +39 -14
- package/dist/.vite/manifest.json +140 -64
- package/dist/api/actions.d.ts +5 -0
- package/dist/api/actions.d.ts.map +1 -0
- package/dist/api/behaviors.d.ts +4 -0
- package/dist/api/behaviors.d.ts.map +1 -0
- package/dist/api/camera.d.ts +4 -0
- package/dist/api/camera.d.ts.map +1 -0
- package/dist/api/core.d.ts +6 -0
- package/dist/api/core.d.ts.map +1 -0
- package/dist/api/entities.d.ts +9 -0
- package/dist/api/entities.d.ts.map +1 -0
- package/dist/api/main.d.ts +32 -0
- package/dist/api/main.d.ts.map +1 -0
- package/dist/api/stage.d.ts +7 -0
- package/dist/api/stage.d.ts.map +1 -0
- package/dist/core.js +4 -4
- package/dist/lib/actions/behaviors/actions.d.ts +1 -0
- package/dist/lib/actions/behaviors/actions.d.ts.map +1 -0
- package/dist/lib/actions/behaviors/behavior.d.ts +1 -0
- package/dist/lib/actions/behaviors/behavior.d.ts.map +1 -0
- package/dist/lib/actions/behaviors/boundaries/boundary.d.ts +1 -0
- package/dist/lib/actions/behaviors/boundaries/boundary.d.ts.map +1 -0
- package/dist/lib/actions/behaviors/character-controller.d.ts +1 -0
- package/dist/lib/actions/behaviors/character-controller.d.ts.map +1 -0
- package/dist/lib/actions/behaviors/debug/debug-collision.d.ts +1 -0
- package/dist/lib/actions/behaviors/debug/debug-collision.d.ts.map +1 -0
- package/dist/lib/actions/behaviors/debug/debug-update.d.ts +1 -0
- package/dist/lib/actions/behaviors/debug/debug-update.d.ts.map +1 -0
- package/dist/lib/actions/behaviors/debug/debug.d.ts +1 -0
- package/dist/lib/actions/behaviors/debug/debug.d.ts.map +1 -0
- package/dist/lib/actions/behaviors/movement/movement-sequence-2d.d.ts +1 -0
- package/dist/lib/actions/behaviors/movement/movement-sequence-2d.d.ts.map +1 -0
- package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts +1 -0
- package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts.map +1 -0
- package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts +1 -0
- package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts.map +1 -0
- package/dist/lib/actions/behaviors/ricochet/ricochet.d.ts +1 -0
- package/dist/lib/actions/behaviors/ricochet/ricochet.d.ts.map +1 -0
- package/dist/lib/actions/behaviors/zylem-behavior.d.ts +1 -0
- package/dist/lib/actions/behaviors/zylem-behavior.d.ts.map +1 -0
- package/dist/lib/actions/capabilities/moveable.d.ts +1 -0
- package/dist/lib/actions/capabilities/moveable.d.ts.map +1 -0
- package/dist/lib/actions/capabilities/rotatable.d.ts +1 -0
- package/dist/lib/actions/capabilities/rotatable.d.ts.map +1 -0
- package/dist/lib/actions/capabilities/transformable.d.ts +1 -0
- package/dist/lib/actions/capabilities/transformable.d.ts.map +1 -0
- package/dist/lib/actions/global-change.d.ts +1 -0
- package/dist/lib/actions/global-change.d.ts.map +1 -0
- package/dist/lib/camera/camera.d.ts +1 -0
- package/dist/lib/camera/camera.d.ts.map +1 -0
- package/dist/lib/camera/fixed-2d.d.ts +1 -0
- package/dist/lib/camera/fixed-2d.d.ts.map +1 -0
- package/dist/lib/camera/perspective.d.ts +1 -0
- package/dist/lib/camera/perspective.d.ts.map +1 -0
- package/dist/lib/camera/third-person.d.ts +1 -0
- package/dist/lib/camera/third-person.d.ts.map +1 -0
- package/dist/lib/camera/zylem-camera.d.ts +27 -0
- package/dist/lib/camera/zylem-camera.d.ts.map +1 -0
- package/dist/lib/camera/zylem-camera.js +100 -37
- package/dist/lib/collision/collision-builder.d.ts +1 -0
- package/dist/lib/collision/collision-builder.d.ts.map +1 -0
- package/dist/lib/collision/collision-delegate.d.ts +1 -0
- package/dist/lib/collision/collision-delegate.d.ts.map +1 -0
- package/dist/lib/collision/collision-group.d.ts +1 -0
- package/dist/lib/collision/collision-group.d.ts.map +1 -0
- package/dist/lib/collision/collision-mask.d.ts +1 -0
- package/dist/lib/collision/collision-mask.d.ts.map +1 -0
- package/dist/lib/collision/collision.d.ts +1 -0
- package/dist/lib/collision/collision.d.ts.map +1 -0
- package/dist/lib/collision/utils.d.ts +1 -0
- package/dist/lib/collision/utils.d.ts.map +1 -0
- package/dist/lib/collision/world.d.ts +1 -0
- package/dist/lib/collision/world.d.ts.map +1 -0
- package/dist/lib/core/asset-manager.d.ts +1 -0
- package/dist/lib/core/asset-manager.d.ts.map +1 -0
- package/dist/lib/core/base-node-life-cycle.d.ts +15 -0
- package/dist/lib/core/base-node-life-cycle.d.ts.map +1 -0
- package/dist/lib/core/base-node.d.ts +7 -2
- package/dist/lib/core/base-node.d.ts.map +1 -0
- package/dist/lib/core/base-node.js +7 -3
- package/dist/lib/core/entity-asset-loader.d.ts +1 -0
- package/dist/lib/core/entity-asset-loader.d.ts.map +1 -0
- package/dist/lib/core/errors.d.ts +1 -0
- package/dist/lib/core/errors.d.ts.map +1 -0
- package/dist/lib/core/flags.d.ts +1 -0
- package/dist/lib/core/flags.d.ts.map +1 -0
- package/dist/lib/core/index.d.ts +1 -0
- package/dist/lib/core/index.d.ts.map +1 -0
- package/dist/lib/core/lazy-loader.d.ts +3 -2
- package/dist/lib/core/lazy-loader.d.ts.map +1 -0
- package/dist/lib/core/lifecycle-base.d.ts +1 -0
- package/dist/lib/core/lifecycle-base.d.ts.map +1 -0
- package/dist/lib/core/preset-shader.d.ts +1 -0
- package/dist/lib/core/preset-shader.d.ts.map +1 -0
- package/dist/lib/core/three-addons/Timer.d.ts +1 -0
- package/dist/lib/core/three-addons/Timer.d.ts.map +1 -0
- package/dist/lib/core/utility/nodes.d.ts +13 -0
- package/dist/lib/core/utility/nodes.d.ts.map +1 -0
- package/dist/lib/core/utility/nodes.js +31 -0
- package/dist/lib/core/utility/strings.d.ts +3 -0
- package/dist/lib/core/utility/strings.d.ts.map +1 -0
- package/dist/lib/core/utility/strings.js +14 -0
- package/dist/lib/core/{utility.d.ts → utility/vector.d.ts} +1 -2
- package/dist/lib/core/utility/vector.d.ts.map +1 -0
- package/dist/lib/core/utility/vector.js +8 -0
- package/dist/lib/core/vector.d.ts +1 -0
- package/dist/lib/core/vector.d.ts.map +1 -0
- package/dist/lib/core/vessel.d.ts +4 -1
- package/dist/lib/core/vessel.d.ts.map +1 -0
- package/dist/lib/core/vessel.js +13 -9
- package/dist/lib/debug/console/console-state.d.ts +1 -0
- package/dist/lib/debug/console/console-state.d.ts.map +1 -0
- package/dist/lib/debug/console/console-store.d.ts +1 -0
- package/dist/lib/debug/console/console-store.d.ts.map +1 -0
- package/dist/lib/debug/debug-state.d.ts +1 -0
- package/dist/lib/debug/debug-state.d.ts.map +1 -0
- package/dist/lib/debug/debug-store.d.ts +1 -0
- package/dist/lib/debug/debug-store.d.ts.map +1 -0
- package/dist/lib/debug/state-based-debug-loader.d.ts +1 -0
- package/dist/lib/debug/state-based-debug-loader.d.ts.map +1 -0
- package/dist/lib/device/aspect-ratio.d.ts +38 -0
- package/dist/lib/device/aspect-ratio.d.ts.map +1 -0
- package/dist/lib/device/aspect-ratio.js +44 -0
- package/dist/lib/device/desktop.d.ts +1 -0
- package/dist/lib/device/desktop.d.ts.map +1 -0
- package/dist/lib/device/mobile.d.ts +1 -0
- package/dist/lib/device/mobile.d.ts.map +1 -0
- package/dist/lib/device/tablet.d.ts +1 -0
- package/dist/lib/device/tablet.d.ts.map +1 -0
- package/dist/lib/entities/actor.d.ts +1 -0
- package/dist/lib/entities/actor.d.ts.map +1 -0
- package/dist/lib/entities/box.d.ts +1 -0
- package/dist/lib/entities/box.d.ts.map +1 -0
- package/dist/lib/entities/builder.d.ts +1 -0
- package/dist/lib/entities/builder.d.ts.map +1 -0
- package/dist/lib/entities/create.d.ts +1 -0
- package/dist/lib/entities/create.d.ts.map +1 -0
- package/dist/lib/entities/delegates/animation.d.ts +1 -0
- package/dist/lib/entities/delegates/animation.d.ts.map +1 -0
- package/dist/lib/entities/delegates/debug.d.ts +1 -0
- package/dist/lib/entities/delegates/debug.d.ts.map +1 -0
- package/dist/lib/entities/delegates/loader.d.ts +1 -0
- package/dist/lib/entities/delegates/loader.d.ts.map +1 -0
- package/dist/lib/entities/destroy.d.ts +1 -0
- package/dist/lib/entities/destroy.d.ts.map +1 -0
- package/dist/lib/entities/entity.d.ts +4 -1
- package/dist/lib/entities/entity.d.ts.map +1 -0
- package/dist/lib/entities/entity.js +9 -5
- package/dist/lib/entities/index.d.ts +1 -0
- package/dist/lib/entities/index.d.ts.map +1 -0
- package/dist/lib/entities/plane.d.ts +1 -0
- package/dist/lib/entities/plane.d.ts.map +1 -0
- package/dist/lib/entities/rect.d.ts +1 -0
- package/dist/lib/entities/rect.d.ts.map +1 -0
- package/dist/lib/entities/sphere.d.ts +1 -0
- package/dist/lib/entities/sphere.d.ts.map +1 -0
- package/dist/lib/entities/sprite.d.ts +1 -0
- package/dist/lib/entities/sprite.d.ts.map +1 -0
- package/dist/lib/entities/text.d.ts +8 -0
- package/dist/lib/entities/text.d.ts.map +1 -0
- package/dist/lib/entities/text.js +77 -48
- package/dist/lib/entities/zone.d.ts +1 -0
- package/dist/lib/entities/zone.d.ts.map +1 -0
- package/dist/lib/game/game-blueprint.d.ts +38 -0
- package/dist/lib/game/game-blueprint.d.ts.map +1 -0
- package/dist/lib/game/game-canvas.d.ts +35 -0
- package/dist/lib/game/game-canvas.d.ts.map +1 -0
- package/dist/lib/game/game-canvas.js +57 -0
- package/dist/lib/game/game-config.d.ts +63 -0
- package/dist/lib/game/game-config.d.ts.map +1 -0
- package/dist/lib/game/game-config.js +79 -0
- package/dist/lib/game/game-default.d.ts +19 -0
- package/dist/lib/game/game-default.d.ts.map +1 -0
- package/dist/lib/game/game-default.js +24 -0
- package/dist/lib/game/game-interfaces.d.ts +3 -2
- package/dist/lib/game/game-interfaces.d.ts.map +1 -0
- package/dist/lib/game/game-retro-resolutions.d.ts +24 -0
- package/dist/lib/game/game-retro-resolutions.d.ts.map +1 -0
- package/dist/lib/game/game-retro-resolutions.js +81 -0
- package/dist/lib/game/game-state.d.ts +6 -5
- package/dist/lib/game/game-state.d.ts.map +1 -0
- package/dist/lib/game/game.d.ts +8 -12
- package/dist/lib/game/game.d.ts.map +1 -0
- package/dist/lib/game/game.js +44 -92
- package/dist/lib/game/zylem-game.d.ts +15 -3
- package/dist/lib/game/zylem-game.d.ts.map +1 -0
- package/dist/lib/game/zylem-game.js +67 -33
- package/dist/lib/graphics/geometries/XZPlaneGeometry.d.ts +1 -0
- package/dist/lib/graphics/geometries/XZPlaneGeometry.d.ts.map +1 -0
- package/dist/lib/graphics/material.d.ts +2 -1
- package/dist/lib/graphics/material.d.ts.map +1 -0
- package/dist/lib/graphics/material.js +1 -1
- package/dist/lib/graphics/mesh.d.ts +1 -0
- package/dist/lib/graphics/mesh.d.ts.map +1 -0
- package/dist/lib/graphics/render-pass.d.ts +1 -0
- package/dist/lib/graphics/render-pass.d.ts.map +1 -0
- package/dist/lib/graphics/zylem-scene.d.ts +8 -7
- package/dist/lib/graphics/zylem-scene.d.ts.map +1 -0
- package/dist/lib/graphics/zylem-scene.js +26 -40
- package/dist/lib/input/gamepad-provider.d.ts +1 -0
- package/dist/lib/input/gamepad-provider.d.ts.map +1 -0
- package/dist/lib/input/input-manager.d.ts +1 -0
- package/dist/lib/input/input-manager.d.ts.map +1 -0
- package/dist/lib/input/input-provider.d.ts +1 -0
- package/dist/lib/input/input-provider.d.ts.map +1 -0
- package/dist/lib/input/input.d.ts +1 -0
- package/dist/lib/input/input.d.ts.map +1 -0
- package/dist/lib/input/keyboard-provider.d.ts +1 -0
- package/dist/lib/input/keyboard-provider.d.ts.map +1 -0
- package/dist/lib/interfaces/entity.d.ts +1 -0
- package/dist/lib/interfaces/entity.d.ts.map +1 -0
- package/dist/lib/sounds/index.d.ts +1 -0
- package/dist/lib/sounds/index.d.ts.map +1 -0
- package/dist/lib/sounds/ping-pong-sound.d.ts +1 -0
- package/dist/lib/sounds/ping-pong-sound.d.ts.map +1 -0
- package/dist/lib/sounds/ricochet-sound.d.ts +1 -0
- package/dist/lib/sounds/ricochet-sound.d.ts.map +1 -0
- package/dist/lib/stage/debug-entity-cursor.d.ts +1 -0
- package/dist/lib/stage/debug-entity-cursor.d.ts.map +1 -0
- package/dist/lib/stage/entity-spawner.d.ts +1 -0
- package/dist/lib/stage/entity-spawner.d.ts.map +1 -0
- package/dist/lib/stage/stage-blueprint.d.ts +45 -0
- package/dist/lib/stage/stage-blueprint.d.ts.map +1 -0
- package/dist/lib/stage/stage-blueprint.js +56 -0
- package/dist/lib/stage/stage-camera-debug-delegate.d.ts +14 -0
- package/dist/lib/stage/stage-camera-debug-delegate.d.ts.map +1 -0
- package/dist/lib/stage/stage-debug-delegate.d.ts +1 -0
- package/dist/lib/stage/stage-debug-delegate.d.ts.map +1 -0
- package/dist/lib/stage/stage-default.d.ts +10 -0
- package/dist/lib/stage/stage-default.d.ts.map +1 -0
- package/dist/lib/stage/stage-default.js +42 -0
- package/dist/lib/stage/stage-state.d.ts +1 -0
- package/dist/lib/stage/stage-state.d.ts.map +1 -0
- package/dist/lib/stage/stage.d.ts +4 -3
- package/dist/lib/stage/stage.d.ts.map +1 -0
- package/dist/lib/stage/stage.js +27 -25
- package/dist/lib/stage/zylem-stage.d.ts +8 -4
- package/dist/lib/stage/zylem-stage.d.ts.map +1 -0
- package/dist/lib/stage/zylem-stage.js +36 -46
- package/dist/lib/systems/test-system.d.ts +1 -0
- package/dist/lib/systems/test-system.d.ts.map +1 -0
- package/dist/lib/systems/transformable.system.d.ts +1 -0
- package/dist/lib/systems/transformable.system.d.ts.map +1 -0
- package/dist/lib/types/entity-types.d.ts +1 -0
- package/dist/lib/types/entity-types.d.ts.map +1 -0
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/index.d.ts.map +1 -0
- package/dist/lib/types/stage-types.d.ts +1 -0
- package/dist/lib/types/stage-types.d.ts.map +1 -0
- package/dist/lib/ui/Debug.d.ts +1 -0
- package/dist/lib/ui/Debug.d.ts.map +1 -0
- package/dist/lib/ui/console/Console.d.ts +1 -0
- package/dist/lib/ui/console/Console.d.ts.map +1 -0
- package/dist/lib/ui/debug-panel/AccordionMenu.d.ts +1 -0
- package/dist/lib/ui/debug-panel/AccordionMenu.d.ts.map +1 -0
- package/dist/lib/ui/debug-panel/Menu.d.ts +1 -0
- package/dist/lib/ui/debug-panel/Menu.d.ts.map +1 -0
- package/dist/lib/ui/debug-panel/sections/EntitiesSection.d.ts +1 -0
- package/dist/lib/ui/debug-panel/sections/EntitiesSection.d.ts.map +1 -0
- package/dist/lib/ui/debug-panel/sections/GameSection.d.ts +1 -0
- package/dist/lib/ui/debug-panel/sections/GameSection.d.ts.map +1 -0
- package/dist/lib/ui/debug-panel/sections/StagesSection.d.ts +1 -0
- package/dist/lib/ui/debug-panel/sections/StagesSection.d.ts.map +1 -0
- package/dist/lib/ui/debug-panel/sections/all.d.ts +1 -0
- package/dist/lib/ui/debug-panel/sections/all.d.ts.map +1 -0
- package/dist/lib/ui/toolbar/Toolbar.d.ts +1 -0
- package/dist/lib/ui/toolbar/Toolbar.d.ts.map +1 -0
- package/dist/main.js +52 -50
- package/dist/stage.js +20 -4
- package/dist/tests/unit/collision/collision.spec.d.ts +2 -0
- package/dist/tests/unit/collision/collision.spec.d.ts.map +1 -0
- package/dist/tests/unit/core/game.spec.d.ts +2 -0
- package/dist/tests/unit/core/game.spec.d.ts.map +1 -0
- package/dist/tests/unit/core/stage.spec.d.ts +2 -0
- package/dist/tests/unit/core/stage.spec.d.ts.map +1 -0
- package/dist/tests/unit/core/vessel.spec.d.ts +2 -0
- package/dist/tests/unit/core/vessel.spec.d.ts.map +1 -0
- package/dist/tests/unit/stage/stage-blueprint.spec.d.ts +2 -0
- package/dist/tests/unit/stage/stage-blueprint.spec.d.ts.map +1 -0
- package/package.json +11 -9
- package/dist/actions.d.ts +0 -4
- package/dist/behaviors.d.ts +0 -3
- package/dist/camera.d.ts +0 -3
- package/dist/core.d.ts +0 -5
- package/dist/entities.d.ts +0 -8
- package/dist/lib/core/game-canvas.d.ts +0 -4
- package/dist/lib/core/utility.js +0 -20
- package/dist/main.d.ts +0 -30
- package/dist/stage.d.ts +0 -3
- package/dist/tests/collision/collision.spec.d.ts +0 -1
- package/dist/tests/core/game.spec.d.ts +0 -1
- package/dist/tests/core/stage.spec.d.ts +0 -1
- package/dist/tests/core/vessel.spec.d.ts +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type RetroResolution = {
|
|
2
|
+
key: string;
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
notes?: string;
|
|
6
|
+
};
|
|
7
|
+
export type RetroPreset = {
|
|
8
|
+
displayAspect: number;
|
|
9
|
+
resolutions: RetroResolution[];
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Retro and console display presets.
|
|
13
|
+
* displayAspect represents the intended display aspect (letterboxing target),
|
|
14
|
+
* not necessarily the raw pixel aspect of internal buffers.
|
|
15
|
+
*/
|
|
16
|
+
export declare const RetroPresets: Record<string, RetroPreset>;
|
|
17
|
+
export type RetroPresetKey = keyof typeof RetroPresets;
|
|
18
|
+
export declare function getDisplayAspect(preset: RetroPresetKey): number;
|
|
19
|
+
export declare function getPresetResolution(preset: RetroPresetKey, key?: string): RetroResolution | undefined;
|
|
20
|
+
export declare function parseResolution(text: string): {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
} | null;
|
|
24
|
+
//# sourceMappingURL=game-retro-resolutions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"game-retro-resolutions.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-retro-resolutions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7F,MAAM,MAAM,WAAW,GAAG;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,eAAe,EAAE,CAAC;CAC/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAuDpD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,YAAY,CAAC;AAEvD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAE/D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAKrG;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAStF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const n = {
|
|
2
|
+
NES: {
|
|
3
|
+
displayAspect: 1.3333333333333333,
|
|
4
|
+
resolutions: [
|
|
5
|
+
{ key: "256x240", width: 256, height: 240, notes: "Standard NTSC; effective 240p." }
|
|
6
|
+
]
|
|
7
|
+
},
|
|
8
|
+
SNES: {
|
|
9
|
+
displayAspect: 1.3333333333333333,
|
|
10
|
+
resolutions: [
|
|
11
|
+
{ key: "256x224", width: 256, height: 224, notes: "Common 240p-equivalent mode." },
|
|
12
|
+
{ key: "512x448", width: 512, height: 448, notes: "Hi-res interlaced (480i)." }
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
N64: {
|
|
16
|
+
displayAspect: 1.3333333333333333,
|
|
17
|
+
resolutions: [
|
|
18
|
+
{ key: "320x240", width: 320, height: 240, notes: "Common 240p mode." },
|
|
19
|
+
{ key: "640x480", width: 640, height: 480, notes: "Higher resolution (480i)." }
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
PS1: {
|
|
23
|
+
displayAspect: 1.3333333333333333,
|
|
24
|
+
resolutions: [
|
|
25
|
+
{ key: "320x240", width: 320, height: 240, notes: "Progressive 240p common." },
|
|
26
|
+
{ key: "640x480", width: 640, height: 480, notes: "Interlaced 480i for higher detail." }
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
PS2: {
|
|
30
|
+
displayAspect: 1.3333333333333333,
|
|
31
|
+
resolutions: [
|
|
32
|
+
{ key: "640x480", width: 640, height: 480, notes: "480i/480p baseline." },
|
|
33
|
+
{ key: "720x480", width: 720, height: 480, notes: "480p (widescreen capable in some titles)." },
|
|
34
|
+
{ key: "1280x720", width: 1280, height: 720, notes: "720p (select titles)." }
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
PS5: {
|
|
38
|
+
displayAspect: 1.7777777777777777,
|
|
39
|
+
resolutions: [
|
|
40
|
+
{ key: "720x480", width: 720, height: 480, notes: "Legacy compatibility." },
|
|
41
|
+
{ key: "1280x720", width: 1280, height: 720, notes: "720p." },
|
|
42
|
+
{ key: "1920x1080", width: 1920, height: 1080, notes: "1080p." },
|
|
43
|
+
{ key: "2560x1440", width: 2560, height: 1440, notes: "1440p." },
|
|
44
|
+
{ key: "3840x2160", width: 3840, height: 2160, notes: "4K (up to 120Hz)." },
|
|
45
|
+
{ key: "7680x4320", width: 7680, height: 4320, notes: "8K (limited)." }
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
XboxOne: {
|
|
49
|
+
displayAspect: 1.7777777777777777,
|
|
50
|
+
resolutions: [
|
|
51
|
+
{ key: "1280x720", width: 1280, height: 720, notes: "720p (original)." },
|
|
52
|
+
{ key: "1920x1080", width: 1920, height: 1080, notes: "1080p (original)." },
|
|
53
|
+
{ key: "3840x2160", width: 3840, height: 2160, notes: "4K UHD (S/X models)." }
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
function h(e) {
|
|
58
|
+
return n[e].displayAspect;
|
|
59
|
+
}
|
|
60
|
+
function r(e, o) {
|
|
61
|
+
const t = n[e]?.resolutions || [];
|
|
62
|
+
if (!o)
|
|
63
|
+
return t[0];
|
|
64
|
+
const i = o.toLowerCase().replace(/\s+/g, "").replace("×", "x");
|
|
65
|
+
return t.find((s) => s.key.toLowerCase() === i);
|
|
66
|
+
}
|
|
67
|
+
function l(e) {
|
|
68
|
+
if (!e)
|
|
69
|
+
return null;
|
|
70
|
+
const t = String(e).toLowerCase().trim().replace(/\s+/g, "").replace("×", "x").match(/^(\d+)x(\d+)$/);
|
|
71
|
+
if (!t)
|
|
72
|
+
return null;
|
|
73
|
+
const i = parseInt(t[1], 10), s = parseInt(t[2], 10);
|
|
74
|
+
return !Number.isFinite(i) || !Number.isFinite(s) ? null : { width: i, height: s };
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
n as RetroPresets,
|
|
78
|
+
h as getDisplayAspect,
|
|
79
|
+
r as getPresetResolution,
|
|
80
|
+
l as parseResolution
|
|
81
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseGlobals } from './game-interfaces';
|
|
2
2
|
declare const state: {
|
|
3
3
|
id: string;
|
|
4
|
-
globals:
|
|
4
|
+
globals: BaseGlobals;
|
|
5
5
|
time: number;
|
|
6
6
|
};
|
|
7
|
-
export declare function setGlobalState<TGlobals extends
|
|
8
|
-
export declare function getGlobalState<TGlobals extends
|
|
9
|
-
export declare function getGlobalState<TGlobals extends
|
|
7
|
+
export declare function setGlobalState<TGlobals extends BaseGlobals, K extends keyof TGlobals = keyof TGlobals>(key: K, value: TGlobals[K]): void;
|
|
8
|
+
export declare function getGlobalState<TGlobals extends BaseGlobals>(): TGlobals;
|
|
9
|
+
export declare function getGlobalState<TGlobals extends BaseGlobals, K extends keyof TGlobals = keyof TGlobals>(key: K): TGlobals[K];
|
|
10
10
|
export { state };
|
|
11
|
+
//# sourceMappingURL=game-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"game-state.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAc,MAAM,mBAAmB,CAAC;AAE5D,QAAA,MAAM,KAAK;;aAEK,WAAW;;CAEzB,CAAC;AAEH,wBAAgB,cAAc,CAC7B,QAAQ,SAAS,WAAW,EAC5B,CAAC,SAAS,MAAM,QAAQ,GAAG,MAAM,QAAQ,EACxC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAMpC,wBAAgB,cAAc,CAAC,QAAQ,SAAS,WAAW,KAAK,QAAQ,CAAC;AAEzE,wBAAgB,cAAc,CAC7B,QAAQ,SAAS,WAAW,EAC5B,CAAC,SAAS,MAAM,QAAQ,GAAG,MAAM,QAAQ,EACxC,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AASvB,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
package/dist/lib/game/game.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { BaseNode } from '../core/base-node';
|
|
2
1
|
import { ZylemGame } from './zylem-game';
|
|
3
|
-
import { Stage } from '../stage/stage';
|
|
4
2
|
import { DestroyFunction, IGame, SetupFunction, UpdateFunction } from '../core/base-node-life-cycle';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
export declare class Game<TGlobals extends
|
|
8
|
-
|
|
9
|
-
options: GameOptions<TGlobals>;
|
|
3
|
+
import { BaseGlobals } from './game-interfaces';
|
|
4
|
+
import { GameOptions } from '../core/utility/nodes';
|
|
5
|
+
export declare class Game<TGlobals extends BaseGlobals> implements IGame<TGlobals> {
|
|
6
|
+
private wrappedGame;
|
|
10
7
|
private pendingGlobalChangeHandlers;
|
|
8
|
+
options: GameOptions<TGlobals>;
|
|
11
9
|
update: UpdateFunction<ZylemGame<TGlobals>, TGlobals>;
|
|
12
10
|
setup: SetupFunction<ZylemGame<TGlobals>, TGlobals>;
|
|
13
11
|
destroy: DestroyFunction<ZylemGame<TGlobals>, TGlobals>;
|
|
14
12
|
refErrorMessage: string;
|
|
15
13
|
constructor(options: GameOptions<TGlobals>);
|
|
16
14
|
start(): Promise<this>;
|
|
17
|
-
load
|
|
15
|
+
private load;
|
|
18
16
|
setOverrides(): void;
|
|
19
17
|
pause(): Promise<void>;
|
|
20
18
|
resume(): Promise<void>;
|
|
@@ -23,12 +21,10 @@ export declare class Game<TGlobals extends Record<string, BasicTypes> = GlobalVa
|
|
|
23
21
|
previousStage(): Promise<void>;
|
|
24
22
|
goToStage(): Promise<void>;
|
|
25
23
|
end(): Promise<void>;
|
|
26
|
-
add(...inputs: Array<Stage | Promise<any> | (() => Stage | Promise<any>)>): this;
|
|
27
24
|
getGlobal<K extends keyof TGlobals>(key: K): TGlobals[K];
|
|
28
25
|
setGlobal<K extends keyof TGlobals>(key: K, value: TGlobals[K]): void;
|
|
29
26
|
onGlobalChange<K extends keyof TGlobals>(key: K, callback: (value: TGlobals[K]) => void): void;
|
|
30
27
|
}
|
|
31
|
-
type GameOptions<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType> = Array<ZylemGameConfig<Stage, Game<TGlobals>, TGlobals> | Stage | GameEntityLifeCycle | BaseNode>;
|
|
32
28
|
/**
|
|
33
29
|
* create a new game
|
|
34
30
|
* @param options GameOptions - Array of IGameOptions, Stage, GameEntity, or BaseNode objects
|
|
@@ -37,5 +33,5 @@ type GameOptions<TGlobals extends Record<string, BasicTypes> = GlobalVariablesTy
|
|
|
37
33
|
* @param options.stages Array of stage objects (when using IGameOptions)
|
|
38
34
|
* @returns Game
|
|
39
35
|
*/
|
|
40
|
-
export declare function
|
|
41
|
-
|
|
36
|
+
export declare function createGame<TGlobals extends BaseGlobals>(...options: GameOptions<TGlobals>): Game<TGlobals>;
|
|
37
|
+
//# sourceMappingURL=game.d.ts.map
|
|
@@ -0,0 +1 @@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AAE,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI;CAOvF;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,QAAQ,SAAS,WAAW,EAAE,GAAG,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAE1G"}
|
package/dist/lib/game/game.js
CHANGED
|
@@ -1,40 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
globals: {},
|
|
10
|
-
stages: [
|
|
11
|
-
l()
|
|
12
|
-
]
|
|
13
|
-
};
|
|
14
|
-
function d(n) {
|
|
15
|
-
let e = { ...f };
|
|
16
|
-
const t = [], s = [], a = [];
|
|
17
|
-
return Object.values(n).forEach((i) => {
|
|
18
|
-
if (i instanceof o)
|
|
19
|
-
s.push(i);
|
|
20
|
-
else if (i instanceof u)
|
|
21
|
-
a.push(i);
|
|
22
|
-
else if (i instanceof h)
|
|
23
|
-
a.push(i);
|
|
24
|
-
else if (i.constructor.name === "Object" && typeof i == "object") {
|
|
25
|
-
const g = Object.assign(f, { ...i });
|
|
26
|
-
t.push(g);
|
|
27
|
-
}
|
|
28
|
-
}), t.forEach((i) => {
|
|
29
|
-
e = Object.assign(e, { ...i });
|
|
30
|
-
}), s.forEach((i) => {
|
|
31
|
-
i.addEntities(a);
|
|
32
|
-
}), s.length ? e.stages = s : e.stages[0].addEntities(a), e;
|
|
33
|
-
}
|
|
34
|
-
class R {
|
|
35
|
-
gameRef = null;
|
|
36
|
-
options;
|
|
1
|
+
import { ZylemGame as n } from "./zylem-game.js";
|
|
2
|
+
import { setPaused as o } from "../debug/debug-state.js";
|
|
3
|
+
import { getGlobalState as i, setGlobalState as p } from "./game-state.js";
|
|
4
|
+
import { hasStages as d, convertNodes as l } from "../core/utility/nodes.js";
|
|
5
|
+
import { resolveGameConfig as h } from "./game-config.js";
|
|
6
|
+
import { stage as g } from "../stage/stage.js";
|
|
7
|
+
class m {
|
|
8
|
+
wrappedGame = null;
|
|
37
9
|
pendingGlobalChangeHandlers = [];
|
|
10
|
+
options;
|
|
38
11
|
update = () => {
|
|
39
12
|
};
|
|
40
13
|
setup = () => {
|
|
@@ -43,115 +16,94 @@ class R {
|
|
|
43
16
|
};
|
|
44
17
|
refErrorMessage = "lost reference to game";
|
|
45
18
|
constructor(e) {
|
|
46
|
-
this.options = e;
|
|
19
|
+
this.options = e, d(e) || this.options.push(g());
|
|
47
20
|
}
|
|
48
21
|
async start() {
|
|
49
22
|
const e = await this.load();
|
|
50
|
-
return this.
|
|
23
|
+
return this.wrappedGame = e, this.setOverrides(), e.start(), this;
|
|
51
24
|
}
|
|
52
25
|
async load() {
|
|
53
26
|
console.log("loading game", this.options);
|
|
54
|
-
const e =
|
|
27
|
+
const e = await l(this.options), a = h(e), t = new n({
|
|
28
|
+
...e,
|
|
29
|
+
...a
|
|
30
|
+
}, this);
|
|
55
31
|
return await t.loadStage(e.stages[0]), t;
|
|
56
32
|
}
|
|
57
33
|
setOverrides() {
|
|
58
|
-
if (!this.
|
|
34
|
+
if (!this.wrappedGame) {
|
|
59
35
|
console.error(this.refErrorMessage);
|
|
60
36
|
return;
|
|
61
37
|
}
|
|
62
|
-
if (this.
|
|
63
|
-
for (const { key: e, callback:
|
|
64
|
-
this.
|
|
38
|
+
if (this.wrappedGame.customSetup = this.setup, this.wrappedGame.customUpdate = this.update, this.wrappedGame.customDestroy = this.destroy, this.pendingGlobalChangeHandlers.length) {
|
|
39
|
+
for (const { key: e, callback: a } of this.pendingGlobalChangeHandlers)
|
|
40
|
+
this.wrappedGame.onGlobalChange(e, a);
|
|
65
41
|
this.pendingGlobalChangeHandlers = [];
|
|
66
42
|
}
|
|
67
43
|
}
|
|
68
44
|
async pause() {
|
|
69
|
-
|
|
45
|
+
o(!0);
|
|
70
46
|
}
|
|
71
47
|
async resume() {
|
|
72
|
-
|
|
48
|
+
o(!1), this.wrappedGame && (this.wrappedGame.previousTimeStamp = 0, this.wrappedGame.timer.reset());
|
|
73
49
|
}
|
|
74
50
|
async reset() {
|
|
75
|
-
if (!this.
|
|
51
|
+
if (!this.wrappedGame) {
|
|
76
52
|
console.error(this.refErrorMessage);
|
|
77
53
|
return;
|
|
78
54
|
}
|
|
79
|
-
await this.
|
|
55
|
+
await this.wrappedGame.loadStage(this.wrappedGame.stages[0]);
|
|
80
56
|
}
|
|
81
57
|
async nextStage() {
|
|
82
|
-
if (!this.
|
|
58
|
+
if (!this.wrappedGame) {
|
|
83
59
|
console.error(this.refErrorMessage);
|
|
84
60
|
return;
|
|
85
61
|
}
|
|
86
|
-
const e = this.
|
|
87
|
-
if (!
|
|
62
|
+
const e = this.wrappedGame.currentStageId, a = this.wrappedGame.stages.findIndex((r) => r.wrappedStage.uuid === e), t = this.wrappedGame.stages[a + 1];
|
|
63
|
+
if (!t) {
|
|
88
64
|
console.error("next stage called on last stage");
|
|
89
65
|
return;
|
|
90
66
|
}
|
|
91
|
-
await this.
|
|
67
|
+
await this.wrappedGame.loadStage(t);
|
|
92
68
|
}
|
|
93
69
|
async previousStage() {
|
|
94
|
-
if (!this.
|
|
70
|
+
if (!this.wrappedGame) {
|
|
95
71
|
console.error(this.refErrorMessage);
|
|
96
72
|
return;
|
|
97
73
|
}
|
|
98
|
-
const e = this.
|
|
99
|
-
if (!
|
|
74
|
+
const e = this.wrappedGame.currentStageId, a = this.wrappedGame.stages.findIndex((r) => r.wrappedStage.uuid === e), t = this.wrappedGame.stages[a - 1];
|
|
75
|
+
if (!t) {
|
|
100
76
|
console.error("previous stage called on first stage");
|
|
101
77
|
return;
|
|
102
78
|
}
|
|
103
|
-
await this.
|
|
79
|
+
await this.wrappedGame.loadStage(t);
|
|
104
80
|
}
|
|
105
81
|
async goToStage() {
|
|
106
82
|
}
|
|
107
83
|
async end() {
|
|
108
84
|
}
|
|
109
|
-
add(...e) {
|
|
110
|
-
for (const t of e)
|
|
111
|
-
if (t) {
|
|
112
|
-
if (t instanceof o) {
|
|
113
|
-
this.gameRef ? (this.gameRef.stages.push(t), this.gameRef.stageMap.set(t.stageRef.uuid, t)) : this.options.push(t);
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
if (typeof t == "function") {
|
|
117
|
-
try {
|
|
118
|
-
const s = t();
|
|
119
|
-
s instanceof o ? this.gameRef ? (this.gameRef.stages.push(s), this.gameRef.stageMap.set(s.stageRef.uuid, s)) : this.options.push(s) : s && typeof s.then == "function" && s.then((a) => {
|
|
120
|
-
a instanceof o && (this.gameRef ? (this.gameRef.stages.push(a), this.gameRef.stageMap.set(a.stageRef.uuid, a)) : this.options.push(a));
|
|
121
|
-
}).catch((a) => console.error("Failed to add async stage", a));
|
|
122
|
-
} catch (s) {
|
|
123
|
-
console.error("Error executing stage factory", s);
|
|
124
|
-
}
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
t && typeof t.then == "function" && t.then((s) => {
|
|
128
|
-
s instanceof o && (this.gameRef ? (this.gameRef.stages.push(s), this.gameRef.stageMap.set(s.stageRef.uuid, s)) : this.options.push(s));
|
|
129
|
-
}).catch((s) => console.error("Failed to add async stage", s));
|
|
130
|
-
}
|
|
131
|
-
return this;
|
|
132
|
-
}
|
|
133
85
|
getGlobal(e) {
|
|
134
|
-
return this.
|
|
86
|
+
return this.wrappedGame ? this.wrappedGame.getGlobal(e) : i(e);
|
|
135
87
|
}
|
|
136
|
-
setGlobal(e,
|
|
137
|
-
if (this.
|
|
138
|
-
this.
|
|
88
|
+
setGlobal(e, a) {
|
|
89
|
+
if (this.wrappedGame) {
|
|
90
|
+
this.wrappedGame.setGlobal(e, a);
|
|
139
91
|
return;
|
|
140
92
|
}
|
|
141
|
-
p(e,
|
|
93
|
+
p(e, a);
|
|
142
94
|
}
|
|
143
|
-
onGlobalChange(e,
|
|
144
|
-
if (this.
|
|
145
|
-
this.
|
|
95
|
+
onGlobalChange(e, a) {
|
|
96
|
+
if (this.wrappedGame) {
|
|
97
|
+
this.wrappedGame.onGlobalChange(e, a);
|
|
146
98
|
return;
|
|
147
99
|
}
|
|
148
|
-
this.pendingGlobalChangeHandlers.push({ key: e, callback:
|
|
100
|
+
this.pendingGlobalChangeHandlers.push({ key: e, callback: a });
|
|
149
101
|
}
|
|
150
102
|
}
|
|
151
|
-
function
|
|
152
|
-
return new
|
|
103
|
+
function b(...s) {
|
|
104
|
+
return new m(s);
|
|
153
105
|
}
|
|
154
106
|
export {
|
|
155
|
-
|
|
156
|
-
|
|
107
|
+
m as Game,
|
|
108
|
+
b as createGame
|
|
157
109
|
};
|
|
@@ -4,8 +4,12 @@ import { InputManager } from '../input/input-manager';
|
|
|
4
4
|
import { Timer } from '../core/three-addons/Timer';
|
|
5
5
|
import { ZylemCamera } from '~/lib/camera/zylem-camera';
|
|
6
6
|
import { Stage } from '../stage/stage';
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import { BaseGlobals, ZylemGameConfig } from './game-interfaces';
|
|
8
|
+
import { GameConfig } from './game-config';
|
|
9
|
+
import { AspectRatioDelegate } from '../device/aspect-ratio';
|
|
10
|
+
import { GameCanvas } from './game-canvas';
|
|
11
|
+
type ZylemGameOptions<TGlobals extends BaseGlobals> = ZylemGameConfig<Stage, ZylemGame<TGlobals>, TGlobals> & Partial<GameConfig>;
|
|
12
|
+
export declare class ZylemGame<TGlobals extends BaseGlobals> {
|
|
9
13
|
id: string;
|
|
10
14
|
initialGlobals: TGlobals;
|
|
11
15
|
customSetup: ((params: SetupContext<ZylemGame<TGlobals>, TGlobals>) => void) | null;
|
|
@@ -26,10 +30,17 @@ export declare class ZylemGame<TGlobals extends Record<string, BasicTypes> = Glo
|
|
|
26
30
|
dom: HTMLElement;
|
|
27
31
|
} | null;
|
|
28
32
|
defaultCamera: ZylemCamera | null;
|
|
33
|
+
container: HTMLElement | null;
|
|
34
|
+
canvas: HTMLCanvasElement | null;
|
|
35
|
+
aspectRatioDelegate: AspectRatioDelegate | null;
|
|
36
|
+
resolvedConfig: GameConfig | null;
|
|
37
|
+
gameCanvas: GameCanvas | null;
|
|
29
38
|
static FRAME_LIMIT: number;
|
|
30
39
|
static FRAME_DURATION: number;
|
|
31
40
|
static MAX_DELTA_SECONDS: number;
|
|
32
|
-
constructor(options:
|
|
41
|
+
constructor(options: ZylemGameOptions<TGlobals>, wrapperRef: Game<TGlobals>);
|
|
42
|
+
loadGameCanvas(config: GameConfig): void;
|
|
43
|
+
loadDebugOptions(options: ZylemGameOptions<TGlobals>): void;
|
|
33
44
|
loadStage(stage: Stage): Promise<void>;
|
|
34
45
|
unloadCurrentStage(): void;
|
|
35
46
|
setGlobals(options: ZylemGameConfig<Stage, ZylemGame<TGlobals>, TGlobals>): void;
|
|
@@ -44,3 +55,4 @@ export declare class ZylemGame<TGlobals extends Record<string, BasicTypes> = Glo
|
|
|
44
55
|
onGlobalChange<K extends keyof TGlobals>(key: K, callback: (value: TGlobals[K]) => void): void;
|
|
45
56
|
}
|
|
46
57
|
export default ZylemGame;
|
|
58
|
+
//# sourceMappingURL=zylem-game.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zylem-game.d.ts","sourceRoot":"","sources":["../../../src/lib/game/zylem-game.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;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AAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI;CAUvF;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { state as
|
|
2
|
-
import { setDebugFlag as
|
|
3
|
-
import { InputManager as
|
|
4
|
-
import { Timer as
|
|
5
|
-
import {
|
|
6
|
-
import f from "
|
|
7
|
-
|
|
1
|
+
import { state as o, getGlobalState as r, setGlobalState as d } from "./game-state.js";
|
|
2
|
+
import { setDebugFlag as h, isPaused as m } from "../debug/debug-state.js";
|
|
3
|
+
import { InputManager as c } from "../input/input-manager.js";
|
|
4
|
+
import { Timer as p } from "../core/three-addons/Timer.js";
|
|
5
|
+
import { resolveGameConfig as g } from "./game-config.js";
|
|
6
|
+
import { GameCanvas as f } from "./game-canvas.js";
|
|
7
|
+
import { subscribe as S } from "valtio/vanilla";
|
|
8
|
+
import b from "stats.js";
|
|
9
|
+
class n {
|
|
8
10
|
id;
|
|
9
11
|
initialGlobals = {};
|
|
10
12
|
customSetup = null;
|
|
@@ -20,27 +22,59 @@ class l {
|
|
|
20
22
|
wrapperRef;
|
|
21
23
|
statsRef = null;
|
|
22
24
|
defaultCamera = null;
|
|
25
|
+
container = null;
|
|
26
|
+
canvas = null;
|
|
27
|
+
aspectRatioDelegate = null;
|
|
28
|
+
resolvedConfig = null;
|
|
29
|
+
gameCanvas = null;
|
|
23
30
|
static FRAME_LIMIT = 120;
|
|
24
|
-
static FRAME_DURATION = 1e3 /
|
|
31
|
+
static FRAME_DURATION = 1e3 / n.FRAME_LIMIT;
|
|
25
32
|
static MAX_DELTA_SECONDS = 1 / 30;
|
|
26
33
|
constructor(t, e) {
|
|
27
|
-
this.wrapperRef = e, this.inputManager = new
|
|
34
|
+
this.wrapperRef = e, this.inputManager = new c(t.input), this.timer = new p(), this.timer.connect(document);
|
|
35
|
+
const a = g(t);
|
|
36
|
+
this.id = a.id, this.stages = a.stages || [], this.container = a.container, this.canvas = a.canvas ?? null, this.resolvedConfig = a, this.loadGameCanvas(a), this.loadDebugOptions(t), this.setGlobals(t);
|
|
37
|
+
}
|
|
38
|
+
loadGameCanvas(t) {
|
|
39
|
+
this.gameCanvas = new f({
|
|
40
|
+
id: t.id,
|
|
41
|
+
container: t.container,
|
|
42
|
+
containerId: t.containerId,
|
|
43
|
+
canvas: this.canvas ?? void 0,
|
|
44
|
+
bodyBackground: t.bodyBackground,
|
|
45
|
+
fullscreen: t.fullscreen,
|
|
46
|
+
aspectRatio: t.aspectRatio
|
|
47
|
+
}), this.gameCanvas.applyBodyBackground(), this.gameCanvas.mountCanvas(), this.gameCanvas.centerIfFullscreen();
|
|
48
|
+
}
|
|
49
|
+
loadDebugOptions(t) {
|
|
50
|
+
h(!!t.debug), t.debug && (this.statsRef = new b(), this.statsRef.showPanel(0), this.statsRef.dom.style.position = "absolute", this.statsRef.dom.style.bottom = "0", this.statsRef.dom.style.right = "0", this.statsRef.dom.style.top = "auto", this.statsRef.dom.style.left = "auto", document.body.appendChild(this.statsRef.dom));
|
|
28
51
|
}
|
|
29
52
|
async loadStage(t) {
|
|
30
53
|
this.unloadCurrentStage();
|
|
31
54
|
const e = t.options[0];
|
|
32
|
-
await t.load(this.id, e?.camera), this.stageMap.set(t.
|
|
55
|
+
if (await t.load(this.id, e?.camera), this.stageMap.set(t.wrappedStage.uuid, t), this.currentStageId = t.wrappedStage.uuid, this.defaultCamera = t.wrappedStage.cameraRef, this.container && this.defaultCamera) {
|
|
56
|
+
const a = this.defaultCamera.getDomElement(), s = this.resolvedConfig?.internalResolution;
|
|
57
|
+
this.gameCanvas?.mountRenderer(a, (i, l) => {
|
|
58
|
+
if (this.defaultCamera)
|
|
59
|
+
if (s)
|
|
60
|
+
this.defaultCamera.setPixelRatio(1), this.defaultCamera.resize(s.width, s.height);
|
|
61
|
+
else {
|
|
62
|
+
const u = window.devicePixelRatio || 1;
|
|
63
|
+
this.defaultCamera.setPixelRatio(u), this.defaultCamera.resize(i, l);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
33
67
|
}
|
|
34
68
|
unloadCurrentStage() {
|
|
35
69
|
if (!this.currentStageId)
|
|
36
70
|
return;
|
|
37
71
|
const t = this.getStage(this.currentStageId);
|
|
38
72
|
if (t) {
|
|
39
|
-
if (t?.
|
|
73
|
+
if (t?.wrappedStage)
|
|
40
74
|
try {
|
|
41
|
-
t.
|
|
42
|
-
me: t.
|
|
43
|
-
globals:
|
|
75
|
+
t.wrappedStage.nodeDestroy({
|
|
76
|
+
me: t.wrappedStage,
|
|
77
|
+
globals: o.globals
|
|
44
78
|
});
|
|
45
79
|
} catch (e) {
|
|
46
80
|
console.error("Failed to destroy previous stage", e);
|
|
@@ -49,37 +83,37 @@ class l {
|
|
|
49
83
|
}
|
|
50
84
|
}
|
|
51
85
|
setGlobals(t) {
|
|
52
|
-
|
|
86
|
+
this.initialGlobals = { ...t.globals };
|
|
53
87
|
for (const e in this.initialGlobals) {
|
|
54
|
-
const
|
|
55
|
-
|
|
88
|
+
const a = this.initialGlobals[e];
|
|
89
|
+
a === void 0 && console.error(`global ${e} is undefined`), this.setGlobal(e, a);
|
|
56
90
|
}
|
|
57
91
|
}
|
|
58
92
|
params() {
|
|
59
|
-
const t = this.currentStage(), e = this.timer.getDelta(),
|
|
93
|
+
const t = this.currentStage(), e = this.timer.getDelta(), a = this.inputManager.getInputs(e), s = t?.wrappedStage?.cameraRef || this.defaultCamera;
|
|
60
94
|
return {
|
|
61
95
|
delta: e,
|
|
62
|
-
inputs:
|
|
63
|
-
globals:
|
|
96
|
+
inputs: a,
|
|
97
|
+
globals: o.globals,
|
|
64
98
|
me: this,
|
|
65
|
-
camera:
|
|
99
|
+
camera: s
|
|
66
100
|
};
|
|
67
101
|
}
|
|
68
102
|
start() {
|
|
69
103
|
const t = this.currentStage(), e = this.params();
|
|
70
|
-
t.start({ ...e, me: t.
|
|
104
|
+
t.start({ ...e, me: t.wrappedStage }), this.customSetup && this.customSetup(e), this.loop(0);
|
|
71
105
|
}
|
|
72
106
|
loop(t) {
|
|
73
|
-
if (this.statsRef && this.statsRef.begin(), !
|
|
107
|
+
if (this.statsRef && this.statsRef.begin(), !m()) {
|
|
74
108
|
this.timer.update(t);
|
|
75
|
-
const e = this.currentStage(),
|
|
76
|
-
this.customUpdate && this.customUpdate(
|
|
109
|
+
const e = this.currentStage(), a = this.params(), s = Math.min(a.delta, n.MAX_DELTA_SECONDS), i = { ...a, delta: s };
|
|
110
|
+
this.customUpdate && this.customUpdate(i), e && e.wrappedStage.nodeUpdate({ ...i, me: e.wrappedStage }), this.totalTime += i.delta, o.time = this.totalTime, this.previousTimeStamp = t;
|
|
77
111
|
}
|
|
78
112
|
this.statsRef && this.statsRef.end(), this.outOfLoop(), requestAnimationFrame(this.loop.bind(this));
|
|
79
113
|
}
|
|
80
114
|
outOfLoop() {
|
|
81
115
|
const t = this.currentStage();
|
|
82
|
-
t && t.
|
|
116
|
+
t && t.wrappedStage.outOfLoop();
|
|
83
117
|
}
|
|
84
118
|
getStage(t) {
|
|
85
119
|
return this.stageMap.get(t);
|
|
@@ -91,17 +125,17 @@ class l {
|
|
|
91
125
|
return r(t);
|
|
92
126
|
}
|
|
93
127
|
setGlobal(t, e) {
|
|
94
|
-
|
|
128
|
+
d(t, e);
|
|
95
129
|
}
|
|
96
130
|
onGlobalChange(t, e) {
|
|
97
|
-
let
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
131
|
+
let a = r(t);
|
|
132
|
+
S(o, () => {
|
|
133
|
+
const s = r(t);
|
|
134
|
+
s !== a && (a = s, e(s));
|
|
101
135
|
});
|
|
102
136
|
}
|
|
103
137
|
}
|
|
104
138
|
export {
|
|
105
|
-
|
|
106
|
-
|
|
139
|
+
n as ZylemGame,
|
|
140
|
+
n as default
|
|
107
141
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XZPlaneGeometry.d.ts","sourceRoot":"","sources":["../../../../src/lib/graphics/geometries/XZPlaneGeometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAA0B,MAAM,OAAO,CAAC;AAE/D,cAAM,eAAgB,SAAQ,cAAc;gBAE/B,KAAK,SAAI,EAAE,MAAM,SAAI,EAAE,aAAa,SAAI,EAAE,cAAc,SAAI;IAwExE,IAAI,CAAC,MAAM,KAAA;IASX,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAA;CAIpB;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Color, Material, Vector2 } from 'three';
|
|
2
|
-
import { shortHash } from '../core/utility';
|
|
2
|
+
import { shortHash } from '../core/utility/strings';
|
|
3
3
|
import { ZylemShaderType } from '../core/preset-shader';
|
|
4
4
|
export interface MaterialOptions {
|
|
5
5
|
path?: string;
|
|
@@ -26,3 +26,4 @@ export declare class MaterialBuilder {
|
|
|
26
26
|
setShader(customShader: ZylemShaderType): void;
|
|
27
27
|
}
|
|
28
28
|
export {};
|
|
29
|
+
//# sourceMappingURL=material.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"material.d.ts","sourceRoot":"","sources":["../../../src/lib/graphics/material.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,EACL,QAAQ,EAMR,OAAO,EAEP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAmB,MAAM,yBAAyB,CAAC;AACrE,OAAkB,EAAqB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEtF,MAAM,WAAW,eAAe;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC;CACd;AAED,KAAK,gBAAgB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5C,UAAU,sBAAsB;IAC/B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAE7C,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;AAExC,qBAAa,eAAe;IAC3B,MAAM,CAAC,gBAAgB,EAAE,GAAG,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAa;IAE3E,SAAS,EAAE,QAAQ,EAAE,CAAM;IAE3B,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,UAAU,EAAE,MAAM;IAmB7D,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,UAAU,EAAE,MAAM;IAWjE,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAK7B,UAAU,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI;IAKvC,UAAU,CAAC,WAAW,GAAE,WAAkB,EAAE,MAAM,GAAE,OAA2B;IAerF,QAAQ,CAAC,KAAK,EAAE,KAAK;IAWrB,SAAS,CAAC,YAAY,EAAE,eAAe;CAgBvC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Color as n, Vector2 as m, TextureLoader as c, RepeatWrapping as o, MeshPhongMaterial as p, MeshStandardMaterial as u, ShaderMaterial as f, Vector3 as d } from "three";
|
|
2
|
-
import { shortHash as M, sortedStringify as w } from "../core/utility.js";
|
|
2
|
+
import { shortHash as M, sortedStringify as w } from "../core/utility/strings.js";
|
|
3
3
|
import h from "../core/preset-shader.js";
|
|
4
4
|
class i {
|
|
5
5
|
static batchMaterialMap = /* @__PURE__ */ new Map();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh.d.ts","sourceRoot":"","sources":["../../../src/lib/graphics/mesh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC;AAE1F,qBAAa,WAAW;IAEvB,MAAM,CAAC,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI;IAY9F,UAAU,IAAI,IAAI;CAGlB"}
|