@galacean/effects 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/alipay.js +80 -23
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +80 -23
- package/dist/alipay.mjs.map +1 -1
- package/dist/index.js +81 -24
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +81 -24
- package/dist/index.mjs.map +1 -1
- package/dist/player.d.ts +7 -5
- package/dist/weapp.js +80 -23
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +80 -23
- package/dist/weapp.mjs.map +1 -1
- package/package.json +3 -3
package/dist/alipay.js
CHANGED
|
@@ -10067,10 +10067,23 @@ var EventSystem = /** @class */ (function () {
|
|
|
10067
10067
|
var getTouchEventValue = function (event, x, y, dx, dy) {
|
|
10068
10068
|
if (dx === void 0) { dx = 0; }
|
|
10069
10069
|
if (dy === void 0) { dy = 0; }
|
|
10070
|
-
var _a = _this.target, width = _a.width, height = _a.height;
|
|
10071
|
-
var ts = alipay.performance.now();
|
|
10072
10070
|
var vx = 0;
|
|
10073
10071
|
var vy = 0;
|
|
10072
|
+
var ts = alipay.performance.now();
|
|
10073
|
+
if (!_this.target) {
|
|
10074
|
+
logger.error('Trigger TouchEvent after EventSystem is disposed');
|
|
10075
|
+
return {
|
|
10076
|
+
x: x,
|
|
10077
|
+
y: y,
|
|
10078
|
+
vx: 0,
|
|
10079
|
+
vy: vy,
|
|
10080
|
+
dx: dx,
|
|
10081
|
+
dy: dy,
|
|
10082
|
+
ts: ts,
|
|
10083
|
+
width: 0, height: 0, origin: event,
|
|
10084
|
+
};
|
|
10085
|
+
}
|
|
10086
|
+
var _a = _this.target, width = _a.width, height = _a.height;
|
|
10074
10087
|
if (lastTouch) {
|
|
10075
10088
|
var dt = ts - lastTouch.ts;
|
|
10076
10089
|
vx = ((dx - lastTouch.dx) / dt) || 0;
|
|
@@ -13501,6 +13514,14 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13501
13514
|
function InteractVFXItem(props, composition) {
|
|
13502
13515
|
var _a;
|
|
13503
13516
|
var _this = _super.call(this, props, composition) || this;
|
|
13517
|
+
/**
|
|
13518
|
+
* 拖拽的惯性衰减系数,范围[0, 1], 越大惯性越强
|
|
13519
|
+
*/
|
|
13520
|
+
_this.downgrade = 0.95;
|
|
13521
|
+
/**
|
|
13522
|
+
* 拖拽的距离映射系数,越大越容易拖动
|
|
13523
|
+
*/
|
|
13524
|
+
_this.dragRatio = [1, 1];
|
|
13504
13525
|
_this.engine = (_a = _this.composition) === null || _a === void 0 ? void 0 : _a.getEngine();
|
|
13505
13526
|
return _this;
|
|
13506
13527
|
}
|
|
@@ -13511,8 +13532,23 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13511
13532
|
enumerable: false,
|
|
13512
13533
|
configurable: true
|
|
13513
13534
|
});
|
|
13535
|
+
Object.defineProperty(InteractVFXItem.prototype, "enable", {
|
|
13536
|
+
get: function () {
|
|
13537
|
+
return this.enabled;
|
|
13538
|
+
},
|
|
13539
|
+
set: function (enable) {
|
|
13540
|
+
this.enabled = enable;
|
|
13541
|
+
if (!enable) {
|
|
13542
|
+
// 立刻停止惯性滑动
|
|
13543
|
+
this.bouncingArg = null;
|
|
13544
|
+
}
|
|
13545
|
+
},
|
|
13546
|
+
enumerable: false,
|
|
13547
|
+
configurable: true
|
|
13548
|
+
});
|
|
13514
13549
|
InteractVFXItem.prototype.onConstructed = function (options) {
|
|
13515
13550
|
this.ui = options.content;
|
|
13551
|
+
this.enabled = true;
|
|
13516
13552
|
};
|
|
13517
13553
|
InteractVFXItem.prototype.onLifetimeBegin = function (composition) {
|
|
13518
13554
|
var _a, _b, _c;
|
|
@@ -13531,9 +13567,8 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13531
13567
|
if (!this.dragEvent || !this.bouncingArg) {
|
|
13532
13568
|
return;
|
|
13533
13569
|
}
|
|
13534
|
-
|
|
13535
|
-
this.bouncingArg.
|
|
13536
|
-
this.bouncingArg.vy *= downgrade;
|
|
13570
|
+
this.bouncingArg.vx *= this.downgrade;
|
|
13571
|
+
this.bouncingArg.vy *= this.downgrade;
|
|
13537
13572
|
this.bouncingArg.dy += this.bouncingArg.vy;
|
|
13538
13573
|
this.bouncingArg.dx += this.bouncingArg.vx;
|
|
13539
13574
|
if (shouldIgnoreBouncing(this.bouncingArg)) {
|
|
@@ -13569,7 +13604,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13569
13604
|
};
|
|
13570
13605
|
};
|
|
13571
13606
|
InteractVFXItem.prototype.getHitTestParams = function () {
|
|
13572
|
-
if (!this.clickable) {
|
|
13607
|
+
if (!this.clickable || !this.canInteract()) {
|
|
13573
13608
|
return;
|
|
13574
13609
|
}
|
|
13575
13610
|
var behavior = this.ui.options.behavior;
|
|
@@ -13606,6 +13641,9 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13606
13641
|
var handlerMap = {
|
|
13607
13642
|
touchstart: function (event) {
|
|
13608
13643
|
var _a;
|
|
13644
|
+
if (!_this.canInteract()) {
|
|
13645
|
+
return;
|
|
13646
|
+
}
|
|
13609
13647
|
_this.dragEvent = null;
|
|
13610
13648
|
_this.bouncingArg = null;
|
|
13611
13649
|
var camera = (_a = _this.composition) === null || _a === void 0 ? void 0 : _a.camera;
|
|
@@ -13623,6 +13661,9 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13623
13661
|
_this.bouncingArg = event;
|
|
13624
13662
|
},
|
|
13625
13663
|
touchend: function (event) {
|
|
13664
|
+
if (!_this.canInteract()) {
|
|
13665
|
+
return;
|
|
13666
|
+
}
|
|
13626
13667
|
var bouncingArg = _this.bouncingArg;
|
|
13627
13668
|
if (!shouldIgnoreBouncing(bouncingArg, 3) && bouncingArg) {
|
|
13628
13669
|
var speed = 5;
|
|
@@ -13648,7 +13689,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13648
13689
|
};
|
|
13649
13690
|
InteractVFXItem.prototype.handleDragMove = function (evt, event) {
|
|
13650
13691
|
var _a, _b;
|
|
13651
|
-
if (!(evt
|
|
13692
|
+
if (!(evt === null || evt === void 0 ? void 0 : evt.cameraParam) || !this.canInteract() || !this.composition) {
|
|
13652
13693
|
return;
|
|
13653
13694
|
}
|
|
13654
13695
|
var options = this.ui.options;
|
|
@@ -13659,8 +13700,8 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13659
13700
|
var sp = Math.tan(fov * Math.PI / 180 / 2) * Math.abs(depth);
|
|
13660
13701
|
var height = dy * sp;
|
|
13661
13702
|
var width = dx * sp;
|
|
13662
|
-
var nx = position[0] - width;
|
|
13663
|
-
var ny = position[1] - height;
|
|
13703
|
+
var nx = position[0] - this.dragRatio[0] * width;
|
|
13704
|
+
var ny = position[1] - this.dragRatio[1] * height;
|
|
13664
13705
|
if (options.dxRange) {
|
|
13665
13706
|
var _d = __read$3(options.dxRange, 2), min = _d[0], max = _d[1];
|
|
13666
13707
|
nx = clamp$1(nx, min, max);
|
|
@@ -13677,6 +13718,10 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13677
13718
|
}
|
|
13678
13719
|
this.composition.camera.position = new Vector3(nx, ny, depth);
|
|
13679
13720
|
};
|
|
13721
|
+
InteractVFXItem.prototype.canInteract = function () {
|
|
13722
|
+
var _a;
|
|
13723
|
+
return Boolean((_a = this.composition) === null || _a === void 0 ? void 0 : _a.interactive) && this.enabled;
|
|
13724
|
+
};
|
|
13680
13725
|
return InteractVFXItem;
|
|
13681
13726
|
}(VFXItem));
|
|
13682
13727
|
function shouldIgnoreBouncing(arg, mul) {
|
|
@@ -23982,27 +24027,28 @@ var AssetManager = /** @class */ (function () {
|
|
|
23982
24027
|
AssetManager.prototype.loadScene = function (url, renderer, options) {
|
|
23983
24028
|
var _a, _b, _c;
|
|
23984
24029
|
return __awaiter(this, void 0, void 0, function () {
|
|
23985
|
-
var rawJSON, assetUrl, startTime,
|
|
24030
|
+
var rawJSON, assetUrl, startTime, timeInfoMessages, gpuInstance, asyncShaderCompile, compressedTexture, timeInfos, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
23986
24031
|
var _this = this;
|
|
23987
24032
|
return __generator(this, function (_d) {
|
|
23988
24033
|
assetUrl = isString(url) ? url : this.id;
|
|
23989
24034
|
startTime = alipay.performance.now();
|
|
23990
|
-
|
|
24035
|
+
timeInfoMessages = [];
|
|
23991
24036
|
gpuInstance = renderer === null || renderer === void 0 ? void 0 : renderer.engine.gpuCapability;
|
|
23992
24037
|
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;
|
|
23993
24038
|
compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
|
|
24039
|
+
timeInfos = {};
|
|
23994
24040
|
cancelLoading = false;
|
|
23995
24041
|
waitPromise = new Promise(function (resolve, reject) {
|
|
23996
24042
|
loadTimer = alipay.window.setTimeout(function () {
|
|
23997
24043
|
cancelLoading = true;
|
|
23998
24044
|
_this.removeTimer(loadTimer);
|
|
23999
24045
|
var totalTime = alipay.performance.now() - startTime;
|
|
24000
|
-
reject("Load time out: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(
|
|
24046
|
+
reject("Load time out: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfoMessages.join(' '), ", url: ").concat(assetUrl));
|
|
24001
24047
|
}, _this.timeout * 1000);
|
|
24002
24048
|
_this.timers.push(loadTimer);
|
|
24003
24049
|
});
|
|
24004
24050
|
hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
|
|
24005
|
-
var st, result, e_1;
|
|
24051
|
+
var st, result, time, e_1;
|
|
24006
24052
|
return __generator(this, function (_a) {
|
|
24007
24053
|
switch (_a.label) {
|
|
24008
24054
|
case 0:
|
|
@@ -24014,7 +24060,9 @@ var AssetManager = /** @class */ (function () {
|
|
|
24014
24060
|
return [4 /*yield*/, func()];
|
|
24015
24061
|
case 2:
|
|
24016
24062
|
result = _a.sent();
|
|
24017
|
-
|
|
24063
|
+
time = alipay.performance.now() - st;
|
|
24064
|
+
timeInfoMessages.push("[".concat(label, ": ").concat(time.toFixed(2), "]"));
|
|
24065
|
+
timeInfos[label] = time;
|
|
24018
24066
|
return [2 /*return*/, result];
|
|
24019
24067
|
case 3:
|
|
24020
24068
|
e_1 = _a.sent();
|
|
@@ -24073,7 +24121,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
24073
24121
|
return [4 /*yield*/, Promise.all([
|
|
24074
24122
|
hookTimeInfo('processBins', function () { return _this.processBins(bins_1); }),
|
|
24075
24123
|
hookTimeInfo('processImages', function () { return _this.processImages(images_2, usedImages_1, compressedTexture); }),
|
|
24076
|
-
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', "
|
|
24124
|
+
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', "Compile"), function () { return _this.precompile(compositions_1, pluginSystem_1, renderer, options); }),
|
|
24077
24125
|
])];
|
|
24078
24126
|
case 8:
|
|
24079
24127
|
_d = __read$3.apply(void 0, [_e.sent(), 2]), loadedBins_1 = _d[0], loadedImages_1 = _d[1];
|
|
@@ -24085,6 +24133,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
24085
24133
|
loadedTextures = _e.sent();
|
|
24086
24134
|
jsonScene_1.compositions = this.updateSceneData(jsonScene_1.compositions);
|
|
24087
24135
|
scene = {
|
|
24136
|
+
timeInfos: timeInfos,
|
|
24088
24137
|
url: url,
|
|
24089
24138
|
renderLevel: this.options.renderLevel,
|
|
24090
24139
|
storage: {},
|
|
@@ -24103,11 +24152,13 @@ var AssetManager = /** @class */ (function () {
|
|
|
24103
24152
|
_e.label = 12;
|
|
24104
24153
|
case 12:
|
|
24105
24154
|
totalTime = alipay.performance.now() - startTime;
|
|
24106
|
-
logger.info("Load asset: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(
|
|
24155
|
+
logger.info("Load asset: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfoMessages.join(' '), ", url: ").concat(assetUrl));
|
|
24107
24156
|
alipay.window.clearTimeout(loadTimer);
|
|
24108
24157
|
this.removeTimer(loadTimer);
|
|
24109
24158
|
scene.totalTime = totalTime;
|
|
24110
24159
|
scene.startTime = startTime;
|
|
24160
|
+
// 各部分分段时长
|
|
24161
|
+
scene.timeInfos = timeInfos;
|
|
24111
24162
|
return [2 /*return*/, scene];
|
|
24112
24163
|
}
|
|
24113
24164
|
});
|
|
@@ -24955,7 +25006,7 @@ var Composition = /** @class */ (function () {
|
|
|
24955
25006
|
* @param props - composition 的创建参数
|
|
24956
25007
|
*/
|
|
24957
25008
|
function Composition(props, scene) {
|
|
24958
|
-
var _a;
|
|
25009
|
+
var _a, _b;
|
|
24959
25010
|
/**
|
|
24960
25011
|
* 动画播放速度
|
|
24961
25012
|
*/
|
|
@@ -24984,7 +25035,7 @@ var Composition = /** @class */ (function () {
|
|
|
24984
25035
|
this.paused = false;
|
|
24985
25036
|
this.lastVideoUpdateTime = 0;
|
|
24986
25037
|
this.postLoaders = [];
|
|
24987
|
-
var
|
|
25038
|
+
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;
|
|
24988
25039
|
this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
|
|
24989
25040
|
scene.jsonScene.imgUsage = undefined;
|
|
24990
25041
|
if (reusable) {
|
|
@@ -24992,7 +25043,7 @@ var Composition = /** @class */ (function () {
|
|
|
24992
25043
|
scene.textures = undefined;
|
|
24993
25044
|
scene.consumed = true;
|
|
24994
25045
|
}
|
|
24995
|
-
var
|
|
25046
|
+
var _f = this.compositionSourceManager, sourceContent = _f.sourceContent, pluginSystem = _f.pluginSystem, imgUsage = _f.imgUsage, totalTime = _f.totalTime, renderLevel = _f.renderLevel, refCompositionProps = _f.refCompositionProps;
|
|
24996
25047
|
assertExist(sourceContent);
|
|
24997
25048
|
this.refCompositionProps = refCompositionProps;
|
|
24998
25049
|
var vfxItem = new CompVFXItem(sourceContent, this);
|
|
@@ -25009,7 +25060,7 @@ var Composition = /** @class */ (function () {
|
|
|
25009
25060
|
this.renderer = renderer;
|
|
25010
25061
|
this.texInfo = imageUsage !== null && imageUsage !== void 0 ? imageUsage : {};
|
|
25011
25062
|
this.event = event;
|
|
25012
|
-
this.statistic = { loadTime: totalTime !== null && totalTime !== void 0 ? totalTime : 0, loadStart: (_a = scene.startTime) !== null && _a !== void 0 ? _a : 0, firstFrameTime: 0 };
|
|
25063
|
+
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'] };
|
|
25013
25064
|
this.reusable = reusable;
|
|
25014
25065
|
this.speed = speed;
|
|
25015
25066
|
this.renderLevel = renderLevel;
|
|
@@ -25021,6 +25072,7 @@ var Composition = /** @class */ (function () {
|
|
|
25021
25072
|
this.camera = new Camera(this.name, __assign$1(__assign$1({}, sourceContent === null || sourceContent === void 0 ? void 0 : sourceContent.camera), { aspect: width / height }));
|
|
25022
25073
|
this.url = scene.url;
|
|
25023
25074
|
this.assigned = true;
|
|
25075
|
+
this.interactive = true;
|
|
25024
25076
|
this.onPlayerPause = onPlayerPause;
|
|
25025
25077
|
this.onMessageItem = onMessageItem;
|
|
25026
25078
|
this.onEnd = onEnd;
|
|
@@ -25400,7 +25452,7 @@ var Composition = /** @class */ (function () {
|
|
|
25400
25452
|
* @param options - 最大求交数和求交时的回调
|
|
25401
25453
|
*/
|
|
25402
25454
|
Composition.prototype.hitTest = function (x, y, force, options) {
|
|
25403
|
-
if (this.isDestroyed) {
|
|
25455
|
+
if (this.isDestroyed || !this.interactive) {
|
|
25404
25456
|
return [];
|
|
25405
25457
|
}
|
|
25406
25458
|
var regions = [];
|
|
@@ -30172,7 +30224,12 @@ var Player = /** @class */ (function () {
|
|
|
30172
30224
|
for (var i = 0; i < regions.length; i++) {
|
|
30173
30225
|
var behavior = regions[i].behavior || InteractBehavior$2.NOTIFY;
|
|
30174
30226
|
if (behavior === InteractBehavior$2.NOTIFY) {
|
|
30175
|
-
(
|
|
30227
|
+
if (composition.onItemClicked) {
|
|
30228
|
+
composition.onItemClicked(__assign$1({}, regions[i]));
|
|
30229
|
+
}
|
|
30230
|
+
else {
|
|
30231
|
+
(_a = _this.handleItemClicked) === null || _a === void 0 ? void 0 : _a.call(_this, __assign$1(__assign$1({}, regions[i]), { compositionId: composition.id, compositionName: composition.name, composition: composition.name, player: _this }));
|
|
30232
|
+
}
|
|
30176
30233
|
}
|
|
30177
30234
|
else if (behavior === InteractBehavior$2.RESUME_PLAYER) {
|
|
30178
30235
|
void _this.resume();
|
|
@@ -30935,7 +30992,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
|
|
|
30935
30992
|
Engine.create = function (gl) {
|
|
30936
30993
|
return new GLEngine(gl);
|
|
30937
30994
|
};
|
|
30938
|
-
var version = "1.
|
|
30995
|
+
var version = "1.6.0-beta.1";
|
|
30939
30996
|
logger.info('player version: ' + version);
|
|
30940
30997
|
|
|
30941
30998
|
exports.AbstractPlugin = AbstractPlugin;
|