@galacean/effects-threejs 2.8.0 → 2.8.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 threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.8.0
6
+ * Version: v2.8.2
7
7
  */
8
8
 
9
9
  'use strict';
@@ -13372,22 +13372,34 @@ function _loadVideo() {
13372
13372
  return [
13373
13373
  2,
13374
13374
  new Promise(function(resolve, reject) {
13375
- var handleCanPlay = function() {
13375
+ var settled = false;
13376
+ var handleSuccess = function() {
13377
+ if (settled) {
13378
+ return;
13379
+ }
13380
+ settled = true;
13381
+ cleanup();
13376
13382
  resolve(video);
13377
- video.removeEventListener("error", handleError);
13378
13383
  };
13379
- var handleError = function(e) {
13380
- video.removeEventListener("canplay", handleCanPlay);
13384
+ var handleError = function() {
13385
+ if (settled) {
13386
+ return;
13387
+ }
13388
+ settled = true;
13389
+ cleanup();
13381
13390
  reject("Load video fail.");
13382
13391
  };
13383
- video.addEventListener("canplay", handleCanPlay, {
13384
- once: true
13385
- });
13386
- video.addEventListener("error", handleError, {
13387
- once: true
13392
+ var cleanup = function() {
13393
+ video.removeEventListener("loadeddata", handleSuccess);
13394
+ video.removeEventListener("canplay", handleSuccess);
13395
+ video.removeEventListener("error", handleError);
13396
+ };
13397
+ video.addEventListener("loadeddata", handleSuccess);
13398
+ video.addEventListener("canplay", handleSuccess);
13399
+ video.addEventListener("error", handleError);
13400
+ video.play().catch(function(err) {
13401
+ console.warn("Autoplay blocked:", err);
13388
13402
  });
13389
- // 显式触发视频加载
13390
- video.load();
13391
13403
  })
13392
13404
  ];
13393
13405
  });
@@ -16689,10 +16701,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
16689
16701
  }
16690
16702
  var regions = [];
16691
16703
  var ray = this.getHitTestRay(x, y);
16692
- this.refContent.forEach(function(ref) {
16693
- var _ref_getComponent;
16694
- (_ref_getComponent = ref.getComponent(exports.CompositionComponent)) == null ? void 0 : _ref_getComponent.hitTest(ray, x, y, regions, force, options);
16695
- });
16704
+ this.rootComposition.hitTest(ray, x, y, regions, force, options);
16696
16705
  return regions;
16697
16706
  };
16698
16707
  /**
@@ -17769,10 +17778,32 @@ exports.CompositionComponent = /*#__PURE__*/ function(Component) {
17769
17778
  });
17770
17779
  };
17771
17780
  _proto.hitTest = function hitTest(ray, x, y, regions, force, options) {
17772
- var _this, _loop = function(i) {
17773
- var item = _this.items[i];
17774
- if (item.isActive && item.transform.getValid() && !exports.VFXItem.isComposition(item) && !skip(item)) {
17775
- var hitParams = item.getHitTestParams(force);
17781
+ var _this_item_composition;
17782
+ var isHitTestSuccess = this.hitTestRecursive(this.item, ray, x, y, regions, force, options);
17783
+ // 子元素碰撞测试成功加入当前预合成元素,判断是否是合成根元素,根元素不加入
17784
+ if (isHitTestSuccess && this.item !== ((_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.rootItem)) {
17785
+ var item = this.item;
17786
+ var lastRegion = regions[regions.length - 1];
17787
+ var hitPositions = lastRegion.hitPositions;
17788
+ var region = {
17789
+ id: item.getInstanceId(),
17790
+ name: item.name,
17791
+ position: hitPositions[hitPositions.length - 1],
17792
+ parentId: item.parentId,
17793
+ hitPositions: hitPositions,
17794
+ behavior: InteractBehavior.NONE,
17795
+ item: item,
17796
+ composition: item.composition
17797
+ };
17798
+ regions.push(region);
17799
+ }
17800
+ return isHitTestSuccess;
17801
+ };
17802
+ _proto.hitTestRecursive = function hitTestRecursive(item, ray, x, y, regions, force, options) {
17803
+ var _this, _loop = function() {
17804
+ var hitTestItem = _step.value;
17805
+ if (hitTestItem.isActive && hitTestItem.transform.getValid() && !skip(hitTestItem)) {
17806
+ var hitParams = hitTestItem.getHitTestParams(force);
17776
17807
  if (hitParams) {
17777
17808
  var success = false;
17778
17809
  var intersectPoint = new Vector3();
@@ -17817,35 +17848,48 @@ exports.CompositionComponent = /*#__PURE__*/ function(Component) {
17817
17848
  }
17818
17849
  if (success) {
17819
17850
  var region = {
17820
- compContent: _this.item,
17821
- id: item.getInstanceId(),
17822
- name: item.name,
17851
+ id: hitTestItem.getInstanceId(),
17852
+ name: hitTestItem.name,
17823
17853
  position: hitPositions[hitPositions.length - 1],
17824
- parentId: item.parentId,
17854
+ parentId: hitTestItem.parentId,
17825
17855
  hitPositions: hitPositions,
17826
17856
  behavior: hitParams.behavior,
17827
- item: item,
17857
+ item: hitTestItem,
17828
17858
  composition: _this.item.composition
17829
17859
  };
17830
17860
  regions.push(region);
17861
+ hitTestSuccess = true;
17831
17862
  if (stop(region)) {
17832
17863
  return {
17833
- v: regions
17864
+ v: true
17834
17865
  };
17835
17866
  }
17836
17867
  }
17837
17868
  }
17869
+ if (exports.VFXItem.isComposition(hitTestItem)) {
17870
+ if (hitTestItem.getComponent(CompositionComponent).hitTest(ray, x, y, regions, force, options)) {
17871
+ hitTestSuccess = true;
17872
+ }
17873
+ } else {
17874
+ if (_this.hitTestRecursive(hitTestItem, ray, x, y, regions, force, options)) {
17875
+ hitTestSuccess = true;
17876
+ }
17877
+ }
17838
17878
  }
17839
17879
  };
17840
17880
  var hitPositions = [];
17841
17881
  var stop = (options == null ? void 0 : options.stop) || noop;
17842
17882
  var skip = (options == null ? void 0 : options.skip) || noop;
17843
- var maxCount = (options == null ? void 0 : options.maxCount) || this.items.length;
17844
- for(var i = 0; i < this.items.length && regions.length < maxCount; i++){
17845
- var _ret = (_this = this, _loop(i));
17883
+ var maxCount = options == null ? void 0 : options.maxCount;
17884
+ if (maxCount !== undefined && regions.length >= maxCount) {
17885
+ return false;
17886
+ }
17887
+ var hitTestSuccess = false;
17888
+ for(var _iterator = _create_for_of_iterator_helper_loose(item.children), _step; !(_step = _iterator()).done;){
17889
+ var _ret = (_this = this, _loop());
17846
17890
  if (_type_of(_ret) === "object") return _ret.v;
17847
17891
  }
17848
- return regions;
17892
+ return hitTestSuccess;
17849
17893
  };
17850
17894
  /**
17851
17895
  * 设置当前合成子元素的渲染顺序
@@ -29417,14 +29461,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29417
29461
  this.isDirty = true;
29418
29462
  };
29419
29463
  _proto.setFontSize = function setFontSize(value) {
29420
- if (this.textStyle.fontSize === value) {
29464
+ var size = Math.max(1, Number(value) || 1);
29465
+ if (this.textStyle.fontSize === size) {
29421
29466
  return;
29422
29467
  }
29423
- // 保证字号变化后位置正常
29424
- var diff = this.textStyle.fontSize - value;
29425
- var layout = this.textLayout;
29426
- layout.lineHeight += diff;
29427
- this.textStyle.fontSize = value;
29468
+ this.textStyle.fontSize = size;
29428
29469
  this.isDirty = true;
29429
29470
  };
29430
29471
  _proto.setOutlineWidth = function setOutlineWidth(value) {
@@ -31518,7 +31559,7 @@ function getStandardSpriteContent(sprite, transform) {
31518
31559
  return ret;
31519
31560
  }
31520
31561
 
31521
- var version$2 = "2.8.0";
31562
+ var version$2 = "2.8.2";
31522
31563
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
31523
31564
  var standardVersion = /^(\d+)\.(\d+)$/;
31524
31565
  var reverseParticle = false;
@@ -32863,7 +32904,7 @@ function _createTextureOptionsBySource() {
32863
32904
  scene.jsonScene.items.forEach(function(item) {
32864
32905
  if (item.type === ItemType.text || item.type === ItemType.richtext) {
32865
32906
  var textVariable = variables[item.name];
32866
- if (!textVariable) {
32907
+ if (textVariable === undefined || textVariable === null) {
32867
32908
  return;
32868
32909
  }
32869
32910
  item.components.forEach(function(param) {
@@ -35218,7 +35259,7 @@ registerPlugin("text", TextLoader);
35218
35259
  registerPlugin("sprite", SpriteLoader);
35219
35260
  registerPlugin("particle", ParticleLoader);
35220
35261
  registerPlugin("interact", InteractLoader);
35221
- var version$1 = "2.8.0";
35262
+ var version$1 = "2.8.2";
35222
35263
  logger.info("Core version: " + version$1 + ".");
35223
35264
 
35224
35265
  var _obj;
@@ -36795,7 +36836,7 @@ applyMixins(exports.ThreeTextComponent, [
36795
36836
  */ Mesh.create = function(engine, props) {
36796
36837
  return new ThreeMesh(engine, props);
36797
36838
  };
36798
- var version = "2.8.0";
36839
+ var version = "2.8.2";
36799
36840
  logger.info("THREEJS plugin version: " + version + ".");
36800
36841
 
36801
36842
  exports.ActivationMixerPlayable = ActivationMixerPlayable;