@zylem/game-lib 0.5.0 → 0.6.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 +23 -41
- package/dist/actions.d.ts +25 -0
- package/dist/actions.js +287 -8
- package/dist/actions.js.map +1 -0
- package/dist/behaviors.d.ts +106 -0
- package/dist/behaviors.js +396 -6
- package/dist/behaviors.js.map +1 -0
- package/dist/blueprints-BOCc3Wve.d.ts +26 -0
- package/dist/{src/lib/camera/zylem-camera.d.ts → camera-CpbDr4-V.d.ts} +48 -27
- package/dist/camera.d.ts +5 -0
- package/dist/camera.js +608 -4
- package/dist/camera.js.map +1 -0
- package/dist/core-CZhozNRH.d.ts +466 -0
- package/dist/core.d.ts +10 -0
- package/dist/core.js +5761 -9
- package/dist/core.js.map +1 -0
- package/dist/entities-BAxfJOkk.d.ts +307 -0
- package/dist/entities.d.ts +6 -0
- package/dist/entities.js +2284 -17
- package/dist/entities.js.map +1 -0
- package/dist/{src/lib/interfaces/entity.d.ts → entity-Bq_eNEDI.d.ts} +8 -6
- package/dist/entity-COvRtFNG.d.ts +395 -0
- package/dist/main.d.ts +211 -0
- package/dist/main.js +7600 -56
- package/dist/main.js.map +1 -0
- package/dist/moveable-B_vyA6cw.d.ts +67 -0
- package/dist/stage-types-CD21XoIU.d.ts +338 -0
- package/dist/stage.d.ts +46 -0
- package/dist/stage.js +2765 -4
- package/dist/stage.js.map +1 -0
- package/dist/transformable-CUhvyuYO.d.ts +67 -0
- package/package.json +11 -47
- package/dist/.vite/manifest.json +0 -716
- package/dist/assets/zylem-logo.png +0 -0
- package/dist/examples/00-readme-example.d.ts +0 -2
- package/dist/examples/00-readme-example.d.ts.map +0 -1
- package/dist/examples/01-basic.d.ts +0 -2
- package/dist/examples/01-basic.d.ts.map +0 -1
- package/dist/examples/01.1-basic-ball.d.ts +0 -9
- package/dist/examples/01.1-basic-ball.d.ts.map +0 -1
- package/dist/examples/01.2-ricochet-test.d.ts +0 -2
- package/dist/examples/01.2-ricochet-test.d.ts.map +0 -1
- package/dist/examples/01.3-rect.d.ts +0 -2
- package/dist/examples/01.3-rect.d.ts.map +0 -1
- package/dist/examples/02-input.d.ts +0 -2
- package/dist/examples/02-input.d.ts.map +0 -1
- package/dist/examples/03-stage-test/03-stage-test.d.ts +0 -2
- package/dist/examples/03-stage-test/03-stage-test.d.ts.map +0 -1
- package/dist/examples/03-stage-test/stage0.d.ts +0 -2
- package/dist/examples/03-stage-test/stage0.d.ts.map +0 -1
- package/dist/examples/03-stage-test/stage1.d.ts +0 -2
- package/dist/examples/03-stage-test/stage1.d.ts.map +0 -1
- package/dist/examples/03-stage-test/stage2.d.ts +0 -2
- package/dist/examples/03-stage-test/stage2.d.ts.map +0 -1
- package/dist/examples/03-stage-test/stage3.d.ts +0 -2
- package/dist/examples/03-stage-test/stage3.d.ts.map +0 -1
- package/dist/examples/03.1-stage-variable.d.ts +0 -2
- package/dist/examples/03.1-stage-variable.d.ts.map +0 -1
- package/dist/examples/04-vessel-test.d.ts +0 -18
- package/dist/examples/04-vessel-test.d.ts.map +0 -1
- package/dist/examples/05-camera-test.d.ts +0 -2
- package/dist/examples/05-camera-test.d.ts.map +0 -1
- package/dist/examples/06-entity-test.d.ts +0 -2
- package/dist/examples/06-entity-test.d.ts.map +0 -1
- package/dist/examples/07-behaviors.d.ts +0 -2
- package/dist/examples/07-behaviors.d.ts.map +0 -1
- package/dist/examples/07.01-behavior-context.d.ts +0 -2
- package/dist/examples/07.01-behavior-context.d.ts.map +0 -1
- package/dist/examples/08-pong.d.ts +0 -2
- package/dist/examples/08-pong.d.ts.map +0 -1
- package/dist/examples/08.01-breakout.d.ts +0 -2
- package/dist/examples/08.01-breakout.d.ts.map +0 -1
- package/dist/examples/09-space-invaders.d.ts +0 -2
- package/dist/examples/09-space-invaders.d.ts.map +0 -1
- package/dist/examples/10-asteroids.d.ts +0 -2
- package/dist/examples/10-asteroids.d.ts.map +0 -1
- package/dist/examples/11-2d-platformer.d.ts +0 -2
- package/dist/examples/11-2d-platformer.d.ts.map +0 -1
- package/dist/examples/12-3d-platformer.d.ts +0 -2
- package/dist/examples/12-3d-platformer.d.ts.map +0 -1
- package/dist/examples/13-fps.d.ts +0 -2
- package/dist/examples/13-fps.d.ts.map +0 -1
- package/dist/examples/14-strategy.d.ts +0 -2
- package/dist/examples/14-strategy.d.ts.map +0 -1
- package/dist/examples/15-zylem-planet-demo.d.ts +0 -2
- package/dist/examples/15-zylem-planet-demo.d.ts.map +0 -1
- package/dist/examples/16-timbotron.d.ts +0 -2
- package/dist/examples/16-timbotron.d.ts.map +0 -1
- package/dist/examples/17-stress-test.d.ts +0 -2
- package/dist/examples/17-stress-test.d.ts.map +0 -1
- package/dist/examples/architecture-test.d.ts +0 -2
- package/dist/examples/architecture-test.d.ts.map +0 -1
- package/dist/examples/utils.d.ts +0 -10
- package/dist/examples/utils.d.ts.map +0 -1
- package/dist/lib/actions/behaviors/actions.js +0 -35
- package/dist/lib/actions/behaviors/boundaries/boundary.js +0 -40
- package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.js +0 -100
- package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.js +0 -37
- package/dist/lib/actions/behaviors/ricochet/ricochet.js +0 -6
- package/dist/lib/actions/capabilities/moveable.js +0 -108
- package/dist/lib/actions/capabilities/rotatable.js +0 -82
- package/dist/lib/actions/capabilities/transformable.js +0 -9
- package/dist/lib/actions/global-change.js +0 -40
- package/dist/lib/camera/camera.js +0 -19
- package/dist/lib/camera/fixed-2d.js +0 -30
- package/dist/lib/camera/perspective.js +0 -10
- package/dist/lib/camera/third-person.js +0 -42
- package/dist/lib/camera/zylem-camera.js +0 -208
- package/dist/lib/collision/collision-builder.js +0 -46
- package/dist/lib/collision/collision-delegate.js +0 -6
- package/dist/lib/collision/utils.js +0 -24
- package/dist/lib/collision/world.js +0 -77
- package/dist/lib/core/base-node.js +0 -61
- package/dist/lib/core/entity-asset-loader.js +0 -54
- package/dist/lib/core/lifecycle-base.js +0 -20
- package/dist/lib/core/preset-shader.js +0 -26
- package/dist/lib/core/three-addons/Timer.js +0 -103
- package/dist/lib/core/utility/nodes.js +0 -31
- package/dist/lib/core/utility/strings.js +0 -14
- package/dist/lib/core/utility/vector.js +0 -8
- package/dist/lib/core/vessel.js +0 -26
- package/dist/lib/debug/console/console-state.js +0 -11
- package/dist/lib/debug/debug-state.js +0 -40
- package/dist/lib/device/aspect-ratio.js +0 -44
- package/dist/lib/entities/actor.js +0 -122
- package/dist/lib/entities/box.js +0 -68
- package/dist/lib/entities/builder.js +0 -79
- package/dist/lib/entities/create.js +0 -31
- package/dist/lib/entities/delegates/animation.js +0 -58
- package/dist/lib/entities/delegates/debug.js +0 -71
- package/dist/lib/entities/delegates/loader.js +0 -19
- package/dist/lib/entities/destroy.js +0 -15
- package/dist/lib/entities/entity-factory.js +0 -24
- package/dist/lib/entities/entity.js +0 -121
- package/dist/lib/entities/plane.js +0 -81
- package/dist/lib/entities/rect.js +0 -160
- package/dist/lib/entities/sphere.js +0 -68
- package/dist/lib/entities/sprite.js +0 -125
- package/dist/lib/entities/text.js +0 -140
- package/dist/lib/entities/zone.js +0 -103
- package/dist/lib/game/game-canvas.js +0 -57
- package/dist/lib/game/game-config.js +0 -78
- package/dist/lib/game/game-default.js +0 -23
- package/dist/lib/game/game-retro-resolutions.js +0 -80
- package/dist/lib/game/game-state.js +0 -17
- package/dist/lib/game/game.js +0 -131
- package/dist/lib/game/zylem-game.js +0 -140
- package/dist/lib/graphics/geometries/XZPlaneGeometry.js +0 -34
- package/dist/lib/graphics/material.js +0 -64
- package/dist/lib/graphics/mesh.js +0 -14
- package/dist/lib/graphics/render-pass.js +0 -56
- package/dist/lib/graphics/shaders/fragment/debug.glsl.js +0 -23
- package/dist/lib/graphics/shaders/fragment/fire.glsl.js +0 -52
- package/dist/lib/graphics/shaders/fragment/standard.glsl.js +0 -11
- package/dist/lib/graphics/shaders/fragment/stars.glsl.js +0 -44
- package/dist/lib/graphics/shaders/vertex/debug.glsl.js +0 -15
- package/dist/lib/graphics/shaders/vertex/object-shader.glsl.js +0 -11
- package/dist/lib/graphics/shaders/vertex/standard.glsl.js +0 -9
- package/dist/lib/graphics/zylem-scene.js +0 -75
- package/dist/lib/input/gamepad-provider.js +0 -58
- package/dist/lib/input/input-manager.js +0 -70
- package/dist/lib/input/keyboard-provider.js +0 -120
- package/dist/lib/stage/debug-entity-cursor.js +0 -53
- package/dist/lib/stage/entity-spawner.js +0 -27
- package/dist/lib/stage/stage-debug-delegate.js +0 -100
- package/dist/lib/stage/stage-default.js +0 -32
- package/dist/lib/stage/stage-factory.js +0 -22
- package/dist/lib/stage/stage-manager.js +0 -49
- package/dist/lib/stage/stage-state.js +0 -36
- package/dist/lib/stage/stage.js +0 -67
- package/dist/lib/stage/zylem-stage.js +0 -268
- package/dist/lib/systems/transformable.system.js +0 -43
- package/dist/node_modules/.pnpm/idb-keyval@6.2.2/node_modules/idb-keyval/dist/index.js +0 -34
- package/dist/node_modules/.pnpm/msgpackr@1.11.5/node_modules/msgpackr/pack.js +0 -520
- package/dist/node_modules/.pnpm/msgpackr@1.11.5/node_modules/msgpackr/unpack.js +0 -672
- package/dist/src/api/actions.d.ts +0 -5
- package/dist/src/api/actions.d.ts.map +0 -1
- package/dist/src/api/behaviors.d.ts +0 -4
- package/dist/src/api/behaviors.d.ts.map +0 -1
- package/dist/src/api/camera.d.ts +0 -4
- package/dist/src/api/camera.d.ts.map +0 -1
- package/dist/src/api/core.d.ts +0 -6
- package/dist/src/api/core.d.ts.map +0 -1
- package/dist/src/api/entities.d.ts +0 -9
- package/dist/src/api/entities.d.ts.map +0 -1
- package/dist/src/api/main.d.ts +0 -32
- package/dist/src/api/main.d.ts.map +0 -1
- package/dist/src/api/stage.d.ts +0 -5
- package/dist/src/api/stage.d.ts.map +0 -1
- package/dist/src/lib/actions/behaviors/actions.d.ts +0 -11
- package/dist/src/lib/actions/behaviors/actions.d.ts.map +0 -1
- package/dist/src/lib/actions/behaviors/behavior.d.ts +0 -6
- package/dist/src/lib/actions/behaviors/behavior.d.ts.map +0 -1
- package/dist/src/lib/actions/behaviors/boundaries/boundary.d.ts +0 -37
- package/dist/src/lib/actions/behaviors/boundaries/boundary.d.ts.map +0 -1
- package/dist/src/lib/actions/behaviors/character-controller.d.ts +0 -6
- package/dist/src/lib/actions/behaviors/character-controller.d.ts.map +0 -1
- package/dist/src/lib/actions/behaviors/debug/debug-collision.d.ts +0 -6
- package/dist/src/lib/actions/behaviors/debug/debug-collision.d.ts.map +0 -1
- package/dist/src/lib/actions/behaviors/debug/debug-update.d.ts +0 -5
- package/dist/src/lib/actions/behaviors/debug/debug-update.d.ts.map +0 -1
- package/dist/src/lib/actions/behaviors/debug/debug.d.ts +0 -10
- package/dist/src/lib/actions/behaviors/debug/debug.d.ts.map +0 -1
- package/dist/src/lib/actions/behaviors/movement/movement-sequence-2d.d.ts +0 -24
- package/dist/src/lib/actions/behaviors/movement/movement-sequence-2d.d.ts.map +0 -1
- package/dist/src/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts +0 -11
- package/dist/src/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts.map +0 -1
- package/dist/src/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts +0 -12
- package/dist/src/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts.map +0 -1
- package/dist/src/lib/actions/behaviors/ricochet/ricochet.d.ts +0 -44
- package/dist/src/lib/actions/behaviors/ricochet/ricochet.d.ts.map +0 -1
- package/dist/src/lib/actions/behaviors/zylem-behavior.d.ts +0 -2
- package/dist/src/lib/actions/behaviors/zylem-behavior.d.ts.map +0 -1
- package/dist/src/lib/actions/capabilities/moveable.d.ts +0 -125
- package/dist/src/lib/actions/capabilities/moveable.d.ts.map +0 -1
- package/dist/src/lib/actions/capabilities/rotatable.d.ts +0 -111
- package/dist/src/lib/actions/capabilities/rotatable.d.ts.map +0 -1
- package/dist/src/lib/actions/capabilities/transformable.d.ts +0 -7
- package/dist/src/lib/actions/capabilities/transformable.d.ts.map +0 -1
- package/dist/src/lib/actions/global-change.d.ts +0 -23
- package/dist/src/lib/actions/global-change.d.ts.map +0 -1
- package/dist/src/lib/camera/camera.d.ts +0 -16
- package/dist/src/lib/camera/camera.d.ts.map +0 -1
- package/dist/src/lib/camera/fixed-2d.d.ts +0 -32
- package/dist/src/lib/camera/fixed-2d.d.ts.map +0 -1
- package/dist/src/lib/camera/perspective.d.ts +0 -9
- package/dist/src/lib/camera/perspective.d.ts.map +0 -1
- package/dist/src/lib/camera/third-person.d.ts +0 -32
- package/dist/src/lib/camera/third-person.d.ts.map +0 -1
- package/dist/src/lib/camera/zylem-camera.d.ts.map +0 -1
- package/dist/src/lib/collision/collision-builder.d.ts +0 -17
- package/dist/src/lib/collision/collision-builder.d.ts.map +0 -1
- package/dist/src/lib/collision/collision-delegate.d.ts +0 -6
- package/dist/src/lib/collision/collision-delegate.d.ts.map +0 -1
- package/dist/src/lib/collision/collision-group.d.ts +0 -11
- package/dist/src/lib/collision/collision-group.d.ts.map +0 -1
- package/dist/src/lib/collision/collision-mask.d.ts +0 -18
- package/dist/src/lib/collision/collision-mask.d.ts.map +0 -1
- package/dist/src/lib/collision/collision.d.ts +0 -19
- package/dist/src/lib/collision/collision.d.ts.map +0 -1
- package/dist/src/lib/collision/utils.d.ts +0 -15
- package/dist/src/lib/collision/utils.d.ts.map +0 -1
- package/dist/src/lib/collision/world.d.ts +0 -23
- package/dist/src/lib/collision/world.d.ts.map +0 -1
- package/dist/src/lib/core/asset-manager.d.ts +0 -2
- package/dist/src/lib/core/asset-manager.d.ts.map +0 -1
- package/dist/src/lib/core/base-node-life-cycle.d.ts +0 -54
- package/dist/src/lib/core/base-node-life-cycle.d.ts.map +0 -1
- package/dist/src/lib/core/base-node.d.ts +0 -36
- package/dist/src/lib/core/base-node.d.ts.map +0 -1
- package/dist/src/lib/core/blueprints.d.ts +0 -22
- package/dist/src/lib/core/blueprints.d.ts.map +0 -1
- package/dist/src/lib/core/entity-asset-loader.d.ts +0 -16
- package/dist/src/lib/core/entity-asset-loader.d.ts.map +0 -1
- package/dist/src/lib/core/errors.d.ts +0 -5
- package/dist/src/lib/core/errors.d.ts.map +0 -1
- package/dist/src/lib/core/flags.d.ts +0 -3
- package/dist/src/lib/core/flags.d.ts.map +0 -1
- package/dist/src/lib/core/index.d.ts +0 -5
- package/dist/src/lib/core/index.d.ts.map +0 -1
- package/dist/src/lib/core/interfaces.d.ts +0 -25
- package/dist/src/lib/core/interfaces.d.ts.map +0 -1
- package/dist/src/lib/core/lazy-loader.d.ts +0 -80
- package/dist/src/lib/core/lazy-loader.d.ts.map +0 -1
- package/dist/src/lib/core/lifecycle-base.d.ts +0 -17
- package/dist/src/lib/core/lifecycle-base.d.ts.map +0 -1
- package/dist/src/lib/core/node-interface.d.ts +0 -12
- package/dist/src/lib/core/node-interface.d.ts.map +0 -1
- package/dist/src/lib/core/preset-shader.d.ts +0 -8
- package/dist/src/lib/core/preset-shader.d.ts.map +0 -1
- package/dist/src/lib/core/three-addons/Timer.d.ts +0 -92
- package/dist/src/lib/core/three-addons/Timer.d.ts.map +0 -1
- package/dist/src/lib/core/utility/nodes.d.ts +0 -13
- package/dist/src/lib/core/utility/nodes.d.ts.map +0 -1
- package/dist/src/lib/core/utility/strings.d.ts +0 -3
- package/dist/src/lib/core/utility/strings.d.ts.map +0 -1
- package/dist/src/lib/core/utility/vector.d.ts +0 -8
- package/dist/src/lib/core/utility/vector.d.ts.map +0 -1
- package/dist/src/lib/core/vector.d.ts +0 -4
- package/dist/src/lib/core/vector.d.ts.map +0 -1
- package/dist/src/lib/core/vessel.d.ts +0 -13
- package/dist/src/lib/core/vessel.d.ts.map +0 -1
- package/dist/src/lib/debug/console/console-state.d.ts +0 -20
- package/dist/src/lib/debug/console/console-state.d.ts.map +0 -1
- package/dist/src/lib/debug/console/console-store.d.ts +0 -6
- package/dist/src/lib/debug/console/console-store.d.ts.map +0 -1
- package/dist/src/lib/debug/debug-state.d.ts +0 -38
- package/dist/src/lib/debug/debug-state.d.ts.map +0 -1
- package/dist/src/lib/debug/debug-store.d.ts +0 -15
- package/dist/src/lib/debug/debug-store.d.ts.map +0 -1
- package/dist/src/lib/debug/state-based-debug-loader.d.ts +0 -8
- package/dist/src/lib/debug/state-based-debug-loader.d.ts.map +0 -1
- package/dist/src/lib/device/aspect-ratio.d.ts +0 -38
- package/dist/src/lib/device/aspect-ratio.d.ts.map +0 -1
- package/dist/src/lib/device/desktop.d.ts +0 -2
- package/dist/src/lib/device/desktop.d.ts.map +0 -1
- package/dist/src/lib/device/mobile.d.ts +0 -2
- package/dist/src/lib/device/mobile.d.ts.map +0 -1
- package/dist/src/lib/device/tablet.d.ts +0 -2
- package/dist/src/lib/device/tablet.d.ts.map +0 -1
- package/dist/src/lib/entities/actor.d.ts +0 -44
- package/dist/src/lib/entities/actor.d.ts.map +0 -1
- package/dist/src/lib/entities/box.d.ts +0 -27
- package/dist/src/lib/entities/box.d.ts.map +0 -1
- package/dist/src/lib/entities/builder.d.ts +0 -28
- package/dist/src/lib/entities/builder.d.ts.map +0 -1
- package/dist/src/lib/entities/create.d.ts +0 -15
- package/dist/src/lib/entities/create.d.ts.map +0 -1
- package/dist/src/lib/entities/delegates/animation.d.ts +0 -33
- package/dist/src/lib/entities/delegates/animation.d.ts.map +0 -1
- package/dist/src/lib/entities/delegates/debug.d.ts +0 -29
- package/dist/src/lib/entities/delegates/debug.d.ts.map +0 -1
- package/dist/src/lib/entities/delegates/loader.d.ts +0 -12
- package/dist/src/lib/entities/delegates/loader.d.ts.map +0 -1
- package/dist/src/lib/entities/destroy.d.ts +0 -4
- package/dist/src/lib/entities/destroy.d.ts.map +0 -1
- package/dist/src/lib/entities/entity-factory.d.ts +0 -10
- package/dist/src/lib/entities/entity-factory.d.ts.map +0 -1
- package/dist/src/lib/entities/entity.d.ts +0 -98
- package/dist/src/lib/entities/entity.d.ts.map +0 -1
- package/dist/src/lib/entities/index.d.ts +0 -12
- package/dist/src/lib/entities/index.d.ts.map +0 -1
- package/dist/src/lib/entities/plane.d.ts +0 -36
- package/dist/src/lib/entities/plane.d.ts.map +0 -1
- package/dist/src/lib/entities/rect.d.ts +0 -63
- package/dist/src/lib/entities/rect.d.ts.map +0 -1
- package/dist/src/lib/entities/sphere.d.ts +0 -29
- package/dist/src/lib/entities/sphere.d.ts.map +0 -1
- package/dist/src/lib/entities/sprite.d.ts +0 -54
- package/dist/src/lib/entities/sprite.d.ts.map +0 -1
- package/dist/src/lib/entities/text.d.ts +0 -49
- package/dist/src/lib/entities/text.d.ts.map +0 -1
- package/dist/src/lib/entities/zone.d.ts +0 -54
- package/dist/src/lib/entities/zone.d.ts.map +0 -1
- package/dist/src/lib/game/game-blueprint.d.ts +0 -38
- package/dist/src/lib/game/game-blueprint.d.ts.map +0 -1
- package/dist/src/lib/game/game-canvas.d.ts +0 -35
- package/dist/src/lib/game/game-canvas.d.ts.map +0 -1
- package/dist/src/lib/game/game-config.d.ts +0 -59
- package/dist/src/lib/game/game-config.d.ts.map +0 -1
- package/dist/src/lib/game/game-default.d.ts +0 -14
- package/dist/src/lib/game/game-default.d.ts.map +0 -1
- package/dist/src/lib/game/game-interfaces.d.ts +0 -29
- package/dist/src/lib/game/game-interfaces.d.ts.map +0 -1
- package/dist/src/lib/game/game-retro-resolutions.d.ts +0 -25
- package/dist/src/lib/game/game-retro-resolutions.d.ts.map +0 -1
- package/dist/src/lib/game/game-state.d.ts +0 -11
- package/dist/src/lib/game/game-state.d.ts.map +0 -1
- package/dist/src/lib/game/game.d.ts +0 -39
- package/dist/src/lib/game/game.d.ts.map +0 -1
- package/dist/src/lib/game/zylem-game.d.ts +0 -58
- package/dist/src/lib/game/zylem-game.d.ts.map +0 -1
- package/dist/src/lib/graphics/geometries/XZPlaneGeometry.d.ts +0 -8
- package/dist/src/lib/graphics/geometries/XZPlaneGeometry.d.ts.map +0 -1
- package/dist/src/lib/graphics/material.d.ts +0 -29
- package/dist/src/lib/graphics/material.d.ts.map +0 -1
- package/dist/src/lib/graphics/mesh.d.ts +0 -19
- package/dist/src/lib/graphics/mesh.d.ts.map +0 -1
- package/dist/src/lib/graphics/render-pass.d.ts +0 -17
- package/dist/src/lib/graphics/render-pass.d.ts.map +0 -1
- package/dist/src/lib/graphics/zylem-scene.d.ts +0 -50
- package/dist/src/lib/graphics/zylem-scene.d.ts.map +0 -1
- package/dist/src/lib/input/gamepad-provider.d.ts +0 -14
- package/dist/src/lib/input/gamepad-provider.d.ts.map +0 -1
- package/dist/src/lib/input/input-manager.d.ts +0 -15
- package/dist/src/lib/input/input-manager.d.ts.map +0 -1
- package/dist/src/lib/input/input-provider.d.ts +0 -7
- package/dist/src/lib/input/input-provider.d.ts.map +0 -1
- package/dist/src/lib/input/input.d.ts +0 -48
- package/dist/src/lib/input/input.d.ts.map +0 -1
- package/dist/src/lib/input/keyboard-provider.d.ts +0 -21
- package/dist/src/lib/input/keyboard-provider.d.ts.map +0 -1
- package/dist/src/lib/interfaces/entity.d.ts.map +0 -1
- package/dist/src/lib/sounds/index.d.ts +0 -3
- package/dist/src/lib/sounds/index.d.ts.map +0 -1
- package/dist/src/lib/sounds/ping-pong-sound.d.ts +0 -5
- package/dist/src/lib/sounds/ping-pong-sound.d.ts.map +0 -1
- package/dist/src/lib/sounds/ricochet-sound.d.ts +0 -5
- package/dist/src/lib/sounds/ricochet-sound.d.ts.map +0 -1
- package/dist/src/lib/stage/debug-entity-cursor.d.ts +0 -24
- package/dist/src/lib/stage/debug-entity-cursor.d.ts.map +0 -1
- package/dist/src/lib/stage/entity-spawner.d.ts +0 -9
- package/dist/src/lib/stage/entity-spawner.d.ts.map +0 -1
- package/dist/src/lib/stage/stage-camera-debug-delegate.d.ts +0 -14
- package/dist/src/lib/stage/stage-camera-debug-delegate.d.ts.map +0 -1
- package/dist/src/lib/stage/stage-debug-delegate.d.ts +0 -26
- package/dist/src/lib/stage/stage-debug-delegate.d.ts.map +0 -1
- package/dist/src/lib/stage/stage-default.d.ts +0 -3
- package/dist/src/lib/stage/stage-default.d.ts.map +0 -1
- package/dist/src/lib/stage/stage-factory.d.ts +0 -6
- package/dist/src/lib/stage/stage-factory.d.ts.map +0 -1
- package/dist/src/lib/stage/stage-manager.d.ts +0 -30
- package/dist/src/lib/stage/stage-manager.d.ts.map +0 -1
- package/dist/src/lib/stage/stage-state.d.ts +0 -14
- package/dist/src/lib/stage/stage-state.d.ts.map +0 -1
- package/dist/src/lib/stage/stage.d.ts +0 -35
- package/dist/src/lib/stage/stage.d.ts.map +0 -1
- package/dist/src/lib/stage/zylem-stage.d.ts +0 -128
- package/dist/src/lib/stage/zylem-stage.d.ts.map +0 -1
- package/dist/src/lib/systems/test-system.d.ts +0 -2
- package/dist/src/lib/systems/test-system.d.ts.map +0 -1
- package/dist/src/lib/systems/transformable.system.d.ts +0 -25
- package/dist/src/lib/systems/transformable.system.d.ts.map +0 -1
- package/dist/src/lib/types/entity-types.d.ts +0 -24
- package/dist/src/lib/types/entity-types.d.ts.map +0 -1
- package/dist/src/lib/types/index.d.ts +0 -3
- package/dist/src/lib/types/index.d.ts.map +0 -1
- package/dist/src/lib/types/stage-types.d.ts +0 -26
- package/dist/src/lib/types/stage-types.d.ts.map +0 -1
- package/dist/src/lib/ui/Debug.d.ts +0 -6
- package/dist/src/lib/ui/Debug.d.ts.map +0 -1
- package/dist/src/lib/ui/console/Console.d.ts +0 -7
- package/dist/src/lib/ui/console/Console.d.ts.map +0 -1
- package/dist/src/lib/ui/debug-panel/AccordionMenu.d.ts +0 -7
- package/dist/src/lib/ui/debug-panel/AccordionMenu.d.ts.map +0 -1
- package/dist/src/lib/ui/debug-panel/Menu.d.ts +0 -6
- package/dist/src/lib/ui/debug-panel/Menu.d.ts.map +0 -1
- package/dist/src/lib/ui/debug-panel/sections/EntitiesSection.d.ts +0 -4
- package/dist/src/lib/ui/debug-panel/sections/EntitiesSection.d.ts.map +0 -1
- package/dist/src/lib/ui/debug-panel/sections/GameSection.d.ts +0 -3
- package/dist/src/lib/ui/debug-panel/sections/GameSection.d.ts.map +0 -1
- package/dist/src/lib/ui/debug-panel/sections/StagesSection.d.ts +0 -3
- package/dist/src/lib/ui/debug-panel/sections/StagesSection.d.ts.map +0 -1
- package/dist/src/lib/ui/debug-panel/sections/all.d.ts +0 -4
- package/dist/src/lib/ui/debug-panel/sections/all.d.ts.map +0 -1
- package/dist/src/lib/ui/toolbar/Toolbar.d.ts +0 -6
- package/dist/src/lib/ui/toolbar/Toolbar.d.ts.map +0 -1
- package/dist/tests/e2e/basic-game.spec.d.ts +0 -2
- package/dist/tests/e2e/basic-game.spec.d.ts.map +0 -1
- package/dist/tests/integration/debug.sim.spec.d.ts +0 -2
- package/dist/tests/integration/debug.sim.spec.d.ts.map +0 -1
- package/dist/tests/unit/collision/collision.spec.d.ts +0 -2
- package/dist/tests/unit/collision/collision.spec.d.ts.map +0 -1
- package/dist/tests/unit/core/base-node.spec.d.ts +0 -2
- package/dist/tests/unit/core/base-node.spec.d.ts.map +0 -1
- package/dist/tests/unit/core/game.spec.d.ts +0 -2
- package/dist/tests/unit/core/game.spec.d.ts.map +0 -1
- package/dist/tests/unit/core/stage.spec.d.ts +0 -2
- package/dist/tests/unit/core/stage.spec.d.ts.map +0 -1
- package/dist/tests/unit/core/vessel.spec.d.ts +0 -2
- package/dist/tests/unit/core/vessel.spec.d.ts.map +0 -1
package/dist/lib/game/game.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { ZylemGame as l } from "./zylem-game.js";
|
|
2
|
-
import { setPaused as n } from "../debug/debug-state.js";
|
|
3
|
-
import { getGlobalState as g, setGlobalState as m } from "./game-state.js";
|
|
4
|
-
import { hasStages as h, convertNodes as c } from "../core/utility/nodes.js";
|
|
5
|
-
import { resolveGameConfig as u } from "./game-config.js";
|
|
6
|
-
import { createStage as G } from "../stage/stage.js";
|
|
7
|
-
import { StageManager as i, stageState as s } from "../stage/stage-manager.js";
|
|
8
|
-
import { StageFactory as p } from "../stage/stage-factory.js";
|
|
9
|
-
class w {
|
|
10
|
-
wrappedGame = null;
|
|
11
|
-
pendingGlobalChangeHandlers = [];
|
|
12
|
-
options;
|
|
13
|
-
update = () => {
|
|
14
|
-
};
|
|
15
|
-
setup = () => {
|
|
16
|
-
};
|
|
17
|
-
destroy = () => {
|
|
18
|
-
};
|
|
19
|
-
refErrorMessage = "lost reference to game";
|
|
20
|
-
constructor(e) {
|
|
21
|
-
this.options = e, h(e) || this.options.push(G());
|
|
22
|
-
}
|
|
23
|
-
async start() {
|
|
24
|
-
const e = await this.load();
|
|
25
|
-
return this.wrappedGame = e, this.setOverrides(), e.start(), this;
|
|
26
|
-
}
|
|
27
|
-
async load() {
|
|
28
|
-
console.log("loading game", this.options);
|
|
29
|
-
const e = await c(this.options), a = u(e), t = new l({
|
|
30
|
-
...e,
|
|
31
|
-
...a
|
|
32
|
-
}, this);
|
|
33
|
-
return await t.loadStage(e.stages[0]), t;
|
|
34
|
-
}
|
|
35
|
-
setOverrides() {
|
|
36
|
-
if (!this.wrappedGame) {
|
|
37
|
-
console.error(this.refErrorMessage);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (this.wrappedGame.customSetup = this.setup, this.wrappedGame.customUpdate = this.update, this.wrappedGame.customDestroy = this.destroy, this.pendingGlobalChangeHandlers.length) {
|
|
41
|
-
for (const { key: e, callback: a } of this.pendingGlobalChangeHandlers)
|
|
42
|
-
this.wrappedGame.onGlobalChange(e, a);
|
|
43
|
-
this.pendingGlobalChangeHandlers = [];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
async pause() {
|
|
47
|
-
n(!0);
|
|
48
|
-
}
|
|
49
|
-
async resume() {
|
|
50
|
-
n(!1), this.wrappedGame && (this.wrappedGame.previousTimeStamp = 0, this.wrappedGame.timer.reset());
|
|
51
|
-
}
|
|
52
|
-
async reset() {
|
|
53
|
-
if (!this.wrappedGame) {
|
|
54
|
-
console.error(this.refErrorMessage);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
await this.wrappedGame.loadStage(this.wrappedGame.stages[0]);
|
|
58
|
-
}
|
|
59
|
-
async previousStage() {
|
|
60
|
-
if (!this.wrappedGame) {
|
|
61
|
-
console.error(this.refErrorMessage);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const e = this.wrappedGame.currentStageId, a = this.wrappedGame.stages.findIndex((r) => r.wrappedStage.uuid === e), t = this.wrappedGame.stages[a - 1];
|
|
65
|
-
if (!t) {
|
|
66
|
-
console.error("previous stage called on first stage");
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
await this.wrappedGame.loadStage(t);
|
|
70
|
-
}
|
|
71
|
-
async loadStageFromId(e) {
|
|
72
|
-
if (!this.wrappedGame) {
|
|
73
|
-
console.error(this.refErrorMessage);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
const a = await i.loadStageData(e), t = await p.createFromBlueprint(a);
|
|
78
|
-
await this.wrappedGame.loadStage(t), s.current = a;
|
|
79
|
-
} catch (a) {
|
|
80
|
-
console.error(`Failed to load stage ${e}`, a);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
async nextStage() {
|
|
84
|
-
if (!this.wrappedGame) {
|
|
85
|
-
console.error(this.refErrorMessage);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (s.next) {
|
|
89
|
-
const r = s.next.id;
|
|
90
|
-
if (await i.transitionForward(r), s.current) {
|
|
91
|
-
const d = await p.createFromBlueprint(s.current);
|
|
92
|
-
await this.wrappedGame.loadStage(d);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const e = this.wrappedGame.currentStageId, a = this.wrappedGame.stages.findIndex((r) => r.wrappedStage.uuid === e), t = this.wrappedGame.stages[a + 1];
|
|
97
|
-
if (!t) {
|
|
98
|
-
console.error("next stage called on last stage");
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
await this.wrappedGame.loadStage(t);
|
|
102
|
-
}
|
|
103
|
-
async goToStage() {
|
|
104
|
-
}
|
|
105
|
-
async end() {
|
|
106
|
-
}
|
|
107
|
-
getGlobal(e) {
|
|
108
|
-
return this.wrappedGame ? this.wrappedGame.getGlobal(e) : g(e);
|
|
109
|
-
}
|
|
110
|
-
setGlobal(e, a) {
|
|
111
|
-
if (this.wrappedGame) {
|
|
112
|
-
this.wrappedGame.setGlobal(e, a);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
m(e, a);
|
|
116
|
-
}
|
|
117
|
-
onGlobalChange(e, a) {
|
|
118
|
-
if (this.wrappedGame) {
|
|
119
|
-
this.wrappedGame.onGlobalChange(e, a);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
this.pendingGlobalChangeHandlers.push({ key: e, callback: a });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function M(...o) {
|
|
126
|
-
return new w(o);
|
|
127
|
-
}
|
|
128
|
-
export {
|
|
129
|
-
w as Game,
|
|
130
|
-
M as createGame
|
|
131
|
-
};
|
|
@@ -1,140 +0,0 @@
|
|
|
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 {
|
|
10
|
-
id;
|
|
11
|
-
initialGlobals = {};
|
|
12
|
-
customSetup = null;
|
|
13
|
-
customUpdate = null;
|
|
14
|
-
customDestroy = null;
|
|
15
|
-
stages = [];
|
|
16
|
-
stageMap = /* @__PURE__ */ new Map();
|
|
17
|
-
currentStageId = "";
|
|
18
|
-
previousTimeStamp = 0;
|
|
19
|
-
totalTime = 0;
|
|
20
|
-
timer;
|
|
21
|
-
inputManager;
|
|
22
|
-
wrapperRef;
|
|
23
|
-
statsRef = null;
|
|
24
|
-
defaultCamera = null;
|
|
25
|
-
container = null;
|
|
26
|
-
canvas = null;
|
|
27
|
-
aspectRatioDelegate = null;
|
|
28
|
-
resolvedConfig = null;
|
|
29
|
-
gameCanvas = null;
|
|
30
|
-
static FRAME_LIMIT = 120;
|
|
31
|
-
static FRAME_DURATION = 1e3 / n.FRAME_LIMIT;
|
|
32
|
-
static MAX_DELTA_SECONDS = 1 / 30;
|
|
33
|
-
constructor(t, e) {
|
|
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));
|
|
51
|
-
}
|
|
52
|
-
async loadStage(t) {
|
|
53
|
-
this.unloadCurrentStage();
|
|
54
|
-
const e = t.options[0];
|
|
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
|
-
}
|
|
67
|
-
}
|
|
68
|
-
unloadCurrentStage() {
|
|
69
|
-
if (!this.currentStageId)
|
|
70
|
-
return;
|
|
71
|
-
const t = this.getStage(this.currentStageId);
|
|
72
|
-
if (t) {
|
|
73
|
-
if (t?.wrappedStage)
|
|
74
|
-
try {
|
|
75
|
-
t.wrappedStage.nodeDestroy({
|
|
76
|
-
me: t.wrappedStage,
|
|
77
|
-
globals: o.globals
|
|
78
|
-
});
|
|
79
|
-
} catch (e) {
|
|
80
|
-
console.error("Failed to destroy previous stage", e);
|
|
81
|
-
}
|
|
82
|
-
this.stageMap.delete(this.currentStageId);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
setGlobals(t) {
|
|
86
|
-
this.initialGlobals = { ...t.globals };
|
|
87
|
-
for (const e in this.initialGlobals) {
|
|
88
|
-
const a = this.initialGlobals[e];
|
|
89
|
-
a === void 0 && console.error(`global ${e} is undefined`), this.setGlobal(e, a);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
params() {
|
|
93
|
-
const t = this.currentStage(), e = this.timer.getDelta(), a = this.inputManager.getInputs(e), s = t?.wrappedStage?.cameraRef || this.defaultCamera;
|
|
94
|
-
return {
|
|
95
|
-
delta: e,
|
|
96
|
-
inputs: a,
|
|
97
|
-
globals: o.globals,
|
|
98
|
-
me: this,
|
|
99
|
-
camera: s
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
start() {
|
|
103
|
-
const t = this.currentStage(), e = this.params();
|
|
104
|
-
t.start({ ...e, me: t.wrappedStage }), this.customSetup && this.customSetup(e), this.loop(0);
|
|
105
|
-
}
|
|
106
|
-
loop(t) {
|
|
107
|
-
if (this.statsRef && this.statsRef.begin(), !m()) {
|
|
108
|
-
this.timer.update(t);
|
|
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;
|
|
111
|
-
}
|
|
112
|
-
this.statsRef && this.statsRef.end(), this.outOfLoop(), requestAnimationFrame(this.loop.bind(this));
|
|
113
|
-
}
|
|
114
|
-
outOfLoop() {
|
|
115
|
-
const t = this.currentStage();
|
|
116
|
-
t && t.wrappedStage.outOfLoop();
|
|
117
|
-
}
|
|
118
|
-
getStage(t) {
|
|
119
|
-
return this.stageMap.get(t);
|
|
120
|
-
}
|
|
121
|
-
currentStage() {
|
|
122
|
-
return this.getStage(this.currentStageId);
|
|
123
|
-
}
|
|
124
|
-
getGlobal(t) {
|
|
125
|
-
return r(t);
|
|
126
|
-
}
|
|
127
|
-
setGlobal(t, e) {
|
|
128
|
-
d(t, e);
|
|
129
|
-
}
|
|
130
|
-
onGlobalChange(t, e) {
|
|
131
|
-
let a = r(t);
|
|
132
|
-
S(o, () => {
|
|
133
|
-
const s = r(t);
|
|
134
|
-
s !== a && (a = s, e(s));
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
export {
|
|
139
|
-
n as ZylemGame
|
|
140
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { BufferGeometry as _, Float32BufferAttribute as f } from "three";
|
|
2
|
-
class b extends _ {
|
|
3
|
-
constructor(t = 1, h = 1, l = 1, a = 1) {
|
|
4
|
-
super(), this.type = "XZPlaneGeometry", this.parameters = {
|
|
5
|
-
width: t,
|
|
6
|
-
height: h,
|
|
7
|
-
widthSegments: l,
|
|
8
|
-
heightSegments: a
|
|
9
|
-
};
|
|
10
|
-
const d = t / 2, x = h / 2, n = Math.floor(l), i = Math.floor(a), r = n + 1, w = i + 1, A = t / n, v = h / i, u = [], m = [], g = [], p = [];
|
|
11
|
-
for (let s = 0; s < w; s++) {
|
|
12
|
-
const e = s * v - x;
|
|
13
|
-
for (let o = 0; o < r; o++) {
|
|
14
|
-
const c = o * A - d;
|
|
15
|
-
m.push(c, 0, e), g.push(0, 1, 0), p.push(o / n), p.push(1 - s / i);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
for (let s = 0; s < i; s++)
|
|
19
|
-
for (let e = 0; e < n; e++) {
|
|
20
|
-
const o = e + r * s, c = e + r * (s + 1), X = e + 1 + r * (s + 1), y = e + 1 + r * s;
|
|
21
|
-
u.push(o, c, y), u.push(c, X, y);
|
|
22
|
-
}
|
|
23
|
-
this.setIndex(u), this.setAttribute("position", new f(m, 3)), this.setAttribute("normal", new f(g, 3)), this.setAttribute("uv", new f(p, 2));
|
|
24
|
-
}
|
|
25
|
-
copy(t) {
|
|
26
|
-
return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
|
|
27
|
-
}
|
|
28
|
-
static fromJSON(t) {
|
|
29
|
-
return new b(t.width, t.height, t.widthSegments, t.heightSegments);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export {
|
|
33
|
-
b as XZPlaneGeometry
|
|
34
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
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/strings.js";
|
|
3
|
-
import h from "../core/preset-shader.js";
|
|
4
|
-
class i {
|
|
5
|
-
static batchMaterialMap = /* @__PURE__ */ new Map();
|
|
6
|
-
materials = [];
|
|
7
|
-
batchMaterial(t, a) {
|
|
8
|
-
const r = M(w(t)), e = i.batchMaterialMap.get(r);
|
|
9
|
-
if (e) {
|
|
10
|
-
const s = e.geometryMap.get(a);
|
|
11
|
-
s ? e.geometryMap.set(a, s + 1) : e.geometryMap.set(a, 1);
|
|
12
|
-
} else
|
|
13
|
-
i.batchMaterialMap.set(r, {
|
|
14
|
-
geometryMap: /* @__PURE__ */ new Map([[a, 1]]),
|
|
15
|
-
material: this.materials[0]
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
async build(t, a) {
|
|
19
|
-
const { path: r, repeat: e, color: s, shader: l } = t;
|
|
20
|
-
l && this.withShader(l), s && this.withColor(s), await this.setTexture(r ?? null, e), this.materials.length === 0 && this.setColor(new n("#ffffff")), this.batchMaterial(t, a);
|
|
21
|
-
}
|
|
22
|
-
withColor(t) {
|
|
23
|
-
return this.setColor(t), this;
|
|
24
|
-
}
|
|
25
|
-
withShader(t) {
|
|
26
|
-
return this.setShader(t), this;
|
|
27
|
-
}
|
|
28
|
-
async setTexture(t = null, a = new m(1, 1)) {
|
|
29
|
-
if (!t)
|
|
30
|
-
return;
|
|
31
|
-
const e = await new c().loadAsync(t);
|
|
32
|
-
e.repeat = a, e.wrapS = o, e.wrapT = o;
|
|
33
|
-
const s = new p({
|
|
34
|
-
map: e
|
|
35
|
-
});
|
|
36
|
-
this.materials.push(s);
|
|
37
|
-
}
|
|
38
|
-
setColor(t) {
|
|
39
|
-
const a = new u({
|
|
40
|
-
color: t,
|
|
41
|
-
emissiveIntensity: 0.5,
|
|
42
|
-
lightMapIntensity: 0.5,
|
|
43
|
-
fog: !0
|
|
44
|
-
});
|
|
45
|
-
this.materials.push(a);
|
|
46
|
-
}
|
|
47
|
-
setShader(t) {
|
|
48
|
-
const { fragment: a, vertex: r } = h.get(t) ?? h.get("standard"), e = new f({
|
|
49
|
-
uniforms: {
|
|
50
|
-
iResolution: { value: new d(1, 1, 1) },
|
|
51
|
-
iTime: { value: 0 },
|
|
52
|
-
tDiffuse: { value: null },
|
|
53
|
-
tDepth: { value: null },
|
|
54
|
-
tNormal: { value: null }
|
|
55
|
-
},
|
|
56
|
-
vertexShader: r,
|
|
57
|
-
fragmentShader: a
|
|
58
|
-
});
|
|
59
|
-
this.materials.push(e);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
export {
|
|
63
|
-
i as MaterialBuilder
|
|
64
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Mesh as n } from "three";
|
|
2
|
-
class h {
|
|
3
|
-
_build(t, r, s) {
|
|
4
|
-
const { batched: i, material: a } = t;
|
|
5
|
-
i && console.warn("warning: mesh batching is not implemented");
|
|
6
|
-
const e = new n(r, s.at(-1));
|
|
7
|
-
return e.position.set(0, 0, 0), e.castShadow = !0, e.receiveShadow = !0, e;
|
|
8
|
-
}
|
|
9
|
-
_postBuild() {
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
h as MeshBuilder
|
|
14
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import * as s from "three";
|
|
2
|
-
import { WebGLRenderTarget as i } from "three";
|
|
3
|
-
import n from "./shaders/fragment/standard.glsl.js";
|
|
4
|
-
import l from "./shaders/vertex/standard.glsl.js";
|
|
5
|
-
import { Pass as o, FullScreenQuad as d } from "three/addons/postprocessing/Pass.js";
|
|
6
|
-
class f extends o {
|
|
7
|
-
fsQuad;
|
|
8
|
-
resolution;
|
|
9
|
-
scene;
|
|
10
|
-
camera;
|
|
11
|
-
rgbRenderTarget;
|
|
12
|
-
normalRenderTarget;
|
|
13
|
-
normalMaterial;
|
|
14
|
-
constructor(e, r, a) {
|
|
15
|
-
super(), this.resolution = e, this.fsQuad = new d(this.material()), this.scene = r, this.camera = a, this.rgbRenderTarget = new i(e.x * 4, e.y * 4), this.normalRenderTarget = new i(e.x * 4, e.y * 4), this.normalMaterial = new s.MeshNormalMaterial();
|
|
16
|
-
}
|
|
17
|
-
render(e, r) {
|
|
18
|
-
e.setRenderTarget(this.rgbRenderTarget), e.render(this.scene, this.camera);
|
|
19
|
-
const a = this.scene.overrideMaterial;
|
|
20
|
-
e.setRenderTarget(this.normalRenderTarget), this.scene.overrideMaterial = this.normalMaterial, e.render(this.scene, this.camera), this.scene.overrideMaterial = a;
|
|
21
|
-
const t = this.fsQuad.material.uniforms;
|
|
22
|
-
t.tDiffuse.value = this.rgbRenderTarget.texture, t.tDepth.value = this.rgbRenderTarget.depthTexture, t.tNormal.value = this.normalRenderTarget.texture, t.iTime.value += 0.01, this.renderToScreen ? e.setRenderTarget(null) : e.setRenderTarget(r), this.fsQuad.render(e);
|
|
23
|
-
}
|
|
24
|
-
material() {
|
|
25
|
-
return new s.ShaderMaterial({
|
|
26
|
-
uniforms: {
|
|
27
|
-
iTime: { value: 0 },
|
|
28
|
-
tDiffuse: { value: null },
|
|
29
|
-
tDepth: { value: null },
|
|
30
|
-
tNormal: { value: null },
|
|
31
|
-
resolution: {
|
|
32
|
-
value: new s.Vector4(this.resolution.x, this.resolution.y, 1 / this.resolution.x, 1 / this.resolution.y)
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
vertexShader: l,
|
|
36
|
-
fragmentShader: n
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
dispose() {
|
|
40
|
-
try {
|
|
41
|
-
this.fsQuad?.dispose?.();
|
|
42
|
-
} catch {
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
this.rgbRenderTarget?.dispose?.(), this.normalRenderTarget?.dispose?.();
|
|
46
|
-
} catch {
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
this.normalMaterial?.dispose?.();
|
|
50
|
-
} catch {
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
export {
|
|
55
|
-
f as default
|
|
56
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var e = `varying vec3 vBarycentric;
|
|
2
|
-
uniform vec3 baseColor;
|
|
3
|
-
uniform vec3 wireframeColor;
|
|
4
|
-
uniform float wireframeThickness;
|
|
5
|
-
|
|
6
|
-
float edgeFactor() {
|
|
7
|
-
vec3 d = fwidth(vBarycentric);
|
|
8
|
-
vec3 a3 = smoothstep(vec3(0.0), d * wireframeThickness, vBarycentric);
|
|
9
|
-
return min(min(a3.x, a3.y), a3.z);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
void main() {
|
|
13
|
-
float edge = edgeFactor();
|
|
14
|
-
|
|
15
|
-
vec3 wireColor = wireframeColor;
|
|
16
|
-
|
|
17
|
-
vec3 finalColor = mix(wireColor, baseColor, edge);
|
|
18
|
-
|
|
19
|
-
gl_FragColor = vec4(finalColor, 1.0);
|
|
20
|
-
}`;
|
|
21
|
-
export {
|
|
22
|
-
e as default
|
|
23
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
var n = `#include <common>
|
|
2
|
-
|
|
3
|
-
uniform vec3 iResolution;
|
|
4
|
-
uniform float iTime;
|
|
5
|
-
uniform vec2 iOffset;
|
|
6
|
-
varying vec2 vUv;
|
|
7
|
-
|
|
8
|
-
float snoise(vec3 uv, float res)
|
|
9
|
-
{
|
|
10
|
-
const vec3 s = vec3(1e0, 1e2, 1e3);
|
|
11
|
-
|
|
12
|
-
uv *= res;
|
|
13
|
-
|
|
14
|
-
vec3 uv0 = floor(mod(uv, res))*s;
|
|
15
|
-
vec3 uv1 = floor(mod(uv+vec3(1.), res))*s;
|
|
16
|
-
|
|
17
|
-
vec3 f = fract(uv); f = f*f*(3.0-2.0*f);
|
|
18
|
-
|
|
19
|
-
vec4 v = vec4(uv0.x+uv0.y+uv0.z, uv1.x+uv0.y+uv0.z,
|
|
20
|
-
uv0.x+uv1.y+uv0.z, uv1.x+uv1.y+uv0.z);
|
|
21
|
-
|
|
22
|
-
vec4 r = fract(sin(v*1e-1)*1e3);
|
|
23
|
-
float r0 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
|
|
24
|
-
|
|
25
|
-
r = fract(sin((v + uv1.z - uv0.z)*1e-1)*1e3);
|
|
26
|
-
float r1 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
|
|
27
|
-
|
|
28
|
-
return mix(r0, r1, f.z)*2.-1.;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
|
|
32
|
-
vec2 p = -.5 + fragCoord.xy / iResolution.xy;
|
|
33
|
-
p.x *= iResolution.x/iResolution.y;
|
|
34
|
-
|
|
35
|
-
float color = 3.0 - (3.*length(2.*p));
|
|
36
|
-
|
|
37
|
-
vec3 coord = vec3(atan(p.x,p.y)/6.2832+.5, length(p)*.4, .5);
|
|
38
|
-
|
|
39
|
-
for(int i = 1; i <= 7; i++)
|
|
40
|
-
{
|
|
41
|
-
float power = pow(2.0, float(i));
|
|
42
|
-
color += (1.5 / power) * snoise(coord + vec3(0.,-iTime*.05, iTime*.01), power*16.);
|
|
43
|
-
}
|
|
44
|
-
fragColor = vec4( color, pow(max(color,0.),2.)*0.4, pow(max(color,0.),3.)*0.15 , 1.0);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
void main() {
|
|
48
|
-
mainImage(gl_FragColor, vUv);
|
|
49
|
-
}`;
|
|
50
|
-
export {
|
|
51
|
-
n as default
|
|
52
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
var n = `#include <common>
|
|
2
|
-
|
|
3
|
-
uniform vec3 iResolution;
|
|
4
|
-
uniform float iTime;
|
|
5
|
-
varying vec2 vUv;
|
|
6
|
-
|
|
7
|
-
vec3 palette( float t ) {
|
|
8
|
-
vec3 a = vec3(0.5, 0.5, 0.5);
|
|
9
|
-
vec3 b = vec3(0.5, 0.5, 0.5);
|
|
10
|
-
vec3 c = vec3(1.0, 1.0, 1.0);
|
|
11
|
-
vec3 d = vec3(0.263,0.416,0.557);
|
|
12
|
-
|
|
13
|
-
return a + b*cos( 6.28318*(c*t+d) );
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
|
|
17
|
-
vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y;
|
|
18
|
-
vec2 uv0 = uv;
|
|
19
|
-
vec3 finalColor = vec3(0.0);
|
|
20
|
-
|
|
21
|
-
for (float i = 0.0; i < 4.0; i++) {
|
|
22
|
-
uv = fract(uv * 1.5) - 0.5;
|
|
23
|
-
|
|
24
|
-
float d = length(uv) * exp(-length(uv0));
|
|
25
|
-
|
|
26
|
-
vec3 col = palette(length(uv0) + i*.4 + iTime*.4);
|
|
27
|
-
|
|
28
|
-
d = sin(d*5. + iTime)/5.;
|
|
29
|
-
d = abs(d);
|
|
30
|
-
|
|
31
|
-
d = pow(0.01 / d, 1.2);
|
|
32
|
-
|
|
33
|
-
finalColor += col * d;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
fragColor = vec4(finalColor, 1.0);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
void main() {
|
|
40
|
-
mainImage(gl_FragColor, vUv);
|
|
41
|
-
}`;
|
|
42
|
-
export {
|
|
43
|
-
n as default
|
|
44
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var e = `varying vec3 vBarycentric;
|
|
2
|
-
|
|
3
|
-
void main() {
|
|
4
|
-
vec3 barycentric = vec3(0.0);
|
|
5
|
-
int index = gl_VertexID % 3;
|
|
6
|
-
if (index == 0) barycentric = vec3(1.0, 0.0, 0.0);
|
|
7
|
-
else if (index == 1) barycentric = vec3(0.0, 1.0, 0.0);
|
|
8
|
-
else barycentric = vec3(0.0, 0.0, 1.0);
|
|
9
|
-
vBarycentric = barycentric;
|
|
10
|
-
|
|
11
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
12
|
-
}`;
|
|
13
|
-
export {
|
|
14
|
-
e as default
|
|
15
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Scene as d, Color as i, TextureLoader as n, AmbientLight as m, DirectionalLight as c, Vector3 as h, GridHelper as l } from "three";
|
|
2
|
-
import { debugState as g } from "../debug/debug-state.js";
|
|
3
|
-
import { getGlobalState as p } from "../game/game-state.js";
|
|
4
|
-
class b {
|
|
5
|
-
type = "Scene";
|
|
6
|
-
_setup;
|
|
7
|
-
scene;
|
|
8
|
-
zylemCamera;
|
|
9
|
-
containerElement = null;
|
|
10
|
-
update = () => {
|
|
11
|
-
};
|
|
12
|
-
_collision;
|
|
13
|
-
_destroy;
|
|
14
|
-
name;
|
|
15
|
-
tag;
|
|
16
|
-
constructor(e, s, a) {
|
|
17
|
-
const o = new d(), t = a.backgroundColor instanceof i ? a.backgroundColor : new i(a.backgroundColor);
|
|
18
|
-
if (o.background = t, a.backgroundImage) {
|
|
19
|
-
const r = new n().load(a.backgroundImage);
|
|
20
|
-
o.background = r;
|
|
21
|
-
}
|
|
22
|
-
this.scene = o, this.zylemCamera = s, this.setupLighting(o), this.setupCamera(o, s), g.on && this.debugScene();
|
|
23
|
-
}
|
|
24
|
-
setup() {
|
|
25
|
-
this._setup && this._setup({ me: this, camera: this.zylemCamera, globals: p() });
|
|
26
|
-
}
|
|
27
|
-
destroy() {
|
|
28
|
-
this.zylemCamera && this.zylemCamera.destroy && this.zylemCamera.destroy(), this.scene && this.scene.traverse((e) => {
|
|
29
|
-
e.geometry && e.geometry.dispose?.(), e.material && (Array.isArray(e.material) ? e.material.forEach((s) => s.dispose?.()) : e.material.dispose?.());
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Setup camera with the scene
|
|
34
|
-
*/
|
|
35
|
-
setupCamera(e, s) {
|
|
36
|
-
e.add(s.cameraRig), s.setup(e);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Setup scene lighting
|
|
40
|
-
*/
|
|
41
|
-
setupLighting(e) {
|
|
42
|
-
const s = new m(16777215, 2);
|
|
43
|
-
e.add(s);
|
|
44
|
-
const a = new c(16777215, 2);
|
|
45
|
-
a.name = "Light", a.position.set(0, 100, 0), a.castShadow = !0, a.shadow.camera.near = 0.1, a.shadow.camera.far = 2e3, a.shadow.camera.left = -100, a.shadow.camera.right = 100, a.shadow.camera.top = 100, a.shadow.camera.bottom = -100, a.shadow.mapSize.width = 2048, a.shadow.mapSize.height = 2048, e.add(a);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Update renderer size - delegates to camera
|
|
49
|
-
*/
|
|
50
|
-
updateRenderer(e, s) {
|
|
51
|
-
this.zylemCamera.resize(e, s);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Add object to scene
|
|
55
|
-
*/
|
|
56
|
-
add(e, s = new h(0, 0, 0)) {
|
|
57
|
-
e.position.set(s.x, s.y, s.z), this.scene.add(e);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Add game entity to scene
|
|
61
|
-
*/
|
|
62
|
-
addEntity(e) {
|
|
63
|
-
e.group ? this.add(e.group, e.options.position) : e.mesh && this.add(e.mesh, e.options.position);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Add debug helpers to scene
|
|
67
|
-
*/
|
|
68
|
-
debugScene() {
|
|
69
|
-
const a = new l(1e3, 100);
|
|
70
|
-
this.scene.add(a);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
b as ZylemScene
|
|
75
|
-
};
|