@lightningjs/renderer 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +184 -0
- package/dist/exports/core-api.d.ts +73 -0
- package/dist/exports/core-api.js +95 -0
- package/dist/exports/core-api.js.map +1 -0
- package/dist/exports/main-api.d.ts +28 -0
- package/dist/exports/main-api.js +45 -0
- package/dist/exports/main-api.js.map +1 -0
- package/dist/exports/utils.d.ts +23 -0
- package/dist/exports/utils.js +42 -0
- package/dist/exports/utils.js.map +1 -0
- package/dist/src/common/CommonTypes.d.ts +38 -0
- package/dist/src/common/CommonTypes.js +20 -0
- package/dist/src/common/CommonTypes.js.map +1 -0
- package/dist/src/common/EventEmitter.d.ts +12 -0
- package/dist/src/common/EventEmitter.js +66 -0
- package/dist/src/common/EventEmitter.js.map +1 -0
- package/dist/src/common/IAnimationController.d.ts +9 -0
- package/dist/src/common/IAnimationController.js +20 -0
- package/dist/src/common/IAnimationController.js.map +1 -0
- package/dist/src/core/CoreExtension.d.ts +12 -0
- package/dist/src/core/CoreExtension.js +29 -0
- package/dist/src/core/CoreExtension.js.map +1 -0
- package/dist/src/core/CoreNode.d.ts +147 -0
- package/dist/src/core/CoreNode.js +498 -0
- package/dist/src/core/CoreNode.js.map +1 -0
- package/dist/src/core/CoreShaderManager.d.ts +29 -0
- package/dist/src/core/CoreShaderManager.js +58 -0
- package/dist/src/core/CoreShaderManager.js.map +1 -0
- package/dist/src/core/CoreTextNode.d.ts +64 -0
- package/dist/src/core/CoreTextNode.js +251 -0
- package/dist/src/core/CoreTextNode.js.map +1 -0
- package/dist/src/core/CoreTextureManager.d.ts +173 -0
- package/dist/src/core/CoreTextureManager.js +190 -0
- package/dist/src/core/CoreTextureManager.js.map +1 -0
- package/dist/src/core/Matrix2DContext.d.ts +15 -0
- package/dist/src/core/Matrix2DContext.js +45 -0
- package/dist/src/core/Matrix2DContext.js.map +1 -0
- package/dist/src/core/Stage.d.ts +53 -0
- package/dist/src/core/Stage.js +214 -0
- package/dist/src/core/Stage.js.map +1 -0
- package/dist/src/core/animations/AnimationManager.d.ts +7 -0
- package/dist/src/core/animations/AnimationManager.js +34 -0
- package/dist/src/core/animations/AnimationManager.js.map +1 -0
- package/dist/src/core/animations/CoreAnimation.d.ts +27 -0
- package/dist/src/core/animations/CoreAnimation.js +103 -0
- package/dist/src/core/animations/CoreAnimation.js.map +1 -0
- package/dist/src/core/animations/CoreAnimationController.d.ts +21 -0
- package/dist/src/core/animations/CoreAnimationController.js +96 -0
- package/dist/src/core/animations/CoreAnimationController.js.map +1 -0
- package/dist/src/core/lib/glm/common.d.ts +162 -0
- package/dist/src/core/lib/glm/common.js +81 -0
- package/dist/src/core/lib/glm/common.js.map +1 -0
- package/dist/src/core/lib/glm/index.d.ts +11 -0
- package/dist/src/core/lib/glm/index.js +30 -0
- package/dist/src/core/lib/glm/index.js.map +1 -0
- package/dist/src/core/lib/glm/mat2.d.ts +219 -0
- package/dist/src/core/lib/glm/mat2.js +396 -0
- package/dist/src/core/lib/glm/mat2.js.map +1 -0
- package/dist/src/core/lib/glm/mat2d.d.ts +237 -0
- package/dist/src/core/lib/glm/mat2d.js +442 -0
- package/dist/src/core/lib/glm/mat2d.js.map +1 -0
- package/dist/src/core/lib/glm/mat3.d.ts +283 -0
- package/dist/src/core/lib/glm/mat3.js +680 -0
- package/dist/src/core/lib/glm/mat3.js.map +1 -0
- package/dist/src/core/lib/glm/mat4.d.ts +550 -0
- package/dist/src/core/lib/glm/mat4.js +1802 -0
- package/dist/src/core/lib/glm/mat4.js.map +1 -0
- package/dist/src/core/lib/glm/quat.d.ts +363 -0
- package/dist/src/core/lib/glm/quat.js +693 -0
- package/dist/src/core/lib/glm/quat.js.map +1 -0
- package/dist/src/core/lib/glm/quat2.d.ts +356 -0
- package/dist/src/core/lib/glm/quat2.js +754 -0
- package/dist/src/core/lib/glm/quat2.js.map +1 -0
- package/dist/src/core/lib/glm/vec2.d.ts +365 -0
- package/dist/src/core/lib/glm/vec2.js +569 -0
- package/dist/src/core/lib/glm/vec2.js.map +1 -0
- package/dist/src/core/lib/glm/vec3.d.ts +406 -0
- package/dist/src/core/lib/glm/vec3.js +720 -0
- package/dist/src/core/lib/glm/vec3.js.map +1 -0
- package/dist/src/core/lib/glm/vec4.d.ts +330 -0
- package/dist/src/core/lib/glm/vec4.js +608 -0
- package/dist/src/core/lib/glm/vec4.js.map +1 -0
- package/dist/src/core/lib/utils.d.ts +27 -0
- package/dist/src/core/lib/utils.js +108 -0
- package/dist/src/core/lib/utils.js.map +1 -0
- package/dist/src/core/platform.d.ts +10 -0
- package/dist/src/core/platform.js +37 -0
- package/dist/src/core/platform.js.map +1 -0
- package/dist/src/core/renderers/CoreContextTexture.d.ts +6 -0
- package/dist/src/core/renderers/CoreContextTexture.js +25 -0
- package/dist/src/core/renderers/CoreContextTexture.js.map +1 -0
- package/dist/src/core/renderers/CoreRenderOp.d.ts +3 -0
- package/dist/src/core/renderers/CoreRenderOp.js +21 -0
- package/dist/src/core/renderers/CoreRenderOp.js.map +1 -0
- package/dist/src/core/renderers/CoreRenderer.d.ts +39 -0
- package/dist/src/core/renderers/CoreRenderer.js +26 -0
- package/dist/src/core/renderers/CoreRenderer.js.map +1 -0
- package/dist/src/core/renderers/CoreShader.d.ts +9 -0
- package/dist/src/core/renderers/CoreShader.js +28 -0
- package/dist/src/core/renderers/CoreShader.js.map +1 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.d.ts +7 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js +32 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js.map +1 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.d.ts +46 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js +163 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js.map +1 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.d.ts +27 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js +82 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js.map +1 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.d.ts +100 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +372 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -0
- package/dist/src/core/renderers/webgl/WebGlCoreShader.d.ts +39 -0
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js +187 -0
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js.map +1 -0
- package/dist/src/core/renderers/webgl/internal/BufferCollection.d.ts +27 -0
- package/dist/src/core/renderers/webgl/internal/BufferCollection.js +48 -0
- package/dist/src/core/renderers/webgl/internal/BufferCollection.js.map +1 -0
- package/dist/src/core/renderers/webgl/internal/RendererUtils.d.ts +39 -0
- package/dist/src/core/renderers/webgl/internal/RendererUtils.js +92 -0
- package/dist/src/core/renderers/webgl/internal/RendererUtils.js.map +1 -0
- package/dist/src/core/renderers/webgl/internal/ShaderUtils.d.ts +46 -0
- package/dist/src/core/renderers/webgl/internal/ShaderUtils.js +50 -0
- package/dist/src/core/renderers/webgl/internal/ShaderUtils.js.map +1 -0
- package/dist/src/core/renderers/webgl/internal/WebGlUtils.d.ts +10 -0
- package/dist/src/core/renderers/webgl/internal/WebGlUtils.js +31 -0
- package/dist/src/core/renderers/webgl/internal/WebGlUtils.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.d.ts +9 -0
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.js +89 -0
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.d.ts +10 -0
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js +119 -0
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.d.ts +53 -0
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js +299 -0
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.d.ts +29 -0
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js +135 -0
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/SdfShader.d.ts +45 -0
- package/dist/src/core/renderers/webgl/shaders/SdfShader.js +137 -0
- package/dist/src/core/renderers/webgl/shaders/SdfShader.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.d.ts +15 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js +68 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.d.ts +14 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js +54 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.d.ts +15 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js +68 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.d.ts +15 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js +68 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.d.ts +15 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js +68 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.d.ts +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js +33 -0
- package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.d.ts +17 -0
- package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js +98 -0
- package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.d.ts +6 -0
- package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js +32 -0
- package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.d.ts +16 -0
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js +140 -0
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.d.ts +14 -0
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js +82 -0
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.d.ts +44 -0
- package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js +61 -0
- package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js.map +1 -0
- package/dist/src/core/scene/Scene.d.ts +59 -0
- package/dist/src/core/scene/Scene.js +106 -0
- package/dist/src/core/scene/Scene.js.map +1 -0
- package/dist/src/core/text-rendering/TextTextureRendererUtils.d.ts +53 -0
- package/dist/src/core/text-rendering/TextTextureRendererUtils.js +156 -0
- package/dist/src/core/text-rendering/TextTextureRendererUtils.js.map +1 -0
- package/dist/src/core/text-rendering/TrFontManager.d.ts +25 -0
- package/dist/src/core/text-rendering/TrFontManager.js +75 -0
- package/dist/src/core/text-rendering/TrFontManager.js.map +1 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.d.ts +29 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js +88 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js.map +1 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.d.ts +103 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.js +21 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.js.map +1 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.d.ts +59 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.js +86 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.js.map +1 -0
- package/dist/src/core/text-rendering/font-face-types/TrFontFace.d.ts +48 -0
- package/dist/src/core/text-rendering/font-face-types/TrFontFace.js +54 -0
- package/dist/src/core/text-rendering/font-face-types/TrFontFace.js.map +1 -0
- package/dist/src/core/text-rendering/font-face-types/WebTrFontFace.d.ts +11 -0
- package/dist/src/core/text-rendering/font-face-types/WebTrFontFace.js +54 -0
- package/dist/src/core/text-rendering/font-face-types/WebTrFontFace.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.d.ts +45 -0
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js +492 -0
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.d.ts +115 -0
- package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.js +493 -0
- package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.d.ts +67 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js +452 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.d.ts +12 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.js +61 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.d.ts +33 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.js +52 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.d.ts +13 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.js +32 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.d.ts +21 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.js +53 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.d.ts +4 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.js +34 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.d.ts +18 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js +294 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.d.ts +20 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js +55 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.d.ts +10 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.js +39 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/TextRenderer.d.ts +254 -0
- package/dist/src/core/text-rendering/renderers/TextRenderer.js +100 -0
- package/dist/src/core/text-rendering/renderers/TextRenderer.js.map +1 -0
- package/dist/src/core/textures/ColorTexture.d.ts +35 -0
- package/dist/src/core/textures/ColorTexture.js +62 -0
- package/dist/src/core/textures/ColorTexture.js.map +1 -0
- package/dist/src/core/textures/ImageTexture.d.ts +51 -0
- package/dist/src/core/textures/ImageTexture.js +76 -0
- package/dist/src/core/textures/ImageTexture.js.map +1 -0
- package/dist/src/core/textures/NoiseTexture.d.ts +42 -0
- package/dist/src/core/textures/NoiseTexture.js +63 -0
- package/dist/src/core/textures/NoiseTexture.js.map +1 -0
- package/dist/src/core/textures/SubTexture.d.ts +57 -0
- package/dist/src/core/textures/SubTexture.js +82 -0
- package/dist/src/core/textures/SubTexture.js.map +1 -0
- package/dist/src/core/textures/Texture.d.ts +92 -0
- package/dist/src/core/textures/Texture.js +105 -0
- package/dist/src/core/textures/Texture.js.map +1 -0
- package/dist/src/core/utils.d.ts +15 -0
- package/dist/src/core/utils.js +183 -0
- package/dist/src/core/utils.js.map +1 -0
- package/dist/src/main-api/INode.d.ts +390 -0
- package/dist/src/main-api/INode.js +20 -0
- package/dist/src/main-api/INode.js.map +1 -0
- package/dist/src/main-api/IRenderDriver.d.ts +20 -0
- package/dist/src/main-api/IRenderDriver.js +20 -0
- package/dist/src/main-api/IRenderDriver.js.map +1 -0
- package/dist/src/main-api/RendererMain.d.ts +232 -0
- package/dist/src/main-api/RendererMain.js +303 -0
- package/dist/src/main-api/RendererMain.js.map +1 -0
- package/dist/src/render-drivers/main/MainOnlyNode.d.ts +84 -0
- package/dist/src/render-drivers/main/MainOnlyNode.js +324 -0
- package/dist/src/render-drivers/main/MainOnlyNode.js.map +1 -0
- package/dist/src/render-drivers/main/MainOnlyTextNode.d.ts +39 -0
- package/dist/src/render-drivers/main/MainOnlyTextNode.js +165 -0
- package/dist/src/render-drivers/main/MainOnlyTextNode.js.map +1 -0
- package/dist/src/render-drivers/main/MainRenderDriver.d.ts +17 -0
- package/dist/src/render-drivers/main/MainRenderDriver.js +88 -0
- package/dist/src/render-drivers/main/MainRenderDriver.js.map +1 -0
- package/dist/src/render-drivers/threadx/NodeStruct.d.ts +81 -0
- package/dist/src/render-drivers/threadx/NodeStruct.js +254 -0
- package/dist/src/render-drivers/threadx/NodeStruct.js.map +1 -0
- package/dist/src/render-drivers/threadx/SharedNode.d.ts +36 -0
- package/dist/src/render-drivers/threadx/SharedNode.js +57 -0
- package/dist/src/render-drivers/threadx/SharedNode.js.map +1 -0
- package/dist/src/render-drivers/threadx/TextNodeStruct.d.ts +34 -0
- package/dist/src/render-drivers/threadx/TextNodeStruct.js +156 -0
- package/dist/src/render-drivers/threadx/TextNodeStruct.js.map +1 -0
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.d.ts +20 -0
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js +84 -0
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js.map +1 -0
- package/dist/src/render-drivers/threadx/ThreadXMainNode.d.ts +37 -0
- package/dist/src/render-drivers/threadx/ThreadXMainNode.js +121 -0
- package/dist/src/render-drivers/threadx/ThreadXMainNode.js.map +1 -0
- package/dist/src/render-drivers/threadx/ThreadXMainTextNode.d.ts +23 -0
- package/dist/src/render-drivers/threadx/ThreadXMainTextNode.js +50 -0
- package/dist/src/render-drivers/threadx/ThreadXMainTextNode.js.map +1 -0
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.d.ts +21 -0
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.js +194 -0
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.js.map +1 -0
- package/dist/src/render-drivers/threadx/ThreadXRendererMessage.d.ts +48 -0
- package/dist/src/render-drivers/threadx/ThreadXRendererMessage.js +32 -0
- package/dist/src/render-drivers/threadx/ThreadXRendererMessage.js.map +1 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.d.ts +19 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js +172 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js.map +1 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.d.ts +22 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.js +101 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.js.map +1 -0
- package/dist/src/render-drivers/threadx/worker/renderer.d.ts +1 -0
- package/dist/src/render-drivers/threadx/worker/renderer.js +130 -0
- package/dist/src/render-drivers/threadx/worker/renderer.js.map +1 -0
- package/dist/src/render-drivers/utils.d.ts +10 -0
- package/dist/src/render-drivers/utils.js +41 -0
- package/dist/src/render-drivers/utils.js.map +1 -0
- package/dist/src/utils.d.ts +79 -0
- package/dist/src/utils.js +162 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/tsconfig.dist.tsbuildinfo +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,106 @@
|
|
|
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
|
|
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
|
+
export class Scene {
|
|
20
|
+
/**
|
|
21
|
+
* Root node of the scene
|
|
22
|
+
*
|
|
23
|
+
* @type {Node}
|
|
24
|
+
* @memberof Scene
|
|
25
|
+
*/
|
|
26
|
+
root;
|
|
27
|
+
constructor(root) {
|
|
28
|
+
this.root = root;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get all nodes of a specific type
|
|
32
|
+
* @param type
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
getNodeByType(type) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Find a node by id
|
|
40
|
+
* @param id
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
getNodeById(id) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a new node
|
|
48
|
+
* @param parent
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
// public createNode(settings: Partial<INodeWritableProps> = {}): NodeTypes {
|
|
52
|
+
// return createNode(settings);
|
|
53
|
+
// }
|
|
54
|
+
/**
|
|
55
|
+
* create a new RectangleNode
|
|
56
|
+
* @param w
|
|
57
|
+
* @param h
|
|
58
|
+
* @param parent
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
// public rectangle(w: number, h: number, parent: NodeTypes | null = null) {
|
|
62
|
+
// // TODO: Fix this
|
|
63
|
+
// // return this.create(new RectangleNode(w, h), parent);
|
|
64
|
+
// }
|
|
65
|
+
/**
|
|
66
|
+
* Create a new CircleNode
|
|
67
|
+
* @param r
|
|
68
|
+
* @param parent
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
// public circle(r: number, parent: NodeTypes | null = null) {
|
|
72
|
+
// // TODO: Fix this
|
|
73
|
+
// // return this.create(new CircleNode(r), parent);
|
|
74
|
+
// }
|
|
75
|
+
/**
|
|
76
|
+
* Create a new TextNode
|
|
77
|
+
* @param text
|
|
78
|
+
* @param parent
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
// public text(text = '', parent: NodeTypes | null = null) {
|
|
82
|
+
// // TODO: Fix this
|
|
83
|
+
// // return this.create(new TextNode(text), parent);
|
|
84
|
+
// }
|
|
85
|
+
/**
|
|
86
|
+
* Setup and attaching Node
|
|
87
|
+
* @param node
|
|
88
|
+
* @param parent
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
// private create(node: NodeTypes, parent: NodeTypes | null = null): NodeTypes {
|
|
92
|
+
// if (!parent) {
|
|
93
|
+
// parent = this.root;
|
|
94
|
+
// }
|
|
95
|
+
// node.parent = parent;
|
|
96
|
+
// return node;
|
|
97
|
+
// }
|
|
98
|
+
/**
|
|
99
|
+
* Update the scene
|
|
100
|
+
* @param delta
|
|
101
|
+
*/
|
|
102
|
+
update(delta) {
|
|
103
|
+
this.root.update(delta);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=Scene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scene.js","sourceRoot":"","sources":["../../../../src/core/scene/Scene.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,MAAM,OAAO,KAAK;IAChB;;;;;OAKG;IACI,IAAI,CAAW;IAEtB,YAAY,IAAc;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,IAAY;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,EAAU;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,6EAA6E;IAC7E,iCAAiC;IACjC,IAAI;IAEJ;;;;;;OAMG;IACH,4EAA4E;IAC5E,sBAAsB;IACtB,4DAA4D;IAC5D,IAAI;IAEJ;;;;;OAKG;IACH,8DAA8D;IAC9D,sBAAsB;IACtB,sDAAsD;IACtD,IAAI;IAEJ;;;;;OAKG;IACH,4DAA4D;IAC5D,sBAAsB;IACtB,uDAAuD;IACvD,IAAI;IAEJ;;;;;OAKG;IACH,gFAAgF;IAChF,mBAAmB;IACnB,0BAA0B;IAC1B,MAAM;IAEN,0BAA0B;IAC1B,iBAAiB;IACjB,IAAI;IAEJ;;;OAGG;IACI,MAAM,CAAC,KAAa;QACzB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns CSS font setting string for use in canvas context.
|
|
3
|
+
*
|
|
4
|
+
* @param fontFace
|
|
5
|
+
* @param fontStyle
|
|
6
|
+
* @param fontSize
|
|
7
|
+
* @param precision
|
|
8
|
+
* @param defaultFontFace
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function getFontSetting(fontFace: string | string[], fontStyle: string, fontSize: number, precision: number, defaultFontFace: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Returns true if the given character is a zero-width space.
|
|
14
|
+
*
|
|
15
|
+
* @param space
|
|
16
|
+
*/
|
|
17
|
+
export declare function isZeroWidthSpace(space: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Returns true if the given character is a zero-width space or a regular space.
|
|
20
|
+
*
|
|
21
|
+
* @param space
|
|
22
|
+
*/
|
|
23
|
+
export declare function isSpace(space: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Converts a string into an array of tokens and the words between them.
|
|
26
|
+
*
|
|
27
|
+
* @param tokenRegex
|
|
28
|
+
* @param text
|
|
29
|
+
*/
|
|
30
|
+
export declare function tokenizeString(tokenRegex: RegExp, text: string): string[];
|
|
31
|
+
/**
|
|
32
|
+
* Measure the width of a string accounting for letter spacing.
|
|
33
|
+
*
|
|
34
|
+
* @param context
|
|
35
|
+
* @param word
|
|
36
|
+
* @param space
|
|
37
|
+
*/
|
|
38
|
+
export declare function measureText(context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, word: string, space?: number): number;
|
|
39
|
+
export interface WrapTextResult {
|
|
40
|
+
l: string[];
|
|
41
|
+
n: number[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Applies newlines to a string to have it optimally fit into the horizontal
|
|
45
|
+
* bounds set by the Text object's wordWrapWidth property.
|
|
46
|
+
*
|
|
47
|
+
* @param context
|
|
48
|
+
* @param text
|
|
49
|
+
* @param wordWrapWidth
|
|
50
|
+
* @param letterSpacing
|
|
51
|
+
* @param indent
|
|
52
|
+
*/
|
|
53
|
+
export declare function wrapText(context: CanvasRenderingContext2D, text: string, wordWrapWidth: number, letterSpacing: number, indent: number): WrapTextResult;
|
|
@@ -0,0 +1,156 @@
|
|
|
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
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Returns CSS font setting string for use in canvas context.
|
|
21
|
+
*
|
|
22
|
+
* @param fontFace
|
|
23
|
+
* @param fontStyle
|
|
24
|
+
* @param fontSize
|
|
25
|
+
* @param precision
|
|
26
|
+
* @param defaultFontFace
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export function getFontSetting(fontFace, fontStyle, fontSize, precision, defaultFontFace) {
|
|
30
|
+
let ff = fontFace;
|
|
31
|
+
if (!Array.isArray(ff)) {
|
|
32
|
+
ff = [ff];
|
|
33
|
+
}
|
|
34
|
+
const ffs = [];
|
|
35
|
+
for (let i = 0, n = ff.length; i < n; i++) {
|
|
36
|
+
let curFf = ff[i];
|
|
37
|
+
// Replace the default font face `null` with the actual default font face set
|
|
38
|
+
// on the stage.
|
|
39
|
+
if (curFf === null || curFf === undefined) {
|
|
40
|
+
curFf = defaultFontFace;
|
|
41
|
+
}
|
|
42
|
+
if (curFf === 'serif' || curFf === 'sans-serif') {
|
|
43
|
+
ffs.push(curFf);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
ffs.push(`"${curFf}"`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return `${fontStyle} ${fontSize * precision}px ${ffs.join(',')}`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns true if the given character is a zero-width space.
|
|
53
|
+
*
|
|
54
|
+
* @param space
|
|
55
|
+
*/
|
|
56
|
+
export function isZeroWidthSpace(space) {
|
|
57
|
+
return space === '' || space === '\u200B';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns true if the given character is a zero-width space or a regular space.
|
|
61
|
+
*
|
|
62
|
+
* @param space
|
|
63
|
+
*/
|
|
64
|
+
export function isSpace(space) {
|
|
65
|
+
return isZeroWidthSpace(space) || space === ' ';
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Converts a string into an array of tokens and the words between them.
|
|
69
|
+
*
|
|
70
|
+
* @param tokenRegex
|
|
71
|
+
* @param text
|
|
72
|
+
*/
|
|
73
|
+
export function tokenizeString(tokenRegex, text) {
|
|
74
|
+
const delimeters = text.match(tokenRegex) || [];
|
|
75
|
+
const words = text.split(tokenRegex) || [];
|
|
76
|
+
const final = [];
|
|
77
|
+
for (let i = 0; i < words.length; i++) {
|
|
78
|
+
final.push(words[i], delimeters[i]);
|
|
79
|
+
}
|
|
80
|
+
final.pop();
|
|
81
|
+
return final.filter((word) => word != '');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Measure the width of a string accounting for letter spacing.
|
|
85
|
+
*
|
|
86
|
+
* @param context
|
|
87
|
+
* @param word
|
|
88
|
+
* @param space
|
|
89
|
+
*/
|
|
90
|
+
export function measureText(context, word, space = 0) {
|
|
91
|
+
if (!space) {
|
|
92
|
+
return context.measureText(word).width;
|
|
93
|
+
}
|
|
94
|
+
return word.split('').reduce((acc, char) => {
|
|
95
|
+
// Zero-width spaces should not include letter spacing.
|
|
96
|
+
// And since we know the width of a zero-width space is 0, we can skip
|
|
97
|
+
// measuring it.
|
|
98
|
+
if (isZeroWidthSpace(char)) {
|
|
99
|
+
return acc;
|
|
100
|
+
}
|
|
101
|
+
return acc + context.measureText(char).width + space;
|
|
102
|
+
}, 0);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Applies newlines to a string to have it optimally fit into the horizontal
|
|
106
|
+
* bounds set by the Text object's wordWrapWidth property.
|
|
107
|
+
*
|
|
108
|
+
* @param context
|
|
109
|
+
* @param text
|
|
110
|
+
* @param wordWrapWidth
|
|
111
|
+
* @param letterSpacing
|
|
112
|
+
* @param indent
|
|
113
|
+
*/
|
|
114
|
+
export function wrapText(context, text, wordWrapWidth, letterSpacing, indent) {
|
|
115
|
+
// Greedy wrapping algorithm that will wrap words as the line grows longer.
|
|
116
|
+
// than its horizontal bounds.
|
|
117
|
+
const spaceRegex = / |\u200B/g;
|
|
118
|
+
const lines = text.split(/\r?\n/g);
|
|
119
|
+
let allLines = [];
|
|
120
|
+
const realNewlines = [];
|
|
121
|
+
for (let i = 0; i < lines.length; i++) {
|
|
122
|
+
const resultLines = [];
|
|
123
|
+
let result = '';
|
|
124
|
+
let spaceLeft = wordWrapWidth - indent;
|
|
125
|
+
const words = lines[i].split(spaceRegex);
|
|
126
|
+
const spaces = lines[i].match(spaceRegex) || [];
|
|
127
|
+
for (let j = 0; j < words.length; j++) {
|
|
128
|
+
const space = spaces[j - 1] || '';
|
|
129
|
+
const word = words[j];
|
|
130
|
+
const wordWidth = measureText(context, word, letterSpacing);
|
|
131
|
+
const wordWidthWithSpace = wordWidth + measureText(context, space, letterSpacing);
|
|
132
|
+
if (j === 0 || wordWidthWithSpace > spaceLeft) {
|
|
133
|
+
// Skip printing the newline if it's the first word of the line that is.
|
|
134
|
+
// greater than the word wrap width.
|
|
135
|
+
if (j > 0) {
|
|
136
|
+
resultLines.push(result);
|
|
137
|
+
result = '';
|
|
138
|
+
}
|
|
139
|
+
result += word;
|
|
140
|
+
spaceLeft = wordWrapWidth - wordWidth - (j === 0 ? indent : 0);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
spaceLeft -= wordWidthWithSpace;
|
|
144
|
+
result += space + word;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
resultLines.push(result);
|
|
148
|
+
result = '';
|
|
149
|
+
allLines = allLines.concat(resultLines);
|
|
150
|
+
if (i < lines.length - 1) {
|
|
151
|
+
realNewlines.push(allLines.length);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return { l: allLines, n: realNewlines };
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=TextTextureRendererUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextTextureRendererUtils.js","sourceRoot":"","sources":["../../../../src/core/text-rendering/TextTextureRendererUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAC5B,QAA2B,EAC3B,SAAiB,EACjB,QAAgB,EAChB,SAA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C;aAChE;iBAAM;gBACL,SAAS,IAAI,kBAAkB,CAAC;gBAChC,MAAM,IAAI,KAAK,GAAG,IAAI,CAAC;aACxB;SACF;QAED,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,MAAM,GAAG,EAAE,CAAC;QAEZ,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAExC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACxB,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SACpC;KACF;IAED,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TrFontFace } from './font-face-types/TrFontFace.js';
|
|
2
|
+
import type { TextRendererMap, TrFontProps } from './renderers/TextRenderer.js';
|
|
3
|
+
/**
|
|
4
|
+
* Structure mapping font family names to a set of font faces.
|
|
5
|
+
*/
|
|
6
|
+
export interface FontFamilyMap {
|
|
7
|
+
[familyName: string]: Set<TrFontFace>;
|
|
8
|
+
}
|
|
9
|
+
export declare class TrFontManager {
|
|
10
|
+
private textRenderers;
|
|
11
|
+
constructor(textRenderers: Partial<TextRendererMap>);
|
|
12
|
+
addFontFace(font: TrFontFace): void;
|
|
13
|
+
/**
|
|
14
|
+
* Utility method to resolve a single font face from a list of prioritized family maps based on
|
|
15
|
+
* a set of font properties.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* These are to be used by a text renderer to resolve a font face if needed.
|
|
19
|
+
*
|
|
20
|
+
* @param familyMapsByPriority
|
|
21
|
+
* @param props
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
static resolveFontFace(familyMapsByPriority: FontFamilyMap[], props: TrFontProps): TrFontFace | undefined;
|
|
25
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
|
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 { SdfTrFontFace } from './font-face-types/SdfTrFontFace/SdfTrFontFace.js';
|
|
20
|
+
import { WebTrFontFace } from './font-face-types/WebTrFontFace.js';
|
|
21
|
+
export class TrFontManager {
|
|
22
|
+
textRenderers;
|
|
23
|
+
constructor(textRenderers) {
|
|
24
|
+
this.textRenderers = textRenderers;
|
|
25
|
+
// Intentionally left blank
|
|
26
|
+
}
|
|
27
|
+
addFontFace(font) {
|
|
28
|
+
// All the font face to all of the text renderers that support it
|
|
29
|
+
for (const trId in this.textRenderers) {
|
|
30
|
+
const tr = this.textRenderers[trId];
|
|
31
|
+
if (tr && tr.isFontFaceSupported(font)) {
|
|
32
|
+
tr.addFontFace(font);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Utility method to resolve a single font face from a list of prioritized family maps based on
|
|
38
|
+
* a set of font properties.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* These are to be used by a text renderer to resolve a font face if needed.
|
|
42
|
+
*
|
|
43
|
+
* @param familyMapsByPriority
|
|
44
|
+
* @param props
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
static resolveFontFace(familyMapsByPriority, props) {
|
|
48
|
+
const closeFaces = [];
|
|
49
|
+
const exactMatch = familyMapsByPriority.reduce((prev, fontFamiles) => {
|
|
50
|
+
if (prev) {
|
|
51
|
+
return prev;
|
|
52
|
+
}
|
|
53
|
+
const fontFaces = fontFamiles[props.fontFamily];
|
|
54
|
+
if (!fontFaces) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const fontFacesCopy = new Set(fontFaces);
|
|
58
|
+
// Remove any font faces that don't match the style exactly
|
|
59
|
+
// TODO: In the future we may enhance this to find the best match
|
|
60
|
+
// based on font weight, style, etc.
|
|
61
|
+
// See https://www.w3.org/TR/2018/REC-css-fonts-3-20180920/#font-matching-algorithm
|
|
62
|
+
for (const fontFace of fontFacesCopy) {
|
|
63
|
+
if (fontFace.descriptors.stretch !== props.fontStretch ||
|
|
64
|
+
fontFace.descriptors.style !== props.fontStyle ||
|
|
65
|
+
fontFace.descriptors.weight !== props.fontWeight) {
|
|
66
|
+
fontFacesCopy.delete(fontFace);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Return the first font face that matches the style exactly
|
|
70
|
+
return fontFacesCopy.values().next().value;
|
|
71
|
+
}, undefined);
|
|
72
|
+
return exactMatch || closeFaces[0];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=TrFontManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TrFontManager.js","sourceRoot":"","sources":["../../../../src/core/text-rendering/TrFontManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAUnE,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,aAAuC;QAAvC,kBAAa,GAAb,aAAa,CAA0B;QACzD,2BAA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V,CAAC;QAEF,OAAO,UAAU,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Stage } from '../../../Stage.js';
|
|
2
|
+
import { ImageTexture } from '../../../textures/ImageTexture.js';
|
|
3
|
+
import { TrFontFace, type TrFontFaceDescriptors } from '../TrFontFace.js';
|
|
4
|
+
import type { FontShaper } from './internal/FontShaper.js';
|
|
5
|
+
import { type SdfFontData } from './internal/SdfFontShaper.js';
|
|
6
|
+
type SdfFontType = 'ssdf' | 'msdf';
|
|
7
|
+
declare module '../TrFontFace.js' {
|
|
8
|
+
interface TrFontFaceMap {
|
|
9
|
+
ssdf: SdfTrFontFace<'ssdf'>;
|
|
10
|
+
msdf: SdfTrFontFace<'msdf'>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
interface GlyphAtlasEntry {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class SdfTrFontFace<FontTypeT extends SdfFontType = SdfFontType> extends TrFontFace {
|
|
20
|
+
readonly type: FontTypeT;
|
|
21
|
+
readonly texture: ImageTexture;
|
|
22
|
+
readonly data: SdfFontData | undefined;
|
|
23
|
+
readonly shaper: FontShaper | undefined;
|
|
24
|
+
readonly glyphMap: Map<number, SdfFontData['chars'][0]>;
|
|
25
|
+
constructor(fontFamily: string, descriptors: Partial<TrFontFaceDescriptors>, type: FontTypeT, stage: Stage, atlasUrl: string, atlasDataUrl: string);
|
|
26
|
+
getAtlasEntry(glyphId: number): GlyphAtlasEntry;
|
|
27
|
+
private checkLoaded;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
|
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 type { Renderer } from '../../../Renderer';
|
|
20
|
+
import { assertTruthy } from '../../../../utils.js';
|
|
21
|
+
import { WebGlCoreRenderer } from '../../../renderers/webgl/WebGlCoreRenderer.js';
|
|
22
|
+
import { ImageTexture } from '../../../textures/ImageTexture.js';
|
|
23
|
+
import { TrFontFace } from '../TrFontFace.js';
|
|
24
|
+
import { SdfFontShaper } from './internal/SdfFontShaper.js';
|
|
25
|
+
export class SdfTrFontFace extends TrFontFace {
|
|
26
|
+
type;
|
|
27
|
+
texture;
|
|
28
|
+
data;
|
|
29
|
+
shaper;
|
|
30
|
+
glyphMap = new Map();
|
|
31
|
+
constructor(fontFamily, descriptors, type, stage, atlasUrl, atlasDataUrl) {
|
|
32
|
+
super(fontFamily, descriptors);
|
|
33
|
+
this.type = type;
|
|
34
|
+
const renderer = stage.renderer;
|
|
35
|
+
assertTruthy(renderer instanceof WebGlCoreRenderer, 'SDF Font Faces can only be used with the WebGL Renderer');
|
|
36
|
+
this.texture = stage.txManager.loadTexture('ImageTexture', {
|
|
37
|
+
src: atlasUrl,
|
|
38
|
+
// IMPORTANT: The SDF shader requires the alpha channel to NOT be
|
|
39
|
+
// premultiplied on the atlas texture. If it is premultiplied, the
|
|
40
|
+
// rendering of SDF glyphs (especially single-channel SDF fonts) will
|
|
41
|
+
// be very jagged.
|
|
42
|
+
premultiplyAlpha: false,
|
|
43
|
+
}, {
|
|
44
|
+
preload: true,
|
|
45
|
+
});
|
|
46
|
+
// TODO: Add texture loaded support
|
|
47
|
+
// this.texture.on('loaded', () => {
|
|
48
|
+
// this.checkLoaded();
|
|
49
|
+
// });
|
|
50
|
+
// Set this.data to the fetched data from dataUrl
|
|
51
|
+
fetch(atlasDataUrl)
|
|
52
|
+
.then(async (response) => {
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
54
|
+
this.data = await response.json();
|
|
55
|
+
// We know `data` is defined here, because we just set it
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
57
|
+
this.shaper = new SdfFontShaper(this.data);
|
|
58
|
+
// Add all the glyphs to the glyph map
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
60
|
+
this.data.chars.forEach((glyph) => {
|
|
61
|
+
this.glyphMap.set(glyph.id, glyph);
|
|
62
|
+
});
|
|
63
|
+
this.checkLoaded();
|
|
64
|
+
})
|
|
65
|
+
.catch(console.error);
|
|
66
|
+
}
|
|
67
|
+
getAtlasEntry(glyphId) {
|
|
68
|
+
const glyph = this.glyphMap.get(glyphId);
|
|
69
|
+
if (glyph === undefined) {
|
|
70
|
+
throw new Error(`Glyph ${glyphId} not found in font ${this.fontFamily}`);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
x: glyph.x,
|
|
74
|
+
y: glyph.y,
|
|
75
|
+
width: glyph.width,
|
|
76
|
+
height: glyph.height,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
checkLoaded() {
|
|
80
|
+
if (this.loaded)
|
|
81
|
+
return;
|
|
82
|
+
if ( /*this.texture.loaded && */this.data) {
|
|
83
|
+
this.loaded = true;
|
|
84
|
+
this.emit('loaded');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=SdfTrFontFace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SdfTrFontFace.js","sourceRoot":"","sources":["../../../../../../src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,qDAAqD;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,UAAU,EAA8B,MAAM,kBAAkB,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAoB,MAAM,6BAA6B,CAAC;AAkB9E,MAAM,OAAO,aAEX,SAAQ,UAAU;IACF,IAAI,CAAY;IAChB,OAAO,CAAe;IACtB,IAAI,CAA0B;IAC9B,MAAM,CAAyB;IAC/B,QAAQ,GAAyC,IAAI,GAAG,EAAE,CAAC;IAE3E,YACE,UAAkB,EAClB,WAA2C,EAC3C,IAAe,EACf,KAAY,EACZ,QAAgB,EAChB,YAAoB;QAEpB,KAAK,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,YAAY,CACV,QAAQ,YAAY,iBAAiB,EACrC,yDAAyD,CAC1D,CAAC;QAEF,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,CACxC,cAAc,EACd;YACE,GAAG,EAAE,QAAQ;YACb,iEAAiE;YACjE,kEAAkE;YAClE,qEAAqE;YACrE,kBAAkB;YAClB,gBAAgB,EAAE,KAAK;SACxB,EACD;YACE,OAAO,EAAE,IAAI;SACd,CACF,CAAC;QAEF,mCAAmC;QACnC,oCAAoC;QACpC,wBAAwB;QACxB,MAAM;QAEN,iDAAiD;QACjD,KAAK,CAAC,YAAY,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|
1
|
+
import type { PeekableIterator } from '../../../renderers/SdfTextRenderer/internal/PeekableGenerator.js';
|
|
2
|
+
/**
|
|
3
|
+
* HarfBuzz compatible glyph position info
|
|
4
|
+
*/
|
|
5
|
+
export interface GlyphPosition {
|
|
6
|
+
/**
|
|
7
|
+
* how much the line advances after drawing this glyph when setting text in horizontal direction.
|
|
8
|
+
*/
|
|
9
|
+
xAdvance: number;
|
|
10
|
+
/**
|
|
11
|
+
* how much the line advances after drawing this glyph when setting text in vertical direction.
|
|
12
|
+
*/
|
|
13
|
+
yAdvance: number;
|
|
14
|
+
/**
|
|
15
|
+
* how much the glyph moves on the X-axis before drawing it, this should not affect how much the line advances.
|
|
16
|
+
*/
|
|
17
|
+
xOffset: number;
|
|
18
|
+
/**
|
|
19
|
+
* how much the glyph moves on the Y-axis before drawing it, this should not affect how much the line advances.
|
|
20
|
+
*/
|
|
21
|
+
yOffset: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* HarfBuzz compatible glyph info
|
|
25
|
+
*/
|
|
26
|
+
export interface GlyphInfo {
|
|
27
|
+
/**
|
|
28
|
+
* Glyph ID
|
|
29
|
+
*/
|
|
30
|
+
glyphId: number;
|
|
31
|
+
/**
|
|
32
|
+
* First codepoint in the cluster this glyph was mapped from.
|
|
33
|
+
*/
|
|
34
|
+
codepoint: number;
|
|
35
|
+
/**
|
|
36
|
+
* the index of the character in the original text that corresponds to this hb_glyph_info_t
|
|
37
|
+
* This is useful for mapping back from glyphs to characters.
|
|
38
|
+
*/
|
|
39
|
+
cluster: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* HarfBuzz compatible glyph extents
|
|
43
|
+
*/
|
|
44
|
+
export interface GlyphExtents {
|
|
45
|
+
/**
|
|
46
|
+
* The X offset from the origin to the leftmost part of the glyph.
|
|
47
|
+
* This is negative for right-to-left scripts.
|
|
48
|
+
*/
|
|
49
|
+
xBearing: number;
|
|
50
|
+
/**
|
|
51
|
+
* The Y offset from the origin to the topmost part of the glyph.
|
|
52
|
+
* This is negative for bottom-to-top scripts.
|
|
53
|
+
*/
|
|
54
|
+
yBearing: number;
|
|
55
|
+
/**
|
|
56
|
+
* Distance from the top extremum of the glyph to the bottom extremum.
|
|
57
|
+
* This is always positive.
|
|
58
|
+
*/
|
|
59
|
+
width: number;
|
|
60
|
+
/**
|
|
61
|
+
* Distance from the left extremum of the glyph to the right extremum.
|
|
62
|
+
* This is always positive.
|
|
63
|
+
*/
|
|
64
|
+
height: number;
|
|
65
|
+
}
|
|
66
|
+
export interface UnmappedCharacterInfo {
|
|
67
|
+
mapped: false;
|
|
68
|
+
/**
|
|
69
|
+
* The Unicode code point of the character.
|
|
70
|
+
*/
|
|
71
|
+
codepoint: number;
|
|
72
|
+
/**
|
|
73
|
+
* The index of the character in the original text that corresponds to this hb_glyph_info_t
|
|
74
|
+
* This is useful for mapping back from glyphs to characters.
|
|
75
|
+
*/
|
|
76
|
+
cluster: number;
|
|
77
|
+
}
|
|
78
|
+
export type MappedGlyphInfo = {
|
|
79
|
+
mapped: true;
|
|
80
|
+
} & GlyphInfo & GlyphPosition & GlyphExtents;
|
|
81
|
+
/**
|
|
82
|
+
* For performance reasons, all properties are required to reduce need for checking for undefined values.
|
|
83
|
+
*/
|
|
84
|
+
export interface FontShaperProps {
|
|
85
|
+
/**
|
|
86
|
+
* Letter spacing
|
|
87
|
+
*
|
|
88
|
+
* @default 0
|
|
89
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/letter-spacing
|
|
90
|
+
**/
|
|
91
|
+
letterSpacing: number;
|
|
92
|
+
}
|
|
93
|
+
export declare abstract class FontShaper {
|
|
94
|
+
/**
|
|
95
|
+
* Returns the glyph IDs of the next
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* If this returns undefined, a glyph for the next codepoint(s) could not be found.
|
|
99
|
+
*
|
|
100
|
+
* @param codepoints
|
|
101
|
+
*/
|
|
102
|
+
abstract shapeText(props: FontShaperProps, codepoints: PeekableIterator<number>): Generator<MappedGlyphInfo | UnmappedCharacterInfo, void>;
|
|
103
|
+
}
|