@galacean/effects-threejs 2.0.0-alpha.14 → 2.0.0-alpha.16
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 +842 -830
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +841 -831
- package/dist/index.mjs.map +1 -1
- package/dist/three-composition.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin 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.16
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -765,6 +765,11 @@ function noop() {}
|
|
|
765
765
|
*/ function isObject(obj) {
|
|
766
766
|
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
767
767
|
}
|
|
768
|
+
function isCanvas(canvas) {
|
|
769
|
+
var _canvas_tagName;
|
|
770
|
+
// 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
|
|
771
|
+
return typeof canvas === "object" && canvas !== null && ((_canvas_tagName = canvas.tagName) == null ? void 0 : _canvas_tagName.toUpperCase()) === "CANVAS";
|
|
772
|
+
}
|
|
768
773
|
function deepClone(obj) {
|
|
769
774
|
if (isArray(obj)) {
|
|
770
775
|
return obj.map(deepClone);
|
|
@@ -792,6 +797,37 @@ function throwDestroyedError() {
|
|
|
792
797
|
function generateGUID() {
|
|
793
798
|
return v4().replace(/-/g, "");
|
|
794
799
|
}
|
|
800
|
+
function base64ToFile(base64, filename, contentType) {
|
|
801
|
+
if (filename === void 0) filename = "base64File";
|
|
802
|
+
if (contentType === void 0) contentType = "";
|
|
803
|
+
// 去掉 Base64 字符串的 Data URL 部分(如果存在)
|
|
804
|
+
var base64WithoutPrefix = base64.split(",")[1] || base64;
|
|
805
|
+
// 将 base64 编码的字符串转换为二进制字符串
|
|
806
|
+
var byteCharacters = atob(base64WithoutPrefix);
|
|
807
|
+
// 创建一个 8 位无符号整数值的数组,即“字节数组”
|
|
808
|
+
var byteArrays = [];
|
|
809
|
+
// 切割二进制字符串为多个片段,并将每个片段转换成一个字节数组
|
|
810
|
+
for(var offset = 0; offset < byteCharacters.length; offset += 512){
|
|
811
|
+
var slice = byteCharacters.slice(offset, offset + 512);
|
|
812
|
+
var byteNumbers = new Array(slice.length);
|
|
813
|
+
for(var i = 0; i < slice.length; i++){
|
|
814
|
+
byteNumbers[i] = slice.charCodeAt(i);
|
|
815
|
+
}
|
|
816
|
+
var byteArray = new Uint8Array(byteNumbers);
|
|
817
|
+
byteArrays.push(byteArray);
|
|
818
|
+
}
|
|
819
|
+
// 使用字节数组创建 Blob 对象
|
|
820
|
+
var blob = new Blob(byteArrays, {
|
|
821
|
+
type: contentType
|
|
822
|
+
});
|
|
823
|
+
// 创建 File 对象
|
|
824
|
+
var file = new File([
|
|
825
|
+
blob
|
|
826
|
+
], filename, {
|
|
827
|
+
type: contentType
|
|
828
|
+
});
|
|
829
|
+
return file;
|
|
830
|
+
}
|
|
795
831
|
|
|
796
832
|
function _defineProperties(target, props) {
|
|
797
833
|
for(var i = 0; i < props.length; i++){
|
|
@@ -13677,13 +13713,16 @@ var SpriteColorPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
13677
13713
|
}
|
|
13678
13714
|
var _proto = SpriteColorPlayable.prototype;
|
|
13679
13715
|
_proto.processFrame = function processFrame(context) {
|
|
13680
|
-
var
|
|
13716
|
+
var boundObject = context.output.getUserData();
|
|
13717
|
+
if (!_instanceof1(boundObject, exports.VFXItem)) {
|
|
13718
|
+
return;
|
|
13719
|
+
}
|
|
13681
13720
|
if (!this.spriteMaterial) {
|
|
13682
|
-
this.spriteMaterial =
|
|
13721
|
+
this.spriteMaterial = boundObject.getComponent(exports.SpriteComponent).material;
|
|
13683
13722
|
}
|
|
13684
13723
|
var colorInc = vecFill(tempColor, 1);
|
|
13685
13724
|
var colorChanged;
|
|
13686
|
-
var life = this.time /
|
|
13725
|
+
var life = this.time / boundObject.duration;
|
|
13687
13726
|
var opacityOverLifetime = this.opacityOverLifetime;
|
|
13688
13727
|
var colorOverLifetime = this.colorOverLifetime;
|
|
13689
13728
|
if (colorOverLifetime) {
|
|
@@ -13813,7 +13852,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
13813
13852
|
renderer.drawGeometry(geo, material);
|
|
13814
13853
|
};
|
|
13815
13854
|
_proto.start = function start() {
|
|
13816
|
-
this.priority = this.item.listIndex;
|
|
13817
13855
|
this.item.getHitTestParams = this.getHitTestParams;
|
|
13818
13856
|
};
|
|
13819
13857
|
_proto.update = function update(dt) {
|
|
@@ -16217,7 +16255,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, env, gpuCapability)
|
|
|
16217
16255
|
}
|
|
16218
16256
|
var _proto = ParticleSystemRenderer.prototype;
|
|
16219
16257
|
_proto.start = function start() {
|
|
16220
|
-
this._priority = this.item.
|
|
16258
|
+
this._priority = this.item.renderOrder;
|
|
16221
16259
|
this.particleMesh.gravityModifier.scaleXCoord(this.item.duration);
|
|
16222
16260
|
for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
|
|
16223
16261
|
var mesh = _step.value;
|
|
@@ -17267,13 +17305,13 @@ function randomArrItem(arr, keepArr) {
|
|
|
17267
17305
|
}
|
|
17268
17306
|
var _proto = ParticleBehaviourPlayable.prototype;
|
|
17269
17307
|
_proto.start = function start(context) {
|
|
17270
|
-
var
|
|
17271
|
-
if (this.particleSystem) {
|
|
17308
|
+
var boundObject = context.output.getUserData();
|
|
17309
|
+
if (this.particleSystem || !_instanceof1(boundObject, exports.VFXItem)) {
|
|
17272
17310
|
return;
|
|
17273
17311
|
}
|
|
17274
|
-
this.particleSystem =
|
|
17312
|
+
this.particleSystem = boundObject.getComponent(exports.ParticleSystem);
|
|
17275
17313
|
if (this.particleSystem) {
|
|
17276
|
-
this.particleSystem.name =
|
|
17314
|
+
this.particleSystem.name = boundObject.name;
|
|
17277
17315
|
this.particleSystem.start();
|
|
17278
17316
|
this.particleSystem.initEmitterTransform();
|
|
17279
17317
|
}
|
|
@@ -18431,10 +18469,13 @@ var tempPos = new Vector3();
|
|
|
18431
18469
|
};
|
|
18432
18470
|
_proto.processFrame = function processFrame(context) {
|
|
18433
18471
|
if (!this.binding) {
|
|
18434
|
-
|
|
18435
|
-
|
|
18472
|
+
var boundObject = context.output.getUserData();
|
|
18473
|
+
if (_instanceof1(boundObject, exports.VFXItem)) {
|
|
18474
|
+
this.binding = boundObject;
|
|
18475
|
+
this.start();
|
|
18476
|
+
}
|
|
18436
18477
|
}
|
|
18437
|
-
if (this.binding.composition) {
|
|
18478
|
+
if (this.binding && this.binding.composition) {
|
|
18438
18479
|
this.sampleAnimation();
|
|
18439
18480
|
}
|
|
18440
18481
|
};
|
|
@@ -18643,9 +18684,12 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
18643
18684
|
}
|
|
18644
18685
|
var _proto = AnimationClipPlayable.prototype;
|
|
18645
18686
|
_proto.processFrame = function processFrame(context) {
|
|
18646
|
-
var
|
|
18647
|
-
if (
|
|
18648
|
-
|
|
18687
|
+
var boundObject = context.output.getUserData();
|
|
18688
|
+
if (!_instanceof1(boundObject, exports.VFXItem)) {
|
|
18689
|
+
return;
|
|
18690
|
+
}
|
|
18691
|
+
if (boundObject.composition) {
|
|
18692
|
+
this.clip.sampleAnimation(boundObject, this.time);
|
|
18649
18693
|
}
|
|
18650
18694
|
};
|
|
18651
18695
|
return AnimationClipPlayable;
|
|
@@ -18663,17 +18707,15 @@ exports.TrackAsset = /*#__PURE__*/ function(PlayableAsset) {
|
|
|
18663
18707
|
return _this;
|
|
18664
18708
|
}
|
|
18665
18709
|
var _proto = TrackAsset.prototype;
|
|
18666
|
-
|
|
18667
|
-
|
|
18710
|
+
/**
|
|
18711
|
+
* 重写该方法以获取自定义对象绑定
|
|
18712
|
+
*/ _proto.resolveBinding = function resolveBinding(parentBinding) {
|
|
18713
|
+
return parentBinding;
|
|
18668
18714
|
};
|
|
18669
18715
|
/**
|
|
18670
|
-
*
|
|
18671
|
-
*/ _proto.
|
|
18672
|
-
|
|
18673
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
|
|
18674
|
-
var subTrack = _step.value;
|
|
18675
|
-
subTrack.initializeBindingRecursive(this.binding);
|
|
18676
|
-
}
|
|
18716
|
+
* 重写该方法以创建自定义混合器
|
|
18717
|
+
*/ _proto.createTrackMixer = function createTrackMixer(graph) {
|
|
18718
|
+
return new Playable(graph);
|
|
18677
18719
|
};
|
|
18678
18720
|
_proto.createOutput = function createOutput() {
|
|
18679
18721
|
var output = new PlayableOutput();
|
|
@@ -18704,11 +18746,6 @@ exports.TrackAsset = /*#__PURE__*/ function(PlayableAsset) {
|
|
|
18704
18746
|
}
|
|
18705
18747
|
return mixer;
|
|
18706
18748
|
};
|
|
18707
|
-
/**
|
|
18708
|
-
* 重写该方法以创建自定义混合器
|
|
18709
|
-
*/ _proto.createTrackMixer = function createTrackMixer(graph) {
|
|
18710
|
-
return new Playable(graph);
|
|
18711
|
-
};
|
|
18712
18749
|
_proto.createPlayable = function createPlayable(graph) {
|
|
18713
18750
|
return new Playable(graph);
|
|
18714
18751
|
};
|
|
@@ -18858,13 +18895,6 @@ exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
|
|
|
18858
18895
|
var _proto = ObjectBindingTrack.prototype;
|
|
18859
18896
|
_proto.create = function create(timelineAsset) {
|
|
18860
18897
|
var boundItem = this.binding;
|
|
18861
|
-
this.options = {
|
|
18862
|
-
start: boundItem.start,
|
|
18863
|
-
duration: boundItem.duration,
|
|
18864
|
-
looping: boundItem.endBehavior === ItemEndBehavior.loop,
|
|
18865
|
-
endBehavior: boundItem.endBehavior || ItemEndBehavior.destroy
|
|
18866
|
-
};
|
|
18867
|
-
this.name = boundItem.name;
|
|
18868
18898
|
// 添加粒子动画 clip
|
|
18869
18899
|
if (boundItem.getComponent(exports.ParticleSystem)) {
|
|
18870
18900
|
var particleTrack = timelineAsset.createTrack(exports.TrackAsset, this, "ParticleTrack");
|
|
@@ -18875,18 +18905,6 @@ exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
|
|
|
18875
18905
|
particleClip.endBehaviour = boundItem.endBehavior;
|
|
18876
18906
|
}
|
|
18877
18907
|
};
|
|
18878
|
-
_proto.toLocalTime = function toLocalTime(time) {
|
|
18879
|
-
var localTime = time - this.options.start;
|
|
18880
|
-
var duration = this.options.duration;
|
|
18881
|
-
if (localTime - duration > 0.001) {
|
|
18882
|
-
if (this.options.endBehavior === END_BEHAVIOR_RESTART) {
|
|
18883
|
-
localTime = localTime % duration;
|
|
18884
|
-
} else if (this.options.endBehavior === END_BEHAVIOR_FREEZE) {
|
|
18885
|
-
localTime = Math.min(duration, localTime);
|
|
18886
|
-
}
|
|
18887
|
-
}
|
|
18888
|
-
return localTime;
|
|
18889
|
-
};
|
|
18890
18908
|
_proto.fromData = function fromData(data) {
|
|
18891
18909
|
TrackAsset1.prototype.fromData.call(this, data);
|
|
18892
18910
|
this.data = data;
|
|
@@ -18915,13 +18933,11 @@ var ActivationMixerPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
18915
18933
|
}
|
|
18916
18934
|
var _proto = ActivationMixerPlayable.prototype;
|
|
18917
18935
|
_proto.processFrame = function processFrame(context) {
|
|
18918
|
-
|
|
18919
|
-
|
|
18920
|
-
}
|
|
18921
|
-
if (!this.bindingItem) {
|
|
18936
|
+
var boundObject = context.output.getUserData();
|
|
18937
|
+
if (!_instanceof1(boundObject, exports.VFXItem)) {
|
|
18922
18938
|
return;
|
|
18923
18939
|
}
|
|
18924
|
-
var
|
|
18940
|
+
var boundItem = boundObject;
|
|
18925
18941
|
var hasInput = false;
|
|
18926
18942
|
for(var i = 0; i < this.getInputCount(); i++){
|
|
18927
18943
|
if (this.getInputWeight(i) > 0) {
|
|
@@ -18930,11 +18946,11 @@ var ActivationMixerPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
18930
18946
|
}
|
|
18931
18947
|
}
|
|
18932
18948
|
if (hasInput) {
|
|
18933
|
-
|
|
18934
|
-
this.showRendererComponents(
|
|
18949
|
+
boundItem.transform.setValid(true);
|
|
18950
|
+
this.showRendererComponents(boundItem);
|
|
18935
18951
|
} else {
|
|
18936
|
-
|
|
18937
|
-
this.hideRendererComponents(
|
|
18952
|
+
boundItem.transform.setValid(false);
|
|
18953
|
+
this.hideRendererComponents(boundItem);
|
|
18938
18954
|
}
|
|
18939
18955
|
};
|
|
18940
18956
|
_proto.hideRendererComponents = function hideRendererComponents(item) {
|
|
@@ -18962,9 +18978,6 @@ exports.ActivationTrack = /*#__PURE__*/ function(TrackAsset) {
|
|
|
18962
18978
|
return TrackAsset.apply(this, arguments);
|
|
18963
18979
|
}
|
|
18964
18980
|
var _proto = ActivationTrack.prototype;
|
|
18965
|
-
_proto.initializeBinding = function initializeBinding(parentBinding) {
|
|
18966
|
-
this.binding = parentBinding;
|
|
18967
|
-
};
|
|
18968
18981
|
_proto.createTrackMixer = function createTrackMixer(graph) {
|
|
18969
18982
|
return new ActivationMixerPlayable(graph);
|
|
18970
18983
|
};
|
|
@@ -18995,7 +19008,6 @@ exports.TimelineAsset = /*#__PURE__*/ function(PlayableAsset) {
|
|
|
18995
19008
|
}
|
|
18996
19009
|
var _proto = TimelineAsset.prototype;
|
|
18997
19010
|
_proto.createPlayable = function createPlayable(graph) {
|
|
18998
|
-
this.graph = graph;
|
|
18999
19011
|
var timelinePlayable = new TimelinePlayable(graph);
|
|
19000
19012
|
timelinePlayable.setTraversalMode(PlayableTraversalMode.Passthrough);
|
|
19001
19013
|
for(var _iterator = _create_for_of_iterator_helper_loose(this.tracks), _step; !(_step = _iterator()).done;){
|
|
@@ -19113,172 +19125,446 @@ function compareTracks(a, b) {
|
|
|
19113
19125
|
}
|
|
19114
19126
|
}
|
|
19115
19127
|
|
|
19116
|
-
|
|
19117
|
-
|
|
19118
|
-
|
|
19119
|
-
|
|
19120
|
-
|
|
19121
|
-
|
|
19122
|
-
|
|
19123
|
-
|
|
19124
|
-
|
|
19125
|
-
|
|
19126
|
-
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
|
|
19130
|
-
|
|
19131
|
-
|
|
19132
|
-
// } else {
|
|
19133
|
-
// if (textWidth) {
|
|
19134
|
-
// this.maxCharCount = Math.floor((textWidth - this.lineWidth) / (tempWidth));
|
|
19135
|
-
// this.width = textWidth;
|
|
19136
|
-
// } else {
|
|
19137
|
-
// this.width = basicScale[0] * 100;
|
|
19138
|
-
// }
|
|
19139
|
-
// this.height = basicScale[1] * 100;
|
|
19140
|
-
// }
|
|
19141
|
-
this.width = textWidth;
|
|
19142
|
-
this.height = textHeight;
|
|
19143
|
-
this.letterSpace = letterSpace;
|
|
19144
|
-
this.overFlow = textOverflow;
|
|
19145
|
-
this.textBaseline = textBaseline;
|
|
19146
|
-
this.textAlign = textAlign;
|
|
19147
|
-
this.lineHeight = lineHeight;
|
|
19128
|
+
/**
|
|
19129
|
+
* @since 2.0.0
|
|
19130
|
+
* @internal
|
|
19131
|
+
*/ var CompositionComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
19132
|
+
_inherits(CompositionComponent, ItemBehaviour);
|
|
19133
|
+
function CompositionComponent() {
|
|
19134
|
+
var _this;
|
|
19135
|
+
_this = ItemBehaviour.apply(this, arguments) || this;
|
|
19136
|
+
_this.time = 0;
|
|
19137
|
+
_this.startTime = 0;
|
|
19138
|
+
_this.items = [] // 场景的所有元素
|
|
19139
|
+
;
|
|
19140
|
+
_this.reusable = false;
|
|
19141
|
+
_this.sceneBindings = [];
|
|
19142
|
+
_this.graph = new PlayableGraph();
|
|
19143
|
+
return _this;
|
|
19148
19144
|
}
|
|
19149
|
-
var _proto =
|
|
19150
|
-
_proto.
|
|
19151
|
-
var
|
|
19152
|
-
|
|
19153
|
-
|
|
19154
|
-
|
|
19155
|
-
|
|
19156
|
-
|
|
19157
|
-
|
|
19158
|
-
|
|
19159
|
-
break;
|
|
19160
|
-
case TextBaseline.bottom:
|
|
19161
|
-
offsetY = this.height - offset / 2;
|
|
19162
|
-
break;
|
|
19145
|
+
var _proto = CompositionComponent.prototype;
|
|
19146
|
+
_proto.start = function start() {
|
|
19147
|
+
var _this_item_props = this.item.props, _this_item_props_startTime = _this_item_props.startTime, startTime = _this_item_props_startTime === void 0 ? 0 : _this_item_props_startTime;
|
|
19148
|
+
this.startTime = startTime;
|
|
19149
|
+
this.resolveBindings();
|
|
19150
|
+
this.timelinePlayable = this.timelineAsset.createPlayable(this.graph);
|
|
19151
|
+
this.timelinePlayable.play();
|
|
19152
|
+
// 重播不销毁元素
|
|
19153
|
+
if (this.item.endBehavior !== ItemEndBehavior.destroy) {
|
|
19154
|
+
this.setReusable(true);
|
|
19163
19155
|
}
|
|
19164
|
-
return offsetY;
|
|
19165
19156
|
};
|
|
19166
|
-
_proto.
|
|
19167
|
-
var
|
|
19168
|
-
|
|
19169
|
-
|
|
19170
|
-
|
|
19171
|
-
|
|
19172
|
-
|
|
19173
|
-
|
|
19174
|
-
|
|
19175
|
-
|
|
19176
|
-
|
|
19177
|
-
|
|
19157
|
+
_proto.setReusable = function setReusable(value) {
|
|
19158
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.timelineAsset.tracks), _step; !(_step = _iterator()).done;){
|
|
19159
|
+
var track = _step.value;
|
|
19160
|
+
var binding = track.binding;
|
|
19161
|
+
if (_instanceof1(binding, exports.VFXItem)) {
|
|
19162
|
+
if (_instanceof1(track, exports.ObjectBindingTrack)) {
|
|
19163
|
+
binding.reusable = value;
|
|
19164
|
+
}
|
|
19165
|
+
var subCompositionComponent = binding.getComponent(CompositionComponent);
|
|
19166
|
+
if (subCompositionComponent) {
|
|
19167
|
+
subCompositionComponent.setReusable(value);
|
|
19168
|
+
}
|
|
19169
|
+
}
|
|
19178
19170
|
}
|
|
19179
|
-
return offsetX;
|
|
19180
|
-
};
|
|
19181
|
-
/**
|
|
19182
|
-
* 设置文本框的宽度和高度
|
|
19183
|
-
* @param width 文本框宽度
|
|
19184
|
-
* @param height 文本框高度
|
|
19185
|
-
*/ _proto.setSize = function setSize(width, height) {
|
|
19186
|
-
this.width = width;
|
|
19187
|
-
this.height = height;
|
|
19188
19171
|
};
|
|
19189
|
-
|
|
19190
|
-
|
|
19191
|
-
|
|
19192
|
-
var TextStyle = function TextStyle(options) {
|
|
19193
|
-
/**
|
|
19194
|
-
* 是否有下划线(暂时无效)
|
|
19195
|
-
*/ this.isUnderline = false // ttf
|
|
19196
|
-
;
|
|
19197
|
-
/**
|
|
19198
|
-
* 下划线高度(暂时无效)
|
|
19199
|
-
*/ this.underlineHeight = 1 // ttf
|
|
19200
|
-
;
|
|
19201
|
-
/**
|
|
19202
|
-
* 是否有外描边
|
|
19203
|
-
*/ this.isOutlined = false // both // ttf & char
|
|
19204
|
-
;
|
|
19205
|
-
/**
|
|
19206
|
-
* 外描边宽度
|
|
19207
|
-
*/ this.outlineWidth = 0 // both // ttf & char
|
|
19208
|
-
;
|
|
19209
|
-
/**
|
|
19210
|
-
* 是否有阴影
|
|
19211
|
-
*/ this.hasShadow = false // ttf
|
|
19212
|
-
;
|
|
19213
|
-
this.fontDesc = "" // both
|
|
19214
|
-
;
|
|
19215
|
-
/**
|
|
19216
|
-
* 字体倍数
|
|
19217
|
-
*/ this.fontScale = 2;
|
|
19218
|
-
this.fontOffset = 0;
|
|
19219
|
-
var _options_textColor = options.textColor, textColor = _options_textColor === void 0 ? [
|
|
19220
|
-
1,
|
|
19221
|
-
1,
|
|
19222
|
-
1,
|
|
19223
|
-
1
|
|
19224
|
-
] : _options_textColor, _options_fontSize = options.fontSize, fontSize = _options_fontSize === void 0 ? 40 : _options_fontSize, outline = options.outline, shadow = options.shadow, _options_fontWeight = options.fontWeight, fontWeight = _options_fontWeight === void 0 ? "normal" : _options_fontWeight, _options_fontStyle = options.fontStyle, fontStyle = _options_fontStyle === void 0 ? "normal" : _options_fontStyle, _options_fontFamily = options.fontFamily, fontFamily = _options_fontFamily === void 0 ? "sans-serif" : _options_fontFamily;
|
|
19225
|
-
this.textColor = textColor;
|
|
19226
|
-
//@ts-expect-error
|
|
19227
|
-
this.textWeight = fontWeight;
|
|
19228
|
-
//@ts-expect-error
|
|
19229
|
-
this.fontStyle = fontStyle;
|
|
19230
|
-
this.fontFamily = fontFamily;
|
|
19231
|
-
this.fontSize = fontSize; // 暂时取消字号限制 Math.min(fontSize, this.maxFontSize);
|
|
19232
|
-
if (outline) {
|
|
19233
|
-
this.isOutlined = true;
|
|
19234
|
-
var _outline_outlineColor;
|
|
19235
|
-
this.outlineColor = (_outline_outlineColor = outline.outlineColor) != null ? _outline_outlineColor : [
|
|
19236
|
-
1,
|
|
19237
|
-
1,
|
|
19238
|
-
1,
|
|
19239
|
-
1
|
|
19240
|
-
];
|
|
19241
|
-
var _outline_outlineWidth;
|
|
19242
|
-
this.outlineWidth = (_outline_outlineWidth = outline.outlineWidth) != null ? _outline_outlineWidth : 1;
|
|
19243
|
-
this.fontOffset += this.outlineWidth;
|
|
19244
|
-
}
|
|
19245
|
-
if (shadow) {
|
|
19246
|
-
this.hasShadow = true;
|
|
19247
|
-
var _shadow_shadowBlur;
|
|
19248
|
-
this.shadowBlur = (_shadow_shadowBlur = shadow.shadowBlur) != null ? _shadow_shadowBlur : 2;
|
|
19249
|
-
var _shadow_shadowColor;
|
|
19250
|
-
this.shadowColor = (_shadow_shadowColor = shadow.shadowColor) != null ? _shadow_shadowColor : [
|
|
19251
|
-
0,
|
|
19252
|
-
0,
|
|
19253
|
-
0,
|
|
19254
|
-
1
|
|
19255
|
-
];
|
|
19256
|
-
var _shadow_shadowOffsetX;
|
|
19257
|
-
this.shadowOffsetX = (_shadow_shadowOffsetX = shadow.shadowOffsetX) != null ? _shadow_shadowOffsetX : 0;
|
|
19258
|
-
var _shadow_shadowOffsetY;
|
|
19259
|
-
this.shadowOffsetY = (_shadow_shadowOffsetY = shadow.shadowOffsetY) != null ? _shadow_shadowOffsetY : 0;
|
|
19260
|
-
}
|
|
19261
|
-
if (this.fontStyle !== FontStyle.normal) {
|
|
19262
|
-
// 0.0174532925 = 3.141592653 / 180
|
|
19263
|
-
this.fontOffset += this.fontSize * Math.tan(12 * 0.0174532925);
|
|
19264
|
-
}
|
|
19265
|
-
};
|
|
19266
|
-
|
|
19267
|
-
var CanvasPool = /*#__PURE__*/ function() {
|
|
19268
|
-
function CanvasPool() {
|
|
19269
|
-
this.elements = [];
|
|
19270
|
-
}
|
|
19271
|
-
var _proto = CanvasPool.prototype;
|
|
19272
|
-
_proto.dispose = function dispose() {
|
|
19273
|
-
this.elements.forEach(function(e) {
|
|
19274
|
-
return e.remove();
|
|
19275
|
-
});
|
|
19276
|
-
// clearing the array
|
|
19277
|
-
this.elements.length = 0;
|
|
19172
|
+
_proto.getReusable = function getReusable() {
|
|
19173
|
+
return this.reusable;
|
|
19278
19174
|
};
|
|
19279
|
-
_proto.
|
|
19280
|
-
|
|
19281
|
-
|
|
19175
|
+
_proto.update = function update(dt) {
|
|
19176
|
+
var time = this.time;
|
|
19177
|
+
// 主合成 rootItem 没有绑定轨道,增加结束行为判断。
|
|
19178
|
+
if (this.item.isEnded(this.time) && !this.item.parent) {
|
|
19179
|
+
this.item.ended = true;
|
|
19180
|
+
}
|
|
19181
|
+
this.timelinePlayable.setTime(time);
|
|
19182
|
+
this.graph.evaluate(dt);
|
|
19183
|
+
};
|
|
19184
|
+
_proto.createContent = function createContent() {
|
|
19185
|
+
var sceneBindings = [];
|
|
19186
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.data.sceneBindings), _step; !(_step = _iterator()).done;){
|
|
19187
|
+
var sceneBindingData = _step.value;
|
|
19188
|
+
sceneBindings.push({
|
|
19189
|
+
key: this.engine.assetLoader.loadGUID(sceneBindingData.key.id),
|
|
19190
|
+
value: this.engine.assetLoader.loadGUID(sceneBindingData.value.id)
|
|
19191
|
+
});
|
|
19192
|
+
}
|
|
19193
|
+
this.sceneBindings = sceneBindings;
|
|
19194
|
+
var timelineAsset = this.data.timelineAsset ? this.engine.assetLoader.loadGUID(this.data.timelineAsset.id) : new exports.TimelineAsset(this.engine);
|
|
19195
|
+
this.timelineAsset = timelineAsset;
|
|
19196
|
+
var items = this.items;
|
|
19197
|
+
this.items.length = 0;
|
|
19198
|
+
if (this.item.composition) {
|
|
19199
|
+
var assetLoader = this.item.engine.assetLoader;
|
|
19200
|
+
var itemProps = this.item.props.items ? this.item.props.items : [];
|
|
19201
|
+
for(var i = 0; i < itemProps.length; i++){
|
|
19202
|
+
var item = void 0;
|
|
19203
|
+
var itemData = itemProps[i];
|
|
19204
|
+
// 设置预合成作为元素时的时长、结束行为和渲染延时
|
|
19205
|
+
if (exports.Item.isComposition(itemData)) {
|
|
19206
|
+
var refId = itemData.content.options.refId;
|
|
19207
|
+
var props = this.item.composition.refCompositionProps.get(refId);
|
|
19208
|
+
if (!props) {
|
|
19209
|
+
throw new Error("引用的Id: " + refId + " 的预合成不存在");
|
|
19210
|
+
}
|
|
19211
|
+
// endBehaviour 类型需优化
|
|
19212
|
+
props.content = itemData.content;
|
|
19213
|
+
item = assetLoader.loadGUID(itemData.id);
|
|
19214
|
+
item.composition = this.item.composition;
|
|
19215
|
+
var compositionComponent = item.addComponent(CompositionComponent);
|
|
19216
|
+
compositionComponent.data = props;
|
|
19217
|
+
compositionComponent.refId = refId;
|
|
19218
|
+
item.transform.parentTransform = this.transform;
|
|
19219
|
+
this.item.composition.refContent.push(item);
|
|
19220
|
+
if (item.endBehavior === ItemEndBehavior.loop) {
|
|
19221
|
+
this.item.composition.autoRefTex = false;
|
|
19222
|
+
}
|
|
19223
|
+
compositionComponent.createContent();
|
|
19224
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(compositionComponent.items), _step1; !(_step1 = _iterator1()).done;){
|
|
19225
|
+
var vfxItem = _step1.value;
|
|
19226
|
+
vfxItem.setInstanceId(generateGUID());
|
|
19227
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(vfxItem.components), _step2; !(_step2 = _iterator2()).done;){
|
|
19228
|
+
var component = _step2.value;
|
|
19229
|
+
component.setInstanceId(generateGUID());
|
|
19230
|
+
}
|
|
19231
|
+
}
|
|
19232
|
+
} else {
|
|
19233
|
+
item = assetLoader.loadGUID(itemData.id);
|
|
19234
|
+
item.composition = this.item.composition;
|
|
19235
|
+
}
|
|
19236
|
+
item.parent = this.item;
|
|
19237
|
+
// 相机不跟随合成移动
|
|
19238
|
+
item.transform.parentTransform = itemData.type === ItemType.camera ? new Transform() : this.transform;
|
|
19239
|
+
if (exports.VFXItem.isExtraCamera(item)) {
|
|
19240
|
+
this.item.composition.extraCamera = item;
|
|
19241
|
+
}
|
|
19242
|
+
items.push(item);
|
|
19243
|
+
}
|
|
19244
|
+
}
|
|
19245
|
+
};
|
|
19246
|
+
_proto.onDestroy = function onDestroy() {
|
|
19247
|
+
if (this.item.composition) {
|
|
19248
|
+
if (this.items) {
|
|
19249
|
+
this.items.forEach(function(item) {
|
|
19250
|
+
return item.dispose();
|
|
19251
|
+
});
|
|
19252
|
+
this.items.length = 0;
|
|
19253
|
+
}
|
|
19254
|
+
}
|
|
19255
|
+
};
|
|
19256
|
+
_proto.hitTest = function hitTest(ray, x, y, regions, force, options) {
|
|
19257
|
+
var _this, _loop = function(i) {
|
|
19258
|
+
var item = _this.items[i];
|
|
19259
|
+
if (item.getVisible() && !item.ended && !exports.VFXItem.isComposition(item) && !skip(item)) {
|
|
19260
|
+
var hitParams = item.getHitTestParams(force);
|
|
19261
|
+
if (hitParams) {
|
|
19262
|
+
var success = false;
|
|
19263
|
+
var intersectPoint = new Vector3();
|
|
19264
|
+
if (hitParams.type === exports.HitTestType.triangle) {
|
|
19265
|
+
var triangles = hitParams.triangles, backfaceCulling = hitParams.backfaceCulling;
|
|
19266
|
+
for(var j = 0; j < triangles.length; j++){
|
|
19267
|
+
var triangle = triangles[j];
|
|
19268
|
+
if (ray.intersectTriangle(triangle, intersectPoint, backfaceCulling)) {
|
|
19269
|
+
success = true;
|
|
19270
|
+
hitPositions.push(intersectPoint);
|
|
19271
|
+
break;
|
|
19272
|
+
}
|
|
19273
|
+
}
|
|
19274
|
+
} else if (hitParams.type === exports.HitTestType.box) {
|
|
19275
|
+
var center = hitParams.center, size = hitParams.size;
|
|
19276
|
+
var boxMin = center.clone().addScaledVector(size, 0.5);
|
|
19277
|
+
var boxMax = center.clone().addScaledVector(size, -0.5);
|
|
19278
|
+
if (ray.intersectBox({
|
|
19279
|
+
min: boxMin,
|
|
19280
|
+
max: boxMax
|
|
19281
|
+
}, intersectPoint)) {
|
|
19282
|
+
success = true;
|
|
19283
|
+
hitPositions.push(intersectPoint);
|
|
19284
|
+
}
|
|
19285
|
+
} else if (hitParams.type === exports.HitTestType.sphere) {
|
|
19286
|
+
var center1 = hitParams.center, radius = hitParams.radius;
|
|
19287
|
+
if (ray.intersectSphere({
|
|
19288
|
+
center: center1,
|
|
19289
|
+
radius: radius
|
|
19290
|
+
}, intersectPoint)) {
|
|
19291
|
+
success = true;
|
|
19292
|
+
hitPositions.push(intersectPoint);
|
|
19293
|
+
}
|
|
19294
|
+
} else if (hitParams.type === exports.HitTestType.custom) {
|
|
19295
|
+
var tempPosition = hitParams.collect(ray, new Vector2(x, y));
|
|
19296
|
+
if (tempPosition && tempPosition.length > 0) {
|
|
19297
|
+
tempPosition.forEach(function(pos) {
|
|
19298
|
+
hitPositions.push(pos);
|
|
19299
|
+
});
|
|
19300
|
+
success = true;
|
|
19301
|
+
}
|
|
19302
|
+
}
|
|
19303
|
+
if (success) {
|
|
19304
|
+
var region = {
|
|
19305
|
+
compContent: _this.item,
|
|
19306
|
+
id: item.id,
|
|
19307
|
+
name: item.name,
|
|
19308
|
+
position: hitPositions[hitPositions.length - 1],
|
|
19309
|
+
parentId: item.parentId,
|
|
19310
|
+
hitPositions: hitPositions,
|
|
19311
|
+
behavior: hitParams.behavior
|
|
19312
|
+
};
|
|
19313
|
+
regions.push(region);
|
|
19314
|
+
if (stop(region)) {
|
|
19315
|
+
return {
|
|
19316
|
+
v: regions
|
|
19317
|
+
};
|
|
19318
|
+
}
|
|
19319
|
+
}
|
|
19320
|
+
}
|
|
19321
|
+
}
|
|
19322
|
+
};
|
|
19323
|
+
var hitPositions = [];
|
|
19324
|
+
var stop = (options == null ? void 0 : options.stop) || noop;
|
|
19325
|
+
var skip = (options == null ? void 0 : options.skip) || noop;
|
|
19326
|
+
var maxCount = (options == null ? void 0 : options.maxCount) || this.items.length;
|
|
19327
|
+
for(var i = 0; i < this.items.length && regions.length < maxCount; i++){
|
|
19328
|
+
var _ret = (_this = this, _loop(i));
|
|
19329
|
+
if (_type_of(_ret) === "object") return _ret.v;
|
|
19330
|
+
}
|
|
19331
|
+
return regions;
|
|
19332
|
+
};
|
|
19333
|
+
_proto.fromData = function fromData(data) {};
|
|
19334
|
+
_proto.resolveBindings = function resolveBindings() {
|
|
19335
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.sceneBindings), _step; !(_step = _iterator()).done;){
|
|
19336
|
+
var sceneBinding = _step.value;
|
|
19337
|
+
sceneBinding.key.binding = sceneBinding.value;
|
|
19338
|
+
}
|
|
19339
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(this.timelineAsset.tracks), _step1; !(_step1 = _iterator1()).done;){
|
|
19340
|
+
var masterTrack = _step1.value;
|
|
19341
|
+
this.resolveTrackBindingsWithRoot(masterTrack);
|
|
19342
|
+
}
|
|
19343
|
+
};
|
|
19344
|
+
_proto.resolveTrackBindingsWithRoot = function resolveTrackBindingsWithRoot(track) {
|
|
19345
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(track.getChildTracks()), _step; !(_step = _iterator()).done;){
|
|
19346
|
+
var subTrack = _step.value;
|
|
19347
|
+
subTrack.binding = subTrack.resolveBinding(track.binding);
|
|
19348
|
+
this.resolveTrackBindingsWithRoot(subTrack);
|
|
19349
|
+
}
|
|
19350
|
+
};
|
|
19351
|
+
return CompositionComponent;
|
|
19352
|
+
}(ItemBehaviour);
|
|
19353
|
+
|
|
19354
|
+
exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
|
|
19355
|
+
_inherits(SubCompositionTrack, TrackAsset);
|
|
19356
|
+
function SubCompositionTrack() {
|
|
19357
|
+
return TrackAsset.apply(this, arguments);
|
|
19358
|
+
}
|
|
19359
|
+
var _proto = SubCompositionTrack.prototype;
|
|
19360
|
+
_proto.resolveBinding = function resolveBinding(parentBinding) {
|
|
19361
|
+
if (!_instanceof1(parentBinding, exports.VFXItem)) {
|
|
19362
|
+
throw new Error("SubCompositionTrack needs to be set under the VFXItem track");
|
|
19363
|
+
}
|
|
19364
|
+
return parentBinding.getComponent(CompositionComponent);
|
|
19365
|
+
};
|
|
19366
|
+
return SubCompositionTrack;
|
|
19367
|
+
}(exports.TrackAsset);
|
|
19368
|
+
exports.SubCompositionTrack = __decorate([
|
|
19369
|
+
effectsClass("SubCompositionTrack")
|
|
19370
|
+
], exports.SubCompositionTrack);
|
|
19371
|
+
|
|
19372
|
+
var SubCompositionClipPlayable = /*#__PURE__*/ function(Playable) {
|
|
19373
|
+
_inherits(SubCompositionClipPlayable, Playable);
|
|
19374
|
+
function SubCompositionClipPlayable() {
|
|
19375
|
+
return Playable.apply(this, arguments);
|
|
19376
|
+
}
|
|
19377
|
+
var _proto = SubCompositionClipPlayable.prototype;
|
|
19378
|
+
_proto.processFrame = function processFrame(context) {
|
|
19379
|
+
var boundObject = context.output.getUserData();
|
|
19380
|
+
if (_instanceof1(boundObject, CompositionComponent)) {
|
|
19381
|
+
boundObject.time = this.getTime();
|
|
19382
|
+
}
|
|
19383
|
+
};
|
|
19384
|
+
return SubCompositionClipPlayable;
|
|
19385
|
+
}(Playable);
|
|
19386
|
+
|
|
19387
|
+
exports.SubCompositionPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
|
|
19388
|
+
_inherits(SubCompositionPlayableAsset, PlayableAsset);
|
|
19389
|
+
function SubCompositionPlayableAsset() {
|
|
19390
|
+
return PlayableAsset.apply(this, arguments);
|
|
19391
|
+
}
|
|
19392
|
+
var _proto = SubCompositionPlayableAsset.prototype;
|
|
19393
|
+
_proto.createPlayable = function createPlayable(graph) {
|
|
19394
|
+
return new SubCompositionClipPlayable(graph);
|
|
19395
|
+
};
|
|
19396
|
+
return SubCompositionPlayableAsset;
|
|
19397
|
+
}(PlayableAsset);
|
|
19398
|
+
exports.SubCompositionPlayableAsset = __decorate([
|
|
19399
|
+
effectsClass("SubCompositionPlayableAsset")
|
|
19400
|
+
], exports.SubCompositionPlayableAsset);
|
|
19401
|
+
|
|
19402
|
+
function _possible_constructor_return(self, call) {
|
|
19403
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
|
|
19404
|
+
return _assert_this_initialized(self);
|
|
19405
|
+
}
|
|
19406
|
+
|
|
19407
|
+
var TextLayout = /*#__PURE__*/ function() {
|
|
19408
|
+
function TextLayout(options) {
|
|
19409
|
+
this.width = 0;
|
|
19410
|
+
this.height = 0;
|
|
19411
|
+
var _options_textHeight = options.textHeight, textHeight = _options_textHeight === void 0 ? 100 : _options_textHeight, _options_textWidth = options.textWidth, textWidth = _options_textWidth === void 0 ? 100 : _options_textWidth, _options_textOverflow = options.textOverflow, textOverflow = _options_textOverflow === void 0 ? TextOverflow.display : _options_textOverflow, _options_textBaseline = options.textBaseline, textBaseline = _options_textBaseline === void 0 ? TextBaseline.top : _options_textBaseline, _options_textAlign = options.textAlign, textAlign = _options_textAlign === void 0 ? TextAlignment.left : _options_textAlign, text = options.text, _options_letterSpace = options.letterSpace, letterSpace = _options_letterSpace === void 0 ? 0 : _options_letterSpace, _options_autoWidth = options.autoWidth, autoWidth = _options_autoWidth === void 0 ? false : _options_autoWidth, fontSize = options.fontSize, _options_lineHeight = options.lineHeight, lineHeight = _options_lineHeight === void 0 ? fontSize : _options_lineHeight;
|
|
19412
|
+
var tempWidth = fontSize + letterSpace;
|
|
19413
|
+
this.autoWidth = autoWidth;
|
|
19414
|
+
this.maxTextWidth = text.length * tempWidth;
|
|
19415
|
+
// if (autoWidth) {
|
|
19416
|
+
// this.width = this.maxTextWidth + this.lineWidth;
|
|
19417
|
+
// this.height = fontSize + this.lineHeight;
|
|
19418
|
+
// } else {
|
|
19419
|
+
// if (textWidth) {
|
|
19420
|
+
// this.maxCharCount = Math.floor((textWidth - this.lineWidth) / (tempWidth));
|
|
19421
|
+
// this.width = textWidth;
|
|
19422
|
+
// } else {
|
|
19423
|
+
// this.width = basicScale[0] * 100;
|
|
19424
|
+
// }
|
|
19425
|
+
// this.height = basicScale[1] * 100;
|
|
19426
|
+
// }
|
|
19427
|
+
this.width = textWidth;
|
|
19428
|
+
this.height = textHeight;
|
|
19429
|
+
this.letterSpace = letterSpace;
|
|
19430
|
+
this.overFlow = textOverflow;
|
|
19431
|
+
this.textBaseline = textBaseline;
|
|
19432
|
+
this.textAlign = textAlign;
|
|
19433
|
+
this.lineHeight = lineHeight;
|
|
19434
|
+
}
|
|
19435
|
+
var _proto = TextLayout.prototype;
|
|
19436
|
+
_proto.getOffsetY = function getOffsetY(style) {
|
|
19437
|
+
var offsetY = 0;
|
|
19438
|
+
var offset = (style.fontSize + style.outlineWidth) * style.fontScale;
|
|
19439
|
+
switch(this.textBaseline){
|
|
19440
|
+
case TextBaseline.top:
|
|
19441
|
+
offsetY = offset;
|
|
19442
|
+
break;
|
|
19443
|
+
case TextBaseline.middle:
|
|
19444
|
+
offsetY = (this.height + offset) / 2; // fonSize;
|
|
19445
|
+
break;
|
|
19446
|
+
case TextBaseline.bottom:
|
|
19447
|
+
offsetY = this.height - offset / 2;
|
|
19448
|
+
break;
|
|
19449
|
+
}
|
|
19450
|
+
return offsetY;
|
|
19451
|
+
};
|
|
19452
|
+
_proto.getOffsetX = function getOffsetX(style, maxWidth) {
|
|
19453
|
+
var offsetX = 0;
|
|
19454
|
+
switch(this.textAlign){
|
|
19455
|
+
case TextAlignment.left:
|
|
19456
|
+
offsetX = style.outlineWidth * style.fontScale;
|
|
19457
|
+
break;
|
|
19458
|
+
case TextAlignment.middle:
|
|
19459
|
+
offsetX = (this.width * style.fontScale - maxWidth) / 2;
|
|
19460
|
+
break;
|
|
19461
|
+
case TextAlignment.right:
|
|
19462
|
+
offsetX = this.width * style.fontScale - maxWidth;
|
|
19463
|
+
break;
|
|
19464
|
+
}
|
|
19465
|
+
return offsetX;
|
|
19466
|
+
};
|
|
19467
|
+
/**
|
|
19468
|
+
* 设置文本框的宽度和高度
|
|
19469
|
+
* @param width 文本框宽度
|
|
19470
|
+
* @param height 文本框高度
|
|
19471
|
+
*/ _proto.setSize = function setSize(width, height) {
|
|
19472
|
+
this.width = width;
|
|
19473
|
+
this.height = height;
|
|
19474
|
+
};
|
|
19475
|
+
return TextLayout;
|
|
19476
|
+
}();
|
|
19477
|
+
|
|
19478
|
+
var TextStyle = function TextStyle(options) {
|
|
19479
|
+
/**
|
|
19480
|
+
* 是否有下划线(暂时无效)
|
|
19481
|
+
*/ this.isUnderline = false // ttf
|
|
19482
|
+
;
|
|
19483
|
+
/**
|
|
19484
|
+
* 下划线高度(暂时无效)
|
|
19485
|
+
*/ this.underlineHeight = 1 // ttf
|
|
19486
|
+
;
|
|
19487
|
+
/**
|
|
19488
|
+
* 是否有外描边
|
|
19489
|
+
*/ this.isOutlined = false // both // ttf & char
|
|
19490
|
+
;
|
|
19491
|
+
/**
|
|
19492
|
+
* 外描边宽度
|
|
19493
|
+
*/ this.outlineWidth = 0 // both // ttf & char
|
|
19494
|
+
;
|
|
19495
|
+
/**
|
|
19496
|
+
* 是否有阴影
|
|
19497
|
+
*/ this.hasShadow = false // ttf
|
|
19498
|
+
;
|
|
19499
|
+
this.fontDesc = "" // both
|
|
19500
|
+
;
|
|
19501
|
+
/**
|
|
19502
|
+
* 字体倍数
|
|
19503
|
+
*/ this.fontScale = 2;
|
|
19504
|
+
this.fontOffset = 0;
|
|
19505
|
+
var _options_textColor = options.textColor, textColor = _options_textColor === void 0 ? [
|
|
19506
|
+
1,
|
|
19507
|
+
1,
|
|
19508
|
+
1,
|
|
19509
|
+
1
|
|
19510
|
+
] : _options_textColor, _options_fontSize = options.fontSize, fontSize = _options_fontSize === void 0 ? 40 : _options_fontSize, outline = options.outline, shadow = options.shadow, _options_fontWeight = options.fontWeight, fontWeight = _options_fontWeight === void 0 ? "normal" : _options_fontWeight, _options_fontStyle = options.fontStyle, fontStyle = _options_fontStyle === void 0 ? "normal" : _options_fontStyle, _options_fontFamily = options.fontFamily, fontFamily = _options_fontFamily === void 0 ? "sans-serif" : _options_fontFamily;
|
|
19511
|
+
this.textColor = textColor;
|
|
19512
|
+
//@ts-expect-error
|
|
19513
|
+
this.textWeight = fontWeight;
|
|
19514
|
+
//@ts-expect-error
|
|
19515
|
+
this.fontStyle = fontStyle;
|
|
19516
|
+
this.fontFamily = fontFamily;
|
|
19517
|
+
this.fontSize = fontSize; // 暂时取消字号限制 Math.min(fontSize, this.maxFontSize);
|
|
19518
|
+
if (outline) {
|
|
19519
|
+
this.isOutlined = true;
|
|
19520
|
+
var _outline_outlineColor;
|
|
19521
|
+
this.outlineColor = (_outline_outlineColor = outline.outlineColor) != null ? _outline_outlineColor : [
|
|
19522
|
+
1,
|
|
19523
|
+
1,
|
|
19524
|
+
1,
|
|
19525
|
+
1
|
|
19526
|
+
];
|
|
19527
|
+
var _outline_outlineWidth;
|
|
19528
|
+
this.outlineWidth = (_outline_outlineWidth = outline.outlineWidth) != null ? _outline_outlineWidth : 1;
|
|
19529
|
+
this.fontOffset += this.outlineWidth;
|
|
19530
|
+
}
|
|
19531
|
+
if (shadow) {
|
|
19532
|
+
this.hasShadow = true;
|
|
19533
|
+
var _shadow_shadowBlur;
|
|
19534
|
+
this.shadowBlur = (_shadow_shadowBlur = shadow.shadowBlur) != null ? _shadow_shadowBlur : 2;
|
|
19535
|
+
var _shadow_shadowColor;
|
|
19536
|
+
this.shadowColor = (_shadow_shadowColor = shadow.shadowColor) != null ? _shadow_shadowColor : [
|
|
19537
|
+
0,
|
|
19538
|
+
0,
|
|
19539
|
+
0,
|
|
19540
|
+
1
|
|
19541
|
+
];
|
|
19542
|
+
var _shadow_shadowOffsetX;
|
|
19543
|
+
this.shadowOffsetX = (_shadow_shadowOffsetX = shadow.shadowOffsetX) != null ? _shadow_shadowOffsetX : 0;
|
|
19544
|
+
var _shadow_shadowOffsetY;
|
|
19545
|
+
this.shadowOffsetY = (_shadow_shadowOffsetY = shadow.shadowOffsetY) != null ? _shadow_shadowOffsetY : 0;
|
|
19546
|
+
}
|
|
19547
|
+
if (this.fontStyle !== FontStyle.normal) {
|
|
19548
|
+
// 0.0174532925 = 3.141592653 / 180
|
|
19549
|
+
this.fontOffset += this.fontSize * Math.tan(12 * 0.0174532925);
|
|
19550
|
+
}
|
|
19551
|
+
};
|
|
19552
|
+
|
|
19553
|
+
var CanvasPool = /*#__PURE__*/ function() {
|
|
19554
|
+
function CanvasPool() {
|
|
19555
|
+
this.elements = [];
|
|
19556
|
+
}
|
|
19557
|
+
var _proto = CanvasPool.prototype;
|
|
19558
|
+
_proto.dispose = function dispose() {
|
|
19559
|
+
this.elements.forEach(function(e) {
|
|
19560
|
+
return e.remove();
|
|
19561
|
+
});
|
|
19562
|
+
// clearing the array
|
|
19563
|
+
this.elements.length = 0;
|
|
19564
|
+
};
|
|
19565
|
+
_proto.getCanvas = function getCanvas() {
|
|
19566
|
+
if (this.elements.length !== 0) {
|
|
19567
|
+
return this.elements.shift();
|
|
19282
19568
|
}
|
|
19283
19569
|
if (getConfig(TEMPLATE_USE_OFFSCREEN_CANVAS)) {
|
|
19284
19570
|
// @ts-expect-error
|
|
@@ -20120,7 +20406,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
20120
20406
|
this.parentId = parentId;
|
|
20121
20407
|
this.duration = duration;
|
|
20122
20408
|
this.endBehavior = endBehavior;
|
|
20123
|
-
this.
|
|
20409
|
+
this.renderOrder = listIndex;
|
|
20124
20410
|
//@ts-expect-error
|
|
20125
20411
|
this.oldId = data.oldId;
|
|
20126
20412
|
if (!data.content) {
|
|
@@ -20252,6 +20538,23 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
20252
20538
|
var _this_composition_reusable;
|
|
20253
20539
|
return (_this_composition_reusable = (_this_composition = this.composition) == null ? void 0 : _this_composition.reusable) != null ? _this_composition_reusable : false;
|
|
20254
20540
|
}
|
|
20541
|
+
},
|
|
20542
|
+
{
|
|
20543
|
+
key: "renderOrder",
|
|
20544
|
+
get: /**
|
|
20545
|
+
* 元素在合成中的索引
|
|
20546
|
+
*/ function get() {
|
|
20547
|
+
return this.listIndex;
|
|
20548
|
+
},
|
|
20549
|
+
set: function set(value) {
|
|
20550
|
+
if (this.listIndex !== value) {
|
|
20551
|
+
this.listIndex = value;
|
|
20552
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.rendererComponents), _step; !(_step = _iterator()).done;){
|
|
20553
|
+
var rendererComponent = _step.value;
|
|
20554
|
+
rendererComponent.priority = value;
|
|
20555
|
+
}
|
|
20556
|
+
}
|
|
20557
|
+
}
|
|
20255
20558
|
}
|
|
20256
20559
|
]);
|
|
20257
20560
|
return VFXItem;
|
|
@@ -20692,14 +20995,16 @@ var SerializationHelper = /*#__PURE__*/ function() {
|
|
|
20692
20995
|
SerializationHelper.checkGLTFNode = function checkGLTFNode(value) {
|
|
20693
20996
|
return _instanceof1(value, Object) && value.nodeIndex !== undefined && value.isJoint !== undefined;
|
|
20694
20997
|
};
|
|
20998
|
+
SerializationHelper.checkImageSource = function checkImageSource(value) {
|
|
20999
|
+
return isCanvas(value) || _instanceof1(value, HTMLImageElement);
|
|
21000
|
+
};
|
|
20695
21001
|
SerializationHelper.deserializeProperty = function deserializeProperty(property, engine, level, type) {
|
|
20696
21002
|
if (level > 14) {
|
|
20697
21003
|
console.error("序列化数据的内嵌对象层数大于上限");
|
|
20698
21004
|
return;
|
|
20699
21005
|
}
|
|
20700
|
-
|
|
20701
|
-
|
|
20702
|
-
} else if (_instanceof1(property, Array)) {
|
|
21006
|
+
// 加载并链接 DataPath 字段表示的 EffectsObject 引用。Class 对象 copy [key, value] 会丢失对象信息,因此只递归数组对象和普通 js Object 结构对象。
|
|
21007
|
+
if (_instanceof1(property, Array)) {
|
|
20703
21008
|
var res = [];
|
|
20704
21009
|
for(var _iterator = _create_for_of_iterator_helper_loose(property), _step; !(_step = _iterator()).done;){
|
|
20705
21010
|
var value = _step.value;
|
|
@@ -20709,9 +21014,7 @@ var SerializationHelper = /*#__PURE__*/ function() {
|
|
|
20709
21014
|
// TODO json 数据避免传 typedArray
|
|
20710
21015
|
} else if (SerializationHelper.checkDataPath(property)) {
|
|
20711
21016
|
return engine.assetLoader.loadGUID(property.id);
|
|
20712
|
-
} else if (_instanceof1(property,
|
|
20713
|
-
return property;
|
|
20714
|
-
} else if (_instanceof1(property, Object)) {
|
|
21017
|
+
} else if (_instanceof1(property, Object) && property.constructor === Object) {
|
|
20715
21018
|
var res1;
|
|
20716
21019
|
if (type) {
|
|
20717
21020
|
var classConstructor = effectsClassStore[type];
|
|
@@ -20725,6 +21028,8 @@ var SerializationHelper = /*#__PURE__*/ function() {
|
|
|
20725
21028
|
res1[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
|
|
20726
21029
|
}
|
|
20727
21030
|
return res1;
|
|
21031
|
+
} else {
|
|
21032
|
+
return property;
|
|
20728
21033
|
}
|
|
20729
21034
|
};
|
|
20730
21035
|
SerializationHelper.deserializePropertyAsync = function deserializePropertyAsync(property, engine, level, type) {
|
|
@@ -20739,26 +21044,17 @@ var SerializationHelper = /*#__PURE__*/ function() {
|
|
|
20739
21044
|
2
|
|
20740
21045
|
];
|
|
20741
21046
|
}
|
|
20742
|
-
if (!(typeof property === "number" || typeof property === "string" || typeof property === "boolean")) return [
|
|
20743
|
-
3,
|
|
20744
|
-
1
|
|
20745
|
-
];
|
|
20746
|
-
return [
|
|
20747
|
-
2,
|
|
20748
|
-
property
|
|
20749
|
-
];
|
|
20750
|
-
case 1:
|
|
20751
21047
|
if (!_instanceof1(property, Array)) return [
|
|
20752
21048
|
3,
|
|
20753
|
-
|
|
21049
|
+
5
|
|
20754
21050
|
];
|
|
20755
21051
|
res = [];
|
|
20756
21052
|
_iterator = _create_for_of_iterator_helper_loose(property);
|
|
20757
|
-
_state.label =
|
|
20758
|
-
case
|
|
21053
|
+
_state.label = 1;
|
|
21054
|
+
case 1:
|
|
20759
21055
|
if (!!(_step = _iterator()).done) return [
|
|
20760
21056
|
3,
|
|
20761
|
-
|
|
21057
|
+
4
|
|
20762
21058
|
];
|
|
20763
21059
|
value = _step.value;
|
|
20764
21060
|
_ = res.push;
|
|
@@ -20766,43 +21062,38 @@ var SerializationHelper = /*#__PURE__*/ function() {
|
|
|
20766
21062
|
4,
|
|
20767
21063
|
SerializationHelper.deserializePropertyAsync(value, engine, level + 1, type)
|
|
20768
21064
|
];
|
|
20769
|
-
case
|
|
21065
|
+
case 2:
|
|
20770
21066
|
_.apply(res, [
|
|
20771
21067
|
_state.sent()
|
|
20772
21068
|
]);
|
|
20773
|
-
_state.label =
|
|
20774
|
-
case
|
|
21069
|
+
_state.label = 3;
|
|
21070
|
+
case 3:
|
|
20775
21071
|
return [
|
|
20776
21072
|
3,
|
|
20777
|
-
|
|
21073
|
+
1
|
|
20778
21074
|
];
|
|
20779
|
-
case
|
|
21075
|
+
case 4:
|
|
20780
21076
|
return [
|
|
20781
21077
|
2,
|
|
20782
21078
|
res
|
|
20783
21079
|
];
|
|
20784
|
-
case
|
|
21080
|
+
case 5:
|
|
20785
21081
|
if (!SerializationHelper.checkDataPath(property)) return [
|
|
20786
21082
|
3,
|
|
20787
|
-
|
|
21083
|
+
7
|
|
20788
21084
|
];
|
|
20789
21085
|
return [
|
|
20790
21086
|
4,
|
|
20791
21087
|
engine.assetLoader.loadGUIDAsync(property.id)
|
|
20792
21088
|
];
|
|
20793
|
-
case
|
|
21089
|
+
case 6:
|
|
20794
21090
|
res1 = _state.sent();
|
|
20795
21091
|
return [
|
|
20796
21092
|
2,
|
|
20797
21093
|
res1
|
|
20798
21094
|
];
|
|
20799
|
-
case
|
|
20800
|
-
if (_instanceof1(property,
|
|
20801
|
-
return [
|
|
20802
|
-
2,
|
|
20803
|
-
property
|
|
20804
|
-
];
|
|
20805
|
-
} else if (_instanceof1(property, Object)) {
|
|
21095
|
+
case 7:
|
|
21096
|
+
if (_instanceof1(property, Object) && property.constructor === Object) {
|
|
20806
21097
|
if (type) {
|
|
20807
21098
|
classConstructor = effectsClassStore[type];
|
|
20808
21099
|
res2 = new classConstructor();
|
|
@@ -20818,9 +21109,13 @@ var SerializationHelper = /*#__PURE__*/ function() {
|
|
|
20818
21109
|
2,
|
|
20819
21110
|
res2
|
|
20820
21111
|
];
|
|
21112
|
+
} else {
|
|
21113
|
+
return [
|
|
21114
|
+
2,
|
|
21115
|
+
property
|
|
21116
|
+
];
|
|
20821
21117
|
}
|
|
20822
|
-
|
|
20823
|
-
case 9:
|
|
21118
|
+
case 8:
|
|
20824
21119
|
return [
|
|
20825
21120
|
2
|
|
20826
21121
|
];
|
|
@@ -20920,9 +21215,8 @@ var SerializationHelper = /*#__PURE__*/ function() {
|
|
|
20920
21215
|
effectsObject = Geometry.create(this.engine);
|
|
20921
21216
|
break;
|
|
20922
21217
|
case DataType.Texture:
|
|
20923
|
-
|
|
20924
|
-
|
|
20925
|
-
return effectsObject;
|
|
21218
|
+
effectsObject = Texture.create(this.engine);
|
|
21219
|
+
break;
|
|
20926
21220
|
default:
|
|
20927
21221
|
{
|
|
20928
21222
|
var classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
|
|
@@ -20993,12 +21287,8 @@ var SerializationHelper = /*#__PURE__*/ function() {
|
|
|
20993
21287
|
effectsObject = Geometry.create(_this.engine);
|
|
20994
21288
|
break;
|
|
20995
21289
|
case DataType.Texture:
|
|
20996
|
-
|
|
20997
|
-
|
|
20998
|
-
return [
|
|
20999
|
-
2,
|
|
21000
|
-
effectsObject
|
|
21001
|
-
];
|
|
21290
|
+
effectsObject = Texture.create(_this.engine);
|
|
21291
|
+
break;
|
|
21002
21292
|
default:
|
|
21003
21293
|
{
|
|
21004
21294
|
classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
|
|
@@ -21918,8 +22208,15 @@ function getStandardCameraContent(model) {
|
|
|
21918
22208
|
id: item.id
|
|
21919
22209
|
};
|
|
21920
22210
|
});
|
|
22211
|
+
var compositionData = _extends({}, composition, {
|
|
22212
|
+
timelineAsset: {
|
|
22213
|
+
id: ""
|
|
22214
|
+
},
|
|
22215
|
+
sceneBindings: []
|
|
22216
|
+
});
|
|
22217
|
+
result.compositions.push(compositionData);
|
|
21921
22218
|
// 生成时间轴数据
|
|
21922
|
-
convertTimelineAsset(
|
|
22219
|
+
convertTimelineAsset(compositionData, guidToItemMap, result);
|
|
21923
22220
|
};
|
|
21924
22221
|
var // 更正 spine 数据中的 images 属性
|
|
21925
22222
|
_json_spines;
|
|
@@ -21927,6 +22224,7 @@ function getStandardCameraContent(model) {
|
|
|
21927
22224
|
_result;
|
|
21928
22225
|
var result = _extends({}, json, {
|
|
21929
22226
|
items: [],
|
|
22227
|
+
compositions: [],
|
|
21930
22228
|
components: [],
|
|
21931
22229
|
materials: [],
|
|
21932
22230
|
shaders: [],
|
|
@@ -22136,10 +22434,7 @@ function getStandardCameraContent(model) {
|
|
|
22136
22434
|
item.type = "orientation-transformer";
|
|
22137
22435
|
}
|
|
22138
22436
|
// item 的 content 转为 component data 加入 JSONScene.components
|
|
22139
|
-
if (item.type === ItemType.sprite || item.type === ItemType.particle || item.type === ItemType.mesh || item.type === ItemType.skybox || item.type === ItemType.light ||
|
|
22140
|
-
item.type === "camera" || item.type === ItemType.tree || item.type === ItemType.interact || item.type === ItemType.camera || item.type === ItemType.text || item.type === ItemType.spine || // @ts-expect-error
|
|
22141
|
-
item.type === "editor-gizmo" || // @ts-expect-error
|
|
22142
|
-
item.type === "orientation-transformer") {
|
|
22437
|
+
if (item.type === ItemType.sprite || item.type === ItemType.particle || item.type === ItemType.mesh || item.type === ItemType.skybox || item.type === ItemType.light || item.type === "camera" || item.type === ItemType.tree || item.type === ItemType.interact || item.type === ItemType.camera || item.type === ItemType.text || item.type === ItemType.spine || item.type === "editor-gizmo" || item.type === "orientation-transformer") {
|
|
22143
22438
|
item.components = [];
|
|
22144
22439
|
result.components.push(item.content);
|
|
22145
22440
|
item.content.id = generateGUID();
|
|
@@ -22171,15 +22466,12 @@ function getStandardCameraContent(model) {
|
|
|
22171
22466
|
case ItemType.light:
|
|
22172
22467
|
item.content.dataType = DataType.LightComponent;
|
|
22173
22468
|
break;
|
|
22174
|
-
// @ts-expect-error
|
|
22175
22469
|
case "camera":
|
|
22176
22470
|
item.content.dataType = DataType.CameraComponent;
|
|
22177
22471
|
break;
|
|
22178
|
-
// @ts-expect-error
|
|
22179
22472
|
case "editor-gizmo":
|
|
22180
22473
|
item.content.dataType = "GizmoComponent";
|
|
22181
22474
|
break;
|
|
22182
|
-
// @ts-expect-error
|
|
22183
22475
|
case "orientation-transformer":
|
|
22184
22476
|
item.content.dataType = "OrientationComponent";
|
|
22185
22477
|
break;
|
|
@@ -22332,6 +22624,32 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
|
|
|
22332
22624
|
});
|
|
22333
22625
|
trackDatas.push(newTrackData1);
|
|
22334
22626
|
}
|
|
22627
|
+
if (item.type === ItemType.composition) {
|
|
22628
|
+
var newSubCompositionPlayableAssetData = {
|
|
22629
|
+
id: generateGUID(),
|
|
22630
|
+
dataType: "SubCompositionPlayableAsset"
|
|
22631
|
+
};
|
|
22632
|
+
playableAssetDatas.push(newSubCompositionPlayableAssetData);
|
|
22633
|
+
var newTrackData2 = {
|
|
22634
|
+
id: generateGUID(),
|
|
22635
|
+
dataType: "SubCompositionTrack",
|
|
22636
|
+
children: [],
|
|
22637
|
+
clips: [
|
|
22638
|
+
{
|
|
22639
|
+
start: item.delay,
|
|
22640
|
+
duration: item.duration,
|
|
22641
|
+
endBehaviour: item.endBehavior,
|
|
22642
|
+
asset: {
|
|
22643
|
+
id: newSubCompositionPlayableAssetData.id
|
|
22644
|
+
}
|
|
22645
|
+
}
|
|
22646
|
+
]
|
|
22647
|
+
};
|
|
22648
|
+
subTrackDatas.push({
|
|
22649
|
+
id: newTrackData2.id
|
|
22650
|
+
});
|
|
22651
|
+
trackDatas.push(newTrackData2);
|
|
22652
|
+
}
|
|
22335
22653
|
var bindingTrackData = {
|
|
22336
22654
|
id: generateGUID(),
|
|
22337
22655
|
dataType: "ObjectBindingTrack",
|
|
@@ -22358,11 +22676,9 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
|
|
|
22358
22676
|
id: trackData.id
|
|
22359
22677
|
});
|
|
22360
22678
|
}
|
|
22361
|
-
//@ts-expect-error
|
|
22362
22679
|
composition.timelineAsset = {
|
|
22363
22680
|
id: timelineAssetData.id
|
|
22364
22681
|
};
|
|
22365
|
-
//@ts-expect-error
|
|
22366
22682
|
composition.sceneBindings = sceneBindings;
|
|
22367
22683
|
if (!jsonScene.animations) {
|
|
22368
22684
|
jsonScene.animations = [];
|
|
@@ -22693,7 +23009,17 @@ function getStandardItem(item, opt) {
|
|
|
22693
23009
|
}
|
|
22694
23010
|
|
|
22695
23011
|
var _obj$1;
|
|
22696
|
-
|
|
23012
|
+
/**
|
|
23013
|
+
* 机型和渲染等级对应表
|
|
23014
|
+
*
|
|
23015
|
+
* 机型:B-低端机、A-中端机、S-高端机
|
|
23016
|
+
* 渲染等级:B-低、A-中、S-高、A+-中高、B+-全部
|
|
23017
|
+
*
|
|
23018
|
+
* - S(高端机):高、全部、中高
|
|
23019
|
+
* - A(中端机):中、全部、中高
|
|
23020
|
+
* - B(低端机):低、全部
|
|
23021
|
+
* - undefined(全部机型)
|
|
23022
|
+
*/ var renderLevelPassSet = (_obj$1 = {}, _obj$1[RenderLevel.S] = [
|
|
22697
23023
|
RenderLevel.S,
|
|
22698
23024
|
RenderLevel.BPlus,
|
|
22699
23025
|
RenderLevel.APlus
|
|
@@ -23607,42 +23933,6 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
23607
23933
|
}
|
|
23608
23934
|
throw new Error("Invalid texture options");
|
|
23609
23935
|
}
|
|
23610
|
-
function base64ToFile(base64, filename, contentType) {
|
|
23611
|
-
if (filename === void 0) filename = "base64File";
|
|
23612
|
-
if (contentType === void 0) contentType = "";
|
|
23613
|
-
// 去掉 Base64 字符串的 Data URL 部分(如果存在)
|
|
23614
|
-
var base64WithoutPrefix = base64.split(",")[1] || base64;
|
|
23615
|
-
// 将 base64 编码的字符串转换为二进制字符串
|
|
23616
|
-
var byteCharacters = atob(base64WithoutPrefix);
|
|
23617
|
-
// 创建一个 8 位无符号整数值的数组,即“字节数组”
|
|
23618
|
-
var byteArrays = [];
|
|
23619
|
-
// 切割二进制字符串为多个片段,并将每个片段转换成一个字节数组
|
|
23620
|
-
for(var offset = 0; offset < byteCharacters.length; offset += 512){
|
|
23621
|
-
var slice = byteCharacters.slice(offset, offset + 512);
|
|
23622
|
-
var byteNumbers = new Array(slice.length);
|
|
23623
|
-
for(var i = 0; i < slice.length; i++){
|
|
23624
|
-
byteNumbers[i] = slice.charCodeAt(i);
|
|
23625
|
-
}
|
|
23626
|
-
var byteArray = new Uint8Array(byteNumbers);
|
|
23627
|
-
byteArrays.push(byteArray);
|
|
23628
|
-
}
|
|
23629
|
-
// 使用字节数组创建 Blob 对象
|
|
23630
|
-
var blob = new Blob(byteArrays, {
|
|
23631
|
-
type: contentType
|
|
23632
|
-
});
|
|
23633
|
-
// 创建 File 对象
|
|
23634
|
-
var file = new File([
|
|
23635
|
-
blob
|
|
23636
|
-
], filename, {
|
|
23637
|
-
type: contentType
|
|
23638
|
-
});
|
|
23639
|
-
return file;
|
|
23640
|
-
}
|
|
23641
|
-
function isCanvas(canvas) {
|
|
23642
|
-
var _canvas_tagName;
|
|
23643
|
-
// 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
|
|
23644
|
-
return typeof canvas === "object" && canvas !== null && ((_canvas_tagName = canvas.tagName) == null ? void 0 : _canvas_tagName.toUpperCase()) === "CANVAS";
|
|
23645
|
-
}
|
|
23646
23936
|
|
|
23647
23937
|
var tmpScale = new Vector3(1, 1, 1);
|
|
23648
23938
|
/**
|
|
@@ -23920,283 +24210,229 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
23920
24210
|
return Camera;
|
|
23921
24211
|
}();
|
|
23922
24212
|
|
|
24213
|
+
var listOrder = 0;
|
|
23923
24214
|
/**
|
|
23924
|
-
*
|
|
23925
|
-
|
|
23926
|
-
|
|
23927
|
-
|
|
23928
|
-
|
|
23929
|
-
|
|
23930
|
-
|
|
23931
|
-
|
|
23932
|
-
|
|
23933
|
-
|
|
23934
|
-
|
|
23935
|
-
|
|
23936
|
-
|
|
23937
|
-
|
|
23938
|
-
|
|
23939
|
-
|
|
24215
|
+
* 合成资源管理
|
|
24216
|
+
*/ var CompositionSourceManager = /*#__PURE__*/ function() {
|
|
24217
|
+
function CompositionSourceManager(scene, engine) {
|
|
24218
|
+
this.refCompositions = new Map();
|
|
24219
|
+
this.refCompositionProps = new Map();
|
|
24220
|
+
this.mask = 0;
|
|
24221
|
+
this.engine = engine;
|
|
24222
|
+
// 资源
|
|
24223
|
+
var jsonScene = scene.jsonScene, renderLevel = scene.renderLevel, textureOptions = scene.textureOptions, pluginSystem = scene.pluginSystem, totalTime = scene.totalTime;
|
|
24224
|
+
var compositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, compositionId = jsonScene.compositionId;
|
|
24225
|
+
if (!textureOptions) {
|
|
24226
|
+
throw new Error("scene.textures expected");
|
|
24227
|
+
}
|
|
24228
|
+
var cachedTextures = textureOptions;
|
|
24229
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(compositions), _step; !(_step = _iterator()).done;){
|
|
24230
|
+
var comp = _step.value;
|
|
24231
|
+
if (comp.id === compositionId) {
|
|
24232
|
+
this.composition = comp;
|
|
24233
|
+
} else {
|
|
24234
|
+
this.refCompositions.set(comp.id, comp);
|
|
24235
|
+
}
|
|
24236
|
+
}
|
|
24237
|
+
if (!this.composition) {
|
|
24238
|
+
throw new Error("Invalid composition id: " + compositionId);
|
|
24239
|
+
}
|
|
24240
|
+
this.jsonScene = jsonScene;
|
|
24241
|
+
this.renderLevel = renderLevel;
|
|
24242
|
+
this.pluginSystem = pluginSystem;
|
|
24243
|
+
this.totalTime = totalTime != null ? totalTime : 0;
|
|
24244
|
+
this.imgUsage = imgUsage != null ? imgUsage : {};
|
|
24245
|
+
this.textures = cachedTextures;
|
|
24246
|
+
listOrder = 0;
|
|
24247
|
+
this.sourceContent = this.getContent(this.composition);
|
|
23940
24248
|
}
|
|
23941
|
-
var _proto =
|
|
23942
|
-
_proto.
|
|
23943
|
-
|
|
23944
|
-
|
|
23945
|
-
|
|
23946
|
-
|
|
23947
|
-
|
|
23948
|
-
|
|
24249
|
+
var _proto = CompositionSourceManager.prototype;
|
|
24250
|
+
_proto.getContent = function getContent(composition) {
|
|
24251
|
+
// TODO: specification 中补充 globalVolume 类型
|
|
24252
|
+
// @ts-expect-error
|
|
24253
|
+
var id = composition.id, duration = composition.duration, name = composition.name, endBehavior = composition.endBehavior, camera = composition.camera, globalVolume = composition.globalVolume, _composition_startTime = composition.startTime, startTime = _composition_startTime === void 0 ? 0 : _composition_startTime;
|
|
24254
|
+
var items = this.assembleItems(composition);
|
|
24255
|
+
return _extends({}, composition, {
|
|
24256
|
+
id: id,
|
|
24257
|
+
duration: duration,
|
|
24258
|
+
name: name,
|
|
24259
|
+
endBehavior: isNaN(endBehavior) ? END_BEHAVIOR_PAUSE : endBehavior,
|
|
24260
|
+
// looping,
|
|
24261
|
+
items: items,
|
|
24262
|
+
camera: camera,
|
|
24263
|
+
startTime: startTime,
|
|
24264
|
+
globalVolume: globalVolume
|
|
24265
|
+
});
|
|
24266
|
+
};
|
|
24267
|
+
_proto.assembleItems = function assembleItems(composition) {
|
|
24268
|
+
var _this = this;
|
|
24269
|
+
var items = [];
|
|
24270
|
+
this.mask++;
|
|
24271
|
+
var componentMap = {};
|
|
24272
|
+
//@ts-expect-error
|
|
24273
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.jsonScene.components), _step; !(_step = _iterator()).done;){
|
|
24274
|
+
var component = _step.value;
|
|
24275
|
+
componentMap[component.id] = component;
|
|
23949
24276
|
}
|
|
23950
|
-
|
|
23951
|
-
|
|
23952
|
-
|
|
23953
|
-
|
|
23954
|
-
var
|
|
23955
|
-
|
|
23956
|
-
|
|
23957
|
-
|
|
23958
|
-
|
|
23959
|
-
|
|
23960
|
-
|
|
24277
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(composition.items), _step1; !(_step1 = _iterator1()).done;){
|
|
24278
|
+
var itemDataPath = _step1.value;
|
|
24279
|
+
//@ts-expect-error
|
|
24280
|
+
var sourceItemData = this.engine.jsonSceneData[itemDataPath.id];
|
|
24281
|
+
var itemProps = sourceItemData;
|
|
24282
|
+
if (passRenderLevel(sourceItemData.renderLevel, this.renderLevel)) {
|
|
24283
|
+
if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle) {
|
|
24284
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(itemProps.components), _step2; !(_step2 = _iterator2()).done;){
|
|
24285
|
+
var componentPath = _step2.value;
|
|
24286
|
+
var componentData = componentMap[componentPath.id];
|
|
24287
|
+
this.preProcessItemContent(componentData);
|
|
24288
|
+
}
|
|
24289
|
+
} else {
|
|
24290
|
+
var renderContent = itemProps.content;
|
|
24291
|
+
if (renderContent) {
|
|
24292
|
+
this.preProcessItemContent(renderContent);
|
|
24293
|
+
}
|
|
24294
|
+
}
|
|
24295
|
+
itemProps.listIndex = listOrder++;
|
|
24296
|
+
// 处理预合成的渲染顺序
|
|
24297
|
+
if (itemProps.type === ItemType.composition) {
|
|
24298
|
+
var refId = sourceItemData.content.options.refId;
|
|
24299
|
+
if (!this.refCompositions.get(refId)) {
|
|
24300
|
+
throw new Error("Invalid Ref Composition id: " + refId);
|
|
23961
24301
|
}
|
|
23962
|
-
var
|
|
23963
|
-
if (
|
|
23964
|
-
|
|
24302
|
+
var ref = this.getContent(this.refCompositions.get(refId));
|
|
24303
|
+
if (!this.refCompositionProps.has(refId)) {
|
|
24304
|
+
this.refCompositionProps.set(refId, ref);
|
|
23965
24305
|
}
|
|
24306
|
+
ref.items.forEach(function(item) {
|
|
24307
|
+
_this.processMask(item.content);
|
|
24308
|
+
});
|
|
24309
|
+
itemProps.items = ref.items;
|
|
23966
24310
|
}
|
|
24311
|
+
items.push(itemProps);
|
|
23967
24312
|
}
|
|
23968
|
-
this.masterTracks.push(track);
|
|
23969
|
-
}
|
|
23970
|
-
};
|
|
23971
|
-
_proto.initializeTrackBindings = function initializeTrackBindings(masterTracks) {
|
|
23972
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(masterTracks), _step; !(_step = _iterator()).done;){
|
|
23973
|
-
var track = _step.value;
|
|
23974
|
-
track.initializeBindingRecursive(track.binding);
|
|
23975
24313
|
}
|
|
24314
|
+
return items;
|
|
23976
24315
|
};
|
|
23977
|
-
_proto.
|
|
23978
|
-
|
|
23979
|
-
|
|
23980
|
-
|
|
23981
|
-
|
|
23982
|
-
|
|
23983
|
-
|
|
23984
|
-
|
|
23985
|
-
|
|
23986
|
-
|
|
23987
|
-
|
|
23988
|
-
if (
|
|
23989
|
-
|
|
23990
|
-
subCompostionComponent.time = subCompositionTrack.toLocalTime(time);
|
|
24316
|
+
_proto.preProcessItemContent = function preProcessItemContent(renderContent) {
|
|
24317
|
+
if (renderContent.renderer) {
|
|
24318
|
+
renderContent.renderer = this.changeTex(renderContent.renderer);
|
|
24319
|
+
if (!renderContent.renderer.mask) {
|
|
24320
|
+
this.processMask(renderContent.renderer);
|
|
24321
|
+
}
|
|
24322
|
+
var split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
|
|
24323
|
+
if (Number.isInteger(renderContent.renderer.shape)) {
|
|
24324
|
+
var _this_jsonScene;
|
|
24325
|
+
// TODO: scene.shapes 类型问题?
|
|
24326
|
+
renderContent.renderer.shape = getGeometryByShape((_this_jsonScene = this.jsonScene) == null ? void 0 : _this_jsonScene.shapes[renderContent.renderer.shape], split);
|
|
24327
|
+
} else if (renderContent.renderer.shape && isObject(renderContent.renderer.shape)) {
|
|
24328
|
+
renderContent.renderer.shape = getGeometryByShape(renderContent.renderer.shape, split);
|
|
23991
24329
|
}
|
|
23992
24330
|
}
|
|
24331
|
+
if (renderContent.trails) {
|
|
24332
|
+
renderContent.trails = this.changeTex(renderContent.trails);
|
|
24333
|
+
}
|
|
23993
24334
|
};
|
|
23994
|
-
|
|
23995
|
-
|
|
23996
|
-
|
|
23997
|
-
this.item.ended = false;
|
|
23998
|
-
};
|
|
23999
|
-
_proto.createContent = function createContent() {
|
|
24000
|
-
var sceneBindings = [];
|
|
24001
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.data.sceneBindings), _step; !(_step = _iterator()).done;){
|
|
24002
|
-
var sceneBindingData = _step.value;
|
|
24003
|
-
sceneBindings.push({
|
|
24004
|
-
key: this.engine.assetLoader.loadGUID(sceneBindingData.key.id),
|
|
24005
|
-
value: this.engine.assetLoader.loadGUID(sceneBindingData.value.id)
|
|
24006
|
-
});
|
|
24335
|
+
_proto.changeTex = function changeTex(renderer) {
|
|
24336
|
+
if (!renderer.texture) {
|
|
24337
|
+
return renderer;
|
|
24007
24338
|
}
|
|
24008
|
-
|
|
24009
|
-
var
|
|
24010
|
-
|
|
24011
|
-
|
|
24012
|
-
|
|
24013
|
-
if (this.item.composition) {
|
|
24014
|
-
var assetLoader = this.item.engine.assetLoader;
|
|
24015
|
-
var itemProps = this.item.props.items ? this.item.props.items : [];
|
|
24016
|
-
for(var i = 0; i < itemProps.length; i++){
|
|
24017
|
-
var item = void 0;
|
|
24018
|
-
var itemData = itemProps[i];
|
|
24019
|
-
// 设置预合成作为元素时的时长、结束行为和渲染延时
|
|
24020
|
-
if (exports.Item.isComposition(itemData)) {
|
|
24021
|
-
var refId = itemData.content.options.refId;
|
|
24022
|
-
var props = this.item.composition.refCompositionProps.get(refId);
|
|
24023
|
-
if (!props) {
|
|
24024
|
-
throw new Error("引用的Id: " + refId + " 的预合成不存在");
|
|
24025
|
-
}
|
|
24026
|
-
// endBehaviour 类型需优化
|
|
24027
|
-
props.content = itemData.content;
|
|
24028
|
-
item = assetLoader.loadGUID(itemData.id);
|
|
24029
|
-
item.composition = this.item.composition;
|
|
24030
|
-
var compositionComponent = item.addComponent(CompositionComponent);
|
|
24031
|
-
compositionComponent.data = props;
|
|
24032
|
-
compositionComponent.refId = refId;
|
|
24033
|
-
item.transform.parentTransform = this.transform;
|
|
24034
|
-
this.item.composition.refContent.push(item);
|
|
24035
|
-
if (item.endBehavior === ItemEndBehavior.loop) {
|
|
24036
|
-
this.item.composition.autoRefTex = false;
|
|
24037
|
-
}
|
|
24038
|
-
compositionComponent.createContent();
|
|
24039
|
-
for(var _iterator1 = _create_for_of_iterator_helper_loose(compositionComponent.items), _step1; !(_step1 = _iterator1()).done;){
|
|
24040
|
-
var vfxItem = _step1.value;
|
|
24041
|
-
vfxItem.setInstanceId(generateGUID());
|
|
24042
|
-
for(var _iterator2 = _create_for_of_iterator_helper_loose(vfxItem.components), _step2; !(_step2 = _iterator2()).done;){
|
|
24043
|
-
var component = _step2.value;
|
|
24044
|
-
component.setInstanceId(generateGUID());
|
|
24045
|
-
}
|
|
24046
|
-
}
|
|
24047
|
-
} else {
|
|
24048
|
-
item = assetLoader.loadGUID(itemData.id);
|
|
24049
|
-
item.composition = this.item.composition;
|
|
24050
|
-
}
|
|
24051
|
-
item.parent = this.item;
|
|
24052
|
-
// 相机不跟随合成移动
|
|
24053
|
-
item.transform.parentTransform = itemData.type === ItemType.camera ? new Transform() : this.transform;
|
|
24054
|
-
if (exports.VFXItem.isExtraCamera(item)) {
|
|
24055
|
-
this.item.composition.extraCamera = item;
|
|
24056
|
-
}
|
|
24057
|
-
items.push(item);
|
|
24058
|
-
}
|
|
24339
|
+
//@ts-expect-error
|
|
24340
|
+
var texIdx = renderer.texture.id;
|
|
24341
|
+
if (texIdx !== undefined) {
|
|
24342
|
+
//@ts-expect-error
|
|
24343
|
+
this.addTextureUsage(texIdx) || texIdx;
|
|
24059
24344
|
}
|
|
24345
|
+
return renderer;
|
|
24060
24346
|
};
|
|
24061
|
-
_proto.
|
|
24062
|
-
|
|
24063
|
-
|
|
24064
|
-
|
|
24065
|
-
|
|
24066
|
-
|
|
24067
|
-
|
|
24347
|
+
_proto.addTextureUsage = function addTextureUsage(texIdx) {
|
|
24348
|
+
var texId = texIdx;
|
|
24349
|
+
var _this_imgUsage;
|
|
24350
|
+
// FIXME: imageUsage 取自 scene.imgUsage,类型为 Record<string, number[]>,这里给的 number,类型对不上
|
|
24351
|
+
var imageUsage = (_this_imgUsage = this.imgUsage) != null ? _this_imgUsage : {};
|
|
24352
|
+
if (texId && imageUsage) {
|
|
24353
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
24354
|
+
if (!imageUsage.hasOwnProperty(texId)) {
|
|
24355
|
+
imageUsage[texId] = 0;
|
|
24068
24356
|
}
|
|
24357
|
+
imageUsage[texId]++;
|
|
24069
24358
|
}
|
|
24070
24359
|
};
|
|
24071
|
-
|
|
24072
|
-
|
|
24073
|
-
|
|
24074
|
-
|
|
24075
|
-
|
|
24076
|
-
|
|
24077
|
-
|
|
24078
|
-
|
|
24079
|
-
|
|
24080
|
-
|
|
24081
|
-
|
|
24082
|
-
|
|
24083
|
-
if (ray.intersectTriangle(triangle, intersectPoint, backfaceCulling)) {
|
|
24084
|
-
success = true;
|
|
24085
|
-
hitPositions.push(intersectPoint);
|
|
24086
|
-
break;
|
|
24087
|
-
}
|
|
24088
|
-
}
|
|
24089
|
-
} else if (hitParams.type === exports.HitTestType.box) {
|
|
24090
|
-
var center = hitParams.center, size = hitParams.size;
|
|
24091
|
-
var boxMin = center.clone().addScaledVector(size, 0.5);
|
|
24092
|
-
var boxMax = center.clone().addScaledVector(size, -0.5);
|
|
24093
|
-
if (ray.intersectBox({
|
|
24094
|
-
min: boxMin,
|
|
24095
|
-
max: boxMax
|
|
24096
|
-
}, intersectPoint)) {
|
|
24097
|
-
success = true;
|
|
24098
|
-
hitPositions.push(intersectPoint);
|
|
24099
|
-
}
|
|
24100
|
-
} else if (hitParams.type === exports.HitTestType.sphere) {
|
|
24101
|
-
var center1 = hitParams.center, radius = hitParams.radius;
|
|
24102
|
-
if (ray.intersectSphere({
|
|
24103
|
-
center: center1,
|
|
24104
|
-
radius: radius
|
|
24105
|
-
}, intersectPoint)) {
|
|
24106
|
-
success = true;
|
|
24107
|
-
hitPositions.push(intersectPoint);
|
|
24108
|
-
}
|
|
24109
|
-
} else if (hitParams.type === exports.HitTestType.custom) {
|
|
24110
|
-
var tempPosition = hitParams.collect(ray, new Vector2(x, y));
|
|
24111
|
-
if (tempPosition && tempPosition.length > 0) {
|
|
24112
|
-
tempPosition.forEach(function(pos) {
|
|
24113
|
-
hitPositions.push(pos);
|
|
24114
|
-
});
|
|
24115
|
-
success = true;
|
|
24116
|
-
}
|
|
24117
|
-
}
|
|
24118
|
-
if (success) {
|
|
24119
|
-
var region = {
|
|
24120
|
-
compContent: _this.item,
|
|
24121
|
-
id: item.id,
|
|
24122
|
-
name: item.name,
|
|
24123
|
-
position: hitPositions[hitPositions.length - 1],
|
|
24124
|
-
parentId: item.parentId,
|
|
24125
|
-
hitPositions: hitPositions,
|
|
24126
|
-
behavior: hitParams.behavior
|
|
24127
|
-
};
|
|
24128
|
-
regions.push(region);
|
|
24129
|
-
if (stop(region)) {
|
|
24130
|
-
return {
|
|
24131
|
-
v: regions
|
|
24132
|
-
};
|
|
24133
|
-
}
|
|
24134
|
-
}
|
|
24135
|
-
}
|
|
24360
|
+
/**
|
|
24361
|
+
* 处理蒙版和遮挡关系写入 stencil 的 ref 值
|
|
24362
|
+
*/ _proto.processMask = function processMask(renderer) {
|
|
24363
|
+
var maskMode = renderer.maskMode;
|
|
24364
|
+
if (maskMode === MaskMode.NONE) {
|
|
24365
|
+
return;
|
|
24366
|
+
}
|
|
24367
|
+
if (!renderer.mask) {
|
|
24368
|
+
if (maskMode === MaskMode.MASK) {
|
|
24369
|
+
renderer.mask = ++this.mask;
|
|
24370
|
+
} else if (maskMode === MaskMode.OBSCURED || maskMode === MaskMode.REVERSE_OBSCURED) {
|
|
24371
|
+
renderer.mask = this.mask;
|
|
24136
24372
|
}
|
|
24137
|
-
};
|
|
24138
|
-
var hitPositions = [];
|
|
24139
|
-
var stop = (options == null ? void 0 : options.stop) || noop;
|
|
24140
|
-
var skip = (options == null ? void 0 : options.skip) || noop;
|
|
24141
|
-
var maxCount = (options == null ? void 0 : options.maxCount) || this.items.length;
|
|
24142
|
-
for(var i = 0; i < this.items.length && regions.length < maxCount; i++){
|
|
24143
|
-
var _ret = (_this = this, _loop(i));
|
|
24144
|
-
if (_type_of(_ret) === "object") return _ret.v;
|
|
24145
24373
|
}
|
|
24146
|
-
return regions;
|
|
24147
24374
|
};
|
|
24148
|
-
_proto.
|
|
24149
|
-
|
|
24375
|
+
_proto.dispose = function dispose() {
|
|
24376
|
+
this.textures = [];
|
|
24377
|
+
this.composition = undefined;
|
|
24378
|
+
this.jsonScene = undefined;
|
|
24379
|
+
this.totalTime = 0;
|
|
24380
|
+
this.pluginSystem = undefined;
|
|
24381
|
+
this.sourceContent = undefined;
|
|
24382
|
+
this.refCompositions.clear();
|
|
24383
|
+
this.refCompositionProps.clear();
|
|
24150
24384
|
};
|
|
24151
|
-
return
|
|
24152
|
-
}(
|
|
24385
|
+
return CompositionSourceManager;
|
|
24386
|
+
}();
|
|
24153
24387
|
|
|
24154
24388
|
/**
|
|
24155
24389
|
* 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
|
|
24156
24390
|
* 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
|
|
24157
24391
|
* 也负责 Item 相关的动画播放控制,和持有渲染帧数据。
|
|
24158
24392
|
*/ var Composition = /*#__PURE__*/ function() {
|
|
24159
|
-
function Composition(props, scene
|
|
24393
|
+
function Composition(props, scene) {
|
|
24160
24394
|
var _this = this;
|
|
24161
|
-
|
|
24162
|
-
this./**
|
|
24395
|
+
/**
|
|
24163
24396
|
* 动画播放速度
|
|
24164
|
-
*/ speed = 1;
|
|
24165
|
-
|
|
24166
|
-
|
|
24167
|
-
|
|
24397
|
+
*/ this.speed = 1;
|
|
24398
|
+
/**
|
|
24399
|
+
* 用于保存与当前合成相关的插件数据
|
|
24400
|
+
*/ this.loaderData = {};
|
|
24401
|
+
/**
|
|
24402
|
+
* 预合成数组
|
|
24403
|
+
*/ this.refContent = [];
|
|
24404
|
+
/**
|
|
24168
24405
|
* 预合成的合成属性,在 content 中会被其元素属性覆盖
|
|
24169
|
-
*/ refCompositionProps = new Map();
|
|
24406
|
+
*/ this.refCompositionProps = new Map();
|
|
24170
24407
|
this.editorScaleRatio = 1.0;
|
|
24408
|
+
// TODO: 待优化
|
|
24171
24409
|
this.assigned = false;
|
|
24172
|
-
|
|
24173
|
-
|
|
24410
|
+
/**
|
|
24411
|
+
* 销毁状态位
|
|
24412
|
+
*/ this.destroyed = false;
|
|
24413
|
+
/**
|
|
24414
|
+
* 合成暂停/播放 标识
|
|
24415
|
+
*/ this.paused = false;
|
|
24174
24416
|
this.lastVideoUpdateTime = 0;
|
|
24175
24417
|
this.postLoaders = [];
|
|
24176
24418
|
var _props_reusable = props.reusable, reusable = _props_reusable === void 0 ? false : _props_reusable, _props_speed = props.speed, speed = _props_speed === void 0 ? 1 : _props_speed, _props_baseRenderOrder = props.baseRenderOrder, baseRenderOrder = _props_baseRenderOrder === void 0 ? 0 : _props_baseRenderOrder, renderer = props.renderer, onPlayerPause = props.onPlayerPause, onMessageItem = props.onMessageItem, onEnd = props.onEnd, event = props.event, width = props.width, height = props.height;
|
|
24419
|
+
this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
|
|
24177
24420
|
scene.jsonScene.imgUsage = undefined;
|
|
24178
24421
|
if (reusable) {
|
|
24179
24422
|
this.keepResource = true;
|
|
24180
24423
|
scene.textures = undefined;
|
|
24181
24424
|
scene.consumed = true;
|
|
24182
24425
|
}
|
|
24183
|
-
var _this_compositionSourceManager = this.compositionSourceManager, sourceContent = _this_compositionSourceManager.sourceContent, pluginSystem = _this_compositionSourceManager.pluginSystem, imgUsage = _this_compositionSourceManager.imgUsage, totalTime = _this_compositionSourceManager.totalTime,
|
|
24426
|
+
var _this_compositionSourceManager = this.compositionSourceManager, sourceContent = _this_compositionSourceManager.sourceContent, pluginSystem = _this_compositionSourceManager.pluginSystem, imgUsage = _this_compositionSourceManager.imgUsage, totalTime = _this_compositionSourceManager.totalTime, refCompositionProps = _this_compositionSourceManager.refCompositionProps;
|
|
24184
24427
|
assertExist(sourceContent);
|
|
24185
24428
|
this.renderer = renderer;
|
|
24186
24429
|
this.refCompositionProps = refCompositionProps;
|
|
24187
|
-
|
|
24188
|
-
|
|
24189
|
-
|
|
24190
|
-
|
|
24191
|
-
vfxItem.composition = this;
|
|
24192
|
-
this.rootComposition = vfxItem.addComponent(CompositionComponent);
|
|
24430
|
+
this.rootItem = new exports.VFXItem(this.getEngine(), sourceContent);
|
|
24431
|
+
this.rootItem.name = "rootItem";
|
|
24432
|
+
this.rootItem.composition = this;
|
|
24433
|
+
this.rootComposition = this.rootItem.addComponent(CompositionComponent);
|
|
24193
24434
|
this.rootComposition.data = sourceContent;
|
|
24194
24435
|
var imageUsage = !reusable && imgUsage;
|
|
24195
|
-
this.transform = new Transform({
|
|
24196
|
-
name: this.name
|
|
24197
|
-
});
|
|
24198
|
-
this.transform.engine = this.getEngine();
|
|
24199
|
-
vfxItem.transform = this.transform;
|
|
24200
24436
|
this.globalVolume = sourceContent.globalVolume;
|
|
24201
24437
|
this.width = width;
|
|
24202
24438
|
this.height = height;
|
|
@@ -24213,9 +24449,7 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
24213
24449
|
};
|
|
24214
24450
|
this.reusable = reusable;
|
|
24215
24451
|
this.speed = speed;
|
|
24216
|
-
this.
|
|
24217
|
-
this.autoRefTex = !this.keepResource && imageUsage && vfxItem.endBehavior !== ItemEndBehavior.loop;
|
|
24218
|
-
this.rootItem = vfxItem;
|
|
24452
|
+
this.autoRefTex = !this.keepResource && imageUsage && this.rootItem.endBehavior !== ItemEndBehavior.loop;
|
|
24219
24453
|
this.name = sourceContent.name;
|
|
24220
24454
|
this.pluginSystem = pluginSystem;
|
|
24221
24455
|
this.pluginSystem.initializeComposition(this, scene);
|
|
@@ -24248,16 +24482,8 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
24248
24482
|
/**
|
|
24249
24483
|
* 重新开始合成
|
|
24250
24484
|
*/ _proto.restart = function restart() {
|
|
24251
|
-
// const contentItems = this.rootComposition.items;
|
|
24252
|
-
// contentItems.forEach(item => item.dispose());
|
|
24253
|
-
// contentItems.length = 0;
|
|
24254
|
-
this.prepareRender();
|
|
24255
24485
|
this.reset();
|
|
24256
|
-
this.transform.setValid(true);
|
|
24257
|
-
this.rootComposition.resetStatus();
|
|
24258
24486
|
this.forwardTime(this.startTime);
|
|
24259
|
-
// this.content.onUpdate(0);
|
|
24260
|
-
// this.loaderData.spriteGroup.onUpdate(0);
|
|
24261
24487
|
};
|
|
24262
24488
|
/**
|
|
24263
24489
|
* 设置当前合成的渲染顺序
|
|
@@ -24385,28 +24611,9 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
24385
24611
|
/**
|
|
24386
24612
|
* 重置状态函数
|
|
24387
24613
|
*/ _proto.reset = function reset() {
|
|
24388
|
-
var _this = this;
|
|
24389
|
-
var vfxItem = new exports.VFXItem(this.getEngine(), this.compositionSourceManager.sourceContent);
|
|
24390
|
-
// TODO 编辑器数据传入 composition type 后移除
|
|
24391
|
-
vfxItem.type = ItemType.composition;
|
|
24392
|
-
vfxItem.composition = this;
|
|
24393
|
-
this.rootComposition = vfxItem.addComponent(CompositionComponent);
|
|
24394
|
-
this.rootComposition.data = this.compositionSourceManager.sourceContent;
|
|
24395
|
-
this.transform = new Transform({
|
|
24396
|
-
name: this.name
|
|
24397
|
-
});
|
|
24398
|
-
this.transform.engine = this.getEngine();
|
|
24399
|
-
vfxItem.transform = this.transform;
|
|
24400
|
-
this.rootItem = vfxItem;
|
|
24401
24614
|
this.rendererOptions = null;
|
|
24402
24615
|
this.globalTime = 0;
|
|
24403
|
-
this.
|
|
24404
|
-
this.buildItemTree(this.rootItem);
|
|
24405
|
-
this.rootItem.onEnd = function() {
|
|
24406
|
-
window.setTimeout(function() {
|
|
24407
|
-
_this.onEnd == null ? void 0 : _this.onEnd.call(_this, _this);
|
|
24408
|
-
}, 0);
|
|
24409
|
-
};
|
|
24616
|
+
this.rootItem.ended = false;
|
|
24410
24617
|
this.pluginSystem.resetComposition(this, this.renderFrame);
|
|
24411
24618
|
};
|
|
24412
24619
|
_proto.prepareRender = function prepareRender() {
|
|
@@ -24452,7 +24659,6 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
24452
24659
|
}
|
|
24453
24660
|
var _this_rootItem = this.rootItem, ended = _this_rootItem.ended, endBehavior = _this_rootItem.endBehavior;
|
|
24454
24661
|
// TODO: 合成结束行为
|
|
24455
|
-
// @ts-expect-error
|
|
24456
24662
|
return ended && (!endBehavior || endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY);
|
|
24457
24663
|
};
|
|
24458
24664
|
/**
|
|
@@ -24548,7 +24754,7 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
24548
24754
|
var child = _step2.value;
|
|
24549
24755
|
if (exports.VFXItem.isComposition(child)) {
|
|
24550
24756
|
if (child.ended && child.endBehavior === ItemEndBehavior.loop) {
|
|
24551
|
-
child.
|
|
24757
|
+
child.ended = false;
|
|
24552
24758
|
// TODO K帧动画在元素重建后需要 tick ,否则会导致元素位置和 k 帧第一帧位置不一致
|
|
24553
24759
|
this.callUpdate(child, 0);
|
|
24554
24760
|
} else {
|
|
@@ -24955,6 +25161,14 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
24955
25161
|
})();
|
|
24956
25162
|
};
|
|
24957
25163
|
_create_class(Composition, [
|
|
25164
|
+
{
|
|
25165
|
+
key: "transform",
|
|
25166
|
+
get: /**
|
|
25167
|
+
* 所有合成 Item 的根变换
|
|
25168
|
+
*/ function get() {
|
|
25169
|
+
return this.rootItem.transform;
|
|
25170
|
+
}
|
|
25171
|
+
},
|
|
24958
25172
|
{
|
|
24959
25173
|
key: "textures",
|
|
24960
25174
|
get: /**
|
|
@@ -25000,189 +25214,6 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
25000
25214
|
return Composition;
|
|
25001
25215
|
}();
|
|
25002
25216
|
|
|
25003
|
-
var listOrder = 0;
|
|
25004
|
-
/**
|
|
25005
|
-
* 合成资源管理
|
|
25006
|
-
*/ var CompositionSourceManager = /*#__PURE__*/ function() {
|
|
25007
|
-
function CompositionSourceManager(scene, engine) {
|
|
25008
|
-
this.refCompositions = new Map();
|
|
25009
|
-
this.refCompositionProps = new Map();
|
|
25010
|
-
this.mask = 0;
|
|
25011
|
-
this.engine = engine;
|
|
25012
|
-
// 资源
|
|
25013
|
-
var jsonScene = scene.jsonScene, renderLevel = scene.renderLevel, textureOptions = scene.textureOptions, pluginSystem = scene.pluginSystem, totalTime = scene.totalTime;
|
|
25014
|
-
var compositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, compositionId = jsonScene.compositionId;
|
|
25015
|
-
if (!textureOptions) {
|
|
25016
|
-
throw new Error("scene.textures expected");
|
|
25017
|
-
}
|
|
25018
|
-
var cachedTextures = textureOptions;
|
|
25019
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(compositions), _step; !(_step = _iterator()).done;){
|
|
25020
|
-
var comp = _step.value;
|
|
25021
|
-
if (comp.id === compositionId) {
|
|
25022
|
-
this.composition = comp;
|
|
25023
|
-
} else {
|
|
25024
|
-
this.refCompositions.set(comp.id, comp);
|
|
25025
|
-
}
|
|
25026
|
-
}
|
|
25027
|
-
if (!this.composition) {
|
|
25028
|
-
throw new Error("Invalid composition id: " + compositionId);
|
|
25029
|
-
}
|
|
25030
|
-
this.jsonScene = jsonScene;
|
|
25031
|
-
this.renderLevel = renderLevel;
|
|
25032
|
-
this.pluginSystem = pluginSystem;
|
|
25033
|
-
this.totalTime = totalTime != null ? totalTime : 0;
|
|
25034
|
-
this.imgUsage = imgUsage != null ? imgUsage : {};
|
|
25035
|
-
this.textures = cachedTextures;
|
|
25036
|
-
listOrder = 0;
|
|
25037
|
-
this.sourceContent = this.getContent(this.composition);
|
|
25038
|
-
}
|
|
25039
|
-
var _proto = CompositionSourceManager.prototype;
|
|
25040
|
-
_proto.getContent = function getContent(composition) {
|
|
25041
|
-
// TODO: specification 中补充 globalVolume 类型
|
|
25042
|
-
// @ts-expect-error
|
|
25043
|
-
var id = composition.id, duration = composition.duration, name = composition.name, endBehavior = composition.endBehavior, camera = composition.camera, globalVolume = composition.globalVolume, _composition_startTime = composition.startTime, startTime = _composition_startTime === void 0 ? 0 : _composition_startTime, timelineAsset = composition.timelineAsset;
|
|
25044
|
-
var items = this.assembleItems(composition);
|
|
25045
|
-
//@ts-expect-error
|
|
25046
|
-
if (!composition.sceneBindings) {
|
|
25047
|
-
//@ts-expect-error
|
|
25048
|
-
composition.sceneBindings = [];
|
|
25049
|
-
}
|
|
25050
|
-
return {
|
|
25051
|
-
id: id,
|
|
25052
|
-
duration: duration,
|
|
25053
|
-
name: name,
|
|
25054
|
-
endBehavior: isNaN(endBehavior) ? END_BEHAVIOR_PAUSE : endBehavior,
|
|
25055
|
-
// looping,
|
|
25056
|
-
items: items,
|
|
25057
|
-
camera: camera,
|
|
25058
|
-
startTime: startTime,
|
|
25059
|
-
globalVolume: globalVolume,
|
|
25060
|
-
timelineAsset: timelineAsset,
|
|
25061
|
-
//@ts-expect-error
|
|
25062
|
-
sceneBindings: composition.sceneBindings
|
|
25063
|
-
};
|
|
25064
|
-
};
|
|
25065
|
-
_proto.assembleItems = function assembleItems(composition) {
|
|
25066
|
-
var _this = this;
|
|
25067
|
-
var items = [];
|
|
25068
|
-
this.mask++;
|
|
25069
|
-
var componentMap = {};
|
|
25070
|
-
//@ts-expect-error
|
|
25071
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.jsonScene.components), _step; !(_step = _iterator()).done;){
|
|
25072
|
-
var component = _step.value;
|
|
25073
|
-
componentMap[component.id] = component;
|
|
25074
|
-
}
|
|
25075
|
-
for(var _iterator1 = _create_for_of_iterator_helper_loose(composition.items), _step1; !(_step1 = _iterator1()).done;){
|
|
25076
|
-
var itemDataPath = _step1.value;
|
|
25077
|
-
//@ts-expect-error
|
|
25078
|
-
var sourceItemData = this.engine.jsonSceneData[itemDataPath.id];
|
|
25079
|
-
var itemProps = sourceItemData;
|
|
25080
|
-
if (passRenderLevel(sourceItemData.renderLevel, this.renderLevel)) {
|
|
25081
|
-
if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle) {
|
|
25082
|
-
for(var _iterator2 = _create_for_of_iterator_helper_loose(itemProps.components), _step2; !(_step2 = _iterator2()).done;){
|
|
25083
|
-
var componentPath = _step2.value;
|
|
25084
|
-
var componentData = componentMap[componentPath.id];
|
|
25085
|
-
this.preProcessItemContent(componentData);
|
|
25086
|
-
}
|
|
25087
|
-
} else {
|
|
25088
|
-
var renderContent = itemProps.content;
|
|
25089
|
-
if (renderContent) {
|
|
25090
|
-
this.preProcessItemContent(renderContent);
|
|
25091
|
-
}
|
|
25092
|
-
}
|
|
25093
|
-
itemProps.listIndex = listOrder++;
|
|
25094
|
-
// 处理预合成的渲染顺序
|
|
25095
|
-
if (itemProps.type === ItemType.composition) {
|
|
25096
|
-
var refId = sourceItemData.content.options.refId;
|
|
25097
|
-
if (!this.refCompositions.get(refId)) {
|
|
25098
|
-
throw new Error("Invalid Ref Composition id: " + refId);
|
|
25099
|
-
}
|
|
25100
|
-
var ref = this.getContent(this.refCompositions.get(refId));
|
|
25101
|
-
if (!this.refCompositionProps.has(refId)) {
|
|
25102
|
-
this.refCompositionProps.set(refId, ref);
|
|
25103
|
-
}
|
|
25104
|
-
ref.items.forEach(function(item) {
|
|
25105
|
-
_this.processMask(item.content);
|
|
25106
|
-
});
|
|
25107
|
-
itemProps.items = ref.items;
|
|
25108
|
-
}
|
|
25109
|
-
items.push(itemProps);
|
|
25110
|
-
}
|
|
25111
|
-
}
|
|
25112
|
-
return items;
|
|
25113
|
-
};
|
|
25114
|
-
_proto.preProcessItemContent = function preProcessItemContent(renderContent) {
|
|
25115
|
-
if (renderContent.renderer) {
|
|
25116
|
-
renderContent.renderer = this.changeTex(renderContent.renderer);
|
|
25117
|
-
if (!renderContent.renderer.mask) {
|
|
25118
|
-
this.processMask(renderContent.renderer);
|
|
25119
|
-
}
|
|
25120
|
-
var split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
|
|
25121
|
-
if (Number.isInteger(renderContent.renderer.shape)) {
|
|
25122
|
-
var _this_jsonScene;
|
|
25123
|
-
// TODO: scene.shapes 类型问题?
|
|
25124
|
-
renderContent.renderer.shape = getGeometryByShape((_this_jsonScene = this.jsonScene) == null ? void 0 : _this_jsonScene.shapes[renderContent.renderer.shape], split);
|
|
25125
|
-
} else if (renderContent.renderer.shape && isObject(renderContent.renderer.shape)) {
|
|
25126
|
-
renderContent.renderer.shape = getGeometryByShape(renderContent.renderer.shape, split);
|
|
25127
|
-
}
|
|
25128
|
-
}
|
|
25129
|
-
if (renderContent.trails) {
|
|
25130
|
-
renderContent.trails = this.changeTex(renderContent.trails);
|
|
25131
|
-
}
|
|
25132
|
-
};
|
|
25133
|
-
_proto.changeTex = function changeTex(renderer) {
|
|
25134
|
-
if (!renderer.texture) {
|
|
25135
|
-
return renderer;
|
|
25136
|
-
}
|
|
25137
|
-
//@ts-expect-error
|
|
25138
|
-
var texIdx = renderer.texture.id;
|
|
25139
|
-
if (texIdx !== undefined) {
|
|
25140
|
-
//@ts-expect-error
|
|
25141
|
-
this.addTextureUsage(texIdx) || texIdx;
|
|
25142
|
-
}
|
|
25143
|
-
return renderer;
|
|
25144
|
-
};
|
|
25145
|
-
_proto.addTextureUsage = function addTextureUsage(texIdx) {
|
|
25146
|
-
var texId = texIdx;
|
|
25147
|
-
var _this_imgUsage;
|
|
25148
|
-
// FIXME: imageUsage 取自 scene.imgUsage,类型为 Record<string, number[]>,这里给的 number,类型对不上
|
|
25149
|
-
var imageUsage = (_this_imgUsage = this.imgUsage) != null ? _this_imgUsage : {};
|
|
25150
|
-
if (texId && imageUsage) {
|
|
25151
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
25152
|
-
if (!imageUsage.hasOwnProperty(texId)) {
|
|
25153
|
-
imageUsage[texId] = 0;
|
|
25154
|
-
}
|
|
25155
|
-
imageUsage[texId]++;
|
|
25156
|
-
}
|
|
25157
|
-
};
|
|
25158
|
-
/**
|
|
25159
|
-
* 处理蒙版和遮挡关系写入 stencil 的 ref 值
|
|
25160
|
-
*/ _proto.processMask = function processMask(renderer) {
|
|
25161
|
-
var maskMode = renderer.maskMode;
|
|
25162
|
-
if (maskMode === MaskMode.NONE) {
|
|
25163
|
-
return;
|
|
25164
|
-
}
|
|
25165
|
-
if (!renderer.mask) {
|
|
25166
|
-
if (maskMode === MaskMode.MASK) {
|
|
25167
|
-
renderer.mask = ++this.mask;
|
|
25168
|
-
} else if (maskMode === MaskMode.OBSCURED || maskMode === MaskMode.REVERSE_OBSCURED) {
|
|
25169
|
-
renderer.mask = this.mask;
|
|
25170
|
-
}
|
|
25171
|
-
}
|
|
25172
|
-
};
|
|
25173
|
-
_proto.dispose = function dispose() {
|
|
25174
|
-
this.textures = [];
|
|
25175
|
-
this.composition = undefined;
|
|
25176
|
-
this.jsonScene = undefined;
|
|
25177
|
-
this.totalTime = 0;
|
|
25178
|
-
this.pluginSystem = undefined;
|
|
25179
|
-
this.sourceContent = undefined;
|
|
25180
|
-
this.refCompositions.clear();
|
|
25181
|
-
this.refCompositionProps.clear();
|
|
25182
|
-
};
|
|
25183
|
-
return CompositionSourceManager;
|
|
25184
|
-
}();
|
|
25185
|
-
|
|
25186
25217
|
/**
|
|
25187
25218
|
* Engine 基类,负责维护所有 GPU 资源的管理及销毁
|
|
25188
25219
|
*/ var Engine = /*#__PURE__*/ function() {
|
|
@@ -25223,61 +25254,46 @@ var listOrder = 0;
|
|
|
25223
25254
|
delete this.objectInstance[id];
|
|
25224
25255
|
};
|
|
25225
25256
|
_proto.addPackageDatas = function addPackageDatas(scene) {
|
|
25226
|
-
var jsonScene = scene.jsonScene;
|
|
25227
|
-
|
|
25228
|
-
|
|
25229
|
-
|
|
25230
|
-
|
|
25231
|
-
|
|
25232
|
-
|
|
25233
|
-
|
|
25234
|
-
|
|
25235
|
-
|
|
25236
|
-
|
|
25237
|
-
|
|
25238
|
-
|
|
25239
|
-
|
|
25240
|
-
|
|
25241
|
-
|
|
25242
|
-
|
|
25243
|
-
|
|
25244
|
-
|
|
25245
|
-
|
|
25246
|
-
|
|
25247
|
-
|
|
25248
|
-
|
|
25249
|
-
|
|
25250
|
-
|
|
25251
|
-
|
|
25252
|
-
|
|
25253
|
-
|
|
25254
|
-
|
|
25255
|
-
|
|
25256
|
-
|
|
25257
|
-
|
|
25258
|
-
|
|
25259
|
-
var animationData = _step5.value;
|
|
25260
|
-
this.addEffectsObjectData(animationData);
|
|
25261
|
-
}
|
|
25262
|
-
}
|
|
25263
|
-
if (jsonScene.bins) {
|
|
25264
|
-
for(var i = 0; i < jsonScene.bins.length; i++){
|
|
25265
|
-
var binaryData = jsonScene.bins[i];
|
|
25266
|
-
var binaryBuffer = scene.bins[i];
|
|
25267
|
-
//@ts-expect-error
|
|
25268
|
-
binaryData.buffer = binaryBuffer;
|
|
25257
|
+
var jsonScene = scene.jsonScene, _scene_textureOptions = scene.textureOptions, textureOptions = _scene_textureOptions === void 0 ? [] : _scene_textureOptions;
|
|
25258
|
+
var _jsonScene_items = jsonScene.items, items = _jsonScene_items === void 0 ? [] : _jsonScene_items, _jsonScene_materials = jsonScene.materials, materials = _jsonScene_materials === void 0 ? [] : _jsonScene_materials, _jsonScene_shaders = jsonScene.shaders, shaders = _jsonScene_shaders === void 0 ? [] : _jsonScene_shaders, _jsonScene_geometries = jsonScene.geometries, geometries = _jsonScene_geometries === void 0 ? [] : _jsonScene_geometries, _jsonScene_components = jsonScene.components, components = _jsonScene_components === void 0 ? [] : _jsonScene_components, _jsonScene_animations = jsonScene.animations, animations = _jsonScene_animations === void 0 ? [] : _jsonScene_animations, _jsonScene_bins = jsonScene.bins, bins = _jsonScene_bins === void 0 ? [] : _jsonScene_bins;
|
|
25259
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
|
|
25260
|
+
var vfxItemData = _step.value;
|
|
25261
|
+
this.addEffectsObjectData(vfxItemData);
|
|
25262
|
+
}
|
|
25263
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(materials), _step1; !(_step1 = _iterator1()).done;){
|
|
25264
|
+
var materialData = _step1.value;
|
|
25265
|
+
this.addEffectsObjectData(materialData);
|
|
25266
|
+
}
|
|
25267
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(shaders), _step2; !(_step2 = _iterator2()).done;){
|
|
25268
|
+
var shaderData = _step2.value;
|
|
25269
|
+
this.addEffectsObjectData(shaderData);
|
|
25270
|
+
}
|
|
25271
|
+
for(var _iterator3 = _create_for_of_iterator_helper_loose(geometries), _step3; !(_step3 = _iterator3()).done;){
|
|
25272
|
+
var geometryData = _step3.value;
|
|
25273
|
+
this.addEffectsObjectData(geometryData);
|
|
25274
|
+
}
|
|
25275
|
+
for(var _iterator4 = _create_for_of_iterator_helper_loose(components), _step4; !(_step4 = _iterator4()).done;){
|
|
25276
|
+
var componentData = _step4.value;
|
|
25277
|
+
this.addEffectsObjectData(componentData);
|
|
25278
|
+
}
|
|
25279
|
+
for(var _iterator5 = _create_for_of_iterator_helper_loose(animations), _step5; !(_step5 = _iterator5()).done;){
|
|
25280
|
+
var animationData = _step5.value;
|
|
25281
|
+
this.addEffectsObjectData(animationData);
|
|
25282
|
+
}
|
|
25283
|
+
for(var i = 0; i < bins.length; i++){
|
|
25284
|
+
var binaryData = bins[i];
|
|
25285
|
+
var binaryBuffer = scene.bins[i];
|
|
25286
|
+
//@ts-expect-error
|
|
25287
|
+
binaryData.buffer = binaryBuffer;
|
|
25288
|
+
//@ts-expect-error
|
|
25289
|
+
if (binaryData.id) {
|
|
25269
25290
|
//@ts-expect-error
|
|
25270
|
-
|
|
25271
|
-
//@ts-expect-error
|
|
25272
|
-
this.addEffectsObjectData(binaryData);
|
|
25273
|
-
}
|
|
25291
|
+
this.addEffectsObjectData(binaryData);
|
|
25274
25292
|
}
|
|
25275
25293
|
}
|
|
25276
|
-
|
|
25277
|
-
|
|
25278
|
-
|
|
25279
|
-
this.addEffectsObjectData(textureData);
|
|
25280
|
-
}
|
|
25294
|
+
for(var _iterator6 = _create_for_of_iterator_helper_loose(textureOptions), _step6; !(_step6 = _iterator6()).done;){
|
|
25295
|
+
var textureData = _step6.value;
|
|
25296
|
+
this.addEffectsObjectData(textureData);
|
|
25281
25297
|
}
|
|
25282
25298
|
};
|
|
25283
25299
|
_proto.createVFXItems = function createVFXItems(scene) {
|
|
@@ -25297,9 +25313,7 @@ var listOrder = 0;
|
|
|
25297
25313
|
];
|
|
25298
25314
|
itemData = _step.value;
|
|
25299
25315
|
itemType = itemData.type;
|
|
25300
|
-
if (
|
|
25301
|
-
(itemType === "ECS" || // @ts-expect-error
|
|
25302
|
-
itemType === "camera" || itemType === ItemType.sprite || itemType === ItemType.particle || itemType === ItemType.mesh || itemType === ItemType.skybox || itemType === ItemType.light || itemType === ItemType.tree || itemType === ItemType.interact || itemType === ItemType.camera)) {
|
|
25316
|
+
if (!(itemType === "ECS" || itemType === "camera" || itemType === ItemType.sprite || itemType === ItemType.particle || itemType === ItemType.mesh || itemType === ItemType.skybox || itemType === ItemType.light || itemType === ItemType.tree || itemType === ItemType.interact || itemType === ItemType.camera)) {
|
|
25303
25317
|
return [
|
|
25304
25318
|
3,
|
|
25305
25319
|
3
|
|
@@ -25416,19 +25430,19 @@ var listOrder = 0;
|
|
|
25416
25430
|
logger.warn("Release GPU memory: " + info.join(", "));
|
|
25417
25431
|
}
|
|
25418
25432
|
this.renderPasses.forEach(function(pass) {
|
|
25419
|
-
pass.dispose();
|
|
25433
|
+
return pass.dispose();
|
|
25420
25434
|
});
|
|
25421
25435
|
this.meshes.forEach(function(mesh) {
|
|
25422
|
-
mesh.dispose();
|
|
25436
|
+
return mesh.dispose();
|
|
25423
25437
|
});
|
|
25424
25438
|
this.geometries.forEach(function(geo) {
|
|
25425
|
-
geo.dispose();
|
|
25439
|
+
return geo.dispose();
|
|
25426
25440
|
});
|
|
25427
25441
|
this.materials.forEach(function(mat) {
|
|
25428
|
-
mat.dispose();
|
|
25442
|
+
return mat.dispose();
|
|
25429
25443
|
});
|
|
25430
25444
|
this.textures.forEach(function(tex) {
|
|
25431
|
-
tex.dispose();
|
|
25445
|
+
return tex.dispose();
|
|
25432
25446
|
});
|
|
25433
25447
|
this.textures = [];
|
|
25434
25448
|
this.materials = [];
|
|
@@ -26741,11 +26755,8 @@ var seed = 1;
|
|
|
26741
26755
|
* composition 抽象类的实现
|
|
26742
26756
|
*/ var ThreeComposition = /*#__PURE__*/ function(Composition) {
|
|
26743
26757
|
_inherits(ThreeComposition, Composition);
|
|
26744
|
-
function ThreeComposition(props, scene
|
|
26745
|
-
|
|
26746
|
-
_this = Composition.call(this, props, scene, compositionSourceManager) || this;
|
|
26747
|
-
_this.rootItem.getComponent(CompositionComponent).resetStatus();
|
|
26748
|
-
return _this;
|
|
26758
|
+
function ThreeComposition(props, scene) {
|
|
26759
|
+
return Composition.call(this, props, scene);
|
|
26749
26760
|
}
|
|
26750
26761
|
var _proto = ThreeComposition.prototype;
|
|
26751
26762
|
/**
|
|
@@ -26937,7 +26948,7 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
26937
26948
|
if (options === void 0) options = {};
|
|
26938
26949
|
var _this = this;
|
|
26939
26950
|
return _async_to_generator(function() {
|
|
26940
|
-
var last, opts, source, scene, engine, i,
|
|
26951
|
+
var last, opts, source, scene, engine, i, composition, firstFrameTime;
|
|
26941
26952
|
return __generator(this, function(_state) {
|
|
26942
26953
|
switch(_state.label){
|
|
26943
26954
|
case 0:
|
|
@@ -26974,7 +26985,6 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
26974
26985
|
scene.textureOptions[i] = engine.assetLoader.loadGUID(scene.textureOptions[i].id);
|
|
26975
26986
|
scene.textureOptions[i].initialize();
|
|
26976
26987
|
}
|
|
26977
|
-
compositionSourceManager = new CompositionSourceManager(scene, engine);
|
|
26978
26988
|
if (!engine.database) return [
|
|
26979
26989
|
3,
|
|
26980
26990
|
3
|
|
@@ -26991,7 +27001,7 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
26991
27001
|
width: _this.width,
|
|
26992
27002
|
height: _this.height,
|
|
26993
27003
|
renderer: _this.renderer
|
|
26994
|
-
}), scene
|
|
27004
|
+
}), scene);
|
|
26995
27005
|
_this.renderer.engine.setOptions({
|
|
26996
27006
|
threeCamera: _this.camera,
|
|
26997
27007
|
threeGroup: _this,
|
|
@@ -27170,7 +27180,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
27170
27180
|
*/ Mesh.create = function(engine, props) {
|
|
27171
27181
|
return new ThreeMesh(engine, props);
|
|
27172
27182
|
};
|
|
27173
|
-
var version = "2.0.0-alpha.
|
|
27183
|
+
var version = "2.0.0-alpha.16";
|
|
27174
27184
|
logger.info("THREEJS plugin version: " + version);
|
|
27175
27185
|
|
|
27176
27186
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -27282,6 +27292,7 @@ exports.addItem = addItem;
|
|
|
27282
27292
|
exports.addItemWithOrder = addItemWithOrder;
|
|
27283
27293
|
exports.assertExist = assertExist;
|
|
27284
27294
|
exports.asserts = asserts;
|
|
27295
|
+
exports.base64ToFile = base64ToFile;
|
|
27285
27296
|
exports.blend = blend;
|
|
27286
27297
|
exports.calculateTranslation = calculateTranslation;
|
|
27287
27298
|
exports.canvasPool = canvasPool;
|
|
@@ -27350,6 +27361,7 @@ exports.interpolateColor = interpolateColor;
|
|
|
27350
27361
|
exports.isAlipayMiniApp = isAlipayMiniApp;
|
|
27351
27362
|
exports.isAndroid = isAndroid;
|
|
27352
27363
|
exports.isArray = isArray;
|
|
27364
|
+
exports.isCanvas = isCanvas;
|
|
27353
27365
|
exports.isFunction = isFunction;
|
|
27354
27366
|
exports.isIOS = isIOS;
|
|
27355
27367
|
exports.isObject = isObject;
|