@meimu/mutracer 0.0.0-stage → 0.1.0

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 (536) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSES/Apache-2.0.txt +202 -0
  3. package/LICENSES/GLSL-PathTracer-MIT.txt +21 -0
  4. package/LICENSES/GlMatrix-MIT.txt +19 -0
  5. package/LICENSES/KinoBloom-MIT.txt +21 -0
  6. package/LICENSES/OIDNWeb-MIT.txt +21 -0
  7. package/LICENSES/Octicons-MIT.txt +21 -0
  8. package/LICENSES/RayTracingRenderer-MIT.txt +21 -0
  9. package/LICENSES/TinyBVH-MIT.txt +21 -0
  10. package/LICENSES/WebGPUUtils-MIT.txt +21 -0
  11. package/LICENSES/ZetaRay-MIT.txt +21 -0
  12. package/README.md +195 -2
  13. package/THIRD_PARTY_NOTICES.md +160 -0
  14. package/dist/assets/bvh.worker.js +1 -0
  15. package/dist/mutracer.umd.js +14352 -0
  16. package/docs/api.md +394 -0
  17. package/docs/bvh.md +141 -0
  18. package/docs/denoising.md +301 -0
  19. package/docs/getting-started.md +308 -0
  20. package/docs/materials.md +281 -0
  21. package/docs/performance.md +85 -0
  22. package/docs/post-processing.md +87 -0
  23. package/docs/progressive-rendering.md +144 -0
  24. package/docs/sampling.md +40 -0
  25. package/docs/threejs.md +273 -0
  26. package/docs/todo.md +61 -0
  27. package/docs/updates.md +208 -0
  28. package/lib/Display.d.ts +72 -0
  29. package/lib/Display.js +121 -0
  30. package/lib/Display.js.map +1 -0
  31. package/lib/Engine.d.ts +161 -0
  32. package/lib/Engine.js +681 -0
  33. package/lib/Engine.js.map +1 -0
  34. package/lib/Render.d.ts +256 -0
  35. package/lib/Render.js +671 -0
  36. package/lib/Render.js.map +1 -0
  37. package/lib/RenderLoop.d.ts +76 -0
  38. package/lib/RenderLoop.js +204 -0
  39. package/lib/RenderLoop.js.map +1 -0
  40. package/lib/Sync.d.ts +19 -0
  41. package/lib/Sync.js +19 -0
  42. package/lib/Sync.js.map +1 -0
  43. package/lib/constants.d.ts +2 -0
  44. package/lib/constants.js +3 -0
  45. package/lib/constants.js.map +1 -0
  46. package/lib/main.d.ts +56 -0
  47. package/lib/main.js +43 -0
  48. package/lib/main.js.map +1 -0
  49. package/lib/math.d.ts +23 -0
  50. package/lib/math.js +56 -0
  51. package/lib/math.js.map +1 -0
  52. package/lib/oidn.d.ts +45 -0
  53. package/lib/oidn.js +42 -0
  54. package/lib/oidn.js.map +1 -0
  55. package/lib/oidnBundledWeights.cdn.d.ts +2 -0
  56. package/lib/oidnBundledWeights.cdn.js +5 -0
  57. package/lib/oidnBundledWeights.cdn.js.map +1 -0
  58. package/lib/oidnBundledWeights.d.ts +2 -0
  59. package/lib/oidnBundledWeights.js +4 -0
  60. package/lib/oidnBundledWeights.js.map +1 -0
  61. package/lib/renderer/DisplayPostProcess.d.ts +14 -0
  62. package/lib/renderer/DisplayPostProcess.js +41 -0
  63. package/lib/renderer/DisplayPostProcess.js.map +1 -0
  64. package/lib/renderer/MaterialTable.d.ts +119 -0
  65. package/lib/renderer/MaterialTable.js +550 -0
  66. package/lib/renderer/MaterialTable.js.map +1 -0
  67. package/lib/renderer/OfflineAdaptiveSampling.d.ts +47 -0
  68. package/lib/renderer/OfflineAdaptiveSampling.js +36 -0
  69. package/lib/renderer/OfflineAdaptiveSampling.js.map +1 -0
  70. package/lib/renderer/RenderingPipeline.d.ts +232 -0
  71. package/lib/renderer/RenderingPipeline.js +18 -0
  72. package/lib/renderer/RenderingPipeline.js.map +1 -0
  73. package/lib/renderer/ScratchPool.d.ts +13 -0
  74. package/lib/renderer/ScratchPool.js +21 -0
  75. package/lib/renderer/ScratchPool.js.map +1 -0
  76. package/lib/renderer/TileRender.d.ts +44 -0
  77. package/lib/renderer/TileRender.js +283 -0
  78. package/lib/renderer/TileRender.js.map +1 -0
  79. package/lib/renderer/WGPUBloomPass.d.ts +17 -0
  80. package/lib/renderer/WGPUBloomPass.js +243 -0
  81. package/lib/renderer/WGPUBloomPass.js.map +1 -0
  82. package/lib/renderer/WGPUCanvasSurface.d.ts +21 -0
  83. package/lib/renderer/WGPUCanvasSurface.js +48 -0
  84. package/lib/renderer/WGPUCanvasSurface.js.map +1 -0
  85. package/lib/renderer/WGPUComputePass.d.ts +73 -0
  86. package/lib/renderer/WGPUComputePass.js +317 -0
  87. package/lib/renderer/WGPUComputePass.js.map +1 -0
  88. package/lib/renderer/WGPUFullQuadPass.d.ts +73 -0
  89. package/lib/renderer/WGPUFullQuadPass.js +389 -0
  90. package/lib/renderer/WGPUFullQuadPass.js.map +1 -0
  91. package/lib/renderer/WGPUHDRPeakMeter.d.ts +19 -0
  92. package/lib/renderer/WGPUHDRPeakMeter.js +112 -0
  93. package/lib/renderer/WGPUHDRPeakMeter.js.map +1 -0
  94. package/lib/renderer/WGPUJNLMDenoiser.d.ts +61 -0
  95. package/lib/renderer/WGPUJNLMDenoiser.js +412 -0
  96. package/lib/renderer/WGPUJNLMDenoiser.js.map +1 -0
  97. package/lib/renderer/WGPURayTraceOutput.d.ts +44 -0
  98. package/lib/renderer/WGPURayTraceOutput.js +368 -0
  99. package/lib/renderer/WGPURayTraceOutput.js.map +1 -0
  100. package/lib/renderer/WGPURayTracePass.d.ts +284 -0
  101. package/lib/renderer/WGPURayTracePass.js +2323 -0
  102. package/lib/renderer/WGPURayTracePass.js.map +1 -0
  103. package/lib/renderer/WGPURenderingPipeline.d.ts +9 -0
  104. package/lib/renderer/WGPURenderingPipeline.js +1446 -0
  105. package/lib/renderer/WGPURenderingPipeline.js.map +1 -0
  106. package/lib/renderer/WGPUSceneFeatures.d.ts +3 -0
  107. package/lib/renderer/WGPUSceneFeatures.js +20 -0
  108. package/lib/renderer/WGPUSceneFeatures.js.map +1 -0
  109. package/lib/renderer/WGPUScratchBuffer.d.ts +9 -0
  110. package/lib/renderer/WGPUScratchBuffer.js +21 -0
  111. package/lib/renderer/WGPUScratchBuffer.js.map +1 -0
  112. package/lib/renderer/WGPUScratchTexture.d.ts +10 -0
  113. package/lib/renderer/WGPUScratchTexture.js +27 -0
  114. package/lib/renderer/WGPUScratchTexture.js.map +1 -0
  115. package/lib/renderer/WGPUShaderCache.d.ts +26 -0
  116. package/lib/renderer/WGPUShaderCache.js +103 -0
  117. package/lib/renderer/WGPUShaderCache.js.map +1 -0
  118. package/lib/renderer/WebGLBloomPass.d.ts +18 -0
  119. package/lib/renderer/WebGLBloomPass.js +113 -0
  120. package/lib/renderer/WebGLBloomPass.js.map +1 -0
  121. package/lib/renderer/WebGLFullQuadPass.d.ts +65 -0
  122. package/lib/renderer/WebGLFullQuadPass.js +208 -0
  123. package/lib/renderer/WebGLFullQuadPass.js.map +1 -0
  124. package/lib/renderer/WebGLJNLMDenoiser.d.ts +32 -0
  125. package/lib/renderer/WebGLJNLMDenoiser.js +328 -0
  126. package/lib/renderer/WebGLJNLMDenoiser.js.map +1 -0
  127. package/lib/renderer/WebGLRayTraceOutputPass.d.ts +20 -0
  128. package/lib/renderer/WebGLRayTraceOutputPass.js +106 -0
  129. package/lib/renderer/WebGLRayTraceOutputPass.js.map +1 -0
  130. package/lib/renderer/WebGLRayTracePass.d.ts +142 -0
  131. package/lib/renderer/WebGLRayTracePass.js +845 -0
  132. package/lib/renderer/WebGLRayTracePass.js.map +1 -0
  133. package/lib/renderer/WebGLReadback.d.ts +4 -0
  134. package/lib/renderer/WebGLReadback.js +75 -0
  135. package/lib/renderer/WebGLReadback.js.map +1 -0
  136. package/lib/renderer/WebGLRenderingPipeline.d.ts +4 -0
  137. package/lib/renderer/WebGLRenderingPipeline.js +510 -0
  138. package/lib/renderer/WebGLRenderingPipeline.js.map +1 -0
  139. package/lib/renderer/WebGLScratchCopy.d.ts +10 -0
  140. package/lib/renderer/WebGLScratchCopy.js +27 -0
  141. package/lib/renderer/WebGLScratchCopy.js.map +1 -0
  142. package/lib/renderer/accumulationTarget.d.ts +26 -0
  143. package/lib/renderer/accumulationTarget.js +2 -0
  144. package/lib/renderer/accumulationTarget.js.map +1 -0
  145. package/lib/renderer/binnedSahBvh.d.ts +31 -0
  146. package/lib/renderer/binnedSahBvh.js +263 -0
  147. package/lib/renderer/binnedSahBvh.js.map +1 -0
  148. package/lib/renderer/bvh.worker.d.ts +1 -0
  149. package/lib/renderer/bvh.worker.js +16 -0
  150. package/lib/renderer/bvh.worker.js.map +1 -0
  151. package/lib/renderer/bvhAccel.d.ts +81 -0
  152. package/lib/renderer/bvhAccel.js +621 -0
  153. package/lib/renderer/bvhAccel.js.map +1 -0
  154. package/lib/renderer/bvhWorkerBuild.d.ts +12 -0
  155. package/lib/renderer/bvhWorkerBuild.js +17 -0
  156. package/lib/renderer/bvhWorkerBuild.js.map +1 -0
  157. package/lib/renderer/bvhWorkerClient.d.ts +57 -0
  158. package/lib/renderer/bvhWorkerClient.js +166 -0
  159. package/lib/renderer/bvhWorkerClient.js.map +1 -0
  160. package/lib/renderer/cameraLens.d.ts +5 -0
  161. package/lib/renderer/cameraLens.js +15 -0
  162. package/lib/renderer/cameraLens.js.map +1 -0
  163. package/lib/renderer/cameraSnapshot.d.ts +3 -0
  164. package/lib/renderer/cameraSnapshot.js +7 -0
  165. package/lib/renderer/cameraSnapshot.js.map +1 -0
  166. package/lib/renderer/committedScene.d.ts +13 -0
  167. package/lib/renderer/committedScene.js +121 -0
  168. package/lib/renderer/committedScene.js.map +1 -0
  169. package/lib/renderer/dataTextureUtil.d.ts +32 -0
  170. package/lib/renderer/dataTextureUtil.js +46 -0
  171. package/lib/renderer/dataTextureUtil.js.map +1 -0
  172. package/lib/renderer/denoiser.d.ts +65 -0
  173. package/lib/renderer/denoiser.js +2 -0
  174. package/lib/renderer/denoiser.js.map +1 -0
  175. package/lib/renderer/depthQuery.d.ts +14 -0
  176. package/lib/renderer/depthQuery.js +14 -0
  177. package/lib/renderer/depthQuery.js.map +1 -0
  178. package/lib/renderer/deviceRequirements.d.ts +23 -0
  179. package/lib/renderer/deviceRequirements.js +50 -0
  180. package/lib/renderer/deviceRequirements.js.map +1 -0
  181. package/lib/renderer/envMapCreation.d.ts +10 -0
  182. package/lib/renderer/envMapCreation.js +96 -0
  183. package/lib/renderer/envMapCreation.js.map +1 -0
  184. package/lib/renderer/envMapDistribution.d.ts +9 -0
  185. package/lib/renderer/envMapDistribution.js +107 -0
  186. package/lib/renderer/envMapDistribution.js.map +1 -0
  187. package/lib/renderer/float16.d.ts +1 -0
  188. package/lib/renderer/float16.js +19 -0
  189. package/lib/renderer/float16.js.map +1 -0
  190. package/lib/renderer/geometryBvh.d.ts +11 -0
  191. package/lib/renderer/geometryBvh.js +24 -0
  192. package/lib/renderer/geometryBvh.js.map +1 -0
  193. package/lib/renderer/geometryUpdates.d.ts +28 -0
  194. package/lib/renderer/geometryUpdates.js +131 -0
  195. package/lib/renderer/geometryUpdates.js.map +1 -0
  196. package/lib/renderer/glsl/chunks/cameraRay.glsl.d.ts +2 -0
  197. package/lib/renderer/glsl/chunks/cameraRay.glsl.js +37 -0
  198. package/lib/renderer/glsl/chunks/cameraRay.glsl.js.map +1 -0
  199. package/lib/renderer/glsl/chunks/common.glsl.d.ts +2 -0
  200. package/lib/renderer/glsl/chunks/common.glsl.js +17 -0
  201. package/lib/renderer/glsl/chunks/common.glsl.js.map +1 -0
  202. package/lib/renderer/glsl/chunks/envMap.glsl.d.ts +2 -0
  203. package/lib/renderer/glsl/chunks/envMap.glsl.js +192 -0
  204. package/lib/renderer/glsl/chunks/envMap.glsl.js.map +1 -0
  205. package/lib/renderer/glsl/chunks/intersect.glsl.d.ts +2 -0
  206. package/lib/renderer/glsl/chunks/intersect.glsl.js +1091 -0
  207. package/lib/renderer/glsl/chunks/intersect.glsl.js.map +1 -0
  208. package/lib/renderer/glsl/chunks/materialBuffer.glsl.d.ts +2 -0
  209. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js +371 -0
  210. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js.map +1 -0
  211. package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.d.ts +2 -0
  212. package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js +1767 -0
  213. package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js.map +1 -0
  214. package/lib/renderer/glsl/chunks/rand.glsl.d.ts +2 -0
  215. package/lib/renderer/glsl/chunks/rand.glsl.js +26 -0
  216. package/lib/renderer/glsl/chunks/rand.glsl.js.map +1 -0
  217. package/lib/renderer/glsl/chunks/random.glsl.d.ts +2 -0
  218. package/lib/renderer/glsl/chunks/random.glsl.js +27 -0
  219. package/lib/renderer/glsl/chunks/random.glsl.js.map +1 -0
  220. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.d.ts +2 -0
  221. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js +287 -0
  222. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js.map +1 -0
  223. package/lib/renderer/glsl/chunks/sampleLight.glsl.d.ts +2 -0
  224. package/lib/renderer/glsl/chunks/sampleLight.glsl.js +254 -0
  225. package/lib/renderer/glsl/chunks/sampleLight.glsl.js.map +1 -0
  226. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.d.ts +2 -0
  227. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js +279 -0
  228. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js.map +1 -0
  229. package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.d.ts +2 -0
  230. package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.js +48 -0
  231. package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.js.map +1 -0
  232. package/lib/renderer/glsl/chunks/sampling.glsl.d.ts +2 -0
  233. package/lib/renderer/glsl/chunks/sampling.glsl.js +194 -0
  234. package/lib/renderer/glsl/chunks/sampling.glsl.js.map +1 -0
  235. package/lib/renderer/glsl/chunks/sobol.glsl.d.ts +2 -0
  236. package/lib/renderer/glsl/chunks/sobol.glsl.js +170 -0
  237. package/lib/renderer/glsl/chunks/sobol.glsl.js.map +1 -0
  238. package/lib/renderer/glsl/chunks/textureLinear.glsl.d.ts +2 -0
  239. package/lib/renderer/glsl/chunks/textureLinear.glsl.js +27 -0
  240. package/lib/renderer/glsl/chunks/textureLinear.glsl.js.map +1 -0
  241. package/lib/renderer/glsl/chunks/uvProjection.glsl.d.ts +2 -0
  242. package/lib/renderer/glsl/chunks/uvProjection.glsl.js +72 -0
  243. package/lib/renderer/glsl/chunks/uvProjection.glsl.js.map +1 -0
  244. package/lib/renderer/glsl/depthQuery.frag.d.ts +3 -0
  245. package/lib/renderer/glsl/depthQuery.frag.js +55 -0
  246. package/lib/renderer/glsl/depthQuery.frag.js.map +1 -0
  247. package/lib/renderer/glsl/normalizeRayTraceOutput.frag.d.ts +6 -0
  248. package/lib/renderer/glsl/normalizeRayTraceOutput.frag.js +46 -0
  249. package/lib/renderer/glsl/normalizeRayTraceOutput.frag.js.map +1 -0
  250. package/lib/renderer/glsl/rayTrace.frag.d.ts +2 -0
  251. package/lib/renderer/glsl/rayTrace.frag.js +619 -0
  252. package/lib/renderer/glsl/rayTrace.frag.js.map +1 -0
  253. package/lib/renderer/glsl/shadowCatcher.frag.d.ts +3 -0
  254. package/lib/renderer/glsl/shadowCatcher.frag.js +119 -0
  255. package/lib/renderer/glsl/shadowCatcher.frag.js.map +1 -0
  256. package/lib/renderer/glsl/webglPipeline.frag.d.ts +4 -0
  257. package/lib/renderer/glsl/webglPipeline.frag.js +208 -0
  258. package/lib/renderer/glsl/webglPipeline.frag.js.map +1 -0
  259. package/lib/renderer/gpuMemory.d.ts +2 -0
  260. package/lib/renderer/gpuMemory.js +10 -0
  261. package/lib/renderer/gpuMemory.js.map +1 -0
  262. package/lib/renderer/halton.d.ts +1 -0
  263. package/lib/renderer/halton.js +15 -0
  264. package/lib/renderer/halton.js.map +1 -0
  265. package/lib/renderer/jnlm.d.ts +85 -0
  266. package/lib/renderer/jnlm.js +87 -0
  267. package/lib/renderer/jnlm.js.map +1 -0
  268. package/lib/renderer/lightSampling.d.ts +75 -0
  269. package/lib/renderer/lightSampling.js +305 -0
  270. package/lib/renderer/lightSampling.js.map +1 -0
  271. package/lib/renderer/lightsUtil.d.ts +26 -0
  272. package/lib/renderer/lightsUtil.js +154 -0
  273. package/lib/renderer/lightsUtil.js.map +1 -0
  274. package/lib/renderer/materialChanges.d.ts +13 -0
  275. package/lib/renderer/materialChanges.js +59 -0
  276. package/lib/renderer/materialChanges.js.map +1 -0
  277. package/lib/renderer/materialComparison.generated.d.ts +5 -0
  278. package/lib/renderer/materialComparison.generated.js +655 -0
  279. package/lib/renderer/materialComparison.generated.js.map +1 -0
  280. package/lib/renderer/materialConstants.d.ts +6 -0
  281. package/lib/renderer/materialConstants.js +3 -0
  282. package/lib/renderer/materialConstants.js.map +1 -0
  283. package/lib/renderer/materialEmission.d.ts +9 -0
  284. package/lib/renderer/materialEmission.js +21 -0
  285. package/lib/renderer/materialEmission.js.map +1 -0
  286. package/lib/renderer/materialIndices.d.ts +7 -0
  287. package/lib/renderer/materialIndices.js +34 -0
  288. package/lib/renderer/materialIndices.js.map +1 -0
  289. package/lib/renderer/materialLayout.d.ts +102 -0
  290. package/lib/renderer/materialLayout.js +189 -0
  291. package/lib/renderer/materialLayout.js.map +1 -0
  292. package/lib/renderer/materialTextureSlots.d.ts +537 -0
  293. package/lib/renderer/materialTextureSlots.js +219 -0
  294. package/lib/renderer/materialTextureSlots.js.map +1 -0
  295. package/lib/renderer/mergeMeshesToGeometry.d.ts +8 -0
  296. package/lib/renderer/mergeMeshesToGeometry.js +236 -0
  297. package/lib/renderer/mergeMeshesToGeometry.js.map +1 -0
  298. package/lib/renderer/meshInstances.d.ts +23 -0
  299. package/lib/renderer/meshInstances.js +66 -0
  300. package/lib/renderer/meshInstances.js.map +1 -0
  301. package/lib/renderer/meshMembership.d.ts +10 -0
  302. package/lib/renderer/meshMembership.js +72 -0
  303. package/lib/renderer/meshMembership.js.map +1 -0
  304. package/lib/renderer/oidnNetwork.d.ts +20 -0
  305. package/lib/renderer/oidnNetwork.js +123 -0
  306. package/lib/renderer/oidnNetwork.js.map +1 -0
  307. package/lib/renderer/openPbrEnergyLut.d.ts +32 -0
  308. package/lib/renderer/openPbrEnergyLut.js +965 -0
  309. package/lib/renderer/openPbrEnergyLut.js.map +1 -0
  310. package/lib/renderer/pathLimits.d.ts +4 -0
  311. package/lib/renderer/pathLimits.js +7 -0
  312. package/lib/renderer/pathLimits.js.map +1 -0
  313. package/lib/renderer/prepareMeshBVH.d.ts +110 -0
  314. package/lib/renderer/prepareMeshBVH.js +857 -0
  315. package/lib/renderer/prepareMeshBVH.js.map +1 -0
  316. package/lib/renderer/progressiveScheduler.d.ts +11 -0
  317. package/lib/renderer/progressiveScheduler.js +19 -0
  318. package/lib/renderer/progressiveScheduler.js.map +1 -0
  319. package/lib/renderer/renderPipeline.d.ts +57 -0
  320. package/lib/renderer/renderPipeline.js +49 -0
  321. package/lib/renderer/renderPipeline.js.map +1 -0
  322. package/lib/renderer/sampling.d.ts +10 -0
  323. package/lib/renderer/sampling.js +28 -0
  324. package/lib/renderer/sampling.js.map +1 -0
  325. package/lib/renderer/sceneChangeDetector.d.ts +29 -0
  326. package/lib/renderer/sceneChangeDetector.js +232 -0
  327. package/lib/renderer/sceneChangeDetector.js.map +1 -0
  328. package/lib/renderer/sceneLightChanges.d.ts +14 -0
  329. package/lib/renderer/sceneLightChanges.js +34 -0
  330. package/lib/renderer/sceneLightChanges.js.map +1 -0
  331. package/lib/renderer/scratchSampling.d.ts +3 -0
  332. package/lib/renderer/scratchSampling.js +39 -0
  333. package/lib/renderer/scratchSampling.js.map +1 -0
  334. package/lib/renderer/shader.d.ts +37 -0
  335. package/lib/renderer/shader.js +41 -0
  336. package/lib/renderer/shader.js.map +1 -0
  337. package/lib/renderer/staticBvhPreparation.d.ts +24 -0
  338. package/lib/renderer/staticBvhPreparation.js +116 -0
  339. package/lib/renderer/staticBvhPreparation.js.map +1 -0
  340. package/lib/renderer/textureRegion.d.ts +8 -0
  341. package/lib/renderer/textureRegion.js +9 -0
  342. package/lib/renderer/textureRegion.js.map +1 -0
  343. package/lib/renderer/texturesFromMaterials.d.ts +6 -0
  344. package/lib/renderer/texturesFromMaterials.js +37 -0
  345. package/lib/renderer/texturesFromMaterials.js.map +1 -0
  346. package/lib/renderer/util.d.ts +17 -0
  347. package/lib/renderer/util.js +56 -0
  348. package/lib/renderer/util.js.map +1 -0
  349. package/lib/renderer/webgl.d.ts +131 -0
  350. package/lib/renderer/webgl.js +586 -0
  351. package/lib/renderer/webgl.js.map +1 -0
  352. package/lib/renderer/webglShaders.d.ts +4 -0
  353. package/lib/renderer/webglShaders.js +41 -0
  354. package/lib/renderer/webglShaders.js.map +1 -0
  355. package/lib/renderer/wgsl/chunks/common.wgsl.d.ts +2 -0
  356. package/lib/renderer/wgsl/chunks/common.wgsl.js +23 -0
  357. package/lib/renderer/wgsl/chunks/common.wgsl.js.map +1 -0
  358. package/lib/renderer/wgsl/chunks/envMap.wgsl.d.ts +2 -0
  359. package/lib/renderer/wgsl/chunks/envMap.wgsl.js +128 -0
  360. package/lib/renderer/wgsl/chunks/envMap.wgsl.js.map +1 -0
  361. package/lib/renderer/wgsl/chunks/intersect.wgsl.d.ts +6 -0
  362. package/lib/renderer/wgsl/chunks/intersect.wgsl.js +1441 -0
  363. package/lib/renderer/wgsl/chunks/intersect.wgsl.js.map +1 -0
  364. package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.d.ts +8 -0
  365. package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.js +85 -0
  366. package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.js.map +1 -0
  367. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.d.ts +7 -0
  368. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js +315 -0
  369. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js.map +1 -0
  370. package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.d.ts +3 -0
  371. package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.js +1737 -0
  372. package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.js.map +1 -0
  373. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.d.ts +4 -0
  374. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js +352 -0
  375. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js.map +1 -0
  376. package/lib/renderer/wgsl/chunks/rand.wgsl.d.ts +2 -0
  377. package/lib/renderer/wgsl/chunks/rand.wgsl.js +25 -0
  378. package/lib/renderer/wgsl/chunks/rand.wgsl.js.map +1 -0
  379. package/lib/renderer/wgsl/chunks/random.wgsl.d.ts +1 -0
  380. package/lib/renderer/wgsl/chunks/random.wgsl.js +2 -0
  381. package/lib/renderer/wgsl/chunks/random.wgsl.js.map +1 -0
  382. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.d.ts +5 -0
  383. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js +328 -0
  384. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js.map +1 -0
  385. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.d.ts +2 -0
  386. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js +400 -0
  387. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js.map +1 -0
  388. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.d.ts +3 -0
  389. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js +439 -0
  390. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js.map +1 -0
  391. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.d.ts +2 -0
  392. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js +40 -0
  393. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js.map +1 -0
  394. package/lib/renderer/wgsl/chunks/sampling.wgsl.d.ts +2 -0
  395. package/lib/renderer/wgsl/chunks/sampling.wgsl.js +198 -0
  396. package/lib/renderer/wgsl/chunks/sampling.wgsl.js.map +1 -0
  397. package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.d.ts +8 -0
  398. package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.js +16 -0
  399. package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.js.map +1 -0
  400. package/lib/renderer/wgsl/chunks/sobol.wgsl.d.ts +2 -0
  401. package/lib/renderer/wgsl/chunks/sobol.wgsl.js +170 -0
  402. package/lib/renderer/wgsl/chunks/sobol.wgsl.js.map +1 -0
  403. package/lib/renderer/wgsl/chunks/uvProjection.wgsl.d.ts +2 -0
  404. package/lib/renderer/wgsl/chunks/uvProjection.wgsl.js +42 -0
  405. package/lib/renderer/wgsl/chunks/uvProjection.wgsl.js.map +1 -0
  406. package/lib/renderer/wgsl/compose.frag.wgsl.d.ts +5 -0
  407. package/lib/renderer/wgsl/compose.frag.wgsl.js +218 -0
  408. package/lib/renderer/wgsl/compose.frag.wgsl.js.map +1 -0
  409. package/lib/renderer/wgsl/customDenoise.wgsl.d.ts +4 -0
  410. package/lib/renderer/wgsl/customDenoise.wgsl.js +28 -0
  411. package/lib/renderer/wgsl/customDenoise.wgsl.js.map +1 -0
  412. package/lib/renderer/wgsl/depthQuery.wgsl.d.ts +3 -0
  413. package/lib/renderer/wgsl/depthQuery.wgsl.js +34 -0
  414. package/lib/renderer/wgsl/depthQuery.wgsl.js.map +1 -0
  415. package/lib/renderer/wgsl/offlineAdaptive.compute.d.ts +2 -0
  416. package/lib/renderer/wgsl/offlineAdaptive.compute.js +108 -0
  417. package/lib/renderer/wgsl/offlineAdaptive.compute.js.map +1 -0
  418. package/lib/renderer/wgsl/rayTrace.compute.d.ts +16 -0
  419. package/lib/renderer/wgsl/rayTrace.compute.js +923 -0
  420. package/lib/renderer/wgsl/rayTrace.compute.js.map +1 -0
  421. package/lib/scene/AmbientLight.d.ts +17 -0
  422. package/lib/scene/AmbientLight.js +15 -0
  423. package/lib/scene/AmbientLight.js.map +1 -0
  424. package/lib/scene/Camera.d.ts +78 -0
  425. package/lib/scene/Camera.js +111 -0
  426. package/lib/scene/Camera.js.map +1 -0
  427. package/lib/scene/DirectionalLight.d.ts +18 -0
  428. package/lib/scene/DirectionalLight.js +17 -0
  429. package/lib/scene/DirectionalLight.js.map +1 -0
  430. package/lib/scene/EnvironmentLight.d.ts +14 -0
  431. package/lib/scene/EnvironmentLight.js +14 -0
  432. package/lib/scene/EnvironmentLight.js.map +1 -0
  433. package/lib/scene/Geometry.d.ts +87 -0
  434. package/lib/scene/Geometry.js +108 -0
  435. package/lib/scene/Geometry.js.map +1 -0
  436. package/lib/scene/IESProfile.d.ts +19 -0
  437. package/lib/scene/IESProfile.js +165 -0
  438. package/lib/scene/IESProfile.js.map +1 -0
  439. package/lib/scene/InstancedMesh.d.ts +43 -0
  440. package/lib/scene/InstancedMesh.js +79 -0
  441. package/lib/scene/InstancedMesh.js.map +1 -0
  442. package/lib/scene/Mesh.d.ts +14 -0
  443. package/lib/scene/Mesh.js +17 -0
  444. package/lib/scene/Mesh.js.map +1 -0
  445. package/lib/scene/OpenPBRMaterial.d.ts +224 -0
  446. package/lib/scene/OpenPBRMaterial.js +240 -0
  447. package/lib/scene/OpenPBRMaterial.js.map +1 -0
  448. package/lib/scene/RectLight.d.ts +31 -0
  449. package/lib/scene/RectLight.js +26 -0
  450. package/lib/scene/RectLight.js.map +1 -0
  451. package/lib/scene/Scene.d.ts +55 -0
  452. package/lib/scene/Scene.js +2 -0
  453. package/lib/scene/Scene.js.map +1 -0
  454. package/lib/scene/SceneNode.d.ts +16 -0
  455. package/lib/scene/SceneNode.js +33 -0
  456. package/lib/scene/SceneNode.js.map +1 -0
  457. package/lib/scene/SphereLight.d.ts +22 -0
  458. package/lib/scene/SphereLight.js +20 -0
  459. package/lib/scene/SphereLight.js.map +1 -0
  460. package/lib/scene/SpotLight.d.ts +35 -0
  461. package/lib/scene/SpotLight.js +29 -0
  462. package/lib/scene/SpotLight.js.map +1 -0
  463. package/lib/scene/Texture.d.ts +38 -0
  464. package/lib/scene/Texture.js +37 -0
  465. package/lib/scene/Texture.js.map +1 -0
  466. package/lib/scene/anisotropyParameters.d.ts +1 -0
  467. package/lib/scene/anisotropyParameters.js +13 -0
  468. package/lib/scene/anisotropyParameters.js.map +1 -0
  469. package/lib/scene/geometryChanges.d.ts +5 -0
  470. package/lib/scene/geometryChanges.js +18 -0
  471. package/lib/scene/geometryChanges.js.map +1 -0
  472. package/lib/scene/materialTextureNames.d.ts +2 -0
  473. package/lib/scene/materialTextureNames.js +9 -0
  474. package/lib/scene/materialTextureNames.js.map +1 -0
  475. package/lib/scene/openPbrSchema.d.ts +400 -0
  476. package/lib/scene/openPbrSchema.js +149 -0
  477. package/lib/scene/openPbrSchema.js.map +1 -0
  478. package/lib/scene/thinFilmParameters.d.ts +4 -0
  479. package/lib/scene/thinFilmParameters.js +12 -0
  480. package/lib/scene/thinFilmParameters.js.map +1 -0
  481. package/lib/settings/display.d.ts +118 -0
  482. package/lib/settings/display.js +34 -0
  483. package/lib/settings/display.js.map +1 -0
  484. package/lib/settings/engine.d.ts +37 -0
  485. package/lib/settings/engine.js +26 -0
  486. package/lib/settings/engine.js.map +1 -0
  487. package/lib/settings/render.d.ts +178 -0
  488. package/lib/settings/render.js +36 -0
  489. package/lib/settings/render.js.map +1 -0
  490. package/lib/tinybvh/LICENSE +21 -0
  491. package/lib/tinybvh/TinyBvhBuilder.d.ts +17 -0
  492. package/lib/tinybvh/TinyBvhBuilder.js +211 -0
  493. package/lib/tinybvh/TinyBvhBuilder.js.map +1 -0
  494. package/lib/tinybvh/tinybvh.wasm +0 -0
  495. package/lib/types.d.ts +13 -0
  496. package/lib/types.js +2 -0
  497. package/lib/types.js.map +1 -0
  498. package/lib/util/canvas.d.ts +2 -0
  499. package/lib/util/canvas.js +13 -0
  500. package/lib/util/canvas.js.map +1 -0
  501. package/lib/util/commonGeometry.d.ts +15 -0
  502. package/lib/util/commonGeometry.js +240 -0
  503. package/lib/util/commonGeometry.js.map +1 -0
  504. package/lib/util/events.d.ts +7 -0
  505. package/lib/util/events.js +23 -0
  506. package/lib/util/events.js.map +1 -0
  507. package/lib/util/frame.d.ts +2 -0
  508. package/lib/util/frame.js +10 -0
  509. package/lib/util/frame.js.map +1 -0
  510. package/lib/util/fromTHREE.d.ts +100 -0
  511. package/lib/util/fromTHREE.js +1063 -0
  512. package/lib/util/fromTHREE.js.map +1 -0
  513. package/lib/util/geometry.d.ts +13 -0
  514. package/lib/util/geometry.js +292 -0
  515. package/lib/util/geometry.js.map +1 -0
  516. package/lib/util/loadRGBE.d.ts +7 -0
  517. package/lib/util/loadRGBE.js +168 -0
  518. package/lib/util/loadRGBE.js.map +1 -0
  519. package/lib/util/math.d.ts +8 -0
  520. package/lib/util/math.js +64 -0
  521. package/lib/util/math.js.map +1 -0
  522. package/lib/util/mesh.d.ts +7 -0
  523. package/lib/util/mesh.js +20 -0
  524. package/lib/util/mesh.js.map +1 -0
  525. package/lib/util/threeDeformation.d.ts +20 -0
  526. package/lib/util/threeDeformation.js +218 -0
  527. package/lib/util/threeDeformation.js.map +1 -0
  528. package/lib/version.d.ts +2 -0
  529. package/lib/version.js +3 -0
  530. package/lib/version.js.map +1 -0
  531. package/llms.txt +62 -0
  532. package/oidn/weights/LICENSE.txt +202 -0
  533. package/oidn/weights/README.md +43 -0
  534. package/oidn/weights/rt_hdr_alb_nrm.tza +0 -0
  535. package/oidn/weights/rt_hdr_alb_nrm_small.tza +0 -0
  536. package/package.json +124 -4
@@ -0,0 +1,273 @@
1
+ # Three.js integration
2
+
3
+ Build or load a Three.js scene, then bind it and its camera with THREESync.
4
+ RenderLoop calls the sync automatically. Three.js is an optional peer dependency
5
+ (`npm install three`).
6
+
7
+ ```ts
8
+ import * as THREE from 'three';
9
+ import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
10
+ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
11
+ import { Engine, RenderLoop, THREESync } from '@meimu/mutracer';
12
+ const scene = new THREE.Scene();
13
+ scene.add((await new GLTFLoader().loadAsync('model.glb')).scene);
14
+ const camera = new THREE.PerspectiveCamera(40, canvas.width / canvas.height, .1, 100);
15
+ camera.position.set(0, 2, 6);
16
+ const controls = new OrbitControls(camera, canvas);
17
+ const engine = new Engine({canvas});
18
+ const sync = new THREESync(engine, {scene, camera, controls});
19
+ const loop = new RenderLoop(engine, {sync});
20
+ loop.start();
21
+ ```
22
+
23
+ ## Keeping scenes in sync
24
+
25
+ Edit Three.js transforms, membership, lights, backgrounds and materials directly.
26
+ Material edits are converted automatically; color and roughness
27
+ edits do not require `material.needsUpdate`. Buffer and pixel edits need the
28
+ usual flags:
29
+
30
+ | Edit | Flag |
31
+ | --- | --- |
32
+ | Attribute or index array elements | `attribute.needsUpdate = true` (`attribute.data.needsUpdate` for interleaved) |
33
+ | Texture pixels or canvas | `texture.needsUpdate = true` |
34
+ | Instance matrices / colors | `instanceMatrix.needsUpdate` / `instanceColor.needsUpdate = true` |
35
+
36
+ ```ts
37
+ threeMesh.rotation.y += .01;
38
+ threeMaterial.roughness = .6;
39
+ geometry.attributes.position.setX(0, .5);
40
+ geometry.attributes.position.needsUpdate = true;
41
+ // The next loop tick synchronizes and commits these edits.
42
+ ```
43
+
44
+ For an application-owned animation frame, update the animation mixer first,
45
+ then call `loop.tick()`. With first-layer frame control, call `sync.update()`,
46
+ `engine.update()`, `render.refine()` and `engine.display.present(render)` in order.
47
+
48
+ ## What is converted
49
+
50
+ | Three.js | MuTracer |
51
+ | --- | --- |
52
+ | `Mesh` with `MeshStandardMaterial` / `MeshPhysicalMaterial` | `Mesh` + `OpenPBRMaterial` (color, metalness, roughness, maps, normal map, emissive, transmission, attenuation, IOR, clearcoat, sheen, iridescence, anisotropy, alpha) |
53
+ | `Mesh` with `MeshBasicMaterial` (glTF `KHR_materials_unlit`) | Unlit emissive material |
54
+ | `MeshPhysicalMaterial.clearcoat`, `.clearcoatRoughness` (glTF `KHR_materials_clearcoat`) | `coatWeight`, `coatRoughness`, with `coatIor = 1.5` and `coatDarkening = 0` for Three.js compatibility; explicit `userData.mutracerOpenPBR.coatDarkening` overrides the imported value |
55
+ | `MeshPhysicalMaterial.sheen`, `.sheenColor`, `.sheenRoughness` | `fuzzWeight`, `fuzzColor`, `fuzzRoughness`; explicit `userData.mutracerOpenPBR.fuzzRoughness` overrides imported roughness |
56
+ | `MeshPhysicalMaterial.iridescenceThicknessMap`, `.iridescenceThicknessRange` | `thinFilmMap` with `thinFilmMapChannel = 'g'`; both nm endpoints are divided by 1000 into `thinFilmThicknessMinimum` / `thinFilmThickness`; without a map only the maximum is used |
57
+ | `MeshPhysicalMaterial.clearcoatMap`, `.clearcoatRoughnessMap` | `coatWeightMap` (linear R), `coatRoughnessMap` (linear G) |
58
+ | `MeshPhysicalMaterial.clearcoatNormalMap`, `.clearcoatNormalScale` | `coatNormalMap` (linear RGB), independent `coatNormalScale`; see [coat normals](./materials.md#coat-normals) |
59
+ | `MeshPhysicalMaterial.sheenColorMap`, `.sheenRoughnessMap` | `fuzzColorMap` (sRGB RGB), `fuzzRoughnessMap` (linear A) |
60
+ | `MeshPhysicalMaterial.specularIntensityMap`, `.specularColorMap` | `specularWeightMap` (linear A), `specularColorMap` (sRGB RGB) |
61
+ | `MeshPhysicalMaterial.anisotropy`, `.anisotropyRotation`, `.anisotropyMap` | Source strength, rotation and direction texture; see [anisotropy source conversion](#anisotropy-source-conversion) |
62
+ | `SkinnedMesh` / mesh with morph targets | CPU-deformed dynamic geometry |
63
+ | `InstancedMesh` | One InstancedMesh per material group, with native colors, sharing geometry and BLAS |
64
+ | Multi-material groups | One MuTracer mesh per group |
65
+ | `DirectionalLight` | `DirectionalLight` |
66
+ | `PointLight` | `SphereLight` (radius `userData.mutracerRadius`, default 0.25) |
67
+ | `SpotLight` | `SpotLight` (radius `userData.mutracerRadius`, default 0.01; `penumbra` sets the inner angle) |
68
+ | `RectAreaLight` | `RectLight` |
69
+ | `AmbientLight` | `AmbientLight` |
70
+ | `scene.environment` (equirectangular float `DataTexture`, e.g. from `HDRLoader`/`RGBELoader`) | `EnvironmentLight` |
71
+ | `scene.background` color / texture | Background; the environment itself when `background === environment` |
72
+
73
+ Three.js `opacity` maps to `geometryOpacity`; thin-shell choices map to
74
+ `geometryThinWalled`. Metadata accepts the five [canonical and compatibility
75
+ names](./materials.md#compatibility-names), using the constructor's equal-value
76
+ or conflict rule. These overrides apply after standard conversion; alpha mode
77
+ still follows the source material flags and resolved coverage. Naming does not
78
+ change transmission, volume or anisotropy conversion semantics.
79
+
80
+ Thin-film ranges keep their endpoint order, including minimum greater than
81
+ maximum, and retain the converter's 0–20 µm endpoint clamp. The converter uses
82
+ Three.js's actual range defaults. `mutracerOpenPBR` may explicitly override the
83
+ range, channel and map after conversion; its map accepts a MuTracer `Texture`
84
+ or a source `THREE.Texture`. `THREESync` converts parameter edits without
85
+ rewriting texture pixels. The iridescence strength texture is not supported;
86
+ `thinFilmMap` represents thickness only.
87
+
88
+ The six layer maps reuse the texture conversion cache, source UV channel,
89
+ scale, offset and flipY. `mutracerOpenPBR` can override them with a MuTracer
90
+ `Texture` or `THREE.Texture`; explicit `null` clears an imported map, while
91
+ unknown JSON objects are ignored. `THREESync` follows texture edits without
92
+ copying pixels. General `KHR_texture_transform` rotation remains unsupported.
93
+ Clearcoat normals are deferred to the independent coat-frame implementation.
94
+ Anisotropy direction and source-model mapping are described [below](#anisotropy-source-conversion). The conversion preserves OpenPBR layering: glTF sheen
95
+ layer order differs, and specular weight/color also affect metals in OpenPBR;
96
+ these imports do not imply identical glTF BRDFs.
97
+
98
+ Invisible objects are skipped. Other material types are skipped with a console
99
+ warning unless `convertMaterial` supplies an OpenPBR material. `BatchedMesh`, instanced morph targets (`morphTexture`) and skinned
100
+ instancing are unsupported: each source object warns once per converter and is
101
+ converted as an ordinary mesh, without per-instance matrices or colors.
102
+
103
+ Meshes without UVs get automatic triplanar texture and displacement
104
+ projection; explicit
105
+ `mutracerUvProjection` settings take precedence.
106
+
107
+ ## Skinning and morph targets
108
+
109
+ The initial conversion and each `sync.update()` evaluate morph targets and
110
+ skinning on the CPU. The sync calls `skeleton.update()` itself, so a preceding
111
+ Three.js render is unnecessary. Relative and absolute morph targets affect
112
+ positions and normals; skinning transforms positions, normals and supplied
113
+ tangents in local space. Missing tangents are generated from the deformed
114
+ positions, normals and UVs. The mesh's world transform remains an instance
115
+ transform.
116
+
117
+ Each deforming source mesh owns its MuTracer geometry, even when several
118
+ SkinnedMesh objects share a Three.js BufferGeometry; deformation is computed
119
+ once per source mesh and copied to each material group. These geometries are
120
+ [dynamic](./updates.md#dynamic-geometry).
121
+
122
+ An unchanged pose (bones, binding matrices, morph weights and attribute
123
+ versions) skips deformation. A changed pose updates the arrays in place, and
124
+ rendering refits only that geometry's BLAS and instances. CPU cost grows with
125
+ vertices, bone influences and material groups. Displaced deforming meshes need
126
+ a full mesh update on every pose change.
127
+
128
+ Try the procedural [animation example](../examples/animation.html). Pause the
129
+ animation to accumulate samples; changing a pose restarts accumulation.
130
+
131
+ ## Instanced meshes
132
+
133
+ `THREE.InstancedMesh.count` converts to a MuTracer `InstancedMesh` per material
134
+ group. Local Float32 matrices and colors are copied in source
135
+ index order within each batch; the retained double-precision `source.matrixWorld`
136
+ is the batch transform. Each world matrix remains `source.matrixWorld * instanceMatrix[i]`.
137
+
138
+ - **Matrices**: set `instanceMatrix.needsUpdate = true` after edits. The converter
139
+ checks values and notifies changed batches; unchanged batches retain their
140
+ matrix arrays and versions. Both backends refit the instance hierarchy.
141
+ - **Count**: the surviving source prefix retains its transforms and batch
142
+ identities. Shrinking removes the tail; increasing reads it again from the
143
+ source buffer. Membership changes rebuild the top-level BVH and reuse vertices
144
+ and BLASes where packing permits ([scene updates](./updates.md#adding-removing-and-reassigning-meshes)).
145
+ - **Colors**: `instanceColor` is copied into the batch's native `colors` array in
146
+ source order; removing it restores undefined (white). Set
147
+ `instanceColor.needsUpdate = true` after edits. Only changed values notify the
148
+ batch, and colors do not create material variants or extra batches. See
149
+ [color semantics and updates](./updates.md#instanced-meshes).
150
+ - **Callbacks**: `onMeshConverted` runs once per visible group on each update.
151
+ It receives `Mesh | InstancedMesh`; edit shared materials as usual, or notify
152
+ batch array element edits as described in [scene updates](./updates.md).
153
+
154
+ Unsupported instanced deformation keeps the ordinary-mesh fallback described
155
+ above. [Native instancing](./updates.md#instanced-meshes) uses the same primitive
156
+ without Three.js.
157
+
158
+ ## `userData` keys
159
+
160
+ Renderer-specific settings without a Three.js equivalent:
161
+
162
+ | Key | On | Description |
163
+ | --- | --- | --- |
164
+ | `mutracerShadowCatcher: true` | material | Shadow-catcher ground |
165
+ | `mutracerOpenPBR: { ... }` | material | OpenPBR inputs without a Three.js equivalent: `baseWeight`, `baseDiffuseRoughness`, `specularWeight`, `specularColor`, `coat*`, `fuzz*`, `thinFilm*`, `thinWalled`, `subsurface*`, `transmissionScatter*`, `transmissionDispersion*` |
166
+ | `mutracerBevelSize` | material | Shader bevel radius |
167
+ | `mutracerUvProjection`, `mutracerUvProjectionScale`, `mutracerUvReferenceLength` | material | Procedural UV projection |
168
+ | `mutracerDisplacement*` | material | Displacement settings, same names as the `OpenPBRMaterial` fields; projection scale is `mutracerDisplacementUvProjectionScale` |
169
+ | `mutracerThinFilmMap` | material | Native R thickness texture with minimum 0; takes precedence over `iridescenceThicknessMap` |
170
+ | `mutracerRadius` | point / spot light | Emitter radius |
171
+ | `mutracerIesProfile`, `mutracerIesRotation` | spot light | `IESProfile` instance; rotation becomes local-Z transform rotation |
172
+ | `mutracerGroundedSkybox: { texture, height, radius, groundHeight?, center? }` | scene | Grounded skybox background |
173
+ | `mutracerHiddenBackground: true` | scene | Transparent background while keeping environment lighting |
174
+
175
+ Directional and spot lights use their world position and target to build a
176
+ MuTracer transform; source rotation alone does not specify their direction.
177
+
178
+ ## Options
179
+
180
+ `new THREESync(engine, options?)` accepts these optional sources and settings:
181
+
182
+ | Option | Default | Meaning |
183
+ | --- | --- | --- |
184
+ | `scene` | undefined | Three.js scene; omitted leaves engine.scene untouched |
185
+ | `camera` | undefined | Perspective or orthographic camera; omitted leaves engine.camera untouched |
186
+ | `controls` | undefined | Controls with update and start/end events, such as OrbitControls |
187
+ | `updateControls` | true | Calls controls.update; false leaves updating to the application |
188
+ | `convertMaterial` | undefined | `(sourceMaterial)` → OpenPBRMaterial, null to skip every mesh using it, undefined for built-in conversion |
189
+ | `convertLight` | undefined | `(sourceLight)` → SceneLight, null to skip the light, undefined for built-in conversion |
190
+ | `onMeshConverted` | undefined | `(mesh, source, group, groupIndex)` on every visible mesh/group during update |
191
+
192
+ Construction subscribes to control events. The first update converts and writes
193
+ sources to the engine. `scene` exposes the retained converted scene, or undefined
194
+ when no source was supplied. A camera-only sync preserves a MuTracer-built scene.
195
+ `active` covers start/end interaction, camera movement, damping and changing
196
+ skinned/morph poses. The damping tail ends when movement and zoom fall below
197
+ 0.05% of view distance, allowing final refinement in that same tick.
198
+
199
+ `fromTHREEScene(scene, options?)` and `fromTHREECamera(camera, options?)` remain
200
+ available for one-shot conversions. Each call reruns conversion hooks and creates fresh default objects; custom
201
+ objects are kept by identity.
202
+ Call `camera.updateProjectionMatrix()` after changing aspect or fov. A perspective
203
+ camera's focus and film height become MuTracer focus distance and sensor height;
204
+ pass `{fStop: 2.8}` to `fromTHREECamera` to enable depth of field.
205
+
206
+ ### Custom conversion
207
+
208
+ Both `fromTHREEScene` and `THREESync` accept the conversion hooks:
209
+
210
+ ```ts
211
+ import { OpenPBRMaterial, SphereLight } from '@meimu/mutracer';
212
+ const customMaterial = new OpenPBRMaterial({baseColor: [0.2, 0.4, 0.8]});
213
+ const customLight = new SphereLight({radius: 0.1, intensity: 3});
214
+ const sync = new THREESync(engine, {
215
+ scene,
216
+ convertMaterial(source) {
217
+ if (source.type === 'ShaderMaterial') return customMaterial;
218
+ if (source.userData.skipPathTracing) return null;
219
+ return undefined;
220
+ },
221
+ convertLight(source) {
222
+ if (source.userData.customEmitter) return customLight;
223
+ return undefined;
224
+ },
225
+ });
226
+ // Edit the returned MuTracer material directly after initial conversion.
227
+ customMaterial.baseColor = [0.8, 0.4, 0.2];
228
+ ```
229
+
230
+ The sync caches each hook result (including null and undefined) by source
231
+ identity and `version`. The material hook receives only the source material,
232
+ so a shared material converts once for every mesh using it; use distinct
233
+ source materials for per-mesh conversion. Set `threeMaterial.needsUpdate = true` to advance its version and
234
+ rerun the hook. Returned objects are used by identity and are caller-owned;
235
+ `engine.update()` detects edits to them. Automatic UV
236
+ projection derives retained variants from the returned material; these refresh
237
+ when its identity or parameters change.
238
+
239
+ Three.js lights have no built-in `version`, so the light hook runs once. To
240
+ rerun it, set a numeric `light.userData.mutracerVersion` and increment it. An undefined hook result keeps normal built-in material/light
241
+ synchronization, including parameter edits that do not change the source
242
+ version. A null material result skips every group/instance of its mesh.
243
+ The environment texture follows the built-in conversion and is not a
244
+ `THREE.Light` hook source.
245
+
246
+ ## Coat normal conversion
247
+
248
+ `clearcoatNormalMap` uses the shared texture conversion cache and preserves its UV channel, scale, offset and `flipY`; `clearcoatNormalScale` is copied separately from `normalScale`. Explicit `mutracerOpenPBR.coatNormalMap` accepts a MuTracer Texture or Three.js Texture, and `null` clears the imported map. `coatNormalScale` metadata overrides the imported pair; unrelated metadata retains the imported anisotropy source convention. Arbitrary JSON objects are not interpreted as texture images. `THREESync` propagates map and scale edits.
249
+
250
+ ## Caveats
251
+
252
+ THREESync updates world/bone matrices and retains unchanged meshes, materials,
253
+ textures, lights, backgrounds and membership arrays. MuTracer transforms use
254
+ Three.js matrixWorld, preserving double precision. Skinning and morphs run on the
255
+ CPU, updating retained geometry in place. Other changed buffers replace geometry
256
+ and require a [full mesh update](./updates.md#full-mesh-updates).
257
+
258
+ `sync.dispose()` removes control subscriptions and conversion caches; it leaves
259
+ the last converted scene usable. Updating a disposed sync throws. RenderLoop does
260
+ not dispose supplied syncs or renders; see [ownership](./progressive-rendering.md#options-and-ownership).
261
+
262
+
263
+ Native `mutracerOpenPBR` metadata can set `anisotropyMap` (a MuTracer or Three.js Texture, or null to clear), `specularAnisotropyRotation` and `coatAnisotropyRotation` (radians, default zero). Imported geometry preserves a tangent's optional W handedness.
264
+
265
+ ## Anisotropy source conversion
266
+
267
+ `MeshPhysicalMaterial.anisotropy`, `anisotropyRotation` and `anisotropyMap` import as source strength, base rotation (radians) and the linear RG/B direction map, with `specularAnisotropyModel = 'gltf'`. Roughness and its maps retain source values. `GLTFLoader` supplies the extension defaults and texture coordinates; `THREESync` propagates later strength, rotation, texture and metadata edits without rewriting pixels. Nonphysical materials retain native semantics.
268
+
269
+ For sampled source roughness r and strength a, u = r², A = u + (1 - u)a² and B = u. The native anisotropy is 1 - B/A (clamped to [0, 1] against Float32 roundoff) and native roughness is ((A² + B²)/2)^(1/4). A = B = 0 resolves to zero. Strength zero returns the original roughness directly. Conversion occurs after roughness/metallic-roughness sampling and the anisotropy blue multiplier, followed by the existing OpenPBR coat roughening. CPU conversion before multiplying maps would give different alpha axes and is not used. The coat's anisotropy is independent.
270
+
271
+ Metadata overriding `specularAnisotropy` or `specularRoughnessAnisotropy` defaults back to `'openpbr'` and clears the automatically imported direction map/rotation to undefined/zero. Explicit metadata direction values can replace or restore them; explicit `specularAnisotropyModel: 'gltf'` retains source semantics and the imported directions. An unrelated override such as baseColor preserves the imported model. Texture overrides accept MuTracer/Three.js textures, and null clears a texture. Invalid model names throw.
272
+
273
+ This is an alpha-parameter match, with approximation differences from the renderer's Fresnel, masking, energy compensation and layer model. Zero roughness with nonzero strength reaches the existing alpha minimum; this numerical endpoint does not reproduce a singular zero-width distribution. General KHR texture-transform rotation remains the adapter limitation documented above.
package/docs/todo.md ADDED
@@ -0,0 +1,61 @@
1
+ # TODO
2
+
3
+ Follow-ups deferred during the Engine / Display / Render API redesign. Each
4
+ item says why it was deferred. None of them changes the current public API;
5
+ the ones marked additive would only add to it.
6
+
7
+ ## Rendering and denoising
8
+
9
+ - **HDR-stage post-process hooks.** `display.addPostProcess` runs after display
10
+ composition only. The built-in JNLM and OIDN filters denoise the composed
11
+ display-linear image and cache the result, so an HDR-stage hook would feed
12
+ the denoiser input and leave stale results whenever the hook changes. This
13
+ needs an invalidation rule first, for example restarting denoising when the
14
+ hook list or a hook revision changes.
15
+ - **Shadow-catcher shadows with custom denoisers.** `DenoiseInput` provides only
16
+ color, albedo and normal. Catcher shadow masks are composited after filtering
17
+ and keep their noise. The built-in filters do filter these shadows. One option
18
+ is an optional mask buffer on `DenoiseInput` (additive).
19
+ - **`readPixels('denoised')` depends on the filter.** Built-in filters return
20
+ display-linear values because they filter after tone mapping. Custom filters
21
+ return linear HDR. This is documented in TSDoc; consider a single contract.
22
+ - **Unused alpha post-filter.** `WGPURenderingPipeline` keeps an OIDN alpha
23
+ post-filter (the `alphaDenoiser` parameter), but `Render` always passes
24
+ `undefined`. Expose it or remove it; removing an image-quality mechanism is
25
+ a maintainer decision.
26
+
27
+ ## Performance and memory
28
+
29
+ - **Dirty ranges for `InstancedMesh`.** `markTransformsUpdated(start, count)` / `markColorsUpdated(start, count)`
30
+ validates its range, but a commit still copies the whole changed `transforms`
31
+ or `colors` array. Transform edits refit the whole TLAS; color edits only
32
+ upload instance records. Unchanged updates are already cheap (100,000
33
+ instances: about 10.6 ms down to 0.0025 ms per `engine.update()`); frames
34
+ that change transforms are not optimized.
35
+ - **Camera allocation in `THREESync`.** Every `update()` creates a temporary
36
+ `Camera` with `fromTHREECamera` and copies it into the retained camera
37
+ (`src/util/fromTHREE.ts`). Update the retained camera in place instead.
38
+ - **Render target memory.** A WebGPU render target uses about 110 bytes per
39
+ pixel. Check which buffers can be shared between renders or use narrower
40
+ formats.
41
+
42
+ ## Additive capabilities
43
+
44
+ - **Multiple canvases.** `engine.createDisplay(canvas)` on WebGPU. WebGL
45
+ contexts cannot share resources, so WebGL keeps a single display.
46
+ - **Several resident scenes.** `new Render(engine, {scene, camera})` would
47
+ override the engine's scene and camera per render. Today one scene is
48
+ resident on the GPU, and `engine.prepare(otherScene)` prepares CPU data only.
49
+
50
+ ## Viewer
51
+
52
+ - **Device loss status.** Show device loss and recovery in the status bar,
53
+ using the engine's `devicelost` event. The library already recovers.
54
+
55
+ ## Decided against
56
+
57
+ - **A scene graph.** Path tracing consumes a flat instance list. Hierarchy stays
58
+ in Three.js or the application, which computes each world `transform`.
59
+ - **Open material or light type extension.** Every new type needs shader support
60
+ in both backends. Keep a closed set and maintain it through the internal
61
+ field tables.
@@ -0,0 +1,208 @@
1
+ # Scene updates and animation
2
+
3
+ This page is the reference for editing a scene that is already rendering.
4
+ Keep the same scene, arrays and resources and edit them in place. Call
5
+ `engine.update()` once per frame to detect and commit changes. Every Render
6
+ uses that committed snapshot until the next update; editing or replacing the
7
+ external scene/camera without calling update has no effect on tracing.
8
+ Changes restart each render at its next refine. See
9
+ [progressive rendering](./progressive-rendering.md) for preview selection.
10
+
11
+ ## What to do after a change
12
+
13
+ `engine.update()` compares the scene with its last commit. It detects every
14
+ property assignment, membership change and small value such as matrices,
15
+ material parameters, light parameters and background fields. It does not read
16
+ the contents of large arrays or images, so in-place edits to them need a
17
+ notification first:
18
+
19
+ | Edited in place | Notification |
20
+ | --- | --- |
21
+ | Texture pixels or UV-array elements | `texture.markUpdated()` |
22
+ | Vertex attributes; indices and `materialIndex` unchanged | `geometry.markVerticesUpdated()` |
23
+ | Indices, `materialIndex` or other geometry data | `geometry.markUpdated()` |
24
+ | `instancedMesh.transforms` elements | `instancedMesh.markTransformsUpdated(start?, count?)` |
25
+ | `instancedMesh.colors` elements | `instancedMesh.markColorsUpdated(start?, count?)` |
26
+ | Both instance matrices and colors | `instancedMesh.markUpdated()` |
27
+
28
+ Everything else, including the camera, `scene.meshes`, `mesh.transform`,
29
+ replaced geometry, materials, textures or arrays, and `instancedMesh.count`,
30
+ needs only `engine.update()`. Engine BVH settings also take effect at the next
31
+ update; see [BVH](./bvh.md).
32
+
33
+ ```ts
34
+ mesh.transform[12] += 0.1; // detected
35
+ material.specularRoughness = 0.6; // detected
36
+ // ...edit texture pixels...
37
+ texture.markUpdated(); // pixels: notify
38
+ engine.update(); final.refine(); engine.display.present(final);
39
+ ```
40
+
41
+ With RenderLoop, edit sources before the next tick; the loop calls sync.update
42
+ and engine.update. THREESync sends resource notifications for you. See
43
+ [Three.js](./threejs.md#keeping-scenes-in-sync).
44
+
45
+ ## Transforms
46
+
47
+ Edit `mesh.transform` in place while retaining the mesh objects and the
48
+ `scene.meshes` array. Both WebGPU and WebGL 2 refit the top-level BVH over the
49
+ changed instances and upload only the affected ranges.
50
+
51
+ ## Instanced meshes
52
+
53
+ Use `InstancedMesh` for many copies of the same geometry and materials:
54
+
55
+ ```ts
56
+ const batch = new InstancedMesh(geometry, material, {count: 1000});
57
+ // Omitted transforms initialize every local matrix to identity.
58
+ for (let i = 0; i < batch.count; i++) batch.transforms[i * 16 + 12] = i * 2;
59
+ batch.markTransformsUpdated();
60
+ scene.meshes.push(batch);
61
+ engine.update();
62
+
63
+ batch.transforms[16 + 12] += 1;
64
+ batch.markTransformsUpdated(1, 1); // start/count are in instances, not floats
65
+ engine.update();
66
+ ```
67
+
68
+ `transforms` contains column-major Float32 matrices; the constructor retains a
69
+ supplied array. Each world matrix is `batch.transform * transforms[i]`, so the
70
+ inherited `position` and `lookAt` move the whole batch. Every instance uses the
71
+ same material list, selected by the geometry's `materialIndex` exactly as for Mesh.
72
+
73
+ `count` selects an active prefix and must be a nonnegative integer within the
74
+ transforms and colors array capacity. Shrinking it retains the stored matrices; increase it again to
75
+ reactivate that prefix. To grow beyond capacity, assign a larger Float32Array
76
+ with the previous prefix copied. The default count and capacity come from the
77
+ constructor. Empty batches are supported.
78
+
79
+ Optional `colors` contains linear RGB multipliers, three Float32 values per
80
+ instance; omitted colors are white. The array is retained and must hold at least
81
+ `3 * count` values. All materials of an instance share its color. Colors multiply
82
+ baseColor after texture sampling, and emissionColor only for unlit materials.
83
+ They do not affect alpha, other layer colors, non-unlit emission or light sampling.
84
+ Values are not clamped; results for nonfinite colors are undefined.
85
+
86
+ ```ts
87
+ batch.colors = new Float32Array(batch.count * 3).fill(1); // replacement: detected
88
+ batch.colors.set([0.2, 0.6, 1], 3);
89
+ batch.markColorsUpdated(1, 1);
90
+ engine.update();
91
+ ```
92
+
93
+ After editing both matrices and colors, call `batch.markUpdated()` to notify
94
+ both for all active instances. This does not notify geometry or material edits.
95
+ For edits to just one array, use the dedicated notification (default range: all
96
+ active instances):
97
+
98
+ | Notification | Work avoided compared with `markUpdated()` |
99
+ | --- | --- |
100
+ | `markTransformsUpdated(start?, count?)` | Copying unchanged instance colors |
101
+ | `markColorsUpdated(start?, count?)` | Copying instance matrices and refitting or rebuilding BVHs; only instance colors are uploaded |
102
+
103
+ Each notification advances the read-only `version` once, initially zero.
104
+ Replacing either array, removing colors, and changing count are detected automatically.
105
+ Arrays are copied into the engine snapshot on their own version or storage change;
106
+ unnotified edits remain uncommitted even when another scene resource changes. Call
107
+ `engine.update()` before refining or converging.
108
+
109
+ Caveats: individual instances have no names, transforms or materials as JS
110
+ objects. Use separate batches for distinct material sets. Nonfinite world
111
+ matrices are excluded, as with Mesh.
112
+ The notification range is validated.
113
+
114
+ ## Materials, textures and lights
115
+
116
+ Material parameter edits repack material parameters without touching geometry
117
+ or BVHs. Emission edits also refresh light-sampling state, and texture edits
118
+ rebuild the texture atlas. Displacement settings that move geometry require a
119
+ [full mesh update](#full-mesh-updates).
120
+
121
+ Analytic-light edits keep the environment map. Ambient and environment edits
122
+ rebuild it. Rect-light texture edits require a full mesh update, because those
123
+ textures live in the material atlas.
124
+
125
+ ## Geometry
126
+
127
+ Choose the notification that matches the edit:
128
+
129
+ | Edit | Notification | Effect |
130
+ | --- | --- | --- |
131
+ | Vertex attributes only; indices and `materialIndex` unchanged | `geometry.markVerticesUpdated()` | Advances `version`; keeps `topologyVersion`. Allows vertex updates and BLAS refits |
132
+ | Indices, `materialIndex`, or any other geometry change | `geometry.markUpdated()` | Advances `version` and `topologyVersion`. Rebuilds the affected BLAS |
133
+
134
+ ```ts
135
+ geometry.dynamic = true; // for frequent deformation
136
+ geometry.position.array[0] += 0.1;
137
+ geometry.markVerticesUpdated();
138
+ // The next engine.update commits this geometry and every mesh that uses it.
139
+ ```
140
+
141
+ - Neither method recalculates normals or tangents. Update them before
142
+ notifying the renderer.
143
+ - `markUpdated()` is valid for vertex edits too, but it can rebuild the BLAS
144
+ unnecessarily.
145
+ - Keep the attribute arrays, their lengths and item sizes. Then both backends
146
+ update only the edited geometry's ranges and BLAS, and refit every instance
147
+ that shares it. Vertex, transform and material edits can be combined in one
148
+ frame.
149
+ - Replaced arrays, changed lengths or item sizes, and displaced geometry
150
+ require a [full mesh update](#full-mesh-updates), whichever method you call.
151
+
152
+ ### Dynamic geometry
153
+
154
+ Set `geometry.dynamic = true` (default `false`) for geometry that deforms
155
+ every frame. Dynamic geometry always uses the built-in builder and the binary
156
+ `'bvh2'` layout, whatever `engine.bvhBuilder` and `engine.bvhLayout` say,
157
+ so its BLAS can be refitted. A refitted BLAS is rebuilt once its total node
158
+ surface area exceeds twice the total of its last build, which limits quality
159
+ loss during long deformations. Non-dynamic geometry refits layouts that
160
+ support it and rebuilds the others.
161
+
162
+ Refits and rebuilds run synchronously during committed GPU uploads. Three.js skinning
163
+ and morph targets set `dynamic` automatically; try the
164
+ [animation example](../examples/animation.html).
165
+
166
+ ## Adding, removing and reassigning meshes
167
+
168
+ Adding, removing or reordering meshes, or replacing a mesh's material, is
169
+ cheap when every mesh uses a single material and geometry that is already on
170
+ the GPU: the renderer rebuilds the top-level BVH and instance data and reuses
171
+ vertex data and BLASes. Otherwise, for example with new geometry, displacement
172
+ or a `materialIndex` attribute, it needs a full mesh update.
173
+
174
+ ## Full mesh updates
175
+
176
+ A full mesh update repacks and uploads all mesh data, and its cost grows with
177
+ the whole scene rather than with the edit. It happens when:
178
+
179
+ - attribute or index arrays are replaced, or their lengths or item sizes change;
180
+ - displaced geometry or its displacement settings change;
181
+ - a rect-light texture changes;
182
+ - a mesh gets geometry that is not yet on the GPU, or meshes with displaced
183
+ or multi-material geometry are added, removed or reassigned.
184
+
185
+ Avoid these in per-frame animation.
186
+
187
+ ## Preview and animation
188
+
189
+ Create a cheaper preview Render and use it during motion. Give the final render
190
+ `fallback: preview`; it transitions when its first complete sample is ready.
191
+ Selection and coalescing of continuous animation changes belong to the
192
+ application. Render.refine only executes the chosen settings, and samples
193
+ always count that render's complete samples. For fixed-quality animation, use
194
+ converge on each frame with disjoint sequence offsets.
195
+
196
+
197
+ ## Implementation notes
198
+
199
+ Material detection compares each distinct material once per engine.update,
200
+ however many meshes share it; cost grows with the number of distinct materials.
201
+
202
+ On a version or storage change, the engine copies the full transforms or colors
203
+ array; start/count validation does not limit the copied elements. In scenes
204
+ containing batches, a transform update regenerates all instance records and
205
+ refits the top-level BVH. World matrices keep double precision until GPU
206
+ packing, matching Three.js world-matrix and inverse calculations. Instances
207
+ share BLAS and vertices unless explicit materialIndex packing or displacement
208
+ requires a distinct vertex region.
@@ -0,0 +1,72 @@
1
+ import type Render from './Render.js';
2
+ import type { ToneMapping, DisplayChannel } from './renderer/RenderingPipeline.js';
3
+ import type { ColorRGB } from './types.js';
4
+ /** Display image channels. Default final. */
5
+ export type { DisplayChannel } from './renderer/RenderingPipeline.js';
6
+ /** Image encoding options for Display.toBlob. */
7
+ export interface BlobOptions {
8
+ /** Browser image MIME type. Default image/png. */ type?: string;
9
+ /** Encoder quality in 0–1. Default undefined uses the browser default. */ quality?: number;
10
+ }
11
+ /** Optional shared display settings; defaults match Display. */
12
+ export interface DisplaySettings {
13
+ /** Tone mapping transform. Default agx. */ toneMapping?: ToneMapping;
14
+ /** Linear exposure multiplier. Default 1. */ toneMappingExposure?: number;
15
+ /** Contrast multiplier. Default 1. */ contrast?: number;
16
+ /** Saturation multiplier. Default 1. */ saturation?: number;
17
+ /** White balance temperature shift in -1–1. Default 0. */ temperature?: number;
18
+ /** Green/magenta tint in -1–1. Default 0. */ tint?: number;
19
+ /** Vignette strength in 0–1. Default 0. */ vignette?: number;
20
+ /** Bloom intensity; 0 disables it. Default 0. */ bloomIntensity?: number;
21
+ /** Bloom luminance threshold. Default 1. */ bloomThreshold?: number;
22
+ /** Bloom radius in 0–1. Default 0.6. */ bloomRadius?: number;
23
+ /** Extended-range WebGPU presentation, ignored on WebGL. Default false. */ hdrOutputEnabled?: boolean;
24
+ /** Display image channel. Default final. */ channel?: DisplayChannel;
25
+ /** Linear shadow-catcher color. Default black. */ shadowCatcherColor?: ColorRGB;
26
+ /** Shadow-catcher opacity multiplier. Default 1. */ shadowCatcherAlpha?: number;
27
+ }
28
+ /** Borrowed WebGPU images for one synchronous display pass. */
29
+ export interface PostProcessContext {
30
+ /** Engine device; may change after recovery. */ device: GPUDevice;
31
+ /** Record commands here; the library finishes and submits it. */ encoder: GPUCommandEncoder;
32
+ /** Read-only composed display image, top row first; no additional color conversion. */ input: GPUTexture;
33
+ /** Fully write this image. Same format and dimensions as input; supports render, storage and copy writes. */ output: GPUTexture;
34
+ /** Actual render width. */ width: number;
35
+ /** Actual render height. */ height: number;
36
+ /** Selected complete render, including a selected fallback. */ render: Render;
37
+ }
38
+ /** Synchronous display pass. Images and encoder are borrowed only during the call; do not retain or destroy them. */
39
+ export type PostProcess = (context: PostProcessContext) => void;
40
+ /** Canvas presentation and shared display settings; obtained from engine.display. */
41
+ export default class Display {
42
+ private readonly engine;
43
+ /** Display canvas. Default the supplied Engine canvas, or a new canvas (OffscreenCanvas without document). */ readonly canvas: HTMLCanvasElement | OffscreenCanvas;
44
+ /** Tone mapping transform. Default agx. */ toneMapping: ToneMapping;
45
+ /** Linear exposure multiplier. Default 1. */ toneMappingExposure: number;
46
+ /** Contrast multiplier. Default 1. */ contrast: number;
47
+ /** Saturation multiplier. Default 1. */ saturation: number;
48
+ /** White balance temperature shift in -1–1. Default 0. */ temperature: number;
49
+ /** Green/magenta tint in -1–1. Default 0. */ tint: number;
50
+ /** Vignette strength in 0–1. Default 0. */ vignette: number;
51
+ /** Bloom intensity; 0 disables it. Default 0. */ bloomIntensity: number;
52
+ /** Bloom luminance threshold. Default 1. */ bloomThreshold: number;
53
+ /** Bloom radius in 0–1. Default 0.6. */ bloomRadius: number;
54
+ /** Extended-range WebGPU presentation, ignored on WebGL. Default false. */ hdrOutputEnabled: boolean;
55
+ /** Display image channel. Default final. */ channel: DisplayChannel;
56
+ /** Linear shadow-catcher color. Default black. */ shadowCatcherColor: ColorRGB;
57
+ /** Shadow-catcher opacity multiplier. Default 1. */ shadowCatcherAlpha: number;
58
+ private constructor();
59
+ /** Resizes the drawing buffer; scale-based renders resize at their next refine. */
60
+ setSize(width: number, height: number): void;
61
+ private readonly settings;
62
+ private readonly _postProcesses;
63
+ private _warnedPostProcess;
64
+ /** Registers a display pass in order and returns an idempotent removal function. Default no passes. WebGPU only; WebGL skips passes with one warning. Runs after composition on every present/toBlob, without tracing or invalidating denoising. A thrown error discards the whole chain, presents the original image and emits engine error. */
65
+ addPostProcess(pass: PostProcess): () => void;
66
+ private warnPostProcess;
67
+ private compose;
68
+ /** Presents a complete render or its fallback. Does not trace; leaves canvas unchanged if neither is ready. */
69
+ present(render: Render): Render | undefined;
70
+ /** Encodes this render at its actual dimensions using these settings; leaves the display canvas unchanged. */
71
+ toBlob(render: Render, options?: BlobOptions): Promise<Blob>;
72
+ }