bard-legends-framework 0.10.9 → 0.12.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/dist/actions-performance.test.d.ts +1 -0
- package/dist/actions-performance.test.js +83 -0
- package/dist/game-entities/controller/controller.d.ts +2 -3
- package/dist/game-entities/controller/controller.js +9 -8
- package/dist/game-entities/controller/controller.test.js +2 -2
- package/dist/game-entities/entity/entity.d.ts +11 -9
- package/dist/game-entities/entity/entity.js +20 -16
- package/dist/game-entities/entity/entity.test.js +116 -147
- package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +6 -9
- package/dist/game-entities/entity/helpers/entity-store.helper.js +22 -57
- package/dist/game-entities/entity/helpers/entity-store.helper.test.d.ts +1 -0
- package/dist/game-entities/entity/helpers/entity-store.helper.test.js +136 -0
- package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +7 -7
- package/dist/game-entities/entity/helpers/entity-views.helper.js +28 -23
- package/dist/game-entities/entity/singleton-entity.d.ts +3 -3
- package/dist/game-entities/entity/singleton-entity.js +1 -1
- package/dist/game-entities/entity/singleton-entity.test.js +9 -31
- package/dist/game-entities/hard-reset.d.ts +5 -0
- package/dist/game-entities/hard-reset.js +14 -0
- package/dist/game-entities/index.d.ts +1 -3
- package/dist/game-entities/index.js +3 -7
- package/dist/game-entities/scene/scene.d.ts +15 -15
- package/dist/game-entities/scene/scene.js +61 -60
- package/dist/game-entities/scene/scene.test.js +97 -67
- package/dist/game-entities/service/service.d.ts +1 -4
- package/dist/game-entities/service/service.js +15 -14
- package/dist/game-entities/service/service.test.js +33 -38
- package/dist/game-entities/unit-test.helper.d.ts +5 -0
- package/dist/game-entities/unit-test.helper.js +14 -0
- package/dist/game-entities/update-cycle.d.ts +10 -9
- package/dist/game-entities/update-cycle.js +34 -23
- package/dist/game-entities/view/view.d.ts +10 -11
- package/dist/game-entities/view/view.js +17 -35
- package/dist/game-entities/view/view.test.js +73 -250
- package/dist/physics/entity-types/immovable-physics-entity.d.ts +2 -4
- package/dist/physics/entity-types/immovable-physics-entity.js +4 -6
- package/dist/physics/entity-types/movable-entity.d.ts +1 -1
- package/dist/physics/entity-types/movable-entity.js +6 -6
- package/dist/physics/entity-types/movable-physics-entity.d.ts +10 -11
- package/dist/physics/entity-types/movable-physics-entity.js +31 -32
- package/dist/physics/entity-types/physics-entity.d.ts +12 -15
- package/dist/physics/entity-types/physics-entity.js +30 -28
- package/dist/physics/interfaces.d.ts +6 -6
- package/dist/physics/interfaces.js +4 -4
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +16 -16
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.js +22 -22
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +20 -20
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.js +30 -30
- package/dist/physics/module//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +3 -3
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +10 -10
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.js +16 -16
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +11 -11
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.js +18 -18
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.d.ts +5 -5
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.js +17 -17
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.js +11 -11
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.js +4 -4
- package/dist/physics/module//360/237/223/220services/creation/border.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/creation/border.service.js +9 -9
- package/dist/physics/module//360/237/223/220services/creation/materials.service.d.ts +7 -7
- package/dist/physics/module//360/237/223/220services/creation/materials.service.js +17 -17
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.d.ts +11 -11
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +28 -27
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.js +13 -13
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.js +19 -19
- package/dist/physics/module//360/237/223/220services/impact/explosion.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/impact/explosion.service.js +20 -20
- package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.d.ts +1 -1
- package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.js +4 -4
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.js +3 -3
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.d.ts +5 -5
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +13 -13
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +13 -13
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.js +4 -4
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.d.ts +1 -4
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.js +7 -15
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +60 -49
- package/dist/physics/module//360/237/247/212entities/border.entity.d.ts +1 -1
- package/dist/physics/module//360/237/247/212entities/border.entity.js +3 -3
- package/dist/physics/module//360/237/247/212entities/physics-world.entity.js +2 -2
- package/dist/pixi/components/display-object-array.d.ts +5 -5
- package/dist/pixi/components/display-object-array.js +14 -14
- package/dist/pixi/components/helpers/smooth-scroller.d.ts +7 -7
- package/dist/pixi/components/helpers/smooth-scroller.js +23 -23
- package/dist/pixi/components/helpers/smooth-scroller.test.js +14 -14
- package/dist/pixi/components/menu/menu-entity.d.ts +14 -0
- package/dist/pixi/components/menu/menu-entity.js +48 -0
- package/dist/pixi/components/menu/menu.ui.d.ts +23 -0
- package/dist/pixi/components/menu/menu.ui.js +97 -0
- package/dist/pixi/components/mouse-wheel-listener.ui.d.ts +4 -3
- package/dist/pixi/components/mouse-wheel-listener.ui.js +15 -14
- package/dist/pixi/components/scroll-area.ui.d.ts +1 -1
- package/dist/pixi/components/scroll-area.ui.js +9 -9
- package/dist/pixi/components/scroll-mask.ui.d.ts +9 -8
- package/dist/pixi/components/scroll-mask.ui.js +25 -24
- package/dist/pixi/display-object/container-attributes.d.ts +24 -26
- package/dist/pixi/display-object/container-attributes.js +27 -28
- package/dist/pixi/display-object/container.d.ts +3 -6
- package/dist/pixi/display-object/container.js +2 -12
- package/dist/pixi/display-object/filters/base-filters/blur.filter.d.ts +9 -9
- package/dist/pixi/display-object/filters/base-filters/blur.filter.js +25 -25
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.d.ts +7 -7
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.js +17 -17
- package/dist/pixi/display-object/filters/composite-filters/glow-filter.d.ts +6 -6
- package/dist/pixi/display-object/filters/composite-filters/glow-filter.js +10 -11
- package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.d.ts +2 -2
- package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.js +5 -5
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.d.ts +5 -5
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.js +8 -8
- package/dist/pixi/display-object/filters/templates/plane.template.d.ts +5 -5
- package/dist/pixi/display-object/filters/templates/plane.template.js +7 -7
- package/dist/pixi/display-object/filters.d.ts +7 -7
- package/dist/pixi/display-object/filters.js +34 -34
- package/dist/pixi/display-object/index.d.ts +1 -1
- package/dist/pixi/display-object/objects/graphics/graphics.d.ts +9 -9
- package/dist/pixi/display-object/objects/graphics/graphics.js +25 -25
- package/dist/pixi/display-object/objects/placeholder.d.ts +1 -1
- package/dist/pixi/display-object/objects/placeholder.js +7 -7
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.d.ts +9 -9
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.js +29 -26
- package/dist/pixi/display-object/objects/sprite/sprite.d.ts +10 -9
- package/dist/pixi/display-object/objects/sprite/sprite.js +62 -53
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/pixi-text-style-converter.d.ts +4 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.d.ts +6 -6
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js +16 -16
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js +28 -28
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.d.ts +1 -1
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.js +3 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.d.ts +17 -17
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.js +62 -62
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.test.js +2 -2
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.d.ts +3 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.js +6 -6
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.test.js +12 -12
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.d.ts +2 -2
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.test.js +5 -5
- package/dist/pixi/display-object/objects/text/rich-text.d.ts +0 -1
- package/dist/pixi/display-object/objects/text/rich-text.js +0 -1
- package/dist/pixi/display-object/objects/text/text.d.ts +9 -10
- package/dist/pixi/display-object/objects/text/text.js +34 -35
- package/dist/pixi/game.d.ts +26 -17
- package/dist/pixi/game.js +53 -39
- package/dist/pixi/helpers/game-assets.d.ts +5 -5
- package/dist/pixi/helpers/game-assets.js +14 -11
- package/dist/pixi/helpers/position-conversion.helper.d.ts +4 -4
- package/dist/pixi/helpers/position-conversion.helper.js +3 -3
- package/dist/pixi/index.d.ts +3 -37
- package/dist/pixi/index.js +6 -22
- package/dist/pixi/modules/CAMERA/camera.d.ts +5 -4
- package/dist/pixi/modules/CAMERA/camera.js +9 -9
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.d.ts +3 -2
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.js +1 -1
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.d.ts +3 -2
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.js +5 -5
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.d.ts +3 -3
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.js +7 -7
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +8 -8
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.js +8 -8
- package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.d.ts +2 -2
- package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.js +12 -12
- package/dist/pixi/modules/CAMERA//360/237/247/212entities/camera.entity.js +4 -4
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.d.ts +17 -16
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +50 -49
- package/dist/pixi/pixi-definitions.d.ts +38 -0
- package/dist/pixi/pixi-definitions.js +37 -0
- package/dist/pixi/services/keyboard/keyboard.d.ts +6 -4
- package/dist/pixi/services/keyboard/keyboard.js +15 -13
- package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +12 -11
- package/dist/pixi/services/mouse/mouse-target-focus.service.js +31 -30
- package/dist/pixi/services/mouse/mouse.service.d.ts +16 -6
- package/dist/pixi/services/mouse/mouse.service.js +42 -22
- package/dist/utilities/animator/animating-content/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/animating-content/fade-in-content.js +37 -0
- package/dist/utilities/animator/animating-content/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/animating-content/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/animating-content/slide-in-content.d.ts +37 -0
- package/dist/utilities/animator/animating-content/slide-in-content.js +99 -0
- package/dist/utilities/animator/animating-content/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/animating-content/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/animations.d.ts +45 -0
- package/dist/utilities/animator/animations.js +92 -0
- package/dist/utilities/animator/animator/animator.d.ts +44 -0
- package/dist/utilities/animator/animator/animator.js +234 -0
- package/dist/utilities/animator/animator/animator.memory-leak.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.memory-leak.test.js +73 -0
- package/dist/utilities/animator/animator/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.performance.test.js +116 -0
- package/dist/utilities/animator/animator/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.test.js +1046 -0
- package/dist/utilities/animator/animator.d.ts +60 -0
- package/dist/utilities/animator/animator.js +322 -0
- package/dist/utilities/animator/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator.performance.test.js +46 -0
- package/dist/utilities/animator/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator.test.js +928 -0
- package/dist/utilities/animator/animator2/animator.d.ts +42 -0
- package/dist/utilities/animator/animator2/animator.js +222 -0
- package/dist/utilities/animator/animator2/animator.memory-leak.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.memory-leak.test.js +73 -0
- package/dist/utilities/animator/animator2/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.performance.test.js +65 -0
- package/dist/utilities/animator/animator2/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.test.js +1007 -0
- package/dist/utilities/animator/animator_old/animator.d.ts +60 -0
- package/dist/utilities/animator/animator_old/animator.js +337 -0
- package/dist/utilities/animator/animator_old/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator_old/animator.performance.test.js +121 -0
- package/dist/utilities/animator/animator_old/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator_old/animator.test.js +996 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.js +37 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.d.ts +38 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.js +208 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.js +439 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.d.ts +41 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.js +107 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.js +138 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.js +307 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.d.ts +37 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.js +170 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.test.js +340 -0
- package/dist/utilities/animator/index.d.ts +7 -0
- package/dist/utilities/animator/index.js +24 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.js +37 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.d.ts +32 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.js +168 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.js +431 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.d.ts +37 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.js +100 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.js +130 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.js +301 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.js +130 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.js +301 -0
- package/dist/utilities/animator/state-animation/state-animation.d.ts +33 -0
- package/dist/utilities/animator/state-animation/state-animation.js +146 -0
- package/dist/utilities/animator/state-animation/state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/state-animation.test.js +335 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.d.ts +32 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.js +168 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +431 -0
- package/dist/utilities/data-structures/vector-set/vector-set.d.ts +7 -0
- package/dist/utilities/data-structures/vector-set/vector-set.js +26 -0
- package/dist/utilities/delta-time/delta-time.d.ts +3 -0
- package/dist/utilities/delta-time/delta-time.js +10 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +6 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +55 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.js +100 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.d.ts +8 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.js +98 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +155 -0
- package/dist/utilities/grid-algorithms/position-to-grid-position-converter.d.ts +6 -0
- package/dist/utilities/grid-algorithms/position-to-grid-position-converter.js +17 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +18 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +129 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +254 -0
- package/dist/utilities/index.d.ts +6 -6
- package/dist/utilities/index.js +6 -6
- package/package.json +8 -6
|
@@ -2,7 +2,7 @@ import { TextData } from '../..';
|
|
|
2
2
|
import { PositionedChunk } from '../2-wrapping-text/rich-text-typewriter';
|
|
3
3
|
export declare class RichTextDataOutConverter {
|
|
4
4
|
static process(sheet: PositionedChunk[][]): TextData[];
|
|
5
|
-
private static
|
|
6
|
-
private static
|
|
7
|
-
private static
|
|
5
|
+
private static _mergeSameStyleChunks;
|
|
6
|
+
private static _trimEmptySpaces;
|
|
7
|
+
private static _chunksToTextData;
|
|
8
8
|
}
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RichTextDataOutConverter = void 0;
|
|
4
4
|
class RichTextDataOutConverter {
|
|
5
5
|
static process(sheet) {
|
|
6
|
-
sheet = this.
|
|
7
|
-
sheet = this.
|
|
8
|
-
return this.
|
|
6
|
+
sheet = this._mergeSameStyleChunks(sheet);
|
|
7
|
+
sheet = this._trimEmptySpaces(sheet);
|
|
8
|
+
return this._chunksToTextData(sheet);
|
|
9
9
|
}
|
|
10
|
-
static
|
|
10
|
+
static _mergeSameStyleChunks(sheet) {
|
|
11
11
|
return sheet.map(line => {
|
|
12
12
|
let mergedChunks = [];
|
|
13
13
|
let currentChunk;
|
|
@@ -42,7 +42,7 @@ class RichTextDataOutConverter {
|
|
|
42
42
|
return mergedChunks;
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
static
|
|
45
|
+
static _trimEmptySpaces(sheet) {
|
|
46
46
|
return sheet.map(line => {
|
|
47
47
|
if (line.length === 0) {
|
|
48
48
|
return [];
|
|
@@ -71,7 +71,7 @@ class RichTextDataOutConverter {
|
|
|
71
71
|
return line;
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
-
static
|
|
74
|
+
static _chunksToTextData(sheet) {
|
|
75
75
|
return sheet
|
|
76
76
|
.flatMap(line => line.map(positionedChunk => {
|
|
77
77
|
let phrase = {
|
|
@@ -14,7 +14,7 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
14
14
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' world'), position: new helpers_lib_1.Vector(50, 0) }
|
|
15
15
|
]
|
|
16
16
|
];
|
|
17
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
17
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_mergeSameStyleChunks'](chunks);
|
|
18
18
|
(0, vitest_1.expect)(result).toEqual([[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('hello world'), position: new helpers_lib_1.Vector(0, 0) }]]);
|
|
19
19
|
});
|
|
20
20
|
(0, vitest_1.test)('does not merge chunks with different styles', () => {
|
|
@@ -24,7 +24,7 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
24
24
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' world', { fontSize: 20 }), position: new helpers_lib_1.Vector(50, 0) }
|
|
25
25
|
]
|
|
26
26
|
];
|
|
27
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
27
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_mergeSameStyleChunks'](chunks);
|
|
28
28
|
(0, vitest_1.expect)(result).toEqual([
|
|
29
29
|
[
|
|
30
30
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('hello'), position: new helpers_lib_1.Vector(0, 0) },
|
|
@@ -43,7 +43,7 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
43
43
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' bar'), position: new helpers_lib_1.Vector(30, 20) }
|
|
44
44
|
]
|
|
45
45
|
];
|
|
46
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
46
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_mergeSameStyleChunks'](chunks);
|
|
47
47
|
(0, vitest_1.expect)(result).toEqual([
|
|
48
48
|
[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('hello world'), position: new helpers_lib_1.Vector(0, 0) }],
|
|
49
49
|
[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('foo bar'), position: new helpers_lib_1.Vector(0, 20) }]
|
|
@@ -58,24 +58,24 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
58
58
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' '), position: new helpers_lib_1.Vector(50, 0) }
|
|
59
59
|
]
|
|
60
60
|
];
|
|
61
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
61
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_trimEmptySpaces'](chunks);
|
|
62
62
|
(0, vitest_1.expect)(result).toEqual([[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('hello'), position: new helpers_lib_1.Vector(0, 0) }]]);
|
|
63
63
|
});
|
|
64
64
|
(0, vitest_1.test)('does not trim non-whitespace', () => {
|
|
65
65
|
let chunks = [[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('hello'), position: new helpers_lib_1.Vector(0, 0) }]];
|
|
66
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
66
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_trimEmptySpaces'](chunks);
|
|
67
67
|
(0, vitest_1.expect)(result).toEqual([[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('hello'), position: new helpers_lib_1.Vector(0, 0) }]]);
|
|
68
68
|
});
|
|
69
69
|
(0, vitest_1.test)('handles empty lines', () => {
|
|
70
70
|
let chunks = [];
|
|
71
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
71
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_trimEmptySpaces'](chunks);
|
|
72
72
|
(0, vitest_1.expect)(result).toEqual([]);
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
(0, vitest_1.describe)('chunksToTextData', () => {
|
|
76
76
|
(0, vitest_1.test)('single line with one chunk', () => {
|
|
77
77
|
let chunks = [[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('Hello'), position: new helpers_lib_1.Vector(0, 0) }]];
|
|
78
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
78
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_chunksToTextData'](chunks);
|
|
79
79
|
(0, vitest_1.expect)(result).toEqual([
|
|
80
80
|
{
|
|
81
81
|
text: 'Hello',
|
|
@@ -91,7 +91,7 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
91
91
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' World'), position: new helpers_lib_1.Vector(50, 0) }
|
|
92
92
|
]
|
|
93
93
|
];
|
|
94
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
94
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_chunksToTextData'](chunks);
|
|
95
95
|
(0, vitest_1.expect)(result).toEqual([
|
|
96
96
|
{
|
|
97
97
|
text: 'Hello',
|
|
@@ -113,7 +113,7 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
113
113
|
],
|
|
114
114
|
[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('012'), position: new helpers_lib_1.Vector(0, 24) }]
|
|
115
115
|
];
|
|
116
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
116
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_chunksToTextData'](chunks);
|
|
117
117
|
(0, vitest_1.expect)(result).toEqual([
|
|
118
118
|
{
|
|
119
119
|
text: '012',
|
|
@@ -134,17 +134,17 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
134
134
|
});
|
|
135
135
|
(0, vitest_1.test)('empty chunks array', () => {
|
|
136
136
|
let chunks = [];
|
|
137
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
137
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_chunksToTextData'](chunks);
|
|
138
138
|
(0, vitest_1.expect)(result).toEqual([]);
|
|
139
139
|
});
|
|
140
140
|
(0, vitest_1.test)('empty string array', () => {
|
|
141
141
|
let chunks = [[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(''), position: new helpers_lib_1.Vector(0, 0) }]];
|
|
142
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
142
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_chunksToTextData'](chunks);
|
|
143
143
|
(0, vitest_1.expect)(result).toEqual([]);
|
|
144
144
|
});
|
|
145
145
|
(0, vitest_1.test)('line with whitespace only chunks', () => {
|
|
146
146
|
let chunks = [[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' '), position: new helpers_lib_1.Vector(0, 0) }]];
|
|
147
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
147
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_chunksToTextData'](chunks);
|
|
148
148
|
(0, vitest_1.expect)(result).toEqual([]);
|
|
149
149
|
});
|
|
150
150
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as Pixi from 'pixi.js';
|
|
2
2
|
import { RichTextOptions } from '../rich-text';
|
|
3
3
|
import { TextData } from '.';
|
|
4
4
|
import { PartialTextOptions } from './process-steps/1-data-in-converter/pixi-text-style-converter';
|
|
@@ -10,7 +10,7 @@ export interface ChunkStyle {
|
|
|
10
10
|
readonly descent: number;
|
|
11
11
|
readonly spaceWidth: number;
|
|
12
12
|
readonly style: PartialTextOptions;
|
|
13
|
-
readonly pixiStyle:
|
|
13
|
+
readonly pixiStyle: Pixi.TextStyle;
|
|
14
14
|
}
|
|
15
15
|
export interface ChunkData {
|
|
16
16
|
readonly text: string;
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.MockPixiMeasureText = exports.CreateSampleChunkData = void 0;
|
|
27
27
|
const helpers_lib_1 = require("helpers-lib");
|
|
28
|
-
const
|
|
28
|
+
const Pixi = __importStar(require("pixi.js"));
|
|
29
29
|
const vitest_1 = require("vitest");
|
|
30
30
|
const rich_text_to_plane_text_1 = require("./rich-text-to-plane-text");
|
|
31
31
|
const CreateSampleChunkData = (text, options) => ({
|
|
@@ -34,7 +34,7 @@ const CreateSampleChunkData = (text, options) => ({
|
|
|
34
34
|
style: {
|
|
35
35
|
cacheKey: JSON.stringify(options) ?? 'empty',
|
|
36
36
|
style: { fontSize: options?.fontSize ?? 16, fontFamily: 'Arial' },
|
|
37
|
-
pixiStyle: new
|
|
37
|
+
pixiStyle: new Pixi.TextStyle({ fontSize: options?.fontSize ?? 16, fontFamily: 'Arial' }),
|
|
38
38
|
height: options?.fontSize ?? 16,
|
|
39
39
|
ascent: options?.fontSize ? options.fontSize - 4 : 12,
|
|
40
40
|
descent: 4,
|
|
@@ -44,10 +44,10 @@ const CreateSampleChunkData = (text, options) => ({
|
|
|
44
44
|
});
|
|
45
45
|
exports.CreateSampleChunkData = CreateSampleChunkData;
|
|
46
46
|
const MockPixiMeasureText = () => {
|
|
47
|
-
const
|
|
47
|
+
const OriginalMeasureText = Pixi.TextMetrics.measureText;
|
|
48
48
|
(0, vitest_1.beforeEach)(() => {
|
|
49
49
|
// Mock PIXI.TextMetrics.measureText to return predictable widths
|
|
50
|
-
|
|
50
|
+
Pixi.TextMetrics.measureText = vitest_1.vi.fn().mockImplementation((text, style) => ({
|
|
51
51
|
width: text.length * 10,
|
|
52
52
|
height: style.fontSize,
|
|
53
53
|
fontProperties: { ascent: +style.fontSize - 4, descent: 4 }
|
|
@@ -55,7 +55,7 @@ const MockPixiMeasureText = () => {
|
|
|
55
55
|
});
|
|
56
56
|
(0, vitest_1.afterEach)(() => {
|
|
57
57
|
// Restore original implementation
|
|
58
|
-
|
|
58
|
+
Pixi.TextMetrics.measureText = OriginalMeasureText;
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
61
|
exports.MockPixiMeasureText = MockPixiMeasureText;
|
|
@@ -7,7 +7,6 @@ const text_1 = require("./text");
|
|
|
7
7
|
class RichText extends container_1.Container {
|
|
8
8
|
constructor(text, options) {
|
|
9
9
|
super();
|
|
10
|
-
this.text = text;
|
|
11
10
|
let textData = helpers_1.RichTextToPlaneText.process(text, options);
|
|
12
11
|
textData.forEach(textDatum => new text_1.Text(textDatum.text, textDatum.style).setPosition(textDatum.position).displayParent(this).attach(this));
|
|
13
12
|
}
|
|
@@ -2,15 +2,14 @@ import { RGBColor, Vector } from 'helpers-lib';
|
|
|
2
2
|
import { Container } from '../../container';
|
|
3
3
|
import { PartialTextOptions } from './helpers/process-steps/1-data-in-converter/pixi-text-style-converter';
|
|
4
4
|
export declare class Text extends Container {
|
|
5
|
-
private
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
private _textMetrics
|
|
11
|
-
private get textMetrics();
|
|
5
|
+
private _pixiText;
|
|
6
|
+
private _strikethroughGraphics?;
|
|
7
|
+
private _pixiTextStyle;
|
|
8
|
+
private _text;
|
|
9
|
+
private _textMetricsVar?;
|
|
10
|
+
private get _textMetrics();
|
|
12
11
|
get ascent(): number;
|
|
13
|
-
constructor(text: string, partialOptions?: PartialTextOptions
|
|
12
|
+
constructor(text: string, partialOptions?: PartialTextOptions);
|
|
14
13
|
destroy(): void;
|
|
15
14
|
setAnchor(value: Vector): this;
|
|
16
15
|
get anchor(): Vector;
|
|
@@ -21,6 +20,6 @@ export declare class Text extends Container {
|
|
|
21
20
|
} | undefined): this;
|
|
22
21
|
setText(text: string): this;
|
|
23
22
|
setColor(color: RGBColor): this;
|
|
24
|
-
private
|
|
25
|
-
private
|
|
23
|
+
private _regeneratePixiText;
|
|
24
|
+
private _addStrikethroughToText;
|
|
26
25
|
}
|
|
@@ -25,32 +25,31 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Text = void 0;
|
|
27
27
|
const helpers_lib_1 = require("helpers-lib");
|
|
28
|
-
const
|
|
28
|
+
const Pixi = __importStar(require("pixi.js"));
|
|
29
29
|
const container_1 = require("../../container");
|
|
30
30
|
const pixi_text_style_converter_1 = require("./helpers/process-steps/1-data-in-converter/pixi-text-style-converter");
|
|
31
31
|
const FONT_SIZE_MULTIPLIER = 1;
|
|
32
32
|
const FONT_SIZE_MULTIPLIER_INVERSE = 1 / FONT_SIZE_MULTIPLIER;
|
|
33
33
|
class Text extends container_1.Container {
|
|
34
|
-
get
|
|
35
|
-
if (!this.
|
|
36
|
-
let pixiTextStyle = new
|
|
37
|
-
this.
|
|
34
|
+
get _textMetrics() {
|
|
35
|
+
if (!this._textMetricsVar) {
|
|
36
|
+
let pixiTextStyle = new Pixi.TextStyle(this._pixiTextStyle);
|
|
37
|
+
this._textMetricsVar = Pixi.TextMetrics.measureText(this._text, pixiTextStyle);
|
|
38
38
|
}
|
|
39
|
-
return this.
|
|
39
|
+
return this._textMetricsVar;
|
|
40
40
|
}
|
|
41
41
|
get ascent() {
|
|
42
|
-
return this.
|
|
42
|
+
return this._textMetrics.fontProperties.ascent;
|
|
43
43
|
}
|
|
44
44
|
constructor(text, partialOptions) {
|
|
45
45
|
super();
|
|
46
|
-
this.
|
|
47
|
-
this.pixiTextStyle = pixi_text_style_converter_1.TextStyleConverter.getPixiTextStyle(partialOptions);
|
|
46
|
+
this._pixiTextStyle = pixi_text_style_converter_1.TextStyleConverter.getPixiTextStyle(partialOptions);
|
|
48
47
|
this.setText(text);
|
|
49
48
|
}
|
|
50
49
|
destroy() {
|
|
51
50
|
if (!this.destroyed) {
|
|
52
|
-
!this.pixiText.destroyed && this.pixiText.destroy();
|
|
53
51
|
super.destroy();
|
|
52
|
+
!this._pixiText.destroyed && this._pixiText.destroy();
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
setAnchor(value) {
|
|
@@ -58,14 +57,14 @@ class Text extends container_1.Container {
|
|
|
58
57
|
return this;
|
|
59
58
|
}
|
|
60
59
|
get anchor() {
|
|
61
|
-
return new helpers_lib_1.Vector(this.
|
|
60
|
+
return new helpers_lib_1.Vector(this._pixiText.anchor.x, this._pixiText.anchor.y);
|
|
62
61
|
}
|
|
63
62
|
set anchor(value) {
|
|
64
|
-
this.
|
|
63
|
+
this._pixiText.anchor.set(value.x, value.y);
|
|
65
64
|
}
|
|
66
65
|
setPosition(value, options) {
|
|
67
66
|
if (options?.holdFrom) {
|
|
68
|
-
let blurDistance = this.
|
|
67
|
+
let blurDistance = this._pixiTextStyle.dropShadowDistance ?? 0;
|
|
69
68
|
let shadowOffset = new helpers_lib_1.Vector(options.holdFrom.x * blurDistance, options.holdFrom.y * blurDistance);
|
|
70
69
|
value = value.add(shadowOffset);
|
|
71
70
|
}
|
|
@@ -73,43 +72,43 @@ class Text extends container_1.Container {
|
|
|
73
72
|
return this;
|
|
74
73
|
}
|
|
75
74
|
setText(text) {
|
|
76
|
-
if (this.
|
|
77
|
-
this.
|
|
78
|
-
this.
|
|
75
|
+
if (this._text !== text) {
|
|
76
|
+
this._text = text;
|
|
77
|
+
this._regeneratePixiText();
|
|
79
78
|
}
|
|
80
79
|
return this;
|
|
81
80
|
}
|
|
82
81
|
setColor(color) {
|
|
83
82
|
let colorHex = helpers_lib_1.ColorHelper.rgbToHex(color);
|
|
84
|
-
if (this.
|
|
85
|
-
this.
|
|
86
|
-
this.
|
|
83
|
+
if (this._pixiTextStyle.fill !== colorHex) {
|
|
84
|
+
this._pixiTextStyle.fill = colorHex;
|
|
85
|
+
this._regeneratePixiText();
|
|
87
86
|
}
|
|
88
87
|
return this;
|
|
89
88
|
}
|
|
90
|
-
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
95
|
-
let pixiTextStyle = new
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
98
|
-
this.pixiContainer.addChild(this.
|
|
99
|
-
if (this.
|
|
100
|
-
this.
|
|
101
|
-
this.pixiContainer.addChild(this.
|
|
89
|
+
_regeneratePixiText() {
|
|
90
|
+
this._pixiText?.destroy();
|
|
91
|
+
this._strikethroughGraphics?.destroy();
|
|
92
|
+
this._strikethroughGraphics = undefined;
|
|
93
|
+
this._textMetricsVar = undefined;
|
|
94
|
+
let pixiTextStyle = new Pixi.TextStyle(this._pixiTextStyle);
|
|
95
|
+
this._pixiText = new Pixi.Text(this._text, pixiTextStyle);
|
|
96
|
+
this._pixiText.scale.set(FONT_SIZE_MULTIPLIER_INVERSE, FONT_SIZE_MULTIPLIER_INVERSE);
|
|
97
|
+
this.pixiContainer.addChild(this._pixiText);
|
|
98
|
+
if (this._pixiTextStyle.lineThrough) {
|
|
99
|
+
this._strikethroughGraphics = this._addStrikethroughToText(this._pixiText, this._pixiTextStyle.fill);
|
|
100
|
+
this.pixiContainer.addChild(this._strikethroughGraphics);
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
|
-
|
|
105
|
-
let textMetrics =
|
|
103
|
+
_addStrikethroughToText(pixiText, lineColor) {
|
|
104
|
+
let textMetrics = Pixi.TextMetrics.measureText(pixiText.text, pixiText.style);
|
|
106
105
|
let lineThickness = Math.max(1, Math.round(textMetrics.lineHeight * 0.07));
|
|
107
106
|
let lineOffset = (lineThickness % 2) * 0.5;
|
|
108
|
-
let strikethroughGraphics = new
|
|
107
|
+
let strikethroughGraphics = new Pixi.Graphics();
|
|
109
108
|
strikethroughGraphics.lineStyle(lineThickness, lineColor);
|
|
110
109
|
let currentY = 0;
|
|
111
110
|
textMetrics.lines.forEach((line, index) => {
|
|
112
|
-
let lineMetrics =
|
|
111
|
+
let lineMetrics = Pixi.TextMetrics.measureText(line, pixiText.style);
|
|
113
112
|
let lineY = Math.round(currentY +
|
|
114
113
|
(lineMetrics.fontProperties.ascent - lineMetrics.fontProperties.descent) * 0.6 +
|
|
115
114
|
lineMetrics.fontProperties.descent) + lineOffset;
|
package/dist/pixi/game.d.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { Reducer, Variable } from 'actions-lib';
|
|
2
2
|
import { RGBColor, Vector } from 'helpers-lib';
|
|
3
|
-
import * as
|
|
4
|
-
import {
|
|
3
|
+
import * as Pixi from 'pixi.js';
|
|
4
|
+
import { Container } from './display-object/container';
|
|
5
5
|
import { Camera } from './modules/CAMERA/camera';
|
|
6
|
-
|
|
6
|
+
import { AssetDefinition, SpriteDefinition } from './pixi-definitions';
|
|
7
7
|
export interface GameConfiguration {
|
|
8
|
-
screenResolution?: {
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
8
|
+
readonly screenResolution?: {
|
|
9
|
+
readonly width: number;
|
|
10
|
+
readonly height: number;
|
|
11
11
|
};
|
|
12
|
-
devMode
|
|
13
|
-
backgroundColor
|
|
12
|
+
readonly devMode: boolean;
|
|
13
|
+
readonly backgroundColor: RGBColor;
|
|
14
|
+
}
|
|
15
|
+
export interface GameSetupOptions {
|
|
16
|
+
readonly assetDefinitions: readonly AssetDefinition<string>[];
|
|
17
|
+
readonly spriteDefinitions: Readonly<Record<string, SpriteDefinition>>;
|
|
14
18
|
}
|
|
15
19
|
export declare class Game {
|
|
16
20
|
private static _instance;
|
|
@@ -19,20 +23,25 @@ export declare class Game {
|
|
|
19
23
|
private static _camera;
|
|
20
24
|
static get camera(): Camera;
|
|
21
25
|
static get time(): number;
|
|
26
|
+
private static _setupOptions;
|
|
22
27
|
readonly stage: Container;
|
|
23
|
-
readonly renderer:
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
28
|
+
readonly renderer: Pixi.Renderer;
|
|
29
|
+
readonly _screenSize: Variable<Vector>;
|
|
30
|
+
readonly screenSize: import("actions-lib").Notifier<Vector>;
|
|
31
|
+
getScreenSize(): Vector;
|
|
32
|
+
readonly _screenSizeCenter: Variable<Vector>;
|
|
33
|
+
readonly screenSizeCenter: import("actions-lib").Notifier<Vector>;
|
|
34
|
+
getScreenSizeCenter(): Vector;
|
|
26
35
|
readonly devMode: boolean;
|
|
27
|
-
private readonly
|
|
28
|
-
private readonly
|
|
29
|
-
private
|
|
36
|
+
private readonly _pixiApp;
|
|
37
|
+
private readonly _configuration;
|
|
38
|
+
private _screenPositionToStagePositionConverter;
|
|
30
39
|
constructor(partialConfiguration?: Partial<GameConfiguration>);
|
|
31
|
-
setup(
|
|
40
|
+
setup(setupOptions: GameSetupOptions): Promise<void>;
|
|
32
41
|
setResolution(resolution: number): void;
|
|
33
42
|
screenPositonToStagePosition(screenPosition: Vector): Vector;
|
|
34
43
|
setScreenPositionToStagePositionFunction(converterFunction: (screenPosition: Vector) => Vector): void;
|
|
35
44
|
resetScreenPositionToStagePositionFunction(): void;
|
|
36
|
-
destroyAsset(
|
|
37
|
-
private
|
|
45
|
+
destroyAsset(assetID: string): void;
|
|
46
|
+
private _setScreenSize;
|
|
38
47
|
}
|
package/dist/pixi/game.js
CHANGED
|
@@ -23,16 +23,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Game =
|
|
26
|
+
exports.Game = void 0;
|
|
27
27
|
const actions_lib_1 = require("actions-lib");
|
|
28
28
|
const helpers_lib_1 = require("helpers-lib");
|
|
29
|
-
const
|
|
29
|
+
const Pixi = __importStar(require("pixi.js"));
|
|
30
30
|
const update_cycle_1 = require("../game-entities/update-cycle");
|
|
31
|
-
const
|
|
31
|
+
const container_1 = require("./display-object/container");
|
|
32
32
|
const game_assets_1 = require("./helpers/game-assets");
|
|
33
33
|
const position_conversion_helper_1 = require("./helpers/position-conversion.helper");
|
|
34
34
|
const camera_1 = require("./modules/CAMERA/camera");
|
|
35
|
-
|
|
35
|
+
const pixi_definitions_1 = require("./pixi-definitions");
|
|
36
36
|
class Game {
|
|
37
37
|
static get instance() {
|
|
38
38
|
return this._instance;
|
|
@@ -42,81 +42,95 @@ class Game {
|
|
|
42
42
|
return this._camera;
|
|
43
43
|
}
|
|
44
44
|
static get time() {
|
|
45
|
-
return update_cycle_1.UpdateCycle
|
|
45
|
+
return update_cycle_1.UpdateCycle._time;
|
|
46
|
+
}
|
|
47
|
+
/** @internal */
|
|
48
|
+
static get setupOptions() {
|
|
49
|
+
return this._setupOptions;
|
|
50
|
+
}
|
|
51
|
+
getScreenSize() {
|
|
52
|
+
return this._screenSize.value;
|
|
53
|
+
}
|
|
54
|
+
getScreenSizeCenter() {
|
|
55
|
+
return this._screenSizeCenter.value;
|
|
46
56
|
}
|
|
47
57
|
constructor(partialConfiguration) {
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
58
|
+
this._screenSize = new actions_lib_1.Variable(helpers_lib_1.Vector.zero);
|
|
59
|
+
this.screenSize = this._screenSize.notifier;
|
|
60
|
+
this._screenSizeCenter = new actions_lib_1.Variable(helpers_lib_1.Vector.zero);
|
|
61
|
+
this.screenSizeCenter = this._screenSizeCenter.notifier;
|
|
50
62
|
this.devMode = false;
|
|
51
63
|
this.resetScreenPositionToStagePositionFunction();
|
|
52
64
|
if (Game._instance) {
|
|
53
65
|
throw new Error('There can be only one Game instance!');
|
|
54
66
|
}
|
|
55
67
|
else {
|
|
56
|
-
this.
|
|
68
|
+
this._configuration = {
|
|
57
69
|
screenResolution: undefined,
|
|
58
70
|
devMode: false,
|
|
59
71
|
backgroundColor: helpers_lib_1.ColorHelper.black,
|
|
60
72
|
...partialConfiguration
|
|
61
73
|
};
|
|
62
|
-
this.devMode = this.
|
|
63
|
-
this.
|
|
64
|
-
backgroundColor: this.
|
|
74
|
+
this.devMode = this._configuration.devMode || false;
|
|
75
|
+
this._pixiApp = new Pixi.Application({
|
|
76
|
+
backgroundColor: this._configuration.backgroundColor,
|
|
65
77
|
autoStart: false,
|
|
66
|
-
antialias:
|
|
67
|
-
resolution:
|
|
68
|
-
width: this.
|
|
69
|
-
height: this.
|
|
70
|
-
resizeTo: this.
|
|
78
|
+
antialias: pixi_definitions_1.DEFAULT_RESOLUTION < 1.5,
|
|
79
|
+
resolution: pixi_definitions_1.DEFAULT_RESOLUTION,
|
|
80
|
+
width: this._configuration.screenResolution?.width,
|
|
81
|
+
height: this._configuration.screenResolution?.height,
|
|
82
|
+
resizeTo: this._configuration.screenResolution === undefined ? window : undefined
|
|
71
83
|
});
|
|
72
84
|
}
|
|
73
85
|
}
|
|
74
|
-
async setup(
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
async setup(setupOptions) {
|
|
87
|
+
Game._setupOptions = setupOptions;
|
|
88
|
+
document.body.appendChild(this._pixiApp.view);
|
|
89
|
+
await Promise.all([game_assets_1.GameAssets.loadGameAssets(setupOptions.assetDefinitions)]);
|
|
77
90
|
Game._instance = this;
|
|
78
91
|
// @ts-ignore
|
|
79
|
-
this.stage = new
|
|
92
|
+
this.stage = new container_1.Container().attachToRoot();
|
|
80
93
|
// @ts-ignore
|
|
81
|
-
this.stage.pixiContainer = this.
|
|
94
|
+
this.stage.pixiContainer = this._pixiApp.stage;
|
|
82
95
|
// @ts-ignore
|
|
83
|
-
this.renderer = this.
|
|
84
|
-
this.
|
|
96
|
+
this.renderer = this._pixiApp.renderer;
|
|
97
|
+
this._setScreenSize();
|
|
85
98
|
this.stage.sortableChildren = true;
|
|
86
99
|
// pixi devtools configuration
|
|
87
100
|
// @ts-ignore
|
|
88
|
-
globalThis.__PIXI_APP__ = this.
|
|
101
|
+
globalThis.__PIXI_APP__ = this._pixiApp;
|
|
89
102
|
window.addEventListener('resize', _ => {
|
|
90
103
|
// Wait until pixijs adjusts the screen size
|
|
91
|
-
setTimeout(() => this.
|
|
104
|
+
setTimeout(() => this._setScreenSize());
|
|
92
105
|
});
|
|
93
106
|
Game._camera = new camera_1.Camera();
|
|
94
107
|
// Reminder: If the game should be paused or destroyed, all promises has to be resolved, that relies on update cycle
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
97
|
-
update_cycle_1.UpdateCycle.triggerUpdateTick(this.
|
|
108
|
+
this._pixiApp.start();
|
|
109
|
+
this._pixiApp.ticker.add(() => {
|
|
110
|
+
update_cycle_1.UpdateCycle.triggerUpdateTick(this._pixiApp.ticker.deltaMS);
|
|
98
111
|
});
|
|
99
112
|
}
|
|
100
113
|
setResolution(resolution) {
|
|
101
|
-
this.
|
|
102
|
-
this.
|
|
114
|
+
this._pixiApp.renderer.resolution = resolution;
|
|
115
|
+
this._pixiApp.renderer.resize(this._pixiApp.screen.width, this._pixiApp.screen.height);
|
|
103
116
|
}
|
|
104
117
|
screenPositonToStagePosition(screenPosition) {
|
|
105
|
-
let adjustedScreenPositionWithScale = position_conversion_helper_1.PositionConversionHelper.includeScaleInScreenPosition(screenPosition, Game.instance.stage.scale, Game.instance.
|
|
106
|
-
return this.
|
|
118
|
+
let adjustedScreenPositionWithScale = position_conversion_helper_1.PositionConversionHelper.includeScaleInScreenPosition(screenPosition, Game.instance.stage.scale, Game.instance.getScreenSizeCenter());
|
|
119
|
+
return this._screenPositionToStagePositionConverter(adjustedScreenPositionWithScale);
|
|
107
120
|
}
|
|
108
121
|
setScreenPositionToStagePositionFunction(converterFunction) {
|
|
109
|
-
this.
|
|
122
|
+
this._screenPositionToStagePositionConverter = converterFunction;
|
|
110
123
|
}
|
|
111
124
|
resetScreenPositionToStagePositionFunction() {
|
|
112
|
-
this.
|
|
125
|
+
this._screenPositionToStagePositionConverter = (screenPosition) => screenPosition;
|
|
113
126
|
}
|
|
114
|
-
destroyAsset(
|
|
115
|
-
game_assets_1.GameAssets.destroyAsset(
|
|
127
|
+
destroyAsset(assetID) {
|
|
128
|
+
game_assets_1.GameAssets.destroyAsset(assetID);
|
|
116
129
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this.
|
|
130
|
+
_setScreenSize() {
|
|
131
|
+
let screenSize = new helpers_lib_1.Vector(this._pixiApp.screen.width, this._pixiApp.screen.height);
|
|
132
|
+
this._screenSize.value = screenSize;
|
|
133
|
+
this._screenSizeCenter.value = screenSize.multiplyNumber(0.5).round();
|
|
120
134
|
}
|
|
121
135
|
}
|
|
122
136
|
exports.Game = Game;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { AssetDefinition } from '
|
|
1
|
+
import * as Pixi from 'pixi.js';
|
|
2
|
+
import { AssetDefinition } from '../pixi-definitions';
|
|
3
3
|
declare module 'pixi.js' {
|
|
4
4
|
interface Texture {
|
|
5
5
|
id: string;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
export declare class GameAssets {
|
|
9
|
-
private static
|
|
10
|
-
private static
|
|
9
|
+
private static _resources;
|
|
10
|
+
private static _anonymouseAssetNameCounter;
|
|
11
11
|
static getAsset<T>(name: string): T;
|
|
12
|
-
static insertAsset(asset:
|
|
12
|
+
static insertAsset(asset: Pixi.Texture, name?: string): string;
|
|
13
13
|
static destroyAsset(name: string): void;
|
|
14
14
|
static loadGameAssets(assetDefinitions: readonly AssetDefinition[]): Promise<void>;
|
|
15
15
|
}
|