@lightningjs/renderer 3.0.0-beta2 → 3.0.0-beta21
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 +124 -100
- package/dist/src/core/CoreNode.js +720 -472
- 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 +355 -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 +93 -33
- package/dist/src/core/Stage.js +315 -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/Animation.d.ts +21 -0
- package/dist/src/core/animations/Animation.js +194 -0
- package/dist/src/core/animations/Animation.js.map +1 -0
- 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/animations/Playback.d.ts +64 -0
- package/dist/src/core/animations/Playback.js +169 -0
- package/dist/src/core/animations/Playback.js.map +1 -0
- package/dist/src/core/animations/Transition.d.ts +27 -0
- package/dist/src/core/animations/Transition.js +52 -0
- package/dist/src/core/animations/Transition.js.map +1 -0
- package/dist/src/core/animations/utils.d.ts +2 -0
- package/dist/src/core/animations/utils.js +136 -0
- package/dist/src/core/animations/utils.js.map +1 -0
- package/dist/src/core/lib/ImageWorker.d.ts +2 -2
- package/dist/src/core/lib/ImageWorker.js +31 -12
- 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 +105 -28
- 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 +8 -2
- package/dist/src/core/lib/utils.js +43 -21
- 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 +5 -30
- 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 +12 -1
- package/dist/src/core/renderers/CoreShaderNode.js +26 -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 +4 -5
- package/dist/src/core/renderers/canvas/CanvasRenderer.js +65 -87
- package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +1 -1
- package/dist/src/core/renderers/canvas/CanvasShaderNode.d.ts +1 -2
- 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/SdfRenderOp.d.ts +33 -0
- package/dist/src/core/renderers/webgl/SdfRenderOp.js +97 -0
- package/dist/src/core/renderers/webgl/SdfRenderOp.js.map +1 -0
- 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 +87 -42
- 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 +102 -52
- package/dist/src/core/renderers/webgl/WebGlCtxTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlRenderOp.d.ts +1 -1
- package/dist/src/core/renderers/webgl/WebGlRenderOp.js +11 -4
- package/dist/src/core/renderers/webgl/WebGlRenderOp.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlRenderer.d.ts +11 -21
- package/dist/src/core/renderers/webgl/WebGlRenderer.js +168 -152
- package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlShaderNode.d.ts +2 -4
- 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 +9 -7
- package/dist/src/core/renderers/webgl/WebGlShaderProgram.js +83 -43
- 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.d.ts +8 -2
- package/dist/src/core/shaders/canvas/Border.js +64 -25
- package/dist/src/core/shaders/canvas/Border.js.map +1 -1
- package/dist/src/core/shaders/canvas/HolePunch.js +4 -3
- package/dist/src/core/shaders/canvas/HolePunch.js.map +1 -1
- package/dist/src/core/shaders/canvas/LinearGradient.js +11 -7
- package/dist/src/core/shaders/canvas/LinearGradient.js.map +1 -1
- package/dist/src/core/shaders/canvas/RadialGradient.js +21 -17
- package/dist/src/core/shaders/canvas/RadialGradient.js.map +1 -1
- package/dist/src/core/shaders/canvas/Rounded.js +3 -3
- package/dist/src/core/shaders/canvas/Rounded.js.map +1 -1
- package/dist/src/core/shaders/canvas/RoundedWithBorder.d.ts +6 -3
- package/dist/src/core/shaders/canvas/RoundedWithBorder.js +45 -7
- package/dist/src/core/shaders/canvas/RoundedWithBorder.js.map +1 -1
- package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.d.ts +2 -3
- package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js +50 -11
- package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js.map +1 -1
- package/dist/src/core/shaders/canvas/RoundedWithShadow.js +10 -7
- package/dist/src/core/shaders/canvas/RoundedWithShadow.js.map +1 -1
- package/dist/src/core/shaders/canvas/Shadow.js +4 -2
- package/dist/src/core/shaders/canvas/Shadow.js.map +1 -1
- package/dist/src/core/shaders/canvas/utils/render.d.ts +1 -1
- package/dist/src/core/shaders/canvas/utils/render.js +31 -18
- package/dist/src/core/shaders/canvas/utils/render.js.map +1 -1
- package/dist/src/core/shaders/templates/BorderTemplate.d.ts +12 -2
- package/dist/src/core/shaders/templates/BorderTemplate.js +31 -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 +116 -35
- 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 +153 -39
- package/dist/src/core/shaders/webgl/RoundedWithBorder.js.map +1 -1
- package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +158 -43
- package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js.map +1 -1
- package/dist/src/core/shaders/webgl/RoundedWithShadow.js +6 -4
- 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/shaders/webgl/SdfShadowShader.d.ts +9 -0
- package/dist/src/core/shaders/webgl/SdfShadowShader.js +100 -0
- package/dist/src/core/shaders/webgl/SdfShadowShader.js.map +1 -0
- package/dist/src/core/shaders/webgl/Shadow.js +12 -6
- package/dist/src/core/shaders/webgl/Shadow.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 +303 -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 +2 -1
- 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 +131 -2
- package/dist/src/main-api/Inspector.js +345 -28
- package/dist/src/main-api/Inspector.js.map +1 -1
- package/dist/src/main-api/Renderer.d.ts +295 -82
- package/dist/src/main-api/Renderer.js +223 -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/Autosizer.ts +224 -0
- package/src/core/CoreNode.test.ts +179 -17
- package/src/core/CoreNode.ts +895 -599
- package/src/core/CoreShaderManager.ts +5 -10
- package/src/core/CoreTextNode.ts +422 -286
- package/src/core/CoreTextureManager.ts +110 -130
- package/src/core/Stage.ts +397 -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 +43 -12
- package/src/core/lib/WebGlContextWrapper.ts +127 -79
- 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 +54 -25
- 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 +5 -32
- package/src/core/renderers/CoreShaderNode.ts +38 -3
- package/src/core/renderers/canvas/CanvasRenderer.ts +84 -126
- package/src/core/renderers/canvas/CanvasShaderNode.ts +4 -8
- package/src/core/renderers/canvas/CanvasTexture.ts +22 -18
- package/src/core/renderers/webgl/SdfRenderOp.ts +105 -0
- 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 +134 -84
- package/src/core/renderers/webgl/WebGlRenderer.ts +203 -190
- package/src/core/renderers/webgl/WebGlShaderNode.ts +4 -11
- package/src/core/renderers/webgl/WebGlShaderProgram.ts +101 -53
- package/src/core/shaders/canvas/Border.ts +88 -34
- package/src/core/shaders/canvas/HolePunch.ts +5 -11
- package/src/core/shaders/canvas/LinearGradient.ts +14 -10
- package/src/core/shaders/canvas/RadialGradient.ts +24 -41
- package/src/core/shaders/canvas/Rounded.ts +7 -7
- package/src/core/shaders/canvas/RoundedWithBorder.ts +77 -23
- package/src/core/shaders/canvas/RoundedWithBorderAndShadow.ts +84 -36
- package/src/core/shaders/canvas/RoundedWithShadow.ts +15 -13
- package/src/core/shaders/canvas/Shadow.ts +7 -5
- package/src/core/shaders/canvas/utils/render.ts +45 -36
- package/src/core/shaders/templates/BorderTemplate.ts +42 -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 +116 -39
- 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 +154 -46
- package/src/core/shaders/webgl/RoundedWithBorderAndShadow.ts +159 -52
- package/src/core/shaders/webgl/RoundedWithShadow.ts +6 -8
- package/src/core/shaders/webgl/SdfShader.ts +7 -19
- package/src/core/shaders/webgl/Shadow.ts +12 -6
- 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 +408 -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 +577 -36
- package/src/main-api/Renderer.ts +518 -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/renderers/webgl/WebGlRenderOp.ts +0 -161
- 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,8 @@ 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 { AutosizeMode, Autosizer } from './Autosizer.js';
|
|
28
|
+
import { bucketSortByZIndex, incrementalRepositionByZIndex, removeChild, } from './lib/collectionUtils.js';
|
|
27
29
|
export var CoreNodeRenderState;
|
|
28
30
|
(function (CoreNodeRenderState) {
|
|
29
31
|
CoreNodeRenderState[CoreNodeRenderState["Init"] = 0] = "Init";
|
|
@@ -31,6 +33,13 @@ export var CoreNodeRenderState;
|
|
|
31
33
|
CoreNodeRenderState[CoreNodeRenderState["InBounds"] = 4] = "InBounds";
|
|
32
34
|
CoreNodeRenderState[CoreNodeRenderState["InViewport"] = 8] = "InViewport";
|
|
33
35
|
})(CoreNodeRenderState || (CoreNodeRenderState = {}));
|
|
36
|
+
const NO_CLIPPING_RECT = {
|
|
37
|
+
x: 0,
|
|
38
|
+
y: 0,
|
|
39
|
+
w: 0,
|
|
40
|
+
h: 0,
|
|
41
|
+
valid: false,
|
|
42
|
+
};
|
|
34
43
|
const CoreNodeRenderStateMap = new Map();
|
|
35
44
|
CoreNodeRenderStateMap.set(CoreNodeRenderState.Init, 'init');
|
|
36
45
|
CoreNodeRenderStateMap.set(CoreNodeRenderState.OutOfBounds, 'outOfBounds');
|
|
@@ -43,31 +52,23 @@ export var UpdateType;
|
|
|
43
52
|
*/
|
|
44
53
|
UpdateType[UpdateType["Children"] = 1] = "Children";
|
|
45
54
|
/**
|
|
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)
|
|
55
|
+
* localTransform
|
|
55
56
|
*
|
|
56
57
|
* @remarks
|
|
57
58
|
* CoreNode Properties Updated:
|
|
58
59
|
* - `localTransform`
|
|
59
60
|
*/
|
|
60
|
-
UpdateType[UpdateType["Local"] =
|
|
61
|
+
UpdateType[UpdateType["Local"] = 2] = "Local";
|
|
61
62
|
/**
|
|
62
|
-
*
|
|
63
|
+
* globalTransform
|
|
63
64
|
*
|
|
64
|
-
* @remarks
|
|
65
|
+
* * @remarks
|
|
65
66
|
* CoreNode Properties Updated:
|
|
66
67
|
* - `globalTransform`
|
|
68
|
+
* - `renderBounds`
|
|
67
69
|
* - `renderCoords`
|
|
68
|
-
* - `renderBound`
|
|
69
70
|
*/
|
|
70
|
-
UpdateType[UpdateType["Global"] =
|
|
71
|
+
UpdateType[UpdateType["Global"] = 4] = "Global";
|
|
71
72
|
/**
|
|
72
73
|
* Clipping rect update
|
|
73
74
|
*
|
|
@@ -75,23 +76,15 @@ export var UpdateType;
|
|
|
75
76
|
* CoreNode Properties Updated:
|
|
76
77
|
* - `clippingRect`
|
|
77
78
|
*/
|
|
78
|
-
UpdateType[UpdateType["Clipping"] =
|
|
79
|
+
UpdateType[UpdateType["Clipping"] = 8] = "Clipping";
|
|
79
80
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* @remarks
|
|
83
|
-
* CoreNode Properties Updated:
|
|
84
|
-
* - `calcZIndex`
|
|
85
|
-
*/
|
|
86
|
-
UpdateType[UpdateType["CalculatedZIndex"] = 32] = "CalculatedZIndex";
|
|
87
|
-
/**
|
|
88
|
-
* Z-Index Sorted Children update
|
|
81
|
+
* Sort Z-Index Children update
|
|
89
82
|
*
|
|
90
83
|
* @remarks
|
|
91
84
|
* CoreNode Properties Updated:
|
|
92
85
|
* - `children` (sorts children by their `calcZIndex`)
|
|
93
86
|
*/
|
|
94
|
-
UpdateType[UpdateType["
|
|
87
|
+
UpdateType[UpdateType["SortZIndexChildren"] = 16] = "SortZIndexChildren";
|
|
95
88
|
/**
|
|
96
89
|
* Premultiplied Colors update
|
|
97
90
|
*
|
|
@@ -102,7 +95,7 @@ export var UpdateType;
|
|
|
102
95
|
* - `premultipliedColorBl`
|
|
103
96
|
* - `premultipliedColorBr`
|
|
104
97
|
*/
|
|
105
|
-
UpdateType[UpdateType["PremultipliedColors"] =
|
|
98
|
+
UpdateType[UpdateType["PremultipliedColors"] = 32] = "PremultipliedColors";
|
|
106
99
|
/**
|
|
107
100
|
* World Alpha update
|
|
108
101
|
*
|
|
@@ -110,7 +103,7 @@ export var UpdateType;
|
|
|
110
103
|
* CoreNode Properties Updated:
|
|
111
104
|
* - `worldAlpha` = `parent.worldAlpha` * `alpha`
|
|
112
105
|
*/
|
|
113
|
-
UpdateType[UpdateType["WorldAlpha"] =
|
|
106
|
+
UpdateType[UpdateType["WorldAlpha"] = 64] = "WorldAlpha";
|
|
114
107
|
/**
|
|
115
108
|
* Render State update
|
|
116
109
|
*
|
|
@@ -118,7 +111,7 @@ export var UpdateType;
|
|
|
118
111
|
* CoreNode Properties Updated:
|
|
119
112
|
* - `renderState`
|
|
120
113
|
*/
|
|
121
|
-
UpdateType[UpdateType["RenderState"] =
|
|
114
|
+
UpdateType[UpdateType["RenderState"] = 128] = "RenderState";
|
|
122
115
|
/**
|
|
123
116
|
* Is Renderable update
|
|
124
117
|
*
|
|
@@ -126,19 +119,27 @@ export var UpdateType;
|
|
|
126
119
|
* CoreNode Properties Updated:
|
|
127
120
|
* - `isRenderable`
|
|
128
121
|
*/
|
|
129
|
-
UpdateType[UpdateType["IsRenderable"] =
|
|
122
|
+
UpdateType[UpdateType["IsRenderable"] = 256] = "IsRenderable";
|
|
130
123
|
/**
|
|
131
124
|
* Render Texture update
|
|
132
125
|
*/
|
|
133
|
-
UpdateType[UpdateType["RenderTexture"] =
|
|
126
|
+
UpdateType[UpdateType["RenderTexture"] = 512] = "RenderTexture";
|
|
134
127
|
/**
|
|
135
128
|
* Track if parent has render texture
|
|
136
129
|
*/
|
|
137
|
-
UpdateType[UpdateType["ParentRenderTexture"] =
|
|
130
|
+
UpdateType[UpdateType["ParentRenderTexture"] = 1024] = "ParentRenderTexture";
|
|
138
131
|
/**
|
|
139
132
|
* Render Bounds update
|
|
140
133
|
*/
|
|
141
|
-
UpdateType[UpdateType["RenderBounds"] =
|
|
134
|
+
UpdateType[UpdateType["RenderBounds"] = 2048] = "RenderBounds";
|
|
135
|
+
/**
|
|
136
|
+
* RecalcUniforms
|
|
137
|
+
*/
|
|
138
|
+
UpdateType[UpdateType["RecalcUniforms"] = 4096] = "RecalcUniforms";
|
|
139
|
+
/**
|
|
140
|
+
* Autosize update
|
|
141
|
+
*/
|
|
142
|
+
UpdateType[UpdateType["Autosize"] = 8192] = "Autosize";
|
|
142
143
|
/**
|
|
143
144
|
* None
|
|
144
145
|
*/
|
|
@@ -146,11 +147,7 @@ export var UpdateType;
|
|
|
146
147
|
/**
|
|
147
148
|
* All
|
|
148
149
|
*/
|
|
149
|
-
UpdateType[UpdateType["All"] =
|
|
150
|
-
/**
|
|
151
|
-
* RecalcUniforms
|
|
152
|
-
*/
|
|
153
|
-
UpdateType[UpdateType["RecalcUniforms"] = 16384] = "RecalcUniforms";
|
|
150
|
+
UpdateType[UpdateType["All"] = 16383] = "All";
|
|
154
151
|
})(UpdateType || (UpdateType = {}));
|
|
155
152
|
/**
|
|
156
153
|
* A visual Node in the Renderer scene graph.
|
|
@@ -165,11 +162,21 @@ export class CoreNode extends EventEmitter {
|
|
|
165
162
|
children = [];
|
|
166
163
|
_id = getNewId();
|
|
167
164
|
props;
|
|
165
|
+
isCoreNode = true;
|
|
166
|
+
// WebGL Render Op State
|
|
167
|
+
renderOpBufferIdx = 0;
|
|
168
|
+
numQuads = 0;
|
|
169
|
+
renderOpTextures = [];
|
|
168
170
|
hasShaderUpdater = false;
|
|
171
|
+
hasShaderTimeFn = false;
|
|
172
|
+
hasColorProps = false;
|
|
173
|
+
zIndexMin = 0;
|
|
174
|
+
zIndexMax = 0;
|
|
175
|
+
previousZIndex = -1;
|
|
176
|
+
zIndexSortList = [];
|
|
169
177
|
updateType = UpdateType.All;
|
|
170
178
|
childUpdateType = UpdateType.None;
|
|
171
179
|
globalTransform;
|
|
172
|
-
scaleRotateTransform;
|
|
173
180
|
localTransform;
|
|
174
181
|
sceneGlobalTransform;
|
|
175
182
|
renderCoords;
|
|
@@ -180,10 +187,12 @@ export class CoreNode extends EventEmitter {
|
|
|
180
187
|
clippingRect = {
|
|
181
188
|
x: 0,
|
|
182
189
|
y: 0,
|
|
183
|
-
|
|
184
|
-
|
|
190
|
+
w: 0,
|
|
191
|
+
h: 0,
|
|
185
192
|
valid: false,
|
|
186
193
|
};
|
|
194
|
+
textureCoords;
|
|
195
|
+
updateShaderUniforms = false;
|
|
187
196
|
isRenderable = false;
|
|
188
197
|
renderState = CoreNodeRenderState.Init;
|
|
189
198
|
worldAlpha = 1;
|
|
@@ -195,104 +204,165 @@ export class CoreNode extends EventEmitter {
|
|
|
195
204
|
hasRTTupdates = false;
|
|
196
205
|
parentHasRenderTexture = false;
|
|
197
206
|
rttParent = null;
|
|
207
|
+
/**
|
|
208
|
+
* only used when rtt = true
|
|
209
|
+
*/
|
|
210
|
+
framebufferDimensions = null;
|
|
211
|
+
/**Autosize properties */
|
|
212
|
+
autosizer = null;
|
|
213
|
+
parentAutosizer = null;
|
|
214
|
+
destroyed = false;
|
|
198
215
|
constructor(stage, props) {
|
|
199
216
|
super();
|
|
200
217
|
this.stage = stage;
|
|
201
|
-
this.props = {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
218
|
+
const p = (this.props = {});
|
|
219
|
+
// Initialize the renderOpTextures array with a capacity of 16 (typical max textures)
|
|
220
|
+
this.renderOpTextures = [];
|
|
221
|
+
//inital update type
|
|
222
|
+
let initialUpdateType = UpdateType.Local | UpdateType.RenderBounds | UpdateType.RenderState;
|
|
223
|
+
// Fast-path assign only known keys
|
|
224
|
+
p.x = props.x;
|
|
225
|
+
p.y = props.y;
|
|
226
|
+
p.w = props.w;
|
|
227
|
+
p.h = props.h;
|
|
228
|
+
p.alpha = props.alpha;
|
|
229
|
+
p.autosize = props.autosize;
|
|
230
|
+
p.clipping = props.clipping;
|
|
231
|
+
p.color = props.color;
|
|
232
|
+
p.colorTop = props.colorTop;
|
|
233
|
+
p.colorBottom = props.colorBottom;
|
|
234
|
+
p.colorLeft = props.colorLeft;
|
|
235
|
+
p.colorRight = props.colorRight;
|
|
236
|
+
p.colorTl = props.colorTl;
|
|
237
|
+
p.colorTr = props.colorTr;
|
|
238
|
+
p.colorBl = props.colorBl;
|
|
239
|
+
p.colorBr = props.colorBr;
|
|
240
|
+
//check if any color props are set for premultiplied color updates
|
|
241
|
+
if (props.color > 0 ||
|
|
242
|
+
props.colorTop > 0 ||
|
|
243
|
+
props.colorBottom > 0 ||
|
|
244
|
+
props.colorLeft > 0 ||
|
|
245
|
+
props.colorRight > 0 ||
|
|
246
|
+
props.colorTl > 0 ||
|
|
247
|
+
props.colorTr > 0 ||
|
|
248
|
+
props.colorBl > 0 ||
|
|
249
|
+
props.colorBr > 0) {
|
|
250
|
+
this.hasColorProps = true;
|
|
251
|
+
initialUpdateType |= UpdateType.PremultipliedColors;
|
|
252
|
+
}
|
|
253
|
+
p.scaleX = props.scaleX;
|
|
254
|
+
p.scaleY = props.scaleY;
|
|
255
|
+
p.rotation = props.rotation;
|
|
256
|
+
p.pivotX = props.pivotX;
|
|
257
|
+
p.pivotY = props.pivotY;
|
|
258
|
+
p.mountX = props.mountX;
|
|
259
|
+
p.mountY = props.mountY;
|
|
260
|
+
p.mount = props.mount;
|
|
261
|
+
p.pivot = props.pivot;
|
|
262
|
+
p.zIndex = props.zIndex;
|
|
263
|
+
p.textureOptions = props.textureOptions;
|
|
264
|
+
p.data = props.data;
|
|
265
|
+
p.imageType = props.imageType;
|
|
266
|
+
p.srcX = props.srcX;
|
|
267
|
+
p.srcY = props.srcY;
|
|
268
|
+
p.srcWidth = props.srcWidth;
|
|
269
|
+
p.srcHeight = props.srcHeight;
|
|
270
|
+
p.autosize = props.autosize;
|
|
271
|
+
p.parent = props.parent;
|
|
272
|
+
p.texture = null;
|
|
273
|
+
p.shader = null;
|
|
274
|
+
p.src = null;
|
|
275
|
+
p.rtt = false;
|
|
276
|
+
p.boundsMargin = null;
|
|
277
|
+
// Only set non-default values
|
|
278
|
+
if (props.zIndex !== 0) {
|
|
279
|
+
this.zIndex = props.zIndex;
|
|
280
|
+
}
|
|
281
|
+
if (props.parent !== null) {
|
|
282
|
+
props.parent.addChild(this);
|
|
283
|
+
}
|
|
209
284
|
// Assign props to instances
|
|
210
|
-
this.parent = props.parent;
|
|
211
285
|
this.texture = props.texture;
|
|
212
286
|
this.shader = props.shader;
|
|
213
287
|
this.src = props.src;
|
|
214
288
|
this.rtt = props.rtt;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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');
|
|
289
|
+
this.boundsMargin = props.boundsMargin;
|
|
290
|
+
this.interactive = props.interactive;
|
|
291
|
+
// Initialize autosize if enabled
|
|
292
|
+
if (p.autosize === true) {
|
|
293
|
+
this.autosizer = new Autosizer(this);
|
|
231
294
|
}
|
|
295
|
+
this.setUpdateType(initialUpdateType);
|
|
232
296
|
// if the default texture isn't loaded yet, wait for it to load
|
|
233
297
|
// this only happens when the node is created before the stage is ready
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
this.setUpdateType(UpdateType.IsRenderable);
|
|
238
|
-
});
|
|
298
|
+
const dt = this.stage.defaultTexture;
|
|
299
|
+
if (dt !== null && dt.state !== 'loaded') {
|
|
300
|
+
dt.once('loaded', () => this.setUpdateType(UpdateType.IsRenderable));
|
|
239
301
|
}
|
|
240
302
|
}
|
|
241
303
|
//#region Textures
|
|
242
304
|
loadTexture() {
|
|
243
|
-
|
|
244
|
-
|
|
305
|
+
if (this.props.texture === null) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
245
308
|
// If texture is already loaded / failed, trigger loaded event manually
|
|
246
309
|
// so that users get a consistent event experience.
|
|
247
310
|
// We do this in a microtask to allow listeners to be attached in the same
|
|
248
311
|
// 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
|
-
});
|
|
312
|
+
queueMicrotask(this.loadTextureTask);
|
|
279
313
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
314
|
+
/**
|
|
315
|
+
* Task for queueMicrotask to loadTexture
|
|
316
|
+
*
|
|
317
|
+
* @remarks
|
|
318
|
+
* This method is called in a microtask to release the texture.
|
|
319
|
+
*/
|
|
320
|
+
loadTextureTask = () => {
|
|
321
|
+
const texture = this.props.texture;
|
|
322
|
+
//it is possible that texture is null here if user sets the texture to null right after loadTexture call
|
|
323
|
+
if (texture === null) {
|
|
324
|
+
return;
|
|
286
325
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
326
|
+
if (this.textureOptions.preload === true) {
|
|
327
|
+
this.stage.txManager.loadTexture(texture);
|
|
328
|
+
}
|
|
329
|
+
texture.preventCleanup = this.props.textureOptions?.preventCleanup ?? false;
|
|
330
|
+
texture.on('loaded', this.onTextureLoaded);
|
|
331
|
+
texture.on('failed', this.onTextureFailed);
|
|
332
|
+
texture.on('freed', this.onTextureFreed);
|
|
333
|
+
// If the parent is a render texture, the initial texture status
|
|
334
|
+
// will be set to freed until the texture is processed by the
|
|
335
|
+
// Render RTT nodes. So we only need to listen fo changes and
|
|
336
|
+
// no need to check the texture.state until we restructure how
|
|
337
|
+
// textures are being processed.
|
|
338
|
+
if (this.parentHasRenderTexture) {
|
|
339
|
+
this.notifyParentRTTOfUpdate();
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
if (texture.state === 'loaded') {
|
|
343
|
+
this.onTextureLoaded(texture, texture.dimensions);
|
|
344
|
+
}
|
|
345
|
+
else if (texture.state === 'failed') {
|
|
346
|
+
this.onTextureFailed(texture, texture.error);
|
|
347
|
+
}
|
|
348
|
+
else if (texture.state === 'freed') {
|
|
349
|
+
this.onTextureFreed(texture);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
unloadTexture() {
|
|
353
|
+
if (this.texture === null) {
|
|
354
|
+
return;
|
|
292
355
|
}
|
|
356
|
+
const texture = this.texture;
|
|
357
|
+
texture.off('loaded', this.onTextureLoaded);
|
|
358
|
+
texture.off('failed', this.onTextureFailed);
|
|
359
|
+
texture.off('freed', this.onTextureFreed);
|
|
360
|
+
texture.setRenderableOwner(this._id, false);
|
|
293
361
|
}
|
|
294
362
|
onTextureLoaded = (_, dimensions) => {
|
|
295
|
-
this.
|
|
363
|
+
if (this.autosizer !== null) {
|
|
364
|
+
this.autosizer.update();
|
|
365
|
+
}
|
|
296
366
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
297
367
|
// Texture was loaded. In case the RAF loop has already stopped, we request
|
|
298
368
|
// a render to ensure the texture is rendered.
|
|
@@ -302,29 +372,44 @@ export class CoreNode extends EventEmitter {
|
|
|
302
372
|
this.notifyParentRTTOfUpdate();
|
|
303
373
|
}
|
|
304
374
|
// ignore 1x1 pixel textures
|
|
305
|
-
if (dimensions.
|
|
375
|
+
if (dimensions.w > 1 && dimensions.h > 1) {
|
|
306
376
|
this.emit('loaded', {
|
|
307
377
|
type: 'texture',
|
|
308
378
|
dimensions,
|
|
309
379
|
});
|
|
310
380
|
}
|
|
381
|
+
if (this.stage.calculateTextureCoord === true &&
|
|
382
|
+
this.props.textureOptions !== null) {
|
|
383
|
+
this.textureCoords = this.stage.renderer.getTextureCoords(this);
|
|
384
|
+
}
|
|
311
385
|
// Trigger a local update if the texture is loaded and the resizeMode is 'contain'
|
|
312
386
|
if (this.props.textureOptions?.resizeMode?.type === 'contain') {
|
|
313
387
|
this.setUpdateType(UpdateType.Local);
|
|
314
388
|
}
|
|
315
389
|
};
|
|
316
390
|
onTextureFailed = (_, error) => {
|
|
391
|
+
// immediately set isRenderable to false, so that we handle the error
|
|
392
|
+
// without waiting for the next frame loop
|
|
393
|
+
this.isRenderable = false;
|
|
394
|
+
this.updateTextureOwnership(false);
|
|
317
395
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
318
396
|
// If parent has a render texture, flag that we need to update
|
|
319
397
|
if (this.parentHasRenderTexture) {
|
|
320
398
|
this.notifyParentRTTOfUpdate();
|
|
321
399
|
}
|
|
322
|
-
this.
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
400
|
+
if (this.texture !== null &&
|
|
401
|
+
this.texture.retryCount > this.texture.maxRetryCount) {
|
|
402
|
+
this.emit('failed', {
|
|
403
|
+
type: 'texture',
|
|
404
|
+
error,
|
|
405
|
+
});
|
|
406
|
+
}
|
|
326
407
|
};
|
|
327
408
|
onTextureFreed = () => {
|
|
409
|
+
// immediately set isRenderable to false, so that we handle the error
|
|
410
|
+
// without waiting for the next frame loop
|
|
411
|
+
this.isRenderable = false;
|
|
412
|
+
this.updateTextureOwnership(false);
|
|
328
413
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
329
414
|
// If parent has a render texture, flag that we need to update
|
|
330
415
|
if (this.parentHasRenderTexture) {
|
|
@@ -348,95 +433,90 @@ export class CoreNode extends EventEmitter {
|
|
|
348
433
|
const parent = this.props.parent;
|
|
349
434
|
if (!parent)
|
|
350
435
|
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);
|
|
436
|
+
parent.setUpdateType(UpdateType.Children);
|
|
367
437
|
}
|
|
368
438
|
updateLocalTransform() {
|
|
369
|
-
const
|
|
370
|
-
const
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
const
|
|
439
|
+
const p = this.props;
|
|
440
|
+
const { x, y, w, h } = p;
|
|
441
|
+
const mountTranslateX = p.mountX * w;
|
|
442
|
+
const mountTranslateY = p.mountY * h;
|
|
443
|
+
if (p.rotation !== 0 || p.scaleX !== 1 || p.scaleY !== 1) {
|
|
444
|
+
const scaleRotate = Matrix3d.rotate(p.rotation).scale(p.scaleX, p.scaleY);
|
|
445
|
+
const pivotTranslateX = p.pivotX * w;
|
|
446
|
+
const pivotTranslateY = p.pivotY * h;
|
|
375
447
|
this.localTransform = Matrix3d.translate(x - mountTranslateX + pivotTranslateX, y - mountTranslateY + pivotTranslateY, this.localTransform)
|
|
376
|
-
.multiply(
|
|
448
|
+
.multiply(scaleRotate)
|
|
377
449
|
.translate(-pivotTranslateX, -pivotTranslateY);
|
|
378
450
|
}
|
|
379
451
|
else {
|
|
380
452
|
this.localTransform = Matrix3d.translate(x - mountTranslateX, y - mountTranslateY, this.localTransform);
|
|
381
453
|
}
|
|
382
454
|
// Handle 'contain' resize mode
|
|
383
|
-
const texture =
|
|
455
|
+
const texture = p.texture;
|
|
384
456
|
if (texture &&
|
|
385
457
|
texture.dimensions &&
|
|
386
|
-
|
|
458
|
+
p.textureOptions.resizeMode?.type === 'contain') {
|
|
387
459
|
let resizeModeScaleX = 1;
|
|
388
460
|
let resizeModeScaleY = 1;
|
|
389
461
|
let extraX = 0;
|
|
390
462
|
let extraY = 0;
|
|
391
|
-
const {
|
|
463
|
+
const { w: tw, h: th } = texture.dimensions;
|
|
392
464
|
const txAspectRatio = tw / th;
|
|
393
|
-
const nodeAspectRatio =
|
|
465
|
+
const nodeAspectRatio = w / h;
|
|
394
466
|
if (txAspectRatio > nodeAspectRatio) {
|
|
395
467
|
// Texture is wider than node
|
|
396
468
|
// Center the node vertically (shift down by extraY)
|
|
397
469
|
// Scale the node vertically to maintain original aspect ratio
|
|
398
|
-
const scaleX =
|
|
470
|
+
const scaleX = w / tw;
|
|
399
471
|
const scaledTxHeight = th * scaleX;
|
|
400
|
-
extraY = (
|
|
401
|
-
resizeModeScaleY = scaledTxHeight /
|
|
472
|
+
extraY = (h - scaledTxHeight) / 2;
|
|
473
|
+
resizeModeScaleY = scaledTxHeight / h;
|
|
402
474
|
}
|
|
403
475
|
else {
|
|
404
476
|
// Texture is taller than node (or equal)
|
|
405
477
|
// Center the node horizontally (shift right by extraX)
|
|
406
478
|
// Scale the node horizontally to maintain original aspect ratio
|
|
407
|
-
const scaleY =
|
|
479
|
+
const scaleY = h / th;
|
|
408
480
|
const scaledTxWidth = tw * scaleY;
|
|
409
|
-
extraX = (
|
|
410
|
-
resizeModeScaleX = scaledTxWidth /
|
|
481
|
+
extraX = (w - scaledTxWidth) / 2;
|
|
482
|
+
resizeModeScaleX = scaledTxWidth / w;
|
|
411
483
|
}
|
|
412
484
|
// Apply the extra translation and scale to the local transform
|
|
413
485
|
this.localTransform
|
|
414
486
|
.translate(extraX, extraY)
|
|
415
487
|
.scale(resizeModeScaleX, resizeModeScaleY);
|
|
416
488
|
}
|
|
417
|
-
this.setUpdateType(UpdateType.Global);
|
|
418
489
|
}
|
|
419
490
|
/**
|
|
420
491
|
* @todo: test for correct calculation flag
|
|
421
492
|
* @param delta
|
|
422
493
|
*/
|
|
423
494
|
update(delta, parentClippingRect) {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
495
|
+
const props = this.props;
|
|
496
|
+
const parent = props.parent;
|
|
497
|
+
const parentHasRenderTexture = this.parentHasRenderTexture;
|
|
498
|
+
const hasParent = props.parent !== null;
|
|
499
|
+
let newRenderState = null;
|
|
500
|
+
let updateType = this.updateType;
|
|
501
|
+
let childUpdateType = this.childUpdateType;
|
|
502
|
+
let updateParent = false;
|
|
503
|
+
//this needs to be handled before setting updateTypes are reset
|
|
504
|
+
if (updateType & UpdateType.Autosize && this.autosizer !== null) {
|
|
505
|
+
this.autosizer.update();
|
|
427
506
|
}
|
|
428
|
-
|
|
507
|
+
// reset update type
|
|
508
|
+
this.updateType = 0;
|
|
509
|
+
this.childUpdateType = 0;
|
|
510
|
+
if (updateType & UpdateType.Local) {
|
|
429
511
|
this.updateLocalTransform();
|
|
430
|
-
|
|
512
|
+
updateType |= UpdateType.Global;
|
|
513
|
+
updateParent = hasParent;
|
|
431
514
|
}
|
|
432
|
-
const parent = this.props.parent;
|
|
433
|
-
let renderState = null;
|
|
434
515
|
// Handle specific RTT updates at this node level
|
|
435
|
-
if (
|
|
516
|
+
if (updateType & UpdateType.RenderTexture && this.rtt === true) {
|
|
436
517
|
this.hasRTTupdates = true;
|
|
437
518
|
}
|
|
438
|
-
if (
|
|
439
|
-
assertTruthy(this.localTransform);
|
|
519
|
+
if (updateType & UpdateType.Global) {
|
|
440
520
|
if (this.parentHasRenderTexture === true && parent?.rtt === true) {
|
|
441
521
|
// we are at the start of the RTT chain, so we need to reset the globalTransform
|
|
442
522
|
// for correct RTT rendering
|
|
@@ -460,134 +540,140 @@ export class CoreNode extends EventEmitter {
|
|
|
460
540
|
}
|
|
461
541
|
this.calculateRenderCoords();
|
|
462
542
|
this.updateBoundingRect();
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
543
|
+
updateType |= UpdateType.RenderState | UpdateType.RecalcUniforms;
|
|
544
|
+
updateParent = hasParent;
|
|
545
|
+
//only propagate children updates if not autosizing
|
|
546
|
+
if ((updateType & UpdateType.Autosize) === 0) {
|
|
547
|
+
updateType |= UpdateType.Children;
|
|
548
|
+
childUpdateType |= UpdateType.Global;
|
|
549
|
+
}
|
|
467
550
|
if (this.clipping === true) {
|
|
468
|
-
|
|
469
|
-
|
|
551
|
+
updateType |= UpdateType.Clipping | UpdateType.RenderBounds;
|
|
552
|
+
updateParent = hasParent;
|
|
553
|
+
childUpdateType |= UpdateType.RenderBounds;
|
|
470
554
|
}
|
|
471
555
|
}
|
|
472
|
-
if (
|
|
556
|
+
if (updateType & UpdateType.RenderBounds) {
|
|
473
557
|
this.createRenderBounds();
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
if (
|
|
479
|
-
|
|
480
|
-
|
|
558
|
+
updateType |= UpdateType.RenderState | UpdateType.Children;
|
|
559
|
+
updateParent = hasParent;
|
|
560
|
+
childUpdateType |= UpdateType.RenderBounds;
|
|
561
|
+
}
|
|
562
|
+
if (updateType & UpdateType.RenderState) {
|
|
563
|
+
newRenderState = this.checkRenderBounds();
|
|
564
|
+
updateType |= UpdateType.IsRenderable;
|
|
565
|
+
updateParent = hasParent;
|
|
481
566
|
// if we're not going out of bounds, update the render state
|
|
482
567
|
// this is done so the update loop can finish before we mark a node
|
|
483
568
|
// as out of bounds
|
|
484
|
-
if (
|
|
485
|
-
this.updateRenderState(
|
|
569
|
+
if (newRenderState !== CoreNodeRenderState.OutOfBounds) {
|
|
570
|
+
this.updateRenderState(newRenderState);
|
|
486
571
|
}
|
|
487
572
|
}
|
|
488
|
-
if (
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
this.worldAlpha = this.props.alpha;
|
|
494
|
-
}
|
|
495
|
-
this.setUpdateType(UpdateType.Children |
|
|
573
|
+
if (updateType & UpdateType.WorldAlpha) {
|
|
574
|
+
this.worldAlpha = (parent?.worldAlpha ?? 1) * this.props.alpha;
|
|
575
|
+
updateType |=
|
|
496
576
|
UpdateType.PremultipliedColors |
|
|
497
|
-
|
|
498
|
-
|
|
577
|
+
UpdateType.Children |
|
|
578
|
+
UpdateType.IsRenderable;
|
|
579
|
+
updateParent = hasParent;
|
|
580
|
+
childUpdateType |= UpdateType.WorldAlpha;
|
|
499
581
|
}
|
|
500
|
-
if (
|
|
582
|
+
if (updateType & UpdateType.IsRenderable) {
|
|
501
583
|
this.updateIsRenderable();
|
|
502
584
|
}
|
|
503
|
-
|
|
585
|
+
// Handle autosize updates when children transforms change
|
|
586
|
+
if (updateType & UpdateType.Global &&
|
|
587
|
+
this.isRenderable === true &&
|
|
588
|
+
this.parentAutosizer !== null) {
|
|
589
|
+
this.parentAutosizer.patch(this.id);
|
|
590
|
+
}
|
|
591
|
+
if (updateType & UpdateType.Clipping) {
|
|
504
592
|
this.calculateClippingRect(parentClippingRect);
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}
|
|
509
|
-
if (
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
593
|
+
updateType |= UpdateType.Children;
|
|
594
|
+
updateParent = hasParent;
|
|
595
|
+
childUpdateType |= UpdateType.Clipping | UpdateType.RenderBounds;
|
|
596
|
+
}
|
|
597
|
+
if (updateType & UpdateType.PremultipliedColors) {
|
|
598
|
+
const alpha = this.worldAlpha;
|
|
599
|
+
const tl = props.colorTl;
|
|
600
|
+
const tr = props.colorTr;
|
|
601
|
+
const bl = props.colorBl;
|
|
602
|
+
const br = props.colorBr;
|
|
603
|
+
// Fast equality check (covers all 4 corners)
|
|
604
|
+
const same = tl === tr && tl === bl && tl === br;
|
|
605
|
+
const merged = mergeColorAlphaPremultiplied(tl, alpha, true);
|
|
606
|
+
this.premultipliedColorTl = merged;
|
|
607
|
+
if (same === true) {
|
|
515
608
|
this.premultipliedColorTr =
|
|
516
609
|
this.premultipliedColorBl =
|
|
517
610
|
this.premultipliedColorBr =
|
|
518
|
-
|
|
611
|
+
merged;
|
|
519
612
|
}
|
|
520
613
|
else {
|
|
521
|
-
this.premultipliedColorTr = mergeColorAlphaPremultiplied(
|
|
522
|
-
this.premultipliedColorBl = mergeColorAlphaPremultiplied(
|
|
523
|
-
this.premultipliedColorBr = mergeColorAlphaPremultiplied(
|
|
614
|
+
this.premultipliedColorTr = mergeColorAlphaPremultiplied(tr, alpha, true);
|
|
615
|
+
this.premultipliedColorBl = mergeColorAlphaPremultiplied(bl, alpha, true);
|
|
616
|
+
this.premultipliedColorBr = mergeColorAlphaPremultiplied(br, alpha, true);
|
|
524
617
|
}
|
|
525
618
|
}
|
|
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
|
|
619
|
+
if (this.renderState === CoreNodeRenderState.OutOfBounds) {
|
|
620
|
+
// Delay updating children until the node is in bounds
|
|
621
|
+
this.updateType = updateType;
|
|
622
|
+
this.childUpdateType = childUpdateType;
|
|
535
623
|
return;
|
|
536
624
|
}
|
|
537
|
-
if (
|
|
625
|
+
if (updateParent === true) {
|
|
626
|
+
parent.setUpdateType(UpdateType.Children);
|
|
627
|
+
}
|
|
628
|
+
if (updateType & UpdateType.RecalcUniforms &&
|
|
538
629
|
this.hasShaderUpdater === true) {
|
|
630
|
+
this.updateShaderUniforms = true;
|
|
631
|
+
}
|
|
632
|
+
if (this.isRenderable === true && this.updateShaderUniforms === true) {
|
|
633
|
+
this.updateShaderUniforms = false;
|
|
539
634
|
//this exists because the boolean hasShaderUpdater === true
|
|
540
635
|
this.shader.update();
|
|
541
636
|
}
|
|
542
|
-
if (
|
|
637
|
+
if (updateType & UpdateType.Children && this.children.length > 0) {
|
|
638
|
+
let childClippingRect = this.clippingRect;
|
|
639
|
+
if (this.rtt === true) {
|
|
640
|
+
childClippingRect = NO_CLIPPING_RECT;
|
|
641
|
+
}
|
|
543
642
|
for (let i = 0, length = this.children.length; i < length; i++) {
|
|
544
643
|
const child = this.children[i];
|
|
545
|
-
|
|
644
|
+
if (childUpdateType !== 0) {
|
|
645
|
+
child.setUpdateType(childUpdateType);
|
|
646
|
+
}
|
|
546
647
|
if (child.updateType === 0) {
|
|
547
648
|
continue;
|
|
548
649
|
}
|
|
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
650
|
child.update(delta, childClippingRect);
|
|
560
651
|
}
|
|
561
652
|
}
|
|
562
653
|
// If the node has an RTT parent and requires a texture re-render, inform the RTT parent
|
|
563
|
-
// if (this.parentHasRenderTexture &&
|
|
654
|
+
// if (this.parentHasRenderTexture && updateType & UpdateType.RenderTexture) {
|
|
564
655
|
// @TODO have a more scoped down updateType for RTT updates
|
|
565
|
-
if (
|
|
656
|
+
if (parentHasRenderTexture === true) {
|
|
566
657
|
this.notifyParentRTTOfUpdate();
|
|
567
658
|
}
|
|
568
|
-
//
|
|
569
|
-
|
|
570
|
-
if (this.updateType & UpdateType.ZIndexSortedChildren) {
|
|
659
|
+
//Resort children if needed
|
|
660
|
+
if (updateType & UpdateType.SortZIndexChildren) {
|
|
571
661
|
// reorder z-index
|
|
572
662
|
this.sortChildren();
|
|
573
663
|
}
|
|
574
664
|
// If we're out of bounds, apply the render state now
|
|
575
665
|
// this is done so nodes can finish their entire update loop before
|
|
576
666
|
// being marked as out of bounds
|
|
577
|
-
if (
|
|
578
|
-
this.updateRenderState(
|
|
667
|
+
if (newRenderState === CoreNodeRenderState.OutOfBounds) {
|
|
668
|
+
this.updateRenderState(newRenderState);
|
|
579
669
|
this.updateIsRenderable();
|
|
580
670
|
if (this.rtt === true &&
|
|
581
|
-
|
|
671
|
+
newRenderState === CoreNodeRenderState.OutOfBounds) {
|
|
582
672
|
// notify children that we are going out of bounds
|
|
583
673
|
// we have to do this now before we stop processing the render tree
|
|
584
|
-
this.notifyChildrenRTTOfUpdate(
|
|
585
|
-
// this.childUpdateType |= UpdateType.RenderState;
|
|
674
|
+
this.notifyChildrenRTTOfUpdate(newRenderState);
|
|
586
675
|
}
|
|
587
676
|
}
|
|
588
|
-
// reset update type
|
|
589
|
-
this.updateType = 0;
|
|
590
|
-
this.childUpdateType = 0;
|
|
591
677
|
}
|
|
592
678
|
findParentRTTNode() {
|
|
593
679
|
let rttNode = this.parent;
|
|
@@ -596,13 +682,6 @@ export class CoreNode extends EventEmitter {
|
|
|
596
682
|
}
|
|
597
683
|
return rttNode;
|
|
598
684
|
}
|
|
599
|
-
getRTTParentRenderState() {
|
|
600
|
-
const rttNode = this.rttParent || this.findParentRTTNode();
|
|
601
|
-
if (!rttNode) {
|
|
602
|
-
return null;
|
|
603
|
-
}
|
|
604
|
-
return rttNode.renderState;
|
|
605
|
-
}
|
|
606
685
|
notifyChildrenRTTOfUpdate(renderState) {
|
|
607
686
|
for (const child of this.children) {
|
|
608
687
|
// force child to update render state
|
|
@@ -628,9 +707,6 @@ export class CoreNode extends EventEmitter {
|
|
|
628
707
|
}
|
|
629
708
|
}
|
|
630
709
|
checkRenderBounds() {
|
|
631
|
-
assertTruthy(this.renderBound);
|
|
632
|
-
assertTruthy(this.strictBound);
|
|
633
|
-
assertTruthy(this.preloadBound);
|
|
634
710
|
if (boundInsideBound(this.renderBound, this.strictBound)) {
|
|
635
711
|
return CoreNodeRenderState.InViewport;
|
|
636
712
|
}
|
|
@@ -642,17 +718,16 @@ export class CoreNode extends EventEmitter {
|
|
|
642
718
|
return CoreNodeRenderState.InViewport;
|
|
643
719
|
}
|
|
644
720
|
// 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)) {
|
|
721
|
+
if (this.parent !== null && (this.props.w === 0 || this.props.h === 0)) {
|
|
647
722
|
return this.parent.renderState;
|
|
648
723
|
}
|
|
649
724
|
return CoreNodeRenderState.OutOfBounds;
|
|
650
725
|
}
|
|
651
726
|
updateBoundingRect() {
|
|
652
|
-
const transform = this.sceneGlobalTransform ||
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
727
|
+
const transform = (this.sceneGlobalTransform ||
|
|
728
|
+
this.globalTransform);
|
|
729
|
+
const renderCoords = (this.sceneRenderCoords ||
|
|
730
|
+
this.renderCoords);
|
|
656
731
|
if (transform.tb === 0 || transform.tc === 0) {
|
|
657
732
|
this.renderBound = createBound(renderCoords.x1, renderCoords.y1, renderCoords.x3, renderCoords.y3, this.renderBound);
|
|
658
733
|
}
|
|
@@ -662,7 +737,6 @@ export class CoreNode extends EventEmitter {
|
|
|
662
737
|
}
|
|
663
738
|
}
|
|
664
739
|
createRenderBounds() {
|
|
665
|
-
assertTruthy(this.stage);
|
|
666
740
|
if (this.parent !== null && this.parent.strictBound !== undefined) {
|
|
667
741
|
// we have a parent with a valid bound, copy it
|
|
668
742
|
const parentBound = this.parent.strictBound;
|
|
@@ -688,13 +762,13 @@ export class CoreNode extends EventEmitter {
|
|
|
688
762
|
return;
|
|
689
763
|
}
|
|
690
764
|
// clipping is enabled and we are in bounds create our own bounds
|
|
691
|
-
const { x, y,
|
|
765
|
+
const { x, y, w, h } = this.props;
|
|
692
766
|
// Pick the global transform if available, otherwise use the local transform
|
|
693
767
|
// global transform is only available if the node in an RTT chain
|
|
694
768
|
const { tx, ty } = this.sceneGlobalTransform || this.globalTransform || {};
|
|
695
769
|
const _x = tx ?? x;
|
|
696
770
|
const _y = ty ?? y;
|
|
697
|
-
this.strictBound = createBound(_x, _y, _x +
|
|
771
|
+
this.strictBound = createBound(_x, _y, _x + w, _y + h, this.strictBound);
|
|
698
772
|
this.preloadBound = createPreloadBounds(this.strictBound, this.boundsMargin);
|
|
699
773
|
}
|
|
700
774
|
updateRenderState(renderState) {
|
|
@@ -710,6 +784,17 @@ export class CoreNode extends EventEmitter {
|
|
|
710
784
|
current: renderState,
|
|
711
785
|
});
|
|
712
786
|
}
|
|
787
|
+
/**
|
|
788
|
+
* Checks if the node is renderable based on world alpha, dimensions and out of bounds status.
|
|
789
|
+
*/
|
|
790
|
+
checkBasicRenderability() {
|
|
791
|
+
if (this.worldAlpha === 0 || this.isOutOfBounds() === true) {
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
else {
|
|
795
|
+
return true;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
713
798
|
/**
|
|
714
799
|
* Updates the `isRenderable` property based on various conditions.
|
|
715
800
|
*/
|
|
@@ -723,11 +808,22 @@ export class CoreNode extends EventEmitter {
|
|
|
723
808
|
return;
|
|
724
809
|
}
|
|
725
810
|
if (this.texture !== null) {
|
|
811
|
+
// preemptive check for failed textures this will mark the current node as non-renderable
|
|
812
|
+
// and will prevent further checks until the texture is reloaded or retry is reset on the texture
|
|
813
|
+
if (this.texture.retryCount > this.texture.maxRetryCount) {
|
|
814
|
+
// texture has failed to load, we cannot render
|
|
815
|
+
this.updateTextureOwnership(false);
|
|
816
|
+
this.setRenderable(false);
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
726
819
|
needsTextureOwnership = true;
|
|
727
820
|
// we're only renderable if the texture state is loaded
|
|
728
821
|
newIsRenderable = this.texture.state === 'loaded';
|
|
729
822
|
}
|
|
730
|
-
else if (
|
|
823
|
+
else if (
|
|
824
|
+
// check shader
|
|
825
|
+
(this.props.shader !== null || this.hasColorProps === true) &&
|
|
826
|
+
// check dimensions
|
|
731
827
|
this.hasDimensions() === true) {
|
|
732
828
|
// This mean we have dimensions and a color set, so we can render a ColorTexture
|
|
733
829
|
if (this.stage.defaultTexture &&
|
|
@@ -738,29 +834,26 @@ export class CoreNode extends EventEmitter {
|
|
|
738
834
|
this.updateTextureOwnership(needsTextureOwnership);
|
|
739
835
|
this.setRenderable(newIsRenderable);
|
|
740
836
|
}
|
|
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
837
|
/**
|
|
753
838
|
* Sets the renderable state and triggers changes if necessary.
|
|
754
839
|
* @param isRenderable - The new renderable state
|
|
755
840
|
*/
|
|
756
841
|
setRenderable(isRenderable) {
|
|
842
|
+
const previousIsRenderable = this.isRenderable;
|
|
757
843
|
this.isRenderable = isRenderable;
|
|
844
|
+
// Emit event if renderable status has changed
|
|
845
|
+
if (previousIsRenderable !== isRenderable) {
|
|
846
|
+
this.emit('renderable', {
|
|
847
|
+
type: 'renderable',
|
|
848
|
+
isRenderable,
|
|
849
|
+
});
|
|
850
|
+
}
|
|
758
851
|
}
|
|
759
852
|
/**
|
|
760
853
|
* Changes the renderable state of the node.
|
|
761
854
|
*/
|
|
762
855
|
updateTextureOwnership(isRenderable) {
|
|
763
|
-
this.texture?.setRenderableOwner(this, isRenderable);
|
|
856
|
+
this.texture?.setRenderableOwner(this._id, isRenderable);
|
|
764
857
|
}
|
|
765
858
|
/**
|
|
766
859
|
* Checks if the node is out of the viewport bounds.
|
|
@@ -772,33 +865,17 @@ export class CoreNode extends EventEmitter {
|
|
|
772
865
|
* Checks if the node has dimensions (width/height)
|
|
773
866
|
*/
|
|
774
867
|
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;
|
|
868
|
+
return this.props.w !== 0 && this.props.h !== 0;
|
|
793
869
|
}
|
|
794
870
|
calculateRenderCoords() {
|
|
795
|
-
const {
|
|
796
|
-
const
|
|
871
|
+
const { w, h } = this.props;
|
|
872
|
+
const g = this.globalTransform;
|
|
873
|
+
const tx = g.tx, ty = g.ty, ta = g.ta, tb = g.tb, tc = g.tc, td = g.td;
|
|
797
874
|
if (tb === 0 && tc === 0) {
|
|
798
875
|
const minX = tx;
|
|
799
|
-
const maxX = tx +
|
|
876
|
+
const maxX = tx + w * ta;
|
|
800
877
|
const minY = ty;
|
|
801
|
-
const maxY = ty +
|
|
878
|
+
const maxY = ty + h * td;
|
|
802
879
|
this.renderCoords = RenderCoords.translate(
|
|
803
880
|
//top-left
|
|
804
881
|
minX, minY,
|
|
@@ -814,11 +891,11 @@ export class CoreNode extends EventEmitter {
|
|
|
814
891
|
//top-left
|
|
815
892
|
tx, ty,
|
|
816
893
|
//top-right
|
|
817
|
-
tx +
|
|
894
|
+
tx + w * ta, ty + w * tc,
|
|
818
895
|
//bottom-right
|
|
819
|
-
tx +
|
|
896
|
+
tx + w * ta + h * tb, ty + w * tc + h * td,
|
|
820
897
|
//bottom-left
|
|
821
|
-
tx +
|
|
898
|
+
tx + h * tb, ty + h * td, this.renderCoords);
|
|
822
899
|
}
|
|
823
900
|
if (this.sceneGlobalTransform === undefined) {
|
|
824
901
|
return;
|
|
@@ -826,9 +903,9 @@ export class CoreNode extends EventEmitter {
|
|
|
826
903
|
const { tx: stx, ty: sty, ta: sta, tb: stb, tc: stc, td: std, } = this.sceneGlobalTransform;
|
|
827
904
|
if (stb === 0 && stc === 0) {
|
|
828
905
|
const minX = stx;
|
|
829
|
-
const maxX = stx +
|
|
906
|
+
const maxX = stx + w * sta;
|
|
830
907
|
const minY = sty;
|
|
831
|
-
const maxY = sty +
|
|
908
|
+
const maxY = sty + h * std;
|
|
832
909
|
this.sceneRenderCoords = RenderCoords.translate(
|
|
833
910
|
//top-left
|
|
834
911
|
minX, minY,
|
|
@@ -844,11 +921,11 @@ export class CoreNode extends EventEmitter {
|
|
|
844
921
|
//top-left
|
|
845
922
|
stx, sty,
|
|
846
923
|
//top-right
|
|
847
|
-
stx +
|
|
924
|
+
stx + w * sta, sty + w * stc,
|
|
848
925
|
//bottom-right
|
|
849
|
-
stx +
|
|
926
|
+
stx + w * sta + h * stb, sty + w * stc + h * std,
|
|
850
927
|
//bottom-left
|
|
851
|
-
stx +
|
|
928
|
+
stx + h * stb, sty + h * std, this.sceneRenderCoords);
|
|
852
929
|
}
|
|
853
930
|
}
|
|
854
931
|
/**
|
|
@@ -860,15 +937,14 @@ export class CoreNode extends EventEmitter {
|
|
|
860
937
|
* Finally, the node's parentClippingRect and clippingRect properties are updated.
|
|
861
938
|
*/
|
|
862
939
|
calculateClippingRect(parentClippingRect) {
|
|
863
|
-
assertTruthy(this.globalTransform);
|
|
864
940
|
const { clippingRect, props, globalTransform: gt } = this;
|
|
865
941
|
const { clipping } = props;
|
|
866
942
|
const isRotated = gt.tb !== 0 || gt.tc !== 0;
|
|
867
943
|
if (clipping === true && isRotated === false) {
|
|
868
944
|
clippingRect.x = gt.tx;
|
|
869
945
|
clippingRect.y = gt.ty;
|
|
870
|
-
clippingRect.
|
|
871
|
-
clippingRect.
|
|
946
|
+
clippingRect.w = this.props.w * gt.ta;
|
|
947
|
+
clippingRect.h = this.props.h * gt.td;
|
|
872
948
|
clippingRect.valid = true;
|
|
873
949
|
}
|
|
874
950
|
else {
|
|
@@ -884,83 +960,153 @@ export class CoreNode extends EventEmitter {
|
|
|
884
960
|
clippingRect.valid = true;
|
|
885
961
|
}
|
|
886
962
|
}
|
|
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
963
|
/**
|
|
898
964
|
* Destroy the node and cleanup all resources
|
|
899
965
|
*/
|
|
900
966
|
destroy() {
|
|
967
|
+
if (this.destroyed === true) {
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
this.removeAllListeners();
|
|
971
|
+
this.destroyed = true;
|
|
901
972
|
this.unloadTexture();
|
|
902
|
-
this.clippingRect.valid = false;
|
|
903
973
|
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;
|
|
974
|
+
if (this.hasShaderTimeFn === true) {
|
|
975
|
+
this.stage.untrackTimedNode(this);
|
|
976
|
+
}
|
|
977
|
+
// Kill children
|
|
913
978
|
while (this.children.length > 0) {
|
|
914
|
-
this.children[0]
|
|
979
|
+
this.children[0].destroy();
|
|
915
980
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
981
|
+
const parent = this.parent;
|
|
982
|
+
if (parent !== null) {
|
|
983
|
+
parent.removeChild(this);
|
|
984
|
+
}
|
|
985
|
+
this.props.parent = null;
|
|
986
|
+
this.props.texture = null;
|
|
987
|
+
if (this.rtt === true) {
|
|
919
988
|
this.stage.renderer.removeRTTNode(this);
|
|
920
989
|
}
|
|
921
|
-
this.
|
|
990
|
+
this.stage.requestRender();
|
|
922
991
|
}
|
|
923
992
|
renderQuads(renderer) {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
if (!renderer.renderToTextureActive) {
|
|
993
|
+
if (this.parentHasRenderTexture === true) {
|
|
994
|
+
const rtt = renderer.renderToTextureActive;
|
|
995
|
+
if (rtt === false || this.parentRenderTexture !== renderer.activeRttNode)
|
|
928
996
|
return;
|
|
997
|
+
}
|
|
998
|
+
const texture = this.props.texture || this.stage.defaultTexture;
|
|
999
|
+
// There is a race condition where the texture can be null
|
|
1000
|
+
// with RTT nodes. Adding this defensively to avoid errors.
|
|
1001
|
+
// Also check if we have a valid texture or default texture to render
|
|
1002
|
+
if (!texture || texture.state !== 'loaded') {
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
renderer.addQuad(this);
|
|
1006
|
+
}
|
|
1007
|
+
get quadBufferCollection() {
|
|
1008
|
+
return this.stage.renderer.quadBufferCollection;
|
|
1009
|
+
}
|
|
1010
|
+
get time() {
|
|
1011
|
+
if (this.hasShaderTimeFn === true) {
|
|
1012
|
+
return this.getTimerValue();
|
|
1013
|
+
}
|
|
1014
|
+
return 0;
|
|
1015
|
+
}
|
|
1016
|
+
getTimerValue() {
|
|
1017
|
+
if (typeof this.shader.time === 'function') {
|
|
1018
|
+
return this.shader.time(this.stage);
|
|
1019
|
+
}
|
|
1020
|
+
return this.stage.elapsedTime;
|
|
1021
|
+
}
|
|
1022
|
+
sortChildren() {
|
|
1023
|
+
const changedCount = this.zIndexSortList.length;
|
|
1024
|
+
if (changedCount === 0) {
|
|
1025
|
+
return;
|
|
1026
|
+
}
|
|
1027
|
+
const children = this.children;
|
|
1028
|
+
let min = Infinity;
|
|
1029
|
+
let max = -Infinity;
|
|
1030
|
+
// find min and max zIndex
|
|
1031
|
+
for (let i = 0; i < children.length; i++) {
|
|
1032
|
+
const zIndex = children[i].props.zIndex;
|
|
1033
|
+
if (zIndex < min) {
|
|
1034
|
+
min = zIndex;
|
|
929
1035
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
return;
|
|
1036
|
+
if (zIndex > max) {
|
|
1037
|
+
max = zIndex;
|
|
933
1038
|
}
|
|
934
1039
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1040
|
+
// update min and max zIndex
|
|
1041
|
+
this.zIndexMin = min;
|
|
1042
|
+
this.zIndexMax = max;
|
|
1043
|
+
// if min and max are the same, no need to sort
|
|
1044
|
+
if (min === max) {
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
const n = children.length;
|
|
1048
|
+
// decide whether to use incremental sort or bucket sort
|
|
1049
|
+
const useIncremental = changedCount <= 2 || changedCount < n * 0.05;
|
|
1050
|
+
// when changed count is less than 2 or 5% of total children, use incremental sort
|
|
1051
|
+
if (useIncremental === true) {
|
|
1052
|
+
incrementalRepositionByZIndex(this.zIndexSortList, children);
|
|
1053
|
+
}
|
|
1054
|
+
else {
|
|
1055
|
+
bucketSortByZIndex(children, min);
|
|
1056
|
+
}
|
|
1057
|
+
this.zIndexSortList.length = 0;
|
|
1058
|
+
this.zIndexSortList = [];
|
|
1059
|
+
}
|
|
1060
|
+
removeChild(node, targetParent = null) {
|
|
1061
|
+
if (targetParent === null) {
|
|
1062
|
+
if (this.props.rtt === true && this.parentHasRenderTexture === true) {
|
|
1063
|
+
node.clearRTTInheritance();
|
|
1064
|
+
}
|
|
1065
|
+
const autosizeTarget = this.autosizer || this.parentAutosizer;
|
|
1066
|
+
if (autosizeTarget !== null) {
|
|
1067
|
+
autosizeTarget.detach(node);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
removeChild(node, this.children);
|
|
1071
|
+
}
|
|
1072
|
+
addChild(node, previousParent = null) {
|
|
1073
|
+
const inRttCluster = this.props.rtt === true || this.parentHasRenderTexture === true;
|
|
1074
|
+
const children = this.children;
|
|
1075
|
+
const min = this.zIndexMin;
|
|
1076
|
+
const max = this.zIndexMax;
|
|
1077
|
+
const zIndex = node.zIndex;
|
|
1078
|
+
const autosizeTarget = this.autosizer || this.parentAutosizer;
|
|
1079
|
+
let attachToAutosizer = autosizeTarget !== null;
|
|
1080
|
+
node.parentHasRenderTexture = inRttCluster;
|
|
1081
|
+
if (previousParent !== null) {
|
|
1082
|
+
const previousParentInRttCluster = previousParent.props.rtt === true ||
|
|
1083
|
+
previousParent.parentHasRenderTexture === true;
|
|
1084
|
+
if (inRttCluster === false && previousParentInRttCluster === true) {
|
|
1085
|
+
// update child RTT status
|
|
1086
|
+
node.clearRTTInheritance();
|
|
1087
|
+
}
|
|
1088
|
+
const previousAutosizer = node.autosizer || node.parentAutosizer;
|
|
1089
|
+
if (previousAutosizer !== null) {
|
|
1090
|
+
if (autosizeTarget === null ||
|
|
1091
|
+
previousAutosizer.id !== autosizeTarget.id) {
|
|
1092
|
+
previousAutosizer.detach(node);
|
|
1093
|
+
}
|
|
1094
|
+
attachToAutosizer = false;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
if (attachToAutosizer === true) {
|
|
1098
|
+
//if this is true, then the autosizer really exists
|
|
1099
|
+
autosizeTarget.attach(node);
|
|
1100
|
+
}
|
|
1101
|
+
if (inRttCluster === true) {
|
|
1102
|
+
node.markChildrenWithRTT(this);
|
|
1103
|
+
}
|
|
1104
|
+
children.push(node);
|
|
1105
|
+
if (min !== max || (zIndex !== min && zIndex !== max)) {
|
|
1106
|
+
this.zIndexSortList.push(node);
|
|
1107
|
+
this.setUpdateType(UpdateType.SortZIndexChildren);
|
|
1108
|
+
}
|
|
1109
|
+
this.setUpdateType(UpdateType.Children);
|
|
964
1110
|
}
|
|
965
1111
|
//#region Properties
|
|
966
1112
|
get id() {
|
|
@@ -983,12 +1129,12 @@ export class CoreNode extends EventEmitter {
|
|
|
983
1129
|
}
|
|
984
1130
|
get absX() {
|
|
985
1131
|
return (this.props.x +
|
|
986
|
-
-this.props.
|
|
1132
|
+
-this.props.w * this.props.mountX +
|
|
987
1133
|
(this.props.parent?.absX || this.props.parent?.globalTransform?.tx || 0));
|
|
988
1134
|
}
|
|
989
1135
|
get absY() {
|
|
990
1136
|
return (this.props.y +
|
|
991
|
-
-this.props.
|
|
1137
|
+
-this.props.h * this.props.mountY +
|
|
992
1138
|
(this.props.parent?.absY ?? 0));
|
|
993
1139
|
}
|
|
994
1140
|
get y() {
|
|
@@ -1000,36 +1146,46 @@ export class CoreNode extends EventEmitter {
|
|
|
1000
1146
|
this.setUpdateType(UpdateType.Local);
|
|
1001
1147
|
}
|
|
1002
1148
|
}
|
|
1003
|
-
get
|
|
1004
|
-
return this.props.
|
|
1149
|
+
get w() {
|
|
1150
|
+
return this.props.w;
|
|
1005
1151
|
}
|
|
1006
|
-
set
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1152
|
+
set w(value) {
|
|
1153
|
+
const props = this.props;
|
|
1154
|
+
if (props.w !== value) {
|
|
1155
|
+
props.w = value;
|
|
1156
|
+
let updateType = UpdateType.Local;
|
|
1157
|
+
if (props.texture !== null &&
|
|
1158
|
+
this.stage.calculateTextureCoord === true &&
|
|
1159
|
+
props.textureOptions !== null) {
|
|
1160
|
+
this.textureCoords = this.stage.renderer.getTextureCoords(this);
|
|
1161
|
+
}
|
|
1162
|
+
if (props.rtt === true) {
|
|
1163
|
+
this.framebufferDimensions.w = value;
|
|
1164
|
+
this.texture = this.stage.txManager.createTexture('RenderTexture', this.framebufferDimensions);
|
|
1165
|
+
updateType |= UpdateType.RenderTexture;
|
|
1016
1166
|
}
|
|
1167
|
+
this.setUpdateType(updateType);
|
|
1017
1168
|
}
|
|
1018
1169
|
}
|
|
1019
|
-
get
|
|
1020
|
-
return this.props.
|
|
1170
|
+
get h() {
|
|
1171
|
+
return this.props.h;
|
|
1021
1172
|
}
|
|
1022
|
-
set
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1173
|
+
set h(value) {
|
|
1174
|
+
const props = this.props;
|
|
1175
|
+
if (props.h !== value) {
|
|
1176
|
+
props.h = value;
|
|
1177
|
+
let updateType = UpdateType.Local;
|
|
1178
|
+
if (props.texture !== null &&
|
|
1179
|
+
this.stage.calculateTextureCoord === true &&
|
|
1180
|
+
props.textureOptions !== null) {
|
|
1181
|
+
this.textureCoords = this.stage.renderer.getTextureCoords(this);
|
|
1182
|
+
}
|
|
1183
|
+
if (props.rtt === true) {
|
|
1184
|
+
this.framebufferDimensions.h = value;
|
|
1185
|
+
this.texture = this.stage.txManager.createTexture('RenderTexture', this.framebufferDimensions);
|
|
1186
|
+
updateType |= UpdateType.RenderTexture;
|
|
1032
1187
|
}
|
|
1188
|
+
this.setUpdateType(updateType);
|
|
1033
1189
|
}
|
|
1034
1190
|
}
|
|
1035
1191
|
get scale() {
|
|
@@ -1049,7 +1205,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1049
1205
|
set scaleX(value) {
|
|
1050
1206
|
if (this.props.scaleX !== value) {
|
|
1051
1207
|
this.props.scaleX = value;
|
|
1052
|
-
this.setUpdateType(UpdateType.
|
|
1208
|
+
this.setUpdateType(UpdateType.Local);
|
|
1053
1209
|
}
|
|
1054
1210
|
}
|
|
1055
1211
|
get scaleY() {
|
|
@@ -1058,7 +1214,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1058
1214
|
set scaleY(value) {
|
|
1059
1215
|
if (this.props.scaleY !== value) {
|
|
1060
1216
|
this.props.scaleY = value;
|
|
1061
|
-
this.setUpdateType(UpdateType.
|
|
1217
|
+
this.setUpdateType(UpdateType.Local);
|
|
1062
1218
|
}
|
|
1063
1219
|
}
|
|
1064
1220
|
get mount() {
|
|
@@ -1125,7 +1281,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1125
1281
|
set rotation(value) {
|
|
1126
1282
|
if (this.props.rotation !== value) {
|
|
1127
1283
|
this.props.rotation = value;
|
|
1128
|
-
this.setUpdateType(UpdateType.
|
|
1284
|
+
this.setUpdateType(UpdateType.Local);
|
|
1129
1285
|
}
|
|
1130
1286
|
}
|
|
1131
1287
|
get alpha() {
|
|
@@ -1143,12 +1299,30 @@ export class CoreNode extends EventEmitter {
|
|
|
1143
1299
|
return this.props.autosize;
|
|
1144
1300
|
}
|
|
1145
1301
|
set autosize(value) {
|
|
1302
|
+
if (this.props.autosize === value) {
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1146
1305
|
this.props.autosize = value;
|
|
1306
|
+
if (value === true && this.autosizer === null) {
|
|
1307
|
+
this.autosizer = new Autosizer(this);
|
|
1308
|
+
}
|
|
1309
|
+
else {
|
|
1310
|
+
this.autosizer = null;
|
|
1311
|
+
}
|
|
1147
1312
|
}
|
|
1148
1313
|
get boundsMargin() {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1314
|
+
const props = this.props;
|
|
1315
|
+
if (props.boundsMargin !== null) {
|
|
1316
|
+
return props.boundsMargin;
|
|
1317
|
+
}
|
|
1318
|
+
const parent = this.parent;
|
|
1319
|
+
if (parent !== null) {
|
|
1320
|
+
const margin = parent.boundsMargin;
|
|
1321
|
+
if (margin !== undefined) {
|
|
1322
|
+
return margin;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
return this.stage.boundsMargin;
|
|
1152
1326
|
}
|
|
1153
1327
|
set boundsMargin(value) {
|
|
1154
1328
|
if (value === this.props.boundsMargin) {
|
|
@@ -1177,11 +1351,20 @@ export class CoreNode extends EventEmitter {
|
|
|
1177
1351
|
return this.props.color;
|
|
1178
1352
|
}
|
|
1179
1353
|
set color(value) {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1354
|
+
const p = this.props;
|
|
1355
|
+
if (p.color === value)
|
|
1356
|
+
return;
|
|
1357
|
+
p.color = value;
|
|
1358
|
+
const has = value > 0;
|
|
1359
|
+
this.hasColorProps = has;
|
|
1360
|
+
if (p.colorTop !== value)
|
|
1361
|
+
this.colorTop = value;
|
|
1362
|
+
if (p.colorBottom !== value)
|
|
1363
|
+
this.colorBottom = value;
|
|
1364
|
+
if (p.colorLeft !== value)
|
|
1365
|
+
this.colorLeft = value;
|
|
1366
|
+
if (p.colorRight !== value)
|
|
1367
|
+
this.colorRight = value;
|
|
1185
1368
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1186
1369
|
}
|
|
1187
1370
|
get colorTop() {
|
|
@@ -1193,6 +1376,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1193
1376
|
this.colorTr = value;
|
|
1194
1377
|
}
|
|
1195
1378
|
this.props.colorTop = value;
|
|
1379
|
+
this.hasColorProps = value > 0;
|
|
1196
1380
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1197
1381
|
}
|
|
1198
1382
|
get colorBottom() {
|
|
@@ -1204,6 +1388,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1204
1388
|
this.colorBr = value;
|
|
1205
1389
|
}
|
|
1206
1390
|
this.props.colorBottom = value;
|
|
1391
|
+
this.hasColorProps = value > 0;
|
|
1207
1392
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1208
1393
|
}
|
|
1209
1394
|
get colorLeft() {
|
|
@@ -1215,6 +1400,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1215
1400
|
this.colorBl = value;
|
|
1216
1401
|
}
|
|
1217
1402
|
this.props.colorLeft = value;
|
|
1403
|
+
this.hasColorProps = value > 0;
|
|
1218
1404
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1219
1405
|
}
|
|
1220
1406
|
get colorRight() {
|
|
@@ -1226,6 +1412,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1226
1412
|
this.colorBr = value;
|
|
1227
1413
|
}
|
|
1228
1414
|
this.props.colorRight = value;
|
|
1415
|
+
this.hasColorProps = value > 0;
|
|
1229
1416
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1230
1417
|
}
|
|
1231
1418
|
get colorTl() {
|
|
@@ -1233,6 +1420,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1233
1420
|
}
|
|
1234
1421
|
set colorTl(value) {
|
|
1235
1422
|
this.props.colorTl = value;
|
|
1423
|
+
this.hasColorProps = value > 0;
|
|
1236
1424
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1237
1425
|
}
|
|
1238
1426
|
get colorTr() {
|
|
@@ -1240,6 +1428,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1240
1428
|
}
|
|
1241
1429
|
set colorTr(value) {
|
|
1242
1430
|
this.props.colorTr = value;
|
|
1431
|
+
this.hasColorProps = value > 0;
|
|
1243
1432
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1244
1433
|
}
|
|
1245
1434
|
get colorBl() {
|
|
@@ -1247,6 +1436,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1247
1436
|
}
|
|
1248
1437
|
set colorBl(value) {
|
|
1249
1438
|
this.props.colorBl = value;
|
|
1439
|
+
this.hasColorProps = value > 0;
|
|
1250
1440
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1251
1441
|
}
|
|
1252
1442
|
get colorBr() {
|
|
@@ -1254,28 +1444,38 @@ export class CoreNode extends EventEmitter {
|
|
|
1254
1444
|
}
|
|
1255
1445
|
set colorBr(value) {
|
|
1256
1446
|
this.props.colorBr = value;
|
|
1447
|
+
this.hasColorProps = value > 0;
|
|
1257
1448
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1258
1449
|
}
|
|
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
1450
|
get zIndex() {
|
|
1272
1451
|
return this.props.zIndex;
|
|
1273
1452
|
}
|
|
1274
1453
|
set zIndex(value) {
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1454
|
+
let sanitizedValue = value;
|
|
1455
|
+
if (isNaN(sanitizedValue) || Number.isFinite(sanitizedValue) === false) {
|
|
1456
|
+
console.warn(`zIndex was set to an invalid value: ${value}, defaulting to 0`);
|
|
1457
|
+
sanitizedValue = 0;
|
|
1458
|
+
}
|
|
1459
|
+
//Clamp to safe integer range
|
|
1460
|
+
if (sanitizedValue > Number.MAX_SAFE_INTEGER) {
|
|
1461
|
+
sanitizedValue = 1000;
|
|
1462
|
+
}
|
|
1463
|
+
else if (sanitizedValue < Number.MIN_SAFE_INTEGER) {
|
|
1464
|
+
sanitizedValue = -1000;
|
|
1465
|
+
}
|
|
1466
|
+
if (this.props.zIndex === sanitizedValue) {
|
|
1467
|
+
return;
|
|
1468
|
+
}
|
|
1469
|
+
this.previousZIndex = this.props.zIndex;
|
|
1470
|
+
this.props.zIndex = sanitizedValue;
|
|
1471
|
+
const parent = this.parent;
|
|
1472
|
+
if (parent !== null) {
|
|
1473
|
+
const min = parent.zIndexMin;
|
|
1474
|
+
const max = parent.zIndexMax;
|
|
1475
|
+
if (min !== max || sanitizedValue < min || sanitizedValue > max) {
|
|
1476
|
+
parent.zIndexSortList.push(this);
|
|
1477
|
+
parent.setUpdateType(UpdateType.SortZIndexChildren);
|
|
1478
|
+
}
|
|
1279
1479
|
}
|
|
1280
1480
|
}
|
|
1281
1481
|
get parent() {
|
|
@@ -1288,34 +1488,13 @@ export class CoreNode extends EventEmitter {
|
|
|
1288
1488
|
}
|
|
1289
1489
|
this.props.parent = newParent;
|
|
1290
1490
|
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
|
-
}
|
|
1491
|
+
oldParent.removeChild(this, newParent);
|
|
1306
1492
|
}
|
|
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');
|
|
1493
|
+
if (newParent !== null) {
|
|
1494
|
+
newParent.addChild(this, oldParent);
|
|
1317
1495
|
}
|
|
1318
|
-
this
|
|
1496
|
+
//since this node has a new parent, recalc global and render bounds
|
|
1497
|
+
this.setUpdateType(UpdateType.Global | UpdateType.RenderBounds);
|
|
1319
1498
|
}
|
|
1320
1499
|
get rtt() {
|
|
1321
1500
|
return this.props.rtt;
|
|
@@ -1338,10 +1517,11 @@ export class CoreNode extends EventEmitter {
|
|
|
1338
1517
|
}
|
|
1339
1518
|
}
|
|
1340
1519
|
initRenderTexture() {
|
|
1341
|
-
this.
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
}
|
|
1520
|
+
this.framebufferDimensions = {
|
|
1521
|
+
w: this.props.w,
|
|
1522
|
+
h: this.props.h,
|
|
1523
|
+
};
|
|
1524
|
+
this.texture = this.stage.txManager.createTexture('RenderTexture', this.framebufferDimensions);
|
|
1345
1525
|
this.stage.renderer.renderToTexture(this);
|
|
1346
1526
|
}
|
|
1347
1527
|
cleanupRenderTexture() {
|
|
@@ -1349,6 +1529,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1349
1529
|
this.clearRTTInheritance();
|
|
1350
1530
|
this.hasRTTupdates = false;
|
|
1351
1531
|
this.texture = null;
|
|
1532
|
+
this.framebufferDimensions = null;
|
|
1352
1533
|
}
|
|
1353
1534
|
markChildrenWithRTT(node = null) {
|
|
1354
1535
|
const parent = node || this;
|
|
@@ -1397,10 +1578,17 @@ export class CoreNode extends EventEmitter {
|
|
|
1397
1578
|
}
|
|
1398
1579
|
if (shader.shaderKey !== 'default') {
|
|
1399
1580
|
this.hasShaderUpdater = shader.update !== undefined;
|
|
1581
|
+
this.hasShaderTimeFn = shader.time !== undefined;
|
|
1400
1582
|
shader.attachNode(this);
|
|
1401
1583
|
}
|
|
1584
|
+
if (this.hasShaderTimeFn === true) {
|
|
1585
|
+
this.stage.trackTimedNode(this);
|
|
1586
|
+
}
|
|
1587
|
+
else {
|
|
1588
|
+
this.stage.untrackTimedNode(this);
|
|
1589
|
+
}
|
|
1402
1590
|
this.props.shader = shader;
|
|
1403
|
-
this.setUpdateType(UpdateType.IsRenderable);
|
|
1591
|
+
this.setUpdateType(UpdateType.IsRenderable | UpdateType.RecalcUniforms);
|
|
1404
1592
|
}
|
|
1405
1593
|
get src() {
|
|
1406
1594
|
return this.props.src;
|
|
@@ -1416,8 +1604,8 @@ export class CoreNode extends EventEmitter {
|
|
|
1416
1604
|
}
|
|
1417
1605
|
this.texture = this.stage.txManager.createTexture('ImageTexture', {
|
|
1418
1606
|
src: imageUrl,
|
|
1419
|
-
|
|
1420
|
-
|
|
1607
|
+
w: this.props.w,
|
|
1608
|
+
h: this.props.h,
|
|
1421
1609
|
type: this.props.imageType,
|
|
1422
1610
|
sx: this.props.srcX,
|
|
1423
1611
|
sy: this.props.srcY,
|
|
@@ -1459,16 +1647,14 @@ export class CoreNode extends EventEmitter {
|
|
|
1459
1647
|
this.props.srcY = value;
|
|
1460
1648
|
}
|
|
1461
1649
|
/**
|
|
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.
|
|
1650
|
+
* Returns the framebuffer dimensions of the RTT parent
|
|
1466
1651
|
*/
|
|
1467
|
-
get
|
|
1468
|
-
if (this.
|
|
1469
|
-
return this.
|
|
1652
|
+
get parentFramebufferDimensions() {
|
|
1653
|
+
if (this.rttParent !== null) {
|
|
1654
|
+
return this.rttParent.framebufferDimensions;
|
|
1470
1655
|
}
|
|
1471
|
-
|
|
1656
|
+
this.rttParent = this.findParentRTTNode();
|
|
1657
|
+
return this.rttParent ? this.rttParent.framebufferDimensions : null;
|
|
1472
1658
|
}
|
|
1473
1659
|
/**
|
|
1474
1660
|
* Returns the parent render texture node if it exists.
|
|
@@ -1492,32 +1678,44 @@ export class CoreNode extends EventEmitter {
|
|
|
1492
1678
|
}
|
|
1493
1679
|
const oldTexture = this.props.texture;
|
|
1494
1680
|
if (oldTexture) {
|
|
1495
|
-
oldTexture.setRenderableOwner(this, false);
|
|
1496
1681
|
this.unloadTexture();
|
|
1682
|
+
if (this.autosizer !== null && value === null) {
|
|
1683
|
+
this.autosizer.setMode(AutosizeMode.Children); // Set to children size mode
|
|
1684
|
+
}
|
|
1497
1685
|
}
|
|
1686
|
+
this.textureCoords = undefined;
|
|
1498
1687
|
this.props.texture = value;
|
|
1499
1688
|
if (value !== null) {
|
|
1500
|
-
|
|
1689
|
+
if (this.autosizer !== null) {
|
|
1690
|
+
this.autosizer.setMode(AutosizeMode.Texture); // Set to texture size mode
|
|
1691
|
+
}
|
|
1692
|
+
value.setRenderableOwner(this._id, this.isRenderable);
|
|
1501
1693
|
this.loadTexture();
|
|
1502
1694
|
}
|
|
1503
1695
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
1504
1696
|
}
|
|
1505
1697
|
set textureOptions(value) {
|
|
1506
1698
|
this.props.textureOptions = value;
|
|
1699
|
+
if (this.stage.calculateTextureCoord === true && value !== null) {
|
|
1700
|
+
this.textureCoords = this.stage.renderer.getTextureCoords(this);
|
|
1701
|
+
}
|
|
1507
1702
|
}
|
|
1508
1703
|
get textureOptions() {
|
|
1509
1704
|
return this.props.textureOptions;
|
|
1510
1705
|
}
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
return;
|
|
1706
|
+
set interactive(value) {
|
|
1707
|
+
this.props.interactive = value;
|
|
1708
|
+
// Update Stage's interactive Set
|
|
1709
|
+
if (value === true) {
|
|
1710
|
+
this.stage.interactiveNodes.add(this);
|
|
1517
1711
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
this.
|
|
1712
|
+
}
|
|
1713
|
+
get interactive() {
|
|
1714
|
+
return this.props.interactive;
|
|
1715
|
+
}
|
|
1716
|
+
setRTTUpdates(type) {
|
|
1717
|
+
this.hasRTTupdates = true;
|
|
1718
|
+
this.parent?.setRTTUpdates(type);
|
|
1521
1719
|
}
|
|
1522
1720
|
animate(props, settings) {
|
|
1523
1721
|
const animation = new CoreAnimation(this, props, settings);
|
|
@@ -1527,5 +1725,55 @@ export class CoreNode extends EventEmitter {
|
|
|
1527
1725
|
flush() {
|
|
1528
1726
|
// no-op
|
|
1529
1727
|
}
|
|
1728
|
+
/**
|
|
1729
|
+
* Add a texture to the current RenderOp.
|
|
1730
|
+
*
|
|
1731
|
+
* @param texture
|
|
1732
|
+
* @returns Assigned Texture Index of the texture in the render op
|
|
1733
|
+
*/
|
|
1734
|
+
addTexture(texture) {
|
|
1735
|
+
const textures = this.renderOpTextures;
|
|
1736
|
+
const length = textures.length;
|
|
1737
|
+
for (let i = 0; i < length; i++) {
|
|
1738
|
+
if (textures[i] === texture) {
|
|
1739
|
+
return i;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
if (length >= 1) {
|
|
1743
|
+
return 0xffffffff;
|
|
1744
|
+
}
|
|
1745
|
+
textures.push(texture);
|
|
1746
|
+
return length;
|
|
1747
|
+
}
|
|
1748
|
+
draw(renderer) {
|
|
1749
|
+
const { glw, options, stage } = renderer;
|
|
1750
|
+
const shader = this.props.shader;
|
|
1751
|
+
stage.shManager.useShader(shader.program);
|
|
1752
|
+
shader.program.bindRenderOp(this);
|
|
1753
|
+
// Clipping
|
|
1754
|
+
if (this.clippingRect.valid === true) {
|
|
1755
|
+
const pixelRatio = this.parentHasRenderTexture ? 1 : stage.pixelRatio;
|
|
1756
|
+
const clipX = Math.round(this.clippingRect.x * pixelRatio);
|
|
1757
|
+
const clipWidth = Math.round(this.clippingRect.w * pixelRatio);
|
|
1758
|
+
const clipHeight = Math.round(this.clippingRect.h * pixelRatio);
|
|
1759
|
+
let clipY = Math.round(options.canvas.height - clipHeight - this.clippingRect.y * pixelRatio);
|
|
1760
|
+
// if parent has render texture, we need to adjust the scissor rect
|
|
1761
|
+
// to be relative to the parent's framebuffer
|
|
1762
|
+
if (this.parentHasRenderTexture) {
|
|
1763
|
+
const parentFramebufferDimensions = this.parentFramebufferDimensions;
|
|
1764
|
+
clipY =
|
|
1765
|
+
parentFramebufferDimensions !== null
|
|
1766
|
+
? parentFramebufferDimensions.h - this.props.h
|
|
1767
|
+
: 0;
|
|
1768
|
+
}
|
|
1769
|
+
glw.setScissorTest(true);
|
|
1770
|
+
glw.scissor(clipX, clipY, clipWidth, clipHeight);
|
|
1771
|
+
}
|
|
1772
|
+
else {
|
|
1773
|
+
glw.setScissorTest(false);
|
|
1774
|
+
}
|
|
1775
|
+
const quadIdx = (this.renderOpBufferIdx / 32) * 6 * 2;
|
|
1776
|
+
glw.drawElements(glw.TRIANGLES, 6 * this.numQuads, glw.UNSIGNED_SHORT, quadIdx);
|
|
1777
|
+
}
|
|
1530
1778
|
}
|
|
1531
1779
|
//# sourceMappingURL=CoreNode.js.map
|