@galacean/effects-core 2.0.0-alpha.13 → 2.0.0-alpha.14
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/index.js +129 -97
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +129 -97
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/cal/calculate-item.d.ts +2 -4
- package/dist/plugins/cal/timeline-asset.d.ts +2 -2
- package/dist/plugins/timeline/track.d.ts +2 -3
- package/dist/plugins/timeline/tracks/activation-track.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.14
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -17452,6 +17452,9 @@ class ActivationPlayableAsset extends PlayableAsset {
|
|
|
17452
17452
|
return new ActivationPlayable(graph);
|
|
17453
17453
|
}
|
|
17454
17454
|
}
|
|
17455
|
+
ActivationPlayableAsset = __decorate([
|
|
17456
|
+
effectsClass('ActivationPlayableAsset')
|
|
17457
|
+
], ActivationPlayableAsset);
|
|
17455
17458
|
class AnimationClip extends EffectsObject {
|
|
17456
17459
|
sampleAnimation(vfxItem, time) {
|
|
17457
17460
|
const duration = vfxItem.duration;
|
|
@@ -17599,6 +17602,9 @@ class TrackAsset extends PlayableAsset {
|
|
|
17599
17602
|
getChildTracks() {
|
|
17600
17603
|
return this.children;
|
|
17601
17604
|
}
|
|
17605
|
+
addChild(child) {
|
|
17606
|
+
this.children.push(child);
|
|
17607
|
+
}
|
|
17602
17608
|
createClip(classConstructor, name) {
|
|
17603
17609
|
const newClip = new TimelineClip();
|
|
17604
17610
|
newClip.asset = new classConstructor(this.engine);
|
|
@@ -17680,9 +17686,10 @@ class RuntimeClip {
|
|
|
17680
17686
|
let weight = 1.0;
|
|
17681
17687
|
let ended = false;
|
|
17682
17688
|
let started = false;
|
|
17689
|
+
const boundItem = this.track.binding;
|
|
17683
17690
|
if (localTime > clip.start + clip.duration + 0.001 && clip.endBehaviour === ItemEndBehavior.destroy) {
|
|
17684
|
-
var
|
|
17685
|
-
if (VFXItem.isParticle(
|
|
17691
|
+
var _boundItem_getComponent;
|
|
17692
|
+
if (VFXItem.isParticle(boundItem) && !((_boundItem_getComponent = boundItem.getComponent(ParticleSystem)) == null ? void 0 : _boundItem_getComponent.destroyed)) {
|
|
17686
17693
|
weight = 1.0;
|
|
17687
17694
|
} else {
|
|
17688
17695
|
weight = 0.0;
|
|
@@ -17698,7 +17705,6 @@ class RuntimeClip {
|
|
|
17698
17705
|
this.playable.play();
|
|
17699
17706
|
}
|
|
17700
17707
|
this.parentMixer.setInputWeight(this.playable, weight);
|
|
17701
|
-
const boundItem = this.track.binding;
|
|
17702
17708
|
// 判断动画是否结束
|
|
17703
17709
|
if (ended && !boundItem.ended) {
|
|
17704
17710
|
boundItem.ended = true;
|
|
@@ -17727,6 +17733,53 @@ class RuntimeClip {
|
|
|
17727
17733
|
}
|
|
17728
17734
|
}
|
|
17729
17735
|
|
|
17736
|
+
class ObjectBindingTrack extends TrackAsset {
|
|
17737
|
+
create(timelineAsset) {
|
|
17738
|
+
const boundItem = this.binding;
|
|
17739
|
+
this.options = {
|
|
17740
|
+
start: boundItem.start,
|
|
17741
|
+
duration: boundItem.duration,
|
|
17742
|
+
looping: boundItem.endBehavior === ItemEndBehavior.loop,
|
|
17743
|
+
endBehavior: boundItem.endBehavior || ItemEndBehavior.destroy
|
|
17744
|
+
};
|
|
17745
|
+
this.name = boundItem.name;
|
|
17746
|
+
// 添加粒子动画 clip
|
|
17747
|
+
if (boundItem.getComponent(ParticleSystem)) {
|
|
17748
|
+
const particleTrack = timelineAsset.createTrack(TrackAsset, this, 'ParticleTrack');
|
|
17749
|
+
particleTrack.binding = this.binding;
|
|
17750
|
+
const particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
|
|
17751
|
+
particleClip.start = boundItem.start;
|
|
17752
|
+
particleClip.duration = boundItem.duration;
|
|
17753
|
+
particleClip.endBehaviour = boundItem.endBehavior;
|
|
17754
|
+
}
|
|
17755
|
+
}
|
|
17756
|
+
toLocalTime(time) {
|
|
17757
|
+
let localTime = time - this.options.start;
|
|
17758
|
+
const duration = this.options.duration;
|
|
17759
|
+
if (localTime - duration > 0.001) {
|
|
17760
|
+
if (this.options.endBehavior === END_BEHAVIOR_RESTART) {
|
|
17761
|
+
localTime = localTime % duration;
|
|
17762
|
+
} else if (this.options.endBehavior === END_BEHAVIOR_FREEZE) {
|
|
17763
|
+
localTime = Math.min(duration, localTime);
|
|
17764
|
+
}
|
|
17765
|
+
}
|
|
17766
|
+
return localTime;
|
|
17767
|
+
}
|
|
17768
|
+
fromData(data) {
|
|
17769
|
+
super.fromData(data);
|
|
17770
|
+
this.data = data;
|
|
17771
|
+
}
|
|
17772
|
+
}
|
|
17773
|
+
ObjectBindingTrack = __decorate([
|
|
17774
|
+
effectsClass('ObjectBindingTrack')
|
|
17775
|
+
], ObjectBindingTrack);
|
|
17776
|
+
|
|
17777
|
+
class TransformTrack extends TrackAsset {
|
|
17778
|
+
}
|
|
17779
|
+
TransformTrack = __decorate([
|
|
17780
|
+
effectsClass('TransformTrack')
|
|
17781
|
+
], TransformTrack);
|
|
17782
|
+
|
|
17730
17783
|
class ActivationMixerPlayable extends Playable {
|
|
17731
17784
|
processFrame(context) {
|
|
17732
17785
|
if (!this.bindingItem) {
|
|
@@ -17768,6 +17821,9 @@ class ActivationMixerPlayable extends Playable {
|
|
|
17768
17821
|
}
|
|
17769
17822
|
|
|
17770
17823
|
class ActivationTrack extends TrackAsset {
|
|
17824
|
+
initializeBinding(parentBinding) {
|
|
17825
|
+
this.binding = parentBinding;
|
|
17826
|
+
}
|
|
17771
17827
|
createTrackMixer(graph) {
|
|
17772
17828
|
return new ActivationMixerPlayable(graph);
|
|
17773
17829
|
}
|
|
@@ -17776,73 +17832,6 @@ ActivationTrack = __decorate([
|
|
|
17776
17832
|
effectsClass('ActivationTrack')
|
|
17777
17833
|
], ActivationTrack);
|
|
17778
17834
|
|
|
17779
|
-
class ObjectBindingTrack extends TrackAsset {
|
|
17780
|
-
create() {
|
|
17781
|
-
this.options = {
|
|
17782
|
-
start: this.binding.start,
|
|
17783
|
-
duration: this.binding.duration,
|
|
17784
|
-
looping: this.binding.endBehavior === ItemEndBehavior.loop,
|
|
17785
|
-
endBehavior: this.binding.endBehavior || ItemEndBehavior.destroy
|
|
17786
|
-
};
|
|
17787
|
-
this.id = this.binding.id;
|
|
17788
|
-
this.name = this.binding.name;
|
|
17789
|
-
const activationTrack = this.createTrack(ActivationTrack, 'ActivationTrack');
|
|
17790
|
-
activationTrack.binding = this.binding;
|
|
17791
|
-
activationTrack.createClip(ActivationPlayableAsset, 'ActivationTimelineClip');
|
|
17792
|
-
// 添加粒子动画 clip
|
|
17793
|
-
if (this.binding.getComponent(ParticleSystem)) {
|
|
17794
|
-
const particleTrack = this.createTrack(TrackAsset, 'ParticleTrack');
|
|
17795
|
-
particleTrack.binding = this.binding;
|
|
17796
|
-
particleTrack.createClip(ParticleBehaviourPlayableAsset);
|
|
17797
|
-
}
|
|
17798
|
-
// TODO TimelineClip 需要传入 start 和 duration 数据
|
|
17799
|
-
for (const track of this.children){
|
|
17800
|
-
for (const clip of track.getClips()){
|
|
17801
|
-
clip.start = this.binding.start;
|
|
17802
|
-
clip.duration = this.binding.duration;
|
|
17803
|
-
clip.endBehaviour = this.binding.endBehavior;
|
|
17804
|
-
}
|
|
17805
|
-
}
|
|
17806
|
-
}
|
|
17807
|
-
toLocalTime(time) {
|
|
17808
|
-
let localTime = time - this.options.start;
|
|
17809
|
-
const duration = this.options.duration;
|
|
17810
|
-
if (localTime - duration > 0.001) {
|
|
17811
|
-
if (this.options.endBehavior === END_BEHAVIOR_RESTART) {
|
|
17812
|
-
localTime = localTime % duration;
|
|
17813
|
-
} else if (this.options.endBehavior === END_BEHAVIOR_FREEZE) {
|
|
17814
|
-
localTime = Math.min(duration, localTime);
|
|
17815
|
-
}
|
|
17816
|
-
}
|
|
17817
|
-
return localTime;
|
|
17818
|
-
}
|
|
17819
|
-
createTrack(classConstructor, name) {
|
|
17820
|
-
const newTrack = new classConstructor(this.engine);
|
|
17821
|
-
newTrack.binding = this.binding;
|
|
17822
|
-
newTrack.id = (this.trackSeed++).toString();
|
|
17823
|
-
newTrack.name = name ? name : 'Track' + newTrack.id;
|
|
17824
|
-
this.children.push(newTrack);
|
|
17825
|
-
return newTrack;
|
|
17826
|
-
}
|
|
17827
|
-
fromData(data) {
|
|
17828
|
-
super.fromData(data);
|
|
17829
|
-
this.data = data;
|
|
17830
|
-
}
|
|
17831
|
-
constructor(...args){
|
|
17832
|
-
super(...args);
|
|
17833
|
-
this.trackSeed = 0;
|
|
17834
|
-
}
|
|
17835
|
-
}
|
|
17836
|
-
ObjectBindingTrack = __decorate([
|
|
17837
|
-
effectsClass('ObjectBindingTrack')
|
|
17838
|
-
], ObjectBindingTrack);
|
|
17839
|
-
|
|
17840
|
-
class TransformTrack extends TrackAsset {
|
|
17841
|
-
}
|
|
17842
|
-
TransformTrack = __decorate([
|
|
17843
|
-
effectsClass('TransformTrack')
|
|
17844
|
-
], TransformTrack);
|
|
17845
|
-
|
|
17846
17835
|
class SpriteColorTrack extends TrackAsset {
|
|
17847
17836
|
}
|
|
17848
17837
|
SpriteColorTrack = __decorate([
|
|
@@ -17854,17 +17843,29 @@ class TimelineAsset extends PlayableAsset {
|
|
|
17854
17843
|
this.graph = graph;
|
|
17855
17844
|
const timelinePlayable = new TimelinePlayable(graph);
|
|
17856
17845
|
timelinePlayable.setTraversalMode(PlayableTraversalMode.Passthrough);
|
|
17846
|
+
for (const track of this.tracks){
|
|
17847
|
+
if (track instanceof ObjectBindingTrack) {
|
|
17848
|
+
track.create(this);
|
|
17849
|
+
}
|
|
17850
|
+
}
|
|
17857
17851
|
timelinePlayable.compileTracks(graph, this.tracks);
|
|
17858
17852
|
return timelinePlayable;
|
|
17859
17853
|
}
|
|
17860
|
-
|
|
17861
|
-
|
|
17854
|
+
createTrack(classConstructor, parent, name) {
|
|
17855
|
+
const newTrack = new classConstructor(this.engine);
|
|
17856
|
+
newTrack.name = name ? name : classConstructor.name;
|
|
17857
|
+
parent.addChild(newTrack);
|
|
17858
|
+
return newTrack;
|
|
17862
17859
|
}
|
|
17860
|
+
fromData(data) {}
|
|
17863
17861
|
constructor(...args){
|
|
17864
17862
|
super(...args);
|
|
17865
17863
|
this.tracks = [];
|
|
17866
17864
|
}
|
|
17867
17865
|
}
|
|
17866
|
+
__decorate([
|
|
17867
|
+
serialize()
|
|
17868
|
+
], TimelineAsset.prototype, "tracks", void 0);
|
|
17868
17869
|
TimelineAsset = __decorate([
|
|
17869
17870
|
effectsClass('TimelineAsset')
|
|
17870
17871
|
], TimelineAsset);
|
|
@@ -17881,12 +17882,6 @@ class TimelinePlayable extends Playable {
|
|
|
17881
17882
|
}
|
|
17882
17883
|
compileTracks(graph, tracks) {
|
|
17883
17884
|
this.sortTracks(tracks);
|
|
17884
|
-
for (const track of tracks){
|
|
17885
|
-
if (track instanceof ObjectBindingTrack) {
|
|
17886
|
-
track.create();
|
|
17887
|
-
}
|
|
17888
|
-
this.masterTracks.push(track);
|
|
17889
|
-
}
|
|
17890
17885
|
const outputTrack = [];
|
|
17891
17886
|
for (const masterTrack of tracks){
|
|
17892
17887
|
outputTrack.push(masterTrack);
|
|
@@ -17923,7 +17918,6 @@ class TimelinePlayable extends Playable {
|
|
|
17923
17918
|
constructor(...args){
|
|
17924
17919
|
super(...args);
|
|
17925
17920
|
this.clips = [];
|
|
17926
|
-
this.masterTracks = [];
|
|
17927
17921
|
}
|
|
17928
17922
|
}
|
|
17929
17923
|
class TrackSortWrapper {
|
|
@@ -17943,9 +17937,14 @@ function isAncestor(ancestorCandidate, descendantCandidate) {
|
|
|
17943
17937
|
return false;
|
|
17944
17938
|
}
|
|
17945
17939
|
function compareTracks(a, b) {
|
|
17946
|
-
|
|
17940
|
+
const bindingA = a.track.binding;
|
|
17941
|
+
const bindingB = b.track.binding;
|
|
17942
|
+
if (!(bindingA instanceof VFXItem) || !(bindingB instanceof VFXItem)) {
|
|
17943
|
+
return a.originalIndex - b.originalIndex;
|
|
17944
|
+
}
|
|
17945
|
+
if (isAncestor(bindingA, bindingB)) {
|
|
17947
17946
|
return -1;
|
|
17948
|
-
} else if (isAncestor(
|
|
17947
|
+
} else if (isAncestor(bindingB, bindingA)) {
|
|
17949
17948
|
return 1;
|
|
17950
17949
|
} else {
|
|
17951
17950
|
return a.originalIndex - b.originalIndex; // 非父子关系的元素保持原始顺序
|
|
@@ -20655,7 +20654,7 @@ function getStandardCameraContent(model) {
|
|
|
20655
20654
|
content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
20656
20655
|
}
|
|
20657
20656
|
// 修复相机K帧缺失 asMovement 参数
|
|
20658
|
-
if (item.type === ItemType.camera) {
|
|
20657
|
+
if (item.type === ItemType.camera && item.content.positionOverLifetime && Object.keys(item.content.positionOverLifetime).length !== 0) {
|
|
20659
20658
|
item.content.positionOverLifetime.asMovement = true;
|
|
20660
20659
|
}
|
|
20661
20660
|
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
@@ -20817,8 +20816,32 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
|
|
|
20817
20816
|
for (const itemDataPath of composition.items){
|
|
20818
20817
|
const item = guidToItemMap[itemDataPath.id];
|
|
20819
20818
|
const subTrackDatas = [];
|
|
20819
|
+
const newActivationPlayableAsset = {
|
|
20820
|
+
id: generateGUID(),
|
|
20821
|
+
dataType: 'ActivationPlayableAsset'
|
|
20822
|
+
};
|
|
20823
|
+
playableAssetDatas.push(newActivationPlayableAsset);
|
|
20824
|
+
const newActivationTrackData = {
|
|
20825
|
+
id: generateGUID(),
|
|
20826
|
+
dataType: 'ActivationTrack',
|
|
20827
|
+
children: [],
|
|
20828
|
+
clips: [
|
|
20829
|
+
{
|
|
20830
|
+
start: item.delay,
|
|
20831
|
+
duration: item.duration,
|
|
20832
|
+
endBehaviour: item.endBehavior,
|
|
20833
|
+
asset: {
|
|
20834
|
+
id: newActivationPlayableAsset.id
|
|
20835
|
+
}
|
|
20836
|
+
}
|
|
20837
|
+
]
|
|
20838
|
+
};
|
|
20839
|
+
subTrackDatas.push({
|
|
20840
|
+
id: newActivationTrackData.id
|
|
20841
|
+
});
|
|
20842
|
+
trackDatas.push(newActivationTrackData);
|
|
20820
20843
|
if (item.type !== ItemType.particle) {
|
|
20821
|
-
const
|
|
20844
|
+
const newTransformPlayableAssetData = {
|
|
20822
20845
|
id: generateGUID(),
|
|
20823
20846
|
dataType: 'TransformPlayableAsset',
|
|
20824
20847
|
//@ts-expect-error
|
|
@@ -20828,15 +20851,18 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
|
|
|
20828
20851
|
//@ts-expect-error
|
|
20829
20852
|
positionOverLifetime: item.content.positionOverLifetime
|
|
20830
20853
|
};
|
|
20831
|
-
playableAssetDatas.push(
|
|
20854
|
+
playableAssetDatas.push(newTransformPlayableAssetData);
|
|
20832
20855
|
const newTrackData = {
|
|
20833
20856
|
id: generateGUID(),
|
|
20834
20857
|
dataType: 'TransformTrack',
|
|
20835
20858
|
children: [],
|
|
20836
20859
|
clips: [
|
|
20837
20860
|
{
|
|
20861
|
+
start: item.delay,
|
|
20862
|
+
duration: item.duration,
|
|
20863
|
+
endBehaviour: item.endBehavior,
|
|
20838
20864
|
asset: {
|
|
20839
|
-
id:
|
|
20865
|
+
id: newTransformPlayableAssetData.id
|
|
20840
20866
|
}
|
|
20841
20867
|
}
|
|
20842
20868
|
]
|
|
@@ -20847,21 +20873,24 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
|
|
|
20847
20873
|
trackDatas.push(newTrackData);
|
|
20848
20874
|
}
|
|
20849
20875
|
if (item.type === ItemType.sprite) {
|
|
20850
|
-
const
|
|
20876
|
+
const newSpriteColorPlayableAssetData = {
|
|
20851
20877
|
id: generateGUID(),
|
|
20852
20878
|
dataType: 'SpriteColorPlayableAsset',
|
|
20853
20879
|
colorOverLifetime: item.content.colorOverLifetime,
|
|
20854
20880
|
startColor: item.content.options.startColor
|
|
20855
20881
|
};
|
|
20856
|
-
playableAssetDatas.push(
|
|
20882
|
+
playableAssetDatas.push(newSpriteColorPlayableAssetData);
|
|
20857
20883
|
const newTrackData = {
|
|
20858
20884
|
id: generateGUID(),
|
|
20859
20885
|
dataType: 'SpriteColorTrack',
|
|
20860
20886
|
children: [],
|
|
20861
20887
|
clips: [
|
|
20862
20888
|
{
|
|
20889
|
+
start: item.delay,
|
|
20890
|
+
duration: item.duration,
|
|
20891
|
+
endBehaviour: item.endBehavior,
|
|
20863
20892
|
asset: {
|
|
20864
|
-
id:
|
|
20893
|
+
id: newSpriteColorPlayableAssetData.id
|
|
20865
20894
|
}
|
|
20866
20895
|
}
|
|
20867
20896
|
]
|
|
@@ -22071,14 +22100,17 @@ const tmpScale = new Vector3(1, 1, 1);
|
|
|
22071
22100
|
this.timelinePlayable = this.timelineAsset.createPlayable(this.graph);
|
|
22072
22101
|
this.timelinePlayable.play();
|
|
22073
22102
|
for (const track of this.timelineAsset.tracks){
|
|
22074
|
-
|
|
22075
|
-
if (
|
|
22076
|
-
|
|
22077
|
-
|
|
22078
|
-
|
|
22079
|
-
|
|
22080
|
-
|
|
22081
|
-
subCompositionComponent
|
|
22103
|
+
const binding = track.binding;
|
|
22104
|
+
if (binding instanceof VFXItem) {
|
|
22105
|
+
// 重播不销毁元素
|
|
22106
|
+
if (this.item.endBehavior !== ItemEndBehavior.destroy || this.reusable) {
|
|
22107
|
+
if (track instanceof ObjectBindingTrack) {
|
|
22108
|
+
binding.reusable = true;
|
|
22109
|
+
}
|
|
22110
|
+
const subCompositionComponent = binding.getComponent(CompositionComponent);
|
|
22111
|
+
if (subCompositionComponent) {
|
|
22112
|
+
subCompositionComponent.reusable = true;
|
|
22113
|
+
}
|
|
22082
22114
|
}
|
|
22083
22115
|
}
|
|
22084
22116
|
this.masterTracks.push(track);
|