@galacean/effects 1.1.0-alpha.0 → 1.1.0-alpha.2

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.0
6
+ * Version: v1.1.0-alpha.2
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;
@@ -19181,7 +19201,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
19181
19201
  (_b = event.origin) === null || _b === void 0 ? void 0 : _b.preventDefault();
19182
19202
  }
19183
19203
  }
19184
- this.composition.camera.position.set(nx, ny, depth);
19204
+ this.composition.camera.position = new Vector3(nx, ny, depth);
19185
19205
  };
19186
19206
  return InteractVFXItem;
19187
19207
  }(VFXItem));
@@ -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)) {
@@ -29898,7 +29918,8 @@ var CompVFXItem = /** @class */ (function (_super) {
29898
29918
  configurable: true
29899
29919
  });
29900
29920
  CompVFXItem.prototype.onConstructed = function (props) {
29901
- var _a = props.items, items = _a === void 0 ? [] : _a, _b = props.startTime, startTime = _b === void 0 ? 0 : _b, content = props.content;
29921
+ var _a = props.items, items = _a === void 0 ? [] : _a, _b = props.startTime, startTime = _b === void 0 ? 0 : _b, content = props.content, refId = props.refId;
29922
+ this.refId = refId;
29902
29923
  this.itemProps = items;
29903
29924
  this.contentProps = content;
29904
29925
  var endBehavior = this.endBehavior;
@@ -29925,13 +29946,8 @@ var CompVFXItem = /** @class */ (function (_super) {
29925
29946
  if (!props) {
29926
29947
  throw new Error("\u5F15\u7528\u7684Id: ".concat(refId, " \u7684\u9884\u5408\u6210\u4E0D\u5B58\u5728"));
29927
29948
  }
29928
- props.name = itemProps.name;
29929
- props.duration = itemProps.duration;
29930
- props.endBehavior = itemProps.endBehavior;
29931
- props.delay = itemProps.delay;
29932
- props.parentId = itemProps.parentId;
29933
29949
  props.content = itemProps.content;
29934
- item = new CompVFXItem(props, this.composition);
29950
+ item = new CompVFXItem(__assign$1(__assign$1({}, props), { refId: refId, id: itemProps.id, name: itemProps.name, duration: itemProps.duration, endBehavior: itemProps.endBehavior, parentId: itemProps.parentId, transform: itemProps.transform }), this.composition);
29935
29951
  item.contentProps = itemProps.content;
29936
29952
  item.transform.parentTransform = this.transform;
29937
29953
  this.composition.refContent.push(item);
@@ -30186,6 +30202,74 @@ var CompVFXItem = /** @class */ (function (_super) {
30186
30202
  }
30187
30203
  return res;
30188
30204
  };
30205
+ CompVFXItem.prototype.hitTest = function (ray, x, y, regions, force, options) {
30206
+ var hitPositions = [];
30207
+ var stop = (options === null || options === void 0 ? void 0 : options.stop) || noop;
30208
+ var skip = (options === null || options === void 0 ? void 0 : options.skip) || noop;
30209
+ var maxCount = (options === null || options === void 0 ? void 0 : options.maxCount) || this.items.length;
30210
+ for (var i = 0; i < this.items.length && regions.length < maxCount; i++) {
30211
+ var item = this.items[i];
30212
+ if (item.lifetime >= 0 && item.lifetime <= 1 && !VFXItem.isComposition(item) && !skip(item)) {
30213
+ var hitParams = item.getHitTestParams(force);
30214
+ if (hitParams) {
30215
+ var success = false;
30216
+ var intersectPoint = new Vector3();
30217
+ if (hitParams.type === exports.HitTestType.triangle) {
30218
+ var triangles = hitParams.triangles, backfaceCulling = hitParams.backfaceCulling;
30219
+ for (var j = 0; j < triangles.length; j++) {
30220
+ var triangle = triangles[j];
30221
+ if (ray.intersectTriangle(triangle, intersectPoint, backfaceCulling)) {
30222
+ success = true;
30223
+ hitPositions.push(intersectPoint);
30224
+ break;
30225
+ }
30226
+ }
30227
+ }
30228
+ else if (hitParams.type === exports.HitTestType.box) {
30229
+ var center = hitParams.center, size = hitParams.size;
30230
+ var boxMin = center.clone().addScaledVector(size, 0.5);
30231
+ var boxMax = center.clone().addScaledVector(size, -0.5);
30232
+ if (ray.intersectBox({ min: boxMin, max: boxMax }, intersectPoint)) {
30233
+ success = true;
30234
+ hitPositions.push(intersectPoint);
30235
+ }
30236
+ }
30237
+ else if (hitParams.type === exports.HitTestType.sphere) {
30238
+ var center = hitParams.center, radius = hitParams.radius;
30239
+ if (ray.intersectSphere({ center: center, radius: radius }, intersectPoint)) {
30240
+ success = true;
30241
+ hitPositions.push(intersectPoint);
30242
+ }
30243
+ }
30244
+ else if (hitParams.type === exports.HitTestType.custom) {
30245
+ var tempPosition = hitParams.collect(ray, new Vector2(x, y));
30246
+ if (tempPosition && tempPosition.length > 0) {
30247
+ tempPosition.forEach(function (pos) {
30248
+ hitPositions.push(pos);
30249
+ });
30250
+ success = true;
30251
+ }
30252
+ }
30253
+ if (success) {
30254
+ var region = {
30255
+ compContent: this,
30256
+ id: item.id,
30257
+ name: item.name,
30258
+ position: hitPositions[hitPositions.length - 1],
30259
+ parentId: item.parentId,
30260
+ hitPositions: hitPositions,
30261
+ behavior: hitParams.behavior,
30262
+ };
30263
+ regions.push(region);
30264
+ if (stop(region)) {
30265
+ return regions;
30266
+ }
30267
+ }
30268
+ }
30269
+ }
30270
+ }
30271
+ return regions;
30272
+ };
30189
30273
  CompVFXItem.prototype.isEnded = function (now) {
30190
30274
  return now >= this.durInms;
30191
30275
  };
@@ -30649,7 +30733,7 @@ var Composition = /** @class */ (function () {
30649
30733
  this.pluginSystem.plugins.forEach(func);
30650
30734
  };
30651
30735
  /**
30652
- *
30736
+ * 获取指定位置和相机连成的射线
30653
30737
  * @param x
30654
30738
  * @param y
30655
30739
  * @returns
@@ -30677,73 +30761,12 @@ var Composition = /** @class */ (function () {
30677
30761
  if (this.isDestroyed) {
30678
30762
  return [];
30679
30763
  }
30680
- var hitPositions = [];
30681
30764
  var regions = [];
30682
- var _a = this.renderFrame.editorTransform, a = _a.x, b = _a.y, c = _a.z, d = _a.w;
30683
- var ray = setRayFromCamera((x - c) / a, (y - d) / b, this.camera);
30684
- var stop = (options === null || options === void 0 ? void 0 : options.stop) || noop;
30685
- var skip = (options === null || options === void 0 ? void 0 : options.skip) || noop;
30686
- var maxCount = (options === null || options === void 0 ? void 0 : options.maxCount) || this.items.length;
30687
- for (var i = 0; i < this.items.length && regions.length < maxCount; i++) {
30688
- var item = this.items[i];
30689
- if (item.lifetime >= 0 && item.lifetime <= 1 && !skip(item)) {
30690
- var hitParams = item.getHitTestParams(force);
30691
- if (hitParams) {
30692
- var success = false;
30693
- var intersectPoint = new Vector3();
30694
- if (hitParams.type === exports.HitTestType.triangle) {
30695
- var triangles = hitParams.triangles, backfaceCulling = hitParams.backfaceCulling;
30696
- for (var j = 0; j < triangles.length; j++) {
30697
- var triangle = triangles[j];
30698
- if (ray.intersectTriangle(triangle, intersectPoint, backfaceCulling)) {
30699
- success = true;
30700
- hitPositions.push(intersectPoint);
30701
- break;
30702
- }
30703
- }
30704
- }
30705
- else if (hitParams.type === exports.HitTestType.box) {
30706
- var center = hitParams.center, size = hitParams.size;
30707
- var boxMin = center.clone().addScaledVector(size, 0.5);
30708
- var boxMax = center.clone().addScaledVector(size, -0.5);
30709
- if (ray.intersectBox({ min: boxMin, max: boxMax }, intersectPoint)) {
30710
- success = true;
30711
- hitPositions.push(intersectPoint);
30712
- }
30713
- }
30714
- else if (hitParams.type === exports.HitTestType.sphere) {
30715
- var center = hitParams.center, radius = hitParams.radius;
30716
- if (ray.intersectSphere({ center: center, radius: radius }, intersectPoint)) {
30717
- success = true;
30718
- hitPositions.push(intersectPoint);
30719
- }
30720
- }
30721
- else if (hitParams.type === exports.HitTestType.custom) {
30722
- var tempPosition = hitParams.collect(ray, new Vector2(x, y));
30723
- if (tempPosition && tempPosition.length > 0) {
30724
- tempPosition.forEach(function (pos) {
30725
- hitPositions.push(pos);
30726
- });
30727
- success = true;
30728
- }
30729
- }
30730
- if (success) {
30731
- var region = {
30732
- id: item.id,
30733
- name: item.name,
30734
- position: hitPositions[hitPositions.length - 1],
30735
- parentId: item.parentId,
30736
- hitPositions: hitPositions,
30737
- behavior: hitParams.behavior,
30738
- };
30739
- regions.push(region);
30740
- if (stop(region)) {
30741
- return regions;
30742
- }
30743
- }
30744
- }
30745
- }
30746
- }
30765
+ var ray = this.getHitTestRay(x, y);
30766
+ this.content.hitTest(ray, x, y, regions, force, options);
30767
+ this.refContent.forEach(function (ref) {
30768
+ ref.hitTest(ray, x, y, regions, force, options);
30769
+ });
30747
30770
  return regions;
30748
30771
  };
30749
30772
  /**
@@ -30903,23 +30926,41 @@ var Composition = /** @class */ (function () {
30903
30926
  this.content.translateByPixel(x, y);
30904
30927
  };
30905
30928
  /**
30906
- * 设置合成在 3D 坐标轴上相对移动
30929
+ * 设置合成在 3D 坐标轴上相对当前的位移
30907
30930
  */
30908
30931
  Composition.prototype.translate = function (x, y, z) {
30909
30932
  this.content.translate(x, y, z);
30910
30933
  };
30911
30934
  /**
30912
- * 设置合成在 3D 坐标轴上相对旋转(角度)
30935
+ * 设置合成在 3D 坐标轴上相对原点的位移
30936
+ */
30937
+ Composition.prototype.setPosition = function (x, y, z) {
30938
+ this.content.setPosition(x, y, z);
30939
+ };
30940
+ /**
30941
+ * 设置合成在 3D 坐标轴上相对当前的旋转(角度)
30913
30942
  */
30914
30943
  Composition.prototype.rotate = function (x, y, z) {
30915
30944
  this.content.rotate(x, y, z);
30916
30945
  };
30917
30946
  /**
30918
- * 设置合成在 3D 坐标轴上相对缩放
30947
+ * 设置合成在 3D 坐标轴上的相对原点的旋转(角度)
30948
+ */
30949
+ Composition.prototype.setRotation = function (x, y, z) {
30950
+ this.content.setRotation(x, y, z);
30951
+ };
30952
+ /**
30953
+ * 设置合成在 3D 坐标轴上相对当前的缩放
30919
30954
  */
30920
30955
  Composition.prototype.scale = function (x, y, z) {
30921
30956
  this.content.scale(x, y, z);
30922
30957
  };
30958
+ /**
30959
+ * 设置合成在 3D 坐标轴上的缩放
30960
+ */
30961
+ Composition.prototype.setScale = function (x, y, z) {
30962
+ this.content.setScale(x, y, z);
30963
+ };
30923
30964
  /**
30924
30965
  * 卸载贴图纹理方法,减少内存
30925
30966
  */
@@ -35209,7 +35250,7 @@ var GLRenderer = /** @class */ (function (_super) {
35209
35250
  // console.error(`mesh ${mesh.name} destroyed`, mesh);
35210
35251
  continue;
35211
35252
  }
35212
- if (mesh.getVisible()) {
35253
+ if (!mesh.getVisible()) {
35213
35254
  continue;
35214
35255
  }
35215
35256
  if (!mesh.material) {
@@ -35525,15 +35566,7 @@ var Player = /** @class */ (function () {
35525
35566
  for (var i = 0; i < regions.length; i++) {
35526
35567
  var behavior = regions[i].behavior || InteractBehavior$2.NOTIFY;
35527
35568
  if (behavior === InteractBehavior$2.NOTIFY) {
35528
- var _b = regions[i], name_1 = _b.name, id = _b.id, hitPositions = _b.hitPositions;
35529
- (_a = _this.handleItemClicked) === null || _a === void 0 ? void 0 : _a.call(_this, {
35530
- name: name_1,
35531
- player: _this,
35532
- composition: composition.name,
35533
- id: id,
35534
- compositionId: composition.id,
35535
- hitPositions: hitPositions,
35536
- });
35569
+ (_a = _this.handleItemClicked) === null || _a === void 0 ? void 0 : _a.call(_this, __assign$1(__assign$1({}, regions[i]), { composition: composition.name, player: _this }));
35537
35570
  }
35538
35571
  else if (behavior === InteractBehavior$2.RESUME_PLAYER) {
35539
35572
  void _this.resume();
@@ -36140,11 +36173,15 @@ var Player = /** @class */ (function () {
36140
36173
  }
36141
36174
  this.canvas.remove();
36142
36175
  }
36143
- this.tick = throwDestroyedError;
36144
- this.resize = throwDestroyedError;
36145
- this.loadScene = throwDestroyedErrorPromise;
36146
- this.play = throwDestroyedErrorPromise;
36147
- 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;
36148
36185
  this.disposed = true;
36149
36186
  };
36150
36187
  Player.prototype.offloadTexture = function () {
@@ -36269,11 +36306,13 @@ function assertContainer(container) {
36269
36306
  throw new Error("Container is not an HTMLElement, see ".concat(HELP_LINK['Container is not an HTMLElement']));
36270
36307
  }
36271
36308
  }
36272
- var destroyedErrorMessage = "Never use destroyed player again, see ".concat(HELP_LINK['Never use destroyed player again']);
36273
- 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) {
36274
36313
  throw new Error(destroyedErrorMessage);
36275
36314
  }
36276
- function throwDestroyedErrorPromise() {
36315
+ function throwDestroyedErrorPromise(destroyedErrorMessage) {
36277
36316
  return Promise.reject(destroyedErrorMessage);
36278
36317
  }
36279
36318
 
@@ -36319,9 +36358,9 @@ Renderer.create = function (canvas, framework, renderOptions) {
36319
36358
  Engine.create = function (gl) {
36320
36359
  return new GLEngine(gl);
36321
36360
  };
36322
- var version = "1.1.0-alpha.0";
36361
+ var version = "1.1.0-alpha.2";
36323
36362
  console.info({
36324
- content: '[Galacean Effects Player] version: ' + "1.1.0-alpha.0",
36363
+ content: '[Galacean Effects Player] version: ' + "1.1.0-alpha.2",
36325
36364
  type: LOG_TYPE,
36326
36365
  });
36327
36366