@lightningjs/renderer 3.0.0-beta7 → 3.0.0-beta8
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/exports/utils.d.ts +2 -1
- package/dist/exports/utils.js +2 -1
- package/dist/exports/utils.js.map +1 -1
- package/dist/src/core/CoreNode.d.ts +24 -49
- package/dist/src/core/CoreNode.js +251 -255
- package/dist/src/core/CoreNode.js.map +1 -1
- package/dist/src/core/CoreTextNode.d.ts +1 -1
- package/dist/src/core/CoreTextNode.js +14 -15
- package/dist/src/core/CoreTextNode.js.map +1 -1
- package/dist/src/core/CoreTextureManager.js +5 -4
- package/dist/src/core/CoreTextureManager.js.map +1 -1
- package/dist/src/core/Stage.d.ts +12 -27
- package/dist/src/core/Stage.js +50 -37
- package/dist/src/core/Stage.js.map +1 -1
- package/dist/src/core/TextureMemoryManager.d.ts +9 -0
- package/dist/src/core/TextureMemoryManager.js +78 -48
- package/dist/src/core/TextureMemoryManager.js.map +1 -1
- package/dist/src/core/animations/CoreAnimation.js +5 -0
- package/dist/src/core/animations/CoreAnimation.js.map +1 -1
- package/dist/src/core/animations/CoreAnimationController.d.ts +1 -0
- package/dist/src/core/animations/CoreAnimationController.js +7 -1
- package/dist/src/core/animations/CoreAnimationController.js.map +1 -1
- package/dist/src/core/renderers/CoreRenderer.d.ts +1 -0
- package/dist/src/core/renderers/CoreRenderer.js.map +1 -1
- package/dist/src/core/renderers/CoreShaderNode.d.ts +1 -0
- package/dist/src/core/renderers/CoreShaderNode.js +9 -0
- package/dist/src/core/renderers/CoreShaderNode.js.map +1 -1
- package/dist/src/core/renderers/canvas/CanvasRenderer.d.ts +1 -0
- package/dist/src/core/renderers/canvas/CanvasRenderer.js +3 -0
- package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +1 -1
- package/dist/src/core/renderers/canvas/CanvasShaderNode.js +1 -4
- package/dist/src/core/renderers/canvas/CanvasShaderNode.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCtxTexture.js +0 -3
- package/dist/src/core/renderers/webgl/WebGlCtxTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlRenderer.d.ts +1 -0
- package/dist/src/core/renderers/webgl/WebGlRenderer.js +56 -54
- package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlShaderNode.js +1 -4
- package/dist/src/core/renderers/webgl/WebGlShaderNode.js.map +1 -1
- package/dist/src/core/shaders/canvas/LinearGradient.js +5 -3
- package/dist/src/core/shaders/canvas/LinearGradient.js.map +1 -1
- package/dist/src/core/shaders/canvas/RadialGradient.js +13 -11
- package/dist/src/core/shaders/canvas/RadialGradient.js.map +1 -1
- package/dist/src/core/shaders/canvas/RoundedWithBorder.js +7 -5
- package/dist/src/core/shaders/canvas/RoundedWithBorder.js.map +1 -1
- package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js +10 -8
- package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js.map +1 -1
- package/dist/src/core/shaders/canvas/RoundedWithShadow.js +7 -5
- package/dist/src/core/shaders/canvas/RoundedWithShadow.js.map +1 -1
- package/dist/src/core/shaders/templates/BorderTemplate.d.ts +1 -1
- package/dist/src/core/shaders/templates/BorderTemplate.js +1 -1
- package/dist/src/core/shaders/templates/BorderTemplate.js.map +1 -1
- package/dist/src/core/shaders/templates/HolePunchTemplate.js +1 -1
- package/dist/src/core/shaders/templates/HolePunchTemplate.js.map +1 -1
- package/dist/src/core/shaders/templates/RoundedTemplate.js +1 -1
- package/dist/src/core/shaders/templates/RoundedTemplate.js.map +1 -1
- package/dist/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.d.ts +1 -1
- package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.d.ts +1 -1
- package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.d.ts +1 -1
- package/dist/src/core/shaders/templates/ShadowTemplate.d.ts +1 -1
- package/dist/src/core/shaders/{templates/shaderUtils.d.ts → utils.d.ts} +1 -1
- package/dist/src/core/shaders/{templates/shaderUtils.js → utils.js} +2 -2
- package/dist/src/core/shaders/utils.js.map +1 -0
- package/dist/src/core/shaders/webgl/HolePunch.js +4 -3
- package/dist/src/core/shaders/webgl/HolePunch.js.map +1 -1
- package/dist/src/core/shaders/webgl/LinearGradient.js +5 -4
- package/dist/src/core/shaders/webgl/LinearGradient.js.map +1 -1
- package/dist/src/core/shaders/webgl/RadialGradient.js +6 -5
- package/dist/src/core/shaders/webgl/RadialGradient.js.map +1 -1
- package/dist/src/core/shaders/webgl/RoundedWithBorder.js +18 -7
- package/dist/src/core/shaders/webgl/RoundedWithBorder.js.map +1 -1
- package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +30 -17
- package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js.map +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js +0 -50
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js.map +1 -1
- package/dist/src/core/textures/ImageTexture.d.ts +1 -1
- package/dist/src/core/textures/ImageTexture.js +1 -1
- package/dist/src/core/textures/ImageTexture.js.map +1 -1
- package/dist/src/core/textures/Texture.d.ts +8 -0
- package/dist/src/core/textures/Texture.js +13 -0
- package/dist/src/core/textures/Texture.js.map +1 -1
- package/dist/src/core/utils.d.ts +1 -1
- package/dist/src/main-api/Inspector.d.ts +6 -1
- package/dist/src/main-api/Inspector.js +42 -4
- package/dist/src/main-api/Inspector.js.map +1 -1
- package/dist/src/main-api/Renderer.d.ts +62 -43
- package/dist/src/main-api/Renderer.js +119 -31
- package/dist/src/main-api/Renderer.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/exports/utils.ts +7 -1
- package/package.json +1 -1
- package/src/core/CoreNode.ts +301 -313
- package/src/core/CoreTextNode.ts +23 -20
- package/src/core/CoreTextureManager.ts +5 -4
- package/src/core/Stage.ts +68 -65
- package/src/core/TextureMemoryManager.ts +104 -63
- package/src/core/animations/CoreAnimation.ts +7 -0
- package/src/core/animations/CoreAnimationController.ts +8 -1
- package/src/core/renderers/CoreRenderer.ts +1 -0
- package/src/core/renderers/CoreShaderNode.ts +10 -0
- package/src/core/renderers/canvas/CanvasRenderer.ts +4 -0
- package/src/core/renderers/canvas/CanvasShaderNode.ts +1 -4
- package/src/core/renderers/webgl/WebGlCtxTexture.ts +0 -3
- package/src/core/renderers/webgl/WebGlRenderer.ts +64 -65
- package/src/core/renderers/webgl/WebGlShaderNode.ts +2 -4
- package/src/core/shaders/canvas/LinearGradient.ts +8 -6
- package/src/core/shaders/canvas/RadialGradient.ts +22 -36
- package/src/core/shaders/canvas/RoundedWithBorder.ts +10 -8
- package/src/core/shaders/canvas/RoundedWithBorderAndShadow.ts +14 -12
- package/src/core/shaders/canvas/RoundedWithShadow.ts +8 -7
- package/src/core/shaders/templates/BorderTemplate.ts +1 -1
- package/src/core/shaders/templates/HolePunchTemplate.ts +1 -1
- package/src/core/shaders/templates/RoundedTemplate.ts +1 -1
- package/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.ts +1 -1
- package/src/core/shaders/templates/RoundedWithBorderTemplate.ts +1 -1
- package/src/core/shaders/templates/RoundedWithShadowTemplate.ts +1 -1
- package/src/core/shaders/templates/ShadowTemplate.ts +1 -1
- package/src/core/shaders/{templates/shaderUtils.ts → utils.ts} +2 -3
- package/src/core/shaders/webgl/HolePunch.ts +4 -7
- package/src/core/shaders/webgl/LinearGradient.ts +5 -4
- package/src/core/shaders/webgl/RadialGradient.ts +7 -6
- package/src/core/shaders/webgl/RoundedWithBorder.ts +18 -7
- package/src/core/shaders/webgl/RoundedWithBorderAndShadow.ts +30 -21
- package/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.ts +2 -58
- package/src/core/textures/ImageTexture.ts +17 -16
- package/src/core/textures/Texture.ts +14 -0
- package/src/main-api/Inspector.ts +52 -5
- package/src/main-api/Renderer.ts +222 -77
- package/dist/src/core/platform.d.ts +0 -10
- package/dist/src/core/platform.js +0 -56
- package/dist/src/core/platform.js.map +0 -1
- package/dist/src/core/renderers/CoreShader.d.ts +0 -9
- package/dist/src/core/renderers/CoreShader.js +0 -28
- package/dist/src/core/renderers/CoreShader.js.map +0 -1
- package/dist/src/core/renderers/canvas/CanvasCoreRenderer.d.ts +0 -33
- package/dist/src/core/renderers/canvas/CanvasCoreRenderer.js +0 -250
- package/dist/src/core/renderers/canvas/CanvasCoreRenderer.js.map +0 -1
- package/dist/src/core/renderers/canvas/CanvasCoreTexture.d.ts +0 -16
- package/dist/src/core/renderers/canvas/CanvasCoreTexture.js +0 -123
- package/dist/src/core/renderers/canvas/CanvasCoreTexture.js.map +0 -1
- package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.d.ts +0 -10
- package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.js +0 -43
- package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.js.map +0 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.d.ts +0 -12
- package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.js +0 -55
- package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.js.map +0 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.d.ts +0 -9
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js +0 -38
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js.map +0 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.d.ts +0 -57
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js +0 -227
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js.map +0 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.d.ts +0 -34
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js +0 -114
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js.map +0 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.d.ts +0 -133
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +0 -613
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +0 -1
- package/dist/src/core/renderers/webgl/WebGlCoreShader.d.ts +0 -83
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js +0 -231
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.d.ts +0 -9
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.js +0 -87
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.d.ts +0 -10
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js +0 -119
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.d.ts +0 -29
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js +0 -413
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.d.ts +0 -28
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js +0 -131
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/SdfShader.d.ts +0 -47
- package/dist/src/core/renderers/webgl/shaders/SdfShader.js +0 -160
- package/dist/src/core/renderers/webgl/shaders/SdfShader.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.d.ts +0 -31
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js +0 -71
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.d.ts +0 -30
- package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js +0 -58
- package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.d.ts +0 -31
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js +0 -71
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.d.ts +0 -31
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js +0 -71
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.d.ts +0 -31
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js +0 -71
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.d.ts +0 -9
- package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js +0 -136
- package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.d.ts +0 -36
- package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.js +0 -85
- package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.d.ts +0 -45
- package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js +0 -104
- package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.d.ts +0 -22
- package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js +0 -45
- package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.d.ts +0 -58
- package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.js +0 -80
- package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.d.ts +0 -35
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js +0 -129
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.d.ts +0 -39
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js +0 -116
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.d.ts +0 -61
- package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.js +0 -127
- package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.d.ts +0 -40
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js +0 -71
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.d.ts +0 -115
- package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js +0 -61
- package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js.map +0 -1
- package/dist/src/core/shaders/templates/shaderUtils.js.map +0 -1
- package/dist/src/core/temp.d.ts +0 -1
- package/dist/src/core/temp.js +0 -77
- package/dist/src/core/temp.js.map +0 -1
- package/dist/src/main-api/DynamicShaderController.d.ts +0 -29
- package/dist/src/main-api/DynamicShaderController.js +0 -58
- package/dist/src/main-api/DynamicShaderController.js.map +0 -1
- package/dist/src/main-api/ShaderController.d.ts +0 -31
- package/dist/src/main-api/ShaderController.js +0 -37
- package/dist/src/main-api/ShaderController.js.map +0 -1
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { assertTruthy, getNewId, mergeColorAlphaPremultiplied,
|
|
19
|
+
import { assertTruthy, getNewId, mergeColorAlphaPremultiplied, } from '../utils.js';
|
|
20
20
|
import {} from './textures/Texture.js';
|
|
21
21
|
import { EventEmitter } from '../common/EventEmitter.js';
|
|
22
22
|
import { copyRect, intersectRect, createBound, boundInsideBound, boundLargeThanBound, createPreloadBounds, } from './lib/utils.js';
|
|
@@ -43,31 +43,23 @@ export var UpdateType;
|
|
|
43
43
|
*/
|
|
44
44
|
UpdateType[UpdateType["Children"] = 1] = "Children";
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @remarks
|
|
49
|
-
* CoreNode Properties Updated:
|
|
50
|
-
* - `scaleRotateTransform`
|
|
51
|
-
*/
|
|
52
|
-
UpdateType[UpdateType["ScaleRotate"] = 2] = "ScaleRotate";
|
|
53
|
-
/**
|
|
54
|
-
* Translate transform update (x/y/width/height/pivot/mount)
|
|
46
|
+
* localTransform
|
|
55
47
|
*
|
|
56
48
|
* @remarks
|
|
57
49
|
* CoreNode Properties Updated:
|
|
58
50
|
* - `localTransform`
|
|
59
51
|
*/
|
|
60
|
-
UpdateType[UpdateType["Local"] =
|
|
52
|
+
UpdateType[UpdateType["Local"] = 2] = "Local";
|
|
61
53
|
/**
|
|
62
|
-
*
|
|
54
|
+
* globalTransform
|
|
63
55
|
*
|
|
64
|
-
* @remarks
|
|
56
|
+
* * @remarks
|
|
65
57
|
* CoreNode Properties Updated:
|
|
66
58
|
* - `globalTransform`
|
|
59
|
+
* - `renderBounds`
|
|
67
60
|
* - `renderCoords`
|
|
68
|
-
* - `renderBound`
|
|
69
61
|
*/
|
|
70
|
-
UpdateType[UpdateType["Global"] =
|
|
62
|
+
UpdateType[UpdateType["Global"] = 4] = "Global";
|
|
71
63
|
/**
|
|
72
64
|
* Clipping rect update
|
|
73
65
|
*
|
|
@@ -75,7 +67,7 @@ export var UpdateType;
|
|
|
75
67
|
* CoreNode Properties Updated:
|
|
76
68
|
* - `clippingRect`
|
|
77
69
|
*/
|
|
78
|
-
UpdateType[UpdateType["Clipping"] =
|
|
70
|
+
UpdateType[UpdateType["Clipping"] = 8] = "Clipping";
|
|
79
71
|
/**
|
|
80
72
|
* Calculated ZIndex update
|
|
81
73
|
*
|
|
@@ -83,7 +75,7 @@ export var UpdateType;
|
|
|
83
75
|
* CoreNode Properties Updated:
|
|
84
76
|
* - `calcZIndex`
|
|
85
77
|
*/
|
|
86
|
-
UpdateType[UpdateType["CalculatedZIndex"] =
|
|
78
|
+
UpdateType[UpdateType["CalculatedZIndex"] = 16] = "CalculatedZIndex";
|
|
87
79
|
/**
|
|
88
80
|
* Z-Index Sorted Children update
|
|
89
81
|
*
|
|
@@ -91,7 +83,7 @@ export var UpdateType;
|
|
|
91
83
|
* CoreNode Properties Updated:
|
|
92
84
|
* - `children` (sorts children by their `calcZIndex`)
|
|
93
85
|
*/
|
|
94
|
-
UpdateType[UpdateType["ZIndexSortedChildren"] =
|
|
86
|
+
UpdateType[UpdateType["ZIndexSortedChildren"] = 32] = "ZIndexSortedChildren";
|
|
95
87
|
/**
|
|
96
88
|
* Premultiplied Colors update
|
|
97
89
|
*
|
|
@@ -102,7 +94,7 @@ export var UpdateType;
|
|
|
102
94
|
* - `premultipliedColorBl`
|
|
103
95
|
* - `premultipliedColorBr`
|
|
104
96
|
*/
|
|
105
|
-
UpdateType[UpdateType["PremultipliedColors"] =
|
|
97
|
+
UpdateType[UpdateType["PremultipliedColors"] = 64] = "PremultipliedColors";
|
|
106
98
|
/**
|
|
107
99
|
* World Alpha update
|
|
108
100
|
*
|
|
@@ -110,7 +102,7 @@ export var UpdateType;
|
|
|
110
102
|
* CoreNode Properties Updated:
|
|
111
103
|
* - `worldAlpha` = `parent.worldAlpha` * `alpha`
|
|
112
104
|
*/
|
|
113
|
-
UpdateType[UpdateType["WorldAlpha"] =
|
|
105
|
+
UpdateType[UpdateType["WorldAlpha"] = 128] = "WorldAlpha";
|
|
114
106
|
/**
|
|
115
107
|
* Render State update
|
|
116
108
|
*
|
|
@@ -118,7 +110,7 @@ export var UpdateType;
|
|
|
118
110
|
* CoreNode Properties Updated:
|
|
119
111
|
* - `renderState`
|
|
120
112
|
*/
|
|
121
|
-
UpdateType[UpdateType["RenderState"] =
|
|
113
|
+
UpdateType[UpdateType["RenderState"] = 256] = "RenderState";
|
|
122
114
|
/**
|
|
123
115
|
* Is Renderable update
|
|
124
116
|
*
|
|
@@ -126,19 +118,23 @@ export var UpdateType;
|
|
|
126
118
|
* CoreNode Properties Updated:
|
|
127
119
|
* - `isRenderable`
|
|
128
120
|
*/
|
|
129
|
-
UpdateType[UpdateType["IsRenderable"] =
|
|
121
|
+
UpdateType[UpdateType["IsRenderable"] = 512] = "IsRenderable";
|
|
130
122
|
/**
|
|
131
123
|
* Render Texture update
|
|
132
124
|
*/
|
|
133
|
-
UpdateType[UpdateType["RenderTexture"] =
|
|
125
|
+
UpdateType[UpdateType["RenderTexture"] = 1024] = "RenderTexture";
|
|
134
126
|
/**
|
|
135
127
|
* Track if parent has render texture
|
|
136
128
|
*/
|
|
137
|
-
UpdateType[UpdateType["ParentRenderTexture"] =
|
|
129
|
+
UpdateType[UpdateType["ParentRenderTexture"] = 2048] = "ParentRenderTexture";
|
|
138
130
|
/**
|
|
139
131
|
* Render Bounds update
|
|
140
132
|
*/
|
|
141
|
-
UpdateType[UpdateType["RenderBounds"] =
|
|
133
|
+
UpdateType[UpdateType["RenderBounds"] = 4096] = "RenderBounds";
|
|
134
|
+
/**
|
|
135
|
+
* RecalcUniforms
|
|
136
|
+
*/
|
|
137
|
+
UpdateType[UpdateType["RecalcUniforms"] = 8192] = "RecalcUniforms";
|
|
142
138
|
/**
|
|
143
139
|
* None
|
|
144
140
|
*/
|
|
@@ -146,11 +142,7 @@ export var UpdateType;
|
|
|
146
142
|
/**
|
|
147
143
|
* All
|
|
148
144
|
*/
|
|
149
|
-
UpdateType[UpdateType["All"] =
|
|
150
|
-
/**
|
|
151
|
-
* RecalcUniforms
|
|
152
|
-
*/
|
|
153
|
-
UpdateType[UpdateType["RecalcUniforms"] = 16384] = "RecalcUniforms";
|
|
145
|
+
UpdateType[UpdateType["All"] = 16383] = "All";
|
|
154
146
|
})(UpdateType || (UpdateType = {}));
|
|
155
147
|
/**
|
|
156
148
|
* A visual Node in the Renderer scene graph.
|
|
@@ -166,10 +158,10 @@ export class CoreNode extends EventEmitter {
|
|
|
166
158
|
_id = getNewId();
|
|
167
159
|
props;
|
|
168
160
|
hasShaderUpdater = false;
|
|
161
|
+
hasColorProps = false;
|
|
169
162
|
updateType = UpdateType.All;
|
|
170
163
|
childUpdateType = UpdateType.None;
|
|
171
164
|
globalTransform;
|
|
172
|
-
scaleRotateTransform;
|
|
173
165
|
localTransform;
|
|
174
166
|
sceneGlobalTransform;
|
|
175
167
|
renderCoords;
|
|
@@ -201,51 +193,75 @@ export class CoreNode extends EventEmitter {
|
|
|
201
193
|
* only used when rtt = true
|
|
202
194
|
*/
|
|
203
195
|
framebufferDimensions = null;
|
|
196
|
+
destroyed = false;
|
|
204
197
|
constructor(stage, props) {
|
|
205
198
|
super();
|
|
206
199
|
this.stage = stage;
|
|
207
|
-
this.props = {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
200
|
+
const p = (this.props = {});
|
|
201
|
+
// Fast-path assign only known keys
|
|
202
|
+
p.x = props.x;
|
|
203
|
+
p.y = props.y;
|
|
204
|
+
p.width = props.width;
|
|
205
|
+
p.height = props.height;
|
|
206
|
+
p.alpha = props.alpha;
|
|
207
|
+
p.autosize = props.autosize;
|
|
208
|
+
p.clipping = props.clipping;
|
|
209
|
+
p.color = props.color;
|
|
210
|
+
p.colorTop = props.colorTop;
|
|
211
|
+
p.colorBottom = props.colorBottom;
|
|
212
|
+
p.colorLeft = props.colorLeft;
|
|
213
|
+
p.colorRight = props.colorRight;
|
|
214
|
+
p.colorTl = props.colorTl;
|
|
215
|
+
p.colorTr = props.colorTr;
|
|
216
|
+
p.colorBl = props.colorBl;
|
|
217
|
+
p.colorBr = props.colorBr;
|
|
218
|
+
p.scaleX = props.scaleX;
|
|
219
|
+
p.scaleY = props.scaleY;
|
|
220
|
+
p.rotation = props.rotation;
|
|
221
|
+
p.pivotX = props.pivotX;
|
|
222
|
+
p.pivotY = props.pivotY;
|
|
223
|
+
p.mountX = props.mountX;
|
|
224
|
+
p.mountY = props.mountY;
|
|
225
|
+
p.mount = props.mount;
|
|
226
|
+
p.pivot = props.pivot;
|
|
227
|
+
p.strictBounds = props.strictBounds;
|
|
228
|
+
p.zIndex = props.zIndex;
|
|
229
|
+
p.zIndexLocked = props.zIndexLocked;
|
|
230
|
+
p.textureOptions = props.textureOptions;
|
|
231
|
+
p.data = props.data;
|
|
232
|
+
p.imageType = props.imageType;
|
|
233
|
+
p.srcX = props.srcX;
|
|
234
|
+
p.srcY = props.srcY;
|
|
235
|
+
p.srcWidth = props.srcWidth;
|
|
236
|
+
p.srcHeight = props.srcHeight;
|
|
237
|
+
p.parent = null;
|
|
238
|
+
p.texture = null;
|
|
239
|
+
p.shader = null;
|
|
240
|
+
p.src = null;
|
|
241
|
+
p.rtt = false;
|
|
242
|
+
p.boundsMargin = null;
|
|
215
243
|
// Assign props to instances
|
|
216
244
|
this.parent = props.parent;
|
|
217
245
|
this.texture = props.texture;
|
|
218
246
|
this.shader = props.shader;
|
|
219
247
|
this.src = props.src;
|
|
220
248
|
this.rtt = props.rtt;
|
|
249
|
+
this.boundsMargin = props.boundsMargin;
|
|
221
250
|
this.interactive = props.interactive;
|
|
222
|
-
|
|
223
|
-
this.boundsMargin = Array.isArray(props.boundsMargin)
|
|
224
|
-
? props.boundsMargin
|
|
225
|
-
: [
|
|
226
|
-
props.boundsMargin,
|
|
227
|
-
props.boundsMargin,
|
|
228
|
-
props.boundsMargin,
|
|
229
|
-
props.boundsMargin,
|
|
230
|
-
];
|
|
231
|
-
}
|
|
232
|
-
this.setUpdateType(UpdateType.ScaleRotate |
|
|
233
|
-
UpdateType.Local |
|
|
234
|
-
UpdateType.RenderBounds |
|
|
235
|
-
UpdateType.RenderState);
|
|
251
|
+
this.setUpdateType(UpdateType.Local | UpdateType.RenderBounds | UpdateType.RenderState);
|
|
236
252
|
// if the default texture isn't loaded yet, wait for it to load
|
|
237
253
|
// this only happens when the node is created before the stage is ready
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
this.setUpdateType(UpdateType.IsRenderable);
|
|
242
|
-
});
|
|
254
|
+
const dt = this.stage.defaultTexture;
|
|
255
|
+
if (dt !== null && dt.state !== 'loaded') {
|
|
256
|
+
dt.once('loaded', () => this.setUpdateType(UpdateType.IsRenderable));
|
|
243
257
|
}
|
|
244
258
|
}
|
|
245
259
|
//#region Textures
|
|
246
260
|
loadTexture() {
|
|
247
261
|
const { texture } = this.props;
|
|
248
|
-
|
|
262
|
+
if (!texture) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
249
265
|
// If texture is already loaded / failed, trigger loaded event manually
|
|
250
266
|
// so that users get a consistent event experience.
|
|
251
267
|
// We do this in a microtask to allow listeners to be attached in the same
|
|
@@ -269,11 +285,9 @@ export class CoreNode extends EventEmitter {
|
|
|
269
285
|
return;
|
|
270
286
|
}
|
|
271
287
|
if (texture.state === 'loaded') {
|
|
272
|
-
assertTruthy(texture.dimensions);
|
|
273
288
|
this.onTextureLoaded(texture, texture.dimensions);
|
|
274
289
|
}
|
|
275
290
|
else if (texture.state === 'failed') {
|
|
276
|
-
assertTruthy(texture.error);
|
|
277
291
|
this.onTextureFailed(texture, texture.error);
|
|
278
292
|
}
|
|
279
293
|
else if (texture.state === 'freed') {
|
|
@@ -282,12 +296,14 @@ export class CoreNode extends EventEmitter {
|
|
|
282
296
|
});
|
|
283
297
|
}
|
|
284
298
|
unloadTexture() {
|
|
285
|
-
if (this.texture
|
|
286
|
-
|
|
287
|
-
this.texture.off('failed', this.onTextureFailed);
|
|
288
|
-
this.texture.off('freed', this.onTextureFreed);
|
|
289
|
-
this.texture.setRenderableOwner(this, false);
|
|
299
|
+
if (this.texture === null) {
|
|
300
|
+
return;
|
|
290
301
|
}
|
|
302
|
+
const texture = this.texture;
|
|
303
|
+
texture.off('loaded', this.onTextureLoaded);
|
|
304
|
+
texture.off('failed', this.onTextureFailed);
|
|
305
|
+
texture.off('freed', this.onTextureFreed);
|
|
306
|
+
texture.setRenderableOwner(this, false);
|
|
291
307
|
}
|
|
292
308
|
autosizeNode(dimensions) {
|
|
293
309
|
if (this.autosize) {
|
|
@@ -352,42 +368,32 @@ export class CoreNode extends EventEmitter {
|
|
|
352
368
|
const parent = this.props.parent;
|
|
353
369
|
if (!parent)
|
|
354
370
|
return;
|
|
355
|
-
|
|
356
|
-
// Inform the parent if it doesn’t already have a child update
|
|
357
|
-
parent.setUpdateType(UpdateType.Children);
|
|
358
|
-
}
|
|
371
|
+
parent.setUpdateType(UpdateType.Children);
|
|
359
372
|
}
|
|
360
373
|
sortChildren() {
|
|
361
374
|
this.children.sort((a, b) => a.calcZIndex - b.calcZIndex);
|
|
362
375
|
}
|
|
363
|
-
updateScaleRotateTransform() {
|
|
364
|
-
const { rotation, scaleX, scaleY } = this.props;
|
|
365
|
-
// optimize simple translation cases
|
|
366
|
-
if (rotation === 0 && scaleX === 1 && scaleY === 1) {
|
|
367
|
-
this.scaleRotateTransform = undefined;
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
this.scaleRotateTransform = Matrix3d.rotate(rotation, this.scaleRotateTransform).scale(scaleX, scaleY);
|
|
371
|
-
}
|
|
372
376
|
updateLocalTransform() {
|
|
373
|
-
const
|
|
374
|
-
const
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
const
|
|
377
|
+
const p = this.props;
|
|
378
|
+
const { x, y, width, height } = p;
|
|
379
|
+
const mountTranslateX = p.mountX * width;
|
|
380
|
+
const mountTranslateY = p.mountY * height;
|
|
381
|
+
if (p.rotation !== 0 || p.scaleX !== 1 || p.scaleY !== 1) {
|
|
382
|
+
const pivotTranslateX = p.pivotX * width;
|
|
383
|
+
const pivotTranslateY = p.pivotY * height;
|
|
379
384
|
this.localTransform = Matrix3d.translate(x - mountTranslateX + pivotTranslateX, y - mountTranslateY + pivotTranslateY, this.localTransform)
|
|
380
|
-
.
|
|
385
|
+
.rotate(p.rotation)
|
|
386
|
+
.scale(p.scaleX, p.scaleY)
|
|
381
387
|
.translate(-pivotTranslateX, -pivotTranslateY);
|
|
382
388
|
}
|
|
383
389
|
else {
|
|
384
390
|
this.localTransform = Matrix3d.translate(x - mountTranslateX, y - mountTranslateY, this.localTransform);
|
|
385
391
|
}
|
|
386
392
|
// Handle 'contain' resize mode
|
|
387
|
-
const texture =
|
|
393
|
+
const texture = p.texture;
|
|
388
394
|
if (texture &&
|
|
389
395
|
texture.dimensions &&
|
|
390
|
-
|
|
396
|
+
p.textureOptions.resizeMode?.type === 'contain') {
|
|
391
397
|
let resizeModeScaleX = 1;
|
|
392
398
|
let resizeModeScaleY = 1;
|
|
393
399
|
let extraX = 0;
|
|
@@ -418,29 +424,33 @@ export class CoreNode extends EventEmitter {
|
|
|
418
424
|
.translate(extraX, extraY)
|
|
419
425
|
.scale(resizeModeScaleX, resizeModeScaleY);
|
|
420
426
|
}
|
|
421
|
-
this.setUpdateType(UpdateType.Global);
|
|
422
427
|
}
|
|
423
428
|
/**
|
|
424
429
|
* @todo: test for correct calculation flag
|
|
425
430
|
* @param delta
|
|
426
431
|
*/
|
|
427
432
|
update(delta, parentClippingRect) {
|
|
428
|
-
if (this.updateType
|
|
429
|
-
|
|
430
|
-
this.setUpdateType(UpdateType.Local);
|
|
433
|
+
if (this.updateType === UpdateType.None) {
|
|
434
|
+
return;
|
|
431
435
|
}
|
|
432
|
-
|
|
436
|
+
const props = this.props;
|
|
437
|
+
const parent = props.parent;
|
|
438
|
+
const parentHasRenderTexture = this.parentHasRenderTexture;
|
|
439
|
+
const hasParent = props.parent !== null;
|
|
440
|
+
let renderState = null;
|
|
441
|
+
let updateType = this.updateType;
|
|
442
|
+
let childUpdateType = this.childUpdateType;
|
|
443
|
+
let updateParent = false;
|
|
444
|
+
if (updateType & UpdateType.Local) {
|
|
433
445
|
this.updateLocalTransform();
|
|
434
|
-
|
|
446
|
+
updateType |= UpdateType.Global;
|
|
447
|
+
updateParent = hasParent;
|
|
435
448
|
}
|
|
436
|
-
const parent = this.props.parent;
|
|
437
|
-
let renderState = null;
|
|
438
449
|
// Handle specific RTT updates at this node level
|
|
439
|
-
if (
|
|
450
|
+
if (updateType & UpdateType.RenderTexture && this.rtt === true) {
|
|
440
451
|
this.hasRTTupdates = true;
|
|
441
452
|
}
|
|
442
|
-
if (
|
|
443
|
-
assertTruthy(this.localTransform);
|
|
453
|
+
if (updateType & UpdateType.Global) {
|
|
444
454
|
if (this.parentHasRenderTexture === true && parent?.rtt === true) {
|
|
445
455
|
// we are at the start of the RTT chain, so we need to reset the globalTransform
|
|
446
456
|
// for correct RTT rendering
|
|
@@ -464,24 +474,28 @@ export class CoreNode extends EventEmitter {
|
|
|
464
474
|
}
|
|
465
475
|
this.calculateRenderCoords();
|
|
466
476
|
this.updateBoundingRect();
|
|
467
|
-
|
|
468
|
-
UpdateType.
|
|
469
|
-
|
|
470
|
-
|
|
477
|
+
updateType |=
|
|
478
|
+
UpdateType.RenderState |
|
|
479
|
+
UpdateType.Children |
|
|
480
|
+
UpdateType.RecalcUniforms;
|
|
481
|
+
updateParent = hasParent;
|
|
482
|
+
childUpdateType |= UpdateType.Global;
|
|
471
483
|
if (this.clipping === true) {
|
|
472
|
-
|
|
473
|
-
|
|
484
|
+
updateType |= UpdateType.Clipping | UpdateType.RenderBounds;
|
|
485
|
+
updateParent = hasParent;
|
|
486
|
+
childUpdateType |= UpdateType.RenderBounds;
|
|
474
487
|
}
|
|
475
488
|
}
|
|
476
|
-
if (
|
|
489
|
+
if (updateType & UpdateType.RenderBounds) {
|
|
477
490
|
this.createRenderBounds();
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
491
|
+
updateType |= UpdateType.RenderState | UpdateType.Children;
|
|
492
|
+
updateParent = hasParent;
|
|
493
|
+
childUpdateType |= UpdateType.RenderBounds;
|
|
481
494
|
}
|
|
482
|
-
if (
|
|
495
|
+
if (updateType & UpdateType.RenderState) {
|
|
483
496
|
renderState = this.checkRenderBounds();
|
|
484
|
-
|
|
497
|
+
updateType |= UpdateType.IsRenderable;
|
|
498
|
+
updateParent = hasParent;
|
|
485
499
|
// if we're not going out of bounds, update the render state
|
|
486
500
|
// this is done so the update loop can finish before we mark a node
|
|
487
501
|
// as out of bounds
|
|
@@ -489,64 +503,69 @@ export class CoreNode extends EventEmitter {
|
|
|
489
503
|
this.updateRenderState(renderState);
|
|
490
504
|
}
|
|
491
505
|
}
|
|
492
|
-
if (
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
this.worldAlpha = this.props.alpha;
|
|
498
|
-
}
|
|
499
|
-
this.setUpdateType(UpdateType.Children |
|
|
506
|
+
if (updateType & UpdateType.WorldAlpha) {
|
|
507
|
+
this.worldAlpha = ((parent && parent.worldAlpha) || 1) * props.alpha;
|
|
508
|
+
updateType |=
|
|
500
509
|
UpdateType.PremultipliedColors |
|
|
501
|
-
|
|
502
|
-
|
|
510
|
+
UpdateType.Children |
|
|
511
|
+
UpdateType.IsRenderable;
|
|
512
|
+
updateParent = hasParent;
|
|
513
|
+
childUpdateType |= UpdateType.WorldAlpha;
|
|
503
514
|
}
|
|
504
|
-
if (
|
|
515
|
+
if (updateType & UpdateType.IsRenderable) {
|
|
505
516
|
this.updateIsRenderable();
|
|
506
517
|
}
|
|
507
|
-
if (
|
|
518
|
+
if (updateType & UpdateType.Clipping) {
|
|
508
519
|
this.calculateClippingRect(parentClippingRect);
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
if (
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
520
|
+
updateType |= UpdateType.Children;
|
|
521
|
+
updateParent = hasParent;
|
|
522
|
+
childUpdateType |= UpdateType.Clipping | UpdateType.RenderBounds;
|
|
523
|
+
}
|
|
524
|
+
if (updateType & UpdateType.PremultipliedColors) {
|
|
525
|
+
const alpha = this.worldAlpha;
|
|
526
|
+
const tl = props.colorTl;
|
|
527
|
+
const tr = props.colorTr;
|
|
528
|
+
const bl = props.colorBl;
|
|
529
|
+
const br = props.colorBr;
|
|
530
|
+
// Fast equality check (covers all 4 corners)
|
|
531
|
+
const same = tl === tr && tl === bl && tl === br;
|
|
532
|
+
const merged = mergeColorAlphaPremultiplied(tl, alpha, true);
|
|
533
|
+
this.premultipliedColorTl = merged;
|
|
534
|
+
if (same) {
|
|
519
535
|
this.premultipliedColorTr =
|
|
520
536
|
this.premultipliedColorBl =
|
|
521
537
|
this.premultipliedColorBr =
|
|
522
|
-
|
|
538
|
+
merged;
|
|
523
539
|
}
|
|
524
540
|
else {
|
|
525
|
-
this.premultipliedColorTr = mergeColorAlphaPremultiplied(
|
|
526
|
-
this.premultipliedColorBl = mergeColorAlphaPremultiplied(
|
|
527
|
-
this.premultipliedColorBr = mergeColorAlphaPremultiplied(
|
|
541
|
+
this.premultipliedColorTr = mergeColorAlphaPremultiplied(tr, alpha, true);
|
|
542
|
+
this.premultipliedColorBl = mergeColorAlphaPremultiplied(bl, alpha, true);
|
|
543
|
+
this.premultipliedColorBr = mergeColorAlphaPremultiplied(br, alpha, true);
|
|
528
544
|
}
|
|
529
545
|
}
|
|
546
|
+
if (updateParent === true) {
|
|
547
|
+
parent.setUpdateType(UpdateType.Children);
|
|
548
|
+
}
|
|
530
549
|
// No need to update zIndex if there is no parent
|
|
531
|
-
if (
|
|
550
|
+
if (updateType & UpdateType.CalculatedZIndex && parent !== null) {
|
|
532
551
|
this.calculateZIndex();
|
|
533
552
|
// Tell parent to re-sort children
|
|
534
553
|
parent.setUpdateType(UpdateType.ZIndexSortedChildren);
|
|
535
554
|
}
|
|
536
|
-
if (
|
|
555
|
+
if (props.strictBounds === true &&
|
|
537
556
|
this.renderState === CoreNodeRenderState.OutOfBounds) {
|
|
538
|
-
|
|
557
|
+
updateType &= ~UpdateType.RenderBounds; // remove render bounds update
|
|
539
558
|
return;
|
|
540
559
|
}
|
|
541
|
-
if (
|
|
560
|
+
if (updateType & UpdateType.RecalcUniforms &&
|
|
542
561
|
this.hasShaderUpdater === true) {
|
|
543
562
|
//this exists because the boolean hasShaderUpdater === true
|
|
544
563
|
this.shader.update();
|
|
545
564
|
}
|
|
546
|
-
if (
|
|
565
|
+
if (updateType & UpdateType.Children && this.children.length > 0) {
|
|
547
566
|
for (let i = 0, length = this.children.length; i < length; i++) {
|
|
548
567
|
const child = this.children[i];
|
|
549
|
-
child.setUpdateType(
|
|
568
|
+
child.setUpdateType(childUpdateType);
|
|
550
569
|
if (child.updateType === 0) {
|
|
551
570
|
continue;
|
|
552
571
|
}
|
|
@@ -564,14 +583,14 @@ export class CoreNode extends EventEmitter {
|
|
|
564
583
|
}
|
|
565
584
|
}
|
|
566
585
|
// If the node has an RTT parent and requires a texture re-render, inform the RTT parent
|
|
567
|
-
// if (this.parentHasRenderTexture &&
|
|
586
|
+
// if (this.parentHasRenderTexture && updateType & UpdateType.RenderTexture) {
|
|
568
587
|
// @TODO have a more scoped down updateType for RTT updates
|
|
569
|
-
if (
|
|
588
|
+
if (parentHasRenderTexture === true) {
|
|
570
589
|
this.notifyParentRTTOfUpdate();
|
|
571
590
|
}
|
|
572
591
|
// Sorting children MUST happen after children have been updated so
|
|
573
592
|
// that they have the oppotunity to update their calculated zIndex.
|
|
574
|
-
if (
|
|
593
|
+
if (updateType & UpdateType.ZIndexSortedChildren) {
|
|
575
594
|
// reorder z-index
|
|
576
595
|
this.sortChildren();
|
|
577
596
|
}
|
|
@@ -590,7 +609,6 @@ export class CoreNode extends EventEmitter {
|
|
|
590
609
|
// notify children that we are going out of bounds
|
|
591
610
|
// we have to do this now before we stop processing the render tree
|
|
592
611
|
this.notifyChildrenRTTOfUpdate(renderState);
|
|
593
|
-
// this.childUpdateType |= UpdateType.RenderState;
|
|
594
612
|
}
|
|
595
613
|
}
|
|
596
614
|
// reset update type
|
|
@@ -629,9 +647,6 @@ export class CoreNode extends EventEmitter {
|
|
|
629
647
|
}
|
|
630
648
|
}
|
|
631
649
|
checkRenderBounds() {
|
|
632
|
-
assertTruthy(this.renderBound);
|
|
633
|
-
assertTruthy(this.strictBound);
|
|
634
|
-
assertTruthy(this.preloadBound);
|
|
635
650
|
if (boundInsideBound(this.renderBound, this.strictBound)) {
|
|
636
651
|
return CoreNodeRenderState.InViewport;
|
|
637
652
|
}
|
|
@@ -650,10 +665,8 @@ export class CoreNode extends EventEmitter {
|
|
|
650
665
|
return CoreNodeRenderState.OutOfBounds;
|
|
651
666
|
}
|
|
652
667
|
updateBoundingRect() {
|
|
653
|
-
const transform = this.sceneGlobalTransform || this.globalTransform;
|
|
654
|
-
const renderCoords = this.sceneRenderCoords || this.renderCoords;
|
|
655
|
-
assertTruthy(transform);
|
|
656
|
-
assertTruthy(renderCoords);
|
|
668
|
+
const transform = (this.sceneGlobalTransform || this.globalTransform);
|
|
669
|
+
const renderCoords = (this.sceneRenderCoords || this.renderCoords);
|
|
657
670
|
if (transform.tb === 0 || transform.tc === 0) {
|
|
658
671
|
this.renderBound = createBound(renderCoords.x1, renderCoords.y1, renderCoords.x3, renderCoords.y3, this.renderBound);
|
|
659
672
|
}
|
|
@@ -717,7 +730,8 @@ export class CoreNode extends EventEmitter {
|
|
|
717
730
|
let newIsRenderable = false;
|
|
718
731
|
let needsTextureOwnership = false;
|
|
719
732
|
// If the node is out of bounds or has an alpha of 0, it is not renderable
|
|
720
|
-
if (this.
|
|
733
|
+
if (this.worldAlpha === 0 ||
|
|
734
|
+
this.renderState <= CoreNodeRenderState.OutOfBounds) {
|
|
721
735
|
this.updateTextureOwnership(false);
|
|
722
736
|
this.setRenderable(false);
|
|
723
737
|
return;
|
|
@@ -727,8 +741,11 @@ export class CoreNode extends EventEmitter {
|
|
|
727
741
|
// we're only renderable if the texture state is loaded
|
|
728
742
|
newIsRenderable = this.texture.state === 'loaded';
|
|
729
743
|
}
|
|
730
|
-
else if (
|
|
731
|
-
|
|
744
|
+
else if (
|
|
745
|
+
// check shader
|
|
746
|
+
(this.props.shader !== null || this.hasColorProps === true) &&
|
|
747
|
+
// check dimensions
|
|
748
|
+
(this.props.width !== 0 && this.props.height !== 0) === true) {
|
|
732
749
|
// This mean we have dimensions and a color set, so we can render a ColorTexture
|
|
733
750
|
if (this.stage.defaultTexture &&
|
|
734
751
|
this.stage.defaultTexture.state === 'loaded') {
|
|
@@ -738,17 +755,6 @@ export class CoreNode extends EventEmitter {
|
|
|
738
755
|
this.updateTextureOwnership(needsTextureOwnership);
|
|
739
756
|
this.setRenderable(newIsRenderable);
|
|
740
757
|
}
|
|
741
|
-
/**
|
|
742
|
-
* Checks if the node is renderable based on world alpha, dimensions and out of bounds status.
|
|
743
|
-
*/
|
|
744
|
-
checkBasicRenderability() {
|
|
745
|
-
if (this.worldAlpha === 0 || this.isOutOfBounds() === true) {
|
|
746
|
-
return false;
|
|
747
|
-
}
|
|
748
|
-
else {
|
|
749
|
-
return true;
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
758
|
/**
|
|
753
759
|
* Sets the renderable state and triggers changes if necessary.
|
|
754
760
|
* @param isRenderable - The new renderable state
|
|
@@ -767,38 +773,10 @@ export class CoreNode extends EventEmitter {
|
|
|
767
773
|
updateTextureOwnership(isRenderable) {
|
|
768
774
|
this.texture?.setRenderableOwner(this, isRenderable);
|
|
769
775
|
}
|
|
770
|
-
/**
|
|
771
|
-
* Checks if the node is out of the viewport bounds.
|
|
772
|
-
*/
|
|
773
|
-
isOutOfBounds() {
|
|
774
|
-
return this.renderState <= CoreNodeRenderState.OutOfBounds;
|
|
775
|
-
}
|
|
776
|
-
/**
|
|
777
|
-
* Checks if the node has dimensions (width/height)
|
|
778
|
-
*/
|
|
779
|
-
hasDimensions() {
|
|
780
|
-
return this.props.width !== 0 && this.props.height !== 0;
|
|
781
|
-
}
|
|
782
|
-
/**
|
|
783
|
-
* Checks if the node has any color properties set.
|
|
784
|
-
*/
|
|
785
|
-
hasColorProperties() {
|
|
786
|
-
return (this.props.color !== 0 ||
|
|
787
|
-
this.props.colorTop !== 0 ||
|
|
788
|
-
this.props.colorBottom !== 0 ||
|
|
789
|
-
this.props.colorLeft !== 0 ||
|
|
790
|
-
this.props.colorRight !== 0 ||
|
|
791
|
-
this.props.colorTl !== 0 ||
|
|
792
|
-
this.props.colorTr !== 0 ||
|
|
793
|
-
this.props.colorBl !== 0 ||
|
|
794
|
-
this.props.colorBr !== 0);
|
|
795
|
-
}
|
|
796
|
-
hasShader() {
|
|
797
|
-
return this.props.shader !== null;
|
|
798
|
-
}
|
|
799
776
|
calculateRenderCoords() {
|
|
800
777
|
const { width, height } = this;
|
|
801
|
-
const
|
|
778
|
+
const g = this.globalTransform;
|
|
779
|
+
const tx = g.tx, ty = g.ty, ta = g.ta, tb = g.tb, tc = g.tc, td = g.td;
|
|
802
780
|
if (tb === 0 && tc === 0) {
|
|
803
781
|
const minX = tx;
|
|
804
782
|
const maxX = tx + width * ta;
|
|
@@ -865,7 +843,6 @@ export class CoreNode extends EventEmitter {
|
|
|
865
843
|
* Finally, the node's parentClippingRect and clippingRect properties are updated.
|
|
866
844
|
*/
|
|
867
845
|
calculateClippingRect(parentClippingRect) {
|
|
868
|
-
assertTruthy(this.globalTransform);
|
|
869
846
|
const { clippingRect, props, globalTransform: gt } = this;
|
|
870
847
|
const { clipping } = props;
|
|
871
848
|
const isRotated = gt.tb !== 0 || gt.tc !== 0;
|
|
@@ -903,68 +880,63 @@ export class CoreNode extends EventEmitter {
|
|
|
903
880
|
* Destroy the node and cleanup all resources
|
|
904
881
|
*/
|
|
905
882
|
destroy() {
|
|
883
|
+
if (this.destroyed === true) {
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
this.removeAllListeners();
|
|
887
|
+
this.destroyed = true;
|
|
906
888
|
this.unloadTexture();
|
|
907
|
-
this.clippingRect.valid = false;
|
|
908
889
|
this.isRenderable = false;
|
|
909
|
-
|
|
910
|
-
this.renderBound = undefined;
|
|
911
|
-
this.strictBound = undefined;
|
|
912
|
-
this.preloadBound = undefined;
|
|
913
|
-
this.globalTransform = undefined;
|
|
914
|
-
this.scaleRotateTransform = undefined;
|
|
915
|
-
this.localTransform = undefined;
|
|
916
|
-
this.props.texture = null;
|
|
917
|
-
this.props.shader = null;
|
|
890
|
+
// Kill children
|
|
918
891
|
while (this.children.length > 0) {
|
|
919
|
-
this.children[0]
|
|
892
|
+
this.children[0].destroy();
|
|
920
893
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
894
|
+
const parent = this.parent;
|
|
895
|
+
if (parent !== null) {
|
|
896
|
+
const index = parent.children.indexOf(this);
|
|
897
|
+
parent.children.splice(index, 1);
|
|
898
|
+
parent.setUpdateType(UpdateType.Children | UpdateType.ZIndexSortedChildren);
|
|
899
|
+
}
|
|
900
|
+
this.props.parent = null;
|
|
901
|
+
this.props.texture = null;
|
|
902
|
+
if (this.rtt === true) {
|
|
924
903
|
this.stage.renderer.removeRTTNode(this);
|
|
925
904
|
}
|
|
926
|
-
this.removeAllListeners();
|
|
927
905
|
}
|
|
928
906
|
renderQuads(renderer) {
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
if (!renderer.renderToTextureActive) {
|
|
933
|
-
return;
|
|
934
|
-
}
|
|
935
|
-
// Prevent quad rendering if parent render texture is not the active render texture
|
|
936
|
-
if (this.parentRenderTexture !== renderer.activeRttNode) {
|
|
907
|
+
if (this.parentHasRenderTexture === true) {
|
|
908
|
+
const rtt = renderer.renderToTextureActive;
|
|
909
|
+
if (rtt === false || this.parentRenderTexture !== renderer.activeRttNode)
|
|
937
910
|
return;
|
|
938
|
-
}
|
|
939
911
|
}
|
|
940
|
-
|
|
941
|
-
|
|
912
|
+
const p = this.props;
|
|
913
|
+
const t = this.globalTransform;
|
|
914
|
+
const coords = this.renderCoords;
|
|
915
|
+
const texture = p.texture || this.stage.defaultTexture;
|
|
942
916
|
renderer.addQuad({
|
|
943
|
-
width:
|
|
944
|
-
height:
|
|
917
|
+
width: p.width,
|
|
918
|
+
height: p.height,
|
|
945
919
|
colorTl: this.premultipliedColorTl,
|
|
946
920
|
colorTr: this.premultipliedColorTr,
|
|
947
921
|
colorBl: this.premultipliedColorBl,
|
|
948
922
|
colorBr: this.premultipliedColorBr,
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
texture: this.texture || this.stage.defaultTexture,
|
|
952
|
-
textureOptions: this.textureOptions,
|
|
923
|
+
texture,
|
|
924
|
+
textureOptions: p.textureOptions,
|
|
953
925
|
textureCoords: this.textureCoords,
|
|
954
|
-
|
|
955
|
-
shader: this.props.shader,
|
|
926
|
+
shader: p.shader,
|
|
956
927
|
alpha: this.worldAlpha,
|
|
957
928
|
clippingRect: this.clippingRect,
|
|
958
|
-
tx:
|
|
959
|
-
ty:
|
|
960
|
-
ta:
|
|
961
|
-
tb:
|
|
962
|
-
tc:
|
|
963
|
-
td:
|
|
964
|
-
renderCoords:
|
|
965
|
-
rtt:
|
|
929
|
+
tx: t.tx,
|
|
930
|
+
ty: t.ty,
|
|
931
|
+
ta: t.ta,
|
|
932
|
+
tb: t.tb,
|
|
933
|
+
tc: t.tc,
|
|
934
|
+
td: t.td,
|
|
935
|
+
renderCoords: coords,
|
|
936
|
+
rtt: p.rtt,
|
|
937
|
+
zIndex: this.calcZIndex,
|
|
966
938
|
parentHasRenderTexture: this.parentHasRenderTexture,
|
|
967
|
-
framebufferDimensions: this.parentHasRenderTexture
|
|
939
|
+
framebufferDimensions: this.parentHasRenderTexture
|
|
968
940
|
? this.parentFramebufferDimensions
|
|
969
941
|
: null,
|
|
970
942
|
});
|
|
@@ -1054,7 +1026,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1054
1026
|
set scaleX(value) {
|
|
1055
1027
|
if (this.props.scaleX !== value) {
|
|
1056
1028
|
this.props.scaleX = value;
|
|
1057
|
-
this.setUpdateType(UpdateType.
|
|
1029
|
+
this.setUpdateType(UpdateType.Local);
|
|
1058
1030
|
}
|
|
1059
1031
|
}
|
|
1060
1032
|
get scaleY() {
|
|
@@ -1063,7 +1035,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1063
1035
|
set scaleY(value) {
|
|
1064
1036
|
if (this.props.scaleY !== value) {
|
|
1065
1037
|
this.props.scaleY = value;
|
|
1066
|
-
this.setUpdateType(UpdateType.
|
|
1038
|
+
this.setUpdateType(UpdateType.Local);
|
|
1067
1039
|
}
|
|
1068
1040
|
}
|
|
1069
1041
|
get mount() {
|
|
@@ -1130,7 +1102,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1130
1102
|
set rotation(value) {
|
|
1131
1103
|
if (this.props.rotation !== value) {
|
|
1132
1104
|
this.props.rotation = value;
|
|
1133
|
-
this.setUpdateType(UpdateType.
|
|
1105
|
+
this.setUpdateType(UpdateType.Local);
|
|
1134
1106
|
}
|
|
1135
1107
|
}
|
|
1136
1108
|
get alpha() {
|
|
@@ -1151,9 +1123,18 @@ export class CoreNode extends EventEmitter {
|
|
|
1151
1123
|
this.props.autosize = value;
|
|
1152
1124
|
}
|
|
1153
1125
|
get boundsMargin() {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1126
|
+
const props = this.props;
|
|
1127
|
+
if (props.boundsMargin !== null) {
|
|
1128
|
+
return props.boundsMargin;
|
|
1129
|
+
}
|
|
1130
|
+
const parent = this.parent;
|
|
1131
|
+
if (parent !== null) {
|
|
1132
|
+
const margin = parent.boundsMargin;
|
|
1133
|
+
if (margin !== undefined) {
|
|
1134
|
+
return margin;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
return this.stage.boundsMargin;
|
|
1157
1138
|
}
|
|
1158
1139
|
set boundsMargin(value) {
|
|
1159
1140
|
if (value === this.props.boundsMargin) {
|
|
@@ -1182,11 +1163,20 @@ export class CoreNode extends EventEmitter {
|
|
|
1182
1163
|
return this.props.color;
|
|
1183
1164
|
}
|
|
1184
1165
|
set color(value) {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1166
|
+
const p = this.props;
|
|
1167
|
+
if (p.color === value)
|
|
1168
|
+
return;
|
|
1169
|
+
p.color = value;
|
|
1170
|
+
const has = value > 0;
|
|
1171
|
+
this.hasColorProps = has;
|
|
1172
|
+
if (p.colorTop !== value)
|
|
1173
|
+
this.colorTop = value;
|
|
1174
|
+
if (p.colorBottom !== value)
|
|
1175
|
+
this.colorBottom = value;
|
|
1176
|
+
if (p.colorLeft !== value)
|
|
1177
|
+
this.colorLeft = value;
|
|
1178
|
+
if (p.colorRight !== value)
|
|
1179
|
+
this.colorRight = value;
|
|
1190
1180
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1191
1181
|
}
|
|
1192
1182
|
get colorTop() {
|
|
@@ -1198,6 +1188,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1198
1188
|
this.colorTr = value;
|
|
1199
1189
|
}
|
|
1200
1190
|
this.props.colorTop = value;
|
|
1191
|
+
this.hasColorProps = value > 0;
|
|
1201
1192
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1202
1193
|
}
|
|
1203
1194
|
get colorBottom() {
|
|
@@ -1209,6 +1200,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1209
1200
|
this.colorBr = value;
|
|
1210
1201
|
}
|
|
1211
1202
|
this.props.colorBottom = value;
|
|
1203
|
+
this.hasColorProps = value > 0;
|
|
1212
1204
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1213
1205
|
}
|
|
1214
1206
|
get colorLeft() {
|
|
@@ -1220,6 +1212,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1220
1212
|
this.colorBl = value;
|
|
1221
1213
|
}
|
|
1222
1214
|
this.props.colorLeft = value;
|
|
1215
|
+
this.hasColorProps = value > 0;
|
|
1223
1216
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1224
1217
|
}
|
|
1225
1218
|
get colorRight() {
|
|
@@ -1231,6 +1224,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1231
1224
|
this.colorBr = value;
|
|
1232
1225
|
}
|
|
1233
1226
|
this.props.colorRight = value;
|
|
1227
|
+
this.hasColorProps = value > 0;
|
|
1234
1228
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1235
1229
|
}
|
|
1236
1230
|
get colorTl() {
|
|
@@ -1238,6 +1232,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1238
1232
|
}
|
|
1239
1233
|
set colorTl(value) {
|
|
1240
1234
|
this.props.colorTl = value;
|
|
1235
|
+
this.hasColorProps = value > 0;
|
|
1241
1236
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1242
1237
|
}
|
|
1243
1238
|
get colorTr() {
|
|
@@ -1245,6 +1240,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1245
1240
|
}
|
|
1246
1241
|
set colorTr(value) {
|
|
1247
1242
|
this.props.colorTr = value;
|
|
1243
|
+
this.hasColorProps = value > 0;
|
|
1248
1244
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1249
1245
|
}
|
|
1250
1246
|
get colorBl() {
|
|
@@ -1252,6 +1248,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1252
1248
|
}
|
|
1253
1249
|
set colorBl(value) {
|
|
1254
1250
|
this.props.colorBl = value;
|
|
1251
|
+
this.hasColorProps = value > 0;
|
|
1255
1252
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1256
1253
|
}
|
|
1257
1254
|
get colorBr() {
|
|
@@ -1259,6 +1256,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1259
1256
|
}
|
|
1260
1257
|
set colorBr(value) {
|
|
1261
1258
|
this.props.colorBr = value;
|
|
1259
|
+
this.hasColorProps = value > 0;
|
|
1262
1260
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1263
1261
|
}
|
|
1264
1262
|
// we're only interested in parent zIndex to test
|
|
@@ -1308,7 +1306,6 @@ export class CoreNode extends EventEmitter {
|
|
|
1308
1306
|
this.applyRTTInheritance(newParent);
|
|
1309
1307
|
}
|
|
1310
1308
|
}
|
|
1311
|
-
this.updateScaleRotateTransform();
|
|
1312
1309
|
// fetch render bounds from parent
|
|
1313
1310
|
this.setUpdateType(UpdateType.RenderBounds | UpdateType.Children);
|
|
1314
1311
|
}
|
|
@@ -1487,7 +1484,6 @@ export class CoreNode extends EventEmitter {
|
|
|
1487
1484
|
}
|
|
1488
1485
|
const oldTexture = this.props.texture;
|
|
1489
1486
|
if (oldTexture) {
|
|
1490
|
-
oldTexture.setRenderableOwner(this, false);
|
|
1491
1487
|
this.unloadTexture();
|
|
1492
1488
|
}
|
|
1493
1489
|
this.textureCoords = undefined;
|