@galacean/effects 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/index.js +50 -24
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +50 -24
- package/dist/index.mjs.map +1 -1
- package/dist/player.d.ts +1 -1
- package/dist/weapp.js +49 -23
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +49 -23
- package/dist/weapp.mjs.map +1 -1
- package/package.json +3 -3
package/dist/player.d.ts
CHANGED
|
@@ -163,7 +163,7 @@ export declare class Player implements Disposable, LostHandler, RestoreHandler {
|
|
|
163
163
|
private resumePending;
|
|
164
164
|
private offscreenMode;
|
|
165
165
|
private disposed;
|
|
166
|
-
private
|
|
166
|
+
private assetManagers;
|
|
167
167
|
private speed;
|
|
168
168
|
private baseCompositionIndex;
|
|
169
169
|
/**
|
package/dist/weapp.js
CHANGED
|
@@ -9241,10 +9241,10 @@ var VFXItem = /** @class */ (function () {
|
|
|
9241
9241
|
};
|
|
9242
9242
|
VFXItem.prototype.translateByPixel = function (x, y) {
|
|
9243
9243
|
if (this.composition) {
|
|
9244
|
+
// @ts-expect-error
|
|
9245
|
+
var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
|
|
9244
9246
|
var z = this.transform.getWorldPosition().z;
|
|
9245
|
-
var
|
|
9246
|
-
var width = this.composition.renderer.getWidth() / 2;
|
|
9247
|
-
var height = this.composition.renderer.getHeight() / 2;
|
|
9247
|
+
var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
|
|
9248
9248
|
this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
|
|
9249
9249
|
}
|
|
9250
9250
|
};
|
|
@@ -21350,8 +21350,9 @@ var Camera = /** @class */ (function () {
|
|
|
21350
21350
|
Camera.prototype.getInverseVPRatio = function (z) {
|
|
21351
21351
|
var pos = new Vector3(0, 0, z);
|
|
21352
21352
|
var mat = this.getViewProjectionMatrix();
|
|
21353
|
-
var
|
|
21354
|
-
|
|
21353
|
+
var inverseVP = this.getInverseViewProjectionMatrix();
|
|
21354
|
+
var nz = mat.projectPoint(pos).z;
|
|
21355
|
+
return inverseVP.projectPoint(new Vector3(1, 1, nz));
|
|
21355
21356
|
};
|
|
21356
21357
|
/**
|
|
21357
21358
|
* 设置相机的旋转四元数
|
|
@@ -21363,7 +21364,6 @@ var Camera = /** @class */ (function () {
|
|
|
21363
21364
|
this.dirty = true;
|
|
21364
21365
|
}
|
|
21365
21366
|
else {
|
|
21366
|
-
this.options.quat;
|
|
21367
21367
|
if (!this.options.quat.equals(value)) {
|
|
21368
21368
|
this.options.quat.copyFrom(value);
|
|
21369
21369
|
this.dirty = true;
|
|
@@ -23464,6 +23464,26 @@ var AssetManager = /** @class */ (function () {
|
|
|
23464
23464
|
var _a = options.timeout, timeout = _a === void 0 ? 10 : _a;
|
|
23465
23465
|
this.timeout = timeout;
|
|
23466
23466
|
};
|
|
23467
|
+
/**
|
|
23468
|
+
* 根据用户传入的参数修改场景数据
|
|
23469
|
+
*/
|
|
23470
|
+
AssetManager.prototype.updateSceneData = function (compositions) {
|
|
23471
|
+
var variables = this.options.variables;
|
|
23472
|
+
if (!variables || Object.keys(variables).length <= 0) {
|
|
23473
|
+
return compositions;
|
|
23474
|
+
}
|
|
23475
|
+
compositions.forEach(function (composition) {
|
|
23476
|
+
composition.items.forEach(function (item) {
|
|
23477
|
+
if (item.type === ItemType$1.text) {
|
|
23478
|
+
var textVariable = variables[item.name];
|
|
23479
|
+
if (textVariable) {
|
|
23480
|
+
item.content.options.text = textVariable;
|
|
23481
|
+
}
|
|
23482
|
+
}
|
|
23483
|
+
});
|
|
23484
|
+
});
|
|
23485
|
+
return compositions;
|
|
23486
|
+
};
|
|
23467
23487
|
/**
|
|
23468
23488
|
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
23469
23489
|
* @param url - json 的 URL 链接或者 json 对象
|
|
@@ -23555,6 +23575,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23555
23575
|
for (i = 0; i < scene.images.length; i++) {
|
|
23556
23576
|
scene.textureOptions[i].image = scene.images[i];
|
|
23557
23577
|
}
|
|
23578
|
+
scene.jsonScene.compositions = this.updateSceneData(scene.jsonScene.compositions);
|
|
23558
23579
|
_e.label = 5;
|
|
23559
23580
|
case 5: return [3 /*break*/, 12];
|
|
23560
23581
|
case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
|
|
@@ -23574,6 +23595,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23574
23595
|
return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
|
|
23575
23596
|
case 10:
|
|
23576
23597
|
loadedTextures = _e.sent();
|
|
23598
|
+
jsonScene_1.compositions = this.updateSceneData(jsonScene_1.compositions);
|
|
23577
23599
|
scene = {
|
|
23578
23600
|
url: url,
|
|
23579
23601
|
renderLevel: this.options.renderLevel,
|
|
@@ -23673,16 +23695,17 @@ var AssetManager = /** @class */ (function () {
|
|
|
23673
23695
|
};
|
|
23674
23696
|
AssetManager.prototype.processBins = function (bins) {
|
|
23675
23697
|
return __awaiter(this, void 0, void 0, function () {
|
|
23676
|
-
var renderLevel, jobs;
|
|
23698
|
+
var renderLevel, baseUrl, jobs;
|
|
23677
23699
|
var _this = this;
|
|
23678
23700
|
return __generator(this, function (_a) {
|
|
23679
23701
|
renderLevel = this.options.renderLevel;
|
|
23702
|
+
baseUrl = this.baseUrl;
|
|
23680
23703
|
jobs = bins.map(function (bin) {
|
|
23681
23704
|
if (bin instanceof ArrayBuffer) {
|
|
23682
23705
|
return bin;
|
|
23683
23706
|
}
|
|
23684
23707
|
if (passRenderLevel(bin.renderLevel, renderLevel)) {
|
|
23685
|
-
return _this.loadBins(bin.url);
|
|
23708
|
+
return _this.loadBins(new weapp.URL(bin.url, baseUrl).href);
|
|
23686
23709
|
}
|
|
23687
23710
|
throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
|
|
23688
23711
|
});
|
|
@@ -23700,13 +23723,14 @@ var AssetManager = /** @class */ (function () {
|
|
|
23700
23723
|
return [2 /*return*/];
|
|
23701
23724
|
}
|
|
23702
23725
|
jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
|
|
23703
|
-
var fontFace;
|
|
23726
|
+
var url, fontFace;
|
|
23704
23727
|
var _a;
|
|
23705
23728
|
return __generator(this, function (_b) {
|
|
23706
23729
|
switch (_b.label) {
|
|
23707
23730
|
case 0:
|
|
23708
23731
|
if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
|
|
23709
|
-
|
|
23732
|
+
url = new weapp.URL(font.fontURL, this.baseUrl).href;
|
|
23733
|
+
fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
|
|
23710
23734
|
_b.label = 1;
|
|
23711
23735
|
case 1:
|
|
23712
23736
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -23719,7 +23743,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23719
23743
|
return [3 /*break*/, 4];
|
|
23720
23744
|
case 3:
|
|
23721
23745
|
_b.sent();
|
|
23722
|
-
logger.warn("Invalid fonts source: ".concat(JSON.stringify(
|
|
23746
|
+
logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
|
|
23723
23747
|
return [3 /*break*/, 4];
|
|
23724
23748
|
case 4: return [2 /*return*/];
|
|
23725
23749
|
}
|
|
@@ -23951,7 +23975,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
23951
23975
|
return image.source;
|
|
23952
23976
|
}
|
|
23953
23977
|
else if (image instanceof weapp.HTMLImageElement ||
|
|
23954
|
-
image
|
|
23978
|
+
isCanvas(image)) {
|
|
23955
23979
|
return {
|
|
23956
23980
|
image: image,
|
|
23957
23981
|
sourceType: exports.TextureSourceType.image,
|
|
@@ -23988,6 +24012,11 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
23988
24012
|
}
|
|
23989
24013
|
throw new Error('Invalid texture options');
|
|
23990
24014
|
}
|
|
24015
|
+
function isCanvas(cavnas) {
|
|
24016
|
+
var _a;
|
|
24017
|
+
// 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
|
|
24018
|
+
return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
|
|
24019
|
+
}
|
|
23991
24020
|
|
|
23992
24021
|
var CompVFXItem = /** @class */ (function (_super) {
|
|
23993
24022
|
__extends(CompVFXItem, _super);
|
|
@@ -29571,6 +29600,7 @@ var Player = /** @class */ (function () {
|
|
|
29571
29600
|
this.displayScale = 1;
|
|
29572
29601
|
this.resumePending = false;
|
|
29573
29602
|
this.disposed = false;
|
|
29603
|
+
this.assetManagers = [];
|
|
29574
29604
|
this.speed = 1;
|
|
29575
29605
|
this.baseCompositionIndex = 0;
|
|
29576
29606
|
/**
|
|
@@ -29853,7 +29883,7 @@ var Player = /** @class */ (function () {
|
|
|
29853
29883
|
Player.prototype.createComposition = function (url, options) {
|
|
29854
29884
|
if (options === void 0) { options = {}; }
|
|
29855
29885
|
return __awaiter(this, void 0, void 0, function () {
|
|
29856
|
-
var renderer, last, opts, source, scene, composition, firstFrameTime;
|
|
29886
|
+
var renderer, last, opts, source, assetManager, scene, composition, firstFrameTime;
|
|
29857
29887
|
var _this = this;
|
|
29858
29888
|
return __generator(this, function (_a) {
|
|
29859
29889
|
switch (_a.label) {
|
|
@@ -29868,13 +29898,9 @@ var Player = /** @class */ (function () {
|
|
|
29868
29898
|
else {
|
|
29869
29899
|
source = url;
|
|
29870
29900
|
}
|
|
29871
|
-
|
|
29872
|
-
|
|
29873
|
-
}
|
|
29874
|
-
else {
|
|
29875
|
-
this.assetManager = new AssetManager(opts);
|
|
29876
|
-
}
|
|
29877
|
-
return [4 /*yield*/, this.assetManager.loadScene(source, this.renderer, { env: this.env })];
|
|
29901
|
+
assetManager = new AssetManager(opts);
|
|
29902
|
+
this.assetManagers.push(assetManager);
|
|
29903
|
+
return [4 /*yield*/, assetManager.loadScene(source, this.renderer, { env: this.env })];
|
|
29878
29904
|
case 1:
|
|
29879
29905
|
scene = _a.sent();
|
|
29880
29906
|
// 加载期间 player 销毁
|
|
@@ -30204,7 +30230,7 @@ var Player = /** @class */ (function () {
|
|
|
30204
30230
|
* @param keepCanvas - 是否保留 canvas 画面,默认不保留,canvas 不能再被使用
|
|
30205
30231
|
*/
|
|
30206
30232
|
Player.prototype.dispose = function (keepCanvas) {
|
|
30207
|
-
var _a
|
|
30233
|
+
var _a;
|
|
30208
30234
|
logger.info("call player destroy: ".concat(this.name));
|
|
30209
30235
|
if (this.disposed) {
|
|
30210
30236
|
return;
|
|
@@ -30212,7 +30238,7 @@ var Player = /** @class */ (function () {
|
|
|
30212
30238
|
playerMap.delete(this.canvas);
|
|
30213
30239
|
this.pause();
|
|
30214
30240
|
(_a = this.ticker) === null || _a === void 0 ? void 0 : _a.stop();
|
|
30215
|
-
(
|
|
30241
|
+
this.assetManagers.forEach(function (assetManager) { return assetManager.dispose(); });
|
|
30216
30242
|
this.compositions.forEach(function (comp) { return comp.dispose(); });
|
|
30217
30243
|
this.compositions.length = 0;
|
|
30218
30244
|
this.renderer.context.removeLostHandler({ lost: this.lost });
|
|
@@ -30418,7 +30444,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
|
|
|
30418
30444
|
Engine.create = function (gl) {
|
|
30419
30445
|
return new GLEngine(gl);
|
|
30420
30446
|
};
|
|
30421
|
-
var version = "1.2.
|
|
30447
|
+
var version = "1.2.4";
|
|
30422
30448
|
logger.info('player version: ' + version);
|
|
30423
30449
|
|
|
30424
30450
|
exports.AbstractPlugin = AbstractPlugin;
|