ris-framework 0.2.0-dev.11 → 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.
Files changed (257) hide show
  1. package/CHANGELOG.md +22 -29
  2. package/README.md +13 -1
  3. package/dist/Framework.d.ts +26 -8
  4. package/dist/Framework.d.ts.map +1 -1
  5. package/dist/api/IFramework.d.ts +43 -0
  6. package/dist/api/IFramework.d.ts.map +1 -1
  7. package/dist/api/_export.d.ts +1 -1
  8. package/dist/api/_export.d.ts.map +1 -1
  9. package/dist/api/content/ContentManager.d.ts +5 -57
  10. package/dist/api/content/ContentManager.d.ts.map +1 -1
  11. package/dist/api/content/IContentManager.d.ts +24 -21
  12. package/dist/api/content/IContentManager.d.ts.map +1 -1
  13. package/dist/api/lights/LightsBuffer.d.ts +13 -6
  14. package/dist/api/lights/LightsBuffer.d.ts.map +1 -1
  15. package/dist/api/loaders/ObjGeometryMapper.d.ts +2 -2
  16. package/dist/api/loaders/ObjLoader.d.ts +61 -0
  17. package/dist/api/loaders/ObjLoader.d.ts.map +1 -0
  18. package/dist/api/loaders/_export.d.ts +1 -0
  19. package/dist/api/loaders/_export.d.ts.map +1 -1
  20. package/dist/api/loaders/obj/{ObjLoader.d.ts → ObjParser.d.ts} +20 -5
  21. package/dist/api/loaders/obj/ObjParser.d.ts.map +1 -0
  22. package/dist/api/loaders/obj/ObjTypes.d.ts +17 -1
  23. package/dist/api/loaders/obj/ObjTypes.d.ts.map +1 -1
  24. package/dist/api/loaders/obj/index.d.ts +1 -1
  25. package/dist/api/material/ForwardBlinnPhongMaterial.d.ts +22 -11
  26. package/dist/api/material/ForwardBlinnPhongMaterial.d.ts.map +1 -1
  27. package/dist/api/material/ICameraMaterial.d.ts +18 -0
  28. package/dist/api/material/ICameraMaterial.d.ts.map +1 -0
  29. package/dist/api/material/ILightsMaterial.d.ts +26 -0
  30. package/dist/api/material/ILightsMaterial.d.ts.map +1 -0
  31. package/dist/api/material/IMaterial.d.ts +2 -8
  32. package/dist/api/material/IMaterial.d.ts.map +1 -1
  33. package/dist/api/material/InspectTextureMipsMaterial.d.ts +2 -2
  34. package/dist/api/material/InspectTextureMipsMaterial.d.ts.map +1 -1
  35. package/dist/api/material/SpriteMaterial.d.ts +2 -2
  36. package/dist/api/material/SpriteMaterial.d.ts.map +1 -1
  37. package/dist/api/material/UnlitMaterial.d.ts +4 -3
  38. package/dist/api/material/UnlitMaterial.d.ts.map +1 -1
  39. package/dist/api/material/_export.d.ts +2 -0
  40. package/dist/api/material/_export.d.ts.map +1 -1
  41. package/dist/api/meshes/IMesh.d.ts +29 -34
  42. package/dist/api/meshes/IMesh.d.ts.map +1 -1
  43. package/dist/api/meshes/IMeshFactory.d.ts +13 -8
  44. package/dist/api/meshes/IMeshFactory.d.ts.map +1 -1
  45. package/dist/api/meshes/IRenderableMesh.d.ts +47 -0
  46. package/dist/api/meshes/IRenderableMesh.d.ts.map +1 -0
  47. package/dist/api/meshes/Mesh.d.ts +11 -57
  48. package/dist/api/meshes/Mesh.d.ts.map +1 -1
  49. package/dist/api/meshes/MeshFactory.d.ts +6 -3
  50. package/dist/api/meshes/MeshFactory.d.ts.map +1 -1
  51. package/dist/api/meshes/QuadMesh.d.ts +3 -5
  52. package/dist/api/meshes/QuadMesh.d.ts.map +1 -1
  53. package/dist/api/meshes/RenderableMesh.d.ts +95 -0
  54. package/dist/api/meshes/RenderableMesh.d.ts.map +1 -0
  55. package/dist/api/meshes/_export.d.ts +2 -1
  56. package/dist/api/meshes/_export.d.ts.map +1 -1
  57. package/dist/api/rendering/IGraphicsDeviceFeatures.d.ts +8 -2
  58. package/dist/api/rendering/IGraphicsDeviceFeatures.d.ts.map +1 -1
  59. package/dist/api/rendering/IRenderer.d.ts +28 -1
  60. package/dist/api/rendering/IRenderer.d.ts.map +1 -1
  61. package/dist/api/rendering/enums.d.ts +7 -0
  62. package/dist/api/rendering/enums.d.ts.map +1 -1
  63. package/dist/api/rendering/renderer-interface.d.ts +1 -31
  64. package/dist/api/rendering/renderer-interface.d.ts.map +1 -1
  65. package/dist/api/rendering/renderpass/RenderPassDescriptor.d.ts +2 -6
  66. package/dist/api/rendering/renderpass/RenderPassDescriptor.d.ts.map +1 -1
  67. package/dist/api/rendering/swapchain/ISwapChain.d.ts +1 -3
  68. package/dist/api/rendering/swapchain/ISwapChain.d.ts.map +1 -1
  69. package/dist/api/rendering/texture/TextureFormat.d.ts +88 -14
  70. package/dist/api/rendering/texture/TextureFormat.d.ts.map +1 -1
  71. package/dist/api/rendering/texture/TextureUtilities.d.ts +23 -0
  72. package/dist/api/rendering/texture/TextureUtilities.d.ts.map +1 -1
  73. package/dist/api/scene/Scene.d.ts +30 -21
  74. package/dist/api/scene/Scene.d.ts.map +1 -1
  75. package/dist/api/scene/SceneMesh.d.ts +27 -0
  76. package/dist/api/scene/SceneMesh.d.ts.map +1 -0
  77. package/dist/api/utilities/AlignUtilities.d.ts.map +1 -1
  78. package/dist/api/window/WindowManager.d.ts.map +1 -1
  79. package/dist/core/rendering/ARenderer.d.ts +5 -5
  80. package/dist/core/rendering/ARenderer.d.ts.map +1 -1
  81. package/dist/index.d.ts +0 -1
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +4006 -1355
  84. package/dist/webgl/WebGLGraphicsDeviceFeatures.d.ts +4 -0
  85. package/dist/webgl/WebGLGraphicsDeviceFeatures.d.ts.map +1 -1
  86. package/dist/webgl/WebGlRenderer.d.ts +1 -3
  87. package/dist/webgl/WebGlRenderer.d.ts.map +1 -1
  88. package/dist/webgl/lights/WebGlLightsBuffer.d.ts +8 -4
  89. package/dist/webgl/lights/WebGlLightsBuffer.d.ts.map +1 -1
  90. package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts +2 -0
  91. package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts.map +1 -1
  92. package/dist/webgl/swap-chain/WebGlSwapChain.d.ts +3 -2
  93. package/dist/webgl/swap-chain/WebGlSwapChain.d.ts.map +1 -1
  94. package/dist/webgl/texture/WebGlTextureFactory.d.ts +7 -0
  95. package/dist/webgl/texture/WebGlTextureFactory.d.ts.map +1 -1
  96. package/dist/webgl/utilities/WebGlConstants.d.ts +91 -0
  97. package/dist/webgl/utilities/WebGlConstants.d.ts.map +1 -0
  98. package/dist/webgl/utilities/WebGlConverter.d.ts +0 -7
  99. package/dist/webgl/utilities/WebGlConverter.d.ts.map +1 -1
  100. package/dist/webgl/utilities/WebGlErrorUtilities.d.ts +10 -0
  101. package/dist/webgl/utilities/WebGlErrorUtilities.d.ts.map +1 -0
  102. package/dist/webgl/utilities/WebGlTextureUtilities.d.ts.map +1 -1
  103. package/dist/webgl/utilities/WebGlUtilities.d.ts +3 -0
  104. package/dist/webgl/utilities/WebGlUtilities.d.ts.map +1 -1
  105. package/dist/webgpu/WebGpuGpuInfo.d.ts +28 -0
  106. package/dist/webgpu/WebGpuGpuInfo.d.ts.map +1 -0
  107. package/dist/webgpu/WebGpuGraphicsDevice.d.ts +80 -0
  108. package/dist/webgpu/WebGpuGraphicsDevice.d.ts.map +1 -0
  109. package/dist/webgpu/WebGpuGraphicsDeviceFeatures.d.ts +26 -0
  110. package/dist/webgpu/WebGpuGraphicsDeviceFeatures.d.ts.map +1 -0
  111. package/dist/webgpu/WebGpuRenderer.d.ts +26 -0
  112. package/dist/webgpu/WebGpuRenderer.d.ts.map +1 -0
  113. package/dist/webgpu/WebGpuTypes.d.ts +355 -0
  114. package/dist/webgpu/WebGpuTypes.d.ts.map +1 -0
  115. package/dist/webgpu/blending/WebGpuBlendState.d.ts +30 -0
  116. package/dist/webgpu/blending/WebGpuBlendState.d.ts.map +1 -0
  117. package/dist/webgpu/buffers/WebGpuBuffersFactory.d.ts +20 -0
  118. package/dist/webgpu/buffers/WebGpuBuffersFactory.d.ts.map +1 -0
  119. package/dist/webgpu/buffers/WebGpuIndexBuffer.d.ts +46 -0
  120. package/dist/webgpu/buffers/WebGpuIndexBuffer.d.ts.map +1 -0
  121. package/dist/webgpu/buffers/WebGpuUniformBuffer.d.ts +43 -0
  122. package/dist/webgpu/buffers/WebGpuUniformBuffer.d.ts.map +1 -0
  123. package/dist/webgpu/buffers/WebGpuVertexBuffer.d.ts +49 -0
  124. package/dist/webgpu/buffers/WebGpuVertexBuffer.d.ts.map +1 -0
  125. package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts +32 -0
  126. package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts.map +1 -0
  127. package/dist/webgpu/render-pass/WebGpuRenderPass.d.ts +28 -0
  128. package/dist/webgpu/render-pass/WebGpuRenderPass.d.ts.map +1 -0
  129. package/dist/webgpu/render-pipelines/AWebGpuRenderPipeline.d.ts +50 -0
  130. package/dist/webgpu/render-pipelines/AWebGpuRenderPipeline.d.ts.map +1 -0
  131. package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts +34 -0
  132. package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts.map +1 -0
  133. package/dist/webgpu/render-pipelines/WebGpuRenderPipelineFactory.d.ts +26 -0
  134. package/dist/webgpu/render-pipelines/WebGpuRenderPipelineFactory.d.ts.map +1 -0
  135. package/dist/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.d.ts +72 -0
  136. package/dist/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.d.ts.map +1 -0
  137. package/dist/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.d.ts +40 -0
  138. package/dist/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.d.ts.map +1 -0
  139. package/dist/webgpu/sampler/WebGpuSampler.d.ts +39 -0
  140. package/dist/webgpu/sampler/WebGpuSampler.d.ts.map +1 -0
  141. package/dist/webgpu/shader/WebGpuShaderModule.d.ts +29 -0
  142. package/dist/webgpu/shader/WebGpuShaderModule.d.ts.map +1 -0
  143. package/dist/webgpu/shader/WebGpuShaderModuleLoader.d.ts +21 -0
  144. package/dist/webgpu/shader/WebGpuShaderModuleLoader.d.ts.map +1 -0
  145. package/dist/webgpu/shader/WgslShaderContent.d.ts +9 -0
  146. package/dist/webgpu/shader/WgslShaderContent.d.ts.map +1 -0
  147. package/dist/webgpu/swap-chain/WebGpuSwapChain.d.ts +41 -0
  148. package/dist/webgpu/swap-chain/WebGpuSwapChain.d.ts.map +1 -0
  149. package/dist/webgpu/texture/WebGpuTexture2D.d.ts +47 -0
  150. package/dist/webgpu/texture/WebGpuTexture2D.d.ts.map +1 -0
  151. package/dist/webgpu/texture/WebGpuTextureFactory.d.ts +21 -0
  152. package/dist/webgpu/texture/WebGpuTextureFactory.d.ts.map +1 -0
  153. package/dist/webgpu/texture/WebGpuTextureView.d.ts +25 -0
  154. package/dist/webgpu/texture/WebGpuTextureView.d.ts.map +1 -0
  155. package/dist/webgpu/utilities/WebGpuConverter.d.ts +45 -0
  156. package/dist/webgpu/utilities/WebGpuConverter.d.ts.map +1 -0
  157. package/package.json +2 -2
  158. package/shaders/glsl/main_render_target_flip_y_fs.glsl +35 -1
  159. package/shaders/wgsl/forward_blinn_phong_material.wgsl +150 -0
  160. package/shaders/wgsl/inspect_texture_mips.wgsl +51 -0
  161. package/shaders/wgsl/main_frame_buffer.wgsl +35 -0
  162. package/shaders/wgsl/main_render_target_flip_y.wgsl +35 -0
  163. package/shaders/wgsl/sprite.wgsl +40 -0
  164. package/shaders/wgsl/unlit_material.wgsl +49 -0
  165. package/src/Framework.ts +121 -37
  166. package/src/api/IFramework.ts +55 -0
  167. package/src/api/_export.ts +1 -1
  168. package/src/api/content/ContentManager.ts +46 -180
  169. package/src/api/content/IContentManager.ts +25 -21
  170. package/src/api/lights/LightsBuffer.ts +13 -6
  171. package/src/api/loaders/ObjGeometryMapper.ts +2 -2
  172. package/src/api/loaders/ObjLoader.ts +126 -0
  173. package/src/api/loaders/_export.ts +1 -0
  174. package/src/api/loaders/obj/{ObjLoader.ts → ObjParser.ts} +35 -4
  175. package/src/api/loaders/obj/ObjTypes.ts +19 -1
  176. package/src/api/loaders/obj/index.ts +1 -1
  177. package/src/api/material/ForwardBlinnPhongMaterial.ts +48 -22
  178. package/src/api/material/ICameraMaterial.ts +22 -0
  179. package/src/api/material/ILightsMaterial.ts +32 -0
  180. package/src/api/material/IMaterial.ts +2 -9
  181. package/src/api/material/InspectTextureMipsMaterial.ts +2 -2
  182. package/src/api/material/SpriteMaterial.ts +2 -2
  183. package/src/api/material/UnlitMaterial.ts +4 -3
  184. package/src/api/material/_export.ts +2 -0
  185. package/src/api/meshes/IMesh.ts +32 -37
  186. package/src/api/meshes/IMeshFactory.ts +14 -8
  187. package/src/api/meshes/IRenderableMesh.ts +58 -0
  188. package/src/api/meshes/Mesh.ts +17 -132
  189. package/src/api/meshes/MeshFactory.ts +14 -5
  190. package/src/api/meshes/QuadMesh.ts +4 -6
  191. package/src/api/meshes/RenderableMesh.ts +207 -0
  192. package/src/api/meshes/_export.ts +6 -5
  193. package/src/api/rendering/IGraphicsDeviceFeatures.ts +28 -21
  194. package/src/api/rendering/IRenderer.ts +34 -1
  195. package/src/api/rendering/enums.ts +10 -0
  196. package/src/api/rendering/renderer-interface.ts +1 -36
  197. package/src/api/rendering/renderpass/RenderPassDescriptor.ts +10 -14
  198. package/src/api/rendering/swapchain/ISwapChain.ts +1 -3
  199. package/src/api/rendering/texture/TextureFormat.ts +128 -14
  200. package/src/api/rendering/texture/TextureUtilities.ts +225 -10
  201. package/src/api/scene/Scene.ts +102 -69
  202. package/src/api/scene/SceneMesh.ts +61 -0
  203. package/src/api/sprites/SpriteBatchMesh.ts +1 -1
  204. package/src/api/utilities/AlignUtilities.ts +2 -1
  205. package/src/api/window/WindowManager.ts +1 -1
  206. package/src/core/rendering/ARenderer.ts +24 -15
  207. package/src/index.ts +0 -1
  208. package/src/main.ts +2 -3
  209. package/src/webgl/WebGLGraphicsDeviceFeatures.ts +12 -2
  210. package/src/webgl/WebGlGpuInfo.ts +1 -1
  211. package/src/webgl/WebGlRenderer.ts +2 -5
  212. package/src/webgl/lights/WebGlLightsBuffer.ts +14 -4
  213. package/src/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.ts +18 -1
  214. package/src/webgl/swap-chain/WebGlSwapChain.ts +7 -6
  215. package/src/webgl/texture/WebGlTextureFactory.ts +49 -7
  216. package/src/webgl/utilities/WebGlConstants.ts +136 -0
  217. package/src/webgl/utilities/WebGlConverter.ts +91 -22
  218. package/src/webgl/utilities/WebGlErrorUtilities.ts +15 -0
  219. package/src/webgl/utilities/WebGlTextureUtilities.ts +5 -2
  220. package/src/webgl/utilities/WebGlUtilities.ts +4 -0
  221. package/src/webgpu/WebGpuGpuInfo.ts +61 -0
  222. package/src/webgpu/WebGpuGraphicsDevice.ts +199 -0
  223. package/src/webgpu/WebGpuGraphicsDeviceFeatures.ts +41 -0
  224. package/src/webgpu/WebGpuRenderer.ts +49 -0
  225. package/src/webgpu/WebGpuTypes.ts +288 -0
  226. package/src/webgpu/blending/WebGpuBlendState.ts +53 -0
  227. package/src/webgpu/buffers/WebGpuBuffersFactory.ts +46 -0
  228. package/src/webgpu/buffers/WebGpuIndexBuffer.ts +118 -0
  229. package/src/webgpu/buffers/WebGpuUniformBuffer.ts +102 -0
  230. package/src/webgpu/buffers/WebGpuVertexBuffer.ts +119 -0
  231. package/src/webgpu/primitive/WebGpuPrimitiveState.ts +52 -0
  232. package/src/webgpu/render-pass/WebGpuRenderPass.ts +131 -0
  233. package/src/webgpu/render-pipelines/AWebGpuRenderPipeline.ts +123 -0
  234. package/src/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.ts +119 -0
  235. package/src/webgpu/render-pipelines/WebGpuRenderPipelineFactory.ts +66 -0
  236. package/src/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.ts +249 -0
  237. package/src/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.ts +101 -0
  238. package/src/webgpu/sampler/WebGpuSampler.ts +84 -0
  239. package/src/webgpu/shader/WebGpuShaderModule.ts +65 -0
  240. package/src/webgpu/shader/WebGpuShaderModuleLoader.ts +38 -0
  241. package/src/webgpu/shader/WgslShaderContent.ts +20 -0
  242. package/src/webgpu/swap-chain/WebGpuSwapChain.ts +93 -0
  243. package/src/webgpu/texture/WebGpuTexture2D.ts +197 -0
  244. package/src/webgpu/texture/WebGpuTextureFactory.ts +118 -0
  245. package/src/webgpu/texture/WebGpuTextureView.ts +43 -0
  246. package/src/webgpu/utilities/WebGpuConverter.ts +299 -0
  247. package/src/wgsl-raw.d.ts +4 -0
  248. package/dist/api/FrameworkConfiguration.d.ts +0 -23
  249. package/dist/api/FrameworkConfiguration.d.ts.map +0 -1
  250. package/dist/api/IFrameworkConfiguration.d.ts +0 -25
  251. package/dist/api/IFrameworkConfiguration.d.ts.map +0 -1
  252. package/dist/api/loaders/obj/ObjLoader.d.ts.map +0 -1
  253. package/dist/api/meshes/SubMesh.d.ts +0 -47
  254. package/dist/api/meshes/SubMesh.d.ts.map +0 -1
  255. package/src/api/FrameworkConfiguration.ts +0 -29
  256. package/src/api/IFrameworkConfiguration.ts +0 -30
  257. package/src/api/meshes/SubMesh.ts +0 -71
package/CHANGELOG.md CHANGED
@@ -9,44 +9,37 @@ Compared with `main` (0.1.0).
9
9
 
10
10
  ### Breaking changes
11
11
 
12
- - **tsyringe and reflect-metadata removed.** Services are created by `Framework` and get their dependencies through constructors. Consumers no longer need `reflect-metadata` or decorator settings.
13
- - **Perspective camera.** `cameraFactory.createPerspectiveCamera(descriptor?, scene?)` takes a `PerspectiveCameraDescriptor` (`fov` in degrees, `aspectRatio`, `near`, `far`, `eye`, `target`, `up`) instead of `(fov, aspectRatio, near, far)`. The `PerspectiveCamera` constructor is `(framework, descriptor?, scene?)` instead of `(framework, fov, aspectRatio, nearPlane, farPlane)`.
14
- - **`ICamera.positionBuffer`.** This new member is required (std140 world-space eye). Custom `ICamera` implementations must provide it. `PerspectiveCamera`, `OrthographicCamera` and `OrbitCamera` implement it.
15
- - **Meshes.** `meshFactory.create(scene, geometry, material)` replaces `create(geometry, geometryFormat)`. The `Mesh` constructor is `(framework, scene, material?)` instead of `(framework)`. The `QuadMesh` constructor is `(framework, scene, material, isUpdatable, scale?)`.
16
- - **Materials.** `IMaterial.modelMatrix` is replaced by `IMaterial.modelBuffer`. The mesh owns the model buffer and assigns it before drawing. `UnlitMaterial` and `InspectTextureMipsMaterial` no longer create their own model buffer. They create their render pipeline once a model buffer is assigned, and rendering without one throws.
17
- - **Render pipelines.** `createUnlitRenderPipeline` and `createInspectTextureMipsRenderPipeline` throw when no model buffer is passed.
12
+ - `FrameworkConfiguration` is no longer exported; pass an `IFrameworkConfiguration` object to `new Framework(...)`.
13
+ - `tsyringe` and `reflect-metadata` are removed; services use plain constructor wiring.
14
+ - `cameraFactory.createPerspectiveCamera` takes a descriptor object, and every `ICamera` now requires a `positionBuffer`.
15
+ - Meshes are split into `IMesh`/`Mesh` (geometry and buffers) and `IRenderableMesh`/`RenderableMesh` (material, index range, sub meshes, transform).
16
+ - Materials take a `modelBuffer` owned by the mesh instead of `modelMatrix`, and `renderMesh` takes an `IRenderableMesh`.
17
+ - Render pipelines throw when no model buffer is passed.
18
+ - Requires `ris-ktx2` 0.2.
18
19
 
19
20
  ### Added
20
21
 
21
- - `Scene` holds meshes, lights and the active camera. `scene.add(item)` and `scene.remove(item)` accept a mesh, `AmbientLight`, `DirectionalLight`, `PointLight` or camera. Adding the same item twice does nothing. Meshes, lights and the perspective camera given a scene in their constructor add themselves, and a disposed mesh removes itself. Removing the active camera clears `scene.camera`. `scene.update(time)` assigns the camera to materials and uploads changed lights. `scene.render()` draws every mesh.
22
- - Lights: `AmbientLight`, `DirectionalLight` and `PointLight` (constant, linear and quadratic attenuation) are plain data classes with descriptors, `intensity`, auto-assigned ids and an optional `scene` constructor argument. `LightsBuffer` is a std140 lights buffer with configurable directional and point light slots, and it uploads only when light data changed. `framework.lightsFactory` creates them.
23
- - `ForwardBlinnPhongMaterial` with ambient, diffuse and Blinn-Phong specular lighting from directional and point lights. Normals use the normal matrix, so non-uniform scale is handled. Specular colour and shininess come from MTL `Ks` and `Ns`, and shader variants are cached per light count. Its descriptor requires `projectionViewBuffer` and `cameraPositionBuffer`, and `materialFactory.createForwardBlinnPhongMaterial(descriptor)` creates it.
24
- - Mesh transforms: `mesh.position`, `mesh.rotation` (Euler radians, applied Y, then X, then Z), `mesh.scale` and a lazily computed `mesh.modelMatrix` / `mesh.modelBuffer`. Submeshes use their parent's transform.
25
- - Submeshes: one mesh can draw several index ranges, each with its own material (`mesh.addSubMesh`, `meshFactory.createWithSubMeshes`).
26
- - OBJ/MTL loading:
27
- - `ObjLoader` is framework-independent and produces plain definitions. `ObjLoader.loadAsync(path, options)` supports `resolveMaterialUrl` and `ignoreMaterials`.
28
- - `content.loadMeshAsync(path, scene)` loads a mesh with unlit materials, and `content.loadBlinnPhongMeshAsync(path, scene)` loads one with Blinn-Phong materials.
29
- - `geometryBuilder.create(descriptor)` with `GeometryDescriptor`. `BaseGeometry` is exported.
30
- - `SpriteMaterial` and `materialFactory.createSpriteMaterial`; sprite batches draw through it.
31
- - `UnlitMaterialDescriptor.camera` and a `camera` property on the unlit and Blinn-Phong materials. A scene assigns its camera through this property.
32
- - Examples: `unlit_mesh`, `blinn_phong_mesh` and `sprite_batch`, with `npm run dev:examples` and `npm run build:examples`.
22
+ - WebGPU backend (preview): set `renderingBackend` and call `framework.initializeAsync()`. Only unlit materials are supported so far; WebGL stays the default and is used as a fallback.
23
+ - `Scene` with `add`/`remove` for meshes, lights and the camera, plus `SceneMesh` for owning a mesh and its materials.
24
+ - Lights: `AmbientLight`, `DirectionalLight` and `PointLight`.
25
+ - `ForwardBlinnPhongMaterial`, `SpriteMaterial`, and the `ICameraMaterial`/`ILightsMaterial` interfaces.
26
+ - Mesh transforms (`position`, `rotation`, `scale`) and sub meshes (`addSubMesh`, `meshFactory.createWithSubMeshes`).
27
+ - OBJ/MTL loading through `framework.objLoader`, `ObjParser`, and `content.loadMeshAsync`, `loadUnlitMeshAsync` and `loadBlinnPhongMeshAsync`.
28
+ - `geometryBuilder.create(descriptor)` and the exported `BaseGeometry`.
29
+ - sRGB compressed texture formats (BC1, BC3, BC7, ETC2), with KTX2 loading choosing sRGB automatically.
30
+ - Examples: `unlit_mesh`, `unlit_mesh_webgpu`, `blinn_phong_mesh` and `sprite_batch`.
33
31
 
34
32
  ### Changed
35
33
 
36
- - `content.loadShaderModule(id, replacements?)` takes optional `##KEY##` replacement values, and they are part of the shader cache key.
34
+ - `content.loadShaderModule` accepts optional replacement values.
37
35
 
38
36
  ### Fixed
39
37
 
40
- - The sprite fragment shader added `vec4(1.0)` to every pixel, so sprites rendered white.
41
- - The orthographic camera's default eye was at z = -1 instead of z = 1.
42
- - The default texture was a static shared by every `Framework` instance, so a second framework (a new GL context) reused a texture from the old one. It is now per framework.
43
- - The anisotropic filtering helper cached the extension object from the first GL context on a shared static. It is now looked up per context.
44
- - A leftover `debugger` statement in `WebGlGraphicsDevice` initialization is removed.
45
-
46
- ### Removed
47
-
48
- - The `tsyringe` and `reflect-metadata` dependencies.
49
- - `IMaterial.modelMatrix`, replaced by `modelBuffer` (see Breaking changes).
38
+ - Sprites rendered white because of a stray value in the sprite shader.
39
+ - The orthographic camera's default eye was on the wrong side (z = -1).
40
+ - A second `Framework` instance reused the default texture and anisotropic-filtering extension from the first.
41
+ - A leftover `debugger` statement in WebGL device initialization.
42
+ - Swapped BC/S3TC compression flags could select BC7 on GPUs without BPTC support.
50
43
 
51
44
  ## [0.1.0]
52
45
 
package/README.md CHANGED
@@ -168,7 +168,19 @@ Setting `framework.renderer.clearColor` after `initialize()` updates later frame
168
168
 
169
169
  ## Scene
170
170
 
171
- `new Scene(framework)` holds meshes, lights and the camera. `scene.add(item)` and `scene.remove(item)` accept a mesh, an `AmbientLight`, `DirectionalLight`, `PointLight` or a camera; adding twice does nothing. Meshes, lights and the perspective camera given a scene in their constructor add themselves, and a disposed mesh removes itself. Adding a camera makes it `scene.camera`; removing the active camera clears it. `addLight`/`removeLight` remain as deprecated aliases.
171
+ `new Scene(framework)` holds meshes, lights and the camera. `scene.add(item)` and `scene.remove(item)` accept a renderable mesh (wrapped in a `SceneMesh`, which owns and disposes its materials), an `AmbientLight`, `DirectionalLight`, `PointLight` or a camera; adding twice does nothing. Lights and the perspective camera given a scene in their constructor add themselves. Adding a camera makes it `scene.camera`; removing the active camera clears it. `scene.update(time)` hands the camera, the active ambient light and the scene's light lists (by reference) to the materials. `addLight`/`removeLight` remain as deprecated aliases.
172
+
173
+ Meshes follow the C# framework: `IMesh`/`Mesh` hold geometry and buffers only; `IRenderableMesh`/`RenderableMesh` add an optional material, an index range (`indexStart`, `indexCount`, -1 for all), sub meshes that share the root's buffers, and the transform with one model buffer per root. OBJ files load through `framework.objLoader`:
174
+
175
+ ```ts
176
+ const mesh = await framework.objLoader.loadAsync(url, {
177
+ projectionViewBuffer: camera.projectionViewBuffer,
178
+ cameraPositionBuffer: camera.positionBuffer,
179
+ }); // one ForwardBlinnPhongMaterial per usemtl material
180
+ // or: framework.objLoader.loadAsync(url, subMesh => myMaterial(subMesh.material))
181
+ // or: await ObjLoader.parseAsync(url) for plain data without GPU resources
182
+ scene.add(mesh);
183
+ ```
172
184
 
173
185
  ## Examples
174
186
 
@@ -1,29 +1,38 @@
1
- import { type ICameraFactory, type IContentManager, type IFramework, IFrameworkConfiguration, type IImageLoader, type IRenderer, type IRenderPipelineFactory, type IWindowManager } from "./api/index.js";
2
- import { GameTime, type IBufferFactory, type IGeometryBuilder, type IGraphicsDevice, type IImageProcessor, type IInputManager, type IMaterialFactory, type AmbientLightFactory, type IMeshFactory, type ISpriteBatch, type ITextureFactory, type ITimeManager, RenderingBackend } from "./api/index.js";
1
+ import { ObjLoader } from "./api/loaders/ObjLoader.js";
2
+ import { type AmbientLightFactory, GameTime, type IBufferFactory, type ICameraFactory, type IContentManager, type IFramework, IFrameworkConfiguration, type IGeometryBuilder, type IGraphicsDevice, type IImageLoader, type IImageProcessor, type IInputManager, type IMaterialFactory, type IMeshFactory, type IRenderer, type IRenderPipelineFactory, type ISpriteBatch, type ITextureFactory, type ITimeManager, type IWindowManager, RenderingBackend } from "./api/index.js";
3
3
  import type { IKtx2Factory } from "ris-ktx2";
4
+ /** The Ris framework */
4
5
  export declare class Framework implements IFramework {
5
6
  private readonly _onLoadContentListeners;
6
7
  private readonly _onInitializeListeners;
7
8
  private readonly _onUpdateListeners;
8
9
  private readonly _onRenderListeners;
9
- private readonly _textureFactory;
10
- private readonly _buffersFactory;
11
- private readonly _contentManager;
10
+ private _configuration;
11
+ private _textureFactory;
12
+ private _buffersFactory;
13
+ private _contentManager;
14
+ private readonly _rendererConfiguration;
15
+ private _renderer;
12
16
  private readonly _geometryBuilder;
13
17
  private readonly _meshFactory;
14
18
  private _disposed;
15
19
  /**
16
20
  * The constructor for the Framework class.
17
- * @param options The optional framework configuration. When omitted, a default `FrameworkConfiguration` is used.
21
+ * @param configuration The optional framework configuration. When omitted, a default `FrameworkConfiguration` is used.
18
22
  */
19
- constructor(options?: IFrameworkConfiguration);
23
+ constructor(configuration?: IFrameworkConfiguration);
20
24
  /** @inheritDoc */
21
25
  readonly imageLoader: IImageLoader;
22
26
  renderingBackend: RenderingBackend;
23
27
  /** @inheritDoc */
24
28
  readonly imageProcessor: IImageProcessor;
25
29
  /** @inheritDoc */
26
- readonly renderer: IRenderer;
30
+ get renderer(): IRenderer;
31
+ /**
32
+ * Creates the backend-specific services: renderer, texture factory, pipeline factory, shader loader and buffers factory.
33
+ * @param backend WEB_GL or WEB_GPU.
34
+ */
35
+ private _setupBackendServices;
27
36
  /** @inheritDoc */
28
37
  readonly spriteBatch: ISpriteBatch;
29
38
  /** @inheritDoc */
@@ -68,6 +77,8 @@ export declare class Framework implements IFramework {
68
77
  /** @inheritdoc */
69
78
  get meshFactory(): IMeshFactory;
70
79
  /** @inheritDoc */
80
+ readonly objLoader: ObjLoader;
81
+ /** @inheritDoc */
71
82
  readonly materialFactory: IMaterialFactory;
72
83
  /** @inheritDoc */
73
84
  readonly lightsFactory: AmbientLightFactory;
@@ -77,6 +88,13 @@ export declare class Framework implements IFramework {
77
88
  readonly input: IInputManager;
78
89
  /** @inheritdoc */
79
90
  initialize(): void;
91
+ /**
92
+ * Initializes the framework and starts the event loop. Required for WebGPU, which requests its adapter
93
+ * and device asynchronously; for WebGL it behaves like {@link initialize}.
94
+ * If the WebGPU device cannot be acquired, the framework falls back to WebGL with a warning.
95
+ */
96
+ initializeAsync(): Promise<void>;
97
+ private _initializeCore;
80
98
  /**
81
99
  * Stops the event loop and disposes the framework's services and GL resources,
82
100
  * including per-framework caches such as the default texture and the shader modules.
@@ -1 +1 @@
1
- {"version":3,"file":"Framework.d.ts","sourceRoot":"","sources":["../src/Framework.ts"],"names":[],"mappings":"AAQA,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,UAAU,EAAE,uBAAuB,EACxC,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAGH,QAAQ,EACR,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,aAAa,EAElB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,YAAY,EAGjB,gBAAgB,EAEnB,MAAM,gBAAgB,CAAC;AASxB,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAK3C,qBAAa,SAAU,YAAW,UAAU;IAExC,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAsB;IAC9D,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAsB;IAC7D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAwC;IAC3E,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAsB;IAEzD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAClD,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U,IAAI,IAAI;IAezB;;;;OAIG;IACU,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB7C,OAAO,CAAC,eAAe;IA4CvB;;;;OAIG;IACI,OAAO,IAAI,IAAI;CAoBzB"}
@@ -7,6 +7,7 @@ import type { IBufferFactory } from "./rendering/buffers/IBufferFactory.js";
7
7
  import type { IGeometryBuilder } from "./geometry/IGeometryBuilder.js";
8
8
  import type { ICameraFactory } from "./camera/ICameraFactory.js";
9
9
  import type { ITextureFactory } from "./rendering/texture/ITextureFactory.js";
10
+ import type { ObjLoader } from "./loaders/ObjLoader.js";
10
11
  import type { IContentManager } from "./content/IContentManager.js";
11
12
  import type { IImageLoader } from "./loaders/IImageLoader.js";
12
13
  import type { IMeshFactory } from "./meshes/IMeshFactory.js";
@@ -19,6 +20,39 @@ import { GameTime } from "./time/GameTime.js";
19
20
  import type { IImageProcessor } from "./image/IImageProcessor.js";
20
21
  import type { IKtx2Factory } from "ris-ktx2";
21
22
  import type { IDisposable } from "./core/IDisposable.js";
23
+ import type { vec2 } from "gl-matrix";
24
+ import type { TextureSamplerFilteringPreset } from "../core/rendering/enums.js";
25
+ import type { PowerPreferenceType } from "./rendering/PowerPreference.js";
26
+ import type { TextureColorSpace } from "./rendering/enums.js";
27
+ /**
28
+ * The configuration for the framework.
29
+ * @public
30
+ **/
31
+ export declare class IFrameworkConfiguration {
32
+ /** If true, creates and makes the KTX2 factory available. */
33
+ useKtx2?: boolean;
34
+ /** The size of back buffer. By default, if not specified (800, 600). */
35
+ backBufferSize?: vec2;
36
+ /** The texture filtering to configure */
37
+ textureFiltering?: TextureSamplerFilteringPreset;
38
+ /** The texture color space to use by default. By default, it is {@link TextureColorSpace.SRGB}. */
39
+ textureColorSpace?: TextureColorSpace;
40
+ /**
41
+ * The HTMLCanvasElement to use for rendering.
42
+ * If null, a new canvas will be created and added to the document body.
43
+ */
44
+ canvas?: HTMLCanvasElement;
45
+ /** Should back buffer use alpha. */
46
+ alpha?: boolean;
47
+ /** The preference when it comes to selecting GPU device. Only makes sense to set on multi-GPU devices. */
48
+ powerPreference?: PowerPreferenceType;
49
+ /**
50
+ * The rendering backend. Defaults to WebGL.
51
+ * WebGPU requires `Framework.initializeAsync()`; when `navigator.gpu` is missing or no device is available,
52
+ * the framework falls back to WebGL with a warning.
53
+ */
54
+ renderingBackend?: RenderingBackend;
55
+ }
22
56
  /** The framework interface. */
23
57
  export interface IFramework extends IDisposable {
24
58
  /**
@@ -72,6 +106,10 @@ export interface IFramework extends IDisposable {
72
106
  * The mesh factory.
73
107
  */
74
108
  readonly meshFactory: IMeshFactory;
109
+ /**
110
+ * The OBJ loader: `objLoader.loadAsync(path, blinnPhongDescriptor | subMesh => material)`.
111
+ */
112
+ readonly objLoader: ObjLoader;
75
113
  /**
76
114
  * The material factory.
77
115
  */
@@ -122,5 +160,10 @@ export interface IFramework extends IDisposable {
122
160
  removeOnRenderListener(event: () => void): void;
123
161
  /** Initializes the framework. */
124
162
  initialize(): void;
163
+ /**
164
+ * Initializes the framework asynchronously and starts the event loop.
165
+ * Required for the WebGPU backend; for WebGL it behaves like {@link initialize}.
166
+ */
167
+ initializeAsync(): Promise<void>;
125
168
  }
126
169
  //# sourceMappingURL=IFramework.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IFramework.d.ts","sourceRoot":"","sources":["../../src/api/IFramework.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wDAAwD,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,E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CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAElD,+CAA+C;IAC/C,2BAA2B,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAErD;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,IAAI,CAAC;IAE/D;;OAEG;IACH,sBAAsB,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,IAAI,CAAC;IAElE;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAE7C;;OAEG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAEhD,iCAAiC;IACjC,UAAU,IAAI,IAAI,CAAC;IAEnB;;;OAGG;IACH,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAEpC"}
@@ -1,5 +1,4 @@
1
1
  export * from "./IFramework.js";
2
- export * from "./IFrameworkConfiguration.js";
3
2
  export * from "./rendering/texture/_export-texture.js";
4
3
  export * from "./rendering/buffers/_export-buffers.js";
5
4
  export * from "./data/_export.js";
@@ -24,6 +23,7 @@ export * from "./meshes/_export.js";
24
23
  export * from "./material/_export.js";
25
24
  export * from "./lights/_export.js";
26
25
  export * from "./scene/Scene.js";
26
+ export * from "./scene/SceneMesh.js";
27
27
  export * from "./input/_export.js";
28
28
  export * from "./image/_export.js";
29
29
  //# sourceMappingURL=_export.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_export.d.ts","sourceRoot":"","sources":["../../src/api/_export.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;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c,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { type IShaderModule, type IContentManager, type IShaderModuleLoader, type ITexture2D, type IFramework, TextureDescriptor, ContentConfig, type IMesh, type Scene } from "../index.js";
1
+ import { type IShaderModule, type IContentManager, type IShaderModuleLoader, type ITexture2D, type IFramework, TextureDescriptor, ContentConfig, type IMesh, type IRenderableMesh, type GeometryFormat, type ICamera } from "../index.js";
2
2
  import type { IKtx2Texture } from "ris-ktx2";
3
3
  /**
4
4
  * The content manager.
@@ -9,7 +9,6 @@ export declare class ContentManager implements IContentManager {
9
9
  readonly shaderModuleLoader: IShaderModuleLoader;
10
10
  private readonly _ktx2Factory;
11
11
  private readonly _ktx2TextureCache;
12
- private readonly _objLoader;
13
12
  /**
14
13
  * The constructor.
15
14
  * @param _framework The framework.
@@ -32,61 +31,10 @@ export declare class ContentManager implements IContentManager {
32
31
  /** @inheritDoc */
33
32
  loadTexture2DFromPixels(width: number, height: number, pixels: ArrayBuffer): ITexture2D;
34
33
  /** @inheritDoc */
35
- loadMeshAsync(path: string, scene: Scene): Promise<IMesh>;
34
+ loadMeshAsync(path: string, geometryFormat: GeometryFormat): Promise<IMesh>;
36
35
  /** @inheritDoc */
37
- loadBlinnPhongMeshAsync(path: string, scene: Scene): Promise<IMesh>;
38
- /**
39
- * Loads the OBJ file and its .mtl material libraries.
40
- * @param path The path or url to the .obj file.
41
- * @returns The plain OBJ data.
42
- */
43
- private _loadObj;
44
- /**
45
- * Creates framework geometry from the OBJ geometry.
46
- * Vertex colours stay white, because each submesh's material carries the colour.
47
- * @param definition The OBJ geometry definition.
48
- * @returns The geometry.
49
- */
50
- private _createGeometry;
51
- /**
52
- * Creates one submesh descriptor per material range.
53
- * Ranges that use the same material name share one material instance.
54
- * @param objResult The loaded OBJ data.
55
- * @param createMaterial Creates the material for a definition (undefined without `usemtl` or .mtl entry).
56
- * @returns The submesh descriptors, in file order.
57
- */
58
- private _createSubMeshDescriptors;
59
- /**
60
- * Indexes material definitions by name.
61
- * @param definitions The material definitions from the .mtl files.
62
- * @returns A map from material name to definition.
63
- */
64
- private _indexMaterialDefinitions;
65
- /**
66
- * Finds the definition for a `usemtl` name.
67
- * @param definitionsByName The definitions by name.
68
- * @param materialName The material name, or undefined for faces without `usemtl`.
69
- * @returns The definition, or undefined when there is none.
70
- */
71
- private _findMaterialDefinition;
72
- /**
73
- * Creates the default unlit material for an OBJ material definition.
74
- * The diffuse colour is the definition's `Kd` with `d` as alpha; white when there is no definition.
75
- * @param definition The material definition, or undefined.
76
- * @param camera The scene's current camera, or undefined; the scene assigns it on update.
77
- * @returns The unlit material.
78
- */
79
- private _createUnlitMaterial;
80
- /**
81
- * Creates a Blinn-Phong material for an OBJ material definition.
82
- * `Kd` (with `d` as alpha) becomes the diffuse colour, white when missing.
83
- * `Ka` becomes the ambient colour; when missing the diffuse colour is used, so ambient light tints by the surface colour.
84
- * `Ks` and `Ns` become specular colour and shininess; when missing the material defaults stay (0.5 grey, 32).
85
- * @param definition The material definition, or undefined.
86
- * @param camera The scene's camera; its projection view and position buffers are bound.
87
- * @param lightsBuffer The optional lights buffer; the shader is compiled for its light counts.
88
- * @returns The Blinn-Phong material.
89
- */
90
- private _createBlinnPhongMaterial;
36
+ loadUnlitMeshAsync(path: string, camera?: ICamera): Promise<IRenderableMesh>;
37
+ /** @inheritDoc */
38
+ loadBlinnPhongMeshAsync(path: string, camera: ICamera): Promise<IRenderableMesh>;
91
39
  }
92
40
  //# sourceMappingURL=ContentManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContentManager.d.ts","sourceRoot":"","sources":["../../../src/api/content/ContentManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,K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E,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,aAAa;IAI7G,kBAAkB;IACL,kBAAkB,CAAC,IAAI,EAAE,MAAM,EACZ,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,aAAa,CAAC,EAAE,aAAa,GAC1D,OAAO,CAAC,UAAU,CAAC;IAmCtB,kBAAkB;IACX,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,UAAU;IAK9F,kBAAkB;IACL,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC;IAMxF,kBAAkB;IACX,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC;IASnF,kBAAkB;IACX,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC;CAS1F"}
@@ -1,4 +1,6 @@
1
- import type { Scene } from "../scene/Scene.js";
1
+ import type { ICamera } from "../camera/ICamera.js";
2
+ import type { GeometryFormat } from "../geometry/GeometryFormat.js";
3
+ import type { IRenderableMesh } from "../meshes/IRenderableMesh.js";
2
4
  import type { IShaderModuleLoader } from "../shader/IShaderModuleLoader.js";
3
5
  import type { IShaderModule } from "../shader/IShaderModule.js";
4
6
  import type { ITexture2D } from "../rendering/texture/ITexture2D.js";
@@ -39,30 +41,31 @@ export interface IContentManager {
39
41
  */
40
42
  loadTexture2DAsync(path: string, desc?: TextureDescriptor, contentConfig?: ContentConfig): Promise<ITexture2D>;
41
43
  /**
42
- * Loads a mesh from a model, typically.
43
- * Currently, OBJ(WAVEFRONT) is supported.
44
- * The mesh has one submesh per `usemtl` range, all sharing one vertex and index buffer.
45
- * By default, each submesh gets an unlit material with the .mtl `Kd` as diffuse colour and `d` as alpha.
46
- * @param path The path or url to the model.
47
- * @param scene The scene the mesh adds itself to; `scene.render()` draws it. The materials use `scene.camera`
48
- * (assigned on `scene.update()` when it is set later).
44
+ * Loads a plain mesh (geometry and buffers only, no material or transform) from an OBJ (Wavefront) file,
45
+ * like C# `ContentManager.LoadMesh`. Materials (.mtl) are not loaded.
46
+ * @param path The path or url to the .obj file.
47
+ * @param geometryFormat The vertex layout of the buffers, e.g. the format of the material it will be drawn with.
49
48
  * @return The mesh.
50
49
  */
51
- loadMeshAsync(path: string, scene: Scene): Promise<IMesh>;
50
+ loadMeshAsync(path: string, geometryFormat: GeometryFormat): Promise<IMesh>;
52
51
  /**
53
- * Loads an OBJ (Wavefront) mesh with lit Blinn-Phong materials.
54
- * Like {@link loadMeshAsync}, the mesh has one submesh per `usemtl` range sharing one vertex and index buffer,
55
- * and ranges with the same material name share one material. `scene.render()` draws it.
56
- * The .mtl values map onto `ForwardBlinnPhongMaterial`:
57
- * - `Kd` → `diffuseColor` (with `d` as alpha), white when missing.
58
- * - `Ka` → `ambientColor`, the diffuse colour when missing.
59
- * - `Ks` → `specularColor` and `Ns` → `shininess`, the material defaults (0.5 grey, 32) when missing.
60
- * Without an .mtl file every submesh gets a white material with those defaults.
52
+ * Loads an OBJ mesh with unlit materials, through `framework.objLoader`.
53
+ * The root mesh has no material; each `usemtl` range is a sub mesh with an unlit material
54
+ * (`Kd` as diffuse colour, `d` as alpha, white when missing). Add it with `scene.add(mesh)`.
55
+ * @param path The path or url to the .obj file.
56
+ * @param camera The optional camera; `scene.update()` assigns the scene camera anyway.
57
+ * @return The root mesh.
58
+ */
59
+ loadUnlitMeshAsync(path: string, camera?: ICamera): Promise<IRenderableMesh>;
60
+ /**
61
+ * Loads an OBJ mesh with Blinn-Phong materials: shorthand for
62
+ * `framework.objLoader.loadAsync(path, {projectionViewBuffer: camera.projectionViewBuffer, cameraPositionBuffer: camera.positionBuffer})`.
63
+ * See `ObjLoader.loadAsync` for the .mtl mapping. Add it with `scene.add(mesh)`; the scene assigns its camera and lights.
61
64
  * @param path The path or url to the .obj file. A relative `mtllib` is resolved against it.
62
- * @param scene The scene the mesh adds itself to. Every material uses the scene's lights and `scene.camera`
63
- * (assigned on `scene.update()` when it is set later).
64
- * @return The mesh.
65
+ * @param camera An initialized camera (e.g. `scene.camera`).
66
+ * @return The root mesh.
67
+ * @throws Error when the camera has no buffers.
65
68
  */
66
- loadBlinnPhongMeshAsync(path: string, scene: Scene): Promise<IMesh>;
69
+ loadBlinnPhongMeshAsync(path: string, camera: ICamera): Promise<IRenderableMesh>;
67
70
  }
68
71
  //# sourceMappingURL=IContentManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IContentManager.d.ts","sourceRoot":"","sources":["../../../src/api/content/IContentManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAC,iBAAiB,EAAC,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,eAAe;IAE5B;;OAEG;IACH,QAAQ,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;IAEjD;;;;;OAKG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAE3E;;;;;OAKG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE;QAAE,CAAC,EAAE,EA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,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAE3E;;;;;OAKG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE;QAAE,CAAC,EAAE,EAAC,MAAM,GAAG,MAAM,CAAA;KAAC,GAAG,aAAa,CAAC;IAEpG;;;;;;OAMG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,iBAAiB,EAAE,aAAa,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAE/G;;;;;;OAMG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAE5E;;;;;;;OAOG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE7E;;;;;;;;OAQG;IACH,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAEpF"}
@@ -27,8 +27,9 @@ export interface LightsBufferDescriptor {
27
27
  maxPointLights?: number;
28
28
  }
29
29
  /**
30
- * Holds the lights of a scene and owns the uniform buffer that shaders read them from.
31
- * Assign it to lit materials, e.g. `ForwardBlinnPhongMaterial.lightsBuffer`.
30
+ * Holds lights and owns the uniform buffer that shaders read them from.
31
+ * Each lit material (`ForwardBlinnPhongMaterial`) owns one.
32
+ *
32
33
  *
33
34
  * std140 layout of the `LightsBuffer` block:
34
35
  * Every light colour is written premultiplied by its intensity, so the layout has no intensity field.
@@ -41,12 +42,18 @@ export interface LightsBufferDescriptor {
41
42
  export interface LightsBuffer extends IDisposable {
42
43
  /** The ambient light written to the buffer. */
43
44
  ambientLight: AmbientLight;
44
- /** The directional lights written to the buffer. Read-only; use {@link add} and {@link remove}. Unused slots are black. */
45
- readonly directionalLights: readonly DirectionalLight[];
45
+ /**
46
+ * The directional lights written to the buffer. Can be replaced by another list, which is then used by reference
47
+ * (a lit material uses the scene's list). Only the first {@link maxDirectionalLights} are written; unused slots are black.
48
+ */
49
+ directionalLights: DirectionalLight[];
46
50
  /** The number of directional light slots in the buffer. */
47
51
  readonly maxDirectionalLights: number;
48
- /** The point lights written to the buffer. Read-only; use {@link add} and {@link remove}. Unused slots are black. */
49
- readonly pointLights: readonly PointLight[];
52
+ /**
53
+ * The point lights written to the buffer. Can be replaced by another list, which is then used by reference.
54
+ * Only the first {@link maxPointLights} are written; unused slots are black.
55
+ */
56
+ pointLights: PointLight[];
50
57
  /** The number of point light slots in the buffer. */
51
58
  readonly maxPointLights: number;
52
59
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"LightsBuffer.d.ts","sourceRoot":"","sources":["../../../src/api/lights/LightsBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,wCAAwC,CAAC;AAC3E,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAExD,qGAAqG;AACrG,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAElD,+FAA+F;AAC/F,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,0CAA0C;AAC1C,MAAM,WAAW,sBAAsB;IAEnC,4DAA4D;IAC5D,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B,qFAAqF;IACrF,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAEvC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,yEAAyE;IACz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AAE5C,0CAA0C;AAC1C,MAAM,WAAW,sBAAsB;IAEnC,4DAA4D;IAC5D,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B,qFAAqF;IACrF,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAEvC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,yEAAyE;IACzE,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAE3B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,YAAa,SAAQ,WAAW;IAE7C,+CAA+C;IAC/C,YAAY,EAAE,YAAY,CAAC;IAE3B;;;OAGG;IACH,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IAEtC,2DAA2D;IAC3D,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IAEtC;;;OAGG;IACH,WAAW,EAAE,UAAU,EAAE,CAAC;IAE1B,qDAAqD;IACrD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC;;;OAGG;IACH,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,UAAU,GAAG,IAAI,CAAC;IAEhD;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,UAAU,GAAG,OAAO,CAAC;IAEtD,2HAA2H;IAC3H,MAAM,IAAI,IAAI,CAAC;CAClB"}
@@ -1,7 +1,7 @@
1
1
  import type { GeometryDescriptor } from "../geometry/IGeometryBuilder.js";
2
2
  import type { ObjGeometryDefinition } from "./obj/index.js";
3
3
  /**
4
- * Maps plain OBJ geometry definitions from {@link ObjLoader} onto the framework's {@link GeometryDescriptor}.
4
+ * Maps plain OBJ geometry definitions from {@link ObjParser} onto the framework's {@link GeometryDescriptor}.
5
5
  * Pass the result to `geometryBuilder.create`.
6
6
  * Not part of the public API: `content.loadMeshAsync` and `content.loadBlinnPhongMeshAsync` use it.
7
7
  * @internal
@@ -9,7 +9,7 @@ import type { ObjGeometryDefinition } from "./obj/index.js";
9
9
  export declare class ObjGeometryMapper {
10
10
  /**
11
11
  * Creates a geometry descriptor from an OBJ geometry definition.
12
- * @param definition The geometry definition, e.g. `result.geometry` from `ObjLoader.loadAsync`.
12
+ * @param definition The geometry definition, e.g. `result.geometry` from `ObjParser.loadAsync`.
13
13
  * @param useMaterialColors True keeps the loader's per-vertex `Kd` colours; false (the default) uses white,
14
14
  * for when each submesh's material carries the colour instead.
15
15
  * @returns The descriptor. It references the definition's arrays; `geometryBuilder.create` copies them.
@@ -0,0 +1,61 @@
1
+ import type { IFramework } from "../IFramework.js";
2
+ import type { IRenderableMesh } from "../meshes/IRenderableMesh.js";
3
+ import type { IMaterial } from "../material/IMaterial.js";
4
+ import { ForwardBlinnPhongMaterialDescriptor } from "../material/ForwardBlinnPhongMaterial.js";
5
+ import type { ObjLoadOptions, ObjModel, ObjSubMesh } from "./obj/ObjTypes.js";
6
+ /** Creates the material for one OBJ sub mesh (`usemtl` range). */
7
+ export type ObjMaterialFactory = (subMesh: ObjSubMesh) => IMaterial;
8
+ /**
9
+ * Loads OBJ (Wavefront) models into renderable meshes (C# `ObjLoader`). Available as `framework.objLoader`.
10
+ *
11
+ * The returned root mesh has no material and owns the vertex and index buffers; each `usemtl` range is a sub mesh
12
+ * with its own material (ranges with the same material name share one material instance).
13
+ * Vertex colours are white, the materials carry the colour. Parsing is done by the engine-independent {@link ObjParser}.
14
+ * @public
15
+ */
16
+ export declare class ObjLoader {
17
+ private readonly _framework;
18
+ /** Default specular colour when the .mtl has no `Ks` (0.5 grey). */
19
+ static readonly DEFAULT_SPECULAR = 0.5;
20
+ /** Default shininess when the .mtl has no `Ns`. */
21
+ static readonly DEFAULT_SHININESS = 32;
22
+ /**
23
+ * The constructor.
24
+ * @param _framework The framework.
25
+ */
26
+ constructor(_framework: IFramework);
27
+ /**
28
+ * Parses an .obj file (and its .mtl files) into plain data. Creates no GPU resources (C# `ObjLoader.Parse`).
29
+ * @param path The .obj URL.
30
+ * @param options Optional: how to resolve `mtllib` names, or skip materials.
31
+ * @returns The model.
32
+ */
33
+ static parseAsync(path: string, options?: ObjLoadOptions): Promise<ObjModel>;
34
+ /**
35
+ * Loads an .obj file into a renderable mesh with one Blinn-Phong material per `usemtl` range.
36
+ * The .mtl values map onto `ForwardBlinnPhongMaterial`: `Kd` (with `d` as alpha) → diffuse colour (white when missing),
37
+ * `Ka` → ambient colour (falls back to `Kd`), `Ks` → specular colour (0.5 grey), `Ns` → shininess (32).
38
+ * @param path The .obj URL. A relative `mtllib` is resolved against it.
39
+ * @param descriptor The descriptor every material is created with (camera buffers, primitive state).
40
+ * @param options Optional parser options.
41
+ * @returns The root mesh.
42
+ */
43
+ loadAsync(path: string, descriptor: ForwardBlinnPhongMaterialDescriptor, options?: ObjLoadOptions): Promise<IRenderableMesh>;
44
+ /**
45
+ * Loads an .obj file into a renderable mesh, creating each sub mesh's material with a callback.
46
+ * @param path The .obj URL.
47
+ * @param createMaterial Called once per distinct `usemtl` name.
48
+ * @param options Optional parser options.
49
+ * @returns The root mesh.
50
+ */
51
+ loadAsync(path: string, createMaterial: ObjMaterialFactory, options?: ObjLoadOptions): Promise<IRenderableMesh>;
52
+ /**
53
+ * Creates a renderable mesh from a parsed model.
54
+ * @param model The model, e.g. from {@link parseAsync}.
55
+ * @param createMaterial Creates the material per distinct `usemtl` name.
56
+ * @returns The root mesh, without a material, with one sub mesh per range.
57
+ */
58
+ createMesh(model: ObjModel, createMaterial: ObjMaterialFactory): IRenderableMesh;
59
+ private _blinnPhongFactory;
60
+ }
61
+ //# sourceMappingURL=ObjLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjLoader.d.ts","sourceRoot":"","sources":["../../../src/api/loaders/ObjLoader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAC,mCAAmC,EAAC,MAAM,0CAA0C,CAAC;AAG7F,OAAO,KAAK,EAAC,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAG5E,kEAAkE;AAClE,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK,SAAS,CAAC;AAEpE;;;;;;;GAOG;AACH,qBAAa,SAAS;IAYC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAV9C,oEAAoE;IACpE,gBAAuB,gBAAgB,OAAO;IAE9C,mDAAmD;IACnD,gBAAuB,iBAAiB,MAAM;IAE9C;;;OAGG;gBACiC,UAAU,EAAE,UAAU;IAG1D;;;;;OAKG;WACW,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAInF;;;;;;;;OAQG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,mCAAmC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAEnI;;;;;;OAMG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAatH;;;;;OAKG;IACI,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,GAAG,eAAe;IAyBvF,OAAO,CAAC,kBAAkB;CAiB7B"}
@@ -1,4 +1,5 @@
1
1
  export * from "./IImageLoader.js";
2
2
  export * from "./ImageLoader.js";
3
3
  export * from "./obj/index.js";
4
+ export * from "./ObjLoader.js";
4
5
  //# sourceMappingURL=_export.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_export.d.ts","sourceRoot":"","sources":["../../../src/api/loaders/_export.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"_export.d.ts","sourceRoot":"","sources":["../../../src/api/loaders/_export.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}