@zcomponent/core 1.24.0 → 1.25.0-beta.2
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 +2 -0
- package/lib/animation/animation.js +9 -0
- package/lib/animation/layer.js +10 -0
- package/lib/animation/layerclip.d.ts +1 -0
- package/lib/animation/layerclip.js +1 -0
- package/lib/data/change.js +1 -1
- package/lib/selectors.js +12 -2
- package/lib/types.d.ts +1 -0
- package/lib/types.js +1 -0
- package/lib/zcomponent.js +21 -6
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ import { Track } from './tracks/track';
|
|
|
8
8
|
import { Bezier } from './bezier';
|
|
9
9
|
/** @internal */
|
|
10
10
|
export declare enum AnimationEvents {
|
|
11
|
+
onLayerClipNotActive = "onLayerClipNotActive",
|
|
11
12
|
onLayerClipActive = "onLayerClipActive",
|
|
12
13
|
onLayerClipState = "onLayerClipState"
|
|
13
14
|
}
|
|
@@ -39,6 +40,7 @@ export declare class Animation {
|
|
|
39
40
|
[id: string]: Bezier;
|
|
40
41
|
};
|
|
41
42
|
onTick: Event<[]>;
|
|
43
|
+
onLayerClipNotActive: Event<[layerClip: LayerClip]>;
|
|
42
44
|
onLayerClipActive: Event<[layerClip: LayerClip]>;
|
|
43
45
|
onLayerClipState: Event<[layerClip: LayerClip]>;
|
|
44
46
|
/**
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Observable } from '../observable';
|
|
2
2
|
import { Event } from '../event';
|
|
3
|
+
import { LayerClip } from './layerclip';
|
|
3
4
|
/** @internal */
|
|
4
5
|
export var AnimationEvents;
|
|
5
6
|
(function (AnimationEvents) {
|
|
7
|
+
AnimationEvents["onLayerClipNotActive"] = "onLayerClipNotActive";
|
|
6
8
|
AnimationEvents["onLayerClipActive"] = "onLayerClipActive";
|
|
7
9
|
AnimationEvents["onLayerClipState"] = "onLayerClipState";
|
|
8
10
|
})(AnimationEvents || (AnimationEvents = {}));
|
|
@@ -33,6 +35,7 @@ export class Animation {
|
|
|
33
35
|
this.clips = Object.create(null);
|
|
34
36
|
this.curves = Object.create(null);
|
|
35
37
|
this.onTick = new Event();
|
|
38
|
+
this.onLayerClipNotActive = new Event();
|
|
36
39
|
this.onLayerClipActive = new Event();
|
|
37
40
|
this.onLayerClipState = new Event();
|
|
38
41
|
/**
|
|
@@ -255,6 +258,12 @@ export class Animation {
|
|
|
255
258
|
const entry = this._pendingEvents.shift();
|
|
256
259
|
if (!entry)
|
|
257
260
|
continue;
|
|
261
|
+
if (entry.evt === AnimationEvents.onLayerClipNotActive && entry.args[0] instanceof LayerClip) {
|
|
262
|
+
entry.args[0].active.value = false;
|
|
263
|
+
}
|
|
264
|
+
else if (entry.evt === AnimationEvents.onLayerClipActive && entry.args[0] instanceof LayerClip) {
|
|
265
|
+
entry.args[0].active.value = true;
|
|
266
|
+
}
|
|
258
267
|
this[entry.evt].emit(...entry.args);
|
|
259
268
|
}
|
|
260
269
|
}
|
package/lib/animation/layer.js
CHANGED
|
@@ -75,6 +75,8 @@ export class Layer {
|
|
|
75
75
|
if (entry.layerClip && entry === this._active) {
|
|
76
76
|
if (next && (entry.layerClip.state.value === StreamState.Ended || next.fadeTime >= entry.layerClip.getRemainingTimeEstimate())) {
|
|
77
77
|
next.startTime = t;
|
|
78
|
+
if (this._active?.layerClip)
|
|
79
|
+
this.animation._pendingEvents.push({ evt: AnimationEvents.onLayerClipNotActive, args: [this._active.layerClip] });
|
|
78
80
|
this._active = next;
|
|
79
81
|
this.animation._pendingEvents.push({ evt: AnimationEvents.onLayerClipActive, args: [this._active.layerClip] });
|
|
80
82
|
next.layerClip?.play();
|
|
@@ -158,6 +160,8 @@ export class Layer {
|
|
|
158
160
|
_activateLayerClip(layerClip, playOptions) {
|
|
159
161
|
if (layerClip === undefined) {
|
|
160
162
|
this._queue = [];
|
|
163
|
+
if (this._active?.layerClip)
|
|
164
|
+
this.animation._pendingEvents.push({ evt: AnimationEvents.onLayerClipNotActive, args: [this._active.layerClip] });
|
|
161
165
|
this._active = undefined;
|
|
162
166
|
this.animation._pendingEvents.push({ evt: AnimationEvents.onLayerClipActive, args: [undefined] });
|
|
163
167
|
return;
|
|
@@ -175,6 +179,8 @@ export class Layer {
|
|
|
175
179
|
...playOptions,
|
|
176
180
|
fade: playOptions?.fade !== undefined ? playOptions.fade : this._active === undefined || layerClip === undefined ? { time: 0, easing: null } : undefined,
|
|
177
181
|
});
|
|
182
|
+
if (this._active?.layerClip)
|
|
183
|
+
this.animation._pendingEvents.push({ evt: AnimationEvents.onLayerClipNotActive, args: [this._active.layerClip] });
|
|
178
184
|
this._active = entry;
|
|
179
185
|
this.animation._pendingEvents.push({ evt: AnimationEvents.onLayerClipActive, args: [this._active.layerClip] });
|
|
180
186
|
this._queue[this._queue.length - 1].startTime = this.animation.timeSource?.() ?? performance.now();
|
|
@@ -240,11 +246,15 @@ export class Layer {
|
|
|
240
246
|
this._queue.push(mqe);
|
|
241
247
|
}
|
|
242
248
|
}
|
|
249
|
+
if (this._active?.layerClip)
|
|
250
|
+
this.animation._pendingEvents.push({ evt: AnimationEvents.onLayerClipNotActive, args: [this._active.layerClip] });
|
|
243
251
|
if (typeof entry.active === 'number') {
|
|
244
252
|
this._active = this._queue[entry.active];
|
|
245
253
|
}
|
|
246
254
|
else
|
|
247
255
|
this._active = entry.active;
|
|
256
|
+
if (this._active?.layerClip)
|
|
257
|
+
this.animation._pendingEvents.push({ evt: AnimationEvents.onLayerClipActive, args: [this._active.layerClip] });
|
|
248
258
|
}
|
|
249
259
|
/**
|
|
250
260
|
* Gets the set of paths influenced by the layer.
|
|
@@ -50,6 +50,7 @@ export declare class LayerClip implements Stream {
|
|
|
50
50
|
state: Observable<StreamState, never>;
|
|
51
51
|
playing: Observable<boolean, never>;
|
|
52
52
|
stalled: Observable<boolean, never>;
|
|
53
|
+
active: Observable<boolean, never>;
|
|
53
54
|
onPlaying: Event<[LayerClip]>;
|
|
54
55
|
onPaused: Event<[LayerClip]>;
|
|
55
56
|
onEnded: Event<[LayerClip]>;
|
|
@@ -43,6 +43,7 @@ export class LayerClip {
|
|
|
43
43
|
this.state = new Observable(this._state);
|
|
44
44
|
this.playing = new Observable(false);
|
|
45
45
|
this.stalled = new Observable(false);
|
|
46
|
+
this.active = new Observable(false);
|
|
46
47
|
this.onPlaying = new Event();
|
|
47
48
|
this.onPaused = new Event();
|
|
48
49
|
this.onEnded = new Event();
|
package/lib/data/change.js
CHANGED
|
@@ -466,7 +466,7 @@ export function removeNodeScriptNameFromRegister(zcomp, id) {
|
|
|
466
466
|
if (!node)
|
|
467
467
|
return;
|
|
468
468
|
if (node.scriptName) {
|
|
469
|
-
if (zcomp.entitiesByScriptName) {
|
|
469
|
+
if (zcomp.entitiesByScriptName?.[node.scriptName]) {
|
|
470
470
|
delete zcomp.entitiesByScriptName[node.scriptName][id];
|
|
471
471
|
if (Object.keys(zcomp.entitiesByScriptName[node.scriptName]).length === 0) {
|
|
472
472
|
delete zcomp.entitiesByScriptName[node.scriptName];
|
package/lib/selectors.js
CHANGED
|
@@ -349,10 +349,20 @@ ${Object.entries(scriptNames ?? {})
|
|
|
349
349
|
.map(entry => {
|
|
350
350
|
const values = Object.keys(entry[1]);
|
|
351
351
|
if (values.length > 1) {
|
|
352
|
-
return `\t\t${entry[0]}: {${values
|
|
352
|
+
return `\t\t${entry[0]}: {${values
|
|
353
|
+
.map(e => {
|
|
354
|
+
const node = nodes[e];
|
|
355
|
+
if (!node)
|
|
356
|
+
return `${JSON.stringify(e)}: any,`;
|
|
357
|
+
return `${JSON.stringify(e)}: ${importMapping.get(nodes[e].type)}${getBehaviorBlockForNode(behaviors, behaviorsByNodeID[nodes[e].id] ?? [], importMapping)}`;
|
|
358
|
+
})
|
|
359
|
+
.join(', ')}},`;
|
|
353
360
|
}
|
|
354
361
|
else {
|
|
355
|
-
|
|
362
|
+
const node = nodes[values[0]];
|
|
363
|
+
if (!node)
|
|
364
|
+
return `\t\t${entry[0]}: any,`;
|
|
365
|
+
return `\t\t${entry[0]}: ${importMapping.get(node.type)}${getBehaviorBlockForNode(behaviors, behaviorsByNodeID[node.id] ?? [], importMapping)},`;
|
|
356
366
|
}
|
|
357
367
|
})
|
|
358
368
|
.join('\n')}
|
package/lib/types.d.ts
CHANGED
|
@@ -180,6 +180,7 @@ export declare enum ValuesType {
|
|
|
180
180
|
'morphTargets' = "morphTargets",
|
|
181
181
|
'events' = "events",
|
|
182
182
|
'parentNodes' = "parentNodes",
|
|
183
|
+
'parentMaterials' = "parentMaterials",
|
|
183
184
|
'nodelabels' = "nodelabels",
|
|
184
185
|
'nodeids' = "nodeids",
|
|
185
186
|
'layerclipids' = "layerclipids",
|
package/lib/types.js
CHANGED
|
@@ -61,6 +61,7 @@ export var ValuesType;
|
|
|
61
61
|
ValuesType["morphTargets"] = "morphTargets";
|
|
62
62
|
ValuesType["events"] = "events";
|
|
63
63
|
ValuesType["parentNodes"] = "parentNodes";
|
|
64
|
+
ValuesType["parentMaterials"] = "parentMaterials";
|
|
64
65
|
ValuesType["nodelabels"] = "nodelabels";
|
|
65
66
|
ValuesType["nodeids"] = "nodeids";
|
|
66
67
|
ValuesType["layerclipids"] = "layerclipids";
|
package/lib/zcomponent.js
CHANGED
|
@@ -279,8 +279,13 @@ export class ZComponent extends Component {
|
|
|
279
279
|
*/
|
|
280
280
|
resolveNodeID(id, type) {
|
|
281
281
|
const entity = this.entityByID.get(id);
|
|
282
|
-
|
|
283
|
-
|
|
282
|
+
try {
|
|
283
|
+
if (!entity)
|
|
284
|
+
return this.getZComponentInstance()?.resolveNodeID(id, type);
|
|
285
|
+
}
|
|
286
|
+
catch (err) {
|
|
287
|
+
return undefined;
|
|
288
|
+
}
|
|
284
289
|
if (!(entity instanceof Component))
|
|
285
290
|
return undefined;
|
|
286
291
|
if (!type)
|
|
@@ -295,8 +300,13 @@ export class ZComponent extends Component {
|
|
|
295
300
|
*/
|
|
296
301
|
resolveBehaviorID(id, type) {
|
|
297
302
|
const entity = this.entityByID.get(id);
|
|
298
|
-
|
|
299
|
-
|
|
303
|
+
try {
|
|
304
|
+
if (!entity)
|
|
305
|
+
return this.getZComponentInstance()?.resolveBehaviorID(id, type);
|
|
306
|
+
}
|
|
307
|
+
catch (err) {
|
|
308
|
+
return undefined;
|
|
309
|
+
}
|
|
300
310
|
if (!(entity instanceof Behavior))
|
|
301
311
|
return undefined;
|
|
302
312
|
if (!type)
|
|
@@ -314,8 +324,13 @@ export class ZComponent extends Component {
|
|
|
314
324
|
*/
|
|
315
325
|
resolveEntityID(id) {
|
|
316
326
|
const entity = this.entityByID.get(id);
|
|
317
|
-
|
|
318
|
-
|
|
327
|
+
try {
|
|
328
|
+
if (!entity)
|
|
329
|
+
return this.getZComponentInstance()?.resolveEntityID(id);
|
|
330
|
+
}
|
|
331
|
+
catch (err) {
|
|
332
|
+
return undefined;
|
|
333
|
+
}
|
|
319
334
|
if (!(entity instanceof Entity))
|
|
320
335
|
return undefined;
|
|
321
336
|
return entity;
|