@lightningjs/renderer 3.0.0-beta2 → 3.0.0-beta20
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/README.md +16 -26
- package/dist/exports/canvas.d.ts +1 -1
- package/dist/exports/canvas.js +1 -1
- package/dist/exports/canvas.js.map +1 -1
- package/dist/exports/index.d.ts +2 -5
- package/dist/exports/index.js +1 -5
- package/dist/exports/index.js.map +1 -1
- 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/exports/webgl.d.ts +2 -1
- package/dist/exports/webgl.js +2 -1
- package/dist/exports/webgl.js.map +1 -1
- package/dist/src/common/CommonTypes.d.ts +13 -2
- package/dist/src/core/Autosizer.d.ts +35 -0
- package/dist/src/core/Autosizer.js +196 -0
- package/dist/src/core/Autosizer.js.map +1 -0
- package/dist/src/core/CoreNode.d.ts +73 -95
- package/dist/src/core/CoreNode.js +599 -461
- package/dist/src/core/CoreNode.js.map +1 -1
- package/dist/src/core/CoreShaderManager.d.ts +3 -5
- package/dist/src/core/CoreShaderManager.js.map +1 -1
- package/dist/src/core/CoreTextNode.d.ts +74 -87
- package/dist/src/core/CoreTextNode.js +357 -232
- package/dist/src/core/CoreTextNode.js.map +1 -1
- package/dist/src/core/CoreTextureManager.d.ts +25 -13
- package/dist/src/core/CoreTextureManager.js +80 -104
- package/dist/src/core/CoreTextureManager.js.map +1 -1
- package/dist/src/core/Stage.d.ts +92 -33
- package/dist/src/core/Stage.js +313 -151
- package/dist/src/core/Stage.js.map +1 -1
- package/dist/src/core/TextureError.d.ts +11 -0
- package/dist/src/core/TextureError.js +37 -0
- package/dist/src/core/TextureError.js.map +1 -0
- package/dist/src/core/TextureMemoryManager.d.ts +11 -4
- package/dist/src/core/TextureMemoryManager.js +128 -109
- package/dist/src/core/TextureMemoryManager.js.map +1 -1
- package/dist/src/core/animations/CoreAnimation.d.ts +3 -3
- package/dist/src/core/animations/CoreAnimation.js +8 -3
- 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/ImageWorker.js +1 -1
- package/dist/src/core/lib/ImageWorker.js.map +1 -1
- package/dist/src/core/lib/WebGlContextWrapper.d.ts +41 -3
- package/dist/src/core/lib/WebGlContextWrapper.js +104 -27
- package/dist/src/core/lib/WebGlContextWrapper.js.map +1 -1
- package/dist/src/core/lib/collectionUtils.d.ts +5 -0
- package/dist/src/core/lib/collectionUtils.js +100 -0
- package/dist/src/core/lib/collectionUtils.js.map +1 -0
- package/dist/src/core/lib/colorCache.d.ts +1 -0
- package/dist/src/core/lib/colorCache.js +19 -0
- package/dist/src/core/lib/colorCache.js.map +1 -0
- package/dist/src/core/lib/colorParser.d.ts +21 -0
- package/dist/src/core/lib/colorParser.js +72 -0
- package/dist/src/core/lib/colorParser.js.map +1 -0
- package/dist/src/core/lib/textureCompression.d.ts +14 -2
- package/dist/src/core/lib/textureCompression.js +320 -67
- package/dist/src/core/lib/textureCompression.js.map +1 -1
- package/dist/src/core/lib/utils.d.ts +2 -0
- package/dist/src/core/lib/utils.js +22 -0
- package/dist/src/core/lib/utils.js.map +1 -1
- package/dist/src/core/lib/validateImageBitmap.d.ts +2 -1
- package/dist/src/core/lib/validateImageBitmap.js +4 -4
- package/dist/src/core/lib/validateImageBitmap.js.map +1 -1
- package/dist/src/core/platform.js +30 -5
- package/dist/src/core/platform.js.map +1 -1
- package/dist/src/core/platforms/Platform.d.ts +42 -0
- package/dist/src/{main-api/IRenderDriver.js → core/platforms/Platform.js} +4 -2
- package/dist/src/core/platforms/Platform.js.map +1 -0
- package/dist/src/core/platforms/web/WebPlatform.d.ts +10 -0
- package/dist/src/core/platforms/web/WebPlatform.js +87 -0
- package/dist/src/core/platforms/web/WebPlatform.js.map +1 -0
- package/dist/src/core/renderers/CoreContextTexture.d.ts +2 -1
- package/dist/src/core/renderers/CoreContextTexture.js.map +1 -1
- package/dist/src/core/renderers/CoreRenderer.d.ts +7 -2
- package/dist/src/core/renderers/CoreRenderer.js +1 -0
- package/dist/src/core/renderers/CoreRenderer.js.map +1 -1
- package/dist/src/core/renderers/CoreShaderNode.d.ts +8 -1
- package/dist/src/core/renderers/CoreShaderNode.js +11 -0
- package/dist/src/core/renderers/CoreShaderNode.js.map +1 -1
- package/dist/src/core/renderers/canvas/CanvasCoreTexture.d.ts +2 -1
- package/dist/src/core/renderers/canvas/CanvasCoreTexture.js +11 -9
- package/dist/src/core/renderers/canvas/CanvasCoreTexture.js.map +1 -1
- package/dist/src/core/renderers/canvas/CanvasRenderer.d.ts +1 -2
- package/dist/src/core/renderers/canvas/CanvasRenderer.js +32 -59
- package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +1 -1
- package/dist/src/core/renderers/canvas/CanvasShaderNode.js +3 -5
- package/dist/src/core/renderers/canvas/CanvasShaderNode.js.map +1 -1
- package/dist/src/core/renderers/canvas/CanvasTexture.d.ts +3 -2
- package/dist/src/core/renderers/canvas/CanvasTexture.js +17 -13
- package/dist/src/core/renderers/canvas/CanvasTexture.js.map +1 -1
- package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.d.ts +13 -0
- package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.js +113 -192
- package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.js.map +1 -1
- package/dist/src/core/renderers/canvas/internal/ColorUtils.d.ts +0 -2
- package/dist/src/core/renderers/canvas/internal/ColorUtils.js +0 -14
- package/dist/src/core/renderers/canvas/internal/ColorUtils.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.js +3 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.d.ts +18 -6
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js +86 -41
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +53 -17
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreShader.d.ts +2 -7
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js +21 -50
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.d.ts +2 -0
- package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js +14 -6
- package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.d.ts +13 -0
- package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js +34 -5
- package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCtxTexture.d.ts +16 -6
- package/dist/src/core/renderers/webgl/WebGlCtxTexture.js +95 -49
- package/dist/src/core/renderers/webgl/WebGlCtxTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlRenderOp.d.ts +3 -2
- package/dist/src/core/renderers/webgl/WebGlRenderOp.js +14 -5
- package/dist/src/core/renderers/webgl/WebGlRenderOp.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlRenderer.d.ts +5 -3
- package/dist/src/core/renderers/webgl/WebGlRenderer.js +141 -112
- 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 +6 -3
- package/dist/src/core/renderers/webgl/WebGlShaderProgram.js +47 -18
- package/dist/src/core/renderers/webgl/WebGlShaderProgram.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.js +3 -6
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js +0 -11
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js +5 -10
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js +5 -10
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/SdfShader.js +0 -12
- package/dist/src/core/renderers/webgl/shaders/SdfShader.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.js +5 -5
- package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js +24 -19
- 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 +32 -5
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js +5 -5
- package/dist/src/core/shaders/canvas/Border.js +5 -5
- package/dist/src/core/shaders/canvas/Border.js.map +1 -1
- package/dist/src/core/shaders/canvas/HolePunch.js +3 -3
- package/dist/src/core/shaders/canvas/HolePunch.js.map +1 -1
- package/dist/src/core/shaders/canvas/LinearGradient.js +7 -5
- package/dist/src/core/shaders/canvas/LinearGradient.js.map +1 -1
- package/dist/src/core/shaders/canvas/RadialGradient.js +14 -12
- package/dist/src/core/shaders/canvas/RadialGradient.js.map +1 -1
- package/dist/src/core/shaders/canvas/Rounded.js +1 -1
- package/dist/src/core/shaders/canvas/Rounded.js.map +1 -1
- package/dist/src/core/shaders/canvas/RoundedWithBorder.js +14 -6
- 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 +2 -2
- package/dist/src/core/shaders/templates/BorderTemplate.js +11 -11
- package/dist/src/core/shaders/templates/BorderTemplate.js.map +1 -1
- package/dist/src/core/shaders/templates/HolePunchTemplate.d.ts +2 -2
- package/dist/src/core/shaders/templates/HolePunchTemplate.js +3 -3
- package/dist/src/core/shaders/templates/HolePunchTemplate.js.map +1 -1
- package/dist/src/core/shaders/templates/RadialGradientTemplate.d.ts +8 -6
- package/dist/src/core/shaders/templates/RadialGradientTemplate.js +2 -2
- package/dist/src/core/shaders/templates/RadialGradientTemplate.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/Border.js +57 -34
- package/dist/src/core/shaders/webgl/Border.js.map +1 -1
- package/dist/src/core/shaders/webgl/Default.js +6 -7
- package/dist/src/core/shaders/webgl/Default.js.map +1 -1
- 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 +33 -8
- package/dist/src/core/shaders/webgl/LinearGradient.js.map +1 -1
- package/dist/src/core/shaders/webgl/RadialGradient.js +56 -32
- package/dist/src/core/shaders/webgl/RadialGradient.js.map +1 -1
- package/dist/src/core/shaders/webgl/Rounded.js +4 -2
- package/dist/src/core/shaders/webgl/Rounded.js.map +1 -1
- package/dist/src/core/shaders/webgl/RoundedWithBorder.js +81 -37
- package/dist/src/core/shaders/webgl/RoundedWithBorder.js.map +1 -1
- package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +93 -42
- package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js.map +1 -1
- package/dist/src/core/shaders/webgl/RoundedWithShadow.js +3 -2
- package/dist/src/core/shaders/webgl/RoundedWithShadow.js.map +1 -1
- package/dist/src/core/shaders/webgl/SdfShader.d.ts +0 -2
- package/dist/src/core/shaders/webgl/SdfShader.js +7 -17
- package/dist/src/core/shaders/webgl/SdfShader.js.map +1 -1
- package/dist/src/core/text-rendering/CanvasFontHandler.d.ts +59 -0
- package/dist/src/core/text-rendering/CanvasFontHandler.js +224 -0
- package/dist/src/core/text-rendering/CanvasFontHandler.js.map +1 -0
- package/dist/src/core/text-rendering/CanvasTextRenderer.d.ts +17 -0
- package/dist/src/core/text-rendering/CanvasTextRenderer.js +157 -0
- package/dist/src/core/text-rendering/CanvasTextRenderer.js.map +1 -0
- package/dist/src/core/text-rendering/SdfFontHandler.d.ts +182 -0
- package/dist/src/core/text-rendering/SdfFontHandler.js +391 -0
- package/dist/src/core/text-rendering/SdfFontHandler.js.map +1 -0
- package/dist/src/core/text-rendering/SdfTextRenderer.d.ts +17 -0
- package/dist/src/core/text-rendering/SdfTextRenderer.js +311 -0
- package/dist/src/core/text-rendering/SdfTextRenderer.js.map +1 -0
- package/dist/src/core/text-rendering/TextLayoutEngine.d.ts +18 -0
- package/dist/src/core/text-rendering/TextLayoutEngine.js +380 -0
- package/dist/src/core/text-rendering/TextLayoutEngine.js.map +1 -0
- package/dist/src/core/text-rendering/TextRenderer.d.ts +383 -0
- package/dist/src/{main-api/ICoreDriver.js → core/text-rendering/TextRenderer.js} +1 -1
- package/dist/src/core/text-rendering/TextRenderer.js.map +1 -0
- package/dist/src/core/text-rendering/TextTextureRendererUtils.js.map +1 -1
- package/dist/src/core/text-rendering/Utils.d.ts +30 -0
- package/dist/src/core/text-rendering/Utils.js +84 -0
- package/dist/src/core/text-rendering/Utils.js.map +1 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js +2 -2
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js.map +1 -1
- package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.d.ts +0 -6
- package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.d.ts +3 -2
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js +35 -38
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/renderers/TextRenderer.d.ts +4 -1
- package/dist/src/core/text-rendering/renderers/TextRenderer.js.map +1 -1
- package/dist/src/core/textures/ColorTexture.d.ts +1 -1
- package/dist/src/core/textures/ColorTexture.js +3 -4
- package/dist/src/core/textures/ColorTexture.js.map +1 -1
- package/dist/src/core/textures/ImageTexture.d.ts +11 -4
- package/dist/src/core/textures/ImageTexture.js +31 -40
- package/dist/src/core/textures/ImageTexture.js.map +1 -1
- package/dist/src/core/textures/NoiseTexture.d.ts +3 -3
- package/dist/src/core/textures/NoiseTexture.js +8 -8
- package/dist/src/core/textures/NoiseTexture.js.map +1 -1
- package/dist/src/core/textures/RenderTexture.d.ts +7 -7
- package/dist/src/core/textures/RenderTexture.js +12 -12
- package/dist/src/core/textures/RenderTexture.js.map +1 -1
- package/dist/src/core/textures/SubTexture.d.ts +6 -8
- package/dist/src/core/textures/SubTexture.js +19 -37
- package/dist/src/core/textures/SubTexture.js.map +1 -1
- package/dist/src/core/textures/Texture.d.ts +87 -10
- package/dist/src/core/textures/Texture.js +160 -17
- package/dist/src/core/textures/Texture.js.map +1 -1
- package/dist/src/core/utils.d.ts +3 -2
- package/dist/src/core/utils.js +1 -1
- package/dist/src/core/utils.js.map +1 -1
- package/dist/src/main-api/INode.d.ts +2 -2
- package/dist/src/main-api/Inspector.d.ts +130 -1
- package/dist/src/main-api/Inspector.js +341 -27
- package/dist/src/main-api/Inspector.js.map +1 -1
- package/dist/src/main-api/Renderer.d.ts +285 -82
- package/dist/src/main-api/Renderer.js +221 -76
- package/dist/src/main-api/Renderer.js.map +1 -1
- package/dist/src/utils.d.ts +1 -6
- package/dist/src/utils.js +2 -9
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/exports/canvas.ts +1 -1
- package/exports/index.ts +2 -8
- package/exports/utils.ts +7 -1
- package/exports/webgl.ts +3 -1
- package/package.json +15 -17
- package/src/common/CommonTypes.ts +18 -2
- package/src/core/CoreNode.test.ts +63 -15
- package/src/core/CoreNode.ts +709 -582
- package/src/core/CoreShaderManager.ts +5 -10
- package/src/core/CoreTextNode.ts +424 -286
- package/src/core/CoreTextureManager.ts +110 -130
- package/src/core/Stage.ts +394 -195
- package/src/core/TextureError.ts +46 -0
- package/src/core/TextureMemoryManager.ts +164 -141
- package/src/core/animations/CoreAnimation.ts +15 -9
- package/src/core/animations/CoreAnimationController.ts +13 -4
- package/src/core/lib/ImageWorker.ts +7 -1
- package/src/core/lib/WebGlContextWrapper.ts +126 -78
- package/src/core/lib/collectionUtils.ts +118 -0
- package/src/core/lib/colorCache.ts +20 -0
- package/src/core/{renderers/canvas/internal/ColorUtils.ts → lib/colorParser.ts} +2 -2
- package/src/core/lib/textureCompression.ts +433 -75
- package/src/core/lib/utils.ts +26 -0
- package/src/core/lib/validateImageBitmap.ts +17 -6
- package/src/core/platforms/Platform.ts +83 -0
- package/src/core/platforms/web/WebPlatform.ts +132 -0
- package/src/core/renderers/CoreContextTexture.ts +2 -1
- package/src/core/renderers/CoreRenderer.ts +7 -3
- package/src/core/renderers/CoreShaderNode.ts +18 -3
- package/src/core/renderers/canvas/CanvasRenderer.ts +48 -82
- package/src/core/renderers/canvas/CanvasShaderNode.ts +3 -6
- package/src/core/renderers/canvas/CanvasTexture.ts +22 -18
- package/src/core/renderers/webgl/WebGlCtxRenderTexture.ts +18 -15
- package/src/core/renderers/webgl/WebGlCtxSubTexture.ts +50 -5
- package/src/core/renderers/webgl/WebGlCtxTexture.ts +124 -81
- package/src/core/renderers/webgl/WebGlRenderOp.ts +21 -12
- package/src/core/renderers/webgl/WebGlRenderer.ts +172 -137
- package/src/core/renderers/webgl/WebGlShaderNode.ts +2 -4
- package/src/core/renderers/webgl/WebGlShaderProgram.ts +58 -20
- package/src/core/shaders/canvas/Border.ts +5 -8
- package/src/core/shaders/canvas/HolePunch.ts +4 -11
- package/src/core/shaders/canvas/LinearGradient.ts +10 -8
- package/src/core/shaders/canvas/RadialGradient.ts +23 -37
- package/src/core/shaders/canvas/Rounded.ts +2 -2
- package/src/core/shaders/canvas/RoundedWithBorder.ts +20 -16
- package/src/core/shaders/canvas/RoundedWithBorderAndShadow.ts +17 -17
- package/src/core/shaders/canvas/RoundedWithShadow.ts +10 -9
- package/src/core/shaders/templates/BorderTemplate.ts +12 -12
- package/src/core/shaders/templates/HolePunchTemplate.ts +5 -5
- package/src/core/shaders/templates/RadialGradientTemplate.ts +10 -8
- 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/Border.ts +57 -37
- package/src/core/shaders/webgl/Default.ts +6 -7
- package/src/core/shaders/webgl/HolePunch.ts +4 -7
- package/src/core/shaders/webgl/LinearGradient.ts +33 -8
- package/src/core/shaders/webgl/RadialGradient.ts +58 -34
- package/src/core/shaders/webgl/Rounded.ts +4 -6
- package/src/core/shaders/webgl/RoundedWithBorder.ts +82 -44
- package/src/core/shaders/webgl/RoundedWithBorderAndShadow.ts +93 -50
- package/src/core/shaders/webgl/RoundedWithShadow.ts +3 -6
- package/src/core/shaders/webgl/SdfShader.ts +7 -19
- package/src/core/text-rendering/CanvasFontHandler.ts +304 -0
- package/src/core/text-rendering/CanvasTextRenderer.ts +255 -0
- package/src/core/text-rendering/SdfFontHandler.ts +591 -0
- package/src/core/text-rendering/SdfTextRenderer.ts +411 -0
- package/src/core/text-rendering/TextLayoutEngine.ts +672 -0
- package/src/core/text-rendering/TextRenderer.ts +444 -0
- package/src/core/text-rendering/Utils.ts +99 -0
- package/src/core/text-rendering/tests/TextLayoutEngine.test.ts +453 -0
- package/src/core/textures/ColorTexture.ts +7 -5
- package/src/core/textures/ImageTexture.ts +78 -66
- package/src/core/textures/NoiseTexture.ts +14 -12
- package/src/core/textures/RenderTexture.ts +18 -16
- package/src/core/textures/SubTexture.ts +25 -46
- package/src/core/textures/Texture.ts +207 -24
- package/src/core/utils.ts +9 -7
- package/src/main-api/INode.ts +4 -3
- package/src/main-api/Inspector.ts +571 -33
- package/src/main-api/Renderer.ts +505 -139
- package/src/utils.ts +10 -10
- package/dist/exports/core-api.d.ts +0 -74
- package/dist/exports/core-api.js +0 -96
- package/dist/exports/core-api.js.map +0 -1
- package/dist/exports/main-api.d.ts +0 -30
- package/dist/exports/main-api.js +0 -45
- package/dist/exports/main-api.js.map +0 -1
- package/dist/src/core/CoreExtension.d.ts +0 -12
- package/dist/src/core/CoreExtension.js +0 -29
- package/dist/src/core/CoreExtension.js.map +0 -1
- package/dist/src/core/CoreStuff.d.ts +0 -1
- package/dist/src/core/CoreStuff.js +0 -138
- package/dist/src/core/CoreStuff.js.map +0 -1
- package/dist/src/core/CoreTexturizer.d.ts +0 -14
- package/dist/src/core/CoreTexturizer.js +0 -47
- package/dist/src/core/CoreTexturizer.js.map +0 -1
- package/dist/src/core/LngNode.d.ts +0 -736
- package/dist/src/core/LngNode.js +0 -1174
- package/dist/src/core/LngNode.js.map +0 -1
- package/dist/src/core/Matrix2DContext.d.ts +0 -15
- package/dist/src/core/Matrix2DContext.js +0 -45
- package/dist/src/core/Matrix2DContext.js.map +0 -1
- package/dist/src/core/ShaderNode.d.ts +0 -10
- package/dist/src/core/ShaderNode.js +0 -30
- package/dist/src/core/ShaderNode.js.map +0 -1
- package/dist/src/core/TextNode.d.ts +0 -103
- package/dist/src/core/TextNode.js +0 -331
- package/dist/src/core/TextNode.js.map +0 -1
- package/dist/src/core/lib/Coords.d.ts +0 -14
- package/dist/src/core/lib/Coords.js +0 -55
- package/dist/src/core/lib/Coords.js.map +0 -1
- package/dist/src/core/lib/glm/common.d.ts +0 -162
- package/dist/src/core/lib/glm/common.js +0 -81
- package/dist/src/core/lib/glm/common.js.map +0 -1
- package/dist/src/core/lib/glm/index.d.ts +0 -11
- package/dist/src/core/lib/glm/index.js +0 -30
- package/dist/src/core/lib/glm/index.js.map +0 -1
- package/dist/src/core/lib/glm/mat2.d.ts +0 -219
- package/dist/src/core/lib/glm/mat2.js +0 -396
- package/dist/src/core/lib/glm/mat2.js.map +0 -1
- package/dist/src/core/lib/glm/mat2d.d.ts +0 -237
- package/dist/src/core/lib/glm/mat2d.js +0 -442
- package/dist/src/core/lib/glm/mat2d.js.map +0 -1
- package/dist/src/core/lib/glm/mat3.d.ts +0 -283
- package/dist/src/core/lib/glm/mat3.js +0 -680
- package/dist/src/core/lib/glm/mat3.js.map +0 -1
- package/dist/src/core/lib/glm/mat4.d.ts +0 -550
- package/dist/src/core/lib/glm/mat4.js +0 -1802
- package/dist/src/core/lib/glm/mat4.js.map +0 -1
- package/dist/src/core/lib/glm/quat.d.ts +0 -363
- package/dist/src/core/lib/glm/quat.js +0 -693
- package/dist/src/core/lib/glm/quat.js.map +0 -1
- package/dist/src/core/lib/glm/quat2.d.ts +0 -356
- package/dist/src/core/lib/glm/quat2.js +0 -754
- package/dist/src/core/lib/glm/quat2.js.map +0 -1
- package/dist/src/core/lib/glm/vec2.d.ts +0 -365
- package/dist/src/core/lib/glm/vec2.js +0 -569
- package/dist/src/core/lib/glm/vec2.js.map +0 -1
- package/dist/src/core/lib/glm/vec3.d.ts +0 -406
- package/dist/src/core/lib/glm/vec3.js +0 -720
- package/dist/src/core/lib/glm/vec3.js.map +0 -1
- package/dist/src/core/lib/glm/vec4.d.ts +0 -330
- package/dist/src/core/lib/glm/vec4.js +0 -608
- package/dist/src/core/lib/glm/vec4.js.map +0 -1
- package/dist/src/core/renderers/CoreShaderManager.d.ts +0 -19
- package/dist/src/core/renderers/CoreShaderManager.js +0 -33
- package/dist/src/core/renderers/CoreShaderManager.js.map +0 -1
- package/dist/src/core/renderers/webgl/WebGlCoreShaderManager.d.ts +0 -27
- package/dist/src/core/renderers/webgl/WebGlCoreShaderManager.js +0 -82
- package/dist/src/core/renderers/webgl/WebGlCoreShaderManager.js.map +0 -1
- package/dist/src/core/renderers/webgl/WebGlCoreShaderProgram.d.ts +0 -11
- package/dist/src/core/renderers/webgl/WebGlCoreShaderProgram.js +0 -34
- package/dist/src/core/renderers/webgl/WebGlCoreShaderProgram.js.map +0 -1
- package/dist/src/core/scene/Scene.d.ts +0 -59
- package/dist/src/core/scene/Scene.js +0 -106
- package/dist/src/core/scene/Scene.js.map +0 -1
- package/dist/src/core/shaders/templates/shaderUtils.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.d.ts +0 -20
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js +0 -55
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js.map +0 -1
- package/dist/src/main-api/ICoreDriver.d.ts +0 -27
- package/dist/src/main-api/ICoreDriver.js.map +0 -1
- package/dist/src/main-api/IRenderDriver.d.ts +0 -20
- package/dist/src/main-api/IRenderDriver.js.map +0 -1
- package/dist/src/main-api/IShaderController.d.ts +0 -14
- package/dist/src/main-api/IShaderController.js +0 -30
- package/dist/src/main-api/IShaderController.js.map +0 -1
- package/dist/src/main-api/IShaderNode.d.ts +0 -17
- package/dist/src/main-api/IShaderNode.js +0 -19
- package/dist/src/main-api/IShaderNode.js.map +0 -1
- package/dist/src/main-api/RendererMain.d.ts +0 -375
- package/dist/src/main-api/RendererMain.js +0 -365
- package/dist/src/main-api/RendererMain.js.map +0 -1
- package/dist/src/main-api/texture-usage-trackers/FinalizationRegistryTextureUsageTracker.d.ts +0 -9
- package/dist/src/main-api/texture-usage-trackers/FinalizationRegistryTextureUsageTracker.js +0 -38
- package/dist/src/main-api/texture-usage-trackers/FinalizationRegistryTextureUsageTracker.js.map +0 -1
- package/dist/src/main-api/texture-usage-trackers/ManualCountTextureUsageTracker.d.ts +0 -56
- package/dist/src/main-api/texture-usage-trackers/ManualCountTextureUsageTracker.js +0 -101
- package/dist/src/main-api/texture-usage-trackers/ManualCountTextureUsageTracker.js.map +0 -1
- package/dist/src/main-api/texture-usage-trackers/TextureUsageTracker.d.ts +0 -32
- package/dist/src/main-api/texture-usage-trackers/TextureUsageTracker.js +0 -28
- package/dist/src/main-api/texture-usage-trackers/TextureUsageTracker.js.map +0 -1
- package/dist/src/render-drivers/main/MainCoreDriver.d.ts +0 -24
- package/dist/src/render-drivers/main/MainCoreDriver.js +0 -118
- package/dist/src/render-drivers/main/MainCoreDriver.js.map +0 -1
- package/dist/src/render-drivers/main/MainOnlyNode.d.ts +0 -99
- package/dist/src/render-drivers/main/MainOnlyNode.js +0 -396
- package/dist/src/render-drivers/main/MainOnlyNode.js.map +0 -1
- package/dist/src/render-drivers/main/MainOnlyShaderController.d.ts +0 -6
- package/dist/src/render-drivers/main/MainOnlyShaderController.js +0 -15
- package/dist/src/render-drivers/main/MainOnlyShaderController.js.map +0 -1
- package/dist/src/render-drivers/main/MainOnlyShaderNode.d.ts +0 -7
- package/dist/src/render-drivers/main/MainOnlyShaderNode.js +0 -34
- package/dist/src/render-drivers/main/MainOnlyShaderNode.js.map +0 -1
- package/dist/src/render-drivers/main/MainOnlyTextNode.d.ts +0 -47
- package/dist/src/render-drivers/main/MainOnlyTextNode.js +0 -205
- package/dist/src/render-drivers/main/MainOnlyTextNode.js.map +0 -1
- package/dist/src/render-drivers/main/MainRenderDriver.d.ts +0 -17
- package/dist/src/render-drivers/main/MainRenderDriver.js +0 -88
- package/dist/src/render-drivers/main/MainRenderDriver.js.map +0 -1
- package/dist/src/render-drivers/threadx/NodeStruct.d.ts +0 -90
- package/dist/src/render-drivers/threadx/NodeStruct.js +0 -281
- package/dist/src/render-drivers/threadx/NodeStruct.js.map +0 -1
- package/dist/src/render-drivers/threadx/SharedNode.d.ts +0 -39
- package/dist/src/render-drivers/threadx/SharedNode.js +0 -60
- package/dist/src/render-drivers/threadx/SharedNode.js.map +0 -1
- package/dist/src/render-drivers/threadx/TextNodeStruct.d.ts +0 -44
- package/dist/src/render-drivers/threadx/TextNodeStruct.js +0 -201
- package/dist/src/render-drivers/threadx/TextNodeStruct.js.map +0 -1
- package/dist/src/render-drivers/threadx/ThreadXCoreDriver.d.ts +0 -28
- package/dist/src/render-drivers/threadx/ThreadXCoreDriver.js +0 -234
- package/dist/src/render-drivers/threadx/ThreadXCoreDriver.js.map +0 -1
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.d.ts +0 -20
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js +0 -84
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js.map +0 -1
- package/dist/src/render-drivers/threadx/ThreadXMainNode.d.ts +0 -44
- package/dist/src/render-drivers/threadx/ThreadXMainNode.js +0 -154
- package/dist/src/render-drivers/threadx/ThreadXMainNode.js.map +0 -1
- package/dist/src/render-drivers/threadx/ThreadXMainShaderController.d.ts +0 -6
- package/dist/src/render-drivers/threadx/ThreadXMainShaderController.js +0 -16
- package/dist/src/render-drivers/threadx/ThreadXMainShaderController.js.map +0 -1
- package/dist/src/render-drivers/threadx/ThreadXMainShaderNode.d.ts +0 -7
- package/dist/src/render-drivers/threadx/ThreadXMainShaderNode.js +0 -15
- package/dist/src/render-drivers/threadx/ThreadXMainShaderNode.js.map +0 -1
- package/dist/src/render-drivers/threadx/ThreadXMainTextNode.d.ts +0 -28
- package/dist/src/render-drivers/threadx/ThreadXMainTextNode.js +0 -55
- package/dist/src/render-drivers/threadx/ThreadXMainTextNode.js.map +0 -1
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.d.ts +0 -21
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.js +0 -198
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.js.map +0 -1
- package/dist/src/render-drivers/threadx/ThreadXRendererMessage.d.ts +0 -70
- package/dist/src/render-drivers/threadx/ThreadXRendererMessage.js +0 -32
- package/dist/src/render-drivers/threadx/ThreadXRendererMessage.js.map +0 -1
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.d.ts +0 -19
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js +0 -177
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js.map +0 -1
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.d.ts +0 -27
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.js +0 -108
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.js.map +0 -1
- package/dist/src/render-drivers/threadx/worker/renderer.d.ts +0 -1
- package/dist/src/render-drivers/threadx/worker/renderer.js +0 -145
- package/dist/src/render-drivers/threadx/worker/renderer.js.map +0 -1
- package/dist/src/render-drivers/utils.d.ts +0 -12
- package/dist/src/render-drivers/utils.js +0 -69
- package/dist/src/render-drivers/utils.js.map +0 -1
- package/scripts/please-use-pnpm.js +0 -13
- package/src/core/platform.ts +0 -64
- package/src/core/renderers/canvas/internal/C2DShaderUtils.ts +0 -220
- package/src/core/text-rendering/TextRenderingUtils.ts +0 -36
- package/src/core/text-rendering/TextTextureRendererUtils.ts +0 -263
- package/src/core/text-rendering/TrFontManager.ts +0 -183
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.ts +0 -176
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.ts +0 -139
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.test.ts +0 -173
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.ts +0 -171
- package/src/core/text-rendering/font-face-types/TrFontFace.ts +0 -187
- package/src/core/text-rendering/font-face-types/WebTrFontFace.ts +0 -94
- package/src/core/text-rendering/font-face-types/utils.ts +0 -39
- package/src/core/text-rendering/renderers/CanvasTextRenderer.ts +0 -509
- package/src/core/text-rendering/renderers/LightningTextTextureRenderer.ts +0 -815
- package/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.ts +0 -840
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.test.ts +0 -48
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.ts +0 -66
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.ts +0 -52
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.ts +0 -32
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.ts +0 -117
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.test.ts +0 -133
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.ts +0 -38
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.ts +0 -408
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.test.ts +0 -49
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.ts +0 -52
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/setRenderWindow.test.ts +0 -205
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/setRenderWindow.ts +0 -93
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/util.ts +0 -40
- package/src/core/text-rendering/renderers/TextRenderer.ts +0 -550
|
@@ -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,
|
|
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';
|
|
@@ -24,6 +24,7 @@ import { Matrix3d } from './lib/Matrix3d.js';
|
|
|
24
24
|
import { RenderCoords } from './lib/RenderCoords.js';
|
|
25
25
|
import { CoreAnimation } from './animations/CoreAnimation.js';
|
|
26
26
|
import { CoreAnimationController } from './animations/CoreAnimationController.js';
|
|
27
|
+
import { bucketSortByZIndex, incrementalRepositionByZIndex, removeChild, } from './lib/collectionUtils.js';
|
|
27
28
|
export var CoreNodeRenderState;
|
|
28
29
|
(function (CoreNodeRenderState) {
|
|
29
30
|
CoreNodeRenderState[CoreNodeRenderState["Init"] = 0] = "Init";
|
|
@@ -31,6 +32,13 @@ export var CoreNodeRenderState;
|
|
|
31
32
|
CoreNodeRenderState[CoreNodeRenderState["InBounds"] = 4] = "InBounds";
|
|
32
33
|
CoreNodeRenderState[CoreNodeRenderState["InViewport"] = 8] = "InViewport";
|
|
33
34
|
})(CoreNodeRenderState || (CoreNodeRenderState = {}));
|
|
35
|
+
const NO_CLIPPING_RECT = {
|
|
36
|
+
x: 0,
|
|
37
|
+
y: 0,
|
|
38
|
+
width: 0,
|
|
39
|
+
height: 0,
|
|
40
|
+
valid: false,
|
|
41
|
+
};
|
|
34
42
|
const CoreNodeRenderStateMap = new Map();
|
|
35
43
|
CoreNodeRenderStateMap.set(CoreNodeRenderState.Init, 'init');
|
|
36
44
|
CoreNodeRenderStateMap.set(CoreNodeRenderState.OutOfBounds, 'outOfBounds');
|
|
@@ -43,31 +51,23 @@ export var UpdateType;
|
|
|
43
51
|
*/
|
|
44
52
|
UpdateType[UpdateType["Children"] = 1] = "Children";
|
|
45
53
|
/**
|
|
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)
|
|
54
|
+
* localTransform
|
|
55
55
|
*
|
|
56
56
|
* @remarks
|
|
57
57
|
* CoreNode Properties Updated:
|
|
58
58
|
* - `localTransform`
|
|
59
59
|
*/
|
|
60
|
-
UpdateType[UpdateType["Local"] =
|
|
60
|
+
UpdateType[UpdateType["Local"] = 2] = "Local";
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* globalTransform
|
|
63
63
|
*
|
|
64
|
-
* @remarks
|
|
64
|
+
* * @remarks
|
|
65
65
|
* CoreNode Properties Updated:
|
|
66
66
|
* - `globalTransform`
|
|
67
|
+
* - `renderBounds`
|
|
67
68
|
* - `renderCoords`
|
|
68
|
-
* - `renderBound`
|
|
69
69
|
*/
|
|
70
|
-
UpdateType[UpdateType["Global"] =
|
|
70
|
+
UpdateType[UpdateType["Global"] = 4] = "Global";
|
|
71
71
|
/**
|
|
72
72
|
* Clipping rect update
|
|
73
73
|
*
|
|
@@ -75,23 +75,15 @@ export var UpdateType;
|
|
|
75
75
|
* CoreNode Properties Updated:
|
|
76
76
|
* - `clippingRect`
|
|
77
77
|
*/
|
|
78
|
-
UpdateType[UpdateType["Clipping"] =
|
|
78
|
+
UpdateType[UpdateType["Clipping"] = 8] = "Clipping";
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* @remarks
|
|
83
|
-
* CoreNode Properties Updated:
|
|
84
|
-
* - `calcZIndex`
|
|
85
|
-
*/
|
|
86
|
-
UpdateType[UpdateType["CalculatedZIndex"] = 32] = "CalculatedZIndex";
|
|
87
|
-
/**
|
|
88
|
-
* Z-Index Sorted Children update
|
|
80
|
+
* Sort Z-Index Children update
|
|
89
81
|
*
|
|
90
82
|
* @remarks
|
|
91
83
|
* CoreNode Properties Updated:
|
|
92
84
|
* - `children` (sorts children by their `calcZIndex`)
|
|
93
85
|
*/
|
|
94
|
-
UpdateType[UpdateType["
|
|
86
|
+
UpdateType[UpdateType["SortZIndexChildren"] = 16] = "SortZIndexChildren";
|
|
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"] = 32] = "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"] = 64] = "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"] = 128] = "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"] = 256] = "IsRenderable";
|
|
130
122
|
/**
|
|
131
123
|
* Render Texture update
|
|
132
124
|
*/
|
|
133
|
-
UpdateType[UpdateType["RenderTexture"] =
|
|
125
|
+
UpdateType[UpdateType["RenderTexture"] = 512] = "RenderTexture";
|
|
134
126
|
/**
|
|
135
127
|
* Track if parent has render texture
|
|
136
128
|
*/
|
|
137
|
-
UpdateType[UpdateType["ParentRenderTexture"] =
|
|
129
|
+
UpdateType[UpdateType["ParentRenderTexture"] = 1024] = "ParentRenderTexture";
|
|
138
130
|
/**
|
|
139
131
|
* Render Bounds update
|
|
140
132
|
*/
|
|
141
|
-
UpdateType[UpdateType["RenderBounds"] =
|
|
133
|
+
UpdateType[UpdateType["RenderBounds"] = 2048] = "RenderBounds";
|
|
134
|
+
/**
|
|
135
|
+
* RecalcUniforms
|
|
136
|
+
*/
|
|
137
|
+
UpdateType[UpdateType["RecalcUniforms"] = 4096] = "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"] = 7167] = "All";
|
|
154
146
|
})(UpdateType || (UpdateType = {}));
|
|
155
147
|
/**
|
|
156
148
|
* A visual Node in the Renderer scene graph.
|
|
@@ -166,10 +158,15 @@ export class CoreNode extends EventEmitter {
|
|
|
166
158
|
_id = getNewId();
|
|
167
159
|
props;
|
|
168
160
|
hasShaderUpdater = false;
|
|
161
|
+
hasShaderTimeFn = false;
|
|
162
|
+
hasColorProps = false;
|
|
163
|
+
zIndexMin = 0;
|
|
164
|
+
zIndexMax = 0;
|
|
165
|
+
previousZIndex = -1;
|
|
166
|
+
zIndexSortList = [];
|
|
169
167
|
updateType = UpdateType.All;
|
|
170
168
|
childUpdateType = UpdateType.None;
|
|
171
169
|
globalTransform;
|
|
172
|
-
scaleRotateTransform;
|
|
173
170
|
localTransform;
|
|
174
171
|
sceneGlobalTransform;
|
|
175
172
|
renderCoords;
|
|
@@ -184,6 +181,8 @@ export class CoreNode extends EventEmitter {
|
|
|
184
181
|
height: 0,
|
|
185
182
|
valid: false,
|
|
186
183
|
};
|
|
184
|
+
textureCoords;
|
|
185
|
+
updateShaderUniforms = false;
|
|
187
186
|
isRenderable = false;
|
|
188
187
|
renderState = CoreNodeRenderState.Init;
|
|
189
188
|
worldAlpha = 1;
|
|
@@ -195,104 +194,152 @@ export class CoreNode extends EventEmitter {
|
|
|
195
194
|
hasRTTupdates = false;
|
|
196
195
|
parentHasRenderTexture = false;
|
|
197
196
|
rttParent = null;
|
|
197
|
+
/**
|
|
198
|
+
* only used when rtt = true
|
|
199
|
+
*/
|
|
200
|
+
framebufferDimensions = null;
|
|
201
|
+
destroyed = false;
|
|
198
202
|
constructor(stage, props) {
|
|
199
203
|
super();
|
|
200
204
|
this.stage = stage;
|
|
201
|
-
this.props = {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
205
|
+
const p = (this.props = {});
|
|
206
|
+
//inital update type
|
|
207
|
+
let initialUpdateType = UpdateType.Local | UpdateType.RenderBounds | UpdateType.RenderState;
|
|
208
|
+
// Fast-path assign only known keys
|
|
209
|
+
p.x = props.x;
|
|
210
|
+
p.y = props.y;
|
|
211
|
+
p.w = props.w;
|
|
212
|
+
p.h = props.h;
|
|
213
|
+
p.alpha = props.alpha;
|
|
214
|
+
p.autosize = props.autosize;
|
|
215
|
+
p.clipping = props.clipping;
|
|
216
|
+
p.color = props.color;
|
|
217
|
+
p.colorTop = props.colorTop;
|
|
218
|
+
p.colorBottom = props.colorBottom;
|
|
219
|
+
p.colorLeft = props.colorLeft;
|
|
220
|
+
p.colorRight = props.colorRight;
|
|
221
|
+
p.colorTl = props.colorTl;
|
|
222
|
+
p.colorTr = props.colorTr;
|
|
223
|
+
p.colorBl = props.colorBl;
|
|
224
|
+
p.colorBr = props.colorBr;
|
|
225
|
+
//check if any color props are set for premultiplied color updates
|
|
226
|
+
if (props.color > 0 ||
|
|
227
|
+
props.colorTop > 0 ||
|
|
228
|
+
props.colorBottom > 0 ||
|
|
229
|
+
props.colorLeft > 0 ||
|
|
230
|
+
props.colorRight > 0 ||
|
|
231
|
+
props.colorTl > 0 ||
|
|
232
|
+
props.colorTr > 0 ||
|
|
233
|
+
props.colorBl > 0 ||
|
|
234
|
+
props.colorBr > 0) {
|
|
235
|
+
this.hasColorProps = true;
|
|
236
|
+
initialUpdateType |= UpdateType.PremultipliedColors;
|
|
237
|
+
}
|
|
238
|
+
p.scaleX = props.scaleX;
|
|
239
|
+
p.scaleY = props.scaleY;
|
|
240
|
+
p.rotation = props.rotation;
|
|
241
|
+
p.pivotX = props.pivotX;
|
|
242
|
+
p.pivotY = props.pivotY;
|
|
243
|
+
p.mountX = props.mountX;
|
|
244
|
+
p.mountY = props.mountY;
|
|
245
|
+
p.mount = props.mount;
|
|
246
|
+
p.pivot = props.pivot;
|
|
247
|
+
p.zIndex = props.zIndex;
|
|
248
|
+
p.textureOptions = props.textureOptions;
|
|
249
|
+
p.data = props.data;
|
|
250
|
+
p.imageType = props.imageType;
|
|
251
|
+
p.srcX = props.srcX;
|
|
252
|
+
p.srcY = props.srcY;
|
|
253
|
+
p.srcWidth = props.srcWidth;
|
|
254
|
+
p.srcHeight = props.srcHeight;
|
|
255
|
+
p.parent = props.parent;
|
|
256
|
+
p.texture = null;
|
|
257
|
+
p.shader = null;
|
|
258
|
+
p.src = null;
|
|
259
|
+
p.rtt = false;
|
|
260
|
+
p.boundsMargin = null;
|
|
261
|
+
// Only set non-default values
|
|
262
|
+
if (props.zIndex !== 0) {
|
|
263
|
+
this.zIndex = props.zIndex;
|
|
264
|
+
}
|
|
265
|
+
if (props.parent !== null) {
|
|
266
|
+
props.parent.addChild(this);
|
|
267
|
+
}
|
|
209
268
|
// Assign props to instances
|
|
210
|
-
this.parent = props.parent;
|
|
211
269
|
this.texture = props.texture;
|
|
212
270
|
this.shader = props.shader;
|
|
213
271
|
this.src = props.src;
|
|
214
272
|
this.rtt = props.rtt;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
: [
|
|
219
|
-
props.boundsMargin,
|
|
220
|
-
props.boundsMargin,
|
|
221
|
-
props.boundsMargin,
|
|
222
|
-
props.boundsMargin,
|
|
223
|
-
];
|
|
224
|
-
}
|
|
225
|
-
this.setUpdateType(UpdateType.ScaleRotate |
|
|
226
|
-
UpdateType.Local |
|
|
227
|
-
UpdateType.RenderBounds |
|
|
228
|
-
UpdateType.RenderState);
|
|
229
|
-
if (isProductionEnvironment() === false && props.preventCleanup === true) {
|
|
230
|
-
console.warn('CoreNode.preventCleanup: Is deprecated and will be removed in upcoming release, please use textureOptions.preventCleanup instead');
|
|
231
|
-
}
|
|
273
|
+
this.boundsMargin = props.boundsMargin;
|
|
274
|
+
this.interactive = props.interactive;
|
|
275
|
+
this.setUpdateType(initialUpdateType);
|
|
232
276
|
// if the default texture isn't loaded yet, wait for it to load
|
|
233
277
|
// this only happens when the node is created before the stage is ready
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
this.setUpdateType(UpdateType.IsRenderable);
|
|
238
|
-
});
|
|
278
|
+
const dt = this.stage.defaultTexture;
|
|
279
|
+
if (dt !== null && dt.state !== 'loaded') {
|
|
280
|
+
dt.once('loaded', () => this.setUpdateType(UpdateType.IsRenderable));
|
|
239
281
|
}
|
|
240
282
|
}
|
|
241
283
|
//#region Textures
|
|
242
284
|
loadTexture() {
|
|
243
|
-
|
|
244
|
-
|
|
285
|
+
if (this.props.texture === null) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
245
288
|
// If texture is already loaded / failed, trigger loaded event manually
|
|
246
289
|
// so that users get a consistent event experience.
|
|
247
290
|
// We do this in a microtask to allow listeners to be attached in the same
|
|
248
291
|
// synchronous task after calling loadTexture()
|
|
249
|
-
queueMicrotask(
|
|
250
|
-
if (this.textureOptions.preload === true) {
|
|
251
|
-
this.stage.txManager.loadTexture(texture);
|
|
252
|
-
}
|
|
253
|
-
texture.preventCleanup =
|
|
254
|
-
this.props.textureOptions?.preventCleanup ?? false;
|
|
255
|
-
texture.on('loaded', this.onTextureLoaded);
|
|
256
|
-
texture.on('failed', this.onTextureFailed);
|
|
257
|
-
texture.on('freed', this.onTextureFreed);
|
|
258
|
-
// If the parent is a render texture, the initial texture status
|
|
259
|
-
// will be set to freed until the texture is processed by the
|
|
260
|
-
// Render RTT nodes. So we only need to listen fo changes and
|
|
261
|
-
// no need to check the texture.state until we restructure how
|
|
262
|
-
// textures are being processed.
|
|
263
|
-
if (this.parentHasRenderTexture) {
|
|
264
|
-
this.notifyParentRTTOfUpdate();
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
if (texture.state === 'loaded') {
|
|
268
|
-
assertTruthy(texture.dimensions);
|
|
269
|
-
this.onTextureLoaded(texture, texture.dimensions);
|
|
270
|
-
}
|
|
271
|
-
else if (texture.state === 'failed') {
|
|
272
|
-
assertTruthy(texture.error);
|
|
273
|
-
this.onTextureFailed(texture, texture.error);
|
|
274
|
-
}
|
|
275
|
-
else if (texture.state === 'freed') {
|
|
276
|
-
this.onTextureFreed(texture);
|
|
277
|
-
}
|
|
278
|
-
});
|
|
292
|
+
queueMicrotask(this.loadTextureTask);
|
|
279
293
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
294
|
+
/**
|
|
295
|
+
* Task for queueMicrotask to loadTexture
|
|
296
|
+
*
|
|
297
|
+
* @remarks
|
|
298
|
+
* This method is called in a microtask to release the texture.
|
|
299
|
+
*/
|
|
300
|
+
loadTextureTask = () => {
|
|
301
|
+
const texture = this.texture;
|
|
302
|
+
if (this.textureOptions.preload === true) {
|
|
303
|
+
this.stage.txManager.loadTexture(texture);
|
|
304
|
+
}
|
|
305
|
+
texture.preventCleanup = this.props.textureOptions?.preventCleanup ?? false;
|
|
306
|
+
texture.on('loaded', this.onTextureLoaded);
|
|
307
|
+
texture.on('failed', this.onTextureFailed);
|
|
308
|
+
texture.on('freed', this.onTextureFreed);
|
|
309
|
+
// If the parent is a render texture, the initial texture status
|
|
310
|
+
// will be set to freed until the texture is processed by the
|
|
311
|
+
// Render RTT nodes. So we only need to listen fo changes and
|
|
312
|
+
// no need to check the texture.state until we restructure how
|
|
313
|
+
// textures are being processed.
|
|
314
|
+
if (this.parentHasRenderTexture) {
|
|
315
|
+
this.notifyParentRTTOfUpdate();
|
|
316
|
+
return;
|
|
286
317
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
this.
|
|
318
|
+
if (texture.state === 'loaded') {
|
|
319
|
+
this.onTextureLoaded(texture, texture.dimensions);
|
|
320
|
+
}
|
|
321
|
+
else if (texture.state === 'failed') {
|
|
322
|
+
this.onTextureFailed(texture, texture.error);
|
|
323
|
+
}
|
|
324
|
+
else if (texture.state === 'freed') {
|
|
325
|
+
this.onTextureFreed(texture);
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
unloadTexture() {
|
|
329
|
+
if (this.texture === null) {
|
|
330
|
+
return;
|
|
292
331
|
}
|
|
332
|
+
const texture = this.texture;
|
|
333
|
+
texture.off('loaded', this.onTextureLoaded);
|
|
334
|
+
texture.off('failed', this.onTextureFailed);
|
|
335
|
+
texture.off('freed', this.onTextureFreed);
|
|
336
|
+
texture.setRenderableOwner(this._id, false);
|
|
293
337
|
}
|
|
294
338
|
onTextureLoaded = (_, dimensions) => {
|
|
295
|
-
this.
|
|
339
|
+
if (this.autosize === true) {
|
|
340
|
+
this.w = dimensions.w;
|
|
341
|
+
this.h = dimensions.h;
|
|
342
|
+
}
|
|
296
343
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
297
344
|
// Texture was loaded. In case the RAF loop has already stopped, we request
|
|
298
345
|
// a render to ensure the texture is rendered.
|
|
@@ -302,29 +349,44 @@ export class CoreNode extends EventEmitter {
|
|
|
302
349
|
this.notifyParentRTTOfUpdate();
|
|
303
350
|
}
|
|
304
351
|
// ignore 1x1 pixel textures
|
|
305
|
-
if (dimensions.
|
|
352
|
+
if (dimensions.w > 1 && dimensions.h > 1) {
|
|
306
353
|
this.emit('loaded', {
|
|
307
354
|
type: 'texture',
|
|
308
355
|
dimensions,
|
|
309
356
|
});
|
|
310
357
|
}
|
|
358
|
+
if (this.stage.calculateTextureCoord === true &&
|
|
359
|
+
this.props.textureOptions !== null) {
|
|
360
|
+
this.textureCoords = this.stage.renderer.getTextureCoords(this);
|
|
361
|
+
}
|
|
311
362
|
// Trigger a local update if the texture is loaded and the resizeMode is 'contain'
|
|
312
363
|
if (this.props.textureOptions?.resizeMode?.type === 'contain') {
|
|
313
364
|
this.setUpdateType(UpdateType.Local);
|
|
314
365
|
}
|
|
315
366
|
};
|
|
316
367
|
onTextureFailed = (_, error) => {
|
|
368
|
+
// immediately set isRenderable to false, so that we handle the error
|
|
369
|
+
// without waiting for the next frame loop
|
|
370
|
+
this.isRenderable = false;
|
|
371
|
+
this.updateTextureOwnership(false);
|
|
317
372
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
318
373
|
// If parent has a render texture, flag that we need to update
|
|
319
374
|
if (this.parentHasRenderTexture) {
|
|
320
375
|
this.notifyParentRTTOfUpdate();
|
|
321
376
|
}
|
|
322
|
-
this.
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
377
|
+
if (this.texture !== null &&
|
|
378
|
+
this.texture.retryCount > this.texture.maxRetryCount) {
|
|
379
|
+
this.emit('failed', {
|
|
380
|
+
type: 'texture',
|
|
381
|
+
error,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
326
384
|
};
|
|
327
385
|
onTextureFreed = () => {
|
|
386
|
+
// immediately set isRenderable to false, so that we handle the error
|
|
387
|
+
// without waiting for the next frame loop
|
|
388
|
+
this.isRenderable = false;
|
|
389
|
+
this.updateTextureOwnership(false);
|
|
328
390
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
329
391
|
// If parent has a render texture, flag that we need to update
|
|
330
392
|
if (this.parentHasRenderTexture) {
|
|
@@ -348,95 +410,86 @@ export class CoreNode extends EventEmitter {
|
|
|
348
410
|
const parent = this.props.parent;
|
|
349
411
|
if (!parent)
|
|
350
412
|
return;
|
|
351
|
-
|
|
352
|
-
// Inform the parent if it doesn’t already have a child update
|
|
353
|
-
parent.setUpdateType(UpdateType.Children);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
sortChildren() {
|
|
357
|
-
this.children.sort((a, b) => a.calcZIndex - b.calcZIndex);
|
|
358
|
-
}
|
|
359
|
-
updateScaleRotateTransform() {
|
|
360
|
-
const { rotation, scaleX, scaleY } = this.props;
|
|
361
|
-
// optimize simple translation cases
|
|
362
|
-
if (rotation === 0 && scaleX === 1 && scaleY === 1) {
|
|
363
|
-
this.scaleRotateTransform = undefined;
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
this.scaleRotateTransform = Matrix3d.rotate(rotation, this.scaleRotateTransform).scale(scaleX, scaleY);
|
|
413
|
+
parent.setUpdateType(UpdateType.Children);
|
|
367
414
|
}
|
|
368
415
|
updateLocalTransform() {
|
|
369
|
-
const
|
|
370
|
-
const
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
const
|
|
416
|
+
const p = this.props;
|
|
417
|
+
const { x, y, w, h } = p;
|
|
418
|
+
const mountTranslateX = p.mountX * w;
|
|
419
|
+
const mountTranslateY = p.mountY * h;
|
|
420
|
+
if (p.rotation !== 0 || p.scaleX !== 1 || p.scaleY !== 1) {
|
|
421
|
+
const scaleRotate = Matrix3d.rotate(p.rotation).scale(p.scaleX, p.scaleY);
|
|
422
|
+
const pivotTranslateX = p.pivotX * w;
|
|
423
|
+
const pivotTranslateY = p.pivotY * h;
|
|
375
424
|
this.localTransform = Matrix3d.translate(x - mountTranslateX + pivotTranslateX, y - mountTranslateY + pivotTranslateY, this.localTransform)
|
|
376
|
-
.multiply(
|
|
425
|
+
.multiply(scaleRotate)
|
|
377
426
|
.translate(-pivotTranslateX, -pivotTranslateY);
|
|
378
427
|
}
|
|
379
428
|
else {
|
|
380
429
|
this.localTransform = Matrix3d.translate(x - mountTranslateX, y - mountTranslateY, this.localTransform);
|
|
381
430
|
}
|
|
382
431
|
// Handle 'contain' resize mode
|
|
383
|
-
const texture =
|
|
432
|
+
const texture = p.texture;
|
|
384
433
|
if (texture &&
|
|
385
434
|
texture.dimensions &&
|
|
386
|
-
|
|
435
|
+
p.textureOptions.resizeMode?.type === 'contain') {
|
|
387
436
|
let resizeModeScaleX = 1;
|
|
388
437
|
let resizeModeScaleY = 1;
|
|
389
438
|
let extraX = 0;
|
|
390
439
|
let extraY = 0;
|
|
391
|
-
const {
|
|
440
|
+
const { w: tw, h: th } = texture.dimensions;
|
|
392
441
|
const txAspectRatio = tw / th;
|
|
393
|
-
const nodeAspectRatio =
|
|
442
|
+
const nodeAspectRatio = w / h;
|
|
394
443
|
if (txAspectRatio > nodeAspectRatio) {
|
|
395
444
|
// Texture is wider than node
|
|
396
445
|
// Center the node vertically (shift down by extraY)
|
|
397
446
|
// Scale the node vertically to maintain original aspect ratio
|
|
398
|
-
const scaleX =
|
|
447
|
+
const scaleX = w / tw;
|
|
399
448
|
const scaledTxHeight = th * scaleX;
|
|
400
|
-
extraY = (
|
|
401
|
-
resizeModeScaleY = scaledTxHeight /
|
|
449
|
+
extraY = (h - scaledTxHeight) / 2;
|
|
450
|
+
resizeModeScaleY = scaledTxHeight / h;
|
|
402
451
|
}
|
|
403
452
|
else {
|
|
404
453
|
// Texture is taller than node (or equal)
|
|
405
454
|
// Center the node horizontally (shift right by extraX)
|
|
406
455
|
// Scale the node horizontally to maintain original aspect ratio
|
|
407
|
-
const scaleY =
|
|
456
|
+
const scaleY = h / th;
|
|
408
457
|
const scaledTxWidth = tw * scaleY;
|
|
409
|
-
extraX = (
|
|
410
|
-
resizeModeScaleX = scaledTxWidth /
|
|
458
|
+
extraX = (w - scaledTxWidth) / 2;
|
|
459
|
+
resizeModeScaleX = scaledTxWidth / w;
|
|
411
460
|
}
|
|
412
461
|
// Apply the extra translation and scale to the local transform
|
|
413
462
|
this.localTransform
|
|
414
463
|
.translate(extraX, extraY)
|
|
415
464
|
.scale(resizeModeScaleX, resizeModeScaleY);
|
|
416
465
|
}
|
|
417
|
-
this.setUpdateType(UpdateType.Global);
|
|
418
466
|
}
|
|
419
467
|
/**
|
|
420
468
|
* @todo: test for correct calculation flag
|
|
421
469
|
* @param delta
|
|
422
470
|
*/
|
|
423
471
|
update(delta, parentClippingRect) {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
472
|
+
const props = this.props;
|
|
473
|
+
const parent = props.parent;
|
|
474
|
+
const parentHasRenderTexture = this.parentHasRenderTexture;
|
|
475
|
+
const hasParent = props.parent !== null;
|
|
476
|
+
let newRenderState = null;
|
|
477
|
+
let updateType = this.updateType;
|
|
478
|
+
let childUpdateType = this.childUpdateType;
|
|
479
|
+
let updateParent = false;
|
|
480
|
+
// reset update type
|
|
481
|
+
this.updateType = 0;
|
|
482
|
+
this.childUpdateType = 0;
|
|
483
|
+
if (updateType & UpdateType.Local) {
|
|
429
484
|
this.updateLocalTransform();
|
|
430
|
-
|
|
485
|
+
updateType |= UpdateType.Global;
|
|
486
|
+
updateParent = hasParent;
|
|
431
487
|
}
|
|
432
|
-
const parent = this.props.parent;
|
|
433
|
-
let renderState = null;
|
|
434
488
|
// Handle specific RTT updates at this node level
|
|
435
|
-
if (
|
|
489
|
+
if (updateType & UpdateType.RenderTexture && this.rtt === true) {
|
|
436
490
|
this.hasRTTupdates = true;
|
|
437
491
|
}
|
|
438
|
-
if (
|
|
439
|
-
assertTruthy(this.localTransform);
|
|
492
|
+
if (updateType & UpdateType.Global) {
|
|
440
493
|
if (this.parentHasRenderTexture === true && parent?.rtt === true) {
|
|
441
494
|
// we are at the start of the RTT chain, so we need to reset the globalTransform
|
|
442
495
|
// for correct RTT rendering
|
|
@@ -460,134 +513,133 @@ export class CoreNode extends EventEmitter {
|
|
|
460
513
|
}
|
|
461
514
|
this.calculateRenderCoords();
|
|
462
515
|
this.updateBoundingRect();
|
|
463
|
-
|
|
464
|
-
UpdateType.
|
|
465
|
-
|
|
466
|
-
|
|
516
|
+
updateType |=
|
|
517
|
+
UpdateType.RenderState |
|
|
518
|
+
UpdateType.Children |
|
|
519
|
+
UpdateType.RecalcUniforms;
|
|
520
|
+
updateParent = hasParent;
|
|
521
|
+
childUpdateType |= UpdateType.Global;
|
|
467
522
|
if (this.clipping === true) {
|
|
468
|
-
|
|
469
|
-
|
|
523
|
+
updateType |= UpdateType.Clipping | UpdateType.RenderBounds;
|
|
524
|
+
updateParent = hasParent;
|
|
525
|
+
childUpdateType |= UpdateType.RenderBounds;
|
|
470
526
|
}
|
|
471
527
|
}
|
|
472
|
-
if (
|
|
528
|
+
if (updateType & UpdateType.RenderBounds) {
|
|
473
529
|
this.createRenderBounds();
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
if (
|
|
479
|
-
|
|
480
|
-
|
|
530
|
+
updateType |= UpdateType.RenderState | UpdateType.Children;
|
|
531
|
+
updateParent = hasParent;
|
|
532
|
+
childUpdateType |= UpdateType.RenderBounds;
|
|
533
|
+
}
|
|
534
|
+
if (updateType & UpdateType.RenderState) {
|
|
535
|
+
newRenderState = this.checkRenderBounds();
|
|
536
|
+
updateType |= UpdateType.IsRenderable;
|
|
537
|
+
updateParent = hasParent;
|
|
481
538
|
// if we're not going out of bounds, update the render state
|
|
482
539
|
// this is done so the update loop can finish before we mark a node
|
|
483
540
|
// as out of bounds
|
|
484
|
-
if (
|
|
485
|
-
this.updateRenderState(
|
|
541
|
+
if (newRenderState !== CoreNodeRenderState.OutOfBounds) {
|
|
542
|
+
this.updateRenderState(newRenderState);
|
|
486
543
|
}
|
|
487
544
|
}
|
|
488
|
-
if (
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
this.worldAlpha = this.props.alpha;
|
|
494
|
-
}
|
|
495
|
-
this.setUpdateType(UpdateType.Children |
|
|
545
|
+
if (updateType & UpdateType.WorldAlpha) {
|
|
546
|
+
this.worldAlpha = (parent?.worldAlpha ?? 1) * this.props.alpha;
|
|
547
|
+
updateType |=
|
|
496
548
|
UpdateType.PremultipliedColors |
|
|
497
|
-
|
|
498
|
-
|
|
549
|
+
UpdateType.Children |
|
|
550
|
+
UpdateType.IsRenderable;
|
|
551
|
+
updateParent = hasParent;
|
|
552
|
+
childUpdateType |= UpdateType.WorldAlpha;
|
|
499
553
|
}
|
|
500
|
-
if (
|
|
554
|
+
if (updateType & UpdateType.IsRenderable) {
|
|
501
555
|
this.updateIsRenderable();
|
|
502
556
|
}
|
|
503
|
-
if (
|
|
557
|
+
if (updateType & UpdateType.Clipping) {
|
|
504
558
|
this.calculateClippingRect(parentClippingRect);
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}
|
|
509
|
-
if (
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
559
|
+
updateType |= UpdateType.Children;
|
|
560
|
+
updateParent = hasParent;
|
|
561
|
+
childUpdateType |= UpdateType.Clipping | UpdateType.RenderBounds;
|
|
562
|
+
}
|
|
563
|
+
if (updateType & UpdateType.PremultipliedColors) {
|
|
564
|
+
const alpha = this.worldAlpha;
|
|
565
|
+
const tl = props.colorTl;
|
|
566
|
+
const tr = props.colorTr;
|
|
567
|
+
const bl = props.colorBl;
|
|
568
|
+
const br = props.colorBr;
|
|
569
|
+
// Fast equality check (covers all 4 corners)
|
|
570
|
+
const same = tl === tr && tl === bl && tl === br;
|
|
571
|
+
const merged = mergeColorAlphaPremultiplied(tl, alpha, true);
|
|
572
|
+
this.premultipliedColorTl = merged;
|
|
573
|
+
if (same === true) {
|
|
515
574
|
this.premultipliedColorTr =
|
|
516
575
|
this.premultipliedColorBl =
|
|
517
576
|
this.premultipliedColorBr =
|
|
518
|
-
|
|
577
|
+
merged;
|
|
519
578
|
}
|
|
520
579
|
else {
|
|
521
|
-
this.premultipliedColorTr = mergeColorAlphaPremultiplied(
|
|
522
|
-
this.premultipliedColorBl = mergeColorAlphaPremultiplied(
|
|
523
|
-
this.premultipliedColorBr = mergeColorAlphaPremultiplied(
|
|
580
|
+
this.premultipliedColorTr = mergeColorAlphaPremultiplied(tr, alpha, true);
|
|
581
|
+
this.premultipliedColorBl = mergeColorAlphaPremultiplied(bl, alpha, true);
|
|
582
|
+
this.premultipliedColorBr = mergeColorAlphaPremultiplied(br, alpha, true);
|
|
524
583
|
}
|
|
525
584
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
this.
|
|
529
|
-
|
|
530
|
-
parent.setUpdateType(UpdateType.ZIndexSortedChildren);
|
|
531
|
-
}
|
|
532
|
-
if (this.props.strictBounds === true &&
|
|
533
|
-
this.renderState === CoreNodeRenderState.OutOfBounds) {
|
|
534
|
-
this.updateType &= ~UpdateType.RenderBounds; // remove render bounds update
|
|
585
|
+
if (this.renderState === CoreNodeRenderState.OutOfBounds) {
|
|
586
|
+
// Delay updating children until the node is in bounds
|
|
587
|
+
this.updateType = updateType;
|
|
588
|
+
this.childUpdateType = childUpdateType;
|
|
535
589
|
return;
|
|
536
590
|
}
|
|
537
|
-
if (
|
|
591
|
+
if (updateParent === true) {
|
|
592
|
+
parent.setUpdateType(UpdateType.Children);
|
|
593
|
+
}
|
|
594
|
+
if (updateType & UpdateType.RecalcUniforms &&
|
|
538
595
|
this.hasShaderUpdater === true) {
|
|
596
|
+
this.updateShaderUniforms = true;
|
|
597
|
+
}
|
|
598
|
+
if (this.isRenderable === true && this.updateShaderUniforms === true) {
|
|
599
|
+
this.updateShaderUniforms = false;
|
|
539
600
|
//this exists because the boolean hasShaderUpdater === true
|
|
540
601
|
this.shader.update();
|
|
541
602
|
}
|
|
542
|
-
if (
|
|
603
|
+
if (updateType & UpdateType.Children && this.children.length > 0) {
|
|
604
|
+
let childClippingRect = this.clippingRect;
|
|
605
|
+
if (this.rtt === true) {
|
|
606
|
+
childClippingRect = NO_CLIPPING_RECT;
|
|
607
|
+
}
|
|
543
608
|
for (let i = 0, length = this.children.length; i < length; i++) {
|
|
544
609
|
const child = this.children[i];
|
|
545
|
-
|
|
610
|
+
if (childUpdateType !== 0) {
|
|
611
|
+
child.setUpdateType(childUpdateType);
|
|
612
|
+
}
|
|
546
613
|
if (child.updateType === 0) {
|
|
547
614
|
continue;
|
|
548
615
|
}
|
|
549
|
-
let childClippingRect = this.clippingRect;
|
|
550
|
-
if (this.rtt === true) {
|
|
551
|
-
childClippingRect = {
|
|
552
|
-
x: 0,
|
|
553
|
-
y: 0,
|
|
554
|
-
width: 0,
|
|
555
|
-
height: 0,
|
|
556
|
-
valid: false,
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
616
|
child.update(delta, childClippingRect);
|
|
560
617
|
}
|
|
561
618
|
}
|
|
562
619
|
// If the node has an RTT parent and requires a texture re-render, inform the RTT parent
|
|
563
|
-
// if (this.parentHasRenderTexture &&
|
|
620
|
+
// if (this.parentHasRenderTexture && updateType & UpdateType.RenderTexture) {
|
|
564
621
|
// @TODO have a more scoped down updateType for RTT updates
|
|
565
|
-
if (
|
|
622
|
+
if (parentHasRenderTexture === true) {
|
|
566
623
|
this.notifyParentRTTOfUpdate();
|
|
567
624
|
}
|
|
568
|
-
//
|
|
569
|
-
|
|
570
|
-
if (this.updateType & UpdateType.ZIndexSortedChildren) {
|
|
625
|
+
//Resort children if needed
|
|
626
|
+
if (updateType & UpdateType.SortZIndexChildren) {
|
|
571
627
|
// reorder z-index
|
|
572
628
|
this.sortChildren();
|
|
573
629
|
}
|
|
574
630
|
// If we're out of bounds, apply the render state now
|
|
575
631
|
// this is done so nodes can finish their entire update loop before
|
|
576
632
|
// being marked as out of bounds
|
|
577
|
-
if (
|
|
578
|
-
this.updateRenderState(
|
|
633
|
+
if (newRenderState === CoreNodeRenderState.OutOfBounds) {
|
|
634
|
+
this.updateRenderState(newRenderState);
|
|
579
635
|
this.updateIsRenderable();
|
|
580
636
|
if (this.rtt === true &&
|
|
581
|
-
|
|
637
|
+
newRenderState === CoreNodeRenderState.OutOfBounds) {
|
|
582
638
|
// notify children that we are going out of bounds
|
|
583
639
|
// we have to do this now before we stop processing the render tree
|
|
584
|
-
this.notifyChildrenRTTOfUpdate(
|
|
585
|
-
// this.childUpdateType |= UpdateType.RenderState;
|
|
640
|
+
this.notifyChildrenRTTOfUpdate(newRenderState);
|
|
586
641
|
}
|
|
587
642
|
}
|
|
588
|
-
// reset update type
|
|
589
|
-
this.updateType = 0;
|
|
590
|
-
this.childUpdateType = 0;
|
|
591
643
|
}
|
|
592
644
|
findParentRTTNode() {
|
|
593
645
|
let rttNode = this.parent;
|
|
@@ -596,13 +648,6 @@ export class CoreNode extends EventEmitter {
|
|
|
596
648
|
}
|
|
597
649
|
return rttNode;
|
|
598
650
|
}
|
|
599
|
-
getRTTParentRenderState() {
|
|
600
|
-
const rttNode = this.rttParent || this.findParentRTTNode();
|
|
601
|
-
if (!rttNode) {
|
|
602
|
-
return null;
|
|
603
|
-
}
|
|
604
|
-
return rttNode.renderState;
|
|
605
|
-
}
|
|
606
651
|
notifyChildrenRTTOfUpdate(renderState) {
|
|
607
652
|
for (const child of this.children) {
|
|
608
653
|
// force child to update render state
|
|
@@ -628,9 +673,6 @@ export class CoreNode extends EventEmitter {
|
|
|
628
673
|
}
|
|
629
674
|
}
|
|
630
675
|
checkRenderBounds() {
|
|
631
|
-
assertTruthy(this.renderBound);
|
|
632
|
-
assertTruthy(this.strictBound);
|
|
633
|
-
assertTruthy(this.preloadBound);
|
|
634
676
|
if (boundInsideBound(this.renderBound, this.strictBound)) {
|
|
635
677
|
return CoreNodeRenderState.InViewport;
|
|
636
678
|
}
|
|
@@ -642,17 +684,16 @@ export class CoreNode extends EventEmitter {
|
|
|
642
684
|
return CoreNodeRenderState.InViewport;
|
|
643
685
|
}
|
|
644
686
|
// check if we dont have dimensions, take our parent's render state
|
|
645
|
-
if (this.parent !== null &&
|
|
646
|
-
(this.props.width === 0 || this.props.height === 0)) {
|
|
687
|
+
if (this.parent !== null && (this.props.w === 0 || this.props.h === 0)) {
|
|
647
688
|
return this.parent.renderState;
|
|
648
689
|
}
|
|
649
690
|
return CoreNodeRenderState.OutOfBounds;
|
|
650
691
|
}
|
|
651
692
|
updateBoundingRect() {
|
|
652
|
-
const transform = this.sceneGlobalTransform ||
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
693
|
+
const transform = (this.sceneGlobalTransform ||
|
|
694
|
+
this.globalTransform);
|
|
695
|
+
const renderCoords = (this.sceneRenderCoords ||
|
|
696
|
+
this.renderCoords);
|
|
656
697
|
if (transform.tb === 0 || transform.tc === 0) {
|
|
657
698
|
this.renderBound = createBound(renderCoords.x1, renderCoords.y1, renderCoords.x3, renderCoords.y3, this.renderBound);
|
|
658
699
|
}
|
|
@@ -662,7 +703,6 @@ export class CoreNode extends EventEmitter {
|
|
|
662
703
|
}
|
|
663
704
|
}
|
|
664
705
|
createRenderBounds() {
|
|
665
|
-
assertTruthy(this.stage);
|
|
666
706
|
if (this.parent !== null && this.parent.strictBound !== undefined) {
|
|
667
707
|
// we have a parent with a valid bound, copy it
|
|
668
708
|
const parentBound = this.parent.strictBound;
|
|
@@ -688,13 +728,13 @@ export class CoreNode extends EventEmitter {
|
|
|
688
728
|
return;
|
|
689
729
|
}
|
|
690
730
|
// clipping is enabled and we are in bounds create our own bounds
|
|
691
|
-
const { x, y,
|
|
731
|
+
const { x, y, w, h } = this.props;
|
|
692
732
|
// Pick the global transform if available, otherwise use the local transform
|
|
693
733
|
// global transform is only available if the node in an RTT chain
|
|
694
734
|
const { tx, ty } = this.sceneGlobalTransform || this.globalTransform || {};
|
|
695
735
|
const _x = tx ?? x;
|
|
696
736
|
const _y = ty ?? y;
|
|
697
|
-
this.strictBound = createBound(_x, _y, _x +
|
|
737
|
+
this.strictBound = createBound(_x, _y, _x + w, _y + h, this.strictBound);
|
|
698
738
|
this.preloadBound = createPreloadBounds(this.strictBound, this.boundsMargin);
|
|
699
739
|
}
|
|
700
740
|
updateRenderState(renderState) {
|
|
@@ -710,6 +750,17 @@ export class CoreNode extends EventEmitter {
|
|
|
710
750
|
current: renderState,
|
|
711
751
|
});
|
|
712
752
|
}
|
|
753
|
+
/**
|
|
754
|
+
* Checks if the node is renderable based on world alpha, dimensions and out of bounds status.
|
|
755
|
+
*/
|
|
756
|
+
checkBasicRenderability() {
|
|
757
|
+
if (this.worldAlpha === 0 || this.isOutOfBounds() === true) {
|
|
758
|
+
return false;
|
|
759
|
+
}
|
|
760
|
+
else {
|
|
761
|
+
return true;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
713
764
|
/**
|
|
714
765
|
* Updates the `isRenderable` property based on various conditions.
|
|
715
766
|
*/
|
|
@@ -723,11 +774,22 @@ export class CoreNode extends EventEmitter {
|
|
|
723
774
|
return;
|
|
724
775
|
}
|
|
725
776
|
if (this.texture !== null) {
|
|
777
|
+
// preemptive check for failed textures this will mark the current node as non-renderable
|
|
778
|
+
// and will prevent further checks until the texture is reloaded or retry is reset on the texture
|
|
779
|
+
if (this.texture.retryCount > this.texture.maxRetryCount) {
|
|
780
|
+
// texture has failed to load, we cannot render
|
|
781
|
+
this.updateTextureOwnership(false);
|
|
782
|
+
this.setRenderable(false);
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
726
785
|
needsTextureOwnership = true;
|
|
727
786
|
// we're only renderable if the texture state is loaded
|
|
728
787
|
newIsRenderable = this.texture.state === 'loaded';
|
|
729
788
|
}
|
|
730
|
-
else if (
|
|
789
|
+
else if (
|
|
790
|
+
// check shader
|
|
791
|
+
(this.props.shader !== null || this.hasColorProps === true) &&
|
|
792
|
+
// check dimensions
|
|
731
793
|
this.hasDimensions() === true) {
|
|
732
794
|
// This mean we have dimensions and a color set, so we can render a ColorTexture
|
|
733
795
|
if (this.stage.defaultTexture &&
|
|
@@ -738,29 +800,26 @@ export class CoreNode extends EventEmitter {
|
|
|
738
800
|
this.updateTextureOwnership(needsTextureOwnership);
|
|
739
801
|
this.setRenderable(newIsRenderable);
|
|
740
802
|
}
|
|
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
803
|
/**
|
|
753
804
|
* Sets the renderable state and triggers changes if necessary.
|
|
754
805
|
* @param isRenderable - The new renderable state
|
|
755
806
|
*/
|
|
756
807
|
setRenderable(isRenderable) {
|
|
808
|
+
const previousIsRenderable = this.isRenderable;
|
|
757
809
|
this.isRenderable = isRenderable;
|
|
810
|
+
// Emit event if renderable status has changed
|
|
811
|
+
if (previousIsRenderable !== isRenderable) {
|
|
812
|
+
this.emit('renderable', {
|
|
813
|
+
type: 'renderable',
|
|
814
|
+
isRenderable,
|
|
815
|
+
});
|
|
816
|
+
}
|
|
758
817
|
}
|
|
759
818
|
/**
|
|
760
819
|
* Changes the renderable state of the node.
|
|
761
820
|
*/
|
|
762
821
|
updateTextureOwnership(isRenderable) {
|
|
763
|
-
this.texture?.setRenderableOwner(this, isRenderable);
|
|
822
|
+
this.texture?.setRenderableOwner(this._id, isRenderable);
|
|
764
823
|
}
|
|
765
824
|
/**
|
|
766
825
|
* Checks if the node is out of the viewport bounds.
|
|
@@ -772,33 +831,17 @@ export class CoreNode extends EventEmitter {
|
|
|
772
831
|
* Checks if the node has dimensions (width/height)
|
|
773
832
|
*/
|
|
774
833
|
hasDimensions() {
|
|
775
|
-
return this.props.
|
|
776
|
-
}
|
|
777
|
-
/**
|
|
778
|
-
* Checks if the node has any color properties set.
|
|
779
|
-
*/
|
|
780
|
-
hasColorProperties() {
|
|
781
|
-
return (this.props.color !== 0 ||
|
|
782
|
-
this.props.colorTop !== 0 ||
|
|
783
|
-
this.props.colorBottom !== 0 ||
|
|
784
|
-
this.props.colorLeft !== 0 ||
|
|
785
|
-
this.props.colorRight !== 0 ||
|
|
786
|
-
this.props.colorTl !== 0 ||
|
|
787
|
-
this.props.colorTr !== 0 ||
|
|
788
|
-
this.props.colorBl !== 0 ||
|
|
789
|
-
this.props.colorBr !== 0);
|
|
790
|
-
}
|
|
791
|
-
hasShader() {
|
|
792
|
-
return this.props.shader !== null;
|
|
834
|
+
return this.props.w !== 0 && this.props.h !== 0;
|
|
793
835
|
}
|
|
794
836
|
calculateRenderCoords() {
|
|
795
|
-
const {
|
|
796
|
-
const
|
|
837
|
+
const { w, h } = this.props;
|
|
838
|
+
const g = this.globalTransform;
|
|
839
|
+
const tx = g.tx, ty = g.ty, ta = g.ta, tb = g.tb, tc = g.tc, td = g.td;
|
|
797
840
|
if (tb === 0 && tc === 0) {
|
|
798
841
|
const minX = tx;
|
|
799
|
-
const maxX = tx +
|
|
842
|
+
const maxX = tx + w * ta;
|
|
800
843
|
const minY = ty;
|
|
801
|
-
const maxY = ty +
|
|
844
|
+
const maxY = ty + h * td;
|
|
802
845
|
this.renderCoords = RenderCoords.translate(
|
|
803
846
|
//top-left
|
|
804
847
|
minX, minY,
|
|
@@ -814,11 +857,11 @@ export class CoreNode extends EventEmitter {
|
|
|
814
857
|
//top-left
|
|
815
858
|
tx, ty,
|
|
816
859
|
//top-right
|
|
817
|
-
tx +
|
|
860
|
+
tx + w * ta, ty + w * tc,
|
|
818
861
|
//bottom-right
|
|
819
|
-
tx +
|
|
862
|
+
tx + w * ta + h * tb, ty + w * tc + h * td,
|
|
820
863
|
//bottom-left
|
|
821
|
-
tx +
|
|
864
|
+
tx + h * tb, ty + h * td, this.renderCoords);
|
|
822
865
|
}
|
|
823
866
|
if (this.sceneGlobalTransform === undefined) {
|
|
824
867
|
return;
|
|
@@ -826,9 +869,9 @@ export class CoreNode extends EventEmitter {
|
|
|
826
869
|
const { tx: stx, ty: sty, ta: sta, tb: stb, tc: stc, td: std, } = this.sceneGlobalTransform;
|
|
827
870
|
if (stb === 0 && stc === 0) {
|
|
828
871
|
const minX = stx;
|
|
829
|
-
const maxX = stx +
|
|
872
|
+
const maxX = stx + w * sta;
|
|
830
873
|
const minY = sty;
|
|
831
|
-
const maxY = sty +
|
|
874
|
+
const maxY = sty + h * std;
|
|
832
875
|
this.sceneRenderCoords = RenderCoords.translate(
|
|
833
876
|
//top-left
|
|
834
877
|
minX, minY,
|
|
@@ -844,11 +887,11 @@ export class CoreNode extends EventEmitter {
|
|
|
844
887
|
//top-left
|
|
845
888
|
stx, sty,
|
|
846
889
|
//top-right
|
|
847
|
-
stx +
|
|
890
|
+
stx + w * sta, sty + w * stc,
|
|
848
891
|
//bottom-right
|
|
849
|
-
stx +
|
|
892
|
+
stx + w * sta + h * stb, sty + w * stc + h * std,
|
|
850
893
|
//bottom-left
|
|
851
|
-
stx +
|
|
894
|
+
stx + h * stb, sty + h * std, this.sceneRenderCoords);
|
|
852
895
|
}
|
|
853
896
|
}
|
|
854
897
|
/**
|
|
@@ -860,15 +903,14 @@ export class CoreNode extends EventEmitter {
|
|
|
860
903
|
* Finally, the node's parentClippingRect and clippingRect properties are updated.
|
|
861
904
|
*/
|
|
862
905
|
calculateClippingRect(parentClippingRect) {
|
|
863
|
-
assertTruthy(this.globalTransform);
|
|
864
906
|
const { clippingRect, props, globalTransform: gt } = this;
|
|
865
907
|
const { clipping } = props;
|
|
866
908
|
const isRotated = gt.tb !== 0 || gt.tc !== 0;
|
|
867
909
|
if (clipping === true && isRotated === false) {
|
|
868
910
|
clippingRect.x = gt.tx;
|
|
869
911
|
clippingRect.y = gt.ty;
|
|
870
|
-
clippingRect.width = this.
|
|
871
|
-
clippingRect.height = this.
|
|
912
|
+
clippingRect.width = this.props.w * gt.ta;
|
|
913
|
+
clippingRect.height = this.props.h * gt.td;
|
|
872
914
|
clippingRect.valid = true;
|
|
873
915
|
}
|
|
874
916
|
else {
|
|
@@ -884,84 +926,157 @@ export class CoreNode extends EventEmitter {
|
|
|
884
926
|
clippingRect.valid = true;
|
|
885
927
|
}
|
|
886
928
|
}
|
|
887
|
-
calculateZIndex() {
|
|
888
|
-
const props = this.props;
|
|
889
|
-
const z = props.zIndex || 0;
|
|
890
|
-
const p = props.parent?.zIndex || 0;
|
|
891
|
-
let zIndex = z;
|
|
892
|
-
if (props.parent?.zIndexLocked) {
|
|
893
|
-
zIndex = z < p ? z : p;
|
|
894
|
-
}
|
|
895
|
-
this.calcZIndex = zIndex;
|
|
896
|
-
}
|
|
897
929
|
/**
|
|
898
930
|
* Destroy the node and cleanup all resources
|
|
899
931
|
*/
|
|
900
932
|
destroy() {
|
|
933
|
+
if (this.destroyed === true) {
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
this.removeAllListeners();
|
|
937
|
+
this.destroyed = true;
|
|
901
938
|
this.unloadTexture();
|
|
902
|
-
this.clippingRect.valid = false;
|
|
903
939
|
this.isRenderable = false;
|
|
904
|
-
this.
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
this.globalTransform = undefined;
|
|
909
|
-
this.scaleRotateTransform = undefined;
|
|
910
|
-
this.localTransform = undefined;
|
|
911
|
-
this.props.texture = null;
|
|
912
|
-
this.props.shader = null;
|
|
940
|
+
if (this.hasShaderTimeFn === true) {
|
|
941
|
+
this.stage.untrackTimedNode(this);
|
|
942
|
+
}
|
|
943
|
+
// Kill children
|
|
913
944
|
while (this.children.length > 0) {
|
|
914
|
-
this.children[0]
|
|
945
|
+
this.children[0].destroy();
|
|
915
946
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
947
|
+
const parent = this.parent;
|
|
948
|
+
if (parent !== null) {
|
|
949
|
+
parent.removeChild(this);
|
|
950
|
+
}
|
|
951
|
+
this.props.parent = null;
|
|
952
|
+
this.props.texture = null;
|
|
953
|
+
if (this.rtt === true) {
|
|
919
954
|
this.stage.renderer.removeRTTNode(this);
|
|
920
955
|
}
|
|
921
|
-
this.
|
|
956
|
+
this.stage.requestRender();
|
|
922
957
|
}
|
|
923
958
|
renderQuads(renderer) {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
if (!renderer.renderToTextureActive) {
|
|
928
|
-
return;
|
|
929
|
-
}
|
|
930
|
-
// Prevent quad rendering if parent render texture is not the active render texture
|
|
931
|
-
if (this.parentRenderTexture !== renderer.activeRttNode) {
|
|
959
|
+
if (this.parentHasRenderTexture === true) {
|
|
960
|
+
const rtt = renderer.renderToTextureActive;
|
|
961
|
+
if (rtt === false || this.parentRenderTexture !== renderer.activeRttNode)
|
|
932
962
|
return;
|
|
933
|
-
}
|
|
934
963
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
964
|
+
const p = this.props;
|
|
965
|
+
const t = this.globalTransform;
|
|
966
|
+
const coords = this.renderCoords;
|
|
967
|
+
const texture = p.texture || this.stage.defaultTexture;
|
|
968
|
+
const textureCoords = this.textureCoords || this.stage.renderer.defaultTextureCoords;
|
|
969
|
+
// There is a race condition where the texture can be null
|
|
970
|
+
// with RTT nodes. Adding this defensively to avoid errors.
|
|
971
|
+
if (texture && texture.state !== 'loaded') {
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
938
974
|
renderer.addQuad({
|
|
939
|
-
width:
|
|
940
|
-
height:
|
|
975
|
+
width: p.w,
|
|
976
|
+
height: p.h,
|
|
941
977
|
colorTl: this.premultipliedColorTl,
|
|
942
978
|
colorTr: this.premultipliedColorTr,
|
|
943
979
|
colorBl: this.premultipliedColorBl,
|
|
944
980
|
colorBr: this.premultipliedColorBr,
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
zIndex: this.zIndex,
|
|
950
|
-
shader: this.props.shader,
|
|
981
|
+
texture,
|
|
982
|
+
textureOptions: p.textureOptions,
|
|
983
|
+
textureCoords: textureCoords,
|
|
984
|
+
shader: p.shader,
|
|
951
985
|
alpha: this.worldAlpha,
|
|
952
986
|
clippingRect: this.clippingRect,
|
|
953
|
-
tx:
|
|
954
|
-
ty:
|
|
955
|
-
ta:
|
|
956
|
-
tb:
|
|
957
|
-
tc:
|
|
958
|
-
td:
|
|
959
|
-
renderCoords:
|
|
960
|
-
rtt:
|
|
987
|
+
tx: t.tx,
|
|
988
|
+
ty: t.ty,
|
|
989
|
+
ta: t.ta,
|
|
990
|
+
tb: t.tb,
|
|
991
|
+
tc: t.tc,
|
|
992
|
+
td: t.td,
|
|
993
|
+
renderCoords: coords,
|
|
994
|
+
rtt: p.rtt,
|
|
995
|
+
zIndex: this.calcZIndex,
|
|
961
996
|
parentHasRenderTexture: this.parentHasRenderTexture,
|
|
962
|
-
framebufferDimensions: this.
|
|
997
|
+
framebufferDimensions: this.parentHasRenderTexture
|
|
998
|
+
? this.parentFramebufferDimensions
|
|
999
|
+
: null,
|
|
1000
|
+
time: this.hasShaderTimeFn === true ? this.getTimerValue() : null,
|
|
963
1001
|
});
|
|
964
1002
|
}
|
|
1003
|
+
getTimerValue() {
|
|
1004
|
+
if (typeof this.shader.time === 'function') {
|
|
1005
|
+
return this.shader.time(this.stage);
|
|
1006
|
+
}
|
|
1007
|
+
return this.stage.elapsedTime;
|
|
1008
|
+
}
|
|
1009
|
+
sortChildren() {
|
|
1010
|
+
const changedCount = this.zIndexSortList.length;
|
|
1011
|
+
if (changedCount === 0) {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
const children = this.children;
|
|
1015
|
+
let min = Infinity;
|
|
1016
|
+
let max = -Infinity;
|
|
1017
|
+
// find min and max zIndex
|
|
1018
|
+
for (let i = 0; i < children.length; i++) {
|
|
1019
|
+
const zIndex = children[i].props.zIndex;
|
|
1020
|
+
if (zIndex < min) {
|
|
1021
|
+
min = zIndex;
|
|
1022
|
+
}
|
|
1023
|
+
if (zIndex > max) {
|
|
1024
|
+
max = zIndex;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
// update min and max zIndex
|
|
1028
|
+
this.zIndexMin = min;
|
|
1029
|
+
this.zIndexMax = max;
|
|
1030
|
+
// if min and max are the same, no need to sort
|
|
1031
|
+
if (min === max) {
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
const n = children.length;
|
|
1035
|
+
// decide whether to use incremental sort or bucket sort
|
|
1036
|
+
const useIncremental = changedCount <= 2 || changedCount < n * 0.05;
|
|
1037
|
+
// when changed count is less than 2 or 5% of total children, use incremental sort
|
|
1038
|
+
if (useIncremental === true) {
|
|
1039
|
+
incrementalRepositionByZIndex(this.zIndexSortList, children);
|
|
1040
|
+
}
|
|
1041
|
+
else {
|
|
1042
|
+
bucketSortByZIndex(children, min);
|
|
1043
|
+
}
|
|
1044
|
+
this.zIndexSortList.length = 0;
|
|
1045
|
+
this.zIndexSortList = [];
|
|
1046
|
+
}
|
|
1047
|
+
removeChild(node, targetParent = null) {
|
|
1048
|
+
if (targetParent === null &&
|
|
1049
|
+
this.props.rtt === true &&
|
|
1050
|
+
this.parentHasRenderTexture === true) {
|
|
1051
|
+
node.clearRTTInheritance();
|
|
1052
|
+
}
|
|
1053
|
+
removeChild(node, this.children);
|
|
1054
|
+
}
|
|
1055
|
+
addChild(node, previousParent = null) {
|
|
1056
|
+
const inRttCluster = this.props.rtt === true || this.parentHasRenderTexture === true;
|
|
1057
|
+
const children = this.children;
|
|
1058
|
+
const min = this.zIndexMin;
|
|
1059
|
+
const max = this.zIndexMax;
|
|
1060
|
+
const zIndex = node.zIndex;
|
|
1061
|
+
node.parentHasRenderTexture = inRttCluster;
|
|
1062
|
+
if (previousParent !== null) {
|
|
1063
|
+
const previousParentInRttCluster = previousParent.props.rtt === true ||
|
|
1064
|
+
previousParent.parentHasRenderTexture === true;
|
|
1065
|
+
if (inRttCluster === false && previousParentInRttCluster === true) {
|
|
1066
|
+
// update child RTT status
|
|
1067
|
+
node.clearRTTInheritance();
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
if (inRttCluster === true) {
|
|
1071
|
+
node.markChildrenWithRTT(this);
|
|
1072
|
+
}
|
|
1073
|
+
children.push(node);
|
|
1074
|
+
if (min !== max || (zIndex !== min && zIndex !== max)) {
|
|
1075
|
+
this.zIndexSortList.push(node);
|
|
1076
|
+
this.setUpdateType(UpdateType.SortZIndexChildren);
|
|
1077
|
+
}
|
|
1078
|
+
this.setUpdateType(UpdateType.Children);
|
|
1079
|
+
}
|
|
965
1080
|
//#region Properties
|
|
966
1081
|
get id() {
|
|
967
1082
|
return this._id;
|
|
@@ -983,12 +1098,12 @@ export class CoreNode extends EventEmitter {
|
|
|
983
1098
|
}
|
|
984
1099
|
get absX() {
|
|
985
1100
|
return (this.props.x +
|
|
986
|
-
-this.props.
|
|
1101
|
+
-this.props.w * this.props.mountX +
|
|
987
1102
|
(this.props.parent?.absX || this.props.parent?.globalTransform?.tx || 0));
|
|
988
1103
|
}
|
|
989
1104
|
get absY() {
|
|
990
1105
|
return (this.props.y +
|
|
991
|
-
-this.props.
|
|
1106
|
+
-this.props.h * this.props.mountY +
|
|
992
1107
|
(this.props.parent?.absY ?? 0));
|
|
993
1108
|
}
|
|
994
1109
|
get y() {
|
|
@@ -1000,34 +1115,30 @@ export class CoreNode extends EventEmitter {
|
|
|
1000
1115
|
this.setUpdateType(UpdateType.Local);
|
|
1001
1116
|
}
|
|
1002
1117
|
}
|
|
1003
|
-
get
|
|
1004
|
-
return this.props.
|
|
1118
|
+
get w() {
|
|
1119
|
+
return this.props.w;
|
|
1005
1120
|
}
|
|
1006
|
-
set
|
|
1007
|
-
if (this.props.
|
|
1008
|
-
this.props.
|
|
1121
|
+
set w(value) {
|
|
1122
|
+
if (this.props.w !== value) {
|
|
1123
|
+
this.props.w = value;
|
|
1009
1124
|
this.setUpdateType(UpdateType.Local);
|
|
1010
|
-
if (this.props.rtt) {
|
|
1011
|
-
this.
|
|
1012
|
-
|
|
1013
|
-
height: this.height,
|
|
1014
|
-
});
|
|
1125
|
+
if (this.props.rtt === true) {
|
|
1126
|
+
this.framebufferDimensions.w = value;
|
|
1127
|
+
this.texture = this.stage.txManager.createTexture('RenderTexture', this.framebufferDimensions);
|
|
1015
1128
|
this.setUpdateType(UpdateType.RenderTexture);
|
|
1016
1129
|
}
|
|
1017
1130
|
}
|
|
1018
1131
|
}
|
|
1019
|
-
get
|
|
1020
|
-
return this.props.
|
|
1132
|
+
get h() {
|
|
1133
|
+
return this.props.h;
|
|
1021
1134
|
}
|
|
1022
|
-
set
|
|
1023
|
-
if (this.props.
|
|
1024
|
-
this.props.
|
|
1135
|
+
set h(value) {
|
|
1136
|
+
if (this.props.h !== value) {
|
|
1137
|
+
this.props.h = value;
|
|
1025
1138
|
this.setUpdateType(UpdateType.Local);
|
|
1026
|
-
if (this.props.rtt) {
|
|
1027
|
-
this.
|
|
1028
|
-
|
|
1029
|
-
height: this.height,
|
|
1030
|
-
});
|
|
1139
|
+
if (this.props.rtt === true) {
|
|
1140
|
+
this.framebufferDimensions.h = value;
|
|
1141
|
+
this.texture = this.stage.txManager.createTexture('RenderTexture', this.framebufferDimensions);
|
|
1031
1142
|
this.setUpdateType(UpdateType.RenderTexture);
|
|
1032
1143
|
}
|
|
1033
1144
|
}
|
|
@@ -1049,7 +1160,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1049
1160
|
set scaleX(value) {
|
|
1050
1161
|
if (this.props.scaleX !== value) {
|
|
1051
1162
|
this.props.scaleX = value;
|
|
1052
|
-
this.setUpdateType(UpdateType.
|
|
1163
|
+
this.setUpdateType(UpdateType.Local);
|
|
1053
1164
|
}
|
|
1054
1165
|
}
|
|
1055
1166
|
get scaleY() {
|
|
@@ -1058,7 +1169,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1058
1169
|
set scaleY(value) {
|
|
1059
1170
|
if (this.props.scaleY !== value) {
|
|
1060
1171
|
this.props.scaleY = value;
|
|
1061
|
-
this.setUpdateType(UpdateType.
|
|
1172
|
+
this.setUpdateType(UpdateType.Local);
|
|
1062
1173
|
}
|
|
1063
1174
|
}
|
|
1064
1175
|
get mount() {
|
|
@@ -1125,7 +1236,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1125
1236
|
set rotation(value) {
|
|
1126
1237
|
if (this.props.rotation !== value) {
|
|
1127
1238
|
this.props.rotation = value;
|
|
1128
|
-
this.setUpdateType(UpdateType.
|
|
1239
|
+
this.setUpdateType(UpdateType.Local);
|
|
1129
1240
|
}
|
|
1130
1241
|
}
|
|
1131
1242
|
get alpha() {
|
|
@@ -1146,9 +1257,18 @@ export class CoreNode extends EventEmitter {
|
|
|
1146
1257
|
this.props.autosize = value;
|
|
1147
1258
|
}
|
|
1148
1259
|
get boundsMargin() {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1260
|
+
const props = this.props;
|
|
1261
|
+
if (props.boundsMargin !== null) {
|
|
1262
|
+
return props.boundsMargin;
|
|
1263
|
+
}
|
|
1264
|
+
const parent = this.parent;
|
|
1265
|
+
if (parent !== null) {
|
|
1266
|
+
const margin = parent.boundsMargin;
|
|
1267
|
+
if (margin !== undefined) {
|
|
1268
|
+
return margin;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
return this.stage.boundsMargin;
|
|
1152
1272
|
}
|
|
1153
1273
|
set boundsMargin(value) {
|
|
1154
1274
|
if (value === this.props.boundsMargin) {
|
|
@@ -1177,11 +1297,20 @@ export class CoreNode extends EventEmitter {
|
|
|
1177
1297
|
return this.props.color;
|
|
1178
1298
|
}
|
|
1179
1299
|
set color(value) {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1300
|
+
const p = this.props;
|
|
1301
|
+
if (p.color === value)
|
|
1302
|
+
return;
|
|
1303
|
+
p.color = value;
|
|
1304
|
+
const has = value > 0;
|
|
1305
|
+
this.hasColorProps = has;
|
|
1306
|
+
if (p.colorTop !== value)
|
|
1307
|
+
this.colorTop = value;
|
|
1308
|
+
if (p.colorBottom !== value)
|
|
1309
|
+
this.colorBottom = value;
|
|
1310
|
+
if (p.colorLeft !== value)
|
|
1311
|
+
this.colorLeft = value;
|
|
1312
|
+
if (p.colorRight !== value)
|
|
1313
|
+
this.colorRight = value;
|
|
1185
1314
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1186
1315
|
}
|
|
1187
1316
|
get colorTop() {
|
|
@@ -1193,6 +1322,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1193
1322
|
this.colorTr = value;
|
|
1194
1323
|
}
|
|
1195
1324
|
this.props.colorTop = value;
|
|
1325
|
+
this.hasColorProps = value > 0;
|
|
1196
1326
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1197
1327
|
}
|
|
1198
1328
|
get colorBottom() {
|
|
@@ -1204,6 +1334,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1204
1334
|
this.colorBr = value;
|
|
1205
1335
|
}
|
|
1206
1336
|
this.props.colorBottom = value;
|
|
1337
|
+
this.hasColorProps = value > 0;
|
|
1207
1338
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1208
1339
|
}
|
|
1209
1340
|
get colorLeft() {
|
|
@@ -1215,6 +1346,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1215
1346
|
this.colorBl = value;
|
|
1216
1347
|
}
|
|
1217
1348
|
this.props.colorLeft = value;
|
|
1349
|
+
this.hasColorProps = value > 0;
|
|
1218
1350
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1219
1351
|
}
|
|
1220
1352
|
get colorRight() {
|
|
@@ -1226,6 +1358,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1226
1358
|
this.colorBr = value;
|
|
1227
1359
|
}
|
|
1228
1360
|
this.props.colorRight = value;
|
|
1361
|
+
this.hasColorProps = value > 0;
|
|
1229
1362
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1230
1363
|
}
|
|
1231
1364
|
get colorTl() {
|
|
@@ -1233,6 +1366,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1233
1366
|
}
|
|
1234
1367
|
set colorTl(value) {
|
|
1235
1368
|
this.props.colorTl = value;
|
|
1369
|
+
this.hasColorProps = value > 0;
|
|
1236
1370
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1237
1371
|
}
|
|
1238
1372
|
get colorTr() {
|
|
@@ -1240,6 +1374,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1240
1374
|
}
|
|
1241
1375
|
set colorTr(value) {
|
|
1242
1376
|
this.props.colorTr = value;
|
|
1377
|
+
this.hasColorProps = value > 0;
|
|
1243
1378
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1244
1379
|
}
|
|
1245
1380
|
get colorBl() {
|
|
@@ -1247,6 +1382,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1247
1382
|
}
|
|
1248
1383
|
set colorBl(value) {
|
|
1249
1384
|
this.props.colorBl = value;
|
|
1385
|
+
this.hasColorProps = value > 0;
|
|
1250
1386
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1251
1387
|
}
|
|
1252
1388
|
get colorBr() {
|
|
@@ -1254,28 +1390,38 @@ export class CoreNode extends EventEmitter {
|
|
|
1254
1390
|
}
|
|
1255
1391
|
set colorBr(value) {
|
|
1256
1392
|
this.props.colorBr = value;
|
|
1393
|
+
this.hasColorProps = value > 0;
|
|
1257
1394
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1258
1395
|
}
|
|
1259
|
-
// we're only interested in parent zIndex to test
|
|
1260
|
-
// if we should use node zIndex is higher then parent zIndex
|
|
1261
|
-
get zIndexLocked() {
|
|
1262
|
-
return this.props.zIndexLocked || 0;
|
|
1263
|
-
}
|
|
1264
|
-
set zIndexLocked(value) {
|
|
1265
|
-
this.props.zIndexLocked = value;
|
|
1266
|
-
this.setUpdateType(UpdateType.CalculatedZIndex | UpdateType.Children);
|
|
1267
|
-
for (let i = 0, length = this.children.length; i < length; i++) {
|
|
1268
|
-
this.children[i].setUpdateType(UpdateType.CalculatedZIndex);
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
1396
|
get zIndex() {
|
|
1272
1397
|
return this.props.zIndex;
|
|
1273
1398
|
}
|
|
1274
1399
|
set zIndex(value) {
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1400
|
+
let sanitizedValue = value;
|
|
1401
|
+
if (isNaN(sanitizedValue) || Number.isFinite(sanitizedValue) === false) {
|
|
1402
|
+
console.warn(`zIndex was set to an invalid value: ${value}, defaulting to 0`);
|
|
1403
|
+
sanitizedValue = 0;
|
|
1404
|
+
}
|
|
1405
|
+
//Clamp to safe integer range
|
|
1406
|
+
if (sanitizedValue > Number.MAX_SAFE_INTEGER) {
|
|
1407
|
+
sanitizedValue = 1000;
|
|
1408
|
+
}
|
|
1409
|
+
else if (sanitizedValue < Number.MIN_SAFE_INTEGER) {
|
|
1410
|
+
sanitizedValue = -1000;
|
|
1411
|
+
}
|
|
1412
|
+
if (this.props.zIndex === sanitizedValue) {
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
this.previousZIndex = this.props.zIndex;
|
|
1416
|
+
this.props.zIndex = sanitizedValue;
|
|
1417
|
+
const parent = this.parent;
|
|
1418
|
+
if (parent !== null) {
|
|
1419
|
+
const min = parent.zIndexMin;
|
|
1420
|
+
const max = parent.zIndexMax;
|
|
1421
|
+
if (min !== max || sanitizedValue < min || sanitizedValue > max) {
|
|
1422
|
+
parent.zIndexSortList.push(this);
|
|
1423
|
+
parent.setUpdateType(UpdateType.SortZIndexChildren);
|
|
1424
|
+
}
|
|
1279
1425
|
}
|
|
1280
1426
|
}
|
|
1281
1427
|
get parent() {
|
|
@@ -1288,34 +1434,13 @@ export class CoreNode extends EventEmitter {
|
|
|
1288
1434
|
}
|
|
1289
1435
|
this.props.parent = newParent;
|
|
1290
1436
|
if (oldParent) {
|
|
1291
|
-
|
|
1292
|
-
assertTruthy(index !== -1, "CoreNode.parent: Node not found in old parent's children!");
|
|
1293
|
-
oldParent.children.splice(index, 1);
|
|
1294
|
-
oldParent.setUpdateType(UpdateType.Children | UpdateType.ZIndexSortedChildren);
|
|
1295
|
-
}
|
|
1296
|
-
if (newParent) {
|
|
1297
|
-
newParent.children.push(this);
|
|
1298
|
-
// Since this node has a new parent, to be safe, have it do a full update.
|
|
1299
|
-
this.setUpdateType(UpdateType.All);
|
|
1300
|
-
// Tell parent that it's children need to be updated and sorted.
|
|
1301
|
-
newParent.setUpdateType(UpdateType.Children | UpdateType.ZIndexSortedChildren);
|
|
1302
|
-
// If the new parent has an RTT enabled, apply RTT inheritance
|
|
1303
|
-
if (newParent.rtt || newParent.parentHasRenderTexture) {
|
|
1304
|
-
this.applyRTTInheritance(newParent);
|
|
1305
|
-
}
|
|
1437
|
+
oldParent.removeChild(this, newParent);
|
|
1306
1438
|
}
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
this.setUpdateType(UpdateType.RenderBounds | UpdateType.Children);
|
|
1310
|
-
}
|
|
1311
|
-
get preventCleanup() {
|
|
1312
|
-
return this.props.textureOptions.preventCleanup || false;
|
|
1313
|
-
}
|
|
1314
|
-
set preventCleanup(value) {
|
|
1315
|
-
if (isProductionEnvironment() === false) {
|
|
1316
|
-
console.warn('CoreNode.preventCleanup: Is deprecated and will be removed in upcoming release, please use textureOptions.preventCleanup instead');
|
|
1439
|
+
if (newParent !== null) {
|
|
1440
|
+
newParent.addChild(this, oldParent);
|
|
1317
1441
|
}
|
|
1318
|
-
this
|
|
1442
|
+
//since this node has a new parent, recalc global and render bounds
|
|
1443
|
+
this.setUpdateType(UpdateType.Global | UpdateType.RenderBounds);
|
|
1319
1444
|
}
|
|
1320
1445
|
get rtt() {
|
|
1321
1446
|
return this.props.rtt;
|
|
@@ -1338,10 +1463,11 @@ export class CoreNode extends EventEmitter {
|
|
|
1338
1463
|
}
|
|
1339
1464
|
}
|
|
1340
1465
|
initRenderTexture() {
|
|
1341
|
-
this.
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
}
|
|
1466
|
+
this.framebufferDimensions = {
|
|
1467
|
+
w: this.props.w,
|
|
1468
|
+
h: this.props.h,
|
|
1469
|
+
};
|
|
1470
|
+
this.texture = this.stage.txManager.createTexture('RenderTexture', this.framebufferDimensions);
|
|
1345
1471
|
this.stage.renderer.renderToTexture(this);
|
|
1346
1472
|
}
|
|
1347
1473
|
cleanupRenderTexture() {
|
|
@@ -1349,6 +1475,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1349
1475
|
this.clearRTTInheritance();
|
|
1350
1476
|
this.hasRTTupdates = false;
|
|
1351
1477
|
this.texture = null;
|
|
1478
|
+
this.framebufferDimensions = null;
|
|
1352
1479
|
}
|
|
1353
1480
|
markChildrenWithRTT(node = null) {
|
|
1354
1481
|
const parent = node || this;
|
|
@@ -1397,10 +1524,17 @@ export class CoreNode extends EventEmitter {
|
|
|
1397
1524
|
}
|
|
1398
1525
|
if (shader.shaderKey !== 'default') {
|
|
1399
1526
|
this.hasShaderUpdater = shader.update !== undefined;
|
|
1527
|
+
this.hasShaderTimeFn = shader.time !== undefined;
|
|
1400
1528
|
shader.attachNode(this);
|
|
1401
1529
|
}
|
|
1530
|
+
if (this.hasShaderTimeFn === true) {
|
|
1531
|
+
this.stage.trackTimedNode(this);
|
|
1532
|
+
}
|
|
1533
|
+
else {
|
|
1534
|
+
this.stage.untrackTimedNode(this);
|
|
1535
|
+
}
|
|
1402
1536
|
this.props.shader = shader;
|
|
1403
|
-
this.setUpdateType(UpdateType.IsRenderable);
|
|
1537
|
+
this.setUpdateType(UpdateType.IsRenderable | UpdateType.RecalcUniforms);
|
|
1404
1538
|
}
|
|
1405
1539
|
get src() {
|
|
1406
1540
|
return this.props.src;
|
|
@@ -1416,8 +1550,8 @@ export class CoreNode extends EventEmitter {
|
|
|
1416
1550
|
}
|
|
1417
1551
|
this.texture = this.stage.txManager.createTexture('ImageTexture', {
|
|
1418
1552
|
src: imageUrl,
|
|
1419
|
-
|
|
1420
|
-
|
|
1553
|
+
w: this.props.w,
|
|
1554
|
+
h: this.props.h,
|
|
1421
1555
|
type: this.props.imageType,
|
|
1422
1556
|
sx: this.props.srcX,
|
|
1423
1557
|
sy: this.props.srcY,
|
|
@@ -1459,16 +1593,14 @@ export class CoreNode extends EventEmitter {
|
|
|
1459
1593
|
this.props.srcY = value;
|
|
1460
1594
|
}
|
|
1461
1595
|
/**
|
|
1462
|
-
* Returns the framebuffer dimensions of the
|
|
1463
|
-
* If the node has a render texture, the dimensions are the same as the node's dimensions.
|
|
1464
|
-
* If the node does not have a render texture, the dimensions are inherited from the parent.
|
|
1465
|
-
* If the node parent has a render texture and the node is a render texture, the nodes dimensions are used.
|
|
1596
|
+
* Returns the framebuffer dimensions of the RTT parent
|
|
1466
1597
|
*/
|
|
1467
|
-
get
|
|
1468
|
-
if (this.
|
|
1469
|
-
return this.
|
|
1598
|
+
get parentFramebufferDimensions() {
|
|
1599
|
+
if (this.rttParent !== null) {
|
|
1600
|
+
return this.rttParent.framebufferDimensions;
|
|
1470
1601
|
}
|
|
1471
|
-
|
|
1602
|
+
this.rttParent = this.findParentRTTNode();
|
|
1603
|
+
return this.rttParent.framebufferDimensions;
|
|
1472
1604
|
}
|
|
1473
1605
|
/**
|
|
1474
1606
|
* Returns the parent render texture node if it exists.
|
|
@@ -1492,32 +1624,38 @@ export class CoreNode extends EventEmitter {
|
|
|
1492
1624
|
}
|
|
1493
1625
|
const oldTexture = this.props.texture;
|
|
1494
1626
|
if (oldTexture) {
|
|
1495
|
-
oldTexture.setRenderableOwner(this, false);
|
|
1496
1627
|
this.unloadTexture();
|
|
1497
1628
|
}
|
|
1629
|
+
this.textureCoords = undefined;
|
|
1498
1630
|
this.props.texture = value;
|
|
1499
1631
|
if (value !== null) {
|
|
1500
|
-
value.setRenderableOwner(this, this.isRenderable);
|
|
1632
|
+
value.setRenderableOwner(this._id, this.isRenderable);
|
|
1501
1633
|
this.loadTexture();
|
|
1502
1634
|
}
|
|
1503
1635
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
1504
1636
|
}
|
|
1505
1637
|
set textureOptions(value) {
|
|
1506
1638
|
this.props.textureOptions = value;
|
|
1639
|
+
if (this.stage.calculateTextureCoord === true && value !== null) {
|
|
1640
|
+
this.textureCoords = this.stage.renderer.getTextureCoords(this);
|
|
1641
|
+
}
|
|
1507
1642
|
}
|
|
1508
1643
|
get textureOptions() {
|
|
1509
1644
|
return this.props.textureOptions;
|
|
1510
1645
|
}
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
return;
|
|
1646
|
+
set interactive(value) {
|
|
1647
|
+
this.props.interactive = value;
|
|
1648
|
+
// Update Stage's interactive Set
|
|
1649
|
+
if (value === true) {
|
|
1650
|
+
this.stage.interactiveNodes.add(this);
|
|
1517
1651
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
this.
|
|
1652
|
+
}
|
|
1653
|
+
get interactive() {
|
|
1654
|
+
return this.props.interactive;
|
|
1655
|
+
}
|
|
1656
|
+
setRTTUpdates(type) {
|
|
1657
|
+
this.hasRTTupdates = true;
|
|
1658
|
+
this.parent?.setRTTUpdates(type);
|
|
1521
1659
|
}
|
|
1522
1660
|
animate(props, settings) {
|
|
1523
1661
|
const animation = new CoreAnimation(this, props, settings);
|