@galacean/effects 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/index.js +152 -106
- 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 +152 -106
- package/dist/index.mjs.map +1 -1
- package/dist/player.d.ts +1 -1
- package/dist/weapp.js +151 -105
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +151 -105
- package/dist/weapp.mjs.map +1 -1
- package/package.json +3 -3
package/dist/weapp.mjs
CHANGED
|
@@ -14723,6 +14723,9 @@ var VFXItem = /** @class */ (function () {
|
|
|
14723
14723
|
VFXItem.isTree = function (item) {
|
|
14724
14724
|
return item.type === ItemType$1.tree;
|
|
14725
14725
|
};
|
|
14726
|
+
VFXItem.isCamera = function (item) {
|
|
14727
|
+
return item.type === ItemType$1.camera;
|
|
14728
|
+
};
|
|
14726
14729
|
VFXItem.isExtraCamera = function (item) {
|
|
14727
14730
|
return item.id === 'extra-camera' && item.name === 'extra-camera';
|
|
14728
14731
|
};
|
|
@@ -14923,10 +14926,11 @@ var VFXItem = /** @class */ (function () {
|
|
|
14923
14926
|
}
|
|
14924
14927
|
else if (this.endBehavior === END_BEHAVIOR_DESTROY$1) {
|
|
14925
14928
|
this._contentVisible = false;
|
|
14929
|
+
shouldUpdate = true;
|
|
14930
|
+
dt = 0;
|
|
14926
14931
|
// 预合成配置 reusable 且销毁时, 需要隐藏其中的元素
|
|
14927
14932
|
if (this.type === ItemType$1.composition) {
|
|
14928
14933
|
this.handleVisibleChanged(false);
|
|
14929
|
-
this.onItemUpdate(0, lifetime);
|
|
14930
14934
|
}
|
|
14931
14935
|
}
|
|
14932
14936
|
lifetime = Math.min(lifetime, 1);
|
|
@@ -14935,7 +14939,6 @@ var VFXItem = /** @class */ (function () {
|
|
|
14935
14939
|
shouldUpdate = true;
|
|
14936
14940
|
if (this.endBehavior === END_BEHAVIOR_RESTART$1) {
|
|
14937
14941
|
this.ended = true;
|
|
14938
|
-
lifetime = lifetime % 1;
|
|
14939
14942
|
}
|
|
14940
14943
|
}
|
|
14941
14944
|
}
|
|
@@ -14943,7 +14946,7 @@ var VFXItem = /** @class */ (function () {
|
|
|
14943
14946
|
this.setVisible(true);
|
|
14944
14947
|
this.callEnd = false;
|
|
14945
14948
|
}
|
|
14946
|
-
this.lifetime = lifetime;
|
|
14949
|
+
this.lifetime = lifetime % 1;
|
|
14947
14950
|
shouldUpdate && this.onItemUpdate(dt, lifetime);
|
|
14948
14951
|
}
|
|
14949
14952
|
}
|
|
@@ -15510,10 +15513,6 @@ var CameraVFXItem = /** @class */ (function (_super) {
|
|
|
15510
15513
|
(_a = this.controller) === null || _a === void 0 ? void 0 : _a.update(lifetime);
|
|
15511
15514
|
this.updateCamera();
|
|
15512
15515
|
};
|
|
15513
|
-
// override onEnd () {
|
|
15514
|
-
// this.controller?.update(1);
|
|
15515
|
-
// this.updateCamera();
|
|
15516
|
-
// }
|
|
15517
15516
|
CameraVFXItem.prototype.updateCamera = function () {
|
|
15518
15517
|
if (this.controller && this.composition) {
|
|
15519
15518
|
var camera = this.composition.camera;
|
|
@@ -19270,19 +19269,28 @@ var SpriteMesh = /** @class */ (function () {
|
|
|
19270
19269
|
var aPointLen = 0;
|
|
19271
19270
|
var indexLen = 0;
|
|
19272
19271
|
var pointCount = 0;
|
|
19272
|
+
var renderInfo;
|
|
19273
19273
|
if (!items.length) {
|
|
19274
19274
|
this.mesh.setVisible(false);
|
|
19275
19275
|
return true;
|
|
19276
19276
|
}
|
|
19277
|
+
for (var i = 0; i < items.length; i++) {
|
|
19278
|
+
if (items[i].renderInfo) {
|
|
19279
|
+
renderInfo = items[i].renderInfo;
|
|
19280
|
+
break;
|
|
19281
|
+
}
|
|
19282
|
+
}
|
|
19283
|
+
if (!renderInfo) {
|
|
19284
|
+
return true;
|
|
19285
|
+
}
|
|
19277
19286
|
this.items = items.slice();
|
|
19278
19287
|
if (items.length > 2) {
|
|
19279
19288
|
itemSlot = maxSpriteMeshItemCount;
|
|
19280
19289
|
}
|
|
19281
|
-
var renderInfo = items[0].renderInfo;
|
|
19282
19290
|
if (this.mtlSlotCount !== itemSlot) {
|
|
19283
19291
|
this.mesh.setMaterial(this.createMaterial(renderInfo, itemSlot), { textures: DestroyOptions.keep });
|
|
19284
19292
|
}
|
|
19285
|
-
var attachmentLength = (_d = (_c = (_b = (_a = renderInfo
|
|
19293
|
+
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;
|
|
19286
19294
|
this.splitLayer = attachmentLength > 0;
|
|
19287
19295
|
for (var i = 0; i < items.length; i++) {
|
|
19288
19296
|
var item = items[i];
|
|
@@ -23558,7 +23566,7 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23558
23566
|
configurable: true
|
|
23559
23567
|
});
|
|
23560
23568
|
ParticleSystem.prototype.updateEmitterTransform = function (time) {
|
|
23561
|
-
var parentTransform = this.parentTransform;
|
|
23569
|
+
var parentTransform = this.transform.parentTransform;
|
|
23562
23570
|
var _a = this.basicTransform, path = _a.path, position = _a.position;
|
|
23563
23571
|
var selfPos = position.clone();
|
|
23564
23572
|
if (path) {
|
|
@@ -23568,9 +23576,9 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23568
23576
|
this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
|
|
23569
23577
|
if (this.options.particleFollowParent && parentTransform) {
|
|
23570
23578
|
var tempMatrix = parentTransform.getWorldMatrix();
|
|
23571
|
-
this.particleMesh.mesh.worldMatrix = tempMatrix
|
|
23579
|
+
this.particleMesh.mesh.worldMatrix = tempMatrix;
|
|
23572
23580
|
if (this.trailMesh) {
|
|
23573
|
-
this.trailMesh.mesh.worldMatrix = tempMatrix
|
|
23581
|
+
this.trailMesh.mesh.worldMatrix = tempMatrix;
|
|
23574
23582
|
}
|
|
23575
23583
|
}
|
|
23576
23584
|
};
|
|
@@ -23589,8 +23597,8 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23589
23597
|
link.pushNode(linkContent);
|
|
23590
23598
|
this.particleMesh.setPoint(point, pointIndex);
|
|
23591
23599
|
this.clearPointTrail(pointIndex);
|
|
23592
|
-
if (this.
|
|
23593
|
-
this.trailMesh.setPointStartPos(pointIndex, this.parentTransform.position.clone());
|
|
23600
|
+
if (this.trailMesh) {
|
|
23601
|
+
this.trailMesh.setPointStartPos(pointIndex, this.transform.parentTransform.position.clone());
|
|
23594
23602
|
}
|
|
23595
23603
|
};
|
|
23596
23604
|
ParticleSystem.prototype.setVisible = function (visible) {
|
|
@@ -23628,7 +23636,8 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23628
23636
|
}
|
|
23629
23637
|
};
|
|
23630
23638
|
ParticleSystem.prototype.setParentTransform = function (transform) {
|
|
23631
|
-
this.parentTransform = transform;
|
|
23639
|
+
// this.transform.parentTransform = transform;
|
|
23640
|
+
// this.parentTransform = transform;
|
|
23632
23641
|
};
|
|
23633
23642
|
ParticleSystem.prototype.getTextures = function () {
|
|
23634
23643
|
var e_1, _a, e_2, _b;
|
|
@@ -23880,9 +23889,7 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23880
23889
|
if (options.removeParticle) {
|
|
23881
23890
|
mesh.removePoint(pointIndex);
|
|
23882
23891
|
this.clearPointTrail(pointIndex);
|
|
23883
|
-
|
|
23884
|
-
node.content = [0];
|
|
23885
|
-
// link.shiftNode(node.content); // 删了又加回去 没明白什么意思
|
|
23892
|
+
node.content[0] = 0;
|
|
23886
23893
|
}
|
|
23887
23894
|
hitPositions.push(pos);
|
|
23888
23895
|
if (!options.multiple) {
|
|
@@ -23921,8 +23928,8 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23921
23928
|
if (trails.sizeAffectsLifetime) {
|
|
23922
23929
|
lifetime *= size[0];
|
|
23923
23930
|
}
|
|
23924
|
-
if (trails.parentAffectsPosition && this.parentTransform) {
|
|
23925
|
-
position.add(this.parentTransform.position);
|
|
23931
|
+
if (trails.parentAffectsPosition && this.transform.parentTransform) {
|
|
23932
|
+
position.add(this.transform.parentTransform.position);
|
|
23926
23933
|
var pos = this.trailMesh.getPointStartPos(pointIndex);
|
|
23927
23934
|
if (pos) {
|
|
23928
23935
|
position.subtract(pos);
|
|
@@ -24136,7 +24143,9 @@ function randomArrItem(arr, keepArr) {
|
|
|
24136
24143
|
var ParticleVFXItem = /** @class */ (function (_super) {
|
|
24137
24144
|
__extends(ParticleVFXItem, _super);
|
|
24138
24145
|
function ParticleVFXItem() {
|
|
24139
|
-
|
|
24146
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
24147
|
+
_this.destroyed = false;
|
|
24148
|
+
return _this;
|
|
24140
24149
|
}
|
|
24141
24150
|
Object.defineProperty(ParticleVFXItem.prototype, "type", {
|
|
24142
24151
|
get: function () {
|
|
@@ -24162,12 +24171,11 @@ var ParticleVFXItem = /** @class */ (function (_super) {
|
|
|
24162
24171
|
ParticleVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
|
|
24163
24172
|
var _a;
|
|
24164
24173
|
if (this.content) {
|
|
24165
|
-
var hide = !this.
|
|
24174
|
+
var hide = !this.visible;
|
|
24166
24175
|
var parentItem = this.parentId && ((_a = this.composition) === null || _a === void 0 ? void 0 : _a.getItemByID(this.parentId));
|
|
24167
24176
|
if (!hide && parentItem) {
|
|
24168
24177
|
var parentData = parentItem.getRenderData();
|
|
24169
24178
|
if (parentData) {
|
|
24170
|
-
this.content.setParentTransform(parentData.transform);
|
|
24171
24179
|
if (!parentData.visible) {
|
|
24172
24180
|
hide = false;
|
|
24173
24181
|
}
|
|
@@ -29170,7 +29178,6 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29170
29178
|
}
|
|
29171
29179
|
var cachedTextures = textureOptions.map(function (option) { return option && (option instanceof Texture ? option : Texture.create(engine, option)); });
|
|
29172
29180
|
// 缓存创建的Texture对象
|
|
29173
|
-
// @ts-expect-error
|
|
29174
29181
|
scene.textureOptions = cachedTextures;
|
|
29175
29182
|
cachedTextures === null || cachedTextures === void 0 ? void 0 : cachedTextures.forEach(function (tex) { return tex === null || tex === void 0 ? void 0 : tex.initialize(); });
|
|
29176
29183
|
try {
|
|
@@ -29400,24 +29407,24 @@ var AssetManager = /** @class */ (function () {
|
|
|
29400
29407
|
this.timeout = timeout;
|
|
29401
29408
|
};
|
|
29402
29409
|
/**
|
|
29403
|
-
*
|
|
29404
|
-
* 通过 json 创建出场景对象,并进行提前编译等工作
|
|
29410
|
+
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
29405
29411
|
* @param url - json 的 URL 链接或者 json 对象
|
|
29406
29412
|
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
29407
29413
|
* @param options - 扩展参数
|
|
29408
29414
|
* @returns
|
|
29409
29415
|
*/
|
|
29410
29416
|
AssetManager.prototype.loadScene = function (url, renderer, options) {
|
|
29411
|
-
var _a, _b;
|
|
29417
|
+
var _a, _b, _c;
|
|
29412
29418
|
return __awaiter(this, void 0, void 0, function () {
|
|
29413
|
-
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;
|
|
29414
29420
|
var _this = this;
|
|
29415
|
-
return __generator(this, function (
|
|
29421
|
+
return __generator(this, function (_d) {
|
|
29416
29422
|
timeLabel = "Load asset: ".concat(isString(url) ? url : this.id);
|
|
29417
29423
|
startTime = performance.now();
|
|
29418
29424
|
timeInfos = [];
|
|
29419
29425
|
gpuInstance = renderer === null || renderer === void 0 ? void 0 : renderer.engine.gpuCapability;
|
|
29420
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;
|
|
29421
29428
|
cancelLoading = false;
|
|
29422
29429
|
waitPromise = new Promise(function (resolve, reject) {
|
|
29423
29430
|
return loadTimer = window$1.setTimeout(function () {
|
|
@@ -29442,10 +29449,10 @@ var AssetManager = /** @class */ (function () {
|
|
|
29442
29449
|
});
|
|
29443
29450
|
}); };
|
|
29444
29451
|
loadResourcePromise = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
29445
|
-
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;
|
|
29446
29453
|
var _this = this;
|
|
29447
|
-
return __generator(this, function (
|
|
29448
|
-
switch (
|
|
29454
|
+
return __generator(this, function (_e) {
|
|
29455
|
+
switch (_e.label) {
|
|
29449
29456
|
case 0:
|
|
29450
29457
|
if (!isObject(url)) return [3 /*break*/, 1];
|
|
29451
29458
|
// TODO: 原 JSONLoader contructor 判断是否兼容
|
|
@@ -29458,42 +29465,66 @@ var AssetManager = /** @class */ (function () {
|
|
|
29458
29465
|
this.baseUrl = url;
|
|
29459
29466
|
return [4 /*yield*/, hookTimeInfo('loadJSON', function () { return _this.loadJSON(url); })];
|
|
29460
29467
|
case 2:
|
|
29461
|
-
rawJSON =
|
|
29462
|
-
|
|
29463
|
-
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); })];
|
|
29464
29485
|
case 4:
|
|
29465
|
-
_a =
|
|
29466
|
-
|
|
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;
|
|
29467
29497
|
return [4 /*yield*/, Promise.all([
|
|
29468
|
-
hookTimeInfo('processBins', function () { return _this.processBins(
|
|
29469
|
-
hookTimeInfo('processImages', function () {
|
|
29470
|
-
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); }),
|
|
29471
29501
|
])];
|
|
29472
|
-
case
|
|
29473
|
-
|
|
29474
|
-
return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(
|
|
29475
|
-
case
|
|
29476
|
-
|
|
29477
|
-
return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(
|
|
29478
|
-
case
|
|
29479
|
-
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();
|
|
29480
29510
|
scene = {
|
|
29481
|
-
jsonScene: jsonScene,
|
|
29482
|
-
images: loadedImages,
|
|
29483
|
-
textureOptions: loadedTextures,
|
|
29484
|
-
bins: loadedBins,
|
|
29485
|
-
storage: {},
|
|
29486
|
-
pluginSystem: this.pluginSystem,
|
|
29487
|
-
renderLevel: this.options.renderLevel,
|
|
29488
|
-
totalTime: 0,
|
|
29489
|
-
startTime: 0,
|
|
29490
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,
|
|
29491
29520
|
};
|
|
29492
29521
|
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
29493
|
-
return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return
|
|
29494
|
-
case
|
|
29522
|
+
return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return pluginSystem_1.loadResources(scene, _this.options); })];
|
|
29523
|
+
case 11:
|
|
29495
29524
|
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
29496
|
-
|
|
29525
|
+
_e.sent();
|
|
29526
|
+
_e.label = 12;
|
|
29527
|
+
case 12:
|
|
29497
29528
|
totalTime = performance.now() - startTime;
|
|
29498
29529
|
console.info({
|
|
29499
29530
|
content: "".concat(timeLabel, ": ").concat(totalTime.toFixed(4), "ms, ").concat(timeInfos.join(' ')),
|
|
@@ -29510,7 +29541,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29510
29541
|
});
|
|
29511
29542
|
});
|
|
29512
29543
|
};
|
|
29513
|
-
AssetManager.prototype.precompile = function (compositions, renderer, options) {
|
|
29544
|
+
AssetManager.prototype.precompile = function (compositions, pluginSystem, renderer, options) {
|
|
29514
29545
|
return __awaiter(this, void 0, void 0, function () {
|
|
29515
29546
|
var shaderLibrary;
|
|
29516
29547
|
return __generator(this, function (_a) {
|
|
@@ -29520,7 +29551,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29520
29551
|
return [2 /*return*/];
|
|
29521
29552
|
}
|
|
29522
29553
|
shaderLibrary = renderer === null || renderer === void 0 ? void 0 : renderer.getShaderLibrary();
|
|
29523
|
-
return [4 /*yield*/,
|
|
29554
|
+
return [4 /*yield*/, (pluginSystem === null || pluginSystem === void 0 ? void 0 : pluginSystem.precompile(compositions, renderer, options))];
|
|
29524
29555
|
case 1:
|
|
29525
29556
|
_a.sent();
|
|
29526
29557
|
return [4 /*yield*/, new Promise(function (resolve) {
|
|
@@ -29537,7 +29568,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29537
29568
|
};
|
|
29538
29569
|
AssetManager.prototype.processJSON = function (json) {
|
|
29539
29570
|
return __awaiter(this, void 0, void 0, function () {
|
|
29540
|
-
var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, renderLevel, usedImages;
|
|
29571
|
+
var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, pluginSystem, renderLevel, usedImages;
|
|
29541
29572
|
return __generator(this, function (_b) {
|
|
29542
29573
|
switch (_b.label) {
|
|
29543
29574
|
case 0:
|
|
@@ -29551,8 +29582,8 @@ var AssetManager = /** @class */ (function () {
|
|
|
29551
29582
|
}
|
|
29552
29583
|
});
|
|
29553
29584
|
_a = jsonScene.plugins, plugins = _a === void 0 ? [] : _a, sceneCompositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, images = jsonScene.images;
|
|
29554
|
-
|
|
29555
|
-
return [4 /*yield*/,
|
|
29585
|
+
pluginSystem = new PluginSystem(plugins);
|
|
29586
|
+
return [4 /*yield*/, pluginSystem.processRawJSON(jsonScene, this.options)];
|
|
29556
29587
|
case 1:
|
|
29557
29588
|
_b.sent();
|
|
29558
29589
|
renderLevel = this.options.renderLevel;
|
|
@@ -29569,6 +29600,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29569
29600
|
return [2 /*return*/, {
|
|
29570
29601
|
usedImages: usedImages,
|
|
29571
29602
|
jsonScene: jsonScene,
|
|
29603
|
+
pluginSystem: pluginSystem,
|
|
29572
29604
|
}];
|
|
29573
29605
|
}
|
|
29574
29606
|
});
|
|
@@ -29952,7 +29984,8 @@ var CompVFXItem = /** @class */ (function (_super) {
|
|
|
29952
29984
|
}
|
|
29953
29985
|
else {
|
|
29954
29986
|
item = createVFXItem(this.itemProps[i], this.composition);
|
|
29955
|
-
|
|
29987
|
+
// 相机不跟随合成移动
|
|
29988
|
+
item.transform.parentTransform = VFXItem.isCamera(item) ? new Transform() : this.transform;
|
|
29956
29989
|
}
|
|
29957
29990
|
if (VFXItem.isExtraCamera(item)) {
|
|
29958
29991
|
this.extraCamera = item;
|
|
@@ -30138,7 +30171,7 @@ var CompVFXItem = /** @class */ (function (_super) {
|
|
|
30138
30171
|
if (!parentItem) {
|
|
30139
30172
|
itemNode.parentId = undefined;
|
|
30140
30173
|
item.parent = undefined;
|
|
30141
|
-
item.transform.parentTransform = this.transform;
|
|
30174
|
+
item.transform.parentTransform = VFXItem.isExtraCamera(item) ? new Transform() : this.transform;
|
|
30142
30175
|
}
|
|
30143
30176
|
else {
|
|
30144
30177
|
var parentNode = this.itemCacheMap.get(parentItem.id);
|
|
@@ -30435,7 +30468,7 @@ var Composition = /** @class */ (function () {
|
|
|
30435
30468
|
});
|
|
30436
30469
|
Object.defineProperty(Composition.prototype, "startTime", {
|
|
30437
30470
|
/**
|
|
30438
|
-
*
|
|
30471
|
+
* 获取合成开始渲染的时间
|
|
30439
30472
|
*/
|
|
30440
30473
|
get: function () {
|
|
30441
30474
|
var _a;
|
|
@@ -30515,7 +30548,12 @@ var Composition = /** @class */ (function () {
|
|
|
30515
30548
|
if (this.content.ended && this.reusable) {
|
|
30516
30549
|
this.restart();
|
|
30517
30550
|
}
|
|
30518
|
-
|
|
30551
|
+
if (this.content.started) {
|
|
30552
|
+
this.gotoAndPlay(this.time - this.startTime);
|
|
30553
|
+
}
|
|
30554
|
+
else {
|
|
30555
|
+
this.gotoAndPlay(0);
|
|
30556
|
+
}
|
|
30519
30557
|
};
|
|
30520
30558
|
/**
|
|
30521
30559
|
* 暂停合成的播放
|
|
@@ -30529,14 +30567,21 @@ var Composition = /** @class */ (function () {
|
|
|
30529
30567
|
Composition.prototype.resume = function () {
|
|
30530
30568
|
this.paused = false;
|
|
30531
30569
|
};
|
|
30570
|
+
/**
|
|
30571
|
+
* 跳转合成到指定时间播放
|
|
30572
|
+
* @param time - 相对 startTime 的时间
|
|
30573
|
+
*/
|
|
30532
30574
|
Composition.prototype.gotoAndPlay = function (time) {
|
|
30533
30575
|
this.resume();
|
|
30534
30576
|
if (!this.content.started) {
|
|
30535
30577
|
this.content.start();
|
|
30536
|
-
this.forwardTime(this.startTime);
|
|
30537
30578
|
}
|
|
30538
|
-
this.forwardTime(time);
|
|
30579
|
+
this.forwardTime(time + this.startTime);
|
|
30539
30580
|
};
|
|
30581
|
+
/**
|
|
30582
|
+
* 跳转合成到指定时间并暂停
|
|
30583
|
+
* @param time - 相对 startTime 的时间
|
|
30584
|
+
*/
|
|
30540
30585
|
Composition.prototype.gotoAndStop = function (time) {
|
|
30541
30586
|
this.gotoAndPlay(time);
|
|
30542
30587
|
this.pause();
|
|
@@ -30556,21 +30601,29 @@ var Composition = /** @class */ (function () {
|
|
|
30556
30601
|
};
|
|
30557
30602
|
/**
|
|
30558
30603
|
* 跳到指定时间点(不做任何播放行为)
|
|
30559
|
-
* @param time -
|
|
30604
|
+
* @param time - 相对 startTime 的时间
|
|
30560
30605
|
*/
|
|
30561
30606
|
Composition.prototype.setTime = function (time) {
|
|
30562
30607
|
var pause = this.paused;
|
|
30563
30608
|
if (pause) {
|
|
30564
30609
|
this.resume();
|
|
30565
30610
|
}
|
|
30566
|
-
this.
|
|
30611
|
+
if (!this.content.started) {
|
|
30612
|
+
this.content.start();
|
|
30613
|
+
}
|
|
30614
|
+
this.forwardTime(time + this.startTime, true);
|
|
30567
30615
|
if (pause) {
|
|
30568
30616
|
this.pause();
|
|
30569
30617
|
}
|
|
30570
30618
|
};
|
|
30619
|
+
/**
|
|
30620
|
+
* 前进合成到指定时间
|
|
30621
|
+
* @param time - 相对0时刻的时间
|
|
30622
|
+
* @param skipRender - 是否跳过渲染
|
|
30623
|
+
*/
|
|
30571
30624
|
Composition.prototype.forwardTime = function (time, skipRender) {
|
|
30572
30625
|
if (skipRender === void 0) { skipRender = false; }
|
|
30573
|
-
var deltaTime =
|
|
30626
|
+
var deltaTime = time * 1000 - this.content.timeInms;
|
|
30574
30627
|
var reverse = deltaTime < 0;
|
|
30575
30628
|
var step = 15;
|
|
30576
30629
|
var t = Math.abs(deltaTime);
|
|
@@ -32970,6 +33023,13 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
32970
33023
|
try {
|
|
32971
33024
|
for (var _b = __values$1(Object.values(this.textures)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
32972
33025
|
var texture = _c.value;
|
|
33026
|
+
if (!isFunction(texture.initialize)) {
|
|
33027
|
+
console.error({
|
|
33028
|
+
content: "".concat(JSON.stringify(texture), " is not valid Texture to initialize"),
|
|
33029
|
+
type: LOG_TYPE,
|
|
33030
|
+
});
|
|
33031
|
+
return;
|
|
33032
|
+
}
|
|
32973
33033
|
texture.initialize();
|
|
32974
33034
|
}
|
|
32975
33035
|
}
|
|
@@ -35773,7 +35833,7 @@ var Player = /** @class */ (function () {
|
|
|
35773
35833
|
Player.prototype.createComposition = function (url, options) {
|
|
35774
35834
|
if (options === void 0) { options = {}; }
|
|
35775
35835
|
return __awaiter(this, void 0, void 0, function () {
|
|
35776
|
-
var renderer, last, opts,
|
|
35836
|
+
var renderer, last, opts, source, scene, composition, firstFrameTime;
|
|
35777
35837
|
var _this = this;
|
|
35778
35838
|
return __generator(this, function (_a) {
|
|
35779
35839
|
switch (_a.label) {
|
|
@@ -35794,14 +35854,9 @@ var Player = /** @class */ (function () {
|
|
|
35794
35854
|
else {
|
|
35795
35855
|
this.assetManager = new AssetManager(opts);
|
|
35796
35856
|
}
|
|
35797
|
-
|
|
35798
|
-
|
|
35799
|
-
return [3 /*break*/, 3];
|
|
35800
|
-
case 1: return [4 /*yield*/, this.assetManager.loadScene(source, this.renderer, { env: this.env })];
|
|
35801
|
-
case 2:
|
|
35857
|
+
return [4 /*yield*/, this.assetManager.loadScene(source, this.renderer, { env: this.env })];
|
|
35858
|
+
case 1:
|
|
35802
35859
|
scene = _a.sent();
|
|
35803
|
-
_a.label = 3;
|
|
35804
|
-
case 3:
|
|
35805
35860
|
composition = new Composition(__assign$1(__assign$1({}, opts), { renderer: renderer, width: renderer.getWidth(), height: renderer.getHeight(), event: this.event, handlePlayerPause: this.handlePlayerPause, handleMessageItem: this.handleMessageItem }), scene);
|
|
35806
35861
|
if (this.ticker) {
|
|
35807
35862
|
if (composition.renderLevel === RenderLevel$1.B) {
|
|
@@ -35813,7 +35868,7 @@ var Player = /** @class */ (function () {
|
|
|
35813
35868
|
resolve(null);
|
|
35814
35869
|
});
|
|
35815
35870
|
})];
|
|
35816
|
-
case
|
|
35871
|
+
case 2:
|
|
35817
35872
|
_a.sent();
|
|
35818
35873
|
if (opts.autoplay) {
|
|
35819
35874
|
this.autoPlaying = true;
|
|
@@ -35870,7 +35925,7 @@ var Player = /** @class */ (function () {
|
|
|
35870
35925
|
}
|
|
35871
35926
|
};
|
|
35872
35927
|
/**
|
|
35873
|
-
*
|
|
35928
|
+
* 跳转全部合成到指定时间并停留
|
|
35874
35929
|
* @param time - 指定时间, 单位秒
|
|
35875
35930
|
*/
|
|
35876
35931
|
Player.prototype.gotoAndStop = function (time) {
|
|
@@ -35971,38 +36026,29 @@ var Player = /** @class */ (function () {
|
|
|
35971
36026
|
var _this = this;
|
|
35972
36027
|
var _a, _b, _c;
|
|
35973
36028
|
dt = Math.min(dt, 33) * this.speed;
|
|
35974
|
-
var removed = false;
|
|
35975
36029
|
var comps = this.compositions;
|
|
35976
36030
|
var skipRender = false;
|
|
35977
36031
|
comps.sort(function (a, b) { return a.getIndex() - b.getIndex(); });
|
|
35978
|
-
|
|
36032
|
+
this.compositions = [];
|
|
36033
|
+
for (var i = 0; i < comps.length; i++) {
|
|
36034
|
+
var composition = comps[i];
|
|
35979
36035
|
if (composition.textureOffloaded) {
|
|
35980
36036
|
skipRender = true;
|
|
35981
36037
|
console.error({
|
|
35982
36038
|
content: "Composition ".concat(composition.name, " texture offloaded, skip render."),
|
|
35983
36039
|
type: LOG_TYPE,
|
|
35984
36040
|
});
|
|
36041
|
+
this.compositions.push(composition);
|
|
36042
|
+
continue;
|
|
35985
36043
|
}
|
|
35986
|
-
if (composition.isDestroyed) {
|
|
35987
|
-
delete comps[i];
|
|
35988
|
-
removed = true;
|
|
35989
|
-
return;
|
|
35990
|
-
}
|
|
35991
|
-
if (composition.renderer) {
|
|
36044
|
+
if (!composition.isDestroyed && composition.renderer) {
|
|
35992
36045
|
composition.update(dt);
|
|
35993
36046
|
}
|
|
35994
|
-
if (composition.isDestroyed) {
|
|
35995
|
-
|
|
35996
|
-
removed = true;
|
|
35997
|
-
return;
|
|
36047
|
+
if (!composition.isDestroyed) {
|
|
36048
|
+
this.compositions.push(composition);
|
|
35998
36049
|
}
|
|
35999
|
-
});
|
|
36000
|
-
if (removed) {
|
|
36001
|
-
comps = comps.filter(function (comp) { return comp; });
|
|
36002
|
-
comps.map(function (comp, index) { return comp.setIndex(index); });
|
|
36003
|
-
this.compositions = comps;
|
|
36004
36050
|
}
|
|
36005
|
-
this.baseCompositionIndex =
|
|
36051
|
+
this.baseCompositionIndex = this.compositions.length;
|
|
36006
36052
|
if (skipRender) {
|
|
36007
36053
|
(_a = this.handleRenderError) === null || _a === void 0 ? void 0 : _a.call(this, new Error('play when texture offloaded'));
|
|
36008
36054
|
return (_b = this.ticker) === null || _b === void 0 ? void 0 : _b.pause();
|
|
@@ -36012,7 +36058,7 @@ var Player = /** @class */ (function () {
|
|
|
36012
36058
|
var gl = this.renderer.context.gl;
|
|
36013
36059
|
var time = (level === 2 && this.reportGPUTime) ? gpuTimer(gl) : undefined;
|
|
36014
36060
|
time === null || time === void 0 ? void 0 : time.begin();
|
|
36015
|
-
if (this.compositions.length || forceRender) {
|
|
36061
|
+
if (this.compositions.length || this.compositions.length < comps.length || forceRender) {
|
|
36016
36062
|
this.renderer.setFrameBuffer(null);
|
|
36017
36063
|
this.renderer.clear({
|
|
36018
36064
|
stencilAction: TextureLoadAction.clear,
|
|
@@ -36358,9 +36404,9 @@ Renderer.create = function (canvas, framework, renderOptions) {
|
|
|
36358
36404
|
Engine.create = function (gl) {
|
|
36359
36405
|
return new GLEngine(gl);
|
|
36360
36406
|
};
|
|
36361
|
-
var version = "1.1.
|
|
36407
|
+
var version = "1.1.5";
|
|
36362
36408
|
console.info({
|
|
36363
|
-
content: '[Galacean Effects Player] version: ' + "1.1.
|
|
36409
|
+
content: '[Galacean Effects Player] version: ' + "1.1.5",
|
|
36364
36410
|
type: LOG_TYPE,
|
|
36365
36411
|
});
|
|
36366
36412
|
|