@galacean/effects-core 1.1.1 → 1.1.3

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.
@@ -37,5 +37,9 @@ export declare class CompositionSourceManager implements Disposable {
37
37
  private assembleItems;
38
38
  private changeTex;
39
39
  private addTextureUsage;
40
+ /**
41
+ * 处理蒙版和遮挡关系写入 stencil 的 ref 值
42
+ */
43
+ private processMask;
40
44
  dispose(): void;
41
45
  }
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v1.1.1
6
+ * Version: v1.1.3
7
7
  */
8
8
 
9
9
  'use strict';
@@ -9327,11 +9327,9 @@ var Matrix4 = /** @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;
@@ -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
  })];
@@ -19370,18 +19368,19 @@ var SpriteMesh = /** @class */ (function () {
19370
19368
  var uSizeStart = start + 4;
19371
19369
  var uQuatStart = start + 8;
19372
19370
  var uColorStart = start + 12;
19373
- if (!selfData.visible && !init) {
19374
- mainDataArray[uSizeStart + 2] = -1;
19375
- return;
19376
- }
19377
- var uColor = selfData.color || [mainDataArray[uColorStart], mainDataArray[uColorStart + 1], mainDataArray[uColorStart + 2], mainDataArray[uColorStart + 3]];
19378
- // if (selfData.startSize) {
19379
- // selfData.transform.scaleBy(1 / selfData.startSize[0], 1 / selfData.startSize[1], 1);
19380
- // }
19381
19371
  var tempPos = new Vector3();
19382
19372
  var tempQuat = new Quaternion();
19383
19373
  var tempScale = new Vector3();
19384
- selfData.transform.assignWorldTRS(tempPos, tempQuat, tempScale);
19374
+ var uColor = selfData.color || [mainDataArray[uColorStart], mainDataArray[uColorStart + 1], mainDataArray[uColorStart + 2], mainDataArray[uColorStart + 3]];
19375
+ if (selfData.visible) {
19376
+ selfData.transform.assignWorldTRS(tempPos, tempQuat, tempScale);
19377
+ }
19378
+ else {
19379
+ if (!init) {
19380
+ mainDataArray[uSizeStart + 2] = -1;
19381
+ return;
19382
+ }
19383
+ }
19385
19384
  var uPos = __spreadArray$2(__spreadArray$2([], __read$3(tempPos.toArray()), false), [0], false);
19386
19385
  var uSize = __spreadArray$2(__spreadArray$2([], __read$3(tempScale.toArray()), false), [0], false);
19387
19386
  var uQuat = tempQuat.toArray();
@@ -29172,6 +29171,7 @@ var CompositionSourceManager = /** @class */ (function () {
29172
29171
  var e_1, _a;
29173
29172
  this.refCompositions = new Map();
29174
29173
  this.refCompositionProps = new Map();
29174
+ this.mask = 0;
29175
29175
  // 资源
29176
29176
  var jsonScene = scene.jsonScene, renderLevel = scene.renderLevel, textureOptions = scene.textureOptions, pluginSystem = scene.pluginSystem, totalTime = scene.totalTime;
29177
29177
  var compositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, compositionId = jsonScene.compositionId;
@@ -29210,7 +29210,6 @@ var CompositionSourceManager = /** @class */ (function () {
29210
29210
  this.totalTime = totalTime !== null && totalTime !== void 0 ? totalTime : 0;
29211
29211
  this.imgUsage = imgUsage !== null && imgUsage !== void 0 ? imgUsage : {};
29212
29212
  this.textures = cachedTextures;
29213
- this.mask = 0;
29214
29213
  listOrder = 0;
29215
29214
  this.textureOptions = textureOptions;
29216
29215
  this.sourceContent = this.getContent(this.composition);
@@ -29235,10 +29234,6 @@ var CompositionSourceManager = /** @class */ (function () {
29235
29234
  CompositionSourceManager.prototype.assembleItems = function (composition) {
29236
29235
  var _this = this;
29237
29236
  var items = [];
29238
- var mask = this.mask;
29239
- if (isNaN(mask)) {
29240
- mask = 0;
29241
- }
29242
29237
  composition.items.forEach(function (item) {
29243
29238
  var _a;
29244
29239
  var option = {};
@@ -29254,15 +29249,7 @@ var CompositionSourceManager = /** @class */ (function () {
29254
29249
  option.type = type;
29255
29250
  if (renderContent.renderer) {
29256
29251
  renderContent.renderer = _this.changeTex(renderContent.renderer);
29257
- if (!renderContent.renderer.mask) {
29258
- var maskMode = renderContent.renderer.maskMode;
29259
- if (maskMode === MaskMode$1.MASK) {
29260
- renderContent.renderer.mask = ++mask;
29261
- }
29262
- else if (maskMode === MaskMode$1.OBSCURED || maskMode === MaskMode$1.REVERSE_OBSCURED) {
29263
- renderContent.renderer.mask = mask;
29264
- }
29265
- }
29252
+ _this.processMask(renderContent.renderer);
29266
29253
  var split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
29267
29254
  if (Number.isInteger(renderContent.renderer.shape)) {
29268
29255
  // TODO: scene.shapes 类型问题?
@@ -29307,16 +29294,18 @@ var CompositionSourceManager = /** @class */ (function () {
29307
29294
  }
29308
29295
  // 处理预合成的渲染顺序
29309
29296
  if (option.type === ItemType$1.composition) {
29297
+ ++_this.mask;
29310
29298
  var refId = item.content.options.refId;
29311
29299
  if (!_this.refCompositions.get(refId)) {
29312
29300
  throw new Error('Invalid Ref Composition id: ' + refId);
29313
29301
  }
29302
+ var ref = _this.getContent(_this.refCompositions.get(refId));
29314
29303
  if (!_this.refCompositionProps.has(refId)) {
29315
- _this.refCompositionProps.set(refId, _this.getContent(_this.refCompositions.get(refId)));
29304
+ _this.refCompositionProps.set(refId, ref);
29316
29305
  }
29317
- var ref = _this.refCompositionProps.get(refId);
29318
29306
  ref.items.forEach(function (item) {
29319
29307
  item.listIndex = listOrder++;
29308
+ _this.processMask(item.content);
29320
29309
  });
29321
29310
  option.items = ref.items;
29322
29311
  }
@@ -29352,6 +29341,23 @@ var CompositionSourceManager = /** @class */ (function () {
29352
29341
  }
29353
29342
  }
29354
29343
  };
29344
+ /**
29345
+ * 处理蒙版和遮挡关系写入 stencil 的 ref 值
29346
+ */
29347
+ CompositionSourceManager.prototype.processMask = function (renderer) {
29348
+ if (renderer.maskMode === MaskMode$1.NONE) {
29349
+ return;
29350
+ }
29351
+ if (!renderer.mask) {
29352
+ var maskMode = renderer.maskMode;
29353
+ if (maskMode === MaskMode$1.MASK) {
29354
+ renderer.mask = ++this.mask;
29355
+ }
29356
+ else if (maskMode === MaskMode$1.OBSCURED || maskMode === MaskMode$1.REVERSE_OBSCURED) {
29357
+ renderer.mask = this.mask;
29358
+ }
29359
+ }
29360
+ };
29355
29361
  CompositionSourceManager.prototype.dispose = function () {
29356
29362
  this.textureOptions = [];
29357
29363
  this.textures = [];
@@ -29426,7 +29432,7 @@ var AssetManager = /** @class */ (function () {
29426
29432
  waitPromise = new Promise(function (resolve, reject) {
29427
29433
  return loadTimer = window.setTimeout(function () {
29428
29434
  cancelLoading = true;
29429
- reject("Load time out: ".concat(url));
29435
+ reject("Load time out: ".concat(JSON.stringify(url)));
29430
29436
  }, _this.timeout * 1000);
29431
29437
  });
29432
29438
  hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
@@ -29591,7 +29597,7 @@ var AssetManager = /** @class */ (function () {
29591
29597
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
29592
29598
  return _this.loadBins(bin.url);
29593
29599
  }
29594
- throw new Error("Invalid bins source: ".concat(bins));
29600
+ throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
29595
29601
  });
29596
29602
  return [2 /*return*/, Promise.all(jobs)];
29597
29603
  });
@@ -29627,7 +29633,7 @@ var AssetManager = /** @class */ (function () {
29627
29633
  case 3:
29628
29634
  _b.sent();
29629
29635
  console.warn({
29630
- content: "Invalid fonts source: ".concat(font.fontURL),
29636
+ content: "Invalid fonts source: ".concat(JSON.stringify(font.fontURL)),
29631
29637
  type: LOG_TYPE,
29632
29638
  });
29633
29639
  return [3 /*break*/, 4];
@@ -29796,7 +29802,7 @@ var AssetManager = /** @class */ (function () {
29796
29802
  return __generator(this, function (_a) {
29797
29803
  return [2 /*return*/, new Promise(function (resolve, reject) {
29798
29804
  _this.downloader.downloadJSON(url, resolve, function (status, responseText) {
29799
- reject("Couldn't load JSON ".concat(url, ": status ").concat(status, ", ").concat(responseText));
29805
+ reject("Couldn't load JSON ".concat(JSON.stringify(url), ": status ").concat(status, ", ").concat(responseText));
29800
29806
  });
29801
29807
  })];
29802
29808
  });
@@ -29808,7 +29814,7 @@ var AssetManager = /** @class */ (function () {
29808
29814
  return __generator(this, function (_a) {
29809
29815
  return [2 /*return*/, new Promise(function (resolve, reject) {
29810
29816
  _this.downloader.downloadBinary(url, resolve, function (status, responseText) {
29811
- reject("Couldn't load bins ".concat(url, ": status ").concat(status, ", ").concat(responseText));
29817
+ reject("Couldn't load bins ".concat(JSON.stringify(url), ": status ").concat(status, ", ").concat(responseText));
29812
29818
  });
29813
29819
  })];
29814
29820
  });
@@ -31154,7 +31160,10 @@ var Ticker = /** @class */ (function () {
31154
31160
  };
31155
31161
  Ticker.prototype.setFPS = function (fps) {
31156
31162
  this.targetFPS = clamp$1(fps, 1, 120);
31157
- this.interval = Math.floor(1000 / fps) - 1;
31163
+ // 注意:-2 的原因是保证帧率稳定
31164
+ // interval 在 fps 为 60 的时候设成 15 累计误差会很大,设成 14 较稳定
31165
+ // requestanimationFrame 在不同的刷新率下时间间隔不一样,120hz 的误差在 8 以内,60hz 的误差在 16 以内
31166
+ this.interval = Math.floor(1000 / fps) - 2;
31158
31167
  };
31159
31168
  /**
31160
31169
  * 获取定时器暂停标志位