angular-three-soba 1.14.1 → 2.0.0-beta.11

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 (426) hide show
  1. package/README.md +2 -2
  2. package/abstractions/billboard/billboard.d.ts +28 -0
  3. package/abstractions/detailed/detailed.d.ts +26 -0
  4. package/abstractions/edges/edges.d.ts +34 -0
  5. package/abstractions/grid/grid.d.ts +50 -0
  6. package/abstractions/index.d.ts +6 -11
  7. package/abstractions/text/text.d.ts +82 -0
  8. package/abstractions/text-3d/text-3d.d.ts +81 -0
  9. package/cameras/{lib/camera → camera}/camera-content.d.ts +2 -2
  10. package/cameras/camera/camera.d.ts +26 -0
  11. package/cameras/cube-camera/cube-camera.d.ts +69 -0
  12. package/cameras/index.d.ts +4 -4
  13. package/cameras/orthographic-camera/orthographic-camera.d.ts +37 -0
  14. package/cameras/{lib/perspective-camera → perspective-camera}/perspective-camera.d.ts +10 -1
  15. package/controls/index.d.ts +1 -1
  16. package/controls/orbit-controls/orbit-controls.d.ts +54 -0
  17. package/esm2022/abstractions/angular-three-soba-abstractions.mjs +1 -1
  18. package/esm2022/abstractions/billboard/billboard.mjs +74 -0
  19. package/esm2022/abstractions/detailed/detailed.mjs +64 -0
  20. package/esm2022/abstractions/edges/edges.mjs +88 -0
  21. package/esm2022/abstractions/grid/grid.mjs +180 -0
  22. package/esm2022/abstractions/index.mjs +7 -12
  23. package/esm2022/abstractions/text/text.mjs +274 -0
  24. package/esm2022/abstractions/text-3d/text-3d.mjs +165 -0
  25. package/esm2022/angular-three-soba.mjs +1 -1
  26. package/esm2022/cameras/angular-three-soba-cameras.mjs +1 -1
  27. package/esm2022/cameras/camera/camera-content.mjs +20 -0
  28. package/esm2022/cameras/camera/camera.mjs +77 -0
  29. package/esm2022/cameras/cube-camera/cube-camera.mjs +161 -0
  30. package/esm2022/cameras/index.mjs +5 -5
  31. package/esm2022/cameras/orthographic-camera/orthographic-camera.mjs +102 -0
  32. package/esm2022/cameras/perspective-camera/perspective-camera.mjs +46 -0
  33. package/esm2022/controls/angular-three-soba-controls.mjs +1 -1
  34. package/esm2022/controls/index.mjs +2 -2
  35. package/esm2022/controls/orbit-controls/orbit-controls.mjs +181 -0
  36. package/esm2022/index.mjs +1 -1
  37. package/esm2022/loaders/angular-three-soba-loaders.mjs +1 -1
  38. package/esm2022/loaders/gltf-loader/gltf-loader.mjs +30 -0
  39. package/esm2022/loaders/index.mjs +5 -6
  40. package/esm2022/loaders/loader/loader.mjs +138 -0
  41. package/esm2022/loaders/progress/progress.mjs +45 -0
  42. package/esm2022/loaders/texture-loader/texture-loader.mjs +28 -0
  43. package/esm2022/materials/angular-three-soba-materials.mjs +1 -1
  44. package/esm2022/materials/index.mjs +7 -6
  45. package/esm2022/materials/mesh-distort-material/mesh-distort-material.mjs +82 -0
  46. package/esm2022/materials/mesh-reflector-material/mesh-reflector-material.mjs +367 -0
  47. package/esm2022/materials/mesh-refraction-material/mesh-refraction-material.mjs +171 -0
  48. package/esm2022/materials/mesh-transmission-material/mesh-transmission-material.mjs +278 -0
  49. package/esm2022/materials/mesh-wobble-material/mesh-wobble-material.mjs +68 -0
  50. package/esm2022/materials/point-material/point-material.mjs +46 -0
  51. package/esm2022/misc/angular-three-soba-misc.mjs +1 -1
  52. package/esm2022/misc/animations/animations.mjs +59 -0
  53. package/esm2022/misc/bake-shadows/bake-shadows.mjs +24 -0
  54. package/esm2022/misc/caustics/caustics.mjs +387 -0
  55. package/esm2022/misc/decal/decal.mjs +187 -0
  56. package/esm2022/misc/depth-buffer/depth-buffer.mjs +44 -0
  57. package/esm2022/misc/example/example.mjs +160 -0
  58. package/esm2022/misc/fbo/fbo.mjs +47 -0
  59. package/esm2022/misc/html/html-wrapper.mjs +478 -0
  60. package/esm2022/misc/html/html.mjs +304 -0
  61. package/esm2022/misc/index.mjs +14 -5
  62. package/esm2022/misc/sampler/sampler.mjs +142 -0
  63. package/esm2022/misc/shadow/shadow.mjs +111 -0
  64. package/esm2022/misc/stats-gl/stats-gl.mjs +61 -0
  65. package/esm2022/misc/trail/trail.mjs +209 -0
  66. package/esm2022/misc/trail-texture/inject-trail-texture.mjs +17 -0
  67. package/esm2022/misc/trail-texture/trail-texture.mjs +106 -0
  68. package/esm2022/modifiers/angular-three-soba-modifiers.mjs +5 -0
  69. package/esm2022/modifiers/curve-modifier/curve-modifier.mjs +64 -0
  70. package/esm2022/modifiers/index.mjs +2 -0
  71. package/esm2022/performances/adaptive-dpr/adaptive-dpr.mjs +44 -0
  72. package/esm2022/performances/adaptive-events/adaptive-events.mjs +27 -0
  73. package/esm2022/performances/angular-three-soba-performances.mjs +5 -0
  74. package/esm2022/performances/index.mjs +6 -0
  75. package/esm2022/performances/points/points-input.mjs +64 -0
  76. package/esm2022/performances/points/points.mjs +329 -0
  77. package/esm2022/performances/points/position-point.mjs +54 -0
  78. package/esm2022/performances/segments/segment-object.mjs +9 -0
  79. package/esm2022/performances/segments/segments.mjs +182 -0
  80. package/esm2022/shaders/angular-three-soba-shaders.mjs +1 -1
  81. package/esm2022/shaders/blur-pass/blur-pass.mjs +61 -0
  82. package/esm2022/shaders/caustics/caustics-material.mjs +130 -0
  83. package/esm2022/shaders/caustics/caustics-projection-material.mjs +31 -0
  84. package/esm2022/shaders/convolution-material/convolution-material.mjs +94 -0
  85. package/esm2022/shaders/discard-material/discard-material.mjs +3 -0
  86. package/esm2022/shaders/grid-material/grid-material.mjs +77 -0
  87. package/esm2022/shaders/index.mjs +18 -15
  88. package/esm2022/shaders/mesh-distort-material/mesh-distort-material.mjs +56 -0
  89. package/esm2022/shaders/mesh-reflector-material/mesh-reflector-material.mjs +223 -0
  90. package/esm2022/shaders/mesh-refraction-material/mesh-refraction-material.mjs +170 -0
  91. package/esm2022/shaders/mesh-transmission-material/mesh-transmission-material.mjs +268 -0
  92. package/esm2022/shaders/mesh-wobble-material/mesh-wobble-material.mjs +37 -0
  93. package/esm2022/shaders/shader-material/shader-material.mjs +34 -0
  94. package/esm2022/shaders/soft-shadow-material/soft-shadow-material.mjs +25 -0
  95. package/esm2022/shaders/sparkles-material/sparkles-material.mjs +33 -0
  96. package/esm2022/shaders/spot-light-material/spot-light-material.mjs +86 -0
  97. package/esm2022/shaders/star-field-material/star-field-material.mjs +33 -0
  98. package/esm2022/shaders/wireframe-material/wireframe-material.mjs +247 -0
  99. package/esm2022/staging/accumulative-shadows/accumulative-shadows.mjs +267 -0
  100. package/esm2022/staging/accumulative-shadows/progressive-light-map.mjs +108 -0
  101. package/esm2022/staging/accumulative-shadows/randomized-lights.mjs +206 -0
  102. package/esm2022/staging/angular-three-soba-staging.mjs +1 -1
  103. package/esm2022/staging/backdrop/backdrop.mjs +77 -0
  104. package/esm2022/staging/bb-anchor/bb-anchor.mjs +69 -0
  105. package/esm2022/staging/bounds/bounds.mjs +308 -0
  106. package/esm2022/staging/camera-shake/camera-shake.mjs +123 -0
  107. package/esm2022/staging/center/center.mjs +163 -0
  108. package/esm2022/staging/cloud/cloud.mjs +158 -0
  109. package/esm2022/staging/contact-shadows/contact-shadows.mjs +246 -0
  110. package/esm2022/staging/environment/assets.mjs +13 -0
  111. package/esm2022/staging/environment/environment-cube.mjs +47 -0
  112. package/esm2022/staging/environment/environment-ground.mjs +41 -0
  113. package/esm2022/staging/environment/environment-input.mjs +119 -0
  114. package/esm2022/staging/environment/environment-map.mjs +53 -0
  115. package/esm2022/staging/environment/environment-portal.mjs +113 -0
  116. package/esm2022/staging/environment/environment.mjs +61 -0
  117. package/esm2022/staging/environment/utils.mjs +105 -0
  118. package/esm2022/staging/float/float.mjs +94 -0
  119. package/esm2022/staging/index.mjs +22 -18
  120. package/esm2022/staging/matcap-texture/matcap-texture.mjs +64 -0
  121. package/esm2022/staging/normal-texture/normal-texture.mjs +53 -0
  122. package/esm2022/staging/sky/sky.mjs +119 -0
  123. package/esm2022/staging/sparkles/sparkles.mjs +164 -0
  124. package/esm2022/staging/spot-light/shadow-mesh-input.mjs +63 -0
  125. package/esm2022/staging/spot-light/shadow-mesh.mjs +266 -0
  126. package/esm2022/staging/spot-light/spot-light-input.mjs +84 -0
  127. package/esm2022/staging/spot-light/spot-light.mjs +81 -0
  128. package/esm2022/staging/spot-light/volumetric-mesh.mjs +98 -0
  129. package/esm2022/staging/stage/stage.mjs +388 -0
  130. package/esm2022/staging/stars/stars.mjs +147 -0
  131. package/esm2022/staging/wireframe/wireframe-input.mjs +191 -0
  132. package/esm2022/staging/wireframe/wireframe.mjs +224 -0
  133. package/esm2022/utils/angular-three-soba-utils.mjs +5 -0
  134. package/esm2022/utils/content/content.mjs +15 -0
  135. package/esm2022/utils/index.mjs +2 -0
  136. package/fesm2022/angular-three-soba-abstractions.mjs +668 -1882
  137. package/fesm2022/angular-three-soba-abstractions.mjs.map +1 -1
  138. package/fesm2022/angular-three-soba-cameras.mjs +279 -232
  139. package/fesm2022/angular-three-soba-cameras.mjs.map +1 -1
  140. package/fesm2022/angular-three-soba-controls.mjs +104 -69
  141. package/fesm2022/angular-three-soba-controls.mjs.map +1 -1
  142. package/fesm2022/angular-three-soba-loaders.mjs +177 -164
  143. package/fesm2022/angular-three-soba-loaders.mjs.map +1 -1
  144. package/fesm2022/angular-three-soba-materials.mjs +630 -482
  145. package/fesm2022/angular-three-soba-materials.mjs.map +1 -1
  146. package/fesm2022/angular-three-soba-misc.mjs +2248 -122
  147. package/fesm2022/angular-three-soba-misc.mjs.map +1 -1
  148. package/fesm2022/angular-three-soba-modifiers.mjs +71 -0
  149. package/fesm2022/angular-three-soba-modifiers.mjs.map +1 -0
  150. package/fesm2022/angular-three-soba-performances.mjs +697 -0
  151. package/fesm2022/angular-three-soba-performances.mjs.map +1 -0
  152. package/fesm2022/angular-three-soba-shaders.mjs +554 -209
  153. package/fesm2022/angular-three-soba-shaders.mjs.map +1 -1
  154. package/fesm2022/angular-three-soba-staging.mjs +3230 -2852
  155. package/fesm2022/angular-three-soba-staging.mjs.map +1 -1
  156. package/fesm2022/angular-three-soba-utils.mjs +22 -0
  157. package/fesm2022/angular-three-soba-utils.mjs.map +1 -0
  158. package/fesm2022/angular-three-soba.mjs.map +1 -1
  159. package/loaders/gltf-loader/gltf-loader.d.ts +10 -0
  160. package/loaders/index.d.ts +4 -5
  161. package/loaders/loader/loader.d.ts +33 -0
  162. package/loaders/progress/progress.d.ts +9 -0
  163. package/loaders/texture-loader/texture-loader.d.ts +7 -0
  164. package/materials/index.d.ts +6 -5
  165. package/materials/mesh-distort-material/mesh-distort-material.d.ts +40 -0
  166. package/materials/mesh-reflector-material/mesh-reflector-material.d.ts +99 -0
  167. package/materials/mesh-refraction-material/mesh-refraction-material.d.ts +62 -0
  168. package/materials/mesh-transmission-material/mesh-transmission-material.d.ts +107 -0
  169. package/materials/mesh-wobble-material/mesh-wobble-material.d.ts +29 -0
  170. package/materials/point-material/point-material.d.ts +24 -0
  171. package/metadata.json +1 -0
  172. package/misc/animations/animations.d.ts +15 -0
  173. package/misc/{lib/bake-shadows → bake-shadows}/bake-shadows.d.ts +2 -5
  174. package/misc/caustics/caustics.d.ts +87 -0
  175. package/misc/decal/decal.d.ts +49 -0
  176. package/misc/depth-buffer/depth-buffer.d.ts +9 -0
  177. package/misc/example/example.d.ts +81 -0
  178. package/misc/{lib/fbo → fbo}/fbo.d.ts +4 -2
  179. package/misc/html/html-wrapper.d.ts +559 -0
  180. package/misc/html/html.d.ts +214 -0
  181. package/misc/index.d.ts +13 -4
  182. package/misc/sampler/sampler.d.ts +67 -0
  183. package/misc/shadow/shadow.d.ts +37 -0
  184. package/misc/stats-gl/stats-gl.d.ts +24 -0
  185. package/misc/trail/trail.d.ts +57 -0
  186. package/misc/trail-texture/inject-trail-texture.d.ts +9 -0
  187. package/misc/trail-texture/trail-texture.d.ts +50 -0
  188. package/modifiers/README.md +3 -0
  189. package/modifiers/curve-modifier/curve-modifier.d.ts +23 -0
  190. package/modifiers/index.d.ts +1 -0
  191. package/package.json +43 -32
  192. package/performances/README.md +3 -0
  193. package/performances/adaptive-dpr/adaptive-dpr.d.ts +14 -0
  194. package/{performance/lib/adaptive → performances/adaptive-events}/adaptive-events.d.ts +5 -6
  195. package/performances/index.d.ts +5 -0
  196. package/performances/points/points-input.d.ts +32 -0
  197. package/performances/points/points.d.ts +92 -0
  198. package/performances/points/position-point.d.ts +11 -0
  199. package/performances/segments/segment-object.d.ts +7 -0
  200. package/performances/segments/segments.d.ts +124 -0
  201. package/shaders/{lib/blur-pass → blur-pass}/blur-pass.d.ts +2 -2
  202. package/shaders/grid-material/grid-material.d.ts +37 -0
  203. package/shaders/index.d.ts +17 -14
  204. package/shaders/{lib/mesh-distort-material → mesh-distort-material}/mesh-distort-material.d.ts +147 -2
  205. package/shaders/{lib/mesh-transmission-material → mesh-transmission-material}/mesh-transmission-material.d.ts +1 -1
  206. package/shaders/{lib/mesh-wobble-material → mesh-wobble-material}/mesh-wobble-material.d.ts +1 -0
  207. package/shaders/{lib/shader-material → shader-material}/shader-material.d.ts +2 -2
  208. package/shaders/soft-shadow-material/soft-shadow-material.d.ts +19 -0
  209. package/shaders/sparkles-material/sparkles-material.d.ts +17 -0
  210. package/shaders/spot-light-material/spot-light-material.d.ts +13 -0
  211. package/shaders/star-field-material/star-field-material.d.ts +13 -0
  212. package/shaders/wireframe-material/wireframe-material.d.ts +58 -0
  213. package/staging/accumulative-shadows/accumulative-shadows.d.ts +146 -0
  214. package/staging/{lib/accumulative-shadows → accumulative-shadows}/progressive-light-map.d.ts +2 -2
  215. package/staging/accumulative-shadows/randomized-lights.d.ts +90 -0
  216. package/staging/backdrop/backdrop.d.ts +30 -0
  217. package/staging/bb-anchor/bb-anchor.d.ts +27 -0
  218. package/staging/bounds/bounds.d.ts +134 -0
  219. package/staging/camera-shake/camera-shake.d.ts +43 -0
  220. package/staging/center/center.d.ts +70 -0
  221. package/staging/cloud/cloud.d.ts +51 -0
  222. package/staging/contact-shadows/contact-shadows.d.ts +70 -0
  223. package/staging/{lib/environment → environment}/assets.d.ts +9 -9
  224. package/staging/environment/environment-cube.d.ts +15 -0
  225. package/staging/environment/environment-ground.d.ts +13 -0
  226. package/staging/environment/environment-input.d.ts +68 -0
  227. package/staging/environment/environment-map.d.ts +16 -0
  228. package/staging/environment/environment-portal.d.ts +18 -0
  229. package/staging/{lib/environment → environment}/environment.d.ts +2 -6
  230. package/staging/environment/utils.d.ts +7 -0
  231. package/staging/float/float.d.ts +31 -0
  232. package/staging/index.d.ts +21 -17
  233. package/staging/matcap-texture/matcap-texture.d.ts +13 -0
  234. package/staging/normal-texture/normal-texture.d.ts +16 -0
  235. package/staging/sky/sky.d.ts +48 -0
  236. package/staging/sparkles/sparkles.d.ts +63 -0
  237. package/staging/spot-light/shadow-mesh-input.d.ts +29 -0
  238. package/staging/spot-light/shadow-mesh.d.ts +37 -0
  239. package/staging/spot-light/spot-light-input.d.ts +38 -0
  240. package/staging/spot-light/spot-light.d.ts +39 -0
  241. package/staging/spot-light/volumetric-mesh.d.ts +24 -0
  242. package/staging/stage/stage.d.ts +130 -0
  243. package/staging/stars/stars.d.ts +45 -0
  244. package/staging/wireframe/wireframe-input.d.ts +65 -0
  245. package/staging/wireframe/wireframe.d.ts +28 -0
  246. package/utils/README.md +3 -0
  247. package/utils/content/content.d.ts +8 -0
  248. package/utils/index.d.ts +1 -0
  249. package/web-types.json +1 -0
  250. package/abstractions/lib/billboard/billboard.d.ts +0 -14
  251. package/abstractions/lib/catmull-rom-line/catmull-rom-line.d.ts +0 -15
  252. package/abstractions/lib/cubic-bezier-line/cubic-bezier-line.d.ts +0 -15
  253. package/abstractions/lib/edges/edges.d.ts +0 -18
  254. package/abstractions/lib/gizmo-helper/gizmo-helper.d.ts +0 -41
  255. package/abstractions/lib/gizmo-helper/gizmo-viewcube/constants.d.ts +0 -12
  256. package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-edge.d.ts +0 -16
  257. package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-face.d.ts +0 -24
  258. package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-inputs.d.ts +0 -14
  259. package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube.d.ts +0 -15
  260. package/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport-axis.d.ts +0 -28
  261. package/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport.d.ts +0 -21
  262. package/abstractions/lib/line/line-input.d.ts +0 -19
  263. package/abstractions/lib/line/line.d.ts +0 -21
  264. package/abstractions/lib/quadratic-bezier-line/quadratic-bezier-line.d.ts +0 -19
  265. package/abstractions/lib/text/text.d.ts +0 -21
  266. package/abstractions/lib/text-3d/text-3d.d.ts +0 -39
  267. package/assets/default-spot-light-shadow.glsl +0 -10
  268. package/cameras/lib/camera/camera.d.ts +0 -19
  269. package/cameras/lib/cube-camera/cube-camera.d.ts +0 -27
  270. package/cameras/lib/orthographic-camera/orthographic-camera.d.ts +0 -17
  271. package/controls/lib/orbit-controls/orbit-controls.d.ts +0 -27
  272. package/esm2022/abstractions/lib/billboard/billboard.mjs +0 -74
  273. package/esm2022/abstractions/lib/catmull-rom-line/catmull-rom-line.mjs +0 -120
  274. package/esm2022/abstractions/lib/cubic-bezier-line/cubic-bezier-line.mjs +0 -99
  275. package/esm2022/abstractions/lib/edges/edges.mjs +0 -96
  276. package/esm2022/abstractions/lib/gizmo-helper/gizmo-helper.mjs +0 -213
  277. package/esm2022/abstractions/lib/gizmo-helper/gizmo-viewcube/constants.mjs +0 -31
  278. package/esm2022/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-edge.mjs +0 -92
  279. package/esm2022/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-face.mjs +0 -184
  280. package/esm2022/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-inputs.mjs +0 -46
  281. package/esm2022/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube.mjs +0 -134
  282. package/esm2022/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport-axis.mjs +0 -195
  283. package/esm2022/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport.mjs +0 -267
  284. package/esm2022/abstractions/lib/line/line-input.mjs +0 -76
  285. package/esm2022/abstractions/lib/line/line.mjs +0 -133
  286. package/esm2022/abstractions/lib/quadratic-bezier-line/quadratic-bezier-line.mjs +0 -128
  287. package/esm2022/abstractions/lib/text/text.mjs +0 -115
  288. package/esm2022/abstractions/lib/text-3d/text-3d.mjs +0 -145
  289. package/esm2022/cameras/lib/camera/camera-content.mjs +0 -21
  290. package/esm2022/cameras/lib/camera/camera.mjs +0 -75
  291. package/esm2022/cameras/lib/cube-camera/cube-camera.mjs +0 -131
  292. package/esm2022/cameras/lib/orthographic-camera/orthographic-camera.mjs +0 -93
  293. package/esm2022/cameras/lib/perspective-camera/perspective-camera.mjs +0 -47
  294. package/esm2022/controls/lib/orbit-controls/orbit-controls.mjs +0 -147
  295. package/esm2022/loaders/lib/cube-texture-loader/cube-texture-loader.mjs +0 -10
  296. package/esm2022/loaders/lib/gltf-loader/gltf-loader.mjs +0 -32
  297. package/esm2022/loaders/lib/loader/loader.mjs +0 -134
  298. package/esm2022/loaders/lib/progress/progress.mjs +0 -39
  299. package/esm2022/loaders/lib/texture-loader/texture-loader.mjs +0 -19
  300. package/esm2022/materials/lib/mesh-distort-material/mesh-distort-material.mjs +0 -75
  301. package/esm2022/materials/lib/mesh-reflector-material/mesh-reflector-material.mjs +0 -328
  302. package/esm2022/materials/lib/mesh-refraction-material/mesh-refraction-material.mjs +0 -158
  303. package/esm2022/materials/lib/mesh-transmission-material/mesh-transmission-material.mjs +0 -238
  304. package/esm2022/materials/lib/mesh-wobble-material/mesh-wobble-material.mjs +0 -68
  305. package/esm2022/misc/lib/animations/animations.mjs +0 -52
  306. package/esm2022/misc/lib/bake-shadows/bake-shadows.mjs +0 -26
  307. package/esm2022/misc/lib/depth-buffer/depth-buffer.mjs +0 -39
  308. package/esm2022/misc/lib/fbo/fbo.mjs +0 -39
  309. package/esm2022/performance/angular-three-soba-performance.mjs +0 -5
  310. package/esm2022/performance/index.mjs +0 -5
  311. package/esm2022/performance/lib/adaptive/adaptive-dpr.mjs +0 -47
  312. package/esm2022/performance/lib/adaptive/adaptive-events.mjs +0 -37
  313. package/esm2022/performance/lib/detailed/detailed.mjs +0 -54
  314. package/esm2022/performance/lib/stats/stats.mjs +0 -80
  315. package/esm2022/shaders/lib/blur-pass/blur-pass.mjs +0 -61
  316. package/esm2022/shaders/lib/caustics-material/caustics-material.mjs +0 -128
  317. package/esm2022/shaders/lib/caustics-projection-material/caustics-projection-material.mjs +0 -33
  318. package/esm2022/shaders/lib/convolution-material/convolution-material.mjs +0 -94
  319. package/esm2022/shaders/lib/discard-material/discard-material.mjs +0 -3
  320. package/esm2022/shaders/lib/mesh-distort-material/mesh-distort-material.mjs +0 -55
  321. package/esm2022/shaders/lib/mesh-reflector-material/mesh-reflector-material.mjs +0 -223
  322. package/esm2022/shaders/lib/mesh-refraction-material/mesh-refraction-material.mjs +0 -169
  323. package/esm2022/shaders/lib/mesh-transmission-material/mesh-transmission-material.mjs +0 -268
  324. package/esm2022/shaders/lib/mesh-wobble-material/mesh-wobble-material.mjs +0 -37
  325. package/esm2022/shaders/lib/shader-material/shader-material.mjs +0 -34
  326. package/esm2022/shaders/lib/soft-shadow-material/soft-shadow-material.mjs +0 -33
  327. package/esm2022/shaders/lib/spot-light-material/spot-light-material.mjs +0 -86
  328. package/esm2022/shaders/lib/star-field-material/star-field-material.mjs +0 -32
  329. package/esm2022/staging/lib/accumulative-shadows/accumulative-shadows.mjs +0 -249
  330. package/esm2022/staging/lib/accumulative-shadows/progressive-light-map.mjs +0 -108
  331. package/esm2022/staging/lib/accumulative-shadows/randomized-lights.mjs +0 -201
  332. package/esm2022/staging/lib/bounds/bounds.mjs +0 -284
  333. package/esm2022/staging/lib/camera-shake/camera-shake.mjs +0 -122
  334. package/esm2022/staging/lib/caustics/caustics.mjs +0 -364
  335. package/esm2022/staging/lib/center/center.mjs +0 -143
  336. package/esm2022/staging/lib/cloud/cloud.mjs +0 -160
  337. package/esm2022/staging/lib/contact-shadows/contact-shadows.mjs +0 -228
  338. package/esm2022/staging/lib/environment/assets.mjs +0 -13
  339. package/esm2022/staging/lib/environment/environment-cube.mjs +0 -41
  340. package/esm2022/staging/lib/environment/environment-ground.mjs +0 -67
  341. package/esm2022/staging/lib/environment/environment-inputs.mjs +0 -87
  342. package/esm2022/staging/lib/environment/environment-map.mjs +0 -39
  343. package/esm2022/staging/lib/environment/environment-portal.mjs +0 -111
  344. package/esm2022/staging/lib/environment/environment.mjs +0 -165
  345. package/esm2022/staging/lib/environment/utils.mjs +0 -70
  346. package/esm2022/staging/lib/float/float.mjs +0 -77
  347. package/esm2022/staging/lib/sky/sky.mjs +0 -109
  348. package/esm2022/staging/lib/sparkles/sparkles.mjs +0 -210
  349. package/esm2022/staging/lib/spot-light/common.mjs +0 -42
  350. package/esm2022/staging/lib/spot-light/shadow-mesh-input.mjs +0 -51
  351. package/esm2022/staging/lib/spot-light/spot-light-input.mjs +0 -62
  352. package/esm2022/staging/lib/spot-light/spot-light-shadow-no-shader.mjs +0 -74
  353. package/esm2022/staging/lib/spot-light/spot-light-shadow-shader.mjs +0 -126
  354. package/esm2022/staging/lib/spot-light/spot-light-shadow.mjs +0 -63
  355. package/esm2022/staging/lib/spot-light/spot-light.mjs +0 -117
  356. package/esm2022/staging/lib/spot-light/volumetric-mesh.mjs +0 -86
  357. package/esm2022/staging/lib/stage/stage.mjs +0 -368
  358. package/esm2022/staging/lib/stars/stars.mjs +0 -140
  359. package/fesm2022/angular-three-soba-performance.mjs +0 -210
  360. package/fesm2022/angular-three-soba-performance.mjs.map +0 -1
  361. package/loaders/lib/cube-texture-loader/cube-texture-loader.d.ts +0 -3
  362. package/loaders/lib/gltf-loader/gltf-loader.d.ts +0 -8
  363. package/loaders/lib/loader/loader.d.ts +0 -26
  364. package/loaders/lib/progress/progress.d.ts +0 -16
  365. package/loaders/lib/texture-loader/texture-loader.d.ts +0 -5
  366. package/materials/lib/mesh-distort-material/mesh-distort-material.d.ts +0 -24
  367. package/materials/lib/mesh-reflector-material/mesh-reflector-material.d.ts +0 -41
  368. package/materials/lib/mesh-refraction-material/mesh-refraction-material.d.ts +0 -28
  369. package/materials/lib/mesh-transmission-material/mesh-transmission-material.d.ts +0 -46
  370. package/materials/lib/mesh-wobble-material/mesh-wobble-material.d.ts +0 -14
  371. package/misc/lib/animations/animations.d.ts +0 -13
  372. package/misc/lib/depth-buffer/depth-buffer.d.ts +0 -7
  373. package/performance/README.md +0 -3
  374. package/performance/index.d.ts +0 -4
  375. package/performance/lib/adaptive/adaptive-dpr.d.ts +0 -11
  376. package/performance/lib/detailed/detailed.d.ts +0 -13
  377. package/performance/lib/stats/stats.d.ts +0 -15
  378. package/plugin/README.md +0 -11
  379. package/plugin/generators.json +0 -19
  380. package/plugin/package.json +0 -9
  381. package/plugin/src/generators/init/compat.d.ts +0 -2
  382. package/plugin/src/generators/init/compat.js +0 -6
  383. package/plugin/src/generators/init/compat.js.map +0 -1
  384. package/plugin/src/generators/init/init.d.ts +0 -4
  385. package/plugin/src/generators/init/init.js +0 -22
  386. package/plugin/src/generators/init/init.js.map +0 -1
  387. package/plugin/src/generators/init/schema.json +0 -6
  388. package/plugin/src/index.d.ts +0 -1
  389. package/plugin/src/index.js +0 -6
  390. package/plugin/src/index.js.map +0 -1
  391. package/shaders/lib/soft-shadow-material/soft-shadow-material.d.ts +0 -10
  392. package/shaders/lib/spot-light-material/spot-light-material.d.ts +0 -4
  393. package/shaders/lib/star-field-material/star-field-material.d.ts +0 -3
  394. package/staging/lib/accumulative-shadows/accumulative-shadows.d.ts +0 -58
  395. package/staging/lib/accumulative-shadows/randomized-lights.d.ts +0 -42
  396. package/staging/lib/bounds/bounds.d.ts +0 -48
  397. package/staging/lib/camera-shake/camera-shake.d.ts +0 -28
  398. package/staging/lib/caustics/caustics.d.ts +0 -47
  399. package/staging/lib/center/center.d.ts +0 -40
  400. package/staging/lib/cloud/cloud.d.ts +0 -23
  401. package/staging/lib/contact-shadows/contact-shadows.d.ts +0 -29
  402. package/staging/lib/environment/environment-cube.d.ts +0 -11
  403. package/staging/lib/environment/environment-ground.d.ts +0 -9
  404. package/staging/lib/environment/environment-inputs.d.ts +0 -28
  405. package/staging/lib/environment/environment-map.d.ts +0 -10
  406. package/staging/lib/environment/environment-portal.d.ts +0 -15
  407. package/staging/lib/environment/utils.d.ts +0 -8
  408. package/staging/lib/float/float.d.ts +0 -16
  409. package/staging/lib/sky/sky.d.ts +0 -20
  410. package/staging/lib/sparkles/sparkles.d.ts +0 -29
  411. package/staging/lib/spot-light/common.d.ts +0 -3
  412. package/staging/lib/spot-light/shadow-mesh-input.d.ts +0 -14
  413. package/staging/lib/spot-light/spot-light-input.d.ts +0 -16
  414. package/staging/lib/spot-light/spot-light-shadow-no-shader.d.ts +0 -14
  415. package/staging/lib/spot-light/spot-light-shadow-shader.d.ts +0 -25
  416. package/staging/lib/spot-light/spot-light-shadow.d.ts +0 -6
  417. package/staging/lib/spot-light/spot-light.d.ts +0 -17
  418. package/staging/lib/spot-light/volumetric-mesh.d.ts +0 -15
  419. package/staging/lib/stage/stage.d.ts +0 -87
  420. package/staging/lib/stars/stars.d.ts +0 -20
  421. /package/shaders/{lib/caustics-material → caustics}/caustics-material.d.ts +0 -0
  422. /package/shaders/{lib/caustics-projection-material → caustics}/caustics-projection-material.d.ts +0 -0
  423. /package/shaders/{lib/convolution-material → convolution-material}/convolution-material.d.ts +0 -0
  424. /package/shaders/{lib/discard-material → discard-material}/discard-material.d.ts +0 -0
  425. /package/shaders/{lib/mesh-reflector-material → mesh-reflector-material}/mesh-reflector-material.d.ts +0 -0
  426. /package/shaders/{lib/mesh-refraction-material → mesh-refraction-material}/mesh-refraction-material.d.ts +0 -0
@@ -1,152 +1,2278 @@
1
- import { injectNgtRef, injectNgtDestroy, injectBeforeRender, NgtRxStore, NgtStore, safeDetectChanges } from 'angular-three';
2
- import { takeUntil, switchMap, map, isObservable, of, combineLatest } from 'rxjs';
3
- import * as THREE from 'three';
4
1
  import * as i0 from '@angular/core';
5
- import { inject, Directive } from '@angular/core';
2
+ import { runInInjectionContext, computed, effect, Directive, inject, ChangeDetectorRef, DestroyRef, Component, CUSTOM_ELEMENTS_SCHEMA, Input, forwardRef, signal, ViewContainerRef, untracked, ViewChild, EventEmitter, TemplateRef, ContentChild, Output, Injector } from '@angular/core';
3
+ import { assertInjectionContext, injectNgtRef, injectBeforeRender, injectNgtStore, safeDetectChanges, extend, signalStore, is, applyProps, createInjectionToken, HTML, checkUpdate, NgtArgs, addEffect, addAfterEffect, NgtPortal, NgtPortalContent } from 'angular-three';
4
+ import * as THREE from 'three';
5
+ import { Group, Scene, Mesh, PlaneGeometry, OrthographicCamera, LineBasicMaterial, BoxGeometry, MeshNormalMaterial, AxesHelper, MeshStandardMaterial, ShaderMaterial, CanvasTexture, MeshBasicMaterial, Texture } from 'three';
6
+ import { NgIf, DOCUMENT, NgTemplateOutlet } from '@angular/common';
7
+ import { NgtsEdges, NgtsText3D } from 'angular-three-soba/abstractions';
8
+ import { CausticsProjectionMaterial, CausticsMaterial } from 'angular-three-soba/shaders';
9
+ import { NgtsSobaContent } from 'angular-three-soba/utils';
10
+ import { FullScreenQuad, DecalGeometry, MeshSurfaceSampler } from 'three-stdlib';
11
+ import { NgtsCenter } from 'angular-three-soba/staging';
12
+ import Stats from 'stats-gl';
13
+ import { MeshLineGeometry, MeshLineMaterial } from 'meshline';
6
14
 
7
- function injectNgtsAnimations(animations$, ref) {
8
- let actualRef = injectNgtRef();
9
- if (ref) {
10
- if (ref instanceof THREE.Object3D) {
11
- actualRef.nativeElement = ref;
12
- }
13
- else {
14
- actualRef = ref;
15
- }
16
- }
17
- const mixer = new THREE.AnimationMixer(null);
18
- const actions = {};
19
- let cached = {};
20
- const clips = [];
21
- const names = [];
22
- const { destroy$ } = injectNgtDestroy(() => {
23
- // clear cached
24
- cached = {};
25
- // uncache actions
26
- Object.values(actions).forEach((action) => {
27
- if (actualRef.nativeElement) {
28
- mixer.uncacheAction(action, actualRef.nativeElement);
29
- }
30
- });
31
- // stop all actions
32
- mixer.stopAllAction();
33
- });
34
- injectBeforeRender(({ delta }) => mixer.update(delta));
35
- actualRef.$.pipe(takeUntil(destroy$))
36
- .pipe(switchMap((object) => animations$.pipe(map((animations) => [object, animations]))))
37
- .subscribe(([object, animations]) => {
38
- for (let i = 0; i < animations.length; i++) {
39
- const clip = animations[i];
40
- names.push(clip.name);
41
- clips.push(clip);
42
- Object.defineProperty(actions, clip.name, {
43
- enumerable: true,
44
- get: () => {
45
- return cached[clip.name] || (cached[clip.name] = mixer.clipAction(clip, object));
46
- },
47
- });
48
- if (i === 0) {
49
- actions[clip.name].play();
15
+ function injectNgtsAnimations(animationsFactory, { ref, injector, playFirstClip = true, } = {}) {
16
+ injector = assertInjectionContext(injectNgtsAnimations, injector);
17
+ return runInInjectionContext(injector, () => {
18
+ let actualRef = injectNgtRef();
19
+ if (ref) {
20
+ if (ref instanceof THREE.Object3D) {
21
+ actualRef.nativeElement = ref;
22
+ }
23
+ else {
24
+ actualRef = ref;
50
25
  }
51
26
  }
27
+ const mixer = new THREE.AnimationMixer(null);
28
+ const actions = {};
29
+ let cached = {};
30
+ let object = null;
31
+ const clips = [];
32
+ const names = [];
33
+ injectBeforeRender(({ delta }) => mixer.update(delta));
34
+ const ready = computed(() => !!actualRef.nativeElement && !!animationsFactory().length);
35
+ effect((onCleanup) => {
36
+ const actual = actualRef.nativeElement;
37
+ if (!actual)
38
+ return;
39
+ object = actual;
40
+ const animations = animationsFactory();
41
+ for (let i = 0; i < animations.length; i++) {
42
+ const clip = animations[i];
43
+ names.push(clip.name);
44
+ clips.push(clip);
45
+ Object.defineProperty(actions, clip.name, {
46
+ enumerable: true,
47
+ get: () => {
48
+ return cached[clip.name] || (cached[clip.name] = mixer.clipAction(clip, actual));
49
+ },
50
+ });
51
+ if (i === 0 && playFirstClip) {
52
+ actions[clip.name].play();
53
+ }
54
+ }
55
+ onCleanup(() => {
56
+ // clear cached
57
+ cached = {};
58
+ // stop all actions
59
+ mixer.stopAllAction();
60
+ // uncache actions
61
+ Object.values(actions).forEach((action) => {
62
+ mixer.uncacheAction(action, object);
63
+ });
64
+ object = null;
65
+ });
66
+ });
67
+ return { ref: actualRef, actions, mixer, names, clips, ready };
52
68
  });
53
- return { ref: actualRef, actions, mixer, names, clips };
54
69
  }
55
70
 
56
- class NgtsBakeShadows extends NgtRxStore {
71
+ class NgtsBakeShadows {
57
72
  constructor() {
58
- super(...arguments);
59
- this.store = inject(NgtStore);
60
- }
61
- ngOnInit() {
62
- this.effect(this.store.select('gl'), (gl) => {
63
- gl.shadowMap.autoUpdate = false;
64
- gl.shadowMap.needsUpdate = true;
65
- return () => {
66
- gl.shadowMap.autoUpdate = gl.shadowMap.needsUpdate = true;
67
- };
73
+ const store = injectNgtStore();
74
+ const glShadowMap = store.select('gl', 'shadowMap');
75
+ effect((onCleanup) => {
76
+ const shadowMap = glShadowMap();
77
+ shadowMap.autoUpdate = false;
78
+ shadowMap.needsUpdate = true;
79
+ onCleanup(() => {
80
+ shadowMap.autoUpdate = shadowMap.needsUpdate = true;
81
+ });
68
82
  });
69
83
  }
70
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: NgtsBakeShadows, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
71
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: NgtsBakeShadows, isStandalone: true, selector: "ngts-bake-shadows", usesInheritance: true, ngImport: i0 }); }
84
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsBakeShadows, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
85
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.0", type: NgtsBakeShadows, isStandalone: true, selector: "ngts-bake-shadows", ngImport: i0 }); }
72
86
  }
73
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: NgtsBakeShadows, decorators: [{
87
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsBakeShadows, decorators: [{
74
88
  type: Directive,
75
89
  args: [{ selector: 'ngts-bake-shadows', standalone: true }]
76
- }] });
90
+ }], ctorParameters: function () { return []; } });
77
91
 
78
- function injectNgtsFBO(paramsFactory) {
79
- const store = inject(NgtStore);
80
- const targetRef = injectNgtRef();
81
- const { destroy$, cdr } = injectNgtDestroy(() => {
82
- targetRef.nativeElement?.dispose();
92
+ function injectNgtsFBO(fboParams, { injector } = {}) {
93
+ injector = assertInjectionContext(injectNgtsFBO, injector);
94
+ return runInInjectionContext(injector, () => {
95
+ const store = injectNgtStore();
96
+ const cdr = inject(ChangeDetectorRef);
97
+ const targetRef = injectNgtRef(null);
98
+ inject(DestroyRef).onDestroy(() => targetRef.nativeElement?.dispose());
99
+ const size = store.select('size');
100
+ const dpr = store.select('viewport', 'dpr');
101
+ const fboSettings = computed(() => {
102
+ const { width, height, settings } = fboParams();
103
+ const _width = typeof width === 'number' ? width : size().width * dpr();
104
+ const _height = typeof height === 'number' ? height : size().height * dpr();
105
+ const _settings = (typeof width === 'number' ? settings : width) || {};
106
+ return { width: _width, height: _height, settings: _settings };
107
+ });
108
+ effect(() => {
109
+ const { width, height, settings } = fboSettings();
110
+ const { samples = 0, depth, ...targetSettings } = settings;
111
+ let untrackedTarget = targetRef.untracked;
112
+ if (!untrackedTarget) {
113
+ const target = new THREE.WebGLRenderTarget(width, height, {
114
+ minFilter: THREE.LinearFilter,
115
+ magFilter: THREE.LinearFilter,
116
+ type: THREE.HalfFloatType,
117
+ ...targetSettings,
118
+ });
119
+ if (depth)
120
+ target.depthTexture = new THREE.DepthTexture(width, height, THREE.FloatType);
121
+ target.samples = samples;
122
+ targetRef.nativeElement = target;
123
+ untrackedTarget = targetRef.untracked;
124
+ }
125
+ if (untrackedTarget) {
126
+ untrackedTarget.setSize(width, height);
127
+ if (samples)
128
+ untrackedTarget.samples = samples;
129
+ safeDetectChanges(cdr);
130
+ }
131
+ });
132
+ return targetRef;
83
133
  });
84
- const params = paramsFactory({});
85
- const params$ = isObservable(params) ? params : of(params);
86
- params$.pipe(takeUntil(destroy$)).subscribe(({ width, height, settings }) => {
87
- const { gl, size, viewport } = store.get();
88
- const _width = typeof width === 'number' ? width : size.width * viewport.dpr;
89
- const _height = typeof height === 'number' ? height : size.height * viewport.dpr;
90
- const _settings = (typeof width === 'number' ? settings : width) || {};
91
- const { samples = 0, depth, ...targetSettings } = _settings;
92
- if (!targetRef.nativeElement) {
93
- const target = new THREE.WebGLRenderTarget(_width, _height, {
94
- minFilter: THREE.LinearFilter,
95
- magFilter: THREE.LinearFilter,
96
- encoding: gl.outputEncoding,
97
- type: THREE.HalfFloatType,
98
- ...targetSettings,
99
- });
100
- if (depth)
101
- target.depthTexture = new THREE.DepthTexture(_width, _height, THREE.FloatType);
102
- target.samples = samples;
103
- targetRef.nativeElement = target;
104
- }
105
- targetRef.nativeElement.setSize(_width, _height);
106
- if (samples)
107
- targetRef.nativeElement.samples = samples;
108
- safeDetectChanges(cdr);
134
+ }
135
+
136
+ extend({ Group, Scene, Mesh, PlaneGeometry, OrthographicCamera, CausticsProjectionMaterial, LineBasicMaterial });
137
+ const NORMALPROPS = {
138
+ depth: true,
139
+ minFilter: THREE.LinearFilter,
140
+ magFilter: THREE.LinearFilter,
141
+ type: THREE.UnsignedByteType,
142
+ };
143
+ const CAUSTICPROPS = {
144
+ minFilter: THREE.LinearMipmapLinearFilter,
145
+ magFilter: THREE.LinearFilter,
146
+ type: THREE.FloatType,
147
+ generateMipmaps: true,
148
+ };
149
+ function createNormalMaterial(side = THREE.FrontSide) {
150
+ const viewMatrix = { value: new THREE.Matrix4() };
151
+ return Object.assign(new THREE.MeshNormalMaterial({ side }), {
152
+ viewMatrix,
153
+ onBeforeCompile: (shader) => {
154
+ shader.uniforms.viewMatrix = viewMatrix;
155
+ shader.fragmentShader =
156
+ `vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
157
+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
158
+ }\n` +
159
+ shader.fragmentShader.replace('#include <normal_fragment_maps>', `#include <normal_fragment_maps>
160
+ normal = inverseTransformDirection( normal, viewMatrix );\n`);
161
+ },
109
162
  });
110
- return targetRef;
111
- }
112
-
113
- function injectNgtsDepthBuffer(paramsFactory = (params) => params) {
114
- const depthBufferRef = injectNgtRef();
115
- const store = inject(NgtStore);
116
- const { destroy$ } = injectNgtDestroy();
117
- const params = paramsFactory({ size: 256, frames: Infinity });
118
- const params$ = isObservable(params) ? params : of(params);
119
- let rawParams = { size: 256, frames: Infinity };
120
- const fbo = injectNgtsFBO(() => {
121
- return combineLatest([params$, store.select('size'), store.select('viewport', 'dpr')]).pipe(map(([params, size, dpr]) => {
122
- rawParams = params;
123
- const w = params.size || size.width * dpr;
124
- const h = params.size || size.height * dpr;
125
- const depthTexture = new THREE.DepthTexture(w, h);
163
+ }
164
+ class NgtsCaustics {
165
+ /** How many frames it will render, set it to Infinity for runtime, default: 1 */
166
+ set _frames(frames) {
167
+ this.inputs.set({ frames });
168
+ }
169
+ /** Enables visual cues to help you stage your scene, default: false */
170
+ set _debug(debug) {
171
+ this.inputs.set({ debug });
172
+ }
173
+ /** Will display caustics only and skip the models, default: false */
174
+ set _causticsOnly(causticsOnly) {
175
+ this.inputs.set({ causticsOnly });
176
+ }
177
+ /** Will include back faces and enable the backsideIOR prop, default: false */
178
+ set _backside(backside) {
179
+ this.inputs.set({ backside });
180
+ }
181
+ /** The IOR refraction index, default: 1.1 */
182
+ set _ior(ior) {
183
+ this.inputs.set({ ior });
184
+ }
185
+ /** The IOR refraction index for back faces (only available when backside is enabled), default: 1.1 */
186
+ set _backsideIOR(backsideIOR) {
187
+ this.inputs.set({ backsideIOR });
188
+ }
189
+ /** The texel size, default: 0.3125 */
190
+ set _worldRadius(worldRadius) {
191
+ this.inputs.set({ worldRadius });
192
+ }
193
+ /** Intensity of the prjected caustics, default: 0.05 */
194
+ set _intensity(intensity) {
195
+ this.inputs.set({ intensity });
196
+ }
197
+ /** Caustics color, default: white */
198
+ set _color(color) {
199
+ this.inputs.set({ color });
200
+ }
201
+ /** Buffer resolution, default: 2048 */
202
+ set _resolution(resolution) {
203
+ this.inputs.set({ resolution });
204
+ }
205
+ /** Camera position, it will point towards the contents bounds center, default: [5, 5, 5] */
206
+ set _lightSource(lightSource) {
207
+ this.inputs.set({ lightSource });
208
+ }
209
+ constructor() {
210
+ this.CustomBlending = THREE.CustomBlending;
211
+ this.OneFactor = THREE.OneFactor;
212
+ this.SrcAlphaFactor = THREE.SrcAlphaFactor;
213
+ this.Math = Math;
214
+ this.inputs = signalStore({
215
+ frames: 1,
216
+ ior: 1.1,
217
+ color: 'white',
218
+ causticsOnly: false,
219
+ backside: false,
220
+ backsideIOR: 1.1,
221
+ worldRadius: 0.3125,
222
+ intensity: 0.05,
223
+ resolution: 2024,
224
+ lightSource: [5, 5, 5],
225
+ });
226
+ this.causticsRef = injectNgtRef();
227
+ this.resolution = this.inputs.select('resolution');
228
+ this.normalTargetSettings = computed(() => ({
229
+ width: this.resolution(),
230
+ height: this.resolution(),
231
+ settings: NORMALPROPS,
232
+ }));
233
+ this.causticsTargetSettings = computed(() => ({
234
+ width: this.resolution(),
235
+ height: this.resolution(),
236
+ settings: CAUSTICPROPS,
237
+ }));
238
+ this.normalTargetFbo = injectNgtsFBO(this.normalTargetSettings);
239
+ this.normalTargetBFbo = injectNgtsFBO(this.normalTargetSettings);
240
+ this.causticsTargetFbo = injectNgtsFBO(this.causticsTargetSettings);
241
+ this.causticsTargetBFbo = injectNgtsFBO(this.causticsTargetSettings);
242
+ this.store = injectNgtStore();
243
+ this.color = this.inputs.select('color');
244
+ this.debug = this.inputs.select('debug');
245
+ this.planeRef = injectNgtRef();
246
+ this.sceneRef = injectNgtRef();
247
+ this.cameraRef = injectNgtRef();
248
+ this.sceneChildren = this.sceneRef.children();
249
+ this.planeChildren = this.planeRef.children('both');
250
+ this.causticsChildren = this.causticsRef.children();
251
+ this.updateWorldMatrix();
252
+ this.setBeforeRender();
253
+ }
254
+ updateWorldMatrix() {
255
+ effect(() => {
256
+ const [caustics] = [
257
+ this.causticsRef.nativeElement,
258
+ this.inputs.state(),
259
+ this.causticsChildren(),
260
+ this.sceneChildren(),
261
+ ];
262
+ if (!caustics)
263
+ return;
264
+ caustics.updateWorldMatrix(false, true);
265
+ });
266
+ }
267
+ setBeforeRender() {
268
+ const causticsMaterial = new CausticsMaterial();
269
+ const causticsQuad = new FullScreenQuad(causticsMaterial);
270
+ const normalMaterial = createNormalMaterial();
271
+ const normalMaterialB = createNormalMaterial(THREE.BackSide);
272
+ effect((onCleanup) => {
273
+ const [caustics, scene, camera, normalTarget, normalTargetB, causticsTarget, causticsTargetB, plane, sceneChildren,] = [
274
+ this.causticsRef.nativeElement,
275
+ this.sceneRef.nativeElement,
276
+ this.cameraRef.nativeElement,
277
+ this.normalTargetFbo.nativeElement,
278
+ this.normalTargetBFbo.nativeElement,
279
+ this.causticsTargetFbo.nativeElement,
280
+ this.causticsTargetBFbo.nativeElement,
281
+ this.planeRef.nativeElement,
282
+ this.sceneChildren(),
283
+ this.planeChildren(),
284
+ ];
285
+ if (!caustics)
286
+ return;
287
+ caustics.updateWorldMatrix(false, true);
288
+ if (sceneChildren.length > 1) {
289
+ const v = new THREE.Vector3();
290
+ const lpF = new THREE.Frustum();
291
+ const lpM = new THREE.Matrix4();
292
+ const lpP = new THREE.Plane();
293
+ const lightDir = new THREE.Vector3();
294
+ const lightDirInv = new THREE.Vector3();
295
+ const bounds = new THREE.Box3();
296
+ const focusPos = new THREE.Vector3();
297
+ let count = 0;
298
+ const sub = this.store.get('internal').subscribe(({ gl }) => {
299
+ const { frames, lightSource, resolution, worldRadius, intensity, backside, backsideIOR, ior, causticsOnly, } = this.inputs.get();
300
+ if (frames === Infinity || count++ < frames) {
301
+ if (Array.isArray(lightSource))
302
+ lightDir.fromArray(lightSource).normalize();
303
+ else
304
+ lightDir.copy(caustics.worldToLocal(lightSource.nativeElement.getWorldPosition(v)).normalize());
305
+ lightDirInv.copy(lightDir).multiplyScalar(-1);
306
+ let boundsVertices = [];
307
+ scene.parent?.matrixWorld.identity();
308
+ bounds.setFromObject(scene, true);
309
+ boundsVertices.push(new THREE.Vector3(bounds.min.x, bounds.min.y, bounds.min.z));
310
+ boundsVertices.push(new THREE.Vector3(bounds.min.x, bounds.min.y, bounds.max.z));
311
+ boundsVertices.push(new THREE.Vector3(bounds.min.x, bounds.max.y, bounds.min.z));
312
+ boundsVertices.push(new THREE.Vector3(bounds.min.x, bounds.max.y, bounds.max.z));
313
+ boundsVertices.push(new THREE.Vector3(bounds.max.x, bounds.min.y, bounds.min.z));
314
+ boundsVertices.push(new THREE.Vector3(bounds.max.x, bounds.min.y, bounds.max.z));
315
+ boundsVertices.push(new THREE.Vector3(bounds.max.x, bounds.max.y, bounds.min.z));
316
+ boundsVertices.push(new THREE.Vector3(bounds.max.x, bounds.max.y, bounds.max.z));
317
+ const worldVerts = boundsVertices.map((v) => v.clone());
318
+ bounds.getCenter(focusPos);
319
+ boundsVertices = boundsVertices.map((v) => v.clone().sub(focusPos));
320
+ const lightPlane = lpP.set(lightDirInv, 0);
321
+ const projectedVerts = boundsVertices.map((v) => lightPlane.projectPoint(v, new THREE.Vector3()));
322
+ const centralVert = projectedVerts
323
+ .reduce((a, b) => a.add(b), v.set(0, 0, 0))
324
+ .divideScalar(projectedVerts.length);
325
+ const radius = projectedVerts
326
+ .map((v) => v.distanceTo(centralVert))
327
+ .reduce((a, b) => Math.max(a, b));
328
+ const dirLength = boundsVertices.map((x) => x.dot(lightDir)).reduce((a, b) => Math.max(a, b));
329
+ // Shadows
330
+ camera.position.copy(lightDir.clone().multiplyScalar(dirLength).add(focusPos));
331
+ camera.lookAt(scene.localToWorld(focusPos.clone()));
332
+ const dirMatrix = lpM.lookAt(camera.position, focusPos, v.set(0, 1, 0));
333
+ camera.left = -radius;
334
+ camera.right = radius;
335
+ camera.top = radius;
336
+ camera.bottom = -radius;
337
+ const yOffset = v.set(0, radius, 0).applyMatrix4(dirMatrix);
338
+ const yTime = (camera.position.y + yOffset.y) / lightDir.y;
339
+ camera.near = 0.1;
340
+ camera.far = yTime;
341
+ camera.updateProjectionMatrix();
342
+ camera.updateMatrixWorld();
343
+ // Now find size of ground plane
344
+ const groundProjectedCoords = worldVerts.map((v) => v.add(lightDir.clone().multiplyScalar(-v.y / lightDir.y)));
345
+ const centerPos = groundProjectedCoords
346
+ .reduce((a, b) => a.add(b), v.set(0, 0, 0))
347
+ .divideScalar(groundProjectedCoords.length);
348
+ const maxSize = 2 *
349
+ groundProjectedCoords
350
+ .map((v) => Math.hypot(v.x - centerPos.x, v.z - centerPos.z))
351
+ .reduce((a, b) => Math.max(a, b));
352
+ plane.scale.setScalar(maxSize);
353
+ plane.position.copy(centerPos);
354
+ // if (debug) helper.current?.update();
355
+ // Inject uniforms
356
+ normalMaterialB.viewMatrix.value = normalMaterial.viewMatrix.value = camera.matrixWorldInverse;
357
+ const dirLightNearPlane = lpF.setFromProjectionMatrix(lpM.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse)).planes[4];
358
+ causticsMaterial.cameraMatrixWorld = camera.matrixWorld;
359
+ causticsMaterial.cameraProjectionMatrixInv = camera.projectionMatrixInverse;
360
+ causticsMaterial.lightDir = lightDirInv;
361
+ causticsMaterial.lightPlaneNormal = dirLightNearPlane.normal;
362
+ causticsMaterial.lightPlaneConstant = dirLightNearPlane.constant;
363
+ causticsMaterial.near = camera.near;
364
+ causticsMaterial.far = camera.far;
365
+ causticsMaterial.resolution = resolution;
366
+ causticsMaterial.size = radius;
367
+ causticsMaterial.intensity = intensity;
368
+ causticsMaterial.worldRadius = worldRadius;
369
+ // Switch the scene on
370
+ scene.visible = true;
371
+ // Render front face normals
372
+ gl.setRenderTarget(normalTarget);
373
+ gl.clear();
374
+ scene.overrideMaterial = normalMaterial;
375
+ gl.render(scene, camera);
376
+ // Render back face normals, if enabled
377
+ gl.setRenderTarget(normalTargetB);
378
+ gl.clear();
379
+ if (backside) {
380
+ scene.overrideMaterial = normalMaterialB;
381
+ gl.render(scene, camera);
382
+ }
383
+ // Remove the override material
384
+ scene.overrideMaterial = null;
385
+ // Render front face caustics
386
+ causticsMaterial.ior = ior;
387
+ plane.material.lightProjMatrix = camera.projectionMatrix;
388
+ plane.material.lightViewMatrix = camera.matrixWorldInverse;
389
+ causticsMaterial.normalTexture = normalTarget?.texture;
390
+ causticsMaterial.depthTexture = normalTarget?.depthTexture;
391
+ gl.setRenderTarget(causticsTarget);
392
+ gl.clear();
393
+ causticsQuad.render(gl);
394
+ // Render back face caustics, if enabled
395
+ causticsMaterial.ior = backsideIOR;
396
+ causticsMaterial.normalTexture = normalTargetB?.texture;
397
+ causticsMaterial.depthTexture = normalTargetB?.depthTexture;
398
+ gl.setRenderTarget(causticsTargetB);
399
+ gl.clear();
400
+ if (backside)
401
+ causticsQuad.render(gl);
402
+ // Reset render target
403
+ gl.setRenderTarget(null);
404
+ // Switch the scene off if caustics is all that's wanted
405
+ if (causticsOnly)
406
+ scene.visible = false;
407
+ }
408
+ });
409
+ onCleanup(() => sub());
410
+ }
411
+ });
412
+ }
413
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsCaustics, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
414
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.0", type: NgtsCaustics, isStandalone: true, selector: "ngts-caustics", inputs: { causticsRef: "causticsRef", _frames: ["frames", "_frames"], _debug: ["debug", "_debug"], _causticsOnly: ["causticsOnly", "_causticsOnly"], _backside: ["backside", "_backside"], _ior: ["ior", "_ior"], _backsideIOR: ["backsideIOR", "_backsideIOR"], _worldRadius: ["worldRadius", "_worldRadius"], _intensity: ["intensity", "_intensity"], _color: ["color", "_color"], _resolution: ["resolution", "_resolution"], _lightSource: ["lightSource", "_lightSource"] }, ngImport: i0, template: `
415
+ <ngt-group [ref]="causticsRef" ngtCompound>
416
+ <ngt-scene [ref]="sceneRef">
417
+ <ngt-orthographic-camera [ref]="cameraRef" [up]="[0, 1, 0]" />
418
+ <ng-content />
419
+ </ngt-scene>
420
+ <ngt-mesh [renderOrder]="2" [ref]="planeRef" [rotation]="[-Math.PI / 2, 0, 0]">
421
+ <ngt-plane-geometry />
422
+ <ngt-caustics-projection-material
423
+ *ngIf="causticsTargetFbo.nativeElement && causticsTargetBFbo.nativeElement"
424
+ [transparent]="true"
425
+ [color]="color()"
426
+ [causticsTexture]="causticsTargetFbo.nativeElement.texture"
427
+ [causticsTextureB]="causticsTargetBFbo.nativeElement.texture"
428
+ [blending]="CustomBlending"
429
+ [blendSrc]="OneFactor"
430
+ [blendDst]="SrcAlphaFactor"
431
+ [depthWrite]="false"
432
+ />
433
+
434
+ <ngts-edges *ngIf="debug()">
435
+ <ngt-line-basic-material *ngtsSobaContent color="#ffff00" [toneMapped]="false" />
436
+ </ngts-edges>
437
+ </ngt-mesh>
438
+ </ngt-group>
439
+ `, 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"] }, { kind: "directive", type: NgtsSobaContent, selector: "ng-template[ngtsSobaContent]", exportAs: ["sobaContent"] }] }); }
440
+ }
441
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsCaustics, decorators: [{
442
+ type: Component,
443
+ args: [{
444
+ selector: 'ngts-caustics',
445
+ standalone: true,
446
+ template: `
447
+ <ngt-group [ref]="causticsRef" ngtCompound>
448
+ <ngt-scene [ref]="sceneRef">
449
+ <ngt-orthographic-camera [ref]="cameraRef" [up]="[0, 1, 0]" />
450
+ <ng-content />
451
+ </ngt-scene>
452
+ <ngt-mesh [renderOrder]="2" [ref]="planeRef" [rotation]="[-Math.PI / 2, 0, 0]">
453
+ <ngt-plane-geometry />
454
+ <ngt-caustics-projection-material
455
+ *ngIf="causticsTargetFbo.nativeElement && causticsTargetBFbo.nativeElement"
456
+ [transparent]="true"
457
+ [color]="color()"
458
+ [causticsTexture]="causticsTargetFbo.nativeElement.texture"
459
+ [causticsTextureB]="causticsTargetBFbo.nativeElement.texture"
460
+ [blending]="CustomBlending"
461
+ [blendSrc]="OneFactor"
462
+ [blendDst]="SrcAlphaFactor"
463
+ [depthWrite]="false"
464
+ />
465
+
466
+ <ngts-edges *ngIf="debug()">
467
+ <ngt-line-basic-material *ngtsSobaContent color="#ffff00" [toneMapped]="false" />
468
+ </ngts-edges>
469
+ </ngt-mesh>
470
+ </ngt-group>
471
+ `,
472
+ imports: [NgIf, NgtsEdges, NgtsSobaContent],
473
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
474
+ }]
475
+ }], ctorParameters: function () { return []; }, propDecorators: { causticsRef: [{
476
+ type: Input
477
+ }], _frames: [{
478
+ type: Input,
479
+ args: [{ alias: 'frames' }]
480
+ }], _debug: [{
481
+ type: Input,
482
+ args: [{ alias: 'debug' }]
483
+ }], _causticsOnly: [{
484
+ type: Input,
485
+ args: [{ alias: 'causticsOnly' }]
486
+ }], _backside: [{
487
+ type: Input,
488
+ args: [{ alias: 'backside' }]
489
+ }], _ior: [{
490
+ type: Input,
491
+ args: [{ alias: 'ior' }]
492
+ }], _backsideIOR: [{
493
+ type: Input,
494
+ args: [{ alias: 'backsideIOR' }]
495
+ }], _worldRadius: [{
496
+ type: Input,
497
+ args: [{ alias: 'worldRadius' }]
498
+ }], _intensity: [{
499
+ type: Input,
500
+ args: [{ alias: 'intensity' }]
501
+ }], _color: [{
502
+ type: Input,
503
+ args: [{ alias: 'color' }]
504
+ }], _resolution: [{
505
+ type: Input,
506
+ args: [{ alias: 'resolution' }]
507
+ }], _lightSource: [{
508
+ type: Input,
509
+ args: [{ alias: 'lightSource' }]
510
+ }] } });
511
+
512
+ extend({ Mesh, BoxGeometry, MeshNormalMaterial, AxesHelper });
513
+ function vecToArray(vec = [0, 0, 0]) {
514
+ if (Array.isArray(vec)) {
515
+ return vec;
516
+ }
517
+ if (vec instanceof THREE.Vector3 || vec instanceof THREE.Euler) {
518
+ return [vec.x, vec.y, vec.z];
519
+ }
520
+ return [vec, vec, vec];
521
+ }
522
+ class NgtsDecal {
523
+ set _debug(debug) {
524
+ this.inputs.set({ debug });
525
+ }
526
+ set _mesh(mesh) {
527
+ this.inputs.set({ mesh });
528
+ }
529
+ set _position(position) {
530
+ this.inputs.set({ position });
531
+ }
532
+ set _rotation(rotation) {
533
+ this.inputs.set({ rotation });
534
+ }
535
+ set _scale(scale) {
536
+ this.inputs.set({ scale });
537
+ }
538
+ set _map(map) {
539
+ this.inputs.set({ map });
540
+ }
541
+ set _polygonOffsetFactor(polygonOffsetFactor) {
542
+ this.inputs.set({ polygonOffsetFactor });
543
+ }
544
+ set _depthTest(depthTest) {
545
+ this.inputs.set({ depthTest });
546
+ }
547
+ constructor() {
548
+ this.inputs = signalStore({
549
+ debug: false,
550
+ depthTest: false,
551
+ polygonOffsetFactor: -10,
552
+ position: [0, 0, 0],
553
+ rotation: [0, 0, 0],
554
+ scale: 1,
555
+ });
556
+ this.decalRef = injectNgtRef();
557
+ this.mesh = this.inputs.select('mesh');
558
+ this.__position = this.inputs.select('position');
559
+ this.__rotation = this.inputs.select('rotation');
560
+ this.__scale = this.inputs.select('scale');
561
+ this.position = computed(() => vecToArray(this.__position()));
562
+ this.rotation = computed(() => vecToArray(this.__rotation()));
563
+ this.scale = computed(() => vecToArray(this.__scale()));
564
+ this.helperRef = injectNgtRef();
565
+ this.debug = this.inputs.select('debug');
566
+ this.depthTest = this.inputs.select('depthTest');
567
+ this.polygonOffsetFactor = this.inputs.select('polygonOffsetFactor');
568
+ this.map = this.inputs.select('map');
569
+ this.processDecal();
570
+ }
571
+ processDecal() {
572
+ effect((onCleanup) => {
573
+ const decal = this.decalRef.nativeElement;
574
+ if (!decal)
575
+ return;
576
+ const [mesh, position, rotation, scale, helper] = [
577
+ this.mesh(),
578
+ this.position(),
579
+ this.rotation(),
580
+ this.scale(),
581
+ this.helperRef.nativeElement,
582
+ ];
583
+ const parent = mesh ? (is.ref(mesh) ? mesh.nativeElement : mesh) : decal.parent;
584
+ if (!(parent instanceof Mesh)) {
585
+ throw new Error('[NGT] ngts-decal must have a ngt-mesh as parent or specify its "mesh" input');
586
+ }
587
+ const state = {
588
+ position: new THREE.Vector3(),
589
+ rotation: new THREE.Euler(),
590
+ scale: new THREE.Vector3(1, 1, 1),
591
+ };
592
+ if (parent) {
593
+ applyProps(state, { position, scale });
594
+ // Zero out the parents matrix world for this operation
595
+ const matrixWorld = parent.matrixWorld.clone();
596
+ parent.matrixWorld.identity();
597
+ if (!rotation || typeof rotation === 'number') {
598
+ const o = new THREE.Object3D();
599
+ o.position.copy(state.position);
600
+ o.lookAt(parent.position);
601
+ if (typeof rotation === 'number')
602
+ o.rotateZ(rotation);
603
+ applyProps(state, { rotation: o.rotation });
604
+ }
605
+ else {
606
+ applyProps(state, { rotation });
607
+ }
608
+ decal.geometry = new DecalGeometry(parent, state.position, state.rotation, state.scale);
609
+ if (helper) {
610
+ applyProps(helper, state);
611
+ // Prevent the helpers from blocking rays
612
+ helper.traverse((child) => (child.raycast = () => null));
613
+ }
614
+ // Reset parents matix-world
615
+ parent.matrixWorld = matrixWorld;
616
+ onCleanup(() => {
617
+ decal.geometry.dispose();
618
+ });
619
+ }
620
+ });
621
+ }
622
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsDecal, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
623
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.0", type: NgtsDecal, isStandalone: true, selector: "ngts-decal", inputs: { decalRef: "decalRef", _debug: ["debug", "_debug"], _mesh: ["mesh", "_mesh"], _position: ["position", "_position"], _rotation: ["rotation", "_rotation"], _scale: ["scale", "_scale"], _map: ["map", "_map"], _polygonOffsetFactor: ["polygonOffsetFactor", "_polygonOffsetFactor"], _depthTest: ["depthTest", "_depthTest"] }, ngImport: i0, template: `
624
+ <ngt-mesh [ref]="decalRef" ngtCompound>
625
+ <ngt-value [rawValue]="true" attach="material.transparent" />
626
+ <ngt-value [rawValue]="true" attach="material.polygonOffset" />
627
+ <ngt-value [rawValue]="polygonOffsetFactor()" attach="material.polygonOffsetFactor" />
628
+ <ngt-value [rawValue]="depthTest()" attach="material.depthTest" />
629
+ <ngt-value [rawValue]="map()" attach="material.map" />
630
+ <ng-content />
631
+
632
+ <ngt-mesh *ngIf="debug()" [ref]="helperRef">
633
+ <ngt-box-geometry />
634
+ <ngt-mesh-normal-material [wireframe]="true" />
635
+ <ngt-axes-helper />
636
+ </ngt-mesh>
637
+ </ngt-mesh>
638
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
639
+ }
640
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsDecal, decorators: [{
641
+ type: Component,
642
+ args: [{
643
+ selector: 'ngts-decal',
644
+ standalone: true,
645
+ template: `
646
+ <ngt-mesh [ref]="decalRef" ngtCompound>
647
+ <ngt-value [rawValue]="true" attach="material.transparent" />
648
+ <ngt-value [rawValue]="true" attach="material.polygonOffset" />
649
+ <ngt-value [rawValue]="polygonOffsetFactor()" attach="material.polygonOffsetFactor" />
650
+ <ngt-value [rawValue]="depthTest()" attach="material.depthTest" />
651
+ <ngt-value [rawValue]="map()" attach="material.map" />
652
+ <ng-content />
653
+
654
+ <ngt-mesh *ngIf="debug()" [ref]="helperRef">
655
+ <ngt-box-geometry />
656
+ <ngt-mesh-normal-material [wireframe]="true" />
657
+ <ngt-axes-helper />
658
+ </ngt-mesh>
659
+ </ngt-mesh>
660
+ `,
661
+ imports: [NgIf],
662
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
663
+ }]
664
+ }], ctorParameters: function () { return []; }, propDecorators: { decalRef: [{
665
+ type: Input
666
+ }], _debug: [{
667
+ type: Input,
668
+ args: [{ alias: 'debug' }]
669
+ }], _mesh: [{
670
+ type: Input,
671
+ args: [{ alias: 'mesh' }]
672
+ }], _position: [{
673
+ type: Input,
674
+ args: [{ alias: 'position' }]
675
+ }], _rotation: [{
676
+ type: Input,
677
+ args: [{ alias: 'rotation' }]
678
+ }], _scale: [{
679
+ type: Input,
680
+ args: [{ alias: 'scale' }]
681
+ }], _map: [{
682
+ type: Input,
683
+ args: [{ alias: 'map' }]
684
+ }], _polygonOffsetFactor: [{
685
+ type: Input,
686
+ args: [{ alias: 'polygonOffsetFactor' }]
687
+ }], _depthTest: [{
688
+ type: Input,
689
+ args: [{ alias: 'depthTest' }]
690
+ }] } });
691
+
692
+ function injectNgtsDepthBuffer(paramsFactory = () => ({}), { injector } = {}) {
693
+ injector = assertInjectionContext(injectNgtsDepthBuffer, injector);
694
+ return runInInjectionContext(injector, () => {
695
+ const depthBufferRef = injectNgtRef(null);
696
+ const store = injectNgtStore();
697
+ const cdr = inject(ChangeDetectorRef);
698
+ const size = store.select('size');
699
+ const dpr = store.select('viewport', 'dpr');
700
+ const fboParams = computed(() => {
701
+ const params = { size: 256, frames: Infinity, ...paramsFactory() };
702
+ const width = params.size || size().width * dpr();
703
+ const height = params.size || size().height * dpr();
704
+ const depthTexture = new THREE.DepthTexture(width, height);
126
705
  depthTexture.format = THREE.DepthFormat;
127
706
  depthTexture.type = THREE.UnsignedShortType;
128
- const depthConfig = { depthTexture };
129
- return { width: w, height: h, settings: depthConfig };
707
+ return { width, height, settings: { depthTexture } };
708
+ });
709
+ const fboRef = injectNgtsFBO(fboParams, { injector });
710
+ effect(() => {
711
+ const fbo = fboRef.nativeElement;
712
+ if (fbo) {
713
+ depthBufferRef.nativeElement = fbo.depthTexture;
714
+ safeDetectChanges(cdr);
715
+ }
716
+ });
717
+ let count = 0;
718
+ injectBeforeRender(({ gl, scene, camera }) => {
719
+ const params = { size: 256, frames: Infinity, ...paramsFactory() };
720
+ const fbo = fboRef.untracked;
721
+ if ((params.frames === Infinity || count < params.frames) && fbo) {
722
+ gl.setRenderTarget(fbo);
723
+ gl.render(scene, camera);
724
+ gl.setRenderTarget(null);
725
+ count++;
726
+ }
727
+ }, { injector });
728
+ return depthBufferRef;
729
+ });
730
+ }
731
+
732
+ /**
733
+ * augment HTMLElementTagNameMap with the selector of the component.
734
+ * the type is usually the Inputs' state and the root THREE element
735
+
736
+ declare global {
737
+ interface HTMLElementTagNameMap {
738
+ \/**
739
+ * @extends ngt-group
740
+ *\/
741
+ 'ngts-example': NgtsExampleState & NgtGroup;
742
+ }
743
+ }
744
+
745
+ */
746
+ /**
747
+ * make sure soba's component extends all regular THREE entities that it needs
748
+ */
749
+ extend({ Group, MeshNormalMaterial, MeshStandardMaterial });
750
+ /**
751
+ * We can setup public API for this soba component with createInjectionToken + forwardRef
752
+ * the `example.api` is **usually** a computed property in the component class
753
+ *
754
+ * @see Bounds for example
755
+ */
756
+ const [injectNgtsExampleApi, provideNgtsExampleApi] = createInjectionToken((example) => example.api, { isRoot: false, deps: [forwardRef(() => NgtsExample)] });
757
+ /**
758
+ * @description this component is only for documentation purposes.
759
+ */
760
+ class NgtsExample {
761
+ constructor() {
762
+ /**
763
+ * use signalStore to store inputs with default inputs
764
+ */
765
+ this.inputs = signalStore({ color: '#cbcbcb', bevelSize: 0.04, debug: false });
766
+ /**
767
+ * a soba component usually has a Input for the component ref and this Input always has a default value with injectNgtRef
768
+ */
769
+ this.exampleRef = injectNgtRef();
770
+ /**
771
+ * exposes signals from inputs
772
+ */
773
+ this.bevelSize = this.inputs.select('bevelSize');
774
+ this.font = this.inputs.select('font');
775
+ this.debug = this.inputs.select('debug');
776
+ this.color = this.inputs.select('color');
777
+ /**
778
+ * can have internal state
779
+ */
780
+ this.count = signal(0);
781
+ /**
782
+ * Expose the public API for this soba component
783
+ */
784
+ this.api = computed(() => ({
785
+ bevelSize: this.bevelSize(),
786
+ increment: () => this.count.update((v) => v + 1),
787
+ decrement: () => this.count.update((v) => v - 1),
130
788
  }));
789
+ }
790
+ /**
791
+ * setup Input for the Inputs state. Use alias to have an easier time to setup computed
792
+ *
793
+ * @example: this way "private font" and "set _font" won't conflict
794
+ * private font = this.inputs.select('font');
795
+ */
796
+ set _font(font) {
797
+ this.inputs.set({ font });
798
+ }
799
+ set _color(color) {
800
+ this.inputs.set({ color });
801
+ }
802
+ set _debug(debug) {
803
+ this.inputs.set({ debug });
804
+ }
805
+ set _bevelSize(bevelSize) {
806
+ this.inputs.set({ bevelSize });
807
+ }
808
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsExample, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
809
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.0", type: NgtsExample, isStandalone: true, selector: "ngts-example", inputs: { exampleRef: "exampleRef", _font: ["font", "_font"], _color: ["color", "_color"], _debug: ["debug", "_debug"], _bevelSize: ["bevelSize", "_bevelSize"] }, providers: [provideNgtsExampleApi()], ngImport: i0, template: `
810
+ <!-- ngtCompound is used by the Renderer to spread props from ngts-example down to ngt-group -->
811
+ <!-- i.e: <ngts-example [position]="[1, 1, 1]" />, [1, 1, 1] will be passed down to ngt-group -->
812
+ <!-- [ref] is used with the Input so that the consumer can pass an external ref and control this internal ngt-group -->
813
+ <ngt-group ngtCompound [ref]="exampleRef">
814
+ <ngts-center [top]="true">
815
+ <ngts-text-3d
816
+ [bevelEnabled]="true"
817
+ [bevelSize]="bevelSize()"
818
+ [font]="font()"
819
+ [text]="count().toString()"
820
+ >
821
+ <ngt-mesh-standard-material *ngIf="!debug(); else withDebug" [color]="color()" />
822
+ <ng-template #withDebug>
823
+ <ngt-mesh-normal-material [wireframe]="true" />
824
+ </ng-template>
825
+ </ngts-text-3d>
826
+ </ngts-center>
827
+ <!-- use Content Projection here so consumers can pass in children for ngt-group -->
828
+ <ng-content />
829
+ </ngt-group>
830
+ `, isInline: true, dependencies: [{ kind: "component", type: NgtsCenter, selector: "ngts-center", inputs: ["centerRef", "top", "right", "bottom", "left", "front", "back", "disableX", "disableY", "disableZ", "disable", "precise", "cacheKey"], outputs: ["centered"] }, { kind: "component", type: NgtsText3D, selector: "ngts-text-3d", inputs: ["textRef", "font", "text", "bevelEnabled", "bevelOffset", "bevelSize", "bevelThickness", "curveSegments", "bevelSegments", "height", "size", "lineHeight", "letterSpacing", "smooth"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
831
+ }
832
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsExample, decorators: [{
833
+ type: Component,
834
+ args: [{
835
+ selector: 'ngts-example',
836
+ standalone: true,
837
+ template: `
838
+ <!-- ngtCompound is used by the Renderer to spread props from ngts-example down to ngt-group -->
839
+ <!-- i.e: <ngts-example [position]="[1, 1, 1]" />, [1, 1, 1] will be passed down to ngt-group -->
840
+ <!-- [ref] is used with the Input so that the consumer can pass an external ref and control this internal ngt-group -->
841
+ <ngt-group ngtCompound [ref]="exampleRef">
842
+ <ngts-center [top]="true">
843
+ <ngts-text-3d
844
+ [bevelEnabled]="true"
845
+ [bevelSize]="bevelSize()"
846
+ [font]="font()"
847
+ [text]="count().toString()"
848
+ >
849
+ <ngt-mesh-standard-material *ngIf="!debug(); else withDebug" [color]="color()" />
850
+ <ng-template #withDebug>
851
+ <ngt-mesh-normal-material [wireframe]="true" />
852
+ </ng-template>
853
+ </ngts-text-3d>
854
+ </ngts-center>
855
+ <!-- use Content Projection here so consumers can pass in children for ngt-group -->
856
+ <ng-content />
857
+ </ngt-group>
858
+ `,
859
+ /**
860
+ * can definitely use other Soba components
861
+ */
862
+ imports: [NgtsCenter, NgtsText3D, NgIf],
863
+ /**
864
+ * call the API provider here to actually provide the API for the component's children
865
+ */
866
+ providers: [provideNgtsExampleApi()],
867
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
868
+ }]
869
+ }], propDecorators: { exampleRef: [{
870
+ type: Input
871
+ }], _font: [{
872
+ type: Input,
873
+ args: [{ alias: 'font', required: true }]
874
+ }], _color: [{
875
+ type: Input,
876
+ args: [{ alias: 'color' }]
877
+ }], _debug: [{
878
+ type: Input,
879
+ args: [{ alias: 'debug' }]
880
+ }], _bevelSize: [{
881
+ type: Input,
882
+ args: [{ alias: 'bevelSize' }]
883
+ }] } });
884
+
885
+ var _a;
886
+ const v1 = new THREE.Vector3();
887
+ const v2 = new THREE.Vector3();
888
+ const v3 = new THREE.Vector3();
889
+ function defaultCalculatePosition(el, camera, size) {
890
+ const objectPos = v1.setFromMatrixPosition(el.matrixWorld);
891
+ objectPos.project(camera);
892
+ const widthHalf = size.width / 2;
893
+ const heightHalf = size.height / 2;
894
+ return [objectPos.x * widthHalf + widthHalf, -(objectPos.y * heightHalf) + heightHalf];
895
+ }
896
+ function isObjectBehindCamera(el, camera) {
897
+ const objectPos = v1.setFromMatrixPosition(el.matrixWorld);
898
+ const cameraPos = v2.setFromMatrixPosition(camera.matrixWorld);
899
+ const deltaCamObj = objectPos.sub(cameraPos);
900
+ const camDir = camera.getWorldDirection(v3);
901
+ return deltaCamObj.angleTo(camDir) > Math.PI / 2;
902
+ }
903
+ function isObjectVisible(el, camera, raycaster, occlude) {
904
+ const elPos = v1.setFromMatrixPosition(el.matrixWorld);
905
+ const screenPos = elPos.clone();
906
+ screenPos.project(camera);
907
+ raycaster.setFromCamera(screenPos, camera);
908
+ const intersects = raycaster.intersectObjects(occlude, true);
909
+ if (intersects.length) {
910
+ const intersectionDistance = intersects[0].distance;
911
+ const pointDistance = elPos.distanceTo(raycaster.ray.origin);
912
+ return pointDistance < intersectionDistance;
913
+ }
914
+ return true;
915
+ }
916
+ function objectScale(el, camera) {
917
+ if (camera instanceof THREE.OrthographicCamera) {
918
+ return camera.zoom;
919
+ }
920
+ else if (camera instanceof THREE.PerspectiveCamera) {
921
+ const objectPos = v1.setFromMatrixPosition(el.matrixWorld);
922
+ const cameraPos = v2.setFromMatrixPosition(camera.matrixWorld);
923
+ const vFOV = (camera.fov * Math.PI) / 180;
924
+ const dist = objectPos.distanceTo(cameraPos);
925
+ const scaleFOV = 2 * Math.tan(vFOV / 2) * dist;
926
+ return 1 / scaleFOV;
927
+ }
928
+ else {
929
+ return 1;
930
+ }
931
+ }
932
+ function objectZIndex(el, camera, zIndexRange) {
933
+ if (camera instanceof THREE.PerspectiveCamera || camera instanceof THREE.OrthographicCamera) {
934
+ const objectPos = v1.setFromMatrixPosition(el.matrixWorld);
935
+ const cameraPos = v2.setFromMatrixPosition(camera.matrixWorld);
936
+ const dist = objectPos.distanceTo(cameraPos);
937
+ const A = (zIndexRange[1] - zIndexRange[0]) / (camera.far - camera.near);
938
+ const B = zIndexRange[1] - A * camera.far;
939
+ return Math.round(A * dist + B);
940
+ }
941
+ return undefined;
942
+ }
943
+ const epsilon = (value) => (Math.abs(value) < 1e-10 ? 0 : value);
944
+ function getCSSMatrix(matrix, multipliers, prepend = '') {
945
+ let matrix3d = 'matrix3d(';
946
+ for (let i = 0; i !== 16; i++) {
947
+ matrix3d += epsilon(multipliers[i] * matrix.elements[i]) + (i !== 15 ? ',' : ')');
948
+ }
949
+ return prepend + matrix3d;
950
+ }
951
+ const getCameraCSSMatrix = ((multipliers) => {
952
+ return (matrix) => getCSSMatrix(matrix, multipliers);
953
+ })([1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1]);
954
+ const getObjectCSSMatrix = ((scaleMultipliers) => {
955
+ return (matrix, factor) => getCSSMatrix(matrix, scaleMultipliers(factor), 'translate(-50%,-50%)');
956
+ })((f) => [1 / f, 1 / f, 1 / f, 1, -1 / f, -1 / f, -1 / f, -1, 1 / f, 1 / f, 1 / f, 1, 1, 1, 1, 1]);
957
+ class NgtsHtmlWrapper {
958
+ static { _a = HTML; }
959
+ static { this[_a] = true; }
960
+ constructor() {
961
+ this.htmlInputs = injectNgtsHtmlInputs();
962
+ this.store = injectNgtStore();
963
+ this.gl = this.store.select('gl');
964
+ this.connected = this.store.select('events', 'connected', { equal: Object.is });
965
+ this.viewport = this.store.select('viewport');
966
+ this.scene = this.store.select('scene');
967
+ this.camera = this.store.select('camera');
968
+ this.size = this.store.select('size');
969
+ this.raycaster = this.store.select('raycaster');
970
+ this.isMeshSizeSet = false;
971
+ this.document = inject(DOCUMENT);
972
+ this.vcr = inject(ViewContainerRef);
973
+ this.portalElement = computed(() => {
974
+ const portal = this.htmlInputs.portal();
975
+ if (!portal)
976
+ return null;
977
+ return is.ref(portal) ? portal.nativeElement : portal;
978
+ });
979
+ this.element = computed(() => this.document.createElement(this.htmlInputs.as()));
980
+ this.target = computed(() => {
981
+ const portalElement = this.portalElement();
982
+ if (portalElement)
983
+ return portalElement;
984
+ const connected = this.connected();
985
+ if (connected)
986
+ return connected;
987
+ return this.gl().domElement.parentElement;
988
+ });
989
+ this.styles = computed(() => {
990
+ const [style, center, transform, size, fullscreen] = [
991
+ this.htmlInputs.style(),
992
+ this.htmlInputs.center(),
993
+ this.htmlInputs.transform(),
994
+ this.size(),
995
+ this.htmlInputs.fullscreen(),
996
+ ];
997
+ if (transform) {
998
+ return {
999
+ position: 'absolute',
1000
+ top: 0,
1001
+ left: 0,
1002
+ width: size.width,
1003
+ height: size.height,
1004
+ transformStyle: 'preserve-3d',
1005
+ pointerEvents: 'none',
1006
+ };
1007
+ }
1008
+ return {
1009
+ position: 'absolute',
1010
+ transform: center ? 'translate3d(-50%,-50%,0)' : 'none',
1011
+ ...(fullscreen && {
1012
+ top: -size.height / 2,
1013
+ left: -size.width / 2,
1014
+ width: size.width,
1015
+ height: size.height,
1016
+ }),
1017
+ ...(style || {}),
1018
+ };
1019
+ });
1020
+ this.transformInnerStyles = computed(() => ({ position: 'absolute', pointerEvents: this.htmlInputs.pointerEvents() }));
1021
+ this.setCanvasElementStyle();
1022
+ this.appendElement();
1023
+ this.setWrapperClass();
1024
+ this.render();
1025
+ this.beforeRender();
1026
+ }
1027
+ setCanvasElementStyle() {
1028
+ effect(() => {
1029
+ const el = untracked(this.gl).domElement;
1030
+ const occlude = this.htmlInputs.occlude();
1031
+ if (occlude && occlude === 'blending') {
1032
+ el.style.zIndex = `${Math.floor(untracked(this.htmlInputs.zIndexRange)[0] / 2)}`;
1033
+ el.style.position = 'absolute';
1034
+ el.style.pointerEvents = 'none';
1035
+ }
1036
+ else {
1037
+ el.style.zIndex = null;
1038
+ el.style.position = null;
1039
+ el.style.pointerEvents = null;
1040
+ }
1041
+ });
1042
+ }
1043
+ appendElement() {
1044
+ effect((onCleanup) => {
1045
+ const [group, element] = [this.htmlInputs.groupRef.nativeElement, this.element()];
1046
+ if (group && element) {
1047
+ const [target, transform, scene, camera, size, calculatePosition, prepend] = [
1048
+ this.target(),
1049
+ this.htmlInputs.transform(),
1050
+ untracked(this.scene),
1051
+ untracked(this.camera),
1052
+ untracked(this.size),
1053
+ untracked(this.htmlInputs.calculatePosition),
1054
+ untracked(this.htmlInputs.prepend),
1055
+ ];
1056
+ scene.updateMatrixWorld();
1057
+ if (transform) {
1058
+ element.style.cssText = `position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;`;
1059
+ }
1060
+ else {
1061
+ const vec = calculatePosition(group, camera, size);
1062
+ element.style.cssText = `position:absolute;top:0;left:0;transform:translate3d(${vec[0]}px,${vec[1]}px,0);transform-origin:0 0;`;
1063
+ }
1064
+ if (target) {
1065
+ if (prepend)
1066
+ target.prepend(element);
1067
+ else
1068
+ target.appendChild(element);
1069
+ }
1070
+ onCleanup(() => {
1071
+ if (target)
1072
+ target.removeChild(element);
1073
+ this.vcr.clear();
1074
+ });
1075
+ }
1076
+ });
1077
+ }
1078
+ setWrapperClass() {
1079
+ effect(() => {
1080
+ const [element, wrapperClass] = [this.element(), this.htmlInputs.wrapperClass()];
1081
+ if (element && wrapperClass) {
1082
+ element.className = wrapperClass;
1083
+ }
1084
+ });
1085
+ }
1086
+ render() {
1087
+ effect((onCleanup) => {
1088
+ const [{ transform }, element, content] = [
1089
+ this.htmlInputs.state(),
1090
+ this.element(),
1091
+ this.htmlInputs.content(),
1092
+ ];
1093
+ if (element) {
1094
+ this.isMeshSizeSet = false;
1095
+ const params = transform
1096
+ ? [this.transformTemplate, {}]
1097
+ : [this.renderTemplate, { styles: this.styles }];
1098
+ const ref = this.vcr.createEmbeddedView(...params);
1099
+ if (ref.rootNodes?.[0]) {
1100
+ if (element.hasChildNodes()) {
1101
+ element.replaceChildren(...ref.rootNodes);
1102
+ }
1103
+ else {
1104
+ element.append(...ref.rootNodes);
1105
+ }
1106
+ }
1107
+ safeDetectChanges(ref);
1108
+ let contentRef;
1109
+ let contentParent;
1110
+ /**
1111
+ * NOTE: utilizing rAF here so that renderAnchor (ViewContainerRef) has a chance to be resolved
1112
+ * TODO: Another approach is to call render() in ngOnInit and pass in an injector to the effect
1113
+ */
1114
+ const rAF = requestAnimationFrame(() => {
1115
+ if (content && this.renderAnchor) {
1116
+ contentRef = this.renderAnchor.createEmbeddedView(content);
1117
+ contentParent = ref.rootNodes[0].lastElementChild || ref.rootNodes[0];
1118
+ while (contentParent && contentParent.lastElementChild) {
1119
+ contentParent = contentParent.lastElementChild;
1120
+ }
1121
+ if (contentRef.rootNodes?.[0]) {
1122
+ if (contentParent.hasChildNodes()) {
1123
+ contentParent.replaceChildren(...contentRef.rootNodes);
1124
+ }
1125
+ else {
1126
+ contentParent.append(...contentRef.rootNodes);
1127
+ }
1128
+ }
1129
+ safeDetectChanges(contentRef);
1130
+ }
1131
+ });
1132
+ onCleanup(() => {
1133
+ cancelAnimationFrame(rAF);
1134
+ if (contentRef && contentParent) {
1135
+ contentRef.rootNodes.forEach((node) => {
1136
+ if (contentParent.hasChildNodes()) {
1137
+ contentParent.removeChild(node);
1138
+ }
1139
+ node.remove();
1140
+ });
1141
+ contentRef.destroy();
1142
+ }
1143
+ ref.rootNodes.forEach((node) => {
1144
+ if (element.hasChildNodes()) {
1145
+ element.removeChild(node);
1146
+ }
1147
+ node.remove();
1148
+ });
1149
+ ref.destroy();
1150
+ this.renderAnchor?.clear();
1151
+ this.vcr.clear();
1152
+ });
1153
+ }
1154
+ });
1155
+ }
1156
+ beforeRender() {
1157
+ let oldPosition = [0, 0];
1158
+ let oldZoom = 0;
1159
+ let visible = true;
1160
+ injectBeforeRender((gl) => {
1161
+ const [group, camera, transform, calculatePosition, size, eps, isRayCastOcclusion, occlude, scene, raycaster, element, zIndexRange, sprite, distanceFactor, occlusionMeshRef, geometry, viewport, scale,] = [
1162
+ this.htmlInputs.groupRef.nativeElement,
1163
+ this.camera(),
1164
+ this.htmlInputs.transform(),
1165
+ this.htmlInputs.calculatePosition(),
1166
+ this.size(),
1167
+ this.htmlInputs.eps(),
1168
+ this.htmlInputs.isRayCastOcclusion(),
1169
+ this.htmlInputs.occlude(),
1170
+ this.scene(),
1171
+ this.raycaster(),
1172
+ this.element(),
1173
+ this.htmlInputs.zIndexRange(),
1174
+ this.htmlInputs.sprite(),
1175
+ this.htmlInputs.distanceFactor(),
1176
+ this.htmlInputs.occlusionMeshRef.nativeElement,
1177
+ this.htmlInputs.geometry(),
1178
+ this.viewport(),
1179
+ this.htmlInputs.scale(),
1180
+ ];
1181
+ if (group && element) {
1182
+ camera.updateMatrixWorld();
1183
+ group.updateWorldMatrix(true, false);
1184
+ const vec = transform ? oldPosition : calculatePosition(group, camera, size);
1185
+ if (transform ||
1186
+ Math.abs(oldZoom - camera.zoom) > eps ||
1187
+ Math.abs(oldPosition[0] - vec[0]) > eps ||
1188
+ Math.abs(oldPosition[1] - vec[1]) > eps) {
1189
+ const isBehindCamera = isObjectBehindCamera(group, camera);
1190
+ let raytraceTarget = false;
1191
+ if (isRayCastOcclusion) {
1192
+ if (occlude !== 'blending') {
1193
+ raytraceTarget = [scene];
1194
+ }
1195
+ else if (Array.isArray(occlude)) {
1196
+ raytraceTarget = occlude.map((item) => (is.ref(item) ? item.nativeElement : item));
1197
+ }
1198
+ }
1199
+ const previouslyVisible = visible;
1200
+ if (raytraceTarget) {
1201
+ const isVisible = isObjectVisible(group, camera, raycaster, raytraceTarget);
1202
+ visible = isVisible && !isBehindCamera;
1203
+ }
1204
+ else {
1205
+ visible = !isBehindCamera;
1206
+ }
1207
+ if (previouslyVisible !== visible) {
1208
+ if (this.htmlInputs.occluded.observed) {
1209
+ this.htmlInputs.occluded.emit(!visible);
1210
+ }
1211
+ else {
1212
+ element.style.display = visible ? 'block' : 'none';
1213
+ }
1214
+ }
1215
+ const halfRange = Math.floor(zIndexRange[0] / 2);
1216
+ const zRange = occlude
1217
+ ? isRayCastOcclusion //
1218
+ ? [zIndexRange[0], halfRange]
1219
+ : [halfRange - 1, 0]
1220
+ : zIndexRange;
1221
+ element.style.zIndex = `${objectZIndex(group, camera, zRange)}`;
1222
+ if (transform) {
1223
+ const [widthHalf, heightHalf] = [size.width / 2, size.height / 2];
1224
+ const fov = camera.projectionMatrix.elements[5] * heightHalf;
1225
+ const { isOrthographicCamera, top, left, bottom, right } = camera;
1226
+ const cameraMatrix = getCameraCSSMatrix(camera.matrixWorldInverse);
1227
+ const cameraTransform = isOrthographicCamera
1228
+ ? `scale(${fov})translate(${epsilon(-(right + left) / 2)}px,${epsilon((top + bottom) / 2)}px)`
1229
+ : `translateZ(${fov}px)`;
1230
+ let matrix = group.matrixWorld;
1231
+ if (sprite) {
1232
+ matrix = camera.matrixWorldInverse
1233
+ .clone()
1234
+ .transpose()
1235
+ .copyPosition(matrix)
1236
+ .scale(group.scale);
1237
+ matrix.elements[3] = matrix.elements[7] = matrix.elements[11] = 0;
1238
+ matrix.elements[15] = 1;
1239
+ }
1240
+ element.style.width = size.width + 'px';
1241
+ element.style.height = size.height + 'px';
1242
+ element.style.perspective = isOrthographicCamera ? '' : `${fov}px`;
1243
+ if (this.outerDiv?.nativeElement && this.innerDiv?.nativeElement) {
1244
+ this.outerDiv.nativeElement.style.width = size.width + 'px';
1245
+ this.outerDiv.nativeElement.style.height = size.height + 'px';
1246
+ this.outerDiv.nativeElement.style.transform = `${cameraTransform}${cameraMatrix}translate(${widthHalf}px,${heightHalf}px)`;
1247
+ this.innerDiv.nativeElement.style.transform = getObjectCSSMatrix(matrix, 1 / ((distanceFactor || 10) / 400));
1248
+ }
1249
+ }
1250
+ else {
1251
+ const scale = distanceFactor === undefined ? 1 : objectScale(group, camera) * distanceFactor;
1252
+ element.style.transform = `translate3d(${vec[0]}px,${vec[1]}px,0) scale(${scale})`;
1253
+ }
1254
+ oldPosition = vec;
1255
+ oldZoom = camera.zoom;
1256
+ }
1257
+ }
1258
+ if (!isRayCastOcclusion && occlusionMeshRef && !this.isMeshSizeSet) {
1259
+ if (transform) {
1260
+ if (this.outerDiv?.nativeElement) {
1261
+ const el = this.outerDiv.nativeElement.children[0];
1262
+ if (el?.clientWidth && el?.clientHeight) {
1263
+ const { isOrthographicCamera } = camera;
1264
+ if (isOrthographicCamera || geometry) {
1265
+ if (scale !== 1) {
1266
+ if (!Array.isArray(scale)) {
1267
+ occlusionMeshRef.scale.setScalar(1 / scale);
1268
+ }
1269
+ else if (scale instanceof THREE.Vector3) {
1270
+ occlusionMeshRef.scale.copy(scale.clone().divideScalar(1));
1271
+ }
1272
+ else {
1273
+ occlusionMeshRef.scale.set(1 / scale[0], 1 / scale[1], 1 / scale[2]);
1274
+ }
1275
+ }
1276
+ }
1277
+ else {
1278
+ const ratio = (distanceFactor || 10) / 400;
1279
+ const w = el.clientWidth * ratio;
1280
+ const h = el.clientHeight * ratio;
1281
+ occlusionMeshRef.scale.set(w, h, 1);
1282
+ }
1283
+ this.isMeshSizeSet = true;
1284
+ }
1285
+ }
1286
+ }
1287
+ else {
1288
+ const ele = element.children[0];
1289
+ if (ele?.clientWidth && ele?.clientHeight) {
1290
+ const ratio = 1 / viewport.factor;
1291
+ const w = ele.clientWidth * ratio;
1292
+ const h = ele.clientHeight * ratio;
1293
+ occlusionMeshRef.scale.set(w, h, 1);
1294
+ this.isMeshSizeSet = true;
1295
+ }
1296
+ occlusionMeshRef.lookAt(gl.camera.position);
1297
+ }
1298
+ }
1299
+ });
1300
+ }
1301
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsHtmlWrapper, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1302
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.0", type: NgtsHtmlWrapper, isStandalone: true, selector: "ngts-html-wrapper", viewQueries: [{ propertyName: "transformTemplate", first: true, predicate: ["transformTemplate"], descendants: true, static: true }, { propertyName: "renderTemplate", first: true, predicate: ["renderTemplate"], descendants: true, static: true }, { propertyName: "outerDiv", first: true, predicate: ["transformedOuterDiv"], descendants: true }, { propertyName: "innerDiv", first: true, predicate: ["transformedInnerDiv"], descendants: true }, { propertyName: "renderAnchor", first: true, predicate: ["renderAnchor"], descendants: true, read: ViewContainerRef }], ngImport: i0, template: `
1303
+ <ng-template #transformTemplate>
1304
+ <div #transformedOuterDiv [style]="styles()">
1305
+ <div #transformedInnerDiv [style]="transformInnerStyles()">
1306
+ <ng-container *ngTemplateOutlet="renderTemplate; context: { styles: htmlInputs.style }" />
1307
+ </div>
1308
+ </div>
1309
+ </ng-template>
1310
+
1311
+ <ng-template #renderTemplate let-renderedStyles="styles">
1312
+ <div #renderedDiv [class]="htmlInputs.renderedDivClass()" [style]="renderedStyles()">
1313
+ <ng-container #renderAnchor />
1314
+ </div>
1315
+ </ng-template>
1316
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
1317
+ }
1318
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsHtmlWrapper, decorators: [{
1319
+ type: Component,
1320
+ args: [{
1321
+ selector: 'ngts-html-wrapper',
1322
+ standalone: true,
1323
+ template: `
1324
+ <ng-template #transformTemplate>
1325
+ <div #transformedOuterDiv [style]="styles()">
1326
+ <div #transformedInnerDiv [style]="transformInnerStyles()">
1327
+ <ng-container *ngTemplateOutlet="renderTemplate; context: { styles: htmlInputs.style }" />
1328
+ </div>
1329
+ </div>
1330
+ </ng-template>
1331
+
1332
+ <ng-template #renderTemplate let-renderedStyles="styles">
1333
+ <div #renderedDiv [class]="htmlInputs.renderedDivClass()" [style]="renderedStyles()">
1334
+ <ng-container #renderAnchor />
1335
+ </div>
1336
+ </ng-template>
1337
+ `,
1338
+ imports: [NgTemplateOutlet],
1339
+ }]
1340
+ }], ctorParameters: function () { return []; }, propDecorators: { transformTemplate: [{
1341
+ type: ViewChild,
1342
+ args: ['transformTemplate', { static: true }]
1343
+ }], renderTemplate: [{
1344
+ type: ViewChild,
1345
+ args: ['renderTemplate', { static: true }]
1346
+ }], outerDiv: [{
1347
+ type: ViewChild,
1348
+ args: ['transformedOuterDiv']
1349
+ }], innerDiv: [{
1350
+ type: ViewChild,
1351
+ args: ['transformedInnerDiv']
1352
+ }], renderAnchor: [{
1353
+ type: ViewChild,
1354
+ args: ['renderAnchor', { read: ViewContainerRef }]
1355
+ }] } });
1356
+
1357
+ extend({ Group, PlaneGeometry, Mesh, ShaderMaterial });
1358
+ const [injectNgtsHtmlInputs, provideNgtsHtmlInputs] = createInjectionToken((html) => ({ state: html.inputs.state, ...html.state }), { isRoot: false, deps: [forwardRef(() => NgtsHtml)] });
1359
+ class NgtsHtml {
1360
+ constructor() {
1361
+ this.DoubleSide = THREE.DoubleSide;
1362
+ this.inputs = signalStore({
1363
+ as: 'div',
1364
+ prepend: false,
1365
+ transform: false,
1366
+ fullscreen: false,
1367
+ center: false,
1368
+ sprite: false,
1369
+ zIndexRange: [16777271, 0],
1370
+ eps: 0.001,
1371
+ scale: 1,
1372
+ calculatePosition: defaultCalculatePosition,
1373
+ pointerEvents: 'auto',
1374
+ occlude: false,
1375
+ castShadow: false,
1376
+ receiveShadow: false,
1377
+ });
1378
+ this.groupRef = injectNgtRef();
1379
+ this.occluded = new EventEmitter();
1380
+ this.occlusionMeshRef = injectNgtRef();
1381
+ this.transform = this.inputs.select('transform');
1382
+ this.isRayCastOcclusion = computed(() => {
1383
+ const occlude = this.occlude();
1384
+ return ((occlude && occlude !== 'blending') || (Array.isArray(occlude) && !!occlude.length && is.ref(occlude[0])));
1385
+ });
1386
+ this.occlude = this.inputs.select('occlude');
1387
+ this.castShadow = this.inputs.select('castShadow');
1388
+ this.receiveShadow = this.inputs.select('receiveShadow');
1389
+ this.geometry = this.inputs.select('geometry');
1390
+ this.material = this.inputs.select('material');
1391
+ this.scale = this.inputs.select('scale');
1392
+ this.shaders = computed(() => {
1393
+ const transform = this.transform();
1394
+ return {
1395
+ vertexShader: !transform
1396
+ ? /* glsl */ `
1397
+ /*
1398
+ This shader is from the THREE's SpriteMaterial.
1399
+ We need to turn the backing plane into a Sprite
1400
+ (make it always face the camera) if "transfrom"
1401
+ is false.
1402
+ */
1403
+ #include <common>
1404
+
1405
+ void main() {
1406
+ vec2 center = vec2(0., 1.);
1407
+ float rotation = 0.0;
1408
+
1409
+ // This is somewhat arbitrary, but it seems to work well
1410
+ // Need to figure out how to derive this dynamically if it even matters
1411
+ float size = 0.03;
1412
+
1413
+ vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
1414
+ vec2 scale;
1415
+ scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
1416
+ scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
1417
+
1418
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
1419
+ if ( isPerspective ) scale *= - mvPosition.z;
1420
+
1421
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;
1422
+ vec2 rotatedPosition;
1423
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
1424
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
1425
+ mvPosition.xy += rotatedPosition;
1426
+
1427
+ gl_Position = projectionMatrix * mvPosition;
1428
+ }
1429
+ `
1430
+ : undefined,
1431
+ fragmentShader: /* glsl */ `
1432
+ void main() {
1433
+ gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
1434
+ }
1435
+ `,
1436
+ };
1437
+ });
1438
+ this.state = {
1439
+ zIndexRange: this.inputs.select('zIndexRange'),
1440
+ prepend: this.inputs.select('prepend'),
1441
+ transform: this.transform,
1442
+ center: this.inputs.select('center'),
1443
+ fullscreen: this.inputs.select('fullscreen'),
1444
+ calculatePosition: this.inputs.select('calculatePosition'),
1445
+ wrapperClass: this.inputs.select('wrapperClass'),
1446
+ renderedDivClass: this.inputs.select('renderedDivClass'),
1447
+ style: this.inputs.select('style'),
1448
+ pointerEvents: this.inputs.select('pointerEvents'),
1449
+ eps: this.inputs.select('eps'),
1450
+ distanceFactor: this.inputs.select('distanceFactor'),
1451
+ sprite: this.inputs.select('sprite'),
1452
+ as: this.inputs.select('as'),
1453
+ portal: this.inputs.select('portal'),
1454
+ content: this.inputs.select('content'),
1455
+ occlude: this.occlude,
1456
+ isRayCastOcclusion: this.isRayCastOcclusion,
1457
+ occlusionMeshRef: this.occlusionMeshRef,
1458
+ occluded: this.occluded,
1459
+ geometry: this.geometry,
1460
+ scale: this.scale,
1461
+ groupRef: this.groupRef,
1462
+ };
1463
+ }
1464
+ set content(content) {
1465
+ this.inputs.set({ content });
1466
+ }
1467
+ set _as(as) {
1468
+ this.inputs.set({ as });
1469
+ }
1470
+ set _zIndexRange(zIndexRange) {
1471
+ this.inputs.set({ zIndexRange });
1472
+ }
1473
+ set _portal(portal) {
1474
+ this.inputs.set({ portal });
1475
+ }
1476
+ set _occlude(occlude) {
1477
+ this.inputs.set({ occlude });
1478
+ }
1479
+ set _castShadow(castShadow) {
1480
+ this.inputs.set({ castShadow });
1481
+ }
1482
+ set _receiveShadow(receiveShadow) {
1483
+ this.inputs.set({ receiveShadow });
1484
+ }
1485
+ set _material(material) {
1486
+ this.inputs.set({ material });
1487
+ }
1488
+ set _geometry(geometry) {
1489
+ this.inputs.set({ geometry });
1490
+ }
1491
+ set _scale(scale) {
1492
+ this.inputs.set({ scale });
1493
+ }
1494
+ set _prepend(prepend) {
1495
+ this.inputs.set({ prepend });
1496
+ }
1497
+ set _transform(transform) {
1498
+ this.inputs.set({ transform });
1499
+ }
1500
+ set _center(center) {
1501
+ this.inputs.set({ center });
1502
+ }
1503
+ set _sprite(sprite) {
1504
+ this.inputs.set({ sprite });
1505
+ }
1506
+ set _fullscreen(fullscreen) {
1507
+ this.inputs.set({ fullscreen });
1508
+ }
1509
+ set _eps(eps) {
1510
+ this.inputs.set({ eps });
1511
+ }
1512
+ set _distanceFactor(distanceFactor) {
1513
+ this.inputs.set({ distanceFactor });
1514
+ }
1515
+ set _wrapperClass(wrapperClass) {
1516
+ this.inputs.set({ wrapperClass });
1517
+ }
1518
+ set _renderedDivClass(renderedDivClass) {
1519
+ this.inputs.set({ renderedDivClass });
1520
+ }
1521
+ set _style(style) {
1522
+ this.inputs.set({ style });
1523
+ }
1524
+ set _pointerEvents(pointerEvents) {
1525
+ this.inputs.set({ pointerEvents });
1526
+ }
1527
+ set _calculatePosition(calculatePosition) {
1528
+ this.inputs.set({ calculatePosition });
1529
+ }
1530
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsHtml, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1531
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.0", type: NgtsHtml, isStandalone: true, selector: "ngts-html", inputs: { groupRef: "groupRef", _as: ["as", "_as"], _zIndexRange: ["zIndexRange", "_zIndexRange"], _portal: ["portal", "_portal"], _occlude: ["occlude", "_occlude"], _castShadow: ["castShadow", "_castShadow"], _receiveShadow: ["receiveShadow", "_receiveShadow"], _material: ["material", "_material"], _geometry: ["geometry", "_geometry"], _scale: ["scale", "_scale"], _prepend: ["prepend", "_prepend"], _transform: ["transform", "_transform"], _center: ["center", "_center"], _sprite: ["sprite", "_sprite"], _fullscreen: ["fullscreen", "_fullscreen"], _eps: ["eps", "_eps"], _distanceFactor: ["distanceFactor", "_distanceFactor"], _wrapperClass: ["wrapperClass", "_wrapperClass"], _renderedDivClass: ["renderedDivClass", "_renderedDivClass"], _style: ["style", "_style"], _pointerEvents: ["pointerEvents", "_pointerEvents"], _calculatePosition: ["calculatePosition", "_calculatePosition"] }, outputs: { occluded: "occluded" }, providers: [provideNgtsHtmlInputs()], queries: [{ propertyName: "content", first: true, predicate: NgtsSobaContent, descendants: true, read: TemplateRef }], ngImport: i0, template: `
1532
+ <ngt-group ngtCompound [ref]="groupRef" [scale]="scale()">
1533
+ <ngt-mesh
1534
+ *ngIf="occlude() && !isRayCastOcclusion()"
1535
+ [castShadow]="castShadow()"
1536
+ [receiveShadow]="receiveShadow()"
1537
+ [ref]="occlusionMeshRef"
1538
+ >
1539
+ <ngt-plane-geometry *ngIf="geometry()" />
1540
+ <ngt-shader-material
1541
+ *ngIf="material()"
1542
+ [side]="DoubleSide"
1543
+ [vertexShader]="shaders().vertexShader"
1544
+ [fragmentShader]="shaders().fragmentShader"
1545
+ />
1546
+ </ngt-mesh>
1547
+ </ngt-group>
1548
+
1549
+ <ngts-html-wrapper />
1550
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: NgtsHtmlWrapper, selector: "ngts-html-wrapper" }] }); }
1551
+ }
1552
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsHtml, decorators: [{
1553
+ type: Component,
1554
+ args: [{
1555
+ selector: 'ngts-html',
1556
+ standalone: true,
1557
+ template: `
1558
+ <ngt-group ngtCompound [ref]="groupRef" [scale]="scale()">
1559
+ <ngt-mesh
1560
+ *ngIf="occlude() && !isRayCastOcclusion()"
1561
+ [castShadow]="castShadow()"
1562
+ [receiveShadow]="receiveShadow()"
1563
+ [ref]="occlusionMeshRef"
1564
+ >
1565
+ <ngt-plane-geometry *ngIf="geometry()" />
1566
+ <ngt-shader-material
1567
+ *ngIf="material()"
1568
+ [side]="DoubleSide"
1569
+ [vertexShader]="shaders().vertexShader"
1570
+ [fragmentShader]="shaders().fragmentShader"
1571
+ />
1572
+ </ngt-mesh>
1573
+ </ngt-group>
1574
+
1575
+ <ngts-html-wrapper />
1576
+ `,
1577
+ imports: [NgIf, NgtsHtmlWrapper],
1578
+ providers: [provideNgtsHtmlInputs()],
1579
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
1580
+ }]
1581
+ }], propDecorators: { content: [{
1582
+ type: ContentChild,
1583
+ args: [NgtsSobaContent, { read: TemplateRef }]
1584
+ }], groupRef: [{
1585
+ type: Input
1586
+ }], _as: [{
1587
+ type: Input,
1588
+ args: [{ alias: 'as' }]
1589
+ }], _zIndexRange: [{
1590
+ type: Input,
1591
+ args: [{ alias: 'zIndexRange' }]
1592
+ }], _portal: [{
1593
+ type: Input,
1594
+ args: [{ alias: 'portal' }]
1595
+ }], _occlude: [{
1596
+ type: Input,
1597
+ args: [{ alias: 'occlude' }]
1598
+ }], _castShadow: [{
1599
+ type: Input,
1600
+ args: [{ alias: 'castShadow' }]
1601
+ }], _receiveShadow: [{
1602
+ type: Input,
1603
+ args: [{ alias: 'receiveShadow' }]
1604
+ }], _material: [{
1605
+ type: Input,
1606
+ args: [{ alias: 'material' }]
1607
+ }], _geometry: [{
1608
+ type: Input,
1609
+ args: [{ alias: 'geometry' }]
1610
+ }], _scale: [{
1611
+ type: Input,
1612
+ args: [{ alias: 'scale' }]
1613
+ }], _prepend: [{
1614
+ type: Input,
1615
+ args: [{ alias: 'prepend' }]
1616
+ }], _transform: [{
1617
+ type: Input,
1618
+ args: [{ alias: 'transform' }]
1619
+ }], _center: [{
1620
+ type: Input,
1621
+ args: [{ alias: 'center' }]
1622
+ }], _sprite: [{
1623
+ type: Input,
1624
+ args: [{ alias: 'sprite' }]
1625
+ }], _fullscreen: [{
1626
+ type: Input,
1627
+ args: [{ alias: 'fullscreen' }]
1628
+ }], _eps: [{
1629
+ type: Input,
1630
+ args: [{ alias: 'eps' }]
1631
+ }], _distanceFactor: [{
1632
+ type: Input,
1633
+ args: [{ alias: 'distanceFactor' }]
1634
+ }], _wrapperClass: [{
1635
+ type: Input,
1636
+ args: [{ alias: 'wrapperClass' }]
1637
+ }], _renderedDivClass: [{
1638
+ type: Input,
1639
+ args: [{ alias: 'renderedDivClass' }]
1640
+ }], _style: [{
1641
+ type: Input,
1642
+ args: [{ alias: 'style' }]
1643
+ }], _pointerEvents: [{
1644
+ type: Input,
1645
+ args: [{ alias: 'pointerEvents' }]
1646
+ }], _calculatePosition: [{
1647
+ type: Input,
1648
+ args: [{ alias: 'calculatePosition' }]
1649
+ }], occluded: [{
1650
+ type: Output
1651
+ }] } });
1652
+
1653
+ const defaultState = {
1654
+ count: 16,
1655
+ };
1656
+ function injectNgtsSurfaceSampler(surfaceSamplerState, { injector } = {}) {
1657
+ injector = assertInjectionContext(injectNgtsSurfaceSampler, injector);
1658
+ return runInInjectionContext(injector, () => {
1659
+ const state = computed(() => {
1660
+ const _state = surfaceSamplerState();
1661
+ if (!_state)
1662
+ return null;
1663
+ return { ...defaultState, ..._state };
1664
+ });
1665
+ const _buffer = signal((() => {
1666
+ const arr = Array.from({ length: state()?.count || defaultState.count }, () => [
1667
+ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,
1668
+ ]).flat();
1669
+ return new THREE.InstancedBufferAttribute(Float32Array.from(arr), 16);
1670
+ })());
1671
+ effect(() => {
1672
+ const _state = state();
1673
+ if (!_state)
1674
+ return;
1675
+ const { mesh, count, transform, instancedMesh, weight } = _state;
1676
+ const meshObj = is.ref(mesh) ? mesh.nativeElement : mesh;
1677
+ if (!meshObj)
1678
+ return;
1679
+ const instancedMeshObj = is.ref(instancedMesh) ? instancedMesh.nativeElement : instancedMesh;
1680
+ const buffer = untracked(_buffer);
1681
+ const sampler = new MeshSurfaceSampler(meshObj);
1682
+ if (weight) {
1683
+ sampler.setWeightAttribute(weight);
1684
+ }
1685
+ sampler.build();
1686
+ const position = new THREE.Vector3();
1687
+ const normal = new THREE.Vector3();
1688
+ const color = new THREE.Color();
1689
+ const dummy = new THREE.Object3D();
1690
+ meshObj.updateMatrixWorld(true);
1691
+ for (let i = 0; i < count; i++) {
1692
+ sampler.sample(position, normal, color);
1693
+ if (typeof transform === 'function') {
1694
+ transform({ dummy, sampledMesh: meshObj, position, normal, color }, i);
1695
+ }
1696
+ else {
1697
+ dummy.position.copy(position);
1698
+ }
1699
+ dummy.updateMatrix();
1700
+ if (instancedMeshObj) {
1701
+ instancedMeshObj.setMatrixAt(i, dummy.matrix);
1702
+ }
1703
+ dummy.matrix.toArray(buffer.array, i * 16);
1704
+ }
1705
+ if (instancedMeshObj) {
1706
+ checkUpdate(instancedMeshObj.instanceMatrix);
1707
+ }
1708
+ checkUpdate(buffer);
1709
+ untracked(() => {
1710
+ _buffer.set(buffer.clone());
1711
+ });
1712
+ });
1713
+ return _buffer.asReadonly();
131
1714
  });
132
- let count = 0;
133
- injectBeforeRender(({ gl, scene, camera }) => {
134
- if ((rawParams.frames === Infinity || count < rawParams.frames) && fbo.nativeElement) {
135
- gl.setRenderTarget(fbo.nativeElement);
136
- gl.render(scene, camera);
137
- gl.setRenderTarget(null);
138
- count++;
1715
+ }
1716
+ extend({ Group });
1717
+ class NgtsSampler {
1718
+ set _count(count) {
1719
+ this.inputs.set({ count });
1720
+ }
1721
+ set _mesh(mesh) {
1722
+ this.inputs.set({ mesh });
1723
+ }
1724
+ set _transform(transform) {
1725
+ this.inputs.set({ transform });
1726
+ }
1727
+ set _weight(weight) {
1728
+ this.inputs.set({ weight });
1729
+ }
1730
+ set _instancedMesh(instancedMesh) {
1731
+ this.inputs.set({ instancedMesh });
1732
+ }
1733
+ constructor() {
1734
+ this.inputs = signalStore({ count: 16 });
1735
+ this.samplerRef = injectNgtRef();
1736
+ this.surfaceSamplerState = computed(() => {
1737
+ const sampler = this.samplerRef.nativeElement;
1738
+ if (!sampler)
1739
+ return null;
1740
+ const { count, weight, transform, mesh, instancedMesh } = this.inputs.state();
1741
+ const instancedMeshRef = instancedMesh ??
1742
+ sampler.children.find((child) => child.hasOwnProperty('instanceMatrix'));
1743
+ const meshRef = mesh ?? sampler.children.find((child) => child.type === 'Mesh');
1744
+ return { count, weight, transform, mesh: meshRef, instancedMesh: instancedMeshRef };
1745
+ });
1746
+ const injector = inject(Injector);
1747
+ effect(() => {
1748
+ injectNgtsSurfaceSampler(this.surfaceSamplerState, { injector });
1749
+ });
1750
+ }
1751
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsSampler, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1752
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.0", type: NgtsSampler, isStandalone: true, selector: "ngts-sampler", inputs: { samplerRef: "samplerRef", _count: ["count", "_count"], _mesh: ["mesh", "_mesh"], _transform: ["transform", "_transform"], _weight: ["weight", "_weight"], _instancedMesh: ["instancedMesh", "_instancedMesh"] }, ngImport: i0, template: `
1753
+ <ngt-group ngtCompound [ref]="samplerRef">
1754
+ <ng-content />
1755
+ </ngt-group>
1756
+ `, isInline: true }); }
1757
+ }
1758
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsSampler, decorators: [{
1759
+ type: Component,
1760
+ args: [{
1761
+ selector: 'ngts-sampler',
1762
+ standalone: true,
1763
+ template: `
1764
+ <ngt-group ngtCompound [ref]="samplerRef">
1765
+ <ng-content />
1766
+ </ngt-group>
1767
+ `,
1768
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
1769
+ }]
1770
+ }], ctorParameters: function () { return []; }, propDecorators: { samplerRef: [{
1771
+ type: Input
1772
+ }], _count: [{
1773
+ type: Input,
1774
+ args: [{ alias: 'count' }]
1775
+ }], _mesh: [{
1776
+ type: Input,
1777
+ args: [{ alias: 'mesh' }]
1778
+ }], _transform: [{
1779
+ type: Input,
1780
+ args: [{ alias: 'transform' }]
1781
+ }], _weight: [{
1782
+ type: Input,
1783
+ args: [{ alias: 'weight' }]
1784
+ }], _instancedMesh: [{
1785
+ type: Input,
1786
+ args: [{ alias: 'instancedMesh' }]
1787
+ }] } });
1788
+
1789
+ extend({ Mesh, CanvasTexture, PlaneGeometry, MeshBasicMaterial });
1790
+ class NgtsShadow {
1791
+ constructor() {
1792
+ this.Math = Math;
1793
+ this.DoubleSide = THREE.DoubleSide;
1794
+ this.inputs = signalStore({
1795
+ fog: false,
1796
+ depthWrite: false,
1797
+ colorStop: 0.0,
1798
+ color: 'black',
1799
+ opacity: 0.5,
1800
+ });
1801
+ this.shadowRef = injectNgtRef();
1802
+ this.colorStop = this.inputs.select('colorStop');
1803
+ this.color = this.inputs.select('color');
1804
+ this.opacity = this.inputs.select('opacity');
1805
+ this.fog = this.inputs.select('fog');
1806
+ this.depthWrite = this.inputs.select('depthWrite');
1807
+ this.canvas = computed(() => {
1808
+ const [colorStop, color] = [this.colorStop(), this.color()];
1809
+ const canvas = document.createElement('canvas');
1810
+ canvas.width = 128;
1811
+ canvas.height = 128;
1812
+ const context = canvas.getContext('2d');
1813
+ const gradient = context.createRadialGradient(canvas.width / 2, canvas.height / 2, 0, canvas.width / 2, canvas.height / 2, canvas.width / 2);
1814
+ gradient.addColorStop(colorStop, new THREE.Color(color).getStyle());
1815
+ gradient.addColorStop(1, 'rgba(0,0,0,0)');
1816
+ context.fillStyle = gradient;
1817
+ context.fillRect(0, 0, canvas.width, canvas.height);
1818
+ return canvas;
1819
+ });
1820
+ }
1821
+ set _colorStop(colorStop) {
1822
+ this.inputs.set({ colorStop });
1823
+ }
1824
+ set _fog(fog) {
1825
+ this.inputs.set({ fog });
1826
+ }
1827
+ set _color(color) {
1828
+ this.inputs.set({ color });
1829
+ }
1830
+ set _opacity(opacity) {
1831
+ this.inputs.set({ opacity });
1832
+ }
1833
+ set _depthWrite(depthWrite) {
1834
+ this.inputs.set({ depthWrite });
1835
+ }
1836
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsShadow, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1837
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.0", type: NgtsShadow, isStandalone: true, selector: "ngts-shadow", inputs: { shadowRef: "shadowRef", _colorStop: ["colorStop", "_colorStop"], _fog: ["fog", "_fog"], _color: ["color", "_color"], _opacity: ["opacity", "_opacity"], _depthWrite: ["depthWrite", "_depthWrite"] }, ngImport: i0, template: `
1838
+ <ngt-mesh ngtCompound [ref]="shadowRef" [rotation]="[-Math.PI / 2, 0, 0]">
1839
+ <ngt-plane-geometry />
1840
+ <ngt-mesh-basic-material
1841
+ [transparent]="true"
1842
+ [opacity]="opacity()"
1843
+ [fog]="fog()"
1844
+ [depthWrite]="depthWrite()"
1845
+ [side]="DoubleSide"
1846
+ >
1847
+ <ngt-canvas-texture *args="[canvas()]" attach="map" />
1848
+ </ngt-mesh-basic-material>
1849
+ <ng-content />
1850
+ </ngt-mesh>
1851
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }] }); }
1852
+ }
1853
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsShadow, decorators: [{
1854
+ type: Component,
1855
+ args: [{
1856
+ selector: 'ngts-shadow',
1857
+ standalone: true,
1858
+ template: `
1859
+ <ngt-mesh ngtCompound [ref]="shadowRef" [rotation]="[-Math.PI / 2, 0, 0]">
1860
+ <ngt-plane-geometry />
1861
+ <ngt-mesh-basic-material
1862
+ [transparent]="true"
1863
+ [opacity]="opacity()"
1864
+ [fog]="fog()"
1865
+ [depthWrite]="depthWrite()"
1866
+ [side]="DoubleSide"
1867
+ >
1868
+ <ngt-canvas-texture *args="[canvas()]" attach="map" />
1869
+ </ngt-mesh-basic-material>
1870
+ <ng-content />
1871
+ </ngt-mesh>
1872
+ `,
1873
+ imports: [NgtArgs],
1874
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
1875
+ }]
1876
+ }], propDecorators: { shadowRef: [{
1877
+ type: Input
1878
+ }], _colorStop: [{
1879
+ type: Input,
1880
+ args: [{ alias: 'colorStop' }]
1881
+ }], _fog: [{
1882
+ type: Input,
1883
+ args: [{ alias: 'fog' }]
1884
+ }], _color: [{
1885
+ type: Input,
1886
+ args: [{ alias: 'color' }]
1887
+ }], _opacity: [{
1888
+ type: Input,
1889
+ args: [{ alias: 'opacity' }]
1890
+ }], _depthWrite: [{
1891
+ type: Input,
1892
+ args: [{ alias: 'depthWrite' }]
1893
+ }] } });
1894
+
1895
+ class NgtsStatsGL {
1896
+ set _parent(parent) {
1897
+ this.inputs.set({ parent });
1898
+ }
1899
+ set _containerClass(containerClass) {
1900
+ this.inputs.set({ containerClass });
1901
+ }
1902
+ set _config(config) {
1903
+ this.inputs.set({ config });
1904
+ }
1905
+ constructor() {
1906
+ this.inputs = signalStore();
1907
+ this.document = inject(DOCUMENT);
1908
+ this.store = injectNgtStore();
1909
+ this.gl = this.store.select('gl');
1910
+ this.config = this.inputs.select('config');
1911
+ this.parent = this.inputs.select('parent');
1912
+ this.containerClass = this.inputs.select('containerClass');
1913
+ this.stats = computed(() => {
1914
+ const [config, gl] = [this.config() || {}, this.gl()];
1915
+ const stats = new Stats(config);
1916
+ stats.init(gl.domElement);
1917
+ return stats;
1918
+ });
1919
+ effect((onCleanup) => {
1920
+ const [parent, stats, containerClass] = [this.parent(), this.stats(), this.containerClass()];
1921
+ const node = parent ? (is.ref(parent) ? parent.nativeElement : parent) : this.document.body;
1922
+ node.appendChild(stats.container);
1923
+ if (containerClass)
1924
+ stats.container.classList.add(...containerClass.split(' ').filter(Boolean));
1925
+ const begin = addEffect(() => stats.begin());
1926
+ const end = addAfterEffect(() => stats.end());
1927
+ onCleanup(() => {
1928
+ node.removeChild(stats.container);
1929
+ begin();
1930
+ end();
1931
+ });
1932
+ });
1933
+ }
1934
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsStatsGL, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1935
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.0", type: NgtsStatsGL, isStandalone: true, selector: "ngts-stats-gl", inputs: { _parent: ["parent", "_parent"], _containerClass: ["containerClass", "_containerClass"], _config: ["config", "_config"] }, ngImport: i0 }); }
1936
+ }
1937
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsStatsGL, decorators: [{
1938
+ type: Directive,
1939
+ args: [{ selector: 'ngts-stats-gl', standalone: true }]
1940
+ }], ctorParameters: function () { return []; }, propDecorators: { _parent: [{
1941
+ type: Input,
1942
+ args: [{ alias: 'parent' }]
1943
+ }], _containerClass: [{
1944
+ type: Input,
1945
+ args: [{ alias: 'containerClass' }]
1946
+ }], _config: [{
1947
+ type: Input,
1948
+ args: [{ alias: 'config' }]
1949
+ }] } });
1950
+
1951
+ // default ease
1952
+ const easeCircleOut = (x) => Math.sqrt(1 - Math.pow(x - 1, 2));
1953
+ // smooth new sample (measurement) based on previous sample (current)
1954
+ function smoothAverage(current, measurement, smoothing = 0.9) {
1955
+ return measurement * smoothing + current * (1.0 - smoothing);
1956
+ }
1957
+ class TrailTexture {
1958
+ constructor({ size = 256, maxAge = 750, radius = 0.3, intensity = 0.2, interpolate = 0, smoothing = 0, minForce = 0.3, blend = 'screen', // source-over is canvas default. Others are slower
1959
+ ease = easeCircleOut, } = {}) {
1960
+ this.size = size;
1961
+ this.maxAge = maxAge;
1962
+ this.radius = radius;
1963
+ this.intensity = intensity;
1964
+ this.ease = ease;
1965
+ this.interpolate = interpolate;
1966
+ this.smoothing = smoothing;
1967
+ this.minForce = minForce;
1968
+ this.blend = blend;
1969
+ this.trail = [];
1970
+ this.force = 0;
1971
+ this.initTexture();
1972
+ }
1973
+ initTexture() {
1974
+ this.canvas = document.createElement('canvas');
1975
+ this.canvas.width = this.canvas.height = this.size;
1976
+ this.ctx = this.canvas.getContext('2d');
1977
+ this.ctx.fillStyle = 'black';
1978
+ this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
1979
+ this.texture = new Texture(this.canvas);
1980
+ this.canvas.id = 'touchTexture';
1981
+ this.canvas.style.width = this.canvas.style.height = `${this.canvas.width}px`;
1982
+ }
1983
+ update(delta) {
1984
+ this.clear();
1985
+ // age points
1986
+ this.trail.forEach((point, i) => {
1987
+ point.age += delta * 1000;
1988
+ // remove old
1989
+ if (point.age > this.maxAge) {
1990
+ this.trail.splice(i, 1);
1991
+ }
1992
+ });
1993
+ // reset force when empty (when smoothing)
1994
+ if (!this.trail.length)
1995
+ this.force = 0;
1996
+ this.trail.forEach((point) => {
1997
+ this.drawTouch(point);
1998
+ });
1999
+ this.texture.needsUpdate = true;
2000
+ }
2001
+ clear() {
2002
+ this.ctx.globalCompositeOperation = 'source-over';
2003
+ this.ctx.fillStyle = 'black';
2004
+ this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
2005
+ }
2006
+ addTouch(point) {
2007
+ const last = this.trail[this.trail.length - 1];
2008
+ if (last) {
2009
+ const dx = last.x - point.x;
2010
+ const dy = last.y - point.y;
2011
+ const dd = dx * dx + dy * dy;
2012
+ const force = Math.max(this.minForce, Math.min(dd * 10000, 1));
2013
+ this.force = smoothAverage(force, this.force, this.smoothing);
2014
+ if (!!this.interpolate) {
2015
+ const lines = Math.ceil(dd / Math.pow((this.radius * 0.5) / this.interpolate, 2));
2016
+ if (lines > 1) {
2017
+ for (let i = 1; i < lines; i++) {
2018
+ this.trail.push({
2019
+ x: last.x - (dx / lines) * i,
2020
+ y: last.y - (dy / lines) * i,
2021
+ age: 0,
2022
+ force,
2023
+ });
2024
+ }
2025
+ }
2026
+ }
2027
+ }
2028
+ this.trail.push({ x: point.x, y: point.y, age: 0, force: this.force });
2029
+ }
2030
+ drawTouch(point) {
2031
+ const pos = {
2032
+ x: point.x * this.size,
2033
+ y: (1 - point.y) * this.size,
2034
+ };
2035
+ let intensity = 1;
2036
+ if (point.age < this.maxAge * 0.3) {
2037
+ intensity = this.ease(point.age / (this.maxAge * 0.3));
2038
+ }
2039
+ else {
2040
+ intensity = this.ease(1 - (point.age - this.maxAge * 0.3) / (this.maxAge * 0.7));
139
2041
  }
2042
+ intensity *= point.force;
2043
+ // apply blending
2044
+ this.ctx.globalCompositeOperation = this.blend;
2045
+ const radius = this.size * this.radius * intensity;
2046
+ const grd = this.ctx.createRadialGradient(pos.x, pos.y, Math.max(0, radius * 0.25), pos.x, pos.y, Math.max(0, radius));
2047
+ grd.addColorStop(0, `rgba(255, 255, 255, ${this.intensity})`);
2048
+ grd.addColorStop(1, `rgba(0, 0, 0, 0.0)`);
2049
+ this.ctx.beginPath();
2050
+ this.ctx.fillStyle = grd;
2051
+ this.ctx.arc(pos.x, pos.y, Math.max(0, radius), 0, Math.PI * 2);
2052
+ this.ctx.fill();
2053
+ }
2054
+ }
2055
+
2056
+ function injectNgtsTrailTexture(trailConfigFn, { injector } = {}) {
2057
+ injector = assertInjectionContext(injectNgtsTrailTexture, injector);
2058
+ return runInInjectionContext(injector, () => {
2059
+ const config = computed(() => trailConfigFn() || {});
2060
+ const trail = computed(() => new TrailTexture(config()));
2061
+ const texture = computed(() => trail().texture);
2062
+ injectBeforeRender(({ delta }) => {
2063
+ trail().update(delta);
2064
+ });
2065
+ const onMove = (ev) => trail().addTouch(ev.uv);
2066
+ return { texture, onMove };
140
2067
  });
141
- fbo.$.pipe(takeUntil(destroy$)).subscribe((fbo) => {
142
- depthBufferRef.nativeElement = fbo.depthTexture;
2068
+ }
2069
+
2070
+ const shiftLeft = (collection, steps = 1) => {
2071
+ collection.set(collection.subarray(steps));
2072
+ collection.fill(-Infinity, -steps);
2073
+ return collection;
2074
+ };
2075
+ const defaultSettings = {
2076
+ width: 0.2,
2077
+ length: 1,
2078
+ decay: 1,
2079
+ local: false,
2080
+ stride: 0,
2081
+ interval: 1,
2082
+ };
2083
+ function injectNgtsTrail(targetFactory, settingsFactory, { injector } = {}) {
2084
+ injector = assertInjectionContext(injectNgtsTrail, injector);
2085
+ return runInInjectionContext(injector, () => {
2086
+ const points = injectNgtRef();
2087
+ let frameCount = 0;
2088
+ const prevPosition = new THREE.Vector3();
2089
+ const worldPosition = new THREE.Vector3();
2090
+ const _target = computed(() => {
2091
+ const _target = targetFactory();
2092
+ if (is.ref(_target))
2093
+ return _target.nativeElement;
2094
+ return _target;
2095
+ });
2096
+ const _settings = computed(() => ({ ...defaultSettings, ...settingsFactory() }));
2097
+ const _length = computed(() => _settings().length);
2098
+ effect(() => {
2099
+ const [target, length] = [_target(), _length()];
2100
+ if (target) {
2101
+ points.nativeElement = Float32Array.from({ length: length * 10 * 3 }, (_, i) => target.position.getComponent(i % 3));
2102
+ }
2103
+ });
2104
+ injectBeforeRender(() => {
2105
+ const [target, _points, { local, decay, stride, interval }] = [
2106
+ _target(),
2107
+ points.nativeElement,
2108
+ _settings(),
2109
+ ];
2110
+ if (!target)
2111
+ return;
2112
+ if (!_points)
2113
+ return;
2114
+ if (frameCount === 0) {
2115
+ let newPosition;
2116
+ if (local) {
2117
+ newPosition = target.position;
2118
+ }
2119
+ else {
2120
+ target.getWorldPosition(worldPosition);
2121
+ newPosition = worldPosition;
2122
+ }
2123
+ const steps = 1 * decay;
2124
+ for (let i = 0; i < steps; i++) {
2125
+ if (newPosition.distanceTo(prevPosition) < stride)
2126
+ continue;
2127
+ shiftLeft(_points, 3);
2128
+ _points.set(newPosition.toArray(), _points.length - 3);
2129
+ }
2130
+ prevPosition.copy(newPosition);
2131
+ }
2132
+ frameCount++;
2133
+ frameCount = frameCount % interval;
2134
+ });
2135
+ return points;
143
2136
  });
144
- return depthBufferRef;
145
2137
  }
2138
+ extend({ Group, Mesh });
2139
+ class NgtsTrail {
2140
+ set _color(color) {
2141
+ this.inputs.set({ color });
2142
+ }
2143
+ set _attenuation(attenuation) {
2144
+ this.inputs.set({ attenuation });
2145
+ }
2146
+ set _target(target) {
2147
+ this.inputs.set({ target });
2148
+ }
2149
+ set _settings(settings) {
2150
+ this.inputs.set({ settings: { ...defaultSettings, ...settings } });
2151
+ }
2152
+ constructor() {
2153
+ this.inputs = signalStore({ settings: defaultSettings, color: 'hotpink' });
2154
+ this.trailRef = injectNgtRef();
2155
+ this.groupRef = injectNgtRef();
2156
+ this.children = this.groupRef.children('both');
2157
+ this.store = injectNgtStore();
2158
+ this.size = this.store.select('size');
2159
+ this.target = this.inputs.select('target');
2160
+ this.settings = this.inputs.select('settings');
2161
+ this.width = computed(() => this.settings().width);
2162
+ this.color = this.inputs.select('color');
2163
+ this.attenuation = this.inputs.select('attenuation');
2164
+ this.anchor = computed(() => {
2165
+ const target = this.target();
2166
+ if (target)
2167
+ return target;
2168
+ const group = this.groupRef.nativeElement;
2169
+ if (group) {
2170
+ return group.children.find((child) => child instanceof THREE.Object3D) || null;
2171
+ }
2172
+ return null;
2173
+ });
2174
+ this.points = injectNgtsTrail(this.anchor, this.settings);
2175
+ this.scene = this.store.select('scene');
2176
+ this.geometry = new MeshLineGeometry();
2177
+ this.material = computed(() => {
2178
+ const [width, color, size] = [this.width(), this.color(), this.size()];
2179
+ const m = new MeshLineMaterial({
2180
+ lineWidth: 0.1 * width,
2181
+ color,
2182
+ sizeAttenuation: 1,
2183
+ resolution: new THREE.Vector2(size.width, size.height),
2184
+ });
2185
+ // TODO: understand this first
2186
+ // Get and apply first <meshLineMaterial /> from children
2187
+ // let matOverride: React.ReactElement | undefined;
2188
+ // if (children) {
2189
+ // if (Array.isArray(children)) {
2190
+ // matOverride = children.find((child: React.ReactNode) => {
2191
+ // const c = child as React.ReactElement;
2192
+ // return typeof c.type === 'string' && c.type === 'meshLineMaterial';
2193
+ // }) as React.ReactElement | undefined;
2194
+ // } else {
2195
+ // const c = children as React.ReactElement;
2196
+ // if (typeof c.type === 'string' && c.type === 'meshLineMaterial') {
2197
+ // matOverride = c;
2198
+ // }
2199
+ // }
2200
+ // }
2201
+ // if (typeof matOverride?.props === 'object') {
2202
+ // m.setValues(matOverride.props);
2203
+ // }
2204
+ return m;
2205
+ });
2206
+ this.setMaterialSize();
2207
+ this.beforeRender();
2208
+ }
2209
+ setMaterialSize() {
2210
+ effect(() => {
2211
+ const [material, size] = [this.material(), this.size()];
2212
+ material.uniforms['resolution'].value.set(size.width, size.height);
2213
+ });
2214
+ }
2215
+ beforeRender() {
2216
+ injectBeforeRender(() => {
2217
+ const [points, attenuation] = [this.points.nativeElement, this.attenuation()];
2218
+ if (!points)
2219
+ return;
2220
+ this.geometry.setPoints(points, attenuation);
2221
+ });
2222
+ }
2223
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsTrail, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2224
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.0", type: NgtsTrail, isStandalone: true, selector: "ngts-trail", inputs: { trailRef: "trailRef", _color: ["color", "_color"], _attenuation: ["attenuation", "_attenuation"], _target: ["target", "_target"], _settings: ["settings", "_settings"] }, ngImport: i0, template: `
2225
+ <ngt-group>
2226
+ <ngt-portal [container]="scene()" [autoRender]="false">
2227
+ <ng-template ngtPortalContent>
2228
+ <ngt-mesh [ref]="trailRef" [geometry]="geometry" [material]="material()" />
2229
+ </ng-template>
2230
+ </ngt-portal>
2231
+ <ngt-group [ref]="groupRef">
2232
+ <ng-content />
2233
+ </ngt-group>
2234
+ </ngt-group>
2235
+ `, 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]" }] }); }
2236
+ }
2237
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: NgtsTrail, decorators: [{
2238
+ type: Component,
2239
+ args: [{
2240
+ selector: 'ngts-trail',
2241
+ standalone: true,
2242
+ template: `
2243
+ <ngt-group>
2244
+ <ngt-portal [container]="scene()" [autoRender]="false">
2245
+ <ng-template ngtPortalContent>
2246
+ <ngt-mesh [ref]="trailRef" [geometry]="geometry" [material]="material()" />
2247
+ </ng-template>
2248
+ </ngt-portal>
2249
+ <ngt-group [ref]="groupRef">
2250
+ <ng-content />
2251
+ </ngt-group>
2252
+ </ngt-group>
2253
+ `,
2254
+ imports: [NgtPortal, NgtPortalContent],
2255
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
2256
+ }]
2257
+ }], ctorParameters: function () { return []; }, propDecorators: { trailRef: [{
2258
+ type: Input
2259
+ }], _color: [{
2260
+ type: Input,
2261
+ args: [{ alias: 'color' }]
2262
+ }], _attenuation: [{
2263
+ type: Input,
2264
+ args: [{ alias: 'attenuation' }]
2265
+ }], _target: [{
2266
+ type: Input,
2267
+ args: [{ alias: 'target' }]
2268
+ }], _settings: [{
2269
+ type: Input,
2270
+ args: [{ alias: 'settings' }]
2271
+ }] } });
146
2272
 
147
2273
  /**
148
2274
  * Generated bundle index. Do not edit.
149
2275
  */
150
2276
 
151
- export { NgtsBakeShadows, injectNgtsAnimations, injectNgtsDepthBuffer, injectNgtsFBO };
2277
+ export { NgtsBakeShadows, NgtsCaustics, NgtsDecal, NgtsExample, NgtsHtml, NgtsSampler, NgtsShadow, NgtsStatsGL, NgtsTrail, injectNgtsAnimations, injectNgtsDepthBuffer, injectNgtsExampleApi, injectNgtsFBO, injectNgtsHtmlInputs, injectNgtsSurfaceSampler, injectNgtsTrail, injectNgtsTrailTexture, provideNgtsExampleApi, provideNgtsHtmlInputs };
152
2278
  //# sourceMappingURL=angular-three-soba-misc.mjs.map