@galacean/effects-threejs 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/index.js +130 -110
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +130 -110
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.2.
|
|
6
|
+
* Version: v2.2.3
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -16608,17 +16608,10 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
16608
16608
|
];
|
|
16609
16609
|
};
|
|
16610
16610
|
_proto.onStart = function onStart() {
|
|
16611
|
-
var _this = this;
|
|
16612
|
-
var _this_item_composition;
|
|
16613
16611
|
var options = this.item.props.content.options;
|
|
16614
16612
|
var env = this.item.engine.renderer.env;
|
|
16615
16613
|
var composition = this.item.composition;
|
|
16616
16614
|
var _this_interactData_options = this.interactData.options, type = _this_interactData_options.type, showPreview = _this_interactData_options.showPreview;
|
|
16617
|
-
(_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.on("goto", function() {
|
|
16618
|
-
if (_this.item.time > 0) {
|
|
16619
|
-
_this.duringPlay = true;
|
|
16620
|
-
}
|
|
16621
|
-
});
|
|
16622
16615
|
if (type === InteractType.CLICK) {
|
|
16623
16616
|
this.clickable = true;
|
|
16624
16617
|
if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
@@ -16653,18 +16646,26 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
16653
16646
|
_proto.onEnable = function onEnable() {
|
|
16654
16647
|
RendererComponent.prototype.onEnable.call(this);
|
|
16655
16648
|
var type = this.interactData.options.type;
|
|
16649
|
+
var env = this.item.engine.renderer.env;
|
|
16656
16650
|
if (type === InteractType.CLICK) {
|
|
16657
16651
|
this.clickable = true;
|
|
16652
|
+
} else if (type === InteractType.DRAG) {
|
|
16653
|
+
var options = this.interactData.options;
|
|
16654
|
+
var enableInEditor = options.enableInEditor;
|
|
16655
|
+
if (env !== PLAYER_OPTIONS_ENV_EDITOR || enableInEditor) {
|
|
16656
|
+
var _this_item_composition;
|
|
16657
|
+
((_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.event) && this.beginDragTarget(options, this.item.composition.event);
|
|
16658
|
+
}
|
|
16658
16659
|
}
|
|
16659
16660
|
};
|
|
16660
16661
|
_proto.onUpdate = function onUpdate(dt) {
|
|
16661
16662
|
var _this_previewContent;
|
|
16663
|
+
this.duringPlay = true;
|
|
16662
16664
|
// trigger messageBegin when item enter
|
|
16663
|
-
if (this.item.time > 0 &&
|
|
16665
|
+
if (this.item.time > 0 && this.item.time - dt / 1000 <= 0) {
|
|
16664
16666
|
var _this_item_composition;
|
|
16665
16667
|
var options = this.item.props.content.options;
|
|
16666
16668
|
(_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.addInteractiveItem(this.item, options.type);
|
|
16667
|
-
this.duringPlay = true;
|
|
16668
16669
|
}
|
|
16669
16670
|
(_this_previewContent = this.previewContent) == null ? void 0 : _this_previewContent.updateMesh();
|
|
16670
16671
|
if (!this.dragEvent || !this.bouncingArg) {
|
|
@@ -17190,6 +17191,83 @@ var PlayState;
|
|
|
17190
17191
|
PlayState[PlayState["Paused"] = 1] = "Paused";
|
|
17191
17192
|
})(PlayState || (PlayState = {}));
|
|
17192
17193
|
|
|
17194
|
+
/**
|
|
17195
|
+
*
|
|
17196
|
+
*/ /**
|
|
17197
|
+
* 事件监听器
|
|
17198
|
+
*/ var EventEmitter = function EventEmitter() {
|
|
17199
|
+
var _this = this;
|
|
17200
|
+
var _this1 = this;
|
|
17201
|
+
this.listeners = {};
|
|
17202
|
+
/**
|
|
17203
|
+
* 移除事件监听器
|
|
17204
|
+
* @param eventName - 事件名称
|
|
17205
|
+
* @param listener - 事件监听器
|
|
17206
|
+
* @returns
|
|
17207
|
+
*/ this.off = function(eventName, listener) {
|
|
17208
|
+
if (!_this.listeners[eventName]) {
|
|
17209
|
+
return;
|
|
17210
|
+
}
|
|
17211
|
+
_this.listeners[eventName] = _this.listeners[eventName].filter(function(param) {
|
|
17212
|
+
var l = param.listener;
|
|
17213
|
+
return l !== listener;
|
|
17214
|
+
});
|
|
17215
|
+
};
|
|
17216
|
+
/**
|
|
17217
|
+
* 监听事件
|
|
17218
|
+
* @param eventName - 事件名称
|
|
17219
|
+
* @param listener - 事件监听器
|
|
17220
|
+
* @param options - 事件监听器选项
|
|
17221
|
+
* @returns
|
|
17222
|
+
*/ this.on = function(eventName, listener, options) {
|
|
17223
|
+
_this.listeners[eventName] = _this.listeners[eventName] || [];
|
|
17224
|
+
_this.listeners[eventName].push({
|
|
17225
|
+
listener: listener,
|
|
17226
|
+
options: options
|
|
17227
|
+
});
|
|
17228
|
+
return function() {
|
|
17229
|
+
return _this.off(eventName, listener);
|
|
17230
|
+
};
|
|
17231
|
+
};
|
|
17232
|
+
/**
|
|
17233
|
+
* 一次性监听事件
|
|
17234
|
+
* @param eventName - 事件名称
|
|
17235
|
+
* @param listener - 事件监听器
|
|
17236
|
+
*/ this.once = function(eventName, listener) {
|
|
17237
|
+
_this.on(eventName, listener, {
|
|
17238
|
+
once: true
|
|
17239
|
+
});
|
|
17240
|
+
};
|
|
17241
|
+
/**
|
|
17242
|
+
* 触发事件
|
|
17243
|
+
* @param eventName - 事件名称
|
|
17244
|
+
* @param args - 事件参数
|
|
17245
|
+
*/ this.emit = function(eventName) {
|
|
17246
|
+
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
17247
|
+
args[_key - 1] = arguments[_key];
|
|
17248
|
+
}
|
|
17249
|
+
var _this_listeners_eventName;
|
|
17250
|
+
(_this_listeners_eventName = _this1.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.forEach(function(param) {
|
|
17251
|
+
var listener = param.listener, options = param.options;
|
|
17252
|
+
listener.apply(void 0, [].concat(args));
|
|
17253
|
+
if (options == null ? void 0 : options.once) {
|
|
17254
|
+
_this1.off(eventName, listener);
|
|
17255
|
+
}
|
|
17256
|
+
});
|
|
17257
|
+
};
|
|
17258
|
+
/**
|
|
17259
|
+
* 获取事件名称对应的所有监听器
|
|
17260
|
+
* @param eventName - 事件名称
|
|
17261
|
+
* @returns - 返回事件名称对应的所有监听器
|
|
17262
|
+
*/ this.getListeners = function(eventName) {
|
|
17263
|
+
var _this_listeners_eventName;
|
|
17264
|
+
return ((_this_listeners_eventName = _this.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.map(function(param) {
|
|
17265
|
+
var listener = param.listener;
|
|
17266
|
+
return listener;
|
|
17267
|
+
})) || [];
|
|
17268
|
+
};
|
|
17269
|
+
};
|
|
17270
|
+
|
|
17193
17271
|
var tempQuat$1 = new Quaternion();
|
|
17194
17272
|
var seed$4 = 1;
|
|
17195
17273
|
// TODO 继承 Component
|
|
@@ -17660,83 +17738,6 @@ var seed$4 = 1;
|
|
|
17660
17738
|
return Transform;
|
|
17661
17739
|
}();
|
|
17662
17740
|
|
|
17663
|
-
/**
|
|
17664
|
-
*
|
|
17665
|
-
*/ /**
|
|
17666
|
-
* 事件监听器
|
|
17667
|
-
*/ var EventEmitter = function EventEmitter() {
|
|
17668
|
-
var _this = this;
|
|
17669
|
-
var _this1 = this;
|
|
17670
|
-
this.listeners = {};
|
|
17671
|
-
/**
|
|
17672
|
-
* 移除事件监听器
|
|
17673
|
-
* @param eventName - 事件名称
|
|
17674
|
-
* @param listener - 事件监听器
|
|
17675
|
-
* @returns
|
|
17676
|
-
*/ this.off = function(eventName, listener) {
|
|
17677
|
-
if (!_this.listeners[eventName]) {
|
|
17678
|
-
return;
|
|
17679
|
-
}
|
|
17680
|
-
_this.listeners[eventName] = _this.listeners[eventName].filter(function(param) {
|
|
17681
|
-
var l = param.listener;
|
|
17682
|
-
return l !== listener;
|
|
17683
|
-
});
|
|
17684
|
-
};
|
|
17685
|
-
/**
|
|
17686
|
-
* 监听事件
|
|
17687
|
-
* @param eventName - 事件名称
|
|
17688
|
-
* @param listener - 事件监听器
|
|
17689
|
-
* @param options - 事件监听器选项
|
|
17690
|
-
* @returns
|
|
17691
|
-
*/ this.on = function(eventName, listener, options) {
|
|
17692
|
-
_this.listeners[eventName] = _this.listeners[eventName] || [];
|
|
17693
|
-
_this.listeners[eventName].push({
|
|
17694
|
-
listener: listener,
|
|
17695
|
-
options: options
|
|
17696
|
-
});
|
|
17697
|
-
return function() {
|
|
17698
|
-
return _this.off(eventName, listener);
|
|
17699
|
-
};
|
|
17700
|
-
};
|
|
17701
|
-
/**
|
|
17702
|
-
* 一次性监听事件
|
|
17703
|
-
* @param eventName - 事件名称
|
|
17704
|
-
* @param listener - 事件监听器
|
|
17705
|
-
*/ this.once = function(eventName, listener) {
|
|
17706
|
-
_this.on(eventName, listener, {
|
|
17707
|
-
once: true
|
|
17708
|
-
});
|
|
17709
|
-
};
|
|
17710
|
-
/**
|
|
17711
|
-
* 触发事件
|
|
17712
|
-
* @param eventName - 事件名称
|
|
17713
|
-
* @param args - 事件参数
|
|
17714
|
-
*/ this.emit = function(eventName) {
|
|
17715
|
-
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
17716
|
-
args[_key - 1] = arguments[_key];
|
|
17717
|
-
}
|
|
17718
|
-
var _this_listeners_eventName;
|
|
17719
|
-
(_this_listeners_eventName = _this1.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.forEach(function(param) {
|
|
17720
|
-
var listener = param.listener, options = param.options;
|
|
17721
|
-
listener.apply(void 0, [].concat(args));
|
|
17722
|
-
if (options == null ? void 0 : options.once) {
|
|
17723
|
-
_this1.off(eventName, listener);
|
|
17724
|
-
}
|
|
17725
|
-
});
|
|
17726
|
-
};
|
|
17727
|
-
/**
|
|
17728
|
-
* 获取事件名称对应的所有监听器
|
|
17729
|
-
* @param eventName - 事件名称
|
|
17730
|
-
* @returns - 返回事件名称对应的所有监听器
|
|
17731
|
-
*/ this.getListeners = function(eventName) {
|
|
17732
|
-
var _this_listeners_eventName;
|
|
17733
|
-
return ((_this_listeners_eventName = _this.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.map(function(param) {
|
|
17734
|
-
var listener = param.listener;
|
|
17735
|
-
return listener;
|
|
17736
|
-
})) || [];
|
|
17737
|
-
};
|
|
17738
|
-
};
|
|
17739
|
-
|
|
17740
17741
|
exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
17741
17742
|
_inherits(VFXItem, EffectsObject);
|
|
17742
17743
|
function VFXItem(engine, props) {
|
|
@@ -18086,42 +18087,36 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
18086
18087
|
EffectsObject.prototype.fromData.call(this, data);
|
|
18087
18088
|
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;
|
|
18088
18089
|
this.props = data;
|
|
18089
|
-
//@ts-expect-error
|
|
18090
18090
|
this.type = data.type;
|
|
18091
18091
|
this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
|
|
18092
18092
|
this.name = name;
|
|
18093
18093
|
this.start = delay ? delay : this.start;
|
|
18094
|
+
var transformProps = {};
|
|
18094
18095
|
if (transform) {
|
|
18095
|
-
|
|
18096
|
-
transform.position = new Vector3().copyFrom(transform.position);
|
|
18096
|
+
transformProps.position = new Vector3().copyFrom(transform.position);
|
|
18097
18097
|
// FIXME: transform.rotation待删除
|
|
18098
|
+
//@ts-expect-error
|
|
18098
18099
|
if (transform.quat) {
|
|
18099
18100
|
//@ts-expect-error
|
|
18100
|
-
|
|
18101
|
+
transformProps.quat = new Quaternion(transform.quat.x, transform.quat.y, transform.quat.z, transform.quat.w);
|
|
18101
18102
|
} else {
|
|
18102
18103
|
var _transform_eulerHint;
|
|
18103
18104
|
//@ts-expect-error
|
|
18104
|
-
|
|
18105
|
+
transformProps.rotation = new Euler().copyFrom((_transform_eulerHint = transform.eulerHint) != null ? _transform_eulerHint : transform.rotation);
|
|
18105
18106
|
}
|
|
18106
|
-
|
|
18107
|
-
transform.scale = new Vector3().copyFrom(transform.scale);
|
|
18108
|
-
//@ts-expect-error
|
|
18107
|
+
transformProps.scale = new Vector3().copyFrom(transform.scale);
|
|
18109
18108
|
if (transform.size) {
|
|
18110
|
-
|
|
18111
|
-
transform.size = new Vector2().copyFrom(transform.size);
|
|
18109
|
+
transformProps.size = new Vector2().copyFrom(transform.size);
|
|
18112
18110
|
}
|
|
18113
|
-
//@ts-expect-error
|
|
18114
18111
|
if (transform.anchor) {
|
|
18115
|
-
|
|
18116
|
-
transform.anchor = new Vector2().copyFrom(transform.anchor);
|
|
18112
|
+
transformProps.anchor = new Vector2().copyFrom(transform.anchor);
|
|
18117
18113
|
}
|
|
18118
|
-
this.transform.setTransform(
|
|
18114
|
+
this.transform.setTransform(transformProps);
|
|
18119
18115
|
}
|
|
18120
18116
|
this.transform.name = this.name;
|
|
18121
18117
|
this.transform.engine = this.engine;
|
|
18122
18118
|
this.parentId = parentId;
|
|
18123
18119
|
this.duration = duration;
|
|
18124
|
-
// TODO spec endbehavior 类型修正
|
|
18125
18120
|
this.endBehavior = endBehavior;
|
|
18126
18121
|
if (!data.content) {
|
|
18127
18122
|
data.content = {
|
|
@@ -24913,9 +24908,23 @@ exports.TextComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
24913
24908
|
order: listIndex
|
|
24914
24909
|
};
|
|
24915
24910
|
this.interaction = interaction;
|
|
24911
|
+
this.cachePrefix = "-";
|
|
24912
|
+
this.renderInfo = getImageItemRenderInfo(this);
|
|
24913
|
+
var material = this.createMaterial(this.renderInfo, 2);
|
|
24914
|
+
this.worldMatrix = Matrix4.fromIdentity();
|
|
24915
|
+
this.material = material;
|
|
24916
|
+
this.material.setVector4("_TexOffset", new Vector4().setFromArray([
|
|
24917
|
+
0,
|
|
24918
|
+
0,
|
|
24919
|
+
1,
|
|
24920
|
+
1
|
|
24921
|
+
]));
|
|
24922
|
+
// TextComponentBase
|
|
24916
24923
|
this.updateWithOptions(options);
|
|
24917
|
-
// Text
|
|
24918
24924
|
this.updateTexture();
|
|
24925
|
+
this.setItem();
|
|
24926
|
+
// 恢复默认颜色
|
|
24927
|
+
this.material.setVector4("_Color", new Vector4(1, 1, 1, 1));
|
|
24919
24928
|
};
|
|
24920
24929
|
_proto.updateWithOptions = function updateWithOptions(options) {
|
|
24921
24930
|
// OVERRIDE by mixins
|
|
@@ -25233,7 +25242,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
25233
25242
|
}
|
|
25234
25243
|
//与 toDataURL() 两种方式都需要像素读取操作
|
|
25235
25244
|
var imageData = context.getImageData(0, 0, this.canvas.width, this.canvas.height);
|
|
25236
|
-
|
|
25245
|
+
var texture = Texture.createWithData(this.engine, {
|
|
25237
25246
|
data: new Uint8Array(imageData.data),
|
|
25238
25247
|
width: imageData.width,
|
|
25239
25248
|
height: imageData.height
|
|
@@ -25243,7 +25252,8 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
25243
25252
|
minFilter: glContext.LINEAR,
|
|
25244
25253
|
wrapS: glContext.CLAMP_TO_EDGE,
|
|
25245
25254
|
wrapT: glContext.CLAMP_TO_EDGE
|
|
25246
|
-
})
|
|
25255
|
+
});
|
|
25256
|
+
this.renderer.texture = texture;
|
|
25247
25257
|
this.isDirty = false;
|
|
25248
25258
|
};
|
|
25249
25259
|
_proto.getFontDesc = function getFontDesc() {
|
|
@@ -28431,7 +28441,7 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
28431
28441
|
var sourceItemData = this.engine.jsonSceneData[itemDataPath.id];
|
|
28432
28442
|
var itemProps = sourceItemData;
|
|
28433
28443
|
if (passRenderLevel(sourceItemData.renderLevel, this.renderLevel)) {
|
|
28434
|
-
if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle || itemProps.type === ItemType.spine || //@ts-expect-error
|
|
28444
|
+
if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle || itemProps.type === ItemType.spine || itemProps.type === ItemType.text || itemProps.type === ItemType.video || //@ts-expect-error
|
|
28435
28445
|
itemProps.type === ItemType.shape) {
|
|
28436
28446
|
for(var _iterator2 = _create_for_of_iterator_helper_loose(itemProps.components), _step2; !(_step2 = _iterator2()).done;){
|
|
28437
28447
|
var componentPath = _step2.value;
|
|
@@ -28452,6 +28462,13 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
28452
28462
|
}
|
|
28453
28463
|
}
|
|
28454
28464
|
items.push(itemDataPath);
|
|
28465
|
+
} else {
|
|
28466
|
+
// 非预合成元素未达到渲染等级的转化为空节点。
|
|
28467
|
+
// 预合成元素有根据 item type 的子元素加载判断,没法保留空节点,这边先整体过滤掉。
|
|
28468
|
+
if (itemProps.type !== ItemType.composition) {
|
|
28469
|
+
itemProps.components = [];
|
|
28470
|
+
items.push(itemDataPath);
|
|
28471
|
+
}
|
|
28455
28472
|
}
|
|
28456
28473
|
}
|
|
28457
28474
|
composition.items = items;
|
|
@@ -28696,10 +28713,13 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
28696
28713
|
assertExist(sourceContent);
|
|
28697
28714
|
_this.renderer = renderer;
|
|
28698
28715
|
_this.refCompositionProps = refCompositionProps;
|
|
28699
|
-
|
|
28716
|
+
// Instantiate composition rootItem
|
|
28717
|
+
_this.rootItem = new exports.VFXItem(_this.getEngine());
|
|
28700
28718
|
_this.rootItem.name = "rootItem";
|
|
28719
|
+
_this.rootItem.duration = sourceContent.duration;
|
|
28720
|
+
_this.rootItem.endBehavior = sourceContent.endBehavior;
|
|
28701
28721
|
_this.rootItem.composition = _assert_this_initialized(_this);
|
|
28702
|
-
//
|
|
28722
|
+
// Create rootCompositionComponent
|
|
28703
28723
|
_this.rootComposition = _this.rootItem.addComponent(CompositionComponent);
|
|
28704
28724
|
_this.width = width;
|
|
28705
28725
|
_this.height = height;
|
|
@@ -31373,7 +31393,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
|
|
|
31373
31393
|
registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
|
|
31374
31394
|
registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
|
|
31375
31395
|
registerPlugin("interact", InteractLoader, exports.VFXItem, true);
|
|
31376
|
-
var version$1 = "2.2.
|
|
31396
|
+
var version$1 = "2.2.3";
|
|
31377
31397
|
logger.info("Core version: " + version$1 + ".");
|
|
31378
31398
|
|
|
31379
31399
|
var _obj;
|
|
@@ -33006,7 +33026,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
33006
33026
|
*/ Mesh.create = function(engine, props) {
|
|
33007
33027
|
return new ThreeMesh(engine, props);
|
|
33008
33028
|
};
|
|
33009
|
-
var version = "2.2.
|
|
33029
|
+
var version = "2.2.3";
|
|
33010
33030
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
33011
33031
|
|
|
33012
33032
|
exports.AbstractPlugin = AbstractPlugin;
|