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
@@ -2,23 +2,34 @@ import {AmbientLight} from "../lights/AmbientLight.ts";
2
2
  import {DirectionalLight} from "../lights/DirectionalLight.ts";
3
3
  import {PointLight} from "../lights/PointLight.ts";
4
4
  import type {IDisposable} from "../core/IDisposable.ts";
5
- import type {LightsBuffer} from "../lights/LightsBuffer.ts";
6
5
  import type {IFramework} from "../IFramework.ts";
7
- import type {IMesh} from "../meshes/IMesh.ts";
6
+ import type {IRenderableMesh} from "../meshes/IRenderableMesh.ts";
7
+ import {SceneMesh} from "./SceneMesh.ts";
8
+ import {isCameraMaterial} from "../material/ICameraMaterial.ts";
9
+ import {isLightsMaterial} from "../material/ILightsMaterial.ts";
8
10
  import type {GameTime} from "../time/GameTime.ts";
9
11
  import type {ICamera} from "../camera/ICamera.ts";
10
- import type {IMaterial} from "../material/IMaterial.ts";
11
12
 
12
13
  /** Anything a scene can hold: a mesh, a light (ambient, directional, point) or a camera. */
13
- export type SceneItem = IMesh | AmbientLight | DirectionalLight | PointLight | ICamera;
14
+ export type SceneItem = IRenderableMesh | SceneMesh | AmbientLight | DirectionalLight | PointLight | ICamera;
14
15
 
15
16
  /**
16
- * The scene. Meshes, lights and cameras given a scene in their constructor add themselves through {@link add};
17
- * meshes remove themselves when disposed. Call {@link update} once per frame and {@link render} in the render listener.
17
+ * The scene. Lights and cameras given a scene in their constructor add themselves through {@link add};
18
+ * meshes are added with `scene.add(mesh)` (wrapped in a {@link SceneMesh}, which owns the mesh's materials).
19
+ * Like C#, the scene keeps the light lists and hands its active ambient light and the lists themselves (not copies)
20
+ * to every lights material in {@link update}; each material owns and uploads its own lights buffer. Call {@link update} once per frame and {@link render} in the render listener.
18
21
  */
19
22
  export class Scene implements IDisposable {
20
23
 
21
- private readonly _meshes: IMesh[] = [];
24
+ private readonly _sceneMeshes: SceneMesh[] = [];
25
+ private readonly _directionalLights: DirectionalLight[] = [];
26
+ private readonly _pointLights: PointLight[] = [];
27
+
28
+ /** The directional light slots (matches the Blinn-Phong material). */
29
+ public static readonly MAX_DIRECTIONAL_LIGHTS = 3;
30
+
31
+ /** The point light slots (matches the Blinn-Phong material). */
32
+ public static readonly MAX_POINT_LIGHTS = 5;
22
33
  private _activeAmbientLight: AmbientLight;
23
34
  private _disposed = false;
24
35
  private _activeCamera?: ICamera;
@@ -37,8 +48,8 @@ export class Scene implements IDisposable {
37
48
  if (!value) {
38
49
  return;
39
50
  }
40
- for (const mesh of this._meshes) {
41
- Scene._assignCameraToMesh(mesh, value);
51
+ for (const sceneMesh of this._sceneMeshes) {
52
+ Scene._assignCamera(sceneMesh, value);
42
53
  }
43
54
  }
44
55
 
@@ -53,34 +64,26 @@ export class Scene implements IDisposable {
53
64
 
54
65
  // Assigned through add() by the ambient light constructor; set here for the type checker.
55
66
  this._activeAmbientLight = framework.lightsFactory.createAmbientLight(undefined, this);
56
-
57
- this.__forwardLightsBuffer = framework.lightsFactory.__createLightsBuffer({
58
- ambientLight: this._activeAmbientLight,
59
- maxDirectionalLights: 3,
60
- maxPointLights: 5
61
- });
62
-
63
67
  }
64
68
 
65
- /**
66
- * The lights buffer used for forward shading.
67
- * @internal
68
- */
69
- __forwardLightsBuffer: LightsBuffer;
69
+ /** The scene meshes, in the order they were added. */
70
+ public get sceneMeshes(): readonly SceneMesh[] {
71
+ return this._sceneMeshes;
72
+ }
70
73
 
71
- /** The meshes in this scene, in the order they were added. */
72
- public get meshes(): readonly IMesh[] {
73
- return this._meshes;
74
+ /** The root meshes in this scene, in the order they were added. */
75
+ public get meshes(): readonly IRenderableMesh[] {
76
+ return this._sceneMeshes.map(s => s.mesh);
74
77
  }
75
78
 
76
79
  /** The directional lights in this scene. */
77
80
  public get directionalLights(): readonly DirectionalLight[] {
78
- return this.__forwardLightsBuffer.directionalLights;
81
+ return this._directionalLights;
79
82
  }
80
83
 
81
84
  /** The point lights in this scene. */
82
85
  public get pointLights(): readonly PointLight[] {
83
- return this.__forwardLightsBuffer.pointLights;
86
+ return this._pointLights;
84
87
  }
85
88
 
86
89
  /**
@@ -94,16 +97,16 @@ export class Scene implements IDisposable {
94
97
  public set activeAmbientLight(value: AmbientLight) {
95
98
  this._addAmbientLight(value);
96
99
  this._activeAmbientLight = value;
97
- this.__forwardLightsBuffer.ambientLight = value;
98
100
  }
99
101
 
100
102
  /**
101
103
  * Adds a mesh, a light or a camera. Adding an item that is already in the scene does nothing.
102
- * - Mesh: drawn by {@link render}; gets the scene camera.
104
+ * - Renderable mesh or {@link SceneMesh}: drawn by {@link render}; its materials get the scene camera and lights.
105
+ * A mesh is wrapped in a `SceneMesh`, so {@link dispose} also disposes its materials.
103
106
  * - Ambient light: added to {@link ambientLights} (use {@link activeAmbientLight} to make it the lit one).
104
- * - Directional / point light: added to the lights buffer.
107
+ * - Directional / point light: added to {@link directionalLights} / {@link pointLights}.
105
108
  * - Camera: becomes the scene {@link camera}.
106
- * Constructors given a scene (meshes, lights, the perspective camera) call this themselves.
109
+ * Constructors given a scene (lights, the perspective camera) call this themselves.
107
110
  * @param item The item to add.
108
111
  * @throws Error when all slots for a light kind are in use (3 directional, 5 point), or for an unsupported item.
109
112
  */
@@ -111,15 +114,15 @@ export class Scene implements IDisposable {
111
114
  if (item instanceof AmbientLight) {
112
115
  this._addAmbientLight(item);
113
116
  } else if (item instanceof DirectionalLight || item instanceof PointLight) {
114
- this.__forwardLightsBuffer.add(item);
117
+ this._addLight(item);
115
118
  } else if (Scene._isCamera(item)) {
116
119
  this.camera = item;
117
- } else if (Scene._isMesh(item)) {
118
- if (!this._meshes.includes(item)) {
119
- this._meshes.push(item);
120
- if (this._activeCamera) {
121
- Scene._assignCameraToMesh(item, this._activeCamera);
122
- }
120
+ } else if (item instanceof SceneMesh || Scene._isMesh(item)) {
121
+ const mesh = item instanceof SceneMesh ? item.mesh : item;
122
+ if (!this._sceneMeshes.some(s => s.mesh === mesh)) {
123
+ const sceneMesh = item instanceof SceneMesh ? item : new SceneMesh(item);
124
+ this._sceneMeshes.push(sceneMesh);
125
+ this._bind(sceneMesh);
123
126
  }
124
127
  } else {
125
128
  throw new Error("Scene.add: expected a mesh, an AmbientLight, DirectionalLight, PointLight or a camera.");
@@ -127,7 +130,7 @@ export class Scene implements IDisposable {
127
130
  }
128
131
 
129
132
  /**
130
- * Removes a mesh, a light or a camera. The mesh is not disposed.
133
+ * Removes a mesh (or scene mesh), a light or a camera. The mesh and its materials are not disposed.
131
134
  * Removing the active camera clears {@link camera}.
132
135
  * @param item The item to remove.
133
136
  * @returns True when the item was in the scene (for a camera: was the active camera).
@@ -141,7 +144,9 @@ export class Scene implements IDisposable {
141
144
  return Scene._removeFrom(this.ambientLights, item);
142
145
  }
143
146
  if (item instanceof DirectionalLight || item instanceof PointLight) {
144
- return this.__forwardLightsBuffer.remove(item);
147
+ return item instanceof DirectionalLight
148
+ ? Scene._removeFrom(this._directionalLights, item)
149
+ : Scene._removeFrom(this._pointLights, item);
145
150
  }
146
151
  if (Scene._isCamera(item)) {
147
152
  if (item !== this._activeCamera) {
@@ -150,8 +155,14 @@ export class Scene implements IDisposable {
150
155
  this._activeCamera = undefined;
151
156
  return true;
152
157
  }
153
- if (Scene._isMesh(item)) {
154
- return Scene._removeFrom(this._meshes, item);
158
+ if (item instanceof SceneMesh || Scene._isMesh(item)) {
159
+ const mesh = item instanceof SceneMesh ? item.mesh : item;
160
+ const index = this._sceneMeshes.findIndex(s => s.mesh === mesh);
161
+ if (index < 0) {
162
+ return false;
163
+ }
164
+ this._sceneMeshes.splice(index, 1);
165
+ return true;
155
166
  }
156
167
  throw new Error("Scene.remove: expected a mesh, an AmbientLight, DirectionalLight, PointLight or a camera.");
157
168
  }
@@ -174,6 +185,19 @@ export class Scene implements IDisposable {
174
185
  return this.remove(light);
175
186
  }
176
187
 
188
+ private _addLight(light: DirectionalLight | PointLight): void {
189
+ const [list, max, kind] = light instanceof DirectionalLight
190
+ ? [this._directionalLights as (DirectionalLight | PointLight)[], Scene.MAX_DIRECTIONAL_LIGHTS, "directional"]
191
+ : [this._pointLights as (DirectionalLight | PointLight)[], Scene.MAX_POINT_LIGHTS, "point"];
192
+ if (list.includes(light)) {
193
+ return;
194
+ }
195
+ if (list.length >= max) {
196
+ throw new Error(`Scene: cannot add ${kind} light ${light.id}; all ${max} ${kind} light slots are in use.`);
197
+ }
198
+ list.push(light);
199
+ }
200
+
177
201
  private _addAmbientLight(ambientLight: AmbientLight): void {
178
202
  if (!this.ambientLights.includes(ambientLight)) {
179
203
  this.ambientLights.push(ambientLight);
@@ -196,44 +220,55 @@ export class Scene implements IDisposable {
196
220
  && "projectionViewBuffer" in camera && "viewMatrix" in camera && typeof camera.updateBuffers === "function";
197
221
  }
198
222
 
199
- /** Meshes have render() and a material slot or submeshes. */
200
- private static _isMesh(item: unknown): item is IMesh {
201
- const mesh = item as Partial<IMesh> | null;
202
- return typeof mesh === "object" && mesh !== null && typeof mesh.render === "function"
203
- && ("material" in mesh || "subMeshes" in mesh);
223
+ /** Renderable meshes have render() and sub meshes. */
224
+ private static _isMesh(item: unknown): item is IRenderableMesh {
225
+ const mesh = item as Partial<IRenderableMesh> | null;
226
+ return typeof mesh === "object" && mesh !== null && typeof mesh.render === "function" && "subMeshes" in mesh;
204
227
  }
205
228
 
206
229
  /**
207
- * Updates the scene: assigns {@link camera} to the mesh materials that don't have it yet, and uploads changed lights.
230
+ * Updates the scene: assigns {@link camera}, the active ambient light and the light lists to the mesh materials.
231
+ * Each lights material uploads its lights buffer when drawn, only if the lights changed.
208
232
  * @param _time The game time.
209
233
  * @public
210
234
  */
211
235
  update(_time: GameTime): void {
212
- // Also covers meshes whose submeshes were added after the mesh registered itself.
213
- if (this._activeCamera) {
214
- for (const mesh of this._meshes) {
215
- Scene._assignCameraToMesh(mesh, this._activeCamera);
216
- }
236
+ for (const sceneMesh of this._sceneMeshes) {
237
+ this._bind(sceneMesh);
217
238
  }
218
- this.__forwardLightsBuffer.update();
219
239
  }
220
240
 
221
- private static _assignCameraToMesh(mesh: IMesh, camera: ICamera): void {
222
- Scene._assignCamera(mesh.material, camera);
223
- for (const subMesh of mesh.subMeshes ?? []) {
224
- Scene._assignCamera(subMesh.material, camera);
241
+ /** Assigns the camera (when set) and the lights to the scene mesh's materials. */
242
+ private _bind(sceneMesh: SceneMesh): void {
243
+ if (this._activeCamera) {
244
+ Scene._assignCamera(sceneMesh, this._activeCamera);
245
+ }
246
+ for (const material of sceneMesh.materials) {
247
+ if (isLightsMaterial(material)) {
248
+ if (material.ambientLight !== this._activeAmbientLight) {
249
+ material.ambientLight = this._activeAmbientLight;
250
+ }
251
+ if (material.directionalLights !== this._directionalLights) {
252
+ material.directionalLights = this._directionalLights;
253
+ }
254
+ if (material.pointLights !== this._pointLights) {
255
+ material.pointLights = this._pointLights;
256
+ }
257
+ }
225
258
  }
226
259
  }
227
260
 
228
- private static _assignCamera(material: IMaterial | undefined, camera: ICamera): void {
229
- // Only materials that have a camera property; the setter rebinds buffers, so skip when unchanged.
261
+ private static _assignCamera(sceneMesh: SceneMesh, camera: ICamera): void {
230
262
  // A camera that is not initialized yet (e.g. added from its constructor) has no buffers;
231
263
  // it is assigned by the next update() once initialize() created them.
232
264
  if (!camera.projectionViewBuffer || !camera.positionBuffer) {
233
265
  return;
234
266
  }
235
- if (material && "camera" in material && material.camera !== camera) {
236
- material.camera = camera;
267
+ for (const material of sceneMesh.materials) {
268
+ // The setter rebinds buffers, so skip when unchanged.
269
+ if (isCameraMaterial(material) && material.camera !== camera) {
270
+ material.camera = camera;
271
+ }
237
272
  }
238
273
  }
239
274
 
@@ -242,23 +277,21 @@ export class Scene implements IDisposable {
242
277
  */
243
278
  render(): void {
244
279
 
245
- for (const mesh of this._meshes) {
246
- mesh.render();
280
+ for (const sceneMesh of this._sceneMeshes) {
281
+ sceneMesh.render();
247
282
  }
248
283
 
249
284
  }
250
285
 
251
- /** Disposes the meshes still in the scene and the lights buffer. Calling it twice does nothing. */
286
+ /** Disposes the scene meshes still in the scene: their meshes and materials. Calling it twice does nothing. */
252
287
  public dispose(): void {
253
288
  if (this._disposed) {
254
289
  return;
255
290
  }
256
291
  this._disposed = true;
257
- // Each mesh removes itself, so iterate a copy.
258
- for (const mesh of this._meshes.slice()) {
259
- mesh.dispose();
292
+ for (const sceneMesh of this._sceneMeshes) {
293
+ sceneMesh.dispose();
260
294
  }
261
- this._meshes.length = 0;
262
- this.__forwardLightsBuffer.dispose();
295
+ this._sceneMeshes.length = 0;
263
296
  }
264
297
  }
@@ -0,0 +1,61 @@
1
+ import type {IDisposable} from "../core/IDisposable.ts";
2
+ import type {IRenderableMesh} from "../meshes/IRenderableMesh.ts";
3
+ import type {IMaterial} from "../material/IMaterial.ts";
4
+
5
+ /**
6
+ * A renderable mesh held by a scene (C# `SceneMesh`): `new SceneMesh(renderableMesh)`.
7
+ * It covers the mesh and all its sub meshes, and owns their materials:
8
+ * disposing it disposes the mesh (buffers once) and each distinct material once.
9
+ * @public
10
+ */
11
+ export class SceneMesh implements IDisposable {
12
+
13
+ private _disposed = false;
14
+
15
+ /**
16
+ * The constructor.
17
+ * @param mesh The root renderable mesh.
18
+ */
19
+ public constructor(public readonly mesh: IRenderableMesh) {
20
+ }
21
+
22
+ /** The mesh and all its sub meshes, depth first. */
23
+ public get meshes(): IRenderableMesh[] {
24
+ const result: IRenderableMesh[] = [];
25
+ const visit = (m: IRenderableMesh) => {
26
+ result.push(m);
27
+ m.subMeshes.forEach(visit);
28
+ };
29
+ visit(this.mesh);
30
+ return result;
31
+ }
32
+
33
+ /** The distinct materials of the mesh and its sub meshes. */
34
+ public get materials(): IMaterial[] {
35
+ const result: IMaterial[] = [];
36
+ for (const m of this.meshes) {
37
+ if (m.material && !result.includes(m.material)) {
38
+ result.push(m.material);
39
+ }
40
+ }
41
+ return result;
42
+ }
43
+
44
+ /** Draws the mesh and its sub meshes. */
45
+ public render(): void {
46
+ this.mesh.render();
47
+ }
48
+
49
+ /** Disposes the mesh and its materials. Calling it twice does nothing. */
50
+ public dispose(): void {
51
+ if (this._disposed) {
52
+ return;
53
+ }
54
+ this._disposed = true;
55
+ const materials = this.materials;
56
+ this.mesh.dispose();
57
+ for (const material of materials) {
58
+ material.dispose();
59
+ }
60
+ }
61
+ }
@@ -34,7 +34,7 @@ export class SpriteBatchMesh extends Mesh {
34
34
  */
35
35
  public constructor(framework: IFramework, material: SpriteMaterial, numberOfInstances: number) {
36
36
  // Drawn by the sprite batch, not by a scene.
37
- super(framework, null, material);
37
+ super(framework);
38
38
  this._spriteMaterial = material;
39
39
  this._maxInstances = numberOfInstances;
40
40
 
@@ -11,7 +11,8 @@ export class AlignUtilities {
11
11
  * @returns The aligned value.
12
12
  */
13
13
  public static align(value: number, alignment: number): number {
14
- return (value + alignment - 1) & ~(alignment - 1);
14
+ const remainder = value % alignment;
15
+ return remainder == 0 ? value : value + alignment - remainder;
15
16
  }
16
17
 
17
18
  /**
@@ -1,4 +1,4 @@
1
- import type { vec2 } from "gl-matrix";
1
+ /**/import type { vec2 } from "gl-matrix";
2
2
  import {WindowBounds, type IWindowManager} from "../index.ts";
3
3
 
4
4
  /**
@@ -1,15 +1,24 @@
1
- import type { ITempRenderer } from "../../api/rendering/renderer-interface.ts";
2
- import type { vec2 } from "gl-matrix";
3
- import type { RenderingLimits } from "../../api/rendering/rendering-limits.ts";
1
+ import type {ITempRenderer} from "../../api/rendering/renderer-interface.ts";
2
+ import type {vec2} from "gl-matrix";
3
+ import type {RenderingLimits} from "../../api/rendering/rendering-limits.ts";
4
4
  import {
5
- type IFramework, type IGraphicsDevice, type IMainRenderTargetRenderPipeline, type IRenderPass, type ISwapChain,
6
- type ITexture2D, type IWindowManager,
5
+ Color,
6
+ type IFramework,
7
+ type IGraphicsDevice,
8
+ type IMainRenderTargetRenderPipeline, type IRendererConfiguration,
9
+ type IRenderPass,
10
+ type ISwapChain,
11
+ type ITexture2D,
12
+ type IWindowManager,
7
13
  RenderingBackend,
8
- RenderPassColorAttachment, RenderPassDepthStencilAttachment,
9
- RenderPassDescriptor, SwapChainDescriptor,
14
+ RenderPassColorAttachment,
15
+ RenderPassDepthStencilAttachment,
16
+ RenderPassDescriptor,
17
+ SwapChainDescriptor,
18
+ TextureFormat,
10
19
  TextureUsage
11
20
  } from "../../api/index.ts";
12
- import {TextureFormat, Color} from "../../api/index.ts";
21
+ import {TextureColorSpace} from "../../api/rendering/enums.ts";
13
22
 
14
23
  export abstract class ARenderer implements ITempRenderer {
15
24
 
@@ -22,7 +31,6 @@ export abstract class ARenderer implements ITempRenderer {
22
31
 
23
32
  private readonly _windowManager: IWindowManager;
24
33
  private _graphicsDevice: IGraphicsDevice = null!;
25
- private _preferredTextureFormat: TextureFormat = TextureFormat.RGBA_8_UNORM;
26
34
  private _preferredDepthStencilFormat: TextureFormat = TextureFormat.DEPTH_24_STENCIL_8;
27
35
  private readonly _currentBackBufferSize: vec2 = [0, 0];
28
36
  private _swapChainRequiresResize: boolean = false;
@@ -36,6 +44,7 @@ export abstract class ARenderer implements ITempRenderer {
36
44
  protected _swapChainRenderPass: IRenderPass = null!;
37
45
  protected _mainRenderTargetRenderPass?: IRenderPass;
38
46
  protected _mainRenderTargetPipeline?: IMainRenderTargetRenderPipeline;
47
+ protected _renderConfiguration: IRendererConfiguration;
39
48
 
40
49
  /** @inheritdoc */
41
50
  public get graphicsDevice(): IGraphicsDevice {
@@ -58,9 +67,7 @@ export abstract class ARenderer implements ITempRenderer {
58
67
  }
59
68
 
60
69
  /** @inheritdoc */
61
- public get preferredTextureFormat(): TextureFormat {
62
- return this._preferredTextureFormat;
63
- }
70
+ public readonly preferredTextureFormat: TextureFormat;
64
71
 
65
72
  /** @inheritdoc */
66
73
  public get preferredDepthStencilFormat(): TextureFormat {
@@ -93,12 +100,16 @@ export abstract class ARenderer implements ITempRenderer {
93
100
  /**
94
101
  * The constructor.
95
102
  * @param framework The framework.
103
+ * @param configuration The renderer configuration.
96
104
  */
97
- constructor(framework: IFramework) {
105
+ protected constructor(framework: IFramework, configuration: IRendererConfiguration) {
98
106
  this._framework = framework;
107
+ this._renderConfiguration = configuration;
99
108
  this._windowManager = framework.windowManager;
100
109
  this._currentBackBufferSize[0] = this._windowManager.canvas.width;
101
110
  this._currentBackBufferSize[1] = this._windowManager.canvas.height;
111
+ this.preferredTextureFormat = configuration.textureColorSpace == TextureColorSpace.SRGB
112
+ ? TextureFormat.RGBA_8_UNORM_SRGB : TextureFormat.RGBA_8_UNORM;
102
113
  }
103
114
 
104
115
  backend: RenderingBackend = RenderingBackend.WEB_GL;
@@ -136,8 +147,6 @@ export abstract class ARenderer implements ITempRenderer {
136
147
  this._swapChain = this._graphicsDevice.createSwapChain(
137
148
  this._windowManager.canvas,
138
149
  new SwapChainDescriptor());
139
- this._preferredTextureFormat = this._swapChain.textureFormat
140
-
141
150
  // TODO: RESIZE EVENT
142
151
 
143
152
  }
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export {Framework} from "./Framework.ts";
2
- export {FrameworkConfiguration} from "./api/FrameworkConfiguration.ts";
3
2
  export {TextureSamplerFilteringPreset} from "./core/rendering/enums.ts";
4
3
  export * from "./api/index.ts";
package/src/main.ts CHANGED
@@ -3,11 +3,10 @@ import './style.css'
3
3
  import typescriptLogo from './typescript.svg'
4
4
  import viteLogo from '/vite.svg'
5
5
  import {Framework} from './Framework.ts';
6
- import {FrameworkConfiguration} from "./api/FrameworkConfiguration.ts";
7
6
  import {TextureSamplerFilteringPreset} from "./core/rendering/enums.ts";
8
7
  import {
9
8
  Color,
10
- type IFramework,
9
+ type IFramework, IFrameworkConfiguration,
11
10
  type ISampler,
12
11
  type ITexture2D,
13
12
  Rect,
@@ -31,7 +30,7 @@ document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
31
30
  `
32
31
 
33
32
 
34
- const frameworkConfig = new FrameworkConfiguration();
33
+ const frameworkConfig: IFrameworkConfiguration = {} ;
35
34
  frameworkConfig.canvas = document.getElementById("game-canvas") as HTMLCanvasElement;
36
35
  frameworkConfig.textureFiltering = TextureSamplerFilteringPreset.BILINEAR;
37
36
  const framework : IFramework = new Framework(frameworkConfig);
@@ -14,13 +14,17 @@ export class WebGLGraphicsDeviceFeatures implements IGraphicsDeviceFeatures {
14
14
  this.supportsTextureCompressionASTC = !!this.astcExtension;
15
15
 
16
16
  this.bptcExtension = webgl.getExtension("EXT_texture_compression_bptc") as EXT_texture_compression_bptc;
17
- this.supportsTextureCompressionS3TC = !!this.bptcExtension;
17
+ // BPTC holds BC6H/BC7 (linear and sRGB).
18
+ this.supportsTextureCompressionBC = !!this.bptcExtension;
18
19
 
19
20
  this.etcExtension = webgl.getExtension("WEBGL_compressed_texture_etc") as WEBGL_compressed_texture_etc;
20
21
  this.supportsTextureCompressionETC2 = !!this.etcExtension;
21
22
 
22
23
  this.s3tcExtension = webgl.getExtension("WEBGL_compressed_texture_s3tc") as WEBGL_compressed_texture_s3tc;
23
- this.supportsTextureCompressionBC = !!this.s3tcExtension;
24
+ this.supportsTextureCompressionS3TC = !!this.s3tcExtension;
25
+
26
+ this.s3tcSrgbExtension = webgl.getExtension("WEBGL_compressed_texture_s3tc_srgb") as WEBGL_compressed_texture_s3tc_srgb;
27
+ this.supportsTextureCompressionS3TCSrgb = !!this.s3tcSrgbExtension;
24
28
 
25
29
  this.pvrtcExtension = webgl.getExtension("WEBGL_compressed_texture_pvrtc") as WEBGL_compressed_texture_pvrtc;
26
30
  this.supportsTextureCompressionPVRTC = !!this.pvrtcExtension;
@@ -54,4 +58,10 @@ export class WebGLGraphicsDeviceFeatures implements IGraphicsDeviceFeatures {
54
58
 
55
59
  /** @inheritdoc */
56
60
  readonly supportsTextureCompressionS3TC: boolean;
61
+
62
+ /** The WEBGL_compressed_texture_s3tc_srgb extension. */
63
+ readonly s3tcSrgbExtension?: WEBGL_compressed_texture_s3tc_srgb;
64
+
65
+ /** @inheritdoc */
66
+ readonly supportsTextureCompressionS3TCSrgb: boolean;
57
67
  }
@@ -34,7 +34,7 @@ export class WebGlGpuInfo implements IGPUInfo {
34
34
  const supportedCompressedTextureFormats = [];
35
35
 
36
36
  if(graphicsDevice.features.supportsTextureCompressionASTC){
37
- supportedCompressedTextureFormats.push(TextureFormat.ASTC_4X4_RGBA)
37
+ supportedCompressedTextureFormats.push(TextureFormat.ASTC_4X4_RGBA_UNORM)
38
38
  }
39
39
 
40
40
  if(graphicsDevice.features.supportsTextureCompressionS3TC) {
@@ -1,14 +1,12 @@
1
- import { type IRendererConfiguration } from "../api/rendering/renderer-interface.ts";
2
1
  import { ARenderer } from "../core/rendering/ARenderer.ts";
3
2
  import { WebGlGraphicsDevice } from "./WebGlGraphicsDevice.ts";
4
- import type {IFramework, IGraphicsDevice} from "../api/index.ts";
3
+ import type {IFramework, IGraphicsDevice, IRendererConfiguration} from "../api/index.ts";
5
4
 
6
5
  /**
7
6
  * The WebGL implementation of the IRenderer interface.
8
7
  */
9
8
  export class WebGlRenderer extends ARenderer {
10
9
 
11
- private _renderConfiguration: IRendererConfiguration;
12
10
 
13
11
  /**
14
12
  * The constructor.
@@ -18,8 +16,7 @@ export class WebGlRenderer extends ARenderer {
18
16
  constructor(
19
17
  framework: IFramework,
20
18
  renderConfiguration: IRendererConfiguration) {
21
- super(framework);
22
- this._renderConfiguration = renderConfiguration;
19
+ super(framework, renderConfiguration);
23
20
  }
24
21
 
25
22
  /** @inheritdoc */
@@ -31,8 +31,8 @@ export class WebGlLightsBuffer implements LightsBuffer {
31
31
  private readonly _buffer: IUniformBuffer;
32
32
  private readonly _data: number[];
33
33
  private readonly _uploaded: number[];
34
- private readonly _directionalLights: DirectionalLight[] = [];
35
- private readonly _pointLights: PointLight[] = [];
34
+ private _directionalLights: DirectionalLight[] = [];
35
+ private _pointLights: PointLight[] = [];
36
36
  private _disposed = false;
37
37
 
38
38
  /**
@@ -71,18 +71,28 @@ export class WebGlLightsBuffer implements LightsBuffer {
71
71
  }
72
72
 
73
73
  /** @inheritDoc */
74
- public get directionalLights(): readonly DirectionalLight[] {
74
+ public get directionalLights(): DirectionalLight[] {
75
75
  return this._directionalLights;
76
76
  }
77
77
 
78
+ /** @inheritDoc */
79
+ public set directionalLights(lights: DirectionalLight[]) {
80
+ this._directionalLights = lights;
81
+ }
82
+
78
83
  /** @inheritDoc */
79
84
  public readonly maxDirectionalLights: number;
80
85
 
81
86
  /** @inheritDoc */
82
- public get pointLights(): readonly PointLight[] {
87
+ public get pointLights(): PointLight[] {
83
88
  return this._pointLights;
84
89
  }
85
90
 
91
+ /** @inheritDoc */
92
+ public set pointLights(lights: PointLight[]) {
93
+ this._pointLights = lights;
94
+ }
95
+
86
96
  /** @inheritDoc */
87
97
  public add(light: DirectionalLight | PointLight): void {
88
98
  const [list, max, kind] = this._listFor(light);