@galacean/effects-core 1.5.2 → 1.6.0-beta.1
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/composition.d.ts +23 -1
- package/dist/index.js +74 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -22
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/interact/click-handler.d.ts +1 -1
- package/dist/plugins/interact/interact-vfx-item.d.ts +17 -5
- package/dist/scene.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.mjs
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: v1.
|
|
6
|
+
* Version: v1.6.0-beta.1
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
@@ -10069,10 +10069,23 @@ var EventSystem = /** @class */ (function () {
|
|
|
10069
10069
|
var getTouchEventValue = function (event, x, y, dx, dy) {
|
|
10070
10070
|
if (dx === void 0) { dx = 0; }
|
|
10071
10071
|
if (dy === void 0) { dy = 0; }
|
|
10072
|
-
var _a = _this.target, width = _a.width, height = _a.height;
|
|
10073
|
-
var ts = performance.now();
|
|
10074
10072
|
var vx = 0;
|
|
10075
10073
|
var vy = 0;
|
|
10074
|
+
var ts = performance.now();
|
|
10075
|
+
if (!_this.target) {
|
|
10076
|
+
logger.error('Trigger TouchEvent after EventSystem is disposed');
|
|
10077
|
+
return {
|
|
10078
|
+
x: x,
|
|
10079
|
+
y: y,
|
|
10080
|
+
vx: 0,
|
|
10081
|
+
vy: vy,
|
|
10082
|
+
dx: dx,
|
|
10083
|
+
dy: dy,
|
|
10084
|
+
ts: ts,
|
|
10085
|
+
width: 0, height: 0, origin: event,
|
|
10086
|
+
};
|
|
10087
|
+
}
|
|
10088
|
+
var _a = _this.target, width = _a.width, height = _a.height;
|
|
10076
10089
|
if (lastTouch) {
|
|
10077
10090
|
var dt = ts - lastTouch.ts;
|
|
10078
10091
|
vx = ((dx - lastTouch.dx) / dt) || 0;
|
|
@@ -13503,6 +13516,14 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13503
13516
|
function InteractVFXItem(props, composition) {
|
|
13504
13517
|
var _a;
|
|
13505
13518
|
var _this = _super.call(this, props, composition) || this;
|
|
13519
|
+
/**
|
|
13520
|
+
* 拖拽的惯性衰减系数,范围[0, 1], 越大惯性越强
|
|
13521
|
+
*/
|
|
13522
|
+
_this.downgrade = 0.95;
|
|
13523
|
+
/**
|
|
13524
|
+
* 拖拽的距离映射系数,越大越容易拖动
|
|
13525
|
+
*/
|
|
13526
|
+
_this.dragRatio = [1, 1];
|
|
13506
13527
|
_this.engine = (_a = _this.composition) === null || _a === void 0 ? void 0 : _a.getEngine();
|
|
13507
13528
|
return _this;
|
|
13508
13529
|
}
|
|
@@ -13513,8 +13534,23 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13513
13534
|
enumerable: false,
|
|
13514
13535
|
configurable: true
|
|
13515
13536
|
});
|
|
13537
|
+
Object.defineProperty(InteractVFXItem.prototype, "enable", {
|
|
13538
|
+
get: function () {
|
|
13539
|
+
return this.enabled;
|
|
13540
|
+
},
|
|
13541
|
+
set: function (enable) {
|
|
13542
|
+
this.enabled = enable;
|
|
13543
|
+
if (!enable) {
|
|
13544
|
+
// 立刻停止惯性滑动
|
|
13545
|
+
this.bouncingArg = null;
|
|
13546
|
+
}
|
|
13547
|
+
},
|
|
13548
|
+
enumerable: false,
|
|
13549
|
+
configurable: true
|
|
13550
|
+
});
|
|
13516
13551
|
InteractVFXItem.prototype.onConstructed = function (options) {
|
|
13517
13552
|
this.ui = options.content;
|
|
13553
|
+
this.enabled = true;
|
|
13518
13554
|
};
|
|
13519
13555
|
InteractVFXItem.prototype.onLifetimeBegin = function (composition) {
|
|
13520
13556
|
var _a, _b, _c;
|
|
@@ -13533,9 +13569,8 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13533
13569
|
if (!this.dragEvent || !this.bouncingArg) {
|
|
13534
13570
|
return;
|
|
13535
13571
|
}
|
|
13536
|
-
|
|
13537
|
-
this.bouncingArg.
|
|
13538
|
-
this.bouncingArg.vy *= downgrade;
|
|
13572
|
+
this.bouncingArg.vx *= this.downgrade;
|
|
13573
|
+
this.bouncingArg.vy *= this.downgrade;
|
|
13539
13574
|
this.bouncingArg.dy += this.bouncingArg.vy;
|
|
13540
13575
|
this.bouncingArg.dx += this.bouncingArg.vx;
|
|
13541
13576
|
if (shouldIgnoreBouncing(this.bouncingArg)) {
|
|
@@ -13571,7 +13606,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13571
13606
|
};
|
|
13572
13607
|
};
|
|
13573
13608
|
InteractVFXItem.prototype.getHitTestParams = function () {
|
|
13574
|
-
if (!this.clickable) {
|
|
13609
|
+
if (!this.clickable || !this.canInteract()) {
|
|
13575
13610
|
return;
|
|
13576
13611
|
}
|
|
13577
13612
|
var behavior = this.ui.options.behavior;
|
|
@@ -13608,6 +13643,9 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13608
13643
|
var handlerMap = {
|
|
13609
13644
|
touchstart: function (event) {
|
|
13610
13645
|
var _a;
|
|
13646
|
+
if (!_this.canInteract()) {
|
|
13647
|
+
return;
|
|
13648
|
+
}
|
|
13611
13649
|
_this.dragEvent = null;
|
|
13612
13650
|
_this.bouncingArg = null;
|
|
13613
13651
|
var camera = (_a = _this.composition) === null || _a === void 0 ? void 0 : _a.camera;
|
|
@@ -13625,6 +13663,9 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13625
13663
|
_this.bouncingArg = event;
|
|
13626
13664
|
},
|
|
13627
13665
|
touchend: function (event) {
|
|
13666
|
+
if (!_this.canInteract()) {
|
|
13667
|
+
return;
|
|
13668
|
+
}
|
|
13628
13669
|
var bouncingArg = _this.bouncingArg;
|
|
13629
13670
|
if (!shouldIgnoreBouncing(bouncingArg, 3) && bouncingArg) {
|
|
13630
13671
|
var speed = 5;
|
|
@@ -13650,7 +13691,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13650
13691
|
};
|
|
13651
13692
|
InteractVFXItem.prototype.handleDragMove = function (evt, event) {
|
|
13652
13693
|
var _a, _b;
|
|
13653
|
-
if (!(evt
|
|
13694
|
+
if (!(evt === null || evt === void 0 ? void 0 : evt.cameraParam) || !this.canInteract() || !this.composition) {
|
|
13654
13695
|
return;
|
|
13655
13696
|
}
|
|
13656
13697
|
var options = this.ui.options;
|
|
@@ -13661,8 +13702,8 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13661
13702
|
var sp = Math.tan(fov * Math.PI / 180 / 2) * Math.abs(depth);
|
|
13662
13703
|
var height = dy * sp;
|
|
13663
13704
|
var width = dx * sp;
|
|
13664
|
-
var nx = position[0] - width;
|
|
13665
|
-
var ny = position[1] - height;
|
|
13705
|
+
var nx = position[0] - this.dragRatio[0] * width;
|
|
13706
|
+
var ny = position[1] - this.dragRatio[1] * height;
|
|
13666
13707
|
if (options.dxRange) {
|
|
13667
13708
|
var _d = __read$3(options.dxRange, 2), min = _d[0], max = _d[1];
|
|
13668
13709
|
nx = clamp$1(nx, min, max);
|
|
@@ -13679,6 +13720,10 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13679
13720
|
}
|
|
13680
13721
|
this.composition.camera.position = new Vector3(nx, ny, depth);
|
|
13681
13722
|
};
|
|
13723
|
+
InteractVFXItem.prototype.canInteract = function () {
|
|
13724
|
+
var _a;
|
|
13725
|
+
return Boolean((_a = this.composition) === null || _a === void 0 ? void 0 : _a.interactive) && this.enabled;
|
|
13726
|
+
};
|
|
13682
13727
|
return InteractVFXItem;
|
|
13683
13728
|
}(VFXItem));
|
|
13684
13729
|
function shouldIgnoreBouncing(arg, mul) {
|
|
@@ -23984,27 +24029,28 @@ var AssetManager = /** @class */ (function () {
|
|
|
23984
24029
|
AssetManager.prototype.loadScene = function (url, renderer, options) {
|
|
23985
24030
|
var _a, _b, _c;
|
|
23986
24031
|
return __awaiter(this, void 0, void 0, function () {
|
|
23987
|
-
var rawJSON, assetUrl, startTime,
|
|
24032
|
+
var rawJSON, assetUrl, startTime, timeInfoMessages, gpuInstance, asyncShaderCompile, compressedTexture, timeInfos, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
23988
24033
|
var _this = this;
|
|
23989
24034
|
return __generator(this, function (_d) {
|
|
23990
24035
|
assetUrl = isString(url) ? url : this.id;
|
|
23991
24036
|
startTime = performance.now();
|
|
23992
|
-
|
|
24037
|
+
timeInfoMessages = [];
|
|
23993
24038
|
gpuInstance = renderer === null || renderer === void 0 ? void 0 : renderer.engine.gpuCapability;
|
|
23994
24039
|
asyncShaderCompile = (_b = (_a = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail) === null || _a === void 0 ? void 0 : _a.asyncShaderCompile) !== null && _b !== void 0 ? _b : false;
|
|
23995
24040
|
compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
|
|
24041
|
+
timeInfos = {};
|
|
23996
24042
|
cancelLoading = false;
|
|
23997
24043
|
waitPromise = new Promise(function (resolve, reject) {
|
|
23998
24044
|
loadTimer = window.setTimeout(function () {
|
|
23999
24045
|
cancelLoading = true;
|
|
24000
24046
|
_this.removeTimer(loadTimer);
|
|
24001
24047
|
var totalTime = performance.now() - startTime;
|
|
24002
|
-
reject("Load time out: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(
|
|
24048
|
+
reject("Load time out: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfoMessages.join(' '), ", url: ").concat(assetUrl));
|
|
24003
24049
|
}, _this.timeout * 1000);
|
|
24004
24050
|
_this.timers.push(loadTimer);
|
|
24005
24051
|
});
|
|
24006
24052
|
hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
|
|
24007
|
-
var st, result, e_1;
|
|
24053
|
+
var st, result, time, e_1;
|
|
24008
24054
|
return __generator(this, function (_a) {
|
|
24009
24055
|
switch (_a.label) {
|
|
24010
24056
|
case 0:
|
|
@@ -24016,7 +24062,9 @@ var AssetManager = /** @class */ (function () {
|
|
|
24016
24062
|
return [4 /*yield*/, func()];
|
|
24017
24063
|
case 2:
|
|
24018
24064
|
result = _a.sent();
|
|
24019
|
-
|
|
24065
|
+
time = performance.now() - st;
|
|
24066
|
+
timeInfoMessages.push("[".concat(label, ": ").concat(time.toFixed(2), "]"));
|
|
24067
|
+
timeInfos[label] = time;
|
|
24020
24068
|
return [2 /*return*/, result];
|
|
24021
24069
|
case 3:
|
|
24022
24070
|
e_1 = _a.sent();
|
|
@@ -24075,7 +24123,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
24075
24123
|
return [4 /*yield*/, Promise.all([
|
|
24076
24124
|
hookTimeInfo('processBins', function () { return _this.processBins(bins_1); }),
|
|
24077
24125
|
hookTimeInfo('processImages', function () { return _this.processImages(images_2, usedImages_1, compressedTexture); }),
|
|
24078
|
-
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', "
|
|
24126
|
+
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', "Compile"), function () { return _this.precompile(compositions_1, pluginSystem_1, renderer, options); }),
|
|
24079
24127
|
])];
|
|
24080
24128
|
case 8:
|
|
24081
24129
|
_d = __read$3.apply(void 0, [_e.sent(), 2]), loadedBins_1 = _d[0], loadedImages_1 = _d[1];
|
|
@@ -24087,6 +24135,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
24087
24135
|
loadedTextures = _e.sent();
|
|
24088
24136
|
jsonScene_1.compositions = this.updateSceneData(jsonScene_1.compositions);
|
|
24089
24137
|
scene = {
|
|
24138
|
+
timeInfos: timeInfos,
|
|
24090
24139
|
url: url,
|
|
24091
24140
|
renderLevel: this.options.renderLevel,
|
|
24092
24141
|
storage: {},
|
|
@@ -24105,11 +24154,13 @@ var AssetManager = /** @class */ (function () {
|
|
|
24105
24154
|
_e.label = 12;
|
|
24106
24155
|
case 12:
|
|
24107
24156
|
totalTime = performance.now() - startTime;
|
|
24108
|
-
logger.info("Load asset: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(
|
|
24157
|
+
logger.info("Load asset: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfoMessages.join(' '), ", url: ").concat(assetUrl));
|
|
24109
24158
|
window.clearTimeout(loadTimer);
|
|
24110
24159
|
this.removeTimer(loadTimer);
|
|
24111
24160
|
scene.totalTime = totalTime;
|
|
24112
24161
|
scene.startTime = startTime;
|
|
24162
|
+
// 各部分分段时长
|
|
24163
|
+
scene.timeInfos = timeInfos;
|
|
24113
24164
|
return [2 /*return*/, scene];
|
|
24114
24165
|
}
|
|
24115
24166
|
});
|
|
@@ -24957,7 +25008,7 @@ var Composition = /** @class */ (function () {
|
|
|
24957
25008
|
* @param props - composition 的创建参数
|
|
24958
25009
|
*/
|
|
24959
25010
|
function Composition(props, scene) {
|
|
24960
|
-
var _a;
|
|
25011
|
+
var _a, _b;
|
|
24961
25012
|
/**
|
|
24962
25013
|
* 动画播放速度
|
|
24963
25014
|
*/
|
|
@@ -24986,7 +25037,7 @@ var Composition = /** @class */ (function () {
|
|
|
24986
25037
|
this.paused = false;
|
|
24987
25038
|
this.lastVideoUpdateTime = 0;
|
|
24988
25039
|
this.postLoaders = [];
|
|
24989
|
-
var
|
|
25040
|
+
var _c = props.reusable, reusable = _c === void 0 ? false : _c, _d = props.speed, speed = _d === void 0 ? 1 : _d, _e = props.baseRenderOrder, baseRenderOrder = _e === void 0 ? 0 : _e, renderer = props.renderer, onPlayerPause = props.onPlayerPause, onMessageItem = props.onMessageItem, onEnd = props.onEnd, event = props.event, width = props.width, height = props.height;
|
|
24990
25041
|
this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
|
|
24991
25042
|
scene.jsonScene.imgUsage = undefined;
|
|
24992
25043
|
if (reusable) {
|
|
@@ -24994,7 +25045,7 @@ var Composition = /** @class */ (function () {
|
|
|
24994
25045
|
scene.textures = undefined;
|
|
24995
25046
|
scene.consumed = true;
|
|
24996
25047
|
}
|
|
24997
|
-
var
|
|
25048
|
+
var _f = this.compositionSourceManager, sourceContent = _f.sourceContent, pluginSystem = _f.pluginSystem, imgUsage = _f.imgUsage, totalTime = _f.totalTime, renderLevel = _f.renderLevel, refCompositionProps = _f.refCompositionProps;
|
|
24998
25049
|
assertExist(sourceContent);
|
|
24999
25050
|
this.refCompositionProps = refCompositionProps;
|
|
25000
25051
|
var vfxItem = new CompVFXItem(sourceContent, this);
|
|
@@ -25011,7 +25062,7 @@ var Composition = /** @class */ (function () {
|
|
|
25011
25062
|
this.renderer = renderer;
|
|
25012
25063
|
this.texInfo = imageUsage !== null && imageUsage !== void 0 ? imageUsage : {};
|
|
25013
25064
|
this.event = event;
|
|
25014
|
-
this.statistic = { loadTime: totalTime !== null && totalTime !== void 0 ? totalTime : 0, loadStart: (_a = scene.startTime) !== null && _a !== void 0 ? _a : 0, firstFrameTime: 0 };
|
|
25065
|
+
this.statistic = { loadTime: totalTime !== null && totalTime !== void 0 ? totalTime : 0, loadStart: (_a = scene.startTime) !== null && _a !== void 0 ? _a : 0, firstFrameTime: 0, precompileTime: (_b = scene.timeInfos['asyncCompile']) !== null && _b !== void 0 ? _b : scene.timeInfos['syncCompile'] };
|
|
25015
25066
|
this.reusable = reusable;
|
|
25016
25067
|
this.speed = speed;
|
|
25017
25068
|
this.renderLevel = renderLevel;
|
|
@@ -25023,6 +25074,7 @@ var Composition = /** @class */ (function () {
|
|
|
25023
25074
|
this.camera = new Camera(this.name, __assign$1(__assign$1({}, sourceContent === null || sourceContent === void 0 ? void 0 : sourceContent.camera), { aspect: width / height }));
|
|
25024
25075
|
this.url = scene.url;
|
|
25025
25076
|
this.assigned = true;
|
|
25077
|
+
this.interactive = true;
|
|
25026
25078
|
this.onPlayerPause = onPlayerPause;
|
|
25027
25079
|
this.onMessageItem = onMessageItem;
|
|
25028
25080
|
this.onEnd = onEnd;
|
|
@@ -25402,7 +25454,7 @@ var Composition = /** @class */ (function () {
|
|
|
25402
25454
|
* @param options - 最大求交数和求交时的回调
|
|
25403
25455
|
*/
|
|
25404
25456
|
Composition.prototype.hitTest = function (x, y, force, options) {
|
|
25405
|
-
if (this.isDestroyed) {
|
|
25457
|
+
if (this.isDestroyed || !this.interactive) {
|
|
25406
25458
|
return [];
|
|
25407
25459
|
}
|
|
25408
25460
|
var regions = [];
|