angular-three-soba 1.13.0 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/abstractions/lib/billboard/billboard.d.ts +1 -1
  2. package/abstractions/lib/catmull-rom-line/catmull-rom-line.d.ts +1 -1
  3. package/abstractions/lib/cubic-bezier-line/cubic-bezier-line.d.ts +1 -1
  4. package/abstractions/lib/edges/edges.d.ts +2 -2
  5. package/abstractions/lib/gizmo-helper/gizmo-helper.d.ts +1 -1
  6. package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-edge.d.ts +1 -1
  7. package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-face.d.ts +2 -2
  8. package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-inputs.d.ts +1 -1
  9. package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube.d.ts +1 -1
  10. package/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport-axis.d.ts +2 -2
  11. package/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport.d.ts +1 -1
  12. package/abstractions/lib/line/line-input.d.ts +1 -1
  13. package/abstractions/lib/line/line.d.ts +1 -1
  14. package/abstractions/lib/quadratic-bezier-line/quadratic-bezier-line.d.ts +1 -1
  15. package/abstractions/lib/text/text.d.ts +1 -1
  16. package/abstractions/lib/text-3d/text-3d.d.ts +1 -1
  17. package/cameras/lib/camera/camera-content.d.ts +1 -1
  18. package/cameras/lib/camera/camera.d.ts +1 -1
  19. package/cameras/lib/cube-camera/cube-camera.d.ts +1 -1
  20. package/cameras/lib/orthographic-camera/orthographic-camera.d.ts +1 -1
  21. package/controls/lib/orbit-controls/orbit-controls.d.ts +1 -1
  22. package/esm2022/abstractions/lib/billboard/billboard.mjs +74 -0
  23. package/esm2022/abstractions/lib/catmull-rom-line/catmull-rom-line.mjs +120 -0
  24. package/esm2022/abstractions/lib/cubic-bezier-line/cubic-bezier-line.mjs +99 -0
  25. package/esm2022/abstractions/lib/edges/edges.mjs +96 -0
  26. package/esm2022/abstractions/lib/gizmo-helper/gizmo-helper.mjs +213 -0
  27. package/esm2022/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-edge.mjs +92 -0
  28. package/esm2022/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-face.mjs +184 -0
  29. package/esm2022/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-inputs.mjs +46 -0
  30. package/{esm2020 → esm2022}/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube.mjs +8 -7
  31. package/esm2022/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport-axis.mjs +195 -0
  32. package/{esm2020 → esm2022}/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport.mjs +8 -7
  33. package/esm2022/abstractions/lib/line/line-input.mjs +76 -0
  34. package/esm2022/abstractions/lib/line/line.mjs +133 -0
  35. package/esm2022/abstractions/lib/quadratic-bezier-line/quadratic-bezier-line.mjs +128 -0
  36. package/esm2022/abstractions/lib/text/text.mjs +115 -0
  37. package/esm2022/abstractions/lib/text-3d/text-3d.mjs +145 -0
  38. package/esm2022/cameras/lib/camera/camera-content.mjs +21 -0
  39. package/esm2022/cameras/lib/camera/camera.mjs +75 -0
  40. package/esm2022/cameras/lib/cube-camera/cube-camera.mjs +131 -0
  41. package/esm2022/cameras/lib/orthographic-camera/orthographic-camera.mjs +93 -0
  42. package/{esm2020 → esm2022}/cameras/lib/perspective-camera/perspective-camera.mjs +8 -7
  43. package/esm2022/controls/lib/orbit-controls/orbit-controls.mjs +147 -0
  44. package/{esm2020 → esm2022}/loaders/lib/cube-texture-loader/cube-texture-loader.mjs +3 -3
  45. package/esm2022/loaders/lib/loader/loader.mjs +134 -0
  46. package/esm2022/materials/lib/mesh-distort-material/mesh-distort-material.mjs +75 -0
  47. package/esm2022/materials/lib/mesh-reflector-material/mesh-reflector-material.mjs +328 -0
  48. package/esm2022/materials/lib/mesh-refraction-material/mesh-refraction-material.mjs +158 -0
  49. package/esm2022/materials/lib/mesh-transmission-material/mesh-transmission-material.mjs +238 -0
  50. package/esm2022/materials/lib/mesh-wobble-material/mesh-wobble-material.mjs +68 -0
  51. package/esm2022/misc/lib/bake-shadows/bake-shadows.mjs +26 -0
  52. package/esm2022/performance/lib/adaptive/adaptive-dpr.mjs +47 -0
  53. package/esm2022/performance/lib/adaptive/adaptive-events.mjs +37 -0
  54. package/esm2022/performance/lib/detailed/detailed.mjs +54 -0
  55. package/esm2022/performance/lib/stats/stats.mjs +80 -0
  56. package/esm2022/shaders/lib/blur-pass/blur-pass.mjs +61 -0
  57. package/esm2022/staging/lib/accumulative-shadows/accumulative-shadows.mjs +249 -0
  58. package/esm2022/staging/lib/accumulative-shadows/randomized-lights.mjs +201 -0
  59. package/{esm2020 → esm2022}/staging/lib/bounds/bounds.mjs +8 -7
  60. package/esm2022/staging/lib/camera-shake/camera-shake.mjs +122 -0
  61. package/esm2022/staging/lib/caustics/caustics.mjs +364 -0
  62. package/esm2022/staging/lib/center/center.mjs +143 -0
  63. package/esm2022/staging/lib/cloud/cloud.mjs +160 -0
  64. package/esm2022/staging/lib/contact-shadows/contact-shadows.mjs +228 -0
  65. package/esm2022/staging/lib/environment/environment-cube.mjs +41 -0
  66. package/esm2022/staging/lib/environment/environment-ground.mjs +67 -0
  67. package/esm2022/staging/lib/environment/environment-inputs.mjs +87 -0
  68. package/esm2022/staging/lib/environment/environment-map.mjs +39 -0
  69. package/esm2022/staging/lib/environment/environment-portal.mjs +111 -0
  70. package/{esm2020 → esm2022}/staging/lib/environment/environment.mjs +13 -11
  71. package/esm2022/staging/lib/float/float.mjs +77 -0
  72. package/esm2022/staging/lib/sky/sky.mjs +109 -0
  73. package/esm2022/staging/lib/sparkles/sparkles.mjs +210 -0
  74. package/esm2022/staging/lib/spot-light/shadow-mesh-input.mjs +51 -0
  75. package/esm2022/staging/lib/spot-light/spot-light-input.mjs +62 -0
  76. package/esm2022/staging/lib/spot-light/spot-light-shadow-no-shader.mjs +74 -0
  77. package/esm2022/staging/lib/spot-light/spot-light-shadow-shader.mjs +126 -0
  78. package/{esm2020 → esm2022}/staging/lib/spot-light/spot-light-shadow.mjs +8 -7
  79. package/esm2022/staging/lib/spot-light/spot-light.mjs +117 -0
  80. package/esm2022/staging/lib/spot-light/volumetric-mesh.mjs +86 -0
  81. package/{esm2020 → esm2022}/staging/lib/stage/stage.mjs +13 -11
  82. package/esm2022/staging/lib/stars/stars.mjs +140 -0
  83. package/{fesm2020 → fesm2022}/angular-three-soba-abstractions.mjs +89 -89
  84. package/{fesm2015 → fesm2022}/angular-three-soba-abstractions.mjs.map +1 -1
  85. package/{fesm2015 → fesm2022}/angular-three-soba-cameras.mjs +21 -21
  86. package/{fesm2015 → fesm2022}/angular-three-soba-cameras.mjs.map +1 -1
  87. package/{fesm2020 → fesm2022}/angular-three-soba-controls.mjs +5 -5
  88. package/fesm2022/angular-three-soba-controls.mjs.map +1 -0
  89. package/{fesm2020 → fesm2022}/angular-three-soba-loaders.mjs +7 -7
  90. package/{fesm2020 → fesm2022}/angular-three-soba-loaders.mjs.map +1 -1
  91. package/{fesm2020 → fesm2022}/angular-three-soba-materials.mjs +25 -25
  92. package/{fesm2020 → fesm2022}/angular-three-soba-materials.mjs.map +1 -1
  93. package/{fesm2020 → fesm2022}/angular-three-soba-misc.mjs +3 -3
  94. package/{fesm2020 → fesm2022}/angular-three-soba-misc.mjs.map +1 -1
  95. package/{fesm2020 → fesm2022}/angular-three-soba-performance.mjs +14 -14
  96. package/{fesm2020 → fesm2022}/angular-three-soba-performance.mjs.map +1 -1
  97. package/{fesm2020 → fesm2022}/angular-three-soba-shaders.mjs +2 -2
  98. package/fesm2022/angular-three-soba-shaders.mjs.map +1 -0
  99. package/{fesm2020 → fesm2022}/angular-three-soba-staging.mjs +139 -139
  100. package/{fesm2020 → fesm2022}/angular-three-soba-staging.mjs.map +1 -1
  101. package/loaders/lib/loader/loader.d.ts +1 -1
  102. package/materials/lib/mesh-distort-material/mesh-distort-material.d.ts +1 -1
  103. package/materials/lib/mesh-reflector-material/mesh-reflector-material.d.ts +1 -1
  104. package/materials/lib/mesh-refraction-material/mesh-refraction-material.d.ts +1 -1
  105. package/materials/lib/mesh-transmission-material/mesh-transmission-material.d.ts +1 -1
  106. package/materials/lib/mesh-wobble-material/mesh-wobble-material.d.ts +1 -1
  107. package/package.json +45 -70
  108. package/performance/lib/adaptive/adaptive-dpr.d.ts +1 -1
  109. package/performance/lib/detailed/detailed.d.ts +1 -1
  110. package/performance/lib/stats/stats.d.ts +1 -1
  111. package/plugin/package.json +1 -1
  112. package/plugin/src/generators/init/compat.js +1 -1
  113. package/plugin/src/generators/init/compat.js.map +1 -1
  114. package/plugin/src/generators/init/init.d.ts +1 -1
  115. package/plugin/src/generators/init/init.js +1 -1
  116. package/plugin/src/generators/init/init.js.map +1 -1
  117. package/staging/lib/accumulative-shadows/accumulative-shadows.d.ts +2 -2
  118. package/staging/lib/accumulative-shadows/randomized-lights.d.ts +1 -1
  119. package/staging/lib/bounds/bounds.d.ts +1 -1
  120. package/staging/lib/camera-shake/camera-shake.d.ts +1 -1
  121. package/staging/lib/caustics/caustics.d.ts +2 -2
  122. package/staging/lib/center/center.d.ts +1 -1
  123. package/staging/lib/cloud/cloud.d.ts +1 -1
  124. package/staging/lib/contact-shadows/contact-shadows.d.ts +1 -1
  125. package/staging/lib/environment/environment-inputs.d.ts +1 -1
  126. package/staging/lib/float/float.d.ts +1 -1
  127. package/staging/lib/sky/sky.d.ts +1 -1
  128. package/staging/lib/sparkles/sparkles.d.ts +2 -2
  129. package/staging/lib/spot-light/shadow-mesh-input.d.ts +1 -1
  130. package/staging/lib/spot-light/spot-light-input.d.ts +1 -1
  131. package/staging/lib/spot-light/spot-light-shadow-no-shader.d.ts +1 -1
  132. package/staging/lib/spot-light/spot-light-shadow-shader.d.ts +1 -1
  133. package/staging/lib/spot-light/spot-light.d.ts +1 -1
  134. package/staging/lib/spot-light/volumetric-mesh.d.ts +1 -1
  135. package/staging/lib/stage/stage.d.ts +2 -2
  136. package/staging/lib/stars/stars.d.ts +2 -2
  137. package/esm2020/abstractions/lib/billboard/billboard.mjs +0 -73
  138. package/esm2020/abstractions/lib/catmull-rom-line/catmull-rom-line.mjs +0 -119
  139. package/esm2020/abstractions/lib/cubic-bezier-line/cubic-bezier-line.mjs +0 -98
  140. package/esm2020/abstractions/lib/edges/edges.mjs +0 -95
  141. package/esm2020/abstractions/lib/gizmo-helper/gizmo-helper.mjs +0 -211
  142. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-edge.mjs +0 -91
  143. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-face.mjs +0 -182
  144. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-inputs.mjs +0 -45
  145. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport-axis.mjs +0 -193
  146. package/esm2020/abstractions/lib/line/line-input.mjs +0 -75
  147. package/esm2020/abstractions/lib/line/line.mjs +0 -132
  148. package/esm2020/abstractions/lib/quadratic-bezier-line/quadratic-bezier-line.mjs +0 -127
  149. package/esm2020/abstractions/lib/text/text.mjs +0 -114
  150. package/esm2020/abstractions/lib/text-3d/text-3d.mjs +0 -144
  151. package/esm2020/cameras/lib/camera/camera-content.mjs +0 -20
  152. package/esm2020/cameras/lib/camera/camera.mjs +0 -74
  153. package/esm2020/cameras/lib/cube-camera/cube-camera.mjs +0 -130
  154. package/esm2020/cameras/lib/orthographic-camera/orthographic-camera.mjs +0 -92
  155. package/esm2020/controls/lib/orbit-controls/orbit-controls.mjs +0 -146
  156. package/esm2020/loaders/lib/loader/loader.mjs +0 -133
  157. package/esm2020/materials/lib/mesh-distort-material/mesh-distort-material.mjs +0 -74
  158. package/esm2020/materials/lib/mesh-reflector-material/mesh-reflector-material.mjs +0 -327
  159. package/esm2020/materials/lib/mesh-refraction-material/mesh-refraction-material.mjs +0 -157
  160. package/esm2020/materials/lib/mesh-transmission-material/mesh-transmission-material.mjs +0 -237
  161. package/esm2020/materials/lib/mesh-wobble-material/mesh-wobble-material.mjs +0 -67
  162. package/esm2020/misc/lib/bake-shadows/bake-shadows.mjs +0 -25
  163. package/esm2020/performance/lib/adaptive/adaptive-dpr.mjs +0 -46
  164. package/esm2020/performance/lib/adaptive/adaptive-events.mjs +0 -36
  165. package/esm2020/performance/lib/detailed/detailed.mjs +0 -53
  166. package/esm2020/performance/lib/stats/stats.mjs +0 -79
  167. package/esm2020/shaders/lib/blur-pass/blur-pass.mjs +0 -61
  168. package/esm2020/staging/lib/accumulative-shadows/accumulative-shadows.mjs +0 -247
  169. package/esm2020/staging/lib/accumulative-shadows/randomized-lights.mjs +0 -199
  170. package/esm2020/staging/lib/camera-shake/camera-shake.mjs +0 -121
  171. package/esm2020/staging/lib/caustics/caustics.mjs +0 -363
  172. package/esm2020/staging/lib/center/center.mjs +0 -142
  173. package/esm2020/staging/lib/cloud/cloud.mjs +0 -159
  174. package/esm2020/staging/lib/contact-shadows/contact-shadows.mjs +0 -227
  175. package/esm2020/staging/lib/environment/environment-cube.mjs +0 -40
  176. package/esm2020/staging/lib/environment/environment-ground.mjs +0 -66
  177. package/esm2020/staging/lib/environment/environment-inputs.mjs +0 -86
  178. package/esm2020/staging/lib/environment/environment-map.mjs +0 -38
  179. package/esm2020/staging/lib/environment/environment-portal.mjs +0 -110
  180. package/esm2020/staging/lib/float/float.mjs +0 -76
  181. package/esm2020/staging/lib/sky/sky.mjs +0 -108
  182. package/esm2020/staging/lib/sparkles/sparkles.mjs +0 -209
  183. package/esm2020/staging/lib/spot-light/shadow-mesh-input.mjs +0 -50
  184. package/esm2020/staging/lib/spot-light/spot-light-input.mjs +0 -61
  185. package/esm2020/staging/lib/spot-light/spot-light-shadow-no-shader.mjs +0 -73
  186. package/esm2020/staging/lib/spot-light/spot-light-shadow-shader.mjs +0 -125
  187. package/esm2020/staging/lib/spot-light/spot-light.mjs +0 -116
  188. package/esm2020/staging/lib/spot-light/volumetric-mesh.mjs +0 -85
  189. package/esm2020/staging/lib/stars/stars.mjs +0 -139
  190. package/fesm2015/angular-three-soba-abstractions.mjs +0 -2048
  191. package/fesm2015/angular-three-soba-controls.mjs +0 -153
  192. package/fesm2015/angular-three-soba-controls.mjs.map +0 -1
  193. package/fesm2015/angular-three-soba-loaders.mjs +0 -229
  194. package/fesm2015/angular-three-soba-loaders.mjs.map +0 -1
  195. package/fesm2015/angular-three-soba-materials.mjs +0 -851
  196. package/fesm2015/angular-three-soba-materials.mjs.map +0 -1
  197. package/fesm2015/angular-three-soba-misc.mjs +0 -148
  198. package/fesm2015/angular-three-soba-misc.mjs.map +0 -1
  199. package/fesm2015/angular-three-soba-performance.mjs +0 -210
  200. package/fesm2015/angular-three-soba-performance.mjs.map +0 -1
  201. package/fesm2015/angular-three-soba-shaders.mjs +0 -1239
  202. package/fesm2015/angular-three-soba-shaders.mjs.map +0 -1
  203. package/fesm2015/angular-three-soba-staging.mjs +0 -3772
  204. package/fesm2015/angular-three-soba-staging.mjs.map +0 -1
  205. package/fesm2020/angular-three-soba-abstractions.mjs.map +0 -1
  206. package/fesm2020/angular-three-soba-cameras.mjs +0 -347
  207. package/fesm2020/angular-three-soba-cameras.mjs.map +0 -1
  208. package/fesm2020/angular-three-soba-controls.mjs.map +0 -1
  209. package/fesm2020/angular-three-soba-shaders.mjs.map +0 -1
  210. package/fesm2020/angular-three-soba.mjs +0 -6
  211. package/fesm2020/angular-three-soba.mjs.map +0 -1
  212. /package/{esm2020 → esm2022}/abstractions/angular-three-soba-abstractions.mjs +0 -0
  213. /package/{esm2020 → esm2022}/abstractions/index.mjs +0 -0
  214. /package/{esm2020 → esm2022}/abstractions/lib/gizmo-helper/gizmo-viewcube/constants.mjs +0 -0
  215. /package/{esm2020 → esm2022}/angular-three-soba.mjs +0 -0
  216. /package/{esm2020 → esm2022}/cameras/angular-three-soba-cameras.mjs +0 -0
  217. /package/{esm2020 → esm2022}/cameras/index.mjs +0 -0
  218. /package/{esm2020 → esm2022}/controls/angular-three-soba-controls.mjs +0 -0
  219. /package/{esm2020 → esm2022}/controls/index.mjs +0 -0
  220. /package/{esm2020 → esm2022}/index.mjs +0 -0
  221. /package/{esm2020 → esm2022}/loaders/angular-three-soba-loaders.mjs +0 -0
  222. /package/{esm2020 → esm2022}/loaders/index.mjs +0 -0
  223. /package/{esm2020 → esm2022}/loaders/lib/gltf-loader/gltf-loader.mjs +0 -0
  224. /package/{esm2020 → esm2022}/loaders/lib/progress/progress.mjs +0 -0
  225. /package/{esm2020 → esm2022}/loaders/lib/texture-loader/texture-loader.mjs +0 -0
  226. /package/{esm2020 → esm2022}/materials/angular-three-soba-materials.mjs +0 -0
  227. /package/{esm2020 → esm2022}/materials/index.mjs +0 -0
  228. /package/{esm2020 → esm2022}/misc/angular-three-soba-misc.mjs +0 -0
  229. /package/{esm2020 → esm2022}/misc/index.mjs +0 -0
  230. /package/{esm2020 → esm2022}/misc/lib/animations/animations.mjs +0 -0
  231. /package/{esm2020 → esm2022}/misc/lib/depth-buffer/depth-buffer.mjs +0 -0
  232. /package/{esm2020 → esm2022}/misc/lib/fbo/fbo.mjs +0 -0
  233. /package/{esm2020 → esm2022}/performance/angular-three-soba-performance.mjs +0 -0
  234. /package/{esm2020 → esm2022}/performance/index.mjs +0 -0
  235. /package/{esm2020 → esm2022}/shaders/angular-three-soba-shaders.mjs +0 -0
  236. /package/{esm2020 → esm2022}/shaders/index.mjs +0 -0
  237. /package/{esm2020 → esm2022}/shaders/lib/caustics-material/caustics-material.mjs +0 -0
  238. /package/{esm2020 → esm2022}/shaders/lib/caustics-projection-material/caustics-projection-material.mjs +0 -0
  239. /package/{esm2020 → esm2022}/shaders/lib/convolution-material/convolution-material.mjs +0 -0
  240. /package/{esm2020 → esm2022}/shaders/lib/discard-material/discard-material.mjs +0 -0
  241. /package/{esm2020 → esm2022}/shaders/lib/mesh-distort-material/mesh-distort-material.mjs +0 -0
  242. /package/{esm2020 → esm2022}/shaders/lib/mesh-reflector-material/mesh-reflector-material.mjs +0 -0
  243. /package/{esm2020 → esm2022}/shaders/lib/mesh-refraction-material/mesh-refraction-material.mjs +0 -0
  244. /package/{esm2020 → esm2022}/shaders/lib/mesh-transmission-material/mesh-transmission-material.mjs +0 -0
  245. /package/{esm2020 → esm2022}/shaders/lib/mesh-wobble-material/mesh-wobble-material.mjs +0 -0
  246. /package/{esm2020 → esm2022}/shaders/lib/shader-material/shader-material.mjs +0 -0
  247. /package/{esm2020 → esm2022}/shaders/lib/soft-shadow-material/soft-shadow-material.mjs +0 -0
  248. /package/{esm2020 → esm2022}/shaders/lib/spot-light-material/spot-light-material.mjs +0 -0
  249. /package/{esm2020 → esm2022}/shaders/lib/star-field-material/star-field-material.mjs +0 -0
  250. /package/{esm2020 → esm2022}/staging/angular-three-soba-staging.mjs +0 -0
  251. /package/{esm2020 → esm2022}/staging/index.mjs +0 -0
  252. /package/{esm2020 → esm2022}/staging/lib/accumulative-shadows/progressive-light-map.mjs +0 -0
  253. /package/{esm2020 → esm2022}/staging/lib/environment/assets.mjs +0 -0
  254. /package/{esm2020 → esm2022}/staging/lib/environment/utils.mjs +0 -0
  255. /package/{esm2020 → esm2022}/staging/lib/spot-light/common.mjs +0 -0
  256. /package/{fesm2015 → fesm2022}/angular-three-soba.mjs +0 -0
  257. /package/{fesm2015 → fesm2022}/angular-three-soba.mjs.map +0 -0
@@ -1,3772 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, Directive, Component, CUSTOM_ELEMENTS_SCHEMA, Input, EventEmitter, Output, TemplateRef, ContentChild, ChangeDetectorRef } from '@angular/core';
3
- import { extend, NgtStore, getLocalState, NgtRxStore, injectNgtRef, NgtArgs, NgtRepeat, is, injectBeforeRender, NgtPush, injectNgtDestroy, injectNgtLoader, startWithUndefined, prepare, NgtPortal, NgtPortalContent, createRunInContext, checkUpdate } from 'angular-three';
4
- import { DiscardMaterial, SoftShadowMaterial, CausticsProjectionMaterial, CausticsMaterial, shaderMaterial, SpotLightMaterial, StarFieldMaterial } from 'angular-three-soba/shaders';
5
- import { Subject, combineLatest, switchMap, map, isObservable, of, debounceTime, takeUntil, startWith, withLatestFrom } from 'rxjs';
6
- import * as THREE from 'three';
7
- import { Group, Mesh, PlaneGeometry, DirectionalLight, OrthographicCamera, Vector2, Scene, LineBasicMaterial, Box3, Vector3, Sphere, MeshStandardMaterial, MeshBasicMaterial, CubeTextureLoader, CubeReflectionMapping, EquirectangularReflectionMapping, sRGBEncoding, LinearEncoding, CubeCamera, HalfFloatType, Points, BufferGeometry, BufferAttribute, Vector4, Color, MathUtils, SpotLight, SpotLightHelper, AmbientLight, PointLight, Spherical } from 'three';
8
- import { SimplexNoise, FullScreenQuad, HorizontalBlurShader, VerticalBlurShader, RGBELoader, GroundProjectedEnv, Sky } from 'three-stdlib';
9
- import { NgIf, NgFor, NgTemplateOutlet } from '@angular/common';
10
- import { NgtsEdges, NgtsBillboard } from 'angular-three-soba/abstractions';
11
- import { injectNgtsFBO } from 'angular-three-soba/misc';
12
- import { injectNgtsTextureLoader } from 'angular-three-soba/loaders';
13
-
14
- function isLight(object) {
15
- return object.isLight;
16
- }
17
- function isGeometry(object) {
18
- return !!object.geometry;
19
- }
20
- class ProgressiveLightMap {
21
- constructor(renderer, scene, res = 1024) {
22
- this.renderer = renderer;
23
- this.res = res;
24
- this.scene = scene;
25
- this.buffer1Active = false;
26
- this.lights = [];
27
- this.meshes = [];
28
- this.object = null;
29
- this.clearColor = new THREE.Color();
30
- this.clearAlpha = 0;
31
- // Create the Progressive LightMap Texture
32
- const format = /(Android|iPad|iPhone|iPod)/g.test(navigator.userAgent) ? THREE.HalfFloatType : THREE.FloatType;
33
- this.progressiveLightMap1 = new THREE.WebGLRenderTarget(this.res, this.res, {
34
- type: format,
35
- encoding: renderer.outputEncoding,
36
- });
37
- this.progressiveLightMap2 = new THREE.WebGLRenderTarget(this.res, this.res, {
38
- type: format,
39
- encoding: renderer.outputEncoding,
40
- });
41
- // Inject some spicy new logic into a standard phong material
42
- this.discardMat = new DiscardMaterial();
43
- this.targetMat = new THREE.MeshLambertMaterial({ fog: false });
44
- this.previousShadowMap = { value: this.progressiveLightMap1.texture };
45
- this.averagingWindow = { value: 100 };
46
- this.targetMat.onBeforeCompile = (shader) => {
47
- // Vertex Shader: Set Vertex Positions to the Unwrapped UV Positions
48
- shader.vertexShader =
49
- 'varying vec2 vUv;\n' +
50
- shader.vertexShader.slice(0, -1) +
51
- 'vUv = uv; gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }';
52
- // Fragment Shader: Set Pixels to average in the Previous frame's Shadows
53
- const bodyStart = shader.fragmentShader.indexOf('void main() {');
54
- shader.fragmentShader =
55
- 'varying vec2 vUv;\n' +
56
- shader.fragmentShader.slice(0, bodyStart) +
57
- 'uniform sampler2D previousShadowMap;\n uniform float averagingWindow;\n' +
58
- shader.fragmentShader.slice(bodyStart - 1, -1) +
59
- `\nvec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
60
- gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/ averagingWindow);
61
- }`;
62
- // Set the Previous Frame's Texture Buffer and Averaging Window
63
- shader.uniforms['previousShadowMap'] = this.previousShadowMap;
64
- shader.uniforms['averagingWindow'] = this.averagingWindow;
65
- };
66
- }
67
- clear() {
68
- this.renderer.getClearColor(this.clearColor);
69
- this.clearAlpha = this.renderer.getClearAlpha();
70
- this.renderer.setClearColor('black', 1);
71
- this.renderer.setRenderTarget(this.progressiveLightMap1);
72
- this.renderer.clear();
73
- this.renderer.setRenderTarget(this.progressiveLightMap2);
74
- this.renderer.clear();
75
- this.renderer.setRenderTarget(null);
76
- this.renderer.setClearColor(this.clearColor, this.clearAlpha);
77
- this.lights = [];
78
- this.meshes = [];
79
- this.scene.traverse((object) => {
80
- if (isGeometry(object)) {
81
- this.meshes.push({ object, material: object.material });
82
- }
83
- else if (isLight(object)) {
84
- this.lights.push({ object, intensity: object.intensity });
85
- }
86
- });
87
- }
88
- prepare() {
89
- this.lights.forEach((light) => (light.object.intensity = 0));
90
- this.meshes.forEach((mesh) => (mesh.object.material = this.discardMat));
91
- }
92
- finish() {
93
- this.lights.forEach((light) => (light.object.intensity = light.intensity));
94
- this.meshes.forEach((mesh) => (mesh.object.material = mesh.material));
95
- }
96
- configure(object) {
97
- this.object = object;
98
- }
99
- update(camera, blendWindow = 100) {
100
- if (!this.object)
101
- return;
102
- // Set each object's material to the UV Unwrapped Surface Mapping Version
103
- this.averagingWindow.value = blendWindow;
104
- this.object.material = this.targetMat;
105
- // Ping-pong two surface buffers for reading/writing
106
- const activeMap = this.buffer1Active ? this.progressiveLightMap1 : this.progressiveLightMap2;
107
- const inactiveMap = this.buffer1Active ? this.progressiveLightMap2 : this.progressiveLightMap1;
108
- // Render the object's surface maps
109
- const oldBg = this.scene.background;
110
- this.scene.background = null;
111
- this.renderer.setRenderTarget(activeMap);
112
- this.previousShadowMap.value = inactiveMap.texture;
113
- this.buffer1Active = !this.buffer1Active;
114
- this.renderer.render(this.scene, camera);
115
- this.renderer.setRenderTarget(null);
116
- this.scene.background = oldBg;
117
- }
118
- }
119
-
120
- extend({ SoftShadowMaterial, Group, Mesh, PlaneGeometry });
121
- const NGTS_ACCUMULATIVE_SHADOWS_API = new InjectionToken('NgtsAccumulativeShadows API');
122
- function accumulativeShadowsApiFactory(accumulativeShadows) {
123
- const store = inject(NgtStore);
124
- const api = {
125
- lights: new Map(),
126
- count: 0,
127
- getMesh: () => accumulativeShadows.meshRef.nativeElement,
128
- reset: () => {
129
- accumulativeShadows.pLM.clear();
130
- const material = api.getMesh().material;
131
- material.opacity = 0;
132
- material.alphaTest = 0;
133
- api.count = 0;
134
- },
135
- update: (frames = 1) => {
136
- // adapt the opacity blend ratio to the number of frames
137
- const material = api.getMesh().material;
138
- if (!api.temporal) {
139
- material.opacity = accumulativeShadows.get('opacity');
140
- material.alphaTest = accumulativeShadows.get('alphaTest');
141
- }
142
- else {
143
- material.opacity = Math.min(accumulativeShadows.get('opacity'), material.opacity + accumulativeShadows.get('opacity') / api.blend);
144
- material.alphaTest = Math.min(accumulativeShadows.get('alphaTest'), material.alphaTest + accumulativeShadows.get('alphaTest') / api.blend);
145
- }
146
- // switch accumulative lights on
147
- accumulativeShadows.accumulativeShadowsRef.nativeElement.visible = true;
148
- // collect scene lights and meshes
149
- accumulativeShadows.pLM.prepare();
150
- // update the lightmap and the accumulative lights
151
- for (let i = 0; i < frames; i++) {
152
- api.lights.forEach((light) => light.update());
153
- accumulativeShadows.pLM.update(store.get('camera'), api.blend);
154
- }
155
- // switch lights off
156
- accumulativeShadows.accumulativeShadowsRef.nativeElement.visible = false;
157
- // restore lights and meshes
158
- accumulativeShadows.pLM.finish();
159
- },
160
- };
161
- Object.defineProperties(api, {
162
- temporal: {
163
- get: () => !!accumulativeShadows.get('temporal'),
164
- },
165
- frames: {
166
- get: () => Math.max(2, accumulativeShadows.get('frames')),
167
- },
168
- blend: {
169
- get: () => Math.max(2, accumulativeShadows.get('frames') === Infinity
170
- ? accumulativeShadows.get('blend')
171
- : accumulativeShadows.get('frames')),
172
- },
173
- });
174
- const subject = new Subject();
175
- accumulativeShadows.hold(accumulativeShadows.meshRef.$, (mesh) => {
176
- accumulativeShadows.pLM.configure(mesh);
177
- accumulativeShadows.hold(combineLatest([accumulativeShadows.select(), getLocalState(store.get('scene')).objects]), () => {
178
- // reset internals, buffers, ...
179
- api.reset();
180
- // update lightmap
181
- if (!api.temporal && api.frames !== Infinity)
182
- api.update(api.blend);
183
- });
184
- accumulativeShadows.effect(subject, () => store.get('internal').subscribe(() => {
185
- const limit = accumulativeShadows.get('limit');
186
- if ((api.temporal || api.frames === Infinity) && api.count < api.frames && api.count < limit) {
187
- api.update();
188
- api.count++;
189
- }
190
- }));
191
- subject.next();
192
- });
193
- return api;
194
- }
195
- class AccumulativeShadowsConsumer {
196
- constructor() {
197
- inject(NGTS_ACCUMULATIVE_SHADOWS_API);
198
- }
199
- }
200
- AccumulativeShadowsConsumer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: AccumulativeShadowsConsumer, deps: [], target: i0.ɵɵFactoryTarget.Directive });
201
- AccumulativeShadowsConsumer.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: AccumulativeShadowsConsumer, isStandalone: true, selector: "[ngtsAccumulativeShadowsConsumer]", ngImport: i0 });
202
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: AccumulativeShadowsConsumer, decorators: [{
203
- type: Directive,
204
- args: [{ selector: '[ngtsAccumulativeShadowsConsumer]', standalone: true }]
205
- }], ctorParameters: function () { return []; } });
206
- class NgtsAccumulativeShadows extends NgtRxStore {
207
- constructor() {
208
- super(...arguments);
209
- this.nullTraverse = () => null;
210
- this.Math = Math;
211
- this.store = inject(NgtStore);
212
- this.pLM = new ProgressiveLightMap(this.store.get('gl'), this.store.get('scene'), this.get('resolution'));
213
- this.accumulativeShadowsRef = injectNgtRef();
214
- this.meshRef = injectNgtRef();
215
- }
216
- /** How many frames it can render, more yields cleaner results but takes more time, 40 */
217
- set frames(frames) {
218
- this.set({ frames });
219
- }
220
- /** If frames === Infinity blend controls the refresh ratio, 100 */
221
- set blend(blend) {
222
- this.set({ blend });
223
- }
224
- /** Can limit the amount of frames rendered if frames === Infinity, usually to get some performance back once a movable scene has settled, Infinity */
225
- set limit(limit) {
226
- this.set({ limit });
227
- }
228
- /** Scale of the plane, */
229
- set scale(scale) {
230
- this.set({ scale });
231
- }
232
- /** Temporal accumulates shadows over time which is more performant but has a visual regression over instant results, false */
233
- set temporal(temporal) {
234
- this.set({ temporal });
235
- }
236
- /** Opacity of the plane, 1 */
237
- set opacity(opacity) {
238
- this.set({ opacity });
239
- }
240
- /** Discards alpha pixels, 0.65 */
241
- set alphaTest(alphaTest) {
242
- this.set({ alphaTest });
243
- }
244
- /** Shadow color, black */
245
- set color(color) {
246
- this.set({ color });
247
- }
248
- /** Colorblend, how much colors turn to black, 0 is black, 2 */
249
- set colorBlend(colorBlend) {
250
- this.set({ colorBlend });
251
- }
252
- /** Buffer resolution, 1024 */
253
- set resolution(resolution) {
254
- this.set({ resolution });
255
- }
256
- /** Texture tonemapping */
257
- set toneMapped(toneMapped) {
258
- this.set({ toneMapped });
259
- }
260
- initialize() {
261
- super.initialize();
262
- this.set({
263
- frames: 40,
264
- limit: Infinity,
265
- blend: 20,
266
- scale: 10,
267
- opacity: 1,
268
- alphaTest: 0.75,
269
- color: 'black',
270
- colorBlend: 2,
271
- resolution: 1024,
272
- toneMapped: true,
273
- });
274
- }
275
- }
276
- NgtsAccumulativeShadows.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsAccumulativeShadows, deps: null, target: i0.ɵɵFactoryTarget.Component });
277
- NgtsAccumulativeShadows.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsAccumulativeShadows, isStandalone: true, selector: "ngts-accumulative-shadows", inputs: { frames: "frames", blend: "blend", limit: "limit", scale: "scale", temporal: "temporal", opacity: "opacity", alphaTest: "alphaTest", color: "color", colorBlend: "colorBlend", resolution: "resolution", toneMapped: "toneMapped" }, providers: [
278
- {
279
- provide: NGTS_ACCUMULATIVE_SHADOWS_API,
280
- useFactory: accumulativeShadowsApiFactory,
281
- deps: [NgtsAccumulativeShadows],
282
- },
283
- ], usesInheritance: true, ngImport: i0, template: `
284
- <ngt-group ngtCompound>
285
- <ngt-group [ref]="accumulativeShadowsRef" [traverse]="nullTraverse">
286
- <ng-content />
287
- <ng-container ngtsAccumulativeShadowsConsumer />
288
- </ngt-group>
289
- <ngt-mesh [ref]="meshRef" [receiveShadow]="true" [scale]="get('scale')" [rotation]="[-Math.PI / 2, 0, 0]">
290
- <ngt-plane-geometry />
291
- <ngt-soft-shadow-material
292
- [transparent]="true"
293
- [depthWrite]="false"
294
- [color]="get('color')"
295
- [toneMapped]="get('toneMapped')"
296
- [blend]="get('colorBlend')"
297
- [map]="pLM.progressiveLightMap2.texture"
298
- />
299
- </ngt-mesh>
300
- </ngt-group>
301
- `, isInline: true, dependencies: [{ kind: "directive", type: AccumulativeShadowsConsumer, selector: "[ngtsAccumulativeShadowsConsumer]" }] });
302
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsAccumulativeShadows, decorators: [{
303
- type: Component,
304
- args: [{
305
- selector: 'ngts-accumulative-shadows',
306
- standalone: true,
307
- template: `
308
- <ngt-group ngtCompound>
309
- <ngt-group [ref]="accumulativeShadowsRef" [traverse]="nullTraverse">
310
- <ng-content />
311
- <ng-container ngtsAccumulativeShadowsConsumer />
312
- </ngt-group>
313
- <ngt-mesh [ref]="meshRef" [receiveShadow]="true" [scale]="get('scale')" [rotation]="[-Math.PI / 2, 0, 0]">
314
- <ngt-plane-geometry />
315
- <ngt-soft-shadow-material
316
- [transparent]="true"
317
- [depthWrite]="false"
318
- [color]="get('color')"
319
- [toneMapped]="get('toneMapped')"
320
- [blend]="get('colorBlend')"
321
- [map]="pLM.progressiveLightMap2.texture"
322
- />
323
- </ngt-mesh>
324
- </ngt-group>
325
- `,
326
- imports: [AccumulativeShadowsConsumer],
327
- providers: [
328
- {
329
- provide: NGTS_ACCUMULATIVE_SHADOWS_API,
330
- useFactory: accumulativeShadowsApiFactory,
331
- deps: [NgtsAccumulativeShadows],
332
- },
333
- ],
334
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
335
- }]
336
- }], propDecorators: { frames: [{
337
- type: Input
338
- }], blend: [{
339
- type: Input
340
- }], limit: [{
341
- type: Input
342
- }], scale: [{
343
- type: Input
344
- }], temporal: [{
345
- type: Input
346
- }], opacity: [{
347
- type: Input
348
- }], alphaTest: [{
349
- type: Input
350
- }], color: [{
351
- type: Input
352
- }], colorBlend: [{
353
- type: Input
354
- }], resolution: [{
355
- type: Input
356
- }], toneMapped: [{
357
- type: Input
358
- }] } });
359
-
360
- extend({ Group, DirectionalLight, OrthographicCamera, Vector2 });
361
- const NGTS_RANDOMIZED_LIGHTS_API = new InjectionToken('NgtsRandomizedLights API');
362
- function randomizedLightsApiFactory(randomizedLights) {
363
- const accumulativeApi = inject(NGTS_ACCUMULATIVE_SHADOWS_API);
364
- const update = () => {
365
- let light;
366
- if (randomizedLights.lightsRef.nativeElement) {
367
- for (let l = 0; l < randomizedLights.lightsRef.nativeElement.children.length; l++) {
368
- light = randomizedLights.lightsRef.nativeElement.children[l];
369
- if (Math.random() > randomizedLights.get('ambient')) {
370
- const position = randomizedLights.get('position');
371
- const radius = randomizedLights.get('radius');
372
- light.position.set(position[0] + THREE.MathUtils.randFloatSpread(radius), position[1] + THREE.MathUtils.randFloatSpread(radius), position[2] + THREE.MathUtils.randFloatSpread(radius));
373
- }
374
- else {
375
- const lambda = Math.acos(2 * Math.random() - 1) - Math.PI / 2.0;
376
- const phi = 2 * Math.PI * Math.random();
377
- const length = randomizedLights.get('length');
378
- light.position.set(Math.cos(lambda) * Math.cos(phi) * length, Math.abs(Math.cos(lambda) * Math.sin(phi) * length), Math.sin(lambda) * length);
379
- }
380
- }
381
- }
382
- };
383
- const api = { update };
384
- randomizedLights.effect(combineLatest([
385
- randomizedLights.lightsRef.$,
386
- randomizedLights.select('position'),
387
- randomizedLights.select('radius'),
388
- randomizedLights.select('length'),
389
- randomizedLights.select('ambient'),
390
- ]), ([group]) => {
391
- if (accumulativeApi)
392
- accumulativeApi.lights.set(group.uuid, api);
393
- return () => accumulativeApi.lights.delete(group.uuid);
394
- });
395
- return api;
396
- }
397
- class RandomizedLightsConsumer {
398
- constructor() {
399
- inject(NGTS_RANDOMIZED_LIGHTS_API);
400
- }
401
- }
402
- RandomizedLightsConsumer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: RandomizedLightsConsumer, deps: [], target: i0.ɵɵFactoryTarget.Directive });
403
- RandomizedLightsConsumer.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: RandomizedLightsConsumer, isStandalone: true, selector: "[ngtsRandomizedLightsConsumer]", ngImport: i0 });
404
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: RandomizedLightsConsumer, decorators: [{
405
- type: Directive,
406
- args: [{ selector: '[ngtsRandomizedLightsConsumer]', standalone: true }]
407
- }], ctorParameters: function () { return []; } });
408
- class NgtsRandomizedLights extends NgtRxStore {
409
- constructor() {
410
- super(...arguments);
411
- this.lightsRef = injectNgtRef();
412
- }
413
- /** How many frames it will jiggle the lights, 1.
414
- * Frames is context aware, if a provider like AccumulativeShadows exists, frames will be taken from there! */
415
- set frames(frames) {
416
- this.set({ frames });
417
- }
418
- /** Light position, [0, 0, 0] */
419
- set position(position) {
420
- this.set({ position });
421
- }
422
- /** Radius of the jiggle, higher values make softer light, 5 */
423
- set radius(radius) {
424
- this.set({ radius });
425
- }
426
- /** Amount of lights, 8 */
427
- set amount(amount) {
428
- this.set({ amount });
429
- }
430
- /** Light intensity, 1 */
431
- set intensity(intensity) {
432
- this.set({ intensity });
433
- }
434
- /** Ambient occlusion, lower values mean less AO, hight more, you can mix AO and directional light, 0.5 */
435
- set ambient(ambient) {
436
- this.set({ ambient });
437
- }
438
- /** If the lights cast shadows, this is true by default */
439
- set castShadow(castShadow) {
440
- this.set({ castShadow });
441
- }
442
- /** Default shadow bias, 0 */
443
- set bias(bias) {
444
- this.set({ bias });
445
- }
446
- /** Default map size, 512 */
447
- set mapSize(mapSize) {
448
- this.set({ mapSize });
449
- }
450
- /** Default size of the shadow camera, 10 */
451
- set size(size) {
452
- this.set({ size });
453
- }
454
- /** Default shadow camera near, 0.5 */
455
- set near(near) {
456
- this.set({ near });
457
- }
458
- /** Default shadow camera far, 500 */
459
- set far(far) {
460
- this.set({ far });
461
- }
462
- initialize() {
463
- super.initialize();
464
- this.set({
465
- castShadow: true,
466
- bias: 0.001,
467
- mapSize: 512,
468
- size: 5,
469
- near: 0.5,
470
- far: 500,
471
- frames: 1,
472
- position: [0, 0, 0],
473
- radius: 1,
474
- amount: 8,
475
- intensity: 1,
476
- ambient: 0.5,
477
- });
478
- this.connect('cameraArgs', this.select(['size', 'near', 'far'], ({ size, near, far }) => [-size, size, size, -size, near, far]));
479
- this.connect('length', this.select(['position'], ({ position }) => new THREE.Vector3(...position).length()));
480
- }
481
- }
482
- NgtsRandomizedLights.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsRandomizedLights, deps: null, target: i0.ɵɵFactoryTarget.Component });
483
- NgtsRandomizedLights.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsRandomizedLights, isStandalone: true, selector: "ngts-randomized-lights", inputs: { lightsRef: "lightsRef", frames: "frames", position: "position", radius: "radius", amount: "amount", intensity: "intensity", ambient: "ambient", castShadow: "castShadow", bias: "bias", mapSize: "mapSize", size: "size", near: "near", far: "far" }, providers: [
484
- { provide: NGTS_RANDOMIZED_LIGHTS_API, useFactory: randomizedLightsApiFactory, deps: [NgtsRandomizedLights] },
485
- ], usesInheritance: true, ngImport: i0, template: `
486
- <ngt-group ngtCompound [ref]="lightsRef">
487
- <ngt-directional-light
488
- *ngFor="let i; repeat: get('amount')"
489
- [castShadow]="get('castShadow')"
490
- [intensity]="get('intensity') / get('amount')"
491
- >
492
- <ngt-value [rawValue]="get('bias')" attach="shadow.bias" />
493
- <ngt-vector2 *args="[get('mapSize'), get('mapSize')]" attach="shadow.mapSize" />
494
- <ngt-orthographic-camera *args="get('cameraArgs')" attach="shadow.camera" />
495
- </ngt-directional-light>
496
- <ng-container ngtsRandomizedLightsConsumer />
497
- </ngt-group>
498
- `, isInline: true, dependencies: [{ kind: "directive", type: RandomizedLightsConsumer, selector: "[ngtsRandomizedLightsConsumer]" }, { kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }, { kind: "directive", type: NgtRepeat, selector: "[ngFor][ngForRepeat]", inputs: ["ngForRepeat"] }] });
499
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsRandomizedLights, decorators: [{
500
- type: Component,
501
- args: [{
502
- selector: 'ngts-randomized-lights',
503
- standalone: true,
504
- template: `
505
- <ngt-group ngtCompound [ref]="lightsRef">
506
- <ngt-directional-light
507
- *ngFor="let i; repeat: get('amount')"
508
- [castShadow]="get('castShadow')"
509
- [intensity]="get('intensity') / get('amount')"
510
- >
511
- <ngt-value [rawValue]="get('bias')" attach="shadow.bias" />
512
- <ngt-vector2 *args="[get('mapSize'), get('mapSize')]" attach="shadow.mapSize" />
513
- <ngt-orthographic-camera *args="get('cameraArgs')" attach="shadow.camera" />
514
- </ngt-directional-light>
515
- <ng-container ngtsRandomizedLightsConsumer />
516
- </ngt-group>
517
- `,
518
- imports: [RandomizedLightsConsumer, NgtArgs, NgtRepeat],
519
- providers: [
520
- { provide: NGTS_RANDOMIZED_LIGHTS_API, useFactory: randomizedLightsApiFactory, deps: [NgtsRandomizedLights] },
521
- ],
522
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
523
- }]
524
- }], propDecorators: { lightsRef: [{
525
- type: Input
526
- }], frames: [{
527
- type: Input
528
- }], position: [{
529
- type: Input
530
- }], radius: [{
531
- type: Input
532
- }], amount: [{
533
- type: Input
534
- }], intensity: [{
535
- type: Input
536
- }], ambient: [{
537
- type: Input
538
- }], castShadow: [{
539
- type: Input
540
- }], bias: [{
541
- type: Input
542
- }], mapSize: [{
543
- type: Input
544
- }], size: [{
545
- type: Input
546
- }], near: [{
547
- type: Input
548
- }], far: [{
549
- type: Input
550
- }] } });
551
-
552
- const isBox3 = (def) => !!def && def.isBox3;
553
- function equals(a, b, eps) {
554
- return Math.abs(a.x - b.x) < eps && Math.abs(a.y - b.y) < eps && Math.abs(a.z - b.z) < eps;
555
- }
556
- function damp(v, t, lambda, delta) {
557
- v.x = THREE.MathUtils.damp(v.x, t.x, lambda, delta);
558
- v.y = THREE.MathUtils.damp(v.y, t.y, lambda, delta);
559
- v.z = THREE.MathUtils.damp(v.z, t.z, lambda, delta);
560
- }
561
- const NGTS_BOUNDS_API = new InjectionToken('NgtsBounds API');
562
- function boundsApiFactory(bounds) {
563
- const store = inject(NgtStore);
564
- const box = new THREE.Box3();
565
- function getSize() {
566
- const camera = store.get('camera');
567
- const margin = bounds.get('margin');
568
- const size = box.getSize(new THREE.Vector3());
569
- const center = box.getCenter(new THREE.Vector3());
570
- const maxSize = Math.max(size.x, size.y, size.z);
571
- const fitHeightDistance = is.orthographicCamera(camera)
572
- ? maxSize * 4
573
- : maxSize / (2 * Math.atan((Math.PI * camera.fov) / 360));
574
- const fitWidthDistance = is.orthographicCamera(camera) ? maxSize * 4 : fitHeightDistance / camera.aspect;
575
- const distance = margin * Math.max(fitHeightDistance, fitWidthDistance);
576
- return { box, size, center, distance };
577
- }
578
- const api = {
579
- getSize,
580
- refresh(object) {
581
- const { camera, controls: storeControls } = store.get();
582
- const controls = storeControls;
583
- if (isBox3(object))
584
- box.copy(object);
585
- else {
586
- const target = object || bounds.boundsRef.nativeElement;
587
- if (target) {
588
- target.updateWorldMatrix(true, true);
589
- box.setFromObject(target);
590
- }
591
- }
592
- if (box.isEmpty()) {
593
- const max = camera.position.length() || 10;
594
- box.setFromCenterAndSize(new THREE.Vector3(), new THREE.Vector3(max, max, max));
595
- }
596
- if ((controls === null || controls === void 0 ? void 0 : controls.constructor.name) === 'OrthographicTrackballControls') {
597
- // put camera on a sphere along which it would move
598
- const { distance } = getSize();
599
- const direction = camera.position.clone().sub(controls.target).normalize().multiplyScalar(distance);
600
- const newPos = controls.target.clone().add(direction);
601
- camera.position.copy(newPos);
602
- }
603
- return this;
604
- },
605
- clip() {
606
- const { distance } = getSize();
607
- const { camera, controls: storeControls, invalidate } = store.get();
608
- const controls = storeControls;
609
- if (controls)
610
- controls.maxDistance = distance * 10;
611
- camera.near = distance / 100;
612
- camera.far = distance * 100;
613
- camera.updateProjectionMatrix();
614
- if (controls)
615
- controls.update();
616
- invalidate();
617
- return this;
618
- },
619
- to({ position, target }) {
620
- const { camera } = store.get();
621
- const { damping } = bounds.get();
622
- bounds.current.camera.copy(camera.position);
623
- const { center } = getSize();
624
- bounds.goal.camera.set(...position);
625
- if (target) {
626
- bounds.goal.focus.set(...target);
627
- }
628
- else {
629
- bounds.goal.focus.copy(center);
630
- }
631
- if (damping) {
632
- bounds.current.animating = true;
633
- }
634
- else {
635
- camera.position.set(...position);
636
- }
637
- return this;
638
- },
639
- fit() {
640
- const { camera, controls: storeControls, invalidate } = store.get();
641
- const controls = storeControls;
642
- const { damping, margin } = bounds.get();
643
- bounds.current.camera.copy(camera.position);
644
- if (controls)
645
- bounds.current.focus.copy(controls.target);
646
- const { center, distance } = getSize();
647
- const direction = center.clone().sub(camera.position).normalize().multiplyScalar(distance);
648
- bounds.goal.camera.copy(center).sub(direction);
649
- bounds.goal.focus.copy(center);
650
- if (is.orthographicCamera(camera)) {
651
- bounds.current.zoom = camera.zoom;
652
- let maxHeight = 0, maxWidth = 0;
653
- const vertices = [
654
- new THREE.Vector3(box.min.x, box.min.y, box.min.z),
655
- new THREE.Vector3(box.min.x, box.max.y, box.min.z),
656
- new THREE.Vector3(box.min.x, box.min.y, box.max.z),
657
- new THREE.Vector3(box.min.x, box.max.y, box.max.z),
658
- new THREE.Vector3(box.max.x, box.max.y, box.max.z),
659
- new THREE.Vector3(box.max.x, box.max.y, box.min.z),
660
- new THREE.Vector3(box.max.x, box.min.y, box.max.z),
661
- new THREE.Vector3(box.max.x, box.min.y, box.min.z),
662
- ];
663
- // Transform the center and each corner to camera space
664
- center.applyMatrix4(camera.matrixWorldInverse);
665
- for (const v of vertices) {
666
- v.applyMatrix4(camera.matrixWorldInverse);
667
- maxHeight = Math.max(maxHeight, Math.abs(v.y - center.y));
668
- maxWidth = Math.max(maxWidth, Math.abs(v.x - center.x));
669
- }
670
- maxHeight *= 2;
671
- maxWidth *= 2;
672
- const zoomForHeight = (camera.top - camera.bottom) / maxHeight;
673
- const zoomForWidth = (camera.right - camera.left) / maxWidth;
674
- bounds.goal.zoom = Math.min(zoomForHeight, zoomForWidth) / margin;
675
- if (!damping) {
676
- camera.zoom = bounds.goal.zoom;
677
- camera.updateProjectionMatrix();
678
- }
679
- }
680
- if (damping) {
681
- bounds.current.animating = true;
682
- }
683
- else {
684
- camera.position.copy(bounds.goal.camera);
685
- camera.lookAt(bounds.goal.focus);
686
- if (controls) {
687
- controls.target.copy(bounds.goal.focus);
688
- controls.update();
689
- }
690
- }
691
- if (bounds.fitted.observed)
692
- bounds.fitted.emit(this.getSize());
693
- invalidate();
694
- return this;
695
- },
696
- };
697
- let count = 0;
698
- bounds.hold(bounds.boundsRef.$.pipe(switchMap(() => combineLatest([
699
- bounds.select('clip'),
700
- bounds.select('fit'),
701
- bounds.select('observe'),
702
- store.select('camera'),
703
- store.select('controls'),
704
- store.select('size'),
705
- bounds.boundsRef.children$(),
706
- ]))), ([clip, fit, observe]) => {
707
- if (observe || count++ === 0) {
708
- api.refresh();
709
- if (fit)
710
- api.fit();
711
- if (clip)
712
- api.clip();
713
- }
714
- });
715
- injectBeforeRender(({ delta }) => {
716
- if (bounds.current.animating) {
717
- const { damping, eps } = bounds.get();
718
- const { camera, controls: storeControls, invalidate } = store.get();
719
- const controls = storeControls;
720
- damp(bounds.current.focus, bounds.goal.focus, damping, delta);
721
- damp(bounds.current.camera, bounds.goal.camera, damping, delta);
722
- bounds.current.zoom = THREE.MathUtils.damp(bounds.current.zoom, bounds.goal.zoom, damping, delta);
723
- camera.position.copy(bounds.current.camera);
724
- if (is.orthographicCamera(camera)) {
725
- camera.zoom = bounds.current.zoom;
726
- camera.updateProjectionMatrix();
727
- }
728
- if (!controls) {
729
- camera.lookAt(bounds.current.focus);
730
- }
731
- else {
732
- controls.target.copy(bounds.current.focus);
733
- controls.update();
734
- }
735
- invalidate();
736
- if (is.orthographicCamera(camera) && !(Math.abs(bounds.current.zoom - bounds.goal.zoom) < eps))
737
- return;
738
- if (!is.orthographicCamera(camera) && !equals(bounds.current.camera, bounds.goal.camera, eps))
739
- return;
740
- if (controls && !equals(bounds.current.focus, bounds.goal.focus, eps))
741
- return;
742
- bounds.current.animating = false;
743
- }
744
- });
745
- return api;
746
- }
747
- extend({ Group });
748
- class NgtsBounds extends NgtRxStore {
749
- constructor() {
750
- super(...arguments);
751
- this.boundsRef = injectNgtRef();
752
- this.fitted = new EventEmitter();
753
- this.store = inject(NgtStore);
754
- this.current = { animating: false, focus: new THREE.Vector3(), camera: new THREE.Vector3(), zoom: 1 };
755
- this.goal = { focus: new THREE.Vector3(), camera: new THREE.Vector3(), zoom: 1 };
756
- }
757
- set damping(damping) {
758
- this.set({ damping });
759
- }
760
- set fit(fit) {
761
- this.set({ fit });
762
- }
763
- set clip(clip) {
764
- this.set({ clip });
765
- }
766
- set observe(observe) {
767
- this.set({ observe });
768
- }
769
- set margin(margin) {
770
- this.set({ margin });
771
- }
772
- set eps(eps) {
773
- this.set({ eps });
774
- }
775
- initialize() {
776
- super.initialize();
777
- this.set({ damping: 6, fit: false, clip: false, observe: false, margin: 1.2, eps: 0.01 });
778
- }
779
- ngOnInit() {
780
- this.preventDragHijacking();
781
- }
782
- preventDragHijacking() {
783
- this.effect(this.store.select('controls'), (controls) => {
784
- if (controls) {
785
- const callback = () => (this.current.animating = false);
786
- controls.addEventListener('start', callback);
787
- return () => controls.removeEventListener('start', callback);
788
- }
789
- });
790
- }
791
- }
792
- NgtsBounds.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsBounds, deps: null, target: i0.ɵɵFactoryTarget.Component });
793
- NgtsBounds.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsBounds, isStandalone: true, selector: "ngts-bounds", inputs: { boundsRef: "boundsRef", damping: "damping", fit: "fit", clip: "clip", observe: "observe", margin: "margin", eps: "eps" }, outputs: { fitted: "fitted" }, providers: [{ provide: NGTS_BOUNDS_API, useFactory: boundsApiFactory, deps: [NgtsBounds] }], usesInheritance: true, ngImport: i0, template: `
794
- <ngt-group ngtCompound [ref]="boundsRef">
795
- <ng-content />
796
- </ngt-group>
797
- `, isInline: true });
798
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsBounds, decorators: [{
799
- type: Component,
800
- args: [{
801
- selector: 'ngts-bounds',
802
- standalone: true,
803
- template: `
804
- <ngt-group ngtCompound [ref]="boundsRef">
805
- <ng-content />
806
- </ngt-group>
807
- `,
808
- providers: [{ provide: NGTS_BOUNDS_API, useFactory: boundsApiFactory, deps: [NgtsBounds] }],
809
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
810
- }]
811
- }], propDecorators: { boundsRef: [{
812
- type: Input
813
- }], damping: [{
814
- type: Input
815
- }], fit: [{
816
- type: Input
817
- }], clip: [{
818
- type: Input
819
- }], observe: [{
820
- type: Input
821
- }], margin: [{
822
- type: Input
823
- }], eps: [{
824
- type: Input
825
- }], fitted: [{
826
- type: Output
827
- }] } });
828
-
829
- class NgtsCameraShake extends NgtRxStore {
830
- set intensity(intensity) {
831
- this.set({ intensity });
832
- }
833
- set decay(decay) {
834
- this.set({ decay });
835
- }
836
- set decayRate(decayRate) {
837
- this.set({ decayRate });
838
- }
839
- set maxYaw(maxYaw) {
840
- this.set({ maxYaw });
841
- }
842
- set maxPitch(maxPitch) {
843
- this.set({ maxPitch });
844
- }
845
- set maxRoll(maxRoll) {
846
- this.set({ maxRoll });
847
- }
848
- set yawFrequency(yawFrequency) {
849
- this.set({ yawFrequency });
850
- }
851
- set pitchFrequency(pitchFrequency) {
852
- this.set({ pitchFrequency });
853
- }
854
- set rollFrequency(rollFrequency) {
855
- this.set({ rollFrequency });
856
- }
857
- initialize() {
858
- super.initialize();
859
- this.set({
860
- intensity: 1,
861
- decayRate: 0.65,
862
- maxYaw: 0.1,
863
- maxPitch: 0.1,
864
- maxRoll: 0.1,
865
- yawFrequency: 0.1,
866
- pitchFrequency: 0.1,
867
- rollFrequency: 0.1,
868
- });
869
- }
870
- constructor() {
871
- super();
872
- this.store = inject(NgtStore);
873
- this.initialRotation = this.store.get('camera').rotation.clone();
874
- this.yawNoise = new SimplexNoise();
875
- this.pitchNoise = new SimplexNoise();
876
- this.rollNoise = new SimplexNoise();
877
- injectBeforeRender(({ clock, delta, camera }) => {
878
- const { intensity, maxYaw, maxPitch, maxRoll, yawFrequency, pitchFrequency, rollFrequency, decay, decayRate, } = this.get();
879
- const shake = Math.pow(intensity, 2);
880
- const yaw = maxYaw * shake * this.yawNoise.noise(clock.elapsedTime * yawFrequency, 1);
881
- const pitch = maxPitch * shake * this.pitchNoise.noise(clock.elapsedTime * pitchFrequency, 1);
882
- const roll = maxRoll * shake * this.rollNoise.noise(clock.elapsedTime * rollFrequency, 1);
883
- camera.rotation.set(this.initialRotation.x + pitch, this.initialRotation.y + yaw, this.initialRotation.z + roll);
884
- if (decay && intensity > 0) {
885
- this.set({ intensity: intensity - decayRate * delta });
886
- this.constraintIntensity();
887
- }
888
- });
889
- }
890
- ngOnInit() {
891
- this.setChangeEvent();
892
- }
893
- setChangeEvent() {
894
- this.effect(combineLatest([this.store.select('camera'), this.store.select('controls')]), ([camera, controls]) => {
895
- if (controls) {
896
- const callback = () => void (this.initialRotation = camera.rotation.clone());
897
- controls.addEventListener('change', callback);
898
- callback();
899
- return () => void controls.removeEventListener('change', callback);
900
- }
901
- });
902
- }
903
- getIntensity() {
904
- return this.get('intensity');
905
- }
906
- setIntensity(intensity) {
907
- this.set({ intensity });
908
- this.constraintIntensity();
909
- }
910
- constraintIntensity() {
911
- const intensity = this.get('intensity');
912
- if (intensity < 0 || intensity > 1) {
913
- this.set({ intensity: intensity < 0 ? 0 : 1 });
914
- }
915
- }
916
- }
917
- NgtsCameraShake.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsCameraShake, deps: [], target: i0.ɵɵFactoryTarget.Directive });
918
- NgtsCameraShake.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtsCameraShake, isStandalone: true, selector: "ngts-camera-shake", inputs: { intensity: "intensity", decay: "decay", decayRate: "decayRate", maxYaw: "maxYaw", maxPitch: "maxPitch", maxRoll: "maxRoll", yawFrequency: "yawFrequency", pitchFrequency: "pitchFrequency", rollFrequency: "rollFrequency" }, usesInheritance: true, ngImport: i0 });
919
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsCameraShake, decorators: [{
920
- type: Directive,
921
- args: [{
922
- selector: 'ngts-camera-shake',
923
- standalone: true,
924
- }]
925
- }], ctorParameters: function () { return []; }, propDecorators: { intensity: [{
926
- type: Input
927
- }], decay: [{
928
- type: Input
929
- }], decayRate: [{
930
- type: Input
931
- }], maxYaw: [{
932
- type: Input
933
- }], maxPitch: [{
934
- type: Input
935
- }], maxRoll: [{
936
- type: Input
937
- }], yawFrequency: [{
938
- type: Input
939
- }], pitchFrequency: [{
940
- type: Input
941
- }], rollFrequency: [{
942
- type: Input
943
- }] } });
944
-
945
- extend({ Group, Scene, Mesh, PlaneGeometry, OrthographicCamera, CausticsProjectionMaterial, LineBasicMaterial });
946
- const NORMALPROPS = {
947
- depth: true,
948
- minFilter: THREE.LinearFilter,
949
- magFilter: THREE.LinearFilter,
950
- encoding: THREE.LinearEncoding,
951
- type: THREE.UnsignedByteType,
952
- };
953
- const CAUSTICPROPS = {
954
- minFilter: THREE.LinearMipmapLinearFilter,
955
- magFilter: THREE.LinearFilter,
956
- encoding: THREE.LinearEncoding,
957
- format: THREE.RGBAFormat,
958
- type: THREE.FloatType,
959
- generateMipmaps: true,
960
- };
961
- function createNormalMaterial(side = THREE.FrontSide) {
962
- const viewMatrix = { value: new THREE.Matrix4() };
963
- return Object.assign(new THREE.MeshNormalMaterial({ side }), {
964
- viewMatrix,
965
- onBeforeCompile: (shader) => {
966
- shader.uniforms.viewMatrix = viewMatrix;
967
- shader.fragmentShader =
968
- `vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
969
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
970
- }\n` +
971
- shader.fragmentShader.replace('#include <normal_fragment_maps>', `#include <normal_fragment_maps>
972
- normal = inverseTransformDirection( normal, viewMatrix );\n`);
973
- },
974
- });
975
- }
976
- class NgtsCaustics extends NgtRxStore {
977
- constructor() {
978
- super(...arguments);
979
- this.CustomBlending = THREE.CustomBlending;
980
- this.OneFactor = THREE.OneFactor;
981
- this.SrcAlphaFactor = THREE.SrcAlphaFactor;
982
- this.Math = Math;
983
- this.planeRef = injectNgtRef();
984
- this.sceneRef = injectNgtRef();
985
- this.cameraRef = injectNgtRef();
986
- this.causticsRef = injectNgtRef();
987
- this.normalTargetFbo = injectNgtsFBO(() => this.select('resolution').pipe(map((resolution) => ({ width: resolution, height: resolution, settings: NORMALPROPS }))));
988
- this.normalTargetBFbo = injectNgtsFBO(() => this.select('resolution').pipe(map((resolution) => ({ width: resolution, height: resolution, settings: NORMALPROPS }))));
989
- this.causticsTargetFbo = injectNgtsFBO(() => this.select('resolution').pipe(map((resolution) => ({ width: resolution, height: resolution, settings: CAUSTICPROPS }))));
990
- this.causticsTargetBFbo = injectNgtsFBO(() => this.select('resolution').pipe(map((resolution) => ({ width: resolution, height: resolution, settings: CAUSTICPROPS }))));
991
- this.store = inject(NgtStore);
992
- }
993
- /** How many frames it will render, set it to Infinity for runtime, default: 1 */
994
- set frames(frames) {
995
- this.set({ frames });
996
- }
997
- /** Enables visual cues to help you stage your scene, default: false */
998
- set debug(debug) {
999
- this.set({ debug });
1000
- }
1001
- /** Will display caustics only and skip the models, default: false */
1002
- set causticsOnly(causticsOnly) {
1003
- this.set({ causticsOnly });
1004
- }
1005
- /** Will include back faces and enable the backsideIOR prop, default: false */
1006
- set backside(backside) {
1007
- this.set({ backside });
1008
- }
1009
- /** The IOR refraction index, default: 1.1 */
1010
- set ior(ior) {
1011
- this.set({ ior });
1012
- }
1013
- /** The IOR refraction index for back faces (only available when backside is enabled), default: 1.1 */
1014
- set backsideIOR(backsideIOR) {
1015
- this.set({ backsideIOR });
1016
- }
1017
- /** The texel size, default: 0.3125 */
1018
- set worldRadius(worldRadius) {
1019
- this.set({ worldRadius });
1020
- }
1021
- /** Intensity of the prjected caustics, default: 0.05 */
1022
- set intensity(intensity) {
1023
- this.set({ intensity });
1024
- }
1025
- /** Caustics color, default: white */
1026
- set color(color) {
1027
- this.set({ color });
1028
- }
1029
- /** Buffer resolution, default: 2048 */
1030
- set resolution(resolution) {
1031
- this.set({ resolution });
1032
- }
1033
- /** Camera position, it will point towards the contents bounds center, default: [5, 5, 5] */
1034
- set lightSource(lightSource) {
1035
- this.set({ lightSource });
1036
- }
1037
- initialize() {
1038
- this.set({
1039
- frames: 1,
1040
- ior: 1.1,
1041
- color: 'white',
1042
- causticsOnly: false,
1043
- backside: false,
1044
- backsideIOR: 1.1,
1045
- worldRadius: 0.3125,
1046
- intensity: 0.05,
1047
- resolution: 2024,
1048
- lightSource: [5, 5, 5],
1049
- });
1050
- }
1051
- ngOnInit() {
1052
- this.updateWorldMatrix();
1053
- this.setBeforeRender();
1054
- }
1055
- updateWorldMatrix() {
1056
- this.hold(combineLatest([this.sceneRef.children$(), this.causticsRef.$, this.causticsRef.children$(), this.select()]), () => {
1057
- if (this.causticsRef.nativeElement) {
1058
- this.causticsRef.nativeElement.updateWorldMatrix(false, true);
1059
- }
1060
- });
1061
- }
1062
- setBeforeRender() {
1063
- const causticsMaterial = new CausticsMaterial();
1064
- const causticsQuad = new FullScreenQuad(causticsMaterial);
1065
- const normalMaterial = createNormalMaterial();
1066
- const normalMaterialB = createNormalMaterial(THREE.BackSide);
1067
- this.effect(combineLatest([
1068
- this.sceneRef.$,
1069
- this.sceneRef.children$(),
1070
- this.causticsRef.$,
1071
- this.cameraRef.$,
1072
- this.normalTargetFbo.$,
1073
- this.normalTargetBFbo.$,
1074
- this.causticsTargetFbo.$,
1075
- this.causticsTargetBFbo.$,
1076
- this.planeRef.$,
1077
- this.planeRef.children$('both'),
1078
- ]), ([scene, children, caustics, camera, normalTarget, normalTargetB, causticsTarget, causticsTargetB, plane,]) => {
1079
- caustics.updateWorldMatrix(false, true);
1080
- if (children.length > 1) {
1081
- const v = new THREE.Vector3();
1082
- const lpF = new THREE.Frustum();
1083
- const lpM = new THREE.Matrix4();
1084
- const lpP = new THREE.Plane();
1085
- const lightDir = new THREE.Vector3();
1086
- const lightDirInv = new THREE.Vector3();
1087
- const bounds = new THREE.Box3();
1088
- const focusPos = new THREE.Vector3();
1089
- let count = 0;
1090
- return this.store.get('internal').subscribe(({ gl }) => {
1091
- var _a;
1092
- const { frames, lightSource, resolution, worldRadius, intensity, backside, backsideIOR, ior, causticsOnly, debug, } = this.get();
1093
- if (frames === Infinity || count++ < frames) {
1094
- if (Array.isArray(lightSource))
1095
- lightDir.fromArray(lightSource).normalize();
1096
- else
1097
- lightDir.copy(caustics.worldToLocal(lightSource.nativeElement.getWorldPosition(v)).normalize());
1098
- lightDirInv.copy(lightDir).multiplyScalar(-1);
1099
- let boundsVertices = [];
1100
- (_a = scene.parent) === null || _a === void 0 ? void 0 : _a.matrixWorld.identity();
1101
- bounds.setFromObject(scene, true);
1102
- boundsVertices.push(new THREE.Vector3(bounds.min.x, bounds.min.y, bounds.min.z));
1103
- boundsVertices.push(new THREE.Vector3(bounds.min.x, bounds.min.y, bounds.max.z));
1104
- boundsVertices.push(new THREE.Vector3(bounds.min.x, bounds.max.y, bounds.min.z));
1105
- boundsVertices.push(new THREE.Vector3(bounds.min.x, bounds.max.y, bounds.max.z));
1106
- boundsVertices.push(new THREE.Vector3(bounds.max.x, bounds.min.y, bounds.min.z));
1107
- boundsVertices.push(new THREE.Vector3(bounds.max.x, bounds.min.y, bounds.max.z));
1108
- boundsVertices.push(new THREE.Vector3(bounds.max.x, bounds.max.y, bounds.min.z));
1109
- boundsVertices.push(new THREE.Vector3(bounds.max.x, bounds.max.y, bounds.max.z));
1110
- const worldVerts = boundsVertices.map((v) => v.clone());
1111
- bounds.getCenter(focusPos);
1112
- boundsVertices = boundsVertices.map((v) => v.clone().sub(focusPos));
1113
- const lightPlane = lpP.set(lightDirInv, 0);
1114
- const projectedVerts = boundsVertices.map((v) => lightPlane.projectPoint(v, new THREE.Vector3()));
1115
- const centralVert = projectedVerts
1116
- .reduce((a, b) => a.add(b), v.set(0, 0, 0))
1117
- .divideScalar(projectedVerts.length);
1118
- const radius = projectedVerts
1119
- .map((v) => v.distanceTo(centralVert))
1120
- .reduce((a, b) => Math.max(a, b));
1121
- const dirLength = boundsVertices
1122
- .map((x) => x.dot(lightDir))
1123
- .reduce((a, b) => Math.max(a, b));
1124
- // Shadows
1125
- camera.position.copy(lightDir.clone().multiplyScalar(dirLength).add(focusPos));
1126
- camera.lookAt(scene.localToWorld(focusPos.clone()));
1127
- const dirMatrix = lpM.lookAt(camera.position, focusPos, v.set(0, 1, 0));
1128
- camera.left = -radius;
1129
- camera.right = radius;
1130
- camera.top = radius;
1131
- camera.bottom = -radius;
1132
- const yOffset = v.set(0, radius, 0).applyMatrix4(dirMatrix);
1133
- const yTime = (camera.position.y + yOffset.y) / lightDir.y;
1134
- camera.near = 0.1;
1135
- camera.far = yTime;
1136
- camera.updateProjectionMatrix();
1137
- camera.updateMatrixWorld();
1138
- // Now find size of ground plane
1139
- const groundProjectedCoords = worldVerts.map((v) => v.add(lightDir.clone().multiplyScalar(-v.y / lightDir.y)));
1140
- const centerPos = groundProjectedCoords
1141
- .reduce((a, b) => a.add(b), v.set(0, 0, 0))
1142
- .divideScalar(groundProjectedCoords.length);
1143
- const maxSize = 2 *
1144
- groundProjectedCoords
1145
- .map((v) => Math.hypot(v.x - centerPos.x, v.z - centerPos.z))
1146
- .reduce((a, b) => Math.max(a, b));
1147
- plane.scale.setScalar(maxSize);
1148
- plane.position.copy(centerPos);
1149
- // if (debug) helper.current?.update();
1150
- // Inject uniforms
1151
- normalMaterialB.viewMatrix.value = normalMaterial.viewMatrix.value =
1152
- camera.matrixWorldInverse;
1153
- const dirLightNearPlane = lpF.setFromProjectionMatrix(lpM.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse)).planes[4];
1154
- causticsMaterial.cameraMatrixWorld = camera.matrixWorld;
1155
- causticsMaterial.cameraProjectionMatrixInv = camera.projectionMatrixInverse;
1156
- causticsMaterial.lightDir = lightDirInv;
1157
- causticsMaterial.lightPlaneNormal = dirLightNearPlane.normal;
1158
- causticsMaterial.lightPlaneConstant = dirLightNearPlane.constant;
1159
- causticsMaterial.near = camera.near;
1160
- causticsMaterial.far = camera.far;
1161
- causticsMaterial.resolution = resolution;
1162
- causticsMaterial.size = radius;
1163
- causticsMaterial.intensity = intensity;
1164
- causticsMaterial.worldRadius = worldRadius;
1165
- // Switch the scene on
1166
- scene.visible = true;
1167
- // Render front face normals
1168
- gl.setRenderTarget(normalTarget);
1169
- gl.clear();
1170
- scene.overrideMaterial = normalMaterial;
1171
- gl.render(scene, camera);
1172
- // Render back face normals, if enabled
1173
- gl.setRenderTarget(normalTargetB);
1174
- gl.clear();
1175
- if (backside) {
1176
- scene.overrideMaterial = normalMaterialB;
1177
- gl.render(scene, camera);
1178
- }
1179
- // Remove the override material
1180
- scene.overrideMaterial = null;
1181
- // Render front face caustics
1182
- causticsMaterial.ior = ior;
1183
- plane.material.lightProjMatrix =
1184
- camera.projectionMatrix;
1185
- plane.material.lightViewMatrix =
1186
- camera.matrixWorldInverse;
1187
- causticsMaterial.normalTexture = normalTarget.texture;
1188
- causticsMaterial.depthTexture = normalTarget.depthTexture;
1189
- gl.setRenderTarget(causticsTarget);
1190
- gl.clear();
1191
- causticsQuad.render(gl);
1192
- // Render back face caustics, if enabled
1193
- causticsMaterial.ior = backsideIOR;
1194
- causticsMaterial.normalTexture = normalTargetB.texture;
1195
- causticsMaterial.depthTexture = normalTargetB.depthTexture;
1196
- gl.setRenderTarget(causticsTargetB);
1197
- gl.clear();
1198
- if (backside)
1199
- causticsQuad.render(gl);
1200
- // Reset render target
1201
- gl.setRenderTarget(null);
1202
- // Switch the scene off if caustics is all that's wanted
1203
- if (causticsOnly)
1204
- scene.visible = false;
1205
- }
1206
- });
1207
- }
1208
- });
1209
- }
1210
- }
1211
- NgtsCaustics.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsCaustics, deps: null, target: i0.ɵɵFactoryTarget.Component });
1212
- NgtsCaustics.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsCaustics, isStandalone: true, selector: "ngts-caustics", inputs: { causticsRef: "causticsRef", frames: "frames", debug: "debug", causticsOnly: "causticsOnly", backside: "backside", ior: "ior", backsideIOR: "backsideIOR", worldRadius: "worldRadius", intensity: "intensity", color: "color", resolution: "resolution", lightSource: "lightSource" }, usesInheritance: true, ngImport: i0, template: `
1213
- <ngt-group [ref]="causticsRef" ngtCompound>
1214
- <ngt-scene [ref]="sceneRef">
1215
- <ngt-orthographic-camera [ref]="cameraRef" [up]="[0, 1, 0]" />
1216
- <ng-content />
1217
- </ngt-scene>
1218
- <ngt-mesh [renderOrder]="2" [ref]="planeRef" [rotation]="[-Math.PI / 2, 0, 0]">
1219
- <ngt-plane-geometry />
1220
- <ngt-caustics-projection-material
1221
- *ngIf="causticsTargetFbo.nativeElement && causticsTargetBFbo.nativeElement"
1222
- [transparent]="true"
1223
- [color]="get('color')"
1224
- [causticsTexture]="causticsTargetFbo.nativeElement.texture"
1225
- [causticsTextureB]="causticsTargetBFbo.nativeElement.texture"
1226
- [blending]="CustomBlending"
1227
- [blendSrc]="OneFactor"
1228
- [blendDst]="SrcAlphaFactor"
1229
- [depthWrite]="false"
1230
- />
1231
-
1232
- <ngts-edges *ngIf="get('debug')" [withChildren]="true">
1233
- <ngt-line-basic-material color="#ffff00" [toneMapped]="false" />
1234
- </ngts-edges>
1235
- </ngt-mesh>
1236
- </ngt-group>
1237
- `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: NgtsEdges, selector: "ngts-edges", inputs: ["edgesRef", "threshold", "color", "geometry", "userData", "withChildren"] }] });
1238
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsCaustics, decorators: [{
1239
- type: Component,
1240
- args: [{
1241
- selector: 'ngts-caustics',
1242
- standalone: true,
1243
- template: `
1244
- <ngt-group [ref]="causticsRef" ngtCompound>
1245
- <ngt-scene [ref]="sceneRef">
1246
- <ngt-orthographic-camera [ref]="cameraRef" [up]="[0, 1, 0]" />
1247
- <ng-content />
1248
- </ngt-scene>
1249
- <ngt-mesh [renderOrder]="2" [ref]="planeRef" [rotation]="[-Math.PI / 2, 0, 0]">
1250
- <ngt-plane-geometry />
1251
- <ngt-caustics-projection-material
1252
- *ngIf="causticsTargetFbo.nativeElement && causticsTargetBFbo.nativeElement"
1253
- [transparent]="true"
1254
- [color]="get('color')"
1255
- [causticsTexture]="causticsTargetFbo.nativeElement.texture"
1256
- [causticsTextureB]="causticsTargetBFbo.nativeElement.texture"
1257
- [blending]="CustomBlending"
1258
- [blendSrc]="OneFactor"
1259
- [blendDst]="SrcAlphaFactor"
1260
- [depthWrite]="false"
1261
- />
1262
-
1263
- <ngts-edges *ngIf="get('debug')" [withChildren]="true">
1264
- <ngt-line-basic-material color="#ffff00" [toneMapped]="false" />
1265
- </ngts-edges>
1266
- </ngt-mesh>
1267
- </ngt-group>
1268
- `,
1269
- imports: [NgIf, NgtsEdges],
1270
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
1271
- }]
1272
- }], propDecorators: { causticsRef: [{
1273
- type: Input
1274
- }], frames: [{
1275
- type: Input
1276
- }], debug: [{
1277
- type: Input
1278
- }], causticsOnly: [{
1279
- type: Input
1280
- }], backside: [{
1281
- type: Input
1282
- }], ior: [{
1283
- type: Input
1284
- }], backsideIOR: [{
1285
- type: Input
1286
- }], worldRadius: [{
1287
- type: Input
1288
- }], intensity: [{
1289
- type: Input
1290
- }], color: [{
1291
- type: Input
1292
- }], resolution: [{
1293
- type: Input
1294
- }], lightSource: [{
1295
- type: Input
1296
- }] } });
1297
-
1298
- extend({ Group });
1299
- class NgtsCenter extends NgtRxStore {
1300
- constructor() {
1301
- super(...arguments);
1302
- this.centerRef = injectNgtRef();
1303
- this.outerRef = injectNgtRef();
1304
- this.innerRef = injectNgtRef();
1305
- this.centered = new EventEmitter();
1306
- }
1307
- set top(top) {
1308
- this.set({ top });
1309
- }
1310
- set right(right) {
1311
- this.set({ right });
1312
- }
1313
- set bottom(bottom) {
1314
- this.set({ bottom });
1315
- }
1316
- set left(left) {
1317
- this.set({ left });
1318
- }
1319
- set front(front) {
1320
- this.set({ front });
1321
- }
1322
- set back(back) {
1323
- this.set({ back });
1324
- }
1325
- set disableX(disableX) {
1326
- this.set({ disableX });
1327
- }
1328
- set disableY(disableY) {
1329
- this.set({ disableY });
1330
- }
1331
- set disableZ(disableZ) {
1332
- this.set({ disableZ });
1333
- }
1334
- set disabled(disabled) {
1335
- this.set({ disabled });
1336
- }
1337
- set precise(precise) {
1338
- this.set({ precise });
1339
- }
1340
- initialize() {
1341
- super.initialize();
1342
- this.set({ precise: true });
1343
- }
1344
- ngOnInit() {
1345
- this.setPosition();
1346
- }
1347
- setPosition() {
1348
- this.hold(combineLatest([this.centerRef.$, this.outerRef.$, this.innerRef.$, this.innerRef.children$()]), ([centerGroup, outerGroup, innerGroup]) => {
1349
- const { precise, top, left, front, disabled, disableX, disableY, disableZ, back, bottom, right } = this.get();
1350
- outerGroup.matrixWorld.identity();
1351
- const box3 = new Box3().setFromObject(innerGroup, precise);
1352
- const center = new Vector3();
1353
- const sphere = new Sphere();
1354
- const width = box3.max.x - box3.min.x;
1355
- const height = box3.max.y - box3.min.y;
1356
- const depth = box3.max.z - box3.min.z;
1357
- box3.getCenter(center);
1358
- box3.getBoundingSphere(sphere);
1359
- const vAlign = top ? height / 2 : bottom ? -height / 2 : 0;
1360
- const hAlign = left ? -width / 2 : right ? width / 2 : 0;
1361
- const dAlign = front ? depth / 2 : back ? -depth / 2 : 0;
1362
- outerGroup.position.set(disabled || disableX ? 0 : -center.x + hAlign, disabled || disableY ? 0 : -center.y + vAlign, disabled || disableZ ? 0 : -center.z + dAlign);
1363
- if (this.centered.observed) {
1364
- this.centered.emit({
1365
- parent: centerGroup.parent,
1366
- container: centerGroup,
1367
- width,
1368
- height,
1369
- depth,
1370
- boundingBox: box3,
1371
- boundingSphere: sphere,
1372
- center: center,
1373
- verticalAlignment: vAlign,
1374
- horizontalAlignment: hAlign,
1375
- depthAlignment: dAlign,
1376
- });
1377
- }
1378
- });
1379
- }
1380
- }
1381
- NgtsCenter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsCenter, deps: null, target: i0.ɵɵFactoryTarget.Component });
1382
- NgtsCenter.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsCenter, isStandalone: true, selector: "ngts-center", inputs: { centerRef: "centerRef", top: "top", right: "right", bottom: "bottom", left: "left", front: "front", back: "back", disableX: "disableX", disableY: "disableY", disableZ: "disableZ", disabled: "disabled", precise: "precise" }, outputs: { centered: "centered" }, usesInheritance: true, ngImport: i0, template: `
1383
- <ngt-group ngtCompound [ref]="centerRef">
1384
- <ngt-group [ref]="outerRef">
1385
- <ngt-group [ref]="innerRef">
1386
- <ng-content />
1387
- </ngt-group>
1388
- </ngt-group>
1389
- </ngt-group>
1390
- `, isInline: true });
1391
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsCenter, decorators: [{
1392
- type: Component,
1393
- args: [{
1394
- selector: 'ngts-center',
1395
- standalone: true,
1396
- template: `
1397
- <ngt-group ngtCompound [ref]="centerRef">
1398
- <ngt-group [ref]="outerRef">
1399
- <ngt-group [ref]="innerRef">
1400
- <ng-content />
1401
- </ngt-group>
1402
- </ngt-group>
1403
- </ngt-group>
1404
- `,
1405
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
1406
- }]
1407
- }], propDecorators: { centerRef: [{
1408
- type: Input
1409
- }], top: [{
1410
- type: Input
1411
- }], right: [{
1412
- type: Input
1413
- }], bottom: [{
1414
- type: Input
1415
- }], left: [{
1416
- type: Input
1417
- }], front: [{
1418
- type: Input
1419
- }], back: [{
1420
- type: Input
1421
- }], disableX: [{
1422
- type: Input
1423
- }], disableY: [{
1424
- type: Input
1425
- }], disableZ: [{
1426
- type: Input
1427
- }], disabled: [{
1428
- type: Input
1429
- }], precise: [{
1430
- type: Input
1431
- }], centered: [{
1432
- type: Output
1433
- }] } });
1434
-
1435
- const CLOUD_URL = 'https://rawcdn.githack.com/pmndrs/drei-assets/9225a9f1fbd449d9411125c2f419b843d0308c9f/cloud.png';
1436
- extend({ Group, Mesh, PlaneGeometry, MeshStandardMaterial });
1437
- class NgtsCloud extends NgtRxStore {
1438
- constructor() {
1439
- super(...arguments);
1440
- this.store = inject(NgtStore);
1441
- this.encoding = this.store.get('gl', 'outputEncoding');
1442
- this.groupRef = injectNgtRef();
1443
- this.clouds$ = this.select('clouds');
1444
- this.cloudTexture$ = injectNgtsTextureLoader(this.select('texture'));
1445
- }
1446
- set opacity(opacity) {
1447
- this.set({ opacity });
1448
- }
1449
- set speed(speed) {
1450
- this.set({ speed });
1451
- }
1452
- set width(width) {
1453
- this.set({ width });
1454
- }
1455
- set depth(depth) {
1456
- this.set({ depth });
1457
- }
1458
- set segments(segments) {
1459
- this.set({ segments });
1460
- }
1461
- set texture(texture) {
1462
- this.set({ texture });
1463
- }
1464
- set color(color) {
1465
- this.set({ color });
1466
- }
1467
- set depthTest(depthTest) {
1468
- this.set({ depthTest });
1469
- }
1470
- initialize() {
1471
- super.initialize();
1472
- this.set({
1473
- opacity: 0.5,
1474
- speed: 0.4,
1475
- width: 10,
1476
- depth: 1.5,
1477
- segments: 20,
1478
- texture: CLOUD_URL,
1479
- color: '#ffffff',
1480
- depthTest: true,
1481
- });
1482
- this.connect('clouds', this.select(['width', 'segments', 'speed'], ({ width, segments, speed }) => {
1483
- return [...new Array(segments)].map((_, index) => ({
1484
- x: width / 2 - Math.random() * width,
1485
- y: width / 2 - Math.random() * width,
1486
- scale: 0.4 + Math.sin(((index + 1) / segments) * Math.PI) * ((0.2 + Math.random()) * 10),
1487
- density: Math.max(0.2, Math.random()),
1488
- rotation: Math.max(0.002, 0.005 * Math.random()) * speed,
1489
- }));
1490
- }));
1491
- }
1492
- onBeforeRender({ state, object }) {
1493
- const clouds = this.get('clouds');
1494
- object.children.forEach((cloud, index) => {
1495
- cloud.children[0].rotation.z += clouds[index].rotation;
1496
- cloud.children[0].scale.setScalar(clouds[index].scale + (((1 + Math.sin(state.clock.getElapsedTime() / 10)) / 2) * index) / 10);
1497
- });
1498
- }
1499
- }
1500
- NgtsCloud.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsCloud, deps: null, target: i0.ɵɵFactoryTarget.Component });
1501
- NgtsCloud.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsCloud, isStandalone: true, selector: "ngts-cloud", inputs: { groupRef: "groupRef", opacity: "opacity", speed: "speed", width: "width", depth: "depth", segments: "segments", texture: "texture", color: "color", depthTest: "depthTest" }, usesInheritance: true, ngImport: i0, template: `
1502
- <ngt-group ngtCompound [ref]="groupRef">
1503
- <ngt-group
1504
- [position]="[0, 0, (get('segments') / 2) * get('depth')]"
1505
- (beforeRender)="onBeforeRender($any($event))"
1506
- >
1507
- <ngts-billboard
1508
- *ngFor="let cloud of clouds$ | ngtPush : []; let i = index"
1509
- [position]="[cloud.x, cloud.y, -i * get('depth')]"
1510
- >
1511
- <ngt-mesh [scale]="cloud.scale" [rotation]="[0, 0, 0]">
1512
- <ngt-plane-geometry />
1513
- <!-- we use ngIf here for texture because by the time ngt-value is initialized -->
1514
- <!-- [map] has not been resolved yet. we ngIf it so that texture is available before -->
1515
- <ngt-mesh-standard-material
1516
- *ngIf="cloudTexture$ | ngtPush as cloudTexture"
1517
- [transparent]="true"
1518
- [map]="cloudTexture"
1519
- [depthTest]="get('depthTest')"
1520
- [opacity]="(cloud.scale / 6) * cloud.density * get('opacity')"
1521
- [color]="get('color')"
1522
- >
1523
- <ngt-value [rawValue]="encoding" attach="map.encoding" />
1524
- </ngt-mesh-standard-material>
1525
- </ngt-mesh>
1526
- </ngts-billboard>
1527
- </ngt-group>
1528
- </ngt-group>
1529
- `, isInline: true, dependencies: [{ kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "pipe", type: NgtPush, name: "ngtPush" }, { kind: "component", type: NgtsBillboard, selector: "ngts-billboard", inputs: ["billboardRef", "follow", "lockX", "lockY", "lockZ"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
1530
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsCloud, decorators: [{
1531
- type: Component,
1532
- args: [{
1533
- selector: 'ngts-cloud',
1534
- standalone: true,
1535
- template: `
1536
- <ngt-group ngtCompound [ref]="groupRef">
1537
- <ngt-group
1538
- [position]="[0, 0, (get('segments') / 2) * get('depth')]"
1539
- (beforeRender)="onBeforeRender($any($event))"
1540
- >
1541
- <ngts-billboard
1542
- *ngFor="let cloud of clouds$ | ngtPush : []; let i = index"
1543
- [position]="[cloud.x, cloud.y, -i * get('depth')]"
1544
- >
1545
- <ngt-mesh [scale]="cloud.scale" [rotation]="[0, 0, 0]">
1546
- <ngt-plane-geometry />
1547
- <!-- we use ngIf here for texture because by the time ngt-value is initialized -->
1548
- <!-- [map] has not been resolved yet. we ngIf it so that texture is available before -->
1549
- <ngt-mesh-standard-material
1550
- *ngIf="cloudTexture$ | ngtPush as cloudTexture"
1551
- [transparent]="true"
1552
- [map]="cloudTexture"
1553
- [depthTest]="get('depthTest')"
1554
- [opacity]="(cloud.scale / 6) * cloud.density * get('opacity')"
1555
- [color]="get('color')"
1556
- >
1557
- <ngt-value [rawValue]="encoding" attach="map.encoding" />
1558
- </ngt-mesh-standard-material>
1559
- </ngt-mesh>
1560
- </ngts-billboard>
1561
- </ngt-group>
1562
- </ngt-group>
1563
- `,
1564
- imports: [NgFor, NgtPush, NgtsBillboard, NgIf],
1565
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
1566
- }]
1567
- }], propDecorators: { groupRef: [{
1568
- type: Input
1569
- }], opacity: [{
1570
- type: Input
1571
- }], speed: [{
1572
- type: Input
1573
- }], width: [{
1574
- type: Input
1575
- }], depth: [{
1576
- type: Input
1577
- }], segments: [{
1578
- type: Input
1579
- }], texture: [{
1580
- type: Input
1581
- }], color: [{
1582
- type: Input
1583
- }], depthTest: [{
1584
- type: Input
1585
- }] } });
1586
-
1587
- extend({ Group, Mesh, MeshBasicMaterial, OrthographicCamera });
1588
- class NgtsContactShadows extends NgtRxStore {
1589
- set opacity(opacity) {
1590
- this.set({ opacity });
1591
- }
1592
- set width(width) {
1593
- this.set({ width });
1594
- }
1595
- set height(height) {
1596
- this.set({ height });
1597
- }
1598
- set blur(blur) {
1599
- this.set({ blur });
1600
- }
1601
- set far(far) {
1602
- this.set({ far });
1603
- }
1604
- set smooth(smooth) {
1605
- this.set({ smooth });
1606
- }
1607
- set resolution(resolution) {
1608
- this.set({ resolution });
1609
- }
1610
- set frames(frames) {
1611
- this.set({ frames });
1612
- }
1613
- set scale(scale) {
1614
- this.set({ scale });
1615
- }
1616
- set color(color) {
1617
- this.set({ color });
1618
- }
1619
- set depthWrite(depthWrite) {
1620
- this.set({ depthWrite });
1621
- }
1622
- set renderOrder(renderOrder) {
1623
- this.set({ renderOrder });
1624
- }
1625
- constructor() {
1626
- super();
1627
- this.store = inject(NgtStore);
1628
- this.shadowCameraRef = injectNgtRef();
1629
- this.encoding = this.store.get('gl', 'outputEncoding');
1630
- this.contactShadows$ = this.select('contactShadows');
1631
- this.Math = Math;
1632
- this.contactShadowsRef = injectNgtRef();
1633
- injectBeforeRender(this.onBeforeRender.bind(this, 0));
1634
- }
1635
- initialize() {
1636
- super.initialize();
1637
- this.set({
1638
- scale: 10,
1639
- frames: Infinity,
1640
- opacity: 1,
1641
- width: 1,
1642
- height: 1,
1643
- blur: 1,
1644
- far: 10,
1645
- resolution: 512,
1646
- smooth: true,
1647
- color: '#000000',
1648
- depthWrite: false,
1649
- renderOrder: 0,
1650
- });
1651
- this.connect('scaledWidth', this.select(['width', 'scale'], ({ width, scale }) => width * (Array.isArray(scale) ? scale[0] : scale || 1)));
1652
- this.connect('scaledHeight', this.select(['height', 'scale'], ({ height, scale }) => height * (Array.isArray(scale) ? scale[1] : scale || 1)));
1653
- this.connect('cameraArgs', this.select(['scaledWidth', 'scaledHeight', 'far'], ({ scaledWidth: width, scaledHeight: height, far }) => {
1654
- return [-width / 2, width / 2, height / 2, -height / 2, 0, far];
1655
- }));
1656
- this.connect('contactShadows', this.select(['resolution', 'scaledWidth', 'scaledHeight', 'scale', 'color'], ({ resolution, scaledWidth: width, scaledHeight: height, color }) => {
1657
- const renderTarget = new THREE.WebGLRenderTarget(resolution, resolution);
1658
- const renderTargetBlur = new THREE.WebGLRenderTarget(resolution, resolution);
1659
- renderTargetBlur.texture.generateMipmaps = renderTarget.texture.generateMipmaps = false;
1660
- const planeGeometry = new THREE.PlaneGeometry(width, height).rotateX(Math.PI / 2);
1661
- const blurPlane = new Mesh(planeGeometry);
1662
- const depthMaterial = new THREE.MeshDepthMaterial();
1663
- depthMaterial.depthTest = depthMaterial.depthWrite = false;
1664
- depthMaterial.onBeforeCompile = (shader) => {
1665
- shader.uniforms = Object.assign(Object.assign({}, shader.uniforms), { ucolor: { value: new THREE.Color(color) } });
1666
- shader.fragmentShader = shader.fragmentShader.replace(`void main() {`, //
1667
- `uniform vec3 ucolor;
1668
- void main() {
1669
- `);
1670
- shader.fragmentShader = shader.fragmentShader.replace('vec4( vec3( 1.0 - fragCoordZ ), opacity );',
1671
- // Colorize the shadow, multiply by the falloff so that the center can remain darker
1672
- 'vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );');
1673
- };
1674
- const horizontalBlurMaterial = new THREE.ShaderMaterial(HorizontalBlurShader);
1675
- const verticalBlurMaterial = new THREE.ShaderMaterial(VerticalBlurShader);
1676
- verticalBlurMaterial.depthTest = horizontalBlurMaterial.depthTest = false;
1677
- return {
1678
- renderTarget,
1679
- planeGeometry,
1680
- depthMaterial,
1681
- blurPlane,
1682
- horizontalBlurMaterial,
1683
- verticalBlurMaterial,
1684
- renderTargetBlur,
1685
- };
1686
- }));
1687
- }
1688
- onBeforeRender(count, { scene, gl }) {
1689
- const { frames, blur, contactShadows: { depthMaterial, renderTarget }, smooth, } = this.get();
1690
- if (this.shadowCameraRef.nativeElement && (frames === Infinity || count < frames)) {
1691
- const initialBackground = scene.background;
1692
- scene.background = null;
1693
- const initialOverrideMaterial = scene.overrideMaterial;
1694
- scene.overrideMaterial = depthMaterial;
1695
- gl.setRenderTarget(renderTarget);
1696
- gl.render(scene, this.shadowCameraRef.nativeElement);
1697
- scene.overrideMaterial = initialOverrideMaterial;
1698
- this.blurShadows(blur);
1699
- if (smooth)
1700
- this.blurShadows(blur * 0.4);
1701
- gl.setRenderTarget(null);
1702
- scene.background = initialBackground;
1703
- count++;
1704
- }
1705
- }
1706
- blurShadows(blur) {
1707
- const { blurPlane, horizontalBlurMaterial, verticalBlurMaterial, renderTargetBlur, renderTarget } = this.get('contactShadows');
1708
- const gl = this.store.get('gl');
1709
- blurPlane.visible = true;
1710
- blurPlane.material = horizontalBlurMaterial;
1711
- horizontalBlurMaterial.uniforms.tDiffuse.value = renderTarget.texture;
1712
- horizontalBlurMaterial.uniforms.h.value = (blur * 1) / 256;
1713
- gl.setRenderTarget(renderTargetBlur);
1714
- gl.render(blurPlane, this.shadowCameraRef.nativeElement);
1715
- blurPlane.material = verticalBlurMaterial;
1716
- verticalBlurMaterial.uniforms.tDiffuse.value = renderTargetBlur.texture;
1717
- verticalBlurMaterial.uniforms.v.value = (blur * 1) / 256;
1718
- gl.setRenderTarget(renderTarget);
1719
- gl.render(blurPlane, this.shadowCameraRef.nativeElement);
1720
- blurPlane.visible = false;
1721
- }
1722
- }
1723
- NgtsContactShadows.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsContactShadows, deps: [], target: i0.ɵɵFactoryTarget.Component });
1724
- NgtsContactShadows.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsContactShadows, isStandalone: true, selector: "ngts-contact-shadows", inputs: { contactShadowsRef: "contactShadowsRef", opacity: "opacity", width: "width", height: "height", blur: "blur", far: "far", smooth: "smooth", resolution: "resolution", frames: "frames", scale: "scale", color: "color", depthWrite: "depthWrite", renderOrder: "renderOrder" }, usesInheritance: true, ngImport: i0, template: `
1725
- <ngt-group ngtCompound [ref]="contactShadowsRef" [rotation]="[Math.PI / 2, 0, 0]">
1726
- <ng-container *ngIf="contactShadows$ | ngtPush : null as contactShadows">
1727
- <ngt-mesh
1728
- [renderOrder]="get('renderOrder')"
1729
- [geometry]="contactShadows.planeGeometry"
1730
- [scale]="[1, -1, 1]"
1731
- [rotation]="[-Math.PI / 2, 0, 0]"
1732
- >
1733
- <ngt-mesh-basic-material
1734
- [map]="contactShadows.renderTarget.texture"
1735
- [transparent]="true"
1736
- [opacity]="get('opacity')"
1737
- [depthWrite]="get('depthWrite')"
1738
- >
1739
- <ngt-value [rawValue]="encoding" attach="map.encoding" />
1740
- </ngt-mesh-basic-material>
1741
- </ngt-mesh>
1742
- <ngt-orthographic-camera *args="get('cameraArgs')" [ref]="shadowCameraRef" />
1743
- </ng-container>
1744
- </ngt-group>
1745
- `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: NgtPush, name: "ngtPush" }, { kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
1746
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsContactShadows, decorators: [{
1747
- type: Component,
1748
- args: [{
1749
- selector: 'ngts-contact-shadows',
1750
- standalone: true,
1751
- template: `
1752
- <ngt-group ngtCompound [ref]="contactShadowsRef" [rotation]="[Math.PI / 2, 0, 0]">
1753
- <ng-container *ngIf="contactShadows$ | ngtPush : null as contactShadows">
1754
- <ngt-mesh
1755
- [renderOrder]="get('renderOrder')"
1756
- [geometry]="contactShadows.planeGeometry"
1757
- [scale]="[1, -1, 1]"
1758
- [rotation]="[-Math.PI / 2, 0, 0]"
1759
- >
1760
- <ngt-mesh-basic-material
1761
- [map]="contactShadows.renderTarget.texture"
1762
- [transparent]="true"
1763
- [opacity]="get('opacity')"
1764
- [depthWrite]="get('depthWrite')"
1765
- >
1766
- <ngt-value [rawValue]="encoding" attach="map.encoding" />
1767
- </ngt-mesh-basic-material>
1768
- </ngt-mesh>
1769
- <ngt-orthographic-camera *args="get('cameraArgs')" [ref]="shadowCameraRef" />
1770
- </ng-container>
1771
- </ngt-group>
1772
- `,
1773
- imports: [NgIf, NgtPush, NgtArgs],
1774
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
1775
- }]
1776
- }], ctorParameters: function () { return []; }, propDecorators: { contactShadowsRef: [{
1777
- type: Input
1778
- }], opacity: [{
1779
- type: Input
1780
- }], width: [{
1781
- type: Input
1782
- }], height: [{
1783
- type: Input
1784
- }], blur: [{
1785
- type: Input
1786
- }], far: [{
1787
- type: Input
1788
- }], smooth: [{
1789
- type: Input
1790
- }], resolution: [{
1791
- type: Input
1792
- }], frames: [{
1793
- type: Input
1794
- }], scale: [{
1795
- type: Input
1796
- }], color: [{
1797
- type: Input
1798
- }], depthWrite: [{
1799
- type: Input
1800
- }], renderOrder: [{
1801
- type: Input
1802
- }] } });
1803
-
1804
- const ngtsEnvironmentPresetsObj = {
1805
- sunset: 'venice/venice_sunset_1k.hdr',
1806
- dawn: 'kiara/kiara_1_dawn_1k.hdr',
1807
- night: 'dikhololo/dikhololo_night_1k.hdr',
1808
- warehouse: 'empty-wharehouse/empty_warehouse_01_1k.hdr',
1809
- forest: 'forrest-slope/forest_slope_1k.hdr',
1810
- apartment: 'lebombo/lebombo_1k.hdr',
1811
- studio: 'studio-small-3/studio_small_03_1k.hdr',
1812
- city: 'potsdamer-platz/potsdamer_platz_1k.hdr',
1813
- park: 'rooitou/rooitou_park_1k.hdr',
1814
- lobby: 'st-fagans/st_fagans_interior_1k.hdr',
1815
- };
1816
-
1817
- class NgtsEnvironmentInputs extends NgtRxStore {
1818
- constructor() {
1819
- super(...arguments);
1820
- this.store = inject(NgtStore);
1821
- }
1822
- set frames(frames) {
1823
- this.set({ frames });
1824
- }
1825
- set near(near) {
1826
- this.set({ near });
1827
- }
1828
- set far(far) {
1829
- this.set({ far });
1830
- }
1831
- set resolution(resolution) {
1832
- this.set({ resolution });
1833
- }
1834
- set background(background) {
1835
- this.set({ background });
1836
- }
1837
- set blur(blur) {
1838
- this.set({ blur });
1839
- }
1840
- set map(map) {
1841
- this.set({ map });
1842
- }
1843
- set files(files) {
1844
- this.set({ files });
1845
- }
1846
- set path(path) {
1847
- this.set({ path });
1848
- }
1849
- set preset(preset) {
1850
- this.set({ preset });
1851
- }
1852
- set scene(scene) {
1853
- this.set({ scene });
1854
- }
1855
- set extensions(extensions) {
1856
- this.set({ extensions });
1857
- }
1858
- set ground(ground) {
1859
- this.set({ ground });
1860
- }
1861
- set encoding(encoding) {
1862
- this.set({ encoding });
1863
- }
1864
- }
1865
- NgtsEnvironmentInputs.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironmentInputs, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1866
- NgtsEnvironmentInputs.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtsEnvironmentInputs, inputs: { frames: "frames", near: "near", far: "far", resolution: "resolution", background: "background", blur: "blur", map: "map", files: "files", path: "path", preset: "preset", scene: "scene", extensions: "extensions", ground: "ground", encoding: "encoding" }, usesInheritance: true, ngImport: i0 });
1867
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironmentInputs, decorators: [{
1868
- type: Directive
1869
- }], propDecorators: { frames: [{
1870
- type: Input
1871
- }], near: [{
1872
- type: Input
1873
- }], far: [{
1874
- type: Input
1875
- }], resolution: [{
1876
- type: Input
1877
- }], background: [{
1878
- type: Input
1879
- }], blur: [{
1880
- type: Input
1881
- }], map: [{
1882
- type: Input
1883
- }], files: [{
1884
- type: Input
1885
- }], path: [{
1886
- type: Input
1887
- }], preset: [{
1888
- type: Input
1889
- }], scene: [{
1890
- type: Input
1891
- }], extensions: [{
1892
- type: Input
1893
- }], ground: [{
1894
- type: Input
1895
- }], encoding: [{
1896
- type: Input
1897
- }] } });
1898
-
1899
- function resolveScene(scene) {
1900
- return is.ref(scene) ? scene.nativeElement : scene;
1901
- }
1902
- function setEnvProps(background, scene, defaultScene, texture, blur = 0) {
1903
- const target = resolveScene(scene || defaultScene);
1904
- const oldbg = target.background;
1905
- const oldenv = target.environment;
1906
- const oldBlur = target.backgroundBlurriness || 0;
1907
- if (background !== 'only')
1908
- target.environment = texture;
1909
- if (background)
1910
- target.background = texture;
1911
- if (background && target.backgroundBlurriness !== undefined)
1912
- target.backgroundBlurriness = blur;
1913
- return () => {
1914
- if (background !== 'only')
1915
- target.environment = oldenv;
1916
- if (background)
1917
- target.background = oldbg;
1918
- if (background && target.backgroundBlurriness !== undefined)
1919
- target.backgroundBlurriness = oldBlur;
1920
- };
1921
- }
1922
- const CUBEMAP_ROOT = 'https://market-assets.fra1.cdn.digitaloceanspaces.com/market-assets/hdris/';
1923
- function injectNgtsEnvironment(paramsFactory) {
1924
- let p = {
1925
- files: ['/px.png', '/nx.png', '/py.png', '/ny.png', '/pz.png', '/nz.png'],
1926
- path: '',
1927
- preset: undefined,
1928
- encoding: undefined,
1929
- };
1930
- const params = paramsFactory(p);
1931
- const params$ = isObservable(params) ? params : of(params);
1932
- const textureRef = injectNgtRef();
1933
- const { destroy$ } = injectNgtDestroy(() => {
1934
- var _a;
1935
- (_a = textureRef.nativeElement) === null || _a === void 0 ? void 0 : _a.dispose();
1936
- });
1937
- const loaderResult = injectNgtLoader((inputs) => (Array.isArray(inputs) ? CubeTextureLoader : RGBELoader), params$.pipe(debounceTime(0), map((data) => {
1938
- p = data;
1939
- return p;
1940
- }), map((data) => {
1941
- if (data.preset) {
1942
- if (!(data.preset in ngtsEnvironmentPresetsObj))
1943
- throw new Error('Preset must be one of: ' + Object.keys(ngtsEnvironmentPresetsObj).join(', '));
1944
- data.files = ngtsEnvironmentPresetsObj[data.preset];
1945
- data.path = CUBEMAP_ROOT;
1946
- }
1947
- return Array.isArray(data.files) ? [data.files] : data.files;
1948
- })), (loader) => {
1949
- if (p.path) {
1950
- loader.setPath(p.path);
1951
- }
1952
- if (p.extensions) {
1953
- p.extensions(loader);
1954
- }
1955
- });
1956
- loaderResult.pipe(takeUntil(destroy$)).subscribe((results) => {
1957
- var _a;
1958
- const texture = Array.isArray(p.files) ? results[0] : results;
1959
- texture.mapping = Array.isArray(p.files) ? CubeReflectionMapping : EquirectangularReflectionMapping;
1960
- texture.encoding = ((_a = p.encoding) !== null && _a !== void 0 ? _a : Array.isArray(p.files)) ? sRGBEncoding : LinearEncoding;
1961
- textureRef.nativeElement = texture;
1962
- });
1963
- return textureRef;
1964
- }
1965
-
1966
- class NgtsEnvironmentCube extends NgtsEnvironmentInputs {
1967
- constructor() {
1968
- super(...arguments);
1969
- this.textureRef = injectNgtsEnvironment((params) => this.select().pipe(startWith(params)));
1970
- }
1971
- initialize() {
1972
- super.initialize();
1973
- this.set({ background: false });
1974
- }
1975
- ngOnInit() {
1976
- this.setEnvProps();
1977
- }
1978
- setEnvProps() {
1979
- this.effect(combineLatest([
1980
- this.store.select('scene'),
1981
- this.select('scene').pipe(startWithUndefined()),
1982
- this.select('background'),
1983
- this.select('blur').pipe(startWithUndefined()),
1984
- this.textureRef.$,
1985
- ]), ([defaultScene, scene, background, blur, texture]) => {
1986
- return setEnvProps(background, scene, defaultScene, texture, blur);
1987
- });
1988
- }
1989
- }
1990
- NgtsEnvironmentCube.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironmentCube, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1991
- NgtsEnvironmentCube.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtsEnvironmentCube, isStandalone: true, selector: "ngts-environment-cube", usesInheritance: true, ngImport: i0 });
1992
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironmentCube, decorators: [{
1993
- type: Directive,
1994
- args: [{
1995
- selector: 'ngts-environment-cube',
1996
- standalone: true,
1997
- }]
1998
- }] });
1999
-
2000
- class NgtsEnvironmentMap extends NgtsEnvironmentInputs {
2001
- initialize() {
2002
- super.initialize();
2003
- this.set({ background: false });
2004
- }
2005
- ngOnInit() {
2006
- this.setEnvProps();
2007
- }
2008
- setEnvProps() {
2009
- this.effect(combineLatest([
2010
- this.store.select('scene'),
2011
- this.select('map'),
2012
- this.select('scene').pipe(startWithUndefined()),
2013
- this.select('background'),
2014
- this.select('blur').pipe(startWithUndefined()),
2015
- ]), ([defaultScene, map, scene, background, blur]) => {
2016
- if (map) {
2017
- return setEnvProps(background, scene, defaultScene, map, blur);
2018
- }
2019
- });
2020
- }
2021
- }
2022
- NgtsEnvironmentMap.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironmentMap, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2023
- NgtsEnvironmentMap.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtsEnvironmentMap, isStandalone: true, selector: "ngts-environment-map", usesInheritance: true, ngImport: i0 });
2024
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironmentMap, decorators: [{
2025
- type: Directive,
2026
- args: [{
2027
- selector: 'ngts-environment-map',
2028
- standalone: true,
2029
- }]
2030
- }] });
2031
-
2032
- extend({ GroundProjectedEnv });
2033
- class NgtsEnvironmentGround extends NgtsEnvironmentInputs {
2034
- constructor() {
2035
- super(...arguments);
2036
- this.defaultTexture = injectNgtsEnvironment((params) => this.select().pipe(startWith(params)));
2037
- }
2038
- ngOnInit() {
2039
- this.connect('texture', combineLatest([this.select('map').pipe(startWithUndefined()), this.defaultTexture.$]).pipe(map(([map, texture]) => map || texture)));
2040
- this.connect('groundArgs', this.select('texture').pipe(map((texture) => [texture])));
2041
- this.connect('groundHeight', this.select(['ground'], ({ ground }) => ground === null || ground === void 0 ? void 0 : ground.height));
2042
- this.connect('groundRadius', this.select(['ground'], ({ ground }) => ground === null || ground === void 0 ? void 0 : ground.radius));
2043
- this.connect('groundScale', this.select(['ground'], ({ ground }) => { var _a; return (_a = ground === null || ground === void 0 ? void 0 : ground.scale) !== null && _a !== void 0 ? _a : 1000; }));
2044
- }
2045
- }
2046
- NgtsEnvironmentGround.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironmentGround, deps: null, target: i0.ɵɵFactoryTarget.Component });
2047
- NgtsEnvironmentGround.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsEnvironmentGround, isStandalone: true, selector: "ngts-environment-ground", usesInheritance: true, ngImport: i0, template: `
2048
- <ngts-environment-map
2049
- [background]="get('background')"
2050
- [blur]="get('blur')"
2051
- [scene]="get('scene')"
2052
- [map]="get('texture')"
2053
- />
2054
- <ng-container *ngIf="get('groundArgs') as groundArgs">
2055
- <ngt-ground-projected-env
2056
- *args="groundArgs"
2057
- [scale]="get('groundScale')"
2058
- [height]="get('groundHeight')"
2059
- [radius]="get('groundRadius')"
2060
- />
2061
- </ng-container>
2062
- `, isInline: true, dependencies: [{ kind: "directive", type: NgtsEnvironmentMap, selector: "ngts-environment-map" }, { kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2063
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironmentGround, decorators: [{
2064
- type: Component,
2065
- args: [{
2066
- selector: 'ngts-environment-ground',
2067
- standalone: true,
2068
- template: `
2069
- <ngts-environment-map
2070
- [background]="get('background')"
2071
- [blur]="get('blur')"
2072
- [scene]="get('scene')"
2073
- [map]="get('texture')"
2074
- />
2075
- <ng-container *ngIf="get('groundArgs') as groundArgs">
2076
- <ngt-ground-projected-env
2077
- *args="groundArgs"
2078
- [scale]="get('groundScale')"
2079
- [height]="get('groundHeight')"
2080
- [radius]="get('groundRadius')"
2081
- />
2082
- </ng-container>
2083
- `,
2084
- imports: [NgtsEnvironmentMap, NgtArgs, NgIf],
2085
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
2086
- }]
2087
- }] });
2088
-
2089
- extend({ CubeCamera });
2090
- class NgtsEnvironmentPortal extends NgtsEnvironmentInputs {
2091
- initialize() {
2092
- super.initialize();
2093
- this.set({ near: 1, far: 1000, resolution: 256, frames: 1, background: false, preset: undefined });
2094
- this.connect('fbo', this.select(['resolution'], ({ resolution }) => {
2095
- const fbo = new THREE.WebGLCubeRenderTarget(resolution);
2096
- fbo.texture.type = HalfFloatType;
2097
- return fbo;
2098
- }));
2099
- this.connect('cameraArgs', this.select(['fbo', 'near', 'far'], ({ near, far, fbo }) => [near, far, fbo]));
2100
- }
2101
- constructor() {
2102
- super();
2103
- this.virtualSceneRef = injectNgtRef(prepare(new THREE.Scene()));
2104
- this.cubeCameraRef = injectNgtRef();
2105
- injectBeforeRender(this.onBeforeRender.bind(this, 1));
2106
- }
2107
- ngOnInit() {
2108
- this.setEnvProps();
2109
- }
2110
- setEnvProps() {
2111
- this.effect(combineLatest([
2112
- this.store.select('gl'),
2113
- this.store.select('scene'),
2114
- this.select('fbo'),
2115
- this.select('scene'),
2116
- this.select('background'),
2117
- this.select('frames'),
2118
- this.select('blur'),
2119
- this.virtualSceneRef.$,
2120
- this.cubeCameraRef.$,
2121
- ]), ([gl, defaultScene, fbo, scene, background, frames, blur, virtualScene, camera]) => {
2122
- if (frames === 1)
2123
- camera.update(gl, virtualScene);
2124
- return setEnvProps(background, scene, defaultScene, fbo.texture, blur);
2125
- });
2126
- }
2127
- onBeforeRender(count, { gl }) {
2128
- const { frames } = this.get();
2129
- if (frames === Infinity || count < frames) {
2130
- if (this.cubeCameraRef.nativeElement) {
2131
- this.cubeCameraRef.nativeElement.update(gl, this.virtualSceneRef.nativeElement);
2132
- count++;
2133
- }
2134
- }
2135
- }
2136
- }
2137
- NgtsEnvironmentPortal.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironmentPortal, deps: [], target: i0.ɵɵFactoryTarget.Component });
2138
- NgtsEnvironmentPortal.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsEnvironmentPortal, isStandalone: true, selector: "ngts-environment-portal", usesInheritance: true, ngImport: i0, template: `
2139
- <ngt-portal [container]="virtualSceneRef">
2140
- <ng-template ngtPortalContent>
2141
- <ng-content />
2142
- <ngt-cube-camera *args="get('cameraArgs')" [ref]="cubeCameraRef" />
2143
- <ng-container *ngIf="get('files') || get('preset'); else environmentMap">
2144
- <ngts-environment-cube
2145
- [background]="true"
2146
- [files]="get('files')"
2147
- [preset]="get('preset')"
2148
- [path]="get('path')"
2149
- [extensions]="get('extensions')"
2150
- />
2151
- </ng-container>
2152
- <ng-template #environmentMap>
2153
- <ngts-environment-map [background]="true" [map]="get('map')" [extensions]="get('extensions')" />
2154
- </ng-template>
2155
- </ng-template>
2156
- </ngt-portal>
2157
- `, isInline: true, dependencies: [{ kind: "component", type: NgtPortal, selector: "ngt-portal", inputs: ["container", "state", "autoRender", "autoRenderPriority"], outputs: ["beforeRender"] }, { kind: "directive", type: NgtPortalContent, selector: "ng-template[ngtPortalContent]" }, { kind: "directive", type: NgtsEnvironmentMap, selector: "ngts-environment-map" }, { kind: "directive", type: NgtsEnvironmentCube, selector: "ngts-environment-cube" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
2158
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironmentPortal, decorators: [{
2159
- type: Component,
2160
- args: [{
2161
- selector: 'ngts-environment-portal',
2162
- standalone: true,
2163
- template: `
2164
- <ngt-portal [container]="virtualSceneRef">
2165
- <ng-template ngtPortalContent>
2166
- <ng-content />
2167
- <ngt-cube-camera *args="get('cameraArgs')" [ref]="cubeCameraRef" />
2168
- <ng-container *ngIf="get('files') || get('preset'); else environmentMap">
2169
- <ngts-environment-cube
2170
- [background]="true"
2171
- [files]="get('files')"
2172
- [preset]="get('preset')"
2173
- [path]="get('path')"
2174
- [extensions]="get('extensions')"
2175
- />
2176
- </ng-container>
2177
- <ng-template #environmentMap>
2178
- <ngts-environment-map [background]="true" [map]="get('map')" [extensions]="get('extensions')" />
2179
- </ng-template>
2180
- </ng-template>
2181
- </ngt-portal>
2182
- `,
2183
- imports: [NgtPortal, NgtPortalContent, NgtsEnvironmentMap, NgtsEnvironmentCube, NgIf, NgtArgs],
2184
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
2185
- }]
2186
- }], ctorParameters: function () { return []; } });
2187
-
2188
- class NgtsEnvironmentContent {
2189
- }
2190
- NgtsEnvironmentContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironmentContent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2191
- NgtsEnvironmentContent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtsEnvironmentContent, isStandalone: true, selector: "ng-template[ngtsEnvironmentContent]", ngImport: i0 });
2192
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironmentContent, decorators: [{
2193
- type: Directive,
2194
- args: [{ selector: 'ng-template[ngtsEnvironmentContent]', standalone: true }]
2195
- }] });
2196
- class NgtsEnvironment extends NgtsEnvironmentInputs {
2197
- }
2198
- NgtsEnvironment.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironment, deps: null, target: i0.ɵɵFactoryTarget.Component });
2199
- NgtsEnvironment.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsEnvironment, isStandalone: true, selector: "ngts-environment", queries: [{ propertyName: "content", first: true, predicate: NgtsEnvironmentContent, descendants: true, read: TemplateRef }], usesInheritance: true, ngImport: i0, template: `
2200
- <ngts-environment-ground
2201
- *ngIf="get('ground'); else noGround"
2202
- [ground]="get('ground')"
2203
- [map]="get('map')"
2204
- [scene]="get('scene')"
2205
- [blur]="get('blur')"
2206
- [background]="get('background')"
2207
- [preset]="get('preset')"
2208
- [frames]="get('frames')"
2209
- [far]="get('far')"
2210
- [near]="get('near')"
2211
- [resolution]="get('resolution')"
2212
- [files]="get('files')"
2213
- [path]="get('path')"
2214
- [extensions]="get('extensions')"
2215
- />
2216
- <ng-template #noGround>
2217
- <ngts-environment-map
2218
- *ngIf="get('map'); else noMap"
2219
- [map]="get('map')"
2220
- [scene]="get('scene')"
2221
- [blur]="get('blur')"
2222
- [background]="get('background')"
2223
- />
2224
- <ng-template #noMap>
2225
- <ngts-environment-portal
2226
- *ngIf="content; else noPortal"
2227
- [frames]="get('frames')"
2228
- [far]="get('far')"
2229
- [near]="get('near')"
2230
- [resolution]="get('resolution')"
2231
- [map]="get('map')"
2232
- [background]="get('background')"
2233
- [blur]="get('blur')"
2234
- [scene]="get('scene')"
2235
- [files]="get('files')"
2236
- [path]="get('path')"
2237
- [preset]="get('preset')"
2238
- [extensions]="get('extensions')"
2239
- >
2240
- <ng-container *ngTemplateOutlet="content" />
2241
- </ngts-environment-portal>
2242
- <ng-template #noPortal>
2243
- <ngts-environment-cube
2244
- [frames]="get('frames')"
2245
- [far]="get('far')"
2246
- [near]="get('near')"
2247
- [resolution]="get('resolution')"
2248
- [map]="get('map')"
2249
- [background]="get('background')"
2250
- [blur]="get('blur')"
2251
- [scene]="get('scene')"
2252
- [files]="get('files')"
2253
- [path]="get('path')"
2254
- [preset]="get('preset')"
2255
- [extensions]="get('extensions')"
2256
- />
2257
- </ng-template>
2258
- </ng-template>
2259
- </ng-template>
2260
- `, isInline: true, dependencies: [{ kind: "directive", type: NgtsEnvironmentMap, selector: "ngts-environment-map" }, { kind: "component", type: NgtsEnvironmentGround, selector: "ngts-environment-ground" }, { kind: "directive", type: NgtsEnvironmentCube, selector: "ngts-environment-cube" }, { kind: "component", type: NgtsEnvironmentPortal, selector: "ngts-environment-portal" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
2261
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsEnvironment, decorators: [{
2262
- type: Component,
2263
- args: [{
2264
- selector: 'ngts-environment',
2265
- standalone: true,
2266
- template: `
2267
- <ngts-environment-ground
2268
- *ngIf="get('ground'); else noGround"
2269
- [ground]="get('ground')"
2270
- [map]="get('map')"
2271
- [scene]="get('scene')"
2272
- [blur]="get('blur')"
2273
- [background]="get('background')"
2274
- [preset]="get('preset')"
2275
- [frames]="get('frames')"
2276
- [far]="get('far')"
2277
- [near]="get('near')"
2278
- [resolution]="get('resolution')"
2279
- [files]="get('files')"
2280
- [path]="get('path')"
2281
- [extensions]="get('extensions')"
2282
- />
2283
- <ng-template #noGround>
2284
- <ngts-environment-map
2285
- *ngIf="get('map'); else noMap"
2286
- [map]="get('map')"
2287
- [scene]="get('scene')"
2288
- [blur]="get('blur')"
2289
- [background]="get('background')"
2290
- />
2291
- <ng-template #noMap>
2292
- <ngts-environment-portal
2293
- *ngIf="content; else noPortal"
2294
- [frames]="get('frames')"
2295
- [far]="get('far')"
2296
- [near]="get('near')"
2297
- [resolution]="get('resolution')"
2298
- [map]="get('map')"
2299
- [background]="get('background')"
2300
- [blur]="get('blur')"
2301
- [scene]="get('scene')"
2302
- [files]="get('files')"
2303
- [path]="get('path')"
2304
- [preset]="get('preset')"
2305
- [extensions]="get('extensions')"
2306
- >
2307
- <ng-container *ngTemplateOutlet="content" />
2308
- </ngts-environment-portal>
2309
- <ng-template #noPortal>
2310
- <ngts-environment-cube
2311
- [frames]="get('frames')"
2312
- [far]="get('far')"
2313
- [near]="get('near')"
2314
- [resolution]="get('resolution')"
2315
- [map]="get('map')"
2316
- [background]="get('background')"
2317
- [blur]="get('blur')"
2318
- [scene]="get('scene')"
2319
- [files]="get('files')"
2320
- [path]="get('path')"
2321
- [preset]="get('preset')"
2322
- [extensions]="get('extensions')"
2323
- />
2324
- </ng-template>
2325
- </ng-template>
2326
- </ng-template>
2327
- `,
2328
- imports: [
2329
- NgtsEnvironmentMap,
2330
- NgtsEnvironmentGround,
2331
- NgtsEnvironmentCube,
2332
- NgtsEnvironmentPortal,
2333
- NgIf,
2334
- NgTemplateOutlet,
2335
- ],
2336
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
2337
- }]
2338
- }], propDecorators: { content: [{
2339
- type: ContentChild,
2340
- args: [NgtsEnvironmentContent, { read: TemplateRef }]
2341
- }] } });
2342
-
2343
- extend({ Group });
2344
- class NgtsFloat extends NgtRxStore {
2345
- set speed(speed) {
2346
- this.set({ speed });
2347
- }
2348
- set rotationIntensity(rotationIntensity) {
2349
- this.set({ rotationIntensity });
2350
- }
2351
- set floatIntensity(floatIntensity) {
2352
- this.set({ floatIntensity });
2353
- }
2354
- set floatingRange(floatingRange) {
2355
- this.set({ floatingRange });
2356
- }
2357
- initialize() {
2358
- super.initialize();
2359
- this.set({ speed: 1, rotationIntensity: 1, floatIntensity: 1, floatingRange: [-0.1, 0.1] });
2360
- }
2361
- constructor() {
2362
- super();
2363
- this.offset = Math.random() * 10000;
2364
- this.floatRef = injectNgtRef();
2365
- injectBeforeRender(this.onBeforeRender.bind(this));
2366
- }
2367
- onBeforeRender({ clock }) {
2368
- var _a, _b;
2369
- if (!this.floatRef.nativeElement)
2370
- return;
2371
- const { speed, floatingRange, floatIntensity, rotationIntensity } = this.get();
2372
- const t = this.offset + clock.getElapsedTime();
2373
- this.floatRef.nativeElement.rotation.x = (Math.cos((t / 4) * speed) / 8) * rotationIntensity;
2374
- this.floatRef.nativeElement.rotation.y = (Math.sin((t / 4) * speed) / 8) * rotationIntensity;
2375
- this.floatRef.nativeElement.rotation.z = (Math.sin((t / 4) * speed) / 20) * rotationIntensity;
2376
- let yPosition = Math.sin((t / 4) * speed) / 10;
2377
- yPosition = THREE.MathUtils.mapLinear(yPosition, -0.1, 0.1, (_a = floatingRange[0]) !== null && _a !== void 0 ? _a : -0.1, (_b = floatingRange[1]) !== null && _b !== void 0 ? _b : 0.1);
2378
- this.floatRef.nativeElement.position.y = yPosition * floatIntensity;
2379
- }
2380
- }
2381
- NgtsFloat.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsFloat, deps: [], target: i0.ɵɵFactoryTarget.Component });
2382
- NgtsFloat.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsFloat, isStandalone: true, selector: "ngts-float", inputs: { floatRef: "floatRef", speed: "speed", rotationIntensity: "rotationIntensity", floatIntensity: "floatIntensity", floatingRange: "floatingRange" }, usesInheritance: true, ngImport: i0, template: `
2383
- <ngt-group ngtCompound>
2384
- <ngt-group [ref]="floatRef">
2385
- <ng-content />
2386
- </ngt-group>
2387
- </ngt-group>
2388
- `, isInline: true });
2389
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsFloat, decorators: [{
2390
- type: Component,
2391
- args: [{
2392
- selector: 'ngts-float',
2393
- standalone: true,
2394
- template: `
2395
- <ngt-group ngtCompound>
2396
- <ngt-group [ref]="floatRef">
2397
- <ng-content />
2398
- </ngt-group>
2399
- </ngt-group>
2400
- `,
2401
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
2402
- }]
2403
- }], ctorParameters: function () { return []; }, propDecorators: { floatRef: [{
2404
- type: Input
2405
- }], speed: [{
2406
- type: Input
2407
- }], rotationIntensity: [{
2408
- type: Input
2409
- }], floatIntensity: [{
2410
- type: Input
2411
- }], floatingRange: [{
2412
- type: Input
2413
- }] } });
2414
-
2415
- function calcPosFromAngles(inclination, azimuth, vector = new Vector3()) {
2416
- const theta = Math.PI * (inclination - 0.5);
2417
- const phi = 2 * Math.PI * (azimuth - 0.5);
2418
- vector.x = Math.cos(phi);
2419
- vector.y = Math.sin(theta);
2420
- vector.z = Math.sin(phi);
2421
- return vector;
2422
- }
2423
- class NgtsSky extends NgtRxStore {
2424
- constructor() {
2425
- super(...arguments);
2426
- this.skyRef = injectNgtRef();
2427
- this.sky = new Sky();
2428
- }
2429
- set distance(distance) {
2430
- this.set({ distance });
2431
- }
2432
- set sunPosition(sunPosition) {
2433
- this.set({ sunPosition });
2434
- }
2435
- set inclination(inclination) {
2436
- this.set({ inclination });
2437
- }
2438
- set azimuth(azimuth) {
2439
- this.set({ azimuth });
2440
- }
2441
- set mieCoefficient(mieCoefficient) {
2442
- this.set({ mieCoefficient });
2443
- }
2444
- set mieDirectionalG(mieDirectionalG) {
2445
- this.set({ mieDirectionalG });
2446
- }
2447
- set rayleigh(rayleigh) {
2448
- this.set({ rayleigh });
2449
- }
2450
- set turbidity(turbidity) {
2451
- this.set({ turbidity });
2452
- }
2453
- initialize() {
2454
- super.initialize();
2455
- const inclination = 0.6;
2456
- const azimuth = 0.1;
2457
- this.set({
2458
- inclination,
2459
- azimuth,
2460
- distance: 1000,
2461
- mieCoefficient: 0.005,
2462
- mieDirectionalG: 0.8,
2463
- rayleigh: 0.5,
2464
- turbidity: 10,
2465
- sunPosition: calcPosFromAngles(inclination, azimuth),
2466
- });
2467
- this.connect('sunPosition', this.select(['inclination', 'azimuth'], ({ inclination, azimuth }) => calcPosFromAngles(inclination, azimuth)));
2468
- this.connect('scale', this.select(['distance'], ({ distance }) => new Vector3().setScalar(distance)));
2469
- }
2470
- }
2471
- NgtsSky.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSky, deps: null, target: i0.ɵɵFactoryTarget.Component });
2472
- NgtsSky.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsSky, isStandalone: true, selector: "ngts-sky", inputs: { skyRef: "skyRef", distance: "distance", sunPosition: "sunPosition", inclination: "inclination", azimuth: "azimuth", mieCoefficient: "mieCoefficient", mieDirectionalG: "mieDirectionalG", rayleigh: "rayleigh", turbidity: "turbidity" }, usesInheritance: true, ngImport: i0, template: `
2473
- <ngt-primitive ngtCompound *args="[sky]" [ref]="skyRef" [scale]="get('scale')">
2474
- <ngt-value [rawValue]="get('mieCoefficient')" attach="material.uniforms.mieCoefficient.value" />
2475
- <ngt-value [rawValue]="get('mieDirectionalG')" attach="material.uniforms.mieDirectionalG.value" />
2476
- <ngt-value [rawValue]="get('rayleigh')" attach="material.uniforms.rayleigh.value" />
2477
- <ngt-value [rawValue]="get('sunPosition')" attach="material.uniforms.sunPosition.value" />
2478
- <ngt-value [rawValue]="get('turbidity')" attach="material.uniforms.turbidity.value" />
2479
- </ngt-primitive>
2480
- `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
2481
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSky, decorators: [{
2482
- type: Component,
2483
- args: [{
2484
- selector: 'ngts-sky',
2485
- standalone: true,
2486
- template: `
2487
- <ngt-primitive ngtCompound *args="[sky]" [ref]="skyRef" [scale]="get('scale')">
2488
- <ngt-value [rawValue]="get('mieCoefficient')" attach="material.uniforms.mieCoefficient.value" />
2489
- <ngt-value [rawValue]="get('mieDirectionalG')" attach="material.uniforms.mieDirectionalG.value" />
2490
- <ngt-value [rawValue]="get('rayleigh')" attach="material.uniforms.rayleigh.value" />
2491
- <ngt-value [rawValue]="get('sunPosition')" attach="material.uniforms.sunPosition.value" />
2492
- <ngt-value [rawValue]="get('turbidity')" attach="material.uniforms.turbidity.value" />
2493
- </ngt-primitive>
2494
- `,
2495
- imports: [NgtArgs],
2496
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
2497
- }]
2498
- }], propDecorators: { skyRef: [{
2499
- type: Input
2500
- }], distance: [{
2501
- type: Input
2502
- }], sunPosition: [{
2503
- type: Input
2504
- }], inclination: [{
2505
- type: Input
2506
- }], azimuth: [{
2507
- type: Input
2508
- }], mieCoefficient: [{
2509
- type: Input
2510
- }], mieDirectionalG: [{
2511
- type: Input
2512
- }], rayleigh: [{
2513
- type: Input
2514
- }], turbidity: [{
2515
- type: Input
2516
- }] } });
2517
-
2518
- const SparklesMaterial = shaderMaterial({ time: 0, pixelRatio: 1 },
2519
- // language=GLSL
2520
- `
2521
- uniform float pixelRatio;
2522
- uniform float time;
2523
-
2524
- attribute float size;
2525
- attribute float speed;
2526
- attribute float opacity;
2527
- attribute vec3 noise;
2528
- attribute vec3 color;
2529
-
2530
- varying vec3 vColor;
2531
- varying float vOpacity;
2532
-
2533
- void main() {
2534
- vec4 modelPosition = modelMatrix * vec4(position, 1.0);
2535
-
2536
- modelPosition.y += sin(time * speed + modelPosition.x * noise.x * 100.0) * 0.2;
2537
- modelPosition.z += cos(time * speed + modelPosition.x * noise.y * 100.0) * 0.2;
2538
- modelPosition.x += cos(time * speed + modelPosition.x * noise.z * 100.0) * 0.2;
2539
-
2540
- vec4 viewPosition = viewMatrix * modelPosition;
2541
- vec4 projectionPostion = projectionMatrix * viewPosition;
2542
-
2543
- gl_Position = projectionPostion;
2544
- gl_PointSize = size * 25. * pixelRatio;
2545
- gl_PointSize *= (1.0 / - viewPosition.z);
2546
-
2547
- vColor = color;
2548
- vOpacity = opacity;
2549
- }
2550
- `,
2551
- // language=GLSL
2552
- `
2553
- varying vec3 vColor;
2554
- varying float vOpacity;
2555
-
2556
- void main() {
2557
- float distanceToCenter = distance(gl_PointCoord, vec2(0.5));
2558
- float strength = 0.05 / distanceToCenter - 0.1;
2559
-
2560
- gl_FragColor = vec4(vColor, strength * vOpacity);
2561
- }
2562
- `);
2563
- extend({ SparklesMaterial, Points, BufferGeometry, BufferAttribute });
2564
- const isFloat32Array = (def) => def && def.constructor === Float32Array;
2565
- const expandColor = (v) => [v.r, v.g, v.b];
2566
- const isVector = (v) => v instanceof Vector2 || v instanceof Vector3 || v instanceof Vector4;
2567
- const normalizeVector = (v) => {
2568
- if (Array.isArray(v))
2569
- return v;
2570
- else if (isVector(v))
2571
- return v.toArray();
2572
- return [v, v, v];
2573
- };
2574
- function usePropAsIsOrAsAttribute(count, prop, setDefault) {
2575
- if (prop !== undefined) {
2576
- if (isFloat32Array(prop)) {
2577
- return prop;
2578
- }
2579
- else {
2580
- if (prop instanceof Color) {
2581
- const a = Array.from({ length: count * 3 }, () => expandColor(prop)).flat();
2582
- return Float32Array.from(a);
2583
- }
2584
- else if (isVector(prop) || Array.isArray(prop)) {
2585
- const a = Array.from({ length: count * 3 }, () => normalizeVector(prop)).flat();
2586
- return Float32Array.from(a);
2587
- }
2588
- return Float32Array.from({ length: count }, () => prop);
2589
- }
2590
- }
2591
- return Float32Array.from({ length: count }, setDefault);
2592
- }
2593
- class NgtsSparkles extends NgtRxStore {
2594
- /** Number of particles (default: 100) */
2595
- set count(count) {
2596
- this.set({ count });
2597
- }
2598
- /** Speed of particles (default: 1) */
2599
- set speed(speed) {
2600
- this.set({ speed });
2601
- }
2602
- /** Opacity of particles (default: 1) */
2603
- set opacity(opacity) {
2604
- this.set({ opacity });
2605
- }
2606
- /** Color of particles (default: 100) */
2607
- set color(color) {
2608
- this.set({ color });
2609
- }
2610
- /** Size of particles (default: randomized between 0 and 1) */
2611
- set size(size) {
2612
- this.set({ size });
2613
- }
2614
- /** The space the particles occupy (default: 1) */
2615
- set scale(scale) {
2616
- this.set({ scale });
2617
- }
2618
- /** Movement factor (default: 1) */
2619
- set noise(noise) {
2620
- this.set({ noise });
2621
- }
2622
- initialize() {
2623
- super.initialize();
2624
- this.set({
2625
- noise: 1,
2626
- count: 100,
2627
- speed: 1,
2628
- opacity: 1,
2629
- scale: 1,
2630
- });
2631
- this.connect('positions', this.select(['count', 'scale'], ({ count, scale }) => Float32Array.from(Array.from({ length: count }, () => normalizeVector(scale).map(MathUtils.randFloatSpread)).flat())));
2632
- this.connect('sizes', this.getAttribute$('size', { setDefault: Math.random }));
2633
- this.connect('opacities', this.getAttribute$('opacity'));
2634
- this.connect('speeds', this.getAttribute$('speed'));
2635
- this.connect('noises', this.getAttribute$('noise', {
2636
- countValue: (_, count) => count * 3,
2637
- }));
2638
- this.connect('colors', this.getAttribute$('color', {
2639
- keyValue: (color) => (!isFloat32Array(color) ? new Color(color) : color),
2640
- countValue: (color, count) => (color === undefined ? count * 3 : count),
2641
- setDefault: () => 1,
2642
- }));
2643
- }
2644
- constructor() {
2645
- super();
2646
- this.store = inject(NgtStore);
2647
- this.dpr = this.store.get('viewport', 'dpr');
2648
- this.materialRef = injectNgtRef();
2649
- this.pointsRef = injectNgtRef();
2650
- injectBeforeRender(this.onBeforeRender.bind(this));
2651
- }
2652
- onBeforeRender({ clock }) {
2653
- if (!this.materialRef.nativeElement)
2654
- return;
2655
- this.materialRef.nativeElement.uniforms['time'].value = clock.elapsedTime;
2656
- }
2657
- getAttribute$(key, options) {
2658
- options !== null && options !== void 0 ? options : (options = {});
2659
- if (!options.keyValue) {
2660
- options.keyValue = (value) => value;
2661
- }
2662
- if (!options.countValue) {
2663
- options.countValue = (_, count) => count;
2664
- }
2665
- return this.select(key).pipe(startWith(this.get(key) || undefined), withLatestFrom(this.select('count')), map(([value, count]) => usePropAsIsOrAsAttribute(options.countValue(value, count), options.keyValue(value, count), options === null || options === void 0 ? void 0 : options.setDefault)));
2666
- }
2667
- }
2668
- NgtsSparkles.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSparkles, deps: [], target: i0.ɵɵFactoryTarget.Component });
2669
- NgtsSparkles.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsSparkles, isStandalone: true, selector: "ngts-sparkles", inputs: { pointsRef: "pointsRef", count: "count", speed: "speed", opacity: "opacity", color: "color", size: "size", scale: "scale", noise: "noise" }, usesInheritance: true, ngImport: i0, template: `
2670
- <ngt-points ngtCompount [ref]="pointsRef">
2671
- <ngt-buffer-geometry>
2672
- <ngt-buffer-attribute *args="[get('positions'), 3]" attach="attributes.position" />
2673
- <ngt-buffer-attribute *args="[get('sizes'), 1]" attach="attributes.size" />
2674
- <ngt-buffer-attribute *args="[get('opacities'), 1]" attach="attributes.opacity" />
2675
- <ngt-buffer-attribute *args="[get('speeds'), 1]" attach="attributes.speed" />
2676
- <ngt-buffer-attribute *args="[get('colors'), 3]" attach="attributes.color" />
2677
- <ngt-buffer-attribute *args="[get('noises'), 3]" attach="attributes.noise" />
2678
- </ngt-buffer-geometry>
2679
- <ngt-sparkles-material [ref]="materialRef" [transparent]="true" [depthWrite]="false" [pixelRatio]="dpr" />
2680
- </ngt-points>
2681
- `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
2682
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSparkles, decorators: [{
2683
- type: Component,
2684
- args: [{
2685
- selector: 'ngts-sparkles',
2686
- standalone: true,
2687
- template: `
2688
- <ngt-points ngtCompount [ref]="pointsRef">
2689
- <ngt-buffer-geometry>
2690
- <ngt-buffer-attribute *args="[get('positions'), 3]" attach="attributes.position" />
2691
- <ngt-buffer-attribute *args="[get('sizes'), 1]" attach="attributes.size" />
2692
- <ngt-buffer-attribute *args="[get('opacities'), 1]" attach="attributes.opacity" />
2693
- <ngt-buffer-attribute *args="[get('speeds'), 1]" attach="attributes.speed" />
2694
- <ngt-buffer-attribute *args="[get('colors'), 3]" attach="attributes.color" />
2695
- <ngt-buffer-attribute *args="[get('noises'), 3]" attach="attributes.noise" />
2696
- </ngt-buffer-geometry>
2697
- <ngt-sparkles-material [ref]="materialRef" [transparent]="true" [depthWrite]="false" [pixelRatio]="dpr" />
2698
- </ngt-points>
2699
- `,
2700
- imports: [NgtArgs],
2701
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
2702
- }]
2703
- }], ctorParameters: function () { return []; }, propDecorators: { pointsRef: [{
2704
- type: Input
2705
- }], count: [{
2706
- type: Input
2707
- }], speed: [{
2708
- type: Input
2709
- }], opacity: [{
2710
- type: Input
2711
- }], color: [{
2712
- type: Input
2713
- }], size: [{
2714
- type: Input
2715
- }], scale: [{
2716
- type: Input
2717
- }], noise: [{
2718
- type: Input
2719
- }] } });
2720
-
2721
- class NgtsSpotLightInput extends NgtRxStore {
2722
- set depthBuffer(depthBuffer) {
2723
- this.set({ depthBuffer });
2724
- }
2725
- set angle(angle) {
2726
- this.set({ angle });
2727
- }
2728
- set distance(distance) {
2729
- this.set({ distance });
2730
- }
2731
- set attenuation(attenuation) {
2732
- this.set({ attenuation });
2733
- }
2734
- set anglePower(anglePower) {
2735
- this.set({ anglePower });
2736
- }
2737
- set radiusTop(radiusTop) {
2738
- this.set({ radiusTop });
2739
- }
2740
- set radiusBottom(radiusBottom) {
2741
- this.set({ radiusBottom });
2742
- }
2743
- set opacity(opacity) {
2744
- this.set({ opacity });
2745
- }
2746
- set color(color) {
2747
- this.set({ color });
2748
- }
2749
- set debug(debug) {
2750
- this.set({ debug });
2751
- }
2752
- }
2753
- NgtsSpotLightInput.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSpotLightInput, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2754
- NgtsSpotLightInput.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtsSpotLightInput, inputs: { depthBuffer: "depthBuffer", angle: "angle", distance: "distance", attenuation: "attenuation", anglePower: "anglePower", radiusTop: "radiusTop", radiusBottom: "radiusBottom", opacity: "opacity", color: "color", debug: "debug" }, usesInheritance: true, ngImport: i0 });
2755
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSpotLightInput, decorators: [{
2756
- type: Directive
2757
- }], propDecorators: { depthBuffer: [{
2758
- type: Input
2759
- }], angle: [{
2760
- type: Input
2761
- }], distance: [{
2762
- type: Input
2763
- }], attenuation: [{
2764
- type: Input
2765
- }], anglePower: [{
2766
- type: Input
2767
- }], radiusTop: [{
2768
- type: Input
2769
- }], radiusBottom: [{
2770
- type: Input
2771
- }], opacity: [{
2772
- type: Input
2773
- }], color: [{
2774
- type: Input
2775
- }], debug: [{
2776
- type: Input
2777
- }] } });
2778
-
2779
- extend({ Mesh });
2780
- class NgtsVolumetricMesh extends NgtsSpotLightInput {
2781
- initialize() {
2782
- super.initialize();
2783
- this.set({ opacity: 1, color: 'white', distance: 5, angle: 0.15, attenuation: 5, anglePower: 5 });
2784
- }
2785
- constructor() {
2786
- super();
2787
- this.mesh = injectNgtRef();
2788
- this.material = new SpotLightMaterial();
2789
- this.nullRaycast = () => null;
2790
- this.vec = new THREE.Vector3();
2791
- this.store = inject(NgtStore);
2792
- this.connect('normalizedRadiusTop', this.select('radiusTop').pipe(startWithUndefined(), map((radiusTop) => (radiusTop === undefined ? 0.1 : radiusTop))));
2793
- this.connect('normalizedRadiusBottom', combineLatest([this.select('radiusBottom').pipe(startWithUndefined()), this.select('angle')]).pipe(map(([radiusBottom, angle]) => (radiusBottom === undefined ? angle * 7 : radiusBottom))));
2794
- this.connect('geometry', combineLatest([
2795
- this.select('normalizedRadiusTop'),
2796
- this.select('normalizedRadiusBottom'),
2797
- this.select('distance'),
2798
- ]).pipe(map(([radiusTop, radiusBottom, distance]) => {
2799
- const geometry = new THREE.CylinderGeometry(radiusTop, radiusBottom, distance, 128, 64, true);
2800
- geometry.applyMatrix4(new THREE.Matrix4().makeTranslation(0, -distance / 2, 0));
2801
- geometry.applyMatrix4(new THREE.Matrix4().makeRotationX(-Math.PI / 2));
2802
- return geometry;
2803
- })));
2804
- this.connect('cameraNear', this.store.select('camera').pipe(map((camera) => camera.near)));
2805
- this.connect('cameraFar', this.store.select('camera').pipe(map((camera) => camera.far)));
2806
- this.connect('resolution', combineLatest([
2807
- this.select('depthBuffer').pipe(startWithUndefined()),
2808
- this.store.select('size'),
2809
- this.store.select('viewport', 'dpr'),
2810
- ]).pipe(map(([depthBuffer, size, dpr]) => (depthBuffer ? [size.width * dpr, size.height * dpr] : [0, 0]))));
2811
- injectBeforeRender(() => {
2812
- this.material.uniforms['spotPosition'].value.copy(this.mesh.nativeElement.getWorldPosition(this.vec));
2813
- this.mesh.nativeElement.lookAt(this.mesh.nativeElement.parent.target.getWorldPosition(this.vec));
2814
- });
2815
- }
2816
- }
2817
- NgtsVolumetricMesh.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsVolumetricMesh, deps: [], target: i0.ɵɵFactoryTarget.Component });
2818
- NgtsVolumetricMesh.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsVolumetricMesh, isStandalone: true, selector: "ngts-volumetric-mesh", usesInheritance: true, ngImport: i0, template: `
2819
- <ngt-mesh [ref]="mesh" [geometry]="get('geometry')" [raycast]="nullRaycast">
2820
- <ngt-primitive *args="[material]" attach="material">
2821
- <ngt-value [rawValue]="get('opacity')" attach="uniforms.opacity.value" />
2822
- <ngt-value [rawValue]="get('color')" attach="uniforms.lightColor.value" />
2823
- <ngt-value [rawValue]="get('attenuation')" attach="uniforms.attenuation.value" />
2824
- <ngt-value [rawValue]="get('anglePower')" attach="uniforms.anglePower.value" />
2825
- <ngt-value [rawvalue]="get('depthBuffer')" attach="uniforms.depth.value" />
2826
- <ngt-value [rawvalue]="get('cameraNear')" attach="uniforms.cameraNear.value" />
2827
- <ngt-value [rawvalue]="get('cameraFar')" attach="uniforms.cameraFar.value" />
2828
- <ngt-value [rawvalue]="get('resolution')" attach="uniforms.resolution.value" />
2829
- </ngt-primitive>
2830
- </ngt-mesh>
2831
- `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
2832
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsVolumetricMesh, decorators: [{
2833
- type: Component,
2834
- args: [{
2835
- selector: 'ngts-volumetric-mesh',
2836
- standalone: true,
2837
- template: `
2838
- <ngt-mesh [ref]="mesh" [geometry]="get('geometry')" [raycast]="nullRaycast">
2839
- <ngt-primitive *args="[material]" attach="material">
2840
- <ngt-value [rawValue]="get('opacity')" attach="uniforms.opacity.value" />
2841
- <ngt-value [rawValue]="get('color')" attach="uniforms.lightColor.value" />
2842
- <ngt-value [rawValue]="get('attenuation')" attach="uniforms.attenuation.value" />
2843
- <ngt-value [rawValue]="get('anglePower')" attach="uniforms.anglePower.value" />
2844
- <ngt-value [rawvalue]="get('depthBuffer')" attach="uniforms.depth.value" />
2845
- <ngt-value [rawvalue]="get('cameraNear')" attach="uniforms.cameraNear.value" />
2846
- <ngt-value [rawvalue]="get('cameraFar')" attach="uniforms.cameraFar.value" />
2847
- <ngt-value [rawvalue]="get('resolution')" attach="uniforms.resolution.value" />
2848
- </ngt-primitive>
2849
- </ngt-mesh>
2850
- `,
2851
- imports: [NgtArgs],
2852
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
2853
- }]
2854
- }], ctorParameters: function () { return []; } });
2855
-
2856
- extend({ SpotLight, SpotLightHelper, Group });
2857
- const NGTS_SPOT_LIGHT_API = new InjectionToken('NgtsSpotLight API');
2858
- function spotLightApiFactory(spotLight) {
2859
- const api = {
2860
- spotLight: spotLight.spotLightRef,
2861
- };
2862
- Object.defineProperty(api, 'debug', {
2863
- get: () => spotLight.get('debug'),
2864
- });
2865
- return api;
2866
- }
2867
- class NgtsSpotLight extends NgtsSpotLightInput {
2868
- constructor() {
2869
- super(...arguments);
2870
- this.spotLightRef = injectNgtRef();
2871
- }
2872
- set volumetric(volumetric) {
2873
- this.set({ volumetric });
2874
- }
2875
- initialize() {
2876
- super.initialize();
2877
- this.set({
2878
- opacity: 1,
2879
- color: 'white',
2880
- distance: 5,
2881
- angle: 0.15,
2882
- attenuation: 5,
2883
- anglePower: 5,
2884
- volumetric: true,
2885
- debug: false,
2886
- });
2887
- }
2888
- }
2889
- NgtsSpotLight.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSpotLight, deps: null, target: i0.ɵɵFactoryTarget.Component });
2890
- NgtsSpotLight.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsSpotLight, isStandalone: true, selector: "ngts-spot-light", inputs: { spotLightRef: "spotLightRef", volumetric: "volumetric" }, providers: [{ provide: NGTS_SPOT_LIGHT_API, useFactory: spotLightApiFactory, deps: [NgtsSpotLight] }], usesInheritance: true, ngImport: i0, template: `
2891
- <ngt-group>
2892
- <ng-container *ngIf="get('debug') && spotLightRef.nativeElement">
2893
- <ngt-spot-light-helper *args="[spotLightRef.nativeElement]" />
2894
- </ng-container>
2895
- <ngt-spot-light
2896
- [ref]="spotLightRef"
2897
- [color]="get('color')"
2898
- [distance]="get('distance')"
2899
- [angle]="get('angle')"
2900
- [castShadow]="true"
2901
- ngtCompound
2902
- >
2903
- <ngts-volumetric-mesh
2904
- *ngIf="get('volumetric')"
2905
- [debug]="get('debug')"
2906
- [opacity]="get('opacity')"
2907
- [radiusTop]="get('radiusTop')"
2908
- [radiusBottom]="get('radiusBottom')"
2909
- [depthBuffer]="get('depthBuffer')"
2910
- [color]="get('color')"
2911
- [distance]="get('distance')"
2912
- [angle]="get('angle')"
2913
- [attenuation]="get('attenuation')"
2914
- [anglePower]="get('anglePower')"
2915
- />
2916
- </ngt-spot-light>
2917
- <ng-content />
2918
- </ngt-group>
2919
- `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }, { kind: "component", type: NgtsVolumetricMesh, selector: "ngts-volumetric-mesh" }] });
2920
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSpotLight, decorators: [{
2921
- type: Component,
2922
- args: [{
2923
- selector: 'ngts-spot-light',
2924
- standalone: true,
2925
- template: `
2926
- <ngt-group>
2927
- <ng-container *ngIf="get('debug') && spotLightRef.nativeElement">
2928
- <ngt-spot-light-helper *args="[spotLightRef.nativeElement]" />
2929
- </ng-container>
2930
- <ngt-spot-light
2931
- [ref]="spotLightRef"
2932
- [color]="get('color')"
2933
- [distance]="get('distance')"
2934
- [angle]="get('angle')"
2935
- [castShadow]="true"
2936
- ngtCompound
2937
- >
2938
- <ngts-volumetric-mesh
2939
- *ngIf="get('volumetric')"
2940
- [debug]="get('debug')"
2941
- [opacity]="get('opacity')"
2942
- [radiusTop]="get('radiusTop')"
2943
- [radiusBottom]="get('radiusBottom')"
2944
- [depthBuffer]="get('depthBuffer')"
2945
- [color]="get('color')"
2946
- [distance]="get('distance')"
2947
- [angle]="get('angle')"
2948
- [attenuation]="get('attenuation')"
2949
- [anglePower]="get('anglePower')"
2950
- />
2951
- </ngt-spot-light>
2952
- <ng-content />
2953
- </ngt-group>
2954
- `,
2955
- imports: [NgIf, NgtArgs, NgtsVolumetricMesh],
2956
- providers: [{ provide: NGTS_SPOT_LIGHT_API, useFactory: spotLightApiFactory, deps: [NgtsSpotLight] }],
2957
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
2958
- }]
2959
- }], propDecorators: { spotLightRef: [{
2960
- type: Input
2961
- }], volumetric: [{
2962
- type: Input
2963
- }] } });
2964
-
2965
- class NgtsSpotLightShadowMeshInput extends NgtRxStore {
2966
- constructor() {
2967
- super(...arguments);
2968
- this.map$ = this.select('map');
2969
- }
2970
- set distance(distance) {
2971
- this.set({ distance });
2972
- }
2973
- set alphaTest(alphaTest) {
2974
- this.set({ alphaTest });
2975
- }
2976
- set scale(scale) {
2977
- this.set({ scale });
2978
- }
2979
- set map(map) {
2980
- this.set({ map });
2981
- }
2982
- set shader(shader) {
2983
- this.set({ shader });
2984
- }
2985
- set width(width) {
2986
- this.set({ width });
2987
- }
2988
- set height(height) {
2989
- this.set({ height });
2990
- }
2991
- }
2992
- NgtsSpotLightShadowMeshInput.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSpotLightShadowMeshInput, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2993
- NgtsSpotLightShadowMeshInput.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtsSpotLightShadowMeshInput, inputs: { distance: "distance", alphaTest: "alphaTest", scale: "scale", map: "map", shader: "shader", width: "width", height: "height" }, usesInheritance: true, ngImport: i0 });
2994
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSpotLightShadowMeshInput, decorators: [{
2995
- type: Directive
2996
- }], propDecorators: { distance: [{
2997
- type: Input
2998
- }], alphaTest: [{
2999
- type: Input
3000
- }], scale: [{
3001
- type: Input
3002
- }], map: [{
3003
- type: Input
3004
- }], shader: [{
3005
- type: Input
3006
- }], width: [{
3007
- type: Input
3008
- }], height: [{
3009
- type: Input
3010
- }] } });
3011
-
3012
- const isSpotLight = (child) => {
3013
- return child === null || child === void 0 ? void 0 : child.isSpotLight;
3014
- };
3015
- function injectShadowMeshCommon(spotLight, mesh, width, height, distance) {
3016
- const pos = new THREE.Vector3();
3017
- const dir = new THREE.Vector3();
3018
- const commonEffect = (instance) => {
3019
- instance.hold(combineLatest([
3020
- spotLight.$,
3021
- instance.select('width').pipe(startWith(width)),
3022
- instance.select('height').pipe(startWith(height)),
3023
- ]), ([light, width, height]) => {
3024
- if (isSpotLight(light)) {
3025
- console.log('[NGTS] SpotLight instance -->', light);
3026
- light.shadow.mapSize.set(width, height);
3027
- light.shadow.needsUpdate = true;
3028
- }
3029
- else {
3030
- throw new Error('<ngts-spot-light-shadow> must be a child of a <ngts-spot-light>');
3031
- }
3032
- });
3033
- };
3034
- injectBeforeRender(() => {
3035
- if (!spotLight.nativeElement)
3036
- return;
3037
- const A = spotLight.nativeElement.position;
3038
- const B = spotLight.nativeElement.target.position;
3039
- dir.copy(B).sub(A);
3040
- const len = dir.length();
3041
- dir.normalize().multiplyScalar(len * distance);
3042
- pos.copy(A).add(dir);
3043
- if (mesh.nativeElement) {
3044
- mesh.nativeElement.position.copy(pos);
3045
- mesh.nativeElement.lookAt(spotLight.nativeElement.target.position);
3046
- }
3047
- });
3048
- return commonEffect;
3049
- }
3050
-
3051
- extend({ Mesh, PlaneGeometry, MeshBasicMaterial });
3052
- class NgtsSpotLightShadowNoShader extends NgtsSpotLightShadowMeshInput {
3053
- constructor() {
3054
- super(...arguments);
3055
- this.mesh = injectNgtRef();
3056
- this.spotLightApi = inject(NGTS_SPOT_LIGHT_API);
3057
- this.DoubleSide = THREE.DoubleSide;
3058
- this.runInContext = createRunInContext();
3059
- }
3060
- initialize() {
3061
- super.initialize();
3062
- this.set({ distance: 0.4, alphaTest: 0.5, width: 512, height: 512 });
3063
- this.hold(this.select('map'), (map) => {
3064
- if (map) {
3065
- map.wrapS = map.wrapT = THREE.RepeatWrapping;
3066
- checkUpdate(map);
3067
- }
3068
- });
3069
- }
3070
- ngOnInit() {
3071
- const commonEffect = this.runInContext(() => {
3072
- return injectShadowMeshCommon(this.spotLightApi.spotLight, this.mesh, this.get('width'), this.get('height'), this.get('distance'));
3073
- });
3074
- commonEffect(this);
3075
- }
3076
- }
3077
- NgtsSpotLightShadowNoShader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSpotLightShadowNoShader, deps: null, target: i0.ɵɵFactoryTarget.Component });
3078
- NgtsSpotLightShadowNoShader.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsSpotLightShadowNoShader, isStandalone: true, selector: "ngts-spot-light-shadow-no-shader", usesInheritance: true, ngImport: i0, template: `
3079
- <ngt-mesh [ref]="mesh" [scale]="get('scale')" [castShadow]="true">
3080
- <ngt-plane-geometry />
3081
- <ngt-mesh-basic-material
3082
- [transparent]="true"
3083
- [side]="DoubleSide"
3084
- [alphaTest]="get('alphaTest')"
3085
- [alphaMap]="map$ | ngtPush"
3086
- [opacity]="spotLightApi.debug ? 1 : 0"
3087
- >
3088
- <ng-content />
3089
- </ngt-mesh-basic-material>
3090
- </ngt-mesh>
3091
- `, isInline: true, dependencies: [{ kind: "pipe", type: NgtPush, name: "ngtPush" }] });
3092
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSpotLightShadowNoShader, decorators: [{
3093
- type: Component,
3094
- args: [{
3095
- selector: 'ngts-spot-light-shadow-no-shader',
3096
- standalone: true,
3097
- template: `
3098
- <ngt-mesh [ref]="mesh" [scale]="get('scale')" [castShadow]="true">
3099
- <ngt-plane-geometry />
3100
- <ngt-mesh-basic-material
3101
- [transparent]="true"
3102
- [side]="DoubleSide"
3103
- [alphaTest]="get('alphaTest')"
3104
- [alphaMap]="map$ | ngtPush"
3105
- [opacity]="spotLightApi.debug ? 1 : 0"
3106
- >
3107
- <ng-content />
3108
- </ngt-mesh-basic-material>
3109
- </ngt-mesh>
3110
- `,
3111
- imports: [NgtPush],
3112
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
3113
- }]
3114
- }] });
3115
-
3116
- extend({ Mesh, PlaneGeometry, MeshBasicMaterial });
3117
- class NgtsSpotLightShadowShader extends NgtsSpotLightShadowMeshInput {
3118
- initialize() {
3119
- super.initialize();
3120
- this.set({ distance: 0.4, alphaTest: 0.5, width: 512, height: 512, scale: 1 });
3121
- }
3122
- constructor() {
3123
- super();
3124
- this.mesh = injectNgtRef();
3125
- this.spotLightApi = inject(NGTS_SPOT_LIGHT_API);
3126
- this.DoubleSide = THREE.DoubleSide;
3127
- this.RepeatWrapping = THREE.RepeatWrapping;
3128
- this.runInContext = createRunInContext();
3129
- this.texture$ = this.select('renderTarget', 'texture');
3130
- this.uniforms = {
3131
- uShadowMap: { value: this.get('map') },
3132
- uTime: { value: 0 },
3133
- };
3134
- this.connect('renderTarget', combineLatest([this.select('width'), this.select('height')]).pipe(map(([width, height]) => {
3135
- return new THREE.WebGLRenderTarget(width, height, {
3136
- format: THREE.RGBAFormat,
3137
- encoding: THREE.LinearEncoding,
3138
- stencilBuffer: false,
3139
- // depthTexture: null!
3140
- });
3141
- })));
3142
- this.connect('fsQuad', this.select('shader').pipe(map((shader) => {
3143
- return new FullScreenQuad(new THREE.ShaderMaterial({
3144
- uniforms: this.uniforms,
3145
- vertexShader: /* glsl */ `
3146
- varying vec2 vUv;
3147
-
3148
- void main() {
3149
- vUv = uv;
3150
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
3151
- }
3152
- `,
3153
- fragmentShader: shader,
3154
- }));
3155
- })));
3156
- this.hold(this.select('map'), (map) => {
3157
- this.uniforms.uShadowMap.value = map;
3158
- });
3159
- this.effect(this.select('fsQuad'), (fsQuad) => {
3160
- return () => {
3161
- fsQuad.dispose();
3162
- fsQuad.material.dispose();
3163
- };
3164
- });
3165
- this.effect(this.select('renderTarget'), (renderTarget) => {
3166
- return () => {
3167
- renderTarget.dispose();
3168
- };
3169
- });
3170
- injectBeforeRender(({ delta, gl }) => {
3171
- this.uniforms.uTime.value += delta;
3172
- const fsQuad = this.get('fsQuad');
3173
- const renderTarget = this.get('renderTarget');
3174
- if (fsQuad && renderTarget) {
3175
- gl.setRenderTarget(renderTarget);
3176
- fsQuad.render(gl);
3177
- gl.setRenderTarget(null);
3178
- }
3179
- });
3180
- }
3181
- ngOnInit() {
3182
- const commonEffect = this.runInContext(() => {
3183
- return injectShadowMeshCommon(this.spotLightApi.spotLight, this.mesh, this.get('width'), this.get('height'), this.get('distance'));
3184
- });
3185
- commonEffect(this);
3186
- }
3187
- }
3188
- NgtsSpotLightShadowShader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSpotLightShadowShader, deps: [], target: i0.ɵɵFactoryTarget.Component });
3189
- NgtsSpotLightShadowShader.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsSpotLightShadowShader, isStandalone: true, selector: "ngts-spot-light-shadow-shader", usesInheritance: true, ngImport: i0, template: `
3190
- <ngt-mesh [ref]="mesh" [scale]="get('scale')" [castShadow]="true">
3191
- <ngt-plane-geometry />
3192
- <ngt-mesh-basic-material
3193
- [transparent]="true"
3194
- [side]="DoubleSide"
3195
- [alphaTest]="get('alphaTest')"
3196
- [alphaMap]="texture$ | ngtPush"
3197
- [opacity]="spotLightApi.debug ? 1 : 0"
3198
- >
3199
- <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapS" />
3200
- <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapT" />
3201
- <ng-content />
3202
- </ngt-mesh-basic-material>
3203
- </ngt-mesh>
3204
- `, isInline: true, dependencies: [{ kind: "pipe", type: NgtPush, name: "ngtPush" }] });
3205
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSpotLightShadowShader, decorators: [{
3206
- type: Component,
3207
- args: [{
3208
- selector: 'ngts-spot-light-shadow-shader',
3209
- standalone: true,
3210
- template: `
3211
- <ngt-mesh [ref]="mesh" [scale]="get('scale')" [castShadow]="true">
3212
- <ngt-plane-geometry />
3213
- <ngt-mesh-basic-material
3214
- [transparent]="true"
3215
- [side]="DoubleSide"
3216
- [alphaTest]="get('alphaTest')"
3217
- [alphaMap]="texture$ | ngtPush"
3218
- [opacity]="spotLightApi.debug ? 1 : 0"
3219
- >
3220
- <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapS" />
3221
- <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapT" />
3222
- <ng-content />
3223
- </ngt-mesh-basic-material>
3224
- </ngt-mesh>
3225
- `,
3226
- imports: [NgtPush],
3227
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
3228
- }]
3229
- }], ctorParameters: function () { return []; } });
3230
-
3231
- class NgtsSpotLightShadow extends NgtsSpotLightShadowMeshInput {
3232
- }
3233
- NgtsSpotLightShadow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSpotLightShadow, deps: null, target: i0.ɵɵFactoryTarget.Component });
3234
- NgtsSpotLightShadow.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsSpotLightShadow, isStandalone: true, selector: "ngts-spot-light-shadow", usesInheritance: true, ngImport: i0, template: `
3235
- <ngts-spot-light-shadow-shader
3236
- *ngIf="get('shader'); else noShader"
3237
- [distance]="get('distance')"
3238
- [shader]="get('shader')"
3239
- [alphaTest]="get('alphaTest')"
3240
- [scale]="get('scale')"
3241
- [map]="get('map')"
3242
- [width]="get('width')"
3243
- [height]="get('height')"
3244
- />
3245
- <ng-template #noShader>
3246
- <ngts-spot-light-shadow-no-shader
3247
- [distance]="get('distance')"
3248
- [alphaTest]="get('alphaTest')"
3249
- [scale]="get('scale')"
3250
- [map]="get('map')"
3251
- [width]="get('width')"
3252
- [height]="get('height')"
3253
- />
3254
- </ng-template>
3255
- `, isInline: true, dependencies: [{ kind: "component", type: NgtsSpotLightShadowShader, selector: "ngts-spot-light-shadow-shader" }, { kind: "component", type: NgtsSpotLightShadowNoShader, selector: "ngts-spot-light-shadow-no-shader" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
3256
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsSpotLightShadow, decorators: [{
3257
- type: Component,
3258
- args: [{
3259
- selector: 'ngts-spot-light-shadow',
3260
- standalone: true,
3261
- template: `
3262
- <ngts-spot-light-shadow-shader
3263
- *ngIf="get('shader'); else noShader"
3264
- [distance]="get('distance')"
3265
- [shader]="get('shader')"
3266
- [alphaTest]="get('alphaTest')"
3267
- [scale]="get('scale')"
3268
- [map]="get('map')"
3269
- [width]="get('width')"
3270
- [height]="get('height')"
3271
- />
3272
- <ng-template #noShader>
3273
- <ngts-spot-light-shadow-no-shader
3274
- [distance]="get('distance')"
3275
- [alphaTest]="get('alphaTest')"
3276
- [scale]="get('scale')"
3277
- [map]="get('map')"
3278
- [width]="get('width')"
3279
- [height]="get('height')"
3280
- />
3281
- </ng-template>
3282
- `,
3283
- imports: [NgtsSpotLightShadowShader, NgtsSpotLightShadowNoShader, NgIf],
3284
- }]
3285
- }] });
3286
-
3287
- const presets = {
3288
- rembrandt: {
3289
- main: [1, 2, 1],
3290
- fill: [-2, -0.5, -2],
3291
- },
3292
- portrait: {
3293
- main: [-1, 2, 0.5],
3294
- fill: [-1, 0.5, -1.5],
3295
- },
3296
- upfront: {
3297
- main: [0, 2, 1],
3298
- fill: [-1, 0.5, -1.5],
3299
- },
3300
- soft: {
3301
- main: [-2, 4, 4],
3302
- fill: [-1, 0.5, -1.5],
3303
- },
3304
- };
3305
- class NgtsStageRefit {
3306
- constructor() {
3307
- this.boundsApi = inject(NGTS_BOUNDS_API);
3308
- this.radius = 0;
3309
- this.adjustCamera = true;
3310
- }
3311
- ngOnChanges() {
3312
- if (this.adjustCamera) {
3313
- this.boundsApi.refresh().clip().fit();
3314
- }
3315
- }
3316
- }
3317
- NgtsStageRefit.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsStageRefit, deps: [], target: i0.ɵɵFactoryTarget.Directive });
3318
- NgtsStageRefit.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtsStageRefit, isStandalone: true, selector: "ngts-stage-refit", inputs: { radius: "radius", adjustCamera: "adjustCamera" }, usesOnChanges: true, ngImport: i0 });
3319
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsStageRefit, decorators: [{
3320
- type: Directive,
3321
- args: [{ selector: 'ngts-stage-refit', standalone: true }]
3322
- }], propDecorators: { radius: [{
3323
- type: Input
3324
- }], adjustCamera: [{
3325
- type: Input
3326
- }] } });
3327
- extend({ AmbientLight, SpotLight, Vector2, PointLight, Group });
3328
- class NgtsStage extends NgtRxStore {
3329
- constructor() {
3330
- super(...arguments);
3331
- this.cdr = inject(ChangeDetectorRef);
3332
- this.Number = Number;
3333
- this.centered = new EventEmitter();
3334
- }
3335
- set preset(preset) {
3336
- this.set({ preset });
3337
- }
3338
- set shadows(shadows) {
3339
- this.set({ shadows });
3340
- }
3341
- set adjustCamera(adjustCamera) {
3342
- this.set({ adjustCamera });
3343
- }
3344
- set environment(environment) {
3345
- this.set({ environment });
3346
- }
3347
- set intensity(intensity) {
3348
- this.set({ intensity });
3349
- }
3350
- set center(center) {
3351
- this.set({ center });
3352
- }
3353
- initialize() {
3354
- super.initialize();
3355
- this.set({
3356
- adjustCamera: true,
3357
- intensity: 0.5,
3358
- shadows: 'contact',
3359
- environment: 'city',
3360
- preset: 'rembrandt',
3361
- radius: 0,
3362
- width: 0,
3363
- height: 0,
3364
- depth: 0,
3365
- });
3366
- this.connect('config', this.select('preset').pipe(map((preset) => (typeof preset === 'string' ? presets[preset] : preset))));
3367
- this.connect('shadowsInfo', this.select('shadows').pipe(map((shadows) => {
3368
- var _a, _b, _c, _d;
3369
- return Object.assign({ contactShadow: shadows === 'contact' || (shadows === null || shadows === void 0 ? void 0 : shadows.type) === 'contact', accumulativeShadow: shadows === 'accumulative' || (shadows === null || shadows === void 0 ? void 0 : shadows.type) === 'accumulative', shadowBias: (_a = shadows === null || shadows === void 0 ? void 0 : shadows.bias) !== null && _a !== void 0 ? _a : -0.0001, normalBias: (_b = shadows === null || shadows === void 0 ? void 0 : shadows.normalBias) !== null && _b !== void 0 ? _b : 0, shadowSize: (_c = shadows === null || shadows === void 0 ? void 0 : shadows.size) !== null && _c !== void 0 ? _c : 1024, shadowOffset: (_d = shadows === null || shadows === void 0 ? void 0 : shadows.offset) !== null && _d !== void 0 ? _d : 0 }, (typeof shadows === 'string' ? {} : shadows || {}));
3370
- })));
3371
- this.connect('spotLightPosition', this.select(['config', 'radius'], ({ config, radius }) => [
3372
- config.main[0] * radius,
3373
- config.main[1] * radius,
3374
- config.main[2] * radius,
3375
- ]));
3376
- this.connect('pointLightPosition', this.select(['config', 'radius'], ({ config, radius }) => [
3377
- config.fill[0] * radius,
3378
- config.fill[1] * radius,
3379
- config.fill[2] * radius,
3380
- ]));
3381
- this.connect('environmentInfo', this.select('environment').pipe(map((environment) => {
3382
- if (!environment)
3383
- return null;
3384
- if (typeof environment === 'string')
3385
- return { preset: environment };
3386
- return environment;
3387
- })));
3388
- }
3389
- onCentered(props) {
3390
- const { boundingSphere, width, height, depth } = props;
3391
- this.set({ radius: boundingSphere.radius, width, height, depth });
3392
- this.cdr.detectChanges();
3393
- if (this.centered.observed)
3394
- this.centered.emit(props);
3395
- }
3396
- }
3397
- NgtsStage.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsStage, deps: null, target: i0.ɵɵFactoryTarget.Component });
3398
- NgtsStage.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsStage, isStandalone: true, selector: "ngts-stage", inputs: { preset: "preset", shadows: "shadows", adjustCamera: "adjustCamera", environment: "environment", intensity: "intensity", center: "center" }, outputs: { centered: "centered" }, usesInheritance: true, ngImport: i0, template: `
3399
- <ngt-ambient-light [intensity]="get('intensity')! / 3" />
3400
- <ngt-spot-light
3401
- [penumbra]="1"
3402
- [position]="get('spotLightPosition')"
3403
- [intensity]="get('intensity')! * 2"
3404
- [castShadow]="!!get('shadows')"
3405
- >
3406
- <ngt-value [rawValue]="get('shadowsInfo').shadowBias" attach="shadow.bias" />
3407
- <ngt-value [rawValue]="get('shadowsInfo').normalBias" attach="shadow.normalBias" />
3408
- <ngt-vector2
3409
- *args="[get('shadowsInfo').shadowSize, get('shadowsInfo').shadowSize]"
3410
- attach="shadow.mapSize"
3411
- />
3412
- </ngt-spot-light>
3413
- <ngt-point-light [position]="get('pointLightPosition')" [intensity]="get('intensity')" />
3414
-
3415
- <ngts-bounds
3416
- [fit]="!!get('adjustCamera')"
3417
- [clip]="!!get('adjustCamera')"
3418
- [margin]="Number(get('adjustCamera'))"
3419
- [observe]="true"
3420
- >
3421
- <ngts-stage-refit [radius]="get('radius')" [adjustCamera]="!!get('adjustCamera')" />
3422
- <ngts-center
3423
- [position]="[0, get('shadowsInfo').shadowOffset / 2, 0]"
3424
- [top]="!!get('center')?.top"
3425
- [right]="!!get('center')?.right"
3426
- [bottom]="!!get('center')?.bottom"
3427
- [left]="!!get('center')?.left"
3428
- [front]="!!get('center')?.front"
3429
- [back]="!!get('center')?.back"
3430
- [disableX]="!!get('center')?.disableX"
3431
- [disableY]="!!get('center')?.disableY"
3432
- [disableZ]="!!get('center')?.disableZ"
3433
- [precise]="!!get('center')?.precise"
3434
- (centered)="onCentered($event)"
3435
- >
3436
- <ng-content />
3437
- </ngts-center>
3438
- </ngts-bounds>
3439
- <ngt-group [position]="[0, -get('height') / 2 - get('shadowsInfo').shadowOffset / 2, 0]">
3440
- <ngts-contact-shadows
3441
- *ngIf="get('shadowsInfo').contactShadow"
3442
- [scale]="get('radius') * 4"
3443
- [far]="get('radius')"
3444
- [blur]="2"
3445
- [opacity]="get('shadowsInfo').opacity"
3446
- [width]="get('shadowsInfo').width"
3447
- [height]="get('shadowsInfo').height"
3448
- [smooth]="get('shadowsInfo').smooth"
3449
- [resolution]="get('shadowsInfo').resolution"
3450
- [frames]="get('shadowsInfo').frames"
3451
- [scale]="get('shadowsInfo').scale"
3452
- [color]="get('shadowsInfo').color"
3453
- [depthWrite]="get('shadowsInfo').depthWrite"
3454
- [renderOrder]="get('shadowsInfo').renderOrder"
3455
- />
3456
- <ngts-accumulative-shadows
3457
- *ngIf="get('shadowsInfo').accumulativeShadow"
3458
- [temporal]="true"
3459
- [frames]="100"
3460
- [alphaTest]="0.9"
3461
- [toneMapped]="true"
3462
- [scale]="get('radius') * 4"
3463
- [opacity]="get('shadowsInfo').opacity"
3464
- [alphaTest]="get('shadowsInfo').alphaTest"
3465
- [color]="get('shadowsInfo').color"
3466
- [colorBlend]="get('shadowsInfo').colorBlend"
3467
- [resolution]="get('shadowsInfo').resolution"
3468
- >
3469
- <ngts-randomized-lights
3470
- [amount]="get('shadowsInfo').amount ?? 8"
3471
- [radius]="get('shadowsInfo').radius ?? get('radius')"
3472
- [ambient]="get('shadowsInfo').ambient ?? 0.5"
3473
- [intensity]="get('shadowsInfo').intensity ?? 1"
3474
- [position]="get('spotLightPosition')"
3475
- [size]="get('radius') * 4"
3476
- [bias]="-get('shadowsInfo').shadowBias"
3477
- [mapSize]="get('shadowsInfo').shadowSize"
3478
- />
3479
- </ngts-accumulative-shadows>
3480
- </ngt-group>
3481
- <ngts-environment
3482
- *ngIf="get('environmentInfo')"
3483
- [frames]="get('environmentInfo').frames"
3484
- [near]="get('environmentInfo').near"
3485
- [far]="get('environmentInfo').far"
3486
- [resolution]="get('environmentInfo').resolution"
3487
- [background]="get('environmentInfo').background"
3488
- [blur]="get('environmentInfo').blur"
3489
- [map]="get('environmentInfo').map"
3490
- [files]="get('environmentInfo').files"
3491
- [path]="get('environmentInfo').path"
3492
- [preset]="get('environmentInfo').preset"
3493
- [scene]="get('environmentInfo').scene"
3494
- [extensions]="get('environmentInfo').extensions"
3495
- [ground]="get('environmentInfo').ground"
3496
- [encoding]="get('environmentInfo').encoding"
3497
- />
3498
- `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }, { kind: "component", type: NgtsBounds, selector: "ngts-bounds", inputs: ["boundsRef", "damping", "fit", "clip", "observe", "margin", "eps"], outputs: ["fitted"] }, { kind: "directive", type: NgtsStageRefit, selector: "ngts-stage-refit", inputs: ["radius", "adjustCamera"] }, { kind: "component", type: NgtsCenter, selector: "ngts-center", inputs: ["centerRef", "top", "right", "bottom", "left", "front", "back", "disableX", "disableY", "disableZ", "disabled", "precise"], outputs: ["centered"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: NgtsContactShadows, selector: "ngts-contact-shadows", inputs: ["contactShadowsRef", "opacity", "width", "height", "blur", "far", "smooth", "resolution", "frames", "scale", "color", "depthWrite", "renderOrder"] }, { kind: "component", type: NgtsAccumulativeShadows, selector: "ngts-accumulative-shadows", inputs: ["frames", "blend", "limit", "scale", "temporal", "opacity", "alphaTest", "color", "colorBlend", "resolution", "toneMapped"] }, { kind: "component", type: NgtsRandomizedLights, selector: "ngts-randomized-lights", inputs: ["lightsRef", "frames", "position", "radius", "amount", "intensity", "ambient", "castShadow", "bias", "mapSize", "size", "near", "far"] }, { kind: "component", type: NgtsEnvironment, selector: "ngts-environment" }] });
3499
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsStage, decorators: [{
3500
- type: Component,
3501
- args: [{
3502
- selector: 'ngts-stage',
3503
- standalone: true,
3504
- template: `
3505
- <ngt-ambient-light [intensity]="get('intensity')! / 3" />
3506
- <ngt-spot-light
3507
- [penumbra]="1"
3508
- [position]="get('spotLightPosition')"
3509
- [intensity]="get('intensity')! * 2"
3510
- [castShadow]="!!get('shadows')"
3511
- >
3512
- <ngt-value [rawValue]="get('shadowsInfo').shadowBias" attach="shadow.bias" />
3513
- <ngt-value [rawValue]="get('shadowsInfo').normalBias" attach="shadow.normalBias" />
3514
- <ngt-vector2
3515
- *args="[get('shadowsInfo').shadowSize, get('shadowsInfo').shadowSize]"
3516
- attach="shadow.mapSize"
3517
- />
3518
- </ngt-spot-light>
3519
- <ngt-point-light [position]="get('pointLightPosition')" [intensity]="get('intensity')" />
3520
-
3521
- <ngts-bounds
3522
- [fit]="!!get('adjustCamera')"
3523
- [clip]="!!get('adjustCamera')"
3524
- [margin]="Number(get('adjustCamera'))"
3525
- [observe]="true"
3526
- >
3527
- <ngts-stage-refit [radius]="get('radius')" [adjustCamera]="!!get('adjustCamera')" />
3528
- <ngts-center
3529
- [position]="[0, get('shadowsInfo').shadowOffset / 2, 0]"
3530
- [top]="!!get('center')?.top"
3531
- [right]="!!get('center')?.right"
3532
- [bottom]="!!get('center')?.bottom"
3533
- [left]="!!get('center')?.left"
3534
- [front]="!!get('center')?.front"
3535
- [back]="!!get('center')?.back"
3536
- [disableX]="!!get('center')?.disableX"
3537
- [disableY]="!!get('center')?.disableY"
3538
- [disableZ]="!!get('center')?.disableZ"
3539
- [precise]="!!get('center')?.precise"
3540
- (centered)="onCentered($event)"
3541
- >
3542
- <ng-content />
3543
- </ngts-center>
3544
- </ngts-bounds>
3545
- <ngt-group [position]="[0, -get('height') / 2 - get('shadowsInfo').shadowOffset / 2, 0]">
3546
- <ngts-contact-shadows
3547
- *ngIf="get('shadowsInfo').contactShadow"
3548
- [scale]="get('radius') * 4"
3549
- [far]="get('radius')"
3550
- [blur]="2"
3551
- [opacity]="get('shadowsInfo').opacity"
3552
- [width]="get('shadowsInfo').width"
3553
- [height]="get('shadowsInfo').height"
3554
- [smooth]="get('shadowsInfo').smooth"
3555
- [resolution]="get('shadowsInfo').resolution"
3556
- [frames]="get('shadowsInfo').frames"
3557
- [scale]="get('shadowsInfo').scale"
3558
- [color]="get('shadowsInfo').color"
3559
- [depthWrite]="get('shadowsInfo').depthWrite"
3560
- [renderOrder]="get('shadowsInfo').renderOrder"
3561
- />
3562
- <ngts-accumulative-shadows
3563
- *ngIf="get('shadowsInfo').accumulativeShadow"
3564
- [temporal]="true"
3565
- [frames]="100"
3566
- [alphaTest]="0.9"
3567
- [toneMapped]="true"
3568
- [scale]="get('radius') * 4"
3569
- [opacity]="get('shadowsInfo').opacity"
3570
- [alphaTest]="get('shadowsInfo').alphaTest"
3571
- [color]="get('shadowsInfo').color"
3572
- [colorBlend]="get('shadowsInfo').colorBlend"
3573
- [resolution]="get('shadowsInfo').resolution"
3574
- >
3575
- <ngts-randomized-lights
3576
- [amount]="get('shadowsInfo').amount ?? 8"
3577
- [radius]="get('shadowsInfo').radius ?? get('radius')"
3578
- [ambient]="get('shadowsInfo').ambient ?? 0.5"
3579
- [intensity]="get('shadowsInfo').intensity ?? 1"
3580
- [position]="get('spotLightPosition')"
3581
- [size]="get('radius') * 4"
3582
- [bias]="-get('shadowsInfo').shadowBias"
3583
- [mapSize]="get('shadowsInfo').shadowSize"
3584
- />
3585
- </ngts-accumulative-shadows>
3586
- </ngt-group>
3587
- <ngts-environment
3588
- *ngIf="get('environmentInfo')"
3589
- [frames]="get('environmentInfo').frames"
3590
- [near]="get('environmentInfo').near"
3591
- [far]="get('environmentInfo').far"
3592
- [resolution]="get('environmentInfo').resolution"
3593
- [background]="get('environmentInfo').background"
3594
- [blur]="get('environmentInfo').blur"
3595
- [map]="get('environmentInfo').map"
3596
- [files]="get('environmentInfo').files"
3597
- [path]="get('environmentInfo').path"
3598
- [preset]="get('environmentInfo').preset"
3599
- [scene]="get('environmentInfo').scene"
3600
- [extensions]="get('environmentInfo').extensions"
3601
- [ground]="get('environmentInfo').ground"
3602
- [encoding]="get('environmentInfo').encoding"
3603
- />
3604
- `,
3605
- imports: [
3606
- NgtArgs,
3607
- NgtsBounds,
3608
- NgtsStageRefit,
3609
- NgtsCenter,
3610
- NgIf,
3611
- NgtsContactShadows,
3612
- NgtsAccumulativeShadows,
3613
- NgtsRandomizedLights,
3614
- NgtsEnvironment,
3615
- ],
3616
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
3617
- }]
3618
- }], propDecorators: { preset: [{
3619
- type: Input
3620
- }], shadows: [{
3621
- type: Input
3622
- }], adjustCamera: [{
3623
- type: Input
3624
- }], environment: [{
3625
- type: Input
3626
- }], intensity: [{
3627
- type: Input
3628
- }], center: [{
3629
- type: Input
3630
- }], centered: [{
3631
- type: Output
3632
- }] } });
3633
-
3634
- extend({ Points, BufferGeometry, BufferAttribute });
3635
- const genStar = (r) => {
3636
- return new Vector3().setFromSpherical(new Spherical(r, Math.acos(1 - Math.random() * 2), Math.random() * 2 * Math.PI));
3637
- };
3638
- class NgtsStars extends NgtRxStore {
3639
- set radius(radius) {
3640
- this.set({ radius });
3641
- }
3642
- set depth(depth) {
3643
- this.set({ depth });
3644
- }
3645
- set count(count) {
3646
- this.set({ count });
3647
- }
3648
- set factor(factor) {
3649
- this.set({ factor });
3650
- }
3651
- set saturation(saturation) {
3652
- this.set({ saturation });
3653
- }
3654
- set fade(fade) {
3655
- this.set({ fade });
3656
- }
3657
- set speed(speed) {
3658
- this.set({ speed });
3659
- }
3660
- initialize() {
3661
- super.initialize();
3662
- this.set({
3663
- radius: 100,
3664
- depth: 50,
3665
- count: 5000,
3666
- saturation: 0,
3667
- factor: 4,
3668
- fade: false,
3669
- speed: 1,
3670
- });
3671
- this.connect('bufferAttributes', this.select(['count', 'depth', 'factor', 'radius', 'saturation'], ({ count, depth, factor, radius, saturation }) => {
3672
- const positions = [];
3673
- const colors = [];
3674
- const sizes = Array.from({ length: count }, () => (0.5 + 0.5 * Math.random()) * factor);
3675
- const color = new Color();
3676
- let r = radius + depth;
3677
- const increment = depth / count;
3678
- for (let i = 0; i < count; i++) {
3679
- r -= increment * Math.random();
3680
- positions.push(...genStar(r).toArray());
3681
- color.setHSL(i / count, saturation, 0.9);
3682
- colors.push(color.r, color.g, color.b);
3683
- }
3684
- return {
3685
- positions: new Float32Array(positions),
3686
- colors: new Float32Array(colors),
3687
- sizes: new Float32Array(sizes),
3688
- };
3689
- }));
3690
- }
3691
- constructor() {
3692
- super();
3693
- this.AdditiveBlending = THREE.AdditiveBlending;
3694
- this.material = new StarFieldMaterial();
3695
- this.starsRef = injectNgtRef();
3696
- injectBeforeRender(this.onBeforeRender.bind(this));
3697
- }
3698
- onBeforeRender({ clock }) {
3699
- this.material.uniforms['time'].value = clock.getElapsedTime() * this.get('speed');
3700
- }
3701
- }
3702
- NgtsStars.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsStars, deps: [], target: i0.ɵɵFactoryTarget.Component });
3703
- NgtsStars.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: NgtsStars, isStandalone: true, selector: "ngts-stars", inputs: { starsRef: "starsRef", radius: "radius", depth: "depth", count: "count", factor: "factor", saturation: "saturation", fade: "fade", speed: "speed" }, usesInheritance: true, ngImport: i0, template: `
3704
- <ngt-points [ref]="starsRef">
3705
- <ngt-buffer-geometry>
3706
- <ngt-buffer-attribute attach="attributes.position" *args="[get('bufferAttributes').positions, 3]" />
3707
- <ngt-buffer-attribute attach="attributes.color" *args="[get('bufferAttributes').colors, 3]" />
3708
- <ngt-buffer-attribute attach="attributes.size" *args="[get('bufferAttributes').sizes, 1]" />
3709
- </ngt-buffer-geometry>
3710
- <ngt-primitive
3711
- *args="[material]"
3712
- attach="material"
3713
- [blending]="AdditiveBlending"
3714
- [depthWrite]="false"
3715
- [transparent]="true"
3716
- [vertexColors]="true"
3717
- >
3718
- <ngt-value attach="uniforms.fade.value" [rawValue]="get('fade')" />
3719
- </ngt-primitive>
3720
- </ngt-points>
3721
- `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
3722
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtsStars, decorators: [{
3723
- type: Component,
3724
- args: [{
3725
- selector: 'ngts-stars',
3726
- standalone: true,
3727
- template: `
3728
- <ngt-points [ref]="starsRef">
3729
- <ngt-buffer-geometry>
3730
- <ngt-buffer-attribute attach="attributes.position" *args="[get('bufferAttributes').positions, 3]" />
3731
- <ngt-buffer-attribute attach="attributes.color" *args="[get('bufferAttributes').colors, 3]" />
3732
- <ngt-buffer-attribute attach="attributes.size" *args="[get('bufferAttributes').sizes, 1]" />
3733
- </ngt-buffer-geometry>
3734
- <ngt-primitive
3735
- *args="[material]"
3736
- attach="material"
3737
- [blending]="AdditiveBlending"
3738
- [depthWrite]="false"
3739
- [transparent]="true"
3740
- [vertexColors]="true"
3741
- >
3742
- <ngt-value attach="uniforms.fade.value" [rawValue]="get('fade')" />
3743
- </ngt-primitive>
3744
- </ngt-points>
3745
- `,
3746
- imports: [NgtArgs],
3747
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
3748
- }]
3749
- }], ctorParameters: function () { return []; }, propDecorators: { starsRef: [{
3750
- type: Input
3751
- }], radius: [{
3752
- type: Input
3753
- }], depth: [{
3754
- type: Input
3755
- }], count: [{
3756
- type: Input
3757
- }], factor: [{
3758
- type: Input
3759
- }], saturation: [{
3760
- type: Input
3761
- }], fade: [{
3762
- type: Input
3763
- }], speed: [{
3764
- type: Input
3765
- }] } });
3766
-
3767
- /**
3768
- * Generated bundle index. Do not edit.
3769
- */
3770
-
3771
- export { NGTS_BOUNDS_API, NGTS_SPOT_LIGHT_API, NgtsAccumulativeShadows, NgtsBounds, NgtsCameraShake, NgtsCaustics, NgtsCenter, NgtsCloud, NgtsContactShadows, NgtsEnvironment, NgtsEnvironmentContent, NgtsFloat, NgtsRandomizedLights, NgtsSky, NgtsSparkles, NgtsSpotLight, NgtsSpotLightShadow, NgtsStage, NgtsStageRefit, NgtsStars, calcPosFromAngles, ngtsEnvironmentPresetsObj };
3772
- //# sourceMappingURL=angular-three-soba-staging.mjs.map