angular-three-soba 2.0.0-beta.21 → 2.0.0-beta.224

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