@galacean/effects-core 2.0.0-alpha.0 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/asset-loader.d.ts +13 -4
- package/dist/asset-manager.d.ts +8 -5
- package/dist/asset-migrations.d.ts +5 -0
- package/dist/components/effect-component.d.ts +1 -1
- package/dist/composition.d.ts +4 -4
- package/dist/index.js +1311 -1235
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1312 -1235
- package/dist/index.mjs.map +1 -1
- package/dist/math/utils.d.ts +0 -5
- package/dist/plugins/cal/calculate-item.d.ts +1 -1
- package/dist/scene.d.ts +2 -2
- package/dist/serialization-helper.d.ts +1 -0
- package/dist/ticker.d.ts +5 -0
- package/dist/transform.d.ts +3 -3
- package/dist/vfx-item.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.2
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -8197,7 +8197,7 @@ function loadMipmapImage(pointer, bins) {
|
|
|
8197
8197
|
});
|
|
8198
8198
|
}
|
|
8199
8199
|
|
|
8200
|
-
var seed$
|
|
8200
|
+
var seed$9 = 1;
|
|
8201
8201
|
/**
|
|
8202
8202
|
* Texture 抽象类
|
|
8203
8203
|
*/
|
|
@@ -8206,7 +8206,7 @@ var Texture = /** @class */ (function (_super) {
|
|
|
8206
8206
|
function Texture(engine) {
|
|
8207
8207
|
var _this = _super.call(this, engine) || this;
|
|
8208
8208
|
_this.destroyed = false;
|
|
8209
|
-
_this.id = 'Tex' + seed$
|
|
8209
|
+
_this.id = 'Tex' + seed$9++;
|
|
8210
8210
|
return _this;
|
|
8211
8211
|
}
|
|
8212
8212
|
Object.defineProperty(Texture.prototype, "isDestroyed", {
|
|
@@ -8608,7 +8608,7 @@ exports.MaterialRenderType = void 0;
|
|
|
8608
8608
|
* 用于设置材质默认名称的自增序号
|
|
8609
8609
|
* @internal
|
|
8610
8610
|
*/
|
|
8611
|
-
var seed$
|
|
8611
|
+
var seed$8 = 1;
|
|
8612
8612
|
/**
|
|
8613
8613
|
* Material 抽象类
|
|
8614
8614
|
*/
|
|
@@ -8623,7 +8623,7 @@ var Material = /** @class */ (function (_super) {
|
|
|
8623
8623
|
_this.destroyed = false;
|
|
8624
8624
|
_this.initialized = false;
|
|
8625
8625
|
if (props) {
|
|
8626
|
-
var _a = props.name, name_1 = _a === void 0 ? 'Material' + seed$
|
|
8626
|
+
var _a = props.name, name_1 = _a === void 0 ? 'Material' + seed$8++ : _a, _b = props.renderType, renderType = _b === void 0 ? exports.MaterialRenderType.normal : _b, shader = props.shader, uniformSemantics = props.uniformSemantics;
|
|
8627
8627
|
_this.name = name_1;
|
|
8628
8628
|
_this.renderType = renderType; // TODO 没有地方用到
|
|
8629
8629
|
_this.shaderSource = shader;
|
|
@@ -8631,7 +8631,7 @@ var Material = /** @class */ (function (_super) {
|
|
|
8631
8631
|
_this.uniformSemantics = __assign$1({}, uniformSemantics); // TODO 废弃,待移除
|
|
8632
8632
|
}
|
|
8633
8633
|
else {
|
|
8634
|
-
_this.name = 'Material' + seed$
|
|
8634
|
+
_this.name = 'Material' + seed$8++;
|
|
8635
8635
|
_this.renderType = exports.MaterialRenderType.normal;
|
|
8636
8636
|
}
|
|
8637
8637
|
return _this;
|
|
@@ -9056,7 +9056,7 @@ function generateEmptyTypedArray(type) {
|
|
|
9056
9056
|
return new Float32Array(0);
|
|
9057
9057
|
}
|
|
9058
9058
|
|
|
9059
|
-
var seed$
|
|
9059
|
+
var seed$7 = 1;
|
|
9060
9060
|
/**
|
|
9061
9061
|
* Mesh 抽象类
|
|
9062
9062
|
*/
|
|
@@ -9068,7 +9068,7 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
9068
9068
|
_this.visible = true;
|
|
9069
9069
|
if (props) {
|
|
9070
9070
|
var material = props.material, geometry = props.geometry, _a = props.name, name_1 = _a === void 0 ? '<unnamed>' : _a, _b = props.priority, priority = _b === void 0 ? 0 : _b, _c = props.worldMatrix, worldMatrix = _c === void 0 ? Matrix4.fromIdentity() : _c;
|
|
9071
|
-
_this.id = 'Mesh' + seed$
|
|
9071
|
+
_this.id = 'Mesh' + seed$7++;
|
|
9072
9072
|
_this.name = name_1;
|
|
9073
9073
|
_this.geometry = geometry;
|
|
9074
9074
|
_this.material = material;
|
|
@@ -9076,7 +9076,7 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
9076
9076
|
_this.worldMatrix = worldMatrix;
|
|
9077
9077
|
}
|
|
9078
9078
|
else {
|
|
9079
|
-
_this.id = 'Mesh' + seed$
|
|
9079
|
+
_this.id = 'Mesh' + seed$7++;
|
|
9080
9080
|
_this.name = '<unnamed>';
|
|
9081
9081
|
_this.worldMatrix = Matrix4.fromIdentity();
|
|
9082
9082
|
_this._priority = 0;
|
|
@@ -9296,7 +9296,7 @@ exports.RenderPassDestroyAttachmentType = void 0;
|
|
|
9296
9296
|
*/
|
|
9297
9297
|
RenderPassDestroyAttachmentType[RenderPassDestroyAttachmentType["destroy"] = 0] = "destroy";
|
|
9298
9298
|
})(exports.RenderPassDestroyAttachmentType || (exports.RenderPassDestroyAttachmentType = {}));
|
|
9299
|
-
var seed$
|
|
9299
|
+
var seed$6 = 1;
|
|
9300
9300
|
/**
|
|
9301
9301
|
* RenderPass 抽象类
|
|
9302
9302
|
*/
|
|
@@ -9308,7 +9308,7 @@ var RenderPass = /** @class */ (function () {
|
|
|
9308
9308
|
this.attachments = [];
|
|
9309
9309
|
this.destroyed = false;
|
|
9310
9310
|
this.initialized = false;
|
|
9311
|
-
var _a = options.name, name = _a === void 0 ? 'RenderPass_' + seed$
|
|
9311
|
+
var _a = options.name, name = _a === void 0 ? 'RenderPass_' + seed$6++ : _a, clearAction = options.clearAction, semantics = options.semantics, depthStencilAttachment = options.depthStencilAttachment, storeAction = options.storeAction, _b = options.priority, priority = _b === void 0 ? 0 : _b, _c = options.meshOrder, meshOrder = _c === void 0 ? exports.OrderType.ascending : _c, _d = options.meshes, meshes = _d === void 0 ? [] : _d, _e = options.delegate, delegate = _e === void 0 ? {} : _e;
|
|
9312
9312
|
this.name = name;
|
|
9313
9313
|
this.renderer = renderer;
|
|
9314
9314
|
this.priority = priority;
|
|
@@ -9925,7 +9925,7 @@ var defaultGlobalVolume = {
|
|
|
9925
9925
|
};
|
|
9926
9926
|
|
|
9927
9927
|
var RENDER_PASS_NAME_PREFIX = '_effects_default_';
|
|
9928
|
-
var seed$
|
|
9928
|
+
var seed$5 = 1;
|
|
9929
9929
|
/**
|
|
9930
9930
|
* RenderFrame 抽象类
|
|
9931
9931
|
*/
|
|
@@ -10060,7 +10060,7 @@ var RenderFrame = /** @class */ (function () {
|
|
|
10060
10060
|
}
|
|
10061
10061
|
this.semantics = new SemanticMap(options.semantics);
|
|
10062
10062
|
this.clearAction = clearAction;
|
|
10063
|
-
this.name = "RenderFrame".concat(seed$
|
|
10063
|
+
this.name = "RenderFrame".concat(seed$5++);
|
|
10064
10064
|
var firstRP = renderPasses[0];
|
|
10065
10065
|
var sourceOpts = {
|
|
10066
10066
|
type: glContext.UNSIGNED_BYTE,
|
|
@@ -11283,6 +11283,12 @@ var SerializationHelper = /** @class */ (function () {
|
|
|
11283
11283
|
value.id &&
|
|
11284
11284
|
value.id.length === 32;
|
|
11285
11285
|
};
|
|
11286
|
+
// TODO 测试函数,2.0 上线后移除
|
|
11287
|
+
SerializationHelper.checkGLTFNode = function (value) {
|
|
11288
|
+
return value instanceof Object &&
|
|
11289
|
+
value.nodeIndex !== undefined &&
|
|
11290
|
+
value.isJoint !== undefined;
|
|
11291
|
+
};
|
|
11286
11292
|
SerializationHelper.deserializeProperty = function (property, engine, level) {
|
|
11287
11293
|
var e_11, _a, e_12, _b;
|
|
11288
11294
|
if (level > 10) {
|
|
@@ -11315,7 +11321,9 @@ var SerializationHelper = /** @class */ (function () {
|
|
|
11315
11321
|
else if (SerializationHelper.checkDataPath(property)) {
|
|
11316
11322
|
return engine.assetLoader.loadGUID(property.id);
|
|
11317
11323
|
}
|
|
11318
|
-
else if (property instanceof EffectsObject ||
|
|
11324
|
+
else if (property instanceof EffectsObject ||
|
|
11325
|
+
SerializationHelper.checkTypedArray(property) ||
|
|
11326
|
+
SerializationHelper.checkGLTFNode(property)) {
|
|
11319
11327
|
return property;
|
|
11320
11328
|
}
|
|
11321
11329
|
else if (property instanceof Object) {
|
|
@@ -11390,7 +11398,9 @@ var SerializationHelper = /** @class */ (function () {
|
|
|
11390
11398
|
res = _j.sent();
|
|
11391
11399
|
return [2 /*return*/, res];
|
|
11392
11400
|
case 12:
|
|
11393
|
-
if (!(property instanceof EffectsObject ||
|
|
11401
|
+
if (!(property instanceof EffectsObject ||
|
|
11402
|
+
SerializationHelper.checkTypedArray(property) ||
|
|
11403
|
+
SerializationHelper.checkGLTFNode(property))) return [3 /*break*/, 13];
|
|
11394
11404
|
return [2 /*return*/, property];
|
|
11395
11405
|
case 13:
|
|
11396
11406
|
if (!(property instanceof Object)) return [3 /*break*/, 22];
|
|
@@ -11878,20 +11888,6 @@ var particleOriginTranslateMap = (_a$3 = {},
|
|
|
11878
11888
|
_a$3[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
|
|
11879
11889
|
_a$3[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
|
|
11880
11890
|
_a$3);
|
|
11881
|
-
/**
|
|
11882
|
-
* 提取并转换 JSON 数据中的 anchor 值
|
|
11883
|
-
*/
|
|
11884
|
-
function convertAnchor(anchor, particleOrigin) {
|
|
11885
|
-
if (anchor) {
|
|
11886
|
-
return [anchor[0] - 0.5, 0.5 - anchor[1]];
|
|
11887
|
-
}
|
|
11888
|
-
else if (particleOrigin) {
|
|
11889
|
-
return particleOriginTranslateMap[particleOrigin];
|
|
11890
|
-
}
|
|
11891
|
-
else {
|
|
11892
|
-
return [0, 0];
|
|
11893
|
-
}
|
|
11894
|
-
}
|
|
11895
11891
|
function nearestPowerOfTwo(value) {
|
|
11896
11892
|
return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
|
|
11897
11893
|
}
|
|
@@ -12587,7 +12583,7 @@ function createKeyFrameMeta() {
|
|
|
12587
12583
|
}
|
|
12588
12584
|
|
|
12589
12585
|
var tempQuat$1 = new Quaternion();
|
|
12590
|
-
var seed$
|
|
12586
|
+
var seed$4 = 1;
|
|
12591
12587
|
// TODO 继承 Component
|
|
12592
12588
|
var Transform = /** @class */ (function () {
|
|
12593
12589
|
function Transform(props, parent) {
|
|
@@ -12650,7 +12646,7 @@ var Transform = /** @class */ (function () {
|
|
|
12650
12646
|
* 最终模型矩阵对应变换的缓存,当自身矩阵或父矩阵有修改时需要更新
|
|
12651
12647
|
*/
|
|
12652
12648
|
this.worldTRSCache = { position: new Vector3(0, 0, 0), quat: new Quaternion(0, 0, 0, 1), scale: new Vector3(1, 1, 1) };
|
|
12653
|
-
this.name = "transform_".concat(seed$
|
|
12649
|
+
this.name = "transform_".concat(seed$4++);
|
|
12654
12650
|
if (props) {
|
|
12655
12651
|
this.setTransform(props);
|
|
12656
12652
|
}
|
|
@@ -12830,13 +12826,11 @@ var Transform = /** @class */ (function () {
|
|
|
12830
12826
|
* 设置锚点
|
|
12831
12827
|
* @param x
|
|
12832
12828
|
* @param y
|
|
12833
|
-
* @param z
|
|
12834
12829
|
*/
|
|
12835
|
-
Transform.prototype.setAnchor = function (x, y
|
|
12836
|
-
if (this.anchor.x !== x || this.anchor.y !== y
|
|
12830
|
+
Transform.prototype.setAnchor = function (x, y) {
|
|
12831
|
+
if (this.anchor.x !== x || this.anchor.y !== y) {
|
|
12837
12832
|
this.anchor.x = x;
|
|
12838
12833
|
this.anchor.y = y;
|
|
12839
|
-
this.anchor.z = z;
|
|
12840
12834
|
this.dirtyFlags.localData = true;
|
|
12841
12835
|
this.dispatchValueChange();
|
|
12842
12836
|
}
|
|
@@ -12847,8 +12841,7 @@ var Transform = /** @class */ (function () {
|
|
|
12847
12841
|
* @param reverseEuler - 设置 rotation时,欧拉角是否需要取负值
|
|
12848
12842
|
*/
|
|
12849
12843
|
Transform.prototype.setTransform = function (props, reverseEuler) {
|
|
12850
|
-
var
|
|
12851
|
-
var position = props.position, rotation = props.rotation, scale = props.scale, quat = props.quat, name = props.name, anchor = props.anchor;
|
|
12844
|
+
var position = props.position, rotation = props.rotation, scale = props.scale, size = props.size, quat = props.quat, name = props.name, anchor = props.anchor;
|
|
12852
12845
|
if (name) {
|
|
12853
12846
|
this.name = name;
|
|
12854
12847
|
}
|
|
@@ -12885,12 +12878,15 @@ var Transform = /** @class */ (function () {
|
|
|
12885
12878
|
this.setScale(scale[0], scale[1], scale[2]);
|
|
12886
12879
|
}
|
|
12887
12880
|
}
|
|
12881
|
+
if (size) {
|
|
12882
|
+
this.setSize(size.x, size.y);
|
|
12883
|
+
}
|
|
12888
12884
|
if (anchor) {
|
|
12889
|
-
if (anchor instanceof
|
|
12890
|
-
this.setAnchor(anchor.x, anchor.y
|
|
12885
|
+
if (anchor instanceof Vector2) {
|
|
12886
|
+
this.setAnchor(anchor.x, anchor.y);
|
|
12891
12887
|
}
|
|
12892
12888
|
else {
|
|
12893
|
-
this.setAnchor(anchor[0], anchor[1]
|
|
12889
|
+
this.setAnchor(anchor[0], anchor[1]);
|
|
12894
12890
|
}
|
|
12895
12891
|
}
|
|
12896
12892
|
};
|
|
@@ -13384,7 +13380,7 @@ var HELP_LINK = {
|
|
|
13384
13380
|
|
|
13385
13381
|
var vertex = "\nprecision highp float;\n\nattribute vec2 aPoint;\nuniform vec4 uPos;\nuniform vec2 uSize;\nuniform vec4 uQuat;\nuniform vec4 uColor;\nuniform mat4 effects_ObjectToWorld;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_MatrixVP;\nvarying vec4 vColor;\n#ifdef ENV_EDITOR\n uniform vec4 uEditorTransform;\n#endif\n\nvec3 rotateByQuat(vec3 a, vec4 quat){\n vec3 qvec = quat.xyz;\n vec3 uv = cross(qvec, a);\n vec3 uuv = cross(qvec, uv) * 2.;\n return a +(uv * 2. * quat.w + uuv);\n}\n\nvoid main() {\n vec4 _pos = uPos;\n vec3 point = rotateByQuat(vec3(aPoint.xy * uSize, 0.),uQuat);\n vec4 pos = vec4(_pos.xyz, 1.0);\n pos = effects_ObjectToWorld * pos;\n pos.xyz += effects_MatrixInvV[0].xyz * point.x+ effects_MatrixInvV[1].xyz * point.y;\n gl_Position = effects_MatrixVP * pos;\n vColor = uColor;\n #ifdef ENV_EDITOR\n gl_Position = vec4(gl_Position.xy * uEditorTransform.xy + uEditorTransform.zw * gl_Position.w, gl_Position.zw);\n #endif\n}\n";
|
|
13386
13382
|
var fragment = "\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor;\n}\n";
|
|
13387
|
-
var seed$
|
|
13383
|
+
var seed$3 = 1;
|
|
13388
13384
|
var InteractMesh = /** @class */ (function () {
|
|
13389
13385
|
function InteractMesh(props, rendererOptions, transform, engine) {
|
|
13390
13386
|
this.transform = transform;
|
|
@@ -13462,7 +13458,7 @@ var InteractMesh = /** @class */ (function () {
|
|
|
13462
13458
|
};
|
|
13463
13459
|
InteractMesh.prototype.createMesh = function (geometry, material) {
|
|
13464
13460
|
return Mesh.create(this.engine, {
|
|
13465
|
-
name: 'Interact_preview' + seed$
|
|
13461
|
+
name: 'Interact_preview' + seed$3++,
|
|
13466
13462
|
priority: 0,
|
|
13467
13463
|
worldMatrix: Matrix4.fromIdentity(),
|
|
13468
13464
|
geometry: geometry,
|
|
@@ -13947,783 +13943,1019 @@ var PlayableOutput = /** @class */ (function () {
|
|
|
13947
13943
|
* @since 2.0.0
|
|
13948
13944
|
* @internal
|
|
13949
13945
|
*/
|
|
13950
|
-
var
|
|
13951
|
-
|
|
13952
|
-
|
|
13953
|
-
|
|
13954
|
-
_this.reusable = false;
|
|
13955
|
-
_this.timelineStarted = false;
|
|
13956
|
-
_this.playableGraph = new PlayableGraph();
|
|
13957
|
-
/**
|
|
13958
|
-
* 元素动画已经播放的时间
|
|
13959
|
-
*/
|
|
13960
|
-
_this.time = 0;
|
|
13961
|
-
_this.tracks = [];
|
|
13962
|
-
_this.trackSeed = 0;
|
|
13963
|
-
return _this;
|
|
13946
|
+
var Track = /** @class */ (function () {
|
|
13947
|
+
function Track() {
|
|
13948
|
+
this.clips = [];
|
|
13949
|
+
this.clipSeed = 0;
|
|
13964
13950
|
}
|
|
13965
|
-
|
|
13966
|
-
var
|
|
13951
|
+
Track.prototype.createOutput = function () {
|
|
13952
|
+
var output = new PlayableOutput();
|
|
13953
|
+
return output;
|
|
13954
|
+
};
|
|
13955
|
+
/**
|
|
13956
|
+
* 重写该方法以创建自定义混合器
|
|
13957
|
+
*/
|
|
13958
|
+
Track.prototype.createMixerPlayable = function () {
|
|
13959
|
+
return new Playable();
|
|
13960
|
+
};
|
|
13961
|
+
Track.prototype.createPlayebleTree = function () {
|
|
13962
|
+
var e_1, _a;
|
|
13963
|
+
var defaultMixPlayable = this.createMixerPlayable();
|
|
13967
13964
|
try {
|
|
13968
|
-
|
|
13969
|
-
|
|
13970
|
-
|
|
13971
|
-
try {
|
|
13972
|
-
for (var _e = (e_2 = void 0, __values$1(track.getClips())), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
13973
|
-
var clip = _f.value;
|
|
13974
|
-
clip.start = this.item.start;
|
|
13975
|
-
clip.duration = this.item.duration;
|
|
13976
|
-
}
|
|
13977
|
-
}
|
|
13978
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
13979
|
-
finally {
|
|
13980
|
-
try {
|
|
13981
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
13982
|
-
}
|
|
13983
|
-
finally { if (e_2) throw e_2.error; }
|
|
13984
|
-
}
|
|
13965
|
+
for (var _b = __values$1(this.clips), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
13966
|
+
var clip = _c.value;
|
|
13967
|
+
defaultMixPlayable.connect(clip.playable);
|
|
13985
13968
|
}
|
|
13986
13969
|
}
|
|
13987
13970
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
13988
13971
|
finally {
|
|
13989
13972
|
try {
|
|
13990
|
-
if (
|
|
13973
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
13991
13974
|
}
|
|
13992
13975
|
finally { if (e_1) throw e_1.error; }
|
|
13993
13976
|
}
|
|
13994
|
-
|
|
13977
|
+
return defaultMixPlayable;
|
|
13995
13978
|
};
|
|
13996
|
-
|
|
13997
|
-
|
|
13998
|
-
|
|
13999
|
-
|
|
14000
|
-
|
|
14001
|
-
|
|
14002
|
-
|
|
14003
|
-
|
|
14004
|
-
|
|
14005
|
-
|
|
14006
|
-
|
|
14007
|
-
|
|
14008
|
-
|
|
14009
|
-
|
|
14010
|
-
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
finally {
|
|
14014
|
-
try {
|
|
14015
|
-
if (_m && !_m.done && (_b = _l.return)) _b.call(_l);
|
|
14016
|
-
}
|
|
14017
|
-
finally { if (e_4) throw e_4.error; }
|
|
14018
|
-
}
|
|
14019
|
-
}
|
|
14020
|
-
}
|
|
14021
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
14022
|
-
finally {
|
|
14023
|
-
try {
|
|
14024
|
-
if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
|
|
13979
|
+
Track.prototype.createClip = function (classConstructor, name) {
|
|
13980
|
+
var newClip = new TimelineClip();
|
|
13981
|
+
newClip.playable = new classConstructor();
|
|
13982
|
+
newClip.name = name ? name : 'TimelineClip' + newClip.id;
|
|
13983
|
+
this.addClip(newClip);
|
|
13984
|
+
return newClip;
|
|
13985
|
+
};
|
|
13986
|
+
Track.prototype.getClips = function () {
|
|
13987
|
+
return this.clips;
|
|
13988
|
+
};
|
|
13989
|
+
Track.prototype.findClip = function (name) {
|
|
13990
|
+
var e_2, _a;
|
|
13991
|
+
try {
|
|
13992
|
+
for (var _b = __values$1(this.clips), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
13993
|
+
var clip = _c.value;
|
|
13994
|
+
if (clip.name === name) {
|
|
13995
|
+
return clip;
|
|
14025
13996
|
}
|
|
14026
|
-
finally { if (e_3) throw e_3.error; }
|
|
14027
13997
|
}
|
|
14028
|
-
this.timelineStarted = true;
|
|
14029
13998
|
}
|
|
14030
|
-
|
|
14031
|
-
|
|
14032
|
-
if (this.item.delaying && now >= 0 && now <= this.item.duration) {
|
|
14033
|
-
this.item.delaying = false;
|
|
13999
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
14000
|
+
finally {
|
|
14034
14001
|
try {
|
|
14035
|
-
|
|
14036
|
-
var track = _p.value;
|
|
14037
|
-
try {
|
|
14038
|
-
for (var _q = (e_6 = void 0, __values$1(track.getClips())), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
14039
|
-
var clip = _r.value;
|
|
14040
|
-
clip.playable.onPlayablePlay();
|
|
14041
|
-
}
|
|
14042
|
-
}
|
|
14043
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
14044
|
-
finally {
|
|
14045
|
-
try {
|
|
14046
|
-
if (_r && !_r.done && (_d = _q.return)) _d.call(_q);
|
|
14047
|
-
}
|
|
14048
|
-
finally { if (e_6) throw e_6.error; }
|
|
14049
|
-
}
|
|
14050
|
-
}
|
|
14051
|
-
}
|
|
14052
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
14053
|
-
finally {
|
|
14054
|
-
try {
|
|
14055
|
-
if (_p && !_p.done && (_c = _o.return)) _c.call(_o);
|
|
14056
|
-
}
|
|
14057
|
-
finally { if (e_5) throw e_5.error; }
|
|
14002
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
14058
14003
|
}
|
|
14004
|
+
finally { if (e_2) throw e_2.error; }
|
|
14059
14005
|
}
|
|
14060
|
-
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14006
|
+
};
|
|
14007
|
+
Track.prototype.addClip = function (clip) {
|
|
14008
|
+
clip.playable.bindingItem = this.bindingItem;
|
|
14009
|
+
clip.id = (this.clipSeed++).toString();
|
|
14010
|
+
this.clips.push(clip);
|
|
14011
|
+
};
|
|
14012
|
+
return Track;
|
|
14013
|
+
}());
|
|
14014
|
+
/**
|
|
14015
|
+
* @since 2.0.0
|
|
14016
|
+
* @internal
|
|
14017
|
+
*/
|
|
14018
|
+
var TimelineClip = /** @class */ (function () {
|
|
14019
|
+
function TimelineClip() {
|
|
14020
|
+
this.start = 0;
|
|
14021
|
+
this.duration = 0;
|
|
14022
|
+
}
|
|
14023
|
+
return TimelineClip;
|
|
14024
|
+
}());
|
|
14025
|
+
|
|
14026
|
+
var AnimationStream = /** @class */ (function () {
|
|
14027
|
+
function AnimationStream(playable) {
|
|
14028
|
+
this.curveValues = {};
|
|
14029
|
+
this.playable = playable;
|
|
14030
|
+
}
|
|
14031
|
+
AnimationStream.prototype.setCurveValue = function (componentType, propertyName, value) {
|
|
14032
|
+
if (!this.findCurveValue(componentType, propertyName)) {
|
|
14033
|
+
this.curveValues[componentType + propertyName] = { componentType: componentType, propertyName: propertyName, value: value };
|
|
14064
14034
|
}
|
|
14065
14035
|
else {
|
|
14066
|
-
|
|
14036
|
+
this.curveValues[componentType + propertyName].value = value;
|
|
14067
14037
|
}
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
try {
|
|
14078
|
-
for (var _u = (e_8 = void 0, __values$1(track.getClips())), _v = _u.next(); !_v.done; _v = _u.next()) {
|
|
14079
|
-
var clip = _v.value;
|
|
14080
|
-
clip.playable.onPlayableDestroy();
|
|
14081
|
-
}
|
|
14082
|
-
}
|
|
14083
|
-
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
14084
|
-
finally {
|
|
14085
|
-
try {
|
|
14086
|
-
if (_v && !_v.done && (_f = _u.return)) _f.call(_u);
|
|
14087
|
-
}
|
|
14088
|
-
finally { if (e_8) throw e_8.error; }
|
|
14089
|
-
}
|
|
14090
|
-
}
|
|
14091
|
-
}
|
|
14092
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
14093
|
-
finally {
|
|
14094
|
-
try {
|
|
14095
|
-
if (_t && !_t.done && (_e = _s.return)) _e.call(_s);
|
|
14096
|
-
}
|
|
14097
|
-
finally { if (e_7) throw e_7.error; }
|
|
14098
|
-
}
|
|
14099
|
-
this.item.delaying = true;
|
|
14100
|
-
if (!this.item.reusable && !this.reusable) {
|
|
14101
|
-
this.item.dispose();
|
|
14102
|
-
return;
|
|
14103
|
-
}
|
|
14104
|
-
}
|
|
14105
|
-
}
|
|
14038
|
+
return this.curveValues[componentType + propertyName];
|
|
14039
|
+
};
|
|
14040
|
+
AnimationStream.prototype.findCurveValue = function (componentType, propertyName) {
|
|
14041
|
+
return this.curveValues[componentType + propertyName];
|
|
14042
|
+
};
|
|
14043
|
+
AnimationStream.prototype.getInputStream = function (index) {
|
|
14044
|
+
var inputPlayable = this.playable.getInput(index);
|
|
14045
|
+
if (inputPlayable instanceof AnimationPlayable) {
|
|
14046
|
+
return inputPlayable.animationStream;
|
|
14106
14047
|
}
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14048
|
+
};
|
|
14049
|
+
return AnimationStream;
|
|
14050
|
+
}());
|
|
14051
|
+
|
|
14052
|
+
var AnimationPlayable = /** @class */ (function (_super) {
|
|
14053
|
+
__extends(AnimationPlayable, _super);
|
|
14054
|
+
function AnimationPlayable() {
|
|
14055
|
+
var _this = _super.call(this) || this;
|
|
14056
|
+
_this.animationStream = new AnimationStream(_this);
|
|
14057
|
+
return _this;
|
|
14058
|
+
}
|
|
14059
|
+
return AnimationPlayable;
|
|
14060
|
+
}(Playable));
|
|
14061
|
+
|
|
14062
|
+
var tempRot$1 = new Euler();
|
|
14063
|
+
var tempSize$1 = new Vector3(1, 1, 1);
|
|
14064
|
+
var tempPos = new Vector3();
|
|
14065
|
+
/**
|
|
14066
|
+
* @since 2.0.0
|
|
14067
|
+
* @internal
|
|
14068
|
+
*/
|
|
14069
|
+
var AnimationClipPlayable = /** @class */ (function (_super) {
|
|
14070
|
+
__extends(AnimationClipPlayable, _super);
|
|
14071
|
+
function AnimationClipPlayable() {
|
|
14072
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
14073
|
+
}
|
|
14074
|
+
AnimationClipPlayable.prototype.processFrame = function (dt) {
|
|
14075
|
+
if (this.bindingItem.composition) {
|
|
14076
|
+
this.sampleAnimation();
|
|
14077
|
+
}
|
|
14078
|
+
};
|
|
14079
|
+
/**
|
|
14080
|
+
* 应用时间轴K帧数据到对象
|
|
14081
|
+
*/
|
|
14082
|
+
AnimationClipPlayable.prototype.sampleAnimation = function () {
|
|
14083
|
+
var _this = this;
|
|
14084
|
+
var duration = this.bindingItem.duration;
|
|
14085
|
+
var life = this.time / duration;
|
|
14086
|
+
life = life < 0 ? 0 : (life > 1 ? 1 : life);
|
|
14087
|
+
if (this.sizeXOverLifetime) {
|
|
14088
|
+
tempSize$1.x = this.sizeXOverLifetime.getValue(life);
|
|
14089
|
+
if (this.sizeSeparateAxes) {
|
|
14090
|
+
tempSize$1.y = this.sizeYOverLifetime.getValue(life);
|
|
14091
|
+
tempSize$1.z = this.sizeZOverLifetime.getValue(life);
|
|
14129
14092
|
}
|
|
14130
|
-
|
|
14131
|
-
|
|
14132
|
-
try {
|
|
14133
|
-
if (_x && !_x.done && (_g = _w.return)) _g.call(_w);
|
|
14134
|
-
}
|
|
14135
|
-
finally { if (e_9) throw e_9.error; }
|
|
14093
|
+
else {
|
|
14094
|
+
tempSize$1.z = tempSize$1.y = tempSize$1.x;
|
|
14136
14095
|
}
|
|
14137
|
-
this.
|
|
14096
|
+
var startSize = this.originalTransform.scale;
|
|
14097
|
+
this.bindingItem.transform.setScale(tempSize$1.x * startSize.x, tempSize$1.y * startSize.y, tempSize$1.z * startSize.z);
|
|
14098
|
+
// this.animationStream.setCurveValue('transform', 'scale.x', tempSize.x * startSize.x);
|
|
14099
|
+
// this.animationStream.setCurveValue('transform', 'scale.y', tempSize.y * startSize.y);
|
|
14100
|
+
// this.animationStream.setCurveValue('transform', 'scale.z', tempSize.z * startSize.z);
|
|
14101
|
+
}
|
|
14102
|
+
if (this.rotationOverLifetime) {
|
|
14103
|
+
var func = function (v) { return _this.rotationOverLifetime.asRotation ? v.getValue(life) : v.getIntegrateValue(0, life, duration); };
|
|
14104
|
+
var incZ = func(this.rotationOverLifetime.z);
|
|
14105
|
+
var separateAxes = this.rotationOverLifetime.separateAxes;
|
|
14106
|
+
tempRot$1.x = separateAxes ? func(this.rotationOverLifetime.x) : 0;
|
|
14107
|
+
tempRot$1.y = separateAxes ? func(this.rotationOverLifetime.y) : 0;
|
|
14108
|
+
tempRot$1.z = incZ;
|
|
14109
|
+
var rot = tempRot$1.addEulers(this.originalTransform.rotation, tempRot$1);
|
|
14110
|
+
this.bindingItem.transform.setRotation(rot.x, rot.y, rot.z);
|
|
14111
|
+
// this.animationStream.setCurveValue('transform', 'rotation.x', rot.x);
|
|
14112
|
+
// this.animationStream.setCurveValue('transform', 'rotation.y', rot.y);
|
|
14113
|
+
// this.animationStream.setCurveValue('transform', 'rotation.z', rot.z);
|
|
14114
|
+
}
|
|
14115
|
+
if (this.positionOverLifetime) {
|
|
14116
|
+
var pos = tempPos;
|
|
14117
|
+
calculateTranslation(pos, this, this.gravity, this.time, duration, this.originalTransform.position, this.velocity);
|
|
14118
|
+
if (this.originalTransform.path) {
|
|
14119
|
+
pos.add(this.originalTransform.path.getValue(life));
|
|
14120
|
+
}
|
|
14121
|
+
this.bindingItem.transform.setPosition(pos.x, pos.y, pos.z);
|
|
14122
|
+
// this.animationStream.setCurveValue('transform', 'position.x', pos.x);
|
|
14123
|
+
// this.animationStream.setCurveValue('transform', 'position.y', pos.y);
|
|
14124
|
+
// this.animationStream.setCurveValue('transform', 'position.z', pos.z);
|
|
14138
14125
|
}
|
|
14139
14126
|
};
|
|
14140
|
-
|
|
14141
|
-
|
|
14142
|
-
|
|
14143
|
-
|
|
14144
|
-
|
|
14145
|
-
|
|
14146
|
-
|
|
14147
|
-
|
|
14148
|
-
|
|
14149
|
-
var
|
|
14150
|
-
|
|
14151
|
-
|
|
14152
|
-
|
|
14127
|
+
AnimationClipPlayable.prototype.fromData = function (data) {
|
|
14128
|
+
var _a;
|
|
14129
|
+
var scale = this.bindingItem.transform.scale;
|
|
14130
|
+
this.originalTransform = {
|
|
14131
|
+
position: this.bindingItem.transform.position.clone(),
|
|
14132
|
+
rotation: this.bindingItem.transform.getRotation().clone(),
|
|
14133
|
+
// TODO 编辑器 scale 没有z轴控制
|
|
14134
|
+
scale: new Vector3(scale.x, scale.y, scale.x),
|
|
14135
|
+
};
|
|
14136
|
+
var positionOverLifetime = data.positionOverLifetime;
|
|
14137
|
+
var rotationOverLifetime = data.rotationOverLifetime;
|
|
14138
|
+
var sizeOverLifetime = data.sizeOverLifetime;
|
|
14139
|
+
// TODO: 没有 K 帧数据的不需要传 positionOverLifetime 空对象
|
|
14140
|
+
if (positionOverLifetime && Object.keys(positionOverLifetime).length !== 0) {
|
|
14141
|
+
this.positionOverLifetime = positionOverLifetime;
|
|
14142
|
+
if (positionOverLifetime.path) {
|
|
14143
|
+
this.originalTransform.path = createValueGetter(positionOverLifetime.path);
|
|
14153
14144
|
}
|
|
14154
|
-
|
|
14155
|
-
|
|
14145
|
+
var linearVelEnable = positionOverLifetime.linearX || positionOverLifetime.linearY || positionOverLifetime.linearZ;
|
|
14146
|
+
if (linearVelEnable) {
|
|
14147
|
+
this.linearVelOverLifetime = {
|
|
14148
|
+
x: positionOverLifetime.linearX && createValueGetter(positionOverLifetime.linearX),
|
|
14149
|
+
y: positionOverLifetime.linearY && createValueGetter(positionOverLifetime.linearY),
|
|
14150
|
+
z: positionOverLifetime.linearZ && createValueGetter(positionOverLifetime.linearZ),
|
|
14151
|
+
asMovement: positionOverLifetime.asMovement,
|
|
14152
|
+
enabled: !!linearVelEnable,
|
|
14153
|
+
};
|
|
14154
|
+
}
|
|
14155
|
+
var orbitalVelEnable = positionOverLifetime.orbitalX || positionOverLifetime.orbitalY || positionOverLifetime.orbitalZ;
|
|
14156
|
+
if (orbitalVelEnable) {
|
|
14157
|
+
this.orbitalVelOverLifetime = {
|
|
14158
|
+
x: positionOverLifetime.orbitalX && createValueGetter(positionOverLifetime.orbitalX),
|
|
14159
|
+
y: positionOverLifetime.orbitalY && createValueGetter(positionOverLifetime.orbitalY),
|
|
14160
|
+
z: positionOverLifetime.orbitalZ && createValueGetter(positionOverLifetime.orbitalZ),
|
|
14161
|
+
center: ensureVec3(positionOverLifetime.orbCenter),
|
|
14162
|
+
asRotation: positionOverLifetime.asRotation,
|
|
14163
|
+
enabled: !!orbitalVelEnable,
|
|
14164
|
+
};
|
|
14156
14165
|
}
|
|
14166
|
+
this.speedOverLifetime = positionOverLifetime.speedOverLifetime && createValueGetter(positionOverLifetime.speedOverLifetime);
|
|
14157
14167
|
}
|
|
14158
|
-
|
|
14168
|
+
if (sizeOverLifetime) {
|
|
14169
|
+
if (sizeOverLifetime.separateAxes) {
|
|
14170
|
+
this.sizeSeparateAxes = true;
|
|
14171
|
+
this.sizeXOverLifetime = createValueGetter(sizeOverLifetime.x || 1);
|
|
14172
|
+
this.sizeYOverLifetime = createValueGetter(sizeOverLifetime.y || 1);
|
|
14173
|
+
this.sizeZOverLifetime = createValueGetter(sizeOverLifetime.z || 1);
|
|
14174
|
+
}
|
|
14175
|
+
else {
|
|
14176
|
+
this.sizeXOverLifetime = createValueGetter(sizeOverLifetime.size || 1);
|
|
14177
|
+
}
|
|
14178
|
+
}
|
|
14179
|
+
if (rotationOverLifetime) {
|
|
14180
|
+
this.rotationOverLifetime = {
|
|
14181
|
+
asRotation: rotationOverLifetime.asRotation,
|
|
14182
|
+
separateAxes: rotationOverLifetime.separateAxes,
|
|
14183
|
+
z: createValueGetter(rotationOverLifetime.z || 0),
|
|
14184
|
+
};
|
|
14185
|
+
if (rotationOverLifetime.separateAxes) {
|
|
14186
|
+
var rotLt = this.rotationOverLifetime;
|
|
14187
|
+
rotLt.x = createValueGetter(rotationOverLifetime.x || 0);
|
|
14188
|
+
rotLt.y = createValueGetter(rotationOverLifetime.y || 0);
|
|
14189
|
+
}
|
|
14190
|
+
}
|
|
14191
|
+
this.gravity = Vector3.fromArray((positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravity) || []);
|
|
14192
|
+
this.gravityModifier = createValueGetter((_a = positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravityOverLifetime) !== null && _a !== void 0 ? _a : 0);
|
|
14193
|
+
this.direction = (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.direction) ? Vector3.fromArray(positionOverLifetime.direction).normalize() : new Vector3();
|
|
14194
|
+
this.startSpeed = (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.startSpeed) || 0;
|
|
14195
|
+
this.velocity = this.direction.clone();
|
|
14196
|
+
this.velocity.multiply(this.startSpeed);
|
|
14159
14197
|
};
|
|
14160
|
-
|
|
14161
|
-
|
|
14162
|
-
|
|
14163
|
-
|
|
14164
|
-
|
|
14165
|
-
|
|
14166
|
-
|
|
14198
|
+
return AnimationClipPlayable;
|
|
14199
|
+
}(AnimationPlayable));
|
|
14200
|
+
/**
|
|
14201
|
+
* @since 2.0.0
|
|
14202
|
+
* @internal
|
|
14203
|
+
*/
|
|
14204
|
+
var ActivationClipPlayable = /** @class */ (function (_super) {
|
|
14205
|
+
__extends(ActivationClipPlayable, _super);
|
|
14206
|
+
function ActivationClipPlayable() {
|
|
14207
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
14208
|
+
}
|
|
14209
|
+
ActivationClipPlayable.prototype.onGraphStart = function () {
|
|
14210
|
+
this.bindingItem.transform.setValid(false);
|
|
14211
|
+
this.hideRendererComponents();
|
|
14167
14212
|
};
|
|
14168
|
-
|
|
14169
|
-
|
|
14213
|
+
ActivationClipPlayable.prototype.onPlayablePlay = function () {
|
|
14214
|
+
this.bindingItem.transform.setValid(true);
|
|
14215
|
+
this.showRendererComponents();
|
|
14170
14216
|
};
|
|
14171
|
-
|
|
14172
|
-
|
|
14217
|
+
ActivationClipPlayable.prototype.onPlayableDestroy = function () {
|
|
14218
|
+
this.bindingItem.transform.setValid(false);
|
|
14219
|
+
this.hideRendererComponents();
|
|
14220
|
+
};
|
|
14221
|
+
ActivationClipPlayable.prototype.hideRendererComponents = function () {
|
|
14222
|
+
var e_1, _a;
|
|
14173
14223
|
try {
|
|
14174
|
-
for (var _b = __values$1(this.
|
|
14175
|
-
var
|
|
14176
|
-
if (
|
|
14177
|
-
|
|
14224
|
+
for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
14225
|
+
var rendererComponent = _c.value;
|
|
14226
|
+
if (rendererComponent.enabled) {
|
|
14227
|
+
rendererComponent.enabled = false;
|
|
14178
14228
|
}
|
|
14179
14229
|
}
|
|
14180
14230
|
}
|
|
14181
|
-
catch (
|
|
14231
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
14182
14232
|
finally {
|
|
14183
14233
|
try {
|
|
14184
14234
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
14185
14235
|
}
|
|
14186
|
-
finally { if (
|
|
14236
|
+
finally { if (e_1) throw e_1.error; }
|
|
14187
14237
|
}
|
|
14188
14238
|
};
|
|
14189
|
-
|
|
14190
|
-
|
|
14191
|
-
this.compileTracks(this.playableGraph);
|
|
14192
|
-
};
|
|
14193
|
-
TimelineComponent.prototype.compileTracks = function (graph) {
|
|
14194
|
-
var e_12, _a;
|
|
14239
|
+
ActivationClipPlayable.prototype.showRendererComponents = function () {
|
|
14240
|
+
var e_2, _a;
|
|
14195
14241
|
try {
|
|
14196
|
-
for (var _b = __values$1(this.
|
|
14197
|
-
var
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
|
|
14201
|
-
trackOutput.setSourcePlayeble(trackMixPlayable);
|
|
14242
|
+
for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
14243
|
+
var rendererComponent = _c.value;
|
|
14244
|
+
if (!rendererComponent.enabled) {
|
|
14245
|
+
rendererComponent.enabled = true;
|
|
14246
|
+
}
|
|
14202
14247
|
}
|
|
14203
14248
|
}
|
|
14204
|
-
catch (
|
|
14249
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
14205
14250
|
finally {
|
|
14206
14251
|
try {
|
|
14207
14252
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
14208
14253
|
}
|
|
14209
|
-
finally { if (
|
|
14254
|
+
finally { if (e_2) throw e_2.error; }
|
|
14210
14255
|
}
|
|
14211
14256
|
};
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
this.options = {
|
|
14215
|
-
start: this.item.start,
|
|
14216
|
-
duration: this.item.duration,
|
|
14217
|
-
looping: this.item.endBehavior === END_BEHAVIOR_RESTART$1,
|
|
14218
|
-
endBehavior: this.item.endBehavior || END_BEHAVIOR_DESTROY$1,
|
|
14219
|
-
};
|
|
14220
|
-
this.id = this.item.id;
|
|
14221
|
-
this.name = this.item.name;
|
|
14222
|
-
};
|
|
14223
|
-
TimelineComponent.prototype.toData = function () {
|
|
14224
|
-
_super.prototype.toData.call(this);
|
|
14225
|
-
};
|
|
14226
|
-
__decorate([
|
|
14227
|
-
serialize()
|
|
14228
|
-
], TimelineComponent.prototype, "time", void 0);
|
|
14229
|
-
return TimelineComponent;
|
|
14230
|
-
}(ItemBehaviour));
|
|
14257
|
+
return ActivationClipPlayable;
|
|
14258
|
+
}(Playable));
|
|
14231
14259
|
|
|
14232
14260
|
/**
|
|
14233
14261
|
* @since 2.0.0
|
|
14234
14262
|
* @internal
|
|
14235
14263
|
*/
|
|
14236
|
-
var
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
|
|
14264
|
+
var TimelineComponent = /** @class */ (function (_super) {
|
|
14265
|
+
__extends(TimelineComponent, _super);
|
|
14266
|
+
function TimelineComponent(engine) {
|
|
14267
|
+
var _this = _super.call(this, engine) || this;
|
|
14268
|
+
_this.reusable = false;
|
|
14269
|
+
_this.timelineStarted = false;
|
|
14270
|
+
_this.playableGraph = new PlayableGraph();
|
|
14271
|
+
/**
|
|
14272
|
+
* 元素动画已经播放的时间
|
|
14273
|
+
*/
|
|
14274
|
+
_this.time = 0;
|
|
14275
|
+
_this.tracks = [];
|
|
14276
|
+
_this.trackSeed = 0;
|
|
14277
|
+
return _this;
|
|
14240
14278
|
}
|
|
14241
|
-
|
|
14242
|
-
var
|
|
14243
|
-
return output;
|
|
14244
|
-
};
|
|
14245
|
-
/**
|
|
14246
|
-
* 重写该方法以创建自定义混合器
|
|
14247
|
-
*/
|
|
14248
|
-
Track.prototype.createMixerPlayable = function () {
|
|
14249
|
-
return new Playable();
|
|
14250
|
-
};
|
|
14251
|
-
Track.prototype.createPlayebleTree = function () {
|
|
14252
|
-
var e_1, _a;
|
|
14253
|
-
var defaultMixPlayable = this.createMixerPlayable();
|
|
14279
|
+
TimelineComponent.prototype.start = function () {
|
|
14280
|
+
var e_1, _a, e_2, _b;
|
|
14254
14281
|
try {
|
|
14255
|
-
|
|
14256
|
-
|
|
14257
|
-
|
|
14282
|
+
// TODO TimelineClip 需要传入 start 和 duration 数据
|
|
14283
|
+
for (var _c = __values$1(this.tracks), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
14284
|
+
var track = _d.value;
|
|
14285
|
+
try {
|
|
14286
|
+
for (var _e = (e_2 = void 0, __values$1(track.getClips())), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
14287
|
+
var clip = _f.value;
|
|
14288
|
+
clip.start = this.item.start;
|
|
14289
|
+
clip.duration = this.item.duration;
|
|
14290
|
+
}
|
|
14291
|
+
}
|
|
14292
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
14293
|
+
finally {
|
|
14294
|
+
try {
|
|
14295
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
14296
|
+
}
|
|
14297
|
+
finally { if (e_2) throw e_2.error; }
|
|
14298
|
+
}
|
|
14258
14299
|
}
|
|
14259
14300
|
}
|
|
14260
14301
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
14261
14302
|
finally {
|
|
14262
14303
|
try {
|
|
14263
|
-
if (
|
|
14304
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
14264
14305
|
}
|
|
14265
14306
|
finally { if (e_1) throw e_1.error; }
|
|
14266
14307
|
}
|
|
14267
|
-
|
|
14268
|
-
};
|
|
14269
|
-
Track.prototype.createClip = function (classConstructor, name) {
|
|
14270
|
-
var newClip = new TimelineClip();
|
|
14271
|
-
newClip.playable = new classConstructor();
|
|
14272
|
-
newClip.name = name ? name : 'TimelineClip' + newClip.id;
|
|
14273
|
-
this.addClip(newClip);
|
|
14274
|
-
return newClip;
|
|
14275
|
-
};
|
|
14276
|
-
Track.prototype.getClips = function () {
|
|
14277
|
-
return this.clips;
|
|
14308
|
+
this.compileTracks(this.playableGraph);
|
|
14278
14309
|
};
|
|
14279
|
-
|
|
14280
|
-
|
|
14281
|
-
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
if (clip.name === name) {
|
|
14285
|
-
return clip;
|
|
14286
|
-
}
|
|
14287
|
-
}
|
|
14310
|
+
// TODO: [1.31] @十弦 vfx-item 下 onUpdate 的改动验证
|
|
14311
|
+
TimelineComponent.prototype.update = function (dt) {
|
|
14312
|
+
var e_3, _a, e_4, _b, e_5, _c, e_6, _d, e_7, _e, e_8, _f, e_9, _g, e_10, _h;
|
|
14313
|
+
if (this.item.stopped || !this.item.composition) {
|
|
14314
|
+
return;
|
|
14288
14315
|
}
|
|
14289
|
-
|
|
14290
|
-
finally {
|
|
14316
|
+
if (!this.timelineStarted) {
|
|
14291
14317
|
try {
|
|
14292
|
-
|
|
14318
|
+
for (var _j = __values$1(this.tracks), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
14319
|
+
var track = _k.value;
|
|
14320
|
+
try {
|
|
14321
|
+
for (var _l = (e_4 = void 0, __values$1(track.getClips())), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
14322
|
+
var clip = _m.value;
|
|
14323
|
+
clip.playable.onGraphStart();
|
|
14324
|
+
}
|
|
14325
|
+
}
|
|
14326
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
14327
|
+
finally {
|
|
14328
|
+
try {
|
|
14329
|
+
if (_m && !_m.done && (_b = _l.return)) _b.call(_l);
|
|
14330
|
+
}
|
|
14331
|
+
finally { if (e_4) throw e_4.error; }
|
|
14332
|
+
}
|
|
14333
|
+
}
|
|
14293
14334
|
}
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
|
|
14298
|
-
|
|
14299
|
-
|
|
14300
|
-
this.clips.push(clip);
|
|
14301
|
-
};
|
|
14302
|
-
return Track;
|
|
14303
|
-
}());
|
|
14304
|
-
/**
|
|
14305
|
-
* @since 2.0.0
|
|
14306
|
-
* @internal
|
|
14307
|
-
*/
|
|
14308
|
-
var TimelineClip = /** @class */ (function () {
|
|
14309
|
-
function TimelineClip() {
|
|
14310
|
-
this.start = 0;
|
|
14311
|
-
this.duration = 0;
|
|
14312
|
-
}
|
|
14313
|
-
return TimelineClip;
|
|
14314
|
-
}());
|
|
14315
|
-
|
|
14316
|
-
var singleSplits = [[0, 0, 1, 1, undefined]];
|
|
14317
|
-
var tempColor = [1, 1, 1, 1];
|
|
14318
|
-
var seed$3 = 0;
|
|
14319
|
-
var SpriteColorPlayable = /** @class */ (function (_super) {
|
|
14320
|
-
__extends(SpriteColorPlayable, _super);
|
|
14321
|
-
function SpriteColorPlayable() {
|
|
14322
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
14323
|
-
_this.renderColor = [1, 1, 1, 1];
|
|
14324
|
-
return _this;
|
|
14325
|
-
}
|
|
14326
|
-
SpriteColorPlayable.prototype.onPlayablePlay = function () {
|
|
14327
|
-
this.spriteMaterial = this.bindingItem.getComponent(SpriteComponent).material;
|
|
14328
|
-
};
|
|
14329
|
-
SpriteColorPlayable.prototype.processFrame = function (dt) {
|
|
14330
|
-
var colorInc = vecFill(tempColor, 1);
|
|
14331
|
-
var colorChanged;
|
|
14332
|
-
var life = this.time / this.bindingItem.duration;
|
|
14333
|
-
var opacityOverLifetime = this.opacityOverLifetime;
|
|
14334
|
-
var colorOverLifetime = this.colorOverLifetime;
|
|
14335
|
-
if (colorOverLifetime) {
|
|
14336
|
-
colorInc = getColorFromGradientStops(colorOverLifetime, life, true);
|
|
14337
|
-
colorChanged = true;
|
|
14338
|
-
}
|
|
14339
|
-
if (opacityOverLifetime) {
|
|
14340
|
-
colorInc[3] *= opacityOverLifetime.getValue(life);
|
|
14341
|
-
colorChanged = true;
|
|
14342
|
-
}
|
|
14343
|
-
if (colorChanged) {
|
|
14344
|
-
vecMulCombine(this.renderColor, colorInc, this.startColor);
|
|
14345
|
-
this.spriteMaterial.getVector4('_Color').setFromArray(this.renderColor);
|
|
14346
|
-
}
|
|
14347
|
-
};
|
|
14348
|
-
SpriteColorPlayable.prototype.fromData = function (clipData) {
|
|
14349
|
-
var _a;
|
|
14350
|
-
this.clipData = clipData;
|
|
14351
|
-
var colorOverLifetime = clipData.colorOverLifetime;
|
|
14352
|
-
if (colorOverLifetime) {
|
|
14353
|
-
this.opacityOverLifetime = createValueGetter((_a = colorOverLifetime.opacity) !== null && _a !== void 0 ? _a : 1);
|
|
14354
|
-
if (colorOverLifetime.color && colorOverLifetime.color[0] === ValueType$1.GRADIENT_COLOR) {
|
|
14355
|
-
this.colorOverLifetime = colorStopsFromGradient(colorOverLifetime.color[1]);
|
|
14335
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
14336
|
+
finally {
|
|
14337
|
+
try {
|
|
14338
|
+
if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
|
|
14339
|
+
}
|
|
14340
|
+
finally { if (e_3) throw e_3.error; }
|
|
14356
14341
|
}
|
|
14342
|
+
this.timelineStarted = true;
|
|
14357
14343
|
}
|
|
14358
|
-
|
|
14359
|
-
|
|
14360
|
-
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
var
|
|
14364
|
-
|
|
14365
|
-
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
|
|
14373
|
-
|
|
14374
|
-
|
|
14375
|
-
|
|
14376
|
-
|
|
14377
|
-
|
|
14378
|
-
triangles: area.area,
|
|
14379
|
-
backfaceCulling: _this.renderer.side === SideMode$1.FRONT,
|
|
14380
|
-
};
|
|
14344
|
+
var now = this.time;
|
|
14345
|
+
// 判断动画是否开始
|
|
14346
|
+
if (this.item.delaying && now >= 0 && now <= this.item.duration) {
|
|
14347
|
+
this.item.delaying = false;
|
|
14348
|
+
try {
|
|
14349
|
+
for (var _o = __values$1(this.tracks), _p = _o.next(); !_p.done; _p = _o.next()) {
|
|
14350
|
+
var track = _p.value;
|
|
14351
|
+
try {
|
|
14352
|
+
for (var _q = (e_6 = void 0, __values$1(track.getClips())), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
14353
|
+
var clip = _r.value;
|
|
14354
|
+
clip.playable.onPlayablePlay();
|
|
14355
|
+
}
|
|
14356
|
+
}
|
|
14357
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
14358
|
+
finally {
|
|
14359
|
+
try {
|
|
14360
|
+
if (_r && !_r.done && (_d = _q.return)) _d.call(_q);
|
|
14361
|
+
}
|
|
14362
|
+
finally { if (e_6) throw e_6.error; }
|
|
14363
|
+
}
|
|
14381
14364
|
}
|
|
14382
14365
|
}
|
|
14383
|
-
|
|
14384
|
-
|
|
14385
|
-
|
|
14366
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
14367
|
+
finally {
|
|
14368
|
+
try {
|
|
14369
|
+
if (_p && !_p.done && (_c = _o.return)) _c.call(_o);
|
|
14370
|
+
}
|
|
14371
|
+
finally { if (e_5) throw e_5.error; }
|
|
14372
|
+
}
|
|
14386
14373
|
}
|
|
14387
|
-
|
|
14388
|
-
|
|
14389
|
-
|
|
14390
|
-
|
|
14391
|
-
* @param visible - true:可见,false:不可见
|
|
14392
|
-
*/
|
|
14393
|
-
SpriteComponent.prototype.setVisible = function (visible) {
|
|
14394
|
-
this.visible = visible;
|
|
14395
|
-
};
|
|
14396
|
-
/**
|
|
14397
|
-
* 获取当前 Mesh 的可见性。
|
|
14398
|
-
*/
|
|
14399
|
-
SpriteComponent.prototype.getVisible = function () {
|
|
14400
|
-
return this.visible;
|
|
14401
|
-
};
|
|
14402
|
-
SpriteComponent.prototype.render = function (renderer) {
|
|
14403
|
-
if (!this.getVisible()) {
|
|
14404
|
-
return;
|
|
14374
|
+
// 判断动画是否结束
|
|
14375
|
+
var ended;
|
|
14376
|
+
if (VFXItem.isParticle(this.item)) {
|
|
14377
|
+
ended = this.item.isEnded(now) && this.item.content.destoryed;
|
|
14405
14378
|
}
|
|
14406
|
-
|
|
14407
|
-
|
|
14408
|
-
if (renderer.renderingData.currentFrame.globalUniforms) {
|
|
14409
|
-
renderer.setGlobalMatrix('effects_ObjectToWorld', this.transform.getWorldMatrix());
|
|
14379
|
+
else {
|
|
14380
|
+
ended = this.item.isEnded(now);
|
|
14410
14381
|
}
|
|
14411
|
-
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14420
|
-
|
|
14421
|
-
|
|
14422
|
-
|
|
14423
|
-
|
|
14424
|
-
|
|
14425
|
-
|
|
14426
|
-
|
|
14427
|
-
|
|
14428
|
-
|
|
14429
|
-
|
|
14430
|
-
|
|
14431
|
-
|
|
14432
|
-
|
|
14433
|
-
|
|
14434
|
-
|
|
14435
|
-
|
|
14436
|
-
|
|
14437
|
-
|
|
14438
|
-
|
|
14439
|
-
|
|
14440
|
-
|
|
14441
|
-
|
|
14442
|
-
|
|
14443
|
-
|
|
14444
|
-
|
|
14382
|
+
if (ended) {
|
|
14383
|
+
var endBehavior = this.item.endBehavior;
|
|
14384
|
+
if (!this.item.ended) {
|
|
14385
|
+
this.item.ended = true;
|
|
14386
|
+
this.item.onEnd();
|
|
14387
|
+
if (endBehavior === END_BEHAVIOR_DESTROY$1) {
|
|
14388
|
+
try {
|
|
14389
|
+
for (var _s = __values$1(this.tracks), _t = _s.next(); !_t.done; _t = _s.next()) {
|
|
14390
|
+
var track = _t.value;
|
|
14391
|
+
try {
|
|
14392
|
+
for (var _u = (e_8 = void 0, __values$1(track.getClips())), _v = _u.next(); !_v.done; _v = _u.next()) {
|
|
14393
|
+
var clip = _v.value;
|
|
14394
|
+
clip.playable.onPlayableDestroy();
|
|
14395
|
+
}
|
|
14396
|
+
}
|
|
14397
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
14398
|
+
finally {
|
|
14399
|
+
try {
|
|
14400
|
+
if (_v && !_v.done && (_f = _u.return)) _f.call(_u);
|
|
14401
|
+
}
|
|
14402
|
+
finally { if (e_8) throw e_8.error; }
|
|
14403
|
+
}
|
|
14404
|
+
}
|
|
14405
|
+
}
|
|
14406
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
14407
|
+
finally {
|
|
14408
|
+
try {
|
|
14409
|
+
if (_t && !_t.done && (_e = _s.return)) _e.call(_s);
|
|
14410
|
+
}
|
|
14411
|
+
finally { if (e_7) throw e_7.error; }
|
|
14412
|
+
}
|
|
14413
|
+
this.item.delaying = true;
|
|
14414
|
+
if (!this.item.reusable && !this.reusable) {
|
|
14415
|
+
this.item.dispose();
|
|
14416
|
+
return;
|
|
14417
|
+
}
|
|
14445
14418
|
}
|
|
14446
14419
|
}
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14420
|
+
}
|
|
14421
|
+
// TODO: [1.31] @茂安 验证 https://github.com/galacean/effects-runtime/commits/main/packages/effects-core/src/vfx-item.ts
|
|
14422
|
+
// 在生命周期内更新动画
|
|
14423
|
+
if (!this.item.delaying) {
|
|
14424
|
+
var lifetime = this.time / this.item.duration;
|
|
14425
|
+
this.item.lifetime = lifetime;
|
|
14426
|
+
try {
|
|
14427
|
+
for (var _w = __values$1(this.tracks), _x = _w.next(); !_x.done; _x = _w.next()) {
|
|
14428
|
+
var track = _x.value;
|
|
14429
|
+
try {
|
|
14430
|
+
for (var _y = (e_10 = void 0, __values$1(track.getClips())), _z = _y.next(); !_z.done; _z = _y.next()) {
|
|
14431
|
+
var clip = _z.value;
|
|
14432
|
+
clip.playable.setTime(this.time);
|
|
14433
|
+
}
|
|
14434
|
+
}
|
|
14435
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
14436
|
+
finally {
|
|
14437
|
+
try {
|
|
14438
|
+
if (_z && !_z.done && (_h = _y.return)) _h.call(_y);
|
|
14439
|
+
}
|
|
14440
|
+
finally { if (e_10) throw e_10.error; }
|
|
14441
|
+
}
|
|
14442
|
+
}
|
|
14451
14443
|
}
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14444
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
14445
|
+
finally {
|
|
14446
|
+
try {
|
|
14447
|
+
if (_x && !_x.done && (_g = _w.return)) _g.call(_w);
|
|
14448
|
+
}
|
|
14449
|
+
finally { if (e_9) throw e_9.error; }
|
|
14455
14450
|
}
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14461
|
-
|
|
14451
|
+
this.playableGraph.evaluate(dt);
|
|
14452
|
+
}
|
|
14453
|
+
};
|
|
14454
|
+
// time 单位秒
|
|
14455
|
+
TimelineComponent.prototype.setTime = function (time) {
|
|
14456
|
+
this.time = time;
|
|
14457
|
+
};
|
|
14458
|
+
TimelineComponent.prototype.getTime = function () {
|
|
14459
|
+
return this.time;
|
|
14460
|
+
};
|
|
14461
|
+
TimelineComponent.prototype.toLocalTime = function (time) {
|
|
14462
|
+
var localTime = time - this.options.start;
|
|
14463
|
+
var duration = this.options.duration;
|
|
14464
|
+
if (localTime - duration > 0.001) {
|
|
14465
|
+
if (this.options.endBehavior === END_BEHAVIOR_RESTART$1) {
|
|
14466
|
+
localTime = localTime % duration;
|
|
14462
14467
|
}
|
|
14463
|
-
else {
|
|
14464
|
-
|
|
14468
|
+
else if (this.options.endBehavior === END_BEHAVIOR_FREEZE$1) {
|
|
14469
|
+
localTime = Math.min(duration, localTime);
|
|
14465
14470
|
}
|
|
14466
|
-
this.material.getVector4('_TexOffset').setFromArray([
|
|
14467
|
-
texRectX + texOffset[0],
|
|
14468
|
-
texRectH + texRectY - texOffset[1],
|
|
14469
|
-
dx, dy,
|
|
14470
|
-
]);
|
|
14471
14471
|
}
|
|
14472
|
+
return localTime;
|
|
14472
14473
|
};
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
|
|
14476
|
-
|
|
14474
|
+
TimelineComponent.prototype.createTrack = function (classConstructor, name) {
|
|
14475
|
+
var newTrack = new classConstructor();
|
|
14476
|
+
newTrack.bindingItem = this.item;
|
|
14477
|
+
newTrack.id = (this.trackSeed++).toString();
|
|
14478
|
+
newTrack.name = name ? name : 'Track' + newTrack.id;
|
|
14479
|
+
this.tracks.push(newTrack);
|
|
14480
|
+
return newTrack;
|
|
14477
14481
|
};
|
|
14478
|
-
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
+
TimelineComponent.prototype.getTracks = function () {
|
|
14483
|
+
return this.tracks;
|
|
14484
|
+
};
|
|
14485
|
+
TimelineComponent.prototype.findTrack = function (name) {
|
|
14486
|
+
var e_11, _a;
|
|
14487
|
+
try {
|
|
14488
|
+
for (var _b = __values$1(this.tracks), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
14489
|
+
var track = _c.value;
|
|
14490
|
+
if (track.name === name) {
|
|
14491
|
+
return track;
|
|
14492
|
+
}
|
|
14493
|
+
}
|
|
14482
14494
|
}
|
|
14483
|
-
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
if (!this.wireframe) {
|
|
14488
|
-
for (var i = 0; i < idxCount; i++) {
|
|
14489
|
-
indexData[i] = pointStartIndex + index[i];
|
|
14495
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
14496
|
+
finally {
|
|
14497
|
+
try {
|
|
14498
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
14490
14499
|
}
|
|
14500
|
+
finally { if (e_11) throw e_11.error; }
|
|
14491
14501
|
}
|
|
14492
|
-
return {
|
|
14493
|
-
atlasOffset: geoData.atlasOffset,
|
|
14494
|
-
index: indexData,
|
|
14495
|
-
};
|
|
14496
14502
|
};
|
|
14497
|
-
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14505
|
-
|
|
14506
|
-
|
|
14507
|
-
|
|
14508
|
-
|
|
14509
|
-
|
|
14510
|
-
|
|
14511
|
-
var attributes = {
|
|
14512
|
-
atlasOffset: new Float32Array(data.atlasOffset.length),
|
|
14513
|
-
index: new Uint16Array(data.index.length),
|
|
14514
|
-
};
|
|
14515
|
-
attributes.atlasOffset.set(data.atlasOffset);
|
|
14516
|
-
attributes.index.set(data.index);
|
|
14517
|
-
var _a = this, material = _a.material, geometry = _a.geometry;
|
|
14518
|
-
var indexData = attributes.index;
|
|
14519
|
-
geometry.setIndexData(indexData);
|
|
14520
|
-
geometry.setAttributeData('atlasOffset', attributes.atlasOffset);
|
|
14521
|
-
geometry.setDrawCount(data.index.length);
|
|
14522
|
-
for (var i = 0; i < textures.length; i++) {
|
|
14523
|
-
var texture_1 = textures[i];
|
|
14524
|
-
material.setTexture('uSampler' + i, texture_1);
|
|
14503
|
+
TimelineComponent.prototype.rebuildGraph = function () {
|
|
14504
|
+
this.playableGraph = new PlayableGraph();
|
|
14505
|
+
this.compileTracks(this.playableGraph);
|
|
14506
|
+
};
|
|
14507
|
+
TimelineComponent.prototype.compileTracks = function (graph) {
|
|
14508
|
+
var e_12, _a;
|
|
14509
|
+
try {
|
|
14510
|
+
for (var _b = __values$1(this.tracks), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
14511
|
+
var track = _c.value;
|
|
14512
|
+
var trackMixPlayable = track.createPlayebleTree();
|
|
14513
|
+
var trackOutput = track.createOutput();
|
|
14514
|
+
graph.addOutput(trackOutput);
|
|
14515
|
+
trackOutput.setSourcePlayeble(trackMixPlayable);
|
|
14516
|
+
}
|
|
14525
14517
|
}
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
|
|
14518
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
14519
|
+
finally {
|
|
14520
|
+
try {
|
|
14521
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
14522
|
+
}
|
|
14523
|
+
finally { if (e_12) throw e_12.error; }
|
|
14530
14524
|
}
|
|
14531
14525
|
};
|
|
14532
|
-
|
|
14533
|
-
|
|
14534
|
-
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
|
|
14538
|
-
|
|
14539
|
-
data: new Float32Array([
|
|
14540
|
-
-0.5, 0.5, 0,
|
|
14541
|
-
-0.5, -0.5, 0,
|
|
14542
|
-
0.5, 0.5, 0,
|
|
14543
|
-
0.5, -0.5, 0, //右下
|
|
14544
|
-
]),
|
|
14545
|
-
},
|
|
14546
|
-
atlasOffset: {
|
|
14547
|
-
size: 2,
|
|
14548
|
-
offset: 0,
|
|
14549
|
-
releasable: true,
|
|
14550
|
-
type: glContext.FLOAT,
|
|
14551
|
-
data: new Float32Array(0),
|
|
14552
|
-
},
|
|
14553
|
-
},
|
|
14554
|
-
indices: { data: new Uint16Array(0), releasable: true },
|
|
14555
|
-
mode: mode,
|
|
14556
|
-
maxVertex: maxVertex,
|
|
14557
|
-
});
|
|
14558
|
-
};
|
|
14559
|
-
SpriteComponent.prototype.createMaterial = function (renderInfo, count) {
|
|
14560
|
-
var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
|
|
14561
|
-
var materialProps = {
|
|
14562
|
-
shader: spriteMeshShaderFromRenderInfo(renderInfo, count, 1),
|
|
14563
|
-
};
|
|
14564
|
-
this.preMultiAlpha = getPreMultiAlpha(blending);
|
|
14565
|
-
var material = Material.create(this.engine, materialProps);
|
|
14566
|
-
var states = {
|
|
14567
|
-
side: side,
|
|
14568
|
-
blending: true,
|
|
14569
|
-
blendMode: blending,
|
|
14570
|
-
mask: mask,
|
|
14571
|
-
maskMode: maskMode,
|
|
14572
|
-
depthTest: true,
|
|
14573
|
-
depthMask: occlusion,
|
|
14526
|
+
TimelineComponent.prototype.fromData = function (data) {
|
|
14527
|
+
_super.prototype.fromData.call(this, data);
|
|
14528
|
+
this.options = {
|
|
14529
|
+
start: this.item.start,
|
|
14530
|
+
duration: this.item.duration,
|
|
14531
|
+
looping: this.item.endBehavior === END_BEHAVIOR_RESTART$1,
|
|
14532
|
+
endBehavior: this.item.endBehavior || END_BEHAVIOR_DESTROY$1,
|
|
14574
14533
|
};
|
|
14575
|
-
|
|
14576
|
-
|
|
14577
|
-
|
|
14578
|
-
|
|
14579
|
-
|
|
14580
|
-
|
|
14581
|
-
|
|
14582
|
-
|
|
14583
|
-
|
|
14534
|
+
this.id = this.item.id;
|
|
14535
|
+
this.name = this.item.name;
|
|
14536
|
+
var activationTrack = this.createTrack(Track, 'ActivationTrack');
|
|
14537
|
+
activationTrack.createClip(ActivationClipPlayable, 'ActivationTimelineClip');
|
|
14538
|
+
};
|
|
14539
|
+
TimelineComponent.prototype.toData = function () {
|
|
14540
|
+
_super.prototype.toData.call(this);
|
|
14541
|
+
};
|
|
14542
|
+
__decorate([
|
|
14543
|
+
serialize()
|
|
14544
|
+
], TimelineComponent.prototype, "time", void 0);
|
|
14545
|
+
return TimelineComponent;
|
|
14546
|
+
}(ItemBehaviour));
|
|
14547
|
+
|
|
14548
|
+
var singleSplits = [[0, 0, 1, 1, undefined]];
|
|
14549
|
+
var tempColor = [1, 1, 1, 1];
|
|
14550
|
+
var seed$2 = 0;
|
|
14551
|
+
var SpriteColorPlayable = /** @class */ (function (_super) {
|
|
14552
|
+
__extends(SpriteColorPlayable, _super);
|
|
14553
|
+
function SpriteColorPlayable() {
|
|
14554
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
14555
|
+
_this.renderColor = [1, 1, 1, 1];
|
|
14556
|
+
return _this;
|
|
14557
|
+
}
|
|
14558
|
+
SpriteColorPlayable.prototype.onPlayablePlay = function () {
|
|
14559
|
+
this.spriteMaterial = this.bindingItem.getComponent(SpriteComponent).material;
|
|
14560
|
+
};
|
|
14561
|
+
SpriteColorPlayable.prototype.processFrame = function (dt) {
|
|
14562
|
+
var colorInc = vecFill(tempColor, 1);
|
|
14563
|
+
var colorChanged;
|
|
14564
|
+
var life = this.time / this.bindingItem.duration;
|
|
14565
|
+
var opacityOverLifetime = this.opacityOverLifetime;
|
|
14566
|
+
var colorOverLifetime = this.colorOverLifetime;
|
|
14567
|
+
if (colorOverLifetime) {
|
|
14568
|
+
colorInc = getColorFromGradientStops(colorOverLifetime, life, true);
|
|
14569
|
+
colorChanged = true;
|
|
14584
14570
|
}
|
|
14585
|
-
if (
|
|
14586
|
-
|
|
14571
|
+
if (opacityOverLifetime) {
|
|
14572
|
+
colorInc[3] *= opacityOverLifetime.getValue(life);
|
|
14573
|
+
colorChanged = true;
|
|
14587
14574
|
}
|
|
14588
|
-
if (
|
|
14589
|
-
|
|
14575
|
+
if (colorChanged) {
|
|
14576
|
+
vecMulCombine(this.renderColor, colorInc, this.startColor);
|
|
14577
|
+
this.spriteMaterial.getVector4('_Color').setFromArray(this.renderColor);
|
|
14590
14578
|
}
|
|
14591
|
-
return material;
|
|
14592
14579
|
};
|
|
14593
|
-
|
|
14594
|
-
var
|
|
14595
|
-
|
|
14596
|
-
|
|
14597
|
-
|
|
14598
|
-
|
|
14599
|
-
|
|
14600
|
-
|
|
14601
|
-
for (var i = 0; i < point.length; i += 6) {
|
|
14602
|
-
point[i] *= sx;
|
|
14603
|
-
point[i + 1] *= sy;
|
|
14604
|
-
atlasOffset_1.push(aPoint[i + 2], aPoint[i + 3]);
|
|
14605
|
-
position_1.push(point[i], point[i + 1], 0.0);
|
|
14606
|
-
}
|
|
14607
|
-
this.geometry.setAttributeData('aPos', new Float32Array(position_1));
|
|
14608
|
-
return {
|
|
14609
|
-
index: index_1,
|
|
14610
|
-
atlasOffset: atlasOffset_1,
|
|
14611
|
-
};
|
|
14612
|
-
}
|
|
14613
|
-
var originData = [-.5, .5, -.5, -.5, .5, .5, .5, -.5];
|
|
14614
|
-
var atlasOffset = [];
|
|
14615
|
-
var index = [];
|
|
14616
|
-
var col = 2;
|
|
14617
|
-
var row = 2;
|
|
14618
|
-
if (splits.length === 1) {
|
|
14619
|
-
col = 1;
|
|
14620
|
-
row = 1;
|
|
14621
|
-
}
|
|
14622
|
-
var position = [];
|
|
14623
|
-
for (var x = 0; x < col; x++) {
|
|
14624
|
-
for (var y = 0; y < row; y++) {
|
|
14625
|
-
var base = (y * 2 + x) * 4;
|
|
14626
|
-
// @ts-expect-error
|
|
14627
|
-
var split = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y * 2 + x];
|
|
14628
|
-
var texOffset = split[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
|
|
14629
|
-
var dw = ((x + x + 1) / col - 1) / 2;
|
|
14630
|
-
var dh = ((y + y + 1) / row - 1) / 2;
|
|
14631
|
-
var tox = split[0];
|
|
14632
|
-
var toy = split[1];
|
|
14633
|
-
var tsx = split[4] ? split[3] : split[2];
|
|
14634
|
-
var tsy = split[4] ? split[2] : split[3];
|
|
14635
|
-
var origin_1 = [
|
|
14636
|
-
originData[0] / col + dw,
|
|
14637
|
-
originData[1] / row + dh,
|
|
14638
|
-
originData[2] / col + dw,
|
|
14639
|
-
originData[3] / row + dh,
|
|
14640
|
-
originData[4] / col + dw,
|
|
14641
|
-
originData[5] / row + dh,
|
|
14642
|
-
originData[6] / col + dw,
|
|
14643
|
-
originData[7] / row + dh,
|
|
14644
|
-
];
|
|
14645
|
-
atlasOffset.push(texOffset[0] * tsx + tox, texOffset[1] * tsy + toy, texOffset[2] * tsx + tox, texOffset[3] * tsy + toy, texOffset[4] * tsx + tox, texOffset[5] * tsy + toy, texOffset[6] * tsx + tox, texOffset[7] * tsy + toy);
|
|
14646
|
-
position.push((origin_1[0]) * sx, (origin_1[1]) * sy, 0.0, (origin_1[2]) * sx, (origin_1[3]) * sy, 0.0, (origin_1[4]) * sx, (origin_1[5]) * sy, 0.0, (origin_1[6]) * sx, (origin_1[7]) * sy, 0.0);
|
|
14647
|
-
index.push(base, 1 + base, 2 + base, 2 + base, 1 + base, 3 + base);
|
|
14580
|
+
SpriteColorPlayable.prototype.fromData = function (clipData) {
|
|
14581
|
+
var _a;
|
|
14582
|
+
this.clipData = clipData;
|
|
14583
|
+
var colorOverLifetime = clipData.colorOverLifetime;
|
|
14584
|
+
if (colorOverLifetime) {
|
|
14585
|
+
this.opacityOverLifetime = createValueGetter((_a = colorOverLifetime.opacity) !== null && _a !== void 0 ? _a : 1);
|
|
14586
|
+
if (colorOverLifetime.color && colorOverLifetime.color[0] === ValueType$1.GRADIENT_COLOR) {
|
|
14587
|
+
this.colorOverLifetime = colorStopsFromGradient(colorOverLifetime.color[1]);
|
|
14648
14588
|
}
|
|
14649
14589
|
}
|
|
14650
|
-
this.
|
|
14651
|
-
return
|
|
14590
|
+
this.startColor = clipData.startColor || [1, 1, 1, 1];
|
|
14591
|
+
return this;
|
|
14652
14592
|
};
|
|
14653
|
-
|
|
14654
|
-
|
|
14655
|
-
|
|
14656
|
-
|
|
14657
|
-
|
|
14593
|
+
return SpriteColorPlayable;
|
|
14594
|
+
}(Playable));
|
|
14595
|
+
var SpriteComponent = /** @class */ (function (_super) {
|
|
14596
|
+
__extends(SpriteComponent, _super);
|
|
14597
|
+
function SpriteComponent(engine, props) {
|
|
14598
|
+
var _this = _super.call(this, engine) || this;
|
|
14599
|
+
_this.color = [1, 1, 1, 1];
|
|
14600
|
+
_this.visible = true;
|
|
14601
|
+
_this.getHitTestParams = function (force) {
|
|
14602
|
+
var _a;
|
|
14603
|
+
var ui = _this.interaction;
|
|
14604
|
+
if ((force || ui)) {
|
|
14605
|
+
var area = _this.getBoundingBox();
|
|
14606
|
+
if (area) {
|
|
14607
|
+
return {
|
|
14608
|
+
behavior: ((_a = _this.interaction) === null || _a === void 0 ? void 0 : _a.behavior) || 0,
|
|
14609
|
+
type: area.type,
|
|
14610
|
+
triangles: area.area,
|
|
14611
|
+
backfaceCulling: _this.renderer.side === SideMode$1.FRONT,
|
|
14612
|
+
};
|
|
14613
|
+
}
|
|
14614
|
+
}
|
|
14615
|
+
};
|
|
14616
|
+
if (props) {
|
|
14617
|
+
_this.fromData(props);
|
|
14658
14618
|
}
|
|
14659
|
-
return
|
|
14619
|
+
return _this;
|
|
14620
|
+
}
|
|
14621
|
+
/**
|
|
14622
|
+
* 设置当前 Mesh 的可见性。
|
|
14623
|
+
* @param visible - true:可见,false:不可见
|
|
14624
|
+
*/
|
|
14625
|
+
SpriteComponent.prototype.setVisible = function (visible) {
|
|
14626
|
+
this.visible = visible;
|
|
14660
14627
|
};
|
|
14661
14628
|
/**
|
|
14662
|
-
*
|
|
14663
|
-
* @returns
|
|
14629
|
+
* 获取当前 Mesh 的可见性。
|
|
14664
14630
|
*/
|
|
14665
|
-
SpriteComponent.prototype.
|
|
14666
|
-
|
|
14631
|
+
SpriteComponent.prototype.getVisible = function () {
|
|
14632
|
+
return this.visible;
|
|
14633
|
+
};
|
|
14634
|
+
SpriteComponent.prototype.render = function (renderer) {
|
|
14635
|
+
if (!this.getVisible()) {
|
|
14667
14636
|
return;
|
|
14668
14637
|
}
|
|
14669
|
-
var
|
|
14670
|
-
var
|
|
14671
|
-
|
|
14672
|
-
|
|
14673
|
-
worldMatrix.transformPoint(triangle.p1);
|
|
14674
|
-
worldMatrix.transformPoint(triangle.p2);
|
|
14675
|
-
});
|
|
14676
|
-
return {
|
|
14677
|
-
type: exports.HitTestType.triangle,
|
|
14678
|
-
area: triangles,
|
|
14679
|
-
};
|
|
14680
|
-
};
|
|
14681
|
-
// TODO: [1.31] @十弦 https://github.com/galacean/effects-runtime/commit/fe8736540b9a461d8e96658f4d755ff8089a263b#diff-a3618f4527c5fe6e842f20d67d5c82984568502c6bf6fdfcbd24f69e2894ca90
|
|
14682
|
-
SpriteComponent.prototype.fromData = function (data) {
|
|
14683
|
-
var _a, _b, _c, _d, _e, _f;
|
|
14684
|
-
_super.prototype.fromData.call(this, data);
|
|
14685
|
-
var interaction = data.interaction, options = data.options, _g = data.listIndex, listIndex = _g === void 0 ? 0 : _g;
|
|
14686
|
-
var renderer = data.renderer;
|
|
14687
|
-
if (!renderer) {
|
|
14688
|
-
//@ts-expect-error
|
|
14689
|
-
renderer = {};
|
|
14638
|
+
var material = this.material;
|
|
14639
|
+
var geo = this.geometry;
|
|
14640
|
+
if (renderer.renderingData.currentFrame.globalUniforms) {
|
|
14641
|
+
renderer.setGlobalMatrix('effects_ObjectToWorld', this.transform.getWorldMatrix());
|
|
14690
14642
|
}
|
|
14691
|
-
this.
|
|
14692
|
-
|
|
14693
|
-
|
|
14694
|
-
|
|
14695
|
-
texture: (_c = renderer.texture) !== null && _c !== void 0 ? _c : this.engine.emptyTexture,
|
|
14696
|
-
occlusion: !!(renderer.occlusion),
|
|
14697
|
-
transparentOcclusion: !!(renderer.transparentOcclusion) || (renderer.maskMode === MaskMode$1.MASK),
|
|
14698
|
-
side: (_d = renderer.side) !== null && _d !== void 0 ? _d : SideMode$1.DOUBLE,
|
|
14699
|
-
shape: renderer.shape,
|
|
14700
|
-
mask: (_e = renderer.mask) !== null && _e !== void 0 ? _e : 0,
|
|
14701
|
-
maskMode: (_f = renderer.maskMode) !== null && _f !== void 0 ? _f : MaskMode$1.NONE,
|
|
14702
|
-
order: listIndex,
|
|
14703
|
-
};
|
|
14704
|
-
this.emptyTexture = this.engine.emptyTexture;
|
|
14705
|
-
this.splits = data.splits || singleSplits;
|
|
14706
|
-
this.textureSheetAnimation = data.textureSheetAnimation;
|
|
14707
|
-
this.cachePrefix = '-';
|
|
14708
|
-
this.renderInfo = getImageItemRenderInfo(this);
|
|
14709
|
-
var geometry = this.createGeometry(glContext.TRIANGLES);
|
|
14710
|
-
var material = this.createMaterial(this.renderInfo, 2);
|
|
14711
|
-
this.worldMatrix = Matrix4.fromIdentity();
|
|
14712
|
-
this.material = material;
|
|
14713
|
-
this.geometry = geometry;
|
|
14714
|
-
this.name = 'MSprite' + seed$3++;
|
|
14715
|
-
var startColor = options.startColor || [1, 1, 1, 1];
|
|
14716
|
-
this.material.setVector4('_Color', new Vector4().setFromArray(startColor));
|
|
14717
|
-
this.material.setVector4('_TexOffset', new Vector4().setFromArray([0, 0, 1, 1]));
|
|
14718
|
-
this.setItem();
|
|
14719
|
-
// 添加K帧动画
|
|
14720
|
-
var colorTrack = this.item.getComponent(TimelineComponent).createTrack(Track, 'SpriteColorTrack');
|
|
14721
|
-
colorTrack.createClip(SpriteColorPlayable, 'SpriteColorClip').playable.fromData({ colorOverLifetime: data.colorOverLifetime, startColor: data.options.startColor });
|
|
14722
|
-
};
|
|
14723
|
-
SpriteComponent.prototype.toData = function () {
|
|
14724
|
-
_super.prototype.toData.call(this);
|
|
14643
|
+
this.material.setVector2('_Size', this.transform.size);
|
|
14644
|
+
// 执行 Geometry 的数据刷新
|
|
14645
|
+
geo.flush();
|
|
14646
|
+
renderer.drawGeometry(geo, material);
|
|
14725
14647
|
};
|
|
14726
|
-
SpriteComponent =
|
|
14648
|
+
SpriteComponent.prototype.start = function () {
|
|
14649
|
+
this.priority = this.item.listIndex;
|
|
14650
|
+
this.timelineComponent = this.item.getComponent(TimelineComponent);
|
|
14651
|
+
this.item.getHitTestParams = this.getHitTestParams;
|
|
14652
|
+
};
|
|
14653
|
+
SpriteComponent.prototype.update = function (dt) {
|
|
14654
|
+
var time = this.timelineComponent.getTime();
|
|
14655
|
+
var duration = this.item.duration;
|
|
14656
|
+
var life = Math.min(Math.max(time / duration, 0.0), 1.0);
|
|
14657
|
+
var ta = this.textureSheetAnimation;
|
|
14658
|
+
if (ta) {
|
|
14659
|
+
var total = ta.total || (ta.row * ta.col);
|
|
14660
|
+
var texRectX = 0;
|
|
14661
|
+
var texRectY = 0;
|
|
14662
|
+
var texRectW = 1;
|
|
14663
|
+
var texRectH = 1;
|
|
14664
|
+
var flip = void 0;
|
|
14665
|
+
if (this.splits) {
|
|
14666
|
+
var sp = this.splits[0];
|
|
14667
|
+
flip = sp[4];
|
|
14668
|
+
texRectX = sp[0];
|
|
14669
|
+
texRectY = sp[1];
|
|
14670
|
+
if (flip) {
|
|
14671
|
+
texRectW = sp[3];
|
|
14672
|
+
texRectH = sp[2];
|
|
14673
|
+
}
|
|
14674
|
+
else {
|
|
14675
|
+
texRectW = sp[2];
|
|
14676
|
+
texRectH = sp[3];
|
|
14677
|
+
}
|
|
14678
|
+
}
|
|
14679
|
+
var dx = void 0, dy = void 0;
|
|
14680
|
+
if (flip) {
|
|
14681
|
+
dx = 1 / ta.row * texRectW;
|
|
14682
|
+
dy = 1 / ta.col * texRectH;
|
|
14683
|
+
}
|
|
14684
|
+
else {
|
|
14685
|
+
dx = 1 / ta.col * texRectW;
|
|
14686
|
+
dy = 1 / ta.row * texRectH;
|
|
14687
|
+
}
|
|
14688
|
+
var texOffset = void 0;
|
|
14689
|
+
if (ta.animate) {
|
|
14690
|
+
var frameIndex = Math.round(life * (total - 1));
|
|
14691
|
+
var yIndex = Math.floor(frameIndex / ta.col);
|
|
14692
|
+
var xIndex = frameIndex - yIndex * ta.col;
|
|
14693
|
+
texOffset = flip ? [dx * yIndex, dy * (ta.col - xIndex)] : [dx * xIndex, dy * (1 + yIndex)];
|
|
14694
|
+
}
|
|
14695
|
+
else {
|
|
14696
|
+
texOffset = [0, dy];
|
|
14697
|
+
}
|
|
14698
|
+
this.material.getVector4('_TexOffset').setFromArray([
|
|
14699
|
+
texRectX + texOffset[0],
|
|
14700
|
+
texRectH + texRectY - texOffset[1],
|
|
14701
|
+
dx, dy,
|
|
14702
|
+
]);
|
|
14703
|
+
}
|
|
14704
|
+
};
|
|
14705
|
+
SpriteComponent.prototype.onDestroy = function () {
|
|
14706
|
+
if (this.item && this.item.composition) {
|
|
14707
|
+
this.item.composition.destroyTextures(this.getTextures());
|
|
14708
|
+
}
|
|
14709
|
+
};
|
|
14710
|
+
SpriteComponent.prototype.getItemInitData = function (item, idx, pointStartIndex, textureIndex) {
|
|
14711
|
+
var geoData = item.geoData;
|
|
14712
|
+
if (!geoData) {
|
|
14713
|
+
geoData = item.geoData = this.getItemGeometryData(item, idx);
|
|
14714
|
+
}
|
|
14715
|
+
var index = geoData.index;
|
|
14716
|
+
var idxCount = index.length;
|
|
14717
|
+
// @ts-expect-error
|
|
14718
|
+
var indexData = this.wireframe ? new Uint8Array([0, 1, 1, 3, 2, 3, 2, 0]) : new index.constructor(idxCount);
|
|
14719
|
+
if (!this.wireframe) {
|
|
14720
|
+
for (var i = 0; i < idxCount; i++) {
|
|
14721
|
+
indexData[i] = pointStartIndex + index[i];
|
|
14722
|
+
}
|
|
14723
|
+
}
|
|
14724
|
+
return {
|
|
14725
|
+
atlasOffset: geoData.atlasOffset,
|
|
14726
|
+
index: indexData,
|
|
14727
|
+
};
|
|
14728
|
+
};
|
|
14729
|
+
SpriteComponent.prototype.setItem = function () {
|
|
14730
|
+
var textures = [];
|
|
14731
|
+
var texture = this.renderer.texture;
|
|
14732
|
+
if (texture) {
|
|
14733
|
+
addItem(textures, texture);
|
|
14734
|
+
}
|
|
14735
|
+
texture = this.renderer.texture;
|
|
14736
|
+
var textureIndex = texture ? textures.indexOf(texture) : -1;
|
|
14737
|
+
var data = this.getItemInitData(this, 0, 0, textureIndex);
|
|
14738
|
+
var renderer = this.renderer;
|
|
14739
|
+
var texParams = this.material.getVector4('_TexParams');
|
|
14740
|
+
texParams.x = renderer.occlusion ? +(renderer.transparentOcclusion) : 1;
|
|
14741
|
+
texParams.y = +this.preMultiAlpha;
|
|
14742
|
+
texParams.z = renderer.renderMode;
|
|
14743
|
+
var attributes = {
|
|
14744
|
+
atlasOffset: new Float32Array(data.atlasOffset.length),
|
|
14745
|
+
index: new Uint16Array(data.index.length),
|
|
14746
|
+
};
|
|
14747
|
+
attributes.atlasOffset.set(data.atlasOffset);
|
|
14748
|
+
attributes.index.set(data.index);
|
|
14749
|
+
var _a = this, material = _a.material, geometry = _a.geometry;
|
|
14750
|
+
var indexData = attributes.index;
|
|
14751
|
+
geometry.setIndexData(indexData);
|
|
14752
|
+
geometry.setAttributeData('atlasOffset', attributes.atlasOffset);
|
|
14753
|
+
geometry.setDrawCount(data.index.length);
|
|
14754
|
+
for (var i = 0; i < textures.length; i++) {
|
|
14755
|
+
var texture_1 = textures[i];
|
|
14756
|
+
material.setTexture('uSampler' + i, texture_1);
|
|
14757
|
+
}
|
|
14758
|
+
// FIXME: 内存泄漏的临时方案,后面再调整
|
|
14759
|
+
var emptyTexture = this.emptyTexture;
|
|
14760
|
+
for (var k = textures.length; k < exports.maxSpriteMeshItemCount; k++) {
|
|
14761
|
+
material.setTexture('uSampler' + k, emptyTexture);
|
|
14762
|
+
}
|
|
14763
|
+
};
|
|
14764
|
+
SpriteComponent.prototype.createGeometry = function (mode) {
|
|
14765
|
+
var maxVertex = 12 * this.splits.length;
|
|
14766
|
+
return Geometry.create(this.engine, {
|
|
14767
|
+
attributes: {
|
|
14768
|
+
aPos: {
|
|
14769
|
+
type: glContext.FLOAT,
|
|
14770
|
+
size: 3,
|
|
14771
|
+
data: new Float32Array([
|
|
14772
|
+
-0.5, 0.5, 0,
|
|
14773
|
+
-0.5, -0.5, 0,
|
|
14774
|
+
0.5, 0.5, 0,
|
|
14775
|
+
0.5, -0.5, 0, //右下
|
|
14776
|
+
]),
|
|
14777
|
+
},
|
|
14778
|
+
atlasOffset: {
|
|
14779
|
+
size: 2,
|
|
14780
|
+
offset: 0,
|
|
14781
|
+
releasable: true,
|
|
14782
|
+
type: glContext.FLOAT,
|
|
14783
|
+
data: new Float32Array(0),
|
|
14784
|
+
},
|
|
14785
|
+
},
|
|
14786
|
+
indices: { data: new Uint16Array(0), releasable: true },
|
|
14787
|
+
mode: mode,
|
|
14788
|
+
maxVertex: maxVertex,
|
|
14789
|
+
});
|
|
14790
|
+
};
|
|
14791
|
+
SpriteComponent.prototype.createMaterial = function (renderInfo, count) {
|
|
14792
|
+
var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
|
|
14793
|
+
var materialProps = {
|
|
14794
|
+
shader: spriteMeshShaderFromRenderInfo(renderInfo, count, 1),
|
|
14795
|
+
};
|
|
14796
|
+
this.preMultiAlpha = getPreMultiAlpha(blending);
|
|
14797
|
+
var material = Material.create(this.engine, materialProps);
|
|
14798
|
+
var states = {
|
|
14799
|
+
side: side,
|
|
14800
|
+
blending: true,
|
|
14801
|
+
blendMode: blending,
|
|
14802
|
+
mask: mask,
|
|
14803
|
+
maskMode: maskMode,
|
|
14804
|
+
depthTest: true,
|
|
14805
|
+
depthMask: occlusion,
|
|
14806
|
+
};
|
|
14807
|
+
material.blending = states.blending;
|
|
14808
|
+
material.stencilRef = states.mask !== undefined ? [states.mask, states.mask] : undefined;
|
|
14809
|
+
material.depthTest = states.depthTest;
|
|
14810
|
+
material.depthMask = states.depthMask;
|
|
14811
|
+
setBlendMode(material, states.blendMode);
|
|
14812
|
+
setMaskMode(material, states.maskMode);
|
|
14813
|
+
setSideMode(material, states.side);
|
|
14814
|
+
if (!material.hasUniform('_Color')) {
|
|
14815
|
+
material.setVector4('_Color', new Vector4(0, 0, 0, 1));
|
|
14816
|
+
}
|
|
14817
|
+
if (!material.hasUniform('_TexOffset')) {
|
|
14818
|
+
material.setVector4('_TexOffset', new Vector4());
|
|
14819
|
+
}
|
|
14820
|
+
if (!material.hasUniform('_TexParams')) {
|
|
14821
|
+
material.setVector4('_TexParams', new Vector4());
|
|
14822
|
+
}
|
|
14823
|
+
return material;
|
|
14824
|
+
};
|
|
14825
|
+
SpriteComponent.prototype.getItemGeometryData = function (item, aIndex) {
|
|
14826
|
+
var splits = item.splits, renderer = item.renderer, textureSheetAnimation = item.textureSheetAnimation;
|
|
14827
|
+
var sx = 1, sy = 1;
|
|
14828
|
+
if (renderer.shape) {
|
|
14829
|
+
var _a = renderer.shape, index_1 = _a.index, aPoint = _a.aPoint;
|
|
14830
|
+
var point = new Float32Array(aPoint);
|
|
14831
|
+
var position_1 = [];
|
|
14832
|
+
var atlasOffset_1 = [];
|
|
14833
|
+
for (var i = 0; i < point.length; i += 6) {
|
|
14834
|
+
point[i] *= sx;
|
|
14835
|
+
point[i + 1] *= sy;
|
|
14836
|
+
atlasOffset_1.push(aPoint[i + 2], aPoint[i + 3]);
|
|
14837
|
+
position_1.push(point[i], point[i + 1], 0.0);
|
|
14838
|
+
}
|
|
14839
|
+
this.geometry.setAttributeData('aPos', new Float32Array(position_1));
|
|
14840
|
+
return {
|
|
14841
|
+
index: index_1,
|
|
14842
|
+
atlasOffset: atlasOffset_1,
|
|
14843
|
+
};
|
|
14844
|
+
}
|
|
14845
|
+
var originData = [-.5, .5, -.5, -.5, .5, .5, .5, -.5];
|
|
14846
|
+
var atlasOffset = [];
|
|
14847
|
+
var index = [];
|
|
14848
|
+
var col = 2;
|
|
14849
|
+
var row = 2;
|
|
14850
|
+
if (splits.length === 1) {
|
|
14851
|
+
col = 1;
|
|
14852
|
+
row = 1;
|
|
14853
|
+
}
|
|
14854
|
+
var position = [];
|
|
14855
|
+
for (var x = 0; x < col; x++) {
|
|
14856
|
+
for (var y = 0; y < row; y++) {
|
|
14857
|
+
var base = (y * 2 + x) * 4;
|
|
14858
|
+
// @ts-expect-error
|
|
14859
|
+
var split = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y * 2 + x];
|
|
14860
|
+
var texOffset = split[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
|
|
14861
|
+
var dw = ((x + x + 1) / col - 1) / 2;
|
|
14862
|
+
var dh = ((y + y + 1) / row - 1) / 2;
|
|
14863
|
+
var tox = split[0];
|
|
14864
|
+
var toy = split[1];
|
|
14865
|
+
var tsx = split[4] ? split[3] : split[2];
|
|
14866
|
+
var tsy = split[4] ? split[2] : split[3];
|
|
14867
|
+
var origin_1 = [
|
|
14868
|
+
originData[0] / col + dw,
|
|
14869
|
+
originData[1] / row + dh,
|
|
14870
|
+
originData[2] / col + dw,
|
|
14871
|
+
originData[3] / row + dh,
|
|
14872
|
+
originData[4] / col + dw,
|
|
14873
|
+
originData[5] / row + dh,
|
|
14874
|
+
originData[6] / col + dw,
|
|
14875
|
+
originData[7] / row + dh,
|
|
14876
|
+
];
|
|
14877
|
+
atlasOffset.push(texOffset[0] * tsx + tox, texOffset[1] * tsy + toy, texOffset[2] * tsx + tox, texOffset[3] * tsy + toy, texOffset[4] * tsx + tox, texOffset[5] * tsy + toy, texOffset[6] * tsx + tox, texOffset[7] * tsy + toy);
|
|
14878
|
+
position.push((origin_1[0]) * sx, (origin_1[1]) * sy, 0.0, (origin_1[2]) * sx, (origin_1[3]) * sy, 0.0, (origin_1[4]) * sx, (origin_1[5]) * sy, 0.0, (origin_1[6]) * sx, (origin_1[7]) * sy, 0.0);
|
|
14879
|
+
index.push(base, 1 + base, 2 + base, 2 + base, 1 + base, 3 + base);
|
|
14880
|
+
}
|
|
14881
|
+
}
|
|
14882
|
+
this.geometry.setAttributeData('aPos', new Float32Array(position));
|
|
14883
|
+
return { index: index, atlasOffset: atlasOffset };
|
|
14884
|
+
};
|
|
14885
|
+
SpriteComponent.prototype.getTextures = function () {
|
|
14886
|
+
var ret = [];
|
|
14887
|
+
var tex = this.renderer.texture;
|
|
14888
|
+
if (tex) {
|
|
14889
|
+
ret.push(tex);
|
|
14890
|
+
}
|
|
14891
|
+
return ret;
|
|
14892
|
+
};
|
|
14893
|
+
/**
|
|
14894
|
+
* 获取图层包围盒的类型和世界坐标
|
|
14895
|
+
* @returns
|
|
14896
|
+
*/
|
|
14897
|
+
SpriteComponent.prototype.getBoundingBox = function () {
|
|
14898
|
+
if (!this.item) {
|
|
14899
|
+
return;
|
|
14900
|
+
}
|
|
14901
|
+
var worldMatrix = this.transform.getWorldMatrix();
|
|
14902
|
+
var triangles = trianglesFromRect(Vector3.ZERO, 1 / 2, 1 / 2);
|
|
14903
|
+
triangles.forEach(function (triangle) {
|
|
14904
|
+
worldMatrix.transformPoint(triangle.p0);
|
|
14905
|
+
worldMatrix.transformPoint(triangle.p1);
|
|
14906
|
+
worldMatrix.transformPoint(triangle.p2);
|
|
14907
|
+
});
|
|
14908
|
+
return {
|
|
14909
|
+
type: exports.HitTestType.triangle,
|
|
14910
|
+
area: triangles,
|
|
14911
|
+
};
|
|
14912
|
+
};
|
|
14913
|
+
// TODO: [1.31] @十弦 https://github.com/galacean/effects-runtime/commit/fe8736540b9a461d8e96658f4d755ff8089a263b#diff-a3618f4527c5fe6e842f20d67d5c82984568502c6bf6fdfcbd24f69e2894ca90
|
|
14914
|
+
SpriteComponent.prototype.fromData = function (data) {
|
|
14915
|
+
var _a, _b, _c, _d, _e, _f;
|
|
14916
|
+
_super.prototype.fromData.call(this, data);
|
|
14917
|
+
var interaction = data.interaction, options = data.options, _g = data.listIndex, listIndex = _g === void 0 ? 0 : _g;
|
|
14918
|
+
var renderer = data.renderer;
|
|
14919
|
+
if (!renderer) {
|
|
14920
|
+
//@ts-expect-error
|
|
14921
|
+
renderer = {};
|
|
14922
|
+
}
|
|
14923
|
+
this.interaction = interaction;
|
|
14924
|
+
this.renderer = {
|
|
14925
|
+
renderMode: (_a = renderer.renderMode) !== null && _a !== void 0 ? _a : RenderMode$1.BILLBOARD,
|
|
14926
|
+
blending: (_b = renderer.blending) !== null && _b !== void 0 ? _b : BlendingMode$1.ALPHA,
|
|
14927
|
+
texture: (_c = renderer.texture) !== null && _c !== void 0 ? _c : this.engine.emptyTexture,
|
|
14928
|
+
occlusion: !!(renderer.occlusion),
|
|
14929
|
+
transparentOcclusion: !!(renderer.transparentOcclusion) || (renderer.maskMode === MaskMode$1.MASK),
|
|
14930
|
+
side: (_d = renderer.side) !== null && _d !== void 0 ? _d : SideMode$1.DOUBLE,
|
|
14931
|
+
shape: renderer.shape,
|
|
14932
|
+
mask: (_e = renderer.mask) !== null && _e !== void 0 ? _e : 0,
|
|
14933
|
+
maskMode: (_f = renderer.maskMode) !== null && _f !== void 0 ? _f : MaskMode$1.NONE,
|
|
14934
|
+
order: listIndex,
|
|
14935
|
+
};
|
|
14936
|
+
this.emptyTexture = this.engine.emptyTexture;
|
|
14937
|
+
this.splits = data.splits || singleSplits;
|
|
14938
|
+
this.textureSheetAnimation = data.textureSheetAnimation;
|
|
14939
|
+
this.cachePrefix = '-';
|
|
14940
|
+
this.renderInfo = getImageItemRenderInfo(this);
|
|
14941
|
+
var geometry = this.createGeometry(glContext.TRIANGLES);
|
|
14942
|
+
var material = this.createMaterial(this.renderInfo, 2);
|
|
14943
|
+
this.worldMatrix = Matrix4.fromIdentity();
|
|
14944
|
+
this.material = material;
|
|
14945
|
+
this.geometry = geometry;
|
|
14946
|
+
this.name = 'MSprite' + seed$2++;
|
|
14947
|
+
var startColor = options.startColor || [1, 1, 1, 1];
|
|
14948
|
+
this.material.setVector4('_Color', new Vector4().setFromArray(startColor));
|
|
14949
|
+
this.material.setVector4('_TexOffset', new Vector4().setFromArray([0, 0, 1, 1]));
|
|
14950
|
+
this.setItem();
|
|
14951
|
+
// 添加K帧动画
|
|
14952
|
+
var colorTrack = this.item.getComponent(TimelineComponent).createTrack(Track, 'SpriteColorTrack');
|
|
14953
|
+
colorTrack.createClip(SpriteColorPlayable, 'SpriteColorClip').playable.fromData({ colorOverLifetime: data.colorOverLifetime, startColor: data.options.startColor });
|
|
14954
|
+
};
|
|
14955
|
+
SpriteComponent.prototype.toData = function () {
|
|
14956
|
+
_super.prototype.toData.call(this);
|
|
14957
|
+
};
|
|
14958
|
+
SpriteComponent = __decorate([
|
|
14727
14959
|
effectsClass(exports.DataType.SpriteComponent)
|
|
14728
14960
|
], SpriteComponent);
|
|
14729
14961
|
return SpriteComponent;
|
|
@@ -17716,7 +17948,7 @@ var ParticleSystem = /** @class */ (function (_super) {
|
|
|
17716
17948
|
sprite[1] = tsa.animationDuration.getValue(lifetime);
|
|
17717
17949
|
sprite[2] = tsa.cycles.getValue(lifetime);
|
|
17718
17950
|
}
|
|
17719
|
-
var rot = tempRot
|
|
17951
|
+
var rot = tempRot;
|
|
17720
17952
|
if (options.start3DRotation) {
|
|
17721
17953
|
// @ts-expect-error
|
|
17722
17954
|
rot.set(options.startRotationX.getValue(lifetime), options.startRotationY.getValue(lifetime), options.startRotationZ.getValue(lifetime));
|
|
@@ -17732,7 +17964,7 @@ var ParticleSystem = /** @class */ (function (_super) {
|
|
|
17732
17964
|
if (color.length === 3) {
|
|
17733
17965
|
color[3] = 1;
|
|
17734
17966
|
}
|
|
17735
|
-
var size = tempSize
|
|
17967
|
+
var size = tempSize;
|
|
17736
17968
|
if (options.start3DSize) {
|
|
17737
17969
|
size.x = options.startSizeX.getValue(lifetime);
|
|
17738
17970
|
size.y = options.startSizeY.getValue(lifetime);
|
|
@@ -17894,7 +18126,8 @@ var ParticleSystem = /** @class */ (function (_super) {
|
|
|
17894
18126
|
separateAxes: false,
|
|
17895
18127
|
x: createValueGetter(('size' in sizeOverLifetime ? sizeOverLifetime.size : sizeOverLifetime.x) || 1),
|
|
17896
18128
|
};
|
|
17897
|
-
|
|
18129
|
+
renderer.anchor = renderer.anchor || [0, 0];
|
|
18130
|
+
var anchor = Vector2.fromArray(renderer.anchor);
|
|
17898
18131
|
this.options = {
|
|
17899
18132
|
particleFollowParent: !!options.particleFollowParent,
|
|
17900
18133
|
startLifetime: createValueGetter(options.startLifetime),
|
|
@@ -17902,488 +18135,254 @@ var ParticleSystem = /** @class */ (function (_super) {
|
|
|
17902
18135
|
startSpeed: createValueGetter(positionOverLifetime.startSpeed || 0),
|
|
17903
18136
|
startColor: createValueGetter(options.startColor),
|
|
17904
18137
|
// duration:vfxItem.duration || 1,
|
|
17905
|
-
looping: false,
|
|
17906
|
-
maxCount: (_e = options.maxCount) !== null && _e !== void 0 ? _e : 0,
|
|
17907
|
-
gravityModifier: createValueGetter(gravityModifier || 0),
|
|
17908
|
-
gravity: gravity,
|
|
17909
|
-
start3DSize: !!options.start3DSize,
|
|
17910
|
-
startTurbulence: startTurbulence,
|
|
17911
|
-
turbulence: turbulence,
|
|
17912
|
-
speedOverLifetime: positionOverLifetime.speedOverLifetime && createValueGetter(positionOverLifetime.speedOverLifetime),
|
|
17913
|
-
linearVelOverLifetime: linearVelOverLifetime,
|
|
17914
|
-
orbitalVelOverLifetime: orbitalVelOverLifetime,
|
|
17915
|
-
forceTarget: forceTarget,
|
|
17916
|
-
};
|
|
17917
|
-
if (options.startRotationZ) {
|
|
17918
|
-
this.options.startRotation = createValueGetter(options.startRotationZ || 0);
|
|
17919
|
-
}
|
|
17920
|
-
if (options.startRotationX || options.startRotationY) {
|
|
17921
|
-
this.options.start3DRotation = true;
|
|
17922
|
-
this.options.startRotationX = createValueGetter(options.startRotationX || 0);
|
|
17923
|
-
this.options.startRotationY = createValueGetter(options.startRotationY || 0);
|
|
17924
|
-
this.options.startRotationZ = createValueGetter(options.startRotationZ || 0);
|
|
17925
|
-
}
|
|
17926
|
-
if (options.start3DSize) {
|
|
17927
|
-
this.options.startSizeX = createValueGetter(options.startSizeX);
|
|
17928
|
-
this.options.startSizeY = createValueGetter(options.startSizeY);
|
|
17929
|
-
}
|
|
17930
|
-
else {
|
|
17931
|
-
this.options.startSize = createValueGetter(options.startSize);
|
|
17932
|
-
this.options.sizeAspect = createValueGetter(options.sizeAspect || 1);
|
|
17933
|
-
}
|
|
17934
|
-
var particleMeshProps = {
|
|
17935
|
-
// listIndex: vfxItem.listIndex,
|
|
17936
|
-
meshSlots: options.meshSlots,
|
|
17937
|
-
name: this.name,
|
|
17938
|
-
matrix: Matrix4.IDENTITY,
|
|
17939
|
-
filter: props.filter,
|
|
17940
|
-
shaderCachePrefix: shaderCachePrefix,
|
|
17941
|
-
renderMode: renderer.renderMode || RenderMode$1.BILLBOARD,
|
|
17942
|
-
side: renderer.side || SideMode$1.DOUBLE,
|
|
17943
|
-
gravity: gravity,
|
|
17944
|
-
// duration: vfxItem.duration,
|
|
17945
|
-
blending: renderer.blending || BlendingMode$1.ALPHA,
|
|
17946
|
-
rotationOverLifetime: rotationOverLifetime,
|
|
17947
|
-
gravityModifier: this.options.gravityModifier,
|
|
17948
|
-
linearVelOverLifetime: this.options.linearVelOverLifetime,
|
|
17949
|
-
orbitalVelOverLifetime: this.options.orbitalVelOverLifetime,
|
|
17950
|
-
speedOverLifetime: this.options.speedOverLifetime,
|
|
17951
|
-
sprite: textureSheetAnimation,
|
|
17952
|
-
occlusion: !!renderer.occlusion,
|
|
17953
|
-
transparentOcclusion: !!renderer.transparentOcclusion,
|
|
17954
|
-
maxCount: options.maxCount,
|
|
17955
|
-
mask: renderer.mask,
|
|
17956
|
-
maskMode: (_f = renderer.maskMode) !== null && _f !== void 0 ? _f : MaskMode$1.NONE,
|
|
17957
|
-
forceTarget: forceTarget,
|
|
17958
|
-
diffuse: renderer.texture,
|
|
17959
|
-
sizeOverLifetime: sizeOverLifetimeGetter,
|
|
17960
|
-
anchor: anchor,
|
|
17961
|
-
};
|
|
17962
|
-
if (colorOverLifetime) {
|
|
17963
|
-
var color = colorOverLifetime.color, opacity = colorOverLifetime.opacity;
|
|
17964
|
-
particleMeshProps.colorOverLifetime = {};
|
|
17965
|
-
if (opacity) {
|
|
17966
|
-
particleMeshProps.colorOverLifetime.opacity = createValueGetter(colorOverLifetime.opacity);
|
|
17967
|
-
}
|
|
17968
|
-
if (color) {
|
|
17969
|
-
if (color[0] === ValueType$1.GRADIENT_COLOR) {
|
|
17970
|
-
particleMeshProps.colorOverLifetime.color = colorOverLifetime.color[1];
|
|
17971
|
-
}
|
|
17972
|
-
else if (color[0] === ValueType$1.RGBA_COLOR) {
|
|
17973
|
-
particleMeshProps.colorOverLifetime.color = Texture.createWithData(this.engine, {
|
|
17974
|
-
data: new Uint8Array(color[1]),
|
|
17975
|
-
width: 1,
|
|
17976
|
-
height: 1,
|
|
17977
|
-
});
|
|
17978
|
-
}
|
|
17979
|
-
else if (color instanceof Texture) {
|
|
17980
|
-
particleMeshProps.colorOverLifetime.color = color;
|
|
17981
|
-
}
|
|
17982
|
-
}
|
|
17983
|
-
}
|
|
17984
|
-
var uvs = [];
|
|
17985
|
-
var textureMap = [0, 0, 1, 1];
|
|
17986
|
-
var flip;
|
|
17987
|
-
if (props.splits) {
|
|
17988
|
-
var s = props.splits[0];
|
|
17989
|
-
flip = s[4];
|
|
17990
|
-
textureMap = flip ? [s[0], s[1], s[3], s[2]] : [s[0], s[1], s[2], s[3]];
|
|
17991
|
-
}
|
|
17992
|
-
if (textureSheetAnimation && !textureSheetAnimation.animate) {
|
|
17993
|
-
var col = flip ? textureSheetAnimation.row : textureSheetAnimation.col;
|
|
17994
|
-
var row = flip ? textureSheetAnimation.col : textureSheetAnimation.row;
|
|
17995
|
-
var total = textureSheetAnimation.total || col * row;
|
|
17996
|
-
var index$1 = 0;
|
|
17997
|
-
for (var x = 0; x < col; x++) {
|
|
17998
|
-
for (var y = 0; y < row && index$1 < total; y++, index$1++) {
|
|
17999
|
-
uvs.push([
|
|
18000
|
-
x * textureMap[2] / col + textureMap[0],
|
|
18001
|
-
y * textureMap[3] / row + textureMap[1],
|
|
18002
|
-
textureMap[2] / col,
|
|
18003
|
-
textureMap[3] / row
|
|
18004
|
-
]);
|
|
18005
|
-
}
|
|
18006
|
-
}
|
|
18007
|
-
}
|
|
18008
|
-
else {
|
|
18009
|
-
uvs.push(textureMap);
|
|
18010
|
-
}
|
|
18011
|
-
this.uvs = uvs;
|
|
18012
|
-
// @ts-expect-error
|
|
18013
|
-
particleMeshProps.textureFlip = flip;
|
|
18014
|
-
var trails = props.trails;
|
|
18015
|
-
var trailMeshProps;
|
|
18016
|
-
if (trails) {
|
|
18017
|
-
this.trails = {
|
|
18018
|
-
lifetime: createValueGetter(trails.lifetime),
|
|
18019
|
-
dieWithParticles: trails.dieWithParticles !== false,
|
|
18020
|
-
sizeAffectsWidth: !!trails.sizeAffectsWidth,
|
|
18021
|
-
sizeAffectsLifetime: !!trails.sizeAffectsLifetime,
|
|
18022
|
-
inheritParticleColor: !!trails.inheritParticleColor,
|
|
18023
|
-
parentAffectsPosition: !!trails.parentAffectsPosition,
|
|
18024
|
-
};
|
|
18025
|
-
trailMeshProps = {
|
|
18026
|
-
name: 'Trail',
|
|
18027
|
-
matrix: Matrix4.IDENTITY,
|
|
18028
|
-
minimumVertexDistance: trails.minimumVertexDistance || 0.02,
|
|
18029
|
-
maxTrailCount: options.maxCount,
|
|
18030
|
-
pointCountPerTrail: Math.round(trails.maxPointPerTrail) || 32,
|
|
18031
|
-
blending: trails.blending,
|
|
18032
|
-
texture: trails.texture,
|
|
18033
|
-
opacityOverLifetime: createValueGetter(trails.opacityOverLifetime || 1),
|
|
18034
|
-
widthOverTrail: createValueGetter(trails.widthOverTrail || 1),
|
|
18035
|
-
// order: vfxItem.listIndex + (trails.orderOffset || 0),
|
|
18036
|
-
shaderCachePrefix: shaderCachePrefix,
|
|
18037
|
-
lifetime: this.trails.lifetime,
|
|
18038
|
-
occlusion: !!trails.occlusion,
|
|
18039
|
-
transparentOcclusion: !!trails.transparentOcclusion,
|
|
18040
|
-
textureMap: trails.textureMap,
|
|
18041
|
-
mask: renderer.mask,
|
|
18042
|
-
maskMode: renderer.maskMode,
|
|
18043
|
-
};
|
|
18044
|
-
if (trails.colorOverLifetime && trails.colorOverLifetime[0] === ValueType$1.GRADIENT_COLOR) {
|
|
18045
|
-
trailMeshProps.colorOverLifetime = trails.colorOverLifetime[1];
|
|
18046
|
-
}
|
|
18047
|
-
if (trails.colorOverTrail && trails.colorOverTrail[0] === ValueType$1.GRADIENT_COLOR) {
|
|
18048
|
-
trailMeshProps.colorOverTrail = trails.colorOverTrail[1];
|
|
18049
|
-
}
|
|
18050
|
-
}
|
|
18051
|
-
this.renderer = new ParticleSystemRenderer(this.engine, particleMeshProps, trailMeshProps);
|
|
18052
|
-
this.meshes = this.renderer.meshes;
|
|
18053
|
-
// this.item = vfxItem;
|
|
18054
|
-
var interaction = props.interaction;
|
|
18055
|
-
if (interaction) {
|
|
18056
|
-
this.interaction = {
|
|
18057
|
-
multiple: interaction.multiple,
|
|
18058
|
-
radius: interaction.radius,
|
|
18059
|
-
behavior: interaction.behavior,
|
|
18060
|
-
};
|
|
18061
|
-
}
|
|
18062
|
-
this.item.getHitTestParams = this.getHitTestParams;
|
|
18063
|
-
this.item._content = this;
|
|
18064
|
-
this.renderer.item = this.item;
|
|
18065
|
-
this.item.components.push(this.renderer);
|
|
18066
|
-
this.item.rendererComponents.push(this.renderer);
|
|
18067
|
-
// 添加粒子动画 clip
|
|
18068
|
-
var timeline = this.item.getComponent(TimelineComponent);
|
|
18069
|
-
timeline.createTrack(Track).createClip(ParticleBehaviourPlayable);
|
|
18070
|
-
};
|
|
18071
|
-
ParticleSystem = __decorate([
|
|
18072
|
-
effectsClass(exports.DataType.ParticleSystem)
|
|
18073
|
-
], ParticleSystem);
|
|
18074
|
-
return ParticleSystem;
|
|
18075
|
-
}(Component));
|
|
18076
|
-
// array performance better for small memory than Float32Array
|
|
18077
|
-
var tempDir = new Vector3();
|
|
18078
|
-
var tempSize$1 = new Vector2();
|
|
18079
|
-
var tempRot$1 = new Euler();
|
|
18080
|
-
var tmpDirX = new Vector3();
|
|
18081
|
-
var tmpDirY = new Vector3();
|
|
18082
|
-
var tempVec3 = new Vector3();
|
|
18083
|
-
var tempEuler = new Euler();
|
|
18084
|
-
var tempSprite = [0, 0, 0];
|
|
18085
|
-
var tempMat4 = new Matrix4();
|
|
18086
|
-
function getBurstOffsets(burstOffsets) {
|
|
18087
|
-
var ret = {};
|
|
18088
|
-
if (Array.isArray(burstOffsets)) {
|
|
18089
|
-
burstOffsets.forEach(function (arr) {
|
|
18090
|
-
var isArr = arr instanceof Array;
|
|
18091
|
-
var index = isArr ? arr[0] : arr.index;
|
|
18092
|
-
var offsets = ret[index];
|
|
18093
|
-
if (!offsets) {
|
|
18094
|
-
offsets = ret[index] = [];
|
|
18095
|
-
}
|
|
18096
|
-
if (isArr) {
|
|
18097
|
-
offsets.push(arr.slice(1, 4));
|
|
18098
|
-
}
|
|
18099
|
-
else {
|
|
18100
|
-
offsets.push([+arr.x, +arr.y, +arr.z]);
|
|
18101
|
-
}
|
|
18102
|
-
});
|
|
18103
|
-
}
|
|
18104
|
-
return ret;
|
|
18105
|
-
}
|
|
18106
|
-
function randomArrItem(arr, keepArr) {
|
|
18107
|
-
var index = Math.floor(Math.random() * arr.length);
|
|
18108
|
-
var item = arr[index];
|
|
18109
|
-
if (!keepArr) {
|
|
18110
|
-
arr.splice(index, 1);
|
|
18111
|
-
}
|
|
18112
|
-
return item;
|
|
18113
|
-
}
|
|
18114
|
-
|
|
18115
|
-
/**
|
|
18116
|
-
* @since 2.0.0
|
|
18117
|
-
* @internal
|
|
18118
|
-
*/
|
|
18119
|
-
var ParticleBehaviourPlayable = /** @class */ (function (_super) {
|
|
18120
|
-
__extends(ParticleBehaviourPlayable, _super);
|
|
18121
|
-
function ParticleBehaviourPlayable() {
|
|
18122
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
18123
|
-
}
|
|
18124
|
-
ParticleBehaviourPlayable.prototype.onPlayablePlay = function () {
|
|
18125
|
-
this.particleSystem = this.bindingItem.getComponent(ParticleSystem);
|
|
18126
|
-
if (this.particleSystem) {
|
|
18127
|
-
this.particleSystem.name = this.bindingItem.name;
|
|
18128
|
-
this.particleSystem.start();
|
|
18129
|
-
this.particleSystem.initEmitterTransform();
|
|
18138
|
+
looping: false,
|
|
18139
|
+
maxCount: (_e = options.maxCount) !== null && _e !== void 0 ? _e : 0,
|
|
18140
|
+
gravityModifier: createValueGetter(gravityModifier || 0),
|
|
18141
|
+
gravity: gravity,
|
|
18142
|
+
start3DSize: !!options.start3DSize,
|
|
18143
|
+
startTurbulence: startTurbulence,
|
|
18144
|
+
turbulence: turbulence,
|
|
18145
|
+
speedOverLifetime: positionOverLifetime.speedOverLifetime && createValueGetter(positionOverLifetime.speedOverLifetime),
|
|
18146
|
+
linearVelOverLifetime: linearVelOverLifetime,
|
|
18147
|
+
orbitalVelOverLifetime: orbitalVelOverLifetime,
|
|
18148
|
+
forceTarget: forceTarget,
|
|
18149
|
+
};
|
|
18150
|
+
if (options.startRotationZ) {
|
|
18151
|
+
this.options.startRotation = createValueGetter(options.startRotationZ || 0);
|
|
18130
18152
|
}
|
|
18131
|
-
|
|
18132
|
-
|
|
18133
|
-
|
|
18134
|
-
|
|
18135
|
-
this.
|
|
18136
|
-
// TODO: [1.31] @十弦 验证 https://github.com/galacean/effects-runtime/commit/3e7d73d37b7d98c2a25e4544e80e928b17801ccd#diff-fae062f28caf3771cfedd3a20dc22f9749bd054c7541bf2fd50a9a5e413153d4
|
|
18137
|
-
// particleSystem.setParentTransform(parentItem.transform);
|
|
18138
|
-
particleSystem.setVisible(true);
|
|
18139
|
-
particleSystem.onUpdate(dt);
|
|
18153
|
+
if (options.startRotationX || options.startRotationY) {
|
|
18154
|
+
this.options.start3DRotation = true;
|
|
18155
|
+
this.options.startRotationX = createValueGetter(options.startRotationX || 0);
|
|
18156
|
+
this.options.startRotationY = createValueGetter(options.startRotationY || 0);
|
|
18157
|
+
this.options.startRotationZ = createValueGetter(options.startRotationZ || 0);
|
|
18140
18158
|
}
|
|
18141
|
-
|
|
18142
|
-
|
|
18143
|
-
|
|
18144
|
-
|
|
18145
|
-
var CalculateLoader = /** @class */ (function (_super) {
|
|
18146
|
-
__extends(CalculateLoader, _super);
|
|
18147
|
-
function CalculateLoader() {
|
|
18148
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
18149
|
-
}
|
|
18150
|
-
return CalculateLoader;
|
|
18151
|
-
}(AbstractPlugin));
|
|
18152
|
-
|
|
18153
|
-
var AnimationStream = /** @class */ (function () {
|
|
18154
|
-
function AnimationStream(playable) {
|
|
18155
|
-
this.curveValues = {};
|
|
18156
|
-
this.playable = playable;
|
|
18157
|
-
}
|
|
18158
|
-
AnimationStream.prototype.setCurveValue = function (componentType, propertyName, value) {
|
|
18159
|
-
if (!this.findCurveValue(componentType, propertyName)) {
|
|
18160
|
-
this.curveValues[componentType + propertyName] = { componentType: componentType, propertyName: propertyName, value: value };
|
|
18159
|
+
if (options.start3DSize) {
|
|
18160
|
+
this.options.startSizeX = createValueGetter(options.startSizeX);
|
|
18161
|
+
this.options.startSizeY = createValueGetter(options.startSizeY);
|
|
18161
18162
|
}
|
|
18162
18163
|
else {
|
|
18163
|
-
this.
|
|
18164
|
-
|
|
18165
|
-
return this.curveValues[componentType + propertyName];
|
|
18166
|
-
};
|
|
18167
|
-
AnimationStream.prototype.findCurveValue = function (componentType, propertyName) {
|
|
18168
|
-
return this.curveValues[componentType + propertyName];
|
|
18169
|
-
};
|
|
18170
|
-
AnimationStream.prototype.getInputStream = function (index) {
|
|
18171
|
-
var inputPlayable = this.playable.getInput(index);
|
|
18172
|
-
if (inputPlayable instanceof AnimationPlayable) {
|
|
18173
|
-
return inputPlayable.animationStream;
|
|
18174
|
-
}
|
|
18175
|
-
};
|
|
18176
|
-
return AnimationStream;
|
|
18177
|
-
}());
|
|
18178
|
-
|
|
18179
|
-
var AnimationPlayable = /** @class */ (function (_super) {
|
|
18180
|
-
__extends(AnimationPlayable, _super);
|
|
18181
|
-
function AnimationPlayable() {
|
|
18182
|
-
var _this = _super.call(this) || this;
|
|
18183
|
-
_this.animationStream = new AnimationStream(_this);
|
|
18184
|
-
return _this;
|
|
18185
|
-
}
|
|
18186
|
-
return AnimationPlayable;
|
|
18187
|
-
}(Playable));
|
|
18188
|
-
|
|
18189
|
-
var tempRot = new Euler();
|
|
18190
|
-
var tempSize = new Vector3(1, 1, 1);
|
|
18191
|
-
var tempPos = new Vector3();
|
|
18192
|
-
/**
|
|
18193
|
-
* @since 2.0.0
|
|
18194
|
-
* @internal
|
|
18195
|
-
*/
|
|
18196
|
-
var AnimationClipPlayable = /** @class */ (function (_super) {
|
|
18197
|
-
__extends(AnimationClipPlayable, _super);
|
|
18198
|
-
function AnimationClipPlayable() {
|
|
18199
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
18200
|
-
}
|
|
18201
|
-
AnimationClipPlayable.prototype.processFrame = function (dt) {
|
|
18202
|
-
if (this.bindingItem.composition) {
|
|
18203
|
-
this.sampleAnimation();
|
|
18164
|
+
this.options.startSize = createValueGetter(options.startSize);
|
|
18165
|
+
this.options.sizeAspect = createValueGetter(options.sizeAspect || 1);
|
|
18204
18166
|
}
|
|
18205
|
-
|
|
18206
|
-
|
|
18207
|
-
|
|
18208
|
-
|
|
18209
|
-
|
|
18210
|
-
|
|
18211
|
-
|
|
18212
|
-
|
|
18213
|
-
|
|
18214
|
-
|
|
18215
|
-
|
|
18216
|
-
|
|
18217
|
-
|
|
18218
|
-
|
|
18167
|
+
var particleMeshProps = {
|
|
18168
|
+
// listIndex: vfxItem.listIndex,
|
|
18169
|
+
meshSlots: options.meshSlots,
|
|
18170
|
+
name: this.name,
|
|
18171
|
+
matrix: Matrix4.IDENTITY,
|
|
18172
|
+
filter: props.filter,
|
|
18173
|
+
shaderCachePrefix: shaderCachePrefix,
|
|
18174
|
+
renderMode: renderer.renderMode || RenderMode$1.BILLBOARD,
|
|
18175
|
+
side: renderer.side || SideMode$1.DOUBLE,
|
|
18176
|
+
gravity: gravity,
|
|
18177
|
+
// duration: vfxItem.duration,
|
|
18178
|
+
blending: renderer.blending || BlendingMode$1.ALPHA,
|
|
18179
|
+
rotationOverLifetime: rotationOverLifetime,
|
|
18180
|
+
gravityModifier: this.options.gravityModifier,
|
|
18181
|
+
linearVelOverLifetime: this.options.linearVelOverLifetime,
|
|
18182
|
+
orbitalVelOverLifetime: this.options.orbitalVelOverLifetime,
|
|
18183
|
+
speedOverLifetime: this.options.speedOverLifetime,
|
|
18184
|
+
sprite: textureSheetAnimation,
|
|
18185
|
+
occlusion: !!renderer.occlusion,
|
|
18186
|
+
transparentOcclusion: !!renderer.transparentOcclusion,
|
|
18187
|
+
maxCount: options.maxCount,
|
|
18188
|
+
mask: renderer.mask,
|
|
18189
|
+
maskMode: (_f = renderer.maskMode) !== null && _f !== void 0 ? _f : MaskMode$1.NONE,
|
|
18190
|
+
forceTarget: forceTarget,
|
|
18191
|
+
diffuse: renderer.texture,
|
|
18192
|
+
sizeOverLifetime: sizeOverLifetimeGetter,
|
|
18193
|
+
anchor: anchor,
|
|
18194
|
+
};
|
|
18195
|
+
if (colorOverLifetime) {
|
|
18196
|
+
var color = colorOverLifetime.color, opacity = colorOverLifetime.opacity;
|
|
18197
|
+
particleMeshProps.colorOverLifetime = {};
|
|
18198
|
+
if (opacity) {
|
|
18199
|
+
particleMeshProps.colorOverLifetime.opacity = createValueGetter(colorOverLifetime.opacity);
|
|
18219
18200
|
}
|
|
18220
|
-
|
|
18221
|
-
|
|
18201
|
+
if (color) {
|
|
18202
|
+
if (color[0] === ValueType$1.GRADIENT_COLOR) {
|
|
18203
|
+
particleMeshProps.colorOverLifetime.color = colorOverLifetime.color[1];
|
|
18204
|
+
}
|
|
18205
|
+
else if (color[0] === ValueType$1.RGBA_COLOR) {
|
|
18206
|
+
particleMeshProps.colorOverLifetime.color = Texture.createWithData(this.engine, {
|
|
18207
|
+
data: new Uint8Array(color[1]),
|
|
18208
|
+
width: 1,
|
|
18209
|
+
height: 1,
|
|
18210
|
+
});
|
|
18211
|
+
}
|
|
18212
|
+
else if (color instanceof Texture) {
|
|
18213
|
+
particleMeshProps.colorOverLifetime.color = color;
|
|
18214
|
+
}
|
|
18222
18215
|
}
|
|
18223
|
-
var startSize = this.originalTransform.scale;
|
|
18224
|
-
this.bindingItem.transform.setScale(tempSize.x * startSize.x, tempSize.y * startSize.y, tempSize.z * startSize.z);
|
|
18225
|
-
// this.animationStream.setCurveValue('transform', 'scale.x', tempSize.x * startSize.x);
|
|
18226
|
-
// this.animationStream.setCurveValue('transform', 'scale.y', tempSize.y * startSize.y);
|
|
18227
|
-
// this.animationStream.setCurveValue('transform', 'scale.z', tempSize.z * startSize.z);
|
|
18228
18216
|
}
|
|
18229
|
-
|
|
18230
|
-
|
|
18231
|
-
|
|
18232
|
-
|
|
18233
|
-
|
|
18234
|
-
|
|
18235
|
-
|
|
18236
|
-
var rot = tempRot.addEulers(this.originalTransform.rotation, tempRot);
|
|
18237
|
-
this.bindingItem.transform.setRotation(rot.x, rot.y, rot.z);
|
|
18238
|
-
// this.animationStream.setCurveValue('transform', 'rotation.x', rot.x);
|
|
18239
|
-
// this.animationStream.setCurveValue('transform', 'rotation.y', rot.y);
|
|
18240
|
-
// this.animationStream.setCurveValue('transform', 'rotation.z', rot.z);
|
|
18217
|
+
var uvs = [];
|
|
18218
|
+
var textureMap = [0, 0, 1, 1];
|
|
18219
|
+
var flip;
|
|
18220
|
+
if (props.splits) {
|
|
18221
|
+
var s = props.splits[0];
|
|
18222
|
+
flip = s[4];
|
|
18223
|
+
textureMap = flip ? [s[0], s[1], s[3], s[2]] : [s[0], s[1], s[2], s[3]];
|
|
18241
18224
|
}
|
|
18242
|
-
if (
|
|
18243
|
-
var
|
|
18244
|
-
|
|
18245
|
-
|
|
18246
|
-
|
|
18225
|
+
if (textureSheetAnimation && !textureSheetAnimation.animate) {
|
|
18226
|
+
var col = flip ? textureSheetAnimation.row : textureSheetAnimation.col;
|
|
18227
|
+
var row = flip ? textureSheetAnimation.col : textureSheetAnimation.row;
|
|
18228
|
+
var total = textureSheetAnimation.total || col * row;
|
|
18229
|
+
var index$1 = 0;
|
|
18230
|
+
for (var x = 0; x < col; x++) {
|
|
18231
|
+
for (var y = 0; y < row && index$1 < total; y++, index$1++) {
|
|
18232
|
+
uvs.push([
|
|
18233
|
+
x * textureMap[2] / col + textureMap[0],
|
|
18234
|
+
y * textureMap[3] / row + textureMap[1],
|
|
18235
|
+
textureMap[2] / col,
|
|
18236
|
+
textureMap[3] / row
|
|
18237
|
+
]);
|
|
18238
|
+
}
|
|
18247
18239
|
}
|
|
18248
|
-
this.bindingItem.transform.setPosition(pos.x, pos.y, pos.z);
|
|
18249
|
-
// this.animationStream.setCurveValue('transform', 'position.x', pos.x);
|
|
18250
|
-
// this.animationStream.setCurveValue('transform', 'position.y', pos.y);
|
|
18251
|
-
// this.animationStream.setCurveValue('transform', 'position.z', pos.z);
|
|
18252
18240
|
}
|
|
18253
|
-
|
|
18254
|
-
|
|
18255
|
-
var _a;
|
|
18256
|
-
var scale = this.bindingItem.transform.scale;
|
|
18257
|
-
this.originalTransform = {
|
|
18258
|
-
position: this.bindingItem.transform.position.clone(),
|
|
18259
|
-
rotation: this.bindingItem.transform.getRotation().clone(),
|
|
18260
|
-
// TODO 编辑器 scale 没有z轴控制
|
|
18261
|
-
scale: new Vector3(scale.x, scale.y, scale.x),
|
|
18262
|
-
};
|
|
18263
|
-
var positionOverLifetime = data.positionOverLifetime;
|
|
18264
|
-
var rotationOverLifetime = data.rotationOverLifetime;
|
|
18265
|
-
var sizeOverLifetime = data.sizeOverLifetime;
|
|
18266
|
-
// TODO: 没有 K 帧数据的不需要传 positionOverLifetime 空对象
|
|
18267
|
-
if (positionOverLifetime && Object.keys(positionOverLifetime).length !== 0) {
|
|
18268
|
-
this.positionOverLifetime = positionOverLifetime;
|
|
18269
|
-
if (positionOverLifetime.path) {
|
|
18270
|
-
this.originalTransform.path = createValueGetter(positionOverLifetime.path);
|
|
18271
|
-
}
|
|
18272
|
-
var linearVelEnable = positionOverLifetime.linearX || positionOverLifetime.linearY || positionOverLifetime.linearZ;
|
|
18273
|
-
if (linearVelEnable) {
|
|
18274
|
-
this.linearVelOverLifetime = {
|
|
18275
|
-
x: positionOverLifetime.linearX && createValueGetter(positionOverLifetime.linearX),
|
|
18276
|
-
y: positionOverLifetime.linearY && createValueGetter(positionOverLifetime.linearY),
|
|
18277
|
-
z: positionOverLifetime.linearZ && createValueGetter(positionOverLifetime.linearZ),
|
|
18278
|
-
asMovement: positionOverLifetime.asMovement,
|
|
18279
|
-
enabled: !!linearVelEnable,
|
|
18280
|
-
};
|
|
18281
|
-
}
|
|
18282
|
-
var orbitalVelEnable = positionOverLifetime.orbitalX || positionOverLifetime.orbitalY || positionOverLifetime.orbitalZ;
|
|
18283
|
-
if (orbitalVelEnable) {
|
|
18284
|
-
this.orbitalVelOverLifetime = {
|
|
18285
|
-
x: positionOverLifetime.orbitalX && createValueGetter(positionOverLifetime.orbitalX),
|
|
18286
|
-
y: positionOverLifetime.orbitalY && createValueGetter(positionOverLifetime.orbitalY),
|
|
18287
|
-
z: positionOverLifetime.orbitalZ && createValueGetter(positionOverLifetime.orbitalZ),
|
|
18288
|
-
center: ensureVec3(positionOverLifetime.orbCenter),
|
|
18289
|
-
asRotation: positionOverLifetime.asRotation,
|
|
18290
|
-
enabled: !!orbitalVelEnable,
|
|
18291
|
-
};
|
|
18292
|
-
}
|
|
18293
|
-
this.speedOverLifetime = positionOverLifetime.speedOverLifetime && createValueGetter(positionOverLifetime.speedOverLifetime);
|
|
18241
|
+
else {
|
|
18242
|
+
uvs.push(textureMap);
|
|
18294
18243
|
}
|
|
18295
|
-
|
|
18296
|
-
|
|
18297
|
-
|
|
18298
|
-
|
|
18299
|
-
|
|
18300
|
-
|
|
18244
|
+
this.uvs = uvs;
|
|
18245
|
+
// @ts-expect-error
|
|
18246
|
+
particleMeshProps.textureFlip = flip;
|
|
18247
|
+
var trails = props.trails;
|
|
18248
|
+
var trailMeshProps;
|
|
18249
|
+
if (trails) {
|
|
18250
|
+
this.trails = {
|
|
18251
|
+
lifetime: createValueGetter(trails.lifetime),
|
|
18252
|
+
dieWithParticles: trails.dieWithParticles !== false,
|
|
18253
|
+
sizeAffectsWidth: !!trails.sizeAffectsWidth,
|
|
18254
|
+
sizeAffectsLifetime: !!trails.sizeAffectsLifetime,
|
|
18255
|
+
inheritParticleColor: !!trails.inheritParticleColor,
|
|
18256
|
+
parentAffectsPosition: !!trails.parentAffectsPosition,
|
|
18257
|
+
};
|
|
18258
|
+
trailMeshProps = {
|
|
18259
|
+
name: 'Trail',
|
|
18260
|
+
matrix: Matrix4.IDENTITY,
|
|
18261
|
+
minimumVertexDistance: trails.minimumVertexDistance || 0.02,
|
|
18262
|
+
maxTrailCount: options.maxCount,
|
|
18263
|
+
pointCountPerTrail: Math.round(trails.maxPointPerTrail) || 32,
|
|
18264
|
+
blending: trails.blending,
|
|
18265
|
+
texture: trails.texture,
|
|
18266
|
+
opacityOverLifetime: createValueGetter(trails.opacityOverLifetime || 1),
|
|
18267
|
+
widthOverTrail: createValueGetter(trails.widthOverTrail || 1),
|
|
18268
|
+
// order: vfxItem.listIndex + (trails.orderOffset || 0),
|
|
18269
|
+
shaderCachePrefix: shaderCachePrefix,
|
|
18270
|
+
lifetime: this.trails.lifetime,
|
|
18271
|
+
occlusion: !!trails.occlusion,
|
|
18272
|
+
transparentOcclusion: !!trails.transparentOcclusion,
|
|
18273
|
+
textureMap: trails.textureMap,
|
|
18274
|
+
mask: renderer.mask,
|
|
18275
|
+
maskMode: renderer.maskMode,
|
|
18276
|
+
};
|
|
18277
|
+
if (trails.colorOverLifetime && trails.colorOverLifetime[0] === ValueType$1.GRADIENT_COLOR) {
|
|
18278
|
+
trailMeshProps.colorOverLifetime = trails.colorOverLifetime[1];
|
|
18301
18279
|
}
|
|
18302
|
-
|
|
18303
|
-
|
|
18280
|
+
if (trails.colorOverTrail && trails.colorOverTrail[0] === ValueType$1.GRADIENT_COLOR) {
|
|
18281
|
+
trailMeshProps.colorOverTrail = trails.colorOverTrail[1];
|
|
18304
18282
|
}
|
|
18305
18283
|
}
|
|
18306
|
-
|
|
18307
|
-
|
|
18308
|
-
|
|
18309
|
-
|
|
18310
|
-
|
|
18284
|
+
this.renderer = new ParticleSystemRenderer(this.engine, particleMeshProps, trailMeshProps);
|
|
18285
|
+
this.meshes = this.renderer.meshes;
|
|
18286
|
+
// this.item = vfxItem;
|
|
18287
|
+
var interaction = props.interaction;
|
|
18288
|
+
if (interaction) {
|
|
18289
|
+
this.interaction = {
|
|
18290
|
+
multiple: interaction.multiple,
|
|
18291
|
+
radius: interaction.radius,
|
|
18292
|
+
behavior: interaction.behavior,
|
|
18311
18293
|
};
|
|
18312
|
-
if (rotationOverLifetime.separateAxes) {
|
|
18313
|
-
var rotLt = this.rotationOverLifetime;
|
|
18314
|
-
rotLt.x = createValueGetter(rotationOverLifetime.x || 0);
|
|
18315
|
-
rotLt.y = createValueGetter(rotationOverLifetime.y || 0);
|
|
18316
|
-
}
|
|
18317
18294
|
}
|
|
18318
|
-
this.
|
|
18319
|
-
this.
|
|
18320
|
-
this.
|
|
18321
|
-
this.
|
|
18322
|
-
this.
|
|
18323
|
-
|
|
18295
|
+
this.item.getHitTestParams = this.getHitTestParams;
|
|
18296
|
+
this.item._content = this;
|
|
18297
|
+
this.renderer.item = this.item;
|
|
18298
|
+
this.item.components.push(this.renderer);
|
|
18299
|
+
this.item.rendererComponents.push(this.renderer);
|
|
18300
|
+
// 添加粒子动画 clip
|
|
18301
|
+
var timeline = this.item.getComponent(TimelineComponent);
|
|
18302
|
+
timeline.createTrack(Track).createClip(ParticleBehaviourPlayable);
|
|
18324
18303
|
};
|
|
18325
|
-
|
|
18326
|
-
|
|
18304
|
+
ParticleSystem = __decorate([
|
|
18305
|
+
effectsClass(exports.DataType.ParticleSystem)
|
|
18306
|
+
], ParticleSystem);
|
|
18307
|
+
return ParticleSystem;
|
|
18308
|
+
}(Component));
|
|
18309
|
+
// array performance better for small memory than Float32Array
|
|
18310
|
+
var tempDir = new Vector3();
|
|
18311
|
+
var tempSize = new Vector2();
|
|
18312
|
+
var tempRot = new Euler();
|
|
18313
|
+
var tmpDirX = new Vector3();
|
|
18314
|
+
var tmpDirY = new Vector3();
|
|
18315
|
+
var tempVec3 = new Vector3();
|
|
18316
|
+
var tempEuler = new Euler();
|
|
18317
|
+
var tempSprite = [0, 0, 0];
|
|
18318
|
+
var tempMat4 = new Matrix4();
|
|
18319
|
+
function getBurstOffsets(burstOffsets) {
|
|
18320
|
+
var ret = {};
|
|
18321
|
+
if (Array.isArray(burstOffsets)) {
|
|
18322
|
+
burstOffsets.forEach(function (arr) {
|
|
18323
|
+
var isArr = arr instanceof Array;
|
|
18324
|
+
var index = isArr ? arr[0] : arr.index;
|
|
18325
|
+
var offsets = ret[index];
|
|
18326
|
+
if (!offsets) {
|
|
18327
|
+
offsets = ret[index] = [];
|
|
18328
|
+
}
|
|
18329
|
+
if (isArr) {
|
|
18330
|
+
offsets.push(arr.slice(1, 4));
|
|
18331
|
+
}
|
|
18332
|
+
else {
|
|
18333
|
+
offsets.push([+arr.x, +arr.y, +arr.z]);
|
|
18334
|
+
}
|
|
18335
|
+
});
|
|
18336
|
+
}
|
|
18337
|
+
return ret;
|
|
18338
|
+
}
|
|
18339
|
+
function randomArrItem(arr, keepArr) {
|
|
18340
|
+
var index = Math.floor(Math.random() * arr.length);
|
|
18341
|
+
var item = arr[index];
|
|
18342
|
+
if (!keepArr) {
|
|
18343
|
+
arr.splice(index, 1);
|
|
18344
|
+
}
|
|
18345
|
+
return item;
|
|
18346
|
+
}
|
|
18347
|
+
|
|
18327
18348
|
/**
|
|
18328
18349
|
* @since 2.0.0
|
|
18329
18350
|
* @internal
|
|
18330
18351
|
*/
|
|
18331
|
-
var
|
|
18332
|
-
__extends(
|
|
18333
|
-
function
|
|
18352
|
+
var ParticleBehaviourPlayable = /** @class */ (function (_super) {
|
|
18353
|
+
__extends(ParticleBehaviourPlayable, _super);
|
|
18354
|
+
function ParticleBehaviourPlayable() {
|
|
18334
18355
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
18335
18356
|
}
|
|
18336
|
-
|
|
18337
|
-
this.bindingItem.
|
|
18338
|
-
this.
|
|
18339
|
-
|
|
18340
|
-
|
|
18341
|
-
|
|
18342
|
-
this.showRendererComponents();
|
|
18343
|
-
};
|
|
18344
|
-
ActivationClipPlayable.prototype.onPlayableDestroy = function () {
|
|
18345
|
-
this.bindingItem.transform.setValid(false);
|
|
18346
|
-
this.hideRendererComponents();
|
|
18347
|
-
};
|
|
18348
|
-
ActivationClipPlayable.prototype.hideRendererComponents = function () {
|
|
18349
|
-
var e_1, _a;
|
|
18350
|
-
try {
|
|
18351
|
-
for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
18352
|
-
var rendererComponent = _c.value;
|
|
18353
|
-
if (rendererComponent.enabled) {
|
|
18354
|
-
rendererComponent.enabled = false;
|
|
18355
|
-
}
|
|
18356
|
-
}
|
|
18357
|
-
}
|
|
18358
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
18359
|
-
finally {
|
|
18360
|
-
try {
|
|
18361
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
18362
|
-
}
|
|
18363
|
-
finally { if (e_1) throw e_1.error; }
|
|
18357
|
+
ParticleBehaviourPlayable.prototype.onPlayablePlay = function () {
|
|
18358
|
+
this.particleSystem = this.bindingItem.getComponent(ParticleSystem);
|
|
18359
|
+
if (this.particleSystem) {
|
|
18360
|
+
this.particleSystem.name = this.bindingItem.name;
|
|
18361
|
+
this.particleSystem.start();
|
|
18362
|
+
this.particleSystem.initEmitterTransform();
|
|
18364
18363
|
}
|
|
18365
18364
|
};
|
|
18366
|
-
|
|
18367
|
-
var
|
|
18368
|
-
|
|
18369
|
-
|
|
18370
|
-
|
|
18371
|
-
|
|
18372
|
-
|
|
18373
|
-
|
|
18374
|
-
}
|
|
18375
|
-
}
|
|
18376
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
18377
|
-
finally {
|
|
18378
|
-
try {
|
|
18379
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
18380
|
-
}
|
|
18381
|
-
finally { if (e_2) throw e_2.error; }
|
|
18365
|
+
ParticleBehaviourPlayable.prototype.processFrame = function (dt) {
|
|
18366
|
+
var particleSystem = this.particleSystem;
|
|
18367
|
+
if (particleSystem) {
|
|
18368
|
+
this.bindingItem.parent;
|
|
18369
|
+
// TODO: [1.31] @十弦 验证 https://github.com/galacean/effects-runtime/commit/3e7d73d37b7d98c2a25e4544e80e928b17801ccd#diff-fae062f28caf3771cfedd3a20dc22f9749bd054c7541bf2fd50a9a5e413153d4
|
|
18370
|
+
// particleSystem.setParentTransform(parentItem.transform);
|
|
18371
|
+
particleSystem.setVisible(true);
|
|
18372
|
+
particleSystem.onUpdate(dt);
|
|
18382
18373
|
}
|
|
18383
18374
|
};
|
|
18384
|
-
return
|
|
18375
|
+
return ParticleBehaviourPlayable;
|
|
18385
18376
|
}(Playable));
|
|
18386
18377
|
|
|
18378
|
+
var CalculateLoader = /** @class */ (function (_super) {
|
|
18379
|
+
__extends(CalculateLoader, _super);
|
|
18380
|
+
function CalculateLoader() {
|
|
18381
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
18382
|
+
}
|
|
18383
|
+
return CalculateLoader;
|
|
18384
|
+
}(AbstractPlugin));
|
|
18385
|
+
|
|
18387
18386
|
var TextLayout = /** @class */ (function () {
|
|
18388
18387
|
function TextLayout(options) {
|
|
18389
18388
|
this.width = 0;
|
|
@@ -19681,9 +19680,10 @@ var TextComponent = /** @class */ (function (_super) {
|
|
|
19681
19680
|
if (this.textStyle.fontSize === value) {
|
|
19682
19681
|
return;
|
|
19683
19682
|
}
|
|
19683
|
+
// 保证字号变化后位置正常
|
|
19684
|
+
var diff = this.textStyle.fontSize - value;
|
|
19685
|
+
this.textLayout.lineHeight += diff;
|
|
19684
19686
|
this.textStyle.fontSize = value;
|
|
19685
|
-
// 1.5175 = 31.43 / 20
|
|
19686
|
-
this.textLayout.lineHeight = this.textStyle.fontSize * 1.5175;
|
|
19687
19687
|
this.isDirty = true;
|
|
19688
19688
|
};
|
|
19689
19689
|
/**
|
|
@@ -20009,7 +20009,7 @@ var TextLoader = /** @class */ (function (_super) {
|
|
|
20009
20009
|
return TextLoader;
|
|
20010
20010
|
}(AbstractPlugin));
|
|
20011
20011
|
|
|
20012
|
-
var seed$
|
|
20012
|
+
var seed$1 = 1;
|
|
20013
20013
|
/**
|
|
20014
20014
|
* @since 2.0.0
|
|
20015
20015
|
* @internal
|
|
@@ -20035,24 +20035,9 @@ var EffectComponent = /** @class */ (function (_super) {
|
|
|
20035
20035
|
};
|
|
20036
20036
|
}
|
|
20037
20037
|
};
|
|
20038
|
-
_this.id = 'Mesh' + seed$
|
|
20038
|
+
_this.id = 'Mesh' + seed$1++;
|
|
20039
20039
|
_this.name = '<unnamed>';
|
|
20040
20040
|
_this._priority = 0;
|
|
20041
|
-
_this.geometry = Geometry.create(_this.engine);
|
|
20042
|
-
var geometryData = {
|
|
20043
|
-
vertices: [
|
|
20044
|
-
-1, 1, 0,
|
|
20045
|
-
-1, -1, 0,
|
|
20046
|
-
1, 1, 0,
|
|
20047
|
-
1, -1, 0, //右下
|
|
20048
|
-
],
|
|
20049
|
-
uvs: [0, 1, 0, 0, 1, 1, 1, 0],
|
|
20050
|
-
indices: [0, 1, 2, 2, 1, 3],
|
|
20051
|
-
dataType: exports.DataType.Geometry,
|
|
20052
|
-
id: generateGUID(),
|
|
20053
|
-
};
|
|
20054
|
-
_this.geometry.fromData(geometryData);
|
|
20055
|
-
_this.triangles = geometryToTriangles(_this.geometry);
|
|
20056
20041
|
return _this;
|
|
20057
20042
|
}
|
|
20058
20043
|
Object.defineProperty(EffectComponent.prototype, "isDestroyed", {
|
|
@@ -20589,11 +20574,6 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20589
20574
|
this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
|
|
20590
20575
|
this.name = name;
|
|
20591
20576
|
this.start = delay ? delay : this.start;
|
|
20592
|
-
// TODO spec 数据需要区分 scale 和 size
|
|
20593
|
-
if (transform && transform.scale && data.type !== 'ECS') {
|
|
20594
|
-
//@ts-expect-error TODO 数据改造后移除 expect-error
|
|
20595
|
-
transform.scale.z = transform.scale.x;
|
|
20596
|
-
}
|
|
20597
20577
|
if (transform) {
|
|
20598
20578
|
//@ts-expect-error TODO 数据改造后移除 expect-error
|
|
20599
20579
|
transform.position = new Vector3().copyFrom(transform.position);
|
|
@@ -20601,51 +20581,36 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20601
20581
|
transform.rotation = new Euler().copyFrom(transform.rotation);
|
|
20602
20582
|
//@ts-expect-error
|
|
20603
20583
|
transform.scale = new Vector3().copyFrom(transform.scale);
|
|
20584
|
+
//@ts-expect-error
|
|
20585
|
+
if (transform.size) {
|
|
20586
|
+
//@ts-expect-error
|
|
20587
|
+
transform.size = new Vector2().copyFrom(transform.size);
|
|
20588
|
+
}
|
|
20589
|
+
//@ts-expect-error
|
|
20590
|
+
if (transform.anchor) {
|
|
20591
|
+
//@ts-expect-error
|
|
20592
|
+
transform.anchor = new Vector2().copyFrom(transform.anchor);
|
|
20593
|
+
}
|
|
20604
20594
|
this.transform.setTransform(transform);
|
|
20605
20595
|
}
|
|
20606
20596
|
this.transform.name = this.name;
|
|
20607
20597
|
this.transform.engine = this.engine;
|
|
20608
|
-
// TODO spec 数据需要区分 scale 和 size
|
|
20609
|
-
if (data.type === ItemType$1.sprite && transform) {
|
|
20610
|
-
this.transform.setSize(this.transform.scale.x, this.transform.scale.y);
|
|
20611
|
-
this.transform.setScale(1, 1, 1);
|
|
20612
|
-
}
|
|
20613
20598
|
this.parentId = parentId;
|
|
20614
20599
|
this.duration = duration;
|
|
20615
20600
|
this.endBehavior = endBehavior;
|
|
20616
|
-
// TODO: 放到 Spec 处理
|
|
20617
|
-
if (this.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 || this.endBehavior === END_BEHAVIOR_PAUSE$1) {
|
|
20618
|
-
this.endBehavior = END_BEHAVIOR_FREEZE$1;
|
|
20619
|
-
}
|
|
20620
20601
|
this.lifetime = -(this.start / this.duration);
|
|
20621
20602
|
this.listIndex = listIndex;
|
|
20603
|
+
//@ts-expect-error
|
|
20604
|
+
this.oldId = data.oldId;
|
|
20622
20605
|
if (!data.content) {
|
|
20623
20606
|
data.content = { options: {} };
|
|
20624
20607
|
}
|
|
20625
20608
|
var timelineComponent = this.getComponent(TimelineComponent);
|
|
20626
20609
|
timelineComponent.fromData(data.content);
|
|
20627
|
-
// TODO anchor 应该放在 transform data
|
|
20628
|
-
if (data.type === ItemType$1.sprite) {
|
|
20629
|
-
var content = data.content;
|
|
20630
|
-
if (!content.renderer) {
|
|
20631
|
-
//@ts-expect-error
|
|
20632
|
-
content.renderer = {};
|
|
20633
|
-
}
|
|
20634
|
-
var realAnchor = convertAnchor(content.renderer.anchor, content.renderer.particleOrigin);
|
|
20635
|
-
var startSize = this.transform.size;
|
|
20636
|
-
// 兼容旧JSON(anchor和particleOrigin可能同时存在)
|
|
20637
|
-
if (!content.renderer.anchor && content.renderer.particleOrigin !== undefined) {
|
|
20638
|
-
this.transform.position.add([-realAnchor[0] * startSize.x, -realAnchor[1] * startSize.y, 0]);
|
|
20639
|
-
}
|
|
20640
|
-
this.transform.setAnchor(realAnchor[0] * startSize.x, realAnchor[1] * startSize.y, 0);
|
|
20641
|
-
}
|
|
20642
|
-
// TODO 要放在上面的 if 后面添加,否则会 position 初始化错误
|
|
20643
20610
|
if (this.type !== ItemType$1.particle) {
|
|
20644
20611
|
var track = timelineComponent.createTrack(Track, 'AnimationTrack');
|
|
20645
20612
|
track.createClip(AnimationClipPlayable, 'AnimationTimelineClip').playable.fromData(data.content);
|
|
20646
20613
|
}
|
|
20647
|
-
var activationTrack = timelineComponent.createTrack(Track, 'ActivationTrack');
|
|
20648
|
-
activationTrack.createClip(ActivationClipPlayable, 'ActivationTimelineClip');
|
|
20649
20614
|
if (duration <= 0) {
|
|
20650
20615
|
throw Error("Item duration can't be less than 0, see ".concat(HELP_LINK['Item duration can\'t be less than 0']));
|
|
20651
20616
|
}
|
|
@@ -22660,7 +22625,7 @@ function isScene(scene) {
|
|
|
22660
22625
|
|
|
22661
22626
|
function version3Migration(scene) {
|
|
22662
22627
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
22663
|
-
scene.jsonScene.version = 3.0;
|
|
22628
|
+
scene.jsonScene.version = '3.0';
|
|
22664
22629
|
var ecScene = scene.jsonScene;
|
|
22665
22630
|
if (!ecScene.items) {
|
|
22666
22631
|
ecScene.items = [];
|
|
@@ -22672,6 +22637,10 @@ function version3Migration(scene) {
|
|
|
22672
22637
|
for (var i = 0; i < composition.items.length; i++) {
|
|
22673
22638
|
ecScene.items.push(composition.items[i]);
|
|
22674
22639
|
}
|
|
22640
|
+
// composition 的 endbehaviour 兼容
|
|
22641
|
+
if (composition.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 || composition.endBehavior === END_BEHAVIOR_PAUSE$1) {
|
|
22642
|
+
composition.endBehavior = END_BEHAVIOR_FREEZE$1;
|
|
22643
|
+
}
|
|
22675
22644
|
}
|
|
22676
22645
|
}
|
|
22677
22646
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -22687,6 +22656,9 @@ function version3Migration(scene) {
|
|
|
22687
22656
|
for (var _j = __values$1(ecScene.items), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
22688
22657
|
var item = _k.value;
|
|
22689
22658
|
itemGuidMap[item.id] = generateGUID();
|
|
22659
|
+
// TODO: 编辑器测试用,上线后删除
|
|
22660
|
+
//@ts-expect-error
|
|
22661
|
+
item.oldId = item.id;
|
|
22690
22662
|
item.id = itemGuidMap[item.id];
|
|
22691
22663
|
}
|
|
22692
22664
|
}
|
|
@@ -22794,12 +22766,61 @@ function version3Migration(scene) {
|
|
|
22794
22766
|
if (!scale) {
|
|
22795
22767
|
scale = [1, 1, 1];
|
|
22796
22768
|
}
|
|
22769
|
+
item.transform = {
|
|
22770
|
+
//@ts-expect-error
|
|
22771
|
+
position: { x: position[0], y: position[1], z: position[2] },
|
|
22772
|
+
//@ts-expect-error
|
|
22773
|
+
rotation: { x: rotation[0], y: rotation[1], z: rotation[2] },
|
|
22774
|
+
//@ts-expect-error
|
|
22775
|
+
scale: { x: scale[0], y: scale[1], z: scale[0] },
|
|
22776
|
+
};
|
|
22777
|
+
// sprite 的 scale 转为 size
|
|
22778
|
+
if (item.type === ItemType$1.sprite) {
|
|
22779
|
+
//@ts-expect-error
|
|
22780
|
+
item.transform.size = { x: scale[0], y: scale[1] };
|
|
22781
|
+
//@ts-expect-error
|
|
22782
|
+
item.transform.scale = { x: 1, y: 1, z: 1 };
|
|
22783
|
+
}
|
|
22784
|
+
// sprite 的 anchor 修正
|
|
22785
|
+
if (item.type === ItemType$1.sprite) {
|
|
22786
|
+
var content = item.content;
|
|
22787
|
+
//@ts-expect-error
|
|
22788
|
+
if (!content.renderer) {
|
|
22789
|
+
//@ts-expect-error
|
|
22790
|
+
content.renderer = {};
|
|
22791
|
+
}
|
|
22792
|
+
//@ts-expect-error
|
|
22793
|
+
var renderer = content.renderer;
|
|
22794
|
+
var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
22795
|
+
//@ts-expect-error
|
|
22796
|
+
var startSize = item.transform.size;
|
|
22797
|
+
// 兼容旧JSON(anchor和particleOrigin可能同时存在)
|
|
22798
|
+
if (!renderer.anchor && renderer.particleOrigin !== undefined) {
|
|
22799
|
+
//@ts-expect-error
|
|
22800
|
+
item.transform.position.x += -realAnchor[0] * startSize.x;
|
|
22801
|
+
//@ts-expect-error
|
|
22802
|
+
item.transform.position.y += -realAnchor[1] * startSize.y;
|
|
22803
|
+
}
|
|
22804
|
+
//@ts-expect-error
|
|
22805
|
+
item.transform.anchor = { x: realAnchor[0] * startSize.x, y: realAnchor[1] * startSize.y };
|
|
22806
|
+
}
|
|
22807
|
+
}
|
|
22808
|
+
if (item.type === ItemType$1.particle) {
|
|
22809
|
+
var content = item.content;
|
|
22797
22810
|
//@ts-expect-error
|
|
22798
|
-
|
|
22811
|
+
if (!content.renderer) {
|
|
22812
|
+
//@ts-expect-error
|
|
22813
|
+
content.renderer = {};
|
|
22814
|
+
}
|
|
22799
22815
|
//@ts-expect-error
|
|
22800
|
-
|
|
22816
|
+
var renderer = content.renderer;
|
|
22801
22817
|
//@ts-expect-error
|
|
22802
|
-
|
|
22818
|
+
content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
22819
|
+
}
|
|
22820
|
+
// item 的 endbehaviour 兼容
|
|
22821
|
+
// @ts-expect-error
|
|
22822
|
+
if (item.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 || item.endBehavior === END_BEHAVIOR_PAUSE$1) {
|
|
22823
|
+
item.endBehavior = END_BEHAVIOR_FREEZE$1;
|
|
22803
22824
|
}
|
|
22804
22825
|
// item 的 content 转为 component data 加入 JSONScene.components
|
|
22805
22826
|
var uuid = v4().replace(/-/g, '');
|
|
@@ -22974,8 +22995,22 @@ function version3Migration(scene) {
|
|
|
22974
22995
|
}
|
|
22975
22996
|
return scene;
|
|
22976
22997
|
}
|
|
22998
|
+
/**
|
|
22999
|
+
* 提取并转换 JSON 数据中的 anchor 值
|
|
23000
|
+
*/
|
|
23001
|
+
function convertAnchor(anchor, particleOrigin) {
|
|
23002
|
+
if (anchor) {
|
|
23003
|
+
return [anchor[0] - 0.5, 0.5 - anchor[1]];
|
|
23004
|
+
}
|
|
23005
|
+
else if (particleOrigin) {
|
|
23006
|
+
return particleOriginTranslateMap[particleOrigin];
|
|
23007
|
+
}
|
|
23008
|
+
else {
|
|
23009
|
+
return [0, 0];
|
|
23010
|
+
}
|
|
23011
|
+
}
|
|
22977
23012
|
|
|
22978
|
-
var seed
|
|
23013
|
+
var seed = 1;
|
|
22979
23014
|
/**
|
|
22980
23015
|
* 资源管理器
|
|
22981
23016
|
* 用于加载和动效中所有的资源文件,包括图片、插件、图层粒子数据等
|
|
@@ -22995,7 +23030,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
22995
23030
|
* 图像资源,用于创建和释放GPU纹理资源
|
|
22996
23031
|
*/
|
|
22997
23032
|
this.assets = {};
|
|
22998
|
-
this.id = seed
|
|
23033
|
+
this.id = seed++;
|
|
22999
23034
|
/**
|
|
23000
23035
|
* 场景加载的超时定时器
|
|
23001
23036
|
*/
|
|
@@ -23011,6 +23046,26 @@ var AssetManager = /** @class */ (function () {
|
|
|
23011
23046
|
var _a = options.timeout, timeout = _a === void 0 ? 10 : _a;
|
|
23012
23047
|
this.timeout = timeout;
|
|
23013
23048
|
};
|
|
23049
|
+
/**
|
|
23050
|
+
* 根据用户传入的参数修改场景数据
|
|
23051
|
+
*/
|
|
23052
|
+
AssetManager.prototype.updateSceneData = function (compositions) {
|
|
23053
|
+
var variables = this.options.variables;
|
|
23054
|
+
if (!variables || Object.keys(variables).length <= 0) {
|
|
23055
|
+
return compositions;
|
|
23056
|
+
}
|
|
23057
|
+
compositions.forEach(function (composition) {
|
|
23058
|
+
composition.items.forEach(function (item) {
|
|
23059
|
+
if (item.type === ItemType$1.text) {
|
|
23060
|
+
var textVariable = variables[item.name];
|
|
23061
|
+
if (textVariable) {
|
|
23062
|
+
item.content.options.text = textVariable;
|
|
23063
|
+
}
|
|
23064
|
+
}
|
|
23065
|
+
});
|
|
23066
|
+
});
|
|
23067
|
+
return compositions;
|
|
23068
|
+
};
|
|
23014
23069
|
/**
|
|
23015
23070
|
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
23016
23071
|
* @param url - json 的 URL 链接或者 json 对象
|
|
@@ -23102,6 +23157,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23102
23157
|
for (i = 0; i < scene.images.length; i++) {
|
|
23103
23158
|
scene.textureOptions[i].image = scene.images[i];
|
|
23104
23159
|
}
|
|
23160
|
+
scene.jsonScene.compositions = this.updateSceneData(scene.jsonScene.compositions);
|
|
23105
23161
|
_e.label = 5;
|
|
23106
23162
|
case 5: return [3 /*break*/, 12];
|
|
23107
23163
|
case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
|
|
@@ -23121,6 +23177,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23121
23177
|
return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
|
|
23122
23178
|
case 10:
|
|
23123
23179
|
loadedTextures = _e.sent();
|
|
23180
|
+
jsonScene_1.compositions = this.updateSceneData(jsonScene_1.compositions);
|
|
23124
23181
|
scene = {
|
|
23125
23182
|
url: url,
|
|
23126
23183
|
renderLevel: this.options.renderLevel,
|
|
@@ -23967,7 +24024,9 @@ var CompositionComponent = /** @class */ (function (_super) {
|
|
|
23967
24024
|
}
|
|
23968
24025
|
// endBehaviour 类型需优化
|
|
23969
24026
|
props.content = itemData.content;
|
|
23970
|
-
item = new VFXItem(this.engine, __assign$1(__assign$1({}, props), { id: itemData.id, name: itemData.name, delay: itemData.delay, duration: itemData.duration, endBehavior: itemData.endBehavior, parentId: itemData.parentId, transform: itemData.transform
|
|
24027
|
+
item = new VFXItem(this.engine, __assign$1(__assign$1({}, props), { id: itemData.id, name: itemData.name, delay: itemData.delay, duration: itemData.duration, endBehavior: itemData.endBehavior, parentId: itemData.parentId, transform: itemData.transform,
|
|
24028
|
+
// @ts-expect-error TODO: 2.0 编辑器测试代码,后续移除
|
|
24029
|
+
oldId: itemData.oldId }));
|
|
23971
24030
|
// TODO 编辑器数据传入 composition type 后移除
|
|
23972
24031
|
item.type = ItemType$1.composition;
|
|
23973
24032
|
item.composition = this.item.composition;
|
|
@@ -24102,7 +24161,6 @@ var CompositionComponent = /** @class */ (function (_super) {
|
|
|
24102
24161
|
return CompositionComponent;
|
|
24103
24162
|
}(ItemBehaviour));
|
|
24104
24163
|
|
|
24105
|
-
var seed = 1;
|
|
24106
24164
|
/**
|
|
24107
24165
|
* 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
|
|
24108
24166
|
* 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
|
|
@@ -24175,7 +24233,7 @@ var Composition = /** @class */ (function () {
|
|
|
24175
24233
|
this.width = width;
|
|
24176
24234
|
this.height = height;
|
|
24177
24235
|
this.renderOrder = baseRenderOrder;
|
|
24178
|
-
this.id =
|
|
24236
|
+
this.id = sourceContent.id;
|
|
24179
24237
|
this.renderer = renderer;
|
|
24180
24238
|
this.texInfo = imageUsage !== null && imageUsage !== void 0 ? imageUsage : {};
|
|
24181
24239
|
this.event = event;
|
|
@@ -24202,7 +24260,7 @@ var Composition = /** @class */ (function () {
|
|
|
24202
24260
|
this.rootItem.onEnd = function () {
|
|
24203
24261
|
window.setTimeout(function () {
|
|
24204
24262
|
var _a;
|
|
24205
|
-
(_a = _this.
|
|
24263
|
+
(_a = _this.onEnd) === null || _a === void 0 ? void 0 : _a.call(_this, _this);
|
|
24206
24264
|
}, 0);
|
|
24207
24265
|
};
|
|
24208
24266
|
this.pluginSystem.resetComposition(this, this.renderFrame);
|
|
@@ -24281,9 +24339,9 @@ var Composition = /** @class */ (function () {
|
|
|
24281
24339
|
* 重新开始合成
|
|
24282
24340
|
*/
|
|
24283
24341
|
Composition.prototype.restart = function () {
|
|
24284
|
-
|
|
24285
|
-
contentItems.forEach(
|
|
24286
|
-
contentItems.length = 0;
|
|
24342
|
+
this.rootComposition.items;
|
|
24343
|
+
// contentItems.forEach(item => item.dispose());
|
|
24344
|
+
// contentItems.length = 0;
|
|
24287
24345
|
this.prepareRender();
|
|
24288
24346
|
this.reset();
|
|
24289
24347
|
this.transform.setValid(true);
|
|
@@ -24566,7 +24624,8 @@ var Composition = /** @class */ (function () {
|
|
|
24566
24624
|
var time = this.getUpdateTime(deltaTime * this.speed);
|
|
24567
24625
|
this.globalTime += time;
|
|
24568
24626
|
if (this.rootTimeline.isActiveAndEnabled) {
|
|
24569
|
-
this.rootTimeline.
|
|
24627
|
+
var localTime = this.rootTimeline.toLocalTime(this.globalTime / 1000);
|
|
24628
|
+
this.rootTimeline.setTime(localTime);
|
|
24570
24629
|
}
|
|
24571
24630
|
this.updateVideo();
|
|
24572
24631
|
// 更新 model-tree-plugin
|
|
@@ -25031,6 +25090,9 @@ var Composition = /** @class */ (function () {
|
|
|
25031
25090
|
}
|
|
25032
25091
|
this.compositionSourceManager.dispose();
|
|
25033
25092
|
this.refCompositionProps.clear();
|
|
25093
|
+
if (this.renderer.env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
25094
|
+
return;
|
|
25095
|
+
}
|
|
25034
25096
|
this.renderer.clear({
|
|
25035
25097
|
stencilAction: exports.TextureLoadAction.clear,
|
|
25036
25098
|
clearStencil: 0,
|
|
@@ -25701,9 +25763,20 @@ var Ticker = /** @class */ (function () {
|
|
|
25701
25763
|
if (fps === void 0) { fps = 60; }
|
|
25702
25764
|
this.paused = true;
|
|
25703
25765
|
this.lastTime = 0;
|
|
25766
|
+
this._deltaTime = 0;
|
|
25704
25767
|
this.setFPS(fps);
|
|
25705
25768
|
this.tickers = [];
|
|
25706
25769
|
}
|
|
25770
|
+
Object.defineProperty(Ticker.prototype, "deltaTime", {
|
|
25771
|
+
/**
|
|
25772
|
+
* 获取定时器当前帧更新的时间
|
|
25773
|
+
*/
|
|
25774
|
+
get: function () {
|
|
25775
|
+
return this._deltaTime;
|
|
25776
|
+
},
|
|
25777
|
+
enumerable: false,
|
|
25778
|
+
configurable: true
|
|
25779
|
+
});
|
|
25707
25780
|
/**
|
|
25708
25781
|
* FPS 帧率设置
|
|
25709
25782
|
*/
|
|
@@ -25730,6 +25803,7 @@ var Ticker = /** @class */ (function () {
|
|
|
25730
25803
|
Ticker.prototype.start = function () {
|
|
25731
25804
|
var _this = this;
|
|
25732
25805
|
this.paused = false;
|
|
25806
|
+
this._deltaTime = 0;
|
|
25733
25807
|
if (!this.intervalId) {
|
|
25734
25808
|
this.lastTime = performance.now();
|
|
25735
25809
|
var raf_1 = requestAnimationFrame || function (func) {
|
|
@@ -25752,6 +25826,7 @@ var Ticker = /** @class */ (function () {
|
|
|
25752
25826
|
this.intervalId = 0;
|
|
25753
25827
|
this.lastTime = 0;
|
|
25754
25828
|
this.paused = true;
|
|
25829
|
+
this._deltaTime = 0;
|
|
25755
25830
|
this.tickers = [];
|
|
25756
25831
|
};
|
|
25757
25832
|
/**
|
|
@@ -25759,12 +25834,14 @@ var Ticker = /** @class */ (function () {
|
|
|
25759
25834
|
*/
|
|
25760
25835
|
Ticker.prototype.pause = function () {
|
|
25761
25836
|
this.paused = true;
|
|
25837
|
+
this._deltaTime = 0;
|
|
25762
25838
|
};
|
|
25763
25839
|
/**
|
|
25764
25840
|
* 定时器恢复方法
|
|
25765
25841
|
*/
|
|
25766
25842
|
Ticker.prototype.resume = function () {
|
|
25767
25843
|
this.paused = false;
|
|
25844
|
+
this._deltaTime = 0;
|
|
25768
25845
|
};
|
|
25769
25846
|
/**
|
|
25770
25847
|
* 定时器 tick 方法
|
|
@@ -25774,8 +25851,8 @@ var Ticker = /** @class */ (function () {
|
|
|
25774
25851
|
return;
|
|
25775
25852
|
}
|
|
25776
25853
|
var startTime = performance.now();
|
|
25777
|
-
|
|
25778
|
-
if (
|
|
25854
|
+
this._deltaTime = startTime - this.lastTime;
|
|
25855
|
+
if (this._deltaTime >= this.interval) {
|
|
25779
25856
|
this.lastTime = startTime;
|
|
25780
25857
|
if (this.resetTickers) {
|
|
25781
25858
|
this.tickers = this.tickers.filter(function (tick) { return tick; });
|
|
@@ -25783,7 +25860,7 @@ var Ticker = /** @class */ (function () {
|
|
|
25783
25860
|
}
|
|
25784
25861
|
for (var i = 0, len = this.tickers.length; i < len; i++) {
|
|
25785
25862
|
var tick = this.tickers[i];
|
|
25786
|
-
tick(
|
|
25863
|
+
tick(this._deltaTime);
|
|
25787
25864
|
}
|
|
25788
25865
|
}
|
|
25789
25866
|
};
|
|
@@ -25936,7 +26013,6 @@ exports.combineImageTemplate2Async = combineImageTemplate2Async;
|
|
|
25936
26013
|
exports.combineImageTemplateAsync = combineImageTemplateAsync;
|
|
25937
26014
|
exports.compatibleFrag = compatible_frag;
|
|
25938
26015
|
exports.compatibleVert = compatible_vert;
|
|
25939
|
-
exports.convertAnchor = convertAnchor;
|
|
25940
26016
|
exports.copyFrag = copy;
|
|
25941
26017
|
exports.createCopyShader = createCopyShader;
|
|
25942
26018
|
exports.createGLContext = createGLContext;
|