@galacean/effects-core 2.2.6 → 2.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/base-render-component.d.ts +12 -4
- package/dist/components/shape-component.d.ts +92 -3
- package/dist/composition.d.ts +62 -2
- package/dist/config.d.ts +11 -0
- package/dist/downloader.d.ts +15 -0
- package/dist/index.js +1352 -676
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1352 -677
- package/dist/index.mjs.map +1 -1
- package/dist/math/value-getters/index.d.ts +1 -1
- package/dist/math/value-getters/{vector4-curve.d.ts → vector-curves.d.ts} +8 -0
- package/dist/plugins/shape/build-line.d.ts +32 -0
- package/dist/plugins/shape/graphics-path.d.ts +0 -4
- package/dist/plugins/shape/polygon.d.ts +0 -4
- package/dist/plugins/shape/shape-path.d.ts +0 -4
- package/dist/plugins/timeline/playable-assets/index.d.ts +1 -1
- package/dist/plugins/timeline/playable-assets/{vector4-property-playable-asset.d.ts → vector-property-playable-assets.d.ts} +5 -1
- package/dist/plugins/timeline/playables/color-property-mixer-playable.d.ts +5 -5
- package/dist/plugins/timeline/playables/float-property-mixer-playable.d.ts +4 -5
- package/dist/plugins/timeline/playables/index.d.ts +1 -1
- package/dist/plugins/timeline/playables/property-mixer-playable.d.ts +9 -0
- package/dist/plugins/timeline/playables/vector-property-mixer-playable.d.ts +11 -0
- package/dist/plugins/timeline/tracks/index.d.ts +1 -1
- package/dist/plugins/timeline/tracks/{vector4-property-track.d.ts → vector-property-track.d.ts} +3 -0
- package/package.json +2 -2
- package/dist/plugins/timeline/playables/vector4-property-mixer-playable.d.ts +0 -6
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.
|
|
6
|
+
* Version: v2.3.0-alpha.1
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -1022,6 +1022,26 @@ function _inherits(subClass, superClass) {
|
|
|
1022
1022
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
1023
1023
|
}
|
|
1024
1024
|
|
|
1025
|
+
/**
|
|
1026
|
+
* JSON 版本
|
|
1027
|
+
*/ var JSONSceneVersion;
|
|
1028
|
+
(function(JSONSceneVersion) {
|
|
1029
|
+
JSONSceneVersion["1_0"] = "1.0";
|
|
1030
|
+
JSONSceneVersion["1_1"] = "1.1";
|
|
1031
|
+
JSONSceneVersion["1_2"] = "1.2";
|
|
1032
|
+
JSONSceneVersion["1_3"] = "1.3";
|
|
1033
|
+
JSONSceneVersion["1_5"] = "1.5";
|
|
1034
|
+
JSONSceneVersion["1_8"] = "1.8";
|
|
1035
|
+
JSONSceneVersion["2_0"] = "2.0";
|
|
1036
|
+
JSONSceneVersion["2_1"] = "2.1";
|
|
1037
|
+
JSONSceneVersion["2_2"] = "2.2";
|
|
1038
|
+
JSONSceneVersion["2_3"] = "2.3";
|
|
1039
|
+
JSONSceneVersion["2_4"] = "2.4";
|
|
1040
|
+
JSONSceneVersion["3_0"] = "3.0";
|
|
1041
|
+
JSONSceneVersion["3_1"] = "3.1";
|
|
1042
|
+
JSONSceneVersion["LATEST"] = "3.1";
|
|
1043
|
+
})(JSONSceneVersion || (JSONSceneVersion = {}));
|
|
1044
|
+
|
|
1025
1045
|
/*********************************************/ /* 元素属性参数类型 */ /*********************************************/ /**
|
|
1026
1046
|
* 渲染等级
|
|
1027
1047
|
*/ var RenderLevel;
|
|
@@ -1327,8 +1347,12 @@ var RenderFace;
|
|
|
1327
1347
|
*/ var END_BEHAVIOR_DESTROY_CHILDREN = 6;
|
|
1328
1348
|
var CAMERA_CLIP_MODE_VERTICAL = 1;
|
|
1329
1349
|
var CAMERA_CLIP_MODE_NORMAL = 0;
|
|
1330
|
-
|
|
1331
|
-
|
|
1350
|
+
/**
|
|
1351
|
+
* 消息开始
|
|
1352
|
+
*/ var MESSAGE_ITEM_PHRASE_BEGIN = 2;
|
|
1353
|
+
/**
|
|
1354
|
+
* 消息结束
|
|
1355
|
+
*/ var MESSAGE_ITEM_PHRASE_END = 1;
|
|
1332
1356
|
|
|
1333
1357
|
var CameraClipMode;
|
|
1334
1358
|
(function(CameraClipMode) {
|
|
@@ -1402,6 +1426,9 @@ var CameraClipMode;
|
|
|
1402
1426
|
/**
|
|
1403
1427
|
* Vector4 曲线
|
|
1404
1428
|
*/ ValueType[ValueType["VECTOR4_CURVE"] = 25] = "VECTOR4_CURVE";
|
|
1429
|
+
/**
|
|
1430
|
+
* Vector2 曲线
|
|
1431
|
+
*/ ValueType[ValueType["VECTOR2_CURVE"] = 26] = "VECTOR2_CURVE";
|
|
1405
1432
|
})(ValueType || (ValueType = {}));
|
|
1406
1433
|
/**
|
|
1407
1434
|
* 关键帧类型
|
|
@@ -1670,19 +1697,13 @@ var ShapePointType;
|
|
|
1670
1697
|
var DataType;
|
|
1671
1698
|
(function(DataType) {
|
|
1672
1699
|
DataType["VFXItemData"] = "VFXItemData";
|
|
1673
|
-
|
|
1700
|
+
// Assets
|
|
1674
1701
|
DataType["Material"] = "Material";
|
|
1675
1702
|
DataType["Shader"] = "Shader";
|
|
1676
|
-
DataType["SpriteComponent"] = "SpriteComponent";
|
|
1677
|
-
DataType["ParticleSystem"] = "ParticleSystem";
|
|
1678
|
-
DataType["InteractComponent"] = "InteractComponent";
|
|
1679
|
-
DataType["CameraController"] = "CameraController";
|
|
1680
|
-
DataType["PostProcessVolume"] = "PostProcessVolume";
|
|
1681
1703
|
DataType["Geometry"] = "Geometry";
|
|
1682
1704
|
DataType["Texture"] = "Texture";
|
|
1683
1705
|
DataType["Image"] = "Image";
|
|
1684
1706
|
DataType["AnimationClip"] = "AnimationClip";
|
|
1685
|
-
DataType["TextComponent"] = "TextComponent";
|
|
1686
1707
|
DataType["BinaryAsset"] = "BinaryAsset";
|
|
1687
1708
|
// Timeline
|
|
1688
1709
|
DataType["TrackAsset"] = "TrackAsset";
|
|
@@ -1694,6 +1715,7 @@ var DataType;
|
|
|
1694
1715
|
DataType["SubCompositionTrack"] = "SubCompositionTrack";
|
|
1695
1716
|
DataType["FloatPropertyTrack"] = "FloatPropertyTrack";
|
|
1696
1717
|
DataType["ColorPropertyTrack"] = "ColorPropertyTrack";
|
|
1718
|
+
DataType["Vector2PropertyTrack"] = "Vector2PropertyTrack";
|
|
1697
1719
|
DataType["Vector4PropertyTrack"] = "Vector4PropertyTrack";
|
|
1698
1720
|
DataType["TransformPlayableAsset"] = "TransformPlayableAsset";
|
|
1699
1721
|
DataType["SpriteColorPlayableAsset"] = "SpriteColorPlayableAsset";
|
|
@@ -1701,6 +1723,9 @@ var DataType;
|
|
|
1701
1723
|
DataType["SubCompositionPlayableAsset"] = "SubCompositionPlayableAsset";
|
|
1702
1724
|
DataType["FloatPropertyPlayableAsset"] = "FloatPropertyPlayableAsset";
|
|
1703
1725
|
DataType["ColorPropertyPlayableAsset"] = "ColorPropertyPlayableAsset";
|
|
1726
|
+
DataType["Vector2PropertyPlayableAsset"] = "Vector2PropertyPlayableAsset";
|
|
1727
|
+
DataType["Vector4PropertyPlayableAsset"] = "Vector4PropertyPlayableAsset";
|
|
1728
|
+
// Components
|
|
1704
1729
|
DataType["MeshComponent"] = "MeshComponent";
|
|
1705
1730
|
DataType["SkyboxComponent"] = "SkyboxComponent";
|
|
1706
1731
|
DataType["LightComponent"] = "LightComponent";
|
|
@@ -1714,6 +1739,13 @@ var DataType;
|
|
|
1714
1739
|
DataType["RichTextComponent"] = "RichTextComponent";
|
|
1715
1740
|
DataType["OrientationComponent"] = "OrientationComponent";
|
|
1716
1741
|
DataType["ShapeComponent"] = "ShapeComponent";
|
|
1742
|
+
DataType["SpriteComponent"] = "SpriteComponent";
|
|
1743
|
+
DataType["ParticleSystem"] = "ParticleSystem";
|
|
1744
|
+
DataType["InteractComponent"] = "InteractComponent";
|
|
1745
|
+
DataType["CameraController"] = "CameraController";
|
|
1746
|
+
DataType["PostProcessVolume"] = "PostProcessVolume";
|
|
1747
|
+
DataType["EffectComponent"] = "EffectComponent";
|
|
1748
|
+
DataType["TextComponent"] = "TextComponent";
|
|
1717
1749
|
// Non-EffectObject
|
|
1718
1750
|
DataType["TimelineClip"] = "TimelineClip";
|
|
1719
1751
|
})(DataType || (DataType = {}));
|
|
@@ -1802,8 +1834,11 @@ var VertexBufferSemantic;
|
|
|
1802
1834
|
VertexBufferSemantic["TangentBS3"] = "TANGENT_BS3";
|
|
1803
1835
|
})(VertexBufferSemantic || (VertexBufferSemantic = {}));
|
|
1804
1836
|
|
|
1837
|
+
var LATEST_VERSION = JSONSceneVersion.LATEST;
|
|
1838
|
+
|
|
1805
1839
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
1806
1840
|
__proto__: null,
|
|
1841
|
+
LATEST_VERSION: LATEST_VERSION,
|
|
1807
1842
|
get RenderLevel () { return RenderLevel; },
|
|
1808
1843
|
get BlendingMode () { return BlendingMode; },
|
|
1809
1844
|
get SideMode () { return SideMode; },
|
|
@@ -1831,6 +1866,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
1831
1866
|
MESSAGE_ITEM_PHRASE_END: MESSAGE_ITEM_PHRASE_END,
|
|
1832
1867
|
get ValueType () { return ValueType; },
|
|
1833
1868
|
get BezierKeyframeType () { return BezierKeyframeType; },
|
|
1869
|
+
get JSONSceneVersion () { return JSONSceneVersion; },
|
|
1834
1870
|
get EndBehavior () { return EndBehavior; },
|
|
1835
1871
|
get ParentItemEndBehavior () { return ParentItemEndBehavior; },
|
|
1836
1872
|
get ParticleInteractionBehavior () { return ParticleInteractionBehavior; },
|
|
@@ -5278,491 +5314,79 @@ Matrix4.tempVec1 = new Vector3();
|
|
|
5278
5314
|
Matrix4.tempVec2 = new Vector3();
|
|
5279
5315
|
Matrix4.tempMat0 = new Matrix4();
|
|
5280
5316
|
|
|
5281
|
-
function
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
5291
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
5292
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
5293
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
5317
|
+
function _extends() {
|
|
5318
|
+
_extends = Object.assign || function assign(target) {
|
|
5319
|
+
for(var i = 1; i < arguments.length; i++){
|
|
5320
|
+
var source = arguments[i];
|
|
5321
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
5322
|
+
}
|
|
5323
|
+
return target;
|
|
5324
|
+
};
|
|
5325
|
+
return _extends.apply(this, arguments);
|
|
5294
5326
|
}
|
|
5295
5327
|
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
//
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
}
|
|
5328
|
+
exports.TextureLoadAction = void 0;
|
|
5329
|
+
(function(TextureLoadAction) {
|
|
5330
|
+
TextureLoadAction[TextureLoadAction["whatever"] = 0] = "whatever";
|
|
5331
|
+
//preserve previous attachment
|
|
5332
|
+
//load = 1,
|
|
5333
|
+
//clear attachment
|
|
5334
|
+
TextureLoadAction[TextureLoadAction["clear"] = 2] = "clear";
|
|
5335
|
+
})(exports.TextureLoadAction || (exports.TextureLoadAction = {}));
|
|
5336
|
+
exports.TextureSourceType = void 0;
|
|
5337
|
+
(function(TextureSourceType) {
|
|
5338
|
+
TextureSourceType[TextureSourceType["none"] = 0] = "none";
|
|
5339
|
+
TextureSourceType[TextureSourceType["data"] = 1] = "data";
|
|
5340
|
+
TextureSourceType[TextureSourceType["image"] = 2] = "image";
|
|
5341
|
+
TextureSourceType[TextureSourceType["compressed"] = 3] = "compressed";
|
|
5342
|
+
TextureSourceType[TextureSourceType["video"] = 4] = "video";
|
|
5343
|
+
TextureSourceType[TextureSourceType["canvas"] = 5] = "canvas";
|
|
5344
|
+
TextureSourceType[TextureSourceType["framebuffer"] = 6] = "framebuffer";
|
|
5345
|
+
TextureSourceType[TextureSourceType["mipmaps"] = 7] = "mipmaps";
|
|
5346
|
+
})(exports.TextureSourceType || (exports.TextureSourceType = {}));
|
|
5315
5347
|
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
exports.GLSLVersion = void 0;
|
|
5324
|
-
(function(GLSLVersion) {
|
|
5325
|
-
GLSLVersion["GLSL1"] = "100";
|
|
5326
|
-
GLSLVersion["GLSL3"] = "300 es";
|
|
5327
|
-
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
5328
|
-
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
5329
|
-
_inherits(ShaderVariant, EffectsObject);
|
|
5330
|
-
function ShaderVariant(engine, source) {
|
|
5331
|
-
var _this;
|
|
5332
|
-
_this = EffectsObject.call(this, engine) || this;
|
|
5333
|
-
_this.source = source;
|
|
5334
|
-
return _this;
|
|
5335
|
-
}
|
|
5336
|
-
return ShaderVariant;
|
|
5337
|
-
}(EffectsObject);
|
|
5338
|
-
exports.Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
5339
|
-
_inherits(Shader, EffectsObject);
|
|
5340
|
-
function Shader() {
|
|
5341
|
-
return EffectsObject.apply(this, arguments);
|
|
5348
|
+
/**
|
|
5349
|
+
* 负责下载各种资源,并提供了一些异步加载和缓存管理的功能
|
|
5350
|
+
*/ var Downloader = /*#__PURE__*/ function() {
|
|
5351
|
+
function Downloader() {
|
|
5352
|
+
/**
|
|
5353
|
+
* 存储多个回调函数的对象
|
|
5354
|
+
*/ this.callbacks = {};
|
|
5342
5355
|
}
|
|
5343
|
-
var _proto =
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
macros[key]
|
|
5352
|
-
]);
|
|
5353
|
-
}
|
|
5354
|
-
}
|
|
5355
|
-
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
5356
|
-
shaderVariant.shader = this;
|
|
5357
|
-
return shaderVariant;
|
|
5356
|
+
var _proto = Downloader.prototype;
|
|
5357
|
+
/**
|
|
5358
|
+
* 下载一个 JSON 文件
|
|
5359
|
+
* @param url - 要下载的 JSON 文件的 URL
|
|
5360
|
+
* @param onSuccess - 下载成功后的回调函数
|
|
5361
|
+
* @param onError - 下载失败后的回调函数
|
|
5362
|
+
*/ _proto.downloadJSON = function downloadJSON(url, onSuccess, onError) {
|
|
5363
|
+
this.download(url, "json", onSuccess, onError);
|
|
5358
5364
|
};
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5365
|
+
/**
|
|
5366
|
+
* 下载一个二进制文件
|
|
5367
|
+
* @param url - 要下载的二进制文件的 URL
|
|
5368
|
+
* @param onSuccess - 下载成功后的回调函数
|
|
5369
|
+
* @param onError - 下载失败后的回调函数
|
|
5370
|
+
*/ _proto.downloadBinary = function downloadBinary(url, onSuccess, onError) {
|
|
5371
|
+
this.download(url, "arraybuffer", onSuccess, onError);
|
|
5362
5372
|
};
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
5371
|
-
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}";
|
|
5372
|
-
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";
|
|
5373
|
-
function createCopyShader(level, writeDepth) {
|
|
5374
|
-
var webgl2 = level === 2;
|
|
5375
|
-
return {
|
|
5376
|
-
name: EFFECTS_COPY_MESH_NAME,
|
|
5377
|
-
vertex: COPY_VERTEX_SHADER,
|
|
5378
|
-
fragment: COPY_FRAGMENT_SHADER,
|
|
5379
|
-
glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
5380
|
-
macros: [
|
|
5381
|
-
[
|
|
5382
|
-
"DEPTH_TEXTURE",
|
|
5383
|
-
!!writeDepth
|
|
5384
|
-
]
|
|
5385
|
-
],
|
|
5386
|
-
// @ts-expect-error
|
|
5387
|
-
cacheId: COPY_MESH_SHADER_ID + +writeDepth
|
|
5373
|
+
/**
|
|
5374
|
+
* 下载一个 Blob 文件
|
|
5375
|
+
* @param url - 要下载的 Blob 文件的 URL
|
|
5376
|
+
* @param onSuccess - 下载成功后的回调函数
|
|
5377
|
+
* @param onError - 下载失败后的回调函数
|
|
5378
|
+
*/ _proto.downloadBlob = function downloadBlob(url, onSuccess, onError) {
|
|
5379
|
+
this.download(url, "blob", onSuccess, onError);
|
|
5388
5380
|
};
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
*
|
|
5394
|
-
* @param canvas
|
|
5395
|
-
* @param glType
|
|
5396
|
-
* @param options
|
|
5397
|
-
* @returns
|
|
5398
|
-
*/ function createGLContext(canvas, glType, options) {
|
|
5399
|
-
if (glType === void 0) glType = "webgl";
|
|
5400
|
-
var context;
|
|
5401
|
-
if (glType === "webgl2") {
|
|
5402
|
-
context = canvas.getContext("webgl2", options);
|
|
5403
|
-
if (!context) {
|
|
5404
|
-
console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
|
|
5405
|
-
}
|
|
5406
|
-
}
|
|
5407
|
-
if (!context || glType === "webgl") {
|
|
5408
|
-
context = canvas.getContext("webgl", options);
|
|
5409
|
-
}
|
|
5410
|
-
if (!context) {
|
|
5411
|
-
throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
|
|
5412
|
-
}
|
|
5413
|
-
return context;
|
|
5414
|
-
}
|
|
5415
|
-
|
|
5416
|
-
function gpuTimer(gl) {
|
|
5417
|
-
var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
|
|
5418
|
-
if (ext) {
|
|
5419
|
-
var query = gl.createQuery();
|
|
5420
|
-
var getTime = /*#__PURE__*/ _async_to_generator(function() {
|
|
5421
|
-
return __generator(this, function(_state) {
|
|
5422
|
-
return [
|
|
5423
|
-
2,
|
|
5424
|
-
new Promise(function(resolve, reject) {
|
|
5425
|
-
if (query) {
|
|
5426
|
-
var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
|
|
5427
|
-
var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
|
|
5428
|
-
if (available && !disjoint) {
|
|
5429
|
-
// See how much time the rendering of the object took in nanoseconds.
|
|
5430
|
-
var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
|
|
5431
|
-
// taken to use all significant bits of the result, not just the
|
|
5432
|
-
// least significant 32 bits.
|
|
5433
|
-
resolve(timeElapsed / 1000 / 1000);
|
|
5434
|
-
}
|
|
5435
|
-
if (available || disjoint) {
|
|
5436
|
-
// Clean up the query object.
|
|
5437
|
-
gl.deleteQuery(query); // Don't re-enter this polling loop.
|
|
5438
|
-
query = null;
|
|
5439
|
-
}
|
|
5440
|
-
available !== null && query && window.setTimeout(function() {
|
|
5441
|
-
getTime().then(resolve).catch;
|
|
5442
|
-
}, 1);
|
|
5443
|
-
}
|
|
5444
|
-
})
|
|
5445
|
-
];
|
|
5446
|
-
});
|
|
5447
|
-
});
|
|
5448
|
-
if (!query) {
|
|
5381
|
+
_proto.download = function download(url, responseType, onSuccess, onError) {
|
|
5382
|
+
var _this = this;
|
|
5383
|
+
if (responseType === void 0) responseType = "json";
|
|
5384
|
+
if (this.start(url, onSuccess, onError)) {
|
|
5449
5385
|
return;
|
|
5450
5386
|
}
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
},
|
|
5455
|
-
end: function() {
|
|
5456
|
-
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
5457
|
-
},
|
|
5458
|
-
getTime: getTime
|
|
5459
|
-
};
|
|
5460
|
-
}
|
|
5461
|
-
}
|
|
5462
|
-
|
|
5463
|
-
var initErrors = [];
|
|
5464
|
-
// @ts-expect-error
|
|
5465
|
-
var glContext = {};
|
|
5466
|
-
if (!initErrors.length) {
|
|
5467
|
-
initGLContext();
|
|
5468
|
-
}
|
|
5469
|
-
function initGLContext() {
|
|
5470
|
-
// 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
|
|
5471
|
-
if (typeof WebGL2RenderingContext === "function") {
|
|
5472
|
-
copy(WebGL2RenderingContext);
|
|
5473
|
-
} else if (typeof WebGLRenderingContext !== "undefined") {
|
|
5474
|
-
copy(WebGLRenderingContext);
|
|
5475
|
-
copy(WebGLRenderingContext.prototype);
|
|
5476
|
-
} else {
|
|
5477
|
-
initErrors.push(// iOS 16 lockdown mode
|
|
5478
|
-
"iOS16 lockdown mode, WebGL Constants not in global");
|
|
5479
|
-
}
|
|
5480
|
-
if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
|
|
5481
|
-
// @ts-expect-error set default value
|
|
5482
|
-
glContext["HALF_FLOAT"] = 5131;
|
|
5483
|
-
}
|
|
5484
|
-
}
|
|
5485
|
-
function isWebGL2(gl) {
|
|
5486
|
-
return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
|
|
5487
|
-
}
|
|
5488
|
-
function copy(target) {
|
|
5489
|
-
for(var name in target){
|
|
5490
|
-
if (/^[A-Z_]/.test(name)) {
|
|
5491
|
-
// @ts-expect-error safe to assign
|
|
5492
|
-
glContext[name] = target[name];
|
|
5493
|
-
}
|
|
5494
|
-
}
|
|
5495
|
-
}
|
|
5496
|
-
function vertexFormatType2GLType(formatType) {
|
|
5497
|
-
switch(formatType){
|
|
5498
|
-
case VertexFormatType.Float32:
|
|
5499
|
-
return WebGLRenderingContext["FLOAT"];
|
|
5500
|
-
case VertexFormatType.Int16:
|
|
5501
|
-
return WebGLRenderingContext["SHORT"];
|
|
5502
|
-
case VertexFormatType.Int8:
|
|
5503
|
-
return WebGLRenderingContext["BYTE"];
|
|
5504
|
-
case VertexFormatType.UInt16:
|
|
5505
|
-
return WebGLRenderingContext["UNSIGNED_SHORT"];
|
|
5506
|
-
case VertexFormatType.UInt8:
|
|
5507
|
-
return WebGLRenderingContext["UNSIGNED_BYTE"];
|
|
5508
|
-
default:
|
|
5509
|
-
return WebGLRenderingContext["FLOAT"];
|
|
5510
|
-
}
|
|
5511
|
-
}
|
|
5512
|
-
function glType2VertexFormatType(webglType) {
|
|
5513
|
-
switch(webglType){
|
|
5514
|
-
case WebGLRenderingContext["FLOAT"]:
|
|
5515
|
-
return VertexFormatType.Float32;
|
|
5516
|
-
case WebGLRenderingContext["SHORT"]:
|
|
5517
|
-
return VertexFormatType.Int16;
|
|
5518
|
-
case WebGLRenderingContext["BYTE"]:
|
|
5519
|
-
return VertexFormatType.Int8;
|
|
5520
|
-
case WebGLRenderingContext["UNSIGNED_SHORT"]:
|
|
5521
|
-
return VertexFormatType.UInt16;
|
|
5522
|
-
case WebGLRenderingContext["UNSIGNED_BYTE"]:
|
|
5523
|
-
return VertexFormatType.UInt8;
|
|
5524
|
-
default:
|
|
5525
|
-
return VertexFormatType.Float32;
|
|
5526
|
-
}
|
|
5527
|
-
}
|
|
5528
|
-
|
|
5529
|
-
exports.ShaderType = void 0;
|
|
5530
|
-
(function(ShaderType) {
|
|
5531
|
-
ShaderType[ShaderType["vertex"] = 0] = "vertex";
|
|
5532
|
-
ShaderType[ShaderType["fragment"] = 1] = "fragment";
|
|
5533
|
-
})(exports.ShaderType || (exports.ShaderType = {}));
|
|
5534
|
-
|
|
5535
|
-
function valIfUndefined(val, def) {
|
|
5536
|
-
if (val === undefined || val === null) {
|
|
5537
|
-
return def;
|
|
5538
|
-
}
|
|
5539
|
-
return val;
|
|
5540
|
-
}
|
|
5541
|
-
function getPreMultiAlpha(blending) {
|
|
5542
|
-
switch(blending){
|
|
5543
|
-
case BlendingMode.ALPHA:
|
|
5544
|
-
return 1;
|
|
5545
|
-
case BlendingMode.ADD:
|
|
5546
|
-
return 1;
|
|
5547
|
-
case BlendingMode.SUBTRACTION:
|
|
5548
|
-
return 1;
|
|
5549
|
-
case BlendingMode.STRONG_LIGHT:
|
|
5550
|
-
return 1;
|
|
5551
|
-
case BlendingMode.WEAK_LIGHT:
|
|
5552
|
-
return 1;
|
|
5553
|
-
case BlendingMode.SUPERPOSITION:
|
|
5554
|
-
return 2;
|
|
5555
|
-
case BlendingMode.BRIGHTNESS:
|
|
5556
|
-
return 3;
|
|
5557
|
-
case BlendingMode.MULTIPLY:
|
|
5558
|
-
return 0;
|
|
5559
|
-
default:
|
|
5560
|
-
// 处理undefined
|
|
5561
|
-
return 1;
|
|
5562
|
-
}
|
|
5563
|
-
}
|
|
5564
|
-
function setBlendMode(material, blendMode) {
|
|
5565
|
-
switch(blendMode){
|
|
5566
|
-
case undefined:
|
|
5567
|
-
material.blendFunction = [
|
|
5568
|
-
glContext.ONE,
|
|
5569
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
5570
|
-
glContext.ONE,
|
|
5571
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
5572
|
-
];
|
|
5573
|
-
break;
|
|
5574
|
-
case BlendingMode.ALPHA:
|
|
5575
|
-
material.blendFunction = [
|
|
5576
|
-
glContext.ONE,
|
|
5577
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
5578
|
-
glContext.ONE,
|
|
5579
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
5580
|
-
];
|
|
5581
|
-
break;
|
|
5582
|
-
case BlendingMode.ADD:
|
|
5583
|
-
material.blendFunction = [
|
|
5584
|
-
glContext.ONE,
|
|
5585
|
-
glContext.ONE,
|
|
5586
|
-
glContext.ONE,
|
|
5587
|
-
glContext.ONE
|
|
5588
|
-
];
|
|
5589
|
-
break;
|
|
5590
|
-
case BlendingMode.SUBTRACTION:
|
|
5591
|
-
material.blendFunction = [
|
|
5592
|
-
glContext.ONE,
|
|
5593
|
-
glContext.ONE,
|
|
5594
|
-
glContext.ZERO,
|
|
5595
|
-
glContext.ONE
|
|
5596
|
-
];
|
|
5597
|
-
material.blendEquation = [
|
|
5598
|
-
glContext.FUNC_REVERSE_SUBTRACT,
|
|
5599
|
-
glContext.FUNC_REVERSE_SUBTRACT
|
|
5600
|
-
];
|
|
5601
|
-
break;
|
|
5602
|
-
case BlendingMode.SUPERPOSITION:
|
|
5603
|
-
material.blendFunction = [
|
|
5604
|
-
glContext.ONE,
|
|
5605
|
-
glContext.ONE,
|
|
5606
|
-
glContext.ONE,
|
|
5607
|
-
glContext.ONE
|
|
5608
|
-
];
|
|
5609
|
-
break;
|
|
5610
|
-
case BlendingMode.MULTIPLY:
|
|
5611
|
-
material.blendFunction = [
|
|
5612
|
-
glContext.DST_COLOR,
|
|
5613
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
5614
|
-
glContext.DST_COLOR,
|
|
5615
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
5616
|
-
];
|
|
5617
|
-
break;
|
|
5618
|
-
case BlendingMode.BRIGHTNESS:
|
|
5619
|
-
material.blendFunction = [
|
|
5620
|
-
glContext.ONE,
|
|
5621
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
5622
|
-
glContext.ONE,
|
|
5623
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
5624
|
-
];
|
|
5625
|
-
break;
|
|
5626
|
-
case BlendingMode.STRONG_LIGHT:
|
|
5627
|
-
material.blendFunction = [
|
|
5628
|
-
glContext.DST_COLOR,
|
|
5629
|
-
glContext.DST_ALPHA,
|
|
5630
|
-
glContext.ZERO,
|
|
5631
|
-
glContext.ONE
|
|
5632
|
-
];
|
|
5633
|
-
break;
|
|
5634
|
-
case BlendingMode.WEAK_LIGHT:
|
|
5635
|
-
material.blendFunction = [
|
|
5636
|
-
glContext.DST_COLOR,
|
|
5637
|
-
glContext.ZERO,
|
|
5638
|
-
glContext.ZERO,
|
|
5639
|
-
glContext.ONE
|
|
5640
|
-
];
|
|
5641
|
-
break;
|
|
5642
|
-
default:
|
|
5643
|
-
console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
|
|
5644
|
-
}
|
|
5645
|
-
}
|
|
5646
|
-
function setSideMode(material, side) {
|
|
5647
|
-
if (side === SideMode.DOUBLE) {
|
|
5648
|
-
material.culling = false;
|
|
5649
|
-
} else {
|
|
5650
|
-
material.culling = true;
|
|
5651
|
-
material.frontFace = glContext.CW;
|
|
5652
|
-
material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
|
|
5653
|
-
}
|
|
5654
|
-
}
|
|
5655
|
-
function setMaskMode(material, maskMode) {
|
|
5656
|
-
switch(maskMode){
|
|
5657
|
-
case undefined:
|
|
5658
|
-
material.stencilTest = false;
|
|
5659
|
-
break;
|
|
5660
|
-
case MaskMode.MASK:
|
|
5661
|
-
material.stencilTest = true;
|
|
5662
|
-
material.stencilFunc = [
|
|
5663
|
-
glContext.ALWAYS,
|
|
5664
|
-
glContext.ALWAYS
|
|
5665
|
-
];
|
|
5666
|
-
material.stencilOpZPass = [
|
|
5667
|
-
glContext.REPLACE,
|
|
5668
|
-
glContext.REPLACE
|
|
5669
|
-
];
|
|
5670
|
-
break;
|
|
5671
|
-
case MaskMode.OBSCURED:
|
|
5672
|
-
material.stencilTest = true;
|
|
5673
|
-
material.stencilFunc = [
|
|
5674
|
-
glContext.EQUAL,
|
|
5675
|
-
glContext.EQUAL
|
|
5676
|
-
];
|
|
5677
|
-
break;
|
|
5678
|
-
case MaskMode.REVERSE_OBSCURED:
|
|
5679
|
-
material.stencilTest = true;
|
|
5680
|
-
material.stencilFunc = [
|
|
5681
|
-
glContext.NOTEQUAL,
|
|
5682
|
-
glContext.NOTEQUAL
|
|
5683
|
-
];
|
|
5684
|
-
break;
|
|
5685
|
-
case MaskMode.NONE:
|
|
5686
|
-
material.stencilTest = false;
|
|
5687
|
-
break;
|
|
5688
|
-
default:
|
|
5689
|
-
console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
|
|
5690
|
-
}
|
|
5691
|
-
}
|
|
5692
|
-
|
|
5693
|
-
function _extends() {
|
|
5694
|
-
_extends = Object.assign || function assign(target) {
|
|
5695
|
-
for(var i = 1; i < arguments.length; i++){
|
|
5696
|
-
var source = arguments[i];
|
|
5697
|
-
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
5698
|
-
}
|
|
5699
|
-
return target;
|
|
5700
|
-
};
|
|
5701
|
-
return _extends.apply(this, arguments);
|
|
5702
|
-
}
|
|
5703
|
-
|
|
5704
|
-
exports.TextureLoadAction = void 0;
|
|
5705
|
-
(function(TextureLoadAction) {
|
|
5706
|
-
TextureLoadAction[TextureLoadAction["whatever"] = 0] = "whatever";
|
|
5707
|
-
//preserve previous attachment
|
|
5708
|
-
//load = 1,
|
|
5709
|
-
//clear attachment
|
|
5710
|
-
TextureLoadAction[TextureLoadAction["clear"] = 2] = "clear";
|
|
5711
|
-
})(exports.TextureLoadAction || (exports.TextureLoadAction = {}));
|
|
5712
|
-
exports.TextureSourceType = void 0;
|
|
5713
|
-
(function(TextureSourceType) {
|
|
5714
|
-
TextureSourceType[TextureSourceType["none"] = 0] = "none";
|
|
5715
|
-
TextureSourceType[TextureSourceType["data"] = 1] = "data";
|
|
5716
|
-
TextureSourceType[TextureSourceType["image"] = 2] = "image";
|
|
5717
|
-
TextureSourceType[TextureSourceType["compressed"] = 3] = "compressed";
|
|
5718
|
-
TextureSourceType[TextureSourceType["video"] = 4] = "video";
|
|
5719
|
-
TextureSourceType[TextureSourceType["canvas"] = 5] = "canvas";
|
|
5720
|
-
TextureSourceType[TextureSourceType["framebuffer"] = 6] = "framebuffer";
|
|
5721
|
-
TextureSourceType[TextureSourceType["mipmaps"] = 7] = "mipmaps";
|
|
5722
|
-
})(exports.TextureSourceType || (exports.TextureSourceType = {}));
|
|
5723
|
-
|
|
5724
|
-
/**
|
|
5725
|
-
* 负责下载各种资源,并提供了一些异步加载和缓存管理的功能
|
|
5726
|
-
*/ var Downloader = /*#__PURE__*/ function() {
|
|
5727
|
-
function Downloader() {
|
|
5728
|
-
/**
|
|
5729
|
-
* 存储多个回调函数的对象
|
|
5730
|
-
*/ this.callbacks = {};
|
|
5731
|
-
}
|
|
5732
|
-
var _proto = Downloader.prototype;
|
|
5733
|
-
/**
|
|
5734
|
-
* 下载一个 JSON 文件
|
|
5735
|
-
* @param url - 要下载的 JSON 文件的 URL
|
|
5736
|
-
* @param onSuccess - 下载成功后的回调函数
|
|
5737
|
-
* @param onError - 下载失败后的回调函数
|
|
5738
|
-
*/ _proto.downloadJSON = function downloadJSON(url, onSuccess, onError) {
|
|
5739
|
-
this.download(url, "json", onSuccess, onError);
|
|
5740
|
-
};
|
|
5741
|
-
/**
|
|
5742
|
-
* 下载一个二进制文件
|
|
5743
|
-
* @param url - 要下载的二进制文件的 URL
|
|
5744
|
-
* @param onSuccess - 下载成功后的回调函数
|
|
5745
|
-
* @param onError - 下载失败后的回调函数
|
|
5746
|
-
*/ _proto.downloadBinary = function downloadBinary(url, onSuccess, onError) {
|
|
5747
|
-
this.download(url, "arraybuffer", onSuccess, onError);
|
|
5748
|
-
};
|
|
5749
|
-
/**
|
|
5750
|
-
* 下载一个 Blob 文件
|
|
5751
|
-
* @param url - 要下载的 Blob 文件的 URL
|
|
5752
|
-
* @param onSuccess - 下载成功后的回调函数
|
|
5753
|
-
* @param onError - 下载失败后的回调函数
|
|
5754
|
-
*/ _proto.downloadBlob = function downloadBlob(url, onSuccess, onError) {
|
|
5755
|
-
this.download(url, "blob", onSuccess, onError);
|
|
5756
|
-
};
|
|
5757
|
-
_proto.download = function download(url, responseType, onSuccess, onError) {
|
|
5758
|
-
var _this = this;
|
|
5759
|
-
if (responseType === void 0) responseType = "json";
|
|
5760
|
-
if (this.start(url, onSuccess, onError)) {
|
|
5761
|
-
return;
|
|
5762
|
-
}
|
|
5763
|
-
var xhr = new XMLHttpRequest();
|
|
5764
|
-
var handleError = function() {
|
|
5765
|
-
_this.finish(url, xhr.status, xhr.response);
|
|
5387
|
+
var xhr = new XMLHttpRequest();
|
|
5388
|
+
var handleError = function() {
|
|
5389
|
+
_this.finish(url, xhr.status, xhr.response);
|
|
5766
5390
|
};
|
|
5767
5391
|
var handleLoad = function() {
|
|
5768
5392
|
if (xhr.status == 200) {
|
|
@@ -6100,7 +5724,12 @@ function _loadVideo() {
|
|
|
6100
5724
|
});
|
|
6101
5725
|
return _loadVideo.apply(this, arguments);
|
|
6102
5726
|
}
|
|
6103
|
-
|
|
5727
|
+
/**
|
|
5728
|
+
* 异步加载一个媒体文件
|
|
5729
|
+
* @param url
|
|
5730
|
+
* @param loadFn
|
|
5731
|
+
* @returns
|
|
5732
|
+
*/ function loadMedia(url, loadFn) {
|
|
6104
5733
|
return _loadMedia.apply(this, arguments);
|
|
6105
5734
|
}
|
|
6106
5735
|
function _loadMedia() {
|
|
@@ -6262,6 +5891,144 @@ function _loadMipmapImage() {
|
|
|
6262
5891
|
return _loadMipmapImage.apply(this, arguments);
|
|
6263
5892
|
}
|
|
6264
5893
|
|
|
5894
|
+
/**
|
|
5895
|
+
* Helper class to create a WebGL Context
|
|
5896
|
+
*
|
|
5897
|
+
* @param canvas
|
|
5898
|
+
* @param glType
|
|
5899
|
+
* @param options
|
|
5900
|
+
* @returns
|
|
5901
|
+
*/ function createGLContext(canvas, glType, options) {
|
|
5902
|
+
if (glType === void 0) glType = "webgl";
|
|
5903
|
+
var context;
|
|
5904
|
+
if (glType === "webgl2") {
|
|
5905
|
+
context = canvas.getContext("webgl2", options);
|
|
5906
|
+
if (!context) {
|
|
5907
|
+
console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
|
|
5908
|
+
}
|
|
5909
|
+
}
|
|
5910
|
+
if (!context || glType === "webgl") {
|
|
5911
|
+
context = canvas.getContext("webgl", options);
|
|
5912
|
+
}
|
|
5913
|
+
if (!context) {
|
|
5914
|
+
throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
|
|
5915
|
+
}
|
|
5916
|
+
return context;
|
|
5917
|
+
}
|
|
5918
|
+
|
|
5919
|
+
function gpuTimer(gl) {
|
|
5920
|
+
var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
|
|
5921
|
+
if (ext) {
|
|
5922
|
+
var query = gl.createQuery();
|
|
5923
|
+
var getTime = /*#__PURE__*/ _async_to_generator(function() {
|
|
5924
|
+
return __generator(this, function(_state) {
|
|
5925
|
+
return [
|
|
5926
|
+
2,
|
|
5927
|
+
new Promise(function(resolve, reject) {
|
|
5928
|
+
if (query) {
|
|
5929
|
+
var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
|
|
5930
|
+
var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
|
|
5931
|
+
if (available && !disjoint) {
|
|
5932
|
+
// See how much time the rendering of the object took in nanoseconds.
|
|
5933
|
+
var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
|
|
5934
|
+
// taken to use all significant bits of the result, not just the
|
|
5935
|
+
// least significant 32 bits.
|
|
5936
|
+
resolve(timeElapsed / 1000 / 1000);
|
|
5937
|
+
}
|
|
5938
|
+
if (available || disjoint) {
|
|
5939
|
+
// Clean up the query object.
|
|
5940
|
+
gl.deleteQuery(query); // Don't re-enter this polling loop.
|
|
5941
|
+
query = null;
|
|
5942
|
+
}
|
|
5943
|
+
available !== null && query && window.setTimeout(function() {
|
|
5944
|
+
getTime().then(resolve).catch;
|
|
5945
|
+
}, 1);
|
|
5946
|
+
}
|
|
5947
|
+
})
|
|
5948
|
+
];
|
|
5949
|
+
});
|
|
5950
|
+
});
|
|
5951
|
+
if (!query) {
|
|
5952
|
+
return;
|
|
5953
|
+
}
|
|
5954
|
+
return {
|
|
5955
|
+
begin: function() {
|
|
5956
|
+
query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
|
|
5957
|
+
},
|
|
5958
|
+
end: function() {
|
|
5959
|
+
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
5960
|
+
},
|
|
5961
|
+
getTime: getTime
|
|
5962
|
+
};
|
|
5963
|
+
}
|
|
5964
|
+
}
|
|
5965
|
+
|
|
5966
|
+
var initErrors = [];
|
|
5967
|
+
// @ts-expect-error
|
|
5968
|
+
var glContext = {};
|
|
5969
|
+
if (!initErrors.length) {
|
|
5970
|
+
initGLContext();
|
|
5971
|
+
}
|
|
5972
|
+
function initGLContext() {
|
|
5973
|
+
// 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
|
|
5974
|
+
if (typeof WebGL2RenderingContext === "function") {
|
|
5975
|
+
copy(WebGL2RenderingContext);
|
|
5976
|
+
} else if (typeof WebGLRenderingContext !== "undefined") {
|
|
5977
|
+
copy(WebGLRenderingContext);
|
|
5978
|
+
copy(WebGLRenderingContext.prototype);
|
|
5979
|
+
} else {
|
|
5980
|
+
initErrors.push(// iOS 16 lockdown mode
|
|
5981
|
+
"iOS16 lockdown mode, WebGL Constants not in global");
|
|
5982
|
+
}
|
|
5983
|
+
if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
|
|
5984
|
+
// @ts-expect-error set default value
|
|
5985
|
+
glContext["HALF_FLOAT"] = 5131;
|
|
5986
|
+
}
|
|
5987
|
+
}
|
|
5988
|
+
function isWebGL2(gl) {
|
|
5989
|
+
return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
|
|
5990
|
+
}
|
|
5991
|
+
function copy(target) {
|
|
5992
|
+
for(var name in target){
|
|
5993
|
+
if (/^[A-Z_]/.test(name)) {
|
|
5994
|
+
// @ts-expect-error safe to assign
|
|
5995
|
+
glContext[name] = target[name];
|
|
5996
|
+
}
|
|
5997
|
+
}
|
|
5998
|
+
}
|
|
5999
|
+
function vertexFormatType2GLType(formatType) {
|
|
6000
|
+
switch(formatType){
|
|
6001
|
+
case VertexFormatType.Float32:
|
|
6002
|
+
return WebGLRenderingContext["FLOAT"];
|
|
6003
|
+
case VertexFormatType.Int16:
|
|
6004
|
+
return WebGLRenderingContext["SHORT"];
|
|
6005
|
+
case VertexFormatType.Int8:
|
|
6006
|
+
return WebGLRenderingContext["BYTE"];
|
|
6007
|
+
case VertexFormatType.UInt16:
|
|
6008
|
+
return WebGLRenderingContext["UNSIGNED_SHORT"];
|
|
6009
|
+
case VertexFormatType.UInt8:
|
|
6010
|
+
return WebGLRenderingContext["UNSIGNED_BYTE"];
|
|
6011
|
+
default:
|
|
6012
|
+
return WebGLRenderingContext["FLOAT"];
|
|
6013
|
+
}
|
|
6014
|
+
}
|
|
6015
|
+
function glType2VertexFormatType(webglType) {
|
|
6016
|
+
switch(webglType){
|
|
6017
|
+
case WebGLRenderingContext["FLOAT"]:
|
|
6018
|
+
return VertexFormatType.Float32;
|
|
6019
|
+
case WebGLRenderingContext["SHORT"]:
|
|
6020
|
+
return VertexFormatType.Int16;
|
|
6021
|
+
case WebGLRenderingContext["BYTE"]:
|
|
6022
|
+
return VertexFormatType.Int8;
|
|
6023
|
+
case WebGLRenderingContext["UNSIGNED_SHORT"]:
|
|
6024
|
+
return VertexFormatType.UInt16;
|
|
6025
|
+
case WebGLRenderingContext["UNSIGNED_BYTE"]:
|
|
6026
|
+
return VertexFormatType.UInt8;
|
|
6027
|
+
default:
|
|
6028
|
+
return VertexFormatType.Float32;
|
|
6029
|
+
}
|
|
6030
|
+
}
|
|
6031
|
+
|
|
6265
6032
|
var seed$9 = 1;
|
|
6266
6033
|
/**
|
|
6267
6034
|
* Texture 抽象类
|
|
@@ -6856,44 +6623,318 @@ var TextureFactory = /*#__PURE__*/ function() {
|
|
|
6856
6623
|
});
|
|
6857
6624
|
})();
|
|
6858
6625
|
};
|
|
6859
|
-
_proto.loadMipmapImages = function loadMipmapImages(pointers, bin) {
|
|
6860
|
-
return _async_to_generator(function() {
|
|
6861
|
-
return __generator(this, function(_state) {
|
|
6862
|
-
return [
|
|
6863
|
-
2,
|
|
6864
|
-
Promise.all(pointers.map(function(pointer) {
|
|
6865
|
-
var blob = new Blob([
|
|
6866
|
-
new Uint8Array(bin, pointer[0], pointer[1])
|
|
6867
|
-
]);
|
|
6868
|
-
return loadImage(blob);
|
|
6869
|
-
}))
|
|
6870
|
-
];
|
|
6871
|
-
});
|
|
6872
|
-
})();
|
|
6626
|
+
_proto.loadMipmapImages = function loadMipmapImages(pointers, bin) {
|
|
6627
|
+
return _async_to_generator(function() {
|
|
6628
|
+
return __generator(this, function(_state) {
|
|
6629
|
+
return [
|
|
6630
|
+
2,
|
|
6631
|
+
Promise.all(pointers.map(function(pointer) {
|
|
6632
|
+
var blob = new Blob([
|
|
6633
|
+
new Uint8Array(bin, pointer[0], pointer[1])
|
|
6634
|
+
]);
|
|
6635
|
+
return loadImage(blob);
|
|
6636
|
+
}))
|
|
6637
|
+
];
|
|
6638
|
+
});
|
|
6639
|
+
})();
|
|
6640
|
+
};
|
|
6641
|
+
_proto.loadCubeMap = function loadCubeMap(cubemap) {
|
|
6642
|
+
return _async_to_generator(function() {
|
|
6643
|
+
return __generator(this, function(_state) {
|
|
6644
|
+
return [
|
|
6645
|
+
2,
|
|
6646
|
+
Promise.all(cubemap.map(function(key) {
|
|
6647
|
+
return loadImage(key);
|
|
6648
|
+
}))
|
|
6649
|
+
];
|
|
6650
|
+
});
|
|
6651
|
+
})();
|
|
6652
|
+
};
|
|
6653
|
+
return TextureFactory;
|
|
6654
|
+
}();
|
|
6655
|
+
var g;
|
|
6656
|
+
function getDefaultTextureFactory() {
|
|
6657
|
+
if (!g) {
|
|
6658
|
+
g = new TextureFactory();
|
|
6659
|
+
}
|
|
6660
|
+
return g;
|
|
6661
|
+
}
|
|
6662
|
+
function setDefaultTextureFactory(factory) {
|
|
6663
|
+
g = factory;
|
|
6664
|
+
}
|
|
6665
|
+
|
|
6666
|
+
function _array_like_to_array(arr, len) {
|
|
6667
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
6668
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
6669
|
+
return arr2;
|
|
6670
|
+
}
|
|
6671
|
+
|
|
6672
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
6673
|
+
if (!o) return;
|
|
6674
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
6675
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
6676
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
6677
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
6678
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
6679
|
+
}
|
|
6680
|
+
|
|
6681
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
6682
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
6683
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
6684
|
+
// Fallback for engines without symbol support
|
|
6685
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
6686
|
+
if (it) o = it;
|
|
6687
|
+
var i = 0;
|
|
6688
|
+
return function() {
|
|
6689
|
+
if (i >= o.length) return {
|
|
6690
|
+
done: true
|
|
6691
|
+
};
|
|
6692
|
+
return {
|
|
6693
|
+
done: false,
|
|
6694
|
+
value: o[i++]
|
|
6695
|
+
};
|
|
6696
|
+
};
|
|
6697
|
+
}
|
|
6698
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
6699
|
+
}
|
|
6700
|
+
|
|
6701
|
+
exports.ShaderCompileResultStatus = void 0;
|
|
6702
|
+
(function(ShaderCompileResultStatus) {
|
|
6703
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
|
|
6704
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
|
|
6705
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
|
|
6706
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
|
|
6707
|
+
})(exports.ShaderCompileResultStatus || (exports.ShaderCompileResultStatus = {}));
|
|
6708
|
+
exports.GLSLVersion = void 0;
|
|
6709
|
+
(function(GLSLVersion) {
|
|
6710
|
+
GLSLVersion["GLSL1"] = "100";
|
|
6711
|
+
GLSLVersion["GLSL3"] = "300 es";
|
|
6712
|
+
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
6713
|
+
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
6714
|
+
_inherits(ShaderVariant, EffectsObject);
|
|
6715
|
+
function ShaderVariant(engine, source) {
|
|
6716
|
+
var _this;
|
|
6717
|
+
_this = EffectsObject.call(this, engine) || this;
|
|
6718
|
+
_this.source = source;
|
|
6719
|
+
return _this;
|
|
6720
|
+
}
|
|
6721
|
+
return ShaderVariant;
|
|
6722
|
+
}(EffectsObject);
|
|
6723
|
+
exports.Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
6724
|
+
_inherits(Shader, EffectsObject);
|
|
6725
|
+
function Shader() {
|
|
6726
|
+
return EffectsObject.apply(this, arguments);
|
|
6727
|
+
}
|
|
6728
|
+
var _proto = Shader.prototype;
|
|
6729
|
+
_proto.createVariant = function createVariant(macros) {
|
|
6730
|
+
var shaderMacros = [];
|
|
6731
|
+
if (macros) {
|
|
6732
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
|
|
6733
|
+
var key = _step.value;
|
|
6734
|
+
shaderMacros.push([
|
|
6735
|
+
key,
|
|
6736
|
+
macros[key]
|
|
6737
|
+
]);
|
|
6738
|
+
}
|
|
6739
|
+
}
|
|
6740
|
+
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
6741
|
+
shaderVariant.shader = this;
|
|
6742
|
+
return shaderVariant;
|
|
6743
|
+
};
|
|
6744
|
+
_proto.fromData = function fromData(data) {
|
|
6745
|
+
EffectsObject.prototype.fromData.call(this, data);
|
|
6746
|
+
this.shaderData = data;
|
|
6873
6747
|
};
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6748
|
+
return Shader;
|
|
6749
|
+
}(EffectsObject);
|
|
6750
|
+
exports.Shader = __decorate([
|
|
6751
|
+
effectsClass(DataType.Shader)
|
|
6752
|
+
], exports.Shader);
|
|
6753
|
+
|
|
6754
|
+
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
6755
|
+
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
6756
|
+
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}";
|
|
6757
|
+
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";
|
|
6758
|
+
function createCopyShader(level, writeDepth) {
|
|
6759
|
+
var webgl2 = level === 2;
|
|
6760
|
+
return {
|
|
6761
|
+
name: EFFECTS_COPY_MESH_NAME,
|
|
6762
|
+
vertex: COPY_VERTEX_SHADER,
|
|
6763
|
+
fragment: COPY_FRAGMENT_SHADER,
|
|
6764
|
+
glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
6765
|
+
macros: [
|
|
6766
|
+
[
|
|
6767
|
+
"DEPTH_TEXTURE",
|
|
6768
|
+
!!writeDepth
|
|
6769
|
+
]
|
|
6770
|
+
],
|
|
6771
|
+
// @ts-expect-error
|
|
6772
|
+
cacheId: COPY_MESH_SHADER_ID + +writeDepth
|
|
6885
6773
|
};
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
function
|
|
6890
|
-
|
|
6891
|
-
|
|
6774
|
+
}
|
|
6775
|
+
|
|
6776
|
+
exports.ShaderType = void 0;
|
|
6777
|
+
(function(ShaderType) {
|
|
6778
|
+
ShaderType[ShaderType["vertex"] = 0] = "vertex";
|
|
6779
|
+
ShaderType[ShaderType["fragment"] = 1] = "fragment";
|
|
6780
|
+
})(exports.ShaderType || (exports.ShaderType = {}));
|
|
6781
|
+
|
|
6782
|
+
function valIfUndefined(val, def) {
|
|
6783
|
+
if (val === undefined || val === null) {
|
|
6784
|
+
return def;
|
|
6892
6785
|
}
|
|
6893
|
-
return
|
|
6786
|
+
return val;
|
|
6894
6787
|
}
|
|
6895
|
-
function
|
|
6896
|
-
|
|
6788
|
+
function getPreMultiAlpha(blending) {
|
|
6789
|
+
switch(blending){
|
|
6790
|
+
case BlendingMode.ALPHA:
|
|
6791
|
+
return 1;
|
|
6792
|
+
case BlendingMode.ADD:
|
|
6793
|
+
return 1;
|
|
6794
|
+
case BlendingMode.SUBTRACTION:
|
|
6795
|
+
return 1;
|
|
6796
|
+
case BlendingMode.STRONG_LIGHT:
|
|
6797
|
+
return 1;
|
|
6798
|
+
case BlendingMode.WEAK_LIGHT:
|
|
6799
|
+
return 1;
|
|
6800
|
+
case BlendingMode.SUPERPOSITION:
|
|
6801
|
+
return 2;
|
|
6802
|
+
case BlendingMode.BRIGHTNESS:
|
|
6803
|
+
return 3;
|
|
6804
|
+
case BlendingMode.MULTIPLY:
|
|
6805
|
+
return 0;
|
|
6806
|
+
default:
|
|
6807
|
+
// 处理undefined
|
|
6808
|
+
return 1;
|
|
6809
|
+
}
|
|
6810
|
+
}
|
|
6811
|
+
function setBlendMode(material, blendMode) {
|
|
6812
|
+
switch(blendMode){
|
|
6813
|
+
case undefined:
|
|
6814
|
+
material.blendFunction = [
|
|
6815
|
+
glContext.ONE,
|
|
6816
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
6817
|
+
glContext.ONE,
|
|
6818
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
6819
|
+
];
|
|
6820
|
+
break;
|
|
6821
|
+
case BlendingMode.ALPHA:
|
|
6822
|
+
material.blendFunction = [
|
|
6823
|
+
glContext.ONE,
|
|
6824
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
6825
|
+
glContext.ONE,
|
|
6826
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
6827
|
+
];
|
|
6828
|
+
break;
|
|
6829
|
+
case BlendingMode.ADD:
|
|
6830
|
+
material.blendFunction = [
|
|
6831
|
+
glContext.ONE,
|
|
6832
|
+
glContext.ONE,
|
|
6833
|
+
glContext.ONE,
|
|
6834
|
+
glContext.ONE
|
|
6835
|
+
];
|
|
6836
|
+
break;
|
|
6837
|
+
case BlendingMode.SUBTRACTION:
|
|
6838
|
+
material.blendFunction = [
|
|
6839
|
+
glContext.ONE,
|
|
6840
|
+
glContext.ONE,
|
|
6841
|
+
glContext.ZERO,
|
|
6842
|
+
glContext.ONE
|
|
6843
|
+
];
|
|
6844
|
+
material.blendEquation = [
|
|
6845
|
+
glContext.FUNC_REVERSE_SUBTRACT,
|
|
6846
|
+
glContext.FUNC_REVERSE_SUBTRACT
|
|
6847
|
+
];
|
|
6848
|
+
break;
|
|
6849
|
+
case BlendingMode.SUPERPOSITION:
|
|
6850
|
+
material.blendFunction = [
|
|
6851
|
+
glContext.ONE,
|
|
6852
|
+
glContext.ONE,
|
|
6853
|
+
glContext.ONE,
|
|
6854
|
+
glContext.ONE
|
|
6855
|
+
];
|
|
6856
|
+
break;
|
|
6857
|
+
case BlendingMode.MULTIPLY:
|
|
6858
|
+
material.blendFunction = [
|
|
6859
|
+
glContext.DST_COLOR,
|
|
6860
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
6861
|
+
glContext.DST_COLOR,
|
|
6862
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
6863
|
+
];
|
|
6864
|
+
break;
|
|
6865
|
+
case BlendingMode.BRIGHTNESS:
|
|
6866
|
+
material.blendFunction = [
|
|
6867
|
+
glContext.ONE,
|
|
6868
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
6869
|
+
glContext.ONE,
|
|
6870
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
6871
|
+
];
|
|
6872
|
+
break;
|
|
6873
|
+
case BlendingMode.STRONG_LIGHT:
|
|
6874
|
+
material.blendFunction = [
|
|
6875
|
+
glContext.DST_COLOR,
|
|
6876
|
+
glContext.DST_ALPHA,
|
|
6877
|
+
glContext.ZERO,
|
|
6878
|
+
glContext.ONE
|
|
6879
|
+
];
|
|
6880
|
+
break;
|
|
6881
|
+
case BlendingMode.WEAK_LIGHT:
|
|
6882
|
+
material.blendFunction = [
|
|
6883
|
+
glContext.DST_COLOR,
|
|
6884
|
+
glContext.ZERO,
|
|
6885
|
+
glContext.ZERO,
|
|
6886
|
+
glContext.ONE
|
|
6887
|
+
];
|
|
6888
|
+
break;
|
|
6889
|
+
default:
|
|
6890
|
+
console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
|
|
6891
|
+
}
|
|
6892
|
+
}
|
|
6893
|
+
function setSideMode(material, side) {
|
|
6894
|
+
if (side === SideMode.DOUBLE) {
|
|
6895
|
+
material.culling = false;
|
|
6896
|
+
} else {
|
|
6897
|
+
material.culling = true;
|
|
6898
|
+
material.frontFace = glContext.CW;
|
|
6899
|
+
material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
|
|
6900
|
+
}
|
|
6901
|
+
}
|
|
6902
|
+
function setMaskMode(material, maskMode) {
|
|
6903
|
+
switch(maskMode){
|
|
6904
|
+
case undefined:
|
|
6905
|
+
material.stencilTest = false;
|
|
6906
|
+
break;
|
|
6907
|
+
case MaskMode.MASK:
|
|
6908
|
+
material.stencilTest = true;
|
|
6909
|
+
material.stencilFunc = [
|
|
6910
|
+
glContext.ALWAYS,
|
|
6911
|
+
glContext.ALWAYS
|
|
6912
|
+
];
|
|
6913
|
+
material.stencilOpZPass = [
|
|
6914
|
+
glContext.REPLACE,
|
|
6915
|
+
glContext.REPLACE
|
|
6916
|
+
];
|
|
6917
|
+
break;
|
|
6918
|
+
case MaskMode.OBSCURED:
|
|
6919
|
+
material.stencilTest = true;
|
|
6920
|
+
material.stencilFunc = [
|
|
6921
|
+
glContext.EQUAL,
|
|
6922
|
+
glContext.EQUAL
|
|
6923
|
+
];
|
|
6924
|
+
break;
|
|
6925
|
+
case MaskMode.REVERSE_OBSCURED:
|
|
6926
|
+
material.stencilTest = true;
|
|
6927
|
+
material.stencilFunc = [
|
|
6928
|
+
glContext.NOTEQUAL,
|
|
6929
|
+
glContext.NOTEQUAL
|
|
6930
|
+
];
|
|
6931
|
+
break;
|
|
6932
|
+
case MaskMode.NONE:
|
|
6933
|
+
material.stencilTest = false;
|
|
6934
|
+
break;
|
|
6935
|
+
default:
|
|
6936
|
+
console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
|
|
6937
|
+
}
|
|
6897
6938
|
}
|
|
6898
6939
|
|
|
6899
6940
|
/**
|
|
@@ -10145,7 +10186,7 @@ var integrate = "float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4
|
|
|
10145
10186
|
|
|
10146
10187
|
var itemVert = "precision highp float;attribute vec2 atlasOffset;attribute vec3 aPos;varying vec2 vTexCoord;varying vec3 vParams;varying vec4 vColor;uniform vec2 _Size;uniform vec3 _Scale;uniform vec4 _Color;uniform vec4 _TexParams;uniform vec4 _TexOffset;uniform mat4 effects_MatrixVP;uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixV;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvoid main(){vec4 texParams=_TexParams;vTexCoord=vec2(atlasOffset.xy*_TexOffset.zw+_TexOffset.xy);vColor=_Color;vParams=vec3(0.0,texParams.y,texParams.x);if(texParams.z==1.0){vec4 pos=vec4(aPos.xy*_Size,aPos.z,1.0);gl_Position=effects_MatrixVP*effects_ObjectToWorld*pos;}else{mat4 view=effects_MatrixV;vec3 camRight=vec3(view[0][0],view[1][0],view[2][0]);vec3 camUp=vec3(view[0][1],view[1][1],view[2][1]);vec3 worldPosition=vec3(effects_ObjectToWorld*vec4(0.0,0.0,0.0,1.0));vec3 vertexPosition=worldPosition+camRight*aPos.x*_Size.x*_Scale.x+camUp*aPos.y*_Size.y*_Scale.y;gl_Position=effects_MatrixVP*vec4(vertexPosition,1.0);}\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
|
|
10147
10188
|
|
|
10148
|
-
var itemFrag = "precision highp float;varying vec4 vColor;varying vec2 vTexCoord;varying vec3 vParams;uniform sampler2D _MainTex;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}void main(){vec4 color=vec4(0.);vec4 texColor=texture2D(_MainTex,vTexCoord.xy)
|
|
10189
|
+
var itemFrag = "precision highp float;varying vec4 vColor;varying vec2 vTexCoord;varying vec3 vParams;uniform sampler2D _MainTex;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}void main(){vec4 color=vec4(0.);\n#ifdef TRANSPARENT_VIDEO\nvec2 uv_rgb=vec2(vTexCoord.x*0.5000,vTexCoord.y);vec2 uv_alpha=vec2(vTexCoord.x*0.5000+0.5000,vTexCoord.y);vec3 rgb=texture2D(_MainTex,uv_rgb).rgb;float alpha=texture2D(_MainTex,uv_alpha).r;vec4 texColor=vec4(rgb/alpha,alpha);\n#else\nvec4 texColor=texture2D(_MainTex,vTexCoord.xy);\n#endif\ncolor=blendColor(texColor,vColor,floor(0.5+vParams.y));\n#ifdef ALPHA_CLIP\nif(vParams.z==0.&&color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}";
|
|
10149
10190
|
|
|
10150
10191
|
var particleFrag = "#version 100\nprecision mediump float;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}\n#define PATICLE_SHADER 1\nvarying float vLife;varying vec2 vTexCoord;varying vec4 vColor;uniform vec3 emissionColor;uniform float emissionIntensity;uniform sampler2D uMaskTex;uniform vec4 uColorParams;uniform vec2 uTexOffset;\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#ifdef USE_SPRITE\nvarying vec4 vTexCoordBlend;\n#endif\nvarying float vSeed;\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\n#ifdef USE_SPRITE\nvec4 getTextureColor(sampler2D tex,vec2 texCoord){if(vTexCoordBlend.w>0.){return mix(texture2D(tex,texCoord),texture2D(tex,vTexCoordBlend.xy+texCoord),vTexCoordBlend.z);}return texture2D(tex,texCoord);}\n#else\n#define getTextureColor texture2D\n#endif\n#ifndef WEBGL2\n#define round(a) floor(0.5+a)\n#endif\n#ifdef PREVIEW_BORDER\nvoid main(){gl_FragColor=uPreviewColor;}\n#else\nvoid main(){vec4 color=vec4(1.0);vec4 tempColor=vColor;vec2 texOffset=uTexOffset;if(vLife<0.){discard;}if(uColorParams.x>0.0){color=getTextureColor(uMaskTex,vTexCoord);}\n#ifdef COLOR_OVER_LIFETIME\n#ifndef ENABLE_VERTEX_TEXTURE\ntempColor*=texture2D(uColorOverLifetime,vec2(vLife,0.));\n#endif\n#endif\ncolor=blendColor(color,tempColor,round(uColorParams.y));if(color.a<=0.01&&uColorParams.w>0.){float _at=texture2D(uMaskTex,vTexCoord+texOffset).a+texture2D(uMaskTex,vTexCoord+texOffset*-1.).a;if(_at<=0.02){discard;}}vec3 emission=emissionColor*pow(2.0,emissionIntensity);color=vec4(pow(pow(color.rgb,vec3(2.2))+emission,vec3(1.0/2.2)),color.a);gl_FragColor=color;}\n#endif\n";
|
|
10151
10192
|
|
|
@@ -13104,7 +13145,28 @@ var Vector4Curve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
13104
13145
|
this.value.set(x, y, z, w);
|
|
13105
13146
|
return this.value;
|
|
13106
13147
|
};
|
|
13107
|
-
return Vector4Curve;
|
|
13148
|
+
return Vector4Curve;
|
|
13149
|
+
}(ValueGetter);
|
|
13150
|
+
var Vector2Curve = /*#__PURE__*/ function(ValueGetter) {
|
|
13151
|
+
_inherits(Vector2Curve, ValueGetter);
|
|
13152
|
+
function Vector2Curve() {
|
|
13153
|
+
var _this;
|
|
13154
|
+
_this = ValueGetter.apply(this, arguments) || this;
|
|
13155
|
+
_this.value = new Vector2();
|
|
13156
|
+
return _this;
|
|
13157
|
+
}
|
|
13158
|
+
var _proto = Vector2Curve.prototype;
|
|
13159
|
+
_proto.onCreate = function onCreate(arg) {
|
|
13160
|
+
this.xCurve = createValueGetter(arg[0]);
|
|
13161
|
+
this.yCurve = createValueGetter(arg[1]);
|
|
13162
|
+
};
|
|
13163
|
+
_proto.getValue = function getValue(t) {
|
|
13164
|
+
var x = this.xCurve.getValue(t);
|
|
13165
|
+
var y = this.yCurve.getValue(t);
|
|
13166
|
+
this.value.set(x, y);
|
|
13167
|
+
return this.value;
|
|
13168
|
+
};
|
|
13169
|
+
return Vector2Curve;
|
|
13108
13170
|
}(ValueGetter);
|
|
13109
13171
|
|
|
13110
13172
|
var SPRITE_VERTEX_STRIDE = 6;
|
|
@@ -13169,6 +13231,8 @@ var map$1 = (_obj$3 = {}, _obj$3[ValueType.RANDOM] = function(props) {
|
|
|
13169
13231
|
return new ColorCurve(props);
|
|
13170
13232
|
}, _obj$3[ValueType.VECTOR4_CURVE] = function(props) {
|
|
13171
13233
|
return new Vector4Curve(props);
|
|
13234
|
+
}, _obj$3[ValueType.VECTOR2_CURVE] = function(props) {
|
|
13235
|
+
return new Vector2Curve(props);
|
|
13172
13236
|
}, _obj$3);
|
|
13173
13237
|
function createValueGetter(args) {
|
|
13174
13238
|
if (!args || !isNaN(+args)) {
|
|
@@ -13293,13 +13357,39 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
13293
13357
|
this.color = color;
|
|
13294
13358
|
this.material.setVector4("_Color", new Vector4().setFromArray(color));
|
|
13295
13359
|
};
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
|
|
13360
|
+
_proto.setTexture = function setTexture(input) {
|
|
13361
|
+
var _this = this;
|
|
13362
|
+
return _async_to_generator(function() {
|
|
13363
|
+
var texture;
|
|
13364
|
+
return __generator(this, function(_state) {
|
|
13365
|
+
switch(_state.label){
|
|
13366
|
+
case 0:
|
|
13367
|
+
if (!(typeof input === "string")) return [
|
|
13368
|
+
3,
|
|
13369
|
+
2
|
|
13370
|
+
];
|
|
13371
|
+
return [
|
|
13372
|
+
4,
|
|
13373
|
+
Texture.fromImage(input, _this.item.engine)
|
|
13374
|
+
];
|
|
13375
|
+
case 1:
|
|
13376
|
+
texture = _state.sent();
|
|
13377
|
+
return [
|
|
13378
|
+
3,
|
|
13379
|
+
3
|
|
13380
|
+
];
|
|
13381
|
+
case 2:
|
|
13382
|
+
texture = input;
|
|
13383
|
+
_state.label = 3;
|
|
13384
|
+
case 3:
|
|
13385
|
+
_this.renderer.texture = texture;
|
|
13386
|
+
_this.material.setTexture("_MainTex", texture);
|
|
13387
|
+
return [
|
|
13388
|
+
2
|
|
13389
|
+
];
|
|
13390
|
+
}
|
|
13391
|
+
});
|
|
13392
|
+
})();
|
|
13303
13393
|
};
|
|
13304
13394
|
/**
|
|
13305
13395
|
* @internal
|
|
@@ -13478,11 +13568,14 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
13478
13568
|
maxVertex: 4
|
|
13479
13569
|
});
|
|
13480
13570
|
};
|
|
13481
|
-
_proto.
|
|
13482
|
-
|
|
13483
|
-
var materialProps = {
|
|
13571
|
+
_proto.getMaterialProps = function getMaterialProps(renderInfo, count) {
|
|
13572
|
+
return {
|
|
13484
13573
|
shader: spriteMeshShaderFromRenderInfo(renderInfo, count, 1)
|
|
13485
13574
|
};
|
|
13575
|
+
};
|
|
13576
|
+
_proto.createMaterial = function createMaterial(renderInfo, count) {
|
|
13577
|
+
var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
|
|
13578
|
+
var materialProps = this.getMaterialProps(renderInfo, count);
|
|
13486
13579
|
this.preMultiAlpha = getPreMultiAlpha(blending);
|
|
13487
13580
|
var material = Material.create(this.engine, materialProps);
|
|
13488
13581
|
var states = {
|
|
@@ -13561,6 +13654,8 @@ function getImageItemRenderInfo(item) {
|
|
|
13561
13654
|
};
|
|
13562
13655
|
}
|
|
13563
13656
|
|
|
13657
|
+
// Based on:
|
|
13658
|
+
// https://github.com/pixijs/pixijs/blob/dev/src/maths/shapes/ShapePrimitive.ts
|
|
13564
13659
|
var ShapePrimitive = function ShapePrimitive() {
|
|
13565
13660
|
};
|
|
13566
13661
|
|
|
@@ -14666,6 +14761,7 @@ function triangulate(contours) {
|
|
|
14666
14761
|
return triangleVerts;
|
|
14667
14762
|
}
|
|
14668
14763
|
|
|
14764
|
+
// Based on:
|
|
14669
14765
|
/**
|
|
14670
14766
|
* A class to define a shape via user defined coordinates.
|
|
14671
14767
|
*/ var Polygon = /*#__PURE__*/ function(ShapePrimitive) {
|
|
@@ -14765,12 +14861,13 @@ function triangulate(contours) {
|
|
|
14765
14861
|
var triangles = triangulate([
|
|
14766
14862
|
points
|
|
14767
14863
|
]);
|
|
14864
|
+
var indexStart = vertices.length / 2;
|
|
14768
14865
|
for(var i = 0; i < triangles.length; i++){
|
|
14769
|
-
vertices[verticesOffset + i] = triangles[i];
|
|
14866
|
+
vertices[verticesOffset * 2 + i] = triangles[i];
|
|
14770
14867
|
}
|
|
14771
14868
|
var vertexCount = triangles.length / 2;
|
|
14772
14869
|
for(var i1 = 0; i1 < vertexCount; i1++){
|
|
14773
|
-
indices[indicesOffset + i1] = i1;
|
|
14870
|
+
indices[indicesOffset + i1] = indexStart + i1;
|
|
14774
14871
|
}
|
|
14775
14872
|
};
|
|
14776
14873
|
_create_class(Polygon, [
|
|
@@ -14892,6 +14989,7 @@ function recursive(x1, y1, x2, y2, x3, y3, x4, y4, points, distanceTolerance, le
|
|
|
14892
14989
|
recursive(x1234, y1234, x234, y234, x34, y34, x4, y4, points, distanceTolerance, level + 1);
|
|
14893
14990
|
}
|
|
14894
14991
|
|
|
14992
|
+
// Based on:
|
|
14895
14993
|
/**
|
|
14896
14994
|
* The Ellipse object is used to help draw graphics and can also be used to specify a hit area for containers.
|
|
14897
14995
|
*/ var Ellipse = /*#__PURE__*/ function(ShapePrimitive) {
|
|
@@ -15098,6 +15196,7 @@ function recursive(x1, y1, x2, y2, x3, y3, x4, y4, points, distanceTolerance, le
|
|
|
15098
15196
|
return Ellipse;
|
|
15099
15197
|
}(ShapePrimitive);
|
|
15100
15198
|
|
|
15199
|
+
// Based on:
|
|
15101
15200
|
var StarType;
|
|
15102
15201
|
(function(StarType) {
|
|
15103
15202
|
StarType[StarType["Star"] = 0] = "Star";
|
|
@@ -15166,12 +15265,13 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
|
|
|
15166
15265
|
var triangles = triangulate([
|
|
15167
15266
|
points
|
|
15168
15267
|
]);
|
|
15268
|
+
var indexStart = vertices.length / 2;
|
|
15169
15269
|
for(var i = 0; i < triangles.length; i++){
|
|
15170
|
-
vertices[verticesOffset + i] = triangles[i];
|
|
15270
|
+
vertices[verticesOffset * 2 + i] = triangles[i];
|
|
15171
15271
|
}
|
|
15172
15272
|
var vertexCount = triangles.length / 2;
|
|
15173
15273
|
for(var i1 = 0; i1 < vertexCount; i1++){
|
|
15174
|
-
indices[indicesOffset + i1] = i1;
|
|
15274
|
+
indices[indicesOffset + i1] = indexStart + i1;
|
|
15175
15275
|
}
|
|
15176
15276
|
};
|
|
15177
15277
|
_proto.buildStarPath = function buildStarPath() {
|
|
@@ -15242,6 +15342,7 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
|
|
|
15242
15342
|
return PolyStar;
|
|
15243
15343
|
}(ShapePrimitive);
|
|
15244
15344
|
|
|
15345
|
+
// Based on:
|
|
15245
15346
|
// const tempPoints = [new Point(), new Point(), new Point(), new Point()];
|
|
15246
15347
|
/**
|
|
15247
15348
|
* The `Rectangle` object is an area defined by its position, as indicated by its upper-left corner
|
|
@@ -15565,6 +15666,7 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
|
|
|
15565
15666
|
return Rectangle;
|
|
15566
15667
|
}(ShapePrimitive);
|
|
15567
15668
|
|
|
15669
|
+
// Based on:
|
|
15568
15670
|
var ShapePath = /*#__PURE__*/ function() {
|
|
15569
15671
|
function ShapePath(graphicsPath) {
|
|
15570
15672
|
this.graphicsPath = graphicsPath;
|
|
@@ -15723,6 +15825,7 @@ var ShapePath = /*#__PURE__*/ function() {
|
|
|
15723
15825
|
return ShapePath;
|
|
15724
15826
|
}();
|
|
15725
15827
|
|
|
15828
|
+
// Based on:
|
|
15726
15829
|
var GraphicsPath = /*#__PURE__*/ function() {
|
|
15727
15830
|
function GraphicsPath() {
|
|
15728
15831
|
this.instructions = [];
|
|
@@ -15860,14 +15963,433 @@ var GraphicsPath = /*#__PURE__*/ function() {
|
|
|
15860
15963
|
return GraphicsPath;
|
|
15861
15964
|
}();
|
|
15862
15965
|
|
|
15966
|
+
// Based on:
|
|
15967
|
+
/**
|
|
15968
|
+
* The Point object represents a location in a two-dimensional coordinate system, where `x` represents
|
|
15969
|
+
* the position on the horizontal axis and `y` represents the position on the vertical axis.
|
|
15970
|
+
*/ var Point = /*#__PURE__*/ function() {
|
|
15971
|
+
function Point(x, y) {
|
|
15972
|
+
if (x === void 0) x = 0;
|
|
15973
|
+
if (y === void 0) y = 0;
|
|
15974
|
+
/**
|
|
15975
|
+
* Position of the point on the x axis
|
|
15976
|
+
*/ this.x = 0;
|
|
15977
|
+
/**
|
|
15978
|
+
* Position of the point on the y axis
|
|
15979
|
+
*/ this.y = 0;
|
|
15980
|
+
this.x = x;
|
|
15981
|
+
this.y = y;
|
|
15982
|
+
}
|
|
15983
|
+
var _proto = Point.prototype;
|
|
15984
|
+
/**
|
|
15985
|
+
* Creates a clone of this point
|
|
15986
|
+
* @returns A clone of this point
|
|
15987
|
+
*/ _proto.clone = function clone() {
|
|
15988
|
+
return new Point(this.x, this.y);
|
|
15989
|
+
};
|
|
15990
|
+
/**
|
|
15991
|
+
* Copies `x` and `y` from the given point into this point
|
|
15992
|
+
* @param p - The point to copy from
|
|
15993
|
+
* @returns The point instance itself
|
|
15994
|
+
*/ _proto.copyFrom = function copyFrom(p) {
|
|
15995
|
+
this.set(p.x, p.y);
|
|
15996
|
+
return this;
|
|
15997
|
+
};
|
|
15998
|
+
/**
|
|
15999
|
+
* Copies this point's x and y into the given point (`p`).
|
|
16000
|
+
* @param p - The point to copy to. Can be any of type that is or extends `PointData`
|
|
16001
|
+
* @returns The point (`p`) with values updated
|
|
16002
|
+
*/ _proto.copyTo = function copyTo(p) {
|
|
16003
|
+
p.set(this.x, this.y);
|
|
16004
|
+
return p;
|
|
16005
|
+
};
|
|
16006
|
+
/**
|
|
16007
|
+
* Accepts another point (`p`) and returns `true` if the given point is equal to this point
|
|
16008
|
+
* @param p - The point to check
|
|
16009
|
+
* @returns Returns `true` if both `x` and `y` are equal
|
|
16010
|
+
*/ _proto.equals = function equals(p) {
|
|
16011
|
+
return p.x === this.x && p.y === this.y;
|
|
16012
|
+
};
|
|
16013
|
+
/**
|
|
16014
|
+
* Sets the point to a new `x` and `y` position.
|
|
16015
|
+
* If `y` is omitted, both `x` and `y` will be set to `x`.
|
|
16016
|
+
* @param {number} [x=0] - position of the point on the `x` axis
|
|
16017
|
+
* @param {number} [y=x] - position of the point on the `y` axis
|
|
16018
|
+
* @returns The point instance itself
|
|
16019
|
+
*/ _proto.set = function set(x, y) {
|
|
16020
|
+
if (x === void 0) x = 0;
|
|
16021
|
+
if (y === void 0) y = x;
|
|
16022
|
+
this.x = x;
|
|
16023
|
+
this.y = y;
|
|
16024
|
+
return this;
|
|
16025
|
+
};
|
|
16026
|
+
_create_class(Point, null, [
|
|
16027
|
+
{
|
|
16028
|
+
key: "shared",
|
|
16029
|
+
get: /**
|
|
16030
|
+
* A static Point object with `x` and `y` values of `0`. Can be used to avoid creating new objects multiple times.
|
|
16031
|
+
* @readonly
|
|
16032
|
+
*/ function get() {
|
|
16033
|
+
tempPoint.x = 0;
|
|
16034
|
+
tempPoint.y = 0;
|
|
16035
|
+
return tempPoint;
|
|
16036
|
+
}
|
|
16037
|
+
}
|
|
16038
|
+
]);
|
|
16039
|
+
return Point;
|
|
16040
|
+
}();
|
|
16041
|
+
var tempPoint = new Point();
|
|
16042
|
+
|
|
16043
|
+
// Based on:
|
|
16044
|
+
var closePointEps = 1e-4;
|
|
16045
|
+
var curveEps = 0.0001;
|
|
16046
|
+
/**
|
|
16047
|
+
* Buffers vertices to draw a square cap.
|
|
16048
|
+
*
|
|
16049
|
+
* @internal
|
|
16050
|
+
* @private
|
|
16051
|
+
* @param x - X-coord of end point
|
|
16052
|
+
* @param y - Y-coord of end point
|
|
16053
|
+
* @param nx - X-coord of line normal pointing inside
|
|
16054
|
+
* @param ny - Y-coord of line normal pointing inside
|
|
16055
|
+
* @param innerWeight - Weight of inner points
|
|
16056
|
+
* @param outerWeight - Weight of outer points
|
|
16057
|
+
* @param clockwise - Whether the cap is drawn clockwise
|
|
16058
|
+
* @param verts - vertex buffer
|
|
16059
|
+
* @returns - no. of vertices pushed
|
|
16060
|
+
*/ function square(x, y, nx, ny, innerWeight, outerWeight, clockwise, /* rotation for square (true at left end, false at right end) */ verts) {
|
|
16061
|
+
var ix = x - nx * innerWeight;
|
|
16062
|
+
var iy = y - ny * innerWeight;
|
|
16063
|
+
var ox = x + nx * outerWeight;
|
|
16064
|
+
var oy = y + ny * outerWeight;
|
|
16065
|
+
/* Rotate nx,ny for extension vector */ var exx;
|
|
16066
|
+
var eyy;
|
|
16067
|
+
if (clockwise) {
|
|
16068
|
+
exx = ny;
|
|
16069
|
+
eyy = -nx;
|
|
16070
|
+
} else {
|
|
16071
|
+
exx = -ny;
|
|
16072
|
+
eyy = nx;
|
|
16073
|
+
}
|
|
16074
|
+
/* [i|0]x,y extended at cap */ var eix = ix + exx;
|
|
16075
|
+
var eiy = iy + eyy;
|
|
16076
|
+
var eox = ox + exx;
|
|
16077
|
+
var eoy = oy + eyy;
|
|
16078
|
+
/* Square itself must be inserted clockwise*/ verts.push(eix, eiy);
|
|
16079
|
+
verts.push(eox, eoy);
|
|
16080
|
+
return 2;
|
|
16081
|
+
}
|
|
16082
|
+
/**
|
|
16083
|
+
* Buffers vertices to draw an arc at the line joint or cap.
|
|
16084
|
+
*
|
|
16085
|
+
* @internal
|
|
16086
|
+
* @private
|
|
16087
|
+
* @param cx - X-coord of center
|
|
16088
|
+
* @param cy - Y-coord of center
|
|
16089
|
+
* @param sx - X-coord of arc start
|
|
16090
|
+
* @param sy - Y-coord of arc start
|
|
16091
|
+
* @param ex - X-coord of arc end
|
|
16092
|
+
* @param ey - Y-coord of arc end
|
|
16093
|
+
* @param verts - buffer of vertices
|
|
16094
|
+
* @param clockwise - orientation of vertices
|
|
16095
|
+
* @returns - no. of vertices pushed
|
|
16096
|
+
*/ function round(cx, cy, sx, sy, ex, ey, verts, clockwise) {
|
|
16097
|
+
var cx2p0x = sx - cx;
|
|
16098
|
+
var cy2p0y = sy - cy;
|
|
16099
|
+
var angle0 = Math.atan2(cx2p0x, cy2p0y);
|
|
16100
|
+
var angle1 = Math.atan2(ex - cx, ey - cy);
|
|
16101
|
+
if (clockwise && angle0 < angle1) {
|
|
16102
|
+
angle0 += Math.PI * 2;
|
|
16103
|
+
} else if (!clockwise && angle0 > angle1) {
|
|
16104
|
+
angle1 += Math.PI * 2;
|
|
16105
|
+
}
|
|
16106
|
+
var startAngle = angle0;
|
|
16107
|
+
var angleDiff = angle1 - angle0;
|
|
16108
|
+
var absAngleDiff = Math.abs(angleDiff);
|
|
16109
|
+
var radius = Math.sqrt(cx2p0x * cx2p0x + cy2p0y * cy2p0y);
|
|
16110
|
+
var segCount = (15 * absAngleDiff * Math.sqrt(radius) / Math.PI >> 0) + 1;
|
|
16111
|
+
var angleInc = angleDiff / segCount;
|
|
16112
|
+
startAngle += angleInc;
|
|
16113
|
+
if (clockwise) {
|
|
16114
|
+
verts.push(cx, cy);
|
|
16115
|
+
verts.push(sx, sy);
|
|
16116
|
+
for(var i = 1, angle = startAngle; i < segCount; i++, angle += angleInc){
|
|
16117
|
+
verts.push(cx, cy);
|
|
16118
|
+
verts.push(cx + Math.sin(angle) * radius, cy + Math.cos(angle) * radius);
|
|
16119
|
+
}
|
|
16120
|
+
verts.push(cx, cy);
|
|
16121
|
+
verts.push(ex, ey);
|
|
16122
|
+
} else {
|
|
16123
|
+
verts.push(sx, sy);
|
|
16124
|
+
verts.push(cx, cy);
|
|
16125
|
+
for(var i1 = 1, angle2 = startAngle; i1 < segCount; i1++, angle2 += angleInc){
|
|
16126
|
+
verts.push(cx + Math.sin(angle2) * radius, cy + Math.cos(angle2) * radius);
|
|
16127
|
+
verts.push(cx, cy);
|
|
16128
|
+
}
|
|
16129
|
+
verts.push(ex, ey);
|
|
16130
|
+
verts.push(cx, cy);
|
|
16131
|
+
}
|
|
16132
|
+
return segCount * 2;
|
|
16133
|
+
}
|
|
16134
|
+
function getOrientationOfPoints(points) {
|
|
16135
|
+
var m = points.length;
|
|
16136
|
+
if (m < 6) {
|
|
16137
|
+
return 1;
|
|
16138
|
+
}
|
|
16139
|
+
var area = 0;
|
|
16140
|
+
for(var i = 0, x1 = points[m - 2], y1 = points[m - 1]; i < m; i += 2){
|
|
16141
|
+
var x2 = points[i];
|
|
16142
|
+
var y2 = points[i + 1];
|
|
16143
|
+
area += (x2 - x1) * (y2 + y1);
|
|
16144
|
+
x1 = x2;
|
|
16145
|
+
y1 = y2;
|
|
16146
|
+
}
|
|
16147
|
+
if (area < 0) {
|
|
16148
|
+
return -1;
|
|
16149
|
+
}
|
|
16150
|
+
return 1;
|
|
16151
|
+
}
|
|
16152
|
+
/**
|
|
16153
|
+
* Builds a line to draw using the polygon method.
|
|
16154
|
+
* @param points
|
|
16155
|
+
* @param lineStyle
|
|
16156
|
+
* @param flipAlignment
|
|
16157
|
+
* @param closed
|
|
16158
|
+
* @param vertices
|
|
16159
|
+
* @param _verticesStride
|
|
16160
|
+
* @param _verticesOffset
|
|
16161
|
+
* @param indices
|
|
16162
|
+
* @param _indicesOffset
|
|
16163
|
+
*/ function buildLine(points, lineStyle, flipAlignment, closed, // alignment:number,
|
|
16164
|
+
vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
|
|
16165
|
+
// const shape = graphicsData.shape as Polygon;
|
|
16166
|
+
// let points = graphicsData.points || shape.points.slice();
|
|
16167
|
+
var eps = closePointEps;
|
|
16168
|
+
if (points.length === 0) {
|
|
16169
|
+
return;
|
|
16170
|
+
}
|
|
16171
|
+
var style = lineStyle;
|
|
16172
|
+
var alignment = style.alignment;
|
|
16173
|
+
if (lineStyle.alignment !== 0.5) {
|
|
16174
|
+
// rotate the points!
|
|
16175
|
+
var orientation = getOrientationOfPoints(points);
|
|
16176
|
+
if (flipAlignment) {
|
|
16177
|
+
orientation *= -1;
|
|
16178
|
+
}
|
|
16179
|
+
alignment = (alignment - 0.5) * orientation + 0.5;
|
|
16180
|
+
}
|
|
16181
|
+
// get first and last point.. figure out the middle!
|
|
16182
|
+
var firstPoint = new Point(points[0], points[1]);
|
|
16183
|
+
var lastPoint = new Point(points[points.length - 2], points[points.length - 1]);
|
|
16184
|
+
var closedShape = closed;
|
|
16185
|
+
var closedPath = Math.abs(firstPoint.x - lastPoint.x) < eps && Math.abs(firstPoint.y - lastPoint.y) < eps;
|
|
16186
|
+
// if the first point is the last point - gonna have issues :)
|
|
16187
|
+
if (closedShape) {
|
|
16188
|
+
// need to clone as we are going to slightly modify the shape..
|
|
16189
|
+
points = points.slice();
|
|
16190
|
+
if (closedPath) {
|
|
16191
|
+
points.pop();
|
|
16192
|
+
points.pop();
|
|
16193
|
+
lastPoint.set(points[points.length - 2], points[points.length - 1]);
|
|
16194
|
+
}
|
|
16195
|
+
var midPointX = (firstPoint.x + lastPoint.x) * 0.5;
|
|
16196
|
+
var midPointY = (lastPoint.y + firstPoint.y) * 0.5;
|
|
16197
|
+
points.unshift(midPointX, midPointY);
|
|
16198
|
+
points.push(midPointX, midPointY);
|
|
16199
|
+
}
|
|
16200
|
+
var verts = vertices;
|
|
16201
|
+
var length = points.length / 2;
|
|
16202
|
+
var indexCount = points.length;
|
|
16203
|
+
var indexStart = verts.length / 2;
|
|
16204
|
+
// Max. inner and outer width
|
|
16205
|
+
var width = style.width / 2;
|
|
16206
|
+
var widthSquared = width * width;
|
|
16207
|
+
var miterLimitSquared = style.miterLimit * style.miterLimit;
|
|
16208
|
+
/* Line segments of interest where (x1,y1) forms the corner. */ var x0 = points[0];
|
|
16209
|
+
var y0 = points[1];
|
|
16210
|
+
var x1 = points[2];
|
|
16211
|
+
var y1 = points[3];
|
|
16212
|
+
var x2 = 0;
|
|
16213
|
+
var y2 = 0;
|
|
16214
|
+
/* perp[?](x|y) = the line normal with magnitude lineWidth. */ var perpX = -(y0 - y1);
|
|
16215
|
+
var perpY = x0 - x1;
|
|
16216
|
+
var perp1x = 0;
|
|
16217
|
+
var perp1y = 0;
|
|
16218
|
+
var dist = Math.sqrt(perpX * perpX + perpY * perpY);
|
|
16219
|
+
perpX /= dist;
|
|
16220
|
+
perpY /= dist;
|
|
16221
|
+
perpX *= width;
|
|
16222
|
+
perpY *= width;
|
|
16223
|
+
var ratio = alignment; // 0.5;
|
|
16224
|
+
var innerWeight = (1 - ratio) * 2;
|
|
16225
|
+
var outerWeight = ratio * 2;
|
|
16226
|
+
if (!closedShape) {
|
|
16227
|
+
if (style.cap === "round") {
|
|
16228
|
+
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;
|
|
16229
|
+
} else if (style.cap === "square") {
|
|
16230
|
+
indexCount += square(x0, y0, perpX, perpY, innerWeight, outerWeight, true, verts);
|
|
16231
|
+
}
|
|
16232
|
+
}
|
|
16233
|
+
// Push first point (below & above vertices)
|
|
16234
|
+
verts.push(x0 - perpX * innerWeight, y0 - perpY * innerWeight);
|
|
16235
|
+
verts.push(x0 + perpX * outerWeight, y0 + perpY * outerWeight);
|
|
16236
|
+
for(var i = 1; i < length - 1; ++i){
|
|
16237
|
+
x0 = points[(i - 1) * 2];
|
|
16238
|
+
y0 = points[(i - 1) * 2 + 1];
|
|
16239
|
+
x1 = points[i * 2];
|
|
16240
|
+
y1 = points[i * 2 + 1];
|
|
16241
|
+
x2 = points[(i + 1) * 2];
|
|
16242
|
+
y2 = points[(i + 1) * 2 + 1];
|
|
16243
|
+
perpX = -(y0 - y1);
|
|
16244
|
+
perpY = x0 - x1;
|
|
16245
|
+
dist = Math.sqrt(perpX * perpX + perpY * perpY);
|
|
16246
|
+
perpX /= dist;
|
|
16247
|
+
perpY /= dist;
|
|
16248
|
+
perpX *= width;
|
|
16249
|
+
perpY *= width;
|
|
16250
|
+
perp1x = -(y1 - y2);
|
|
16251
|
+
perp1y = x1 - x2;
|
|
16252
|
+
dist = Math.sqrt(perp1x * perp1x + perp1y * perp1y);
|
|
16253
|
+
perp1x /= dist;
|
|
16254
|
+
perp1y /= dist;
|
|
16255
|
+
perp1x *= width;
|
|
16256
|
+
perp1y *= width;
|
|
16257
|
+
/* d[x|y](0|1) = the component displacement between points p(0,1|1,2) */ var dx0 = x1 - x0;
|
|
16258
|
+
var dy0 = y0 - y1;
|
|
16259
|
+
var dx1 = x1 - x2;
|
|
16260
|
+
var dy1 = y2 - y1;
|
|
16261
|
+
/* +ve if internal angle < 90 degree, -ve if internal angle > 90 degree. */ var dot = dx0 * dx1 + dy0 * dy1;
|
|
16262
|
+
/* +ve if internal angle counterclockwise, -ve if internal angle clockwise. */ var cross = dy0 * dx1 - dy1 * dx0;
|
|
16263
|
+
var clockwise = cross < 0;
|
|
16264
|
+
/* Going nearly parallel? */ /* atan(0.001) ~= 0.001 rad ~= 0.057 degree */ if (Math.abs(cross) < 0.001 * Math.abs(dot)) {
|
|
16265
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
|
|
16266
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
|
|
16267
|
+
/* 180 degree corner? */ if (dot >= 0) {
|
|
16268
|
+
if (style.join === "round") {
|
|
16269
|
+
indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 4;
|
|
16270
|
+
} else {
|
|
16271
|
+
indexCount += 2;
|
|
16272
|
+
}
|
|
16273
|
+
verts.push(x1 - perp1x * outerWeight, y1 - perp1y * outerWeight);
|
|
16274
|
+
verts.push(x1 + perp1x * innerWeight, y1 + perp1y * innerWeight);
|
|
16275
|
+
}
|
|
16276
|
+
continue;
|
|
16277
|
+
}
|
|
16278
|
+
/* 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);
|
|
16279
|
+
var c2 = (-perp1x + x2) * (-perp1y + y1) - (-perp1x + x1) * (-perp1y + y2);
|
|
16280
|
+
var px = (dx0 * c2 - dx1 * c1) / cross;
|
|
16281
|
+
var py = (dy1 * c1 - dy0 * c2) / cross;
|
|
16282
|
+
var pDist = (px - x1) * (px - x1) + (py - y1) * (py - y1);
|
|
16283
|
+
/* Inner miter point */ var imx = x1 + (px - x1) * innerWeight;
|
|
16284
|
+
var imy = y1 + (py - y1) * innerWeight;
|
|
16285
|
+
/* Outer miter point */ var omx = x1 - (px - x1) * outerWeight;
|
|
16286
|
+
var omy = y1 - (py - y1) * outerWeight;
|
|
16287
|
+
/* Is the inside miter point too far away, creating a spike? */ var smallerInsideSegmentSq = Math.min(dx0 * dx0 + dy0 * dy0, dx1 * dx1 + dy1 * dy1);
|
|
16288
|
+
var insideWeight = clockwise ? innerWeight : outerWeight;
|
|
16289
|
+
var smallerInsideDiagonalSq = smallerInsideSegmentSq + insideWeight * insideWeight * widthSquared;
|
|
16290
|
+
var insideMiterOk = pDist <= smallerInsideDiagonalSq;
|
|
16291
|
+
if (insideMiterOk) {
|
|
16292
|
+
if (style.join === "bevel" || pDist / widthSquared > miterLimitSquared) {
|
|
16293
|
+
if (clockwise) /* rotating at inner angle */ {
|
|
16294
|
+
verts.push(imx, imy); // inner miter point
|
|
16295
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
|
|
16296
|
+
verts.push(imx, imy); // inner miter point
|
|
16297
|
+
verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight); // second segment's outer vertex
|
|
16298
|
+
} else /* rotating at outer angle */ {
|
|
16299
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight); // first segment's inner vertex
|
|
16300
|
+
verts.push(omx, omy); // outer miter point
|
|
16301
|
+
verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight); // second segment's outer vertex
|
|
16302
|
+
verts.push(omx, omy); // outer miter point
|
|
16303
|
+
}
|
|
16304
|
+
indexCount += 2;
|
|
16305
|
+
} else if (style.join === "round") {
|
|
16306
|
+
if (clockwise) /* arc is outside */ {
|
|
16307
|
+
verts.push(imx, imy);
|
|
16308
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
|
|
16309
|
+
indexCount += round(x1, y1, x1 + perpX * outerWeight, y1 + perpY * outerWeight, x1 + perp1x * outerWeight, y1 + perp1y * outerWeight, verts, true) + 4;
|
|
16310
|
+
verts.push(imx, imy);
|
|
16311
|
+
verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight);
|
|
16312
|
+
} else /* arc is inside */ {
|
|
16313
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
|
|
16314
|
+
verts.push(omx, omy);
|
|
16315
|
+
indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 4;
|
|
16316
|
+
verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight);
|
|
16317
|
+
verts.push(omx, omy);
|
|
16318
|
+
}
|
|
16319
|
+
} else {
|
|
16320
|
+
verts.push(imx, imy);
|
|
16321
|
+
verts.push(omx, omy);
|
|
16322
|
+
}
|
|
16323
|
+
} else {
|
|
16324
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight); // first segment's inner vertex
|
|
16325
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
|
|
16326
|
+
if (style.join === "round") {
|
|
16327
|
+
if (clockwise) /* arc is outside */ {
|
|
16328
|
+
indexCount += round(x1, y1, x1 + perpX * outerWeight, y1 + perpY * outerWeight, x1 + perp1x * outerWeight, y1 + perp1y * outerWeight, verts, true) + 2;
|
|
16329
|
+
} else /* arc is inside */ {
|
|
16330
|
+
indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 2;
|
|
16331
|
+
}
|
|
16332
|
+
} else if (style.join === "miter" && pDist / widthSquared <= miterLimitSquared) {
|
|
16333
|
+
if (clockwise) {
|
|
16334
|
+
verts.push(omx, omy); // inner miter point
|
|
16335
|
+
verts.push(omx, omy); // inner miter point
|
|
16336
|
+
} else {
|
|
16337
|
+
verts.push(imx, imy); // outer miter point
|
|
16338
|
+
verts.push(imx, imy); // outer miter point
|
|
16339
|
+
}
|
|
16340
|
+
indexCount += 2;
|
|
16341
|
+
}
|
|
16342
|
+
verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight); // second segment's inner vertex
|
|
16343
|
+
verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight); // second segment's outer vertex
|
|
16344
|
+
indexCount += 2;
|
|
16345
|
+
}
|
|
16346
|
+
}
|
|
16347
|
+
x0 = points[(length - 2) * 2];
|
|
16348
|
+
y0 = points[(length - 2) * 2 + 1];
|
|
16349
|
+
x1 = points[(length - 1) * 2];
|
|
16350
|
+
y1 = points[(length - 1) * 2 + 1];
|
|
16351
|
+
perpX = -(y0 - y1);
|
|
16352
|
+
perpY = x0 - x1;
|
|
16353
|
+
dist = Math.sqrt(perpX * perpX + perpY * perpY);
|
|
16354
|
+
perpX /= dist;
|
|
16355
|
+
perpY /= dist;
|
|
16356
|
+
perpX *= width;
|
|
16357
|
+
perpY *= width;
|
|
16358
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
|
|
16359
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
|
|
16360
|
+
if (!closedShape) {
|
|
16361
|
+
if (style.cap === "round") {
|
|
16362
|
+
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;
|
|
16363
|
+
} else if (style.cap === "square") {
|
|
16364
|
+
indexCount += square(x1, y1, perpX, perpY, innerWeight, outerWeight, false, verts);
|
|
16365
|
+
}
|
|
16366
|
+
}
|
|
16367
|
+
// const indices = graphicsGeometry.indices;
|
|
16368
|
+
var eps2 = curveEps * curveEps;
|
|
16369
|
+
// indices.push(indexStart);
|
|
16370
|
+
for(var i1 = indexStart; i1 < indexCount + indexStart - 2; ++i1){
|
|
16371
|
+
x0 = verts[i1 * 2];
|
|
16372
|
+
y0 = verts[i1 * 2 + 1];
|
|
16373
|
+
x1 = verts[(i1 + 1) * 2];
|
|
16374
|
+
y1 = verts[(i1 + 1) * 2 + 1];
|
|
16375
|
+
x2 = verts[(i1 + 2) * 2];
|
|
16376
|
+
y2 = verts[(i1 + 2) * 2 + 1];
|
|
16377
|
+
/* Skip zero area triangles */ if (Math.abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) < eps2) {
|
|
16378
|
+
continue;
|
|
16379
|
+
}
|
|
16380
|
+
indices.push(i1, i1 + 1, i1 + 2);
|
|
16381
|
+
}
|
|
16382
|
+
}
|
|
16383
|
+
|
|
15863
16384
|
exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
15864
16385
|
_inherits(ShapeComponent, MeshComponent);
|
|
15865
16386
|
function ShapeComponent(engine) {
|
|
15866
16387
|
var _this;
|
|
15867
16388
|
_this = MeshComponent.call(this, engine) || this;
|
|
15868
|
-
_this.
|
|
16389
|
+
_this.isStroke = false;
|
|
16390
|
+
_this.graphicsPath = new GraphicsPath();
|
|
15869
16391
|
_this.curveValues = [];
|
|
15870
|
-
_this.
|
|
16392
|
+
_this.shapeDirty = true;
|
|
15871
16393
|
_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";
|
|
15872
16394
|
_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";
|
|
15873
16395
|
if (!_this.geometry) {
|
|
@@ -15915,6 +16437,20 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15915
16437
|
_this.material.depthTest = true;
|
|
15916
16438
|
_this.material.blending = true;
|
|
15917
16439
|
}
|
|
16440
|
+
_this.strokeAttributes = {
|
|
16441
|
+
width: 1,
|
|
16442
|
+
alignment: 0.5,
|
|
16443
|
+
cap: "butt",
|
|
16444
|
+
join: "miter",
|
|
16445
|
+
miterLimit: 10
|
|
16446
|
+
};
|
|
16447
|
+
_this.shapeAttribute = {
|
|
16448
|
+
type: ShapePrimitiveType.Custom,
|
|
16449
|
+
points: [],
|
|
16450
|
+
easingIns: [],
|
|
16451
|
+
easingOuts: [],
|
|
16452
|
+
shapes: []
|
|
16453
|
+
};
|
|
15918
16454
|
return _this;
|
|
15919
16455
|
}
|
|
15920
16456
|
var _proto = ShapeComponent.prototype;
|
|
@@ -15922,10 +16458,10 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15922
16458
|
this.item.getHitTestParams = this.getHitTestParams;
|
|
15923
16459
|
};
|
|
15924
16460
|
_proto.onUpdate = function onUpdate(dt) {
|
|
15925
|
-
if (this.
|
|
15926
|
-
this.buildPath(this.
|
|
15927
|
-
this.buildGeometryFromPath(this.
|
|
15928
|
-
this.
|
|
16461
|
+
if (this.shapeDirty) {
|
|
16462
|
+
this.buildPath(this.shapeAttribute);
|
|
16463
|
+
this.buildGeometryFromPath(this.graphicsPath.shapePath);
|
|
16464
|
+
this.shapeDirty = false;
|
|
15929
16465
|
}
|
|
15930
16466
|
};
|
|
15931
16467
|
_proto.buildGeometryFromPath = function buildGeometryFromPath(shapePath) {
|
|
@@ -15940,7 +16476,13 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15940
16476
|
var indexOffset = indices.length;
|
|
15941
16477
|
var vertOffset = vertices.length / 2;
|
|
15942
16478
|
shape.build(points);
|
|
15943
|
-
|
|
16479
|
+
if (!this.isStroke) {
|
|
16480
|
+
shape.triangulate(points, vertices, vertOffset, indices, indexOffset);
|
|
16481
|
+
} else {
|
|
16482
|
+
var close = true;
|
|
16483
|
+
var lineStyle = this.strokeAttributes;
|
|
16484
|
+
buildLine(points, lineStyle, false, close, vertices, 2, vertOffset, indices);
|
|
16485
|
+
}
|
|
15944
16486
|
}
|
|
15945
16487
|
var vertexCount = vertices.length / 2;
|
|
15946
16488
|
// get the current attribute and index arrays from the geometry, avoiding re-creation
|
|
@@ -15953,7 +16495,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15953
16495
|
if (!uvArray || uvArray.length < vertexCount * 2) {
|
|
15954
16496
|
uvArray = new Float32Array(vertexCount * 2);
|
|
15955
16497
|
}
|
|
15956
|
-
if (!indexArray) {
|
|
16498
|
+
if (!indexArray || indexArray.length < indices.length) {
|
|
15957
16499
|
indexArray = new Uint16Array(indices.length);
|
|
15958
16500
|
}
|
|
15959
16501
|
// set position and uv attribute array
|
|
@@ -15975,19 +16517,18 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15975
16517
|
this.geometry.setIndexData(indexArray);
|
|
15976
16518
|
this.geometry.setDrawCount(indices.length);
|
|
15977
16519
|
};
|
|
15978
|
-
_proto.buildPath = function buildPath(
|
|
15979
|
-
this.
|
|
15980
|
-
|
|
15981
|
-
switch(shapeData.type){
|
|
16520
|
+
_proto.buildPath = function buildPath(shapeAttribute) {
|
|
16521
|
+
this.graphicsPath.clear();
|
|
16522
|
+
switch(shapeAttribute.type){
|
|
15982
16523
|
case ShapePrimitiveType.Custom:
|
|
15983
16524
|
{
|
|
15984
|
-
var
|
|
15985
|
-
var points =
|
|
15986
|
-
var easingIns =
|
|
15987
|
-
var easingOuts =
|
|
15988
|
-
|
|
15989
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(customData.shapes), _step; !(_step = _iterator()).done;){
|
|
16525
|
+
var customShapeAtribute = this.shapeAttribute;
|
|
16526
|
+
var points = customShapeAtribute.points;
|
|
16527
|
+
var easingIns = customShapeAtribute.easingIns;
|
|
16528
|
+
var easingOuts = customShapeAtribute.easingOuts;
|
|
16529
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(customShapeAtribute.shapes), _step; !(_step = _iterator()).done;){
|
|
15990
16530
|
var shape = _step.value;
|
|
16531
|
+
this.curveValues = [];
|
|
15991
16532
|
this.setFillColor(shape.fill);
|
|
15992
16533
|
var indices = shape.indexes;
|
|
15993
16534
|
for(var i = 1; i < indices.length; i++){
|
|
@@ -16005,42 +16546,42 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
16005
16546
|
controlPoint1: easingOuts[indices[indices.length - 1].easingOut],
|
|
16006
16547
|
controlPoint2: easingIns[indices[0].easingIn]
|
|
16007
16548
|
});
|
|
16008
|
-
|
|
16009
|
-
|
|
16010
|
-
|
|
16011
|
-
|
|
16012
|
-
|
|
16013
|
-
|
|
16014
|
-
|
|
16015
|
-
|
|
16549
|
+
this.graphicsPath.moveTo(this.curveValues[this.curveValues.length - 1].point.x, this.curveValues[this.curveValues.length - 1].point.y);
|
|
16550
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(this.curveValues), _step1; !(_step1 = _iterator1()).done;){
|
|
16551
|
+
var curveValue = _step1.value;
|
|
16552
|
+
var point = curveValue.point;
|
|
16553
|
+
var control1 = curveValue.controlPoint1;
|
|
16554
|
+
var control2 = curveValue.controlPoint2;
|
|
16555
|
+
this.graphicsPath.bezierCurveTo(control1.x, control1.y, control2.x, control2.y, point.x, point.y, 1);
|
|
16556
|
+
}
|
|
16016
16557
|
}
|
|
16017
16558
|
break;
|
|
16018
16559
|
}
|
|
16019
16560
|
case ShapePrimitiveType.Ellipse:
|
|
16020
16561
|
{
|
|
16021
|
-
var ellipseData =
|
|
16022
|
-
this.
|
|
16562
|
+
var ellipseData = shapeAttribute;
|
|
16563
|
+
this.graphicsPath.ellipse(0, 0, ellipseData.xRadius, ellipseData.yRadius);
|
|
16023
16564
|
this.setFillColor(ellipseData.fill);
|
|
16024
16565
|
break;
|
|
16025
16566
|
}
|
|
16026
16567
|
case ShapePrimitiveType.Rectangle:
|
|
16027
16568
|
{
|
|
16028
|
-
var rectangleData =
|
|
16029
|
-
this.
|
|
16569
|
+
var rectangleData = shapeAttribute;
|
|
16570
|
+
this.graphicsPath.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height);
|
|
16030
16571
|
this.setFillColor(rectangleData.fill);
|
|
16031
16572
|
break;
|
|
16032
16573
|
}
|
|
16033
16574
|
case ShapePrimitiveType.Star:
|
|
16034
16575
|
{
|
|
16035
|
-
var starData =
|
|
16036
|
-
this.
|
|
16576
|
+
var starData = shapeAttribute;
|
|
16577
|
+
this.graphicsPath.polyStar(starData.pointCount, starData.outerRadius, starData.innerRadius, starData.outerRoundness, starData.innerRoundness, StarType.Star);
|
|
16037
16578
|
this.setFillColor(starData.fill);
|
|
16038
16579
|
break;
|
|
16039
16580
|
}
|
|
16040
16581
|
case ShapePrimitiveType.Polygon:
|
|
16041
16582
|
{
|
|
16042
|
-
var polygonData =
|
|
16043
|
-
this.
|
|
16583
|
+
var polygonData = shapeAttribute;
|
|
16584
|
+
this.graphicsPath.polyStar(polygonData.pointCount, polygonData.radius, polygonData.radius, polygonData.roundness, polygonData.roundness, StarType.Polygon);
|
|
16044
16585
|
this.setFillColor(polygonData.fill);
|
|
16045
16586
|
break;
|
|
16046
16587
|
}
|
|
@@ -16054,7 +16595,93 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
16054
16595
|
};
|
|
16055
16596
|
_proto.fromData = function fromData(data) {
|
|
16056
16597
|
MeshComponent.prototype.fromData.call(this, data);
|
|
16057
|
-
this.
|
|
16598
|
+
this.shapeDirty = true;
|
|
16599
|
+
var strokeParam = data.stroke;
|
|
16600
|
+
if (strokeParam) {
|
|
16601
|
+
this.isStroke = true;
|
|
16602
|
+
this.strokeAttributes.width = strokeParam.width;
|
|
16603
|
+
}
|
|
16604
|
+
switch(data.type){
|
|
16605
|
+
case ShapePrimitiveType.Custom:
|
|
16606
|
+
{
|
|
16607
|
+
this.shapeAttribute = {
|
|
16608
|
+
type: ShapePrimitiveType.Custom,
|
|
16609
|
+
points: [],
|
|
16610
|
+
easingIns: [],
|
|
16611
|
+
easingOuts: [],
|
|
16612
|
+
shapes: []
|
|
16613
|
+
};
|
|
16614
|
+
var customShapeData = data;
|
|
16615
|
+
var customShapeAttribute = this.shapeAttribute;
|
|
16616
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(customShapeData.points), _step; !(_step = _iterator()).done;){
|
|
16617
|
+
var point = _step.value;
|
|
16618
|
+
customShapeAttribute.points.push(new Vector2(point.x, point.y));
|
|
16619
|
+
}
|
|
16620
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(customShapeData.easingIns), _step1; !(_step1 = _iterator1()).done;){
|
|
16621
|
+
var easingIn = _step1.value;
|
|
16622
|
+
customShapeAttribute.easingIns.push(new Vector2(easingIn.x, easingIn.y));
|
|
16623
|
+
}
|
|
16624
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(customShapeData.easingOuts), _step2; !(_step2 = _iterator2()).done;){
|
|
16625
|
+
var easingOut = _step2.value;
|
|
16626
|
+
customShapeAttribute.easingOuts.push(new Vector2(easingOut.x, easingOut.y));
|
|
16627
|
+
}
|
|
16628
|
+
customShapeAttribute.shapes = customShapeData.shapes;
|
|
16629
|
+
break;
|
|
16630
|
+
}
|
|
16631
|
+
case ShapePrimitiveType.Ellipse:
|
|
16632
|
+
{
|
|
16633
|
+
var ellipseData = data;
|
|
16634
|
+
var ellipseAttribute = {
|
|
16635
|
+
type: ShapePrimitiveType.Ellipse,
|
|
16636
|
+
xRadius: ellipseData.xRadius,
|
|
16637
|
+
yRadius: ellipseData.yRadius,
|
|
16638
|
+
fill: ellipseData.fill
|
|
16639
|
+
};
|
|
16640
|
+
this.shapeAttribute = ellipseAttribute;
|
|
16641
|
+
break;
|
|
16642
|
+
}
|
|
16643
|
+
case ShapePrimitiveType.Rectangle:
|
|
16644
|
+
{
|
|
16645
|
+
var rectangleData = data;
|
|
16646
|
+
var rectangleAttribute = {
|
|
16647
|
+
type: ShapePrimitiveType.Rectangle,
|
|
16648
|
+
width: rectangleData.width,
|
|
16649
|
+
height: rectangleData.height,
|
|
16650
|
+
roundness: rectangleData.roundness,
|
|
16651
|
+
fill: rectangleData.fill
|
|
16652
|
+
};
|
|
16653
|
+
this.shapeAttribute = rectangleAttribute;
|
|
16654
|
+
break;
|
|
16655
|
+
}
|
|
16656
|
+
case ShapePrimitiveType.Star:
|
|
16657
|
+
{
|
|
16658
|
+
var starData = data;
|
|
16659
|
+
var starAttribute = {
|
|
16660
|
+
type: ShapePrimitiveType.Star,
|
|
16661
|
+
pointCount: starData.pointCount,
|
|
16662
|
+
innerRadius: starData.innerRadius,
|
|
16663
|
+
outerRadius: starData.outerRadius,
|
|
16664
|
+
innerRoundness: starData.innerRoundness,
|
|
16665
|
+
outerRoundness: starData.outerRoundness,
|
|
16666
|
+
fill: starData.fill
|
|
16667
|
+
};
|
|
16668
|
+
this.shapeAttribute = starAttribute;
|
|
16669
|
+
break;
|
|
16670
|
+
}
|
|
16671
|
+
case ShapePrimitiveType.Polygon:
|
|
16672
|
+
{
|
|
16673
|
+
var polygonData = data;
|
|
16674
|
+
var polygonAttribute = {
|
|
16675
|
+
type: ShapePrimitiveType.Polygon,
|
|
16676
|
+
pointCount: polygonData.pointCount,
|
|
16677
|
+
radius: polygonData.radius,
|
|
16678
|
+
roundness: polygonData.roundness,
|
|
16679
|
+
fill: polygonData.fill
|
|
16680
|
+
};
|
|
16681
|
+
this.shapeAttribute = polygonAttribute;
|
|
16682
|
+
break;
|
|
16683
|
+
}
|
|
16684
|
+
}
|
|
16058
16685
|
var material = this.material;
|
|
16059
16686
|
//@ts-expect-error // TODO 新版蒙版上线后重构
|
|
16060
16687
|
material.stencilRef = data.renderer.mask !== undefined ? [
|
|
@@ -16064,6 +16691,15 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
16064
16691
|
//@ts-expect-error // TODO 新版蒙版上线后重构
|
|
16065
16692
|
setMaskMode(material, data.renderer.maskMode);
|
|
16066
16693
|
};
|
|
16694
|
+
_create_class(ShapeComponent, [
|
|
16695
|
+
{
|
|
16696
|
+
key: "shape",
|
|
16697
|
+
get: function get() {
|
|
16698
|
+
this.shapeDirty = true;
|
|
16699
|
+
return this.shapeAttribute;
|
|
16700
|
+
}
|
|
16701
|
+
}
|
|
16702
|
+
]);
|
|
16067
16703
|
return ShapeComponent;
|
|
16068
16704
|
}(MeshComponent);
|
|
16069
16705
|
exports.ShapeComponent = __decorate([
|
|
@@ -18751,10 +19387,19 @@ var TEMPLATE_USE_OFFSCREEN_CANVAS = "offscreen_canvas";
|
|
|
18751
19387
|
// 后处理配置相关
|
|
18752
19388
|
var POST_PROCESS_SETTINGS = "post_process_settings";
|
|
18753
19389
|
var config = {};
|
|
18754
|
-
|
|
19390
|
+
/**
|
|
19391
|
+
* 获取全局配置项
|
|
19392
|
+
* @param name
|
|
19393
|
+
* @returns
|
|
19394
|
+
*/ function getConfig(name) {
|
|
18755
19395
|
return config[name];
|
|
18756
19396
|
}
|
|
18757
|
-
|
|
19397
|
+
/**
|
|
19398
|
+
* 设置全局配置项
|
|
19399
|
+
* @param name
|
|
19400
|
+
* @param value
|
|
19401
|
+
* @returns
|
|
19402
|
+
*/ function setConfig(name, value) {
|
|
18758
19403
|
return config[name] = value;
|
|
18759
19404
|
}
|
|
18760
19405
|
|
|
@@ -20456,19 +21101,17 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
20456
21101
|
rotation: rotation,
|
|
20457
21102
|
path: path
|
|
20458
21103
|
};
|
|
20459
|
-
var parentTransform = this.transform.parentTransform;
|
|
20460
21104
|
var selfPos = position.clone();
|
|
20461
21105
|
if (path) {
|
|
20462
21106
|
selfPos.add(path.getValue(0));
|
|
20463
21107
|
}
|
|
20464
21108
|
this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
|
|
20465
|
-
if (this.options.particleFollowParent
|
|
20466
|
-
var worldMatrix =
|
|
21109
|
+
if (this.options.particleFollowParent) {
|
|
21110
|
+
var worldMatrix = this.transform.getWorldMatrix();
|
|
20467
21111
|
this.renderer.updateWorldMatrix(worldMatrix);
|
|
20468
21112
|
}
|
|
20469
21113
|
};
|
|
20470
21114
|
_proto.updateEmitterTransform = function updateEmitterTransform(time) {
|
|
20471
|
-
var parentTransform = this.transform.parentTransform;
|
|
20472
21115
|
var _this_basicTransform = this.basicTransform, path = _this_basicTransform.path, position = _this_basicTransform.position;
|
|
20473
21116
|
var selfPos = position.clone();
|
|
20474
21117
|
if (path) {
|
|
@@ -20476,8 +21119,8 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
20476
21119
|
selfPos.add(path.getValue(time / duration));
|
|
20477
21120
|
}
|
|
20478
21121
|
this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
|
|
20479
|
-
if (this.options.particleFollowParent
|
|
20480
|
-
var worldMatrix =
|
|
21122
|
+
if (this.options.particleFollowParent) {
|
|
21123
|
+
var worldMatrix = this.transform.getWorldMatrix();
|
|
20481
21124
|
this.renderer.updateWorldMatrix(worldMatrix);
|
|
20482
21125
|
}
|
|
20483
21126
|
};
|
|
@@ -20865,7 +21508,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
20865
21508
|
var lifetime = this.lifetime;
|
|
20866
21509
|
var shape = this.shape;
|
|
20867
21510
|
var speed = options.startSpeed.getValue(lifetime);
|
|
20868
|
-
var matrix4 = options.particleFollowParent ?
|
|
21511
|
+
var matrix4 = options.particleFollowParent ? Matrix4.IDENTITY : this.transform.getWorldMatrix();
|
|
20869
21512
|
var pointPosition = data.position;
|
|
20870
21513
|
// 粒子的位置受发射器的位置影响,自身的旋转和缩放不受影响
|
|
20871
21514
|
var position = matrix4.transformPoint(pointPosition, new Vector3());
|
|
@@ -23101,88 +23744,81 @@ var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
23101
23744
|
return PropertyClipPlayable;
|
|
23102
23745
|
}(Playable);
|
|
23103
23746
|
|
|
23104
|
-
var
|
|
23105
|
-
_inherits(
|
|
23106
|
-
function
|
|
23747
|
+
var PropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
|
|
23748
|
+
_inherits(PropertyMixerPlayable, TrackMixerPlayable);
|
|
23749
|
+
function PropertyMixerPlayable() {
|
|
23107
23750
|
var _this;
|
|
23108
23751
|
_this = TrackMixerPlayable.apply(this, arguments) || this;
|
|
23109
23752
|
_this.propertyName = "";
|
|
23110
23753
|
return _this;
|
|
23111
23754
|
}
|
|
23112
|
-
var _proto =
|
|
23755
|
+
var _proto = PropertyMixerPlayable.prototype;
|
|
23113
23756
|
_proto.evaluate = function evaluate(context) {
|
|
23114
23757
|
var boundObject = context.output.getUserData();
|
|
23115
23758
|
if (!boundObject) {
|
|
23116
23759
|
return;
|
|
23117
23760
|
}
|
|
23118
23761
|
var hasInput = false;
|
|
23119
|
-
|
|
23120
|
-
if (
|
|
23762
|
+
this.propertyValue = boundObject[this.propertyName];
|
|
23763
|
+
if (this.propertyValue === undefined || this.propertyValue === null) {
|
|
23121
23764
|
return;
|
|
23122
23765
|
}
|
|
23123
|
-
|
|
23766
|
+
this.resetPropertyValue();
|
|
23124
23767
|
// evaluate the curve
|
|
23125
23768
|
for(var i = 0; i < this.clipPlayables.length; i++){
|
|
23126
23769
|
var weight = this.getClipWeight(i);
|
|
23127
23770
|
if (weight > 0) {
|
|
23128
23771
|
var propertyClipPlayable = this.getClipPlayable(i);
|
|
23129
23772
|
if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
|
|
23130
|
-
console.error("
|
|
23773
|
+
console.error("PropertyTrack added non-PropertyPlayableAsset");
|
|
23131
23774
|
continue;
|
|
23132
23775
|
}
|
|
23133
23776
|
var curveValue = propertyClipPlayable.value;
|
|
23134
|
-
|
|
23135
|
-
value.g += curveValue.g * weight;
|
|
23136
|
-
value.b += curveValue.b * weight;
|
|
23137
|
-
value.a += curveValue.a * weight;
|
|
23777
|
+
this.addWeightedValue(curveValue, weight);
|
|
23138
23778
|
hasInput = true;
|
|
23139
23779
|
}
|
|
23140
23780
|
}
|
|
23141
23781
|
// set value
|
|
23142
23782
|
if (hasInput) {
|
|
23143
|
-
boundObject[this.propertyName] =
|
|
23783
|
+
boundObject[this.propertyName] = this.propertyValue;
|
|
23144
23784
|
}
|
|
23145
23785
|
};
|
|
23146
|
-
return
|
|
23786
|
+
return PropertyMixerPlayable;
|
|
23147
23787
|
}(TrackMixerPlayable);
|
|
23148
23788
|
|
|
23149
|
-
var
|
|
23150
|
-
_inherits(
|
|
23789
|
+
var ColorPropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
|
|
23790
|
+
_inherits(ColorPropertyMixerPlayable, PropertyMixerPlayable);
|
|
23791
|
+
function ColorPropertyMixerPlayable() {
|
|
23792
|
+
return PropertyMixerPlayable.apply(this, arguments);
|
|
23793
|
+
}
|
|
23794
|
+
var _proto = ColorPropertyMixerPlayable.prototype;
|
|
23795
|
+
_proto.resetPropertyValue = function resetPropertyValue() {
|
|
23796
|
+
this.propertyValue.setZero();
|
|
23797
|
+
};
|
|
23798
|
+
_proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
|
|
23799
|
+
var result = this.propertyValue;
|
|
23800
|
+
result.r += curveValue.r * weight;
|
|
23801
|
+
result.g += curveValue.g * weight;
|
|
23802
|
+
result.b += curveValue.b * weight;
|
|
23803
|
+
result.a += curveValue.a * weight;
|
|
23804
|
+
};
|
|
23805
|
+
return ColorPropertyMixerPlayable;
|
|
23806
|
+
}(PropertyMixerPlayable);
|
|
23807
|
+
|
|
23808
|
+
var FloatPropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
|
|
23809
|
+
_inherits(FloatPropertyMixerPlayable, PropertyMixerPlayable);
|
|
23151
23810
|
function FloatPropertyMixerPlayable() {
|
|
23152
|
-
|
|
23153
|
-
_this = TrackMixerPlayable.apply(this, arguments) || this;
|
|
23154
|
-
_this.propertyName = "";
|
|
23155
|
-
return _this;
|
|
23811
|
+
return PropertyMixerPlayable.apply(this, arguments);
|
|
23156
23812
|
}
|
|
23157
23813
|
var _proto = FloatPropertyMixerPlayable.prototype;
|
|
23158
|
-
_proto.
|
|
23159
|
-
|
|
23160
|
-
|
|
23161
|
-
|
|
23162
|
-
|
|
23163
|
-
var hasInput = false;
|
|
23164
|
-
var value = 0;
|
|
23165
|
-
// evaluate the curve
|
|
23166
|
-
for(var i = 0; i < this.clipPlayables.length; i++){
|
|
23167
|
-
var weight = this.getClipWeight(i);
|
|
23168
|
-
if (weight > 0) {
|
|
23169
|
-
var propertyClipPlayable = this.getClipPlayable(i);
|
|
23170
|
-
if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
|
|
23171
|
-
console.error("FloatPropertyTrack added non-FloatPropertyPlayableAsset");
|
|
23172
|
-
continue;
|
|
23173
|
-
}
|
|
23174
|
-
var curveValue = propertyClipPlayable.value;
|
|
23175
|
-
value += curveValue * weight;
|
|
23176
|
-
hasInput = true;
|
|
23177
|
-
}
|
|
23178
|
-
}
|
|
23179
|
-
// set value
|
|
23180
|
-
if (hasInput) {
|
|
23181
|
-
boundObject[this.propertyName] = value;
|
|
23182
|
-
}
|
|
23814
|
+
_proto.resetPropertyValue = function resetPropertyValue() {
|
|
23815
|
+
this.propertyValue = 0;
|
|
23816
|
+
};
|
|
23817
|
+
_proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
|
|
23818
|
+
this.propertyValue += curveValue * weight;
|
|
23183
23819
|
};
|
|
23184
23820
|
return FloatPropertyMixerPlayable;
|
|
23185
|
-
}(
|
|
23821
|
+
}(PropertyMixerPlayable);
|
|
23186
23822
|
|
|
23187
23823
|
var ParticleMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
|
|
23188
23824
|
_inherits(ParticleMixerPlayable, TrackMixerPlayable);
|
|
@@ -23694,7 +24330,7 @@ var SerializationHelper = /*#__PURE__*/ function() {
|
|
|
23694
24330
|
this.timelinePlayable.setTime(time);
|
|
23695
24331
|
// The properties of the object may change dynamically,
|
|
23696
24332
|
// so reset the track binding to avoid invalidation of the previously obtained binding object.
|
|
23697
|
-
|
|
24333
|
+
this.resolveBindings();
|
|
23698
24334
|
this.timelinePlayable.evaluate();
|
|
23699
24335
|
this.graph.evaluate(dt);
|
|
23700
24336
|
};
|
|
@@ -23926,50 +24562,44 @@ var TransformMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
|
|
|
23926
24562
|
return TransformMixerPlayable;
|
|
23927
24563
|
}(TrackMixerPlayable);
|
|
23928
24564
|
|
|
23929
|
-
var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(
|
|
23930
|
-
_inherits(Vector4PropertyMixerPlayable,
|
|
24565
|
+
var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
|
|
24566
|
+
_inherits(Vector4PropertyMixerPlayable, PropertyMixerPlayable);
|
|
23931
24567
|
function Vector4PropertyMixerPlayable() {
|
|
23932
|
-
|
|
23933
|
-
_this = TrackMixerPlayable.apply(this, arguments) || this;
|
|
23934
|
-
_this.propertyName = "";
|
|
23935
|
-
return _this;
|
|
24568
|
+
return PropertyMixerPlayable.apply(this, arguments);
|
|
23936
24569
|
}
|
|
23937
24570
|
var _proto = Vector4PropertyMixerPlayable.prototype;
|
|
23938
|
-
_proto.
|
|
23939
|
-
|
|
23940
|
-
|
|
23941
|
-
|
|
23942
|
-
|
|
23943
|
-
|
|
23944
|
-
|
|
23945
|
-
|
|
23946
|
-
|
|
23947
|
-
|
|
23948
|
-
|
|
23949
|
-
|
|
23950
|
-
for(var i = 0; i < this.clipPlayables.length; i++){
|
|
23951
|
-
var weight = this.getClipWeight(i);
|
|
23952
|
-
if (weight > 0) {
|
|
23953
|
-
var propertyClipPlayable = this.getClipPlayable(i);
|
|
23954
|
-
if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
|
|
23955
|
-
console.error("Vector4PropertyTrack added non-Vector4PropertyPlayableAsset");
|
|
23956
|
-
continue;
|
|
23957
|
-
}
|
|
23958
|
-
var curveValue = propertyClipPlayable.value;
|
|
23959
|
-
value.x += curveValue.x * weight;
|
|
23960
|
-
value.y += curveValue.y * weight;
|
|
23961
|
-
value.z += curveValue.z * weight;
|
|
23962
|
-
value.w += curveValue.w * weight;
|
|
23963
|
-
hasInput = true;
|
|
23964
|
-
}
|
|
23965
|
-
}
|
|
23966
|
-
// set value
|
|
23967
|
-
if (hasInput) {
|
|
23968
|
-
boundObject[this.propertyName] = value;
|
|
23969
|
-
}
|
|
24571
|
+
_proto.resetPropertyValue = function resetPropertyValue() {
|
|
24572
|
+
this.propertyValue.x = 0;
|
|
24573
|
+
this.propertyValue.y = 0;
|
|
24574
|
+
this.propertyValue.z = 0;
|
|
24575
|
+
this.propertyValue.w = 0;
|
|
24576
|
+
};
|
|
24577
|
+
_proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
|
|
24578
|
+
var result = this.propertyValue;
|
|
24579
|
+
result.x += curveValue.x * weight;
|
|
24580
|
+
result.y += curveValue.y * weight;
|
|
24581
|
+
result.z += curveValue.z * weight;
|
|
24582
|
+
result.w += curveValue.w * weight;
|
|
23970
24583
|
};
|
|
23971
24584
|
return Vector4PropertyMixerPlayable;
|
|
23972
|
-
}(
|
|
24585
|
+
}(PropertyMixerPlayable);
|
|
24586
|
+
var Vector2PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
|
|
24587
|
+
_inherits(Vector2PropertyMixerPlayable, PropertyMixerPlayable);
|
|
24588
|
+
function Vector2PropertyMixerPlayable() {
|
|
24589
|
+
return PropertyMixerPlayable.apply(this, arguments);
|
|
24590
|
+
}
|
|
24591
|
+
var _proto = Vector2PropertyMixerPlayable.prototype;
|
|
24592
|
+
_proto.resetPropertyValue = function resetPropertyValue() {
|
|
24593
|
+
this.propertyValue.x = 0;
|
|
24594
|
+
this.propertyValue.y = 0;
|
|
24595
|
+
};
|
|
24596
|
+
_proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
|
|
24597
|
+
var result = this.propertyValue;
|
|
24598
|
+
result.x += curveValue.x * weight;
|
|
24599
|
+
result.y += curveValue.y * weight;
|
|
24600
|
+
};
|
|
24601
|
+
return Vector2PropertyMixerPlayable;
|
|
24602
|
+
}(PropertyMixerPlayable);
|
|
23973
24603
|
|
|
23974
24604
|
/**
|
|
23975
24605
|
* @since 2.0.0
|
|
@@ -24350,6 +24980,26 @@ exports.Vector4PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
|
|
|
24350
24980
|
exports.Vector4PropertyTrack = __decorate([
|
|
24351
24981
|
effectsClass(DataType.Vector4PropertyTrack)
|
|
24352
24982
|
], exports.Vector4PropertyTrack);
|
|
24983
|
+
exports.Vector2PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
|
|
24984
|
+
_inherits(Vector2PropertyTrack, PropertyTrack);
|
|
24985
|
+
function Vector2PropertyTrack() {
|
|
24986
|
+
return PropertyTrack.apply(this, arguments);
|
|
24987
|
+
}
|
|
24988
|
+
var _proto = Vector2PropertyTrack.prototype;
|
|
24989
|
+
_proto.createTrackMixer = function createTrackMixer(graph) {
|
|
24990
|
+
var mixer = new Vector2PropertyMixerPlayable(graph);
|
|
24991
|
+
var propertyNames = this.propertyNames;
|
|
24992
|
+
if (propertyNames.length > 0) {
|
|
24993
|
+
var propertyName = propertyNames[propertyNames.length - 1];
|
|
24994
|
+
mixer.propertyName = propertyName;
|
|
24995
|
+
}
|
|
24996
|
+
return mixer;
|
|
24997
|
+
};
|
|
24998
|
+
return Vector2PropertyTrack;
|
|
24999
|
+
}(PropertyTrack);
|
|
25000
|
+
exports.Vector2PropertyTrack = __decorate([
|
|
25001
|
+
effectsClass("Vector2PropertyTrack")
|
|
25002
|
+
], exports.Vector2PropertyTrack);
|
|
24353
25003
|
|
|
24354
25004
|
exports.ColorPropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
|
|
24355
25005
|
_inherits(ColorPropertyTrack, PropertyTrack);
|
|
@@ -24616,8 +25266,28 @@ __decorate([
|
|
|
24616
25266
|
serialize()
|
|
24617
25267
|
], exports.Vector4PropertyPlayableAsset.prototype, "curveData", void 0);
|
|
24618
25268
|
exports.Vector4PropertyPlayableAsset = __decorate([
|
|
24619
|
-
effectsClass(
|
|
25269
|
+
effectsClass(DataType.Vector4PropertyPlayableAsset)
|
|
24620
25270
|
], exports.Vector4PropertyPlayableAsset);
|
|
25271
|
+
exports.Vector2PropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
|
|
25272
|
+
_inherits(Vector2PropertyPlayableAsset, PlayableAsset);
|
|
25273
|
+
function Vector2PropertyPlayableAsset() {
|
|
25274
|
+
return PlayableAsset.apply(this, arguments);
|
|
25275
|
+
}
|
|
25276
|
+
var _proto = Vector2PropertyPlayableAsset.prototype;
|
|
25277
|
+
_proto.createPlayable = function createPlayable(graph) {
|
|
25278
|
+
var clipPlayable = new PropertyClipPlayable(graph);
|
|
25279
|
+
clipPlayable.curve = createValueGetter(this.curveData);
|
|
25280
|
+
clipPlayable.value = clipPlayable.curve.getValue(0);
|
|
25281
|
+
return clipPlayable;
|
|
25282
|
+
};
|
|
25283
|
+
return Vector2PropertyPlayableAsset;
|
|
25284
|
+
}(PlayableAsset);
|
|
25285
|
+
__decorate([
|
|
25286
|
+
serialize()
|
|
25287
|
+
], exports.Vector2PropertyPlayableAsset.prototype, "curveData", void 0);
|
|
25288
|
+
exports.Vector2PropertyPlayableAsset = __decorate([
|
|
25289
|
+
effectsClass(DataType.Vector2PropertyPlayableAsset)
|
|
25290
|
+
], exports.Vector2PropertyPlayableAsset);
|
|
24621
25291
|
|
|
24622
25292
|
exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset) {
|
|
24623
25293
|
_inherits(ObjectBindingTrack, TrackAsset);
|
|
@@ -26000,7 +26670,7 @@ function getStandardInteractContent(ui) {
|
|
|
26000
26670
|
}
|
|
26001
26671
|
});
|
|
26002
26672
|
});
|
|
26003
|
-
json.version = "
|
|
26673
|
+
json.version = JSONSceneVersion["2_1"];
|
|
26004
26674
|
return json;
|
|
26005
26675
|
}
|
|
26006
26676
|
/**
|
|
@@ -26339,7 +27009,7 @@ function getStandardInteractContent(ui) {
|
|
|
26339
27009
|
break;
|
|
26340
27010
|
}
|
|
26341
27011
|
}
|
|
26342
|
-
result.version = "
|
|
27012
|
+
result.version = JSONSceneVersion["3_0"];
|
|
26343
27013
|
return result;
|
|
26344
27014
|
}
|
|
26345
27015
|
/**
|
|
@@ -26881,13 +27551,13 @@ function getStandardJSON(json) {
|
|
|
26881
27551
|
}
|
|
26882
27552
|
throw new Error("Invalid JSON version: " + json.version + ".");
|
|
26883
27553
|
}
|
|
26884
|
-
var currentVersion = "
|
|
27554
|
+
var currentVersion = JSONSceneVersion["1_0"];
|
|
26885
27555
|
function getStandardJSONFromV0(json) {
|
|
26886
27556
|
var _json_bins;
|
|
26887
|
-
currentVersion = "
|
|
27557
|
+
currentVersion = JSONSceneVersion["1_0"];
|
|
26888
27558
|
var plugins = json.plugins || [];
|
|
26889
27559
|
if ((_json_bins = json.bins) == null ? void 0 : _json_bins.length) {
|
|
26890
|
-
currentVersion = "
|
|
27560
|
+
currentVersion = JSONSceneVersion["1_3"];
|
|
26891
27561
|
}
|
|
26892
27562
|
var requires = (json.requires || []).slice();
|
|
26893
27563
|
var images = json.images.map(function(img, index) {
|
|
@@ -28810,7 +29480,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
28810
29480
|
*/ _proto.getSpeed = function getSpeed() {
|
|
28811
29481
|
return this.speed;
|
|
28812
29482
|
};
|
|
28813
|
-
|
|
29483
|
+
/**
|
|
29484
|
+
*
|
|
29485
|
+
*/ _proto.play = function play() {
|
|
28814
29486
|
if (this.isEnded && this.reusable) {
|
|
28815
29487
|
this.restart();
|
|
28816
29488
|
}
|
|
@@ -28825,7 +29497,10 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
28825
29497
|
*/ _proto.pause = function pause() {
|
|
28826
29498
|
this.paused = true;
|
|
28827
29499
|
};
|
|
28828
|
-
|
|
29500
|
+
/**
|
|
29501
|
+
*
|
|
29502
|
+
* @returns
|
|
29503
|
+
*/ _proto.getPaused = function getPaused() {
|
|
28829
29504
|
return this.paused;
|
|
28830
29505
|
};
|
|
28831
29506
|
/**
|
|
@@ -31403,7 +32078,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
|
|
|
31403
32078
|
registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
|
|
31404
32079
|
registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
|
|
31405
32080
|
registerPlugin("interact", InteractLoader, exports.VFXItem, true);
|
|
31406
|
-
var version = "2.
|
|
32081
|
+
var version = "2.3.0-alpha.1";
|
|
31407
32082
|
logger.info("Core version: " + version + ".");
|
|
31408
32083
|
|
|
31409
32084
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -31512,6 +32187,7 @@ exports.TrackSortWrapper = TrackSortWrapper;
|
|
|
31512
32187
|
exports.Transform = Transform;
|
|
31513
32188
|
exports.TransformAnimationPlayable = TransformAnimationPlayable;
|
|
31514
32189
|
exports.ValueGetter = ValueGetter;
|
|
32190
|
+
exports.Vector2Curve = Vector2Curve;
|
|
31515
32191
|
exports.Vector4Curve = Vector4Curve;
|
|
31516
32192
|
exports.addByOrder = addByOrder;
|
|
31517
32193
|
exports.addItem = addItem;
|