@skenora/runtime 0.1.2

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 (270) hide show
  1. package/README.md +92 -0
  2. package/dist/core/built-in-runtime-capabilities.d.ts +21 -0
  3. package/dist/core/built-in-runtime-capabilities.d.ts.map +1 -0
  4. package/dist/core/built-in-runtime-capabilities.js +175 -0
  5. package/dist/core/built-in-runtime-capabilities.js.map +1 -0
  6. package/dist/core/runtime-capability-registry.d.ts +90 -0
  7. package/dist/core/runtime-capability-registry.d.ts.map +1 -0
  8. package/dist/core/runtime-capability-registry.js +42 -0
  9. package/dist/core/runtime-capability-registry.js.map +1 -0
  10. package/dist/core/runtime-document-coordinator.d.ts +28 -0
  11. package/dist/core/runtime-document-coordinator.d.ts.map +1 -0
  12. package/dist/core/runtime-document-coordinator.js +124 -0
  13. package/dist/core/runtime-document-coordinator.js.map +1 -0
  14. package/dist/core/runtime-events.d.ts +43 -0
  15. package/dist/core/runtime-events.d.ts.map +1 -0
  16. package/dist/core/runtime-events.js +2 -0
  17. package/dist/core/runtime-events.js.map +1 -0
  18. package/dist/core/runtime-session.d.ts +93 -0
  19. package/dist/core/runtime-session.d.ts.map +1 -0
  20. package/dist/core/runtime-session.js +1344 -0
  21. package/dist/core/runtime-session.js.map +1 -0
  22. package/dist/editor-tools/camera-path-editing-controller.d.ts +36 -0
  23. package/dist/editor-tools/camera-path-editing-controller.d.ts.map +1 -0
  24. package/dist/editor-tools/camera-path-editing-controller.js +212 -0
  25. package/dist/editor-tools/camera-path-editing-controller.js.map +1 -0
  26. package/dist/editor-tools/camera-path-visualizer.d.ts +28 -0
  27. package/dist/editor-tools/camera-path-visualizer.d.ts.map +1 -0
  28. package/dist/editor-tools/camera-path-visualizer.js +151 -0
  29. package/dist/editor-tools/camera-path-visualizer.js.map +1 -0
  30. package/dist/editor-tools/drop-preview-controller.d.ts +34 -0
  31. package/dist/editor-tools/drop-preview-controller.d.ts.map +1 -0
  32. package/dist/editor-tools/drop-preview-controller.js +209 -0
  33. package/dist/editor-tools/drop-preview-controller.js.map +1 -0
  34. package/dist/editor-tools/grid-helper.d.ts +18 -0
  35. package/dist/editor-tools/grid-helper.d.ts.map +1 -0
  36. package/dist/editor-tools/grid-helper.js +27 -0
  37. package/dist/editor-tools/grid-helper.js.map +1 -0
  38. package/dist/editor-tools/light-editing-controller.d.ts +25 -0
  39. package/dist/editor-tools/light-editing-controller.d.ts.map +1 -0
  40. package/dist/editor-tools/light-editing-controller.js +207 -0
  41. package/dist/editor-tools/light-editing-controller.js.map +1 -0
  42. package/dist/editor-tools/node-operations.d.ts +51 -0
  43. package/dist/editor-tools/node-operations.d.ts.map +1 -0
  44. package/dist/editor-tools/node-operations.js +182 -0
  45. package/dist/editor-tools/node-operations.js.map +1 -0
  46. package/dist/editor-tools/selection-controller.d.ts +44 -0
  47. package/dist/editor-tools/selection-controller.d.ts.map +1 -0
  48. package/dist/editor-tools/selection-controller.js +299 -0
  49. package/dist/editor-tools/selection-controller.js.map +1 -0
  50. package/dist/editor-tools/shape-drawing-controller.d.ts +45 -0
  51. package/dist/editor-tools/shape-drawing-controller.d.ts.map +1 -0
  52. package/dist/editor-tools/shape-drawing-controller.js +205 -0
  53. package/dist/editor-tools/shape-drawing-controller.js.map +1 -0
  54. package/dist/editor-tools/shape-editing-controller.d.ts +40 -0
  55. package/dist/editor-tools/shape-editing-controller.d.ts.map +1 -0
  56. package/dist/editor-tools/shape-editing-controller.js +340 -0
  57. package/dist/editor-tools/shape-editing-controller.js.map +1 -0
  58. package/dist/editor.d.ts +12 -0
  59. package/dist/editor.d.ts.map +1 -0
  60. package/dist/editor.js +12 -0
  61. package/dist/editor.js.map +1 -0
  62. package/dist/index.d.ts +2 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +2 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/inspection/node-tools.d.ts +51 -0
  67. package/dist/inspection/node-tools.d.ts.map +1 -0
  68. package/dist/inspection/node-tools.js +282 -0
  69. package/dist/inspection/node-tools.js.map +1 -0
  70. package/dist/interaction/runtime-third-person-controller.d.ts +24 -0
  71. package/dist/interaction/runtime-third-person-controller.d.ts.map +1 -0
  72. package/dist/interaction/runtime-third-person-controller.js +71 -0
  73. package/dist/interaction/runtime-third-person-controller.js.map +1 -0
  74. package/dist/interaction/third-person-controller.d.ts +61 -0
  75. package/dist/interaction/third-person-controller.d.ts.map +1 -0
  76. package/dist/interaction/third-person-controller.js +400 -0
  77. package/dist/interaction/third-person-controller.js.map +1 -0
  78. package/dist/interaction.d.ts +3 -0
  79. package/dist/interaction.d.ts.map +1 -0
  80. package/dist/interaction.js +3 -0
  81. package/dist/interaction.js.map +1 -0
  82. package/dist/presentation/scene-renderer.d.ts +75 -0
  83. package/dist/presentation/scene-renderer.d.ts.map +1 -0
  84. package/dist/presentation/scene-renderer.js +324 -0
  85. package/dist/presentation/scene-renderer.js.map +1 -0
  86. package/dist/presentation/viewport-controller.d.ts +13 -0
  87. package/dist/presentation/viewport-controller.d.ts.map +1 -0
  88. package/dist/presentation/viewport-controller.js +186 -0
  89. package/dist/presentation/viewport-controller.js.map +1 -0
  90. package/dist/projection/annotation-projector.d.ts +28 -0
  91. package/dist/projection/annotation-projector.d.ts.map +1 -0
  92. package/dist/projection/annotation-projector.js +98 -0
  93. package/dist/projection/annotation-projector.js.map +1 -0
  94. package/dist/projection/built-in-entity-projectors.d.ts +7 -0
  95. package/dist/projection/built-in-entity-projectors.d.ts.map +1 -0
  96. package/dist/projection/built-in-entity-projectors.js +75 -0
  97. package/dist/projection/built-in-entity-projectors.js.map +1 -0
  98. package/dist/projection/camera-entity-factory.d.ts +9 -0
  99. package/dist/projection/camera-entity-factory.d.ts.map +1 -0
  100. package/dist/projection/camera-entity-factory.js +93 -0
  101. package/dist/projection/camera-entity-factory.js.map +1 -0
  102. package/dist/projection/document-applier.d.ts +38 -0
  103. package/dist/projection/document-applier.d.ts.map +1 -0
  104. package/dist/projection/document-applier.js +219 -0
  105. package/dist/projection/document-applier.js.map +1 -0
  106. package/dist/projection/entity-projection-registry.d.ts +56 -0
  107. package/dist/projection/entity-projection-registry.d.ts.map +1 -0
  108. package/dist/projection/entity-projection-registry.js +121 -0
  109. package/dist/projection/entity-projection-registry.js.map +1 -0
  110. package/dist/projection/model-importer.d.ts +41 -0
  111. package/dist/projection/model-importer.d.ts.map +1 -0
  112. package/dist/projection/model-importer.js +469 -0
  113. package/dist/projection/model-importer.js.map +1 -0
  114. package/dist/projection/particle-capability.d.ts +5 -0
  115. package/dist/projection/particle-capability.d.ts.map +1 -0
  116. package/dist/projection/particle-capability.js +2 -0
  117. package/dist/projection/particle-capability.js.map +1 -0
  118. package/dist/projection/particle-factory.d.ts +18 -0
  119. package/dist/projection/particle-factory.d.ts.map +1 -0
  120. package/dist/projection/particle-factory.js +313 -0
  121. package/dist/projection/particle-factory.js.map +1 -0
  122. package/dist/projection/primitive-factory.d.ts +5 -0
  123. package/dist/projection/primitive-factory.d.ts.map +1 -0
  124. package/dist/projection/primitive-factory.js +55 -0
  125. package/dist/projection/primitive-factory.js.map +1 -0
  126. package/dist/projection/procedural-factory.d.ts +6 -0
  127. package/dist/projection/procedural-factory.d.ts.map +1 -0
  128. package/dist/projection/procedural-factory.js +34 -0
  129. package/dist/projection/procedural-factory.js.map +1 -0
  130. package/dist/projection/runtime-projection-state.d.ts +19 -0
  131. package/dist/projection/runtime-projection-state.d.ts.map +1 -0
  132. package/dist/projection/runtime-projection-state.js +58 -0
  133. package/dist/projection/runtime-projection-state.js.map +1 -0
  134. package/dist/projection/shape-factory.d.ts +5 -0
  135. package/dist/projection/shape-factory.d.ts.map +1 -0
  136. package/dist/projection/shape-factory.js +101 -0
  137. package/dist/projection/shape-factory.js.map +1 -0
  138. package/dist/projection-entry.d.ts +10 -0
  139. package/dist/projection-entry.d.ts.map +1 -0
  140. package/dist/projection-entry.js +8 -0
  141. package/dist/projection-entry.js.map +1 -0
  142. package/dist/simulation/fixed-step-scheduler.d.ts +13 -0
  143. package/dist/simulation/fixed-step-scheduler.d.ts.map +1 -0
  144. package/dist/simulation/fixed-step-scheduler.js +45 -0
  145. package/dist/simulation/fixed-step-scheduler.js.map +1 -0
  146. package/dist/simulation/simulation-runtime-model.d.ts +24 -0
  147. package/dist/simulation/simulation-runtime-model.d.ts.map +1 -0
  148. package/dist/simulation/simulation-runtime-model.js +63 -0
  149. package/dist/simulation/simulation-runtime-model.js.map +1 -0
  150. package/dist/simulation/simulation-wgsl.d.ts +3 -0
  151. package/dist/simulation/simulation-wgsl.d.ts.map +1 -0
  152. package/dist/simulation/simulation-wgsl.js +294 -0
  153. package/dist/simulation/simulation-wgsl.js.map +1 -0
  154. package/dist/simulation/webgpu-simulation-renderer.d.ts +67 -0
  155. package/dist/simulation/webgpu-simulation-renderer.d.ts.map +1 -0
  156. package/dist/simulation/webgpu-simulation-renderer.js +504 -0
  157. package/dist/simulation/webgpu-simulation-renderer.js.map +1 -0
  158. package/dist/simulation/webgpu-types.d.ts +90 -0
  159. package/dist/simulation/webgpu-types.d.ts.map +1 -0
  160. package/dist/simulation/webgpu-types.js +10 -0
  161. package/dist/simulation/webgpu-types.js.map +1 -0
  162. package/dist/simulation.d.ts +4 -0
  163. package/dist/simulation.d.ts.map +1 -0
  164. package/dist/simulation.js +4 -0
  165. package/dist/simulation.js.map +1 -0
  166. package/dist/systems/animation-controller.d.ts +52 -0
  167. package/dist/systems/animation-controller.d.ts.map +1 -0
  168. package/dist/systems/animation-controller.js +146 -0
  169. package/dist/systems/animation-controller.js.map +1 -0
  170. package/dist/systems/camera-controller.d.ts +41 -0
  171. package/dist/systems/camera-controller.d.ts.map +1 -0
  172. package/dist/systems/camera-controller.js +207 -0
  173. package/dist/systems/camera-controller.js.map +1 -0
  174. package/dist/systems/camera-path-controller.d.ts +39 -0
  175. package/dist/systems/camera-path-controller.d.ts.map +1 -0
  176. package/dist/systems/camera-path-controller.js +287 -0
  177. package/dist/systems/camera-path-controller.js.map +1 -0
  178. package/dist/systems/environment-controller.d.ts +18 -0
  179. package/dist/systems/environment-controller.d.ts.map +1 -0
  180. package/dist/systems/environment-controller.js +251 -0
  181. package/dist/systems/environment-controller.js.map +1 -0
  182. package/dist/systems/environment-texture.d.ts +7 -0
  183. package/dist/systems/environment-texture.d.ts.map +1 -0
  184. package/dist/systems/environment-texture.js +57 -0
  185. package/dist/systems/environment-texture.js.map +1 -0
  186. package/dist/systems/fog-controller.d.ts +12 -0
  187. package/dist/systems/fog-controller.d.ts.map +1 -0
  188. package/dist/systems/fog-controller.js +60 -0
  189. package/dist/systems/fog-controller.js.map +1 -0
  190. package/dist/systems/generated-texture-cache.d.ts +33 -0
  191. package/dist/systems/generated-texture-cache.d.ts.map +1 -0
  192. package/dist/systems/generated-texture-cache.js +101 -0
  193. package/dist/systems/generated-texture-cache.js.map +1 -0
  194. package/dist/systems/glass-transmission-controller.d.ts +21 -0
  195. package/dist/systems/glass-transmission-controller.d.ts.map +1 -0
  196. package/dist/systems/glass-transmission-controller.js +119 -0
  197. package/dist/systems/glass-transmission-controller.js.map +1 -0
  198. package/dist/systems/gpu-program-cache.d.ts +19 -0
  199. package/dist/systems/gpu-program-cache.d.ts.map +1 -0
  200. package/dist/systems/gpu-program-cache.js +95 -0
  201. package/dist/systems/gpu-program-cache.js.map +1 -0
  202. package/dist/systems/ground-controller.d.ts +14 -0
  203. package/dist/systems/ground-controller.d.ts.map +1 -0
  204. package/dist/systems/ground-controller.js +121 -0
  205. package/dist/systems/ground-controller.js.map +1 -0
  206. package/dist/systems/lighting-controller.d.ts +23 -0
  207. package/dist/systems/lighting-controller.d.ts.map +1 -0
  208. package/dist/systems/lighting-controller.js +204 -0
  209. package/dist/systems/lighting-controller.js.map +1 -0
  210. package/dist/systems/material-animation-controller.d.ts +26 -0
  211. package/dist/systems/material-animation-controller.d.ts.map +1 -0
  212. package/dist/systems/material-animation-controller.js +221 -0
  213. package/dist/systems/material-animation-controller.js.map +1 -0
  214. package/dist/systems/material-binding-resolver.d.ts +16 -0
  215. package/dist/systems/material-binding-resolver.d.ts.map +1 -0
  216. package/dist/systems/material-binding-resolver.js +54 -0
  217. package/dist/systems/material-binding-resolver.js.map +1 -0
  218. package/dist/systems/material-controller.d.ts +29 -0
  219. package/dist/systems/material-controller.d.ts.map +1 -0
  220. package/dist/systems/material-controller.js +233 -0
  221. package/dist/systems/material-controller.js.map +1 -0
  222. package/dist/systems/material-preparation.d.ts +9 -0
  223. package/dist/systems/material-preparation.d.ts.map +1 -0
  224. package/dist/systems/material-preparation.js +51 -0
  225. package/dist/systems/material-preparation.js.map +1 -0
  226. package/dist/systems/material-slots.d.ts +18 -0
  227. package/dist/systems/material-slots.d.ts.map +1 -0
  228. package/dist/systems/material-slots.js +78 -0
  229. package/dist/systems/material-slots.js.map +1 -0
  230. package/dist/systems/owned-material-controller.d.ts +20 -0
  231. package/dist/systems/owned-material-controller.d.ts.map +1 -0
  232. package/dist/systems/owned-material-controller.js +611 -0
  233. package/dist/systems/owned-material-controller.js.map +1 -0
  234. package/dist/systems/pbr-material.d.ts +22 -0
  235. package/dist/systems/pbr-material.d.ts.map +1 -0
  236. package/dist/systems/pbr-material.js +358 -0
  237. package/dist/systems/pbr-material.js.map +1 -0
  238. package/dist/systems/post-process-controller.d.ts +17 -0
  239. package/dist/systems/post-process-controller.d.ts.map +1 -0
  240. package/dist/systems/post-process-controller.js +246 -0
  241. package/dist/systems/post-process-controller.js.map +1 -0
  242. package/dist/systems/runtime-clock.d.ts +9 -0
  243. package/dist/systems/runtime-clock.d.ts.map +1 -0
  244. package/dist/systems/runtime-clock.js +25 -0
  245. package/dist/systems/runtime-clock.js.map +1 -0
  246. package/dist/systems/skybox-controller.d.ts +15 -0
  247. package/dist/systems/skybox-controller.d.ts.map +1 -0
  248. package/dist/systems/skybox-controller.js +282 -0
  249. package/dist/systems/skybox-controller.js.map +1 -0
  250. package/dist/systems/sprite-sheet-controller.d.ts +52 -0
  251. package/dist/systems/sprite-sheet-controller.d.ts.map +1 -0
  252. package/dist/systems/sprite-sheet-controller.js +187 -0
  253. package/dist/systems/sprite-sheet-controller.js.map +1 -0
  254. package/dist/systems/surface-effect-plugin.d.ts +26 -0
  255. package/dist/systems/surface-effect-plugin.d.ts.map +1 -0
  256. package/dist/systems/surface-effect-plugin.js +204 -0
  257. package/dist/systems/surface-effect-plugin.js.map +1 -0
  258. package/dist/systems/surface-program-plugin.d.ts +29 -0
  259. package/dist/systems/surface-program-plugin.d.ts.map +1 -0
  260. package/dist/systems/surface-program-plugin.js +139 -0
  261. package/dist/systems/surface-program-plugin.js.map +1 -0
  262. package/dist/systems/texture-animation-controller.d.ts +18 -0
  263. package/dist/systems/texture-animation-controller.d.ts.map +1 -0
  264. package/dist/systems/texture-animation-controller.js +147 -0
  265. package/dist/systems/texture-animation-controller.js.map +1 -0
  266. package/dist/systems/weather-controller.d.ts +16 -0
  267. package/dist/systems/weather-controller.d.ts.map +1 -0
  268. package/dist/systems/weather-controller.js +205 -0
  269. package/dist/systems/weather-controller.js.map +1 -0
  270. package/package.json +63 -0
@@ -0,0 +1,57 @@
1
+ import { CubeTexture } from "@babylonjs/core/Materials/Textures/cubeTexture";
2
+ import { EXRCubeTexture } from "@babylonjs/core/Materials/Textures/exrCubeTexture";
3
+ import { HDRCubeTexture } from "@babylonjs/core/Materials/Textures/hdrCubeTexture";
4
+ /** Loads a GPU-ready environment texture without assigning it to the scene. */
5
+ export function loadEnvironmentTexture(scene, url, sourceName, requestedFormat = "auto") {
6
+ const format = resolveEnvironmentTextureFormat(sourceName, requestedFormat);
7
+ if (format === "hdr") {
8
+ return loadTexture((onLoad, onError) => new HDRCubeTexture(url, scene, 512, false, true, false, true, onLoad, onError));
9
+ }
10
+ if (format === "exr") {
11
+ return loadTexture((onLoad, onError) => new EXRCubeTexture(url, scene, 512, false, true, false, true, onLoad, onError));
12
+ }
13
+ return loadTexture((onLoad, onError) => new CubeTexture(url, scene, {
14
+ forcedExtension: `.${format}`,
15
+ prefiltered: true,
16
+ createPolynomials: true,
17
+ onLoad,
18
+ onError,
19
+ }));
20
+ }
21
+ export function resolveEnvironmentTextureFormat(sourceName, requestedFormat) {
22
+ if (requestedFormat !== "auto")
23
+ return requestedFormat;
24
+ const path = sourceName.split(/[?#]/, 1)[0]?.toLowerCase() ?? "";
25
+ for (const format of ["env", "dds", "hdr", "exr"]) {
26
+ if (path.endsWith(`.${format}`))
27
+ return format;
28
+ }
29
+ // V1 treated every non-HDR environment as Babylon prefiltered data. Keep
30
+ // that fallback for provider keys without a file extension.
31
+ return "env";
32
+ }
33
+ function loadTexture(create) {
34
+ return new Promise((resolve, reject) => {
35
+ let texture = null;
36
+ let settled = false;
37
+ const onLoad = () => {
38
+ if (!texture || settled)
39
+ return;
40
+ settled = true;
41
+ resolve(texture);
42
+ };
43
+ const onError = (message, exception) => {
44
+ if (settled)
45
+ return;
46
+ settled = true;
47
+ texture?.dispose();
48
+ reject(exception instanceof Error
49
+ ? exception
50
+ : new Error(message || "Environment texture could not be loaded"));
51
+ };
52
+ texture = create(onLoad, onError);
53
+ if (texture.isReady())
54
+ onLoad();
55
+ });
56
+ }
57
+ //# sourceMappingURL=environment-texture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment-texture.js","sourceRoot":"","sources":["../../src/systems/environment-texture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gDAAgD,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAKnF,+EAA+E;AAC/E,MAAM,UAAU,sBAAsB,CACpC,KAAY,EACZ,GAAW,EACX,UAAkB,EAClB,kBAA4C,MAAM;IAElD,MAAM,MAAM,GAAG,+BAA+B,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAC5E,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;QACrB,OAAO,WAAW,CAChB,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CA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AE;QAC/C,IAAI,OAAO,GAAoB,IAAI,CAAC;QACpC,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,MAAM,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,OAAO,IAAI,OAAO;gBAAE,OAAO;YAChC,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC,CAAC;QACF,MAAM,OAAO,GAAG,CAAC,OAAgB,EAAE,SAAmB,EAAE,EAAE;YACxD,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,EAAE,OAAO,EAAE,CAAC;YACnB,MAAM,CACJ,SAAS,YAAY,KAAK;gBACxB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,IAAI,yCAAyC,CAAC,CACpE,CAAC;QACJ,CAAC,CAAC;QACF,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAClC,IAAI,OAAO,CAAC,OAAO,EAAE;YAAE,MAAM,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Scene } from "@babylonjs/core/scene";
2
+ import type { FogConfig } from "@skenora/contracts";
3
+ /** Owns the global fog state applied by the scene document. */
4
+ export declare class FogController {
5
+ #private;
6
+ readonly scene: Scene;
7
+ constructor(scene: Scene);
8
+ apply(config: Readonly<FogConfig>): void;
9
+ capture(): FogConfig;
10
+ dispose(): void;
11
+ }
12
+ //# sourceMappingURL=fog-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fog-controller.d.ts","sourceRoot":"","sources":["../../src/systems/fog-controller.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,+DAA+D;AAC/D,qBAAa,aAAa;;IACxB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;gBAGV,KAAK,EAAE,KAAK;IAIxB,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI;IAmBxC,OAAO,IAAI,SAAS;IAqBpB,OAAO,IAAI,IAAI;CAWhB"}
@@ -0,0 +1,60 @@
1
+ /** Projects document fog settings onto the Babylon scene. */
2
+ import { Color3 } from "@babylonjs/core/Maths/math.color";
3
+ /** Owns the global fog state applied by the scene document. */
4
+ export class FogController {
5
+ scene;
6
+ #disposed = false;
7
+ constructor(scene) {
8
+ this.scene = scene;
9
+ }
10
+ apply(config) {
11
+ this.#assertActive();
12
+ this.scene.fogEnabled = config.enabled;
13
+ this.scene.fogColor = new Color3(config.color.r, config.color.g, config.color.b);
14
+ this.scene.fogStart = config.start;
15
+ this.scene.fogEnd = config.end;
16
+ this.scene.fogDensity = config.density;
17
+ this.scene.fogMode =
18
+ config.mode === "exp"
19
+ ? SceneFogMode.EXP
20
+ : config.mode === "exp2"
21
+ ? SceneFogMode.EXP2
22
+ : SceneFogMode.LINEAR;
23
+ }
24
+ capture() {
25
+ this.#assertActive();
26
+ return {
27
+ enabled: this.scene.fogEnabled,
28
+ mode: this.scene.fogMode === SceneFogMode.EXP
29
+ ? "exp"
30
+ : this.scene.fogMode === SceneFogMode.EXP2
31
+ ? "exp2"
32
+ : "linear",
33
+ color: {
34
+ r: this.scene.fogColor.r,
35
+ g: this.scene.fogColor.g,
36
+ b: this.scene.fogColor.b,
37
+ },
38
+ start: this.scene.fogStart,
39
+ end: this.scene.fogEnd,
40
+ density: this.scene.fogDensity,
41
+ };
42
+ }
43
+ dispose() {
44
+ if (this.#disposed)
45
+ return;
46
+ this.#disposed = true;
47
+ this.scene.fogEnabled = false;
48
+ }
49
+ #assertActive() {
50
+ if (this.#disposed) {
51
+ throw new Error("FogController has been disposed");
52
+ }
53
+ }
54
+ }
55
+ const SceneFogMode = {
56
+ LINEAR: 3,
57
+ EXP: 1,
58
+ EXP2: 2,
59
+ };
60
+ //# sourceMappingURL=fog-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fog-controller.js","sourceRoot":"","sources":["../../src/systems/fog-controller.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAI1D,+DAA+D;AAC/D,MAAM,OAAO,aAAa;IACf,KAAK,CAAQ;IACtB,SAAS,GAAG,KAAK,CAAC;IAElB,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,MAA2B;QAC/B,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,MAAM,CAC9B,MAAM,CAAC,KAAK,CAAC,CAAC,EACd,MAAM,CAAC,KAAK,CAAC,CAAC,EACd,MAAM,CAAC,KAAK,CAAC,CAAC,CACf,CAAC;QACF,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,OAAO;YAChB,MAAM,CAAC,IAAI,KAAK,KAAK;gBACnB,CAAC,CAAC,YAAY,CAAC,GAAG;gBAClB,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM;oBACtB,CAAC,CAAC,YAAY,CAAC,IAAI;oBACnB,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;YAC9B,IAAI,EACF,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,YAAY,CAAC,GAAG;gBACrC,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,YAAY,CAAC,IAAI;oBACxC,CAAC,CAAC,MAAM;oBACR,CAAC,CAAC,QAAQ;YAChB,KAAK,EAAE;gBACL,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBACxB,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBACxB,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;aACzB;YACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;YAC1B,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;YACtB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;SAC/B,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;IAChC,CAAC;IAED,aAAa;QACX,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF;AAED,MAAM,YAAY,GAAG;IACnB,MAAM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;CACC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { RawTexture } from "@babylonjs/core/Materials/Textures/rawTexture";
2
+ import type { Scene } from "@babylonjs/core/scene";
3
+ import type { TextureProgram } from "@skenora/contracts";
4
+ import { type CompiledTextureProgram } from "@skenora/procedural";
5
+ export interface GeneratedTextureLease {
6
+ readonly key: string;
7
+ readonly hit: boolean;
8
+ readonly texture: RawTexture;
9
+ readonly compiled: CompiledTextureProgram;
10
+ release(): void;
11
+ }
12
+ export interface GeneratedTextureCacheSnapshot {
13
+ readonly maxEntries: number;
14
+ readonly size: number;
15
+ readonly hits: number;
16
+ readonly misses: number;
17
+ readonly evictions: number;
18
+ readonly entries: readonly Readonly<{
19
+ key: string;
20
+ references: number;
21
+ width: number;
22
+ height: number;
23
+ }>[];
24
+ }
25
+ /** Runtime-owned cache for deterministic generated texture resources. */
26
+ export declare class GeneratedTextureCache {
27
+ #private;
28
+ constructor(scene: Scene, maxEntries?: number);
29
+ acquire(program: Readonly<TextureProgram>): GeneratedTextureLease;
30
+ snapshot(): GeneratedTextureCacheSnapshot;
31
+ dispose(): void;
32
+ }
33
+ //# sourceMappingURL=generated-texture-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-texture-cache.d.ts","sourceRoot":"","sources":["../../src/systems/generated-texture-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAE3E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC;IAC1C,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,QAAQ,CAAC;QAClC,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,EAAE,CAAC;CACN;AAQD,yEAAyE;AACzE,qBAAa,qBAAqB;;gBASpB,KAAK,EAAE,KAAK,EAAE,UAAU,SAAK;IAOzC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,qBAAqB;IAuDjE,QAAQ,IAAI,6BAA6B;IAoBzC,OAAO,IAAI,IAAI;CAiBhB"}
@@ -0,0 +1,101 @@
1
+ import { RawTexture } from "@babylonjs/core/Materials/Textures/rawTexture";
2
+ import { Texture } from "@babylonjs/core/Materials/Textures/texture";
3
+ import { compileTextureProgram, } from "@skenora/procedural";
4
+ /** Runtime-owned cache for deterministic generated texture resources. */
5
+ export class GeneratedTextureCache {
6
+ #scene;
7
+ #maxEntries;
8
+ #entries = new Map();
9
+ #hits = 0;
10
+ #misses = 0;
11
+ #evictions = 0;
12
+ #disposed = false;
13
+ constructor(scene, maxEntries = 16) {
14
+ if (!Number.isInteger(maxEntries) || maxEntries < 1)
15
+ throw new Error("Generated texture cache maxEntries must be positive");
16
+ this.#scene = scene;
17
+ this.#maxEntries = maxEntries;
18
+ }
19
+ acquire(program) {
20
+ if (this.#disposed)
21
+ throw new Error("Generated texture cache has been disposed");
22
+ const compiled = compileTextureProgram(program);
23
+ const key = `${compiled.contentSignature}:${compiled.width}x${compiled.height}:${compiled.colorSpace}`;
24
+ let entry = this.#entries.get(key);
25
+ const hit = !!entry;
26
+ if (entry) {
27
+ this.#hits += 1;
28
+ this.#entries.delete(key);
29
+ this.#entries.set(key, entry);
30
+ }
31
+ else {
32
+ this.#misses += 1;
33
+ const texture = RawTexture.CreateRGBATexture(compiled.bytes, compiled.width, compiled.height, this.#scene, true, false, Texture.TRILINEAR_SAMPLINGMODE, undefined, undefined, compiled.colorSpace === "srgb");
34
+ texture.name = `skenora-generated:${key}`;
35
+ texture.wrapU = Texture.WRAP_ADDRESSMODE;
36
+ texture.wrapV = Texture.CLAMP_ADDRESSMODE;
37
+ texture.metadata = {
38
+ skenora: {
39
+ generated: true,
40
+ signature: compiled.contentSignature,
41
+ lifecycle: compiled.lifecycle,
42
+ },
43
+ };
44
+ entry = { texture, compiled, references: 0 };
45
+ this.#entries.set(key, entry);
46
+ }
47
+ entry.references += 1;
48
+ this.#evictUnused();
49
+ let released = false;
50
+ return Object.freeze({
51
+ key,
52
+ hit,
53
+ texture: entry.texture,
54
+ compiled: entry.compiled,
55
+ release: () => {
56
+ if (released)
57
+ return;
58
+ released = true;
59
+ entry.references = Math.max(0, entry.references - 1);
60
+ this.#evictUnused();
61
+ },
62
+ });
63
+ }
64
+ snapshot() {
65
+ return Object.freeze({
66
+ maxEntries: this.#maxEntries,
67
+ size: this.#entries.size,
68
+ hits: this.#hits,
69
+ misses: this.#misses,
70
+ evictions: this.#evictions,
71
+ entries: Object.freeze([...this.#entries].map(([key, entry]) => Object.freeze({
72
+ key,
73
+ references: entry.references,
74
+ width: entry.compiled.width,
75
+ height: entry.compiled.height,
76
+ }))),
77
+ });
78
+ }
79
+ dispose() {
80
+ if (this.#disposed)
81
+ return;
82
+ this.#disposed = true;
83
+ for (const entry of this.#entries.values())
84
+ entry.texture.dispose();
85
+ this.#entries.clear();
86
+ }
87
+ #evictUnused() {
88
+ if (this.#entries.size <= this.#maxEntries)
89
+ return;
90
+ for (const [key, entry] of this.#entries) {
91
+ if (entry.references !== 0)
92
+ continue;
93
+ entry.texture.dispose();
94
+ this.#entries.delete(key);
95
+ this.#evictions += 1;
96
+ if (this.#entries.size <= this.#maxEntries)
97
+ return;
98
+ }
99
+ }
100
+ }
101
+ //# sourceMappingURL=generated-texture-cache.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CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO;QACnD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACzC,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC;gBAAE,SAAS;YACrC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACxB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC1B,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC;YACrB,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC,WAAW;gBAAE,OAAO;QACrD,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ import type { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial";
2
+ import type { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh";
3
+ import type { Scene } from "@babylonjs/core/scene";
4
+ import type { RenderGraphProgram } from "@skenora/contracts";
5
+ export interface GlassTransmissionSnapshot {
6
+ readonly topologySignature: string;
7
+ readonly targetIds: readonly string[];
8
+ readonly passIds: readonly string[];
9
+ readonly width: number;
10
+ readonly height: number;
11
+ readonly resizeReplacements: number;
12
+ readonly disposed: boolean;
13
+ }
14
+ /** Owns one bounded Babylon capture/blur chain for an attached glass surface. */
15
+ export declare class GlassTransmissionController {
16
+ #private;
17
+ constructor(scene: Scene, material: PBRMaterial, excluded: AbstractMesh, graph: Readonly<RenderGraphProgram>);
18
+ snapshot(): GlassTransmissionSnapshot;
19
+ dispose(): void;
20
+ }
21
+ //# sourceMappingURL=glass-transmission-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glass-transmission-controller.d.ts","sourceRoot":"","sources":["../../src/systems/glass-transmission-controller.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAI7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAM7D,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,iFAAiF;AACjF,qBAAa,2BAA2B;;gBAWpC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,QAAQ,CAAC,kBAAkB,CAAC;IAoBrC,QAAQ,IAAI,yBAAyB;IAarC,OAAO,IAAI,IAAI;CA6GhB"}
@@ -0,0 +1,119 @@
1
+ import { BlurPostProcess } from "@babylonjs/core/PostProcesses/blurPostProcess";
2
+ import { RenderTargetTexture } from "@babylonjs/core/Materials/Textures/renderTargetTexture";
3
+ import { Texture } from "@babylonjs/core/Materials/Textures/texture";
4
+ import { Color3 } from "@babylonjs/core/Maths/math.color";
5
+ import { Color4 } from "@babylonjs/core/Maths/math.color";
6
+ import { Vector2 } from "@babylonjs/core/Maths/math.vector";
7
+ import { compileRenderGraph, } from "@skenora/procedural";
8
+ /** Owns one bounded Babylon capture/blur chain for an attached glass surface. */
9
+ export class GlassTransmissionController {
10
+ #scene;
11
+ #material;
12
+ #excluded;
13
+ #compiled;
14
+ #resizeObserver;
15
+ #target;
16
+ #resizeReplacements = 0;
17
+ #disposed = false;
18
+ constructor(scene, material, excluded, graph) {
19
+ this.#scene = scene;
20
+ this.#material = material;
21
+ this.#excluded = excluded;
22
+ this.#compiled = compileRenderGraph(graph);
23
+ this.#target = this.#createTarget();
24
+ this.#activateTarget(this.#target);
25
+ this.#applyGlassParameters();
26
+ this.#resizeObserver = scene.getEngine().onResizeObservable.add(() => {
27
+ if (this.#disposed)
28
+ return;
29
+ const next = this.#createTarget();
30
+ const previous = this.#target;
31
+ this.#target = next;
32
+ this.#activateTarget(next);
33
+ this.#resizeReplacements += 1;
34
+ if (previous)
35
+ this.#releaseTarget(previous);
36
+ });
37
+ }
38
+ snapshot() {
39
+ const target = this.#target;
40
+ return Object.freeze({
41
+ topologySignature: this.#compiled.topologySignature,
42
+ targetIds: Object.freeze(this.#compiled.targets.map(({ id }) => id)),
43
+ passIds: Object.freeze(this.#compiled.passes.map(({ id }) => id)),
44
+ width: target?.getRenderWidth() ?? 0,
45
+ height: target?.getRenderHeight() ?? 0,
46
+ resizeReplacements: this.#resizeReplacements,
47
+ disposed: this.#disposed,
48
+ });
49
+ }
50
+ dispose() {
51
+ if (this.#disposed)
52
+ return;
53
+ this.#disposed = true;
54
+ const observable = this.#scene.getEngine().onResizeObservable;
55
+ observable.remove(this.#resizeObserver);
56
+ if (this.#target)
57
+ this.#releaseTarget(this.#target);
58
+ this.#target = undefined;
59
+ this.#material.subSurface.refractionTexture = null;
60
+ this.#material.subSurface.isRefractionEnabled = false;
61
+ }
62
+ #createTarget() {
63
+ const capture = this.#compiled.passes.find((pass) => pass.type === "scene.capture");
64
+ if (!capture || capture.type !== "scene.capture")
65
+ throw new Error("Compiled render graph has no scene capture pass");
66
+ const target = this.#compiled.targets.find(({ id }) => id === capture.output);
67
+ const engine = this.#scene.getEngine();
68
+ const width = Math.max(1, Math.floor(engine.getRenderWidth() * target.scale));
69
+ const height = Math.max(1, Math.floor(engine.getRenderHeight() * target.scale));
70
+ const texture = new RenderTargetTexture(`skenora:render-graph:${this.#compiled.topologySignature}`, { width, height }, this.#scene, true, true, undefined, false, Texture.BILINEAR_SAMPLINGMODE, target.depth, false, false, undefined, false, target.samples);
71
+ texture.renderListPredicate = (mesh) => mesh !== this.#excluded && !mesh.isDescendantOf(this.#excluded);
72
+ texture.activeCamera = this.#scene.activeCamera;
73
+ texture.coordinatesMode = Texture.PROJECTION_MODE;
74
+ texture.ignoreCameraViewport = true;
75
+ texture.forceLayerMaskCheck = true;
76
+ texture.gammaSpace = false;
77
+ texture.disableImageProcessing = true;
78
+ const captureColor = capture.clearColor ?? "#000000";
79
+ texture.clearColor = Color4.FromHexString(`${captureColor}00`);
80
+ texture.refreshRate = 1;
81
+ for (const pass of this.#compiled.passes) {
82
+ if (pass.type !== "blur.gaussian")
83
+ continue;
84
+ texture.addPostProcess(new BlurPostProcess(`skenora:${pass.id}`, pass.direction === "horizontal"
85
+ ? new Vector2(1, 0)
86
+ : new Vector2(0, 1), pass.radius, 1, null, Texture.BILINEAR_SAMPLINGMODE, engine, false));
87
+ }
88
+ return texture;
89
+ }
90
+ #activateTarget(target) {
91
+ if (!this.#scene.customRenderTargets.includes(target))
92
+ this.#scene.customRenderTargets.push(target);
93
+ this.#material.subSurface.refractionTexture = target;
94
+ this.#material.subSurface.isRefractionEnabled = true;
95
+ }
96
+ #releaseTarget(target) {
97
+ const index = this.#scene.customRenderTargets.indexOf(target);
98
+ if (index >= 0)
99
+ this.#scene.customRenderTargets.splice(index, 1);
100
+ target.dispose();
101
+ }
102
+ #applyGlassParameters() {
103
+ const pass = this.#compiled.passes.find((candidate) => candidate.type === "glass.transmission");
104
+ if (!pass || pass.type !== "glass.transmission")
105
+ throw new Error("Compiled render graph has no glass transmission pass");
106
+ const surface = this.#material.subSurface;
107
+ surface.indexOfRefraction = pass.indexOfRefraction;
108
+ surface.refractionIntensity = pass.intensity;
109
+ surface.linkRefractionWithTransparency = false;
110
+ surface.minimumThickness = 0.05;
111
+ surface.maximumThickness = 1.5;
112
+ surface.isDispersionEnabled = pass.dispersion > 0;
113
+ surface.dispersion = Math.max(1, 100 - pass.dispersion * 80);
114
+ surface.useAlbedoToTintRefraction = true;
115
+ surface.tintColor = new Color3(pass.tint.r, pass.tint.g, pass.tint.b);
116
+ surface.tintColorAtDistance = 2;
117
+ }
118
+ }
119
+ //# sourceMappingURL=glass-transmission-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glass-transmission-controller.js","sourceRoot":"","sources":["../../src/systems/glass-transmission-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,EAAE,OAAO,EAAE,MAAM,4CAA4C,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAI5D,OAAO,EACL,kBAAkB,GAEnB,MAAM,qBAAqB,CAAC;AAY7B,iFAAiF;AACjF,MAAM,OAAO,2BAA2B;IAC7B,MAAM,CAAQ;IACd,SAAS,CAAc;IACvB,SAAS,CAAe;IACxB,SAAS,CAAsB;IAC/B,eAAe,CAAU;IAClC,OAAO,CAAkC;IACzC,mBAAmB,GAAG,CAAC,CAAC;IACxB,SAAS,GAAG,KAAK,CAAC;IAElB,YACE,KAAY,EACZ,QAAqB,EACrB,QAAsB,EACtB,KAAmC;QAEnC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,C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AAS,CAAC,UAAU,CAAC;QAC1C,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;QACnD,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7C,OAAO,CAAC,8BAA8B,GAAG,KAAK,CAAC;QAC/C,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAChC,OAAO,CAAC,gBAAgB,GAAG,GAAG,CAAC;QAC/B,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QAClD,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC;QAC7D,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC;QACzC,OAAO,CAAC,SAAS,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACtE,OAAO,CAAC,mBAAmB,GAAG,CAAC,CAAC;IAClC,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import { type GpuProgramCacheSnapshot, type GpuProgramIdentity, type MaterialProgram, type RuntimeBackendId } from "@skenora/contracts";
2
+ import { type MaterialProgramGlslArtifact } from "@skenora/procedural/emitters";
3
+ import { type CompiledMaterialProgram } from "@skenora/procedural";
4
+ export interface PreparedGpuProgram {
5
+ readonly identity: GpuProgramIdentity;
6
+ readonly key: string;
7
+ readonly hit: boolean;
8
+ readonly compiled: CompiledMaterialProgram;
9
+ readonly artifact: MaterialProgramGlslArtifact;
10
+ }
11
+ /** Runtime-owned bounded LRU over generated structural GPU artifacts. */
12
+ export declare class GpuProgramCache {
13
+ #private;
14
+ constructor(backend: RuntimeBackendId, maxEntries: number);
15
+ prepare(program: Readonly<MaterialProgram>): PreparedGpuProgram;
16
+ snapshot(): GpuProgramCacheSnapshot;
17
+ dispose(): void;
18
+ }
19
+ //# sourceMappingURL=gpu-program-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpu-program-cache.d.ts","sourceRoot":"","sources":["../../src/systems/gpu-program-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,2BAA2B,EACjC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,2BAA2B,CAAC;CAChD;AAMD,yEAAyE;AACzE,qBAAa,eAAe;;gBASd,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM;IASzD,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,kBAAkB;IAmD/D,QAAQ,IAAI,uBAAuB;IAYnC,OAAO,IAAI,IAAI;CAKhB"}
@@ -0,0 +1,95 @@
1
+ import { MATERIAL_PROGRAM_CAPABILITY_ID, } from "@skenora/contracts";
2
+ import { emitMaterialProgramGlsl, materialProgramGlslEmitter, } from "@skenora/procedural/emitters";
3
+ import { compileMaterialProgram, } from "@skenora/procedural";
4
+ /** Runtime-owned bounded LRU over generated structural GPU artifacts. */
5
+ export class GpuProgramCache {
6
+ #backend;
7
+ #maxEntries;
8
+ #entries = new Map();
9
+ #hits = 0;
10
+ #misses = 0;
11
+ #evictions = 0;
12
+ #disposed = false;
13
+ constructor(backend, maxEntries) {
14
+ if (!Number.isInteger(maxEntries) || maxEntries < 1)
15
+ throw new Error("GPU program cache maxEntries must be a positive integer");
16
+ this.#backend = backend;
17
+ this.#maxEntries = maxEntries;
18
+ }
19
+ prepare(program) {
20
+ if (this.#disposed)
21
+ throw new Error("GPU program cache has been disposed");
22
+ const compiled = compileMaterialProgram(program);
23
+ const variantSignature = fnv1a([
24
+ MATERIAL_PROGRAM_CAPABILITY_ID,
25
+ materialProgramGlslEmitter.id,
26
+ materialProgramGlslEmitter.version,
27
+ this.#backend,
28
+ compiled.topologySignature,
29
+ ].join("|"));
30
+ const key = `${materialProgramGlslEmitter.id}@${materialProgramGlslEmitter.version}:${this.#backend}:${variantSignature}`;
31
+ const cached = this.#entries.get(key);
32
+ let artifact;
33
+ let hit = false;
34
+ if (cached) {
35
+ this.#hits += 1;
36
+ hit = true;
37
+ artifact = cached.artifact;
38
+ this.#entries.delete(key);
39
+ this.#entries.set(key, cached);
40
+ }
41
+ else {
42
+ this.#misses += 1;
43
+ artifact = emitMaterialProgramGlsl(compiled);
44
+ this.#entries.set(key, Object.freeze({ artifact }));
45
+ if (this.#entries.size > this.#maxEntries) {
46
+ const oldest = this.#entries.keys().next().value;
47
+ if (oldest !== undefined) {
48
+ this.#entries.delete(oldest);
49
+ this.#evictions += 1;
50
+ }
51
+ }
52
+ }
53
+ return Object.freeze({
54
+ identity: Object.freeze({
55
+ version: 1,
56
+ capability: MATERIAL_PROGRAM_CAPABILITY_ID,
57
+ backend: this.#backend,
58
+ shaderLanguage: "glsl",
59
+ topologySignature: compiled.topologySignature,
60
+ contentSignature: compiled.contentSignature,
61
+ variantSignature,
62
+ }),
63
+ key,
64
+ hit,
65
+ compiled,
66
+ artifact,
67
+ });
68
+ }
69
+ snapshot() {
70
+ return Object.freeze({
71
+ version: 1,
72
+ maxEntries: this.#maxEntries,
73
+ size: this.#entries.size,
74
+ hits: this.#hits,
75
+ misses: this.#misses,
76
+ evictions: this.#evictions,
77
+ keys: Object.freeze([...this.#entries.keys()]),
78
+ });
79
+ }
80
+ dispose() {
81
+ if (this.#disposed)
82
+ return;
83
+ this.#disposed = true;
84
+ this.#entries.clear();
85
+ }
86
+ }
87
+ function fnv1a(value) {
88
+ let hash = 0x811c9dc5;
89
+ for (let index = 0; index < value.length; index += 1) {
90
+ hash ^= value.charCodeAt(index);
91
+ hash = Math.imul(hash, 0x01000193);
92
+ }
93
+ return `fnv1a:${(hash >>> 0).toString(16).padStart(8, "0")}`;
94
+ }
95
+ //# sourceMappingURL=gpu-program-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpu-program-cache.js","sourceRoot":"","sources":["../../src/systems/gpu-program-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,GAK/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,uBAAuB,EACvB,0BAA0B,GAE3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,sBAAsB,GAEvB,MAAM,qBAAqB,CAAC;AAc7B,yEAAyE;AACzE,MAAM,OAAO,eAAe;IACjB,QAAQ,CAAmB;IAC3B,WAAW,CAAS;IACpB,QAAQ,GAAG,IAAI,GAAG,EAAgC,CAAC;IAC5D,KAAK,GAAG,CAAC,CAAC;IACV,OAAO,GAAG,CAAC,CAAC;IACZ,UAAU,GAAG,CAAC,CAAC;IACf,SAAS,GAAG,KAAK,CAAC;IAElB,YAAY,OAAyB,EAAE,UAAkB;QACvD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC;YACjD,MAAM,IAAI,KAAK,CACb,yDAAyD,CAC1D,CAAC;QACJ,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,OAAkC;QACxC,IAAI,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;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CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACrD,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Mesh } from "@babylonjs/core/Meshes/mesh";
2
+ import type { Scene } from "@babylonjs/core/scene";
3
+ import type { GroundConfig } from "@skenora/contracts";
4
+ /** Owns the document-created ground mesh and its material. */
5
+ export declare class GroundController {
6
+ #private;
7
+ readonly scene: Scene;
8
+ constructor(scene: Scene);
9
+ get ground(): Mesh | null;
10
+ apply(config: Readonly<GroundConfig>): void;
11
+ capture(fallback: Readonly<GroundConfig>): GroundConfig;
12
+ dispose(): void;
13
+ }
14
+ //# sourceMappingURL=ground-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ground-controller.d.ts","sourceRoot":"","sources":["../../src/systems/ground-controller.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,8DAA8D;AAC9D,qBAAa,gBAAgB;;IAC3B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;gBAKV,KAAK,EAAE,KAAK;IAIxB,IAAI,MAAM,IAAI,IAAI,GAAG,IAAI,CAExB;IAED,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,IAAI;IAiC3C,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,YAAY;IAkBvD,OAAO,IAAI,IAAI;CAiBhB"}