@galacean/effects-threejs 2.2.5 → 2.3.0-alpha.0
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 +1179 -562
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +1179 -563
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.
|
|
6
|
+
* Version: v2.3.0-alpha.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -979,7 +979,7 @@ var pluginInfoMap = {
|
|
|
979
979
|
"video": "@galacean/effects-plugin-multimedia",
|
|
980
980
|
"audio": "@galacean/effects-plugin-multimedia",
|
|
981
981
|
"orientation-transformer": "@galacean/effects-plugin-orientation-transformer",
|
|
982
|
-
"
|
|
982
|
+
"rich-text": "@galacean/effects-plugin-rich-text",
|
|
983
983
|
"spine": "@galacean/effects-plugin-spine"
|
|
984
984
|
};
|
|
985
985
|
function getPluginUsageInfo(name) {
|
|
@@ -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
|
-
|
|
1353
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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() {
|
|
@@ -11741,25 +11782,35 @@ function numberToFix(a, fixed) {
|
|
|
11741
11782
|
}
|
|
11742
11783
|
|
|
11743
11784
|
var keyframeInfo = {
|
|
11785
|
+
pointIndexCache: {
|
|
11786
|
+
xIndex: 0,
|
|
11787
|
+
yIndex: 0
|
|
11788
|
+
},
|
|
11744
11789
|
/**
|
|
11745
11790
|
* 根据不同关键帧类型,获取位于曲线上的点
|
|
11746
11791
|
*/ getPointInCurve: function getPointInCurve(keyframe) {
|
|
11747
11792
|
keyframe[0]; var data = keyframe[1];
|
|
11748
|
-
var _this_getPointIndexInCurve = this.getPointIndexInCurve(keyframe), xIndex = _this_getPointIndexInCurve.xIndex, yIndex = _this_getPointIndexInCurve.yIndex;
|
|
11793
|
+
var _this_getPointIndexInCurve = this.getPointIndexInCurve(keyframe, this.pointIndexCache), xIndex = _this_getPointIndexInCurve.xIndex, yIndex = _this_getPointIndexInCurve.yIndex;
|
|
11749
11794
|
var time = data[xIndex];
|
|
11750
11795
|
var value = data[yIndex];
|
|
11751
11796
|
return new Vector2(time, value);
|
|
11752
11797
|
},
|
|
11753
11798
|
/**
|
|
11754
11799
|
* 根据不同关键帧类型,获取位于曲线上的点的索引
|
|
11755
|
-
*/ getPointIndexInCurve: function getPointIndexInCurve(keyframe) {
|
|
11800
|
+
*/ getPointIndexInCurve: function getPointIndexInCurve(keyframe, res) {
|
|
11756
11801
|
var type = keyframe[0], markType = keyframe[2];
|
|
11757
11802
|
// 不同类型,存放的时间不同
|
|
11758
11803
|
var index = type === BezierKeyframeType.LINE ? 0 : type === BezierKeyframeType.EASE_OUT ? 0 : type === BezierKeyframeType.EASE_IN ? 2 : type === BezierKeyframeType.EASE ? 2 : type === BezierKeyframeType.HOLD ? markType === BezierKeyframeType.EASE_IN ? 2 : 0 : 0;
|
|
11759
|
-
|
|
11760
|
-
xIndex
|
|
11761
|
-
yIndex
|
|
11762
|
-
|
|
11804
|
+
if (res) {
|
|
11805
|
+
res.xIndex = index;
|
|
11806
|
+
res.yIndex = index + 1;
|
|
11807
|
+
return res;
|
|
11808
|
+
} else {
|
|
11809
|
+
return {
|
|
11810
|
+
xIndex: index,
|
|
11811
|
+
yIndex: index + 1
|
|
11812
|
+
};
|
|
11813
|
+
}
|
|
11763
11814
|
},
|
|
11764
11815
|
/**
|
|
11765
11816
|
* 关键帧左侧是否为缓动类型(否则为线段)
|
|
@@ -12666,6 +12717,8 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
12666
12717
|
timeEnd: Number(e.x)
|
|
12667
12718
|
};
|
|
12668
12719
|
}
|
|
12720
|
+
this.startKeyframe = keyframes[0];
|
|
12721
|
+
this.endKeyframe = keyframes[keyframes.length - 1];
|
|
12669
12722
|
this.keyTimeData = Object.keys(this.curveMap);
|
|
12670
12723
|
};
|
|
12671
12724
|
_proto.getValue = function getValue(time) {
|
|
@@ -12673,12 +12726,18 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
12673
12726
|
var keyTimeData = this.keyTimeData;
|
|
12674
12727
|
var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
|
|
12675
12728
|
var keyTimeEnd = this.curveMap[keyTimeData[keyTimeData.length - 1]].timeEnd;
|
|
12676
|
-
// const keyTimeStart = Number(keyTimeData[0].split('&')[0]);
|
|
12677
|
-
// const keyTimeEnd = Number(keyTimeData[keyTimeData.length - 1].split('&')[1]);
|
|
12678
12729
|
if (time <= keyTimeStart) {
|
|
12730
|
+
if (this.startKeyframe[0] === BezierKeyframeType.LINE || this.startKeyframe[0] === BezierKeyframeType.HOLD) {
|
|
12731
|
+
keyframeInfo.getPointIndexInCurve(this.startKeyframe, keyframeInfo.pointIndexCache);
|
|
12732
|
+
return this.endKeyframe[1][keyframeInfo.pointIndexCache.yIndex];
|
|
12733
|
+
}
|
|
12679
12734
|
return this.getCurveValue(keyTimeData[0], keyTimeStart);
|
|
12680
12735
|
}
|
|
12681
12736
|
if (time >= keyTimeEnd) {
|
|
12737
|
+
if (this.endKeyframe[0] === BezierKeyframeType.LINE || this.endKeyframe[0] === BezierKeyframeType.HOLD) {
|
|
12738
|
+
keyframeInfo.getPointIndexInCurve(this.endKeyframe, keyframeInfo.pointIndexCache);
|
|
12739
|
+
return this.endKeyframe[1][keyframeInfo.pointIndexCache.yIndex];
|
|
12740
|
+
}
|
|
12682
12741
|
return this.getCurveValue(keyTimeData[keyTimeData.length - 1], keyTimeEnd);
|
|
12683
12742
|
}
|
|
12684
12743
|
for(var i = 0; i < keyTimeData.length; i++){
|
|
@@ -13110,6 +13169,27 @@ var Vector4Curve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
13110
13169
|
};
|
|
13111
13170
|
return Vector4Curve;
|
|
13112
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);
|
|
13113
13193
|
|
|
13114
13194
|
var SPRITE_VERTEX_STRIDE = 6;
|
|
13115
13195
|
var SEMANTIC_PRE_COLOR_ATTACHMENT_0 = "PRE_COLOR_0";
|
|
@@ -13173,6 +13253,8 @@ var map$1 = (_obj$4 = {}, _obj$4[ValueType.RANDOM] = function(props) {
|
|
|
13173
13253
|
return new ColorCurve(props);
|
|
13174
13254
|
}, _obj$4[ValueType.VECTOR4_CURVE] = function(props) {
|
|
13175
13255
|
return new Vector4Curve(props);
|
|
13256
|
+
}, _obj$4[ValueType.VECTOR2_CURVE] = function(props) {
|
|
13257
|
+
return new Vector2Curve(props);
|
|
13176
13258
|
}, _obj$4);
|
|
13177
13259
|
function createValueGetter(args) {
|
|
13178
13260
|
if (!args || !isNaN(+args)) {
|
|
@@ -13297,13 +13379,39 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
13297
13379
|
this.color = color;
|
|
13298
13380
|
this.material.setVector4("_Color", new Vector4().setFromArray(color));
|
|
13299
13381
|
};
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
13306
|
-
|
|
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
|
+
})();
|
|
13307
13415
|
};
|
|
13308
13416
|
/**
|
|
13309
13417
|
* @internal
|
|
@@ -13565,6 +13673,8 @@ function getImageItemRenderInfo(item) {
|
|
|
13565
13673
|
};
|
|
13566
13674
|
}
|
|
13567
13675
|
|
|
13676
|
+
// Based on:
|
|
13677
|
+
// https://github.com/pixijs/pixijs/blob/dev/src/maths/shapes/ShapePrimitive.ts
|
|
13568
13678
|
var ShapePrimitive = function ShapePrimitive() {
|
|
13569
13679
|
};
|
|
13570
13680
|
|
|
@@ -14670,6 +14780,7 @@ function triangulate(contours) {
|
|
|
14670
14780
|
return triangleVerts;
|
|
14671
14781
|
}
|
|
14672
14782
|
|
|
14783
|
+
// Based on:
|
|
14673
14784
|
/**
|
|
14674
14785
|
* A class to define a shape via user defined coordinates.
|
|
14675
14786
|
*/ var Polygon = /*#__PURE__*/ function(ShapePrimitive) {
|
|
@@ -14769,12 +14880,13 @@ function triangulate(contours) {
|
|
|
14769
14880
|
var triangles = triangulate([
|
|
14770
14881
|
points
|
|
14771
14882
|
]);
|
|
14883
|
+
var indexStart = vertices.length / 2;
|
|
14772
14884
|
for(var i = 0; i < triangles.length; i++){
|
|
14773
|
-
vertices[verticesOffset + i] = triangles[i];
|
|
14885
|
+
vertices[verticesOffset * 2 + i] = triangles[i];
|
|
14774
14886
|
}
|
|
14775
14887
|
var vertexCount = triangles.length / 2;
|
|
14776
14888
|
for(var i1 = 0; i1 < vertexCount; i1++){
|
|
14777
|
-
indices[indicesOffset + i1] = i1;
|
|
14889
|
+
indices[indicesOffset + i1] = indexStart + i1;
|
|
14778
14890
|
}
|
|
14779
14891
|
};
|
|
14780
14892
|
_create_class(Polygon, [
|
|
@@ -14896,6 +15008,7 @@ function recursive(x1, y1, x2, y2, x3, y3, x4, y4, points, distanceTolerance, le
|
|
|
14896
15008
|
recursive(x1234, y1234, x234, y234, x34, y34, x4, y4, points, distanceTolerance, level + 1);
|
|
14897
15009
|
}
|
|
14898
15010
|
|
|
15011
|
+
// Based on:
|
|
14899
15012
|
/**
|
|
14900
15013
|
* The Ellipse object is used to help draw graphics and can also be used to specify a hit area for containers.
|
|
14901
15014
|
*/ var Ellipse = /*#__PURE__*/ function(ShapePrimitive) {
|
|
@@ -15102,6 +15215,7 @@ function recursive(x1, y1, x2, y2, x3, y3, x4, y4, points, distanceTolerance, le
|
|
|
15102
15215
|
return Ellipse;
|
|
15103
15216
|
}(ShapePrimitive);
|
|
15104
15217
|
|
|
15218
|
+
// Based on:
|
|
15105
15219
|
var StarType;
|
|
15106
15220
|
(function(StarType) {
|
|
15107
15221
|
StarType[StarType["Star"] = 0] = "Star";
|
|
@@ -15170,12 +15284,13 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
|
|
|
15170
15284
|
var triangles = triangulate([
|
|
15171
15285
|
points
|
|
15172
15286
|
]);
|
|
15287
|
+
var indexStart = vertices.length / 2;
|
|
15173
15288
|
for(var i = 0; i < triangles.length; i++){
|
|
15174
|
-
vertices[verticesOffset + i] = triangles[i];
|
|
15289
|
+
vertices[verticesOffset * 2 + i] = triangles[i];
|
|
15175
15290
|
}
|
|
15176
15291
|
var vertexCount = triangles.length / 2;
|
|
15177
15292
|
for(var i1 = 0; i1 < vertexCount; i1++){
|
|
15178
|
-
indices[indicesOffset + i1] = i1;
|
|
15293
|
+
indices[indicesOffset + i1] = indexStart + i1;
|
|
15179
15294
|
}
|
|
15180
15295
|
};
|
|
15181
15296
|
_proto.buildStarPath = function buildStarPath() {
|
|
@@ -15246,6 +15361,7 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
|
|
|
15246
15361
|
return PolyStar;
|
|
15247
15362
|
}(ShapePrimitive);
|
|
15248
15363
|
|
|
15364
|
+
// Based on:
|
|
15249
15365
|
// const tempPoints = [new Point(), new Point(), new Point(), new Point()];
|
|
15250
15366
|
/**
|
|
15251
15367
|
* The `Rectangle` object is an area defined by its position, as indicated by its upper-left corner
|
|
@@ -15569,6 +15685,7 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
|
|
|
15569
15685
|
return Rectangle;
|
|
15570
15686
|
}(ShapePrimitive);
|
|
15571
15687
|
|
|
15688
|
+
// Based on:
|
|
15572
15689
|
var ShapePath = /*#__PURE__*/ function() {
|
|
15573
15690
|
function ShapePath(graphicsPath) {
|
|
15574
15691
|
this.graphicsPath = graphicsPath;
|
|
@@ -15727,6 +15844,7 @@ var ShapePath = /*#__PURE__*/ function() {
|
|
|
15727
15844
|
return ShapePath;
|
|
15728
15845
|
}();
|
|
15729
15846
|
|
|
15847
|
+
// Based on:
|
|
15730
15848
|
var GraphicsPath = /*#__PURE__*/ function() {
|
|
15731
15849
|
function GraphicsPath() {
|
|
15732
15850
|
this.instructions = [];
|
|
@@ -15864,14 +15982,433 @@ var GraphicsPath = /*#__PURE__*/ function() {
|
|
|
15864
15982
|
return GraphicsPath;
|
|
15865
15983
|
}();
|
|
15866
15984
|
|
|
15985
|
+
// Based on:
|
|
15986
|
+
/**
|
|
15987
|
+
* The Point object represents a location in a two-dimensional coordinate system, where `x` represents
|
|
15988
|
+
* the position on the horizontal axis and `y` represents the position on the vertical axis.
|
|
15989
|
+
*/ var Point = /*#__PURE__*/ function() {
|
|
15990
|
+
function Point(x, y) {
|
|
15991
|
+
if (x === void 0) x = 0;
|
|
15992
|
+
if (y === void 0) y = 0;
|
|
15993
|
+
/**
|
|
15994
|
+
* Position of the point on the x axis
|
|
15995
|
+
*/ this.x = 0;
|
|
15996
|
+
/**
|
|
15997
|
+
* Position of the point on the y axis
|
|
15998
|
+
*/ this.y = 0;
|
|
15999
|
+
this.x = x;
|
|
16000
|
+
this.y = y;
|
|
16001
|
+
}
|
|
16002
|
+
var _proto = Point.prototype;
|
|
16003
|
+
/**
|
|
16004
|
+
* Creates a clone of this point
|
|
16005
|
+
* @returns A clone of this point
|
|
16006
|
+
*/ _proto.clone = function clone() {
|
|
16007
|
+
return new Point(this.x, this.y);
|
|
16008
|
+
};
|
|
16009
|
+
/**
|
|
16010
|
+
* Copies `x` and `y` from the given point into this point
|
|
16011
|
+
* @param p - The point to copy from
|
|
16012
|
+
* @returns The point instance itself
|
|
16013
|
+
*/ _proto.copyFrom = function copyFrom(p) {
|
|
16014
|
+
this.set(p.x, p.y);
|
|
16015
|
+
return this;
|
|
16016
|
+
};
|
|
16017
|
+
/**
|
|
16018
|
+
* Copies this point's x and y into the given point (`p`).
|
|
16019
|
+
* @param p - The point to copy to. Can be any of type that is or extends `PointData`
|
|
16020
|
+
* @returns The point (`p`) with values updated
|
|
16021
|
+
*/ _proto.copyTo = function copyTo(p) {
|
|
16022
|
+
p.set(this.x, this.y);
|
|
16023
|
+
return p;
|
|
16024
|
+
};
|
|
16025
|
+
/**
|
|
16026
|
+
* Accepts another point (`p`) and returns `true` if the given point is equal to this point
|
|
16027
|
+
* @param p - The point to check
|
|
16028
|
+
* @returns Returns `true` if both `x` and `y` are equal
|
|
16029
|
+
*/ _proto.equals = function equals(p) {
|
|
16030
|
+
return p.x === this.x && p.y === this.y;
|
|
16031
|
+
};
|
|
16032
|
+
/**
|
|
16033
|
+
* Sets the point to a new `x` and `y` position.
|
|
16034
|
+
* If `y` is omitted, both `x` and `y` will be set to `x`.
|
|
16035
|
+
* @param {number} [x=0] - position of the point on the `x` axis
|
|
16036
|
+
* @param {number} [y=x] - position of the point on the `y` axis
|
|
16037
|
+
* @returns The point instance itself
|
|
16038
|
+
*/ _proto.set = function set(x, y) {
|
|
16039
|
+
if (x === void 0) x = 0;
|
|
16040
|
+
if (y === void 0) y = x;
|
|
16041
|
+
this.x = x;
|
|
16042
|
+
this.y = y;
|
|
16043
|
+
return this;
|
|
16044
|
+
};
|
|
16045
|
+
_create_class(Point, null, [
|
|
16046
|
+
{
|
|
16047
|
+
key: "shared",
|
|
16048
|
+
get: /**
|
|
16049
|
+
* A static Point object with `x` and `y` values of `0`. Can be used to avoid creating new objects multiple times.
|
|
16050
|
+
* @readonly
|
|
16051
|
+
*/ function get() {
|
|
16052
|
+
tempPoint.x = 0;
|
|
16053
|
+
tempPoint.y = 0;
|
|
16054
|
+
return tempPoint;
|
|
16055
|
+
}
|
|
16056
|
+
}
|
|
16057
|
+
]);
|
|
16058
|
+
return Point;
|
|
16059
|
+
}();
|
|
16060
|
+
var tempPoint = new Point();
|
|
16061
|
+
|
|
16062
|
+
// Based on:
|
|
16063
|
+
var closePointEps = 1e-4;
|
|
16064
|
+
var curveEps = 0.0001;
|
|
16065
|
+
/**
|
|
16066
|
+
* Buffers vertices to draw a square cap.
|
|
16067
|
+
*
|
|
16068
|
+
* @internal
|
|
16069
|
+
* @private
|
|
16070
|
+
* @param x - X-coord of end point
|
|
16071
|
+
* @param y - Y-coord of end point
|
|
16072
|
+
* @param nx - X-coord of line normal pointing inside
|
|
16073
|
+
* @param ny - Y-coord of line normal pointing inside
|
|
16074
|
+
* @param innerWeight - Weight of inner points
|
|
16075
|
+
* @param outerWeight - Weight of outer points
|
|
16076
|
+
* @param clockwise - Whether the cap is drawn clockwise
|
|
16077
|
+
* @param verts - vertex buffer
|
|
16078
|
+
* @returns - no. of vertices pushed
|
|
16079
|
+
*/ function square(x, y, nx, ny, innerWeight, outerWeight, clockwise, /* rotation for square (true at left end, false at right end) */ verts) {
|
|
16080
|
+
var ix = x - nx * innerWeight;
|
|
16081
|
+
var iy = y - ny * innerWeight;
|
|
16082
|
+
var ox = x + nx * outerWeight;
|
|
16083
|
+
var oy = y + ny * outerWeight;
|
|
16084
|
+
/* Rotate nx,ny for extension vector */ var exx;
|
|
16085
|
+
var eyy;
|
|
16086
|
+
if (clockwise) {
|
|
16087
|
+
exx = ny;
|
|
16088
|
+
eyy = -nx;
|
|
16089
|
+
} else {
|
|
16090
|
+
exx = -ny;
|
|
16091
|
+
eyy = nx;
|
|
16092
|
+
}
|
|
16093
|
+
/* [i|0]x,y extended at cap */ var eix = ix + exx;
|
|
16094
|
+
var eiy = iy + eyy;
|
|
16095
|
+
var eox = ox + exx;
|
|
16096
|
+
var eoy = oy + eyy;
|
|
16097
|
+
/* Square itself must be inserted clockwise*/ verts.push(eix, eiy);
|
|
16098
|
+
verts.push(eox, eoy);
|
|
16099
|
+
return 2;
|
|
16100
|
+
}
|
|
16101
|
+
/**
|
|
16102
|
+
* Buffers vertices to draw an arc at the line joint or cap.
|
|
16103
|
+
*
|
|
16104
|
+
* @internal
|
|
16105
|
+
* @private
|
|
16106
|
+
* @param cx - X-coord of center
|
|
16107
|
+
* @param cy - Y-coord of center
|
|
16108
|
+
* @param sx - X-coord of arc start
|
|
16109
|
+
* @param sy - Y-coord of arc start
|
|
16110
|
+
* @param ex - X-coord of arc end
|
|
16111
|
+
* @param ey - Y-coord of arc end
|
|
16112
|
+
* @param verts - buffer of vertices
|
|
16113
|
+
* @param clockwise - orientation of vertices
|
|
16114
|
+
* @returns - no. of vertices pushed
|
|
16115
|
+
*/ function round(cx, cy, sx, sy, ex, ey, verts, clockwise) {
|
|
16116
|
+
var cx2p0x = sx - cx;
|
|
16117
|
+
var cy2p0y = sy - cy;
|
|
16118
|
+
var angle0 = Math.atan2(cx2p0x, cy2p0y);
|
|
16119
|
+
var angle1 = Math.atan2(ex - cx, ey - cy);
|
|
16120
|
+
if (clockwise && angle0 < angle1) {
|
|
16121
|
+
angle0 += Math.PI * 2;
|
|
16122
|
+
} else if (!clockwise && angle0 > angle1) {
|
|
16123
|
+
angle1 += Math.PI * 2;
|
|
16124
|
+
}
|
|
16125
|
+
var startAngle = angle0;
|
|
16126
|
+
var angleDiff = angle1 - angle0;
|
|
16127
|
+
var absAngleDiff = Math.abs(angleDiff);
|
|
16128
|
+
var radius = Math.sqrt(cx2p0x * cx2p0x + cy2p0y * cy2p0y);
|
|
16129
|
+
var segCount = (15 * absAngleDiff * Math.sqrt(radius) / Math.PI >> 0) + 1;
|
|
16130
|
+
var angleInc = angleDiff / segCount;
|
|
16131
|
+
startAngle += angleInc;
|
|
16132
|
+
if (clockwise) {
|
|
16133
|
+
verts.push(cx, cy);
|
|
16134
|
+
verts.push(sx, sy);
|
|
16135
|
+
for(var i = 1, angle = startAngle; i < segCount; i++, angle += angleInc){
|
|
16136
|
+
verts.push(cx, cy);
|
|
16137
|
+
verts.push(cx + Math.sin(angle) * radius, cy + Math.cos(angle) * radius);
|
|
16138
|
+
}
|
|
16139
|
+
verts.push(cx, cy);
|
|
16140
|
+
verts.push(ex, ey);
|
|
16141
|
+
} else {
|
|
16142
|
+
verts.push(sx, sy);
|
|
16143
|
+
verts.push(cx, cy);
|
|
16144
|
+
for(var i1 = 1, angle2 = startAngle; i1 < segCount; i1++, angle2 += angleInc){
|
|
16145
|
+
verts.push(cx + Math.sin(angle2) * radius, cy + Math.cos(angle2) * radius);
|
|
16146
|
+
verts.push(cx, cy);
|
|
16147
|
+
}
|
|
16148
|
+
verts.push(ex, ey);
|
|
16149
|
+
verts.push(cx, cy);
|
|
16150
|
+
}
|
|
16151
|
+
return segCount * 2;
|
|
16152
|
+
}
|
|
16153
|
+
function getOrientationOfPoints(points) {
|
|
16154
|
+
var m = points.length;
|
|
16155
|
+
if (m < 6) {
|
|
16156
|
+
return 1;
|
|
16157
|
+
}
|
|
16158
|
+
var area = 0;
|
|
16159
|
+
for(var i = 0, x1 = points[m - 2], y1 = points[m - 1]; i < m; i += 2){
|
|
16160
|
+
var x2 = points[i];
|
|
16161
|
+
var y2 = points[i + 1];
|
|
16162
|
+
area += (x2 - x1) * (y2 + y1);
|
|
16163
|
+
x1 = x2;
|
|
16164
|
+
y1 = y2;
|
|
16165
|
+
}
|
|
16166
|
+
if (area < 0) {
|
|
16167
|
+
return -1;
|
|
16168
|
+
}
|
|
16169
|
+
return 1;
|
|
16170
|
+
}
|
|
16171
|
+
/**
|
|
16172
|
+
* Builds a line to draw using the polygon method.
|
|
16173
|
+
* @param points
|
|
16174
|
+
* @param lineStyle
|
|
16175
|
+
* @param flipAlignment
|
|
16176
|
+
* @param closed
|
|
16177
|
+
* @param vertices
|
|
16178
|
+
* @param _verticesStride
|
|
16179
|
+
* @param _verticesOffset
|
|
16180
|
+
* @param indices
|
|
16181
|
+
* @param _indicesOffset
|
|
16182
|
+
*/ function buildLine(points, lineStyle, flipAlignment, closed, // alignment:number,
|
|
16183
|
+
vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
|
|
16184
|
+
// const shape = graphicsData.shape as Polygon;
|
|
16185
|
+
// let points = graphicsData.points || shape.points.slice();
|
|
16186
|
+
var eps = closePointEps;
|
|
16187
|
+
if (points.length === 0) {
|
|
16188
|
+
return;
|
|
16189
|
+
}
|
|
16190
|
+
var style = lineStyle;
|
|
16191
|
+
var alignment = style.alignment;
|
|
16192
|
+
if (lineStyle.alignment !== 0.5) {
|
|
16193
|
+
// rotate the points!
|
|
16194
|
+
var orientation = getOrientationOfPoints(points);
|
|
16195
|
+
if (flipAlignment) {
|
|
16196
|
+
orientation *= -1;
|
|
16197
|
+
}
|
|
16198
|
+
alignment = (alignment - 0.5) * orientation + 0.5;
|
|
16199
|
+
}
|
|
16200
|
+
// get first and last point.. figure out the middle!
|
|
16201
|
+
var firstPoint = new Point(points[0], points[1]);
|
|
16202
|
+
var lastPoint = new Point(points[points.length - 2], points[points.length - 1]);
|
|
16203
|
+
var closedShape = closed;
|
|
16204
|
+
var closedPath = Math.abs(firstPoint.x - lastPoint.x) < eps && Math.abs(firstPoint.y - lastPoint.y) < eps;
|
|
16205
|
+
// if the first point is the last point - gonna have issues :)
|
|
16206
|
+
if (closedShape) {
|
|
16207
|
+
// need to clone as we are going to slightly modify the shape..
|
|
16208
|
+
points = points.slice();
|
|
16209
|
+
if (closedPath) {
|
|
16210
|
+
points.pop();
|
|
16211
|
+
points.pop();
|
|
16212
|
+
lastPoint.set(points[points.length - 2], points[points.length - 1]);
|
|
16213
|
+
}
|
|
16214
|
+
var midPointX = (firstPoint.x + lastPoint.x) * 0.5;
|
|
16215
|
+
var midPointY = (lastPoint.y + firstPoint.y) * 0.5;
|
|
16216
|
+
points.unshift(midPointX, midPointY);
|
|
16217
|
+
points.push(midPointX, midPointY);
|
|
16218
|
+
}
|
|
16219
|
+
var verts = vertices;
|
|
16220
|
+
var length = points.length / 2;
|
|
16221
|
+
var indexCount = points.length;
|
|
16222
|
+
var indexStart = verts.length / 2;
|
|
16223
|
+
// Max. inner and outer width
|
|
16224
|
+
var width = style.width / 2;
|
|
16225
|
+
var widthSquared = width * width;
|
|
16226
|
+
var miterLimitSquared = style.miterLimit * style.miterLimit;
|
|
16227
|
+
/* Line segments of interest where (x1,y1) forms the corner. */ var x0 = points[0];
|
|
16228
|
+
var y0 = points[1];
|
|
16229
|
+
var x1 = points[2];
|
|
16230
|
+
var y1 = points[3];
|
|
16231
|
+
var x2 = 0;
|
|
16232
|
+
var y2 = 0;
|
|
16233
|
+
/* perp[?](x|y) = the line normal with magnitude lineWidth. */ var perpX = -(y0 - y1);
|
|
16234
|
+
var perpY = x0 - x1;
|
|
16235
|
+
var perp1x = 0;
|
|
16236
|
+
var perp1y = 0;
|
|
16237
|
+
var dist = Math.sqrt(perpX * perpX + perpY * perpY);
|
|
16238
|
+
perpX /= dist;
|
|
16239
|
+
perpY /= dist;
|
|
16240
|
+
perpX *= width;
|
|
16241
|
+
perpY *= width;
|
|
16242
|
+
var ratio = alignment; // 0.5;
|
|
16243
|
+
var innerWeight = (1 - ratio) * 2;
|
|
16244
|
+
var outerWeight = ratio * 2;
|
|
16245
|
+
if (!closedShape) {
|
|
16246
|
+
if (style.cap === "round") {
|
|
16247
|
+
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;
|
|
16248
|
+
} else if (style.cap === "square") {
|
|
16249
|
+
indexCount += square(x0, y0, perpX, perpY, innerWeight, outerWeight, true, verts);
|
|
16250
|
+
}
|
|
16251
|
+
}
|
|
16252
|
+
// Push first point (below & above vertices)
|
|
16253
|
+
verts.push(x0 - perpX * innerWeight, y0 - perpY * innerWeight);
|
|
16254
|
+
verts.push(x0 + perpX * outerWeight, y0 + perpY * outerWeight);
|
|
16255
|
+
for(var i = 1; i < length - 1; ++i){
|
|
16256
|
+
x0 = points[(i - 1) * 2];
|
|
16257
|
+
y0 = points[(i - 1) * 2 + 1];
|
|
16258
|
+
x1 = points[i * 2];
|
|
16259
|
+
y1 = points[i * 2 + 1];
|
|
16260
|
+
x2 = points[(i + 1) * 2];
|
|
16261
|
+
y2 = points[(i + 1) * 2 + 1];
|
|
16262
|
+
perpX = -(y0 - y1);
|
|
16263
|
+
perpY = x0 - x1;
|
|
16264
|
+
dist = Math.sqrt(perpX * perpX + perpY * perpY);
|
|
16265
|
+
perpX /= dist;
|
|
16266
|
+
perpY /= dist;
|
|
16267
|
+
perpX *= width;
|
|
16268
|
+
perpY *= width;
|
|
16269
|
+
perp1x = -(y1 - y2);
|
|
16270
|
+
perp1y = x1 - x2;
|
|
16271
|
+
dist = Math.sqrt(perp1x * perp1x + perp1y * perp1y);
|
|
16272
|
+
perp1x /= dist;
|
|
16273
|
+
perp1y /= dist;
|
|
16274
|
+
perp1x *= width;
|
|
16275
|
+
perp1y *= width;
|
|
16276
|
+
/* d[x|y](0|1) = the component displacement between points p(0,1|1,2) */ var dx0 = x1 - x0;
|
|
16277
|
+
var dy0 = y0 - y1;
|
|
16278
|
+
var dx1 = x1 - x2;
|
|
16279
|
+
var dy1 = y2 - y1;
|
|
16280
|
+
/* +ve if internal angle < 90 degree, -ve if internal angle > 90 degree. */ var dot = dx0 * dx1 + dy0 * dy1;
|
|
16281
|
+
/* +ve if internal angle counterclockwise, -ve if internal angle clockwise. */ var cross = dy0 * dx1 - dy1 * dx0;
|
|
16282
|
+
var clockwise = cross < 0;
|
|
16283
|
+
/* Going nearly parallel? */ /* atan(0.001) ~= 0.001 rad ~= 0.057 degree */ if (Math.abs(cross) < 0.001 * Math.abs(dot)) {
|
|
16284
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
|
|
16285
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
|
|
16286
|
+
/* 180 degree corner? */ if (dot >= 0) {
|
|
16287
|
+
if (style.join === "round") {
|
|
16288
|
+
indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 4;
|
|
16289
|
+
} else {
|
|
16290
|
+
indexCount += 2;
|
|
16291
|
+
}
|
|
16292
|
+
verts.push(x1 - perp1x * outerWeight, y1 - perp1y * outerWeight);
|
|
16293
|
+
verts.push(x1 + perp1x * innerWeight, y1 + perp1y * innerWeight);
|
|
16294
|
+
}
|
|
16295
|
+
continue;
|
|
16296
|
+
}
|
|
16297
|
+
/* 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);
|
|
16298
|
+
var c2 = (-perp1x + x2) * (-perp1y + y1) - (-perp1x + x1) * (-perp1y + y2);
|
|
16299
|
+
var px = (dx0 * c2 - dx1 * c1) / cross;
|
|
16300
|
+
var py = (dy1 * c1 - dy0 * c2) / cross;
|
|
16301
|
+
var pDist = (px - x1) * (px - x1) + (py - y1) * (py - y1);
|
|
16302
|
+
/* Inner miter point */ var imx = x1 + (px - x1) * innerWeight;
|
|
16303
|
+
var imy = y1 + (py - y1) * innerWeight;
|
|
16304
|
+
/* Outer miter point */ var omx = x1 - (px - x1) * outerWeight;
|
|
16305
|
+
var omy = y1 - (py - y1) * outerWeight;
|
|
16306
|
+
/* Is the inside miter point too far away, creating a spike? */ var smallerInsideSegmentSq = Math.min(dx0 * dx0 + dy0 * dy0, dx1 * dx1 + dy1 * dy1);
|
|
16307
|
+
var insideWeight = clockwise ? innerWeight : outerWeight;
|
|
16308
|
+
var smallerInsideDiagonalSq = smallerInsideSegmentSq + insideWeight * insideWeight * widthSquared;
|
|
16309
|
+
var insideMiterOk = pDist <= smallerInsideDiagonalSq;
|
|
16310
|
+
if (insideMiterOk) {
|
|
16311
|
+
if (style.join === "bevel" || pDist / widthSquared > miterLimitSquared) {
|
|
16312
|
+
if (clockwise) /* rotating at inner angle */ {
|
|
16313
|
+
verts.push(imx, imy); // inner miter point
|
|
16314
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
|
|
16315
|
+
verts.push(imx, imy); // inner miter point
|
|
16316
|
+
verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight); // second segment's outer vertex
|
|
16317
|
+
} else /* rotating at outer angle */ {
|
|
16318
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight); // first segment's inner vertex
|
|
16319
|
+
verts.push(omx, omy); // outer miter point
|
|
16320
|
+
verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight); // second segment's outer vertex
|
|
16321
|
+
verts.push(omx, omy); // outer miter point
|
|
16322
|
+
}
|
|
16323
|
+
indexCount += 2;
|
|
16324
|
+
} else if (style.join === "round") {
|
|
16325
|
+
if (clockwise) /* arc is outside */ {
|
|
16326
|
+
verts.push(imx, imy);
|
|
16327
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
|
|
16328
|
+
indexCount += round(x1, y1, x1 + perpX * outerWeight, y1 + perpY * outerWeight, x1 + perp1x * outerWeight, y1 + perp1y * outerWeight, verts, true) + 4;
|
|
16329
|
+
verts.push(imx, imy);
|
|
16330
|
+
verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight);
|
|
16331
|
+
} else /* arc is inside */ {
|
|
16332
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
|
|
16333
|
+
verts.push(omx, omy);
|
|
16334
|
+
indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 4;
|
|
16335
|
+
verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight);
|
|
16336
|
+
verts.push(omx, omy);
|
|
16337
|
+
}
|
|
16338
|
+
} else {
|
|
16339
|
+
verts.push(imx, imy);
|
|
16340
|
+
verts.push(omx, omy);
|
|
16341
|
+
}
|
|
16342
|
+
} else {
|
|
16343
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight); // first segment's inner vertex
|
|
16344
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
|
|
16345
|
+
if (style.join === "round") {
|
|
16346
|
+
if (clockwise) /* arc is outside */ {
|
|
16347
|
+
indexCount += round(x1, y1, x1 + perpX * outerWeight, y1 + perpY * outerWeight, x1 + perp1x * outerWeight, y1 + perp1y * outerWeight, verts, true) + 2;
|
|
16348
|
+
} else /* arc is inside */ {
|
|
16349
|
+
indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 2;
|
|
16350
|
+
}
|
|
16351
|
+
} else if (style.join === "miter" && pDist / widthSquared <= miterLimitSquared) {
|
|
16352
|
+
if (clockwise) {
|
|
16353
|
+
verts.push(omx, omy); // inner miter point
|
|
16354
|
+
verts.push(omx, omy); // inner miter point
|
|
16355
|
+
} else {
|
|
16356
|
+
verts.push(imx, imy); // outer miter point
|
|
16357
|
+
verts.push(imx, imy); // outer miter point
|
|
16358
|
+
}
|
|
16359
|
+
indexCount += 2;
|
|
16360
|
+
}
|
|
16361
|
+
verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight); // second segment's inner vertex
|
|
16362
|
+
verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight); // second segment's outer vertex
|
|
16363
|
+
indexCount += 2;
|
|
16364
|
+
}
|
|
16365
|
+
}
|
|
16366
|
+
x0 = points[(length - 2) * 2];
|
|
16367
|
+
y0 = points[(length - 2) * 2 + 1];
|
|
16368
|
+
x1 = points[(length - 1) * 2];
|
|
16369
|
+
y1 = points[(length - 1) * 2 + 1];
|
|
16370
|
+
perpX = -(y0 - y1);
|
|
16371
|
+
perpY = x0 - x1;
|
|
16372
|
+
dist = Math.sqrt(perpX * perpX + perpY * perpY);
|
|
16373
|
+
perpX /= dist;
|
|
16374
|
+
perpY /= dist;
|
|
16375
|
+
perpX *= width;
|
|
16376
|
+
perpY *= width;
|
|
16377
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
|
|
16378
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
|
|
16379
|
+
if (!closedShape) {
|
|
16380
|
+
if (style.cap === "round") {
|
|
16381
|
+
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;
|
|
16382
|
+
} else if (style.cap === "square") {
|
|
16383
|
+
indexCount += square(x1, y1, perpX, perpY, innerWeight, outerWeight, false, verts);
|
|
16384
|
+
}
|
|
16385
|
+
}
|
|
16386
|
+
// const indices = graphicsGeometry.indices;
|
|
16387
|
+
var eps2 = curveEps * curveEps;
|
|
16388
|
+
// indices.push(indexStart);
|
|
16389
|
+
for(var i1 = indexStart; i1 < indexCount + indexStart - 2; ++i1){
|
|
16390
|
+
x0 = verts[i1 * 2];
|
|
16391
|
+
y0 = verts[i1 * 2 + 1];
|
|
16392
|
+
x1 = verts[(i1 + 1) * 2];
|
|
16393
|
+
y1 = verts[(i1 + 1) * 2 + 1];
|
|
16394
|
+
x2 = verts[(i1 + 2) * 2];
|
|
16395
|
+
y2 = verts[(i1 + 2) * 2 + 1];
|
|
16396
|
+
/* Skip zero area triangles */ if (Math.abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) < eps2) {
|
|
16397
|
+
continue;
|
|
16398
|
+
}
|
|
16399
|
+
indices.push(i1, i1 + 1, i1 + 2);
|
|
16400
|
+
}
|
|
16401
|
+
}
|
|
16402
|
+
|
|
15867
16403
|
exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
15868
16404
|
_inherits(ShapeComponent, MeshComponent);
|
|
15869
16405
|
function ShapeComponent(engine) {
|
|
15870
16406
|
var _this;
|
|
15871
16407
|
_this = MeshComponent.call(this, engine) || this;
|
|
15872
|
-
_this.
|
|
16408
|
+
_this.isStroke = false;
|
|
16409
|
+
_this.graphicsPath = new GraphicsPath();
|
|
15873
16410
|
_this.curveValues = [];
|
|
15874
|
-
_this.
|
|
16411
|
+
_this.shapeDirty = true;
|
|
15875
16412
|
_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";
|
|
15876
16413
|
_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";
|
|
15877
16414
|
if (!_this.geometry) {
|
|
@@ -15919,6 +16456,13 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15919
16456
|
_this.material.depthTest = true;
|
|
15920
16457
|
_this.material.blending = true;
|
|
15921
16458
|
}
|
|
16459
|
+
_this.strokeAttributes = {
|
|
16460
|
+
width: 1,
|
|
16461
|
+
alignment: 0.5,
|
|
16462
|
+
cap: "butt",
|
|
16463
|
+
join: "miter",
|
|
16464
|
+
miterLimit: 10
|
|
16465
|
+
};
|
|
15922
16466
|
return _this;
|
|
15923
16467
|
}
|
|
15924
16468
|
var _proto = ShapeComponent.prototype;
|
|
@@ -15926,10 +16470,10 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15926
16470
|
this.item.getHitTestParams = this.getHitTestParams;
|
|
15927
16471
|
};
|
|
15928
16472
|
_proto.onUpdate = function onUpdate(dt) {
|
|
15929
|
-
if (this.
|
|
16473
|
+
if (this.shapeDirty) {
|
|
15930
16474
|
this.buildPath(this.data);
|
|
15931
|
-
this.buildGeometryFromPath(this.
|
|
15932
|
-
this.
|
|
16475
|
+
this.buildGeometryFromPath(this.graphicsPath.shapePath);
|
|
16476
|
+
this.shapeDirty = false;
|
|
15933
16477
|
}
|
|
15934
16478
|
};
|
|
15935
16479
|
_proto.buildGeometryFromPath = function buildGeometryFromPath(shapePath) {
|
|
@@ -15944,7 +16488,13 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15944
16488
|
var indexOffset = indices.length;
|
|
15945
16489
|
var vertOffset = vertices.length / 2;
|
|
15946
16490
|
shape.build(points);
|
|
15947
|
-
|
|
16491
|
+
if (!this.isStroke) {
|
|
16492
|
+
shape.triangulate(points, vertices, vertOffset, indices, indexOffset);
|
|
16493
|
+
} else {
|
|
16494
|
+
var close = true;
|
|
16495
|
+
var lineStyle = this.strokeAttributes;
|
|
16496
|
+
buildLine(points, lineStyle, false, close, vertices, 2, vertOffset, indices);
|
|
16497
|
+
}
|
|
15948
16498
|
}
|
|
15949
16499
|
var vertexCount = vertices.length / 2;
|
|
15950
16500
|
// get the current attribute and index arrays from the geometry, avoiding re-creation
|
|
@@ -15957,7 +16507,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15957
16507
|
if (!uvArray || uvArray.length < vertexCount * 2) {
|
|
15958
16508
|
uvArray = new Float32Array(vertexCount * 2);
|
|
15959
16509
|
}
|
|
15960
|
-
if (!indexArray) {
|
|
16510
|
+
if (!indexArray || indexArray.length < indices.length) {
|
|
15961
16511
|
indexArray = new Uint16Array(indices.length);
|
|
15962
16512
|
}
|
|
15963
16513
|
// set position and uv attribute array
|
|
@@ -15980,7 +16530,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15980
16530
|
this.geometry.setDrawCount(indices.length);
|
|
15981
16531
|
};
|
|
15982
16532
|
_proto.buildPath = function buildPath(data) {
|
|
15983
|
-
this.
|
|
16533
|
+
this.graphicsPath.clear();
|
|
15984
16534
|
var shapeData = data;
|
|
15985
16535
|
switch(shapeData.type){
|
|
15986
16536
|
case ShapePrimitiveType.Custom:
|
|
@@ -15989,9 +16539,9 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15989
16539
|
var points = customData.points;
|
|
15990
16540
|
var easingIns = customData.easingIns;
|
|
15991
16541
|
var easingOuts = customData.easingOuts;
|
|
15992
|
-
this.curveValues = [];
|
|
15993
16542
|
for(var _iterator = _create_for_of_iterator_helper_loose(customData.shapes), _step; !(_step = _iterator()).done;){
|
|
15994
16543
|
var shape = _step.value;
|
|
16544
|
+
this.curveValues = [];
|
|
15995
16545
|
this.setFillColor(shape.fill);
|
|
15996
16546
|
var indices = shape.indexes;
|
|
15997
16547
|
for(var i = 1; i < indices.length; i++){
|
|
@@ -16009,42 +16559,42 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
16009
16559
|
controlPoint1: easingOuts[indices[indices.length - 1].easingOut],
|
|
16010
16560
|
controlPoint2: easingIns[indices[0].easingIn]
|
|
16011
16561
|
});
|
|
16012
|
-
|
|
16013
|
-
|
|
16014
|
-
|
|
16015
|
-
|
|
16016
|
-
|
|
16017
|
-
|
|
16018
|
-
|
|
16019
|
-
|
|
16562
|
+
this.graphicsPath.moveTo(this.curveValues[this.curveValues.length - 1].point.x, this.curveValues[this.curveValues.length - 1].point.y);
|
|
16563
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(this.curveValues), _step1; !(_step1 = _iterator1()).done;){
|
|
16564
|
+
var curveValue = _step1.value;
|
|
16565
|
+
var point = curveValue.point;
|
|
16566
|
+
var control1 = curveValue.controlPoint1;
|
|
16567
|
+
var control2 = curveValue.controlPoint2;
|
|
16568
|
+
this.graphicsPath.bezierCurveTo(control1.x, control1.y, control2.x, control2.y, point.x, point.y, 1);
|
|
16569
|
+
}
|
|
16020
16570
|
}
|
|
16021
16571
|
break;
|
|
16022
16572
|
}
|
|
16023
16573
|
case ShapePrimitiveType.Ellipse:
|
|
16024
16574
|
{
|
|
16025
16575
|
var ellipseData = shapeData;
|
|
16026
|
-
this.
|
|
16576
|
+
this.graphicsPath.ellipse(0, 0, ellipseData.xRadius, ellipseData.yRadius);
|
|
16027
16577
|
this.setFillColor(ellipseData.fill);
|
|
16028
16578
|
break;
|
|
16029
16579
|
}
|
|
16030
16580
|
case ShapePrimitiveType.Rectangle:
|
|
16031
16581
|
{
|
|
16032
16582
|
var rectangleData = shapeData;
|
|
16033
|
-
this.
|
|
16583
|
+
this.graphicsPath.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height);
|
|
16034
16584
|
this.setFillColor(rectangleData.fill);
|
|
16035
16585
|
break;
|
|
16036
16586
|
}
|
|
16037
16587
|
case ShapePrimitiveType.Star:
|
|
16038
16588
|
{
|
|
16039
16589
|
var starData = shapeData;
|
|
16040
|
-
this.
|
|
16590
|
+
this.graphicsPath.polyStar(starData.pointCount, starData.outerRadius, starData.innerRadius, starData.outerRoundness, starData.innerRoundness, StarType.Star);
|
|
16041
16591
|
this.setFillColor(starData.fill);
|
|
16042
16592
|
break;
|
|
16043
16593
|
}
|
|
16044
16594
|
case ShapePrimitiveType.Polygon:
|
|
16045
16595
|
{
|
|
16046
16596
|
var polygonData = shapeData;
|
|
16047
|
-
this.
|
|
16597
|
+
this.graphicsPath.polyStar(polygonData.pointCount, polygonData.radius, polygonData.radius, polygonData.roundness, polygonData.roundness, StarType.Polygon);
|
|
16048
16598
|
this.setFillColor(polygonData.fill);
|
|
16049
16599
|
break;
|
|
16050
16600
|
}
|
|
@@ -16059,6 +16609,12 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
16059
16609
|
_proto.fromData = function fromData(data) {
|
|
16060
16610
|
MeshComponent.prototype.fromData.call(this, data);
|
|
16061
16611
|
this.data = data;
|
|
16612
|
+
this.shapeDirty = true;
|
|
16613
|
+
var strokeParam = data.stroke;
|
|
16614
|
+
if (strokeParam) {
|
|
16615
|
+
this.isStroke = true;
|
|
16616
|
+
this.strokeAttributes.width = strokeParam.width;
|
|
16617
|
+
}
|
|
16062
16618
|
var material = this.material;
|
|
16063
16619
|
//@ts-expect-error // TODO 新版蒙版上线后重构
|
|
16064
16620
|
material.stencilRef = data.renderer.mask !== undefined ? [
|
|
@@ -16068,6 +16624,15 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
16068
16624
|
//@ts-expect-error // TODO 新版蒙版上线后重构
|
|
16069
16625
|
setMaskMode(material, data.renderer.maskMode);
|
|
16070
16626
|
};
|
|
16627
|
+
_create_class(ShapeComponent, [
|
|
16628
|
+
{
|
|
16629
|
+
key: "path",
|
|
16630
|
+
get: function get() {
|
|
16631
|
+
this.shapeDirty = true;
|
|
16632
|
+
return this.data;
|
|
16633
|
+
}
|
|
16634
|
+
}
|
|
16635
|
+
]);
|
|
16071
16636
|
return ShapeComponent;
|
|
16072
16637
|
}(MeshComponent);
|
|
16073
16638
|
exports.ShapeComponent = __decorate([
|
|
@@ -16282,7 +16847,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
16282
16847
|
var vy = 0;
|
|
16283
16848
|
var ts = performance.now();
|
|
16284
16849
|
if (!_this.target) {
|
|
16285
|
-
logger.
|
|
16850
|
+
logger.warn("Trigger TouchEvent after EventSystem is disposed.");
|
|
16286
16851
|
return {
|
|
16287
16852
|
x: x,
|
|
16288
16853
|
y: y,
|
|
@@ -18755,10 +19320,19 @@ var TEMPLATE_USE_OFFSCREEN_CANVAS = "offscreen_canvas";
|
|
|
18755
19320
|
// 后处理配置相关
|
|
18756
19321
|
var POST_PROCESS_SETTINGS = "post_process_settings";
|
|
18757
19322
|
var config = {};
|
|
18758
|
-
|
|
19323
|
+
/**
|
|
19324
|
+
* 获取全局配置项
|
|
19325
|
+
* @param name
|
|
19326
|
+
* @returns
|
|
19327
|
+
*/ function getConfig(name) {
|
|
18759
19328
|
return config[name];
|
|
18760
19329
|
}
|
|
18761
|
-
|
|
19330
|
+
/**
|
|
19331
|
+
* 设置全局配置项
|
|
19332
|
+
* @param name
|
|
19333
|
+
* @param value
|
|
19334
|
+
* @returns
|
|
19335
|
+
*/ function setConfig(name, value) {
|
|
18762
19336
|
return config[name] = value;
|
|
18763
19337
|
}
|
|
18764
19338
|
|
|
@@ -23105,88 +23679,81 @@ var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
23105
23679
|
return PropertyClipPlayable;
|
|
23106
23680
|
}(Playable);
|
|
23107
23681
|
|
|
23108
|
-
var
|
|
23109
|
-
_inherits(
|
|
23110
|
-
function
|
|
23682
|
+
var PropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
|
|
23683
|
+
_inherits(PropertyMixerPlayable, TrackMixerPlayable);
|
|
23684
|
+
function PropertyMixerPlayable() {
|
|
23111
23685
|
var _this;
|
|
23112
23686
|
_this = TrackMixerPlayable.apply(this, arguments) || this;
|
|
23113
23687
|
_this.propertyName = "";
|
|
23114
23688
|
return _this;
|
|
23115
23689
|
}
|
|
23116
|
-
var _proto =
|
|
23690
|
+
var _proto = PropertyMixerPlayable.prototype;
|
|
23117
23691
|
_proto.evaluate = function evaluate(context) {
|
|
23118
23692
|
var boundObject = context.output.getUserData();
|
|
23119
23693
|
if (!boundObject) {
|
|
23120
23694
|
return;
|
|
23121
23695
|
}
|
|
23122
23696
|
var hasInput = false;
|
|
23123
|
-
|
|
23124
|
-
if (
|
|
23697
|
+
this.propertyValue = boundObject[this.propertyName];
|
|
23698
|
+
if (this.propertyValue === undefined || this.propertyValue === null) {
|
|
23125
23699
|
return;
|
|
23126
23700
|
}
|
|
23127
|
-
|
|
23701
|
+
this.resetPropertyValue();
|
|
23128
23702
|
// evaluate the curve
|
|
23129
23703
|
for(var i = 0; i < this.clipPlayables.length; i++){
|
|
23130
23704
|
var weight = this.getClipWeight(i);
|
|
23131
23705
|
if (weight > 0) {
|
|
23132
23706
|
var propertyClipPlayable = this.getClipPlayable(i);
|
|
23133
23707
|
if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
|
|
23134
|
-
console.error("
|
|
23708
|
+
console.error("PropertyTrack added non-PropertyPlayableAsset");
|
|
23135
23709
|
continue;
|
|
23136
23710
|
}
|
|
23137
23711
|
var curveValue = propertyClipPlayable.value;
|
|
23138
|
-
|
|
23139
|
-
value.g += curveValue.g * weight;
|
|
23140
|
-
value.b += curveValue.b * weight;
|
|
23141
|
-
value.a += curveValue.a * weight;
|
|
23712
|
+
this.addWeightedValue(curveValue, weight);
|
|
23142
23713
|
hasInput = true;
|
|
23143
23714
|
}
|
|
23144
23715
|
}
|
|
23145
23716
|
// set value
|
|
23146
23717
|
if (hasInput) {
|
|
23147
|
-
boundObject[this.propertyName] =
|
|
23718
|
+
boundObject[this.propertyName] = this.propertyValue;
|
|
23148
23719
|
}
|
|
23149
23720
|
};
|
|
23150
|
-
return
|
|
23721
|
+
return PropertyMixerPlayable;
|
|
23151
23722
|
}(TrackMixerPlayable);
|
|
23152
23723
|
|
|
23153
|
-
var
|
|
23154
|
-
_inherits(
|
|
23724
|
+
var ColorPropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
|
|
23725
|
+
_inherits(ColorPropertyMixerPlayable, PropertyMixerPlayable);
|
|
23726
|
+
function ColorPropertyMixerPlayable() {
|
|
23727
|
+
return PropertyMixerPlayable.apply(this, arguments);
|
|
23728
|
+
}
|
|
23729
|
+
var _proto = ColorPropertyMixerPlayable.prototype;
|
|
23730
|
+
_proto.resetPropertyValue = function resetPropertyValue() {
|
|
23731
|
+
this.propertyValue.setZero();
|
|
23732
|
+
};
|
|
23733
|
+
_proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
|
|
23734
|
+
var result = this.propertyValue;
|
|
23735
|
+
result.r += curveValue.r * weight;
|
|
23736
|
+
result.g += curveValue.g * weight;
|
|
23737
|
+
result.b += curveValue.b * weight;
|
|
23738
|
+
result.a += curveValue.a * weight;
|
|
23739
|
+
};
|
|
23740
|
+
return ColorPropertyMixerPlayable;
|
|
23741
|
+
}(PropertyMixerPlayable);
|
|
23742
|
+
|
|
23743
|
+
var FloatPropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
|
|
23744
|
+
_inherits(FloatPropertyMixerPlayable, PropertyMixerPlayable);
|
|
23155
23745
|
function FloatPropertyMixerPlayable() {
|
|
23156
|
-
|
|
23157
|
-
_this = TrackMixerPlayable.apply(this, arguments) || this;
|
|
23158
|
-
_this.propertyName = "";
|
|
23159
|
-
return _this;
|
|
23746
|
+
return PropertyMixerPlayable.apply(this, arguments);
|
|
23160
23747
|
}
|
|
23161
23748
|
var _proto = FloatPropertyMixerPlayable.prototype;
|
|
23162
|
-
_proto.
|
|
23163
|
-
|
|
23164
|
-
|
|
23165
|
-
|
|
23166
|
-
|
|
23167
|
-
var hasInput = false;
|
|
23168
|
-
var value = 0;
|
|
23169
|
-
// evaluate the curve
|
|
23170
|
-
for(var i = 0; i < this.clipPlayables.length; i++){
|
|
23171
|
-
var weight = this.getClipWeight(i);
|
|
23172
|
-
if (weight > 0) {
|
|
23173
|
-
var propertyClipPlayable = this.getClipPlayable(i);
|
|
23174
|
-
if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
|
|
23175
|
-
console.error("FloatPropertyTrack added non-FloatPropertyPlayableAsset");
|
|
23176
|
-
continue;
|
|
23177
|
-
}
|
|
23178
|
-
var curveValue = propertyClipPlayable.value;
|
|
23179
|
-
value += curveValue * weight;
|
|
23180
|
-
hasInput = true;
|
|
23181
|
-
}
|
|
23182
|
-
}
|
|
23183
|
-
// set value
|
|
23184
|
-
if (hasInput) {
|
|
23185
|
-
boundObject[this.propertyName] = value;
|
|
23186
|
-
}
|
|
23749
|
+
_proto.resetPropertyValue = function resetPropertyValue() {
|
|
23750
|
+
this.propertyValue = 0;
|
|
23751
|
+
};
|
|
23752
|
+
_proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
|
|
23753
|
+
this.propertyValue += curveValue * weight;
|
|
23187
23754
|
};
|
|
23188
23755
|
return FloatPropertyMixerPlayable;
|
|
23189
|
-
}(
|
|
23756
|
+
}(PropertyMixerPlayable);
|
|
23190
23757
|
|
|
23191
23758
|
var ParticleMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
|
|
23192
23759
|
_inherits(ParticleMixerPlayable, TrackMixerPlayable);
|
|
@@ -23930,50 +24497,40 @@ var TransformMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
|
|
|
23930
24497
|
return TransformMixerPlayable;
|
|
23931
24498
|
}(TrackMixerPlayable);
|
|
23932
24499
|
|
|
23933
|
-
var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(
|
|
23934
|
-
_inherits(Vector4PropertyMixerPlayable,
|
|
24500
|
+
var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
|
|
24501
|
+
_inherits(Vector4PropertyMixerPlayable, PropertyMixerPlayable);
|
|
23935
24502
|
function Vector4PropertyMixerPlayable() {
|
|
23936
|
-
|
|
23937
|
-
_this = TrackMixerPlayable.apply(this, arguments) || this;
|
|
23938
|
-
_this.propertyName = "";
|
|
23939
|
-
return _this;
|
|
24503
|
+
return PropertyMixerPlayable.apply(this, arguments);
|
|
23940
24504
|
}
|
|
23941
24505
|
var _proto = Vector4PropertyMixerPlayable.prototype;
|
|
23942
|
-
_proto.
|
|
23943
|
-
|
|
23944
|
-
|
|
23945
|
-
|
|
23946
|
-
|
|
23947
|
-
|
|
23948
|
-
|
|
23949
|
-
|
|
23950
|
-
|
|
23951
|
-
}
|
|
23952
|
-
value.setZero();
|
|
23953
|
-
// evaluate the curve
|
|
23954
|
-
for(var i = 0; i < this.clipPlayables.length; i++){
|
|
23955
|
-
var weight = this.getClipWeight(i);
|
|
23956
|
-
if (weight > 0) {
|
|
23957
|
-
var propertyClipPlayable = this.getClipPlayable(i);
|
|
23958
|
-
if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
|
|
23959
|
-
console.error("Vector4PropertyTrack added non-Vector4PropertyPlayableAsset");
|
|
23960
|
-
continue;
|
|
23961
|
-
}
|
|
23962
|
-
var curveValue = propertyClipPlayable.value;
|
|
23963
|
-
value.x += curveValue.x * weight;
|
|
23964
|
-
value.y += curveValue.y * weight;
|
|
23965
|
-
value.z += curveValue.z * weight;
|
|
23966
|
-
value.w += curveValue.w * weight;
|
|
23967
|
-
hasInput = true;
|
|
23968
|
-
}
|
|
23969
|
-
}
|
|
23970
|
-
// set value
|
|
23971
|
-
if (hasInput) {
|
|
23972
|
-
boundObject[this.propertyName] = value;
|
|
23973
|
-
}
|
|
24506
|
+
_proto.resetPropertyValue = function resetPropertyValue() {
|
|
24507
|
+
this.propertyValue.setZero();
|
|
24508
|
+
};
|
|
24509
|
+
_proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
|
|
24510
|
+
var result = this.propertyValue;
|
|
24511
|
+
result.x += curveValue.x * weight;
|
|
24512
|
+
result.y += curveValue.y * weight;
|
|
24513
|
+
result.z += curveValue.z * weight;
|
|
24514
|
+
result.w += curveValue.w * weight;
|
|
23974
24515
|
};
|
|
23975
24516
|
return Vector4PropertyMixerPlayable;
|
|
23976
|
-
}(
|
|
24517
|
+
}(PropertyMixerPlayable);
|
|
24518
|
+
var Vector2PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
|
|
24519
|
+
_inherits(Vector2PropertyMixerPlayable, PropertyMixerPlayable);
|
|
24520
|
+
function Vector2PropertyMixerPlayable() {
|
|
24521
|
+
return PropertyMixerPlayable.apply(this, arguments);
|
|
24522
|
+
}
|
|
24523
|
+
var _proto = Vector2PropertyMixerPlayable.prototype;
|
|
24524
|
+
_proto.resetPropertyValue = function resetPropertyValue() {
|
|
24525
|
+
this.propertyValue.setZero();
|
|
24526
|
+
};
|
|
24527
|
+
_proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
|
|
24528
|
+
var result = this.propertyValue;
|
|
24529
|
+
result.x += curveValue.x * weight;
|
|
24530
|
+
result.y += curveValue.y * weight;
|
|
24531
|
+
};
|
|
24532
|
+
return Vector2PropertyMixerPlayable;
|
|
24533
|
+
}(PropertyMixerPlayable);
|
|
23977
24534
|
|
|
23978
24535
|
/**
|
|
23979
24536
|
* @since 2.0.0
|
|
@@ -24354,6 +24911,26 @@ exports.Vector4PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
|
|
|
24354
24911
|
exports.Vector4PropertyTrack = __decorate([
|
|
24355
24912
|
effectsClass(DataType.Vector4PropertyTrack)
|
|
24356
24913
|
], exports.Vector4PropertyTrack);
|
|
24914
|
+
exports.Vector2PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
|
|
24915
|
+
_inherits(Vector2PropertyTrack, PropertyTrack);
|
|
24916
|
+
function Vector2PropertyTrack() {
|
|
24917
|
+
return PropertyTrack.apply(this, arguments);
|
|
24918
|
+
}
|
|
24919
|
+
var _proto = Vector2PropertyTrack.prototype;
|
|
24920
|
+
_proto.createTrackMixer = function createTrackMixer(graph) {
|
|
24921
|
+
var mixer = new Vector2PropertyMixerPlayable(graph);
|
|
24922
|
+
var propertyNames = this.propertyNames;
|
|
24923
|
+
if (propertyNames.length > 0) {
|
|
24924
|
+
var propertyName = propertyNames[propertyNames.length - 1];
|
|
24925
|
+
mixer.propertyName = propertyName;
|
|
24926
|
+
}
|
|
24927
|
+
return mixer;
|
|
24928
|
+
};
|
|
24929
|
+
return Vector2PropertyTrack;
|
|
24930
|
+
}(PropertyTrack);
|
|
24931
|
+
exports.Vector2PropertyTrack = __decorate([
|
|
24932
|
+
effectsClass("Vector2PropertyTrack")
|
|
24933
|
+
], exports.Vector2PropertyTrack);
|
|
24357
24934
|
|
|
24358
24935
|
exports.ColorPropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
|
|
24359
24936
|
_inherits(ColorPropertyTrack, PropertyTrack);
|
|
@@ -24620,8 +25197,28 @@ __decorate([
|
|
|
24620
25197
|
serialize()
|
|
24621
25198
|
], exports.Vector4PropertyPlayableAsset.prototype, "curveData", void 0);
|
|
24622
25199
|
exports.Vector4PropertyPlayableAsset = __decorate([
|
|
24623
|
-
effectsClass(
|
|
25200
|
+
effectsClass(DataType.Vector4PropertyPlayableAsset)
|
|
24624
25201
|
], exports.Vector4PropertyPlayableAsset);
|
|
25202
|
+
exports.Vector2PropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
|
|
25203
|
+
_inherits(Vector2PropertyPlayableAsset, PlayableAsset);
|
|
25204
|
+
function Vector2PropertyPlayableAsset() {
|
|
25205
|
+
return PlayableAsset.apply(this, arguments);
|
|
25206
|
+
}
|
|
25207
|
+
var _proto = Vector2PropertyPlayableAsset.prototype;
|
|
25208
|
+
_proto.createPlayable = function createPlayable(graph) {
|
|
25209
|
+
var clipPlayable = new PropertyClipPlayable(graph);
|
|
25210
|
+
clipPlayable.curve = createValueGetter(this.curveData);
|
|
25211
|
+
clipPlayable.value = clipPlayable.curve.getValue(0);
|
|
25212
|
+
return clipPlayable;
|
|
25213
|
+
};
|
|
25214
|
+
return Vector2PropertyPlayableAsset;
|
|
25215
|
+
}(PlayableAsset);
|
|
25216
|
+
__decorate([
|
|
25217
|
+
serialize()
|
|
25218
|
+
], exports.Vector2PropertyPlayableAsset.prototype, "curveData", void 0);
|
|
25219
|
+
exports.Vector2PropertyPlayableAsset = __decorate([
|
|
25220
|
+
effectsClass(DataType.Vector2PropertyPlayableAsset)
|
|
25221
|
+
], exports.Vector2PropertyPlayableAsset);
|
|
24625
25222
|
|
|
24626
25223
|
exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset) {
|
|
24627
25224
|
_inherits(ObjectBindingTrack, TrackAsset);
|
|
@@ -26004,7 +26601,7 @@ function getStandardInteractContent(ui) {
|
|
|
26004
26601
|
}
|
|
26005
26602
|
});
|
|
26006
26603
|
});
|
|
26007
|
-
json.version = "
|
|
26604
|
+
json.version = JSONSceneVersion["2_1"];
|
|
26008
26605
|
return json;
|
|
26009
26606
|
}
|
|
26010
26607
|
/**
|
|
@@ -26024,6 +26621,18 @@ function getStandardInteractContent(ui) {
|
|
|
26024
26621
|
});
|
|
26025
26622
|
return json;
|
|
26026
26623
|
}
|
|
26624
|
+
/**
|
|
26625
|
+
* 3.1 版本数据适配
|
|
26626
|
+
* - 富文本插件名称的适配
|
|
26627
|
+
*/ function version31Migration(json) {
|
|
26628
|
+
var _json_plugins;
|
|
26629
|
+
(_json_plugins = json.plugins) == null ? void 0 : _json_plugins.forEach(function(plugin, index) {
|
|
26630
|
+
if (plugin === "richtext") {
|
|
26631
|
+
json.plugins[index] = "rich-text";
|
|
26632
|
+
}
|
|
26633
|
+
});
|
|
26634
|
+
return json;
|
|
26635
|
+
}
|
|
26027
26636
|
/**
|
|
26028
26637
|
* 3.0 以下版本数据适配(runtime 2.0及以上版本支持)
|
|
26029
26638
|
*/ function version30Migration(json) {
|
|
@@ -26331,7 +26940,7 @@ function getStandardInteractContent(ui) {
|
|
|
26331
26940
|
break;
|
|
26332
26941
|
}
|
|
26333
26942
|
}
|
|
26334
|
-
result.version = "
|
|
26943
|
+
result.version = JSONSceneVersion["3_0"];
|
|
26335
26944
|
return result;
|
|
26336
26945
|
}
|
|
26337
26946
|
/**
|
|
@@ -26851,6 +27460,8 @@ function getStandardJSON(json) {
|
|
|
26851
27460
|
}
|
|
26852
27461
|
// 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
|
|
26853
27462
|
version22Migration(json);
|
|
27463
|
+
// 修正老版本数据中,富文本插件名称的问题
|
|
27464
|
+
version31Migration(json);
|
|
26854
27465
|
if (v0.test(json.version)) {
|
|
26855
27466
|
var _exec;
|
|
26856
27467
|
reverseParticle = ((_exec = /^(\d+)/.exec(json.version)) == null ? void 0 : _exec[0]) === "0";
|
|
@@ -26871,13 +27482,13 @@ function getStandardJSON(json) {
|
|
|
26871
27482
|
}
|
|
26872
27483
|
throw new Error("Invalid JSON version: " + json.version + ".");
|
|
26873
27484
|
}
|
|
26874
|
-
var currentVersion = "
|
|
27485
|
+
var currentVersion = JSONSceneVersion["1_0"];
|
|
26875
27486
|
function getStandardJSONFromV0(json) {
|
|
26876
27487
|
var _json_bins;
|
|
26877
|
-
currentVersion = "
|
|
27488
|
+
currentVersion = JSONSceneVersion["1_0"];
|
|
26878
27489
|
var plugins = json.plugins || [];
|
|
26879
27490
|
if ((_json_bins = json.bins) == null ? void 0 : _json_bins.length) {
|
|
26880
|
-
currentVersion = "
|
|
27491
|
+
currentVersion = JSONSceneVersion["1_3"];
|
|
26881
27492
|
}
|
|
26882
27493
|
var requires = (json.requires || []).slice();
|
|
26883
27494
|
var images = json.images.map(function(img, index) {
|
|
@@ -28800,7 +29411,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
28800
29411
|
*/ _proto.getSpeed = function getSpeed() {
|
|
28801
29412
|
return this.speed;
|
|
28802
29413
|
};
|
|
28803
|
-
|
|
29414
|
+
/**
|
|
29415
|
+
*
|
|
29416
|
+
*/ _proto.play = function play() {
|
|
28804
29417
|
if (this.isEnded && this.reusable) {
|
|
28805
29418
|
this.restart();
|
|
28806
29419
|
}
|
|
@@ -28815,7 +29428,10 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
28815
29428
|
*/ _proto.pause = function pause() {
|
|
28816
29429
|
this.paused = true;
|
|
28817
29430
|
};
|
|
28818
|
-
|
|
29431
|
+
/**
|
|
29432
|
+
*
|
|
29433
|
+
* @returns
|
|
29434
|
+
*/ _proto.getPaused = function getPaused() {
|
|
28819
29435
|
return this.paused;
|
|
28820
29436
|
};
|
|
28821
29437
|
/**
|
|
@@ -31393,7 +32009,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
|
|
|
31393
32009
|
registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
|
|
31394
32010
|
registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
|
|
31395
32011
|
registerPlugin("interact", InteractLoader, exports.VFXItem, true);
|
|
31396
|
-
var version$1 = "2.
|
|
32012
|
+
var version$1 = "2.3.0-alpha.0";
|
|
31397
32013
|
logger.info("Core version: " + version$1 + ".");
|
|
31398
32014
|
|
|
31399
32015
|
var _obj;
|
|
@@ -33026,7 +33642,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
33026
33642
|
*/ Mesh.create = function(engine, props) {
|
|
33027
33643
|
return new ThreeMesh(engine, props);
|
|
33028
33644
|
};
|
|
33029
|
-
var version = "2.
|
|
33645
|
+
var version = "2.3.0-alpha.0";
|
|
33030
33646
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
33031
33647
|
|
|
33032
33648
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -33145,6 +33761,7 @@ exports.TrackSortWrapper = TrackSortWrapper;
|
|
|
33145
33761
|
exports.Transform = Transform;
|
|
33146
33762
|
exports.TransformAnimationPlayable = TransformAnimationPlayable;
|
|
33147
33763
|
exports.ValueGetter = ValueGetter;
|
|
33764
|
+
exports.Vector2Curve = Vector2Curve;
|
|
33148
33765
|
exports.Vector4Curve = Vector4Curve;
|
|
33149
33766
|
exports.addByOrder = addByOrder;
|
|
33150
33767
|
exports.addItem = addItem;
|