@galacean/effects 1.1.0-alpha.1 → 1.1.0-alpha.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 CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime player for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v1.1.0-alpha.1
6
+ * Version: v1.1.0-alpha.3
7
7
  */
8
8
 
9
9
  'use strict';
@@ -14394,6 +14394,7 @@ var Transform = /** @class */ (function () {
14394
14394
  */
14395
14395
  Transform.prototype.rotateByQuat = function (quat) {
14396
14396
  this.quat.multiply(quat);
14397
+ this.rotation.setFromQuaternion(this.quat);
14397
14398
  this.dirtyFlags.localData = true;
14398
14399
  this.dispatchValueChange();
14399
14400
  };
@@ -14892,6 +14893,7 @@ var VFXItem = /** @class */ (function () {
14892
14893
  this.delaying = false;
14893
14894
  this.transform.setValid(true);
14894
14895
  this.createContent();
14896
+ this._contentVisible = true;
14895
14897
  this.onLifetimeBegin(this.composition, this.content);
14896
14898
  this.composition.itemLifetimeEvent(this, true);
14897
14899
  }
@@ -14932,7 +14934,7 @@ var VFXItem = /** @class */ (function () {
14932
14934
  }
14933
14935
  }
14934
14936
  else if (this.endBehavior === END_BEHAVIOR_DESTROY$1) {
14935
- this.setVisible(false);
14937
+ this._contentVisible = false;
14936
14938
  }
14937
14939
  lifetime = Math.min(lifetime, 1);
14938
14940
  }
@@ -15156,6 +15158,7 @@ var VFXItem = /** @class */ (function () {
15156
15158
  if (this.composition) {
15157
15159
  this.onItemRemoved(this.composition, this._content);
15158
15160
  this._content = undefined;
15161
+ this._contentVisible = false;
15159
15162
  }
15160
15163
  this.started = false;
15161
15164
  };
@@ -15286,7 +15289,7 @@ var PluginSystem = /** @class */ (function () {
15286
15289
  .map(function (name) {
15287
15290
  var CTRL = pluginLoaderMap[name];
15288
15291
  if (!CTRL) {
15289
- throw new Error("plugin '".concat(name, "' not found"));
15292
+ throw new Error("plugin '".concat(name, "' not found.") + getPluginUsageInfo(name));
15290
15293
  }
15291
15294
  var loader = new CTRL();
15292
15295
  loader.name = name;
@@ -15358,6 +15361,23 @@ var PluginSystem = /** @class */ (function () {
15358
15361
  };
15359
15362
  return PluginSystem;
15360
15363
  }());
15364
+ var pluginInfoMap = {
15365
+ 'alipay-downgrade': '@galacean/effects-plugin-alipay-downgrade',
15366
+ 'editor-gizmo': '@galacean/effects-plugin-editor-gizmo',
15367
+ 'tree': '@galacean/effects-plugin-model',
15368
+ 'model': '@galacean/effects-plugin-model',
15369
+ 'orientation-transformer': '@galacean/effects-plugin-orientation-transformer',
15370
+ 'spine': '@galacean/effects-plugin-spine',
15371
+ };
15372
+ function getPluginUsageInfo(name) {
15373
+ var info = pluginInfoMap[name];
15374
+ if (info) {
15375
+ return "\nInstall Plugin: npm i ".concat(info, "@latest --save\nImport Plugin: import '").concat(info, "'");
15376
+ }
15377
+ else {
15378
+ return '';
15379
+ }
15380
+ }
15361
15381
 
15362
15382
  /**
15363
15383
  * 抽象插件类
@@ -17030,7 +17050,7 @@ var Mesh = /** @class */ (function () {
17030
17050
  function Mesh(engine, props) {
17031
17051
  this.engine = engine;
17032
17052
  this.destroyed = false;
17033
- this.visible = false;
17053
+ this.visible = true;
17034
17054
  var material = props.material, geometry = props.geometry, _a = props.name, name = _a === void 0 ? '<unnamed>' : _a, _b = props.priority, priority = _b === void 0 ? 0 : _b, _c = props.worldMatrix, worldMatrix = _c === void 0 ? Matrix4$1.fromIdentity() : _c;
17035
17055
  this.id = 'Mesh' + seed$b++;
17036
17056
  this.name = name;
@@ -19257,7 +19277,7 @@ var SpriteMesh = /** @class */ (function () {
19257
19277
  var indexLen = 0;
19258
19278
  var pointCount = 0;
19259
19279
  if (!items.length) {
19260
- this.mesh.setVisible(true);
19280
+ this.mesh.setVisible(false);
19261
19281
  return true;
19262
19282
  }
19263
19283
  this.items = items.slice();
@@ -19314,7 +19334,7 @@ var SpriteMesh = /** @class */ (function () {
19314
19334
  geometry.setIndexData(indexData);
19315
19335
  geometry.setAttributeData('aPoint', bundle.aPoint);
19316
19336
  geometry.setDrawCount(indexLen);
19317
- this.mesh.setVisible(!geometry.getDrawCount());
19337
+ this.mesh.setVisible(!!geometry.getDrawCount());
19318
19338
  this.mesh.priority = items[0].listIndex;
19319
19339
  for (var i = 0; i < textures.length; i++) {
19320
19340
  var texture = textures[i];
@@ -19344,7 +19364,7 @@ var SpriteMesh = /** @class */ (function () {
19344
19364
  var uSizeStart = start + 4;
19345
19365
  var uQuatStart = start + 8;
19346
19366
  var uColorStart = start + 12;
19347
- if (!selfData.visible) {
19367
+ if (!selfData.visible && !init) {
19348
19368
  mainDataArray[uSizeStart + 2] = -1;
19349
19369
  return;
19350
19370
  }
@@ -20443,6 +20463,7 @@ new Vector3();
20443
20463
  var CalculateItem = /** @class */ (function () {
20444
20464
  function CalculateItem(props, vfxItem) {
20445
20465
  var _a;
20466
+ this.vfxItem = vfxItem;
20446
20467
  this.active = false;
20447
20468
  this.transform = vfxItem.transform;
20448
20469
  var scale = this.transform.scale;
@@ -20836,7 +20857,7 @@ var SpriteItem = /** @class */ (function (_super) {
20836
20857
  else if (init) {
20837
20858
  ret.texOffset = [0, 0, 1, 1];
20838
20859
  }
20839
- ret.visible = this.visible;
20860
+ ret.visible = this.vfxItem.contentVisible;
20840
20861
  // 图层元素作为父节点时,除了k的大小变换,自身的尺寸也需要传递给子元素,子元素可以通过startSize读取
20841
20862
  ret.startSize = this.startSize;
20842
20863
  return ret;
@@ -20865,21 +20886,14 @@ var SpriteVFXItem = /** @class */ (function (_super) {
20865
20886
  this.sprite = props.content;
20866
20887
  };
20867
20888
  SpriteVFXItem.prototype.onLifetimeBegin = function (composition, content) {
20868
- this._contentVisible = true;
20869
20889
  content.active = true;
20870
20890
  };
20871
20891
  SpriteVFXItem.prototype.onItemRemoved = function (composition, content) {
20872
- this._contentVisible = false;
20873
20892
  if (content) {
20874
20893
  delete content.mesh;
20875
20894
  composition.destroyTextures(content.getTextures());
20876
20895
  }
20877
20896
  };
20878
- SpriteVFXItem.prototype.handleVisibleChanged = function (visible) {
20879
- if (this.content) {
20880
- this.content.visible = visible;
20881
- }
20882
- };
20883
20897
  SpriteVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
20884
20898
  var _a;
20885
20899
  (_a = this.content) === null || _a === void 0 ? void 0 : _a.updateTime(this.time);
@@ -23517,7 +23531,7 @@ var ParticleSystem = /** @class */ (function () {
23517
23531
  }
23518
23532
  this.meshes = meshes;
23519
23533
  this.reusable = vfxItem.reusable;
23520
- this.setVisible(vfxItem.getVisible());
23534
+ this.setVisible(vfxItem.contentVisible);
23521
23535
  var interaction = props.interaction;
23522
23536
  if (interaction) {
23523
23537
  this.interaction = {
@@ -24172,10 +24186,10 @@ var ParticleVFXItem = /** @class */ (function (_super) {
24172
24186
  }
24173
24187
  }
24174
24188
  if (hide) {
24175
- this.content.setVisible(true);
24189
+ this.content.setVisible(false);
24176
24190
  }
24177
24191
  else {
24178
- this.content.setVisible(false);
24192
+ this.content.setVisible(true);
24179
24193
  this.content.onUpdate(dt);
24180
24194
  }
24181
24195
  }
@@ -25891,13 +25905,11 @@ var TextItem = /** @class */ (function (_super) {
25891
25905
  _this.text = options.text;
25892
25906
  // Text
25893
25907
  _this.mesh = new TextMesh(_this.engine, _this.renderInfo, vfxItem.composition);
25894
- _this.mesh.setItems([_this]);
25895
- _this.updateTexture();
25896
25908
  return _this;
25897
25909
  }
25898
25910
  /**
25899
25911
  * 设置字号大小
25900
- * @param value 字号
25912
+ * @param value - 字号
25901
25913
  * @returns
25902
25914
  */
25903
25915
  TextItem.prototype.setFontSize = function (value) {
@@ -25911,7 +25923,7 @@ var TextItem = /** @class */ (function (_super) {
25911
25923
  };
25912
25924
  /**
25913
25925
  * 设置字重
25914
- * @param value 字重类型
25926
+ * @param value - 字重类型
25915
25927
  * @returns
25916
25928
  */
25917
25929
  TextItem.prototype.setFontWeight = function (value) {
@@ -25935,7 +25947,7 @@ var TextItem = /** @class */ (function (_super) {
25935
25947
  };
25936
25948
  /**
25937
25949
  * 设置文本
25938
- * @param value 文本内容
25950
+ * @param value - 文本内容
25939
25951
  * @returns
25940
25952
  */
25941
25953
  TextItem.prototype.setText = function (value) {
@@ -25947,7 +25959,7 @@ var TextItem = /** @class */ (function (_super) {
25947
25959
  };
25948
25960
  /**
25949
25961
  * 设置文本水平布局
25950
- * @param value 布局选项
25962
+ * @param value - 布局选项
25951
25963
  * @returns
25952
25964
  */
25953
25965
  TextItem.prototype.setTextAlign = function (value) {
@@ -25959,7 +25971,7 @@ var TextItem = /** @class */ (function (_super) {
25959
25971
  };
25960
25972
  /**
25961
25973
  * 设置文本垂直布局
25962
- * @param value 布局选项
25974
+ * @param value - 布局选项
25963
25975
  * @returns
25964
25976
  */
25965
25977
  TextItem.prototype.setTextBaseline = function (value) {
@@ -25971,7 +25983,7 @@ var TextItem = /** @class */ (function (_super) {
25971
25983
  };
25972
25984
  /**
25973
25985
  * 设置文本颜色
25974
- * @param value 颜色内容
25986
+ * @param value - 颜色内容
25975
25987
  * @returns
25976
25988
  */
25977
25989
  TextItem.prototype.setTextColor = function (value) {
@@ -25983,7 +25995,7 @@ var TextItem = /** @class */ (function (_super) {
25983
25995
  };
25984
25996
  /**
25985
25997
  * 设置文本字体
25986
- * @param value 文本字体
25998
+ * @param value - 文本字体
25987
25999
  * @returns
25988
26000
  */
25989
26001
  TextItem.prototype.setFontFamily = function (value) {
@@ -25995,7 +26007,7 @@ var TextItem = /** @class */ (function (_super) {
25995
26007
  };
25996
26008
  /**
25997
26009
  * 设置外描边文本颜色
25998
- * @param value 颜色内容
26010
+ * @param value - 颜色内容
25999
26011
  * @returns
26000
26012
  */
26001
26013
  TextItem.prototype.setOutlineColor = function (value) {
@@ -26007,7 +26019,7 @@ var TextItem = /** @class */ (function (_super) {
26007
26019
  };
26008
26020
  /**
26009
26021
  * 设置外描边文本宽度
26010
- * @param value 外描边宽度
26022
+ * @param value - 外描边宽度
26011
26023
  * @returns
26012
26024
  */
26013
26025
  TextItem.prototype.setOutlineWidth = function (value) {
@@ -26019,7 +26031,7 @@ var TextItem = /** @class */ (function (_super) {
26019
26031
  };
26020
26032
  /**
26021
26033
  * 设置阴影模糊
26022
- * @param value 阴影模糊强度
26034
+ * @param value - 阴影模糊强度
26023
26035
  * @returns
26024
26036
  */
26025
26037
  TextItem.prototype.setShadowBlur = function (value) {
@@ -26031,7 +26043,7 @@ var TextItem = /** @class */ (function (_super) {
26031
26043
  };
26032
26044
  /**
26033
26045
  * 设置阴影颜色
26034
- * @param value 阴影颜色
26046
+ * @param value - 阴影颜色
26035
26047
  * @returns
26036
26048
  */
26037
26049
  TextItem.prototype.setShadowColor = function (value) {
@@ -26043,7 +26055,7 @@ var TextItem = /** @class */ (function (_super) {
26043
26055
  };
26044
26056
  /**
26045
26057
  * 设置阴影水平偏移距离
26046
- * @param value 水平偏移距离
26058
+ * @param value - 水平偏移距离
26047
26059
  * @returns
26048
26060
  */
26049
26061
  TextItem.prototype.setShadowOffsetX = function (value) {
@@ -26055,7 +26067,7 @@ var TextItem = /** @class */ (function (_super) {
26055
26067
  };
26056
26068
  /**
26057
26069
  * 设置阴影水平偏移距离
26058
- * @param value 水平偏移距离
26070
+ * @param value - 水平偏移距离
26059
26071
  * @returns
26060
26072
  */
26061
26073
  TextItem.prototype.setShadowOffsetY = function (value) {
@@ -26067,7 +26079,7 @@ var TextItem = /** @class */ (function (_super) {
26067
26079
  };
26068
26080
  /**
26069
26081
  * 设置字体清晰度
26070
- * @param value 字体清晰度
26082
+ * @param value - 字体清晰度
26071
26083
  * @returns
26072
26084
  */
26073
26085
  TextItem.prototype.setFontScale = function (value) {
@@ -26094,7 +26106,7 @@ var TextItem = /** @class */ (function (_super) {
26094
26106
  var height = layout.height * fontScale;
26095
26107
  var fontSize = style.fontSize * fontScale;
26096
26108
  var lineHeight = layout.lineHeight * fontScale;
26097
- this.char = this.text.split('');
26109
+ this.char = (this.text || '').split('');
26098
26110
  this.canvas.width = width;
26099
26111
  this.canvas.height = height;
26100
26112
  context.clearRect(0, 0, width, this.canvas.height);
@@ -26224,23 +26236,22 @@ var TextVFXItem = /** @class */ (function (_super) {
26224
26236
  this.textContext = props.content;
26225
26237
  };
26226
26238
  TextVFXItem.prototype.onLifetimeBegin = function (composition, content) {
26227
- this._contentVisible = true;
26239
+ var _a;
26228
26240
  content.active = true;
26241
+ (_a = this.content) === null || _a === void 0 ? void 0 : _a.mesh.setItems([this.content]);
26242
+ this.content.updateTexture();
26229
26243
  };
26230
26244
  TextVFXItem.prototype.onItemRemoved = function (composition, content) {
26231
- this._contentVisible = false;
26232
26245
  if (content) {
26233
26246
  delete content.mesh;
26234
26247
  composition.destroyTextures(content.getTextures());
26235
26248
  }
26236
26249
  };
26237
- TextVFXItem.prototype.handleVisibleChanged = function (visible) {
26238
- if (this.content) {
26239
- this.content.visible = visible;
26240
- }
26241
- };
26242
26250
  TextVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
26243
26251
  var _a;
26252
+ if (!this.content) {
26253
+ return;
26254
+ }
26244
26255
  (_a = this.content) === null || _a === void 0 ? void 0 : _a.updateTime(this.time);
26245
26256
  };
26246
26257
  TextVFXItem.prototype.getCurrentPosition = function () {
@@ -26295,6 +26306,7 @@ var TextVFXItem = /** @class */ (function (_super) {
26295
26306
  };
26296
26307
  TextVFXItem.prototype.createWireframeMesh = function (item, color) {
26297
26308
  var spMesh = new TextMesh(this.composition.getEngine(), __assign$1({ wireframe: true }, item.renderInfo), this.composition);
26309
+ spMesh.mesh.setVisible(true);
26298
26310
  spMesh.setItems([item]);
26299
26311
  spMesh.mesh.material.setVector3('uFrameColor', Vector3.fromArray(color));
26300
26312
  spMesh.mesh.priority = 999;
@@ -26310,7 +26322,7 @@ var TextLoader = /** @class */ (function (_super) {
26310
26322
  _this.name = 'text';
26311
26323
  _this.addItems = [];
26312
26324
  _this.removeItems = [];
26313
- _this.meshes = []; // meshSplits对应的mesh数组 每次diff后更新
26325
+ _this.meshes = [];
26314
26326
  return _this;
26315
26327
  }
26316
26328
  TextLoader.prototype.onCompositionDestroyed = function (composition) {
@@ -26329,12 +26341,19 @@ var TextLoader = /** @class */ (function (_super) {
26329
26341
  };
26330
26342
  TextLoader.prototype.onCompositionUpdate = function (composition, dt) {
26331
26343
  this.addItems.forEach(function (item) {
26332
- var _a;
26344
+ var _a, _b, _c;
26345
+ if (!item.contentVisible) {
26346
+ (_a = item.content.mesh) === null || _a === void 0 ? void 0 : _a.mesh.setVisible(false);
26347
+ return;
26348
+ }
26349
+ else {
26350
+ (_b = item.content.mesh) === null || _b === void 0 ? void 0 : _b.mesh.setVisible(true);
26351
+ }
26333
26352
  item.content.updateTexture();
26334
26353
  if (!item.content.ended && item.content.mesh) {
26335
26354
  item.content.mesh.updateItem(item.content);
26355
+ (_c = item.content.mesh) === null || _c === void 0 ? void 0 : _c.applyChange();
26336
26356
  }
26337
- (_a = item.content.mesh) === null || _a === void 0 ? void 0 : _a.applyChange();
26338
26357
  });
26339
26358
  };
26340
26359
  TextLoader.prototype.onCompositionItemLifeBegin = function (composition, item) {
@@ -26353,6 +26372,7 @@ var TextLoader = /** @class */ (function (_super) {
26353
26372
  };
26354
26373
  TextLoader.prototype.onCompositionItemRemoved = function (composition, item) {
26355
26374
  var _a;
26375
+ // FIXME: 此处判断有问题,item 应该先判断
26356
26376
  if (item instanceof TextVFXItem && item) {
26357
26377
  addItem(this.removeItems, item);
26358
26378
  if (this.addItems.includes(item)) {
@@ -30906,23 +30926,41 @@ var Composition = /** @class */ (function () {
30906
30926
  this.content.translateByPixel(x, y);
30907
30927
  };
30908
30928
  /**
30909
- * 设置合成在 3D 坐标轴上相对移动
30929
+ * 设置合成在 3D 坐标轴上相对当前的位移
30910
30930
  */
30911
30931
  Composition.prototype.translate = function (x, y, z) {
30912
30932
  this.content.translate(x, y, z);
30913
30933
  };
30914
30934
  /**
30915
- * 设置合成在 3D 坐标轴上相对旋转(角度)
30935
+ * 设置合成在 3D 坐标轴上相对原点的位移
30936
+ */
30937
+ Composition.prototype.setPosition = function (x, y, z) {
30938
+ this.content.setPosition(x, y, z);
30939
+ };
30940
+ /**
30941
+ * 设置合成在 3D 坐标轴上相对当前的旋转(角度)
30916
30942
  */
30917
30943
  Composition.prototype.rotate = function (x, y, z) {
30918
30944
  this.content.rotate(x, y, z);
30919
30945
  };
30920
30946
  /**
30921
- * 设置合成在 3D 坐标轴上相对缩放
30947
+ * 设置合成在 3D 坐标轴上的相对原点的旋转(角度)
30948
+ */
30949
+ Composition.prototype.setRotation = function (x, y, z) {
30950
+ this.content.setRotation(x, y, z);
30951
+ };
30952
+ /**
30953
+ * 设置合成在 3D 坐标轴上相对当前的缩放
30922
30954
  */
30923
30955
  Composition.prototype.scale = function (x, y, z) {
30924
30956
  this.content.scale(x, y, z);
30925
30957
  };
30958
+ /**
30959
+ * 设置合成在 3D 坐标轴上的缩放
30960
+ */
30961
+ Composition.prototype.setScale = function (x, y, z) {
30962
+ this.content.setScale(x, y, z);
30963
+ };
30926
30964
  /**
30927
30965
  * 卸载贴图纹理方法,减少内存
30928
30966
  */
@@ -35212,7 +35250,7 @@ var GLRenderer = /** @class */ (function (_super) {
35212
35250
  // console.error(`mesh ${mesh.name} destroyed`, mesh);
35213
35251
  continue;
35214
35252
  }
35215
- if (mesh.getVisible()) {
35253
+ if (!mesh.getVisible()) {
35216
35254
  continue;
35217
35255
  }
35218
35256
  if (!mesh.material) {
@@ -36135,11 +36173,15 @@ var Player = /** @class */ (function () {
36135
36173
  }
36136
36174
  this.canvas.remove();
36137
36175
  }
36138
- this.tick = throwDestroyedError;
36139
- this.resize = throwDestroyedError;
36140
- this.loadScene = throwDestroyedErrorPromise;
36141
- this.play = throwDestroyedErrorPromise;
36142
- this.resume = throwDestroyedErrorPromise;
36176
+ // 在报错函数中传入 player.name
36177
+ var errorMsg = getDestroyedErrorMessage(this.name);
36178
+ var throwErrorFunc = function () { return throwDestroyedError(errorMsg); };
36179
+ var throwErrorPromiseFunc = function () { return throwDestroyedErrorPromise(errorMsg); };
36180
+ this.tick = throwErrorFunc;
36181
+ this.resize = throwErrorFunc;
36182
+ this.loadScene = throwErrorPromiseFunc;
36183
+ this.play = throwErrorPromiseFunc;
36184
+ this.resume = throwErrorPromiseFunc;
36143
36185
  this.disposed = true;
36144
36186
  };
36145
36187
  Player.prototype.offloadTexture = function () {
@@ -36264,11 +36306,13 @@ function assertContainer(container) {
36264
36306
  throw new Error("Container is not an HTMLElement, see ".concat(HELP_LINK['Container is not an HTMLElement']));
36265
36307
  }
36266
36308
  }
36267
- var destroyedErrorMessage = "Never use destroyed player again, see ".concat(HELP_LINK['Never use destroyed player again']);
36268
- function throwDestroyedError() {
36309
+ function getDestroyedErrorMessage(name) {
36310
+ return "Never use destroyed player: ".concat(name, " again, see ").concat(HELP_LINK['Never use destroyed player again']);
36311
+ }
36312
+ function throwDestroyedError(destroyedErrorMessage) {
36269
36313
  throw new Error(destroyedErrorMessage);
36270
36314
  }
36271
- function throwDestroyedErrorPromise() {
36315
+ function throwDestroyedErrorPromise(destroyedErrorMessage) {
36272
36316
  return Promise.reject(destroyedErrorMessage);
36273
36317
  }
36274
36318
 
@@ -36314,9 +36358,9 @@ Renderer.create = function (canvas, framework, renderOptions) {
36314
36358
  Engine.create = function (gl) {
36315
36359
  return new GLEngine(gl);
36316
36360
  };
36317
- var version = "1.1.0-alpha.1";
36361
+ var version = "1.1.0-alpha.3";
36318
36362
  console.info({
36319
- content: '[Galacean Effects Player] version: ' + "1.1.0-alpha.1",
36363
+ content: '[Galacean Effects Player] version: ' + "1.1.0-alpha.3",
36320
36364
  type: LOG_TYPE,
36321
36365
  });
36322
36366