@galacean/effects-threejs 2.2.6 → 2.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1137 -552
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +1137 -553
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.
|
|
6
|
+
* Version: v2.3.0-alpha.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as THREE from 'three';
|
|
@@ -1020,6 +1020,26 @@ function _inherits(subClass, superClass) {
|
|
|
1020
1020
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
1021
1021
|
}
|
|
1022
1022
|
|
|
1023
|
+
/**
|
|
1024
|
+
* JSON 版本
|
|
1025
|
+
*/ var JSONSceneVersion;
|
|
1026
|
+
(function(JSONSceneVersion) {
|
|
1027
|
+
JSONSceneVersion["1_0"] = "1.0";
|
|
1028
|
+
JSONSceneVersion["1_1"] = "1.1";
|
|
1029
|
+
JSONSceneVersion["1_2"] = "1.2";
|
|
1030
|
+
JSONSceneVersion["1_3"] = "1.3";
|
|
1031
|
+
JSONSceneVersion["1_5"] = "1.5";
|
|
1032
|
+
JSONSceneVersion["1_8"] = "1.8";
|
|
1033
|
+
JSONSceneVersion["2_0"] = "2.0";
|
|
1034
|
+
JSONSceneVersion["2_1"] = "2.1";
|
|
1035
|
+
JSONSceneVersion["2_2"] = "2.2";
|
|
1036
|
+
JSONSceneVersion["2_3"] = "2.3";
|
|
1037
|
+
JSONSceneVersion["2_4"] = "2.4";
|
|
1038
|
+
JSONSceneVersion["3_0"] = "3.0";
|
|
1039
|
+
JSONSceneVersion["3_1"] = "3.1";
|
|
1040
|
+
JSONSceneVersion["LATEST"] = "3.1";
|
|
1041
|
+
})(JSONSceneVersion || (JSONSceneVersion = {}));
|
|
1042
|
+
|
|
1023
1043
|
/*********************************************/ /* 元素属性参数类型 */ /*********************************************/ /**
|
|
1024
1044
|
* 渲染等级
|
|
1025
1045
|
*/ var RenderLevel;
|
|
@@ -1325,8 +1345,12 @@ var RenderFace;
|
|
|
1325
1345
|
*/ var END_BEHAVIOR_DESTROY_CHILDREN = 6;
|
|
1326
1346
|
var CAMERA_CLIP_MODE_VERTICAL = 1;
|
|
1327
1347
|
var CAMERA_CLIP_MODE_NORMAL = 0;
|
|
1328
|
-
|
|
1329
|
-
|
|
1348
|
+
/**
|
|
1349
|
+
* 消息开始
|
|
1350
|
+
*/ var MESSAGE_ITEM_PHRASE_BEGIN = 2;
|
|
1351
|
+
/**
|
|
1352
|
+
* 消息结束
|
|
1353
|
+
*/ var MESSAGE_ITEM_PHRASE_END = 1;
|
|
1330
1354
|
|
|
1331
1355
|
var CameraClipMode;
|
|
1332
1356
|
(function(CameraClipMode) {
|
|
@@ -1400,6 +1424,9 @@ var CameraClipMode;
|
|
|
1400
1424
|
/**
|
|
1401
1425
|
* Vector4 曲线
|
|
1402
1426
|
*/ ValueType[ValueType["VECTOR4_CURVE"] = 25] = "VECTOR4_CURVE";
|
|
1427
|
+
/**
|
|
1428
|
+
* Vector2 曲线
|
|
1429
|
+
*/ ValueType[ValueType["VECTOR2_CURVE"] = 26] = "VECTOR2_CURVE";
|
|
1403
1430
|
})(ValueType || (ValueType = {}));
|
|
1404
1431
|
/**
|
|
1405
1432
|
* 关键帧类型
|
|
@@ -1668,19 +1695,13 @@ var ShapePointType;
|
|
|
1668
1695
|
var DataType;
|
|
1669
1696
|
(function(DataType) {
|
|
1670
1697
|
DataType["VFXItemData"] = "VFXItemData";
|
|
1671
|
-
|
|
1698
|
+
// Assets
|
|
1672
1699
|
DataType["Material"] = "Material";
|
|
1673
1700
|
DataType["Shader"] = "Shader";
|
|
1674
|
-
DataType["SpriteComponent"] = "SpriteComponent";
|
|
1675
|
-
DataType["ParticleSystem"] = "ParticleSystem";
|
|
1676
|
-
DataType["InteractComponent"] = "InteractComponent";
|
|
1677
|
-
DataType["CameraController"] = "CameraController";
|
|
1678
|
-
DataType["PostProcessVolume"] = "PostProcessVolume";
|
|
1679
1701
|
DataType["Geometry"] = "Geometry";
|
|
1680
1702
|
DataType["Texture"] = "Texture";
|
|
1681
1703
|
DataType["Image"] = "Image";
|
|
1682
1704
|
DataType["AnimationClip"] = "AnimationClip";
|
|
1683
|
-
DataType["TextComponent"] = "TextComponent";
|
|
1684
1705
|
DataType["BinaryAsset"] = "BinaryAsset";
|
|
1685
1706
|
// Timeline
|
|
1686
1707
|
DataType["TrackAsset"] = "TrackAsset";
|
|
@@ -1692,6 +1713,7 @@ var DataType;
|
|
|
1692
1713
|
DataType["SubCompositionTrack"] = "SubCompositionTrack";
|
|
1693
1714
|
DataType["FloatPropertyTrack"] = "FloatPropertyTrack";
|
|
1694
1715
|
DataType["ColorPropertyTrack"] = "ColorPropertyTrack";
|
|
1716
|
+
DataType["Vector2PropertyTrack"] = "Vector2PropertyTrack";
|
|
1695
1717
|
DataType["Vector4PropertyTrack"] = "Vector4PropertyTrack";
|
|
1696
1718
|
DataType["TransformPlayableAsset"] = "TransformPlayableAsset";
|
|
1697
1719
|
DataType["SpriteColorPlayableAsset"] = "SpriteColorPlayableAsset";
|
|
@@ -1699,6 +1721,9 @@ var DataType;
|
|
|
1699
1721
|
DataType["SubCompositionPlayableAsset"] = "SubCompositionPlayableAsset";
|
|
1700
1722
|
DataType["FloatPropertyPlayableAsset"] = "FloatPropertyPlayableAsset";
|
|
1701
1723
|
DataType["ColorPropertyPlayableAsset"] = "ColorPropertyPlayableAsset";
|
|
1724
|
+
DataType["Vector2PropertyPlayableAsset"] = "Vector2PropertyPlayableAsset";
|
|
1725
|
+
DataType["Vector4PropertyPlayableAsset"] = "Vector4PropertyPlayableAsset";
|
|
1726
|
+
// Components
|
|
1702
1727
|
DataType["MeshComponent"] = "MeshComponent";
|
|
1703
1728
|
DataType["SkyboxComponent"] = "SkyboxComponent";
|
|
1704
1729
|
DataType["LightComponent"] = "LightComponent";
|
|
@@ -1712,6 +1737,13 @@ var DataType;
|
|
|
1712
1737
|
DataType["RichTextComponent"] = "RichTextComponent";
|
|
1713
1738
|
DataType["OrientationComponent"] = "OrientationComponent";
|
|
1714
1739
|
DataType["ShapeComponent"] = "ShapeComponent";
|
|
1740
|
+
DataType["SpriteComponent"] = "SpriteComponent";
|
|
1741
|
+
DataType["ParticleSystem"] = "ParticleSystem";
|
|
1742
|
+
DataType["InteractComponent"] = "InteractComponent";
|
|
1743
|
+
DataType["CameraController"] = "CameraController";
|
|
1744
|
+
DataType["PostProcessVolume"] = "PostProcessVolume";
|
|
1745
|
+
DataType["EffectComponent"] = "EffectComponent";
|
|
1746
|
+
DataType["TextComponent"] = "TextComponent";
|
|
1715
1747
|
// Non-EffectObject
|
|
1716
1748
|
DataType["TimelineClip"] = "TimelineClip";
|
|
1717
1749
|
})(DataType || (DataType = {}));
|
|
@@ -1800,8 +1832,11 @@ var VertexBufferSemantic;
|
|
|
1800
1832
|
VertexBufferSemantic["TangentBS3"] = "TANGENT_BS3";
|
|
1801
1833
|
})(VertexBufferSemantic || (VertexBufferSemantic = {}));
|
|
1802
1834
|
|
|
1835
|
+
var LATEST_VERSION = JSONSceneVersion.LATEST;
|
|
1836
|
+
|
|
1803
1837
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
1804
1838
|
__proto__: null,
|
|
1839
|
+
LATEST_VERSION: LATEST_VERSION,
|
|
1805
1840
|
get RenderLevel () { return RenderLevel; },
|
|
1806
1841
|
get BlendingMode () { return BlendingMode; },
|
|
1807
1842
|
get SideMode () { return SideMode; },
|
|
@@ -1829,6 +1864,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
1829
1864
|
MESSAGE_ITEM_PHRASE_END: MESSAGE_ITEM_PHRASE_END,
|
|
1830
1865
|
get ValueType () { return ValueType; },
|
|
1831
1866
|
get BezierKeyframeType () { return BezierKeyframeType; },
|
|
1867
|
+
get JSONSceneVersion () { return JSONSceneVersion; },
|
|
1832
1868
|
get EndBehavior () { return EndBehavior; },
|
|
1833
1869
|
get ParentItemEndBehavior () { return ParentItemEndBehavior; },
|
|
1834
1870
|
get ParticleInteractionBehavior () { return ParticleInteractionBehavior; },
|
|
@@ -5276,418 +5312,6 @@ Matrix4.tempVec1 = new Vector3();
|
|
|
5276
5312
|
Matrix4.tempVec2 = new Vector3();
|
|
5277
5313
|
Matrix4.tempMat0 = new Matrix4();
|
|
5278
5314
|
|
|
5279
|
-
function _array_like_to_array(arr, len) {
|
|
5280
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
5281
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5282
|
-
return arr2;
|
|
5283
|
-
}
|
|
5284
|
-
|
|
5285
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
5286
|
-
if (!o) return;
|
|
5287
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
5288
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
5289
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
5290
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
5291
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
5292
|
-
}
|
|
5293
|
-
|
|
5294
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
5295
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
5296
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
5297
|
-
// Fallback for engines without symbol support
|
|
5298
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
5299
|
-
if (it) o = it;
|
|
5300
|
-
var i = 0;
|
|
5301
|
-
return function() {
|
|
5302
|
-
if (i >= o.length) return {
|
|
5303
|
-
done: true
|
|
5304
|
-
};
|
|
5305
|
-
return {
|
|
5306
|
-
done: false,
|
|
5307
|
-
value: o[i++]
|
|
5308
|
-
};
|
|
5309
|
-
};
|
|
5310
|
-
}
|
|
5311
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
5312
|
-
}
|
|
5313
|
-
|
|
5314
|
-
var ShaderCompileResultStatus;
|
|
5315
|
-
(function(ShaderCompileResultStatus) {
|
|
5316
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
|
|
5317
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
|
|
5318
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
|
|
5319
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
|
|
5320
|
-
})(ShaderCompileResultStatus || (ShaderCompileResultStatus = {}));
|
|
5321
|
-
var GLSLVersion;
|
|
5322
|
-
(function(GLSLVersion) {
|
|
5323
|
-
GLSLVersion["GLSL1"] = "100";
|
|
5324
|
-
GLSLVersion["GLSL3"] = "300 es";
|
|
5325
|
-
})(GLSLVersion || (GLSLVersion = {}));
|
|
5326
|
-
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
5327
|
-
_inherits(ShaderVariant, EffectsObject);
|
|
5328
|
-
function ShaderVariant(engine, source) {
|
|
5329
|
-
var _this;
|
|
5330
|
-
_this = EffectsObject.call(this, engine) || this;
|
|
5331
|
-
_this.source = source;
|
|
5332
|
-
return _this;
|
|
5333
|
-
}
|
|
5334
|
-
return ShaderVariant;
|
|
5335
|
-
}(EffectsObject);
|
|
5336
|
-
var Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
5337
|
-
_inherits(Shader, EffectsObject);
|
|
5338
|
-
function Shader() {
|
|
5339
|
-
return EffectsObject.apply(this, arguments);
|
|
5340
|
-
}
|
|
5341
|
-
var _proto = Shader.prototype;
|
|
5342
|
-
_proto.createVariant = function createVariant(macros) {
|
|
5343
|
-
var shaderMacros = [];
|
|
5344
|
-
if (macros) {
|
|
5345
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
|
|
5346
|
-
var key = _step.value;
|
|
5347
|
-
shaderMacros.push([
|
|
5348
|
-
key,
|
|
5349
|
-
macros[key]
|
|
5350
|
-
]);
|
|
5351
|
-
}
|
|
5352
|
-
}
|
|
5353
|
-
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
5354
|
-
shaderVariant.shader = this;
|
|
5355
|
-
return shaderVariant;
|
|
5356
|
-
};
|
|
5357
|
-
_proto.fromData = function fromData(data) {
|
|
5358
|
-
EffectsObject.prototype.fromData.call(this, data);
|
|
5359
|
-
this.shaderData = data;
|
|
5360
|
-
};
|
|
5361
|
-
return Shader;
|
|
5362
|
-
}(EffectsObject);
|
|
5363
|
-
Shader = __decorate([
|
|
5364
|
-
effectsClass(DataType.Shader)
|
|
5365
|
-
], Shader);
|
|
5366
|
-
|
|
5367
|
-
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
5368
|
-
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
5369
|
-
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}";
|
|
5370
|
-
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";
|
|
5371
|
-
function createCopyShader(level, writeDepth) {
|
|
5372
|
-
var webgl2 = level === 2;
|
|
5373
|
-
return {
|
|
5374
|
-
name: EFFECTS_COPY_MESH_NAME,
|
|
5375
|
-
vertex: COPY_VERTEX_SHADER,
|
|
5376
|
-
fragment: COPY_FRAGMENT_SHADER,
|
|
5377
|
-
glslVersion: webgl2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1,
|
|
5378
|
-
macros: [
|
|
5379
|
-
[
|
|
5380
|
-
"DEPTH_TEXTURE",
|
|
5381
|
-
!!writeDepth
|
|
5382
|
-
]
|
|
5383
|
-
],
|
|
5384
|
-
// @ts-expect-error
|
|
5385
|
-
cacheId: COPY_MESH_SHADER_ID + +writeDepth
|
|
5386
|
-
};
|
|
5387
|
-
}
|
|
5388
|
-
|
|
5389
|
-
/**
|
|
5390
|
-
* Helper class to create a WebGL Context
|
|
5391
|
-
*
|
|
5392
|
-
* @param canvas
|
|
5393
|
-
* @param glType
|
|
5394
|
-
* @param options
|
|
5395
|
-
* @returns
|
|
5396
|
-
*/ function createGLContext(canvas, glType, options) {
|
|
5397
|
-
if (glType === void 0) glType = "webgl";
|
|
5398
|
-
var context;
|
|
5399
|
-
if (glType === "webgl2") {
|
|
5400
|
-
context = canvas.getContext("webgl2", options);
|
|
5401
|
-
if (!context) {
|
|
5402
|
-
console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
|
|
5403
|
-
}
|
|
5404
|
-
}
|
|
5405
|
-
if (!context || glType === "webgl") {
|
|
5406
|
-
context = canvas.getContext("webgl", options);
|
|
5407
|
-
}
|
|
5408
|
-
if (!context) {
|
|
5409
|
-
throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
|
|
5410
|
-
}
|
|
5411
|
-
return context;
|
|
5412
|
-
}
|
|
5413
|
-
|
|
5414
|
-
function gpuTimer(gl) {
|
|
5415
|
-
var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
|
|
5416
|
-
if (ext) {
|
|
5417
|
-
var query = gl.createQuery();
|
|
5418
|
-
var getTime = /*#__PURE__*/ _async_to_generator(function() {
|
|
5419
|
-
return __generator(this, function(_state) {
|
|
5420
|
-
return [
|
|
5421
|
-
2,
|
|
5422
|
-
new Promise(function(resolve, reject) {
|
|
5423
|
-
if (query) {
|
|
5424
|
-
var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
|
|
5425
|
-
var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
|
|
5426
|
-
if (available && !disjoint) {
|
|
5427
|
-
// See how much time the rendering of the object took in nanoseconds.
|
|
5428
|
-
var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
|
|
5429
|
-
// taken to use all significant bits of the result, not just the
|
|
5430
|
-
// least significant 32 bits.
|
|
5431
|
-
resolve(timeElapsed / 1000 / 1000);
|
|
5432
|
-
}
|
|
5433
|
-
if (available || disjoint) {
|
|
5434
|
-
// Clean up the query object.
|
|
5435
|
-
gl.deleteQuery(query); // Don't re-enter this polling loop.
|
|
5436
|
-
query = null;
|
|
5437
|
-
}
|
|
5438
|
-
available !== null && query && window.setTimeout(function() {
|
|
5439
|
-
getTime().then(resolve).catch;
|
|
5440
|
-
}, 1);
|
|
5441
|
-
}
|
|
5442
|
-
})
|
|
5443
|
-
];
|
|
5444
|
-
});
|
|
5445
|
-
});
|
|
5446
|
-
if (!query) {
|
|
5447
|
-
return;
|
|
5448
|
-
}
|
|
5449
|
-
return {
|
|
5450
|
-
begin: function() {
|
|
5451
|
-
query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
|
|
5452
|
-
},
|
|
5453
|
-
end: function() {
|
|
5454
|
-
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
5455
|
-
},
|
|
5456
|
-
getTime: getTime
|
|
5457
|
-
};
|
|
5458
|
-
}
|
|
5459
|
-
}
|
|
5460
|
-
|
|
5461
|
-
var initErrors = [];
|
|
5462
|
-
// @ts-expect-error
|
|
5463
|
-
var glContext = {};
|
|
5464
|
-
if (!initErrors.length) {
|
|
5465
|
-
initGLContext();
|
|
5466
|
-
}
|
|
5467
|
-
function initGLContext() {
|
|
5468
|
-
// 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
|
|
5469
|
-
if (typeof WebGL2RenderingContext === "function") {
|
|
5470
|
-
copy(WebGL2RenderingContext);
|
|
5471
|
-
} else if (typeof WebGLRenderingContext !== "undefined") {
|
|
5472
|
-
copy(WebGLRenderingContext);
|
|
5473
|
-
copy(WebGLRenderingContext.prototype);
|
|
5474
|
-
} else {
|
|
5475
|
-
initErrors.push(// iOS 16 lockdown mode
|
|
5476
|
-
"iOS16 lockdown mode, WebGL Constants not in global");
|
|
5477
|
-
}
|
|
5478
|
-
if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
|
|
5479
|
-
// @ts-expect-error set default value
|
|
5480
|
-
glContext["HALF_FLOAT"] = 5131;
|
|
5481
|
-
}
|
|
5482
|
-
}
|
|
5483
|
-
function isWebGL2(gl) {
|
|
5484
|
-
return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
|
|
5485
|
-
}
|
|
5486
|
-
function copy(target) {
|
|
5487
|
-
for(var name in target){
|
|
5488
|
-
if (/^[A-Z_]/.test(name)) {
|
|
5489
|
-
// @ts-expect-error safe to assign
|
|
5490
|
-
glContext[name] = target[name];
|
|
5491
|
-
}
|
|
5492
|
-
}
|
|
5493
|
-
}
|
|
5494
|
-
function vertexFormatType2GLType(formatType) {
|
|
5495
|
-
switch(formatType){
|
|
5496
|
-
case VertexFormatType.Float32:
|
|
5497
|
-
return WebGLRenderingContext["FLOAT"];
|
|
5498
|
-
case VertexFormatType.Int16:
|
|
5499
|
-
return WebGLRenderingContext["SHORT"];
|
|
5500
|
-
case VertexFormatType.Int8:
|
|
5501
|
-
return WebGLRenderingContext["BYTE"];
|
|
5502
|
-
case VertexFormatType.UInt16:
|
|
5503
|
-
return WebGLRenderingContext["UNSIGNED_SHORT"];
|
|
5504
|
-
case VertexFormatType.UInt8:
|
|
5505
|
-
return WebGLRenderingContext["UNSIGNED_BYTE"];
|
|
5506
|
-
default:
|
|
5507
|
-
return WebGLRenderingContext["FLOAT"];
|
|
5508
|
-
}
|
|
5509
|
-
}
|
|
5510
|
-
function glType2VertexFormatType(webglType) {
|
|
5511
|
-
switch(webglType){
|
|
5512
|
-
case WebGLRenderingContext["FLOAT"]:
|
|
5513
|
-
return VertexFormatType.Float32;
|
|
5514
|
-
case WebGLRenderingContext["SHORT"]:
|
|
5515
|
-
return VertexFormatType.Int16;
|
|
5516
|
-
case WebGLRenderingContext["BYTE"]:
|
|
5517
|
-
return VertexFormatType.Int8;
|
|
5518
|
-
case WebGLRenderingContext["UNSIGNED_SHORT"]:
|
|
5519
|
-
return VertexFormatType.UInt16;
|
|
5520
|
-
case WebGLRenderingContext["UNSIGNED_BYTE"]:
|
|
5521
|
-
return VertexFormatType.UInt8;
|
|
5522
|
-
default:
|
|
5523
|
-
return VertexFormatType.Float32;
|
|
5524
|
-
}
|
|
5525
|
-
}
|
|
5526
|
-
|
|
5527
|
-
var ShaderType;
|
|
5528
|
-
(function(ShaderType) {
|
|
5529
|
-
ShaderType[ShaderType["vertex"] = 0] = "vertex";
|
|
5530
|
-
ShaderType[ShaderType["fragment"] = 1] = "fragment";
|
|
5531
|
-
})(ShaderType || (ShaderType = {}));
|
|
5532
|
-
|
|
5533
|
-
function valIfUndefined(val, def) {
|
|
5534
|
-
if (val === undefined || val === null) {
|
|
5535
|
-
return def;
|
|
5536
|
-
}
|
|
5537
|
-
return val;
|
|
5538
|
-
}
|
|
5539
|
-
function getPreMultiAlpha(blending) {
|
|
5540
|
-
switch(blending){
|
|
5541
|
-
case BlendingMode.ALPHA:
|
|
5542
|
-
return 1;
|
|
5543
|
-
case BlendingMode.ADD:
|
|
5544
|
-
return 1;
|
|
5545
|
-
case BlendingMode.SUBTRACTION:
|
|
5546
|
-
return 1;
|
|
5547
|
-
case BlendingMode.STRONG_LIGHT:
|
|
5548
|
-
return 1;
|
|
5549
|
-
case BlendingMode.WEAK_LIGHT:
|
|
5550
|
-
return 1;
|
|
5551
|
-
case BlendingMode.SUPERPOSITION:
|
|
5552
|
-
return 2;
|
|
5553
|
-
case BlendingMode.BRIGHTNESS:
|
|
5554
|
-
return 3;
|
|
5555
|
-
case BlendingMode.MULTIPLY:
|
|
5556
|
-
return 0;
|
|
5557
|
-
default:
|
|
5558
|
-
// 处理undefined
|
|
5559
|
-
return 1;
|
|
5560
|
-
}
|
|
5561
|
-
}
|
|
5562
|
-
function setBlendMode(material, blendMode) {
|
|
5563
|
-
switch(blendMode){
|
|
5564
|
-
case undefined:
|
|
5565
|
-
material.blendFunction = [
|
|
5566
|
-
glContext.ONE,
|
|
5567
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
5568
|
-
glContext.ONE,
|
|
5569
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
5570
|
-
];
|
|
5571
|
-
break;
|
|
5572
|
-
case BlendingMode.ALPHA:
|
|
5573
|
-
material.blendFunction = [
|
|
5574
|
-
glContext.ONE,
|
|
5575
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
5576
|
-
glContext.ONE,
|
|
5577
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
5578
|
-
];
|
|
5579
|
-
break;
|
|
5580
|
-
case BlendingMode.ADD:
|
|
5581
|
-
material.blendFunction = [
|
|
5582
|
-
glContext.ONE,
|
|
5583
|
-
glContext.ONE,
|
|
5584
|
-
glContext.ONE,
|
|
5585
|
-
glContext.ONE
|
|
5586
|
-
];
|
|
5587
|
-
break;
|
|
5588
|
-
case BlendingMode.SUBTRACTION:
|
|
5589
|
-
material.blendFunction = [
|
|
5590
|
-
glContext.ONE,
|
|
5591
|
-
glContext.ONE,
|
|
5592
|
-
glContext.ZERO,
|
|
5593
|
-
glContext.ONE
|
|
5594
|
-
];
|
|
5595
|
-
material.blendEquation = [
|
|
5596
|
-
glContext.FUNC_REVERSE_SUBTRACT,
|
|
5597
|
-
glContext.FUNC_REVERSE_SUBTRACT
|
|
5598
|
-
];
|
|
5599
|
-
break;
|
|
5600
|
-
case BlendingMode.SUPERPOSITION:
|
|
5601
|
-
material.blendFunction = [
|
|
5602
|
-
glContext.ONE,
|
|
5603
|
-
glContext.ONE,
|
|
5604
|
-
glContext.ONE,
|
|
5605
|
-
glContext.ONE
|
|
5606
|
-
];
|
|
5607
|
-
break;
|
|
5608
|
-
case BlendingMode.MULTIPLY:
|
|
5609
|
-
material.blendFunction = [
|
|
5610
|
-
glContext.DST_COLOR,
|
|
5611
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
5612
|
-
glContext.DST_COLOR,
|
|
5613
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
5614
|
-
];
|
|
5615
|
-
break;
|
|
5616
|
-
case BlendingMode.BRIGHTNESS:
|
|
5617
|
-
material.blendFunction = [
|
|
5618
|
-
glContext.ONE,
|
|
5619
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
5620
|
-
glContext.ONE,
|
|
5621
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
5622
|
-
];
|
|
5623
|
-
break;
|
|
5624
|
-
case BlendingMode.STRONG_LIGHT:
|
|
5625
|
-
material.blendFunction = [
|
|
5626
|
-
glContext.DST_COLOR,
|
|
5627
|
-
glContext.DST_ALPHA,
|
|
5628
|
-
glContext.ZERO,
|
|
5629
|
-
glContext.ONE
|
|
5630
|
-
];
|
|
5631
|
-
break;
|
|
5632
|
-
case BlendingMode.WEAK_LIGHT:
|
|
5633
|
-
material.blendFunction = [
|
|
5634
|
-
glContext.DST_COLOR,
|
|
5635
|
-
glContext.ZERO,
|
|
5636
|
-
glContext.ZERO,
|
|
5637
|
-
glContext.ONE
|
|
5638
|
-
];
|
|
5639
|
-
break;
|
|
5640
|
-
default:
|
|
5641
|
-
console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
|
|
5642
|
-
}
|
|
5643
|
-
}
|
|
5644
|
-
function setSideMode(material, side) {
|
|
5645
|
-
if (side === SideMode.DOUBLE) {
|
|
5646
|
-
material.culling = false;
|
|
5647
|
-
} else {
|
|
5648
|
-
material.culling = true;
|
|
5649
|
-
material.frontFace = glContext.CW;
|
|
5650
|
-
material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
|
|
5651
|
-
}
|
|
5652
|
-
}
|
|
5653
|
-
function setMaskMode(material, maskMode) {
|
|
5654
|
-
switch(maskMode){
|
|
5655
|
-
case undefined:
|
|
5656
|
-
material.stencilTest = false;
|
|
5657
|
-
break;
|
|
5658
|
-
case MaskMode.MASK:
|
|
5659
|
-
material.stencilTest = true;
|
|
5660
|
-
material.stencilFunc = [
|
|
5661
|
-
glContext.ALWAYS,
|
|
5662
|
-
glContext.ALWAYS
|
|
5663
|
-
];
|
|
5664
|
-
material.stencilOpZPass = [
|
|
5665
|
-
glContext.REPLACE,
|
|
5666
|
-
glContext.REPLACE
|
|
5667
|
-
];
|
|
5668
|
-
break;
|
|
5669
|
-
case MaskMode.OBSCURED:
|
|
5670
|
-
material.stencilTest = true;
|
|
5671
|
-
material.stencilFunc = [
|
|
5672
|
-
glContext.EQUAL,
|
|
5673
|
-
glContext.EQUAL
|
|
5674
|
-
];
|
|
5675
|
-
break;
|
|
5676
|
-
case MaskMode.REVERSE_OBSCURED:
|
|
5677
|
-
material.stencilTest = true;
|
|
5678
|
-
material.stencilFunc = [
|
|
5679
|
-
glContext.NOTEQUAL,
|
|
5680
|
-
glContext.NOTEQUAL
|
|
5681
|
-
];
|
|
5682
|
-
break;
|
|
5683
|
-
case MaskMode.NONE:
|
|
5684
|
-
material.stencilTest = false;
|
|
5685
|
-
break;
|
|
5686
|
-
default:
|
|
5687
|
-
console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
|
|
5688
|
-
}
|
|
5689
|
-
}
|
|
5690
|
-
|
|
5691
5315
|
function _extends() {
|
|
5692
5316
|
_extends = Object.assign || function assign(target) {
|
|
5693
5317
|
for(var i = 1; i < arguments.length; i++){
|
|
@@ -6098,7 +5722,12 @@ function _loadVideo() {
|
|
|
6098
5722
|
});
|
|
6099
5723
|
return _loadVideo.apply(this, arguments);
|
|
6100
5724
|
}
|
|
6101
|
-
|
|
5725
|
+
/**
|
|
5726
|
+
* 异步加载一个媒体文件
|
|
5727
|
+
* @param url
|
|
5728
|
+
* @param loadFn
|
|
5729
|
+
* @returns
|
|
5730
|
+
*/ function loadMedia(url, loadFn) {
|
|
6102
5731
|
return _loadMedia.apply(this, arguments);
|
|
6103
5732
|
}
|
|
6104
5733
|
function _loadMedia() {
|
|
@@ -6260,6 +5889,144 @@ function _loadMipmapImage() {
|
|
|
6260
5889
|
return _loadMipmapImage.apply(this, arguments);
|
|
6261
5890
|
}
|
|
6262
5891
|
|
|
5892
|
+
/**
|
|
5893
|
+
* Helper class to create a WebGL Context
|
|
5894
|
+
*
|
|
5895
|
+
* @param canvas
|
|
5896
|
+
* @param glType
|
|
5897
|
+
* @param options
|
|
5898
|
+
* @returns
|
|
5899
|
+
*/ function createGLContext(canvas, glType, options) {
|
|
5900
|
+
if (glType === void 0) glType = "webgl";
|
|
5901
|
+
var context;
|
|
5902
|
+
if (glType === "webgl2") {
|
|
5903
|
+
context = canvas.getContext("webgl2", options);
|
|
5904
|
+
if (!context) {
|
|
5905
|
+
console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
|
|
5906
|
+
}
|
|
5907
|
+
}
|
|
5908
|
+
if (!context || glType === "webgl") {
|
|
5909
|
+
context = canvas.getContext("webgl", options);
|
|
5910
|
+
}
|
|
5911
|
+
if (!context) {
|
|
5912
|
+
throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
|
|
5913
|
+
}
|
|
5914
|
+
return context;
|
|
5915
|
+
}
|
|
5916
|
+
|
|
5917
|
+
function gpuTimer(gl) {
|
|
5918
|
+
var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
|
|
5919
|
+
if (ext) {
|
|
5920
|
+
var query = gl.createQuery();
|
|
5921
|
+
var getTime = /*#__PURE__*/ _async_to_generator(function() {
|
|
5922
|
+
return __generator(this, function(_state) {
|
|
5923
|
+
return [
|
|
5924
|
+
2,
|
|
5925
|
+
new Promise(function(resolve, reject) {
|
|
5926
|
+
if (query) {
|
|
5927
|
+
var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
|
|
5928
|
+
var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
|
|
5929
|
+
if (available && !disjoint) {
|
|
5930
|
+
// See how much time the rendering of the object took in nanoseconds.
|
|
5931
|
+
var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
|
|
5932
|
+
// taken to use all significant bits of the result, not just the
|
|
5933
|
+
// least significant 32 bits.
|
|
5934
|
+
resolve(timeElapsed / 1000 / 1000);
|
|
5935
|
+
}
|
|
5936
|
+
if (available || disjoint) {
|
|
5937
|
+
// Clean up the query object.
|
|
5938
|
+
gl.deleteQuery(query); // Don't re-enter this polling loop.
|
|
5939
|
+
query = null;
|
|
5940
|
+
}
|
|
5941
|
+
available !== null && query && window.setTimeout(function() {
|
|
5942
|
+
getTime().then(resolve).catch;
|
|
5943
|
+
}, 1);
|
|
5944
|
+
}
|
|
5945
|
+
})
|
|
5946
|
+
];
|
|
5947
|
+
});
|
|
5948
|
+
});
|
|
5949
|
+
if (!query) {
|
|
5950
|
+
return;
|
|
5951
|
+
}
|
|
5952
|
+
return {
|
|
5953
|
+
begin: function() {
|
|
5954
|
+
query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
|
|
5955
|
+
},
|
|
5956
|
+
end: function() {
|
|
5957
|
+
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
5958
|
+
},
|
|
5959
|
+
getTime: getTime
|
|
5960
|
+
};
|
|
5961
|
+
}
|
|
5962
|
+
}
|
|
5963
|
+
|
|
5964
|
+
var initErrors = [];
|
|
5965
|
+
// @ts-expect-error
|
|
5966
|
+
var glContext = {};
|
|
5967
|
+
if (!initErrors.length) {
|
|
5968
|
+
initGLContext();
|
|
5969
|
+
}
|
|
5970
|
+
function initGLContext() {
|
|
5971
|
+
// 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
|
|
5972
|
+
if (typeof WebGL2RenderingContext === "function") {
|
|
5973
|
+
copy(WebGL2RenderingContext);
|
|
5974
|
+
} else if (typeof WebGLRenderingContext !== "undefined") {
|
|
5975
|
+
copy(WebGLRenderingContext);
|
|
5976
|
+
copy(WebGLRenderingContext.prototype);
|
|
5977
|
+
} else {
|
|
5978
|
+
initErrors.push(// iOS 16 lockdown mode
|
|
5979
|
+
"iOS16 lockdown mode, WebGL Constants not in global");
|
|
5980
|
+
}
|
|
5981
|
+
if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
|
|
5982
|
+
// @ts-expect-error set default value
|
|
5983
|
+
glContext["HALF_FLOAT"] = 5131;
|
|
5984
|
+
}
|
|
5985
|
+
}
|
|
5986
|
+
function isWebGL2(gl) {
|
|
5987
|
+
return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
|
|
5988
|
+
}
|
|
5989
|
+
function copy(target) {
|
|
5990
|
+
for(var name in target){
|
|
5991
|
+
if (/^[A-Z_]/.test(name)) {
|
|
5992
|
+
// @ts-expect-error safe to assign
|
|
5993
|
+
glContext[name] = target[name];
|
|
5994
|
+
}
|
|
5995
|
+
}
|
|
5996
|
+
}
|
|
5997
|
+
function vertexFormatType2GLType(formatType) {
|
|
5998
|
+
switch(formatType){
|
|
5999
|
+
case VertexFormatType.Float32:
|
|
6000
|
+
return WebGLRenderingContext["FLOAT"];
|
|
6001
|
+
case VertexFormatType.Int16:
|
|
6002
|
+
return WebGLRenderingContext["SHORT"];
|
|
6003
|
+
case VertexFormatType.Int8:
|
|
6004
|
+
return WebGLRenderingContext["BYTE"];
|
|
6005
|
+
case VertexFormatType.UInt16:
|
|
6006
|
+
return WebGLRenderingContext["UNSIGNED_SHORT"];
|
|
6007
|
+
case VertexFormatType.UInt8:
|
|
6008
|
+
return WebGLRenderingContext["UNSIGNED_BYTE"];
|
|
6009
|
+
default:
|
|
6010
|
+
return WebGLRenderingContext["FLOAT"];
|
|
6011
|
+
}
|
|
6012
|
+
}
|
|
6013
|
+
function glType2VertexFormatType(webglType) {
|
|
6014
|
+
switch(webglType){
|
|
6015
|
+
case WebGLRenderingContext["FLOAT"]:
|
|
6016
|
+
return VertexFormatType.Float32;
|
|
6017
|
+
case WebGLRenderingContext["SHORT"]:
|
|
6018
|
+
return VertexFormatType.Int16;
|
|
6019
|
+
case WebGLRenderingContext["BYTE"]:
|
|
6020
|
+
return VertexFormatType.Int8;
|
|
6021
|
+
case WebGLRenderingContext["UNSIGNED_SHORT"]:
|
|
6022
|
+
return VertexFormatType.UInt16;
|
|
6023
|
+
case WebGLRenderingContext["UNSIGNED_BYTE"]:
|
|
6024
|
+
return VertexFormatType.UInt8;
|
|
6025
|
+
default:
|
|
6026
|
+
return VertexFormatType.Float32;
|
|
6027
|
+
}
|
|
6028
|
+
}
|
|
6029
|
+
|
|
6263
6030
|
var seed$a = 1;
|
|
6264
6031
|
/**
|
|
6265
6032
|
* Texture 抽象类
|
|
@@ -6894,6 +6661,280 @@ function setDefaultTextureFactory(factory) {
|
|
|
6894
6661
|
g = factory;
|
|
6895
6662
|
}
|
|
6896
6663
|
|
|
6664
|
+
function _array_like_to_array(arr, len) {
|
|
6665
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
6666
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
6667
|
+
return arr2;
|
|
6668
|
+
}
|
|
6669
|
+
|
|
6670
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
6671
|
+
if (!o) return;
|
|
6672
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
6673
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
6674
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
6675
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
6676
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
6677
|
+
}
|
|
6678
|
+
|
|
6679
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
6680
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
6681
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
6682
|
+
// Fallback for engines without symbol support
|
|
6683
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
6684
|
+
if (it) o = it;
|
|
6685
|
+
var i = 0;
|
|
6686
|
+
return function() {
|
|
6687
|
+
if (i >= o.length) return {
|
|
6688
|
+
done: true
|
|
6689
|
+
};
|
|
6690
|
+
return {
|
|
6691
|
+
done: false,
|
|
6692
|
+
value: o[i++]
|
|
6693
|
+
};
|
|
6694
|
+
};
|
|
6695
|
+
}
|
|
6696
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
6697
|
+
}
|
|
6698
|
+
|
|
6699
|
+
var ShaderCompileResultStatus;
|
|
6700
|
+
(function(ShaderCompileResultStatus) {
|
|
6701
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
|
|
6702
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
|
|
6703
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
|
|
6704
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
|
|
6705
|
+
})(ShaderCompileResultStatus || (ShaderCompileResultStatus = {}));
|
|
6706
|
+
var GLSLVersion;
|
|
6707
|
+
(function(GLSLVersion) {
|
|
6708
|
+
GLSLVersion["GLSL1"] = "100";
|
|
6709
|
+
GLSLVersion["GLSL3"] = "300 es";
|
|
6710
|
+
})(GLSLVersion || (GLSLVersion = {}));
|
|
6711
|
+
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
6712
|
+
_inherits(ShaderVariant, EffectsObject);
|
|
6713
|
+
function ShaderVariant(engine, source) {
|
|
6714
|
+
var _this;
|
|
6715
|
+
_this = EffectsObject.call(this, engine) || this;
|
|
6716
|
+
_this.source = source;
|
|
6717
|
+
return _this;
|
|
6718
|
+
}
|
|
6719
|
+
return ShaderVariant;
|
|
6720
|
+
}(EffectsObject);
|
|
6721
|
+
var Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
6722
|
+
_inherits(Shader, EffectsObject);
|
|
6723
|
+
function Shader() {
|
|
6724
|
+
return EffectsObject.apply(this, arguments);
|
|
6725
|
+
}
|
|
6726
|
+
var _proto = Shader.prototype;
|
|
6727
|
+
_proto.createVariant = function createVariant(macros) {
|
|
6728
|
+
var shaderMacros = [];
|
|
6729
|
+
if (macros) {
|
|
6730
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
|
|
6731
|
+
var key = _step.value;
|
|
6732
|
+
shaderMacros.push([
|
|
6733
|
+
key,
|
|
6734
|
+
macros[key]
|
|
6735
|
+
]);
|
|
6736
|
+
}
|
|
6737
|
+
}
|
|
6738
|
+
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
6739
|
+
shaderVariant.shader = this;
|
|
6740
|
+
return shaderVariant;
|
|
6741
|
+
};
|
|
6742
|
+
_proto.fromData = function fromData(data) {
|
|
6743
|
+
EffectsObject.prototype.fromData.call(this, data);
|
|
6744
|
+
this.shaderData = data;
|
|
6745
|
+
};
|
|
6746
|
+
return Shader;
|
|
6747
|
+
}(EffectsObject);
|
|
6748
|
+
Shader = __decorate([
|
|
6749
|
+
effectsClass(DataType.Shader)
|
|
6750
|
+
], Shader);
|
|
6751
|
+
|
|
6752
|
+
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
6753
|
+
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
6754
|
+
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}";
|
|
6755
|
+
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";
|
|
6756
|
+
function createCopyShader(level, writeDepth) {
|
|
6757
|
+
var webgl2 = level === 2;
|
|
6758
|
+
return {
|
|
6759
|
+
name: EFFECTS_COPY_MESH_NAME,
|
|
6760
|
+
vertex: COPY_VERTEX_SHADER,
|
|
6761
|
+
fragment: COPY_FRAGMENT_SHADER,
|
|
6762
|
+
glslVersion: webgl2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1,
|
|
6763
|
+
macros: [
|
|
6764
|
+
[
|
|
6765
|
+
"DEPTH_TEXTURE",
|
|
6766
|
+
!!writeDepth
|
|
6767
|
+
]
|
|
6768
|
+
],
|
|
6769
|
+
// @ts-expect-error
|
|
6770
|
+
cacheId: COPY_MESH_SHADER_ID + +writeDepth
|
|
6771
|
+
};
|
|
6772
|
+
}
|
|
6773
|
+
|
|
6774
|
+
var ShaderType;
|
|
6775
|
+
(function(ShaderType) {
|
|
6776
|
+
ShaderType[ShaderType["vertex"] = 0] = "vertex";
|
|
6777
|
+
ShaderType[ShaderType["fragment"] = 1] = "fragment";
|
|
6778
|
+
})(ShaderType || (ShaderType = {}));
|
|
6779
|
+
|
|
6780
|
+
function valIfUndefined(val, def) {
|
|
6781
|
+
if (val === undefined || val === null) {
|
|
6782
|
+
return def;
|
|
6783
|
+
}
|
|
6784
|
+
return val;
|
|
6785
|
+
}
|
|
6786
|
+
function getPreMultiAlpha(blending) {
|
|
6787
|
+
switch(blending){
|
|
6788
|
+
case BlendingMode.ALPHA:
|
|
6789
|
+
return 1;
|
|
6790
|
+
case BlendingMode.ADD:
|
|
6791
|
+
return 1;
|
|
6792
|
+
case BlendingMode.SUBTRACTION:
|
|
6793
|
+
return 1;
|
|
6794
|
+
case BlendingMode.STRONG_LIGHT:
|
|
6795
|
+
return 1;
|
|
6796
|
+
case BlendingMode.WEAK_LIGHT:
|
|
6797
|
+
return 1;
|
|
6798
|
+
case BlendingMode.SUPERPOSITION:
|
|
6799
|
+
return 2;
|
|
6800
|
+
case BlendingMode.BRIGHTNESS:
|
|
6801
|
+
return 3;
|
|
6802
|
+
case BlendingMode.MULTIPLY:
|
|
6803
|
+
return 0;
|
|
6804
|
+
default:
|
|
6805
|
+
// 处理undefined
|
|
6806
|
+
return 1;
|
|
6807
|
+
}
|
|
6808
|
+
}
|
|
6809
|
+
function setBlendMode(material, blendMode) {
|
|
6810
|
+
switch(blendMode){
|
|
6811
|
+
case undefined:
|
|
6812
|
+
material.blendFunction = [
|
|
6813
|
+
glContext.ONE,
|
|
6814
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
6815
|
+
glContext.ONE,
|
|
6816
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
6817
|
+
];
|
|
6818
|
+
break;
|
|
6819
|
+
case BlendingMode.ALPHA:
|
|
6820
|
+
material.blendFunction = [
|
|
6821
|
+
glContext.ONE,
|
|
6822
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
6823
|
+
glContext.ONE,
|
|
6824
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
6825
|
+
];
|
|
6826
|
+
break;
|
|
6827
|
+
case BlendingMode.ADD:
|
|
6828
|
+
material.blendFunction = [
|
|
6829
|
+
glContext.ONE,
|
|
6830
|
+
glContext.ONE,
|
|
6831
|
+
glContext.ONE,
|
|
6832
|
+
glContext.ONE
|
|
6833
|
+
];
|
|
6834
|
+
break;
|
|
6835
|
+
case BlendingMode.SUBTRACTION:
|
|
6836
|
+
material.blendFunction = [
|
|
6837
|
+
glContext.ONE,
|
|
6838
|
+
glContext.ONE,
|
|
6839
|
+
glContext.ZERO,
|
|
6840
|
+
glContext.ONE
|
|
6841
|
+
];
|
|
6842
|
+
material.blendEquation = [
|
|
6843
|
+
glContext.FUNC_REVERSE_SUBTRACT,
|
|
6844
|
+
glContext.FUNC_REVERSE_SUBTRACT
|
|
6845
|
+
];
|
|
6846
|
+
break;
|
|
6847
|
+
case BlendingMode.SUPERPOSITION:
|
|
6848
|
+
material.blendFunction = [
|
|
6849
|
+
glContext.ONE,
|
|
6850
|
+
glContext.ONE,
|
|
6851
|
+
glContext.ONE,
|
|
6852
|
+
glContext.ONE
|
|
6853
|
+
];
|
|
6854
|
+
break;
|
|
6855
|
+
case BlendingMode.MULTIPLY:
|
|
6856
|
+
material.blendFunction = [
|
|
6857
|
+
glContext.DST_COLOR,
|
|
6858
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
6859
|
+
glContext.DST_COLOR,
|
|
6860
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
6861
|
+
];
|
|
6862
|
+
break;
|
|
6863
|
+
case BlendingMode.BRIGHTNESS:
|
|
6864
|
+
material.blendFunction = [
|
|
6865
|
+
glContext.ONE,
|
|
6866
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
6867
|
+
glContext.ONE,
|
|
6868
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
6869
|
+
];
|
|
6870
|
+
break;
|
|
6871
|
+
case BlendingMode.STRONG_LIGHT:
|
|
6872
|
+
material.blendFunction = [
|
|
6873
|
+
glContext.DST_COLOR,
|
|
6874
|
+
glContext.DST_ALPHA,
|
|
6875
|
+
glContext.ZERO,
|
|
6876
|
+
glContext.ONE
|
|
6877
|
+
];
|
|
6878
|
+
break;
|
|
6879
|
+
case BlendingMode.WEAK_LIGHT:
|
|
6880
|
+
material.blendFunction = [
|
|
6881
|
+
glContext.DST_COLOR,
|
|
6882
|
+
glContext.ZERO,
|
|
6883
|
+
glContext.ZERO,
|
|
6884
|
+
glContext.ONE
|
|
6885
|
+
];
|
|
6886
|
+
break;
|
|
6887
|
+
default:
|
|
6888
|
+
console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
|
|
6889
|
+
}
|
|
6890
|
+
}
|
|
6891
|
+
function setSideMode(material, side) {
|
|
6892
|
+
if (side === SideMode.DOUBLE) {
|
|
6893
|
+
material.culling = false;
|
|
6894
|
+
} else {
|
|
6895
|
+
material.culling = true;
|
|
6896
|
+
material.frontFace = glContext.CW;
|
|
6897
|
+
material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
|
|
6898
|
+
}
|
|
6899
|
+
}
|
|
6900
|
+
function setMaskMode(material, maskMode) {
|
|
6901
|
+
switch(maskMode){
|
|
6902
|
+
case undefined:
|
|
6903
|
+
material.stencilTest = false;
|
|
6904
|
+
break;
|
|
6905
|
+
case MaskMode.MASK:
|
|
6906
|
+
material.stencilTest = true;
|
|
6907
|
+
material.stencilFunc = [
|
|
6908
|
+
glContext.ALWAYS,
|
|
6909
|
+
glContext.ALWAYS
|
|
6910
|
+
];
|
|
6911
|
+
material.stencilOpZPass = [
|
|
6912
|
+
glContext.REPLACE,
|
|
6913
|
+
glContext.REPLACE
|
|
6914
|
+
];
|
|
6915
|
+
break;
|
|
6916
|
+
case MaskMode.OBSCURED:
|
|
6917
|
+
material.stencilTest = true;
|
|
6918
|
+
material.stencilFunc = [
|
|
6919
|
+
glContext.EQUAL,
|
|
6920
|
+
glContext.EQUAL
|
|
6921
|
+
];
|
|
6922
|
+
break;
|
|
6923
|
+
case MaskMode.REVERSE_OBSCURED:
|
|
6924
|
+
material.stencilTest = true;
|
|
6925
|
+
material.stencilFunc = [
|
|
6926
|
+
glContext.NOTEQUAL,
|
|
6927
|
+
glContext.NOTEQUAL
|
|
6928
|
+
];
|
|
6929
|
+
break;
|
|
6930
|
+
case MaskMode.NONE:
|
|
6931
|
+
material.stencilTest = false;
|
|
6932
|
+
break;
|
|
6933
|
+
default:
|
|
6934
|
+
console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
|
|
6935
|
+
}
|
|
6936
|
+
}
|
|
6937
|
+
|
|
6897
6938
|
/**
|
|
6898
6939
|
* 引擎接入暂时不需要实现
|
|
6899
6940
|
*/ var MaterialDataBlock = /*#__PURE__*/ function() {
|
|
@@ -13104,6 +13145,27 @@ var Vector4Curve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
13104
13145
|
};
|
|
13105
13146
|
return Vector4Curve;
|
|
13106
13147
|
}(ValueGetter);
|
|
13148
|
+
var Vector2Curve = /*#__PURE__*/ function(ValueGetter) {
|
|
13149
|
+
_inherits(Vector2Curve, ValueGetter);
|
|
13150
|
+
function Vector2Curve() {
|
|
13151
|
+
var _this;
|
|
13152
|
+
_this = ValueGetter.apply(this, arguments) || this;
|
|
13153
|
+
_this.value = new Vector2();
|
|
13154
|
+
return _this;
|
|
13155
|
+
}
|
|
13156
|
+
var _proto = Vector2Curve.prototype;
|
|
13157
|
+
_proto.onCreate = function onCreate(arg) {
|
|
13158
|
+
this.xCurve = createValueGetter(arg[0]);
|
|
13159
|
+
this.yCurve = createValueGetter(arg[1]);
|
|
13160
|
+
};
|
|
13161
|
+
_proto.getValue = function getValue(t) {
|
|
13162
|
+
var x = this.xCurve.getValue(t);
|
|
13163
|
+
var y = this.yCurve.getValue(t);
|
|
13164
|
+
this.value.set(x, y);
|
|
13165
|
+
return this.value;
|
|
13166
|
+
};
|
|
13167
|
+
return Vector2Curve;
|
|
13168
|
+
}(ValueGetter);
|
|
13107
13169
|
|
|
13108
13170
|
var SPRITE_VERTEX_STRIDE = 6;
|
|
13109
13171
|
var SEMANTIC_PRE_COLOR_ATTACHMENT_0 = "PRE_COLOR_0";
|
|
@@ -13167,6 +13229,8 @@ var map$1 = (_obj$4 = {}, _obj$4[ValueType.RANDOM] = function(props) {
|
|
|
13167
13229
|
return new ColorCurve(props);
|
|
13168
13230
|
}, _obj$4[ValueType.VECTOR4_CURVE] = function(props) {
|
|
13169
13231
|
return new Vector4Curve(props);
|
|
13232
|
+
}, _obj$4[ValueType.VECTOR2_CURVE] = function(props) {
|
|
13233
|
+
return new Vector2Curve(props);
|
|
13170
13234
|
}, _obj$4);
|
|
13171
13235
|
function createValueGetter(args) {
|
|
13172
13236
|
if (!args || !isNaN(+args)) {
|
|
@@ -13291,13 +13355,39 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
13291
13355
|
this.color = color;
|
|
13292
13356
|
this.material.setVector4("_Color", new Vector4().setFromArray(color));
|
|
13293
13357
|
};
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
|
|
13358
|
+
_proto.setTexture = function setTexture(input) {
|
|
13359
|
+
var _this = this;
|
|
13360
|
+
return _async_to_generator(function() {
|
|
13361
|
+
var texture;
|
|
13362
|
+
return __generator(this, function(_state) {
|
|
13363
|
+
switch(_state.label){
|
|
13364
|
+
case 0:
|
|
13365
|
+
if (!(typeof input === "string")) return [
|
|
13366
|
+
3,
|
|
13367
|
+
2
|
|
13368
|
+
];
|
|
13369
|
+
return [
|
|
13370
|
+
4,
|
|
13371
|
+
Texture.fromImage(input, _this.item.engine)
|
|
13372
|
+
];
|
|
13373
|
+
case 1:
|
|
13374
|
+
texture = _state.sent();
|
|
13375
|
+
return [
|
|
13376
|
+
3,
|
|
13377
|
+
3
|
|
13378
|
+
];
|
|
13379
|
+
case 2:
|
|
13380
|
+
texture = input;
|
|
13381
|
+
_state.label = 3;
|
|
13382
|
+
case 3:
|
|
13383
|
+
_this.renderer.texture = texture;
|
|
13384
|
+
_this.material.setTexture("_MainTex", texture);
|
|
13385
|
+
return [
|
|
13386
|
+
2
|
|
13387
|
+
];
|
|
13388
|
+
}
|
|
13389
|
+
});
|
|
13390
|
+
})();
|
|
13301
13391
|
};
|
|
13302
13392
|
/**
|
|
13303
13393
|
* @internal
|
|
@@ -13559,6 +13649,8 @@ function getImageItemRenderInfo(item) {
|
|
|
13559
13649
|
};
|
|
13560
13650
|
}
|
|
13561
13651
|
|
|
13652
|
+
// Based on:
|
|
13653
|
+
// https://github.com/pixijs/pixijs/blob/dev/src/maths/shapes/ShapePrimitive.ts
|
|
13562
13654
|
var ShapePrimitive = function ShapePrimitive() {
|
|
13563
13655
|
};
|
|
13564
13656
|
|
|
@@ -14664,6 +14756,7 @@ function triangulate(contours) {
|
|
|
14664
14756
|
return triangleVerts;
|
|
14665
14757
|
}
|
|
14666
14758
|
|
|
14759
|
+
// Based on:
|
|
14667
14760
|
/**
|
|
14668
14761
|
* A class to define a shape via user defined coordinates.
|
|
14669
14762
|
*/ var Polygon = /*#__PURE__*/ function(ShapePrimitive) {
|
|
@@ -14763,12 +14856,13 @@ function triangulate(contours) {
|
|
|
14763
14856
|
var triangles = triangulate([
|
|
14764
14857
|
points
|
|
14765
14858
|
]);
|
|
14859
|
+
var indexStart = vertices.length / 2;
|
|
14766
14860
|
for(var i = 0; i < triangles.length; i++){
|
|
14767
|
-
vertices[verticesOffset + i] = triangles[i];
|
|
14861
|
+
vertices[verticesOffset * 2 + i] = triangles[i];
|
|
14768
14862
|
}
|
|
14769
14863
|
var vertexCount = triangles.length / 2;
|
|
14770
14864
|
for(var i1 = 0; i1 < vertexCount; i1++){
|
|
14771
|
-
indices[indicesOffset + i1] = i1;
|
|
14865
|
+
indices[indicesOffset + i1] = indexStart + i1;
|
|
14772
14866
|
}
|
|
14773
14867
|
};
|
|
14774
14868
|
_create_class(Polygon, [
|
|
@@ -14890,6 +14984,7 @@ function recursive(x1, y1, x2, y2, x3, y3, x4, y4, points, distanceTolerance, le
|
|
|
14890
14984
|
recursive(x1234, y1234, x234, y234, x34, y34, x4, y4, points, distanceTolerance, level + 1);
|
|
14891
14985
|
}
|
|
14892
14986
|
|
|
14987
|
+
// Based on:
|
|
14893
14988
|
/**
|
|
14894
14989
|
* The Ellipse object is used to help draw graphics and can also be used to specify a hit area for containers.
|
|
14895
14990
|
*/ var Ellipse = /*#__PURE__*/ function(ShapePrimitive) {
|
|
@@ -15096,6 +15191,7 @@ function recursive(x1, y1, x2, y2, x3, y3, x4, y4, points, distanceTolerance, le
|
|
|
15096
15191
|
return Ellipse;
|
|
15097
15192
|
}(ShapePrimitive);
|
|
15098
15193
|
|
|
15194
|
+
// Based on:
|
|
15099
15195
|
var StarType;
|
|
15100
15196
|
(function(StarType) {
|
|
15101
15197
|
StarType[StarType["Star"] = 0] = "Star";
|
|
@@ -15164,12 +15260,13 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
|
|
|
15164
15260
|
var triangles = triangulate([
|
|
15165
15261
|
points
|
|
15166
15262
|
]);
|
|
15263
|
+
var indexStart = vertices.length / 2;
|
|
15167
15264
|
for(var i = 0; i < triangles.length; i++){
|
|
15168
|
-
vertices[verticesOffset + i] = triangles[i];
|
|
15265
|
+
vertices[verticesOffset * 2 + i] = triangles[i];
|
|
15169
15266
|
}
|
|
15170
15267
|
var vertexCount = triangles.length / 2;
|
|
15171
15268
|
for(var i1 = 0; i1 < vertexCount; i1++){
|
|
15172
|
-
indices[indicesOffset + i1] = i1;
|
|
15269
|
+
indices[indicesOffset + i1] = indexStart + i1;
|
|
15173
15270
|
}
|
|
15174
15271
|
};
|
|
15175
15272
|
_proto.buildStarPath = function buildStarPath() {
|
|
@@ -15240,6 +15337,7 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
|
|
|
15240
15337
|
return PolyStar;
|
|
15241
15338
|
}(ShapePrimitive);
|
|
15242
15339
|
|
|
15340
|
+
// Based on:
|
|
15243
15341
|
// const tempPoints = [new Point(), new Point(), new Point(), new Point()];
|
|
15244
15342
|
/**
|
|
15245
15343
|
* The `Rectangle` object is an area defined by its position, as indicated by its upper-left corner
|
|
@@ -15563,6 +15661,7 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
|
|
|
15563
15661
|
return Rectangle;
|
|
15564
15662
|
}(ShapePrimitive);
|
|
15565
15663
|
|
|
15664
|
+
// Based on:
|
|
15566
15665
|
var ShapePath = /*#__PURE__*/ function() {
|
|
15567
15666
|
function ShapePath(graphicsPath) {
|
|
15568
15667
|
this.graphicsPath = graphicsPath;
|
|
@@ -15721,6 +15820,7 @@ var ShapePath = /*#__PURE__*/ function() {
|
|
|
15721
15820
|
return ShapePath;
|
|
15722
15821
|
}();
|
|
15723
15822
|
|
|
15823
|
+
// Based on:
|
|
15724
15824
|
var GraphicsPath = /*#__PURE__*/ function() {
|
|
15725
15825
|
function GraphicsPath() {
|
|
15726
15826
|
this.instructions = [];
|
|
@@ -15858,14 +15958,433 @@ var GraphicsPath = /*#__PURE__*/ function() {
|
|
|
15858
15958
|
return GraphicsPath;
|
|
15859
15959
|
}();
|
|
15860
15960
|
|
|
15961
|
+
// Based on:
|
|
15962
|
+
/**
|
|
15963
|
+
* The Point object represents a location in a two-dimensional coordinate system, where `x` represents
|
|
15964
|
+
* the position on the horizontal axis and `y` represents the position on the vertical axis.
|
|
15965
|
+
*/ var Point = /*#__PURE__*/ function() {
|
|
15966
|
+
function Point(x, y) {
|
|
15967
|
+
if (x === void 0) x = 0;
|
|
15968
|
+
if (y === void 0) y = 0;
|
|
15969
|
+
/**
|
|
15970
|
+
* Position of the point on the x axis
|
|
15971
|
+
*/ this.x = 0;
|
|
15972
|
+
/**
|
|
15973
|
+
* Position of the point on the y axis
|
|
15974
|
+
*/ this.y = 0;
|
|
15975
|
+
this.x = x;
|
|
15976
|
+
this.y = y;
|
|
15977
|
+
}
|
|
15978
|
+
var _proto = Point.prototype;
|
|
15979
|
+
/**
|
|
15980
|
+
* Creates a clone of this point
|
|
15981
|
+
* @returns A clone of this point
|
|
15982
|
+
*/ _proto.clone = function clone() {
|
|
15983
|
+
return new Point(this.x, this.y);
|
|
15984
|
+
};
|
|
15985
|
+
/**
|
|
15986
|
+
* Copies `x` and `y` from the given point into this point
|
|
15987
|
+
* @param p - The point to copy from
|
|
15988
|
+
* @returns The point instance itself
|
|
15989
|
+
*/ _proto.copyFrom = function copyFrom(p) {
|
|
15990
|
+
this.set(p.x, p.y);
|
|
15991
|
+
return this;
|
|
15992
|
+
};
|
|
15993
|
+
/**
|
|
15994
|
+
* Copies this point's x and y into the given point (`p`).
|
|
15995
|
+
* @param p - The point to copy to. Can be any of type that is or extends `PointData`
|
|
15996
|
+
* @returns The point (`p`) with values updated
|
|
15997
|
+
*/ _proto.copyTo = function copyTo(p) {
|
|
15998
|
+
p.set(this.x, this.y);
|
|
15999
|
+
return p;
|
|
16000
|
+
};
|
|
16001
|
+
/**
|
|
16002
|
+
* Accepts another point (`p`) and returns `true` if the given point is equal to this point
|
|
16003
|
+
* @param p - The point to check
|
|
16004
|
+
* @returns Returns `true` if both `x` and `y` are equal
|
|
16005
|
+
*/ _proto.equals = function equals(p) {
|
|
16006
|
+
return p.x === this.x && p.y === this.y;
|
|
16007
|
+
};
|
|
16008
|
+
/**
|
|
16009
|
+
* Sets the point to a new `x` and `y` position.
|
|
16010
|
+
* If `y` is omitted, both `x` and `y` will be set to `x`.
|
|
16011
|
+
* @param {number} [x=0] - position of the point on the `x` axis
|
|
16012
|
+
* @param {number} [y=x] - position of the point on the `y` axis
|
|
16013
|
+
* @returns The point instance itself
|
|
16014
|
+
*/ _proto.set = function set(x, y) {
|
|
16015
|
+
if (x === void 0) x = 0;
|
|
16016
|
+
if (y === void 0) y = x;
|
|
16017
|
+
this.x = x;
|
|
16018
|
+
this.y = y;
|
|
16019
|
+
return this;
|
|
16020
|
+
};
|
|
16021
|
+
_create_class(Point, null, [
|
|
16022
|
+
{
|
|
16023
|
+
key: "shared",
|
|
16024
|
+
get: /**
|
|
16025
|
+
* A static Point object with `x` and `y` values of `0`. Can be used to avoid creating new objects multiple times.
|
|
16026
|
+
* @readonly
|
|
16027
|
+
*/ function get() {
|
|
16028
|
+
tempPoint.x = 0;
|
|
16029
|
+
tempPoint.y = 0;
|
|
16030
|
+
return tempPoint;
|
|
16031
|
+
}
|
|
16032
|
+
}
|
|
16033
|
+
]);
|
|
16034
|
+
return Point;
|
|
16035
|
+
}();
|
|
16036
|
+
var tempPoint = new Point();
|
|
16037
|
+
|
|
16038
|
+
// Based on:
|
|
16039
|
+
var closePointEps = 1e-4;
|
|
16040
|
+
var curveEps = 0.0001;
|
|
16041
|
+
/**
|
|
16042
|
+
* Buffers vertices to draw a square cap.
|
|
16043
|
+
*
|
|
16044
|
+
* @internal
|
|
16045
|
+
* @private
|
|
16046
|
+
* @param x - X-coord of end point
|
|
16047
|
+
* @param y - Y-coord of end point
|
|
16048
|
+
* @param nx - X-coord of line normal pointing inside
|
|
16049
|
+
* @param ny - Y-coord of line normal pointing inside
|
|
16050
|
+
* @param innerWeight - Weight of inner points
|
|
16051
|
+
* @param outerWeight - Weight of outer points
|
|
16052
|
+
* @param clockwise - Whether the cap is drawn clockwise
|
|
16053
|
+
* @param verts - vertex buffer
|
|
16054
|
+
* @returns - no. of vertices pushed
|
|
16055
|
+
*/ function square(x, y, nx, ny, innerWeight, outerWeight, clockwise, /* rotation for square (true at left end, false at right end) */ verts) {
|
|
16056
|
+
var ix = x - nx * innerWeight;
|
|
16057
|
+
var iy = y - ny * innerWeight;
|
|
16058
|
+
var ox = x + nx * outerWeight;
|
|
16059
|
+
var oy = y + ny * outerWeight;
|
|
16060
|
+
/* Rotate nx,ny for extension vector */ var exx;
|
|
16061
|
+
var eyy;
|
|
16062
|
+
if (clockwise) {
|
|
16063
|
+
exx = ny;
|
|
16064
|
+
eyy = -nx;
|
|
16065
|
+
} else {
|
|
16066
|
+
exx = -ny;
|
|
16067
|
+
eyy = nx;
|
|
16068
|
+
}
|
|
16069
|
+
/* [i|0]x,y extended at cap */ var eix = ix + exx;
|
|
16070
|
+
var eiy = iy + eyy;
|
|
16071
|
+
var eox = ox + exx;
|
|
16072
|
+
var eoy = oy + eyy;
|
|
16073
|
+
/* Square itself must be inserted clockwise*/ verts.push(eix, eiy);
|
|
16074
|
+
verts.push(eox, eoy);
|
|
16075
|
+
return 2;
|
|
16076
|
+
}
|
|
16077
|
+
/**
|
|
16078
|
+
* Buffers vertices to draw an arc at the line joint or cap.
|
|
16079
|
+
*
|
|
16080
|
+
* @internal
|
|
16081
|
+
* @private
|
|
16082
|
+
* @param cx - X-coord of center
|
|
16083
|
+
* @param cy - Y-coord of center
|
|
16084
|
+
* @param sx - X-coord of arc start
|
|
16085
|
+
* @param sy - Y-coord of arc start
|
|
16086
|
+
* @param ex - X-coord of arc end
|
|
16087
|
+
* @param ey - Y-coord of arc end
|
|
16088
|
+
* @param verts - buffer of vertices
|
|
16089
|
+
* @param clockwise - orientation of vertices
|
|
16090
|
+
* @returns - no. of vertices pushed
|
|
16091
|
+
*/ function round(cx, cy, sx, sy, ex, ey, verts, clockwise) {
|
|
16092
|
+
var cx2p0x = sx - cx;
|
|
16093
|
+
var cy2p0y = sy - cy;
|
|
16094
|
+
var angle0 = Math.atan2(cx2p0x, cy2p0y);
|
|
16095
|
+
var angle1 = Math.atan2(ex - cx, ey - cy);
|
|
16096
|
+
if (clockwise && angle0 < angle1) {
|
|
16097
|
+
angle0 += Math.PI * 2;
|
|
16098
|
+
} else if (!clockwise && angle0 > angle1) {
|
|
16099
|
+
angle1 += Math.PI * 2;
|
|
16100
|
+
}
|
|
16101
|
+
var startAngle = angle0;
|
|
16102
|
+
var angleDiff = angle1 - angle0;
|
|
16103
|
+
var absAngleDiff = Math.abs(angleDiff);
|
|
16104
|
+
var radius = Math.sqrt(cx2p0x * cx2p0x + cy2p0y * cy2p0y);
|
|
16105
|
+
var segCount = (15 * absAngleDiff * Math.sqrt(radius) / Math.PI >> 0) + 1;
|
|
16106
|
+
var angleInc = angleDiff / segCount;
|
|
16107
|
+
startAngle += angleInc;
|
|
16108
|
+
if (clockwise) {
|
|
16109
|
+
verts.push(cx, cy);
|
|
16110
|
+
verts.push(sx, sy);
|
|
16111
|
+
for(var i = 1, angle = startAngle; i < segCount; i++, angle += angleInc){
|
|
16112
|
+
verts.push(cx, cy);
|
|
16113
|
+
verts.push(cx + Math.sin(angle) * radius, cy + Math.cos(angle) * radius);
|
|
16114
|
+
}
|
|
16115
|
+
verts.push(cx, cy);
|
|
16116
|
+
verts.push(ex, ey);
|
|
16117
|
+
} else {
|
|
16118
|
+
verts.push(sx, sy);
|
|
16119
|
+
verts.push(cx, cy);
|
|
16120
|
+
for(var i1 = 1, angle2 = startAngle; i1 < segCount; i1++, angle2 += angleInc){
|
|
16121
|
+
verts.push(cx + Math.sin(angle2) * radius, cy + Math.cos(angle2) * radius);
|
|
16122
|
+
verts.push(cx, cy);
|
|
16123
|
+
}
|
|
16124
|
+
verts.push(ex, ey);
|
|
16125
|
+
verts.push(cx, cy);
|
|
16126
|
+
}
|
|
16127
|
+
return segCount * 2;
|
|
16128
|
+
}
|
|
16129
|
+
function getOrientationOfPoints(points) {
|
|
16130
|
+
var m = points.length;
|
|
16131
|
+
if (m < 6) {
|
|
16132
|
+
return 1;
|
|
16133
|
+
}
|
|
16134
|
+
var area = 0;
|
|
16135
|
+
for(var i = 0, x1 = points[m - 2], y1 = points[m - 1]; i < m; i += 2){
|
|
16136
|
+
var x2 = points[i];
|
|
16137
|
+
var y2 = points[i + 1];
|
|
16138
|
+
area += (x2 - x1) * (y2 + y1);
|
|
16139
|
+
x1 = x2;
|
|
16140
|
+
y1 = y2;
|
|
16141
|
+
}
|
|
16142
|
+
if (area < 0) {
|
|
16143
|
+
return -1;
|
|
16144
|
+
}
|
|
16145
|
+
return 1;
|
|
16146
|
+
}
|
|
16147
|
+
/**
|
|
16148
|
+
* Builds a line to draw using the polygon method.
|
|
16149
|
+
* @param points
|
|
16150
|
+
* @param lineStyle
|
|
16151
|
+
* @param flipAlignment
|
|
16152
|
+
* @param closed
|
|
16153
|
+
* @param vertices
|
|
16154
|
+
* @param _verticesStride
|
|
16155
|
+
* @param _verticesOffset
|
|
16156
|
+
* @param indices
|
|
16157
|
+
* @param _indicesOffset
|
|
16158
|
+
*/ function buildLine(points, lineStyle, flipAlignment, closed, // alignment:number,
|
|
16159
|
+
vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
|
|
16160
|
+
// const shape = graphicsData.shape as Polygon;
|
|
16161
|
+
// let points = graphicsData.points || shape.points.slice();
|
|
16162
|
+
var eps = closePointEps;
|
|
16163
|
+
if (points.length === 0) {
|
|
16164
|
+
return;
|
|
16165
|
+
}
|
|
16166
|
+
var style = lineStyle;
|
|
16167
|
+
var alignment = style.alignment;
|
|
16168
|
+
if (lineStyle.alignment !== 0.5) {
|
|
16169
|
+
// rotate the points!
|
|
16170
|
+
var orientation = getOrientationOfPoints(points);
|
|
16171
|
+
if (flipAlignment) {
|
|
16172
|
+
orientation *= -1;
|
|
16173
|
+
}
|
|
16174
|
+
alignment = (alignment - 0.5) * orientation + 0.5;
|
|
16175
|
+
}
|
|
16176
|
+
// get first and last point.. figure out the middle!
|
|
16177
|
+
var firstPoint = new Point(points[0], points[1]);
|
|
16178
|
+
var lastPoint = new Point(points[points.length - 2], points[points.length - 1]);
|
|
16179
|
+
var closedShape = closed;
|
|
16180
|
+
var closedPath = Math.abs(firstPoint.x - lastPoint.x) < eps && Math.abs(firstPoint.y - lastPoint.y) < eps;
|
|
16181
|
+
// if the first point is the last point - gonna have issues :)
|
|
16182
|
+
if (closedShape) {
|
|
16183
|
+
// need to clone as we are going to slightly modify the shape..
|
|
16184
|
+
points = points.slice();
|
|
16185
|
+
if (closedPath) {
|
|
16186
|
+
points.pop();
|
|
16187
|
+
points.pop();
|
|
16188
|
+
lastPoint.set(points[points.length - 2], points[points.length - 1]);
|
|
16189
|
+
}
|
|
16190
|
+
var midPointX = (firstPoint.x + lastPoint.x) * 0.5;
|
|
16191
|
+
var midPointY = (lastPoint.y + firstPoint.y) * 0.5;
|
|
16192
|
+
points.unshift(midPointX, midPointY);
|
|
16193
|
+
points.push(midPointX, midPointY);
|
|
16194
|
+
}
|
|
16195
|
+
var verts = vertices;
|
|
16196
|
+
var length = points.length / 2;
|
|
16197
|
+
var indexCount = points.length;
|
|
16198
|
+
var indexStart = verts.length / 2;
|
|
16199
|
+
// Max. inner and outer width
|
|
16200
|
+
var width = style.width / 2;
|
|
16201
|
+
var widthSquared = width * width;
|
|
16202
|
+
var miterLimitSquared = style.miterLimit * style.miterLimit;
|
|
16203
|
+
/* Line segments of interest where (x1,y1) forms the corner. */ var x0 = points[0];
|
|
16204
|
+
var y0 = points[1];
|
|
16205
|
+
var x1 = points[2];
|
|
16206
|
+
var y1 = points[3];
|
|
16207
|
+
var x2 = 0;
|
|
16208
|
+
var y2 = 0;
|
|
16209
|
+
/* perp[?](x|y) = the line normal with magnitude lineWidth. */ var perpX = -(y0 - y1);
|
|
16210
|
+
var perpY = x0 - x1;
|
|
16211
|
+
var perp1x = 0;
|
|
16212
|
+
var perp1y = 0;
|
|
16213
|
+
var dist = Math.sqrt(perpX * perpX + perpY * perpY);
|
|
16214
|
+
perpX /= dist;
|
|
16215
|
+
perpY /= dist;
|
|
16216
|
+
perpX *= width;
|
|
16217
|
+
perpY *= width;
|
|
16218
|
+
var ratio = alignment; // 0.5;
|
|
16219
|
+
var innerWeight = (1 - ratio) * 2;
|
|
16220
|
+
var outerWeight = ratio * 2;
|
|
16221
|
+
if (!closedShape) {
|
|
16222
|
+
if (style.cap === "round") {
|
|
16223
|
+
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;
|
|
16224
|
+
} else if (style.cap === "square") {
|
|
16225
|
+
indexCount += square(x0, y0, perpX, perpY, innerWeight, outerWeight, true, verts);
|
|
16226
|
+
}
|
|
16227
|
+
}
|
|
16228
|
+
// Push first point (below & above vertices)
|
|
16229
|
+
verts.push(x0 - perpX * innerWeight, y0 - perpY * innerWeight);
|
|
16230
|
+
verts.push(x0 + perpX * outerWeight, y0 + perpY * outerWeight);
|
|
16231
|
+
for(var i = 1; i < length - 1; ++i){
|
|
16232
|
+
x0 = points[(i - 1) * 2];
|
|
16233
|
+
y0 = points[(i - 1) * 2 + 1];
|
|
16234
|
+
x1 = points[i * 2];
|
|
16235
|
+
y1 = points[i * 2 + 1];
|
|
16236
|
+
x2 = points[(i + 1) * 2];
|
|
16237
|
+
y2 = points[(i + 1) * 2 + 1];
|
|
16238
|
+
perpX = -(y0 - y1);
|
|
16239
|
+
perpY = x0 - x1;
|
|
16240
|
+
dist = Math.sqrt(perpX * perpX + perpY * perpY);
|
|
16241
|
+
perpX /= dist;
|
|
16242
|
+
perpY /= dist;
|
|
16243
|
+
perpX *= width;
|
|
16244
|
+
perpY *= width;
|
|
16245
|
+
perp1x = -(y1 - y2);
|
|
16246
|
+
perp1y = x1 - x2;
|
|
16247
|
+
dist = Math.sqrt(perp1x * perp1x + perp1y * perp1y);
|
|
16248
|
+
perp1x /= dist;
|
|
16249
|
+
perp1y /= dist;
|
|
16250
|
+
perp1x *= width;
|
|
16251
|
+
perp1y *= width;
|
|
16252
|
+
/* d[x|y](0|1) = the component displacement between points p(0,1|1,2) */ var dx0 = x1 - x0;
|
|
16253
|
+
var dy0 = y0 - y1;
|
|
16254
|
+
var dx1 = x1 - x2;
|
|
16255
|
+
var dy1 = y2 - y1;
|
|
16256
|
+
/* +ve if internal angle < 90 degree, -ve if internal angle > 90 degree. */ var dot = dx0 * dx1 + dy0 * dy1;
|
|
16257
|
+
/* +ve if internal angle counterclockwise, -ve if internal angle clockwise. */ var cross = dy0 * dx1 - dy1 * dx0;
|
|
16258
|
+
var clockwise = cross < 0;
|
|
16259
|
+
/* Going nearly parallel? */ /* atan(0.001) ~= 0.001 rad ~= 0.057 degree */ if (Math.abs(cross) < 0.001 * Math.abs(dot)) {
|
|
16260
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
|
|
16261
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
|
|
16262
|
+
/* 180 degree corner? */ if (dot >= 0) {
|
|
16263
|
+
if (style.join === "round") {
|
|
16264
|
+
indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 4;
|
|
16265
|
+
} else {
|
|
16266
|
+
indexCount += 2;
|
|
16267
|
+
}
|
|
16268
|
+
verts.push(x1 - perp1x * outerWeight, y1 - perp1y * outerWeight);
|
|
16269
|
+
verts.push(x1 + perp1x * innerWeight, y1 + perp1y * innerWeight);
|
|
16270
|
+
}
|
|
16271
|
+
continue;
|
|
16272
|
+
}
|
|
16273
|
+
/* 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);
|
|
16274
|
+
var c2 = (-perp1x + x2) * (-perp1y + y1) - (-perp1x + x1) * (-perp1y + y2);
|
|
16275
|
+
var px = (dx0 * c2 - dx1 * c1) / cross;
|
|
16276
|
+
var py = (dy1 * c1 - dy0 * c2) / cross;
|
|
16277
|
+
var pDist = (px - x1) * (px - x1) + (py - y1) * (py - y1);
|
|
16278
|
+
/* Inner miter point */ var imx = x1 + (px - x1) * innerWeight;
|
|
16279
|
+
var imy = y1 + (py - y1) * innerWeight;
|
|
16280
|
+
/* Outer miter point */ var omx = x1 - (px - x1) * outerWeight;
|
|
16281
|
+
var omy = y1 - (py - y1) * outerWeight;
|
|
16282
|
+
/* Is the inside miter point too far away, creating a spike? */ var smallerInsideSegmentSq = Math.min(dx0 * dx0 + dy0 * dy0, dx1 * dx1 + dy1 * dy1);
|
|
16283
|
+
var insideWeight = clockwise ? innerWeight : outerWeight;
|
|
16284
|
+
var smallerInsideDiagonalSq = smallerInsideSegmentSq + insideWeight * insideWeight * widthSquared;
|
|
16285
|
+
var insideMiterOk = pDist <= smallerInsideDiagonalSq;
|
|
16286
|
+
if (insideMiterOk) {
|
|
16287
|
+
if (style.join === "bevel" || pDist / widthSquared > miterLimitSquared) {
|
|
16288
|
+
if (clockwise) /* rotating at inner angle */ {
|
|
16289
|
+
verts.push(imx, imy); // inner miter point
|
|
16290
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
|
|
16291
|
+
verts.push(imx, imy); // inner miter point
|
|
16292
|
+
verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight); // second segment's outer vertex
|
|
16293
|
+
} else /* rotating at outer angle */ {
|
|
16294
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight); // first segment's inner vertex
|
|
16295
|
+
verts.push(omx, omy); // outer miter point
|
|
16296
|
+
verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight); // second segment's outer vertex
|
|
16297
|
+
verts.push(omx, omy); // outer miter point
|
|
16298
|
+
}
|
|
16299
|
+
indexCount += 2;
|
|
16300
|
+
} else if (style.join === "round") {
|
|
16301
|
+
if (clockwise) /* arc is outside */ {
|
|
16302
|
+
verts.push(imx, imy);
|
|
16303
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
|
|
16304
|
+
indexCount += round(x1, y1, x1 + perpX * outerWeight, y1 + perpY * outerWeight, x1 + perp1x * outerWeight, y1 + perp1y * outerWeight, verts, true) + 4;
|
|
16305
|
+
verts.push(imx, imy);
|
|
16306
|
+
verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight);
|
|
16307
|
+
} else /* arc is inside */ {
|
|
16308
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
|
|
16309
|
+
verts.push(omx, omy);
|
|
16310
|
+
indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 4;
|
|
16311
|
+
verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight);
|
|
16312
|
+
verts.push(omx, omy);
|
|
16313
|
+
}
|
|
16314
|
+
} else {
|
|
16315
|
+
verts.push(imx, imy);
|
|
16316
|
+
verts.push(omx, omy);
|
|
16317
|
+
}
|
|
16318
|
+
} else {
|
|
16319
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight); // first segment's inner vertex
|
|
16320
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
|
|
16321
|
+
if (style.join === "round") {
|
|
16322
|
+
if (clockwise) /* arc is outside */ {
|
|
16323
|
+
indexCount += round(x1, y1, x1 + perpX * outerWeight, y1 + perpY * outerWeight, x1 + perp1x * outerWeight, y1 + perp1y * outerWeight, verts, true) + 2;
|
|
16324
|
+
} else /* arc is inside */ {
|
|
16325
|
+
indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 2;
|
|
16326
|
+
}
|
|
16327
|
+
} else if (style.join === "miter" && pDist / widthSquared <= miterLimitSquared) {
|
|
16328
|
+
if (clockwise) {
|
|
16329
|
+
verts.push(omx, omy); // inner miter point
|
|
16330
|
+
verts.push(omx, omy); // inner miter point
|
|
16331
|
+
} else {
|
|
16332
|
+
verts.push(imx, imy); // outer miter point
|
|
16333
|
+
verts.push(imx, imy); // outer miter point
|
|
16334
|
+
}
|
|
16335
|
+
indexCount += 2;
|
|
16336
|
+
}
|
|
16337
|
+
verts.push(x1 - perp1x * innerWeight, y1 - perp1y * innerWeight); // second segment's inner vertex
|
|
16338
|
+
verts.push(x1 + perp1x * outerWeight, y1 + perp1y * outerWeight); // second segment's outer vertex
|
|
16339
|
+
indexCount += 2;
|
|
16340
|
+
}
|
|
16341
|
+
}
|
|
16342
|
+
x0 = points[(length - 2) * 2];
|
|
16343
|
+
y0 = points[(length - 2) * 2 + 1];
|
|
16344
|
+
x1 = points[(length - 1) * 2];
|
|
16345
|
+
y1 = points[(length - 1) * 2 + 1];
|
|
16346
|
+
perpX = -(y0 - y1);
|
|
16347
|
+
perpY = x0 - x1;
|
|
16348
|
+
dist = Math.sqrt(perpX * perpX + perpY * perpY);
|
|
16349
|
+
perpX /= dist;
|
|
16350
|
+
perpY /= dist;
|
|
16351
|
+
perpX *= width;
|
|
16352
|
+
perpY *= width;
|
|
16353
|
+
verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
|
|
16354
|
+
verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
|
|
16355
|
+
if (!closedShape) {
|
|
16356
|
+
if (style.cap === "round") {
|
|
16357
|
+
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;
|
|
16358
|
+
} else if (style.cap === "square") {
|
|
16359
|
+
indexCount += square(x1, y1, perpX, perpY, innerWeight, outerWeight, false, verts);
|
|
16360
|
+
}
|
|
16361
|
+
}
|
|
16362
|
+
// const indices = graphicsGeometry.indices;
|
|
16363
|
+
var eps2 = curveEps * curveEps;
|
|
16364
|
+
// indices.push(indexStart);
|
|
16365
|
+
for(var i1 = indexStart; i1 < indexCount + indexStart - 2; ++i1){
|
|
16366
|
+
x0 = verts[i1 * 2];
|
|
16367
|
+
y0 = verts[i1 * 2 + 1];
|
|
16368
|
+
x1 = verts[(i1 + 1) * 2];
|
|
16369
|
+
y1 = verts[(i1 + 1) * 2 + 1];
|
|
16370
|
+
x2 = verts[(i1 + 2) * 2];
|
|
16371
|
+
y2 = verts[(i1 + 2) * 2 + 1];
|
|
16372
|
+
/* Skip zero area triangles */ if (Math.abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) < eps2) {
|
|
16373
|
+
continue;
|
|
16374
|
+
}
|
|
16375
|
+
indices.push(i1, i1 + 1, i1 + 2);
|
|
16376
|
+
}
|
|
16377
|
+
}
|
|
16378
|
+
|
|
15861
16379
|
var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
15862
16380
|
_inherits(ShapeComponent, MeshComponent);
|
|
15863
16381
|
function ShapeComponent(engine) {
|
|
15864
16382
|
var _this;
|
|
15865
16383
|
_this = MeshComponent.call(this, engine) || this;
|
|
15866
|
-
_this.
|
|
16384
|
+
_this.isStroke = false;
|
|
16385
|
+
_this.graphicsPath = new GraphicsPath();
|
|
15867
16386
|
_this.curveValues = [];
|
|
15868
|
-
_this.
|
|
16387
|
+
_this.shapeDirty = true;
|
|
15869
16388
|
_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";
|
|
15870
16389
|
_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";
|
|
15871
16390
|
if (!_this.geometry) {
|
|
@@ -15913,6 +16432,13 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15913
16432
|
_this.material.depthTest = true;
|
|
15914
16433
|
_this.material.blending = true;
|
|
15915
16434
|
}
|
|
16435
|
+
_this.strokeAttributes = {
|
|
16436
|
+
width: 1,
|
|
16437
|
+
alignment: 0.5,
|
|
16438
|
+
cap: "butt",
|
|
16439
|
+
join: "miter",
|
|
16440
|
+
miterLimit: 10
|
|
16441
|
+
};
|
|
15916
16442
|
return _this;
|
|
15917
16443
|
}
|
|
15918
16444
|
var _proto = ShapeComponent.prototype;
|
|
@@ -15920,10 +16446,10 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15920
16446
|
this.item.getHitTestParams = this.getHitTestParams;
|
|
15921
16447
|
};
|
|
15922
16448
|
_proto.onUpdate = function onUpdate(dt) {
|
|
15923
|
-
if (this.
|
|
16449
|
+
if (this.shapeDirty) {
|
|
15924
16450
|
this.buildPath(this.data);
|
|
15925
|
-
this.buildGeometryFromPath(this.
|
|
15926
|
-
this.
|
|
16451
|
+
this.buildGeometryFromPath(this.graphicsPath.shapePath);
|
|
16452
|
+
this.shapeDirty = false;
|
|
15927
16453
|
}
|
|
15928
16454
|
};
|
|
15929
16455
|
_proto.buildGeometryFromPath = function buildGeometryFromPath(shapePath) {
|
|
@@ -15938,7 +16464,13 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15938
16464
|
var indexOffset = indices.length;
|
|
15939
16465
|
var vertOffset = vertices.length / 2;
|
|
15940
16466
|
shape.build(points);
|
|
15941
|
-
|
|
16467
|
+
if (!this.isStroke) {
|
|
16468
|
+
shape.triangulate(points, vertices, vertOffset, indices, indexOffset);
|
|
16469
|
+
} else {
|
|
16470
|
+
var close = true;
|
|
16471
|
+
var lineStyle = this.strokeAttributes;
|
|
16472
|
+
buildLine(points, lineStyle, false, close, vertices, 2, vertOffset, indices);
|
|
16473
|
+
}
|
|
15942
16474
|
}
|
|
15943
16475
|
var vertexCount = vertices.length / 2;
|
|
15944
16476
|
// get the current attribute and index arrays from the geometry, avoiding re-creation
|
|
@@ -15951,7 +16483,7 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15951
16483
|
if (!uvArray || uvArray.length < vertexCount * 2) {
|
|
15952
16484
|
uvArray = new Float32Array(vertexCount * 2);
|
|
15953
16485
|
}
|
|
15954
|
-
if (!indexArray) {
|
|
16486
|
+
if (!indexArray || indexArray.length < indices.length) {
|
|
15955
16487
|
indexArray = new Uint16Array(indices.length);
|
|
15956
16488
|
}
|
|
15957
16489
|
// set position and uv attribute array
|
|
@@ -15974,7 +16506,7 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15974
16506
|
this.geometry.setDrawCount(indices.length);
|
|
15975
16507
|
};
|
|
15976
16508
|
_proto.buildPath = function buildPath(data) {
|
|
15977
|
-
this.
|
|
16509
|
+
this.graphicsPath.clear();
|
|
15978
16510
|
var shapeData = data;
|
|
15979
16511
|
switch(shapeData.type){
|
|
15980
16512
|
case ShapePrimitiveType.Custom:
|
|
@@ -15983,9 +16515,9 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
15983
16515
|
var points = customData.points;
|
|
15984
16516
|
var easingIns = customData.easingIns;
|
|
15985
16517
|
var easingOuts = customData.easingOuts;
|
|
15986
|
-
this.curveValues = [];
|
|
15987
16518
|
for(var _iterator = _create_for_of_iterator_helper_loose(customData.shapes), _step; !(_step = _iterator()).done;){
|
|
15988
16519
|
var shape = _step.value;
|
|
16520
|
+
this.curveValues = [];
|
|
15989
16521
|
this.setFillColor(shape.fill);
|
|
15990
16522
|
var indices = shape.indexes;
|
|
15991
16523
|
for(var i = 1; i < indices.length; i++){
|
|
@@ -16003,42 +16535,42 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
16003
16535
|
controlPoint1: easingOuts[indices[indices.length - 1].easingOut],
|
|
16004
16536
|
controlPoint2: easingIns[indices[0].easingIn]
|
|
16005
16537
|
});
|
|
16006
|
-
|
|
16007
|
-
|
|
16008
|
-
|
|
16009
|
-
|
|
16010
|
-
|
|
16011
|
-
|
|
16012
|
-
|
|
16013
|
-
|
|
16538
|
+
this.graphicsPath.moveTo(this.curveValues[this.curveValues.length - 1].point.x, this.curveValues[this.curveValues.length - 1].point.y);
|
|
16539
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(this.curveValues), _step1; !(_step1 = _iterator1()).done;){
|
|
16540
|
+
var curveValue = _step1.value;
|
|
16541
|
+
var point = curveValue.point;
|
|
16542
|
+
var control1 = curveValue.controlPoint1;
|
|
16543
|
+
var control2 = curveValue.controlPoint2;
|
|
16544
|
+
this.graphicsPath.bezierCurveTo(control1.x, control1.y, control2.x, control2.y, point.x, point.y, 1);
|
|
16545
|
+
}
|
|
16014
16546
|
}
|
|
16015
16547
|
break;
|
|
16016
16548
|
}
|
|
16017
16549
|
case ShapePrimitiveType.Ellipse:
|
|
16018
16550
|
{
|
|
16019
16551
|
var ellipseData = shapeData;
|
|
16020
|
-
this.
|
|
16552
|
+
this.graphicsPath.ellipse(0, 0, ellipseData.xRadius, ellipseData.yRadius);
|
|
16021
16553
|
this.setFillColor(ellipseData.fill);
|
|
16022
16554
|
break;
|
|
16023
16555
|
}
|
|
16024
16556
|
case ShapePrimitiveType.Rectangle:
|
|
16025
16557
|
{
|
|
16026
16558
|
var rectangleData = shapeData;
|
|
16027
|
-
this.
|
|
16559
|
+
this.graphicsPath.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height);
|
|
16028
16560
|
this.setFillColor(rectangleData.fill);
|
|
16029
16561
|
break;
|
|
16030
16562
|
}
|
|
16031
16563
|
case ShapePrimitiveType.Star:
|
|
16032
16564
|
{
|
|
16033
16565
|
var starData = shapeData;
|
|
16034
|
-
this.
|
|
16566
|
+
this.graphicsPath.polyStar(starData.pointCount, starData.outerRadius, starData.innerRadius, starData.outerRoundness, starData.innerRoundness, StarType.Star);
|
|
16035
16567
|
this.setFillColor(starData.fill);
|
|
16036
16568
|
break;
|
|
16037
16569
|
}
|
|
16038
16570
|
case ShapePrimitiveType.Polygon:
|
|
16039
16571
|
{
|
|
16040
16572
|
var polygonData = shapeData;
|
|
16041
|
-
this.
|
|
16573
|
+
this.graphicsPath.polyStar(polygonData.pointCount, polygonData.radius, polygonData.radius, polygonData.roundness, polygonData.roundness, StarType.Polygon);
|
|
16042
16574
|
this.setFillColor(polygonData.fill);
|
|
16043
16575
|
break;
|
|
16044
16576
|
}
|
|
@@ -16053,6 +16585,12 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
16053
16585
|
_proto.fromData = function fromData(data) {
|
|
16054
16586
|
MeshComponent.prototype.fromData.call(this, data);
|
|
16055
16587
|
this.data = data;
|
|
16588
|
+
this.shapeDirty = true;
|
|
16589
|
+
var strokeParam = data.stroke;
|
|
16590
|
+
if (strokeParam) {
|
|
16591
|
+
this.isStroke = true;
|
|
16592
|
+
this.strokeAttributes.width = strokeParam.width;
|
|
16593
|
+
}
|
|
16056
16594
|
var material = this.material;
|
|
16057
16595
|
//@ts-expect-error // TODO 新版蒙版上线后重构
|
|
16058
16596
|
material.stencilRef = data.renderer.mask !== undefined ? [
|
|
@@ -16062,6 +16600,15 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
|
16062
16600
|
//@ts-expect-error // TODO 新版蒙版上线后重构
|
|
16063
16601
|
setMaskMode(material, data.renderer.maskMode);
|
|
16064
16602
|
};
|
|
16603
|
+
_create_class(ShapeComponent, [
|
|
16604
|
+
{
|
|
16605
|
+
key: "path",
|
|
16606
|
+
get: function get() {
|
|
16607
|
+
this.shapeDirty = true;
|
|
16608
|
+
return this.data;
|
|
16609
|
+
}
|
|
16610
|
+
}
|
|
16611
|
+
]);
|
|
16065
16612
|
return ShapeComponent;
|
|
16066
16613
|
}(MeshComponent);
|
|
16067
16614
|
ShapeComponent = __decorate([
|
|
@@ -18749,10 +19296,19 @@ var TEMPLATE_USE_OFFSCREEN_CANVAS = "offscreen_canvas";
|
|
|
18749
19296
|
// 后处理配置相关
|
|
18750
19297
|
var POST_PROCESS_SETTINGS = "post_process_settings";
|
|
18751
19298
|
var config = {};
|
|
18752
|
-
|
|
19299
|
+
/**
|
|
19300
|
+
* 获取全局配置项
|
|
19301
|
+
* @param name
|
|
19302
|
+
* @returns
|
|
19303
|
+
*/ function getConfig(name) {
|
|
18753
19304
|
return config[name];
|
|
18754
19305
|
}
|
|
18755
|
-
|
|
19306
|
+
/**
|
|
19307
|
+
* 设置全局配置项
|
|
19308
|
+
* @param name
|
|
19309
|
+
* @param value
|
|
19310
|
+
* @returns
|
|
19311
|
+
*/ function setConfig(name, value) {
|
|
18756
19312
|
return config[name] = value;
|
|
18757
19313
|
}
|
|
18758
19314
|
|
|
@@ -23099,88 +23655,81 @@ var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
23099
23655
|
return PropertyClipPlayable;
|
|
23100
23656
|
}(Playable);
|
|
23101
23657
|
|
|
23102
|
-
var
|
|
23103
|
-
_inherits(
|
|
23104
|
-
function
|
|
23658
|
+
var PropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
|
|
23659
|
+
_inherits(PropertyMixerPlayable, TrackMixerPlayable);
|
|
23660
|
+
function PropertyMixerPlayable() {
|
|
23105
23661
|
var _this;
|
|
23106
23662
|
_this = TrackMixerPlayable.apply(this, arguments) || this;
|
|
23107
23663
|
_this.propertyName = "";
|
|
23108
23664
|
return _this;
|
|
23109
23665
|
}
|
|
23110
|
-
var _proto =
|
|
23666
|
+
var _proto = PropertyMixerPlayable.prototype;
|
|
23111
23667
|
_proto.evaluate = function evaluate(context) {
|
|
23112
23668
|
var boundObject = context.output.getUserData();
|
|
23113
23669
|
if (!boundObject) {
|
|
23114
23670
|
return;
|
|
23115
23671
|
}
|
|
23116
23672
|
var hasInput = false;
|
|
23117
|
-
|
|
23118
|
-
if (
|
|
23673
|
+
this.propertyValue = boundObject[this.propertyName];
|
|
23674
|
+
if (this.propertyValue === undefined || this.propertyValue === null) {
|
|
23119
23675
|
return;
|
|
23120
23676
|
}
|
|
23121
|
-
|
|
23677
|
+
this.resetPropertyValue();
|
|
23122
23678
|
// evaluate the curve
|
|
23123
23679
|
for(var i = 0; i < this.clipPlayables.length; i++){
|
|
23124
23680
|
var weight = this.getClipWeight(i);
|
|
23125
23681
|
if (weight > 0) {
|
|
23126
23682
|
var propertyClipPlayable = this.getClipPlayable(i);
|
|
23127
23683
|
if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
|
|
23128
|
-
console.error("
|
|
23684
|
+
console.error("PropertyTrack added non-PropertyPlayableAsset");
|
|
23129
23685
|
continue;
|
|
23130
23686
|
}
|
|
23131
23687
|
var curveValue = propertyClipPlayable.value;
|
|
23132
|
-
|
|
23133
|
-
value.g += curveValue.g * weight;
|
|
23134
|
-
value.b += curveValue.b * weight;
|
|
23135
|
-
value.a += curveValue.a * weight;
|
|
23688
|
+
this.addWeightedValue(curveValue, weight);
|
|
23136
23689
|
hasInput = true;
|
|
23137
23690
|
}
|
|
23138
23691
|
}
|
|
23139
23692
|
// set value
|
|
23140
23693
|
if (hasInput) {
|
|
23141
|
-
boundObject[this.propertyName] =
|
|
23694
|
+
boundObject[this.propertyName] = this.propertyValue;
|
|
23142
23695
|
}
|
|
23143
23696
|
};
|
|
23144
|
-
return
|
|
23697
|
+
return PropertyMixerPlayable;
|
|
23145
23698
|
}(TrackMixerPlayable);
|
|
23146
23699
|
|
|
23147
|
-
var
|
|
23148
|
-
_inherits(
|
|
23700
|
+
var ColorPropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
|
|
23701
|
+
_inherits(ColorPropertyMixerPlayable, PropertyMixerPlayable);
|
|
23702
|
+
function ColorPropertyMixerPlayable() {
|
|
23703
|
+
return PropertyMixerPlayable.apply(this, arguments);
|
|
23704
|
+
}
|
|
23705
|
+
var _proto = ColorPropertyMixerPlayable.prototype;
|
|
23706
|
+
_proto.resetPropertyValue = function resetPropertyValue() {
|
|
23707
|
+
this.propertyValue.setZero();
|
|
23708
|
+
};
|
|
23709
|
+
_proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
|
|
23710
|
+
var result = this.propertyValue;
|
|
23711
|
+
result.r += curveValue.r * weight;
|
|
23712
|
+
result.g += curveValue.g * weight;
|
|
23713
|
+
result.b += curveValue.b * weight;
|
|
23714
|
+
result.a += curveValue.a * weight;
|
|
23715
|
+
};
|
|
23716
|
+
return ColorPropertyMixerPlayable;
|
|
23717
|
+
}(PropertyMixerPlayable);
|
|
23718
|
+
|
|
23719
|
+
var FloatPropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
|
|
23720
|
+
_inherits(FloatPropertyMixerPlayable, PropertyMixerPlayable);
|
|
23149
23721
|
function FloatPropertyMixerPlayable() {
|
|
23150
|
-
|
|
23151
|
-
_this = TrackMixerPlayable.apply(this, arguments) || this;
|
|
23152
|
-
_this.propertyName = "";
|
|
23153
|
-
return _this;
|
|
23722
|
+
return PropertyMixerPlayable.apply(this, arguments);
|
|
23154
23723
|
}
|
|
23155
23724
|
var _proto = FloatPropertyMixerPlayable.prototype;
|
|
23156
|
-
_proto.
|
|
23157
|
-
|
|
23158
|
-
|
|
23159
|
-
|
|
23160
|
-
|
|
23161
|
-
var hasInput = false;
|
|
23162
|
-
var value = 0;
|
|
23163
|
-
// evaluate the curve
|
|
23164
|
-
for(var i = 0; i < this.clipPlayables.length; i++){
|
|
23165
|
-
var weight = this.getClipWeight(i);
|
|
23166
|
-
if (weight > 0) {
|
|
23167
|
-
var propertyClipPlayable = this.getClipPlayable(i);
|
|
23168
|
-
if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
|
|
23169
|
-
console.error("FloatPropertyTrack added non-FloatPropertyPlayableAsset");
|
|
23170
|
-
continue;
|
|
23171
|
-
}
|
|
23172
|
-
var curveValue = propertyClipPlayable.value;
|
|
23173
|
-
value += curveValue * weight;
|
|
23174
|
-
hasInput = true;
|
|
23175
|
-
}
|
|
23176
|
-
}
|
|
23177
|
-
// set value
|
|
23178
|
-
if (hasInput) {
|
|
23179
|
-
boundObject[this.propertyName] = value;
|
|
23180
|
-
}
|
|
23725
|
+
_proto.resetPropertyValue = function resetPropertyValue() {
|
|
23726
|
+
this.propertyValue = 0;
|
|
23727
|
+
};
|
|
23728
|
+
_proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
|
|
23729
|
+
this.propertyValue += curveValue * weight;
|
|
23181
23730
|
};
|
|
23182
23731
|
return FloatPropertyMixerPlayable;
|
|
23183
|
-
}(
|
|
23732
|
+
}(PropertyMixerPlayable);
|
|
23184
23733
|
|
|
23185
23734
|
var ParticleMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
|
|
23186
23735
|
_inherits(ParticleMixerPlayable, TrackMixerPlayable);
|
|
@@ -23924,50 +24473,40 @@ var TransformMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
|
|
|
23924
24473
|
return TransformMixerPlayable;
|
|
23925
24474
|
}(TrackMixerPlayable);
|
|
23926
24475
|
|
|
23927
|
-
var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(
|
|
23928
|
-
_inherits(Vector4PropertyMixerPlayable,
|
|
24476
|
+
var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
|
|
24477
|
+
_inherits(Vector4PropertyMixerPlayable, PropertyMixerPlayable);
|
|
23929
24478
|
function Vector4PropertyMixerPlayable() {
|
|
23930
|
-
|
|
23931
|
-
_this = TrackMixerPlayable.apply(this, arguments) || this;
|
|
23932
|
-
_this.propertyName = "";
|
|
23933
|
-
return _this;
|
|
24479
|
+
return PropertyMixerPlayable.apply(this, arguments);
|
|
23934
24480
|
}
|
|
23935
24481
|
var _proto = Vector4PropertyMixerPlayable.prototype;
|
|
23936
|
-
_proto.
|
|
23937
|
-
|
|
23938
|
-
|
|
23939
|
-
|
|
23940
|
-
|
|
23941
|
-
|
|
23942
|
-
|
|
23943
|
-
|
|
23944
|
-
|
|
23945
|
-
}
|
|
23946
|
-
value.setZero();
|
|
23947
|
-
// evaluate the curve
|
|
23948
|
-
for(var i = 0; i < this.clipPlayables.length; i++){
|
|
23949
|
-
var weight = this.getClipWeight(i);
|
|
23950
|
-
if (weight > 0) {
|
|
23951
|
-
var propertyClipPlayable = this.getClipPlayable(i);
|
|
23952
|
-
if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
|
|
23953
|
-
console.error("Vector4PropertyTrack added non-Vector4PropertyPlayableAsset");
|
|
23954
|
-
continue;
|
|
23955
|
-
}
|
|
23956
|
-
var curveValue = propertyClipPlayable.value;
|
|
23957
|
-
value.x += curveValue.x * weight;
|
|
23958
|
-
value.y += curveValue.y * weight;
|
|
23959
|
-
value.z += curveValue.z * weight;
|
|
23960
|
-
value.w += curveValue.w * weight;
|
|
23961
|
-
hasInput = true;
|
|
23962
|
-
}
|
|
23963
|
-
}
|
|
23964
|
-
// set value
|
|
23965
|
-
if (hasInput) {
|
|
23966
|
-
boundObject[this.propertyName] = value;
|
|
23967
|
-
}
|
|
24482
|
+
_proto.resetPropertyValue = function resetPropertyValue() {
|
|
24483
|
+
this.propertyValue.setZero();
|
|
24484
|
+
};
|
|
24485
|
+
_proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
|
|
24486
|
+
var result = this.propertyValue;
|
|
24487
|
+
result.x += curveValue.x * weight;
|
|
24488
|
+
result.y += curveValue.y * weight;
|
|
24489
|
+
result.z += curveValue.z * weight;
|
|
24490
|
+
result.w += curveValue.w * weight;
|
|
23968
24491
|
};
|
|
23969
24492
|
return Vector4PropertyMixerPlayable;
|
|
23970
|
-
}(
|
|
24493
|
+
}(PropertyMixerPlayable);
|
|
24494
|
+
var Vector2PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
|
|
24495
|
+
_inherits(Vector2PropertyMixerPlayable, PropertyMixerPlayable);
|
|
24496
|
+
function Vector2PropertyMixerPlayable() {
|
|
24497
|
+
return PropertyMixerPlayable.apply(this, arguments);
|
|
24498
|
+
}
|
|
24499
|
+
var _proto = Vector2PropertyMixerPlayable.prototype;
|
|
24500
|
+
_proto.resetPropertyValue = function resetPropertyValue() {
|
|
24501
|
+
this.propertyValue.setZero();
|
|
24502
|
+
};
|
|
24503
|
+
_proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
|
|
24504
|
+
var result = this.propertyValue;
|
|
24505
|
+
result.x += curveValue.x * weight;
|
|
24506
|
+
result.y += curveValue.y * weight;
|
|
24507
|
+
};
|
|
24508
|
+
return Vector2PropertyMixerPlayable;
|
|
24509
|
+
}(PropertyMixerPlayable);
|
|
23971
24510
|
|
|
23972
24511
|
/**
|
|
23973
24512
|
* @since 2.0.0
|
|
@@ -24348,6 +24887,26 @@ var Vector4PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
|
|
|
24348
24887
|
Vector4PropertyTrack = __decorate([
|
|
24349
24888
|
effectsClass(DataType.Vector4PropertyTrack)
|
|
24350
24889
|
], Vector4PropertyTrack);
|
|
24890
|
+
var Vector2PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
|
|
24891
|
+
_inherits(Vector2PropertyTrack, PropertyTrack);
|
|
24892
|
+
function Vector2PropertyTrack() {
|
|
24893
|
+
return PropertyTrack.apply(this, arguments);
|
|
24894
|
+
}
|
|
24895
|
+
var _proto = Vector2PropertyTrack.prototype;
|
|
24896
|
+
_proto.createTrackMixer = function createTrackMixer(graph) {
|
|
24897
|
+
var mixer = new Vector2PropertyMixerPlayable(graph);
|
|
24898
|
+
var propertyNames = this.propertyNames;
|
|
24899
|
+
if (propertyNames.length > 0) {
|
|
24900
|
+
var propertyName = propertyNames[propertyNames.length - 1];
|
|
24901
|
+
mixer.propertyName = propertyName;
|
|
24902
|
+
}
|
|
24903
|
+
return mixer;
|
|
24904
|
+
};
|
|
24905
|
+
return Vector2PropertyTrack;
|
|
24906
|
+
}(PropertyTrack);
|
|
24907
|
+
Vector2PropertyTrack = __decorate([
|
|
24908
|
+
effectsClass("Vector2PropertyTrack")
|
|
24909
|
+
], Vector2PropertyTrack);
|
|
24351
24910
|
|
|
24352
24911
|
var ColorPropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
|
|
24353
24912
|
_inherits(ColorPropertyTrack, PropertyTrack);
|
|
@@ -24614,8 +25173,28 @@ __decorate([
|
|
|
24614
25173
|
serialize()
|
|
24615
25174
|
], Vector4PropertyPlayableAsset.prototype, "curveData", void 0);
|
|
24616
25175
|
Vector4PropertyPlayableAsset = __decorate([
|
|
24617
|
-
effectsClass(
|
|
25176
|
+
effectsClass(DataType.Vector4PropertyPlayableAsset)
|
|
24618
25177
|
], Vector4PropertyPlayableAsset);
|
|
25178
|
+
var Vector2PropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
|
|
25179
|
+
_inherits(Vector2PropertyPlayableAsset, PlayableAsset);
|
|
25180
|
+
function Vector2PropertyPlayableAsset() {
|
|
25181
|
+
return PlayableAsset.apply(this, arguments);
|
|
25182
|
+
}
|
|
25183
|
+
var _proto = Vector2PropertyPlayableAsset.prototype;
|
|
25184
|
+
_proto.createPlayable = function createPlayable(graph) {
|
|
25185
|
+
var clipPlayable = new PropertyClipPlayable(graph);
|
|
25186
|
+
clipPlayable.curve = createValueGetter(this.curveData);
|
|
25187
|
+
clipPlayable.value = clipPlayable.curve.getValue(0);
|
|
25188
|
+
return clipPlayable;
|
|
25189
|
+
};
|
|
25190
|
+
return Vector2PropertyPlayableAsset;
|
|
25191
|
+
}(PlayableAsset);
|
|
25192
|
+
__decorate([
|
|
25193
|
+
serialize()
|
|
25194
|
+
], Vector2PropertyPlayableAsset.prototype, "curveData", void 0);
|
|
25195
|
+
Vector2PropertyPlayableAsset = __decorate([
|
|
25196
|
+
effectsClass(DataType.Vector2PropertyPlayableAsset)
|
|
25197
|
+
], Vector2PropertyPlayableAsset);
|
|
24619
25198
|
|
|
24620
25199
|
var ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset) {
|
|
24621
25200
|
_inherits(ObjectBindingTrack, TrackAsset);
|
|
@@ -25998,7 +26577,7 @@ function getStandardInteractContent(ui) {
|
|
|
25998
26577
|
}
|
|
25999
26578
|
});
|
|
26000
26579
|
});
|
|
26001
|
-
json.version = "
|
|
26580
|
+
json.version = JSONSceneVersion["2_1"];
|
|
26002
26581
|
return json;
|
|
26003
26582
|
}
|
|
26004
26583
|
/**
|
|
@@ -26337,7 +26916,7 @@ function getStandardInteractContent(ui) {
|
|
|
26337
26916
|
break;
|
|
26338
26917
|
}
|
|
26339
26918
|
}
|
|
26340
|
-
result.version = "
|
|
26919
|
+
result.version = JSONSceneVersion["3_0"];
|
|
26341
26920
|
return result;
|
|
26342
26921
|
}
|
|
26343
26922
|
/**
|
|
@@ -26879,13 +27458,13 @@ function getStandardJSON(json) {
|
|
|
26879
27458
|
}
|
|
26880
27459
|
throw new Error("Invalid JSON version: " + json.version + ".");
|
|
26881
27460
|
}
|
|
26882
|
-
var currentVersion = "
|
|
27461
|
+
var currentVersion = JSONSceneVersion["1_0"];
|
|
26883
27462
|
function getStandardJSONFromV0(json) {
|
|
26884
27463
|
var _json_bins;
|
|
26885
|
-
currentVersion = "
|
|
27464
|
+
currentVersion = JSONSceneVersion["1_0"];
|
|
26886
27465
|
var plugins = json.plugins || [];
|
|
26887
27466
|
if ((_json_bins = json.bins) == null ? void 0 : _json_bins.length) {
|
|
26888
|
-
currentVersion = "
|
|
27467
|
+
currentVersion = JSONSceneVersion["1_3"];
|
|
26889
27468
|
}
|
|
26890
27469
|
var requires = (json.requires || []).slice();
|
|
26891
27470
|
var images = json.images.map(function(img, index) {
|
|
@@ -28808,7 +29387,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
28808
29387
|
*/ _proto.getSpeed = function getSpeed() {
|
|
28809
29388
|
return this.speed;
|
|
28810
29389
|
};
|
|
28811
|
-
|
|
29390
|
+
/**
|
|
29391
|
+
*
|
|
29392
|
+
*/ _proto.play = function play() {
|
|
28812
29393
|
if (this.isEnded && this.reusable) {
|
|
28813
29394
|
this.restart();
|
|
28814
29395
|
}
|
|
@@ -28823,7 +29404,10 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
28823
29404
|
*/ _proto.pause = function pause() {
|
|
28824
29405
|
this.paused = true;
|
|
28825
29406
|
};
|
|
28826
|
-
|
|
29407
|
+
/**
|
|
29408
|
+
*
|
|
29409
|
+
* @returns
|
|
29410
|
+
*/ _proto.getPaused = function getPaused() {
|
|
28827
29411
|
return this.paused;
|
|
28828
29412
|
};
|
|
28829
29413
|
/**
|
|
@@ -31401,7 +31985,7 @@ registerPlugin("sprite", SpriteLoader, VFXItem, true);
|
|
|
31401
31985
|
registerPlugin("particle", ParticleLoader, VFXItem, true);
|
|
31402
31986
|
registerPlugin("cal", CalculateLoader, VFXItem, true);
|
|
31403
31987
|
registerPlugin("interact", InteractLoader, VFXItem, true);
|
|
31404
|
-
var version$1 = "2.
|
|
31988
|
+
var version$1 = "2.3.0-alpha.0";
|
|
31405
31989
|
logger.info("Core version: " + version$1 + ".");
|
|
31406
31990
|
|
|
31407
31991
|
var _obj;
|
|
@@ -33034,8 +33618,8 @@ setMaxSpriteMeshItemCount(8);
|
|
|
33034
33618
|
*/ Mesh.create = function(engine, props) {
|
|
33035
33619
|
return new ThreeMesh(engine, props);
|
|
33036
33620
|
};
|
|
33037
|
-
var version = "2.
|
|
33621
|
+
var version = "2.3.0-alpha.0";
|
|
33038
33622
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
33039
33623
|
|
|
33040
|
-
export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, Asset, AssetLoader, AssetManager, BYTES_TYPE_MAP, BaseRenderComponent, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, ColorCurve, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatPropertyPlayableAsset, FloatPropertyTrack, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, MaterialTrack, Mesh, MeshCollider, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, PropertyTrack, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, Vector4Curve, Vector4PropertyPlayableAsset, Vector4PropertyTrack, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
|
|
33624
|
+
export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, Asset, AssetLoader, AssetManager, BYTES_TYPE_MAP, BaseRenderComponent, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, ColorCurve, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatPropertyPlayableAsset, FloatPropertyTrack, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, MaterialTrack, Mesh, MeshCollider, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, PropertyTrack, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, Vector2Curve, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector4Curve, Vector4PropertyPlayableAsset, Vector4PropertyTrack, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
|
|
33041
33625
|
//# sourceMappingURL=index.mjs.map
|