@zcomponent/core 0.0.22 → 0.0.23
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/clips/clip.d.ts +2 -2
- package/lib/animation/clips/clip.js +1 -4
- package/lib/animation/layer.d.ts +2 -1
- package/lib/animation/layer.js +10 -15
- package/lib/data/animation.d.ts +2 -2
- package/lib/data/change.d.ts +1 -0
- package/lib/data/change.js +21 -0
- package/lib/inflate.js +1 -0
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ export declare class Clip {
|
|
|
8
8
|
readonly scriptName?: string | undefined;
|
|
9
9
|
readonly id?: string | undefined;
|
|
10
10
|
influencedPathsDirty: Observable<boolean, never>;
|
|
11
|
-
defaultFadeParameters?: Data.FadeParameters
|
|
11
|
+
defaultFadeParameters?: Partial<Data.FadeParameters>;
|
|
12
12
|
private _influencedPaths;
|
|
13
13
|
private _tracksByPath;
|
|
14
14
|
private _tracksByPathDirty;
|
|
@@ -21,7 +21,7 @@ export declare class Clip {
|
|
|
21
21
|
get tracksByPath(): Map<string, Track[]>;
|
|
22
22
|
get influencedPaths(): string[];
|
|
23
23
|
fadePropertiesByPath(props: {
|
|
24
|
-
[id: string]: Data.FadeParameters
|
|
24
|
+
[id: string]: Partial<Data.FadeParameters>;
|
|
25
25
|
}): void;
|
|
26
26
|
resolveClipTime(t: number, t0: number, s0: number, rate: number, t1?: number): number;
|
|
27
27
|
streamPlay(speed?: number): void;
|
|
@@ -76,16 +76,13 @@ export class Clip {
|
|
|
76
76
|
if (this.defaultFadeParameters) {
|
|
77
77
|
// Replace any existing fade properties with our defaults
|
|
78
78
|
for (const id in props) {
|
|
79
|
-
props[id] = { ...this.defaultFadeParameters };
|
|
79
|
+
props[id] = { ...props[id], ...this.defaultFadeParameters };
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
for (const track of this._tracks) {
|
|
83
83
|
if (track instanceof PropertyTrack) {
|
|
84
84
|
if (track.fadeParameters || this.defaultFadeParameters) {
|
|
85
85
|
const params = {
|
|
86
|
-
time: 0,
|
|
87
|
-
easing: null,
|
|
88
|
-
pin: 0,
|
|
89
86
|
...this.defaultFadeParameters,
|
|
90
87
|
...track.fadeParameters,
|
|
91
88
|
};
|
package/lib/animation/layer.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare class Layer {
|
|
|
10
10
|
clips: {
|
|
11
11
|
[id: string]: LayerClip;
|
|
12
12
|
};
|
|
13
|
+
defaultFadeParameters?: Data.FadeParameters;
|
|
13
14
|
influencedPathsDirty: Observable<boolean, never>;
|
|
14
15
|
private _influencedPaths;
|
|
15
16
|
private _active;
|
|
@@ -40,7 +41,7 @@ export interface QueueEntry {
|
|
|
40
41
|
layerClip: LayerClip | null;
|
|
41
42
|
playOptions?: LayerClipPlayOptions;
|
|
42
43
|
fadeByPath: {
|
|
43
|
-
[id: string]: Data.FadeParameters
|
|
44
|
+
[id: string]: Partial<Data.FadeParameters>;
|
|
44
45
|
};
|
|
45
46
|
fadeTime: number;
|
|
46
47
|
startTime?: number;
|
package/lib/animation/layer.js
CHANGED
|
@@ -25,7 +25,7 @@ export class Layer {
|
|
|
25
25
|
if (ct >= entry.fadeTime)
|
|
26
26
|
fadeValue = clipValue;
|
|
27
27
|
else
|
|
28
|
-
fadeValue = computeFade(entry.fadeByPath[p], entry.playOptions?.fade, ct, entry.fadeTime, fadeValue, clipValue);
|
|
28
|
+
fadeValue = computeFade(this.defaultFadeParameters, entry.fadeByPath[p], entry.playOptions?.fade, ct, entry.fadeTime, fadeValue, clipValue);
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
fadeValue = clipValue;
|
|
@@ -71,20 +71,15 @@ export class Layer {
|
|
|
71
71
|
this.influencedPathsDirty.value = true;
|
|
72
72
|
}
|
|
73
73
|
queue(layerClip, playOptions) {
|
|
74
|
-
const previous = this._queue[this._queue.length - 1];
|
|
75
74
|
const fadeByPath = {};
|
|
76
|
-
previous?.layerClip?.clip?.fadePropertiesByPath(fadeByPath);
|
|
77
|
-
for (const [path, params] of Object.entries(fadeByPath)) {
|
|
78
|
-
fadeByPath[path] = {
|
|
79
|
-
...params,
|
|
80
|
-
reverse: !(params.reverse ?? false),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
75
|
layerClip?.clip?.fadePropertiesByPath(fadeByPath);
|
|
84
76
|
let fadeTime = playOptions?.fade?.time ?? 0;
|
|
85
77
|
for (const params of Object.values(fadeByPath)) {
|
|
86
|
-
|
|
78
|
+
if (params.time !== undefined)
|
|
79
|
+
fadeTime = Math.max(fadeTime, params.time);
|
|
87
80
|
}
|
|
81
|
+
if (this.defaultFadeParameters)
|
|
82
|
+
fadeTime = Math.max(fadeTime, this.defaultFadeParameters.time);
|
|
88
83
|
const ret = {
|
|
89
84
|
layerClip,
|
|
90
85
|
fadeTime,
|
|
@@ -197,11 +192,11 @@ export class Layer {
|
|
|
197
192
|
return this._influencedPaths;
|
|
198
193
|
}
|
|
199
194
|
}
|
|
200
|
-
function computeFade(params, override, t, fadeTime, before, after) {
|
|
195
|
+
function computeFade(defaults, params, override, t, fadeTime, before, after) {
|
|
201
196
|
// TODO further implementation
|
|
202
|
-
const paramTime = override?.time ?? params?.time ?? 0;
|
|
203
|
-
let paramPin = override?.pin ?? params?.pin ?? 0;
|
|
204
|
-
const reverse = override?.reverse ?? params?.reverse ?? false;
|
|
197
|
+
const paramTime = override?.time ?? params?.time ?? defaults?.time ?? 0;
|
|
198
|
+
let paramPin = override?.pin ?? params?.pin ?? defaults?.pin ?? 0;
|
|
199
|
+
const reverse = override?.reverse ?? params?.reverse ?? defaults?.reverse ?? false;
|
|
205
200
|
if (reverse)
|
|
206
201
|
paramPin = 1 - paramPin;
|
|
207
202
|
const emptyTime = fadeTime - paramTime;
|
|
@@ -213,7 +208,7 @@ function computeFade(params, override, t, fadeTime, before, after) {
|
|
|
213
208
|
let prop = (t - startTime) / paramTime;
|
|
214
209
|
if (reverse)
|
|
215
210
|
prop = 1 - prop;
|
|
216
|
-
prop = computeEasing(prop, override?.easing ?? params?.easing);
|
|
211
|
+
prop = computeEasing(prop, override?.easing ?? params?.easing ?? defaults?.easing);
|
|
217
212
|
if (reverse)
|
|
218
213
|
prop = 1 - prop;
|
|
219
214
|
return interpolate(before, after, prop);
|
package/lib/data/animation.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export interface Clip {
|
|
|
51
51
|
tracks: ByID<Track>;
|
|
52
52
|
length: number;
|
|
53
53
|
lengthType: ClipLengthType;
|
|
54
|
-
defaultFadeParameters?: FadeParameters
|
|
54
|
+
defaultFadeParameters?: Partial<FadeParameters>;
|
|
55
55
|
timeSourceTrack?: string;
|
|
56
56
|
scriptName?: string;
|
|
57
57
|
}
|
|
@@ -117,7 +117,7 @@ export interface StreamTrack extends BaseTrack {
|
|
|
117
117
|
data: ByID<StreamTrackEntity>;
|
|
118
118
|
weight: ByID<Keyframe>;
|
|
119
119
|
}
|
|
120
|
-
export interface StreamTrackEntity {
|
|
120
|
+
export interface StreamTrackEntity extends BaseTrack {
|
|
121
121
|
t0: number;
|
|
122
122
|
t1: number;
|
|
123
123
|
s0: number;
|
package/lib/data/change.d.ts
CHANGED
package/lib/data/change.js
CHANGED
|
@@ -350,6 +350,16 @@ export function deleteEntity(zcomp, id) {
|
|
|
350
350
|
delete zcomp.entityPropOverrides[overrideID];
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
|
+
if (zcomp.animation) {
|
|
354
|
+
for (const clip of Object.values(zcomp.animation.clips)) {
|
|
355
|
+
if (!clip)
|
|
356
|
+
continue;
|
|
357
|
+
for (const track of Object.values(clip.tracks)) {
|
|
358
|
+
if (track?.entityID === id)
|
|
359
|
+
delete clip.tracks[track.id];
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
353
363
|
}
|
|
354
364
|
export function forEachNodeAncestor(zcomp, id, fn) {
|
|
355
365
|
const node = zcomp.nodes[id];
|
|
@@ -358,3 +368,14 @@ export function forEachNodeAncestor(zcomp, id, fn) {
|
|
|
358
368
|
fn(node.parent.id);
|
|
359
369
|
forEachNodeAncestor(zcomp, node.parent.id, fn);
|
|
360
370
|
}
|
|
371
|
+
export function getUniqueLabel(zcomp, label) {
|
|
372
|
+
const existingLabels = zcomp.entitiesByLabel ?? {};
|
|
373
|
+
for (let i = 1; i < 10000; i++) {
|
|
374
|
+
const testName = i === 1 ? label : `${label} ${i.toString()}`;
|
|
375
|
+
if (!Object.prototype.hasOwnProperty.call(existingLabels, testName)) {
|
|
376
|
+
label = testName;
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return label;
|
|
381
|
+
}
|
package/lib/inflate.js
CHANGED
|
@@ -94,6 +94,7 @@ export function createLayerClipFromData(zcomp, layer, data) {
|
|
|
94
94
|
export function createLayerFromData(zcomp, anim, data) {
|
|
95
95
|
const ret = new Layer(anim, data.scriptName, data.id);
|
|
96
96
|
ret.active = undefined;
|
|
97
|
+
ret.defaultFadeParameters = data.defaultFadeParameters;
|
|
97
98
|
if (data.defaultClip === null)
|
|
98
99
|
ret.active = null;
|
|
99
100
|
for (const layerClip of Object.values(data.clips)) {
|