@galacean/effects 1.1.2 → 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.
package/dist/index.mjs 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.3
7
7
  */
8
8
 
9
9
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -9323,11 +9323,9 @@ var Matrix4$1 = /** @class */ (function () {
9323
9323
  var vX = Matrix4.tempVec0;
9324
9324
  var vY = Matrix4.tempVec1;
9325
9325
  var vZ = Matrix4.tempVec2;
9326
- vZ.subtractVectors(target, eye);
9326
+ vZ.subtractVectors(eye, target);
9327
9327
  vZ.normalize();
9328
- vY.copyFrom(up);
9329
- vY.normalize();
9330
- vX.crossVectors(vY, vZ);
9328
+ vX.crossVectors(up, vZ);
9331
9329
  vX.normalize();
9332
9330
  vY.crossVectors(vZ, vX);
9333
9331
  var te = this.elements;
@@ -16016,7 +16014,7 @@ function loadImage(source) {
16016
16014
  }
16017
16015
  // 2. 非法类型
16018
16016
  if (!url) {
16019
- throw new Error("Invalid url type: ".concat(source));
16017
+ throw new Error("Invalid url type: ".concat(JSON.stringify(source)));
16020
16018
  }
16021
16019
  return [2 /*return*/, new Promise(function (resolve, reject) {
16022
16020
  var img = new Image();
@@ -16035,7 +16033,7 @@ function loadImage(source) {
16035
16033
  if (revokeURL) {
16036
16034
  URL.revokeObjectURL(url);
16037
16035
  }
16038
- return reject("Load image fail: ".concat(e));
16036
+ return reject("Load image fail: ".concat(JSON.stringify(e)));
16039
16037
  };
16040
16038
  img.src = url;
16041
16039
  })];
@@ -29232,7 +29230,6 @@ var CompositionSourceManager = /** @class */ (function () {
29232
29230
  CompositionSourceManager.prototype.assembleItems = function (composition) {
29233
29231
  var _this = this;
29234
29232
  var items = [];
29235
- this.mask++;
29236
29233
  composition.items.forEach(function (item) {
29237
29234
  var _a;
29238
29235
  var option = {};
@@ -29248,9 +29245,7 @@ var CompositionSourceManager = /** @class */ (function () {
29248
29245
  option.type = type;
29249
29246
  if (renderContent.renderer) {
29250
29247
  renderContent.renderer = _this.changeTex(renderContent.renderer);
29251
- if (!renderContent.renderer.mask) {
29252
- _this.processMask(renderContent.renderer, _this.mask);
29253
- }
29248
+ _this.processMask(renderContent.renderer);
29254
29249
  var split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
29255
29250
  if (Number.isInteger(renderContent.renderer.shape)) {
29256
29251
  // TODO: scene.shapes 类型问题?
@@ -29295,7 +29290,7 @@ var CompositionSourceManager = /** @class */ (function () {
29295
29290
  }
29296
29291
  // 处理预合成的渲染顺序
29297
29292
  if (option.type === ItemType$1.composition) {
29298
- var maskRef_1 = ++_this.mask;
29293
+ ++_this.mask;
29299
29294
  var refId = item.content.options.refId;
29300
29295
  if (!_this.refCompositions.get(refId)) {
29301
29296
  throw new Error('Invalid Ref Composition id: ' + refId);
@@ -29306,7 +29301,7 @@ var CompositionSourceManager = /** @class */ (function () {
29306
29301
  }
29307
29302
  ref.items.forEach(function (item) {
29308
29303
  item.listIndex = listOrder++;
29309
- _this.processMask(item.content, maskRef_1);
29304
+ _this.processMask(item.content);
29310
29305
  });
29311
29306
  option.items = ref.items;
29312
29307
  }
@@ -29345,11 +29340,17 @@ var CompositionSourceManager = /** @class */ (function () {
29345
29340
  /**
29346
29341
  * 处理蒙版和遮挡关系写入 stencil 的 ref 值
29347
29342
  */
29348
- CompositionSourceManager.prototype.processMask = function (renderer, maskRef) {
29343
+ CompositionSourceManager.prototype.processMask = function (renderer) {
29344
+ if (renderer.maskMode === MaskMode$1.NONE) {
29345
+ return;
29346
+ }
29349
29347
  if (!renderer.mask) {
29350
29348
  var maskMode = renderer.maskMode;
29351
- if (maskMode !== MaskMode$1.NONE) {
29352
- renderer.mask = maskRef;
29349
+ if (maskMode === MaskMode$1.MASK) {
29350
+ renderer.mask = ++this.mask;
29351
+ }
29352
+ else if (maskMode === MaskMode$1.OBSCURED || maskMode === MaskMode$1.REVERSE_OBSCURED) {
29353
+ renderer.mask = this.mask;
29353
29354
  }
29354
29355
  }
29355
29356
  };
@@ -29427,7 +29428,7 @@ var AssetManager = /** @class */ (function () {
29427
29428
  waitPromise = new Promise(function (resolve, reject) {
29428
29429
  return loadTimer = window.setTimeout(function () {
29429
29430
  cancelLoading = true;
29430
- reject("Load time out: ".concat(url));
29431
+ reject("Load time out: ".concat(JSON.stringify(url)));
29431
29432
  }, _this.timeout * 1000);
29432
29433
  });
29433
29434
  hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
@@ -29592,7 +29593,7 @@ var AssetManager = /** @class */ (function () {
29592
29593
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
29593
29594
  return _this.loadBins(bin.url);
29594
29595
  }
29595
- throw new Error("Invalid bins source: ".concat(bins));
29596
+ throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
29596
29597
  });
29597
29598
  return [2 /*return*/, Promise.all(jobs)];
29598
29599
  });
@@ -29628,7 +29629,7 @@ var AssetManager = /** @class */ (function () {
29628
29629
  case 3:
29629
29630
  _b.sent();
29630
29631
  console.warn({
29631
- content: "Invalid fonts source: ".concat(font.fontURL),
29632
+ content: "Invalid fonts source: ".concat(JSON.stringify(font.fontURL)),
29632
29633
  type: LOG_TYPE,
29633
29634
  });
29634
29635
  return [3 /*break*/, 4];
@@ -29797,7 +29798,7 @@ var AssetManager = /** @class */ (function () {
29797
29798
  return __generator(this, function (_a) {
29798
29799
  return [2 /*return*/, new Promise(function (resolve, reject) {
29799
29800
  _this.downloader.downloadJSON(url, resolve, function (status, responseText) {
29800
- reject("Couldn't load JSON ".concat(url, ": status ").concat(status, ", ").concat(responseText));
29801
+ reject("Couldn't load JSON ".concat(JSON.stringify(url), ": status ").concat(status, ", ").concat(responseText));
29801
29802
  });
29802
29803
  })];
29803
29804
  });
@@ -29809,7 +29810,7 @@ var AssetManager = /** @class */ (function () {
29809
29810
  return __generator(this, function (_a) {
29810
29811
  return [2 /*return*/, new Promise(function (resolve, reject) {
29811
29812
  _this.downloader.downloadBinary(url, resolve, function (status, responseText) {
29812
- reject("Couldn't load bins ".concat(url, ": status ").concat(status, ", ").concat(responseText));
29813
+ reject("Couldn't load bins ".concat(JSON.stringify(url), ": status ").concat(status, ", ").concat(responseText));
29813
29814
  });
29814
29815
  })];
29815
29816
  });
@@ -31155,7 +31156,10 @@ var Ticker = /** @class */ (function () {
31155
31156
  };
31156
31157
  Ticker.prototype.setFPS = function (fps) {
31157
31158
  this.targetFPS = clamp$1(fps, 1, 120);
31158
- this.interval = Math.floor(1000 / fps) - 1;
31159
+ // 注意:-2 的原因是保证帧率稳定
31160
+ // interval 在 fps 为 60 的时候设成 15 累计误差会很大,设成 14 较稳定
31161
+ // requestanimationFrame 在不同的刷新率下时间间隔不一样,120hz 的误差在 8 以内,60hz 的误差在 16 以内
31162
+ this.interval = Math.floor(1000 / fps) - 2;
31159
31163
  };
31160
31164
  /**
31161
31165
  * 获取定时器暂停标志位
@@ -35161,22 +35165,23 @@ var GLRenderer = /** @class */ (function (_super) {
35161
35165
  });
35162
35166
  Object.defineProperty(GLRenderer.prototype, "height", {
35163
35167
  get: function () {
35164
- var _a;
35165
- return ((_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.height) || 0;
35168
+ var _a, _b;
35169
+ return (_b = (_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 0;
35166
35170
  },
35167
35171
  enumerable: false,
35168
35172
  configurable: true
35169
35173
  });
35170
35174
  Object.defineProperty(GLRenderer.prototype, "width", {
35171
35175
  get: function () {
35172
- var _a;
35173
- return ((_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.width) || 0;
35176
+ var _a, _b;
35177
+ return (_b = (_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 0;
35174
35178
  },
35175
35179
  enumerable: false,
35176
35180
  configurable: true
35177
35181
  });
35178
35182
  GLRenderer.prototype.renderRenderFrame = function (renderFrame) {
35179
35183
  var e_1, _a, e_2, _b;
35184
+ var _c, _d;
35180
35185
  var frame = renderFrame;
35181
35186
  // TODO 需要一个贴图统一初始化的管理类,避免在渲染逻辑代码中初始化。
35182
35187
  // 初始化renderframe的贴图资源
@@ -35205,9 +35210,9 @@ var GLRenderer = /** @class */ (function (_super) {
35205
35210
  for (var passes_1 = __values$1(passes), passes_1_1 = passes_1.next(); !passes_1_1.done; passes_1_1 = passes_1.next()) {
35206
35211
  var pass = passes_1_1.value;
35207
35212
  var delegate = pass.delegate;
35208
- delegate.willBeginRenderPass && (delegate === null || delegate === void 0 ? void 0 : delegate.willBeginRenderPass(pass, this.renderingData));
35213
+ (_c = delegate.willBeginRenderPass) === null || _c === void 0 ? void 0 : _c.call(delegate, pass, this.renderingData);
35209
35214
  this.renderRenderPass(pass);
35210
- delegate.didEndRenderPass && (delegate === null || delegate === void 0 ? void 0 : delegate.didEndRenderPass(pass, this.renderingData));
35215
+ (_d = delegate.didEndRenderPass) === null || _d === void 0 ? void 0 : _d.call(delegate, pass, this.renderingData);
35211
35216
  }
35212
35217
  }
35213
35218
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -35242,6 +35247,7 @@ var GLRenderer = /** @class */ (function (_super) {
35242
35247
  };
35243
35248
  GLRenderer.prototype.renderMeshes = function (meshes) {
35244
35249
  var e_3, _a;
35250
+ var _b, _c;
35245
35251
  var delegate = this.renderingData.currentPass.delegate;
35246
35252
  try {
35247
35253
  for (var meshes_1 = __values$1(meshes), meshes_1_1 = meshes_1.next(); !meshes_1_1.done; meshes_1_1 = meshes_1.next()) {
@@ -35259,9 +35265,9 @@ var GLRenderer = /** @class */ (function (_super) {
35259
35265
  }
35260
35266
  mesh.material.initialize();
35261
35267
  mesh.geometry.initialize();
35262
- delegate.willRenderMesh && delegate.willRenderMesh(mesh, this.renderingData);
35268
+ (_b = delegate.willRenderMesh) === null || _b === void 0 ? void 0 : _b.call(delegate, mesh, this.renderingData);
35263
35269
  mesh.render(this);
35264
- delegate.didiRenderMesh && delegate.didiRenderMesh(mesh, this.renderingData);
35270
+ (_c = delegate.didRenderMesh) === null || _c === void 0 ? void 0 : _c.call(delegate, mesh, this.renderingData);
35265
35271
  }
35266
35272
  }
35267
35273
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -36358,9 +36364,9 @@ Renderer.create = function (canvas, framework, renderOptions) {
36358
36364
  Engine.create = function (gl) {
36359
36365
  return new GLEngine(gl);
36360
36366
  };
36361
- var version = "1.1.2";
36367
+ var version = "1.1.3";
36362
36368
  console.info({
36363
- content: '[Galacean Effects Player] version: ' + "1.1.2",
36369
+ content: '[Galacean Effects Player] version: ' + "1.1.3",
36364
36370
  type: LOG_TYPE,
36365
36371
  });
36366
36372