@galacean/effects-core 2.8.0-alpha.3 → 2.8.0-alpha.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 +1 -1
- package/dist/index.js +311 -191
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +311 -191
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-system.d.ts +4 -4
- package/dist/plugins/cal/calculate-loader.d.ts +2 -2
- package/dist/plugins/camera/camera-vfx-item-loader.d.ts +2 -2
- package/dist/plugins/interact/interact-loader.d.ts +2 -2
- package/dist/plugins/particle/particle-loader.d.ts +2 -2
- package/dist/plugins/particle/particle-system.d.ts +2 -1
- package/dist/plugins/plugin.d.ts +24 -19
- package/dist/plugins/sprite/sprite-item.d.ts +0 -1
- package/dist/plugins/sprite/sprite-loader.d.ts +2 -2
- package/dist/plugins/text/text-item.d.ts +21 -1
- package/dist/plugins/text/text-loader.d.ts +2 -2
- package/package.json +1 -1
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: v2.8.0-alpha.
|
|
6
|
+
* Version: v2.8.0-alpha.4
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -2883,7 +2883,6 @@ var plugins = [];
|
|
|
2883
2883
|
pluginLoaderMap[name] = pluginClass;
|
|
2884
2884
|
var pluginInstance = new pluginClass();
|
|
2885
2885
|
pluginInstance.name = name;
|
|
2886
|
-
pluginInstance.initialize();
|
|
2887
2886
|
plugins.push(pluginInstance);
|
|
2888
2887
|
plugins.sort(function(a, b) {
|
|
2889
2888
|
return a.order - b.order;
|
|
@@ -2907,29 +2906,29 @@ var PluginSystem = /*#__PURE__*/ function() {
|
|
|
2907
2906
|
};
|
|
2908
2907
|
PluginSystem.initializeComposition = function initializeComposition(composition, scene) {
|
|
2909
2908
|
plugins.forEach(function(loader) {
|
|
2910
|
-
return loader.
|
|
2909
|
+
return loader.onCompositionCreated(composition, scene);
|
|
2911
2910
|
});
|
|
2912
2911
|
};
|
|
2913
2912
|
PluginSystem.destroyComposition = function destroyComposition(comp) {
|
|
2914
2913
|
plugins.forEach(function(loader) {
|
|
2915
|
-
return loader.
|
|
2914
|
+
return loader.onCompositionDestroy(comp);
|
|
2916
2915
|
});
|
|
2917
2916
|
};
|
|
2918
|
-
PluginSystem.
|
|
2917
|
+
PluginSystem.onAssetsLoadStart = function onAssetsLoadStart(scene, options) {
|
|
2919
2918
|
return _async_to_generator(function() {
|
|
2920
2919
|
return __generator(this, function(_state) {
|
|
2921
2920
|
return [
|
|
2922
2921
|
2,
|
|
2923
2922
|
Promise.all(plugins.map(function(plugin) {
|
|
2924
|
-
return plugin.
|
|
2923
|
+
return plugin.onAssetsLoadStart(scene, options);
|
|
2925
2924
|
}))
|
|
2926
2925
|
];
|
|
2927
2926
|
});
|
|
2928
2927
|
})();
|
|
2929
2928
|
};
|
|
2930
|
-
PluginSystem.
|
|
2929
|
+
PluginSystem.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {
|
|
2931
2930
|
plugins.forEach(function(loader) {
|
|
2932
|
-
return loader.
|
|
2931
|
+
return loader.onAssetsLoadFinish(scene, options, engine);
|
|
2933
2932
|
});
|
|
2934
2933
|
};
|
|
2935
2934
|
return PluginSystem;
|
|
@@ -2959,20 +2958,18 @@ function getPluginUsageInfo(name) {
|
|
|
2959
2958
|
/**
|
|
2960
2959
|
* 抽象插件类
|
|
2961
2960
|
* 注册合成不同生命周期的回调函数
|
|
2962
|
-
*/ var
|
|
2963
|
-
function
|
|
2961
|
+
*/ var Plugin = /*#__PURE__*/ function() {
|
|
2962
|
+
function Plugin() {
|
|
2964
2963
|
this.order = 100;
|
|
2965
|
-
this.name = "";
|
|
2964
|
+
this.name = "Plugin";
|
|
2966
2965
|
}
|
|
2967
|
-
var _proto =
|
|
2968
|
-
_proto.initialize = function initialize() {};
|
|
2966
|
+
var _proto = Plugin.prototype;
|
|
2969
2967
|
/**
|
|
2970
|
-
*
|
|
2971
|
-
*
|
|
2972
|
-
* @param scene
|
|
2973
|
-
* @param options
|
|
2974
|
-
|
|
2975
|
-
*/ _proto.processAssets = function processAssets(scene, options) {
|
|
2968
|
+
* 场景加载时触发,用于加载插件所需的自定义资源。
|
|
2969
|
+
* 此阶段适合发起异步资源请求。
|
|
2970
|
+
* @param scene - 场景对象
|
|
2971
|
+
* @param options - 场景加载选项
|
|
2972
|
+
*/ _proto.onAssetsLoadStart = function onAssetsLoadStart(scene, options) {
|
|
2976
2973
|
return _async_to_generator(function() {
|
|
2977
2974
|
return __generator(this, function(_state) {
|
|
2978
2975
|
return [
|
|
@@ -2982,17 +2979,22 @@ function getPluginUsageInfo(name) {
|
|
|
2982
2979
|
})();
|
|
2983
2980
|
};
|
|
2984
2981
|
/**
|
|
2985
|
-
*
|
|
2986
|
-
*
|
|
2987
|
-
*
|
|
2988
|
-
*
|
|
2989
|
-
*
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2982
|
+
* 场景资源加载完成后触发。
|
|
2983
|
+
* 此时 JSON 中的图片和二进制已加载完成,可对资源做进一步处理。
|
|
2984
|
+
* @param scene - 场景对象
|
|
2985
|
+
* @param options - 场景加载选项
|
|
2986
|
+
* @param engine - 引擎实例
|
|
2987
|
+
*/ _proto.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {};
|
|
2988
|
+
/**
|
|
2989
|
+
* 合成创建完成后触发。
|
|
2990
|
+
* @param composition - 合成对象
|
|
2991
|
+
* @param scene - 场景对象
|
|
2992
|
+
*/ _proto.onCompositionCreated = function onCompositionCreated(composition, scene) {};
|
|
2993
|
+
/**
|
|
2994
|
+
* 合成销毁时触发。
|
|
2995
|
+
* @param composition - 合成对象
|
|
2996
|
+
*/ _proto.onCompositionDestroy = function onCompositionDestroy(composition) {};
|
|
2997
|
+
return Plugin;
|
|
2996
2998
|
}();
|
|
2997
2999
|
|
|
2998
3000
|
function _set_prototype_of(o, p) {
|
|
@@ -10652,6 +10654,9 @@ var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
10652
10654
|
stencilAction: exports.TextureLoadAction.clear
|
|
10653
10655
|
});
|
|
10654
10656
|
}
|
|
10657
|
+
this.meshes.sort(function(a, b) {
|
|
10658
|
+
return a.priority - b.priority;
|
|
10659
|
+
});
|
|
10655
10660
|
renderer.renderMeshes(this.meshes);
|
|
10656
10661
|
};
|
|
10657
10662
|
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
@@ -16589,13 +16594,49 @@ exports.CameraController = __decorate([
|
|
|
16589
16594
|
effectsClass(DataType.CameraController)
|
|
16590
16595
|
], exports.CameraController);
|
|
16591
16596
|
|
|
16592
|
-
|
|
16593
|
-
|
|
16597
|
+
function _get_prototype_of(o) {
|
|
16598
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
16599
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
16600
|
+
};
|
|
16601
|
+
return _get_prototype_of(o);
|
|
16602
|
+
}
|
|
16603
|
+
|
|
16604
|
+
function _is_native_function(fn) {
|
|
16605
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
16606
|
+
}
|
|
16607
|
+
|
|
16608
|
+
function _wrap_native_super(Class) {
|
|
16609
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
16610
|
+
_wrap_native_super = function _wrap_native_super(Class) {
|
|
16611
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
16612
|
+
if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
|
|
16613
|
+
if (typeof _cache !== "undefined") {
|
|
16614
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
16615
|
+
_cache.set(Class, Wrapper);
|
|
16616
|
+
}
|
|
16617
|
+
function Wrapper() {
|
|
16618
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
16619
|
+
}
|
|
16620
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
16621
|
+
constructor: {
|
|
16622
|
+
value: Wrapper,
|
|
16623
|
+
enumerable: false,
|
|
16624
|
+
writable: true,
|
|
16625
|
+
configurable: true
|
|
16626
|
+
}
|
|
16627
|
+
});
|
|
16628
|
+
return _set_prototype_of(Wrapper, Class);
|
|
16629
|
+
};
|
|
16630
|
+
return _wrap_native_super(Class);
|
|
16631
|
+
}
|
|
16632
|
+
|
|
16633
|
+
var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
|
|
16634
|
+
_inherits(CameraVFXItemLoader, Plugin);
|
|
16594
16635
|
function CameraVFXItemLoader() {
|
|
16595
|
-
return
|
|
16636
|
+
return Plugin.apply(this, arguments);
|
|
16596
16637
|
}
|
|
16597
16638
|
return CameraVFXItemLoader;
|
|
16598
|
-
}(
|
|
16639
|
+
}(_wrap_native_super(Plugin));
|
|
16599
16640
|
|
|
16600
16641
|
exports.HitTestType = void 0;
|
|
16601
16642
|
(function(HitTestType) {
|
|
@@ -16879,13 +16920,13 @@ function getCoord(event) {
|
|
|
16879
16920
|
};
|
|
16880
16921
|
}
|
|
16881
16922
|
|
|
16882
|
-
var InteractLoader = /*#__PURE__*/ function(
|
|
16883
|
-
_inherits(InteractLoader,
|
|
16923
|
+
var InteractLoader = /*#__PURE__*/ function(Plugin) {
|
|
16924
|
+
_inherits(InteractLoader, Plugin);
|
|
16884
16925
|
function InteractLoader() {
|
|
16885
|
-
return
|
|
16926
|
+
return Plugin.apply(this, arguments);
|
|
16886
16927
|
}
|
|
16887
16928
|
return InteractLoader;
|
|
16888
|
-
}(
|
|
16929
|
+
}(_wrap_native_super(Plugin));
|
|
16889
16930
|
|
|
16890
16931
|
var vertex = "\nprecision highp float;\n\nattribute vec2 aPoint;\nuniform vec4 uPos;\nuniform vec2 uSize;\nuniform vec4 uQuat;\nuniform vec4 uColor;\nuniform mat4 effects_ObjectToWorld;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_MatrixVP;\nvarying vec4 vColor;\n\nvec3 rotateByQuat(vec3 a, vec4 quat){\n vec3 qvec = quat.xyz;\n vec3 uv = cross(qvec, a);\n vec3 uuv = cross(qvec, uv) * 2.;\n return a +(uv * 2. * quat.w + uuv);\n}\n\nvoid main() {\n vec4 _pos = uPos;\n vec3 point = rotateByQuat(vec3(aPoint.xy * uSize, 0.),uQuat);\n vec4 pos = vec4(_pos.xyz, 1.0);\n pos = effects_ObjectToWorld * pos;\n pos.xyz += effects_MatrixInvV[0].xyz * point.x+ effects_MatrixInvV[1].xyz * point.y;\n gl_Position = effects_MatrixVP * pos;\n vColor = uColor;\n}\n";
|
|
16891
16932
|
var fragment = "\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor*vColor.a;\n}\n";
|
|
@@ -17484,16 +17525,16 @@ function shouldIgnoreBouncing(arg, mul) {
|
|
|
17484
17525
|
return MeshCollider;
|
|
17485
17526
|
}();
|
|
17486
17527
|
|
|
17487
|
-
var SpriteLoader = /*#__PURE__*/ function(
|
|
17488
|
-
_inherits(SpriteLoader,
|
|
17528
|
+
var SpriteLoader = /*#__PURE__*/ function(Plugin) {
|
|
17529
|
+
_inherits(SpriteLoader, Plugin);
|
|
17489
17530
|
function SpriteLoader() {
|
|
17490
17531
|
var _this;
|
|
17491
|
-
_this =
|
|
17532
|
+
_this = Plugin.apply(this, arguments) || this;
|
|
17492
17533
|
_this.name = "sprite";
|
|
17493
17534
|
return _this;
|
|
17494
17535
|
}
|
|
17495
17536
|
return SpriteLoader;
|
|
17496
|
-
}(
|
|
17537
|
+
}(_wrap_native_super(Plugin));
|
|
17497
17538
|
|
|
17498
17539
|
/**
|
|
17499
17540
|
* 动画图可播放节点对象
|
|
@@ -19984,7 +20025,7 @@ function calculateDirection(prePoint, point, nextPoint) {
|
|
|
19984
20025
|
if (this.time >= 0 && this.time < particleSystem.item.duration && particleSystem.isEnded()) {
|
|
19985
20026
|
particleSystem.reset();
|
|
19986
20027
|
}
|
|
19987
|
-
particleSystem.
|
|
20028
|
+
particleSystem.simulate(this.time - particleSystem.time);
|
|
19988
20029
|
}
|
|
19989
20030
|
this.lastTime = this.time;
|
|
19990
20031
|
};
|
|
@@ -21435,126 +21476,133 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
21435
21476
|
this.initEmitterTransform();
|
|
21436
21477
|
};
|
|
21437
21478
|
_proto.onUpdate = function onUpdate(dt) {
|
|
21438
|
-
this.
|
|
21479
|
+
if (!this.frozen) {
|
|
21480
|
+
this.update(dt);
|
|
21481
|
+
}
|
|
21482
|
+
};
|
|
21483
|
+
_proto.simulate = function simulate(time) {
|
|
21484
|
+
this.update(time * 1000);
|
|
21485
|
+
this.frozen = true;
|
|
21439
21486
|
};
|
|
21440
21487
|
_proto.update = function update(delta) {
|
|
21441
21488
|
var _this = this;
|
|
21442
|
-
if (this.started
|
|
21443
|
-
|
|
21444
|
-
|
|
21445
|
-
|
|
21446
|
-
|
|
21447
|
-
|
|
21448
|
-
|
|
21449
|
-
|
|
21450
|
-
|
|
21451
|
-
|
|
21452
|
-
|
|
21453
|
-
|
|
21454
|
-
|
|
21455
|
-
|
|
21456
|
-
|
|
21457
|
-
|
|
21458
|
-
|
|
21459
|
-
|
|
21460
|
-
|
|
21461
|
-
|
|
21462
|
-
|
|
21463
|
-
|
|
21464
|
-
|
|
21489
|
+
if (!this.started) {
|
|
21490
|
+
return;
|
|
21491
|
+
}
|
|
21492
|
+
var now = this.time + delta / 1000;
|
|
21493
|
+
var options = this.options;
|
|
21494
|
+
var loopStartTime = this.loopStartTime;
|
|
21495
|
+
var emission = this.emission;
|
|
21496
|
+
this.time = now;
|
|
21497
|
+
this.upDirectionWorld = null;
|
|
21498
|
+
this.renderer.updateTime(now, delta);
|
|
21499
|
+
var link = this.particleLink;
|
|
21500
|
+
var emitterLifetime = (now - loopStartTime) / this.item.duration;
|
|
21501
|
+
var timePassed = this.timePassed;
|
|
21502
|
+
var trailUpdated = false;
|
|
21503
|
+
var updateTrail = function() {
|
|
21504
|
+
if (_this.trails && !trailUpdated) {
|
|
21505
|
+
trailUpdated = true;
|
|
21506
|
+
link.forEach(function(param) {
|
|
21507
|
+
var time = param[0], pointIndex = param[1], delay = param[2], point = param[3];
|
|
21508
|
+
if (time < timePassed) {
|
|
21509
|
+
_this.clearPointTrail(pointIndex);
|
|
21510
|
+
} else if (timePassed > delay) {
|
|
21511
|
+
_this.updatePointTrail(pointIndex, emitterLifetime, point, delay);
|
|
21512
|
+
}
|
|
21513
|
+
});
|
|
21514
|
+
}
|
|
21515
|
+
};
|
|
21516
|
+
if (!this.ended) {
|
|
21517
|
+
var duration = this.item.duration;
|
|
21518
|
+
var lifetime = this.lifetime;
|
|
21519
|
+
if (timePassed < duration) {
|
|
21520
|
+
var interval = 1 / emission.rateOverTime.getValue(lifetime);
|
|
21521
|
+
var pointCount = Math.floor((timePassed - this.lastEmitTime) / interval);
|
|
21522
|
+
var maxEmissionCount = pointCount;
|
|
21523
|
+
var timeDelta = interval / pointCount;
|
|
21524
|
+
var meshTime = now;
|
|
21525
|
+
var maxCount = options.maxCount;
|
|
21526
|
+
this.updateEmitterTransform(timePassed);
|
|
21527
|
+
var shouldSkipGenerate = function() {
|
|
21528
|
+
var first = link.first;
|
|
21529
|
+
return _this.emissionStopped || link.length === maxCount && first && first.content[0] - loopStartTime > timePassed;
|
|
21530
|
+
};
|
|
21531
|
+
for(var i = 0; i < maxEmissionCount && i < maxCount; i++){
|
|
21532
|
+
if (shouldSkipGenerate()) {
|
|
21533
|
+
break;
|
|
21534
|
+
}
|
|
21535
|
+
var p = this.createPoint(lifetime);
|
|
21536
|
+
p.delay += meshTime + i * timeDelta;
|
|
21537
|
+
this.addParticle(p, maxCount);
|
|
21538
|
+
this.lastEmitTime = timePassed;
|
|
21465
21539
|
}
|
|
21466
|
-
|
|
21467
|
-
|
|
21468
|
-
|
|
21469
|
-
|
|
21470
|
-
if (timePassed < duration) {
|
|
21471
|
-
var interval = 1 / emission.rateOverTime.getValue(lifetime);
|
|
21472
|
-
var pointCount = Math.floor((timePassed - this.lastEmitTime) / interval);
|
|
21473
|
-
var maxEmissionCount = pointCount;
|
|
21474
|
-
var timeDelta = interval / pointCount;
|
|
21475
|
-
var meshTime = now;
|
|
21476
|
-
var maxCount = options.maxCount;
|
|
21477
|
-
this.updateEmitterTransform(timePassed);
|
|
21478
|
-
var shouldSkipGenerate = function() {
|
|
21479
|
-
var first = link.first;
|
|
21480
|
-
return _this.emissionStopped || link.length === maxCount && first && first.content[0] - loopStartTime > timePassed;
|
|
21481
|
-
};
|
|
21482
|
-
for(var i = 0; i < maxEmissionCount && i < maxCount; i++){
|
|
21483
|
-
if (shouldSkipGenerate()) {
|
|
21484
|
-
break;
|
|
21485
|
-
}
|
|
21486
|
-
var p = this.createPoint(lifetime);
|
|
21487
|
-
p.delay += meshTime + i * timeDelta;
|
|
21488
|
-
this.addParticle(p, maxCount);
|
|
21489
|
-
this.lastEmitTime = timePassed;
|
|
21540
|
+
var bursts = emission.bursts;
|
|
21541
|
+
for(var j = (bursts == null ? void 0 : bursts.length) - 1, cursor = 0; j >= 0 && cursor < maxCount; j--){
|
|
21542
|
+
if (shouldSkipGenerate()) {
|
|
21543
|
+
break;
|
|
21490
21544
|
}
|
|
21491
|
-
var
|
|
21492
|
-
|
|
21493
|
-
|
|
21494
|
-
|
|
21545
|
+
var burst = bursts[j];
|
|
21546
|
+
var opts = !burst.disabled && burst.getGeneratorOptions(timePassed, lifetime);
|
|
21547
|
+
if (opts) {
|
|
21548
|
+
var originVec = [
|
|
21549
|
+
0,
|
|
21550
|
+
0,
|
|
21551
|
+
0
|
|
21552
|
+
];
|
|
21553
|
+
var offsets = emission.burstOffsets[j];
|
|
21554
|
+
var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
|
|
21555
|
+
if (burst.once) {
|
|
21556
|
+
this.removeBurst(j);
|
|
21495
21557
|
}
|
|
21496
|
-
var
|
|
21497
|
-
|
|
21498
|
-
|
|
21499
|
-
|
|
21500
|
-
0,
|
|
21501
|
-
0,
|
|
21502
|
-
0
|
|
21503
|
-
];
|
|
21504
|
-
var offsets = emission.burstOffsets[j];
|
|
21505
|
-
var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
|
|
21506
|
-
if (burst.once) {
|
|
21507
|
-
this.removeBurst(j);
|
|
21508
|
-
}
|
|
21509
|
-
for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
|
|
21510
|
-
var _p_transform;
|
|
21511
|
-
if (shouldSkipGenerate()) {
|
|
21512
|
-
break;
|
|
21513
|
-
}
|
|
21514
|
-
var p1 = this.initPoint(this.shape.generate({
|
|
21515
|
-
total: opts.total,
|
|
21516
|
-
index: opts.index,
|
|
21517
|
-
burstIndex: i1,
|
|
21518
|
-
burstCount: opts.count
|
|
21519
|
-
}));
|
|
21520
|
-
p1.delay += meshTime;
|
|
21521
|
-
cursor++;
|
|
21522
|
-
(_p_transform = p1.transform).translate.apply(_p_transform, [].concat(burstOffset));
|
|
21523
|
-
this.addParticle(p1, maxCount);
|
|
21558
|
+
for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
|
|
21559
|
+
var _p_transform;
|
|
21560
|
+
if (shouldSkipGenerate()) {
|
|
21561
|
+
break;
|
|
21524
21562
|
}
|
|
21563
|
+
var p1 = this.initPoint(this.shape.generate({
|
|
21564
|
+
total: opts.total,
|
|
21565
|
+
index: opts.index,
|
|
21566
|
+
burstIndex: i1,
|
|
21567
|
+
burstCount: opts.count
|
|
21568
|
+
}));
|
|
21569
|
+
p1.delay += meshTime;
|
|
21570
|
+
cursor++;
|
|
21571
|
+
(_p_transform = p1.transform).translate.apply(_p_transform, [].concat(burstOffset));
|
|
21572
|
+
this.addParticle(p1, maxCount);
|
|
21525
21573
|
}
|
|
21526
21574
|
}
|
|
21527
|
-
} else if (this.item.endBehavior === EndBehavior.restart) {
|
|
21528
|
-
updateTrail();
|
|
21529
|
-
this.loopStartTime = now - duration;
|
|
21530
|
-
this.lastEmitTime -= duration;
|
|
21531
|
-
this.time -= duration;
|
|
21532
|
-
emission.bursts.forEach(function(b) {
|
|
21533
|
-
return b.reset();
|
|
21534
|
-
});
|
|
21535
|
-
this.particleLink.forEach(function(content) {
|
|
21536
|
-
content[0] -= duration;
|
|
21537
|
-
content[2] -= duration;
|
|
21538
|
-
content[3].delay -= duration;
|
|
21539
|
-
});
|
|
21540
|
-
this.renderer.minusTimeForLoop(duration);
|
|
21541
|
-
} else {
|
|
21542
|
-
this.ended = true;
|
|
21543
|
-
var endBehavior = this.item.endBehavior;
|
|
21544
|
-
if (endBehavior === EndBehavior.freeze) {
|
|
21545
|
-
this.frozen = true;
|
|
21546
|
-
}
|
|
21547
21575
|
}
|
|
21548
|
-
} else if (this.item.endBehavior
|
|
21549
|
-
|
|
21550
|
-
|
|
21551
|
-
|
|
21552
|
-
|
|
21553
|
-
|
|
21576
|
+
} else if (this.item.endBehavior === EndBehavior.restart) {
|
|
21577
|
+
updateTrail();
|
|
21578
|
+
this.loopStartTime = now - duration;
|
|
21579
|
+
this.lastEmitTime -= duration;
|
|
21580
|
+
this.time -= duration;
|
|
21581
|
+
emission.bursts.forEach(function(b) {
|
|
21582
|
+
return b.reset();
|
|
21583
|
+
});
|
|
21584
|
+
this.particleLink.forEach(function(content) {
|
|
21585
|
+
content[0] -= duration;
|
|
21586
|
+
content[2] -= duration;
|
|
21587
|
+
content[3].delay -= duration;
|
|
21588
|
+
});
|
|
21589
|
+
this.renderer.minusTimeForLoop(duration);
|
|
21590
|
+
} else {
|
|
21591
|
+
this.ended = true;
|
|
21592
|
+
var endBehavior = this.item.endBehavior;
|
|
21593
|
+
if (endBehavior === EndBehavior.freeze) {
|
|
21594
|
+
this.frozen = true;
|
|
21595
|
+
}
|
|
21596
|
+
}
|
|
21597
|
+
} else if (this.item.endBehavior !== EndBehavior.restart) {
|
|
21598
|
+
if (EndBehavior.destroy === this.item.endBehavior) {
|
|
21599
|
+
var node = link.last;
|
|
21600
|
+
if (node && node.content[0] < this.time) {
|
|
21601
|
+
this.destroyed = true;
|
|
21554
21602
|
}
|
|
21555
21603
|
}
|
|
21556
|
-
updateTrail();
|
|
21557
21604
|
}
|
|
21605
|
+
updateTrail();
|
|
21558
21606
|
};
|
|
21559
21607
|
_proto.drawStencilMask = function drawStencilMask(renderer) {
|
|
21560
21608
|
if (!this.isActiveAndEnabled) {
|
|
@@ -25594,7 +25642,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25594
25642
|
_this = MaskableGraphic.call(this, engine) || this;
|
|
25595
25643
|
_this.time = 0;
|
|
25596
25644
|
_this.duration = 1;
|
|
25597
|
-
_this.loop = true;
|
|
25598
25645
|
/**
|
|
25599
25646
|
* @internal
|
|
25600
25647
|
*/ _this.splits = singleSplits;
|
|
@@ -25609,11 +25656,15 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25609
25656
|
var _this = this;
|
|
25610
25657
|
var time = this.time;
|
|
25611
25658
|
var duration = this.duration;
|
|
25612
|
-
|
|
25659
|
+
var textureAnimation = this.textureSheetAnimation;
|
|
25660
|
+
var _textureAnimation_loop;
|
|
25661
|
+
// TODO: Update textureAnimation spec.
|
|
25662
|
+
// @ts-expect-error
|
|
25663
|
+
var loop = (_textureAnimation_loop = textureAnimation == null ? void 0 : textureAnimation.loop) != null ? _textureAnimation_loop : true;
|
|
25664
|
+
if (time > duration && loop) {
|
|
25613
25665
|
time = time % duration;
|
|
25614
25666
|
}
|
|
25615
25667
|
var life = Math.min(Math.max(time / duration, 0.0), 1.0);
|
|
25616
|
-
var ta = this.textureSheetAnimation;
|
|
25617
25668
|
var video = this.renderer.texture.source.video;
|
|
25618
25669
|
if (video) {
|
|
25619
25670
|
if (time === 0) {
|
|
@@ -25625,9 +25676,9 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25625
25676
|
}
|
|
25626
25677
|
this.renderer.texture.uploadCurrentVideoFrame();
|
|
25627
25678
|
}
|
|
25628
|
-
if (
|
|
25679
|
+
if (textureAnimation) {
|
|
25629
25680
|
var _this_material_getVector4;
|
|
25630
|
-
var total =
|
|
25681
|
+
var total = textureAnimation.total || textureAnimation.row * textureAnimation.col;
|
|
25631
25682
|
var texRectX = 0;
|
|
25632
25683
|
var texRectY = 0;
|
|
25633
25684
|
var texRectW = 1;
|
|
@@ -25648,20 +25699,20 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25648
25699
|
}
|
|
25649
25700
|
var dx, dy;
|
|
25650
25701
|
if (flip) {
|
|
25651
|
-
dx = 1 /
|
|
25652
|
-
dy = 1 /
|
|
25702
|
+
dx = 1 / textureAnimation.row * texRectW;
|
|
25703
|
+
dy = 1 / textureAnimation.col * texRectH;
|
|
25653
25704
|
} else {
|
|
25654
|
-
dx = 1 /
|
|
25655
|
-
dy = 1 /
|
|
25705
|
+
dx = 1 / textureAnimation.col * texRectW;
|
|
25706
|
+
dy = 1 / textureAnimation.row * texRectH;
|
|
25656
25707
|
}
|
|
25657
25708
|
var texOffset;
|
|
25658
|
-
if (
|
|
25709
|
+
if (textureAnimation.animate) {
|
|
25659
25710
|
var frameIndex = Math.round(life * (total - 1));
|
|
25660
|
-
var yIndex = Math.floor(frameIndex /
|
|
25661
|
-
var xIndex = frameIndex - yIndex *
|
|
25711
|
+
var yIndex = Math.floor(frameIndex / textureAnimation.col);
|
|
25712
|
+
var xIndex = frameIndex - yIndex * textureAnimation.col;
|
|
25662
25713
|
texOffset = flip ? [
|
|
25663
25714
|
dx * yIndex,
|
|
25664
|
-
dy * (
|
|
25715
|
+
dy * (textureAnimation.col - xIndex)
|
|
25665
25716
|
] : [
|
|
25666
25717
|
dx * xIndex,
|
|
25667
25718
|
dy * (1 + yIndex)
|
|
@@ -25849,8 +25900,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25849
25900
|
var _data_duration;
|
|
25850
25901
|
//@ts-expect-error
|
|
25851
25902
|
this.duration = (_data_duration = data.duration) != null ? _data_duration : this.item.duration;
|
|
25852
|
-
var _data_loop;
|
|
25853
|
-
this.loop = (_data_loop = data.loop) != null ? _data_loop : true;
|
|
25854
25903
|
};
|
|
25855
25904
|
return SpriteComponent;
|
|
25856
25905
|
}(MaskableGraphic);
|
|
@@ -25858,21 +25907,21 @@ exports.SpriteComponent = __decorate([
|
|
|
25858
25907
|
effectsClass(DataType.SpriteComponent)
|
|
25859
25908
|
], exports.SpriteComponent);
|
|
25860
25909
|
|
|
25861
|
-
var ParticleLoader = /*#__PURE__*/ function(
|
|
25862
|
-
_inherits(ParticleLoader,
|
|
25910
|
+
var ParticleLoader = /*#__PURE__*/ function(Plugin) {
|
|
25911
|
+
_inherits(ParticleLoader, Plugin);
|
|
25863
25912
|
function ParticleLoader() {
|
|
25864
|
-
return
|
|
25913
|
+
return Plugin.apply(this, arguments);
|
|
25865
25914
|
}
|
|
25866
25915
|
return ParticleLoader;
|
|
25867
|
-
}(
|
|
25916
|
+
}(_wrap_native_super(Plugin));
|
|
25868
25917
|
|
|
25869
|
-
var CalculateLoader = /*#__PURE__*/ function(
|
|
25870
|
-
_inherits(CalculateLoader,
|
|
25918
|
+
var CalculateLoader = /*#__PURE__*/ function(Plugin) {
|
|
25919
|
+
_inherits(CalculateLoader, Plugin);
|
|
25871
25920
|
function CalculateLoader() {
|
|
25872
|
-
return
|
|
25921
|
+
return Plugin.apply(this, arguments);
|
|
25873
25922
|
}
|
|
25874
25923
|
return CalculateLoader;
|
|
25875
|
-
}(
|
|
25924
|
+
}(_wrap_native_super(Plugin));
|
|
25876
25925
|
|
|
25877
25926
|
// Based on:
|
|
25878
25927
|
/**
|
|
@@ -28974,6 +29023,12 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
28974
29023
|
/**
|
|
28975
29024
|
* 每一行文本的最大宽度
|
|
28976
29025
|
*/ _this.maxLineWidth = 0;
|
|
29026
|
+
/**
|
|
29027
|
+
* 初始文本宽度,用于计算缩放比例
|
|
29028
|
+
*/ _this.baseTextWidth = 0;
|
|
29029
|
+
/**
|
|
29030
|
+
* 初始 `transform.size.x`,用于按比例更新显示宽度
|
|
29031
|
+
*/ _this.baseScaleX = 1;
|
|
28977
29032
|
_this.name = "MText" + seed$1++;
|
|
28978
29033
|
// 初始化canvas资源
|
|
28979
29034
|
_this.canvas = canvasPool.getCanvas();
|
|
@@ -28999,10 +29054,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
28999
29054
|
text: "默认文本",
|
|
29000
29055
|
fontFamily: "AlibabaSans-BoldItalic",
|
|
29001
29056
|
fontSize: 40,
|
|
29057
|
+
// 统一使用 0-1 颜色值
|
|
29002
29058
|
textColor: [
|
|
29003
|
-
|
|
29004
|
-
|
|
29005
|
-
|
|
29059
|
+
1,
|
|
29060
|
+
1,
|
|
29061
|
+
1,
|
|
29006
29062
|
1
|
|
29007
29063
|
],
|
|
29008
29064
|
fontWeight: TextWeight.normal,
|
|
@@ -29039,6 +29095,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29039
29095
|
// TextComponentBase
|
|
29040
29096
|
this.updateWithOptions(options);
|
|
29041
29097
|
this.renderText(options);
|
|
29098
|
+
// 记录初始的 textWidth 和 x 缩放,用于后续按比例更新显示宽度
|
|
29099
|
+
// 添加兜底值 1 防止除 0
|
|
29100
|
+
this.baseTextWidth = options.textWidth || this.textLayout.width || 1;
|
|
29101
|
+
this.baseScaleX = this.item.transform.size.x;
|
|
29042
29102
|
// 恢复默认颜色
|
|
29043
29103
|
this.material.setColor("_Color", new Color(1, 1, 1, 1));
|
|
29044
29104
|
};
|
|
@@ -29237,9 +29297,9 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29237
29297
|
if (style.isOutlined) {
|
|
29238
29298
|
_this.setupOutline();
|
|
29239
29299
|
}
|
|
29240
|
-
//
|
|
29300
|
+
// textColor 统一是 0-1,写入 canvas 时乘 255
|
|
29241
29301
|
var _style_textColor = style.textColor, r = _style_textColor[0], g = _style_textColor[1], b = _style_textColor[2], a = _style_textColor[3];
|
|
29242
|
-
context.fillStyle = "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
|
|
29302
|
+
context.fillStyle = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
|
|
29243
29303
|
var charsInfo = [];
|
|
29244
29304
|
var x = 0;
|
|
29245
29305
|
var y = layout.getOffsetY(style, _this.lineCount, lineHeight, fontSize);
|
|
@@ -29301,6 +29361,46 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29301
29361
|
layout.autoWidth = normalizedValue;
|
|
29302
29362
|
this.isDirty = true;
|
|
29303
29363
|
};
|
|
29364
|
+
/**
|
|
29365
|
+
* 设置文本框宽度
|
|
29366
|
+
* 手动设置宽度时会自动关闭 `autoWidth`
|
|
29367
|
+
* 同时会按比例更新 `transform.size.x`,让 UI 框宽度也跟着变化
|
|
29368
|
+
* @param value - 文本框宽度
|
|
29369
|
+
*/ _proto.setTextWidth = function setTextWidth(value) {
|
|
29370
|
+
var width = Math.max(0, Number(value) || 0);
|
|
29371
|
+
var layout = this.textLayout;
|
|
29372
|
+
// 宽度没变且已是非 autoWidth 模式,直接返回
|
|
29373
|
+
if (layout.width === width && layout.autoWidth === false) {
|
|
29374
|
+
return;
|
|
29375
|
+
}
|
|
29376
|
+
// 手动设置宽度时关闭 autoWidth
|
|
29377
|
+
layout.autoWidth = false;
|
|
29378
|
+
layout.width = width;
|
|
29379
|
+
// 按当前 overflow 模式重新计算行数和 maxLineWidth
|
|
29380
|
+
this.lineCount = this.getLineCount(this.text || "");
|
|
29381
|
+
this.isDirty = true;
|
|
29382
|
+
// 同步更新外层显示宽度(按比例缩放 transform)
|
|
29383
|
+
// 这样 UI 框的视觉宽度也会跟着文本宽度变化
|
|
29384
|
+
if (this.baseTextWidth > 0) {
|
|
29385
|
+
var scale = width / this.baseTextWidth;
|
|
29386
|
+
this.item.transform.size.x = this.baseScaleX * scale;
|
|
29387
|
+
}
|
|
29388
|
+
};
|
|
29389
|
+
/**
|
|
29390
|
+
* 设置文本框高度
|
|
29391
|
+
* @param value - 文本框高度
|
|
29392
|
+
*/ _proto.setTextHeight = function setTextHeight(value) {
|
|
29393
|
+
var height = Math.max(0, Number(value) || 0);
|
|
29394
|
+
if (height === 0) {
|
|
29395
|
+
return;
|
|
29396
|
+
}
|
|
29397
|
+
var layout = this.textLayout;
|
|
29398
|
+
if (layout.height === height) {
|
|
29399
|
+
return;
|
|
29400
|
+
}
|
|
29401
|
+
layout.height = height;
|
|
29402
|
+
this.isDirty = true;
|
|
29403
|
+
};
|
|
29304
29404
|
_proto.setFontSize = function setFontSize(value) {
|
|
29305
29405
|
if (this.textStyle.fontSize === value) {
|
|
29306
29406
|
return;
|
|
@@ -29368,13 +29468,13 @@ applyMixins(exports.TextComponent, [
|
|
|
29368
29468
|
]);
|
|
29369
29469
|
|
|
29370
29470
|
// TODO: 注册必须用
|
|
29371
|
-
var TextLoader = /*#__PURE__*/ function(
|
|
29372
|
-
_inherits(TextLoader,
|
|
29471
|
+
var TextLoader = /*#__PURE__*/ function(Plugin) {
|
|
29472
|
+
_inherits(TextLoader, Plugin);
|
|
29373
29473
|
function TextLoader() {
|
|
29374
|
-
return
|
|
29474
|
+
return Plugin.apply(this, arguments);
|
|
29375
29475
|
}
|
|
29376
29476
|
return TextLoader;
|
|
29377
|
-
}(
|
|
29477
|
+
}(_wrap_native_super(Plugin));
|
|
29378
29478
|
|
|
29379
29479
|
var Asset = /*#__PURE__*/ function(EffectsObject) {
|
|
29380
29480
|
_inherits(Asset, EffectsObject);
|
|
@@ -30431,6 +30531,10 @@ function version35Migration(json) {
|
|
|
30431
30531
|
if (component.dataType === DataType.TextComponent || component.dataType === DataType.RichTextComponent && component.options) {
|
|
30432
30532
|
ensureTextVerticalAlign(component.options);
|
|
30433
30533
|
}
|
|
30534
|
+
// 处理文本颜色从 0-255 到 0-1 的转换
|
|
30535
|
+
if (component.dataType === DataType.TextComponent) {
|
|
30536
|
+
convertTextColorTo01(component.options);
|
|
30537
|
+
}
|
|
30434
30538
|
}
|
|
30435
30539
|
}
|
|
30436
30540
|
//@ts-expect-error
|
|
@@ -30450,6 +30554,22 @@ function version35Migration(json) {
|
|
|
30450
30554
|
options.TextVerticalAlign = options.textBaseline;
|
|
30451
30555
|
}
|
|
30452
30556
|
}
|
|
30557
|
+
/**
|
|
30558
|
+
* 将文本颜色从 0-255 转换到 0-1
|
|
30559
|
+
*/ function convertTextColorTo01(options) {
|
|
30560
|
+
if (!options || !options.textColor) {
|
|
30561
|
+
return;
|
|
30562
|
+
}
|
|
30563
|
+
var textColor = options.textColor;
|
|
30564
|
+
var _textColor_;
|
|
30565
|
+
// 将 RGB 从 0-255 转换到 0-1(alpha 通道已经是 0-1,不需要转换)
|
|
30566
|
+
options.textColor = [
|
|
30567
|
+
textColor[0] / 255.0,
|
|
30568
|
+
textColor[1] / 255.0,
|
|
30569
|
+
textColor[2] / 255.0,
|
|
30570
|
+
(_textColor_ = textColor[3]) != null ? _textColor_ : 1
|
|
30571
|
+
];
|
|
30572
|
+
}
|
|
30453
30573
|
/**
|
|
30454
30574
|
* 根据形状获取形状几何体数据
|
|
30455
30575
|
* @param shape - 形状
|
|
@@ -31372,7 +31492,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
31372
31492
|
return ret;
|
|
31373
31493
|
}
|
|
31374
31494
|
|
|
31375
|
-
var version$1 = "2.8.0-alpha.
|
|
31495
|
+
var version$1 = "2.8.0-alpha.4";
|
|
31376
31496
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
31377
31497
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
31378
31498
|
var reverseParticle = false;
|
|
@@ -32012,8 +32132,8 @@ var seed = 1;
|
|
|
32012
32132
|
};
|
|
32013
32133
|
return [
|
|
32014
32134
|
4,
|
|
32015
|
-
hookTimeInfo("plugin:
|
|
32016
|
-
return _this.
|
|
32135
|
+
hookTimeInfo("plugin:onAssetsLoadStart", function() {
|
|
32136
|
+
return _this.onPluginSceneLoadStart(scene);
|
|
32017
32137
|
})
|
|
32018
32138
|
];
|
|
32019
32139
|
case 6:
|
|
@@ -32301,7 +32421,7 @@ var seed = 1;
|
|
|
32301
32421
|
});
|
|
32302
32422
|
})();
|
|
32303
32423
|
};
|
|
32304
|
-
_proto.
|
|
32424
|
+
_proto.onPluginSceneLoadStart = function onPluginSceneLoadStart(scene) {
|
|
32305
32425
|
var _this = this;
|
|
32306
32426
|
return _async_to_generator(function() {
|
|
32307
32427
|
return __generator(this, function(_state) {
|
|
@@ -32309,7 +32429,7 @@ var seed = 1;
|
|
|
32309
32429
|
case 0:
|
|
32310
32430
|
return [
|
|
32311
32431
|
4,
|
|
32312
|
-
PluginSystem.
|
|
32432
|
+
PluginSystem.onAssetsLoadStart(scene, _this.options)
|
|
32313
32433
|
];
|
|
32314
32434
|
case 1:
|
|
32315
32435
|
_state.sent();
|
|
@@ -35010,8 +35130,8 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35010
35130
|
case 1:
|
|
35011
35131
|
loadedScene = _state.sent();
|
|
35012
35132
|
engine.clearResources();
|
|
35013
|
-
// 触发插件系统 pluginSystem 的回调
|
|
35014
|
-
PluginSystem.
|
|
35133
|
+
// 触发插件系统 pluginSystem 的回调 onAssetsLoadFinish
|
|
35134
|
+
PluginSystem.onAssetsLoadFinish(loadedScene, assetManager.options, engine);
|
|
35015
35135
|
engine.assetService.prepareAssets(loadedScene, loadedScene.assets);
|
|
35016
35136
|
engine.assetService.updateTextVariables(loadedScene, options.variables);
|
|
35017
35137
|
engine.assetService.initializeTexture(loadedScene);
|
|
@@ -35073,10 +35193,9 @@ registerPlugin("sprite", SpriteLoader);
|
|
|
35073
35193
|
registerPlugin("particle", ParticleLoader);
|
|
35074
35194
|
registerPlugin("cal", CalculateLoader);
|
|
35075
35195
|
registerPlugin("interact", InteractLoader);
|
|
35076
|
-
var version = "2.8.0-alpha.
|
|
35196
|
+
var version = "2.8.0-alpha.4";
|
|
35077
35197
|
logger.info("Core version: " + version + ".");
|
|
35078
35198
|
|
|
35079
|
-
exports.AbstractPlugin = AbstractPlugin;
|
|
35080
35199
|
exports.ActivationMixerPlayable = ActivationMixerPlayable;
|
|
35081
35200
|
exports.ActivationPlayable = ActivationPlayable;
|
|
35082
35201
|
exports.AndNode = AndNode;
|
|
@@ -35176,6 +35295,7 @@ exports.PathSegments = PathSegments;
|
|
|
35176
35295
|
exports.Playable = Playable;
|
|
35177
35296
|
exports.PlayableAsset = PlayableAsset;
|
|
35178
35297
|
exports.PlayableOutput = PlayableOutput;
|
|
35298
|
+
exports.Plugin = Plugin;
|
|
35179
35299
|
exports.PluginSystem = PluginSystem;
|
|
35180
35300
|
exports.PointerEventData = PointerEventData;
|
|
35181
35301
|
exports.PolyStar = PolyStar;
|