@galacean/effects-core 1.2.3 → 1.2.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 core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v1.2.3
6
+ * Version: v1.2.4
7
7
  */
8
8
 
9
9
  'use strict';
@@ -9247,10 +9247,10 @@ var VFXItem = /** @class */ (function () {
9247
9247
  };
9248
9248
  VFXItem.prototype.translateByPixel = function (x, y) {
9249
9249
  if (this.composition) {
9250
+ // @ts-expect-error
9251
+ var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
9250
9252
  var z = this.transform.getWorldPosition().z;
9251
- var _a = this.composition.camera.getInverseVPRatio(z), rx = _a.x, ry = _a.y;
9252
- var width = this.composition.renderer.getWidth() / 2;
9253
- var height = this.composition.renderer.getHeight() / 2;
9253
+ var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
9254
9254
  this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
9255
9255
  }
9256
9256
  };
@@ -21356,8 +21356,9 @@ var Camera = /** @class */ (function () {
21356
21356
  Camera.prototype.getInverseVPRatio = function (z) {
21357
21357
  var pos = new Vector3(0, 0, z);
21358
21358
  var mat = this.getViewProjectionMatrix();
21359
- var nz = pos.applyMatrix(mat).z;
21360
- return new Vector3(1, 1, nz).applyMatrix(mat);
21359
+ var inverseVP = this.getInverseViewProjectionMatrix();
21360
+ var nz = mat.projectPoint(pos).z;
21361
+ return inverseVP.projectPoint(new Vector3(1, 1, nz));
21361
21362
  };
21362
21363
  /**
21363
21364
  * 设置相机的旋转四元数
@@ -21369,7 +21370,6 @@ var Camera = /** @class */ (function () {
21369
21370
  this.dirty = true;
21370
21371
  }
21371
21372
  else {
21372
- this.options.quat;
21373
21373
  if (!this.options.quat.equals(value)) {
21374
21374
  this.options.quat.copyFrom(value);
21375
21375
  this.dirty = true;
@@ -23701,16 +23701,17 @@ var AssetManager = /** @class */ (function () {
23701
23701
  };
23702
23702
  AssetManager.prototype.processBins = function (bins) {
23703
23703
  return __awaiter(this, void 0, void 0, function () {
23704
- var renderLevel, jobs;
23704
+ var renderLevel, baseUrl, jobs;
23705
23705
  var _this = this;
23706
23706
  return __generator(this, function (_a) {
23707
23707
  renderLevel = this.options.renderLevel;
23708
+ baseUrl = this.baseUrl;
23708
23709
  jobs = bins.map(function (bin) {
23709
23710
  if (bin instanceof ArrayBuffer) {
23710
23711
  return bin;
23711
23712
  }
23712
23713
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
23713
- return _this.loadBins(bin.url);
23714
+ return _this.loadBins(new URL(bin.url, baseUrl).href);
23714
23715
  }
23715
23716
  throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
23716
23717
  });
@@ -23728,13 +23729,14 @@ var AssetManager = /** @class */ (function () {
23728
23729
  return [2 /*return*/];
23729
23730
  }
23730
23731
  jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
23731
- var fontFace;
23732
+ var url, fontFace;
23732
23733
  var _a;
23733
23734
  return __generator(this, function (_b) {
23734
23735
  switch (_b.label) {
23735
23736
  case 0:
23736
23737
  if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
23737
- fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + font.fontURL + ')');
23738
+ url = new URL(font.fontURL, this.baseUrl).href;
23739
+ fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
23738
23740
  _b.label = 1;
23739
23741
  case 1:
23740
23742
  _b.trys.push([1, 3, , 4]);
@@ -23747,7 +23749,7 @@ var AssetManager = /** @class */ (function () {
23747
23749
  return [3 /*break*/, 4];
23748
23750
  case 3:
23749
23751
  _b.sent();
23750
- logger.warn("Invalid fonts source: ".concat(JSON.stringify(font.fontURL)));
23752
+ logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
23751
23753
  return [3 /*break*/, 4];
23752
23754
  case 4: return [2 /*return*/];
23753
23755
  }
@@ -23979,7 +23981,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
23979
23981
  return image.source;
23980
23982
  }
23981
23983
  else if (image instanceof HTMLImageElement ||
23982
- image instanceof HTMLCanvasElement) {
23984
+ isCanvas(image)) {
23983
23985
  return {
23984
23986
  image: image,
23985
23987
  sourceType: exports.TextureSourceType.image,
@@ -24016,6 +24018,11 @@ function createTextureOptionsBySource(image, sourceFrom) {
24016
24018
  }
24017
24019
  throw new Error('Invalid texture options');
24018
24020
  }
24021
+ function isCanvas(cavnas) {
24022
+ var _a;
24023
+ // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
24024
+ return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
24025
+ }
24019
24026
 
24020
24027
  var CompVFXItem = /** @class */ (function (_super) {
24021
24028
  __extends(CompVFXItem, _super);