bard-legends-framework 0.11.0 → 0.12.1
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 -2
- package/dist/game-entities/controller/controller.js +8 -8
- package/dist/game-entities/controller/controller.test.js +2 -2
- package/dist/game-entities/entity/entity.d.ts +7 -7
- package/dist/game-entities/entity/entity.js +18 -12
- package/dist/game-entities/entity/entity.test.js +93 -30
- package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +3 -3
- package/dist/game-entities/entity/helpers/entity-store.helper.js +12 -12
- package/dist/game-entities/entity/helpers/entity-store.helper.test.js +11 -11
- package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +6 -6
- package/dist/game-entities/entity/helpers/entity-views.helper.js +25 -22
- package/dist/game-entities/entity/singleton-entity.test.js +9 -4
- 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 -1
- package/dist/game-entities/index.js +3 -3
- package/dist/game-entities/scene/scene.d.ts +13 -13
- package/dist/game-entities/scene/scene.js +41 -46
- package/dist/game-entities/scene/scene.test.js +95 -37
- package/dist/game-entities/service/service.d.ts +1 -4
- package/dist/game-entities/service/service.js +12 -13
- package/dist/game-entities/service/service.test.js +33 -12
- package/dist/game-entities/unit-test.helper.js +1 -1
- package/dist/game-entities/update-cycle.d.ts +7 -17
- package/dist/game-entities/update-cycle.js +25 -19
- package/dist/game-entities/view/view.d.ts +6 -6
- package/dist/game-entities/view/view.js +15 -21
- package/dist/game-entities/view/view.test.js +40 -9
- package/dist/physics/entity-types/immovable-physics-entity.d.ts +1 -1
- package/dist/physics/entity-types/immovable-physics-entity.js +4 -4
- package/dist/physics/entity-types/movable-entity.d.ts +1 -1
- package/dist/physics/entity-types/movable-entity.js +2 -2
- package/dist/physics/entity-types/movable-physics-entity.d.ts +8 -8
- package/dist/physics/entity-types/movable-physics-entity.js +27 -27
- package/dist/physics/entity-types/physics-entity.d.ts +10 -14
- package/dist/physics/entity-types/physics-entity.js +27 -26
- 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 +19 -19
- 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 +10 -10
- 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 +27 -26
- 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 +12 -12
- 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 +12 -12
- 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 +43 -42
- 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/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 +2 -2
- package/dist/pixi/components/mouse-wheel-listener.ui.js +11 -11
- 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 -25
- package/dist/pixi/display-object/container-attributes.js +26 -26
- package/dist/pixi/display-object/container.d.ts +3 -3
- package/dist/pixi/display-object/container.js +2 -2
- 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 +26 -25
- 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 +20 -15
- package/dist/pixi/game.js +40 -35
- 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/251views/camera.view.d.ts +17 -16
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +49 -48
- 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 +2 -2
- package/dist/pixi/services/keyboard/keyboard.js +9 -9
- package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +10 -10
- package/dist/pixi/services/mouse/mouse-target-focus.service.js +28 -28
- package/dist/pixi/services/mouse/mouse.service.d.ts +1 -1
- package/dist/pixi/services/mouse/mouse.service.js +5 -5
- 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.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 +14 -6
- package/dist/utilities/animator/animations.js +15 -11
- 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 +2 -3
- package/dist/utilities/animator/animator.js +66 -59
- 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.js +89 -28
- 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 +6 -6
- package/dist/utilities/animator/index.js +6 -6
- 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.test.js +30 -30
- package/dist/utilities/animator/state-animation/state-animation.js +7 -7
- package/dist/utilities/animator/state-animation/state-animation.test.js +24 -24
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +30 -30
- package/dist/utilities/data-structures/vector-set/vector-set.d.ts +1 -1
- package/dist/utilities/data-structures/vector-set/vector-set.js +5 -5
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +1 -1
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +5 -5
- package/dist/utilities/grid-algorithms/path-finder/path-finder.js +21 -21
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +9 -9
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +14 -14
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +43 -43
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +21 -21
- package/package.json +7 -5
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Attachable, SingleEvent } from 'actions-lib';
|
|
2
|
+
import { AnimatorAnimation } from '../animations';
|
|
3
|
+
export interface AnimationState {
|
|
4
|
+
duration: number;
|
|
5
|
+
elapsedTime: number;
|
|
6
|
+
startingValue: number;
|
|
7
|
+
targetValue: number;
|
|
8
|
+
loop: boolean;
|
|
9
|
+
completeAnimationsHandling: CompleteAnimationsHandlingType;
|
|
10
|
+
}
|
|
11
|
+
export declare enum ReAnimateHandlingType {
|
|
12
|
+
throwError = "throwError",
|
|
13
|
+
ignoreNewAnimation = "ignoreNewAnimation",
|
|
14
|
+
completePrevious = "completePrevious"
|
|
15
|
+
}
|
|
16
|
+
export declare enum CompleteAnimationsHandlingType {
|
|
17
|
+
returnToOriginal = "returnToOriginal",
|
|
18
|
+
stayInCurrentState = "stayInCurrentState",
|
|
19
|
+
jumpToEnd = "jumpToEnd"
|
|
20
|
+
}
|
|
21
|
+
export interface AnimationOptions {
|
|
22
|
+
duration?: number;
|
|
23
|
+
animation?: AnimatorAnimation;
|
|
24
|
+
loop?: boolean;
|
|
25
|
+
reAnimateHandling?: ReAnimateHandlingType;
|
|
26
|
+
completeAnimationsHandling?: CompleteAnimationsHandlingType;
|
|
27
|
+
}
|
|
28
|
+
export declare class Animator<T extends Record<string, any>> extends Attachable {
|
|
29
|
+
private target;
|
|
30
|
+
private static animatedObjects;
|
|
31
|
+
private effectOn;
|
|
32
|
+
private defaultDuration;
|
|
33
|
+
private defaultAnimation;
|
|
34
|
+
private defaultLoop;
|
|
35
|
+
private defaultReAnimateHandling;
|
|
36
|
+
private defaultCompleteAnimationsHandling;
|
|
37
|
+
private onChangeCallback?;
|
|
38
|
+
private onCompleteCallback?;
|
|
39
|
+
private running;
|
|
40
|
+
private propertyStates;
|
|
41
|
+
private updateCycleSubscription;
|
|
42
|
+
get animating(): boolean;
|
|
43
|
+
constructor(target: T, effectOn: string | string[], options?: AnimationOptions);
|
|
44
|
+
onChange(callback: (target: T) => void): Animator<T>;
|
|
45
|
+
onComplete(callback: (key: string, value: number) => void): Animator<T>;
|
|
46
|
+
destroy(): void;
|
|
47
|
+
getAnimationStateOfKey(key: string): AnimationState | undefined;
|
|
48
|
+
pauseAnimations(): void;
|
|
49
|
+
resumeAnimations(): void;
|
|
50
|
+
completeAnimations(completeAnimationsHandling?: CompleteAnimationsHandlingType): void;
|
|
51
|
+
set(values: Record<string, any>): void;
|
|
52
|
+
animate(values: Record<string, any>, options?: AnimationOptions): SingleEvent;
|
|
53
|
+
private completeAnimationOfProperty;
|
|
54
|
+
private getCompleteFunctionOfOngoingAnimations;
|
|
55
|
+
private update;
|
|
56
|
+
private subscribeUpdateCycle;
|
|
57
|
+
private unsubscribeUpdateCycle;
|
|
58
|
+
private checkPropertyValidity;
|
|
59
|
+
private triggerOnChange;
|
|
60
|
+
}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Animator = exports.CompleteAnimationsHandlingType = exports.ReAnimateHandlingType = void 0;
|
|
4
|
+
const actions_lib_1 = require("actions-lib");
|
|
5
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
6
|
+
const update_cycle_1 = require("../../../game-entities/update-cycle");
|
|
7
|
+
const animations_1 = require("../animations");
|
|
8
|
+
var ReAnimateHandlingType;
|
|
9
|
+
(function (ReAnimateHandlingType) {
|
|
10
|
+
ReAnimateHandlingType["throwError"] = "throwError";
|
|
11
|
+
ReAnimateHandlingType["ignoreNewAnimation"] = "ignoreNewAnimation";
|
|
12
|
+
ReAnimateHandlingType["completePrevious"] = "completePrevious";
|
|
13
|
+
})(ReAnimateHandlingType || (exports.ReAnimateHandlingType = ReAnimateHandlingType = {}));
|
|
14
|
+
var CompleteAnimationsHandlingType;
|
|
15
|
+
(function (CompleteAnimationsHandlingType) {
|
|
16
|
+
CompleteAnimationsHandlingType["returnToOriginal"] = "returnToOriginal";
|
|
17
|
+
CompleteAnimationsHandlingType["stayInCurrentState"] = "stayInCurrentState";
|
|
18
|
+
CompleteAnimationsHandlingType["jumpToEnd"] = "jumpToEnd";
|
|
19
|
+
})(CompleteAnimationsHandlingType || (exports.CompleteAnimationsHandlingType = CompleteAnimationsHandlingType = {}));
|
|
20
|
+
const DEFAULT_DURATION = 200;
|
|
21
|
+
const DEFAULT_ANIMATION = animations_1.Animations.lineer;
|
|
22
|
+
const DEFAULT_LOOP = false;
|
|
23
|
+
const DEFAULT_RE_ANIMATE_HANDLING = ReAnimateHandlingType.throwError;
|
|
24
|
+
const DEFAULT_COMPLETE_ANIMATIONS_HANDLING = CompleteAnimationsHandlingType.stayInCurrentState;
|
|
25
|
+
class Animator extends actions_lib_1.Attachable {
|
|
26
|
+
static { this.animatedObjects = new Map(); }
|
|
27
|
+
get animating() {
|
|
28
|
+
return this.propertyStates.size > 0;
|
|
29
|
+
}
|
|
30
|
+
constructor(target, effectOn, options = {}) {
|
|
31
|
+
super();
|
|
32
|
+
this.target = target;
|
|
33
|
+
this.effectOn = new Set();
|
|
34
|
+
this.running = true;
|
|
35
|
+
this.propertyStates = new Map();
|
|
36
|
+
if (!helpers_lib_1.Comparator.isObject(target)) {
|
|
37
|
+
this.attachToRoot();
|
|
38
|
+
throw new Error(`Animator: target is not an object! Target: "${target}"`);
|
|
39
|
+
}
|
|
40
|
+
this.effectOn = helpers_lib_1.Comparator.isArray(effectOn) ? new Set(effectOn) : new Set([effectOn]);
|
|
41
|
+
let animatedObjectProperties = Animator.animatedObjects.get(target);
|
|
42
|
+
if (!animatedObjectProperties) {
|
|
43
|
+
animatedObjectProperties = new Set();
|
|
44
|
+
Animator.animatedObjects.set(target, animatedObjectProperties);
|
|
45
|
+
}
|
|
46
|
+
for (let key of this.effectOn) {
|
|
47
|
+
if (animatedObjectProperties.has(key)) {
|
|
48
|
+
this.attachToRoot();
|
|
49
|
+
throw new Error(`Animator: target property is already animated! Target: "${JSON.stringify(target, undefined, 2)}", Property: "${key}"`);
|
|
50
|
+
}
|
|
51
|
+
animatedObjectProperties.add(key);
|
|
52
|
+
}
|
|
53
|
+
this.defaultDuration = options.duration ?? DEFAULT_DURATION;
|
|
54
|
+
this.defaultAnimation = options.animation ?? DEFAULT_ANIMATION;
|
|
55
|
+
this.defaultLoop = options.loop ?? DEFAULT_LOOP;
|
|
56
|
+
this.defaultReAnimateHandling = options.reAnimateHandling ?? DEFAULT_RE_ANIMATE_HANDLING;
|
|
57
|
+
this.defaultCompleteAnimationsHandling = options.completeAnimationsHandling ?? DEFAULT_COMPLETE_ANIMATIONS_HANDLING;
|
|
58
|
+
for (let key of this.effectOn) {
|
|
59
|
+
if (!helpers_lib_1.Comparator.hasProperty(target, key)) {
|
|
60
|
+
this.attachToRoot();
|
|
61
|
+
throw new Error(`Animator: target does not have property. Target property: "${key}"`);
|
|
62
|
+
}
|
|
63
|
+
else if (!helpers_lib_1.Comparator.isNumber(target[key])) {
|
|
64
|
+
this.attachToRoot();
|
|
65
|
+
throw new Error(`Animator: target property is not a number. Target property: "${key}"`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
onChange(callback) {
|
|
70
|
+
if (this.onChangeCallback) {
|
|
71
|
+
this.attachToRoot();
|
|
72
|
+
throw new Error('Animator: onChangeCallback is already set!');
|
|
73
|
+
}
|
|
74
|
+
this.onChangeCallback = callback;
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
onComplete(callback) {
|
|
78
|
+
if (this.onCompleteCallback) {
|
|
79
|
+
this.attachToRoot();
|
|
80
|
+
throw new Error('Animator: onCompleteCallback is already set!');
|
|
81
|
+
}
|
|
82
|
+
this.onCompleteCallback = callback;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
destroy() {
|
|
86
|
+
if (!this.destroyed) {
|
|
87
|
+
super.destroy();
|
|
88
|
+
this.onChangeCallback = undefined;
|
|
89
|
+
this.onCompleteCallback = undefined;
|
|
90
|
+
this.defaultAnimation = DEFAULT_ANIMATION;
|
|
91
|
+
this.propertyStates.clear();
|
|
92
|
+
let animatedObjectProperties = Animator.animatedObjects.get(this.target);
|
|
93
|
+
for (let key of this.effectOn) {
|
|
94
|
+
animatedObjectProperties.delete(key);
|
|
95
|
+
}
|
|
96
|
+
if (animatedObjectProperties.size <= 0) {
|
|
97
|
+
Animator.animatedObjects.delete(this.target);
|
|
98
|
+
}
|
|
99
|
+
this.target = undefined;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
getAnimationStateOfKey(key) {
|
|
103
|
+
let propertyState = this.propertyStates.get(key);
|
|
104
|
+
if (propertyState) {
|
|
105
|
+
return {
|
|
106
|
+
duration: propertyState.duration,
|
|
107
|
+
elapsedTime: propertyState.elapsedTime,
|
|
108
|
+
startingValue: propertyState.startingValue,
|
|
109
|
+
targetValue: propertyState.targetValue,
|
|
110
|
+
loop: propertyState.loop,
|
|
111
|
+
completeAnimationsHandling: propertyState.completeAnimationsHandling
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
pauseAnimations() {
|
|
116
|
+
this.running = false;
|
|
117
|
+
}
|
|
118
|
+
resumeAnimations() {
|
|
119
|
+
this.running = true;
|
|
120
|
+
}
|
|
121
|
+
completeAnimations(completeAnimationsHandling) {
|
|
122
|
+
let triggerOnChange = false;
|
|
123
|
+
for (let [key, value] of this.propertyStates) {
|
|
124
|
+
let completeAnimationsHandlingFinal = completeAnimationsHandling ?? value.completeAnimationsHandling;
|
|
125
|
+
if (completeAnimationsHandlingFinal === CompleteAnimationsHandlingType.returnToOriginal) {
|
|
126
|
+
if (this.target[key] !== value.startingValue) {
|
|
127
|
+
triggerOnChange = true;
|
|
128
|
+
this.target[key] = value.startingValue;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else if (completeAnimationsHandlingFinal === CompleteAnimationsHandlingType.jumpToEnd) {
|
|
132
|
+
if (this.target[key] !== value.targetValue) {
|
|
133
|
+
triggerOnChange = true;
|
|
134
|
+
this.target[key] = value.targetValue;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
this.completeAnimationOfProperty(value.propertyName, value.completionCallback);
|
|
138
|
+
}
|
|
139
|
+
triggerOnChange && this.triggerOnChange();
|
|
140
|
+
}
|
|
141
|
+
set(values) {
|
|
142
|
+
let keys = Object.keys(values);
|
|
143
|
+
for (let i = 0; i < keys.length; i++) {
|
|
144
|
+
this.checkPropertyValidity(keys[i]);
|
|
145
|
+
}
|
|
146
|
+
let complete = this.getCompleteFunctionOfOngoingAnimations(values);
|
|
147
|
+
let triggerOnChange = false;
|
|
148
|
+
for (let i = 0; i < keys.length; i++) {
|
|
149
|
+
let key = keys[i];
|
|
150
|
+
triggerOnChange = triggerOnChange || this.target[key] !== values[key];
|
|
151
|
+
this.target[key] = values[key];
|
|
152
|
+
}
|
|
153
|
+
complete();
|
|
154
|
+
triggerOnChange && this.triggerOnChange();
|
|
155
|
+
}
|
|
156
|
+
animate(values, options = {}) {
|
|
157
|
+
if (this.destroyed) {
|
|
158
|
+
return actions_lib_1.SingleEvent.instant();
|
|
159
|
+
}
|
|
160
|
+
let valueKeys = Object.keys(values);
|
|
161
|
+
for (let i = 0; i < valueKeys.length; i++) {
|
|
162
|
+
this.checkPropertyValidity(valueKeys[i]);
|
|
163
|
+
}
|
|
164
|
+
let complete = this.getCompleteFunctionOfOngoingAnimations(values, options.reAnimateHandling);
|
|
165
|
+
// Recalculate valueKeys after checkOngoingAnimations, as it may have deleted some keys
|
|
166
|
+
valueKeys = Object.keys(values);
|
|
167
|
+
this.subscribeUpdateCycle();
|
|
168
|
+
let animationEvent = actions_lib_1.SingleEvent.create(resolve => {
|
|
169
|
+
let ongoingKeys = new Set(valueKeys);
|
|
170
|
+
let animationDone = (key) => {
|
|
171
|
+
ongoingKeys.delete(key);
|
|
172
|
+
if (ongoingKeys.size <= 0) {
|
|
173
|
+
resolve();
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
for (let i = 0; i < valueKeys.length; i++) {
|
|
177
|
+
let key = valueKeys[i];
|
|
178
|
+
let duration = options.duration ?? this.defaultDuration;
|
|
179
|
+
let animation = options.animation ?? this.defaultAnimation;
|
|
180
|
+
let loop = options.loop ?? this.defaultLoop;
|
|
181
|
+
let completeAnimationsHandling = options.completeAnimationsHandling ?? this.defaultCompleteAnimationsHandling;
|
|
182
|
+
let startingValue = this.target[key];
|
|
183
|
+
let targetValue = values[key];
|
|
184
|
+
if (startingValue === targetValue && !loop) {
|
|
185
|
+
animationDone(key);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
animation.start();
|
|
189
|
+
try {
|
|
190
|
+
this.propertyStates.set(key, {
|
|
191
|
+
propertyName: key,
|
|
192
|
+
duration,
|
|
193
|
+
animation,
|
|
194
|
+
elapsedTime: 0,
|
|
195
|
+
startingValue,
|
|
196
|
+
targetValue,
|
|
197
|
+
loop,
|
|
198
|
+
completeAnimationsHandling,
|
|
199
|
+
completionCallback: () => animationDone(key)
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
animationDone(key);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
complete();
|
|
209
|
+
return animationEvent;
|
|
210
|
+
}
|
|
211
|
+
completeAnimationOfProperty(propertyName, completionCallback) {
|
|
212
|
+
let currentState = this.target[propertyName];
|
|
213
|
+
let propertyState = this.propertyStates.get(propertyName);
|
|
214
|
+
if (propertyState?.completionCallback === completionCallback) {
|
|
215
|
+
this.propertyStates.delete(propertyName);
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
completionCallback();
|
|
219
|
+
this.onCompleteCallback?.(propertyName, currentState);
|
|
220
|
+
}
|
|
221
|
+
catch (e) {
|
|
222
|
+
console.error('Animator:', e);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
getCompleteFunctionOfOngoingAnimations(values, reAnimateHandling) {
|
|
226
|
+
reAnimateHandling = reAnimateHandling ?? this.defaultReAnimateHandling;
|
|
227
|
+
let keys = Object.keys(values);
|
|
228
|
+
let completionInfos = [];
|
|
229
|
+
for (let i = 0; i < keys.length; i++) {
|
|
230
|
+
let key = keys[i];
|
|
231
|
+
let propertyState = this.propertyStates.get(key);
|
|
232
|
+
if (propertyState) {
|
|
233
|
+
if (reAnimateHandling === ReAnimateHandlingType.throwError) {
|
|
234
|
+
throw new Error(`Animator: property is already being animated. Property: "${key}"`);
|
|
235
|
+
}
|
|
236
|
+
else if (reAnimateHandling === ReAnimateHandlingType.ignoreNewAnimation) {
|
|
237
|
+
delete values[key];
|
|
238
|
+
}
|
|
239
|
+
else if (reAnimateHandling === ReAnimateHandlingType.completePrevious) {
|
|
240
|
+
completionInfos.push({
|
|
241
|
+
propertyName: propertyState.propertyName,
|
|
242
|
+
completionCallback: propertyState.completionCallback
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return () => {
|
|
248
|
+
for (let i = 0; i < completionInfos.length; i++) {
|
|
249
|
+
let completionInfo = completionInfos[i];
|
|
250
|
+
this.completeAnimationOfProperty(completionInfo.propertyName, completionInfo.completionCallback);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
update(delta) {
|
|
255
|
+
if (this.running && !this.destroyed) {
|
|
256
|
+
let triggerOnChange = this.propertyStates.size;
|
|
257
|
+
let propertyStatesToComplete = [];
|
|
258
|
+
for (let [key, value] of this.propertyStates) {
|
|
259
|
+
value.elapsedTime += delta;
|
|
260
|
+
let animationIsCompete = value.elapsedTime >= value.duration;
|
|
261
|
+
if (animationIsCompete) {
|
|
262
|
+
if (value.loop) {
|
|
263
|
+
value.animation.start();
|
|
264
|
+
value.elapsedTime -= value.duration;
|
|
265
|
+
animationIsCompete = false;
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
if (value.completeAnimationsHandling === CompleteAnimationsHandlingType.returnToOriginal) {
|
|
269
|
+
this.target[key] = value.startingValue;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
this.target[key] = value.targetValue;
|
|
273
|
+
}
|
|
274
|
+
// Do not complete inside the for loop, completion can start a new animation which will put the loop into infinite loop
|
|
275
|
+
propertyStatesToComplete.push(value);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (!animationIsCompete) {
|
|
279
|
+
let multiplier = value.animation.multiplierFunction(value.elapsedTime / value.duration);
|
|
280
|
+
let relativeTarget = value.targetValue - value.startingValue;
|
|
281
|
+
this.target[key] = relativeTarget * multiplier + value.startingValue;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
for (let value of propertyStatesToComplete) {
|
|
285
|
+
this.completeAnimationOfProperty(value.propertyName, value.completionCallback);
|
|
286
|
+
}
|
|
287
|
+
triggerOnChange && this.triggerOnChange();
|
|
288
|
+
if (this.propertyStates.size <= 0) {
|
|
289
|
+
this.unsubscribeUpdateCycle();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
subscribeUpdateCycle() {
|
|
294
|
+
if (!this.updateCycleSubscription && !this.destroyed) {
|
|
295
|
+
this.updateCycleSubscription = update_cycle_1.UpdateCycle.beforeSceneUpdateAction
|
|
296
|
+
.subscribe(update => {
|
|
297
|
+
try {
|
|
298
|
+
this.update(update.delta);
|
|
299
|
+
}
|
|
300
|
+
catch (e) {
|
|
301
|
+
console.error('Animator:', e);
|
|
302
|
+
for (let value of this.propertyStates.values()) {
|
|
303
|
+
try {
|
|
304
|
+
value.completionCallback();
|
|
305
|
+
}
|
|
306
|
+
catch (err) {
|
|
307
|
+
console.error('Animator:', err);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
this.propertyStates = new Map();
|
|
311
|
+
this.unsubscribeUpdateCycle();
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
.attachToRoot();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
unsubscribeUpdateCycle() {
|
|
318
|
+
this.updateCycleSubscription?.destroy();
|
|
319
|
+
this.updateCycleSubscription = undefined;
|
|
320
|
+
}
|
|
321
|
+
checkPropertyValidity(key) {
|
|
322
|
+
if (!this.effectOn.has(key)) {
|
|
323
|
+
this.attachToRoot();
|
|
324
|
+
throw new Error(`Animator: not effected property is tried to update. Key: "${key}", EffectOn: "${this.effectOn}"`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
triggerOnChange() {
|
|
328
|
+
try {
|
|
329
|
+
this.onChangeCallback?.(this.target);
|
|
330
|
+
}
|
|
331
|
+
catch (e) {
|
|
332
|
+
console.error('Animator:', e);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
exports.Animator = Animator;
|
|
337
|
+
//# sourceMappingURL=animator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const game_entities_1 = require("../../../game-entities");
|
|
6
|
+
const animator_1 = require("./animator");
|
|
7
|
+
vitest_1.describe.skipIf(!process.env.MANUAL)('Performance Tests', () => {
|
|
8
|
+
(0, vitest_1.test)('no anim single', async () => {
|
|
9
|
+
await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
|
|
10
|
+
return new Promise(resolve => {
|
|
11
|
+
let obj = { x: 0, y: 0 };
|
|
12
|
+
new animator_1.Animator(obj, 'x', {
|
|
13
|
+
duration: 1
|
|
14
|
+
}).attachToRoot();
|
|
15
|
+
resolve();
|
|
16
|
+
});
|
|
17
|
+
// 18.053100109100342
|
|
18
|
+
}, { sampleCount: 100, repetationCount: 10000 });
|
|
19
|
+
}, 60000);
|
|
20
|
+
(0, vitest_1.test)('no anim multiple', async () => {
|
|
21
|
+
await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
|
|
22
|
+
return new Promise(resolve => {
|
|
23
|
+
let obj = { x: 0, y: 0 };
|
|
24
|
+
new animator_1.Animator(obj, ['x', 'y'], {
|
|
25
|
+
duration: 1
|
|
26
|
+
}).attachToRoot();
|
|
27
|
+
resolve();
|
|
28
|
+
});
|
|
29
|
+
// 18.6875
|
|
30
|
+
}, { sampleCount: 100, repetationCount: 10000 });
|
|
31
|
+
}, 60000);
|
|
32
|
+
(0, vitest_1.test)('single 1 duration', async () => {
|
|
33
|
+
await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
|
|
34
|
+
return new Promise(resolve => {
|
|
35
|
+
let obj = { x: 0, y: 0 };
|
|
36
|
+
let animator = new animator_1.Animator(obj, 'x', {
|
|
37
|
+
duration: 1
|
|
38
|
+
}).attachToRoot();
|
|
39
|
+
animator.animate({ x: 1 }).tap(resolve).attachToRoot();
|
|
40
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
41
|
+
});
|
|
42
|
+
// 3.178299903869629
|
|
43
|
+
// converting to single event: 6.434300422668457
|
|
44
|
+
// with wait until all destroyed: 11.552299976348877
|
|
45
|
+
// 7.839200019836426
|
|
46
|
+
// last comparible: 5.697200298309326
|
|
47
|
+
// no forEach: 5.479100227355957
|
|
48
|
+
// after bundle: 2.5292000770568848
|
|
49
|
+
// 4.8225998878479
|
|
50
|
+
// after repetationCount: 10000
|
|
51
|
+
// 40.16639995574951
|
|
52
|
+
}, { sampleCount: 100, repetationCount: 10000 });
|
|
53
|
+
}, 60000);
|
|
54
|
+
(0, vitest_1.test)('multiple 1 duration', async () => {
|
|
55
|
+
await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
|
|
56
|
+
return new Promise(resolve => {
|
|
57
|
+
let obj = { x: 0, y: 0 };
|
|
58
|
+
let animator = new animator_1.Animator(obj, ['x', 'y'], {
|
|
59
|
+
duration: 1
|
|
60
|
+
}).attachToRoot();
|
|
61
|
+
animator.animate({ x: 1, y: 1 }).tap(resolve).attachToRoot();
|
|
62
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
63
|
+
});
|
|
64
|
+
// 3.6912999153137207
|
|
65
|
+
// converting to single event: 6.845600128173828
|
|
66
|
+
// with wait until all destroyed: 13.253100395202637
|
|
67
|
+
// 9.115399837493896
|
|
68
|
+
// last comparible: 6.0391998291015625
|
|
69
|
+
// no forEach: 5.958700180053711
|
|
70
|
+
// after bundle: 2.9321999549865723
|
|
71
|
+
// 5.1743998527526855
|
|
72
|
+
// after repetationCount: 10000
|
|
73
|
+
// 43.13860011100769
|
|
74
|
+
}, { sampleCount: 100, repetationCount: 10000 });
|
|
75
|
+
}, 60000);
|
|
76
|
+
(0, vitest_1.test)('single 10 duration', async () => {
|
|
77
|
+
await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
|
|
78
|
+
return new Promise(resolve => {
|
|
79
|
+
let obj = { x: 0, y: 0 };
|
|
80
|
+
let animator = new animator_1.Animator(obj, 'x', {
|
|
81
|
+
duration: 10
|
|
82
|
+
}).attachToRoot();
|
|
83
|
+
animator.animate({ x: 1 }).tap(resolve).attachToRoot();
|
|
84
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
85
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
86
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
87
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
88
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
89
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
90
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
91
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
92
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
93
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
94
|
+
});
|
|
95
|
+
// 45.116599798202515
|
|
96
|
+
}, { sampleCount: 50, repetationCount: 10000 });
|
|
97
|
+
}, 60000);
|
|
98
|
+
(0, vitest_1.test)('multiple 10 duration', async () => {
|
|
99
|
+
await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
|
|
100
|
+
return new Promise(resolve => {
|
|
101
|
+
let obj = { x: 0, y: 0 };
|
|
102
|
+
let animator = new animator_1.Animator(obj, ['x', 'y'], {
|
|
103
|
+
duration: 10
|
|
104
|
+
}).attachToRoot();
|
|
105
|
+
animator.animate({ x: 1, y: 1 }).tap(resolve).attachToRoot();
|
|
106
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
107
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
108
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
109
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
110
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
111
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
112
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
113
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
114
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
115
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
116
|
+
});
|
|
117
|
+
// 55.35859990119934
|
|
118
|
+
}, { sampleCount: 50, repetationCount: 10000 });
|
|
119
|
+
}, 60000);
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=animator.performance.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|