@galacean/effects 1.6.0-beta.0 → 1.6.0-beta.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.
package/dist/alipay.js CHANGED
@@ -13514,6 +13514,14 @@ var InteractVFXItem = /** @class */ (function (_super) {
13514
13514
  function InteractVFXItem(props, composition) {
13515
13515
  var _a;
13516
13516
  var _this = _super.call(this, props, composition) || this;
13517
+ /**
13518
+ * 拖拽的惯性衰减系数,范围[0, 1], 越大惯性越强
13519
+ */
13520
+ _this.downgrade = 0.95;
13521
+ /**
13522
+ * 拖拽的距离映射系数,越大越容易拖动
13523
+ */
13524
+ _this.dragRatio = [1, 1];
13517
13525
  _this.engine = (_a = _this.composition) === null || _a === void 0 ? void 0 : _a.getEngine();
13518
13526
  return _this;
13519
13527
  }
@@ -13524,8 +13532,23 @@ var InteractVFXItem = /** @class */ (function (_super) {
13524
13532
  enumerable: false,
13525
13533
  configurable: true
13526
13534
  });
13535
+ Object.defineProperty(InteractVFXItem.prototype, "enable", {
13536
+ get: function () {
13537
+ return this.enabled;
13538
+ },
13539
+ set: function (enable) {
13540
+ this.enabled = enable;
13541
+ if (!enable) {
13542
+ // 立刻停止惯性滑动
13543
+ this.bouncingArg = null;
13544
+ }
13545
+ },
13546
+ enumerable: false,
13547
+ configurable: true
13548
+ });
13527
13549
  InteractVFXItem.prototype.onConstructed = function (options) {
13528
13550
  this.ui = options.content;
13551
+ this.enabled = true;
13529
13552
  };
13530
13553
  InteractVFXItem.prototype.onLifetimeBegin = function (composition) {
13531
13554
  var _a, _b, _c;
@@ -13544,9 +13567,8 @@ var InteractVFXItem = /** @class */ (function (_super) {
13544
13567
  if (!this.dragEvent || !this.bouncingArg) {
13545
13568
  return;
13546
13569
  }
13547
- var downgrade = 0.95;
13548
- this.bouncingArg.vx *= downgrade;
13549
- this.bouncingArg.vy *= downgrade;
13570
+ this.bouncingArg.vx *= this.downgrade;
13571
+ this.bouncingArg.vy *= this.downgrade;
13550
13572
  this.bouncingArg.dy += this.bouncingArg.vy;
13551
13573
  this.bouncingArg.dx += this.bouncingArg.vx;
13552
13574
  if (shouldIgnoreBouncing(this.bouncingArg)) {
@@ -13582,7 +13604,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
13582
13604
  };
13583
13605
  };
13584
13606
  InteractVFXItem.prototype.getHitTestParams = function () {
13585
- if (!this.clickable) {
13607
+ if (!this.clickable || !this.canInteract()) {
13586
13608
  return;
13587
13609
  }
13588
13610
  var behavior = this.ui.options.behavior;
@@ -13618,13 +13640,13 @@ var InteractVFXItem = /** @class */ (function (_super) {
13618
13640
  var dragEvent;
13619
13641
  var handlerMap = {
13620
13642
  touchstart: function (event) {
13621
- var _a, _b;
13622
- if (!((_a = _this.composition) === null || _a === void 0 ? void 0 : _a.interactive)) {
13643
+ var _a;
13644
+ if (!_this.canInteract()) {
13623
13645
  return;
13624
13646
  }
13625
13647
  _this.dragEvent = null;
13626
13648
  _this.bouncingArg = null;
13627
- var camera = (_b = _this.composition) === null || _b === void 0 ? void 0 : _b.camera;
13649
+ var camera = (_a = _this.composition) === null || _a === void 0 ? void 0 : _a.camera;
13628
13650
  dragEvent = {
13629
13651
  x: event.x,
13630
13652
  y: event.y,
@@ -13639,8 +13661,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
13639
13661
  _this.bouncingArg = event;
13640
13662
  },
13641
13663
  touchend: function (event) {
13642
- var _a;
13643
- if (!((_a = _this.composition) === null || _a === void 0 ? void 0 : _a.interactive)) {
13664
+ if (!_this.canInteract()) {
13644
13665
  return;
13645
13666
  }
13646
13667
  var bouncingArg = _this.bouncingArg;
@@ -13667,36 +13688,40 @@ var InteractVFXItem = /** @class */ (function (_super) {
13667
13688
  // OVERRIDE
13668
13689
  };
13669
13690
  InteractVFXItem.prototype.handleDragMove = function (evt, event) {
13670
- var _a, _b, _c;
13671
- if (!(evt && evt.cameraParam) || !((_a = this.composition) === null || _a === void 0 ? void 0 : _a.interactive)) {
13691
+ var _a, _b;
13692
+ if (!(evt === null || evt === void 0 ? void 0 : evt.cameraParam) || !this.canInteract() || !this.composition) {
13672
13693
  return;
13673
13694
  }
13674
13695
  var options = this.ui.options;
13675
- var _d = evt.cameraParam, position = _d.position, fov = _d.fov;
13696
+ var _c = evt.cameraParam, position = _c.position, fov = _c.fov;
13676
13697
  var dy = event.dy;
13677
13698
  var dx = event.dx * event.width / event.height;
13678
13699
  var depth = position[2];
13679
13700
  var sp = Math.tan(fov * Math.PI / 180 / 2) * Math.abs(depth);
13680
13701
  var height = dy * sp;
13681
13702
  var width = dx * sp;
13682
- var nx = position[0] - width;
13683
- var ny = position[1] - height;
13703
+ var nx = position[0] - this.dragRatio[0] * width;
13704
+ var ny = position[1] - this.dragRatio[1] * height;
13684
13705
  if (options.dxRange) {
13685
- var _e = __read$3(options.dxRange, 2), min = _e[0], max = _e[1];
13706
+ var _d = __read$3(options.dxRange, 2), min = _d[0], max = _d[1];
13686
13707
  nx = clamp$1(nx, min, max);
13687
13708
  if (nx !== min && nx !== max && min !== max) {
13688
- (_b = event.origin) === null || _b === void 0 ? void 0 : _b.preventDefault();
13709
+ (_a = event.origin) === null || _a === void 0 ? void 0 : _a.preventDefault();
13689
13710
  }
13690
13711
  }
13691
13712
  if (options.dyRange) {
13692
- var _f = __read$3(options.dyRange, 2), min = _f[0], max = _f[1];
13713
+ var _e = __read$3(options.dyRange, 2), min = _e[0], max = _e[1];
13693
13714
  ny = clamp$1(ny, min, max);
13694
13715
  if (ny !== min && ny !== max && min !== max) {
13695
- (_c = event.origin) === null || _c === void 0 ? void 0 : _c.preventDefault();
13716
+ (_b = event.origin) === null || _b === void 0 ? void 0 : _b.preventDefault();
13696
13717
  }
13697
13718
  }
13698
13719
  this.composition.camera.position = new Vector3(nx, ny, depth);
13699
13720
  };
13721
+ InteractVFXItem.prototype.canInteract = function () {
13722
+ var _a;
13723
+ return Boolean((_a = this.composition) === null || _a === void 0 ? void 0 : _a.interactive) && this.enabled;
13724
+ };
13700
13725
  return InteractVFXItem;
13701
13726
  }(VFXItem));
13702
13727
  function shouldIgnoreBouncing(arg, mul) {
@@ -24002,27 +24027,28 @@ var AssetManager = /** @class */ (function () {
24002
24027
  AssetManager.prototype.loadScene = function (url, renderer, options) {
24003
24028
  var _a, _b, _c;
24004
24029
  return __awaiter(this, void 0, void 0, function () {
24005
- var rawJSON, assetUrl, startTime, timeInfos, gpuInstance, asyncShaderCompile, compressedTexture, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
24030
+ var rawJSON, assetUrl, startTime, timeInfoMessages, gpuInstance, asyncShaderCompile, compressedTexture, timeInfos, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
24006
24031
  var _this = this;
24007
24032
  return __generator(this, function (_d) {
24008
24033
  assetUrl = isString(url) ? url : this.id;
24009
24034
  startTime = alipay.performance.now();
24010
- timeInfos = [];
24035
+ timeInfoMessages = [];
24011
24036
  gpuInstance = renderer === null || renderer === void 0 ? void 0 : renderer.engine.gpuCapability;
24012
24037
  asyncShaderCompile = (_b = (_a = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail) === null || _a === void 0 ? void 0 : _a.asyncShaderCompile) !== null && _b !== void 0 ? _b : false;
24013
24038
  compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
24039
+ timeInfos = {};
24014
24040
  cancelLoading = false;
24015
24041
  waitPromise = new Promise(function (resolve, reject) {
24016
24042
  loadTimer = alipay.window.setTimeout(function () {
24017
24043
  cancelLoading = true;
24018
24044
  _this.removeTimer(loadTimer);
24019
24045
  var totalTime = alipay.performance.now() - startTime;
24020
- reject("Load time out: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfos.join(' '), ", url: ").concat(assetUrl));
24046
+ reject("Load time out: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfoMessages.join(' '), ", url: ").concat(assetUrl));
24021
24047
  }, _this.timeout * 1000);
24022
24048
  _this.timers.push(loadTimer);
24023
24049
  });
24024
24050
  hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
24025
- var st, result, e_1;
24051
+ var st, result, time, e_1;
24026
24052
  return __generator(this, function (_a) {
24027
24053
  switch (_a.label) {
24028
24054
  case 0:
@@ -24034,7 +24060,9 @@ var AssetManager = /** @class */ (function () {
24034
24060
  return [4 /*yield*/, func()];
24035
24061
  case 2:
24036
24062
  result = _a.sent();
24037
- timeInfos.push("[".concat(label, ": ").concat((alipay.performance.now() - st).toFixed(2), "]"));
24063
+ time = alipay.performance.now() - st;
24064
+ timeInfoMessages.push("[".concat(label, ": ").concat(time.toFixed(2), "]"));
24065
+ timeInfos[label] = time;
24038
24066
  return [2 /*return*/, result];
24039
24067
  case 3:
24040
24068
  e_1 = _a.sent();
@@ -24093,7 +24121,7 @@ var AssetManager = /** @class */ (function () {
24093
24121
  return [4 /*yield*/, Promise.all([
24094
24122
  hookTimeInfo('processBins', function () { return _this.processBins(bins_1); }),
24095
24123
  hookTimeInfo('processImages', function () { return _this.processImages(images_2, usedImages_1, compressedTexture); }),
24096
- hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(compositions_1, pluginSystem_1, renderer, options); }),
24124
+ hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', "Compile"), function () { return _this.precompile(compositions_1, pluginSystem_1, renderer, options); }),
24097
24125
  ])];
24098
24126
  case 8:
24099
24127
  _d = __read$3.apply(void 0, [_e.sent(), 2]), loadedBins_1 = _d[0], loadedImages_1 = _d[1];
@@ -24105,6 +24133,7 @@ var AssetManager = /** @class */ (function () {
24105
24133
  loadedTextures = _e.sent();
24106
24134
  jsonScene_1.compositions = this.updateSceneData(jsonScene_1.compositions);
24107
24135
  scene = {
24136
+ timeInfos: timeInfos,
24108
24137
  url: url,
24109
24138
  renderLevel: this.options.renderLevel,
24110
24139
  storage: {},
@@ -24123,11 +24152,13 @@ var AssetManager = /** @class */ (function () {
24123
24152
  _e.label = 12;
24124
24153
  case 12:
24125
24154
  totalTime = alipay.performance.now() - startTime;
24126
- logger.info("Load asset: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfos.join(' '), ", url: ").concat(assetUrl));
24155
+ logger.info("Load asset: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfoMessages.join(' '), ", url: ").concat(assetUrl));
24127
24156
  alipay.window.clearTimeout(loadTimer);
24128
24157
  this.removeTimer(loadTimer);
24129
24158
  scene.totalTime = totalTime;
24130
24159
  scene.startTime = startTime;
24160
+ // 各部分分段时长
24161
+ scene.timeInfos = timeInfos;
24131
24162
  return [2 /*return*/, scene];
24132
24163
  }
24133
24164
  });
@@ -24975,7 +25006,7 @@ var Composition = /** @class */ (function () {
24975
25006
  * @param props - composition 的创建参数
24976
25007
  */
24977
25008
  function Composition(props, scene) {
24978
- var _a;
25009
+ var _a, _b;
24979
25010
  /**
24980
25011
  * 动画播放速度
24981
25012
  */
@@ -25004,7 +25035,7 @@ var Composition = /** @class */ (function () {
25004
25035
  this.paused = false;
25005
25036
  this.lastVideoUpdateTime = 0;
25006
25037
  this.postLoaders = [];
25007
- var _b = props.reusable, reusable = _b === void 0 ? false : _b, _c = props.speed, speed = _c === void 0 ? 1 : _c, _d = props.baseRenderOrder, baseRenderOrder = _d === void 0 ? 0 : _d, renderer = props.renderer, onPlayerPause = props.onPlayerPause, onMessageItem = props.onMessageItem, onEnd = props.onEnd, event = props.event, width = props.width, height = props.height;
25038
+ var _c = props.reusable, reusable = _c === void 0 ? false : _c, _d = props.speed, speed = _d === void 0 ? 1 : _d, _e = props.baseRenderOrder, baseRenderOrder = _e === void 0 ? 0 : _e, renderer = props.renderer, onPlayerPause = props.onPlayerPause, onMessageItem = props.onMessageItem, onEnd = props.onEnd, event = props.event, width = props.width, height = props.height;
25008
25039
  this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
25009
25040
  scene.jsonScene.imgUsage = undefined;
25010
25041
  if (reusable) {
@@ -25012,7 +25043,7 @@ var Composition = /** @class */ (function () {
25012
25043
  scene.textures = undefined;
25013
25044
  scene.consumed = true;
25014
25045
  }
25015
- var _e = this.compositionSourceManager, sourceContent = _e.sourceContent, pluginSystem = _e.pluginSystem, imgUsage = _e.imgUsage, totalTime = _e.totalTime, renderLevel = _e.renderLevel, refCompositionProps = _e.refCompositionProps;
25046
+ var _f = this.compositionSourceManager, sourceContent = _f.sourceContent, pluginSystem = _f.pluginSystem, imgUsage = _f.imgUsage, totalTime = _f.totalTime, renderLevel = _f.renderLevel, refCompositionProps = _f.refCompositionProps;
25016
25047
  assertExist(sourceContent);
25017
25048
  this.refCompositionProps = refCompositionProps;
25018
25049
  var vfxItem = new CompVFXItem(sourceContent, this);
@@ -25029,7 +25060,7 @@ var Composition = /** @class */ (function () {
25029
25060
  this.renderer = renderer;
25030
25061
  this.texInfo = imageUsage !== null && imageUsage !== void 0 ? imageUsage : {};
25031
25062
  this.event = event;
25032
- this.statistic = { loadTime: totalTime !== null && totalTime !== void 0 ? totalTime : 0, loadStart: (_a = scene.startTime) !== null && _a !== void 0 ? _a : 0, firstFrameTime: 0 };
25063
+ this.statistic = { loadTime: totalTime !== null && totalTime !== void 0 ? totalTime : 0, loadStart: (_a = scene.startTime) !== null && _a !== void 0 ? _a : 0, firstFrameTime: 0, precompileTime: (_b = scene.timeInfos['asyncCompile']) !== null && _b !== void 0 ? _b : scene.timeInfos['syncCompile'] };
25033
25064
  this.reusable = reusable;
25034
25065
  this.speed = speed;
25035
25066
  this.renderLevel = renderLevel;
@@ -30961,7 +30992,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
30961
30992
  Engine.create = function (gl) {
30962
30993
  return new GLEngine(gl);
30963
30994
  };
30964
- var version = "1.6.0-beta.0";
30995
+ var version = "1.6.0-beta.1";
30965
30996
  logger.info('player version: ' + version);
30966
30997
 
30967
30998
  exports.AbstractPlugin = AbstractPlugin;