@zcomponent/core 0.0.19 → 0.0.21
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/lib/animation/animation.d.ts +46 -0
- package/lib/animation/animation.js +159 -0
- package/lib/animation/animationstate.d.ts +27 -0
- package/lib/animation/animationstate.js +1 -0
- package/lib/animation/bezier.d.ts +9 -0
- package/lib/animation/bezier.js +93 -0
- package/lib/animation/clips/clip.d.ts +30 -0
- package/lib/animation/clips/clip.js +114 -0
- package/lib/animation/index.d.ts +7 -0
- package/lib/animation/index.js +7 -0
- package/lib/animation/interpolate.d.ts +2 -0
- package/lib/animation/interpolate.js +44 -0
- package/lib/animation/layer.d.ts +42 -0
- package/lib/animation/layer.js +211 -0
- package/lib/animation/layerclip.d.ts +46 -0
- package/lib/animation/layerclip.js +168 -0
- package/lib/animation/stream.d.ts +15 -0
- package/lib/animation/stream.js +6 -0
- package/lib/animation/tracks/cliptrack.d.ts +25 -0
- package/lib/animation/tracks/cliptrack.js +68 -0
- package/lib/animation/tracks/propertytrack.d.ts +32 -0
- package/lib/animation/tracks/propertytrack.js +79 -0
- package/lib/animation/tracks/track.d.ts +10 -0
- package/lib/animation/tracks/track.js +30 -0
- package/lib/animation.d.ts +86 -65
- package/lib/animation.js +83 -1
- package/lib/behaviors/PauseLayerClip.d.ts +20 -0
- package/lib/behaviors/PauseLayerClip.js +26 -0
- package/lib/behaviors/PlayLayerClip.d.ts +78 -0
- package/lib/behaviors/PlayLayerClip.js +62 -0
- package/lib/behaviors/SetLayerOff.d.ts +20 -0
- package/lib/behaviors/SetLayerOff.js +26 -0
- package/lib/data.d.ts +3 -2
- package/lib/data.js +8 -5
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/inflate.d.ts +13 -0
- package/lib/inflate.js +185 -0
- package/lib/interfaces.d.ts +1 -0
- package/lib/selectors.d.ts +5 -0
- package/lib/selectors.js +14 -0
- package/lib/types.d.ts +22 -2
- package/lib/types.js +41 -15
- package/lib/zcomponent.d.ts +11 -0
- package/lib/zcomponent.js +35 -0
- package/package.json +2 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Observable } from '../../observable';
|
|
2
|
+
import { computeEasing } from '../bezier';
|
|
3
|
+
import { interpolate } from '../interpolate';
|
|
4
|
+
export class Track {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.influencedPathsDirty = new Observable(false);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function resolveKeyframeValue(t, before, after) {
|
|
10
|
+
if (!after || !before.easing)
|
|
11
|
+
return before.v;
|
|
12
|
+
const tprop = computeEasing((t - before.t) / (after.t - before.t), before.easing);
|
|
13
|
+
return interpolate(before.v, after.v, tprop);
|
|
14
|
+
}
|
|
15
|
+
export function resolveKeyframes(keyframes, t) {
|
|
16
|
+
let keyframeBefore;
|
|
17
|
+
let keyframeAfter;
|
|
18
|
+
for (let i = 0; i < keyframes.length; i++) {
|
|
19
|
+
const keyframe = keyframes[i];
|
|
20
|
+
if (keyframe.t <= t)
|
|
21
|
+
keyframeBefore = keyframe;
|
|
22
|
+
if (keyframe.t === t)
|
|
23
|
+
break;
|
|
24
|
+
if (keyframe.t > t) {
|
|
25
|
+
keyframeAfter = keyframe;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return [keyframeBefore, keyframeAfter];
|
|
30
|
+
}
|
package/lib/animation.d.ts
CHANGED
|
@@ -9,121 +9,142 @@ export type ByNodeProperty<T> = {
|
|
|
9
9
|
export interface Animation {
|
|
10
10
|
clips: ByID<Clip>;
|
|
11
11
|
layers: ByID<Layer>;
|
|
12
|
+
curves: ByID<Curve>;
|
|
12
13
|
}
|
|
13
14
|
export type BlendType = 'overlay' | 'add';
|
|
14
15
|
export interface FadeParameters {
|
|
15
16
|
time: number;
|
|
16
|
-
pin?:
|
|
17
|
+
pin?: number;
|
|
18
|
+
easing?: Easing;
|
|
19
|
+
reverse?: boolean;
|
|
17
20
|
}
|
|
18
21
|
export interface Layer {
|
|
22
|
+
order: string;
|
|
23
|
+
name: string;
|
|
24
|
+
id: string;
|
|
19
25
|
defaultFadeParameters?: FadeParameters;
|
|
20
|
-
clips: LayerClip
|
|
26
|
+
clips: ByID<LayerClip>;
|
|
27
|
+
defaultClip?: string | null;
|
|
28
|
+
enabled: boolean;
|
|
21
29
|
}
|
|
22
30
|
export interface LayerClip {
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
order: string;
|
|
32
|
+
id: string;
|
|
33
|
+
clipId: string;
|
|
34
|
+
loop?: boolean;
|
|
25
35
|
reverse?: boolean;
|
|
26
36
|
playbackSpeed?: number;
|
|
27
37
|
}
|
|
28
|
-
export type
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export interface StateClipBlend {
|
|
40
|
-
weight?: number;
|
|
41
|
-
type?: BlendType;
|
|
42
|
-
}
|
|
43
|
-
export interface TimelineClip extends BaseClip {
|
|
44
|
-
type: 'timeline';
|
|
45
|
-
length: number;
|
|
38
|
+
export type ActiveLayerClips = ByID<string | undefined>;
|
|
39
|
+
export declare enum ClipType {
|
|
40
|
+
Timeline = "timeline",
|
|
41
|
+
State = "state"
|
|
42
|
+
}
|
|
43
|
+
export type ClipLengthType = 'auto' | 'expand' | 'manual';
|
|
44
|
+
export interface Clip {
|
|
45
|
+
order: string;
|
|
46
|
+
type: ClipType;
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
46
49
|
tracks: ByID<Track>;
|
|
47
|
-
|
|
50
|
+
length: number;
|
|
51
|
+
lengthType: ClipLengthType;
|
|
48
52
|
defaultFadeParameters?: FadeParameters;
|
|
49
53
|
timeSourceTrack?: string;
|
|
50
54
|
}
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
export interface Keyframe<T> {
|
|
56
|
-
v: T;
|
|
55
|
+
export interface Keyframe {
|
|
56
|
+
id: string;
|
|
57
|
+
v: any;
|
|
57
58
|
t: number;
|
|
58
59
|
label?: string;
|
|
59
60
|
easing?: Easing;
|
|
60
61
|
}
|
|
61
|
-
export
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
export declare const predefinedCurve: {
|
|
63
|
+
[id: string]: Bezier[];
|
|
64
|
+
};
|
|
65
|
+
export type Easing = null | keyof typeof predefinedCurve | string;
|
|
66
|
+
export type Point = [number, number];
|
|
67
|
+
export type Bezier = [Point, Point, Point, Point];
|
|
68
|
+
export type Curve = {
|
|
69
|
+
id: string;
|
|
70
|
+
order?: string;
|
|
71
|
+
name: string;
|
|
72
|
+
curve: Bezier[];
|
|
73
|
+
};
|
|
74
|
+
export declare enum TrackType {
|
|
75
|
+
Property = "property",
|
|
76
|
+
Clip = "clip",
|
|
77
|
+
Stream = "stream",
|
|
78
|
+
Function = "function",
|
|
79
|
+
Label = "label",
|
|
80
|
+
Entity = "entity",
|
|
81
|
+
Blend = "blend",
|
|
82
|
+
Fade = "fade"
|
|
83
|
+
}
|
|
84
|
+
export type Track = PropertyTrack | ClipTrack | StreamTrack | FunctionTrack | LabelTrack;
|
|
85
|
+
export interface BaseTrack {
|
|
86
|
+
order: string;
|
|
87
|
+
id: string;
|
|
88
|
+
type: TrackType;
|
|
73
89
|
entityID: string;
|
|
74
|
-
|
|
75
|
-
|
|
90
|
+
}
|
|
91
|
+
export interface PropertyTrack extends BaseTrack {
|
|
92
|
+
type: TrackType.Property;
|
|
93
|
+
property: (string | number)[];
|
|
76
94
|
blend: BlendType;
|
|
77
|
-
weight: Keyframe
|
|
78
|
-
|
|
95
|
+
weight: ByID<Keyframe>;
|
|
96
|
+
keyframes: ByID<Keyframe>;
|
|
97
|
+
fadeParameters?: Partial<FadeParameters>;
|
|
79
98
|
}
|
|
80
99
|
export interface ClipTrack extends BaseTrack {
|
|
81
|
-
type:
|
|
82
|
-
|
|
83
|
-
data:
|
|
84
|
-
weight: Keyframe
|
|
100
|
+
type: TrackType.Clip;
|
|
101
|
+
name: string;
|
|
102
|
+
data: ByID<ClipTrackEntity>;
|
|
103
|
+
weight: ByID<Keyframe>;
|
|
85
104
|
}
|
|
86
|
-
export interface
|
|
105
|
+
export interface ClipTrackEntity {
|
|
106
|
+
id: string;
|
|
87
107
|
t0: number;
|
|
88
108
|
t1: number;
|
|
89
109
|
s0: number;
|
|
90
110
|
rate: number;
|
|
91
111
|
}
|
|
92
112
|
export interface StreamTrack extends BaseTrack {
|
|
93
|
-
type:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
weight: Keyframe<number>[];
|
|
113
|
+
type: TrackType.Stream;
|
|
114
|
+
data: ByID<StreamTrackEntity>;
|
|
115
|
+
weight: ByID<Keyframe>;
|
|
97
116
|
}
|
|
98
|
-
export interface
|
|
117
|
+
export interface StreamTrackEntity {
|
|
99
118
|
t0: number;
|
|
100
119
|
t1: number;
|
|
101
120
|
s0: number;
|
|
102
121
|
rate: number;
|
|
103
122
|
}
|
|
104
123
|
export interface FunctionTrack extends BaseTrack {
|
|
105
|
-
type:
|
|
106
|
-
data:
|
|
124
|
+
type: TrackType.Function;
|
|
125
|
+
data: ByID<FunctionTrackEntity>;
|
|
107
126
|
}
|
|
108
|
-
export type
|
|
109
|
-
export interface
|
|
127
|
+
export type FunctionTrackEntity = EntityFunctionTrackEntity | ImportFunctionTrackEntity;
|
|
128
|
+
export interface BaseFunctionTrackEntity {
|
|
129
|
+
order: string;
|
|
110
130
|
type: 'entity' | 'import';
|
|
111
|
-
args: any
|
|
131
|
+
args: ByID<any>;
|
|
112
132
|
}
|
|
113
|
-
export interface
|
|
133
|
+
export interface EntityFunctionTrackEntity extends BaseFunctionTrackEntity {
|
|
114
134
|
type: 'entity';
|
|
115
135
|
entityID: string;
|
|
116
136
|
functionName: string;
|
|
117
137
|
}
|
|
118
|
-
export interface
|
|
138
|
+
export interface ImportFunctionTrackEntity extends BaseFunctionTrackEntity {
|
|
119
139
|
type: 'import';
|
|
120
140
|
import: string;
|
|
121
141
|
}
|
|
122
142
|
export interface LabelTrack extends BaseTrack {
|
|
123
|
-
type:
|
|
124
|
-
data:
|
|
143
|
+
type: TrackType.Label;
|
|
144
|
+
data: ByID<LabelTrackEntity>;
|
|
125
145
|
}
|
|
126
|
-
export interface
|
|
146
|
+
export interface LabelTrackEntity {
|
|
147
|
+
order: string;
|
|
127
148
|
t: number;
|
|
128
149
|
label: string;
|
|
129
150
|
}
|
package/lib/animation.js
CHANGED
|
@@ -1 +1,83 @@
|
|
|
1
|
-
|
|
1
|
+
// CLIP
|
|
2
|
+
export var ClipType;
|
|
3
|
+
(function (ClipType) {
|
|
4
|
+
ClipType["Timeline"] = "timeline";
|
|
5
|
+
ClipType["State"] = "state";
|
|
6
|
+
})(ClipType || (ClipType = {}));
|
|
7
|
+
// TODO: it's a temporary placement for this object
|
|
8
|
+
export const predefinedCurve = {
|
|
9
|
+
linear: [[[0, 0], [0.5, 0.5], [0.5, 0.5], [1, 1]]],
|
|
10
|
+
ease: [[[0, 0], [0.25, 0.1], [0.25, 1], [1, 1]]],
|
|
11
|
+
easeIn: [[[0, 0], [0.42, 0], [1, 1], [1, 1]]],
|
|
12
|
+
easeOut: [[[0, 0], [0, 0], [0.58, 1], [1, 1]]],
|
|
13
|
+
easeInOut: [[[0, 0], [0.42, 0], [0.58, 1], [1, 1]]],
|
|
14
|
+
bounceOut: [[[0, 0], [0.1, 0], [0.2, 0.5], [0.3, 1]],
|
|
15
|
+
[[0.3, 1], [0.4, 0.7], [0.6, 0.7], [0.7, 1]],
|
|
16
|
+
[[0.7, 1], [0.75, 0.85], [0.85, 0.85], [0.9, 1]],
|
|
17
|
+
[[0.9, 1], [0.925, 0.95], [0.975, 0.95], [1, 1]]]
|
|
18
|
+
};
|
|
19
|
+
// Simple linear transition between two object position value could look like this:
|
|
20
|
+
// [
|
|
21
|
+
// {
|
|
22
|
+
// v: [1, 2, 3], // initial position
|
|
23
|
+
// t: 0,
|
|
24
|
+
// easing: 'linear'
|
|
25
|
+
// },
|
|
26
|
+
// {
|
|
27
|
+
// v: [4, 5, 6], // end position
|
|
28
|
+
// t: 1000, // one second
|
|
29
|
+
// }
|
|
30
|
+
// ];
|
|
31
|
+
// The same thing (a linear transition) represented as bezier points
|
|
32
|
+
// [
|
|
33
|
+
// {
|
|
34
|
+
// v: [1, 2, 3],
|
|
35
|
+
// t: 0,
|
|
36
|
+
// easing: [
|
|
37
|
+
// [[0.5, 0.5], [0.5, 0.5]] // Two bezier control points half way between the keyframes, and half way between the normalized values
|
|
38
|
+
// ]
|
|
39
|
+
// },
|
|
40
|
+
// {
|
|
41
|
+
// v: [4, 5, 6],
|
|
42
|
+
// t: 1000
|
|
43
|
+
// }
|
|
44
|
+
// ];
|
|
45
|
+
// Now with a step at the start of the transition
|
|
46
|
+
// [
|
|
47
|
+
// {
|
|
48
|
+
// v: [1, 2, 3],
|
|
49
|
+
// t: 0,
|
|
50
|
+
// // easing value omitted implies immediate setting of value
|
|
51
|
+
// },
|
|
52
|
+
// {
|
|
53
|
+
// v: [4, 5, 6],
|
|
54
|
+
// t: 1000
|
|
55
|
+
// }
|
|
56
|
+
// ];
|
|
57
|
+
// Same thing implemented with bezier
|
|
58
|
+
// [
|
|
59
|
+
// {
|
|
60
|
+
// v: [1, 2, 3],
|
|
61
|
+
// t: 0,
|
|
62
|
+
// easing: [
|
|
63
|
+
// [[0, 0.5], [0, 0.5], [0, 1]], // Bezier point at x=0, y=1 with control points at origin and at x=0, y=1
|
|
64
|
+
// [[0.5, 1], [0.5, 1]] // Bezier control points for a flat line from x=0 y=1 to x=1 y=1
|
|
65
|
+
// ]
|
|
66
|
+
// },
|
|
67
|
+
// {
|
|
68
|
+
// v: [4, 5, 6],
|
|
69
|
+
// t: 1000
|
|
70
|
+
// }
|
|
71
|
+
// ];
|
|
72
|
+
////// TRACKS
|
|
73
|
+
export var TrackType;
|
|
74
|
+
(function (TrackType) {
|
|
75
|
+
TrackType["Property"] = "property";
|
|
76
|
+
TrackType["Clip"] = "clip";
|
|
77
|
+
TrackType["Stream"] = "stream";
|
|
78
|
+
TrackType["Function"] = "function";
|
|
79
|
+
TrackType["Label"] = "label";
|
|
80
|
+
TrackType["Entity"] = "entity";
|
|
81
|
+
TrackType["Blend"] = "blend";
|
|
82
|
+
TrackType["Fade"] = "fade";
|
|
83
|
+
})(TrackType || (TrackType = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ActionBehavior, ActionBehaviorConstructorProps } from "../actionbehavior";
|
|
2
|
+
import { Component } from "../component";
|
|
3
|
+
import { ContextManager } from "../context";
|
|
4
|
+
/**
|
|
5
|
+
* @zbehavior
|
|
6
|
+
* @zicon pause_circle
|
|
7
|
+
* @zgroup Animation Actions
|
|
8
|
+
*/
|
|
9
|
+
export declare class PauseLayerClip extends ActionBehavior {
|
|
10
|
+
private zcomponent;
|
|
11
|
+
/**
|
|
12
|
+
* @zprop
|
|
13
|
+
* @zvalues layerclipids
|
|
14
|
+
*/
|
|
15
|
+
layerClip: string | undefined;
|
|
16
|
+
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
17
|
+
perform(): void;
|
|
18
|
+
/** @zprop */
|
|
19
|
+
preview(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ActionBehavior, } from "../actionbehavior";
|
|
2
|
+
import { registerBehaviorRunAtDesignTime } from "../behavior";
|
|
3
|
+
/**
|
|
4
|
+
* @zbehavior
|
|
5
|
+
* @zicon pause_circle
|
|
6
|
+
* @zgroup Animation Actions
|
|
7
|
+
*/
|
|
8
|
+
export class PauseLayerClip extends ActionBehavior {
|
|
9
|
+
constructor(contextManager, instance, props) {
|
|
10
|
+
super(contextManager, instance, props);
|
|
11
|
+
this.zcomponent = this.getZComponentInstance();
|
|
12
|
+
}
|
|
13
|
+
perform() {
|
|
14
|
+
if (!this.layerClip)
|
|
15
|
+
return;
|
|
16
|
+
const layerclip = this.zcomponent.animation.layerClipByID.get(this.layerClip);
|
|
17
|
+
if (!layerclip)
|
|
18
|
+
return;
|
|
19
|
+
layerclip.pause();
|
|
20
|
+
}
|
|
21
|
+
/** @zprop */
|
|
22
|
+
preview() {
|
|
23
|
+
this.perform();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
registerBehaviorRunAtDesignTime(PauseLayerClip);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ActionBehavior, ActionBehaviorConstructorProps } from "../actionbehavior";
|
|
2
|
+
import { Component } from "../component";
|
|
3
|
+
import { ContextManager } from "../context";
|
|
4
|
+
/**
|
|
5
|
+
* @zbehavior
|
|
6
|
+
* @zicon play_circle
|
|
7
|
+
* @zgroup Animation Actions
|
|
8
|
+
*/
|
|
9
|
+
export declare class PlayLayerClip extends ActionBehavior {
|
|
10
|
+
private zcomponent;
|
|
11
|
+
/**
|
|
12
|
+
* @zprop
|
|
13
|
+
* @zgroup Play Settings
|
|
14
|
+
* @zgrouppriority 20
|
|
15
|
+
* @zvalues layerclipids
|
|
16
|
+
*/
|
|
17
|
+
layerClip: string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* @zprop
|
|
20
|
+
* @zgroup Play Settings
|
|
21
|
+
* @zgrouppriority 20
|
|
22
|
+
* @zdefault false
|
|
23
|
+
*/
|
|
24
|
+
loop?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @zprop
|
|
27
|
+
* @zgroup Play Settings
|
|
28
|
+
* @zgrouppriority 20
|
|
29
|
+
* @zdefault 1
|
|
30
|
+
*/
|
|
31
|
+
speed?: number;
|
|
32
|
+
/**
|
|
33
|
+
* @zprop
|
|
34
|
+
* @zgroup Play Settings
|
|
35
|
+
* @zgrouppriority 20
|
|
36
|
+
* @zdefault false
|
|
37
|
+
*/
|
|
38
|
+
queue: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Seek the clip to the start before playing
|
|
41
|
+
*
|
|
42
|
+
* @zprop
|
|
43
|
+
* @zgroup Play Settings
|
|
44
|
+
* @zgrouppriority 20
|
|
45
|
+
* @zdefault false
|
|
46
|
+
*/
|
|
47
|
+
fromStart: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* @zprop
|
|
50
|
+
* @zgroup Override Fade
|
|
51
|
+
* @zgrouppriority 10
|
|
52
|
+
*/
|
|
53
|
+
fadeTime?: number;
|
|
54
|
+
/**
|
|
55
|
+
* @zprop
|
|
56
|
+
* @zgroup Override Fade
|
|
57
|
+
* @zgrouppriority 10
|
|
58
|
+
* @zdefault 0
|
|
59
|
+
*/
|
|
60
|
+
pin?: Pin | number;
|
|
61
|
+
/**
|
|
62
|
+
* @zprop
|
|
63
|
+
* @zgroup Override Fade
|
|
64
|
+
* @zgrouppriority 10
|
|
65
|
+
* @zdefault 0
|
|
66
|
+
* @zvalues easings
|
|
67
|
+
*/
|
|
68
|
+
easing?: string;
|
|
69
|
+
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
70
|
+
perform(): void;
|
|
71
|
+
/** @zprop */
|
|
72
|
+
preview(): void;
|
|
73
|
+
}
|
|
74
|
+
export declare enum Pin {
|
|
75
|
+
Start = 0,
|
|
76
|
+
Middle = 0.5,
|
|
77
|
+
End = 1
|
|
78
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ActionBehavior, } from "../actionbehavior";
|
|
2
|
+
import { registerBehaviorRunAtDesignTime } from "../behavior";
|
|
3
|
+
/**
|
|
4
|
+
* @zbehavior
|
|
5
|
+
* @zicon play_circle
|
|
6
|
+
* @zgroup Animation Actions
|
|
7
|
+
*/
|
|
8
|
+
export class PlayLayerClip extends ActionBehavior {
|
|
9
|
+
constructor(contextManager, instance, props) {
|
|
10
|
+
super(contextManager, instance, props);
|
|
11
|
+
this.zcomponent = this.getZComponentInstance();
|
|
12
|
+
/**
|
|
13
|
+
* @zprop
|
|
14
|
+
* @zgroup Play Settings
|
|
15
|
+
* @zgrouppriority 20
|
|
16
|
+
* @zdefault false
|
|
17
|
+
*/
|
|
18
|
+
this.queue = false;
|
|
19
|
+
/**
|
|
20
|
+
* Seek the clip to the start before playing
|
|
21
|
+
*
|
|
22
|
+
* @zprop
|
|
23
|
+
* @zgroup Play Settings
|
|
24
|
+
* @zgrouppriority 20
|
|
25
|
+
* @zdefault false
|
|
26
|
+
*/
|
|
27
|
+
this.fromStart = false;
|
|
28
|
+
}
|
|
29
|
+
perform() {
|
|
30
|
+
if (!this.layerClip)
|
|
31
|
+
return;
|
|
32
|
+
const layerclip = this.zcomponent.animation.layerClipByID.get(this.layerClip);
|
|
33
|
+
if (!layerclip)
|
|
34
|
+
return;
|
|
35
|
+
const opts = {
|
|
36
|
+
loop: this.loop,
|
|
37
|
+
speed: this.speed,
|
|
38
|
+
fade: {
|
|
39
|
+
time: this.fadeTime,
|
|
40
|
+
pin: this.pin,
|
|
41
|
+
easing: this.easing
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
if (this.fromStart ?? false)
|
|
45
|
+
layerclip.seek(0, { dontActivateLayer: true });
|
|
46
|
+
if (this.queue ?? false)
|
|
47
|
+
layerclip.queue(opts);
|
|
48
|
+
else
|
|
49
|
+
layerclip.play(opts);
|
|
50
|
+
}
|
|
51
|
+
/** @zprop */
|
|
52
|
+
preview() {
|
|
53
|
+
this.perform();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export var Pin;
|
|
57
|
+
(function (Pin) {
|
|
58
|
+
Pin[Pin["Start"] = 0] = "Start";
|
|
59
|
+
Pin[Pin["Middle"] = 0.5] = "Middle";
|
|
60
|
+
Pin[Pin["End"] = 1] = "End";
|
|
61
|
+
})(Pin || (Pin = {}));
|
|
62
|
+
registerBehaviorRunAtDesignTime(PlayLayerClip);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ActionBehavior, ActionBehaviorConstructorProps } from "../actionbehavior";
|
|
2
|
+
import { Component } from "../component";
|
|
3
|
+
import { ContextManager } from "../context";
|
|
4
|
+
/**
|
|
5
|
+
* @zbehavior
|
|
6
|
+
* @zicon toggle_off
|
|
7
|
+
* @zgroup Animation Actions
|
|
8
|
+
*/
|
|
9
|
+
export declare class SetLayerOff extends ActionBehavior {
|
|
10
|
+
private zcomponent;
|
|
11
|
+
/**
|
|
12
|
+
* @zprop
|
|
13
|
+
* @zvalues layerids
|
|
14
|
+
*/
|
|
15
|
+
layer: string | undefined;
|
|
16
|
+
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
17
|
+
perform(): void;
|
|
18
|
+
/** @zprop */
|
|
19
|
+
preview(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ActionBehavior, } from "../actionbehavior";
|
|
2
|
+
import { registerBehaviorRunAtDesignTime } from "../behavior";
|
|
3
|
+
/**
|
|
4
|
+
* @zbehavior
|
|
5
|
+
* @zicon toggle_off
|
|
6
|
+
* @zgroup Animation Actions
|
|
7
|
+
*/
|
|
8
|
+
export class SetLayerOff extends ActionBehavior {
|
|
9
|
+
constructor(contextManager, instance, props) {
|
|
10
|
+
super(contextManager, instance, props);
|
|
11
|
+
this.zcomponent = this.getZComponentInstance();
|
|
12
|
+
}
|
|
13
|
+
perform() {
|
|
14
|
+
if (!this.layer)
|
|
15
|
+
return;
|
|
16
|
+
const layer = this.zcomponent.animation.layerByID.get(this.layer);
|
|
17
|
+
if (!layer)
|
|
18
|
+
return;
|
|
19
|
+
layer.active = null;
|
|
20
|
+
}
|
|
21
|
+
/** @zprop */
|
|
22
|
+
preview() {
|
|
23
|
+
this.perform();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
registerBehaviorRunAtDesignTime(SetLayerOff);
|
package/lib/data.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BehaviorByID, BehaviorData, ComputedHierarchy, EntityPropOverride, NodeByID, NodeData, ZComponentData } from
|
|
2
|
-
import { Prop } from
|
|
1
|
+
import { BehaviorByID, BehaviorData, ComputedHierarchy, EntityPropOverride, NodeByID, NodeData, ZComponentData } from './interfaces';
|
|
2
|
+
import { Prop } from './types';
|
|
3
3
|
export declare function computeNodeHierarchy(nodes: NodeByID): ComputedHierarchy;
|
|
4
4
|
export declare function computeBehaviorHierarchy(behaviors: BehaviorByID): ComputedHierarchy;
|
|
5
5
|
export declare function addNode(zcomp: ZComponentData, info: NodeDataCombined): void;
|
|
@@ -8,6 +8,7 @@ export declare function updateComponentProp(zcomp: ZComponentData, prop: string,
|
|
|
8
8
|
export declare function addEntityPropOverride(zcomp: ZComponentData, o: EntityPropOverride): void;
|
|
9
9
|
export declare function deleteEntityPropOverride(zcomp: ZComponentData, id: string): void;
|
|
10
10
|
export declare function clone<T>(obj: T): T;
|
|
11
|
+
export declare function isEqual<T>(obj1: T, obj2: T): boolean;
|
|
11
12
|
export declare function addEntity(zcomp: ZComponentData, id: string, info: EntityDataCombined): void;
|
|
12
13
|
export declare function moveNodes(zcomp: ZComponentData, nodeIDs: string[], newParentID: string, indx: number): void;
|
|
13
14
|
export declare function deleteNode(zcomp: ZComponentData, id: string): void;
|
package/lib/data.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { generateKeyBetween, generateNKeysBetween } from
|
|
2
|
-
import { EntityPropOverrideType } from
|
|
1
|
+
import { generateKeyBetween, generateNKeysBetween } from './fractionalindexing';
|
|
2
|
+
import { EntityPropOverrideType } from './interfaces';
|
|
3
3
|
// Simple memoizing of computed hierarchy
|
|
4
4
|
const computedHierarchies = new Map();
|
|
5
5
|
const computedBehaviors = new Map();
|
|
@@ -129,7 +129,7 @@ export function deleteEntityPropOverride(zcomp, id) {
|
|
|
129
129
|
delete zcomp.entityPropOverrides[id];
|
|
130
130
|
}
|
|
131
131
|
function idForEntityPropOverride(override) {
|
|
132
|
-
return override.type +
|
|
132
|
+
return (override.type + ':' + (override.entityPropIsConstructor ? 'constructorprop' : 'prop') + ':' + override.entityID + ':' + override.entityPropPath.join('.'));
|
|
133
133
|
}
|
|
134
134
|
export function clone(obj) {
|
|
135
135
|
try {
|
|
@@ -141,6 +141,9 @@ export function clone(obj) {
|
|
|
141
141
|
}
|
|
142
142
|
return JSON.parse(JSON.stringify(obj));
|
|
143
143
|
}
|
|
144
|
+
export function isEqual(obj1, obj2) {
|
|
145
|
+
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
|
146
|
+
}
|
|
144
147
|
export function addEntity(zcomp, id, info) {
|
|
145
148
|
zcomp.entityProps[id] = info.props;
|
|
146
149
|
zcomp.entityConstructorProps[id] = info.constructorProps;
|
|
@@ -192,7 +195,7 @@ export function getNodeDataCombined(zcomp, id) {
|
|
|
192
195
|
return {
|
|
193
196
|
data,
|
|
194
197
|
props: zcomp.entityProps[id] ?? {},
|
|
195
|
-
constructorProps: zcomp.entityConstructorProps[id] ?? {}
|
|
198
|
+
constructorProps: zcomp.entityConstructorProps[id] ?? {},
|
|
196
199
|
};
|
|
197
200
|
}
|
|
198
201
|
export function getBehaviorDataCombined(zcomp, id) {
|
|
@@ -202,7 +205,7 @@ export function getBehaviorDataCombined(zcomp, id) {
|
|
|
202
205
|
return {
|
|
203
206
|
data,
|
|
204
207
|
props: zcomp.entityProps[id] ?? {},
|
|
205
|
-
constructorProps: zcomp.entityConstructorProps[id] ?? {}
|
|
208
|
+
constructorProps: zcomp.entityConstructorProps[id] ?? {},
|
|
206
209
|
};
|
|
207
210
|
}
|
|
208
211
|
export function fixAnyDuplicateIndex(zcomp, hierarchy, nodeID, indx) {
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from './contexts/tagcontext';
|
|
|
13
13
|
export * from './contexts/gamepadcontext';
|
|
14
14
|
export * from './observable';
|
|
15
15
|
export * from './contexts/environmentcontext';
|
|
16
|
+
export * from './animation';
|
|
16
17
|
const link = document.createElement('link');
|
|
17
18
|
link.setAttribute('rel', 'stylesheet');
|
|
18
19
|
link.setAttribute('href', new URL('../css/zcomponent.css', import.meta.url).toString());
|
package/lib/inflate.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Track } from './animation/tracks/track';
|
|
2
|
+
import * as Data from './animation';
|
|
3
|
+
import { ZComponent } from './zcomponent';
|
|
4
|
+
import { Clip } from './animation/clips/clip';
|
|
5
|
+
import { Animation } from './animation/animation';
|
|
6
|
+
import { LayerClip } from './animation/layerclip';
|
|
7
|
+
import { Layer } from './animation/layer';
|
|
8
|
+
export declare function createTrackFromData(zcomp: ZComponent, anim: Animation, data: Data.Track): Track | undefined;
|
|
9
|
+
export declare function createClipFromData(zcomp: ZComponent, anim: Animation, data: Data.Clip): Clip;
|
|
10
|
+
export declare function updateClipFromData(zcomp: ZComponent, clip: Clip, data: Data.Clip): void;
|
|
11
|
+
export declare function createLayerClipFromData(zcomp: ZComponent, layer: Layer, data: Data.LayerClip): LayerClip | undefined;
|
|
12
|
+
export declare function createLayerFromData(zcomp: ZComponent, anim: Animation, data: Data.Layer): Layer | undefined;
|
|
13
|
+
export declare function populateAnimationFromData(zcomp: ZComponent, anim: Animation, data: Data.Animation): void;
|