@luma.gl/engine 10.0.0-alpha.3 → 10.0.0-alpha.5

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 (673) hide show
  1. package/README.md +9 -0
  2. package/dist/animation/animation-clip.cjs +36 -0
  3. package/dist/animation/animation-interpolation.cjs +115 -0
  4. package/dist/animation/animation-mixer.cjs +302 -0
  5. package/dist/animation/animation-track.cjs +55 -0
  6. package/dist/animation/animator.cjs +75 -0
  7. package/dist/animation/deform-positions.cjs +69 -0
  8. package/dist/animation/deform-positions.d.ts +13 -0
  9. package/dist/animation/deform-positions.d.ts.map +1 -0
  10. package/dist/animation/deform-positions.js +49 -0
  11. package/dist/animation/deform-positions.js.map +1 -0
  12. package/dist/animation/key-frames.cjs +81 -0
  13. package/dist/animation/morph-targets.cjs +162 -0
  14. package/dist/animation/node-animation-binding.cjs +67 -0
  15. package/dist/animation/node-animation-binding.d.ts +9 -0
  16. package/dist/animation/node-animation-binding.d.ts.map +1 -0
  17. package/dist/animation/node-animation-binding.js +45 -0
  18. package/dist/animation/node-animation-binding.js.map +1 -0
  19. package/dist/animation/property-animation-binding.cjs +159 -0
  20. package/dist/animation/property-animation-binding.d.ts +29 -0
  21. package/dist/animation/property-animation-binding.d.ts.map +1 -0
  22. package/dist/animation/property-animation-binding.js +138 -0
  23. package/dist/animation/property-animation-binding.js.map +1 -0
  24. package/dist/animation/scenegraph-animator.cjs +122 -0
  25. package/dist/animation/scenegraph-animator.d.ts +37 -0
  26. package/dist/animation/scenegraph-animator.d.ts.map +1 -0
  27. package/dist/animation/scenegraph-animator.js +99 -0
  28. package/dist/animation/scenegraph-animator.js.map +1 -0
  29. package/dist/animation/skin.cjs +49 -0
  30. package/dist/animation/texture-transform.cjs +41 -0
  31. package/dist/animation/texture-transform.d.ts +8 -0
  32. package/dist/animation/texture-transform.d.ts.map +1 -0
  33. package/dist/animation/texture-transform.js +17 -0
  34. package/dist/animation/texture-transform.js.map +1 -0
  35. package/dist/animation/timeline.cjs +129 -0
  36. package/dist/animation-loop/animation-loop-template.cjs +33 -0
  37. package/dist/animation-loop/animation-loop.cjs +498 -0
  38. package/dist/animation-loop/animation-loop.d.ts +2 -1
  39. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  40. package/dist/animation-loop/animation-loop.js +9 -3
  41. package/dist/animation-loop/animation-loop.js.map +1 -1
  42. package/dist/animation-loop/animation-props.cjs +15 -0
  43. package/dist/animation-loop/make-animation-loop.cjs +104 -0
  44. package/dist/animation-loop/request-animation-frame.cjs +43 -0
  45. package/dist/application-utils/load-file.cjs +77 -0
  46. package/dist/application-utils/random.cjs +38 -0
  47. package/dist/audio/audio-controller.cjs +429 -0
  48. package/dist/audio/audio-controller.d.ts +146 -0
  49. package/dist/audio/audio-controller.d.ts.map +1 -0
  50. package/dist/audio/audio-controller.js +445 -0
  51. package/dist/audio/audio-controller.js.map +1 -0
  52. package/dist/audio/audio-environment.cjs +157 -0
  53. package/dist/audio/audio-environment.d.ts +49 -0
  54. package/dist/audio/audio-environment.d.ts.map +1 -0
  55. package/dist/audio/audio-environment.js +148 -0
  56. package/dist/audio/audio-environment.js.map +1 -0
  57. package/dist/audio/audio-graph.cjs +182 -0
  58. package/dist/audio/audio-graph.d.ts +58 -0
  59. package/dist/audio/audio-graph.d.ts.map +1 -0
  60. package/dist/audio/audio-graph.js +181 -0
  61. package/dist/audio/audio-graph.js.map +1 -0
  62. package/dist/compute/buffer-transform.cjs +146 -0
  63. package/dist/compute/buffer-transform.d.ts +15 -5
  64. package/dist/compute/buffer-transform.d.ts.map +1 -1
  65. package/dist/compute/buffer-transform.js +56 -12
  66. package/dist/compute/buffer-transform.js.map +1 -1
  67. package/dist/compute/computation.cjs +331 -0
  68. package/dist/compute/computation.d.ts +2 -4
  69. package/dist/compute/computation.d.ts.map +1 -1
  70. package/dist/compute/computation.js +3 -14
  71. package/dist/compute/computation.js.map +1 -1
  72. package/dist/compute/swap.cjs +132 -0
  73. package/dist/compute/texture-transform.cjs +142 -0
  74. package/dist/compute/texture-transform.d.ts +11 -7
  75. package/dist/compute/texture-transform.d.ts.map +1 -1
  76. package/dist/compute/texture-transform.js +16 -6
  77. package/dist/compute/texture-transform.js.map +1 -1
  78. package/dist/controls/orbit-controls.cjs +283 -0
  79. package/dist/controls/orbit-controls.d.ts +2 -0
  80. package/dist/controls/orbit-controls.d.ts.map +1 -1
  81. package/dist/controls/orbit-controls.js +2 -1
  82. package/dist/controls/orbit-controls.js.map +1 -1
  83. package/dist/debug/copy-texture-to-image.cjs +84 -0
  84. package/dist/debug/debug-framebuffer.cjs +113 -0
  85. package/dist/debug/debug-shader-layout.cjs +45 -0
  86. package/dist/debug/pixel-data-utils.cjs +54 -0
  87. package/dist/dist.dev.js +11517 -6015
  88. package/dist/dist.min.js +39 -35
  89. package/dist/dynamic-buffer/dynamic-buffer.cjs +39 -0
  90. package/dist/dynamic-buffer/dynamic-buffer.d.ts +1 -170
  91. package/dist/dynamic-buffer/dynamic-buffer.d.ts.map +1 -1
  92. package/dist/dynamic-buffer/dynamic-buffer.js +2 -312
  93. package/dist/dynamic-buffer/dynamic-buffer.js.map +1 -1
  94. package/dist/dynamic-texture/dynamic-texture.cjs +27 -0
  95. package/dist/dynamic-texture/dynamic-texture.d.ts +1 -114
  96. package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
  97. package/dist/dynamic-texture/dynamic-texture.js +2 -584
  98. package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
  99. package/dist/dynamic-texture/texture-binding-source.cjs +31 -0
  100. package/dist/dynamic-texture/texture-binding-source.d.ts +1 -54
  101. package/dist/dynamic-texture/texture-binding-source.d.ts.map +1 -1
  102. package/dist/dynamic-texture/texture-binding-source.js +2 -51
  103. package/dist/dynamic-texture/texture-binding-source.js.map +1 -1
  104. package/dist/dynamic-texture/texture-data.cjs +53 -0
  105. package/dist/dynamic-texture/texture-data.d.ts +1 -145
  106. package/dist/dynamic-texture/texture-data.d.ts.map +1 -1
  107. package/dist/dynamic-texture/texture-data.js +2 -209
  108. package/dist/dynamic-texture/texture-data.js.map +1 -1
  109. package/dist/dynamic-texture/video-texture.cjs +269 -0
  110. package/dist/dynamic-texture/video-texture.d.ts +1 -1
  111. package/dist/dynamic-texture/video-texture.d.ts.map +1 -1
  112. package/dist/experimental/controls/comparison-splitter.cjs +231 -0
  113. package/dist/experimental/controls/comparison-splitter.d.ts +54 -0
  114. package/dist/experimental/controls/comparison-splitter.d.ts.map +1 -0
  115. package/dist/experimental/controls/comparison-splitter.js +215 -0
  116. package/dist/experimental/controls/comparison-splitter.js.map +1 -0
  117. package/dist/experimental/controls/flat-controller.cjs +301 -0
  118. package/dist/experimental/controls/flat-controller.d.ts +80 -0
  119. package/dist/experimental/controls/flat-controller.d.ts.map +1 -0
  120. package/dist/experimental/controls/flat-controller.js +295 -0
  121. package/dist/experimental/controls/flat-controller.js.map +1 -0
  122. package/dist/experimental/controls/index.cjs +35 -0
  123. package/dist/experimental/controls/index.cjs.map +6 -0
  124. package/dist/experimental/controls/index.d.ts +7 -0
  125. package/dist/experimental/controls/index.d.ts.map +1 -0
  126. package/dist/experimental/controls/index.js +7 -0
  127. package/dist/experimental/controls/index.js.map +1 -0
  128. package/dist/experimental/controls/orbit-controls.cjs +27 -0
  129. package/dist/experimental/controls/orbit-controls.d.ts +3 -0
  130. package/dist/experimental/controls/orbit-controls.d.ts.map +1 -0
  131. package/dist/experimental/controls/orbit-controls.js +5 -0
  132. package/dist/experimental/controls/orbit-controls.js.map +1 -0
  133. package/dist/experimental/materials/emissive-material.cjs +126 -0
  134. package/dist/experimental/materials/emissive-material.d.ts +38 -0
  135. package/dist/experimental/materials/emissive-material.d.ts.map +1 -0
  136. package/dist/experimental/materials/emissive-material.js +100 -0
  137. package/dist/experimental/materials/emissive-material.js.map +1 -0
  138. package/dist/experimental/materials/glass-material.cjs +570 -0
  139. package/dist/experimental/materials/glass-material.d.ts +107 -0
  140. package/dist/experimental/materials/glass-material.d.ts.map +1 -0
  141. package/dist/experimental/materials/glass-material.js +544 -0
  142. package/dist/experimental/materials/glass-material.js.map +1 -0
  143. package/dist/experimental/materials/glass-transmission.cjs +954 -0
  144. package/dist/experimental/materials/glass-transmission.d.ts +193 -0
  145. package/dist/experimental/materials/glass-transmission.d.ts.map +1 -0
  146. package/dist/experimental/materials/glass-transmission.js +928 -0
  147. package/dist/experimental/materials/glass-transmission.js.map +1 -0
  148. package/dist/experimental/materials/index.cjs +61 -0
  149. package/dist/experimental/materials/index.cjs.map +6 -0
  150. package/dist/experimental/materials/index.d.ts +14 -0
  151. package/dist/experimental/materials/index.d.ts.map +1 -0
  152. package/dist/experimental/materials/index.js +11 -0
  153. package/dist/experimental/materials/index.js.map +1 -0
  154. package/dist/experimental/materials/optical-caustics.cjs +201 -0
  155. package/dist/experimental/materials/optical-caustics.d.ts +69 -0
  156. package/dist/experimental/materials/optical-caustics.d.ts.map +1 -0
  157. package/dist/experimental/materials/optical-caustics.js +180 -0
  158. package/dist/experimental/materials/optical-caustics.js.map +1 -0
  159. package/dist/experimental/materials/optical-lighting.cjs +169 -0
  160. package/dist/experimental/materials/optical-lighting.d.ts +7 -0
  161. package/dist/experimental/materials/optical-lighting.d.ts.map +1 -0
  162. package/dist/experimental/materials/optical-lighting.js +144 -0
  163. package/dist/experimental/materials/optical-lighting.js.map +1 -0
  164. package/dist/experimental/materials/optical-point-lights.cjs +258 -0
  165. package/dist/experimental/materials/optical-point-lights.d.ts +68 -0
  166. package/dist/experimental/materials/optical-point-lights.d.ts.map +1 -0
  167. package/dist/experimental/materials/optical-point-lights.js +237 -0
  168. package/dist/experimental/materials/optical-point-lights.js.map +1 -0
  169. package/dist/experimental/materials/reflective-material.cjs +216 -0
  170. package/dist/experimental/materials/reflective-material.d.ts +46 -0
  171. package/dist/experimental/materials/reflective-material.d.ts.map +1 -0
  172. package/dist/experimental/materials/reflective-material.js +190 -0
  173. package/dist/experimental/materials/reflective-material.js.map +1 -0
  174. package/dist/experimental/textures/html-texture.cjs +221 -0
  175. package/dist/experimental/textures/html-texture.d.ts +85 -0
  176. package/dist/experimental/textures/html-texture.d.ts.map +1 -0
  177. package/dist/experimental/textures/html-texture.js +206 -0
  178. package/dist/experimental/textures/html-texture.js.map +1 -0
  179. package/dist/experimental/textures/index.cjs +33 -0
  180. package/dist/experimental/textures/index.cjs.map +6 -0
  181. package/dist/experimental/textures/index.d.ts +5 -0
  182. package/dist/experimental/textures/index.d.ts.map +1 -0
  183. package/dist/experimental/textures/index.js +7 -0
  184. package/dist/experimental/textures/index.js.map +1 -0
  185. package/dist/experimental/textures/packed-pixels.cjs +248 -0
  186. package/dist/experimental/textures/packed-pixels.d.ts +17 -0
  187. package/dist/experimental/textures/packed-pixels.d.ts.map +1 -0
  188. package/dist/experimental/textures/packed-pixels.js +237 -0
  189. package/dist/experimental/textures/packed-pixels.js.map +1 -0
  190. package/dist/experimental/textures/rgba-decoder.cjs +60 -0
  191. package/dist/experimental/textures/rgba-decoder.d.ts +29 -0
  192. package/dist/experimental/textures/rgba-decoder.d.ts.map +1 -0
  193. package/dist/experimental/textures/rgba-decoder.js +43 -0
  194. package/dist/experimental/textures/rgba-decoder.js.map +1 -0
  195. package/dist/experimental/webxr/index.cjs +38 -0
  196. package/dist/experimental/webxr/index.cjs.map +6 -0
  197. package/dist/experimental/webxr/index.d.ts +9 -0
  198. package/dist/experimental/webxr/index.d.ts.map +1 -0
  199. package/dist/experimental/webxr/index.js +8 -0
  200. package/dist/experimental/webxr/index.js.map +1 -0
  201. package/dist/experimental/webxr/webxr-animation-frame-provider.cjs +38 -0
  202. package/dist/experimental/webxr/webxr-animation-frame-provider.d.ts +9 -0
  203. package/dist/experimental/webxr/webxr-animation-frame-provider.d.ts.map +1 -0
  204. package/dist/experimental/webxr/webxr-animation-frame-provider.js +17 -0
  205. package/dist/experimental/webxr/webxr-animation-frame-provider.js.map +1 -0
  206. package/dist/experimental/webxr/webxr-camera-texture.cjs +157 -0
  207. package/dist/experimental/webxr/webxr-camera-texture.d.ts +48 -0
  208. package/dist/experimental/webxr/webxr-camera-texture.d.ts.map +1 -0
  209. package/dist/experimental/webxr/webxr-camera-texture.js +144 -0
  210. package/dist/experimental/webxr/webxr-camera-texture.js.map +1 -0
  211. package/dist/experimental/webxr/webxr-input.cjs +93 -0
  212. package/dist/experimental/webxr/webxr-input.d.ts +24 -0
  213. package/dist/experimental/webxr/webxr-input.d.ts.map +1 -0
  214. package/dist/experimental/webxr/webxr-input.js +70 -0
  215. package/dist/experimental/webxr/webxr-input.js.map +1 -0
  216. package/dist/experimental/webxr/webxr-manager.cjs +356 -0
  217. package/dist/experimental/webxr/webxr-manager.d.ts +91 -0
  218. package/dist/experimental/webxr/webxr-manager.d.ts.map +1 -0
  219. package/dist/experimental/webxr/webxr-manager.js +354 -0
  220. package/dist/experimental/webxr/webxr-manager.js.map +1 -0
  221. package/dist/experimental/webxr/webxr-types.cjs +15 -0
  222. package/dist/experimental/webxr/webxr-types.d.ts +152 -0
  223. package/dist/experimental/webxr/webxr-types.d.ts.map +1 -0
  224. package/dist/experimental/webxr/webxr-types.js +5 -0
  225. package/dist/experimental/webxr/webxr-types.js.map +1 -0
  226. package/dist/geometry/edge-geometry.cjs +171 -0
  227. package/dist/geometry/edge-geometry.d.ts +3 -2
  228. package/dist/geometry/edge-geometry.d.ts.map +1 -1
  229. package/dist/geometry/edge-geometry.js.map +1 -1
  230. package/dist/geometry/geometry-primitives.cjs +189 -0
  231. package/dist/geometry/geometry-primitives.d.ts +60 -0
  232. package/dist/geometry/geometry-primitives.d.ts.map +1 -0
  233. package/dist/geometry/geometry-primitives.js +161 -0
  234. package/dist/geometry/geometry-primitives.js.map +1 -0
  235. package/dist/geometry/geometry-table.cjs +15 -0
  236. package/dist/geometry/geometry-utils.cjs +147 -0
  237. package/dist/geometry/geometry-utils.d.ts +7 -15
  238. package/dist/geometry/geometry-utils.d.ts.map +1 -1
  239. package/dist/geometry/geometry-utils.js +9 -55
  240. package/dist/geometry/geometry-utils.js.map +1 -1
  241. package/dist/geometry/geometry.cjs +90 -0
  242. package/dist/geometry/geometry.d.ts +9 -69
  243. package/dist/geometry/geometry.d.ts.map +1 -1
  244. package/dist/geometry/geometry.js +27 -93
  245. package/dist/geometry/geometry.js.map +1 -1
  246. package/dist/geometry/gpu-geometry.cjs +130 -0
  247. package/dist/geometry/gpu-geometry.d.ts +4 -2
  248. package/dist/geometry/gpu-geometry.d.ts.map +1 -1
  249. package/dist/geometry/gpu-geometry.js +3 -3
  250. package/dist/geometry/gpu-geometry.js.map +1 -1
  251. package/dist/geometry/gpu-vector-geometry-adapter.cjs +88 -0
  252. package/dist/geometry/gpu-vector-geometry-adapter.d.ts +5 -0
  253. package/dist/geometry/gpu-vector-geometry-adapter.d.ts.map +1 -0
  254. package/dist/geometry/gpu-vector-geometry-adapter.js +73 -0
  255. package/dist/geometry/gpu-vector-geometry-adapter.js.map +1 -0
  256. package/dist/geometry/gpu-vector-geometry.cjs +40 -0
  257. package/dist/geometry/gpu-vector-geometry.d.ts +21 -0
  258. package/dist/geometry/gpu-vector-geometry.d.ts.map +1 -0
  259. package/dist/geometry/gpu-vector-geometry.js +19 -0
  260. package/dist/geometry/gpu-vector-geometry.js.map +1 -0
  261. package/dist/geometry/mesh-simplification.cjs +385 -0
  262. package/dist/geometry/ring-geometry.cjs +104 -0
  263. package/dist/geometry/ring-geometry.d.ts +17 -0
  264. package/dist/geometry/ring-geometry.d.ts.map +1 -0
  265. package/dist/geometry/ring-geometry.js +94 -0
  266. package/dist/geometry/ring-geometry.js.map +1 -0
  267. package/dist/geometry/stroke-geometry.cjs +171 -0
  268. package/dist/graph/models/index.cjs +66 -0
  269. package/dist/graph/models/index.cjs.map +6 -0
  270. package/dist/graph/models/index.d.ts +7 -0
  271. package/dist/graph/models/index.d.ts.map +1 -0
  272. package/dist/graph/models/index.js +10 -0
  273. package/dist/graph/models/index.js.map +1 -0
  274. package/dist/graph/models/path/path-attribute-model.cjs +421 -0
  275. package/dist/graph/models/path/path-attribute-model.d.ts +142 -0
  276. package/dist/graph/models/path/path-attribute-model.d.ts.map +1 -0
  277. package/dist/graph/models/path/path-attribute-model.js +409 -0
  278. package/dist/graph/models/path/path-attribute-model.js.map +1 -0
  279. package/dist/graph/models/path/path-storage-model.cjs +711 -0
  280. package/dist/graph/models/path/path-storage-model.d.ts +174 -0
  281. package/dist/graph/models/path/path-storage-model.d.ts.map +1 -0
  282. package/dist/graph/models/path/path-storage-model.js +720 -0
  283. package/dist/graph/models/path/path-storage-model.js.map +1 -0
  284. package/dist/graph/models/path/path-trips-storage-model.cjs +271 -0
  285. package/dist/graph/models/path/path-trips-storage-model.d.ts +58 -0
  286. package/dist/graph/models/path/path-trips-storage-model.d.ts.map +1 -0
  287. package/dist/graph/models/path/path-trips-storage-model.js +248 -0
  288. package/dist/graph/models/path/path-trips-storage-model.js.map +1 -0
  289. package/dist/graph/models/polygon/polygon-attribute-model.cjs +117 -0
  290. package/dist/graph/models/polygon/polygon-attribute-model.d.ts +53 -0
  291. package/dist/graph/models/polygon/polygon-attribute-model.d.ts.map +1 -0
  292. package/dist/graph/models/polygon/polygon-attribute-model.js +101 -0
  293. package/dist/graph/models/polygon/polygon-attribute-model.js.map +1 -0
  294. package/dist/graph/models/polygon/polygon-shaders.cjs +283 -0
  295. package/dist/graph/models/polygon/polygon-shaders.d.ts +77 -0
  296. package/dist/graph/models/polygon/polygon-shaders.d.ts.map +1 -0
  297. package/dist/graph/models/polygon/polygon-shaders.js +242 -0
  298. package/dist/graph/models/polygon/polygon-shaders.js.map +1 -0
  299. package/dist/graph/models/polygon/polygon-storage-model.cjs +111 -0
  300. package/dist/graph/models/polygon/polygon-storage-model.d.ts +53 -0
  301. package/dist/graph/models/polygon/polygon-storage-model.d.ts.map +1 -0
  302. package/dist/graph/models/polygon/polygon-storage-model.js +92 -0
  303. package/dist/graph/models/polygon/polygon-storage-model.js.map +1 -0
  304. package/dist/graph/physics/index.cjs +50 -0
  305. package/dist/graph/physics/index.cjs.map +6 -0
  306. package/dist/graph/physics/index.d.ts +12 -0
  307. package/dist/graph/physics/index.d.ts.map +1 -0
  308. package/dist/graph/physics/index.js +12 -0
  309. package/dist/graph/physics/index.js.map +1 -0
  310. package/dist/graph/physics/physics-scenegraph.cjs +92 -0
  311. package/dist/graph/physics/physics-scenegraph.d.ts +35 -0
  312. package/dist/graph/physics/physics-scenegraph.d.ts.map +1 -0
  313. package/dist/graph/physics/physics-scenegraph.js +80 -0
  314. package/dist/graph/physics/physics-scenegraph.js.map +1 -0
  315. package/dist/graph/physics/scenegraph-behaviors.cjs +164 -0
  316. package/dist/graph/physics/scenegraph-behaviors.d.ts +37 -0
  317. package/dist/graph/physics/scenegraph-behaviors.d.ts.map +1 -0
  318. package/dist/graph/physics/scenegraph-behaviors.js +145 -0
  319. package/dist/graph/physics/scenegraph-behaviors.js.map +1 -0
  320. package/dist/graph/physics/scenegraph-instance.cjs +246 -0
  321. package/dist/graph/physics/scenegraph-instance.d.ts +59 -0
  322. package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -0
  323. package/dist/graph/physics/scenegraph-instance.js +241 -0
  324. package/dist/graph/physics/scenegraph-instance.js.map +1 -0
  325. package/dist/graph/physics/scenegraph-joints.cjs +51 -0
  326. package/dist/graph/physics/scenegraph-joints.d.ts +5 -0
  327. package/dist/graph/physics/scenegraph-joints.d.ts.map +1 -0
  328. package/dist/graph/physics/scenegraph-joints.js +31 -0
  329. package/dist/graph/physics/scenegraph-joints.js.map +1 -0
  330. package/dist/graph/physics/scenegraph-motion.cjs +177 -0
  331. package/dist/graph/physics/scenegraph-motion.d.ts +37 -0
  332. package/dist/graph/physics/scenegraph-motion.d.ts.map +1 -0
  333. package/dist/graph/physics/scenegraph-motion.js +168 -0
  334. package/dist/graph/physics/scenegraph-motion.js.map +1 -0
  335. package/dist/graph/physics/scenegraph-properties.cjs +170 -0
  336. package/dist/graph/physics/scenegraph-properties.d.ts +37 -0
  337. package/dist/graph/physics/scenegraph-properties.d.ts.map +1 -0
  338. package/dist/graph/physics/scenegraph-properties.js +186 -0
  339. package/dist/graph/physics/scenegraph-properties.js.map +1 -0
  340. package/dist/graph/physics/scenegraph-publication.cjs +112 -0
  341. package/dist/graph/physics/scenegraph-publication.d.ts +23 -0
  342. package/dist/graph/physics/scenegraph-publication.d.ts.map +1 -0
  343. package/dist/graph/physics/scenegraph-publication.js +99 -0
  344. package/dist/graph/physics/scenegraph-publication.js.map +1 -0
  345. package/dist/graph/physics/scenegraph-session.cjs +256 -0
  346. package/dist/graph/physics/scenegraph-session.d.ts +68 -0
  347. package/dist/graph/physics/scenegraph-session.d.ts.map +1 -0
  348. package/dist/graph/physics/scenegraph-session.js +249 -0
  349. package/dist/graph/physics/scenegraph-session.js.map +1 -0
  350. package/dist/graph/tables/gpu-table-geometry.cjs +84 -0
  351. package/dist/graph/tables/gpu-table-geometry.d.ts +32 -0
  352. package/dist/graph/tables/gpu-table-geometry.d.ts.map +1 -0
  353. package/dist/graph/tables/gpu-table-geometry.js +67 -0
  354. package/dist/graph/tables/gpu-table-geometry.js.map +1 -0
  355. package/dist/graph/tables/gpu-table-model.cjs +459 -0
  356. package/dist/graph/tables/gpu-table-model.d.ts +67 -0
  357. package/dist/graph/tables/gpu-table-model.d.ts.map +1 -0
  358. package/dist/graph/tables/gpu-table-model.js +457 -0
  359. package/dist/graph/tables/gpu-table-model.js.map +1 -0
  360. package/dist/graph/tables/gpu-table-transform.cjs +341 -0
  361. package/dist/graph/tables/gpu-table-transform.d.ts +61 -0
  362. package/dist/graph/tables/gpu-table-transform.d.ts.map +1 -0
  363. package/dist/graph/tables/gpu-table-transform.js +333 -0
  364. package/dist/graph/tables/gpu-table-transform.js.map +1 -0
  365. package/dist/graph/tables/index.cjs +33 -0
  366. package/dist/graph/tables/index.cjs.map +6 -0
  367. package/dist/graph/tables/index.d.ts +4 -0
  368. package/dist/graph/tables/index.d.ts.map +1 -0
  369. package/dist/graph/tables/index.js +7 -0
  370. package/dist/graph/tables/index.js.map +1 -0
  371. package/dist/index.cjs +303 -10629
  372. package/dist/index.cjs.map +3 -3
  373. package/dist/index.d.ts +46 -19
  374. package/dist/index.d.ts.map +1 -1
  375. package/dist/index.js +33 -10
  376. package/dist/index.js.map +1 -1
  377. package/dist/interactivity/interactivity.cjs +570 -0
  378. package/dist/interactivity/interactivity.d.ts +107 -0
  379. package/dist/interactivity/interactivity.d.ts.map +1 -0
  380. package/dist/interactivity/interactivity.js +575 -0
  381. package/dist/interactivity/interactivity.js.map +1 -0
  382. package/dist/interactivity/physics.cjs +15 -0
  383. package/dist/interactivity/physics.d.ts +12 -0
  384. package/dist/interactivity/physics.d.ts.map +1 -0
  385. package/dist/interactivity/physics.js +5 -0
  386. package/dist/interactivity/physics.js.map +1 -0
  387. package/dist/material/material-factory.cjs +99 -0
  388. package/dist/material/material-factory.d.ts +1 -1
  389. package/dist/material/material-factory.d.ts.map +1 -1
  390. package/dist/material/material.cjs +239 -0
  391. package/dist/material/material.d.ts +2 -2
  392. package/dist/material/material.d.ts.map +1 -1
  393. package/dist/material/material.js +2 -2
  394. package/dist/material/material.js.map +1 -1
  395. package/dist/model/gpu-vector-bindings.cjs +226 -0
  396. package/dist/model/gpu-vector-bindings.d.ts +36 -0
  397. package/dist/model/gpu-vector-bindings.d.ts.map +1 -0
  398. package/dist/model/gpu-vector-bindings.js +217 -0
  399. package/dist/model/gpu-vector-bindings.js.map +1 -0
  400. package/dist/model/gpu-vector-draw-batches.cjs +82 -0
  401. package/dist/model/gpu-vector-draw-batches.d.ts +5 -0
  402. package/dist/model/gpu-vector-draw-batches.d.ts.map +1 -0
  403. package/dist/model/gpu-vector-draw-batches.js +73 -0
  404. package/dist/model/gpu-vector-draw-batches.js.map +1 -0
  405. package/dist/model/gpu-vector-model-batches.cjs +94 -0
  406. package/dist/model/gpu-vector-model-batches.d.ts +41 -0
  407. package/dist/model/gpu-vector-model-batches.d.ts.map +1 -0
  408. package/dist/model/gpu-vector-model-batches.js +77 -0
  409. package/dist/model/gpu-vector-model-batches.js.map +1 -0
  410. package/dist/model/gpu-vector-model.cjs +1264 -0
  411. package/dist/model/gpu-vector-model.d.ts +352 -0
  412. package/dist/model/gpu-vector-model.d.ts.map +1 -0
  413. package/dist/model/gpu-vector-model.js +1375 -0
  414. package/dist/model/gpu-vector-model.js.map +1 -0
  415. package/dist/model/model.cjs +134 -0
  416. package/dist/model/model.d.ts +22 -306
  417. package/dist/model/model.d.ts.map +1 -1
  418. package/dist/model/model.js +68 -1092
  419. package/dist/model/model.js.map +1 -1
  420. package/dist/model/split-uniforms-and-bindings.cjs +44 -0
  421. package/dist/model/split-uniforms-and-bindings.d.ts +1 -1
  422. package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -1
  423. package/dist/model/split-uniforms-and-bindings.js +5 -2
  424. package/dist/model/split-uniforms-and-bindings.js.map +1 -1
  425. package/dist/models/billboard-texture-model.cjs +167 -0
  426. package/dist/models/billboard-texture-model.d.ts +1 -1
  427. package/dist/models/billboard-texture-model.d.ts.map +1 -1
  428. package/dist/models/billboard-texture-model.js +1 -1
  429. package/dist/models/billboard-texture-model.js.map +1 -1
  430. package/dist/models/billboard-texture-module.cjs +61 -0
  431. package/dist/models/clip-space.cjs +103 -0
  432. package/dist/models/clip-space.d.ts +4 -1
  433. package/dist/models/clip-space.d.ts.map +1 -1
  434. package/dist/models/clip-space.js +16 -13
  435. package/dist/models/clip-space.js.map +1 -1
  436. package/dist/models/directional-light-model.cjs +45 -0
  437. package/dist/models/directional-light-model.js +1 -1
  438. package/dist/models/directional-light-model.js.map +1 -1
  439. package/dist/models/light-model-utils.cjs +426 -0
  440. package/dist/models/point-light-model.cjs +44 -0
  441. package/dist/models/point-light-model.js +1 -1
  442. package/dist/models/point-light-model.js.map +1 -1
  443. package/dist/models/spot-light-model.cjs +45 -0
  444. package/dist/models/spot-light-model.js +1 -1
  445. package/dist/models/spot-light-model.js.map +1 -1
  446. package/dist/modules/picking/color-picking.cjs +209 -0
  447. package/dist/modules/picking/color-picking.d.ts +1 -1
  448. package/dist/modules/picking/index-color-picking.cjs +230 -0
  449. package/dist/modules/picking/index-color-picking.d.ts +1 -1
  450. package/dist/modules/picking/index-picking.cjs +201 -0
  451. package/dist/modules/picking/index-picking.d.ts +1 -1
  452. package/dist/modules/picking/legacy-color-picking.cjs +28 -0
  453. package/dist/modules/picking/legacy-color-picking.d.ts +1 -1
  454. package/dist/modules/picking/legacy-picking-manager.cjs +92 -0
  455. package/dist/modules/picking/picking-manager.cjs +360 -0
  456. package/dist/modules/picking/picking-uniforms.cjs +140 -0
  457. package/dist/modules/picking/picking-uniforms.d.ts +1 -1
  458. package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
  459. package/dist/modules/picking/picking.cjs +43 -0
  460. package/dist/modules/picking/picking.d.ts +1 -1
  461. package/dist/passes/get-fragment-shader.cjs +119 -0
  462. package/dist/passes/shader-pass-renderer.cjs +722 -0
  463. package/dist/passes/shader-pass-renderer.d.ts +2 -2
  464. package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
  465. package/dist/passes/shader-pass-renderer.js +1 -1
  466. package/dist/passes/shader-pass-renderer.js.map +1 -1
  467. package/dist/passes/texture-transform-module.cjs +78 -0
  468. package/dist/scenegraph/controllers/area-light-controller.cjs +143 -0
  469. package/dist/scenegraph/controllers/area-light-controller.d.ts +31 -0
  470. package/dist/scenegraph/controllers/area-light-controller.d.ts.map +1 -0
  471. package/dist/scenegraph/controllers/area-light-controller.js +130 -0
  472. package/dist/scenegraph/controllers/area-light-controller.js.map +1 -0
  473. package/dist/scenegraph/controllers/billboard-controller.cjs +156 -0
  474. package/dist/scenegraph/controllers/billboard-controller.d.ts +45 -0
  475. package/dist/scenegraph/controllers/billboard-controller.d.ts.map +1 -0
  476. package/dist/scenegraph/controllers/billboard-controller.js +156 -0
  477. package/dist/scenegraph/controllers/billboard-controller.js.map +1 -0
  478. package/dist/scenegraph/controllers/joint-controller.cjs +71 -0
  479. package/dist/scenegraph/controllers/joint-controller.d.ts +30 -0
  480. package/dist/scenegraph/controllers/joint-controller.d.ts.map +1 -0
  481. package/dist/scenegraph/controllers/joint-controller.js +53 -0
  482. package/dist/scenegraph/controllers/joint-controller.js.map +1 -0
  483. package/dist/scenegraph/controllers/material-variants.cjs +61 -0
  484. package/dist/scenegraph/controllers/material-variants.d.ts +42 -0
  485. package/dist/scenegraph/controllers/material-variants.d.ts.map +1 -0
  486. package/dist/scenegraph/controllers/material-variants.js +40 -0
  487. package/dist/scenegraph/controllers/material-variants.js.map +1 -0
  488. package/dist/scenegraph/controllers/morph-controller.cjs +61 -0
  489. package/dist/scenegraph/controllers/morph-controller.d.ts +19 -0
  490. package/dist/scenegraph/controllers/morph-controller.d.ts.map +1 -0
  491. package/dist/scenegraph/controllers/morph-controller.js +41 -0
  492. package/dist/scenegraph/controllers/morph-controller.js.map +1 -0
  493. package/dist/scenegraph/controllers/skin-controller.cjs +111 -0
  494. package/dist/scenegraph/controllers/skin-controller.d.ts +36 -0
  495. package/dist/scenegraph/controllers/skin-controller.d.ts.map +1 -0
  496. package/dist/scenegraph/controllers/skin-controller.js +90 -0
  497. package/dist/scenegraph/controllers/skin-controller.js.map +1 -0
  498. package/dist/scenegraph/group-node.cjs +129 -0
  499. package/dist/scenegraph/model-node.cjs +68 -0
  500. package/dist/scenegraph/physics-transforms.cjs +95 -0
  501. package/dist/scenegraph/physics-transforms.d.ts +13 -0
  502. package/dist/scenegraph/physics-transforms.d.ts.map +1 -0
  503. package/dist/scenegraph/physics-transforms.js +72 -0
  504. package/dist/scenegraph/physics-transforms.js.map +1 -0
  505. package/dist/scenegraph/published-transforms.cjs +37 -0
  506. package/dist/scenegraph/published-transforms.d.ts +17 -0
  507. package/dist/scenegraph/published-transforms.d.ts.map +1 -0
  508. package/dist/scenegraph/published-transforms.js +16 -0
  509. package/dist/scenegraph/published-transforms.js.map +1 -0
  510. package/dist/scenegraph/scenegraph-bounds.cjs +51 -0
  511. package/dist/scenegraph/scenegraph-node.cjs +182 -0
  512. package/dist/shader-inputs.cjs +231 -0
  513. package/dist/shader-inputs.d.ts +1 -1
  514. package/dist/shader-inputs.d.ts.map +1 -1
  515. package/dist/utils/buffer-layout-helper.cjs +52 -0
  516. package/dist/utils/buffer-layout-order.cjs +37 -0
  517. package/dist/utils/deep-equal.cjs +65 -0
  518. package/dist/utils/get-platform-info.cjs +21 -0
  519. package/dist/utils/get-platform-info.d.ts +2 -0
  520. package/dist/utils/get-platform-info.d.ts.map +1 -0
  521. package/dist/utils/get-platform-info.js +5 -0
  522. package/dist/utils/get-platform-info.js.map +1 -0
  523. package/dist/utils/gpu-vector-batch-structure.cjs +45 -0
  524. package/dist/utils/gpu-vector-batch-structure.d.ts +12 -0
  525. package/dist/utils/gpu-vector-batch-structure.d.ts.map +1 -0
  526. package/dist/utils/gpu-vector-batch-structure.js +27 -0
  527. package/dist/utils/gpu-vector-batch-structure.js.map +1 -0
  528. package/dist/utils/shader-module-utils.cjs +148 -0
  529. package/dist/utils/uid.cjs +32 -0
  530. package/package.json +47 -8
  531. package/src/animation/deform-positions.ts +62 -0
  532. package/src/animation/node-animation-binding.ts +54 -0
  533. package/src/animation/property-animation-binding.ts +212 -0
  534. package/src/animation/scenegraph-animator.ts +117 -0
  535. package/src/animation/texture-transform.ts +59 -0
  536. package/src/animation-loop/animation-loop.ts +10 -3
  537. package/src/audio/audio-controller.ts +583 -0
  538. package/src/audio/audio-environment.ts +202 -0
  539. package/src/audio/audio-graph.ts +253 -0
  540. package/src/compute/buffer-transform.ts +71 -16
  541. package/src/compute/computation.ts +4 -19
  542. package/src/compute/texture-transform.ts +25 -12
  543. package/src/controls/orbit-controls.ts +4 -1
  544. package/src/dynamic-buffer/dynamic-buffer.ts +15 -449
  545. package/src/dynamic-texture/dynamic-texture.ts +5 -760
  546. package/src/dynamic-texture/texture-binding-source.ts +8 -90
  547. package/src/dynamic-texture/texture-data.ts +31 -340
  548. package/src/dynamic-texture/video-texture.ts +1 -1
  549. package/src/experimental/controls/comparison-splitter.ts +269 -0
  550. package/src/experimental/controls/flat-controller.ts +403 -0
  551. package/src/experimental/controls/index.ts +16 -0
  552. package/src/experimental/controls/orbit-controls.ts +6 -0
  553. package/src/experimental/materials/emissive-material.ts +120 -0
  554. package/src/experimental/materials/glass-material.ts +607 -0
  555. package/src/experimental/materials/glass-transmission.ts +1023 -0
  556. package/src/experimental/materials/index.ts +49 -0
  557. package/src/experimental/materials/optical-caustics.ts +234 -0
  558. package/src/experimental/materials/optical-lighting.ts +148 -0
  559. package/src/experimental/materials/optical-point-lights.ts +288 -0
  560. package/src/experimental/materials/reflective-material.ts +214 -0
  561. package/src/experimental/textures/html-texture.ts +285 -0
  562. package/src/experimental/textures/index.ts +8 -0
  563. package/src/experimental/textures/packed-pixels.ts +351 -0
  564. package/src/experimental/textures/rgba-decoder.ts +79 -0
  565. package/src/experimental/webxr/index.ts +21 -0
  566. package/src/experimental/webxr/webxr-animation-frame-provider.ts +22 -0
  567. package/src/experimental/webxr/webxr-camera-texture.ts +195 -0
  568. package/src/experimental/webxr/webxr-input.ts +117 -0
  569. package/src/experimental/webxr/webxr-manager.ts +524 -0
  570. package/src/experimental/webxr/webxr-types.ts +192 -0
  571. package/src/geometry/edge-geometry.ts +7 -3
  572. package/src/geometry/geometry-primitives.ts +226 -0
  573. package/src/geometry/geometry-utils.ts +16 -71
  574. package/src/geometry/geometry.ts +36 -163
  575. package/src/geometry/gpu-geometry.ts +9 -4
  576. package/src/geometry/gpu-vector-geometry-adapter.ts +78 -0
  577. package/src/geometry/gpu-vector-geometry.ts +33 -0
  578. package/src/geometry/ring-geometry.ts +117 -0
  579. package/src/graph/models/index.ts +45 -0
  580. package/src/graph/models/path/path-attribute-model.ts +563 -0
  581. package/src/graph/models/path/path-storage-model.ts +996 -0
  582. package/src/graph/models/path/path-trips-storage-model.ts +286 -0
  583. package/src/graph/models/polygon/polygon-attribute-model.ts +165 -0
  584. package/src/graph/models/polygon/polygon-shaders.ts +279 -0
  585. package/src/graph/models/polygon/polygon-storage-model.ts +146 -0
  586. package/src/graph/physics/index.ts +24 -0
  587. package/src/graph/physics/physics-scenegraph.ts +112 -0
  588. package/src/graph/physics/scenegraph-behaviors.ts +169 -0
  589. package/src/graph/physics/scenegraph-instance.ts +296 -0
  590. package/src/graph/physics/scenegraph-joints.ts +37 -0
  591. package/src/graph/physics/scenegraph-motion.ts +175 -0
  592. package/src/graph/physics/scenegraph-properties.ts +241 -0
  593. package/src/graph/physics/scenegraph-publication.ts +116 -0
  594. package/src/graph/physics/scenegraph-session.ts +317 -0
  595. package/src/graph/tables/gpu-table-geometry.ts +88 -0
  596. package/src/graph/tables/gpu-table-model.ts +661 -0
  597. package/src/graph/tables/gpu-table-transform.ts +497 -0
  598. package/src/graph/tables/index.ts +18 -0
  599. package/src/index.ts +144 -27
  600. package/src/interactivity/interactivity.ts +670 -0
  601. package/src/interactivity/physics.ts +19 -0
  602. package/src/material/material-factory.ts +1 -1
  603. package/src/material/material.ts +2 -2
  604. package/src/model/gpu-vector-bindings.ts +276 -0
  605. package/src/model/gpu-vector-draw-batches.ts +116 -0
  606. package/src/model/gpu-vector-model-batches.ts +142 -0
  607. package/src/model/gpu-vector-model.ts +1819 -0
  608. package/src/model/model.ts +91 -1444
  609. package/src/model/split-uniforms-and-bindings.ts +6 -3
  610. package/src/models/billboard-texture-model.ts +1 -1
  611. package/src/models/clip-space.ts +21 -14
  612. package/src/models/directional-light-model.ts +1 -1
  613. package/src/models/point-light-model.ts +1 -1
  614. package/src/models/spot-light-model.ts +1 -1
  615. package/src/modules/picking/legacy-picking-manager.ts +1 -1
  616. package/src/modules/picking/picking-uniforms.ts +1 -1
  617. package/src/passes/shader-pass-renderer.ts +2 -2
  618. package/src/scenegraph/controllers/area-light-controller.ts +152 -0
  619. package/src/scenegraph/controllers/billboard-controller.ts +204 -0
  620. package/src/scenegraph/controllers/joint-controller.ts +81 -0
  621. package/src/scenegraph/controllers/material-variants.ts +70 -0
  622. package/src/scenegraph/controllers/morph-controller.ts +61 -0
  623. package/src/scenegraph/controllers/skin-controller.ts +125 -0
  624. package/src/scenegraph/physics-transforms.ts +82 -0
  625. package/src/scenegraph/published-transforms.ts +18 -0
  626. package/src/shader-inputs.ts +1 -1
  627. package/src/utils/get-platform-info.ts +5 -0
  628. package/src/utils/gpu-vector-batch-structure.ts +36 -0
  629. package/dist/compute/kernel.d.ts +0 -54
  630. package/dist/compute/kernel.d.ts.map +0 -1
  631. package/dist/compute/kernel.js +0 -103
  632. package/dist/compute/kernel.js.map +0 -1
  633. package/dist/compute/render-kernel.d.ts +0 -65
  634. package/dist/compute/render-kernel.d.ts.map +0 -1
  635. package/dist/compute/render-kernel.js +0 -129
  636. package/dist/compute/render-kernel.js.map +0 -1
  637. package/dist/geometries/cone-geometry.d.ts +0 -12
  638. package/dist/geometries/cone-geometry.d.ts.map +0 -1
  639. package/dist/geometries/cone-geometry.js +0 -19
  640. package/dist/geometries/cone-geometry.js.map +0 -1
  641. package/dist/geometries/cube-geometry.d.ts +0 -14
  642. package/dist/geometries/cube-geometry.d.ts.map +0 -1
  643. package/dist/geometries/cube-geometry.js +0 -222
  644. package/dist/geometries/cube-geometry.js.map +0 -1
  645. package/dist/geometries/cylinder-geometry.d.ts +0 -11
  646. package/dist/geometries/cylinder-geometry.d.ts.map +0 -1
  647. package/dist/geometries/cylinder-geometry.js +0 -17
  648. package/dist/geometries/cylinder-geometry.js.map +0 -1
  649. package/dist/geometries/ico-sphere-geometry.d.ts +0 -11
  650. package/dist/geometries/ico-sphere-geometry.d.ts.map +0 -1
  651. package/dist/geometries/ico-sphere-geometry.js +0 -158
  652. package/dist/geometries/ico-sphere-geometry.js.map +0 -1
  653. package/dist/geometries/plane-geometry.d.ts +0 -20
  654. package/dist/geometries/plane-geometry.d.ts.map +0 -1
  655. package/dist/geometries/plane-geometry.js +0 -106
  656. package/dist/geometries/plane-geometry.js.map +0 -1
  657. package/dist/geometries/sphere-geometry.d.ts +0 -12
  658. package/dist/geometries/sphere-geometry.d.ts.map +0 -1
  659. package/dist/geometries/sphere-geometry.js +0 -88
  660. package/dist/geometries/sphere-geometry.js.map +0 -1
  661. package/dist/geometries/truncated-cone-geometry.d.ts +0 -23
  662. package/dist/geometries/truncated-cone-geometry.d.ts.map +0 -1
  663. package/dist/geometries/truncated-cone-geometry.js +0 -112
  664. package/dist/geometries/truncated-cone-geometry.js.map +0 -1
  665. package/src/compute/kernel.ts +0 -146
  666. package/src/compute/render-kernel.ts +0 -192
  667. package/src/geometries/cone-geometry.ts +0 -31
  668. package/src/geometries/cube-geometry.ts +0 -258
  669. package/src/geometries/cylinder-geometry.ts +0 -28
  670. package/src/geometries/ico-sphere-geometry.ts +0 -193
  671. package/src/geometries/plane-geometry.ts +0 -142
  672. package/src/geometries/sphere-geometry.ts +0 -113
  673. package/src/geometries/truncated-cone-geometry.ts +0 -145
@@ -0,0 +1,68 @@
1
+ import type { ShaderModule } from '@luma.gl/shadertools';
2
+ /** Maximum number of local lights carried by the portable fixed-size uniform block. */
3
+ export declare const MAX_OPTICAL_POINT_LIGHTS = 16;
4
+ /** Local colored light emitted from a world-space position. */
5
+ export type OpticalPointLight = {
6
+ /** Position in the same world-space coordinate system as the illuminated geometry. */
7
+ position: [number, number, number];
8
+ /** Linear RGB light color. */
9
+ color: [number, number, number];
10
+ /** Optional per-light intensity multiplier. */
11
+ intensity?: number;
12
+ /** World-space distance at which illumination falls smoothly to zero. */
13
+ radius?: number;
14
+ };
15
+ /** Runtime properties for a bounded set of local optical lights. */
16
+ export type OpticalPointLightsProps = {
17
+ /** Active local lights; additional lights beyond the fixed capacity are ignored. */
18
+ lights?: readonly OpticalPointLight[];
19
+ /** Multiplier applied to the complete set of lights. */
20
+ intensity?: number;
21
+ };
22
+ /** One packed entry in the cross-backend optical-light uniform array. */
23
+ export type OpticalPointLightUniform = {
24
+ position: [number, number, number];
25
+ radius: number;
26
+ color: [number, number, number];
27
+ intensity: number;
28
+ };
29
+ /** Uniform values consumed by {@link opticalPointLights}. */
30
+ export type OpticalPointLightsUniforms = {
31
+ lightCount: number;
32
+ intensity: number;
33
+ lights: readonly OpticalPointLightUniform[];
34
+ };
35
+ declare function getOpticalPointLightsUniforms(props?: Partial<OpticalPointLightsProps>, previousUniforms?: OpticalPointLightsUniforms): OpticalPointLightsUniforms;
36
+ /** Portable bounded point lights for glass and reflective optical materials. */
37
+ export declare const opticalPointLights: {
38
+ readonly name: "opticalPointLights";
39
+ readonly source: "struct OpticalPointLightUniform {\n position: vec3<f32>,\n radius: f32,\n color: vec3<f32>,\n intensity: f32,\n};\n\nstruct opticalPointLightsUniforms {\n lightCount: i32,\n intensity: f32,\n lights: array<OpticalPointLightUniform, 16>,\n};\n\n@group(0) @binding(auto) var<uniform> opticalPointLights: opticalPointLightsUniforms;\n\nfn opticalPointLights_getColor(\n normal: vec3<f32>,\n worldPosition: vec3<f32>,\n cameraPosition: vec3<f32>\n) -> vec3<f32> {\n let viewDirection = normalize(cameraPosition - worldPosition);\n let normalFacingCamera = opticalLighting_faceNormal(normalize(normal), viewDirection);\n var accumulatedColor = vec3<f32>(0.0);\n\n for (var lightIndex = 0; lightIndex < 16; lightIndex++) {\n if (lightIndex >= opticalPointLights.lightCount) {\n break;\n }\n\n let light = opticalPointLights.lights[lightIndex];\n let lightOffset = light.position - worldPosition;\n let distanceSquared = dot(lightOffset, lightOffset);\n let radius = max(light.radius, 0.0001);\n let normalizedDistance = clamp(sqrt(distanceSquared) / radius, 0.0, 1.0);\n let attenuation = pow(1.0 - normalizedDistance * normalizedDistance, 2.0);\n let lightDirection = lightOffset * inverseSqrt(max(distanceSquared, 0.00001));\n let halfVector = normalize(lightDirection + viewDirection + vec3<f32>(0.00001));\n let diffuse = max(dot(normalFacingCamera, lightDirection), 0.0);\n let specular = pow(max(dot(normalFacingCamera, halfVector), 0.0), 28.0);\n let surfaceResponse = 0.08 + diffuse * 0.52 + specular * 0.4;\n accumulatedColor += light.color * light.intensity * attenuation * surfaceResponse;\n }\n\n return accumulatedColor * opticalPointLights.intensity;\n}\n\nfn opticalPointLights_getSpecularColor(\n normal: vec3<f32>,\n worldPosition: vec3<f32>,\n cameraPosition: vec3<f32>,\n roughness: f32\n) -> vec3<f32> {\n let viewDirection = normalize(cameraPosition - worldPosition);\n let normalFacingCamera = opticalLighting_faceNormal(normalize(normal), viewDirection);\n let shininess = mix(118.0, 34.0, clamp(roughness, 0.0, 1.0));\n let fresnel = opticalLighting_getFresnel(\n clamp(dot(normalFacingCamera, viewDirection), 0.0, 1.0),\n 0.04,\n 5.0\n );\n var accumulatedColor = vec3<f32>(0.0);\n\n for (var lightIndex = 0; lightIndex < 16; lightIndex++) {\n if (lightIndex >= opticalPointLights.lightCount) {\n break;\n }\n\n let light = opticalPointLights.lights[lightIndex];\n let lightOffset = light.position - worldPosition;\n let distanceSquared = dot(lightOffset, lightOffset);\n let radius = max(light.radius, 0.0001);\n let normalizedDistance = clamp(sqrt(distanceSquared) / radius, 0.0, 1.0);\n let attenuation = pow(1.0 - normalizedDistance * normalizedDistance, 2.0);\n let lightDirection = lightOffset * inverseSqrt(max(distanceSquared, 0.00001));\n let reflectionDirection = reflect(-viewDirection, normalFacingCamera);\n let reflectionAlignment = max(dot(reflectionDirection, lightDirection), 0.0);\n let specular = pow(reflectionAlignment, shininess);\n let softSpecular = pow(reflectionAlignment, max(shininess * 0.34, 10.0)) * 0.045;\n accumulatedColor += light.color * light.intensity * attenuation *\n (specular * 1.45 + softSpecular) *\n (0.35 + fresnel * 1.65);\n }\n\n return accumulatedColor * opticalPointLights.intensity;\n}\n";
40
+ readonly fs: "struct OpticalPointLightUniform {\n vec3 position;\n float radius;\n vec3 color;\n float intensity;\n};\n\nlayout(std140) uniform opticalPointLightsUniforms {\n int lightCount;\n float intensity;\n OpticalPointLightUniform lights[16];\n} opticalPointLights;\n\nvec3 opticalPointLights_getColor(\n vec3 normal,\n vec3 worldPosition,\n vec3 cameraPosition\n) {\n vec3 viewDirection = normalize(cameraPosition - worldPosition);\n vec3 normalFacingCamera = opticalLighting_faceNormal(normalize(normal), viewDirection);\n vec3 accumulatedColor = vec3(0.0);\n\n for (int lightIndex = 0; lightIndex < 16; lightIndex++) {\n if (lightIndex >= opticalPointLights.lightCount) {\n break;\n }\n\n OpticalPointLightUniform light = opticalPointLights.lights[lightIndex];\n vec3 lightOffset = light.position - worldPosition;\n float distanceSquared = dot(lightOffset, lightOffset);\n float radius = max(light.radius, 0.0001);\n float normalizedDistance = clamp(sqrt(distanceSquared) / radius, 0.0, 1.0);\n float attenuation = pow(1.0 - normalizedDistance * normalizedDistance, 2.0);\n vec3 lightDirection = lightOffset * inversesqrt(max(distanceSquared, 0.00001));\n vec3 halfVector = normalize(lightDirection + viewDirection + vec3(0.00001));\n float diffuse = max(dot(normalFacingCamera, lightDirection), 0.0);\n float specular = pow(max(dot(normalFacingCamera, halfVector), 0.0), 28.0);\n float surfaceResponse = 0.08 + diffuse * 0.52 + specular * 0.4;\n accumulatedColor += light.color * light.intensity * attenuation * surfaceResponse;\n }\n\n return accumulatedColor * opticalPointLights.intensity;\n}\n\nvec3 opticalPointLights_getSpecularColor(\n vec3 normal,\n vec3 worldPosition,\n vec3 cameraPosition,\n float roughness\n) {\n vec3 viewDirection = normalize(cameraPosition - worldPosition);\n vec3 normalFacingCamera = opticalLighting_faceNormal(normalize(normal), viewDirection);\n float shininess = mix(118.0, 34.0, clamp(roughness, 0.0, 1.0));\n float fresnel = opticalLighting_getFresnel(\n clamp(dot(normalFacingCamera, viewDirection), 0.0, 1.0),\n 0.04,\n 5.0\n );\n vec3 accumulatedColor = vec3(0.0);\n\n for (int lightIndex = 0; lightIndex < 16; lightIndex++) {\n if (lightIndex >= opticalPointLights.lightCount) {\n break;\n }\n\n OpticalPointLightUniform light = opticalPointLights.lights[lightIndex];\n vec3 lightOffset = light.position - worldPosition;\n float distanceSquared = dot(lightOffset, lightOffset);\n float radius = max(light.radius, 0.0001);\n float normalizedDistance = clamp(sqrt(distanceSquared) / radius, 0.0, 1.0);\n float attenuation = pow(1.0 - normalizedDistance * normalizedDistance, 2.0);\n vec3 lightDirection = lightOffset * inversesqrt(max(distanceSquared, 0.00001));\n vec3 reflectionDirection = reflect(-viewDirection, normalFacingCamera);\n float reflectionAlignment = max(dot(reflectionDirection, lightDirection), 0.0);\n float specular = pow(reflectionAlignment, shininess);\n float softSpecular = pow(reflectionAlignment, max(shininess * 0.34, 10.0)) * 0.045;\n accumulatedColor += light.color * light.intensity * attenuation *\n (specular * 1.45 + softSpecular) *\n (0.35 + fresnel * 1.65);\n }\n\n return accumulatedColor * opticalPointLights.intensity;\n}\n";
41
+ readonly defines: {
42
+ readonly LUMA_OPTICAL_POINT_LIGHTS: true;
43
+ };
44
+ readonly dependencies: [{
45
+ readonly name: "opticalLighting";
46
+ readonly source: "fn opticalLighting_faceNormal(normal: vec3<f32>, viewDirection: vec3<f32>) -> vec3<f32> {\n return select(-normal, normal, dot(normal, viewDirection) >= 0.0);\n}\n\nfn opticalLighting_getFresnel(\n viewAlignment: f32,\n baseReflectance: f32,\n exponent: f32\n) -> f32 {\n return baseReflectance + (1.0 - baseReflectance) *\n pow(1.0 - clamp(viewAlignment, 0.0, 1.0), exponent);\n}\n\nfn opticalLighting_getFilteredRoughness(normal: vec3<f32>, roughness: f32) -> f32 {\n let normalDerivativeX = dpdx(normal);\n let normalDerivativeY = dpdy(normal);\n let normalVariance = dot(normalDerivativeX, normalDerivativeX) +\n dot(normalDerivativeY, normalDerivativeY);\n let kernelRoughnessSquared = min(2.0 * normalVariance, 1.0);\n return clamp(sqrt(roughness * roughness + kernelRoughnessSquared), 0.04, 1.0);\n}\n\nfn opticalLighting_getMicrofacetSpecular(\n normal: vec3<f32>,\n viewDirection: vec3<f32>,\n lightDirection: vec3<f32>,\n roughness: f32\n) -> f32 {\n let halfDirection = normalize(viewDirection + lightDirection);\n let normalAlignment = max(dot(normal, viewDirection), 0.001);\n let lightAlignment = max(dot(normal, lightDirection), 0.0);\n let halfAlignment = max(dot(normal, halfDirection), 0.0);\n let alpha = max(roughness * roughness, 0.045);\n let alphaSquared = alpha * alpha;\n let distributionDenominator = halfAlignment * halfAlignment * (alphaSquared - 1.0) + 1.0;\n let distribution = alphaSquared /\n max(3.14159265 * distributionDenominator * distributionDenominator, 0.001);\n let visibilityFactor = pow(roughness + 1.0, 2.0) * 0.125;\n let viewVisibility = normalAlignment /\n (normalAlignment * (1.0 - visibilityFactor) + visibilityFactor);\n let lightVisibility = lightAlignment /\n (lightAlignment * (1.0 - visibilityFactor) + visibilityFactor);\n return distribution * viewVisibility * lightVisibility * lightAlignment /\n max(4.0 * normalAlignment * lightAlignment, 0.001);\n}\n\nfn opticalLighting_getKeyLight() -> vec3<f32> {\n return normalize(vec3<f32>(-0.45, 0.82, 0.34));\n}\n\nfn opticalLighting_getFillLight() -> vec3<f32> {\n return normalize(vec3<f32>(0.62, 0.35, -0.7));\n}\n\nfn opticalLighting_sampleEnvironment(\n reflectionDirection: vec3<f32>,\n shadowColor: vec3<f32>,\n highlightColor: vec3<f32>,\n horizonStrength: f32\n) -> vec3<f32> {\n let horizon = pow(1.0 - abs(reflectionDirection.y), 4.0);\n return mix(\n shadowColor,\n highlightColor,\n clamp(reflectionDirection.y * 0.5 + 0.5 + horizon * horizonStrength, 0.0, 1.0)\n );\n}\n";
47
+ readonly fs: "vec3 opticalLighting_faceNormal(vec3 normal, vec3 viewDirection) {\n return dot(normal, viewDirection) >= 0.0 ? normal : -normal;\n}\n\nfloat opticalLighting_getFresnel(float viewAlignment, float baseReflectance, float exponent) {\n return baseReflectance + (1.0 - baseReflectance) *\n pow(1.0 - clamp(viewAlignment, 0.0, 1.0), exponent);\n}\n\nfloat opticalLighting_getFilteredRoughness(vec3 normal, float roughness) {\n vec3 normalDerivativeX = dFdx(normal);\n vec3 normalDerivativeY = dFdy(normal);\n float normalVariance = dot(normalDerivativeX, normalDerivativeX) +\n dot(normalDerivativeY, normalDerivativeY);\n float kernelRoughnessSquared = min(2.0 * normalVariance, 1.0);\n return clamp(sqrt(roughness * roughness + kernelRoughnessSquared), 0.04, 1.0);\n}\n\nfloat opticalLighting_getMicrofacetSpecular(\n vec3 normal,\n vec3 viewDirection,\n vec3 lightDirection,\n float roughness\n) {\n vec3 halfDirection = normalize(viewDirection + lightDirection);\n float normalAlignment = max(dot(normal, viewDirection), 0.001);\n float lightAlignment = max(dot(normal, lightDirection), 0.0);\n float halfAlignment = max(dot(normal, halfDirection), 0.0);\n float alpha = max(roughness * roughness, 0.045);\n float alphaSquared = alpha * alpha;\n float distributionDenominator = halfAlignment * halfAlignment * (alphaSquared - 1.0) + 1.0;\n float distribution = alphaSquared /\n max(3.14159265 * distributionDenominator * distributionDenominator, 0.001);\n float visibilityFactor = pow(roughness + 1.0, 2.0) * 0.125;\n float viewVisibility = normalAlignment /\n (normalAlignment * (1.0 - visibilityFactor) + visibilityFactor);\n float lightVisibility = lightAlignment /\n (lightAlignment * (1.0 - visibilityFactor) + visibilityFactor);\n return distribution * viewVisibility * lightVisibility * lightAlignment /\n max(4.0 * normalAlignment * lightAlignment, 0.001);\n}\n\nvec3 opticalLighting_getKeyLight() {\n return normalize(vec3(-0.45, 0.82, 0.34));\n}\n\nvec3 opticalLighting_getFillLight() {\n return normalize(vec3(0.62, 0.35, -0.7));\n}\n\nvec3 opticalLighting_sampleEnvironment(\n vec3 reflectionDirection,\n vec3 shadowColor,\n vec3 highlightColor,\n float horizonStrength\n) {\n float horizon = pow(1.0 - abs(reflectionDirection.y), 4.0);\n return mix(\n shadowColor,\n highlightColor,\n clamp(reflectionDirection.y * 0.5 + 0.5 + horizon * horizonStrength, 0.0, 1.0)\n );\n}\n";
48
+ }];
49
+ readonly uniformTypes: {
50
+ readonly lightCount: "i32";
51
+ readonly intensity: "f32";
52
+ readonly lights: readonly [{
53
+ readonly position: "vec3<f32>";
54
+ readonly radius: "f32";
55
+ readonly color: "vec3<f32>";
56
+ readonly intensity: "f32";
57
+ }, 16];
58
+ };
59
+ readonly defaultUniforms: OpticalPointLightsUniforms;
60
+ readonly getUniforms: typeof getOpticalPointLightsUniforms;
61
+ };
62
+ /** Explicitly installs bounded point lights and enables illuminated material helpers. */
63
+ export declare const opticalPointLightsPlugin: {
64
+ readonly name: "opticalPointLights";
65
+ readonly modules: [ShaderModule];
66
+ };
67
+ export {};
68
+ //# sourceMappingURL=optical-point-lights.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optical-point-lights.d.ts","sourceRoot":"","sources":["../../../src/experimental/materials/optical-point-lights.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAe,MAAM,sBAAsB,CAAC;AAGrE,uFAAuF;AACvF,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,+DAA+D;AAC/D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,sFAAsF;IACtF,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,8BAA8B;IAC9B,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oEAAoE;AACpE,MAAM,MAAM,uBAAuB,GAAG;IACpC,oFAAoF;IACpF,MAAM,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtC,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,yEAAyE;AACzE,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,wBAAwB,EAAE,CAAC;CAC7C,CAAC;AAuLF,iBAAS,6BAA6B,CACpC,KAAK,GAAE,OAAO,CAAC,uBAAuB,CAAM,EAC5C,gBAAgB,CAAC,EAAE,0BAA0B,GAC5C,0BAA0B,CAY5B;AAwBD,gFAAgF;AAChF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;CAe2D,CAAC;AAE3F,yFAAyF;AACzF,eAAO,MAAM,wBAAwB;;;CAGJ,CAAC"}
@@ -0,0 +1,237 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { opticalLighting } from "./optical-lighting.js";
5
+ /** Maximum number of local lights carried by the portable fixed-size uniform block. */
6
+ export const MAX_OPTICAL_POINT_LIGHTS = 16;
7
+ const OPTICAL_POINT_LIGHT_UNIFORM_TYPE = {
8
+ position: 'vec3<f32>',
9
+ radius: 'f32',
10
+ color: 'vec3<f32>',
11
+ intensity: 'f32'
12
+ };
13
+ const OPTICAL_POINT_LIGHTS_WGSL = /* wgsl */ `\
14
+ struct OpticalPointLightUniform {
15
+ position: vec3<f32>,
16
+ radius: f32,
17
+ color: vec3<f32>,
18
+ intensity: f32,
19
+ };
20
+
21
+ struct opticalPointLightsUniforms {
22
+ lightCount: i32,
23
+ intensity: f32,
24
+ lights: array<OpticalPointLightUniform, ${MAX_OPTICAL_POINT_LIGHTS}>,
25
+ };
26
+
27
+ @group(0) @binding(auto) var<uniform> opticalPointLights: opticalPointLightsUniforms;
28
+
29
+ fn opticalPointLights_getColor(
30
+ normal: vec3<f32>,
31
+ worldPosition: vec3<f32>,
32
+ cameraPosition: vec3<f32>
33
+ ) -> vec3<f32> {
34
+ let viewDirection = normalize(cameraPosition - worldPosition);
35
+ let normalFacingCamera = opticalLighting_faceNormal(normalize(normal), viewDirection);
36
+ var accumulatedColor = vec3<f32>(0.0);
37
+
38
+ for (var lightIndex = 0; lightIndex < ${MAX_OPTICAL_POINT_LIGHTS}; lightIndex++) {
39
+ if (lightIndex >= opticalPointLights.lightCount) {
40
+ break;
41
+ }
42
+
43
+ let light = opticalPointLights.lights[lightIndex];
44
+ let lightOffset = light.position - worldPosition;
45
+ let distanceSquared = dot(lightOffset, lightOffset);
46
+ let radius = max(light.radius, 0.0001);
47
+ let normalizedDistance = clamp(sqrt(distanceSquared) / radius, 0.0, 1.0);
48
+ let attenuation = pow(1.0 - normalizedDistance * normalizedDistance, 2.0);
49
+ let lightDirection = lightOffset * inverseSqrt(max(distanceSquared, 0.00001));
50
+ let halfVector = normalize(lightDirection + viewDirection + vec3<f32>(0.00001));
51
+ let diffuse = max(dot(normalFacingCamera, lightDirection), 0.0);
52
+ let specular = pow(max(dot(normalFacingCamera, halfVector), 0.0), 28.0);
53
+ let surfaceResponse = 0.08 + diffuse * 0.52 + specular * 0.4;
54
+ accumulatedColor += light.color * light.intensity * attenuation * surfaceResponse;
55
+ }
56
+
57
+ return accumulatedColor * opticalPointLights.intensity;
58
+ }
59
+
60
+ fn opticalPointLights_getSpecularColor(
61
+ normal: vec3<f32>,
62
+ worldPosition: vec3<f32>,
63
+ cameraPosition: vec3<f32>,
64
+ roughness: f32
65
+ ) -> vec3<f32> {
66
+ let viewDirection = normalize(cameraPosition - worldPosition);
67
+ let normalFacingCamera = opticalLighting_faceNormal(normalize(normal), viewDirection);
68
+ let shininess = mix(118.0, 34.0, clamp(roughness, 0.0, 1.0));
69
+ let fresnel = opticalLighting_getFresnel(
70
+ clamp(dot(normalFacingCamera, viewDirection), 0.0, 1.0),
71
+ 0.04,
72
+ 5.0
73
+ );
74
+ var accumulatedColor = vec3<f32>(0.0);
75
+
76
+ for (var lightIndex = 0; lightIndex < ${MAX_OPTICAL_POINT_LIGHTS}; lightIndex++) {
77
+ if (lightIndex >= opticalPointLights.lightCount) {
78
+ break;
79
+ }
80
+
81
+ let light = opticalPointLights.lights[lightIndex];
82
+ let lightOffset = light.position - worldPosition;
83
+ let distanceSquared = dot(lightOffset, lightOffset);
84
+ let radius = max(light.radius, 0.0001);
85
+ let normalizedDistance = clamp(sqrt(distanceSquared) / radius, 0.0, 1.0);
86
+ let attenuation = pow(1.0 - normalizedDistance * normalizedDistance, 2.0);
87
+ let lightDirection = lightOffset * inverseSqrt(max(distanceSquared, 0.00001));
88
+ let reflectionDirection = reflect(-viewDirection, normalFacingCamera);
89
+ let reflectionAlignment = max(dot(reflectionDirection, lightDirection), 0.0);
90
+ let specular = pow(reflectionAlignment, shininess);
91
+ let softSpecular = pow(reflectionAlignment, max(shininess * 0.34, 10.0)) * 0.045;
92
+ accumulatedColor += light.color * light.intensity * attenuation *
93
+ (specular * 1.45 + softSpecular) *
94
+ (0.35 + fresnel * 1.65);
95
+ }
96
+
97
+ return accumulatedColor * opticalPointLights.intensity;
98
+ }
99
+ `;
100
+ const OPTICAL_POINT_LIGHTS_GLSL = /* glsl */ `\
101
+ struct OpticalPointLightUniform {
102
+ vec3 position;
103
+ float radius;
104
+ vec3 color;
105
+ float intensity;
106
+ };
107
+
108
+ layout(std140) uniform opticalPointLightsUniforms {
109
+ int lightCount;
110
+ float intensity;
111
+ OpticalPointLightUniform lights[${MAX_OPTICAL_POINT_LIGHTS}];
112
+ } opticalPointLights;
113
+
114
+ vec3 opticalPointLights_getColor(
115
+ vec3 normal,
116
+ vec3 worldPosition,
117
+ vec3 cameraPosition
118
+ ) {
119
+ vec3 viewDirection = normalize(cameraPosition - worldPosition);
120
+ vec3 normalFacingCamera = opticalLighting_faceNormal(normalize(normal), viewDirection);
121
+ vec3 accumulatedColor = vec3(0.0);
122
+
123
+ for (int lightIndex = 0; lightIndex < ${MAX_OPTICAL_POINT_LIGHTS}; lightIndex++) {
124
+ if (lightIndex >= opticalPointLights.lightCount) {
125
+ break;
126
+ }
127
+
128
+ OpticalPointLightUniform light = opticalPointLights.lights[lightIndex];
129
+ vec3 lightOffset = light.position - worldPosition;
130
+ float distanceSquared = dot(lightOffset, lightOffset);
131
+ float radius = max(light.radius, 0.0001);
132
+ float normalizedDistance = clamp(sqrt(distanceSquared) / radius, 0.0, 1.0);
133
+ float attenuation = pow(1.0 - normalizedDistance * normalizedDistance, 2.0);
134
+ vec3 lightDirection = lightOffset * inversesqrt(max(distanceSquared, 0.00001));
135
+ vec3 halfVector = normalize(lightDirection + viewDirection + vec3(0.00001));
136
+ float diffuse = max(dot(normalFacingCamera, lightDirection), 0.0);
137
+ float specular = pow(max(dot(normalFacingCamera, halfVector), 0.0), 28.0);
138
+ float surfaceResponse = 0.08 + diffuse * 0.52 + specular * 0.4;
139
+ accumulatedColor += light.color * light.intensity * attenuation * surfaceResponse;
140
+ }
141
+
142
+ return accumulatedColor * opticalPointLights.intensity;
143
+ }
144
+
145
+ vec3 opticalPointLights_getSpecularColor(
146
+ vec3 normal,
147
+ vec3 worldPosition,
148
+ vec3 cameraPosition,
149
+ float roughness
150
+ ) {
151
+ vec3 viewDirection = normalize(cameraPosition - worldPosition);
152
+ vec3 normalFacingCamera = opticalLighting_faceNormal(normalize(normal), viewDirection);
153
+ float shininess = mix(118.0, 34.0, clamp(roughness, 0.0, 1.0));
154
+ float fresnel = opticalLighting_getFresnel(
155
+ clamp(dot(normalFacingCamera, viewDirection), 0.0, 1.0),
156
+ 0.04,
157
+ 5.0
158
+ );
159
+ vec3 accumulatedColor = vec3(0.0);
160
+
161
+ for (int lightIndex = 0; lightIndex < ${MAX_OPTICAL_POINT_LIGHTS}; lightIndex++) {
162
+ if (lightIndex >= opticalPointLights.lightCount) {
163
+ break;
164
+ }
165
+
166
+ OpticalPointLightUniform light = opticalPointLights.lights[lightIndex];
167
+ vec3 lightOffset = light.position - worldPosition;
168
+ float distanceSquared = dot(lightOffset, lightOffset);
169
+ float radius = max(light.radius, 0.0001);
170
+ float normalizedDistance = clamp(sqrt(distanceSquared) / radius, 0.0, 1.0);
171
+ float attenuation = pow(1.0 - normalizedDistance * normalizedDistance, 2.0);
172
+ vec3 lightDirection = lightOffset * inversesqrt(max(distanceSquared, 0.00001));
173
+ vec3 reflectionDirection = reflect(-viewDirection, normalFacingCamera);
174
+ float reflectionAlignment = max(dot(reflectionDirection, lightDirection), 0.0);
175
+ float specular = pow(reflectionAlignment, shininess);
176
+ float softSpecular = pow(reflectionAlignment, max(shininess * 0.34, 10.0)) * 0.045;
177
+ accumulatedColor += light.color * light.intensity * attenuation *
178
+ (specular * 1.45 + softSpecular) *
179
+ (0.35 + fresnel * 1.65);
180
+ }
181
+
182
+ return accumulatedColor * opticalPointLights.intensity;
183
+ }
184
+ `;
185
+ function getOpticalPointLightsUniforms(props = {}, previousUniforms) {
186
+ const suppliedLights = props.lights;
187
+ return {
188
+ lightCount: suppliedLights
189
+ ? Math.min(suppliedLights.length, MAX_OPTICAL_POINT_LIGHTS)
190
+ : (previousUniforms?.lightCount ?? 0),
191
+ intensity: props.intensity ?? previousUniforms?.intensity ?? 1,
192
+ lights: suppliedLights
193
+ ? makeOpticalPointLightUniforms(suppliedLights)
194
+ : (previousUniforms?.lights ?? makeOpticalPointLightUniforms([]))
195
+ };
196
+ }
197
+ function makeOpticalPointLightUniforms(lights) {
198
+ return Array.from({ length: MAX_OPTICAL_POINT_LIGHTS }, (_, lightIndex) => {
199
+ const light = lights[lightIndex];
200
+ return light
201
+ ? {
202
+ position: light.position,
203
+ radius: light.radius ?? 1,
204
+ color: light.color,
205
+ intensity: light.intensity ?? 1
206
+ }
207
+ : {
208
+ position: [0, 0, 0],
209
+ radius: 1,
210
+ color: [0, 0, 0],
211
+ intensity: 0
212
+ };
213
+ });
214
+ }
215
+ /** Portable bounded point lights for glass and reflective optical materials. */
216
+ export const opticalPointLights = {
217
+ name: 'opticalPointLights',
218
+ source: OPTICAL_POINT_LIGHTS_WGSL,
219
+ fs: OPTICAL_POINT_LIGHTS_GLSL,
220
+ defines: {
221
+ LUMA_OPTICAL_POINT_LIGHTS: true
222
+ },
223
+ dependencies: [opticalLighting],
224
+ uniformTypes: {
225
+ lightCount: 'i32',
226
+ intensity: 'f32',
227
+ lights: [OPTICAL_POINT_LIGHT_UNIFORM_TYPE, MAX_OPTICAL_POINT_LIGHTS]
228
+ },
229
+ defaultUniforms: getOpticalPointLightsUniforms(),
230
+ getUniforms: getOpticalPointLightsUniforms
231
+ };
232
+ /** Explicitly installs bounded point lights and enables illuminated material helpers. */
233
+ export const opticalPointLightsPlugin = {
234
+ name: 'opticalPointLights',
235
+ modules: [opticalPointLights]
236
+ };
237
+ //# sourceMappingURL=optical-point-lights.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optical-point-lights.js","sourceRoot":"","sources":["../../../src/experimental/materials/optical-point-lights.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAG5D,OAAO,EAAC,eAAe,EAAC,8BAA2B;AAEnD,uFAAuF;AACvF,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAqC3C,MAAM,gCAAgC,GAAG;IACvC,QAAQ,EAAE,WAAW;IACrB,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,WAAW;IAClB,SAAS,EAAE,KAAK;CACR,CAAC;AAEX,MAAM,yBAAyB,GAAG,UAAU,CAAC;;;;;;;;;;;4CAWD,wBAAwB;;;;;;;;;;;;;;0CAc1B,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0CAsCxB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;CAuBjE,CAAC;AAEF,MAAM,yBAAyB,GAAG,UAAU,CAAC;;;;;;;;;;;oCAWT,wBAAwB;;;;;;;;;;;;0CAYlB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0CAsCxB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;CAuBjE,CAAC;AAEF,SAAS,6BAA6B,CACpC,QAA0C,EAAE,EAC5C,gBAA6C;IAE7C,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC;IAEpC,OAAO;QACL,UAAU,EAAE,cAAc;YACxB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,wBAAwB,CAAC;YAC3D,CAAC,CAAC,CAAC,gBAAgB,EAAE,UAAU,IAAI,CAAC,CAAC;QACvC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,gBAAgB,EAAE,SAAS,IAAI,CAAC;QAC9D,MAAM,EAAE,cAAc;YACpB,CAAC,CAAC,6BAA6B,CAAC,cAAc,CAAC;YAC/C,CAAC,CAAC,CAAC,gBAAgB,EAAE,MAAM,IAAI,6BAA6B,CAAC,EAAE,CAAC,CAAC;KACpE,CAAC;AACJ,CAAC;AAED,SAAS,6BAA6B,CACpC,MAAoC;IAEpC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,wBAAwB,EAAC,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE;QACtE,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QAEjC,OAAO,KAAK;YACV,CAAC,CAAC;gBACE,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC;gBACzB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,CAAC;aAChC;YACH,CAAC,CAAC;gBACE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACnB,MAAM,EAAE,CAAC;gBACT,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBAChB,SAAS,EAAE,CAAC;aACb,CAAC;IACR,CAAC,CAAC,CAAC;AACL,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,oBAAoB;IAC1B,MAAM,EAAE,yBAAyB;IACjC,EAAE,EAAE,yBAAyB;IAC7B,OAAO,EAAE;QACP,yBAAyB,EAAE,IAAI;KAChC;IACD,YAAY,EAAE,CAAC,eAAe,CAAC;IAC/B,YAAY,EAAE;QACZ,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,CAAC,gCAAgC,EAAE,wBAAwB,CAAC;KACrE;IACD,eAAe,EAAE,6BAA6B,EAAE;IAChD,WAAW,EAAE,6BAA6B;CAC8C,CAAC;AAE3F,yFAAyF;AACzF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,IAAI,EAAE,oBAAoB;IAC1B,OAAO,EAAE,CAAC,kBAAkC,CAAC;CACd,CAAC"}
@@ -0,0 +1,216 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var reflective_material_exports = {};
19
+ __export(reflective_material_exports, {
20
+ reflectiveMaterial: () => reflectiveMaterial,
21
+ reflectiveMaterialPlugin: () => reflectiveMaterialPlugin
22
+ });
23
+ module.exports = __toCommonJS(reflective_material_exports);
24
+ var import_optical_lighting = require("./optical-lighting.cjs");
25
+ const REFLECTIVE_MATERIAL_WGSL = (
26
+ /* wgsl */
27
+ `struct ReflectiveMaterialUniforms {
28
+ roughness: f32,
29
+ reflectionStrength: f32,
30
+ specularStrength: f32,
31
+ opacityScale: f32,
32
+ };
33
+
34
+ @group(0) @binding(auto) var<uniform> reflectiveMaterial: ReflectiveMaterialUniforms;
35
+
36
+ fn reflectiveMaterial_getColor(
37
+ normal: vec3<f32>,
38
+ worldPosition: vec3<f32>,
39
+ baseColor: vec4<f32>,
40
+ cameraPosition: vec3<f32>
41
+ ) -> vec4<f32> {
42
+ let viewDirection = normalize(cameraPosition - worldPosition);
43
+ let normalFacingCamera = opticalLighting_faceNormal(normalize(normal), viewDirection);
44
+ let viewAlignment = clamp(dot(normalFacingCamera, viewDirection), 0.0, 1.0);
45
+ let fresnel = opticalLighting_getFresnel(viewAlignment, 0.08, 4.0);
46
+ let keyLight = opticalLighting_getKeyLight();
47
+ let fillLight = opticalLighting_getFillLight();
48
+ let keyHalfVector = normalize(keyLight + viewDirection);
49
+ let fillHalfVector = normalize(fillLight + viewDirection);
50
+ let diffuse = 0.36 + 0.64 * max(dot(normalFacingCamera, keyLight), 0.0);
51
+ let filteredRoughness = opticalLighting_getFilteredRoughness(
52
+ normalFacingCamera,
53
+ reflectiveMaterial.roughness
54
+ );
55
+ let specularExponent = mix(96.0, 12.0, filteredRoughness);
56
+ let keySpecular = pow(max(dot(normalFacingCamera, keyHalfVector), 0.0), specularExponent);
57
+ let fillSpecular = pow(
58
+ max(dot(normalFacingCamera, fillHalfVector), 0.0),
59
+ specularExponent * 0.545
60
+ );
61
+ let reflectionDirection = reflect(-viewDirection, normalFacingCamera);
62
+ let reflectedColor = opticalLighting_sampleEnvironment(
63
+ reflectionDirection,
64
+ vec3<f32>(0.08, 0.14, 0.25),
65
+ vec3<f32>(0.52, 0.7, 0.95),
66
+ 0.0
67
+ );
68
+ let color = baseColor.rgb * diffuse +
69
+ reflectedColor * fresnel * reflectiveMaterial.reflectionStrength +
70
+ vec3<f32>(1.0, 0.94, 0.8) * keySpecular * reflectiveMaterial.specularStrength +
71
+ vec3<f32>(0.4, 0.67, 1.0) * fillSpecular * reflectiveMaterial.specularStrength * 0.524;
72
+ let opacity = clamp(
73
+ baseColor.a * reflectiveMaterial.opacityScale *
74
+ (0.85 + fresnel * 0.2 + (keySpecular + fillSpecular) * 0.35),
75
+ 0.0,
76
+ 1.0
77
+ );
78
+ return vec4<f32>(color, opacity);
79
+ }
80
+
81
+ #ifdef LUMA_OPTICAL_POINT_LIGHTS
82
+ fn reflectiveMaterial_getIlluminatedColor(
83
+ normal: vec3<f32>,
84
+ worldPosition: vec3<f32>,
85
+ baseColor: vec4<f32>,
86
+ cameraPosition: vec3<f32>
87
+ ) -> vec4<f32> {
88
+ let reflectedColor = reflectiveMaterial_getColor(
89
+ normal,
90
+ worldPosition,
91
+ baseColor,
92
+ cameraPosition
93
+ );
94
+ let pointLightColor = opticalPointLights_getColor(normal, worldPosition, cameraPosition);
95
+ return vec4<f32>(
96
+ reflectedColor.rgb + pointLightColor * reflectiveMaterial.specularStrength,
97
+ reflectedColor.a
98
+ );
99
+ }
100
+ #endif
101
+ `
102
+ );
103
+ const REFLECTIVE_MATERIAL_GLSL = (
104
+ /* glsl */
105
+ `layout(std140) uniform reflectiveMaterialUniforms {
106
+ float roughness;
107
+ float reflectionStrength;
108
+ float specularStrength;
109
+ float opacityScale;
110
+ } reflectiveMaterial;
111
+
112
+ vec4 reflectiveMaterial_getColor(
113
+ vec3 normal,
114
+ vec3 worldPosition,
115
+ vec4 baseColor,
116
+ vec3 cameraPosition
117
+ ) {
118
+ vec3 viewDirection = normalize(cameraPosition - worldPosition);
119
+ vec3 normalFacingCamera = opticalLighting_faceNormal(normalize(normal), viewDirection);
120
+ float viewAlignment = clamp(dot(normalFacingCamera, viewDirection), 0.0, 1.0);
121
+ float fresnel = opticalLighting_getFresnel(viewAlignment, 0.08, 4.0);
122
+ vec3 keyLight = opticalLighting_getKeyLight();
123
+ vec3 fillLight = opticalLighting_getFillLight();
124
+ vec3 keyHalfVector = normalize(keyLight + viewDirection);
125
+ vec3 fillHalfVector = normalize(fillLight + viewDirection);
126
+ float diffuse = 0.36 + 0.64 * max(dot(normalFacingCamera, keyLight), 0.0);
127
+ float filteredRoughness = opticalLighting_getFilteredRoughness(
128
+ normalFacingCamera,
129
+ reflectiveMaterial.roughness
130
+ );
131
+ float specularExponent = mix(96.0, 12.0, filteredRoughness);
132
+ float keySpecular = pow(max(dot(normalFacingCamera, keyHalfVector), 0.0), specularExponent);
133
+ float fillSpecular = pow(
134
+ max(dot(normalFacingCamera, fillHalfVector), 0.0),
135
+ specularExponent * 0.545
136
+ );
137
+ vec3 reflectionDirection = reflect(-viewDirection, normalFacingCamera);
138
+ vec3 reflectedColor = opticalLighting_sampleEnvironment(
139
+ reflectionDirection,
140
+ vec3(0.08, 0.14, 0.25),
141
+ vec3(0.52, 0.7, 0.95),
142
+ 0.0
143
+ );
144
+ vec3 color = baseColor.rgb * diffuse +
145
+ reflectedColor * fresnel * reflectiveMaterial.reflectionStrength +
146
+ vec3(1.0, 0.94, 0.8) * keySpecular * reflectiveMaterial.specularStrength +
147
+ vec3(0.4, 0.67, 1.0) * fillSpecular * reflectiveMaterial.specularStrength * 0.524;
148
+ float opacity = clamp(
149
+ baseColor.a * reflectiveMaterial.opacityScale *
150
+ (0.85 + fresnel * 0.2 + (keySpecular + fillSpecular) * 0.35),
151
+ 0.0,
152
+ 1.0
153
+ );
154
+ return vec4(color, opacity);
155
+ }
156
+
157
+ #ifdef LUMA_OPTICAL_POINT_LIGHTS
158
+ vec3 opticalPointLights_getColor(vec3 normal, vec3 worldPosition, vec3 cameraPosition);
159
+
160
+ vec4 reflectiveMaterial_getIlluminatedColor(
161
+ vec3 normal,
162
+ vec3 worldPosition,
163
+ vec4 baseColor,
164
+ vec3 cameraPosition
165
+ ) {
166
+ vec4 reflectedColor = reflectiveMaterial_getColor(
167
+ normal,
168
+ worldPosition,
169
+ baseColor,
170
+ cameraPosition
171
+ );
172
+ vec3 pointLightColor = opticalPointLights_getColor(normal, worldPosition, cameraPosition);
173
+ return vec4(
174
+ reflectedColor.rgb + pointLightColor * reflectiveMaterial.specularStrength,
175
+ reflectedColor.a
176
+ );
177
+ }
178
+ #endif
179
+ `
180
+ );
181
+ function getReflectiveMaterialUniforms(props = {}, previousUniforms) {
182
+ return {
183
+ roughness: props.roughness ?? (previousUniforms == null ? void 0 : previousUniforms.roughness) ?? 0.62,
184
+ reflectionStrength: props.reflectionStrength ?? (previousUniforms == null ? void 0 : previousUniforms.reflectionStrength) ?? 0.32,
185
+ specularStrength: props.specularStrength ?? (previousUniforms == null ? void 0 : previousUniforms.specularStrength) ?? 0.42,
186
+ opacityScale: props.opacityScale ?? (previousUniforms == null ? void 0 : previousUniforms.opacityScale) ?? 1
187
+ };
188
+ }
189
+ const reflectiveMaterial = {
190
+ name: "reflectiveMaterial",
191
+ source: REFLECTIVE_MATERIAL_WGSL,
192
+ fs: REFLECTIVE_MATERIAL_GLSL,
193
+ dependencies: [import_optical_lighting.opticalLighting],
194
+ uniformTypes: {
195
+ roughness: "f32",
196
+ reflectionStrength: "f32",
197
+ specularStrength: "f32",
198
+ opacityScale: "f32"
199
+ },
200
+ defaultUniforms: {
201
+ roughness: 0.62,
202
+ reflectionStrength: 0.32,
203
+ specularStrength: 0.42,
204
+ opacityScale: 1
205
+ },
206
+ getUniforms: getReflectiveMaterialUniforms
207
+ };
208
+ const reflectiveMaterialPlugin = {
209
+ name: "reflectiveMaterial",
210
+ modules: [reflectiveMaterial]
211
+ };
212
+ // Annotate the CommonJS export names for ESM import in node:
213
+ 0 && (module.exports = {
214
+ reflectiveMaterial,
215
+ reflectiveMaterialPlugin
216
+ });
@@ -0,0 +1,46 @@
1
+ import type { ShaderModule } from '@luma.gl/shadertools';
2
+ /** Runtime properties for the portable reflective-surface shader module. */
3
+ export type ReflectiveMaterialProps = {
4
+ /** Surface roughness in the inclusive zero-to-one range. */
5
+ roughness?: number;
6
+ /** Intensity of environment reflections around the Fresnel rim. */
7
+ reflectionStrength?: number;
8
+ /** Intensity of the key and fill light specular highlights. */
9
+ specularStrength?: number;
10
+ /** Multiplier applied to the incoming material opacity. */
11
+ opacityScale?: number;
12
+ };
13
+ /** Uniform values consumed by {@link reflectiveMaterial}. */
14
+ export type ReflectiveMaterialUniforms = Required<ReflectiveMaterialProps>;
15
+ declare function getReflectiveMaterialUniforms(props?: Partial<ReflectiveMaterialProps>, previousUniforms?: ReflectiveMaterialUniforms): ReflectiveMaterialUniforms;
16
+ /** Portable glossy surface shading with Fresnel edges and key/fill specular highlights. */
17
+ export declare const reflectiveMaterial: {
18
+ readonly name: "reflectiveMaterial";
19
+ readonly source: "struct ReflectiveMaterialUniforms {\n roughness: f32,\n reflectionStrength: f32,\n specularStrength: f32,\n opacityScale: f32,\n};\n\n@group(0) @binding(auto) var<uniform> reflectiveMaterial: ReflectiveMaterialUniforms;\n\nfn reflectiveMaterial_getColor(\n normal: vec3<f32>,\n worldPosition: vec3<f32>,\n baseColor: vec4<f32>,\n cameraPosition: vec3<f32>\n) -> vec4<f32> {\n let viewDirection = normalize(cameraPosition - worldPosition);\n let normalFacingCamera = opticalLighting_faceNormal(normalize(normal), viewDirection);\n let viewAlignment = clamp(dot(normalFacingCamera, viewDirection), 0.0, 1.0);\n let fresnel = opticalLighting_getFresnel(viewAlignment, 0.08, 4.0);\n let keyLight = opticalLighting_getKeyLight();\n let fillLight = opticalLighting_getFillLight();\n let keyHalfVector = normalize(keyLight + viewDirection);\n let fillHalfVector = normalize(fillLight + viewDirection);\n let diffuse = 0.36 + 0.64 * max(dot(normalFacingCamera, keyLight), 0.0);\n let filteredRoughness = opticalLighting_getFilteredRoughness(\n normalFacingCamera,\n reflectiveMaterial.roughness\n );\n let specularExponent = mix(96.0, 12.0, filteredRoughness);\n let keySpecular = pow(max(dot(normalFacingCamera, keyHalfVector), 0.0), specularExponent);\n let fillSpecular = pow(\n max(dot(normalFacingCamera, fillHalfVector), 0.0),\n specularExponent * 0.545\n );\n let reflectionDirection = reflect(-viewDirection, normalFacingCamera);\n let reflectedColor = opticalLighting_sampleEnvironment(\n reflectionDirection,\n vec3<f32>(0.08, 0.14, 0.25),\n vec3<f32>(0.52, 0.7, 0.95),\n 0.0\n );\n let color = baseColor.rgb * diffuse +\n reflectedColor * fresnel * reflectiveMaterial.reflectionStrength +\n vec3<f32>(1.0, 0.94, 0.8) * keySpecular * reflectiveMaterial.specularStrength +\n vec3<f32>(0.4, 0.67, 1.0) * fillSpecular * reflectiveMaterial.specularStrength * 0.524;\n let opacity = clamp(\n baseColor.a * reflectiveMaterial.opacityScale *\n (0.85 + fresnel * 0.2 + (keySpecular + fillSpecular) * 0.35),\n 0.0,\n 1.0\n );\n return vec4<f32>(color, opacity);\n}\n\n#ifdef LUMA_OPTICAL_POINT_LIGHTS\nfn reflectiveMaterial_getIlluminatedColor(\n normal: vec3<f32>,\n worldPosition: vec3<f32>,\n baseColor: vec4<f32>,\n cameraPosition: vec3<f32>\n) -> vec4<f32> {\n let reflectedColor = reflectiveMaterial_getColor(\n normal,\n worldPosition,\n baseColor,\n cameraPosition\n );\n let pointLightColor = opticalPointLights_getColor(normal, worldPosition, cameraPosition);\n return vec4<f32>(\n reflectedColor.rgb + pointLightColor * reflectiveMaterial.specularStrength,\n reflectedColor.a\n );\n}\n#endif\n";
20
+ readonly fs: "layout(std140) uniform reflectiveMaterialUniforms {\n float roughness;\n float reflectionStrength;\n float specularStrength;\n float opacityScale;\n} reflectiveMaterial;\n\nvec4 reflectiveMaterial_getColor(\n vec3 normal,\n vec3 worldPosition,\n vec4 baseColor,\n vec3 cameraPosition\n) {\n vec3 viewDirection = normalize(cameraPosition - worldPosition);\n vec3 normalFacingCamera = opticalLighting_faceNormal(normalize(normal), viewDirection);\n float viewAlignment = clamp(dot(normalFacingCamera, viewDirection), 0.0, 1.0);\n float fresnel = opticalLighting_getFresnel(viewAlignment, 0.08, 4.0);\n vec3 keyLight = opticalLighting_getKeyLight();\n vec3 fillLight = opticalLighting_getFillLight();\n vec3 keyHalfVector = normalize(keyLight + viewDirection);\n vec3 fillHalfVector = normalize(fillLight + viewDirection);\n float diffuse = 0.36 + 0.64 * max(dot(normalFacingCamera, keyLight), 0.0);\n float filteredRoughness = opticalLighting_getFilteredRoughness(\n normalFacingCamera,\n reflectiveMaterial.roughness\n );\n float specularExponent = mix(96.0, 12.0, filteredRoughness);\n float keySpecular = pow(max(dot(normalFacingCamera, keyHalfVector), 0.0), specularExponent);\n float fillSpecular = pow(\n max(dot(normalFacingCamera, fillHalfVector), 0.0),\n specularExponent * 0.545\n );\n vec3 reflectionDirection = reflect(-viewDirection, normalFacingCamera);\n vec3 reflectedColor = opticalLighting_sampleEnvironment(\n reflectionDirection,\n vec3(0.08, 0.14, 0.25),\n vec3(0.52, 0.7, 0.95),\n 0.0\n );\n vec3 color = baseColor.rgb * diffuse +\n reflectedColor * fresnel * reflectiveMaterial.reflectionStrength +\n vec3(1.0, 0.94, 0.8) * keySpecular * reflectiveMaterial.specularStrength +\n vec3(0.4, 0.67, 1.0) * fillSpecular * reflectiveMaterial.specularStrength * 0.524;\n float opacity = clamp(\n baseColor.a * reflectiveMaterial.opacityScale *\n (0.85 + fresnel * 0.2 + (keySpecular + fillSpecular) * 0.35),\n 0.0,\n 1.0\n );\n return vec4(color, opacity);\n}\n\n#ifdef LUMA_OPTICAL_POINT_LIGHTS\nvec3 opticalPointLights_getColor(vec3 normal, vec3 worldPosition, vec3 cameraPosition);\n\nvec4 reflectiveMaterial_getIlluminatedColor(\n vec3 normal,\n vec3 worldPosition,\n vec4 baseColor,\n vec3 cameraPosition\n) {\n vec4 reflectedColor = reflectiveMaterial_getColor(\n normal,\n worldPosition,\n baseColor,\n cameraPosition\n );\n vec3 pointLightColor = opticalPointLights_getColor(normal, worldPosition, cameraPosition);\n return vec4(\n reflectedColor.rgb + pointLightColor * reflectiveMaterial.specularStrength,\n reflectedColor.a\n );\n}\n#endif\n";
21
+ readonly dependencies: [{
22
+ readonly name: "opticalLighting";
23
+ readonly source: "fn opticalLighting_faceNormal(normal: vec3<f32>, viewDirection: vec3<f32>) -> vec3<f32> {\n return select(-normal, normal, dot(normal, viewDirection) >= 0.0);\n}\n\nfn opticalLighting_getFresnel(\n viewAlignment: f32,\n baseReflectance: f32,\n exponent: f32\n) -> f32 {\n return baseReflectance + (1.0 - baseReflectance) *\n pow(1.0 - clamp(viewAlignment, 0.0, 1.0), exponent);\n}\n\nfn opticalLighting_getFilteredRoughness(normal: vec3<f32>, roughness: f32) -> f32 {\n let normalDerivativeX = dpdx(normal);\n let normalDerivativeY = dpdy(normal);\n let normalVariance = dot(normalDerivativeX, normalDerivativeX) +\n dot(normalDerivativeY, normalDerivativeY);\n let kernelRoughnessSquared = min(2.0 * normalVariance, 1.0);\n return clamp(sqrt(roughness * roughness + kernelRoughnessSquared), 0.04, 1.0);\n}\n\nfn opticalLighting_getMicrofacetSpecular(\n normal: vec3<f32>,\n viewDirection: vec3<f32>,\n lightDirection: vec3<f32>,\n roughness: f32\n) -> f32 {\n let halfDirection = normalize(viewDirection + lightDirection);\n let normalAlignment = max(dot(normal, viewDirection), 0.001);\n let lightAlignment = max(dot(normal, lightDirection), 0.0);\n let halfAlignment = max(dot(normal, halfDirection), 0.0);\n let alpha = max(roughness * roughness, 0.045);\n let alphaSquared = alpha * alpha;\n let distributionDenominator = halfAlignment * halfAlignment * (alphaSquared - 1.0) + 1.0;\n let distribution = alphaSquared /\n max(3.14159265 * distributionDenominator * distributionDenominator, 0.001);\n let visibilityFactor = pow(roughness + 1.0, 2.0) * 0.125;\n let viewVisibility = normalAlignment /\n (normalAlignment * (1.0 - visibilityFactor) + visibilityFactor);\n let lightVisibility = lightAlignment /\n (lightAlignment * (1.0 - visibilityFactor) + visibilityFactor);\n return distribution * viewVisibility * lightVisibility * lightAlignment /\n max(4.0 * normalAlignment * lightAlignment, 0.001);\n}\n\nfn opticalLighting_getKeyLight() -> vec3<f32> {\n return normalize(vec3<f32>(-0.45, 0.82, 0.34));\n}\n\nfn opticalLighting_getFillLight() -> vec3<f32> {\n return normalize(vec3<f32>(0.62, 0.35, -0.7));\n}\n\nfn opticalLighting_sampleEnvironment(\n reflectionDirection: vec3<f32>,\n shadowColor: vec3<f32>,\n highlightColor: vec3<f32>,\n horizonStrength: f32\n) -> vec3<f32> {\n let horizon = pow(1.0 - abs(reflectionDirection.y), 4.0);\n return mix(\n shadowColor,\n highlightColor,\n clamp(reflectionDirection.y * 0.5 + 0.5 + horizon * horizonStrength, 0.0, 1.0)\n );\n}\n";
24
+ readonly fs: "vec3 opticalLighting_faceNormal(vec3 normal, vec3 viewDirection) {\n return dot(normal, viewDirection) >= 0.0 ? normal : -normal;\n}\n\nfloat opticalLighting_getFresnel(float viewAlignment, float baseReflectance, float exponent) {\n return baseReflectance + (1.0 - baseReflectance) *\n pow(1.0 - clamp(viewAlignment, 0.0, 1.0), exponent);\n}\n\nfloat opticalLighting_getFilteredRoughness(vec3 normal, float roughness) {\n vec3 normalDerivativeX = dFdx(normal);\n vec3 normalDerivativeY = dFdy(normal);\n float normalVariance = dot(normalDerivativeX, normalDerivativeX) +\n dot(normalDerivativeY, normalDerivativeY);\n float kernelRoughnessSquared = min(2.0 * normalVariance, 1.0);\n return clamp(sqrt(roughness * roughness + kernelRoughnessSquared), 0.04, 1.0);\n}\n\nfloat opticalLighting_getMicrofacetSpecular(\n vec3 normal,\n vec3 viewDirection,\n vec3 lightDirection,\n float roughness\n) {\n vec3 halfDirection = normalize(viewDirection + lightDirection);\n float normalAlignment = max(dot(normal, viewDirection), 0.001);\n float lightAlignment = max(dot(normal, lightDirection), 0.0);\n float halfAlignment = max(dot(normal, halfDirection), 0.0);\n float alpha = max(roughness * roughness, 0.045);\n float alphaSquared = alpha * alpha;\n float distributionDenominator = halfAlignment * halfAlignment * (alphaSquared - 1.0) + 1.0;\n float distribution = alphaSquared /\n max(3.14159265 * distributionDenominator * distributionDenominator, 0.001);\n float visibilityFactor = pow(roughness + 1.0, 2.0) * 0.125;\n float viewVisibility = normalAlignment /\n (normalAlignment * (1.0 - visibilityFactor) + visibilityFactor);\n float lightVisibility = lightAlignment /\n (lightAlignment * (1.0 - visibilityFactor) + visibilityFactor);\n return distribution * viewVisibility * lightVisibility * lightAlignment /\n max(4.0 * normalAlignment * lightAlignment, 0.001);\n}\n\nvec3 opticalLighting_getKeyLight() {\n return normalize(vec3(-0.45, 0.82, 0.34));\n}\n\nvec3 opticalLighting_getFillLight() {\n return normalize(vec3(0.62, 0.35, -0.7));\n}\n\nvec3 opticalLighting_sampleEnvironment(\n vec3 reflectionDirection,\n vec3 shadowColor,\n vec3 highlightColor,\n float horizonStrength\n) {\n float horizon = pow(1.0 - abs(reflectionDirection.y), 4.0);\n return mix(\n shadowColor,\n highlightColor,\n clamp(reflectionDirection.y * 0.5 + 0.5 + horizon * horizonStrength, 0.0, 1.0)\n );\n}\n";
25
+ }];
26
+ readonly uniformTypes: {
27
+ readonly roughness: "f32";
28
+ readonly reflectionStrength: "f32";
29
+ readonly specularStrength: "f32";
30
+ readonly opacityScale: "f32";
31
+ };
32
+ readonly defaultUniforms: {
33
+ readonly roughness: 0.62;
34
+ readonly reflectionStrength: 0.32;
35
+ readonly specularStrength: 0.42;
36
+ readonly opacityScale: 1;
37
+ };
38
+ readonly getUniforms: typeof getReflectiveMaterialUniforms;
39
+ };
40
+ /** Installs portable reflective surface shading and shared optical-lighting helpers. */
41
+ export declare const reflectiveMaterialPlugin: {
42
+ readonly name: "reflectiveMaterial";
43
+ readonly modules: [ShaderModule];
44
+ };
45
+ export {};
46
+ //# sourceMappingURL=reflective-material.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reflective-material.d.ts","sourceRoot":"","sources":["../../../src/experimental/materials/reflective-material.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAe,MAAM,sBAAsB,CAAC;AAGrE,4EAA4E;AAC5E,MAAM,MAAM,uBAAuB,GAAG;IACpC,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,+DAA+D;IAC/D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAAC,uBAAuB,CAAC,CAAC;AA4J3E,iBAAS,6BAA6B,CACpC,KAAK,GAAE,OAAO,CAAC,uBAAuB,CAAM,EAC5C,gBAAgB,CAAC,EAAE,0BAA0B,GAC5C,0BAA0B,CAO5B;AAED,2FAA2F;AAC3F,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;CAkB2D,CAAC;AAE3F,wFAAwF;AACxF,eAAO,MAAM,wBAAwB;;;CAGJ,CAAC"}