@galacean/effects-core 2.2.6 → 2.3.0-alpha.1

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.
Files changed (26) hide show
  1. package/dist/components/base-render-component.d.ts +12 -4
  2. package/dist/components/shape-component.d.ts +92 -3
  3. package/dist/composition.d.ts +62 -2
  4. package/dist/config.d.ts +11 -0
  5. package/dist/downloader.d.ts +15 -0
  6. package/dist/index.js +1352 -676
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +1352 -677
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/math/value-getters/index.d.ts +1 -1
  11. package/dist/math/value-getters/{vector4-curve.d.ts → vector-curves.d.ts} +8 -0
  12. package/dist/plugins/shape/build-line.d.ts +32 -0
  13. package/dist/plugins/shape/graphics-path.d.ts +0 -4
  14. package/dist/plugins/shape/polygon.d.ts +0 -4
  15. package/dist/plugins/shape/shape-path.d.ts +0 -4
  16. package/dist/plugins/timeline/playable-assets/index.d.ts +1 -1
  17. package/dist/plugins/timeline/playable-assets/{vector4-property-playable-asset.d.ts → vector-property-playable-assets.d.ts} +5 -1
  18. package/dist/plugins/timeline/playables/color-property-mixer-playable.d.ts +5 -5
  19. package/dist/plugins/timeline/playables/float-property-mixer-playable.d.ts +4 -5
  20. package/dist/plugins/timeline/playables/index.d.ts +1 -1
  21. package/dist/plugins/timeline/playables/property-mixer-playable.d.ts +9 -0
  22. package/dist/plugins/timeline/playables/vector-property-mixer-playable.d.ts +11 -0
  23. package/dist/plugins/timeline/tracks/index.d.ts +1 -1
  24. package/dist/plugins/timeline/tracks/{vector4-property-track.d.ts → vector-property-track.d.ts} +3 -0
  25. package/package.json +2 -2
  26. package/dist/plugins/timeline/playables/vector4-property-mixer-playable.d.ts +0 -6
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.2.6
6
+ * Version: v2.3.0-alpha.1
7
7
  */
8
8
 
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -1018,6 +1018,26 @@ function _inherits(subClass, superClass) {
1018
1018
  if (superClass) _set_prototype_of(subClass, superClass);
1019
1019
  }
1020
1020
 
1021
+ /**
1022
+ * JSON 版本
1023
+ */ var JSONSceneVersion;
1024
+ (function(JSONSceneVersion) {
1025
+ JSONSceneVersion["1_0"] = "1.0";
1026
+ JSONSceneVersion["1_1"] = "1.1";
1027
+ JSONSceneVersion["1_2"] = "1.2";
1028
+ JSONSceneVersion["1_3"] = "1.3";
1029
+ JSONSceneVersion["1_5"] = "1.5";
1030
+ JSONSceneVersion["1_8"] = "1.8";
1031
+ JSONSceneVersion["2_0"] = "2.0";
1032
+ JSONSceneVersion["2_1"] = "2.1";
1033
+ JSONSceneVersion["2_2"] = "2.2";
1034
+ JSONSceneVersion["2_3"] = "2.3";
1035
+ JSONSceneVersion["2_4"] = "2.4";
1036
+ JSONSceneVersion["3_0"] = "3.0";
1037
+ JSONSceneVersion["3_1"] = "3.1";
1038
+ JSONSceneVersion["LATEST"] = "3.1";
1039
+ })(JSONSceneVersion || (JSONSceneVersion = {}));
1040
+
1021
1041
  /*********************************************/ /* 元素属性参数类型 */ /*********************************************/ /**
1022
1042
  * 渲染等级
1023
1043
  */ var RenderLevel;
@@ -1323,8 +1343,12 @@ var RenderFace;
1323
1343
  */ var END_BEHAVIOR_DESTROY_CHILDREN = 6;
1324
1344
  var CAMERA_CLIP_MODE_VERTICAL = 1;
1325
1345
  var CAMERA_CLIP_MODE_NORMAL = 0;
1326
- var MESSAGE_ITEM_PHRASE_BEGIN = 2;
1327
- var MESSAGE_ITEM_PHRASE_END = 1;
1346
+ /**
1347
+ * 消息开始
1348
+ */ var MESSAGE_ITEM_PHRASE_BEGIN = 2;
1349
+ /**
1350
+ * 消息结束
1351
+ */ var MESSAGE_ITEM_PHRASE_END = 1;
1328
1352
 
1329
1353
  var CameraClipMode;
1330
1354
  (function(CameraClipMode) {
@@ -1398,6 +1422,9 @@ var CameraClipMode;
1398
1422
  /**
1399
1423
  * Vector4 曲线
1400
1424
  */ ValueType[ValueType["VECTOR4_CURVE"] = 25] = "VECTOR4_CURVE";
1425
+ /**
1426
+ * Vector2 曲线
1427
+ */ ValueType[ValueType["VECTOR2_CURVE"] = 26] = "VECTOR2_CURVE";
1401
1428
  })(ValueType || (ValueType = {}));
1402
1429
  /**
1403
1430
  * 关键帧类型
@@ -1666,19 +1693,13 @@ var ShapePointType;
1666
1693
  var DataType;
1667
1694
  (function(DataType) {
1668
1695
  DataType["VFXItemData"] = "VFXItemData";
1669
- DataType["EffectComponent"] = "EffectComponent";
1696
+ // Assets
1670
1697
  DataType["Material"] = "Material";
1671
1698
  DataType["Shader"] = "Shader";
1672
- DataType["SpriteComponent"] = "SpriteComponent";
1673
- DataType["ParticleSystem"] = "ParticleSystem";
1674
- DataType["InteractComponent"] = "InteractComponent";
1675
- DataType["CameraController"] = "CameraController";
1676
- DataType["PostProcessVolume"] = "PostProcessVolume";
1677
1699
  DataType["Geometry"] = "Geometry";
1678
1700
  DataType["Texture"] = "Texture";
1679
1701
  DataType["Image"] = "Image";
1680
1702
  DataType["AnimationClip"] = "AnimationClip";
1681
- DataType["TextComponent"] = "TextComponent";
1682
1703
  DataType["BinaryAsset"] = "BinaryAsset";
1683
1704
  // Timeline
1684
1705
  DataType["TrackAsset"] = "TrackAsset";
@@ -1690,6 +1711,7 @@ var DataType;
1690
1711
  DataType["SubCompositionTrack"] = "SubCompositionTrack";
1691
1712
  DataType["FloatPropertyTrack"] = "FloatPropertyTrack";
1692
1713
  DataType["ColorPropertyTrack"] = "ColorPropertyTrack";
1714
+ DataType["Vector2PropertyTrack"] = "Vector2PropertyTrack";
1693
1715
  DataType["Vector4PropertyTrack"] = "Vector4PropertyTrack";
1694
1716
  DataType["TransformPlayableAsset"] = "TransformPlayableAsset";
1695
1717
  DataType["SpriteColorPlayableAsset"] = "SpriteColorPlayableAsset";
@@ -1697,6 +1719,9 @@ var DataType;
1697
1719
  DataType["SubCompositionPlayableAsset"] = "SubCompositionPlayableAsset";
1698
1720
  DataType["FloatPropertyPlayableAsset"] = "FloatPropertyPlayableAsset";
1699
1721
  DataType["ColorPropertyPlayableAsset"] = "ColorPropertyPlayableAsset";
1722
+ DataType["Vector2PropertyPlayableAsset"] = "Vector2PropertyPlayableAsset";
1723
+ DataType["Vector4PropertyPlayableAsset"] = "Vector4PropertyPlayableAsset";
1724
+ // Components
1700
1725
  DataType["MeshComponent"] = "MeshComponent";
1701
1726
  DataType["SkyboxComponent"] = "SkyboxComponent";
1702
1727
  DataType["LightComponent"] = "LightComponent";
@@ -1710,6 +1735,13 @@ var DataType;
1710
1735
  DataType["RichTextComponent"] = "RichTextComponent";
1711
1736
  DataType["OrientationComponent"] = "OrientationComponent";
1712
1737
  DataType["ShapeComponent"] = "ShapeComponent";
1738
+ DataType["SpriteComponent"] = "SpriteComponent";
1739
+ DataType["ParticleSystem"] = "ParticleSystem";
1740
+ DataType["InteractComponent"] = "InteractComponent";
1741
+ DataType["CameraController"] = "CameraController";
1742
+ DataType["PostProcessVolume"] = "PostProcessVolume";
1743
+ DataType["EffectComponent"] = "EffectComponent";
1744
+ DataType["TextComponent"] = "TextComponent";
1713
1745
  // Non-EffectObject
1714
1746
  DataType["TimelineClip"] = "TimelineClip";
1715
1747
  })(DataType || (DataType = {}));
@@ -1798,8 +1830,11 @@ var VertexBufferSemantic;
1798
1830
  VertexBufferSemantic["TangentBS3"] = "TANGENT_BS3";
1799
1831
  })(VertexBufferSemantic || (VertexBufferSemantic = {}));
1800
1832
 
1833
+ var LATEST_VERSION = JSONSceneVersion.LATEST;
1834
+
1801
1835
  var index$1 = /*#__PURE__*/Object.freeze({
1802
1836
  __proto__: null,
1837
+ LATEST_VERSION: LATEST_VERSION,
1803
1838
  get RenderLevel () { return RenderLevel; },
1804
1839
  get BlendingMode () { return BlendingMode; },
1805
1840
  get SideMode () { return SideMode; },
@@ -1827,6 +1862,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
1827
1862
  MESSAGE_ITEM_PHRASE_END: MESSAGE_ITEM_PHRASE_END,
1828
1863
  get ValueType () { return ValueType; },
1829
1864
  get BezierKeyframeType () { return BezierKeyframeType; },
1865
+ get JSONSceneVersion () { return JSONSceneVersion; },
1830
1866
  get EndBehavior () { return EndBehavior; },
1831
1867
  get ParentItemEndBehavior () { return ParentItemEndBehavior; },
1832
1868
  get ParticleInteractionBehavior () { return ParticleInteractionBehavior; },
@@ -5274,491 +5310,79 @@ Matrix4.tempVec1 = new Vector3();
5274
5310
  Matrix4.tempVec2 = new Vector3();
5275
5311
  Matrix4.tempMat0 = new Matrix4();
5276
5312
 
5277
- function _array_like_to_array(arr, len) {
5278
- if (len == null || len > arr.length) len = arr.length;
5279
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5280
- return arr2;
5281
- }
5282
-
5283
- function _unsupported_iterable_to_array(o, minLen) {
5284
- if (!o) return;
5285
- if (typeof o === "string") return _array_like_to_array(o, minLen);
5286
- var n = Object.prototype.toString.call(o).slice(8, -1);
5287
- if (n === "Object" && o.constructor) n = o.constructor.name;
5288
- if (n === "Map" || n === "Set") return Array.from(n);
5289
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
5313
+ function _extends() {
5314
+ _extends = Object.assign || function assign(target) {
5315
+ for(var i = 1; i < arguments.length; i++){
5316
+ var source = arguments[i];
5317
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
5318
+ }
5319
+ return target;
5320
+ };
5321
+ return _extends.apply(this, arguments);
5290
5322
  }
5291
5323
 
5292
- function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
5293
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
5294
- if (it) return (it = it.call(o)).next.bind(it);
5295
- // Fallback for engines without symbol support
5296
- if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
5297
- if (it) o = it;
5298
- var i = 0;
5299
- return function() {
5300
- if (i >= o.length) return {
5301
- done: true
5302
- };
5303
- return {
5304
- done: false,
5305
- value: o[i++]
5306
- };
5307
- };
5308
- }
5309
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5310
- }
5324
+ var TextureLoadAction;
5325
+ (function(TextureLoadAction) {
5326
+ TextureLoadAction[TextureLoadAction["whatever"] = 0] = "whatever";
5327
+ //preserve previous attachment
5328
+ //load = 1,
5329
+ //clear attachment
5330
+ TextureLoadAction[TextureLoadAction["clear"] = 2] = "clear";
5331
+ })(TextureLoadAction || (TextureLoadAction = {}));
5332
+ var TextureSourceType;
5333
+ (function(TextureSourceType) {
5334
+ TextureSourceType[TextureSourceType["none"] = 0] = "none";
5335
+ TextureSourceType[TextureSourceType["data"] = 1] = "data";
5336
+ TextureSourceType[TextureSourceType["image"] = 2] = "image";
5337
+ TextureSourceType[TextureSourceType["compressed"] = 3] = "compressed";
5338
+ TextureSourceType[TextureSourceType["video"] = 4] = "video";
5339
+ TextureSourceType[TextureSourceType["canvas"] = 5] = "canvas";
5340
+ TextureSourceType[TextureSourceType["framebuffer"] = 6] = "framebuffer";
5341
+ TextureSourceType[TextureSourceType["mipmaps"] = 7] = "mipmaps";
5342
+ })(TextureSourceType || (TextureSourceType = {}));
5311
5343
 
5312
- var ShaderCompileResultStatus;
5313
- (function(ShaderCompileResultStatus) {
5314
- ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
5315
- ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
5316
- ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
5317
- ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
5318
- })(ShaderCompileResultStatus || (ShaderCompileResultStatus = {}));
5319
- var GLSLVersion;
5320
- (function(GLSLVersion) {
5321
- GLSLVersion["GLSL1"] = "100";
5322
- GLSLVersion["GLSL3"] = "300 es";
5323
- })(GLSLVersion || (GLSLVersion = {}));
5324
- var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
5325
- _inherits(ShaderVariant, EffectsObject);
5326
- function ShaderVariant(engine, source) {
5327
- var _this;
5328
- _this = EffectsObject.call(this, engine) || this;
5329
- _this.source = source;
5330
- return _this;
5331
- }
5332
- return ShaderVariant;
5333
- }(EffectsObject);
5334
- var Shader = /*#__PURE__*/ function(EffectsObject) {
5335
- _inherits(Shader, EffectsObject);
5336
- function Shader() {
5337
- return EffectsObject.apply(this, arguments);
5344
+ /**
5345
+ * 负责下载各种资源,并提供了一些异步加载和缓存管理的功能
5346
+ */ var Downloader = /*#__PURE__*/ function() {
5347
+ function Downloader() {
5348
+ /**
5349
+ * 存储多个回调函数的对象
5350
+ */ this.callbacks = {};
5338
5351
  }
5339
- var _proto = Shader.prototype;
5340
- _proto.createVariant = function createVariant(macros) {
5341
- var shaderMacros = [];
5342
- if (macros) {
5343
- for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
5344
- var key = _step.value;
5345
- shaderMacros.push([
5346
- key,
5347
- macros[key]
5348
- ]);
5349
- }
5350
- }
5351
- var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
5352
- shaderVariant.shader = this;
5353
- return shaderVariant;
5352
+ var _proto = Downloader.prototype;
5353
+ /**
5354
+ * 下载一个 JSON 文件
5355
+ * @param url - 要下载的 JSON 文件的 URL
5356
+ * @param onSuccess - 下载成功后的回调函数
5357
+ * @param onError - 下载失败后的回调函数
5358
+ */ _proto.downloadJSON = function downloadJSON(url, onSuccess, onError) {
5359
+ this.download(url, "json", onSuccess, onError);
5354
5360
  };
5355
- _proto.fromData = function fromData(data) {
5356
- EffectsObject.prototype.fromData.call(this, data);
5357
- this.shaderData = data;
5361
+ /**
5362
+ * 下载一个二进制文件
5363
+ * @param url - 要下载的二进制文件的 URL
5364
+ * @param onSuccess - 下载成功后的回调函数
5365
+ * @param onError - 下载失败后的回调函数
5366
+ */ _proto.downloadBinary = function downloadBinary(url, onSuccess, onError) {
5367
+ this.download(url, "arraybuffer", onSuccess, onError);
5358
5368
  };
5359
- return Shader;
5360
- }(EffectsObject);
5361
- Shader = __decorate([
5362
- effectsClass(DataType.Shader)
5363
- ], Shader);
5364
-
5365
- var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
5366
- var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
5367
- var COPY_VERTEX_SHADER = "\nprecision highp float;\nattribute vec2 aPos;\nvarying vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.0))/2.;\n}";
5368
- var COPY_FRAGMENT_SHADER = "precision mediump float;\nvarying vec2 vTex;\n\n#ifdef DEPTH_TEXTURE\nuniform sampler2D uDepth;\n#extension GL_EXT_frag_depth : enable\n#endif\nvoid main(){\n #ifdef DEPTH_TEXTURE\n gl_FragDepthEXT = texture2D(uDepth,vTex).r;\n #endif\n}\n";
5369
- function createCopyShader(level, writeDepth) {
5370
- var webgl2 = level === 2;
5371
- return {
5372
- name: EFFECTS_COPY_MESH_NAME,
5373
- vertex: COPY_VERTEX_SHADER,
5374
- fragment: COPY_FRAGMENT_SHADER,
5375
- glslVersion: webgl2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1,
5376
- macros: [
5377
- [
5378
- "DEPTH_TEXTURE",
5379
- !!writeDepth
5380
- ]
5381
- ],
5382
- // @ts-expect-error
5383
- cacheId: COPY_MESH_SHADER_ID + +writeDepth
5369
+ /**
5370
+ * 下载一个 Blob 文件
5371
+ * @param url - 要下载的 Blob 文件的 URL
5372
+ * @param onSuccess - 下载成功后的回调函数
5373
+ * @param onError - 下载失败后的回调函数
5374
+ */ _proto.downloadBlob = function downloadBlob(url, onSuccess, onError) {
5375
+ this.download(url, "blob", onSuccess, onError);
5384
5376
  };
5385
- }
5386
-
5387
- /**
5388
- * Helper class to create a WebGL Context
5389
- *
5390
- * @param canvas
5391
- * @param glType
5392
- * @param options
5393
- * @returns
5394
- */ function createGLContext(canvas, glType, options) {
5395
- if (glType === void 0) glType = "webgl";
5396
- var context;
5397
- if (glType === "webgl2") {
5398
- context = canvas.getContext("webgl2", options);
5399
- if (!context) {
5400
- console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
5401
- }
5402
- }
5403
- if (!context || glType === "webgl") {
5404
- context = canvas.getContext("webgl", options);
5405
- }
5406
- if (!context) {
5407
- throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
5408
- }
5409
- return context;
5410
- }
5411
-
5412
- function gpuTimer(gl) {
5413
- var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
5414
- if (ext) {
5415
- var query = gl.createQuery();
5416
- var getTime = /*#__PURE__*/ _async_to_generator(function() {
5417
- return __generator(this, function(_state) {
5418
- return [
5419
- 2,
5420
- new Promise(function(resolve, reject) {
5421
- if (query) {
5422
- var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
5423
- var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
5424
- if (available && !disjoint) {
5425
- // See how much time the rendering of the object took in nanoseconds.
5426
- var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
5427
- // taken to use all significant bits of the result, not just the
5428
- // least significant 32 bits.
5429
- resolve(timeElapsed / 1000 / 1000);
5430
- }
5431
- if (available || disjoint) {
5432
- // Clean up the query object.
5433
- gl.deleteQuery(query); // Don't re-enter this polling loop.
5434
- query = null;
5435
- }
5436
- available !== null && query && window.setTimeout(function() {
5437
- getTime().then(resolve).catch;
5438
- }, 1);
5439
- }
5440
- })
5441
- ];
5442
- });
5443
- });
5444
- if (!query) {
5377
+ _proto.download = function download(url, responseType, onSuccess, onError) {
5378
+ var _this = this;
5379
+ if (responseType === void 0) responseType = "json";
5380
+ if (this.start(url, onSuccess, onError)) {
5445
5381
  return;
5446
5382
  }
5447
- return {
5448
- begin: function() {
5449
- query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
5450
- },
5451
- end: function() {
5452
- gl.endQuery(ext.TIME_ELAPSED_EXT);
5453
- },
5454
- getTime: getTime
5455
- };
5456
- }
5457
- }
5458
-
5459
- var initErrors = [];
5460
- // @ts-expect-error
5461
- var glContext = {};
5462
- if (!initErrors.length) {
5463
- initGLContext();
5464
- }
5465
- function initGLContext() {
5466
- // 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
5467
- if (typeof WebGL2RenderingContext === "function") {
5468
- copy(WebGL2RenderingContext);
5469
- } else if (typeof WebGLRenderingContext !== "undefined") {
5470
- copy(WebGLRenderingContext);
5471
- copy(WebGLRenderingContext.prototype);
5472
- } else {
5473
- initErrors.push(// iOS 16 lockdown mode
5474
- "iOS16 lockdown mode, WebGL Constants not in global");
5475
- }
5476
- if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
5477
- // @ts-expect-error set default value
5478
- glContext["HALF_FLOAT"] = 5131;
5479
- }
5480
- }
5481
- function isWebGL2(gl) {
5482
- return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
5483
- }
5484
- function copy(target) {
5485
- for(var name in target){
5486
- if (/^[A-Z_]/.test(name)) {
5487
- // @ts-expect-error safe to assign
5488
- glContext[name] = target[name];
5489
- }
5490
- }
5491
- }
5492
- function vertexFormatType2GLType(formatType) {
5493
- switch(formatType){
5494
- case VertexFormatType.Float32:
5495
- return WebGLRenderingContext["FLOAT"];
5496
- case VertexFormatType.Int16:
5497
- return WebGLRenderingContext["SHORT"];
5498
- case VertexFormatType.Int8:
5499
- return WebGLRenderingContext["BYTE"];
5500
- case VertexFormatType.UInt16:
5501
- return WebGLRenderingContext["UNSIGNED_SHORT"];
5502
- case VertexFormatType.UInt8:
5503
- return WebGLRenderingContext["UNSIGNED_BYTE"];
5504
- default:
5505
- return WebGLRenderingContext["FLOAT"];
5506
- }
5507
- }
5508
- function glType2VertexFormatType(webglType) {
5509
- switch(webglType){
5510
- case WebGLRenderingContext["FLOAT"]:
5511
- return VertexFormatType.Float32;
5512
- case WebGLRenderingContext["SHORT"]:
5513
- return VertexFormatType.Int16;
5514
- case WebGLRenderingContext["BYTE"]:
5515
- return VertexFormatType.Int8;
5516
- case WebGLRenderingContext["UNSIGNED_SHORT"]:
5517
- return VertexFormatType.UInt16;
5518
- case WebGLRenderingContext["UNSIGNED_BYTE"]:
5519
- return VertexFormatType.UInt8;
5520
- default:
5521
- return VertexFormatType.Float32;
5522
- }
5523
- }
5524
-
5525
- var ShaderType;
5526
- (function(ShaderType) {
5527
- ShaderType[ShaderType["vertex"] = 0] = "vertex";
5528
- ShaderType[ShaderType["fragment"] = 1] = "fragment";
5529
- })(ShaderType || (ShaderType = {}));
5530
-
5531
- function valIfUndefined(val, def) {
5532
- if (val === undefined || val === null) {
5533
- return def;
5534
- }
5535
- return val;
5536
- }
5537
- function getPreMultiAlpha(blending) {
5538
- switch(blending){
5539
- case BlendingMode.ALPHA:
5540
- return 1;
5541
- case BlendingMode.ADD:
5542
- return 1;
5543
- case BlendingMode.SUBTRACTION:
5544
- return 1;
5545
- case BlendingMode.STRONG_LIGHT:
5546
- return 1;
5547
- case BlendingMode.WEAK_LIGHT:
5548
- return 1;
5549
- case BlendingMode.SUPERPOSITION:
5550
- return 2;
5551
- case BlendingMode.BRIGHTNESS:
5552
- return 3;
5553
- case BlendingMode.MULTIPLY:
5554
- return 0;
5555
- default:
5556
- // 处理undefined
5557
- return 1;
5558
- }
5559
- }
5560
- function setBlendMode(material, blendMode) {
5561
- switch(blendMode){
5562
- case undefined:
5563
- material.blendFunction = [
5564
- glContext.ONE,
5565
- glContext.ONE_MINUS_SRC_ALPHA,
5566
- glContext.ONE,
5567
- glContext.ONE_MINUS_SRC_ALPHA
5568
- ];
5569
- break;
5570
- case BlendingMode.ALPHA:
5571
- material.blendFunction = [
5572
- glContext.ONE,
5573
- glContext.ONE_MINUS_SRC_ALPHA,
5574
- glContext.ONE,
5575
- glContext.ONE_MINUS_SRC_ALPHA
5576
- ];
5577
- break;
5578
- case BlendingMode.ADD:
5579
- material.blendFunction = [
5580
- glContext.ONE,
5581
- glContext.ONE,
5582
- glContext.ONE,
5583
- glContext.ONE
5584
- ];
5585
- break;
5586
- case BlendingMode.SUBTRACTION:
5587
- material.blendFunction = [
5588
- glContext.ONE,
5589
- glContext.ONE,
5590
- glContext.ZERO,
5591
- glContext.ONE
5592
- ];
5593
- material.blendEquation = [
5594
- glContext.FUNC_REVERSE_SUBTRACT,
5595
- glContext.FUNC_REVERSE_SUBTRACT
5596
- ];
5597
- break;
5598
- case BlendingMode.SUPERPOSITION:
5599
- material.blendFunction = [
5600
- glContext.ONE,
5601
- glContext.ONE,
5602
- glContext.ONE,
5603
- glContext.ONE
5604
- ];
5605
- break;
5606
- case BlendingMode.MULTIPLY:
5607
- material.blendFunction = [
5608
- glContext.DST_COLOR,
5609
- glContext.ONE_MINUS_SRC_ALPHA,
5610
- glContext.DST_COLOR,
5611
- glContext.ONE_MINUS_SRC_ALPHA
5612
- ];
5613
- break;
5614
- case BlendingMode.BRIGHTNESS:
5615
- material.blendFunction = [
5616
- glContext.ONE,
5617
- glContext.ONE_MINUS_SRC_ALPHA,
5618
- glContext.ONE,
5619
- glContext.ONE_MINUS_SRC_ALPHA
5620
- ];
5621
- break;
5622
- case BlendingMode.STRONG_LIGHT:
5623
- material.blendFunction = [
5624
- glContext.DST_COLOR,
5625
- glContext.DST_ALPHA,
5626
- glContext.ZERO,
5627
- glContext.ONE
5628
- ];
5629
- break;
5630
- case BlendingMode.WEAK_LIGHT:
5631
- material.blendFunction = [
5632
- glContext.DST_COLOR,
5633
- glContext.ZERO,
5634
- glContext.ZERO,
5635
- glContext.ONE
5636
- ];
5637
- break;
5638
- default:
5639
- console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
5640
- }
5641
- }
5642
- function setSideMode(material, side) {
5643
- if (side === SideMode.DOUBLE) {
5644
- material.culling = false;
5645
- } else {
5646
- material.culling = true;
5647
- material.frontFace = glContext.CW;
5648
- material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
5649
- }
5650
- }
5651
- function setMaskMode(material, maskMode) {
5652
- switch(maskMode){
5653
- case undefined:
5654
- material.stencilTest = false;
5655
- break;
5656
- case MaskMode.MASK:
5657
- material.stencilTest = true;
5658
- material.stencilFunc = [
5659
- glContext.ALWAYS,
5660
- glContext.ALWAYS
5661
- ];
5662
- material.stencilOpZPass = [
5663
- glContext.REPLACE,
5664
- glContext.REPLACE
5665
- ];
5666
- break;
5667
- case MaskMode.OBSCURED:
5668
- material.stencilTest = true;
5669
- material.stencilFunc = [
5670
- glContext.EQUAL,
5671
- glContext.EQUAL
5672
- ];
5673
- break;
5674
- case MaskMode.REVERSE_OBSCURED:
5675
- material.stencilTest = true;
5676
- material.stencilFunc = [
5677
- glContext.NOTEQUAL,
5678
- glContext.NOTEQUAL
5679
- ];
5680
- break;
5681
- case MaskMode.NONE:
5682
- material.stencilTest = false;
5683
- break;
5684
- default:
5685
- console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
5686
- }
5687
- }
5688
-
5689
- function _extends() {
5690
- _extends = Object.assign || function assign(target) {
5691
- for(var i = 1; i < arguments.length; i++){
5692
- var source = arguments[i];
5693
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
5694
- }
5695
- return target;
5696
- };
5697
- return _extends.apply(this, arguments);
5698
- }
5699
-
5700
- var TextureLoadAction;
5701
- (function(TextureLoadAction) {
5702
- TextureLoadAction[TextureLoadAction["whatever"] = 0] = "whatever";
5703
- //preserve previous attachment
5704
- //load = 1,
5705
- //clear attachment
5706
- TextureLoadAction[TextureLoadAction["clear"] = 2] = "clear";
5707
- })(TextureLoadAction || (TextureLoadAction = {}));
5708
- var TextureSourceType;
5709
- (function(TextureSourceType) {
5710
- TextureSourceType[TextureSourceType["none"] = 0] = "none";
5711
- TextureSourceType[TextureSourceType["data"] = 1] = "data";
5712
- TextureSourceType[TextureSourceType["image"] = 2] = "image";
5713
- TextureSourceType[TextureSourceType["compressed"] = 3] = "compressed";
5714
- TextureSourceType[TextureSourceType["video"] = 4] = "video";
5715
- TextureSourceType[TextureSourceType["canvas"] = 5] = "canvas";
5716
- TextureSourceType[TextureSourceType["framebuffer"] = 6] = "framebuffer";
5717
- TextureSourceType[TextureSourceType["mipmaps"] = 7] = "mipmaps";
5718
- })(TextureSourceType || (TextureSourceType = {}));
5719
-
5720
- /**
5721
- * 负责下载各种资源,并提供了一些异步加载和缓存管理的功能
5722
- */ var Downloader = /*#__PURE__*/ function() {
5723
- function Downloader() {
5724
- /**
5725
- * 存储多个回调函数的对象
5726
- */ this.callbacks = {};
5727
- }
5728
- var _proto = Downloader.prototype;
5729
- /**
5730
- * 下载一个 JSON 文件
5731
- * @param url - 要下载的 JSON 文件的 URL
5732
- * @param onSuccess - 下载成功后的回调函数
5733
- * @param onError - 下载失败后的回调函数
5734
- */ _proto.downloadJSON = function downloadJSON(url, onSuccess, onError) {
5735
- this.download(url, "json", onSuccess, onError);
5736
- };
5737
- /**
5738
- * 下载一个二进制文件
5739
- * @param url - 要下载的二进制文件的 URL
5740
- * @param onSuccess - 下载成功后的回调函数
5741
- * @param onError - 下载失败后的回调函数
5742
- */ _proto.downloadBinary = function downloadBinary(url, onSuccess, onError) {
5743
- this.download(url, "arraybuffer", onSuccess, onError);
5744
- };
5745
- /**
5746
- * 下载一个 Blob 文件
5747
- * @param url - 要下载的 Blob 文件的 URL
5748
- * @param onSuccess - 下载成功后的回调函数
5749
- * @param onError - 下载失败后的回调函数
5750
- */ _proto.downloadBlob = function downloadBlob(url, onSuccess, onError) {
5751
- this.download(url, "blob", onSuccess, onError);
5752
- };
5753
- _proto.download = function download(url, responseType, onSuccess, onError) {
5754
- var _this = this;
5755
- if (responseType === void 0) responseType = "json";
5756
- if (this.start(url, onSuccess, onError)) {
5757
- return;
5758
- }
5759
- var xhr = new XMLHttpRequest();
5760
- var handleError = function() {
5761
- _this.finish(url, xhr.status, xhr.response);
5383
+ var xhr = new XMLHttpRequest();
5384
+ var handleError = function() {
5385
+ _this.finish(url, xhr.status, xhr.response);
5762
5386
  };
5763
5387
  var handleLoad = function() {
5764
5388
  if (xhr.status == 200) {
@@ -6096,7 +5720,12 @@ function _loadVideo() {
6096
5720
  });
6097
5721
  return _loadVideo.apply(this, arguments);
6098
5722
  }
6099
- function loadMedia(url, loadFn) {
5723
+ /**
5724
+ * 异步加载一个媒体文件
5725
+ * @param url
5726
+ * @param loadFn
5727
+ * @returns
5728
+ */ function loadMedia(url, loadFn) {
6100
5729
  return _loadMedia.apply(this, arguments);
6101
5730
  }
6102
5731
  function _loadMedia() {
@@ -6258,6 +5887,144 @@ function _loadMipmapImage() {
6258
5887
  return _loadMipmapImage.apply(this, arguments);
6259
5888
  }
6260
5889
 
5890
+ /**
5891
+ * Helper class to create a WebGL Context
5892
+ *
5893
+ * @param canvas
5894
+ * @param glType
5895
+ * @param options
5896
+ * @returns
5897
+ */ function createGLContext(canvas, glType, options) {
5898
+ if (glType === void 0) glType = "webgl";
5899
+ var context;
5900
+ if (glType === "webgl2") {
5901
+ context = canvas.getContext("webgl2", options);
5902
+ if (!context) {
5903
+ console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
5904
+ }
5905
+ }
5906
+ if (!context || glType === "webgl") {
5907
+ context = canvas.getContext("webgl", options);
5908
+ }
5909
+ if (!context) {
5910
+ throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
5911
+ }
5912
+ return context;
5913
+ }
5914
+
5915
+ function gpuTimer(gl) {
5916
+ var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
5917
+ if (ext) {
5918
+ var query = gl.createQuery();
5919
+ var getTime = /*#__PURE__*/ _async_to_generator(function() {
5920
+ return __generator(this, function(_state) {
5921
+ return [
5922
+ 2,
5923
+ new Promise(function(resolve, reject) {
5924
+ if (query) {
5925
+ var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
5926
+ var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
5927
+ if (available && !disjoint) {
5928
+ // See how much time the rendering of the object took in nanoseconds.
5929
+ var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
5930
+ // taken to use all significant bits of the result, not just the
5931
+ // least significant 32 bits.
5932
+ resolve(timeElapsed / 1000 / 1000);
5933
+ }
5934
+ if (available || disjoint) {
5935
+ // Clean up the query object.
5936
+ gl.deleteQuery(query); // Don't re-enter this polling loop.
5937
+ query = null;
5938
+ }
5939
+ available !== null && query && window.setTimeout(function() {
5940
+ getTime().then(resolve).catch;
5941
+ }, 1);
5942
+ }
5943
+ })
5944
+ ];
5945
+ });
5946
+ });
5947
+ if (!query) {
5948
+ return;
5949
+ }
5950
+ return {
5951
+ begin: function() {
5952
+ query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
5953
+ },
5954
+ end: function() {
5955
+ gl.endQuery(ext.TIME_ELAPSED_EXT);
5956
+ },
5957
+ getTime: getTime
5958
+ };
5959
+ }
5960
+ }
5961
+
5962
+ var initErrors = [];
5963
+ // @ts-expect-error
5964
+ var glContext = {};
5965
+ if (!initErrors.length) {
5966
+ initGLContext();
5967
+ }
5968
+ function initGLContext() {
5969
+ // 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
5970
+ if (typeof WebGL2RenderingContext === "function") {
5971
+ copy(WebGL2RenderingContext);
5972
+ } else if (typeof WebGLRenderingContext !== "undefined") {
5973
+ copy(WebGLRenderingContext);
5974
+ copy(WebGLRenderingContext.prototype);
5975
+ } else {
5976
+ initErrors.push(// iOS 16 lockdown mode
5977
+ "iOS16 lockdown mode, WebGL Constants not in global");
5978
+ }
5979
+ if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
5980
+ // @ts-expect-error set default value
5981
+ glContext["HALF_FLOAT"] = 5131;
5982
+ }
5983
+ }
5984
+ function isWebGL2(gl) {
5985
+ return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
5986
+ }
5987
+ function copy(target) {
5988
+ for(var name in target){
5989
+ if (/^[A-Z_]/.test(name)) {
5990
+ // @ts-expect-error safe to assign
5991
+ glContext[name] = target[name];
5992
+ }
5993
+ }
5994
+ }
5995
+ function vertexFormatType2GLType(formatType) {
5996
+ switch(formatType){
5997
+ case VertexFormatType.Float32:
5998
+ return WebGLRenderingContext["FLOAT"];
5999
+ case VertexFormatType.Int16:
6000
+ return WebGLRenderingContext["SHORT"];
6001
+ case VertexFormatType.Int8:
6002
+ return WebGLRenderingContext["BYTE"];
6003
+ case VertexFormatType.UInt16:
6004
+ return WebGLRenderingContext["UNSIGNED_SHORT"];
6005
+ case VertexFormatType.UInt8:
6006
+ return WebGLRenderingContext["UNSIGNED_BYTE"];
6007
+ default:
6008
+ return WebGLRenderingContext["FLOAT"];
6009
+ }
6010
+ }
6011
+ function glType2VertexFormatType(webglType) {
6012
+ switch(webglType){
6013
+ case WebGLRenderingContext["FLOAT"]:
6014
+ return VertexFormatType.Float32;
6015
+ case WebGLRenderingContext["SHORT"]:
6016
+ return VertexFormatType.Int16;
6017
+ case WebGLRenderingContext["BYTE"]:
6018
+ return VertexFormatType.Int8;
6019
+ case WebGLRenderingContext["UNSIGNED_SHORT"]:
6020
+ return VertexFormatType.UInt16;
6021
+ case WebGLRenderingContext["UNSIGNED_BYTE"]:
6022
+ return VertexFormatType.UInt8;
6023
+ default:
6024
+ return VertexFormatType.Float32;
6025
+ }
6026
+ }
6027
+
6261
6028
  var seed$9 = 1;
6262
6029
  /**
6263
6030
  * Texture 抽象类
@@ -6852,44 +6619,318 @@ var TextureFactory = /*#__PURE__*/ function() {
6852
6619
  });
6853
6620
  })();
6854
6621
  };
6855
- _proto.loadMipmapImages = function loadMipmapImages(pointers, bin) {
6856
- return _async_to_generator(function() {
6857
- return __generator(this, function(_state) {
6858
- return [
6859
- 2,
6860
- Promise.all(pointers.map(function(pointer) {
6861
- var blob = new Blob([
6862
- new Uint8Array(bin, pointer[0], pointer[1])
6863
- ]);
6864
- return loadImage(blob);
6865
- }))
6866
- ];
6867
- });
6868
- })();
6622
+ _proto.loadMipmapImages = function loadMipmapImages(pointers, bin) {
6623
+ return _async_to_generator(function() {
6624
+ return __generator(this, function(_state) {
6625
+ return [
6626
+ 2,
6627
+ Promise.all(pointers.map(function(pointer) {
6628
+ var blob = new Blob([
6629
+ new Uint8Array(bin, pointer[0], pointer[1])
6630
+ ]);
6631
+ return loadImage(blob);
6632
+ }))
6633
+ ];
6634
+ });
6635
+ })();
6636
+ };
6637
+ _proto.loadCubeMap = function loadCubeMap(cubemap) {
6638
+ return _async_to_generator(function() {
6639
+ return __generator(this, function(_state) {
6640
+ return [
6641
+ 2,
6642
+ Promise.all(cubemap.map(function(key) {
6643
+ return loadImage(key);
6644
+ }))
6645
+ ];
6646
+ });
6647
+ })();
6648
+ };
6649
+ return TextureFactory;
6650
+ }();
6651
+ var g;
6652
+ function getDefaultTextureFactory() {
6653
+ if (!g) {
6654
+ g = new TextureFactory();
6655
+ }
6656
+ return g;
6657
+ }
6658
+ function setDefaultTextureFactory(factory) {
6659
+ g = factory;
6660
+ }
6661
+
6662
+ function _array_like_to_array(arr, len) {
6663
+ if (len == null || len > arr.length) len = arr.length;
6664
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
6665
+ return arr2;
6666
+ }
6667
+
6668
+ function _unsupported_iterable_to_array(o, minLen) {
6669
+ if (!o) return;
6670
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
6671
+ var n = Object.prototype.toString.call(o).slice(8, -1);
6672
+ if (n === "Object" && o.constructor) n = o.constructor.name;
6673
+ if (n === "Map" || n === "Set") return Array.from(n);
6674
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
6675
+ }
6676
+
6677
+ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
6678
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
6679
+ if (it) return (it = it.call(o)).next.bind(it);
6680
+ // Fallback for engines without symbol support
6681
+ if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
6682
+ if (it) o = it;
6683
+ var i = 0;
6684
+ return function() {
6685
+ if (i >= o.length) return {
6686
+ done: true
6687
+ };
6688
+ return {
6689
+ done: false,
6690
+ value: o[i++]
6691
+ };
6692
+ };
6693
+ }
6694
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6695
+ }
6696
+
6697
+ var ShaderCompileResultStatus;
6698
+ (function(ShaderCompileResultStatus) {
6699
+ ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
6700
+ ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
6701
+ ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
6702
+ ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
6703
+ })(ShaderCompileResultStatus || (ShaderCompileResultStatus = {}));
6704
+ var GLSLVersion;
6705
+ (function(GLSLVersion) {
6706
+ GLSLVersion["GLSL1"] = "100";
6707
+ GLSLVersion["GLSL3"] = "300 es";
6708
+ })(GLSLVersion || (GLSLVersion = {}));
6709
+ var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
6710
+ _inherits(ShaderVariant, EffectsObject);
6711
+ function ShaderVariant(engine, source) {
6712
+ var _this;
6713
+ _this = EffectsObject.call(this, engine) || this;
6714
+ _this.source = source;
6715
+ return _this;
6716
+ }
6717
+ return ShaderVariant;
6718
+ }(EffectsObject);
6719
+ var Shader = /*#__PURE__*/ function(EffectsObject) {
6720
+ _inherits(Shader, EffectsObject);
6721
+ function Shader() {
6722
+ return EffectsObject.apply(this, arguments);
6723
+ }
6724
+ var _proto = Shader.prototype;
6725
+ _proto.createVariant = function createVariant(macros) {
6726
+ var shaderMacros = [];
6727
+ if (macros) {
6728
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
6729
+ var key = _step.value;
6730
+ shaderMacros.push([
6731
+ key,
6732
+ macros[key]
6733
+ ]);
6734
+ }
6735
+ }
6736
+ var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
6737
+ shaderVariant.shader = this;
6738
+ return shaderVariant;
6739
+ };
6740
+ _proto.fromData = function fromData(data) {
6741
+ EffectsObject.prototype.fromData.call(this, data);
6742
+ this.shaderData = data;
6869
6743
  };
6870
- _proto.loadCubeMap = function loadCubeMap(cubemap) {
6871
- return _async_to_generator(function() {
6872
- return __generator(this, function(_state) {
6873
- return [
6874
- 2,
6875
- Promise.all(cubemap.map(function(key) {
6876
- return loadImage(key);
6877
- }))
6878
- ];
6879
- });
6880
- })();
6744
+ return Shader;
6745
+ }(EffectsObject);
6746
+ Shader = __decorate([
6747
+ effectsClass(DataType.Shader)
6748
+ ], Shader);
6749
+
6750
+ var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
6751
+ var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
6752
+ var COPY_VERTEX_SHADER = "\nprecision highp float;\nattribute vec2 aPos;\nvarying vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.0))/2.;\n}";
6753
+ var COPY_FRAGMENT_SHADER = "precision mediump float;\nvarying vec2 vTex;\n\n#ifdef DEPTH_TEXTURE\nuniform sampler2D uDepth;\n#extension GL_EXT_frag_depth : enable\n#endif\nvoid main(){\n #ifdef DEPTH_TEXTURE\n gl_FragDepthEXT = texture2D(uDepth,vTex).r;\n #endif\n}\n";
6754
+ function createCopyShader(level, writeDepth) {
6755
+ var webgl2 = level === 2;
6756
+ return {
6757
+ name: EFFECTS_COPY_MESH_NAME,
6758
+ vertex: COPY_VERTEX_SHADER,
6759
+ fragment: COPY_FRAGMENT_SHADER,
6760
+ glslVersion: webgl2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1,
6761
+ macros: [
6762
+ [
6763
+ "DEPTH_TEXTURE",
6764
+ !!writeDepth
6765
+ ]
6766
+ ],
6767
+ // @ts-expect-error
6768
+ cacheId: COPY_MESH_SHADER_ID + +writeDepth
6881
6769
  };
6882
- return TextureFactory;
6883
- }();
6884
- var g;
6885
- function getDefaultTextureFactory() {
6886
- if (!g) {
6887
- g = new TextureFactory();
6770
+ }
6771
+
6772
+ var ShaderType;
6773
+ (function(ShaderType) {
6774
+ ShaderType[ShaderType["vertex"] = 0] = "vertex";
6775
+ ShaderType[ShaderType["fragment"] = 1] = "fragment";
6776
+ })(ShaderType || (ShaderType = {}));
6777
+
6778
+ function valIfUndefined(val, def) {
6779
+ if (val === undefined || val === null) {
6780
+ return def;
6888
6781
  }
6889
- return g;
6782
+ return val;
6890
6783
  }
6891
- function setDefaultTextureFactory(factory) {
6892
- g = factory;
6784
+ function getPreMultiAlpha(blending) {
6785
+ switch(blending){
6786
+ case BlendingMode.ALPHA:
6787
+ return 1;
6788
+ case BlendingMode.ADD:
6789
+ return 1;
6790
+ case BlendingMode.SUBTRACTION:
6791
+ return 1;
6792
+ case BlendingMode.STRONG_LIGHT:
6793
+ return 1;
6794
+ case BlendingMode.WEAK_LIGHT:
6795
+ return 1;
6796
+ case BlendingMode.SUPERPOSITION:
6797
+ return 2;
6798
+ case BlendingMode.BRIGHTNESS:
6799
+ return 3;
6800
+ case BlendingMode.MULTIPLY:
6801
+ return 0;
6802
+ default:
6803
+ // 处理undefined
6804
+ return 1;
6805
+ }
6806
+ }
6807
+ function setBlendMode(material, blendMode) {
6808
+ switch(blendMode){
6809
+ case undefined:
6810
+ material.blendFunction = [
6811
+ glContext.ONE,
6812
+ glContext.ONE_MINUS_SRC_ALPHA,
6813
+ glContext.ONE,
6814
+ glContext.ONE_MINUS_SRC_ALPHA
6815
+ ];
6816
+ break;
6817
+ case BlendingMode.ALPHA:
6818
+ material.blendFunction = [
6819
+ glContext.ONE,
6820
+ glContext.ONE_MINUS_SRC_ALPHA,
6821
+ glContext.ONE,
6822
+ glContext.ONE_MINUS_SRC_ALPHA
6823
+ ];
6824
+ break;
6825
+ case BlendingMode.ADD:
6826
+ material.blendFunction = [
6827
+ glContext.ONE,
6828
+ glContext.ONE,
6829
+ glContext.ONE,
6830
+ glContext.ONE
6831
+ ];
6832
+ break;
6833
+ case BlendingMode.SUBTRACTION:
6834
+ material.blendFunction = [
6835
+ glContext.ONE,
6836
+ glContext.ONE,
6837
+ glContext.ZERO,
6838
+ glContext.ONE
6839
+ ];
6840
+ material.blendEquation = [
6841
+ glContext.FUNC_REVERSE_SUBTRACT,
6842
+ glContext.FUNC_REVERSE_SUBTRACT
6843
+ ];
6844
+ break;
6845
+ case BlendingMode.SUPERPOSITION:
6846
+ material.blendFunction = [
6847
+ glContext.ONE,
6848
+ glContext.ONE,
6849
+ glContext.ONE,
6850
+ glContext.ONE
6851
+ ];
6852
+ break;
6853
+ case BlendingMode.MULTIPLY:
6854
+ material.blendFunction = [
6855
+ glContext.DST_COLOR,
6856
+ glContext.ONE_MINUS_SRC_ALPHA,
6857
+ glContext.DST_COLOR,
6858
+ glContext.ONE_MINUS_SRC_ALPHA
6859
+ ];
6860
+ break;
6861
+ case BlendingMode.BRIGHTNESS:
6862
+ material.blendFunction = [
6863
+ glContext.ONE,
6864
+ glContext.ONE_MINUS_SRC_ALPHA,
6865
+ glContext.ONE,
6866
+ glContext.ONE_MINUS_SRC_ALPHA
6867
+ ];
6868
+ break;
6869
+ case BlendingMode.STRONG_LIGHT:
6870
+ material.blendFunction = [
6871
+ glContext.DST_COLOR,
6872
+ glContext.DST_ALPHA,
6873
+ glContext.ZERO,
6874
+ glContext.ONE
6875
+ ];
6876
+ break;
6877
+ case BlendingMode.WEAK_LIGHT:
6878
+ material.blendFunction = [
6879
+ glContext.DST_COLOR,
6880
+ glContext.ZERO,
6881
+ glContext.ZERO,
6882
+ glContext.ONE
6883
+ ];
6884
+ break;
6885
+ default:
6886
+ console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
6887
+ }
6888
+ }
6889
+ function setSideMode(material, side) {
6890
+ if (side === SideMode.DOUBLE) {
6891
+ material.culling = false;
6892
+ } else {
6893
+ material.culling = true;
6894
+ material.frontFace = glContext.CW;
6895
+ material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
6896
+ }
6897
+ }
6898
+ function setMaskMode(material, maskMode) {
6899
+ switch(maskMode){
6900
+ case undefined:
6901
+ material.stencilTest = false;
6902
+ break;
6903
+ case MaskMode.MASK:
6904
+ material.stencilTest = true;
6905
+ material.stencilFunc = [
6906
+ glContext.ALWAYS,
6907
+ glContext.ALWAYS
6908
+ ];
6909
+ material.stencilOpZPass = [
6910
+ glContext.REPLACE,
6911
+ glContext.REPLACE
6912
+ ];
6913
+ break;
6914
+ case MaskMode.OBSCURED:
6915
+ material.stencilTest = true;
6916
+ material.stencilFunc = [
6917
+ glContext.EQUAL,
6918
+ glContext.EQUAL
6919
+ ];
6920
+ break;
6921
+ case MaskMode.REVERSE_OBSCURED:
6922
+ material.stencilTest = true;
6923
+ material.stencilFunc = [
6924
+ glContext.NOTEQUAL,
6925
+ glContext.NOTEQUAL
6926
+ ];
6927
+ break;
6928
+ case MaskMode.NONE:
6929
+ material.stencilTest = false;
6930
+ break;
6931
+ default:
6932
+ console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
6933
+ }
6893
6934
  }
6894
6935
 
6895
6936
  /**
@@ -10141,7 +10182,7 @@ var integrate = "float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4
10141
10182
 
10142
10183
  var itemVert = "precision highp float;attribute vec2 atlasOffset;attribute vec3 aPos;varying vec2 vTexCoord;varying vec3 vParams;varying vec4 vColor;uniform vec2 _Size;uniform vec3 _Scale;uniform vec4 _Color;uniform vec4 _TexParams;uniform vec4 _TexOffset;uniform mat4 effects_MatrixVP;uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixV;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvoid main(){vec4 texParams=_TexParams;vTexCoord=vec2(atlasOffset.xy*_TexOffset.zw+_TexOffset.xy);vColor=_Color;vParams=vec3(0.0,texParams.y,texParams.x);if(texParams.z==1.0){vec4 pos=vec4(aPos.xy*_Size,aPos.z,1.0);gl_Position=effects_MatrixVP*effects_ObjectToWorld*pos;}else{mat4 view=effects_MatrixV;vec3 camRight=vec3(view[0][0],view[1][0],view[2][0]);vec3 camUp=vec3(view[0][1],view[1][1],view[2][1]);vec3 worldPosition=vec3(effects_ObjectToWorld*vec4(0.0,0.0,0.0,1.0));vec3 vertexPosition=worldPosition+camRight*aPos.x*_Size.x*_Scale.x+camUp*aPos.y*_Size.y*_Scale.y;gl_Position=effects_MatrixVP*vec4(vertexPosition,1.0);}\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
10143
10184
 
10144
- var itemFrag = "precision highp float;varying vec4 vColor;varying vec2 vTexCoord;varying vec3 vParams;uniform sampler2D _MainTex;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}void main(){vec4 color=vec4(0.);vec4 texColor=texture2D(_MainTex,vTexCoord.xy);color=blendColor(texColor,vColor,floor(0.5+vParams.y));\n#ifdef ALPHA_CLIP\nif(vParams.z==0.&&color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}";
10185
+ var itemFrag = "precision highp float;varying vec4 vColor;varying vec2 vTexCoord;varying vec3 vParams;uniform sampler2D _MainTex;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}void main(){vec4 color=vec4(0.);\n#ifdef TRANSPARENT_VIDEO\nvec2 uv_rgb=vec2(vTexCoord.x*0.5000,vTexCoord.y);vec2 uv_alpha=vec2(vTexCoord.x*0.5000+0.5000,vTexCoord.y);vec3 rgb=texture2D(_MainTex,uv_rgb).rgb;float alpha=texture2D(_MainTex,uv_alpha).r;vec4 texColor=vec4(rgb/alpha,alpha);\n#else\nvec4 texColor=texture2D(_MainTex,vTexCoord.xy);\n#endif\ncolor=blendColor(texColor,vColor,floor(0.5+vParams.y));\n#ifdef ALPHA_CLIP\nif(vParams.z==0.&&color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}";
10145
10186
 
10146
10187
  var particleFrag = "#version 100\nprecision mediump float;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}\n#define PATICLE_SHADER 1\nvarying float vLife;varying vec2 vTexCoord;varying vec4 vColor;uniform vec3 emissionColor;uniform float emissionIntensity;uniform sampler2D uMaskTex;uniform vec4 uColorParams;uniform vec2 uTexOffset;\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#ifdef USE_SPRITE\nvarying vec4 vTexCoordBlend;\n#endif\nvarying float vSeed;\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\n#ifdef USE_SPRITE\nvec4 getTextureColor(sampler2D tex,vec2 texCoord){if(vTexCoordBlend.w>0.){return mix(texture2D(tex,texCoord),texture2D(tex,vTexCoordBlend.xy+texCoord),vTexCoordBlend.z);}return texture2D(tex,texCoord);}\n#else\n#define getTextureColor texture2D\n#endif\n#ifndef WEBGL2\n#define round(a) floor(0.5+a)\n#endif\n#ifdef PREVIEW_BORDER\nvoid main(){gl_FragColor=uPreviewColor;}\n#else\nvoid main(){vec4 color=vec4(1.0);vec4 tempColor=vColor;vec2 texOffset=uTexOffset;if(vLife<0.){discard;}if(uColorParams.x>0.0){color=getTextureColor(uMaskTex,vTexCoord);}\n#ifdef COLOR_OVER_LIFETIME\n#ifndef ENABLE_VERTEX_TEXTURE\ntempColor*=texture2D(uColorOverLifetime,vec2(vLife,0.));\n#endif\n#endif\ncolor=blendColor(color,tempColor,round(uColorParams.y));if(color.a<=0.01&&uColorParams.w>0.){float _at=texture2D(uMaskTex,vTexCoord+texOffset).a+texture2D(uMaskTex,vTexCoord+texOffset*-1.).a;if(_at<=0.02){discard;}}vec3 emission=emissionColor*pow(2.0,emissionIntensity);color=vec4(pow(pow(color.rgb,vec3(2.2))+emission,vec3(1.0/2.2)),color.a);gl_FragColor=color;}\n#endif\n";
10147
10188
 
@@ -13100,7 +13141,28 @@ var Vector4Curve = /*#__PURE__*/ function(ValueGetter) {
13100
13141
  this.value.set(x, y, z, w);
13101
13142
  return this.value;
13102
13143
  };
13103
- return Vector4Curve;
13144
+ return Vector4Curve;
13145
+ }(ValueGetter);
13146
+ var Vector2Curve = /*#__PURE__*/ function(ValueGetter) {
13147
+ _inherits(Vector2Curve, ValueGetter);
13148
+ function Vector2Curve() {
13149
+ var _this;
13150
+ _this = ValueGetter.apply(this, arguments) || this;
13151
+ _this.value = new Vector2();
13152
+ return _this;
13153
+ }
13154
+ var _proto = Vector2Curve.prototype;
13155
+ _proto.onCreate = function onCreate(arg) {
13156
+ this.xCurve = createValueGetter(arg[0]);
13157
+ this.yCurve = createValueGetter(arg[1]);
13158
+ };
13159
+ _proto.getValue = function getValue(t) {
13160
+ var x = this.xCurve.getValue(t);
13161
+ var y = this.yCurve.getValue(t);
13162
+ this.value.set(x, y);
13163
+ return this.value;
13164
+ };
13165
+ return Vector2Curve;
13104
13166
  }(ValueGetter);
13105
13167
 
13106
13168
  var SPRITE_VERTEX_STRIDE = 6;
@@ -13165,6 +13227,8 @@ var map$1 = (_obj$3 = {}, _obj$3[ValueType.RANDOM] = function(props) {
13165
13227
  return new ColorCurve(props);
13166
13228
  }, _obj$3[ValueType.VECTOR4_CURVE] = function(props) {
13167
13229
  return new Vector4Curve(props);
13230
+ }, _obj$3[ValueType.VECTOR2_CURVE] = function(props) {
13231
+ return new Vector2Curve(props);
13168
13232
  }, _obj$3);
13169
13233
  function createValueGetter(args) {
13170
13234
  if (!args || !isNaN(+args)) {
@@ -13289,13 +13353,39 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13289
13353
  this.color = color;
13290
13354
  this.material.setVector4("_Color", new Vector4().setFromArray(color));
13291
13355
  };
13292
- /**
13293
- * 设置当前 Mesh 的纹理
13294
- * @since 2.0.0
13295
- * @param texture - 纹理对象
13296
- */ _proto.setTexture = function setTexture(texture) {
13297
- this.renderer.texture = texture;
13298
- this.material.setTexture("_MainTex", texture);
13356
+ _proto.setTexture = function setTexture(input) {
13357
+ var _this = this;
13358
+ return _async_to_generator(function() {
13359
+ var texture;
13360
+ return __generator(this, function(_state) {
13361
+ switch(_state.label){
13362
+ case 0:
13363
+ if (!(typeof input === "string")) return [
13364
+ 3,
13365
+ 2
13366
+ ];
13367
+ return [
13368
+ 4,
13369
+ Texture.fromImage(input, _this.item.engine)
13370
+ ];
13371
+ case 1:
13372
+ texture = _state.sent();
13373
+ return [
13374
+ 3,
13375
+ 3
13376
+ ];
13377
+ case 2:
13378
+ texture = input;
13379
+ _state.label = 3;
13380
+ case 3:
13381
+ _this.renderer.texture = texture;
13382
+ _this.material.setTexture("_MainTex", texture);
13383
+ return [
13384
+ 2
13385
+ ];
13386
+ }
13387
+ });
13388
+ })();
13299
13389
  };
13300
13390
  /**
13301
13391
  * @internal
@@ -13474,11 +13564,14 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13474
13564
  maxVertex: 4
13475
13565
  });
13476
13566
  };
13477
- _proto.createMaterial = function createMaterial(renderInfo, count) {
13478
- var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
13479
- var materialProps = {
13567
+ _proto.getMaterialProps = function getMaterialProps(renderInfo, count) {
13568
+ return {
13480
13569
  shader: spriteMeshShaderFromRenderInfo(renderInfo, count, 1)
13481
13570
  };
13571
+ };
13572
+ _proto.createMaterial = function createMaterial(renderInfo, count) {
13573
+ var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
13574
+ var materialProps = this.getMaterialProps(renderInfo, count);
13482
13575
  this.preMultiAlpha = getPreMultiAlpha(blending);
13483
13576
  var material = Material.create(this.engine, materialProps);
13484
13577
  var states = {
@@ -13557,6 +13650,8 @@ function getImageItemRenderInfo(item) {
13557
13650
  };
13558
13651
  }
13559
13652
 
13653
+ // Based on:
13654
+ // https://github.com/pixijs/pixijs/blob/dev/src/maths/shapes/ShapePrimitive.ts
13560
13655
  var ShapePrimitive = function ShapePrimitive() {
13561
13656
  };
13562
13657
 
@@ -14662,6 +14757,7 @@ function triangulate(contours) {
14662
14757
  return triangleVerts;
14663
14758
  }
14664
14759
 
14760
+ // Based on:
14665
14761
  /**
14666
14762
  * A class to define a shape via user defined coordinates.
14667
14763
  */ var Polygon = /*#__PURE__*/ function(ShapePrimitive) {
@@ -14761,12 +14857,13 @@ function triangulate(contours) {
14761
14857
  var triangles = triangulate([
14762
14858
  points
14763
14859
  ]);
14860
+ var indexStart = vertices.length / 2;
14764
14861
  for(var i = 0; i < triangles.length; i++){
14765
- vertices[verticesOffset + i] = triangles[i];
14862
+ vertices[verticesOffset * 2 + i] = triangles[i];
14766
14863
  }
14767
14864
  var vertexCount = triangles.length / 2;
14768
14865
  for(var i1 = 0; i1 < vertexCount; i1++){
14769
- indices[indicesOffset + i1] = i1;
14866
+ indices[indicesOffset + i1] = indexStart + i1;
14770
14867
  }
14771
14868
  };
14772
14869
  _create_class(Polygon, [
@@ -14888,6 +14985,7 @@ function recursive(x1, y1, x2, y2, x3, y3, x4, y4, points, distanceTolerance, le
14888
14985
  recursive(x1234, y1234, x234, y234, x34, y34, x4, y4, points, distanceTolerance, level + 1);
14889
14986
  }
14890
14987
 
14988
+ // Based on:
14891
14989
  /**
14892
14990
  * The Ellipse object is used to help draw graphics and can also be used to specify a hit area for containers.
14893
14991
  */ var Ellipse = /*#__PURE__*/ function(ShapePrimitive) {
@@ -15094,6 +15192,7 @@ function recursive(x1, y1, x2, y2, x3, y3, x4, y4, points, distanceTolerance, le
15094
15192
  return Ellipse;
15095
15193
  }(ShapePrimitive);
15096
15194
 
15195
+ // Based on:
15097
15196
  var StarType;
15098
15197
  (function(StarType) {
15099
15198
  StarType[StarType["Star"] = 0] = "Star";
@@ -15162,12 +15261,13 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15162
15261
  var triangles = triangulate([
15163
15262
  points
15164
15263
  ]);
15264
+ var indexStart = vertices.length / 2;
15165
15265
  for(var i = 0; i < triangles.length; i++){
15166
- vertices[verticesOffset + i] = triangles[i];
15266
+ vertices[verticesOffset * 2 + i] = triangles[i];
15167
15267
  }
15168
15268
  var vertexCount = triangles.length / 2;
15169
15269
  for(var i1 = 0; i1 < vertexCount; i1++){
15170
- indices[indicesOffset + i1] = i1;
15270
+ indices[indicesOffset + i1] = indexStart + i1;
15171
15271
  }
15172
15272
  };
15173
15273
  _proto.buildStarPath = function buildStarPath() {
@@ -15238,6 +15338,7 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15238
15338
  return PolyStar;
15239
15339
  }(ShapePrimitive);
15240
15340
 
15341
+ // Based on:
15241
15342
  // const tempPoints = [new Point(), new Point(), new Point(), new Point()];
15242
15343
  /**
15243
15344
  * The `Rectangle` object is an area defined by its position, as indicated by its upper-left corner
@@ -15561,6 +15662,7 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15561
15662
  return Rectangle;
15562
15663
  }(ShapePrimitive);
15563
15664
 
15665
+ // Based on:
15564
15666
  var ShapePath = /*#__PURE__*/ function() {
15565
15667
  function ShapePath(graphicsPath) {
15566
15668
  this.graphicsPath = graphicsPath;
@@ -15719,6 +15821,7 @@ var ShapePath = /*#__PURE__*/ function() {
15719
15821
  return ShapePath;
15720
15822
  }();
15721
15823
 
15824
+ // Based on:
15722
15825
  var GraphicsPath = /*#__PURE__*/ function() {
15723
15826
  function GraphicsPath() {
15724
15827
  this.instructions = [];
@@ -15856,14 +15959,433 @@ var GraphicsPath = /*#__PURE__*/ function() {
15856
15959
  return GraphicsPath;
15857
15960
  }();
15858
15961
 
15962
+ // Based on:
15963
+ /**
15964
+ * The Point object represents a location in a two-dimensional coordinate system, where `x` represents
15965
+ * the position on the horizontal axis and `y` represents the position on the vertical axis.
15966
+ */ var Point = /*#__PURE__*/ function() {
15967
+ function Point(x, y) {
15968
+ if (x === void 0) x = 0;
15969
+ if (y === void 0) y = 0;
15970
+ /**
15971
+ * Position of the point on the x axis
15972
+ */ this.x = 0;
15973
+ /**
15974
+ * Position of the point on the y axis
15975
+ */ this.y = 0;
15976
+ this.x = x;
15977
+ this.y = y;
15978
+ }
15979
+ var _proto = Point.prototype;
15980
+ /**
15981
+ * Creates a clone of this point
15982
+ * @returns A clone of this point
15983
+ */ _proto.clone = function clone() {
15984
+ return new Point(this.x, this.y);
15985
+ };
15986
+ /**
15987
+ * Copies `x` and `y` from the given point into this point
15988
+ * @param p - The point to copy from
15989
+ * @returns The point instance itself
15990
+ */ _proto.copyFrom = function copyFrom(p) {
15991
+ this.set(p.x, p.y);
15992
+ return this;
15993
+ };
15994
+ /**
15995
+ * Copies this point's x and y into the given point (`p`).
15996
+ * @param p - The point to copy to. Can be any of type that is or extends `PointData`
15997
+ * @returns The point (`p`) with values updated
15998
+ */ _proto.copyTo = function copyTo(p) {
15999
+ p.set(this.x, this.y);
16000
+ return p;
16001
+ };
16002
+ /**
16003
+ * Accepts another point (`p`) and returns `true` if the given point is equal to this point
16004
+ * @param p - The point to check
16005
+ * @returns Returns `true` if both `x` and `y` are equal
16006
+ */ _proto.equals = function equals(p) {
16007
+ return p.x === this.x && p.y === this.y;
16008
+ };
16009
+ /**
16010
+ * Sets the point to a new `x` and `y` position.
16011
+ * If `y` is omitted, both `x` and `y` will be set to `x`.
16012
+ * @param {number} [x=0] - position of the point on the `x` axis
16013
+ * @param {number} [y=x] - position of the point on the `y` axis
16014
+ * @returns The point instance itself
16015
+ */ _proto.set = function set(x, y) {
16016
+ if (x === void 0) x = 0;
16017
+ if (y === void 0) y = x;
16018
+ this.x = x;
16019
+ this.y = y;
16020
+ return this;
16021
+ };
16022
+ _create_class(Point, null, [
16023
+ {
16024
+ key: "shared",
16025
+ get: /**
16026
+ * A static Point object with `x` and `y` values of `0`. Can be used to avoid creating new objects multiple times.
16027
+ * @readonly
16028
+ */ function get() {
16029
+ tempPoint.x = 0;
16030
+ tempPoint.y = 0;
16031
+ return tempPoint;
16032
+ }
16033
+ }
16034
+ ]);
16035
+ return Point;
16036
+ }();
16037
+ var tempPoint = new Point();
16038
+
16039
+ // Based on:
16040
+ var closePointEps = 1e-4;
16041
+ var curveEps = 0.0001;
16042
+ /**
16043
+ * Buffers vertices to draw a square cap.
16044
+ *
16045
+ * @internal
16046
+ * @private
16047
+ * @param x - X-coord of end point
16048
+ * @param y - Y-coord of end point
16049
+ * @param nx - X-coord of line normal pointing inside
16050
+ * @param ny - Y-coord of line normal pointing inside
16051
+ * @param innerWeight - Weight of inner points
16052
+ * @param outerWeight - Weight of outer points
16053
+ * @param clockwise - Whether the cap is drawn clockwise
16054
+ * @param verts - vertex buffer
16055
+ * @returns - no. of vertices pushed
16056
+ */ function square(x, y, nx, ny, innerWeight, outerWeight, clockwise, /* rotation for square (true at left end, false at right end) */ verts) {
16057
+ var ix = x - nx * innerWeight;
16058
+ var iy = y - ny * innerWeight;
16059
+ var ox = x + nx * outerWeight;
16060
+ var oy = y + ny * outerWeight;
16061
+ /* Rotate nx,ny for extension vector */ var exx;
16062
+ var eyy;
16063
+ if (clockwise) {
16064
+ exx = ny;
16065
+ eyy = -nx;
16066
+ } else {
16067
+ exx = -ny;
16068
+ eyy = nx;
16069
+ }
16070
+ /* [i|0]x,y extended at cap */ var eix = ix + exx;
16071
+ var eiy = iy + eyy;
16072
+ var eox = ox + exx;
16073
+ var eoy = oy + eyy;
16074
+ /* Square itself must be inserted clockwise*/ verts.push(eix, eiy);
16075
+ verts.push(eox, eoy);
16076
+ return 2;
16077
+ }
16078
+ /**
16079
+ * Buffers vertices to draw an arc at the line joint or cap.
16080
+ *
16081
+ * @internal
16082
+ * @private
16083
+ * @param cx - X-coord of center
16084
+ * @param cy - Y-coord of center
16085
+ * @param sx - X-coord of arc start
16086
+ * @param sy - Y-coord of arc start
16087
+ * @param ex - X-coord of arc end
16088
+ * @param ey - Y-coord of arc end
16089
+ * @param verts - buffer of vertices
16090
+ * @param clockwise - orientation of vertices
16091
+ * @returns - no. of vertices pushed
16092
+ */ function round(cx, cy, sx, sy, ex, ey, verts, clockwise) {
16093
+ var cx2p0x = sx - cx;
16094
+ var cy2p0y = sy - cy;
16095
+ var angle0 = Math.atan2(cx2p0x, cy2p0y);
16096
+ var angle1 = Math.atan2(ex - cx, ey - cy);
16097
+ if (clockwise && angle0 < angle1) {
16098
+ angle0 += Math.PI * 2;
16099
+ } else if (!clockwise && angle0 > angle1) {
16100
+ angle1 += Math.PI * 2;
16101
+ }
16102
+ var startAngle = angle0;
16103
+ var angleDiff = angle1 - angle0;
16104
+ var absAngleDiff = Math.abs(angleDiff);
16105
+ var radius = Math.sqrt(cx2p0x * cx2p0x + cy2p0y * cy2p0y);
16106
+ var segCount = (15 * absAngleDiff * Math.sqrt(radius) / Math.PI >> 0) + 1;
16107
+ var angleInc = angleDiff / segCount;
16108
+ startAngle += angleInc;
16109
+ if (clockwise) {
16110
+ verts.push(cx, cy);
16111
+ verts.push(sx, sy);
16112
+ for(var i = 1, angle = startAngle; i < segCount; i++, angle += angleInc){
16113
+ verts.push(cx, cy);
16114
+ verts.push(cx + Math.sin(angle) * radius, cy + Math.cos(angle) * radius);
16115
+ }
16116
+ verts.push(cx, cy);
16117
+ verts.push(ex, ey);
16118
+ } else {
16119
+ verts.push(sx, sy);
16120
+ verts.push(cx, cy);
16121
+ for(var i1 = 1, angle2 = startAngle; i1 < segCount; i1++, angle2 += angleInc){
16122
+ verts.push(cx + Math.sin(angle2) * radius, cy + Math.cos(angle2) * radius);
16123
+ verts.push(cx, cy);
16124
+ }
16125
+ verts.push(ex, ey);
16126
+ verts.push(cx, cy);
16127
+ }
16128
+ return segCount * 2;
16129
+ }
16130
+ function getOrientationOfPoints(points) {
16131
+ var m = points.length;
16132
+ if (m < 6) {
16133
+ return 1;
16134
+ }
16135
+ var area = 0;
16136
+ for(var i = 0, x1 = points[m - 2], y1 = points[m - 1]; i < m; i += 2){
16137
+ var x2 = points[i];
16138
+ var y2 = points[i + 1];
16139
+ area += (x2 - x1) * (y2 + y1);
16140
+ x1 = x2;
16141
+ y1 = y2;
16142
+ }
16143
+ if (area < 0) {
16144
+ return -1;
16145
+ }
16146
+ return 1;
16147
+ }
16148
+ /**
16149
+ * Builds a line to draw using the polygon method.
16150
+ * @param points
16151
+ * @param lineStyle
16152
+ * @param flipAlignment
16153
+ * @param closed
16154
+ * @param vertices
16155
+ * @param _verticesStride
16156
+ * @param _verticesOffset
16157
+ * @param indices
16158
+ * @param _indicesOffset
16159
+ */ function buildLine(points, lineStyle, flipAlignment, closed, // alignment:number,
16160
+ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16161
+ // const shape = graphicsData.shape as Polygon;
16162
+ // let points = graphicsData.points || shape.points.slice();
16163
+ var eps = closePointEps;
16164
+ if (points.length === 0) {
16165
+ return;
16166
+ }
16167
+ var style = lineStyle;
16168
+ var alignment = style.alignment;
16169
+ if (lineStyle.alignment !== 0.5) {
16170
+ // rotate the points!
16171
+ var orientation = getOrientationOfPoints(points);
16172
+ if (flipAlignment) {
16173
+ orientation *= -1;
16174
+ }
16175
+ alignment = (alignment - 0.5) * orientation + 0.5;
16176
+ }
16177
+ // get first and last point.. figure out the middle!
16178
+ var firstPoint = new Point(points[0], points[1]);
16179
+ var lastPoint = new Point(points[points.length - 2], points[points.length - 1]);
16180
+ var closedShape = closed;
16181
+ var closedPath = Math.abs(firstPoint.x - lastPoint.x) < eps && Math.abs(firstPoint.y - lastPoint.y) < eps;
16182
+ // if the first point is the last point - gonna have issues :)
16183
+ if (closedShape) {
16184
+ // need to clone as we are going to slightly modify the shape..
16185
+ points = points.slice();
16186
+ if (closedPath) {
16187
+ points.pop();
16188
+ points.pop();
16189
+ lastPoint.set(points[points.length - 2], points[points.length - 1]);
16190
+ }
16191
+ var midPointX = (firstPoint.x + lastPoint.x) * 0.5;
16192
+ var midPointY = (lastPoint.y + firstPoint.y) * 0.5;
16193
+ points.unshift(midPointX, midPointY);
16194
+ points.push(midPointX, midPointY);
16195
+ }
16196
+ var verts = vertices;
16197
+ var length = points.length / 2;
16198
+ var indexCount = points.length;
16199
+ var indexStart = verts.length / 2;
16200
+ // Max. inner and outer width
16201
+ var width = style.width / 2;
16202
+ var widthSquared = width * width;
16203
+ var miterLimitSquared = style.miterLimit * style.miterLimit;
16204
+ /* Line segments of interest where (x1,y1) forms the corner. */ var x0 = points[0];
16205
+ var y0 = points[1];
16206
+ var x1 = points[2];
16207
+ var y1 = points[3];
16208
+ var x2 = 0;
16209
+ var y2 = 0;
16210
+ /* perp[?](x|y) = the line normal with magnitude lineWidth. */ var perpX = -(y0 - y1);
16211
+ var perpY = x0 - x1;
16212
+ var perp1x = 0;
16213
+ var perp1y = 0;
16214
+ var dist = Math.sqrt(perpX * perpX + perpY * perpY);
16215
+ perpX /= dist;
16216
+ perpY /= dist;
16217
+ perpX *= width;
16218
+ perpY *= width;
16219
+ var ratio = alignment; // 0.5;
16220
+ var innerWeight = (1 - ratio) * 2;
16221
+ var outerWeight = ratio * 2;
16222
+ if (!closedShape) {
16223
+ if (style.cap === "round") {
16224
+ indexCount += round(x0 - perpX * (innerWeight - outerWeight) * 0.5, y0 - perpY * (innerWeight - outerWeight) * 0.5, x0 - perpX * innerWeight, y0 - perpY * innerWeight, x0 + perpX * outerWeight, y0 + perpY * outerWeight, verts, true) + 2;
16225
+ } else if (style.cap === "square") {
16226
+ indexCount += square(x0, y0, perpX, perpY, innerWeight, outerWeight, true, verts);
16227
+ }
16228
+ }
16229
+ // Push first point (below & above vertices)
16230
+ verts.push(x0 - perpX * innerWeight, y0 - perpY * innerWeight);
16231
+ verts.push(x0 + perpX * outerWeight, y0 + perpY * outerWeight);
16232
+ for(var i = 1; i < length - 1; ++i){
16233
+ x0 = points[(i - 1) * 2];
16234
+ y0 = points[(i - 1) * 2 + 1];
16235
+ x1 = points[i * 2];
16236
+ y1 = points[i * 2 + 1];
16237
+ x2 = points[(i + 1) * 2];
16238
+ y2 = points[(i + 1) * 2 + 1];
16239
+ perpX = -(y0 - y1);
16240
+ perpY = x0 - x1;
16241
+ dist = Math.sqrt(perpX * perpX + perpY * perpY);
16242
+ perpX /= dist;
16243
+ perpY /= dist;
16244
+ perpX *= width;
16245
+ perpY *= width;
16246
+ perp1x = -(y1 - y2);
16247
+ perp1y = x1 - x2;
16248
+ dist = Math.sqrt(perp1x * perp1x + perp1y * perp1y);
16249
+ perp1x /= dist;
16250
+ perp1y /= dist;
16251
+ perp1x *= width;
16252
+ perp1y *= width;
16253
+ /* d[x|y](0|1) = the component displacement between points p(0,1|1,2) */ var dx0 = x1 - x0;
16254
+ var dy0 = y0 - y1;
16255
+ var dx1 = x1 - x2;
16256
+ var dy1 = y2 - y1;
16257
+ /* +ve if internal angle < 90 degree, -ve if internal angle > 90 degree. */ var dot = dx0 * dx1 + dy0 * dy1;
16258
+ /* +ve if internal angle counterclockwise, -ve if internal angle clockwise. */ var cross = dy0 * dx1 - dy1 * dx0;
16259
+ var clockwise = cross < 0;
16260
+ /* Going nearly parallel? */ /* atan(0.001) ~= 0.001 rad ~= 0.057 degree */ if (Math.abs(cross) < 0.001 * Math.abs(dot)) {
16261
+ verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
16262
+ verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
16263
+ /* 180 degree corner? */ if (dot >= 0) {
16264
+ if (style.join === "round") {
16265
+ indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 4;
16266
+ } else {
16267
+ indexCount += 2;
16268
+ }
16269
+ verts.push(x1 - perp1x * outerWeight, y1 - perp1y * outerWeight);
16270
+ verts.push(x1 + perp1x * innerWeight, y1 + perp1y * innerWeight);
16271
+ }
16272
+ continue;
16273
+ }
16274
+ /* p[x|y] is the miter point. pDist is the distance between miter point and p1. */ var c1 = (-perpX + x0) * (-perpY + y1) - (-perpX + x1) * (-perpY + y0);
16275
+ var c2 = (-perp1x + x2) * (-perp1y + y1) - (-perp1x + x1) * (-perp1y + y2);
16276
+ var px = (dx0 * c2 - dx1 * c1) / cross;
16277
+ var py = (dy1 * c1 - dy0 * c2) / cross;
16278
+ var pDist = (px - x1) * (px - x1) + (py - y1) * (py - y1);
16279
+ /* Inner miter point */ var imx = x1 + (px - x1) * innerWeight;
16280
+ var imy = y1 + (py - y1) * innerWeight;
16281
+ /* Outer miter point */ var omx = x1 - (px - x1) * outerWeight;
16282
+ var omy = y1 - (py - y1) * outerWeight;
16283
+ /* Is the inside miter point too far away, creating a spike? */ var smallerInsideSegmentSq = Math.min(dx0 * dx0 + dy0 * dy0, dx1 * dx1 + dy1 * dy1);
16284
+ var insideWeight = clockwise ? innerWeight : outerWeight;
16285
+ var smallerInsideDiagonalSq = smallerInsideSegmentSq + insideWeight * insideWeight * widthSquared;
16286
+ var insideMiterOk = pDist <= smallerInsideDiagonalSq;
16287
+ if (insideMiterOk) {
16288
+ if (style.join === "bevel" || pDist / widthSquared > miterLimitSquared) {
16289
+ if (clockwise) /* rotating at inner angle */ {
16290
+ verts.push(imx, imy); // inner miter point
16291
+ verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
16292
+ verts.push(imx, imy); // inner miter point
16293
+ verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight); // second segment's outer vertex
16294
+ } else /* rotating at outer angle */ {
16295
+ verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight); // first segment's inner vertex
16296
+ verts.push(omx, omy); // outer miter point
16297
+ verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight); // second segment's outer vertex
16298
+ verts.push(omx, omy); // outer miter point
16299
+ }
16300
+ indexCount += 2;
16301
+ } else if (style.join === "round") {
16302
+ if (clockwise) /* arc is outside */ {
16303
+ verts.push(imx, imy);
16304
+ verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
16305
+ indexCount += round(x1, y1, x1 + perpX * outerWeight, y1 + perpY * outerWeight, x1 + perp1x * outerWeight, y1 + perp1y * outerWeight, verts, true) + 4;
16306
+ verts.push(imx, imy);
16307
+ verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight);
16308
+ } else /* arc is inside */ {
16309
+ verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
16310
+ verts.push(omx, omy);
16311
+ indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 4;
16312
+ verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight);
16313
+ verts.push(omx, omy);
16314
+ }
16315
+ } else {
16316
+ verts.push(imx, imy);
16317
+ verts.push(omx, omy);
16318
+ }
16319
+ } else {
16320
+ verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight); // first segment's inner vertex
16321
+ verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
16322
+ if (style.join === "round") {
16323
+ if (clockwise) /* arc is outside */ {
16324
+ indexCount += round(x1, y1, x1 + perpX * outerWeight, y1 + perpY * outerWeight, x1 + perp1x * outerWeight, y1 + perp1y * outerWeight, verts, true) + 2;
16325
+ } else /* arc is inside */ {
16326
+ indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 2;
16327
+ }
16328
+ } else if (style.join === "miter" && pDist / widthSquared <= miterLimitSquared) {
16329
+ if (clockwise) {
16330
+ verts.push(omx, omy); // inner miter point
16331
+ verts.push(omx, omy); // inner miter point
16332
+ } else {
16333
+ verts.push(imx, imy); // outer miter point
16334
+ verts.push(imx, imy); // outer miter point
16335
+ }
16336
+ indexCount += 2;
16337
+ }
16338
+ verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight); // second segment's inner vertex
16339
+ verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight); // second segment's outer vertex
16340
+ indexCount += 2;
16341
+ }
16342
+ }
16343
+ x0 = points[(length - 2) * 2];
16344
+ y0 = points[(length - 2) * 2 + 1];
16345
+ x1 = points[(length - 1) * 2];
16346
+ y1 = points[(length - 1) * 2 + 1];
16347
+ perpX = -(y0 - y1);
16348
+ perpY = x0 - x1;
16349
+ dist = Math.sqrt(perpX * perpX + perpY * perpY);
16350
+ perpX /= dist;
16351
+ perpY /= dist;
16352
+ perpX *= width;
16353
+ perpY *= width;
16354
+ verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
16355
+ verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
16356
+ if (!closedShape) {
16357
+ if (style.cap === "round") {
16358
+ indexCount += round(x1 - perpX * (innerWeight - outerWeight) * 0.5, y1 - perpY * (innerWeight - outerWeight) * 0.5, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 + perpX * outerWeight, y1 + perpY * outerWeight, verts, false) + 2;
16359
+ } else if (style.cap === "square") {
16360
+ indexCount += square(x1, y1, perpX, perpY, innerWeight, outerWeight, false, verts);
16361
+ }
16362
+ }
16363
+ // const indices = graphicsGeometry.indices;
16364
+ var eps2 = curveEps * curveEps;
16365
+ // indices.push(indexStart);
16366
+ for(var i1 = indexStart; i1 < indexCount + indexStart - 2; ++i1){
16367
+ x0 = verts[i1 * 2];
16368
+ y0 = verts[i1 * 2 + 1];
16369
+ x1 = verts[(i1 + 1) * 2];
16370
+ y1 = verts[(i1 + 1) * 2 + 1];
16371
+ x2 = verts[(i1 + 2) * 2];
16372
+ y2 = verts[(i1 + 2) * 2 + 1];
16373
+ /* Skip zero area triangles */ if (Math.abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) < eps2) {
16374
+ continue;
16375
+ }
16376
+ indices.push(i1, i1 + 1, i1 + 2);
16377
+ }
16378
+ }
16379
+
15859
16380
  var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15860
16381
  _inherits(ShapeComponent, MeshComponent);
15861
16382
  function ShapeComponent(engine) {
15862
16383
  var _this;
15863
16384
  _this = MeshComponent.call(this, engine) || this;
15864
- _this.path = new GraphicsPath();
16385
+ _this.isStroke = false;
16386
+ _this.graphicsPath = new GraphicsPath();
15865
16387
  _this.curveValues = [];
15866
- _this.animated = true;
16388
+ _this.shapeDirty = true;
15867
16389
  _this.vert = "\nprecision highp float;\n\nattribute vec3 aPos;//x y\n\nuniform mat4 effects_MatrixVP;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_ObjectToWorld;\n\nvoid main() {\n vec4 pos = vec4(aPos.xyz, 1.0);\n gl_Position = effects_MatrixVP * effects_ObjectToWorld * pos;\n}\n";
15868
16390
  _this.frag = "\nprecision highp float;\n\nuniform vec4 _Color;\n\nvoid main() {\n vec4 color = _Color;\n color.rgb *= color.a;\n gl_FragColor = color;\n}\n";
15869
16391
  if (!_this.geometry) {
@@ -15911,6 +16433,20 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15911
16433
  _this.material.depthTest = true;
15912
16434
  _this.material.blending = true;
15913
16435
  }
16436
+ _this.strokeAttributes = {
16437
+ width: 1,
16438
+ alignment: 0.5,
16439
+ cap: "butt",
16440
+ join: "miter",
16441
+ miterLimit: 10
16442
+ };
16443
+ _this.shapeAttribute = {
16444
+ type: ShapePrimitiveType.Custom,
16445
+ points: [],
16446
+ easingIns: [],
16447
+ easingOuts: [],
16448
+ shapes: []
16449
+ };
15914
16450
  return _this;
15915
16451
  }
15916
16452
  var _proto = ShapeComponent.prototype;
@@ -15918,10 +16454,10 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15918
16454
  this.item.getHitTestParams = this.getHitTestParams;
15919
16455
  };
15920
16456
  _proto.onUpdate = function onUpdate(dt) {
15921
- if (this.animated) {
15922
- this.buildPath(this.data);
15923
- this.buildGeometryFromPath(this.path.shapePath);
15924
- this.animated = false;
16457
+ if (this.shapeDirty) {
16458
+ this.buildPath(this.shapeAttribute);
16459
+ this.buildGeometryFromPath(this.graphicsPath.shapePath);
16460
+ this.shapeDirty = false;
15925
16461
  }
15926
16462
  };
15927
16463
  _proto.buildGeometryFromPath = function buildGeometryFromPath(shapePath) {
@@ -15936,7 +16472,13 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15936
16472
  var indexOffset = indices.length;
15937
16473
  var vertOffset = vertices.length / 2;
15938
16474
  shape.build(points);
15939
- shape.triangulate(points, vertices, vertOffset, indices, indexOffset);
16475
+ if (!this.isStroke) {
16476
+ shape.triangulate(points, vertices, vertOffset, indices, indexOffset);
16477
+ } else {
16478
+ var close = true;
16479
+ var lineStyle = this.strokeAttributes;
16480
+ buildLine(points, lineStyle, false, close, vertices, 2, vertOffset, indices);
16481
+ }
15940
16482
  }
15941
16483
  var vertexCount = vertices.length / 2;
15942
16484
  // get the current attribute and index arrays from the geometry, avoiding re-creation
@@ -15949,7 +16491,7 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15949
16491
  if (!uvArray || uvArray.length < vertexCount * 2) {
15950
16492
  uvArray = new Float32Array(vertexCount * 2);
15951
16493
  }
15952
- if (!indexArray) {
16494
+ if (!indexArray || indexArray.length < indices.length) {
15953
16495
  indexArray = new Uint16Array(indices.length);
15954
16496
  }
15955
16497
  // set position and uv attribute array
@@ -15971,19 +16513,18 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15971
16513
  this.geometry.setIndexData(indexArray);
15972
16514
  this.geometry.setDrawCount(indices.length);
15973
16515
  };
15974
- _proto.buildPath = function buildPath(data) {
15975
- this.path.clear();
15976
- var shapeData = data;
15977
- switch(shapeData.type){
16516
+ _proto.buildPath = function buildPath(shapeAttribute) {
16517
+ this.graphicsPath.clear();
16518
+ switch(shapeAttribute.type){
15978
16519
  case ShapePrimitiveType.Custom:
15979
16520
  {
15980
- var customData = shapeData;
15981
- var points = customData.points;
15982
- var easingIns = customData.easingIns;
15983
- var easingOuts = customData.easingOuts;
15984
- this.curveValues = [];
15985
- for(var _iterator = _create_for_of_iterator_helper_loose(customData.shapes), _step; !(_step = _iterator()).done;){
16521
+ var customShapeAtribute = this.shapeAttribute;
16522
+ var points = customShapeAtribute.points;
16523
+ var easingIns = customShapeAtribute.easingIns;
16524
+ var easingOuts = customShapeAtribute.easingOuts;
16525
+ for(var _iterator = _create_for_of_iterator_helper_loose(customShapeAtribute.shapes), _step; !(_step = _iterator()).done;){
15986
16526
  var shape = _step.value;
16527
+ this.curveValues = [];
15987
16528
  this.setFillColor(shape.fill);
15988
16529
  var indices = shape.indexes;
15989
16530
  for(var i = 1; i < indices.length; i++){
@@ -16001,42 +16542,42 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16001
16542
  controlPoint1: easingOuts[indices[indices.length - 1].easingOut],
16002
16543
  controlPoint2: easingIns[indices[0].easingIn]
16003
16544
  });
16004
- }
16005
- this.path.moveTo(this.curveValues[this.curveValues.length - 1].point.x, this.curveValues[this.curveValues.length - 1].point.y);
16006
- for(var _iterator1 = _create_for_of_iterator_helper_loose(this.curveValues), _step1; !(_step1 = _iterator1()).done;){
16007
- var curveValue = _step1.value;
16008
- var point = curveValue.point;
16009
- var control1 = curveValue.controlPoint1;
16010
- var control2 = curveValue.controlPoint2;
16011
- this.path.bezierCurveTo(control1.x, control1.y, control2.x, control2.y, point.x, point.y, 1);
16545
+ this.graphicsPath.moveTo(this.curveValues[this.curveValues.length - 1].point.x, this.curveValues[this.curveValues.length - 1].point.y);
16546
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this.curveValues), _step1; !(_step1 = _iterator1()).done;){
16547
+ var curveValue = _step1.value;
16548
+ var point = curveValue.point;
16549
+ var control1 = curveValue.controlPoint1;
16550
+ var control2 = curveValue.controlPoint2;
16551
+ this.graphicsPath.bezierCurveTo(control1.x, control1.y, control2.x, control2.y, point.x, point.y, 1);
16552
+ }
16012
16553
  }
16013
16554
  break;
16014
16555
  }
16015
16556
  case ShapePrimitiveType.Ellipse:
16016
16557
  {
16017
- var ellipseData = shapeData;
16018
- this.path.ellipse(0, 0, ellipseData.xRadius, ellipseData.yRadius);
16558
+ var ellipseData = shapeAttribute;
16559
+ this.graphicsPath.ellipse(0, 0, ellipseData.xRadius, ellipseData.yRadius);
16019
16560
  this.setFillColor(ellipseData.fill);
16020
16561
  break;
16021
16562
  }
16022
16563
  case ShapePrimitiveType.Rectangle:
16023
16564
  {
16024
- var rectangleData = shapeData;
16025
- this.path.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height);
16565
+ var rectangleData = shapeAttribute;
16566
+ this.graphicsPath.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height);
16026
16567
  this.setFillColor(rectangleData.fill);
16027
16568
  break;
16028
16569
  }
16029
16570
  case ShapePrimitiveType.Star:
16030
16571
  {
16031
- var starData = shapeData;
16032
- this.path.polyStar(starData.pointCount, starData.outerRadius, starData.innerRadius, starData.outerRoundness, starData.innerRoundness, StarType.Star);
16572
+ var starData = shapeAttribute;
16573
+ this.graphicsPath.polyStar(starData.pointCount, starData.outerRadius, starData.innerRadius, starData.outerRoundness, starData.innerRoundness, StarType.Star);
16033
16574
  this.setFillColor(starData.fill);
16034
16575
  break;
16035
16576
  }
16036
16577
  case ShapePrimitiveType.Polygon:
16037
16578
  {
16038
- var polygonData = shapeData;
16039
- this.path.polyStar(polygonData.pointCount, polygonData.radius, polygonData.radius, polygonData.roundness, polygonData.roundness, StarType.Polygon);
16579
+ var polygonData = shapeAttribute;
16580
+ this.graphicsPath.polyStar(polygonData.pointCount, polygonData.radius, polygonData.radius, polygonData.roundness, polygonData.roundness, StarType.Polygon);
16040
16581
  this.setFillColor(polygonData.fill);
16041
16582
  break;
16042
16583
  }
@@ -16050,7 +16591,93 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16050
16591
  };
16051
16592
  _proto.fromData = function fromData(data) {
16052
16593
  MeshComponent.prototype.fromData.call(this, data);
16053
- this.data = data;
16594
+ this.shapeDirty = true;
16595
+ var strokeParam = data.stroke;
16596
+ if (strokeParam) {
16597
+ this.isStroke = true;
16598
+ this.strokeAttributes.width = strokeParam.width;
16599
+ }
16600
+ switch(data.type){
16601
+ case ShapePrimitiveType.Custom:
16602
+ {
16603
+ this.shapeAttribute = {
16604
+ type: ShapePrimitiveType.Custom,
16605
+ points: [],
16606
+ easingIns: [],
16607
+ easingOuts: [],
16608
+ shapes: []
16609
+ };
16610
+ var customShapeData = data;
16611
+ var customShapeAttribute = this.shapeAttribute;
16612
+ for(var _iterator = _create_for_of_iterator_helper_loose(customShapeData.points), _step; !(_step = _iterator()).done;){
16613
+ var point = _step.value;
16614
+ customShapeAttribute.points.push(new Vector2(point.x, point.y));
16615
+ }
16616
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(customShapeData.easingIns), _step1; !(_step1 = _iterator1()).done;){
16617
+ var easingIn = _step1.value;
16618
+ customShapeAttribute.easingIns.push(new Vector2(easingIn.x, easingIn.y));
16619
+ }
16620
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(customShapeData.easingOuts), _step2; !(_step2 = _iterator2()).done;){
16621
+ var easingOut = _step2.value;
16622
+ customShapeAttribute.easingOuts.push(new Vector2(easingOut.x, easingOut.y));
16623
+ }
16624
+ customShapeAttribute.shapes = customShapeData.shapes;
16625
+ break;
16626
+ }
16627
+ case ShapePrimitiveType.Ellipse:
16628
+ {
16629
+ var ellipseData = data;
16630
+ var ellipseAttribute = {
16631
+ type: ShapePrimitiveType.Ellipse,
16632
+ xRadius: ellipseData.xRadius,
16633
+ yRadius: ellipseData.yRadius,
16634
+ fill: ellipseData.fill
16635
+ };
16636
+ this.shapeAttribute = ellipseAttribute;
16637
+ break;
16638
+ }
16639
+ case ShapePrimitiveType.Rectangle:
16640
+ {
16641
+ var rectangleData = data;
16642
+ var rectangleAttribute = {
16643
+ type: ShapePrimitiveType.Rectangle,
16644
+ width: rectangleData.width,
16645
+ height: rectangleData.height,
16646
+ roundness: rectangleData.roundness,
16647
+ fill: rectangleData.fill
16648
+ };
16649
+ this.shapeAttribute = rectangleAttribute;
16650
+ break;
16651
+ }
16652
+ case ShapePrimitiveType.Star:
16653
+ {
16654
+ var starData = data;
16655
+ var starAttribute = {
16656
+ type: ShapePrimitiveType.Star,
16657
+ pointCount: starData.pointCount,
16658
+ innerRadius: starData.innerRadius,
16659
+ outerRadius: starData.outerRadius,
16660
+ innerRoundness: starData.innerRoundness,
16661
+ outerRoundness: starData.outerRoundness,
16662
+ fill: starData.fill
16663
+ };
16664
+ this.shapeAttribute = starAttribute;
16665
+ break;
16666
+ }
16667
+ case ShapePrimitiveType.Polygon:
16668
+ {
16669
+ var polygonData = data;
16670
+ var polygonAttribute = {
16671
+ type: ShapePrimitiveType.Polygon,
16672
+ pointCount: polygonData.pointCount,
16673
+ radius: polygonData.radius,
16674
+ roundness: polygonData.roundness,
16675
+ fill: polygonData.fill
16676
+ };
16677
+ this.shapeAttribute = polygonAttribute;
16678
+ break;
16679
+ }
16680
+ }
16054
16681
  var material = this.material;
16055
16682
  //@ts-expect-error // TODO 新版蒙版上线后重构
16056
16683
  material.stencilRef = data.renderer.mask !== undefined ? [
@@ -16060,6 +16687,15 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16060
16687
  //@ts-expect-error // TODO 新版蒙版上线后重构
16061
16688
  setMaskMode(material, data.renderer.maskMode);
16062
16689
  };
16690
+ _create_class(ShapeComponent, [
16691
+ {
16692
+ key: "shape",
16693
+ get: function get() {
16694
+ this.shapeDirty = true;
16695
+ return this.shapeAttribute;
16696
+ }
16697
+ }
16698
+ ]);
16063
16699
  return ShapeComponent;
16064
16700
  }(MeshComponent);
16065
16701
  ShapeComponent = __decorate([
@@ -18747,10 +19383,19 @@ var TEMPLATE_USE_OFFSCREEN_CANVAS = "offscreen_canvas";
18747
19383
  // 后处理配置相关
18748
19384
  var POST_PROCESS_SETTINGS = "post_process_settings";
18749
19385
  var config = {};
18750
- function getConfig(name) {
19386
+ /**
19387
+ * 获取全局配置项
19388
+ * @param name
19389
+ * @returns
19390
+ */ function getConfig(name) {
18751
19391
  return config[name];
18752
19392
  }
18753
- function setConfig(name, value) {
19393
+ /**
19394
+ * 设置全局配置项
19395
+ * @param name
19396
+ * @param value
19397
+ * @returns
19398
+ */ function setConfig(name, value) {
18754
19399
  return config[name] = value;
18755
19400
  }
18756
19401
 
@@ -20452,19 +21097,17 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
20452
21097
  rotation: rotation,
20453
21098
  path: path
20454
21099
  };
20455
- var parentTransform = this.transform.parentTransform;
20456
21100
  var selfPos = position.clone();
20457
21101
  if (path) {
20458
21102
  selfPos.add(path.getValue(0));
20459
21103
  }
20460
21104
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
20461
- if (this.options.particleFollowParent && parentTransform) {
20462
- var worldMatrix = parentTransform.getWorldMatrix();
21105
+ if (this.options.particleFollowParent) {
21106
+ var worldMatrix = this.transform.getWorldMatrix();
20463
21107
  this.renderer.updateWorldMatrix(worldMatrix);
20464
21108
  }
20465
21109
  };
20466
21110
  _proto.updateEmitterTransform = function updateEmitterTransform(time) {
20467
- var parentTransform = this.transform.parentTransform;
20468
21111
  var _this_basicTransform = this.basicTransform, path = _this_basicTransform.path, position = _this_basicTransform.position;
20469
21112
  var selfPos = position.clone();
20470
21113
  if (path) {
@@ -20472,8 +21115,8 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
20472
21115
  selfPos.add(path.getValue(time / duration));
20473
21116
  }
20474
21117
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
20475
- if (this.options.particleFollowParent && parentTransform) {
20476
- var worldMatrix = parentTransform.getWorldMatrix();
21118
+ if (this.options.particleFollowParent) {
21119
+ var worldMatrix = this.transform.getWorldMatrix();
20477
21120
  this.renderer.updateWorldMatrix(worldMatrix);
20478
21121
  }
20479
21122
  };
@@ -20861,7 +21504,7 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
20861
21504
  var lifetime = this.lifetime;
20862
21505
  var shape = this.shape;
20863
21506
  var speed = options.startSpeed.getValue(lifetime);
20864
- var matrix4 = options.particleFollowParent ? this.transform.getMatrix() : this.transform.getWorldMatrix();
21507
+ var matrix4 = options.particleFollowParent ? Matrix4.IDENTITY : this.transform.getWorldMatrix();
20865
21508
  var pointPosition = data.position;
20866
21509
  // 粒子的位置受发射器的位置影响,自身的旋转和缩放不受影响
20867
21510
  var position = matrix4.transformPoint(pointPosition, new Vector3());
@@ -23097,88 +23740,81 @@ var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
23097
23740
  return PropertyClipPlayable;
23098
23741
  }(Playable);
23099
23742
 
23100
- var ColorPropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23101
- _inherits(ColorPropertyMixerPlayable, TrackMixerPlayable);
23102
- function ColorPropertyMixerPlayable() {
23743
+ var PropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23744
+ _inherits(PropertyMixerPlayable, TrackMixerPlayable);
23745
+ function PropertyMixerPlayable() {
23103
23746
  var _this;
23104
23747
  _this = TrackMixerPlayable.apply(this, arguments) || this;
23105
23748
  _this.propertyName = "";
23106
23749
  return _this;
23107
23750
  }
23108
- var _proto = ColorPropertyMixerPlayable.prototype;
23751
+ var _proto = PropertyMixerPlayable.prototype;
23109
23752
  _proto.evaluate = function evaluate(context) {
23110
23753
  var boundObject = context.output.getUserData();
23111
23754
  if (!boundObject) {
23112
23755
  return;
23113
23756
  }
23114
23757
  var hasInput = false;
23115
- var value = boundObject[this.propertyName];
23116
- if (!_instanceof1(value, Color)) {
23758
+ this.propertyValue = boundObject[this.propertyName];
23759
+ if (this.propertyValue === undefined || this.propertyValue === null) {
23117
23760
  return;
23118
23761
  }
23119
- value.setZero();
23762
+ this.resetPropertyValue();
23120
23763
  // evaluate the curve
23121
23764
  for(var i = 0; i < this.clipPlayables.length; i++){
23122
23765
  var weight = this.getClipWeight(i);
23123
23766
  if (weight > 0) {
23124
23767
  var propertyClipPlayable = this.getClipPlayable(i);
23125
23768
  if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23126
- console.error("ColorPropertyMixerPlayable received incompatible input");
23769
+ console.error("PropertyTrack added non-PropertyPlayableAsset");
23127
23770
  continue;
23128
23771
  }
23129
23772
  var curveValue = propertyClipPlayable.value;
23130
- value.r += curveValue.r * weight;
23131
- value.g += curveValue.g * weight;
23132
- value.b += curveValue.b * weight;
23133
- value.a += curveValue.a * weight;
23773
+ this.addWeightedValue(curveValue, weight);
23134
23774
  hasInput = true;
23135
23775
  }
23136
23776
  }
23137
23777
  // set value
23138
23778
  if (hasInput) {
23139
- boundObject[this.propertyName] = value;
23779
+ boundObject[this.propertyName] = this.propertyValue;
23140
23780
  }
23141
23781
  };
23142
- return ColorPropertyMixerPlayable;
23782
+ return PropertyMixerPlayable;
23143
23783
  }(TrackMixerPlayable);
23144
23784
 
23145
- var FloatPropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23146
- _inherits(FloatPropertyMixerPlayable, TrackMixerPlayable);
23785
+ var ColorPropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
23786
+ _inherits(ColorPropertyMixerPlayable, PropertyMixerPlayable);
23787
+ function ColorPropertyMixerPlayable() {
23788
+ return PropertyMixerPlayable.apply(this, arguments);
23789
+ }
23790
+ var _proto = ColorPropertyMixerPlayable.prototype;
23791
+ _proto.resetPropertyValue = function resetPropertyValue() {
23792
+ this.propertyValue.setZero();
23793
+ };
23794
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
23795
+ var result = this.propertyValue;
23796
+ result.r += curveValue.r * weight;
23797
+ result.g += curveValue.g * weight;
23798
+ result.b += curveValue.b * weight;
23799
+ result.a += curveValue.a * weight;
23800
+ };
23801
+ return ColorPropertyMixerPlayable;
23802
+ }(PropertyMixerPlayable);
23803
+
23804
+ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
23805
+ _inherits(FloatPropertyMixerPlayable, PropertyMixerPlayable);
23147
23806
  function FloatPropertyMixerPlayable() {
23148
- var _this;
23149
- _this = TrackMixerPlayable.apply(this, arguments) || this;
23150
- _this.propertyName = "";
23151
- return _this;
23807
+ return PropertyMixerPlayable.apply(this, arguments);
23152
23808
  }
23153
23809
  var _proto = FloatPropertyMixerPlayable.prototype;
23154
- _proto.evaluate = function evaluate(context) {
23155
- var boundObject = context.output.getUserData();
23156
- if (!boundObject) {
23157
- return;
23158
- }
23159
- var hasInput = false;
23160
- var value = 0;
23161
- // evaluate the curve
23162
- for(var i = 0; i < this.clipPlayables.length; i++){
23163
- var weight = this.getClipWeight(i);
23164
- if (weight > 0) {
23165
- var propertyClipPlayable = this.getClipPlayable(i);
23166
- if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23167
- console.error("FloatPropertyTrack added non-FloatPropertyPlayableAsset");
23168
- continue;
23169
- }
23170
- var curveValue = propertyClipPlayable.value;
23171
- value += curveValue * weight;
23172
- hasInput = true;
23173
- }
23174
- }
23175
- // set value
23176
- if (hasInput) {
23177
- boundObject[this.propertyName] = value;
23178
- }
23810
+ _proto.resetPropertyValue = function resetPropertyValue() {
23811
+ this.propertyValue = 0;
23812
+ };
23813
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
23814
+ this.propertyValue += curveValue * weight;
23179
23815
  };
23180
23816
  return FloatPropertyMixerPlayable;
23181
- }(TrackMixerPlayable);
23817
+ }(PropertyMixerPlayable);
23182
23818
 
23183
23819
  var ParticleMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23184
23820
  _inherits(ParticleMixerPlayable, TrackMixerPlayable);
@@ -23690,7 +24326,7 @@ var SerializationHelper = /*#__PURE__*/ function() {
23690
24326
  this.timelinePlayable.setTime(time);
23691
24327
  // The properties of the object may change dynamically,
23692
24328
  // so reset the track binding to avoid invalidation of the previously obtained binding object.
23693
- // this.resolveBindings();
24329
+ this.resolveBindings();
23694
24330
  this.timelinePlayable.evaluate();
23695
24331
  this.graph.evaluate(dt);
23696
24332
  };
@@ -23922,50 +24558,44 @@ var TransformMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23922
24558
  return TransformMixerPlayable;
23923
24559
  }(TrackMixerPlayable);
23924
24560
 
23925
- var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23926
- _inherits(Vector4PropertyMixerPlayable, TrackMixerPlayable);
24561
+ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
24562
+ _inherits(Vector4PropertyMixerPlayable, PropertyMixerPlayable);
23927
24563
  function Vector4PropertyMixerPlayable() {
23928
- var _this;
23929
- _this = TrackMixerPlayable.apply(this, arguments) || this;
23930
- _this.propertyName = "";
23931
- return _this;
24564
+ return PropertyMixerPlayable.apply(this, arguments);
23932
24565
  }
23933
24566
  var _proto = Vector4PropertyMixerPlayable.prototype;
23934
- _proto.evaluate = function evaluate(context) {
23935
- var boundObject = context.output.getUserData();
23936
- if (!boundObject) {
23937
- return;
23938
- }
23939
- var hasInput = false;
23940
- var value = boundObject[this.propertyName];
23941
- if (!_instanceof1(value, Vector4)) {
23942
- return;
23943
- }
23944
- value.setZero();
23945
- // evaluate the curve
23946
- for(var i = 0; i < this.clipPlayables.length; i++){
23947
- var weight = this.getClipWeight(i);
23948
- if (weight > 0) {
23949
- var propertyClipPlayable = this.getClipPlayable(i);
23950
- if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23951
- console.error("Vector4PropertyTrack added non-Vector4PropertyPlayableAsset");
23952
- continue;
23953
- }
23954
- var curveValue = propertyClipPlayable.value;
23955
- value.x += curveValue.x * weight;
23956
- value.y += curveValue.y * weight;
23957
- value.z += curveValue.z * weight;
23958
- value.w += curveValue.w * weight;
23959
- hasInput = true;
23960
- }
23961
- }
23962
- // set value
23963
- if (hasInput) {
23964
- boundObject[this.propertyName] = value;
23965
- }
24567
+ _proto.resetPropertyValue = function resetPropertyValue() {
24568
+ this.propertyValue.x = 0;
24569
+ this.propertyValue.y = 0;
24570
+ this.propertyValue.z = 0;
24571
+ this.propertyValue.w = 0;
24572
+ };
24573
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
24574
+ var result = this.propertyValue;
24575
+ result.x += curveValue.x * weight;
24576
+ result.y += curveValue.y * weight;
24577
+ result.z += curveValue.z * weight;
24578
+ result.w += curveValue.w * weight;
23966
24579
  };
23967
24580
  return Vector4PropertyMixerPlayable;
23968
- }(TrackMixerPlayable);
24581
+ }(PropertyMixerPlayable);
24582
+ var Vector2PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
24583
+ _inherits(Vector2PropertyMixerPlayable, PropertyMixerPlayable);
24584
+ function Vector2PropertyMixerPlayable() {
24585
+ return PropertyMixerPlayable.apply(this, arguments);
24586
+ }
24587
+ var _proto = Vector2PropertyMixerPlayable.prototype;
24588
+ _proto.resetPropertyValue = function resetPropertyValue() {
24589
+ this.propertyValue.x = 0;
24590
+ this.propertyValue.y = 0;
24591
+ };
24592
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
24593
+ var result = this.propertyValue;
24594
+ result.x += curveValue.x * weight;
24595
+ result.y += curveValue.y * weight;
24596
+ };
24597
+ return Vector2PropertyMixerPlayable;
24598
+ }(PropertyMixerPlayable);
23969
24599
 
23970
24600
  /**
23971
24601
  * @since 2.0.0
@@ -24346,6 +24976,26 @@ var Vector4PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
24346
24976
  Vector4PropertyTrack = __decorate([
24347
24977
  effectsClass(DataType.Vector4PropertyTrack)
24348
24978
  ], Vector4PropertyTrack);
24979
+ var Vector2PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
24980
+ _inherits(Vector2PropertyTrack, PropertyTrack);
24981
+ function Vector2PropertyTrack() {
24982
+ return PropertyTrack.apply(this, arguments);
24983
+ }
24984
+ var _proto = Vector2PropertyTrack.prototype;
24985
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24986
+ var mixer = new Vector2PropertyMixerPlayable(graph);
24987
+ var propertyNames = this.propertyNames;
24988
+ if (propertyNames.length > 0) {
24989
+ var propertyName = propertyNames[propertyNames.length - 1];
24990
+ mixer.propertyName = propertyName;
24991
+ }
24992
+ return mixer;
24993
+ };
24994
+ return Vector2PropertyTrack;
24995
+ }(PropertyTrack);
24996
+ Vector2PropertyTrack = __decorate([
24997
+ effectsClass("Vector2PropertyTrack")
24998
+ ], Vector2PropertyTrack);
24349
24999
 
24350
25000
  var ColorPropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
24351
25001
  _inherits(ColorPropertyTrack, PropertyTrack);
@@ -24612,8 +25262,28 @@ __decorate([
24612
25262
  serialize()
24613
25263
  ], Vector4PropertyPlayableAsset.prototype, "curveData", void 0);
24614
25264
  Vector4PropertyPlayableAsset = __decorate([
24615
- effectsClass("Vector4PropertyPlayableAsset")
25265
+ effectsClass(DataType.Vector4PropertyPlayableAsset)
24616
25266
  ], Vector4PropertyPlayableAsset);
25267
+ var Vector2PropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
25268
+ _inherits(Vector2PropertyPlayableAsset, PlayableAsset);
25269
+ function Vector2PropertyPlayableAsset() {
25270
+ return PlayableAsset.apply(this, arguments);
25271
+ }
25272
+ var _proto = Vector2PropertyPlayableAsset.prototype;
25273
+ _proto.createPlayable = function createPlayable(graph) {
25274
+ var clipPlayable = new PropertyClipPlayable(graph);
25275
+ clipPlayable.curve = createValueGetter(this.curveData);
25276
+ clipPlayable.value = clipPlayable.curve.getValue(0);
25277
+ return clipPlayable;
25278
+ };
25279
+ return Vector2PropertyPlayableAsset;
25280
+ }(PlayableAsset);
25281
+ __decorate([
25282
+ serialize()
25283
+ ], Vector2PropertyPlayableAsset.prototype, "curveData", void 0);
25284
+ Vector2PropertyPlayableAsset = __decorate([
25285
+ effectsClass(DataType.Vector2PropertyPlayableAsset)
25286
+ ], Vector2PropertyPlayableAsset);
24617
25287
 
24618
25288
  var ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset) {
24619
25289
  _inherits(ObjectBindingTrack, TrackAsset);
@@ -25996,7 +26666,7 @@ function getStandardInteractContent(ui) {
25996
26666
  }
25997
26667
  });
25998
26668
  });
25999
- json.version = "2.1";
26669
+ json.version = JSONSceneVersion["2_1"];
26000
26670
  return json;
26001
26671
  }
26002
26672
  /**
@@ -26335,7 +27005,7 @@ function getStandardInteractContent(ui) {
26335
27005
  break;
26336
27006
  }
26337
27007
  }
26338
- result.version = "3.0";
27008
+ result.version = JSONSceneVersion["3_0"];
26339
27009
  return result;
26340
27010
  }
26341
27011
  /**
@@ -26877,13 +27547,13 @@ function getStandardJSON(json) {
26877
27547
  }
26878
27548
  throw new Error("Invalid JSON version: " + json.version + ".");
26879
27549
  }
26880
- var currentVersion = "1.0";
27550
+ var currentVersion = JSONSceneVersion["1_0"];
26881
27551
  function getStandardJSONFromV0(json) {
26882
27552
  var _json_bins;
26883
- currentVersion = "1.0";
27553
+ currentVersion = JSONSceneVersion["1_0"];
26884
27554
  var plugins = json.plugins || [];
26885
27555
  if ((_json_bins = json.bins) == null ? void 0 : _json_bins.length) {
26886
- currentVersion = "1.3";
27556
+ currentVersion = JSONSceneVersion["1_3"];
26887
27557
  }
26888
27558
  var requires = (json.requires || []).slice();
26889
27559
  var images = json.images.map(function(img, index) {
@@ -28806,7 +29476,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
28806
29476
  */ _proto.getSpeed = function getSpeed() {
28807
29477
  return this.speed;
28808
29478
  };
28809
- _proto.play = function play() {
29479
+ /**
29480
+ *
29481
+ */ _proto.play = function play() {
28810
29482
  if (this.isEnded && this.reusable) {
28811
29483
  this.restart();
28812
29484
  }
@@ -28821,7 +29493,10 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
28821
29493
  */ _proto.pause = function pause() {
28822
29494
  this.paused = true;
28823
29495
  };
28824
- _proto.getPaused = function getPaused() {
29496
+ /**
29497
+ *
29498
+ * @returns
29499
+ */ _proto.getPaused = function getPaused() {
28825
29500
  return this.paused;
28826
29501
  };
28827
29502
  /**
@@ -31399,8 +32074,8 @@ registerPlugin("sprite", SpriteLoader, VFXItem, true);
31399
32074
  registerPlugin("particle", ParticleLoader, VFXItem, true);
31400
32075
  registerPlugin("cal", CalculateLoader, VFXItem, true);
31401
32076
  registerPlugin("interact", InteractLoader, VFXItem, true);
31402
- var version = "2.2.6";
32077
+ var version = "2.3.0-alpha.1";
31403
32078
  logger.info("Core version: " + version + ".");
31404
32079
 
31405
- export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, Asset, AssetLoader, AssetManager, BYTES_TYPE_MAP, BaseRenderComponent, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, ColorCurve, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatPropertyPlayableAsset, FloatPropertyTrack, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, MaterialTrack, Mesh, MeshCollider, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, PropertyTrack, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, Vector4Curve, Vector4PropertyPlayableAsset, Vector4PropertyTrack, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
32080
+ export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, Asset, AssetLoader, AssetManager, BYTES_TYPE_MAP, BaseRenderComponent, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, ColorCurve, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatPropertyPlayableAsset, FloatPropertyTrack, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, MaterialTrack, Mesh, MeshCollider, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, PropertyTrack, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, Vector2Curve, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector4Curve, Vector4PropertyPlayableAsset, Vector4PropertyTrack, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
31406
32081
  //# sourceMappingURL=index.mjs.map