@galacean/effects-threejs 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 threejs plugin 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';
@@ -9269,10 +9269,10 @@ var VFXItem = /** @class */ (function () {
9269
9269
  };
9270
9270
  VFXItem.prototype.translateByPixel = function (x, y) {
9271
9271
  if (this.composition) {
9272
+ // @ts-expect-error
9273
+ var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
9272
9274
  var z = this.transform.getWorldPosition().z;
9273
- var _a = this.composition.camera.getInverseVPRatio(z), rx = _a.x, ry = _a.y;
9274
- var width = this.composition.renderer.getWidth() / 2;
9275
- var height = this.composition.renderer.getHeight() / 2;
9275
+ var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
9276
9276
  this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
9277
9277
  }
9278
9278
  };
@@ -13168,9 +13168,13 @@ var InteractVFXItem = /** @class */ (function (_super) {
13168
13168
  this.handleDragMove(this.dragEvent, this.bouncingArg);
13169
13169
  }
13170
13170
  };
13171
- InteractVFXItem.prototype.onItemRemoved = function (composition) {
13171
+ InteractVFXItem.prototype.onEnd = function () {
13172
+ if (this.composition) {
13173
+ this.composition.removeInteractiveItem(this, this.ui.options.type);
13174
+ }
13175
+ };
13176
+ InteractVFXItem.prototype.onItemRemoved = function () {
13172
13177
  var _a;
13173
- composition.removeInteractiveItem(this, this.ui.options.type);
13174
13178
  this.clickable = false;
13175
13179
  (_a = this.previewContent) === null || _a === void 0 ? void 0 : _a.mesh.dispose();
13176
13180
  this.endDragTarget();
@@ -21378,8 +21382,9 @@ var Camera = /** @class */ (function () {
21378
21382
  Camera.prototype.getInverseVPRatio = function (z) {
21379
21383
  var pos = new Vector3(0, 0, z);
21380
21384
  var mat = this.getViewProjectionMatrix();
21381
- var nz = pos.applyMatrix(mat).z;
21382
- return new Vector3(1, 1, nz).applyMatrix(mat);
21385
+ var inverseVP = this.getInverseViewProjectionMatrix();
21386
+ var nz = mat.projectPoint(pos).z;
21387
+ return inverseVP.projectPoint(new Vector3(1, 1, nz));
21383
21388
  };
21384
21389
  /**
21385
21390
  * 设置相机的旋转四元数
@@ -21391,7 +21396,6 @@ var Camera = /** @class */ (function () {
21391
21396
  this.dirty = true;
21392
21397
  }
21393
21398
  else {
21394
- this.options.quat;
21395
21399
  if (!this.options.quat.equals(value)) {
21396
21400
  this.options.quat.copyFrom(value);
21397
21401
  this.dirty = true;
@@ -23723,16 +23727,17 @@ var AssetManager = /** @class */ (function () {
23723
23727
  };
23724
23728
  AssetManager.prototype.processBins = function (bins) {
23725
23729
  return __awaiter(this, void 0, void 0, function () {
23726
- var renderLevel, jobs;
23730
+ var renderLevel, baseUrl, jobs;
23727
23731
  var _this = this;
23728
23732
  return __generator(this, function (_a) {
23729
23733
  renderLevel = this.options.renderLevel;
23734
+ baseUrl = this.baseUrl;
23730
23735
  jobs = bins.map(function (bin) {
23731
23736
  if (bin instanceof ArrayBuffer) {
23732
23737
  return bin;
23733
23738
  }
23734
23739
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
23735
- return _this.loadBins(bin.url);
23740
+ return _this.loadBins(new URL(bin.url, baseUrl).href);
23736
23741
  }
23737
23742
  throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
23738
23743
  });
@@ -23750,13 +23755,14 @@ var AssetManager = /** @class */ (function () {
23750
23755
  return [2 /*return*/];
23751
23756
  }
23752
23757
  jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
23753
- var fontFace;
23758
+ var url, fontFace;
23754
23759
  var _a;
23755
23760
  return __generator(this, function (_b) {
23756
23761
  switch (_b.label) {
23757
23762
  case 0:
23758
23763
  if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
23759
- fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + font.fontURL + ')');
23764
+ url = new URL(font.fontURL, this.baseUrl).href;
23765
+ fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
23760
23766
  _b.label = 1;
23761
23767
  case 1:
23762
23768
  _b.trys.push([1, 3, , 4]);
@@ -23769,7 +23775,7 @@ var AssetManager = /** @class */ (function () {
23769
23775
  return [3 /*break*/, 4];
23770
23776
  case 3:
23771
23777
  _b.sent();
23772
- logger.warn("Invalid fonts source: ".concat(JSON.stringify(font.fontURL)));
23778
+ logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
23773
23779
  return [3 /*break*/, 4];
23774
23780
  case 4: return [2 /*return*/];
23775
23781
  }
@@ -24001,7 +24007,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
24001
24007
  return image.source;
24002
24008
  }
24003
24009
  else if (image instanceof HTMLImageElement ||
24004
- image instanceof HTMLCanvasElement) {
24010
+ isCanvas(image)) {
24005
24011
  return {
24006
24012
  image: image,
24007
24013
  sourceType: exports.TextureSourceType.image,
@@ -24038,6 +24044,11 @@ function createTextureOptionsBySource(image, sourceFrom) {
24038
24044
  }
24039
24045
  throw new Error('Invalid texture options');
24040
24046
  }
24047
+ function isCanvas(cavnas) {
24048
+ var _a;
24049
+ // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
24050
+ return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
24051
+ }
24041
24052
 
24042
24053
  var CompVFXItem = /** @class */ (function (_super) {
24043
24054
  __extends(CompVFXItem, _super);
@@ -26935,7 +26946,7 @@ Geometry.create = function (engine, options) {
26935
26946
  Mesh.create = function (engine, props) {
26936
26947
  return new ThreeMesh(engine, props);
26937
26948
  };
26938
- var version = "1.2.3";
26949
+ var version = "1.2.5";
26939
26950
  logger.info('THREEJS plugin version: ' + version);
26940
26951
 
26941
26952
  exports.AbstractPlugin = AbstractPlugin;