@lightningjs/renderer 2.19.1 → 2.20.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/src/common/CommonTypes.d.ts +11 -0
- package/dist/src/core/AutosizeManager.d.ts +29 -0
- package/dist/src/core/AutosizeManager.js +171 -0
- package/dist/src/core/AutosizeManager.js.map +1 -0
- package/dist/src/core/CoreNode.d.ts +1 -1
- package/dist/src/core/CoreNode.js +8 -0
- package/dist/src/core/CoreNode.js.map +1 -1
- package/dist/src/core/Stage.js +2 -1
- package/dist/src/core/Stage.js.map +1 -1
- package/dist/src/core/animations/Animation.d.ts +16 -0
- package/dist/src/core/animations/Animation.js +111 -0
- package/dist/src/core/animations/Animation.js.map +1 -0
- package/dist/src/core/animations/CoreTransition.d.ts +24 -0
- package/dist/src/core/animations/CoreTransition.js +63 -0
- package/dist/src/core/animations/CoreTransition.js.map +1 -0
- package/dist/src/core/animations/Playback.d.ts +62 -0
- package/dist/src/core/animations/Playback.js +155 -0
- package/dist/src/core/animations/Playback.js.map +1 -0
- package/dist/src/core/animations/Transition.d.ts +25 -0
- package/dist/src/core/animations/Transition.js +63 -0
- package/dist/src/core/animations/Transition.js.map +1 -0
- package/dist/src/core/animations/utils.d.ts +2 -0
- package/dist/src/core/animations/utils.js +137 -0
- package/dist/src/core/animations/utils.js.map +1 -0
- package/dist/src/core/lib/WebGlContextWrapper.d.ts +19 -5
- package/dist/src/core/lib/WebGlContextWrapper.js +35 -0
- package/dist/src/core/lib/WebGlContextWrapper.js.map +1 -1
- package/dist/src/core/lib/collectionUtils.d.ts +5 -0
- package/dist/src/core/lib/collectionUtils.js +100 -0
- package/dist/src/core/lib/collectionUtils.js.map +1 -0
- package/dist/src/core/lib/textureCompression.d.ts +14 -2
- package/dist/src/core/lib/textureCompression.js +301 -65
- package/dist/src/core/lib/textureCompression.js.map +1 -1
- package/dist/src/core/platforms/Platform.d.ts +5 -0
- package/dist/src/core/platforms/Platform.js.map +1 -1
- package/dist/src/core/platforms/web/WebPlatform.d.ts +1 -0
- package/dist/src/core/platforms/web/WebPlatform.js +3 -0
- package/dist/src/core/platforms/web/WebPlatform.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.d.ts +4 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js +14 -11
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +43 -8
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreShader.d.ts +2 -7
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js +18 -49
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js.map +1 -1
- package/dist/src/core/renderers/webgl/internal/ShaderUtils.d.ts +0 -2
- package/dist/src/core/renderers/webgl/internal/ShaderUtils.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.js +3 -6
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js +0 -11
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js +5 -10
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js +5 -10
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/SdfShader.js +0 -12
- package/dist/src/core/renderers/webgl/shaders/SdfShader.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.js +5 -5
- package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js +5 -5
- package/dist/src/core/shaders/webgl/LinearGradient.js +2 -1
- package/dist/src/core/shaders/webgl/LinearGradient.js.map +1 -1
- package/dist/src/core/shaders/webgl/RadialGradient.js +7 -6
- package/dist/src/core/shaders/webgl/RadialGradient.js.map +1 -1
- package/dist/src/core/text-rendering/CanvasFontHandler.js +4 -1
- package/dist/src/core/text-rendering/CanvasFontHandler.js.map +1 -1
- package/dist/src/core/text-rendering/CanvasTextRenderer.d.ts +4 -6
- package/dist/src/core/text-rendering/CanvasTextRenderer.js +15 -23
- package/dist/src/core/text-rendering/CanvasTextRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/SdfFontHandler.d.ts +125 -28
- package/dist/src/core/text-rendering/SdfFontHandler.js +337 -4
- package/dist/src/core/text-rendering/SdfFontHandler.js.map +1 -1
- package/dist/src/core/text-rendering/SdfTextRenderer.d.ts +5 -6
- package/dist/src/core/text-rendering/SdfTextRenderer.js +19 -23
- package/dist/src/core/text-rendering/SdfTextRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/TextLayoutEngine.d.ts +14 -16
- package/dist/src/core/text-rendering/TextLayoutEngine.js +248 -192
- package/dist/src/core/text-rendering/TextLayoutEngine.js.map +1 -1
- package/dist/src/core/text-rendering/TextRenderer.d.ts +25 -11
- package/dist/src/core/textures/Texture.d.ts +12 -5
- package/dist/src/core/textures/Texture.js.map +1 -1
- package/dist/src/main-api/Inspector.js +9 -5
- package/dist/src/main-api/Inspector.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/CommonTypes.ts +16 -0
- package/src/core/CoreNode.test.ts +49 -0
- package/src/core/CoreNode.ts +10 -0
- package/src/core/Stage.ts +3 -1
- package/src/core/lib/WebGlContextWrapper.ts +49 -0
- package/src/core/lib/textureCompression.ts +416 -75
- package/src/core/renderers/webgl/WebGlCoreCtxTexture.ts +16 -14
- package/src/core/renderers/webgl/WebGlCoreRenderOp.ts +1 -1
- package/src/core/renderers/webgl/WebGlCoreRenderer.ts +44 -11
- package/src/core/renderers/webgl/WebGlCoreShader.ts +27 -75
- package/src/core/renderers/webgl/internal/ShaderUtils.ts +0 -2
- package/src/core/renderers/webgl/shaders/DefaultShader.ts +3 -6
- package/src/core/renderers/webgl/shaders/DefaultShaderBatched.ts +0 -11
- package/src/core/renderers/webgl/shaders/DynamicShader.ts +5 -10
- package/src/core/renderers/webgl/shaders/RoundedRectangle.ts +5 -10
- package/src/core/renderers/webgl/shaders/SdfShader.ts +0 -12
- package/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.ts +1 -1
- package/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.ts +1 -1
- package/src/core/renderers/webgl/shaders/effects/BorderRightEffect.ts +1 -1
- package/src/core/renderers/webgl/shaders/effects/BorderTopEffect.ts +1 -1
- package/src/core/renderers/webgl/shaders/effects/FadeOutEffect.ts +5 -5
- package/src/core/renderers/webgl/shaders/effects/HolePunchEffect.ts +1 -1
- package/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.ts +1 -1
- package/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.ts +1 -1
- package/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.ts +1 -1
- package/src/core/renderers/webgl/shaders/effects/RadiusEffect.ts +5 -5
- package/src/core/textures/Texture.ts +13 -6
- package/src/main-api/Inspector.ts +9 -5
- package/dist/src/core/text-rendering/CanvasFont.d.ts +0 -14
- package/dist/src/core/text-rendering/CanvasFont.js +0 -111
- package/dist/src/core/text-rendering/CanvasFont.js.map +0 -1
- package/dist/src/core/text-rendering/CoreFont.d.ts +0 -33
- package/dist/src/core/text-rendering/CoreFont.js +0 -48
- package/dist/src/core/text-rendering/CoreFont.js.map +0 -1
- package/dist/src/core/text-rendering/FontManager.d.ts +0 -11
- package/dist/src/core/text-rendering/FontManager.js +0 -42
- package/dist/src/core/text-rendering/FontManager.js.map +0 -1
- package/dist/src/core/text-rendering/SdfFont.d.ts +0 -29
- package/dist/src/core/text-rendering/SdfFont.js +0 -142
- package/dist/src/core/text-rendering/SdfFont.js.map +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import Transition from './Transition.js';
|
|
2
|
+
import { normalizeTimingFunction } from './utils.js';
|
|
3
|
+
import Playback, { PlaybackSettingsKeys } from './Playback.js';
|
|
4
|
+
const mapTransitions = (target, animationParams, aDuration, aDelay, aEasing) => {
|
|
5
|
+
const aStart = aDelay;
|
|
6
|
+
const aEnd = aDelay + aDuration;
|
|
7
|
+
const transitionsByKey = {};
|
|
8
|
+
const keys = Object.keys(animationParams);
|
|
9
|
+
const filteredKeys = [];
|
|
10
|
+
for (let i = 0; i < keys.length; i++) {
|
|
11
|
+
const key = keys[i];
|
|
12
|
+
//skip playback settings
|
|
13
|
+
if (PlaybackSettingsKeys[key] === true) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
transitionsByKey[key] = [];
|
|
17
|
+
filteredKeys.push(key);
|
|
18
|
+
}
|
|
19
|
+
for (let i = 0; i < filteredKeys.length; i++) {
|
|
20
|
+
const key = filteredKeys[i];
|
|
21
|
+
const prop = target[key];
|
|
22
|
+
if (prop === undefined) {
|
|
23
|
+
console.warn(`CoreAnimation: property "${key}" does not exist on target.`);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const aProp = animationParams[key];
|
|
27
|
+
if (typeof aProp === 'number') {
|
|
28
|
+
transitionsByKey[key].push(new Transition(null, animationParams[key], aStart, aEnd, aEasing));
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (typeof aProp === 'object' && Array.isArray(aProp) === false) {
|
|
32
|
+
const from = aProp.from ?? null;
|
|
33
|
+
const start = aProp.duration ?? aDuration;
|
|
34
|
+
const end = aDelay + (aProp.delay ?? 0);
|
|
35
|
+
const easing = normalizeTimingFunction(aProp.easing) ?? aEasing;
|
|
36
|
+
transitionsByKey[key].push(new Transition(from, aProp.to, start, end, easing));
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const isUsableArray = Array.isArray(aProp) && aProp.length > 0;
|
|
40
|
+
//keyframed animation for number arrays
|
|
41
|
+
if (isUsableArray === true && typeof aProp[0] === 'number') {
|
|
42
|
+
const spreadDuration = aDuration / Math.min(aProp.length - 1, 1);
|
|
43
|
+
let transitionStart = aDelay;
|
|
44
|
+
let startValue = aProp[0];
|
|
45
|
+
const len = aProp.length;
|
|
46
|
+
if (len > 1) {
|
|
47
|
+
for (let j = 1; j < len; j++) {
|
|
48
|
+
const value = aProp[j];
|
|
49
|
+
const transitionEnd = transitionStart + spreadDuration;
|
|
50
|
+
transitionsByKey[key].push(new Transition(startValue, value, transitionStart, transitionEnd, aEasing));
|
|
51
|
+
//carry over to next transition
|
|
52
|
+
transitionStart = transitionEnd;
|
|
53
|
+
startValue = value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
transitionsByKey[key].push(new Transition(null, startValue, transitionStart, transitionStart + spreadDuration, aEasing));
|
|
58
|
+
}
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (isUsableArray === true && typeof aProp[0] === 'string') {
|
|
62
|
+
console.warn(`CoreAnimation: keyframed string animations are not yet supported for property "${key}".`);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return transitionsByKey;
|
|
67
|
+
};
|
|
68
|
+
export default class Animation extends Playback {
|
|
69
|
+
target;
|
|
70
|
+
transitions;
|
|
71
|
+
transitionKeys;
|
|
72
|
+
constructor(animationManager, target, animationParams) {
|
|
73
|
+
super(animationManager, animationParams);
|
|
74
|
+
this.target = target;
|
|
75
|
+
this.transitions = mapTransitions(target, animationParams, this.duration, this.delay, this.easing);
|
|
76
|
+
this.transitionKeys = Object.keys(this.transitions);
|
|
77
|
+
}
|
|
78
|
+
updateValues(currentTime) {
|
|
79
|
+
for (let i = 0; i < this.transitionKeys.length; i++) {
|
|
80
|
+
const key = this.transitionKeys[i];
|
|
81
|
+
const transitions = this.transitions[key];
|
|
82
|
+
for (let j = 0; j < transitions.length; j++) {
|
|
83
|
+
const transition = transitions[j];
|
|
84
|
+
if (currentTime >= transition.start &&
|
|
85
|
+
currentTime <= transition.start + transition.end) {
|
|
86
|
+
//apply value to target
|
|
87
|
+
this.target[key] =
|
|
88
|
+
transition.update(currentTime);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
applyStartValues() {
|
|
95
|
+
//set start values for transitions
|
|
96
|
+
for (let i = 0; i < this.transitionKeys.length; i++) {
|
|
97
|
+
const key = this.transitionKeys[i];
|
|
98
|
+
//only need to set the first transition's from value
|
|
99
|
+
const firstTransition = this.transitions[key][0];
|
|
100
|
+
const from = firstTransition.from;
|
|
101
|
+
const currentValue = this.target[key];
|
|
102
|
+
const targetValue = from !== null ? from : currentValue;
|
|
103
|
+
if (from === null) {
|
|
104
|
+
firstTransition.from = targetValue;
|
|
105
|
+
}
|
|
106
|
+
this.target[key] = targetValue;
|
|
107
|
+
firstTransition.currentValue = targetValue;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=Animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Animation.js","sourceRoot":"","sources":["../../../../src/core/animations/Animation.ts"],"names":[],"mappings":"AAoBA,OAAO,UAAU,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AC,IAAI,CAAC;YAClC,MAAM,YAAY,GAAI,IAAI,CAAC,MAA2C,CACpE,GAAG,CACH,CAAC;YAEH,MAAM,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC;YACxD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAClB,eAAe,CAAC,IAAI,GAAG,WAAW,CAAC;YACrC,CAAC;YACA,IAAI,CAAC,MAA2C,CAAC,GAAG,CAAE,GAAG,WAAW,CAAC;YACtE,eAAe,CAAC,YAAY,GAAG,WAAW,CAAC;QAC7C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TimingFunction } from "./utils";
|
|
2
|
+
export interface TransitionSettings {
|
|
3
|
+
to: number;
|
|
4
|
+
from?: number | null;
|
|
5
|
+
duration?: number;
|
|
6
|
+
delay?: number;
|
|
7
|
+
easing?: string | TimingFunction;
|
|
8
|
+
}
|
|
9
|
+
export type TransitionValueTypes = number | TransitionSettings | string | (number | TransitionSettings | string)[];
|
|
10
|
+
export default class Transition {
|
|
11
|
+
private data;
|
|
12
|
+
currentValue: number | null;
|
|
13
|
+
applyProgress: (from: number, to: number, p: number) => number;
|
|
14
|
+
constructor(from: number | null, to: number, duration: number, delay: number, easing: TimingFunction | null);
|
|
15
|
+
applyEasedProgress(from: number, to: number, p: number): number;
|
|
16
|
+
applyLinearProgress(from: number, to: number, p: number): number;
|
|
17
|
+
update(animationTime: number): number;
|
|
18
|
+
set from(value: number | null);
|
|
19
|
+
get from(): number | null;
|
|
20
|
+
get to(): number;
|
|
21
|
+
get start(): number;
|
|
22
|
+
get end(): number;
|
|
23
|
+
get easing(): TimingFunction | null;
|
|
24
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
export default class Transition {
|
|
20
|
+
data;
|
|
21
|
+
currentValue = null;
|
|
22
|
+
applyProgress = this.applyLinearProgress;
|
|
23
|
+
constructor(from, to, duration, delay, easing) {
|
|
24
|
+
this.data = [from, to, duration, delay, easing];
|
|
25
|
+
if (easing !== null) {
|
|
26
|
+
this.applyProgress = this.applyEasedProgress;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// This function only gets called if an easing function is provided
|
|
30
|
+
applyEasedProgress(from, to, p) {
|
|
31
|
+
return from + (to - from) * this.data[4](p);
|
|
32
|
+
}
|
|
33
|
+
// This function gets called if no easing function is provided (linear)
|
|
34
|
+
applyLinearProgress(from, to, p) {
|
|
35
|
+
return from + (to - from) * p;
|
|
36
|
+
}
|
|
37
|
+
update(animationTime) {
|
|
38
|
+
const [from, to, start, end] = this.data;
|
|
39
|
+
//calculate progress of transition
|
|
40
|
+
let p = (animationTime - start) / (end - start);
|
|
41
|
+
return this.currentValue = this.applyProgress(from, to, p);
|
|
42
|
+
}
|
|
43
|
+
//only settable property is 'from' will be used on start of animation
|
|
44
|
+
set from(value) {
|
|
45
|
+
this.data[0] = value;
|
|
46
|
+
}
|
|
47
|
+
get from() {
|
|
48
|
+
return this.data[0];
|
|
49
|
+
}
|
|
50
|
+
get to() {
|
|
51
|
+
return this.data[1];
|
|
52
|
+
}
|
|
53
|
+
get start() {
|
|
54
|
+
return this.data[2];
|
|
55
|
+
}
|
|
56
|
+
get end() {
|
|
57
|
+
return this.data[3];
|
|
58
|
+
}
|
|
59
|
+
get easing() {
|
|
60
|
+
return this.data[4];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=CoreTransition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoreTransition.js","sourceRoot":"","sources":["../../../../src/core/animations/CoreTransition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAkCH,MAAM,CAAC,OAAO,OAAO,UAAU;IACrB,IAAI,CAAwB;IACpC,YAAY,GAAkB,IAAI,CAAC;IACnC,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC;IAEzC,YAAY,IAAmB,EAAE,EAAU,EAAE,QAAgB,EAAE,KAAa,EAAE,MAA6B;QACzG,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QAChD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,kBAAkB,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,mEAAmE;IACnE,kBAAkB,CAAC,IAAY,EAAE,EAAU,EAAE,CAAS;QACpD,OAAO,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,uEAAuE;IACvE,mBAAmB,CAAC,IAAY,EAAE,EAAU,EAAE,CAAS;QACrD,OAAO,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,aAAqB;QAC1B,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;QACzC,kCAAkC;QAClC,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,IAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,qEAAqE;IACrE,IAAI,IAAI,CAAC,KAAoB;QAC3B,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { EventEmitter } from '../../common/EventEmitter.js';
|
|
2
|
+
import type { AnimationManager } from './AnimationManager.js';
|
|
3
|
+
import { type TimingFunction } from './utils.js';
|
|
4
|
+
export declare enum StopMethodFlags {
|
|
5
|
+
Immediate = 0,
|
|
6
|
+
Reset = 1,
|
|
7
|
+
Reverse = 2
|
|
8
|
+
}
|
|
9
|
+
export type StopMethodOptions = 'reverse' | 'reset' | 'immediate';
|
|
10
|
+
export declare const getStopMethodFlag: (method: string | undefined) => StopMethodFlags;
|
|
11
|
+
export interface PlaybackSettings {
|
|
12
|
+
delay: number;
|
|
13
|
+
duration: number;
|
|
14
|
+
easing: string | TimingFunction;
|
|
15
|
+
loop: boolean;
|
|
16
|
+
repeat: number;
|
|
17
|
+
reverse: boolean;
|
|
18
|
+
stopMethod: StopMethodOptions;
|
|
19
|
+
}
|
|
20
|
+
export declare enum PlaybackState {
|
|
21
|
+
Idle = 0,
|
|
22
|
+
Destroyed = 1,
|
|
23
|
+
Stopped = 2,
|
|
24
|
+
Finished = 3,
|
|
25
|
+
Paused = 4,
|
|
26
|
+
Playing = 5,
|
|
27
|
+
Stopping = 6
|
|
28
|
+
}
|
|
29
|
+
export declare const PlaybackSettingsKeys: {
|
|
30
|
+
delay: boolean;
|
|
31
|
+
duration: boolean;
|
|
32
|
+
easing: boolean;
|
|
33
|
+
loop: boolean;
|
|
34
|
+
repeat: boolean;
|
|
35
|
+
reverse: boolean;
|
|
36
|
+
stopMethod: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare function getPlaybackId(): number;
|
|
39
|
+
export default class Playback extends EventEmitter {
|
|
40
|
+
readonly animationManager: AnimationManager;
|
|
41
|
+
readonly id: number;
|
|
42
|
+
delay: number;
|
|
43
|
+
duration: number;
|
|
44
|
+
easing: TimingFunction | null;
|
|
45
|
+
loop: boolean;
|
|
46
|
+
repeat: number;
|
|
47
|
+
reverse: boolean;
|
|
48
|
+
stopMethod: StopMethodFlags;
|
|
49
|
+
state: PlaybackState;
|
|
50
|
+
startTime: number | null;
|
|
51
|
+
pauseTime: number | null;
|
|
52
|
+
endTime: number | null;
|
|
53
|
+
currentTime: number;
|
|
54
|
+
iteration: number;
|
|
55
|
+
constructor(animationManager: AnimationManager, settings?: Partial<PlaybackSettings>);
|
|
56
|
+
update(currentFrameTime: number): void;
|
|
57
|
+
updateValues(currentTime: number): void;
|
|
58
|
+
applyStartValues(): void;
|
|
59
|
+
start(): this;
|
|
60
|
+
stop(): void;
|
|
61
|
+
finish(): void;
|
|
62
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { EventEmitter } from '../../common/EventEmitter.js';
|
|
20
|
+
import { normalizeTimingFunction } from './utils.js';
|
|
21
|
+
export var StopMethodFlags;
|
|
22
|
+
(function (StopMethodFlags) {
|
|
23
|
+
StopMethodFlags[StopMethodFlags["Immediate"] = 0] = "Immediate";
|
|
24
|
+
StopMethodFlags[StopMethodFlags["Reset"] = 1] = "Reset";
|
|
25
|
+
StopMethodFlags[StopMethodFlags["Reverse"] = 2] = "Reverse";
|
|
26
|
+
})(StopMethodFlags || (StopMethodFlags = {}));
|
|
27
|
+
export const getStopMethodFlag = (method) => {
|
|
28
|
+
if (method === undefined || method === 'immediate') {
|
|
29
|
+
return StopMethodFlags.Immediate;
|
|
30
|
+
}
|
|
31
|
+
switch (method) {
|
|
32
|
+
case 'reverse':
|
|
33
|
+
return StopMethodFlags.Reverse;
|
|
34
|
+
case 'reset':
|
|
35
|
+
return StopMethodFlags.Reset;
|
|
36
|
+
}
|
|
37
|
+
return StopMethodFlags.Immediate;
|
|
38
|
+
};
|
|
39
|
+
export var PlaybackState;
|
|
40
|
+
(function (PlaybackState) {
|
|
41
|
+
PlaybackState[PlaybackState["Idle"] = 0] = "Idle";
|
|
42
|
+
PlaybackState[PlaybackState["Destroyed"] = 1] = "Destroyed";
|
|
43
|
+
PlaybackState[PlaybackState["Stopped"] = 2] = "Stopped";
|
|
44
|
+
PlaybackState[PlaybackState["Finished"] = 3] = "Finished";
|
|
45
|
+
PlaybackState[PlaybackState["Paused"] = 4] = "Paused";
|
|
46
|
+
PlaybackState[PlaybackState["Playing"] = 5] = "Playing";
|
|
47
|
+
PlaybackState[PlaybackState["Stopping"] = 6] = "Stopping";
|
|
48
|
+
})(PlaybackState || (PlaybackState = {}));
|
|
49
|
+
export const PlaybackSettingsKeys = {
|
|
50
|
+
delay: true,
|
|
51
|
+
duration: true,
|
|
52
|
+
easing: true,
|
|
53
|
+
loop: true,
|
|
54
|
+
repeat: true,
|
|
55
|
+
reverse: true,
|
|
56
|
+
stopMethod: true,
|
|
57
|
+
};
|
|
58
|
+
//freeze the keys object to prevent modification
|
|
59
|
+
Object.freeze(PlaybackSettingsKeys);
|
|
60
|
+
/**
|
|
61
|
+
* Returns a new unique ID
|
|
62
|
+
*/
|
|
63
|
+
let playbackId = 1;
|
|
64
|
+
export function getPlaybackId() {
|
|
65
|
+
return playbackId++;
|
|
66
|
+
}
|
|
67
|
+
export default class Playback extends EventEmitter {
|
|
68
|
+
animationManager;
|
|
69
|
+
//id
|
|
70
|
+
id = getPlaybackId();
|
|
71
|
+
//settings
|
|
72
|
+
delay;
|
|
73
|
+
duration;
|
|
74
|
+
easing;
|
|
75
|
+
loop;
|
|
76
|
+
repeat;
|
|
77
|
+
reverse;
|
|
78
|
+
stopMethod;
|
|
79
|
+
//lifecycle
|
|
80
|
+
state = PlaybackState.Idle;
|
|
81
|
+
startTime = null;
|
|
82
|
+
pauseTime = null;
|
|
83
|
+
endTime = null;
|
|
84
|
+
currentTime = 0;
|
|
85
|
+
iteration = 0;
|
|
86
|
+
constructor(animationManager, settings = {}) {
|
|
87
|
+
super();
|
|
88
|
+
this.animationManager = animationManager;
|
|
89
|
+
this.delay = settings.delay ?? 0;
|
|
90
|
+
this.duration = settings.duration ?? 200;
|
|
91
|
+
this.easing = normalizeTimingFunction(settings.easing);
|
|
92
|
+
this.loop = settings.loop ?? false;
|
|
93
|
+
this.repeat = settings.repeat ?? 0;
|
|
94
|
+
this.reverse = settings.reverse ?? false;
|
|
95
|
+
this.stopMethod = getStopMethodFlag(settings.stopMethod);
|
|
96
|
+
}
|
|
97
|
+
update(currentFrameTime) {
|
|
98
|
+
let state = this.state;
|
|
99
|
+
let targetTime = currentFrameTime - this.startTime;
|
|
100
|
+
if (state === PlaybackState.Stopping) {
|
|
101
|
+
targetTime = this.duration - targetTime;
|
|
102
|
+
}
|
|
103
|
+
if (state === PlaybackState.Playing && targetTime > this.duration) {
|
|
104
|
+
targetTime = this.duration;
|
|
105
|
+
if (this.loop === true) {
|
|
106
|
+
this.iteration++;
|
|
107
|
+
this.startTime = currentFrameTime;
|
|
108
|
+
targetTime = 0;
|
|
109
|
+
if (this.repeat > 0 && this.iteration > this.repeat) {
|
|
110
|
+
this.stop();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
updateValues(currentTime) { }
|
|
116
|
+
applyStartValues() {
|
|
117
|
+
//needs to be implemented in subclass
|
|
118
|
+
}
|
|
119
|
+
start() {
|
|
120
|
+
const animationManager = this.animationManager;
|
|
121
|
+
this.startTime = animationManager.currentFrameTime + this.delay;
|
|
122
|
+
this.endTime = this.startTime + this.duration;
|
|
123
|
+
this.state = PlaybackState.Playing;
|
|
124
|
+
animationManager.register(this);
|
|
125
|
+
this.emit('start');
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
stop() {
|
|
129
|
+
const stopMethod = this.stopMethod;
|
|
130
|
+
if (stopMethod === StopMethodFlags.Immediate) {
|
|
131
|
+
this.finish();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (stopMethod === StopMethodFlags.Reset) {
|
|
135
|
+
this.updateValues(0);
|
|
136
|
+
this.finish();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (stopMethod === StopMethodFlags.Reverse) {
|
|
140
|
+
if (this.state === PlaybackState.Playing) {
|
|
141
|
+
this.state = PlaybackState.Stopping;
|
|
142
|
+
//adjust start time to account for current time
|
|
143
|
+
const currentFrameTime = this.animationManager.currentFrameTime;
|
|
144
|
+
const elapsedTime = currentFrameTime - this.startTime;
|
|
145
|
+
this.startTime = currentFrameTime - (this.duration - elapsedTime);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
finish() {
|
|
150
|
+
this.state = PlaybackState.Finished;
|
|
151
|
+
this.emit('finish');
|
|
152
|
+
this.animationManager.unregister(this);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=Playback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Playback.js","sourceRoot":"","sources":["../../../../src/core/animations/Playback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,uBAAuB,EAAuB,MAAM,YAAY,CAAC;AAE1E,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,+DAAS,CAAA;IACT,uDAAK,CAAA;IACL,2DAAO,CAAA;AACT,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAKD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,MAA0B,EACT,EAAE;IACnB,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QACnD,OAAO,eAAe,CAAC,SAAS,CAAC;IACnC,CAAC;IAED,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,SAAS;YACZ,OAAO,eAAe,CAAC,OAAO,CAAC;QACjC,KAAK,OAAO;YACV,OAAO,eAAe,CAAC,KAAK,CAAC;IACjC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C,QAAQ,GAAG,WAAW,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpB,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TimingFunction } from './utils';
|
|
2
|
+
export interface TransitionSettings {
|
|
3
|
+
to: number;
|
|
4
|
+
from?: number | null;
|
|
5
|
+
duration?: number;
|
|
6
|
+
delay?: number;
|
|
7
|
+
easing?: string | TimingFunction;
|
|
8
|
+
}
|
|
9
|
+
export type TransitionableValue = number | number[];
|
|
10
|
+
export type TransitionValueTypes = number | TransitionSettings | string | (number | TransitionSettings | string)[];
|
|
11
|
+
export default class Transition {
|
|
12
|
+
private data;
|
|
13
|
+
currentValue: TransitionableValue | null;
|
|
14
|
+
applyProgress: (from: number, to: number, p: number) => number;
|
|
15
|
+
constructor(from: TransitionableValue | null, to: TransitionableValue, duration: number, delay: number, easing: TimingFunction | null);
|
|
16
|
+
applyEasedProgress(from: number, to: number, p: number): number;
|
|
17
|
+
applyLinearProgress(from: number, to: number, p: number): number;
|
|
18
|
+
update(animationTime: number): number;
|
|
19
|
+
set from(value: TransitionableValue | null);
|
|
20
|
+
get from(): TransitionableValue | null;
|
|
21
|
+
get to(): TransitionableValue;
|
|
22
|
+
get start(): number;
|
|
23
|
+
get end(): number;
|
|
24
|
+
get easing(): TimingFunction | null;
|
|
25
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
export default class Transition {
|
|
20
|
+
data;
|
|
21
|
+
currentValue = null;
|
|
22
|
+
applyProgress = this.applyLinearProgress;
|
|
23
|
+
constructor(from, to, duration, delay, easing) {
|
|
24
|
+
this.data = [from, to, duration, delay, easing];
|
|
25
|
+
if (easing !== null) {
|
|
26
|
+
this.applyProgress = this.applyEasedProgress;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// This function only gets called if an easing function is provided
|
|
30
|
+
applyEasedProgress(from, to, p) {
|
|
31
|
+
return from + (to - from) * this.data[4](p);
|
|
32
|
+
}
|
|
33
|
+
// This function gets called if no easing function is provided (linear)
|
|
34
|
+
applyLinearProgress(from, to, p) {
|
|
35
|
+
return from + (to - from) * p;
|
|
36
|
+
}
|
|
37
|
+
update(animationTime) {
|
|
38
|
+
const [from, to, start, end] = this.data;
|
|
39
|
+
//calculate progress of transition
|
|
40
|
+
let p = (animationTime - start) / (end - start);
|
|
41
|
+
return (this.currentValue = this.applyProgress(from, to, p));
|
|
42
|
+
}
|
|
43
|
+
//only settable property is 'from' will be used on start of animation
|
|
44
|
+
set from(value) {
|
|
45
|
+
this.data[0] = value;
|
|
46
|
+
}
|
|
47
|
+
get from() {
|
|
48
|
+
return this.data[0];
|
|
49
|
+
}
|
|
50
|
+
get to() {
|
|
51
|
+
return this.data[1];
|
|
52
|
+
}
|
|
53
|
+
get start() {
|
|
54
|
+
return this.data[2];
|
|
55
|
+
}
|
|
56
|
+
get end() {
|
|
57
|
+
return this.data[3];
|
|
58
|
+
}
|
|
59
|
+
get easing() {
|
|
60
|
+
return this.data[4];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=Transition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transition.js","sourceRoot":"","sources":["../../../../src/core/animations/Transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAoCH,MAAM,CAAC,OAAO,OAAO,UAAU;IACrB,IAAI,CAAuB;IACnC,YAAY,GAA+B,IAAI,CAAC;IAChD,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC;IAEzC,YACE,IAAgC,EAChC,EAAuB,EACvB,QAAgB,EAChB,KAAa,EACb,MAA6B;QAE7B,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QAChD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,kBAAkB,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,mEAAmE;IACnE,kBAAkB,CAAC,IAAY,EAAE,EAAU,EAAE,CAAS;QACpD,OAAO,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,uEAAuE;IACvE,mBAAmB,CAAC,IAAY,EAAE,EAAU,EAAE,CAAS;QACrD,OAAO,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,aAAqB;QAC1B,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,IAMnC,CAAC;QACF,kCAAkC;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