@galacean/engine-core 0.0.0-experimental-2.0-migrate.6 → 0.0.0-experimental-2.0-skill.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/main.js +1103 -2630
- package/dist/main.js.map +1 -1
- package/dist/module.js +1105 -2626
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/2d/assembler/ISpriteRenderer.d.ts +0 -6
- package/types/2d/enums/SpriteDrawMode.d.ts +1 -3
- package/types/2d/enums/TextOverflow.d.ts +2 -4
- package/types/2d/index.d.ts +0 -3
- package/types/2d/sprite/SpriteMask.d.ts +31 -8
- package/types/2d/sprite/SpriteRenderer.d.ts +0 -31
- package/types/2d/sprite/index.d.ts +0 -3
- package/types/2d/text/TextRenderer.d.ts +2 -23
- package/types/Entity.d.ts +1 -2
- package/types/Renderer.d.ts +0 -2
- package/types/Script.d.ts +0 -1
- package/types/Transform.d.ts +14 -16
- package/types/asset/AssetPromise.d.ts +1 -1
- package/types/asset/LoadItem.d.ts +1 -2
- package/types/input/pointer/Pointer.d.ts +0 -2
- package/types/input/pointer/PointerEventData.d.ts +0 -5
- package/types/input/pointer/emitter/PointerEventEmitter.d.ts +1 -1
- package/types/physics/CharacterController.d.ts +1 -2
- package/types/physics/Collider.d.ts +0 -22
- package/types/physics/DynamicCollider.d.ts +0 -20
- package/types/physics/PhysicsScene.d.ts +0 -11
- package/types/physics/index.d.ts +1 -1
- package/types/shader/ShaderFactory.d.ts +1 -10
- package/types/shader/ShaderPass.d.ts +0 -1
- package/types/ui/UIUtils.d.ts +0 -7
- package/types/2d/assembler/FilledSpriteAssembler.d.ts +0 -32
- package/types/2d/enums/SpriteFilledMode.d.ts +0 -15
- package/types/2d/enums/SpriteFilledOrigin.d.ts +0 -21
- package/types/2d/sprite/MaskRenderable.d.ts +0 -48
- package/types/2d/sprite/SpriteMaskUtils.d.ts +0 -1
package/dist/main.js
CHANGED
|
@@ -600,10 +600,10 @@ var AssetPromise = /*#__PURE__*/ function() {
|
|
|
600
600
|
*/ _proto.onProgress = function onProgress(onTaskComplete, onTaskDetail) {
|
|
601
601
|
var completeProgress = this._taskCompleteProgress;
|
|
602
602
|
var detailProgress = this._taskDetailProgress;
|
|
603
|
-
if (completeProgress
|
|
603
|
+
if (completeProgress) {
|
|
604
604
|
onTaskComplete(completeProgress.loaded, completeProgress.total);
|
|
605
605
|
}
|
|
606
|
-
if (detailProgress
|
|
606
|
+
if (detailProgress) {
|
|
607
607
|
for(var url in detailProgress){
|
|
608
608
|
var _detailProgress_url = detailProgress[url], loaded = _detailProgress_url.loaded, total = _detailProgress_url.total;
|
|
609
609
|
onTaskDetail(url, loaded, total);
|
|
@@ -1763,7 +1763,7 @@ SystemInfo._webpSupported = null;
|
|
|
1763
1763
|
_inherits(FontAtlas, ReferResource);
|
|
1764
1764
|
function FontAtlas(engine) {
|
|
1765
1765
|
var _this;
|
|
1766
|
-
_this = ReferResource.call(this, engine) || this, _this._charInfoMap = {}, _this._space =
|
|
1766
|
+
_this = ReferResource.call(this, engine) || this, _this._charInfoMap = {}, _this._space = 1, _this._curX = 1, _this._curY = 1, _this._nextY = 1;
|
|
1767
1767
|
_this.isGCIgnored = true;
|
|
1768
1768
|
var format = engine._hardwareRenderer.isWebGL2 ? TextureFormat.R8 : TextureFormat.Alpha8;
|
|
1769
1769
|
var texture = new Texture2D(engine, 512, 512, format, false, false);
|
|
@@ -1844,11 +1844,10 @@ SystemInfo._webpSupported = null;
|
|
|
1844
1844
|
}({});
|
|
1845
1845
|
|
|
1846
1846
|
/**
|
|
1847
|
-
* The way to handle the situation where
|
|
1847
|
+
* The way to handle the situation where wrapped text is too tall to fit in the height.
|
|
1848
1848
|
*/ var OverflowMode = /*#__PURE__*/ function(OverflowMode) {
|
|
1849
1849
|
/** Overflow when the text is too tall */ OverflowMode[OverflowMode["Overflow"] = 0] = "Overflow";
|
|
1850
1850
|
/** Truncate with height when the text is too tall */ OverflowMode[OverflowMode["Truncate"] = 1] = "Truncate";
|
|
1851
|
-
/** Shrink the font size until the text fits within the bounds (both width and height) */ OverflowMode[OverflowMode["Shrink"] = 2] = "Shrink";
|
|
1852
1851
|
return OverflowMode;
|
|
1853
1852
|
}({});
|
|
1854
1853
|
|
|
@@ -1913,8 +1912,7 @@ SystemInfo._webpSupported = null;
|
|
|
1913
1912
|
TextUtils.measureChar = function measureChar(char, fontString) {
|
|
1914
1913
|
return TextUtils._measureFontOrChar(fontString, char, true);
|
|
1915
1914
|
};
|
|
1916
|
-
TextUtils.measureTextWithWrap = function measureTextWithWrap(renderer, rendererWidth, rendererHeight, lineSpacing, characterSpacing
|
|
1917
|
-
if (uploadCharTexture === void 0) uploadCharTexture = true;
|
|
1915
|
+
TextUtils.measureTextWithWrap = function measureTextWithWrap(renderer, rendererWidth, rendererHeight, lineSpacing, characterSpacing) {
|
|
1918
1916
|
var subFont = renderer._getSubFont();
|
|
1919
1917
|
var fontString = subFont.nativeFontString;
|
|
1920
1918
|
var fontSizeInfo = TextUtils.measureFont(fontString);
|
|
@@ -1943,7 +1941,7 @@ SystemInfo._webpSupported = null;
|
|
|
1943
1941
|
var notFirstLine = false;
|
|
1944
1942
|
for(var j = 0, m = subText.length; j < m; ++j){
|
|
1945
1943
|
var char = subText[j];
|
|
1946
|
-
var charInfo = TextUtils._getCharInfo(char, fontString, subFont
|
|
1944
|
+
var charInfo = TextUtils._getCharInfo(char, fontString, subFont);
|
|
1947
1945
|
var charCode = char.charCodeAt(0);
|
|
1948
1946
|
var isSpace = charCode === 32;
|
|
1949
1947
|
if (isSpace && notFirstLine && line.length === 0 && word.length === 0) {
|
|
@@ -2072,8 +2070,7 @@ SystemInfo._webpSupported = null;
|
|
|
2072
2070
|
lineMaxSizes: lineMaxSizes
|
|
2073
2071
|
};
|
|
2074
2072
|
};
|
|
2075
|
-
TextUtils.measureTextWithoutWrap = function measureTextWithoutWrap(renderer, rendererHeight, lineSpacing, characterSpacing
|
|
2076
|
-
if (uploadCharTexture === void 0) uploadCharTexture = true;
|
|
2073
|
+
TextUtils.measureTextWithoutWrap = function measureTextWithoutWrap(renderer, rendererHeight, lineSpacing, characterSpacing) {
|
|
2077
2074
|
var subFont = renderer._getSubFont();
|
|
2078
2075
|
var fontString = subFont.nativeFontString;
|
|
2079
2076
|
var fontSizeInfo = TextUtils.measureFont(fontString);
|
|
@@ -2092,7 +2089,7 @@ SystemInfo._webpSupported = null;
|
|
|
2092
2089
|
var maxAscent = 0;
|
|
2093
2090
|
var maxDescent = 0;
|
|
2094
2091
|
for(var j = 0; j < lineLength; ++j){
|
|
2095
|
-
var charInfo = TextUtils._getCharInfo(line[j], fontString, subFont
|
|
2092
|
+
var charInfo = TextUtils._getCharInfo(line[j], fontString, subFont);
|
|
2096
2093
|
curWidth += charInfo.xAdvance;
|
|
2097
2094
|
var offsetY = charInfo.offsetY;
|
|
2098
2095
|
var halfH = charInfo.h * 0.5;
|
|
@@ -2120,64 +2117,6 @@ SystemInfo._webpSupported = null;
|
|
|
2120
2117
|
};
|
|
2121
2118
|
};
|
|
2122
2119
|
/**
|
|
2123
|
-
* Measure text in SHRINK overflow mode: keep shrinking the font size until the text fits
|
|
2124
|
-
* within the bounds (both width and height). Mirrors Cocos Creator's `Overflow.SHRINK`.
|
|
2125
|
-
*
|
|
2126
|
-
* @param renderer - The text renderer
|
|
2127
|
-
* @param rendererWidth - The width of the bounds in pixels
|
|
2128
|
-
* @param rendererHeight - The height of the bounds in pixels
|
|
2129
|
-
* @param originalFontSize - The font size set on the renderer (the upper bound, never enlarged)
|
|
2130
|
-
* @param lineSpacing - The line spacing ratio (relative to font size)
|
|
2131
|
-
* @param characterSpacing - The character spacing ratio (relative to font size)
|
|
2132
|
-
* @param enableWrapping - Whether wrapping is enabled
|
|
2133
|
-
* @param applyFontSize - Callback that switches the renderer's sub font to the given font size
|
|
2134
|
-
* @returns The fitted text metrics and the actual font size used for layout
|
|
2135
|
-
*/ TextUtils.measureTextWithShrink = function measureTextWithShrink(renderer, rendererWidth, rendererHeight, originalFontSize, lineSpacing, characterSpacing, enableWrapping, applyFontSize) {
|
|
2136
|
-
// During the binary search we only need the text dimensions, so pass `uploadCharTexture=false`
|
|
2137
|
-
// to avoid building GPU font atlases for the intermediate font sizes that won't be used.
|
|
2138
|
-
// The fitted size is then re-measured once with upload=true to populate its atlas. This trades
|
|
2139
|
-
// one extra full measure pass (CPU) for skipping ~log2(size) throwaway atlas textures (GPU);
|
|
2140
|
-
// we can't reuse the search's last measure because its char bitmaps were never cached.
|
|
2141
|
-
var measureAt = function(fontSize, uploadCharTexture) {
|
|
2142
|
-
applyFontSize(fontSize);
|
|
2143
|
-
return enableWrapping ? TextUtils.measureTextWithWrap(renderer, rendererWidth, rendererHeight, lineSpacing * fontSize, characterSpacing * fontSize, uploadCharTexture) : TextUtils.measureTextWithoutWrap(renderer, rendererHeight, lineSpacing * fontSize, characterSpacing * fontSize, uploadCharTexture);
|
|
2144
|
-
};
|
|
2145
|
-
// The content height is `lineHeight * lineCount`; `metrics.height` is clamped to the bounds
|
|
2146
|
-
// unless overflowMode is Overflow, so it can't be used to detect vertical overflow here.
|
|
2147
|
-
var isFit = function(metrics) {
|
|
2148
|
-
return metrics.width <= rendererWidth && metrics.lineHeight * metrics.lines.length <= rendererHeight;
|
|
2149
|
-
};
|
|
2150
|
-
// If the text already fits at the original size, keep it (SHRINK only shrinks, never enlarges).
|
|
2151
|
-
var metrics = measureAt(originalFontSize, false);
|
|
2152
|
-
if (isFit(metrics)) {
|
|
2153
|
-
metrics = measureAt(originalFontSize, true);
|
|
2154
|
-
return {
|
|
2155
|
-
metrics: metrics,
|
|
2156
|
-
fontSize: originalFontSize
|
|
2157
|
-
};
|
|
2158
|
-
}
|
|
2159
|
-
// Binary search for the largest integer font size that fits (measure only, no atlas upload).
|
|
2160
|
-
var low = 1;
|
|
2161
|
-
var high = Math.floor(originalFontSize);
|
|
2162
|
-
var fitFontSize = low;
|
|
2163
|
-
while(low <= high){
|
|
2164
|
-
var mid = low + high >> 1;
|
|
2165
|
-
metrics = measureAt(mid, false);
|
|
2166
|
-
if (isFit(metrics)) {
|
|
2167
|
-
fitFontSize = mid;
|
|
2168
|
-
low = mid + 1;
|
|
2169
|
-
} else {
|
|
2170
|
-
high = mid - 1;
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2173
|
-
// Re-measure the fitted size with upload=true so the sub font / atlas correspond to it.
|
|
2174
|
-
metrics = measureAt(fitFontSize, true);
|
|
2175
|
-
return {
|
|
2176
|
-
metrics: metrics,
|
|
2177
|
-
fontSize: fitFontSize
|
|
2178
|
-
};
|
|
2179
|
-
};
|
|
2180
|
-
/**
|
|
2181
2120
|
* Get native font hash.
|
|
2182
2121
|
* @param fontName - The font name
|
|
2183
2122
|
* @param fontSize - The font size
|
|
@@ -2294,17 +2233,12 @@ SystemInfo._webpSupported = null;
|
|
|
2294
2233
|
};
|
|
2295
2234
|
/**
|
|
2296
2235
|
* @internal
|
|
2297
|
-
*/ TextUtils._getCharInfo = function _getCharInfo(char, fontString, font
|
|
2298
|
-
if (uploadCharTexture === void 0) uploadCharTexture = true;
|
|
2236
|
+
*/ TextUtils._getCharInfo = function _getCharInfo(char, fontString, font) {
|
|
2299
2237
|
var charInfo = font._getCharInfo(char);
|
|
2300
2238
|
if (!charInfo) {
|
|
2301
2239
|
charInfo = TextUtils.measureChar(char, fontString);
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
if (uploadCharTexture) {
|
|
2305
|
-
font._uploadCharTexture(charInfo);
|
|
2306
|
-
font._addCharInfo(char, charInfo);
|
|
2307
|
-
}
|
|
2240
|
+
font._uploadCharTexture(charInfo);
|
|
2241
|
+
font._addCharInfo(char, charInfo);
|
|
2308
2242
|
}
|
|
2309
2243
|
return charInfo;
|
|
2310
2244
|
};
|
|
@@ -2513,550 +2447,6 @@ TextUtils._textContext = null;
|
|
|
2513
2447
|
};
|
|
2514
2448
|
}
|
|
2515
2449
|
|
|
2516
|
-
/**
|
|
2517
|
-
* Sprite's filled mode enumeration.
|
|
2518
|
-
*/ var SpriteFilledMode = /*#__PURE__*/ function(SpriteFilledMode) {
|
|
2519
|
-
/** Fill horizontally. */ SpriteFilledMode[SpriteFilledMode["Horizontal"] = 0] = "Horizontal";
|
|
2520
|
-
/** Fill vertically. */ SpriteFilledMode[SpriteFilledMode["Vertical"] = 1] = "Vertical";
|
|
2521
|
-
/** Fill radially over 90 degrees. */ SpriteFilledMode[SpriteFilledMode["Radial90"] = 2] = "Radial90";
|
|
2522
|
-
/** Fill radially over 180 degrees. */ SpriteFilledMode[SpriteFilledMode["Radial180"] = 3] = "Radial180";
|
|
2523
|
-
/** Fill radially over 360 degrees. */ SpriteFilledMode[SpriteFilledMode["Radial360"] = 4] = "Radial360";
|
|
2524
|
-
return SpriteFilledMode;
|
|
2525
|
-
}({});
|
|
2526
|
-
|
|
2527
|
-
/**
|
|
2528
|
-
* Sprite's filled origin enumeration.
|
|
2529
|
-
*/ var SpriteFilledOrigin = /*#__PURE__*/ function(SpriteFilledOrigin) {
|
|
2530
|
-
/** Origin at the right. */ SpriteFilledOrigin[SpriteFilledOrigin["Right"] = 0] = "Right";
|
|
2531
|
-
/** Origin at the top-right. */ SpriteFilledOrigin[SpriteFilledOrigin["TopRight"] = 1] = "TopRight";
|
|
2532
|
-
/** Origin at the top. */ SpriteFilledOrigin[SpriteFilledOrigin["Top"] = 2] = "Top";
|
|
2533
|
-
/** Origin at the top-left. */ SpriteFilledOrigin[SpriteFilledOrigin["TopLeft"] = 3] = "TopLeft";
|
|
2534
|
-
/** Origin at the left. */ SpriteFilledOrigin[SpriteFilledOrigin["Left"] = 4] = "Left";
|
|
2535
|
-
/** Origin at the bottom-left. */ SpriteFilledOrigin[SpriteFilledOrigin["BottomLeft"] = 5] = "BottomLeft";
|
|
2536
|
-
/** Origin at the bottom. */ SpriteFilledOrigin[SpriteFilledOrigin["Bottom"] = 6] = "Bottom";
|
|
2537
|
-
/** Origin at the bottom-right. */ SpriteFilledOrigin[SpriteFilledOrigin["BottomRight"] = 7] = "BottomRight";
|
|
2538
|
-
return SpriteFilledOrigin;
|
|
2539
|
-
}({});
|
|
2540
|
-
|
|
2541
|
-
exports.FilledSpriteAssembler = /*#__PURE__*/ function() {
|
|
2542
|
-
function FilledSpriteAssembler() {}
|
|
2543
|
-
FilledSpriteAssembler.resetData = function resetData(renderer) {
|
|
2544
|
-
var manager = renderer._getChunkManager();
|
|
2545
|
-
var lastSubChunk = renderer._subChunk;
|
|
2546
|
-
lastSubChunk && manager.freeSubChunk(lastSubChunk);
|
|
2547
|
-
// Allocate the maximum any fill mode can produce (Radial360 = 4 quadrants x 4 verts = 16).
|
|
2548
|
-
// A fixed size avoids reallocating the sub-chunk when filledMode changes at runtime.
|
|
2549
|
-
var subChunk = manager.allocateSubChunk(16);
|
|
2550
|
-
subChunk.indices = [];
|
|
2551
|
-
renderer._subChunk = subChunk;
|
|
2552
|
-
};
|
|
2553
|
-
FilledSpriteAssembler.updatePositions = function updatePositions(renderer, worldMatrix, width, height, pivot, flipX, flipY) {
|
|
2554
|
-
var pivotX = pivot.x, pivotY = pivot.y;
|
|
2555
|
-
var modelMatrix = FilledSpriteAssembler._matrix;
|
|
2556
|
-
var wE = modelMatrix.elements;
|
|
2557
|
-
var pWE = worldMatrix.elements;
|
|
2558
|
-
var sx = flipX ? -width : width;
|
|
2559
|
-
var sy = flipY ? -height : height;
|
|
2560
|
-
wE[0] = pWE[0] * sx, wE[1] = pWE[1] * sx, wE[2] = pWE[2] * sx;
|
|
2561
|
-
wE[4] = pWE[4] * sy, wE[5] = pWE[5] * sy, wE[6] = pWE[6] * sy;
|
|
2562
|
-
wE[8] = pWE[8], wE[9] = pWE[9], wE[10] = pWE[10];
|
|
2563
|
-
wE[12] = pWE[12] - pivotX * wE[0] - pivotY * wE[4];
|
|
2564
|
-
wE[13] = pWE[13] - pivotX * wE[1] - pivotY * wE[5];
|
|
2565
|
-
wE[14] = pWE[14] - pivotX * wE[2] - pivotY * wE[6];
|
|
2566
|
-
switch(renderer.filledMode){
|
|
2567
|
-
case SpriteFilledMode.Horizontal:
|
|
2568
|
-
this._filledLinear(renderer, modelMatrix, true);
|
|
2569
|
-
break;
|
|
2570
|
-
case SpriteFilledMode.Vertical:
|
|
2571
|
-
this._filledLinear(renderer, modelMatrix, false);
|
|
2572
|
-
break;
|
|
2573
|
-
case SpriteFilledMode.Radial90:
|
|
2574
|
-
this._filledRadial90(renderer, modelMatrix, renderer.filledOrigin, renderer.filledAmount, renderer.filledClockWise);
|
|
2575
|
-
break;
|
|
2576
|
-
case SpriteFilledMode.Radial180:
|
|
2577
|
-
this._filledRadial180(renderer, modelMatrix, renderer.filledOrigin, renderer.filledAmount, renderer.filledClockWise);
|
|
2578
|
-
break;
|
|
2579
|
-
case SpriteFilledMode.Radial360:
|
|
2580
|
-
this._filledRadial360(renderer, modelMatrix, renderer.filledOrigin, renderer.filledAmount, renderer.filledClockWise);
|
|
2581
|
-
break;
|
|
2582
|
-
}
|
|
2583
|
-
// @ts-ignore
|
|
2584
|
-
engineMath.BoundingBox.transform(renderer.sprite._getBounds(), modelMatrix, renderer._bounds);
|
|
2585
|
-
};
|
|
2586
|
-
FilledSpriteAssembler.updateUVs = function updateUVs(renderer) {
|
|
2587
|
-
// UVs are computed in updatePositions.
|
|
2588
|
-
};
|
|
2589
|
-
FilledSpriteAssembler.updateColor = function updateColor(renderer, alpha) {
|
|
2590
|
-
var subChunk = renderer._subChunk;
|
|
2591
|
-
var _renderer_color = renderer.color, r = _renderer_color.r, g = _renderer_color.g, b = _renderer_color.b, a = _renderer_color.a;
|
|
2592
|
-
var finalAlpha = a * alpha;
|
|
2593
|
-
var vertices = subChunk.chunk.vertices;
|
|
2594
|
-
var vertexArea = subChunk.vertexArea;
|
|
2595
|
-
for(var i = 0, o = vertexArea.start + 5, n = vertexArea.size / 9; i < n; ++i, o += 9){
|
|
2596
|
-
vertices[o] = r;
|
|
2597
|
-
vertices[o + 1] = g;
|
|
2598
|
-
vertices[o + 2] = b;
|
|
2599
|
-
vertices[o + 3] = finalAlpha;
|
|
2600
|
-
}
|
|
2601
|
-
};
|
|
2602
|
-
FilledSpriteAssembler._filledLinear = function _filledLinear(renderer, matrix, isHorizontal) {
|
|
2603
|
-
var amount = renderer.filledAmount;
|
|
2604
|
-
if (amount <= this._fillAmountEpsilon) {
|
|
2605
|
-
renderer._subChunk.indices.length = 0;
|
|
2606
|
-
return;
|
|
2607
|
-
}
|
|
2608
|
-
var sprite = renderer.sprite;
|
|
2609
|
-
var _sprite__getPositions = sprite._getPositions(), lPosLB = _sprite__getPositions[0], lPosRB = _sprite__getPositions[1], lPosLT = _sprite__getPositions[2], lPosRT = _sprite__getPositions[3];
|
|
2610
|
-
var spriteUVs = sprite._getUVs();
|
|
2611
|
-
var _spriteUVs_ = spriteUVs[0], left = _spriteUVs_.x, bottom = _spriteUVs_.y;
|
|
2612
|
-
var _spriteUVs_1 = spriteUVs[3], right = _spriteUVs_1.x, top = _spriteUVs_1.y;
|
|
2613
|
-
var subChunk = renderer._subChunk;
|
|
2614
|
-
var vertices = subChunk.chunk.vertices;
|
|
2615
|
-
var x0, y0, u0, v0;
|
|
2616
|
-
var x1, y1, u1, v1;
|
|
2617
|
-
var x2, y2, u2, v2;
|
|
2618
|
-
var x3, y3, u3, v3;
|
|
2619
|
-
if (isHorizontal) {
|
|
2620
|
-
var originIsStart = renderer.filledOrigin === SpriteFilledOrigin.Left;
|
|
2621
|
-
var startX = originIsStart ? lPosLB.x : lPosRB.x - (lPosRB.x - lPosLB.x) * amount;
|
|
2622
|
-
var endX = originIsStart ? lPosLB.x + (lPosRB.x - lPosLB.x) * amount : lPosRB.x;
|
|
2623
|
-
var startU = originIsStart ? left : right - (right - left) * amount;
|
|
2624
|
-
var endU = originIsStart ? left + (right - left) * amount : right;
|
|
2625
|
-
x0 = startX, y0 = lPosLB.y, u0 = startU, v0 = bottom;
|
|
2626
|
-
x1 = endX, y1 = lPosRB.y, u1 = endU, v1 = bottom;
|
|
2627
|
-
x2 = startX, y2 = lPosLT.y, u2 = startU, v2 = top;
|
|
2628
|
-
x3 = endX, y3 = lPosRT.y, u3 = endU, v3 = top;
|
|
2629
|
-
} else {
|
|
2630
|
-
var originIsStart1 = renderer.filledOrigin === SpriteFilledOrigin.Bottom;
|
|
2631
|
-
var startY = originIsStart1 ? lPosLB.y : lPosLT.y - (lPosLT.y - lPosLB.y) * amount;
|
|
2632
|
-
var endY = originIsStart1 ? lPosLB.y + (lPosLT.y - lPosLB.y) * amount : lPosLT.y;
|
|
2633
|
-
var startV = originIsStart1 ? bottom : top - (top - bottom) * amount;
|
|
2634
|
-
var endV = originIsStart1 ? bottom + (top - bottom) * amount : top;
|
|
2635
|
-
x0 = lPosLB.x, y0 = startY, u0 = left, v0 = startV;
|
|
2636
|
-
x1 = lPosRB.x, y1 = startY, u1 = right, v1 = startV;
|
|
2637
|
-
x2 = lPosLT.x, y2 = endY, u2 = left, v2 = endV;
|
|
2638
|
-
x3 = lPosRT.x, y3 = endY, u3 = right, v3 = endV;
|
|
2639
|
-
}
|
|
2640
|
-
var wE = matrix.elements;
|
|
2641
|
-
var start = subChunk.vertexArea.start;
|
|
2642
|
-
// LB
|
|
2643
|
-
vertices[start] = wE[0] * x0 + wE[4] * y0 + wE[12];
|
|
2644
|
-
vertices[start + 1] = wE[1] * x0 + wE[5] * y0 + wE[13];
|
|
2645
|
-
vertices[start + 2] = wE[2] * x0 + wE[6] * y0 + wE[14];
|
|
2646
|
-
vertices[start + 3] = u0;
|
|
2647
|
-
vertices[start + 4] = v0;
|
|
2648
|
-
// RB
|
|
2649
|
-
vertices[start + 9] = wE[0] * x1 + wE[4] * y1 + wE[12];
|
|
2650
|
-
vertices[start + 10] = wE[1] * x1 + wE[5] * y1 + wE[13];
|
|
2651
|
-
vertices[start + 11] = wE[2] * x1 + wE[6] * y1 + wE[14];
|
|
2652
|
-
vertices[start + 12] = u1;
|
|
2653
|
-
vertices[start + 13] = v1;
|
|
2654
|
-
// LT
|
|
2655
|
-
vertices[start + 18] = wE[0] * x2 + wE[4] * y2 + wE[12];
|
|
2656
|
-
vertices[start + 19] = wE[1] * x2 + wE[5] * y2 + wE[13];
|
|
2657
|
-
vertices[start + 20] = wE[2] * x2 + wE[6] * y2 + wE[14];
|
|
2658
|
-
vertices[start + 21] = u2;
|
|
2659
|
-
vertices[start + 22] = v2;
|
|
2660
|
-
// RT
|
|
2661
|
-
vertices[start + 27] = wE[0] * x3 + wE[4] * y3 + wE[12];
|
|
2662
|
-
vertices[start + 28] = wE[1] * x3 + wE[5] * y3 + wE[13];
|
|
2663
|
-
vertices[start + 29] = wE[2] * x3 + wE[6] * y3 + wE[14];
|
|
2664
|
-
vertices[start + 30] = u3;
|
|
2665
|
-
vertices[start + 31] = v3;
|
|
2666
|
-
var indices = subChunk.indices;
|
|
2667
|
-
indices[0] = 0;
|
|
2668
|
-
indices[1] = 1;
|
|
2669
|
-
indices[2] = 2;
|
|
2670
|
-
indices[3] = 2;
|
|
2671
|
-
indices[4] = 1;
|
|
2672
|
-
indices[5] = 3;
|
|
2673
|
-
indices.length = 6;
|
|
2674
|
-
};
|
|
2675
|
-
FilledSpriteAssembler._filledRadial90 = function _filledRadial90(renderer, matrix, origin, amount, cw) {
|
|
2676
|
-
if (amount <= this._fillAmountEpsilon) {
|
|
2677
|
-
renderer._subChunk.indices.length = 0;
|
|
2678
|
-
return;
|
|
2679
|
-
}
|
|
2680
|
-
var sprite = renderer.sprite;
|
|
2681
|
-
var _sprite__getPositions = sprite._getPositions(), lPosLB = _sprite__getPositions[0], lPosRB = _sprite__getPositions[1], lPosLT = _sprite__getPositions[2], lPosRT = _sprite__getPositions[3];
|
|
2682
|
-
var spriteUVs = sprite._getUVs();
|
|
2683
|
-
var _spriteUVs_ = spriteUVs[0], left = _spriteUVs_.x, bottom = _spriteUVs_.y;
|
|
2684
|
-
var _spriteUVs_1 = spriteUVs[3], right = _spriteUVs_1.x, top = _spriteUVs_1.y;
|
|
2685
|
-
// Transform 4 corners to world space
|
|
2686
|
-
var _this__worldPositions = this._worldPositions, wLB = _this__worldPositions[0], wRB = _this__worldPositions[1], wLT = _this__worldPositions[2], wRT = _this__worldPositions[3];
|
|
2687
|
-
var _this__uvs = this._uvs, uvLB = _this__uvs[0], uvRB = _this__uvs[1], uvLT = _this__uvs[2], uvRT = _this__uvs[3];
|
|
2688
|
-
wLB.set(lPosLB.x, lPosLB.y, 0).transformToVec3(matrix), uvLB.set(left, bottom);
|
|
2689
|
-
wRB.set(lPosRB.x, lPosRB.y, 0).transformToVec3(matrix), uvRB.set(right, bottom);
|
|
2690
|
-
wLT.set(lPosLT.x, lPosLT.y, 0).transformToVec3(matrix), uvLT.set(left, top);
|
|
2691
|
-
wRT.set(lPosRT.x, lPosRT.y, 0).transformToVec3(matrix), uvRT.set(right, top);
|
|
2692
|
-
// Map vertices based on origin corner:
|
|
2693
|
-
// [center, CW-adjacent, CCW-adjacent, opposite]
|
|
2694
|
-
var _this = this, inPositions = _this._inPositions, inUVs = _this._inUVs, outPositions = _this._outPositions, outUVs = _this._outUVs;
|
|
2695
|
-
switch(origin){
|
|
2696
|
-
case SpriteFilledOrigin.BottomRight:
|
|
2697
|
-
inPositions[0] = wRB, inUVs[0] = uvRB;
|
|
2698
|
-
inPositions[1] = wRT, inUVs[1] = uvRT;
|
|
2699
|
-
inPositions[2] = wLB, inUVs[2] = uvLB;
|
|
2700
|
-
inPositions[3] = wLT, inUVs[3] = uvLT;
|
|
2701
|
-
break;
|
|
2702
|
-
case SpriteFilledOrigin.TopRight:
|
|
2703
|
-
inPositions[0] = wRT, inUVs[0] = uvRT;
|
|
2704
|
-
inPositions[1] = wLT, inUVs[1] = uvLT;
|
|
2705
|
-
inPositions[2] = wRB, inUVs[2] = uvRB;
|
|
2706
|
-
inPositions[3] = wLB, inUVs[3] = uvLB;
|
|
2707
|
-
break;
|
|
2708
|
-
case SpriteFilledOrigin.TopLeft:
|
|
2709
|
-
inPositions[0] = wLT, inUVs[0] = uvLT;
|
|
2710
|
-
inPositions[1] = wLB, inUVs[1] = uvLB;
|
|
2711
|
-
inPositions[2] = wRT, inUVs[2] = uvRT;
|
|
2712
|
-
inPositions[3] = wRB, inUVs[3] = uvRB;
|
|
2713
|
-
break;
|
|
2714
|
-
// BottomLeft is the default; any unsupported origin falls back to it instead of rendering stale data.
|
|
2715
|
-
case SpriteFilledOrigin.BottomLeft:
|
|
2716
|
-
default:
|
|
2717
|
-
inPositions[0] = wLB, inUVs[0] = uvLB;
|
|
2718
|
-
inPositions[1] = wRB, inUVs[1] = uvRB;
|
|
2719
|
-
inPositions[2] = wLT, inUVs[2] = uvLT;
|
|
2720
|
-
inPositions[3] = wRT, inUVs[3] = uvRT;
|
|
2721
|
-
break;
|
|
2722
|
-
}
|
|
2723
|
-
var startAngle = cw ? 90 - amount * 90 : 0;
|
|
2724
|
-
var endAngle = cw ? 90 : amount * 90;
|
|
2725
|
-
this._vertexOffset = this._indicesOffset = 0;
|
|
2726
|
-
this._radialCut(renderer._subChunk, inPositions, inUVs, startAngle, endAngle, outPositions, outUVs);
|
|
2727
|
-
renderer._subChunk.indices.length = this._indicesOffset;
|
|
2728
|
-
};
|
|
2729
|
-
FilledSpriteAssembler._filledRadial180 = function _filledRadial180(renderer, matrix, origin, amount, cw) {
|
|
2730
|
-
if (amount <= this._fillAmountEpsilon) {
|
|
2731
|
-
renderer._subChunk.indices.length = 0;
|
|
2732
|
-
return;
|
|
2733
|
-
}
|
|
2734
|
-
var sprite = renderer.sprite;
|
|
2735
|
-
var _sprite__getPositions = sprite._getPositions(), lPosLB = _sprite__getPositions[0], lPosRB = _sprite__getPositions[1], lPosLT = _sprite__getPositions[2], lPosRT = _sprite__getPositions[3];
|
|
2736
|
-
var spriteUVs = sprite._getUVs();
|
|
2737
|
-
var _spriteUVs_ = spriteUVs[0], left = _spriteUVs_.x, bottom = _spriteUVs_.y;
|
|
2738
|
-
var _spriteUVs_1 = spriteUVs[3], right = _spriteUVs_1.x, top = _spriteUVs_1.y;
|
|
2739
|
-
// Transform corners and compute edge midpoints
|
|
2740
|
-
var _this__worldPositions = this._worldPositions, wLB = _this__worldPositions[0], wMB = _this__worldPositions[1], wRB = _this__worldPositions[2], wLM = _this__worldPositions[3], wRM = _this__worldPositions[5], wLT = _this__worldPositions[6], wMT = _this__worldPositions[7], wRT = _this__worldPositions[8];
|
|
2741
|
-
var _this__uvs = this._uvs, uvLB = _this__uvs[0], uvMB = _this__uvs[1], uvRB = _this__uvs[2], uvLM = _this__uvs[3], uvRM = _this__uvs[5], uvLT = _this__uvs[6], uvMT = _this__uvs[7], uvRT = _this__uvs[8];
|
|
2742
|
-
wLB.set(lPosLB.x, lPosLB.y, 0).transformToVec3(matrix), uvLB.set(left, bottom);
|
|
2743
|
-
wRB.set(lPosRB.x, lPosRB.y, 0).transformToVec3(matrix), uvRB.set(right, bottom);
|
|
2744
|
-
wLT.set(lPosLT.x, lPosLT.y, 0).transformToVec3(matrix), uvLT.set(left, top);
|
|
2745
|
-
wRT.set(lPosRT.x, lPosRT.y, 0).transformToVec3(matrix), uvRT.set(right, top);
|
|
2746
|
-
engineMath.Vector3.lerp(wLB, wRB, 0.5, wMB), engineMath.Vector2.lerp(uvLB, uvRB, 0.5, uvMB);
|
|
2747
|
-
engineMath.Vector3.lerp(wLB, wLT, 0.5, wLM), engineMath.Vector2.lerp(uvLB, uvLT, 0.5, uvLM);
|
|
2748
|
-
engineMath.Vector3.lerp(wLT, wRT, 0.5, wMT), engineMath.Vector2.lerp(uvLT, uvRT, 0.5, uvMT);
|
|
2749
|
-
engineMath.Vector3.lerp(wRB, wRT, 0.5, wRM), engineMath.Vector2.lerp(uvRB, uvRT, 0.5, uvRM);
|
|
2750
|
-
var startAngle = cw ? 180 - amount * 180 : 0;
|
|
2751
|
-
var endAngle = cw ? 180 : amount * 180;
|
|
2752
|
-
this._vertexOffset = this._indicesOffset = 0;
|
|
2753
|
-
var _this = this, inPositions = _this._inPositions, inUVs = _this._inUVs, outPositions = _this._outPositions, outUVs = _this._outUVs;
|
|
2754
|
-
var subChunk = renderer._subChunk;
|
|
2755
|
-
// Center is at the origin edge midpoint; two quadrants cover the full sprite.
|
|
2756
|
-
// Quadrant A (0°-90°), Quadrant B (90°-180°)
|
|
2757
|
-
switch(origin){
|
|
2758
|
-
case SpriteFilledOrigin.Top:
|
|
2759
|
-
// Center=MT, A: [MT,LT,MB,LB], B: [MT,MB,RT,RB]
|
|
2760
|
-
inPositions[0] = wMT, inUVs[0] = uvMT;
|
|
2761
|
-
inPositions[1] = wLT, inUVs[1] = uvLT;
|
|
2762
|
-
inPositions[2] = wMB, inUVs[2] = uvMB;
|
|
2763
|
-
inPositions[3] = wLB, inUVs[3] = uvLB;
|
|
2764
|
-
this._radialCut(subChunk, inPositions, inUVs, startAngle, endAngle, outPositions, outUVs);
|
|
2765
|
-
inPositions[1] = wMB, inUVs[1] = uvMB;
|
|
2766
|
-
inPositions[2] = wRT, inUVs[2] = uvRT;
|
|
2767
|
-
inPositions[3] = wRB, inUVs[3] = uvRB;
|
|
2768
|
-
this._radialCut(subChunk, inPositions, inUVs, startAngle - 90, endAngle - 90, outPositions, outUVs);
|
|
2769
|
-
break;
|
|
2770
|
-
case SpriteFilledOrigin.Left:
|
|
2771
|
-
// Center=LM, A: [LM,LB,RM,RB], B: [LM,RM,LT,RT]
|
|
2772
|
-
inPositions[0] = wLM, inUVs[0] = uvLM;
|
|
2773
|
-
inPositions[1] = wLB, inUVs[1] = uvLB;
|
|
2774
|
-
inPositions[2] = wRM, inUVs[2] = uvRM;
|
|
2775
|
-
inPositions[3] = wRB, inUVs[3] = uvRB;
|
|
2776
|
-
this._radialCut(subChunk, inPositions, inUVs, startAngle, endAngle, outPositions, outUVs);
|
|
2777
|
-
inPositions[1] = wRM, inUVs[1] = uvRM;
|
|
2778
|
-
inPositions[2] = wLT, inUVs[2] = uvLT;
|
|
2779
|
-
inPositions[3] = wRT, inUVs[3] = uvRT;
|
|
2780
|
-
this._radialCut(subChunk, inPositions, inUVs, startAngle - 90, endAngle - 90, outPositions, outUVs);
|
|
2781
|
-
break;
|
|
2782
|
-
case SpriteFilledOrigin.Right:
|
|
2783
|
-
// Center=RM, A: [RM,RT,LM,LT], B: [RM,LM,RB,LB]
|
|
2784
|
-
inPositions[0] = wRM, inUVs[0] = uvRM;
|
|
2785
|
-
inPositions[1] = wRT, inUVs[1] = uvRT;
|
|
2786
|
-
inPositions[2] = wLM, inUVs[2] = uvLM;
|
|
2787
|
-
inPositions[3] = wLT, inUVs[3] = uvLT;
|
|
2788
|
-
this._radialCut(subChunk, inPositions, inUVs, startAngle, endAngle, outPositions, outUVs);
|
|
2789
|
-
inPositions[1] = wLM, inUVs[1] = uvLM;
|
|
2790
|
-
inPositions[2] = wRB, inUVs[2] = uvRB;
|
|
2791
|
-
inPositions[3] = wLB, inUVs[3] = uvLB;
|
|
2792
|
-
this._radialCut(subChunk, inPositions, inUVs, startAngle - 90, endAngle - 90, outPositions, outUVs);
|
|
2793
|
-
break;
|
|
2794
|
-
// Bottom is the default; any unsupported origin falls back to it instead of rendering stale data.
|
|
2795
|
-
case SpriteFilledOrigin.Bottom:
|
|
2796
|
-
default:
|
|
2797
|
-
// Center=MB, A: [MB,RB,MT,RT], B: [MB,MT,LB,LT]
|
|
2798
|
-
inPositions[0] = wMB, inUVs[0] = uvMB;
|
|
2799
|
-
inPositions[1] = wRB, inUVs[1] = uvRB;
|
|
2800
|
-
inPositions[2] = wMT, inUVs[2] = uvMT;
|
|
2801
|
-
inPositions[3] = wRT, inUVs[3] = uvRT;
|
|
2802
|
-
this._radialCut(subChunk, inPositions, inUVs, startAngle, endAngle, outPositions, outUVs);
|
|
2803
|
-
inPositions[1] = wMT, inUVs[1] = uvMT;
|
|
2804
|
-
inPositions[2] = wLB, inUVs[2] = uvLB;
|
|
2805
|
-
inPositions[3] = wLT, inUVs[3] = uvLT;
|
|
2806
|
-
this._radialCut(subChunk, inPositions, inUVs, startAngle - 90, endAngle - 90, outPositions, outUVs);
|
|
2807
|
-
break;
|
|
2808
|
-
}
|
|
2809
|
-
subChunk.indices.length = this._indicesOffset;
|
|
2810
|
-
};
|
|
2811
|
-
FilledSpriteAssembler._filledRadial360 = function _filledRadial360(renderer, matrix, origin, amount, cw) {
|
|
2812
|
-
if (amount <= this._fillAmountEpsilon) {
|
|
2813
|
-
renderer._subChunk.indices.length = 0;
|
|
2814
|
-
return;
|
|
2815
|
-
}
|
|
2816
|
-
var startAngle = 0;
|
|
2817
|
-
switch(origin){
|
|
2818
|
-
case SpriteFilledOrigin.Top:
|
|
2819
|
-
startAngle = cw ? 450 - amount * 360 : 90;
|
|
2820
|
-
break;
|
|
2821
|
-
case SpriteFilledOrigin.Left:
|
|
2822
|
-
startAngle = cw ? 540 - amount * 360 : 180;
|
|
2823
|
-
break;
|
|
2824
|
-
case SpriteFilledOrigin.Bottom:
|
|
2825
|
-
startAngle = cw ? 630 - amount * 360 : 270;
|
|
2826
|
-
break;
|
|
2827
|
-
// Right is handled here, and this branch also catches any unsupported origin as a fallback.
|
|
2828
|
-
case SpriteFilledOrigin.Right:
|
|
2829
|
-
default:
|
|
2830
|
-
startAngle = cw ? 360 - amount * 360 : 0;
|
|
2831
|
-
break;
|
|
2832
|
-
}
|
|
2833
|
-
var endAngle = startAngle + amount * 360;
|
|
2834
|
-
this._processRadialGrid(renderer, matrix, startAngle, endAngle);
|
|
2835
|
-
};
|
|
2836
|
-
/**
|
|
2837
|
-
* Prepare the 3x3 grid and process 4 quadrants for radial fill.
|
|
2838
|
-
*/ FilledSpriteAssembler._processRadialGrid = function _processRadialGrid(renderer, matrix, startAngle, endAngle) {
|
|
2839
|
-
var sprite = renderer.sprite;
|
|
2840
|
-
var _sprite__getPositions = sprite._getPositions(), lPosLB = _sprite__getPositions[0], lPosRB = _sprite__getPositions[1], lPosLT = _sprite__getPositions[2], lPosRT = _sprite__getPositions[3];
|
|
2841
|
-
var spriteUVs = sprite._getUVs();
|
|
2842
|
-
var _spriteUVs_ = spriteUVs[0], left = _spriteUVs_.x, bottom = _spriteUVs_.y;
|
|
2843
|
-
var _spriteUVs_1 = spriteUVs[3], right = _spriteUVs_1.x, top = _spriteUVs_1.y;
|
|
2844
|
-
// ---------------
|
|
2845
|
-
// LT - MT - RT
|
|
2846
|
-
// | | |
|
|
2847
|
-
// LM - C - RM
|
|
2848
|
-
// | | |
|
|
2849
|
-
// LB - MB - RB
|
|
2850
|
-
// ---------------
|
|
2851
|
-
var _this__worldPositions = this._worldPositions, wPosLB = _this__worldPositions[0], wPosMB = _this__worldPositions[1], wPosRB = _this__worldPositions[2], wPosLM = _this__worldPositions[3], wPosC = _this__worldPositions[4], wPosRM = _this__worldPositions[5], wPosLT = _this__worldPositions[6], wPosMT = _this__worldPositions[7], wPosRT = _this__worldPositions[8];
|
|
2852
|
-
var _this__uvs = this._uvs, uvLB = _this__uvs[0], uvMB = _this__uvs[1], uvRB = _this__uvs[2], uvLM = _this__uvs[3], uvC = _this__uvs[4], uvRM = _this__uvs[5], uvLT = _this__uvs[6], uvMT = _this__uvs[7], uvRT = _this__uvs[8];
|
|
2853
|
-
wPosLB.set(lPosLB.x, lPosLB.y, 0).transformToVec3(matrix), uvLB.set(left, bottom);
|
|
2854
|
-
wPosRB.set(lPosRB.x, lPosRB.y, 0).transformToVec3(matrix), uvRB.set(right, bottom);
|
|
2855
|
-
wPosLT.set(lPosLT.x, lPosLT.y, 0).transformToVec3(matrix), uvLT.set(left, top);
|
|
2856
|
-
wPosRT.set(lPosRT.x, lPosRT.y, 0).transformToVec3(matrix), uvRT.set(right, top);
|
|
2857
|
-
engineMath.Vector3.lerp(wPosLB, wPosRB, 0.5, wPosMB), engineMath.Vector2.lerp(uvLB, uvRB, 0.5, uvMB);
|
|
2858
|
-
engineMath.Vector3.lerp(wPosLB, wPosLT, 0.5, wPosLM), engineMath.Vector2.lerp(uvLB, uvLT, 0.5, uvLM);
|
|
2859
|
-
engineMath.Vector3.lerp(wPosLT, wPosRT, 0.5, wPosMT), engineMath.Vector2.lerp(uvLT, uvRT, 0.5, uvMT);
|
|
2860
|
-
engineMath.Vector3.lerp(wPosRB, wPosRT, 0.5, wPosRM), engineMath.Vector2.lerp(uvRB, uvRT, 0.5, uvRM);
|
|
2861
|
-
engineMath.Vector3.lerp(wPosLB, wPosRT, 0.5, wPosC), engineMath.Vector2.lerp(uvLB, uvRT, 0.5, uvC);
|
|
2862
|
-
this._vertexOffset = this._indicesOffset = 0;
|
|
2863
|
-
var _this = this, inPositions = _this._inPositions, inUVs = _this._inUVs, outPositions = _this._outPositions, outUVs = _this._outUVs;
|
|
2864
|
-
var subChunk = renderer._subChunk;
|
|
2865
|
-
var quadrantStart = 0;
|
|
2866
|
-
var quadrantEnd = 0;
|
|
2867
|
-
inPositions[0] = wPosC, inUVs[0] = uvC;
|
|
2868
|
-
{
|
|
2869
|
-
// First quadrant (0°-90°)
|
|
2870
|
-
if (startAngle >= 90) {
|
|
2871
|
-
quadrantStart = startAngle - 360;
|
|
2872
|
-
quadrantEnd = endAngle - 360;
|
|
2873
|
-
} else {
|
|
2874
|
-
quadrantStart = startAngle;
|
|
2875
|
-
quadrantEnd = endAngle;
|
|
2876
|
-
}
|
|
2877
|
-
inPositions[1] = wPosRM, inUVs[1] = uvRM;
|
|
2878
|
-
inPositions[2] = wPosMT, inUVs[2] = uvMT;
|
|
2879
|
-
inPositions[3] = wPosRT, inUVs[3] = uvRT;
|
|
2880
|
-
this._radialCut(subChunk, inPositions, inUVs, quadrantStart, quadrantEnd, outPositions, outUVs);
|
|
2881
|
-
}
|
|
2882
|
-
{
|
|
2883
|
-
// Second quadrant (90°-180°)
|
|
2884
|
-
if (startAngle >= 180) {
|
|
2885
|
-
quadrantStart = startAngle - 360 - 90;
|
|
2886
|
-
quadrantEnd = endAngle - 360 - 90;
|
|
2887
|
-
} else {
|
|
2888
|
-
quadrantStart = startAngle - 90;
|
|
2889
|
-
quadrantEnd = endAngle - 90;
|
|
2890
|
-
}
|
|
2891
|
-
inPositions[1] = wPosMT, inUVs[1] = uvMT;
|
|
2892
|
-
inPositions[2] = wPosLM, inUVs[2] = uvLM;
|
|
2893
|
-
inPositions[3] = wPosLT, inUVs[3] = uvLT;
|
|
2894
|
-
this._radialCut(subChunk, inPositions, inUVs, quadrantStart, quadrantEnd, outPositions, outUVs);
|
|
2895
|
-
}
|
|
2896
|
-
{
|
|
2897
|
-
// Third quadrant (180°-270°)
|
|
2898
|
-
if (startAngle >= 270) {
|
|
2899
|
-
quadrantStart = startAngle - 360 - 180;
|
|
2900
|
-
quadrantEnd = endAngle - 360 - 180;
|
|
2901
|
-
} else {
|
|
2902
|
-
quadrantStart = startAngle - 180;
|
|
2903
|
-
quadrantEnd = endAngle - 180;
|
|
2904
|
-
}
|
|
2905
|
-
inPositions[1] = wPosLM, inUVs[1] = uvLM;
|
|
2906
|
-
inPositions[2] = wPosMB, inUVs[2] = uvMB;
|
|
2907
|
-
inPositions[3] = wPosLB, inUVs[3] = uvLB;
|
|
2908
|
-
this._radialCut(subChunk, inPositions, inUVs, quadrantStart, quadrantEnd, outPositions, outUVs);
|
|
2909
|
-
}
|
|
2910
|
-
{
|
|
2911
|
-
// Fourth quadrant (270°-360°)
|
|
2912
|
-
if (startAngle >= 360) {
|
|
2913
|
-
quadrantStart = startAngle - 360 - 270;
|
|
2914
|
-
quadrantEnd = endAngle - 360 - 270;
|
|
2915
|
-
} else {
|
|
2916
|
-
quadrantStart = startAngle - 270;
|
|
2917
|
-
quadrantEnd = endAngle - 270;
|
|
2918
|
-
}
|
|
2919
|
-
inPositions[1] = wPosMB, inUVs[1] = uvMB;
|
|
2920
|
-
inPositions[2] = wPosRM, inUVs[2] = uvRM;
|
|
2921
|
-
inPositions[3] = wPosRB, inUVs[3] = uvRB;
|
|
2922
|
-
this._radialCut(subChunk, inPositions, inUVs, quadrantStart, quadrantEnd, outPositions, outUVs);
|
|
2923
|
-
}
|
|
2924
|
-
subChunk.indices.length = this._indicesOffset;
|
|
2925
|
-
};
|
|
2926
|
-
FilledSpriteAssembler._radialCut = function _radialCut(subChunk, positions, uvs, start, end, outPositions, outUVs) {
|
|
2927
|
-
if (start >= 90 || end <= 0) return;
|
|
2928
|
-
outPositions[0].copyFrom(positions[0]);
|
|
2929
|
-
outUVs[0].copyFrom(uvs[0]);
|
|
2930
|
-
if (start <= 0) {
|
|
2931
|
-
outPositions[1].copyFrom(positions[1]);
|
|
2932
|
-
outUVs[1].copyFrom(uvs[1]);
|
|
2933
|
-
} else {
|
|
2934
|
-
var startTan = Math.tan(start * Math.PI / 180);
|
|
2935
|
-
if (startTan < 1) {
|
|
2936
|
-
engineMath.Vector3.lerp(positions[1], positions[3], startTan, outPositions[1]);
|
|
2937
|
-
engineMath.Vector2.lerp(uvs[1], uvs[3], startTan, outUVs[1]);
|
|
2938
|
-
} else {
|
|
2939
|
-
engineMath.Vector3.lerp(positions[2], positions[3], 1 / startTan, outPositions[1]);
|
|
2940
|
-
engineMath.Vector2.lerp(uvs[2], uvs[3], 1 / startTan, outUVs[1]);
|
|
2941
|
-
}
|
|
2942
|
-
}
|
|
2943
|
-
if (end >= 90) {
|
|
2944
|
-
outPositions[2].copyFrom(positions[2]);
|
|
2945
|
-
outUVs[2].copyFrom(uvs[2]);
|
|
2946
|
-
} else {
|
|
2947
|
-
var endTan = Math.tan(end * Math.PI / 180);
|
|
2948
|
-
if (endTan < 1) {
|
|
2949
|
-
engineMath.Vector3.lerp(positions[1], positions[3], endTan, outPositions[2]);
|
|
2950
|
-
engineMath.Vector2.lerp(uvs[1], uvs[3], endTan, outUVs[2]);
|
|
2951
|
-
} else {
|
|
2952
|
-
engineMath.Vector3.lerp(positions[2], positions[3], 1 / endTan, outPositions[2]);
|
|
2953
|
-
engineMath.Vector2.lerp(uvs[2], uvs[3], 1 / endTan, outUVs[2]);
|
|
2954
|
-
}
|
|
2955
|
-
}
|
|
2956
|
-
// 45° is the quadrant diagonal: a sector spanning it reaches the far corner and needs a quad;
|
|
2957
|
-
// otherwise the cut produces a triangle.
|
|
2958
|
-
if (start < 45 && end > 45) {
|
|
2959
|
-
outPositions[3].copyFrom(positions[3]);
|
|
2960
|
-
outUVs[3].copyFrom(uvs[3]);
|
|
2961
|
-
this._addQuad(subChunk, outPositions, outUVs);
|
|
2962
|
-
} else {
|
|
2963
|
-
this._addTriangle(subChunk, outPositions, outUVs);
|
|
2964
|
-
}
|
|
2965
|
-
};
|
|
2966
|
-
FilledSpriteAssembler._addTriangle = function _addTriangle(subChunk, positions, uvs) {
|
|
2967
|
-
var vertices = subChunk.chunk.vertices;
|
|
2968
|
-
var indices = subChunk.indices;
|
|
2969
|
-
var vertexOffset = this._vertexOffset;
|
|
2970
|
-
var vertexCount = vertexOffset / 9;
|
|
2971
|
-
var start = subChunk.vertexArea.start + vertexOffset;
|
|
2972
|
-
for(var i = 0, o = start; i < 3; ++i, o += 9){
|
|
2973
|
-
var position = positions[i];
|
|
2974
|
-
var uv = uvs[i];
|
|
2975
|
-
vertices[o] = position.x;
|
|
2976
|
-
vertices[o + 1] = position.y;
|
|
2977
|
-
vertices[o + 2] = position.z;
|
|
2978
|
-
vertices[o + 3] = uv.x;
|
|
2979
|
-
vertices[o + 4] = uv.y;
|
|
2980
|
-
}
|
|
2981
|
-
var indicesOffset = this._indicesOffset;
|
|
2982
|
-
indices[indicesOffset] = vertexCount;
|
|
2983
|
-
indices[indicesOffset + 1] = vertexCount + 1;
|
|
2984
|
-
indices[indicesOffset + 2] = vertexCount + 2;
|
|
2985
|
-
this._vertexOffset += 3 * 9;
|
|
2986
|
-
this._indicesOffset += 3;
|
|
2987
|
-
};
|
|
2988
|
-
FilledSpriteAssembler._addQuad = function _addQuad(subChunk, positions, uvs) {
|
|
2989
|
-
var vertices = subChunk.chunk.vertices;
|
|
2990
|
-
var indices = subChunk.indices;
|
|
2991
|
-
var vertexOffset = this._vertexOffset;
|
|
2992
|
-
var vertexCount = vertexOffset / 9;
|
|
2993
|
-
var start = subChunk.vertexArea.start + vertexOffset;
|
|
2994
|
-
for(var i = 0, o = start; i < 4; ++i, o += 9){
|
|
2995
|
-
var position = positions[i];
|
|
2996
|
-
var uv = uvs[i];
|
|
2997
|
-
vertices[o] = position.x;
|
|
2998
|
-
vertices[o + 1] = position.y;
|
|
2999
|
-
vertices[o + 2] = position.z;
|
|
3000
|
-
vertices[o + 3] = uv.x;
|
|
3001
|
-
vertices[o + 4] = uv.y;
|
|
3002
|
-
}
|
|
3003
|
-
var indicesOffset = this._indicesOffset;
|
|
3004
|
-
indices[indicesOffset] = vertexCount;
|
|
3005
|
-
indices[indicesOffset + 1] = vertexCount + 1;
|
|
3006
|
-
indices[indicesOffset + 2] = vertexCount + 2;
|
|
3007
|
-
indices[indicesOffset + 3] = vertexCount + 2;
|
|
3008
|
-
indices[indicesOffset + 4] = vertexCount + 1;
|
|
3009
|
-
indices[indicesOffset + 5] = vertexCount + 3;
|
|
3010
|
-
this._vertexOffset += 4 * 9;
|
|
3011
|
-
this._indicesOffset += 6;
|
|
3012
|
-
};
|
|
3013
|
-
return FilledSpriteAssembler;
|
|
3014
|
-
}();
|
|
3015
|
-
exports.FilledSpriteAssembler._matrix = new engineMath.Matrix();
|
|
3016
|
-
exports.FilledSpriteAssembler._worldPositions = [
|
|
3017
|
-
new engineMath.Vector3(),
|
|
3018
|
-
new engineMath.Vector3(),
|
|
3019
|
-
new engineMath.Vector3(),
|
|
3020
|
-
new engineMath.Vector3(),
|
|
3021
|
-
new engineMath.Vector3(),
|
|
3022
|
-
new engineMath.Vector3(),
|
|
3023
|
-
new engineMath.Vector3(),
|
|
3024
|
-
new engineMath.Vector3(),
|
|
3025
|
-
new engineMath.Vector3()
|
|
3026
|
-
];
|
|
3027
|
-
exports.FilledSpriteAssembler._uvs = [
|
|
3028
|
-
new engineMath.Vector2(),
|
|
3029
|
-
new engineMath.Vector2(),
|
|
3030
|
-
new engineMath.Vector2(),
|
|
3031
|
-
new engineMath.Vector2(),
|
|
3032
|
-
new engineMath.Vector2(),
|
|
3033
|
-
new engineMath.Vector2(),
|
|
3034
|
-
new engineMath.Vector2(),
|
|
3035
|
-
new engineMath.Vector2(),
|
|
3036
|
-
new engineMath.Vector2()
|
|
3037
|
-
];
|
|
3038
|
-
exports.FilledSpriteAssembler._inPositions = [];
|
|
3039
|
-
exports.FilledSpriteAssembler._inUVs = [];
|
|
3040
|
-
exports.FilledSpriteAssembler._outPositions = [
|
|
3041
|
-
new engineMath.Vector3(),
|
|
3042
|
-
new engineMath.Vector3(),
|
|
3043
|
-
new engineMath.Vector3(),
|
|
3044
|
-
new engineMath.Vector3()
|
|
3045
|
-
];
|
|
3046
|
-
exports.FilledSpriteAssembler._outUVs = [
|
|
3047
|
-
new engineMath.Vector2(),
|
|
3048
|
-
new engineMath.Vector2(),
|
|
3049
|
-
new engineMath.Vector2(),
|
|
3050
|
-
new engineMath.Vector2()
|
|
3051
|
-
];
|
|
3052
|
-
exports.FilledSpriteAssembler._vertexOffset = 0;
|
|
3053
|
-
exports.FilledSpriteAssembler._indicesOffset = 0;
|
|
3054
|
-
// Fill amounts at or below this are treated as empty (render nothing), avoiding degenerate geometry.
|
|
3055
|
-
exports.FilledSpriteAssembler._fillAmountEpsilon = 0.001;
|
|
3056
|
-
exports.FilledSpriteAssembler = __decorate([
|
|
3057
|
-
StaticInterfaceImplement()
|
|
3058
|
-
], exports.FilledSpriteAssembler);
|
|
3059
|
-
|
|
3060
2450
|
exports.SimpleSpriteAssembler = /*#__PURE__*/ function() {
|
|
3061
2451
|
function SimpleSpriteAssembler() {}
|
|
3062
2452
|
SimpleSpriteAssembler.resetData = function resetData(renderer) {
|
|
@@ -3706,16 +3096,10 @@ var Utils = /*#__PURE__*/ function() {
|
|
|
3706
3096
|
if (Utils.isAbsoluteUrl(baseUrl)) {
|
|
3707
3097
|
return relativeUrl ? new URL(relativeUrl, baseUrl).href : baseUrl;
|
|
3708
3098
|
}
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
// lowercases the first segment and breaks case-sensitive virtual-resource
|
|
3712
|
-
// lookup in Editor previews
|
|
3713
|
-
var resolvedHasLeadingSlash = baseUrl.startsWith("/") || relativeUrl.startsWith("/");
|
|
3714
|
-
var head = "file:///";
|
|
3715
|
-
var encodedBaseUrl = head + this._encodePathComponents(baseUrl.replace(/^\/+/, ""));
|
|
3099
|
+
var head = "file://";
|
|
3100
|
+
var encodedBaseUrl = head + this._encodePathComponents(baseUrl);
|
|
3716
3101
|
var encodedRelativeUrl = this._encodePathComponents(relativeUrl);
|
|
3717
|
-
|
|
3718
|
-
return resolvedHasLeadingSlash ? "/" + resolvedPath : resolvedPath;
|
|
3102
|
+
return decodeURIComponent(new URL(encodedRelativeUrl, encodedBaseUrl).href.slice(head.length));
|
|
3719
3103
|
};
|
|
3720
3104
|
/**
|
|
3721
3105
|
* @internal
|
|
@@ -4414,7 +3798,6 @@ exports.TiledSpriteAssembler = __decorate([
|
|
|
4414
3798
|
/** Overall scaling when modifying size. */ SpriteDrawMode[SpriteDrawMode["Simple"] = 0] = "Simple";
|
|
4415
3799
|
/** When modifying the size of the renderer, it scales to fill the range according to the sprite border settings. */ SpriteDrawMode[SpriteDrawMode["Sliced"] = 1] = "Sliced";
|
|
4416
3800
|
/** When modifying the size of the renderer, it will tile to fill the range according to the sprite border settings. */ SpriteDrawMode[SpriteDrawMode["Tiled"] = 2] = "Tiled";
|
|
4417
|
-
/** Fill the sprite partially, controlled by fill amount, mode and origin. */ SpriteDrawMode[SpriteDrawMode["Filled"] = 3] = "Filled";
|
|
4418
3801
|
return SpriteDrawMode;
|
|
4419
3802
|
}({});
|
|
4420
3803
|
|
|
@@ -4459,50 +3842,430 @@ exports.TiledSpriteAssembler = __decorate([
|
|
|
4459
3842
|
return TextVerticalAlignment;
|
|
4460
3843
|
}({});
|
|
4461
3844
|
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
/**
|
|
3845
|
+
/**
|
|
3846
|
+
* @internal
|
|
3847
|
+
*/ var UpdateFlagManager = /*#__PURE__*/ function() {
|
|
3848
|
+
function UpdateFlagManager() {
|
|
3849
|
+
/** Monotonic counter bumped on every `dispatch`; consumers can snapshot it for lazy pull-style cache invalidation. */ this.version = 0;
|
|
3850
|
+
this._updateFlags = [];
|
|
3851
|
+
this._listeners = [];
|
|
4467
3852
|
}
|
|
4468
|
-
var _proto =
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
this.
|
|
4475
|
-
|
|
4476
|
-
this.instancedRenderers.length = 0;
|
|
4477
|
-
this.subDistancePriority = 0;
|
|
4478
|
-
this._isBatched = false;
|
|
3853
|
+
var _proto = UpdateFlagManager.prototype;
|
|
3854
|
+
/**
|
|
3855
|
+
* Create a UpdateFlag.
|
|
3856
|
+
* @returns - The UpdateFlag.
|
|
3857
|
+
*/ _proto.createFlag = function createFlag(type) {
|
|
3858
|
+
var flag = new type();
|
|
3859
|
+
this.addFlag(flag);
|
|
3860
|
+
return flag;
|
|
4479
3861
|
};
|
|
4480
3862
|
/**
|
|
4481
|
-
*
|
|
4482
|
-
*
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
this.set(source.component, source.material, source.primitive, source.subPrimitive, source.texture, source.subChunk);
|
|
4487
|
-
this.priority = source.priority;
|
|
4488
|
-
this.distanceForSort = source.distanceForSort;
|
|
4489
|
-
this.subShader = source.subShader;
|
|
4490
|
-
this.shaderData = source.shaderData;
|
|
4491
|
-
this.subDistancePriority = source.subDistancePriority;
|
|
3863
|
+
* Add a UpdateFlag.
|
|
3864
|
+
* @param flag - The UpdateFlag.
|
|
3865
|
+
*/ _proto.addFlag = function addFlag(flag) {
|
|
3866
|
+
this._updateFlags.push(flag);
|
|
3867
|
+
flag._flagManagers.push(this);
|
|
4492
3868
|
};
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
this.
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
this.texture && (this.texture = null);
|
|
4502
|
-
this.subChunk && (this.subChunk = null);
|
|
3869
|
+
/**
|
|
3870
|
+
* Remove a UpdateFlag.
|
|
3871
|
+
* @param flag - The UpdateFlag.
|
|
3872
|
+
*/ _proto.removeFlag = function removeFlag(flag) {
|
|
3873
|
+
var success = Utils.removeFromArray(this._updateFlags, flag);
|
|
3874
|
+
if (success) {
|
|
3875
|
+
Utils.removeFromArray(flag._flagManagers, this);
|
|
3876
|
+
}
|
|
4503
3877
|
};
|
|
4504
|
-
|
|
3878
|
+
/**
|
|
3879
|
+
* Add a listener.
|
|
3880
|
+
* @param listener - The listener
|
|
3881
|
+
*/ _proto.addListener = function addListener(listener) {
|
|
3882
|
+
this._listeners.push(listener);
|
|
3883
|
+
};
|
|
3884
|
+
/**
|
|
3885
|
+
* Remove a listener.
|
|
3886
|
+
* @param listener - The listener
|
|
3887
|
+
*/ _proto.removeListener = function removeListener(listener) {
|
|
3888
|
+
Utils.removeFromArray(this._listeners, listener);
|
|
3889
|
+
};
|
|
3890
|
+
/**
|
|
3891
|
+
* Dispatch a event.
|
|
3892
|
+
* @param type - Event type, usually in the form of enumeration
|
|
3893
|
+
* @param param - Event param
|
|
3894
|
+
*/ _proto.dispatch = function dispatch(type, param) {
|
|
3895
|
+
this.version++;
|
|
3896
|
+
var updateFlags = this._updateFlags;
|
|
3897
|
+
for(var i = updateFlags.length - 1; i >= 0; i--){
|
|
3898
|
+
updateFlags[i].dispatch(type, param);
|
|
3899
|
+
}
|
|
3900
|
+
var listeners = this._listeners;
|
|
3901
|
+
for(var i1 = listeners.length - 1; i1 >= 0; i1--){
|
|
3902
|
+
listeners[i1](type, param);
|
|
3903
|
+
}
|
|
3904
|
+
};
|
|
3905
|
+
return UpdateFlagManager;
|
|
4505
3906
|
}();
|
|
3907
|
+
registerDefaultCloneMode(UpdateFlagManager, CloneMode.Ignore);
|
|
3908
|
+
|
|
3909
|
+
/**
|
|
3910
|
+
* 2D sprite.
|
|
3911
|
+
*/ var Sprite = /*#__PURE__*/ function(ReferResource) {
|
|
3912
|
+
_inherits(Sprite, ReferResource);
|
|
3913
|
+
function Sprite(engine, texture, region, pivot, border, name) {
|
|
3914
|
+
if (texture === void 0) texture = null;
|
|
3915
|
+
if (region === void 0) region = null;
|
|
3916
|
+
if (pivot === void 0) pivot = null;
|
|
3917
|
+
if (border === void 0) border = null;
|
|
3918
|
+
if (name === void 0) name = null;
|
|
3919
|
+
var _this;
|
|
3920
|
+
_this = ReferResource.call(this, engine) || this, _this._automaticWidth = 0, _this._automaticHeight = 0, _this._customWidth = undefined, _this._customHeight = undefined, _this._positions = [
|
|
3921
|
+
new engineMath.Vector2(),
|
|
3922
|
+
new engineMath.Vector2(),
|
|
3923
|
+
new engineMath.Vector2(),
|
|
3924
|
+
new engineMath.Vector2()
|
|
3925
|
+
], _this._uvs = [
|
|
3926
|
+
new engineMath.Vector2(),
|
|
3927
|
+
new engineMath.Vector2(),
|
|
3928
|
+
new engineMath.Vector2(),
|
|
3929
|
+
new engineMath.Vector2()
|
|
3930
|
+
], _this._bounds = new engineMath.BoundingBox(), _this._texture = null, _this._atlasRotated = false, _this._atlasRegion = new engineMath.Rect(0, 0, 1, 1), _this._atlasRegionOffset = new engineMath.Vector4(0, 0, 0, 0), _this._region = new engineMath.Rect(0, 0, 1, 1), _this._pivot = new engineMath.Vector2(0.5, 0.5), _this._border = new engineMath.Vector4(0, 0, 0, 0), _this._dirtyUpdateFlag = 7, /** @internal */ _this._updateFlagManager = new UpdateFlagManager();
|
|
3931
|
+
_this._texture = texture;
|
|
3932
|
+
_this._onRegionChange = _this._onRegionChange.bind(_this);
|
|
3933
|
+
_this._onPivotChange = _this._onPivotChange.bind(_this);
|
|
3934
|
+
_this._onBorderChange = _this._onBorderChange.bind(_this);
|
|
3935
|
+
// @ts-ignore
|
|
3936
|
+
_this._region._onValueChanged = _this._onRegionChange;
|
|
3937
|
+
// @ts-ignore
|
|
3938
|
+
_this._pivot._onValueChanged = _this._onPivotChange;
|
|
3939
|
+
// @ts-ignore
|
|
3940
|
+
_this._border._onValueChanged = _this._onBorderChange;
|
|
3941
|
+
region && _this._region.copyFrom(region);
|
|
3942
|
+
pivot && _this._pivot.copyFrom(pivot);
|
|
3943
|
+
border && _this._border.copyFrom(border);
|
|
3944
|
+
_this.name = name;
|
|
3945
|
+
return _this;
|
|
3946
|
+
}
|
|
3947
|
+
var _proto = Sprite.prototype;
|
|
3948
|
+
/**
|
|
3949
|
+
* Clone.
|
|
3950
|
+
* @returns Cloned sprite
|
|
3951
|
+
*/ _proto.clone = function clone() {
|
|
3952
|
+
var cloneSprite = new Sprite(this._engine, this._texture, this._region, this._pivot, this._border, this.name);
|
|
3953
|
+
cloneSprite._atlasRotated = this._atlasRotated;
|
|
3954
|
+
cloneSprite._atlasRegion.copyFrom(this._atlasRegion);
|
|
3955
|
+
cloneSprite._atlasRegionOffset.copyFrom(this._atlasRegionOffset);
|
|
3956
|
+
return cloneSprite;
|
|
3957
|
+
};
|
|
3958
|
+
/**
|
|
3959
|
+
* @internal
|
|
3960
|
+
*/ _proto._getPositions = function _getPositions() {
|
|
3961
|
+
this._dirtyUpdateFlag & 1 && this._updatePositions();
|
|
3962
|
+
return this._positions;
|
|
3963
|
+
};
|
|
3964
|
+
/**
|
|
3965
|
+
* @internal
|
|
3966
|
+
*/ _proto._getUVs = function _getUVs() {
|
|
3967
|
+
this._dirtyUpdateFlag & 2 && this._updateUVs();
|
|
3968
|
+
return this._uvs;
|
|
3969
|
+
};
|
|
3970
|
+
/**
|
|
3971
|
+
* @internal
|
|
3972
|
+
*/ _proto._getBounds = function _getBounds() {
|
|
3973
|
+
this._dirtyUpdateFlag & 1 && this._updatePositions();
|
|
3974
|
+
return this._bounds;
|
|
3975
|
+
};
|
|
3976
|
+
/**
|
|
3977
|
+
* @internal
|
|
3978
|
+
*/ _proto._addReferCount = function _addReferCount(value) {
|
|
3979
|
+
var _this__atlas;
|
|
3980
|
+
ReferResource.prototype._addReferCount.call(this, value);
|
|
3981
|
+
(_this__atlas = this._atlas) == null ? void 0 : _this__atlas._addReferCount(value);
|
|
3982
|
+
};
|
|
3983
|
+
/**
|
|
3984
|
+
* @internal
|
|
3985
|
+
*/ _proto._onDestroy = function _onDestroy() {
|
|
3986
|
+
this._dispatchSpriteChange(SpriteModifyFlags.destroy);
|
|
3987
|
+
ReferResource.prototype._onDestroy.call(this);
|
|
3988
|
+
this._positions.length = 0;
|
|
3989
|
+
this._positions = null;
|
|
3990
|
+
this._uvs.length = 0;
|
|
3991
|
+
this._uvs = null;
|
|
3992
|
+
this._atlasRegion = null;
|
|
3993
|
+
this._atlasRegionOffset = null;
|
|
3994
|
+
this._region = null;
|
|
3995
|
+
this._pivot = null;
|
|
3996
|
+
this._border = null;
|
|
3997
|
+
this._bounds = null;
|
|
3998
|
+
this._atlas = null;
|
|
3999
|
+
this._texture = null;
|
|
4000
|
+
};
|
|
4001
|
+
_proto._calDefaultSize = function _calDefaultSize() {
|
|
4002
|
+
if (this._texture) {
|
|
4003
|
+
var _this = this, _texture = _this._texture, _atlasRegion = _this._atlasRegion, _atlasRegionOffset = _this._atlasRegionOffset, _region = _this._region;
|
|
4004
|
+
var pixelsPerUnitReciprocal = 1.0 / Engine._pixelsPerUnit;
|
|
4005
|
+
this._automaticWidth = _texture.width * _atlasRegion.width / (1 - _atlasRegionOffset.x - _atlasRegionOffset.z) * _region.width * pixelsPerUnitReciprocal;
|
|
4006
|
+
this._automaticHeight = _texture.height * _atlasRegion.height / (1 - _atlasRegionOffset.y - _atlasRegionOffset.w) * _region.height * pixelsPerUnitReciprocal;
|
|
4007
|
+
} else {
|
|
4008
|
+
this._automaticWidth = this._automaticHeight = 0;
|
|
4009
|
+
}
|
|
4010
|
+
this._dirtyUpdateFlag &= ~4;
|
|
4011
|
+
};
|
|
4012
|
+
_proto._updatePositions = function _updatePositions() {
|
|
4013
|
+
var blank = this._atlasRegionOffset;
|
|
4014
|
+
var _this__region = this._region, regionX = _this__region.x, regionY = _this__region.y, regionW = _this__region.width, regionH = _this__region.height;
|
|
4015
|
+
var regionRight = 1 - regionX - regionW;
|
|
4016
|
+
var regionBottom = 1 - regionY - regionH;
|
|
4017
|
+
var left = Math.max(blank.x - regionX, 0) / regionW;
|
|
4018
|
+
var bottom = Math.max(blank.w - regionY, 0) / regionH;
|
|
4019
|
+
var right = 1 - Math.max(blank.z - regionRight, 0) / regionW;
|
|
4020
|
+
var top = 1 - Math.max(blank.y - regionBottom, 0) / regionH;
|
|
4021
|
+
// Update positions.
|
|
4022
|
+
// ---------------
|
|
4023
|
+
// 2 - 3
|
|
4024
|
+
// | |
|
|
4025
|
+
// 0 - 1
|
|
4026
|
+
// ---------------
|
|
4027
|
+
var positions = this._positions;
|
|
4028
|
+
positions[0].set(left, bottom);
|
|
4029
|
+
positions[1].set(right, bottom);
|
|
4030
|
+
positions[2].set(left, top);
|
|
4031
|
+
positions[3].set(right, top);
|
|
4032
|
+
var bounds = this._bounds;
|
|
4033
|
+
bounds.min.set(left, bottom, 0);
|
|
4034
|
+
bounds.max.set(right, top, 0);
|
|
4035
|
+
this._dirtyUpdateFlag &= ~1;
|
|
4036
|
+
};
|
|
4037
|
+
_proto._updateUVs = function _updateUVs() {
|
|
4038
|
+
var _this = this, uv = _this._uvs, atlasRegionOffset = _this._atlasRegionOffset;
|
|
4039
|
+
var _this__region = this._region, regionX = _this__region.x, regionY = _this__region.y, regionW = _this__region.width, regionH = _this__region.height;
|
|
4040
|
+
var regionRight = 1 - regionX - regionW;
|
|
4041
|
+
var regionBottom = 1 - regionY - regionH;
|
|
4042
|
+
var _this__atlasRegion = this._atlasRegion, atlasRegionX = _this__atlasRegion.x, atlasRegionY = _this__atlasRegion.y, atlasRegionW = _this__atlasRegion.width, atlasRegionH = _this__atlasRegion.height;
|
|
4043
|
+
var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
|
|
4044
|
+
var realWidth = atlasRegionW / (1 - offsetLeft - offsetRight);
|
|
4045
|
+
var realHeight = atlasRegionH / (1 - offsetTop - offsetBottom);
|
|
4046
|
+
// Coordinates of the four boundaries.
|
|
4047
|
+
var left = Math.max(regionX - offsetLeft, 0) * realWidth + atlasRegionX;
|
|
4048
|
+
var top = Math.max(regionBottom - offsetTop, 0) * realHeight + atlasRegionY;
|
|
4049
|
+
var right = atlasRegionW + atlasRegionX - Math.max(regionRight - offsetRight, 0) * realWidth;
|
|
4050
|
+
var bottom = atlasRegionH + atlasRegionY - Math.max(regionY - offsetBottom, 0) * realHeight;
|
|
4051
|
+
var _this__border = this._border, borderLeft = _this__border.x, borderBottom = _this__border.y, borderRight = _this__border.z, borderTop = _this__border.w;
|
|
4052
|
+
// Left-Bottom
|
|
4053
|
+
uv[0].set(left, bottom);
|
|
4054
|
+
// Border ( Left-Bottom )
|
|
4055
|
+
uv[1].set((regionX - offsetLeft + borderLeft * regionW) * realWidth + atlasRegionX, atlasRegionH + atlasRegionY - (regionY - offsetBottom + borderBottom * regionH) * realHeight);
|
|
4056
|
+
// Border ( Right-Top )
|
|
4057
|
+
uv[2].set(atlasRegionW + atlasRegionX - (regionRight - offsetRight + borderRight * regionW) * realWidth, (regionBottom - offsetTop + borderTop * regionH) * realHeight + atlasRegionY);
|
|
4058
|
+
// Right-Top
|
|
4059
|
+
uv[3].set(right, top);
|
|
4060
|
+
this._dirtyUpdateFlag &= ~2;
|
|
4061
|
+
};
|
|
4062
|
+
_proto._dispatchSpriteChange = function _dispatchSpriteChange(type) {
|
|
4063
|
+
switch(type){
|
|
4064
|
+
case SpriteModifyFlags.texture:
|
|
4065
|
+
this._dirtyUpdateFlag |= 4;
|
|
4066
|
+
break;
|
|
4067
|
+
case SpriteModifyFlags.atlasRegionOffset:
|
|
4068
|
+
case SpriteModifyFlags.region:
|
|
4069
|
+
this._dirtyUpdateFlag |= 7;
|
|
4070
|
+
break;
|
|
4071
|
+
case SpriteModifyFlags.atlasRegion:
|
|
4072
|
+
this._dirtyUpdateFlag |= 4 | 2;
|
|
4073
|
+
break;
|
|
4074
|
+
case SpriteModifyFlags.border:
|
|
4075
|
+
this._dirtyUpdateFlag |= 2;
|
|
4076
|
+
break;
|
|
4077
|
+
}
|
|
4078
|
+
this._updateFlagManager.dispatch(type);
|
|
4079
|
+
};
|
|
4080
|
+
_proto._onRegionChange = function _onRegionChange() {
|
|
4081
|
+
var _this = this, region = _this._region;
|
|
4082
|
+
// @ts-ignore
|
|
4083
|
+
region._onValueChanged = null;
|
|
4084
|
+
var x = engineMath.MathUtil.clamp(region.x, 0, 1);
|
|
4085
|
+
var y = engineMath.MathUtil.clamp(region.y, 0, 1);
|
|
4086
|
+
region.set(x, y, engineMath.MathUtil.clamp(region.width, 0, 1 - x), engineMath.MathUtil.clamp(region.height, 0, 1 - y));
|
|
4087
|
+
this._dispatchSpriteChange(SpriteModifyFlags.region);
|
|
4088
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
4089
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
4090
|
+
}
|
|
4091
|
+
// @ts-ignore
|
|
4092
|
+
region._onValueChanged = this._onRegionChange;
|
|
4093
|
+
};
|
|
4094
|
+
_proto._onPivotChange = function _onPivotChange() {
|
|
4095
|
+
this._dispatchSpriteChange(SpriteModifyFlags.pivot);
|
|
4096
|
+
};
|
|
4097
|
+
_proto._onBorderChange = function _onBorderChange() {
|
|
4098
|
+
var _this = this, border = _this._border;
|
|
4099
|
+
// @ts-ignore
|
|
4100
|
+
border._onValueChanged = null;
|
|
4101
|
+
var x = engineMath.MathUtil.clamp(border.x, 0, 1);
|
|
4102
|
+
var y = engineMath.MathUtil.clamp(border.y, 0, 1);
|
|
4103
|
+
border.set(x, y, engineMath.MathUtil.clamp(border.z, 0, 1 - x), engineMath.MathUtil.clamp(border.w, 0, 1 - y));
|
|
4104
|
+
this._dispatchSpriteChange(SpriteModifyFlags.border);
|
|
4105
|
+
// @ts-ignore
|
|
4106
|
+
border._onValueChanged = this._onBorderChange;
|
|
4107
|
+
};
|
|
4108
|
+
_create_class(Sprite, [
|
|
4109
|
+
{
|
|
4110
|
+
key: "texture",
|
|
4111
|
+
get: /**
|
|
4112
|
+
* The reference to the used texture.
|
|
4113
|
+
*/ function get() {
|
|
4114
|
+
return this._texture;
|
|
4115
|
+
},
|
|
4116
|
+
set: function set(value) {
|
|
4117
|
+
if (this._texture !== value) {
|
|
4118
|
+
this._texture = value;
|
|
4119
|
+
this._dispatchSpriteChange(SpriteModifyFlags.texture);
|
|
4120
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
4121
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
4122
|
+
}
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
},
|
|
4126
|
+
{
|
|
4127
|
+
key: "width",
|
|
4128
|
+
get: /**
|
|
4129
|
+
* The width of the sprite (in world coordinates).
|
|
4130
|
+
*
|
|
4131
|
+
* @remarks
|
|
4132
|
+
* If width is set, return the set value,
|
|
4133
|
+
* otherwise return the width calculated according to `Texture.width`, `Sprite.region`, `Sprite.atlasRegion` and `Sprite.atlasRegionOffset`.
|
|
4134
|
+
*/ function get() {
|
|
4135
|
+
if (this._customWidth !== undefined) {
|
|
4136
|
+
return this._customWidth;
|
|
4137
|
+
} else {
|
|
4138
|
+
this._dirtyUpdateFlag & 4 && this._calDefaultSize();
|
|
4139
|
+
return this._automaticWidth;
|
|
4140
|
+
}
|
|
4141
|
+
},
|
|
4142
|
+
set: function set(value) {
|
|
4143
|
+
if (this._customWidth !== value) {
|
|
4144
|
+
this._customWidth = value;
|
|
4145
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
},
|
|
4149
|
+
{
|
|
4150
|
+
key: "height",
|
|
4151
|
+
get: /**
|
|
4152
|
+
* The height of the sprite (in world coordinates).
|
|
4153
|
+
*
|
|
4154
|
+
* @remarks
|
|
4155
|
+
* If height is set, return the set value,
|
|
4156
|
+
* otherwise return the height calculated according to `Texture.height`, `Sprite.region`, `Sprite.atlasRegion` and `Sprite.atlasRegionOffset`.
|
|
4157
|
+
*/ function get() {
|
|
4158
|
+
if (this._customHeight !== undefined) {
|
|
4159
|
+
return this._customHeight;
|
|
4160
|
+
} else {
|
|
4161
|
+
this._dirtyUpdateFlag & 4 && this._calDefaultSize();
|
|
4162
|
+
return this._automaticHeight;
|
|
4163
|
+
}
|
|
4164
|
+
},
|
|
4165
|
+
set: function set(value) {
|
|
4166
|
+
if (this._customHeight !== value) {
|
|
4167
|
+
this._customHeight = value;
|
|
4168
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4171
|
+
},
|
|
4172
|
+
{
|
|
4173
|
+
key: "atlasRotated",
|
|
4174
|
+
get: /**
|
|
4175
|
+
* Is it rotated 90 degrees clockwise when packing.
|
|
4176
|
+
*/ function get() {
|
|
4177
|
+
return this._atlasRotated;
|
|
4178
|
+
},
|
|
4179
|
+
set: function set(value) {
|
|
4180
|
+
if (this._atlasRotated != value) {
|
|
4181
|
+
this._atlasRotated = value;
|
|
4182
|
+
}
|
|
4183
|
+
}
|
|
4184
|
+
},
|
|
4185
|
+
{
|
|
4186
|
+
key: "atlasRegion",
|
|
4187
|
+
get: /**
|
|
4188
|
+
* The rectangle region of the original texture on its atlas texture, specified in normalized.
|
|
4189
|
+
*/ function get() {
|
|
4190
|
+
return this._atlasRegion;
|
|
4191
|
+
},
|
|
4192
|
+
set: function set(value) {
|
|
4193
|
+
var x = engineMath.MathUtil.clamp(value.x, 0, 1);
|
|
4194
|
+
var y = engineMath.MathUtil.clamp(value.y, 0, 1);
|
|
4195
|
+
this._atlasRegion.set(x, y, engineMath.MathUtil.clamp(value.width, 0, 1 - x), engineMath.MathUtil.clamp(value.height, 0, 1 - y));
|
|
4196
|
+
this._dispatchSpriteChange(SpriteModifyFlags.atlasRegion);
|
|
4197
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
4198
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
4199
|
+
}
|
|
4200
|
+
}
|
|
4201
|
+
},
|
|
4202
|
+
{
|
|
4203
|
+
key: "atlasRegionOffset",
|
|
4204
|
+
get: /**
|
|
4205
|
+
* The rectangle region offset of the original texture on its atlas texture, specified in normalized.
|
|
4206
|
+
*/ function get() {
|
|
4207
|
+
return this._atlasRegionOffset;
|
|
4208
|
+
},
|
|
4209
|
+
set: function set(value) {
|
|
4210
|
+
var x = engineMath.MathUtil.clamp(value.x, 0, 1);
|
|
4211
|
+
var y = engineMath.MathUtil.clamp(value.y, 0, 1);
|
|
4212
|
+
this._atlasRegionOffset.set(x, y, engineMath.MathUtil.clamp(value.z, 0, 1 - x), engineMath.MathUtil.clamp(value.w, 0, 1 - y));
|
|
4213
|
+
this._dispatchSpriteChange(SpriteModifyFlags.atlasRegionOffset);
|
|
4214
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
4215
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
4216
|
+
}
|
|
4217
|
+
}
|
|
4218
|
+
},
|
|
4219
|
+
{
|
|
4220
|
+
key: "region",
|
|
4221
|
+
get: /**
|
|
4222
|
+
* The rectangle region of the sprite, specified in normalized.
|
|
4223
|
+
*/ function get() {
|
|
4224
|
+
return this._region;
|
|
4225
|
+
},
|
|
4226
|
+
set: function set(value) {
|
|
4227
|
+
this._region !== value && this._region.copyFrom(value);
|
|
4228
|
+
}
|
|
4229
|
+
},
|
|
4230
|
+
{
|
|
4231
|
+
key: "pivot",
|
|
4232
|
+
get: /**
|
|
4233
|
+
* Location of the sprite's center point in the rectangle region, specified in normalized.
|
|
4234
|
+
* The origin is at the bottom left and the default value is (0.5, 0.5).
|
|
4235
|
+
*/ function get() {
|
|
4236
|
+
return this._pivot;
|
|
4237
|
+
},
|
|
4238
|
+
set: function set(value) {
|
|
4239
|
+
this._pivot !== value && this._pivot.copyFrom(value);
|
|
4240
|
+
}
|
|
4241
|
+
},
|
|
4242
|
+
{
|
|
4243
|
+
key: "border",
|
|
4244
|
+
get: /**
|
|
4245
|
+
* Get the border of the sprite.
|
|
4246
|
+
* x y z w
|
|
4247
|
+
* | | | |
|
|
4248
|
+
* Left, bottom, right, top.
|
|
4249
|
+
* @remarks only use in sliced mode.
|
|
4250
|
+
*/ function get() {
|
|
4251
|
+
return this._border;
|
|
4252
|
+
},
|
|
4253
|
+
set: function set(value) {
|
|
4254
|
+
this._border !== value && this._border.copyFrom(value);
|
|
4255
|
+
}
|
|
4256
|
+
}
|
|
4257
|
+
]);
|
|
4258
|
+
return Sprite;
|
|
4259
|
+
}(ReferResource);
|
|
4260
|
+
__decorate([
|
|
4261
|
+
ignoreClone
|
|
4262
|
+
], Sprite.prototype, "_onRegionChange", null);
|
|
4263
|
+
__decorate([
|
|
4264
|
+
ignoreClone
|
|
4265
|
+
], Sprite.prototype, "_onPivotChange", null);
|
|
4266
|
+
__decorate([
|
|
4267
|
+
ignoreClone
|
|
4268
|
+
], Sprite.prototype, "_onBorderChange", null);
|
|
4506
4269
|
|
|
4507
4270
|
/**
|
|
4508
4271
|
* Blend factor.
|
|
@@ -4901,70 +4664,6 @@ function _extends() {
|
|
|
4901
4664
|
return _extends.apply(this, arguments);
|
|
4902
4665
|
}
|
|
4903
4666
|
|
|
4904
|
-
/**
|
|
4905
|
-
* @internal
|
|
4906
|
-
*/ var UpdateFlagManager = /*#__PURE__*/ function() {
|
|
4907
|
-
function UpdateFlagManager() {
|
|
4908
|
-
/** Monotonic counter bumped on every `dispatch`; consumers can snapshot it for lazy pull-style cache invalidation. */ this.version = 0;
|
|
4909
|
-
this._updateFlags = [];
|
|
4910
|
-
this._listeners = [];
|
|
4911
|
-
}
|
|
4912
|
-
var _proto = UpdateFlagManager.prototype;
|
|
4913
|
-
/**
|
|
4914
|
-
* Create a UpdateFlag.
|
|
4915
|
-
* @returns - The UpdateFlag.
|
|
4916
|
-
*/ _proto.createFlag = function createFlag(type) {
|
|
4917
|
-
var flag = new type();
|
|
4918
|
-
this.addFlag(flag);
|
|
4919
|
-
return flag;
|
|
4920
|
-
};
|
|
4921
|
-
/**
|
|
4922
|
-
* Add a UpdateFlag.
|
|
4923
|
-
* @param flag - The UpdateFlag.
|
|
4924
|
-
*/ _proto.addFlag = function addFlag(flag) {
|
|
4925
|
-
this._updateFlags.push(flag);
|
|
4926
|
-
flag._flagManagers.push(this);
|
|
4927
|
-
};
|
|
4928
|
-
/**
|
|
4929
|
-
* Remove a UpdateFlag.
|
|
4930
|
-
* @param flag - The UpdateFlag.
|
|
4931
|
-
*/ _proto.removeFlag = function removeFlag(flag) {
|
|
4932
|
-
var success = Utils.removeFromArray(this._updateFlags, flag);
|
|
4933
|
-
if (success) {
|
|
4934
|
-
Utils.removeFromArray(flag._flagManagers, this);
|
|
4935
|
-
}
|
|
4936
|
-
};
|
|
4937
|
-
/**
|
|
4938
|
-
* Add a listener.
|
|
4939
|
-
* @param listener - The listener
|
|
4940
|
-
*/ _proto.addListener = function addListener(listener) {
|
|
4941
|
-
this._listeners.push(listener);
|
|
4942
|
-
};
|
|
4943
|
-
/**
|
|
4944
|
-
* Remove a listener.
|
|
4945
|
-
* @param listener - The listener
|
|
4946
|
-
*/ _proto.removeListener = function removeListener(listener) {
|
|
4947
|
-
Utils.removeFromArray(this._listeners, listener);
|
|
4948
|
-
};
|
|
4949
|
-
/**
|
|
4950
|
-
* Dispatch a event.
|
|
4951
|
-
* @param type - Event type, usually in the form of enumeration
|
|
4952
|
-
* @param param - Event param
|
|
4953
|
-
*/ _proto.dispatch = function dispatch(type, param) {
|
|
4954
|
-
this.version++;
|
|
4955
|
-
var updateFlags = this._updateFlags;
|
|
4956
|
-
for(var i = updateFlags.length - 1; i >= 0; i--){
|
|
4957
|
-
updateFlags[i].dispatch(type, param);
|
|
4958
|
-
}
|
|
4959
|
-
var listeners = this._listeners;
|
|
4960
|
-
for(var i1 = listeners.length - 1; i1 >= 0; i1--){
|
|
4961
|
-
listeners[i1](type, param);
|
|
4962
|
-
}
|
|
4963
|
-
};
|
|
4964
|
-
return UpdateFlagManager;
|
|
4965
|
-
}();
|
|
4966
|
-
registerDefaultCloneMode(UpdateFlagManager, CloneMode.Ignore);
|
|
4967
|
-
|
|
4968
4667
|
/**
|
|
4969
4668
|
* Buffer usage.
|
|
4970
4669
|
*/ var BufferUsage = /*#__PURE__*/ function(BufferUsage) {
|
|
@@ -5324,12 +5023,10 @@ registerDefaultCloneMode(Component, CloneMode.Remap);
|
|
|
5324
5023
|
};
|
|
5325
5024
|
/**
|
|
5326
5025
|
* @internal
|
|
5327
|
-
*/ ComponentsDependencies._removeCheck = function _removeCheck(entity, type
|
|
5026
|
+
*/ ComponentsDependencies._removeCheck = function _removeCheck(entity, type) {
|
|
5328
5027
|
var components = entity._components;
|
|
5329
5028
|
var n = components.length;
|
|
5330
5029
|
while(type !== Component){
|
|
5331
|
-
// The replacement still satisfies this type and all of its base types.
|
|
5332
|
-
if (replace && (replace === type || _instanceof(replace.prototype, type))) return;
|
|
5333
5030
|
var count = 0;
|
|
5334
5031
|
for(var i = 0; i < n; i++){
|
|
5335
5032
|
if (_instanceof(components[i], type) && ++count > 1) return;
|
|
@@ -5450,7 +5147,7 @@ registerDefaultCloneMode(UpdateFlag, CloneMode.Ignore);
|
|
|
5450
5147
|
_inherits(Transform, Component);
|
|
5451
5148
|
function Transform(entity) {
|
|
5452
5149
|
var _this;
|
|
5453
|
-
_this = Component.call(this, entity) || this, _this._position = new engineMath.Vector3(), _this._rotation = new engineMath.Vector3(), _this._rotationQuaternion = new engineMath.Quaternion(), _this._scale = new engineMath.Vector3(1, 1, 1), _this._localUniformScaling = true, _this._worldPosition = new engineMath.Vector3(), _this._worldRotation = new engineMath.Vector3(), _this._worldRotationQuaternion = new engineMath.Quaternion(), _this._worldUniformScaling = true, _this._lossyWorldScale = new engineMath.Vector3(1, 1, 1), _this._localMatrix = new engineMath.Matrix(), _this._worldMatrix = new engineMath.Matrix(), _this._worldForward = null, _this._worldRight = null, _this._worldUp = null, _this.
|
|
5150
|
+
_this = Component.call(this, entity) || this, _this._position = new engineMath.Vector3(), _this._rotation = new engineMath.Vector3(), _this._rotationQuaternion = new engineMath.Quaternion(), _this._scale = new engineMath.Vector3(1, 1, 1), _this._localUniformScaling = true, _this._worldPosition = new engineMath.Vector3(), _this._worldRotation = new engineMath.Vector3(), _this._worldRotationQuaternion = new engineMath.Quaternion(), _this._worldUniformScaling = true, _this._lossyWorldScale = new engineMath.Vector3(1, 1, 1), _this._localMatrix = new engineMath.Matrix(), _this._worldMatrix = new engineMath.Matrix(), _this._worldForward = null, _this._worldRight = null, _this._worldUp = null, _this._isParentDirty = true, _this._parentTransformCache = null, _this._dirtyFlag = 510;
|
|
5454
5151
|
_this._onPositionChanged = _this._onPositionChanged.bind(_this);
|
|
5455
5152
|
_this._onWorldPositionChanged = _this._onWorldPositionChanged.bind(_this);
|
|
5456
5153
|
_this._onRotationChanged = _this._onRotationChanged.bind(_this);
|
|
@@ -5601,21 +5298,16 @@ registerDefaultCloneMode(UpdateFlag, CloneMode.Ignore);
|
|
|
5601
5298
|
* @internal
|
|
5602
5299
|
*/ _proto._parentChange = function _parentChange() {
|
|
5603
5300
|
this._isParentDirty = true;
|
|
5604
|
-
this._updateAllWorldFlag(
|
|
5301
|
+
this._updateAllWorldFlag(444);
|
|
5605
5302
|
};
|
|
5606
5303
|
/**
|
|
5607
5304
|
* @internal
|
|
5608
5305
|
*/ _proto._isFrontFaceInvert = function _isFrontFaceInvert() {
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
var parent = this._getParentTransform();
|
|
5615
|
-
this._frontFaceInvert = parent ? invert !== parent._isFrontFaceInvert() : invert;
|
|
5616
|
-
this._setDirtyFlagFalse(2048);
|
|
5617
|
-
}
|
|
5618
|
-
return this._frontFaceInvert;
|
|
5306
|
+
var scale = this.lossyWorldScale;
|
|
5307
|
+
var isInvert = scale.x < 0;
|
|
5308
|
+
scale.y < 0 && (isInvert = !isInvert);
|
|
5309
|
+
scale.z < 0 && (isInvert = !isInvert);
|
|
5310
|
+
return isInvert;
|
|
5619
5311
|
};
|
|
5620
5312
|
/**
|
|
5621
5313
|
* @inheritdoc
|
|
@@ -5716,10 +5408,10 @@ registerDefaultCloneMode(UpdateFlag, CloneMode.Ignore);
|
|
|
5716
5408
|
*/ _proto._updateWorldRotationFlag = function _updateWorldRotationFlag() {
|
|
5717
5409
|
var parent = this._getParentTransform();
|
|
5718
5410
|
var parentWorldUniformScaling = parent ? parent._getWorldUniformScaling() : true;
|
|
5719
|
-
var flags = parentWorldUniformScaling ? 152 :
|
|
5411
|
+
var flags = parentWorldUniformScaling ? 152 : 184;
|
|
5720
5412
|
if (!this._isContainDirtyFlags(flags)) {
|
|
5721
5413
|
this._worldAssociatedChange(flags);
|
|
5722
|
-
flags = this._getWorldUniformScaling() ? 156 :
|
|
5414
|
+
flags = this._getWorldUniformScaling() ? 156 : 188;
|
|
5723
5415
|
var children = this._entity._children;
|
|
5724
5416
|
for(var i = 0, n = children.length; i < n; i++){
|
|
5725
5417
|
var _children_i_transform;
|
|
@@ -5738,7 +5430,7 @@ registerDefaultCloneMode(UpdateFlag, CloneMode.Ignore);
|
|
|
5738
5430
|
*/ _proto._updateWorldPositionAndRotationFlag = function _updateWorldPositionAndRotationFlag(flags) {
|
|
5739
5431
|
if (!this._isContainDirtyFlags(flags)) {
|
|
5740
5432
|
this._worldAssociatedChange(flags);
|
|
5741
|
-
flags = this._getWorldUniformScaling() ? 156 :
|
|
5433
|
+
flags = this._getWorldUniformScaling() ? 156 : 188;
|
|
5742
5434
|
var children = this._entity._children;
|
|
5743
5435
|
for(var i = 0, n = children.length; i < n; i++){
|
|
5744
5436
|
var _children_i_transform;
|
|
@@ -5860,9 +5552,9 @@ registerDefaultCloneMode(UpdateFlag, CloneMode.Ignore);
|
|
|
5860
5552
|
var localUniformScaling = x == y && y == z;
|
|
5861
5553
|
if (this._localUniformScaling !== localUniformScaling) {
|
|
5862
5554
|
this._localUniformScaling = localUniformScaling;
|
|
5863
|
-
this._updateWorldScaleFlag(
|
|
5555
|
+
this._updateWorldScaleFlag(416);
|
|
5864
5556
|
} else {
|
|
5865
|
-
this._updateWorldScaleFlag(
|
|
5557
|
+
this._updateWorldScaleFlag(160);
|
|
5866
5558
|
}
|
|
5867
5559
|
};
|
|
5868
5560
|
_proto._getWorldUniformScaling = function _getWorldUniformScaling() {
|
|
@@ -6100,9 +5792,9 @@ registerDefaultCloneMode(UpdateFlag, CloneMode.Ignore);
|
|
|
6100
5792
|
var localUniformScaling = scale.x === scale.y && scale.y === scale.z;
|
|
6101
5793
|
if (this._localUniformScaling !== localUniformScaling) {
|
|
6102
5794
|
this._localUniformScaling = localUniformScaling;
|
|
6103
|
-
this._updateAllWorldFlag(
|
|
5795
|
+
this._updateAllWorldFlag(444);
|
|
6104
5796
|
} else {
|
|
6105
|
-
this._updateAllWorldFlag(
|
|
5797
|
+
this._updateAllWorldFlag(188);
|
|
6106
5798
|
}
|
|
6107
5799
|
}
|
|
6108
5800
|
},
|
|
@@ -6225,9 +5917,6 @@ __decorate([
|
|
|
6225
5917
|
__decorate([
|
|
6226
5918
|
ignoreClone
|
|
6227
5919
|
], Transform.prototype, "_worldUp", void 0);
|
|
6228
|
-
__decorate([
|
|
6229
|
-
ignoreClone
|
|
6230
|
-
], Transform.prototype, "_frontFaceInvert", void 0);
|
|
6231
5920
|
__decorate([
|
|
6232
5921
|
ignoreClone
|
|
6233
5922
|
], Transform.prototype, "_isParentDirty", void 0);
|
|
@@ -6272,18 +5961,16 @@ __decorate([
|
|
|
6272
5961
|
/** This is an internal flag used to assist in determining the dispatch
|
|
6273
5962
|
* of world scaling dirty flags in the case of non-uniform scaling.
|
|
6274
5963
|
*/ TransformModifyFlags[TransformModifyFlags["IsWorldUniformScaling"] = 256] = "IsWorldUniformScaling";
|
|
6275
|
-
// Note: 0x200 (UITransformModifyFlags.Size) and 0x400 (Pivot) are reserved by UITransform — do not reuse.
|
|
6276
|
-
TransformModifyFlags[TransformModifyFlags["WorldFrontFaceInvert"] = 2048] = "WorldFrontFaceInvert";
|
|
6277
5964
|
/** WorldMatrix | WorldPosition */ TransformModifyFlags[TransformModifyFlags["WmWp"] = 132] = "WmWp";
|
|
6278
5965
|
/** WorldMatrix | WorldEuler | WorldQuat */ TransformModifyFlags[TransformModifyFlags["WmWeWq"] = 152] = "WmWeWq";
|
|
6279
|
-
/** WorldMatrix | WorldEuler | WorldQuat | WorldScale
|
|
5966
|
+
/** WorldMatrix | WorldEuler | WorldQuat | WorldScale*/ TransformModifyFlags[TransformModifyFlags["WmWeWqWs"] = 184] = "WmWeWqWs";
|
|
6280
5967
|
/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat */ TransformModifyFlags[TransformModifyFlags["WmWpWeWq"] = 156] = "WmWpWeWq";
|
|
6281
|
-
/** WorldMatrix | WorldScale
|
|
6282
|
-
/** WorldMatrix | WorldScale | WorldUniformScaling
|
|
6283
|
-
/** WorldMatrix | WorldPosition | WorldScale
|
|
6284
|
-
/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale
|
|
6285
|
-
/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldUniformScaling
|
|
6286
|
-
/** LocalQuat | LocalMatrix | WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldUniformScaling
|
|
5968
|
+
/** WorldMatrix | WorldScale */ TransformModifyFlags[TransformModifyFlags["WmWs"] = 160] = "WmWs";
|
|
5969
|
+
/** WorldMatrix | WorldScale | WorldUniformScaling */ TransformModifyFlags[TransformModifyFlags["WmWsWus"] = 416] = "WmWsWus";
|
|
5970
|
+
/** WorldMatrix | WorldPosition | WorldScale */ TransformModifyFlags[TransformModifyFlags["WmWpWs"] = 164] = "WmWpWs";
|
|
5971
|
+
/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale */ TransformModifyFlags[TransformModifyFlags["WmWpWeWqWs"] = 188] = "WmWpWeWqWs";
|
|
5972
|
+
/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldUniformScaling */ TransformModifyFlags[TransformModifyFlags["WmWpWeWqWsWus"] = 444] = "WmWpWeWqWsWus";
|
|
5973
|
+
/** LocalQuat | LocalMatrix | WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldUniformScaling */ TransformModifyFlags[TransformModifyFlags["LqLmWmWpWeWqWsWus"] = 510] = "LqLmWmWpWeWqWsWus";
|
|
6287
5974
|
return TransformModifyFlags;
|
|
6288
5975
|
}({});
|
|
6289
5976
|
|
|
@@ -6489,22 +6176,10 @@ function _construct(Parent, args, Class) {
|
|
|
6489
6176
|
_this = EngineObject.call(this, engine) || this, /** The layer the entity belongs to. */ _this.layer = Layer.Layer0, /** @internal */ _this._isActiveInHierarchy = false, /** @internal */ _this._isActiveInScene = false, /** @internal */ _this._components = [], /** @internal */ _this._scripts = new DisorderedArray(), /** @internal */ _this._scriptsVersion = 0, /** @internal */ _this._children = [], /** @internal */ _this._isRoot = false, /** @internal */ _this._isActive = true, /** @internal */ _this._siblingIndex = -1, /** @internal */ _this._isTemplate = false, /** @internal */ _this._updateFlagManager = new UpdateFlagManager(), _this._parent = null, //--------------------------------------------------------------deprecated----------------------------------------------------------------
|
|
6490
6177
|
_this._invModelMatrix = new engineMath.Matrix();
|
|
6491
6178
|
_this.name = name != null ? name : "Entity";
|
|
6492
|
-
var
|
|
6493
|
-
|
|
6494
|
-
for(var i = n - 1; i >= 0; i--){
|
|
6495
|
-
var componentType = components[i];
|
|
6496
|
-
if (Entity._isTransformType(componentType)) {
|
|
6497
|
-
transformType = componentType;
|
|
6498
|
-
break;
|
|
6499
|
-
}
|
|
6500
|
-
}
|
|
6501
|
-
_this._transform = _this.addComponent(transformType);
|
|
6502
|
-
for(var i1 = 0; i1 < n; i1++){
|
|
6503
|
-
var componentType1 = components[i1];
|
|
6504
|
-
if (!Entity._isTransformType(componentType1)) {
|
|
6505
|
-
_this.addComponent(componentType1);
|
|
6506
|
-
}
|
|
6179
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
6180
|
+
_this.addComponent(components[i]);
|
|
6507
6181
|
}
|
|
6182
|
+
!_this._transform && _this.addComponent(Transform);
|
|
6508
6183
|
_this._inverseWorldMatFlag = _this.registerWorldChangeFlag();
|
|
6509
6184
|
return _this;
|
|
6510
6185
|
}
|
|
@@ -6518,19 +6193,13 @@ function _construct(Parent, args, Class) {
|
|
|
6518
6193
|
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
6519
6194
|
args[_key - 1] = arguments[_key];
|
|
6520
6195
|
}
|
|
6521
|
-
var needReplaceTransform = Entity._isTransformType(type) && this._transform;
|
|
6522
|
-
if (needReplaceTransform) {
|
|
6523
|
-
ComponentsDependencies._removeCheck(this, this._transform.constructor, type);
|
|
6524
|
-
}
|
|
6525
6196
|
ComponentsDependencies._addCheck(this, type);
|
|
6526
6197
|
var component = _construct(type, [].concat([
|
|
6527
6198
|
this
|
|
6528
6199
|
], args));
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
this._components.push(component);
|
|
6533
|
-
}
|
|
6200
|
+
this._components.push(component);
|
|
6201
|
+
// @todo: temporary solution
|
|
6202
|
+
if (_instanceof(component, Transform)) this._setTransform(component);
|
|
6534
6203
|
component._setActive(true, ActiveChangeFlag.All);
|
|
6535
6204
|
return component;
|
|
6536
6205
|
};
|
|
@@ -6643,9 +6312,16 @@ function _construct(Parent, args, Class) {
|
|
|
6643
6312
|
* Clear children entities.
|
|
6644
6313
|
*/ _proto.clearChildren = function clearChildren() {
|
|
6645
6314
|
var children = this._children;
|
|
6646
|
-
|
|
6647
|
-
children[
|
|
6315
|
+
for(var i = children.length - 1; i >= 0; i--){
|
|
6316
|
+
var child = children[i];
|
|
6317
|
+
child._parent = null;
|
|
6318
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
6319
|
+
child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
6320
|
+
child._isActiveInScene && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
6321
|
+
activeChangeFlag && child._processInActive(activeChangeFlag);
|
|
6322
|
+
Entity._traverseSetOwnerScene(child, null); // Must after child._processInActive().
|
|
6648
6323
|
}
|
|
6324
|
+
children.length = 0;
|
|
6649
6325
|
};
|
|
6650
6326
|
/**
|
|
6651
6327
|
* Clone this entity include children and components.
|
|
@@ -6738,13 +6414,9 @@ function _construct(Parent, args, Class) {
|
|
|
6738
6414
|
/**
|
|
6739
6415
|
* @internal
|
|
6740
6416
|
*/ _proto._removeComponent = function _removeComponent(component) {
|
|
6741
|
-
var components = this._components;
|
|
6742
|
-
var index = components.indexOf(component);
|
|
6743
|
-
// A replaced Transform is detached from the component slot immediately but
|
|
6744
|
-
// can still reach here later because object destruction may be deferred.
|
|
6745
|
-
if (index < 0) return;
|
|
6746
6417
|
ComponentsDependencies._removeCheck(this, component.constructor);
|
|
6747
|
-
components.
|
|
6418
|
+
var components = this._components;
|
|
6419
|
+
components.splice(components.indexOf(component), 1);
|
|
6748
6420
|
};
|
|
6749
6421
|
/**
|
|
6750
6422
|
* @internal
|
|
@@ -6946,18 +6618,10 @@ function _construct(Parent, args, Class) {
|
|
|
6946
6618
|
}
|
|
6947
6619
|
}
|
|
6948
6620
|
};
|
|
6949
|
-
_proto.
|
|
6950
|
-
var
|
|
6951
|
-
|
|
6952
|
-
value.rotationQuaternion.copyFrom(previous.rotationQuaternion);
|
|
6953
|
-
value.scale.copyFrom(previous.scale);
|
|
6954
|
-
// Keep the unique Transform in the same component slot. Detach the old
|
|
6955
|
-
// instance before destroy because destroy can be deferred during a frame.
|
|
6956
|
-
var components = this._components;
|
|
6957
|
-
var previousIndex = components.indexOf(previous);
|
|
6958
|
-
components[previousIndex] = value;
|
|
6621
|
+
_proto._setTransform = function _setTransform(value) {
|
|
6622
|
+
var _this__transform;
|
|
6623
|
+
(_this__transform = this._transform) == null ? void 0 : _this__transform.destroy();
|
|
6959
6624
|
this._transform = value;
|
|
6960
|
-
previous.destroy();
|
|
6961
6625
|
var children = this._children;
|
|
6962
6626
|
for(var i = 0, n = children.length; i < n; i++){
|
|
6963
6627
|
var _children_i_transform;
|
|
@@ -6973,9 +6637,6 @@ function _construct(Parent, args, Class) {
|
|
|
6973
6637
|
}
|
|
6974
6638
|
return this._invModelMatrix;
|
|
6975
6639
|
};
|
|
6976
|
-
Entity._isTransformType = function _isTransformType(type) {
|
|
6977
|
-
return type === Transform || _instanceof(type.prototype, Transform);
|
|
6978
|
-
};
|
|
6979
6640
|
/**
|
|
6980
6641
|
* @internal
|
|
6981
6642
|
*/ Entity._findChildByName = function _findChildByName(entity, childIndex, paths, pathIndex) {
|
|
@@ -7124,14 +6785,15 @@ function _construct(Parent, args, Class) {
|
|
|
7124
6785
|
return this._siblingIndex;
|
|
7125
6786
|
},
|
|
7126
6787
|
set: function set(value) {
|
|
6788
|
+
if (this._siblingIndex === -1) {
|
|
6789
|
+
throw "The entity " + this.name + " is not in the hierarchy";
|
|
6790
|
+
}
|
|
7127
6791
|
if (this._isRoot) {
|
|
7128
6792
|
this._setSiblingIndex(this._scene._rootEntities, value);
|
|
7129
|
-
} else
|
|
6793
|
+
} else {
|
|
7130
6794
|
var parent = this._parent;
|
|
7131
6795
|
this._setSiblingIndex(parent._children, value);
|
|
7132
6796
|
parent._dispatchModify(EntityModifyFlags.Child, parent);
|
|
7133
|
-
} else {
|
|
7134
|
-
Logger.warn("The entity " + this.name + " is not in the hierarchy");
|
|
7135
6797
|
}
|
|
7136
6798
|
}
|
|
7137
6799
|
}
|
|
@@ -7726,7 +7388,7 @@ exports.Renderer = /*#__PURE__*/ function(Component) {
|
|
|
7726
7388
|
_inherits(Renderer, Component);
|
|
7727
7389
|
function Renderer(entity) {
|
|
7728
7390
|
var _this;
|
|
7729
|
-
_this = Component.call(this, entity) || this, /** @internal */ _this._onUpdateIndex = -1, /** @internal */ _this._rendererIndex = -1, /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection(), _this._maskInteraction = SpriteMaskInteraction.None, _this._maskLayer = SpriteMaskLayer.Layer0, _this._overrideUpdate = false, _this._materials = [], _this._dirtyUpdateFlag = 0, _this._rendererLayer = new engineMath.Vector4(), _this._bounds = new engineMath.BoundingBox(), _this._shaderData = new ShaderData(ShaderDataGroup.Renderer), _this._mvMatrix = new engineMath.Matrix(), _this._mvpMatrix = new engineMath.Matrix(), _this._normalMatrix = new engineMath.Matrix(), _this._materialsInstanced = [], _this._priority = 0, _this._receiveShadows = true, /** Whether cast shadow. */ _this.castShadows = true;
|
|
7391
|
+
_this = Component.call(this, entity) || this, /** @internal */ _this._onUpdateIndex = -1, /** @internal */ _this._rendererIndex = -1, /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection(), /** @internal */ _this._maskInteraction = SpriteMaskInteraction.None, _this._maskLayer = SpriteMaskLayer.Layer0, _this._overrideUpdate = false, _this._materials = [], _this._dirtyUpdateFlag = 0, _this._rendererLayer = new engineMath.Vector4(), _this._bounds = new engineMath.BoundingBox(), _this._shaderData = new ShaderData(ShaderDataGroup.Renderer), _this._mvMatrix = new engineMath.Matrix(), _this._mvpMatrix = new engineMath.Matrix(), _this._normalMatrix = new engineMath.Matrix(), _this._materialsInstanced = [], _this._priority = 0, _this._receiveShadows = true, /** Whether cast shadow. */ _this.castShadows = true;
|
|
7730
7392
|
var prototype = Renderer.prototype;
|
|
7731
7393
|
var shaderData = _this.shaderData;
|
|
7732
7394
|
_this._overrideUpdate = _this.update !== prototype.update;
|
|
@@ -8270,15 +7932,10 @@ ShaderBlockProperty._nameMap = Object.create(null);
|
|
|
8270
7932
|
* names resolve to `rendererData[instanceID].field`.
|
|
8271
7933
|
*
|
|
8272
7934
|
* Inputs are expected to be already preprocessor-evaluated (no `#ifdef` left).
|
|
8273
|
-
*/ ShaderFactory.injectInstanceUBO = function injectInstanceUBO(engine, vertexSource, fragmentSource
|
|
7935
|
+
*/ ShaderFactory.injectInstanceUBO = function injectInstanceUBO(engine, vertexSource, fragmentSource) {
|
|
8274
7936
|
var fieldMap = Object.create(null);
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
fragmentSource = ShaderFactory._scanInstanceUniformsWithMacros(fragmentSource, fieldMap, activeMacros);
|
|
8278
|
-
} else {
|
|
8279
|
-
vertexSource = ShaderFactory._scanInstanceUniforms(vertexSource, fieldMap);
|
|
8280
|
-
fragmentSource = ShaderFactory._scanInstanceUniforms(fragmentSource, fieldMap);
|
|
8281
|
-
}
|
|
7937
|
+
vertexSource = ShaderFactory._scanInstanceUniforms(vertexSource, fieldMap);
|
|
7938
|
+
fragmentSource = ShaderFactory._scanInstanceUniforms(fragmentSource, fieldMap);
|
|
8282
7939
|
// Even when fieldMap is empty, derived built-ins (e.g. `renderer_MVPMat`) may have
|
|
8283
7940
|
// had their declarations stripped by scan and still need a `#define` to compile
|
|
8284
7941
|
var instanceLayout = ShaderFactory._buildLayout(engine, fieldMap);
|
|
@@ -8322,47 +7979,6 @@ ShaderBlockProperty._nameMap = Object.create(null);
|
|
|
8322
7979
|
return "";
|
|
8323
7980
|
});
|
|
8324
7981
|
};
|
|
8325
|
-
/**
|
|
8326
|
-
* Scan raw GLSL while respecting simple conditional-compilation branches so renderer uniforms
|
|
8327
|
-
* in inactive branches are not moved into the instance UBO.
|
|
8328
|
-
*/ ShaderFactory._scanInstanceUniformsWithMacros = function _scanInstanceUniformsWithMacros(source, fieldMap, activeMacros) {
|
|
8329
|
-
var branchStack = [
|
|
8330
|
-
true
|
|
8331
|
-
];
|
|
8332
|
-
var lines = source.split("\n");
|
|
8333
|
-
for(var i = 0, n = lines.length; i < n; i++){
|
|
8334
|
-
var line = lines[i];
|
|
8335
|
-
var match = line.match(ShaderFactory._ifdefRegex);
|
|
8336
|
-
if (match) {
|
|
8337
|
-
var parentActive = branchStack[branchStack.length - 1];
|
|
8338
|
-
branchStack.push(parentActive && activeMacros.has(match[1]));
|
|
8339
|
-
continue;
|
|
8340
|
-
}
|
|
8341
|
-
match = line.match(ShaderFactory._ifndefRegex);
|
|
8342
|
-
if (match) {
|
|
8343
|
-
var parentActive1 = branchStack[branchStack.length - 1];
|
|
8344
|
-
branchStack.push(parentActive1 && !activeMacros.has(match[1]));
|
|
8345
|
-
continue;
|
|
8346
|
-
}
|
|
8347
|
-
if (ShaderFactory._elseRegex.test(line)) {
|
|
8348
|
-
if (branchStack.length > 1) {
|
|
8349
|
-
var parentActive2 = branchStack[branchStack.length - 2];
|
|
8350
|
-
branchStack[branchStack.length - 1] = parentActive2 && !branchStack[branchStack.length - 1];
|
|
8351
|
-
}
|
|
8352
|
-
continue;
|
|
8353
|
-
}
|
|
8354
|
-
if (ShaderFactory._endifRegex.test(line)) {
|
|
8355
|
-
if (branchStack.length > 1) {
|
|
8356
|
-
branchStack.pop();
|
|
8357
|
-
}
|
|
8358
|
-
continue;
|
|
8359
|
-
}
|
|
8360
|
-
if (branchStack[branchStack.length - 1]) {
|
|
8361
|
-
lines[i] = ShaderFactory._scanInstanceUniforms(line, fieldMap);
|
|
8362
|
-
}
|
|
8363
|
-
}
|
|
8364
|
-
return lines.join("\n");
|
|
8365
|
-
};
|
|
8366
7982
|
ShaderFactory._buildLayout = function _buildLayout(engine, fieldMap) {
|
|
8367
7983
|
var maxUBOSize = engine._hardwareRenderer.maxUniformBlockSize;
|
|
8368
7984
|
var std140Map = ShaderFactory._std140TypeInfoMap;
|
|
@@ -8619,10 +8235,6 @@ ShaderFactory._packFuncMap = function() {
|
|
|
8619
8235
|
}
|
|
8620
8236
|
};
|
|
8621
8237
|
}();
|
|
8622
|
-
ShaderFactory._ifdefRegex = /^[ \t]*#ifdef\s+(\w+)/;
|
|
8623
|
-
ShaderFactory._ifndefRegex = /^[ \t]*#ifndef\s+(\w+)/;
|
|
8624
|
-
ShaderFactory._elseRegex = /^[ \t]*#else\b/;
|
|
8625
|
-
ShaderFactory._endifRegex = /^[ \t]*#endif\b/;
|
|
8626
8238
|
|
|
8627
8239
|
/**
|
|
8628
8240
|
* Shader tag key.
|
|
@@ -10436,20 +10048,17 @@ var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision hig
|
|
|
10436
10048
|
shaderMacroList.push(ShaderMacro.getByName("HAS_DERIVATIVES"));
|
|
10437
10049
|
}
|
|
10438
10050
|
var macroMap = ShaderPass._macroMap;
|
|
10439
|
-
var activeMacroSet = ShaderPass._activeMacroSet;
|
|
10440
10051
|
macroMap.clear();
|
|
10441
|
-
activeMacroSet.clear();
|
|
10442
10052
|
for(var i = 0, n = shaderMacroList.length; i < n; i++){
|
|
10443
10053
|
var macro = shaderMacroList[i];
|
|
10444
10054
|
var _macro_value;
|
|
10445
10055
|
macroMap.set(macro.name, (_macro_value = macro.value) != null ? _macro_value : "");
|
|
10446
|
-
activeMacroSet.add(macro.name);
|
|
10447
10056
|
}
|
|
10448
10057
|
var vertexSource = ShaderMacroProcessor.evaluate(this._vertexShaderInstructions, macroMap);
|
|
10449
10058
|
var fragmentSource = ShaderMacroProcessor.evaluate(this._fragmentShaderInstructions, macroMap);
|
|
10450
10059
|
var instanceLayout = null;
|
|
10451
10060
|
if (isGPUInstance) {
|
|
10452
|
-
var injected = ShaderFactory.injectInstanceUBO(engine, vertexSource, fragmentSource
|
|
10061
|
+
var injected = ShaderFactory.injectInstanceUBO(engine, vertexSource, fragmentSource);
|
|
10453
10062
|
vertexSource = injected.vertexSource;
|
|
10454
10063
|
fragmentSource = injected.fragmentSource;
|
|
10455
10064
|
instanceLayout = injected.instanceLayout;
|
|
@@ -10471,7 +10080,6 @@ var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision hig
|
|
|
10471
10080
|
/** @internal */ ShaderPass._shaderRootPath = "shaders://root/";
|
|
10472
10081
|
ShaderPass._shaderMacroList = [];
|
|
10473
10082
|
ShaderPass._macroMap = new Map();
|
|
10474
|
-
ShaderPass._activeMacroSet = new Set();
|
|
10475
10083
|
|
|
10476
10084
|
/**
|
|
10477
10085
|
* Sub shader.
|
|
@@ -10803,917 +10411,147 @@ ShaderPass._activeMacroSet = new Set();
|
|
|
10803
10411
|
break;
|
|
10804
10412
|
case RenderStateElementKey.RenderQueueType:
|
|
10805
10413
|
renderState.renderQueueType = value;
|
|
10806
|
-
break;
|
|
10807
|
-
}
|
|
10808
|
-
};
|
|
10809
|
-
Shader.getMacroByName = function getMacroByName(name, value) {
|
|
10810
|
-
return ShaderMacro.getByName(name, value);
|
|
10811
|
-
};
|
|
10812
|
-
/**
|
|
10813
|
-
* @deprecated Please use `ShaderProperty.getByName` instead
|
|
10814
|
-
*
|
|
10815
|
-
* Get shader property by name.
|
|
10816
|
-
* @param name - Name of the shader property
|
|
10817
|
-
* @returns Shader property
|
|
10818
|
-
*/ Shader.getPropertyByName = function getPropertyByName(name) {
|
|
10819
|
-
return ShaderProperty.getByName(name);
|
|
10820
|
-
};
|
|
10821
|
-
_create_class(Shader, [
|
|
10822
|
-
{
|
|
10823
|
-
key: "subShaders",
|
|
10824
|
-
get: /**
|
|
10825
|
-
* Sub shaders of the shader.
|
|
10826
|
-
*/ function get() {
|
|
10827
|
-
return this._subShaders;
|
|
10828
|
-
}
|
|
10829
|
-
},
|
|
10830
|
-
{
|
|
10831
|
-
key: "destroyed",
|
|
10832
|
-
get: /**
|
|
10833
|
-
* Whether it has been destroyed.
|
|
10834
|
-
*/ function get() {
|
|
10835
|
-
return this._destroyed;
|
|
10836
|
-
}
|
|
10837
|
-
}
|
|
10838
|
-
]);
|
|
10839
|
-
return Shader;
|
|
10840
|
-
}();
|
|
10841
|
-
/** @internal */ Shader._compileMacros = new ShaderMacroCollection();
|
|
10842
|
-
Shader._shaderMap = Object.create(null);
|
|
10843
|
-
|
|
10844
|
-
/**
|
|
10845
|
-
* @internal
|
|
10846
|
-
*/ var VertexMergeBatcher = /*#__PURE__*/ function() {
|
|
10847
|
-
function VertexMergeBatcher() {}
|
|
10848
|
-
VertexMergeBatcher.canBatchSprite = function canBatchSprite(preElement, curElement) {
|
|
10849
|
-
var preRenderer = preElement.component;
|
|
10850
|
-
var renderer = curElement.component;
|
|
10851
|
-
var maskInteraction = preRenderer.maskInteraction;
|
|
10852
|
-
var preRendererAny = preRenderer;
|
|
10853
|
-
var curRendererAny = renderer;
|
|
10854
|
-
var rectMaskEnabledA = preRendererAny._rectMaskEnabled;
|
|
10855
|
-
if (rectMaskEnabledA !== curRendererAny._rectMaskEnabled) {
|
|
10856
|
-
return false;
|
|
10857
|
-
}
|
|
10858
|
-
if (rectMaskEnabledA) {
|
|
10859
|
-
var rectMaskRectA = preRendererAny._rectMaskRect;
|
|
10860
|
-
var rectMaskRectB = curRendererAny._rectMaskRect;
|
|
10861
|
-
var rectMaskSoftnessA = preRendererAny._rectMaskSoftness;
|
|
10862
|
-
var rectMaskSoftnessB = curRendererAny._rectMaskSoftness;
|
|
10863
|
-
if (!rectMaskRectA || !rectMaskRectB || !rectMaskSoftnessA || !rectMaskSoftnessB || rectMaskRectA.x !== rectMaskRectB.x || rectMaskRectA.y !== rectMaskRectB.y || rectMaskRectA.z !== rectMaskRectB.z || rectMaskRectA.w !== rectMaskRectB.w || rectMaskSoftnessA.x !== rectMaskSoftnessB.x || rectMaskSoftnessA.y !== rectMaskSoftnessB.y || rectMaskSoftnessA.z !== rectMaskSoftnessB.z || rectMaskSoftnessA.w !== rectMaskSoftnessB.w || preRendererAny._rectMaskHardClip !== curRendererAny._rectMaskHardClip) {
|
|
10864
|
-
return false;
|
|
10865
|
-
}
|
|
10866
|
-
}
|
|
10867
|
-
// Order: cheap reference checks → mask state → tag lookup (rare opt-out)
|
|
10868
|
-
return preElement.subChunk.chunk === curElement.subChunk.chunk && preElement.texture === curElement.texture && preElement.material === curElement.material && maskInteraction === renderer.maskInteraction && (maskInteraction === SpriteMaskInteraction.None || preRenderer.maskLayer === renderer.maskLayer) && curElement.subShader.passes[0].getTagValue(VertexMergeBatcher._disableBatchTag) !== true;
|
|
10869
|
-
};
|
|
10870
|
-
/**
|
|
10871
|
-
* Text-specific batch check: extends sprite check with outline parity.
|
|
10872
|
-
* Different outlineWidth or outlineColor must split into separate draw calls,
|
|
10873
|
-
* because outline uniforms are shared per draw call.
|
|
10874
|
-
*/ VertexMergeBatcher.canBatchText = function canBatchText(preElement, curElement) {
|
|
10875
|
-
if (!VertexMergeBatcher.canBatchSprite(preElement, curElement)) {
|
|
10876
|
-
return false;
|
|
10877
|
-
}
|
|
10878
|
-
var preRendererAny = preElement.component;
|
|
10879
|
-
var curRendererAny = curElement.component;
|
|
10880
|
-
if (preRendererAny._outlineWidth !== curRendererAny._outlineWidth) {
|
|
10881
|
-
return false;
|
|
10882
|
-
}
|
|
10883
|
-
if (preRendererAny._outlineWidth > 0) {
|
|
10884
|
-
var a = preRendererAny._outlineColor;
|
|
10885
|
-
var b = curRendererAny._outlineColor;
|
|
10886
|
-
if (a.r !== b.r || a.g !== b.g || a.b !== b.b || a.a !== b.a) {
|
|
10887
|
-
return false;
|
|
10888
|
-
}
|
|
10889
|
-
}
|
|
10890
|
-
return true;
|
|
10891
|
-
};
|
|
10892
|
-
VertexMergeBatcher.canBatchSpriteMask = function canBatchSpriteMask(preElement, curElement) {
|
|
10893
|
-
if (preElement.subChunk.chunk !== curElement.subChunk.chunk) {
|
|
10894
|
-
return false;
|
|
10895
|
-
}
|
|
10896
|
-
var alphaCutoffProperty = SpriteMask._alphaCutoffProperty;
|
|
10897
|
-
// Compare renderer property
|
|
10898
|
-
return preElement.texture === curElement.texture && preElement.component.shaderData.getFloat(alphaCutoffProperty) === curElement.component.shaderData.getFloat(alphaCutoffProperty);
|
|
10899
|
-
};
|
|
10900
|
-
VertexMergeBatcher.batch = function batch(preElement, curElement) {
|
|
10901
|
-
var subChunk = curElement.subChunk;
|
|
10902
|
-
var chunk = subChunk.chunk, localIndices = subChunk.indices;
|
|
10903
|
-
var length = localIndices.length;
|
|
10904
|
-
if (preElement) {
|
|
10905
|
-
preElement.subChunk.subMesh.count += length;
|
|
10906
|
-
} else {
|
|
10907
|
-
// First write this frame — init subMesh range
|
|
10908
|
-
subChunk.subMesh.start = chunk.updateIndexLength;
|
|
10909
|
-
subChunk.subMesh.count = length;
|
|
10910
|
-
}
|
|
10911
|
-
var startIndex = chunk.updateIndexLength;
|
|
10912
|
-
var _subChunk_vertexArea = subChunk.vertexArea, start = _subChunk_vertexArea.start, size = _subChunk_vertexArea.size;
|
|
10913
|
-
// PrimitiveChunk vertex layout: pos(3) + uv(2) + color(4) = 9 floats per vertex
|
|
10914
|
-
var vertexOffset = start / 9;
|
|
10915
|
-
var indices = chunk.indices;
|
|
10916
|
-
for(var i = 0; i < length; ++i){
|
|
10917
|
-
indices[startIndex++] = vertexOffset + localIndices[i];
|
|
10918
|
-
}
|
|
10919
|
-
chunk.updateIndexLength += length;
|
|
10920
|
-
chunk.updateVertexStart = Math.min(chunk.updateVertexStart, start);
|
|
10921
|
-
chunk.updateVertexEnd = Math.max(chunk.updateVertexEnd, start + size);
|
|
10922
|
-
};
|
|
10923
|
-
return VertexMergeBatcher;
|
|
10924
|
-
}();
|
|
10925
|
-
VertexMergeBatcher._disableBatchTag = ShaderTagKey.getByName("spriteDisableBatching");
|
|
10926
|
-
|
|
10927
|
-
/**
|
|
10928
|
-
* Internal helpers for sprite mask hit testing.
|
|
10929
|
-
* @internal
|
|
10930
|
-
*/ var SpriteMaskUtils = /*#__PURE__*/ function() {
|
|
10931
|
-
function SpriteMaskUtils() {}
|
|
10932
|
-
SpriteMaskUtils.containsWorldPoint = function containsWorldPoint(worldPoint, sprite, worldMatrix, width, height, pivot, flipX, flipY, alphaCutoff) {
|
|
10933
|
-
if (alphaCutoff === void 0) alphaCutoff = 0;
|
|
10934
|
-
if (!sprite || !width || !height) {
|
|
10935
|
-
return false;
|
|
10936
|
-
}
|
|
10937
|
-
var worldMatrixInv = SpriteMaskUtils._tempMat;
|
|
10938
|
-
engineMath.Matrix.invert(worldMatrix, worldMatrixInv);
|
|
10939
|
-
var localPosition = SpriteMaskUtils._tempVec3;
|
|
10940
|
-
engineMath.Vector3.transformCoordinate(worldPoint, worldMatrixInv, localPosition);
|
|
10941
|
-
var sx = flipX ? -width : width;
|
|
10942
|
-
var sy = flipY ? -height : height;
|
|
10943
|
-
if (!sx || !sy) {
|
|
10944
|
-
return false;
|
|
10945
|
-
}
|
|
10946
|
-
var spriteX = localPosition.x / sx + pivot.x;
|
|
10947
|
-
var spriteY = localPosition.y / sy + pivot.y;
|
|
10948
|
-
var spritePositions = sprite._getPositions();
|
|
10949
|
-
var _spritePositions_ = spritePositions[0], left = _spritePositions_.x, bottom = _spritePositions_.y;
|
|
10950
|
-
var _spritePositions_1 = spritePositions[3], right = _spritePositions_1.x, top = _spritePositions_1.y;
|
|
10951
|
-
if (!(spriteX >= left && spriteX <= right && spriteY >= bottom && spriteY <= top)) {
|
|
10952
|
-
return false;
|
|
10953
|
-
}
|
|
10954
|
-
if (alphaCutoff <= 0) {
|
|
10955
|
-
return true;
|
|
10956
|
-
}
|
|
10957
|
-
var texture = sprite.texture;
|
|
10958
|
-
if (!texture) {
|
|
10959
|
-
return false;
|
|
10960
|
-
}
|
|
10961
|
-
var spriteUVs = sprite._getUVs();
|
|
10962
|
-
var leftU = spriteUVs[0].x;
|
|
10963
|
-
var bottomV = spriteUVs[0].y;
|
|
10964
|
-
var rightU = spriteUVs[3].x;
|
|
10965
|
-
var topV = spriteUVs[3].y;
|
|
10966
|
-
var positionWidth = right - left;
|
|
10967
|
-
var positionHeight = top - bottom;
|
|
10968
|
-
if (!positionWidth || !positionHeight) {
|
|
10969
|
-
return false;
|
|
10970
|
-
}
|
|
10971
|
-
var tx = (spriteX - left) / positionWidth;
|
|
10972
|
-
var ty = (spriteY - bottom) / positionHeight;
|
|
10973
|
-
var u = leftU + (rightU - leftU) * tx;
|
|
10974
|
-
var v = bottomV + (topV - bottomV) * ty;
|
|
10975
|
-
var x = Math.min(Math.max(Math.floor(u * texture.width), 0), texture.width - 1);
|
|
10976
|
-
var y = Math.min(Math.max(Math.floor(v * texture.height), 0), texture.height - 1);
|
|
10977
|
-
return SpriteMaskUtils._sampleTextureAlpha(texture, x, y) >= alphaCutoff;
|
|
10978
|
-
};
|
|
10979
|
-
SpriteMaskUtils._sampleTextureAlpha = function _sampleTextureAlpha(texture, x, y) {
|
|
10980
|
-
try {
|
|
10981
|
-
switch(texture.format){
|
|
10982
|
-
case TextureFormat.R8G8B8A8:
|
|
10983
|
-
{
|
|
10984
|
-
var buffer = SpriteMaskUtils._u8Buffer4;
|
|
10985
|
-
texture.getPixelBuffer(x, y, 1, 1, buffer);
|
|
10986
|
-
return buffer[3] / 255;
|
|
10987
|
-
}
|
|
10988
|
-
case TextureFormat.R4G4B4A4:
|
|
10989
|
-
{
|
|
10990
|
-
var buffer1 = SpriteMaskUtils._u16Buffer1;
|
|
10991
|
-
texture.getPixelBuffer(x, y, 1, 1, buffer1);
|
|
10992
|
-
return (buffer1[0] & 0xf) / 15;
|
|
10993
|
-
}
|
|
10994
|
-
case TextureFormat.R5G5B5A1:
|
|
10995
|
-
{
|
|
10996
|
-
var buffer2 = SpriteMaskUtils._u16Buffer1;
|
|
10997
|
-
texture.getPixelBuffer(x, y, 1, 1, buffer2);
|
|
10998
|
-
return buffer2[0] & 0x1;
|
|
10999
|
-
}
|
|
11000
|
-
case TextureFormat.Alpha8:
|
|
11001
|
-
case TextureFormat.R8:
|
|
11002
|
-
{
|
|
11003
|
-
var buffer3 = SpriteMaskUtils._u8Buffer1;
|
|
11004
|
-
texture.getPixelBuffer(x, y, 1, 1, buffer3);
|
|
11005
|
-
return buffer3[0] / 255;
|
|
11006
|
-
}
|
|
11007
|
-
case TextureFormat.LuminanceAlpha:
|
|
11008
|
-
case TextureFormat.R8G8:
|
|
11009
|
-
{
|
|
11010
|
-
var buffer4 = SpriteMaskUtils._u8Buffer2;
|
|
11011
|
-
texture.getPixelBuffer(x, y, 1, 1, buffer4);
|
|
11012
|
-
return buffer4[1] / 255;
|
|
11013
|
-
}
|
|
11014
|
-
case TextureFormat.R16G16B16A16:
|
|
11015
|
-
{
|
|
11016
|
-
var buffer5 = SpriteMaskUtils._u16Buffer4;
|
|
11017
|
-
texture.getPixelBuffer(x, y, 1, 1, buffer5);
|
|
11018
|
-
return buffer5[3] / 65535;
|
|
11019
|
-
}
|
|
11020
|
-
case TextureFormat.R32G32B32A32:
|
|
11021
|
-
{
|
|
11022
|
-
var buffer6 = SpriteMaskUtils._f32Buffer4;
|
|
11023
|
-
texture.getPixelBuffer(x, y, 1, 1, buffer6);
|
|
11024
|
-
return buffer6[3];
|
|
11025
|
-
}
|
|
11026
|
-
case TextureFormat.R32G32B32A32_UInt:
|
|
11027
|
-
{
|
|
11028
|
-
var buffer7 = SpriteMaskUtils._u32Buffer4;
|
|
11029
|
-
texture.getPixelBuffer(x, y, 1, 1, buffer7);
|
|
11030
|
-
return buffer7[3] / 4294967295;
|
|
11031
|
-
}
|
|
11032
|
-
default:
|
|
11033
|
-
return 1;
|
|
11034
|
-
}
|
|
11035
|
-
} catch (e) {
|
|
11036
|
-
return 1;
|
|
11037
|
-
}
|
|
11038
|
-
};
|
|
11039
|
-
return SpriteMaskUtils;
|
|
11040
|
-
}();
|
|
11041
|
-
SpriteMaskUtils._tempMat = new engineMath.Matrix();
|
|
11042
|
-
SpriteMaskUtils._tempVec3 = new engineMath.Vector3();
|
|
11043
|
-
SpriteMaskUtils._u8Buffer1 = new Uint8Array(1);
|
|
11044
|
-
SpriteMaskUtils._u8Buffer2 = new Uint8Array(2);
|
|
11045
|
-
SpriteMaskUtils._u8Buffer4 = new Uint8Array(4);
|
|
11046
|
-
SpriteMaskUtils._u16Buffer1 = new Uint16Array(1);
|
|
11047
|
-
SpriteMaskUtils._u16Buffer4 = new Uint16Array(4);
|
|
11048
|
-
SpriteMaskUtils._f32Buffer4 = new Float32Array(4);
|
|
11049
|
-
SpriteMaskUtils._u32Buffer4 = new Uint32Array(4);
|
|
11050
|
-
|
|
11051
|
-
/**
|
|
11052
|
-
* Mixin that provides shared mask rendering logic for both 2D SpriteMask and UI Mask.
|
|
11053
|
-
*/ function MaskRenderable(Base) {
|
|
11054
|
-
var MaskRenderableBase = /*#__PURE__*/ function(Base) {
|
|
11055
|
-
_inherits(MaskRenderableBase, Base);
|
|
11056
|
-
function MaskRenderableBase() {
|
|
11057
|
-
var _this;
|
|
11058
|
-
_this = Base.apply(this, arguments) || this, _this._influenceLayers = SpriteMaskLayer.Everything, /** @internal */ _this._maskIndex = -1, _this._sprite = null, _this._flipX = false, _this._flipY = false, _this._alphaCutoff = 0.5;
|
|
11059
|
-
return _this;
|
|
11060
|
-
}
|
|
11061
|
-
var _proto = MaskRenderableBase.prototype;
|
|
11062
|
-
/**
|
|
11063
|
-
* @internal
|
|
11064
|
-
*/ // @ts-ignore
|
|
11065
|
-
_proto._canBatch = function _canBatch(preElement, curElement) {
|
|
11066
|
-
return VertexMergeBatcher.canBatchSpriteMask(preElement, curElement);
|
|
11067
|
-
};
|
|
11068
|
-
/**
|
|
11069
|
-
* @internal
|
|
11070
|
-
*/ // @ts-ignore
|
|
11071
|
-
_proto._batch = function _batch(preElement, curElement) {
|
|
11072
|
-
VertexMergeBatcher.batch(preElement, curElement);
|
|
11073
|
-
};
|
|
11074
|
-
/**
|
|
11075
|
-
* @internal
|
|
11076
|
-
*/ // @ts-ignore
|
|
11077
|
-
_proto._onEnableInScene = function _onEnableInScene() {
|
|
11078
|
-
// @ts-ignore
|
|
11079
|
-
Base.prototype._onEnableInScene.call(this);
|
|
11080
|
-
// @ts-ignore
|
|
11081
|
-
this.scene._maskManager.addSpriteMask(this);
|
|
11082
|
-
};
|
|
11083
|
-
/**
|
|
11084
|
-
* @internal
|
|
11085
|
-
*/ // @ts-ignore
|
|
11086
|
-
_proto._onDisableInScene = function _onDisableInScene() {
|
|
11087
|
-
// @ts-ignore
|
|
11088
|
-
Base.prototype._onDisableInScene.call(this);
|
|
11089
|
-
// @ts-ignore
|
|
11090
|
-
this.scene._maskManager.removeSpriteMask(this);
|
|
11091
|
-
};
|
|
11092
|
-
/**
|
|
11093
|
-
* @internal
|
|
11094
|
-
*/ _proto._containsWorldPoint = function _containsWorldPoint(worldPoint) {
|
|
11095
|
-
return SpriteMaskUtils.containsWorldPoint(worldPoint, this._sprite, // @ts-ignore
|
|
11096
|
-
this._transformEntity.transform.worldMatrix, this._getSpriteWidth(), this._getSpriteHeight(), this._getSpritePivot(), this._flipX, this._flipY, this._alphaCutoff);
|
|
11097
|
-
};
|
|
11098
|
-
/**
|
|
11099
|
-
* @internal
|
|
11100
|
-
* Initialize shared mask resources. Must be called from subclass constructor.
|
|
11101
|
-
*/ _proto._initMask = function _initMask() {
|
|
11102
|
-
exports.SimpleSpriteAssembler.resetData(this);
|
|
11103
|
-
// @ts-ignore
|
|
11104
|
-
this.setMaterial(this._engine._basicResources.spriteMaskDefaultMaterial);
|
|
11105
|
-
// @ts-ignore
|
|
11106
|
-
this.shaderData.setFloat(MaskRenderableBase._alphaCutoffProperty, this._alphaCutoff);
|
|
11107
|
-
this._renderElement = new RenderElement();
|
|
11108
|
-
this._onSpriteChange = this._onSpriteChange.bind(this);
|
|
11109
|
-
};
|
|
11110
|
-
/**
|
|
11111
|
-
* @internal
|
|
11112
|
-
* Clone mask data to target. Called from subclass _onClone.
|
|
11113
|
-
*/ _proto._cloneMaskData = function _cloneMaskData(target) {
|
|
11114
|
-
target.sprite = this._sprite;
|
|
11115
|
-
};
|
|
11116
|
-
/**
|
|
11117
|
-
* @internal
|
|
11118
|
-
* Release mask sprite resources. Called from subclass _onDestroy.
|
|
11119
|
-
*/ _proto._destroyMaskResources = function _destroyMaskResources() {
|
|
11120
|
-
var sprite = this._sprite;
|
|
11121
|
-
if (sprite) {
|
|
11122
|
-
// @ts-ignore
|
|
11123
|
-
this._addResourceReferCount(sprite, -1);
|
|
11124
|
-
sprite._updateFlagManager.removeListener(this._onSpriteChange);
|
|
11125
|
-
}
|
|
11126
|
-
this._sprite = null;
|
|
11127
|
-
this._renderElement = null;
|
|
11128
|
-
};
|
|
11129
|
-
/**
|
|
11130
|
-
* @internal
|
|
11131
|
-
* Update bounds using SimpleSpriteAssembler directly.
|
|
11132
|
-
*/ _proto._updateMaskBounds = function _updateMaskBounds(worldBounds) {
|
|
11133
|
-
var sprite = this._sprite;
|
|
11134
|
-
if (sprite) {
|
|
11135
|
-
exports.SimpleSpriteAssembler.updatePositions(this, // @ts-ignore
|
|
11136
|
-
this._transformEntity.transform.worldMatrix, this._getSpriteWidth(), this._getSpriteHeight(), this._getSpritePivot(), this._flipX, this._flipY);
|
|
11137
|
-
} else {
|
|
11138
|
-
// @ts-ignore
|
|
11139
|
-
var worldPosition = this._transformEntity.transform.worldPosition;
|
|
11140
|
-
worldBounds.min.copyFrom(worldPosition);
|
|
11141
|
-
worldBounds.max.copyFrom(worldPosition);
|
|
11142
|
-
}
|
|
11143
|
-
};
|
|
11144
|
-
/**
|
|
11145
|
-
* @internal
|
|
11146
|
-
* Shared render logic for mask geometry.
|
|
11147
|
-
*/ _proto._renderMask = function _renderMask(distanceForSort) {
|
|
11148
|
-
var _this = this, sprite = _this._sprite;
|
|
11149
|
-
var width = this._getSpriteWidth();
|
|
11150
|
-
var height = this._getSpriteHeight();
|
|
11151
|
-
if (!(sprite == null ? void 0 : sprite.texture) || !width || !height) {
|
|
11152
|
-
return;
|
|
11153
|
-
}
|
|
11154
|
-
// @ts-ignore
|
|
11155
|
-
var material = this.getMaterial();
|
|
11156
|
-
if (!material) {
|
|
11157
|
-
return;
|
|
11158
|
-
}
|
|
11159
|
-
if (material.destroyed) {
|
|
11160
|
-
// @ts-ignore
|
|
11161
|
-
material = this._engine._basicResources.spriteMaskDefaultMaterial;
|
|
11162
|
-
}
|
|
11163
|
-
// Update position
|
|
11164
|
-
// @ts-ignore
|
|
11165
|
-
if (this._dirtyUpdateFlag & RendererUpdateFlags.WorldVolume) {
|
|
11166
|
-
exports.SimpleSpriteAssembler.updatePositions(this, // @ts-ignore
|
|
11167
|
-
this._transformEntity.transform.worldMatrix, width, height, this._getSpritePivot(), this._flipX, this._flipY);
|
|
11168
|
-
// @ts-ignore
|
|
11169
|
-
this._dirtyUpdateFlag &= ~RendererUpdateFlags.WorldVolume;
|
|
11170
|
-
}
|
|
11171
|
-
// Update uv
|
|
11172
|
-
// @ts-ignore
|
|
11173
|
-
if (this._dirtyUpdateFlag & 2) {
|
|
11174
|
-
exports.SimpleSpriteAssembler.updateUVs(this);
|
|
11175
|
-
// @ts-ignore
|
|
11176
|
-
this._dirtyUpdateFlag &= ~2;
|
|
11177
|
-
}
|
|
11178
|
-
var renderElement = this._renderElement;
|
|
11179
|
-
var subChunk = this._subChunk;
|
|
11180
|
-
// @ts-ignore
|
|
11181
|
-
renderElement.set(this, material, subChunk.chunk.primitive, subChunk.subMesh, sprite.texture, subChunk);
|
|
11182
|
-
// @ts-ignore
|
|
11183
|
-
renderElement.priority = this.priority;
|
|
11184
|
-
renderElement.distanceForSort = distanceForSort;
|
|
11185
|
-
renderElement.subShader = material.shader.subShaders[0];
|
|
11186
|
-
};
|
|
11187
|
-
/** @internal */ _proto._onSpriteChange = function _onSpriteChange(type) {
|
|
11188
|
-
switch(type){
|
|
11189
|
-
case SpriteModifyFlags.texture:
|
|
11190
|
-
// @ts-ignore
|
|
11191
|
-
this.shaderData.setTexture(MaskRenderableBase._maskTextureProperty, this.sprite.texture);
|
|
11192
|
-
break;
|
|
11193
|
-
case SpriteModifyFlags.region:
|
|
11194
|
-
case SpriteModifyFlags.atlasRegionOffset:
|
|
11195
|
-
// @ts-ignore
|
|
11196
|
-
this._dirtyUpdateFlag |= 3;
|
|
11197
|
-
break;
|
|
11198
|
-
case SpriteModifyFlags.atlasRegion:
|
|
11199
|
-
// @ts-ignore
|
|
11200
|
-
this._dirtyUpdateFlag |= 2;
|
|
11201
|
-
break;
|
|
11202
|
-
case SpriteModifyFlags.destroy:
|
|
11203
|
-
this.sprite = null;
|
|
11204
|
-
break;
|
|
11205
|
-
default:
|
|
11206
|
-
this._onSpriteChangeExtra(type);
|
|
11207
|
-
break;
|
|
11208
|
-
}
|
|
11209
|
-
};
|
|
11210
|
-
/**
|
|
11211
|
-
* @internal
|
|
11212
|
-
* Hook for subclass-specific sprite change handling.
|
|
11213
|
-
* SpriteMask overrides this to handle size/pivot changes.
|
|
11214
|
-
*/ _proto._onSpriteChangeExtra = function _onSpriteChangeExtra(type) {};
|
|
11215
|
-
/** @internal */ _proto._getSpriteWidth = function _getSpriteWidth() {
|
|
11216
|
-
return 0;
|
|
11217
|
-
};
|
|
11218
|
-
/** @internal */ _proto._getSpriteHeight = function _getSpriteHeight() {
|
|
11219
|
-
return 0;
|
|
11220
|
-
};
|
|
11221
|
-
/** @internal */ _proto._getSpritePivot = function _getSpritePivot() {
|
|
11222
|
-
return null;
|
|
11223
|
-
};
|
|
11224
|
-
_create_class(MaskRenderableBase, [
|
|
11225
|
-
{
|
|
11226
|
-
key: "influenceLayers",
|
|
11227
|
-
get: /**
|
|
11228
|
-
* The mask layers the sprite mask influence to.
|
|
11229
|
-
*/ function get() {
|
|
11230
|
-
return this._influenceLayers;
|
|
11231
|
-
},
|
|
11232
|
-
set: function set(value) {
|
|
11233
|
-
if (this._influenceLayers !== value) {
|
|
11234
|
-
this._influenceLayers = value;
|
|
11235
|
-
// @ts-ignore
|
|
11236
|
-
if (this._phasedActiveInScene) {
|
|
11237
|
-
// @ts-ignore
|
|
11238
|
-
this.scene._maskManager.onMaskInfluenceLayersChange();
|
|
11239
|
-
}
|
|
11240
|
-
}
|
|
11241
|
-
}
|
|
11242
|
-
},
|
|
11243
|
-
{
|
|
11244
|
-
key: "flipX",
|
|
11245
|
-
get: /**
|
|
11246
|
-
* Flips the sprite on the X axis.
|
|
11247
|
-
*/ function get() {
|
|
11248
|
-
return this._flipX;
|
|
11249
|
-
},
|
|
11250
|
-
set: function set(value) {
|
|
11251
|
-
if (this._flipX !== value) {
|
|
11252
|
-
this._flipX = value;
|
|
11253
|
-
// @ts-ignore
|
|
11254
|
-
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11255
|
-
}
|
|
11256
|
-
}
|
|
11257
|
-
},
|
|
11258
|
-
{
|
|
11259
|
-
key: "flipY",
|
|
11260
|
-
get: /**
|
|
11261
|
-
* Flips the sprite on the Y axis.
|
|
11262
|
-
*/ function get() {
|
|
11263
|
-
return this._flipY;
|
|
11264
|
-
},
|
|
11265
|
-
set: function set(value) {
|
|
11266
|
-
if (this._flipY !== value) {
|
|
11267
|
-
this._flipY = value;
|
|
11268
|
-
// @ts-ignore
|
|
11269
|
-
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11270
|
-
}
|
|
11271
|
-
}
|
|
11272
|
-
},
|
|
11273
|
-
{
|
|
11274
|
-
key: "sprite",
|
|
11275
|
-
get: /**
|
|
11276
|
-
* The Sprite to render.
|
|
11277
|
-
*/ function get() {
|
|
11278
|
-
return this._sprite;
|
|
11279
|
-
},
|
|
11280
|
-
set: function set(value) {
|
|
11281
|
-
var lastSprite = this._sprite;
|
|
11282
|
-
if (lastSprite !== value) {
|
|
11283
|
-
if (lastSprite) {
|
|
11284
|
-
// @ts-ignore
|
|
11285
|
-
this._addResourceReferCount(lastSprite, -1);
|
|
11286
|
-
lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
|
|
11287
|
-
}
|
|
11288
|
-
// @ts-ignore
|
|
11289
|
-
this._dirtyUpdateFlag |= 11;
|
|
11290
|
-
if (value) {
|
|
11291
|
-
// @ts-ignore
|
|
11292
|
-
this._addResourceReferCount(value, 1);
|
|
11293
|
-
value._updateFlagManager.addListener(this._onSpriteChange);
|
|
11294
|
-
// @ts-ignore
|
|
11295
|
-
this.shaderData.setTexture(MaskRenderableBase._maskTextureProperty, value.texture);
|
|
11296
|
-
} else {
|
|
11297
|
-
// @ts-ignore
|
|
11298
|
-
this.shaderData.setTexture(MaskRenderableBase._maskTextureProperty, null);
|
|
11299
|
-
}
|
|
11300
|
-
this._sprite = value;
|
|
11301
|
-
}
|
|
11302
|
-
}
|
|
11303
|
-
},
|
|
11304
|
-
{
|
|
11305
|
-
key: "alphaCutoff",
|
|
11306
|
-
get: /**
|
|
11307
|
-
* The minimum alpha value used by the mask to select the area of influence defined over the mask's sprite. Value between 0 and 1.
|
|
11308
|
-
*/ function get() {
|
|
11309
|
-
return this._alphaCutoff;
|
|
11310
|
-
},
|
|
11311
|
-
set: function set(value) {
|
|
11312
|
-
if (this._alphaCutoff !== value) {
|
|
11313
|
-
this._alphaCutoff = value;
|
|
11314
|
-
// @ts-ignore
|
|
11315
|
-
this.shaderData.setFloat(MaskRenderableBase._alphaCutoffProperty, value);
|
|
11316
|
-
}
|
|
11317
|
-
}
|
|
11318
|
-
}
|
|
11319
|
-
]);
|
|
11320
|
-
return MaskRenderableBase;
|
|
11321
|
-
}(Base);
|
|
11322
|
-
MaskRenderableBase._maskTextureProperty = ShaderProperty.getByName("renderer_MaskTexture");
|
|
11323
|
-
MaskRenderableBase._alphaCutoffProperty = ShaderProperty.getByName("renderer_MaskAlphaCutoff");
|
|
11324
|
-
__decorate([
|
|
11325
|
-
ignoreClone
|
|
11326
|
-
], MaskRenderableBase.prototype, "_renderElement", void 0);
|
|
11327
|
-
__decorate([
|
|
11328
|
-
ignoreClone
|
|
11329
|
-
], MaskRenderableBase.prototype, "_maskIndex", void 0);
|
|
11330
|
-
__decorate([
|
|
11331
|
-
ignoreClone
|
|
11332
|
-
], MaskRenderableBase.prototype, "_sprite", void 0);
|
|
11333
|
-
__decorate([
|
|
11334
|
-
ignoreClone
|
|
11335
|
-
], MaskRenderableBase.prototype, "_onSpriteChange", null);
|
|
11336
|
-
return MaskRenderableBase;
|
|
11337
|
-
}
|
|
11338
|
-
/**
|
|
11339
|
-
* @remarks Extends `RendererUpdateFlags`.
|
|
11340
|
-
*/ var MaskDirtyFlags = /*#__PURE__*/ function(MaskDirtyFlags) {
|
|
11341
|
-
/** UV. */ MaskDirtyFlags[MaskDirtyFlags["UV"] = 2] = "UV";
|
|
11342
|
-
/** Automatic Size. */ MaskDirtyFlags[MaskDirtyFlags["AutomaticSize"] = 8] = "AutomaticSize";
|
|
11343
|
-
/** WorldVolume and UV. */ MaskDirtyFlags[MaskDirtyFlags["WorldVolumeAndUV"] = 3] = "WorldVolumeAndUV";
|
|
11344
|
-
/** All. */ MaskDirtyFlags[MaskDirtyFlags["All"] = 11] = "All";
|
|
11345
|
-
return MaskDirtyFlags;
|
|
11346
|
-
}({});
|
|
11347
|
-
|
|
11348
|
-
/**
|
|
11349
|
-
* 2D sprite.
|
|
11350
|
-
*/ var Sprite = /*#__PURE__*/ function(ReferResource) {
|
|
11351
|
-
_inherits(Sprite, ReferResource);
|
|
11352
|
-
function Sprite(engine, texture, region, pivot, border, name) {
|
|
11353
|
-
if (texture === void 0) texture = null;
|
|
11354
|
-
if (region === void 0) region = null;
|
|
11355
|
-
if (pivot === void 0) pivot = null;
|
|
11356
|
-
if (border === void 0) border = null;
|
|
11357
|
-
if (name === void 0) name = null;
|
|
11358
|
-
var _this;
|
|
11359
|
-
_this = ReferResource.call(this, engine) || this, _this._automaticWidth = 0, _this._automaticHeight = 0, _this._customWidth = undefined, _this._customHeight = undefined, _this._positions = [
|
|
11360
|
-
new engineMath.Vector2(),
|
|
11361
|
-
new engineMath.Vector2(),
|
|
11362
|
-
new engineMath.Vector2(),
|
|
11363
|
-
new engineMath.Vector2()
|
|
11364
|
-
], _this._uvs = [
|
|
11365
|
-
new engineMath.Vector2(),
|
|
11366
|
-
new engineMath.Vector2(),
|
|
11367
|
-
new engineMath.Vector2(),
|
|
11368
|
-
new engineMath.Vector2()
|
|
11369
|
-
], _this._bounds = new engineMath.BoundingBox(), _this._texture = null, _this._atlasRotated = false, _this._atlasRegion = new engineMath.Rect(0, 0, 1, 1), _this._atlasRegionOffset = new engineMath.Vector4(0, 0, 0, 0), _this._region = new engineMath.Rect(0, 0, 1, 1), _this._pivot = new engineMath.Vector2(0.5, 0.5), _this._border = new engineMath.Vector4(0, 0, 0, 0), _this._dirtyUpdateFlag = 7, /** @internal */ _this._updateFlagManager = new UpdateFlagManager();
|
|
11370
|
-
_this._texture = texture;
|
|
11371
|
-
_this._onRegionChange = _this._onRegionChange.bind(_this);
|
|
11372
|
-
_this._onPivotChange = _this._onPivotChange.bind(_this);
|
|
11373
|
-
_this._onBorderChange = _this._onBorderChange.bind(_this);
|
|
11374
|
-
// @ts-ignore
|
|
11375
|
-
_this._region._onValueChanged = _this._onRegionChange;
|
|
11376
|
-
// @ts-ignore
|
|
11377
|
-
_this._pivot._onValueChanged = _this._onPivotChange;
|
|
11378
|
-
// @ts-ignore
|
|
11379
|
-
_this._border._onValueChanged = _this._onBorderChange;
|
|
11380
|
-
region && _this._region.copyFrom(region);
|
|
11381
|
-
pivot && _this._pivot.copyFrom(pivot);
|
|
11382
|
-
border && _this._border.copyFrom(border);
|
|
11383
|
-
_this.name = name;
|
|
11384
|
-
return _this;
|
|
11385
|
-
}
|
|
11386
|
-
var _proto = Sprite.prototype;
|
|
11387
|
-
/**
|
|
11388
|
-
* Clone.
|
|
11389
|
-
* @returns Cloned sprite
|
|
11390
|
-
*/ _proto.clone = function clone() {
|
|
11391
|
-
var cloneSprite = new Sprite(this._engine, this._texture, this._region, this._pivot, this._border, this.name);
|
|
11392
|
-
cloneSprite._atlasRotated = this._atlasRotated;
|
|
11393
|
-
cloneSprite._atlasRegion.copyFrom(this._atlasRegion);
|
|
11394
|
-
cloneSprite._atlasRegionOffset.copyFrom(this._atlasRegionOffset);
|
|
11395
|
-
return cloneSprite;
|
|
11396
|
-
};
|
|
11397
|
-
/**
|
|
11398
|
-
* @internal
|
|
11399
|
-
*/ _proto._getPositions = function _getPositions() {
|
|
11400
|
-
this._dirtyUpdateFlag & 1 && this._updatePositions();
|
|
11401
|
-
return this._positions;
|
|
11402
|
-
};
|
|
11403
|
-
/**
|
|
11404
|
-
* @internal
|
|
11405
|
-
*/ _proto._getUVs = function _getUVs() {
|
|
11406
|
-
this._dirtyUpdateFlag & 2 && this._updateUVs();
|
|
11407
|
-
return this._uvs;
|
|
11408
|
-
};
|
|
11409
|
-
/**
|
|
11410
|
-
* @internal
|
|
11411
|
-
*/ _proto._getBounds = function _getBounds() {
|
|
11412
|
-
this._dirtyUpdateFlag & 1 && this._updatePositions();
|
|
11413
|
-
return this._bounds;
|
|
11414
|
-
};
|
|
11415
|
-
/**
|
|
11416
|
-
* @internal
|
|
11417
|
-
*/ _proto._addReferCount = function _addReferCount(value) {
|
|
11418
|
-
var _this__atlas;
|
|
11419
|
-
ReferResource.prototype._addReferCount.call(this, value);
|
|
11420
|
-
(_this__atlas = this._atlas) == null ? void 0 : _this__atlas._addReferCount(value);
|
|
11421
|
-
};
|
|
11422
|
-
/**
|
|
11423
|
-
* @internal
|
|
11424
|
-
*/ _proto._onDestroy = function _onDestroy() {
|
|
11425
|
-
this._dispatchSpriteChange(SpriteModifyFlags.destroy);
|
|
11426
|
-
ReferResource.prototype._onDestroy.call(this);
|
|
11427
|
-
this._positions.length = 0;
|
|
11428
|
-
this._positions = null;
|
|
11429
|
-
this._uvs.length = 0;
|
|
11430
|
-
this._uvs = null;
|
|
11431
|
-
this._atlasRegion = null;
|
|
11432
|
-
this._atlasRegionOffset = null;
|
|
11433
|
-
this._region = null;
|
|
11434
|
-
this._pivot = null;
|
|
11435
|
-
this._border = null;
|
|
11436
|
-
this._bounds = null;
|
|
11437
|
-
this._atlas = null;
|
|
11438
|
-
this._texture = null;
|
|
11439
|
-
};
|
|
11440
|
-
_proto._calDefaultSize = function _calDefaultSize() {
|
|
11441
|
-
if (this._texture) {
|
|
11442
|
-
var _this = this, _texture = _this._texture, _atlasRegion = _this._atlasRegion, _atlasRegionOffset = _this._atlasRegionOffset, _region = _this._region;
|
|
11443
|
-
var pixelsPerUnitReciprocal = 1.0 / Engine._pixelsPerUnit;
|
|
11444
|
-
this._automaticWidth = _texture.width * _atlasRegion.width / (1 - _atlasRegionOffset.x - _atlasRegionOffset.z) * _region.width * pixelsPerUnitReciprocal;
|
|
11445
|
-
this._automaticHeight = _texture.height * _atlasRegion.height / (1 - _atlasRegionOffset.y - _atlasRegionOffset.w) * _region.height * pixelsPerUnitReciprocal;
|
|
11446
|
-
} else {
|
|
11447
|
-
this._automaticWidth = this._automaticHeight = 0;
|
|
11448
|
-
}
|
|
11449
|
-
this._dirtyUpdateFlag &= ~4;
|
|
11450
|
-
};
|
|
11451
|
-
_proto._updatePositions = function _updatePositions() {
|
|
11452
|
-
var blank = this._atlasRegionOffset;
|
|
11453
|
-
var _this__region = this._region, regionX = _this__region.x, regionY = _this__region.y, regionW = _this__region.width, regionH = _this__region.height;
|
|
11454
|
-
var regionRight = 1 - regionX - regionW;
|
|
11455
|
-
var regionBottom = 1 - regionY - regionH;
|
|
11456
|
-
var left = Math.max(blank.x - regionX, 0) / regionW;
|
|
11457
|
-
var bottom = Math.max(blank.w - regionY, 0) / regionH;
|
|
11458
|
-
var right = 1 - Math.max(blank.z - regionRight, 0) / regionW;
|
|
11459
|
-
var top = 1 - Math.max(blank.y - regionBottom, 0) / regionH;
|
|
11460
|
-
// Update positions.
|
|
11461
|
-
// ---------------
|
|
11462
|
-
// 2 - 3
|
|
11463
|
-
// | |
|
|
11464
|
-
// 0 - 1
|
|
11465
|
-
// ---------------
|
|
11466
|
-
var positions = this._positions;
|
|
11467
|
-
positions[0].set(left, bottom);
|
|
11468
|
-
positions[1].set(right, bottom);
|
|
11469
|
-
positions[2].set(left, top);
|
|
11470
|
-
positions[3].set(right, top);
|
|
11471
|
-
var bounds = this._bounds;
|
|
11472
|
-
bounds.min.set(left, bottom, 0);
|
|
11473
|
-
bounds.max.set(right, top, 0);
|
|
11474
|
-
this._dirtyUpdateFlag &= ~1;
|
|
11475
|
-
};
|
|
11476
|
-
_proto._updateUVs = function _updateUVs() {
|
|
11477
|
-
var _this = this, uv = _this._uvs, atlasRegionOffset = _this._atlasRegionOffset;
|
|
11478
|
-
var _this__region = this._region, regionX = _this__region.x, regionY = _this__region.y, regionW = _this__region.width, regionH = _this__region.height;
|
|
11479
|
-
var regionRight = 1 - regionX - regionW;
|
|
11480
|
-
var regionBottom = 1 - regionY - regionH;
|
|
11481
|
-
var _this__atlasRegion = this._atlasRegion, atlasRegionX = _this__atlasRegion.x, atlasRegionY = _this__atlasRegion.y, atlasRegionW = _this__atlasRegion.width, atlasRegionH = _this__atlasRegion.height;
|
|
11482
|
-
var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
|
|
11483
|
-
var realWidth = atlasRegionW / (1 - offsetLeft - offsetRight);
|
|
11484
|
-
var realHeight = atlasRegionH / (1 - offsetTop - offsetBottom);
|
|
11485
|
-
// Coordinates of the four boundaries.
|
|
11486
|
-
var left = Math.max(regionX - offsetLeft, 0) * realWidth + atlasRegionX;
|
|
11487
|
-
var top = Math.max(regionBottom - offsetTop, 0) * realHeight + atlasRegionY;
|
|
11488
|
-
var right = atlasRegionW + atlasRegionX - Math.max(regionRight - offsetRight, 0) * realWidth;
|
|
11489
|
-
var bottom = atlasRegionH + atlasRegionY - Math.max(regionY - offsetBottom, 0) * realHeight;
|
|
11490
|
-
var _this__border = this._border, borderLeft = _this__border.x, borderBottom = _this__border.y, borderRight = _this__border.z, borderTop = _this__border.w;
|
|
11491
|
-
// Left-Bottom
|
|
11492
|
-
uv[0].set(left, bottom);
|
|
11493
|
-
// Border ( Left-Bottom )
|
|
11494
|
-
uv[1].set((regionX - offsetLeft + borderLeft * regionW) * realWidth + atlasRegionX, atlasRegionH + atlasRegionY - (regionY - offsetBottom + borderBottom * regionH) * realHeight);
|
|
11495
|
-
// Border ( Right-Top )
|
|
11496
|
-
uv[2].set(atlasRegionW + atlasRegionX - (regionRight - offsetRight + borderRight * regionW) * realWidth, (regionBottom - offsetTop + borderTop * regionH) * realHeight + atlasRegionY);
|
|
11497
|
-
// Right-Top
|
|
11498
|
-
uv[3].set(right, top);
|
|
11499
|
-
this._dirtyUpdateFlag &= ~2;
|
|
11500
|
-
};
|
|
11501
|
-
_proto._dispatchSpriteChange = function _dispatchSpriteChange(type) {
|
|
11502
|
-
switch(type){
|
|
11503
|
-
case SpriteModifyFlags.texture:
|
|
11504
|
-
this._dirtyUpdateFlag |= 4;
|
|
11505
|
-
break;
|
|
11506
|
-
case SpriteModifyFlags.atlasRegionOffset:
|
|
11507
|
-
case SpriteModifyFlags.region:
|
|
11508
|
-
this._dirtyUpdateFlag |= 7;
|
|
11509
|
-
break;
|
|
11510
|
-
case SpriteModifyFlags.atlasRegion:
|
|
11511
|
-
this._dirtyUpdateFlag |= 4 | 2;
|
|
11512
|
-
break;
|
|
11513
|
-
case SpriteModifyFlags.border:
|
|
11514
|
-
this._dirtyUpdateFlag |= 2;
|
|
11515
|
-
break;
|
|
11516
|
-
}
|
|
11517
|
-
this._updateFlagManager.dispatch(type);
|
|
11518
|
-
};
|
|
11519
|
-
_proto._onRegionChange = function _onRegionChange() {
|
|
11520
|
-
var _this = this, region = _this._region;
|
|
11521
|
-
// @ts-ignore
|
|
11522
|
-
region._onValueChanged = null;
|
|
11523
|
-
var x = engineMath.MathUtil.clamp(region.x, 0, 1);
|
|
11524
|
-
var y = engineMath.MathUtil.clamp(region.y, 0, 1);
|
|
11525
|
-
region.set(x, y, engineMath.MathUtil.clamp(region.width, 0, 1 - x), engineMath.MathUtil.clamp(region.height, 0, 1 - y));
|
|
11526
|
-
this._dispatchSpriteChange(SpriteModifyFlags.region);
|
|
11527
|
-
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
11528
|
-
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
11529
|
-
}
|
|
11530
|
-
// @ts-ignore
|
|
11531
|
-
region._onValueChanged = this._onRegionChange;
|
|
11532
|
-
};
|
|
11533
|
-
_proto._onPivotChange = function _onPivotChange() {
|
|
11534
|
-
this._dispatchSpriteChange(SpriteModifyFlags.pivot);
|
|
11535
|
-
};
|
|
11536
|
-
_proto._onBorderChange = function _onBorderChange() {
|
|
11537
|
-
var _this = this, border = _this._border;
|
|
11538
|
-
// @ts-ignore
|
|
11539
|
-
border._onValueChanged = null;
|
|
11540
|
-
var x = engineMath.MathUtil.clamp(border.x, 0, 1);
|
|
11541
|
-
var y = engineMath.MathUtil.clamp(border.y, 0, 1);
|
|
11542
|
-
border.set(x, y, engineMath.MathUtil.clamp(border.z, 0, 1 - x), engineMath.MathUtil.clamp(border.w, 0, 1 - y));
|
|
11543
|
-
this._dispatchSpriteChange(SpriteModifyFlags.border);
|
|
11544
|
-
// @ts-ignore
|
|
11545
|
-
border._onValueChanged = this._onBorderChange;
|
|
11546
|
-
};
|
|
11547
|
-
_create_class(Sprite, [
|
|
11548
|
-
{
|
|
11549
|
-
key: "texture",
|
|
11550
|
-
get: /**
|
|
11551
|
-
* The reference to the used texture.
|
|
11552
|
-
*/ function get() {
|
|
11553
|
-
return this._texture;
|
|
11554
|
-
},
|
|
11555
|
-
set: function set(value) {
|
|
11556
|
-
if (this._texture !== value) {
|
|
11557
|
-
this._texture = value;
|
|
11558
|
-
this._dispatchSpriteChange(SpriteModifyFlags.texture);
|
|
11559
|
-
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
11560
|
-
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
11561
|
-
}
|
|
11562
|
-
}
|
|
11563
|
-
}
|
|
11564
|
-
},
|
|
11565
|
-
{
|
|
11566
|
-
key: "width",
|
|
11567
|
-
get: /**
|
|
11568
|
-
* The width of the sprite (in world coordinates).
|
|
11569
|
-
*
|
|
11570
|
-
* @remarks
|
|
11571
|
-
* If width is set, return the set value,
|
|
11572
|
-
* otherwise return the width calculated according to `Texture.width`, `Sprite.region`, `Sprite.atlasRegion` and `Sprite.atlasRegionOffset`.
|
|
11573
|
-
*/ function get() {
|
|
11574
|
-
if (this._customWidth !== undefined) {
|
|
11575
|
-
return this._customWidth;
|
|
11576
|
-
} else {
|
|
11577
|
-
this._dirtyUpdateFlag & 4 && this._calDefaultSize();
|
|
11578
|
-
return this._automaticWidth;
|
|
11579
|
-
}
|
|
11580
|
-
},
|
|
11581
|
-
set: function set(value) {
|
|
11582
|
-
if (this._customWidth !== value) {
|
|
11583
|
-
this._customWidth = value;
|
|
11584
|
-
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
11585
|
-
}
|
|
11586
|
-
}
|
|
11587
|
-
},
|
|
11588
|
-
{
|
|
11589
|
-
key: "height",
|
|
11590
|
-
get: /**
|
|
11591
|
-
* The height of the sprite (in world coordinates).
|
|
10414
|
+
break;
|
|
10415
|
+
}
|
|
10416
|
+
};
|
|
10417
|
+
Shader.getMacroByName = function getMacroByName(name, value) {
|
|
10418
|
+
return ShaderMacro.getByName(name, value);
|
|
10419
|
+
};
|
|
10420
|
+
/**
|
|
10421
|
+
* @deprecated Please use `ShaderProperty.getByName` instead
|
|
11592
10422
|
*
|
|
11593
|
-
*
|
|
11594
|
-
*
|
|
11595
|
-
*
|
|
11596
|
-
*/ function
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
|
|
11600
|
-
this._dirtyUpdateFlag & 4 && this._calDefaultSize();
|
|
11601
|
-
return this._automaticHeight;
|
|
11602
|
-
}
|
|
11603
|
-
},
|
|
11604
|
-
set: function set(value) {
|
|
11605
|
-
if (this._customHeight !== value) {
|
|
11606
|
-
this._customHeight = value;
|
|
11607
|
-
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
11608
|
-
}
|
|
11609
|
-
}
|
|
11610
|
-
},
|
|
11611
|
-
{
|
|
11612
|
-
key: "atlasRotated",
|
|
11613
|
-
get: /**
|
|
11614
|
-
* Is it rotated 90 degrees clockwise when packing.
|
|
11615
|
-
*/ function get() {
|
|
11616
|
-
return this._atlasRotated;
|
|
11617
|
-
},
|
|
11618
|
-
set: function set(value) {
|
|
11619
|
-
if (this._atlasRotated != value) {
|
|
11620
|
-
this._atlasRotated = value;
|
|
11621
|
-
}
|
|
11622
|
-
}
|
|
11623
|
-
},
|
|
11624
|
-
{
|
|
11625
|
-
key: "atlasRegion",
|
|
11626
|
-
get: /**
|
|
11627
|
-
* The rectangle region of the original texture on its atlas texture, specified in normalized.
|
|
11628
|
-
*/ function get() {
|
|
11629
|
-
return this._atlasRegion;
|
|
11630
|
-
},
|
|
11631
|
-
set: function set(value) {
|
|
11632
|
-
var x = engineMath.MathUtil.clamp(value.x, 0, 1);
|
|
11633
|
-
var y = engineMath.MathUtil.clamp(value.y, 0, 1);
|
|
11634
|
-
this._atlasRegion.set(x, y, engineMath.MathUtil.clamp(value.width, 0, 1 - x), engineMath.MathUtil.clamp(value.height, 0, 1 - y));
|
|
11635
|
-
this._dispatchSpriteChange(SpriteModifyFlags.atlasRegion);
|
|
11636
|
-
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
11637
|
-
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
11638
|
-
}
|
|
11639
|
-
}
|
|
11640
|
-
},
|
|
11641
|
-
{
|
|
11642
|
-
key: "atlasRegionOffset",
|
|
11643
|
-
get: /**
|
|
11644
|
-
* The rectangle region offset of the original texture on its atlas texture, specified in normalized.
|
|
11645
|
-
*/ function get() {
|
|
11646
|
-
return this._atlasRegionOffset;
|
|
11647
|
-
},
|
|
11648
|
-
set: function set(value) {
|
|
11649
|
-
var x = engineMath.MathUtil.clamp(value.x, 0, 1);
|
|
11650
|
-
var y = engineMath.MathUtil.clamp(value.y, 0, 1);
|
|
11651
|
-
this._atlasRegionOffset.set(x, y, engineMath.MathUtil.clamp(value.z, 0, 1 - x), engineMath.MathUtil.clamp(value.w, 0, 1 - y));
|
|
11652
|
-
this._dispatchSpriteChange(SpriteModifyFlags.atlasRegionOffset);
|
|
11653
|
-
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
11654
|
-
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
11655
|
-
}
|
|
11656
|
-
}
|
|
11657
|
-
},
|
|
11658
|
-
{
|
|
11659
|
-
key: "region",
|
|
11660
|
-
get: /**
|
|
11661
|
-
* The rectangle region of the sprite, specified in normalized.
|
|
11662
|
-
*/ function get() {
|
|
11663
|
-
return this._region;
|
|
11664
|
-
},
|
|
11665
|
-
set: function set(value) {
|
|
11666
|
-
this._region !== value && this._region.copyFrom(value);
|
|
11667
|
-
}
|
|
11668
|
-
},
|
|
10423
|
+
* Get shader property by name.
|
|
10424
|
+
* @param name - Name of the shader property
|
|
10425
|
+
* @returns Shader property
|
|
10426
|
+
*/ Shader.getPropertyByName = function getPropertyByName(name) {
|
|
10427
|
+
return ShaderProperty.getByName(name);
|
|
10428
|
+
};
|
|
10429
|
+
_create_class(Shader, [
|
|
11669
10430
|
{
|
|
11670
|
-
key: "
|
|
10431
|
+
key: "subShaders",
|
|
11671
10432
|
get: /**
|
|
11672
|
-
*
|
|
11673
|
-
* The origin is at the bottom left and the default value is (0.5, 0.5).
|
|
10433
|
+
* Sub shaders of the shader.
|
|
11674
10434
|
*/ function get() {
|
|
11675
|
-
return this.
|
|
11676
|
-
},
|
|
11677
|
-
set: function set(value) {
|
|
11678
|
-
this._pivot !== value && this._pivot.copyFrom(value);
|
|
10435
|
+
return this._subShaders;
|
|
11679
10436
|
}
|
|
11680
10437
|
},
|
|
11681
10438
|
{
|
|
11682
|
-
key: "
|
|
10439
|
+
key: "destroyed",
|
|
11683
10440
|
get: /**
|
|
11684
|
-
*
|
|
11685
|
-
* x y z w
|
|
11686
|
-
* | | | |
|
|
11687
|
-
* Left, bottom, right, top.
|
|
11688
|
-
* @remarks only use in sliced mode.
|
|
10441
|
+
* Whether it has been destroyed.
|
|
11689
10442
|
*/ function get() {
|
|
11690
|
-
return this.
|
|
11691
|
-
},
|
|
11692
|
-
set: function set(value) {
|
|
11693
|
-
this._border !== value && this._border.copyFrom(value);
|
|
10443
|
+
return this._destroyed;
|
|
11694
10444
|
}
|
|
11695
10445
|
}
|
|
11696
10446
|
]);
|
|
11697
|
-
return
|
|
11698
|
-
}(
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
10447
|
+
return Shader;
|
|
10448
|
+
}();
|
|
10449
|
+
/** @internal */ Shader._compileMacros = new ShaderMacroCollection();
|
|
10450
|
+
Shader._shaderMap = Object.create(null);
|
|
10451
|
+
|
|
10452
|
+
/**
|
|
10453
|
+
* @internal
|
|
10454
|
+
*/ var VertexMergeBatcher = /*#__PURE__*/ function() {
|
|
10455
|
+
function VertexMergeBatcher() {}
|
|
10456
|
+
VertexMergeBatcher.canBatchSprite = function canBatchSprite(preElement, curElement) {
|
|
10457
|
+
var preRenderer = preElement.component;
|
|
10458
|
+
var renderer = curElement.component;
|
|
10459
|
+
var maskInteraction = preRenderer.maskInteraction;
|
|
10460
|
+
// Order: cheap reference checks → mask state → tag lookup (rare opt-out)
|
|
10461
|
+
return preElement.subChunk.chunk === curElement.subChunk.chunk && preElement.texture === curElement.texture && preElement.material === curElement.material && maskInteraction === renderer.maskInteraction && (maskInteraction === SpriteMaskInteraction.None || preRenderer.maskLayer === renderer.maskLayer) && curElement.subShader.passes[0].getTagValue(VertexMergeBatcher._disableBatchTag) !== true;
|
|
10462
|
+
};
|
|
10463
|
+
VertexMergeBatcher.canBatchSpriteMask = function canBatchSpriteMask(preElement, curElement) {
|
|
10464
|
+
if (preElement.subChunk.chunk !== curElement.subChunk.chunk) {
|
|
10465
|
+
return false;
|
|
10466
|
+
}
|
|
10467
|
+
var alphaCutoffProperty = SpriteMask._alphaCutoffProperty;
|
|
10468
|
+
// Compare renderer property
|
|
10469
|
+
return preElement.texture === curElement.texture && preElement.component.shaderData.getFloat(alphaCutoffProperty) === curElement.component.shaderData.getFloat(alphaCutoffProperty);
|
|
10470
|
+
};
|
|
10471
|
+
VertexMergeBatcher.batch = function batch(preElement, curElement) {
|
|
10472
|
+
var subChunk = curElement.subChunk;
|
|
10473
|
+
var chunk = subChunk.chunk, localIndices = subChunk.indices;
|
|
10474
|
+
var length = localIndices.length;
|
|
10475
|
+
if (preElement) {
|
|
10476
|
+
preElement.subChunk.subMesh.count += length;
|
|
10477
|
+
} else {
|
|
10478
|
+
// First write this frame — init subMesh range
|
|
10479
|
+
subChunk.subMesh.start = chunk.updateIndexLength;
|
|
10480
|
+
subChunk.subMesh.count = length;
|
|
10481
|
+
}
|
|
10482
|
+
var startIndex = chunk.updateIndexLength;
|
|
10483
|
+
var _subChunk_vertexArea = subChunk.vertexArea, start = _subChunk_vertexArea.start, size = _subChunk_vertexArea.size;
|
|
10484
|
+
// PrimitiveChunk vertex layout: pos(3) + uv(2) + color(4) = 9 floats per vertex
|
|
10485
|
+
var vertexOffset = start / 9;
|
|
10486
|
+
var indices = chunk.indices;
|
|
10487
|
+
for(var i = 0; i < length; ++i){
|
|
10488
|
+
indices[startIndex++] = vertexOffset + localIndices[i];
|
|
10489
|
+
}
|
|
10490
|
+
chunk.updateIndexLength += length;
|
|
10491
|
+
chunk.updateVertexStart = Math.min(chunk.updateVertexStart, start);
|
|
10492
|
+
chunk.updateVertexEnd = Math.max(chunk.updateVertexEnd, start + size);
|
|
10493
|
+
};
|
|
10494
|
+
return VertexMergeBatcher;
|
|
10495
|
+
}();
|
|
10496
|
+
VertexMergeBatcher._disableBatchTag = ShaderTagKey.getByName("spriteDisableBatching");
|
|
10497
|
+
|
|
10498
|
+
var RenderElement = /*#__PURE__*/ function() {
|
|
10499
|
+
function RenderElement() {
|
|
10500
|
+
this.instancedRenderers = [];
|
|
10501
|
+
this.subDistancePriority = 0;
|
|
10502
|
+
/** @internal Marks a batch leader — a self-contained draw range that must not be merged again downstream */ this._isBatched = false;
|
|
10503
|
+
}
|
|
10504
|
+
var _proto = RenderElement.prototype;
|
|
10505
|
+
_proto.set = function set(component, material, primitive, subPrimitive, texture, subChunk) {
|
|
10506
|
+
this.component = component;
|
|
10507
|
+
this.material = material;
|
|
10508
|
+
this.primitive = primitive;
|
|
10509
|
+
this.subPrimitive = subPrimitive;
|
|
10510
|
+
this.texture = texture;
|
|
10511
|
+
this.subChunk = subChunk;
|
|
10512
|
+
this.instancedRenderers.length = 0;
|
|
10513
|
+
this.subDistancePriority = 0;
|
|
10514
|
+
this._isBatched = false;
|
|
10515
|
+
};
|
|
10516
|
+
/**
|
|
10517
|
+
* @internal
|
|
10518
|
+
* Copy identity fields from `source` and reset per-queue batch state, so the same
|
|
10519
|
+
* logical element can live in multiple queues (e.g. an Opaque + Transparent multi-pass
|
|
10520
|
+
* material) without one queue's batching corrupting another's `instancedRenderers`.
|
|
10521
|
+
*/ _proto._cloneFrom = function _cloneFrom(source) {
|
|
10522
|
+
this.set(source.component, source.material, source.primitive, source.subPrimitive, source.texture, source.subChunk);
|
|
10523
|
+
this.priority = source.priority;
|
|
10524
|
+
this.distanceForSort = source.distanceForSort;
|
|
10525
|
+
this.subShader = source.subShader;
|
|
10526
|
+
this.shaderData = source.shaderData;
|
|
10527
|
+
this.subDistancePriority = source.subDistancePriority;
|
|
10528
|
+
};
|
|
10529
|
+
_proto.dispose = function dispose() {
|
|
10530
|
+
this.component = null;
|
|
10531
|
+
this.material = null;
|
|
10532
|
+
this.primitive = null;
|
|
10533
|
+
this.subPrimitive = null;
|
|
10534
|
+
this.subShader = null;
|
|
10535
|
+
this.shaderData && (this.shaderData = null);
|
|
10536
|
+
this.instancedRenderers = null;
|
|
10537
|
+
this.texture && (this.texture = null);
|
|
10538
|
+
this.subChunk && (this.subChunk = null);
|
|
10539
|
+
};
|
|
10540
|
+
return RenderElement;
|
|
10541
|
+
}();
|
|
11708
10542
|
|
|
11709
10543
|
/**
|
|
11710
10544
|
* A component for masking Sprites.
|
|
11711
|
-
*/ var SpriteMask = /*#__PURE__*/ function(
|
|
11712
|
-
_inherits(SpriteMask,
|
|
10545
|
+
*/ var SpriteMask = /*#__PURE__*/ function(Renderer) {
|
|
10546
|
+
_inherits(SpriteMask, Renderer);
|
|
11713
10547
|
function SpriteMask(entity) {
|
|
11714
10548
|
var _this;
|
|
11715
|
-
_this =
|
|
11716
|
-
|
|
10549
|
+
_this = Renderer.call(this, entity) || this, /** The mask layers the sprite mask influence to. */ _this.influenceLayers = SpriteMaskLayer.Everything, /** @internal */ _this._maskIndex = -1, _this._sprite = null, _this._automaticWidth = 0, _this._automaticHeight = 0, _this._customWidth = undefined, _this._customHeight = undefined, _this._flipX = false, _this._flipY = false, _this._alphaCutoff = 0.5;
|
|
10550
|
+
exports.SimpleSpriteAssembler.resetData(_this);
|
|
10551
|
+
_this.setMaterial(_this._engine._basicResources.spriteMaskDefaultMaterial);
|
|
10552
|
+
_this.shaderData.setFloat(SpriteMask._alphaCutoffProperty, _this._alphaCutoff);
|
|
10553
|
+
_this._renderElement = new RenderElement();
|
|
10554
|
+
_this._onSpriteChange = _this._onSpriteChange.bind(_this);
|
|
11717
10555
|
return _this;
|
|
11718
10556
|
}
|
|
11719
10557
|
var _proto = SpriteMask.prototype;
|
|
@@ -11726,8 +10564,30 @@ __decorate([
|
|
|
11726
10564
|
/**
|
|
11727
10565
|
* @inheritdoc
|
|
11728
10566
|
*/ _proto._onClone = function _onClone(target) {
|
|
11729
|
-
|
|
11730
|
-
this.
|
|
10567
|
+
Renderer.prototype._onClone.call(this, target);
|
|
10568
|
+
target.sprite = this._sprite;
|
|
10569
|
+
};
|
|
10570
|
+
/**
|
|
10571
|
+
* @internal
|
|
10572
|
+
*/ _proto._canBatch = function _canBatch(preElement, curElement) {
|
|
10573
|
+
return VertexMergeBatcher.canBatchSpriteMask(preElement, curElement);
|
|
10574
|
+
};
|
|
10575
|
+
/**
|
|
10576
|
+
* @internal
|
|
10577
|
+
*/ _proto._batch = function _batch(preElement, curElement) {
|
|
10578
|
+
VertexMergeBatcher.batch(preElement, curElement);
|
|
10579
|
+
};
|
|
10580
|
+
/**
|
|
10581
|
+
* @internal
|
|
10582
|
+
*/ _proto._onEnableInScene = function _onEnableInScene() {
|
|
10583
|
+
Renderer.prototype._onEnableInScene.call(this);
|
|
10584
|
+
this.scene._maskManager.addSpriteMask(this);
|
|
10585
|
+
};
|
|
10586
|
+
/**
|
|
10587
|
+
* @internal
|
|
10588
|
+
*/ _proto._onDisableInScene = function _onDisableInScene() {
|
|
10589
|
+
Renderer.prototype._onDisableInScene.call(this);
|
|
10590
|
+
this.scene._maskManager.removeSpriteMask(this);
|
|
11731
10591
|
};
|
|
11732
10592
|
/**
|
|
11733
10593
|
* @internal
|
|
@@ -11735,56 +10595,100 @@ __decorate([
|
|
|
11735
10595
|
return this.engine._batcherManager.primitiveChunkManagerMask;
|
|
11736
10596
|
};
|
|
11737
10597
|
_proto._updateBounds = function _updateBounds(worldBounds) {
|
|
11738
|
-
this.
|
|
10598
|
+
var sprite = this._sprite;
|
|
10599
|
+
if (sprite) {
|
|
10600
|
+
exports.SimpleSpriteAssembler.updatePositions(this, this._transformEntity.transform.worldMatrix, this.width, this.height, sprite.pivot, this._flipX, this._flipY);
|
|
10601
|
+
} else {
|
|
10602
|
+
var worldPosition = this._transformEntity.transform.worldPosition;
|
|
10603
|
+
worldBounds.min.copyFrom(worldPosition);
|
|
10604
|
+
worldBounds.max.copyFrom(worldPosition);
|
|
10605
|
+
}
|
|
11739
10606
|
};
|
|
11740
10607
|
/**
|
|
11741
10608
|
* @inheritdoc
|
|
11742
10609
|
*/ _proto._render = function _render(context) {
|
|
11743
|
-
this.
|
|
10610
|
+
var _this = this, sprite = _this._sprite;
|
|
10611
|
+
if (!(sprite == null ? void 0 : sprite.texture) || !this.width || !this.height) {
|
|
10612
|
+
return;
|
|
10613
|
+
}
|
|
10614
|
+
var material = this.getMaterial();
|
|
10615
|
+
if (!material) {
|
|
10616
|
+
return;
|
|
10617
|
+
}
|
|
10618
|
+
var _this1 = this, engine = _this1._engine;
|
|
10619
|
+
// @todo: This question needs to be raised rather than hidden.
|
|
10620
|
+
if (material.destroyed) {
|
|
10621
|
+
material = engine._basicResources.spriteMaskDefaultMaterial;
|
|
10622
|
+
}
|
|
10623
|
+
// Update position
|
|
10624
|
+
if (this._dirtyUpdateFlag & RendererUpdateFlags.WorldVolume) {
|
|
10625
|
+
exports.SimpleSpriteAssembler.updatePositions(this, this._transformEntity.transform.worldMatrix, this.width, this.height, sprite.pivot, this._flipX, this._flipY);
|
|
10626
|
+
this._dirtyUpdateFlag &= ~RendererUpdateFlags.WorldVolume;
|
|
10627
|
+
}
|
|
10628
|
+
// Update uv
|
|
10629
|
+
if (this._dirtyUpdateFlag & 2) {
|
|
10630
|
+
exports.SimpleSpriteAssembler.updateUVs(this);
|
|
10631
|
+
this._dirtyUpdateFlag &= ~2;
|
|
10632
|
+
}
|
|
10633
|
+
var renderElement = this._renderElement;
|
|
10634
|
+
var subChunk = this._subChunk;
|
|
10635
|
+
renderElement.set(this, material, subChunk.chunk.primitive, subChunk.subMesh, this.sprite.texture, subChunk);
|
|
10636
|
+
renderElement.priority = this.priority;
|
|
10637
|
+
renderElement.distanceForSort = this._distanceForSort;
|
|
10638
|
+
renderElement.subShader = material.shader.subShaders[0];
|
|
11744
10639
|
};
|
|
11745
10640
|
/**
|
|
11746
10641
|
* @inheritdoc
|
|
11747
10642
|
*/ _proto._onDestroy = function _onDestroy() {
|
|
11748
|
-
this.
|
|
11749
|
-
|
|
10643
|
+
var sprite = this._sprite;
|
|
10644
|
+
if (sprite) {
|
|
10645
|
+
this._addResourceReferCount(sprite, -1);
|
|
10646
|
+
sprite._updateFlagManager.removeListener(this._onSpriteChange);
|
|
10647
|
+
}
|
|
10648
|
+
Renderer.prototype._onDestroy.call(this);
|
|
10649
|
+
this._sprite = null;
|
|
11750
10650
|
if (this._subChunk) {
|
|
11751
10651
|
this._getChunkManager().freeSubChunk(this._subChunk);
|
|
11752
10652
|
this._subChunk = null;
|
|
11753
10653
|
}
|
|
10654
|
+
this._renderElement = null;
|
|
11754
10655
|
};
|
|
11755
|
-
_proto.
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
10656
|
+
_proto._calDefaultSize = function _calDefaultSize() {
|
|
10657
|
+
var sprite = this._sprite;
|
|
10658
|
+
if (sprite) {
|
|
10659
|
+
this._automaticWidth = sprite.width;
|
|
10660
|
+
this._automaticHeight = sprite.height;
|
|
10661
|
+
} else {
|
|
10662
|
+
this._automaticWidth = this._automaticHeight = 0;
|
|
10663
|
+
}
|
|
10664
|
+
this._dirtyUpdateFlag &= ~4;
|
|
11764
10665
|
};
|
|
11765
|
-
_proto.
|
|
10666
|
+
_proto._onSpriteChange = function _onSpriteChange(type) {
|
|
11766
10667
|
switch(type){
|
|
10668
|
+
case SpriteModifyFlags.texture:
|
|
10669
|
+
this.shaderData.setTexture(SpriteMask._textureProperty, this.sprite.texture);
|
|
10670
|
+
break;
|
|
11767
10671
|
case SpriteModifyFlags.size:
|
|
11768
|
-
this._dirtyUpdateFlag |=
|
|
10672
|
+
this._dirtyUpdateFlag |= 4;
|
|
11769
10673
|
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
11770
10674
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11771
10675
|
}
|
|
11772
10676
|
break;
|
|
10677
|
+
case SpriteModifyFlags.region:
|
|
10678
|
+
case SpriteModifyFlags.atlasRegionOffset:
|
|
10679
|
+
this._dirtyUpdateFlag |= 3;
|
|
10680
|
+
break;
|
|
10681
|
+
case SpriteModifyFlags.atlasRegion:
|
|
10682
|
+
this._dirtyUpdateFlag |= 2;
|
|
10683
|
+
break;
|
|
11773
10684
|
case SpriteModifyFlags.pivot:
|
|
11774
10685
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11775
10686
|
break;
|
|
10687
|
+
case SpriteModifyFlags.destroy:
|
|
10688
|
+
this.sprite = null;
|
|
10689
|
+
break;
|
|
11776
10690
|
}
|
|
11777
10691
|
};
|
|
11778
|
-
_proto._calDefaultSize = function _calDefaultSize() {
|
|
11779
|
-
var sprite = this.sprite;
|
|
11780
|
-
if (sprite) {
|
|
11781
|
-
this._automaticWidth = sprite.width;
|
|
11782
|
-
this._automaticHeight = sprite.height;
|
|
11783
|
-
} else {
|
|
11784
|
-
this._automaticWidth = this._automaticHeight = 0;
|
|
11785
|
-
}
|
|
11786
|
-
this._dirtyUpdateFlag &= ~MaskDirtyFlags.AutomaticSize;
|
|
11787
|
-
};
|
|
11788
10692
|
_create_class(SpriteMask, [
|
|
11789
10693
|
{
|
|
11790
10694
|
key: "width",
|
|
@@ -11798,7 +10702,7 @@ __decorate([
|
|
|
11798
10702
|
if (this._customWidth !== undefined) {
|
|
11799
10703
|
return this._customWidth;
|
|
11800
10704
|
} else {
|
|
11801
|
-
this._dirtyUpdateFlag &
|
|
10705
|
+
this._dirtyUpdateFlag & 4 && this._calDefaultSize();
|
|
11802
10706
|
return this._automaticWidth;
|
|
11803
10707
|
}
|
|
11804
10708
|
},
|
|
@@ -11821,7 +10725,7 @@ __decorate([
|
|
|
11821
10725
|
if (this._customHeight !== undefined) {
|
|
11822
10726
|
return this._customHeight;
|
|
11823
10727
|
} else {
|
|
11824
|
-
this._dirtyUpdateFlag &
|
|
10728
|
+
this._dirtyUpdateFlag & 4 && this._calDefaultSize();
|
|
11825
10729
|
return this._automaticHeight;
|
|
11826
10730
|
}
|
|
11827
10731
|
},
|
|
@@ -11831,21 +10735,101 @@ __decorate([
|
|
|
11831
10735
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11832
10736
|
}
|
|
11833
10737
|
}
|
|
10738
|
+
},
|
|
10739
|
+
{
|
|
10740
|
+
key: "flipX",
|
|
10741
|
+
get: /**
|
|
10742
|
+
* Flips the sprite on the X axis.
|
|
10743
|
+
*/ function get() {
|
|
10744
|
+
return this._flipX;
|
|
10745
|
+
},
|
|
10746
|
+
set: function set(value) {
|
|
10747
|
+
if (this._flipX !== value) {
|
|
10748
|
+
this._flipX = value;
|
|
10749
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
10750
|
+
}
|
|
10751
|
+
}
|
|
10752
|
+
},
|
|
10753
|
+
{
|
|
10754
|
+
key: "flipY",
|
|
10755
|
+
get: /**
|
|
10756
|
+
* Flips the sprite on the Y axis.
|
|
10757
|
+
*/ function get() {
|
|
10758
|
+
return this._flipY;
|
|
10759
|
+
},
|
|
10760
|
+
set: function set(value) {
|
|
10761
|
+
if (this._flipY !== value) {
|
|
10762
|
+
this._flipY = value;
|
|
10763
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
10764
|
+
}
|
|
10765
|
+
}
|
|
10766
|
+
},
|
|
10767
|
+
{
|
|
10768
|
+
key: "sprite",
|
|
10769
|
+
get: /**
|
|
10770
|
+
* The Sprite to render.
|
|
10771
|
+
*/ function get() {
|
|
10772
|
+
return this._sprite;
|
|
10773
|
+
},
|
|
10774
|
+
set: function set(value) {
|
|
10775
|
+
var lastSprite = this._sprite;
|
|
10776
|
+
if (lastSprite !== value) {
|
|
10777
|
+
if (lastSprite) {
|
|
10778
|
+
this._addResourceReferCount(lastSprite, -1);
|
|
10779
|
+
lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
|
|
10780
|
+
}
|
|
10781
|
+
this._dirtyUpdateFlag |= 7;
|
|
10782
|
+
if (value) {
|
|
10783
|
+
this._addResourceReferCount(value, 1);
|
|
10784
|
+
value._updateFlagManager.addListener(this._onSpriteChange);
|
|
10785
|
+
this.shaderData.setTexture(SpriteMask._textureProperty, value.texture);
|
|
10786
|
+
} else {
|
|
10787
|
+
this.shaderData.setTexture(SpriteMask._textureProperty, null);
|
|
10788
|
+
}
|
|
10789
|
+
this._sprite = value;
|
|
10790
|
+
}
|
|
10791
|
+
}
|
|
10792
|
+
},
|
|
10793
|
+
{
|
|
10794
|
+
key: "alphaCutoff",
|
|
10795
|
+
get: /**
|
|
10796
|
+
* The minimum alpha value used by the mask to select the area of influence defined over the mask's sprite. Value between 0 and 1.
|
|
10797
|
+
*/ function get() {
|
|
10798
|
+
return this._alphaCutoff;
|
|
10799
|
+
},
|
|
10800
|
+
set: function set(value) {
|
|
10801
|
+
if (this._alphaCutoff !== value) {
|
|
10802
|
+
this._alphaCutoff = value;
|
|
10803
|
+
this.shaderData.setFloat(SpriteMask._alphaCutoffProperty, value);
|
|
10804
|
+
}
|
|
10805
|
+
}
|
|
11834
10806
|
}
|
|
11835
10807
|
]);
|
|
11836
10808
|
return SpriteMask;
|
|
11837
|
-
}(
|
|
11838
|
-
/** @internal */ SpriteMask._alphaCutoffProperty = ShaderProperty.getByName("renderer_MaskAlphaCutoff");
|
|
10809
|
+
}(exports.Renderer);
|
|
11839
10810
|
/** @internal */ SpriteMask._textureProperty = ShaderProperty.getByName("renderer_MaskTexture");
|
|
10811
|
+
/** @internal */ SpriteMask._alphaCutoffProperty = ShaderProperty.getByName("renderer_MaskAlphaCutoff");
|
|
10812
|
+
__decorate([
|
|
10813
|
+
ignoreClone
|
|
10814
|
+
], SpriteMask.prototype, "_renderElement", void 0);
|
|
11840
10815
|
__decorate([
|
|
11841
10816
|
ignoreClone
|
|
11842
10817
|
], SpriteMask.prototype, "_subChunk", void 0);
|
|
10818
|
+
__decorate([
|
|
10819
|
+
ignoreClone
|
|
10820
|
+
], SpriteMask.prototype, "_maskIndex", void 0);
|
|
10821
|
+
__decorate([
|
|
10822
|
+
ignoreClone
|
|
10823
|
+
], SpriteMask.prototype, "_sprite", void 0);
|
|
11843
10824
|
__decorate([
|
|
11844
10825
|
ignoreClone
|
|
11845
10826
|
], SpriteMask.prototype, "_automaticWidth", void 0);
|
|
11846
10827
|
__decorate([
|
|
11847
10828
|
ignoreClone
|
|
11848
10829
|
], SpriteMask.prototype, "_automaticHeight", void 0);
|
|
10830
|
+
__decorate([
|
|
10831
|
+
ignoreClone
|
|
10832
|
+
], SpriteMask.prototype, "_onSpriteChange", null);
|
|
11849
10833
|
|
|
11850
10834
|
/**
|
|
11851
10835
|
* Renders a Sprite for 2D graphics.
|
|
@@ -11853,7 +10837,7 @@ __decorate([
|
|
|
11853
10837
|
_inherits(SpriteRenderer, Renderer);
|
|
11854
10838
|
function SpriteRenderer(entity) {
|
|
11855
10839
|
var _this;
|
|
11856
|
-
_this = Renderer.call(this, entity) || this, _this._tileMode = SpriteTileMode.Continuous, _this._tiledAdaptiveThreshold = 0.5, _this.
|
|
10840
|
+
_this = Renderer.call(this, entity) || this, _this._tileMode = SpriteTileMode.Continuous, _this._tiledAdaptiveThreshold = 0.5, _this._color = new engineMath.Color(1, 1, 1, 1), _this._sprite = null, _this._automaticWidth = 0, _this._automaticHeight = 0, _this._customWidth = undefined, _this._customHeight = undefined, _this._flipX = false, _this._flipY = false;
|
|
11857
10841
|
_this.drawMode = SpriteDrawMode.Simple;
|
|
11858
10842
|
_this._dirtyUpdateFlag |= 4;
|
|
11859
10843
|
_this.setMaterial(_this._engine._basicResources.spriteDefaultMaterial);
|
|
@@ -11987,9 +10971,6 @@ __decorate([
|
|
|
11987
10971
|
case SpriteDrawMode.Tiled:
|
|
11988
10972
|
this._dirtyUpdateFlag |= 7;
|
|
11989
10973
|
break;
|
|
11990
|
-
case SpriteDrawMode.Filled:
|
|
11991
|
-
this._dirtyUpdateFlag |= 7;
|
|
11992
|
-
break;
|
|
11993
10974
|
}
|
|
11994
10975
|
break;
|
|
11995
10976
|
case SpriteModifyFlags.border:
|
|
@@ -12007,8 +10988,7 @@ __decorate([
|
|
|
12007
10988
|
this._dirtyUpdateFlag |= 3;
|
|
12008
10989
|
break;
|
|
12009
10990
|
case SpriteModifyFlags.atlasRegion:
|
|
12010
|
-
|
|
12011
|
-
this._dirtyUpdateFlag |= this._drawMode === SpriteDrawMode.Filled ? 3 : 2;
|
|
10991
|
+
this._dirtyUpdateFlag |= 2;
|
|
12012
10992
|
break;
|
|
12013
10993
|
case SpriteModifyFlags.pivot:
|
|
12014
10994
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
@@ -12021,23 +11001,6 @@ __decorate([
|
|
|
12021
11001
|
_proto._onColorChanged = function _onColorChanged() {
|
|
12022
11002
|
this._dirtyUpdateFlag |= 4;
|
|
12023
11003
|
};
|
|
12024
|
-
/**
|
|
12025
|
-
* Returns an origin valid for the given fill mode: the passed origin when it belongs to the mode's
|
|
12026
|
-
* accepted subset, otherwise the mode's default. Keeps `filledMode`/`filledOrigin` always consistent.
|
|
12027
|
-
*/ SpriteRenderer._correctOrigin = function _correctOrigin(mode, origin) {
|
|
12028
|
-
switch(mode){
|
|
12029
|
-
case SpriteFilledMode.Horizontal:
|
|
12030
|
-
return origin === SpriteFilledOrigin.Left || origin === SpriteFilledOrigin.Right ? origin : SpriteFilledOrigin.Left;
|
|
12031
|
-
case SpriteFilledMode.Vertical:
|
|
12032
|
-
return origin === SpriteFilledOrigin.Top || origin === SpriteFilledOrigin.Bottom ? origin : SpriteFilledOrigin.Bottom;
|
|
12033
|
-
case SpriteFilledMode.Radial90:
|
|
12034
|
-
// Radial90 accepts the four corner origins.
|
|
12035
|
-
return origin === SpriteFilledOrigin.TopLeft || origin === SpriteFilledOrigin.TopRight || origin === SpriteFilledOrigin.BottomLeft || origin === SpriteFilledOrigin.BottomRight ? origin : SpriteFilledOrigin.BottomLeft;
|
|
12036
|
-
default:
|
|
12037
|
-
// Radial180 / Radial360 accept the four edge origins.
|
|
12038
|
-
return origin === SpriteFilledOrigin.Top || origin === SpriteFilledOrigin.Bottom || origin === SpriteFilledOrigin.Left || origin === SpriteFilledOrigin.Right ? origin : SpriteFilledOrigin.Bottom;
|
|
12039
|
-
}
|
|
12040
|
-
};
|
|
12041
11004
|
_create_class(SpriteRenderer, [
|
|
12042
11005
|
{
|
|
12043
11006
|
key: "drawMode",
|
|
@@ -12059,9 +11022,6 @@ __decorate([
|
|
|
12059
11022
|
case SpriteDrawMode.Tiled:
|
|
12060
11023
|
this._assembler = exports.TiledSpriteAssembler;
|
|
12061
11024
|
break;
|
|
12062
|
-
case SpriteDrawMode.Filled:
|
|
12063
|
-
this._assembler = exports.FilledSpriteAssembler;
|
|
12064
|
-
break;
|
|
12065
11025
|
}
|
|
12066
11026
|
this._assembler.resetData(this);
|
|
12067
11027
|
this._dirtyUpdateFlag |= 7;
|
|
@@ -12101,76 +11061,6 @@ __decorate([
|
|
|
12101
11061
|
}
|
|
12102
11062
|
}
|
|
12103
11063
|
},
|
|
12104
|
-
{
|
|
12105
|
-
key: "filledAmount",
|
|
12106
|
-
get: /**
|
|
12107
|
-
* The fill amount of the sprite renderer, range from 0 to 1. (Only works in filled mode.)
|
|
12108
|
-
*/ function get() {
|
|
12109
|
-
return this._filledAmount;
|
|
12110
|
-
},
|
|
12111
|
-
set: function set(value) {
|
|
12112
|
-
value = engineMath.MathUtil.clamp(value, 0, 1);
|
|
12113
|
-
if (this._filledAmount !== value) {
|
|
12114
|
-
this._filledAmount = value;
|
|
12115
|
-
if (this._drawMode === SpriteDrawMode.Filled) {
|
|
12116
|
-
this._dirtyUpdateFlag |= 3;
|
|
12117
|
-
}
|
|
12118
|
-
}
|
|
12119
|
-
}
|
|
12120
|
-
},
|
|
12121
|
-
{
|
|
12122
|
-
key: "filledMode",
|
|
12123
|
-
get: /**
|
|
12124
|
-
* The fill mode of the sprite renderer. (Only works in filled mode.)
|
|
12125
|
-
*/ function get() {
|
|
12126
|
-
return this._filledMode;
|
|
12127
|
-
},
|
|
12128
|
-
set: function set(value) {
|
|
12129
|
-
if (this._filledMode !== value) {
|
|
12130
|
-
this._filledMode = value;
|
|
12131
|
-
// Keep the current origin if it is still valid for the new mode, otherwise snap to the mode's
|
|
12132
|
-
// default, since each mode only accepts a subset of origins.
|
|
12133
|
-
this._filledOrigin = SpriteRenderer._correctOrigin(value, this._filledOrigin);
|
|
12134
|
-
if (this._drawMode === SpriteDrawMode.Filled) {
|
|
12135
|
-
this._dirtyUpdateFlag |= 3;
|
|
12136
|
-
}
|
|
12137
|
-
}
|
|
12138
|
-
}
|
|
12139
|
-
},
|
|
12140
|
-
{
|
|
12141
|
-
key: "filledOrigin",
|
|
12142
|
-
get: /**
|
|
12143
|
-
* The fill origin of the sprite renderer. (Only works in filled mode.)
|
|
12144
|
-
*/ function get() {
|
|
12145
|
-
return this._filledOrigin;
|
|
12146
|
-
},
|
|
12147
|
-
set: function set(value) {
|
|
12148
|
-
// Snap to a value valid for the current mode so state stays self-consistent (getter === rendered).
|
|
12149
|
-
value = SpriteRenderer._correctOrigin(this._filledMode, value);
|
|
12150
|
-
if (this._filledOrigin !== value) {
|
|
12151
|
-
this._filledOrigin = value;
|
|
12152
|
-
if (this._drawMode === SpriteDrawMode.Filled) {
|
|
12153
|
-
this._dirtyUpdateFlag |= 3;
|
|
12154
|
-
}
|
|
12155
|
-
}
|
|
12156
|
-
}
|
|
12157
|
-
},
|
|
12158
|
-
{
|
|
12159
|
-
key: "filledClockWise",
|
|
12160
|
-
get: /**
|
|
12161
|
-
* Whether the fill is clockwise. (Only works in filled radial mode.)
|
|
12162
|
-
*/ function get() {
|
|
12163
|
-
return this._filledClockWise;
|
|
12164
|
-
},
|
|
12165
|
-
set: function set(value) {
|
|
12166
|
-
if (this._filledClockWise !== value) {
|
|
12167
|
-
this._filledClockWise = value;
|
|
12168
|
-
if (this._drawMode === SpriteDrawMode.Filled) {
|
|
12169
|
-
this._dirtyUpdateFlag |= 3;
|
|
12170
|
-
}
|
|
12171
|
-
}
|
|
12172
|
-
}
|
|
12173
|
-
},
|
|
12174
11064
|
{
|
|
12175
11065
|
key: "sprite",
|
|
12176
11066
|
get: /**
|
|
@@ -12343,18 +11233,13 @@ __decorate([
|
|
|
12343
11233
|
_inherits(TextRenderer, Renderer);
|
|
12344
11234
|
function TextRenderer(entity) {
|
|
12345
11235
|
var _this;
|
|
12346
|
-
_this = Renderer.call(this, entity) || this, _this._textChunks = Array(), /** @internal */ _this._subFont = null, /** @internal */ _this._dirtyFlag = 15, _this._color = new engineMath.Color(1, 1, 1, 1), _this._text = "", _this._width = 0, _this._height = 0, _this._localBounds = new engineMath.BoundingBox(), _this._font = null, _this._fontSize = 24, _this._fontStyle = FontStyle.None, _this._lineSpacing = 0, _this._characterSpacing = 0, _this._horizontalAlignment = TextHorizontalAlignment.Center, _this._verticalAlignment = TextVerticalAlignment.Center, _this._enableWrapping = false, _this._overflowMode = OverflowMode.Overflow
|
|
11236
|
+
_this = Renderer.call(this, entity) || this, _this._textChunks = Array(), /** @internal */ _this._subFont = null, /** @internal */ _this._dirtyFlag = 15, _this._color = new engineMath.Color(1, 1, 1, 1), _this._text = "", _this._width = 0, _this._height = 0, _this._localBounds = new engineMath.BoundingBox(), _this._font = null, _this._fontSize = 24, _this._fontStyle = FontStyle.None, _this._lineSpacing = 0, _this._characterSpacing = 0, _this._horizontalAlignment = TextHorizontalAlignment.Center, _this._verticalAlignment = TextVerticalAlignment.Center, _this._enableWrapping = false, _this._overflowMode = OverflowMode.Overflow;
|
|
12347
11237
|
var engine = _this.engine;
|
|
12348
11238
|
_this._font = engine._textDefaultFont;
|
|
12349
11239
|
_this._addResourceReferCount(_this._font, 1);
|
|
12350
11240
|
_this.setMaterial(engine._basicResources.textDefaultMaterial);
|
|
12351
|
-
var shaderData = _this.shaderData;
|
|
12352
|
-
shaderData.setFloat(TextRenderer._outlineWidthProperty, _this._outlineWidth);
|
|
12353
|
-
shaderData.setColor(TextRenderer._outlineColorProperty, _this._outlineColor);
|
|
12354
11241
|
//@ts-ignore
|
|
12355
11242
|
_this._color._onValueChanged = _this._onColorChanged.bind(_this);
|
|
12356
|
-
// @ts-ignore
|
|
12357
|
-
_this._outlineColor._onValueChanged = _this._onOutlineColorChanged.bind(_this);
|
|
12358
11243
|
return _this;
|
|
12359
11244
|
}
|
|
12360
11245
|
var _proto = TextRenderer.prototype;
|
|
@@ -12402,7 +11287,7 @@ __decorate([
|
|
|
12402
11287
|
/**
|
|
12403
11288
|
* @internal
|
|
12404
11289
|
*/ _proto._canBatch = function _canBatch(preElement, curElement) {
|
|
12405
|
-
return VertexMergeBatcher.
|
|
11290
|
+
return VertexMergeBatcher.canBatchSprite(preElement, curElement);
|
|
12406
11291
|
};
|
|
12407
11292
|
/**
|
|
12408
11293
|
* @internal
|
|
@@ -12445,7 +11330,6 @@ __decorate([
|
|
|
12445
11330
|
var distanceForSort = this._distanceForSort;
|
|
12446
11331
|
var renderPipeline = camera._renderPipeline;
|
|
12447
11332
|
var textChunks = this._textChunks;
|
|
12448
|
-
var textTextureSize = TextRenderer._tempVec20;
|
|
12449
11333
|
for(var i = 0, n = textChunks.length; i < n; ++i){
|
|
12450
11334
|
var _renderElement;
|
|
12451
11335
|
var _textChunks_i = textChunks[i], subChunk = _textChunks_i.subChunk, texture = _textChunks_i.texture;
|
|
@@ -12453,7 +11337,6 @@ __decorate([
|
|
|
12453
11337
|
renderElement.set(this, material, subChunk.chunk.primitive, subChunk.subMesh, texture, subChunk);
|
|
12454
11338
|
(_renderElement = renderElement).shaderData || (_renderElement.shaderData = new ShaderData(ShaderDataGroup.RenderElement));
|
|
12455
11339
|
renderElement.shaderData.setTexture(TextRenderer._textureProperty, texture);
|
|
12456
|
-
renderElement.shaderData.setVector2(TextRenderer._textTextureSizeProperty, textTextureSize.set(texture.width, texture.height));
|
|
12457
11340
|
renderElement.priority = priority;
|
|
12458
11341
|
renderElement.distanceForSort = distanceForSort;
|
|
12459
11342
|
renderPipeline.pushRenderElement(context, renderElement);
|
|
@@ -12464,14 +11347,6 @@ __decorate([
|
|
|
12464
11347
|
this._subFont = font._getSubFont(this.fontSize, this.fontStyle);
|
|
12465
11348
|
this._subFont.nativeFontString = TextUtils.getNativeFontString(font.name, this.fontSize, this.fontStyle);
|
|
12466
11349
|
};
|
|
12467
|
-
/**
|
|
12468
|
-
* Switch the sub font to a specific font size, used by the SHRINK overflow measurement.
|
|
12469
|
-
*/ _proto._applyFontSizeForShrink = function _applyFontSizeForShrink(fontSize) {
|
|
12470
|
-
var font = this._font;
|
|
12471
|
-
var subFont = font._getSubFont(fontSize, this._fontStyle);
|
|
12472
|
-
subFont.nativeFontString = TextUtils.getNativeFontString(font.name, fontSize, this._fontStyle);
|
|
12473
|
-
this._subFont = subFont;
|
|
12474
|
-
};
|
|
12475
11350
|
_proto._updatePosition = function _updatePosition() {
|
|
12476
11351
|
var transform = this.entity.transform;
|
|
12477
11352
|
var e = transform.worldMatrix.elements;
|
|
@@ -12527,26 +11402,12 @@ __decorate([
|
|
|
12527
11402
|
}
|
|
12528
11403
|
};
|
|
12529
11404
|
_proto._updateLocalData = function _updateLocalData() {
|
|
12530
|
-
var _this = this;
|
|
12531
11405
|
var _pixelsPerUnit = Engine._pixelsPerUnit;
|
|
12532
11406
|
var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
|
|
12533
11407
|
var charRenderInfos = TextRenderer._charRenderInfos;
|
|
12534
|
-
var rendererWidth = this.width * _pixelsPerUnit;
|
|
12535
|
-
var rendererHeight = this.height * _pixelsPerUnit;
|
|
12536
|
-
var fontSize = this._fontSize;
|
|
12537
|
-
var textMetrics;
|
|
12538
|
-
if (this._overflowMode === OverflowMode.Shrink) {
|
|
12539
|
-
var result = TextUtils.measureTextWithShrink(this, rendererWidth, rendererHeight, this._fontSize, this._lineSpacing, this._characterSpacing, this.enableWrapping, function(size) {
|
|
12540
|
-
return _this._applyFontSizeForShrink(size);
|
|
12541
|
-
});
|
|
12542
|
-
fontSize = result.fontSize;
|
|
12543
|
-
textMetrics = result.metrics;
|
|
12544
|
-
} else {
|
|
12545
|
-
var characterSpacing = this._characterSpacing * fontSize;
|
|
12546
|
-
textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this, rendererWidth, rendererHeight, this._lineSpacing * fontSize, characterSpacing) : TextUtils.measureTextWithoutWrap(this, rendererHeight, this._lineSpacing * fontSize, characterSpacing);
|
|
12547
|
-
}
|
|
12548
11408
|
var charFont = this._getSubFont();
|
|
12549
|
-
var
|
|
11409
|
+
var characterSpacing = this._characterSpacing * this._fontSize;
|
|
11410
|
+
var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this, this.width * _pixelsPerUnit, this.height * _pixelsPerUnit, this._lineSpacing * this._fontSize, characterSpacing) : TextUtils.measureTextWithoutWrap(this, this.height * _pixelsPerUnit, this._lineSpacing * this._fontSize, characterSpacing);
|
|
12550
11411
|
var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
|
|
12551
11412
|
var charRenderInfoPool = this.engine._charRenderInfoPool;
|
|
12552
11413
|
var linesLen = lines.length;
|
|
@@ -12554,7 +11415,9 @@ __decorate([
|
|
|
12554
11415
|
if (linesLen > 0) {
|
|
12555
11416
|
var horizontalAlignment = this.horizontalAlignment;
|
|
12556
11417
|
var pixelsPerUnitReciprocal = 1.0 / _pixelsPerUnit;
|
|
11418
|
+
var rendererWidth = this._width * _pixelsPerUnit;
|
|
12557
11419
|
var halfRendererWidth = rendererWidth * 0.5;
|
|
11420
|
+
var rendererHeight = this._height * _pixelsPerUnit;
|
|
12558
11421
|
var halfLineHeight = lineHeight * 0.5;
|
|
12559
11422
|
var startY = 0;
|
|
12560
11423
|
var topDiff = lineHeight * 0.5 - lineMaxSizes[0].ascent;
|
|
@@ -12564,10 +11427,7 @@ __decorate([
|
|
|
12564
11427
|
startY = rendererHeight * 0.5 - halfLineHeight + topDiff;
|
|
12565
11428
|
break;
|
|
12566
11429
|
case TextVerticalAlignment.Center:
|
|
12567
|
-
|
|
12568
|
-
// `height` — which equals the renderer height for Truncate/Shrink and would otherwise
|
|
12569
|
-
// push the text upward by (rendererHeight - blockHeight) / 2 when the box is taller.
|
|
12570
|
-
startY = lineHeight * linesLen * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
|
|
11430
|
+
startY = height * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
|
|
12571
11431
|
break;
|
|
12572
11432
|
case TextVerticalAlignment.Bottom:
|
|
12573
11433
|
startY = height - rendererHeight * 0.5 - halfLineHeight - bottomDiff;
|
|
@@ -12608,18 +11468,17 @@ __decorate([
|
|
|
12608
11468
|
charRenderInfo.texture = charFont._getTextureByIndex(charInfo.index);
|
|
12609
11469
|
charRenderInfo.uvs = charInfo.uvs;
|
|
12610
11470
|
var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
|
|
12611
|
-
var
|
|
12612
|
-
var
|
|
12613
|
-
var
|
|
12614
|
-
var
|
|
12615
|
-
var bottom = (startY - descent) * pixelsPerUnitReciprocal - ow;
|
|
11471
|
+
var left = startX * pixelsPerUnitReciprocal;
|
|
11472
|
+
var right = (startX + w) * pixelsPerUnitReciprocal;
|
|
11473
|
+
var top = (startY + ascent) * pixelsPerUnitReciprocal;
|
|
11474
|
+
var bottom = (startY - descent) * pixelsPerUnitReciprocal;
|
|
12616
11475
|
localPositions.set(left, top, right, bottom);
|
|
12617
11476
|
i === firstLine && (maxY = Math.max(maxY, top));
|
|
12618
11477
|
minY = Math.min(minY, bottom);
|
|
12619
11478
|
j === firstRow && (minX = Math.min(minX, left));
|
|
12620
11479
|
maxX = Math.max(maxX, right);
|
|
12621
11480
|
}
|
|
12622
|
-
startX += charInfo.xAdvance +
|
|
11481
|
+
startX += charInfo.xAdvance + characterSpacing;
|
|
12623
11482
|
}
|
|
12624
11483
|
}
|
|
12625
11484
|
startY -= lineHeight;
|
|
@@ -12675,7 +11534,7 @@ __decorate([
|
|
|
12675
11534
|
this._setDirtyFlagTrue(4 | 8);
|
|
12676
11535
|
};
|
|
12677
11536
|
_proto._isTextNoVisible = function _isTextNoVisible() {
|
|
12678
|
-
return !this._font || this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 ||
|
|
11537
|
+
return !this._font || this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === OverflowMode.Truncate && this.height <= 0;
|
|
12679
11538
|
};
|
|
12680
11539
|
_proto._buildChunk = function _buildChunk(textChunk, count) {
|
|
12681
11540
|
var _this_color = this.color, r = _this_color.r, g = _this_color.g, b = _this_color.b, a = _this_color.a;
|
|
@@ -12685,10 +11544,6 @@ __decorate([
|
|
|
12685
11544
|
var vertices = subChunk.chunk.vertices;
|
|
12686
11545
|
var indices = subChunk.indices = [];
|
|
12687
11546
|
var charRenderInfos = textChunk.charRenderInfos;
|
|
12688
|
-
var ow = this._outlineWidth;
|
|
12689
|
-
var texture = textChunk.texture;
|
|
12690
|
-
var owU = ow > 0 ? ow / texture.width : 0;
|
|
12691
|
-
var owV = ow > 0 ? ow / texture.height : 0;
|
|
12692
11547
|
for(var i = 0, ii = 0, io = 0, vo = subChunk.vertexArea.start + 3; i < count; ++i, io += 4){
|
|
12693
11548
|
var charRenderInfo = charRenderInfos[i];
|
|
12694
11549
|
charRenderInfo.indexInChunk = i;
|
|
@@ -12696,13 +11551,10 @@ __decorate([
|
|
|
12696
11551
|
for(var j = 0; j < tempIndicesLength; ++j){
|
|
12697
11552
|
indices[ii++] = tempIndices[j] + io;
|
|
12698
11553
|
}
|
|
12699
|
-
// Set uv and color for vertices
|
|
11554
|
+
// Set uv and color for vertices
|
|
12700
11555
|
for(var j1 = 0; j1 < 4; ++j1, vo += 9){
|
|
12701
11556
|
var uv = charRenderInfo.uvs[j1];
|
|
12702
|
-
|
|
12703
|
-
var sv = j1 >= 2 ? 1 : -1;
|
|
12704
|
-
vertices[vo] = uv.x + owU * su;
|
|
12705
|
-
vertices[vo + 1] = uv.y + owV * sv;
|
|
11557
|
+
uv.copyToArray(vertices, vo);
|
|
12706
11558
|
vertices[vo + 2] = r;
|
|
12707
11559
|
vertices[vo + 3] = g;
|
|
12708
11560
|
vertices[vo + 4] = b;
|
|
@@ -12731,9 +11583,6 @@ __decorate([
|
|
|
12731
11583
|
_proto._onColorChanged = function _onColorChanged() {
|
|
12732
11584
|
this._setDirtyFlagTrue(16);
|
|
12733
11585
|
};
|
|
12734
|
-
_proto._onOutlineColorChanged = function _onOutlineColorChanged() {
|
|
12735
|
-
this.shaderData.setColor(TextRenderer._outlineColorProperty, this._outlineColor);
|
|
12736
|
-
};
|
|
12737
11586
|
_create_class(TextRenderer, [
|
|
12738
11587
|
{
|
|
12739
11588
|
key: "color",
|
|
@@ -12920,35 +11769,6 @@ __decorate([
|
|
|
12920
11769
|
}
|
|
12921
11770
|
}
|
|
12922
11771
|
},
|
|
12923
|
-
{
|
|
12924
|
-
key: "outlineWidth",
|
|
12925
|
-
get: /**
|
|
12926
|
-
* The outline width in pixels. 0 means outline is disabled. Clamped to [0, 8].
|
|
12927
|
-
*/ function get() {
|
|
12928
|
-
return this._outlineWidth;
|
|
12929
|
-
},
|
|
12930
|
-
set: function set(value) {
|
|
12931
|
-
value = Math.max(0, Math.min(value, 3));
|
|
12932
|
-
if (this._outlineWidth !== value) {
|
|
12933
|
-
this._outlineWidth = value;
|
|
12934
|
-
this.shaderData.setFloat(TextRenderer._outlineWidthProperty, value);
|
|
12935
|
-
this._setDirtyFlagTrue(14);
|
|
12936
|
-
}
|
|
12937
|
-
}
|
|
12938
|
-
},
|
|
12939
|
-
{
|
|
12940
|
-
key: "outlineColor",
|
|
12941
|
-
get: /**
|
|
12942
|
-
* The outline color. Only effective when outlineWidth > 0.
|
|
12943
|
-
*/ function get() {
|
|
12944
|
-
return this._outlineColor;
|
|
12945
|
-
},
|
|
12946
|
-
set: function set(value) {
|
|
12947
|
-
if (this._outlineColor !== value) {
|
|
12948
|
-
this._outlineColor.copyFrom(value);
|
|
12949
|
-
}
|
|
12950
|
-
}
|
|
12951
|
-
},
|
|
12952
11772
|
{
|
|
12953
11773
|
key: "maskInteraction",
|
|
12954
11774
|
get: /**
|
|
@@ -12999,13 +11819,9 @@ __decorate([
|
|
|
12999
11819
|
]);
|
|
13000
11820
|
return TextRenderer;
|
|
13001
11821
|
}(exports.Renderer);
|
|
13002
|
-
TextRenderer.
|
|
11822
|
+
TextRenderer._textureProperty = ShaderProperty.getByName("renderElement_TextTexture");
|
|
13003
11823
|
TextRenderer._tempVec30 = new engineMath.Vector3();
|
|
13004
11824
|
TextRenderer._tempVec31 = new engineMath.Vector3();
|
|
13005
|
-
TextRenderer._textureProperty = ShaderProperty.getByName("renderElement_TextTexture");
|
|
13006
|
-
TextRenderer._textTextureSizeProperty = ShaderProperty.getByName("renderElement_TextTextureSize");
|
|
13007
|
-
TextRenderer._outlineColorProperty = ShaderProperty.getByName("renderer_OutlineColor");
|
|
13008
|
-
TextRenderer._outlineWidthProperty = ShaderProperty.getByName("renderer_OutlineWidth");
|
|
13009
11825
|
TextRenderer._worldPositions = [
|
|
13010
11826
|
new engineMath.Vector3(),
|
|
13011
11827
|
new engineMath.Vector3(),
|
|
@@ -13028,9 +11844,6 @@ __decorate([
|
|
|
13028
11844
|
__decorate([
|
|
13029
11845
|
ignoreClone
|
|
13030
11846
|
], TextRenderer.prototype, "_onColorChanged", null);
|
|
13031
|
-
__decorate([
|
|
13032
|
-
ignoreClone
|
|
13033
|
-
], TextRenderer.prototype, "_onOutlineColorChanged", null);
|
|
13034
11847
|
var TextChunk = function TextChunk() {
|
|
13035
11848
|
this.charRenderInfos = new Array();
|
|
13036
11849
|
};
|
|
@@ -16533,7 +15346,7 @@ BlendShapeManager._blendShapeTextureInfoProperty = ShaderProperty.getByName("ren
|
|
|
16533
15346
|
return null;
|
|
16534
15347
|
}
|
|
16535
15348
|
if (!buffer.readable) {
|
|
16536
|
-
throw
|
|
15349
|
+
throw "Not allowed to access data while vertex buffer readable is false.";
|
|
16537
15350
|
}
|
|
16538
15351
|
var vertexCount = this.vertexCount;
|
|
16539
15352
|
var formatMetaInfo = vertexElement._formatMetaInfo;
|
|
@@ -19536,12 +18349,9 @@ registerDefaultCloneMode(SafeLoopArray, CloneMode.Ignore);
|
|
|
19536
18349
|
});
|
|
19537
18350
|
scenePromise.then(function(scene) {
|
|
19538
18351
|
if (destroyOldScene) {
|
|
19539
|
-
|
|
19540
|
-
// and skip `scene` itself because concurrent loads of the same url resolve to the same instance
|
|
19541
|
-
var scenes = _this._scenes.getLoopArray();
|
|
18352
|
+
var scenes = _this._scenes.getArray();
|
|
19542
18353
|
for(var i = 0, n = scenes.length; i < n; i++){
|
|
19543
|
-
|
|
19544
|
-
oldScene !== scene && oldScene.destroy();
|
|
18354
|
+
scenes[i].destroy();
|
|
19545
18355
|
}
|
|
19546
18356
|
}
|
|
19547
18357
|
_this.addScene(scene);
|
|
@@ -19827,8 +18637,8 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
19827
18637
|
* @param url - Resource url
|
|
19828
18638
|
* @returns Resource object
|
|
19829
18639
|
*/ _proto.getFromCache = function getFromCache(url) {
|
|
19830
|
-
var
|
|
19831
|
-
return (
|
|
18640
|
+
var _this__assetUrlPool_url;
|
|
18641
|
+
return (_this__assetUrlPool_url = this._assetUrlPool[url]) != null ? _this__assetUrlPool_url : null;
|
|
19832
18642
|
};
|
|
19833
18643
|
/**
|
|
19834
18644
|
* Find the resource by type.
|
|
@@ -20027,13 +18837,10 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
20027
18837
|
// Get remote asset base url
|
|
20028
18838
|
var virtualResourceEntry = this._virtualPathResourceMap[assetBaseURL];
|
|
20029
18839
|
this._resolveLoadItemOptions(item, virtualResourceEntry);
|
|
20030
|
-
//
|
|
20031
|
-
|
|
20032
|
-
// resolves ordinary relative transport URLs
|
|
20033
|
-
var loadItemUrl = virtualResourceEntry !== undefined || Utils.isAbsoluteUrl(assetBaseURL) || !this.baseUrl ? assetBaseURL : Utils.resolveAbsoluteUrl(this.baseUrl, assetBaseURL);
|
|
20034
|
-
item.url = loadItemUrl;
|
|
18840
|
+
// Not absolute and base url is set
|
|
18841
|
+
item.url = !Utils.isAbsoluteUrl(assetBaseURL) && this.baseUrl ? Utils.resolveAbsoluteUrl(this.baseUrl, assetBaseURL) : assetBaseURL;
|
|
20035
18842
|
var _virtualResourceEntry_path;
|
|
20036
|
-
var remoteAssetBaseURL = (_virtualResourceEntry_path = virtualResourceEntry == null ? void 0 : virtualResourceEntry.path) != null ? _virtualResourceEntry_path :
|
|
18843
|
+
var remoteAssetBaseURL = (_virtualResourceEntry_path = virtualResourceEntry == null ? void 0 : virtualResourceEntry.path) != null ? _virtualResourceEntry_path : item.url;
|
|
20037
18844
|
// Check cache
|
|
20038
18845
|
var cacheObject = this._assetUrlPool[remoteAssetBaseURL];
|
|
20039
18846
|
if (cacheObject) {
|
|
@@ -20704,7 +19511,6 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
20704
19511
|
function Pointer(id) {
|
|
20705
19512
|
/** The phase of pointer. */ this.phase = PointerPhase.Leave;
|
|
20706
19513
|
/** The position of the pointer in screen space pixel coordinates. */ this.position = new engineMath.Vector2();
|
|
20707
|
-
/** The position of the pointer when it was last pressed down (in screen space pixel coordinates). */ this.pressedPosition = new engineMath.Vector2();
|
|
20708
19514
|
/** The change of the pointer. */ this.deltaPosition = new engineMath.Vector2();
|
|
20709
19515
|
/** @internal */ this._events = [];
|
|
20710
19516
|
/** @internal */ this._upMap = [];
|
|
@@ -20718,6 +19524,11 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
20718
19524
|
var _proto = Pointer.prototype;
|
|
20719
19525
|
/**
|
|
20720
19526
|
* @internal
|
|
19527
|
+
*/ _proto._addEmitters = function _addEmitters(type, pool) {
|
|
19528
|
+
this._emitters.push(new type(pool));
|
|
19529
|
+
};
|
|
19530
|
+
/**
|
|
19531
|
+
* @internal
|
|
20721
19532
|
*/ _proto._resetOnFrameBegin = function _resetOnFrameBegin() {
|
|
20722
19533
|
this._frameEvents = 0;
|
|
20723
19534
|
this._events.length = this._upList.length = this._downList.length = 0;
|
|
@@ -20748,16 +19559,12 @@ var PointerEventType = /*#__PURE__*/ function(PointerEventType) {
|
|
|
20748
19559
|
*/ var PointerEventData = /*#__PURE__*/ function() {
|
|
20749
19560
|
function PointerEventData() {
|
|
20750
19561
|
/** The position of the event trigger (in world space). */ this.worldPosition = new engineMath.Vector3();
|
|
20751
|
-
/** The hit-tested target entity (deepest entity on the bubble path). */ this.target = null;
|
|
20752
|
-
/** The entity currently handling the event (same as target on non-bubbling fire, varies on bubble). */ this.currentTarget = null;
|
|
20753
19562
|
}
|
|
20754
19563
|
var _proto = PointerEventData.prototype;
|
|
20755
19564
|
/**
|
|
20756
19565
|
* @internal
|
|
20757
19566
|
*/ _proto.dispose = function dispose() {
|
|
20758
19567
|
this.pointer = null;
|
|
20759
|
-
this.target = null;
|
|
20760
|
-
this.currentTarget = null;
|
|
20761
19568
|
};
|
|
20762
19569
|
return PointerEventData;
|
|
20763
19570
|
}();
|
|
@@ -20789,12 +19596,7 @@ exports.Collider = /*#__PURE__*/ function(Component) {
|
|
|
20789
19596
|
_inherits(Collider, Component);
|
|
20790
19597
|
function Collider(entity) {
|
|
20791
19598
|
var _this;
|
|
20792
|
-
_this = Component.call(this, entity) || this, /** @internal */ _this._index = -1, _this._shapes = [], _this._collisionLayerIndex = 0
|
|
20793
|
-
* A collider must teleport on the next transform sync when its native actor
|
|
20794
|
-
* already exists at a stale pose, such as after re-entering the scene or after
|
|
20795
|
-
* clone-time native reconstruction. Ordinary first entry can use subclass sync
|
|
20796
|
-
* semantics so kinematic actors still use setKinematicTarget.
|
|
20797
|
-
*/ _this._pendingReenterTeleport = false, _this._enteredScene = false;
|
|
19599
|
+
_this = Component.call(this, entity) || this, /** @internal */ _this._index = -1, _this._shapes = [], _this._collisionLayerIndex = 0;
|
|
20798
19600
|
_this._updateFlag = entity.registerWorldChangeFlag();
|
|
20799
19601
|
return _this;
|
|
20800
19602
|
}
|
|
@@ -20837,16 +19639,11 @@ exports.Collider = /*#__PURE__*/ function(Component) {
|
|
|
20837
19639
|
/**
|
|
20838
19640
|
* @internal
|
|
20839
19641
|
*/ _proto._onUpdate = function _onUpdate() {
|
|
20840
|
-
|
|
20841
|
-
if (this._pendingReenterTeleport || this._updateFlag.flag) {
|
|
19642
|
+
if (this._updateFlag.flag) {
|
|
20842
19643
|
var transform = this.entity.transform;
|
|
20843
|
-
|
|
20844
|
-
this._teleportToEntityTransform(transform.worldPosition, transform.worldRotationQuaternion);
|
|
20845
|
-
this._pendingReenterTeleport = false;
|
|
20846
|
-
} else {
|
|
20847
|
-
this._syncEntityTransformToNative(transform.worldPosition, transform.worldRotationQuaternion);
|
|
20848
|
-
}
|
|
19644
|
+
this._nativeCollider.setWorldTransform(transform.worldPosition, transform.worldRotationQuaternion);
|
|
20849
19645
|
var worldScale = transform.lossyWorldScale;
|
|
19646
|
+
var shapes = this._shapes;
|
|
20850
19647
|
for(var i = 0, n = shapes.length; i < n; i++){
|
|
20851
19648
|
var _shapes_i__nativeShape;
|
|
20852
19649
|
(_shapes_i__nativeShape = shapes[i]._nativeShape) == null ? void 0 : _shapes_i__nativeShape.setWorldScale(worldScale);
|
|
@@ -20861,10 +19658,6 @@ exports.Collider = /*#__PURE__*/ function(Component) {
|
|
|
20861
19658
|
* @internal
|
|
20862
19659
|
*/ _proto._onEnableInScene = function _onEnableInScene() {
|
|
20863
19660
|
this.scene.physics._addCollider(this);
|
|
20864
|
-
if (this._enteredScene) {
|
|
20865
|
-
this._pendingReenterTeleport = true;
|
|
20866
|
-
}
|
|
20867
|
-
this._enteredScene = true;
|
|
20868
19661
|
};
|
|
20869
19662
|
/**
|
|
20870
19663
|
* @internal
|
|
@@ -20875,7 +19668,6 @@ exports.Collider = /*#__PURE__*/ function(Component) {
|
|
|
20875
19668
|
* @inheritdoc
|
|
20876
19669
|
*/ _proto._onClone = function _onClone(target) {
|
|
20877
19670
|
target._syncNative();
|
|
20878
|
-
target._pendingReenterTeleport = true;
|
|
20879
19671
|
};
|
|
20880
19672
|
/**
|
|
20881
19673
|
* @internal
|
|
@@ -20903,28 +19695,6 @@ exports.Collider = /*#__PURE__*/ function(Component) {
|
|
|
20903
19695
|
this._addNativeShape(this.shapes[i]);
|
|
20904
19696
|
}
|
|
20905
19697
|
this._setCollisionLayer();
|
|
20906
|
-
// Teleport native actor to entity's current world pose.
|
|
20907
|
-
// The native actor was created in constructor() with the entity's then-current
|
|
20908
|
-
// worldPosition/Rotation. On clone, the entity's transform fields are deep-cloned
|
|
20909
|
-
// AFTER the Component (and its native actor) are constructed, so the native actor's
|
|
20910
|
-
// pose lags behind the cloned entity transform until this sync.
|
|
20911
|
-
var transform = this.entity.transform;
|
|
20912
|
-
this._teleportToEntityTransform(transform.worldPosition, transform.worldRotationQuaternion);
|
|
20913
|
-
};
|
|
20914
|
-
/**
|
|
20915
|
-
* Teleport native actor to a world pose (instant, no implied velocity).
|
|
20916
|
-
* Used during initialization paths (clone) where the native actor must be re-aligned
|
|
20917
|
-
* with the entity transform after construction-time pose was based on stale defaults.
|
|
20918
|
-
*/ _proto._teleportToEntityTransform = function _teleportToEntityTransform(worldPosition, worldRotation) {
|
|
20919
|
-
this._nativeCollider.setWorldTransform(worldPosition, worldRotation);
|
|
20920
|
-
};
|
|
20921
|
-
/**
|
|
20922
|
-
* Sync entity world transform to native actor for per-frame updates.
|
|
20923
|
-
* Default semantics: teleport (setGlobalPose). Subclasses override to express
|
|
20924
|
-
* physics-aware movement (e.g. DynamicCollider routes kinematic actors through
|
|
20925
|
-
* setKinematicTarget to generate contact events on swept motion).
|
|
20926
|
-
*/ _proto._syncEntityTransformToNative = function _syncEntityTransformToNative(worldPosition, worldRotation) {
|
|
20927
|
-
this._nativeCollider.setWorldTransform(worldPosition, worldRotation);
|
|
20928
19698
|
};
|
|
20929
19699
|
/**
|
|
20930
19700
|
* @internal
|
|
@@ -20987,12 +19757,6 @@ __decorate([
|
|
|
20987
19757
|
__decorate([
|
|
20988
19758
|
ignoreClone
|
|
20989
19759
|
], exports.Collider.prototype, "_nativeCollider", void 0);
|
|
20990
|
-
__decorate([
|
|
20991
|
-
ignoreClone
|
|
20992
|
-
], exports.Collider.prototype, "_pendingReenterTeleport", void 0);
|
|
20993
|
-
__decorate([
|
|
20994
|
-
ignoreClone
|
|
20995
|
-
], exports.Collider.prototype, "_enteredScene", void 0);
|
|
20996
19760
|
exports.Collider = __decorate([
|
|
20997
19761
|
dependentComponents(Transform, DependentMode.CheckOnly)
|
|
20998
19762
|
], exports.Collider);
|
|
@@ -21079,9 +19843,6 @@ exports.Collider = __decorate([
|
|
|
21079
19843
|
this._nativeCollider.setUpDirection(this._upDirection);
|
|
21080
19844
|
this._nativeCollider.setSlopeLimit(this._slopeLimit);
|
|
21081
19845
|
};
|
|
21082
|
-
_proto._teleportToEntityTransform = function _teleportToEntityTransform(worldPosition, _worldRotation) {
|
|
21083
|
-
this._nativeCollider.setWorldPosition(worldPosition);
|
|
21084
|
-
};
|
|
21085
19846
|
_proto._syncWorldPositionFromPhysicalSpace = function _syncWorldPositionFromPhysicalSpace() {
|
|
21086
19847
|
this._nativeCollider.getWorldPosition(this.entity.transform.worldPosition);
|
|
21087
19848
|
};
|
|
@@ -21181,7 +19942,7 @@ __decorate([
|
|
|
21181
19942
|
this._staticFriction = 0.6;
|
|
21182
19943
|
this._bounceCombine = PhysicsMaterialCombineMode.Average;
|
|
21183
19944
|
this._frictionCombine = PhysicsMaterialCombineMode.Average;
|
|
21184
|
-
this._nativeMaterial = Engine._nativePhysics.createPhysicsMaterial(this._staticFriction, this._dynamicFriction, this._bounciness, this.
|
|
19945
|
+
this._nativeMaterial = Engine._nativePhysics.createPhysicsMaterial(this._staticFriction, this._dynamicFriction, this._bounciness, this._bounceCombine, this._frictionCombine);
|
|
21185
19946
|
}
|
|
21186
19947
|
var _proto = PhysicsMaterial.prototype;
|
|
21187
19948
|
/**
|
|
@@ -21190,21 +19951,6 @@ __decorate([
|
|
|
21190
19951
|
!this._destroyed && this._nativeMaterial.destroy();
|
|
21191
19952
|
this._destroyed = true;
|
|
21192
19953
|
};
|
|
21193
|
-
/**
|
|
21194
|
-
* @internal
|
|
21195
|
-
*/ _proto._onClone = function _onClone(target) {
|
|
21196
|
-
target._syncNative();
|
|
21197
|
-
};
|
|
21198
|
-
/**
|
|
21199
|
-
* @internal
|
|
21200
|
-
*/ _proto._syncNative = function _syncNative() {
|
|
21201
|
-
var nativeMaterial = this._nativeMaterial;
|
|
21202
|
-
nativeMaterial.setStaticFriction(this._staticFriction);
|
|
21203
|
-
nativeMaterial.setDynamicFriction(this._dynamicFriction);
|
|
21204
|
-
nativeMaterial.setBounciness(this._bounciness);
|
|
21205
|
-
nativeMaterial.setFrictionCombine(this._frictionCombine);
|
|
21206
|
-
nativeMaterial.setBounceCombine(this._bounceCombine);
|
|
21207
|
-
};
|
|
21208
19954
|
_create_class(PhysicsMaterial, [
|
|
21209
19955
|
{
|
|
21210
19956
|
key: "bounciness",
|
|
@@ -21279,9 +20025,6 @@ __decorate([
|
|
|
21279
20025
|
]);
|
|
21280
20026
|
return PhysicsMaterial;
|
|
21281
20027
|
}();
|
|
21282
|
-
__decorate([
|
|
21283
|
-
ignoreClone
|
|
21284
|
-
], PhysicsMaterial.prototype, "_nativeMaterial", void 0);
|
|
21285
20028
|
|
|
21286
20029
|
/**
|
|
21287
20030
|
* Abstract class for collider shapes.
|
|
@@ -21289,7 +20032,7 @@ __decorate([
|
|
|
21289
20032
|
_inherits(ColliderShape, DataObject);
|
|
21290
20033
|
function ColliderShape() {
|
|
21291
20034
|
var _this;
|
|
21292
|
-
_this = DataObject.call(this) || this, /** @internal */ _this._isShapeAttached = false, _this._isTrigger = false, _this._rotation = new engineMath.Vector3(), _this._position = new engineMath.Vector3(), /**
|
|
20035
|
+
_this = DataObject.call(this) || this, /** @internal */ _this._isShapeAttached = false, _this._isTrigger = false, _this._rotation = new engineMath.Vector3(), _this._position = new engineMath.Vector3(), _this._contactOffset = 0.02, /**
|
|
21293
20036
|
* @internal
|
|
21294
20037
|
* @beta
|
|
21295
20038
|
* Whether raycast can select it.
|
|
@@ -21345,9 +20088,7 @@ __decorate([
|
|
|
21345
20088
|
if (!this._nativeShape) return;
|
|
21346
20089
|
this._nativeShape.setPosition(this._position);
|
|
21347
20090
|
this._nativeShape.setRotation(this._rotation);
|
|
21348
|
-
|
|
21349
|
-
this._nativeShape.setContactOffset(this._contactOffset);
|
|
21350
|
-
}
|
|
20091
|
+
this._nativeShape.setContactOffset(this._contactOffset);
|
|
21351
20092
|
this._nativeShape.setIsTrigger(this._isTrigger);
|
|
21352
20093
|
this._nativeShape.setMaterial(this._material._nativeMaterial);
|
|
21353
20094
|
(_this__collider = this._collider) == null ? void 0 : _this__collider._handleShapesChanged(ColliderShapeChangeFlag.Property);
|
|
@@ -21385,9 +20126,7 @@ __decorate([
|
|
|
21385
20126
|
* Contact offset for this shape, the value must be greater than or equal to 0.
|
|
21386
20127
|
* @defaultValue 0.02
|
|
21387
20128
|
*/ function get() {
|
|
21388
|
-
|
|
21389
|
-
var _this__contactOffset, _ref;
|
|
21390
|
-
return (_ref = (_this__contactOffset = this._contactOffset) != null ? _this__contactOffset : (_Engine__nativePhysics = Engine._nativePhysics) == null ? void 0 : (_Engine__nativePhysics_getDefaultContactOffset = _Engine__nativePhysics.getDefaultContactOffset) == null ? void 0 : _Engine__nativePhysics_getDefaultContactOffset.call(_Engine__nativePhysics)) != null ? _ref : 0.02;
|
|
20129
|
+
return this._contactOffset;
|
|
21391
20130
|
},
|
|
21392
20131
|
set: function set(value) {
|
|
21393
20132
|
value = Math.max(0, value);
|
|
@@ -21466,10 +20205,10 @@ __decorate([
|
|
|
21466
20205
|
], ColliderShape.prototype, "_collider", void 0);
|
|
21467
20206
|
__decorate([
|
|
21468
20207
|
ignoreClone
|
|
21469
|
-
], ColliderShape.prototype, "
|
|
20208
|
+
], ColliderShape.prototype, "_nativeShape", void 0);
|
|
21470
20209
|
__decorate([
|
|
21471
20210
|
ignoreClone
|
|
21472
|
-
], ColliderShape.prototype, "
|
|
20211
|
+
], ColliderShape.prototype, "_isShapeAttached", void 0);
|
|
21473
20212
|
__decorate([
|
|
21474
20213
|
ignoreClone
|
|
21475
20214
|
], ColliderShape.prototype, "_id", void 0);
|
|
@@ -21550,29 +20289,25 @@ __decorate([
|
|
|
21550
20289
|
return true;
|
|
21551
20290
|
};
|
|
21552
20291
|
_proto._updateNativeShapeData = function _updateNativeShapeData() {
|
|
20292
|
+
var _this__collider;
|
|
21553
20293
|
var succeeded = this._nativeShape.setMeshData(this._positions, this._indices, this._isConvex, this._cookingFlags);
|
|
21554
|
-
|
|
21555
|
-
var _this__collider;
|
|
21556
|
-
(_this__collider = this._collider) == null ? void 0 : _this__collider._setNativeShapeAttached(this, true);
|
|
21557
|
-
}
|
|
21558
|
-
return succeeded;
|
|
20294
|
+
(_this__collider = this._collider) == null ? void 0 : _this__collider._setNativeShapeAttached(this, succeeded);
|
|
21559
20295
|
};
|
|
21560
20296
|
_proto._createNativeShape = function _createNativeShape() {
|
|
21561
20297
|
var _this__collider;
|
|
21562
20298
|
// Non-convex MeshColliderShape is only supported on StaticCollider or kinematic DynamicCollider
|
|
21563
20299
|
if (!this._isConvex && _instanceof(this._collider, DynamicCollider) && !this._collider.isKinematic) {
|
|
21564
20300
|
console.error("MeshColliderShape: Non-convex mesh is not supported on non-kinematic DynamicCollider.");
|
|
21565
|
-
return
|
|
20301
|
+
return;
|
|
21566
20302
|
}
|
|
21567
20303
|
var nativeShape = Engine._nativePhysics.createMeshColliderShape(this._id, this._positions, this._indices, this._isConvex, this._material._nativeMaterial, this._cookingFlags);
|
|
21568
20304
|
if (!nativeShape) {
|
|
21569
|
-
return
|
|
20305
|
+
return;
|
|
21570
20306
|
}
|
|
21571
20307
|
this._nativeShape = nativeShape;
|
|
21572
20308
|
// Sync base class properties (position, rotation, contactOffset, isTrigger, material)
|
|
21573
20309
|
ColliderShape.prototype._syncNative.call(this);
|
|
21574
20310
|
(_this__collider = this._collider) == null ? void 0 : _this__collider._setNativeShapeAttached(this, true);
|
|
21575
|
-
return true;
|
|
21576
20311
|
};
|
|
21577
20312
|
_create_class(MeshColliderShape, [
|
|
21578
20313
|
{
|
|
@@ -21584,17 +20319,9 @@ __decorate([
|
|
|
21584
20319
|
},
|
|
21585
20320
|
set: function set(value) {
|
|
21586
20321
|
if (this._cookingFlags !== value) {
|
|
21587
|
-
var previousValue = this._cookingFlags;
|
|
21588
20322
|
this._cookingFlags = value;
|
|
21589
20323
|
if (this._nativeShape) {
|
|
21590
|
-
|
|
21591
|
-
try {
|
|
21592
|
-
updated = this._updateNativeShapeData();
|
|
21593
|
-
} finally{
|
|
21594
|
-
if (!updated) {
|
|
21595
|
-
this._cookingFlags = previousValue;
|
|
21596
|
-
}
|
|
21597
|
-
}
|
|
20324
|
+
this._updateNativeShapeData();
|
|
21598
20325
|
} else if (this._mesh && this._extractMeshData(this._mesh)) {
|
|
21599
20326
|
this._createNativeShape();
|
|
21600
20327
|
}
|
|
@@ -21638,34 +20365,14 @@ __decorate([
|
|
|
21638
20365
|
set: function set(value) {
|
|
21639
20366
|
if (this._mesh !== value) {
|
|
21640
20367
|
var _this__mesh;
|
|
21641
|
-
var previousMesh = this._mesh;
|
|
21642
|
-
var previousPositions = this._positions;
|
|
21643
|
-
var previousIndices = this._indices;
|
|
21644
20368
|
(_this__mesh = this._mesh) == null ? void 0 : _this__mesh._addReferCount(-1);
|
|
21645
20369
|
value == null ? void 0 : value._addReferCount(1);
|
|
21646
20370
|
this._mesh = value;
|
|
21647
|
-
if (value) {
|
|
21648
|
-
if (this.
|
|
21649
|
-
|
|
21650
|
-
var updated = false;
|
|
21651
|
-
try {
|
|
21652
|
-
updated = this._updateNativeShapeData();
|
|
21653
|
-
} finally{
|
|
21654
|
-
if (!updated) {
|
|
21655
|
-
value == null ? void 0 : value._addReferCount(-1);
|
|
21656
|
-
previousMesh == null ? void 0 : previousMesh._addReferCount(1);
|
|
21657
|
-
this._mesh = previousMesh;
|
|
21658
|
-
this._positions = previousPositions;
|
|
21659
|
-
this._indices = previousIndices;
|
|
21660
|
-
}
|
|
21661
|
-
}
|
|
21662
|
-
} else {
|
|
21663
|
-
this._createNativeShape();
|
|
21664
|
-
}
|
|
20371
|
+
if (value && this._extractMeshData(value)) {
|
|
20372
|
+
if (this._nativeShape) {
|
|
20373
|
+
this._updateNativeShapeData();
|
|
21665
20374
|
} else {
|
|
21666
|
-
|
|
21667
|
-
this._destroyNativeShape();
|
|
21668
|
-
this._clearMeshData();
|
|
20375
|
+
this._createNativeShape();
|
|
21669
20376
|
}
|
|
21670
20377
|
} else {
|
|
21671
20378
|
this._destroyNativeShape();
|
|
@@ -21693,7 +20400,7 @@ __decorate([
|
|
|
21693
20400
|
_inherits(DynamicCollider, Collider);
|
|
21694
20401
|
function DynamicCollider(entity) {
|
|
21695
20402
|
var _this;
|
|
21696
|
-
_this = Collider.call(this, entity) || this, _this._linearDamping = 0, _this._angularDamping = 0.05, _this._linearVelocity = new engineMath.Vector3(), _this._angularVelocity = new engineMath.Vector3(), _this._mass = 1.0, _this._centerOfMass = new engineMath.Vector3(), _this._inertiaTensor = new engineMath.Vector3(1, 1, 1), _this._maxAngularVelocity = 18000 / Math.PI, _this._maxDepenetrationVelocity = 1.0000000331813535e32, _this._solverIterations = 4, _this._useGravity = true, _this._isKinematic = false, _this._constraints = 0, _this._collisionDetectionMode = 0, _this.
|
|
20403
|
+
_this = Collider.call(this, entity) || this, _this._linearDamping = 0, _this._angularDamping = 0.05, _this._linearVelocity = new engineMath.Vector3(), _this._angularVelocity = new engineMath.Vector3(), _this._mass = 1.0, _this._centerOfMass = new engineMath.Vector3(), _this._inertiaTensor = new engineMath.Vector3(1, 1, 1), _this._maxAngularVelocity = 18000 / Math.PI, _this._maxDepenetrationVelocity = 1.0000000331813535e32, _this._solverIterations = 4, _this._useGravity = true, _this._isKinematic = false, _this._constraints = 0, _this._collisionDetectionMode = 0, _this._sleepThreshold = 5e-3, _this._automaticCenterOfMass = true, _this._automaticInertiaTensor = true;
|
|
21697
20404
|
var transform = _this.entity.transform;
|
|
21698
20405
|
_this._nativeCollider = Engine._nativePhysics.createDynamicCollider(transform.worldPosition, transform.worldRotationQuaternion);
|
|
21699
20406
|
_this._setLinearVelocity = _this._setLinearVelocity.bind(_this);
|
|
@@ -21763,28 +20470,6 @@ __decorate([
|
|
|
21763
20470
|
Collider.prototype.addShape.call(this, shape);
|
|
21764
20471
|
};
|
|
21765
20472
|
/**
|
|
21766
|
-
* Route per-frame entity → native transform sync to the correct physics API based
|
|
21767
|
-
* on kinematic state.
|
|
21768
|
-
*
|
|
21769
|
-
* PhysX 4.x docs (PxRigidDynamic):
|
|
21770
|
-
* "If you intend to move a kinematic actor with [setGlobalPose] and want
|
|
21771
|
-
* collision detection, use setKinematicTarget() instead."
|
|
21772
|
-
*
|
|
21773
|
-
* setGlobalPose is a teleport: PhysX skips contact detection between the old
|
|
21774
|
-
* and new pose. setKinematicTarget tells PhysX the actor is animating to the
|
|
21775
|
-
* target during the next simulate(), enabling swept contacts. Some compatibility
|
|
21776
|
-
* layers need transform writes to stay teleport-like, so the sync mode is
|
|
21777
|
-
* explicit while {@link move} always keeps target semantics.
|
|
21778
|
-
*
|
|
21779
|
-
* @internal
|
|
21780
|
-
*/ _proto._syncEntityTransformToNative = function _syncEntityTransformToNative(worldPosition, worldRotation) {
|
|
21781
|
-
if (this._isKinematic && this._kinematicTransformSyncMode === 0) {
|
|
21782
|
-
this._nativeCollider.move(worldPosition, worldRotation);
|
|
21783
|
-
} else {
|
|
21784
|
-
Collider.prototype._syncEntityTransformToNative.call(this, worldPosition, worldRotation);
|
|
21785
|
-
}
|
|
21786
|
-
};
|
|
21787
|
-
/**
|
|
21788
20473
|
* @internal
|
|
21789
20474
|
*/ _proto._onLateUpdate = function _onLateUpdate() {
|
|
21790
20475
|
var transform = this.entity.transform;
|
|
@@ -21806,12 +20491,8 @@ __decorate([
|
|
|
21806
20491
|
*/ _proto._onClone = function _onClone(target) {
|
|
21807
20492
|
target._linearVelocity.copyFrom(this.linearVelocity);
|
|
21808
20493
|
target._angularVelocity.copyFrom(this.angularVelocity);
|
|
21809
|
-
|
|
21810
|
-
|
|
21811
|
-
}
|
|
21812
|
-
if (!this._automaticInertiaTensor) {
|
|
21813
|
-
target._inertiaTensor.copyFrom(this.inertiaTensor);
|
|
21814
|
-
}
|
|
20494
|
+
target._centerOfMass.copyFrom(this.centerOfMass);
|
|
20495
|
+
target._inertiaTensor.copyFrom(this.inertiaTensor);
|
|
21815
20496
|
Collider.prototype._onClone.call(this, target);
|
|
21816
20497
|
};
|
|
21817
20498
|
/**
|
|
@@ -21839,9 +20520,7 @@ __decorate([
|
|
|
21839
20520
|
}
|
|
21840
20521
|
this._nativeCollider.setMaxAngularVelocity(this._maxAngularVelocity);
|
|
21841
20522
|
this._nativeCollider.setMaxDepenetrationVelocity(this._maxDepenetrationVelocity);
|
|
21842
|
-
|
|
21843
|
-
this._nativeCollider.setSleepThreshold(this._sleepThreshold);
|
|
21844
|
-
}
|
|
20523
|
+
this._nativeCollider.setSleepThreshold(this._sleepThreshold);
|
|
21845
20524
|
this._nativeCollider.setSolverIterations(this._solverIterations);
|
|
21846
20525
|
this._nativeCollider.setUseGravity(this._useGravity);
|
|
21847
20526
|
this._nativeCollider.setConstraints(this._constraints);
|
|
@@ -22064,9 +20743,7 @@ __decorate([
|
|
|
22064
20743
|
get: /**
|
|
22065
20744
|
* The mass-normalized energy threshold, below which objects start going to sleep.
|
|
22066
20745
|
*/ function get() {
|
|
22067
|
-
|
|
22068
|
-
var _this__sleepThreshold, _ref;
|
|
22069
|
-
return (_ref = (_this__sleepThreshold = this._sleepThreshold) != null ? _this__sleepThreshold : (_Engine__nativePhysics = Engine._nativePhysics) == null ? void 0 : (_Engine__nativePhysics_getDefaultSleepThreshold = _Engine__nativePhysics.getDefaultSleepThreshold) == null ? void 0 : _Engine__nativePhysics_getDefaultSleepThreshold.call(_Engine__nativePhysics)) != null ? _ref : 5e-3;
|
|
20746
|
+
return this._sleepThreshold;
|
|
22070
20747
|
},
|
|
22071
20748
|
set: function set(value) {
|
|
22072
20749
|
if (value !== this._sleepThreshold) {
|
|
@@ -22162,22 +20839,6 @@ __decorate([
|
|
|
22162
20839
|
this._nativeCollider.setCollisionDetectionMode(value);
|
|
22163
20840
|
}
|
|
22164
20841
|
}
|
|
22165
|
-
},
|
|
22166
|
-
{
|
|
22167
|
-
key: "kinematicTransformSyncMode",
|
|
22168
|
-
get: /**
|
|
22169
|
-
* Controls how entity transform changes are synchronized to a kinematic native actor.
|
|
22170
|
-
*
|
|
22171
|
-
* @remarks
|
|
22172
|
-
* `Target` routes transform changes through {@link move}, so PhysX treats the
|
|
22173
|
-
* actor as moving between frames and can generate swept contacts. `Teleport`
|
|
22174
|
-
* writes the native pose directly and does not imply velocity.
|
|
22175
|
-
*/ function get() {
|
|
22176
|
-
return this._kinematicTransformSyncMode;
|
|
22177
|
-
},
|
|
22178
|
-
set: function set(value) {
|
|
22179
|
-
this._kinematicTransformSyncMode = value;
|
|
22180
|
-
}
|
|
22181
20842
|
}
|
|
22182
20843
|
]);
|
|
22183
20844
|
return DynamicCollider;
|
|
@@ -22217,13 +20878,6 @@ __decorate([
|
|
|
22217
20878
|
/** Speculative continuous collision detection is on for static and dynamic geometries */ CollisionDetectionMode[CollisionDetectionMode["ContinuousSpeculative"] = 3] = "ContinuousSpeculative";
|
|
22218
20879
|
return CollisionDetectionMode;
|
|
22219
20880
|
}({});
|
|
22220
|
-
/**
|
|
22221
|
-
* Kinematic transform synchronization mode.
|
|
22222
|
-
*/ var DynamicColliderKinematicTransformSyncMode = /*#__PURE__*/ function(DynamicColliderKinematicTransformSyncMode) {
|
|
22223
|
-
/** Synchronize transform changes through PhysX setKinematicTarget. */ DynamicColliderKinematicTransformSyncMode[DynamicColliderKinematicTransformSyncMode["Target"] = 0] = "Target";
|
|
22224
|
-
/** Synchronize transform changes by directly teleporting the native actor. */ DynamicColliderKinematicTransformSyncMode[DynamicColliderKinematicTransformSyncMode["Teleport"] = 1] = "Teleport";
|
|
22225
|
-
return DynamicColliderKinematicTransformSyncMode;
|
|
22226
|
-
}({});
|
|
22227
20881
|
/**
|
|
22228
20882
|
* Use these flags to constrain motion of dynamic collider.
|
|
22229
20883
|
*/ var DynamicColliderConstraints = /*#__PURE__*/ function(DynamicColliderConstraints) {
|
|
@@ -22247,228 +20901,6 @@ __decorate([
|
|
|
22247
20901
|
/** The shape of the collider that was hit. */ this.shape = null;
|
|
22248
20902
|
};
|
|
22249
20903
|
|
|
22250
|
-
/**
|
|
22251
|
-
* Script class, used for logic writing.
|
|
22252
|
-
*/ var Script = /*#__PURE__*/ function(Component) {
|
|
22253
|
-
_inherits(Script, Component);
|
|
22254
|
-
function Script() {
|
|
22255
|
-
var _this;
|
|
22256
|
-
_this = Component.apply(this, arguments) || this, /** @internal */ _this._started = false, /** @internal */ _this._onStartIndex = -1, /** @internal */ _this._onUpdateIndex = -1, /** @internal */ _this._onLateUpdateIndex = -1, /** @internal */ _this._onPhysicsUpdateIndex = -1, /** @internal */ _this._onPreRenderIndex = -1, /** @internal */ _this._onPostRenderIndex = -1, /** @internal */ _this._entityScriptsIndex = -1;
|
|
22257
|
-
return _this;
|
|
22258
|
-
}
|
|
22259
|
-
var _proto = Script.prototype;
|
|
22260
|
-
/**
|
|
22261
|
-
* Called when be enabled first time, only once.
|
|
22262
|
-
*/ _proto.onAwake = function onAwake() {};
|
|
22263
|
-
/**
|
|
22264
|
-
* Called when be enabled.
|
|
22265
|
-
*/ _proto.onEnable = function onEnable() {};
|
|
22266
|
-
/**
|
|
22267
|
-
* Called before the frame-level loop start for the first time, only once.
|
|
22268
|
-
*/ _proto.onStart = function onStart() {};
|
|
22269
|
-
/**
|
|
22270
|
-
* The main loop, called frame by frame.
|
|
22271
|
-
* @param deltaTime - The delta time since last frame in seconds
|
|
22272
|
-
*/ _proto.onUpdate = function onUpdate(deltaTime) {};
|
|
22273
|
-
/**
|
|
22274
|
-
* Called after the onUpdate finished, called frame by frame.
|
|
22275
|
-
* @param deltaTime - The delta time since last frame in seconds
|
|
22276
|
-
*/ _proto.onLateUpdate = function onLateUpdate(deltaTime) {};
|
|
22277
|
-
/**
|
|
22278
|
-
* Called before camera rendering, called per camera.
|
|
22279
|
-
* @param camera - Current camera.
|
|
22280
|
-
*/ _proto.onBeginRender = function onBeginRender(camera) {};
|
|
22281
|
-
/**
|
|
22282
|
-
* Called after camera rendering, called per camera.
|
|
22283
|
-
* @param camera - Current camera.
|
|
22284
|
-
*/ _proto.onEndRender = function onEndRender(camera) {};
|
|
22285
|
-
/**
|
|
22286
|
-
* Called before physics calculations, the number of times is related to the physical update frequency.
|
|
22287
|
-
*/ _proto.onPhysicsUpdate = function onPhysicsUpdate() {};
|
|
22288
|
-
/**
|
|
22289
|
-
* Called when the trigger enter.
|
|
22290
|
-
* @param other - ColliderShape
|
|
22291
|
-
*/ _proto.onTriggerEnter = function onTriggerEnter(other) {};
|
|
22292
|
-
/**
|
|
22293
|
-
* Called when the trigger exit.
|
|
22294
|
-
* @param other - ColliderShape
|
|
22295
|
-
*/ _proto.onTriggerExit = function onTriggerExit(other) {};
|
|
22296
|
-
/**
|
|
22297
|
-
* Called when the trigger stay.
|
|
22298
|
-
* @remarks onTriggerStay is called every frame while the trigger stay.
|
|
22299
|
-
* @param other - ColliderShape
|
|
22300
|
-
*/ _proto.onTriggerStay = function onTriggerStay(other) {};
|
|
22301
|
-
/**
|
|
22302
|
-
* Called when the collision enter.
|
|
22303
|
-
* @param other - The Collision data associated with this collision event
|
|
22304
|
-
* @remarks The Collision data will be invalid after this call, you should copy the data if needed.
|
|
22305
|
-
*/ _proto.onCollisionEnter = function onCollisionEnter(other) {};
|
|
22306
|
-
/**
|
|
22307
|
-
* Called when the collision exit.
|
|
22308
|
-
* @param other - The Collision data associated with this collision event
|
|
22309
|
-
* @remarks The Collision data will be invalid after this call, you should copy the data if needed.
|
|
22310
|
-
*/ _proto.onCollisionExit = function onCollisionExit(other) {};
|
|
22311
|
-
/**
|
|
22312
|
-
* Called when the collision stay.
|
|
22313
|
-
* @param other - The Collision data associated with this collision event
|
|
22314
|
-
* @remarks The Collision data will be invalid after this call, you should copy the data if needed.
|
|
22315
|
-
*/ _proto.onCollisionStay = function onCollisionStay(other) {};
|
|
22316
|
-
/**
|
|
22317
|
-
* Called when the pointer is down while over the ColliderShape.
|
|
22318
|
-
* @param eventData - The pointer event data that triggered this callback
|
|
22319
|
-
*/ _proto.onPointerDown = function onPointerDown(eventData) {};
|
|
22320
|
-
/**
|
|
22321
|
-
* Called when the pointer is up while over the ColliderShape.
|
|
22322
|
-
* @param eventData - The pointer event data that triggered this callback
|
|
22323
|
-
*/ _proto.onPointerUp = function onPointerUp(eventData) {};
|
|
22324
|
-
/**
|
|
22325
|
-
* Called when the pointer is down and up with the same collider.
|
|
22326
|
-
* @param eventData - The pointer event data that triggered this callback
|
|
22327
|
-
*/ _proto.onPointerClick = function onPointerClick(eventData) {};
|
|
22328
|
-
/**
|
|
22329
|
-
* Called when the pointer enters the ColliderShape.
|
|
22330
|
-
* @param eventData - The pointer event data that triggered this callback
|
|
22331
|
-
*/ _proto.onPointerEnter = function onPointerEnter(eventData) {};
|
|
22332
|
-
/**
|
|
22333
|
-
* Called when the pointer exits the ColliderShape.
|
|
22334
|
-
* @param eventData - The pointer event data that triggered this callback
|
|
22335
|
-
*/ _proto.onPointerExit = function onPointerExit(eventData) {};
|
|
22336
|
-
/**
|
|
22337
|
-
* This function will be called when the pointer is pressed on the collider.
|
|
22338
|
-
* @param eventData - The pointer event data that triggered this callback
|
|
22339
|
-
*/ _proto.onPointerBeginDrag = function onPointerBeginDrag(eventData) {};
|
|
22340
|
-
/**
|
|
22341
|
-
* When a drag collision occurs on the pointer, this function will be called every time it moves.
|
|
22342
|
-
* @param eventData - The pointer event data that triggered this callback
|
|
22343
|
-
*/ _proto.onPointerDrag = function onPointerDrag(eventData) {};
|
|
22344
|
-
/**
|
|
22345
|
-
* When dragging ends, this function will be called (Dragged object).
|
|
22346
|
-
* @param eventData - The pointer event data that triggered this callback
|
|
22347
|
-
*/ _proto.onPointerEndDrag = function onPointerEndDrag(eventData) {};
|
|
22348
|
-
/**
|
|
22349
|
-
* When dragging ends, this function will be called (Receiving object).
|
|
22350
|
-
* @param eventData - The pointer event data that triggered this callback
|
|
22351
|
-
*/ _proto.onPointerDrop = function onPointerDrop(eventData) {};
|
|
22352
|
-
/**
|
|
22353
|
-
* Called when be disabled.
|
|
22354
|
-
*/ _proto.onDisable = function onDisable() {};
|
|
22355
|
-
/**
|
|
22356
|
-
* Called at the end of the destroyed frame.
|
|
22357
|
-
*/ _proto.onDestroy = function onDestroy() {};
|
|
22358
|
-
/**
|
|
22359
|
-
* @internal
|
|
22360
|
-
*/ _proto._onAwake = function _onAwake() {
|
|
22361
|
-
this.onAwake();
|
|
22362
|
-
};
|
|
22363
|
-
/**
|
|
22364
|
-
* @internal
|
|
22365
|
-
*/ _proto._onEnable = function _onEnable() {
|
|
22366
|
-
this.onEnable();
|
|
22367
|
-
};
|
|
22368
|
-
/**
|
|
22369
|
-
* @internal
|
|
22370
|
-
*/ _proto._onDisable = function _onDisable() {
|
|
22371
|
-
this.onDisable();
|
|
22372
|
-
};
|
|
22373
|
-
/**
|
|
22374
|
-
* @internal
|
|
22375
|
-
*/ _proto._onEnableInScene = function _onEnableInScene() {
|
|
22376
|
-
var _this_scene = this.scene, componentsManager = _this_scene._componentsManager;
|
|
22377
|
-
var prototype = Script.prototype;
|
|
22378
|
-
if (!this._started) {
|
|
22379
|
-
componentsManager.addOnStartScript(this);
|
|
22380
|
-
}
|
|
22381
|
-
if (this.onUpdate !== prototype.onUpdate) {
|
|
22382
|
-
componentsManager.addOnUpdateScript(this);
|
|
22383
|
-
}
|
|
22384
|
-
if (this.onLateUpdate !== prototype.onLateUpdate) {
|
|
22385
|
-
componentsManager.addOnLateUpdateScript(this);
|
|
22386
|
-
}
|
|
22387
|
-
if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
|
|
22388
|
-
componentsManager.addOnPhysicsUpdateScript(this);
|
|
22389
|
-
}
|
|
22390
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.values(PointerMethods)), _step; !(_step = _iterator()).done;){
|
|
22391
|
-
var pointerMethod = _step.value;
|
|
22392
|
-
if (this[pointerMethod] === prototype[pointerMethod]) {
|
|
22393
|
-
this[pointerMethod] = null;
|
|
22394
|
-
}
|
|
22395
|
-
}
|
|
22396
|
-
this._entity._addScript(this);
|
|
22397
|
-
if (this._hasCollisionEventCallbacks()) {
|
|
22398
|
-
this.scene.physics._markCollisionEventConsumersDirty();
|
|
22399
|
-
}
|
|
22400
|
-
};
|
|
22401
|
-
/**
|
|
22402
|
-
* @internal
|
|
22403
|
-
*/ _proto._onDisableInScene = function _onDisableInScene() {
|
|
22404
|
-
var componentsManager = this.scene._componentsManager;
|
|
22405
|
-
var prototype = Script.prototype;
|
|
22406
|
-
if (!this._started) {
|
|
22407
|
-
componentsManager.removeOnStartScript(this);
|
|
22408
|
-
}
|
|
22409
|
-
if (this.onUpdate !== prototype.onUpdate) {
|
|
22410
|
-
componentsManager.removeOnUpdateScript(this);
|
|
22411
|
-
}
|
|
22412
|
-
if (this.onLateUpdate !== prototype.onLateUpdate) {
|
|
22413
|
-
componentsManager.removeOnLateUpdateScript(this);
|
|
22414
|
-
}
|
|
22415
|
-
if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
|
|
22416
|
-
componentsManager.removeOnPhysicsUpdateScript(this);
|
|
22417
|
-
}
|
|
22418
|
-
this._entity._removeScript(this);
|
|
22419
|
-
if (this._hasCollisionEventCallbacks()) {
|
|
22420
|
-
this.scene.physics._markCollisionEventConsumersDirty();
|
|
22421
|
-
}
|
|
22422
|
-
};
|
|
22423
|
-
_proto._hasCollisionEventCallbacks = function _hasCollisionEventCallbacks() {
|
|
22424
|
-
var prototype = Script.prototype;
|
|
22425
|
-
return this.onCollisionEnter !== prototype.onCollisionEnter || this.onCollisionExit !== prototype.onCollisionExit || this.onCollisionStay !== prototype.onCollisionStay;
|
|
22426
|
-
};
|
|
22427
|
-
/**
|
|
22428
|
-
* @internal
|
|
22429
|
-
*/ _proto._onDestroy = function _onDestroy() {
|
|
22430
|
-
Component.prototype._onDestroy.call(this);
|
|
22431
|
-
this.onDestroy();
|
|
22432
|
-
};
|
|
22433
|
-
return Script;
|
|
22434
|
-
}(Component);
|
|
22435
|
-
__decorate([
|
|
22436
|
-
ignoreClone
|
|
22437
|
-
], Script.prototype, "_started", void 0);
|
|
22438
|
-
__decorate([
|
|
22439
|
-
ignoreClone
|
|
22440
|
-
], Script.prototype, "_onStartIndex", void 0);
|
|
22441
|
-
__decorate([
|
|
22442
|
-
ignoreClone
|
|
22443
|
-
], Script.prototype, "_onUpdateIndex", void 0);
|
|
22444
|
-
__decorate([
|
|
22445
|
-
ignoreClone
|
|
22446
|
-
], Script.prototype, "_onLateUpdateIndex", void 0);
|
|
22447
|
-
__decorate([
|
|
22448
|
-
ignoreClone
|
|
22449
|
-
], Script.prototype, "_onPhysicsUpdateIndex", void 0);
|
|
22450
|
-
__decorate([
|
|
22451
|
-
ignoreClone
|
|
22452
|
-
], Script.prototype, "_onPreRenderIndex", void 0);
|
|
22453
|
-
__decorate([
|
|
22454
|
-
ignoreClone
|
|
22455
|
-
], Script.prototype, "_onPostRenderIndex", void 0);
|
|
22456
|
-
__decorate([
|
|
22457
|
-
ignoreClone
|
|
22458
|
-
], Script.prototype, "_entityScriptsIndex", void 0);
|
|
22459
|
-
var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
22460
|
-
PointerMethods["onPointerDown"] = "onPointerDown";
|
|
22461
|
-
PointerMethods["onPointerUp"] = "onPointerUp";
|
|
22462
|
-
PointerMethods["onPointerClick"] = "onPointerClick";
|
|
22463
|
-
PointerMethods["onPointerEnter"] = "onPointerEnter";
|
|
22464
|
-
PointerMethods["onPointerExit"] = "onPointerExit";
|
|
22465
|
-
PointerMethods["onPointerBeginDrag"] = "onPointerBeginDrag";
|
|
22466
|
-
PointerMethods["onPointerDrag"] = "onPointerDrag";
|
|
22467
|
-
PointerMethods["onPointerEndDrag"] = "onPointerEndDrag";
|
|
22468
|
-
PointerMethods["onPointerDrop"] = "onPointerDrop";
|
|
22469
|
-
return PointerMethods;
|
|
22470
|
-
}({});
|
|
22471
|
-
|
|
22472
20904
|
/**
|
|
22473
20905
|
* Describes a contact point where the collision occurs.
|
|
22474
20906
|
*/ var ContactPoint = function ContactPoint() {
|
|
@@ -22491,7 +20923,8 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
22491
20923
|
* You need to obtain the actual number of contact points from the function's return value.
|
|
22492
20924
|
*/ _proto.getContacts = function getContacts(outContacts) {
|
|
22493
20925
|
var nativeCollision = this._nativeCollision;
|
|
22494
|
-
var
|
|
20926
|
+
var smallerShapeId = Math.min(nativeCollision.shape0Id, nativeCollision.shape1Id);
|
|
20927
|
+
var factor = this.shape.id === smallerShapeId ? 1 : -1;
|
|
22495
20928
|
var nativeContactPoints = nativeCollision.getContacts();
|
|
22496
20929
|
var length = nativeContactPoints.size();
|
|
22497
20930
|
for(var i = 0; i < length; i++){
|
|
@@ -22524,11 +20957,8 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
22524
20957
|
function PhysicsScene(scene) {
|
|
22525
20958
|
this._restTime = 0;
|
|
22526
20959
|
this._fixedTimeStep = 1 / 60;
|
|
22527
|
-
this._maximumDeltaTime = Infinity;
|
|
22528
20960
|
this._colliders = new DisorderedArray();
|
|
22529
20961
|
this._gravity = new engineMath.Vector3(0, -9.81, 0);
|
|
22530
|
-
this._collisionEventConsumersDirty = true;
|
|
22531
|
-
this._hasCollisionEventConsumersCache = false;
|
|
22532
20962
|
this._scene = scene;
|
|
22533
20963
|
this._setGravity = this._setGravity.bind(this);
|
|
22534
20964
|
//@ts-ignore
|
|
@@ -22739,13 +21169,12 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
22739
21169
|
*/ _proto._update = function _update(deltaTime) {
|
|
22740
21170
|
var _this = this, fixedTimeStep = _this._fixedTimeStep, nativePhysicsManager = _this._nativePhysicsScene;
|
|
22741
21171
|
var componentsManager = this._scene._componentsManager;
|
|
22742
|
-
var simulateTime = this._restTime +
|
|
21172
|
+
var simulateTime = this._restTime + deltaTime;
|
|
22743
21173
|
var step = Math.floor(simulateTime / fixedTimeStep);
|
|
22744
21174
|
this._restTime = simulateTime - step * fixedTimeStep;
|
|
22745
21175
|
for(var i = 0; i < step; i++){
|
|
22746
21176
|
componentsManager.callScriptOnPhysicsUpdate();
|
|
22747
21177
|
this._callColliderOnUpdate();
|
|
22748
|
-
this._syncContactEventDemand();
|
|
22749
21178
|
nativePhysicsManager.update(fixedTimeStep);
|
|
22750
21179
|
this._callColliderOnLateUpdate();
|
|
22751
21180
|
this._dispatchEvents(nativePhysicsManager.updateEvents());
|
|
@@ -22759,7 +21188,6 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
22759
21188
|
if (collider._index === -1) {
|
|
22760
21189
|
collider._index = this._colliders.length;
|
|
22761
21190
|
this._colliders.add(collider);
|
|
22762
|
-
this._markCollisionEventConsumersDirty();
|
|
22763
21191
|
}
|
|
22764
21192
|
this._nativePhysicsScene.addCollider(collider._nativeCollider);
|
|
22765
21193
|
};
|
|
@@ -22771,7 +21199,6 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
22771
21199
|
if (controller._index === -1) {
|
|
22772
21200
|
controller._index = this._colliders.length;
|
|
22773
21201
|
this._colliders.add(controller);
|
|
22774
|
-
this._markCollisionEventConsumersDirty();
|
|
22775
21202
|
}
|
|
22776
21203
|
this._nativePhysicsScene.addCharacterController(controller._nativeCollider);
|
|
22777
21204
|
};
|
|
@@ -22783,7 +21210,6 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
22783
21210
|
var replaced = this._colliders.deleteByIndex(collider._index);
|
|
22784
21211
|
replaced && (replaced._index = collider._index);
|
|
22785
21212
|
collider._index = -1;
|
|
22786
|
-
this._markCollisionEventConsumersDirty();
|
|
22787
21213
|
this._nativePhysicsScene.removeCollider(collider._nativeCollider);
|
|
22788
21214
|
};
|
|
22789
21215
|
/**
|
|
@@ -22794,16 +21220,10 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
22794
21220
|
var replaced = this._colliders.deleteByIndex(controller._index);
|
|
22795
21221
|
replaced && (replaced._index = controller._index);
|
|
22796
21222
|
controller._index = -1;
|
|
22797
|
-
this._markCollisionEventConsumersDirty();
|
|
22798
21223
|
this._nativePhysicsScene.removeCharacterController(controller._nativeCollider);
|
|
22799
21224
|
};
|
|
22800
21225
|
/**
|
|
22801
21226
|
* @internal
|
|
22802
|
-
*/ _proto._markCollisionEventConsumersDirty = function _markCollisionEventConsumersDirty() {
|
|
22803
|
-
this._collisionEventConsumersDirty = true;
|
|
22804
|
-
};
|
|
22805
|
-
/**
|
|
22806
|
-
* @internal
|
|
22807
21227
|
*/ _proto._callColliderOnUpdate = function _callColliderOnUpdate() {
|
|
22808
21228
|
var elements = this._colliders._elements;
|
|
22809
21229
|
for(var i = this._colliders.length - 1; i >= 0; --i){
|
|
@@ -22917,35 +21337,6 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
22917
21337
|
// Dispatch trigger events
|
|
22918
21338
|
for(var i1 = 0, n1 = triggerEvents.length; i1 < n1; i1++)_loop1(i1);
|
|
22919
21339
|
};
|
|
22920
|
-
_proto._hasCollisionEventConsumers = function _hasCollisionEventConsumers() {
|
|
22921
|
-
if (!this._collisionEventConsumersDirty) {
|
|
22922
|
-
return this._hasCollisionEventConsumersCache;
|
|
22923
|
-
}
|
|
22924
|
-
var _this__colliders = this._colliders, colliders = _this__colliders._elements;
|
|
22925
|
-
var _Script_prototype = Script.prototype, onCollisionEnter = _Script_prototype.onCollisionEnter, onCollisionExit = _Script_prototype.onCollisionExit, onCollisionStay = _Script_prototype.onCollisionStay;
|
|
22926
|
-
for(var i = this._colliders.length - 1; i >= 0; --i){
|
|
22927
|
-
var scripts = colliders[i].entity._scripts;
|
|
22928
|
-
var scriptElements = scripts._elements;
|
|
22929
|
-
for(var j = scripts.length - 1; j >= 0; --j){
|
|
22930
|
-
var script = scriptElements[j];
|
|
22931
|
-
if (script.onCollisionEnter !== onCollisionEnter || script.onCollisionExit !== onCollisionExit || script.onCollisionStay !== onCollisionStay) {
|
|
22932
|
-
this._collisionEventConsumersDirty = false;
|
|
22933
|
-
this._hasCollisionEventConsumersCache = true;
|
|
22934
|
-
return true;
|
|
22935
|
-
}
|
|
22936
|
-
}
|
|
22937
|
-
}
|
|
22938
|
-
this._collisionEventConsumersDirty = false;
|
|
22939
|
-
this._hasCollisionEventConsumersCache = false;
|
|
22940
|
-
return this._hasCollisionEventConsumersCache;
|
|
22941
|
-
};
|
|
22942
|
-
_proto._syncContactEventDemand = function _syncContactEventDemand() {
|
|
22943
|
-
var enabled = this._hasCollisionEventConsumers();
|
|
22944
|
-
if (this._contactEventEnabled !== enabled) {
|
|
22945
|
-
this._nativePhysicsScene.setContactEventEnabled == null ? void 0 : this._nativePhysicsScene.setContactEventEnabled.call(this._nativePhysicsScene, enabled);
|
|
22946
|
-
this._contactEventEnabled = enabled;
|
|
22947
|
-
}
|
|
22948
|
-
};
|
|
22949
21340
|
_proto._setGravity = function _setGravity() {
|
|
22950
21341
|
this._nativePhysicsScene.setGravity(this._gravity);
|
|
22951
21342
|
};
|
|
@@ -22999,17 +21390,6 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
22999
21390
|
set: function set(value) {
|
|
23000
21391
|
this._fixedTimeStep = Math.max(value, engineMath.MathUtil.zeroTolerance);
|
|
23001
21392
|
}
|
|
23002
|
-
},
|
|
23003
|
-
{
|
|
23004
|
-
key: "maximumDeltaTime",
|
|
23005
|
-
get: /**
|
|
23006
|
-
* Maximum delta time in seconds allowed per frame for physics simulation.
|
|
23007
|
-
*/ function get() {
|
|
23008
|
-
return this._maximumDeltaTime;
|
|
23009
|
-
},
|
|
23010
|
-
set: function set(value) {
|
|
23011
|
-
this._maximumDeltaTime = Math.max(value, engineMath.MathUtil.zeroTolerance);
|
|
23012
|
-
}
|
|
23013
21393
|
}
|
|
23014
21394
|
]);
|
|
23015
21395
|
return PhysicsScene;
|
|
@@ -24020,13 +22400,10 @@ var PointerEventEmitter = /*#__PURE__*/ function() {
|
|
|
24020
22400
|
this._init();
|
|
24021
22401
|
}
|
|
24022
22402
|
var _proto = PointerEventEmitter.prototype;
|
|
24023
|
-
_proto._createEventData = function _createEventData(pointer
|
|
24024
|
-
if (currentTarget === void 0) currentTarget = target;
|
|
22403
|
+
_proto._createEventData = function _createEventData(pointer) {
|
|
24025
22404
|
var data = this._pool.get();
|
|
24026
22405
|
data.pointer = pointer;
|
|
24027
22406
|
data.worldPosition.copyFrom(this._hitResult.point);
|
|
24028
|
-
data.target = target;
|
|
24029
|
-
data.currentTarget = currentTarget;
|
|
24030
22407
|
return data;
|
|
24031
22408
|
};
|
|
24032
22409
|
_proto._fireDown = function _fireDown(entity, eventData) {
|
|
@@ -24156,12 +22533,12 @@ PointerEventEmitter._tempRay = new engineMath.Ray();
|
|
|
24156
22533
|
};
|
|
24157
22534
|
_proto.processDrag = function processDrag(pointer) {
|
|
24158
22535
|
var entity = this._draggedEntity;
|
|
24159
|
-
entity && this._fireDrag(entity, this._createEventData(pointer
|
|
22536
|
+
entity && this._fireDrag(entity, this._createEventData(pointer));
|
|
24160
22537
|
};
|
|
24161
22538
|
_proto.processDown = function processDown(pointer) {
|
|
24162
22539
|
var entity = this._pressedEntity = this._draggedEntity = this._enteredEntity;
|
|
24163
22540
|
if (entity) {
|
|
24164
|
-
var eventData = this._createEventData(pointer
|
|
22541
|
+
var eventData = this._createEventData(pointer);
|
|
24165
22542
|
this._fireDown(entity, eventData);
|
|
24166
22543
|
this._fireBeginDrag(entity, eventData);
|
|
24167
22544
|
}
|
|
@@ -24170,26 +22547,26 @@ PointerEventEmitter._tempRay = new engineMath.Ray();
|
|
|
24170
22547
|
var _this = this, enteredEntity = _this._enteredEntity, draggedEntity = _this._draggedEntity;
|
|
24171
22548
|
if (enteredEntity) {
|
|
24172
22549
|
var sameTarget = this._pressedEntity === enteredEntity;
|
|
24173
|
-
var eventData = this._createEventData(pointer
|
|
22550
|
+
var eventData = this._createEventData(pointer);
|
|
24174
22551
|
this._fireUp(enteredEntity, eventData);
|
|
24175
22552
|
sameTarget && this._fireClick(enteredEntity, eventData);
|
|
24176
22553
|
this._fireDrop(enteredEntity, eventData);
|
|
24177
22554
|
}
|
|
24178
22555
|
this._pressedEntity = null;
|
|
24179
22556
|
if (draggedEntity) {
|
|
24180
|
-
this._fireEndDrag(draggedEntity, this._createEventData(pointer
|
|
22557
|
+
this._fireEndDrag(draggedEntity, this._createEventData(pointer));
|
|
24181
22558
|
this._draggedEntity = null;
|
|
24182
22559
|
}
|
|
24183
22560
|
};
|
|
24184
22561
|
_proto.processLeave = function processLeave(pointer) {
|
|
24185
22562
|
var enteredEntity = this._enteredEntity;
|
|
24186
22563
|
if (enteredEntity) {
|
|
24187
|
-
this._fireExit(enteredEntity, this._createEventData(pointer
|
|
22564
|
+
this._fireExit(enteredEntity, this._createEventData(pointer));
|
|
24188
22565
|
this._enteredEntity = null;
|
|
24189
22566
|
}
|
|
24190
22567
|
var draggedEntity = this._draggedEntity;
|
|
24191
22568
|
if (draggedEntity) {
|
|
24192
|
-
this._fireEndDrag(draggedEntity, this._createEventData(pointer
|
|
22569
|
+
this._fireEndDrag(draggedEntity, this._createEventData(pointer));
|
|
24193
22570
|
this._draggedEntity = null;
|
|
24194
22571
|
}
|
|
24195
22572
|
this._pressedEntity = null;
|
|
@@ -24204,10 +22581,10 @@ PointerEventEmitter._tempRay = new engineMath.Ray();
|
|
|
24204
22581
|
var enteredEntity = this._enteredEntity;
|
|
24205
22582
|
if (entity !== enteredEntity) {
|
|
24206
22583
|
if (enteredEntity) {
|
|
24207
|
-
this._fireExit(enteredEntity, this._createEventData(pointer
|
|
22584
|
+
this._fireExit(enteredEntity, this._createEventData(pointer));
|
|
24208
22585
|
}
|
|
24209
22586
|
if (entity) {
|
|
24210
|
-
this._fireEnter(entity, this._createEventData(pointer
|
|
22587
|
+
this._fireEnter(entity, this._createEventData(pointer));
|
|
24211
22588
|
}
|
|
24212
22589
|
this._enteredEntity = entity;
|
|
24213
22590
|
}
|
|
@@ -24247,7 +22624,39 @@ PointerEventEmitter._tempRay = new engineMath.Ray();
|
|
|
24247
22624
|
/**
|
|
24248
22625
|
* @internal
|
|
24249
22626
|
*/ _proto._update = function _update() {
|
|
24250
|
-
var _this
|
|
22627
|
+
var _this, _loop = function(i1, n) {
|
|
22628
|
+
var evt = nativeEvents[i1];
|
|
22629
|
+
var pointerId = evt.pointerId;
|
|
22630
|
+
var pointer = _this._getPointerByID(pointerId);
|
|
22631
|
+
if (pointer) {
|
|
22632
|
+
pointer._events.push(evt);
|
|
22633
|
+
} else {
|
|
22634
|
+
var lastCount = pointers.length;
|
|
22635
|
+
if (lastCount === 0 || _this._multiPointerEnabled) {
|
|
22636
|
+
var _this1 = _this, pointerPool = _this1._pointerPool;
|
|
22637
|
+
// Get Pointer smallest index
|
|
22638
|
+
var j = 0;
|
|
22639
|
+
for(; j < lastCount; j++){
|
|
22640
|
+
if (pointers[j].id > j) {
|
|
22641
|
+
break;
|
|
22642
|
+
}
|
|
22643
|
+
}
|
|
22644
|
+
pointer = pointerPool[j];
|
|
22645
|
+
if (!pointer) {
|
|
22646
|
+
pointer = pointerPool[j] = new Pointer(j);
|
|
22647
|
+
engine._physicsInitialized && pointer._addEmitters(PhysicsPointerEventEmitter, eventPool);
|
|
22648
|
+
PointerManager._pointerEventEmitters.forEach(function(emitter) {
|
|
22649
|
+
pointer._addEmitters(emitter, eventPool);
|
|
22650
|
+
});
|
|
22651
|
+
}
|
|
22652
|
+
pointer._uniqueID = pointerId;
|
|
22653
|
+
pointer._events.push(evt);
|
|
22654
|
+
pointer.position.set((evt.clientX - left) * widthDPR, (evt.clientY - top) * heightDPR);
|
|
22655
|
+
pointers.splice(j, 0, pointer);
|
|
22656
|
+
}
|
|
22657
|
+
}
|
|
22658
|
+
};
|
|
22659
|
+
var _this1 = this, pointers = _this1._pointers, nativeEvents = _this1._nativeEvents, htmlCanvas = _this1._htmlCanvas, engine = _this1._engine, eventPool = _this1._eventPool;
|
|
24251
22660
|
var _this__canvas = this._canvas, width = _this__canvas.width, height = _this__canvas.height;
|
|
24252
22661
|
var clientWidth = htmlCanvas.clientWidth, clientHeight = htmlCanvas.clientHeight;
|
|
24253
22662
|
var _htmlCanvas_getBoundingClientRect = htmlCanvas.getBoundingClientRect(), left = _htmlCanvas_getBoundingClientRect.left, top = _htmlCanvas_getBoundingClientRect.top;
|
|
@@ -24266,44 +22675,16 @@ PointerEventEmitter._tempRay = new engineMath.Ray();
|
|
|
24266
22675
|
}
|
|
24267
22676
|
}
|
|
24268
22677
|
// Generate the pointer received for this frame
|
|
24269
|
-
for(var i1 = 0, n = nativeEvents.length; i1 < n; i1++)
|
|
24270
|
-
var evt = nativeEvents[i1];
|
|
24271
|
-
var pointerId = evt.pointerId;
|
|
24272
|
-
var pointer1 = this._getPointerByID(pointerId);
|
|
24273
|
-
if (pointer1) {
|
|
24274
|
-
pointer1._events.push(evt);
|
|
24275
|
-
} else {
|
|
24276
|
-
var lastCount = pointers.length;
|
|
24277
|
-
if (lastCount === 0 || this._multiPointerEnabled) {
|
|
24278
|
-
var _this1 = this, pointerPool = _this1._pointerPool;
|
|
24279
|
-
// Get Pointer smallest index
|
|
24280
|
-
var j = 0;
|
|
24281
|
-
for(; j < lastCount; j++){
|
|
24282
|
-
if (pointers[j].id > j) {
|
|
24283
|
-
break;
|
|
24284
|
-
}
|
|
24285
|
-
}
|
|
24286
|
-
pointer1 = pointerPool[j];
|
|
24287
|
-
if (!pointer1) {
|
|
24288
|
-
pointer1 = pointerPool[j] = new Pointer(j);
|
|
24289
|
-
this._addEmitters(pointer1);
|
|
24290
|
-
}
|
|
24291
|
-
pointer1._uniqueID = pointerId;
|
|
24292
|
-
pointer1._events.push(evt);
|
|
24293
|
-
pointer1.position.set((evt.clientX - left) * widthDPR, (evt.clientY - top) * heightDPR);
|
|
24294
|
-
pointers.splice(j, 0, pointer1);
|
|
24295
|
-
}
|
|
24296
|
-
}
|
|
24297
|
-
}
|
|
22678
|
+
for(var i1 = 0, n = nativeEvents.length; i1 < n; i1++)_this = this, _loop(i1);
|
|
24298
22679
|
nativeEvents.length = 0;
|
|
24299
22680
|
this._upList.length = this._downList.length = 0;
|
|
24300
22681
|
this._buttons = PointerButton.None;
|
|
24301
22682
|
// Pointer handles its own events
|
|
24302
22683
|
var frameCount = engine.time.frameCount;
|
|
24303
22684
|
for(var i2 = 0, n1 = pointers.length; i2 < n1; i2++){
|
|
24304
|
-
var
|
|
24305
|
-
this._updatePointerInfo(frameCount,
|
|
24306
|
-
this._buttons |=
|
|
22685
|
+
var pointer1 = pointers[i2];
|
|
22686
|
+
this._updatePointerInfo(frameCount, pointer1, left, top, widthDPR, heightDPR);
|
|
22687
|
+
this._buttons |= pointer1.pressedButtons;
|
|
24307
22688
|
}
|
|
24308
22689
|
};
|
|
24309
22690
|
/**
|
|
@@ -24358,24 +22739,10 @@ PointerEventEmitter._tempRay = new engineMath.Ray();
|
|
|
24358
22739
|
};
|
|
24359
22740
|
/**
|
|
24360
22741
|
* @internal
|
|
24361
|
-
*/ _proto._gc = function _gc() {
|
|
24362
|
-
this._eventPool.garbageCollection();
|
|
24363
|
-
};
|
|
24364
|
-
/**
|
|
24365
|
-
* @internal
|
|
24366
22742
|
*/ _proto._destroy = function _destroy() {
|
|
24367
22743
|
this._removeEventListener();
|
|
24368
22744
|
this._pointerPool.length = 0;
|
|
24369
22745
|
};
|
|
24370
|
-
_proto._addEmitters = function _addEmitters(pointer) {
|
|
24371
|
-
var _this = this, eventPool = _this._eventPool, engine = _this._engine;
|
|
24372
|
-
var emitters = pointer._emitters;
|
|
24373
|
-
engine._physicsInitialized && emitters.push(new PhysicsPointerEventEmitter(eventPool));
|
|
24374
|
-
var emitterTypes = PointerManager._pointerEventEmitters;
|
|
24375
|
-
for(var i = 0, n = emitterTypes.length; i < n; i++){
|
|
24376
|
-
emitters.push(new emitterTypes[i](eventPool));
|
|
24377
|
-
}
|
|
24378
|
-
};
|
|
24379
22746
|
_proto._onPointerEvent = function _onPointerEvent(evt) {
|
|
24380
22747
|
this._nativeEvents.push(evt);
|
|
24381
22748
|
};
|
|
@@ -24412,7 +22779,6 @@ PointerEventEmitter._tempRay = new engineMath.Ray();
|
|
|
24412
22779
|
pointer._downMap[button] = frameCount;
|
|
24413
22780
|
pointer._frameEvents |= PointerEventType.Down;
|
|
24414
22781
|
pointer.phase = PointerPhase.Down;
|
|
24415
|
-
pointer.pressedPosition.set((event.clientX - left) * widthPixelRatio, (event.clientY - top) * heightPixelRatio);
|
|
24416
22782
|
break;
|
|
24417
22783
|
}
|
|
24418
22784
|
case "pointerup":
|
|
@@ -24657,11 +23023,6 @@ PointerEventEmitter._tempRay = new engineMath.Ray();
|
|
|
24657
23023
|
};
|
|
24658
23024
|
/**
|
|
24659
23025
|
* @internal
|
|
24660
|
-
*/ _proto._gc = function _gc() {
|
|
24661
|
-
this._initialized && this._pointerManager._gc();
|
|
24662
|
-
};
|
|
24663
|
-
/**
|
|
24664
|
-
* @internal
|
|
24665
23026
|
*/ _proto._destroy = function _destroy() {
|
|
24666
23027
|
if (this._initialized) {
|
|
24667
23028
|
this._wheelManager._destroy();
|
|
@@ -28643,7 +27004,7 @@ var UIUtils = /*#__PURE__*/ function() {
|
|
|
28643
27004
|
function UIUtils() {}
|
|
28644
27005
|
UIUtils.renderOverlay = function renderOverlay(engine, scene, uiCanvases) {
|
|
28645
27006
|
engine._macroCollection.enable(UIUtils._shouldSRGBCorrect);
|
|
28646
|
-
var canvas = engine.canvas
|
|
27007
|
+
var canvas = engine.canvas; engine._hardwareRenderer; var renderContext = engine._renderContext, batcherManager = engine._batcherManager;
|
|
28647
27008
|
var uiRenderQueue = this._renderQueue || (this._renderQueue = new RenderQueue(RenderQueueType.Transparent));
|
|
28648
27009
|
var virtualCamera = this._virtualCamera || (this._virtualCamera = new VirtualCamera());
|
|
28649
27010
|
var viewport = this._viewport || (this._viewport = new engineMath.Vector4(0, 0, 1, 1));
|
|
@@ -28652,16 +27013,10 @@ var UIUtils = /*#__PURE__*/ function() {
|
|
|
28652
27013
|
camera.engine = engine;
|
|
28653
27014
|
camera.scene = scene;
|
|
28654
27015
|
renderContext.camera = camera;
|
|
28655
|
-
var width = canvas.width, height = canvas.height;
|
|
28656
27016
|
var _virtualCamera_projectionMatrix = virtualCamera.projectionMatrix, projectE = _virtualCamera_projectionMatrix.elements;
|
|
28657
27017
|
var _virtualCamera_viewMatrix = virtualCamera.viewMatrix, viewE = _virtualCamera_viewMatrix.elements;
|
|
28658
|
-
projectE[0] = 2 / width, projectE[5] = 2 / height, projectE[10] = 0;
|
|
28659
|
-
|
|
28660
|
-
// The default canvas framebuffer is created without a stencil buffer
|
|
28661
|
-
// (see WebGLGraphicDevice._webGLOptions.stencil = false).
|
|
28662
|
-
var overlayRT = UIUtils._getOverlayRT(engine, width, height);
|
|
28663
|
-
renderContext.setRenderTarget(overlayRT, viewport, 0);
|
|
28664
|
-
rhi.clearRenderTarget(engine, CameraClearFlags.All, UIUtils._clearColor);
|
|
27018
|
+
projectE[0] = 2 / canvas.width, projectE[5] = 2 / canvas.height, projectE[10] = 0;
|
|
27019
|
+
renderContext.setRenderTarget(null, viewport, 0);
|
|
28665
27020
|
for(var i = 0, n = uiCanvases.length; i < n; i++){
|
|
28666
27021
|
var uiCanvas = uiCanvases.get(i);
|
|
28667
27022
|
if (uiCanvas) {
|
|
@@ -28682,43 +27037,12 @@ var UIUtils = /*#__PURE__*/ function() {
|
|
|
28682
27037
|
engine._renderCount++;
|
|
28683
27038
|
}
|
|
28684
27039
|
}
|
|
28685
|
-
// Blit overlay RT to default framebuffer with premultiplied alpha blending.
|
|
28686
|
-
// Blitter.blitTexture picks the non-flipping `blitMesh` when destination is null,
|
|
28687
|
-
// but the RT contents are written in standard Y-up NDC, so we flip V here via
|
|
28688
|
-
// sourceScaleOffset to match the default framebuffer orientation.
|
|
28689
|
-
Blitter.blitTexture(engine, overlayRT.getColorTexture(0), null, 0, viewport, UIUtils._getOverlayBlitMaterial(engine), 0, UIUtils._flipYScaleOffset);
|
|
28690
27040
|
renderContext.camera = null;
|
|
28691
27041
|
engine._macroCollection.disable(UIUtils._shouldSRGBCorrect);
|
|
28692
27042
|
};
|
|
28693
|
-
UIUtils._getOverlayRT = function _getOverlayRT(engine, width, height) {
|
|
28694
|
-
var rt = UIUtils._overlayRT;
|
|
28695
|
-
if (!rt || rt.width !== width || rt.height !== height) {
|
|
28696
|
-
if (rt) {
|
|
28697
|
-
rt.getColorTexture(0).destroy();
|
|
28698
|
-
rt.destroy();
|
|
28699
|
-
}
|
|
28700
|
-
var colorTexture = new Texture2D(engine, width, height, TextureFormat.R8G8B8A8, false);
|
|
28701
|
-
colorTexture.isGCIgnored = true;
|
|
28702
|
-
rt = new RenderTarget(engine, width, height, colorTexture, TextureFormat.Depth24Stencil8);
|
|
28703
|
-
rt.isGCIgnored = true;
|
|
28704
|
-
UIUtils._overlayRT = rt;
|
|
28705
|
-
}
|
|
28706
|
-
return rt;
|
|
28707
|
-
};
|
|
28708
|
-
UIUtils._getOverlayBlitMaterial = function _getOverlayBlitMaterial(engine) {
|
|
28709
|
-
var material = UIUtils._overlayBlitMaterial;
|
|
28710
|
-
if (!material) {
|
|
28711
|
-
material = new Material(engine, Shader.find("2D/UIOverlayBlit"));
|
|
28712
|
-
material.isGCIgnored = true;
|
|
28713
|
-
UIUtils._overlayBlitMaterial = material;
|
|
28714
|
-
}
|
|
28715
|
-
return material;
|
|
28716
|
-
};
|
|
28717
27043
|
return UIUtils;
|
|
28718
27044
|
}();
|
|
28719
27045
|
UIUtils._shouldSRGBCorrect = ShaderMacro.getByName("ENGINE_SHOULD_SRGB_CORRECT");
|
|
28720
|
-
UIUtils._clearColor = new engineMath.Color(0, 0, 0, 0);
|
|
28721
|
-
/** Flip V so that Y-up RT content maps correctly onto the default framebuffer. */ UIUtils._flipYScaleOffset = new engineMath.Vector4(1, -1, 0, 1);
|
|
28722
27046
|
var OverlayCamera = function OverlayCamera() {
|
|
28723
27047
|
// @ts-ignore
|
|
28724
27048
|
this.instanceId = ++EngineObject._instanceIdCounter;
|
|
@@ -29165,7 +27489,6 @@ var OverlayCamera = function OverlayCamera() {
|
|
|
29165
27489
|
this._renderElementPool.garbageCollection();
|
|
29166
27490
|
this._textRenderElementPool.garbageCollection();
|
|
29167
27491
|
this._renderContext.garbageCollection();
|
|
29168
|
-
this.inputManager._gc();
|
|
29169
27492
|
var scenes = this._sceneManager._scenes.getLoopArray();
|
|
29170
27493
|
for(var i = 0, n = scenes.length; i < n; i++){
|
|
29171
27494
|
var _scenes_i_physics, _scenes_i;
|
|
@@ -29588,44 +27911,16 @@ var OverlayCamera = function OverlayCamera() {
|
|
|
29588
27911
|
this.hasStencilWritten = false;
|
|
29589
27912
|
this._preMaskLayer = SpriteMaskLayer.Nothing;
|
|
29590
27913
|
this._allSpriteMasks = new DisorderedArray();
|
|
29591
|
-
this._filteredMasksByLayer = new Map();
|
|
29592
|
-
this._isFilteredMasksDirty = true;
|
|
29593
27914
|
}
|
|
29594
27915
|
var _proto = MaskManager.prototype;
|
|
29595
27916
|
_proto.addSpriteMask = function addSpriteMask(mask) {
|
|
29596
27917
|
mask._maskIndex = this._allSpriteMasks.length;
|
|
29597
27918
|
this._allSpriteMasks.add(mask);
|
|
29598
|
-
this._setFilteredMasksDirty();
|
|
29599
27919
|
};
|
|
29600
27920
|
_proto.removeSpriteMask = function removeSpriteMask(mask) {
|
|
29601
27921
|
var replaced = this._allSpriteMasks.deleteByIndex(mask._maskIndex);
|
|
29602
27922
|
replaced && (replaced._maskIndex = mask._maskIndex);
|
|
29603
27923
|
mask._maskIndex = -1;
|
|
29604
|
-
this._setFilteredMasksDirty();
|
|
29605
|
-
};
|
|
29606
|
-
_proto.onMaskInfluenceLayersChange = function onMaskInfluenceLayersChange() {
|
|
29607
|
-
this._setFilteredMasksDirty();
|
|
29608
|
-
};
|
|
29609
|
-
_proto.isVisibleByMask = function isVisibleByMask(maskInteraction, maskLayer, worldPoint) {
|
|
29610
|
-
if (maskInteraction === SpriteMaskInteraction.None) {
|
|
29611
|
-
return true;
|
|
29612
|
-
}
|
|
29613
|
-
var masks = this._getMasksByLayer(maskLayer);
|
|
29614
|
-
var insideMask = false;
|
|
29615
|
-
for(var i = 0, n = masks.length; i < n; i++){
|
|
29616
|
-
if (masks[i]._containsWorldPoint(worldPoint)) {
|
|
29617
|
-
insideMask = true;
|
|
29618
|
-
break;
|
|
29619
|
-
}
|
|
29620
|
-
}
|
|
29621
|
-
switch(maskInteraction){
|
|
29622
|
-
case SpriteMaskInteraction.VisibleInsideMask:
|
|
29623
|
-
return insideMask;
|
|
29624
|
-
case SpriteMaskInteraction.VisibleOutsideMask:
|
|
29625
|
-
return !insideMask;
|
|
29626
|
-
default:
|
|
29627
|
-
return true;
|
|
29628
|
-
}
|
|
29629
27924
|
};
|
|
29630
27925
|
_proto.drawMask = function drawMask(context, pipelineStageTagValue, maskLayer) {
|
|
29631
27926
|
var incrementMaskQueue = MaskManager.getMaskIncrementRenderQueue();
|
|
@@ -29700,34 +27995,6 @@ var OverlayCamera = function OverlayCamera() {
|
|
|
29700
27995
|
var allSpriteMasks = this._allSpriteMasks;
|
|
29701
27996
|
allSpriteMasks.length = 0;
|
|
29702
27997
|
allSpriteMasks.garbageCollection();
|
|
29703
|
-
this._filteredMasksByLayer.clear();
|
|
29704
|
-
this._isFilteredMasksDirty = true;
|
|
29705
|
-
};
|
|
29706
|
-
_proto._setFilteredMasksDirty = function _setFilteredMasksDirty() {
|
|
29707
|
-
this._isFilteredMasksDirty = true;
|
|
29708
|
-
};
|
|
29709
|
-
_proto._getMasksByLayer = function _getMasksByLayer(maskLayer) {
|
|
29710
|
-
if (maskLayer === SpriteMaskLayer.Nothing) {
|
|
29711
|
-
return [];
|
|
29712
|
-
}
|
|
29713
|
-
if (this._isFilteredMasksDirty) {
|
|
29714
|
-
this._filteredMasksByLayer.clear();
|
|
29715
|
-
this._isFilteredMasksDirty = false;
|
|
29716
|
-
}
|
|
29717
|
-
var filteredMasks = this._filteredMasksByLayer.get(maskLayer);
|
|
29718
|
-
if (!filteredMasks) {
|
|
29719
|
-
filteredMasks = [];
|
|
29720
|
-
var allMasks = this._allSpriteMasks;
|
|
29721
|
-
var maskElements = allMasks._elements;
|
|
29722
|
-
for(var i = 0, n = allMasks.length; i < n; i++){
|
|
29723
|
-
var mask = maskElements[i];
|
|
29724
|
-
if (mask.influenceLayers & maskLayer) {
|
|
29725
|
-
filteredMasks.push(mask);
|
|
29726
|
-
}
|
|
29727
|
-
}
|
|
29728
|
-
this._filteredMasksByLayer.set(maskLayer, filteredMasks);
|
|
29729
|
-
}
|
|
29730
|
-
return filteredMasks;
|
|
29731
27998
|
};
|
|
29732
27999
|
_proto._buildMaskRenderElement = function _buildMaskRenderElement(curMaskLayer, incrementMaskQueue, decrementMaskQueue) {
|
|
29733
28000
|
var preMaskLayer = this._preMaskLayer;
|
|
@@ -31033,6 +29300,218 @@ Scene._fogColorProperty = ShaderProperty.getByName("scene_FogColor");
|
|
|
31033
29300
|
Scene._fogParamsProperty = ShaderProperty.getByName("scene_FogParams");
|
|
31034
29301
|
Scene._prefilterdDFGProperty = ShaderProperty.getByName("scene_PrefilteredDFG");
|
|
31035
29302
|
|
|
29303
|
+
/**
|
|
29304
|
+
* Script class, used for logic writing.
|
|
29305
|
+
*/ var Script = /*#__PURE__*/ function(Component) {
|
|
29306
|
+
_inherits(Script, Component);
|
|
29307
|
+
function Script() {
|
|
29308
|
+
var _this;
|
|
29309
|
+
_this = Component.apply(this, arguments) || this, /** @internal */ _this._started = false, /** @internal */ _this._onStartIndex = -1, /** @internal */ _this._onUpdateIndex = -1, /** @internal */ _this._onLateUpdateIndex = -1, /** @internal */ _this._onPhysicsUpdateIndex = -1, /** @internal */ _this._onPreRenderIndex = -1, /** @internal */ _this._onPostRenderIndex = -1, /** @internal */ _this._entityScriptsIndex = -1;
|
|
29310
|
+
return _this;
|
|
29311
|
+
}
|
|
29312
|
+
var _proto = Script.prototype;
|
|
29313
|
+
/**
|
|
29314
|
+
* Called when be enabled first time, only once.
|
|
29315
|
+
*/ _proto.onAwake = function onAwake() {};
|
|
29316
|
+
/**
|
|
29317
|
+
* Called when be enabled.
|
|
29318
|
+
*/ _proto.onEnable = function onEnable() {};
|
|
29319
|
+
/**
|
|
29320
|
+
* Called before the frame-level loop start for the first time, only once.
|
|
29321
|
+
*/ _proto.onStart = function onStart() {};
|
|
29322
|
+
/**
|
|
29323
|
+
* The main loop, called frame by frame.
|
|
29324
|
+
* @param deltaTime - The delta time since last frame in seconds
|
|
29325
|
+
*/ _proto.onUpdate = function onUpdate(deltaTime) {};
|
|
29326
|
+
/**
|
|
29327
|
+
* Called after the onUpdate finished, called frame by frame.
|
|
29328
|
+
* @param deltaTime - The delta time since last frame in seconds
|
|
29329
|
+
*/ _proto.onLateUpdate = function onLateUpdate(deltaTime) {};
|
|
29330
|
+
/**
|
|
29331
|
+
* Called before camera rendering, called per camera.
|
|
29332
|
+
* @param camera - Current camera.
|
|
29333
|
+
*/ _proto.onBeginRender = function onBeginRender(camera) {};
|
|
29334
|
+
/**
|
|
29335
|
+
* Called after camera rendering, called per camera.
|
|
29336
|
+
* @param camera - Current camera.
|
|
29337
|
+
*/ _proto.onEndRender = function onEndRender(camera) {};
|
|
29338
|
+
/**
|
|
29339
|
+
* Called before physics calculations, the number of times is related to the physical update frequency.
|
|
29340
|
+
*/ _proto.onPhysicsUpdate = function onPhysicsUpdate() {};
|
|
29341
|
+
/**
|
|
29342
|
+
* Called when the trigger enter.
|
|
29343
|
+
* @param other - ColliderShape
|
|
29344
|
+
*/ _proto.onTriggerEnter = function onTriggerEnter(other) {};
|
|
29345
|
+
/**
|
|
29346
|
+
* Called when the trigger exit.
|
|
29347
|
+
* @param other - ColliderShape
|
|
29348
|
+
*/ _proto.onTriggerExit = function onTriggerExit(other) {};
|
|
29349
|
+
/**
|
|
29350
|
+
* Called when the trigger stay.
|
|
29351
|
+
* @remarks onTriggerStay is called every frame while the trigger stay.
|
|
29352
|
+
* @param other - ColliderShape
|
|
29353
|
+
*/ _proto.onTriggerStay = function onTriggerStay(other) {};
|
|
29354
|
+
/**
|
|
29355
|
+
* Called when the collision enter.
|
|
29356
|
+
* @param other - The Collision data associated with this collision event
|
|
29357
|
+
* @remarks The Collision data will be invalid after this call, you should copy the data if needed.
|
|
29358
|
+
*/ _proto.onCollisionEnter = function onCollisionEnter(other) {};
|
|
29359
|
+
/**
|
|
29360
|
+
* Called when the collision exit.
|
|
29361
|
+
* @param other - The Collision data associated with this collision event
|
|
29362
|
+
* @remarks The Collision data will be invalid after this call, you should copy the data if needed.
|
|
29363
|
+
*/ _proto.onCollisionExit = function onCollisionExit(other) {};
|
|
29364
|
+
/**
|
|
29365
|
+
* Called when the collision stay.
|
|
29366
|
+
* @param other - The Collision data associated with this collision event
|
|
29367
|
+
* @remarks The Collision data will be invalid after this call, you should copy the data if needed.
|
|
29368
|
+
*/ _proto.onCollisionStay = function onCollisionStay(other) {};
|
|
29369
|
+
/**
|
|
29370
|
+
* Called when the pointer is down while over the ColliderShape.
|
|
29371
|
+
* @param eventData - The pointer event data that triggered this callback
|
|
29372
|
+
*/ _proto.onPointerDown = function onPointerDown(eventData) {};
|
|
29373
|
+
/**
|
|
29374
|
+
* Called when the pointer is up while over the ColliderShape.
|
|
29375
|
+
* @param eventData - The pointer event data that triggered this callback
|
|
29376
|
+
*/ _proto.onPointerUp = function onPointerUp(eventData) {};
|
|
29377
|
+
/**
|
|
29378
|
+
* Called when the pointer is down and up with the same collider.
|
|
29379
|
+
* @param eventData - The pointer event data that triggered this callback
|
|
29380
|
+
*/ _proto.onPointerClick = function onPointerClick(eventData) {};
|
|
29381
|
+
/**
|
|
29382
|
+
* Called when the pointer enters the ColliderShape.
|
|
29383
|
+
* @param eventData - The pointer event data that triggered this callback
|
|
29384
|
+
*/ _proto.onPointerEnter = function onPointerEnter(eventData) {};
|
|
29385
|
+
/**
|
|
29386
|
+
* Called when the pointer exits the ColliderShape.
|
|
29387
|
+
* @param eventData - The pointer event data that triggered this callback
|
|
29388
|
+
*/ _proto.onPointerExit = function onPointerExit(eventData) {};
|
|
29389
|
+
/**
|
|
29390
|
+
* This function will be called when the pointer is pressed on the collider.
|
|
29391
|
+
* @param eventData - The pointer event data that triggered this callback
|
|
29392
|
+
*/ _proto.onPointerBeginDrag = function onPointerBeginDrag(eventData) {};
|
|
29393
|
+
/**
|
|
29394
|
+
* When a drag collision occurs on the pointer, this function will be called every time it moves.
|
|
29395
|
+
* @param eventData - The pointer event data that triggered this callback
|
|
29396
|
+
*/ _proto.onPointerDrag = function onPointerDrag(eventData) {};
|
|
29397
|
+
/**
|
|
29398
|
+
* When dragging ends, this function will be called (Dragged object).
|
|
29399
|
+
* @param eventData - The pointer event data that triggered this callback
|
|
29400
|
+
*/ _proto.onPointerEndDrag = function onPointerEndDrag(eventData) {};
|
|
29401
|
+
/**
|
|
29402
|
+
* When dragging ends, this function will be called (Receiving object).
|
|
29403
|
+
* @param eventData - The pointer event data that triggered this callback
|
|
29404
|
+
*/ _proto.onPointerDrop = function onPointerDrop(eventData) {};
|
|
29405
|
+
/**
|
|
29406
|
+
* Called when be disabled.
|
|
29407
|
+
*/ _proto.onDisable = function onDisable() {};
|
|
29408
|
+
/**
|
|
29409
|
+
* Called at the end of the destroyed frame.
|
|
29410
|
+
*/ _proto.onDestroy = function onDestroy() {};
|
|
29411
|
+
/**
|
|
29412
|
+
* @internal
|
|
29413
|
+
*/ _proto._onAwake = function _onAwake() {
|
|
29414
|
+
this.onAwake();
|
|
29415
|
+
};
|
|
29416
|
+
/**
|
|
29417
|
+
* @internal
|
|
29418
|
+
*/ _proto._onEnable = function _onEnable() {
|
|
29419
|
+
this.onEnable();
|
|
29420
|
+
};
|
|
29421
|
+
/**
|
|
29422
|
+
* @internal
|
|
29423
|
+
*/ _proto._onDisable = function _onDisable() {
|
|
29424
|
+
this.onDisable();
|
|
29425
|
+
};
|
|
29426
|
+
/**
|
|
29427
|
+
* @internal
|
|
29428
|
+
*/ _proto._onEnableInScene = function _onEnableInScene() {
|
|
29429
|
+
var _this_scene = this.scene, componentsManager = _this_scene._componentsManager;
|
|
29430
|
+
var prototype = Script.prototype;
|
|
29431
|
+
if (!this._started) {
|
|
29432
|
+
componentsManager.addOnStartScript(this);
|
|
29433
|
+
}
|
|
29434
|
+
if (this.onUpdate !== prototype.onUpdate) {
|
|
29435
|
+
componentsManager.addOnUpdateScript(this);
|
|
29436
|
+
}
|
|
29437
|
+
if (this.onLateUpdate !== prototype.onLateUpdate) {
|
|
29438
|
+
componentsManager.addOnLateUpdateScript(this);
|
|
29439
|
+
}
|
|
29440
|
+
if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
|
|
29441
|
+
componentsManager.addOnPhysicsUpdateScript(this);
|
|
29442
|
+
}
|
|
29443
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.values(PointerMethods)), _step; !(_step = _iterator()).done;){
|
|
29444
|
+
var pointerMethod = _step.value;
|
|
29445
|
+
if (this[pointerMethod] === prototype[pointerMethod]) {
|
|
29446
|
+
this[pointerMethod] = null;
|
|
29447
|
+
}
|
|
29448
|
+
}
|
|
29449
|
+
this._entity._addScript(this);
|
|
29450
|
+
};
|
|
29451
|
+
/**
|
|
29452
|
+
* @internal
|
|
29453
|
+
*/ _proto._onDisableInScene = function _onDisableInScene() {
|
|
29454
|
+
var componentsManager = this.scene._componentsManager;
|
|
29455
|
+
var prototype = Script.prototype;
|
|
29456
|
+
if (!this._started) {
|
|
29457
|
+
componentsManager.removeOnStartScript(this);
|
|
29458
|
+
}
|
|
29459
|
+
if (this.onUpdate !== prototype.onUpdate) {
|
|
29460
|
+
componentsManager.removeOnUpdateScript(this);
|
|
29461
|
+
}
|
|
29462
|
+
if (this.onLateUpdate !== prototype.onLateUpdate) {
|
|
29463
|
+
componentsManager.removeOnLateUpdateScript(this);
|
|
29464
|
+
}
|
|
29465
|
+
if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
|
|
29466
|
+
componentsManager.removeOnPhysicsUpdateScript(this);
|
|
29467
|
+
}
|
|
29468
|
+
this._entity._removeScript(this);
|
|
29469
|
+
};
|
|
29470
|
+
/**
|
|
29471
|
+
* @internal
|
|
29472
|
+
*/ _proto._onDestroy = function _onDestroy() {
|
|
29473
|
+
Component.prototype._onDestroy.call(this);
|
|
29474
|
+
this.onDestroy();
|
|
29475
|
+
};
|
|
29476
|
+
return Script;
|
|
29477
|
+
}(Component);
|
|
29478
|
+
__decorate([
|
|
29479
|
+
ignoreClone
|
|
29480
|
+
], Script.prototype, "_started", void 0);
|
|
29481
|
+
__decorate([
|
|
29482
|
+
ignoreClone
|
|
29483
|
+
], Script.prototype, "_onStartIndex", void 0);
|
|
29484
|
+
__decorate([
|
|
29485
|
+
ignoreClone
|
|
29486
|
+
], Script.prototype, "_onUpdateIndex", void 0);
|
|
29487
|
+
__decorate([
|
|
29488
|
+
ignoreClone
|
|
29489
|
+
], Script.prototype, "_onLateUpdateIndex", void 0);
|
|
29490
|
+
__decorate([
|
|
29491
|
+
ignoreClone
|
|
29492
|
+
], Script.prototype, "_onPhysicsUpdateIndex", void 0);
|
|
29493
|
+
__decorate([
|
|
29494
|
+
ignoreClone
|
|
29495
|
+
], Script.prototype, "_onPreRenderIndex", void 0);
|
|
29496
|
+
__decorate([
|
|
29497
|
+
ignoreClone
|
|
29498
|
+
], Script.prototype, "_onPostRenderIndex", void 0);
|
|
29499
|
+
__decorate([
|
|
29500
|
+
ignoreClone
|
|
29501
|
+
], Script.prototype, "_entityScriptsIndex", void 0);
|
|
29502
|
+
var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
29503
|
+
PointerMethods["onPointerDown"] = "onPointerDown";
|
|
29504
|
+
PointerMethods["onPointerUp"] = "onPointerUp";
|
|
29505
|
+
PointerMethods["onPointerClick"] = "onPointerClick";
|
|
29506
|
+
PointerMethods["onPointerEnter"] = "onPointerEnter";
|
|
29507
|
+
PointerMethods["onPointerExit"] = "onPointerExit";
|
|
29508
|
+
PointerMethods["onPointerBeginDrag"] = "onPointerBeginDrag";
|
|
29509
|
+
PointerMethods["onPointerDrag"] = "onPointerDrag";
|
|
29510
|
+
PointerMethods["onPointerEndDrag"] = "onPointerEndDrag";
|
|
29511
|
+
PointerMethods["onPointerDrop"] = "onPointerDrop";
|
|
29512
|
+
return PointerMethods;
|
|
29513
|
+
}({});
|
|
29514
|
+
|
|
31036
29515
|
/**
|
|
31037
29516
|
* Signal is a typed event mechanism for Galacean Engine.
|
|
31038
29517
|
* @typeParam T - Tuple type of the signal arguments
|
|
@@ -43198,7 +41677,6 @@ exports.DisorderedArray = DisorderedArray;
|
|
|
43198
41677
|
exports.Downsampling = Downsampling;
|
|
43199
41678
|
exports.DynamicCollider = DynamicCollider;
|
|
43200
41679
|
exports.DynamicColliderConstraints = DynamicColliderConstraints;
|
|
43201
|
-
exports.DynamicColliderKinematicTransformSyncMode = DynamicColliderKinematicTransformSyncMode;
|
|
43202
41680
|
exports.EmissionModule = EmissionModule;
|
|
43203
41681
|
exports.Engine = Engine;
|
|
43204
41682
|
exports.EngineEventType = EngineEventType;
|
|
@@ -43234,8 +41712,6 @@ exports.Loader = Loader;
|
|
|
43234
41712
|
exports.Logger = Logger;
|
|
43235
41713
|
exports.MSAASamples = MSAASamples;
|
|
43236
41714
|
exports.MainModule = MainModule;
|
|
43237
|
-
exports.MaskDirtyFlags = MaskDirtyFlags;
|
|
43238
|
-
exports.MaskRenderable = MaskRenderable;
|
|
43239
41715
|
exports.Material = Material;
|
|
43240
41716
|
exports.Mesh = Mesh;
|
|
43241
41717
|
exports.MeshColliderShape = MeshColliderShape;
|
|
@@ -43344,12 +41820,9 @@ exports.SpringJoint = SpringJoint;
|
|
|
43344
41820
|
exports.Sprite = Sprite;
|
|
43345
41821
|
exports.SpriteAtlas = SpriteAtlas;
|
|
43346
41822
|
exports.SpriteDrawMode = SpriteDrawMode;
|
|
43347
|
-
exports.SpriteFilledMode = SpriteFilledMode;
|
|
43348
|
-
exports.SpriteFilledOrigin = SpriteFilledOrigin;
|
|
43349
41823
|
exports.SpriteMask = SpriteMask;
|
|
43350
41824
|
exports.SpriteMaskInteraction = SpriteMaskInteraction;
|
|
43351
41825
|
exports.SpriteMaskLayer = SpriteMaskLayer;
|
|
43352
|
-
exports.SpriteMaskUtils = SpriteMaskUtils;
|
|
43353
41826
|
exports.SpriteModifyFlags = SpriteModifyFlags;
|
|
43354
41827
|
exports.SpriteRenderer = SpriteRenderer;
|
|
43355
41828
|
exports.SpriteTileMode = SpriteTileMode;
|