@galacean/effects-core 2.2.2-alpha.0 → 2.2.3
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 +1 -2
- package/dist/index.js +129 -109
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +129 -109
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/text/text-item.d.ts +2 -0
- package/dist/vfx-item.d.ts +5 -12
- package/package.json +1 -1
package/dist/asset-loader.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as spec from '@galacean/effects-specification';
|
|
2
2
|
import type { EffectsObject } from './effects-object';
|
|
3
3
|
import type { Engine } from './engine';
|
|
4
|
-
import type { VFXItemProps } from './vfx-item';
|
|
5
4
|
/**
|
|
6
5
|
* @since 2.0.0
|
|
7
6
|
*/
|
|
@@ -22,7 +21,7 @@ export interface EffectComponentData extends spec.EffectsObjectData {
|
|
|
22
21
|
materials: spec.DataPath[];
|
|
23
22
|
geometry: spec.DataPath;
|
|
24
23
|
}
|
|
25
|
-
export type VFXItemData =
|
|
24
|
+
export type VFXItemData = spec.Item & {
|
|
26
25
|
dataType: spec.DataType;
|
|
27
26
|
components: spec.DataPath[];
|
|
28
27
|
};
|
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.2.
|
|
6
|
+
* Version: v2.2.3
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -16586,17 +16586,10 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
16586
16586
|
];
|
|
16587
16587
|
};
|
|
16588
16588
|
_proto.onStart = function onStart() {
|
|
16589
|
-
var _this = this;
|
|
16590
|
-
var _this_item_composition;
|
|
16591
16589
|
var options = this.item.props.content.options;
|
|
16592
16590
|
var env = this.item.engine.renderer.env;
|
|
16593
16591
|
var composition = this.item.composition;
|
|
16594
16592
|
var _this_interactData_options = this.interactData.options, type = _this_interactData_options.type, showPreview = _this_interactData_options.showPreview;
|
|
16595
|
-
(_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.on("goto", function() {
|
|
16596
|
-
if (_this.item.time > 0) {
|
|
16597
|
-
_this.duringPlay = true;
|
|
16598
|
-
}
|
|
16599
|
-
});
|
|
16600
16593
|
if (type === InteractType.CLICK) {
|
|
16601
16594
|
this.clickable = true;
|
|
16602
16595
|
if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
@@ -16631,18 +16624,26 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
16631
16624
|
_proto.onEnable = function onEnable() {
|
|
16632
16625
|
RendererComponent.prototype.onEnable.call(this);
|
|
16633
16626
|
var type = this.interactData.options.type;
|
|
16627
|
+
var env = this.item.engine.renderer.env;
|
|
16634
16628
|
if (type === InteractType.CLICK) {
|
|
16635
16629
|
this.clickable = true;
|
|
16630
|
+
} else if (type === InteractType.DRAG) {
|
|
16631
|
+
var options = this.interactData.options;
|
|
16632
|
+
var enableInEditor = options.enableInEditor;
|
|
16633
|
+
if (env !== PLAYER_OPTIONS_ENV_EDITOR || enableInEditor) {
|
|
16634
|
+
var _this_item_composition;
|
|
16635
|
+
((_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.event) && this.beginDragTarget(options, this.item.composition.event);
|
|
16636
|
+
}
|
|
16636
16637
|
}
|
|
16637
16638
|
};
|
|
16638
16639
|
_proto.onUpdate = function onUpdate(dt) {
|
|
16639
16640
|
var _this_previewContent;
|
|
16641
|
+
this.duringPlay = true;
|
|
16640
16642
|
// trigger messageBegin when item enter
|
|
16641
|
-
if (this.item.time > 0 &&
|
|
16643
|
+
if (this.item.time > 0 && this.item.time - dt / 1000 <= 0) {
|
|
16642
16644
|
var _this_item_composition;
|
|
16643
16645
|
var options = this.item.props.content.options;
|
|
16644
16646
|
(_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.addInteractiveItem(this.item, options.type);
|
|
16645
|
-
this.duringPlay = true;
|
|
16646
16647
|
}
|
|
16647
16648
|
(_this_previewContent = this.previewContent) == null ? void 0 : _this_previewContent.updateMesh();
|
|
16648
16649
|
if (!this.dragEvent || !this.bouncingArg) {
|
|
@@ -17168,6 +17169,83 @@ var PlayState;
|
|
|
17168
17169
|
PlayState[PlayState["Paused"] = 1] = "Paused";
|
|
17169
17170
|
})(PlayState || (PlayState = {}));
|
|
17170
17171
|
|
|
17172
|
+
/**
|
|
17173
|
+
*
|
|
17174
|
+
*/ /**
|
|
17175
|
+
* 事件监听器
|
|
17176
|
+
*/ var EventEmitter = function EventEmitter() {
|
|
17177
|
+
var _this = this;
|
|
17178
|
+
var _this1 = this;
|
|
17179
|
+
this.listeners = {};
|
|
17180
|
+
/**
|
|
17181
|
+
* 移除事件监听器
|
|
17182
|
+
* @param eventName - 事件名称
|
|
17183
|
+
* @param listener - 事件监听器
|
|
17184
|
+
* @returns
|
|
17185
|
+
*/ this.off = function(eventName, listener) {
|
|
17186
|
+
if (!_this.listeners[eventName]) {
|
|
17187
|
+
return;
|
|
17188
|
+
}
|
|
17189
|
+
_this.listeners[eventName] = _this.listeners[eventName].filter(function(param) {
|
|
17190
|
+
var l = param.listener;
|
|
17191
|
+
return l !== listener;
|
|
17192
|
+
});
|
|
17193
|
+
};
|
|
17194
|
+
/**
|
|
17195
|
+
* 监听事件
|
|
17196
|
+
* @param eventName - 事件名称
|
|
17197
|
+
* @param listener - 事件监听器
|
|
17198
|
+
* @param options - 事件监听器选项
|
|
17199
|
+
* @returns
|
|
17200
|
+
*/ this.on = function(eventName, listener, options) {
|
|
17201
|
+
_this.listeners[eventName] = _this.listeners[eventName] || [];
|
|
17202
|
+
_this.listeners[eventName].push({
|
|
17203
|
+
listener: listener,
|
|
17204
|
+
options: options
|
|
17205
|
+
});
|
|
17206
|
+
return function() {
|
|
17207
|
+
return _this.off(eventName, listener);
|
|
17208
|
+
};
|
|
17209
|
+
};
|
|
17210
|
+
/**
|
|
17211
|
+
* 一次性监听事件
|
|
17212
|
+
* @param eventName - 事件名称
|
|
17213
|
+
* @param listener - 事件监听器
|
|
17214
|
+
*/ this.once = function(eventName, listener) {
|
|
17215
|
+
_this.on(eventName, listener, {
|
|
17216
|
+
once: true
|
|
17217
|
+
});
|
|
17218
|
+
};
|
|
17219
|
+
/**
|
|
17220
|
+
* 触发事件
|
|
17221
|
+
* @param eventName - 事件名称
|
|
17222
|
+
* @param args - 事件参数
|
|
17223
|
+
*/ this.emit = function(eventName) {
|
|
17224
|
+
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
17225
|
+
args[_key - 1] = arguments[_key];
|
|
17226
|
+
}
|
|
17227
|
+
var _this_listeners_eventName;
|
|
17228
|
+
(_this_listeners_eventName = _this1.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.forEach(function(param) {
|
|
17229
|
+
var listener = param.listener, options = param.options;
|
|
17230
|
+
listener.apply(void 0, [].concat(args));
|
|
17231
|
+
if (options == null ? void 0 : options.once) {
|
|
17232
|
+
_this1.off(eventName, listener);
|
|
17233
|
+
}
|
|
17234
|
+
});
|
|
17235
|
+
};
|
|
17236
|
+
/**
|
|
17237
|
+
* 获取事件名称对应的所有监听器
|
|
17238
|
+
* @param eventName - 事件名称
|
|
17239
|
+
* @returns - 返回事件名称对应的所有监听器
|
|
17240
|
+
*/ this.getListeners = function(eventName) {
|
|
17241
|
+
var _this_listeners_eventName;
|
|
17242
|
+
return ((_this_listeners_eventName = _this.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.map(function(param) {
|
|
17243
|
+
var listener = param.listener;
|
|
17244
|
+
return listener;
|
|
17245
|
+
})) || [];
|
|
17246
|
+
};
|
|
17247
|
+
};
|
|
17248
|
+
|
|
17171
17249
|
var tempQuat$1 = new Quaternion();
|
|
17172
17250
|
var seed$3 = 1;
|
|
17173
17251
|
// TODO 继承 Component
|
|
@@ -17638,83 +17716,6 @@ var seed$3 = 1;
|
|
|
17638
17716
|
return Transform;
|
|
17639
17717
|
}();
|
|
17640
17718
|
|
|
17641
|
-
/**
|
|
17642
|
-
*
|
|
17643
|
-
*/ /**
|
|
17644
|
-
* 事件监听器
|
|
17645
|
-
*/ var EventEmitter = function EventEmitter() {
|
|
17646
|
-
var _this = this;
|
|
17647
|
-
var _this1 = this;
|
|
17648
|
-
this.listeners = {};
|
|
17649
|
-
/**
|
|
17650
|
-
* 移除事件监听器
|
|
17651
|
-
* @param eventName - 事件名称
|
|
17652
|
-
* @param listener - 事件监听器
|
|
17653
|
-
* @returns
|
|
17654
|
-
*/ this.off = function(eventName, listener) {
|
|
17655
|
-
if (!_this.listeners[eventName]) {
|
|
17656
|
-
return;
|
|
17657
|
-
}
|
|
17658
|
-
_this.listeners[eventName] = _this.listeners[eventName].filter(function(param) {
|
|
17659
|
-
var l = param.listener;
|
|
17660
|
-
return l !== listener;
|
|
17661
|
-
});
|
|
17662
|
-
};
|
|
17663
|
-
/**
|
|
17664
|
-
* 监听事件
|
|
17665
|
-
* @param eventName - 事件名称
|
|
17666
|
-
* @param listener - 事件监听器
|
|
17667
|
-
* @param options - 事件监听器选项
|
|
17668
|
-
* @returns
|
|
17669
|
-
*/ this.on = function(eventName, listener, options) {
|
|
17670
|
-
_this.listeners[eventName] = _this.listeners[eventName] || [];
|
|
17671
|
-
_this.listeners[eventName].push({
|
|
17672
|
-
listener: listener,
|
|
17673
|
-
options: options
|
|
17674
|
-
});
|
|
17675
|
-
return function() {
|
|
17676
|
-
return _this.off(eventName, listener);
|
|
17677
|
-
};
|
|
17678
|
-
};
|
|
17679
|
-
/**
|
|
17680
|
-
* 一次性监听事件
|
|
17681
|
-
* @param eventName - 事件名称
|
|
17682
|
-
* @param listener - 事件监听器
|
|
17683
|
-
*/ this.once = function(eventName, listener) {
|
|
17684
|
-
_this.on(eventName, listener, {
|
|
17685
|
-
once: true
|
|
17686
|
-
});
|
|
17687
|
-
};
|
|
17688
|
-
/**
|
|
17689
|
-
* 触发事件
|
|
17690
|
-
* @param eventName - 事件名称
|
|
17691
|
-
* @param args - 事件参数
|
|
17692
|
-
*/ this.emit = function(eventName) {
|
|
17693
|
-
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
17694
|
-
args[_key - 1] = arguments[_key];
|
|
17695
|
-
}
|
|
17696
|
-
var _this_listeners_eventName;
|
|
17697
|
-
(_this_listeners_eventName = _this1.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.forEach(function(param) {
|
|
17698
|
-
var listener = param.listener, options = param.options;
|
|
17699
|
-
listener.apply(void 0, [].concat(args));
|
|
17700
|
-
if (options == null ? void 0 : options.once) {
|
|
17701
|
-
_this1.off(eventName, listener);
|
|
17702
|
-
}
|
|
17703
|
-
});
|
|
17704
|
-
};
|
|
17705
|
-
/**
|
|
17706
|
-
* 获取事件名称对应的所有监听器
|
|
17707
|
-
* @param eventName - 事件名称
|
|
17708
|
-
* @returns - 返回事件名称对应的所有监听器
|
|
17709
|
-
*/ this.getListeners = function(eventName) {
|
|
17710
|
-
var _this_listeners_eventName;
|
|
17711
|
-
return ((_this_listeners_eventName = _this.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.map(function(param) {
|
|
17712
|
-
var listener = param.listener;
|
|
17713
|
-
return listener;
|
|
17714
|
-
})) || [];
|
|
17715
|
-
};
|
|
17716
|
-
};
|
|
17717
|
-
|
|
17718
17719
|
exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
17719
17720
|
_inherits(VFXItem, EffectsObject);
|
|
17720
17721
|
function VFXItem(engine, props) {
|
|
@@ -18064,42 +18065,36 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
18064
18065
|
EffectsObject.prototype.fromData.call(this, data);
|
|
18065
18066
|
var id = data.id, name = data.name, delay = data.delay, parentId = data.parentId, endBehavior = data.endBehavior, transform = data.transform, _data_duration = data.duration, duration = _data_duration === void 0 ? 0 : _data_duration;
|
|
18066
18067
|
this.props = data;
|
|
18067
|
-
//@ts-expect-error
|
|
18068
18068
|
this.type = data.type;
|
|
18069
18069
|
this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
|
|
18070
18070
|
this.name = name;
|
|
18071
18071
|
this.start = delay ? delay : this.start;
|
|
18072
|
+
var transformProps = {};
|
|
18072
18073
|
if (transform) {
|
|
18073
|
-
|
|
18074
|
-
transform.position = new Vector3().copyFrom(transform.position);
|
|
18074
|
+
transformProps.position = new Vector3().copyFrom(transform.position);
|
|
18075
18075
|
// FIXME: transform.rotation待删除
|
|
18076
|
+
//@ts-expect-error
|
|
18076
18077
|
if (transform.quat) {
|
|
18077
18078
|
//@ts-expect-error
|
|
18078
|
-
|
|
18079
|
+
transformProps.quat = new Quaternion(transform.quat.x, transform.quat.y, transform.quat.z, transform.quat.w);
|
|
18079
18080
|
} else {
|
|
18080
18081
|
var _transform_eulerHint;
|
|
18081
18082
|
//@ts-expect-error
|
|
18082
|
-
|
|
18083
|
+
transformProps.rotation = new Euler().copyFrom((_transform_eulerHint = transform.eulerHint) != null ? _transform_eulerHint : transform.rotation);
|
|
18083
18084
|
}
|
|
18084
|
-
|
|
18085
|
-
transform.scale = new Vector3().copyFrom(transform.scale);
|
|
18086
|
-
//@ts-expect-error
|
|
18085
|
+
transformProps.scale = new Vector3().copyFrom(transform.scale);
|
|
18087
18086
|
if (transform.size) {
|
|
18088
|
-
|
|
18089
|
-
transform.size = new Vector2().copyFrom(transform.size);
|
|
18087
|
+
transformProps.size = new Vector2().copyFrom(transform.size);
|
|
18090
18088
|
}
|
|
18091
|
-
//@ts-expect-error
|
|
18092
18089
|
if (transform.anchor) {
|
|
18093
|
-
|
|
18094
|
-
transform.anchor = new Vector2().copyFrom(transform.anchor);
|
|
18090
|
+
transformProps.anchor = new Vector2().copyFrom(transform.anchor);
|
|
18095
18091
|
}
|
|
18096
|
-
this.transform.setTransform(
|
|
18092
|
+
this.transform.setTransform(transformProps);
|
|
18097
18093
|
}
|
|
18098
18094
|
this.transform.name = this.name;
|
|
18099
18095
|
this.transform.engine = this.engine;
|
|
18100
18096
|
this.parentId = parentId;
|
|
18101
18097
|
this.duration = duration;
|
|
18102
|
-
// TODO spec endbehavior 类型修正
|
|
18103
18098
|
this.endBehavior = endBehavior;
|
|
18104
18099
|
if (!data.content) {
|
|
18105
18100
|
data.content = {
|
|
@@ -24891,9 +24886,23 @@ exports.TextComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
24891
24886
|
order: listIndex
|
|
24892
24887
|
};
|
|
24893
24888
|
this.interaction = interaction;
|
|
24889
|
+
this.cachePrefix = "-";
|
|
24890
|
+
this.renderInfo = getImageItemRenderInfo(this);
|
|
24891
|
+
var material = this.createMaterial(this.renderInfo, 2);
|
|
24892
|
+
this.worldMatrix = Matrix4.fromIdentity();
|
|
24893
|
+
this.material = material;
|
|
24894
|
+
this.material.setVector4("_TexOffset", new Vector4().setFromArray([
|
|
24895
|
+
0,
|
|
24896
|
+
0,
|
|
24897
|
+
1,
|
|
24898
|
+
1
|
|
24899
|
+
]));
|
|
24900
|
+
// TextComponentBase
|
|
24894
24901
|
this.updateWithOptions(options);
|
|
24895
|
-
// Text
|
|
24896
24902
|
this.updateTexture();
|
|
24903
|
+
this.setItem();
|
|
24904
|
+
// 恢复默认颜色
|
|
24905
|
+
this.material.setVector4("_Color", new Vector4(1, 1, 1, 1));
|
|
24897
24906
|
};
|
|
24898
24907
|
_proto.updateWithOptions = function updateWithOptions(options) {
|
|
24899
24908
|
// OVERRIDE by mixins
|
|
@@ -25211,7 +25220,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
25211
25220
|
}
|
|
25212
25221
|
//与 toDataURL() 两种方式都需要像素读取操作
|
|
25213
25222
|
var imageData = context.getImageData(0, 0, this.canvas.width, this.canvas.height);
|
|
25214
|
-
|
|
25223
|
+
var texture = Texture.createWithData(this.engine, {
|
|
25215
25224
|
data: new Uint8Array(imageData.data),
|
|
25216
25225
|
width: imageData.width,
|
|
25217
25226
|
height: imageData.height
|
|
@@ -25221,7 +25230,8 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
25221
25230
|
minFilter: glContext.LINEAR,
|
|
25222
25231
|
wrapS: glContext.CLAMP_TO_EDGE,
|
|
25223
25232
|
wrapT: glContext.CLAMP_TO_EDGE
|
|
25224
|
-
})
|
|
25233
|
+
});
|
|
25234
|
+
this.renderer.texture = texture;
|
|
25225
25235
|
this.isDirty = false;
|
|
25226
25236
|
};
|
|
25227
25237
|
_proto.getFontDesc = function getFontDesc() {
|
|
@@ -28409,7 +28419,7 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
28409
28419
|
var sourceItemData = this.engine.jsonSceneData[itemDataPath.id];
|
|
28410
28420
|
var itemProps = sourceItemData;
|
|
28411
28421
|
if (passRenderLevel(sourceItemData.renderLevel, this.renderLevel)) {
|
|
28412
|
-
if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle || itemProps.type === ItemType.spine || //@ts-expect-error
|
|
28422
|
+
if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle || itemProps.type === ItemType.spine || itemProps.type === ItemType.text || itemProps.type === ItemType.video || //@ts-expect-error
|
|
28413
28423
|
itemProps.type === ItemType.shape) {
|
|
28414
28424
|
for(var _iterator2 = _create_for_of_iterator_helper_loose(itemProps.components), _step2; !(_step2 = _iterator2()).done;){
|
|
28415
28425
|
var componentPath = _step2.value;
|
|
@@ -28430,6 +28440,13 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
28430
28440
|
}
|
|
28431
28441
|
}
|
|
28432
28442
|
items.push(itemDataPath);
|
|
28443
|
+
} else {
|
|
28444
|
+
// 非预合成元素未达到渲染等级的转化为空节点。
|
|
28445
|
+
// 预合成元素有根据 item type 的子元素加载判断,没法保留空节点,这边先整体过滤掉。
|
|
28446
|
+
if (itemProps.type !== ItemType.composition) {
|
|
28447
|
+
itemProps.components = [];
|
|
28448
|
+
items.push(itemDataPath);
|
|
28449
|
+
}
|
|
28433
28450
|
}
|
|
28434
28451
|
}
|
|
28435
28452
|
composition.items = items;
|
|
@@ -28674,10 +28691,13 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
28674
28691
|
assertExist(sourceContent);
|
|
28675
28692
|
_this.renderer = renderer;
|
|
28676
28693
|
_this.refCompositionProps = refCompositionProps;
|
|
28677
|
-
|
|
28694
|
+
// Instantiate composition rootItem
|
|
28695
|
+
_this.rootItem = new exports.VFXItem(_this.getEngine());
|
|
28678
28696
|
_this.rootItem.name = "rootItem";
|
|
28697
|
+
_this.rootItem.duration = sourceContent.duration;
|
|
28698
|
+
_this.rootItem.endBehavior = sourceContent.endBehavior;
|
|
28679
28699
|
_this.rootItem.composition = _assert_this_initialized(_this);
|
|
28680
|
-
//
|
|
28700
|
+
// Create rootCompositionComponent
|
|
28681
28701
|
_this.rootComposition = _this.rootItem.addComponent(CompositionComponent);
|
|
28682
28702
|
_this.width = width;
|
|
28683
28703
|
_this.height = height;
|
|
@@ -31351,7 +31371,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
|
|
|
31351
31371
|
registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
|
|
31352
31372
|
registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
|
|
31353
31373
|
registerPlugin("interact", InteractLoader, exports.VFXItem, true);
|
|
31354
|
-
var version = "2.2.
|
|
31374
|
+
var version = "2.2.3";
|
|
31355
31375
|
logger.info("Core version: " + version + ".");
|
|
31356
31376
|
|
|
31357
31377
|
exports.AbstractPlugin = AbstractPlugin;
|