@galacean/effects-threejs 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.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.2.6
6
+ * Version: v2.3.0-alpha.1
7
7
  */
8
8
 
9
9
  'use strict';
@@ -1044,6 +1044,26 @@ function _inherits(subClass, superClass) {
1044
1044
  if (superClass) _set_prototype_of(subClass, superClass);
1045
1045
  }
1046
1046
 
1047
+ /**
1048
+ * JSON 版本
1049
+ */ var JSONSceneVersion;
1050
+ (function(JSONSceneVersion) {
1051
+ JSONSceneVersion["1_0"] = "1.0";
1052
+ JSONSceneVersion["1_1"] = "1.1";
1053
+ JSONSceneVersion["1_2"] = "1.2";
1054
+ JSONSceneVersion["1_3"] = "1.3";
1055
+ JSONSceneVersion["1_5"] = "1.5";
1056
+ JSONSceneVersion["1_8"] = "1.8";
1057
+ JSONSceneVersion["2_0"] = "2.0";
1058
+ JSONSceneVersion["2_1"] = "2.1";
1059
+ JSONSceneVersion["2_2"] = "2.2";
1060
+ JSONSceneVersion["2_3"] = "2.3";
1061
+ JSONSceneVersion["2_4"] = "2.4";
1062
+ JSONSceneVersion["3_0"] = "3.0";
1063
+ JSONSceneVersion["3_1"] = "3.1";
1064
+ JSONSceneVersion["LATEST"] = "3.1";
1065
+ })(JSONSceneVersion || (JSONSceneVersion = {}));
1066
+
1047
1067
  /*********************************************/ /* 元素属性参数类型 */ /*********************************************/ /**
1048
1068
  * 渲染等级
1049
1069
  */ var RenderLevel;
@@ -1349,8 +1369,12 @@ var RenderFace;
1349
1369
  */ var END_BEHAVIOR_DESTROY_CHILDREN = 6;
1350
1370
  var CAMERA_CLIP_MODE_VERTICAL = 1;
1351
1371
  var CAMERA_CLIP_MODE_NORMAL = 0;
1352
- var MESSAGE_ITEM_PHRASE_BEGIN = 2;
1353
- var MESSAGE_ITEM_PHRASE_END = 1;
1372
+ /**
1373
+ * 消息开始
1374
+ */ var MESSAGE_ITEM_PHRASE_BEGIN = 2;
1375
+ /**
1376
+ * 消息结束
1377
+ */ var MESSAGE_ITEM_PHRASE_END = 1;
1354
1378
 
1355
1379
  var CameraClipMode;
1356
1380
  (function(CameraClipMode) {
@@ -1424,6 +1448,9 @@ var CameraClipMode;
1424
1448
  /**
1425
1449
  * Vector4 曲线
1426
1450
  */ ValueType[ValueType["VECTOR4_CURVE"] = 25] = "VECTOR4_CURVE";
1451
+ /**
1452
+ * Vector2 曲线
1453
+ */ ValueType[ValueType["VECTOR2_CURVE"] = 26] = "VECTOR2_CURVE";
1427
1454
  })(ValueType || (ValueType = {}));
1428
1455
  /**
1429
1456
  * 关键帧类型
@@ -1692,19 +1719,13 @@ var ShapePointType;
1692
1719
  var DataType;
1693
1720
  (function(DataType) {
1694
1721
  DataType["VFXItemData"] = "VFXItemData";
1695
- DataType["EffectComponent"] = "EffectComponent";
1722
+ // Assets
1696
1723
  DataType["Material"] = "Material";
1697
1724
  DataType["Shader"] = "Shader";
1698
- DataType["SpriteComponent"] = "SpriteComponent";
1699
- DataType["ParticleSystem"] = "ParticleSystem";
1700
- DataType["InteractComponent"] = "InteractComponent";
1701
- DataType["CameraController"] = "CameraController";
1702
- DataType["PostProcessVolume"] = "PostProcessVolume";
1703
1725
  DataType["Geometry"] = "Geometry";
1704
1726
  DataType["Texture"] = "Texture";
1705
1727
  DataType["Image"] = "Image";
1706
1728
  DataType["AnimationClip"] = "AnimationClip";
1707
- DataType["TextComponent"] = "TextComponent";
1708
1729
  DataType["BinaryAsset"] = "BinaryAsset";
1709
1730
  // Timeline
1710
1731
  DataType["TrackAsset"] = "TrackAsset";
@@ -1716,6 +1737,7 @@ var DataType;
1716
1737
  DataType["SubCompositionTrack"] = "SubCompositionTrack";
1717
1738
  DataType["FloatPropertyTrack"] = "FloatPropertyTrack";
1718
1739
  DataType["ColorPropertyTrack"] = "ColorPropertyTrack";
1740
+ DataType["Vector2PropertyTrack"] = "Vector2PropertyTrack";
1719
1741
  DataType["Vector4PropertyTrack"] = "Vector4PropertyTrack";
1720
1742
  DataType["TransformPlayableAsset"] = "TransformPlayableAsset";
1721
1743
  DataType["SpriteColorPlayableAsset"] = "SpriteColorPlayableAsset";
@@ -1723,6 +1745,9 @@ var DataType;
1723
1745
  DataType["SubCompositionPlayableAsset"] = "SubCompositionPlayableAsset";
1724
1746
  DataType["FloatPropertyPlayableAsset"] = "FloatPropertyPlayableAsset";
1725
1747
  DataType["ColorPropertyPlayableAsset"] = "ColorPropertyPlayableAsset";
1748
+ DataType["Vector2PropertyPlayableAsset"] = "Vector2PropertyPlayableAsset";
1749
+ DataType["Vector4PropertyPlayableAsset"] = "Vector4PropertyPlayableAsset";
1750
+ // Components
1726
1751
  DataType["MeshComponent"] = "MeshComponent";
1727
1752
  DataType["SkyboxComponent"] = "SkyboxComponent";
1728
1753
  DataType["LightComponent"] = "LightComponent";
@@ -1736,6 +1761,13 @@ var DataType;
1736
1761
  DataType["RichTextComponent"] = "RichTextComponent";
1737
1762
  DataType["OrientationComponent"] = "OrientationComponent";
1738
1763
  DataType["ShapeComponent"] = "ShapeComponent";
1764
+ DataType["SpriteComponent"] = "SpriteComponent";
1765
+ DataType["ParticleSystem"] = "ParticleSystem";
1766
+ DataType["InteractComponent"] = "InteractComponent";
1767
+ DataType["CameraController"] = "CameraController";
1768
+ DataType["PostProcessVolume"] = "PostProcessVolume";
1769
+ DataType["EffectComponent"] = "EffectComponent";
1770
+ DataType["TextComponent"] = "TextComponent";
1739
1771
  // Non-EffectObject
1740
1772
  DataType["TimelineClip"] = "TimelineClip";
1741
1773
  })(DataType || (DataType = {}));
@@ -1824,8 +1856,11 @@ var VertexBufferSemantic;
1824
1856
  VertexBufferSemantic["TangentBS3"] = "TANGENT_BS3";
1825
1857
  })(VertexBufferSemantic || (VertexBufferSemantic = {}));
1826
1858
 
1859
+ var LATEST_VERSION = JSONSceneVersion.LATEST;
1860
+
1827
1861
  var index$1 = /*#__PURE__*/Object.freeze({
1828
1862
  __proto__: null,
1863
+ LATEST_VERSION: LATEST_VERSION,
1829
1864
  get RenderLevel () { return RenderLevel; },
1830
1865
  get BlendingMode () { return BlendingMode; },
1831
1866
  get SideMode () { return SideMode; },
@@ -1853,6 +1888,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
1853
1888
  MESSAGE_ITEM_PHRASE_END: MESSAGE_ITEM_PHRASE_END,
1854
1889
  get ValueType () { return ValueType; },
1855
1890
  get BezierKeyframeType () { return BezierKeyframeType; },
1891
+ get JSONSceneVersion () { return JSONSceneVersion; },
1856
1892
  get EndBehavior () { return EndBehavior; },
1857
1893
  get ParentItemEndBehavior () { return ParentItemEndBehavior; },
1858
1894
  get ParticleInteractionBehavior () { return ParticleInteractionBehavior; },
@@ -5300,418 +5336,6 @@ Matrix4.tempVec1 = new Vector3();
5300
5336
  Matrix4.tempVec2 = new Vector3();
5301
5337
  Matrix4.tempMat0 = new Matrix4();
5302
5338
 
5303
- function _array_like_to_array(arr, len) {
5304
- if (len == null || len > arr.length) len = arr.length;
5305
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5306
- return arr2;
5307
- }
5308
-
5309
- function _unsupported_iterable_to_array(o, minLen) {
5310
- if (!o) return;
5311
- if (typeof o === "string") return _array_like_to_array(o, minLen);
5312
- var n = Object.prototype.toString.call(o).slice(8, -1);
5313
- if (n === "Object" && o.constructor) n = o.constructor.name;
5314
- if (n === "Map" || n === "Set") return Array.from(n);
5315
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
5316
- }
5317
-
5318
- function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
5319
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
5320
- if (it) return (it = it.call(o)).next.bind(it);
5321
- // Fallback for engines without symbol support
5322
- if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
5323
- if (it) o = it;
5324
- var i = 0;
5325
- return function() {
5326
- if (i >= o.length) return {
5327
- done: true
5328
- };
5329
- return {
5330
- done: false,
5331
- value: o[i++]
5332
- };
5333
- };
5334
- }
5335
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5336
- }
5337
-
5338
- exports.ShaderCompileResultStatus = void 0;
5339
- (function(ShaderCompileResultStatus) {
5340
- ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
5341
- ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
5342
- ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
5343
- ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
5344
- })(exports.ShaderCompileResultStatus || (exports.ShaderCompileResultStatus = {}));
5345
- exports.GLSLVersion = void 0;
5346
- (function(GLSLVersion) {
5347
- GLSLVersion["GLSL1"] = "100";
5348
- GLSLVersion["GLSL3"] = "300 es";
5349
- })(exports.GLSLVersion || (exports.GLSLVersion = {}));
5350
- var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
5351
- _inherits(ShaderVariant, EffectsObject);
5352
- function ShaderVariant(engine, source) {
5353
- var _this;
5354
- _this = EffectsObject.call(this, engine) || this;
5355
- _this.source = source;
5356
- return _this;
5357
- }
5358
- return ShaderVariant;
5359
- }(EffectsObject);
5360
- exports.Shader = /*#__PURE__*/ function(EffectsObject) {
5361
- _inherits(Shader, EffectsObject);
5362
- function Shader() {
5363
- return EffectsObject.apply(this, arguments);
5364
- }
5365
- var _proto = Shader.prototype;
5366
- _proto.createVariant = function createVariant(macros) {
5367
- var shaderMacros = [];
5368
- if (macros) {
5369
- for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
5370
- var key = _step.value;
5371
- shaderMacros.push([
5372
- key,
5373
- macros[key]
5374
- ]);
5375
- }
5376
- }
5377
- var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
5378
- shaderVariant.shader = this;
5379
- return shaderVariant;
5380
- };
5381
- _proto.fromData = function fromData(data) {
5382
- EffectsObject.prototype.fromData.call(this, data);
5383
- this.shaderData = data;
5384
- };
5385
- return Shader;
5386
- }(EffectsObject);
5387
- exports.Shader = __decorate([
5388
- effectsClass(DataType.Shader)
5389
- ], exports.Shader);
5390
-
5391
- var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
5392
- var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
5393
- 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}";
5394
- 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";
5395
- function createCopyShader(level, writeDepth) {
5396
- var webgl2 = level === 2;
5397
- return {
5398
- name: EFFECTS_COPY_MESH_NAME,
5399
- vertex: COPY_VERTEX_SHADER,
5400
- fragment: COPY_FRAGMENT_SHADER,
5401
- glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
5402
- macros: [
5403
- [
5404
- "DEPTH_TEXTURE",
5405
- !!writeDepth
5406
- ]
5407
- ],
5408
- // @ts-expect-error
5409
- cacheId: COPY_MESH_SHADER_ID + +writeDepth
5410
- };
5411
- }
5412
-
5413
- /**
5414
- * Helper class to create a WebGL Context
5415
- *
5416
- * @param canvas
5417
- * @param glType
5418
- * @param options
5419
- * @returns
5420
- */ function createGLContext(canvas, glType, options) {
5421
- if (glType === void 0) glType = "webgl";
5422
- var context;
5423
- if (glType === "webgl2") {
5424
- context = canvas.getContext("webgl2", options);
5425
- if (!context) {
5426
- console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
5427
- }
5428
- }
5429
- if (!context || glType === "webgl") {
5430
- context = canvas.getContext("webgl", options);
5431
- }
5432
- if (!context) {
5433
- throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
5434
- }
5435
- return context;
5436
- }
5437
-
5438
- function gpuTimer(gl) {
5439
- var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
5440
- if (ext) {
5441
- var query = gl.createQuery();
5442
- var getTime = /*#__PURE__*/ _async_to_generator(function() {
5443
- return __generator(this, function(_state) {
5444
- return [
5445
- 2,
5446
- new Promise(function(resolve, reject) {
5447
- if (query) {
5448
- var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
5449
- var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
5450
- if (available && !disjoint) {
5451
- // See how much time the rendering of the object took in nanoseconds.
5452
- var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
5453
- // taken to use all significant bits of the result, not just the
5454
- // least significant 32 bits.
5455
- resolve(timeElapsed / 1000 / 1000);
5456
- }
5457
- if (available || disjoint) {
5458
- // Clean up the query object.
5459
- gl.deleteQuery(query); // Don't re-enter this polling loop.
5460
- query = null;
5461
- }
5462
- available !== null && query && window.setTimeout(function() {
5463
- getTime().then(resolve).catch;
5464
- }, 1);
5465
- }
5466
- })
5467
- ];
5468
- });
5469
- });
5470
- if (!query) {
5471
- return;
5472
- }
5473
- return {
5474
- begin: function() {
5475
- query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
5476
- },
5477
- end: function() {
5478
- gl.endQuery(ext.TIME_ELAPSED_EXT);
5479
- },
5480
- getTime: getTime
5481
- };
5482
- }
5483
- }
5484
-
5485
- var initErrors = [];
5486
- // @ts-expect-error
5487
- var glContext = {};
5488
- if (!initErrors.length) {
5489
- initGLContext();
5490
- }
5491
- function initGLContext() {
5492
- // 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
5493
- if (typeof WebGL2RenderingContext === "function") {
5494
- copy(WebGL2RenderingContext);
5495
- } else if (typeof WebGLRenderingContext !== "undefined") {
5496
- copy(WebGLRenderingContext);
5497
- copy(WebGLRenderingContext.prototype);
5498
- } else {
5499
- initErrors.push(// iOS 16 lockdown mode
5500
- "iOS16 lockdown mode, WebGL Constants not in global");
5501
- }
5502
- if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
5503
- // @ts-expect-error set default value
5504
- glContext["HALF_FLOAT"] = 5131;
5505
- }
5506
- }
5507
- function isWebGL2(gl) {
5508
- return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
5509
- }
5510
- function copy(target) {
5511
- for(var name in target){
5512
- if (/^[A-Z_]/.test(name)) {
5513
- // @ts-expect-error safe to assign
5514
- glContext[name] = target[name];
5515
- }
5516
- }
5517
- }
5518
- function vertexFormatType2GLType(formatType) {
5519
- switch(formatType){
5520
- case VertexFormatType.Float32:
5521
- return WebGLRenderingContext["FLOAT"];
5522
- case VertexFormatType.Int16:
5523
- return WebGLRenderingContext["SHORT"];
5524
- case VertexFormatType.Int8:
5525
- return WebGLRenderingContext["BYTE"];
5526
- case VertexFormatType.UInt16:
5527
- return WebGLRenderingContext["UNSIGNED_SHORT"];
5528
- case VertexFormatType.UInt8:
5529
- return WebGLRenderingContext["UNSIGNED_BYTE"];
5530
- default:
5531
- return WebGLRenderingContext["FLOAT"];
5532
- }
5533
- }
5534
- function glType2VertexFormatType(webglType) {
5535
- switch(webglType){
5536
- case WebGLRenderingContext["FLOAT"]:
5537
- return VertexFormatType.Float32;
5538
- case WebGLRenderingContext["SHORT"]:
5539
- return VertexFormatType.Int16;
5540
- case WebGLRenderingContext["BYTE"]:
5541
- return VertexFormatType.Int8;
5542
- case WebGLRenderingContext["UNSIGNED_SHORT"]:
5543
- return VertexFormatType.UInt16;
5544
- case WebGLRenderingContext["UNSIGNED_BYTE"]:
5545
- return VertexFormatType.UInt8;
5546
- default:
5547
- return VertexFormatType.Float32;
5548
- }
5549
- }
5550
-
5551
- exports.ShaderType = void 0;
5552
- (function(ShaderType) {
5553
- ShaderType[ShaderType["vertex"] = 0] = "vertex";
5554
- ShaderType[ShaderType["fragment"] = 1] = "fragment";
5555
- })(exports.ShaderType || (exports.ShaderType = {}));
5556
-
5557
- function valIfUndefined(val, def) {
5558
- if (val === undefined || val === null) {
5559
- return def;
5560
- }
5561
- return val;
5562
- }
5563
- function getPreMultiAlpha(blending) {
5564
- switch(blending){
5565
- case BlendingMode.ALPHA:
5566
- return 1;
5567
- case BlendingMode.ADD:
5568
- return 1;
5569
- case BlendingMode.SUBTRACTION:
5570
- return 1;
5571
- case BlendingMode.STRONG_LIGHT:
5572
- return 1;
5573
- case BlendingMode.WEAK_LIGHT:
5574
- return 1;
5575
- case BlendingMode.SUPERPOSITION:
5576
- return 2;
5577
- case BlendingMode.BRIGHTNESS:
5578
- return 3;
5579
- case BlendingMode.MULTIPLY:
5580
- return 0;
5581
- default:
5582
- // 处理undefined
5583
- return 1;
5584
- }
5585
- }
5586
- function setBlendMode(material, blendMode) {
5587
- switch(blendMode){
5588
- case undefined:
5589
- material.blendFunction = [
5590
- glContext.ONE,
5591
- glContext.ONE_MINUS_SRC_ALPHA,
5592
- glContext.ONE,
5593
- glContext.ONE_MINUS_SRC_ALPHA
5594
- ];
5595
- break;
5596
- case BlendingMode.ALPHA:
5597
- material.blendFunction = [
5598
- glContext.ONE,
5599
- glContext.ONE_MINUS_SRC_ALPHA,
5600
- glContext.ONE,
5601
- glContext.ONE_MINUS_SRC_ALPHA
5602
- ];
5603
- break;
5604
- case BlendingMode.ADD:
5605
- material.blendFunction = [
5606
- glContext.ONE,
5607
- glContext.ONE,
5608
- glContext.ONE,
5609
- glContext.ONE
5610
- ];
5611
- break;
5612
- case BlendingMode.SUBTRACTION:
5613
- material.blendFunction = [
5614
- glContext.ONE,
5615
- glContext.ONE,
5616
- glContext.ZERO,
5617
- glContext.ONE
5618
- ];
5619
- material.blendEquation = [
5620
- glContext.FUNC_REVERSE_SUBTRACT,
5621
- glContext.FUNC_REVERSE_SUBTRACT
5622
- ];
5623
- break;
5624
- case BlendingMode.SUPERPOSITION:
5625
- material.blendFunction = [
5626
- glContext.ONE,
5627
- glContext.ONE,
5628
- glContext.ONE,
5629
- glContext.ONE
5630
- ];
5631
- break;
5632
- case BlendingMode.MULTIPLY:
5633
- material.blendFunction = [
5634
- glContext.DST_COLOR,
5635
- glContext.ONE_MINUS_SRC_ALPHA,
5636
- glContext.DST_COLOR,
5637
- glContext.ONE_MINUS_SRC_ALPHA
5638
- ];
5639
- break;
5640
- case BlendingMode.BRIGHTNESS:
5641
- material.blendFunction = [
5642
- glContext.ONE,
5643
- glContext.ONE_MINUS_SRC_ALPHA,
5644
- glContext.ONE,
5645
- glContext.ONE_MINUS_SRC_ALPHA
5646
- ];
5647
- break;
5648
- case BlendingMode.STRONG_LIGHT:
5649
- material.blendFunction = [
5650
- glContext.DST_COLOR,
5651
- glContext.DST_ALPHA,
5652
- glContext.ZERO,
5653
- glContext.ONE
5654
- ];
5655
- break;
5656
- case BlendingMode.WEAK_LIGHT:
5657
- material.blendFunction = [
5658
- glContext.DST_COLOR,
5659
- glContext.ZERO,
5660
- glContext.ZERO,
5661
- glContext.ONE
5662
- ];
5663
- break;
5664
- default:
5665
- console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
5666
- }
5667
- }
5668
- function setSideMode(material, side) {
5669
- if (side === SideMode.DOUBLE) {
5670
- material.culling = false;
5671
- } else {
5672
- material.culling = true;
5673
- material.frontFace = glContext.CW;
5674
- material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
5675
- }
5676
- }
5677
- function setMaskMode(material, maskMode) {
5678
- switch(maskMode){
5679
- case undefined:
5680
- material.stencilTest = false;
5681
- break;
5682
- case MaskMode.MASK:
5683
- material.stencilTest = true;
5684
- material.stencilFunc = [
5685
- glContext.ALWAYS,
5686
- glContext.ALWAYS
5687
- ];
5688
- material.stencilOpZPass = [
5689
- glContext.REPLACE,
5690
- glContext.REPLACE
5691
- ];
5692
- break;
5693
- case MaskMode.OBSCURED:
5694
- material.stencilTest = true;
5695
- material.stencilFunc = [
5696
- glContext.EQUAL,
5697
- glContext.EQUAL
5698
- ];
5699
- break;
5700
- case MaskMode.REVERSE_OBSCURED:
5701
- material.stencilTest = true;
5702
- material.stencilFunc = [
5703
- glContext.NOTEQUAL,
5704
- glContext.NOTEQUAL
5705
- ];
5706
- break;
5707
- case MaskMode.NONE:
5708
- material.stencilTest = false;
5709
- break;
5710
- default:
5711
- console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
5712
- }
5713
- }
5714
-
5715
5339
  function _extends() {
5716
5340
  _extends = Object.assign || function assign(target) {
5717
5341
  for(var i = 1; i < arguments.length; i++){
@@ -6122,7 +5746,12 @@ function _loadVideo() {
6122
5746
  });
6123
5747
  return _loadVideo.apply(this, arguments);
6124
5748
  }
6125
- function loadMedia(url, loadFn) {
5749
+ /**
5750
+ * 异步加载一个媒体文件
5751
+ * @param url
5752
+ * @param loadFn
5753
+ * @returns
5754
+ */ function loadMedia(url, loadFn) {
6126
5755
  return _loadMedia.apply(this, arguments);
6127
5756
  }
6128
5757
  function _loadMedia() {
@@ -6284,6 +5913,144 @@ function _loadMipmapImage() {
6284
5913
  return _loadMipmapImage.apply(this, arguments);
6285
5914
  }
6286
5915
 
5916
+ /**
5917
+ * Helper class to create a WebGL Context
5918
+ *
5919
+ * @param canvas
5920
+ * @param glType
5921
+ * @param options
5922
+ * @returns
5923
+ */ function createGLContext(canvas, glType, options) {
5924
+ if (glType === void 0) glType = "webgl";
5925
+ var context;
5926
+ if (glType === "webgl2") {
5927
+ context = canvas.getContext("webgl2", options);
5928
+ if (!context) {
5929
+ console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
5930
+ }
5931
+ }
5932
+ if (!context || glType === "webgl") {
5933
+ context = canvas.getContext("webgl", options);
5934
+ }
5935
+ if (!context) {
5936
+ throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
5937
+ }
5938
+ return context;
5939
+ }
5940
+
5941
+ function gpuTimer(gl) {
5942
+ var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
5943
+ if (ext) {
5944
+ var query = gl.createQuery();
5945
+ var getTime = /*#__PURE__*/ _async_to_generator(function() {
5946
+ return __generator(this, function(_state) {
5947
+ return [
5948
+ 2,
5949
+ new Promise(function(resolve, reject) {
5950
+ if (query) {
5951
+ var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
5952
+ var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
5953
+ if (available && !disjoint) {
5954
+ // See how much time the rendering of the object took in nanoseconds.
5955
+ var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
5956
+ // taken to use all significant bits of the result, not just the
5957
+ // least significant 32 bits.
5958
+ resolve(timeElapsed / 1000 / 1000);
5959
+ }
5960
+ if (available || disjoint) {
5961
+ // Clean up the query object.
5962
+ gl.deleteQuery(query); // Don't re-enter this polling loop.
5963
+ query = null;
5964
+ }
5965
+ available !== null && query && window.setTimeout(function() {
5966
+ getTime().then(resolve).catch;
5967
+ }, 1);
5968
+ }
5969
+ })
5970
+ ];
5971
+ });
5972
+ });
5973
+ if (!query) {
5974
+ return;
5975
+ }
5976
+ return {
5977
+ begin: function() {
5978
+ query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
5979
+ },
5980
+ end: function() {
5981
+ gl.endQuery(ext.TIME_ELAPSED_EXT);
5982
+ },
5983
+ getTime: getTime
5984
+ };
5985
+ }
5986
+ }
5987
+
5988
+ var initErrors = [];
5989
+ // @ts-expect-error
5990
+ var glContext = {};
5991
+ if (!initErrors.length) {
5992
+ initGLContext();
5993
+ }
5994
+ function initGLContext() {
5995
+ // 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
5996
+ if (typeof WebGL2RenderingContext === "function") {
5997
+ copy(WebGL2RenderingContext);
5998
+ } else if (typeof WebGLRenderingContext !== "undefined") {
5999
+ copy(WebGLRenderingContext);
6000
+ copy(WebGLRenderingContext.prototype);
6001
+ } else {
6002
+ initErrors.push(// iOS 16 lockdown mode
6003
+ "iOS16 lockdown mode, WebGL Constants not in global");
6004
+ }
6005
+ if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
6006
+ // @ts-expect-error set default value
6007
+ glContext["HALF_FLOAT"] = 5131;
6008
+ }
6009
+ }
6010
+ function isWebGL2(gl) {
6011
+ return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
6012
+ }
6013
+ function copy(target) {
6014
+ for(var name in target){
6015
+ if (/^[A-Z_]/.test(name)) {
6016
+ // @ts-expect-error safe to assign
6017
+ glContext[name] = target[name];
6018
+ }
6019
+ }
6020
+ }
6021
+ function vertexFormatType2GLType(formatType) {
6022
+ switch(formatType){
6023
+ case VertexFormatType.Float32:
6024
+ return WebGLRenderingContext["FLOAT"];
6025
+ case VertexFormatType.Int16:
6026
+ return WebGLRenderingContext["SHORT"];
6027
+ case VertexFormatType.Int8:
6028
+ return WebGLRenderingContext["BYTE"];
6029
+ case VertexFormatType.UInt16:
6030
+ return WebGLRenderingContext["UNSIGNED_SHORT"];
6031
+ case VertexFormatType.UInt8:
6032
+ return WebGLRenderingContext["UNSIGNED_BYTE"];
6033
+ default:
6034
+ return WebGLRenderingContext["FLOAT"];
6035
+ }
6036
+ }
6037
+ function glType2VertexFormatType(webglType) {
6038
+ switch(webglType){
6039
+ case WebGLRenderingContext["FLOAT"]:
6040
+ return VertexFormatType.Float32;
6041
+ case WebGLRenderingContext["SHORT"]:
6042
+ return VertexFormatType.Int16;
6043
+ case WebGLRenderingContext["BYTE"]:
6044
+ return VertexFormatType.Int8;
6045
+ case WebGLRenderingContext["UNSIGNED_SHORT"]:
6046
+ return VertexFormatType.UInt16;
6047
+ case WebGLRenderingContext["UNSIGNED_BYTE"]:
6048
+ return VertexFormatType.UInt8;
6049
+ default:
6050
+ return VertexFormatType.Float32;
6051
+ }
6052
+ }
6053
+
6287
6054
  var seed$a = 1;
6288
6055
  /**
6289
6056
  * Texture 抽象类
@@ -6918,6 +6685,280 @@ function setDefaultTextureFactory(factory) {
6918
6685
  g = factory;
6919
6686
  }
6920
6687
 
6688
+ function _array_like_to_array(arr, len) {
6689
+ if (len == null || len > arr.length) len = arr.length;
6690
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
6691
+ return arr2;
6692
+ }
6693
+
6694
+ function _unsupported_iterable_to_array(o, minLen) {
6695
+ if (!o) return;
6696
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
6697
+ var n = Object.prototype.toString.call(o).slice(8, -1);
6698
+ if (n === "Object" && o.constructor) n = o.constructor.name;
6699
+ if (n === "Map" || n === "Set") return Array.from(n);
6700
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
6701
+ }
6702
+
6703
+ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
6704
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
6705
+ if (it) return (it = it.call(o)).next.bind(it);
6706
+ // Fallback for engines without symbol support
6707
+ if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
6708
+ if (it) o = it;
6709
+ var i = 0;
6710
+ return function() {
6711
+ if (i >= o.length) return {
6712
+ done: true
6713
+ };
6714
+ return {
6715
+ done: false,
6716
+ value: o[i++]
6717
+ };
6718
+ };
6719
+ }
6720
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6721
+ }
6722
+
6723
+ exports.ShaderCompileResultStatus = void 0;
6724
+ (function(ShaderCompileResultStatus) {
6725
+ ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
6726
+ ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
6727
+ ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
6728
+ ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
6729
+ })(exports.ShaderCompileResultStatus || (exports.ShaderCompileResultStatus = {}));
6730
+ exports.GLSLVersion = void 0;
6731
+ (function(GLSLVersion) {
6732
+ GLSLVersion["GLSL1"] = "100";
6733
+ GLSLVersion["GLSL3"] = "300 es";
6734
+ })(exports.GLSLVersion || (exports.GLSLVersion = {}));
6735
+ var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
6736
+ _inherits(ShaderVariant, EffectsObject);
6737
+ function ShaderVariant(engine, source) {
6738
+ var _this;
6739
+ _this = EffectsObject.call(this, engine) || this;
6740
+ _this.source = source;
6741
+ return _this;
6742
+ }
6743
+ return ShaderVariant;
6744
+ }(EffectsObject);
6745
+ exports.Shader = /*#__PURE__*/ function(EffectsObject) {
6746
+ _inherits(Shader, EffectsObject);
6747
+ function Shader() {
6748
+ return EffectsObject.apply(this, arguments);
6749
+ }
6750
+ var _proto = Shader.prototype;
6751
+ _proto.createVariant = function createVariant(macros) {
6752
+ var shaderMacros = [];
6753
+ if (macros) {
6754
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
6755
+ var key = _step.value;
6756
+ shaderMacros.push([
6757
+ key,
6758
+ macros[key]
6759
+ ]);
6760
+ }
6761
+ }
6762
+ var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
6763
+ shaderVariant.shader = this;
6764
+ return shaderVariant;
6765
+ };
6766
+ _proto.fromData = function fromData(data) {
6767
+ EffectsObject.prototype.fromData.call(this, data);
6768
+ this.shaderData = data;
6769
+ };
6770
+ return Shader;
6771
+ }(EffectsObject);
6772
+ exports.Shader = __decorate([
6773
+ effectsClass(DataType.Shader)
6774
+ ], exports.Shader);
6775
+
6776
+ var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
6777
+ var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
6778
+ 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}";
6779
+ 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";
6780
+ function createCopyShader(level, writeDepth) {
6781
+ var webgl2 = level === 2;
6782
+ return {
6783
+ name: EFFECTS_COPY_MESH_NAME,
6784
+ vertex: COPY_VERTEX_SHADER,
6785
+ fragment: COPY_FRAGMENT_SHADER,
6786
+ glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
6787
+ macros: [
6788
+ [
6789
+ "DEPTH_TEXTURE",
6790
+ !!writeDepth
6791
+ ]
6792
+ ],
6793
+ // @ts-expect-error
6794
+ cacheId: COPY_MESH_SHADER_ID + +writeDepth
6795
+ };
6796
+ }
6797
+
6798
+ exports.ShaderType = void 0;
6799
+ (function(ShaderType) {
6800
+ ShaderType[ShaderType["vertex"] = 0] = "vertex";
6801
+ ShaderType[ShaderType["fragment"] = 1] = "fragment";
6802
+ })(exports.ShaderType || (exports.ShaderType = {}));
6803
+
6804
+ function valIfUndefined(val, def) {
6805
+ if (val === undefined || val === null) {
6806
+ return def;
6807
+ }
6808
+ return val;
6809
+ }
6810
+ function getPreMultiAlpha(blending) {
6811
+ switch(blending){
6812
+ case BlendingMode.ALPHA:
6813
+ return 1;
6814
+ case BlendingMode.ADD:
6815
+ return 1;
6816
+ case BlendingMode.SUBTRACTION:
6817
+ return 1;
6818
+ case BlendingMode.STRONG_LIGHT:
6819
+ return 1;
6820
+ case BlendingMode.WEAK_LIGHT:
6821
+ return 1;
6822
+ case BlendingMode.SUPERPOSITION:
6823
+ return 2;
6824
+ case BlendingMode.BRIGHTNESS:
6825
+ return 3;
6826
+ case BlendingMode.MULTIPLY:
6827
+ return 0;
6828
+ default:
6829
+ // 处理undefined
6830
+ return 1;
6831
+ }
6832
+ }
6833
+ function setBlendMode(material, blendMode) {
6834
+ switch(blendMode){
6835
+ case undefined:
6836
+ material.blendFunction = [
6837
+ glContext.ONE,
6838
+ glContext.ONE_MINUS_SRC_ALPHA,
6839
+ glContext.ONE,
6840
+ glContext.ONE_MINUS_SRC_ALPHA
6841
+ ];
6842
+ break;
6843
+ case BlendingMode.ALPHA:
6844
+ material.blendFunction = [
6845
+ glContext.ONE,
6846
+ glContext.ONE_MINUS_SRC_ALPHA,
6847
+ glContext.ONE,
6848
+ glContext.ONE_MINUS_SRC_ALPHA
6849
+ ];
6850
+ break;
6851
+ case BlendingMode.ADD:
6852
+ material.blendFunction = [
6853
+ glContext.ONE,
6854
+ glContext.ONE,
6855
+ glContext.ONE,
6856
+ glContext.ONE
6857
+ ];
6858
+ break;
6859
+ case BlendingMode.SUBTRACTION:
6860
+ material.blendFunction = [
6861
+ glContext.ONE,
6862
+ glContext.ONE,
6863
+ glContext.ZERO,
6864
+ glContext.ONE
6865
+ ];
6866
+ material.blendEquation = [
6867
+ glContext.FUNC_REVERSE_SUBTRACT,
6868
+ glContext.FUNC_REVERSE_SUBTRACT
6869
+ ];
6870
+ break;
6871
+ case BlendingMode.SUPERPOSITION:
6872
+ material.blendFunction = [
6873
+ glContext.ONE,
6874
+ glContext.ONE,
6875
+ glContext.ONE,
6876
+ glContext.ONE
6877
+ ];
6878
+ break;
6879
+ case BlendingMode.MULTIPLY:
6880
+ material.blendFunction = [
6881
+ glContext.DST_COLOR,
6882
+ glContext.ONE_MINUS_SRC_ALPHA,
6883
+ glContext.DST_COLOR,
6884
+ glContext.ONE_MINUS_SRC_ALPHA
6885
+ ];
6886
+ break;
6887
+ case BlendingMode.BRIGHTNESS:
6888
+ material.blendFunction = [
6889
+ glContext.ONE,
6890
+ glContext.ONE_MINUS_SRC_ALPHA,
6891
+ glContext.ONE,
6892
+ glContext.ONE_MINUS_SRC_ALPHA
6893
+ ];
6894
+ break;
6895
+ case BlendingMode.STRONG_LIGHT:
6896
+ material.blendFunction = [
6897
+ glContext.DST_COLOR,
6898
+ glContext.DST_ALPHA,
6899
+ glContext.ZERO,
6900
+ glContext.ONE
6901
+ ];
6902
+ break;
6903
+ case BlendingMode.WEAK_LIGHT:
6904
+ material.blendFunction = [
6905
+ glContext.DST_COLOR,
6906
+ glContext.ZERO,
6907
+ glContext.ZERO,
6908
+ glContext.ONE
6909
+ ];
6910
+ break;
6911
+ default:
6912
+ console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
6913
+ }
6914
+ }
6915
+ function setSideMode(material, side) {
6916
+ if (side === SideMode.DOUBLE) {
6917
+ material.culling = false;
6918
+ } else {
6919
+ material.culling = true;
6920
+ material.frontFace = glContext.CW;
6921
+ material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
6922
+ }
6923
+ }
6924
+ function setMaskMode(material, maskMode) {
6925
+ switch(maskMode){
6926
+ case undefined:
6927
+ material.stencilTest = false;
6928
+ break;
6929
+ case MaskMode.MASK:
6930
+ material.stencilTest = true;
6931
+ material.stencilFunc = [
6932
+ glContext.ALWAYS,
6933
+ glContext.ALWAYS
6934
+ ];
6935
+ material.stencilOpZPass = [
6936
+ glContext.REPLACE,
6937
+ glContext.REPLACE
6938
+ ];
6939
+ break;
6940
+ case MaskMode.OBSCURED:
6941
+ material.stencilTest = true;
6942
+ material.stencilFunc = [
6943
+ glContext.EQUAL,
6944
+ glContext.EQUAL
6945
+ ];
6946
+ break;
6947
+ case MaskMode.REVERSE_OBSCURED:
6948
+ material.stencilTest = true;
6949
+ material.stencilFunc = [
6950
+ glContext.NOTEQUAL,
6951
+ glContext.NOTEQUAL
6952
+ ];
6953
+ break;
6954
+ case MaskMode.NONE:
6955
+ material.stencilTest = false;
6956
+ break;
6957
+ default:
6958
+ console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
6959
+ }
6960
+ }
6961
+
6921
6962
  /**
6922
6963
  * 引擎接入暂时不需要实现
6923
6964
  */ var MaterialDataBlock = /*#__PURE__*/ function() {
@@ -10167,7 +10208,7 @@ var integrate = "float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4
10167
10208
 
10168
10209
  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}";
10169
10210
 
10170
- 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;}";
10211
+ 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;}";
10171
10212
 
10172
10213
  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";
10173
10214
 
@@ -13128,6 +13169,27 @@ var Vector4Curve = /*#__PURE__*/ function(ValueGetter) {
13128
13169
  };
13129
13170
  return Vector4Curve;
13130
13171
  }(ValueGetter);
13172
+ var Vector2Curve = /*#__PURE__*/ function(ValueGetter) {
13173
+ _inherits(Vector2Curve, ValueGetter);
13174
+ function Vector2Curve() {
13175
+ var _this;
13176
+ _this = ValueGetter.apply(this, arguments) || this;
13177
+ _this.value = new Vector2();
13178
+ return _this;
13179
+ }
13180
+ var _proto = Vector2Curve.prototype;
13181
+ _proto.onCreate = function onCreate(arg) {
13182
+ this.xCurve = createValueGetter(arg[0]);
13183
+ this.yCurve = createValueGetter(arg[1]);
13184
+ };
13185
+ _proto.getValue = function getValue(t) {
13186
+ var x = this.xCurve.getValue(t);
13187
+ var y = this.yCurve.getValue(t);
13188
+ this.value.set(x, y);
13189
+ return this.value;
13190
+ };
13191
+ return Vector2Curve;
13192
+ }(ValueGetter);
13131
13193
 
13132
13194
  var SPRITE_VERTEX_STRIDE = 6;
13133
13195
  var SEMANTIC_PRE_COLOR_ATTACHMENT_0 = "PRE_COLOR_0";
@@ -13191,6 +13253,8 @@ var map$1 = (_obj$4 = {}, _obj$4[ValueType.RANDOM] = function(props) {
13191
13253
  return new ColorCurve(props);
13192
13254
  }, _obj$4[ValueType.VECTOR4_CURVE] = function(props) {
13193
13255
  return new Vector4Curve(props);
13256
+ }, _obj$4[ValueType.VECTOR2_CURVE] = function(props) {
13257
+ return new Vector2Curve(props);
13194
13258
  }, _obj$4);
13195
13259
  function createValueGetter(args) {
13196
13260
  if (!args || !isNaN(+args)) {
@@ -13315,13 +13379,39 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13315
13379
  this.color = color;
13316
13380
  this.material.setVector4("_Color", new Vector4().setFromArray(color));
13317
13381
  };
13318
- /**
13319
- * 设置当前 Mesh 的纹理
13320
- * @since 2.0.0
13321
- * @param texture - 纹理对象
13322
- */ _proto.setTexture = function setTexture(texture) {
13323
- this.renderer.texture = texture;
13324
- this.material.setTexture("_MainTex", texture);
13382
+ _proto.setTexture = function setTexture(input) {
13383
+ var _this = this;
13384
+ return _async_to_generator(function() {
13385
+ var texture;
13386
+ return __generator(this, function(_state) {
13387
+ switch(_state.label){
13388
+ case 0:
13389
+ if (!(typeof input === "string")) return [
13390
+ 3,
13391
+ 2
13392
+ ];
13393
+ return [
13394
+ 4,
13395
+ Texture.fromImage(input, _this.item.engine)
13396
+ ];
13397
+ case 1:
13398
+ texture = _state.sent();
13399
+ return [
13400
+ 3,
13401
+ 3
13402
+ ];
13403
+ case 2:
13404
+ texture = input;
13405
+ _state.label = 3;
13406
+ case 3:
13407
+ _this.renderer.texture = texture;
13408
+ _this.material.setTexture("_MainTex", texture);
13409
+ return [
13410
+ 2
13411
+ ];
13412
+ }
13413
+ });
13414
+ })();
13325
13415
  };
13326
13416
  /**
13327
13417
  * @internal
@@ -13500,11 +13590,14 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13500
13590
  maxVertex: 4
13501
13591
  });
13502
13592
  };
13503
- _proto.createMaterial = function createMaterial(renderInfo, count) {
13504
- var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
13505
- var materialProps = {
13593
+ _proto.getMaterialProps = function getMaterialProps(renderInfo, count) {
13594
+ return {
13506
13595
  shader: spriteMeshShaderFromRenderInfo(renderInfo, count, 1)
13507
13596
  };
13597
+ };
13598
+ _proto.createMaterial = function createMaterial(renderInfo, count) {
13599
+ var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
13600
+ var materialProps = this.getMaterialProps(renderInfo, count);
13508
13601
  this.preMultiAlpha = getPreMultiAlpha(blending);
13509
13602
  var material = Material.create(this.engine, materialProps);
13510
13603
  var states = {
@@ -13583,6 +13676,8 @@ function getImageItemRenderInfo(item) {
13583
13676
  };
13584
13677
  }
13585
13678
 
13679
+ // Based on:
13680
+ // https://github.com/pixijs/pixijs/blob/dev/src/maths/shapes/ShapePrimitive.ts
13586
13681
  var ShapePrimitive = function ShapePrimitive() {
13587
13682
  };
13588
13683
 
@@ -14688,6 +14783,7 @@ function triangulate(contours) {
14688
14783
  return triangleVerts;
14689
14784
  }
14690
14785
 
14786
+ // Based on:
14691
14787
  /**
14692
14788
  * A class to define a shape via user defined coordinates.
14693
14789
  */ var Polygon = /*#__PURE__*/ function(ShapePrimitive) {
@@ -14787,12 +14883,13 @@ function triangulate(contours) {
14787
14883
  var triangles = triangulate([
14788
14884
  points
14789
14885
  ]);
14886
+ var indexStart = vertices.length / 2;
14790
14887
  for(var i = 0; i < triangles.length; i++){
14791
- vertices[verticesOffset + i] = triangles[i];
14888
+ vertices[verticesOffset * 2 + i] = triangles[i];
14792
14889
  }
14793
14890
  var vertexCount = triangles.length / 2;
14794
14891
  for(var i1 = 0; i1 < vertexCount; i1++){
14795
- indices[indicesOffset + i1] = i1;
14892
+ indices[indicesOffset + i1] = indexStart + i1;
14796
14893
  }
14797
14894
  };
14798
14895
  _create_class(Polygon, [
@@ -14914,6 +15011,7 @@ function recursive(x1, y1, x2, y2, x3, y3, x4, y4, points, distanceTolerance, le
14914
15011
  recursive(x1234, y1234, x234, y234, x34, y34, x4, y4, points, distanceTolerance, level + 1);
14915
15012
  }
14916
15013
 
15014
+ // Based on:
14917
15015
  /**
14918
15016
  * The Ellipse object is used to help draw graphics and can also be used to specify a hit area for containers.
14919
15017
  */ var Ellipse = /*#__PURE__*/ function(ShapePrimitive) {
@@ -15120,6 +15218,7 @@ function recursive(x1, y1, x2, y2, x3, y3, x4, y4, points, distanceTolerance, le
15120
15218
  return Ellipse;
15121
15219
  }(ShapePrimitive);
15122
15220
 
15221
+ // Based on:
15123
15222
  var StarType;
15124
15223
  (function(StarType) {
15125
15224
  StarType[StarType["Star"] = 0] = "Star";
@@ -15188,12 +15287,13 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15188
15287
  var triangles = triangulate([
15189
15288
  points
15190
15289
  ]);
15290
+ var indexStart = vertices.length / 2;
15191
15291
  for(var i = 0; i < triangles.length; i++){
15192
- vertices[verticesOffset + i] = triangles[i];
15292
+ vertices[verticesOffset * 2 + i] = triangles[i];
15193
15293
  }
15194
15294
  var vertexCount = triangles.length / 2;
15195
15295
  for(var i1 = 0; i1 < vertexCount; i1++){
15196
- indices[indicesOffset + i1] = i1;
15296
+ indices[indicesOffset + i1] = indexStart + i1;
15197
15297
  }
15198
15298
  };
15199
15299
  _proto.buildStarPath = function buildStarPath() {
@@ -15264,6 +15364,7 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15264
15364
  return PolyStar;
15265
15365
  }(ShapePrimitive);
15266
15366
 
15367
+ // Based on:
15267
15368
  // const tempPoints = [new Point(), new Point(), new Point(), new Point()];
15268
15369
  /**
15269
15370
  * The `Rectangle` object is an area defined by its position, as indicated by its upper-left corner
@@ -15587,6 +15688,7 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15587
15688
  return Rectangle;
15588
15689
  }(ShapePrimitive);
15589
15690
 
15691
+ // Based on:
15590
15692
  var ShapePath = /*#__PURE__*/ function() {
15591
15693
  function ShapePath(graphicsPath) {
15592
15694
  this.graphicsPath = graphicsPath;
@@ -15745,6 +15847,7 @@ var ShapePath = /*#__PURE__*/ function() {
15745
15847
  return ShapePath;
15746
15848
  }();
15747
15849
 
15850
+ // Based on:
15748
15851
  var GraphicsPath = /*#__PURE__*/ function() {
15749
15852
  function GraphicsPath() {
15750
15853
  this.instructions = [];
@@ -15882,14 +15985,433 @@ var GraphicsPath = /*#__PURE__*/ function() {
15882
15985
  return GraphicsPath;
15883
15986
  }();
15884
15987
 
15988
+ // Based on:
15989
+ /**
15990
+ * The Point object represents a location in a two-dimensional coordinate system, where `x` represents
15991
+ * the position on the horizontal axis and `y` represents the position on the vertical axis.
15992
+ */ var Point = /*#__PURE__*/ function() {
15993
+ function Point(x, y) {
15994
+ if (x === void 0) x = 0;
15995
+ if (y === void 0) y = 0;
15996
+ /**
15997
+ * Position of the point on the x axis
15998
+ */ this.x = 0;
15999
+ /**
16000
+ * Position of the point on the y axis
16001
+ */ this.y = 0;
16002
+ this.x = x;
16003
+ this.y = y;
16004
+ }
16005
+ var _proto = Point.prototype;
16006
+ /**
16007
+ * Creates a clone of this point
16008
+ * @returns A clone of this point
16009
+ */ _proto.clone = function clone() {
16010
+ return new Point(this.x, this.y);
16011
+ };
16012
+ /**
16013
+ * Copies `x` and `y` from the given point into this point
16014
+ * @param p - The point to copy from
16015
+ * @returns The point instance itself
16016
+ */ _proto.copyFrom = function copyFrom(p) {
16017
+ this.set(p.x, p.y);
16018
+ return this;
16019
+ };
16020
+ /**
16021
+ * Copies this point's x and y into the given point (`p`).
16022
+ * @param p - The point to copy to. Can be any of type that is or extends `PointData`
16023
+ * @returns The point (`p`) with values updated
16024
+ */ _proto.copyTo = function copyTo(p) {
16025
+ p.set(this.x, this.y);
16026
+ return p;
16027
+ };
16028
+ /**
16029
+ * Accepts another point (`p`) and returns `true` if the given point is equal to this point
16030
+ * @param p - The point to check
16031
+ * @returns Returns `true` if both `x` and `y` are equal
16032
+ */ _proto.equals = function equals(p) {
16033
+ return p.x === this.x && p.y === this.y;
16034
+ };
16035
+ /**
16036
+ * Sets the point to a new `x` and `y` position.
16037
+ * If `y` is omitted, both `x` and `y` will be set to `x`.
16038
+ * @param {number} [x=0] - position of the point on the `x` axis
16039
+ * @param {number} [y=x] - position of the point on the `y` axis
16040
+ * @returns The point instance itself
16041
+ */ _proto.set = function set(x, y) {
16042
+ if (x === void 0) x = 0;
16043
+ if (y === void 0) y = x;
16044
+ this.x = x;
16045
+ this.y = y;
16046
+ return this;
16047
+ };
16048
+ _create_class(Point, null, [
16049
+ {
16050
+ key: "shared",
16051
+ get: /**
16052
+ * A static Point object with `x` and `y` values of `0`. Can be used to avoid creating new objects multiple times.
16053
+ * @readonly
16054
+ */ function get() {
16055
+ tempPoint.x = 0;
16056
+ tempPoint.y = 0;
16057
+ return tempPoint;
16058
+ }
16059
+ }
16060
+ ]);
16061
+ return Point;
16062
+ }();
16063
+ var tempPoint = new Point();
16064
+
16065
+ // Based on:
16066
+ var closePointEps = 1e-4;
16067
+ var curveEps = 0.0001;
16068
+ /**
16069
+ * Buffers vertices to draw a square cap.
16070
+ *
16071
+ * @internal
16072
+ * @private
16073
+ * @param x - X-coord of end point
16074
+ * @param y - Y-coord of end point
16075
+ * @param nx - X-coord of line normal pointing inside
16076
+ * @param ny - Y-coord of line normal pointing inside
16077
+ * @param innerWeight - Weight of inner points
16078
+ * @param outerWeight - Weight of outer points
16079
+ * @param clockwise - Whether the cap is drawn clockwise
16080
+ * @param verts - vertex buffer
16081
+ * @returns - no. of vertices pushed
16082
+ */ function square(x, y, nx, ny, innerWeight, outerWeight, clockwise, /* rotation for square (true at left end, false at right end) */ verts) {
16083
+ var ix = x - nx * innerWeight;
16084
+ var iy = y - ny * innerWeight;
16085
+ var ox = x + nx * outerWeight;
16086
+ var oy = y + ny * outerWeight;
16087
+ /* Rotate nx,ny for extension vector */ var exx;
16088
+ var eyy;
16089
+ if (clockwise) {
16090
+ exx = ny;
16091
+ eyy = -nx;
16092
+ } else {
16093
+ exx = -ny;
16094
+ eyy = nx;
16095
+ }
16096
+ /* [i|0]x,y extended at cap */ var eix = ix + exx;
16097
+ var eiy = iy + eyy;
16098
+ var eox = ox + exx;
16099
+ var eoy = oy + eyy;
16100
+ /* Square itself must be inserted clockwise*/ verts.push(eix, eiy);
16101
+ verts.push(eox, eoy);
16102
+ return 2;
16103
+ }
16104
+ /**
16105
+ * Buffers vertices to draw an arc at the line joint or cap.
16106
+ *
16107
+ * @internal
16108
+ * @private
16109
+ * @param cx - X-coord of center
16110
+ * @param cy - Y-coord of center
16111
+ * @param sx - X-coord of arc start
16112
+ * @param sy - Y-coord of arc start
16113
+ * @param ex - X-coord of arc end
16114
+ * @param ey - Y-coord of arc end
16115
+ * @param verts - buffer of vertices
16116
+ * @param clockwise - orientation of vertices
16117
+ * @returns - no. of vertices pushed
16118
+ */ function round(cx, cy, sx, sy, ex, ey, verts, clockwise) {
16119
+ var cx2p0x = sx - cx;
16120
+ var cy2p0y = sy - cy;
16121
+ var angle0 = Math.atan2(cx2p0x, cy2p0y);
16122
+ var angle1 = Math.atan2(ex - cx, ey - cy);
16123
+ if (clockwise && angle0 < angle1) {
16124
+ angle0 += Math.PI * 2;
16125
+ } else if (!clockwise && angle0 > angle1) {
16126
+ angle1 += Math.PI * 2;
16127
+ }
16128
+ var startAngle = angle0;
16129
+ var angleDiff = angle1 - angle0;
16130
+ var absAngleDiff = Math.abs(angleDiff);
16131
+ var radius = Math.sqrt(cx2p0x * cx2p0x + cy2p0y * cy2p0y);
16132
+ var segCount = (15 * absAngleDiff * Math.sqrt(radius) / Math.PI >> 0) + 1;
16133
+ var angleInc = angleDiff / segCount;
16134
+ startAngle += angleInc;
16135
+ if (clockwise) {
16136
+ verts.push(cx, cy);
16137
+ verts.push(sx, sy);
16138
+ for(var i = 1, angle = startAngle; i < segCount; i++, angle += angleInc){
16139
+ verts.push(cx, cy);
16140
+ verts.push(cx + Math.sin(angle) * radius, cy + Math.cos(angle) * radius);
16141
+ }
16142
+ verts.push(cx, cy);
16143
+ verts.push(ex, ey);
16144
+ } else {
16145
+ verts.push(sx, sy);
16146
+ verts.push(cx, cy);
16147
+ for(var i1 = 1, angle2 = startAngle; i1 < segCount; i1++, angle2 += angleInc){
16148
+ verts.push(cx + Math.sin(angle2) * radius, cy + Math.cos(angle2) * radius);
16149
+ verts.push(cx, cy);
16150
+ }
16151
+ verts.push(ex, ey);
16152
+ verts.push(cx, cy);
16153
+ }
16154
+ return segCount * 2;
16155
+ }
16156
+ function getOrientationOfPoints(points) {
16157
+ var m = points.length;
16158
+ if (m < 6) {
16159
+ return 1;
16160
+ }
16161
+ var area = 0;
16162
+ for(var i = 0, x1 = points[m - 2], y1 = points[m - 1]; i < m; i += 2){
16163
+ var x2 = points[i];
16164
+ var y2 = points[i + 1];
16165
+ area += (x2 - x1) * (y2 + y1);
16166
+ x1 = x2;
16167
+ y1 = y2;
16168
+ }
16169
+ if (area < 0) {
16170
+ return -1;
16171
+ }
16172
+ return 1;
16173
+ }
16174
+ /**
16175
+ * Builds a line to draw using the polygon method.
16176
+ * @param points
16177
+ * @param lineStyle
16178
+ * @param flipAlignment
16179
+ * @param closed
16180
+ * @param vertices
16181
+ * @param _verticesStride
16182
+ * @param _verticesOffset
16183
+ * @param indices
16184
+ * @param _indicesOffset
16185
+ */ function buildLine(points, lineStyle, flipAlignment, closed, // alignment:number,
16186
+ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16187
+ // const shape = graphicsData.shape as Polygon;
16188
+ // let points = graphicsData.points || shape.points.slice();
16189
+ var eps = closePointEps;
16190
+ if (points.length === 0) {
16191
+ return;
16192
+ }
16193
+ var style = lineStyle;
16194
+ var alignment = style.alignment;
16195
+ if (lineStyle.alignment !== 0.5) {
16196
+ // rotate the points!
16197
+ var orientation = getOrientationOfPoints(points);
16198
+ if (flipAlignment) {
16199
+ orientation *= -1;
16200
+ }
16201
+ alignment = (alignment - 0.5) * orientation + 0.5;
16202
+ }
16203
+ // get first and last point.. figure out the middle!
16204
+ var firstPoint = new Point(points[0], points[1]);
16205
+ var lastPoint = new Point(points[points.length - 2], points[points.length - 1]);
16206
+ var closedShape = closed;
16207
+ var closedPath = Math.abs(firstPoint.x - lastPoint.x) < eps && Math.abs(firstPoint.y - lastPoint.y) < eps;
16208
+ // if the first point is the last point - gonna have issues :)
16209
+ if (closedShape) {
16210
+ // need to clone as we are going to slightly modify the shape..
16211
+ points = points.slice();
16212
+ if (closedPath) {
16213
+ points.pop();
16214
+ points.pop();
16215
+ lastPoint.set(points[points.length - 2], points[points.length - 1]);
16216
+ }
16217
+ var midPointX = (firstPoint.x + lastPoint.x) * 0.5;
16218
+ var midPointY = (lastPoint.y + firstPoint.y) * 0.5;
16219
+ points.unshift(midPointX, midPointY);
16220
+ points.push(midPointX, midPointY);
16221
+ }
16222
+ var verts = vertices;
16223
+ var length = points.length / 2;
16224
+ var indexCount = points.length;
16225
+ var indexStart = verts.length / 2;
16226
+ // Max. inner and outer width
16227
+ var width = style.width / 2;
16228
+ var widthSquared = width * width;
16229
+ var miterLimitSquared = style.miterLimit * style.miterLimit;
16230
+ /* Line segments of interest where (x1,y1) forms the corner. */ var x0 = points[0];
16231
+ var y0 = points[1];
16232
+ var x1 = points[2];
16233
+ var y1 = points[3];
16234
+ var x2 = 0;
16235
+ var y2 = 0;
16236
+ /* perp[?](x|y) = the line normal with magnitude lineWidth. */ var perpX = -(y0 - y1);
16237
+ var perpY = x0 - x1;
16238
+ var perp1x = 0;
16239
+ var perp1y = 0;
16240
+ var dist = Math.sqrt(perpX * perpX + perpY * perpY);
16241
+ perpX /= dist;
16242
+ perpY /= dist;
16243
+ perpX *= width;
16244
+ perpY *= width;
16245
+ var ratio = alignment; // 0.5;
16246
+ var innerWeight = (1 - ratio) * 2;
16247
+ var outerWeight = ratio * 2;
16248
+ if (!closedShape) {
16249
+ if (style.cap === "round") {
16250
+ 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;
16251
+ } else if (style.cap === "square") {
16252
+ indexCount += square(x0, y0, perpX, perpY, innerWeight, outerWeight, true, verts);
16253
+ }
16254
+ }
16255
+ // Push first point (below & above vertices)
16256
+ verts.push(x0 - perpX * innerWeight, y0 - perpY * innerWeight);
16257
+ verts.push(x0 + perpX * outerWeight, y0 + perpY * outerWeight);
16258
+ for(var i = 1; i < length - 1; ++i){
16259
+ x0 = points[(i - 1) * 2];
16260
+ y0 = points[(i - 1) * 2 + 1];
16261
+ x1 = points[i * 2];
16262
+ y1 = points[i * 2 + 1];
16263
+ x2 = points[(i + 1) * 2];
16264
+ y2 = points[(i + 1) * 2 + 1];
16265
+ perpX = -(y0 - y1);
16266
+ perpY = x0 - x1;
16267
+ dist = Math.sqrt(perpX * perpX + perpY * perpY);
16268
+ perpX /= dist;
16269
+ perpY /= dist;
16270
+ perpX *= width;
16271
+ perpY *= width;
16272
+ perp1x = -(y1 - y2);
16273
+ perp1y = x1 - x2;
16274
+ dist = Math.sqrt(perp1x * perp1x + perp1y * perp1y);
16275
+ perp1x /= dist;
16276
+ perp1y /= dist;
16277
+ perp1x *= width;
16278
+ perp1y *= width;
16279
+ /* d[x|y](0|1) = the component displacement between points p(0,1|1,2) */ var dx0 = x1 - x0;
16280
+ var dy0 = y0 - y1;
16281
+ var dx1 = x1 - x2;
16282
+ var dy1 = y2 - y1;
16283
+ /* +ve if internal angle < 90 degree, -ve if internal angle > 90 degree. */ var dot = dx0 * dx1 + dy0 * dy1;
16284
+ /* +ve if internal angle counterclockwise, -ve if internal angle clockwise. */ var cross = dy0 * dx1 - dy1 * dx0;
16285
+ var clockwise = cross < 0;
16286
+ /* Going nearly parallel? */ /* atan(0.001) ~= 0.001 rad ~= 0.057 degree */ if (Math.abs(cross) < 0.001 * Math.abs(dot)) {
16287
+ verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
16288
+ verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
16289
+ /* 180 degree corner? */ if (dot >= 0) {
16290
+ if (style.join === "round") {
16291
+ indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 4;
16292
+ } else {
16293
+ indexCount += 2;
16294
+ }
16295
+ verts.push(x1 - perp1x * outerWeight, y1 - perp1y * outerWeight);
16296
+ verts.push(x1 + perp1x * innerWeight, y1 + perp1y * innerWeight);
16297
+ }
16298
+ continue;
16299
+ }
16300
+ /* 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);
16301
+ var c2 = (-perp1x + x2) * (-perp1y + y1) - (-perp1x + x1) * (-perp1y + y2);
16302
+ var px = (dx0 * c2 - dx1 * c1) / cross;
16303
+ var py = (dy1 * c1 - dy0 * c2) / cross;
16304
+ var pDist = (px - x1) * (px - x1) + (py - y1) * (py - y1);
16305
+ /* Inner miter point */ var imx = x1 + (px - x1) * innerWeight;
16306
+ var imy = y1 + (py - y1) * innerWeight;
16307
+ /* Outer miter point */ var omx = x1 - (px - x1) * outerWeight;
16308
+ var omy = y1 - (py - y1) * outerWeight;
16309
+ /* Is the inside miter point too far away, creating a spike? */ var smallerInsideSegmentSq = Math.min(dx0 * dx0 + dy0 * dy0, dx1 * dx1 + dy1 * dy1);
16310
+ var insideWeight = clockwise ? innerWeight : outerWeight;
16311
+ var smallerInsideDiagonalSq = smallerInsideSegmentSq + insideWeight * insideWeight * widthSquared;
16312
+ var insideMiterOk = pDist <= smallerInsideDiagonalSq;
16313
+ if (insideMiterOk) {
16314
+ if (style.join === "bevel" || pDist / widthSquared > miterLimitSquared) {
16315
+ if (clockwise) /* rotating at inner angle */ {
16316
+ verts.push(imx, imy); // inner miter point
16317
+ verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
16318
+ verts.push(imx, imy); // inner miter point
16319
+ verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight); // second segment's outer vertex
16320
+ } else /* rotating at outer angle */ {
16321
+ verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight); // first segment's inner vertex
16322
+ verts.push(omx, omy); // outer miter point
16323
+ verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight); // second segment's outer vertex
16324
+ verts.push(omx, omy); // outer miter point
16325
+ }
16326
+ indexCount += 2;
16327
+ } else if (style.join === "round") {
16328
+ if (clockwise) /* arc is outside */ {
16329
+ verts.push(imx, imy);
16330
+ verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
16331
+ indexCount += round(x1, y1, x1 + perpX * outerWeight, y1 + perpY * outerWeight, x1 + perp1x * outerWeight, y1 + perp1y * outerWeight, verts, true) + 4;
16332
+ verts.push(imx, imy);
16333
+ verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight);
16334
+ } else /* arc is inside */ {
16335
+ verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
16336
+ verts.push(omx, omy);
16337
+ indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 4;
16338
+ verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight);
16339
+ verts.push(omx, omy);
16340
+ }
16341
+ } else {
16342
+ verts.push(imx, imy);
16343
+ verts.push(omx, omy);
16344
+ }
16345
+ } else {
16346
+ verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight); // first segment's inner vertex
16347
+ verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
16348
+ if (style.join === "round") {
16349
+ if (clockwise) /* arc is outside */ {
16350
+ indexCount += round(x1, y1, x1 + perpX * outerWeight, y1 + perpY * outerWeight, x1 + perp1x * outerWeight, y1 + perp1y * outerWeight, verts, true) + 2;
16351
+ } else /* arc is inside */ {
16352
+ indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 2;
16353
+ }
16354
+ } else if (style.join === "miter" && pDist / widthSquared <= miterLimitSquared) {
16355
+ if (clockwise) {
16356
+ verts.push(omx, omy); // inner miter point
16357
+ verts.push(omx, omy); // inner miter point
16358
+ } else {
16359
+ verts.push(imx, imy); // outer miter point
16360
+ verts.push(imx, imy); // outer miter point
16361
+ }
16362
+ indexCount += 2;
16363
+ }
16364
+ verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight); // second segment's inner vertex
16365
+ verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight); // second segment's outer vertex
16366
+ indexCount += 2;
16367
+ }
16368
+ }
16369
+ x0 = points[(length - 2) * 2];
16370
+ y0 = points[(length - 2) * 2 + 1];
16371
+ x1 = points[(length - 1) * 2];
16372
+ y1 = points[(length - 1) * 2 + 1];
16373
+ perpX = -(y0 - y1);
16374
+ perpY = x0 - x1;
16375
+ dist = Math.sqrt(perpX * perpX + perpY * perpY);
16376
+ perpX /= dist;
16377
+ perpY /= dist;
16378
+ perpX *= width;
16379
+ perpY *= width;
16380
+ verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
16381
+ verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
16382
+ if (!closedShape) {
16383
+ if (style.cap === "round") {
16384
+ 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;
16385
+ } else if (style.cap === "square") {
16386
+ indexCount += square(x1, y1, perpX, perpY, innerWeight, outerWeight, false, verts);
16387
+ }
16388
+ }
16389
+ // const indices = graphicsGeometry.indices;
16390
+ var eps2 = curveEps * curveEps;
16391
+ // indices.push(indexStart);
16392
+ for(var i1 = indexStart; i1 < indexCount + indexStart - 2; ++i1){
16393
+ x0 = verts[i1 * 2];
16394
+ y0 = verts[i1 * 2 + 1];
16395
+ x1 = verts[(i1 + 1) * 2];
16396
+ y1 = verts[(i1 + 1) * 2 + 1];
16397
+ x2 = verts[(i1 + 2) * 2];
16398
+ y2 = verts[(i1 + 2) * 2 + 1];
16399
+ /* Skip zero area triangles */ if (Math.abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) < eps2) {
16400
+ continue;
16401
+ }
16402
+ indices.push(i1, i1 + 1, i1 + 2);
16403
+ }
16404
+ }
16405
+
15885
16406
  exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15886
16407
  _inherits(ShapeComponent, MeshComponent);
15887
16408
  function ShapeComponent(engine) {
15888
16409
  var _this;
15889
16410
  _this = MeshComponent.call(this, engine) || this;
15890
- _this.path = new GraphicsPath();
16411
+ _this.isStroke = false;
16412
+ _this.graphicsPath = new GraphicsPath();
15891
16413
  _this.curveValues = [];
15892
- _this.animated = true;
16414
+ _this.shapeDirty = true;
15893
16415
  _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";
15894
16416
  _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";
15895
16417
  if (!_this.geometry) {
@@ -15937,6 +16459,20 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15937
16459
  _this.material.depthTest = true;
15938
16460
  _this.material.blending = true;
15939
16461
  }
16462
+ _this.strokeAttributes = {
16463
+ width: 1,
16464
+ alignment: 0.5,
16465
+ cap: "butt",
16466
+ join: "miter",
16467
+ miterLimit: 10
16468
+ };
16469
+ _this.shapeAttribute = {
16470
+ type: ShapePrimitiveType.Custom,
16471
+ points: [],
16472
+ easingIns: [],
16473
+ easingOuts: [],
16474
+ shapes: []
16475
+ };
15940
16476
  return _this;
15941
16477
  }
15942
16478
  var _proto = ShapeComponent.prototype;
@@ -15944,10 +16480,10 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15944
16480
  this.item.getHitTestParams = this.getHitTestParams;
15945
16481
  };
15946
16482
  _proto.onUpdate = function onUpdate(dt) {
15947
- if (this.animated) {
15948
- this.buildPath(this.data);
15949
- this.buildGeometryFromPath(this.path.shapePath);
15950
- this.animated = false;
16483
+ if (this.shapeDirty) {
16484
+ this.buildPath(this.shapeAttribute);
16485
+ this.buildGeometryFromPath(this.graphicsPath.shapePath);
16486
+ this.shapeDirty = false;
15951
16487
  }
15952
16488
  };
15953
16489
  _proto.buildGeometryFromPath = function buildGeometryFromPath(shapePath) {
@@ -15962,7 +16498,13 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15962
16498
  var indexOffset = indices.length;
15963
16499
  var vertOffset = vertices.length / 2;
15964
16500
  shape.build(points);
15965
- shape.triangulate(points, vertices, vertOffset, indices, indexOffset);
16501
+ if (!this.isStroke) {
16502
+ shape.triangulate(points, vertices, vertOffset, indices, indexOffset);
16503
+ } else {
16504
+ var close = true;
16505
+ var lineStyle = this.strokeAttributes;
16506
+ buildLine(points, lineStyle, false, close, vertices, 2, vertOffset, indices);
16507
+ }
15966
16508
  }
15967
16509
  var vertexCount = vertices.length / 2;
15968
16510
  // get the current attribute and index arrays from the geometry, avoiding re-creation
@@ -15975,7 +16517,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15975
16517
  if (!uvArray || uvArray.length < vertexCount * 2) {
15976
16518
  uvArray = new Float32Array(vertexCount * 2);
15977
16519
  }
15978
- if (!indexArray) {
16520
+ if (!indexArray || indexArray.length < indices.length) {
15979
16521
  indexArray = new Uint16Array(indices.length);
15980
16522
  }
15981
16523
  // set position and uv attribute array
@@ -15997,19 +16539,18 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15997
16539
  this.geometry.setIndexData(indexArray);
15998
16540
  this.geometry.setDrawCount(indices.length);
15999
16541
  };
16000
- _proto.buildPath = function buildPath(data) {
16001
- this.path.clear();
16002
- var shapeData = data;
16003
- switch(shapeData.type){
16542
+ _proto.buildPath = function buildPath(shapeAttribute) {
16543
+ this.graphicsPath.clear();
16544
+ switch(shapeAttribute.type){
16004
16545
  case ShapePrimitiveType.Custom:
16005
16546
  {
16006
- var customData = shapeData;
16007
- var points = customData.points;
16008
- var easingIns = customData.easingIns;
16009
- var easingOuts = customData.easingOuts;
16010
- this.curveValues = [];
16011
- for(var _iterator = _create_for_of_iterator_helper_loose(customData.shapes), _step; !(_step = _iterator()).done;){
16547
+ var customShapeAtribute = this.shapeAttribute;
16548
+ var points = customShapeAtribute.points;
16549
+ var easingIns = customShapeAtribute.easingIns;
16550
+ var easingOuts = customShapeAtribute.easingOuts;
16551
+ for(var _iterator = _create_for_of_iterator_helper_loose(customShapeAtribute.shapes), _step; !(_step = _iterator()).done;){
16012
16552
  var shape = _step.value;
16553
+ this.curveValues = [];
16013
16554
  this.setFillColor(shape.fill);
16014
16555
  var indices = shape.indexes;
16015
16556
  for(var i = 1; i < indices.length; i++){
@@ -16027,42 +16568,42 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16027
16568
  controlPoint1: easingOuts[indices[indices.length - 1].easingOut],
16028
16569
  controlPoint2: easingIns[indices[0].easingIn]
16029
16570
  });
16030
- }
16031
- this.path.moveTo(this.curveValues[this.curveValues.length - 1].point.x, this.curveValues[this.curveValues.length - 1].point.y);
16032
- for(var _iterator1 = _create_for_of_iterator_helper_loose(this.curveValues), _step1; !(_step1 = _iterator1()).done;){
16033
- var curveValue = _step1.value;
16034
- var point = curveValue.point;
16035
- var control1 = curveValue.controlPoint1;
16036
- var control2 = curveValue.controlPoint2;
16037
- this.path.bezierCurveTo(control1.x, control1.y, control2.x, control2.y, point.x, point.y, 1);
16571
+ this.graphicsPath.moveTo(this.curveValues[this.curveValues.length - 1].point.x, this.curveValues[this.curveValues.length - 1].point.y);
16572
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this.curveValues), _step1; !(_step1 = _iterator1()).done;){
16573
+ var curveValue = _step1.value;
16574
+ var point = curveValue.point;
16575
+ var control1 = curveValue.controlPoint1;
16576
+ var control2 = curveValue.controlPoint2;
16577
+ this.graphicsPath.bezierCurveTo(control1.x, control1.y, control2.x, control2.y, point.x, point.y, 1);
16578
+ }
16038
16579
  }
16039
16580
  break;
16040
16581
  }
16041
16582
  case ShapePrimitiveType.Ellipse:
16042
16583
  {
16043
- var ellipseData = shapeData;
16044
- this.path.ellipse(0, 0, ellipseData.xRadius, ellipseData.yRadius);
16584
+ var ellipseData = shapeAttribute;
16585
+ this.graphicsPath.ellipse(0, 0, ellipseData.xRadius, ellipseData.yRadius);
16045
16586
  this.setFillColor(ellipseData.fill);
16046
16587
  break;
16047
16588
  }
16048
16589
  case ShapePrimitiveType.Rectangle:
16049
16590
  {
16050
- var rectangleData = shapeData;
16051
- this.path.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height);
16591
+ var rectangleData = shapeAttribute;
16592
+ this.graphicsPath.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height);
16052
16593
  this.setFillColor(rectangleData.fill);
16053
16594
  break;
16054
16595
  }
16055
16596
  case ShapePrimitiveType.Star:
16056
16597
  {
16057
- var starData = shapeData;
16058
- this.path.polyStar(starData.pointCount, starData.outerRadius, starData.innerRadius, starData.outerRoundness, starData.innerRoundness, StarType.Star);
16598
+ var starData = shapeAttribute;
16599
+ this.graphicsPath.polyStar(starData.pointCount, starData.outerRadius, starData.innerRadius, starData.outerRoundness, starData.innerRoundness, StarType.Star);
16059
16600
  this.setFillColor(starData.fill);
16060
16601
  break;
16061
16602
  }
16062
16603
  case ShapePrimitiveType.Polygon:
16063
16604
  {
16064
- var polygonData = shapeData;
16065
- this.path.polyStar(polygonData.pointCount, polygonData.radius, polygonData.radius, polygonData.roundness, polygonData.roundness, StarType.Polygon);
16605
+ var polygonData = shapeAttribute;
16606
+ this.graphicsPath.polyStar(polygonData.pointCount, polygonData.radius, polygonData.radius, polygonData.roundness, polygonData.roundness, StarType.Polygon);
16066
16607
  this.setFillColor(polygonData.fill);
16067
16608
  break;
16068
16609
  }
@@ -16076,7 +16617,93 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16076
16617
  };
16077
16618
  _proto.fromData = function fromData(data) {
16078
16619
  MeshComponent.prototype.fromData.call(this, data);
16079
- this.data = data;
16620
+ this.shapeDirty = true;
16621
+ var strokeParam = data.stroke;
16622
+ if (strokeParam) {
16623
+ this.isStroke = true;
16624
+ this.strokeAttributes.width = strokeParam.width;
16625
+ }
16626
+ switch(data.type){
16627
+ case ShapePrimitiveType.Custom:
16628
+ {
16629
+ this.shapeAttribute = {
16630
+ type: ShapePrimitiveType.Custom,
16631
+ points: [],
16632
+ easingIns: [],
16633
+ easingOuts: [],
16634
+ shapes: []
16635
+ };
16636
+ var customShapeData = data;
16637
+ var customShapeAttribute = this.shapeAttribute;
16638
+ for(var _iterator = _create_for_of_iterator_helper_loose(customShapeData.points), _step; !(_step = _iterator()).done;){
16639
+ var point = _step.value;
16640
+ customShapeAttribute.points.push(new Vector2(point.x, point.y));
16641
+ }
16642
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(customShapeData.easingIns), _step1; !(_step1 = _iterator1()).done;){
16643
+ var easingIn = _step1.value;
16644
+ customShapeAttribute.easingIns.push(new Vector2(easingIn.x, easingIn.y));
16645
+ }
16646
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(customShapeData.easingOuts), _step2; !(_step2 = _iterator2()).done;){
16647
+ var easingOut = _step2.value;
16648
+ customShapeAttribute.easingOuts.push(new Vector2(easingOut.x, easingOut.y));
16649
+ }
16650
+ customShapeAttribute.shapes = customShapeData.shapes;
16651
+ break;
16652
+ }
16653
+ case ShapePrimitiveType.Ellipse:
16654
+ {
16655
+ var ellipseData = data;
16656
+ var ellipseAttribute = {
16657
+ type: ShapePrimitiveType.Ellipse,
16658
+ xRadius: ellipseData.xRadius,
16659
+ yRadius: ellipseData.yRadius,
16660
+ fill: ellipseData.fill
16661
+ };
16662
+ this.shapeAttribute = ellipseAttribute;
16663
+ break;
16664
+ }
16665
+ case ShapePrimitiveType.Rectangle:
16666
+ {
16667
+ var rectangleData = data;
16668
+ var rectangleAttribute = {
16669
+ type: ShapePrimitiveType.Rectangle,
16670
+ width: rectangleData.width,
16671
+ height: rectangleData.height,
16672
+ roundness: rectangleData.roundness,
16673
+ fill: rectangleData.fill
16674
+ };
16675
+ this.shapeAttribute = rectangleAttribute;
16676
+ break;
16677
+ }
16678
+ case ShapePrimitiveType.Star:
16679
+ {
16680
+ var starData = data;
16681
+ var starAttribute = {
16682
+ type: ShapePrimitiveType.Star,
16683
+ pointCount: starData.pointCount,
16684
+ innerRadius: starData.innerRadius,
16685
+ outerRadius: starData.outerRadius,
16686
+ innerRoundness: starData.innerRoundness,
16687
+ outerRoundness: starData.outerRoundness,
16688
+ fill: starData.fill
16689
+ };
16690
+ this.shapeAttribute = starAttribute;
16691
+ break;
16692
+ }
16693
+ case ShapePrimitiveType.Polygon:
16694
+ {
16695
+ var polygonData = data;
16696
+ var polygonAttribute = {
16697
+ type: ShapePrimitiveType.Polygon,
16698
+ pointCount: polygonData.pointCount,
16699
+ radius: polygonData.radius,
16700
+ roundness: polygonData.roundness,
16701
+ fill: polygonData.fill
16702
+ };
16703
+ this.shapeAttribute = polygonAttribute;
16704
+ break;
16705
+ }
16706
+ }
16080
16707
  var material = this.material;
16081
16708
  //@ts-expect-error // TODO 新版蒙版上线后重构
16082
16709
  material.stencilRef = data.renderer.mask !== undefined ? [
@@ -16086,6 +16713,15 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16086
16713
  //@ts-expect-error // TODO 新版蒙版上线后重构
16087
16714
  setMaskMode(material, data.renderer.maskMode);
16088
16715
  };
16716
+ _create_class(ShapeComponent, [
16717
+ {
16718
+ key: "shape",
16719
+ get: function get() {
16720
+ this.shapeDirty = true;
16721
+ return this.shapeAttribute;
16722
+ }
16723
+ }
16724
+ ]);
16089
16725
  return ShapeComponent;
16090
16726
  }(MeshComponent);
16091
16727
  exports.ShapeComponent = __decorate([
@@ -18773,10 +19409,19 @@ var TEMPLATE_USE_OFFSCREEN_CANVAS = "offscreen_canvas";
18773
19409
  // 后处理配置相关
18774
19410
  var POST_PROCESS_SETTINGS = "post_process_settings";
18775
19411
  var config = {};
18776
- function getConfig(name) {
19412
+ /**
19413
+ * 获取全局配置项
19414
+ * @param name
19415
+ * @returns
19416
+ */ function getConfig(name) {
18777
19417
  return config[name];
18778
19418
  }
18779
- function setConfig(name, value) {
19419
+ /**
19420
+ * 设置全局配置项
19421
+ * @param name
19422
+ * @param value
19423
+ * @returns
19424
+ */ function setConfig(name, value) {
18780
19425
  return config[name] = value;
18781
19426
  }
18782
19427
 
@@ -20478,19 +21123,17 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
20478
21123
  rotation: rotation,
20479
21124
  path: path
20480
21125
  };
20481
- var parentTransform = this.transform.parentTransform;
20482
21126
  var selfPos = position.clone();
20483
21127
  if (path) {
20484
21128
  selfPos.add(path.getValue(0));
20485
21129
  }
20486
21130
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
20487
- if (this.options.particleFollowParent && parentTransform) {
20488
- var worldMatrix = parentTransform.getWorldMatrix();
21131
+ if (this.options.particleFollowParent) {
21132
+ var worldMatrix = this.transform.getWorldMatrix();
20489
21133
  this.renderer.updateWorldMatrix(worldMatrix);
20490
21134
  }
20491
21135
  };
20492
21136
  _proto.updateEmitterTransform = function updateEmitterTransform(time) {
20493
- var parentTransform = this.transform.parentTransform;
20494
21137
  var _this_basicTransform = this.basicTransform, path = _this_basicTransform.path, position = _this_basicTransform.position;
20495
21138
  var selfPos = position.clone();
20496
21139
  if (path) {
@@ -20498,8 +21141,8 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
20498
21141
  selfPos.add(path.getValue(time / duration));
20499
21142
  }
20500
21143
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
20501
- if (this.options.particleFollowParent && parentTransform) {
20502
- var worldMatrix = parentTransform.getWorldMatrix();
21144
+ if (this.options.particleFollowParent) {
21145
+ var worldMatrix = this.transform.getWorldMatrix();
20503
21146
  this.renderer.updateWorldMatrix(worldMatrix);
20504
21147
  }
20505
21148
  };
@@ -20887,7 +21530,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
20887
21530
  var lifetime = this.lifetime;
20888
21531
  var shape = this.shape;
20889
21532
  var speed = options.startSpeed.getValue(lifetime);
20890
- var matrix4 = options.particleFollowParent ? this.transform.getMatrix() : this.transform.getWorldMatrix();
21533
+ var matrix4 = options.particleFollowParent ? Matrix4.IDENTITY : this.transform.getWorldMatrix();
20891
21534
  var pointPosition = data.position;
20892
21535
  // 粒子的位置受发射器的位置影响,自身的旋转和缩放不受影响
20893
21536
  var position = matrix4.transformPoint(pointPosition, new Vector3());
@@ -23123,88 +23766,81 @@ var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
23123
23766
  return PropertyClipPlayable;
23124
23767
  }(Playable);
23125
23768
 
23126
- var ColorPropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23127
- _inherits(ColorPropertyMixerPlayable, TrackMixerPlayable);
23128
- function ColorPropertyMixerPlayable() {
23769
+ var PropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23770
+ _inherits(PropertyMixerPlayable, TrackMixerPlayable);
23771
+ function PropertyMixerPlayable() {
23129
23772
  var _this;
23130
23773
  _this = TrackMixerPlayable.apply(this, arguments) || this;
23131
23774
  _this.propertyName = "";
23132
23775
  return _this;
23133
23776
  }
23134
- var _proto = ColorPropertyMixerPlayable.prototype;
23777
+ var _proto = PropertyMixerPlayable.prototype;
23135
23778
  _proto.evaluate = function evaluate(context) {
23136
23779
  var boundObject = context.output.getUserData();
23137
23780
  if (!boundObject) {
23138
23781
  return;
23139
23782
  }
23140
23783
  var hasInput = false;
23141
- var value = boundObject[this.propertyName];
23142
- if (!_instanceof1(value, Color)) {
23784
+ this.propertyValue = boundObject[this.propertyName];
23785
+ if (this.propertyValue === undefined || this.propertyValue === null) {
23143
23786
  return;
23144
23787
  }
23145
- value.setZero();
23788
+ this.resetPropertyValue();
23146
23789
  // evaluate the curve
23147
23790
  for(var i = 0; i < this.clipPlayables.length; i++){
23148
23791
  var weight = this.getClipWeight(i);
23149
23792
  if (weight > 0) {
23150
23793
  var propertyClipPlayable = this.getClipPlayable(i);
23151
23794
  if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23152
- console.error("ColorPropertyMixerPlayable received incompatible input");
23795
+ console.error("PropertyTrack added non-PropertyPlayableAsset");
23153
23796
  continue;
23154
23797
  }
23155
23798
  var curveValue = propertyClipPlayable.value;
23156
- value.r += curveValue.r * weight;
23157
- value.g += curveValue.g * weight;
23158
- value.b += curveValue.b * weight;
23159
- value.a += curveValue.a * weight;
23799
+ this.addWeightedValue(curveValue, weight);
23160
23800
  hasInput = true;
23161
23801
  }
23162
23802
  }
23163
23803
  // set value
23164
23804
  if (hasInput) {
23165
- boundObject[this.propertyName] = value;
23805
+ boundObject[this.propertyName] = this.propertyValue;
23166
23806
  }
23167
23807
  };
23168
- return ColorPropertyMixerPlayable;
23808
+ return PropertyMixerPlayable;
23169
23809
  }(TrackMixerPlayable);
23170
23810
 
23171
- var FloatPropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23172
- _inherits(FloatPropertyMixerPlayable, TrackMixerPlayable);
23811
+ var ColorPropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
23812
+ _inherits(ColorPropertyMixerPlayable, PropertyMixerPlayable);
23813
+ function ColorPropertyMixerPlayable() {
23814
+ return PropertyMixerPlayable.apply(this, arguments);
23815
+ }
23816
+ var _proto = ColorPropertyMixerPlayable.prototype;
23817
+ _proto.resetPropertyValue = function resetPropertyValue() {
23818
+ this.propertyValue.setZero();
23819
+ };
23820
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
23821
+ var result = this.propertyValue;
23822
+ result.r += curveValue.r * weight;
23823
+ result.g += curveValue.g * weight;
23824
+ result.b += curveValue.b * weight;
23825
+ result.a += curveValue.a * weight;
23826
+ };
23827
+ return ColorPropertyMixerPlayable;
23828
+ }(PropertyMixerPlayable);
23829
+
23830
+ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
23831
+ _inherits(FloatPropertyMixerPlayable, PropertyMixerPlayable);
23173
23832
  function FloatPropertyMixerPlayable() {
23174
- var _this;
23175
- _this = TrackMixerPlayable.apply(this, arguments) || this;
23176
- _this.propertyName = "";
23177
- return _this;
23833
+ return PropertyMixerPlayable.apply(this, arguments);
23178
23834
  }
23179
23835
  var _proto = FloatPropertyMixerPlayable.prototype;
23180
- _proto.evaluate = function evaluate(context) {
23181
- var boundObject = context.output.getUserData();
23182
- if (!boundObject) {
23183
- return;
23184
- }
23185
- var hasInput = false;
23186
- var value = 0;
23187
- // evaluate the curve
23188
- for(var i = 0; i < this.clipPlayables.length; i++){
23189
- var weight = this.getClipWeight(i);
23190
- if (weight > 0) {
23191
- var propertyClipPlayable = this.getClipPlayable(i);
23192
- if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23193
- console.error("FloatPropertyTrack added non-FloatPropertyPlayableAsset");
23194
- continue;
23195
- }
23196
- var curveValue = propertyClipPlayable.value;
23197
- value += curveValue * weight;
23198
- hasInput = true;
23199
- }
23200
- }
23201
- // set value
23202
- if (hasInput) {
23203
- boundObject[this.propertyName] = value;
23204
- }
23836
+ _proto.resetPropertyValue = function resetPropertyValue() {
23837
+ this.propertyValue = 0;
23838
+ };
23839
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
23840
+ this.propertyValue += curveValue * weight;
23205
23841
  };
23206
23842
  return FloatPropertyMixerPlayable;
23207
- }(TrackMixerPlayable);
23843
+ }(PropertyMixerPlayable);
23208
23844
 
23209
23845
  var ParticleMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23210
23846
  _inherits(ParticleMixerPlayable, TrackMixerPlayable);
@@ -23716,7 +24352,7 @@ var SerializationHelper = /*#__PURE__*/ function() {
23716
24352
  this.timelinePlayable.setTime(time);
23717
24353
  // The properties of the object may change dynamically,
23718
24354
  // so reset the track binding to avoid invalidation of the previously obtained binding object.
23719
- // this.resolveBindings();
24355
+ this.resolveBindings();
23720
24356
  this.timelinePlayable.evaluate();
23721
24357
  this.graph.evaluate(dt);
23722
24358
  };
@@ -23948,50 +24584,44 @@ var TransformMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23948
24584
  return TransformMixerPlayable;
23949
24585
  }(TrackMixerPlayable);
23950
24586
 
23951
- var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23952
- _inherits(Vector4PropertyMixerPlayable, TrackMixerPlayable);
24587
+ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
24588
+ _inherits(Vector4PropertyMixerPlayable, PropertyMixerPlayable);
23953
24589
  function Vector4PropertyMixerPlayable() {
23954
- var _this;
23955
- _this = TrackMixerPlayable.apply(this, arguments) || this;
23956
- _this.propertyName = "";
23957
- return _this;
24590
+ return PropertyMixerPlayable.apply(this, arguments);
23958
24591
  }
23959
24592
  var _proto = Vector4PropertyMixerPlayable.prototype;
23960
- _proto.evaluate = function evaluate(context) {
23961
- var boundObject = context.output.getUserData();
23962
- if (!boundObject) {
23963
- return;
23964
- }
23965
- var hasInput = false;
23966
- var value = boundObject[this.propertyName];
23967
- if (!_instanceof1(value, Vector4)) {
23968
- return;
23969
- }
23970
- value.setZero();
23971
- // evaluate the curve
23972
- for(var i = 0; i < this.clipPlayables.length; i++){
23973
- var weight = this.getClipWeight(i);
23974
- if (weight > 0) {
23975
- var propertyClipPlayable = this.getClipPlayable(i);
23976
- if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23977
- console.error("Vector4PropertyTrack added non-Vector4PropertyPlayableAsset");
23978
- continue;
23979
- }
23980
- var curveValue = propertyClipPlayable.value;
23981
- value.x += curveValue.x * weight;
23982
- value.y += curveValue.y * weight;
23983
- value.z += curveValue.z * weight;
23984
- value.w += curveValue.w * weight;
23985
- hasInput = true;
23986
- }
23987
- }
23988
- // set value
23989
- if (hasInput) {
23990
- boundObject[this.propertyName] = value;
23991
- }
24593
+ _proto.resetPropertyValue = function resetPropertyValue() {
24594
+ this.propertyValue.x = 0;
24595
+ this.propertyValue.y = 0;
24596
+ this.propertyValue.z = 0;
24597
+ this.propertyValue.w = 0;
24598
+ };
24599
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
24600
+ var result = this.propertyValue;
24601
+ result.x += curveValue.x * weight;
24602
+ result.y += curveValue.y * weight;
24603
+ result.z += curveValue.z * weight;
24604
+ result.w += curveValue.w * weight;
23992
24605
  };
23993
24606
  return Vector4PropertyMixerPlayable;
23994
- }(TrackMixerPlayable);
24607
+ }(PropertyMixerPlayable);
24608
+ var Vector2PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
24609
+ _inherits(Vector2PropertyMixerPlayable, PropertyMixerPlayable);
24610
+ function Vector2PropertyMixerPlayable() {
24611
+ return PropertyMixerPlayable.apply(this, arguments);
24612
+ }
24613
+ var _proto = Vector2PropertyMixerPlayable.prototype;
24614
+ _proto.resetPropertyValue = function resetPropertyValue() {
24615
+ this.propertyValue.x = 0;
24616
+ this.propertyValue.y = 0;
24617
+ };
24618
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
24619
+ var result = this.propertyValue;
24620
+ result.x += curveValue.x * weight;
24621
+ result.y += curveValue.y * weight;
24622
+ };
24623
+ return Vector2PropertyMixerPlayable;
24624
+ }(PropertyMixerPlayable);
23995
24625
 
23996
24626
  /**
23997
24627
  * @since 2.0.0
@@ -24372,6 +25002,26 @@ exports.Vector4PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
24372
25002
  exports.Vector4PropertyTrack = __decorate([
24373
25003
  effectsClass(DataType.Vector4PropertyTrack)
24374
25004
  ], exports.Vector4PropertyTrack);
25005
+ exports.Vector2PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
25006
+ _inherits(Vector2PropertyTrack, PropertyTrack);
25007
+ function Vector2PropertyTrack() {
25008
+ return PropertyTrack.apply(this, arguments);
25009
+ }
25010
+ var _proto = Vector2PropertyTrack.prototype;
25011
+ _proto.createTrackMixer = function createTrackMixer(graph) {
25012
+ var mixer = new Vector2PropertyMixerPlayable(graph);
25013
+ var propertyNames = this.propertyNames;
25014
+ if (propertyNames.length > 0) {
25015
+ var propertyName = propertyNames[propertyNames.length - 1];
25016
+ mixer.propertyName = propertyName;
25017
+ }
25018
+ return mixer;
25019
+ };
25020
+ return Vector2PropertyTrack;
25021
+ }(PropertyTrack);
25022
+ exports.Vector2PropertyTrack = __decorate([
25023
+ effectsClass("Vector2PropertyTrack")
25024
+ ], exports.Vector2PropertyTrack);
24375
25025
 
24376
25026
  exports.ColorPropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
24377
25027
  _inherits(ColorPropertyTrack, PropertyTrack);
@@ -24638,8 +25288,28 @@ __decorate([
24638
25288
  serialize()
24639
25289
  ], exports.Vector4PropertyPlayableAsset.prototype, "curveData", void 0);
24640
25290
  exports.Vector4PropertyPlayableAsset = __decorate([
24641
- effectsClass("Vector4PropertyPlayableAsset")
25291
+ effectsClass(DataType.Vector4PropertyPlayableAsset)
24642
25292
  ], exports.Vector4PropertyPlayableAsset);
25293
+ exports.Vector2PropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
25294
+ _inherits(Vector2PropertyPlayableAsset, PlayableAsset);
25295
+ function Vector2PropertyPlayableAsset() {
25296
+ return PlayableAsset.apply(this, arguments);
25297
+ }
25298
+ var _proto = Vector2PropertyPlayableAsset.prototype;
25299
+ _proto.createPlayable = function createPlayable(graph) {
25300
+ var clipPlayable = new PropertyClipPlayable(graph);
25301
+ clipPlayable.curve = createValueGetter(this.curveData);
25302
+ clipPlayable.value = clipPlayable.curve.getValue(0);
25303
+ return clipPlayable;
25304
+ };
25305
+ return Vector2PropertyPlayableAsset;
25306
+ }(PlayableAsset);
25307
+ __decorate([
25308
+ serialize()
25309
+ ], exports.Vector2PropertyPlayableAsset.prototype, "curveData", void 0);
25310
+ exports.Vector2PropertyPlayableAsset = __decorate([
25311
+ effectsClass(DataType.Vector2PropertyPlayableAsset)
25312
+ ], exports.Vector2PropertyPlayableAsset);
24643
25313
 
24644
25314
  exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset) {
24645
25315
  _inherits(ObjectBindingTrack, TrackAsset);
@@ -26022,7 +26692,7 @@ function getStandardInteractContent(ui) {
26022
26692
  }
26023
26693
  });
26024
26694
  });
26025
- json.version = "2.1";
26695
+ json.version = JSONSceneVersion["2_1"];
26026
26696
  return json;
26027
26697
  }
26028
26698
  /**
@@ -26361,7 +27031,7 @@ function getStandardInteractContent(ui) {
26361
27031
  break;
26362
27032
  }
26363
27033
  }
26364
- result.version = "3.0";
27034
+ result.version = JSONSceneVersion["3_0"];
26365
27035
  return result;
26366
27036
  }
26367
27037
  /**
@@ -26903,13 +27573,13 @@ function getStandardJSON(json) {
26903
27573
  }
26904
27574
  throw new Error("Invalid JSON version: " + json.version + ".");
26905
27575
  }
26906
- var currentVersion = "1.0";
27576
+ var currentVersion = JSONSceneVersion["1_0"];
26907
27577
  function getStandardJSONFromV0(json) {
26908
27578
  var _json_bins;
26909
- currentVersion = "1.0";
27579
+ currentVersion = JSONSceneVersion["1_0"];
26910
27580
  var plugins = json.plugins || [];
26911
27581
  if ((_json_bins = json.bins) == null ? void 0 : _json_bins.length) {
26912
- currentVersion = "1.3";
27582
+ currentVersion = JSONSceneVersion["1_3"];
26913
27583
  }
26914
27584
  var requires = (json.requires || []).slice();
26915
27585
  var images = json.images.map(function(img, index) {
@@ -28832,7 +29502,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
28832
29502
  */ _proto.getSpeed = function getSpeed() {
28833
29503
  return this.speed;
28834
29504
  };
28835
- _proto.play = function play() {
29505
+ /**
29506
+ *
29507
+ */ _proto.play = function play() {
28836
29508
  if (this.isEnded && this.reusable) {
28837
29509
  this.restart();
28838
29510
  }
@@ -28847,7 +29519,10 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
28847
29519
  */ _proto.pause = function pause() {
28848
29520
  this.paused = true;
28849
29521
  };
28850
- _proto.getPaused = function getPaused() {
29522
+ /**
29523
+ *
29524
+ * @returns
29525
+ */ _proto.getPaused = function getPaused() {
28851
29526
  return this.paused;
28852
29527
  };
28853
29528
  /**
@@ -31425,7 +32100,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
31425
32100
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
31426
32101
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
31427
32102
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
31428
- var version$1 = "2.2.6";
32103
+ var version$1 = "2.3.0-alpha.1";
31429
32104
  logger.info("Core version: " + version$1 + ".");
31430
32105
 
31431
32106
  var _obj;
@@ -33058,7 +33733,7 @@ setMaxSpriteMeshItemCount(8);
33058
33733
  */ Mesh.create = function(engine, props) {
33059
33734
  return new ThreeMesh(engine, props);
33060
33735
  };
33061
- var version = "2.2.6";
33736
+ var version = "2.3.0-alpha.1";
33062
33737
  logger.info("THREEJS plugin version: " + version + ".");
33063
33738
 
33064
33739
  exports.AbstractPlugin = AbstractPlugin;
@@ -33177,6 +33852,7 @@ exports.TrackSortWrapper = TrackSortWrapper;
33177
33852
  exports.Transform = Transform;
33178
33853
  exports.TransformAnimationPlayable = TransformAnimationPlayable;
33179
33854
  exports.ValueGetter = ValueGetter;
33855
+ exports.Vector2Curve = Vector2Curve;
33180
33856
  exports.Vector4Curve = Vector4Curve;
33181
33857
  exports.addByOrder = addByOrder;
33182
33858
  exports.addItem = addItem;