@lightningjs/renderer 0.7.5 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -202
- package/NOTICE +3 -3
- package/README.md +233 -221
- package/dist/src/common/CommonTypes.d.ts +12 -0
- package/dist/src/core/CoreNode.d.ts +83 -9
- package/dist/src/core/CoreNode.js +232 -44
- package/dist/src/core/CoreNode.js.map +1 -1
- package/dist/src/core/CoreTextNode.d.ts +6 -1
- package/dist/src/core/CoreTextNode.js +33 -20
- package/dist/src/core/CoreTextNode.js.map +1 -1
- package/dist/src/core/CoreTextureManager.d.ts +3 -1
- package/dist/src/core/CoreTextureManager.js +11 -2
- package/dist/src/core/CoreTextureManager.js.map +1 -1
- package/dist/src/core/Stage.d.ts +6 -0
- package/dist/src/core/Stage.js +16 -1
- package/dist/src/core/Stage.js.map +1 -1
- package/dist/src/core/TextureMemoryManager.d.ts +12 -0
- package/dist/src/core/TextureMemoryManager.js +42 -0
- package/dist/src/core/TextureMemoryManager.js.map +1 -0
- package/dist/src/core/lib/ImageWorker.d.ts +0 -1
- package/dist/src/core/lib/ImageWorker.js +55 -40
- package/dist/src/core/lib/ImageWorker.js.map +1 -1
- package/dist/src/core/lib/RenderCoords.d.ts +13 -0
- package/dist/src/core/lib/RenderCoords.js +63 -0
- package/dist/src/core/lib/RenderCoords.js.map +1 -0
- package/dist/src/core/lib/WebGlContext.d.ts +414 -0
- package/dist/src/core/lib/WebGlContext.js +640 -0
- package/dist/src/core/lib/WebGlContext.js.map +1 -0
- package/dist/src/core/lib/utils.d.ts +1 -0
- package/dist/src/core/lib/utils.js +6 -0
- package/dist/src/core/lib/utils.js.map +1 -1
- package/dist/src/core/platform.js +8 -0
- package/dist/src/core/platform.js.map +1 -1
- package/dist/src/core/renderers/CoreContextTexture.d.ts +5 -1
- package/dist/src/core/renderers/CoreContextTexture.js +3 -1
- package/dist/src/core/renderers/CoreContextTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.d.ts +2 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js +2 -2
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.d.ts +3 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js +26 -6
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.d.ts +3 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +4 -2
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -1
- package/dist/src/core/renderers/webgl/internal/RendererUtils.d.ts +9 -0
- package/dist/src/core/renderers/webgl/internal/RendererUtils.js +14 -0
- package/dist/src/core/renderers/webgl/internal/RendererUtils.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.js +47 -47
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js +61 -61
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js +93 -93
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js +63 -63
- package/dist/src/core/renderers/webgl/shaders/SdfShader.js +49 -49
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js +15 -15
- package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js +5 -5
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js +15 -15
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js +15 -15
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js +15 -15
- package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.js +42 -42
- package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js +44 -44
- package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js +3 -3
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js +44 -57
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.d.ts +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js +33 -39
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.js +37 -37
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js +19 -19
- package/dist/src/core/scene/Scene.d.ts +59 -0
- package/dist/src/core/scene/Scene.js +106 -0
- package/dist/src/core/scene/Scene.js.map +1 -0
- package/dist/src/core/text-rendering/TrFontManager.js +30 -25
- package/dist/src/core/text-rendering/TrFontManager.js.map +1 -1
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.d.ts +2 -0
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js +26 -2
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.d.ts +8 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js +34 -6
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/findNearestMultiple.d.ts +8 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/findNearestMultiple.js +29 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/findNearestMultiple.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js +1 -3
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js.map +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/SdfBufferHelper.d.ts +19 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/SdfBufferHelper.js +84 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/SdfBufferHelper.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/layoutLine.d.ts +8 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/layoutLine.js +40 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/layoutLine.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/layoutText2.d.ts +2 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/layoutText2.js +41 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/layoutText2.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/utils.d.ts +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/utils.js +4 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/utils.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2.d.ts +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2.js +2 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.d.ts +20 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js +55 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/roundUpToMultiple.d.ts +9 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/roundUpToMultiple.js +32 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/roundUpToMultiple.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/TextRenderer.d.ts +31 -0
- package/dist/src/core/text-rendering/renderers/TextRenderer.js +26 -0
- package/dist/src/core/text-rendering/renderers/TextRenderer.js.map +1 -1
- package/dist/src/core/textures/ImageTexture.js +16 -2
- package/dist/src/core/textures/ImageTexture.js.map +1 -1
- package/dist/src/core/textures/Texture.d.ts +27 -2
- package/dist/src/core/textures/Texture.js +30 -1
- package/dist/src/core/textures/Texture.js.map +1 -1
- package/dist/src/core/utils.d.ts +1 -1
- package/dist/src/main-api/ICoreDriver.d.ts +1 -0
- package/dist/src/main-api/Inspector.js +2 -1
- package/dist/src/main-api/Inspector.js.map +1 -1
- package/dist/src/main-api/RendererMain.d.ts +15 -0
- package/dist/src/main-api/RendererMain.js +7 -1
- package/dist/src/main-api/RendererMain.js.map +1 -1
- package/dist/src/render-drivers/main/MainCoreDriver.d.ts +1 -0
- package/dist/src/render-drivers/main/MainCoreDriver.js +8 -0
- package/dist/src/render-drivers/main/MainCoreDriver.js.map +1 -1
- package/dist/src/render-drivers/main/MainOnlyNode.d.ts +5 -0
- package/dist/src/render-drivers/main/MainOnlyNode.js +26 -0
- package/dist/src/render-drivers/main/MainOnlyNode.js.map +1 -1
- package/dist/src/render-drivers/threadx/ThreadXCoreDriver.js +2 -0
- package/dist/src/render-drivers/threadx/ThreadXCoreDriver.js.map +1 -1
- package/dist/src/render-drivers/threadx/ThreadXRendererMessage.d.ts +2 -0
- package/dist/src/render-drivers/threadx/ThreadXRendererMessage.js.map +1 -1
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js +3 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js.map +1 -1
- package/dist/src/render-drivers/threadx/worker/renderer.js +2 -0
- package/dist/src/render-drivers/threadx/worker/renderer.js.map +1 -1
- package/dist/src/utils.d.ts +6 -0
- package/dist/src/utils.js +9 -1
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/exports/core-api.ts +102 -102
- package/exports/main-api.ts +60 -60
- package/exports/utils.ts +41 -41
- package/package.json +1 -1
- package/scripts/please-use-pnpm.js +13 -13
- package/src/common/CommonTypes.ts +132 -113
- package/src/common/EventEmitter.ts +77 -77
- package/src/common/IAnimationController.ts +29 -29
- package/src/core/CoreExtension.ts +32 -32
- package/src/core/CoreNode.ts +1199 -955
- package/src/core/CoreShaderManager.ts +243 -243
- package/src/core/CoreTextNode.ts +400 -391
- package/src/core/CoreTextureManager.ts +339 -326
- package/src/core/Stage.ts +375 -354
- package/src/core/TextureMemoryManager.ts +66 -0
- package/src/core/animations/AnimationManager.ts +38 -38
- package/src/core/animations/CoreAnimation.ts +181 -181
- package/src/core/animations/CoreAnimationController.ts +148 -148
- package/src/core/lib/ContextSpy.ts +41 -41
- package/src/core/lib/ImageWorker.ts +149 -135
- package/src/core/lib/Matrix3d.ts +290 -290
- package/src/core/lib/RenderCoords.ts +86 -0
- package/src/core/lib/WebGlContextWrapper.ts +992 -992
- package/src/core/lib/textureCompression.ts +152 -152
- package/src/core/lib/utils.ts +250 -241
- package/src/core/platform.ts +54 -46
- package/src/core/renderers/CoreContextTexture.ts +35 -30
- package/src/core/renderers/CoreRenderOp.ts +22 -22
- package/src/core/renderers/CoreRenderer.ts +63 -63
- package/src/core/renderers/CoreShader.ts +41 -41
- package/src/core/renderers/webgl/WebGlCoreCtxSubTexture.ts +42 -37
- package/src/core/renderers/webgl/WebGlCoreCtxTexture.ts +261 -230
- package/src/core/renderers/webgl/WebGlCoreRenderOp.ts +107 -107
- package/src/core/renderers/webgl/WebGlCoreRenderer.ts +528 -520
- package/src/core/renderers/webgl/WebGlCoreShader.ts +337 -337
- package/src/core/renderers/webgl/internal/BufferCollection.ts +54 -54
- package/src/core/renderers/webgl/internal/RendererUtils.ts +148 -131
- package/src/core/renderers/webgl/internal/ShaderUtils.ts +136 -136
- package/src/core/renderers/webgl/internal/WebGlUtils.ts +35 -35
- package/src/core/renderers/webgl/shaders/DefaultShader.ts +95 -95
- package/src/core/renderers/webgl/shaders/DefaultShaderBatched.ts +132 -132
- package/src/core/renderers/webgl/shaders/DynamicShader.ts +474 -474
- package/src/core/renderers/webgl/shaders/RoundedRectangle.ts +161 -161
- package/src/core/renderers/webgl/shaders/SdfShader.ts +174 -174
- package/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.ts +101 -101
- package/src/core/renderers/webgl/shaders/effects/BorderEffect.ts +86 -86
- package/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.ts +101 -101
- package/src/core/renderers/webgl/shaders/effects/BorderRightEffect.ts +101 -101
- package/src/core/renderers/webgl/shaders/effects/BorderTopEffect.ts +101 -101
- package/src/core/renderers/webgl/shaders/effects/EffectUtils.ts +33 -33
- package/src/core/renderers/webgl/shaders/effects/FadeOutEffect.ts +135 -135
- package/src/core/renderers/webgl/shaders/effects/GlitchEffect.ts +145 -145
- package/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.ts +67 -67
- package/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.ts +160 -176
- package/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.ts +153 -159
- package/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.ts +186 -186
- package/src/core/renderers/webgl/shaders/effects/RadiusEffect.ts +121 -121
- package/src/core/renderers/webgl/shaders/effects/ShaderEffect.ts +114 -114
- package/src/core/text-rendering/TextTextureRendererUtils.ts +189 -189
- package/src/core/text-rendering/TrFontManager.ts +170 -166
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.ts +141 -141
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.ts +139 -139
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.test.ts +173 -173
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.ts +169 -169
- package/src/core/text-rendering/font-face-types/TrFontFace.ts +105 -105
- package/src/core/text-rendering/font-face-types/WebTrFontFace.ts +77 -77
- package/src/core/text-rendering/renderers/CanvasTextRenderer.ts +780 -751
- package/src/core/text-rendering/renderers/LightningTextTextureRenderer.ts +741 -741
- package/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.ts +812 -778
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.test.ts +48 -48
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.ts +66 -66
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.ts +52 -52
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.ts +32 -32
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.ts +84 -84
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.test.ts +133 -133
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.ts +38 -38
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.ts +391 -393
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.test.ts +49 -49
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.ts +51 -51
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/setRenderWindow.test.ts +205 -205
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/setRenderWindow.ts +93 -93
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/util.ts +40 -40
- package/src/core/text-rendering/renderers/TextRenderer.ts +548 -504
- package/src/core/textures/ColorTexture.ts +86 -86
- package/src/core/textures/ImageTexture.ts +154 -140
- package/src/core/textures/NoiseTexture.ts +96 -96
- package/src/core/textures/SubTexture.ts +143 -143
- package/src/core/textures/Texture.ts +261 -218
- package/src/core/utils.ts +224 -224
- package/src/env.d.ts +7 -7
- package/src/main-api/ICoreDriver.ts +68 -66
- package/src/main-api/INode.ts +499 -499
- package/src/main-api/Inspector.ts +440 -439
- package/src/main-api/RendererMain.ts +676 -652
- package/src/main-api/texture-usage-trackers/FinalizationRegistryTextureUsageTracker.ts +45 -45
- package/src/main-api/texture-usage-trackers/ManualCountTextureUsageTracker.ts +154 -154
- package/src/main-api/texture-usage-trackers/TextureUsageTracker.ts +54 -54
- package/src/render-drivers/main/MainCoreDriver.ts +158 -148
- package/src/render-drivers/main/MainOnlyNode.ts +500 -466
- package/src/render-drivers/main/MainOnlyTextNode.ts +261 -261
- package/src/render-drivers/threadx/NodeStruct.ts +300 -300
- package/src/render-drivers/threadx/SharedNode.ts +97 -97
- package/src/render-drivers/threadx/TextNodeStruct.ts +211 -211
- package/src/render-drivers/threadx/ThreadXCoreDriver.ts +287 -285
- package/src/render-drivers/threadx/ThreadXMainAnimationController.ts +99 -99
- package/src/render-drivers/threadx/ThreadXMainNode.ts +192 -192
- package/src/render-drivers/threadx/ThreadXMainTextNode.ts +85 -85
- package/src/render-drivers/threadx/ThreadXRendererMessage.ts +112 -110
- package/src/render-drivers/threadx/worker/ThreadXRendererNode.ts +245 -238
- package/src/render-drivers/threadx/worker/ThreadXRendererTextNode.ts +149 -149
- package/src/render-drivers/threadx/worker/renderer.ts +153 -151
- package/src/render-drivers/utils.ts +97 -97
- package/src/utils.ts +216 -207
- package/COPYING +0 -1
package/src/core/CoreNode.ts
CHANGED
|
@@ -1,955 +1,1199 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
-
* following copyright and licenses apply:
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { assertTruthy, mergeColorAlphaPremultiplied } from '../utils.js';
|
|
21
|
-
import type { ShaderMap } from './CoreShaderManager.js';
|
|
22
|
-
import type {
|
|
23
|
-
ExtractProps,
|
|
24
|
-
TextureMap,
|
|
25
|
-
TextureOptions,
|
|
26
|
-
} from './CoreTextureManager.js';
|
|
27
|
-
import type { CoreRenderer } from './renderers/CoreRenderer.js';
|
|
28
|
-
import type { CoreShader } from './renderers/CoreShader.js';
|
|
29
|
-
import type { Stage } from './Stage.js';
|
|
30
|
-
import type {
|
|
31
|
-
Texture,
|
|
32
|
-
TextureFailedEventHandler,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
*
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
this.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
this.
|
|
384
|
-
this.
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
this.
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
this.
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
if (this.
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
this.
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
this.
|
|
614
|
-
(
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
this.
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
this.
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
this.
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
this.
|
|
786
|
-
this.
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
this.props
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
this.
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
this.
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
this.
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
this.
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
this.
|
|
906
|
-
this.
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { assertTruthy, mergeColorAlphaPremultiplied } from '../utils.js';
|
|
21
|
+
import type { ShaderMap } from './CoreShaderManager.js';
|
|
22
|
+
import type {
|
|
23
|
+
ExtractProps,
|
|
24
|
+
TextureMap,
|
|
25
|
+
TextureOptions,
|
|
26
|
+
} from './CoreTextureManager.js';
|
|
27
|
+
import type { CoreRenderer } from './renderers/CoreRenderer.js';
|
|
28
|
+
import type { CoreShader } from './renderers/CoreShader.js';
|
|
29
|
+
import type { Stage } from './Stage.js';
|
|
30
|
+
import type {
|
|
31
|
+
Texture,
|
|
32
|
+
TextureFailedEventHandler,
|
|
33
|
+
TextureFreedEventHandler,
|
|
34
|
+
TextureLoadedEventHandler,
|
|
35
|
+
} from './textures/Texture.js';
|
|
36
|
+
import type {
|
|
37
|
+
NodeTextureFailedPayload,
|
|
38
|
+
NodeTextureFreedPayload,
|
|
39
|
+
NodeTextureLoadedPayload,
|
|
40
|
+
} from '../common/CommonTypes.js';
|
|
41
|
+
import { EventEmitter } from '../common/EventEmitter.js';
|
|
42
|
+
import {
|
|
43
|
+
copyRect,
|
|
44
|
+
intersectRect,
|
|
45
|
+
type Bound,
|
|
46
|
+
type RectWithValid,
|
|
47
|
+
createBound,
|
|
48
|
+
boundInsideBound,
|
|
49
|
+
} from './lib/utils.js';
|
|
50
|
+
import { Matrix3d } from './lib/Matrix3d.js';
|
|
51
|
+
import { RenderCoords } from './lib/RenderCoords.js';
|
|
52
|
+
|
|
53
|
+
export enum CoreNodeRenderState {
|
|
54
|
+
Init = 0,
|
|
55
|
+
OutOfBounds = 2,
|
|
56
|
+
InBounds = 4,
|
|
57
|
+
InViewport = 8,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const CoreNodeRenderStateMap: Map<CoreNodeRenderState, string> = new Map();
|
|
61
|
+
CoreNodeRenderStateMap.set(CoreNodeRenderState.Init, 'init');
|
|
62
|
+
CoreNodeRenderStateMap.set(CoreNodeRenderState.OutOfBounds, 'outOfBounds');
|
|
63
|
+
CoreNodeRenderStateMap.set(CoreNodeRenderState.InBounds, 'inBounds');
|
|
64
|
+
CoreNodeRenderStateMap.set(CoreNodeRenderState.InViewport, 'inViewport');
|
|
65
|
+
|
|
66
|
+
export interface CoreNodeProps {
|
|
67
|
+
id: number;
|
|
68
|
+
// External facing properties whose defaults are determined by
|
|
69
|
+
// RendererMain's resolveNodeDefaults() method
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
width: number;
|
|
73
|
+
height: number;
|
|
74
|
+
alpha: number;
|
|
75
|
+
clipping: boolean;
|
|
76
|
+
color: number;
|
|
77
|
+
colorTop: number;
|
|
78
|
+
colorBottom: number;
|
|
79
|
+
colorLeft: number;
|
|
80
|
+
colorRight: number;
|
|
81
|
+
colorTl: number;
|
|
82
|
+
colorTr: number;
|
|
83
|
+
colorBl: number;
|
|
84
|
+
colorBr: number;
|
|
85
|
+
parent: CoreNode | null;
|
|
86
|
+
zIndex: number;
|
|
87
|
+
texture: Texture | null;
|
|
88
|
+
textureOptions: TextureOptions | null;
|
|
89
|
+
shader: CoreShader | null;
|
|
90
|
+
shaderProps: Record<string, unknown> | null;
|
|
91
|
+
zIndexLocked: number;
|
|
92
|
+
scaleX: number;
|
|
93
|
+
scaleY: number;
|
|
94
|
+
mount: number;
|
|
95
|
+
mountX: number;
|
|
96
|
+
mountY: number;
|
|
97
|
+
pivot: number;
|
|
98
|
+
pivotX: number;
|
|
99
|
+
pivotY: number;
|
|
100
|
+
rotation: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
type ICoreNode = Omit<
|
|
104
|
+
CoreNodeProps,
|
|
105
|
+
'texture' | 'textureOptions' | 'shader' | 'shaderProps'
|
|
106
|
+
>;
|
|
107
|
+
|
|
108
|
+
export enum UpdateType {
|
|
109
|
+
/**
|
|
110
|
+
* Child updates
|
|
111
|
+
*/
|
|
112
|
+
Children = 1,
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Scale/Rotate transform update
|
|
116
|
+
*
|
|
117
|
+
* @remarks
|
|
118
|
+
* CoreNode Properties Updated:
|
|
119
|
+
* - `scaleRotateTransform`
|
|
120
|
+
*/
|
|
121
|
+
ScaleRotate = 2,
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Translate transform update (x/y/width/height/pivot/mount)
|
|
125
|
+
*
|
|
126
|
+
* @remarks
|
|
127
|
+
* CoreNode Properties Updated:
|
|
128
|
+
* - `localTransform`
|
|
129
|
+
*/
|
|
130
|
+
Local = 4,
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Global Transform update
|
|
134
|
+
*
|
|
135
|
+
* @remarks
|
|
136
|
+
* CoreNode Properties Updated:
|
|
137
|
+
* - `globalTransform`
|
|
138
|
+
* - `renderCoords`
|
|
139
|
+
* - `renderBound`
|
|
140
|
+
*/
|
|
141
|
+
Global = 8,
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Clipping rect update
|
|
145
|
+
*
|
|
146
|
+
* @remarks
|
|
147
|
+
* CoreNode Properties Updated:
|
|
148
|
+
* - `clippingRect`
|
|
149
|
+
*/
|
|
150
|
+
Clipping = 16,
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Calculated ZIndex update
|
|
154
|
+
*
|
|
155
|
+
* @remarks
|
|
156
|
+
* CoreNode Properties Updated:
|
|
157
|
+
* - `calcZIndex`
|
|
158
|
+
*/
|
|
159
|
+
CalculatedZIndex = 32,
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Z-Index Sorted Children update
|
|
163
|
+
*
|
|
164
|
+
* @remarks
|
|
165
|
+
* CoreNode Properties Updated:
|
|
166
|
+
* - `children` (sorts children by their `calcZIndex`)
|
|
167
|
+
*/
|
|
168
|
+
ZIndexSortedChildren = 64,
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Premultiplied Colors update
|
|
172
|
+
*
|
|
173
|
+
* @remarks
|
|
174
|
+
* CoreNode Properties Updated:
|
|
175
|
+
* - `premultipliedColorTl`
|
|
176
|
+
* - `premultipliedColorTr`
|
|
177
|
+
* - `premultipliedColorBl`
|
|
178
|
+
* - `premultipliedColorBr`
|
|
179
|
+
*/
|
|
180
|
+
PremultipliedColors = 128,
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* World Alpha update
|
|
184
|
+
*
|
|
185
|
+
* @remarks
|
|
186
|
+
* CoreNode Properties Updated:
|
|
187
|
+
* - `worldAlpha` = `parent.worldAlpha` * `alpha`
|
|
188
|
+
*/
|
|
189
|
+
WorldAlpha = 256,
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Render State update
|
|
193
|
+
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* CoreNode Properties Updated:
|
|
196
|
+
* - `renderState`
|
|
197
|
+
*/
|
|
198
|
+
RenderState = 512,
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Is Renderable update
|
|
202
|
+
*
|
|
203
|
+
* @remarks
|
|
204
|
+
* CoreNode Properties Updated:
|
|
205
|
+
* - `isRenderable`
|
|
206
|
+
*/
|
|
207
|
+
IsRenderable = 1024,
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* None
|
|
211
|
+
*/
|
|
212
|
+
None = 0,
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* All
|
|
216
|
+
*/
|
|
217
|
+
All = 2047,
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export class CoreNode extends EventEmitter implements ICoreNode {
|
|
221
|
+
readonly children: CoreNode[] = [];
|
|
222
|
+
protected props: Required<CoreNodeProps>;
|
|
223
|
+
|
|
224
|
+
public updateType = UpdateType.All;
|
|
225
|
+
|
|
226
|
+
public globalTransform?: Matrix3d;
|
|
227
|
+
public scaleRotateTransform?: Matrix3d;
|
|
228
|
+
public localTransform?: Matrix3d;
|
|
229
|
+
public renderCoords?: RenderCoords;
|
|
230
|
+
public renderBound?: Bound;
|
|
231
|
+
public strictBound?: Bound;
|
|
232
|
+
public preloadBound?: Bound;
|
|
233
|
+
public clippingRect: RectWithValid = {
|
|
234
|
+
x: 0,
|
|
235
|
+
y: 0,
|
|
236
|
+
width: 0,
|
|
237
|
+
height: 0,
|
|
238
|
+
valid: false,
|
|
239
|
+
};
|
|
240
|
+
public isRenderable = false;
|
|
241
|
+
public renderState: CoreNodeRenderState = CoreNodeRenderState.Init;
|
|
242
|
+
|
|
243
|
+
public worldAlpha = 1;
|
|
244
|
+
public premultipliedColorTl = 0;
|
|
245
|
+
public premultipliedColorTr = 0;
|
|
246
|
+
public premultipliedColorBl = 0;
|
|
247
|
+
public premultipliedColorBr = 0;
|
|
248
|
+
public calcZIndex = 0;
|
|
249
|
+
|
|
250
|
+
constructor(protected stage: Stage, props: CoreNodeProps) {
|
|
251
|
+
super();
|
|
252
|
+
this.props = {
|
|
253
|
+
...props,
|
|
254
|
+
parent: null,
|
|
255
|
+
};
|
|
256
|
+
// Allow for parent to be processed appropriately
|
|
257
|
+
this.parent = props.parent;
|
|
258
|
+
this.updateScaleRotateTransform();
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
//#region Textures
|
|
262
|
+
loadTexture<Type extends keyof TextureMap>(
|
|
263
|
+
textureType: Type,
|
|
264
|
+
props: ExtractProps<TextureMap[Type]>,
|
|
265
|
+
options: TextureOptions | null = null,
|
|
266
|
+
): void {
|
|
267
|
+
// First unload any existing texture
|
|
268
|
+
if (this.props.texture) {
|
|
269
|
+
this.unloadTexture();
|
|
270
|
+
}
|
|
271
|
+
const { txManager } = this.stage;
|
|
272
|
+
const texture = txManager.loadTexture(textureType, props, options);
|
|
273
|
+
|
|
274
|
+
this.props.texture = texture;
|
|
275
|
+
this.props.textureOptions = options;
|
|
276
|
+
this.setUpdateType(UpdateType.IsRenderable);
|
|
277
|
+
|
|
278
|
+
// If texture is already loaded / failed, trigger loaded event manually
|
|
279
|
+
// so that users get a consistent event experience.
|
|
280
|
+
// We do this in a microtask to allow listeners to be attached in the same
|
|
281
|
+
// synchronous task after calling loadTexture()
|
|
282
|
+
queueMicrotask(() => {
|
|
283
|
+
if (texture.state === 'loaded') {
|
|
284
|
+
this.onTextureLoaded(texture, texture.dimensions!);
|
|
285
|
+
} else if (texture.state === 'failed') {
|
|
286
|
+
this.onTextureFailed(texture, texture.error!);
|
|
287
|
+
} else if (texture.state === 'freed') {
|
|
288
|
+
this.onTextureFreed(texture);
|
|
289
|
+
}
|
|
290
|
+
texture.on('loaded', this.onTextureLoaded);
|
|
291
|
+
texture.on('failed', this.onTextureFailed);
|
|
292
|
+
texture.on('freed', this.onTextureFreed);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
unloadTexture(): void {
|
|
297
|
+
if (this.props.texture) {
|
|
298
|
+
const { texture } = this.props;
|
|
299
|
+
texture.off('loaded', this.onTextureLoaded);
|
|
300
|
+
texture.off('failed', this.onTextureFailed);
|
|
301
|
+
texture.off('freed', this.onTextureFreed);
|
|
302
|
+
texture.setRenderableOwner(this, false);
|
|
303
|
+
}
|
|
304
|
+
this.props.texture = null;
|
|
305
|
+
this.props.textureOptions = null;
|
|
306
|
+
this.setUpdateType(UpdateType.IsRenderable);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
private onTextureLoaded: TextureLoadedEventHandler = (target, dimensions) => {
|
|
310
|
+
// Texture was loaded. In case the RAF loop has already stopped, we request
|
|
311
|
+
// a render to ensure the texture is rendered.
|
|
312
|
+
this.stage.requestRender();
|
|
313
|
+
this.emit('loaded', {
|
|
314
|
+
type: 'texture',
|
|
315
|
+
dimensions,
|
|
316
|
+
} satisfies NodeTextureLoadedPayload);
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
private onTextureFailed: TextureFailedEventHandler = (target, error) => {
|
|
320
|
+
this.emit('failed', {
|
|
321
|
+
type: 'texture',
|
|
322
|
+
error,
|
|
323
|
+
} satisfies NodeTextureFailedPayload);
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
private onTextureFreed: TextureFreedEventHandler = (target: Texture) => {
|
|
327
|
+
this.emit('freed', {
|
|
328
|
+
type: 'texture',
|
|
329
|
+
} satisfies NodeTextureFreedPayload);
|
|
330
|
+
};
|
|
331
|
+
//#endregion Textures
|
|
332
|
+
|
|
333
|
+
loadShader<Type extends keyof ShaderMap>(
|
|
334
|
+
shaderType: Type,
|
|
335
|
+
props: ExtractProps<ShaderMap[Type]>,
|
|
336
|
+
): void {
|
|
337
|
+
const shManager = this.stage.renderer.getShaderManager();
|
|
338
|
+
assertTruthy(shManager);
|
|
339
|
+
const { shader, props: p } = shManager.loadShader(shaderType, props);
|
|
340
|
+
this.props.shader = shader;
|
|
341
|
+
this.props.shaderProps = p;
|
|
342
|
+
this.setUpdateType(UpdateType.IsRenderable);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Change types types is used to determine the scope of the changes being applied
|
|
347
|
+
*
|
|
348
|
+
* @remarks
|
|
349
|
+
* See {@link UpdateType} for more information on each type
|
|
350
|
+
*
|
|
351
|
+
* @param type
|
|
352
|
+
*/
|
|
353
|
+
setUpdateType(type: UpdateType): void {
|
|
354
|
+
this.updateType |= type;
|
|
355
|
+
|
|
356
|
+
// If we're updating this node at all, we need to inform the parent
|
|
357
|
+
// (and all ancestors) that their children need updating as well
|
|
358
|
+
const parent = this.props.parent;
|
|
359
|
+
if (parent && !(parent.updateType & UpdateType.Children)) {
|
|
360
|
+
parent.setUpdateType(UpdateType.Children);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
sortChildren() {
|
|
365
|
+
this.children.sort((a, b) => a.calcZIndex - b.calcZIndex);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
updateScaleRotateTransform() {
|
|
369
|
+
this.scaleRotateTransform = Matrix3d.rotate(
|
|
370
|
+
this.props.rotation,
|
|
371
|
+
this.scaleRotateTransform,
|
|
372
|
+
).scale(this.props.scaleX, this.props.scaleY);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
updateLocalTransform() {
|
|
376
|
+
assertTruthy(this.scaleRotateTransform);
|
|
377
|
+
const pivotTranslateX = this.props.pivotX * this.props.width;
|
|
378
|
+
const pivotTranslateY = this.props.pivotY * this.props.height;
|
|
379
|
+
const mountTranslateX = this.props.mountX * this.props.width;
|
|
380
|
+
const mountTranslateY = this.props.mountY * this.props.height;
|
|
381
|
+
|
|
382
|
+
this.localTransform = Matrix3d.translate(
|
|
383
|
+
pivotTranslateX - mountTranslateX + this.props.x,
|
|
384
|
+
pivotTranslateY - mountTranslateY + this.props.y,
|
|
385
|
+
this.localTransform,
|
|
386
|
+
)
|
|
387
|
+
.multiply(this.scaleRotateTransform)
|
|
388
|
+
.translate(-pivotTranslateX, -pivotTranslateY);
|
|
389
|
+
|
|
390
|
+
this.setUpdateType(UpdateType.Global);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* @todo: test for correct calculation flag
|
|
395
|
+
* @param delta
|
|
396
|
+
*/
|
|
397
|
+
update(delta: number, parentClippingRect: RectWithValid): void {
|
|
398
|
+
if (this.updateType & UpdateType.ScaleRotate) {
|
|
399
|
+
this.updateScaleRotateTransform();
|
|
400
|
+
this.setUpdateType(UpdateType.Local);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (this.updateType & UpdateType.Local) {
|
|
404
|
+
this.updateLocalTransform();
|
|
405
|
+
this.setUpdateType(UpdateType.Global);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
const parent = this.props.parent;
|
|
409
|
+
let childUpdateType = UpdateType.None;
|
|
410
|
+
if (this.updateType & UpdateType.Global) {
|
|
411
|
+
assertTruthy(this.localTransform);
|
|
412
|
+
this.globalTransform = Matrix3d.copy(
|
|
413
|
+
parent?.globalTransform || this.localTransform,
|
|
414
|
+
this.globalTransform,
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
if (parent) {
|
|
418
|
+
this.globalTransform.multiply(this.localTransform);
|
|
419
|
+
}
|
|
420
|
+
this.calculateRenderCoords();
|
|
421
|
+
this.updateBoundingRect();
|
|
422
|
+
this.setUpdateType(
|
|
423
|
+
UpdateType.Clipping | UpdateType.RenderState | UpdateType.Children,
|
|
424
|
+
);
|
|
425
|
+
childUpdateType |= UpdateType.Global;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (this.updateType & UpdateType.Clipping) {
|
|
429
|
+
this.calculateClippingRect(parentClippingRect);
|
|
430
|
+
this.setUpdateType(UpdateType.Children);
|
|
431
|
+
childUpdateType |= UpdateType.Clipping;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
if (this.updateType & UpdateType.WorldAlpha) {
|
|
435
|
+
if (parent) {
|
|
436
|
+
this.worldAlpha = parent.worldAlpha * this.props.alpha;
|
|
437
|
+
} else {
|
|
438
|
+
this.worldAlpha = this.props.alpha;
|
|
439
|
+
}
|
|
440
|
+
this.setUpdateType(UpdateType.Children | UpdateType.PremultipliedColors);
|
|
441
|
+
childUpdateType |= UpdateType.WorldAlpha;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if (this.updateType & UpdateType.PremultipliedColors) {
|
|
445
|
+
this.premultipliedColorTl = mergeColorAlphaPremultiplied(
|
|
446
|
+
this.props.colorTl,
|
|
447
|
+
this.worldAlpha,
|
|
448
|
+
true,
|
|
449
|
+
);
|
|
450
|
+
|
|
451
|
+
// If all the colors are the same just sent them all to the same value
|
|
452
|
+
if (
|
|
453
|
+
this.props.colorTl === this.props.colorTr &&
|
|
454
|
+
this.props.colorBl === this.props.colorBr &&
|
|
455
|
+
this.props.colorTl === this.props.colorBl
|
|
456
|
+
) {
|
|
457
|
+
this.premultipliedColorTr =
|
|
458
|
+
this.premultipliedColorBl =
|
|
459
|
+
this.premultipliedColorBr =
|
|
460
|
+
this.premultipliedColorTl;
|
|
461
|
+
} else {
|
|
462
|
+
this.premultipliedColorTr = mergeColorAlphaPremultiplied(
|
|
463
|
+
this.props.colorTr,
|
|
464
|
+
this.worldAlpha,
|
|
465
|
+
true,
|
|
466
|
+
);
|
|
467
|
+
this.premultipliedColorBl = mergeColorAlphaPremultiplied(
|
|
468
|
+
this.props.colorBl,
|
|
469
|
+
this.worldAlpha,
|
|
470
|
+
true,
|
|
471
|
+
);
|
|
472
|
+
this.premultipliedColorBr = mergeColorAlphaPremultiplied(
|
|
473
|
+
this.props.colorBr,
|
|
474
|
+
this.worldAlpha,
|
|
475
|
+
true,
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (this.updateType & UpdateType.RenderState) {
|
|
481
|
+
this.updateRenderState();
|
|
482
|
+
this.setUpdateType(UpdateType.IsRenderable);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (this.updateType & UpdateType.IsRenderable) {
|
|
486
|
+
this.updateIsRenderable();
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// No need to update zIndex if there is no parent
|
|
490
|
+
if (parent && this.updateType & UpdateType.CalculatedZIndex) {
|
|
491
|
+
this.calculateZIndex();
|
|
492
|
+
// Tell parent to re-sort children
|
|
493
|
+
parent.setUpdateType(UpdateType.ZIndexSortedChildren);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (this.updateType & UpdateType.Children && this.children.length) {
|
|
497
|
+
this.children.forEach((child) => {
|
|
498
|
+
// Trigger the depenedent update types on the child
|
|
499
|
+
child.setUpdateType(childUpdateType);
|
|
500
|
+
// If child has no updates, skip
|
|
501
|
+
if (child.updateType === 0) {
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
child.update(delta, this.clippingRect);
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// Sorting children MUST happen after children have been updated so
|
|
509
|
+
// that they have the oppotunity to update their calculated zIndex.
|
|
510
|
+
if (this.updateType & UpdateType.ZIndexSortedChildren) {
|
|
511
|
+
// reorder z-index
|
|
512
|
+
this.sortChildren();
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// reset update type
|
|
516
|
+
this.updateType = 0;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
//check if CoreNode is renderable based on props
|
|
520
|
+
checkRenderProps(): boolean {
|
|
521
|
+
if (this.props.texture) {
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (!this.props.width || !this.props.height) {
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (this.props.shader) {
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (this.props.clipping) {
|
|
534
|
+
return true;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
if (this.props.color !== 0) {
|
|
538
|
+
return true;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// Consider removing these checks and just using the color property check above.
|
|
542
|
+
// Maybe add a forceRender prop for nodes that should always render.
|
|
543
|
+
if (this.props.colorTop !== 0) {
|
|
544
|
+
return true;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (this.props.colorBottom !== 0) {
|
|
548
|
+
return true;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (this.props.colorLeft !== 0) {
|
|
552
|
+
return true;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (this.props.colorRight !== 0) {
|
|
556
|
+
return true;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
if (this.props.colorTl !== 0) {
|
|
560
|
+
return true;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if (this.props.colorTr !== 0) {
|
|
564
|
+
return true;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (this.props.colorBl !== 0) {
|
|
568
|
+
return true;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
if (this.props.colorBr !== 0) {
|
|
572
|
+
return true;
|
|
573
|
+
}
|
|
574
|
+
return false;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
checkRenderBounds(): CoreNodeRenderState {
|
|
578
|
+
assertTruthy(this.clippingRect);
|
|
579
|
+
assertTruthy(this.renderBound);
|
|
580
|
+
const rectW = this.clippingRect.width || this.stage.root.width;
|
|
581
|
+
const rectH = this.clippingRect.height || this.stage.root.height;
|
|
582
|
+
this.strictBound = createBound(
|
|
583
|
+
this.clippingRect.x,
|
|
584
|
+
this.clippingRect.y,
|
|
585
|
+
rectW,
|
|
586
|
+
rectH,
|
|
587
|
+
this.strictBound,
|
|
588
|
+
);
|
|
589
|
+
|
|
590
|
+
const renderM = this.stage.boundsMargin;
|
|
591
|
+
this.preloadBound = createBound(
|
|
592
|
+
this.clippingRect.x - renderM[3],
|
|
593
|
+
this.clippingRect.y - renderM[0],
|
|
594
|
+
this.clippingRect.x + rectW + renderM[1],
|
|
595
|
+
this.clippingRect.y + rectH + renderM[2],
|
|
596
|
+
this.preloadBound,
|
|
597
|
+
);
|
|
598
|
+
|
|
599
|
+
if (boundInsideBound(this.renderBound, this.strictBound)) {
|
|
600
|
+
return CoreNodeRenderState.InViewport;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
if (boundInsideBound(this.renderBound, this.preloadBound)) {
|
|
604
|
+
return CoreNodeRenderState.InBounds;
|
|
605
|
+
}
|
|
606
|
+
return CoreNodeRenderState.OutOfBounds;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
updateRenderState() {
|
|
610
|
+
const renderState = this.checkRenderBounds();
|
|
611
|
+
if (renderState !== this.renderState) {
|
|
612
|
+
const previous = this.renderState;
|
|
613
|
+
this.renderState = renderState;
|
|
614
|
+
if (previous === CoreNodeRenderState.InViewport) {
|
|
615
|
+
this.emit('outOfViewport', {
|
|
616
|
+
previous,
|
|
617
|
+
current: renderState,
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
const event = CoreNodeRenderStateMap.get(renderState);
|
|
621
|
+
assertTruthy(event);
|
|
622
|
+
this.emit(event, {
|
|
623
|
+
previous,
|
|
624
|
+
current: renderState,
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
setRenderState(state: CoreNodeRenderState) {
|
|
630
|
+
if (state !== this.renderState) {
|
|
631
|
+
this.renderState = state;
|
|
632
|
+
this.emit(CoreNodeRenderState[state]);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* This function updates the `isRenderable` property based on certain conditions.
|
|
638
|
+
*
|
|
639
|
+
* @returns
|
|
640
|
+
*/
|
|
641
|
+
updateIsRenderable() {
|
|
642
|
+
let newIsRenderable;
|
|
643
|
+
if (!this.checkRenderProps()) {
|
|
644
|
+
newIsRenderable = false;
|
|
645
|
+
} else {
|
|
646
|
+
newIsRenderable = this.renderState > CoreNodeRenderState.OutOfBounds;
|
|
647
|
+
}
|
|
648
|
+
if (this.isRenderable !== newIsRenderable) {
|
|
649
|
+
this.isRenderable = newIsRenderable;
|
|
650
|
+
this.onChangeIsRenderable(newIsRenderable);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
onChangeIsRenderable(isRenderable: boolean) {
|
|
655
|
+
this.props.texture?.setRenderableOwner(this, isRenderable);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
calculateRenderCoords() {
|
|
659
|
+
const { width, height, globalTransform: transform } = this;
|
|
660
|
+
assertTruthy(transform);
|
|
661
|
+
const { tx, ty, ta, tb, tc, td } = transform;
|
|
662
|
+
if (tb === 0 && tc === 0) {
|
|
663
|
+
const minX = tx;
|
|
664
|
+
const maxX = tx + width * ta;
|
|
665
|
+
|
|
666
|
+
const minY = ty;
|
|
667
|
+
const maxY = ty + height * td;
|
|
668
|
+
this.renderCoords = RenderCoords.translate(
|
|
669
|
+
//top-left
|
|
670
|
+
minX,
|
|
671
|
+
minY,
|
|
672
|
+
//top-right
|
|
673
|
+
maxX,
|
|
674
|
+
minY,
|
|
675
|
+
//bottom-right
|
|
676
|
+
maxX,
|
|
677
|
+
maxY,
|
|
678
|
+
//bottom-left
|
|
679
|
+
minX,
|
|
680
|
+
maxY,
|
|
681
|
+
this.renderCoords,
|
|
682
|
+
);
|
|
683
|
+
} else {
|
|
684
|
+
this.renderCoords = RenderCoords.translate(
|
|
685
|
+
//top-left
|
|
686
|
+
tx,
|
|
687
|
+
ty,
|
|
688
|
+
//top-right
|
|
689
|
+
tx + width * ta,
|
|
690
|
+
ty + width * tc,
|
|
691
|
+
//bottom-right
|
|
692
|
+
tx + width * ta + height * tb,
|
|
693
|
+
ty + width * tc + height * td,
|
|
694
|
+
//bottom-left
|
|
695
|
+
tx + height * tb,
|
|
696
|
+
ty + height * td,
|
|
697
|
+
this.renderCoords,
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
updateBoundingRect() {
|
|
703
|
+
const { renderCoords, globalTransform: transform } = this;
|
|
704
|
+
assertTruthy(transform);
|
|
705
|
+
assertTruthy(renderCoords);
|
|
706
|
+
|
|
707
|
+
const { tb, tc } = transform;
|
|
708
|
+
const { x1, y1, x3, y3 } = renderCoords;
|
|
709
|
+
if (tb === 0 || tc === 0) {
|
|
710
|
+
this.renderBound = createBound(x1, y1, x3, y3, this.renderBound);
|
|
711
|
+
} else {
|
|
712
|
+
const { x2, x4, y2, y4 } = renderCoords;
|
|
713
|
+
this.renderBound = createBound(
|
|
714
|
+
Math.min(x1, x2, x3, x4),
|
|
715
|
+
Math.min(y1, y2, y3, y4),
|
|
716
|
+
Math.max(x1, x2, x3, x4),
|
|
717
|
+
Math.max(y1, y2, y3, y4),
|
|
718
|
+
this.renderBound,
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* This function calculates the clipping rectangle for a node.
|
|
725
|
+
*
|
|
726
|
+
* The function then checks if the node is rotated. If the node requires clipping and is not rotated, a new clipping rectangle is created based on the node's global transform and dimensions.
|
|
727
|
+
* If a parent clipping rectangle exists, it is intersected with the node's clipping rectangle (if it exists), or replaces the node's clipping rectangle.
|
|
728
|
+
*
|
|
729
|
+
* Finally, the node's parentClippingRect and clippingRect properties are updated.
|
|
730
|
+
*/
|
|
731
|
+
calculateClippingRect(parentClippingRect: RectWithValid) {
|
|
732
|
+
assertTruthy(this.globalTransform);
|
|
733
|
+
const { clippingRect, props, globalTransform: gt } = this;
|
|
734
|
+
const { clipping } = props;
|
|
735
|
+
|
|
736
|
+
const isRotated = gt.tb !== 0 || gt.tc !== 0;
|
|
737
|
+
|
|
738
|
+
if (clipping && !isRotated) {
|
|
739
|
+
clippingRect.x = gt.tx;
|
|
740
|
+
clippingRect.y = gt.ty;
|
|
741
|
+
clippingRect.width = this.width * gt.ta;
|
|
742
|
+
clippingRect.height = this.height * gt.td;
|
|
743
|
+
clippingRect.valid = true;
|
|
744
|
+
} else {
|
|
745
|
+
clippingRect.valid = false;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if (parentClippingRect.valid && clippingRect.valid) {
|
|
749
|
+
// Intersect parent clipping rect with node clipping rect
|
|
750
|
+
intersectRect(parentClippingRect, clippingRect, clippingRect);
|
|
751
|
+
} else if (parentClippingRect.valid) {
|
|
752
|
+
// Copy parent clipping rect
|
|
753
|
+
copyRect(parentClippingRect, clippingRect);
|
|
754
|
+
clippingRect.valid = true;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
calculateZIndex(): void {
|
|
759
|
+
const props = this.props;
|
|
760
|
+
const z = props.zIndex || 0;
|
|
761
|
+
const p = props.parent?.zIndex || 0;
|
|
762
|
+
|
|
763
|
+
let zIndex = z;
|
|
764
|
+
if (props.parent?.zIndexLocked) {
|
|
765
|
+
zIndex = z < p ? z : p;
|
|
766
|
+
}
|
|
767
|
+
this.calcZIndex = zIndex;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Destroy the node and cleanup all resources
|
|
772
|
+
*/
|
|
773
|
+
destroy(): void {
|
|
774
|
+
this.unloadTexture();
|
|
775
|
+
|
|
776
|
+
this.clippingRect.valid = false;
|
|
777
|
+
|
|
778
|
+
this.isRenderable = false;
|
|
779
|
+
|
|
780
|
+
delete this.renderCoords;
|
|
781
|
+
delete this.renderBound;
|
|
782
|
+
delete this.strictBound;
|
|
783
|
+
delete this.preloadBound;
|
|
784
|
+
delete this.globalTransform;
|
|
785
|
+
delete this.scaleRotateTransform;
|
|
786
|
+
delete this.localTransform;
|
|
787
|
+
|
|
788
|
+
this.props.texture = null;
|
|
789
|
+
this.props.shader = null;
|
|
790
|
+
|
|
791
|
+
this.removeAllListeners();
|
|
792
|
+
this.parent = null;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
renderQuads(renderer: CoreRenderer): void {
|
|
796
|
+
const { width, height, texture, textureOptions, shader, shaderProps } =
|
|
797
|
+
this.props;
|
|
798
|
+
const {
|
|
799
|
+
premultipliedColorTl,
|
|
800
|
+
premultipliedColorTr,
|
|
801
|
+
premultipliedColorBl,
|
|
802
|
+
premultipliedColorBr,
|
|
803
|
+
} = this;
|
|
804
|
+
|
|
805
|
+
const { zIndex, worldAlpha, globalTransform: gt, clippingRect } = this;
|
|
806
|
+
|
|
807
|
+
assertTruthy(gt);
|
|
808
|
+
|
|
809
|
+
// add to list of renderables to be sorted before rendering
|
|
810
|
+
renderer.addQuad({
|
|
811
|
+
width,
|
|
812
|
+
height,
|
|
813
|
+
colorTl: premultipliedColorTl,
|
|
814
|
+
colorTr: premultipliedColorTr,
|
|
815
|
+
colorBl: premultipliedColorBl,
|
|
816
|
+
colorBr: premultipliedColorBr,
|
|
817
|
+
texture,
|
|
818
|
+
textureOptions,
|
|
819
|
+
zIndex,
|
|
820
|
+
shader,
|
|
821
|
+
shaderProps,
|
|
822
|
+
alpha: worldAlpha,
|
|
823
|
+
clippingRect,
|
|
824
|
+
tx: gt.tx,
|
|
825
|
+
ty: gt.ty,
|
|
826
|
+
ta: gt.ta,
|
|
827
|
+
tb: gt.tb,
|
|
828
|
+
tc: gt.tc,
|
|
829
|
+
td: gt.td,
|
|
830
|
+
});
|
|
831
|
+
|
|
832
|
+
// Calculate absolute X and Y based on all ancestors
|
|
833
|
+
// renderer.addQuad(absX, absY, w, h, color, texture, textureOptions, zIndex);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
//#region Properties
|
|
837
|
+
get id(): number {
|
|
838
|
+
return this.props.id;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
get x(): number {
|
|
842
|
+
return this.props.x;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
set x(value: number) {
|
|
846
|
+
if (this.props.x !== value) {
|
|
847
|
+
this.props.x = value;
|
|
848
|
+
this.setUpdateType(UpdateType.Local);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
get absX(): number {
|
|
853
|
+
return (
|
|
854
|
+
this.props.x +
|
|
855
|
+
(this.props.parent?.absX || this.props.parent?.globalTransform?.tx || 0)
|
|
856
|
+
);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
get absY(): number {
|
|
860
|
+
return this.props.y + (this.props.parent?.absY ?? 0);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
get y(): number {
|
|
864
|
+
return this.props.y;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
set y(value: number) {
|
|
868
|
+
if (this.props.y !== value) {
|
|
869
|
+
this.props.y = value;
|
|
870
|
+
this.setUpdateType(UpdateType.Local);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
get width(): number {
|
|
875
|
+
return this.props.width;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
set width(value: number) {
|
|
879
|
+
if (this.props.width !== value) {
|
|
880
|
+
this.props.width = value;
|
|
881
|
+
this.setUpdateType(UpdateType.Local);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
get height(): number {
|
|
886
|
+
return this.props.height;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
set height(value: number) {
|
|
890
|
+
if (this.props.height !== value) {
|
|
891
|
+
this.props.height = value;
|
|
892
|
+
this.setUpdateType(UpdateType.Local);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
get scale(): number {
|
|
897
|
+
// The CoreNode `scale` property is only used by Animations.
|
|
898
|
+
// Unlike INode, `null` should never be possibility for Animations.
|
|
899
|
+
return this.scaleX;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
set scale(value: number) {
|
|
903
|
+
// The CoreNode `scale` property is only used by Animations.
|
|
904
|
+
// Unlike INode, `null` should never be possibility for Animations.
|
|
905
|
+
this.scaleX = value;
|
|
906
|
+
this.scaleY = value;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
get scaleX(): number {
|
|
910
|
+
return this.props.scaleX;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
set scaleX(value: number) {
|
|
914
|
+
if (this.props.scaleX !== value) {
|
|
915
|
+
this.props.scaleX = value;
|
|
916
|
+
this.setUpdateType(UpdateType.ScaleRotate);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
get scaleY(): number {
|
|
921
|
+
return this.props.scaleY;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
set scaleY(value: number) {
|
|
925
|
+
if (this.props.scaleY !== value) {
|
|
926
|
+
this.props.scaleY = value;
|
|
927
|
+
this.setUpdateType(UpdateType.ScaleRotate);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
get mount(): number {
|
|
932
|
+
return this.props.mount;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
set mount(value: number) {
|
|
936
|
+
if (this.props.mountX !== value || this.props.mountY !== value) {
|
|
937
|
+
this.props.mountX = value;
|
|
938
|
+
this.props.mountY = value;
|
|
939
|
+
this.props.mount = value;
|
|
940
|
+
this.setUpdateType(UpdateType.Local);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
get mountX(): number {
|
|
945
|
+
return this.props.mountX;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
set mountX(value: number) {
|
|
949
|
+
if (this.props.mountX !== value) {
|
|
950
|
+
this.props.mountX = value;
|
|
951
|
+
this.setUpdateType(UpdateType.Local);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
get mountY(): number {
|
|
956
|
+
return this.props.mountY;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
set mountY(value: number) {
|
|
960
|
+
if (this.props.mountY !== value) {
|
|
961
|
+
this.props.mountY = value;
|
|
962
|
+
this.setUpdateType(UpdateType.Local);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
get pivot(): number {
|
|
967
|
+
return this.props.pivot;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
set pivot(value: number) {
|
|
971
|
+
if (this.props.pivotX !== value || this.props.pivotY !== value) {
|
|
972
|
+
this.props.pivotX = value;
|
|
973
|
+
this.props.pivotY = value;
|
|
974
|
+
this.props.pivot = value;
|
|
975
|
+
this.setUpdateType(UpdateType.Local);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
get pivotX(): number {
|
|
980
|
+
return this.props.pivotX;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
set pivotX(value: number) {
|
|
984
|
+
if (this.props.pivotX !== value) {
|
|
985
|
+
this.props.pivotX = value;
|
|
986
|
+
this.setUpdateType(UpdateType.Local);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
get pivotY(): number {
|
|
991
|
+
return this.props.pivotY;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
set pivotY(value: number) {
|
|
995
|
+
if (this.props.pivotY !== value) {
|
|
996
|
+
this.props.pivotY = value;
|
|
997
|
+
this.setUpdateType(UpdateType.Local);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
get rotation(): number {
|
|
1002
|
+
return this.props.rotation;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
set rotation(value: number) {
|
|
1006
|
+
if (this.props.rotation !== value) {
|
|
1007
|
+
this.props.rotation = value;
|
|
1008
|
+
this.setUpdateType(UpdateType.ScaleRotate);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
get alpha(): number {
|
|
1013
|
+
return this.props.alpha;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
set alpha(value: number) {
|
|
1017
|
+
this.props.alpha = value;
|
|
1018
|
+
this.setUpdateType(UpdateType.PremultipliedColors | UpdateType.WorldAlpha);
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
get clipping(): boolean {
|
|
1022
|
+
return this.props.clipping;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
set clipping(value: boolean) {
|
|
1026
|
+
this.props.clipping = value;
|
|
1027
|
+
this.setUpdateType(UpdateType.Clipping);
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
get color(): number {
|
|
1031
|
+
return this.props.color;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
set color(value: number) {
|
|
1035
|
+
if (
|
|
1036
|
+
this.props.colorTl !== value ||
|
|
1037
|
+
this.props.colorTr !== value ||
|
|
1038
|
+
this.props.colorBl !== value ||
|
|
1039
|
+
this.props.colorBr !== value
|
|
1040
|
+
) {
|
|
1041
|
+
this.colorTl = value;
|
|
1042
|
+
this.colorTr = value;
|
|
1043
|
+
this.colorBl = value;
|
|
1044
|
+
this.colorBr = value;
|
|
1045
|
+
}
|
|
1046
|
+
this.props.color = value;
|
|
1047
|
+
|
|
1048
|
+
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
get colorTop(): number {
|
|
1052
|
+
return this.props.colorTop;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
set colorTop(value: number) {
|
|
1056
|
+
if (this.props.colorTl !== value || this.props.colorTr !== value) {
|
|
1057
|
+
this.colorTl = value;
|
|
1058
|
+
this.colorTr = value;
|
|
1059
|
+
}
|
|
1060
|
+
this.props.colorTop = value;
|
|
1061
|
+
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
get colorBottom(): number {
|
|
1065
|
+
return this.props.colorBottom;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
set colorBottom(value: number) {
|
|
1069
|
+
if (this.props.colorBl !== value || this.props.colorBr !== value) {
|
|
1070
|
+
this.colorBl = value;
|
|
1071
|
+
this.colorBr = value;
|
|
1072
|
+
}
|
|
1073
|
+
this.props.colorBottom = value;
|
|
1074
|
+
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
get colorLeft(): number {
|
|
1078
|
+
return this.props.colorLeft;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
set colorLeft(value: number) {
|
|
1082
|
+
if (this.props.colorTl !== value || this.props.colorBl !== value) {
|
|
1083
|
+
this.colorTl = value;
|
|
1084
|
+
this.colorBl = value;
|
|
1085
|
+
}
|
|
1086
|
+
this.props.colorLeft = value;
|
|
1087
|
+
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
get colorRight(): number {
|
|
1091
|
+
return this.props.colorRight;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
set colorRight(value: number) {
|
|
1095
|
+
if (this.props.colorTr !== value || this.props.colorBr !== value) {
|
|
1096
|
+
this.colorTr = value;
|
|
1097
|
+
this.colorBr = value;
|
|
1098
|
+
}
|
|
1099
|
+
this.props.colorRight = value;
|
|
1100
|
+
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
get colorTl(): number {
|
|
1104
|
+
return this.props.colorTl;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
set colorTl(value: number) {
|
|
1108
|
+
this.props.colorTl = value;
|
|
1109
|
+
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
get colorTr(): number {
|
|
1113
|
+
return this.props.colorTr;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
set colorTr(value: number) {
|
|
1117
|
+
this.props.colorTr = value;
|
|
1118
|
+
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
get colorBl(): number {
|
|
1122
|
+
return this.props.colorBl;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
set colorBl(value: number) {
|
|
1126
|
+
this.props.colorBl = value;
|
|
1127
|
+
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
get colorBr(): number {
|
|
1131
|
+
return this.props.colorBr;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
set colorBr(value: number) {
|
|
1135
|
+
this.props.colorBr = value;
|
|
1136
|
+
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
// we're only interested in parent zIndex to test
|
|
1140
|
+
// if we should use node zIndex is higher then parent zIndex
|
|
1141
|
+
get zIndexLocked(): number {
|
|
1142
|
+
return this.props.zIndexLocked || 0;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
set zIndexLocked(value: number) {
|
|
1146
|
+
this.props.zIndexLocked = value;
|
|
1147
|
+
this.setUpdateType(UpdateType.CalculatedZIndex | UpdateType.Children);
|
|
1148
|
+
this.children.forEach((child) => {
|
|
1149
|
+
child.setUpdateType(UpdateType.CalculatedZIndex);
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
get zIndex(): number {
|
|
1154
|
+
return this.props.zIndex;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
set zIndex(value: number) {
|
|
1158
|
+
this.props.zIndex = value;
|
|
1159
|
+
this.setUpdateType(UpdateType.CalculatedZIndex | UpdateType.Children);
|
|
1160
|
+
this.children.forEach((child) => {
|
|
1161
|
+
child.setUpdateType(UpdateType.CalculatedZIndex);
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
get parent(): CoreNode | null {
|
|
1166
|
+
return this.props.parent;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
set parent(newParent: CoreNode | null) {
|
|
1170
|
+
const oldParent = this.props.parent;
|
|
1171
|
+
if (oldParent === newParent) {
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
this.props.parent = newParent;
|
|
1175
|
+
if (oldParent) {
|
|
1176
|
+
const index = oldParent.children.indexOf(this);
|
|
1177
|
+
assertTruthy(
|
|
1178
|
+
index !== -1,
|
|
1179
|
+
"CoreNode.parent: Node not found in old parent's children!",
|
|
1180
|
+
);
|
|
1181
|
+
oldParent.children.splice(index, 1);
|
|
1182
|
+
oldParent.setUpdateType(
|
|
1183
|
+
UpdateType.Children | UpdateType.ZIndexSortedChildren,
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
if (newParent) {
|
|
1187
|
+
newParent.children.push(this);
|
|
1188
|
+
// Since this node has a new parent, to be safe, have it do a full update.
|
|
1189
|
+
this.setUpdateType(UpdateType.All);
|
|
1190
|
+
// Tell parent that it's children need to be updated and sorted.
|
|
1191
|
+
newParent.setUpdateType(
|
|
1192
|
+
UpdateType.Children | UpdateType.ZIndexSortedChildren,
|
|
1193
|
+
);
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
this.updateScaleRotateTransform();
|
|
1197
|
+
}
|
|
1198
|
+
//#endregion Properties
|
|
1199
|
+
}
|