@galacean/effects-threejs 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/index.js +314 -194
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +314 -194
- 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: v2.8.0-alpha.
|
|
6
|
+
* Version: v2.8.0-alpha.4
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -2905,7 +2905,6 @@ var plugins = [];
|
|
|
2905
2905
|
pluginLoaderMap[name] = pluginClass;
|
|
2906
2906
|
var pluginInstance = new pluginClass();
|
|
2907
2907
|
pluginInstance.name = name;
|
|
2908
|
-
pluginInstance.initialize();
|
|
2909
2908
|
plugins.push(pluginInstance);
|
|
2910
2909
|
plugins.sort(function(a, b) {
|
|
2911
2910
|
return a.order - b.order;
|
|
@@ -2929,29 +2928,29 @@ var PluginSystem = /*#__PURE__*/ function() {
|
|
|
2929
2928
|
};
|
|
2930
2929
|
PluginSystem.initializeComposition = function initializeComposition(composition, scene) {
|
|
2931
2930
|
plugins.forEach(function(loader) {
|
|
2932
|
-
return loader.
|
|
2931
|
+
return loader.onCompositionCreated(composition, scene);
|
|
2933
2932
|
});
|
|
2934
2933
|
};
|
|
2935
2934
|
PluginSystem.destroyComposition = function destroyComposition(comp) {
|
|
2936
2935
|
plugins.forEach(function(loader) {
|
|
2937
|
-
return loader.
|
|
2936
|
+
return loader.onCompositionDestroy(comp);
|
|
2938
2937
|
});
|
|
2939
2938
|
};
|
|
2940
|
-
PluginSystem.
|
|
2939
|
+
PluginSystem.onAssetsLoadStart = function onAssetsLoadStart(scene, options) {
|
|
2941
2940
|
return _async_to_generator(function() {
|
|
2942
2941
|
return __generator(this, function(_state) {
|
|
2943
2942
|
return [
|
|
2944
2943
|
2,
|
|
2945
2944
|
Promise.all(plugins.map(function(plugin) {
|
|
2946
|
-
return plugin.
|
|
2945
|
+
return plugin.onAssetsLoadStart(scene, options);
|
|
2947
2946
|
}))
|
|
2948
2947
|
];
|
|
2949
2948
|
});
|
|
2950
2949
|
})();
|
|
2951
2950
|
};
|
|
2952
|
-
PluginSystem.
|
|
2951
|
+
PluginSystem.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {
|
|
2953
2952
|
plugins.forEach(function(loader) {
|
|
2954
|
-
return loader.
|
|
2953
|
+
return loader.onAssetsLoadFinish(scene, options, engine);
|
|
2955
2954
|
});
|
|
2956
2955
|
};
|
|
2957
2956
|
return PluginSystem;
|
|
@@ -2981,20 +2980,18 @@ function getPluginUsageInfo(name) {
|
|
|
2981
2980
|
/**
|
|
2982
2981
|
* 抽象插件类
|
|
2983
2982
|
* 注册合成不同生命周期的回调函数
|
|
2984
|
-
*/ var
|
|
2985
|
-
function
|
|
2983
|
+
*/ var Plugin = /*#__PURE__*/ function() {
|
|
2984
|
+
function Plugin() {
|
|
2986
2985
|
this.order = 100;
|
|
2987
|
-
this.name = "";
|
|
2986
|
+
this.name = "Plugin";
|
|
2988
2987
|
}
|
|
2989
|
-
var _proto =
|
|
2990
|
-
_proto.initialize = function initialize() {};
|
|
2988
|
+
var _proto = Plugin.prototype;
|
|
2991
2989
|
/**
|
|
2992
|
-
*
|
|
2993
|
-
*
|
|
2994
|
-
* @param scene
|
|
2995
|
-
* @param options
|
|
2996
|
-
|
|
2997
|
-
*/ _proto.processAssets = function processAssets(scene, options) {
|
|
2990
|
+
* 场景加载时触发,用于加载插件所需的自定义资源。
|
|
2991
|
+
* 此阶段适合发起异步资源请求。
|
|
2992
|
+
* @param scene - 场景对象
|
|
2993
|
+
* @param options - 场景加载选项
|
|
2994
|
+
*/ _proto.onAssetsLoadStart = function onAssetsLoadStart(scene, options) {
|
|
2998
2995
|
return _async_to_generator(function() {
|
|
2999
2996
|
return __generator(this, function(_state) {
|
|
3000
2997
|
return [
|
|
@@ -3004,17 +3001,22 @@ function getPluginUsageInfo(name) {
|
|
|
3004
3001
|
})();
|
|
3005
3002
|
};
|
|
3006
3003
|
/**
|
|
3007
|
-
*
|
|
3008
|
-
*
|
|
3009
|
-
*
|
|
3010
|
-
*
|
|
3011
|
-
*
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3004
|
+
* 场景资源加载完成后触发。
|
|
3005
|
+
* 此时 JSON 中的图片和二进制已加载完成,可对资源做进一步处理。
|
|
3006
|
+
* @param scene - 场景对象
|
|
3007
|
+
* @param options - 场景加载选项
|
|
3008
|
+
* @param engine - 引擎实例
|
|
3009
|
+
*/ _proto.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {};
|
|
3010
|
+
/**
|
|
3011
|
+
* 合成创建完成后触发。
|
|
3012
|
+
* @param composition - 合成对象
|
|
3013
|
+
* @param scene - 场景对象
|
|
3014
|
+
*/ _proto.onCompositionCreated = function onCompositionCreated(composition, scene) {};
|
|
3015
|
+
/**
|
|
3016
|
+
* 合成销毁时触发。
|
|
3017
|
+
* @param composition - 合成对象
|
|
3018
|
+
*/ _proto.onCompositionDestroy = function onCompositionDestroy(composition) {};
|
|
3019
|
+
return Plugin;
|
|
3018
3020
|
}();
|
|
3019
3021
|
|
|
3020
3022
|
function _set_prototype_of(o, p) {
|
|
@@ -10674,6 +10676,9 @@ var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
10674
10676
|
stencilAction: exports.TextureLoadAction.clear
|
|
10675
10677
|
});
|
|
10676
10678
|
}
|
|
10679
|
+
this.meshes.sort(function(a, b) {
|
|
10680
|
+
return a.priority - b.priority;
|
|
10681
|
+
});
|
|
10677
10682
|
renderer.renderMeshes(this.meshes);
|
|
10678
10683
|
};
|
|
10679
10684
|
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
@@ -16611,13 +16616,49 @@ exports.CameraController = __decorate([
|
|
|
16611
16616
|
effectsClass(DataType.CameraController)
|
|
16612
16617
|
], exports.CameraController);
|
|
16613
16618
|
|
|
16614
|
-
|
|
16615
|
-
|
|
16619
|
+
function _get_prototype_of(o) {
|
|
16620
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
16621
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
16622
|
+
};
|
|
16623
|
+
return _get_prototype_of(o);
|
|
16624
|
+
}
|
|
16625
|
+
|
|
16626
|
+
function _is_native_function(fn) {
|
|
16627
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
16628
|
+
}
|
|
16629
|
+
|
|
16630
|
+
function _wrap_native_super(Class) {
|
|
16631
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
16632
|
+
_wrap_native_super = function _wrap_native_super(Class) {
|
|
16633
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
16634
|
+
if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
|
|
16635
|
+
if (typeof _cache !== "undefined") {
|
|
16636
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
16637
|
+
_cache.set(Class, Wrapper);
|
|
16638
|
+
}
|
|
16639
|
+
function Wrapper() {
|
|
16640
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
16641
|
+
}
|
|
16642
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
16643
|
+
constructor: {
|
|
16644
|
+
value: Wrapper,
|
|
16645
|
+
enumerable: false,
|
|
16646
|
+
writable: true,
|
|
16647
|
+
configurable: true
|
|
16648
|
+
}
|
|
16649
|
+
});
|
|
16650
|
+
return _set_prototype_of(Wrapper, Class);
|
|
16651
|
+
};
|
|
16652
|
+
return _wrap_native_super(Class);
|
|
16653
|
+
}
|
|
16654
|
+
|
|
16655
|
+
var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
|
|
16656
|
+
_inherits(CameraVFXItemLoader, Plugin);
|
|
16616
16657
|
function CameraVFXItemLoader() {
|
|
16617
|
-
return
|
|
16658
|
+
return Plugin.apply(this, arguments);
|
|
16618
16659
|
}
|
|
16619
16660
|
return CameraVFXItemLoader;
|
|
16620
|
-
}(
|
|
16661
|
+
}(_wrap_native_super(Plugin));
|
|
16621
16662
|
|
|
16622
16663
|
exports.HitTestType = void 0;
|
|
16623
16664
|
(function(HitTestType) {
|
|
@@ -16901,13 +16942,13 @@ function getCoord(event) {
|
|
|
16901
16942
|
};
|
|
16902
16943
|
}
|
|
16903
16944
|
|
|
16904
|
-
var InteractLoader = /*#__PURE__*/ function(
|
|
16905
|
-
_inherits(InteractLoader,
|
|
16945
|
+
var InteractLoader = /*#__PURE__*/ function(Plugin) {
|
|
16946
|
+
_inherits(InteractLoader, Plugin);
|
|
16906
16947
|
function InteractLoader() {
|
|
16907
|
-
return
|
|
16948
|
+
return Plugin.apply(this, arguments);
|
|
16908
16949
|
}
|
|
16909
16950
|
return InteractLoader;
|
|
16910
|
-
}(
|
|
16951
|
+
}(_wrap_native_super(Plugin));
|
|
16911
16952
|
|
|
16912
16953
|
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";
|
|
16913
16954
|
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";
|
|
@@ -17506,16 +17547,16 @@ function shouldIgnoreBouncing(arg, mul) {
|
|
|
17506
17547
|
return MeshCollider;
|
|
17507
17548
|
}();
|
|
17508
17549
|
|
|
17509
|
-
var SpriteLoader = /*#__PURE__*/ function(
|
|
17510
|
-
_inherits(SpriteLoader,
|
|
17550
|
+
var SpriteLoader = /*#__PURE__*/ function(Plugin) {
|
|
17551
|
+
_inherits(SpriteLoader, Plugin);
|
|
17511
17552
|
function SpriteLoader() {
|
|
17512
17553
|
var _this;
|
|
17513
|
-
_this =
|
|
17554
|
+
_this = Plugin.apply(this, arguments) || this;
|
|
17514
17555
|
_this.name = "sprite";
|
|
17515
17556
|
return _this;
|
|
17516
17557
|
}
|
|
17517
17558
|
return SpriteLoader;
|
|
17518
|
-
}(
|
|
17559
|
+
}(_wrap_native_super(Plugin));
|
|
17519
17560
|
|
|
17520
17561
|
/**
|
|
17521
17562
|
* 动画图可播放节点对象
|
|
@@ -20006,7 +20047,7 @@ function calculateDirection(prePoint, point, nextPoint) {
|
|
|
20006
20047
|
if (this.time >= 0 && this.time < particleSystem.item.duration && particleSystem.isEnded()) {
|
|
20007
20048
|
particleSystem.reset();
|
|
20008
20049
|
}
|
|
20009
|
-
particleSystem.
|
|
20050
|
+
particleSystem.simulate(this.time - particleSystem.time);
|
|
20010
20051
|
}
|
|
20011
20052
|
this.lastTime = this.time;
|
|
20012
20053
|
};
|
|
@@ -21457,126 +21498,133 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
21457
21498
|
this.initEmitterTransform();
|
|
21458
21499
|
};
|
|
21459
21500
|
_proto.onUpdate = function onUpdate(dt) {
|
|
21460
|
-
this.
|
|
21501
|
+
if (!this.frozen) {
|
|
21502
|
+
this.update(dt);
|
|
21503
|
+
}
|
|
21504
|
+
};
|
|
21505
|
+
_proto.simulate = function simulate(time) {
|
|
21506
|
+
this.update(time * 1000);
|
|
21507
|
+
this.frozen = true;
|
|
21461
21508
|
};
|
|
21462
21509
|
_proto.update = function update(delta) {
|
|
21463
21510
|
var _this = this;
|
|
21464
|
-
if (this.started
|
|
21465
|
-
|
|
21466
|
-
|
|
21467
|
-
|
|
21468
|
-
|
|
21469
|
-
|
|
21470
|
-
|
|
21471
|
-
|
|
21472
|
-
|
|
21473
|
-
|
|
21474
|
-
|
|
21475
|
-
|
|
21476
|
-
|
|
21477
|
-
|
|
21478
|
-
|
|
21479
|
-
|
|
21480
|
-
|
|
21481
|
-
|
|
21482
|
-
|
|
21483
|
-
|
|
21484
|
-
|
|
21485
|
-
|
|
21486
|
-
|
|
21511
|
+
if (!this.started) {
|
|
21512
|
+
return;
|
|
21513
|
+
}
|
|
21514
|
+
var now = this.time + delta / 1000;
|
|
21515
|
+
var options = this.options;
|
|
21516
|
+
var loopStartTime = this.loopStartTime;
|
|
21517
|
+
var emission = this.emission;
|
|
21518
|
+
this.time = now;
|
|
21519
|
+
this.upDirectionWorld = null;
|
|
21520
|
+
this.renderer.updateTime(now, delta);
|
|
21521
|
+
var link = this.particleLink;
|
|
21522
|
+
var emitterLifetime = (now - loopStartTime) / this.item.duration;
|
|
21523
|
+
var timePassed = this.timePassed;
|
|
21524
|
+
var trailUpdated = false;
|
|
21525
|
+
var updateTrail = function() {
|
|
21526
|
+
if (_this.trails && !trailUpdated) {
|
|
21527
|
+
trailUpdated = true;
|
|
21528
|
+
link.forEach(function(param) {
|
|
21529
|
+
var time = param[0], pointIndex = param[1], delay = param[2], point = param[3];
|
|
21530
|
+
if (time < timePassed) {
|
|
21531
|
+
_this.clearPointTrail(pointIndex);
|
|
21532
|
+
} else if (timePassed > delay) {
|
|
21533
|
+
_this.updatePointTrail(pointIndex, emitterLifetime, point, delay);
|
|
21534
|
+
}
|
|
21535
|
+
});
|
|
21536
|
+
}
|
|
21537
|
+
};
|
|
21538
|
+
if (!this.ended) {
|
|
21539
|
+
var duration = this.item.duration;
|
|
21540
|
+
var lifetime = this.lifetime;
|
|
21541
|
+
if (timePassed < duration) {
|
|
21542
|
+
var interval = 1 / emission.rateOverTime.getValue(lifetime);
|
|
21543
|
+
var pointCount = Math.floor((timePassed - this.lastEmitTime) / interval);
|
|
21544
|
+
var maxEmissionCount = pointCount;
|
|
21545
|
+
var timeDelta = interval / pointCount;
|
|
21546
|
+
var meshTime = now;
|
|
21547
|
+
var maxCount = options.maxCount;
|
|
21548
|
+
this.updateEmitterTransform(timePassed);
|
|
21549
|
+
var shouldSkipGenerate = function() {
|
|
21550
|
+
var first = link.first;
|
|
21551
|
+
return _this.emissionStopped || link.length === maxCount && first && first.content[0] - loopStartTime > timePassed;
|
|
21552
|
+
};
|
|
21553
|
+
for(var i = 0; i < maxEmissionCount && i < maxCount; i++){
|
|
21554
|
+
if (shouldSkipGenerate()) {
|
|
21555
|
+
break;
|
|
21556
|
+
}
|
|
21557
|
+
var p = this.createPoint(lifetime);
|
|
21558
|
+
p.delay += meshTime + i * timeDelta;
|
|
21559
|
+
this.addParticle(p, maxCount);
|
|
21560
|
+
this.lastEmitTime = timePassed;
|
|
21487
21561
|
}
|
|
21488
|
-
|
|
21489
|
-
|
|
21490
|
-
|
|
21491
|
-
|
|
21492
|
-
if (timePassed < duration) {
|
|
21493
|
-
var interval = 1 / emission.rateOverTime.getValue(lifetime);
|
|
21494
|
-
var pointCount = Math.floor((timePassed - this.lastEmitTime) / interval);
|
|
21495
|
-
var maxEmissionCount = pointCount;
|
|
21496
|
-
var timeDelta = interval / pointCount;
|
|
21497
|
-
var meshTime = now;
|
|
21498
|
-
var maxCount = options.maxCount;
|
|
21499
|
-
this.updateEmitterTransform(timePassed);
|
|
21500
|
-
var shouldSkipGenerate = function() {
|
|
21501
|
-
var first = link.first;
|
|
21502
|
-
return _this.emissionStopped || link.length === maxCount && first && first.content[0] - loopStartTime > timePassed;
|
|
21503
|
-
};
|
|
21504
|
-
for(var i = 0; i < maxEmissionCount && i < maxCount; i++){
|
|
21505
|
-
if (shouldSkipGenerate()) {
|
|
21506
|
-
break;
|
|
21507
|
-
}
|
|
21508
|
-
var p = this.createPoint(lifetime);
|
|
21509
|
-
p.delay += meshTime + i * timeDelta;
|
|
21510
|
-
this.addParticle(p, maxCount);
|
|
21511
|
-
this.lastEmitTime = timePassed;
|
|
21562
|
+
var bursts = emission.bursts;
|
|
21563
|
+
for(var j = (bursts == null ? void 0 : bursts.length) - 1, cursor = 0; j >= 0 && cursor < maxCount; j--){
|
|
21564
|
+
if (shouldSkipGenerate()) {
|
|
21565
|
+
break;
|
|
21512
21566
|
}
|
|
21513
|
-
var
|
|
21514
|
-
|
|
21515
|
-
|
|
21516
|
-
|
|
21567
|
+
var burst = bursts[j];
|
|
21568
|
+
var opts = !burst.disabled && burst.getGeneratorOptions(timePassed, lifetime);
|
|
21569
|
+
if (opts) {
|
|
21570
|
+
var originVec = [
|
|
21571
|
+
0,
|
|
21572
|
+
0,
|
|
21573
|
+
0
|
|
21574
|
+
];
|
|
21575
|
+
var offsets = emission.burstOffsets[j];
|
|
21576
|
+
var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
|
|
21577
|
+
if (burst.once) {
|
|
21578
|
+
this.removeBurst(j);
|
|
21517
21579
|
}
|
|
21518
|
-
var
|
|
21519
|
-
|
|
21520
|
-
|
|
21521
|
-
|
|
21522
|
-
0,
|
|
21523
|
-
0,
|
|
21524
|
-
0
|
|
21525
|
-
];
|
|
21526
|
-
var offsets = emission.burstOffsets[j];
|
|
21527
|
-
var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
|
|
21528
|
-
if (burst.once) {
|
|
21529
|
-
this.removeBurst(j);
|
|
21530
|
-
}
|
|
21531
|
-
for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
|
|
21532
|
-
var _p_transform;
|
|
21533
|
-
if (shouldSkipGenerate()) {
|
|
21534
|
-
break;
|
|
21535
|
-
}
|
|
21536
|
-
var p1 = this.initPoint(this.shape.generate({
|
|
21537
|
-
total: opts.total,
|
|
21538
|
-
index: opts.index,
|
|
21539
|
-
burstIndex: i1,
|
|
21540
|
-
burstCount: opts.count
|
|
21541
|
-
}));
|
|
21542
|
-
p1.delay += meshTime;
|
|
21543
|
-
cursor++;
|
|
21544
|
-
(_p_transform = p1.transform).translate.apply(_p_transform, [].concat(burstOffset));
|
|
21545
|
-
this.addParticle(p1, maxCount);
|
|
21580
|
+
for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
|
|
21581
|
+
var _p_transform;
|
|
21582
|
+
if (shouldSkipGenerate()) {
|
|
21583
|
+
break;
|
|
21546
21584
|
}
|
|
21585
|
+
var p1 = this.initPoint(this.shape.generate({
|
|
21586
|
+
total: opts.total,
|
|
21587
|
+
index: opts.index,
|
|
21588
|
+
burstIndex: i1,
|
|
21589
|
+
burstCount: opts.count
|
|
21590
|
+
}));
|
|
21591
|
+
p1.delay += meshTime;
|
|
21592
|
+
cursor++;
|
|
21593
|
+
(_p_transform = p1.transform).translate.apply(_p_transform, [].concat(burstOffset));
|
|
21594
|
+
this.addParticle(p1, maxCount);
|
|
21547
21595
|
}
|
|
21548
21596
|
}
|
|
21549
|
-
} else if (this.item.endBehavior === EndBehavior.restart) {
|
|
21550
|
-
updateTrail();
|
|
21551
|
-
this.loopStartTime = now - duration;
|
|
21552
|
-
this.lastEmitTime -= duration;
|
|
21553
|
-
this.time -= duration;
|
|
21554
|
-
emission.bursts.forEach(function(b) {
|
|
21555
|
-
return b.reset();
|
|
21556
|
-
});
|
|
21557
|
-
this.particleLink.forEach(function(content) {
|
|
21558
|
-
content[0] -= duration;
|
|
21559
|
-
content[2] -= duration;
|
|
21560
|
-
content[3].delay -= duration;
|
|
21561
|
-
});
|
|
21562
|
-
this.renderer.minusTimeForLoop(duration);
|
|
21563
|
-
} else {
|
|
21564
|
-
this.ended = true;
|
|
21565
|
-
var endBehavior = this.item.endBehavior;
|
|
21566
|
-
if (endBehavior === EndBehavior.freeze) {
|
|
21567
|
-
this.frozen = true;
|
|
21568
|
-
}
|
|
21569
21597
|
}
|
|
21570
|
-
} else if (this.item.endBehavior
|
|
21571
|
-
|
|
21572
|
-
|
|
21573
|
-
|
|
21574
|
-
|
|
21575
|
-
|
|
21598
|
+
} else if (this.item.endBehavior === EndBehavior.restart) {
|
|
21599
|
+
updateTrail();
|
|
21600
|
+
this.loopStartTime = now - duration;
|
|
21601
|
+
this.lastEmitTime -= duration;
|
|
21602
|
+
this.time -= duration;
|
|
21603
|
+
emission.bursts.forEach(function(b) {
|
|
21604
|
+
return b.reset();
|
|
21605
|
+
});
|
|
21606
|
+
this.particleLink.forEach(function(content) {
|
|
21607
|
+
content[0] -= duration;
|
|
21608
|
+
content[2] -= duration;
|
|
21609
|
+
content[3].delay -= duration;
|
|
21610
|
+
});
|
|
21611
|
+
this.renderer.minusTimeForLoop(duration);
|
|
21612
|
+
} else {
|
|
21613
|
+
this.ended = true;
|
|
21614
|
+
var endBehavior = this.item.endBehavior;
|
|
21615
|
+
if (endBehavior === EndBehavior.freeze) {
|
|
21616
|
+
this.frozen = true;
|
|
21617
|
+
}
|
|
21618
|
+
}
|
|
21619
|
+
} else if (this.item.endBehavior !== EndBehavior.restart) {
|
|
21620
|
+
if (EndBehavior.destroy === this.item.endBehavior) {
|
|
21621
|
+
var node = link.last;
|
|
21622
|
+
if (node && node.content[0] < this.time) {
|
|
21623
|
+
this.destroyed = true;
|
|
21576
21624
|
}
|
|
21577
21625
|
}
|
|
21578
|
-
updateTrail();
|
|
21579
21626
|
}
|
|
21627
|
+
updateTrail();
|
|
21580
21628
|
};
|
|
21581
21629
|
_proto.drawStencilMask = function drawStencilMask(renderer) {
|
|
21582
21630
|
if (!this.isActiveAndEnabled) {
|
|
@@ -25616,7 +25664,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25616
25664
|
_this = MaskableGraphic.call(this, engine) || this;
|
|
25617
25665
|
_this.time = 0;
|
|
25618
25666
|
_this.duration = 1;
|
|
25619
|
-
_this.loop = true;
|
|
25620
25667
|
/**
|
|
25621
25668
|
* @internal
|
|
25622
25669
|
*/ _this.splits = singleSplits;
|
|
@@ -25631,11 +25678,15 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25631
25678
|
var _this = this;
|
|
25632
25679
|
var time = this.time;
|
|
25633
25680
|
var duration = this.duration;
|
|
25634
|
-
|
|
25681
|
+
var textureAnimation = this.textureSheetAnimation;
|
|
25682
|
+
var _textureAnimation_loop;
|
|
25683
|
+
// TODO: Update textureAnimation spec.
|
|
25684
|
+
// @ts-expect-error
|
|
25685
|
+
var loop = (_textureAnimation_loop = textureAnimation == null ? void 0 : textureAnimation.loop) != null ? _textureAnimation_loop : true;
|
|
25686
|
+
if (time > duration && loop) {
|
|
25635
25687
|
time = time % duration;
|
|
25636
25688
|
}
|
|
25637
25689
|
var life = Math.min(Math.max(time / duration, 0.0), 1.0);
|
|
25638
|
-
var ta = this.textureSheetAnimation;
|
|
25639
25690
|
var video = this.renderer.texture.source.video;
|
|
25640
25691
|
if (video) {
|
|
25641
25692
|
if (time === 0) {
|
|
@@ -25647,9 +25698,9 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25647
25698
|
}
|
|
25648
25699
|
this.renderer.texture.uploadCurrentVideoFrame();
|
|
25649
25700
|
}
|
|
25650
|
-
if (
|
|
25701
|
+
if (textureAnimation) {
|
|
25651
25702
|
var _this_material_getVector4;
|
|
25652
|
-
var total =
|
|
25703
|
+
var total = textureAnimation.total || textureAnimation.row * textureAnimation.col;
|
|
25653
25704
|
var texRectX = 0;
|
|
25654
25705
|
var texRectY = 0;
|
|
25655
25706
|
var texRectW = 1;
|
|
@@ -25670,20 +25721,20 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25670
25721
|
}
|
|
25671
25722
|
var dx, dy;
|
|
25672
25723
|
if (flip) {
|
|
25673
|
-
dx = 1 /
|
|
25674
|
-
dy = 1 /
|
|
25724
|
+
dx = 1 / textureAnimation.row * texRectW;
|
|
25725
|
+
dy = 1 / textureAnimation.col * texRectH;
|
|
25675
25726
|
} else {
|
|
25676
|
-
dx = 1 /
|
|
25677
|
-
dy = 1 /
|
|
25727
|
+
dx = 1 / textureAnimation.col * texRectW;
|
|
25728
|
+
dy = 1 / textureAnimation.row * texRectH;
|
|
25678
25729
|
}
|
|
25679
25730
|
var texOffset;
|
|
25680
|
-
if (
|
|
25731
|
+
if (textureAnimation.animate) {
|
|
25681
25732
|
var frameIndex = Math.round(life * (total - 1));
|
|
25682
|
-
var yIndex = Math.floor(frameIndex /
|
|
25683
|
-
var xIndex = frameIndex - yIndex *
|
|
25733
|
+
var yIndex = Math.floor(frameIndex / textureAnimation.col);
|
|
25734
|
+
var xIndex = frameIndex - yIndex * textureAnimation.col;
|
|
25684
25735
|
texOffset = flip ? [
|
|
25685
25736
|
dx * yIndex,
|
|
25686
|
-
dy * (
|
|
25737
|
+
dy * (textureAnimation.col - xIndex)
|
|
25687
25738
|
] : [
|
|
25688
25739
|
dx * xIndex,
|
|
25689
25740
|
dy * (1 + yIndex)
|
|
@@ -25871,8 +25922,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25871
25922
|
var _data_duration;
|
|
25872
25923
|
//@ts-expect-error
|
|
25873
25924
|
this.duration = (_data_duration = data.duration) != null ? _data_duration : this.item.duration;
|
|
25874
|
-
var _data_loop;
|
|
25875
|
-
this.loop = (_data_loop = data.loop) != null ? _data_loop : true;
|
|
25876
25925
|
};
|
|
25877
25926
|
return SpriteComponent;
|
|
25878
25927
|
}(MaskableGraphic);
|
|
@@ -25880,21 +25929,21 @@ exports.SpriteComponent = __decorate([
|
|
|
25880
25929
|
effectsClass(DataType.SpriteComponent)
|
|
25881
25930
|
], exports.SpriteComponent);
|
|
25882
25931
|
|
|
25883
|
-
var ParticleLoader = /*#__PURE__*/ function(
|
|
25884
|
-
_inherits(ParticleLoader,
|
|
25932
|
+
var ParticleLoader = /*#__PURE__*/ function(Plugin) {
|
|
25933
|
+
_inherits(ParticleLoader, Plugin);
|
|
25885
25934
|
function ParticleLoader() {
|
|
25886
|
-
return
|
|
25935
|
+
return Plugin.apply(this, arguments);
|
|
25887
25936
|
}
|
|
25888
25937
|
return ParticleLoader;
|
|
25889
|
-
}(
|
|
25938
|
+
}(_wrap_native_super(Plugin));
|
|
25890
25939
|
|
|
25891
|
-
var CalculateLoader = /*#__PURE__*/ function(
|
|
25892
|
-
_inherits(CalculateLoader,
|
|
25940
|
+
var CalculateLoader = /*#__PURE__*/ function(Plugin) {
|
|
25941
|
+
_inherits(CalculateLoader, Plugin);
|
|
25893
25942
|
function CalculateLoader() {
|
|
25894
|
-
return
|
|
25943
|
+
return Plugin.apply(this, arguments);
|
|
25895
25944
|
}
|
|
25896
25945
|
return CalculateLoader;
|
|
25897
|
-
}(
|
|
25946
|
+
}(_wrap_native_super(Plugin));
|
|
25898
25947
|
|
|
25899
25948
|
// Based on:
|
|
25900
25949
|
/**
|
|
@@ -28996,6 +29045,12 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
28996
29045
|
/**
|
|
28997
29046
|
* 每一行文本的最大宽度
|
|
28998
29047
|
*/ _this.maxLineWidth = 0;
|
|
29048
|
+
/**
|
|
29049
|
+
* 初始文本宽度,用于计算缩放比例
|
|
29050
|
+
*/ _this.baseTextWidth = 0;
|
|
29051
|
+
/**
|
|
29052
|
+
* 初始 `transform.size.x`,用于按比例更新显示宽度
|
|
29053
|
+
*/ _this.baseScaleX = 1;
|
|
28999
29054
|
_this.name = "MText" + seed$2++;
|
|
29000
29055
|
// 初始化canvas资源
|
|
29001
29056
|
_this.canvas = canvasPool.getCanvas();
|
|
@@ -29021,10 +29076,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29021
29076
|
text: "默认文本",
|
|
29022
29077
|
fontFamily: "AlibabaSans-BoldItalic",
|
|
29023
29078
|
fontSize: 40,
|
|
29079
|
+
// 统一使用 0-1 颜色值
|
|
29024
29080
|
textColor: [
|
|
29025
|
-
|
|
29026
|
-
|
|
29027
|
-
|
|
29081
|
+
1,
|
|
29082
|
+
1,
|
|
29083
|
+
1,
|
|
29028
29084
|
1
|
|
29029
29085
|
],
|
|
29030
29086
|
fontWeight: TextWeight.normal,
|
|
@@ -29061,6 +29117,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29061
29117
|
// TextComponentBase
|
|
29062
29118
|
this.updateWithOptions(options);
|
|
29063
29119
|
this.renderText(options);
|
|
29120
|
+
// 记录初始的 textWidth 和 x 缩放,用于后续按比例更新显示宽度
|
|
29121
|
+
// 添加兜底值 1 防止除 0
|
|
29122
|
+
this.baseTextWidth = options.textWidth || this.textLayout.width || 1;
|
|
29123
|
+
this.baseScaleX = this.item.transform.size.x;
|
|
29064
29124
|
// 恢复默认颜色
|
|
29065
29125
|
this.material.setColor("_Color", new Color(1, 1, 1, 1));
|
|
29066
29126
|
};
|
|
@@ -29259,9 +29319,9 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29259
29319
|
if (style.isOutlined) {
|
|
29260
29320
|
_this.setupOutline();
|
|
29261
29321
|
}
|
|
29262
|
-
//
|
|
29322
|
+
// textColor 统一是 0-1,写入 canvas 时乘 255
|
|
29263
29323
|
var _style_textColor = style.textColor, r = _style_textColor[0], g = _style_textColor[1], b = _style_textColor[2], a = _style_textColor[3];
|
|
29264
|
-
context.fillStyle = "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
|
|
29324
|
+
context.fillStyle = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
|
|
29265
29325
|
var charsInfo = [];
|
|
29266
29326
|
var x = 0;
|
|
29267
29327
|
var y = layout.getOffsetY(style, _this.lineCount, lineHeight, fontSize);
|
|
@@ -29323,6 +29383,46 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29323
29383
|
layout.autoWidth = normalizedValue;
|
|
29324
29384
|
this.isDirty = true;
|
|
29325
29385
|
};
|
|
29386
|
+
/**
|
|
29387
|
+
* 设置文本框宽度
|
|
29388
|
+
* 手动设置宽度时会自动关闭 `autoWidth`
|
|
29389
|
+
* 同时会按比例更新 `transform.size.x`,让 UI 框宽度也跟着变化
|
|
29390
|
+
* @param value - 文本框宽度
|
|
29391
|
+
*/ _proto.setTextWidth = function setTextWidth(value) {
|
|
29392
|
+
var width = Math.max(0, Number(value) || 0);
|
|
29393
|
+
var layout = this.textLayout;
|
|
29394
|
+
// 宽度没变且已是非 autoWidth 模式,直接返回
|
|
29395
|
+
if (layout.width === width && layout.autoWidth === false) {
|
|
29396
|
+
return;
|
|
29397
|
+
}
|
|
29398
|
+
// 手动设置宽度时关闭 autoWidth
|
|
29399
|
+
layout.autoWidth = false;
|
|
29400
|
+
layout.width = width;
|
|
29401
|
+
// 按当前 overflow 模式重新计算行数和 maxLineWidth
|
|
29402
|
+
this.lineCount = this.getLineCount(this.text || "");
|
|
29403
|
+
this.isDirty = true;
|
|
29404
|
+
// 同步更新外层显示宽度(按比例缩放 transform)
|
|
29405
|
+
// 这样 UI 框的视觉宽度也会跟着文本宽度变化
|
|
29406
|
+
if (this.baseTextWidth > 0) {
|
|
29407
|
+
var scale = width / this.baseTextWidth;
|
|
29408
|
+
this.item.transform.size.x = this.baseScaleX * scale;
|
|
29409
|
+
}
|
|
29410
|
+
};
|
|
29411
|
+
/**
|
|
29412
|
+
* 设置文本框高度
|
|
29413
|
+
* @param value - 文本框高度
|
|
29414
|
+
*/ _proto.setTextHeight = function setTextHeight(value) {
|
|
29415
|
+
var height = Math.max(0, Number(value) || 0);
|
|
29416
|
+
if (height === 0) {
|
|
29417
|
+
return;
|
|
29418
|
+
}
|
|
29419
|
+
var layout = this.textLayout;
|
|
29420
|
+
if (layout.height === height) {
|
|
29421
|
+
return;
|
|
29422
|
+
}
|
|
29423
|
+
layout.height = height;
|
|
29424
|
+
this.isDirty = true;
|
|
29425
|
+
};
|
|
29326
29426
|
_proto.setFontSize = function setFontSize(value) {
|
|
29327
29427
|
if (this.textStyle.fontSize === value) {
|
|
29328
29428
|
return;
|
|
@@ -29390,13 +29490,13 @@ applyMixins(exports.TextComponent, [
|
|
|
29390
29490
|
]);
|
|
29391
29491
|
|
|
29392
29492
|
// TODO: 注册必须用
|
|
29393
|
-
var TextLoader = /*#__PURE__*/ function(
|
|
29394
|
-
_inherits(TextLoader,
|
|
29493
|
+
var TextLoader = /*#__PURE__*/ function(Plugin) {
|
|
29494
|
+
_inherits(TextLoader, Plugin);
|
|
29395
29495
|
function TextLoader() {
|
|
29396
|
-
return
|
|
29496
|
+
return Plugin.apply(this, arguments);
|
|
29397
29497
|
}
|
|
29398
29498
|
return TextLoader;
|
|
29399
|
-
}(
|
|
29499
|
+
}(_wrap_native_super(Plugin));
|
|
29400
29500
|
|
|
29401
29501
|
var Asset = /*#__PURE__*/ function(EffectsObject) {
|
|
29402
29502
|
_inherits(Asset, EffectsObject);
|
|
@@ -30453,6 +30553,10 @@ function version35Migration(json) {
|
|
|
30453
30553
|
if (component.dataType === DataType.TextComponent || component.dataType === DataType.RichTextComponent && component.options) {
|
|
30454
30554
|
ensureTextVerticalAlign(component.options);
|
|
30455
30555
|
}
|
|
30556
|
+
// 处理文本颜色从 0-255 到 0-1 的转换
|
|
30557
|
+
if (component.dataType === DataType.TextComponent) {
|
|
30558
|
+
convertTextColorTo01(component.options);
|
|
30559
|
+
}
|
|
30456
30560
|
}
|
|
30457
30561
|
}
|
|
30458
30562
|
//@ts-expect-error
|
|
@@ -30472,6 +30576,22 @@ function version35Migration(json) {
|
|
|
30472
30576
|
options.TextVerticalAlign = options.textBaseline;
|
|
30473
30577
|
}
|
|
30474
30578
|
}
|
|
30579
|
+
/**
|
|
30580
|
+
* 将文本颜色从 0-255 转换到 0-1
|
|
30581
|
+
*/ function convertTextColorTo01(options) {
|
|
30582
|
+
if (!options || !options.textColor) {
|
|
30583
|
+
return;
|
|
30584
|
+
}
|
|
30585
|
+
var textColor = options.textColor;
|
|
30586
|
+
var _textColor_;
|
|
30587
|
+
// 将 RGB 从 0-255 转换到 0-1(alpha 通道已经是 0-1,不需要转换)
|
|
30588
|
+
options.textColor = [
|
|
30589
|
+
textColor[0] / 255.0,
|
|
30590
|
+
textColor[1] / 255.0,
|
|
30591
|
+
textColor[2] / 255.0,
|
|
30592
|
+
(_textColor_ = textColor[3]) != null ? _textColor_ : 1
|
|
30593
|
+
];
|
|
30594
|
+
}
|
|
30475
30595
|
/**
|
|
30476
30596
|
* 根据形状获取形状几何体数据
|
|
30477
30597
|
* @param shape - 形状
|
|
@@ -31394,7 +31514,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
31394
31514
|
return ret;
|
|
31395
31515
|
}
|
|
31396
31516
|
|
|
31397
|
-
var version$2 = "2.8.0-alpha.
|
|
31517
|
+
var version$2 = "2.8.0-alpha.4";
|
|
31398
31518
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
31399
31519
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
31400
31520
|
var reverseParticle = false;
|
|
@@ -32034,8 +32154,8 @@ var seed$1 = 1;
|
|
|
32034
32154
|
};
|
|
32035
32155
|
return [
|
|
32036
32156
|
4,
|
|
32037
|
-
hookTimeInfo("plugin:
|
|
32038
|
-
return _this.
|
|
32157
|
+
hookTimeInfo("plugin:onAssetsLoadStart", function() {
|
|
32158
|
+
return _this.onPluginSceneLoadStart(scene);
|
|
32039
32159
|
})
|
|
32040
32160
|
];
|
|
32041
32161
|
case 6:
|
|
@@ -32323,7 +32443,7 @@ var seed$1 = 1;
|
|
|
32323
32443
|
});
|
|
32324
32444
|
})();
|
|
32325
32445
|
};
|
|
32326
|
-
_proto.
|
|
32446
|
+
_proto.onPluginSceneLoadStart = function onPluginSceneLoadStart(scene) {
|
|
32327
32447
|
var _this = this;
|
|
32328
32448
|
return _async_to_generator(function() {
|
|
32329
32449
|
return __generator(this, function(_state) {
|
|
@@ -32331,7 +32451,7 @@ var seed$1 = 1;
|
|
|
32331
32451
|
case 0:
|
|
32332
32452
|
return [
|
|
32333
32453
|
4,
|
|
32334
|
-
PluginSystem.
|
|
32454
|
+
PluginSystem.onAssetsLoadStart(scene, _this.options)
|
|
32335
32455
|
];
|
|
32336
32456
|
case 1:
|
|
32337
32457
|
_state.sent();
|
|
@@ -35032,8 +35152,8 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35032
35152
|
case 1:
|
|
35033
35153
|
loadedScene = _state.sent();
|
|
35034
35154
|
engine.clearResources();
|
|
35035
|
-
// 触发插件系统 pluginSystem 的回调
|
|
35036
|
-
PluginSystem.
|
|
35155
|
+
// 触发插件系统 pluginSystem 的回调 onAssetsLoadFinish
|
|
35156
|
+
PluginSystem.onAssetsLoadFinish(loadedScene, assetManager.options, engine);
|
|
35037
35157
|
engine.assetService.prepareAssets(loadedScene, loadedScene.assets);
|
|
35038
35158
|
engine.assetService.updateTextVariables(loadedScene, options.variables);
|
|
35039
35159
|
engine.assetService.initializeTexture(loadedScene);
|
|
@@ -35095,7 +35215,7 @@ registerPlugin("sprite", SpriteLoader);
|
|
|
35095
35215
|
registerPlugin("particle", ParticleLoader);
|
|
35096
35216
|
registerPlugin("cal", CalculateLoader);
|
|
35097
35217
|
registerPlugin("interact", InteractLoader);
|
|
35098
|
-
var version$1 = "2.8.0-alpha.
|
|
35218
|
+
var version$1 = "2.8.0-alpha.4";
|
|
35099
35219
|
logger.info("Core version: " + version$1 + ".");
|
|
35100
35220
|
|
|
35101
35221
|
var _obj;
|
|
@@ -36389,8 +36509,8 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
36389
36509
|
_$scene = _state.sent();
|
|
36390
36510
|
engine = _this.engine;
|
|
36391
36511
|
engine.clearResources();
|
|
36392
|
-
// 触发插件系统 pluginSystem 的回调
|
|
36393
|
-
PluginSystem.
|
|
36512
|
+
// 触发插件系统 pluginSystem 的回调 onAssetsLoadFinish
|
|
36513
|
+
PluginSystem.onAssetsLoadFinish(_$scene, assetManager.options, engine);
|
|
36394
36514
|
_this.assetService.prepareAssets(_$scene, assetManager.getAssets());
|
|
36395
36515
|
_this.assetService.updateTextVariables(_$scene, assetManager.options.variables);
|
|
36396
36516
|
_this.assetService.initializeTexture(_$scene);
|
|
@@ -36685,10 +36805,9 @@ applyMixins(exports.ThreeTextComponent, [
|
|
|
36685
36805
|
*/ Mesh.create = function(engine, props) {
|
|
36686
36806
|
return new ThreeMesh(engine, props);
|
|
36687
36807
|
};
|
|
36688
|
-
var version = "2.8.0-alpha.
|
|
36808
|
+
var version = "2.8.0-alpha.4";
|
|
36689
36809
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
36690
36810
|
|
|
36691
|
-
exports.AbstractPlugin = AbstractPlugin;
|
|
36692
36811
|
exports.ActivationMixerPlayable = ActivationMixerPlayable;
|
|
36693
36812
|
exports.ActivationPlayable = ActivationPlayable;
|
|
36694
36813
|
exports.AndNode = AndNode;
|
|
@@ -36792,6 +36911,7 @@ exports.PathSegments = PathSegments;
|
|
|
36792
36911
|
exports.Playable = Playable;
|
|
36793
36912
|
exports.PlayableAsset = PlayableAsset;
|
|
36794
36913
|
exports.PlayableOutput = PlayableOutput;
|
|
36914
|
+
exports.Plugin = Plugin;
|
|
36795
36915
|
exports.PluginSystem = PluginSystem;
|
|
36796
36916
|
exports.PointerEventData = PointerEventData;
|
|
36797
36917
|
exports.PolyStar = PolyStar;
|