@galacean/effects-threejs 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.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v1.1.3
6
+ * Version: v1.1.5
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -14731,6 +14731,9 @@ var VFXItem = /** @class */ (function () {
14731
14731
  VFXItem.isTree = function (item) {
14732
14732
  return item.type === ItemType$1.tree;
14733
14733
  };
14734
+ VFXItem.isCamera = function (item) {
14735
+ return item.type === ItemType$1.camera;
14736
+ };
14734
14737
  VFXItem.isExtraCamera = function (item) {
14735
14738
  return item.id === 'extra-camera' && item.name === 'extra-camera';
14736
14739
  };
@@ -14931,10 +14934,11 @@ var VFXItem = /** @class */ (function () {
14931
14934
  }
14932
14935
  else if (this.endBehavior === END_BEHAVIOR_DESTROY$1) {
14933
14936
  this._contentVisible = false;
14937
+ shouldUpdate = true;
14938
+ dt = 0;
14934
14939
  // 预合成配置 reusable 且销毁时, 需要隐藏其中的元素
14935
14940
  if (this.type === ItemType$1.composition) {
14936
14941
  this.handleVisibleChanged(false);
14937
- this.onItemUpdate(0, lifetime);
14938
14942
  }
14939
14943
  }
14940
14944
  lifetime = Math.min(lifetime, 1);
@@ -14943,7 +14947,6 @@ var VFXItem = /** @class */ (function () {
14943
14947
  shouldUpdate = true;
14944
14948
  if (this.endBehavior === END_BEHAVIOR_RESTART$1) {
14945
14949
  this.ended = true;
14946
- lifetime = lifetime % 1;
14947
14950
  }
14948
14951
  }
14949
14952
  }
@@ -14951,7 +14954,7 @@ var VFXItem = /** @class */ (function () {
14951
14954
  this.setVisible(true);
14952
14955
  this.callEnd = false;
14953
14956
  }
14954
- this.lifetime = lifetime;
14957
+ this.lifetime = lifetime % 1;
14955
14958
  shouldUpdate && this.onItemUpdate(dt, lifetime);
14956
14959
  }
14957
14960
  }
@@ -15518,10 +15521,6 @@ var CameraVFXItem = /** @class */ (function (_super) {
15518
15521
  (_a = this.controller) === null || _a === void 0 ? void 0 : _a.update(lifetime);
15519
15522
  this.updateCamera();
15520
15523
  };
15521
- // override onEnd () {
15522
- // this.controller?.update(1);
15523
- // this.updateCamera();
15524
- // }
15525
15524
  CameraVFXItem.prototype.updateCamera = function () {
15526
15525
  if (this.controller && this.composition) {
15527
15526
  var camera = this.composition.camera;
@@ -19278,19 +19277,28 @@ var SpriteMesh = /** @class */ (function () {
19278
19277
  var aPointLen = 0;
19279
19278
  var indexLen = 0;
19280
19279
  var pointCount = 0;
19280
+ var renderInfo;
19281
19281
  if (!items.length) {
19282
19282
  this.mesh.setVisible(false);
19283
19283
  return true;
19284
19284
  }
19285
+ for (var i = 0; i < items.length; i++) {
19286
+ if (items[i].renderInfo) {
19287
+ renderInfo = items[i].renderInfo;
19288
+ break;
19289
+ }
19290
+ }
19291
+ if (!renderInfo) {
19292
+ return true;
19293
+ }
19285
19294
  this.items = items.slice();
19286
19295
  if (items.length > 2) {
19287
19296
  itemSlot = maxSpriteMeshItemCount;
19288
19297
  }
19289
- var renderInfo = items[0].renderInfo;
19290
19298
  if (this.mtlSlotCount !== itemSlot) {
19291
19299
  this.mesh.setMaterial(this.createMaterial(renderInfo, itemSlot), { textures: DestroyOptions.keep });
19292
19300
  }
19293
- 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;
19301
+ 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;
19294
19302
  this.splitLayer = attachmentLength > 0;
19295
19303
  for (var i = 0; i < items.length; i++) {
19296
19304
  var item = items[i];
@@ -23566,7 +23574,7 @@ var ParticleSystem = /** @class */ (function () {
23566
23574
  configurable: true
23567
23575
  });
23568
23576
  ParticleSystem.prototype.updateEmitterTransform = function (time) {
23569
- var parentTransform = this.parentTransform;
23577
+ var parentTransform = this.transform.parentTransform;
23570
23578
  var _a = this.basicTransform, path = _a.path, position = _a.position;
23571
23579
  var selfPos = position.clone();
23572
23580
  if (path) {
@@ -23576,9 +23584,9 @@ var ParticleSystem = /** @class */ (function () {
23576
23584
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
23577
23585
  if (this.options.particleFollowParent && parentTransform) {
23578
23586
  var tempMatrix = parentTransform.getWorldMatrix();
23579
- this.particleMesh.mesh.worldMatrix = tempMatrix.clone();
23587
+ this.particleMesh.mesh.worldMatrix = tempMatrix;
23580
23588
  if (this.trailMesh) {
23581
- this.trailMesh.mesh.worldMatrix = tempMatrix.clone();
23589
+ this.trailMesh.mesh.worldMatrix = tempMatrix;
23582
23590
  }
23583
23591
  }
23584
23592
  };
@@ -23597,8 +23605,8 @@ var ParticleSystem = /** @class */ (function () {
23597
23605
  link.pushNode(linkContent);
23598
23606
  this.particleMesh.setPoint(point, pointIndex);
23599
23607
  this.clearPointTrail(pointIndex);
23600
- if (this.parentTransform && this.trailMesh) {
23601
- this.trailMesh.setPointStartPos(pointIndex, this.parentTransform.position.clone());
23608
+ if (this.trailMesh) {
23609
+ this.trailMesh.setPointStartPos(pointIndex, this.transform.parentTransform.position.clone());
23602
23610
  }
23603
23611
  };
23604
23612
  ParticleSystem.prototype.setVisible = function (visible) {
@@ -23636,7 +23644,8 @@ var ParticleSystem = /** @class */ (function () {
23636
23644
  }
23637
23645
  };
23638
23646
  ParticleSystem.prototype.setParentTransform = function (transform) {
23639
- this.parentTransform = transform;
23647
+ // this.transform.parentTransform = transform;
23648
+ // this.parentTransform = transform;
23640
23649
  };
23641
23650
  ParticleSystem.prototype.getTextures = function () {
23642
23651
  var e_1, _a, e_2, _b;
@@ -23888,9 +23897,7 @@ var ParticleSystem = /** @class */ (function () {
23888
23897
  if (options.removeParticle) {
23889
23898
  mesh.removePoint(pointIndex);
23890
23899
  this.clearPointTrail(pointIndex);
23891
- link.removeNode(node);
23892
- node.content = [0];
23893
- // link.shiftNode(node.content); // 删了又加回去 没明白什么意思
23900
+ node.content[0] = 0;
23894
23901
  }
23895
23902
  hitPositions.push(pos);
23896
23903
  if (!options.multiple) {
@@ -23929,8 +23936,8 @@ var ParticleSystem = /** @class */ (function () {
23929
23936
  if (trails.sizeAffectsLifetime) {
23930
23937
  lifetime *= size[0];
23931
23938
  }
23932
- if (trails.parentAffectsPosition && this.parentTransform) {
23933
- position.add(this.parentTransform.position);
23939
+ if (trails.parentAffectsPosition && this.transform.parentTransform) {
23940
+ position.add(this.transform.parentTransform.position);
23934
23941
  var pos = this.trailMesh.getPointStartPos(pointIndex);
23935
23942
  if (pos) {
23936
23943
  position.subtract(pos);
@@ -24144,7 +24151,9 @@ function randomArrItem(arr, keepArr) {
24144
24151
  var ParticleVFXItem = /** @class */ (function (_super) {
24145
24152
  __extends(ParticleVFXItem, _super);
24146
24153
  function ParticleVFXItem() {
24147
- return _super !== null && _super.apply(this, arguments) || this;
24154
+ var _this = _super !== null && _super.apply(this, arguments) || this;
24155
+ _this.destroyed = false;
24156
+ return _this;
24148
24157
  }
24149
24158
  Object.defineProperty(ParticleVFXItem.prototype, "type", {
24150
24159
  get: function () {
@@ -24170,12 +24179,11 @@ var ParticleVFXItem = /** @class */ (function (_super) {
24170
24179
  ParticleVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
24171
24180
  var _a;
24172
24181
  if (this.content) {
24173
- var hide = !this.contentVisible;
24182
+ var hide = !this.visible;
24174
24183
  var parentItem = this.parentId && ((_a = this.composition) === null || _a === void 0 ? void 0 : _a.getItemByID(this.parentId));
24175
24184
  if (!hide && parentItem) {
24176
24185
  var parentData = parentItem.getRenderData();
24177
24186
  if (parentData) {
24178
- this.content.setParentTransform(parentData.transform);
24179
24187
  if (!parentData.visible) {
24180
24188
  hide = false;
24181
24189
  }
@@ -29178,7 +29186,6 @@ var CompositionSourceManager = /** @class */ (function () {
29178
29186
  }
29179
29187
  var cachedTextures = textureOptions.map(function (option) { return option && (option instanceof Texture ? option : Texture.create(engine, option)); });
29180
29188
  // 缓存创建的Texture对象
29181
- // @ts-expect-error
29182
29189
  scene.textureOptions = cachedTextures;
29183
29190
  cachedTextures === null || cachedTextures === void 0 ? void 0 : cachedTextures.forEach(function (tex) { return tex === null || tex === void 0 ? void 0 : tex.initialize(); });
29184
29191
  try {
@@ -29408,24 +29415,24 @@ var AssetManager = /** @class */ (function () {
29408
29415
  this.timeout = timeout;
29409
29416
  };
29410
29417
  /**
29411
- * 场景创建
29412
- * 通过 json 创建出场景对象,并进行提前编译等工作
29418
+ * 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
29413
29419
  * @param url - json 的 URL 链接或者 json 对象
29414
29420
  * @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
29415
29421
  * @param options - 扩展参数
29416
29422
  * @returns
29417
29423
  */
29418
29424
  AssetManager.prototype.loadScene = function (url, renderer, options) {
29419
- var _a, _b;
29425
+ var _a, _b, _c;
29420
29426
  return __awaiter(this, void 0, void 0, function () {
29421
- var rawJSON, timeLabel, startTime, timeInfos, gpuInstance, asyncShaderCompile, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
29427
+ var rawJSON, timeLabel, startTime, timeInfos, gpuInstance, asyncShaderCompile, compressedTexture, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
29422
29428
  var _this = this;
29423
- return __generator(this, function (_c) {
29429
+ return __generator(this, function (_d) {
29424
29430
  timeLabel = "Load asset: ".concat(isString(url) ? url : this.id);
29425
29431
  startTime = performance.now();
29426
29432
  timeInfos = [];
29427
29433
  gpuInstance = renderer === null || renderer === void 0 ? void 0 : renderer.engine.gpuCapability;
29428
29434
  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;
29435
+ compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
29429
29436
  cancelLoading = false;
29430
29437
  waitPromise = new Promise(function (resolve, reject) {
29431
29438
  return loadTimer = window.setTimeout(function () {
@@ -29450,10 +29457,10 @@ var AssetManager = /** @class */ (function () {
29450
29457
  });
29451
29458
  }); };
29452
29459
  loadResourcePromise = function () { return __awaiter(_this, void 0, void 0, function () {
29453
- var _a, usedImages, jsonScene, _b, bins, images, compositions, fonts, _c, loadedBins, loadedImages, loadedTextures, scene, totalTime;
29460
+ 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;
29454
29461
  var _this = this;
29455
- return __generator(this, function (_d) {
29456
- switch (_d.label) {
29462
+ return __generator(this, function (_e) {
29463
+ switch (_e.label) {
29457
29464
  case 0:
29458
29465
  if (!isObject(url)) return [3 /*break*/, 1];
29459
29466
  // TODO: 原 JSONLoader contructor 判断是否兼容
@@ -29466,42 +29473,66 @@ var AssetManager = /** @class */ (function () {
29466
29473
  this.baseUrl = url;
29467
29474
  return [4 /*yield*/, hookTimeInfo('loadJSON', function () { return _this.loadJSON(url); })];
29468
29475
  case 2:
29469
- rawJSON = _d.sent();
29470
- _d.label = 3;
29471
- case 3: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
29476
+ rawJSON = _e.sent();
29477
+ _e.label = 3;
29478
+ case 3:
29479
+ if (!isScene(rawJSON)) return [3 /*break*/, 6];
29480
+ // 已经加载过的 可能需要更新数据模板
29481
+ scene = __assign$1({}, rawJSON);
29482
+ if (!(this.options && this.options.variables && Object.keys(this.options.variables).length !== 0)) return [3 /*break*/, 5];
29483
+ rawImages = rawJSON.jsonScene.images;
29484
+ images_1 = scene.images;
29485
+ for (i = 0; i < rawImages.length; i++) {
29486
+ // 仅重新加载数据模板对应的图片
29487
+ if (images_1[i] instanceof HTMLCanvasElement) {
29488
+ images_1[i] = rawImages[i];
29489
+ }
29490
+ }
29491
+ _a = scene;
29492
+ return [4 /*yield*/, hookTimeInfo('processImages', function () { return _this.processImages(images_1, scene.usedImages, compressedTexture); })];
29472
29493
  case 4:
29473
- _a = _d.sent(), usedImages = _a.usedImages, jsonScene = _a.jsonScene;
29474
- _b = jsonScene.bins, bins = _b === void 0 ? [] : _b, images = jsonScene.images, compositions = jsonScene.compositions, fonts = jsonScene.fonts;
29494
+ _a.images = _e.sent();
29495
+ // 更新 TextureOptions 中的 image 指向
29496
+ for (i = 0; i < scene.images.length; i++) {
29497
+ scene.textureOptions[i].image = scene.images[i];
29498
+ }
29499
+ _e.label = 5;
29500
+ case 5: return [3 /*break*/, 12];
29501
+ case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
29502
+ case 7:
29503
+ _b = _e.sent(), usedImages_1 = _b.usedImages, jsonScene_1 = _b.jsonScene, pluginSystem_1 = _b.pluginSystem;
29504
+ _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;
29475
29505
  return [4 /*yield*/, Promise.all([
29476
- hookTimeInfo('processBins', function () { return _this.processBins(bins); }),
29477
- 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); }),
29478
- hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(compositions, renderer, options); }),
29506
+ hookTimeInfo('processBins', function () { return _this.processBins(bins_1); }),
29507
+ hookTimeInfo('processImages', function () { return _this.processImages(images_2, usedImages_1, compressedTexture); }),
29508
+ hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(compositions_1, pluginSystem_1, renderer, options); }),
29479
29509
  ])];
29480
- case 5:
29481
- _c = __read$3.apply(void 0, [_d.sent(), 2]), loadedBins = _c[0], loadedImages = _c[1];
29482
- return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(fonts); })];
29483
- case 6:
29484
- _d.sent();
29485
- return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages, loadedBins, jsonScene); })];
29486
- case 7:
29487
- loadedTextures = _d.sent();
29510
+ case 8:
29511
+ _d = __read$3.apply(void 0, [_e.sent(), 2]), loadedBins_1 = _d[0], loadedImages_1 = _d[1];
29512
+ return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(fonts_1); })];
29513
+ case 9:
29514
+ _e.sent();
29515
+ return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
29516
+ case 10:
29517
+ loadedTextures = _e.sent();
29488
29518
  scene = {
29489
- jsonScene: jsonScene,
29490
- images: loadedImages,
29491
- textureOptions: loadedTextures,
29492
- bins: loadedBins,
29493
- storage: {},
29494
- pluginSystem: this.pluginSystem,
29495
- renderLevel: this.options.renderLevel,
29496
- totalTime: 0,
29497
- startTime: 0,
29498
29519
  url: url,
29520
+ renderLevel: this.options.renderLevel,
29521
+ storage: {},
29522
+ pluginSystem: pluginSystem_1,
29523
+ jsonScene: jsonScene_1,
29524
+ usedImages: usedImages_1,
29525
+ images: loadedImages_1,
29526
+ textureOptions: loadedTextures,
29527
+ bins: loadedBins_1,
29499
29528
  };
29500
29529
  // 触发插件系统 pluginSystem 的回调 prepareResource
29501
- return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return _this.pluginSystem.loadResources(scene, _this.options); })];
29502
- case 8:
29530
+ return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return pluginSystem_1.loadResources(scene, _this.options); })];
29531
+ case 11:
29503
29532
  // 触发插件系统 pluginSystem 的回调 prepareResource
29504
- _d.sent();
29533
+ _e.sent();
29534
+ _e.label = 12;
29535
+ case 12:
29505
29536
  totalTime = performance.now() - startTime;
29506
29537
  console.info({
29507
29538
  content: "".concat(timeLabel, ": ").concat(totalTime.toFixed(4), "ms, ").concat(timeInfos.join(' ')),
@@ -29518,7 +29549,7 @@ var AssetManager = /** @class */ (function () {
29518
29549
  });
29519
29550
  });
29520
29551
  };
29521
- AssetManager.prototype.precompile = function (compositions, renderer, options) {
29552
+ AssetManager.prototype.precompile = function (compositions, pluginSystem, renderer, options) {
29522
29553
  return __awaiter(this, void 0, void 0, function () {
29523
29554
  var shaderLibrary;
29524
29555
  return __generator(this, function (_a) {
@@ -29528,7 +29559,7 @@ var AssetManager = /** @class */ (function () {
29528
29559
  return [2 /*return*/];
29529
29560
  }
29530
29561
  shaderLibrary = renderer === null || renderer === void 0 ? void 0 : renderer.getShaderLibrary();
29531
- return [4 /*yield*/, this.pluginSystem.precompile(compositions, renderer, options)];
29562
+ return [4 /*yield*/, (pluginSystem === null || pluginSystem === void 0 ? void 0 : pluginSystem.precompile(compositions, renderer, options))];
29532
29563
  case 1:
29533
29564
  _a.sent();
29534
29565
  return [4 /*yield*/, new Promise(function (resolve) {
@@ -29545,7 +29576,7 @@ var AssetManager = /** @class */ (function () {
29545
29576
  };
29546
29577
  AssetManager.prototype.processJSON = function (json) {
29547
29578
  return __awaiter(this, void 0, void 0, function () {
29548
- var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, renderLevel, usedImages;
29579
+ var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, pluginSystem, renderLevel, usedImages;
29549
29580
  return __generator(this, function (_b) {
29550
29581
  switch (_b.label) {
29551
29582
  case 0:
@@ -29559,8 +29590,8 @@ var AssetManager = /** @class */ (function () {
29559
29590
  }
29560
29591
  });
29561
29592
  _a = jsonScene.plugins, plugins = _a === void 0 ? [] : _a, sceneCompositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, images = jsonScene.images;
29562
- this.pluginSystem = new PluginSystem(plugins);
29563
- return [4 /*yield*/, this.pluginSystem.processRawJSON(jsonScene, this.options)];
29593
+ pluginSystem = new PluginSystem(plugins);
29594
+ return [4 /*yield*/, pluginSystem.processRawJSON(jsonScene, this.options)];
29564
29595
  case 1:
29565
29596
  _b.sent();
29566
29597
  renderLevel = this.options.renderLevel;
@@ -29577,6 +29608,7 @@ var AssetManager = /** @class */ (function () {
29577
29608
  return [2 /*return*/, {
29578
29609
  usedImages: usedImages,
29579
29610
  jsonScene: jsonScene,
29611
+ pluginSystem: pluginSystem,
29580
29612
  }];
29581
29613
  }
29582
29614
  });
@@ -29960,7 +29992,8 @@ var CompVFXItem = /** @class */ (function (_super) {
29960
29992
  }
29961
29993
  else {
29962
29994
  item = createVFXItem(this.itemProps[i], this.composition);
29963
- item.transform.parentTransform = this.transform;
29995
+ // 相机不跟随合成移动
29996
+ item.transform.parentTransform = VFXItem.isCamera(item) ? new Transform() : this.transform;
29964
29997
  }
29965
29998
  if (VFXItem.isExtraCamera(item)) {
29966
29999
  this.extraCamera = item;
@@ -30146,7 +30179,7 @@ var CompVFXItem = /** @class */ (function (_super) {
30146
30179
  if (!parentItem) {
30147
30180
  itemNode.parentId = undefined;
30148
30181
  item.parent = undefined;
30149
- item.transform.parentTransform = this.transform;
30182
+ item.transform.parentTransform = VFXItem.isExtraCamera(item) ? new Transform() : this.transform;
30150
30183
  }
30151
30184
  else {
30152
30185
  var parentNode = this.itemCacheMap.get(parentItem.id);
@@ -30443,7 +30476,7 @@ var Composition = /** @class */ (function () {
30443
30476
  });
30444
30477
  Object.defineProperty(Composition.prototype, "startTime", {
30445
30478
  /**
30446
- * 获取合成开始时间
30479
+ * 获取合成开始渲染的时间
30447
30480
  */
30448
30481
  get: function () {
30449
30482
  var _a;
@@ -30523,7 +30556,12 @@ var Composition = /** @class */ (function () {
30523
30556
  if (this.content.ended && this.reusable) {
30524
30557
  this.restart();
30525
30558
  }
30526
- this.gotoAndPlay(this.time);
30559
+ if (this.content.started) {
30560
+ this.gotoAndPlay(this.time - this.startTime);
30561
+ }
30562
+ else {
30563
+ this.gotoAndPlay(0);
30564
+ }
30527
30565
  };
30528
30566
  /**
30529
30567
  * 暂停合成的播放
@@ -30537,14 +30575,21 @@ var Composition = /** @class */ (function () {
30537
30575
  Composition.prototype.resume = function () {
30538
30576
  this.paused = false;
30539
30577
  };
30578
+ /**
30579
+ * 跳转合成到指定时间播放
30580
+ * @param time - 相对 startTime 的时间
30581
+ */
30540
30582
  Composition.prototype.gotoAndPlay = function (time) {
30541
30583
  this.resume();
30542
30584
  if (!this.content.started) {
30543
30585
  this.content.start();
30544
- this.forwardTime(this.startTime);
30545
30586
  }
30546
- this.forwardTime(time);
30587
+ this.forwardTime(time + this.startTime);
30547
30588
  };
30589
+ /**
30590
+ * 跳转合成到指定时间并暂停
30591
+ * @param time - 相对 startTime 的时间
30592
+ */
30548
30593
  Composition.prototype.gotoAndStop = function (time) {
30549
30594
  this.gotoAndPlay(time);
30550
30595
  this.pause();
@@ -30564,21 +30609,29 @@ var Composition = /** @class */ (function () {
30564
30609
  };
30565
30610
  /**
30566
30611
  * 跳到指定时间点(不做任何播放行为)
30567
- * @param time - 指定的时间
30612
+ * @param time - 相对 startTime 的时间
30568
30613
  */
30569
30614
  Composition.prototype.setTime = function (time) {
30570
30615
  var pause = this.paused;
30571
30616
  if (pause) {
30572
30617
  this.resume();
30573
30618
  }
30574
- this.forwardTime(time, true);
30619
+ if (!this.content.started) {
30620
+ this.content.start();
30621
+ }
30622
+ this.forwardTime(time + this.startTime, true);
30575
30623
  if (pause) {
30576
30624
  this.pause();
30577
30625
  }
30578
30626
  };
30627
+ /**
30628
+ * 前进合成到指定时间
30629
+ * @param time - 相对0时刻的时间
30630
+ * @param skipRender - 是否跳过渲染
30631
+ */
30579
30632
  Composition.prototype.forwardTime = function (time, skipRender) {
30580
30633
  if (skipRender === void 0) { skipRender = false; }
30581
- var deltaTime = (this.startTime + Math.max(0, time)) * 1000 - this.content.timeInms;
30634
+ var deltaTime = time * 1000 - this.content.timeInms;
30582
30635
  var reverse = deltaTime < 0;
30583
30636
  var step = 15;
30584
30637
  var t = Math.abs(deltaTime);
@@ -32761,9 +32814,9 @@ Geometry.create = function (engine, options) {
32761
32814
  Mesh.create = function (engine, props) {
32762
32815
  return new ThreeMesh(engine, props);
32763
32816
  };
32764
- var version = "1.1.3";
32817
+ var version = "1.1.5";
32765
32818
  console.info({
32766
- content: '[Galacean Effects THREEJS] version: ' + "1.1.3",
32819
+ content: '[Galacean Effects THREEJS] version: ' + "1.1.5",
32767
32820
  type: LOG_TYPE,
32768
32821
  });
32769
32822