@galacean/effects 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 CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime player for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v1.1.2
6
+ * Version: v1.1.4
7
7
  */
8
8
 
9
9
  'use strict';
@@ -9327,11 +9327,9 @@ var Matrix4$1 = /** @class */ (function () {
9327
9327
  var vX = Matrix4.tempVec0;
9328
9328
  var vY = Matrix4.tempVec1;
9329
9329
  var vZ = Matrix4.tempVec2;
9330
- vZ.subtractVectors(target, eye);
9330
+ vZ.subtractVectors(eye, target);
9331
9331
  vZ.normalize();
9332
- vY.copyFrom(up);
9333
- vY.normalize();
9334
- vX.crossVectors(vY, vZ);
9332
+ vX.crossVectors(up, vZ);
9335
9333
  vX.normalize();
9336
9334
  vY.crossVectors(vZ, vX);
9337
9335
  var te = this.elements;
@@ -14735,6 +14733,9 @@ var VFXItem = /** @class */ (function () {
14735
14733
  VFXItem.isTree = function (item) {
14736
14734
  return item.type === ItemType$1.tree;
14737
14735
  };
14736
+ VFXItem.isCamera = function (item) {
14737
+ return item.type === ItemType$1.camera;
14738
+ };
14738
14739
  VFXItem.isExtraCamera = function (item) {
14739
14740
  return item.id === 'extra-camera' && item.name === 'extra-camera';
14740
14741
  };
@@ -14935,10 +14936,11 @@ var VFXItem = /** @class */ (function () {
14935
14936
  }
14936
14937
  else if (this.endBehavior === END_BEHAVIOR_DESTROY$1) {
14937
14938
  this._contentVisible = false;
14939
+ shouldUpdate = true;
14940
+ dt = 0;
14938
14941
  // 预合成配置 reusable 且销毁时, 需要隐藏其中的元素
14939
14942
  if (this.type === ItemType$1.composition) {
14940
14943
  this.handleVisibleChanged(false);
14941
- this.onItemUpdate(0, lifetime);
14942
14944
  }
14943
14945
  }
14944
14946
  lifetime = Math.min(lifetime, 1);
@@ -15522,10 +15524,6 @@ var CameraVFXItem = /** @class */ (function (_super) {
15522
15524
  (_a = this.controller) === null || _a === void 0 ? void 0 : _a.update(lifetime);
15523
15525
  this.updateCamera();
15524
15526
  };
15525
- // override onEnd () {
15526
- // this.controller?.update(1);
15527
- // this.updateCamera();
15528
- // }
15529
15527
  CameraVFXItem.prototype.updateCamera = function () {
15530
15528
  if (this.controller && this.composition) {
15531
15529
  var camera = this.composition.camera;
@@ -16020,7 +16018,7 @@ function loadImage(source) {
16020
16018
  }
16021
16019
  // 2. 非法类型
16022
16020
  if (!url) {
16023
- throw new Error("Invalid url type: ".concat(source));
16021
+ throw new Error("Invalid url type: ".concat(JSON.stringify(source)));
16024
16022
  }
16025
16023
  return [2 /*return*/, new Promise(function (resolve, reject) {
16026
16024
  var img = new Image();
@@ -16039,7 +16037,7 @@ function loadImage(source) {
16039
16037
  if (revokeURL) {
16040
16038
  URL.revokeObjectURL(url);
16041
16039
  }
16042
- return reject("Load image fail: ".concat(e));
16040
+ return reject("Load image fail: ".concat(JSON.stringify(e)));
16043
16041
  };
16044
16042
  img.src = url;
16045
16043
  })];
@@ -23570,7 +23568,7 @@ var ParticleSystem = /** @class */ (function () {
23570
23568
  configurable: true
23571
23569
  });
23572
23570
  ParticleSystem.prototype.updateEmitterTransform = function (time) {
23573
- var parentTransform = this.parentTransform;
23571
+ var parentTransform = this.transform.parentTransform;
23574
23572
  var _a = this.basicTransform, path = _a.path, position = _a.position;
23575
23573
  var selfPos = position.clone();
23576
23574
  if (path) {
@@ -23580,9 +23578,9 @@ var ParticleSystem = /** @class */ (function () {
23580
23578
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
23581
23579
  if (this.options.particleFollowParent && parentTransform) {
23582
23580
  var tempMatrix = parentTransform.getWorldMatrix();
23583
- this.particleMesh.mesh.worldMatrix = tempMatrix.clone();
23581
+ this.particleMesh.mesh.worldMatrix = tempMatrix;
23584
23582
  if (this.trailMesh) {
23585
- this.trailMesh.mesh.worldMatrix = tempMatrix.clone();
23583
+ this.trailMesh.mesh.worldMatrix = tempMatrix;
23586
23584
  }
23587
23585
  }
23588
23586
  };
@@ -23601,8 +23599,8 @@ var ParticleSystem = /** @class */ (function () {
23601
23599
  link.pushNode(linkContent);
23602
23600
  this.particleMesh.setPoint(point, pointIndex);
23603
23601
  this.clearPointTrail(pointIndex);
23604
- if (this.parentTransform && this.trailMesh) {
23605
- this.trailMesh.setPointStartPos(pointIndex, this.parentTransform.position.clone());
23602
+ if (this.trailMesh) {
23603
+ this.trailMesh.setPointStartPos(pointIndex, this.transform.parentTransform.position.clone());
23606
23604
  }
23607
23605
  };
23608
23606
  ParticleSystem.prototype.setVisible = function (visible) {
@@ -23640,7 +23638,8 @@ var ParticleSystem = /** @class */ (function () {
23640
23638
  }
23641
23639
  };
23642
23640
  ParticleSystem.prototype.setParentTransform = function (transform) {
23643
- this.parentTransform = transform;
23641
+ // this.transform.parentTransform = transform;
23642
+ // this.parentTransform = transform;
23644
23643
  };
23645
23644
  ParticleSystem.prototype.getTextures = function () {
23646
23645
  var e_1, _a, e_2, _b;
@@ -23933,8 +23932,8 @@ var ParticleSystem = /** @class */ (function () {
23933
23932
  if (trails.sizeAffectsLifetime) {
23934
23933
  lifetime *= size[0];
23935
23934
  }
23936
- if (trails.parentAffectsPosition && this.parentTransform) {
23937
- position.add(this.parentTransform.position);
23935
+ if (trails.parentAffectsPosition && this.transform.parentTransform) {
23936
+ position.add(this.transform.parentTransform.position);
23938
23937
  var pos = this.trailMesh.getPointStartPos(pointIndex);
23939
23938
  if (pos) {
23940
23939
  position.subtract(pos);
@@ -24174,12 +24173,11 @@ var ParticleVFXItem = /** @class */ (function (_super) {
24174
24173
  ParticleVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
24175
24174
  var _a;
24176
24175
  if (this.content) {
24177
- var hide = !this.contentVisible;
24176
+ var hide = !this.visible;
24178
24177
  var parentItem = this.parentId && ((_a = this.composition) === null || _a === void 0 ? void 0 : _a.getItemByID(this.parentId));
24179
24178
  if (!hide && parentItem) {
24180
24179
  var parentData = parentItem.getRenderData();
24181
24180
  if (parentData) {
24182
- this.content.setParentTransform(parentData.transform);
24183
24181
  if (!parentData.visible) {
24184
24182
  hide = false;
24185
24183
  }
@@ -29182,7 +29180,6 @@ var CompositionSourceManager = /** @class */ (function () {
29182
29180
  }
29183
29181
  var cachedTextures = textureOptions.map(function (option) { return option && (option instanceof Texture ? option : Texture.create(engine, option)); });
29184
29182
  // 缓存创建的Texture对象
29185
- // @ts-expect-error
29186
29183
  scene.textureOptions = cachedTextures;
29187
29184
  cachedTextures === null || cachedTextures === void 0 ? void 0 : cachedTextures.forEach(function (tex) { return tex === null || tex === void 0 ? void 0 : tex.initialize(); });
29188
29185
  try {
@@ -29236,7 +29233,6 @@ var CompositionSourceManager = /** @class */ (function () {
29236
29233
  CompositionSourceManager.prototype.assembleItems = function (composition) {
29237
29234
  var _this = this;
29238
29235
  var items = [];
29239
- this.mask++;
29240
29236
  composition.items.forEach(function (item) {
29241
29237
  var _a;
29242
29238
  var option = {};
@@ -29252,9 +29248,7 @@ var CompositionSourceManager = /** @class */ (function () {
29252
29248
  option.type = type;
29253
29249
  if (renderContent.renderer) {
29254
29250
  renderContent.renderer = _this.changeTex(renderContent.renderer);
29255
- if (!renderContent.renderer.mask) {
29256
- _this.processMask(renderContent.renderer, _this.mask);
29257
- }
29251
+ _this.processMask(renderContent.renderer);
29258
29252
  var split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
29259
29253
  if (Number.isInteger(renderContent.renderer.shape)) {
29260
29254
  // TODO: scene.shapes 类型问题?
@@ -29299,7 +29293,7 @@ var CompositionSourceManager = /** @class */ (function () {
29299
29293
  }
29300
29294
  // 处理预合成的渲染顺序
29301
29295
  if (option.type === ItemType$1.composition) {
29302
- var maskRef_1 = ++_this.mask;
29296
+ ++_this.mask;
29303
29297
  var refId = item.content.options.refId;
29304
29298
  if (!_this.refCompositions.get(refId)) {
29305
29299
  throw new Error('Invalid Ref Composition id: ' + refId);
@@ -29310,7 +29304,7 @@ var CompositionSourceManager = /** @class */ (function () {
29310
29304
  }
29311
29305
  ref.items.forEach(function (item) {
29312
29306
  item.listIndex = listOrder++;
29313
- _this.processMask(item.content, maskRef_1);
29307
+ _this.processMask(item.content);
29314
29308
  });
29315
29309
  option.items = ref.items;
29316
29310
  }
@@ -29349,11 +29343,17 @@ var CompositionSourceManager = /** @class */ (function () {
29349
29343
  /**
29350
29344
  * 处理蒙版和遮挡关系写入 stencil 的 ref 值
29351
29345
  */
29352
- CompositionSourceManager.prototype.processMask = function (renderer, maskRef) {
29346
+ CompositionSourceManager.prototype.processMask = function (renderer) {
29347
+ if (renderer.maskMode === MaskMode$1.NONE) {
29348
+ return;
29349
+ }
29353
29350
  if (!renderer.mask) {
29354
29351
  var maskMode = renderer.maskMode;
29355
- if (maskMode !== MaskMode$1.NONE) {
29356
- renderer.mask = maskRef;
29352
+ if (maskMode === MaskMode$1.MASK) {
29353
+ renderer.mask = ++this.mask;
29354
+ }
29355
+ else if (maskMode === MaskMode$1.OBSCURED || maskMode === MaskMode$1.REVERSE_OBSCURED) {
29356
+ renderer.mask = this.mask;
29357
29357
  }
29358
29358
  }
29359
29359
  };
@@ -29409,29 +29409,29 @@ var AssetManager = /** @class */ (function () {
29409
29409
  this.timeout = timeout;
29410
29410
  };
29411
29411
  /**
29412
- * 场景创建
29413
- * 通过 json 创建出场景对象,并进行提前编译等工作
29412
+ * 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
29414
29413
  * @param url - json 的 URL 链接或者 json 对象
29415
29414
  * @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
29416
29415
  * @param options - 扩展参数
29417
29416
  * @returns
29418
29417
  */
29419
29418
  AssetManager.prototype.loadScene = function (url, renderer, options) {
29420
- var _a, _b;
29419
+ var _a, _b, _c;
29421
29420
  return __awaiter(this, void 0, void 0, function () {
29422
- var rawJSON, timeLabel, startTime, timeInfos, gpuInstance, asyncShaderCompile, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
29421
+ var rawJSON, timeLabel, startTime, timeInfos, gpuInstance, asyncShaderCompile, compressedTexture, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
29423
29422
  var _this = this;
29424
- return __generator(this, function (_c) {
29423
+ return __generator(this, function (_d) {
29425
29424
  timeLabel = "Load asset: ".concat(isString(url) ? url : this.id);
29426
29425
  startTime = performance.now();
29427
29426
  timeInfos = [];
29428
29427
  gpuInstance = renderer === null || renderer === void 0 ? void 0 : renderer.engine.gpuCapability;
29429
29428
  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;
29429
+ compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
29430
29430
  cancelLoading = false;
29431
29431
  waitPromise = new Promise(function (resolve, reject) {
29432
29432
  return loadTimer = window.setTimeout(function () {
29433
29433
  cancelLoading = true;
29434
- reject("Load time out: ".concat(url));
29434
+ reject("Load time out: ".concat(JSON.stringify(url)));
29435
29435
  }, _this.timeout * 1000);
29436
29436
  });
29437
29437
  hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
@@ -29451,10 +29451,10 @@ var AssetManager = /** @class */ (function () {
29451
29451
  });
29452
29452
  }); };
29453
29453
  loadResourcePromise = function () { return __awaiter(_this, void 0, void 0, function () {
29454
- var _a, usedImages, jsonScene, _b, bins, images, compositions, fonts, _c, loadedBins, loadedImages, loadedTextures, scene, totalTime;
29454
+ 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;
29455
29455
  var _this = this;
29456
- return __generator(this, function (_d) {
29457
- switch (_d.label) {
29456
+ return __generator(this, function (_e) {
29457
+ switch (_e.label) {
29458
29458
  case 0:
29459
29459
  if (!isObject(url)) return [3 /*break*/, 1];
29460
29460
  // TODO: 原 JSONLoader contructor 判断是否兼容
@@ -29467,42 +29467,66 @@ var AssetManager = /** @class */ (function () {
29467
29467
  this.baseUrl = url;
29468
29468
  return [4 /*yield*/, hookTimeInfo('loadJSON', function () { return _this.loadJSON(url); })];
29469
29469
  case 2:
29470
- rawJSON = _d.sent();
29471
- _d.label = 3;
29472
- case 3: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
29470
+ rawJSON = _e.sent();
29471
+ _e.label = 3;
29472
+ case 3:
29473
+ if (!isScene(rawJSON)) return [3 /*break*/, 6];
29474
+ // 已经加载过的 可能需要更新数据模板
29475
+ scene = __assign$1({}, rawJSON);
29476
+ if (!(this.options && this.options.variables && Object.keys(this.options.variables).length !== 0)) return [3 /*break*/, 5];
29477
+ rawImages = rawJSON.jsonScene.images;
29478
+ images_1 = scene.images;
29479
+ for (i = 0; i < rawImages.length; i++) {
29480
+ // 仅重新加载数据模板对应的图片
29481
+ if (images_1[i] instanceof HTMLCanvasElement) {
29482
+ images_1[i] = rawImages[i];
29483
+ }
29484
+ }
29485
+ _a = scene;
29486
+ return [4 /*yield*/, hookTimeInfo('processImages', function () { return _this.processImages(images_1, scene.usedImages, compressedTexture); })];
29473
29487
  case 4:
29474
- _a = _d.sent(), usedImages = _a.usedImages, jsonScene = _a.jsonScene;
29475
- _b = jsonScene.bins, bins = _b === void 0 ? [] : _b, images = jsonScene.images, compositions = jsonScene.compositions, fonts = jsonScene.fonts;
29488
+ _a.images = _e.sent();
29489
+ // 更新 TextureOptions 中的 image 指向
29490
+ for (i = 0; i < scene.images.length; i++) {
29491
+ scene.textureOptions[i].image = scene.images[i];
29492
+ }
29493
+ _e.label = 5;
29494
+ case 5: return [3 /*break*/, 12];
29495
+ case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
29496
+ case 7:
29497
+ _b = _e.sent(), usedImages_1 = _b.usedImages, jsonScene_1 = _b.jsonScene, pluginSystem_1 = _b.pluginSystem;
29498
+ _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;
29476
29499
  return [4 /*yield*/, Promise.all([
29477
- hookTimeInfo('processBins', function () { return _this.processBins(bins); }),
29478
- 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); }),
29479
- hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(compositions, renderer, options); }),
29500
+ hookTimeInfo('processBins', function () { return _this.processBins(bins_1); }),
29501
+ hookTimeInfo('processImages', function () { return _this.processImages(images_2, usedImages_1, compressedTexture); }),
29502
+ hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(compositions_1, pluginSystem_1, renderer, options); }),
29480
29503
  ])];
29481
- case 5:
29482
- _c = __read$3.apply(void 0, [_d.sent(), 2]), loadedBins = _c[0], loadedImages = _c[1];
29483
- return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(fonts); })];
29484
- case 6:
29485
- _d.sent();
29486
- return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages, loadedBins, jsonScene); })];
29487
- case 7:
29488
- loadedTextures = _d.sent();
29504
+ case 8:
29505
+ _d = __read$3.apply(void 0, [_e.sent(), 2]), loadedBins_1 = _d[0], loadedImages_1 = _d[1];
29506
+ return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(fonts_1); })];
29507
+ case 9:
29508
+ _e.sent();
29509
+ return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
29510
+ case 10:
29511
+ loadedTextures = _e.sent();
29489
29512
  scene = {
29490
- jsonScene: jsonScene,
29491
- images: loadedImages,
29492
- textureOptions: loadedTextures,
29493
- bins: loadedBins,
29494
- storage: {},
29495
- pluginSystem: this.pluginSystem,
29496
- renderLevel: this.options.renderLevel,
29497
- totalTime: 0,
29498
- startTime: 0,
29499
29513
  url: url,
29514
+ renderLevel: this.options.renderLevel,
29515
+ storage: {},
29516
+ pluginSystem: pluginSystem_1,
29517
+ jsonScene: jsonScene_1,
29518
+ usedImages: usedImages_1,
29519
+ images: loadedImages_1,
29520
+ textureOptions: loadedTextures,
29521
+ bins: loadedBins_1,
29500
29522
  };
29501
29523
  // 触发插件系统 pluginSystem 的回调 prepareResource
29502
- return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return _this.pluginSystem.loadResources(scene, _this.options); })];
29503
- case 8:
29524
+ return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return pluginSystem_1.loadResources(scene, _this.options); })];
29525
+ case 11:
29504
29526
  // 触发插件系统 pluginSystem 的回调 prepareResource
29505
- _d.sent();
29527
+ _e.sent();
29528
+ _e.label = 12;
29529
+ case 12:
29506
29530
  totalTime = performance.now() - startTime;
29507
29531
  console.info({
29508
29532
  content: "".concat(timeLabel, ": ").concat(totalTime.toFixed(4), "ms, ").concat(timeInfos.join(' ')),
@@ -29519,7 +29543,7 @@ var AssetManager = /** @class */ (function () {
29519
29543
  });
29520
29544
  });
29521
29545
  };
29522
- AssetManager.prototype.precompile = function (compositions, renderer, options) {
29546
+ AssetManager.prototype.precompile = function (compositions, pluginSystem, renderer, options) {
29523
29547
  return __awaiter(this, void 0, void 0, function () {
29524
29548
  var shaderLibrary;
29525
29549
  return __generator(this, function (_a) {
@@ -29529,7 +29553,7 @@ var AssetManager = /** @class */ (function () {
29529
29553
  return [2 /*return*/];
29530
29554
  }
29531
29555
  shaderLibrary = renderer === null || renderer === void 0 ? void 0 : renderer.getShaderLibrary();
29532
- return [4 /*yield*/, this.pluginSystem.precompile(compositions, renderer, options)];
29556
+ return [4 /*yield*/, (pluginSystem === null || pluginSystem === void 0 ? void 0 : pluginSystem.precompile(compositions, renderer, options))];
29533
29557
  case 1:
29534
29558
  _a.sent();
29535
29559
  return [4 /*yield*/, new Promise(function (resolve) {
@@ -29546,7 +29570,7 @@ var AssetManager = /** @class */ (function () {
29546
29570
  };
29547
29571
  AssetManager.prototype.processJSON = function (json) {
29548
29572
  return __awaiter(this, void 0, void 0, function () {
29549
- var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, renderLevel, usedImages;
29573
+ var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, pluginSystem, renderLevel, usedImages;
29550
29574
  return __generator(this, function (_b) {
29551
29575
  switch (_b.label) {
29552
29576
  case 0:
@@ -29560,8 +29584,8 @@ var AssetManager = /** @class */ (function () {
29560
29584
  }
29561
29585
  });
29562
29586
  _a = jsonScene.plugins, plugins = _a === void 0 ? [] : _a, sceneCompositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, images = jsonScene.images;
29563
- this.pluginSystem = new PluginSystem(plugins);
29564
- return [4 /*yield*/, this.pluginSystem.processRawJSON(jsonScene, this.options)];
29587
+ pluginSystem = new PluginSystem(plugins);
29588
+ return [4 /*yield*/, pluginSystem.processRawJSON(jsonScene, this.options)];
29565
29589
  case 1:
29566
29590
  _b.sent();
29567
29591
  renderLevel = this.options.renderLevel;
@@ -29578,6 +29602,7 @@ var AssetManager = /** @class */ (function () {
29578
29602
  return [2 /*return*/, {
29579
29603
  usedImages: usedImages,
29580
29604
  jsonScene: jsonScene,
29605
+ pluginSystem: pluginSystem,
29581
29606
  }];
29582
29607
  }
29583
29608
  });
@@ -29596,7 +29621,7 @@ var AssetManager = /** @class */ (function () {
29596
29621
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
29597
29622
  return _this.loadBins(bin.url);
29598
29623
  }
29599
- throw new Error("Invalid bins source: ".concat(bins));
29624
+ throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
29600
29625
  });
29601
29626
  return [2 /*return*/, Promise.all(jobs)];
29602
29627
  });
@@ -29632,7 +29657,7 @@ var AssetManager = /** @class */ (function () {
29632
29657
  case 3:
29633
29658
  _b.sent();
29634
29659
  console.warn({
29635
- content: "Invalid fonts source: ".concat(font.fontURL),
29660
+ content: "Invalid fonts source: ".concat(JSON.stringify(font.fontURL)),
29636
29661
  type: LOG_TYPE,
29637
29662
  });
29638
29663
  return [3 /*break*/, 4];
@@ -29801,7 +29826,7 @@ var AssetManager = /** @class */ (function () {
29801
29826
  return __generator(this, function (_a) {
29802
29827
  return [2 /*return*/, new Promise(function (resolve, reject) {
29803
29828
  _this.downloader.downloadJSON(url, resolve, function (status, responseText) {
29804
- reject("Couldn't load JSON ".concat(url, ": status ").concat(status, ", ").concat(responseText));
29829
+ reject("Couldn't load JSON ".concat(JSON.stringify(url), ": status ").concat(status, ", ").concat(responseText));
29805
29830
  });
29806
29831
  })];
29807
29832
  });
@@ -29813,7 +29838,7 @@ var AssetManager = /** @class */ (function () {
29813
29838
  return __generator(this, function (_a) {
29814
29839
  return [2 /*return*/, new Promise(function (resolve, reject) {
29815
29840
  _this.downloader.downloadBinary(url, resolve, function (status, responseText) {
29816
- reject("Couldn't load bins ".concat(url, ": status ").concat(status, ", ").concat(responseText));
29841
+ reject("Couldn't load bins ".concat(JSON.stringify(url), ": status ").concat(status, ", ").concat(responseText));
29817
29842
  });
29818
29843
  })];
29819
29844
  });
@@ -29961,7 +29986,8 @@ var CompVFXItem = /** @class */ (function (_super) {
29961
29986
  }
29962
29987
  else {
29963
29988
  item = createVFXItem(this.itemProps[i], this.composition);
29964
- item.transform.parentTransform = this.transform;
29989
+ // 相机不跟随合成移动
29990
+ item.transform.parentTransform = VFXItem.isCamera(item) ? new Transform() : this.transform;
29965
29991
  }
29966
29992
  if (VFXItem.isExtraCamera(item)) {
29967
29993
  this.extraCamera = item;
@@ -30147,7 +30173,7 @@ var CompVFXItem = /** @class */ (function (_super) {
30147
30173
  if (!parentItem) {
30148
30174
  itemNode.parentId = undefined;
30149
30175
  item.parent = undefined;
30150
- item.transform.parentTransform = this.transform;
30176
+ item.transform.parentTransform = VFXItem.isExtraCamera(item) ? new Transform() : this.transform;
30151
30177
  }
30152
30178
  else {
30153
30179
  var parentNode = this.itemCacheMap.get(parentItem.id);
@@ -31159,7 +31185,10 @@ var Ticker = /** @class */ (function () {
31159
31185
  };
31160
31186
  Ticker.prototype.setFPS = function (fps) {
31161
31187
  this.targetFPS = clamp$1(fps, 1, 120);
31162
- this.interval = Math.floor(1000 / fps) - 1;
31188
+ // 注意:-2 的原因是保证帧率稳定
31189
+ // interval 在 fps 为 60 的时候设成 15 累计误差会很大,设成 14 较稳定
31190
+ // requestanimationFrame 在不同的刷新率下时间间隔不一样,120hz 的误差在 8 以内,60hz 的误差在 16 以内
31191
+ this.interval = Math.floor(1000 / fps) - 2;
31163
31192
  };
31164
31193
  /**
31165
31194
  * 获取定时器暂停标志位
@@ -35165,22 +35194,23 @@ var GLRenderer = /** @class */ (function (_super) {
35165
35194
  });
35166
35195
  Object.defineProperty(GLRenderer.prototype, "height", {
35167
35196
  get: function () {
35168
- var _a;
35169
- return ((_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.height) || 0;
35197
+ var _a, _b;
35198
+ return (_b = (_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 0;
35170
35199
  },
35171
35200
  enumerable: false,
35172
35201
  configurable: true
35173
35202
  });
35174
35203
  Object.defineProperty(GLRenderer.prototype, "width", {
35175
35204
  get: function () {
35176
- var _a;
35177
- return ((_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.width) || 0;
35205
+ var _a, _b;
35206
+ return (_b = (_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 0;
35178
35207
  },
35179
35208
  enumerable: false,
35180
35209
  configurable: true
35181
35210
  });
35182
35211
  GLRenderer.prototype.renderRenderFrame = function (renderFrame) {
35183
35212
  var e_1, _a, e_2, _b;
35213
+ var _c, _d;
35184
35214
  var frame = renderFrame;
35185
35215
  // TODO 需要一个贴图统一初始化的管理类,避免在渲染逻辑代码中初始化。
35186
35216
  // 初始化renderframe的贴图资源
@@ -35209,9 +35239,9 @@ var GLRenderer = /** @class */ (function (_super) {
35209
35239
  for (var passes_1 = __values$1(passes), passes_1_1 = passes_1.next(); !passes_1_1.done; passes_1_1 = passes_1.next()) {
35210
35240
  var pass = passes_1_1.value;
35211
35241
  var delegate = pass.delegate;
35212
- delegate.willBeginRenderPass && (delegate === null || delegate === void 0 ? void 0 : delegate.willBeginRenderPass(pass, this.renderingData));
35242
+ (_c = delegate.willBeginRenderPass) === null || _c === void 0 ? void 0 : _c.call(delegate, pass, this.renderingData);
35213
35243
  this.renderRenderPass(pass);
35214
- delegate.didEndRenderPass && (delegate === null || delegate === void 0 ? void 0 : delegate.didEndRenderPass(pass, this.renderingData));
35244
+ (_d = delegate.didEndRenderPass) === null || _d === void 0 ? void 0 : _d.call(delegate, pass, this.renderingData);
35215
35245
  }
35216
35246
  }
35217
35247
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -35246,6 +35276,7 @@ var GLRenderer = /** @class */ (function (_super) {
35246
35276
  };
35247
35277
  GLRenderer.prototype.renderMeshes = function (meshes) {
35248
35278
  var e_3, _a;
35279
+ var _b, _c;
35249
35280
  var delegate = this.renderingData.currentPass.delegate;
35250
35281
  try {
35251
35282
  for (var meshes_1 = __values$1(meshes), meshes_1_1 = meshes_1.next(); !meshes_1_1.done; meshes_1_1 = meshes_1.next()) {
@@ -35263,9 +35294,9 @@ var GLRenderer = /** @class */ (function (_super) {
35263
35294
  }
35264
35295
  mesh.material.initialize();
35265
35296
  mesh.geometry.initialize();
35266
- delegate.willRenderMesh && delegate.willRenderMesh(mesh, this.renderingData);
35297
+ (_b = delegate.willRenderMesh) === null || _b === void 0 ? void 0 : _b.call(delegate, mesh, this.renderingData);
35267
35298
  mesh.render(this);
35268
- delegate.didiRenderMesh && delegate.didiRenderMesh(mesh, this.renderingData);
35299
+ (_c = delegate.didRenderMesh) === null || _c === void 0 ? void 0 : _c.call(delegate, mesh, this.renderingData);
35269
35300
  }
35270
35301
  }
35271
35302
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -35777,7 +35808,7 @@ var Player = /** @class */ (function () {
35777
35808
  Player.prototype.createComposition = function (url, options) {
35778
35809
  if (options === void 0) { options = {}; }
35779
35810
  return __awaiter(this, void 0, void 0, function () {
35780
- var renderer, last, opts, scene, source, composition, firstFrameTime;
35811
+ var renderer, last, opts, source, scene, composition, firstFrameTime;
35781
35812
  var _this = this;
35782
35813
  return __generator(this, function (_a) {
35783
35814
  switch (_a.label) {
@@ -35798,14 +35829,9 @@ var Player = /** @class */ (function () {
35798
35829
  else {
35799
35830
  this.assetManager = new AssetManager(opts);
35800
35831
  }
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:
35832
+ return [4 /*yield*/, this.assetManager.loadScene(source, this.renderer, { env: this.env })];
35833
+ case 1:
35806
35834
  scene = _a.sent();
35807
- _a.label = 3;
35808
- case 3:
35809
35835
  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
35836
  if (this.ticker) {
35811
35837
  if (composition.renderLevel === RenderLevel$1.B) {
@@ -35817,7 +35843,7 @@ var Player = /** @class */ (function () {
35817
35843
  resolve(null);
35818
35844
  });
35819
35845
  })];
35820
- case 4:
35846
+ case 2:
35821
35847
  _a.sent();
35822
35848
  if (opts.autoplay) {
35823
35849
  this.autoPlaying = true;
@@ -35975,38 +36001,29 @@ var Player = /** @class */ (function () {
35975
36001
  var _this = this;
35976
36002
  var _a, _b, _c;
35977
36003
  dt = Math.min(dt, 33) * this.speed;
35978
- var removed = false;
35979
36004
  var comps = this.compositions;
35980
36005
  var skipRender = false;
35981
36006
  comps.sort(function (a, b) { return a.getIndex() - b.getIndex(); });
35982
- comps.forEach(function (composition, i) {
36007
+ this.compositions = [];
36008
+ for (var i = 0; i < comps.length; i++) {
36009
+ var composition = comps[i];
35983
36010
  if (composition.textureOffloaded) {
35984
36011
  skipRender = true;
35985
36012
  console.error({
35986
36013
  content: "Composition ".concat(composition.name, " texture offloaded, skip render."),
35987
36014
  type: LOG_TYPE,
35988
36015
  });
36016
+ this.compositions.push(composition);
36017
+ continue;
35989
36018
  }
35990
- if (composition.isDestroyed) {
35991
- delete comps[i];
35992
- removed = true;
35993
- return;
35994
- }
35995
- if (composition.renderer) {
36019
+ if (!composition.isDestroyed && composition.renderer) {
35996
36020
  composition.update(dt);
35997
36021
  }
35998
- if (composition.isDestroyed) {
35999
- delete comps[i];
36000
- removed = true;
36001
- return;
36022
+ if (!composition.isDestroyed) {
36023
+ this.compositions.push(composition);
36002
36024
  }
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
36025
  }
36009
- this.baseCompositionIndex = comps.length;
36026
+ this.baseCompositionIndex = this.compositions.length;
36010
36027
  if (skipRender) {
36011
36028
  (_a = this.handleRenderError) === null || _a === void 0 ? void 0 : _a.call(this, new Error('play when texture offloaded'));
36012
36029
  return (_b = this.ticker) === null || _b === void 0 ? void 0 : _b.pause();
@@ -36016,7 +36033,7 @@ var Player = /** @class */ (function () {
36016
36033
  var gl = this.renderer.context.gl;
36017
36034
  var time = (level === 2 && this.reportGPUTime) ? gpuTimer(gl) : undefined;
36018
36035
  time === null || time === void 0 ? void 0 : time.begin();
36019
- if (this.compositions.length || forceRender) {
36036
+ if (this.compositions.length || this.compositions.length < comps.length || forceRender) {
36020
36037
  this.renderer.setFrameBuffer(null);
36021
36038
  this.renderer.clear({
36022
36039
  stencilAction: exports.TextureLoadAction.clear,
@@ -36362,9 +36379,9 @@ Renderer.create = function (canvas, framework, renderOptions) {
36362
36379
  Engine.create = function (gl) {
36363
36380
  return new GLEngine(gl);
36364
36381
  };
36365
- var version = "1.1.2";
36382
+ var version = "1.1.4";
36366
36383
  console.info({
36367
- content: '[Galacean Effects Player] version: ' + "1.1.2",
36384
+ content: '[Galacean Effects Player] version: ' + "1.1.4",
36368
36385
  type: LOG_TYPE,
36369
36386
  });
36370
36387