@galacean/effects-threejs 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 +21 -14
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +21 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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.
|
|
6
|
+
* Version: v1.2.4
|
|
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
|
|
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
|
};
|
|
@@ -21378,8 +21378,9 @@ var Camera = /** @class */ (function () {
|
|
|
21378
21378
|
Camera.prototype.getInverseVPRatio = function (z) {
|
|
21379
21379
|
var pos = new Vector3(0, 0, z);
|
|
21380
21380
|
var mat = this.getViewProjectionMatrix();
|
|
21381
|
-
var
|
|
21382
|
-
|
|
21381
|
+
var inverseVP = this.getInverseViewProjectionMatrix();
|
|
21382
|
+
var nz = mat.projectPoint(pos).z;
|
|
21383
|
+
return inverseVP.projectPoint(new Vector3(1, 1, nz));
|
|
21383
21384
|
};
|
|
21384
21385
|
/**
|
|
21385
21386
|
* 设置相机的旋转四元数
|
|
@@ -21391,7 +21392,6 @@ var Camera = /** @class */ (function () {
|
|
|
21391
21392
|
this.dirty = true;
|
|
21392
21393
|
}
|
|
21393
21394
|
else {
|
|
21394
|
-
this.options.quat;
|
|
21395
21395
|
if (!this.options.quat.equals(value)) {
|
|
21396
21396
|
this.options.quat.copyFrom(value);
|
|
21397
21397
|
this.dirty = true;
|
|
@@ -23723,16 +23723,17 @@ var AssetManager = /** @class */ (function () {
|
|
|
23723
23723
|
};
|
|
23724
23724
|
AssetManager.prototype.processBins = function (bins) {
|
|
23725
23725
|
return __awaiter(this, void 0, void 0, function () {
|
|
23726
|
-
var renderLevel, jobs;
|
|
23726
|
+
var renderLevel, baseUrl, jobs;
|
|
23727
23727
|
var _this = this;
|
|
23728
23728
|
return __generator(this, function (_a) {
|
|
23729
23729
|
renderLevel = this.options.renderLevel;
|
|
23730
|
+
baseUrl = this.baseUrl;
|
|
23730
23731
|
jobs = bins.map(function (bin) {
|
|
23731
23732
|
if (bin instanceof ArrayBuffer) {
|
|
23732
23733
|
return bin;
|
|
23733
23734
|
}
|
|
23734
23735
|
if (passRenderLevel(bin.renderLevel, renderLevel)) {
|
|
23735
|
-
return _this.loadBins(bin.url);
|
|
23736
|
+
return _this.loadBins(new URL(bin.url, baseUrl).href);
|
|
23736
23737
|
}
|
|
23737
23738
|
throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
|
|
23738
23739
|
});
|
|
@@ -23750,13 +23751,14 @@ var AssetManager = /** @class */ (function () {
|
|
|
23750
23751
|
return [2 /*return*/];
|
|
23751
23752
|
}
|
|
23752
23753
|
jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
|
|
23753
|
-
var fontFace;
|
|
23754
|
+
var url, fontFace;
|
|
23754
23755
|
var _a;
|
|
23755
23756
|
return __generator(this, function (_b) {
|
|
23756
23757
|
switch (_b.label) {
|
|
23757
23758
|
case 0:
|
|
23758
23759
|
if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
|
|
23759
|
-
|
|
23760
|
+
url = new URL(font.fontURL, this.baseUrl).href;
|
|
23761
|
+
fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
|
|
23760
23762
|
_b.label = 1;
|
|
23761
23763
|
case 1:
|
|
23762
23764
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -23769,7 +23771,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23769
23771
|
return [3 /*break*/, 4];
|
|
23770
23772
|
case 3:
|
|
23771
23773
|
_b.sent();
|
|
23772
|
-
logger.warn("Invalid fonts source: ".concat(JSON.stringify(
|
|
23774
|
+
logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
|
|
23773
23775
|
return [3 /*break*/, 4];
|
|
23774
23776
|
case 4: return [2 /*return*/];
|
|
23775
23777
|
}
|
|
@@ -24001,7 +24003,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
24001
24003
|
return image.source;
|
|
24002
24004
|
}
|
|
24003
24005
|
else if (image instanceof HTMLImageElement ||
|
|
24004
|
-
image
|
|
24006
|
+
isCanvas(image)) {
|
|
24005
24007
|
return {
|
|
24006
24008
|
image: image,
|
|
24007
24009
|
sourceType: exports.TextureSourceType.image,
|
|
@@ -24038,6 +24040,11 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
24038
24040
|
}
|
|
24039
24041
|
throw new Error('Invalid texture options');
|
|
24040
24042
|
}
|
|
24043
|
+
function isCanvas(cavnas) {
|
|
24044
|
+
var _a;
|
|
24045
|
+
// 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
|
|
24046
|
+
return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
|
|
24047
|
+
}
|
|
24041
24048
|
|
|
24042
24049
|
var CompVFXItem = /** @class */ (function (_super) {
|
|
24043
24050
|
__extends(CompVFXItem, _super);
|
|
@@ -26935,7 +26942,7 @@ Geometry.create = function (engine, options) {
|
|
|
26935
26942
|
Mesh.create = function (engine, props) {
|
|
26936
26943
|
return new ThreeMesh(engine, props);
|
|
26937
26944
|
};
|
|
26938
|
-
var version = "1.2.
|
|
26945
|
+
var version = "1.2.4";
|
|
26939
26946
|
logger.info('THREEJS plugin version: ' + version);
|
|
26940
26947
|
|
|
26941
26948
|
exports.AbstractPlugin = AbstractPlugin;
|