@galacean/effects-threejs 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.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.0
6
+ * Version: v1.1.0-alpha.2
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;
@@ -19179,7 +19199,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
19179
19199
  (_b = event.origin) === null || _b === void 0 ? void 0 : _b.preventDefault();
19180
19200
  }
19181
19201
  }
19182
- this.composition.camera.position.set(nx, ny, depth);
19202
+ this.composition.camera.position = new Vector3(nx, ny, depth);
19183
19203
  };
19184
19204
  return InteractVFXItem;
19185
19205
  }(VFXItem));
@@ -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)) {
@@ -29896,7 +29916,8 @@ var CompVFXItem = /** @class */ (function (_super) {
29896
29916
  configurable: true
29897
29917
  });
29898
29918
  CompVFXItem.prototype.onConstructed = function (props) {
29899
- var _a = props.items, items = _a === void 0 ? [] : _a, _b = props.startTime, startTime = _b === void 0 ? 0 : _b, content = props.content;
29919
+ var _a = props.items, items = _a === void 0 ? [] : _a, _b = props.startTime, startTime = _b === void 0 ? 0 : _b, content = props.content, refId = props.refId;
29920
+ this.refId = refId;
29900
29921
  this.itemProps = items;
29901
29922
  this.contentProps = content;
29902
29923
  var endBehavior = this.endBehavior;
@@ -29923,13 +29944,8 @@ var CompVFXItem = /** @class */ (function (_super) {
29923
29944
  if (!props) {
29924
29945
  throw new Error("\u5F15\u7528\u7684Id: ".concat(refId, " \u7684\u9884\u5408\u6210\u4E0D\u5B58\u5728"));
29925
29946
  }
29926
- props.name = itemProps.name;
29927
- props.duration = itemProps.duration;
29928
- props.endBehavior = itemProps.endBehavior;
29929
- props.delay = itemProps.delay;
29930
- props.parentId = itemProps.parentId;
29931
29947
  props.content = itemProps.content;
29932
- item = new CompVFXItem(props, this.composition);
29948
+ 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);
29933
29949
  item.contentProps = itemProps.content;
29934
29950
  item.transform.parentTransform = this.transform;
29935
29951
  this.composition.refContent.push(item);
@@ -30184,6 +30200,74 @@ var CompVFXItem = /** @class */ (function (_super) {
30184
30200
  }
30185
30201
  return res;
30186
30202
  };
30203
+ CompVFXItem.prototype.hitTest = function (ray, x, y, regions, force, options) {
30204
+ var hitPositions = [];
30205
+ var stop = (options === null || options === void 0 ? void 0 : options.stop) || noop;
30206
+ var skip = (options === null || options === void 0 ? void 0 : options.skip) || noop;
30207
+ var maxCount = (options === null || options === void 0 ? void 0 : options.maxCount) || this.items.length;
30208
+ for (var i = 0; i < this.items.length && regions.length < maxCount; i++) {
30209
+ var item = this.items[i];
30210
+ if (item.lifetime >= 0 && item.lifetime <= 1 && !VFXItem.isComposition(item) && !skip(item)) {
30211
+ var hitParams = item.getHitTestParams(force);
30212
+ if (hitParams) {
30213
+ var success = false;
30214
+ var intersectPoint = new Vector3();
30215
+ if (hitParams.type === HitTestType.triangle) {
30216
+ var triangles = hitParams.triangles, backfaceCulling = hitParams.backfaceCulling;
30217
+ for (var j = 0; j < triangles.length; j++) {
30218
+ var triangle = triangles[j];
30219
+ if (ray.intersectTriangle(triangle, intersectPoint, backfaceCulling)) {
30220
+ success = true;
30221
+ hitPositions.push(intersectPoint);
30222
+ break;
30223
+ }
30224
+ }
30225
+ }
30226
+ else if (hitParams.type === HitTestType.box) {
30227
+ var center = hitParams.center, size = hitParams.size;
30228
+ var boxMin = center.clone().addScaledVector(size, 0.5);
30229
+ var boxMax = center.clone().addScaledVector(size, -0.5);
30230
+ if (ray.intersectBox({ min: boxMin, max: boxMax }, intersectPoint)) {
30231
+ success = true;
30232
+ hitPositions.push(intersectPoint);
30233
+ }
30234
+ }
30235
+ else if (hitParams.type === HitTestType.sphere) {
30236
+ var center = hitParams.center, radius = hitParams.radius;
30237
+ if (ray.intersectSphere({ center: center, radius: radius }, intersectPoint)) {
30238
+ success = true;
30239
+ hitPositions.push(intersectPoint);
30240
+ }
30241
+ }
30242
+ else if (hitParams.type === HitTestType.custom) {
30243
+ var tempPosition = hitParams.collect(ray, new Vector2(x, y));
30244
+ if (tempPosition && tempPosition.length > 0) {
30245
+ tempPosition.forEach(function (pos) {
30246
+ hitPositions.push(pos);
30247
+ });
30248
+ success = true;
30249
+ }
30250
+ }
30251
+ if (success) {
30252
+ var region = {
30253
+ compContent: this,
30254
+ id: item.id,
30255
+ name: item.name,
30256
+ position: hitPositions[hitPositions.length - 1],
30257
+ parentId: item.parentId,
30258
+ hitPositions: hitPositions,
30259
+ behavior: hitParams.behavior,
30260
+ };
30261
+ regions.push(region);
30262
+ if (stop(region)) {
30263
+ return regions;
30264
+ }
30265
+ }
30266
+ }
30267
+ }
30268
+ }
30269
+ return regions;
30270
+ };
30187
30271
  CompVFXItem.prototype.isEnded = function (now) {
30188
30272
  return now >= this.durInms;
30189
30273
  };
@@ -30647,7 +30731,7 @@ var Composition = /** @class */ (function () {
30647
30731
  this.pluginSystem.plugins.forEach(func);
30648
30732
  };
30649
30733
  /**
30650
- *
30734
+ * 获取指定位置和相机连成的射线
30651
30735
  * @param x
30652
30736
  * @param y
30653
30737
  * @returns
@@ -30675,73 +30759,12 @@ var Composition = /** @class */ (function () {
30675
30759
  if (this.isDestroyed) {
30676
30760
  return [];
30677
30761
  }
30678
- var hitPositions = [];
30679
30762
  var regions = [];
30680
- var _a = this.renderFrame.editorTransform, a = _a.x, b = _a.y, c = _a.z, d = _a.w;
30681
- var ray = setRayFromCamera((x - c) / a, (y - d) / b, this.camera);
30682
- var stop = (options === null || options === void 0 ? void 0 : options.stop) || noop;
30683
- var skip = (options === null || options === void 0 ? void 0 : options.skip) || noop;
30684
- var maxCount = (options === null || options === void 0 ? void 0 : options.maxCount) || this.items.length;
30685
- for (var i = 0; i < this.items.length && regions.length < maxCount; i++) {
30686
- var item = this.items[i];
30687
- if (item.lifetime >= 0 && item.lifetime <= 1 && !skip(item)) {
30688
- var hitParams = item.getHitTestParams(force);
30689
- if (hitParams) {
30690
- var success = false;
30691
- var intersectPoint = new Vector3();
30692
- if (hitParams.type === HitTestType.triangle) {
30693
- var triangles = hitParams.triangles, backfaceCulling = hitParams.backfaceCulling;
30694
- for (var j = 0; j < triangles.length; j++) {
30695
- var triangle = triangles[j];
30696
- if (ray.intersectTriangle(triangle, intersectPoint, backfaceCulling)) {
30697
- success = true;
30698
- hitPositions.push(intersectPoint);
30699
- break;
30700
- }
30701
- }
30702
- }
30703
- else if (hitParams.type === HitTestType.box) {
30704
- var center = hitParams.center, size = hitParams.size;
30705
- var boxMin = center.clone().addScaledVector(size, 0.5);
30706
- var boxMax = center.clone().addScaledVector(size, -0.5);
30707
- if (ray.intersectBox({ min: boxMin, max: boxMax }, intersectPoint)) {
30708
- success = true;
30709
- hitPositions.push(intersectPoint);
30710
- }
30711
- }
30712
- else if (hitParams.type === HitTestType.sphere) {
30713
- var center = hitParams.center, radius = hitParams.radius;
30714
- if (ray.intersectSphere({ center: center, radius: radius }, intersectPoint)) {
30715
- success = true;
30716
- hitPositions.push(intersectPoint);
30717
- }
30718
- }
30719
- else if (hitParams.type === HitTestType.custom) {
30720
- var tempPosition = hitParams.collect(ray, new Vector2(x, y));
30721
- if (tempPosition && tempPosition.length > 0) {
30722
- tempPosition.forEach(function (pos) {
30723
- hitPositions.push(pos);
30724
- });
30725
- success = true;
30726
- }
30727
- }
30728
- if (success) {
30729
- var region = {
30730
- id: item.id,
30731
- name: item.name,
30732
- position: hitPositions[hitPositions.length - 1],
30733
- parentId: item.parentId,
30734
- hitPositions: hitPositions,
30735
- behavior: hitParams.behavior,
30736
- };
30737
- regions.push(region);
30738
- if (stop(region)) {
30739
- return regions;
30740
- }
30741
- }
30742
- }
30743
- }
30744
- }
30763
+ var ray = this.getHitTestRay(x, y);
30764
+ this.content.hitTest(ray, x, y, regions, force, options);
30765
+ this.refContent.forEach(function (ref) {
30766
+ ref.hitTest(ray, x, y, regions, force, options);
30767
+ });
30745
30768
  return regions;
30746
30769
  };
30747
30770
  /**
@@ -30901,23 +30924,41 @@ var Composition = /** @class */ (function () {
30901
30924
  this.content.translateByPixel(x, y);
30902
30925
  };
30903
30926
  /**
30904
- * 设置合成在 3D 坐标轴上相对移动
30927
+ * 设置合成在 3D 坐标轴上相对当前的位移
30905
30928
  */
30906
30929
  Composition.prototype.translate = function (x, y, z) {
30907
30930
  this.content.translate(x, y, z);
30908
30931
  };
30909
30932
  /**
30910
- * 设置合成在 3D 坐标轴上相对旋转(角度)
30933
+ * 设置合成在 3D 坐标轴上相对原点的位移
30934
+ */
30935
+ Composition.prototype.setPosition = function (x, y, z) {
30936
+ this.content.setPosition(x, y, z);
30937
+ };
30938
+ /**
30939
+ * 设置合成在 3D 坐标轴上相对当前的旋转(角度)
30911
30940
  */
30912
30941
  Composition.prototype.rotate = function (x, y, z) {
30913
30942
  this.content.rotate(x, y, z);
30914
30943
  };
30915
30944
  /**
30916
- * 设置合成在 3D 坐标轴上相对缩放
30945
+ * 设置合成在 3D 坐标轴上的相对原点的旋转(角度)
30946
+ */
30947
+ Composition.prototype.setRotation = function (x, y, z) {
30948
+ this.content.setRotation(x, y, z);
30949
+ };
30950
+ /**
30951
+ * 设置合成在 3D 坐标轴上相对当前的缩放
30917
30952
  */
30918
30953
  Composition.prototype.scale = function (x, y, z) {
30919
30954
  this.content.scale(x, y, z);
30920
30955
  };
30956
+ /**
30957
+ * 设置合成在 3D 坐标轴上的缩放
30958
+ */
30959
+ Composition.prototype.setScale = function (x, y, z) {
30960
+ this.content.setScale(x, y, z);
30961
+ };
30921
30962
  /**
30922
30963
  * 卸载贴图纹理方法,减少内存
30923
30964
  */
@@ -32515,7 +32556,7 @@ var ThreeMesh = /** @class */ (function (_super) {
32515
32556
  * @param val - 可见性开关
32516
32557
  */
32517
32558
  ThreeMesh.prototype.setVisible = function (val) {
32518
- this.mesh.visible = !val;
32559
+ this.mesh.visible = val;
32519
32560
  };
32520
32561
  /**
32521
32562
  * 获取 mesh 的可见性
@@ -32523,7 +32564,7 @@ var ThreeMesh = /** @class */ (function (_super) {
32523
32564
  * @returns
32524
32565
  */
32525
32566
  ThreeMesh.prototype.getVisible = function () {
32526
- return !this.mesh.visible;
32567
+ return this.mesh.visible;
32527
32568
  };
32528
32569
  /**
32529
32570
  * 获取 mesh 中的首个 geometry
@@ -32712,9 +32753,9 @@ Geometry.create = function (engine, options) {
32712
32753
  Mesh.create = function (engine, props) {
32713
32754
  return new ThreeMesh(engine, props);
32714
32755
  };
32715
- var version = "1.1.0-alpha.0";
32756
+ var version = "1.1.0-alpha.2";
32716
32757
  console.info({
32717
- content: '[Galacean Effects THREEJS] version: ' + "1.1.0-alpha.0",
32758
+ content: '[Galacean Effects THREEJS] version: ' + "1.1.0-alpha.2",
32718
32759
  type: LOG_TYPE,
32719
32760
  });
32720
32761