@galacean/effects-threejs 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/index.js +75 -23
- 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 +75 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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: v1.
|
|
6
|
+
* Version: v1.6.0-beta.1
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -10095,10 +10095,23 @@ var EventSystem = /** @class */ (function () {
|
|
|
10095
10095
|
var getTouchEventValue = function (event, x, y, dx, dy) {
|
|
10096
10096
|
if (dx === void 0) { dx = 0; }
|
|
10097
10097
|
if (dy === void 0) { dy = 0; }
|
|
10098
|
-
var _a = _this.target, width = _a.width, height = _a.height;
|
|
10099
|
-
var ts = performance.now();
|
|
10100
10098
|
var vx = 0;
|
|
10101
10099
|
var vy = 0;
|
|
10100
|
+
var ts = performance.now();
|
|
10101
|
+
if (!_this.target) {
|
|
10102
|
+
logger.error('Trigger TouchEvent after EventSystem is disposed');
|
|
10103
|
+
return {
|
|
10104
|
+
x: x,
|
|
10105
|
+
y: y,
|
|
10106
|
+
vx: 0,
|
|
10107
|
+
vy: vy,
|
|
10108
|
+
dx: dx,
|
|
10109
|
+
dy: dy,
|
|
10110
|
+
ts: ts,
|
|
10111
|
+
width: 0, height: 0, origin: event,
|
|
10112
|
+
};
|
|
10113
|
+
}
|
|
10114
|
+
var _a = _this.target, width = _a.width, height = _a.height;
|
|
10102
10115
|
if (lastTouch) {
|
|
10103
10116
|
var dt = ts - lastTouch.ts;
|
|
10104
10117
|
vx = ((dx - lastTouch.dx) / dt) || 0;
|
|
@@ -13529,6 +13542,14 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13529
13542
|
function InteractVFXItem(props, composition) {
|
|
13530
13543
|
var _a;
|
|
13531
13544
|
var _this = _super.call(this, props, composition) || this;
|
|
13545
|
+
/**
|
|
13546
|
+
* 拖拽的惯性衰减系数,范围[0, 1], 越大惯性越强
|
|
13547
|
+
*/
|
|
13548
|
+
_this.downgrade = 0.95;
|
|
13549
|
+
/**
|
|
13550
|
+
* 拖拽的距离映射系数,越大越容易拖动
|
|
13551
|
+
*/
|
|
13552
|
+
_this.dragRatio = [1, 1];
|
|
13532
13553
|
_this.engine = (_a = _this.composition) === null || _a === void 0 ? void 0 : _a.getEngine();
|
|
13533
13554
|
return _this;
|
|
13534
13555
|
}
|
|
@@ -13539,8 +13560,23 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13539
13560
|
enumerable: false,
|
|
13540
13561
|
configurable: true
|
|
13541
13562
|
});
|
|
13563
|
+
Object.defineProperty(InteractVFXItem.prototype, "enable", {
|
|
13564
|
+
get: function () {
|
|
13565
|
+
return this.enabled;
|
|
13566
|
+
},
|
|
13567
|
+
set: function (enable) {
|
|
13568
|
+
this.enabled = enable;
|
|
13569
|
+
if (!enable) {
|
|
13570
|
+
// 立刻停止惯性滑动
|
|
13571
|
+
this.bouncingArg = null;
|
|
13572
|
+
}
|
|
13573
|
+
},
|
|
13574
|
+
enumerable: false,
|
|
13575
|
+
configurable: true
|
|
13576
|
+
});
|
|
13542
13577
|
InteractVFXItem.prototype.onConstructed = function (options) {
|
|
13543
13578
|
this.ui = options.content;
|
|
13579
|
+
this.enabled = true;
|
|
13544
13580
|
};
|
|
13545
13581
|
InteractVFXItem.prototype.onLifetimeBegin = function (composition) {
|
|
13546
13582
|
var _a, _b, _c;
|
|
@@ -13559,9 +13595,8 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13559
13595
|
if (!this.dragEvent || !this.bouncingArg) {
|
|
13560
13596
|
return;
|
|
13561
13597
|
}
|
|
13562
|
-
|
|
13563
|
-
this.bouncingArg.
|
|
13564
|
-
this.bouncingArg.vy *= downgrade;
|
|
13598
|
+
this.bouncingArg.vx *= this.downgrade;
|
|
13599
|
+
this.bouncingArg.vy *= this.downgrade;
|
|
13565
13600
|
this.bouncingArg.dy += this.bouncingArg.vy;
|
|
13566
13601
|
this.bouncingArg.dx += this.bouncingArg.vx;
|
|
13567
13602
|
if (shouldIgnoreBouncing(this.bouncingArg)) {
|
|
@@ -13597,7 +13632,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13597
13632
|
};
|
|
13598
13633
|
};
|
|
13599
13634
|
InteractVFXItem.prototype.getHitTestParams = function () {
|
|
13600
|
-
if (!this.clickable) {
|
|
13635
|
+
if (!this.clickable || !this.canInteract()) {
|
|
13601
13636
|
return;
|
|
13602
13637
|
}
|
|
13603
13638
|
var behavior = this.ui.options.behavior;
|
|
@@ -13634,6 +13669,9 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13634
13669
|
var handlerMap = {
|
|
13635
13670
|
touchstart: function (event) {
|
|
13636
13671
|
var _a;
|
|
13672
|
+
if (!_this.canInteract()) {
|
|
13673
|
+
return;
|
|
13674
|
+
}
|
|
13637
13675
|
_this.dragEvent = null;
|
|
13638
13676
|
_this.bouncingArg = null;
|
|
13639
13677
|
var camera = (_a = _this.composition) === null || _a === void 0 ? void 0 : _a.camera;
|
|
@@ -13651,6 +13689,9 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13651
13689
|
_this.bouncingArg = event;
|
|
13652
13690
|
},
|
|
13653
13691
|
touchend: function (event) {
|
|
13692
|
+
if (!_this.canInteract()) {
|
|
13693
|
+
return;
|
|
13694
|
+
}
|
|
13654
13695
|
var bouncingArg = _this.bouncingArg;
|
|
13655
13696
|
if (!shouldIgnoreBouncing(bouncingArg, 3) && bouncingArg) {
|
|
13656
13697
|
var speed = 5;
|
|
@@ -13676,7 +13717,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13676
13717
|
};
|
|
13677
13718
|
InteractVFXItem.prototype.handleDragMove = function (evt, event) {
|
|
13678
13719
|
var _a, _b;
|
|
13679
|
-
if (!(evt
|
|
13720
|
+
if (!(evt === null || evt === void 0 ? void 0 : evt.cameraParam) || !this.canInteract() || !this.composition) {
|
|
13680
13721
|
return;
|
|
13681
13722
|
}
|
|
13682
13723
|
var options = this.ui.options;
|
|
@@ -13687,8 +13728,8 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13687
13728
|
var sp = Math.tan(fov * Math.PI / 180 / 2) * Math.abs(depth);
|
|
13688
13729
|
var height = dy * sp;
|
|
13689
13730
|
var width = dx * sp;
|
|
13690
|
-
var nx = position[0] - width;
|
|
13691
|
-
var ny = position[1] - height;
|
|
13731
|
+
var nx = position[0] - this.dragRatio[0] * width;
|
|
13732
|
+
var ny = position[1] - this.dragRatio[1] * height;
|
|
13692
13733
|
if (options.dxRange) {
|
|
13693
13734
|
var _d = __read$3(options.dxRange, 2), min = _d[0], max = _d[1];
|
|
13694
13735
|
nx = clamp$1(nx, min, max);
|
|
@@ -13705,6 +13746,10 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13705
13746
|
}
|
|
13706
13747
|
this.composition.camera.position = new Vector3(nx, ny, depth);
|
|
13707
13748
|
};
|
|
13749
|
+
InteractVFXItem.prototype.canInteract = function () {
|
|
13750
|
+
var _a;
|
|
13751
|
+
return Boolean((_a = this.composition) === null || _a === void 0 ? void 0 : _a.interactive) && this.enabled;
|
|
13752
|
+
};
|
|
13708
13753
|
return InteractVFXItem;
|
|
13709
13754
|
}(VFXItem));
|
|
13710
13755
|
function shouldIgnoreBouncing(arg, mul) {
|
|
@@ -24010,27 +24055,28 @@ var AssetManager = /** @class */ (function () {
|
|
|
24010
24055
|
AssetManager.prototype.loadScene = function (url, renderer, options) {
|
|
24011
24056
|
var _a, _b, _c;
|
|
24012
24057
|
return __awaiter(this, void 0, void 0, function () {
|
|
24013
|
-
var rawJSON, assetUrl, startTime,
|
|
24058
|
+
var rawJSON, assetUrl, startTime, timeInfoMessages, gpuInstance, asyncShaderCompile, compressedTexture, timeInfos, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
24014
24059
|
var _this = this;
|
|
24015
24060
|
return __generator(this, function (_d) {
|
|
24016
24061
|
assetUrl = isString(url) ? url : this.id;
|
|
24017
24062
|
startTime = performance.now();
|
|
24018
|
-
|
|
24063
|
+
timeInfoMessages = [];
|
|
24019
24064
|
gpuInstance = renderer === null || renderer === void 0 ? void 0 : renderer.engine.gpuCapability;
|
|
24020
24065
|
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;
|
|
24021
24066
|
compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
|
|
24067
|
+
timeInfos = {};
|
|
24022
24068
|
cancelLoading = false;
|
|
24023
24069
|
waitPromise = new Promise(function (resolve, reject) {
|
|
24024
24070
|
loadTimer = window.setTimeout(function () {
|
|
24025
24071
|
cancelLoading = true;
|
|
24026
24072
|
_this.removeTimer(loadTimer);
|
|
24027
24073
|
var totalTime = performance.now() - startTime;
|
|
24028
|
-
reject("Load time out: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(
|
|
24074
|
+
reject("Load time out: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfoMessages.join(' '), ", url: ").concat(assetUrl));
|
|
24029
24075
|
}, _this.timeout * 1000);
|
|
24030
24076
|
_this.timers.push(loadTimer);
|
|
24031
24077
|
});
|
|
24032
24078
|
hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
|
|
24033
|
-
var st, result, e_1;
|
|
24079
|
+
var st, result, time, e_1;
|
|
24034
24080
|
return __generator(this, function (_a) {
|
|
24035
24081
|
switch (_a.label) {
|
|
24036
24082
|
case 0:
|
|
@@ -24042,7 +24088,9 @@ var AssetManager = /** @class */ (function () {
|
|
|
24042
24088
|
return [4 /*yield*/, func()];
|
|
24043
24089
|
case 2:
|
|
24044
24090
|
result = _a.sent();
|
|
24045
|
-
|
|
24091
|
+
time = performance.now() - st;
|
|
24092
|
+
timeInfoMessages.push("[".concat(label, ": ").concat(time.toFixed(2), "]"));
|
|
24093
|
+
timeInfos[label] = time;
|
|
24046
24094
|
return [2 /*return*/, result];
|
|
24047
24095
|
case 3:
|
|
24048
24096
|
e_1 = _a.sent();
|
|
@@ -24101,7 +24149,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
24101
24149
|
return [4 /*yield*/, Promise.all([
|
|
24102
24150
|
hookTimeInfo('processBins', function () { return _this.processBins(bins_1); }),
|
|
24103
24151
|
hookTimeInfo('processImages', function () { return _this.processImages(images_2, usedImages_1, compressedTexture); }),
|
|
24104
|
-
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', "
|
|
24152
|
+
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', "Compile"), function () { return _this.precompile(compositions_1, pluginSystem_1, renderer, options); }),
|
|
24105
24153
|
])];
|
|
24106
24154
|
case 8:
|
|
24107
24155
|
_d = __read$3.apply(void 0, [_e.sent(), 2]), loadedBins_1 = _d[0], loadedImages_1 = _d[1];
|
|
@@ -24113,6 +24161,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
24113
24161
|
loadedTextures = _e.sent();
|
|
24114
24162
|
jsonScene_1.compositions = this.updateSceneData(jsonScene_1.compositions);
|
|
24115
24163
|
scene = {
|
|
24164
|
+
timeInfos: timeInfos,
|
|
24116
24165
|
url: url,
|
|
24117
24166
|
renderLevel: this.options.renderLevel,
|
|
24118
24167
|
storage: {},
|
|
@@ -24131,11 +24180,13 @@ var AssetManager = /** @class */ (function () {
|
|
|
24131
24180
|
_e.label = 12;
|
|
24132
24181
|
case 12:
|
|
24133
24182
|
totalTime = performance.now() - startTime;
|
|
24134
|
-
logger.info("Load asset: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(
|
|
24183
|
+
logger.info("Load asset: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfoMessages.join(' '), ", url: ").concat(assetUrl));
|
|
24135
24184
|
window.clearTimeout(loadTimer);
|
|
24136
24185
|
this.removeTimer(loadTimer);
|
|
24137
24186
|
scene.totalTime = totalTime;
|
|
24138
24187
|
scene.startTime = startTime;
|
|
24188
|
+
// 各部分分段时长
|
|
24189
|
+
scene.timeInfos = timeInfos;
|
|
24139
24190
|
return [2 /*return*/, scene];
|
|
24140
24191
|
}
|
|
24141
24192
|
});
|
|
@@ -24983,7 +25034,7 @@ var Composition = /** @class */ (function () {
|
|
|
24983
25034
|
* @param props - composition 的创建参数
|
|
24984
25035
|
*/
|
|
24985
25036
|
function Composition(props, scene) {
|
|
24986
|
-
var _a;
|
|
25037
|
+
var _a, _b;
|
|
24987
25038
|
/**
|
|
24988
25039
|
* 动画播放速度
|
|
24989
25040
|
*/
|
|
@@ -25012,7 +25063,7 @@ var Composition = /** @class */ (function () {
|
|
|
25012
25063
|
this.paused = false;
|
|
25013
25064
|
this.lastVideoUpdateTime = 0;
|
|
25014
25065
|
this.postLoaders = [];
|
|
25015
|
-
var
|
|
25066
|
+
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;
|
|
25016
25067
|
this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
|
|
25017
25068
|
scene.jsonScene.imgUsage = undefined;
|
|
25018
25069
|
if (reusable) {
|
|
@@ -25020,7 +25071,7 @@ var Composition = /** @class */ (function () {
|
|
|
25020
25071
|
scene.textures = undefined;
|
|
25021
25072
|
scene.consumed = true;
|
|
25022
25073
|
}
|
|
25023
|
-
var
|
|
25074
|
+
var _f = this.compositionSourceManager, sourceContent = _f.sourceContent, pluginSystem = _f.pluginSystem, imgUsage = _f.imgUsage, totalTime = _f.totalTime, renderLevel = _f.renderLevel, refCompositionProps = _f.refCompositionProps;
|
|
25024
25075
|
assertExist(sourceContent);
|
|
25025
25076
|
this.refCompositionProps = refCompositionProps;
|
|
25026
25077
|
var vfxItem = new CompVFXItem(sourceContent, this);
|
|
@@ -25037,7 +25088,7 @@ var Composition = /** @class */ (function () {
|
|
|
25037
25088
|
this.renderer = renderer;
|
|
25038
25089
|
this.texInfo = imageUsage !== null && imageUsage !== void 0 ? imageUsage : {};
|
|
25039
25090
|
this.event = event;
|
|
25040
|
-
this.statistic = { loadTime: totalTime !== null && totalTime !== void 0 ? totalTime : 0, loadStart: (_a = scene.startTime) !== null && _a !== void 0 ? _a : 0, firstFrameTime: 0 };
|
|
25091
|
+
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'] };
|
|
25041
25092
|
this.reusable = reusable;
|
|
25042
25093
|
this.speed = speed;
|
|
25043
25094
|
this.renderLevel = renderLevel;
|
|
@@ -25049,6 +25100,7 @@ var Composition = /** @class */ (function () {
|
|
|
25049
25100
|
this.camera = new Camera(this.name, __assign$1(__assign$1({}, sourceContent === null || sourceContent === void 0 ? void 0 : sourceContent.camera), { aspect: width / height }));
|
|
25050
25101
|
this.url = scene.url;
|
|
25051
25102
|
this.assigned = true;
|
|
25103
|
+
this.interactive = true;
|
|
25052
25104
|
this.onPlayerPause = onPlayerPause;
|
|
25053
25105
|
this.onMessageItem = onMessageItem;
|
|
25054
25106
|
this.onEnd = onEnd;
|
|
@@ -25428,7 +25480,7 @@ var Composition = /** @class */ (function () {
|
|
|
25428
25480
|
* @param options - 最大求交数和求交时的回调
|
|
25429
25481
|
*/
|
|
25430
25482
|
Composition.prototype.hitTest = function (x, y, force, options) {
|
|
25431
|
-
if (this.isDestroyed) {
|
|
25483
|
+
if (this.isDestroyed || !this.interactive) {
|
|
25432
25484
|
return [];
|
|
25433
25485
|
}
|
|
25434
25486
|
var regions = [];
|
|
@@ -27426,7 +27478,7 @@ Geometry.create = function (engine, options) {
|
|
|
27426
27478
|
Mesh.create = function (engine, props) {
|
|
27427
27479
|
return new ThreeMesh(engine, props);
|
|
27428
27480
|
};
|
|
27429
|
-
var version = "1.
|
|
27481
|
+
var version = "1.6.0-beta.1";
|
|
27430
27482
|
logger.info('THREEJS plugin version: ' + version);
|
|
27431
27483
|
|
|
27432
27484
|
exports.AbstractPlugin = AbstractPlugin;
|