@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.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.3
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;
@@ -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
  })];
@@ -29236,7 +29234,6 @@ var CompositionSourceManager = /** @class */ (function () {
29236
29234
  CompositionSourceManager.prototype.assembleItems = function (composition) {
29237
29235
  var _this = this;
29238
29236
  var items = [];
29239
- this.mask++;
29240
29237
  composition.items.forEach(function (item) {
29241
29238
  var _a;
29242
29239
  var option = {};
@@ -29252,9 +29249,7 @@ var CompositionSourceManager = /** @class */ (function () {
29252
29249
  option.type = type;
29253
29250
  if (renderContent.renderer) {
29254
29251
  renderContent.renderer = _this.changeTex(renderContent.renderer);
29255
- if (!renderContent.renderer.mask) {
29256
- _this.processMask(renderContent.renderer, _this.mask);
29257
- }
29252
+ _this.processMask(renderContent.renderer);
29258
29253
  var split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
29259
29254
  if (Number.isInteger(renderContent.renderer.shape)) {
29260
29255
  // TODO: scene.shapes 类型问题?
@@ -29299,7 +29294,7 @@ var CompositionSourceManager = /** @class */ (function () {
29299
29294
  }
29300
29295
  // 处理预合成的渲染顺序
29301
29296
  if (option.type === ItemType$1.composition) {
29302
- var maskRef_1 = ++_this.mask;
29297
+ ++_this.mask;
29303
29298
  var refId = item.content.options.refId;
29304
29299
  if (!_this.refCompositions.get(refId)) {
29305
29300
  throw new Error('Invalid Ref Composition id: ' + refId);
@@ -29310,7 +29305,7 @@ var CompositionSourceManager = /** @class */ (function () {
29310
29305
  }
29311
29306
  ref.items.forEach(function (item) {
29312
29307
  item.listIndex = listOrder++;
29313
- _this.processMask(item.content, maskRef_1);
29308
+ _this.processMask(item.content);
29314
29309
  });
29315
29310
  option.items = ref.items;
29316
29311
  }
@@ -29349,11 +29344,17 @@ var CompositionSourceManager = /** @class */ (function () {
29349
29344
  /**
29350
29345
  * 处理蒙版和遮挡关系写入 stencil 的 ref 值
29351
29346
  */
29352
- CompositionSourceManager.prototype.processMask = function (renderer, maskRef) {
29347
+ CompositionSourceManager.prototype.processMask = function (renderer) {
29348
+ if (renderer.maskMode === MaskMode$1.NONE) {
29349
+ return;
29350
+ }
29353
29351
  if (!renderer.mask) {
29354
29352
  var maskMode = renderer.maskMode;
29355
- if (maskMode !== MaskMode$1.NONE) {
29356
- renderer.mask = maskRef;
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;
29357
29358
  }
29358
29359
  }
29359
29360
  };
@@ -29431,7 +29432,7 @@ var AssetManager = /** @class */ (function () {
29431
29432
  waitPromise = new Promise(function (resolve, reject) {
29432
29433
  return loadTimer = window.setTimeout(function () {
29433
29434
  cancelLoading = true;
29434
- reject("Load time out: ".concat(url));
29435
+ reject("Load time out: ".concat(JSON.stringify(url)));
29435
29436
  }, _this.timeout * 1000);
29436
29437
  });
29437
29438
  hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
@@ -29596,7 +29597,7 @@ var AssetManager = /** @class */ (function () {
29596
29597
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
29597
29598
  return _this.loadBins(bin.url);
29598
29599
  }
29599
- throw new Error("Invalid bins source: ".concat(bins));
29600
+ throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
29600
29601
  });
29601
29602
  return [2 /*return*/, Promise.all(jobs)];
29602
29603
  });
@@ -29632,7 +29633,7 @@ var AssetManager = /** @class */ (function () {
29632
29633
  case 3:
29633
29634
  _b.sent();
29634
29635
  console.warn({
29635
- content: "Invalid fonts source: ".concat(font.fontURL),
29636
+ content: "Invalid fonts source: ".concat(JSON.stringify(font.fontURL)),
29636
29637
  type: LOG_TYPE,
29637
29638
  });
29638
29639
  return [3 /*break*/, 4];
@@ -29801,7 +29802,7 @@ var AssetManager = /** @class */ (function () {
29801
29802
  return __generator(this, function (_a) {
29802
29803
  return [2 /*return*/, new Promise(function (resolve, reject) {
29803
29804
  _this.downloader.downloadJSON(url, resolve, function (status, responseText) {
29804
- 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));
29805
29806
  });
29806
29807
  })];
29807
29808
  });
@@ -29813,7 +29814,7 @@ var AssetManager = /** @class */ (function () {
29813
29814
  return __generator(this, function (_a) {
29814
29815
  return [2 /*return*/, new Promise(function (resolve, reject) {
29815
29816
  _this.downloader.downloadBinary(url, resolve, function (status, responseText) {
29816
- 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));
29817
29818
  });
29818
29819
  })];
29819
29820
  });
@@ -31159,7 +31160,10 @@ var Ticker = /** @class */ (function () {
31159
31160
  };
31160
31161
  Ticker.prototype.setFPS = function (fps) {
31161
31162
  this.targetFPS = clamp$1(fps, 1, 120);
31162
- 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;
31163
31167
  };
31164
31168
  /**
31165
31169
  * 获取定时器暂停标志位
@@ -35165,22 +35169,23 @@ var GLRenderer = /** @class */ (function (_super) {
35165
35169
  });
35166
35170
  Object.defineProperty(GLRenderer.prototype, "height", {
35167
35171
  get: function () {
35168
- var _a;
35169
- return ((_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.height) || 0;
35172
+ var _a, _b;
35173
+ return (_b = (_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 0;
35170
35174
  },
35171
35175
  enumerable: false,
35172
35176
  configurable: true
35173
35177
  });
35174
35178
  Object.defineProperty(GLRenderer.prototype, "width", {
35175
35179
  get: function () {
35176
- var _a;
35177
- return ((_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.width) || 0;
35180
+ var _a, _b;
35181
+ return (_b = (_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 0;
35178
35182
  },
35179
35183
  enumerable: false,
35180
35184
  configurable: true
35181
35185
  });
35182
35186
  GLRenderer.prototype.renderRenderFrame = function (renderFrame) {
35183
35187
  var e_1, _a, e_2, _b;
35188
+ var _c, _d;
35184
35189
  var frame = renderFrame;
35185
35190
  // TODO 需要一个贴图统一初始化的管理类,避免在渲染逻辑代码中初始化。
35186
35191
  // 初始化renderframe的贴图资源
@@ -35209,9 +35214,9 @@ var GLRenderer = /** @class */ (function (_super) {
35209
35214
  for (var passes_1 = __values$1(passes), passes_1_1 = passes_1.next(); !passes_1_1.done; passes_1_1 = passes_1.next()) {
35210
35215
  var pass = passes_1_1.value;
35211
35216
  var delegate = pass.delegate;
35212
- delegate.willBeginRenderPass && (delegate === null || delegate === void 0 ? void 0 : delegate.willBeginRenderPass(pass, this.renderingData));
35217
+ (_c = delegate.willBeginRenderPass) === null || _c === void 0 ? void 0 : _c.call(delegate, pass, this.renderingData);
35213
35218
  this.renderRenderPass(pass);
35214
- delegate.didEndRenderPass && (delegate === null || delegate === void 0 ? void 0 : delegate.didEndRenderPass(pass, this.renderingData));
35219
+ (_d = delegate.didEndRenderPass) === null || _d === void 0 ? void 0 : _d.call(delegate, pass, this.renderingData);
35215
35220
  }
35216
35221
  }
35217
35222
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -35246,6 +35251,7 @@ var GLRenderer = /** @class */ (function (_super) {
35246
35251
  };
35247
35252
  GLRenderer.prototype.renderMeshes = function (meshes) {
35248
35253
  var e_3, _a;
35254
+ var _b, _c;
35249
35255
  var delegate = this.renderingData.currentPass.delegate;
35250
35256
  try {
35251
35257
  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 +35269,9 @@ var GLRenderer = /** @class */ (function (_super) {
35263
35269
  }
35264
35270
  mesh.material.initialize();
35265
35271
  mesh.geometry.initialize();
35266
- delegate.willRenderMesh && delegate.willRenderMesh(mesh, this.renderingData);
35272
+ (_b = delegate.willRenderMesh) === null || _b === void 0 ? void 0 : _b.call(delegate, mesh, this.renderingData);
35267
35273
  mesh.render(this);
35268
- delegate.didiRenderMesh && delegate.didiRenderMesh(mesh, this.renderingData);
35274
+ (_c = delegate.didRenderMesh) === null || _c === void 0 ? void 0 : _c.call(delegate, mesh, this.renderingData);
35269
35275
  }
35270
35276
  }
35271
35277
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -36362,9 +36368,9 @@ Renderer.create = function (canvas, framework, renderOptions) {
36362
36368
  Engine.create = function (gl) {
36363
36369
  return new GLEngine(gl);
36364
36370
  };
36365
- var version = "1.1.2";
36371
+ var version = "1.1.3";
36366
36372
  console.info({
36367
- content: '[Galacean Effects Player] version: ' + "1.1.2",
36373
+ content: '[Galacean Effects Player] version: ' + "1.1.3",
36368
36374
  type: LOG_TYPE,
36369
36375
  });
36370
36376