@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.mjs 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
  import * as THREE from 'three';
@@ -14392,6 +14392,7 @@ var Transform = /** @class */ (function () {
14392
14392
  */
14393
14393
  Transform.prototype.rotateByQuat = function (quat) {
14394
14394
  this.quat.multiply(quat);
14395
+ this.rotation.setFromQuaternion(this.quat);
14395
14396
  this.dirtyFlags.localData = true;
14396
14397
  this.dispatchValueChange();
14397
14398
  };
@@ -14890,6 +14891,7 @@ var VFXItem = /** @class */ (function () {
14890
14891
  this.delaying = false;
14891
14892
  this.transform.setValid(true);
14892
14893
  this.createContent();
14894
+ this._contentVisible = true;
14893
14895
  this.onLifetimeBegin(this.composition, this.content);
14894
14896
  this.composition.itemLifetimeEvent(this, true);
14895
14897
  }
@@ -14930,7 +14932,7 @@ var VFXItem = /** @class */ (function () {
14930
14932
  }
14931
14933
  }
14932
14934
  else if (this.endBehavior === END_BEHAVIOR_DESTROY$1) {
14933
- this.setVisible(false);
14935
+ this._contentVisible = false;
14934
14936
  }
14935
14937
  lifetime = Math.min(lifetime, 1);
14936
14938
  }
@@ -15154,6 +15156,7 @@ var VFXItem = /** @class */ (function () {
15154
15156
  if (this.composition) {
15155
15157
  this.onItemRemoved(this.composition, this._content);
15156
15158
  this._content = undefined;
15159
+ this._contentVisible = false;
15157
15160
  }
15158
15161
  this.started = false;
15159
15162
  };
@@ -15284,7 +15287,7 @@ var PluginSystem = /** @class */ (function () {
15284
15287
  .map(function (name) {
15285
15288
  var CTRL = pluginLoaderMap[name];
15286
15289
  if (!CTRL) {
15287
- throw new Error("plugin '".concat(name, "' not found"));
15290
+ throw new Error("plugin '".concat(name, "' not found.") + getPluginUsageInfo(name));
15288
15291
  }
15289
15292
  var loader = new CTRL();
15290
15293
  loader.name = name;
@@ -15356,6 +15359,23 @@ var PluginSystem = /** @class */ (function () {
15356
15359
  };
15357
15360
  return PluginSystem;
15358
15361
  }());
15362
+ var pluginInfoMap = {
15363
+ 'alipay-downgrade': '@galacean/effects-plugin-alipay-downgrade',
15364
+ 'editor-gizmo': '@galacean/effects-plugin-editor-gizmo',
15365
+ 'tree': '@galacean/effects-plugin-model',
15366
+ 'model': '@galacean/effects-plugin-model',
15367
+ 'orientation-transformer': '@galacean/effects-plugin-orientation-transformer',
15368
+ 'spine': '@galacean/effects-plugin-spine',
15369
+ };
15370
+ function getPluginUsageInfo(name) {
15371
+ var info = pluginInfoMap[name];
15372
+ if (info) {
15373
+ return "\nInstall Plugin: npm i ".concat(info, "@latest --save\nImport Plugin: import '").concat(info, "'");
15374
+ }
15375
+ else {
15376
+ return '';
15377
+ }
15378
+ }
15359
15379
 
15360
15380
  /**
15361
15381
  * 抽象插件类
@@ -17028,7 +17048,7 @@ var Mesh = /** @class */ (function () {
17028
17048
  function Mesh(engine, props) {
17029
17049
  this.engine = engine;
17030
17050
  this.destroyed = false;
17031
- this.visible = false;
17051
+ this.visible = true;
17032
17052
  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;
17033
17053
  this.id = 'Mesh' + seed$8++;
17034
17054
  this.name = name;
@@ -19255,7 +19275,7 @@ var SpriteMesh = /** @class */ (function () {
19255
19275
  var indexLen = 0;
19256
19276
  var pointCount = 0;
19257
19277
  if (!items.length) {
19258
- this.mesh.setVisible(true);
19278
+ this.mesh.setVisible(false);
19259
19279
  return true;
19260
19280
  }
19261
19281
  this.items = items.slice();
@@ -19312,7 +19332,7 @@ var SpriteMesh = /** @class */ (function () {
19312
19332
  geometry.setIndexData(indexData);
19313
19333
  geometry.setAttributeData('aPoint', bundle.aPoint);
19314
19334
  geometry.setDrawCount(indexLen);
19315
- this.mesh.setVisible(!geometry.getDrawCount());
19335
+ this.mesh.setVisible(!!geometry.getDrawCount());
19316
19336
  this.mesh.priority = items[0].listIndex;
19317
19337
  for (var i = 0; i < textures.length; i++) {
19318
19338
  var texture = textures[i];
@@ -19342,7 +19362,7 @@ var SpriteMesh = /** @class */ (function () {
19342
19362
  var uSizeStart = start + 4;
19343
19363
  var uQuatStart = start + 8;
19344
19364
  var uColorStart = start + 12;
19345
- if (!selfData.visible) {
19365
+ if (!selfData.visible && !init) {
19346
19366
  mainDataArray[uSizeStart + 2] = -1;
19347
19367
  return;
19348
19368
  }
@@ -20441,6 +20461,7 @@ new Vector3();
20441
20461
  var CalculateItem = /** @class */ (function () {
20442
20462
  function CalculateItem(props, vfxItem) {
20443
20463
  var _a;
20464
+ this.vfxItem = vfxItem;
20444
20465
  this.active = false;
20445
20466
  this.transform = vfxItem.transform;
20446
20467
  var scale = this.transform.scale;
@@ -20834,7 +20855,7 @@ var SpriteItem = /** @class */ (function (_super) {
20834
20855
  else if (init) {
20835
20856
  ret.texOffset = [0, 0, 1, 1];
20836
20857
  }
20837
- ret.visible = this.visible;
20858
+ ret.visible = this.vfxItem.contentVisible;
20838
20859
  // 图层元素作为父节点时,除了k的大小变换,自身的尺寸也需要传递给子元素,子元素可以通过startSize读取
20839
20860
  ret.startSize = this.startSize;
20840
20861
  return ret;
@@ -20863,21 +20884,14 @@ var SpriteVFXItem = /** @class */ (function (_super) {
20863
20884
  this.sprite = props.content;
20864
20885
  };
20865
20886
  SpriteVFXItem.prototype.onLifetimeBegin = function (composition, content) {
20866
- this._contentVisible = true;
20867
20887
  content.active = true;
20868
20888
  };
20869
20889
  SpriteVFXItem.prototype.onItemRemoved = function (composition, content) {
20870
- this._contentVisible = false;
20871
20890
  if (content) {
20872
20891
  delete content.mesh;
20873
20892
  composition.destroyTextures(content.getTextures());
20874
20893
  }
20875
20894
  };
20876
- SpriteVFXItem.prototype.handleVisibleChanged = function (visible) {
20877
- if (this.content) {
20878
- this.content.visible = visible;
20879
- }
20880
- };
20881
20895
  SpriteVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
20882
20896
  var _a;
20883
20897
  (_a = this.content) === null || _a === void 0 ? void 0 : _a.updateTime(this.time);
@@ -23515,7 +23529,7 @@ var ParticleSystem = /** @class */ (function () {
23515
23529
  }
23516
23530
  this.meshes = meshes;
23517
23531
  this.reusable = vfxItem.reusable;
23518
- this.setVisible(vfxItem.getVisible());
23532
+ this.setVisible(vfxItem.contentVisible);
23519
23533
  var interaction = props.interaction;
23520
23534
  if (interaction) {
23521
23535
  this.interaction = {
@@ -24170,10 +24184,10 @@ var ParticleVFXItem = /** @class */ (function (_super) {
24170
24184
  }
24171
24185
  }
24172
24186
  if (hide) {
24173
- this.content.setVisible(true);
24187
+ this.content.setVisible(false);
24174
24188
  }
24175
24189
  else {
24176
- this.content.setVisible(false);
24190
+ this.content.setVisible(true);
24177
24191
  this.content.onUpdate(dt);
24178
24192
  }
24179
24193
  }
@@ -25889,13 +25903,11 @@ var TextItem = /** @class */ (function (_super) {
25889
25903
  _this.text = options.text;
25890
25904
  // Text
25891
25905
  _this.mesh = new TextMesh(_this.engine, _this.renderInfo, vfxItem.composition);
25892
- _this.mesh.setItems([_this]);
25893
- _this.updateTexture();
25894
25906
  return _this;
25895
25907
  }
25896
25908
  /**
25897
25909
  * 设置字号大小
25898
- * @param value 字号
25910
+ * @param value - 字号
25899
25911
  * @returns
25900
25912
  */
25901
25913
  TextItem.prototype.setFontSize = function (value) {
@@ -25909,7 +25921,7 @@ var TextItem = /** @class */ (function (_super) {
25909
25921
  };
25910
25922
  /**
25911
25923
  * 设置字重
25912
- * @param value 字重类型
25924
+ * @param value - 字重类型
25913
25925
  * @returns
25914
25926
  */
25915
25927
  TextItem.prototype.setFontWeight = 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.setText = function (value) {
@@ -25945,7 +25957,7 @@ var TextItem = /** @class */ (function (_super) {
25945
25957
  };
25946
25958
  /**
25947
25959
  * 设置文本水平布局
25948
- * @param value 布局选项
25960
+ * @param value - 布局选项
25949
25961
  * @returns
25950
25962
  */
25951
25963
  TextItem.prototype.setTextAlign = 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.setTextBaseline = 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.setTextColor = 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.setFontFamily = 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.setOutlineColor = 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.setOutlineWidth = 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.setShadowBlur = 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.setShadowColor = 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.setShadowOffsetX = 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.setShadowOffsetY = 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.setFontScale = function (value) {
@@ -26092,7 +26104,7 @@ var TextItem = /** @class */ (function (_super) {
26092
26104
  var height = layout.height * fontScale;
26093
26105
  var fontSize = style.fontSize * fontScale;
26094
26106
  var lineHeight = layout.lineHeight * fontScale;
26095
- this.char = this.text.split('');
26107
+ this.char = (this.text || '').split('');
26096
26108
  this.canvas.width = width;
26097
26109
  this.canvas.height = height;
26098
26110
  context.clearRect(0, 0, width, this.canvas.height);
@@ -26222,23 +26234,22 @@ var TextVFXItem = /** @class */ (function (_super) {
26222
26234
  this.textContext = props.content;
26223
26235
  };
26224
26236
  TextVFXItem.prototype.onLifetimeBegin = function (composition, content) {
26225
- this._contentVisible = true;
26237
+ var _a;
26226
26238
  content.active = true;
26239
+ (_a = this.content) === null || _a === void 0 ? void 0 : _a.mesh.setItems([this.content]);
26240
+ this.content.updateTexture();
26227
26241
  };
26228
26242
  TextVFXItem.prototype.onItemRemoved = function (composition, content) {
26229
- this._contentVisible = false;
26230
26243
  if (content) {
26231
26244
  delete content.mesh;
26232
26245
  composition.destroyTextures(content.getTextures());
26233
26246
  }
26234
26247
  };
26235
- TextVFXItem.prototype.handleVisibleChanged = function (visible) {
26236
- if (this.content) {
26237
- this.content.visible = visible;
26238
- }
26239
- };
26240
26248
  TextVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
26241
26249
  var _a;
26250
+ if (!this.content) {
26251
+ return;
26252
+ }
26242
26253
  (_a = this.content) === null || _a === void 0 ? void 0 : _a.updateTime(this.time);
26243
26254
  };
26244
26255
  TextVFXItem.prototype.getCurrentPosition = function () {
@@ -26293,6 +26304,7 @@ var TextVFXItem = /** @class */ (function (_super) {
26293
26304
  };
26294
26305
  TextVFXItem.prototype.createWireframeMesh = function (item, color) {
26295
26306
  var spMesh = new TextMesh(this.composition.getEngine(), __assign$1({ wireframe: true }, item.renderInfo), this.composition);
26307
+ spMesh.mesh.setVisible(true);
26296
26308
  spMesh.setItems([item]);
26297
26309
  spMesh.mesh.material.setVector3('uFrameColor', Vector3.fromArray(color));
26298
26310
  spMesh.mesh.priority = 999;
@@ -26308,7 +26320,7 @@ var TextLoader = /** @class */ (function (_super) {
26308
26320
  _this.name = 'text';
26309
26321
  _this.addItems = [];
26310
26322
  _this.removeItems = [];
26311
- _this.meshes = []; // meshSplits对应的mesh数组 每次diff后更新
26323
+ _this.meshes = [];
26312
26324
  return _this;
26313
26325
  }
26314
26326
  TextLoader.prototype.onCompositionDestroyed = function (composition) {
@@ -26327,12 +26339,19 @@ var TextLoader = /** @class */ (function (_super) {
26327
26339
  };
26328
26340
  TextLoader.prototype.onCompositionUpdate = function (composition, dt) {
26329
26341
  this.addItems.forEach(function (item) {
26330
- var _a;
26342
+ var _a, _b, _c;
26343
+ if (!item.contentVisible) {
26344
+ (_a = item.content.mesh) === null || _a === void 0 ? void 0 : _a.mesh.setVisible(false);
26345
+ return;
26346
+ }
26347
+ else {
26348
+ (_b = item.content.mesh) === null || _b === void 0 ? void 0 : _b.mesh.setVisible(true);
26349
+ }
26331
26350
  item.content.updateTexture();
26332
26351
  if (!item.content.ended && item.content.mesh) {
26333
26352
  item.content.mesh.updateItem(item.content);
26353
+ (_c = item.content.mesh) === null || _c === void 0 ? void 0 : _c.applyChange();
26334
26354
  }
26335
- (_a = item.content.mesh) === null || _a === void 0 ? void 0 : _a.applyChange();
26336
26355
  });
26337
26356
  };
26338
26357
  TextLoader.prototype.onCompositionItemLifeBegin = function (composition, item) {
@@ -26351,6 +26370,7 @@ var TextLoader = /** @class */ (function (_super) {
26351
26370
  };
26352
26371
  TextLoader.prototype.onCompositionItemRemoved = function (composition, item) {
26353
26372
  var _a;
26373
+ // FIXME: 此处判断有问题,item 应该先判断
26354
26374
  if (item instanceof TextVFXItem && item) {
26355
26375
  addItem(this.removeItems, item);
26356
26376
  if (this.addItems.includes(item)) {
@@ -30904,23 +30924,41 @@ var Composition = /** @class */ (function () {
30904
30924
  this.content.translateByPixel(x, y);
30905
30925
  };
30906
30926
  /**
30907
- * 设置合成在 3D 坐标轴上相对移动
30927
+ * 设置合成在 3D 坐标轴上相对当前的位移
30908
30928
  */
30909
30929
  Composition.prototype.translate = function (x, y, z) {
30910
30930
  this.content.translate(x, y, z);
30911
30931
  };
30912
30932
  /**
30913
- * 设置合成在 3D 坐标轴上相对旋转(角度)
30933
+ * 设置合成在 3D 坐标轴上相对原点的位移
30934
+ */
30935
+ Composition.prototype.setPosition = function (x, y, z) {
30936
+ this.content.setPosition(x, y, z);
30937
+ };
30938
+ /**
30939
+ * 设置合成在 3D 坐标轴上相对当前的旋转(角度)
30914
30940
  */
30915
30941
  Composition.prototype.rotate = function (x, y, z) {
30916
30942
  this.content.rotate(x, y, z);
30917
30943
  };
30918
30944
  /**
30919
- * 设置合成在 3D 坐标轴上相对缩放
30945
+ * 设置合成在 3D 坐标轴上的相对原点的旋转(角度)
30946
+ */
30947
+ Composition.prototype.setRotation = function (x, y, z) {
30948
+ this.content.setRotation(x, y, z);
30949
+ };
30950
+ /**
30951
+ * 设置合成在 3D 坐标轴上相对当前的缩放
30920
30952
  */
30921
30953
  Composition.prototype.scale = function (x, y, z) {
30922
30954
  this.content.scale(x, y, z);
30923
30955
  };
30956
+ /**
30957
+ * 设置合成在 3D 坐标轴上的缩放
30958
+ */
30959
+ Composition.prototype.setScale = function (x, y, z) {
30960
+ this.content.setScale(x, y, z);
30961
+ };
30924
30962
  /**
30925
30963
  * 卸载贴图纹理方法,减少内存
30926
30964
  */
@@ -32518,7 +32556,7 @@ var ThreeMesh = /** @class */ (function (_super) {
32518
32556
  * @param val - 可见性开关
32519
32557
  */
32520
32558
  ThreeMesh.prototype.setVisible = function (val) {
32521
- this.mesh.visible = !val;
32559
+ this.mesh.visible = val;
32522
32560
  };
32523
32561
  /**
32524
32562
  * 获取 mesh 的可见性
@@ -32526,7 +32564,7 @@ var ThreeMesh = /** @class */ (function (_super) {
32526
32564
  * @returns
32527
32565
  */
32528
32566
  ThreeMesh.prototype.getVisible = function () {
32529
- return !this.mesh.visible;
32567
+ return this.mesh.visible;
32530
32568
  };
32531
32569
  /**
32532
32570
  * 获取 mesh 中的首个 geometry
@@ -32715,9 +32753,9 @@ Geometry.create = function (engine, options) {
32715
32753
  Mesh.create = function (engine, props) {
32716
32754
  return new ThreeMesh(engine, props);
32717
32755
  };
32718
- var version = "1.1.0-alpha.1";
32756
+ var version = "1.1.0-alpha.3";
32719
32757
  console.info({
32720
- content: '[Galacean Effects THREEJS] version: ' + "1.1.0-alpha.1",
32758
+ content: '[Galacean Effects THREEJS] version: ' + "1.1.0-alpha.3",
32721
32759
  type: LOG_TYPE,
32722
32760
  });
32723
32761