@galacean/effects-threejs 1.1.2 → 1.1.4
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 +112 -83
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +112 -83
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
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.1.
|
|
6
|
+
* Version: v1.1.4
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as THREE from 'three';
|
|
@@ -9325,11 +9325,9 @@ var Matrix4 = /** @class */ (function () {
|
|
|
9325
9325
|
var vX = Matrix4.tempVec0;
|
|
9326
9326
|
var vY = Matrix4.tempVec1;
|
|
9327
9327
|
var vZ = Matrix4.tempVec2;
|
|
9328
|
-
vZ.subtractVectors(
|
|
9328
|
+
vZ.subtractVectors(eye, target);
|
|
9329
9329
|
vZ.normalize();
|
|
9330
|
-
|
|
9331
|
-
vY.normalize();
|
|
9332
|
-
vX.crossVectors(vY, vZ);
|
|
9330
|
+
vX.crossVectors(up, vZ);
|
|
9333
9331
|
vX.normalize();
|
|
9334
9332
|
vY.crossVectors(vZ, vX);
|
|
9335
9333
|
var te = this.elements;
|
|
@@ -14733,6 +14731,9 @@ var VFXItem = /** @class */ (function () {
|
|
|
14733
14731
|
VFXItem.isTree = function (item) {
|
|
14734
14732
|
return item.type === ItemType$1.tree;
|
|
14735
14733
|
};
|
|
14734
|
+
VFXItem.isCamera = function (item) {
|
|
14735
|
+
return item.type === ItemType$1.camera;
|
|
14736
|
+
};
|
|
14736
14737
|
VFXItem.isExtraCamera = function (item) {
|
|
14737
14738
|
return item.id === 'extra-camera' && item.name === 'extra-camera';
|
|
14738
14739
|
};
|
|
@@ -14933,10 +14934,11 @@ var VFXItem = /** @class */ (function () {
|
|
|
14933
14934
|
}
|
|
14934
14935
|
else if (this.endBehavior === END_BEHAVIOR_DESTROY$1) {
|
|
14935
14936
|
this._contentVisible = false;
|
|
14937
|
+
shouldUpdate = true;
|
|
14938
|
+
dt = 0;
|
|
14936
14939
|
// 预合成配置 reusable 且销毁时, 需要隐藏其中的元素
|
|
14937
14940
|
if (this.type === ItemType$1.composition) {
|
|
14938
14941
|
this.handleVisibleChanged(false);
|
|
14939
|
-
this.onItemUpdate(0, lifetime);
|
|
14940
14942
|
}
|
|
14941
14943
|
}
|
|
14942
14944
|
lifetime = Math.min(lifetime, 1);
|
|
@@ -15520,10 +15522,6 @@ var CameraVFXItem = /** @class */ (function (_super) {
|
|
|
15520
15522
|
(_a = this.controller) === null || _a === void 0 ? void 0 : _a.update(lifetime);
|
|
15521
15523
|
this.updateCamera();
|
|
15522
15524
|
};
|
|
15523
|
-
// override onEnd () {
|
|
15524
|
-
// this.controller?.update(1);
|
|
15525
|
-
// this.updateCamera();
|
|
15526
|
-
// }
|
|
15527
15525
|
CameraVFXItem.prototype.updateCamera = function () {
|
|
15528
15526
|
if (this.controller && this.composition) {
|
|
15529
15527
|
var camera = this.composition.camera;
|
|
@@ -16018,7 +16016,7 @@ function loadImage(source) {
|
|
|
16018
16016
|
}
|
|
16019
16017
|
// 2. 非法类型
|
|
16020
16018
|
if (!url) {
|
|
16021
|
-
throw new Error("Invalid url type: ".concat(source));
|
|
16019
|
+
throw new Error("Invalid url type: ".concat(JSON.stringify(source)));
|
|
16022
16020
|
}
|
|
16023
16021
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
16024
16022
|
var img = new Image();
|
|
@@ -16037,7 +16035,7 @@ function loadImage(source) {
|
|
|
16037
16035
|
if (revokeURL) {
|
|
16038
16036
|
URL.revokeObjectURL(url);
|
|
16039
16037
|
}
|
|
16040
|
-
return reject("Load image fail: ".concat(e));
|
|
16038
|
+
return reject("Load image fail: ".concat(JSON.stringify(e)));
|
|
16041
16039
|
};
|
|
16042
16040
|
img.src = url;
|
|
16043
16041
|
})];
|
|
@@ -23568,7 +23566,7 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23568
23566
|
configurable: true
|
|
23569
23567
|
});
|
|
23570
23568
|
ParticleSystem.prototype.updateEmitterTransform = function (time) {
|
|
23571
|
-
var parentTransform = this.parentTransform;
|
|
23569
|
+
var parentTransform = this.transform.parentTransform;
|
|
23572
23570
|
var _a = this.basicTransform, path = _a.path, position = _a.position;
|
|
23573
23571
|
var selfPos = position.clone();
|
|
23574
23572
|
if (path) {
|
|
@@ -23578,9 +23576,9 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23578
23576
|
this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
|
|
23579
23577
|
if (this.options.particleFollowParent && parentTransform) {
|
|
23580
23578
|
var tempMatrix = parentTransform.getWorldMatrix();
|
|
23581
|
-
this.particleMesh.mesh.worldMatrix = tempMatrix
|
|
23579
|
+
this.particleMesh.mesh.worldMatrix = tempMatrix;
|
|
23582
23580
|
if (this.trailMesh) {
|
|
23583
|
-
this.trailMesh.mesh.worldMatrix = tempMatrix
|
|
23581
|
+
this.trailMesh.mesh.worldMatrix = tempMatrix;
|
|
23584
23582
|
}
|
|
23585
23583
|
}
|
|
23586
23584
|
};
|
|
@@ -23599,8 +23597,8 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23599
23597
|
link.pushNode(linkContent);
|
|
23600
23598
|
this.particleMesh.setPoint(point, pointIndex);
|
|
23601
23599
|
this.clearPointTrail(pointIndex);
|
|
23602
|
-
if (this.
|
|
23603
|
-
this.trailMesh.setPointStartPos(pointIndex, this.parentTransform.position.clone());
|
|
23600
|
+
if (this.trailMesh) {
|
|
23601
|
+
this.trailMesh.setPointStartPos(pointIndex, this.transform.parentTransform.position.clone());
|
|
23604
23602
|
}
|
|
23605
23603
|
};
|
|
23606
23604
|
ParticleSystem.prototype.setVisible = function (visible) {
|
|
@@ -23638,7 +23636,8 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23638
23636
|
}
|
|
23639
23637
|
};
|
|
23640
23638
|
ParticleSystem.prototype.setParentTransform = function (transform) {
|
|
23641
|
-
this.parentTransform = transform;
|
|
23639
|
+
// this.transform.parentTransform = transform;
|
|
23640
|
+
// this.parentTransform = transform;
|
|
23642
23641
|
};
|
|
23643
23642
|
ParticleSystem.prototype.getTextures = function () {
|
|
23644
23643
|
var e_1, _a, e_2, _b;
|
|
@@ -23931,8 +23930,8 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23931
23930
|
if (trails.sizeAffectsLifetime) {
|
|
23932
23931
|
lifetime *= size[0];
|
|
23933
23932
|
}
|
|
23934
|
-
if (trails.parentAffectsPosition && this.parentTransform) {
|
|
23935
|
-
position.add(this.parentTransform.position);
|
|
23933
|
+
if (trails.parentAffectsPosition && this.transform.parentTransform) {
|
|
23934
|
+
position.add(this.transform.parentTransform.position);
|
|
23936
23935
|
var pos = this.trailMesh.getPointStartPos(pointIndex);
|
|
23937
23936
|
if (pos) {
|
|
23938
23937
|
position.subtract(pos);
|
|
@@ -24172,12 +24171,11 @@ var ParticleVFXItem = /** @class */ (function (_super) {
|
|
|
24172
24171
|
ParticleVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
|
|
24173
24172
|
var _a;
|
|
24174
24173
|
if (this.content) {
|
|
24175
|
-
var hide = !this.
|
|
24174
|
+
var hide = !this.visible;
|
|
24176
24175
|
var parentItem = this.parentId && ((_a = this.composition) === null || _a === void 0 ? void 0 : _a.getItemByID(this.parentId));
|
|
24177
24176
|
if (!hide && parentItem) {
|
|
24178
24177
|
var parentData = parentItem.getRenderData();
|
|
24179
24178
|
if (parentData) {
|
|
24180
|
-
this.content.setParentTransform(parentData.transform);
|
|
24181
24179
|
if (!parentData.visible) {
|
|
24182
24180
|
hide = false;
|
|
24183
24181
|
}
|
|
@@ -29180,7 +29178,6 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29180
29178
|
}
|
|
29181
29179
|
var cachedTextures = textureOptions.map(function (option) { return option && (option instanceof Texture ? option : Texture.create(engine, option)); });
|
|
29182
29180
|
// 缓存创建的Texture对象
|
|
29183
|
-
// @ts-expect-error
|
|
29184
29181
|
scene.textureOptions = cachedTextures;
|
|
29185
29182
|
cachedTextures === null || cachedTextures === void 0 ? void 0 : cachedTextures.forEach(function (tex) { return tex === null || tex === void 0 ? void 0 : tex.initialize(); });
|
|
29186
29183
|
try {
|
|
@@ -29234,7 +29231,6 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29234
29231
|
CompositionSourceManager.prototype.assembleItems = function (composition) {
|
|
29235
29232
|
var _this = this;
|
|
29236
29233
|
var items = [];
|
|
29237
|
-
this.mask++;
|
|
29238
29234
|
composition.items.forEach(function (item) {
|
|
29239
29235
|
var _a;
|
|
29240
29236
|
var option = {};
|
|
@@ -29250,9 +29246,7 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29250
29246
|
option.type = type;
|
|
29251
29247
|
if (renderContent.renderer) {
|
|
29252
29248
|
renderContent.renderer = _this.changeTex(renderContent.renderer);
|
|
29253
|
-
|
|
29254
|
-
_this.processMask(renderContent.renderer, _this.mask);
|
|
29255
|
-
}
|
|
29249
|
+
_this.processMask(renderContent.renderer);
|
|
29256
29250
|
var split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
|
|
29257
29251
|
if (Number.isInteger(renderContent.renderer.shape)) {
|
|
29258
29252
|
// TODO: scene.shapes 类型问题?
|
|
@@ -29297,7 +29291,7 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29297
29291
|
}
|
|
29298
29292
|
// 处理预合成的渲染顺序
|
|
29299
29293
|
if (option.type === ItemType$1.composition) {
|
|
29300
|
-
|
|
29294
|
+
++_this.mask;
|
|
29301
29295
|
var refId = item.content.options.refId;
|
|
29302
29296
|
if (!_this.refCompositions.get(refId)) {
|
|
29303
29297
|
throw new Error('Invalid Ref Composition id: ' + refId);
|
|
@@ -29308,7 +29302,7 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29308
29302
|
}
|
|
29309
29303
|
ref.items.forEach(function (item) {
|
|
29310
29304
|
item.listIndex = listOrder++;
|
|
29311
|
-
_this.processMask(item.content
|
|
29305
|
+
_this.processMask(item.content);
|
|
29312
29306
|
});
|
|
29313
29307
|
option.items = ref.items;
|
|
29314
29308
|
}
|
|
@@ -29347,11 +29341,17 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29347
29341
|
/**
|
|
29348
29342
|
* 处理蒙版和遮挡关系写入 stencil 的 ref 值
|
|
29349
29343
|
*/
|
|
29350
|
-
CompositionSourceManager.prototype.processMask = function (renderer
|
|
29344
|
+
CompositionSourceManager.prototype.processMask = function (renderer) {
|
|
29345
|
+
if (renderer.maskMode === MaskMode$1.NONE) {
|
|
29346
|
+
return;
|
|
29347
|
+
}
|
|
29351
29348
|
if (!renderer.mask) {
|
|
29352
29349
|
var maskMode = renderer.maskMode;
|
|
29353
|
-
if (maskMode
|
|
29354
|
-
renderer.mask =
|
|
29350
|
+
if (maskMode === MaskMode$1.MASK) {
|
|
29351
|
+
renderer.mask = ++this.mask;
|
|
29352
|
+
}
|
|
29353
|
+
else if (maskMode === MaskMode$1.OBSCURED || maskMode === MaskMode$1.REVERSE_OBSCURED) {
|
|
29354
|
+
renderer.mask = this.mask;
|
|
29355
29355
|
}
|
|
29356
29356
|
}
|
|
29357
29357
|
};
|
|
@@ -29407,29 +29407,29 @@ var AssetManager = /** @class */ (function () {
|
|
|
29407
29407
|
this.timeout = timeout;
|
|
29408
29408
|
};
|
|
29409
29409
|
/**
|
|
29410
|
-
*
|
|
29411
|
-
* 通过 json 创建出场景对象,并进行提前编译等工作
|
|
29410
|
+
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
29412
29411
|
* @param url - json 的 URL 链接或者 json 对象
|
|
29413
29412
|
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
29414
29413
|
* @param options - 扩展参数
|
|
29415
29414
|
* @returns
|
|
29416
29415
|
*/
|
|
29417
29416
|
AssetManager.prototype.loadScene = function (url, renderer, options) {
|
|
29418
|
-
var _a, _b;
|
|
29417
|
+
var _a, _b, _c;
|
|
29419
29418
|
return __awaiter(this, void 0, void 0, function () {
|
|
29420
|
-
var rawJSON, timeLabel, startTime, timeInfos, gpuInstance, asyncShaderCompile, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
29419
|
+
var rawJSON, timeLabel, startTime, timeInfos, gpuInstance, asyncShaderCompile, compressedTexture, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
29421
29420
|
var _this = this;
|
|
29422
|
-
return __generator(this, function (
|
|
29421
|
+
return __generator(this, function (_d) {
|
|
29423
29422
|
timeLabel = "Load asset: ".concat(isString(url) ? url : this.id);
|
|
29424
29423
|
startTime = performance.now();
|
|
29425
29424
|
timeInfos = [];
|
|
29426
29425
|
gpuInstance = renderer === null || renderer === void 0 ? void 0 : renderer.engine.gpuCapability;
|
|
29427
29426
|
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;
|
|
29427
|
+
compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
|
|
29428
29428
|
cancelLoading = false;
|
|
29429
29429
|
waitPromise = new Promise(function (resolve, reject) {
|
|
29430
29430
|
return loadTimer = window.setTimeout(function () {
|
|
29431
29431
|
cancelLoading = true;
|
|
29432
|
-
reject("Load time out: ".concat(url));
|
|
29432
|
+
reject("Load time out: ".concat(JSON.stringify(url)));
|
|
29433
29433
|
}, _this.timeout * 1000);
|
|
29434
29434
|
});
|
|
29435
29435
|
hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -29449,10 +29449,10 @@ var AssetManager = /** @class */ (function () {
|
|
|
29449
29449
|
});
|
|
29450
29450
|
}); };
|
|
29451
29451
|
loadResourcePromise = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
29452
|
-
var
|
|
29452
|
+
var scene, rawImages, images_1, i, _a, i, _b, usedImages_1, jsonScene_1, pluginSystem_1, _c, bins_1, images_2, compositions_1, fonts_1, _d, loadedBins_1, loadedImages_1, loadedTextures, totalTime;
|
|
29453
29453
|
var _this = this;
|
|
29454
|
-
return __generator(this, function (
|
|
29455
|
-
switch (
|
|
29454
|
+
return __generator(this, function (_e) {
|
|
29455
|
+
switch (_e.label) {
|
|
29456
29456
|
case 0:
|
|
29457
29457
|
if (!isObject(url)) return [3 /*break*/, 1];
|
|
29458
29458
|
// TODO: 原 JSONLoader contructor 判断是否兼容
|
|
@@ -29465,42 +29465,66 @@ var AssetManager = /** @class */ (function () {
|
|
|
29465
29465
|
this.baseUrl = url;
|
|
29466
29466
|
return [4 /*yield*/, hookTimeInfo('loadJSON', function () { return _this.loadJSON(url); })];
|
|
29467
29467
|
case 2:
|
|
29468
|
-
rawJSON =
|
|
29469
|
-
|
|
29470
|
-
case 3:
|
|
29468
|
+
rawJSON = _e.sent();
|
|
29469
|
+
_e.label = 3;
|
|
29470
|
+
case 3:
|
|
29471
|
+
if (!isScene(rawJSON)) return [3 /*break*/, 6];
|
|
29472
|
+
// 已经加载过的 可能需要更新数据模板
|
|
29473
|
+
scene = __assign$1({}, rawJSON);
|
|
29474
|
+
if (!(this.options && this.options.variables && Object.keys(this.options.variables).length !== 0)) return [3 /*break*/, 5];
|
|
29475
|
+
rawImages = rawJSON.jsonScene.images;
|
|
29476
|
+
images_1 = scene.images;
|
|
29477
|
+
for (i = 0; i < rawImages.length; i++) {
|
|
29478
|
+
// 仅重新加载数据模板对应的图片
|
|
29479
|
+
if (images_1[i] instanceof HTMLCanvasElement) {
|
|
29480
|
+
images_1[i] = rawImages[i];
|
|
29481
|
+
}
|
|
29482
|
+
}
|
|
29483
|
+
_a = scene;
|
|
29484
|
+
return [4 /*yield*/, hookTimeInfo('processImages', function () { return _this.processImages(images_1, scene.usedImages, compressedTexture); })];
|
|
29471
29485
|
case 4:
|
|
29472
|
-
_a =
|
|
29473
|
-
|
|
29486
|
+
_a.images = _e.sent();
|
|
29487
|
+
// 更新 TextureOptions 中的 image 指向
|
|
29488
|
+
for (i = 0; i < scene.images.length; i++) {
|
|
29489
|
+
scene.textureOptions[i].image = scene.images[i];
|
|
29490
|
+
}
|
|
29491
|
+
_e.label = 5;
|
|
29492
|
+
case 5: return [3 /*break*/, 12];
|
|
29493
|
+
case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
|
|
29494
|
+
case 7:
|
|
29495
|
+
_b = _e.sent(), usedImages_1 = _b.usedImages, jsonScene_1 = _b.jsonScene, pluginSystem_1 = _b.pluginSystem;
|
|
29496
|
+
_c = jsonScene_1.bins, bins_1 = _c === void 0 ? [] : _c, images_2 = jsonScene_1.images, compositions_1 = jsonScene_1.compositions, fonts_1 = jsonScene_1.fonts;
|
|
29474
29497
|
return [4 /*yield*/, Promise.all([
|
|
29475
|
-
hookTimeInfo('processBins', function () { return _this.processBins(
|
|
29476
|
-
hookTimeInfo('processImages', function () {
|
|
29477
|
-
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(
|
|
29498
|
+
hookTimeInfo('processBins', function () { return _this.processBins(bins_1); }),
|
|
29499
|
+
hookTimeInfo('processImages', function () { return _this.processImages(images_2, usedImages_1, compressedTexture); }),
|
|
29500
|
+
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(compositions_1, pluginSystem_1, renderer, options); }),
|
|
29478
29501
|
])];
|
|
29479
|
-
case
|
|
29480
|
-
|
|
29481
|
-
return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(
|
|
29482
|
-
case
|
|
29483
|
-
|
|
29484
|
-
return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(
|
|
29485
|
-
case
|
|
29486
|
-
loadedTextures =
|
|
29502
|
+
case 8:
|
|
29503
|
+
_d = __read$3.apply(void 0, [_e.sent(), 2]), loadedBins_1 = _d[0], loadedImages_1 = _d[1];
|
|
29504
|
+
return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(fonts_1); })];
|
|
29505
|
+
case 9:
|
|
29506
|
+
_e.sent();
|
|
29507
|
+
return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
|
|
29508
|
+
case 10:
|
|
29509
|
+
loadedTextures = _e.sent();
|
|
29487
29510
|
scene = {
|
|
29488
|
-
jsonScene: jsonScene,
|
|
29489
|
-
images: loadedImages,
|
|
29490
|
-
textureOptions: loadedTextures,
|
|
29491
|
-
bins: loadedBins,
|
|
29492
|
-
storage: {},
|
|
29493
|
-
pluginSystem: this.pluginSystem,
|
|
29494
|
-
renderLevel: this.options.renderLevel,
|
|
29495
|
-
totalTime: 0,
|
|
29496
|
-
startTime: 0,
|
|
29497
29511
|
url: url,
|
|
29512
|
+
renderLevel: this.options.renderLevel,
|
|
29513
|
+
storage: {},
|
|
29514
|
+
pluginSystem: pluginSystem_1,
|
|
29515
|
+
jsonScene: jsonScene_1,
|
|
29516
|
+
usedImages: usedImages_1,
|
|
29517
|
+
images: loadedImages_1,
|
|
29518
|
+
textureOptions: loadedTextures,
|
|
29519
|
+
bins: loadedBins_1,
|
|
29498
29520
|
};
|
|
29499
29521
|
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
29500
|
-
return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return
|
|
29501
|
-
case
|
|
29522
|
+
return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return pluginSystem_1.loadResources(scene, _this.options); })];
|
|
29523
|
+
case 11:
|
|
29502
29524
|
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
29503
|
-
|
|
29525
|
+
_e.sent();
|
|
29526
|
+
_e.label = 12;
|
|
29527
|
+
case 12:
|
|
29504
29528
|
totalTime = performance.now() - startTime;
|
|
29505
29529
|
console.info({
|
|
29506
29530
|
content: "".concat(timeLabel, ": ").concat(totalTime.toFixed(4), "ms, ").concat(timeInfos.join(' ')),
|
|
@@ -29517,7 +29541,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29517
29541
|
});
|
|
29518
29542
|
});
|
|
29519
29543
|
};
|
|
29520
|
-
AssetManager.prototype.precompile = function (compositions, renderer, options) {
|
|
29544
|
+
AssetManager.prototype.precompile = function (compositions, pluginSystem, renderer, options) {
|
|
29521
29545
|
return __awaiter(this, void 0, void 0, function () {
|
|
29522
29546
|
var shaderLibrary;
|
|
29523
29547
|
return __generator(this, function (_a) {
|
|
@@ -29527,7 +29551,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29527
29551
|
return [2 /*return*/];
|
|
29528
29552
|
}
|
|
29529
29553
|
shaderLibrary = renderer === null || renderer === void 0 ? void 0 : renderer.getShaderLibrary();
|
|
29530
|
-
return [4 /*yield*/,
|
|
29554
|
+
return [4 /*yield*/, (pluginSystem === null || pluginSystem === void 0 ? void 0 : pluginSystem.precompile(compositions, renderer, options))];
|
|
29531
29555
|
case 1:
|
|
29532
29556
|
_a.sent();
|
|
29533
29557
|
return [4 /*yield*/, new Promise(function (resolve) {
|
|
@@ -29544,7 +29568,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29544
29568
|
};
|
|
29545
29569
|
AssetManager.prototype.processJSON = function (json) {
|
|
29546
29570
|
return __awaiter(this, void 0, void 0, function () {
|
|
29547
|
-
var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, renderLevel, usedImages;
|
|
29571
|
+
var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, pluginSystem, renderLevel, usedImages;
|
|
29548
29572
|
return __generator(this, function (_b) {
|
|
29549
29573
|
switch (_b.label) {
|
|
29550
29574
|
case 0:
|
|
@@ -29558,8 +29582,8 @@ var AssetManager = /** @class */ (function () {
|
|
|
29558
29582
|
}
|
|
29559
29583
|
});
|
|
29560
29584
|
_a = jsonScene.plugins, plugins = _a === void 0 ? [] : _a, sceneCompositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, images = jsonScene.images;
|
|
29561
|
-
|
|
29562
|
-
return [4 /*yield*/,
|
|
29585
|
+
pluginSystem = new PluginSystem(plugins);
|
|
29586
|
+
return [4 /*yield*/, pluginSystem.processRawJSON(jsonScene, this.options)];
|
|
29563
29587
|
case 1:
|
|
29564
29588
|
_b.sent();
|
|
29565
29589
|
renderLevel = this.options.renderLevel;
|
|
@@ -29576,6 +29600,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29576
29600
|
return [2 /*return*/, {
|
|
29577
29601
|
usedImages: usedImages,
|
|
29578
29602
|
jsonScene: jsonScene,
|
|
29603
|
+
pluginSystem: pluginSystem,
|
|
29579
29604
|
}];
|
|
29580
29605
|
}
|
|
29581
29606
|
});
|
|
@@ -29594,7 +29619,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29594
29619
|
if (passRenderLevel(bin.renderLevel, renderLevel)) {
|
|
29595
29620
|
return _this.loadBins(bin.url);
|
|
29596
29621
|
}
|
|
29597
|
-
throw new Error("Invalid bins source: ".concat(bins));
|
|
29622
|
+
throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
|
|
29598
29623
|
});
|
|
29599
29624
|
return [2 /*return*/, Promise.all(jobs)];
|
|
29600
29625
|
});
|
|
@@ -29630,7 +29655,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29630
29655
|
case 3:
|
|
29631
29656
|
_b.sent();
|
|
29632
29657
|
console.warn({
|
|
29633
|
-
content: "Invalid fonts source: ".concat(font.fontURL),
|
|
29658
|
+
content: "Invalid fonts source: ".concat(JSON.stringify(font.fontURL)),
|
|
29634
29659
|
type: LOG_TYPE,
|
|
29635
29660
|
});
|
|
29636
29661
|
return [3 /*break*/, 4];
|
|
@@ -29799,7 +29824,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29799
29824
|
return __generator(this, function (_a) {
|
|
29800
29825
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
29801
29826
|
_this.downloader.downloadJSON(url, resolve, function (status, responseText) {
|
|
29802
|
-
reject("Couldn't load JSON ".concat(url, ": status ").concat(status, ", ").concat(responseText));
|
|
29827
|
+
reject("Couldn't load JSON ".concat(JSON.stringify(url), ": status ").concat(status, ", ").concat(responseText));
|
|
29803
29828
|
});
|
|
29804
29829
|
})];
|
|
29805
29830
|
});
|
|
@@ -29811,7 +29836,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29811
29836
|
return __generator(this, function (_a) {
|
|
29812
29837
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
29813
29838
|
_this.downloader.downloadBinary(url, resolve, function (status, responseText) {
|
|
29814
|
-
reject("Couldn't load bins ".concat(url, ": status ").concat(status, ", ").concat(responseText));
|
|
29839
|
+
reject("Couldn't load bins ".concat(JSON.stringify(url), ": status ").concat(status, ", ").concat(responseText));
|
|
29815
29840
|
});
|
|
29816
29841
|
})];
|
|
29817
29842
|
});
|
|
@@ -29959,7 +29984,8 @@ var CompVFXItem = /** @class */ (function (_super) {
|
|
|
29959
29984
|
}
|
|
29960
29985
|
else {
|
|
29961
29986
|
item = createVFXItem(this.itemProps[i], this.composition);
|
|
29962
|
-
|
|
29987
|
+
// 相机不跟随合成移动
|
|
29988
|
+
item.transform.parentTransform = VFXItem.isCamera(item) ? new Transform() : this.transform;
|
|
29963
29989
|
}
|
|
29964
29990
|
if (VFXItem.isExtraCamera(item)) {
|
|
29965
29991
|
this.extraCamera = item;
|
|
@@ -30145,7 +30171,7 @@ var CompVFXItem = /** @class */ (function (_super) {
|
|
|
30145
30171
|
if (!parentItem) {
|
|
30146
30172
|
itemNode.parentId = undefined;
|
|
30147
30173
|
item.parent = undefined;
|
|
30148
|
-
item.transform.parentTransform = this.transform;
|
|
30174
|
+
item.transform.parentTransform = VFXItem.isExtraCamera(item) ? new Transform() : this.transform;
|
|
30149
30175
|
}
|
|
30150
30176
|
else {
|
|
30151
30177
|
var parentNode = this.itemCacheMap.get(parentItem.id);
|
|
@@ -31157,7 +31183,10 @@ var Ticker = /** @class */ (function () {
|
|
|
31157
31183
|
};
|
|
31158
31184
|
Ticker.prototype.setFPS = function (fps) {
|
|
31159
31185
|
this.targetFPS = clamp$1(fps, 1, 120);
|
|
31160
|
-
|
|
31186
|
+
// 注意:-2 的原因是保证帧率稳定
|
|
31187
|
+
// interval 在 fps 为 60 的时候设成 15 累计误差会很大,设成 14 较稳定
|
|
31188
|
+
// requestanimationFrame 在不同的刷新率下时间间隔不一样,120hz 的误差在 8 以内,60hz 的误差在 16 以内
|
|
31189
|
+
this.interval = Math.floor(1000 / fps) - 2;
|
|
31161
31190
|
};
|
|
31162
31191
|
/**
|
|
31163
31192
|
* 获取定时器暂停标志位
|
|
@@ -32757,9 +32786,9 @@ Geometry.create = function (engine, options) {
|
|
|
32757
32786
|
Mesh.create = function (engine, props) {
|
|
32758
32787
|
return new ThreeMesh(engine, props);
|
|
32759
32788
|
};
|
|
32760
|
-
var version = "1.1.
|
|
32789
|
+
var version = "1.1.4";
|
|
32761
32790
|
console.info({
|
|
32762
|
-
content: '[Galacean Effects THREEJS] version: ' + "1.1.
|
|
32791
|
+
content: '[Galacean Effects THREEJS] version: ' + "1.1.4",
|
|
32763
32792
|
type: LOG_TYPE,
|
|
32764
32793
|
});
|
|
32765
32794
|
|