@galacean/effects-threejs 1.6.0-beta.0 → 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 +62 -31
- 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 +62 -31
- 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.0-beta.
|
|
6
|
+
* Version: v1.6.0-beta.1
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -13542,6 +13542,14 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13542
13542
|
function InteractVFXItem(props, composition) {
|
|
13543
13543
|
var _a;
|
|
13544
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];
|
|
13545
13553
|
_this.engine = (_a = _this.composition) === null || _a === void 0 ? void 0 : _a.getEngine();
|
|
13546
13554
|
return _this;
|
|
13547
13555
|
}
|
|
@@ -13552,8 +13560,23 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13552
13560
|
enumerable: false,
|
|
13553
13561
|
configurable: true
|
|
13554
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
|
+
});
|
|
13555
13577
|
InteractVFXItem.prototype.onConstructed = function (options) {
|
|
13556
13578
|
this.ui = options.content;
|
|
13579
|
+
this.enabled = true;
|
|
13557
13580
|
};
|
|
13558
13581
|
InteractVFXItem.prototype.onLifetimeBegin = function (composition) {
|
|
13559
13582
|
var _a, _b, _c;
|
|
@@ -13572,9 +13595,8 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13572
13595
|
if (!this.dragEvent || !this.bouncingArg) {
|
|
13573
13596
|
return;
|
|
13574
13597
|
}
|
|
13575
|
-
|
|
13576
|
-
this.bouncingArg.
|
|
13577
|
-
this.bouncingArg.vy *= downgrade;
|
|
13598
|
+
this.bouncingArg.vx *= this.downgrade;
|
|
13599
|
+
this.bouncingArg.vy *= this.downgrade;
|
|
13578
13600
|
this.bouncingArg.dy += this.bouncingArg.vy;
|
|
13579
13601
|
this.bouncingArg.dx += this.bouncingArg.vx;
|
|
13580
13602
|
if (shouldIgnoreBouncing(this.bouncingArg)) {
|
|
@@ -13610,7 +13632,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13610
13632
|
};
|
|
13611
13633
|
};
|
|
13612
13634
|
InteractVFXItem.prototype.getHitTestParams = function () {
|
|
13613
|
-
if (!this.clickable) {
|
|
13635
|
+
if (!this.clickable || !this.canInteract()) {
|
|
13614
13636
|
return;
|
|
13615
13637
|
}
|
|
13616
13638
|
var behavior = this.ui.options.behavior;
|
|
@@ -13646,13 +13668,13 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13646
13668
|
var dragEvent;
|
|
13647
13669
|
var handlerMap = {
|
|
13648
13670
|
touchstart: function (event) {
|
|
13649
|
-
var _a
|
|
13650
|
-
if (!
|
|
13671
|
+
var _a;
|
|
13672
|
+
if (!_this.canInteract()) {
|
|
13651
13673
|
return;
|
|
13652
13674
|
}
|
|
13653
13675
|
_this.dragEvent = null;
|
|
13654
13676
|
_this.bouncingArg = null;
|
|
13655
|
-
var camera = (
|
|
13677
|
+
var camera = (_a = _this.composition) === null || _a === void 0 ? void 0 : _a.camera;
|
|
13656
13678
|
dragEvent = {
|
|
13657
13679
|
x: event.x,
|
|
13658
13680
|
y: event.y,
|
|
@@ -13667,8 +13689,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13667
13689
|
_this.bouncingArg = event;
|
|
13668
13690
|
},
|
|
13669
13691
|
touchend: function (event) {
|
|
13670
|
-
|
|
13671
|
-
if (!((_a = _this.composition) === null || _a === void 0 ? void 0 : _a.interactive)) {
|
|
13692
|
+
if (!_this.canInteract()) {
|
|
13672
13693
|
return;
|
|
13673
13694
|
}
|
|
13674
13695
|
var bouncingArg = _this.bouncingArg;
|
|
@@ -13695,36 +13716,40 @@ var InteractVFXItem = /** @class */ (function (_super) {
|
|
|
13695
13716
|
// OVERRIDE
|
|
13696
13717
|
};
|
|
13697
13718
|
InteractVFXItem.prototype.handleDragMove = function (evt, event) {
|
|
13698
|
-
var _a, _b
|
|
13699
|
-
if (!(evt
|
|
13719
|
+
var _a, _b;
|
|
13720
|
+
if (!(evt === null || evt === void 0 ? void 0 : evt.cameraParam) || !this.canInteract() || !this.composition) {
|
|
13700
13721
|
return;
|
|
13701
13722
|
}
|
|
13702
13723
|
var options = this.ui.options;
|
|
13703
|
-
var
|
|
13724
|
+
var _c = evt.cameraParam, position = _c.position, fov = _c.fov;
|
|
13704
13725
|
var dy = event.dy;
|
|
13705
13726
|
var dx = event.dx * event.width / event.height;
|
|
13706
13727
|
var depth = position[2];
|
|
13707
13728
|
var sp = Math.tan(fov * Math.PI / 180 / 2) * Math.abs(depth);
|
|
13708
13729
|
var height = dy * sp;
|
|
13709
13730
|
var width = dx * sp;
|
|
13710
|
-
var nx = position[0] - width;
|
|
13711
|
-
var ny = position[1] - height;
|
|
13731
|
+
var nx = position[0] - this.dragRatio[0] * width;
|
|
13732
|
+
var ny = position[1] - this.dragRatio[1] * height;
|
|
13712
13733
|
if (options.dxRange) {
|
|
13713
|
-
var
|
|
13734
|
+
var _d = __read$3(options.dxRange, 2), min = _d[0], max = _d[1];
|
|
13714
13735
|
nx = clamp$1(nx, min, max);
|
|
13715
13736
|
if (nx !== min && nx !== max && min !== max) {
|
|
13716
|
-
(
|
|
13737
|
+
(_a = event.origin) === null || _a === void 0 ? void 0 : _a.preventDefault();
|
|
13717
13738
|
}
|
|
13718
13739
|
}
|
|
13719
13740
|
if (options.dyRange) {
|
|
13720
|
-
var
|
|
13741
|
+
var _e = __read$3(options.dyRange, 2), min = _e[0], max = _e[1];
|
|
13721
13742
|
ny = clamp$1(ny, min, max);
|
|
13722
13743
|
if (ny !== min && ny !== max && min !== max) {
|
|
13723
|
-
(
|
|
13744
|
+
(_b = event.origin) === null || _b === void 0 ? void 0 : _b.preventDefault();
|
|
13724
13745
|
}
|
|
13725
13746
|
}
|
|
13726
13747
|
this.composition.camera.position = new Vector3(nx, ny, depth);
|
|
13727
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
|
+
};
|
|
13728
13753
|
return InteractVFXItem;
|
|
13729
13754
|
}(VFXItem));
|
|
13730
13755
|
function shouldIgnoreBouncing(arg, mul) {
|
|
@@ -24030,27 +24055,28 @@ var AssetManager = /** @class */ (function () {
|
|
|
24030
24055
|
AssetManager.prototype.loadScene = function (url, renderer, options) {
|
|
24031
24056
|
var _a, _b, _c;
|
|
24032
24057
|
return __awaiter(this, void 0, void 0, function () {
|
|
24033
|
-
var rawJSON, assetUrl, startTime,
|
|
24058
|
+
var rawJSON, assetUrl, startTime, timeInfoMessages, gpuInstance, asyncShaderCompile, compressedTexture, timeInfos, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
24034
24059
|
var _this = this;
|
|
24035
24060
|
return __generator(this, function (_d) {
|
|
24036
24061
|
assetUrl = isString(url) ? url : this.id;
|
|
24037
24062
|
startTime = performance.now();
|
|
24038
|
-
|
|
24063
|
+
timeInfoMessages = [];
|
|
24039
24064
|
gpuInstance = renderer === null || renderer === void 0 ? void 0 : renderer.engine.gpuCapability;
|
|
24040
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;
|
|
24041
24066
|
compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
|
|
24067
|
+
timeInfos = {};
|
|
24042
24068
|
cancelLoading = false;
|
|
24043
24069
|
waitPromise = new Promise(function (resolve, reject) {
|
|
24044
24070
|
loadTimer = window.setTimeout(function () {
|
|
24045
24071
|
cancelLoading = true;
|
|
24046
24072
|
_this.removeTimer(loadTimer);
|
|
24047
24073
|
var totalTime = performance.now() - startTime;
|
|
24048
|
-
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));
|
|
24049
24075
|
}, _this.timeout * 1000);
|
|
24050
24076
|
_this.timers.push(loadTimer);
|
|
24051
24077
|
});
|
|
24052
24078
|
hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
|
|
24053
|
-
var st, result, e_1;
|
|
24079
|
+
var st, result, time, e_1;
|
|
24054
24080
|
return __generator(this, function (_a) {
|
|
24055
24081
|
switch (_a.label) {
|
|
24056
24082
|
case 0:
|
|
@@ -24062,7 +24088,9 @@ var AssetManager = /** @class */ (function () {
|
|
|
24062
24088
|
return [4 /*yield*/, func()];
|
|
24063
24089
|
case 2:
|
|
24064
24090
|
result = _a.sent();
|
|
24065
|
-
|
|
24091
|
+
time = performance.now() - st;
|
|
24092
|
+
timeInfoMessages.push("[".concat(label, ": ").concat(time.toFixed(2), "]"));
|
|
24093
|
+
timeInfos[label] = time;
|
|
24066
24094
|
return [2 /*return*/, result];
|
|
24067
24095
|
case 3:
|
|
24068
24096
|
e_1 = _a.sent();
|
|
@@ -24121,7 +24149,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
24121
24149
|
return [4 /*yield*/, Promise.all([
|
|
24122
24150
|
hookTimeInfo('processBins', function () { return _this.processBins(bins_1); }),
|
|
24123
24151
|
hookTimeInfo('processImages', function () { return _this.processImages(images_2, usedImages_1, compressedTexture); }),
|
|
24124
|
-
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', "
|
|
24152
|
+
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', "Compile"), function () { return _this.precompile(compositions_1, pluginSystem_1, renderer, options); }),
|
|
24125
24153
|
])];
|
|
24126
24154
|
case 8:
|
|
24127
24155
|
_d = __read$3.apply(void 0, [_e.sent(), 2]), loadedBins_1 = _d[0], loadedImages_1 = _d[1];
|
|
@@ -24133,6 +24161,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
24133
24161
|
loadedTextures = _e.sent();
|
|
24134
24162
|
jsonScene_1.compositions = this.updateSceneData(jsonScene_1.compositions);
|
|
24135
24163
|
scene = {
|
|
24164
|
+
timeInfos: timeInfos,
|
|
24136
24165
|
url: url,
|
|
24137
24166
|
renderLevel: this.options.renderLevel,
|
|
24138
24167
|
storage: {},
|
|
@@ -24151,11 +24180,13 @@ var AssetManager = /** @class */ (function () {
|
|
|
24151
24180
|
_e.label = 12;
|
|
24152
24181
|
case 12:
|
|
24153
24182
|
totalTime = performance.now() - startTime;
|
|
24154
|
-
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));
|
|
24155
24184
|
window.clearTimeout(loadTimer);
|
|
24156
24185
|
this.removeTimer(loadTimer);
|
|
24157
24186
|
scene.totalTime = totalTime;
|
|
24158
24187
|
scene.startTime = startTime;
|
|
24188
|
+
// 各部分分段时长
|
|
24189
|
+
scene.timeInfos = timeInfos;
|
|
24159
24190
|
return [2 /*return*/, scene];
|
|
24160
24191
|
}
|
|
24161
24192
|
});
|
|
@@ -25003,7 +25034,7 @@ var Composition = /** @class */ (function () {
|
|
|
25003
25034
|
* @param props - composition 的创建参数
|
|
25004
25035
|
*/
|
|
25005
25036
|
function Composition(props, scene) {
|
|
25006
|
-
var _a;
|
|
25037
|
+
var _a, _b;
|
|
25007
25038
|
/**
|
|
25008
25039
|
* 动画播放速度
|
|
25009
25040
|
*/
|
|
@@ -25032,7 +25063,7 @@ var Composition = /** @class */ (function () {
|
|
|
25032
25063
|
this.paused = false;
|
|
25033
25064
|
this.lastVideoUpdateTime = 0;
|
|
25034
25065
|
this.postLoaders = [];
|
|
25035
|
-
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;
|
|
25036
25067
|
this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
|
|
25037
25068
|
scene.jsonScene.imgUsage = undefined;
|
|
25038
25069
|
if (reusable) {
|
|
@@ -25040,7 +25071,7 @@ var Composition = /** @class */ (function () {
|
|
|
25040
25071
|
scene.textures = undefined;
|
|
25041
25072
|
scene.consumed = true;
|
|
25042
25073
|
}
|
|
25043
|
-
var
|
|
25074
|
+
var _f = this.compositionSourceManager, sourceContent = _f.sourceContent, pluginSystem = _f.pluginSystem, imgUsage = _f.imgUsage, totalTime = _f.totalTime, renderLevel = _f.renderLevel, refCompositionProps = _f.refCompositionProps;
|
|
25044
25075
|
assertExist(sourceContent);
|
|
25045
25076
|
this.refCompositionProps = refCompositionProps;
|
|
25046
25077
|
var vfxItem = new CompVFXItem(sourceContent, this);
|
|
@@ -25057,7 +25088,7 @@ var Composition = /** @class */ (function () {
|
|
|
25057
25088
|
this.renderer = renderer;
|
|
25058
25089
|
this.texInfo = imageUsage !== null && imageUsage !== void 0 ? imageUsage : {};
|
|
25059
25090
|
this.event = event;
|
|
25060
|
-
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'] };
|
|
25061
25092
|
this.reusable = reusable;
|
|
25062
25093
|
this.speed = speed;
|
|
25063
25094
|
this.renderLevel = renderLevel;
|
|
@@ -27447,7 +27478,7 @@ Geometry.create = function (engine, options) {
|
|
|
27447
27478
|
Mesh.create = function (engine, props) {
|
|
27448
27479
|
return new ThreeMesh(engine, props);
|
|
27449
27480
|
};
|
|
27450
|
-
var version = "1.6.0-beta.
|
|
27481
|
+
var version = "1.6.0-beta.1";
|
|
27451
27482
|
logger.info('THREEJS plugin version: ' + version);
|
|
27452
27483
|
|
|
27453
27484
|
exports.AbstractPlugin = AbstractPlugin;
|