@galacean/effects-core 1.2.3 → 1.2.5

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.5
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
  };
@@ -13146,9 +13146,13 @@ var InteractVFXItem = /** @class */ (function (_super) {
13146
13146
  this.handleDragMove(this.dragEvent, this.bouncingArg);
13147
13147
  }
13148
13148
  };
13149
- InteractVFXItem.prototype.onItemRemoved = function (composition) {
13149
+ InteractVFXItem.prototype.onEnd = function () {
13150
+ if (this.composition) {
13151
+ this.composition.removeInteractiveItem(this, this.ui.options.type);
13152
+ }
13153
+ };
13154
+ InteractVFXItem.prototype.onItemRemoved = function () {
13150
13155
  var _a;
13151
- composition.removeInteractiveItem(this, this.ui.options.type);
13152
13156
  this.clickable = false;
13153
13157
  (_a = this.previewContent) === null || _a === void 0 ? void 0 : _a.mesh.dispose();
13154
13158
  this.endDragTarget();
@@ -21356,8 +21360,9 @@ var Camera = /** @class */ (function () {
21356
21360
  Camera.prototype.getInverseVPRatio = function (z) {
21357
21361
  var pos = new Vector3(0, 0, z);
21358
21362
  var mat = this.getViewProjectionMatrix();
21359
- var nz = pos.applyMatrix(mat).z;
21360
- return new Vector3(1, 1, nz).applyMatrix(mat);
21363
+ var inverseVP = this.getInverseViewProjectionMatrix();
21364
+ var nz = mat.projectPoint(pos).z;
21365
+ return inverseVP.projectPoint(new Vector3(1, 1, nz));
21361
21366
  };
21362
21367
  /**
21363
21368
  * 设置相机的旋转四元数
@@ -21369,7 +21374,6 @@ var Camera = /** @class */ (function () {
21369
21374
  this.dirty = true;
21370
21375
  }
21371
21376
  else {
21372
- this.options.quat;
21373
21377
  if (!this.options.quat.equals(value)) {
21374
21378
  this.options.quat.copyFrom(value);
21375
21379
  this.dirty = true;
@@ -23701,16 +23705,17 @@ var AssetManager = /** @class */ (function () {
23701
23705
  };
23702
23706
  AssetManager.prototype.processBins = function (bins) {
23703
23707
  return __awaiter(this, void 0, void 0, function () {
23704
- var renderLevel, jobs;
23708
+ var renderLevel, baseUrl, jobs;
23705
23709
  var _this = this;
23706
23710
  return __generator(this, function (_a) {
23707
23711
  renderLevel = this.options.renderLevel;
23712
+ baseUrl = this.baseUrl;
23708
23713
  jobs = bins.map(function (bin) {
23709
23714
  if (bin instanceof ArrayBuffer) {
23710
23715
  return bin;
23711
23716
  }
23712
23717
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
23713
- return _this.loadBins(bin.url);
23718
+ return _this.loadBins(new URL(bin.url, baseUrl).href);
23714
23719
  }
23715
23720
  throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
23716
23721
  });
@@ -23728,13 +23733,14 @@ var AssetManager = /** @class */ (function () {
23728
23733
  return [2 /*return*/];
23729
23734
  }
23730
23735
  jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
23731
- var fontFace;
23736
+ var url, fontFace;
23732
23737
  var _a;
23733
23738
  return __generator(this, function (_b) {
23734
23739
  switch (_b.label) {
23735
23740
  case 0:
23736
23741
  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 + ')');
23742
+ url = new URL(font.fontURL, this.baseUrl).href;
23743
+ fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
23738
23744
  _b.label = 1;
23739
23745
  case 1:
23740
23746
  _b.trys.push([1, 3, , 4]);
@@ -23747,7 +23753,7 @@ var AssetManager = /** @class */ (function () {
23747
23753
  return [3 /*break*/, 4];
23748
23754
  case 3:
23749
23755
  _b.sent();
23750
- logger.warn("Invalid fonts source: ".concat(JSON.stringify(font.fontURL)));
23756
+ logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
23751
23757
  return [3 /*break*/, 4];
23752
23758
  case 4: return [2 /*return*/];
23753
23759
  }
@@ -23979,7 +23985,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
23979
23985
  return image.source;
23980
23986
  }
23981
23987
  else if (image instanceof HTMLImageElement ||
23982
- image instanceof HTMLCanvasElement) {
23988
+ isCanvas(image)) {
23983
23989
  return {
23984
23990
  image: image,
23985
23991
  sourceType: exports.TextureSourceType.image,
@@ -24016,6 +24022,11 @@ function createTextureOptionsBySource(image, sourceFrom) {
24016
24022
  }
24017
24023
  throw new Error('Invalid texture options');
24018
24024
  }
24025
+ function isCanvas(cavnas) {
24026
+ var _a;
24027
+ // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
24028
+ return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
24029
+ }
24019
24030
 
24020
24031
  var CompVFXItem = /** @class */ (function (_super) {
24021
24032
  __extends(CompVFXItem, _super);