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
|
@@ -5,6 +5,34 @@ import {MathHelper} from "../utilities/MathHelper.ts";
|
|
|
5
5
|
import {BufferUsage} from "../rendering/buffers/BufferUsage.ts";
|
|
6
6
|
import type { IUniformBuffer } from "../rendering/buffers/IUniformBuffer.ts";
|
|
7
7
|
import {GameTime} from "../time/GameTime.ts";
|
|
8
|
+
import type {Scene} from "../scene/Scene.ts";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The descriptor for a perspective camera. Every field is optional.
|
|
12
|
+
*/
|
|
13
|
+
export interface PerspectiveCameraDescriptor {
|
|
14
|
+
|
|
15
|
+
/** The vertical field of view in degrees. By default, 60. */
|
|
16
|
+
fov?: number;
|
|
17
|
+
|
|
18
|
+
/** The aspect ratio (width / height). By default, 1. */
|
|
19
|
+
aspectRatio?: number;
|
|
20
|
+
|
|
21
|
+
/** The near plane. By default, 0.01. */
|
|
22
|
+
near?: number;
|
|
23
|
+
|
|
24
|
+
/** The far plane. By default, 100. */
|
|
25
|
+
far?: number;
|
|
26
|
+
|
|
27
|
+
/** The eye position. Copied. By default, (0, 0, 3). */
|
|
28
|
+
eye?: vec3;
|
|
29
|
+
|
|
30
|
+
/** The point the camera looks at. Copied. By default, the origin. */
|
|
31
|
+
target?: vec3;
|
|
32
|
+
|
|
33
|
+
/** The up vector. Copied. By default, (0, 1, 0). */
|
|
34
|
+
up?: vec3;
|
|
35
|
+
}
|
|
8
36
|
|
|
9
37
|
/**
|
|
10
38
|
* The perspective camera.
|
|
@@ -26,24 +54,33 @@ export class PerspectiveCamera implements ICamera {
|
|
|
26
54
|
private _projectionBuffer: IUniformBuffer = null!;
|
|
27
55
|
|
|
28
56
|
/**
|
|
29
|
-
* The constructor.
|
|
57
|
+
* The constructor. Call `initialize()` before use (the camera factory does).
|
|
30
58
|
* @param framework The framework.
|
|
31
|
-
* @param
|
|
32
|
-
* @
|
|
33
|
-
* @param
|
|
34
|
-
* @param farPlane The far plane.
|
|
59
|
+
* @param descriptor The optional descriptor; omitted fields use the defaults documented on {@link PerspectiveCameraDescriptor}.
|
|
60
|
+
* `fov` is in degrees; {@link fieldOfView} holds it in radians. Vectors are copied.
|
|
61
|
+
* @param scene The optional scene; the camera assigns itself as `scene.camera`.
|
|
35
62
|
*/
|
|
36
63
|
public constructor(
|
|
37
64
|
framework: IFramework,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
nearPlane: number,
|
|
41
|
-
farPlane: number) {
|
|
65
|
+
descriptor?: PerspectiveCameraDescriptor,
|
|
66
|
+
scene?: Scene) {
|
|
42
67
|
this._framework = framework;
|
|
43
|
-
this.fieldOfView = fov;
|
|
44
|
-
this.aspectRatio = aspectRatio;
|
|
45
|
-
this.nearPlane =
|
|
46
|
-
this.farPlane =
|
|
68
|
+
this.fieldOfView = MathHelper.toRadians(descriptor?.fov ?? 60);
|
|
69
|
+
this.aspectRatio = descriptor?.aspectRatio ?? 1;
|
|
70
|
+
this.nearPlane = descriptor?.near ?? 0.01;
|
|
71
|
+
this.farPlane = descriptor?.far ?? 100;
|
|
72
|
+
if (descriptor?.eye) {
|
|
73
|
+
vec3.copy(this.eye, descriptor.eye);
|
|
74
|
+
}
|
|
75
|
+
if (descriptor?.target) {
|
|
76
|
+
vec3.copy(this.target, descriptor.target);
|
|
77
|
+
}
|
|
78
|
+
if (descriptor?.up) {
|
|
79
|
+
vec3.copy(this.up, descriptor.up);
|
|
80
|
+
}
|
|
81
|
+
if (scene) {
|
|
82
|
+
scene.add(this);
|
|
83
|
+
}
|
|
47
84
|
|
|
48
85
|
this._updateMatrices();
|
|
49
86
|
}
|
|
@@ -159,12 +196,20 @@ export class PerspectiveCamera implements ICamera {
|
|
|
159
196
|
*/
|
|
160
197
|
public initialize(): void {
|
|
161
198
|
const bufferUsage = BufferUsage.UNIFORM | BufferUsage.COPY_DST;
|
|
162
|
-
this._positionBuffer = this._framework.bufferFactory.createUniformBuffer(this.
|
|
199
|
+
this._positionBuffer = this._framework.bufferFactory.createUniformBuffer(this._worldEye(), bufferUsage);
|
|
163
200
|
this._projectionViewBuffer = this._framework.bufferFactory.createUniformBuffer(this.projectionViewMatrix, bufferUsage);
|
|
164
201
|
this._projectionBuffer = this._framework.bufferFactory.createUniformBuffer(this.projectionMatrix, bufferUsage);
|
|
165
202
|
this._viewBuffer = this._framework.bufferFactory.createUniformBuffer(this.viewMatrix, bufferUsage);
|
|
166
203
|
}
|
|
167
204
|
|
|
205
|
+
/**
|
|
206
|
+
* The eye in world space, as used by the view matrix: z is flipped for the right-handed look-at.
|
|
207
|
+
* This is what {@link positionBuffer} holds, std140 `vec3` (padded to 16 bytes).
|
|
208
|
+
*/
|
|
209
|
+
private _worldEye(): number[] {
|
|
210
|
+
return [this.eye[0], this.eye[1], -this.eye[2], 0];
|
|
211
|
+
}
|
|
212
|
+
|
|
168
213
|
/**
|
|
169
214
|
* Updates the camera matrices.
|
|
170
215
|
*/
|
|
@@ -190,7 +235,7 @@ export class PerspectiveCamera implements ICamera {
|
|
|
190
235
|
|
|
191
236
|
/** @inheritDoc */
|
|
192
237
|
public updateBuffers(): void {
|
|
193
|
-
this._positionBuffer.update(this.
|
|
238
|
+
this._positionBuffer.update(this._worldEye());
|
|
194
239
|
this._projectionBuffer.update(this.projectionMatrix);
|
|
195
240
|
this._viewBuffer.update(this.viewMatrix);
|
|
196
241
|
this._projectionViewBuffer.update(this.projectionViewMatrix);
|
|
@@ -3,11 +3,24 @@ import {
|
|
|
3
3
|
type IContentManager,
|
|
4
4
|
type IShaderModuleLoader,
|
|
5
5
|
type ITexture2D,
|
|
6
|
-
type IFramework,
|
|
6
|
+
type IFramework,
|
|
7
|
+
TextureDescriptor,
|
|
8
|
+
TextureFormat,
|
|
9
|
+
ContentConfig,
|
|
10
|
+
TextureUsage,
|
|
11
|
+
type IMesh,
|
|
12
|
+
type IRenderableMesh,
|
|
13
|
+
type GeometryFormat,
|
|
14
|
+
Color,
|
|
15
|
+
type ICamera,
|
|
16
|
+
type IDisposable,
|
|
7
17
|
} from "../index.ts";
|
|
18
|
+
import {ObjGeometryMapper} from "../loaders/ObjGeometryMapper.ts";
|
|
19
|
+
import {ObjLoader} from "../loaders/ObjLoader.ts";
|
|
8
20
|
import {Ktx2Factory} from "ris-ktx2";
|
|
9
21
|
import type {IKtx2Texture} from "ris-ktx2";
|
|
10
22
|
|
|
23
|
+
const KTX2_EXTENSION = ".ktx2";
|
|
11
24
|
|
|
12
25
|
/**
|
|
13
26
|
* The content manager.
|
|
@@ -16,7 +29,7 @@ import type {IKtx2Texture} from "ris-ktx2";
|
|
|
16
29
|
export class ContentManager implements IContentManager {
|
|
17
30
|
|
|
18
31
|
private readonly _ktx2Factory = new Ktx2Factory();
|
|
19
|
-
private readonly _ktx2TextureCache: {[key: string]: IKtx2Texture} = {};
|
|
32
|
+
private readonly _ktx2TextureCache: { [key: string]: IKtx2Texture } = {};
|
|
20
33
|
|
|
21
34
|
/**
|
|
22
35
|
* The constructor.
|
|
@@ -29,53 +42,75 @@ export class ContentManager implements IContentManager {
|
|
|
29
42
|
/** @inheritDoc */
|
|
30
43
|
public async loadKtx2Async(path: string, contentConfig?: ContentConfig): Promise<IKtx2Texture> {
|
|
31
44
|
|
|
45
|
+
// it's fine to call it, handled internally if called multiple times.
|
|
46
|
+
await this._ktx2Factory.initializeAsync();
|
|
47
|
+
|
|
32
48
|
let ktx2Texture = this._ktx2TextureCache[path];
|
|
33
|
-
if(ktx2Texture) {
|
|
49
|
+
if (ktx2Texture) {
|
|
34
50
|
return ktx2Texture;
|
|
35
51
|
}
|
|
36
52
|
|
|
37
53
|
ktx2Texture = await this._ktx2Factory.loadAsync(path);
|
|
38
|
-
if(contentConfig?.keepDataCached == true){
|
|
54
|
+
if (contentConfig?.keepDataCached == true) {
|
|
39
55
|
this._ktx2TextureCache[path] = ktx2Texture;
|
|
40
56
|
}
|
|
41
57
|
return ktx2Texture;
|
|
42
58
|
}
|
|
43
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Disposes the cached shader modules (their GL programs) and forgets cached KTX2 data.
|
|
62
|
+
* Called from `Framework.dispose()`.
|
|
63
|
+
*/
|
|
64
|
+
public dispose(): void {
|
|
65
|
+
(this.shaderModuleLoader as Partial<IDisposable>).dispose?.();
|
|
66
|
+
for (const key of Object.keys(this._ktx2TextureCache)) {
|
|
67
|
+
this._ktx2TextureCache[key].delete();
|
|
68
|
+
delete this._ktx2TextureCache[key];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
44
72
|
/** @inheritDoc */
|
|
45
|
-
public loadShaderModule(shaderModuleId: string): IShaderModule {
|
|
46
|
-
return this.shaderModuleLoader.load(shaderModuleId);
|
|
73
|
+
public loadShaderModule(shaderModuleId: string, keyValueDictionary?: { [id: string]: number }): IShaderModule {
|
|
74
|
+
return this.shaderModuleLoader.load(shaderModuleId, keyValueDictionary);
|
|
47
75
|
}
|
|
48
76
|
|
|
49
77
|
/** @inheritDoc */
|
|
50
78
|
public async loadTexture2DAsync(path: string,
|
|
51
79
|
textureDescriptor?: TextureDescriptor,
|
|
52
80
|
contentConfig?: ContentConfig,
|
|
53
|
-
|
|
81
|
+
): Promise<ITexture2D> {
|
|
82
|
+
|
|
83
|
+
// TODO: check texture cache
|
|
84
|
+
if (path.endsWith(KTX2_EXTENSION)) {
|
|
54
85
|
|
|
55
|
-
|
|
56
|
-
const ktx2Texture = await this.loadKtx2Async(path, contentConfig);
|
|
86
|
+
const ktx2Texture = await this.loadKtx2Async(path);
|
|
57
87
|
textureDescriptor = textureDescriptor ?? new TextureDescriptor();
|
|
58
|
-
|
|
88
|
+
const tex = this._framework.textureFactory.createFromKtx2(ktx2Texture, textureDescriptor);
|
|
89
|
+
if (contentConfig?.keepDataCached !== true) {
|
|
90
|
+
ktx2Texture.delete();
|
|
91
|
+
}
|
|
92
|
+
return tex;
|
|
59
93
|
}
|
|
60
94
|
|
|
61
|
-
let format =
|
|
95
|
+
let format = this._framework.renderer.preferredTextureFormat;
|
|
62
96
|
|
|
63
|
-
if(textureDescriptor && textureDescriptor.textureFormat != TextureFormat.UNDEFINED) {
|
|
97
|
+
if (textureDescriptor && textureDescriptor.textureFormat != TextureFormat.UNDEFINED) {
|
|
64
98
|
format = textureDescriptor.textureFormat;
|
|
65
99
|
}
|
|
66
100
|
|
|
67
|
-
// TODO: pass texture descriptor
|
|
68
101
|
const imageLoader = this._framework.imageLoader;
|
|
69
102
|
const data = await imageLoader.loadAsync(path, contentConfig?.keepDataCached);
|
|
103
|
+
|
|
104
|
+
// TODO: pass texture descriptor
|
|
70
105
|
return this._framework.textureFactory.create(
|
|
71
106
|
data.baseWidth, data.baseHeight,
|
|
72
107
|
data.getData(0) as Uint8Array,
|
|
73
108
|
data.channels,
|
|
74
|
-
|
|
109
|
+
path,
|
|
75
110
|
TextureUsage.TEXTURE_BINDING | TextureUsage.COPY_SRC,
|
|
76
111
|
format,
|
|
77
112
|
textureDescriptor?.generateMipmaps
|
|
78
|
-
|
|
113
|
+
);
|
|
79
114
|
}
|
|
80
115
|
|
|
81
116
|
/** @inheritDoc */
|
|
@@ -84,4 +119,31 @@ export class ContentManager implements IContentManager {
|
|
|
84
119
|
return this._framework.textureFactory.create(width, height, view);
|
|
85
120
|
}
|
|
86
121
|
|
|
87
|
-
|
|
122
|
+
/** @inheritDoc */
|
|
123
|
+
public async loadMeshAsync(path: string, geometryFormat: GeometryFormat): Promise<IMesh> {
|
|
124
|
+
const model = await ObjLoader.parseAsync(path, {ignoreMaterials: true});
|
|
125
|
+
const geometry = this._framework.geometryBuilder.create(ObjGeometryMapper.toDescriptor(model.geometry));
|
|
126
|
+
return this._framework.meshFactory.createMesh(geometry, geometryFormat);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** @inheritDoc */
|
|
130
|
+
public loadUnlitMeshAsync(path: string, camera?: ICamera): Promise<IRenderableMesh> {
|
|
131
|
+
return this._framework.objLoader.loadAsync(path, subMesh => {
|
|
132
|
+
const material = this._framework.materialFactory.createUnlitMaterial({camera});
|
|
133
|
+
const diffuse = subMesh.material?.diffuseColor ?? [1, 1, 1];
|
|
134
|
+
material.diffuseColor = new Color(diffuse[0], diffuse[1], diffuse[2], subMesh.material?.opacity ?? 1);
|
|
135
|
+
return material;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** @inheritDoc */
|
|
140
|
+
public loadBlinnPhongMeshAsync(path: string, camera: ICamera): Promise<IRenderableMesh> {
|
|
141
|
+
if (!camera?.projectionViewBuffer || !camera?.positionBuffer) {
|
|
142
|
+
throw new Error(`loadBlinnPhongMeshAsync("${path}"): the camera has no projectionViewBuffer/positionBuffer. Pass an initialized camera (the camera factory initializes it).`);
|
|
143
|
+
}
|
|
144
|
+
return this._framework.objLoader.loadAsync(path, {
|
|
145
|
+
projectionViewBuffer: camera.projectionViewBuffer,
|
|
146
|
+
cameraPositionBuffer: camera.positionBuffer,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import type { ICamera } from "../camera/ICamera.ts";
|
|
2
|
+
import type { GeometryFormat } from "../geometry/GeometryFormat.ts";
|
|
3
|
+
import type { IRenderableMesh } from "../meshes/IRenderableMesh.ts";
|
|
1
4
|
import type { IShaderModuleLoader } from "../shader/IShaderModuleLoader.ts";
|
|
2
5
|
import type { IShaderModule } from "../shader/IShaderModule.ts";
|
|
3
6
|
import type { ITexture2D } from "../rendering/texture/ITexture2D.ts";
|
|
4
7
|
import {TextureDescriptor} from "../rendering/texture/TextureDescriptor.ts";
|
|
5
8
|
import {ContentConfig} from "./ContentConfig.ts";
|
|
6
9
|
import type { IKtx2Texture } from "ris-ktx2";
|
|
10
|
+
import type {IMesh} from "../meshes/IMesh.ts";
|
|
7
11
|
|
|
8
12
|
/**
|
|
9
13
|
* The content manager.
|
|
@@ -26,9 +30,10 @@ export interface IContentManager {
|
|
|
26
30
|
/**
|
|
27
31
|
* Loads a shader module.
|
|
28
32
|
* @param shaderAssetId - The id of a shader asset.
|
|
33
|
+
* @param keyValueDictionary - If present, tries to find key in shader such that it replaced ##DIRECTIONAL_LIGHT_COUNT## by given value for key DIRECTIONAL_LIGHST_COUNT.
|
|
29
34
|
* @returns The shader module.
|
|
30
35
|
*/
|
|
31
|
-
loadShaderModule(shaderAssetId: string): IShaderModule;
|
|
36
|
+
loadShaderModule(shaderAssetId: string, keyValueDictionary?: { [id:string]: number}): IShaderModule;
|
|
32
37
|
|
|
33
38
|
/**
|
|
34
39
|
* Loads a texture2D.
|
|
@@ -38,4 +43,35 @@ export interface IContentManager {
|
|
|
38
43
|
* @returns The Texture2D.
|
|
39
44
|
*/
|
|
40
45
|
loadTexture2DAsync(path: string, desc?: TextureDescriptor, contentConfig?: ContentConfig): Promise<ITexture2D>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Loads a plain mesh (geometry and buffers only, no material or transform) from an OBJ (Wavefront) file,
|
|
49
|
+
* like C# `ContentManager.LoadMesh`. Materials (.mtl) are not loaded.
|
|
50
|
+
* @param path The path or url to the .obj file.
|
|
51
|
+
* @param geometryFormat The vertex layout of the buffers, e.g. the format of the material it will be drawn with.
|
|
52
|
+
* @return The mesh.
|
|
53
|
+
*/
|
|
54
|
+
loadMeshAsync(path: string, geometryFormat: GeometryFormat): Promise<IMesh>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Loads an OBJ mesh with unlit materials, through `framework.objLoader`.
|
|
58
|
+
* The root mesh has no material; each `usemtl` range is a sub mesh with an unlit material
|
|
59
|
+
* (`Kd` as diffuse colour, `d` as alpha, white when missing). Add it with `scene.add(mesh)`.
|
|
60
|
+
* @param path The path or url to the .obj file.
|
|
61
|
+
* @param camera The optional camera; `scene.update()` assigns the scene camera anyway.
|
|
62
|
+
* @return The root mesh.
|
|
63
|
+
*/
|
|
64
|
+
loadUnlitMeshAsync(path: string, camera?: ICamera): Promise<IRenderableMesh>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Loads an OBJ mesh with Blinn-Phong materials: shorthand for
|
|
68
|
+
* `framework.objLoader.loadAsync(path, {projectionViewBuffer: camera.projectionViewBuffer, cameraPositionBuffer: camera.positionBuffer})`.
|
|
69
|
+
* See `ObjLoader.loadAsync` for the .mtl mapping. Add it with `scene.add(mesh)`; the scene assigns its camera and lights.
|
|
70
|
+
* @param path The path or url to the .obj file. A relative `mtllib` is resolved against it.
|
|
71
|
+
* @param camera An initialized camera (e.g. `scene.camera`).
|
|
72
|
+
* @return The root mesh.
|
|
73
|
+
* @throws Error when the camera has no buffers.
|
|
74
|
+
*/
|
|
75
|
+
loadBlinnPhongMeshAsync(path: string, camera: ICamera): Promise<IRenderableMesh>;
|
|
76
|
+
|
|
41
77
|
}
|
|
@@ -6,6 +6,9 @@ import inspectTextureMipsVS from "../../../shaders/glsl/inspect_texture_mips_vs.
|
|
|
6
6
|
import inspectTextureMipsFS from "../../../shaders/glsl/inspect_texture_mips_fs.glsl?raw";
|
|
7
7
|
import unlitMaterialVS from "../../../shaders/glsl/unlit_material_vs.glsl?raw";
|
|
8
8
|
import unlitMaterialFS from "../../../shaders/glsl/unlit_material_fs.glsl?raw";
|
|
9
|
+
import forwardBlinnPhongVS from "../../../shaders/glsl/forward_blinn_phong_material_vs.glsl?raw";
|
|
10
|
+
import forwardBlinnPhongFS from "../../../shaders/glsl/forward_blinn_phong_material_fs.glsl?raw";
|
|
11
|
+
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* The api should look something like this for internal ones.
|
|
@@ -43,5 +46,11 @@ export const ShaderModuleContent : {[id: string]: any} = {
|
|
|
43
46
|
"vertex": unlitMaterialVS,
|
|
44
47
|
"fragment": unlitMaterialFS,
|
|
45
48
|
"reflection": {}
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
"forward_blinn_phong_material": {
|
|
52
|
+
"vertex": forwardBlinnPhongVS,
|
|
53
|
+
"fragment": forwardBlinnPhongFS,
|
|
54
|
+
"reflection": {}
|
|
46
55
|
}
|
|
47
56
|
}
|
package/src/api/data/Color.ts
CHANGED
|
@@ -222,7 +222,13 @@ export class Color implements Iterable<number>{
|
|
|
222
222
|
o
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Copy self and return new instance with same values.
|
|
227
|
+
* @return Color
|
|
228
|
+
* */
|
|
229
|
+
public copy(): Color {
|
|
230
|
+
return new Color(this.r, this.g, this.b, this.a);
|
|
231
|
+
}
|
|
226
232
|
}
|
|
227
233
|
|
|
228
234
|
|
|
@@ -2,11 +2,34 @@ import { GeometryFormat } from "./GeometryFormat.ts";
|
|
|
2
2
|
import {VertexFormat} from "./VertexFormat.ts";
|
|
3
3
|
import type {IGeometry} from "../index.ts";
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* The default IGeometry implementation. GeometryBuilder fills it with vertex data.
|
|
7
8
|
*/
|
|
8
9
|
export class BaseGeometry implements IGeometry {
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Initializes a new instance of the BaseGeometry class.
|
|
13
|
+
* @param positions The optional positions of the geometry.
|
|
14
|
+
* @param indices The optional indices of the geometry.
|
|
15
|
+
* @param normals The optional normals of the geometry.
|
|
16
|
+
* @param textureCoords The optional texture coordinates of the geometry.
|
|
17
|
+
* @param colors The optional colors of the geometry.
|
|
18
|
+
*/
|
|
19
|
+
constructor(positions?: number[], indices?: number[], normals?: number[], textureCoords?: number[], colors?: number[]) {
|
|
20
|
+
this.positions = positions;
|
|
21
|
+
this.indices = indices;
|
|
22
|
+
this.normals = normals;
|
|
23
|
+
this.textureCoords = textureCoords;
|
|
24
|
+
this.colors = colors;
|
|
25
|
+
|
|
26
|
+
if(this.indices && this.indices.length > 0) {
|
|
27
|
+
this.vertexCount = this.indices.length / 3;
|
|
28
|
+
} else if(this.positions && this.positions.length > 0) {
|
|
29
|
+
this.vertexCount = this.positions.length / 3;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
10
33
|
/** @inheritdoc */
|
|
11
34
|
public vertexCount: number = 0;
|
|
12
35
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { vec2 } from "gl-matrix"
|
|
2
2
|
import { BaseGeometry } from "./BaseGeometry.ts";
|
|
3
|
-
import type {IGeometry, IGeometryBuilder} from "../index.ts";
|
|
3
|
+
import type {IGeometry, IGeometryBuilder, GeometryDescriptor} from "../index.ts";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The GeometryBuilder class provides methods for creating various types of geometries, such as quads, with specified parameters like scale and winding order.
|
|
@@ -55,4 +55,16 @@ export class GeometryBuilder implements IGeometryBuilder {
|
|
|
55
55
|
|
|
56
56
|
return geometry;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
|
|
59
|
+
/** @inheritdoc */
|
|
60
|
+
public create(descriptor: GeometryDescriptor): IGeometry {
|
|
61
|
+
const vertexCount = descriptor.positions.length / 3;
|
|
62
|
+
return new BaseGeometry(
|
|
63
|
+
[...descriptor.positions],
|
|
64
|
+
descriptor.indices ? [...descriptor.indices] : undefined,
|
|
65
|
+
descriptor.normals ? [...descriptor.normals] : new Array(vertexCount * 3).fill(0),
|
|
66
|
+
descriptor.textureCoords ? [...descriptor.textureCoords] : new Array(vertexCount * 2).fill(0),
|
|
67
|
+
descriptor.colors ? [...descriptor.colors] : new Array(vertexCount * 4).fill(1),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import type { IGeometry } from "./IGeometry.ts";
|
|
2
2
|
import {vec2} from "gl-matrix";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The geometry descriptor.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface GeometryDescriptor {
|
|
9
|
+
|
|
10
|
+
/** Positions, 3 per vertex. */
|
|
11
|
+
readonly positions: number[];
|
|
12
|
+
|
|
13
|
+
/** Triangle indices, 3 per triangle. Optional for non-indexed geometry. */
|
|
14
|
+
readonly indices?: number[];
|
|
15
|
+
|
|
16
|
+
/** Normals, 3 per vertex. */
|
|
17
|
+
readonly normals?: number[];
|
|
18
|
+
|
|
19
|
+
/** Texture coordinates, 2 per vertex. */
|
|
20
|
+
readonly textureCoords?: number[];
|
|
21
|
+
|
|
22
|
+
/** RGBA colours, 4 per vertex. */
|
|
23
|
+
readonly colors?: number[];
|
|
24
|
+
}
|
|
25
|
+
|
|
4
26
|
/**
|
|
5
27
|
* The geometry builder.
|
|
6
28
|
*/
|
|
@@ -13,5 +35,13 @@ export interface IGeometryBuilder {
|
|
|
13
35
|
* @returns The geometry.
|
|
14
36
|
*/
|
|
15
37
|
quadGeometry(scale?: vec2, counterClockwise?: boolean): IGeometry;
|
|
16
|
-
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates geometry from a plain descriptor.
|
|
41
|
+
* Attributes a material's geometry format needs but the descriptor lacks are filled with defaults:
|
|
42
|
+
* white colours, zero texture coordinates and zero normals.
|
|
43
|
+
* @param descriptor - The geometry descriptor. Its arrays are copied.
|
|
44
|
+
* @returns The geometry.
|
|
45
|
+
*/
|
|
46
|
+
create(descriptor: GeometryDescriptor): IGeometry;
|
|
17
47
|
}
|
|
@@ -63,6 +63,8 @@ export class InputManager implements IInputManager {
|
|
|
63
63
|
private readonly _touchCapabilities: TouchPanelCapabilities;
|
|
64
64
|
private readonly _contacts: TouchContact[];
|
|
65
65
|
private _touchListening = false;
|
|
66
|
+
/** Aborting it removes every canvas listener added in initialize(). */
|
|
67
|
+
private _listeners = new AbortController();
|
|
66
68
|
/** Set in update, consumed in afterUpdate. Ageing before a publish would hide the press. */
|
|
67
69
|
private _touchPublished = false;
|
|
68
70
|
|
|
@@ -120,6 +122,13 @@ export class InputManager implements IInputManager {
|
|
|
120
122
|
return this._touchCapabilities;
|
|
121
123
|
}
|
|
122
124
|
|
|
125
|
+
/** Removes the canvas listeners. Called from `Framework.dispose()`. */
|
|
126
|
+
public dispose(): void {
|
|
127
|
+
this._listeners.abort();
|
|
128
|
+
this._listeners = new AbortController();
|
|
129
|
+
this._touchListening = false;
|
|
130
|
+
}
|
|
131
|
+
|
|
123
132
|
/** @inheritDoc */
|
|
124
133
|
public initialize(): void {
|
|
125
134
|
|
|
@@ -133,20 +142,20 @@ export class InputManager implements IInputManager {
|
|
|
133
142
|
canvas.addEventListener("mousemove", (e: MouseEvent) => {
|
|
134
143
|
this._mousePosition[0] = e.clientX;
|
|
135
144
|
this._mousePosition[1] = e.clientY;
|
|
136
|
-
});
|
|
145
|
+
}, {signal: this._listeners.signal});
|
|
137
146
|
|
|
138
147
|
canvas.addEventListener("mousedown", (e: MouseEvent) => {
|
|
139
148
|
const idx = e.button;
|
|
140
149
|
const btn = this._mouseButtonMap[idx] ?? MouseButton.NONE;
|
|
141
150
|
this._mouseButtonDown[btn] = true;
|
|
142
|
-
})
|
|
151
|
+
}, {signal: this._listeners.signal})
|
|
143
152
|
|
|
144
153
|
canvas.addEventListener("mouseup", (e: MouseEvent) => {
|
|
145
154
|
const idx = e.button;
|
|
146
155
|
const btn = this._mouseButtonMap[idx] ?? MouseButton.NONE;
|
|
147
156
|
this._mouseButtonDown[btn] = false;
|
|
148
157
|
this._mouseButtonReleased[btn] = true;
|
|
149
|
-
});
|
|
158
|
+
}, {signal: this._listeners.signal});
|
|
150
159
|
|
|
151
160
|
canvas.addEventListener("wheel", (e: WheelEvent) => {
|
|
152
161
|
|
|
@@ -167,7 +176,7 @@ export class InputManager implements IInputManager {
|
|
|
167
176
|
vec2.set(this._scrollWheelPosition, x, y);
|
|
168
177
|
|
|
169
178
|
e.preventDefault();
|
|
170
|
-
})
|
|
179
|
+
}, {signal: this._listeners.signal})
|
|
171
180
|
}
|
|
172
181
|
|
|
173
182
|
private _handleTouchEvents(canvas: HTMLCanvasElement): void {
|
|
@@ -179,7 +188,7 @@ export class InputManager implements IInputManager {
|
|
|
179
188
|
// Pan and pinch-zoom start on this canvas only. The rest of the page is left alone.
|
|
180
189
|
canvas.style.touchAction = "none";
|
|
181
190
|
|
|
182
|
-
const options = InputManager._touchListenerOptions;
|
|
191
|
+
const options: AddEventListenerOptions = {...InputManager._touchListenerOptions, signal: this._listeners.signal};
|
|
183
192
|
canvas.addEventListener("touchstart", this._onTouchStart, options);
|
|
184
193
|
canvas.addEventListener("touchmove", this._onTouchMove, options);
|
|
185
194
|
canvas.addEventListener("touchend", this._onTouchEnd, options);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {Color} from "../data/Color.ts";
|
|
2
|
+
import {createLightId} from "./LightId.ts";
|
|
3
|
+
import type {Scene} from "../scene/Scene.ts";
|
|
4
|
+
|
|
5
|
+
/** The descriptor for an ambient light. All fields are optional. */
|
|
6
|
+
export interface AmbientLightDescriptor {
|
|
7
|
+
/** The unique id. Assigned automatically when omitted. */
|
|
8
|
+
id?: number;
|
|
9
|
+
|
|
10
|
+
/** The optional name for a light. */
|
|
11
|
+
name?: string;
|
|
12
|
+
|
|
13
|
+
/** The light colour. Alpha is ignored. Defaults to black. */
|
|
14
|
+
color?: Color;
|
|
15
|
+
|
|
16
|
+
/** Multiplies the colour. Defaults to 1. */
|
|
17
|
+
intensity?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The ambient light. Plain data: it has no GPU resources.
|
|
22
|
+
* Put it into a {@link LightsBuffer} to use it in shaders.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export class AmbientLight {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The constructor.
|
|
29
|
+
* @param descriptor The optional descriptor. The colour is copied.
|
|
30
|
+
* @param scene The optional scene to register with.
|
|
31
|
+
*/
|
|
32
|
+
public constructor(descriptor?: AmbientLightDescriptor, scene?: Scene) {
|
|
33
|
+
|
|
34
|
+
this.id = descriptor?.id ?? createLightId();
|
|
35
|
+
this.name = descriptor?.name;
|
|
36
|
+
this.color = descriptor?.color?.copy() ?? Color.black();
|
|
37
|
+
this.intensity = descriptor?.intensity ?? 1;
|
|
38
|
+
|
|
39
|
+
scene?.add(this);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The unique id of this light. */
|
|
43
|
+
public readonly id: number;
|
|
44
|
+
|
|
45
|
+
/** The optional name for a light. */
|
|
46
|
+
public name?: string;
|
|
47
|
+
|
|
48
|
+
/** The light color. Alpha is ignored. */
|
|
49
|
+
public color: Color;
|
|
50
|
+
|
|
51
|
+
/** Multiplies {@link color} when written to the lights buffer. */
|
|
52
|
+
public intensity: number;
|
|
53
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {vec3} from "gl-matrix";
|
|
2
|
+
import {Color} from "../data/Color.ts";
|
|
3
|
+
import {createLightId} from "./LightId.ts";
|
|
4
|
+
import type {Scene} from "../scene/Scene.ts";
|
|
5
|
+
|
|
6
|
+
/** The descriptor for a directional light. All fields are optional. */
|
|
7
|
+
export interface DirectionalLightDescriptor {
|
|
8
|
+
/** The unique id. Assigned automatically when omitted. */
|
|
9
|
+
id?: number;
|
|
10
|
+
|
|
11
|
+
/** The optional name for a light. */
|
|
12
|
+
name?: string;
|
|
13
|
+
|
|
14
|
+
/** The light colour. Alpha is ignored. Defaults to white. */
|
|
15
|
+
color?: Color;
|
|
16
|
+
|
|
17
|
+
/** Multiplies the colour. Defaults to 1. */
|
|
18
|
+
intensity?: number;
|
|
19
|
+
|
|
20
|
+
/** The direction in which the light travels. Defaults to straight down, (0, -1, 0). */
|
|
21
|
+
direction?: vec3;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The directional light. Plain data: it has no GPU resources.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export class DirectionalLight {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The constructor.
|
|
32
|
+
* @param descriptor The optional descriptor. Colour and direction are copied.
|
|
33
|
+
* @param scene The optional scene; the light adds itself via {@link Scene.add}.
|
|
34
|
+
* @throws Error when the scene has no free directional light slot left (the light is then not in the scene).
|
|
35
|
+
*/
|
|
36
|
+
public constructor(descriptor?: DirectionalLightDescriptor, scene?: Scene) {
|
|
37
|
+
this.id = descriptor?.id ?? createLightId();
|
|
38
|
+
this.name = descriptor?.name;
|
|
39
|
+
this.color = descriptor?.color?.copy() ?? Color.white();
|
|
40
|
+
this.intensity = descriptor?.intensity ?? 1;
|
|
41
|
+
this.direction = descriptor?.direction ? vec3.clone(descriptor.direction) : vec3.fromValues(0, -1, 0);
|
|
42
|
+
|
|
43
|
+
scene?.add(this);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The unique id of this light. */
|
|
47
|
+
public readonly id: number;
|
|
48
|
+
|
|
49
|
+
/** The optional name for a light. */
|
|
50
|
+
public name?: string;
|
|
51
|
+
|
|
52
|
+
/** The light colour. Alpha is ignored. */
|
|
53
|
+
public color: Color;
|
|
54
|
+
|
|
55
|
+
/** Multiplies {@link color} when written to the lights buffer. */
|
|
56
|
+
public intensity: number;
|
|
57
|
+
|
|
58
|
+
/** The direction in which the light travels. */
|
|
59
|
+
public direction: vec3;
|
|
60
|
+
}
|