@galacean/effects-threejs 1.1.3 → 1.1.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 +87 -62
- 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 +87 -62
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
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.1.
|
|
6
|
+
* Version: v1.1.4
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as THREE from 'three';
|
|
@@ -14731,6 +14731,9 @@ var VFXItem = /** @class */ (function () {
|
|
|
14731
14731
|
VFXItem.isTree = function (item) {
|
|
14732
14732
|
return item.type === ItemType$1.tree;
|
|
14733
14733
|
};
|
|
14734
|
+
VFXItem.isCamera = function (item) {
|
|
14735
|
+
return item.type === ItemType$1.camera;
|
|
14736
|
+
};
|
|
14734
14737
|
VFXItem.isExtraCamera = function (item) {
|
|
14735
14738
|
return item.id === 'extra-camera' && item.name === 'extra-camera';
|
|
14736
14739
|
};
|
|
@@ -14931,10 +14934,11 @@ var VFXItem = /** @class */ (function () {
|
|
|
14931
14934
|
}
|
|
14932
14935
|
else if (this.endBehavior === END_BEHAVIOR_DESTROY$1) {
|
|
14933
14936
|
this._contentVisible = false;
|
|
14937
|
+
shouldUpdate = true;
|
|
14938
|
+
dt = 0;
|
|
14934
14939
|
// 预合成配置 reusable 且销毁时, 需要隐藏其中的元素
|
|
14935
14940
|
if (this.type === ItemType$1.composition) {
|
|
14936
14941
|
this.handleVisibleChanged(false);
|
|
14937
|
-
this.onItemUpdate(0, lifetime);
|
|
14938
14942
|
}
|
|
14939
14943
|
}
|
|
14940
14944
|
lifetime = Math.min(lifetime, 1);
|
|
@@ -15518,10 +15522,6 @@ var CameraVFXItem = /** @class */ (function (_super) {
|
|
|
15518
15522
|
(_a = this.controller) === null || _a === void 0 ? void 0 : _a.update(lifetime);
|
|
15519
15523
|
this.updateCamera();
|
|
15520
15524
|
};
|
|
15521
|
-
// override onEnd () {
|
|
15522
|
-
// this.controller?.update(1);
|
|
15523
|
-
// this.updateCamera();
|
|
15524
|
-
// }
|
|
15525
15525
|
CameraVFXItem.prototype.updateCamera = function () {
|
|
15526
15526
|
if (this.controller && this.composition) {
|
|
15527
15527
|
var camera = this.composition.camera;
|
|
@@ -23566,7 +23566,7 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23566
23566
|
configurable: true
|
|
23567
23567
|
});
|
|
23568
23568
|
ParticleSystem.prototype.updateEmitterTransform = function (time) {
|
|
23569
|
-
var parentTransform = this.parentTransform;
|
|
23569
|
+
var parentTransform = this.transform.parentTransform;
|
|
23570
23570
|
var _a = this.basicTransform, path = _a.path, position = _a.position;
|
|
23571
23571
|
var selfPos = position.clone();
|
|
23572
23572
|
if (path) {
|
|
@@ -23576,9 +23576,9 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23576
23576
|
this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
|
|
23577
23577
|
if (this.options.particleFollowParent && parentTransform) {
|
|
23578
23578
|
var tempMatrix = parentTransform.getWorldMatrix();
|
|
23579
|
-
this.particleMesh.mesh.worldMatrix = tempMatrix
|
|
23579
|
+
this.particleMesh.mesh.worldMatrix = tempMatrix;
|
|
23580
23580
|
if (this.trailMesh) {
|
|
23581
|
-
this.trailMesh.mesh.worldMatrix = tempMatrix
|
|
23581
|
+
this.trailMesh.mesh.worldMatrix = tempMatrix;
|
|
23582
23582
|
}
|
|
23583
23583
|
}
|
|
23584
23584
|
};
|
|
@@ -23597,8 +23597,8 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23597
23597
|
link.pushNode(linkContent);
|
|
23598
23598
|
this.particleMesh.setPoint(point, pointIndex);
|
|
23599
23599
|
this.clearPointTrail(pointIndex);
|
|
23600
|
-
if (this.
|
|
23601
|
-
this.trailMesh.setPointStartPos(pointIndex, this.parentTransform.position.clone());
|
|
23600
|
+
if (this.trailMesh) {
|
|
23601
|
+
this.trailMesh.setPointStartPos(pointIndex, this.transform.parentTransform.position.clone());
|
|
23602
23602
|
}
|
|
23603
23603
|
};
|
|
23604
23604
|
ParticleSystem.prototype.setVisible = function (visible) {
|
|
@@ -23636,7 +23636,8 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23636
23636
|
}
|
|
23637
23637
|
};
|
|
23638
23638
|
ParticleSystem.prototype.setParentTransform = function (transform) {
|
|
23639
|
-
this.parentTransform = transform;
|
|
23639
|
+
// this.transform.parentTransform = transform;
|
|
23640
|
+
// this.parentTransform = transform;
|
|
23640
23641
|
};
|
|
23641
23642
|
ParticleSystem.prototype.getTextures = function () {
|
|
23642
23643
|
var e_1, _a, e_2, _b;
|
|
@@ -23929,8 +23930,8 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
23929
23930
|
if (trails.sizeAffectsLifetime) {
|
|
23930
23931
|
lifetime *= size[0];
|
|
23931
23932
|
}
|
|
23932
|
-
if (trails.parentAffectsPosition && this.parentTransform) {
|
|
23933
|
-
position.add(this.parentTransform.position);
|
|
23933
|
+
if (trails.parentAffectsPosition && this.transform.parentTransform) {
|
|
23934
|
+
position.add(this.transform.parentTransform.position);
|
|
23934
23935
|
var pos = this.trailMesh.getPointStartPos(pointIndex);
|
|
23935
23936
|
if (pos) {
|
|
23936
23937
|
position.subtract(pos);
|
|
@@ -24170,12 +24171,11 @@ var ParticleVFXItem = /** @class */ (function (_super) {
|
|
|
24170
24171
|
ParticleVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
|
|
24171
24172
|
var _a;
|
|
24172
24173
|
if (this.content) {
|
|
24173
|
-
var hide = !this.
|
|
24174
|
+
var hide = !this.visible;
|
|
24174
24175
|
var parentItem = this.parentId && ((_a = this.composition) === null || _a === void 0 ? void 0 : _a.getItemByID(this.parentId));
|
|
24175
24176
|
if (!hide && parentItem) {
|
|
24176
24177
|
var parentData = parentItem.getRenderData();
|
|
24177
24178
|
if (parentData) {
|
|
24178
|
-
this.content.setParentTransform(parentData.transform);
|
|
24179
24179
|
if (!parentData.visible) {
|
|
24180
24180
|
hide = false;
|
|
24181
24181
|
}
|
|
@@ -29178,7 +29178,6 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29178
29178
|
}
|
|
29179
29179
|
var cachedTextures = textureOptions.map(function (option) { return option && (option instanceof Texture ? option : Texture.create(engine, option)); });
|
|
29180
29180
|
// 缓存创建的Texture对象
|
|
29181
|
-
// @ts-expect-error
|
|
29182
29181
|
scene.textureOptions = cachedTextures;
|
|
29183
29182
|
cachedTextures === null || cachedTextures === void 0 ? void 0 : cachedTextures.forEach(function (tex) { return tex === null || tex === void 0 ? void 0 : tex.initialize(); });
|
|
29184
29183
|
try {
|
|
@@ -29408,24 +29407,24 @@ var AssetManager = /** @class */ (function () {
|
|
|
29408
29407
|
this.timeout = timeout;
|
|
29409
29408
|
};
|
|
29410
29409
|
/**
|
|
29411
|
-
*
|
|
29412
|
-
* 通过 json 创建出场景对象,并进行提前编译等工作
|
|
29410
|
+
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
29413
29411
|
* @param url - json 的 URL 链接或者 json 对象
|
|
29414
29412
|
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
29415
29413
|
* @param options - 扩展参数
|
|
29416
29414
|
* @returns
|
|
29417
29415
|
*/
|
|
29418
29416
|
AssetManager.prototype.loadScene = function (url, renderer, options) {
|
|
29419
|
-
var _a, _b;
|
|
29417
|
+
var _a, _b, _c;
|
|
29420
29418
|
return __awaiter(this, void 0, void 0, function () {
|
|
29421
|
-
var rawJSON, timeLabel, startTime, timeInfos, gpuInstance, asyncShaderCompile, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
29419
|
+
var rawJSON, timeLabel, startTime, timeInfos, gpuInstance, asyncShaderCompile, compressedTexture, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
29422
29420
|
var _this = this;
|
|
29423
|
-
return __generator(this, function (
|
|
29421
|
+
return __generator(this, function (_d) {
|
|
29424
29422
|
timeLabel = "Load asset: ".concat(isString(url) ? url : this.id);
|
|
29425
29423
|
startTime = performance.now();
|
|
29426
29424
|
timeInfos = [];
|
|
29427
29425
|
gpuInstance = renderer === null || renderer === void 0 ? void 0 : renderer.engine.gpuCapability;
|
|
29428
29426
|
asyncShaderCompile = (_b = (_a = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail) === null || _a === void 0 ? void 0 : _a.asyncShaderCompile) !== null && _b !== void 0 ? _b : false;
|
|
29427
|
+
compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
|
|
29429
29428
|
cancelLoading = false;
|
|
29430
29429
|
waitPromise = new Promise(function (resolve, reject) {
|
|
29431
29430
|
return loadTimer = window.setTimeout(function () {
|
|
@@ -29450,10 +29449,10 @@ var AssetManager = /** @class */ (function () {
|
|
|
29450
29449
|
});
|
|
29451
29450
|
}); };
|
|
29452
29451
|
loadResourcePromise = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
29453
|
-
var
|
|
29452
|
+
var scene, rawImages, images_1, i, _a, i, _b, usedImages_1, jsonScene_1, pluginSystem_1, _c, bins_1, images_2, compositions_1, fonts_1, _d, loadedBins_1, loadedImages_1, loadedTextures, totalTime;
|
|
29454
29453
|
var _this = this;
|
|
29455
|
-
return __generator(this, function (
|
|
29456
|
-
switch (
|
|
29454
|
+
return __generator(this, function (_e) {
|
|
29455
|
+
switch (_e.label) {
|
|
29457
29456
|
case 0:
|
|
29458
29457
|
if (!isObject(url)) return [3 /*break*/, 1];
|
|
29459
29458
|
// TODO: 原 JSONLoader contructor 判断是否兼容
|
|
@@ -29466,42 +29465,66 @@ var AssetManager = /** @class */ (function () {
|
|
|
29466
29465
|
this.baseUrl = url;
|
|
29467
29466
|
return [4 /*yield*/, hookTimeInfo('loadJSON', function () { return _this.loadJSON(url); })];
|
|
29468
29467
|
case 2:
|
|
29469
|
-
rawJSON =
|
|
29470
|
-
|
|
29471
|
-
case 3:
|
|
29468
|
+
rawJSON = _e.sent();
|
|
29469
|
+
_e.label = 3;
|
|
29470
|
+
case 3:
|
|
29471
|
+
if (!isScene(rawJSON)) return [3 /*break*/, 6];
|
|
29472
|
+
// 已经加载过的 可能需要更新数据模板
|
|
29473
|
+
scene = __assign$1({}, rawJSON);
|
|
29474
|
+
if (!(this.options && this.options.variables && Object.keys(this.options.variables).length !== 0)) return [3 /*break*/, 5];
|
|
29475
|
+
rawImages = rawJSON.jsonScene.images;
|
|
29476
|
+
images_1 = scene.images;
|
|
29477
|
+
for (i = 0; i < rawImages.length; i++) {
|
|
29478
|
+
// 仅重新加载数据模板对应的图片
|
|
29479
|
+
if (images_1[i] instanceof HTMLCanvasElement) {
|
|
29480
|
+
images_1[i] = rawImages[i];
|
|
29481
|
+
}
|
|
29482
|
+
}
|
|
29483
|
+
_a = scene;
|
|
29484
|
+
return [4 /*yield*/, hookTimeInfo('processImages', function () { return _this.processImages(images_1, scene.usedImages, compressedTexture); })];
|
|
29472
29485
|
case 4:
|
|
29473
|
-
_a =
|
|
29474
|
-
|
|
29486
|
+
_a.images = _e.sent();
|
|
29487
|
+
// 更新 TextureOptions 中的 image 指向
|
|
29488
|
+
for (i = 0; i < scene.images.length; i++) {
|
|
29489
|
+
scene.textureOptions[i].image = scene.images[i];
|
|
29490
|
+
}
|
|
29491
|
+
_e.label = 5;
|
|
29492
|
+
case 5: return [3 /*break*/, 12];
|
|
29493
|
+
case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
|
|
29494
|
+
case 7:
|
|
29495
|
+
_b = _e.sent(), usedImages_1 = _b.usedImages, jsonScene_1 = _b.jsonScene, pluginSystem_1 = _b.pluginSystem;
|
|
29496
|
+
_c = jsonScene_1.bins, bins_1 = _c === void 0 ? [] : _c, images_2 = jsonScene_1.images, compositions_1 = jsonScene_1.compositions, fonts_1 = jsonScene_1.fonts;
|
|
29475
29497
|
return [4 /*yield*/, Promise.all([
|
|
29476
|
-
hookTimeInfo('processBins', function () { return _this.processBins(
|
|
29477
|
-
hookTimeInfo('processImages', function () {
|
|
29478
|
-
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(
|
|
29498
|
+
hookTimeInfo('processBins', function () { return _this.processBins(bins_1); }),
|
|
29499
|
+
hookTimeInfo('processImages', function () { return _this.processImages(images_2, usedImages_1, compressedTexture); }),
|
|
29500
|
+
hookTimeInfo("".concat(asyncShaderCompile ? 'async' : 'sync', " compile"), function () { return _this.precompile(compositions_1, pluginSystem_1, renderer, options); }),
|
|
29479
29501
|
])];
|
|
29480
|
-
case
|
|
29481
|
-
|
|
29482
|
-
return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(
|
|
29483
|
-
case
|
|
29484
|
-
|
|
29485
|
-
return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(
|
|
29486
|
-
case
|
|
29487
|
-
loadedTextures =
|
|
29502
|
+
case 8:
|
|
29503
|
+
_d = __read$3.apply(void 0, [_e.sent(), 2]), loadedBins_1 = _d[0], loadedImages_1 = _d[1];
|
|
29504
|
+
return [4 /*yield*/, hookTimeInfo('processFontURL', function () { return _this.processFontURL(fonts_1); })];
|
|
29505
|
+
case 9:
|
|
29506
|
+
_e.sent();
|
|
29507
|
+
return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
|
|
29508
|
+
case 10:
|
|
29509
|
+
loadedTextures = _e.sent();
|
|
29488
29510
|
scene = {
|
|
29489
|
-
jsonScene: jsonScene,
|
|
29490
|
-
images: loadedImages,
|
|
29491
|
-
textureOptions: loadedTextures,
|
|
29492
|
-
bins: loadedBins,
|
|
29493
|
-
storage: {},
|
|
29494
|
-
pluginSystem: this.pluginSystem,
|
|
29495
|
-
renderLevel: this.options.renderLevel,
|
|
29496
|
-
totalTime: 0,
|
|
29497
|
-
startTime: 0,
|
|
29498
29511
|
url: url,
|
|
29512
|
+
renderLevel: this.options.renderLevel,
|
|
29513
|
+
storage: {},
|
|
29514
|
+
pluginSystem: pluginSystem_1,
|
|
29515
|
+
jsonScene: jsonScene_1,
|
|
29516
|
+
usedImages: usedImages_1,
|
|
29517
|
+
images: loadedImages_1,
|
|
29518
|
+
textureOptions: loadedTextures,
|
|
29519
|
+
bins: loadedBins_1,
|
|
29499
29520
|
};
|
|
29500
29521
|
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
29501
|
-
return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return
|
|
29502
|
-
case
|
|
29522
|
+
return [4 /*yield*/, hookTimeInfo('processPlugins', function () { return pluginSystem_1.loadResources(scene, _this.options); })];
|
|
29523
|
+
case 11:
|
|
29503
29524
|
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
29504
|
-
|
|
29525
|
+
_e.sent();
|
|
29526
|
+
_e.label = 12;
|
|
29527
|
+
case 12:
|
|
29505
29528
|
totalTime = performance.now() - startTime;
|
|
29506
29529
|
console.info({
|
|
29507
29530
|
content: "".concat(timeLabel, ": ").concat(totalTime.toFixed(4), "ms, ").concat(timeInfos.join(' ')),
|
|
@@ -29518,7 +29541,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29518
29541
|
});
|
|
29519
29542
|
});
|
|
29520
29543
|
};
|
|
29521
|
-
AssetManager.prototype.precompile = function (compositions, renderer, options) {
|
|
29544
|
+
AssetManager.prototype.precompile = function (compositions, pluginSystem, renderer, options) {
|
|
29522
29545
|
return __awaiter(this, void 0, void 0, function () {
|
|
29523
29546
|
var shaderLibrary;
|
|
29524
29547
|
return __generator(this, function (_a) {
|
|
@@ -29528,7 +29551,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29528
29551
|
return [2 /*return*/];
|
|
29529
29552
|
}
|
|
29530
29553
|
shaderLibrary = renderer === null || renderer === void 0 ? void 0 : renderer.getShaderLibrary();
|
|
29531
|
-
return [4 /*yield*/,
|
|
29554
|
+
return [4 /*yield*/, (pluginSystem === null || pluginSystem === void 0 ? void 0 : pluginSystem.precompile(compositions, renderer, options))];
|
|
29532
29555
|
case 1:
|
|
29533
29556
|
_a.sent();
|
|
29534
29557
|
return [4 /*yield*/, new Promise(function (resolve) {
|
|
@@ -29545,7 +29568,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29545
29568
|
};
|
|
29546
29569
|
AssetManager.prototype.processJSON = function (json) {
|
|
29547
29570
|
return __awaiter(this, void 0, void 0, function () {
|
|
29548
|
-
var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, renderLevel, usedImages;
|
|
29571
|
+
var jsonScene, _a, plugins, sceneCompositions, imgUsage, images, pluginSystem, renderLevel, usedImages;
|
|
29549
29572
|
return __generator(this, function (_b) {
|
|
29550
29573
|
switch (_b.label) {
|
|
29551
29574
|
case 0:
|
|
@@ -29559,8 +29582,8 @@ var AssetManager = /** @class */ (function () {
|
|
|
29559
29582
|
}
|
|
29560
29583
|
});
|
|
29561
29584
|
_a = jsonScene.plugins, plugins = _a === void 0 ? [] : _a, sceneCompositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, images = jsonScene.images;
|
|
29562
|
-
|
|
29563
|
-
return [4 /*yield*/,
|
|
29585
|
+
pluginSystem = new PluginSystem(plugins);
|
|
29586
|
+
return [4 /*yield*/, pluginSystem.processRawJSON(jsonScene, this.options)];
|
|
29564
29587
|
case 1:
|
|
29565
29588
|
_b.sent();
|
|
29566
29589
|
renderLevel = this.options.renderLevel;
|
|
@@ -29577,6 +29600,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29577
29600
|
return [2 /*return*/, {
|
|
29578
29601
|
usedImages: usedImages,
|
|
29579
29602
|
jsonScene: jsonScene,
|
|
29603
|
+
pluginSystem: pluginSystem,
|
|
29580
29604
|
}];
|
|
29581
29605
|
}
|
|
29582
29606
|
});
|
|
@@ -29960,7 +29984,8 @@ var CompVFXItem = /** @class */ (function (_super) {
|
|
|
29960
29984
|
}
|
|
29961
29985
|
else {
|
|
29962
29986
|
item = createVFXItem(this.itemProps[i], this.composition);
|
|
29963
|
-
|
|
29987
|
+
// 相机不跟随合成移动
|
|
29988
|
+
item.transform.parentTransform = VFXItem.isCamera(item) ? new Transform() : this.transform;
|
|
29964
29989
|
}
|
|
29965
29990
|
if (VFXItem.isExtraCamera(item)) {
|
|
29966
29991
|
this.extraCamera = item;
|
|
@@ -30146,7 +30171,7 @@ var CompVFXItem = /** @class */ (function (_super) {
|
|
|
30146
30171
|
if (!parentItem) {
|
|
30147
30172
|
itemNode.parentId = undefined;
|
|
30148
30173
|
item.parent = undefined;
|
|
30149
|
-
item.transform.parentTransform = this.transform;
|
|
30174
|
+
item.transform.parentTransform = VFXItem.isExtraCamera(item) ? new Transform() : this.transform;
|
|
30150
30175
|
}
|
|
30151
30176
|
else {
|
|
30152
30177
|
var parentNode = this.itemCacheMap.get(parentItem.id);
|
|
@@ -32761,9 +32786,9 @@ Geometry.create = function (engine, options) {
|
|
|
32761
32786
|
Mesh.create = function (engine, props) {
|
|
32762
32787
|
return new ThreeMesh(engine, props);
|
|
32763
32788
|
};
|
|
32764
|
-
var version = "1.1.
|
|
32789
|
+
var version = "1.1.4";
|
|
32765
32790
|
console.info({
|
|
32766
|
-
content: '[Galacean Effects THREEJS] version: ' + "1.1.
|
|
32791
|
+
content: '[Galacean Effects THREEJS] version: ' + "1.1.4",
|
|
32767
32792
|
type: LOG_TYPE,
|
|
32768
32793
|
});
|
|
32769
32794
|
|