@galacean/effects-core 1.2.2 → 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/asset-manager.d.ts +5 -1
- package/dist/index.js +42 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -13
- package/dist/index.mjs.map +1 -1
- package/dist/semantic-map.d.ts +1 -1
- package/package.json +1 -1
package/dist/asset-manager.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as spec from '@galacean/effects-specification';
|
|
2
2
|
import { Downloader } from './downloader';
|
|
3
3
|
import type { Disposable } from './utils';
|
|
4
4
|
import type { Scene } from './scene';
|
|
@@ -112,6 +112,10 @@ export declare class AssetManager implements Disposable {
|
|
|
112
112
|
*/
|
|
113
113
|
constructor(options?: SceneLoadOptions, downloader?: Downloader);
|
|
114
114
|
updateOptions(options?: SceneLoadOptions): void;
|
|
115
|
+
/**
|
|
116
|
+
* 根据用户传入的参数修改场景数据
|
|
117
|
+
*/
|
|
118
|
+
private updateSceneData;
|
|
115
119
|
/**
|
|
116
120
|
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
117
121
|
* @param url - json 的 URL 链接或者 json 对象
|
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.
|
|
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
|
|
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
|
|
21360
|
-
|
|
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;
|
|
@@ -23470,6 +23470,26 @@ var AssetManager = /** @class */ (function () {
|
|
|
23470
23470
|
var _a = options.timeout, timeout = _a === void 0 ? 10 : _a;
|
|
23471
23471
|
this.timeout = timeout;
|
|
23472
23472
|
};
|
|
23473
|
+
/**
|
|
23474
|
+
* 根据用户传入的参数修改场景数据
|
|
23475
|
+
*/
|
|
23476
|
+
AssetManager.prototype.updateSceneData = function (compositions) {
|
|
23477
|
+
var variables = this.options.variables;
|
|
23478
|
+
if (!variables || Object.keys(variables).length <= 0) {
|
|
23479
|
+
return compositions;
|
|
23480
|
+
}
|
|
23481
|
+
compositions.forEach(function (composition) {
|
|
23482
|
+
composition.items.forEach(function (item) {
|
|
23483
|
+
if (item.type === ItemType$1.text) {
|
|
23484
|
+
var textVariable = variables[item.name];
|
|
23485
|
+
if (textVariable) {
|
|
23486
|
+
item.content.options.text = textVariable;
|
|
23487
|
+
}
|
|
23488
|
+
}
|
|
23489
|
+
});
|
|
23490
|
+
});
|
|
23491
|
+
return compositions;
|
|
23492
|
+
};
|
|
23473
23493
|
/**
|
|
23474
23494
|
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
23475
23495
|
* @param url - json 的 URL 链接或者 json 对象
|
|
@@ -23561,6 +23581,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23561
23581
|
for (i = 0; i < scene.images.length; i++) {
|
|
23562
23582
|
scene.textureOptions[i].image = scene.images[i];
|
|
23563
23583
|
}
|
|
23584
|
+
scene.jsonScene.compositions = this.updateSceneData(scene.jsonScene.compositions);
|
|
23564
23585
|
_e.label = 5;
|
|
23565
23586
|
case 5: return [3 /*break*/, 12];
|
|
23566
23587
|
case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
|
|
@@ -23580,6 +23601,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23580
23601
|
return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
|
|
23581
23602
|
case 10:
|
|
23582
23603
|
loadedTextures = _e.sent();
|
|
23604
|
+
jsonScene_1.compositions = this.updateSceneData(jsonScene_1.compositions);
|
|
23583
23605
|
scene = {
|
|
23584
23606
|
url: url,
|
|
23585
23607
|
renderLevel: this.options.renderLevel,
|
|
@@ -23679,16 +23701,17 @@ var AssetManager = /** @class */ (function () {
|
|
|
23679
23701
|
};
|
|
23680
23702
|
AssetManager.prototype.processBins = function (bins) {
|
|
23681
23703
|
return __awaiter(this, void 0, void 0, function () {
|
|
23682
|
-
var renderLevel, jobs;
|
|
23704
|
+
var renderLevel, baseUrl, jobs;
|
|
23683
23705
|
var _this = this;
|
|
23684
23706
|
return __generator(this, function (_a) {
|
|
23685
23707
|
renderLevel = this.options.renderLevel;
|
|
23708
|
+
baseUrl = this.baseUrl;
|
|
23686
23709
|
jobs = bins.map(function (bin) {
|
|
23687
23710
|
if (bin instanceof ArrayBuffer) {
|
|
23688
23711
|
return bin;
|
|
23689
23712
|
}
|
|
23690
23713
|
if (passRenderLevel(bin.renderLevel, renderLevel)) {
|
|
23691
|
-
return _this.loadBins(bin.url);
|
|
23714
|
+
return _this.loadBins(new URL(bin.url, baseUrl).href);
|
|
23692
23715
|
}
|
|
23693
23716
|
throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
|
|
23694
23717
|
});
|
|
@@ -23706,13 +23729,14 @@ var AssetManager = /** @class */ (function () {
|
|
|
23706
23729
|
return [2 /*return*/];
|
|
23707
23730
|
}
|
|
23708
23731
|
jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
|
|
23709
|
-
var fontFace;
|
|
23732
|
+
var url, fontFace;
|
|
23710
23733
|
var _a;
|
|
23711
23734
|
return __generator(this, function (_b) {
|
|
23712
23735
|
switch (_b.label) {
|
|
23713
23736
|
case 0:
|
|
23714
23737
|
if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
|
|
23715
|
-
|
|
23738
|
+
url = new URL(font.fontURL, this.baseUrl).href;
|
|
23739
|
+
fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
|
|
23716
23740
|
_b.label = 1;
|
|
23717
23741
|
case 1:
|
|
23718
23742
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -23725,7 +23749,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23725
23749
|
return [3 /*break*/, 4];
|
|
23726
23750
|
case 3:
|
|
23727
23751
|
_b.sent();
|
|
23728
|
-
logger.warn("Invalid fonts source: ".concat(JSON.stringify(
|
|
23752
|
+
logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
|
|
23729
23753
|
return [3 /*break*/, 4];
|
|
23730
23754
|
case 4: return [2 /*return*/];
|
|
23731
23755
|
}
|
|
@@ -23957,7 +23981,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
23957
23981
|
return image.source;
|
|
23958
23982
|
}
|
|
23959
23983
|
else if (image instanceof HTMLImageElement ||
|
|
23960
|
-
image
|
|
23984
|
+
isCanvas(image)) {
|
|
23961
23985
|
return {
|
|
23962
23986
|
image: image,
|
|
23963
23987
|
sourceType: exports.TextureSourceType.image,
|
|
@@ -23994,6 +24018,11 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
23994
24018
|
}
|
|
23995
24019
|
throw new Error('Invalid texture options');
|
|
23996
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
|
+
}
|
|
23997
24026
|
|
|
23998
24027
|
var CompVFXItem = /** @class */ (function (_super) {
|
|
23999
24028
|
__extends(CompVFXItem, _super);
|