@galacean/effects-core 2.8.1 → 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/components/composition-component.d.ts +3 -2
- package/dist/index.js +80 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Ray } from '@galacean/effects-math/es/core/ray';
|
|
2
|
-
import
|
|
2
|
+
import * as spec from '@galacean/effects-specification';
|
|
3
3
|
import type { CompositionHitTestOptions } from '../composition';
|
|
4
4
|
import type { Region, TrackAsset } from '../plugins';
|
|
5
5
|
import { VFXItem } from '../vfx-item';
|
|
@@ -30,6 +30,7 @@ export declare class CompositionComponent extends Component {
|
|
|
30
30
|
onEnable(): void;
|
|
31
31
|
onDisable(): void;
|
|
32
32
|
onDestroy(): void;
|
|
33
|
-
hitTest(ray: Ray, x: number, y: number, regions: Region[], force?: boolean, options?: CompositionHitTestOptions):
|
|
33
|
+
hitTest(ray: Ray, x: number, y: number, regions: Region[], force?: boolean, options?: CompositionHitTestOptions): boolean;
|
|
34
|
+
private hitTestRecursive;
|
|
34
35
|
fromData(data: any): void;
|
|
35
36
|
}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.8.
|
|
6
|
+
* Version: v2.8.2
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -13350,22 +13350,34 @@ function _loadVideo() {
|
|
|
13350
13350
|
return [
|
|
13351
13351
|
2,
|
|
13352
13352
|
new Promise(function(resolve, reject) {
|
|
13353
|
-
var
|
|
13353
|
+
var settled = false;
|
|
13354
|
+
var handleSuccess = function() {
|
|
13355
|
+
if (settled) {
|
|
13356
|
+
return;
|
|
13357
|
+
}
|
|
13358
|
+
settled = true;
|
|
13359
|
+
cleanup();
|
|
13354
13360
|
resolve(video);
|
|
13355
|
-
video.removeEventListener("error", handleError);
|
|
13356
13361
|
};
|
|
13357
|
-
var handleError = function(
|
|
13358
|
-
|
|
13362
|
+
var handleError = function() {
|
|
13363
|
+
if (settled) {
|
|
13364
|
+
return;
|
|
13365
|
+
}
|
|
13366
|
+
settled = true;
|
|
13367
|
+
cleanup();
|
|
13359
13368
|
reject("Load video fail.");
|
|
13360
13369
|
};
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13370
|
+
var cleanup = function() {
|
|
13371
|
+
video.removeEventListener("loadeddata", handleSuccess);
|
|
13372
|
+
video.removeEventListener("canplay", handleSuccess);
|
|
13373
|
+
video.removeEventListener("error", handleError);
|
|
13374
|
+
};
|
|
13375
|
+
video.addEventListener("loadeddata", handleSuccess);
|
|
13376
|
+
video.addEventListener("canplay", handleSuccess);
|
|
13377
|
+
video.addEventListener("error", handleError);
|
|
13378
|
+
video.play().catch(function(err) {
|
|
13379
|
+
console.warn("Autoplay blocked:", err);
|
|
13366
13380
|
});
|
|
13367
|
-
// 显式触发视频加载
|
|
13368
|
-
video.load();
|
|
13369
13381
|
})
|
|
13370
13382
|
];
|
|
13371
13383
|
});
|
|
@@ -16667,10 +16679,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
16667
16679
|
}
|
|
16668
16680
|
var regions = [];
|
|
16669
16681
|
var ray = this.getHitTestRay(x, y);
|
|
16670
|
-
this.
|
|
16671
|
-
var _ref_getComponent;
|
|
16672
|
-
(_ref_getComponent = ref.getComponent(exports.CompositionComponent)) == null ? void 0 : _ref_getComponent.hitTest(ray, x, y, regions, force, options);
|
|
16673
|
-
});
|
|
16682
|
+
this.rootComposition.hitTest(ray, x, y, regions, force, options);
|
|
16674
16683
|
return regions;
|
|
16675
16684
|
};
|
|
16676
16685
|
/**
|
|
@@ -17747,10 +17756,32 @@ exports.CompositionComponent = /*#__PURE__*/ function(Component) {
|
|
|
17747
17756
|
});
|
|
17748
17757
|
};
|
|
17749
17758
|
_proto.hitTest = function hitTest(ray, x, y, regions, force, options) {
|
|
17750
|
-
var
|
|
17751
|
-
|
|
17752
|
-
|
|
17753
|
-
|
|
17759
|
+
var _this_item_composition;
|
|
17760
|
+
var isHitTestSuccess = this.hitTestRecursive(this.item, ray, x, y, regions, force, options);
|
|
17761
|
+
// 子元素碰撞测试成功加入当前预合成元素,判断是否是合成根元素,根元素不加入
|
|
17762
|
+
if (isHitTestSuccess && this.item !== ((_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.rootItem)) {
|
|
17763
|
+
var item = this.item;
|
|
17764
|
+
var lastRegion = regions[regions.length - 1];
|
|
17765
|
+
var hitPositions = lastRegion.hitPositions;
|
|
17766
|
+
var region = {
|
|
17767
|
+
id: item.getInstanceId(),
|
|
17768
|
+
name: item.name,
|
|
17769
|
+
position: hitPositions[hitPositions.length - 1],
|
|
17770
|
+
parentId: item.parentId,
|
|
17771
|
+
hitPositions: hitPositions,
|
|
17772
|
+
behavior: InteractBehavior.NONE,
|
|
17773
|
+
item: item,
|
|
17774
|
+
composition: item.composition
|
|
17775
|
+
};
|
|
17776
|
+
regions.push(region);
|
|
17777
|
+
}
|
|
17778
|
+
return isHitTestSuccess;
|
|
17779
|
+
};
|
|
17780
|
+
_proto.hitTestRecursive = function hitTestRecursive(item, ray, x, y, regions, force, options) {
|
|
17781
|
+
var _this, _loop = function() {
|
|
17782
|
+
var hitTestItem = _step.value;
|
|
17783
|
+
if (hitTestItem.isActive && hitTestItem.transform.getValid() && !skip(hitTestItem)) {
|
|
17784
|
+
var hitParams = hitTestItem.getHitTestParams(force);
|
|
17754
17785
|
if (hitParams) {
|
|
17755
17786
|
var success = false;
|
|
17756
17787
|
var intersectPoint = new Vector3();
|
|
@@ -17795,35 +17826,48 @@ exports.CompositionComponent = /*#__PURE__*/ function(Component) {
|
|
|
17795
17826
|
}
|
|
17796
17827
|
if (success) {
|
|
17797
17828
|
var region = {
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
name: item.name,
|
|
17829
|
+
id: hitTestItem.getInstanceId(),
|
|
17830
|
+
name: hitTestItem.name,
|
|
17801
17831
|
position: hitPositions[hitPositions.length - 1],
|
|
17802
|
-
parentId:
|
|
17832
|
+
parentId: hitTestItem.parentId,
|
|
17803
17833
|
hitPositions: hitPositions,
|
|
17804
17834
|
behavior: hitParams.behavior,
|
|
17805
|
-
item:
|
|
17835
|
+
item: hitTestItem,
|
|
17806
17836
|
composition: _this.item.composition
|
|
17807
17837
|
};
|
|
17808
17838
|
regions.push(region);
|
|
17839
|
+
hitTestSuccess = true;
|
|
17809
17840
|
if (stop(region)) {
|
|
17810
17841
|
return {
|
|
17811
|
-
v:
|
|
17842
|
+
v: true
|
|
17812
17843
|
};
|
|
17813
17844
|
}
|
|
17814
17845
|
}
|
|
17815
17846
|
}
|
|
17847
|
+
if (exports.VFXItem.isComposition(hitTestItem)) {
|
|
17848
|
+
if (hitTestItem.getComponent(CompositionComponent).hitTest(ray, x, y, regions, force, options)) {
|
|
17849
|
+
hitTestSuccess = true;
|
|
17850
|
+
}
|
|
17851
|
+
} else {
|
|
17852
|
+
if (_this.hitTestRecursive(hitTestItem, ray, x, y, regions, force, options)) {
|
|
17853
|
+
hitTestSuccess = true;
|
|
17854
|
+
}
|
|
17855
|
+
}
|
|
17816
17856
|
}
|
|
17817
17857
|
};
|
|
17818
17858
|
var hitPositions = [];
|
|
17819
17859
|
var stop = (options == null ? void 0 : options.stop) || noop;
|
|
17820
17860
|
var skip = (options == null ? void 0 : options.skip) || noop;
|
|
17821
|
-
var maxCount =
|
|
17822
|
-
|
|
17823
|
-
|
|
17861
|
+
var maxCount = options == null ? void 0 : options.maxCount;
|
|
17862
|
+
if (maxCount !== undefined && regions.length >= maxCount) {
|
|
17863
|
+
return false;
|
|
17864
|
+
}
|
|
17865
|
+
var hitTestSuccess = false;
|
|
17866
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(item.children), _step; !(_step = _iterator()).done;){
|
|
17867
|
+
var _ret = (_this = this, _loop());
|
|
17824
17868
|
if (_type_of(_ret) === "object") return _ret.v;
|
|
17825
17869
|
}
|
|
17826
|
-
return
|
|
17870
|
+
return hitTestSuccess;
|
|
17827
17871
|
};
|
|
17828
17872
|
/**
|
|
17829
17873
|
* 设置当前合成子元素的渲染顺序
|
|
@@ -29395,14 +29439,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29395
29439
|
this.isDirty = true;
|
|
29396
29440
|
};
|
|
29397
29441
|
_proto.setFontSize = function setFontSize(value) {
|
|
29398
|
-
|
|
29442
|
+
var size = Math.max(1, Number(value) || 1);
|
|
29443
|
+
if (this.textStyle.fontSize === size) {
|
|
29399
29444
|
return;
|
|
29400
29445
|
}
|
|
29401
|
-
|
|
29402
|
-
var diff = this.textStyle.fontSize - value;
|
|
29403
|
-
var layout = this.textLayout;
|
|
29404
|
-
layout.lineHeight += diff;
|
|
29405
|
-
this.textStyle.fontSize = value;
|
|
29446
|
+
this.textStyle.fontSize = size;
|
|
29406
29447
|
this.isDirty = true;
|
|
29407
29448
|
};
|
|
29408
29449
|
_proto.setOutlineWidth = function setOutlineWidth(value) {
|
|
@@ -31496,7 +31537,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
31496
31537
|
return ret;
|
|
31497
31538
|
}
|
|
31498
31539
|
|
|
31499
|
-
var version$1 = "2.8.
|
|
31540
|
+
var version$1 = "2.8.2";
|
|
31500
31541
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
31501
31542
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
31502
31543
|
var reverseParticle = false;
|
|
@@ -32841,7 +32882,7 @@ function _createTextureOptionsBySource() {
|
|
|
32841
32882
|
scene.jsonScene.items.forEach(function(item) {
|
|
32842
32883
|
if (item.type === ItemType.text || item.type === ItemType.richtext) {
|
|
32843
32884
|
var textVariable = variables[item.name];
|
|
32844
|
-
if (
|
|
32885
|
+
if (textVariable === undefined || textVariable === null) {
|
|
32845
32886
|
return;
|
|
32846
32887
|
}
|
|
32847
32888
|
item.components.forEach(function(param) {
|
|
@@ -35196,7 +35237,7 @@ registerPlugin("text", TextLoader);
|
|
|
35196
35237
|
registerPlugin("sprite", SpriteLoader);
|
|
35197
35238
|
registerPlugin("particle", ParticleLoader);
|
|
35198
35239
|
registerPlugin("interact", InteractLoader);
|
|
35199
|
-
var version = "2.8.
|
|
35240
|
+
var version = "2.8.2";
|
|
35200
35241
|
logger.info("Core version: " + version + ".");
|
|
35201
35242
|
|
|
35202
35243
|
exports.ActivationMixerPlayable = ActivationMixerPlayable;
|