@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.mjs 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
  /******************************************************************************
@@ -9243,10 +9243,10 @@ var VFXItem = /** @class */ (function () {
9243
9243
  };
9244
9244
  VFXItem.prototype.translateByPixel = function (x, y) {
9245
9245
  if (this.composition) {
9246
+ // @ts-expect-error
9247
+ var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
9246
9248
  var z = this.transform.getWorldPosition().z;
9247
- var _a = this.composition.camera.getInverseVPRatio(z), rx = _a.x, ry = _a.y;
9248
- var width = this.composition.renderer.getWidth() / 2;
9249
- var height = this.composition.renderer.getHeight() / 2;
9249
+ var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
9250
9250
  this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
9251
9251
  }
9252
9252
  };
@@ -21352,8 +21352,9 @@ var Camera = /** @class */ (function () {
21352
21352
  Camera.prototype.getInverseVPRatio = function (z) {
21353
21353
  var pos = new Vector3(0, 0, z);
21354
21354
  var mat = this.getViewProjectionMatrix();
21355
- var nz = pos.applyMatrix(mat).z;
21356
- return new Vector3(1, 1, nz).applyMatrix(mat);
21355
+ var inverseVP = this.getInverseViewProjectionMatrix();
21356
+ var nz = mat.projectPoint(pos).z;
21357
+ return inverseVP.projectPoint(new Vector3(1, 1, nz));
21357
21358
  };
21358
21359
  /**
21359
21360
  * 设置相机的旋转四元数
@@ -21365,7 +21366,6 @@ var Camera = /** @class */ (function () {
21365
21366
  this.dirty = true;
21366
21367
  }
21367
21368
  else {
21368
- this.options.quat;
21369
21369
  if (!this.options.quat.equals(value)) {
21370
21370
  this.options.quat.copyFrom(value);
21371
21371
  this.dirty = true;
@@ -23697,16 +23697,17 @@ var AssetManager = /** @class */ (function () {
23697
23697
  };
23698
23698
  AssetManager.prototype.processBins = function (bins) {
23699
23699
  return __awaiter(this, void 0, void 0, function () {
23700
- var renderLevel, jobs;
23700
+ var renderLevel, baseUrl, jobs;
23701
23701
  var _this = this;
23702
23702
  return __generator(this, function (_a) {
23703
23703
  renderLevel = this.options.renderLevel;
23704
+ baseUrl = this.baseUrl;
23704
23705
  jobs = bins.map(function (bin) {
23705
23706
  if (bin instanceof ArrayBuffer) {
23706
23707
  return bin;
23707
23708
  }
23708
23709
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
23709
- return _this.loadBins(bin.url);
23710
+ return _this.loadBins(new URL(bin.url, baseUrl).href);
23710
23711
  }
23711
23712
  throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
23712
23713
  });
@@ -23724,13 +23725,14 @@ var AssetManager = /** @class */ (function () {
23724
23725
  return [2 /*return*/];
23725
23726
  }
23726
23727
  jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
23727
- var fontFace;
23728
+ var url, fontFace;
23728
23729
  var _a;
23729
23730
  return __generator(this, function (_b) {
23730
23731
  switch (_b.label) {
23731
23732
  case 0:
23732
23733
  if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
23733
- fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + font.fontURL + ')');
23734
+ url = new URL(font.fontURL, this.baseUrl).href;
23735
+ fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
23734
23736
  _b.label = 1;
23735
23737
  case 1:
23736
23738
  _b.trys.push([1, 3, , 4]);
@@ -23743,7 +23745,7 @@ var AssetManager = /** @class */ (function () {
23743
23745
  return [3 /*break*/, 4];
23744
23746
  case 3:
23745
23747
  _b.sent();
23746
- logger.warn("Invalid fonts source: ".concat(JSON.stringify(font.fontURL)));
23748
+ logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
23747
23749
  return [3 /*break*/, 4];
23748
23750
  case 4: return [2 /*return*/];
23749
23751
  }
@@ -23975,7 +23977,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
23975
23977
  return image.source;
23976
23978
  }
23977
23979
  else if (image instanceof HTMLImageElement ||
23978
- image instanceof HTMLCanvasElement) {
23980
+ isCanvas(image)) {
23979
23981
  return {
23980
23982
  image: image,
23981
23983
  sourceType: TextureSourceType.image,
@@ -24012,6 +24014,11 @@ function createTextureOptionsBySource(image, sourceFrom) {
24012
24014
  }
24013
24015
  throw new Error('Invalid texture options');
24014
24016
  }
24017
+ function isCanvas(cavnas) {
24018
+ var _a;
24019
+ // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
24020
+ return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
24021
+ }
24015
24022
 
24016
24023
  var CompVFXItem = /** @class */ (function (_super) {
24017
24024
  __extends(CompVFXItem, _super);