@galacean/effects-threejs 2.8.0-alpha.3 → 2.8.0-alpha.5

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 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.3
6
+ * Version: v2.8.0-alpha.5
7
7
  */
8
8
 
9
9
  'use strict';
@@ -2690,355 +2690,6 @@ function asserts(condition, msg) {
2690
2690
  return /^[^\d.][\w-]*$/.test(fontFamily);
2691
2691
  }
2692
2692
 
2693
- /**
2694
- * Simple implementation of the deferred pattern.
2695
- * An object that exposes a promise and functions to resolve and reject it.
2696
- */ var Deferred = function Deferred() {
2697
- var _this = this;
2698
- this.promise = new Promise(function(resolve, reject) {
2699
- _this.resolve = resolve;
2700
- _this.reject = reject;
2701
- });
2702
- };
2703
-
2704
- var prefix = "[Galacean Effects]";
2705
- var localLogger;
2706
- function format(message) {
2707
- return [
2708
- "%c" + prefix,
2709
- "color: #AA0100",
2710
- "" + message
2711
- ];
2712
- }
2713
- function error(message) {
2714
- for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
2715
- args[_key - 1] = arguments[_key];
2716
- }
2717
- var _console;
2718
- (_console = console).error.apply(_console, [].concat(format(message), [
2719
- args
2720
- ]));
2721
- localLogger == null ? void 0 : localLogger("error", message, args);
2722
- }
2723
- /**
2724
- * info 会转换成浏览器的 console.debug
2725
- * @param message
2726
- * @param args
2727
- */ function info(message) {
2728
- for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
2729
- args[_key - 1] = arguments[_key];
2730
- }
2731
- var _console;
2732
- (_console = console).debug.apply(_console, [].concat(format(message)));
2733
- localLogger == null ? void 0 : localLogger("info", message, args);
2734
- }
2735
- function warn(message) {
2736
- for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
2737
- args[_key - 1] = arguments[_key];
2738
- }
2739
- var _console;
2740
- (_console = console).warn.apply(_console, [].concat(format(message)));
2741
- localLogger == null ? void 0 : localLogger("warn", message, args);
2742
- }
2743
- /**
2744
- * 注册自定义埋点函数
2745
- *
2746
- * @param fn
2747
- */ function register(fn) {
2748
- if (fn && isFunction(fn)) {
2749
- localLogger = fn;
2750
- }
2751
- }
2752
- var logger = {
2753
- error: error,
2754
- info: info,
2755
- warn: warn,
2756
- register: register
2757
- };
2758
-
2759
- exports.DestroyOptions = void 0;
2760
- (function(DestroyOptions) {
2761
- DestroyOptions[DestroyOptions["destroy"] = 0] = "destroy";
2762
- DestroyOptions[DestroyOptions["keep"] = 1] = "keep";
2763
- DestroyOptions[DestroyOptions["force"] = 0] = "force";
2764
- })(exports.DestroyOptions || (exports.DestroyOptions = {}));
2765
- function noop() {}
2766
- /**
2767
- * 判断对象是否是`String`类型
2768
- *
2769
- * @static
2770
- * @function isString
2771
- * @param obj - 要判断的对象
2772
- * @return
2773
- */ function isString(obj) {
2774
- return typeof obj === "string";
2775
- }
2776
- /**
2777
- * 判断对象是否是`Array`类型
2778
- *
2779
- * @static
2780
- * @function isArray
2781
- * @param obj - 要判断的对象
2782
- * @return
2783
- */ var isArray = Array.isArray || function(obj) {
2784
- return Object.prototype.toString.call(obj) === "[object Array]";
2785
- };
2786
- /**
2787
- * 判断对象是否是函数类型
2788
- *
2789
- * @static
2790
- * @function isFunction
2791
- * @param obj - 要判断的对象
2792
- * @return
2793
- */ function isFunction(obj) {
2794
- return Object.prototype.toString.call(obj) === "[object Function]";
2795
- }
2796
- /**
2797
- * 判断对象是否是`Object`类型
2798
- *
2799
- * @static
2800
- * @function isObject
2801
- * @param obj - 要判断的对象
2802
- * @return
2803
- */ function isObject(obj) {
2804
- return Object.prototype.toString.call(obj) === "[object Object]";
2805
- }
2806
- /**
2807
- * 判断对象是否是`Plain Object`类型
2808
- *
2809
- * @param obj - 要判断的对象
2810
- * @returns
2811
- */ function isPlainObject(obj) {
2812
- if (obj === null || typeof obj !== "object") {
2813
- return false;
2814
- }
2815
- // 先排除 Array/Date/Map/Set/RegExp 等
2816
- if (Object.prototype.toString.call(obj) !== "[object Object]") {
2817
- return false;
2818
- }
2819
- var proto = Object.getPrototypeOf(obj);
2820
- if (proto === null) {
2821
- return true;
2822
- } // Object.create(null)
2823
- var hasOwn = Object.prototype.hasOwnProperty;
2824
- var Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
2825
- // 构造器需要是 Object(跨 realm 用函数源码比对)
2826
- return typeof Ctor === "function" && Function.prototype.toString.call(Ctor) === Function.prototype.toString.call(Object);
2827
- }
2828
- function isCanvas(canvas) {
2829
- var _canvas_tagName;
2830
- // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
2831
- return typeof canvas === "object" && canvas !== null && ((_canvas_tagName = canvas.tagName) == null ? void 0 : _canvas_tagName.toUpperCase()) === "CANVAS";
2832
- }
2833
- function isPowerOfTwo(value) {
2834
- return (value & value - 1) === 0 && value !== 0;
2835
- }
2836
- /**
2837
- * 生成一个位于 min 和 max 之间的随机数
2838
- * @param min
2839
- * @param max
2840
- * @returns
2841
- */ function randomInRange(min, max) {
2842
- return min + Math.random() * (max - min);
2843
- }
2844
- function throwDestroyedError() {
2845
- throw new Error("Destroyed item cannot be used again.");
2846
- }
2847
- function generateGUID() {
2848
- return v4().replace(/-/g, "");
2849
- }
2850
- function base64ToFile(base64, filename, contentType) {
2851
- if (filename === void 0) filename = "base64File";
2852
- if (contentType === void 0) contentType = "";
2853
- // 去掉 Base64 字符串的 Data URL 部分(如果存在)
2854
- var base64WithoutPrefix = base64.split(",")[1] || base64;
2855
- // 将 base64 编码的字符串转换为二进制字符串
2856
- var byteCharacters = atob(base64WithoutPrefix);
2857
- // 创建一个 8 位无符号整数值的数组,即“字节数组”
2858
- var byteArrays = [];
2859
- // 切割二进制字符串为多个片段,并将每个片段转换成一个字节数组
2860
- for(var offset = 0; offset < byteCharacters.length; offset += 512){
2861
- var slice = byteCharacters.slice(offset, offset + 512);
2862
- var byteNumbers = new Array(slice.length);
2863
- for(var i = 0; i < slice.length; i++){
2864
- byteNumbers[i] = slice.charCodeAt(i);
2865
- }
2866
- var byteArray = new Uint8Array(byteNumbers);
2867
- byteArrays.push(byteArray);
2868
- }
2869
- // 使用字节数组创建 Blob 对象
2870
- var blob = new Blob(byteArrays, {
2871
- type: contentType
2872
- });
2873
- // 创建 File 对象
2874
- var file = new File([
2875
- blob
2876
- ], filename, {
2877
- type: contentType
2878
- });
2879
- return file;
2880
- }
2881
- function applyMixins(derivedCtrl, baseCtrls) {
2882
- baseCtrls.forEach(function(baseCtrl) {
2883
- Object.getOwnPropertyNames(baseCtrl.prototype).forEach(function(name) {
2884
- var propertyDescriptor = Object.getOwnPropertyDescriptor(baseCtrl.prototype, name);
2885
- if (!propertyDescriptor) {
2886
- throw new Error("Cannot find property descriptor of class " + baseCtrl);
2887
- }
2888
- Object.defineProperty(derivedCtrl.prototype, name, propertyDescriptor);
2889
- });
2890
- });
2891
- }
2892
-
2893
- var pluginLoaderMap = {};
2894
- var plugins = [];
2895
- /**
2896
- * 注册 plugin
2897
- * @param name
2898
- * @param pluginClass class of plugin
2899
- * @param itemClass class of item
2900
- * @param isDefault load
2901
- */ function registerPlugin(name, pluginClass) {
2902
- if (pluginLoaderMap[name]) {
2903
- logger.error("Duplicate registration for plugin " + name + ".");
2904
- }
2905
- pluginLoaderMap[name] = pluginClass;
2906
- var pluginInstance = new pluginClass();
2907
- pluginInstance.name = name;
2908
- pluginInstance.initialize();
2909
- plugins.push(pluginInstance);
2910
- plugins.sort(function(a, b) {
2911
- return a.order - b.order;
2912
- });
2913
- }
2914
- /**
2915
- * 注销 plugin
2916
- */ function unregisterPlugin(name) {
2917
- delete pluginLoaderMap[name];
2918
- var pluginIndex = plugins.findIndex(function(plugin) {
2919
- return plugin.name === name;
2920
- });
2921
- if (pluginIndex !== -1) {
2922
- plugins.splice(pluginIndex, 1);
2923
- }
2924
- }
2925
- var PluginSystem = /*#__PURE__*/ function() {
2926
- function PluginSystem() {}
2927
- PluginSystem.getPlugins = function getPlugins() {
2928
- return plugins;
2929
- };
2930
- PluginSystem.initializeComposition = function initializeComposition(composition, scene) {
2931
- plugins.forEach(function(loader) {
2932
- return loader.onCompositionConstructed(composition, scene);
2933
- });
2934
- };
2935
- PluginSystem.destroyComposition = function destroyComposition(comp) {
2936
- plugins.forEach(function(loader) {
2937
- return loader.onCompositionDestroyed(comp);
2938
- });
2939
- };
2940
- PluginSystem.processAssets = function processAssets(scene, options) {
2941
- return _async_to_generator(function() {
2942
- return __generator(this, function(_state) {
2943
- return [
2944
- 2,
2945
- Promise.all(plugins.map(function(plugin) {
2946
- return plugin.processAssets(scene, options);
2947
- }))
2948
- ];
2949
- });
2950
- })();
2951
- };
2952
- PluginSystem.loadResources = function loadResources(scene, options, engine) {
2953
- plugins.forEach(function(loader) {
2954
- return loader.prepareResource(scene, options, engine);
2955
- });
2956
- };
2957
- return PluginSystem;
2958
- }();
2959
- var pluginInfoMap = {
2960
- "alipay-downgrade": "@galacean/effects-plugin-alipay-downgrade",
2961
- "downgrade": "@galacean/effects-plugin-downgrade",
2962
- "editor-gizmo": "@galacean/effects-plugin-editor-gizmo",
2963
- "ffd": "@galacean/effects-plugin-ffd",
2964
- "ktx2": "@galacean/effects-plugin-ktx2",
2965
- "model": "@galacean/effects-plugin-model",
2966
- "video": "@galacean/effects-plugin-multimedia",
2967
- "audio": "@galacean/effects-plugin-multimedia",
2968
- "orientation-transformer": "@galacean/effects-plugin-orientation-transformer",
2969
- "rich-text": "@galacean/effects-plugin-rich-text",
2970
- "spine": "@galacean/effects-plugin-spine"
2971
- };
2972
- function getPluginUsageInfo(name) {
2973
- var info = pluginInfoMap[name];
2974
- if (info) {
2975
- return "\n请按如下命令进行操作(Please follow the commands below to proceed):\n1、使用 npm 安装插件(Install Plugin):npm i " + info + "@latest --save\n2、导入插件(Import Plugin):import '" + info + "'";
2976
- } else {
2977
- return "";
2978
- }
2979
- }
2980
-
2981
- /**
2982
- * 抽象插件类
2983
- * 注册合成不同生命周期的回调函数
2984
- */ var AbstractPlugin = /*#__PURE__*/ function() {
2985
- function AbstractPlugin() {
2986
- this.order = 100;
2987
- this.name = "";
2988
- }
2989
- var _proto = AbstractPlugin.prototype;
2990
- _proto.initialize = function initialize() {};
2991
- /**
2992
- * loadScene 函数调用的时候会触发此函数,
2993
- * 此阶段可以加载插件所需类型资源,并返回原始资源和加载后的资源。
2994
- * @param scene
2995
- * @param options
2996
- * @returns
2997
- */ _proto.processAssets = function processAssets(scene, options) {
2998
- return _async_to_generator(function() {
2999
- return __generator(this, function(_state) {
3000
- return [
3001
- 2
3002
- ];
3003
- });
3004
- })();
3005
- };
3006
- /**
3007
- * loadScene 函数调用的时候会触发此函数,
3008
- * 此阶段时,json 中的图片和二进制已经被加载完成,可以对加载好的资源做进一步处理,
3009
- * 如果 promise 被 reject, loadScene 函数同样会被 reject,表示场景加载失败。
3010
- * 请记住,整个 load 阶段都不要创建 GL 相关的对象,只创建 JS 对象
3011
- * 此阶段晚于 processAssets
3012
- * @param {Scene} scene
3013
- * @param {SceneLoadOptions} options
3014
- */ _proto.prepareResource = function prepareResource(scene, options, engine) {};
3015
- _proto.onCompositionConstructed = function onCompositionConstructed(composition, scene) {};
3016
- _proto.onCompositionDestroyed = function onCompositionDestroyed(composition) {};
3017
- return AbstractPlugin;
3018
- }();
3019
-
3020
- function _set_prototype_of(o, p) {
3021
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
3022
- o.__proto__ = p;
3023
- return o;
3024
- };
3025
- return _set_prototype_of(o, p);
3026
- }
3027
-
3028
- function _inherits(subClass, superClass) {
3029
- if (typeof superClass !== "function" && superClass !== null) {
3030
- throw new TypeError("Super expression must either be null or a function");
3031
- }
3032
- subClass.prototype = Object.create(superClass && superClass.prototype, {
3033
- constructor: {
3034
- value: subClass,
3035
- writable: true,
3036
- configurable: true
3037
- }
3038
- });
3039
- if (superClass) _set_prototype_of(subClass, superClass);
3040
- }
3041
-
3042
2693
  /**
3043
2694
  * JSON 版本
3044
2695
  */ var JSONSceneVersion;
@@ -3786,6 +3437,17 @@ var NodeDataType;
3786
3437
  MultimediaType["video"] = "video";
3787
3438
  MultimediaType["audio"] = "audio";
3788
3439
  })(MultimediaType || (MultimediaType = {}));
3440
+ var HevcVideoCodec;
3441
+ (function(HevcVideoCodec) {
3442
+ HevcVideoCodec["L30"] = "hev1.1.0.L30.B0";
3443
+ HevcVideoCodec["L60"] = "hev1.1.0.L60.B0";
3444
+ HevcVideoCodec["L63"] = "hev1.1.0.L63.B0";
3445
+ HevcVideoCodec["L90"] = "hev1.1.0.L90.B0";
3446
+ HevcVideoCodec["L93"] = "hev1.1.0.L93.B0";
3447
+ HevcVideoCodec["L120"] = "hev1.1.0.L120.B0";
3448
+ HevcVideoCodec["L150"] = "hev1.1.0.L150.B0";
3449
+ HevcVideoCodec["L180"] = "hev1.1.0.L180.B0";
3450
+ })(HevcVideoCodec || (HevcVideoCodec = {}));
3789
3451
 
3790
3452
  var DataType;
3791
3453
  (function(DataType) {
@@ -3991,6 +3653,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
3991
3653
  get NodeDataType () { return NodeDataType; },
3992
3654
  get BackgroundType () { return BackgroundType; },
3993
3655
  get MultimediaType () { return MultimediaType; },
3656
+ get HevcVideoCodec () { return HevcVideoCodec; },
3994
3657
  get DataType () { return DataType; },
3995
3658
  get GeometryType () { return GeometryType; },
3996
3659
  get VertexFormatType () { return VertexFormatType; },
@@ -3998,6 +3661,391 @@ var index$1 = /*#__PURE__*/Object.freeze({
3998
3661
  get VertexBufferSemantic () { return VertexBufferSemantic; }
3999
3662
  });
4000
3663
 
3664
+ /**
3665
+ * Check if the browser can play the given HEVC codec.
3666
+ * @param codec - The HEVC codec to check.
3667
+ * @returns True if the browser can probably or maybe play the codec, false otherwise.
3668
+ */ function canPlayHevcCodec(codec) {
3669
+ var video = document.createElement("video");
3670
+ var contentType = 'video/mp4; codecs="' + codec + '"';
3671
+ var result = video.canPlayType(contentType);
3672
+ return result === "probably" || result === "maybe";
3673
+ }
3674
+ /**
3675
+ * Parse the given codec string into a HEVC video codec enum value.
3676
+ * @param codec - The codec string to parse.
3677
+ * @returns The corresponding HEVC video codec enum value, or undefined if the codec is invalid.
3678
+ */ function parseCodec(codec) {
3679
+ // 传入的是完整的枚举值
3680
+ if (isCodecValue(codec)) {
3681
+ return codec;
3682
+ }
3683
+ // 传入的是枚举名称
3684
+ if (isCodecKey(codec)) {
3685
+ return HevcVideoCodec[codec];
3686
+ }
3687
+ return undefined;
3688
+ }
3689
+ function isCodecValue(codec) {
3690
+ return Object.keys(HevcVideoCodec).some(function(key) {
3691
+ return HevcVideoCodec[key] === codec;
3692
+ });
3693
+ }
3694
+ function isCodecKey(codec) {
3695
+ return codec in HevcVideoCodec;
3696
+ }
3697
+
3698
+ /**
3699
+ * Simple implementation of the deferred pattern.
3700
+ * An object that exposes a promise and functions to resolve and reject it.
3701
+ */ var Deferred = function Deferred() {
3702
+ var _this = this;
3703
+ this.promise = new Promise(function(resolve, reject) {
3704
+ _this.resolve = resolve;
3705
+ _this.reject = reject;
3706
+ });
3707
+ };
3708
+
3709
+ var prefix = "[Galacean Effects]";
3710
+ var localLogger;
3711
+ function format(message) {
3712
+ return [
3713
+ "%c" + prefix,
3714
+ "color: #AA0100",
3715
+ "" + message
3716
+ ];
3717
+ }
3718
+ function error(message) {
3719
+ for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
3720
+ args[_key - 1] = arguments[_key];
3721
+ }
3722
+ var _console;
3723
+ (_console = console).error.apply(_console, [].concat(format(message), [
3724
+ args
3725
+ ]));
3726
+ localLogger == null ? void 0 : localLogger("error", message, args);
3727
+ }
3728
+ /**
3729
+ * info 会转换成浏览器的 console.debug
3730
+ * @param message
3731
+ * @param args
3732
+ */ function info(message) {
3733
+ for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
3734
+ args[_key - 1] = arguments[_key];
3735
+ }
3736
+ var _console;
3737
+ (_console = console).debug.apply(_console, [].concat(format(message)));
3738
+ localLogger == null ? void 0 : localLogger("info", message, args);
3739
+ }
3740
+ function warn(message) {
3741
+ for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
3742
+ args[_key - 1] = arguments[_key];
3743
+ }
3744
+ var _console;
3745
+ (_console = console).warn.apply(_console, [].concat(format(message)));
3746
+ localLogger == null ? void 0 : localLogger("warn", message, args);
3747
+ }
3748
+ /**
3749
+ * 注册自定义埋点函数
3750
+ *
3751
+ * @param fn
3752
+ */ function register(fn) {
3753
+ if (fn && isFunction(fn)) {
3754
+ localLogger = fn;
3755
+ }
3756
+ }
3757
+ var logger = {
3758
+ error: error,
3759
+ info: info,
3760
+ warn: warn,
3761
+ register: register
3762
+ };
3763
+
3764
+ exports.DestroyOptions = void 0;
3765
+ (function(DestroyOptions) {
3766
+ DestroyOptions[DestroyOptions["destroy"] = 0] = "destroy";
3767
+ DestroyOptions[DestroyOptions["keep"] = 1] = "keep";
3768
+ DestroyOptions[DestroyOptions["force"] = 0] = "force";
3769
+ })(exports.DestroyOptions || (exports.DestroyOptions = {}));
3770
+ function noop() {}
3771
+ /**
3772
+ * 判断对象是否是`String`类型
3773
+ *
3774
+ * @static
3775
+ * @function isString
3776
+ * @param obj - 要判断的对象
3777
+ * @return
3778
+ */ function isString(obj) {
3779
+ return typeof obj === "string";
3780
+ }
3781
+ /**
3782
+ * 判断对象是否是`Array`类型
3783
+ *
3784
+ * @static
3785
+ * @function isArray
3786
+ * @param obj - 要判断的对象
3787
+ * @return
3788
+ */ var isArray = Array.isArray || function(obj) {
3789
+ return Object.prototype.toString.call(obj) === "[object Array]";
3790
+ };
3791
+ /**
3792
+ * 判断对象是否是函数类型
3793
+ *
3794
+ * @static
3795
+ * @function isFunction
3796
+ * @param obj - 要判断的对象
3797
+ * @return
3798
+ */ function isFunction(obj) {
3799
+ return Object.prototype.toString.call(obj) === "[object Function]";
3800
+ }
3801
+ /**
3802
+ * 判断对象是否是`Object`类型
3803
+ *
3804
+ * @static
3805
+ * @function isObject
3806
+ * @param obj - 要判断的对象
3807
+ * @return
3808
+ */ function isObject(obj) {
3809
+ return Object.prototype.toString.call(obj) === "[object Object]";
3810
+ }
3811
+ /**
3812
+ * 判断对象是否是`Plain Object`类型
3813
+ *
3814
+ * @param obj - 要判断的对象
3815
+ * @returns
3816
+ */ function isPlainObject(obj) {
3817
+ if (obj === null || typeof obj !== "object") {
3818
+ return false;
3819
+ }
3820
+ // 先排除 Array/Date/Map/Set/RegExp 等
3821
+ if (Object.prototype.toString.call(obj) !== "[object Object]") {
3822
+ return false;
3823
+ }
3824
+ var proto = Object.getPrototypeOf(obj);
3825
+ if (proto === null) {
3826
+ return true;
3827
+ } // Object.create(null)
3828
+ var hasOwn = Object.prototype.hasOwnProperty;
3829
+ var Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
3830
+ // 构造器需要是 Object(跨 realm 用函数源码比对)
3831
+ return typeof Ctor === "function" && Function.prototype.toString.call(Ctor) === Function.prototype.toString.call(Object);
3832
+ }
3833
+ function isCanvas(canvas) {
3834
+ var _canvas_tagName;
3835
+ // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
3836
+ return typeof canvas === "object" && canvas !== null && ((_canvas_tagName = canvas.tagName) == null ? void 0 : _canvas_tagName.toUpperCase()) === "CANVAS";
3837
+ }
3838
+ function isPowerOfTwo(value) {
3839
+ return (value & value - 1) === 0 && value !== 0;
3840
+ }
3841
+ /**
3842
+ * 生成一个位于 min 和 max 之间的随机数
3843
+ * @param min
3844
+ * @param max
3845
+ * @returns
3846
+ */ function randomInRange(min, max) {
3847
+ return min + Math.random() * (max - min);
3848
+ }
3849
+ function throwDestroyedError() {
3850
+ throw new Error("Destroyed item cannot be used again.");
3851
+ }
3852
+ function generateGUID() {
3853
+ return v4().replace(/-/g, "");
3854
+ }
3855
+ function base64ToFile(base64, filename, contentType) {
3856
+ if (filename === void 0) filename = "base64File";
3857
+ if (contentType === void 0) contentType = "";
3858
+ // 去掉 Base64 字符串的 Data URL 部分(如果存在)
3859
+ var base64WithoutPrefix = base64.split(",")[1] || base64;
3860
+ // 将 base64 编码的字符串转换为二进制字符串
3861
+ var byteCharacters = atob(base64WithoutPrefix);
3862
+ // 创建一个 8 位无符号整数值的数组,即“字节数组”
3863
+ var byteArrays = [];
3864
+ // 切割二进制字符串为多个片段,并将每个片段转换成一个字节数组
3865
+ for(var offset = 0; offset < byteCharacters.length; offset += 512){
3866
+ var slice = byteCharacters.slice(offset, offset + 512);
3867
+ var byteNumbers = new Array(slice.length);
3868
+ for(var i = 0; i < slice.length; i++){
3869
+ byteNumbers[i] = slice.charCodeAt(i);
3870
+ }
3871
+ var byteArray = new Uint8Array(byteNumbers);
3872
+ byteArrays.push(byteArray);
3873
+ }
3874
+ // 使用字节数组创建 Blob 对象
3875
+ var blob = new Blob(byteArrays, {
3876
+ type: contentType
3877
+ });
3878
+ // 创建 File 对象
3879
+ var file = new File([
3880
+ blob
3881
+ ], filename, {
3882
+ type: contentType
3883
+ });
3884
+ return file;
3885
+ }
3886
+ function applyMixins(derivedCtrl, baseCtrls) {
3887
+ baseCtrls.forEach(function(baseCtrl) {
3888
+ Object.getOwnPropertyNames(baseCtrl.prototype).forEach(function(name) {
3889
+ var propertyDescriptor = Object.getOwnPropertyDescriptor(baseCtrl.prototype, name);
3890
+ if (!propertyDescriptor) {
3891
+ throw new Error("Cannot find property descriptor of class " + baseCtrl);
3892
+ }
3893
+ Object.defineProperty(derivedCtrl.prototype, name, propertyDescriptor);
3894
+ });
3895
+ });
3896
+ }
3897
+
3898
+ var pluginLoaderMap = {};
3899
+ var plugins = [];
3900
+ /**
3901
+ * 注册 plugin
3902
+ * @param name
3903
+ * @param pluginClass class of plugin
3904
+ * @param itemClass class of item
3905
+ * @param isDefault load
3906
+ */ function registerPlugin(name, pluginClass) {
3907
+ if (pluginLoaderMap[name]) {
3908
+ logger.error("Duplicate registration for plugin " + name + ".");
3909
+ }
3910
+ pluginLoaderMap[name] = pluginClass;
3911
+ var pluginInstance = new pluginClass();
3912
+ pluginInstance.name = name;
3913
+ plugins.push(pluginInstance);
3914
+ plugins.sort(function(a, b) {
3915
+ return a.order - b.order;
3916
+ });
3917
+ }
3918
+ /**
3919
+ * 注销 plugin
3920
+ */ function unregisterPlugin(name) {
3921
+ delete pluginLoaderMap[name];
3922
+ var pluginIndex = plugins.findIndex(function(plugin) {
3923
+ return plugin.name === name;
3924
+ });
3925
+ if (pluginIndex !== -1) {
3926
+ plugins.splice(pluginIndex, 1);
3927
+ }
3928
+ }
3929
+ var PluginSystem = /*#__PURE__*/ function() {
3930
+ function PluginSystem() {}
3931
+ PluginSystem.getPlugins = function getPlugins() {
3932
+ return plugins;
3933
+ };
3934
+ PluginSystem.initializeComposition = function initializeComposition(composition, scene) {
3935
+ plugins.forEach(function(loader) {
3936
+ return loader.onCompositionCreated(composition, scene);
3937
+ });
3938
+ };
3939
+ PluginSystem.destroyComposition = function destroyComposition(comp) {
3940
+ plugins.forEach(function(loader) {
3941
+ return loader.onCompositionDestroy(comp);
3942
+ });
3943
+ };
3944
+ PluginSystem.onAssetsLoadStart = function onAssetsLoadStart(scene, options) {
3945
+ return _async_to_generator(function() {
3946
+ return __generator(this, function(_state) {
3947
+ return [
3948
+ 2,
3949
+ Promise.all(plugins.map(function(plugin) {
3950
+ return plugin.onAssetsLoadStart(scene, options);
3951
+ }))
3952
+ ];
3953
+ });
3954
+ })();
3955
+ };
3956
+ PluginSystem.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {
3957
+ plugins.forEach(function(loader) {
3958
+ return loader.onAssetsLoadFinish(scene, options, engine);
3959
+ });
3960
+ };
3961
+ return PluginSystem;
3962
+ }();
3963
+ var pluginInfoMap = {
3964
+ "alipay-downgrade": "@galacean/effects-plugin-alipay-downgrade",
3965
+ "downgrade": "@galacean/effects-plugin-downgrade",
3966
+ "editor-gizmo": "@galacean/effects-plugin-editor-gizmo",
3967
+ "ffd": "@galacean/effects-plugin-ffd",
3968
+ "ktx2": "@galacean/effects-plugin-ktx2",
3969
+ "model": "@galacean/effects-plugin-model",
3970
+ "video": "@galacean/effects-plugin-multimedia",
3971
+ "audio": "@galacean/effects-plugin-multimedia",
3972
+ "orientation-transformer": "@galacean/effects-plugin-orientation-transformer",
3973
+ "rich-text": "@galacean/effects-plugin-rich-text",
3974
+ "spine": "@galacean/effects-plugin-spine"
3975
+ };
3976
+ function getPluginUsageInfo(name) {
3977
+ var info = pluginInfoMap[name];
3978
+ if (info) {
3979
+ return "\n请按如下命令进行操作(Please follow the commands below to proceed):\n1、使用 npm 安装插件(Install Plugin):npm i " + info + "@latest --save\n2、导入插件(Import Plugin):import '" + info + "'";
3980
+ } else {
3981
+ return "";
3982
+ }
3983
+ }
3984
+
3985
+ /**
3986
+ * 抽象插件类
3987
+ * 注册合成不同生命周期的回调函数
3988
+ */ var Plugin = /*#__PURE__*/ function() {
3989
+ function Plugin() {
3990
+ this.order = 100;
3991
+ this.name = "Plugin";
3992
+ }
3993
+ var _proto = Plugin.prototype;
3994
+ /**
3995
+ * 场景加载时触发,用于加载插件所需的自定义资源。
3996
+ * 此阶段适合发起异步资源请求。
3997
+ * @param scene - 场景对象
3998
+ * @param options - 场景加载选项
3999
+ */ _proto.onAssetsLoadStart = function onAssetsLoadStart(scene, options) {
4000
+ return _async_to_generator(function() {
4001
+ return __generator(this, function(_state) {
4002
+ return [
4003
+ 2
4004
+ ];
4005
+ });
4006
+ })();
4007
+ };
4008
+ /**
4009
+ * 场景资源加载完成后触发。
4010
+ * 此时 JSON 中的图片和二进制已加载完成,可对资源做进一步处理。
4011
+ * @param scene - 场景对象
4012
+ * @param options - 场景加载选项
4013
+ * @param engine - 引擎实例
4014
+ */ _proto.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {};
4015
+ /**
4016
+ * 合成创建完成后触发。
4017
+ * @param composition - 合成对象
4018
+ * @param scene - 场景对象
4019
+ */ _proto.onCompositionCreated = function onCompositionCreated(composition, scene) {};
4020
+ /**
4021
+ * 合成销毁时触发。
4022
+ * @param composition - 合成对象
4023
+ */ _proto.onCompositionDestroy = function onCompositionDestroy(composition) {};
4024
+ return Plugin;
4025
+ }();
4026
+
4027
+ function _set_prototype_of(o, p) {
4028
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
4029
+ o.__proto__ = p;
4030
+ return o;
4031
+ };
4032
+ return _set_prototype_of(o, p);
4033
+ }
4034
+
4035
+ function _inherits(subClass, superClass) {
4036
+ if (typeof superClass !== "function" && superClass !== null) {
4037
+ throw new TypeError("Super expression must either be null or a function");
4038
+ }
4039
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
4040
+ constructor: {
4041
+ value: subClass,
4042
+ writable: true,
4043
+ configurable: true
4044
+ }
4045
+ });
4046
+ if (superClass) _set_prototype_of(subClass, superClass);
4047
+ }
4048
+
4001
4049
  function _array_like_to_array(arr, len) {
4002
4050
  if (len == null || len > arr.length) len = arr.length;
4003
4051
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -10674,6 +10722,9 @@ var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
10674
10722
  stencilAction: exports.TextureLoadAction.clear
10675
10723
  });
10676
10724
  }
10725
+ this.meshes.sort(function(a, b) {
10726
+ return a.priority - b.priority;
10727
+ });
10677
10728
  renderer.renderMeshes(this.meshes);
10678
10729
  };
10679
10730
  _proto.onCameraCleanup = function onCameraCleanup(renderer) {
@@ -16611,13 +16662,49 @@ exports.CameraController = __decorate([
16611
16662
  effectsClass(DataType.CameraController)
16612
16663
  ], exports.CameraController);
16613
16664
 
16614
- var CameraVFXItemLoader = /*#__PURE__*/ function(AbstractPlugin) {
16615
- _inherits(CameraVFXItemLoader, AbstractPlugin);
16665
+ function _get_prototype_of(o) {
16666
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
16667
+ return o.__proto__ || Object.getPrototypeOf(o);
16668
+ };
16669
+ return _get_prototype_of(o);
16670
+ }
16671
+
16672
+ function _is_native_function(fn) {
16673
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
16674
+ }
16675
+
16676
+ function _wrap_native_super(Class) {
16677
+ var _cache = typeof Map === "function" ? new Map() : undefined;
16678
+ _wrap_native_super = function _wrap_native_super(Class) {
16679
+ if (Class === null || !_is_native_function(Class)) return Class;
16680
+ if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
16681
+ if (typeof _cache !== "undefined") {
16682
+ if (_cache.has(Class)) return _cache.get(Class);
16683
+ _cache.set(Class, Wrapper);
16684
+ }
16685
+ function Wrapper() {
16686
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
16687
+ }
16688
+ Wrapper.prototype = Object.create(Class.prototype, {
16689
+ constructor: {
16690
+ value: Wrapper,
16691
+ enumerable: false,
16692
+ writable: true,
16693
+ configurable: true
16694
+ }
16695
+ });
16696
+ return _set_prototype_of(Wrapper, Class);
16697
+ };
16698
+ return _wrap_native_super(Class);
16699
+ }
16700
+
16701
+ var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
16702
+ _inherits(CameraVFXItemLoader, Plugin);
16616
16703
  function CameraVFXItemLoader() {
16617
- return AbstractPlugin.apply(this, arguments);
16704
+ return Plugin.apply(this, arguments);
16618
16705
  }
16619
16706
  return CameraVFXItemLoader;
16620
- }(AbstractPlugin);
16707
+ }(_wrap_native_super(Plugin));
16621
16708
 
16622
16709
  exports.HitTestType = void 0;
16623
16710
  (function(HitTestType) {
@@ -16901,13 +16988,13 @@ function getCoord(event) {
16901
16988
  };
16902
16989
  }
16903
16990
 
16904
- var InteractLoader = /*#__PURE__*/ function(AbstractPlugin) {
16905
- _inherits(InteractLoader, AbstractPlugin);
16991
+ var InteractLoader = /*#__PURE__*/ function(Plugin) {
16992
+ _inherits(InteractLoader, Plugin);
16906
16993
  function InteractLoader() {
16907
- return AbstractPlugin.apply(this, arguments);
16994
+ return Plugin.apply(this, arguments);
16908
16995
  }
16909
16996
  return InteractLoader;
16910
- }(AbstractPlugin);
16997
+ }(_wrap_native_super(Plugin));
16911
16998
 
16912
16999
  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
17000
  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 +17593,16 @@ function shouldIgnoreBouncing(arg, mul) {
17506
17593
  return MeshCollider;
17507
17594
  }();
17508
17595
 
17509
- var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17510
- _inherits(SpriteLoader, AbstractPlugin);
17596
+ var SpriteLoader = /*#__PURE__*/ function(Plugin) {
17597
+ _inherits(SpriteLoader, Plugin);
17511
17598
  function SpriteLoader() {
17512
17599
  var _this;
17513
- _this = AbstractPlugin.apply(this, arguments) || this;
17600
+ _this = Plugin.apply(this, arguments) || this;
17514
17601
  _this.name = "sprite";
17515
17602
  return _this;
17516
17603
  }
17517
17604
  return SpriteLoader;
17518
- }(AbstractPlugin);
17605
+ }(_wrap_native_super(Plugin));
17519
17606
 
17520
17607
  /**
17521
17608
  * 动画图可播放节点对象
@@ -20006,7 +20093,7 @@ function calculateDirection(prePoint, point, nextPoint) {
20006
20093
  if (this.time >= 0 && this.time < particleSystem.item.duration && particleSystem.isEnded()) {
20007
20094
  particleSystem.reset();
20008
20095
  }
20009
- particleSystem.update(this.time - particleSystem.time);
20096
+ particleSystem.simulate(this.time - particleSystem.time);
20010
20097
  }
20011
20098
  this.lastTime = this.time;
20012
20099
  };
@@ -21457,126 +21544,133 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
21457
21544
  this.initEmitterTransform();
21458
21545
  };
21459
21546
  _proto.onUpdate = function onUpdate(dt) {
21460
- this.update(dt);
21547
+ if (!this.frozen) {
21548
+ this.update(dt);
21549
+ }
21550
+ };
21551
+ _proto.simulate = function simulate(time) {
21552
+ this.update(time * 1000);
21553
+ this.frozen = true;
21461
21554
  };
21462
21555
  _proto.update = function update(delta) {
21463
21556
  var _this = this;
21464
- if (this.started && !this.frozen) {
21465
- var now = this.time + delta / 1000;
21466
- var options = this.options;
21467
- var loopStartTime = this.loopStartTime;
21468
- var emission = this.emission;
21469
- this.time = now;
21470
- this.upDirectionWorld = null;
21471
- this.renderer.updateTime(now, delta);
21472
- var link = this.particleLink;
21473
- var emitterLifetime = (now - loopStartTime) / this.item.duration;
21474
- var timePassed = this.timePassed;
21475
- var trailUpdated = false;
21476
- var updateTrail = function() {
21477
- if (_this.trails && !trailUpdated) {
21478
- trailUpdated = true;
21479
- link.forEach(function(param) {
21480
- var time = param[0], pointIndex = param[1], delay = param[2], point = param[3];
21481
- if (time < timePassed) {
21482
- _this.clearPointTrail(pointIndex);
21483
- } else if (timePassed > delay) {
21484
- _this.updatePointTrail(pointIndex, emitterLifetime, point, delay);
21485
- }
21486
- });
21557
+ if (!this.started) {
21558
+ return;
21559
+ }
21560
+ var now = this.time + delta / 1000;
21561
+ var options = this.options;
21562
+ var loopStartTime = this.loopStartTime;
21563
+ var emission = this.emission;
21564
+ this.time = now;
21565
+ this.upDirectionWorld = null;
21566
+ this.renderer.updateTime(now, delta);
21567
+ var link = this.particleLink;
21568
+ var emitterLifetime = (now - loopStartTime) / this.item.duration;
21569
+ var timePassed = this.timePassed;
21570
+ var trailUpdated = false;
21571
+ var updateTrail = function() {
21572
+ if (_this.trails && !trailUpdated) {
21573
+ trailUpdated = true;
21574
+ link.forEach(function(param) {
21575
+ var time = param[0], pointIndex = param[1], delay = param[2], point = param[3];
21576
+ if (time < timePassed) {
21577
+ _this.clearPointTrail(pointIndex);
21578
+ } else if (timePassed > delay) {
21579
+ _this.updatePointTrail(pointIndex, emitterLifetime, point, delay);
21580
+ }
21581
+ });
21582
+ }
21583
+ };
21584
+ if (!this.ended) {
21585
+ var duration = this.item.duration;
21586
+ var lifetime = this.lifetime;
21587
+ if (timePassed < duration) {
21588
+ var interval = 1 / emission.rateOverTime.getValue(lifetime);
21589
+ var pointCount = Math.floor((timePassed - this.lastEmitTime) / interval);
21590
+ var maxEmissionCount = pointCount;
21591
+ var timeDelta = interval / pointCount;
21592
+ var meshTime = now;
21593
+ var maxCount = options.maxCount;
21594
+ this.updateEmitterTransform(timePassed);
21595
+ var shouldSkipGenerate = function() {
21596
+ var first = link.first;
21597
+ return _this.emissionStopped || link.length === maxCount && first && first.content[0] - loopStartTime > timePassed;
21598
+ };
21599
+ for(var i = 0; i < maxEmissionCount && i < maxCount; i++){
21600
+ if (shouldSkipGenerate()) {
21601
+ break;
21602
+ }
21603
+ var p = this.createPoint(lifetime);
21604
+ p.delay += meshTime + i * timeDelta;
21605
+ this.addParticle(p, maxCount);
21606
+ this.lastEmitTime = timePassed;
21487
21607
  }
21488
- };
21489
- if (!this.ended) {
21490
- var duration = this.item.duration;
21491
- var lifetime = this.lifetime;
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;
21608
+ var bursts = emission.bursts;
21609
+ for(var j = (bursts == null ? void 0 : bursts.length) - 1, cursor = 0; j >= 0 && cursor < maxCount; j--){
21610
+ if (shouldSkipGenerate()) {
21611
+ break;
21512
21612
  }
21513
- var bursts = emission.bursts;
21514
- for(var j = (bursts == null ? void 0 : bursts.length) - 1, cursor = 0; j >= 0 && cursor < maxCount; j--){
21515
- if (shouldSkipGenerate()) {
21516
- break;
21613
+ var burst = bursts[j];
21614
+ var opts = !burst.disabled && burst.getGeneratorOptions(timePassed, lifetime);
21615
+ if (opts) {
21616
+ var originVec = [
21617
+ 0,
21618
+ 0,
21619
+ 0
21620
+ ];
21621
+ var offsets = emission.burstOffsets[j];
21622
+ var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
21623
+ if (burst.once) {
21624
+ this.removeBurst(j);
21517
21625
  }
21518
- var burst = bursts[j];
21519
- var opts = !burst.disabled && burst.getGeneratorOptions(timePassed, lifetime);
21520
- if (opts) {
21521
- var originVec = [
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);
21626
+ for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
21627
+ var _p_transform;
21628
+ if (shouldSkipGenerate()) {
21629
+ break;
21546
21630
  }
21631
+ var p1 = this.initPoint(this.shape.generate({
21632
+ total: opts.total,
21633
+ index: opts.index,
21634
+ burstIndex: i1,
21635
+ burstCount: opts.count
21636
+ }));
21637
+ p1.delay += meshTime;
21638
+ cursor++;
21639
+ (_p_transform = p1.transform).translate.apply(_p_transform, [].concat(burstOffset));
21640
+ this.addParticle(p1, maxCount);
21547
21641
  }
21548
21642
  }
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
21643
  }
21570
- } else if (this.item.endBehavior !== EndBehavior.restart) {
21571
- if (EndBehavior.destroy === this.item.endBehavior) {
21572
- var node = link.last;
21573
- if (node && node.content[0] < this.time) {
21574
- this.destroyed = true;
21575
- }
21644
+ } else if (this.item.endBehavior === EndBehavior.restart) {
21645
+ updateTrail();
21646
+ this.loopStartTime = now - duration;
21647
+ this.lastEmitTime -= duration;
21648
+ this.time -= duration;
21649
+ emission.bursts.forEach(function(b) {
21650
+ return b.reset();
21651
+ });
21652
+ this.particleLink.forEach(function(content) {
21653
+ content[0] -= duration;
21654
+ content[2] -= duration;
21655
+ content[3].delay -= duration;
21656
+ });
21657
+ this.renderer.minusTimeForLoop(duration);
21658
+ } else {
21659
+ this.ended = true;
21660
+ var endBehavior = this.item.endBehavior;
21661
+ if (endBehavior === EndBehavior.freeze) {
21662
+ this.frozen = true;
21663
+ }
21664
+ }
21665
+ } else if (this.item.endBehavior !== EndBehavior.restart) {
21666
+ if (EndBehavior.destroy === this.item.endBehavior) {
21667
+ var node = link.last;
21668
+ if (node && node.content[0] < this.time) {
21669
+ this.destroyed = true;
21576
21670
  }
21577
21671
  }
21578
- updateTrail();
21579
21672
  }
21673
+ updateTrail();
21580
21674
  };
21581
21675
  _proto.drawStencilMask = function drawStencilMask(renderer) {
21582
21676
  if (!this.isActiveAndEnabled) {
@@ -25616,7 +25710,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
25616
25710
  _this = MaskableGraphic.call(this, engine) || this;
25617
25711
  _this.time = 0;
25618
25712
  _this.duration = 1;
25619
- _this.loop = true;
25620
25713
  /**
25621
25714
  * @internal
25622
25715
  */ _this.splits = singleSplits;
@@ -25631,11 +25724,13 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
25631
25724
  var _this = this;
25632
25725
  var time = this.time;
25633
25726
  var duration = this.duration;
25634
- if (time > duration && this.loop) {
25727
+ var textureAnimation = this.textureSheetAnimation;
25728
+ var _textureAnimation_loop;
25729
+ var loop = (_textureAnimation_loop = textureAnimation == null ? void 0 : textureAnimation.loop) != null ? _textureAnimation_loop : true;
25730
+ if (time > duration && loop) {
25635
25731
  time = time % duration;
25636
25732
  }
25637
25733
  var life = Math.min(Math.max(time / duration, 0.0), 1.0);
25638
- var ta = this.textureSheetAnimation;
25639
25734
  var video = this.renderer.texture.source.video;
25640
25735
  if (video) {
25641
25736
  if (time === 0) {
@@ -25647,9 +25742,9 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
25647
25742
  }
25648
25743
  this.renderer.texture.uploadCurrentVideoFrame();
25649
25744
  }
25650
- if (ta) {
25745
+ if (textureAnimation) {
25651
25746
  var _this_material_getVector4;
25652
- var total = ta.total || ta.row * ta.col;
25747
+ var total = textureAnimation.total || textureAnimation.row * textureAnimation.col;
25653
25748
  var texRectX = 0;
25654
25749
  var texRectY = 0;
25655
25750
  var texRectW = 1;
@@ -25670,20 +25765,20 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
25670
25765
  }
25671
25766
  var dx, dy;
25672
25767
  if (flip) {
25673
- dx = 1 / ta.row * texRectW;
25674
- dy = 1 / ta.col * texRectH;
25768
+ dx = 1 / textureAnimation.row * texRectW;
25769
+ dy = 1 / textureAnimation.col * texRectH;
25675
25770
  } else {
25676
- dx = 1 / ta.col * texRectW;
25677
- dy = 1 / ta.row * texRectH;
25771
+ dx = 1 / textureAnimation.col * texRectW;
25772
+ dy = 1 / textureAnimation.row * texRectH;
25678
25773
  }
25679
25774
  var texOffset;
25680
- if (ta.animate) {
25775
+ if (textureAnimation.animate) {
25681
25776
  var frameIndex = Math.round(life * (total - 1));
25682
- var yIndex = Math.floor(frameIndex / ta.col);
25683
- var xIndex = frameIndex - yIndex * ta.col;
25777
+ var yIndex = Math.floor(frameIndex / textureAnimation.col);
25778
+ var xIndex = frameIndex - yIndex * textureAnimation.col;
25684
25779
  texOffset = flip ? [
25685
25780
  dx * yIndex,
25686
- dy * (ta.col - xIndex)
25781
+ dy * (textureAnimation.col - xIndex)
25687
25782
  ] : [
25688
25783
  dx * xIndex,
25689
25784
  dy * (1 + yIndex)
@@ -25871,8 +25966,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
25871
25966
  var _data_duration;
25872
25967
  //@ts-expect-error
25873
25968
  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
25969
  };
25877
25970
  return SpriteComponent;
25878
25971
  }(MaskableGraphic);
@@ -25880,21 +25973,21 @@ exports.SpriteComponent = __decorate([
25880
25973
  effectsClass(DataType.SpriteComponent)
25881
25974
  ], exports.SpriteComponent);
25882
25975
 
25883
- var ParticleLoader = /*#__PURE__*/ function(AbstractPlugin) {
25884
- _inherits(ParticleLoader, AbstractPlugin);
25976
+ var ParticleLoader = /*#__PURE__*/ function(Plugin) {
25977
+ _inherits(ParticleLoader, Plugin);
25885
25978
  function ParticleLoader() {
25886
- return AbstractPlugin.apply(this, arguments);
25979
+ return Plugin.apply(this, arguments);
25887
25980
  }
25888
25981
  return ParticleLoader;
25889
- }(AbstractPlugin);
25982
+ }(_wrap_native_super(Plugin));
25890
25983
 
25891
- var CalculateLoader = /*#__PURE__*/ function(AbstractPlugin) {
25892
- _inherits(CalculateLoader, AbstractPlugin);
25984
+ var CalculateLoader = /*#__PURE__*/ function(Plugin) {
25985
+ _inherits(CalculateLoader, Plugin);
25893
25986
  function CalculateLoader() {
25894
- return AbstractPlugin.apply(this, arguments);
25987
+ return Plugin.apply(this, arguments);
25895
25988
  }
25896
25989
  return CalculateLoader;
25897
- }(AbstractPlugin);
25990
+ }(_wrap_native_super(Plugin));
25898
25991
 
25899
25992
  // Based on:
25900
25993
  /**
@@ -28996,6 +29089,12 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
28996
29089
  /**
28997
29090
  * 每一行文本的最大宽度
28998
29091
  */ _this.maxLineWidth = 0;
29092
+ /**
29093
+ * 初始文本宽度,用于计算缩放比例
29094
+ */ _this.baseTextWidth = 0;
29095
+ /**
29096
+ * 初始 `transform.size.x`,用于按比例更新显示宽度
29097
+ */ _this.baseScaleX = 1;
28999
29098
  _this.name = "MText" + seed$2++;
29000
29099
  // 初始化canvas资源
29001
29100
  _this.canvas = canvasPool.getCanvas();
@@ -29021,10 +29120,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29021
29120
  text: "默认文本",
29022
29121
  fontFamily: "AlibabaSans-BoldItalic",
29023
29122
  fontSize: 40,
29123
+ // 统一使用 0-1 颜色值
29024
29124
  textColor: [
29025
- 255,
29026
- 255,
29027
- 255,
29125
+ 1,
29126
+ 1,
29127
+ 1,
29028
29128
  1
29029
29129
  ],
29030
29130
  fontWeight: TextWeight.normal,
@@ -29061,6 +29161,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29061
29161
  // TextComponentBase
29062
29162
  this.updateWithOptions(options);
29063
29163
  this.renderText(options);
29164
+ // 记录初始的 textWidth 和 x 缩放,用于后续按比例更新显示宽度
29165
+ // 添加兜底值 1 防止除 0
29166
+ this.baseTextWidth = options.textWidth || this.textLayout.width || 1;
29167
+ this.baseScaleX = this.item.transform.size.x;
29064
29168
  // 恢复默认颜色
29065
29169
  this.material.setColor("_Color", new Color(1, 1, 1, 1));
29066
29170
  };
@@ -29259,9 +29363,9 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29259
29363
  if (style.isOutlined) {
29260
29364
  _this.setupOutline();
29261
29365
  }
29262
- // 文本颜色 - 直接使用 vec4 原值,不乘以 255
29366
+ // textColor 统一是 0-1,写入 canvas 时乘 255
29263
29367
  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 + ")";
29368
+ context.fillStyle = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
29265
29369
  var charsInfo = [];
29266
29370
  var x = 0;
29267
29371
  var y = layout.getOffsetY(style, _this.lineCount, lineHeight, fontSize);
@@ -29323,6 +29427,31 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29323
29427
  layout.autoWidth = normalizedValue;
29324
29428
  this.isDirty = true;
29325
29429
  };
29430
+ /**
29431
+ * 设置文本框宽度
29432
+ * 手动设置宽度时会自动关闭 `autoWidth`
29433
+ * 同时会按比例更新 `transform.size.x`,让 UI 框宽度也跟着变化
29434
+ * @param value - 文本框宽度
29435
+ */ _proto.setTextWidth = function setTextWidth(value) {
29436
+ var width = Math.max(0, Number(value) || 0);
29437
+ var layout = this.textLayout;
29438
+ // 宽度没变且已是非 autoWidth 模式,直接返回
29439
+ if (layout.width === width && layout.autoWidth === false) {
29440
+ return;
29441
+ }
29442
+ // 手动设置宽度时关闭 autoWidth
29443
+ layout.autoWidth = false;
29444
+ layout.width = width;
29445
+ // 按当前 overflow 模式重新计算行数和 maxLineWidth
29446
+ this.lineCount = this.getLineCount(this.text || "");
29447
+ this.isDirty = true;
29448
+ // 同步更新外层显示宽度(按比例缩放 transform)
29449
+ // 这样 UI 框的视觉宽度也会跟着文本宽度变化
29450
+ if (this.baseTextWidth > 0) {
29451
+ var scale = width / this.baseTextWidth;
29452
+ this.item.transform.size.x = this.baseScaleX * scale;
29453
+ }
29454
+ };
29326
29455
  _proto.setFontSize = function setFontSize(value) {
29327
29456
  if (this.textStyle.fontSize === value) {
29328
29457
  return;
@@ -29390,13 +29519,13 @@ applyMixins(exports.TextComponent, [
29390
29519
  ]);
29391
29520
 
29392
29521
  // TODO: 注册必须用
29393
- var TextLoader = /*#__PURE__*/ function(AbstractPlugin) {
29394
- _inherits(TextLoader, AbstractPlugin);
29522
+ var TextLoader = /*#__PURE__*/ function(Plugin) {
29523
+ _inherits(TextLoader, Plugin);
29395
29524
  function TextLoader() {
29396
- return AbstractPlugin.apply(this, arguments);
29525
+ return Plugin.apply(this, arguments);
29397
29526
  }
29398
29527
  return TextLoader;
29399
- }(AbstractPlugin);
29528
+ }(_wrap_native_super(Plugin));
29400
29529
 
29401
29530
  var Asset = /*#__PURE__*/ function(EffectsObject) {
29402
29531
  _inherits(Asset, EffectsObject);
@@ -30453,6 +30582,10 @@ function version35Migration(json) {
30453
30582
  if (component.dataType === DataType.TextComponent || component.dataType === DataType.RichTextComponent && component.options) {
30454
30583
  ensureTextVerticalAlign(component.options);
30455
30584
  }
30585
+ // 处理文本颜色从 0-255 到 0-1 的转换
30586
+ if (component.dataType === DataType.TextComponent) {
30587
+ convertTextColorTo01(component.options);
30588
+ }
30456
30589
  }
30457
30590
  }
30458
30591
  //@ts-expect-error
@@ -30472,6 +30605,22 @@ function version35Migration(json) {
30472
30605
  options.TextVerticalAlign = options.textBaseline;
30473
30606
  }
30474
30607
  }
30608
+ /**
30609
+ * 将文本颜色从 0-255 转换到 0-1
30610
+ */ function convertTextColorTo01(options) {
30611
+ if (!options || !options.textColor) {
30612
+ return;
30613
+ }
30614
+ var textColor = options.textColor;
30615
+ var _textColor_;
30616
+ // 将 RGB 从 0-255 转换到 0-1(alpha 通道已经是 0-1,不需要转换)
30617
+ options.textColor = [
30618
+ textColor[0] / 255.0,
30619
+ textColor[1] / 255.0,
30620
+ textColor[2] / 255.0,
30621
+ (_textColor_ = textColor[3]) != null ? _textColor_ : 1
30622
+ ];
30623
+ }
30475
30624
  /**
30476
30625
  * 根据形状获取形状几何体数据
30477
30626
  * @param shape - 形状
@@ -31248,6 +31397,7 @@ function getStandardParticleContent(particle) {
31248
31397
  }
31249
31398
  var textureSheetAnimation = particle.textureSheetAnimation;
31250
31399
  if (textureSheetAnimation) {
31400
+ // @ts-expect-error
31251
31401
  ret.textureSheetAnimation = {
31252
31402
  row: textureSheetAnimation.row,
31253
31403
  col: textureSheetAnimation.col,
@@ -31377,6 +31527,7 @@ function getStandardSpriteContent(sprite, transform) {
31377
31527
  var ret = getStandardNullContent(sprite, transform);
31378
31528
  var texAni = sprite.textureSheetAnimation;
31379
31529
  if (texAni) {
31530
+ // @ts-expect-error
31380
31531
  ret.textureSheetAnimation = {
31381
31532
  row: texAni.row,
31382
31533
  col: texAni.col,
@@ -31394,7 +31545,7 @@ function getStandardSpriteContent(sprite, transform) {
31394
31545
  return ret;
31395
31546
  }
31396
31547
 
31397
- var version$2 = "2.8.0-alpha.3";
31548
+ var version$2 = "2.8.0-alpha.5";
31398
31549
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
31399
31550
  var standardVersion = /^(\d+)\.(\d+)$/;
31400
31551
  var reverseParticle = false;
@@ -32034,8 +32185,8 @@ var seed$1 = 1;
32034
32185
  };
32035
32186
  return [
32036
32187
  4,
32037
- hookTimeInfo("plugin:processAssets", function() {
32038
- return _this.processPluginAssets(scene);
32188
+ hookTimeInfo("plugin:onAssetsLoadStart", function() {
32189
+ return _this.onPluginSceneLoadStart(scene);
32039
32190
  })
32040
32191
  ];
32041
32192
  case 6:
@@ -32043,7 +32194,7 @@ var seed$1 = 1;
32043
32194
  _jsonScene_bins = jsonScene.bins, bins = _jsonScene_bins === void 0 ? [] : _jsonScene_bins, images = jsonScene.images, fonts = jsonScene.fonts;
32044
32195
  return [
32045
32196
  4,
32046
- Promise.all([
32197
+ Promise.all([].concat([
32047
32198
  hookTimeInfo("processBins", function() {
32048
32199
  return _this.processBins(bins);
32049
32200
  }),
@@ -32053,7 +32204,11 @@ var seed$1 = 1;
32053
32204
  hookTimeInfo("processFontURL", function() {
32054
32205
  return _this.processFontURL(fonts);
32055
32206
  })
32056
- ])
32207
+ ], _this.options.useHevcVideo ? [
32208
+ hookTimeInfo("processVideoURL", function() {
32209
+ return _this.processVideoURL(jsonScene);
32210
+ })
32211
+ ] : []))
32057
32212
  ];
32058
32213
  case 7:
32059
32214
  _ref = _state.sent(), loadedBins = _ref[0], loadedImages = _ref[1];
@@ -32323,7 +32478,7 @@ var seed$1 = 1;
32323
32478
  });
32324
32479
  })();
32325
32480
  };
32326
- _proto.processPluginAssets = function processPluginAssets(scene) {
32481
+ _proto.onPluginSceneLoadStart = function onPluginSceneLoadStart(scene) {
32327
32482
  var _this = this;
32328
32483
  return _async_to_generator(function() {
32329
32484
  return __generator(this, function(_state) {
@@ -32331,7 +32486,7 @@ var seed$1 = 1;
32331
32486
  case 0:
32332
32487
  return [
32333
32488
  4,
32334
- PluginSystem.processAssets(scene, _this.options)
32489
+ PluginSystem.onAssetsLoadStart(scene, _this.options)
32335
32490
  ];
32336
32491
  case 1:
32337
32492
  _state.sent();
@@ -32439,6 +32594,30 @@ var seed$1 = 1;
32439
32594
  });
32440
32595
  })();
32441
32596
  };
32597
+ _proto.processVideoURL = function processVideoURL(jsonScene) {
32598
+ return _async_to_generator(function() {
32599
+ return __generator(this, function(_state) {
32600
+ if (!(jsonScene == null ? void 0 : jsonScene.videos) || !Array.isArray(jsonScene.videos)) {
32601
+ return [
32602
+ 2
32603
+ ];
32604
+ }
32605
+ jsonScene.videos.forEach(function(video) {
32606
+ var hevc = video.hevc;
32607
+ if (!(hevc == null ? void 0 : hevc.url) || !(hevc == null ? void 0 : hevc.codec)) {
32608
+ return;
32609
+ }
32610
+ var codec = parseCodec(hevc.codec);
32611
+ if (codec && canPlayHevcCodec(codec)) {
32612
+ video.url = hevc.url;
32613
+ }
32614
+ });
32615
+ return [
32616
+ 2
32617
+ ];
32618
+ });
32619
+ })();
32620
+ };
32442
32621
  _proto.loadJSON = function loadJSON(url) {
32443
32622
  var _this = this;
32444
32623
  return _async_to_generator(function() {
@@ -35032,8 +35211,8 @@ var SceneLoader = /*#__PURE__*/ function() {
35032
35211
  case 1:
35033
35212
  loadedScene = _state.sent();
35034
35213
  engine.clearResources();
35035
- // 触发插件系统 pluginSystem 的回调 prepareResource
35036
- PluginSystem.loadResources(loadedScene, assetManager.options, engine);
35214
+ // 触发插件系统 pluginSystem 的回调 onAssetsLoadFinish
35215
+ PluginSystem.onAssetsLoadFinish(loadedScene, assetManager.options, engine);
35037
35216
  engine.assetService.prepareAssets(loadedScene, loadedScene.assets);
35038
35217
  engine.assetService.updateTextVariables(loadedScene, options.variables);
35039
35218
  engine.assetService.initializeTexture(loadedScene);
@@ -35095,7 +35274,7 @@ registerPlugin("sprite", SpriteLoader);
35095
35274
  registerPlugin("particle", ParticleLoader);
35096
35275
  registerPlugin("cal", CalculateLoader);
35097
35276
  registerPlugin("interact", InteractLoader);
35098
- var version$1 = "2.8.0-alpha.3";
35277
+ var version$1 = "2.8.0-alpha.5";
35099
35278
  logger.info("Core version: " + version$1 + ".");
35100
35279
 
35101
35280
  var _obj;
@@ -36389,8 +36568,8 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
36389
36568
  _$scene = _state.sent();
36390
36569
  engine = _this.engine;
36391
36570
  engine.clearResources();
36392
- // 触发插件系统 pluginSystem 的回调 prepareResource
36393
- PluginSystem.loadResources(_$scene, assetManager.options, engine);
36571
+ // 触发插件系统 pluginSystem 的回调 onAssetsLoadFinish
36572
+ PluginSystem.onAssetsLoadFinish(_$scene, assetManager.options, engine);
36394
36573
  _this.assetService.prepareAssets(_$scene, assetManager.getAssets());
36395
36574
  _this.assetService.updateTextVariables(_$scene, assetManager.options.variables);
36396
36575
  _this.assetService.initializeTexture(_$scene);
@@ -36685,10 +36864,9 @@ applyMixins(exports.ThreeTextComponent, [
36685
36864
  */ Mesh.create = function(engine, props) {
36686
36865
  return new ThreeMesh(engine, props);
36687
36866
  };
36688
- var version = "2.8.0-alpha.3";
36867
+ var version = "2.8.0-alpha.5";
36689
36868
  logger.info("THREEJS plugin version: " + version + ".");
36690
36869
 
36691
- exports.AbstractPlugin = AbstractPlugin;
36692
36870
  exports.ActivationMixerPlayable = ActivationMixerPlayable;
36693
36871
  exports.ActivationPlayable = ActivationPlayable;
36694
36872
  exports.AndNode = AndNode;
@@ -36792,6 +36970,7 @@ exports.PathSegments = PathSegments;
36792
36970
  exports.Playable = Playable;
36793
36971
  exports.PlayableAsset = PlayableAsset;
36794
36972
  exports.PlayableOutput = PlayableOutput;
36973
+ exports.Plugin = Plugin;
36795
36974
  exports.PluginSystem = PluginSystem;
36796
36975
  exports.PointerEventData = PointerEventData;
36797
36976
  exports.PolyStar = PolyStar;
@@ -36874,6 +37053,7 @@ exports.asserts = asserts;
36874
37053
  exports.base64ToFile = base64ToFile;
36875
37054
  exports.buildLine = buildLine;
36876
37055
  exports.calculateTranslation = calculateTranslation;
37056
+ exports.canPlayHevcCodec = canPlayHevcCodec;
36877
37057
  exports.canUseBOM = canUseBOM;
36878
37058
  exports.canvasPool = canvasPool;
36879
37059
  exports.closePointEps = closePointEps;
@@ -36967,6 +37147,7 @@ exports.noop = noop;
36967
37147
  exports.normalizeColor = normalizeColor;
36968
37148
  exports.numberToFix = numberToFix;
36969
37149
  exports.oldBezierKeyFramesToNew = oldBezierKeyFramesToNew;
37150
+ exports.parseCodec = parseCodec;
36970
37151
  exports.parsePercent = parsePercent$1;
36971
37152
  exports.particleFrag = particleFrag;
36972
37153
  exports.particleOriginTranslateMap = particleOriginTranslateMap$1;