ris-framework 0.2.0-dev.11 → 0.2.0-dev.13

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 +21 -29
  2. package/README.md +99 -150
  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
@@ -3,6 +3,7 @@ import {
3
3
  type ObjColor,
4
4
  type ObjLoadResult,
5
5
  type ObjLoadOptions,
6
+ type ObjModel,
6
7
  type ObjMaterialRange,
7
8
  } from "./ObjTypes.ts";
8
9
 
@@ -22,10 +23,11 @@ function readColor(parts: string[]): ObjColor | undefined {
22
23
  }
23
24
 
24
25
  /**
25
- * Loads .obj models (and their .mtl materials) from text or a URL into plain data.
26
- * Engine-independent; uses only `fetch` and `URL`. `content.loadMeshAsync` turns the result into a framework mesh.
26
+ * Parses .obj models (and their .mtl materials) from text or a URL into plain data.
27
+ * Engine-independent; uses only `fetch` and `URL`, and creates no GPU resources.
28
+ * `framework.objLoader` (or the static `ObjLoader.parseAsync`) builds on it.
27
29
  */
28
- export class ObjLoader {
30
+ export class ObjParser {
29
31
 
30
32
  /**
31
33
  * Parses .mtl text.
@@ -260,11 +262,40 @@ export class ObjLoader {
260
262
  }
261
263
  materials.push(...this.parseMtl(await mtlResponse.text()));
262
264
  } catch (error) {
263
- console.warn(`ObjLoader: could not load material library '${library}'.`, error);
265
+ console.warn(`ObjParser: could not load material library '${library}'.`, error);
264
266
  }
265
267
  }
266
268
 
267
269
 
268
270
  return this.fromText(text, materials);
269
271
  }
272
+
273
+ /**
274
+ * Loads an .obj file (and its .mtl files) into an {@link ObjModel}: the geometry plus one sub mesh per `usemtl`
275
+ * range with its resolved material definition.
276
+ * @param filePath The .obj URL.
277
+ * @param options Optional: how to resolve `mtllib` names, or skip materials.
278
+ * @returns The model.
279
+ */
280
+ public async parseAsync(filePath: string, options?: ObjLoadOptions): Promise<ObjModel> {
281
+ return ObjParser.toModel(await this.loadAsync(filePath, options));
282
+ }
283
+
284
+ /**
285
+ * Turns a load result into an {@link ObjModel}.
286
+ * @param result The load result.
287
+ * @returns The model.
288
+ */
289
+ public static toModel(result: ObjLoadResult): ObjModel {
290
+ const byName = new Map(result.materials.map(m => [m.name, m]));
291
+ return {
292
+ ...result,
293
+ subMeshes: result.geometry.materialRanges.map(range => ({
294
+ materialName: range.materialName,
295
+ material: range.materialName === undefined ? undefined : byName.get(range.materialName),
296
+ indexStart: range.indexStart,
297
+ indexCount: range.indexCount,
298
+ })),
299
+ };
300
+ }
270
301
  }
@@ -111,7 +111,7 @@ export interface ObjLoadResult {
111
111
  readonly raw: ObjRawData;
112
112
  }
113
113
 
114
- /** Options for {@link ObjLoader.loadAsync}. */
114
+ /** Options for {@link ObjParser.loadAsync} and `ObjLoader.loadAsync`. */
115
115
  export interface ObjLoadOptions {
116
116
  /**
117
117
  * Maps an `mtllib` name to the URL to fetch.
@@ -122,3 +122,21 @@ export interface ObjLoadOptions {
122
122
  /** Skip fetching .mtl files. */
123
123
  ignoreMaterials?: boolean;
124
124
  }
125
+
126
+ /** One `usemtl` range of an {@link ObjModel}: its index range and resolved material definition. */
127
+ export interface ObjSubMesh {
128
+ /** The material name from `usemtl`, or undefined for faces before any `usemtl`. */
129
+ readonly materialName?: string;
130
+ /** The material definition from the .mtl files, or undefined when there is none. */
131
+ readonly material?: ObjMaterialDefinition;
132
+ /** First index in `geometry.indices`. */
133
+ readonly indexStart: number;
134
+ /** Number of indices. */
135
+ readonly indexCount: number;
136
+ }
137
+
138
+ /** A parsed OBJ model (C# `ObjModel`): geometry, sub meshes and material definitions. No GPU resources. */
139
+ export interface ObjModel extends ObjLoadResult {
140
+ /** One entry per `usemtl` range, in file order. */
141
+ readonly subMeshes: ObjSubMesh[];
142
+ }
@@ -2,4 +2,4 @@
2
2
  * OBJ/MTL loader. Self-contained: no imports outside this folder.
3
3
  */
4
4
  export * from "./ObjTypes.ts";
5
- export * from "./ObjLoader.ts";
5
+ export * from "./ObjParser.ts";
@@ -1,4 +1,4 @@
1
- import type {IMesh} from "../meshes/IMesh.ts";
1
+ import type {IRenderableMesh} from "../meshes/IRenderableMesh.ts";
2
2
  import type {ITexture2D} from "../rendering/texture/ITexture2D.ts";
3
3
  import type {ISampler} from "../rendering/sampler/ISampler.ts";
4
4
  import {GeometryFormat} from "../geometry/GeometryFormat.ts";
@@ -11,6 +11,11 @@ import {Color} from "../data/Color.ts";
11
11
  import type {IPrimitiveState} from "../rendering/primitive/IPrimitiveState.ts";
12
12
  import type {ICamera} from "../camera/ICamera.ts";
13
13
  import type {LightsBuffer} from "../lights/LightsBuffer.ts";
14
+ import type {AmbientLight} from "../lights/AmbientLight.ts";
15
+ import type {DirectionalLight} from "../lights/DirectionalLight.ts";
16
+ import type {PointLight} from "../lights/PointLight.ts";
17
+ import type {ICameraMaterial} from "./ICameraMaterial.ts";
18
+ import type {ILightsMaterial} from "./ILightsMaterial.ts";
14
19
  import type {IForwardBlinnPhongRenderPipeline} from "../rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.ts";
15
20
 
16
21
  /**
@@ -27,9 +32,6 @@ export class ForwardBlinnPhongMaterialDescriptor {
27
32
 
28
33
  /** The camera position buffer. */
29
34
  public cameraPositionBuffer!: IUniformBuffer;
30
-
31
- /** The lights buffer. The shader is compiled for its light counts. Can also be set later through `material.lightsBuffer`. */
32
- public lightsBuffer?: LightsBuffer;
33
35
  }
34
36
 
35
37
 
@@ -37,11 +39,17 @@ export class ForwardBlinnPhongMaterialDescriptor {
37
39
  * The Blinn-Phong material with forward calculated lighting.
38
40
  * @public
39
41
  */
40
- export class ForwardBlinnPhongMaterial {
42
+ export class ForwardBlinnPhongMaterial implements ICameraMaterial, ILightsMaterial {
43
+
44
+ /** The directional light slots of the material's lights buffer and shader. */
45
+ public static readonly MAX_DIRECTIONAL_LIGHTS = 3;
46
+
47
+ /** The point light slots of the material's lights buffer and shader. */
48
+ public static readonly MAX_POINT_LIGHTS = 5;
41
49
 
42
50
  private readonly _framework: IFramework;
43
51
 
44
- private _lightsBuffer?: LightsBuffer;
52
+ private readonly _lightsBuffer: LightsBuffer;
45
53
  private _diffuseColorCache: Color;
46
54
  private _ambientColorCache: Color;
47
55
  private _specularColorCache: Color;
@@ -94,7 +102,11 @@ export class ForwardBlinnPhongMaterial {
94
102
  this._cameraPositionBuffer = descriptor.cameraPositionBuffer;
95
103
  this._materialBuffer = framework.bufferFactory.createUniformBuffer(this._materialData, usage);
96
104
  this._primitiveState = descriptor.primitiveState;
97
- this._lightsBuffer = descriptor.lightsBuffer;
105
+ // Owned by the material, like C#: 3 directional + 5 point slots (88 floats), uploaded only when the lights changed.
106
+ this._lightsBuffer = framework.lightsFactory.__createLightsBuffer({
107
+ maxDirectionalLights: ForwardBlinnPhongMaterial.MAX_DIRECTIONAL_LIGHTS,
108
+ maxPointLights: ForwardBlinnPhongMaterial.MAX_POINT_LIGHTS,
109
+ });
98
110
  // The pipeline is created once a model buffer is assigned (see modelBuffer).
99
111
  }
100
112
 
@@ -105,9 +117,9 @@ export class ForwardBlinnPhongMaterial {
105
117
  modelBuffer,
106
118
  materialBuffer: this._materialBuffer,
107
119
  cameraPositionBuffer: this._cameraPositionBuffer,
108
- lightsBuffer: this._lightsBuffer?.buffer,
109
- maxDirectionalLights: this._lightsBuffer?.maxDirectionalLights,
110
- maxPointLights: this._lightsBuffer?.maxPointLights,
120
+ lightsBuffer: this._lightsBuffer.buffer,
121
+ maxDirectionalLights: this._lightsBuffer.maxDirectionalLights,
122
+ maxPointLights: this._lightsBuffer.maxPointLights,
111
123
  primitiveState: this._primitiveState,
112
124
  });
113
125
  if (this._pendingTexture) {
@@ -175,19 +187,31 @@ export class ForwardBlinnPhongMaterial {
175
187
  }
176
188
  }
177
189
 
178
- /** The lights buffer with the scene's lights. Shared, not disposed by this material. */
179
- public get lightsBuffer(): LightsBuffer | undefined {
180
- return this._lightsBuffer;
190
+ /** @inheritDoc Defaults to a black ambient light; a `Scene` assigns its active ambient light. */
191
+ public get ambientLight(): AmbientLight {
192
+ return this._lightsBuffer.ambientLight;
181
193
  }
182
194
 
183
- /** The lights buffer with the scene's lights. Shared, not disposed by this material. */
184
- public set lightsBuffer(lightsBuffer: LightsBuffer | undefined) {
185
- this._lightsBuffer = lightsBuffer;
186
- if (lightsBuffer && this._pipeline) {
187
- // Switches to the shader variant for this buffer's light counts when they differ.
188
- this._pipeline.setLightCounts(lightsBuffer.maxDirectionalLights, lightsBuffer.maxPointLights);
189
- this._pipeline.lightsBuffer = lightsBuffer.buffer;
190
- }
195
+ public set ambientLight(value: AmbientLight) {
196
+ this._lightsBuffer.ambientLight = value;
197
+ }
198
+
199
+ /** @inheritDoc Only the first 3 are used. A `Scene` assigns its own list. */
200
+ public get directionalLights(): DirectionalLight[] {
201
+ return this._lightsBuffer.directionalLights;
202
+ }
203
+
204
+ public set directionalLights(value: DirectionalLight[]) {
205
+ this._lightsBuffer.directionalLights = value;
206
+ }
207
+
208
+ /** @inheritDoc Only the first 5 are used. A `Scene` assigns its own list. */
209
+ public get pointLights(): PointLight[] {
210
+ return this._lightsBuffer.pointLights;
211
+ }
212
+
213
+ public set pointLights(value: PointLight[]) {
214
+ this._lightsBuffer.pointLights = value;
191
215
  }
192
216
 
193
217
  /**
@@ -256,6 +280,7 @@ export class ForwardBlinnPhongMaterial {
256
280
 
257
281
  /** @inheritDoc */
258
282
  public beforeRender(): void {
283
+ this._lightsBuffer.update();
259
284
 
260
285
 
261
286
  if (!this._diffuseColorCache.equals(this.diffuseColor)
@@ -281,7 +306,7 @@ export class ForwardBlinnPhongMaterial {
281
306
  }
282
307
 
283
308
  /** @inheritDoc */
284
- public renderMesh(mesh: IMesh): void {
309
+ public renderMesh(mesh: IRenderableMesh): void {
285
310
  this.render(mesh.vertexBuffer!, mesh.indexBuffer!, mesh.indexCount ?? -1, mesh.indexStart ?? 0);
286
311
  }
287
312
 
@@ -298,5 +323,6 @@ export class ForwardBlinnPhongMaterial {
298
323
  this._pipeline?.dispose();
299
324
  this._pipeline = undefined;
300
325
  this._materialBuffer.dispose();
326
+ this._lightsBuffer.dispose();
301
327
  }
302
328
  }
@@ -0,0 +1,22 @@
1
+ import type { IMaterial } from "./IMaterial.ts";
2
+ import type { ICamera } from "../camera/ICamera.ts";
3
+
4
+ /**
5
+ * A material that renders with a camera (unlit, Blinn-Phong, inspect mips).
6
+ * A `Scene` assigns its camera to these materials in `scene.update()`.
7
+ * @public
8
+ */
9
+ export interface ICameraMaterial extends IMaterial {
10
+
11
+ /** The camera. Setting it binds the camera's buffers. */
12
+ camera?: ICamera;
13
+ }
14
+
15
+ /**
16
+ * Whether a material is an {@link ICameraMaterial}.
17
+ * @param material The material.
18
+ * @public
19
+ */
20
+ export function isCameraMaterial(material: IMaterial | undefined): material is ICameraMaterial {
21
+ return !!material && "camera" in material;
22
+ }
@@ -0,0 +1,32 @@
1
+ import type { IMaterial } from "./IMaterial.ts";
2
+ import type { AmbientLight } from "../lights/AmbientLight.ts";
3
+ import type { DirectionalLight } from "../lights/DirectionalLight.ts";
4
+ import type { PointLight } from "../lights/PointLight.ts";
5
+
6
+ /**
7
+ * A material lit by an ambient light, directional lights and point lights (Blinn-Phong).
8
+ * The material owns its lights buffer and uploads it only when the lights changed.
9
+ * A `Scene` hands each lights material its active ambient light and its own light lists (the same arrays, not copies)
10
+ * in `scene.update()`, so lights added to the scene reach every lit material.
11
+ * @public
12
+ */
13
+ export interface ILightsMaterial extends IMaterial {
14
+
15
+ /** The ambient light. */
16
+ ambientLight: AmbientLight;
17
+
18
+ /** The directional lights. The list is used by reference and may be edited; extra lights beyond the slots are ignored. */
19
+ directionalLights: DirectionalLight[];
20
+
21
+ /** The point lights. The list is used by reference and may be edited; extra lights beyond the slots are ignored. */
22
+ pointLights: PointLight[];
23
+ }
24
+
25
+ /**
26
+ * Whether a material is an {@link ILightsMaterial}.
27
+ * @param material The material.
28
+ * @public
29
+ */
30
+ export function isLightsMaterial(material: IMaterial | undefined): material is ILightsMaterial {
31
+ return !!material && "directionalLights" in material && "pointLights" in material && "ambientLight" in material;
32
+ }
@@ -1,9 +1,8 @@
1
1
  import type { IDisposable } from "../core/IDisposable.ts";
2
2
  import {GeometryFormat} from "../geometry/GeometryFormat.ts";
3
- import type { IMesh } from "../meshes/IMesh.ts";
3
+ import type { IRenderableMesh } from "../meshes/IRenderableMesh.ts";
4
4
  import type { IVertexBuffer } from "../rendering/buffers/IVertexBuffer.ts";
5
5
  import type { IIndexBuffer } from "../rendering/buffers/IIndexBuffer.ts";
6
- import type { ICamera } from "../camera/ICamera.ts";
7
6
  import type { IUniformBuffer } from "../rendering/buffers/IUniformBuffer.ts";
8
7
 
9
8
  /**
@@ -12,12 +11,6 @@ import type { IUniformBuffer } from "../rendering/buffers/IUniformBuffer.ts";
12
11
  */
13
12
  export interface IMaterial extends IDisposable {
14
13
 
15
- /**
16
- * The camera this material renders with, for materials that use one (unlit, Blinn-Phong).
17
- * A `Scene` assigns its camera to the materials of its meshes in `scene.update()`.
18
- */
19
- camera?: ICamera;
20
-
21
14
  /**
22
15
  * The model buffer (std140 `mat4`) for materials that use one (unlit, Blinn-Phong, inspect mips).
23
16
  * A mesh owns it and assigns it before drawing, like the scene assigns its camera; materials never dispose it.
@@ -37,7 +30,7 @@ export interface IMaterial extends IDisposable {
37
30
  * Renders the mesh with this material, honouring the mesh's index range.
38
31
  * @param mesh - The mesh.
39
32
  */
40
- renderMesh(mesh: IMesh): void;
33
+ renderMesh(mesh: IRenderableMesh): void;
41
34
 
42
35
  /**
43
36
  * Renders the material.
@@ -1,4 +1,4 @@
1
- import type { IMesh } from "../meshes/IMesh.ts";
1
+ import type {IRenderableMesh} from "../meshes/IRenderableMesh.ts";
2
2
  import type { ITexture2D } from "../rendering/texture/ITexture2D.ts";
3
3
  import type { IInspectTextureMipsRenderPipeline } from "../rendering/render-pipelines/IInspectTextureMipsRenderPipeline.ts";
4
4
  import type { ISampler } from "../rendering/sampler/ISampler.ts";
@@ -130,7 +130,7 @@ export class InspectTextureMipsMaterial {
130
130
  }
131
131
 
132
132
  /** @inheritDoc */
133
- public renderMesh(mesh: IMesh): void {
133
+ public renderMesh(mesh: IRenderableMesh): void {
134
134
  this.render(mesh.vertexBuffer!, mesh.indexBuffer!, mesh.indexCount ?? -1, mesh.indexStart ?? 0);
135
135
  }
136
136
 
@@ -1,5 +1,5 @@
1
1
  import type { GeometryFormat } from "../geometry/GeometryFormat.ts";
2
- import type { IMesh } from "../meshes/IMesh.ts";
2
+ import type {IRenderableMesh} from "../meshes/IRenderableMesh.ts";
3
3
  import type { IVertexBuffer } from "../rendering/buffers/IVertexBuffer.ts";
4
4
  import type { IIndexBuffer } from "../rendering/buffers/IIndexBuffer.ts";
5
5
  import type { ITexture2D } from "../rendering/texture/ITexture2D.ts";
@@ -61,7 +61,7 @@ export class SpriteMaterial implements IMaterial {
61
61
  }
62
62
 
63
63
  /** @inheritDoc */
64
- public renderMesh(mesh: IMesh): void {
64
+ public renderMesh(mesh: IRenderableMesh): void {
65
65
  this.render(mesh.vertexBuffer!, mesh.indexBuffer!, mesh.indexCount ?? -1, mesh.indexStart ?? 0);
66
66
  }
67
67
 
@@ -1,5 +1,6 @@
1
+ import type {ICameraMaterial} from "./ICameraMaterial.ts";
1
2
 
2
- import type { IMesh } from "../meshes/IMesh.ts";
3
+ import type {IRenderableMesh} from "../meshes/IRenderableMesh.ts";
3
4
  import type { ITexture2D } from "../rendering/texture/ITexture2D.ts";
4
5
  import type { ISampler } from "../rendering/sampler/ISampler.ts";
5
6
  import {mat4} from "gl-matrix";
@@ -28,7 +29,7 @@ export class UnlitMaterialDescriptor {
28
29
  /**
29
30
  * Unlit material.
30
31
  */
31
- export class UnlitMaterial {
32
+ export class UnlitMaterial implements ICameraMaterial {
32
33
 
33
34
  private readonly _framework: IFramework;
34
35
  private _color = Color.white();
@@ -191,7 +192,7 @@ export class UnlitMaterial {
191
192
  }
192
193
 
193
194
  /** @inheritDoc */
194
- public renderMesh(mesh: IMesh): void {
195
+ public renderMesh(mesh: IRenderableMesh): void {
195
196
  this.render(mesh.vertexBuffer!, mesh.indexBuffer!, mesh.indexCount ?? -1, mesh.indexStart ?? 0);
196
197
  }
197
198
 
@@ -5,3 +5,5 @@ export * from "./MaterialFactory.ts"
5
5
  export * from "./SpriteMaterial.ts"
6
6
  export * from "./UnlitMaterial.ts"
7
7
  export * from "./ForwardBlinnPhongMaterial.ts"
8
+ export * from "./ICameraMaterial.ts"
9
+ export * from "./ILightsMaterial.ts"
@@ -1,59 +1,54 @@
1
1
  import type { IVertexBuffer } from "../rendering/buffers/IVertexBuffer.ts";
2
2
  import type { IDisposable } from "../core/IDisposable.ts";
3
3
  import type { IIndexBuffer } from "../rendering/buffers/IIndexBuffer.ts";
4
- import type { IMaterial } from "../material/IMaterial.ts";
5
- import type { mat4, vec3 } from "gl-matrix";
6
- import type { IUniformBuffer } from "../rendering/buffers/IUniformBuffer.ts";
4
+ import type { IGeometry } from "../geometry/IGeometry.ts";
5
+ import type { GeometryFormat } from "../geometry/GeometryFormat.ts";
6
+ import type { State } from "../data/State.ts";
7
7
 
8
8
  /**
9
- * Represents a mesh containing geometry, material information, and optionally child submeshes.
10
- * A mesh may contain vertex and index buffers directly, or act as a container for submeshes.
9
+ * A mesh: geometry and the vertex and index buffers created from it.
10
+ * It has no material and no transform; see {@link IRenderableMesh} for a mesh that can be drawn.
11
11
  * @public
12
12
  */
13
13
  export interface IMesh extends IDisposable {
14
14
 
15
- /** The vertex buffer containing the mesh's vertex data, if any. */
16
- readonly vertexBuffer?: IVertexBuffer;
15
+ /** The state of the mesh. */
16
+ readonly state: State;
17
17
 
18
- /** The index buffer containing the mesh's index data, if any. */
19
- readonly indexBuffer?: IIndexBuffer;
18
+ /** The positions, when set through `setMesh`. */
19
+ readonly positions?: number[];
20
20
 
21
- /** The material assigned to this mesh, if any. */
22
- material?: IMaterial;
21
+ /** The colors, when set through `setMesh`. */
22
+ readonly colors?: number[];
23
23
 
24
- /** First index in {@link indexBuffer} to draw. Undefined draws from 0. */
25
- readonly indexStart?: number;
24
+ /** The texture coordinates, when set through `setMesh`. */
25
+ readonly textureCoords?: number[];
26
26
 
27
- /** Number of indices to draw. Undefined draws the whole index buffer. */
28
- readonly indexCount?: number;
27
+ /** The normals, when set through `setMesh`. */
28
+ readonly normals?: number[];
29
29
 
30
- /** The child submeshes contained in this mesh, if any. */
31
- readonly subMeshes?: IMesh[];
30
+ /** The indices, when set through `setMesh`. */
31
+ readonly indices?: number[];
32
32
 
33
- /** World position. Defaults to the origin. In-place edits are detected. */
34
- position: vec3;
33
+ /** The geometry the buffers were created from with `setGeometry`, if any. */
34
+ readonly geometry?: IGeometry;
35
35
 
36
- /**
37
- * Euler rotation in radians, applied in Y, X, Z order (yaw, pitch, roll): `R = Ry * Rx * Rz`.
38
- * Defaults to (0, 0, 0). In-place edits are detected.
39
- */
40
- rotation: vec3;
36
+ /** The vertex buffer, if created. */
37
+ readonly vertexBuffer?: IVertexBuffer;
41
38
 
42
- /** Scale. Defaults to (1, 1, 1). In-place edits are detected. */
43
- scale: vec3;
39
+ /** The index buffer, if created. */
40
+ readonly indexBuffer?: IIndexBuffer;
44
41
 
45
- /**
46
- * The model matrix `T * R * S`, recomputed only when position, rotation or scale changed.
47
- */
48
- readonly modelMatrix: mat4;
42
+ /** Creates the buffers from the current data. */
43
+ initialize(): void;
49
44
 
50
45
  /**
51
- * The model buffer (std140 `mat4`) holding {@link modelMatrix}. Owned by the mesh (submeshes share the parent's),
52
- * uploaded when the transform changed and assigned to the material(s) before drawing.
53
- * Created on first use.
46
+ * Creates the vertex and index buffers from a geometry.
47
+ * @param geometry The geometry.
48
+ * @param geometryFormat The vertex layout.
54
49
  */
55
- readonly modelBuffer: IUniformBuffer;
50
+ setGeometry(geometry: IGeometry, geometryFormat?: GeometryFormat): void;
56
51
 
57
- /** Render the mesh. */
58
- render(): void;
59
- }
52
+ /** Re-creates (or updates) the buffers from the current data. */
53
+ applyChanges(): void;
54
+ }
@@ -1,9 +1,10 @@
1
+ import type { GeometryFormat } from "../geometry/GeometryFormat.ts";
1
2
  import type { IGeometry } from "../geometry/IGeometry.ts";
2
3
  import {QuadMesh} from "./QuadMesh.ts";
3
4
  import {vec2} from "gl-matrix";
4
5
  import type { IMesh } from "./IMesh.ts";
5
6
  import type { IMaterial } from "../material/IMaterial.ts";
6
- import type { Scene } from "../scene/Scene.ts";
7
+ import type { IRenderableMesh } from "./IRenderableMesh.ts";
7
8
 
8
9
  /** Describes one submesh: a material and the index range it draws. */
9
10
  export interface SubMeshDescriptor {
@@ -21,24 +22,29 @@ export interface SubMeshDescriptor {
21
22
  export interface IMeshFactory {
22
23
 
23
24
  /**
24
- * Creates a mesh and adds it to the scene.
25
- * @param scene - The scene the mesh adds itself to.
25
+ * Creates a plain mesh (buffers only, no material or transform) from a geometry.
26
+ * @param geometry - The geometry.
27
+ * @param geometryFormat - The vertex layout.
28
+ * @returns The mesh.
29
+ */
30
+ createMesh(geometry: IGeometry, geometryFormat: GeometryFormat): IMesh;
31
+
32
+ /**
33
+ * Creates a renderable mesh with one material. Add it to a scene with `scene.add(mesh)`.
26
34
  * @param geometry - The geometry.
27
35
  * @param material - The material.
28
36
  * @returns The mesh.
29
37
  */
30
- create(scene: Scene, geometry: IGeometry, material: IMaterial): IMesh;
38
+ create(geometry: IGeometry, material: IMaterial): IRenderableMesh;
31
39
 
32
40
  /**
33
41
  * Creates a mesh made of submeshes that share one vertex and one index buffer.
34
- * The mesh itself has no material; `scene.render()` (or `mesh.render()`) draws its submeshes.
35
- * Only the mesh is added to the scene, not the submeshes.
36
- * @param scene - The scene the mesh adds itself to.
42
+ * The root mesh has no material; `mesh.render()` draws its submeshes. Add the root to a scene with `scene.add(mesh)`.
37
43
  * @param geometry - The geometry.
38
44
  * @param subMeshes - One entry per submesh. All materials must use the same geometry format.
39
45
  * @returns The mesh.
40
46
  */
41
- createWithSubMeshes(scene: Scene, geometry: IGeometry, subMeshes: SubMeshDescriptor[]): IMesh;
47
+ createWithSubMeshes(geometry: IGeometry, subMeshes: SubMeshDescriptor[]): IRenderableMesh;
42
48
 
43
49
  /**
44
50
  * Creates the quad mesh.
@@ -0,0 +1,58 @@
1
+ import type { mat4, vec3 } from "gl-matrix";
2
+ import type { IMesh } from "./IMesh.ts";
3
+ import type { IMaterial } from "../material/IMaterial.ts";
4
+ import type { IUniformBuffer } from "../rendering/buffers/IUniformBuffer.ts";
5
+
6
+ /**
7
+ * A mesh that can be drawn: a mesh plus an optional material, an index range and sub meshes.
8
+ *
9
+ * - A root mesh owns the vertex and index buffers. Sub meshes share them and only store their index range.
10
+ * - Rendering: a mesh with a material draws its range, then its sub meshes draw theirs.
11
+ * A root without a material only draws its sub meshes.
12
+ * - The transform (position, rotation, scale) and the model buffer live on the root and are shared by all sub meshes,
13
+ * so a mesh uploads its model matrix once per change, whatever the number of materials.
14
+ * - Disposing the root disposes the sub meshes and the buffers once. Materials are not disposed by the mesh
15
+ * (a `SceneMesh` does that).
16
+ * @public
17
+ */
18
+ export interface IRenderableMesh extends IMesh {
19
+
20
+ /** The material, if any. A root mesh made only of sub meshes has none. */
21
+ material?: IMaterial;
22
+
23
+ /** The parent for a sub mesh; undefined for a root mesh. */
24
+ readonly parent?: IRenderableMesh;
25
+
26
+ /** The sub meshes. */
27
+ readonly subMeshes: readonly IRenderableMesh[];
28
+
29
+ /** First index of the range to draw. Defaults to 0. */
30
+ readonly indexStart: number;
31
+
32
+ /** Number of indices to draw; -1 (the default) draws all indices. */
33
+ readonly indexCount: number;
34
+
35
+ /** World position. Defaults to the origin. In-place edits are detected. A sub mesh uses the root's. */
36
+ position: vec3;
37
+
38
+ /**
39
+ * Euler rotation in radians, applied in Y, X, Z order (yaw, pitch, roll): `R = Ry * Rx * Rz`.
40
+ * Defaults to (0, 0, 0). In-place edits are detected. A sub mesh uses the root's.
41
+ */
42
+ rotation: vec3;
43
+
44
+ /** Scale. Defaults to (1, 1, 1). In-place edits are detected. A sub mesh uses the root's. */
45
+ scale: vec3;
46
+
47
+ /** The model matrix `T * R * S`, recomputed only when position, rotation or scale changed. */
48
+ readonly modelMatrix: mat4;
49
+
50
+ /**
51
+ * The model buffer (std140 `mat4`) holding {@link modelMatrix}. Owned by the root mesh (sub meshes share it),
52
+ * uploaded when the transform changed and assigned to the material(s) before drawing. Created on first use.
53
+ */
54
+ readonly modelBuffer: IUniformBuffer;
55
+
56
+ /** Draws the mesh's range with its material (if any), then the sub meshes. */
57
+ render(): void;
58
+ }