@lightningtv/renderer 3.0.0-beta1 → 3.2.4
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/NOTICE +4 -0
- package/README.md +22 -28
- package/dist/exports/canvas-shaders.js +0 -16
- package/dist/exports/canvas-shaders.js.map +1 -1
- package/dist/exports/canvas.d.ts +1 -1
- package/dist/exports/canvas.js +1 -19
- package/dist/exports/canvas.js.map +1 -1
- package/dist/exports/index.d.ts +2 -5
- package/dist/exports/index.js +1 -23
- package/dist/exports/index.js.map +1 -1
- package/dist/exports/inspector.js +0 -18
- package/dist/exports/inspector.js.map +1 -1
- package/dist/exports/utils.d.ts +2 -1
- package/dist/exports/utils.js +2 -19
- package/dist/exports/utils.js.map +1 -1
- package/dist/exports/webgl-shaders.js +0 -16
- package/dist/exports/webgl-shaders.js.map +1 -1
- package/dist/exports/webgl.d.ts +2 -1
- package/dist/exports/webgl.js +2 -19
- package/dist/exports/webgl.js.map +1 -1
- package/dist/src/common/CommonTypes.d.ts +15 -3
- package/dist/src/common/CommonTypes.js +0 -18
- package/dist/src/common/CommonTypes.js.map +1 -1
- package/dist/src/common/EventEmitter.js +0 -18
- package/dist/src/common/EventEmitter.js.map +1 -1
- package/dist/src/common/IEventEmitter.js +0 -16
- package/dist/src/common/IEventEmitter.js.map +1 -1
- package/dist/src/core/Autosizer.d.ts +35 -0
- package/dist/src/core/Autosizer.js +178 -0
- package/dist/src/core/Autosizer.js.map +1 -0
- package/dist/src/core/CoreNode.d.ts +139 -101
- package/dist/src/core/CoreNode.js +813 -528
- package/dist/src/core/CoreNode.js.map +1 -1
- package/dist/src/core/CoreShaderManager.d.ts +3 -3
- package/dist/src/core/CoreShaderManager.js +0 -18
- package/dist/src/core/CoreShaderManager.js.map +1 -1
- package/dist/src/core/CoreTextNode.d.ts +75 -87
- package/dist/src/core/CoreTextNode.js +380 -258
- package/dist/src/core/CoreTextNode.js.map +1 -1
- package/dist/src/core/CoreTextureManager.d.ts +25 -14
- package/dist/src/core/CoreTextureManager.js +83 -140
- package/dist/src/core/CoreTextureManager.js.map +1 -1
- package/dist/src/core/Stage.d.ts +102 -36
- package/dist/src/core/Stage.js +424 -191
- 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 +114 -134
- package/dist/src/core/TextureMemoryManager.js.map +1 -1
- package/dist/src/core/animations/AnimationManager.js +0 -18
- package/dist/src/core/animations/AnimationManager.js.map +1 -1
- package/dist/src/core/animations/CoreAnimation.d.ts +3 -3
- package/dist/src/core/animations/CoreAnimation.js +8 -24
- 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 -22
- package/dist/src/core/animations/CoreAnimationController.js.map +1 -1
- package/dist/src/core/lib/ContextSpy.js +0 -18
- package/dist/src/core/lib/ContextSpy.js.map +1 -1
- package/dist/src/core/lib/ImageWorker.d.ts +2 -2
- package/dist/src/core/lib/ImageWorker.js +33 -31
- package/dist/src/core/lib/ImageWorker.js.map +1 -1
- package/dist/src/core/lib/Matrix3d.d.ts +1 -0
- package/dist/src/core/lib/Matrix3d.js +7 -19
- package/dist/src/core/lib/Matrix3d.js.map +1 -1
- package/dist/src/core/lib/RenderCoords.d.ts +9 -10
- package/dist/src/core/lib/RenderCoords.js +27 -55
- package/dist/src/core/lib/RenderCoords.js.map +1 -1
- package/dist/src/core/lib/WebGlContextWrapper.d.ts +78 -3
- package/dist/src/core/lib/WebGlContextWrapper.js +150 -25
- 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 +82 -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/{renderers/canvas/internal/ColorUtils.js → lib/colorParser.js} +1 -19
- 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 -85
- package/dist/src/core/lib/textureCompression.js.map +1 -1
- package/dist/src/core/lib/textureSvg.js +0 -18
- package/dist/src/core/lib/textureSvg.js.map +1 -1
- package/dist/src/core/lib/utils.d.ts +8 -1
- package/dist/src/core/lib/utils.js +44 -20
- 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/platforms/Platform.d.ts +42 -0
- package/dist/src/core/platforms/Platform.js +4 -0
- 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 +90 -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 +0 -18
- package/dist/src/core/renderers/CoreContextTexture.js.map +1 -1
- package/dist/src/core/renderers/CoreRenderOp.js +0 -18
- package/dist/src/core/renderers/CoreRenderOp.js.map +1 -1
- package/dist/src/core/renderers/CoreRenderer.d.ts +15 -3
- package/dist/src/core/renderers/CoreRenderer.js +1 -18
- package/dist/src/core/renderers/CoreRenderer.js.map +1 -1
- package/dist/src/core/renderers/CoreShaderNode.d.ts +13 -3
- package/dist/src/core/renderers/CoreShaderNode.js +25 -2
- package/dist/src/core/renderers/CoreShaderNode.js.map +1 -1
- package/dist/src/core/renderers/CoreShaderProgram.js +0 -18
- package/dist/src/core/renderers/CoreShaderProgram.js.map +1 -1
- package/dist/src/core/renderers/canvas/CanvasRenderer.d.ts +4 -5
- package/dist/src/core/renderers/canvas/CanvasRenderer.js +89 -83
- package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +1 -1
- package/dist/src/core/renderers/canvas/CanvasShaderNode.js +3 -21
- 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 +18 -31
- package/dist/src/core/renderers/canvas/CanvasTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/BatchRenderOp.d.ts +25 -0
- package/dist/src/core/renderers/webgl/BatchRenderOp.js +60 -0
- package/dist/src/core/renderers/webgl/BatchRenderOp.js.map +1 -0
- package/dist/src/core/renderers/webgl/SdfRenderOp.d.ts +33 -0
- package/dist/src/core/renderers/webgl/SdfRenderOp.js +80 -0
- package/dist/src/core/renderers/webgl/SdfRenderOp.js.map +1 -0
- package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.d.ts +2 -0
- package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js +14 -24
- 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 -23
- 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 -70
- package/dist/src/core/renderers/webgl/WebGlCtxTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlRenderer.d.ts +34 -20
- package/dist/src/core/renderers/webgl/WebGlRenderer.js +319 -195
- package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlShaderNode.d.ts +2 -3
- 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 +99 -48
- package/dist/src/core/renderers/webgl/WebGlShaderProgram.js.map +1 -1
- package/dist/src/core/renderers/webgl/internal/BufferCollection.d.ts +1 -0
- package/dist/src/core/renderers/webgl/internal/BufferCollection.js +12 -21
- package/dist/src/core/renderers/webgl/internal/BufferCollection.js.map +1 -1
- package/dist/src/core/renderers/webgl/internal/RendererUtils.js +0 -18
- package/dist/src/core/renderers/webgl/internal/RendererUtils.js.map +1 -1
- package/dist/src/core/renderers/webgl/internal/ShaderUtils.js +0 -18
- package/dist/src/core/renderers/webgl/internal/ShaderUtils.js.map +1 -1
- package/dist/src/core/renderers/webgl/internal/WebGlUtils.js +0 -18
- package/dist/src/core/renderers/webgl/internal/WebGlUtils.js.map +1 -1
- package/dist/src/core/shaders/canvas/Border.d.ts +8 -2
- package/dist/src/core/shaders/canvas/Border.js +67 -41
- package/dist/src/core/shaders/canvas/Border.js.map +1 -1
- package/dist/src/core/shaders/canvas/HolePunch.js +3 -19
- package/dist/src/core/shaders/canvas/HolePunch.js.map +1 -1
- package/dist/src/core/shaders/canvas/LinearGradient.js +7 -21
- package/dist/src/core/shaders/canvas/LinearGradient.js.map +1 -1
- package/dist/src/core/shaders/canvas/RadialGradient.js +14 -28
- package/dist/src/core/shaders/canvas/RadialGradient.js.map +1 -1
- package/dist/src/core/shaders/canvas/Rounded.js +1 -17
- 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 +44 -22
- 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 +47 -25
- package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js.map +1 -1
- package/dist/src/core/shaders/canvas/RoundedWithShadow.js +9 -21
- package/dist/src/core/shaders/canvas/RoundedWithShadow.js.map +1 -1
- package/dist/src/core/shaders/canvas/Shadow.js +0 -16
- 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 -34
- 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 -27
- 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 -19
- package/dist/src/core/shaders/templates/HolePunchTemplate.js.map +1 -1
- package/dist/src/core/shaders/templates/LinearGradientTemplate.js +0 -16
- package/dist/src/core/shaders/templates/LinearGradientTemplate.js.map +1 -1
- package/dist/src/core/shaders/templates/RadialGradientTemplate.d.ts +8 -6
- package/dist/src/core/shaders/templates/RadialGradientTemplate.js +2 -18
- package/dist/src/core/shaders/templates/RadialGradientTemplate.js.map +1 -1
- package/dist/src/core/shaders/templates/RoundedTemplate.js +1 -17
- 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/RoundedWithBorderAndShadowTemplate.js +0 -16
- package/dist/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.js.map +1 -1
- package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.d.ts +4 -2
- package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.js +3 -17
- package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.js.map +1 -1
- package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.d.ts +1 -1
- package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.js +0 -16
- package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.js.map +1 -1
- package/dist/src/core/shaders/templates/ShadowTemplate.d.ts +1 -1
- package/dist/src/core/shaders/templates/ShadowTemplate.js +0 -16
- package/dist/src/core/shaders/templates/ShadowTemplate.js.map +1 -1
- package/dist/src/core/shaders/{templates/shaderUtils.d.ts → utils.d.ts} +1 -1
- package/dist/src/core/shaders/utils.js +25 -0
- package/dist/src/core/shaders/utils.js.map +1 -0
- package/dist/src/core/shaders/webgl/Border.js +118 -51
- package/dist/src/core/shaders/webgl/Border.js.map +1 -1
- package/dist/src/core/shaders/webgl/Default.js +6 -41
- package/dist/src/core/shaders/webgl/Default.js.map +1 -1
- package/dist/src/core/shaders/webgl/HolePunch.js +4 -19
- package/dist/src/core/shaders/webgl/HolePunch.js.map +1 -1
- package/dist/src/core/shaders/webgl/LinearGradient.js +73 -34
- package/dist/src/core/shaders/webgl/LinearGradient.js.map +1 -1
- package/dist/src/core/shaders/webgl/RadialGradient.js +56 -48
- package/dist/src/core/shaders/webgl/RadialGradient.js.map +1 -1
- package/dist/src/core/shaders/webgl/Rounded.js +25 -23
- package/dist/src/core/shaders/webgl/Rounded.js.map +1 -1
- package/dist/src/core/shaders/webgl/RoundedWithBorder.js +160 -55
- package/dist/src/core/shaders/webgl/RoundedWithBorder.js.map +1 -1
- package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +168 -58
- package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js.map +1 -1
- package/dist/src/core/shaders/webgl/RoundedWithShadow.js +73 -34
- 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 +8 -36
- package/dist/src/core/shaders/webgl/SdfShader.js.map +1 -1
- package/dist/src/core/shaders/webgl/Shadow.js +39 -34
- 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 +206 -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 +139 -0
- package/dist/src/core/text-rendering/CanvasTextRenderer.js.map +1 -0
- package/dist/src/core/text-rendering/SdfFontHandler.d.ts +167 -0
- package/dist/src/core/text-rendering/SdfFontHandler.js +371 -0
- package/dist/src/core/text-rendering/SdfFontHandler.js.map +1 -0
- package/dist/src/core/text-rendering/SdfTextRenderer.d.ts +18 -0
- package/dist/src/core/text-rendering/SdfTextRenderer.js +301 -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 +384 -0
- package/dist/src/core/text-rendering/TextRenderer.js +2 -0
- package/dist/src/core/text-rendering/TextRenderer.js.map +1 -0
- package/dist/src/core/text-rendering/Utils.d.ts +30 -0
- package/dist/src/core/text-rendering/Utils.js +66 -0
- package/dist/src/core/text-rendering/Utils.js.map +1 -0
- package/dist/src/core/textures/ColorTexture.d.ts +1 -1
- package/dist/src/core/textures/ColorTexture.js +3 -22
- package/dist/src/core/textures/ColorTexture.js.map +1 -1
- package/dist/src/core/textures/ImageTexture.d.ts +13 -6
- package/dist/src/core/textures/ImageTexture.js +57 -66
- 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 -26
- 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 -30
- 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 -55
- package/dist/src/core/textures/SubTexture.js.map +1 -1
- package/dist/src/core/textures/Texture.d.ts +90 -12
- package/dist/src/core/textures/Texture.js +160 -35
- 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 -19
- package/dist/src/core/utils.js.map +1 -1
- package/dist/src/main-api/INode.js.map +1 -1
- package/dist/src/main-api/Inspector.d.ts +135 -2
- package/dist/src/main-api/Inspector.js +507 -30
- package/dist/src/main-api/Inspector.js.map +1 -1
- package/dist/src/main-api/Renderer.d.ts +294 -81
- package/dist/src/main-api/Renderer.js +225 -96
- package/dist/src/main-api/Renderer.js.map +1 -1
- package/dist/src/utils.d.ts +19 -6
- package/dist/src/utils.js +32 -27
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/exports/canvas-shaders.ts +0 -17
- package/exports/canvas.ts +1 -19
- package/exports/index.ts +6 -27
- package/exports/inspector.ts +0 -19
- package/exports/utils.ts +7 -19
- package/exports/webgl-shaders.ts +0 -16
- package/exports/webgl.ts +3 -20
- package/package.json +23 -22
- package/src/common/CommonTypes.ts +20 -22
- package/src/common/EventEmitter.ts +0 -19
- package/src/common/IAnimationController.ts +0 -18
- package/src/common/IEventEmitter.ts +0 -17
- package/src/core/Autosizer.ts +205 -0
- package/src/core/CoreNode.test.ts +376 -45
- package/src/core/CoreNode.ts +1017 -656
- package/src/core/CoreShaderManager.ts +3 -21
- package/src/core/CoreTextNode.ts +457 -314
- package/src/core/CoreTextureManager.ts +123 -168
- package/src/core/Stage.ts +526 -236
- package/src/core/TextureError.ts +46 -0
- package/src/core/TextureMemoryManager.ts +150 -167
- package/src/core/animations/AnimationManager.ts +0 -19
- package/src/core/animations/CoreAnimation.ts +15 -32
- package/src/core/animations/CoreAnimationController.ts +13 -23
- package/src/core/lib/ContextSpy.ts +0 -19
- package/src/core/lib/ImageWorker.ts +45 -32
- package/src/core/lib/Matrix3d.ts +7 -20
- package/src/core/lib/RenderCoords.ts +36 -67
- package/src/core/lib/WebGlContextWrapper.ts +196 -72
- package/src/core/lib/collectionUtils.ts +99 -0
- package/src/core/lib/colorCache.ts +20 -0
- package/src/core/{renderers/canvas/internal/ColorUtils.ts → lib/colorParser.ts} +2 -21
- package/src/core/lib/textureCompression.ts +433 -93
- package/src/core/lib/textureSvg.ts +0 -19
- package/src/core/lib/utils.ts +58 -19
- package/src/core/lib/validateImageBitmap.ts +17 -6
- package/src/core/platforms/Platform.ts +64 -0
- package/src/core/platforms/web/WebPlatform.ts +132 -0
- package/src/core/renderers/CoreContextTexture.ts +2 -20
- package/src/core/renderers/CoreRenderOp.ts +0 -19
- package/src/core/renderers/CoreRenderer.ts +16 -23
- package/src/core/renderers/CoreShaderNode.ts +37 -6
- package/src/core/renderers/CoreShaderProgram.ts +0 -19
- package/src/core/renderers/canvas/CanvasRenderer.ts +108 -137
- package/src/core/renderers/canvas/CanvasShaderNode.ts +3 -23
- package/src/core/renderers/canvas/CanvasTexture.ts +25 -37
- package/src/core/renderers/webgl/SdfRenderOp.ts +88 -0
- package/src/core/renderers/webgl/WebGlCtxRenderTexture.ts +18 -34
- package/src/core/renderers/webgl/WebGlCtxSubTexture.ts +50 -24
- package/src/core/renderers/webgl/WebGlCtxTexture.ts +134 -103
- package/src/core/renderers/webgl/WebGlRenderer.ts +368 -233
- package/src/core/renderers/webgl/WebGlShaderNode.ts +4 -7
- package/src/core/renderers/webgl/WebGlShaderProgram.ts +122 -76
- package/src/core/renderers/webgl/internal/BufferCollection.ts +15 -23
- package/src/core/renderers/webgl/internal/RendererUtils.ts +0 -19
- package/src/core/renderers/webgl/internal/ShaderUtils.ts +0 -19
- package/src/core/renderers/webgl/internal/WebGlUtils.ts +0 -19
- package/src/core/shaders/canvas/Border.ts +91 -50
- package/src/core/shaders/canvas/HolePunch.ts +4 -28
- package/src/core/shaders/canvas/LinearGradient.ts +10 -25
- package/src/core/shaders/canvas/RadialGradient.ts +23 -54
- package/src/core/shaders/canvas/Rounded.ts +2 -19
- package/src/core/shaders/canvas/RoundedWithBorder.ts +72 -35
- package/src/core/shaders/canvas/RoundedWithBorderAndShadow.ts +77 -47
- package/src/core/shaders/canvas/RoundedWithShadow.ts +21 -34
- package/src/core/shaders/canvas/Shadow.ts +0 -17
- package/src/core/shaders/canvas/utils/render.ts +45 -53
- package/src/core/shaders/templates/BorderTemplate.ts +42 -29
- package/src/core/shaders/templates/HolePunchTemplate.ts +5 -22
- package/src/core/shaders/templates/LinearGradientTemplate.ts +0 -17
- package/src/core/shaders/templates/RadialGradientTemplate.ts +10 -25
- package/src/core/shaders/templates/RoundedTemplate.ts +1 -18
- package/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.ts +1 -18
- package/src/core/shaders/templates/RoundedWithBorderTemplate.ts +7 -19
- package/src/core/shaders/templates/RoundedWithShadowTemplate.ts +1 -18
- package/src/core/shaders/templates/ShadowTemplate.ts +1 -18
- package/src/core/shaders/utils.ts +30 -0
- package/src/core/shaders/webgl/Border.ts +118 -55
- package/src/core/shaders/webgl/Default.ts +6 -43
- package/src/core/shaders/webgl/HolePunch.ts +4 -24
- package/src/core/shaders/webgl/LinearGradient.ts +73 -35
- package/src/core/shaders/webgl/RadialGradient.ts +58 -51
- package/src/core/shaders/webgl/Rounded.ts +25 -45
- package/src/core/shaders/webgl/RoundedWithBorder.ts +161 -63
- package/src/core/shaders/webgl/RoundedWithBorderAndShadow.ts +169 -68
- package/src/core/shaders/webgl/RoundedWithShadow.ts +73 -39
- package/src/core/shaders/webgl/SdfShader.ts +8 -41
- package/src/core/shaders/webgl/Shadow.ts +39 -35
- package/src/core/text-rendering/CanvasFontHandler.ts +285 -0
- package/src/core/text-rendering/CanvasTextRenderer.ts +236 -0
- package/src/core/text-rendering/SdfFontHandler.ts +566 -0
- package/src/core/text-rendering/SdfTextRenderer.ts +406 -0
- package/src/core/text-rendering/TextLayoutEngine.ts +672 -0
- package/src/core/text-rendering/TextRenderer.ts +426 -0
- package/src/core/text-rendering/Utils.ts +80 -0
- package/src/core/text-rendering/tests/TextLayoutEngine.test.ts +434 -0
- package/src/core/textures/ColorTexture.ts +7 -24
- package/src/core/textures/ImageTexture.ts +110 -92
- package/src/core/textures/NoiseTexture.ts +14 -31
- package/src/core/textures/RenderTexture.ts +18 -35
- package/src/core/textures/SubTexture.ts +25 -65
- package/src/core/textures/Texture.ts +214 -46
- package/src/core/utils.ts +9 -26
- package/src/main-api/INode.ts +0 -18
- package/src/main-api/Inspector.ts +794 -38
- package/src/main-api/Renderer.ts +519 -159
- package/src/utils.ts +64 -29
- package/dist/src/core/platform.d.ts +0 -10
- package/dist/src/core/platform.js +0 -56
- package/dist/src/core/platform.js.map +0 -1
- package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.d.ts +0 -1
- package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.js +0 -217
- package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.js.map +0 -1
- package/dist/src/core/renderers/canvas/internal/ColorUtils.js.map +0 -1
- package/dist/src/core/renderers/webgl/WebGlRenderOp.d.ts +0 -36
- package/dist/src/core/renderers/webgl/WebGlRenderOp.js +0 -107
- package/dist/src/core/renderers/webgl/WebGlRenderOp.js.map +0 -1
- package/dist/src/core/shaders/templates/shaderUtils.js +0 -41
- package/dist/src/core/shaders/templates/shaderUtils.js.map +0 -1
- package/dist/src/core/shaders/webgl/DefaultBatched.d.ts +0 -2
- package/dist/src/core/shaders/webgl/DefaultBatched.js +0 -104
- package/dist/src/core/shaders/webgl/DefaultBatched.js.map +0 -1
- package/dist/src/core/text-rendering/TextRenderingUtils.d.ts +0 -12
- package/dist/src/core/text-rendering/TextRenderingUtils.js +0 -14
- package/dist/src/core/text-rendering/TextRenderingUtils.js.map +0 -1
- package/dist/src/core/text-rendering/TextTextureRendererUtils.d.ts +0 -72
- package/dist/src/core/text-rendering/TextTextureRendererUtils.js +0 -217
- package/dist/src/core/text-rendering/TextTextureRendererUtils.js.map +0 -1
- package/dist/src/core/text-rendering/TrFontManager.d.ts +0 -26
- package/dist/src/core/text-rendering/TrFontManager.js +0 -131
- package/dist/src/core/text-rendering/TrFontManager.js.map +0 -1
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.d.ts +0 -39
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js +0 -125
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js.map +0 -1
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.d.ts +0 -103
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.js +0 -21
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.js.map +0 -1
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.d.ts +0 -62
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.js +0 -88
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.js.map +0 -1
- package/dist/src/core/text-rendering/font-face-types/TrFontFace.d.ts +0 -118
- package/dist/src/core/text-rendering/font-face-types/TrFontFace.js +0 -63
- package/dist/src/core/text-rendering/font-face-types/TrFontFace.js.map +0 -1
- package/dist/src/core/text-rendering/font-face-types/WebTrFontFace.d.ts +0 -14
- package/dist/src/core/text-rendering/font-face-types/WebTrFontFace.js +0 -66
- package/dist/src/core/text-rendering/font-face-types/WebTrFontFace.js.map +0 -1
- package/dist/src/core/text-rendering/font-face-types/utils.d.ts +0 -1
- package/dist/src/core/text-rendering/font-face-types/utils.js +0 -38
- package/dist/src/core/text-rendering/font-face-types/utils.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.d.ts +0 -59
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js +0 -397
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.d.ts +0 -126
- package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.js +0 -551
- package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.d.ts +0 -91
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js +0 -611
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.d.ts +0 -12
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.js +0 -61
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.d.ts +0 -33
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.js +0 -52
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.d.ts +0 -13
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.js +0 -32
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.d.ts +0 -23
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.js +0 -84
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.d.ts +0 -4
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.js +0 -34
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.d.ts +0 -20
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js +0 -308
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.d.ts +0 -10
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.js +0 -40
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/setRenderWindow.d.ts +0 -26
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/setRenderWindow.js +0 -70
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/setRenderWindow.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/util.d.ts +0 -16
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/util.js +0 -39
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/util.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/TextRenderer.d.ts +0 -370
- package/dist/src/core/text-rendering/renderers/TextRenderer.js +0 -178
- package/dist/src/core/text-rendering/renderers/TextRenderer.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 -145
- package/src/core/shaders/templates/shaderUtils.ts +0 -47
- package/src/core/shaders/webgl/DefaultBatched.ts +0 -129
- 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 -841
- 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
- /package/dist/src/core/{renderers/canvas/internal/ColorUtils.d.ts → lib/colorParser.d.ts} +0 -0
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
-
* following copyright and licenses apply:
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
import { assertTruthy, getNewId, isProductionEnvironment, mergeColorAlphaPremultiplied, } from '../utils.js';
|
|
1
|
+
import { assertTruthy, getNewId, premultiplyColorABGR, USE_RTT, ENABLE_AUTOSIZE, EMIT_BOUNDS_EVENTS, } from '../utils.js';
|
|
20
2
|
import {} from './textures/Texture.js';
|
|
21
3
|
import { EventEmitter } from '../common/EventEmitter.js';
|
|
22
4
|
import { copyRect, intersectRect, createBound, boundInsideBound, boundLargeThanBound, createPreloadBounds, } from './lib/utils.js';
|
|
@@ -24,6 +6,8 @@ import { Matrix3d } from './lib/Matrix3d.js';
|
|
|
24
6
|
import { RenderCoords } from './lib/RenderCoords.js';
|
|
25
7
|
import { CoreAnimation } from './animations/CoreAnimation.js';
|
|
26
8
|
import { CoreAnimationController } from './animations/CoreAnimationController.js';
|
|
9
|
+
import { AutosizeMode, Autosizer } from './Autosizer.js';
|
|
10
|
+
import { removeChild } from './lib/collectionUtils.js';
|
|
27
11
|
export var CoreNodeRenderState;
|
|
28
12
|
(function (CoreNodeRenderState) {
|
|
29
13
|
CoreNodeRenderState[CoreNodeRenderState["Init"] = 0] = "Init";
|
|
@@ -31,6 +15,13 @@ export var CoreNodeRenderState;
|
|
|
31
15
|
CoreNodeRenderState[CoreNodeRenderState["InBounds"] = 4] = "InBounds";
|
|
32
16
|
CoreNodeRenderState[CoreNodeRenderState["InViewport"] = 8] = "InViewport";
|
|
33
17
|
})(CoreNodeRenderState || (CoreNodeRenderState = {}));
|
|
18
|
+
const NO_CLIPPING_RECT = {
|
|
19
|
+
x: 0,
|
|
20
|
+
y: 0,
|
|
21
|
+
width: 0,
|
|
22
|
+
height: 0,
|
|
23
|
+
valid: false,
|
|
24
|
+
};
|
|
34
25
|
const CoreNodeRenderStateMap = new Map();
|
|
35
26
|
CoreNodeRenderStateMap.set(CoreNodeRenderState.Init, 'init');
|
|
36
27
|
CoreNodeRenderStateMap.set(CoreNodeRenderState.OutOfBounds, 'outOfBounds');
|
|
@@ -43,31 +34,23 @@ export var UpdateType;
|
|
|
43
34
|
*/
|
|
44
35
|
UpdateType[UpdateType["Children"] = 1] = "Children";
|
|
45
36
|
/**
|
|
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)
|
|
37
|
+
* localTransform
|
|
55
38
|
*
|
|
56
39
|
* @remarks
|
|
57
40
|
* CoreNode Properties Updated:
|
|
58
41
|
* - `localTransform`
|
|
59
42
|
*/
|
|
60
|
-
UpdateType[UpdateType["Local"] =
|
|
43
|
+
UpdateType[UpdateType["Local"] = 2] = "Local";
|
|
61
44
|
/**
|
|
62
|
-
*
|
|
45
|
+
* globalTransform
|
|
63
46
|
*
|
|
64
|
-
* @remarks
|
|
47
|
+
* * @remarks
|
|
65
48
|
* CoreNode Properties Updated:
|
|
66
49
|
* - `globalTransform`
|
|
50
|
+
* - `renderBounds`
|
|
67
51
|
* - `renderCoords`
|
|
68
|
-
* - `renderBound`
|
|
69
52
|
*/
|
|
70
|
-
UpdateType[UpdateType["Global"] =
|
|
53
|
+
UpdateType[UpdateType["Global"] = 4] = "Global";
|
|
71
54
|
/**
|
|
72
55
|
* Clipping rect update
|
|
73
56
|
*
|
|
@@ -75,23 +58,15 @@ export var UpdateType;
|
|
|
75
58
|
* CoreNode Properties Updated:
|
|
76
59
|
* - `clippingRect`
|
|
77
60
|
*/
|
|
78
|
-
UpdateType[UpdateType["Clipping"] =
|
|
79
|
-
/**
|
|
80
|
-
* Calculated ZIndex update
|
|
81
|
-
*
|
|
82
|
-
* @remarks
|
|
83
|
-
* CoreNode Properties Updated:
|
|
84
|
-
* - `calcZIndex`
|
|
85
|
-
*/
|
|
86
|
-
UpdateType[UpdateType["CalculatedZIndex"] = 32] = "CalculatedZIndex";
|
|
61
|
+
UpdateType[UpdateType["Clipping"] = 8] = "Clipping";
|
|
87
62
|
/**
|
|
88
|
-
* Z-Index
|
|
63
|
+
* Sort Z-Index Children update
|
|
89
64
|
*
|
|
90
65
|
* @remarks
|
|
91
66
|
* CoreNode Properties Updated:
|
|
92
67
|
* - `children` (sorts children by their `calcZIndex`)
|
|
93
68
|
*/
|
|
94
|
-
UpdateType[UpdateType["
|
|
69
|
+
UpdateType[UpdateType["SortZIndexChildren"] = 16] = "SortZIndexChildren";
|
|
95
70
|
/**
|
|
96
71
|
* Premultiplied Colors update
|
|
97
72
|
*
|
|
@@ -102,7 +77,7 @@ export var UpdateType;
|
|
|
102
77
|
* - `premultipliedColorBl`
|
|
103
78
|
* - `premultipliedColorBr`
|
|
104
79
|
*/
|
|
105
|
-
UpdateType[UpdateType["PremultipliedColors"] =
|
|
80
|
+
UpdateType[UpdateType["PremultipliedColors"] = 32] = "PremultipliedColors";
|
|
106
81
|
/**
|
|
107
82
|
* World Alpha update
|
|
108
83
|
*
|
|
@@ -110,7 +85,7 @@ export var UpdateType;
|
|
|
110
85
|
* CoreNode Properties Updated:
|
|
111
86
|
* - `worldAlpha` = `parent.worldAlpha` * `alpha`
|
|
112
87
|
*/
|
|
113
|
-
UpdateType[UpdateType["WorldAlpha"] =
|
|
88
|
+
UpdateType[UpdateType["WorldAlpha"] = 64] = "WorldAlpha";
|
|
114
89
|
/**
|
|
115
90
|
* Render State update
|
|
116
91
|
*
|
|
@@ -118,7 +93,7 @@ export var UpdateType;
|
|
|
118
93
|
* CoreNode Properties Updated:
|
|
119
94
|
* - `renderState`
|
|
120
95
|
*/
|
|
121
|
-
UpdateType[UpdateType["RenderState"] =
|
|
96
|
+
UpdateType[UpdateType["RenderState"] = 128] = "RenderState";
|
|
122
97
|
/**
|
|
123
98
|
* Is Renderable update
|
|
124
99
|
*
|
|
@@ -126,19 +101,27 @@ export var UpdateType;
|
|
|
126
101
|
* CoreNode Properties Updated:
|
|
127
102
|
* - `isRenderable`
|
|
128
103
|
*/
|
|
129
|
-
UpdateType[UpdateType["IsRenderable"] =
|
|
104
|
+
UpdateType[UpdateType["IsRenderable"] = 256] = "IsRenderable";
|
|
130
105
|
/**
|
|
131
106
|
* Render Texture update
|
|
132
107
|
*/
|
|
133
|
-
UpdateType[UpdateType["RenderTexture"] =
|
|
108
|
+
UpdateType[UpdateType["RenderTexture"] = 512] = "RenderTexture";
|
|
134
109
|
/**
|
|
135
110
|
* Track if parent has render texture
|
|
136
111
|
*/
|
|
137
|
-
UpdateType[UpdateType["ParentRenderTexture"] =
|
|
112
|
+
UpdateType[UpdateType["ParentRenderTexture"] = 1024] = "ParentRenderTexture";
|
|
138
113
|
/**
|
|
139
114
|
* Render Bounds update
|
|
140
115
|
*/
|
|
141
|
-
UpdateType[UpdateType["RenderBounds"] =
|
|
116
|
+
UpdateType[UpdateType["RenderBounds"] = 2048] = "RenderBounds";
|
|
117
|
+
/**
|
|
118
|
+
* RecalcUniforms
|
|
119
|
+
*/
|
|
120
|
+
UpdateType[UpdateType["RecalcUniforms"] = 4096] = "RecalcUniforms";
|
|
121
|
+
/**
|
|
122
|
+
* Autosize update
|
|
123
|
+
*/
|
|
124
|
+
UpdateType[UpdateType["Autosize"] = 8192] = "Autosize";
|
|
142
125
|
/**
|
|
143
126
|
* None
|
|
144
127
|
*/
|
|
@@ -146,11 +129,7 @@ export var UpdateType;
|
|
|
146
129
|
/**
|
|
147
130
|
* All
|
|
148
131
|
*/
|
|
149
|
-
UpdateType[UpdateType["All"] =
|
|
150
|
-
/**
|
|
151
|
-
* RecalcUniforms
|
|
152
|
-
*/
|
|
153
|
-
UpdateType[UpdateType["RecalcUniforms"] = 16384] = "RecalcUniforms";
|
|
132
|
+
UpdateType[UpdateType["All"] = 16383] = "All";
|
|
154
133
|
})(UpdateType || (UpdateType = {}));
|
|
155
134
|
/**
|
|
156
135
|
* A visual Node in the Renderer scene graph.
|
|
@@ -165,10 +144,28 @@ export class CoreNode extends EventEmitter {
|
|
|
165
144
|
children = [];
|
|
166
145
|
_id = getNewId();
|
|
167
146
|
props;
|
|
147
|
+
isCoreNode = true;
|
|
148
|
+
// WebGL Render Op State
|
|
149
|
+
renderOpBufferIdx = 0;
|
|
150
|
+
numQuads = 0;
|
|
151
|
+
renderOpTextures = [];
|
|
152
|
+
/**
|
|
153
|
+
* Permanent index (in float32 units) into the renderer's quad buffer.
|
|
154
|
+
* -1 means this node has not yet been assigned a slot.
|
|
155
|
+
*/
|
|
156
|
+
quadBufferIndex = -1;
|
|
157
|
+
/**
|
|
158
|
+
* True when renderCoords, premultiplied colors, or textureCoords changed
|
|
159
|
+
* since the node's quad was last written to the GPU.
|
|
160
|
+
*/
|
|
161
|
+
isQuadDirty = true;
|
|
162
|
+
hasShaderUpdater = false;
|
|
163
|
+
hasShaderTimeFn = false;
|
|
164
|
+
hasColorProps = false;
|
|
165
|
+
textureLoaded = false;
|
|
168
166
|
updateType = UpdateType.All;
|
|
169
167
|
childUpdateType = UpdateType.None;
|
|
170
168
|
globalTransform;
|
|
171
|
-
scaleRotateTransform;
|
|
172
169
|
localTransform;
|
|
173
170
|
sceneGlobalTransform;
|
|
174
171
|
renderCoords;
|
|
@@ -183,8 +180,11 @@ export class CoreNode extends EventEmitter {
|
|
|
183
180
|
height: 0,
|
|
184
181
|
valid: false,
|
|
185
182
|
};
|
|
183
|
+
textureCoords;
|
|
184
|
+
updateShaderUniforms = false;
|
|
186
185
|
isRenderable = false;
|
|
187
186
|
renderState = CoreNodeRenderState.Init;
|
|
187
|
+
isSimple = true;
|
|
188
188
|
worldAlpha = 1;
|
|
189
189
|
premultipliedColorTl = 0;
|
|
190
190
|
premultipliedColorTr = 0;
|
|
@@ -194,103 +194,167 @@ export class CoreNode extends EventEmitter {
|
|
|
194
194
|
hasRTTupdates = false;
|
|
195
195
|
parentHasRenderTexture = false;
|
|
196
196
|
rttParent = null;
|
|
197
|
+
/**
|
|
198
|
+
* only used when rtt = true
|
|
199
|
+
*/
|
|
200
|
+
framebufferDimensions = null;
|
|
201
|
+
/**Autosize properties */
|
|
202
|
+
autosizer = null;
|
|
203
|
+
parentAutosizer = null;
|
|
204
|
+
destroyed = false;
|
|
197
205
|
constructor(stage, props) {
|
|
198
206
|
super();
|
|
199
207
|
this.stage = stage;
|
|
200
|
-
|
|
201
|
-
|
|
208
|
+
//inital update type
|
|
209
|
+
let initialUpdateType = UpdateType.Local | UpdateType.RenderBounds | UpdateType.RenderState;
|
|
210
|
+
// Fast-path assign only known keys
|
|
211
|
+
const p = (this.props = {
|
|
212
|
+
x: props.x,
|
|
213
|
+
y: props.y,
|
|
214
|
+
w: props.w,
|
|
215
|
+
h: props.h,
|
|
216
|
+
alpha: props.alpha,
|
|
217
|
+
autosize: props.autosize,
|
|
218
|
+
clipping: props.clipping,
|
|
219
|
+
color: props.color,
|
|
220
|
+
colorTop: props.colorTop,
|
|
221
|
+
colorBottom: props.colorBottom,
|
|
222
|
+
colorLeft: props.colorLeft,
|
|
223
|
+
colorRight: props.colorRight,
|
|
224
|
+
colorTl: props.colorTl,
|
|
225
|
+
colorTr: props.colorTr,
|
|
226
|
+
colorBl: props.colorBl,
|
|
227
|
+
colorBr: props.colorBr,
|
|
228
|
+
scaleX: props.scaleX,
|
|
229
|
+
scaleY: props.scaleY,
|
|
230
|
+
rotation: props.rotation,
|
|
231
|
+
pivotX: props.pivotX,
|
|
232
|
+
pivotY: props.pivotY,
|
|
233
|
+
mountX: props.mountX,
|
|
234
|
+
mountY: props.mountY,
|
|
235
|
+
mount: props.mount,
|
|
236
|
+
pivot: props.pivot,
|
|
237
|
+
zIndex: props.zIndex,
|
|
238
|
+
textureOptions: props.textureOptions,
|
|
239
|
+
data: props.data,
|
|
240
|
+
imageType: props.imageType,
|
|
241
|
+
srcX: props.srcX,
|
|
242
|
+
srcY: props.srcY,
|
|
243
|
+
srcWidth: props.srcWidth,
|
|
244
|
+
srcHeight: props.srcHeight,
|
|
245
|
+
parent: props.parent,
|
|
202
246
|
texture: null,
|
|
203
247
|
shader: null,
|
|
204
248
|
src: null,
|
|
205
249
|
rtt: false,
|
|
250
|
+
boundsMargin: null,
|
|
251
|
+
scale: null,
|
|
252
|
+
interactive: props.interactive,
|
|
206
253
|
});
|
|
207
|
-
//
|
|
208
|
-
|
|
254
|
+
//check if any color props are set for premultiplied color updates
|
|
255
|
+
if (p.color > 0 ||
|
|
256
|
+
p.colorTop > 0 ||
|
|
257
|
+
p.colorBottom > 0 ||
|
|
258
|
+
p.colorLeft > 0 ||
|
|
259
|
+
p.colorRight > 0 ||
|
|
260
|
+
p.colorTl > 0 ||
|
|
261
|
+
p.colorTr > 0 ||
|
|
262
|
+
p.colorBl > 0 ||
|
|
263
|
+
p.colorBr > 0) {
|
|
264
|
+
this.hasColorProps = true;
|
|
265
|
+
initialUpdateType |= UpdateType.PremultipliedColors;
|
|
266
|
+
}
|
|
267
|
+
// Only set non-default values
|
|
268
|
+
if (p.zIndex !== 0) {
|
|
269
|
+
this.zIndex = p.zIndex;
|
|
270
|
+
}
|
|
271
|
+
if (props.parent !== null) {
|
|
272
|
+
props.parent.addChild(this);
|
|
273
|
+
}
|
|
274
|
+
// Assign props to instances
|
|
209
275
|
this.texture = props.texture;
|
|
210
276
|
this.shader = props.shader;
|
|
211
277
|
this.src = props.src;
|
|
212
278
|
this.rtt = props.rtt;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
props.boundsMargin,
|
|
219
|
-
props.boundsMargin,
|
|
220
|
-
props.boundsMargin,
|
|
221
|
-
];
|
|
222
|
-
}
|
|
223
|
-
this.setUpdateType(UpdateType.ScaleRotate |
|
|
224
|
-
UpdateType.Local |
|
|
225
|
-
UpdateType.RenderBounds |
|
|
226
|
-
UpdateType.RenderState);
|
|
227
|
-
if (isProductionEnvironment() === false && props.preventCleanup === true) {
|
|
228
|
-
console.warn('CoreNode.preventCleanup: Is deprecated and will be removed in upcoming release, please use textureOptions.preventCleanup instead');
|
|
279
|
+
this.boundsMargin = props.boundsMargin;
|
|
280
|
+
this.interactive = props.interactive;
|
|
281
|
+
// Initialize autosize if enabled
|
|
282
|
+
if (p.autosize === true) {
|
|
283
|
+
this.autosizer = new Autosizer(this);
|
|
229
284
|
}
|
|
285
|
+
this.setUpdateType(initialUpdateType);
|
|
230
286
|
// if the default texture isn't loaded yet, wait for it to load
|
|
231
287
|
// this only happens when the node is created before the stage is ready
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
this.setUpdateType(UpdateType.IsRenderable);
|
|
236
|
-
});
|
|
288
|
+
const dt = this.stage.defaultTexture;
|
|
289
|
+
if (dt !== null && dt.state !== 'loaded') {
|
|
290
|
+
dt.once('loaded', () => this.setUpdateType(UpdateType.IsRenderable));
|
|
237
291
|
}
|
|
292
|
+
this.updateIsSimple();
|
|
238
293
|
}
|
|
239
294
|
//#region Textures
|
|
240
295
|
loadTexture() {
|
|
241
|
-
|
|
242
|
-
|
|
296
|
+
if (this.props.texture === null) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
243
299
|
// If texture is already loaded / failed, trigger loaded event manually
|
|
244
300
|
// so that users get a consistent event experience.
|
|
245
301
|
// We do this in a microtask to allow listeners to be attached in the same
|
|
246
302
|
// synchronous task after calling loadTexture()
|
|
247
|
-
queueMicrotask(
|
|
248
|
-
if (this.textureOptions.preload === true) {
|
|
249
|
-
this.stage.txManager.loadTexture(texture);
|
|
250
|
-
}
|
|
251
|
-
texture.preventCleanup =
|
|
252
|
-
this.props.textureOptions?.preventCleanup ?? false;
|
|
253
|
-
texture.on('loaded', this.onTextureLoaded);
|
|
254
|
-
texture.on('failed', this.onTextureFailed);
|
|
255
|
-
texture.on('freed', this.onTextureFreed);
|
|
256
|
-
// If the parent is a render texture, the initial texture status
|
|
257
|
-
// will be set to freed until the texture is processed by the
|
|
258
|
-
// Render RTT nodes. So we only need to listen fo changes and
|
|
259
|
-
// no need to check the texture.state until we restructure how
|
|
260
|
-
// textures are being processed.
|
|
261
|
-
if (this.parentHasRenderTexture) {
|
|
262
|
-
this.notifyParentRTTOfUpdate();
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
if (texture.state === 'loaded') {
|
|
266
|
-
assertTruthy(texture.dimensions);
|
|
267
|
-
this.onTextureLoaded(texture, texture.dimensions);
|
|
268
|
-
}
|
|
269
|
-
else if (texture.state === 'failed') {
|
|
270
|
-
assertTruthy(texture.error);
|
|
271
|
-
this.onTextureFailed(texture, texture.error);
|
|
272
|
-
}
|
|
273
|
-
else if (texture.state === 'freed') {
|
|
274
|
-
this.onTextureFreed(texture);
|
|
275
|
-
}
|
|
276
|
-
});
|
|
303
|
+
queueMicrotask(this.loadTextureTask);
|
|
277
304
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Task for queueMicrotask to loadTexture
|
|
307
|
+
*
|
|
308
|
+
* @remarks
|
|
309
|
+
* This method is called in a microtask to release the texture.
|
|
310
|
+
*/
|
|
311
|
+
loadTextureTask = () => {
|
|
312
|
+
const texture = this.props.texture;
|
|
313
|
+
//it is possible that texture is null here if user sets the texture to null right after loadTexture call
|
|
314
|
+
if (texture === null) {
|
|
315
|
+
return;
|
|
284
316
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
317
|
+
if (this.textureOptions.preload === true) {
|
|
318
|
+
this.stage.txManager.loadTexture(texture);
|
|
319
|
+
}
|
|
320
|
+
texture.preventCleanup = this.props.textureOptions?.preventCleanup ?? false;
|
|
321
|
+
texture.on('loaded', this.onTextureLoaded);
|
|
322
|
+
texture.on('failed', this.onTextureFailed);
|
|
323
|
+
texture.on('freed', this.onTextureFreed);
|
|
324
|
+
// If the parent is a render texture, the initial texture status
|
|
325
|
+
// will be set to freed until the texture is processed by the
|
|
326
|
+
// Render RTT nodes. So we only need to listen fo changes and
|
|
327
|
+
// no need to check the texture.state until we restructure how
|
|
328
|
+
// textures are being processed.
|
|
329
|
+
if (this.parentHasRenderTexture) {
|
|
330
|
+
this.notifyParentRTTOfUpdate();
|
|
331
|
+
return;
|
|
290
332
|
}
|
|
333
|
+
if (texture.state === 'loaded') {
|
|
334
|
+
this.onTextureLoaded(texture, texture.dimensions);
|
|
335
|
+
}
|
|
336
|
+
else if (texture.state === 'failed') {
|
|
337
|
+
this.onTextureFailed(texture, texture.error);
|
|
338
|
+
}
|
|
339
|
+
else if (texture.state === 'freed') {
|
|
340
|
+
this.onTextureFreed(texture);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
unloadTexture() {
|
|
344
|
+
if (this.texture === null) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const texture = this.texture;
|
|
348
|
+
texture.off('loaded', this.onTextureLoaded);
|
|
349
|
+
texture.off('failed', this.onTextureFailed);
|
|
350
|
+
texture.off('freed', this.onTextureFreed);
|
|
351
|
+
texture.setRenderableOwner(this._id, false);
|
|
291
352
|
}
|
|
292
353
|
onTextureLoaded = (_, dimensions) => {
|
|
293
|
-
this.
|
|
354
|
+
if (this.autosizer !== null) {
|
|
355
|
+
this.autosizer.update();
|
|
356
|
+
}
|
|
357
|
+
this.textureLoaded = true;
|
|
294
358
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
295
359
|
// Texture was loaded. In case the RAF loop has already stopped, we request
|
|
296
360
|
// a render to ensure the texture is rendered.
|
|
@@ -300,29 +364,46 @@ export class CoreNode extends EventEmitter {
|
|
|
300
364
|
this.notifyParentRTTOfUpdate();
|
|
301
365
|
}
|
|
302
366
|
// ignore 1x1 pixel textures
|
|
303
|
-
if (dimensions.
|
|
367
|
+
if (dimensions.w > 1 && dimensions.h > 1) {
|
|
304
368
|
this.emit('loaded', {
|
|
305
369
|
type: 'texture',
|
|
306
370
|
dimensions,
|
|
307
371
|
});
|
|
308
372
|
}
|
|
373
|
+
if (this.stage.calculateTextureCoord === true &&
|
|
374
|
+
this.props.textureOptions !== null) {
|
|
375
|
+
this.textureCoords = this.stage.renderer.getTextureCoords(this);
|
|
376
|
+
}
|
|
309
377
|
// Trigger a local update if the texture is loaded and the resizeMode is 'contain'
|
|
310
378
|
if (this.props.textureOptions?.resizeMode?.type === 'contain') {
|
|
311
379
|
this.setUpdateType(UpdateType.Local);
|
|
312
380
|
}
|
|
313
381
|
};
|
|
314
382
|
onTextureFailed = (_, error) => {
|
|
383
|
+
// immediately set isRenderable to false, so that we handle the error
|
|
384
|
+
// without waiting for the next frame loop
|
|
385
|
+
this.textureLoaded = false;
|
|
386
|
+
this.isRenderable = false;
|
|
387
|
+
this.updateTextureOwnership(false);
|
|
315
388
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
316
389
|
// If parent has a render texture, flag that we need to update
|
|
317
390
|
if (this.parentHasRenderTexture) {
|
|
318
391
|
this.notifyParentRTTOfUpdate();
|
|
319
392
|
}
|
|
320
|
-
this.
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
393
|
+
if (this.texture !== null &&
|
|
394
|
+
this.texture.retryCount > this.texture.maxRetryCount) {
|
|
395
|
+
this.emit('failed', {
|
|
396
|
+
type: 'texture',
|
|
397
|
+
error,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
324
400
|
};
|
|
325
401
|
onTextureFreed = () => {
|
|
402
|
+
// immediately set isRenderable to false, so that we handle the error
|
|
403
|
+
// without waiting for the next frame loop
|
|
404
|
+
this.textureLoaded = false;
|
|
405
|
+
this.isRenderable = false;
|
|
406
|
+
this.updateTextureOwnership(false);
|
|
326
407
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
327
408
|
// If parent has a render texture, flag that we need to update
|
|
328
409
|
if (this.parentHasRenderTexture) {
|
|
@@ -344,248 +425,274 @@ export class CoreNode extends EventEmitter {
|
|
|
344
425
|
setUpdateType(type) {
|
|
345
426
|
this.updateType |= type;
|
|
346
427
|
const parent = this.props.parent;
|
|
347
|
-
if (!parent)
|
|
428
|
+
if (!parent || parent.updateType & UpdateType.Children)
|
|
348
429
|
return;
|
|
349
|
-
|
|
350
|
-
// Inform the parent if it doesn’t already have a child update
|
|
351
|
-
parent.setUpdateType(UpdateType.Children);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
sortChildren() {
|
|
355
|
-
this.children.sort((a, b) => a.calcZIndex - b.calcZIndex);
|
|
430
|
+
parent.setUpdateType(UpdateType.Children);
|
|
356
431
|
}
|
|
357
|
-
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
if (
|
|
361
|
-
this.
|
|
432
|
+
updateLocalTransform() {
|
|
433
|
+
const p = this.props;
|
|
434
|
+
const { x, y } = p;
|
|
435
|
+
if (this.isSimple) {
|
|
436
|
+
this.localTransform = Matrix3d.translate(x, y, this.localTransform);
|
|
362
437
|
return;
|
|
363
438
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
const pivotTranslateX = this.props.pivotX * width;
|
|
372
|
-
const pivotTranslateY = this.props.pivotY * height;
|
|
439
|
+
const { w, h } = p;
|
|
440
|
+
const mountTranslateX = p.mountX * w;
|
|
441
|
+
const mountTranslateY = p.mountY * h;
|
|
442
|
+
if (p.rotation !== 0 || p.scaleX !== 1 || p.scaleY !== 1) {
|
|
443
|
+
const scaleRotate = Matrix3d.rotate(p.rotation, Matrix3d.temp).scale(p.scaleX, p.scaleY);
|
|
444
|
+
const pivotTranslateX = p.pivotX * w;
|
|
445
|
+
const pivotTranslateY = p.pivotY * h;
|
|
373
446
|
this.localTransform = Matrix3d.translate(x - mountTranslateX + pivotTranslateX, y - mountTranslateY + pivotTranslateY, this.localTransform)
|
|
374
|
-
.multiply(
|
|
447
|
+
.multiply(scaleRotate)
|
|
375
448
|
.translate(-pivotTranslateX, -pivotTranslateY);
|
|
376
449
|
}
|
|
377
450
|
else {
|
|
378
451
|
this.localTransform = Matrix3d.translate(x - mountTranslateX, y - mountTranslateY, this.localTransform);
|
|
379
452
|
}
|
|
380
453
|
// Handle 'contain' resize mode
|
|
381
|
-
const texture =
|
|
454
|
+
const texture = p.texture;
|
|
382
455
|
if (texture &&
|
|
383
456
|
texture.dimensions &&
|
|
384
|
-
|
|
457
|
+
p.textureOptions.resizeMode?.type === 'contain') {
|
|
385
458
|
let resizeModeScaleX = 1;
|
|
386
459
|
let resizeModeScaleY = 1;
|
|
387
460
|
let extraX = 0;
|
|
388
461
|
let extraY = 0;
|
|
389
|
-
const {
|
|
462
|
+
const { w: tw, h: th } = texture.dimensions;
|
|
390
463
|
const txAspectRatio = tw / th;
|
|
391
|
-
const nodeAspectRatio =
|
|
464
|
+
const nodeAspectRatio = w / h;
|
|
392
465
|
if (txAspectRatio > nodeAspectRatio) {
|
|
393
466
|
// Texture is wider than node
|
|
394
467
|
// Center the node vertically (shift down by extraY)
|
|
395
468
|
// Scale the node vertically to maintain original aspect ratio
|
|
396
|
-
const scaleX =
|
|
469
|
+
const scaleX = w / tw;
|
|
397
470
|
const scaledTxHeight = th * scaleX;
|
|
398
|
-
extraY = (
|
|
399
|
-
resizeModeScaleY = scaledTxHeight /
|
|
471
|
+
extraY = (h - scaledTxHeight) / 2;
|
|
472
|
+
resizeModeScaleY = scaledTxHeight / h;
|
|
400
473
|
}
|
|
401
474
|
else {
|
|
402
475
|
// Texture is taller than node (or equal)
|
|
403
476
|
// Center the node horizontally (shift right by extraX)
|
|
404
477
|
// Scale the node horizontally to maintain original aspect ratio
|
|
405
|
-
const scaleY =
|
|
478
|
+
const scaleY = h / th;
|
|
406
479
|
const scaledTxWidth = tw * scaleY;
|
|
407
|
-
extraX = (
|
|
408
|
-
resizeModeScaleX = scaledTxWidth /
|
|
480
|
+
extraX = (w - scaledTxWidth) / 2;
|
|
481
|
+
resizeModeScaleX = scaledTxWidth / w;
|
|
409
482
|
}
|
|
410
483
|
// Apply the extra translation and scale to the local transform
|
|
411
484
|
this.localTransform
|
|
412
485
|
.translate(extraX, extraY)
|
|
413
486
|
.scale(resizeModeScaleX, resizeModeScaleY);
|
|
414
487
|
}
|
|
415
|
-
|
|
488
|
+
}
|
|
489
|
+
updateIsSimple() {
|
|
490
|
+
const p = this.props;
|
|
491
|
+
this.isSimple =
|
|
492
|
+
p.rotation === 0 &&
|
|
493
|
+
p.scaleX === 1 &&
|
|
494
|
+
p.scaleY === 1 &&
|
|
495
|
+
p.mountX === 0 &&
|
|
496
|
+
p.mountY === 0 &&
|
|
497
|
+
!(p.texture && p.textureOptions.resizeMode?.type === 'contain');
|
|
416
498
|
}
|
|
417
499
|
/**
|
|
418
500
|
* @todo: test for correct calculation flag
|
|
419
501
|
* @param delta
|
|
420
502
|
*/
|
|
421
503
|
update(delta, parentClippingRect) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
504
|
+
const props = this.props;
|
|
505
|
+
//parent can be forced to ! because the root node update loop uses updateRoot which implies that
|
|
506
|
+
//all other loops using this update method have a parent
|
|
507
|
+
const parent = props.parent;
|
|
508
|
+
const parentHasRenderTexture = this.parentHasRenderTexture;
|
|
509
|
+
let newRenderState = null;
|
|
510
|
+
let updateType = this.updateType;
|
|
511
|
+
let childUpdateType = this.childUpdateType;
|
|
512
|
+
//this needs to be handled before setting updateTypes are reset
|
|
513
|
+
if (ENABLE_AUTOSIZE &&
|
|
514
|
+
updateType & UpdateType.Autosize &&
|
|
515
|
+
this.autosizer !== null) {
|
|
516
|
+
this.autosizer.update();
|
|
425
517
|
}
|
|
426
|
-
|
|
518
|
+
// reset update type
|
|
519
|
+
this.updateType = 0;
|
|
520
|
+
this.childUpdateType = 0;
|
|
521
|
+
if (updateType & UpdateType.Local) {
|
|
427
522
|
this.updateLocalTransform();
|
|
428
|
-
|
|
523
|
+
updateType |= UpdateType.Global;
|
|
429
524
|
}
|
|
430
|
-
const parent = this.props.parent;
|
|
431
|
-
let renderState = null;
|
|
432
525
|
// Handle specific RTT updates at this node level
|
|
433
|
-
if (
|
|
526
|
+
if (USE_RTT && updateType & UpdateType.RenderTexture && this.rtt === true) {
|
|
434
527
|
this.hasRTTupdates = true;
|
|
435
528
|
}
|
|
436
|
-
if (
|
|
437
|
-
|
|
438
|
-
|
|
529
|
+
if (updateType & UpdateType.Global) {
|
|
530
|
+
if (USE_RTT &&
|
|
531
|
+
this.parentHasRenderTexture === true &&
|
|
532
|
+
parent.rtt === true) {
|
|
439
533
|
// we are at the start of the RTT chain, so we need to reset the globalTransform
|
|
440
534
|
// for correct RTT rendering
|
|
441
|
-
this.globalTransform = Matrix3d.identity();
|
|
535
|
+
this.globalTransform = Matrix3d.identity(this.globalTransform);
|
|
442
536
|
// Maintain a full scene global transform for bounds detection
|
|
443
|
-
|
|
537
|
+
const parentTransform = parent.globalTransform || Matrix3d.identity(Matrix3d.temp);
|
|
538
|
+
this.sceneGlobalTransform = Matrix3d.copy(parentTransform, this.sceneGlobalTransform).translateOrMultiply(this.localTransform);
|
|
444
539
|
}
|
|
445
|
-
else if (
|
|
446
|
-
|
|
540
|
+
else if (USE_RTT &&
|
|
541
|
+
this.parentHasRenderTexture === true &&
|
|
542
|
+
parent.rtt === false) {
|
|
447
543
|
// we're part of an RTT chain but our parent is not the main RTT node
|
|
448
544
|
// so we need to propogate the sceneGlobalTransform of the parent
|
|
449
545
|
// to maintain a full scene global transform for bounds detection
|
|
450
|
-
|
|
451
|
-
this.
|
|
546
|
+
const parentSceneTransform = parent.sceneGlobalTransform || this.localTransform;
|
|
547
|
+
this.sceneGlobalTransform = Matrix3d.copy(parentSceneTransform, this.sceneGlobalTransform).translateOrMultiply(this.localTransform);
|
|
548
|
+
this.globalTransform = Matrix3d.copy(parent.globalTransform || this.localTransform, this.globalTransform);
|
|
452
549
|
}
|
|
453
550
|
else {
|
|
454
|
-
this.globalTransform = Matrix3d.copy(parent
|
|
551
|
+
this.globalTransform = Matrix3d.copy(parent.globalTransform || this.localTransform, this.globalTransform);
|
|
455
552
|
}
|
|
456
|
-
if (
|
|
457
|
-
this.globalTransform.
|
|
553
|
+
if (this.isSimple) {
|
|
554
|
+
this.globalTransform.translate(this.localTransform.tx, this.localTransform.ty);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
this.globalTransform.translateOrMultiply(this.localTransform);
|
|
458
558
|
}
|
|
459
559
|
this.calculateRenderCoords();
|
|
460
560
|
this.updateBoundingRect();
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
561
|
+
updateType |= UpdateType.RenderState | UpdateType.RecalcUniforms;
|
|
562
|
+
//only propagate children updates if not autosizing
|
|
563
|
+
if ((updateType & UpdateType.Autosize) === 0) {
|
|
564
|
+
updateType |= UpdateType.Children;
|
|
565
|
+
childUpdateType |= UpdateType.Global;
|
|
566
|
+
}
|
|
465
567
|
if (this.clipping === true) {
|
|
466
|
-
|
|
467
|
-
|
|
568
|
+
updateType |= UpdateType.Clipping | UpdateType.RenderBounds;
|
|
569
|
+
childUpdateType |= UpdateType.RenderBounds;
|
|
468
570
|
}
|
|
469
571
|
}
|
|
470
|
-
if (
|
|
572
|
+
if (updateType & UpdateType.RenderBounds) {
|
|
471
573
|
this.createRenderBounds();
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
this.childUpdateType |= UpdateType.RenderBounds;
|
|
574
|
+
updateType |= UpdateType.RenderState | UpdateType.Children;
|
|
575
|
+
childUpdateType |= UpdateType.RenderBounds;
|
|
475
576
|
}
|
|
476
|
-
if (
|
|
477
|
-
|
|
478
|
-
|
|
577
|
+
if (updateType & UpdateType.RenderState) {
|
|
578
|
+
newRenderState = this.checkRenderBounds();
|
|
579
|
+
updateType |= UpdateType.IsRenderable;
|
|
479
580
|
// if we're not going out of bounds, update the render state
|
|
480
581
|
// this is done so the update loop can finish before we mark a node
|
|
481
582
|
// as out of bounds
|
|
482
|
-
if (
|
|
483
|
-
this.updateRenderState(
|
|
583
|
+
if (newRenderState !== CoreNodeRenderState.OutOfBounds) {
|
|
584
|
+
this.updateRenderState(newRenderState);
|
|
484
585
|
}
|
|
485
586
|
}
|
|
486
|
-
if (
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
}
|
|
490
|
-
else {
|
|
491
|
-
this.worldAlpha = this.props.alpha;
|
|
492
|
-
}
|
|
493
|
-
this.setUpdateType(UpdateType.Children |
|
|
587
|
+
if (updateType & UpdateType.WorldAlpha) {
|
|
588
|
+
this.worldAlpha = parent.worldAlpha * this.props.alpha;
|
|
589
|
+
updateType |=
|
|
494
590
|
UpdateType.PremultipliedColors |
|
|
495
|
-
|
|
496
|
-
|
|
591
|
+
UpdateType.Children |
|
|
592
|
+
UpdateType.IsRenderable;
|
|
593
|
+
childUpdateType |= UpdateType.WorldAlpha;
|
|
497
594
|
}
|
|
498
|
-
if (
|
|
595
|
+
if (updateType & UpdateType.IsRenderable) {
|
|
499
596
|
this.updateIsRenderable();
|
|
500
597
|
}
|
|
501
|
-
|
|
598
|
+
// Handle autosize updates when children transforms change
|
|
599
|
+
if (ENABLE_AUTOSIZE &&
|
|
600
|
+
updateType & UpdateType.Global &&
|
|
601
|
+
this.isRenderable === true &&
|
|
602
|
+
this.parentAutosizer !== null) {
|
|
603
|
+
this.parentAutosizer.patch(this.id);
|
|
604
|
+
}
|
|
605
|
+
if (updateType & UpdateType.Clipping) {
|
|
502
606
|
this.calculateClippingRect(parentClippingRect);
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
607
|
+
updateType |= UpdateType.Children;
|
|
608
|
+
childUpdateType |= UpdateType.Clipping | UpdateType.RenderBounds;
|
|
609
|
+
}
|
|
610
|
+
if (updateType & UpdateType.PremultipliedColors) {
|
|
611
|
+
const alpha = this.worldAlpha;
|
|
612
|
+
const tl = props.colorTl;
|
|
613
|
+
const tr = props.colorTr;
|
|
614
|
+
const bl = props.colorBl;
|
|
615
|
+
const br = props.colorBr;
|
|
616
|
+
// Fast equality check (covers all 4 corners)
|
|
617
|
+
const same = tl === tr && tl === bl && tl === br;
|
|
618
|
+
const merged = premultiplyColorABGR(tl, alpha);
|
|
619
|
+
this.premultipliedColorTl = merged;
|
|
620
|
+
if (same === true) {
|
|
513
621
|
this.premultipliedColorTr =
|
|
514
622
|
this.premultipliedColorBl =
|
|
515
623
|
this.premultipliedColorBr =
|
|
516
|
-
|
|
624
|
+
merged;
|
|
517
625
|
}
|
|
518
626
|
else {
|
|
519
|
-
this.premultipliedColorTr =
|
|
520
|
-
this.premultipliedColorBl =
|
|
521
|
-
this.premultipliedColorBr =
|
|
627
|
+
this.premultipliedColorTr = premultiplyColorABGR(tr, alpha);
|
|
628
|
+
this.premultipliedColorBl = premultiplyColorABGR(bl, alpha);
|
|
629
|
+
this.premultipliedColorBr = premultiplyColorABGR(br, alpha);
|
|
522
630
|
}
|
|
523
631
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
this.
|
|
527
|
-
|
|
528
|
-
parent.setUpdateType(UpdateType.ZIndexSortedChildren);
|
|
529
|
-
}
|
|
530
|
-
if (this.props.strictBounds === true &&
|
|
531
|
-
this.renderState === CoreNodeRenderState.OutOfBounds) {
|
|
532
|
-
this.updateType &= ~UpdateType.RenderBounds; // remove render bounds update
|
|
632
|
+
if (this.renderState === CoreNodeRenderState.OutOfBounds) {
|
|
633
|
+
// Delay updating children until the node is in bounds
|
|
634
|
+
this.updateType = updateType;
|
|
635
|
+
this.childUpdateType = childUpdateType;
|
|
533
636
|
return;
|
|
534
637
|
}
|
|
535
|
-
if (
|
|
536
|
-
|
|
537
|
-
|
|
638
|
+
if (updateType & UpdateType.RecalcUniforms &&
|
|
639
|
+
this.hasShaderUpdater === true) {
|
|
640
|
+
this.updateShaderUniforms = true;
|
|
641
|
+
}
|
|
642
|
+
if (this.isRenderable === true && this.updateShaderUniforms === true) {
|
|
643
|
+
this.updateShaderUniforms = false;
|
|
644
|
+
//this exists because the boolean hasShaderUpdater === true
|
|
538
645
|
this.shader.update();
|
|
539
646
|
}
|
|
540
|
-
if (
|
|
647
|
+
if (updateType & UpdateType.Children && this.children.length > 0) {
|
|
648
|
+
let childClippingRect = this.clippingRect;
|
|
649
|
+
if (USE_RTT && this.rtt === true) {
|
|
650
|
+
childClippingRect = NO_CLIPPING_RECT;
|
|
651
|
+
}
|
|
541
652
|
for (let i = 0, length = this.children.length; i < length; i++) {
|
|
542
653
|
const child = this.children[i];
|
|
543
|
-
|
|
654
|
+
if (childUpdateType !== 0) {
|
|
655
|
+
child.setUpdateType(childUpdateType);
|
|
656
|
+
}
|
|
544
657
|
if (child.updateType === 0) {
|
|
545
658
|
continue;
|
|
546
659
|
}
|
|
547
|
-
let childClippingRect = this.clippingRect;
|
|
548
|
-
if (this.rtt === true) {
|
|
549
|
-
childClippingRect = {
|
|
550
|
-
x: 0,
|
|
551
|
-
y: 0,
|
|
552
|
-
width: 0,
|
|
553
|
-
height: 0,
|
|
554
|
-
valid: false,
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
660
|
child.update(delta, childClippingRect);
|
|
558
661
|
}
|
|
559
662
|
}
|
|
560
663
|
// If the node has an RTT parent and requires a texture re-render, inform the RTT parent
|
|
561
|
-
// if (this.parentHasRenderTexture &&
|
|
664
|
+
// if (this.parentHasRenderTexture && updateType & UpdateType.RenderTexture) {
|
|
562
665
|
// @TODO have a more scoped down updateType for RTT updates
|
|
563
|
-
if (
|
|
666
|
+
if (USE_RTT === true && parentHasRenderTexture === true) {
|
|
564
667
|
this.notifyParentRTTOfUpdate();
|
|
565
668
|
}
|
|
566
|
-
//
|
|
567
|
-
|
|
568
|
-
if (this.updateType & UpdateType.ZIndexSortedChildren) {
|
|
669
|
+
//Resort children if needed
|
|
670
|
+
if (updateType & UpdateType.SortZIndexChildren) {
|
|
569
671
|
// reorder z-index
|
|
570
672
|
this.sortChildren();
|
|
571
673
|
}
|
|
572
674
|
// If we're out of bounds, apply the render state now
|
|
573
675
|
// this is done so nodes can finish their entire update loop before
|
|
574
676
|
// being marked as out of bounds
|
|
575
|
-
if (
|
|
576
|
-
this.updateRenderState(
|
|
677
|
+
if (newRenderState === CoreNodeRenderState.OutOfBounds) {
|
|
678
|
+
this.updateRenderState(newRenderState);
|
|
577
679
|
this.updateIsRenderable();
|
|
578
|
-
if (
|
|
579
|
-
|
|
680
|
+
if (USE_RTT === true &&
|
|
681
|
+
this.rtt === true &&
|
|
682
|
+
newRenderState === CoreNodeRenderState.OutOfBounds) {
|
|
580
683
|
// notify children that we are going out of bounds
|
|
581
684
|
// we have to do this now before we stop processing the render tree
|
|
582
|
-
this.notifyChildrenRTTOfUpdate(
|
|
583
|
-
// this.childUpdateType |= UpdateType.RenderState;
|
|
685
|
+
this.notifyChildrenRTTOfUpdate(newRenderState);
|
|
584
686
|
}
|
|
585
687
|
}
|
|
586
|
-
//
|
|
587
|
-
|
|
588
|
-
|
|
688
|
+
// Mark quad dirty only when visual data (transforms, colors) actually
|
|
689
|
+
// changed, so the WebGL renderer only re-uploads modified slots.
|
|
690
|
+
if (updateType &
|
|
691
|
+
(UpdateType.Global |
|
|
692
|
+
UpdateType.PremultipliedColors |
|
|
693
|
+
UpdateType.WorldAlpha)) {
|
|
694
|
+
this.isQuadDirty = true;
|
|
695
|
+
}
|
|
589
696
|
}
|
|
590
697
|
findParentRTTNode() {
|
|
591
698
|
let rttNode = this.parent;
|
|
@@ -594,13 +701,6 @@ export class CoreNode extends EventEmitter {
|
|
|
594
701
|
}
|
|
595
702
|
return rttNode;
|
|
596
703
|
}
|
|
597
|
-
getRTTParentRenderState() {
|
|
598
|
-
const rttNode = this.rttParent || this.findParentRTTNode();
|
|
599
|
-
if (!rttNode) {
|
|
600
|
-
return null;
|
|
601
|
-
}
|
|
602
|
-
return rttNode.renderState;
|
|
603
|
-
}
|
|
604
704
|
notifyChildrenRTTOfUpdate(renderState) {
|
|
605
705
|
for (const child of this.children) {
|
|
606
706
|
// force child to update render state
|
|
@@ -626,9 +726,6 @@ export class CoreNode extends EventEmitter {
|
|
|
626
726
|
}
|
|
627
727
|
}
|
|
628
728
|
checkRenderBounds() {
|
|
629
|
-
assertTruthy(this.renderBound);
|
|
630
|
-
assertTruthy(this.strictBound);
|
|
631
|
-
assertTruthy(this.preloadBound);
|
|
632
729
|
if (boundInsideBound(this.renderBound, this.strictBound)) {
|
|
633
730
|
return CoreNodeRenderState.InViewport;
|
|
634
731
|
}
|
|
@@ -640,34 +737,30 @@ export class CoreNode extends EventEmitter {
|
|
|
640
737
|
return CoreNodeRenderState.InViewport;
|
|
641
738
|
}
|
|
642
739
|
// check if we dont have dimensions, take our parent's render state
|
|
643
|
-
if (this.parent !== null &&
|
|
644
|
-
(this.props.width === 0 || this.props.height === 0)) {
|
|
740
|
+
if (this.parent !== null && (this.props.w === 0 || this.props.h === 0)) {
|
|
645
741
|
return this.parent.renderState;
|
|
646
742
|
}
|
|
647
743
|
return CoreNodeRenderState.OutOfBounds;
|
|
648
744
|
}
|
|
649
745
|
updateBoundingRect() {
|
|
650
|
-
const transform = this.sceneGlobalTransform ||
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
if (tb === 0 || tc === 0) {
|
|
657
|
-
this.renderBound = createBound(x1, y1, x3, y3, this.renderBound);
|
|
746
|
+
const transform = (this.sceneGlobalTransform ||
|
|
747
|
+
this.globalTransform);
|
|
748
|
+
const renderCoords = (this.sceneRenderCoords ||
|
|
749
|
+
this.renderCoords);
|
|
750
|
+
if (transform.tb === 0 || transform.tc === 0) {
|
|
751
|
+
this.renderBound = createBound(renderCoords.x1, renderCoords.y1, renderCoords.x3, renderCoords.y3, this.renderBound);
|
|
658
752
|
}
|
|
659
753
|
else {
|
|
660
|
-
const {
|
|
754
|
+
const { x1, y1, x2, y2, x3, y3, x4, y4 } = renderCoords;
|
|
661
755
|
this.renderBound = createBound(Math.min(x1, x2, x3, x4), Math.min(y1, y2, y3, y4), Math.max(x1, x2, x3, x4), Math.max(y1, y2, y3, y4), this.renderBound);
|
|
662
756
|
}
|
|
663
757
|
}
|
|
664
758
|
createRenderBounds() {
|
|
665
|
-
assertTruthy(this.stage);
|
|
666
759
|
if (this.parent !== null && this.parent.strictBound !== undefined) {
|
|
667
760
|
// we have a parent with a valid bound, copy it
|
|
668
761
|
const parentBound = this.parent.strictBound;
|
|
669
|
-
this.strictBound = createBound(parentBound.x1, parentBound.y1, parentBound.x2, parentBound.y2);
|
|
670
|
-
this.preloadBound = createPreloadBounds(this.strictBound, this.boundsMargin);
|
|
762
|
+
this.strictBound = createBound(parentBound.x1, parentBound.y1, parentBound.x2, parentBound.y2, this.strictBound);
|
|
763
|
+
this.preloadBound = createPreloadBounds(this.strictBound, this.boundsMargin, this.preloadBound);
|
|
671
764
|
}
|
|
672
765
|
else {
|
|
673
766
|
// no parent or parent does not have a bound, take the stage boundaries
|
|
@@ -688,14 +781,14 @@ export class CoreNode extends EventEmitter {
|
|
|
688
781
|
return;
|
|
689
782
|
}
|
|
690
783
|
// clipping is enabled and we are in bounds create our own bounds
|
|
691
|
-
const { x, y,
|
|
784
|
+
const { x, y, w, h } = this.props;
|
|
692
785
|
// Pick the global transform if available, otherwise use the local transform
|
|
693
786
|
// global transform is only available if the node in an RTT chain
|
|
694
787
|
const { tx, ty } = this.sceneGlobalTransform || this.globalTransform || {};
|
|
695
788
|
const _x = tx ?? x;
|
|
696
789
|
const _y = ty ?? y;
|
|
697
|
-
this.strictBound = createBound(_x, _y, _x +
|
|
698
|
-
this.preloadBound = createPreloadBounds(this.strictBound, this.boundsMargin);
|
|
790
|
+
this.strictBound = createBound(_x, _y, _x + w, _y + h, this.strictBound);
|
|
791
|
+
this.preloadBound = createPreloadBounds(this.strictBound, this.boundsMargin, this.preloadBound);
|
|
699
792
|
}
|
|
700
793
|
updateRenderState(renderState) {
|
|
701
794
|
if (renderState === this.renderState) {
|
|
@@ -703,12 +796,30 @@ export class CoreNode extends EventEmitter {
|
|
|
703
796
|
}
|
|
704
797
|
const previous = this.renderState;
|
|
705
798
|
this.renderState = renderState;
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
799
|
+
// If node visibility changes, dirty the render list cache
|
|
800
|
+
if (renderState === CoreNodeRenderState.OutOfBounds ||
|
|
801
|
+
previous === CoreNodeRenderState.OutOfBounds) {
|
|
802
|
+
this.stage.requestRenderListUpdate();
|
|
803
|
+
}
|
|
804
|
+
if (EMIT_BOUNDS_EVENTS) {
|
|
805
|
+
const event = CoreNodeRenderStateMap.get(renderState);
|
|
806
|
+
assertTruthy(event);
|
|
807
|
+
this.emit(event, {
|
|
808
|
+
previous,
|
|
809
|
+
current: renderState,
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Checks if the node is renderable based on world alpha, dimensions and out of bounds status.
|
|
815
|
+
*/
|
|
816
|
+
checkBasicRenderability() {
|
|
817
|
+
if (this.worldAlpha === 0 || this.isOutOfBounds() === true) {
|
|
818
|
+
return false;
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
return true;
|
|
822
|
+
}
|
|
712
823
|
}
|
|
713
824
|
/**
|
|
714
825
|
* Updates the `isRenderable` property based on various conditions.
|
|
@@ -723,44 +834,53 @@ export class CoreNode extends EventEmitter {
|
|
|
723
834
|
return;
|
|
724
835
|
}
|
|
725
836
|
if (this.texture !== null) {
|
|
837
|
+
// preemptive check for failed textures this will mark the current node as non-renderable
|
|
838
|
+
// and will prevent further checks until the texture is reloaded or retry is reset on the texture
|
|
839
|
+
if (this.texture.retryCount > this.texture.maxRetryCount) {
|
|
840
|
+
// texture has failed to load, we cannot render
|
|
841
|
+
this.updateTextureOwnership(false);
|
|
842
|
+
this.setRenderable(false);
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
726
845
|
needsTextureOwnership = true;
|
|
727
|
-
//
|
|
728
|
-
newIsRenderable = this.
|
|
729
|
-
}
|
|
730
|
-
else if (
|
|
846
|
+
// Use cached boolean instead of string comparison
|
|
847
|
+
newIsRenderable = this.textureLoaded;
|
|
848
|
+
}
|
|
849
|
+
else if (
|
|
850
|
+
// check shader
|
|
851
|
+
(this.props.shader !== this.stage.renderer.getDefaultShaderNode() ||
|
|
852
|
+
this.hasColorProps === true) &&
|
|
853
|
+
// check dimensions
|
|
731
854
|
this.hasDimensions() === true) {
|
|
732
855
|
// This mean we have dimensions and a color set, so we can render a ColorTexture
|
|
733
|
-
|
|
734
|
-
this.stage.defaultTexture.state === 'loaded') {
|
|
735
|
-
newIsRenderable = true;
|
|
736
|
-
}
|
|
856
|
+
newIsRenderable = true;
|
|
737
857
|
}
|
|
738
858
|
this.updateTextureOwnership(needsTextureOwnership);
|
|
739
859
|
this.setRenderable(newIsRenderable);
|
|
740
860
|
}
|
|
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
861
|
/**
|
|
753
862
|
* Sets the renderable state and triggers changes if necessary.
|
|
754
863
|
* @param isRenderable - The new renderable state
|
|
755
864
|
*/
|
|
756
865
|
setRenderable(isRenderable) {
|
|
866
|
+
const previousIsRenderable = this.isRenderable;
|
|
757
867
|
this.isRenderable = isRenderable;
|
|
868
|
+
// Emit event if renderable status has changed
|
|
869
|
+
if (previousIsRenderable !== isRenderable) {
|
|
870
|
+
this.stage.requestRenderListUpdate();
|
|
871
|
+
if (EMIT_BOUNDS_EVENTS) {
|
|
872
|
+
this.emit('renderable', {
|
|
873
|
+
type: 'renderable',
|
|
874
|
+
isRenderable,
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
}
|
|
758
878
|
}
|
|
759
879
|
/**
|
|
760
880
|
* Changes the renderable state of the node.
|
|
761
881
|
*/
|
|
762
882
|
updateTextureOwnership(isRenderable) {
|
|
763
|
-
this.texture?.setRenderableOwner(this, isRenderable);
|
|
883
|
+
this.texture?.setRenderableOwner(this._id, isRenderable);
|
|
764
884
|
}
|
|
765
885
|
/**
|
|
766
886
|
* Checks if the node is out of the viewport bounds.
|
|
@@ -772,33 +892,17 @@ export class CoreNode extends EventEmitter {
|
|
|
772
892
|
* Checks if the node has dimensions (width/height)
|
|
773
893
|
*/
|
|
774
894
|
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;
|
|
895
|
+
return this.props.w !== 0 && this.props.h !== 0;
|
|
793
896
|
}
|
|
794
897
|
calculateRenderCoords() {
|
|
795
|
-
const {
|
|
796
|
-
const
|
|
898
|
+
const { w, h } = this.props;
|
|
899
|
+
const g = this.globalTransform;
|
|
900
|
+
const tx = g.tx, ty = g.ty, ta = g.ta, tb = g.tb, tc = g.tc, td = g.td;
|
|
797
901
|
if (tb === 0 && tc === 0) {
|
|
798
902
|
const minX = tx;
|
|
799
|
-
const maxX = tx +
|
|
903
|
+
const maxX = tx + w * ta;
|
|
800
904
|
const minY = ty;
|
|
801
|
-
const maxY = ty +
|
|
905
|
+
const maxY = ty + h * td;
|
|
802
906
|
this.renderCoords = RenderCoords.translate(
|
|
803
907
|
//top-left
|
|
804
908
|
minX, minY,
|
|
@@ -814,21 +918,21 @@ export class CoreNode extends EventEmitter {
|
|
|
814
918
|
//top-left
|
|
815
919
|
tx, ty,
|
|
816
920
|
//top-right
|
|
817
|
-
tx +
|
|
921
|
+
tx + w * ta, ty + w * tc,
|
|
818
922
|
//bottom-right
|
|
819
|
-
tx +
|
|
923
|
+
tx + w * ta + h * tb, ty + w * tc + h * td,
|
|
820
924
|
//bottom-left
|
|
821
|
-
tx +
|
|
925
|
+
tx + h * tb, ty + h * td, this.renderCoords);
|
|
822
926
|
}
|
|
823
|
-
if (this.sceneGlobalTransform === undefined) {
|
|
927
|
+
if (!USE_RTT || this.sceneGlobalTransform === undefined) {
|
|
824
928
|
return;
|
|
825
929
|
}
|
|
826
930
|
const { tx: stx, ty: sty, ta: sta, tb: stb, tc: stc, td: std, } = this.sceneGlobalTransform;
|
|
827
931
|
if (stb === 0 && stc === 0) {
|
|
828
932
|
const minX = stx;
|
|
829
|
-
const maxX = stx +
|
|
933
|
+
const maxX = stx + w * sta;
|
|
830
934
|
const minY = sty;
|
|
831
|
-
const maxY = sty +
|
|
935
|
+
const maxY = sty + h * std;
|
|
832
936
|
this.sceneRenderCoords = RenderCoords.translate(
|
|
833
937
|
//top-left
|
|
834
938
|
minX, minY,
|
|
@@ -844,11 +948,11 @@ export class CoreNode extends EventEmitter {
|
|
|
844
948
|
//top-left
|
|
845
949
|
stx, sty,
|
|
846
950
|
//top-right
|
|
847
|
-
stx +
|
|
951
|
+
stx + w * sta, sty + w * stc,
|
|
848
952
|
//bottom-right
|
|
849
|
-
stx +
|
|
953
|
+
stx + w * sta + h * stb, sty + w * stc + h * std,
|
|
850
954
|
//bottom-left
|
|
851
|
-
stx +
|
|
955
|
+
stx + h * stb, sty + h * std, this.sceneRenderCoords);
|
|
852
956
|
}
|
|
853
957
|
}
|
|
854
958
|
/**
|
|
@@ -860,15 +964,14 @@ export class CoreNode extends EventEmitter {
|
|
|
860
964
|
* Finally, the node's parentClippingRect and clippingRect properties are updated.
|
|
861
965
|
*/
|
|
862
966
|
calculateClippingRect(parentClippingRect) {
|
|
863
|
-
assertTruthy(this.globalTransform);
|
|
864
967
|
const { clippingRect, props, globalTransform: gt } = this;
|
|
865
968
|
const { clipping } = props;
|
|
866
969
|
const isRotated = gt.tb !== 0 || gt.tc !== 0;
|
|
867
970
|
if (clipping === true && isRotated === false) {
|
|
868
971
|
clippingRect.x = gt.tx;
|
|
869
972
|
clippingRect.y = gt.ty;
|
|
870
|
-
clippingRect.width = this.
|
|
871
|
-
clippingRect.height = this.
|
|
973
|
+
clippingRect.width = this.props.w * gt.ta;
|
|
974
|
+
clippingRect.height = this.props.h * gt.td;
|
|
872
975
|
clippingRect.valid = true;
|
|
873
976
|
}
|
|
874
977
|
else {
|
|
@@ -884,83 +987,154 @@ export class CoreNode extends EventEmitter {
|
|
|
884
987
|
clippingRect.valid = true;
|
|
885
988
|
}
|
|
886
989
|
}
|
|
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
990
|
/**
|
|
898
991
|
* Destroy the node and cleanup all resources
|
|
899
992
|
*/
|
|
900
|
-
destroy() {
|
|
993
|
+
destroy(isChild = false) {
|
|
994
|
+
if (this.destroyed === true) {
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
this.destroyed = true;
|
|
998
|
+
// Detach from parent first to stop propagation of updates
|
|
999
|
+
if (isChild === false) {
|
|
1000
|
+
const parent = this.parent;
|
|
1001
|
+
if (parent !== null) {
|
|
1002
|
+
parent.removeChild(this);
|
|
1003
|
+
}
|
|
1004
|
+
this.props.parent = null;
|
|
1005
|
+
this.stage.requestRender();
|
|
1006
|
+
}
|
|
1007
|
+
this.removeAllListeners();
|
|
901
1008
|
this.unloadTexture();
|
|
902
|
-
this.clippingRect.valid = false;
|
|
903
1009
|
this.isRenderable = false;
|
|
904
|
-
this.
|
|
905
|
-
|
|
906
|
-
this.strictBound = undefined;
|
|
907
|
-
this.preloadBound = undefined;
|
|
908
|
-
this.globalTransform = undefined;
|
|
909
|
-
this.scaleRotateTransform = undefined;
|
|
910
|
-
this.localTransform = undefined;
|
|
911
|
-
this.props.texture = null;
|
|
912
|
-
this.props.shader = this.stage.defShaderNode;
|
|
913
|
-
while (this.children.length > 0) {
|
|
914
|
-
this.children[0]?.destroy();
|
|
1010
|
+
if (this.hasShaderTimeFn === true) {
|
|
1011
|
+
this.stage.untrackTimedNode(this);
|
|
915
1012
|
}
|
|
916
|
-
|
|
917
|
-
this.parent = null;
|
|
918
|
-
if (this.rtt) {
|
|
1013
|
+
if (USE_RTT && this.rtt === true) {
|
|
919
1014
|
this.stage.renderer.removeRTTNode(this);
|
|
920
1015
|
}
|
|
921
|
-
|
|
1016
|
+
// Kill children
|
|
1017
|
+
for (let i = 0, n = this.children.length; i < n; i++) {
|
|
1018
|
+
this.children[i].destroy(true);
|
|
1019
|
+
}
|
|
1020
|
+
this.children.length = 0;
|
|
1021
|
+
this.props.texture = null;
|
|
922
1022
|
}
|
|
923
1023
|
renderQuads(renderer) {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
if (!renderer.renderToTextureActive) {
|
|
1024
|
+
if (USE_RTT && this.parentHasRenderTexture === true) {
|
|
1025
|
+
const rtt = renderer.renderToTextureActive;
|
|
1026
|
+
if (rtt === false || this.parentRenderTexture !== renderer.activeRttNode)
|
|
928
1027
|
return;
|
|
1028
|
+
}
|
|
1029
|
+
// There is a race condition where the texture can be null
|
|
1030
|
+
// with RTT nodes. Adding this defensively to avoid errors.
|
|
1031
|
+
// Also check if we have a valid texture or default texture to render
|
|
1032
|
+
if (USE_RTT && this.renderTexture.state !== 'loaded') {
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
renderer.addQuad(this);
|
|
1036
|
+
}
|
|
1037
|
+
get renderTexture() {
|
|
1038
|
+
return this.props.texture || this.stage.defaultTexture;
|
|
1039
|
+
}
|
|
1040
|
+
get renderTextureCoords() {
|
|
1041
|
+
return this.textureCoords || this.stage.renderer.defaultTextureCoords;
|
|
1042
|
+
}
|
|
1043
|
+
get quadBufferCollection() {
|
|
1044
|
+
return this.stage.renderer.quadBufferCollection;
|
|
1045
|
+
}
|
|
1046
|
+
get width() {
|
|
1047
|
+
return this.props.w;
|
|
1048
|
+
}
|
|
1049
|
+
get height() {
|
|
1050
|
+
return this.props.h;
|
|
1051
|
+
}
|
|
1052
|
+
get time() {
|
|
1053
|
+
if (this.hasShaderTimeFn === true) {
|
|
1054
|
+
return this.getTimerValue();
|
|
1055
|
+
}
|
|
1056
|
+
return 0;
|
|
1057
|
+
}
|
|
1058
|
+
getTimerValue() {
|
|
1059
|
+
if (typeof this.shader.time === 'function') {
|
|
1060
|
+
return this.shader.time(this.stage);
|
|
1061
|
+
}
|
|
1062
|
+
return this.stage.elapsedTime;
|
|
1063
|
+
}
|
|
1064
|
+
sortChildren() {
|
|
1065
|
+
this.children.sort((a, b) => a.props.zIndex - b.props.zIndex);
|
|
1066
|
+
this.stage.requestRenderListUpdate();
|
|
1067
|
+
}
|
|
1068
|
+
removeChild(node, targetParent = null) {
|
|
1069
|
+
if (targetParent === null) {
|
|
1070
|
+
if (USE_RTT &&
|
|
1071
|
+
this.props.rtt === true &&
|
|
1072
|
+
this.parentHasRenderTexture === true) {
|
|
1073
|
+
node.clearRTTInheritance();
|
|
929
1074
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
1075
|
+
if (ENABLE_AUTOSIZE) {
|
|
1076
|
+
const autosizeTarget = this.autosizer || this.parentAutosizer;
|
|
1077
|
+
if (autosizeTarget !== null) {
|
|
1078
|
+
autosizeTarget.detach(node);
|
|
1079
|
+
}
|
|
933
1080
|
}
|
|
934
1081
|
}
|
|
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
|
-
|
|
1082
|
+
removeChild(node, this.children);
|
|
1083
|
+
this.stage.requestRenderListUpdate();
|
|
1084
|
+
}
|
|
1085
|
+
addChild(node, previousParent = null) {
|
|
1086
|
+
const inRttCluster = USE_RTT &&
|
|
1087
|
+
(this.props.rtt === true || this.parentHasRenderTexture === true);
|
|
1088
|
+
const children = this.children;
|
|
1089
|
+
let attachToAutosizer = false;
|
|
1090
|
+
let autosizeTarget = null;
|
|
1091
|
+
if (ENABLE_AUTOSIZE) {
|
|
1092
|
+
autosizeTarget = this.autosizer || this.parentAutosizer;
|
|
1093
|
+
attachToAutosizer = autosizeTarget !== null;
|
|
1094
|
+
}
|
|
1095
|
+
node.parentHasRenderTexture = inRttCluster;
|
|
1096
|
+
if (previousParent !== null) {
|
|
1097
|
+
const previousParentInRttCluster = USE_RTT &&
|
|
1098
|
+
(previousParent.props.rtt === true ||
|
|
1099
|
+
previousParent.parentHasRenderTexture === true);
|
|
1100
|
+
if (inRttCluster === false && previousParentInRttCluster === true) {
|
|
1101
|
+
// update child RTT status
|
|
1102
|
+
node.clearRTTInheritance();
|
|
1103
|
+
}
|
|
1104
|
+
if (ENABLE_AUTOSIZE) {
|
|
1105
|
+
const previousAutosizer = node.autosizer || node.parentAutosizer;
|
|
1106
|
+
if (previousAutosizer !== null) {
|
|
1107
|
+
if (!autosizeTarget || previousAutosizer.id !== autosizeTarget.id) {
|
|
1108
|
+
previousAutosizer.detach(node);
|
|
1109
|
+
}
|
|
1110
|
+
attachToAutosizer = false;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
if (ENABLE_AUTOSIZE && attachToAutosizer === true && autosizeTarget) {
|
|
1115
|
+
//if this is true, then the autosizer really exists
|
|
1116
|
+
autosizeTarget.attach(node);
|
|
1117
|
+
}
|
|
1118
|
+
if (inRttCluster === true) {
|
|
1119
|
+
node.markChildrenWithRTT(this);
|
|
1120
|
+
}
|
|
1121
|
+
children.push(node);
|
|
1122
|
+
// check if we need to sort
|
|
1123
|
+
const lastIndex = children.length - 1;
|
|
1124
|
+
let shouldSort = node.zIndex !== 0;
|
|
1125
|
+
if (shouldSort === false && lastIndex > 0) {
|
|
1126
|
+
// If the new node has zIndex 0, we check if any existing children have (had) non-zero zIndex.
|
|
1127
|
+
// Since children are sorted, we only need to check the first and the last (before the new one).
|
|
1128
|
+
// The new node is at `lastIndex`. The previous last node is at `lastIndex - 1`.
|
|
1129
|
+
const first = children[0];
|
|
1130
|
+
const last = children[lastIndex - 1];
|
|
1131
|
+
shouldSort = first.zIndex !== 0 || last.zIndex !== 0;
|
|
1132
|
+
}
|
|
1133
|
+
if (shouldSort) {
|
|
1134
|
+
this.setUpdateType(UpdateType.SortZIndexChildren);
|
|
1135
|
+
}
|
|
1136
|
+
this.setUpdateType(UpdateType.Children);
|
|
1137
|
+
this.stage.requestRenderListUpdate();
|
|
964
1138
|
}
|
|
965
1139
|
//#region Properties
|
|
966
1140
|
get id() {
|
|
@@ -983,12 +1157,12 @@ export class CoreNode extends EventEmitter {
|
|
|
983
1157
|
}
|
|
984
1158
|
get absX() {
|
|
985
1159
|
return (this.props.x +
|
|
986
|
-
-this.props.
|
|
1160
|
+
-this.props.w * this.props.mountX +
|
|
987
1161
|
(this.props.parent?.absX || this.props.parent?.globalTransform?.tx || 0));
|
|
988
1162
|
}
|
|
989
1163
|
get absY() {
|
|
990
1164
|
return (this.props.y +
|
|
991
|
-
-this.props.
|
|
1165
|
+
-this.props.h * this.props.mountY +
|
|
992
1166
|
(this.props.parent?.absY ?? 0));
|
|
993
1167
|
}
|
|
994
1168
|
get y() {
|
|
@@ -1000,36 +1174,46 @@ export class CoreNode extends EventEmitter {
|
|
|
1000
1174
|
this.setUpdateType(UpdateType.Local);
|
|
1001
1175
|
}
|
|
1002
1176
|
}
|
|
1003
|
-
get
|
|
1004
|
-
return this.props.
|
|
1177
|
+
get w() {
|
|
1178
|
+
return this.props.w;
|
|
1005
1179
|
}
|
|
1006
|
-
set
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1180
|
+
set w(value) {
|
|
1181
|
+
const props = this.props;
|
|
1182
|
+
if (props.w !== value) {
|
|
1183
|
+
props.w = value;
|
|
1184
|
+
let updateType = UpdateType.Local;
|
|
1185
|
+
if (props.texture !== null &&
|
|
1186
|
+
this.stage.calculateTextureCoord === true &&
|
|
1187
|
+
props.textureOptions !== null) {
|
|
1188
|
+
this.textureCoords = this.stage.renderer.getTextureCoords(this);
|
|
1189
|
+
}
|
|
1190
|
+
if (props.rtt === true) {
|
|
1191
|
+
this.framebufferDimensions.w = value;
|
|
1192
|
+
this.texture = this.stage.txManager.createTexture('RenderTexture', this.framebufferDimensions);
|
|
1193
|
+
updateType |= UpdateType.RenderTexture;
|
|
1016
1194
|
}
|
|
1195
|
+
this.setUpdateType(updateType);
|
|
1017
1196
|
}
|
|
1018
1197
|
}
|
|
1019
|
-
get
|
|
1020
|
-
return this.props.
|
|
1198
|
+
get h() {
|
|
1199
|
+
return this.props.h;
|
|
1021
1200
|
}
|
|
1022
|
-
set
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
this.setUpdateType(UpdateType.RenderTexture);
|
|
1201
|
+
set h(value) {
|
|
1202
|
+
const props = this.props;
|
|
1203
|
+
if (props.h !== value) {
|
|
1204
|
+
props.h = value;
|
|
1205
|
+
let updateType = UpdateType.Local;
|
|
1206
|
+
if (props.texture !== null &&
|
|
1207
|
+
this.stage.calculateTextureCoord === true &&
|
|
1208
|
+
props.textureOptions !== null) {
|
|
1209
|
+
this.textureCoords = this.stage.renderer.getTextureCoords(this);
|
|
1032
1210
|
}
|
|
1211
|
+
if (props.rtt === true) {
|
|
1212
|
+
this.framebufferDimensions.h = value;
|
|
1213
|
+
this.texture = this.stage.txManager.createTexture('RenderTexture', this.framebufferDimensions);
|
|
1214
|
+
updateType |= UpdateType.RenderTexture;
|
|
1215
|
+
}
|
|
1216
|
+
this.setUpdateType(updateType);
|
|
1033
1217
|
}
|
|
1034
1218
|
}
|
|
1035
1219
|
get scale() {
|
|
@@ -1042,6 +1226,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1042
1226
|
// Unlike INode, `null` should never be possibility for Animations.
|
|
1043
1227
|
this.scaleX = value;
|
|
1044
1228
|
this.scaleY = value;
|
|
1229
|
+
this.updateIsSimple();
|
|
1045
1230
|
}
|
|
1046
1231
|
get scaleX() {
|
|
1047
1232
|
return this.props.scaleX;
|
|
@@ -1049,7 +1234,8 @@ export class CoreNode extends EventEmitter {
|
|
|
1049
1234
|
set scaleX(value) {
|
|
1050
1235
|
if (this.props.scaleX !== value) {
|
|
1051
1236
|
this.props.scaleX = value;
|
|
1052
|
-
this.setUpdateType(UpdateType.
|
|
1237
|
+
this.setUpdateType(UpdateType.Local);
|
|
1238
|
+
this.updateIsSimple();
|
|
1053
1239
|
}
|
|
1054
1240
|
}
|
|
1055
1241
|
get scaleY() {
|
|
@@ -1058,7 +1244,8 @@ export class CoreNode extends EventEmitter {
|
|
|
1058
1244
|
set scaleY(value) {
|
|
1059
1245
|
if (this.props.scaleY !== value) {
|
|
1060
1246
|
this.props.scaleY = value;
|
|
1061
|
-
this.setUpdateType(UpdateType.
|
|
1247
|
+
this.setUpdateType(UpdateType.Local);
|
|
1248
|
+
this.updateIsSimple();
|
|
1062
1249
|
}
|
|
1063
1250
|
}
|
|
1064
1251
|
get mount() {
|
|
@@ -1070,6 +1257,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1070
1257
|
this.props.mountY = value;
|
|
1071
1258
|
this.props.mount = value;
|
|
1072
1259
|
this.setUpdateType(UpdateType.Local);
|
|
1260
|
+
this.updateIsSimple();
|
|
1073
1261
|
}
|
|
1074
1262
|
}
|
|
1075
1263
|
get mountX() {
|
|
@@ -1079,6 +1267,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1079
1267
|
if (this.props.mountX !== value) {
|
|
1080
1268
|
this.props.mountX = value;
|
|
1081
1269
|
this.setUpdateType(UpdateType.Local);
|
|
1270
|
+
this.updateIsSimple();
|
|
1082
1271
|
}
|
|
1083
1272
|
}
|
|
1084
1273
|
get mountY() {
|
|
@@ -1088,6 +1277,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1088
1277
|
if (this.props.mountY !== value) {
|
|
1089
1278
|
this.props.mountY = value;
|
|
1090
1279
|
this.setUpdateType(UpdateType.Local);
|
|
1280
|
+
this.updateIsSimple();
|
|
1091
1281
|
}
|
|
1092
1282
|
}
|
|
1093
1283
|
get pivot() {
|
|
@@ -1125,7 +1315,8 @@ export class CoreNode extends EventEmitter {
|
|
|
1125
1315
|
set rotation(value) {
|
|
1126
1316
|
if (this.props.rotation !== value) {
|
|
1127
1317
|
this.props.rotation = value;
|
|
1128
|
-
this.setUpdateType(UpdateType.
|
|
1318
|
+
this.setUpdateType(UpdateType.Local);
|
|
1319
|
+
this.updateIsSimple();
|
|
1129
1320
|
}
|
|
1130
1321
|
}
|
|
1131
1322
|
get alpha() {
|
|
@@ -1143,12 +1334,30 @@ export class CoreNode extends EventEmitter {
|
|
|
1143
1334
|
return this.props.autosize;
|
|
1144
1335
|
}
|
|
1145
1336
|
set autosize(value) {
|
|
1337
|
+
if (this.props.autosize === value) {
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1146
1340
|
this.props.autosize = value;
|
|
1341
|
+
if (value === true && this.autosizer === null) {
|
|
1342
|
+
this.autosizer = new Autosizer(this);
|
|
1343
|
+
}
|
|
1344
|
+
else {
|
|
1345
|
+
this.autosizer = null;
|
|
1346
|
+
}
|
|
1147
1347
|
}
|
|
1148
1348
|
get boundsMargin() {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1349
|
+
const props = this.props;
|
|
1350
|
+
if (props.boundsMargin !== null) {
|
|
1351
|
+
return props.boundsMargin;
|
|
1352
|
+
}
|
|
1353
|
+
const parent = this.parent;
|
|
1354
|
+
if (parent !== null) {
|
|
1355
|
+
const margin = parent.boundsMargin;
|
|
1356
|
+
if (margin !== undefined) {
|
|
1357
|
+
return margin;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
return this.stage.boundsMargin;
|
|
1152
1361
|
}
|
|
1153
1362
|
set boundsMargin(value) {
|
|
1154
1363
|
if (value === this.props.boundsMargin) {
|
|
@@ -1177,11 +1386,23 @@ export class CoreNode extends EventEmitter {
|
|
|
1177
1386
|
return this.props.color;
|
|
1178
1387
|
}
|
|
1179
1388
|
set color(value) {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1389
|
+
const p = this.props;
|
|
1390
|
+
if (p.color === value)
|
|
1391
|
+
return;
|
|
1392
|
+
p.color = value;
|
|
1393
|
+
const has = value > 0;
|
|
1394
|
+
if (has !== this.hasColorProps) {
|
|
1395
|
+
this.setUpdateType(UpdateType.IsRenderable);
|
|
1396
|
+
}
|
|
1397
|
+
this.hasColorProps = has;
|
|
1398
|
+
if (p.colorTop !== value)
|
|
1399
|
+
this.colorTop = value;
|
|
1400
|
+
if (p.colorBottom !== value)
|
|
1401
|
+
this.colorBottom = value;
|
|
1402
|
+
if (p.colorLeft !== value)
|
|
1403
|
+
this.colorLeft = value;
|
|
1404
|
+
if (p.colorRight !== value)
|
|
1405
|
+
this.colorRight = value;
|
|
1185
1406
|
this.setUpdateType(UpdateType.PremultipliedColors);
|
|
1186
1407
|
}
|
|
1187
1408
|
get colorTop() {
|
|
@@ -1193,7 +1414,8 @@ export class CoreNode extends EventEmitter {
|
|
|
1193
1414
|
this.colorTr = value;
|
|
1194
1415
|
}
|
|
1195
1416
|
this.props.colorTop = value;
|
|
1196
|
-
this.
|
|
1417
|
+
this.hasColorProps = value > 0;
|
|
1418
|
+
this.setUpdateType(UpdateType.PremultipliedColors | UpdateType.IsRenderable);
|
|
1197
1419
|
}
|
|
1198
1420
|
get colorBottom() {
|
|
1199
1421
|
return this.props.colorBottom;
|
|
@@ -1204,7 +1426,8 @@ export class CoreNode extends EventEmitter {
|
|
|
1204
1426
|
this.colorBr = value;
|
|
1205
1427
|
}
|
|
1206
1428
|
this.props.colorBottom = value;
|
|
1207
|
-
this.
|
|
1429
|
+
this.hasColorProps = value > 0;
|
|
1430
|
+
this.setUpdateType(UpdateType.PremultipliedColors | UpdateType.IsRenderable);
|
|
1208
1431
|
}
|
|
1209
1432
|
get colorLeft() {
|
|
1210
1433
|
return this.props.colorLeft;
|
|
@@ -1215,7 +1438,8 @@ export class CoreNode extends EventEmitter {
|
|
|
1215
1438
|
this.colorBl = value;
|
|
1216
1439
|
}
|
|
1217
1440
|
this.props.colorLeft = value;
|
|
1218
|
-
this.
|
|
1441
|
+
this.hasColorProps = value > 0;
|
|
1442
|
+
this.setUpdateType(UpdateType.PremultipliedColors | UpdateType.IsRenderable);
|
|
1219
1443
|
}
|
|
1220
1444
|
get colorRight() {
|
|
1221
1445
|
return this.props.colorRight;
|
|
@@ -1226,56 +1450,64 @@ export class CoreNode extends EventEmitter {
|
|
|
1226
1450
|
this.colorBr = value;
|
|
1227
1451
|
}
|
|
1228
1452
|
this.props.colorRight = value;
|
|
1229
|
-
this.
|
|
1453
|
+
this.hasColorProps = value > 0;
|
|
1454
|
+
this.setUpdateType(UpdateType.PremultipliedColors | UpdateType.IsRenderable);
|
|
1230
1455
|
}
|
|
1231
1456
|
get colorTl() {
|
|
1232
1457
|
return this.props.colorTl;
|
|
1233
1458
|
}
|
|
1234
1459
|
set colorTl(value) {
|
|
1235
1460
|
this.props.colorTl = value;
|
|
1236
|
-
this.
|
|
1461
|
+
this.hasColorProps = value > 0;
|
|
1462
|
+
this.setUpdateType(UpdateType.PremultipliedColors | UpdateType.IsRenderable);
|
|
1237
1463
|
}
|
|
1238
1464
|
get colorTr() {
|
|
1239
1465
|
return this.props.colorTr;
|
|
1240
1466
|
}
|
|
1241
1467
|
set colorTr(value) {
|
|
1242
1468
|
this.props.colorTr = value;
|
|
1243
|
-
this.
|
|
1469
|
+
this.hasColorProps = value > 0;
|
|
1470
|
+
this.setUpdateType(UpdateType.PremultipliedColors | UpdateType.IsRenderable);
|
|
1244
1471
|
}
|
|
1245
1472
|
get colorBl() {
|
|
1246
1473
|
return this.props.colorBl;
|
|
1247
1474
|
}
|
|
1248
1475
|
set colorBl(value) {
|
|
1249
1476
|
this.props.colorBl = value;
|
|
1250
|
-
this.
|
|
1477
|
+
this.hasColorProps = value > 0;
|
|
1478
|
+
this.setUpdateType(UpdateType.PremultipliedColors | UpdateType.IsRenderable);
|
|
1251
1479
|
}
|
|
1252
1480
|
get colorBr() {
|
|
1253
1481
|
return this.props.colorBr;
|
|
1254
1482
|
}
|
|
1255
1483
|
set colorBr(value) {
|
|
1256
1484
|
this.props.colorBr = value;
|
|
1257
|
-
this.
|
|
1258
|
-
|
|
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
|
-
}
|
|
1485
|
+
this.hasColorProps = value > 0;
|
|
1486
|
+
this.setUpdateType(UpdateType.PremultipliedColors | UpdateType.IsRenderable);
|
|
1270
1487
|
}
|
|
1271
1488
|
get zIndex() {
|
|
1272
1489
|
return this.props.zIndex;
|
|
1273
1490
|
}
|
|
1274
1491
|
set zIndex(value) {
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1492
|
+
let sanitizedValue = value;
|
|
1493
|
+
if (isNaN(sanitizedValue) || Number.isFinite(sanitizedValue) === false) {
|
|
1494
|
+
console.warn(`zIndex was set to an invalid value: ${value}, defaulting to 0`);
|
|
1495
|
+
sanitizedValue = 0;
|
|
1496
|
+
}
|
|
1497
|
+
//Clamp to safe integer range
|
|
1498
|
+
if (sanitizedValue > Number.MAX_SAFE_INTEGER) {
|
|
1499
|
+
sanitizedValue = 1000;
|
|
1500
|
+
}
|
|
1501
|
+
else if (sanitizedValue < Number.MIN_SAFE_INTEGER) {
|
|
1502
|
+
sanitizedValue = -1000;
|
|
1503
|
+
}
|
|
1504
|
+
if (this.props.zIndex === sanitizedValue) {
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
this.props.zIndex = sanitizedValue;
|
|
1508
|
+
const parent = this.parent;
|
|
1509
|
+
if (parent !== null) {
|
|
1510
|
+
parent.setUpdateType(UpdateType.SortZIndexChildren);
|
|
1279
1511
|
}
|
|
1280
1512
|
}
|
|
1281
1513
|
get parent() {
|
|
@@ -1288,34 +1520,13 @@ export class CoreNode extends EventEmitter {
|
|
|
1288
1520
|
}
|
|
1289
1521
|
this.props.parent = newParent;
|
|
1290
1522
|
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
|
-
}
|
|
1523
|
+
oldParent.removeChild(this, newParent);
|
|
1306
1524
|
}
|
|
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');
|
|
1525
|
+
if (newParent !== null) {
|
|
1526
|
+
newParent.addChild(this, oldParent);
|
|
1317
1527
|
}
|
|
1318
|
-
this
|
|
1528
|
+
//since this node has a new parent, recalc global and render bounds
|
|
1529
|
+
this.setUpdateType(UpdateType.Global | UpdateType.RenderBounds);
|
|
1319
1530
|
}
|
|
1320
1531
|
get rtt() {
|
|
1321
1532
|
return this.props.rtt;
|
|
@@ -1338,10 +1549,11 @@ export class CoreNode extends EventEmitter {
|
|
|
1338
1549
|
}
|
|
1339
1550
|
}
|
|
1340
1551
|
initRenderTexture() {
|
|
1341
|
-
this.
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
}
|
|
1552
|
+
this.framebufferDimensions = {
|
|
1553
|
+
w: this.props.w,
|
|
1554
|
+
h: this.props.h,
|
|
1555
|
+
};
|
|
1556
|
+
this.texture = this.stage.txManager.createTexture('RenderTexture', this.framebufferDimensions);
|
|
1345
1557
|
this.stage.renderer.renderToTexture(this);
|
|
1346
1558
|
}
|
|
1347
1559
|
cleanupRenderTexture() {
|
|
@@ -1349,6 +1561,7 @@ export class CoreNode extends EventEmitter {
|
|
|
1349
1561
|
this.clearRTTInheritance();
|
|
1350
1562
|
this.hasRTTupdates = false;
|
|
1351
1563
|
this.texture = null;
|
|
1564
|
+
this.framebufferDimensions = null;
|
|
1352
1565
|
}
|
|
1353
1566
|
markChildrenWithRTT(node = null) {
|
|
1354
1567
|
const parent = node || this;
|
|
@@ -1390,13 +1603,24 @@ export class CoreNode extends EventEmitter {
|
|
|
1390
1603
|
return;
|
|
1391
1604
|
}
|
|
1392
1605
|
if (shader === null) {
|
|
1606
|
+
this.hasShaderUpdater = false;
|
|
1393
1607
|
this.props.shader = this.stage.defShaderNode;
|
|
1394
1608
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
1395
1609
|
return;
|
|
1396
1610
|
}
|
|
1397
|
-
shader.
|
|
1611
|
+
if (shader.shaderKey !== 'default') {
|
|
1612
|
+
this.hasShaderUpdater = shader.update !== undefined;
|
|
1613
|
+
this.hasShaderTimeFn = shader.time !== undefined;
|
|
1614
|
+
shader.attachNode(this);
|
|
1615
|
+
}
|
|
1616
|
+
if (this.hasShaderTimeFn === true) {
|
|
1617
|
+
this.stage.trackTimedNode(this);
|
|
1618
|
+
}
|
|
1619
|
+
else {
|
|
1620
|
+
this.stage.untrackTimedNode(this);
|
|
1621
|
+
}
|
|
1398
1622
|
this.props.shader = shader;
|
|
1399
|
-
this.setUpdateType(UpdateType.IsRenderable);
|
|
1623
|
+
this.setUpdateType(UpdateType.IsRenderable | UpdateType.RecalcUniforms);
|
|
1400
1624
|
}
|
|
1401
1625
|
get src() {
|
|
1402
1626
|
return this.props.src;
|
|
@@ -1412,8 +1636,8 @@ export class CoreNode extends EventEmitter {
|
|
|
1412
1636
|
}
|
|
1413
1637
|
this.texture = this.stage.txManager.createTexture('ImageTexture', {
|
|
1414
1638
|
src: imageUrl,
|
|
1415
|
-
|
|
1416
|
-
|
|
1639
|
+
w: this.props.w,
|
|
1640
|
+
h: this.props.h,
|
|
1417
1641
|
type: this.props.imageType,
|
|
1418
1642
|
sx: this.props.srcX,
|
|
1419
1643
|
sy: this.props.srcY,
|
|
@@ -1455,16 +1679,14 @@ export class CoreNode extends EventEmitter {
|
|
|
1455
1679
|
this.props.srcY = value;
|
|
1456
1680
|
}
|
|
1457
1681
|
/**
|
|
1458
|
-
* Returns the framebuffer dimensions of the
|
|
1459
|
-
* If the node has a render texture, the dimensions are the same as the node's dimensions.
|
|
1460
|
-
* If the node does not have a render texture, the dimensions are inherited from the parent.
|
|
1461
|
-
* If the node parent has a render texture and the node is a render texture, the nodes dimensions are used.
|
|
1682
|
+
* Returns the framebuffer dimensions of the RTT parent
|
|
1462
1683
|
*/
|
|
1463
|
-
get
|
|
1464
|
-
if (this.
|
|
1465
|
-
return this.
|
|
1684
|
+
get parentFramebufferDimensions() {
|
|
1685
|
+
if (this.rttParent !== null) {
|
|
1686
|
+
return this.rttParent.framebufferDimensions;
|
|
1466
1687
|
}
|
|
1467
|
-
|
|
1688
|
+
this.rttParent = this.findParentRTTNode();
|
|
1689
|
+
return this.rttParent ? this.rttParent.framebufferDimensions : null;
|
|
1468
1690
|
}
|
|
1469
1691
|
/**
|
|
1470
1692
|
* Returns the parent render texture node if it exists.
|
|
@@ -1488,32 +1710,47 @@ export class CoreNode extends EventEmitter {
|
|
|
1488
1710
|
}
|
|
1489
1711
|
const oldTexture = this.props.texture;
|
|
1490
1712
|
if (oldTexture) {
|
|
1491
|
-
oldTexture.setRenderableOwner(this, false);
|
|
1492
1713
|
this.unloadTexture();
|
|
1714
|
+
if (this.autosizer !== null && value === null) {
|
|
1715
|
+
this.autosizer.setMode(AutosizeMode.Children); // Set to children size mode
|
|
1716
|
+
}
|
|
1493
1717
|
}
|
|
1718
|
+
this.textureCoords = undefined;
|
|
1494
1719
|
this.props.texture = value;
|
|
1720
|
+
this.textureLoaded = value !== null && value.state === 'loaded';
|
|
1495
1721
|
if (value !== null) {
|
|
1496
|
-
|
|
1722
|
+
if (this.autosizer !== null) {
|
|
1723
|
+
this.autosizer.setMode(AutosizeMode.Texture); // Set to texture size mode
|
|
1724
|
+
}
|
|
1725
|
+
value.setRenderableOwner(this._id, this.isRenderable);
|
|
1497
1726
|
this.loadTexture();
|
|
1498
1727
|
}
|
|
1499
1728
|
this.setUpdateType(UpdateType.IsRenderable);
|
|
1729
|
+
this.updateIsSimple();
|
|
1500
1730
|
}
|
|
1501
1731
|
set textureOptions(value) {
|
|
1502
1732
|
this.props.textureOptions = value;
|
|
1733
|
+
if (this.stage.calculateTextureCoord === true && value !== null) {
|
|
1734
|
+
this.textureCoords = this.stage.renderer.getTextureCoords(this);
|
|
1735
|
+
}
|
|
1736
|
+
this.updateIsSimple();
|
|
1503
1737
|
}
|
|
1504
1738
|
get textureOptions() {
|
|
1505
1739
|
return this.props.textureOptions;
|
|
1506
1740
|
}
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
return;
|
|
1741
|
+
set interactive(value) {
|
|
1742
|
+
this.props.interactive = value;
|
|
1743
|
+
// Update Stage's interactive Set
|
|
1744
|
+
if (value === true) {
|
|
1745
|
+
this.stage.interactiveNodes.add(this);
|
|
1513
1746
|
}
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
this.
|
|
1747
|
+
}
|
|
1748
|
+
get interactive() {
|
|
1749
|
+
return this.props.interactive;
|
|
1750
|
+
}
|
|
1751
|
+
setRTTUpdates(type) {
|
|
1752
|
+
this.hasRTTupdates = true;
|
|
1753
|
+
this.parent?.setRTTUpdates(type);
|
|
1517
1754
|
}
|
|
1518
1755
|
animate(props, settings) {
|
|
1519
1756
|
const animation = new CoreAnimation(this, props, settings);
|
|
@@ -1523,5 +1760,53 @@ export class CoreNode extends EventEmitter {
|
|
|
1523
1760
|
flush() {
|
|
1524
1761
|
// no-op
|
|
1525
1762
|
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Add a texture to the current RenderOp.
|
|
1765
|
+
*
|
|
1766
|
+
* @param texture
|
|
1767
|
+
* @returns Assigned Texture Index of the texture in the render op
|
|
1768
|
+
*/
|
|
1769
|
+
addTexture(texture) {
|
|
1770
|
+
const textures = this.renderOpTextures;
|
|
1771
|
+
const length = textures.length;
|
|
1772
|
+
for (let i = 0; i < length; i++) {
|
|
1773
|
+
if (textures[i] === texture) {
|
|
1774
|
+
return i;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
if (length >= 1) {
|
|
1778
|
+
return 0xffffffff;
|
|
1779
|
+
}
|
|
1780
|
+
textures.push(texture);
|
|
1781
|
+
return length;
|
|
1782
|
+
}
|
|
1783
|
+
draw(renderer) {
|
|
1784
|
+
const { glw, options, stage } = renderer;
|
|
1785
|
+
const shader = this.props.shader;
|
|
1786
|
+
stage.shManager.useShader(shader.program);
|
|
1787
|
+
shader.program.bindRenderOp(this);
|
|
1788
|
+
// Clipping
|
|
1789
|
+
if (this.clippingRect.valid === true) {
|
|
1790
|
+
const pixelRatio = USE_RTT && this.parentHasRenderTexture ? 1 : stage.pixelRatio;
|
|
1791
|
+
const clipX = Math.round(this.clippingRect.x * pixelRatio);
|
|
1792
|
+
const clipWidth = Math.round(this.clippingRect.width * pixelRatio);
|
|
1793
|
+
const clipHeight = Math.round(this.clippingRect.height * pixelRatio);
|
|
1794
|
+
let clipY = Math.round(options.canvas.height - clipHeight - this.clippingRect.y * pixelRatio);
|
|
1795
|
+
// if parent has render texture, we need to adjust the scissor rect
|
|
1796
|
+
// to be relative to the parent's framebuffer
|
|
1797
|
+
if (USE_RTT && this.parentHasRenderTexture) {
|
|
1798
|
+
clipY = this.parentFramebufferDimensions
|
|
1799
|
+
? this.parentFramebufferDimensions.h - this.props.h
|
|
1800
|
+
: 0;
|
|
1801
|
+
}
|
|
1802
|
+
glw.setScissorTest(true);
|
|
1803
|
+
glw.scissor(clipX, clipY, clipWidth, clipHeight);
|
|
1804
|
+
}
|
|
1805
|
+
else {
|
|
1806
|
+
glw.setScissorTest(false);
|
|
1807
|
+
}
|
|
1808
|
+
const quadIdx = (this.renderOpBufferIdx / 20) * 6 * 2;
|
|
1809
|
+
glw.drawElements(glw.TRIANGLES, 6 * this.numQuads, glw.UNSIGNED_SHORT, quadIdx);
|
|
1810
|
+
}
|
|
1526
1811
|
}
|
|
1527
1812
|
//# sourceMappingURL=CoreNode.js.map
|