@galacean/effects-threejs 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 threejs plugin 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';
@@ -14416,6 +14416,7 @@ var Transform = /** @class */ (function () {
14416
14416
  */
14417
14417
  Transform.prototype.rotateByQuat = function (quat) {
14418
14418
  this.quat.multiply(quat);
14419
+ this.rotation.setFromQuaternion(this.quat);
14419
14420
  this.dirtyFlags.localData = true;
14420
14421
  this.dispatchValueChange();
14421
14422
  };
@@ -14914,6 +14915,7 @@ var VFXItem = /** @class */ (function () {
14914
14915
  this.delaying = false;
14915
14916
  this.transform.setValid(true);
14916
14917
  this.createContent();
14918
+ this._contentVisible = true;
14917
14919
  this.onLifetimeBegin(this.composition, this.content);
14918
14920
  this.composition.itemLifetimeEvent(this, true);
14919
14921
  }
@@ -14954,7 +14956,7 @@ var VFXItem = /** @class */ (function () {
14954
14956
  }
14955
14957
  }
14956
14958
  else if (this.endBehavior === END_BEHAVIOR_DESTROY$1) {
14957
- this.setVisible(false);
14959
+ this._contentVisible = false;
14958
14960
  }
14959
14961
  lifetime = Math.min(lifetime, 1);
14960
14962
  }
@@ -15178,6 +15180,7 @@ var VFXItem = /** @class */ (function () {
15178
15180
  if (this.composition) {
15179
15181
  this.onItemRemoved(this.composition, this._content);
15180
15182
  this._content = undefined;
15183
+ this._contentVisible = false;
15181
15184
  }
15182
15185
  this.started = false;
15183
15186
  };
@@ -15308,7 +15311,7 @@ var PluginSystem = /** @class */ (function () {
15308
15311
  .map(function (name) {
15309
15312
  var CTRL = pluginLoaderMap[name];
15310
15313
  if (!CTRL) {
15311
- throw new Error("plugin '".concat(name, "' not found"));
15314
+ throw new Error("plugin '".concat(name, "' not found.") + getPluginUsageInfo(name));
15312
15315
  }
15313
15316
  var loader = new CTRL();
15314
15317
  loader.name = name;
@@ -15380,6 +15383,23 @@ var PluginSystem = /** @class */ (function () {
15380
15383
  };
15381
15384
  return PluginSystem;
15382
15385
  }());
15386
+ var pluginInfoMap = {
15387
+ 'alipay-downgrade': '@galacean/effects-plugin-alipay-downgrade',
15388
+ 'editor-gizmo': '@galacean/effects-plugin-editor-gizmo',
15389
+ 'tree': '@galacean/effects-plugin-model',
15390
+ 'model': '@galacean/effects-plugin-model',
15391
+ 'orientation-transformer': '@galacean/effects-plugin-orientation-transformer',
15392
+ 'spine': '@galacean/effects-plugin-spine',
15393
+ };
15394
+ function getPluginUsageInfo(name) {
15395
+ var info = pluginInfoMap[name];
15396
+ if (info) {
15397
+ return "\nInstall Plugin: npm i ".concat(info, "@latest --save\nImport Plugin: import '").concat(info, "'");
15398
+ }
15399
+ else {
15400
+ return '';
15401
+ }
15402
+ }
15383
15403
 
15384
15404
  /**
15385
15405
  * 抽象插件类
@@ -17052,7 +17072,7 @@ var Mesh = /** @class */ (function () {
17052
17072
  function Mesh(engine, props) {
17053
17073
  this.engine = engine;
17054
17074
  this.destroyed = false;
17055
- this.visible = false;
17075
+ this.visible = true;
17056
17076
  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.fromIdentity() : _c;
17057
17077
  this.id = 'Mesh' + seed$8++;
17058
17078
  this.name = name;
@@ -19279,7 +19299,7 @@ var SpriteMesh = /** @class */ (function () {
19279
19299
  var indexLen = 0;
19280
19300
  var pointCount = 0;
19281
19301
  if (!items.length) {
19282
- this.mesh.setVisible(true);
19302
+ this.mesh.setVisible(false);
19283
19303
  return true;
19284
19304
  }
19285
19305
  this.items = items.slice();
@@ -19336,7 +19356,7 @@ var SpriteMesh = /** @class */ (function () {
19336
19356
  geometry.setIndexData(indexData);
19337
19357
  geometry.setAttributeData('aPoint', bundle.aPoint);
19338
19358
  geometry.setDrawCount(indexLen);
19339
- this.mesh.setVisible(!geometry.getDrawCount());
19359
+ this.mesh.setVisible(!!geometry.getDrawCount());
19340
19360
  this.mesh.priority = items[0].listIndex;
19341
19361
  for (var i = 0; i < textures.length; i++) {
19342
19362
  var texture = textures[i];
@@ -19366,7 +19386,7 @@ var SpriteMesh = /** @class */ (function () {
19366
19386
  var uSizeStart = start + 4;
19367
19387
  var uQuatStart = start + 8;
19368
19388
  var uColorStart = start + 12;
19369
- if (!selfData.visible) {
19389
+ if (!selfData.visible && !init) {
19370
19390
  mainDataArray[uSizeStart + 2] = -1;
19371
19391
  return;
19372
19392
  }
@@ -20465,6 +20485,7 @@ new Vector3();
20465
20485
  var CalculateItem = /** @class */ (function () {
20466
20486
  function CalculateItem(props, vfxItem) {
20467
20487
  var _a;
20488
+ this.vfxItem = vfxItem;
20468
20489
  this.active = false;
20469
20490
  this.transform = vfxItem.transform;
20470
20491
  var scale = this.transform.scale;
@@ -20858,7 +20879,7 @@ var SpriteItem = /** @class */ (function (_super) {
20858
20879
  else if (init) {
20859
20880
  ret.texOffset = [0, 0, 1, 1];
20860
20881
  }
20861
- ret.visible = this.visible;
20882
+ ret.visible = this.vfxItem.contentVisible;
20862
20883
  // 图层元素作为父节点时,除了k的大小变换,自身的尺寸也需要传递给子元素,子元素可以通过startSize读取
20863
20884
  ret.startSize = this.startSize;
20864
20885
  return ret;
@@ -20887,21 +20908,14 @@ var SpriteVFXItem = /** @class */ (function (_super) {
20887
20908
  this.sprite = props.content;
20888
20909
  };
20889
20910
  SpriteVFXItem.prototype.onLifetimeBegin = function (composition, content) {
20890
- this._contentVisible = true;
20891
20911
  content.active = true;
20892
20912
  };
20893
20913
  SpriteVFXItem.prototype.onItemRemoved = function (composition, content) {
20894
- this._contentVisible = false;
20895
20914
  if (content) {
20896
20915
  delete content.mesh;
20897
20916
  composition.destroyTextures(content.getTextures());
20898
20917
  }
20899
20918
  };
20900
- SpriteVFXItem.prototype.handleVisibleChanged = function (visible) {
20901
- if (this.content) {
20902
- this.content.visible = visible;
20903
- }
20904
- };
20905
20919
  SpriteVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
20906
20920
  var _a;
20907
20921
  (_a = this.content) === null || _a === void 0 ? void 0 : _a.updateTime(this.time);
@@ -23539,7 +23553,7 @@ var ParticleSystem = /** @class */ (function () {
23539
23553
  }
23540
23554
  this.meshes = meshes;
23541
23555
  this.reusable = vfxItem.reusable;
23542
- this.setVisible(vfxItem.getVisible());
23556
+ this.setVisible(vfxItem.contentVisible);
23543
23557
  var interaction = props.interaction;
23544
23558
  if (interaction) {
23545
23559
  this.interaction = {
@@ -24194,10 +24208,10 @@ var ParticleVFXItem = /** @class */ (function (_super) {
24194
24208
  }
24195
24209
  }
24196
24210
  if (hide) {
24197
- this.content.setVisible(true);
24211
+ this.content.setVisible(false);
24198
24212
  }
24199
24213
  else {
24200
- this.content.setVisible(false);
24214
+ this.content.setVisible(true);
24201
24215
  this.content.onUpdate(dt);
24202
24216
  }
24203
24217
  }
@@ -25913,13 +25927,11 @@ var TextItem = /** @class */ (function (_super) {
25913
25927
  _this.text = options.text;
25914
25928
  // Text
25915
25929
  _this.mesh = new TextMesh(_this.engine, _this.renderInfo, vfxItem.composition);
25916
- _this.mesh.setItems([_this]);
25917
- _this.updateTexture();
25918
25930
  return _this;
25919
25931
  }
25920
25932
  /**
25921
25933
  * 设置字号大小
25922
- * @param value 字号
25934
+ * @param value - 字号
25923
25935
  * @returns
25924
25936
  */
25925
25937
  TextItem.prototype.setFontSize = function (value) {
@@ -25933,7 +25945,7 @@ var TextItem = /** @class */ (function (_super) {
25933
25945
  };
25934
25946
  /**
25935
25947
  * 设置字重
25936
- * @param value 字重类型
25948
+ * @param value - 字重类型
25937
25949
  * @returns
25938
25950
  */
25939
25951
  TextItem.prototype.setFontWeight = function (value) {
@@ -25957,7 +25969,7 @@ var TextItem = /** @class */ (function (_super) {
25957
25969
  };
25958
25970
  /**
25959
25971
  * 设置文本
25960
- * @param value 文本内容
25972
+ * @param value - 文本内容
25961
25973
  * @returns
25962
25974
  */
25963
25975
  TextItem.prototype.setText = function (value) {
@@ -25969,7 +25981,7 @@ var TextItem = /** @class */ (function (_super) {
25969
25981
  };
25970
25982
  /**
25971
25983
  * 设置文本水平布局
25972
- * @param value 布局选项
25984
+ * @param value - 布局选项
25973
25985
  * @returns
25974
25986
  */
25975
25987
  TextItem.prototype.setTextAlign = function (value) {
@@ -25981,7 +25993,7 @@ var TextItem = /** @class */ (function (_super) {
25981
25993
  };
25982
25994
  /**
25983
25995
  * 设置文本垂直布局
25984
- * @param value 布局选项
25996
+ * @param value - 布局选项
25985
25997
  * @returns
25986
25998
  */
25987
25999
  TextItem.prototype.setTextBaseline = function (value) {
@@ -25993,7 +26005,7 @@ var TextItem = /** @class */ (function (_super) {
25993
26005
  };
25994
26006
  /**
25995
26007
  * 设置文本颜色
25996
- * @param value 颜色内容
26008
+ * @param value - 颜色内容
25997
26009
  * @returns
25998
26010
  */
25999
26011
  TextItem.prototype.setTextColor = function (value) {
@@ -26005,7 +26017,7 @@ var TextItem = /** @class */ (function (_super) {
26005
26017
  };
26006
26018
  /**
26007
26019
  * 设置文本字体
26008
- * @param value 文本字体
26020
+ * @param value - 文本字体
26009
26021
  * @returns
26010
26022
  */
26011
26023
  TextItem.prototype.setFontFamily = function (value) {
@@ -26017,7 +26029,7 @@ var TextItem = /** @class */ (function (_super) {
26017
26029
  };
26018
26030
  /**
26019
26031
  * 设置外描边文本颜色
26020
- * @param value 颜色内容
26032
+ * @param value - 颜色内容
26021
26033
  * @returns
26022
26034
  */
26023
26035
  TextItem.prototype.setOutlineColor = function (value) {
@@ -26029,7 +26041,7 @@ var TextItem = /** @class */ (function (_super) {
26029
26041
  };
26030
26042
  /**
26031
26043
  * 设置外描边文本宽度
26032
- * @param value 外描边宽度
26044
+ * @param value - 外描边宽度
26033
26045
  * @returns
26034
26046
  */
26035
26047
  TextItem.prototype.setOutlineWidth = function (value) {
@@ -26041,7 +26053,7 @@ var TextItem = /** @class */ (function (_super) {
26041
26053
  };
26042
26054
  /**
26043
26055
  * 设置阴影模糊
26044
- * @param value 阴影模糊强度
26056
+ * @param value - 阴影模糊强度
26045
26057
  * @returns
26046
26058
  */
26047
26059
  TextItem.prototype.setShadowBlur = function (value) {
@@ -26053,7 +26065,7 @@ var TextItem = /** @class */ (function (_super) {
26053
26065
  };
26054
26066
  /**
26055
26067
  * 设置阴影颜色
26056
- * @param value 阴影颜色
26068
+ * @param value - 阴影颜色
26057
26069
  * @returns
26058
26070
  */
26059
26071
  TextItem.prototype.setShadowColor = function (value) {
@@ -26065,7 +26077,7 @@ var TextItem = /** @class */ (function (_super) {
26065
26077
  };
26066
26078
  /**
26067
26079
  * 设置阴影水平偏移距离
26068
- * @param value 水平偏移距离
26080
+ * @param value - 水平偏移距离
26069
26081
  * @returns
26070
26082
  */
26071
26083
  TextItem.prototype.setShadowOffsetX = function (value) {
@@ -26077,7 +26089,7 @@ var TextItem = /** @class */ (function (_super) {
26077
26089
  };
26078
26090
  /**
26079
26091
  * 设置阴影水平偏移距离
26080
- * @param value 水平偏移距离
26092
+ * @param value - 水平偏移距离
26081
26093
  * @returns
26082
26094
  */
26083
26095
  TextItem.prototype.setShadowOffsetY = function (value) {
@@ -26089,7 +26101,7 @@ var TextItem = /** @class */ (function (_super) {
26089
26101
  };
26090
26102
  /**
26091
26103
  * 设置字体清晰度
26092
- * @param value 字体清晰度
26104
+ * @param value - 字体清晰度
26093
26105
  * @returns
26094
26106
  */
26095
26107
  TextItem.prototype.setFontScale = function (value) {
@@ -26116,7 +26128,7 @@ var TextItem = /** @class */ (function (_super) {
26116
26128
  var height = layout.height * fontScale;
26117
26129
  var fontSize = style.fontSize * fontScale;
26118
26130
  var lineHeight = layout.lineHeight * fontScale;
26119
- this.char = this.text.split('');
26131
+ this.char = (this.text || '').split('');
26120
26132
  this.canvas.width = width;
26121
26133
  this.canvas.height = height;
26122
26134
  context.clearRect(0, 0, width, this.canvas.height);
@@ -26246,23 +26258,22 @@ var TextVFXItem = /** @class */ (function (_super) {
26246
26258
  this.textContext = props.content;
26247
26259
  };
26248
26260
  TextVFXItem.prototype.onLifetimeBegin = function (composition, content) {
26249
- this._contentVisible = true;
26261
+ var _a;
26250
26262
  content.active = true;
26263
+ (_a = this.content) === null || _a === void 0 ? void 0 : _a.mesh.setItems([this.content]);
26264
+ this.content.updateTexture();
26251
26265
  };
26252
26266
  TextVFXItem.prototype.onItemRemoved = function (composition, content) {
26253
- this._contentVisible = false;
26254
26267
  if (content) {
26255
26268
  delete content.mesh;
26256
26269
  composition.destroyTextures(content.getTextures());
26257
26270
  }
26258
26271
  };
26259
- TextVFXItem.prototype.handleVisibleChanged = function (visible) {
26260
- if (this.content) {
26261
- this.content.visible = visible;
26262
- }
26263
- };
26264
26272
  TextVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
26265
26273
  var _a;
26274
+ if (!this.content) {
26275
+ return;
26276
+ }
26266
26277
  (_a = this.content) === null || _a === void 0 ? void 0 : _a.updateTime(this.time);
26267
26278
  };
26268
26279
  TextVFXItem.prototype.getCurrentPosition = function () {
@@ -26317,6 +26328,7 @@ var TextVFXItem = /** @class */ (function (_super) {
26317
26328
  };
26318
26329
  TextVFXItem.prototype.createWireframeMesh = function (item, color) {
26319
26330
  var spMesh = new TextMesh(this.composition.getEngine(), __assign$1({ wireframe: true }, item.renderInfo), this.composition);
26331
+ spMesh.mesh.setVisible(true);
26320
26332
  spMesh.setItems([item]);
26321
26333
  spMesh.mesh.material.setVector3('uFrameColor', Vector3.fromArray(color));
26322
26334
  spMesh.mesh.priority = 999;
@@ -26332,7 +26344,7 @@ var TextLoader = /** @class */ (function (_super) {
26332
26344
  _this.name = 'text';
26333
26345
  _this.addItems = [];
26334
26346
  _this.removeItems = [];
26335
- _this.meshes = []; // meshSplits对应的mesh数组 每次diff后更新
26347
+ _this.meshes = [];
26336
26348
  return _this;
26337
26349
  }
26338
26350
  TextLoader.prototype.onCompositionDestroyed = function (composition) {
@@ -26351,12 +26363,19 @@ var TextLoader = /** @class */ (function (_super) {
26351
26363
  };
26352
26364
  TextLoader.prototype.onCompositionUpdate = function (composition, dt) {
26353
26365
  this.addItems.forEach(function (item) {
26354
- var _a;
26366
+ var _a, _b, _c;
26367
+ if (!item.contentVisible) {
26368
+ (_a = item.content.mesh) === null || _a === void 0 ? void 0 : _a.mesh.setVisible(false);
26369
+ return;
26370
+ }
26371
+ else {
26372
+ (_b = item.content.mesh) === null || _b === void 0 ? void 0 : _b.mesh.setVisible(true);
26373
+ }
26355
26374
  item.content.updateTexture();
26356
26375
  if (!item.content.ended && item.content.mesh) {
26357
26376
  item.content.mesh.updateItem(item.content);
26377
+ (_c = item.content.mesh) === null || _c === void 0 ? void 0 : _c.applyChange();
26358
26378
  }
26359
- (_a = item.content.mesh) === null || _a === void 0 ? void 0 : _a.applyChange();
26360
26379
  });
26361
26380
  };
26362
26381
  TextLoader.prototype.onCompositionItemLifeBegin = function (composition, item) {
@@ -26375,6 +26394,7 @@ var TextLoader = /** @class */ (function (_super) {
26375
26394
  };
26376
26395
  TextLoader.prototype.onCompositionItemRemoved = function (composition, item) {
26377
26396
  var _a;
26397
+ // FIXME: 此处判断有问题,item 应该先判断
26378
26398
  if (item instanceof TextVFXItem && item) {
26379
26399
  addItem(this.removeItems, item);
26380
26400
  if (this.addItems.includes(item)) {
@@ -30928,23 +30948,41 @@ var Composition = /** @class */ (function () {
30928
30948
  this.content.translateByPixel(x, y);
30929
30949
  };
30930
30950
  /**
30931
- * 设置合成在 3D 坐标轴上相对移动
30951
+ * 设置合成在 3D 坐标轴上相对当前的位移
30932
30952
  */
30933
30953
  Composition.prototype.translate = function (x, y, z) {
30934
30954
  this.content.translate(x, y, z);
30935
30955
  };
30936
30956
  /**
30937
- * 设置合成在 3D 坐标轴上相对旋转(角度)
30957
+ * 设置合成在 3D 坐标轴上相对原点的位移
30958
+ */
30959
+ Composition.prototype.setPosition = function (x, y, z) {
30960
+ this.content.setPosition(x, y, z);
30961
+ };
30962
+ /**
30963
+ * 设置合成在 3D 坐标轴上相对当前的旋转(角度)
30938
30964
  */
30939
30965
  Composition.prototype.rotate = function (x, y, z) {
30940
30966
  this.content.rotate(x, y, z);
30941
30967
  };
30942
30968
  /**
30943
- * 设置合成在 3D 坐标轴上相对缩放
30969
+ * 设置合成在 3D 坐标轴上的相对原点的旋转(角度)
30970
+ */
30971
+ Composition.prototype.setRotation = function (x, y, z) {
30972
+ this.content.setRotation(x, y, z);
30973
+ };
30974
+ /**
30975
+ * 设置合成在 3D 坐标轴上相对当前的缩放
30944
30976
  */
30945
30977
  Composition.prototype.scale = function (x, y, z) {
30946
30978
  this.content.scale(x, y, z);
30947
30979
  };
30980
+ /**
30981
+ * 设置合成在 3D 坐标轴上的缩放
30982
+ */
30983
+ Composition.prototype.setScale = function (x, y, z) {
30984
+ this.content.setScale(x, y, z);
30985
+ };
30948
30986
  /**
30949
30987
  * 卸载贴图纹理方法,减少内存
30950
30988
  */
@@ -32542,7 +32580,7 @@ var ThreeMesh = /** @class */ (function (_super) {
32542
32580
  * @param val - 可见性开关
32543
32581
  */
32544
32582
  ThreeMesh.prototype.setVisible = function (val) {
32545
- this.mesh.visible = !val;
32583
+ this.mesh.visible = val;
32546
32584
  };
32547
32585
  /**
32548
32586
  * 获取 mesh 的可见性
@@ -32550,7 +32588,7 @@ var ThreeMesh = /** @class */ (function (_super) {
32550
32588
  * @returns
32551
32589
  */
32552
32590
  ThreeMesh.prototype.getVisible = function () {
32553
- return !this.mesh.visible;
32591
+ return this.mesh.visible;
32554
32592
  };
32555
32593
  /**
32556
32594
  * 获取 mesh 中的首个 geometry
@@ -32739,9 +32777,9 @@ Geometry.create = function (engine, options) {
32739
32777
  Mesh.create = function (engine, props) {
32740
32778
  return new ThreeMesh(engine, props);
32741
32779
  };
32742
- var version = "1.1.0-alpha.1";
32780
+ var version = "1.1.0-alpha.3";
32743
32781
  console.info({
32744
- content: '[Galacean Effects THREEJS] version: ' + "1.1.0-alpha.1",
32782
+ content: '[Galacean Effects THREEJS] version: ' + "1.1.0-alpha.3",
32745
32783
  type: LOG_TYPE,
32746
32784
  });
32747
32785