@galacean/effects-core 1.1.3 → 1.1.5
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/asset-manager.d.ts +2 -7
- package/dist/composition.d.ts +15 -2
- package/dist/index.js +128 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +128 -75
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-system.d.ts +1 -1
- package/dist/plugins/particle/particle-system.d.ts +1 -3
- package/dist/scene.d.ts +3 -2
- package/dist/vfx-item.d.ts +1 -0
- package/package.json +1 -1
package/dist/asset-manager.d.ts
CHANGED
|
@@ -84,10 +84,6 @@ export declare class AssetManager implements Disposable {
|
|
|
84
84
|
* 相对url的基本路径
|
|
85
85
|
*/
|
|
86
86
|
private baseUrl;
|
|
87
|
-
/**
|
|
88
|
-
* 插件系统
|
|
89
|
-
*/
|
|
90
|
-
private pluginSystem;
|
|
91
87
|
/**
|
|
92
88
|
* 图像资源,用于创建和释放GPU纹理资源
|
|
93
89
|
*/
|
|
@@ -110,14 +106,13 @@ export declare class AssetManager implements Disposable {
|
|
|
110
106
|
constructor(options?: SceneLoadOptions, downloader?: Downloader);
|
|
111
107
|
updateOptions(options?: SceneLoadOptions): void;
|
|
112
108
|
/**
|
|
113
|
-
*
|
|
114
|
-
* 通过 json 创建出场景对象,并进行提前编译等工作
|
|
109
|
+
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
115
110
|
* @param url - json 的 URL 链接或者 json 对象
|
|
116
111
|
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
117
112
|
* @param options - 扩展参数
|
|
118
113
|
* @returns
|
|
119
114
|
*/
|
|
120
|
-
loadScene(url: string | JSONValue, renderer?: Renderer, options?: {
|
|
115
|
+
loadScene(url: string | JSONValue | Scene, renderer?: Renderer, options?: {
|
|
121
116
|
env: string;
|
|
122
117
|
}): Promise<Scene>;
|
|
123
118
|
private precompile;
|
package/dist/composition.d.ts
CHANGED
|
@@ -186,7 +186,7 @@ export declare class Composition implements Disposable, LostHandler {
|
|
|
186
186
|
*/
|
|
187
187
|
get items(): VFXItem<VFXItemContent>[];
|
|
188
188
|
/**
|
|
189
|
-
*
|
|
189
|
+
* 获取合成开始渲染的时间
|
|
190
190
|
*/
|
|
191
191
|
get startTime(): number;
|
|
192
192
|
/**
|
|
@@ -234,7 +234,15 @@ export declare class Composition implements Disposable, LostHandler {
|
|
|
234
234
|
* 恢复合成的播放
|
|
235
235
|
*/
|
|
236
236
|
resume(): void;
|
|
237
|
+
/**
|
|
238
|
+
* 跳转合成到指定时间播放
|
|
239
|
+
* @param time - 相对 startTime 的时间
|
|
240
|
+
*/
|
|
237
241
|
gotoAndPlay(time: number): void;
|
|
242
|
+
/**
|
|
243
|
+
* 跳转合成到指定时间并暂停
|
|
244
|
+
* @param time - 相对 startTime 的时间
|
|
245
|
+
*/
|
|
238
246
|
gotoAndStop(time: number): void;
|
|
239
247
|
/**
|
|
240
248
|
*
|
|
@@ -242,9 +250,14 @@ export declare class Composition implements Disposable, LostHandler {
|
|
|
242
250
|
createRenderFrame(): void;
|
|
243
251
|
/**
|
|
244
252
|
* 跳到指定时间点(不做任何播放行为)
|
|
245
|
-
* @param time -
|
|
253
|
+
* @param time - 相对 startTime 的时间
|
|
246
254
|
*/
|
|
247
255
|
setTime(time: number): void;
|
|
256
|
+
/**
|
|
257
|
+
* 前进合成到指定时间
|
|
258
|
+
* @param time - 相对0时刻的时间
|
|
259
|
+
* @param skipRender - 是否跳过渲染
|
|
260
|
+
*/
|
|
248
261
|
private forwardTime;
|
|
249
262
|
/**
|
|
250
263
|
* 重置状态函数
|
package/dist/index.js
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.1.
|
|
6
|
+
* Version: v1.1.5
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -14733,6 +14733,9 @@ var VFXItem = /** @class */ (function () {
|
|
|
14733
14733
|
VFXItem.isTree = function (item) {
|
|
14734
14734
|
return item.type === ItemType$1.tree;
|
|
14735
14735
|
};
|
|
14736
|
+
VFXItem.isCamera = function (item) {
|
|
14737
|
+
return item.type === ItemType$1.camera;
|
|
14738
|
+
};
|
|
14736
14739
|
VFXItem.isExtraCamera = function (item) {
|
|
14737
14740
|
return item.id === 'extra-camera' && item.name === 'extra-camera';
|
|
14738
14741
|
};
|
|
@@ -14933,10 +14936,11 @@ var VFXItem = /** @class */ (function () {
|
|
|
14933
14936
|
}
|
|
14934
14937
|
else if (this.endBehavior === END_BEHAVIOR_DESTROY$1) {
|
|
14935
14938
|
this._contentVisible = false;
|
|
14939
|
+
shouldUpdate = true;
|
|
14940
|
+
dt = 0;
|
|
14936
14941
|
// 预合成配置 reusable 且销毁时, 需要隐藏其中的元素
|
|
14937
14942
|
if (this.type === ItemType$1.composition) {
|
|
14938
14943
|
this.handleVisibleChanged(false);
|
|
14939
|
-
this.onItemUpdate(0, lifetime);
|
|
14940
14944
|
}
|
|
14941
14945
|
}
|
|
14942
14946
|
lifetime = Math.min(lifetime, 1);
|
|
@@ -14945,7 +14949,6 @@ var VFXItem = /** @class */ (function () {
|
|
|
14945
14949
|
shouldUpdate = true;
|
|
14946
14950
|
if (this.endBehavior === END_BEHAVIOR_RESTART$1) {
|
|
14947
14951
|
this.ended = true;
|
|
14948
|
-
lifetime = lifetime % 1;
|
|
14949
14952
|
}
|
|
14950
14953
|
}
|
|
14951
14954
|
}
|
|
@@ -14953,7 +14956,7 @@ var VFXItem = /** @class */ (function () {
|
|
|
14953
14956
|
this.setVisible(true);
|
|
14954
14957
|
this.callEnd = false;
|
|
14955
14958
|
}
|
|
14956
|
-
this.lifetime = lifetime;
|
|
14959
|
+
this.lifetime = lifetime % 1;
|
|
14957
14960
|
shouldUpdate && this.onItemUpdate(dt, lifetime);
|
|
14958
14961
|
}
|
|
14959
14962
|
}
|
|
@@ -15520,10 +15523,6 @@ var CameraVFXItem = /** @class */ (function (_super) {
|
|
|
15520
15523
|
(_a = this.controller) === null || _a === void 0 ? void 0 : _a.update(lifetime);
|
|
15521
15524
|
this.updateCamera();
|
|
15522
15525
|
};
|
|
15523
|
-
// override onEnd () {
|
|
15524
|
-
// this.controller?.update(1);
|
|
15525
|
-
// this.updateCamera();
|
|
15526
|
-
// }
|
|
15527
15526
|
CameraVFXItem.prototype.updateCamera = function () {
|
|
15528
15527
|
if (this.controller && this.composition) {
|
|
15529
15528
|
var camera = this.composition.camera;
|
|
@@ -19280,19 +19279,28 @@ var SpriteMesh = /** @class */ (function () {
|
|
|
19280
19279
|
var aPointLen = 0;
|
|
19281
19280
|
var indexLen = 0;
|
|
19282
19281
|
var pointCount = 0;
|
|
19282
|
+
var renderInfo;
|
|
19283
19283
|
if (!items.length) {
|
|
19284
19284
|
this.mesh.setVisible(false);
|
|
19285
19285
|
return true;
|
|
19286
19286
|
}
|
|
19287
|
+
for (var i = 0; i < items.length; i++) {
|
|
19288
|
+
if (items[i].renderInfo) {
|
|
19289
|
+
renderInfo = items[i].renderInfo;
|
|
19290
|
+
break;
|
|
19291
|
+
}
|
|
19292
|
+
}
|
|
19293
|
+
if (!renderInfo) {
|
|
19294
|
+
return true;
|
|
19295
|
+
}
|
|
19287
19296
|
this.items = items.slice();
|
|
19288
19297
|
if (items.length > 2) {
|
|
19289
19298
|
itemSlot = exports.maxSpriteMeshItemCount;
|
|
19290
19299
|
}
|
|
19291
|
-
var renderInfo = items[0].renderInfo;
|
|
19292
19300
|
if (this.mtlSlotCount !== itemSlot) {
|
|
19293
19301
|
this.mesh.setMaterial(this.createMaterial(renderInfo, itemSlot), { textures: exports.DestroyOptions.keep });
|
|
19294
19302
|
}
|
|
19295
|
-
var attachmentLength = (_d = (_c = (_b = (_a = renderInfo
|
|
19303
|
+
var attachmentLength = (_d = (_c = (_b = (_a = renderInfo.filter) === null || _a === void 0 ? void 0 : _a.passSplitOptions) === null || _b === void 0 ? void 0 : _b.attachments) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
|
|
19296
19304
|
this.splitLayer = attachmentLength > 0;
|
|
19297
19305
|
for (var i = 0; i < items.length; i++) {
|
|
19298
19306
|
var item = items[i];
|
|
@@ -23568,7 +23576,7 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23568
23576
|
configurable: true
|
|
23569
23577
|
});
|
|
23570
23578
|
ParticleSystem.prototype.updateEmitterTransform = function (time) {
|
|
23571
|
-
var parentTransform = this.parentTransform;
|
|
23579
|
+
var parentTransform = this.transform.parentTransform;
|
|
23572
23580
|
var _a = this.basicTransform, path = _a.path, position = _a.position;
|
|
23573
23581
|
var selfPos = position.clone();
|
|
23574
23582
|
if (path) {
|
|
@@ -23578,9 +23586,9 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23578
23586
|
this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
|
|
23579
23587
|
if (this.options.particleFollowParent && parentTransform) {
|
|
23580
23588
|
var tempMatrix = parentTransform.getWorldMatrix();
|
|
23581
|
-
this.particleMesh.mesh.worldMatrix = tempMatrix
|
|
23589
|
+
this.particleMesh.mesh.worldMatrix = tempMatrix;
|
|
23582
23590
|
if (this.trailMesh) {
|
|
23583
|
-
this.trailMesh.mesh.worldMatrix = tempMatrix
|
|
23591
|
+
this.trailMesh.mesh.worldMatrix = tempMatrix;
|
|
23584
23592
|
}
|
|
23585
23593
|
}
|
|
23586
23594
|
};
|
|
@@ -23599,8 +23607,8 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23599
23607
|
link.pushNode(linkContent);
|
|
23600
23608
|
this.particleMesh.setPoint(point, pointIndex);
|
|
23601
23609
|
this.clearPointTrail(pointIndex);
|
|
23602
|
-
if (this.
|
|
23603
|
-
this.trailMesh.setPointStartPos(pointIndex, this.parentTransform.position.clone());
|
|
23610
|
+
if (this.trailMesh) {
|
|
23611
|
+
this.trailMesh.setPointStartPos(pointIndex, this.transform.parentTransform.position.clone());
|
|
23604
23612
|
}
|
|
23605
23613
|
};
|
|
23606
23614
|
ParticleSystem.prototype.setVisible = function (visible) {
|
|
@@ -23638,7 +23646,8 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23638
23646
|
}
|
|
23639
23647
|
};
|
|
23640
23648
|
ParticleSystem.prototype.setParentTransform = function (transform) {
|
|
23641
|
-
this.parentTransform = transform;
|
|
23649
|
+
// this.transform.parentTransform = transform;
|
|
23650
|
+
// this.parentTransform = transform;
|
|
23642
23651
|
};
|
|
23643
23652
|
ParticleSystem.prototype.getTextures = function () {
|
|
23644
23653
|
var e_1, _a, e_2, _b;
|
|
@@ -23890,9 +23899,7 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23890
23899
|
if (options.removeParticle) {
|
|
23891
23900
|
mesh.removePoint(pointIndex);
|
|
23892
23901
|
this.clearPointTrail(pointIndex);
|
|
23893
|
-
|
|
23894
|
-
node.content = [0];
|
|
23895
|
-
// link.shiftNode(node.content); // 删了又加回去 没明白什么意思
|
|
23902
|
+
node.content[0] = 0;
|
|
23896
23903
|
}
|
|
23897
23904
|
hitPositions.push(pos);
|
|
23898
23905
|
if (!options.multiple) {
|
|
@@ -23931,8 +23938,8 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23931
23938
|
if (trails.sizeAffectsLifetime) {
|
|
23932
23939
|
lifetime *= size[0];
|
|
23933
23940
|
}
|
|
23934
|
-
if (trails.parentAffectsPosition && this.parentTransform) {
|
|
23935
|
-
position.add(this.parentTransform.position);
|
|
23941
|
+
if (trails.parentAffectsPosition && this.transform.parentTransform) {
|
|
23942
|
+
position.add(this.transform.parentTransform.position);
|
|
23936
23943
|
var pos = this.trailMesh.getPointStartPos(pointIndex);
|
|
23937
23944
|
if (pos) {
|
|
23938
23945
|
position.subtract(pos);
|
|
@@ -24146,7 +24153,9 @@ function randomArrItem(arr, keepArr) {
|
|
|
24146
24153
|
var ParticleVFXItem = /** @class */ (function (_super) {
|
|
24147
24154
|
__extends(ParticleVFXItem, _super);
|
|
24148
24155
|
function ParticleVFXItem() {
|
|
24149
|
-
|
|
24156
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
24157
|
+
_this.destroyed = false;
|
|
24158
|
+
return _this;
|
|
24150
24159
|
}
|
|
24151
24160
|
Object.defineProperty(ParticleVFXItem.prototype, "type", {
|
|
24152
24161
|
get: function () {
|
|
@@ -24172,12 +24181,11 @@ var ParticleVFXItem = /** @class */ (function (_super) {
|
|
|
24172
24181
|
ParticleVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
|
|
24173
24182
|
var _a;
|
|
24174
24183
|
if (this.content) {
|
|
24175
|
-
var hide = !this.
|
|
24184
|
+
var hide = !this.visible;
|
|
24176
24185
|
var parentItem = this.parentId && ((_a = this.composition) === null || _a === void 0 ? void 0 : _a.getItemByID(this.parentId));
|
|
24177
24186
|
if (!hide && parentItem) {
|
|
24178
24187
|
var parentData = parentItem.getRenderData();
|
|
24179
24188
|
if (parentData) {
|
|
24180
|
-
this.content.setParentTransform(parentData.transform);
|
|
24181
24189
|
if (!parentData.visible) {
|
|
24182
24190
|
hide = false;
|
|
24183
24191
|
}
|
|
@@ -29180,7 +29188,6 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29180
29188
|
}
|
|
29181
29189
|
var cachedTextures = textureOptions.map(function (option) { return option && (option instanceof Texture ? option : Texture.create(engine, option)); });
|
|
29182
29190
|
// 缓存创建的Texture对象
|
|
29183
|
-
// @ts-expect-error
|
|
29184
29191
|
scene.textureOptions = cachedTextures;
|
|
29185
29192
|
cachedTextures === null || cachedTextures === void 0 ? void 0 : cachedTextures.forEach(function (tex) { return tex === null || tex === void 0 ? void 0 : tex.initialize(); });
|
|
29186
29193
|
try {
|
|
@@ -29410,24 +29417,24 @@ var AssetManager = /** @class */ (function () {
|
|
|
29410
29417
|
this.timeout = timeout;
|
|
29411
29418
|
};
|
|
29412
29419
|
/**
|
|
29413
|
-
*
|
|
29414
|
-
* 通过 json 创建出场景对象,并进行提前编译等工作
|
|
29420
|
+
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
29415
29421
|
* @param url - json 的 URL 链接或者 json 对象
|
|
29416
29422
|
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
29417
29423
|
* @param options - 扩展参数
|
|
29418
29424
|
* @returns
|
|
29419
29425
|
*/
|
|
29420
29426
|
AssetManager.prototype.loadScene = function (url, renderer, options) {
|
|
29421
|
-
var _a, _b;
|
|
29427
|
+
var _a, _b, _c;
|
|
29422
29428
|
return __awaiter(this, void 0, void 0, function () {
|
|
29423
|
-
var rawJSON, timeLabel, startTime, timeInfos, gpuInstance, asyncShaderCompile, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
29429
|
+
var rawJSON, timeLabel, startTime, timeInfos, gpuInstance, asyncShaderCompile, compressedTexture, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
29424
29430
|
var _this = this;
|
|
29425
|
-
return __generator(this, function (
|
|
29431
|
+
return __generator(this, function (_d) {
|
|
29426
29432
|
timeLabel = "Load asset: ".concat(isString(url) ? url : this.id);
|
|
29427
29433
|
startTime = performance.now();
|
|
29428
29434
|
timeInfos = [];
|
|
29429
29435
|
gpuInstance = renderer === null || renderer === void 0 ? void 0 : renderer.engine.gpuCapability;
|
|
29430
29436
|
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;
|
|
29437
|
+
compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
|
|
29431
29438
|
cancelLoading = false;
|
|
29432
29439
|
waitPromise = new Promise(function (resolve, reject) {
|
|
29433
29440
|
return loadTimer = window.setTimeout(function () {
|
|
@@ -29452,10 +29459,10 @@ var AssetManager = /** @class */ (function () {
|
|
|
29452
29459
|
});
|
|
29453
29460
|
}); };
|
|
29454
29461
|
loadResourcePromise = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
29455
|
-
var
|
|
29462
|
+
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;
|
|
29456
29463
|
var _this = this;
|
|
29457
|
-
return __generator(this, function (
|
|
29458
|
-
switch (
|
|
29464
|
+
return __generator(this, function (_e) {
|
|
29465
|
+
switch (_e.label) {
|
|
29459
29466
|
case 0:
|
|
29460
29467
|
if (!isObject(url)) return [3 /*break*/, 1];
|
|
29461
29468
|
// TODO: 原 JSONLoader contructor 判断是否兼容
|
|
@@ -29468,42 +29475,66 @@ var AssetManager = /** @class */ (function () {
|
|
|
29468
29475
|
this.baseUrl = url;
|
|
29469
29476
|
return [4 /*yield*/, hookTimeInfo('loadJSON', function () { return _this.loadJSON(url); })];
|
|
29470
29477
|
case 2:
|
|
29471
|
-
rawJSON =
|
|
29472
|
-
|
|
29473
|
-
case 3:
|
|
29478
|
+
rawJSON = _e.sent();
|
|
29479
|
+
_e.label = 3;
|
|
29480
|
+
case 3:
|
|
29481
|
+
if (!isScene(rawJSON)) return [3 /*break*/, 6];
|
|
29482
|
+
// 已经加载过的 可能需要更新数据模板
|
|
29483
|
+
scene = __assign$1({}, rawJSON);
|
|
29484
|
+
if (!(this.options && this.options.variables && Object.keys(this.options.variables).length !== 0)) return [3 /*break*/, 5];
|
|
29485
|
+
rawImages = rawJSON.jsonScene.images;
|
|
29486
|
+
images_1 = scene.images;
|
|
29487
|
+
for (i = 0; i < rawImages.length; i++) {
|
|
29488
|
+
// 仅重新加载数据模板对应的图片
|
|
29489
|
+
if (images_1[i] instanceof HTMLCanvasElement) {
|
|
29490
|
+
images_1[i] = rawImages[i];
|
|
29491
|
+
}
|
|
29492
|
+
}
|
|
29493
|
+
_a = scene;
|
|
29494
|
+
return [4 /*yield*/, hookTimeInfo('processImages', function () { return _this.processImages(images_1, scene.usedImages, compressedTexture); })];
|
|
29474
29495
|
case 4:
|
|
29475
|
-
_a =
|
|
29476
|
-
|
|
29496
|
+
_a.images = _e.sent();
|
|
29497
|
+
// 更新 TextureOptions 中的 image 指向
|
|
29498
|
+
for (i = 0; i < scene.images.length; i++) {
|
|
29499
|
+
scene.textureOptions[i].image = scene.images[i];
|
|
29500
|
+
}
|
|
29501
|
+
_e.label = 5;
|
|
29502
|
+
case 5: return [3 /*break*/, 12];
|
|
29503
|
+
case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
|
|
29504
|
+
case 7:
|
|
29505
|
+
_b = _e.sent(), usedImages_1 = _b.usedImages, jsonScene_1 = _b.jsonScene, pluginSystem_1 = _b.pluginSystem;
|
|
29506
|
+
_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;
|
|
29477
29507
|
return [4 /*yield*/, Promise.all([
|
|
29478
|
-
hookTimeInfo('processBins', function () { return _this.processBins(
|
|
29479
|
-
hookTimeInfo('processImages', function () {
|
|
29480
|
-
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(
|
|
29508
|
+
hookTimeInfo('processBins', function () { return _this.processBins(bins_1); }),
|
|
29509
|
+
hookTimeInfo('processImages', function () { return _this.processImages(images_2, usedImages_1, compressedTexture); }),
|
|
29510
|
+
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(compositions_1, pluginSystem_1, renderer, options); }),
|
|
29481
29511
|
])];
|
|
29482
|
-
case
|
|
29483
|
-
|
|
29484
|
-
return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(
|
|
29485
|
-
case
|
|
29486
|
-
|
|
29487
|
-
return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(
|
|
29488
|
-
case
|
|
29489
|
-
loadedTextures =
|
|
29512
|
+
case 8:
|
|
29513
|
+
_d = __read$3.apply(void 0, [_e.sent(), 2]), loadedBins_1 = _d[0], loadedImages_1 = _d[1];
|
|
29514
|
+
return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(fonts_1); })];
|
|
29515
|
+
case 9:
|
|
29516
|
+
_e.sent();
|
|
29517
|
+
return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
|
|
29518
|
+
case 10:
|
|
29519
|
+
loadedTextures = _e.sent();
|
|
29490
29520
|
scene = {
|
|
29491
|
-
jsonScene: jsonScene,
|
|
29492
|
-
images: loadedImages,
|
|
29493
|
-
textureOptions: loadedTextures,
|
|
29494
|
-
bins: loadedBins,
|
|
29495
|
-
storage: {},
|
|
29496
|
-
pluginSystem: this.pluginSystem,
|
|
29497
|
-
renderLevel: this.options.renderLevel,
|
|
29498
|
-
totalTime: 0,
|
|
29499
|
-
startTime: 0,
|
|
29500
29521
|
url: url,
|
|
29522
|
+
renderLevel: this.options.renderLevel,
|
|
29523
|
+
storage: {},
|
|
29524
|
+
pluginSystem: pluginSystem_1,
|
|
29525
|
+
jsonScene: jsonScene_1,
|
|
29526
|
+
usedImages: usedImages_1,
|
|
29527
|
+
images: loadedImages_1,
|
|
29528
|
+
textureOptions: loadedTextures,
|
|
29529
|
+
bins: loadedBins_1,
|
|
29501
29530
|
};
|
|
29502
29531
|
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
29503
|
-
return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return
|
|
29504
|
-
case
|
|
29532
|
+
return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return pluginSystem_1.loadResources(scene, _this.options); })];
|
|
29533
|
+
case 11:
|
|
29505
29534
|
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
29506
|
-
|
|
29535
|
+
_e.sent();
|
|
29536
|
+
_e.label = 12;
|
|
29537
|
+
case 12:
|
|
29507
29538
|
totalTime = performance.now() - startTime;
|
|
29508
29539
|
console.info({
|
|
29509
29540
|
content: "".concat(timeLabel, ": ").concat(totalTime.toFixed(4), "ms, ").concat(timeInfos.join(' ')),
|
|
@@ -29520,7 +29551,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29520
29551
|
});
|
|
29521
29552
|
});
|
|
29522
29553
|
};
|
|
29523
|
-
AssetManager.prototype.precompile = function (compositions, renderer, options) {
|
|
29554
|
+
AssetManager.prototype.precompile = function (compositions, pluginSystem, renderer, options) {
|
|
29524
29555
|
return __awaiter(this, void 0, void 0, function () {
|
|
29525
29556
|
var shaderLibrary;
|
|
29526
29557
|
return __generator(this, function (_a) {
|
|
@@ -29530,7 +29561,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29530
29561
|
return [2 /*return*/];
|
|
29531
29562
|
}
|
|
29532
29563
|
shaderLibrary = renderer === null || renderer === void 0 ? void 0 : renderer.getShaderLibrary();
|
|
29533
|
-
return [4 /*yield*/,
|
|
29564
|
+
return [4 /*yield*/, (pluginSystem === null || pluginSystem === void 0 ? void 0 : pluginSystem.precompile(compositions, renderer, options))];
|
|
29534
29565
|
case 1:
|
|
29535
29566
|
_a.sent();
|
|
29536
29567
|
return [4 /*yield*/, new Promise(function (resolve) {
|
|
@@ -29547,7 +29578,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29547
29578
|
};
|
|
29548
29579
|
AssetManager.prototype.processJSON = function (json) {
|
|
29549
29580
|
return __awaiter(this, void 0, void 0, function () {
|
|
29550
|
-
var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, renderLevel, usedImages;
|
|
29581
|
+
var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, pluginSystem, renderLevel, usedImages;
|
|
29551
29582
|
return __generator(this, function (_b) {
|
|
29552
29583
|
switch (_b.label) {
|
|
29553
29584
|
case 0:
|
|
@@ -29561,8 +29592,8 @@ var AssetManager = /** @class */ (function () {
|
|
|
29561
29592
|
}
|
|
29562
29593
|
});
|
|
29563
29594
|
_a = jsonScene.plugins, plugins = _a === void 0 ? [] : _a, sceneCompositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, images = jsonScene.images;
|
|
29564
|
-
|
|
29565
|
-
return [4 /*yield*/,
|
|
29595
|
+
pluginSystem = new PluginSystem(plugins);
|
|
29596
|
+
return [4 /*yield*/, pluginSystem.processRawJSON(jsonScene, this.options)];
|
|
29566
29597
|
case 1:
|
|
29567
29598
|
_b.sent();
|
|
29568
29599
|
renderLevel = this.options.renderLevel;
|
|
@@ -29579,6 +29610,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29579
29610
|
return [2 /*return*/, {
|
|
29580
29611
|
usedImages: usedImages,
|
|
29581
29612
|
jsonScene: jsonScene,
|
|
29613
|
+
pluginSystem: pluginSystem,
|
|
29582
29614
|
}];
|
|
29583
29615
|
}
|
|
29584
29616
|
});
|
|
@@ -29962,7 +29994,8 @@ var CompVFXItem = /** @class */ (function (_super) {
|
|
|
29962
29994
|
}
|
|
29963
29995
|
else {
|
|
29964
29996
|
item = createVFXItem(this.itemProps[i], this.composition);
|
|
29965
|
-
|
|
29997
|
+
// 相机不跟随合成移动
|
|
29998
|
+
item.transform.parentTransform = VFXItem.isCamera(item) ? new Transform() : this.transform;
|
|
29966
29999
|
}
|
|
29967
30000
|
if (VFXItem.isExtraCamera(item)) {
|
|
29968
30001
|
this.extraCamera = item;
|
|
@@ -30148,7 +30181,7 @@ var CompVFXItem = /** @class */ (function (_super) {
|
|
|
30148
30181
|
if (!parentItem) {
|
|
30149
30182
|
itemNode.parentId = undefined;
|
|
30150
30183
|
item.parent = undefined;
|
|
30151
|
-
item.transform.parentTransform = this.transform;
|
|
30184
|
+
item.transform.parentTransform = VFXItem.isExtraCamera(item) ? new Transform() : this.transform;
|
|
30152
30185
|
}
|
|
30153
30186
|
else {
|
|
30154
30187
|
var parentNode = this.itemCacheMap.get(parentItem.id);
|
|
@@ -30445,7 +30478,7 @@ var Composition = /** @class */ (function () {
|
|
|
30445
30478
|
});
|
|
30446
30479
|
Object.defineProperty(Composition.prototype, "startTime", {
|
|
30447
30480
|
/**
|
|
30448
|
-
*
|
|
30481
|
+
* 获取合成开始渲染的时间
|
|
30449
30482
|
*/
|
|
30450
30483
|
get: function () {
|
|
30451
30484
|
var _a;
|
|
@@ -30525,7 +30558,12 @@ var Composition = /** @class */ (function () {
|
|
|
30525
30558
|
if (this.content.ended && this.reusable) {
|
|
30526
30559
|
this.restart();
|
|
30527
30560
|
}
|
|
30528
|
-
|
|
30561
|
+
if (this.content.started) {
|
|
30562
|
+
this.gotoAndPlay(this.time - this.startTime);
|
|
30563
|
+
}
|
|
30564
|
+
else {
|
|
30565
|
+
this.gotoAndPlay(0);
|
|
30566
|
+
}
|
|
30529
30567
|
};
|
|
30530
30568
|
/**
|
|
30531
30569
|
* 暂停合成的播放
|
|
@@ -30539,14 +30577,21 @@ var Composition = /** @class */ (function () {
|
|
|
30539
30577
|
Composition.prototype.resume = function () {
|
|
30540
30578
|
this.paused = false;
|
|
30541
30579
|
};
|
|
30580
|
+
/**
|
|
30581
|
+
* 跳转合成到指定时间播放
|
|
30582
|
+
* @param time - 相对 startTime 的时间
|
|
30583
|
+
*/
|
|
30542
30584
|
Composition.prototype.gotoAndPlay = function (time) {
|
|
30543
30585
|
this.resume();
|
|
30544
30586
|
if (!this.content.started) {
|
|
30545
30587
|
this.content.start();
|
|
30546
|
-
this.forwardTime(this.startTime);
|
|
30547
30588
|
}
|
|
30548
|
-
this.forwardTime(time);
|
|
30589
|
+
this.forwardTime(time + this.startTime);
|
|
30549
30590
|
};
|
|
30591
|
+
/**
|
|
30592
|
+
* 跳转合成到指定时间并暂停
|
|
30593
|
+
* @param time - 相对 startTime 的时间
|
|
30594
|
+
*/
|
|
30550
30595
|
Composition.prototype.gotoAndStop = function (time) {
|
|
30551
30596
|
this.gotoAndPlay(time);
|
|
30552
30597
|
this.pause();
|
|
@@ -30566,21 +30611,29 @@ var Composition = /** @class */ (function () {
|
|
|
30566
30611
|
};
|
|
30567
30612
|
/**
|
|
30568
30613
|
* 跳到指定时间点(不做任何播放行为)
|
|
30569
|
-
* @param time -
|
|
30614
|
+
* @param time - 相对 startTime 的时间
|
|
30570
30615
|
*/
|
|
30571
30616
|
Composition.prototype.setTime = function (time) {
|
|
30572
30617
|
var pause = this.paused;
|
|
30573
30618
|
if (pause) {
|
|
30574
30619
|
this.resume();
|
|
30575
30620
|
}
|
|
30576
|
-
this.
|
|
30621
|
+
if (!this.content.started) {
|
|
30622
|
+
this.content.start();
|
|
30623
|
+
}
|
|
30624
|
+
this.forwardTime(time + this.startTime, true);
|
|
30577
30625
|
if (pause) {
|
|
30578
30626
|
this.pause();
|
|
30579
30627
|
}
|
|
30580
30628
|
};
|
|
30629
|
+
/**
|
|
30630
|
+
* 前进合成到指定时间
|
|
30631
|
+
* @param time - 相对0时刻的时间
|
|
30632
|
+
* @param skipRender - 是否跳过渲染
|
|
30633
|
+
*/
|
|
30581
30634
|
Composition.prototype.forwardTime = function (time, skipRender) {
|
|
30582
30635
|
if (skipRender === void 0) { skipRender = false; }
|
|
30583
|
-
var deltaTime =
|
|
30636
|
+
var deltaTime = time * 1000 - this.content.timeInms;
|
|
30584
30637
|
var reverse = deltaTime < 0;
|
|
30585
30638
|
var step = 15;
|
|
30586
30639
|
var t = Math.abs(deltaTime);
|