@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/player.d.ts CHANGED
@@ -222,7 +222,7 @@ export declare class Player implements Disposable, LostHandler, RestoreHandler {
222
222
  */
223
223
  gotoAndPlay(time: number): void;
224
224
  /**
225
- * 跳转全部合成带指定时间并停留
225
+ * 跳转全部合成到指定时间并停留
226
226
  * @param time - 指定时间, 单位秒
227
227
  */
228
228
  gotoAndStop(time: number): void;
package/dist/weapp.js CHANGED
@@ -14727,6 +14727,9 @@ var VFXItem = /** @class */ (function () {
14727
14727
  VFXItem.isTree = function (item) {
14728
14728
  return item.type === ItemType$1.tree;
14729
14729
  };
14730
+ VFXItem.isCamera = function (item) {
14731
+ return item.type === ItemType$1.camera;
14732
+ };
14730
14733
  VFXItem.isExtraCamera = function (item) {
14731
14734
  return item.id === 'extra-camera' && item.name === 'extra-camera';
14732
14735
  };
@@ -14927,10 +14930,11 @@ var VFXItem = /** @class */ (function () {
14927
14930
  }
14928
14931
  else if (this.endBehavior === END_BEHAVIOR_DESTROY$1) {
14929
14932
  this._contentVisible = false;
14933
+ shouldUpdate = true;
14934
+ dt = 0;
14930
14935
  // 预合成配置 reusable 且销毁时, 需要隐藏其中的元素
14931
14936
  if (this.type === ItemType$1.composition) {
14932
14937
  this.handleVisibleChanged(false);
14933
- this.onItemUpdate(0, lifetime);
14934
14938
  }
14935
14939
  }
14936
14940
  lifetime = Math.min(lifetime, 1);
@@ -14939,7 +14943,6 @@ var VFXItem = /** @class */ (function () {
14939
14943
  shouldUpdate = true;
14940
14944
  if (this.endBehavior === END_BEHAVIOR_RESTART$1) {
14941
14945
  this.ended = true;
14942
- lifetime = lifetime % 1;
14943
14946
  }
14944
14947
  }
14945
14948
  }
@@ -14947,7 +14950,7 @@ var VFXItem = /** @class */ (function () {
14947
14950
  this.setVisible(true);
14948
14951
  this.callEnd = false;
14949
14952
  }
14950
- this.lifetime = lifetime;
14953
+ this.lifetime = lifetime % 1;
14951
14954
  shouldUpdate && this.onItemUpdate(dt, lifetime);
14952
14955
  }
14953
14956
  }
@@ -15514,10 +15517,6 @@ var CameraVFXItem = /** @class */ (function (_super) {
15514
15517
  (_a = this.controller) === null || _a === void 0 ? void 0 : _a.update(lifetime);
15515
15518
  this.updateCamera();
15516
15519
  };
15517
- // override onEnd () {
15518
- // this.controller?.update(1);
15519
- // this.updateCamera();
15520
- // }
15521
15520
  CameraVFXItem.prototype.updateCamera = function () {
15522
15521
  if (this.controller && this.composition) {
15523
15522
  var camera = this.composition.camera;
@@ -19274,19 +19273,28 @@ var SpriteMesh = /** @class */ (function () {
19274
19273
  var aPointLen = 0;
19275
19274
  var indexLen = 0;
19276
19275
  var pointCount = 0;
19276
+ var renderInfo;
19277
19277
  if (!items.length) {
19278
19278
  this.mesh.setVisible(false);
19279
19279
  return true;
19280
19280
  }
19281
+ for (var i = 0; i < items.length; i++) {
19282
+ if (items[i].renderInfo) {
19283
+ renderInfo = items[i].renderInfo;
19284
+ break;
19285
+ }
19286
+ }
19287
+ if (!renderInfo) {
19288
+ return true;
19289
+ }
19281
19290
  this.items = items.slice();
19282
19291
  if (items.length > 2) {
19283
19292
  itemSlot = exports.maxSpriteMeshItemCount;
19284
19293
  }
19285
- var renderInfo = items[0].renderInfo;
19286
19294
  if (this.mtlSlotCount !== itemSlot) {
19287
19295
  this.mesh.setMaterial(this.createMaterial(renderInfo, itemSlot), { textures: exports.DestroyOptions.keep });
19288
19296
  }
19289
- var attachmentLength = (_d = (_c = (_b = (_a = renderInfo === null || renderInfo === void 0 ? void 0 : 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;
19297
+ 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;
19290
19298
  this.splitLayer = attachmentLength > 0;
19291
19299
  for (var i = 0; i < items.length; i++) {
19292
19300
  var item = items[i];
@@ -23562,7 +23570,7 @@ var ParticleSystem = /** @class */ (function () {
23562
23570
  configurable: true
23563
23571
  });
23564
23572
  ParticleSystem.prototype.updateEmitterTransform = function (time) {
23565
- var parentTransform = this.parentTransform;
23573
+ var parentTransform = this.transform.parentTransform;
23566
23574
  var _a = this.basicTransform, path = _a.path, position = _a.position;
23567
23575
  var selfPos = position.clone();
23568
23576
  if (path) {
@@ -23572,9 +23580,9 @@ var ParticleSystem = /** @class */ (function () {
23572
23580
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
23573
23581
  if (this.options.particleFollowParent && parentTransform) {
23574
23582
  var tempMatrix = parentTransform.getWorldMatrix();
23575
- this.particleMesh.mesh.worldMatrix = tempMatrix.clone();
23583
+ this.particleMesh.mesh.worldMatrix = tempMatrix;
23576
23584
  if (this.trailMesh) {
23577
- this.trailMesh.mesh.worldMatrix = tempMatrix.clone();
23585
+ this.trailMesh.mesh.worldMatrix = tempMatrix;
23578
23586
  }
23579
23587
  }
23580
23588
  };
@@ -23593,8 +23601,8 @@ var ParticleSystem = /** @class */ (function () {
23593
23601
  link.pushNode(linkContent);
23594
23602
  this.particleMesh.setPoint(point, pointIndex);
23595
23603
  this.clearPointTrail(pointIndex);
23596
- if (this.parentTransform && this.trailMesh) {
23597
- this.trailMesh.setPointStartPos(pointIndex, this.parentTransform.position.clone());
23604
+ if (this.trailMesh) {
23605
+ this.trailMesh.setPointStartPos(pointIndex, this.transform.parentTransform.position.clone());
23598
23606
  }
23599
23607
  };
23600
23608
  ParticleSystem.prototype.setVisible = function (visible) {
@@ -23632,7 +23640,8 @@ var ParticleSystem = /** @class */ (function () {
23632
23640
  }
23633
23641
  };
23634
23642
  ParticleSystem.prototype.setParentTransform = function (transform) {
23635
- this.parentTransform = transform;
23643
+ // this.transform.parentTransform = transform;
23644
+ // this.parentTransform = transform;
23636
23645
  };
23637
23646
  ParticleSystem.prototype.getTextures = function () {
23638
23647
  var e_1, _a, e_2, _b;
@@ -23884,9 +23893,7 @@ var ParticleSystem = /** @class */ (function () {
23884
23893
  if (options.removeParticle) {
23885
23894
  mesh.removePoint(pointIndex);
23886
23895
  this.clearPointTrail(pointIndex);
23887
- link.removeNode(node);
23888
- node.content = [0];
23889
- // link.shiftNode(node.content); // 删了又加回去 没明白什么意思
23896
+ node.content[0] = 0;
23890
23897
  }
23891
23898
  hitPositions.push(pos);
23892
23899
  if (!options.multiple) {
@@ -23925,8 +23932,8 @@ var ParticleSystem = /** @class */ (function () {
23925
23932
  if (trails.sizeAffectsLifetime) {
23926
23933
  lifetime *= size[0];
23927
23934
  }
23928
- if (trails.parentAffectsPosition && this.parentTransform) {
23929
- position.add(this.parentTransform.position);
23935
+ if (trails.parentAffectsPosition && this.transform.parentTransform) {
23936
+ position.add(this.transform.parentTransform.position);
23930
23937
  var pos = this.trailMesh.getPointStartPos(pointIndex);
23931
23938
  if (pos) {
23932
23939
  position.subtract(pos);
@@ -24140,7 +24147,9 @@ function randomArrItem(arr, keepArr) {
24140
24147
  var ParticleVFXItem = /** @class */ (function (_super) {
24141
24148
  __extends(ParticleVFXItem, _super);
24142
24149
  function ParticleVFXItem() {
24143
- return _super !== null && _super.apply(this, arguments) || this;
24150
+ var _this = _super !== null && _super.apply(this, arguments) || this;
24151
+ _this.destroyed = false;
24152
+ return _this;
24144
24153
  }
24145
24154
  Object.defineProperty(ParticleVFXItem.prototype, "type", {
24146
24155
  get: function () {
@@ -24166,12 +24175,11 @@ var ParticleVFXItem = /** @class */ (function (_super) {
24166
24175
  ParticleVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
24167
24176
  var _a;
24168
24177
  if (this.content) {
24169
- var hide = !this.contentVisible;
24178
+ var hide = !this.visible;
24170
24179
  var parentItem = this.parentId && ((_a = this.composition) === null || _a === void 0 ? void 0 : _a.getItemByID(this.parentId));
24171
24180
  if (!hide && parentItem) {
24172
24181
  var parentData = parentItem.getRenderData();
24173
24182
  if (parentData) {
24174
- this.content.setParentTransform(parentData.transform);
24175
24183
  if (!parentData.visible) {
24176
24184
  hide = false;
24177
24185
  }
@@ -29174,7 +29182,6 @@ var CompositionSourceManager = /** @class */ (function () {
29174
29182
  }
29175
29183
  var cachedTextures = textureOptions.map(function (option) { return option && (option instanceof Texture ? option : Texture.create(engine, option)); });
29176
29184
  // 缓存创建的Texture对象
29177
- // @ts-expect-error
29178
29185
  scene.textureOptions = cachedTextures;
29179
29186
  cachedTextures === null || cachedTextures === void 0 ? void 0 : cachedTextures.forEach(function (tex) { return tex === null || tex === void 0 ? void 0 : tex.initialize(); });
29180
29187
  try {
@@ -29404,24 +29411,24 @@ var AssetManager = /** @class */ (function () {
29404
29411
  this.timeout = timeout;
29405
29412
  };
29406
29413
  /**
29407
- * 场景创建
29408
- * 通过 json 创建出场景对象,并进行提前编译等工作
29414
+ * 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
29409
29415
  * @param url - json 的 URL 链接或者 json 对象
29410
29416
  * @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
29411
29417
  * @param options - 扩展参数
29412
29418
  * @returns
29413
29419
  */
29414
29420
  AssetManager.prototype.loadScene = function (url, renderer, options) {
29415
- var _a, _b;
29421
+ var _a, _b, _c;
29416
29422
  return __awaiter(this, void 0, void 0, function () {
29417
- var rawJSON, timeLabel, startTime, timeInfos, gpuInstance, asyncShaderCompile, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
29423
+ var rawJSON, timeLabel, startTime, timeInfos, gpuInstance, asyncShaderCompile, compressedTexture, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
29418
29424
  var _this = this;
29419
- return __generator(this, function (_c) {
29425
+ return __generator(this, function (_d) {
29420
29426
  timeLabel = "Load asset: ".concat(isString(url) ? url : this.id);
29421
29427
  startTime = weapp.performance.now();
29422
29428
  timeInfos = [];
29423
29429
  gpuInstance = renderer === null || renderer === void 0 ? void 0 : renderer.engine.gpuCapability;
29424
29430
  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;
29431
+ compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
29425
29432
  cancelLoading = false;
29426
29433
  waitPromise = new Promise(function (resolve, reject) {
29427
29434
  return loadTimer = weapp.window.setTimeout(function () {
@@ -29446,10 +29453,10 @@ var AssetManager = /** @class */ (function () {
29446
29453
  });
29447
29454
  }); };
29448
29455
  loadResourcePromise = function () { return __awaiter(_this, void 0, void 0, function () {
29449
- var _a, usedImages, jsonScene, _b, bins, images, compositions, fonts, _c, loadedBins, loadedImages, loadedTextures, scene, totalTime;
29456
+ 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;
29450
29457
  var _this = this;
29451
- return __generator(this, function (_d) {
29452
- switch (_d.label) {
29458
+ return __generator(this, function (_e) {
29459
+ switch (_e.label) {
29453
29460
  case 0:
29454
29461
  if (!isObject(url)) return [3 /*break*/, 1];
29455
29462
  // TODO: 原 JSONLoader contructor 判断是否兼容
@@ -29462,42 +29469,66 @@ var AssetManager = /** @class */ (function () {
29462
29469
  this.baseUrl = url;
29463
29470
  return [4 /*yield*/, hookTimeInfo('loadJSON', function () { return _this.loadJSON(url); })];
29464
29471
  case 2:
29465
- rawJSON = _d.sent();
29466
- _d.label = 3;
29467
- case 3: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
29472
+ rawJSON = _e.sent();
29473
+ _e.label = 3;
29474
+ case 3:
29475
+ if (!isScene(rawJSON)) return [3 /*break*/, 6];
29476
+ // 已经加载过的 可能需要更新数据模板
29477
+ scene = __assign$1({}, rawJSON);
29478
+ if (!(this.options && this.options.variables && Object.keys(this.options.variables).length !== 0)) return [3 /*break*/, 5];
29479
+ rawImages = rawJSON.jsonScene.images;
29480
+ images_1 = scene.images;
29481
+ for (i = 0; i < rawImages.length; i++) {
29482
+ // 仅重新加载数据模板对应的图片
29483
+ if (images_1[i] instanceof weapp.HTMLCanvasElement) {
29484
+ images_1[i] = rawImages[i];
29485
+ }
29486
+ }
29487
+ _a = scene;
29488
+ return [4 /*yield*/, hookTimeInfo('processImages', function () { return _this.processImages(images_1, scene.usedImages, compressedTexture); })];
29468
29489
  case 4:
29469
- _a = _d.sent(), usedImages = _a.usedImages, jsonScene = _a.jsonScene;
29470
- _b = jsonScene.bins, bins = _b === void 0 ? [] : _b, images = jsonScene.images, compositions = jsonScene.compositions, fonts = jsonScene.fonts;
29490
+ _a.images = _e.sent();
29491
+ // 更新 TextureOptions 中的 image 指向
29492
+ for (i = 0; i < scene.images.length; i++) {
29493
+ scene.textureOptions[i].image = scene.images[i];
29494
+ }
29495
+ _e.label = 5;
29496
+ case 5: return [3 /*break*/, 12];
29497
+ case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
29498
+ case 7:
29499
+ _b = _e.sent(), usedImages_1 = _b.usedImages, jsonScene_1 = _b.jsonScene, pluginSystem_1 = _b.pluginSystem;
29500
+ _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;
29471
29501
  return [4 /*yield*/, Promise.all([
29472
- hookTimeInfo('processBins', function () { return _this.processBins(bins); }),
29473
- hookTimeInfo('processImages', function () { var _a; return _this.processImages(images, usedImages, (_a = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _a !== void 0 ? _a : 0); }),
29474
- hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(compositions, renderer, options); }),
29502
+ hookTimeInfo('processBins', function () { return _this.processBins(bins_1); }),
29503
+ hookTimeInfo('processImages', function () { return _this.processImages(images_2, usedImages_1, compressedTexture); }),
29504
+ hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(compositions_1, pluginSystem_1, renderer, options); }),
29475
29505
  ])];
29476
- case 5:
29477
- _c = __read$3.apply(void 0, [_d.sent(), 2]), loadedBins = _c[0], loadedImages = _c[1];
29478
- return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(fonts); })];
29479
- case 6:
29480
- _d.sent();
29481
- return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages, loadedBins, jsonScene); })];
29482
- case 7:
29483
- loadedTextures = _d.sent();
29506
+ case 8:
29507
+ _d = __read$3.apply(void 0, [_e.sent(), 2]), loadedBins_1 = _d[0], loadedImages_1 = _d[1];
29508
+ return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(fonts_1); })];
29509
+ case 9:
29510
+ _e.sent();
29511
+ return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
29512
+ case 10:
29513
+ loadedTextures = _e.sent();
29484
29514
  scene = {
29485
- jsonScene: jsonScene,
29486
- images: loadedImages,
29487
- textureOptions: loadedTextures,
29488
- bins: loadedBins,
29489
- storage: {},
29490
- pluginSystem: this.pluginSystem,
29491
- renderLevel: this.options.renderLevel,
29492
- totalTime: 0,
29493
- startTime: 0,
29494
29515
  url: url,
29516
+ renderLevel: this.options.renderLevel,
29517
+ storage: {},
29518
+ pluginSystem: pluginSystem_1,
29519
+ jsonScene: jsonScene_1,
29520
+ usedImages: usedImages_1,
29521
+ images: loadedImages_1,
29522
+ textureOptions: loadedTextures,
29523
+ bins: loadedBins_1,
29495
29524
  };
29496
29525
  // 触发插件系统 pluginSystem 的回调 prepareResource
29497
- return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return _this.pluginSystem.loadResources(scene, _this.options); })];
29498
- case 8:
29526
+ return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return pluginSystem_1.loadResources(scene, _this.options); })];
29527
+ case 11:
29499
29528
  // 触发插件系统 pluginSystem 的回调 prepareResource
29500
- _d.sent();
29529
+ _e.sent();
29530
+ _e.label = 12;
29531
+ case 12:
29501
29532
  totalTime = weapp.performance.now() - startTime;
29502
29533
  console.info({
29503
29534
  content: "".concat(timeLabel, ": ").concat(totalTime.toFixed(4), "ms, ").concat(timeInfos.join(' ')),
@@ -29514,7 +29545,7 @@ var AssetManager = /** @class */ (function () {
29514
29545
  });
29515
29546
  });
29516
29547
  };
29517
- AssetManager.prototype.precompile = function (compositions, renderer, options) {
29548
+ AssetManager.prototype.precompile = function (compositions, pluginSystem, renderer, options) {
29518
29549
  return __awaiter(this, void 0, void 0, function () {
29519
29550
  var shaderLibrary;
29520
29551
  return __generator(this, function (_a) {
@@ -29524,7 +29555,7 @@ var AssetManager = /** @class */ (function () {
29524
29555
  return [2 /*return*/];
29525
29556
  }
29526
29557
  shaderLibrary = renderer === null || renderer === void 0 ? void 0 : renderer.getShaderLibrary();
29527
- return [4 /*yield*/, this.pluginSystem.precompile(compositions, renderer, options)];
29558
+ return [4 /*yield*/, (pluginSystem === null || pluginSystem === void 0 ? void 0 : pluginSystem.precompile(compositions, renderer, options))];
29528
29559
  case 1:
29529
29560
  _a.sent();
29530
29561
  return [4 /*yield*/, new Promise(function (resolve) {
@@ -29541,7 +29572,7 @@ var AssetManager = /** @class */ (function () {
29541
29572
  };
29542
29573
  AssetManager.prototype.processJSON = function (json) {
29543
29574
  return __awaiter(this, void 0, void 0, function () {
29544
- var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, renderLevel, usedImages;
29575
+ var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, pluginSystem, renderLevel, usedImages;
29545
29576
  return __generator(this, function (_b) {
29546
29577
  switch (_b.label) {
29547
29578
  case 0:
@@ -29555,8 +29586,8 @@ var AssetManager = /** @class */ (function () {
29555
29586
  }
29556
29587
  });
29557
29588
  _a = jsonScene.plugins, plugins = _a === void 0 ? [] : _a, sceneCompositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, images = jsonScene.images;
29558
- this.pluginSystem = new PluginSystem(plugins);
29559
- return [4 /*yield*/, this.pluginSystem.processRawJSON(jsonScene, this.options)];
29589
+ pluginSystem = new PluginSystem(plugins);
29590
+ return [4 /*yield*/, pluginSystem.processRawJSON(jsonScene, this.options)];
29560
29591
  case 1:
29561
29592
  _b.sent();
29562
29593
  renderLevel = this.options.renderLevel;
@@ -29573,6 +29604,7 @@ var AssetManager = /** @class */ (function () {
29573
29604
  return [2 /*return*/, {
29574
29605
  usedImages: usedImages,
29575
29606
  jsonScene: jsonScene,
29607
+ pluginSystem: pluginSystem,
29576
29608
  }];
29577
29609
  }
29578
29610
  });
@@ -29956,7 +29988,8 @@ var CompVFXItem = /** @class */ (function (_super) {
29956
29988
  }
29957
29989
  else {
29958
29990
  item = createVFXItem(this.itemProps[i], this.composition);
29959
- item.transform.parentTransform = this.transform;
29991
+ // 相机不跟随合成移动
29992
+ item.transform.parentTransform = VFXItem.isCamera(item) ? new Transform() : this.transform;
29960
29993
  }
29961
29994
  if (VFXItem.isExtraCamera(item)) {
29962
29995
  this.extraCamera = item;
@@ -30142,7 +30175,7 @@ var CompVFXItem = /** @class */ (function (_super) {
30142
30175
  if (!parentItem) {
30143
30176
  itemNode.parentId = undefined;
30144
30177
  item.parent = undefined;
30145
- item.transform.parentTransform = this.transform;
30178
+ item.transform.parentTransform = VFXItem.isExtraCamera(item) ? new Transform() : this.transform;
30146
30179
  }
30147
30180
  else {
30148
30181
  var parentNode = this.itemCacheMap.get(parentItem.id);
@@ -30439,7 +30472,7 @@ var Composition = /** @class */ (function () {
30439
30472
  });
30440
30473
  Object.defineProperty(Composition.prototype, "startTime", {
30441
30474
  /**
30442
- * 获取合成开始时间
30475
+ * 获取合成开始渲染的时间
30443
30476
  */
30444
30477
  get: function () {
30445
30478
  var _a;
@@ -30519,7 +30552,12 @@ var Composition = /** @class */ (function () {
30519
30552
  if (this.content.ended && this.reusable) {
30520
30553
  this.restart();
30521
30554
  }
30522
- this.gotoAndPlay(this.time);
30555
+ if (this.content.started) {
30556
+ this.gotoAndPlay(this.time - this.startTime);
30557
+ }
30558
+ else {
30559
+ this.gotoAndPlay(0);
30560
+ }
30523
30561
  };
30524
30562
  /**
30525
30563
  * 暂停合成的播放
@@ -30533,14 +30571,21 @@ var Composition = /** @class */ (function () {
30533
30571
  Composition.prototype.resume = function () {
30534
30572
  this.paused = false;
30535
30573
  };
30574
+ /**
30575
+ * 跳转合成到指定时间播放
30576
+ * @param time - 相对 startTime 的时间
30577
+ */
30536
30578
  Composition.prototype.gotoAndPlay = function (time) {
30537
30579
  this.resume();
30538
30580
  if (!this.content.started) {
30539
30581
  this.content.start();
30540
- this.forwardTime(this.startTime);
30541
30582
  }
30542
- this.forwardTime(time);
30583
+ this.forwardTime(time + this.startTime);
30543
30584
  };
30585
+ /**
30586
+ * 跳转合成到指定时间并暂停
30587
+ * @param time - 相对 startTime 的时间
30588
+ */
30544
30589
  Composition.prototype.gotoAndStop = function (time) {
30545
30590
  this.gotoAndPlay(time);
30546
30591
  this.pause();
@@ -30560,21 +30605,29 @@ var Composition = /** @class */ (function () {
30560
30605
  };
30561
30606
  /**
30562
30607
  * 跳到指定时间点(不做任何播放行为)
30563
- * @param time - 指定的时间
30608
+ * @param time - 相对 startTime 的时间
30564
30609
  */
30565
30610
  Composition.prototype.setTime = function (time) {
30566
30611
  var pause = this.paused;
30567
30612
  if (pause) {
30568
30613
  this.resume();
30569
30614
  }
30570
- this.forwardTime(time, true);
30615
+ if (!this.content.started) {
30616
+ this.content.start();
30617
+ }
30618
+ this.forwardTime(time + this.startTime, true);
30571
30619
  if (pause) {
30572
30620
  this.pause();
30573
30621
  }
30574
30622
  };
30623
+ /**
30624
+ * 前进合成到指定时间
30625
+ * @param time - 相对0时刻的时间
30626
+ * @param skipRender - 是否跳过渲染
30627
+ */
30575
30628
  Composition.prototype.forwardTime = function (time, skipRender) {
30576
30629
  if (skipRender === void 0) { skipRender = false; }
30577
- var deltaTime = (this.startTime + Math.max(0, time)) * 1000 - this.content.timeInms;
30630
+ var deltaTime = time * 1000 - this.content.timeInms;
30578
30631
  var reverse = deltaTime < 0;
30579
30632
  var step = 15;
30580
30633
  var t = Math.abs(deltaTime);
@@ -32974,6 +33027,13 @@ var GLMaterial = /** @class */ (function (_super) {
32974
33027
  try {
32975
33028
  for (var _b = __values$1(Object.values(this.textures)), _c = _b.next(); !_c.done; _c = _b.next()) {
32976
33029
  var texture = _c.value;
33030
+ if (!isFunction(texture.initialize)) {
33031
+ console.error({
33032
+ content: "".concat(JSON.stringify(texture), " is not valid Texture to initialize"),
33033
+ type: LOG_TYPE,
33034
+ });
33035
+ return;
33036
+ }
32977
33037
  texture.initialize();
32978
33038
  }
32979
33039
  }
@@ -35777,7 +35837,7 @@ var Player = /** @class */ (function () {
35777
35837
  Player.prototype.createComposition = function (url, options) {
35778
35838
  if (options === void 0) { options = {}; }
35779
35839
  return __awaiter(this, void 0, void 0, function () {
35780
- var renderer, last, opts, scene, source, composition, firstFrameTime;
35840
+ var renderer, last, opts, source, scene, composition, firstFrameTime;
35781
35841
  var _this = this;
35782
35842
  return __generator(this, function (_a) {
35783
35843
  switch (_a.label) {
@@ -35798,14 +35858,9 @@ var Player = /** @class */ (function () {
35798
35858
  else {
35799
35859
  this.assetManager = new AssetManager(opts);
35800
35860
  }
35801
- if (!isScene(source)) return [3 /*break*/, 1];
35802
- scene = source;
35803
- return [3 /*break*/, 3];
35804
- case 1: return [4 /*yield*/, this.assetManager.loadScene(source, this.renderer, { env: this.env })];
35805
- case 2:
35861
+ return [4 /*yield*/, this.assetManager.loadScene(source, this.renderer, { env: this.env })];
35862
+ case 1:
35806
35863
  scene = _a.sent();
35807
- _a.label = 3;
35808
- case 3:
35809
35864
  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);
35810
35865
  if (this.ticker) {
35811
35866
  if (composition.renderLevel === RenderLevel$1.B) {
@@ -35817,7 +35872,7 @@ var Player = /** @class */ (function () {
35817
35872
  resolve(null);
35818
35873
  });
35819
35874
  })];
35820
- case 4:
35875
+ case 2:
35821
35876
  _a.sent();
35822
35877
  if (opts.autoplay) {
35823
35878
  this.autoPlaying = true;
@@ -35874,7 +35929,7 @@ var Player = /** @class */ (function () {
35874
35929
  }
35875
35930
  };
35876
35931
  /**
35877
- * 跳转全部合成带指定时间并停留
35932
+ * 跳转全部合成到指定时间并停留
35878
35933
  * @param time - 指定时间, 单位秒
35879
35934
  */
35880
35935
  Player.prototype.gotoAndStop = function (time) {
@@ -35975,38 +36030,29 @@ var Player = /** @class */ (function () {
35975
36030
  var _this = this;
35976
36031
  var _a, _b, _c;
35977
36032
  dt = Math.min(dt, 33) * this.speed;
35978
- var removed = false;
35979
36033
  var comps = this.compositions;
35980
36034
  var skipRender = false;
35981
36035
  comps.sort(function (a, b) { return a.getIndex() - b.getIndex(); });
35982
- comps.forEach(function (composition, i) {
36036
+ this.compositions = [];
36037
+ for (var i = 0; i < comps.length; i++) {
36038
+ var composition = comps[i];
35983
36039
  if (composition.textureOffloaded) {
35984
36040
  skipRender = true;
35985
36041
  console.error({
35986
36042
  content: "Composition ".concat(composition.name, " texture offloaded, skip render."),
35987
36043
  type: LOG_TYPE,
35988
36044
  });
36045
+ this.compositions.push(composition);
36046
+ continue;
35989
36047
  }
35990
- if (composition.isDestroyed) {
35991
- delete comps[i];
35992
- removed = true;
35993
- return;
35994
- }
35995
- if (composition.renderer) {
36048
+ if (!composition.isDestroyed && composition.renderer) {
35996
36049
  composition.update(dt);
35997
36050
  }
35998
- if (composition.isDestroyed) {
35999
- delete comps[i];
36000
- removed = true;
36001
- return;
36051
+ if (!composition.isDestroyed) {
36052
+ this.compositions.push(composition);
36002
36053
  }
36003
- });
36004
- if (removed) {
36005
- comps = comps.filter(function (comp) { return comp; });
36006
- comps.map(function (comp, index) { return comp.setIndex(index); });
36007
- this.compositions = comps;
36008
36054
  }
36009
- this.baseCompositionIndex = comps.length;
36055
+ this.baseCompositionIndex = this.compositions.length;
36010
36056
  if (skipRender) {
36011
36057
  (_a = this.handleRenderError) === null || _a === void 0 ? void 0 : _a.call(this, new Error('play when texture offloaded'));
36012
36058
  return (_b = this.ticker) === null || _b === void 0 ? void 0 : _b.pause();
@@ -36016,7 +36062,7 @@ var Player = /** @class */ (function () {
36016
36062
  var gl = this.renderer.context.gl;
36017
36063
  var time = (level === 2 && this.reportGPUTime) ? gpuTimer(gl) : undefined;
36018
36064
  time === null || time === void 0 ? void 0 : time.begin();
36019
- if (this.compositions.length || forceRender) {
36065
+ if (this.compositions.length || this.compositions.length < comps.length || forceRender) {
36020
36066
  this.renderer.setFrameBuffer(null);
36021
36067
  this.renderer.clear({
36022
36068
  stencilAction: exports.TextureLoadAction.clear,
@@ -36362,9 +36408,9 @@ Renderer.create = function (canvas, framework, renderOptions) {
36362
36408
  Engine.create = function (gl) {
36363
36409
  return new GLEngine(gl);
36364
36410
  };
36365
- var version = "1.1.3";
36411
+ var version = "1.1.5";
36366
36412
  console.info({
36367
- content: '[Galacean Effects Player] version: ' + "1.1.3",
36413
+ content: '[Galacean Effects Player] version: ' + "1.1.5",
36368
36414
  type: LOG_TYPE,
36369
36415
  });
36370
36416