@galacean/effects-core 2.6.0-beta.1 → 2.6.1

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.
@@ -29,12 +29,14 @@ export type CompositionEvent<C> = {
29
29
  ];
30
30
  /**
31
31
  * 合成开始播放事件
32
+ * @since 2.6.0
32
33
  */
33
34
  ['play']: [playInfo: {
34
35
  time: number;
35
36
  }];
36
37
  /**
37
38
  * 合成暂停事件
39
+ * @since 2.6.0
38
40
  */
39
41
  ['pause']: [];
40
42
  /**
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.6.0-beta.1
6
+ * Version: v2.6.1
7
7
  */
8
8
 
9
9
  'use strict';
@@ -466,6 +466,8 @@ function getPixelRatio() {
466
466
  }
467
467
  return 1;
468
468
  }
469
+ // window 对象不存在时需要判断
470
+ var canUseBOM = typeof window !== "undefined";
469
471
  function isIOS() {
470
472
  // real ios device not in simulator
471
473
  return !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
@@ -8290,6 +8292,8 @@ function gpuTimer(gl) {
8290
8292
 
8291
8293
  var initErrors = [];
8292
8294
  var glContext = {};
8295
+ var IOS16_LOCKDOWN_MODE = "iOS16 lockdown mode, WebGL Constants not in global";
8296
+ var WEBGL_CONSTANTS_NOT_IN_GLOBAL = "WebGL Constants not in global, please check your environment";
8293
8297
  if (!initErrors.length) {
8294
8298
  initGLContext();
8295
8299
  }
@@ -8301,8 +8305,12 @@ function initGLContext() {
8301
8305
  copy(WebGLRenderingContext);
8302
8306
  copy(WebGLRenderingContext.prototype);
8303
8307
  } else {
8304
- initErrors.push(isIOS() ? // iOS 16 lockdown mode
8305
- "iOS16 lockdown mode, WebGL Constants not in global" : "WebGL Constants not in global, please check your environment");
8308
+ if (canUseBOM) {
8309
+ initErrors.push(// iOS 16 lockdown mode
8310
+ isIOS() ? IOS16_LOCKDOWN_MODE : WEBGL_CONSTANTS_NOT_IN_GLOBAL);
8311
+ } else {
8312
+ initErrors.push(WEBGL_CONSTANTS_NOT_IN_GLOBAL);
8313
+ }
8306
8314
  }
8307
8315
  if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
8308
8316
  // @ts-expect-error set default value
@@ -10012,18 +10020,15 @@ var MaskProcessor = /*#__PURE__*/ function() {
10012
10020
  _proto.getRefValue = function getRefValue() {
10013
10021
  return 1;
10014
10022
  };
10015
- _proto.getMaskMode = function getMaskMode(data) {
10023
+ _proto.setMaskOptions = function setMaskOptions(data) {
10016
10024
  var _data_isMask = data.isMask, isMask = _data_isMask === void 0 ? false : _data_isMask, _data_inverted = data.inverted, inverted = _data_inverted === void 0 ? false : _data_inverted, reference = data.reference, _data_alphaMaskEnabled = data.alphaMaskEnabled, alphaMaskEnabled = _data_alphaMaskEnabled === void 0 ? false : _data_alphaMaskEnabled;
10017
10025
  this.alphaMaskEnabled = alphaMaskEnabled;
10018
10026
  if (isMask) {
10019
10027
  this.maskMode = exports.MaskMode.MASK;
10020
10028
  } else {
10021
10029
  this.maskMode = inverted ? exports.MaskMode.REVERSE_OBSCURED : exports.MaskMode.OBSCURED;
10022
- if (reference) {
10023
- this.maskable = this.engine.findObject(reference);
10024
- }
10030
+ this.maskable = this.engine.findObject(reference);
10025
10031
  }
10026
- return this.maskMode;
10027
10032
  };
10028
10033
  _proto.drawStencilMask = function drawStencilMask(renderer) {
10029
10034
  if (this.maskable) {
@@ -15210,7 +15215,7 @@ var singleSplits = [
15210
15215
  var textureSheetAnimation = baseRenderComponentData.textureSheetAnimation;
15211
15216
  var maskOptions = baseRenderComponentData.mask;
15212
15217
  if (maskOptions) {
15213
- this.maskManager.getMaskMode(maskOptions);
15218
+ this.maskManager.setMaskOptions(maskOptions);
15214
15219
  }
15215
15220
  // TODO 新蒙板上线后移除
15216
15221
  //-------------------------------------------------------------------------
@@ -15616,7 +15621,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(BaseRenderComponent) {
15616
15621
  }
15617
15622
  }
15618
15623
  if (data.mask) {
15619
- this.maskManager.getMaskMode(data.mask);
15624
+ this.maskManager.setMaskOptions(data.mask);
15620
15625
  }
15621
15626
  var maskRef = this.maskManager.getRefValue();
15622
15627
  this.material.stencilRef = maskRef !== undefined ? [
@@ -15843,6 +15848,7 @@ var EventSystem = /*#__PURE__*/ function() {
15843
15848
  var touchstart = "mousedown";
15844
15849
  var touchmove = "mousemove";
15845
15850
  var touchend = "mouseup";
15851
+ var touchcancel = "mouseleave";
15846
15852
  var getTouchEventValue = function(event, x, y, dx, dy) {
15847
15853
  if (dx === void 0) dx = 0;
15848
15854
  if (dy === void 0) dy = 0;
@@ -15896,6 +15902,7 @@ var EventSystem = /*#__PURE__*/ function() {
15896
15902
  touchstart = "touchstart";
15897
15903
  touchmove = "touchmove";
15898
15904
  touchend = "touchend";
15905
+ touchcancel = "touchcancel";
15899
15906
  }
15900
15907
  var _obj;
15901
15908
  this.nativeHandlers = (_obj = {}, _obj[touchstart] = function(event) {
@@ -15938,6 +15945,7 @@ var EventSystem = /*#__PURE__*/ function() {
15938
15945
  }
15939
15946
  currentTouch = 0;
15940
15947
  }, _obj);
15948
+ this.nativeHandlers[touchcancel] = this.nativeHandlers[touchend];
15941
15949
  Object.keys(this.nativeHandlers).forEach(function(name) {
15942
15950
  var _this_target;
15943
15951
  (_this_target = _this.target) == null ? void 0 : _this_target.addEventListener(String(name), _this.nativeHandlers[name]);
@@ -18071,16 +18079,23 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
18071
18079
  var _this;
18072
18080
  _this = RendererComponent.apply(this, arguments) || this;
18073
18081
  /**
18074
- * 拖拽的惯性衰减系数,范围[0, 1], 越大惯性越强
18082
+ * 拖拽后的惯性衰减系数,范围[0, 1], 越大惯性越强
18083
+ * @default 0.95
18075
18084
  */ _this.downgrade = 0.95;
18076
18085
  /**
18077
- * 拖拽的距离映射系数,越大越容易拖动
18086
+ * 拖拽后的惯性速度,范围[0, +∞), 越大惯性越强
18087
+ * @default 25
18088
+ * @since 2.6.0
18089
+ */ _this.speed = 25;
18090
+ /**
18091
+ * 拖拽时的距离映射系数,越大越容易拖动
18092
+ * @default [1, 1]
18078
18093
  */ _this.dragRatio = [
18079
18094
  1,
18080
18095
  1
18081
18096
  ];
18082
18097
  /**
18083
- * 拖拽X范围
18098
+ * 拖拽范围(编辑器制作时已经设置好,特殊情况可运行时修改)
18084
18099
  */ _this.dragRange = {
18085
18100
  dxRange: [
18086
18101
  0,
@@ -18091,6 +18106,13 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
18091
18106
  0
18092
18107
  ]
18093
18108
  };
18109
+ /**
18110
+ * 滑动失效区域,范围[0, 1],单位 %,避免滑动触控冲突(如 iOS 右滑退出时不执行)
18111
+ * > 若是数组形式,格式为:[top、right、bottom、left]
18112
+ * @since 2.6.0
18113
+ * @default 0
18114
+ */ _this.invalidBorderRange = 0;
18115
+ _this.invalidByBorderRange = false;
18094
18116
  _this.duringPlay = false;
18095
18117
  /** 是否响应点击和拖拽交互事件 */ _this._interactive = true;
18096
18118
  _this.lastTime = -1;
@@ -18130,7 +18152,6 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
18130
18152
  ];
18131
18153
  };
18132
18154
  _proto.onStart = function onStart() {
18133
- var options = this.item.props.content.options;
18134
18155
  var env = this.item.engine.renderer.env;
18135
18156
  var composition = this.item.composition;
18136
18157
  var _this_interactData_options = this.interactData.options, type = _this_interactData_options.type, showPreview = _this_interactData_options.showPreview;
@@ -18143,11 +18164,6 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
18143
18164
  }
18144
18165
  }
18145
18166
  }
18146
- if (options.type === InteractType.DRAG) {
18147
- if (env !== PLAYER_OPTIONS_ENV_EDITOR || options.enableInEditor) {
18148
- (composition == null ? void 0 : composition.event) && this.beginDragTarget(options, composition.event);
18149
- }
18150
- }
18151
18167
  if (this.previewContent) {
18152
18168
  this.previewContent.mesh.item = this.item;
18153
18169
  this.materials = this.previewContent.mesh.materials;
@@ -18157,7 +18173,8 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
18157
18173
  _proto.onDisable = function onDisable() {
18158
18174
  RendererComponent.prototype.onDisable.call(this);
18159
18175
  if (this.item && this.item.composition) {
18160
- if (this.duringPlay && !this.item.transform.getValid()) {
18176
+ // Triggers the Message end event, do not trigger when reverse playback
18177
+ if (this.duringPlay && !this.item.transform.getValid() && this.item.composition.getSpeed() > 0) {
18161
18178
  this.item.composition.removeInteractiveItem(this.item, this.item.props.content.options.type);
18162
18179
  this.duringPlay = false;
18163
18180
  }
@@ -18176,14 +18193,17 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
18176
18193
  var enableInEditor = options.enableInEditor;
18177
18194
  if (env !== PLAYER_OPTIONS_ENV_EDITOR || enableInEditor) {
18178
18195
  var _this_item_composition;
18179
- ((_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.event) && this.beginDragTarget(options, this.item.composition.event);
18196
+ var event = ((_this_item_composition = this.item.composition) != null ? _this_item_composition : {}).event;
18197
+ if (event) {
18198
+ this.beginDragTarget(options, event);
18199
+ }
18180
18200
  }
18181
18201
  }
18182
18202
  };
18183
18203
  _proto.onUpdate = function onUpdate(dt) {
18184
18204
  var _this_previewContent;
18185
18205
  this.duringPlay = true;
18186
- // trigger messageBegin when item enter
18206
+ // Trigger messageBegin when item enter
18187
18207
  if (this.lastTime <= this.item.time) {
18188
18208
  if (this.item.time >= 0 && this.lastTime < 0) {
18189
18209
  var _this_item_composition;
@@ -18191,8 +18211,8 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
18191
18211
  (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.addInteractiveItem(this.item, options.type);
18192
18212
  }
18193
18213
  } else {
18194
- // loop trigger
18195
- if (this.item.time >= 0) {
18214
+ // Loop trigger, do not trigger when reverse playback
18215
+ if (this.item.time >= 0 && dt > 0) {
18196
18216
  var _this_item_composition1;
18197
18217
  var options1 = this.item.props.content.options;
18198
18218
  (_this_item_composition1 = this.item.composition) == null ? void 0 : _this_item_composition1.addInteractiveItem(this.item, options1.type);
@@ -18266,6 +18286,13 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
18266
18286
  if (!_this.canInteract()) {
18267
18287
  return;
18268
18288
  }
18289
+ _this.invalidByBorderRange = _this.checkInvalidBorderRange({
18290
+ x: event.x,
18291
+ y: event.y
18292
+ });
18293
+ if (_this.invalidByBorderRange) {
18294
+ return;
18295
+ }
18269
18296
  _this.dragEvent = null;
18270
18297
  _this.bouncingArg = null;
18271
18298
  var camera = (_this_item_composition = _this.item.composition) == null ? void 0 : _this_item_composition.camera;
@@ -18283,6 +18310,9 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
18283
18310
  };
18284
18311
  },
18285
18312
  touchmove: function(event) {
18313
+ if (_this.invalidByBorderRange) {
18314
+ return;
18315
+ }
18286
18316
  _this.handleDragMove(dragEvent, event);
18287
18317
  _this.bouncingArg = event;
18288
18318
  },
@@ -18292,9 +18322,8 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
18292
18322
  }
18293
18323
  var bouncingArg = _this.bouncingArg;
18294
18324
  if (!shouldIgnoreBouncing(bouncingArg, 3) && bouncingArg) {
18295
- var speed = 5;
18296
- bouncingArg.vx *= speed;
18297
- bouncingArg.vy *= speed;
18325
+ bouncingArg.vx *= _this.speed;
18326
+ bouncingArg.vy *= _this.speed;
18298
18327
  _this.dragEvent = _extends({}, dragEvent);
18299
18328
  }
18300
18329
  dragEvent = null;
@@ -18345,6 +18374,31 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
18345
18374
  var _this_item_composition;
18346
18375
  return Boolean((_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.interactive) && this._interactive;
18347
18376
  };
18377
+ /**
18378
+ * 检查滑动手势边界
18379
+ * @param position
18380
+ */ _proto.checkInvalidBorderRange = function checkInvalidBorderRange(position) {
18381
+ var invalidBorderRange = this.invalidBorderRange;
18382
+ if (invalidBorderRange) {
18383
+ var top = 0;
18384
+ var right = 0;
18385
+ var bottom = 0;
18386
+ var left = 0;
18387
+ if (typeof invalidBorderRange === "number") {
18388
+ top = invalidBorderRange;
18389
+ right = invalidBorderRange;
18390
+ bottom = invalidBorderRange;
18391
+ left = invalidBorderRange;
18392
+ } else if (isArray(invalidBorderRange)) {
18393
+ var ref, ref1, ref2, ref3, ref4;
18394
+ ref = invalidBorderRange, ref1 = ref[0], top = ref1 === void 0 ? 0 : ref1, ref2 = ref[1], right = ref2 === void 0 ? 0 : ref2, ref3 = ref[2], bottom = ref3 === void 0 ? 0 : ref3, ref4 = ref[3], left = ref4 === void 0 ? 0 : ref4;
18395
+ }
18396
+ if (position.x < left - 1 || position.x > 1 - right || position.y < top - 1 || position.y > 1 - bottom) {
18397
+ return true;
18398
+ }
18399
+ }
18400
+ return false;
18401
+ };
18348
18402
  _create_class(InteractComponent, [
18349
18403
  {
18350
18404
  key: "interactive",
@@ -22139,7 +22193,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
22139
22193
  this.options.startSize = createValueGetter(options.startSize);
22140
22194
  this.options.sizeAspect = createValueGetter(options.sizeAspect || 1);
22141
22195
  }
22142
- var maskProps = this.getMaskOptions(props);
22196
+ if (props.mask) {
22197
+ this.maskManager.setMaskOptions(props.mask);
22198
+ }
22143
22199
  var particleMeshProps = {
22144
22200
  // listIndex: vfxItem.listIndex,
22145
22201
  meshSlots: options.meshSlots,
@@ -22160,8 +22216,8 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
22160
22216
  occlusion: !!renderer.occlusion,
22161
22217
  transparentOcclusion: !!renderer.transparentOcclusion,
22162
22218
  maxCount: options.maxCount,
22163
- mask: maskProps.maskRef,
22164
- maskMode: maskProps.maskMode,
22219
+ mask: this.maskManager.getRefValue(),
22220
+ maskMode: this.maskManager.maskMode,
22165
22221
  forceTarget: forceTarget,
22166
22222
  diffuse: renderer.texture ? this.engine.findObject(renderer.texture) : undefined,
22167
22223
  sizeOverLifetime: sizeOverLifetimeGetter,
@@ -22242,7 +22298,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
22242
22298
  inheritParticleColor: !!trails.inheritParticleColor,
22243
22299
  parentAffectsPosition: !!trails.parentAffectsPosition
22244
22300
  };
22245
- maskProps = this.getMaskOptions(trails);
22301
+ if (trails.mask) {
22302
+ this.maskManager.setMaskOptions(trails.mask);
22303
+ }
22246
22304
  trailMeshProps = {
22247
22305
  name: "Trail",
22248
22306
  matrix: Matrix4.IDENTITY,
@@ -22259,8 +22317,8 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
22259
22317
  occlusion: !!trails.occlusion,
22260
22318
  transparentOcclusion: !!trails.transparentOcclusion,
22261
22319
  textureMap: trails.textureMap,
22262
- mask: maskProps.maskRef,
22263
- maskMode: maskProps.maskMode
22320
+ mask: this.maskManager.getRefValue(),
22321
+ maskMode: this.maskManager.maskMode
22264
22322
  };
22265
22323
  if (trails.colorOverLifetime && trails.colorOverLifetime[0] === ValueType.GRADIENT_COLOR) {
22266
22324
  trailMeshProps.colorOverLifetime = trails.colorOverLifetime[1];
@@ -22285,18 +22343,6 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
22285
22343
  this.item.getHitTestParams = this.getHitTestParams;
22286
22344
  this.item._content = this;
22287
22345
  };
22288
- _proto.getMaskOptions = function getMaskOptions(data) {
22289
- var maskMode = exports.MaskMode.NONE;
22290
- var maskRef = 0;
22291
- if (data.mask) {
22292
- maskMode = this.maskManager.getMaskMode(data.mask);
22293
- maskRef = this.maskManager.getRefValue();
22294
- }
22295
- return {
22296
- maskMode: maskMode,
22297
- maskRef: maskRef
22298
- };
22299
- };
22300
22346
  _create_class(ParticleSystem, [
22301
22347
  {
22302
22348
  key: "timePassed",
@@ -30109,6 +30155,7 @@ var itemMap = new Map();
30109
30155
  }
30110
30156
  }
30111
30157
  }
30158
+ json.version = JSONSceneVersion["3_2"];
30112
30159
  return json;
30113
30160
  }
30114
30161
  function version32Migration(json) {
@@ -30128,6 +30175,7 @@ function version32Migration(json) {
30128
30175
  var comp = _step2.value;
30129
30176
  processContent(comp);
30130
30177
  }
30178
+ json.version = JSONSceneVersion["3_3"];
30131
30179
  return json;
30132
30180
  }
30133
30181
  function version33Migration(json) {
@@ -30195,6 +30243,7 @@ function version33Migration(json) {
30195
30243
  }
30196
30244
  }
30197
30245
  }
30246
+ json.version = JSONSceneVersion["3_4"];
30198
30247
  return json;
30199
30248
  }
30200
30249
  function processContent(composition) {
@@ -31050,7 +31099,7 @@ function getStandardSpriteContent(sprite, transform) {
31050
31099
  return ret;
31051
31100
  }
31052
31101
 
31053
- var version$1 = "2.6.0-beta.1";
31102
+ var version$1 = "2.6.1";
31054
31103
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
31055
31104
  var standardVersion = /^(\d+)\.(\d+)$/;
31056
31105
  var reverseParticle = false;
@@ -34300,7 +34349,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
34300
34349
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
34301
34350
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
34302
34351
  registerPlugin("interact", InteractLoader, exports.VFXItem);
34303
- var version = "2.6.0-beta.1";
34352
+ var version = "2.6.1";
34304
34353
  logger.info("Core version: " + version + ".");
34305
34354
 
34306
34355
  exports.AbstractPlugin = AbstractPlugin;
@@ -34458,6 +34507,7 @@ exports.base64ToFile = base64ToFile;
34458
34507
  exports.blend = blend;
34459
34508
  exports.buildLine = buildLine;
34460
34509
  exports.calculateTranslation = calculateTranslation;
34510
+ exports.canUseBOM = canUseBOM;
34461
34511
  exports.canvasPool = canvasPool;
34462
34512
  exports.closePointEps = closePointEps;
34463
34513
  exports.colorGradingFrag = colorGradingFrag;