ris-framework 0.1.0 → 0.2.0-dev.12
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/CHANGELOG.md +42 -1
- package/README.md +27 -4
- package/dist/Framework.d.ts +34 -10
- package/dist/Framework.d.ts.map +1 -1
- package/dist/api/IFramework.d.ts +50 -6
- package/dist/api/IFramework.d.ts.map +1 -1
- package/dist/api/_export.d.ts +3 -1
- package/dist/api/_export.d.ts.map +1 -1
- package/dist/api/camera/CameraFactory.d.ts +3 -2
- package/dist/api/camera/CameraFactory.d.ts.map +1 -1
- package/dist/api/camera/ICamera.d.ts +5 -0
- package/dist/api/camera/ICamera.d.ts.map +1 -1
- package/dist/api/camera/ICameraFactory.d.ts +5 -6
- package/dist/api/camera/ICameraFactory.d.ts.map +1 -1
- package/dist/api/camera/OrthographicCamera.d.ts +7 -0
- package/dist/api/camera/OrthographicCamera.d.ts.map +1 -1
- package/dist/api/camera/PerspectiveCamera.d.ts +30 -6
- package/dist/api/camera/PerspectiveCamera.d.ts.map +1 -1
- package/dist/api/content/ContentManager.d.ts +15 -2
- package/dist/api/content/ContentManager.d.ts.map +1 -1
- package/dist/api/content/IContentManager.d.ts +35 -1
- package/dist/api/content/IContentManager.d.ts.map +1 -1
- package/dist/api/content/ShaderModuleContent.d.ts.map +1 -1
- package/dist/api/data/Color.d.ts +5 -0
- package/dist/api/data/Color.d.ts.map +1 -1
- package/dist/api/geometry/BaseGeometry.d.ts +9 -0
- package/dist/api/geometry/BaseGeometry.d.ts.map +1 -1
- package/dist/api/geometry/GeometryBuilder.d.ts +3 -1
- package/dist/api/geometry/GeometryBuilder.d.ts.map +1 -1
- package/dist/api/geometry/IGeometryBuilder.d.ts +24 -0
- package/dist/api/geometry/IGeometryBuilder.d.ts.map +1 -1
- package/dist/api/geometry/_export-geometry.d.ts +1 -0
- package/dist/api/geometry/_export-geometry.d.ts.map +1 -1
- package/dist/api/input/InputManager.d.ts +4 -0
- package/dist/api/input/InputManager.d.ts.map +1 -1
- package/dist/api/lights/AmbientLight.d.ts +35 -0
- package/dist/api/lights/AmbientLight.d.ts.map +1 -0
- package/dist/api/lights/DirectionalLight.d.ts +40 -0
- package/dist/api/lights/DirectionalLight.d.ts.map +1 -0
- package/dist/api/lights/LightFactory.d.ts +18 -0
- package/dist/api/lights/LightFactory.d.ts.map +1 -0
- package/dist/api/lights/LightId.d.ts +6 -0
- package/dist/api/lights/LightId.d.ts.map +1 -0
- package/dist/api/lights/LightsBuffer.d.ts +77 -0
- package/dist/api/lights/LightsBuffer.d.ts.map +1 -0
- package/dist/api/lights/PointLight.d.ts +59 -0
- package/dist/api/lights/PointLight.d.ts.map +1 -0
- package/dist/api/lights/_export.d.ts +6 -0
- package/dist/api/lights/_export.d.ts.map +1 -0
- package/dist/api/loaders/ObjGeometryMapper.d.ts +19 -0
- package/dist/api/loaders/ObjGeometryMapper.d.ts.map +1 -0
- package/dist/api/loaders/ObjLoader.d.ts +61 -0
- package/dist/api/loaders/ObjLoader.d.ts.map +1 -0
- package/dist/api/loaders/_export.d.ts +2 -0
- package/dist/api/loaders/_export.d.ts.map +1 -1
- package/dist/api/loaders/obj/ObjParser.d.ts +44 -0
- package/dist/api/loaders/obj/ObjParser.d.ts.map +1 -0
- package/dist/api/loaders/obj/ObjTypes.d.ts +119 -0
- package/dist/api/loaders/obj/ObjTypes.d.ts.map +1 -0
- package/dist/api/loaders/obj/index.d.ts +3 -0
- package/dist/api/loaders/obj/index.d.ts.map +1 -0
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts +138 -0
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts.map +1 -0
- package/dist/api/material/ICameraMaterial.d.ts +18 -0
- package/dist/api/material/ICameraMaterial.d.ts.map +1 -0
- package/dist/api/material/ILightsMaterial.d.ts +26 -0
- package/dist/api/material/ILightsMaterial.d.ts.map +1 -0
- package/dist/api/material/IMaterial.d.ts +13 -10
- package/dist/api/material/IMaterial.d.ts.map +1 -1
- package/dist/api/material/IMaterialFactory.d.ts +17 -2
- package/dist/api/material/IMaterialFactory.d.ts.map +1 -1
- package/dist/api/material/InspectTextureMipsMaterial.d.ts +18 -9
- package/dist/api/material/InspectTextureMipsMaterial.d.ts.map +1 -1
- package/dist/api/material/MaterialFactory.d.ts +6 -0
- package/dist/api/material/MaterialFactory.d.ts.map +1 -1
- package/dist/api/material/SpriteMaterial.d.ts +51 -0
- package/dist/api/material/SpriteMaterial.d.ts.map +1 -0
- package/dist/api/material/UnlitMaterial.d.ts +32 -13
- package/dist/api/material/UnlitMaterial.d.ts.map +1 -1
- package/dist/api/material/_export.d.ts +4 -0
- package/dist/api/material/_export.d.ts.map +1 -1
- package/dist/api/meshes/IMesh.d.ts +31 -6
- package/dist/api/meshes/IMesh.d.ts.map +1 -1
- package/dist/api/meshes/IMeshFactory.d.ts +30 -4
- package/dist/api/meshes/IMeshFactory.d.ts.map +1 -1
- package/dist/api/meshes/IRenderableMesh.d.ts +47 -0
- package/dist/api/meshes/IRenderableMesh.d.ts.map +1 -0
- package/dist/api/meshes/Mesh.d.ts +14 -8
- package/dist/api/meshes/Mesh.d.ts.map +1 -1
- package/dist/api/meshes/MeshFactory.d.ts +10 -3
- package/dist/api/meshes/MeshFactory.d.ts.map +1 -1
- package/dist/api/meshes/QuadMesh.d.ts +5 -3
- package/dist/api/meshes/QuadMesh.d.ts.map +1 -1
- package/dist/api/meshes/RenderableMesh.d.ts +95 -0
- package/dist/api/meshes/RenderableMesh.d.ts.map +1 -0
- package/dist/api/meshes/_export.d.ts +2 -0
- package/dist/api/meshes/_export.d.ts.map +1 -1
- package/dist/api/rendering/IGraphicsDeviceFeatures.d.ts +8 -2
- package/dist/api/rendering/IGraphicsDeviceFeatures.d.ts.map +1 -1
- package/dist/api/rendering/IRenderer.d.ts +28 -1
- package/dist/api/rendering/IRenderer.d.ts.map +1 -1
- package/dist/api/rendering/enums.d.ts +7 -0
- package/dist/api/rendering/enums.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.d.ts +56 -0
- package/dist/api/rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.d.ts.map +1 -0
- package/dist/api/rendering/render-pipelines/IRenderPipeline.d.ts +3 -0
- package/dist/api/rendering/render-pipelines/IRenderPipeline.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/IRenderPipelineFactory.d.ts +29 -0
- package/dist/api/rendering/render-pipelines/IRenderPipelineFactory.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/_export-render-pipelines.d.ts +1 -0
- package/dist/api/rendering/render-pipelines/_export-render-pipelines.d.ts.map +1 -1
- package/dist/api/rendering/renderer-interface.d.ts +1 -31
- package/dist/api/rendering/renderer-interface.d.ts.map +1 -1
- package/dist/api/rendering/renderpass/RenderPassDescriptor.d.ts +2 -6
- package/dist/api/rendering/renderpass/RenderPassDescriptor.d.ts.map +1 -1
- package/dist/api/rendering/swapchain/ISwapChain.d.ts +1 -3
- package/dist/api/rendering/swapchain/ISwapChain.d.ts.map +1 -1
- package/dist/api/rendering/texture/TextureFormat.d.ts +88 -14
- package/dist/api/rendering/texture/TextureFormat.d.ts.map +1 -1
- package/dist/api/rendering/texture/TextureUtilities.d.ts +23 -0
- package/dist/api/rendering/texture/TextureUtilities.d.ts.map +1 -1
- package/dist/api/scene/Scene.d.ts +113 -0
- package/dist/api/scene/Scene.d.ts.map +1 -0
- package/dist/api/scene/SceneMesh.d.ts +27 -0
- package/dist/api/scene/SceneMesh.d.ts.map +1 -0
- package/dist/api/shader/IShaderModuleLoader.d.ts +4 -1
- package/dist/api/shader/IShaderModuleLoader.d.ts.map +1 -1
- package/dist/api/shader/{shader-loader.d.ts → ShaderLoader.d.ts} +1 -1
- package/dist/api/shader/ShaderLoader.d.ts.map +1 -0
- package/dist/api/sprites/SpriteBatchDrawable.d.ts +1 -1
- package/dist/api/sprites/SpriteBatchDrawable.d.ts.map +1 -1
- package/dist/api/sprites/SpriteBatchMesh.d.ts +14 -1
- package/dist/api/sprites/SpriteBatchMesh.d.ts.map +1 -1
- package/dist/api/utilities/AlignUtilities.d.ts.map +1 -1
- package/dist/api/utilities/GeometryUtilities.d.ts.map +1 -1
- package/dist/api/window/WindowManager.d.ts +4 -0
- package/dist/api/window/WindowManager.d.ts.map +1 -1
- package/dist/core/rendering/ARenderer.d.ts +5 -5
- package/dist/core/rendering/ARenderer.d.ts.map +1 -1
- package/dist/core/rendering/vertex-buffer-layout.d.ts +1 -0
- package/dist/core/rendering/vertex-buffer-layout.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9238 -4595
- package/dist/webgl/WebGLGraphicsDeviceFeatures.d.ts +4 -0
- package/dist/webgl/WebGLGraphicsDeviceFeatures.d.ts.map +1 -1
- package/dist/webgl/WebGlGraphicsDevice.d.ts.map +1 -1
- package/dist/webgl/WebGlRenderer.d.ts +1 -3
- package/dist/webgl/WebGlRenderer.d.ts.map +1 -1
- package/dist/webgl/lights/WebGlAmbientLightFactory.d.ts +17 -0
- package/dist/webgl/lights/WebGlAmbientLightFactory.d.ts.map +1 -0
- package/dist/webgl/lights/WebGlLightsBuffer.d.ts +59 -0
- package/dist/webgl/lights/WebGlLightsBuffer.d.ts.map +1 -0
- package/dist/webgl/render-pipelines/AWebGlRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/AWebGlRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts +5 -0
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/WebGlRenderPipelineFactory.d.ts +3 -1
- package/dist/webgl/render-pipelines/WebGlRenderPipelineFactory.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/inspect/WebGlInspectTextureMipsRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/inspect/WebGlInspectTextureMipsRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/material/WebGlBlinnPhongRenderPipeline.d.ts +88 -0
- package/dist/webgl/render-pipelines/material/WebGlBlinnPhongRenderPipeline.d.ts.map +1 -0
- package/dist/webgl/render-pipelines/material/WebGlUnlitRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/material/WebGlUnlitRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/sprite/WebGlSpriteRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/sprite/WebGlSpriteRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/shader/WebGlShaderModule.d.ts +4 -1
- package/dist/webgl/shader/WebGlShaderModule.d.ts.map +1 -1
- package/dist/webgl/shader/WebGlShaderModuleLoader.d.ts +16 -5
- package/dist/webgl/shader/WebGlShaderModuleLoader.d.ts.map +1 -1
- package/dist/webgl/swap-chain/WebGlSwapChain.d.ts +3 -2
- package/dist/webgl/swap-chain/WebGlSwapChain.d.ts.map +1 -1
- package/dist/webgl/texture/WebGlTexture2D.d.ts +8 -1
- package/dist/webgl/texture/WebGlTexture2D.d.ts.map +1 -1
- package/dist/webgl/texture/WebGlTextureFactory.d.ts +7 -0
- package/dist/webgl/texture/WebGlTextureFactory.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlConstants.d.ts +91 -0
- package/dist/webgl/utilities/WebGlConstants.d.ts.map +1 -0
- package/dist/webgl/utilities/WebGlConverter.d.ts +0 -7
- package/dist/webgl/utilities/WebGlConverter.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlErrorUtilities.d.ts +10 -0
- package/dist/webgl/utilities/WebGlErrorUtilities.d.ts.map +1 -0
- package/dist/webgl/utilities/WebGlTextureUtilities.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlUtilities.d.ts +3 -0
- package/dist/webgl/utilities/WebGlUtilities.d.ts.map +1 -1
- package/dist/webgl/utilities/webgl-filter-anisotropic-utilities.d.ts +0 -1
- package/dist/webgl/utilities/webgl-filter-anisotropic-utilities.d.ts.map +1 -1
- package/dist/webgpu/WebGpuGpuInfo.d.ts +28 -0
- package/dist/webgpu/WebGpuGpuInfo.d.ts.map +1 -0
- package/dist/webgpu/WebGpuGraphicsDevice.d.ts +80 -0
- package/dist/webgpu/WebGpuGraphicsDevice.d.ts.map +1 -0
- package/dist/webgpu/WebGpuGraphicsDeviceFeatures.d.ts +26 -0
- package/dist/webgpu/WebGpuGraphicsDeviceFeatures.d.ts.map +1 -0
- package/dist/webgpu/WebGpuRenderer.d.ts +26 -0
- package/dist/webgpu/WebGpuRenderer.d.ts.map +1 -0
- package/dist/webgpu/WebGpuTypes.d.ts +355 -0
- package/dist/webgpu/WebGpuTypes.d.ts.map +1 -0
- package/dist/webgpu/blending/WebGpuBlendState.d.ts +30 -0
- package/dist/webgpu/blending/WebGpuBlendState.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuBuffersFactory.d.ts +20 -0
- package/dist/webgpu/buffers/WebGpuBuffersFactory.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuIndexBuffer.d.ts +46 -0
- package/dist/webgpu/buffers/WebGpuIndexBuffer.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuUniformBuffer.d.ts +43 -0
- package/dist/webgpu/buffers/WebGpuUniformBuffer.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuVertexBuffer.d.ts +49 -0
- package/dist/webgpu/buffers/WebGpuVertexBuffer.d.ts.map +1 -0
- package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts +32 -0
- package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts.map +1 -0
- package/dist/webgpu/render-pass/WebGpuRenderPass.d.ts +28 -0
- package/dist/webgpu/render-pass/WebGpuRenderPass.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/AWebGpuRenderPipeline.d.ts +50 -0
- package/dist/webgpu/render-pipelines/AWebGpuRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts +34 -0
- package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/WebGpuRenderPipelineFactory.d.ts +26 -0
- package/dist/webgpu/render-pipelines/WebGpuRenderPipelineFactory.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.d.ts +72 -0
- package/dist/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.d.ts +40 -0
- package/dist/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/sampler/WebGpuSampler.d.ts +39 -0
- package/dist/webgpu/sampler/WebGpuSampler.d.ts.map +1 -0
- package/dist/webgpu/shader/WebGpuShaderModule.d.ts +29 -0
- package/dist/webgpu/shader/WebGpuShaderModule.d.ts.map +1 -0
- package/dist/webgpu/shader/WebGpuShaderModuleLoader.d.ts +21 -0
- package/dist/webgpu/shader/WebGpuShaderModuleLoader.d.ts.map +1 -0
- package/dist/webgpu/shader/WgslShaderContent.d.ts +9 -0
- package/dist/webgpu/shader/WgslShaderContent.d.ts.map +1 -0
- package/dist/webgpu/swap-chain/WebGpuSwapChain.d.ts +41 -0
- package/dist/webgpu/swap-chain/WebGpuSwapChain.d.ts.map +1 -0
- package/dist/webgpu/texture/WebGpuTexture2D.d.ts +47 -0
- package/dist/webgpu/texture/WebGpuTexture2D.d.ts.map +1 -0
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts +21 -0
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts.map +1 -0
- package/dist/webgpu/texture/WebGpuTextureView.d.ts +25 -0
- package/dist/webgpu/texture/WebGpuTextureView.d.ts.map +1 -0
- package/dist/webgpu/utilities/WebGpuConverter.d.ts +45 -0
- package/dist/webgpu/utilities/WebGpuConverter.d.ts.map +1 -0
- package/package.json +4 -4
- package/shaders/glsl/forward_blinn_phong_material_fs.glsl +110 -0
- package/shaders/glsl/forward_blinn_phong_material_vs.glsl +32 -0
- package/shaders/glsl/main_render_target_flip_y_fs.glsl +35 -1
- package/shaders/glsl/sprite_fs.glsl +1 -1
- package/shaders/glsl/unlit_material_fs.glsl +1 -1
- package/shaders/wgsl/forward_blinn_phong_material.wgsl +150 -0
- package/shaders/wgsl/inspect_texture_mips.wgsl +51 -0
- package/shaders/wgsl/main_frame_buffer.wgsl +35 -0
- package/shaders/wgsl/main_render_target_flip_y.wgsl +35 -0
- package/shaders/wgsl/sprite.wgsl +40 -0
- package/shaders/wgsl/unlit_material.wgsl +49 -0
- package/src/Framework.ts +156 -48
- package/src/api/IFramework.ts +63 -6
- package/src/api/_export.ts +3 -1
- package/src/api/camera/CameraFactory.ts +6 -6
- package/src/api/camera/ICamera.ts +6 -0
- package/src/api/camera/ICameraFactory.ts +5 -10
- package/src/api/camera/OrthographicCamera.ts +23 -1
- package/src/api/camera/PerspectiveCamera.ts +60 -15
- package/src/api/content/ContentManager.ts +78 -16
- package/src/api/content/IContentManager.ts +37 -1
- package/src/api/content/ShaderModuleContent.ts +9 -0
- package/src/api/data/Color.ts +7 -1
- package/src/api/geometry/BaseGeometry.ts +23 -0
- package/src/api/geometry/GeometryBuilder.ts +14 -2
- package/src/api/geometry/IGeometryBuilder.ts +31 -1
- package/src/api/geometry/_export-geometry.ts +2 -1
- package/src/api/input/InputManager.ts +14 -5
- package/src/api/lights/AmbientLight.ts +53 -0
- package/src/api/lights/DirectionalLight.ts +60 -0
- package/src/api/lights/LightFactory.ts +21 -0
- package/src/api/lights/LightId.ts +9 -0
- package/src/api/lights/LightsBuffer.ts +94 -0
- package/src/api/lights/PointLight.ts +91 -0
- package/src/api/lights/_export.ts +5 -0
- package/src/api/loaders/ObjGeometryMapper.ts +28 -0
- package/src/api/loaders/ObjLoader.ts +126 -0
- package/src/api/loaders/_export.ts +3 -1
- package/src/api/loaders/obj/ObjParser.ts +301 -0
- package/src/api/loaders/obj/ObjTypes.ts +142 -0
- package/src/api/loaders/obj/index.ts +5 -0
- package/src/api/material/ForwardBlinnPhongMaterial.ts +328 -0
- package/src/api/material/ICameraMaterial.ts +22 -0
- package/src/api/material/ILightsMaterial.ts +32 -0
- package/src/api/material/IMaterial.ts +13 -10
- package/src/api/material/IMaterialFactory.ts +19 -2
- package/src/api/material/InspectTextureMipsMaterial.ts +65 -26
- package/src/api/material/MaterialFactory.ts +12 -0
- package/src/api/material/SpriteMaterial.ts +83 -0
- package/src/api/material/UnlitMaterial.ts +105 -32
- package/src/api/material/_export.ts +5 -1
- package/src/api/meshes/IMesh.ts +40 -6
- package/src/api/meshes/IMeshFactory.ts +33 -4
- package/src/api/meshes/IRenderableMesh.ts +58 -0
- package/src/api/meshes/Mesh.ts +50 -43
- package/src/api/meshes/MeshFactory.ts +37 -4
- package/src/api/meshes/QuadMesh.ts +6 -4
- package/src/api/meshes/RenderableMesh.ts +207 -0
- package/src/api/meshes/_export.ts +6 -4
- package/src/api/rendering/IGraphicsDeviceFeatures.ts +28 -21
- package/src/api/rendering/IRenderer.ts +34 -1
- package/src/api/rendering/enums.ts +10 -0
- package/src/api/rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.ts +66 -0
- package/src/api/rendering/render-pipelines/IRenderPipeline.ts +4 -0
- package/src/api/rendering/render-pipelines/IRenderPipelineFactory.ts +39 -0
- package/src/api/rendering/render-pipelines/_export-render-pipelines.ts +2 -1
- package/src/api/rendering/renderer-interface.ts +1 -36
- package/src/api/rendering/renderpass/RenderPassDescriptor.ts +10 -14
- package/src/api/rendering/swapchain/ISwapChain.ts +1 -3
- package/src/api/rendering/texture/TextureFormat.ts +128 -14
- package/src/api/rendering/texture/TextureUtilities.ts +225 -10
- package/src/api/scene/Scene.ts +297 -0
- package/src/api/scene/SceneMesh.ts +61 -0
- package/src/api/shader/IShaderModuleLoader.ts +2 -1
- package/src/api/sprites/SpriteBatchDrawable.ts +12 -16
- package/src/api/sprites/SpriteBatchMesh.ts +22 -3
- package/src/api/utilities/AlignUtilities.ts +2 -1
- package/src/api/utilities/GeometryUtilities.ts +2 -0
- package/src/api/window/WindowManager.ts +23 -3
- package/src/core/rendering/ARenderer.ts +24 -15
- package/src/core/rendering/vertex-buffer-layout.ts +32 -1
- package/src/index.ts +0 -1
- package/src/main.ts +2 -4
- package/src/webgl/WebGLGraphicsDeviceFeatures.ts +12 -2
- package/src/webgl/WebGlGpuInfo.ts +1 -1
- package/src/webgl/WebGlGraphicsDevice.ts +0 -1
- package/src/webgl/WebGlRenderer.ts +2 -5
- package/src/webgl/lights/WebGlAmbientLightFactory.ts +35 -0
- package/src/webgl/lights/WebGlLightsBuffer.ts +225 -0
- package/src/webgl/render-pipelines/AWebGlRenderPipeline.ts +7 -1
- package/src/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.ts +21 -1
- package/src/webgl/render-pipelines/WebGlRenderPipelineFactory.ts +24 -2
- package/src/webgl/render-pipelines/inspect/WebGlInspectTextureMipsRenderPipeline.ts +16 -6
- package/src/webgl/render-pipelines/material/WebGlBlinnPhongRenderPipeline.ts +300 -0
- package/src/webgl/render-pipelines/material/WebGlUnlitRenderPipeline.ts +16 -6
- package/src/webgl/render-pipelines/sprite/WebGlSpriteRenderPipeline.ts +11 -7
- package/src/webgl/shader/WebGlShaderModule.ts +11 -4
- package/src/webgl/shader/WebGlShaderModuleLoader.ts +29 -10
- package/src/webgl/swap-chain/WebGlSwapChain.ts +7 -6
- package/src/webgl/texture/WebGlTexture2D.ts +19 -5
- package/src/webgl/texture/WebGlTextureFactory.ts +49 -7
- package/src/webgl/utilities/WebGlConstants.ts +136 -0
- package/src/webgl/utilities/WebGlConverter.ts +91 -22
- package/src/webgl/utilities/WebGlErrorUtilities.ts +15 -0
- package/src/webgl/utilities/WebGlTextureUtilities.ts +5 -2
- package/src/webgl/utilities/WebGlUtilities.ts +4 -0
- package/src/webgl/utilities/webgl-filter-anisotropic-utilities.ts +9 -6
- package/src/webgpu/WebGpuGpuInfo.ts +61 -0
- package/src/webgpu/WebGpuGraphicsDevice.ts +199 -0
- package/src/webgpu/WebGpuGraphicsDeviceFeatures.ts +41 -0
- package/src/webgpu/WebGpuRenderer.ts +49 -0
- package/src/webgpu/WebGpuTypes.ts +288 -0
- package/src/webgpu/blending/WebGpuBlendState.ts +53 -0
- package/src/webgpu/buffers/WebGpuBuffersFactory.ts +46 -0
- package/src/webgpu/buffers/WebGpuIndexBuffer.ts +118 -0
- package/src/webgpu/buffers/WebGpuUniformBuffer.ts +102 -0
- package/src/webgpu/buffers/WebGpuVertexBuffer.ts +119 -0
- package/src/webgpu/primitive/WebGpuPrimitiveState.ts +52 -0
- package/src/webgpu/render-pass/WebGpuRenderPass.ts +131 -0
- package/src/webgpu/render-pipelines/AWebGpuRenderPipeline.ts +123 -0
- package/src/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.ts +119 -0
- package/src/webgpu/render-pipelines/WebGpuRenderPipelineFactory.ts +66 -0
- package/src/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.ts +249 -0
- package/src/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.ts +101 -0
- package/src/webgpu/sampler/WebGpuSampler.ts +84 -0
- package/src/webgpu/shader/WebGpuShaderModule.ts +65 -0
- package/src/webgpu/shader/WebGpuShaderModuleLoader.ts +38 -0
- package/src/webgpu/shader/WgslShaderContent.ts +20 -0
- package/src/webgpu/swap-chain/WebGpuSwapChain.ts +93 -0
- package/src/webgpu/texture/WebGpuTexture2D.ts +197 -0
- package/src/webgpu/texture/WebGpuTextureFactory.ts +118 -0
- package/src/webgpu/texture/WebGpuTextureView.ts +43 -0
- package/src/webgpu/utilities/WebGpuConverter.ts +299 -0
- package/src/wgsl-raw.d.ts +4 -0
- package/dist/api/FrameworkConfiguration.d.ts +0 -23
- package/dist/api/FrameworkConfiguration.d.ts.map +0 -1
- package/dist/api/IFrameworkConfiguration.d.ts +0 -25
- package/dist/api/IFrameworkConfiguration.d.ts.map +0 -1
- package/dist/api/shader/shader-loader.d.ts.map +0 -1
- package/src/api/FrameworkConfiguration.ts +0 -29
- package/src/api/IFrameworkConfiguration.ts +0 -30
- /package/src/api/shader/{shader-loader.ts → ShaderLoader.ts} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
IFramework,
|
|
3
|
-
ISpriteRenderPipeline,
|
|
4
3
|
ITexture2D,
|
|
5
4
|
IUniformBuffer,
|
|
6
5
|
Color,
|
|
7
6
|
IDisposable, ISampler
|
|
8
7
|
} from "../index.ts";
|
|
9
8
|
import {SpriteBatchMesh} from "./SpriteBatchMesh.ts";
|
|
9
|
+
import type {SpriteMaterial} from "../material/SpriteMaterial.ts";
|
|
10
10
|
import type {vec2, vec3} from "gl-matrix";
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -19,7 +19,7 @@ export class SpriteBatchDrawable implements IDisposable {
|
|
|
19
19
|
private readonly _sampler: ISampler;
|
|
20
20
|
private _maxBatchSize: number;
|
|
21
21
|
private _drawingMesh: SpriteBatchMesh = null!;
|
|
22
|
-
private
|
|
22
|
+
private _material: SpriteMaterial = null!;
|
|
23
23
|
|
|
24
24
|
private _needsResize = false;
|
|
25
25
|
|
|
@@ -54,13 +54,13 @@ export class SpriteBatchDrawable implements IDisposable {
|
|
|
54
54
|
|
|
55
55
|
/** Initialize the drawable */
|
|
56
56
|
public initialize(): void {
|
|
57
|
-
this.
|
|
58
|
-
.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
this._material = this._framework.materialFactory.createSpriteMaterial({
|
|
58
|
+
projectionViewBuffer: this.projectionViewBuffer,
|
|
59
|
+
texture: this._texture,
|
|
60
|
+
sampler: this._sampler,
|
|
61
|
+
});
|
|
62
62
|
|
|
63
|
-
this._drawingMesh = new SpriteBatchMesh(this._framework, this._maxBatchSize);
|
|
63
|
+
this._drawingMesh = new SpriteBatchMesh(this._framework, this._material, this._maxBatchSize);
|
|
64
64
|
this._drawingMesh.initialize();
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -115,14 +115,10 @@ export class SpriteBatchDrawable implements IDisposable {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// Draw mesh.
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
this._drawingMesh.indicesOffset = this._fromInstance * 6;
|
|
119
|
+
this._drawingMesh.indicesCount = this._toInstance * 6 - this._drawingMesh.indicesOffset;
|
|
120
120
|
this._drawingMesh.applyChanges();
|
|
121
|
-
this.
|
|
122
|
-
this._drawingMesh.vertexBuffer!,
|
|
123
|
-
this._drawingMesh.indexBuffer!,
|
|
124
|
-
indicesCount,
|
|
125
|
-
indicesOffset);
|
|
121
|
+
this._drawingMesh.draw();
|
|
126
122
|
this._fromInstance = this._toInstance;
|
|
127
123
|
}
|
|
128
124
|
|
|
@@ -140,7 +136,7 @@ export class SpriteBatchDrawable implements IDisposable {
|
|
|
140
136
|
|
|
141
137
|
/** @inheritDoc */
|
|
142
138
|
public dispose(): void {
|
|
143
|
-
this.
|
|
139
|
+
this._material.dispose();
|
|
144
140
|
this._drawingMesh.dispose();
|
|
145
141
|
}
|
|
146
142
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {vec2, vec3} from "gl-matrix";
|
|
2
2
|
import {BufferUsage, type Color, type IFramework, Mesh} from "../index.ts";
|
|
3
|
+
import type {SpriteMaterial} from "../material/SpriteMaterial.ts";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* The sprite batch mesh.
|
|
@@ -15,14 +16,26 @@ export class SpriteBatchMesh extends Mesh {
|
|
|
15
16
|
/** The total number of floats in a sprite. 4 for each vertex * 9 floats per vertex (xyz rgba uv). */
|
|
16
17
|
static readonly TOTAL_FLOATS_IN_SPRITE = 4 * this.TOTAL_FLOATS_PER_VERTEX;
|
|
17
18
|
|
|
19
|
+
private readonly _spriteMaterial: SpriteMaterial;
|
|
18
20
|
private _maxInstances = 0;
|
|
19
21
|
private _lastIndex = -1;
|
|
20
22
|
|
|
23
|
+
/** The offset of the first index to draw. Defaults to 0. */
|
|
24
|
+
public indicesOffset = 0;
|
|
25
|
+
|
|
26
|
+
/** The number of indices to draw. If -1 draws all indices. */
|
|
27
|
+
public indicesCount = -1;
|
|
28
|
+
|
|
21
29
|
/**
|
|
22
30
|
* The constructor for the batch sprite mesh.
|
|
31
|
+
* @param framework - The framework.
|
|
32
|
+
* @param material - The material.
|
|
33
|
+
* @param numberOfInstances - The number of instances.
|
|
23
34
|
*/
|
|
24
|
-
public constructor(framework: IFramework, numberOfInstances: number) {
|
|
35
|
+
public constructor(framework: IFramework, material: SpriteMaterial, numberOfInstances: number) {
|
|
36
|
+
// Drawn by the sprite batch, not by a scene.
|
|
25
37
|
super(framework);
|
|
38
|
+
this._spriteMaterial = material;
|
|
26
39
|
this._maxInstances = numberOfInstances;
|
|
27
40
|
|
|
28
41
|
this._vertexData = new Array(this.maxInstances * SpriteBatchMesh.TOTAL_FLOATS_IN_SPRITE);
|
|
@@ -48,6 +61,13 @@ export class SpriteBatchMesh extends Mesh {
|
|
|
48
61
|
this._indices = indices;
|
|
49
62
|
}
|
|
50
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Draws the mesh with its sprite material, using {@link indicesCount} and {@link indicesOffset}.
|
|
66
|
+
*/
|
|
67
|
+
public draw(): void {
|
|
68
|
+
this._spriteMaterial.render(this._vertexBuffer!, this._indexBuffer!, this.indicesCount, this.indicesOffset);
|
|
69
|
+
}
|
|
70
|
+
|
|
51
71
|
/** The maximum number of instances that can be batched. */
|
|
52
72
|
public get maxInstances() {
|
|
53
73
|
return this._maxInstances;
|
|
@@ -233,8 +253,7 @@ export class SpriteBatchMesh extends Mesh {
|
|
|
233
253
|
/** @inheritDoc */
|
|
234
254
|
public override applyChanges(): void {
|
|
235
255
|
|
|
236
|
-
if(this._lastIndex <= 0)
|
|
237
|
-
{
|
|
256
|
+
if (this._lastIndex <= 0) {
|
|
238
257
|
return;
|
|
239
258
|
}
|
|
240
259
|
|
|
@@ -11,7 +11,8 @@ export class AlignUtilities {
|
|
|
11
11
|
* @returns The aligned value.
|
|
12
12
|
*/
|
|
13
13
|
public static align(value: number, alignment: number): number {
|
|
14
|
-
|
|
14
|
+
const remainder = value % alignment;
|
|
15
|
+
return remainder == 0 ? value : value + alignment - remainder;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -13,6 +13,8 @@ export class GeometryUtilities {
|
|
|
13
13
|
switch (geometryFormat) {
|
|
14
14
|
case GeometryFormat.POS3_COLOR4_TEXTURECOORDS2:
|
|
15
15
|
return (3 + 4 + 2) * Float32Array.BYTES_PER_ELEMENT;
|
|
16
|
+
case GeometryFormat.POS3_COLOR4_TEXTURECOORDS2_NORMAL3:
|
|
17
|
+
return (3 + 4 + 2 + 3) * Float32Array.BYTES_PER_ELEMENT;
|
|
16
18
|
default:
|
|
17
19
|
throw new Error("Unknown geometryFormat");
|
|
18
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { vec2 } from "gl-matrix";
|
|
1
|
+
/**/import type { vec2 } from "gl-matrix";
|
|
2
2
|
import {WindowBounds, type IWindowManager} from "../index.ts";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -8,6 +8,9 @@ export class WindowManager implements IWindowManager {
|
|
|
8
8
|
private readonly _canvas: HTMLCanvasElement;
|
|
9
9
|
private readonly _updateCallbacks: Array<() => void> = [];
|
|
10
10
|
private readonly _renderCallbacks: Array<() => void> = [];
|
|
11
|
+
private readonly _ownsCanvas: boolean;
|
|
12
|
+
private _animationFrame: number | null = null;
|
|
13
|
+
private _disposed = false;
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* The constructor for the WindowManager class.
|
|
@@ -15,6 +18,7 @@ export class WindowManager implements IWindowManager {
|
|
|
15
18
|
*/
|
|
16
19
|
public constructor(canvas: HTMLCanvasElement | null = null) {
|
|
17
20
|
this._canvas = canvas ?? document.createElement("canvas");
|
|
21
|
+
this._ownsCanvas = !canvas;
|
|
18
22
|
if (!canvas) {
|
|
19
23
|
document.body.appendChild(this._canvas);
|
|
20
24
|
}
|
|
@@ -53,12 +57,28 @@ export class WindowManager implements IWindowManager {
|
|
|
53
57
|
initializeForWebGl(): void {
|
|
54
58
|
throw new Error("Method not implemented.");
|
|
55
59
|
}
|
|
60
|
+
/** Stops the event loop, drops all callbacks and removes the canvas when this manager created it. */
|
|
56
61
|
dispose(): void {
|
|
57
|
-
|
|
62
|
+
if (this._disposed) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this._disposed = true;
|
|
66
|
+
if (this._animationFrame !== null) {
|
|
67
|
+
cancelAnimationFrame(this._animationFrame);
|
|
68
|
+
this._animationFrame = null;
|
|
69
|
+
}
|
|
70
|
+
this._updateCallbacks.length = 0;
|
|
71
|
+
this._renderCallbacks.length = 0;
|
|
72
|
+
if (this._ownsCanvas) {
|
|
73
|
+
this._canvas.remove();
|
|
74
|
+
}
|
|
58
75
|
}
|
|
59
76
|
|
|
60
77
|
/** @inheritdoc */
|
|
61
78
|
runEventLoop(): void {
|
|
79
|
+
if (this._disposed) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
62
82
|
for (const callback of this._updateCallbacks) {
|
|
63
83
|
callback();
|
|
64
84
|
}
|
|
@@ -66,7 +86,7 @@ export class WindowManager implements IWindowManager {
|
|
|
66
86
|
callback();
|
|
67
87
|
}
|
|
68
88
|
|
|
69
|
-
requestAnimationFrame(() => this.runEventLoop());
|
|
89
|
+
this._animationFrame = requestAnimationFrame(() => this.runEventLoop());
|
|
70
90
|
}
|
|
71
91
|
|
|
72
92
|
/** @inheritdoc */
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type {ITempRenderer} from "../../api/rendering/renderer-interface.ts";
|
|
2
|
+
import type {vec2} from "gl-matrix";
|
|
3
|
+
import type {RenderingLimits} from "../../api/rendering/rendering-limits.ts";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
type
|
|
5
|
+
Color,
|
|
6
|
+
type IFramework,
|
|
7
|
+
type IGraphicsDevice,
|
|
8
|
+
type IMainRenderTargetRenderPipeline, type IRendererConfiguration,
|
|
9
|
+
type IRenderPass,
|
|
10
|
+
type ISwapChain,
|
|
11
|
+
type ITexture2D,
|
|
12
|
+
type IWindowManager,
|
|
7
13
|
RenderingBackend,
|
|
8
|
-
RenderPassColorAttachment,
|
|
9
|
-
|
|
14
|
+
RenderPassColorAttachment,
|
|
15
|
+
RenderPassDepthStencilAttachment,
|
|
16
|
+
RenderPassDescriptor,
|
|
17
|
+
SwapChainDescriptor,
|
|
18
|
+
TextureFormat,
|
|
10
19
|
TextureUsage
|
|
11
20
|
} from "../../api/index.ts";
|
|
12
|
-
import {
|
|
21
|
+
import {TextureColorSpace} from "../../api/rendering/enums.ts";
|
|
13
22
|
|
|
14
23
|
export abstract class ARenderer implements ITempRenderer {
|
|
15
24
|
|
|
@@ -22,7 +31,6 @@ export abstract class ARenderer implements ITempRenderer {
|
|
|
22
31
|
|
|
23
32
|
private readonly _windowManager: IWindowManager;
|
|
24
33
|
private _graphicsDevice: IGraphicsDevice = null!;
|
|
25
|
-
private _preferredTextureFormat: TextureFormat = TextureFormat.RGBA_8_UNORM;
|
|
26
34
|
private _preferredDepthStencilFormat: TextureFormat = TextureFormat.DEPTH_24_STENCIL_8;
|
|
27
35
|
private readonly _currentBackBufferSize: vec2 = [0, 0];
|
|
28
36
|
private _swapChainRequiresResize: boolean = false;
|
|
@@ -36,6 +44,7 @@ export abstract class ARenderer implements ITempRenderer {
|
|
|
36
44
|
protected _swapChainRenderPass: IRenderPass = null!;
|
|
37
45
|
protected _mainRenderTargetRenderPass?: IRenderPass;
|
|
38
46
|
protected _mainRenderTargetPipeline?: IMainRenderTargetRenderPipeline;
|
|
47
|
+
protected _renderConfiguration: IRendererConfiguration;
|
|
39
48
|
|
|
40
49
|
/** @inheritdoc */
|
|
41
50
|
public get graphicsDevice(): IGraphicsDevice {
|
|
@@ -58,9 +67,7 @@ export abstract class ARenderer implements ITempRenderer {
|
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
/** @inheritdoc */
|
|
61
|
-
public
|
|
62
|
-
return this._preferredTextureFormat;
|
|
63
|
-
}
|
|
70
|
+
public readonly preferredTextureFormat: TextureFormat;
|
|
64
71
|
|
|
65
72
|
/** @inheritdoc */
|
|
66
73
|
public get preferredDepthStencilFormat(): TextureFormat {
|
|
@@ -93,12 +100,16 @@ export abstract class ARenderer implements ITempRenderer {
|
|
|
93
100
|
/**
|
|
94
101
|
* The constructor.
|
|
95
102
|
* @param framework The framework.
|
|
103
|
+
* @param configuration The renderer configuration.
|
|
96
104
|
*/
|
|
97
|
-
constructor(framework: IFramework) {
|
|
105
|
+
protected constructor(framework: IFramework, configuration: IRendererConfiguration) {
|
|
98
106
|
this._framework = framework;
|
|
107
|
+
this._renderConfiguration = configuration;
|
|
99
108
|
this._windowManager = framework.windowManager;
|
|
100
109
|
this._currentBackBufferSize[0] = this._windowManager.canvas.width;
|
|
101
110
|
this._currentBackBufferSize[1] = this._windowManager.canvas.height;
|
|
111
|
+
this.preferredTextureFormat = configuration.textureColorSpace == TextureColorSpace.SRGB
|
|
112
|
+
? TextureFormat.RGBA_8_UNORM_SRGB : TextureFormat.RGBA_8_UNORM;
|
|
102
113
|
}
|
|
103
114
|
|
|
104
115
|
backend: RenderingBackend = RenderingBackend.WEB_GL;
|
|
@@ -136,8 +147,6 @@ export abstract class ARenderer implements ITempRenderer {
|
|
|
136
147
|
this._swapChain = this._graphicsDevice.createSwapChain(
|
|
137
148
|
this._windowManager.canvas,
|
|
138
149
|
new SwapChainDescriptor());
|
|
139
|
-
this._preferredTextureFormat = this._swapChain.textureFormat
|
|
140
|
-
|
|
141
150
|
// TODO: RESIZE EVENT
|
|
142
151
|
|
|
143
152
|
}
|
|
@@ -80,4 +80,35 @@ export class VertexBufferLayout implements IVertexBufferLayout {
|
|
|
80
80
|
]
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
|
|
84
|
+
static createFloat3Float4Float2Float3Layout(): VertexBufferLayout {
|
|
85
|
+
const floatSize = 4;
|
|
86
|
+
|
|
87
|
+
return new VertexBufferLayout(
|
|
88
|
+
(3 + 4 + 2 + 3) * floatSize,
|
|
89
|
+
VertexStepMode.VERTEX,
|
|
90
|
+
[
|
|
91
|
+
{
|
|
92
|
+
format: VertexFormat.FLOAT_32X3,
|
|
93
|
+
offset: 0,
|
|
94
|
+
shaderLocation: 0,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
format: VertexFormat.FLOAT_32X4,
|
|
98
|
+
offset: 3 * floatSize,
|
|
99
|
+
shaderLocation: 1,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
format: VertexFormat.FLOAT_32X2,
|
|
103
|
+
offset: (3 + 4) * floatSize,
|
|
104
|
+
shaderLocation: 2,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
format: VertexFormat.FLOAT_32X3,
|
|
108
|
+
offset: (3 + 4 + 2) * floatSize,
|
|
109
|
+
shaderLocation: 3,
|
|
110
|
+
},
|
|
111
|
+
]
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
package/src/index.ts
CHANGED
package/src/main.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import './style.css'
|
|
2
|
-
import "reflect-metadata";
|
|
3
2
|
|
|
4
3
|
import typescriptLogo from './typescript.svg'
|
|
5
4
|
import viteLogo from '/vite.svg'
|
|
6
5
|
import {Framework} from './Framework.ts';
|
|
7
|
-
import {FrameworkConfiguration} from "./api/FrameworkConfiguration.ts";
|
|
8
6
|
import {TextureSamplerFilteringPreset} from "./core/rendering/enums.ts";
|
|
9
7
|
import {
|
|
10
8
|
Color,
|
|
11
|
-
type IFramework,
|
|
9
|
+
type IFramework, IFrameworkConfiguration,
|
|
12
10
|
type ISampler,
|
|
13
11
|
type ITexture2D,
|
|
14
12
|
Rect,
|
|
@@ -32,7 +30,7 @@ document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
|
|
|
32
30
|
`
|
|
33
31
|
|
|
34
32
|
|
|
35
|
-
const frameworkConfig =
|
|
33
|
+
const frameworkConfig: IFrameworkConfiguration = {} ;
|
|
36
34
|
frameworkConfig.canvas = document.getElementById("game-canvas") as HTMLCanvasElement;
|
|
37
35
|
frameworkConfig.textureFiltering = TextureSamplerFilteringPreset.BILINEAR;
|
|
38
36
|
const framework : IFramework = new Framework(frameworkConfig);
|
|
@@ -14,13 +14,17 @@ export class WebGLGraphicsDeviceFeatures implements IGraphicsDeviceFeatures {
|
|
|
14
14
|
this.supportsTextureCompressionASTC = !!this.astcExtension;
|
|
15
15
|
|
|
16
16
|
this.bptcExtension = webgl.getExtension("EXT_texture_compression_bptc") as EXT_texture_compression_bptc;
|
|
17
|
-
|
|
17
|
+
// BPTC holds BC6H/BC7 (linear and sRGB).
|
|
18
|
+
this.supportsTextureCompressionBC = !!this.bptcExtension;
|
|
18
19
|
|
|
19
20
|
this.etcExtension = webgl.getExtension("WEBGL_compressed_texture_etc") as WEBGL_compressed_texture_etc;
|
|
20
21
|
this.supportsTextureCompressionETC2 = !!this.etcExtension;
|
|
21
22
|
|
|
22
23
|
this.s3tcExtension = webgl.getExtension("WEBGL_compressed_texture_s3tc") as WEBGL_compressed_texture_s3tc;
|
|
23
|
-
this.
|
|
24
|
+
this.supportsTextureCompressionS3TC = !!this.s3tcExtension;
|
|
25
|
+
|
|
26
|
+
this.s3tcSrgbExtension = webgl.getExtension("WEBGL_compressed_texture_s3tc_srgb") as WEBGL_compressed_texture_s3tc_srgb;
|
|
27
|
+
this.supportsTextureCompressionS3TCSrgb = !!this.s3tcSrgbExtension;
|
|
24
28
|
|
|
25
29
|
this.pvrtcExtension = webgl.getExtension("WEBGL_compressed_texture_pvrtc") as WEBGL_compressed_texture_pvrtc;
|
|
26
30
|
this.supportsTextureCompressionPVRTC = !!this.pvrtcExtension;
|
|
@@ -54,4 +58,10 @@ export class WebGLGraphicsDeviceFeatures implements IGraphicsDeviceFeatures {
|
|
|
54
58
|
|
|
55
59
|
/** @inheritdoc */
|
|
56
60
|
readonly supportsTextureCompressionS3TC: boolean;
|
|
61
|
+
|
|
62
|
+
/** The WEBGL_compressed_texture_s3tc_srgb extension. */
|
|
63
|
+
readonly s3tcSrgbExtension?: WEBGL_compressed_texture_s3tc_srgb;
|
|
64
|
+
|
|
65
|
+
/** @inheritdoc */
|
|
66
|
+
readonly supportsTextureCompressionS3TCSrgb: boolean;
|
|
57
67
|
}
|
|
@@ -34,7 +34,7 @@ export class WebGlGpuInfo implements IGPUInfo {
|
|
|
34
34
|
const supportedCompressedTextureFormats = [];
|
|
35
35
|
|
|
36
36
|
if(graphicsDevice.features.supportsTextureCompressionASTC){
|
|
37
|
-
supportedCompressedTextureFormats.push(TextureFormat.
|
|
37
|
+
supportedCompressedTextureFormats.push(TextureFormat.ASTC_4X4_RGBA_UNORM)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if(graphicsDevice.features.supportsTextureCompressionS3TC) {
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { type IRendererConfiguration } from "../api/rendering/renderer-interface.ts";
|
|
2
1
|
import { ARenderer } from "../core/rendering/ARenderer.ts";
|
|
3
2
|
import { WebGlGraphicsDevice } from "./WebGlGraphicsDevice.ts";
|
|
4
|
-
import type {IFramework, IGraphicsDevice} from "../api/index.ts";
|
|
3
|
+
import type {IFramework, IGraphicsDevice, IRendererConfiguration} from "../api/index.ts";
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* The WebGL implementation of the IRenderer interface.
|
|
8
7
|
*/
|
|
9
8
|
export class WebGlRenderer extends ARenderer {
|
|
10
9
|
|
|
11
|
-
private _renderConfiguration: IRendererConfiguration;
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* The constructor.
|
|
@@ -18,8 +16,7 @@ export class WebGlRenderer extends ARenderer {
|
|
|
18
16
|
constructor(
|
|
19
17
|
framework: IFramework,
|
|
20
18
|
renderConfiguration: IRendererConfiguration) {
|
|
21
|
-
super(framework);
|
|
22
|
-
this._renderConfiguration = renderConfiguration;
|
|
19
|
+
super(framework, renderConfiguration);
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
/** @inheritdoc */
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AmbientLight,
|
|
3
|
+
Color,
|
|
4
|
+
type AmbientLightDescriptor,
|
|
5
|
+
type AmbientLightFactory,
|
|
6
|
+
type IFramework,
|
|
7
|
+
type LightsBuffer,
|
|
8
|
+
type LightsBufferDescriptor,
|
|
9
|
+
type Scene,
|
|
10
|
+
} from "../../api/index.ts";
|
|
11
|
+
import {WebGlLightsBuffer} from "./WebGlLightsBuffer.ts";
|
|
12
|
+
|
|
13
|
+
/** The WebGL implementation of the light factory. */
|
|
14
|
+
export class WebGlAmbientLightFactory implements AmbientLightFactory {
|
|
15
|
+
|
|
16
|
+
/** The colour used when no descriptor is given. */
|
|
17
|
+
public static readonly DEFAULT_COLOR = new Color(0.1, 0.1, 0.1);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The constructor.
|
|
21
|
+
* @param _framework The framework.
|
|
22
|
+
*/
|
|
23
|
+
public constructor(private readonly _framework: IFramework) {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** @inheritDoc */
|
|
27
|
+
public createAmbientLight(desc?: AmbientLightDescriptor, scene?: Scene): AmbientLight {
|
|
28
|
+
return new AmbientLight({...desc, color: desc?.color ?? WebGlAmbientLightFactory.DEFAULT_COLOR}, scene);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @inheritDoc */
|
|
32
|
+
public __createLightsBuffer(desc?: LightsBufferDescriptor): LightsBuffer {
|
|
33
|
+
return new WebGlLightsBuffer(this._framework, desc);
|
|
34
|
+
}
|
|
35
|
+
}
|