@lightningjs/renderer 3.0.0-beta7 → 3.0.0-beta9
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 +257 -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.d.ts +4 -9
- package/dist/src/core/CoreTextureManager.js +41 -78
- 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 +10 -1
- package/dist/src/core/TextureMemoryManager.js +103 -50
- 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 +11 -4
- package/dist/src/core/animations/CoreAnimationController.js.map +1 -1
- package/dist/src/core/lib/WebGlContextWrapper.d.ts +19 -2
- package/dist/src/core/lib/WebGlContextWrapper.js +56 -25
- package/dist/src/core/lib/WebGlContextWrapper.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/renderers/webgl/WebGlShaderProgram.d.ts +4 -2
- package/dist/src/core/renderers/webgl/WebGlShaderProgram.js +31 -13
- package/dist/src/core/renderers/webgl/WebGlShaderProgram.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 +12 -0
- package/dist/src/core/textures/Texture.js +19 -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 +307 -313
- package/src/core/CoreTextNode.ts +23 -20
- package/src/core/CoreTextureManager.ts +40 -99
- package/src/core/Stage.ts +68 -65
- package/src/core/TextureMemoryManager.ts +135 -67
- package/src/core/animations/CoreAnimation.ts +7 -0
- package/src/core/animations/CoreAnimationController.ts +13 -4
- package/src/core/lib/WebGlContextWrapper.ts +69 -75
- 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/renderers/webgl/WebGlShaderProgram.ts +37 -14
- 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 +23 -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) {
|
|
@@ -318,6 +334,9 @@ export class CoreNode extends EventEmitter {
|
|
|
318
334
|
}
|
|
319
335
|
};
|
|
320
336
|
onTextureFailed = (_, error) => {
|
|
337
|
+
// immediately set isRenderable to false, so that we handle the error
|
|
338
|
+
// without waiting for the next frame loop
|
|
339
|
+
this.isRenderable = false;
|
|
321
340
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
322
341
|
// If parent has a render texture, flag that we need to update
|
|
323
342
|
if (this.parentHasRenderTexture) {
|
|
@@ -329,6 +348,9 @@ export class CoreNode extends EventEmitter {
|
|
|
329
348
|
});
|
|
330
349
|
};
|
|
331
350
|
onTextureFreed = () => {
|
|
351
|
+
// immediately set isRenderable to false, so that we handle the error
|
|
352
|
+
// without waiting for the next frame loop
|
|
353
|
+
this.isRenderable = false;
|
|
332
354
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
333
355
|
// If parent has a render texture, flag that we need to update
|
|
334
356
|
if (this.parentHasRenderTexture) {
|
|
@@ -352,42 +374,32 @@ export class CoreNode extends EventEmitter {
|
|
|
352
374
|
const parent = this.props.parent;
|
|
353
375
|
if (!parent)
|
|
354
376
|
return;
|
|
355
|
-
|
|
356
|
-
// Inform the parent if it doesn’t already have a child update
|
|
357
|
-
parent.setUpdateType(UpdateType.Children);
|
|
358
|
-
}
|
|
377
|
+
parent.setUpdateType(UpdateType.Children);
|
|
359
378
|
}
|
|
360
379
|
sortChildren() {
|
|
361
380
|
this.children.sort((a, b) => a.calcZIndex - b.calcZIndex);
|
|
362
381
|
}
|
|
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
382
|
updateLocalTransform() {
|
|
373
|
-
const
|
|
374
|
-
const
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
const
|
|
383
|
+
const p = this.props;
|
|
384
|
+
const { x, y, width, height } = p;
|
|
385
|
+
const mountTranslateX = p.mountX * width;
|
|
386
|
+
const mountTranslateY = p.mountY * height;
|
|
387
|
+
if (p.rotation !== 0 || p.scaleX !== 1 || p.scaleY !== 1) {
|
|
388
|
+
const pivotTranslateX = p.pivotX * width;
|
|
389
|
+
const pivotTranslateY = p.pivotY * height;
|
|
379
390
|
this.localTransform = Matrix3d.translate(x - mountTranslateX + pivotTranslateX, y - mountTranslateY + pivotTranslateY, this.localTransform)
|
|
380
|
-
.
|
|
391
|
+
.rotate(p.rotation)
|
|
392
|
+
.scale(p.scaleX, p.scaleY)
|
|
381
393
|
.translate(-pivotTranslateX, -pivotTranslateY);
|
|
382
394
|
}
|
|
383
395
|
else {
|
|
384
396
|
this.localTransform = Matrix3d.translate(x - mountTranslateX, y - mountTranslateY, this.localTransform);
|
|
385
397
|
}
|
|
386
398
|
// Handle 'contain' resize mode
|
|
387
|
-
const texture =
|
|
399
|
+
const texture = p.texture;
|
|
388
400
|
if (texture &&
|
|
389
401
|
texture.dimensions &&
|
|
390
|
-
|
|
402
|
+
p.textureOptions.resizeMode?.type === 'contain') {
|
|
391
403
|
let resizeModeScaleX = 1;
|
|
392
404
|
let resizeModeScaleY = 1;
|
|
393
405
|
let extraX = 0;
|
|
@@ -418,29 +430,33 @@ export class CoreNode extends EventEmitter {
|
|
|
418
430
|
.translate(extraX, extraY)
|
|
419
431
|
.scale(resizeModeScaleX, resizeModeScaleY);
|
|
420
432
|
}
|
|
421
|
-
this.setUpdateType(UpdateType.Global);
|
|
422
433
|
}
|
|
423
434
|
/**
|
|
424
435
|
* @todo: test for correct calculation flag
|
|
425
436
|
* @param delta
|
|
426
437
|
*/
|
|
427
438
|
update(delta, parentClippingRect) {
|
|
428
|
-
if (this.updateType
|
|
429
|
-
|
|
430
|
-
this.setUpdateType(UpdateType.Local);
|
|
439
|
+
if (this.updateType === UpdateType.None) {
|
|
440
|
+
return;
|
|
431
441
|
}
|
|
432
|
-
|
|
442
|
+
const props = this.props;
|
|
443
|
+
const parent = props.parent;
|
|
444
|
+
const parentHasRenderTexture = this.parentHasRenderTexture;
|
|
445
|
+
const hasParent = props.parent !== null;
|
|
446
|
+
let renderState = null;
|
|
447
|
+
let updateType = this.updateType;
|
|
448
|
+
let childUpdateType = this.childUpdateType;
|
|
449
|
+
let updateParent = false;
|
|
450
|
+
if (updateType & UpdateType.Local) {
|
|
433
451
|
this.updateLocalTransform();
|
|
434
|
-
|
|
452
|
+
updateType |= UpdateType.Global;
|
|
453
|
+
updateParent = hasParent;
|
|
435
454
|
}
|
|
436
|
-
const parent = this.props.parent;
|
|
437
|
-
let renderState = null;
|
|
438
455
|
// Handle specific RTT updates at this node level
|
|
439
|
-
if (
|
|
456
|
+
if (updateType & UpdateType.RenderTexture && this.rtt === true) {
|
|
440
457
|
this.hasRTTupdates = true;
|
|
441
458
|
}
|
|
442
|
-
if (
|
|
443
|
-
assertTruthy(this.localTransform);
|
|
459
|
+
if (updateType & UpdateType.Global) {
|
|
444
460
|
if (this.parentHasRenderTexture === true && parent?.rtt === true) {
|
|
445
461
|
// we are at the start of the RTT chain, so we need to reset the globalTransform
|
|
446
462
|
// for correct RTT rendering
|
|
@@ -464,24 +480,28 @@ export class CoreNode extends EventEmitter {
|
|
|
464
480
|
}
|
|
465
481
|
this.calculateRenderCoords();
|
|
466
482
|
this.updateBoundingRect();
|
|
467
|
-
|
|
468
|
-
UpdateType.
|
|
469
|
-
|
|
470
|
-
|
|
483
|
+
updateType |=
|
|
484
|
+
UpdateType.RenderState |
|
|
485
|
+
UpdateType.Children |
|
|
486
|
+
UpdateType.RecalcUniforms;
|
|
487
|
+
updateParent = hasParent;
|
|
488
|
+
childUpdateType |= UpdateType.Global;
|
|
471
489
|
if (this.clipping === true) {
|
|
472
|
-
|
|
473
|
-
|
|
490
|
+
updateType |= UpdateType.Clipping | UpdateType.RenderBounds;
|
|
491
|
+
updateParent = hasParent;
|
|
492
|
+
childUpdateType |= UpdateType.RenderBounds;
|
|
474
493
|
}
|
|
475
494
|
}
|
|
476
|
-
if (
|
|
495
|
+
if (updateType & UpdateType.RenderBounds) {
|
|
477
496
|
this.createRenderBounds();
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
497
|
+
updateType |= UpdateType.RenderState | UpdateType.Children;
|
|
498
|
+
updateParent = hasParent;
|
|
499
|
+
childUpdateType |= UpdateType.RenderBounds;
|
|
481
500
|
}
|
|
482
|
-
if (
|
|
501
|
+
if (updateType & UpdateType.RenderState) {
|
|
483
502
|
renderState = this.checkRenderBounds();
|
|
484
|
-
|
|
503
|
+
updateType |= UpdateType.IsRenderable;
|
|
504
|
+
updateParent = hasParent;
|
|
485
505
|
// if we're not going out of bounds, update the render state
|
|
486
506
|
// this is done so the update loop can finish before we mark a node
|
|
487
507
|
// as out of bounds
|
|
@@ -489,64 +509,69 @@ export class CoreNode extends EventEmitter {
|
|
|
489
509
|
this.updateRenderState(renderState);
|
|
490
510
|
}
|
|
491
511
|
}
|
|
492
|
-
if (
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
this.worldAlpha = this.props.alpha;
|
|
498
|
-
}
|
|
499
|
-
this.setUpdateType(UpdateType.Children |
|
|
512
|
+
if (updateType & UpdateType.WorldAlpha) {
|
|
513
|
+
this.worldAlpha = ((parent && parent.worldAlpha) || 1) * props.alpha;
|
|
514
|
+
updateType |=
|
|
500
515
|
UpdateType.PremultipliedColors |
|
|
501
|
-
|
|
502
|
-
|
|
516
|
+
UpdateType.Children |
|
|
517
|
+
UpdateType.IsRenderable;
|
|
518
|
+
updateParent = hasParent;
|
|
519
|
+
childUpdateType |= UpdateType.WorldAlpha;
|
|
503
520
|
}
|
|
504
|
-
if (
|
|
521
|
+
if (updateType & UpdateType.IsRenderable) {
|
|
505
522
|
this.updateIsRenderable();
|
|
506
523
|
}
|
|
507
|
-
if (
|
|
524
|
+
if (updateType & UpdateType.Clipping) {
|
|
508
525
|
this.calculateClippingRect(parentClippingRect);
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
if (
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
526
|
+
updateType |= UpdateType.Children;
|
|
527
|
+
updateParent = hasParent;
|
|
528
|
+
childUpdateType |= UpdateType.Clipping | UpdateType.RenderBounds;
|
|
529
|
+
}
|
|
530
|
+
if (updateType & UpdateType.PremultipliedColors) {
|
|
531
|
+
const alpha = this.worldAlpha;
|
|
532
|
+
const tl = props.colorTl;
|
|
533
|
+
const tr = props.colorTr;
|
|
534
|
+
const bl = props.colorBl;
|
|
535
|
+
const br = props.colorBr;
|
|
536
|
+
// Fast equality check (covers all 4 corners)
|
|
537
|
+
const same = tl === tr && tl === bl && tl === br;
|
|
538
|
+
const merged = mergeColorAlphaPremultiplied(tl, alpha, true);
|
|
539
|
+
this.premultipliedColorTl = merged;
|
|
540
|
+
if (same) {
|
|
519
541
|
this.premultipliedColorTr =
|
|
520
542
|
this.premultipliedColorBl =
|
|
521
543
|
this.premultipliedColorBr =
|
|
522
|
-
|
|
544
|
+
merged;
|
|
523
545
|
}
|
|
524
546
|
else {
|
|
525
|
-
this.premultipliedColorTr = mergeColorAlphaPremultiplied(
|
|
526
|
-
this.premultipliedColorBl = mergeColorAlphaPremultiplied(
|
|
527
|
-
this.premultipliedColorBr = mergeColorAlphaPremultiplied(
|
|
547
|
+
this.premultipliedColorTr = mergeColorAlphaPremultiplied(tr, alpha, true);
|
|
548
|
+
this.premultipliedColorBl = mergeColorAlphaPremultiplied(bl, alpha, true);
|
|
549
|
+
this.premultipliedColorBr = mergeColorAlphaPremultiplied(br, alpha, true);
|
|
528
550
|
}
|
|
529
551
|
}
|
|
552
|
+
if (updateParent === true) {
|
|
553
|
+
parent.setUpdateType(UpdateType.Children);
|
|
554
|
+
}
|
|
530
555
|
// No need to update zIndex if there is no parent
|
|
531
|
-
if (
|
|
556
|
+
if (updateType & UpdateType.CalculatedZIndex && parent !== null) {
|
|
532
557
|
this.calculateZIndex();
|
|
533
558
|
// Tell parent to re-sort children
|
|
534
559
|
parent.setUpdateType(UpdateType.ZIndexSortedChildren);
|
|
535
560
|
}
|
|
536
|
-
if (
|
|
561
|
+
if (props.strictBounds === true &&
|
|
537
562
|
this.renderState === CoreNodeRenderState.OutOfBounds) {
|
|
538
|
-
|
|
563
|
+
updateType &= ~UpdateType.RenderBounds; // remove render bounds update
|
|
539
564
|
return;
|
|
540
565
|
}
|
|
541
|
-
if (
|
|
566
|
+
if (updateType & UpdateType.RecalcUniforms &&
|
|
542
567
|
this.hasShaderUpdater === true) {
|
|
543
568
|
//this exists because the boolean hasShaderUpdater === true
|
|
544
569
|
this.shader.update();
|
|
545
570
|
}
|
|
546
|
-
if (
|
|
571
|
+
if (updateType & UpdateType.Children && this.children.length > 0) {
|
|
547
572
|
for (let i = 0, length = this.children.length; i < length; i++) {
|
|
548
573
|
const child = this.children[i];
|
|
549
|
-
child.setUpdateType(
|
|
574
|
+
child.setUpdateType(childUpdateType);
|
|
550
575
|
if (child.updateType === 0) {
|
|
551
576
|
continue;
|
|
552
577
|
}
|
|
@@ -564,14 +589,14 @@ export class CoreNode extends EventEmitter {
|
|
|
564
589
|
}
|
|
565
590
|
}
|
|
566
591
|
// If the node has an RTT parent and requires a texture re-render, inform the RTT parent
|
|
567
|
-
// if (this.parentHasRenderTexture &&
|
|
592
|
+
// if (this.parentHasRenderTexture && updateType & UpdateType.RenderTexture) {
|
|
568
593
|
// @TODO have a more scoped down updateType for RTT updates
|
|
569
|
-
if (
|
|
594
|
+
if (parentHasRenderTexture === true) {
|
|
570
595
|
this.notifyParentRTTOfUpdate();
|
|
571
596
|
}
|
|
572
597
|
// Sorting children MUST happen after children have been updated so
|
|
573
598
|
// that they have the oppotunity to update their calculated zIndex.
|
|
574
|
-
if (
|
|
599
|
+
if (updateType & UpdateType.ZIndexSortedChildren) {
|
|
575
600
|
// reorder z-index
|
|
576
601
|
this.sortChildren();
|
|
577
602
|
}
|
|
@@ -590,7 +615,6 @@ export class CoreNode extends EventEmitter {
|
|
|
590
615
|
// notify children that we are going out of bounds
|
|
591
616
|
// we have to do this now before we stop processing the render tree
|
|
592
617
|
this.notifyChildrenRTTOfUpdate(renderState);
|
|
593
|
-
// this.childUpdateType |= UpdateType.RenderState;
|
|
594
618
|
}
|
|
595
619
|
}
|
|
596
620
|
// reset update type
|
|
@@ -629,9 +653,6 @@ export class CoreNode extends EventEmitter {
|
|
|
629
653
|
}
|
|
630
654
|
}
|
|
631
655
|
checkRenderBounds() {
|
|
632
|
-
assertTruthy(this.renderBound);
|
|
633
|
-
assertTruthy(this.strictBound);
|
|
634
|
-
assertTruthy(this.preloadBound);
|
|
635
656
|
if (boundInsideBound(this.renderBound, this.strictBound)) {
|
|
636
657
|
return CoreNodeRenderState.InViewport;
|
|
637
658
|
}
|
|
@@ -650,10 +671,8 @@ export class CoreNode extends EventEmitter {
|
|
|
650
671
|
return CoreNodeRenderState.OutOfBounds;
|
|
651
672
|
}
|
|
652
673
|
updateBoundingRect() {
|
|
653
|
-
const transform = this.sceneGlobalTransform || this.globalTransform;
|
|
654
|
-
const renderCoords = this.sceneRenderCoords || this.renderCoords;
|
|
655
|
-
assertTruthy(transform);
|
|
656
|
-
assertTruthy(renderCoords);
|
|
674
|
+
const transform = (this.sceneGlobalTransform || this.globalTransform);
|
|
675
|
+
const renderCoords = (this.sceneRenderCoords || this.renderCoords);
|
|
657
676
|
if (transform.tb === 0 || transform.tc === 0) {
|
|
658
677
|
this.renderBound = createBound(renderCoords.x1, renderCoords.y1, renderCoords.x3, renderCoords.y3, this.renderBound);
|
|
659
678
|
}
|
|
@@ -717,7 +736,8 @@ export class CoreNode extends EventEmitter {
|
|
|
717
736
|
let newIsRenderable = false;
|
|
718
737
|
let needsTextureOwnership = false;
|
|
719
738
|
// If the node is out of bounds or has an alpha of 0, it is not renderable
|
|
720
|
-
if (this.
|
|
739
|
+
if (this.worldAlpha === 0 ||
|
|
740
|
+
this.renderState <= CoreNodeRenderState.OutOfBounds) {
|
|
721
741
|
this.updateTextureOwnership(false);
|
|
722
742
|
this.setRenderable(false);
|
|
723
743
|
return;
|
|
@@ -727,8 +747,11 @@ export class CoreNode extends EventEmitter {
|
|
|
727
747
|
// we're only renderable if the texture state is loaded
|
|
728
748
|
newIsRenderable = this.texture.state === 'loaded';
|
|
729
749
|
}
|
|
730
|
-
else if (
|
|
731
|
-
|
|
750
|
+
else if (
|
|
751
|
+
// check shader
|
|
752
|
+
(this.props.shader !== null || this.hasColorProps === true) &&
|
|
753
|
+
// check dimensions
|
|
754
|
+
(this.props.width !== 0 && this.props.height !== 0) === true) {
|
|
732
755
|
// This mean we have dimensions and a color set, so we can render a ColorTexture
|
|
733
756
|
if (this.stage.defaultTexture &&
|
|
734
757
|
this.stage.defaultTexture.state === 'loaded') {
|
|
@@ -738,17 +761,6 @@ export class CoreNode extends EventEmitter {
|
|
|
738
761
|
this.updateTextureOwnership(needsTextureOwnership);
|
|
739
762
|
this.setRenderable(newIsRenderable);
|
|
740
763
|
}
|
|
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
764
|
/**
|
|
753
765
|
* Sets the renderable state and triggers changes if necessary.
|
|
754
766
|
* @param isRenderable - The new renderable state
|
|
@@ -767,38 +779,10 @@ export class CoreNode extends EventEmitter {
|
|
|
767
779
|
updateTextureOwnership(isRenderable) {
|
|
768
780
|
this.texture?.setRenderableOwner(this, isRenderable);
|
|
769
781
|
}
|
|
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
782
|
calculateRenderCoords() {
|
|
800
783
|
const { width, height } = this;
|
|
801
|
-
const
|
|
784
|
+
const g = this.globalTransform;
|
|
785
|
+
const tx = g.tx, ty = g.ty, ta = g.ta, tb = g.tb, tc = g.tc, td = g.td;
|
|
802
786
|
if (tb === 0 && tc === 0) {
|
|
803
787
|
const minX = tx;
|
|
804
788
|
const maxX = tx + width * ta;
|
|
@@ -865,7 +849,6 @@ export class CoreNode extends EventEmitter {
|
|
|
865
849
|
* Finally, the node's parentClippingRect and clippingRect properties are updated.
|
|
866
850
|
*/
|
|
867
851
|
calculateClippingRect(parentClippingRect) {
|
|
868
|
-
assertTruthy(this.globalTransform);
|
|
869
852
|
const { clippingRect, props, globalTransform: gt } = this;
|
|
870
853
|
const { clipping } = props;
|
|
871
854
|
const isRotated = gt.tb !== 0 || gt.tc !== 0;
|
|
@@ -903,68 +886,63 @@ export class CoreNode extends EventEmitter {
|
|
|
903
886
|
* Destroy the node and cleanup all resources
|
|
904
887
|
*/
|
|
905
888
|
destroy() {
|
|
889
|
+
if (this.destroyed === true) {
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
this.removeAllListeners();
|
|
893
|
+
this.destroyed = true;
|
|
906
894
|
this.unloadTexture();
|
|
907
|
-
this.clippingRect.valid = false;
|
|
908
895
|
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;
|
|
896
|
+
// Kill children
|
|
918
897
|
while (this.children.length > 0) {
|
|
919
|
-
this.children[0]
|
|
898
|
+
this.children[0].destroy();
|
|
920
899
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
900
|
+
const parent = this.parent;
|
|
901
|
+
if (parent !== null) {
|
|
902
|
+
const index = parent.children.indexOf(this);
|
|
903
|
+
parent.children.splice(index, 1);
|
|
904
|
+
parent.setUpdateType(UpdateType.Children | UpdateType.ZIndexSortedChildren);
|
|
905
|
+
}
|
|
906
|
+
this.props.parent = null;
|
|
907
|
+
this.props.texture = null;
|
|
908
|
+
if (this.rtt === true) {
|
|
924
909
|
this.stage.renderer.removeRTTNode(this);
|
|
925
910
|
}
|
|
926
|
-
this.removeAllListeners();
|
|
927
911
|
}
|
|
928
912
|
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) {
|
|
913
|
+
if (this.parentHasRenderTexture === true) {
|
|
914
|
+
const rtt = renderer.renderToTextureActive;
|
|
915
|
+
if (rtt === false || this.parentRenderTexture !== renderer.activeRttNode)
|
|
937
916
|
return;
|
|
938
|
-
}
|
|
939
917
|
}
|
|
940
|
-
|
|
941
|
-
|
|
918
|
+
const p = this.props;
|
|
919
|
+
const t = this.globalTransform;
|
|
920
|
+
const coords = this.renderCoords;
|
|
921
|
+
const texture = p.texture || this.stage.defaultTexture;
|
|
942
922
|
renderer.addQuad({
|
|
943
|
-
width:
|
|
944
|
-
height:
|
|
923
|
+
width: p.width,
|
|
924
|
+
height: p.height,
|
|
945
925
|
colorTl: this.premultipliedColorTl,
|
|
946
926
|
colorTr: this.premultipliedColorTr,
|
|
947
927
|
colorBl: this.premultipliedColorBl,
|
|
948
928
|
colorBr: this.premultipliedColorBr,
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
texture: this.texture || this.stage.defaultTexture,
|
|
952
|
-
textureOptions: this.textureOptions,
|
|
929
|
+
texture,
|
|
930
|
+
textureOptions: p.textureOptions,
|
|
953
931
|
textureCoords: this.textureCoords,
|
|
954
|
-
|
|
955
|
-
shader: this.props.shader,
|
|
932
|
+
shader: p.shader,
|
|
956
933
|
alpha: this.worldAlpha,
|
|
957
934
|
clippingRect: this.clippingRect,
|
|
958
|
-
tx:
|
|
959
|
-
ty:
|
|
960
|
-
ta:
|
|
961
|
-
tb:
|
|
962
|
-
tc:
|
|
963
|
-
td:
|
|
964
|
-
renderCoords:
|
|
965
|
-
rtt:
|
|
935
|
+
tx: t.tx,
|
|
936
|
+
ty: t.ty,
|
|
937
|
+
ta: t.ta,
|
|
938
|
+
tb: t.tb,
|
|
939
|
+
tc: t.tc,
|
|
940
|
+
td: t.td,
|
|
941
|
+
renderCoords: coords,
|
|
942
|
+
rtt: p.rtt,
|
|
943
|
+
zIndex: this.calcZIndex,
|
|
966
944
|
parentHasRenderTexture: this.parentHasRenderTexture,
|
|
967
|
-
framebufferDimensions: this.parentHasRenderTexture
|
|
945
|
+
framebufferDimensions: this.parentHasRenderTexture
|
|
968
946
|
? this.parentFramebufferDimensions
|
|
969
947
|
: null,
|
|
970
948
|
});
|
|
@@ -1054,7 +1032,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1054
1032
|
set scaleX(value) {
|
|
1055
1033
|
if (this.props.scaleX !== value) {
|
|
1056
1034
|
this.props.scaleX = value;
|
|
1057
|
-
this.setUpdateType(UpdateType.
|
|
1035
|
+
this.setUpdateType(UpdateType.Local);
|
|
1058
1036
|
}
|
|
1059
1037
|
}
|
|
1060
1038
|
get scaleY() {
|
|
@@ -1063,7 +1041,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1063
1041
|
set scaleY(value) {
|
|
1064
1042
|
if (this.props.scaleY !== value) {
|
|
1065
1043
|
this.props.scaleY = value;
|
|
1066
|
-
this.setUpdateType(UpdateType.
|
|
1044
|
+
this.setUpdateType(UpdateType.Local);
|
|
1067
1045
|
}
|
|
1068
1046
|
}
|
|
1069
1047
|
get mount() {
|
|
@@ -1130,7 +1108,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1130
1108
|
set rotation(value) {
|
|
1131
1109
|
if (this.props.rotation !== value) {
|
|
1132
1110
|
this.props.rotation = value;
|
|
1133
|
-
this.setUpdateType(UpdateType.
|
|
1111
|
+
this.setUpdateType(UpdateType.Local);
|
|
1134
1112
|
}
|
|
1135
1113
|
}
|
|
1136
1114
|
get alpha() {
|
|
@@ -1151,9 +1129,18 @@ export class CoreNode extends EventEmitter {
|
|
|
1151
1129
|
this.props.autosize = value;
|
|
1152
1130
|
}
|
|
1153
1131
|
get boundsMargin() {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1132
|
+
const props = this.props;
|
|
1133
|
+
if (props.boundsMargin !== null) {
|
|
1134
|
+
return props.boundsMargin;
|
|
1135
|
+
}
|
|
1136
|
+
const parent = this.parent;
|
|
1137
|
+
if (parent !== null) {
|
|
1138
|
+
const margin = parent.boundsMargin;
|
|
1139
|
+
if (margin !== undefined) {
|
|
1140
|
+
return margin;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
return this.stage.boundsMargin;
|
|
1157
1144
|
}
|
|
1158
1145
|
set boundsMargin(value) {
|
|
1159
1146
|
if (value === this.props.boundsMargin) {
|
|
@@ -1182,11 +1169,20 @@ export class CoreNode extends EventEmitter {
|
|
|
1182
1169
|
return this.props.color;
|
|
1183
1170
|
}
|
|
1184
1171
|
set color(value) {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1172
|
+
const p = this.props;
|
|
1173
|
+
if (p.color === value)
|
|
1174
|
+
return;
|
|
1175
|
+
p.color = value;
|
|
1176
|
+
const has = value > 0;
|
|
1177
|
+
this.hasColorProps = has;
|
|
1178
|
+
if (p.colorTop !== value)
|
|
1179
|
+
this.colorTop = value;
|
|
1180
|
+
if (p.colorBottom !== value)
|
|
1181
|
+
this.colorBottom = value;
|
|
1182
|
+
if (p.colorLeft !== value)
|
|
1183
|
+
this.colorLeft = value;
|
|
1184
|
+
if (p.colorRight !== value)
|
|
1185
|
+
this.colorRight = value;
|
|
1190
1186
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1191
1187
|
}
|
|
1192
1188
|
get colorTop() {
|
|
@@ -1198,6 +1194,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1198
1194
|
this.colorTr = value;
|
|
1199
1195
|
}
|
|
1200
1196
|
this.props.colorTop = value;
|
|
1197
|
+
this.hasColorProps = value > 0;
|
|
1201
1198
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1202
1199
|
}
|
|
1203
1200
|
get colorBottom() {
|
|
@@ -1209,6 +1206,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1209
1206
|
this.colorBr = value;
|
|
1210
1207
|
}
|
|
1211
1208
|
this.props.colorBottom = value;
|
|
1209
|
+
this.hasColorProps = value > 0;
|
|
1212
1210
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1213
1211
|
}
|
|
1214
1212
|
get colorLeft() {
|
|
@@ -1220,6 +1218,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1220
1218
|
this.colorBl = value;
|
|
1221
1219
|
}
|
|
1222
1220
|
this.props.colorLeft = value;
|
|
1221
|
+
this.hasColorProps = value > 0;
|
|
1223
1222
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1224
1223
|
}
|
|
1225
1224
|
get colorRight() {
|
|
@@ -1231,6 +1230,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1231
1230
|
this.colorBr = value;
|
|
1232
1231
|
}
|
|
1233
1232
|
this.props.colorRight = value;
|
|
1233
|
+
this.hasColorProps = value > 0;
|
|
1234
1234
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1235
1235
|
}
|
|
1236
1236
|
get colorTl() {
|
|
@@ -1238,6 +1238,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1238
1238
|
}
|
|
1239
1239
|
set colorTl(value) {
|
|
1240
1240
|
this.props.colorTl = value;
|
|
1241
|
+
this.hasColorProps = value > 0;
|
|
1241
1242
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1242
1243
|
}
|
|
1243
1244
|
get colorTr() {
|
|
@@ -1245,6 +1246,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1245
1246
|
}
|
|
1246
1247
|
set colorTr(value) {
|
|
1247
1248
|
this.props.colorTr = value;
|
|
1249
|
+
this.hasColorProps = value > 0;
|
|
1248
1250
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1249
1251
|
}
|
|
1250
1252
|
get colorBl() {
|
|
@@ -1252,6 +1254,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1252
1254
|
}
|
|
1253
1255
|
set colorBl(value) {
|
|
1254
1256
|
this.props.colorBl = value;
|
|
1257
|
+
this.hasColorProps = value > 0;
|
|
1255
1258
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1256
1259
|
}
|
|
1257
1260
|
get colorBr() {
|
|
@@ -1259,6 +1262,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1259
1262
|
}
|
|
1260
1263
|
set colorBr(value) {
|
|
1261
1264
|
this.props.colorBr = value;
|
|
1265
|
+
this.hasColorProps = value > 0;
|
|
1262
1266
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1263
1267
|
}
|
|
1264
1268
|
// we're only interested in parent zIndex to test
|
|
@@ -1308,7 +1312,6 @@ export class CoreNode extends EventEmitter {
|
|
|
1308
1312
|
this.applyRTTInheritance(newParent);
|
|
1309
1313
|
}
|
|
1310
1314
|
}
|
|
1311
|
-
this.updateScaleRotateTransform();
|
|
1312
1315
|
// fetch render bounds from parent
|
|
1313
1316
|
this.setUpdateType(UpdateType.RenderBounds | UpdateType.Children);
|
|
1314
1317
|
}
|
|
@@ -1487,7 +1490,6 @@ export class CoreNode extends EventEmitter {
|
|
|
1487
1490
|
}
|
|
1488
1491
|
const oldTexture = this.props.texture;
|
|
1489
1492
|
if (oldTexture) {
|
|
1490
|
-
oldTexture.setRenderableOwner(this, false);
|
|
1491
1493
|
this.unloadTexture();
|
|
1492
1494
|
}
|
|
1493
1495
|
this.textureCoords = undefined;
|