angular-three-soba 2.0.0-beta.8 → 2.0.0

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 (423) hide show
  1. package/README.md +62 -4
  2. package/abstractions/README.md +279 -2
  3. package/abstractions/index.d.ts +13 -6
  4. package/abstractions/lib/billboard.d.ts +19 -0
  5. package/abstractions/lib/catmull-rom-line.d.ts +617 -0
  6. package/abstractions/lib/cubic-bezier-line.d.ts +19 -0
  7. package/abstractions/lib/edges.d.ts +800 -0
  8. package/abstractions/lib/gradient-texture.d.ts +24 -0
  9. package/abstractions/lib/grid.d.ts +315 -0
  10. package/abstractions/lib/helper.d.ts +25 -0
  11. package/abstractions/lib/line.d.ts +41 -0
  12. package/abstractions/lib/prism-geometry.d.ts +32 -0
  13. package/abstractions/lib/quadratic-bezier-line.d.ts +21 -0
  14. package/abstractions/lib/rounded-box.d.ts +41 -0
  15. package/abstractions/lib/text-3d.d.ts +314 -0
  16. package/abstractions/lib/text.d.ts +54 -0
  17. package/cameras/README.md +91 -2
  18. package/cameras/index.d.ts +4 -4
  19. package/cameras/lib/camera-content.d.ts +10 -0
  20. package/cameras/lib/cube-camera.d.ts +38 -0
  21. package/cameras/lib/orthographic-camera.d.ts +40 -0
  22. package/cameras/lib/perspective-camera.d.ts +36 -0
  23. package/controls/README.md +96 -2
  24. package/controls/index.d.ts +4 -1
  25. package/controls/lib/camera-controls.d.ts +31 -0
  26. package/controls/lib/orbit-controls.d.ts +38 -0
  27. package/controls/lib/pivot-controls/axis-arrow.d.ts +31 -0
  28. package/controls/lib/pivot-controls/axis-rotator.d.ts +30 -0
  29. package/controls/lib/pivot-controls/pivot-controls.d.ts +110 -0
  30. package/controls/lib/pivot-controls/plane-slider.d.ts +32 -0
  31. package/controls/lib/pivot-controls/scaling-sphere.d.ts +32 -0
  32. package/controls/lib/scroll-controls.d.ts +78 -0
  33. package/esm2022/abstractions/index.mjs +14 -7
  34. package/esm2022/abstractions/lib/billboard.mjs +69 -0
  35. package/esm2022/abstractions/lib/catmull-rom-line.mjs +76 -0
  36. package/esm2022/abstractions/lib/cubic-bezier-line.mjs +51 -0
  37. package/esm2022/abstractions/lib/edges.mjs +70 -0
  38. package/esm2022/abstractions/lib/gradient-texture.mjs +91 -0
  39. package/esm2022/abstractions/lib/grid.mjs +103 -0
  40. package/esm2022/abstractions/lib/helper.mjs +76 -0
  41. package/esm2022/abstractions/lib/line.mjs +126 -0
  42. package/esm2022/abstractions/lib/prism-geometry.mjs +46 -0
  43. package/esm2022/abstractions/lib/quadratic-bezier-line.mjs +73 -0
  44. package/esm2022/abstractions/lib/rounded-box.mjs +111 -0
  45. package/esm2022/abstractions/lib/text-3d.mjs +98 -0
  46. package/esm2022/abstractions/lib/text.mjs +91 -0
  47. package/esm2022/cameras/index.mjs +5 -5
  48. package/esm2022/cameras/lib/camera-content.mjs +14 -0
  49. package/esm2022/cameras/lib/cube-camera.mjs +111 -0
  50. package/esm2022/cameras/lib/orthographic-camera.mjs +131 -0
  51. package/esm2022/cameras/lib/perspective-camera.mjs +104 -0
  52. package/esm2022/controls/index.mjs +5 -2
  53. package/esm2022/controls/lib/camera-controls.mjs +127 -0
  54. package/esm2022/controls/lib/orbit-controls.mjs +132 -0
  55. package/esm2022/controls/lib/pivot-controls/axis-arrow.mjs +263 -0
  56. package/esm2022/controls/lib/pivot-controls/axis-rotator.mjs +264 -0
  57. package/esm2022/controls/lib/pivot-controls/pivot-controls.mjs +340 -0
  58. package/esm2022/controls/lib/pivot-controls/plane-slider.mjs +266 -0
  59. package/esm2022/controls/lib/pivot-controls/scaling-sphere.mjs +232 -0
  60. package/esm2022/controls/lib/scroll-controls.mjs +268 -0
  61. package/esm2022/loaders/index.mjs +6 -5
  62. package/esm2022/loaders/lib/font-loader.mjs +49 -0
  63. package/esm2022/loaders/lib/gltf-loader.mjs +51 -0
  64. package/esm2022/loaders/lib/loader.mjs +109 -0
  65. package/esm2022/loaders/lib/progress.mjs +51 -0
  66. package/esm2022/loaders/lib/texture-loader.mjs +32 -0
  67. package/esm2022/materials/index.mjs +8 -7
  68. package/esm2022/materials/lib/custom-shader-material.mjs +71 -0
  69. package/esm2022/materials/lib/mesh-distort-material.mjs +42 -0
  70. package/esm2022/materials/lib/mesh-reflector-material.mjs +278 -0
  71. package/esm2022/materials/lib/mesh-refraction-material.mjs +144 -0
  72. package/esm2022/materials/lib/mesh-transmission-material.mjs +188 -0
  73. package/esm2022/materials/lib/mesh-wobble-material.mjs +42 -0
  74. package/esm2022/materials/lib/point-material.mjs +33 -0
  75. package/esm2022/misc/index.mjs +14 -14
  76. package/esm2022/misc/lib/animations.mjs +71 -0
  77. package/esm2022/misc/lib/bake-shadows.mjs +26 -0
  78. package/esm2022/misc/lib/computed-attribute.mjs +55 -0
  79. package/esm2022/misc/lib/constants.mjs +5 -0
  80. package/esm2022/misc/lib/decal.mjs +139 -0
  81. package/esm2022/misc/lib/deprecated.mjs +15 -0
  82. package/esm2022/misc/lib/depth-buffer.mjs +39 -0
  83. package/esm2022/misc/lib/fbo.mjs +86 -0
  84. package/esm2022/misc/lib/html/html-content.mjs +327 -0
  85. package/esm2022/misc/lib/html/html.mjs +129 -0
  86. package/esm2022/misc/lib/html/utils.mjs +74 -0
  87. package/esm2022/misc/lib/intersect.mjs +52 -0
  88. package/esm2022/misc/lib/sampler.mjs +122 -0
  89. package/esm2022/misc/lib/scale-factor.mjs +29 -0
  90. package/esm2022/performances/index.mjs +7 -6
  91. package/esm2022/performances/lib/adaptive-dpr.mjs +52 -0
  92. package/esm2022/performances/lib/adaptive-events.mjs +28 -0
  93. package/esm2022/performances/lib/detailed.mjs +57 -0
  94. package/esm2022/performances/lib/instances/instances.mjs +183 -0
  95. package/esm2022/performances/lib/instances/position-mesh.mjs +51 -0
  96. package/esm2022/performances/lib/points/points.mjs +278 -0
  97. package/esm2022/performances/lib/points/position-point.mjs +53 -0
  98. package/esm2022/performances/lib/segments/segment-object.mjs +9 -0
  99. package/esm2022/performances/lib/segments/segments.mjs +129 -0
  100. package/esm2022/shaders/index.mjs +4 -18
  101. package/esm2022/shaders/lib/grid-material.mjs +81 -0
  102. package/esm2022/shaders/lib/mesh-refraction-material.mjs +163 -0
  103. package/esm2022/shaders/lib/point-material.mjs +24 -0
  104. package/esm2022/staging/index.mjs +19 -22
  105. package/esm2022/staging/lib/accumulative-shadows.mjs +182 -0
  106. package/esm2022/staging/lib/backdrop.mjs +73 -0
  107. package/esm2022/staging/lib/bb-anchor.mjs +58 -0
  108. package/esm2022/staging/lib/bounds.mjs +286 -0
  109. package/esm2022/staging/lib/camera-shake.mjs +69 -0
  110. package/esm2022/staging/lib/caustics.mjs +188 -0
  111. package/esm2022/staging/lib/center.mjs +118 -0
  112. package/esm2022/staging/lib/contact-shadows.mjs +214 -0
  113. package/esm2022/staging/lib/environment.mjs +481 -0
  114. package/esm2022/staging/lib/float.mjs +70 -0
  115. package/esm2022/staging/lib/lightformer.mjs +107 -0
  116. package/esm2022/staging/lib/matcap-texture.mjs +81 -0
  117. package/esm2022/staging/lib/normal-texture.mjs +81 -0
  118. package/esm2022/staging/lib/randomized-lights.mjs +104 -0
  119. package/esm2022/staging/lib/render-texture.mjs +203 -0
  120. package/esm2022/staging/lib/sky.mjs +86 -0
  121. package/esm2022/staging/lib/spot-light.mjs +453 -0
  122. package/esm2022/staging/lib/stage.mjs +236 -0
  123. package/esm2022/{utils/angular-three-soba-utils.mjs → stats/angular-three-soba-stats.mjs} +1 -1
  124. package/esm2022/stats/index.mjs +2 -0
  125. package/esm2022/stats/lib/stats.mjs +63 -0
  126. package/esm2022/vanilla-exports/angular-three-soba-vanilla-exports.mjs +5 -0
  127. package/esm2022/vanilla-exports/index.mjs +3 -0
  128. package/fesm2022/angular-three-soba-abstractions.mjs +884 -697
  129. package/fesm2022/angular-three-soba-abstractions.mjs.map +1 -1
  130. package/fesm2022/angular-three-soba-cameras.mjs +261 -308
  131. package/fesm2022/angular-three-soba-cameras.mjs.map +1 -1
  132. package/fesm2022/angular-three-soba-controls.mjs +1776 -109
  133. package/fesm2022/angular-three-soba-controls.mjs.map +1 -1
  134. package/fesm2022/angular-three-soba-loaders.mjs +191 -145
  135. package/fesm2022/angular-three-soba-loaders.mjs.map +1 -1
  136. package/fesm2022/angular-three-soba-materials.mjs +527 -748
  137. package/fesm2022/angular-three-soba-materials.mjs.map +1 -1
  138. package/fesm2022/angular-three-soba-misc.mjs +783 -1935
  139. package/fesm2022/angular-three-soba-misc.mjs.map +1 -1
  140. package/fesm2022/angular-three-soba-performances.mjs +591 -475
  141. package/fesm2022/angular-three-soba-performances.mjs.map +1 -1
  142. package/fesm2022/angular-three-soba-shaders.mjs +51 -1369
  143. package/fesm2022/angular-three-soba-shaders.mjs.map +1 -1
  144. package/fesm2022/angular-three-soba-staging.mjs +2350 -3521
  145. package/fesm2022/angular-three-soba-staging.mjs.map +1 -1
  146. package/fesm2022/angular-three-soba-stats.mjs +70 -0
  147. package/fesm2022/angular-three-soba-stats.mjs.map +1 -0
  148. package/fesm2022/angular-three-soba-vanilla-exports.mjs +6 -0
  149. package/fesm2022/angular-three-soba-vanilla-exports.mjs.map +1 -0
  150. package/loaders/README.md +130 -2
  151. package/loaders/index.d.ts +5 -4
  152. package/loaders/lib/font-loader.d.ts +27 -0
  153. package/loaders/lib/gltf-loader.d.ts +24 -0
  154. package/loaders/lib/loader.d.ts +29 -0
  155. package/loaders/lib/progress.d.ts +9 -0
  156. package/loaders/lib/texture-loader.d.ts +13 -0
  157. package/materials/README.md +160 -2
  158. package/materials/index.d.ts +7 -6
  159. package/materials/lib/custom-shader-material.d.ts +20 -0
  160. package/materials/lib/mesh-distort-material.d.ts +17 -0
  161. package/materials/lib/mesh-reflector-material.d.ts +51 -0
  162. package/materials/lib/mesh-refraction-material.d.ts +42 -0
  163. package/materials/lib/mesh-transmission-material.d.ts +77 -0
  164. package/materials/lib/mesh-wobble-material.d.ts +15 -0
  165. package/materials/lib/point-material.d.ts +11 -0
  166. package/metadata.json +1 -1
  167. package/misc/README.md +217 -2
  168. package/misc/index.d.ts +13 -13
  169. package/misc/lib/animations.d.ts +17 -0
  170. package/misc/lib/computed-attribute.d.ts +64 -0
  171. package/misc/lib/constants.d.ts +1 -0
  172. package/misc/lib/decal.d.ts +27 -0
  173. package/misc/lib/deprecated.d.ts +14 -0
  174. package/misc/lib/depth-buffer.d.ts +8 -0
  175. package/misc/lib/fbo.d.ts +46 -0
  176. package/misc/lib/html/html-content.d.ts +47 -0
  177. package/misc/lib/html/html.d.ts +30 -0
  178. package/misc/lib/html/utils.d.ts +14 -0
  179. package/misc/lib/intersect.d.ts +13 -0
  180. package/misc/lib/sampler.d.ts +73 -0
  181. package/misc/lib/scale-factor.d.ts +3 -0
  182. package/package.json +89 -48
  183. package/performances/index.d.ts +6 -5
  184. package/performances/lib/adaptive-dpr.d.ts +7 -0
  185. package/performances/{adaptive-events → lib}/adaptive-events.d.ts +0 -3
  186. package/performances/lib/detailed.d.ts +17 -0
  187. package/performances/lib/instances/instances.d.ts +122 -0
  188. package/performances/lib/instances/position-mesh.d.ts +20 -0
  189. package/performances/lib/points/points.d.ts +224 -0
  190. package/performances/lib/points/position-point.d.ts +21 -0
  191. package/performances/lib/segments/segment-object.d.ts +17 -0
  192. package/performances/lib/segments/segments.d.ts +97 -0
  193. package/shaders/index.d.ts +3 -17
  194. package/shaders/lib/grid-material.d.ts +69 -0
  195. package/shaders/lib/mesh-refraction-material.d.ts +11 -0
  196. package/shaders/lib/point-material.d.ts +14 -0
  197. package/staging/README.md +473 -2
  198. package/staging/index.d.ts +18 -21
  199. package/staging/lib/accumulative-shadows.d.ts +75 -0
  200. package/staging/lib/backdrop.d.ts +22 -0
  201. package/staging/lib/bb-anchor.d.ts +17 -0
  202. package/staging/lib/bounds.d.ts +47 -0
  203. package/staging/lib/camera-shake.d.ts +29 -0
  204. package/staging/lib/caustics.d.ts +53 -0
  205. package/staging/lib/center.d.ts +390 -0
  206. package/staging/lib/contact-shadows.d.ts +55 -0
  207. package/staging/lib/environment.d.ts +132 -0
  208. package/staging/lib/float.d.ts +20 -0
  209. package/staging/lib/lightformer.d.ts +310 -0
  210. package/staging/lib/matcap-texture.d.ts +32 -0
  211. package/staging/lib/normal-texture.d.ts +37 -0
  212. package/staging/lib/randomized-lights.d.ts +54 -0
  213. package/staging/lib/render-texture.d.ts +64 -0
  214. package/staging/lib/sky.d.ts +32 -0
  215. package/staging/lib/spot-light.d.ts +119 -0
  216. package/staging/lib/stage.d.ts +352 -0
  217. package/stats/README.md +3 -0
  218. package/stats/index.d.ts +1 -0
  219. package/stats/lib/stats.d.ts +14 -0
  220. package/vanilla-exports/README.md +3 -0
  221. package/vanilla-exports/index.d.ts +27 -0
  222. package/web-types.json +1 -1
  223. package/abstractions/billboard/billboard.d.ts +0 -28
  224. package/abstractions/detailed/detailed.d.ts +0 -26
  225. package/abstractions/edges/edges.d.ts +0 -34
  226. package/abstractions/grid/grid.d.ts +0 -50
  227. package/abstractions/text/text.d.ts +0 -82
  228. package/abstractions/text-3d/text-3d.d.ts +0 -81
  229. package/assets/distort.vert.glsl +0 -1
  230. package/cameras/camera/camera-content.d.ts +0 -13
  231. package/cameras/camera/camera.d.ts +0 -26
  232. package/cameras/cube-camera/cube-camera.d.ts +0 -69
  233. package/cameras/orthographic-camera/orthographic-camera.d.ts +0 -37
  234. package/cameras/perspective-camera/perspective-camera.d.ts +0 -18
  235. package/controls/orbit-controls/orbit-controls.d.ts +0 -54
  236. package/esm2022/abstractions/billboard/billboard.mjs +0 -74
  237. package/esm2022/abstractions/detailed/detailed.mjs +0 -64
  238. package/esm2022/abstractions/edges/edges.mjs +0 -88
  239. package/esm2022/abstractions/grid/grid.mjs +0 -180
  240. package/esm2022/abstractions/text/text.mjs +0 -274
  241. package/esm2022/abstractions/text-3d/text-3d.mjs +0 -165
  242. package/esm2022/cameras/camera/camera-content.mjs +0 -20
  243. package/esm2022/cameras/camera/camera.mjs +0 -77
  244. package/esm2022/cameras/cube-camera/cube-camera.mjs +0 -161
  245. package/esm2022/cameras/orthographic-camera/orthographic-camera.mjs +0 -102
  246. package/esm2022/cameras/perspective-camera/perspective-camera.mjs +0 -46
  247. package/esm2022/controls/orbit-controls/orbit-controls.mjs +0 -181
  248. package/esm2022/loaders/gltf-loader/gltf-loader.mjs +0 -30
  249. package/esm2022/loaders/loader/loader.mjs +0 -138
  250. package/esm2022/loaders/progress/progress.mjs +0 -45
  251. package/esm2022/loaders/texture-loader/texture-loader.mjs +0 -28
  252. package/esm2022/materials/mesh-distort-material/mesh-distort-material.mjs +0 -82
  253. package/esm2022/materials/mesh-reflector-material/mesh-reflector-material.mjs +0 -367
  254. package/esm2022/materials/mesh-refraction-material/mesh-refraction-material.mjs +0 -171
  255. package/esm2022/materials/mesh-transmission-material/mesh-transmission-material.mjs +0 -278
  256. package/esm2022/materials/mesh-wobble-material/mesh-wobble-material.mjs +0 -68
  257. package/esm2022/materials/point-material/point-material.mjs +0 -46
  258. package/esm2022/misc/animations/animations.mjs +0 -59
  259. package/esm2022/misc/bake-shadows/bake-shadows.mjs +0 -24
  260. package/esm2022/misc/caustics/caustics.mjs +0 -387
  261. package/esm2022/misc/decal/decal.mjs +0 -187
  262. package/esm2022/misc/depth-buffer/depth-buffer.mjs +0 -44
  263. package/esm2022/misc/example/example.mjs +0 -160
  264. package/esm2022/misc/fbo/fbo.mjs +0 -47
  265. package/esm2022/misc/html/html-wrapper.mjs +0 -478
  266. package/esm2022/misc/html/html.mjs +0 -304
  267. package/esm2022/misc/sampler/sampler.mjs +0 -142
  268. package/esm2022/misc/shadow/shadow.mjs +0 -111
  269. package/esm2022/misc/stats-gl/stats-gl.mjs +0 -61
  270. package/esm2022/misc/trail/trail.mjs +0 -209
  271. package/esm2022/misc/trail-texture/inject-trail-texture.mjs +0 -17
  272. package/esm2022/misc/trail-texture/trail-texture.mjs +0 -106
  273. package/esm2022/modifiers/angular-three-soba-modifiers.mjs +0 -5
  274. package/esm2022/modifiers/curve-modifier/curve-modifier.mjs +0 -64
  275. package/esm2022/modifiers/index.mjs +0 -2
  276. package/esm2022/performances/adaptive-dpr/adaptive-dpr.mjs +0 -44
  277. package/esm2022/performances/adaptive-events/adaptive-events.mjs +0 -27
  278. package/esm2022/performances/points/points-input.mjs +0 -64
  279. package/esm2022/performances/points/points.mjs +0 -329
  280. package/esm2022/performances/points/position-point.mjs +0 -54
  281. package/esm2022/performances/segments/segment-object.mjs +0 -9
  282. package/esm2022/performances/segments/segments.mjs +0 -182
  283. package/esm2022/shaders/blur-pass/blur-pass.mjs +0 -61
  284. package/esm2022/shaders/caustics/caustics-material.mjs +0 -130
  285. package/esm2022/shaders/caustics/caustics-projection-material.mjs +0 -31
  286. package/esm2022/shaders/convolution-material/convolution-material.mjs +0 -94
  287. package/esm2022/shaders/discard-material/discard-material.mjs +0 -3
  288. package/esm2022/shaders/grid-material/grid-material.mjs +0 -77
  289. package/esm2022/shaders/mesh-distort-material/mesh-distort-material.mjs +0 -56
  290. package/esm2022/shaders/mesh-reflector-material/mesh-reflector-material.mjs +0 -223
  291. package/esm2022/shaders/mesh-refraction-material/mesh-refraction-material.mjs +0 -170
  292. package/esm2022/shaders/mesh-transmission-material/mesh-transmission-material.mjs +0 -268
  293. package/esm2022/shaders/mesh-wobble-material/mesh-wobble-material.mjs +0 -37
  294. package/esm2022/shaders/shader-material/shader-material.mjs +0 -34
  295. package/esm2022/shaders/soft-shadow-material/soft-shadow-material.mjs +0 -25
  296. package/esm2022/shaders/sparkles-material/sparkles-material.mjs +0 -33
  297. package/esm2022/shaders/spot-light-material/spot-light-material.mjs +0 -86
  298. package/esm2022/shaders/star-field-material/star-field-material.mjs +0 -33
  299. package/esm2022/shaders/wireframe-material/wireframe-material.mjs +0 -247
  300. package/esm2022/staging/accumulative-shadows/accumulative-shadows.mjs +0 -267
  301. package/esm2022/staging/accumulative-shadows/progressive-light-map.mjs +0 -108
  302. package/esm2022/staging/accumulative-shadows/randomized-lights.mjs +0 -206
  303. package/esm2022/staging/backdrop/backdrop.mjs +0 -77
  304. package/esm2022/staging/bb-anchor/bb-anchor.mjs +0 -70
  305. package/esm2022/staging/bounds/bounds.mjs +0 -308
  306. package/esm2022/staging/camera-shake/camera-shake.mjs +0 -123
  307. package/esm2022/staging/center/center.mjs +0 -163
  308. package/esm2022/staging/cloud/cloud.mjs +0 -158
  309. package/esm2022/staging/contact-shadows/contact-shadows.mjs +0 -246
  310. package/esm2022/staging/environment/assets.mjs +0 -13
  311. package/esm2022/staging/environment/environment-cube.mjs +0 -47
  312. package/esm2022/staging/environment/environment-ground.mjs +0 -41
  313. package/esm2022/staging/environment/environment-input.mjs +0 -119
  314. package/esm2022/staging/environment/environment-map.mjs +0 -53
  315. package/esm2022/staging/environment/environment-portal.mjs +0 -113
  316. package/esm2022/staging/environment/environment.mjs +0 -61
  317. package/esm2022/staging/environment/utils.mjs +0 -105
  318. package/esm2022/staging/float/float.mjs +0 -94
  319. package/esm2022/staging/matcap-texture/matcap-texture.mjs +0 -64
  320. package/esm2022/staging/normal-texture/normal-texture.mjs +0 -53
  321. package/esm2022/staging/sky/sky.mjs +0 -119
  322. package/esm2022/staging/sparkles/sparkles.mjs +0 -164
  323. package/esm2022/staging/spot-light/shadow-mesh-input.mjs +0 -63
  324. package/esm2022/staging/spot-light/shadow-mesh.mjs +0 -266
  325. package/esm2022/staging/spot-light/spot-light-input.mjs +0 -84
  326. package/esm2022/staging/spot-light/spot-light.mjs +0 -81
  327. package/esm2022/staging/spot-light/volumetric-mesh.mjs +0 -98
  328. package/esm2022/staging/stage/stage.mjs +0 -388
  329. package/esm2022/staging/stars/stars.mjs +0 -147
  330. package/esm2022/staging/wireframe/wireframe-input.mjs +0 -191
  331. package/esm2022/staging/wireframe/wireframe.mjs +0 -224
  332. package/esm2022/utils/content/content.mjs +0 -15
  333. package/esm2022/utils/index.mjs +0 -2
  334. package/fesm2022/angular-three-soba-modifiers.mjs +0 -71
  335. package/fesm2022/angular-three-soba-modifiers.mjs.map +0 -1
  336. package/fesm2022/angular-three-soba-utils.mjs +0 -22
  337. package/fesm2022/angular-three-soba-utils.mjs.map +0 -1
  338. package/loaders/gltf-loader/gltf-loader.d.ts +0 -10
  339. package/loaders/loader/loader.d.ts +0 -33
  340. package/loaders/progress/progress.d.ts +0 -9
  341. package/loaders/texture-loader/texture-loader.d.ts +0 -7
  342. package/materials/mesh-distort-material/mesh-distort-material.d.ts +0 -40
  343. package/materials/mesh-reflector-material/mesh-reflector-material.d.ts +0 -99
  344. package/materials/mesh-refraction-material/mesh-refraction-material.d.ts +0 -62
  345. package/materials/mesh-transmission-material/mesh-transmission-material.d.ts +0 -107
  346. package/materials/mesh-wobble-material/mesh-wobble-material.d.ts +0 -29
  347. package/materials/point-material/point-material.d.ts +0 -24
  348. package/misc/animations/animations.d.ts +0 -15
  349. package/misc/caustics/caustics.d.ts +0 -87
  350. package/misc/decal/decal.d.ts +0 -49
  351. package/misc/depth-buffer/depth-buffer.d.ts +0 -9
  352. package/misc/example/example.d.ts +0 -81
  353. package/misc/fbo/fbo.d.ts +0 -17
  354. package/misc/html/html-wrapper.d.ts +0 -559
  355. package/misc/html/html.d.ts +0 -214
  356. package/misc/sampler/sampler.d.ts +0 -67
  357. package/misc/shadow/shadow.d.ts +0 -37
  358. package/misc/stats-gl/stats-gl.d.ts +0 -24
  359. package/misc/trail/trail.d.ts +0 -57
  360. package/misc/trail-texture/inject-trail-texture.d.ts +0 -9
  361. package/misc/trail-texture/trail-texture.d.ts +0 -50
  362. package/modifiers/README.md +0 -3
  363. package/modifiers/curve-modifier/curve-modifier.d.ts +0 -23
  364. package/modifiers/index.d.ts +0 -1
  365. package/performances/adaptive-dpr/adaptive-dpr.d.ts +0 -14
  366. package/performances/points/points-input.d.ts +0 -32
  367. package/performances/points/points.d.ts +0 -92
  368. package/performances/points/position-point.d.ts +0 -11
  369. package/performances/segments/segment-object.d.ts +0 -7
  370. package/performances/segments/segments.d.ts +0 -124
  371. package/shaders/blur-pass/blur-pass.d.ts +0 -23
  372. package/shaders/caustics/caustics-material.d.ts +0 -4
  373. package/shaders/caustics/caustics-projection-material.d.ts +0 -4
  374. package/shaders/convolution-material/convolution-material.d.ts +0 -7
  375. package/shaders/discard-material/discard-material.d.ts +0 -3
  376. package/shaders/grid-material/grid-material.d.ts +0 -37
  377. package/shaders/mesh-distort-material/mesh-distort-material.d.ts +0 -295
  378. package/shaders/mesh-reflector-material/mesh-reflector-material.d.ts +0 -50
  379. package/shaders/mesh-refraction-material/mesh-refraction-material.d.ts +0 -4
  380. package/shaders/mesh-transmission-material/mesh-transmission-material.d.ts +0 -25
  381. package/shaders/mesh-wobble-material/mesh-wobble-material.d.ts +0 -16
  382. package/shaders/shader-material/shader-material.d.ts +0 -6
  383. package/shaders/soft-shadow-material/soft-shadow-material.d.ts +0 -19
  384. package/shaders/sparkles-material/sparkles-material.d.ts +0 -17
  385. package/shaders/spot-light-material/spot-light-material.d.ts +0 -13
  386. package/shaders/star-field-material/star-field-material.d.ts +0 -13
  387. package/shaders/wireframe-material/wireframe-material.d.ts +0 -58
  388. package/staging/accumulative-shadows/accumulative-shadows.d.ts +0 -146
  389. package/staging/accumulative-shadows/progressive-light-map.d.ts +0 -34
  390. package/staging/accumulative-shadows/randomized-lights.d.ts +0 -90
  391. package/staging/backdrop/backdrop.d.ts +0 -30
  392. package/staging/bb-anchor/bb-anchor.d.ts +0 -27
  393. package/staging/bounds/bounds.d.ts +0 -134
  394. package/staging/camera-shake/camera-shake.d.ts +0 -43
  395. package/staging/center/center.d.ts +0 -70
  396. package/staging/cloud/cloud.d.ts +0 -51
  397. package/staging/contact-shadows/contact-shadows.d.ts +0 -70
  398. package/staging/environment/assets.d.ts +0 -13
  399. package/staging/environment/environment-cube.d.ts +0 -15
  400. package/staging/environment/environment-ground.d.ts +0 -13
  401. package/staging/environment/environment-input.d.ts +0 -68
  402. package/staging/environment/environment-map.d.ts +0 -16
  403. package/staging/environment/environment-portal.d.ts +0 -18
  404. package/staging/environment/environment.d.ts +0 -8
  405. package/staging/environment/utils.d.ts +0 -7
  406. package/staging/float/float.d.ts +0 -31
  407. package/staging/matcap-texture/matcap-texture.d.ts +0 -13
  408. package/staging/normal-texture/normal-texture.d.ts +0 -16
  409. package/staging/sky/sky.d.ts +0 -48
  410. package/staging/sparkles/sparkles.d.ts +0 -63
  411. package/staging/spot-light/shadow-mesh-input.d.ts +0 -29
  412. package/staging/spot-light/shadow-mesh.d.ts +0 -37
  413. package/staging/spot-light/spot-light-input.d.ts +0 -38
  414. package/staging/spot-light/spot-light.d.ts +0 -39
  415. package/staging/spot-light/volumetric-mesh.d.ts +0 -24
  416. package/staging/stage/stage.d.ts +0 -130
  417. package/staging/stars/stars.d.ts +0 -45
  418. package/staging/wireframe/wireframe-input.d.ts +0 -65
  419. package/staging/wireframe/wireframe.d.ts +0 -28
  420. package/utils/README.md +0 -3
  421. package/utils/content/content.d.ts +0 -8
  422. package/utils/index.d.ts +0 -1
  423. /package/misc/{bake-shadows → lib}/bake-shadows.d.ts +0 -0
@@ -1,83 +1,182 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, computed, effect, Component, CUSTOM_ELEMENTS_SCHEMA, Input, Output } from '@angular/core';
3
- import { signalStore, injectNgtRef, injectNgtStore, injectBeforeRender, NgtArgs } from 'angular-three';
2
+ import { input, output, computed, effect, Component, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, viewChild, ElementRef, inject, signal, afterNextRender, model, untracked, Directive } from '@angular/core';
3
+ import { omit, injectStore, pick, extend, injectBeforeRender, NgtArgs, getLocalState, NgtHTML, provideHTMLDomElement } from 'angular-three';
4
+ import CameraControls from 'camera-controls';
5
+ import { mergeInputs } from 'ngxtension/inject-inputs';
6
+ import { Box3, MathUtils, Matrix4, Quaternion, Raycaster, Sphere, Spherical, Vector2, Vector3, Vector4, DoubleSide, Group, Mesh, ConeGeometry, CylinderGeometry, MeshBasicMaterial, Ray, Plane, PlaneGeometry, SphereGeometry } from 'three';
4
7
  import { OrbitControls } from 'three-stdlib';
8
+ import { NgtsHTML, NgtsHTMLContent, calculateScaleFactor } from 'angular-three-soba/misc';
9
+ import { injectAutoEffect } from 'ngxtension/auto-effect';
10
+ import { NgtsLine } from 'angular-three-soba/abstractions';
11
+ import { DOCUMENT } from '@angular/common';
12
+ import { easing } from 'maath';
5
13
 
6
- class NgtsOrbitControls {
7
- set _camera(camera) {
8
- this.inputs.set({ camera });
9
- }
10
- set _domElement(domElement) {
11
- this.inputs.set({ domElement });
12
- }
13
- set _makeDefault(makeDefault) {
14
- this.inputs.set({ makeDefault });
15
- }
16
- set _regress(regress) {
17
- this.inputs.set({ regress });
18
- }
19
- set _target(target) {
20
- this.inputs.set({ target });
21
- }
22
- set _enableDamping(enableDamping) {
23
- this.inputs.set({ enableDamping });
24
- }
25
- set _keyEvents(keyEvents) {
26
- this.inputs.set({ keyEvents });
14
+ const defaultOptions$3 = {
15
+ makeDefault: false,
16
+ events: false,
17
+ regress: false,
18
+ };
19
+ class NgtsCameraControls {
20
+ constructor() {
21
+ this.options = input(defaultOptions$3, { transform: mergeInputs(defaultOptions$3) });
22
+ this.parameters = omit(this.options, ['makeDefault', 'camera', 'regress', 'domElement']);
23
+ this.changed = output();
24
+ this.started = output();
25
+ this.ended = output();
26
+ this.store = injectStore();
27
+ this.invalidate = this.store.select('invalidate');
28
+ this.performanceRegress = this.store.select('performance', 'regress');
29
+ this.defaultCamera = this.store.select('camera');
30
+ this.glDomElement = this.store.select('gl', 'domElement');
31
+ this.eventsElement = this.store.select('events', 'connected');
32
+ this.camera = pick(this.options, 'camera');
33
+ this.regress = pick(this.options, 'regress');
34
+ this.domElement = pick(this.options, 'domElement');
35
+ this.makeDefault = pick(this.options, 'makeDefault');
36
+ this.controls = computed(() => {
37
+ const [camera, defaultCamera] = [this.camera(), this.defaultCamera()];
38
+ return new CameraControls(camera || defaultCamera);
39
+ });
40
+ // to allow for tree shaking, we only import the subset of THREE that is used by camera-controls
41
+ // see https://github.com/yomotsu/camera-controls#important
42
+ CameraControls.install({
43
+ THREE: {
44
+ Box3,
45
+ MathUtils: { clamp: MathUtils.clamp },
46
+ Matrix4,
47
+ Quaternion,
48
+ Raycaster,
49
+ Sphere,
50
+ Spherical,
51
+ Vector2,
52
+ Vector3,
53
+ Vector4,
54
+ },
55
+ });
56
+ extend({ CameraControls });
57
+ injectBeforeRender(({ delta }) => {
58
+ const controls = this.controls();
59
+ if (controls?.enabled) {
60
+ controls.update(delta);
61
+ }
62
+ }, { priority: -1 });
63
+ effect((onCleanup) => {
64
+ const [domElement, eventsElement, glDomElement, controls] = [
65
+ this.domElement(),
66
+ this.eventsElement(),
67
+ this.glDomElement(),
68
+ this.controls(),
69
+ ];
70
+ controls.connect(domElement || eventsElement || glDomElement);
71
+ onCleanup(() => controls.disconnect());
72
+ });
73
+ effect((onCleanup) => {
74
+ const [controls, regress, performanceRegress, invalidate] = [
75
+ this.controls(),
76
+ this.regress(),
77
+ this.performanceRegress(),
78
+ this.invalidate(),
79
+ ];
80
+ const callback = (e) => {
81
+ invalidate();
82
+ if (regress)
83
+ performanceRegress();
84
+ this.changed.emit(e);
85
+ };
86
+ const startCallback = this.started.emit.bind(this.started);
87
+ const endCallback = this.ended.emit.bind(this.ended);
88
+ controls.addEventListener('update', callback);
89
+ controls.addEventListener('controlstart', startCallback);
90
+ controls.addEventListener('controlend', endCallback);
91
+ controls.addEventListener('control', callback);
92
+ controls.addEventListener('transitionstart', callback);
93
+ controls.addEventListener('wake', callback);
94
+ onCleanup(() => {
95
+ controls.removeEventListener('update', callback);
96
+ controls.removeEventListener('controlstart', startCallback);
97
+ controls.removeEventListener('controlend', endCallback);
98
+ controls.removeEventListener('control', callback);
99
+ controls.removeEventListener('transitionstart', callback);
100
+ controls.removeEventListener('wake', callback);
101
+ });
102
+ });
103
+ effect((onCleanup) => {
104
+ const [controls, makeDefault] = [this.controls(), this.makeDefault()];
105
+ if (makeDefault) {
106
+ const oldControls = this.store.snapshot.controls;
107
+ this.store.update({ controls: controls });
108
+ onCleanup(() => void this.store.update({ controls: oldControls }));
109
+ }
110
+ });
27
111
  }
112
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsCameraControls, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
113
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.0", type: NgtsCameraControls, isStandalone: true, selector: "ngts-camera-controls", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { changed: "changed", started: "started", ended: "ended" }, ngImport: i0, template: `
114
+ <ngt-primitive *args="[controls()]" [parameters]="parameters()">
115
+ <ng-content />
116
+ </ngt-primitive>
117
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
118
+ }
119
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsCameraControls, decorators: [{
120
+ type: Component,
121
+ args: [{
122
+ selector: 'ngts-camera-controls',
123
+ standalone: true,
124
+ template: `
125
+ <ngt-primitive *args="[controls()]" [parameters]="parameters()">
126
+ <ng-content />
127
+ </ngt-primitive>
128
+ `,
129
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
130
+ imports: [NgtArgs],
131
+ changeDetection: ChangeDetectionStrategy.OnPush,
132
+ }]
133
+ }], ctorParameters: () => [] });
134
+
135
+ const defaultOptions$2 = {
136
+ enableDamping: true,
137
+ regress: false,
138
+ makeDefault: false,
139
+ keyEvents: false,
140
+ };
141
+ class NgtsOrbitControls {
28
142
  constructor() {
29
- this.inputs = signalStore({
30
- enableDamping: true,
31
- regress: false,
32
- makeDefault: false,
33
- keyEvents: false,
34
- });
35
- this.controlsRef = injectNgtRef();
36
- this.change = new EventEmitter();
37
- this.start = new EventEmitter();
38
- this.end = new EventEmitter();
39
- this.store = injectNgtStore();
143
+ this.options = input(defaultOptions$2, { transform: mergeInputs(defaultOptions$2) });
144
+ this.parameters = omit(this.options, ['makeDefault', 'camera', 'regress', 'domElement', 'keyEvents', 'enableDamping']);
145
+ this.changed = output();
146
+ this.started = output();
147
+ this.ended = output();
148
+ this.store = injectStore();
40
149
  this.invalidate = this.store.select('invalidate');
41
150
  this.performanceRegress = this.store.select('performance', 'regress');
42
151
  this.defaultCamera = this.store.select('camera');
43
152
  this.glDomElement = this.store.select('gl', 'domElement');
44
- this.regress = this.inputs.select('regress');
45
- this.camera = this.inputs.select('camera');
46
- this.domElement = this.inputs.select('domElement');
47
- this.keyEvents = this.inputs.select('keyEvents');
48
- this.makeDefault = this.inputs.select('makeDefault');
49
- this.args = computed(() => [this.controlsRef.nativeElement]);
50
- this.enableDamping = this.inputs.select('enableDamping');
153
+ this.camera = pick(this.options, 'camera');
154
+ this.regress = pick(this.options, 'regress');
155
+ this.keyEvents = pick(this.options, 'keyEvents');
156
+ this.domElement = pick(this.options, 'domElement');
157
+ this.makeDefault = pick(this.options, 'makeDefault');
158
+ this.controls = computed(() => {
159
+ const [camera, defaultCamera] = [this.camera(), this.defaultCamera()];
160
+ const controlsCamera = camera || defaultCamera;
161
+ return new OrbitControls(controlsCamera);
162
+ });
163
+ this.enableDamping = pick(this.options, 'enableDamping');
51
164
  injectBeforeRender(() => {
52
- const controls = this.controlsRef.nativeElement;
53
- if (controls && controls.enabled) {
165
+ const controls = this.controls();
166
+ if (controls?.enabled) {
54
167
  controls.update();
55
168
  }
56
169
  }, { priority: -1 });
57
- this.setControls();
58
170
  this.connectElement();
59
171
  this.makeControlsDefault();
60
172
  this.setEvents();
61
173
  }
62
- setControls() {
63
- effect(() => {
64
- const [camera, defaultCamera, controls] = [
65
- this.camera(),
66
- this.defaultCamera(),
67
- this.controlsRef.nativeElement,
68
- ];
69
- const controlsCamera = camera || defaultCamera;
70
- if (!controls || controls.object !== controlsCamera) {
71
- this.controlsRef.nativeElement = new OrbitControls(controlsCamera);
72
- }
73
- });
74
- }
75
174
  connectElement() {
76
175
  effect((onCleanup) => {
77
176
  const [keyEvents, domElement, controls] = [
78
177
  this.keyEvents(),
79
178
  this.domElement() || this.store.get('events', 'connected') || this.glDomElement(),
80
- this.controlsRef.nativeElement,
179
+ this.controls(),
81
180
  this.invalidate(),
82
181
  this.regress(),
83
182
  ];
@@ -94,20 +193,20 @@ class NgtsOrbitControls {
94
193
  }
95
194
  makeControlsDefault() {
96
195
  effect((onCleanup) => {
97
- const [controls, makeDefault] = [this.controlsRef.nativeElement, this.makeDefault()];
196
+ const [controls, makeDefault] = [this.controls(), this.makeDefault()];
98
197
  if (!controls)
99
198
  return;
100
199
  if (makeDefault) {
101
200
  const oldControls = this.store.get('controls');
102
- this.store.set({ controls });
103
- onCleanup(() => void this.store.set({ controls: oldControls }));
201
+ this.store.update({ controls });
202
+ onCleanup(() => void this.store.update({ controls: oldControls }));
104
203
  }
105
204
  });
106
205
  }
107
206
  setEvents() {
108
207
  effect((onCleanup) => {
109
208
  const [controls, invalidate, performanceRegress, regress] = [
110
- this.controlsRef.nativeElement,
209
+ this.controls(),
111
210
  this.invalidate(),
112
211
  this.performanceRegress(),
113
212
  this.regress(),
@@ -118,71 +217,1639 @@ class NgtsOrbitControls {
118
217
  invalidate();
119
218
  if (regress)
120
219
  performanceRegress();
121
- if (this.change.observed)
122
- this.change.emit(e);
220
+ this.changed.emit(e);
123
221
  };
124
- const startCallback = this.start.observed ? this.start.emit.bind(this.start) : null;
125
- const endCallback = this.end.observed ? this.end.emit.bind(this.end) : null;
222
+ const startCallback = this.started.emit.bind(this.started);
223
+ const endCallback = this.ended.emit.bind(this.ended);
224
+ // @ts-expect-error - type error from three-stdlib
126
225
  controls.addEventListener('change', changeCallback);
127
- if (startCallback)
128
- controls.addEventListener('start', startCallback);
129
- if (endCallback)
130
- controls.addEventListener('end', endCallback);
226
+ // @ts-expect-error - type error from three-stdlib
227
+ controls.addEventListener('start', startCallback);
228
+ // @ts-expect-error - type error from three-stdlib
229
+ controls.addEventListener('end', endCallback);
131
230
  onCleanup(() => {
231
+ // @ts-expect-error - type error from three-stdlib
132
232
  controls.removeEventListener('change', changeCallback);
133
- if (startCallback)
134
- controls.removeEventListener('start', startCallback);
135
- if (endCallback)
136
- controls.removeEventListener('end', endCallback);
233
+ // @ts-expect-error - type error from three-stdlib
234
+ controls.removeEventListener('start', startCallback);
235
+ // @ts-expect-error - type error from three-stdlib
236
+ controls.removeEventListener('end', endCallback);
137
237
  });
138
238
  });
139
239
  }
140
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: NgtsOrbitControls, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
141
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: NgtsOrbitControls, isStandalone: true, selector: "ngts-orbit-controls", inputs: { controlsRef: "controlsRef", _camera: ["camera", "_camera"], _domElement: ["domElement", "_domElement"], _makeDefault: ["makeDefault", "_makeDefault"], _regress: ["regress", "_regress"], _target: ["target", "_target"], _enableDamping: ["enableDamping", "_enableDamping"], _keyEvents: ["keyEvents", "_keyEvents"] }, outputs: { change: "change", start: "start", end: "end" }, ngImport: i0, template: ` <ngt-primitive *args="args()" ngtCompound [enableDamping]="enableDamping()" /> `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }] }); }
240
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsOrbitControls, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
241
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.0", type: NgtsOrbitControls, isStandalone: true, selector: "ngts-orbit-controls", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { changed: "changed", started: "started", ended: "ended" }, ngImport: i0, template: `
242
+ <ngt-primitive *args="[controls()]" [parameters]="parameters()" [enableDamping]="enableDamping()">
243
+ <ng-content />
244
+ </ngt-primitive>
245
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }] }); }
142
246
  }
143
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: NgtsOrbitControls, decorators: [{
247
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsOrbitControls, decorators: [{
144
248
  type: Component,
145
249
  args: [{
146
250
  selector: 'ngts-orbit-controls',
147
251
  standalone: true,
148
- template: ` <ngt-primitive *args="args()" ngtCompound [enableDamping]="enableDamping()" /> `,
252
+ template: `
253
+ <ngt-primitive *args="[controls()]" [parameters]="parameters()" [enableDamping]="enableDamping()">
254
+ <ng-content />
255
+ </ngt-primitive>
256
+ `,
149
257
  imports: [NgtArgs],
150
258
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
151
259
  }]
152
- }], ctorParameters: function () { return []; }, propDecorators: { controlsRef: [{
153
- type: Input
154
- }], _camera: [{
155
- type: Input,
156
- args: [{ alias: 'camera' }]
157
- }], _domElement: [{
158
- type: Input,
159
- args: [{ alias: 'domElement' }]
160
- }], _makeDefault: [{
161
- type: Input,
162
- args: [{ alias: 'makeDefault' }]
163
- }], _regress: [{
164
- type: Input,
165
- args: [{ alias: 'regress' }]
166
- }], _target: [{
167
- type: Input,
168
- args: [{ alias: 'target' }]
169
- }], _enableDamping: [{
170
- type: Input,
171
- args: [{ alias: 'enableDamping' }]
172
- }], _keyEvents: [{
173
- type: Input,
174
- args: [{ alias: 'keyEvents' }]
175
- }], change: [{
176
- type: Output
177
- }], start: [{
178
- type: Output
179
- }], end: [{
180
- type: Output
181
- }] } });
260
+ }], ctorParameters: () => [] });
261
+
262
+ const vec1$1 = new Vector3();
263
+ const vec2$1 = new Vector3();
264
+ function calculateOffset$1(clickPoint, normal, rayStart, rayDir) {
265
+ const e1 = normal.dot(normal);
266
+ const e2 = normal.dot(clickPoint) - normal.dot(rayStart);
267
+ const e3 = normal.dot(rayDir);
268
+ if (e3 === 0) {
269
+ return -e2 / e1;
270
+ }
271
+ vec1$1
272
+ .copy(rayDir)
273
+ .multiplyScalar(e1 / e3)
274
+ .sub(normal);
275
+ vec2$1
276
+ .copy(rayDir)
277
+ .multiplyScalar(e2 / e3)
278
+ .add(rayStart)
279
+ .sub(clickPoint);
280
+ return -vec1$1.dot(vec2$1) / vec1$1.dot(vec1$1);
281
+ }
282
+ const upV$1 = new Vector3(0, 1, 0);
283
+ const offsetMatrix$1 = new Matrix4();
284
+ class NgtsAxisArrow {
285
+ constructor() {
286
+ this.DoubleSide = DoubleSide;
287
+ this.direction = input.required();
288
+ this.axis = input.required();
289
+ this.groupRef = viewChild.required('group');
290
+ this.annotationRef = viewChild('annotation', { read: ElementRef });
291
+ this.pivotControls = inject(NgtsPivotControls);
292
+ this.store = injectStore();
293
+ this.controls = this.store.select('controls');
294
+ this.hovered = signal(false);
295
+ this.clickInfo = null;
296
+ this.offset0 = 0;
297
+ this.color = computed(() => this.hovered() ? this.pivotControls.hoveredColor() : this.pivotControls.axisColors()[this.axis()]);
298
+ this.coneWidth = computed(() => this.pivotControls.fixed()
299
+ ? (this.pivotControls.lineWidth() / this.pivotControls.scale()) * 1.6
300
+ : this.pivotControls.scale() / 20);
301
+ this.coneLength = computed(() => (this.pivotControls.fixed() ? 0.2 : this.pivotControls.scale() / 5));
302
+ this.cylinderLength = computed(() => this.pivotControls.fixed() ? 1 - this.coneLength() : this.pivotControls.scale() - this.coneLength());
303
+ this.matrixL = computed(() => {
304
+ const quaternion = new Quaternion().setFromUnitVectors(upV$1, this.direction().clone().normalize());
305
+ return new Matrix4().makeRotationFromQuaternion(quaternion);
306
+ });
307
+ extend({ Group, Mesh, ConeGeometry, CylinderGeometry, MeshBasicMaterial });
308
+ }
309
+ onPointerDown(event) {
310
+ const [group, direction, axis, controls, annotation] = [
311
+ this.groupRef().nativeElement,
312
+ this.direction(),
313
+ this.axis(),
314
+ this.controls(),
315
+ this.annotationRef()?.nativeElement,
316
+ ];
317
+ if (annotation) {
318
+ annotation.innerText = `${this.pivotControls.translation[axis].toFixed(2)}`;
319
+ annotation.style.display = 'block';
320
+ }
321
+ event.stopPropagation();
322
+ const rotation = new Matrix4().extractRotation(group.matrixWorld);
323
+ const origin = new Vector3().setFromMatrixPosition(group.matrixWorld);
324
+ const clickPoint = event.point.clone();
325
+ const dir = direction.clone().applyMatrix4(rotation).normalize();
326
+ this.clickInfo = { clickPoint, dir };
327
+ this.offset0 = this.pivotControls.translation[axis];
328
+ this.pivotControls.onDragStart({ component: 'Arrow', axis, origin, directions: [dir] });
329
+ if (controls) {
330
+ controls.enabled = false;
331
+ }
332
+ // @ts-expect-error - setPointerCapture is not in the type definition
333
+ event.target.setPointerCapture(event.pointerId);
334
+ }
335
+ onPointerUp(event) {
336
+ const [annotation, controls] = [this.annotationRef()?.nativeElement, this.controls()];
337
+ if (annotation) {
338
+ annotation.style.display = 'none';
339
+ }
340
+ event.stopPropagation();
341
+ this.clickInfo = null;
342
+ this.pivotControls.onDragEnd();
343
+ if (controls) {
344
+ controls.enabled = true;
345
+ }
346
+ // @ts-expect-error - setPointerCapture is not in the type definition
347
+ event.target.releasePointerCapture(event.pointerId);
348
+ }
349
+ onPointerMove(event) {
350
+ event.stopPropagation();
351
+ if (!this.hovered()) {
352
+ this.hovered.set(true);
353
+ }
354
+ if (this.clickInfo) {
355
+ const { clickPoint, dir } = this.clickInfo;
356
+ const [translationLimits, annotation, axis] = [
357
+ this.pivotControls.translationLimits(),
358
+ this.annotationRef()?.nativeElement,
359
+ this.axis(),
360
+ ];
361
+ const [min, max] = translationLimits?.[axis] || [undefined, undefined];
362
+ let offset = calculateOffset$1(clickPoint, dir, event.ray.origin, event.ray.direction);
363
+ if (min !== undefined) {
364
+ offset = Math.max(offset, min - this.offset0);
365
+ }
366
+ if (max !== undefined) {
367
+ offset = Math.min(offset, max - this.offset0);
368
+ }
369
+ this.pivotControls.translation[axis] = this.offset0 + offset;
370
+ if (annotation) {
371
+ annotation.innerText = `${this.pivotControls.translation[axis].toFixed(2)}`;
372
+ }
373
+ offsetMatrix$1.makeTranslation(dir.x * offset, dir.y * offset, dir.z * offset);
374
+ this.pivotControls.onDrag(offsetMatrix$1);
375
+ }
376
+ }
377
+ onPointerOut(event) {
378
+ event.stopPropagation();
379
+ this.hovered.set(false);
380
+ }
381
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsAxisArrow, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
382
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: NgtsAxisArrow, isStandalone: true, selector: "ngts-axis-arrow", inputs: { direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: true, transformFunction: null }, axis: { classPropertyName: "axis", publicName: "axis", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "groupRef", first: true, predicate: ["group"], descendants: true, isSignal: true }, { propertyName: "annotationRef", first: true, predicate: ["annotation"], descendants: true, read: ElementRef, isSignal: true }], ngImport: i0, template: `
383
+ <ngt-group #group>
384
+ <ngt-group
385
+ [matrix]="matrixL()"
386
+ [matrixAutoUpdate]="false"
387
+ (pointerdown)="onPointerDown($any($event))"
388
+ (pointerup)="onPointerUp($any($event))"
389
+ (pointermove)="onPointerMove($any($event))"
390
+ (pointerout)="onPointerOut($any($event))"
391
+ >
392
+ @if (pivotControls.annotations()) {
393
+ <ngts-html [options]="{ position: [0, -coneLength(), 0] }">
394
+ <div
395
+ #annotation
396
+ ngtsHTMLContent
397
+ style="display: none; background: #151520; color: white; padding: 6px 8px; border-radius: 7px; white-space: nowrap;"
398
+ [class]="pivotControls.annotationsClass()"
399
+ ></div>
400
+ </ngts-html>
401
+ }
402
+ <ngt-mesh
403
+ [visible]="false"
404
+ [position]="[0, (cylinderLength() + coneLength()) / 2.0, 0]"
405
+ [userData]="pivotControls.userData()"
406
+ >
407
+ <ngt-cylinder-geometry
408
+ *args="[coneWidth() * 1.4, coneWidth() * 1.4, cylinderLength() + coneLength(), 8, 1]"
409
+ />
410
+ </ngt-mesh>
411
+
412
+ <ngts-line
413
+ [points]="[0, 0, 0, 0, cylinderLength(), 0]"
414
+ [options]="{
415
+ raycast: null,
416
+ side: DoubleSide,
417
+ polygonOffset: true,
418
+ polygonOffsetFactor: -10,
419
+ renderOrder: 1,
420
+ fog: false,
421
+ transparent: true,
422
+ lineWidth: pivotControls.lineWidth(),
423
+ color: color(),
424
+ opacity: pivotControls.opacity(),
425
+ depthTest: pivotControls.depthTest(),
426
+ }"
427
+ />
428
+
429
+ <ngt-mesh [raycast]="null" [position]="[0, cylinderLength() + coneLength() / 2.0, 0]" [renderOrder]="500">
430
+ <ngt-cone-geometry *args="[coneWidth(), coneLength(), 24, 1]" />
431
+ <ngt-mesh-basic-material
432
+ [transparent]="true"
433
+ [depthTest]="pivotControls.depthTest()"
434
+ [color]="color()"
435
+ [opacity]="pivotControls.opacity()"
436
+ [polygonOffset]="true"
437
+ [polygonOffsetFactor]="-10"
438
+ [fog]="false"
439
+ />
440
+ </ngt-mesh>
441
+ </ngt-group>
442
+ </ngt-group>
443
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }, { kind: "component", type: NgtsLine, selector: "ngts-line", inputs: ["points", "options"] }, { kind: "component", type: NgtsHTML, selector: "ngts-html", inputs: ["options"] }, { kind: "component", type: NgtsHTMLContent, selector: "[ngtsHTMLContent]", inputs: ["ngtsHTMLContent"], outputs: ["occluded"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
444
+ }
445
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsAxisArrow, decorators: [{
446
+ type: Component,
447
+ args: [{
448
+ selector: 'ngts-axis-arrow',
449
+ standalone: true,
450
+ template: `
451
+ <ngt-group #group>
452
+ <ngt-group
453
+ [matrix]="matrixL()"
454
+ [matrixAutoUpdate]="false"
455
+ (pointerdown)="onPointerDown($any($event))"
456
+ (pointerup)="onPointerUp($any($event))"
457
+ (pointermove)="onPointerMove($any($event))"
458
+ (pointerout)="onPointerOut($any($event))"
459
+ >
460
+ @if (pivotControls.annotations()) {
461
+ <ngts-html [options]="{ position: [0, -coneLength(), 0] }">
462
+ <div
463
+ #annotation
464
+ ngtsHTMLContent
465
+ style="display: none; background: #151520; color: white; padding: 6px 8px; border-radius: 7px; white-space: nowrap;"
466
+ [class]="pivotControls.annotationsClass()"
467
+ ></div>
468
+ </ngts-html>
469
+ }
470
+ <ngt-mesh
471
+ [visible]="false"
472
+ [position]="[0, (cylinderLength() + coneLength()) / 2.0, 0]"
473
+ [userData]="pivotControls.userData()"
474
+ >
475
+ <ngt-cylinder-geometry
476
+ *args="[coneWidth() * 1.4, coneWidth() * 1.4, cylinderLength() + coneLength(), 8, 1]"
477
+ />
478
+ </ngt-mesh>
479
+
480
+ <ngts-line
481
+ [points]="[0, 0, 0, 0, cylinderLength(), 0]"
482
+ [options]="{
483
+ raycast: null,
484
+ side: DoubleSide,
485
+ polygonOffset: true,
486
+ polygonOffsetFactor: -10,
487
+ renderOrder: 1,
488
+ fog: false,
489
+ transparent: true,
490
+ lineWidth: pivotControls.lineWidth(),
491
+ color: color(),
492
+ opacity: pivotControls.opacity(),
493
+ depthTest: pivotControls.depthTest(),
494
+ }"
495
+ />
496
+
497
+ <ngt-mesh [raycast]="null" [position]="[0, cylinderLength() + coneLength() / 2.0, 0]" [renderOrder]="500">
498
+ <ngt-cone-geometry *args="[coneWidth(), coneLength(), 24, 1]" />
499
+ <ngt-mesh-basic-material
500
+ [transparent]="true"
501
+ [depthTest]="pivotControls.depthTest()"
502
+ [color]="color()"
503
+ [opacity]="pivotControls.opacity()"
504
+ [polygonOffset]="true"
505
+ [polygonOffsetFactor]="-10"
506
+ [fog]="false"
507
+ />
508
+ </ngt-mesh>
509
+ </ngt-group>
510
+ </ngt-group>
511
+ `,
512
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
513
+ changeDetection: ChangeDetectionStrategy.OnPush,
514
+ imports: [NgtArgs, NgtsLine, NgtsHTML, NgtsHTMLContent],
515
+ }]
516
+ }], ctorParameters: () => [] });
517
+
518
+ const clickDir = new Vector3();
519
+ const intersectionDir = new Vector3();
520
+ function toDegrees(radians) {
521
+ return (radians * 180) / Math.PI;
522
+ }
523
+ function toRadians(degrees) {
524
+ return (degrees * Math.PI) / 180;
525
+ }
526
+ function calculateAngle(clickPoint, intersectionPoint, origin, e1, e2) {
527
+ clickDir.copy(clickPoint).sub(origin);
528
+ intersectionDir.copy(intersectionPoint).sub(origin);
529
+ const dote1e1 = e1.dot(e1);
530
+ const dote2e2 = e2.dot(e2);
531
+ const uClick = clickDir.dot(e1) / dote1e1;
532
+ const vClick = clickDir.dot(e2) / dote2e2;
533
+ const uIntersection = intersectionDir.dot(e1) / dote1e1;
534
+ const vIntersection = intersectionDir.dot(e2) / dote2e2;
535
+ const angleClick = Math.atan2(vClick, uClick);
536
+ const angleIntersection = Math.atan2(vIntersection, uIntersection);
537
+ return angleIntersection - angleClick;
538
+ }
539
+ function fmod(num, denom) {
540
+ let k = Math.floor(num / denom);
541
+ k = k < 0 ? k + 1 : k;
542
+ return num - k * denom;
543
+ }
544
+ function minimizeAngle(angle) {
545
+ let result = fmod(angle, 2 * Math.PI);
546
+ if (Math.abs(result) < 1e-6) {
547
+ return 0.0;
548
+ }
549
+ if (result < 0.0) {
550
+ result += 2 * Math.PI;
551
+ }
552
+ return result;
553
+ }
554
+ const rotMatrix = new Matrix4();
555
+ const posNew = new Vector3();
556
+ const ray$1 = new Ray();
557
+ const intersection$1 = new Vector3();
558
+ class NgtsAxisRotator {
559
+ constructor() {
560
+ this.DoubleSide = DoubleSide;
561
+ this.dir1 = input.required();
562
+ this.dir2 = input.required();
563
+ this.axis = input.required();
564
+ this.groupRef = viewChild.required('group');
565
+ this.annotationRef = viewChild('annotation', { read: ElementRef });
566
+ this.pivotControls = inject(NgtsPivotControls);
567
+ this.store = injectStore();
568
+ this.controls = this.store.select('controls');
569
+ this.hovered = signal(false);
570
+ this.angle = 0;
571
+ this.angle0 = 0;
572
+ this.clickInfo = null;
573
+ this.matrixL = computed(() => {
574
+ const dir1N = this.dir1().clone().normalize();
575
+ const dir2N = this.dir2().clone().normalize();
576
+ return new Matrix4().makeBasis(dir1N, dir2N, dir1N.clone().cross(dir2N));
577
+ });
578
+ this.r = computed(() => (this.pivotControls.fixed() ? 0.65 : this.pivotControls.scale() * 0.65));
579
+ this.arc = computed(() => {
580
+ const segments = 32;
581
+ const points = [];
582
+ for (let j = 0; j <= segments; j++) {
583
+ const angle = (j * (Math.PI / 2)) / segments;
584
+ points.push(new Vector3(Math.cos(angle) * this.r(), Math.sin(angle) * this.r(), 0));
585
+ }
586
+ return points;
587
+ });
588
+ extend({ Group });
589
+ }
590
+ onPointerDown(event) {
591
+ const [annotation, group, axis, controls] = [
592
+ this.annotationRef()?.nativeElement,
593
+ this.groupRef().nativeElement,
594
+ this.axis(),
595
+ this.controls(),
596
+ ];
597
+ if (annotation) {
598
+ annotation.innerText = `${toDegrees(this.angle).toFixed(0)}º`;
599
+ annotation.style.display = 'block';
600
+ }
601
+ event.stopPropagation();
602
+ const clickPoint = event.point.clone();
603
+ const origin = new Vector3().setFromMatrixPosition(group.matrixWorld);
604
+ const e1 = new Vector3().setFromMatrixColumn(group.matrixWorld, 0).normalize();
605
+ const e2 = new Vector3().setFromMatrixColumn(group.matrixWorld, 1).normalize();
606
+ const normal = new Vector3().setFromMatrixColumn(group.matrixWorld, 2).normalize();
607
+ const plane = new Plane().setFromNormalAndCoplanarPoint(normal, origin);
608
+ this.clickInfo = { clickPoint, origin, e1, e2, normal, plane };
609
+ this.pivotControls.onDragStart({ component: 'Rotator', axis, origin, directions: [e1, e2, normal] });
610
+ if (controls) {
611
+ controls.enabled = false;
612
+ }
613
+ // @ts-expect-error - setPointerCapture is not a function on PointerEvent
614
+ event.target.setPointerCapture(event.pointerId);
615
+ }
616
+ onPointerMove(event) {
617
+ event.stopPropagation();
618
+ if (!this.hovered())
619
+ this.hovered.set(true);
620
+ if (this.clickInfo) {
621
+ const { clickPoint, origin, e1, e2, normal, plane } = this.clickInfo;
622
+ const [rotationLimits, axis, annotation] = [
623
+ this.pivotControls.rotationLimits(),
624
+ this.axis(),
625
+ this.annotationRef()?.nativeElement,
626
+ ];
627
+ const [min, max] = rotationLimits?.[axis] || [undefined, undefined];
628
+ ray$1.copy(event.ray);
629
+ ray$1.intersectPlane(plane, intersection$1);
630
+ ray$1.direction.negate();
631
+ ray$1.intersectPlane(plane, intersection$1);
632
+ let deltaAngle = calculateAngle(clickPoint, intersection$1, origin, e1, e2);
633
+ let degrees = toDegrees(deltaAngle);
634
+ if (event.shiftKey) {
635
+ degrees = Math.round(degrees / 10) * 10;
636
+ deltaAngle = toRadians(degrees);
637
+ }
638
+ if (min !== undefined && max !== undefined && max - min < 2 * Math.PI) {
639
+ deltaAngle = minimizeAngle(deltaAngle);
640
+ deltaAngle = deltaAngle > Math.PI ? deltaAngle - 2 * Math.PI : deltaAngle;
641
+ deltaAngle = Math.round(deltaAngle / 10) * 10;
642
+ this.angle = this.angle0 + deltaAngle;
643
+ }
644
+ else {
645
+ this.angle = minimizeAngle(this.angle0 + deltaAngle);
646
+ this.angle = this.angle > Math.PI ? this.angle - 2 * Math.PI : this.angle;
647
+ }
648
+ if (annotation) {
649
+ degrees = toDegrees(this.angle);
650
+ annotation.innerText = `${degrees.toFixed(0)}º`;
651
+ }
652
+ rotMatrix.makeRotationAxis(normal, deltaAngle);
653
+ posNew.copy(origin).applyMatrix4(rotMatrix).sub(origin).negate();
654
+ rotMatrix.setPosition(posNew);
655
+ this.pivotControls.onDrag(rotMatrix);
656
+ }
657
+ }
658
+ onPointerUp(event) {
659
+ const [annotation, controls] = [this.annotationRef()?.nativeElement, this.controls()];
660
+ if (annotation) {
661
+ annotation.style.display = 'none';
662
+ }
663
+ event.stopPropagation();
664
+ this.clickInfo = null;
665
+ this.pivotControls.onDragEnd();
666
+ if (controls) {
667
+ controls.enabled = true;
668
+ }
669
+ // @ts-expect-error - releasePointerCapture is not a function on PointerEvent
670
+ event.target.releasePointerCapture(event.pointerId);
671
+ }
672
+ onPointerOut(event) {
673
+ event.stopPropagation();
674
+ this.hovered.set(false);
675
+ }
676
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsAxisRotator, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
677
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: NgtsAxisRotator, isStandalone: true, selector: "ngts-axis-rotator", inputs: { dir1: { classPropertyName: "dir1", publicName: "dir1", isSignal: true, isRequired: true, transformFunction: null }, dir2: { classPropertyName: "dir2", publicName: "dir2", isSignal: true, isRequired: true, transformFunction: null }, axis: { classPropertyName: "axis", publicName: "axis", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "groupRef", first: true, predicate: ["group"], descendants: true, isSignal: true }, { propertyName: "annotationRef", first: true, predicate: ["annotation"], descendants: true, read: ElementRef, isSignal: true }], ngImport: i0, template: `
678
+ <ngt-group
679
+ #group
680
+ [matrix]="matrixL()"
681
+ [matrixAutoUpdate]="false"
682
+ (pointerdown)="onPointerDown($any($event))"
683
+ (pointermove)="onPointerMove($any($event))"
684
+ (pointerup)="onPointerUp($any($event))"
685
+ (pointerout)="onPointerOut($any($event))"
686
+ >
687
+ @if (pivotControls.annotations()) {
688
+ <ngts-html [options]="{ position: [r(), r(), 0] }">
689
+ <div
690
+ #annotation
691
+ ngtsHTMLContent
692
+ style="display: none; background: #151520; color: white; padding: 6px 8px; border-radius: 7px; white-space: nowrap"
693
+ [class]="pivotControls.annotationsClass()"
694
+ ></div>
695
+ </ngts-html>
696
+ }
697
+
698
+ <ngts-line
699
+ [points]="arc()"
700
+ [options]="{ lineWidth: pivotControls.lineWidth() * 4, visible: false, userData: pivotControls.userData() }"
701
+ />
702
+
703
+ <ngts-line
704
+ [points]="arc()"
705
+ [options]="{
706
+ transparent: true,
707
+ raycast: null,
708
+ depthTest: pivotControls.depthTest(),
709
+ lineWidth: pivotControls.lineWidth(),
710
+ side: DoubleSide,
711
+ color: hovered() ? pivotControls.hoveredColor() : pivotControls.axisColors()[axis()],
712
+ opacity: pivotControls.opacity(),
713
+ polygonOffset: true,
714
+ polygonOffsetFactor: -10,
715
+ fog: false,
716
+ }"
717
+ />
718
+ </ngt-group>
719
+ `, isInline: true, dependencies: [{ kind: "component", type: NgtsLine, selector: "ngts-line", inputs: ["points", "options"] }, { kind: "component", type: NgtsHTML, selector: "ngts-html", inputs: ["options"] }, { kind: "component", type: NgtsHTMLContent, selector: "[ngtsHTMLContent]", inputs: ["ngtsHTMLContent"], outputs: ["occluded"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
720
+ }
721
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsAxisRotator, decorators: [{
722
+ type: Component,
723
+ args: [{
724
+ selector: 'ngts-axis-rotator',
725
+ standalone: true,
726
+ template: `
727
+ <ngt-group
728
+ #group
729
+ [matrix]="matrixL()"
730
+ [matrixAutoUpdate]="false"
731
+ (pointerdown)="onPointerDown($any($event))"
732
+ (pointermove)="onPointerMove($any($event))"
733
+ (pointerup)="onPointerUp($any($event))"
734
+ (pointerout)="onPointerOut($any($event))"
735
+ >
736
+ @if (pivotControls.annotations()) {
737
+ <ngts-html [options]="{ position: [r(), r(), 0] }">
738
+ <div
739
+ #annotation
740
+ ngtsHTMLContent
741
+ style="display: none; background: #151520; color: white; padding: 6px 8px; border-radius: 7px; white-space: nowrap"
742
+ [class]="pivotControls.annotationsClass()"
743
+ ></div>
744
+ </ngts-html>
745
+ }
746
+
747
+ <ngts-line
748
+ [points]="arc()"
749
+ [options]="{ lineWidth: pivotControls.lineWidth() * 4, visible: false, userData: pivotControls.userData() }"
750
+ />
751
+
752
+ <ngts-line
753
+ [points]="arc()"
754
+ [options]="{
755
+ transparent: true,
756
+ raycast: null,
757
+ depthTest: pivotControls.depthTest(),
758
+ lineWidth: pivotControls.lineWidth(),
759
+ side: DoubleSide,
760
+ color: hovered() ? pivotControls.hoveredColor() : pivotControls.axisColors()[axis()],
761
+ opacity: pivotControls.opacity(),
762
+ polygonOffset: true,
763
+ polygonOffsetFactor: -10,
764
+ fog: false,
765
+ }"
766
+ />
767
+ </ngt-group>
768
+ `,
769
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
770
+ changeDetection: ChangeDetectionStrategy.OnPush,
771
+ imports: [NgtsLine, NgtsHTML, NgtsHTMLContent],
772
+ }]
773
+ }], ctorParameters: () => [] });
774
+
775
+ function decomposeIntoBasis(e1, e2, offset) {
776
+ const i1 = Math.abs(e1.x) >= Math.abs(e1.y) && Math.abs(e1.x) >= Math.abs(e1.z)
777
+ ? 0
778
+ : Math.abs(e1.y) >= Math.abs(e1.x) && Math.abs(e1.y) >= Math.abs(e1.z)
779
+ ? 1
780
+ : 2;
781
+ const e2DegrowthOrder = [0, 1, 2].sort((a, b) => Math.abs(e2.getComponent(b)) - Math.abs(e2.getComponent(a)));
782
+ const i2 = i1 === e2DegrowthOrder[0] ? e2DegrowthOrder[1] : e2DegrowthOrder[0];
783
+ const a1 = e1.getComponent(i1);
784
+ const a2 = e1.getComponent(i2);
785
+ const b1 = e2.getComponent(i1);
786
+ const b2 = e2.getComponent(i2);
787
+ const c1 = offset.getComponent(i1);
788
+ const c2 = offset.getComponent(i2);
789
+ const y = (c2 - c1 * (a2 / a1)) / (b2 - b1 * (a2 / a1));
790
+ const x = (c1 - y * b1) / a1;
791
+ return [x, y];
792
+ }
793
+ const ray = new Ray();
794
+ const intersection = new Vector3();
795
+ const offsetMatrix = new Matrix4();
796
+ class NgtsPlaneSlider {
797
+ constructor() {
798
+ this.DoubleSide = DoubleSide;
799
+ this.dir1 = input.required();
800
+ this.dir2 = input.required();
801
+ this.axis = input.required();
802
+ this.groupRef = viewChild.required('group');
803
+ this.annotationRef = viewChild('annotation', { read: ElementRef });
804
+ this.pivotControls = inject(NgtsPivotControls);
805
+ this.store = injectStore();
806
+ this.controls = this.store.select('controls');
807
+ this.hovered = signal(false);
808
+ this.clickInfo = null;
809
+ this.offsetX0 = 0;
810
+ this.offsetY0 = 0;
811
+ this.matrixL = computed(() => {
812
+ const dir1N = this.dir1().clone().normalize();
813
+ const dir2N = this.dir2().clone().normalize();
814
+ return new Matrix4().makeBasis(dir1N, dir2N, dir1N.clone().cross(dir2N));
815
+ });
816
+ this.pos1 = computed(() => (this.pivotControls.fixed() ? 1 / 7 : this.pivotControls.scale() / 7));
817
+ this.length = computed(() => (this.pivotControls.fixed() ? 0.225 : this.pivotControls.scale() * 0.225));
818
+ this.color = computed(() => this.hovered() ? this.pivotControls.hoveredColor() : this.pivotControls.axisColors()[this.axis()]);
819
+ this.points = computed(() => {
820
+ const length = this.length();
821
+ return [
822
+ new Vector3(0, 0, 0),
823
+ new Vector3(0, length, 0),
824
+ new Vector3(length, length, 0),
825
+ new Vector3(length, 0, 0),
826
+ new Vector3(0, 0, 0),
827
+ ];
828
+ });
829
+ extend({ Group, Mesh, PlaneGeometry, MeshBasicMaterial });
830
+ }
831
+ onPointerDown(event) {
832
+ const [annotation, axis, group, controls] = [
833
+ this.annotationRef()?.nativeElement,
834
+ this.axis(),
835
+ this.groupRef().nativeElement,
836
+ this.controls(),
837
+ ];
838
+ if (annotation) {
839
+ annotation.innerText = `${this.pivotControls.translation[(axis + 1) % 3].toFixed(2)}, ${this.pivotControls.translation[(axis + 2) % 3].toFixed(2)}`;
840
+ annotation.style.display = 'block';
841
+ }
842
+ event.stopPropagation();
843
+ const clickPoint = event.point.clone();
844
+ const origin = new Vector3().setFromMatrixPosition(group.matrixWorld);
845
+ const e1 = new Vector3().setFromMatrixColumn(group.matrixWorld, 0).normalize();
846
+ const e2 = new Vector3().setFromMatrixColumn(group.matrixWorld, 1).normalize();
847
+ const normal = new Vector3().setFromMatrixColumn(group.matrixWorld, 2).normalize();
848
+ const plane = new Plane().setFromNormalAndCoplanarPoint(normal, origin);
849
+ this.clickInfo = { clickPoint, e1, e2, plane };
850
+ this.offsetX0 = this.pivotControls.translation[(axis + 1) % 3];
851
+ this.offsetY0 = this.pivotControls.translation[(axis + 2) % 3];
852
+ this.pivotControls.onDragStart({ component: 'Slider', axis, origin, directions: [e1, e2, normal] });
853
+ if (controls) {
854
+ controls.enabled = false;
855
+ }
856
+ // @ts-expect-error - setPointerCapture is not defined on ThreeEvent
857
+ event.target.setPointerCapture(event.pointerId);
858
+ }
859
+ onPointerMove(event) {
860
+ event.stopPropagation();
861
+ if (!this.hovered())
862
+ this.hovered.set(true);
863
+ if (this.clickInfo) {
864
+ const { clickPoint, e1, e2, plane } = this.clickInfo;
865
+ const [translationLimits, axis, annotation] = [
866
+ this.pivotControls.translationLimits(),
867
+ this.axis(),
868
+ this.annotationRef()?.nativeElement,
869
+ ];
870
+ const [minX, maxX] = translationLimits?.[(axis + 1) % 3] || [undefined, undefined];
871
+ const [minY, maxY] = translationLimits?.[(axis + 2) % 3] || [undefined, undefined];
872
+ ray.copy(event.ray);
873
+ ray.intersectPlane(plane, intersection);
874
+ ray.direction.negate();
875
+ ray.intersectPlane(plane, intersection);
876
+ intersection.sub(clickPoint);
877
+ let [offsetX, offsetY] = decomposeIntoBasis(e1, e2, intersection);
878
+ /* let offsetY = (intersection.y - (intersection.x * e1.y) / e1.x) / (e2.y - (e2.x * e1.y) / e1.x)
879
+ let offsetX = (intersection.x - offsetY * e2.x) / e1.x */
880
+ if (minX !== undefined) {
881
+ offsetX = Math.max(offsetX, minX - this.offsetX0);
882
+ }
883
+ if (maxX !== undefined) {
884
+ offsetX = Math.min(offsetX, maxX - this.offsetX0);
885
+ }
886
+ if (minY !== undefined) {
887
+ offsetY = Math.max(offsetY, minY - this.offsetY0);
888
+ }
889
+ if (maxY !== undefined) {
890
+ offsetY = Math.min(offsetY, maxY - this.offsetY0);
891
+ }
892
+ this.pivotControls.translation[(axis + 1) % 3] = this.offsetX0 + offsetX;
893
+ this.pivotControls.translation[(axis + 2) % 3] = this.offsetY0 + offsetY;
894
+ if (annotation) {
895
+ annotation.innerText = `${this.pivotControls.translation[(axis + 1) % 3].toFixed(2)}, ${this.pivotControls.translation[(axis + 2) % 3].toFixed(2)}`;
896
+ }
897
+ offsetMatrix.makeTranslation(offsetX * e1.x + offsetY * e2.x, offsetX * e1.y + offsetY * e2.y, offsetX * e1.z + offsetY * e2.z);
898
+ this.pivotControls.onDrag(offsetMatrix);
899
+ }
900
+ }
901
+ onPointerUp(event) {
902
+ const [annotation, controls] = [this.annotationRef()?.nativeElement, this.controls()];
903
+ if (annotation) {
904
+ annotation.style.display = 'none';
905
+ }
906
+ event.stopPropagation();
907
+ this.clickInfo = null;
908
+ this.pivotControls.onDragEnd();
909
+ if (controls) {
910
+ controls.enabled = true;
911
+ }
912
+ // @ts-expect-error - releasePointerCapture is not defined on ThreeEvent
913
+ event.target.releasePointerCapture(event.pointerId);
914
+ }
915
+ onPointerOut(event) {
916
+ event.stopPropagation();
917
+ this.hovered.set(false);
918
+ }
919
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsPlaneSlider, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
920
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: NgtsPlaneSlider, isStandalone: true, selector: "ngts-plane-slider", inputs: { dir1: { classPropertyName: "dir1", publicName: "dir1", isSignal: true, isRequired: true, transformFunction: null }, dir2: { classPropertyName: "dir2", publicName: "dir2", isSignal: true, isRequired: true, transformFunction: null }, axis: { classPropertyName: "axis", publicName: "axis", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "groupRef", first: true, predicate: ["group"], descendants: true, isSignal: true }, { propertyName: "annotationRef", first: true, predicate: ["annotation"], descendants: true, read: ElementRef, isSignal: true }], ngImport: i0, template: `
921
+ <ngt-group #group [matrix]="matrixL()" [matrixAutoUpdate]="false">
922
+ @if (pivotControls.annotations()) {
923
+ <ngts-html [options]="{ position: [0, 0, 0] }">
924
+ <div
925
+ #annotation
926
+ ngtsHTMLContent
927
+ style="display: none; background: #151520; color: white; padding: 6px 8px; border-radius: 7px; white-space: nowrap"
928
+ [class]="pivotControls.annotationsClass()"
929
+ ></div>
930
+ </ngts-html>
931
+ }
932
+ <ngt-group [position]="[pos1() * 1.7, pos1() * 1.7, 0]">
933
+ <ngt-mesh
934
+ [visible]="true"
935
+ [scale]="length()"
936
+ [userData]="pivotControls.userData()"
937
+ (pointerdown)="onPointerDown($any($event))"
938
+ (pointermove)="onPointerMove($any($event))"
939
+ (pointerup)="onPointerUp($any($event))"
940
+ (pointerout)="onPointerOut($any($event))"
941
+ >
942
+ <ngt-plane-geometry />
943
+ <ngt-mesh-basic-material
944
+ [transparent]="true"
945
+ [depthTest]="pivotControls.depthTest()"
946
+ [color]="color()"
947
+ [polygonOffset]="true"
948
+ [polygonOffsetFactor]="-10"
949
+ [side]="DoubleSide"
950
+ [fog]="false"
951
+ />
952
+ </ngt-mesh>
953
+ <ngts-line
954
+ [points]="points()"
955
+ [options]="{
956
+ position: [-length() / 2, -length() / 2, 0],
957
+ transparent: true,
958
+ depthTest: pivotControls.depthTest(),
959
+ lineWidth: pivotControls.lineWidth(),
960
+ color: color(),
961
+ opacity: pivotControls.opacity(),
962
+ polygonOffset: true,
963
+ polygonOffsetFactor: -10,
964
+ userData: pivotControls.userData(),
965
+ fog: false,
966
+ }"
967
+ />
968
+ </ngt-group>
969
+ </ngt-group>
970
+ `, isInline: true, dependencies: [{ kind: "component", type: NgtsHTML, selector: "ngts-html", inputs: ["options"] }, { kind: "component", type: NgtsHTMLContent, selector: "[ngtsHTMLContent]", inputs: ["ngtsHTMLContent"], outputs: ["occluded"] }, { kind: "component", type: NgtsLine, selector: "ngts-line", inputs: ["points", "options"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
971
+ }
972
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsPlaneSlider, decorators: [{
973
+ type: Component,
974
+ args: [{
975
+ selector: 'ngts-plane-slider',
976
+ standalone: true,
977
+ template: `
978
+ <ngt-group #group [matrix]="matrixL()" [matrixAutoUpdate]="false">
979
+ @if (pivotControls.annotations()) {
980
+ <ngts-html [options]="{ position: [0, 0, 0] }">
981
+ <div
982
+ #annotation
983
+ ngtsHTMLContent
984
+ style="display: none; background: #151520; color: white; padding: 6px 8px; border-radius: 7px; white-space: nowrap"
985
+ [class]="pivotControls.annotationsClass()"
986
+ ></div>
987
+ </ngts-html>
988
+ }
989
+ <ngt-group [position]="[pos1() * 1.7, pos1() * 1.7, 0]">
990
+ <ngt-mesh
991
+ [visible]="true"
992
+ [scale]="length()"
993
+ [userData]="pivotControls.userData()"
994
+ (pointerdown)="onPointerDown($any($event))"
995
+ (pointermove)="onPointerMove($any($event))"
996
+ (pointerup)="onPointerUp($any($event))"
997
+ (pointerout)="onPointerOut($any($event))"
998
+ >
999
+ <ngt-plane-geometry />
1000
+ <ngt-mesh-basic-material
1001
+ [transparent]="true"
1002
+ [depthTest]="pivotControls.depthTest()"
1003
+ [color]="color()"
1004
+ [polygonOffset]="true"
1005
+ [polygonOffsetFactor]="-10"
1006
+ [side]="DoubleSide"
1007
+ [fog]="false"
1008
+ />
1009
+ </ngt-mesh>
1010
+ <ngts-line
1011
+ [points]="points()"
1012
+ [options]="{
1013
+ position: [-length() / 2, -length() / 2, 0],
1014
+ transparent: true,
1015
+ depthTest: pivotControls.depthTest(),
1016
+ lineWidth: pivotControls.lineWidth(),
1017
+ color: color(),
1018
+ opacity: pivotControls.opacity(),
1019
+ polygonOffset: true,
1020
+ polygonOffsetFactor: -10,
1021
+ userData: pivotControls.userData(),
1022
+ fog: false,
1023
+ }"
1024
+ />
1025
+ </ngt-group>
1026
+ </ngt-group>
1027
+ `,
1028
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
1029
+ changeDetection: ChangeDetectionStrategy.OnPush,
1030
+ imports: [NgtsHTML, NgtsHTMLContent, NgtsLine],
1031
+ }]
1032
+ }], ctorParameters: () => [] });
1033
+
1034
+ const vec1 = new Vector3();
1035
+ const vec2 = new Vector3();
1036
+ function calculateOffset(clickPoint, normal, rayStart, rayDir) {
1037
+ const e1 = normal.dot(normal);
1038
+ const e2 = normal.dot(clickPoint) - normal.dot(rayStart);
1039
+ const e3 = normal.dot(rayDir);
1040
+ if (e3 === 0) {
1041
+ return -e2 / e1;
1042
+ }
1043
+ vec1
1044
+ .copy(rayDir)
1045
+ .multiplyScalar(e1 / e3)
1046
+ .sub(normal);
1047
+ vec2
1048
+ .copy(rayDir)
1049
+ .multiplyScalar(e2 / e3)
1050
+ .add(rayStart)
1051
+ .sub(clickPoint);
1052
+ return -vec1.dot(vec2) / vec1.dot(vec1);
1053
+ }
1054
+ const upV = new Vector3(0, 1, 0);
1055
+ const scaleV = new Vector3();
1056
+ const scaleMatrix = new Matrix4();
1057
+ class NgtsScalingSphere {
1058
+ constructor() {
1059
+ this.direction = input.required();
1060
+ this.axis = input.required();
1061
+ this.groupRef = viewChild.required('group');
1062
+ this.annotationRef = viewChild('annotation', { read: ElementRef });
1063
+ this.meshRef = viewChild.required('mesh');
1064
+ this.pivotControls = inject(NgtsPivotControls);
1065
+ this.store = injectStore();
1066
+ this.controls = this.store.select('controls');
1067
+ this.size = this.store.select('size');
1068
+ this.hovered = signal(false);
1069
+ this.scale0 = 1;
1070
+ this.scaleCurrent = 1;
1071
+ this.clickInfo = null;
1072
+ this.position = computed(() => (this.pivotControls.fixed() ? 1.2 : 1.2 * this.pivotControls.scale()));
1073
+ this.radius = computed(() => this.pivotControls.fixed()
1074
+ ? (this.pivotControls.lineWidth() / this.pivotControls.scale()) * 1.8
1075
+ : this.pivotControls.scale() / 22.5);
1076
+ this.matrixL = computed(() => {
1077
+ const quaternion = new Quaternion().setFromUnitVectors(upV, this.direction().clone().normalize());
1078
+ return new Matrix4().makeRotationFromQuaternion(quaternion);
1079
+ });
1080
+ this.color = computed(() => this.hovered() ? this.pivotControls.hoveredColor() : this.pivotControls.axisColors()[this.axis()]);
1081
+ extend({ Group, Mesh, SphereGeometry, MeshBasicMaterial });
1082
+ }
1083
+ onPointerDown(event) {
1084
+ const [annotation, controls, fixed, scale, direction, axis, size, group] = [
1085
+ this.annotationRef()?.nativeElement,
1086
+ this.controls(),
1087
+ this.pivotControls.fixed(),
1088
+ this.pivotControls.scale(),
1089
+ this.direction(),
1090
+ this.axis(),
1091
+ this.size(),
1092
+ this.groupRef().nativeElement,
1093
+ ];
1094
+ if (annotation) {
1095
+ annotation.innerText = `${scale.toFixed(2)}`;
1096
+ annotation.style.display = 'block';
1097
+ }
1098
+ event.stopPropagation();
1099
+ const rotation = new Matrix4().extractRotation(group.matrixWorld);
1100
+ const clickPoint = event.point.clone();
1101
+ const origin = new Vector3().setFromMatrixPosition(group.matrixWorld);
1102
+ const dir = direction.clone().applyMatrix4(rotation).normalize();
1103
+ const mPLG = group.matrixWorld.clone();
1104
+ const mPLGInv = mPLG.clone().invert();
1105
+ const offsetMultiplier = fixed
1106
+ ? 1 / calculateScaleFactor(group.getWorldPosition(vec1), scale, event.camera, size)
1107
+ : 1;
1108
+ this.clickInfo = { clickPoint, dir, mPLG, mPLGInv, offsetMultiplier };
1109
+ this.pivotControls.onDragStart({ component: 'Sphere', axis, origin, directions: [dir] });
1110
+ if (controls) {
1111
+ controls.enabled = false;
1112
+ }
1113
+ // @ts-expect-error - setPointerCapture is not in the type definition
1114
+ event.target.setPointerCapture(event.pointerId);
1115
+ }
1116
+ onPointerMove(event) {
1117
+ event.stopPropagation();
1118
+ if (!this.hovered())
1119
+ this.hovered.set(true);
1120
+ if (this.clickInfo) {
1121
+ const { clickPoint, dir, mPLG, mPLGInv, offsetMultiplier } = this.clickInfo;
1122
+ const [scaleLimits, axis, position, annotation, fixed, scale, mesh] = [
1123
+ this.pivotControls.scaleLimits(),
1124
+ this.axis(),
1125
+ this.position(),
1126
+ this.annotationRef()?.nativeElement,
1127
+ this.pivotControls.fixed(),
1128
+ this.pivotControls.scale(),
1129
+ this.meshRef().nativeElement,
1130
+ ];
1131
+ const [min, max] = scaleLimits?.[axis] || [1e-5, undefined]; // always limit the minimal value, since setting it very low might break the transform
1132
+ const offsetW = calculateOffset(clickPoint, dir, event.ray.origin, event.ray.direction);
1133
+ const offsetL = offsetW * offsetMultiplier;
1134
+ const offsetH = fixed ? offsetL : offsetL / scale;
1135
+ let upscale = Math.pow(2, offsetH * 0.2);
1136
+ if (event.shiftKey) {
1137
+ upscale = Math.round(upscale * 10) / 10;
1138
+ }
1139
+ upscale = Math.max(upscale, min / this.scale0);
1140
+ if (max !== undefined) {
1141
+ upscale = Math.min(upscale, max / this.scale0);
1142
+ }
1143
+ this.scaleCurrent = this.scale0 * upscale;
1144
+ mesh.position.set(0, position + offsetL, 0);
1145
+ if (annotation) {
1146
+ annotation.innerText = `${this.scaleCurrent.toFixed(2)}`;
1147
+ }
1148
+ scaleV.set(1, 1, 1);
1149
+ scaleV.setComponent(axis, upscale);
1150
+ scaleMatrix.makeScale(scaleV.x, scaleV.y, scaleV.z).premultiply(mPLG).multiply(mPLGInv);
1151
+ this.pivotControls.onDrag(scaleMatrix);
1152
+ }
1153
+ }
1154
+ onPointerUp(event) {
1155
+ const [annotation, controls, position, mesh] = [
1156
+ this.annotationRef()?.nativeElement,
1157
+ this.controls(),
1158
+ this.position(),
1159
+ this.meshRef().nativeElement,
1160
+ ];
1161
+ if (annotation) {
1162
+ annotation.style.display = 'none';
1163
+ }
1164
+ event.stopPropagation();
1165
+ this.scale0 = this.scaleCurrent;
1166
+ this.clickInfo = null;
1167
+ mesh.position.set(0, position, 0);
1168
+ this.pivotControls.onDragEnd();
1169
+ if (controls) {
1170
+ controls.enabled = true;
1171
+ }
1172
+ // @ts-expect-error - releasePointerCapture is not in the type definition
1173
+ event.target.releasePointerCapture(event.pointerId);
1174
+ }
1175
+ onPointerOut(event) {
1176
+ event.stopPropagation();
1177
+ this.hovered.set(false);
1178
+ }
1179
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsScalingSphere, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1180
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: NgtsScalingSphere, isStandalone: true, selector: "ngts-scaling-sphere", inputs: { direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: true, transformFunction: null }, axis: { classPropertyName: "axis", publicName: "axis", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "groupRef", first: true, predicate: ["group"], descendants: true, isSignal: true }, { propertyName: "annotationRef", first: true, predicate: ["annotation"], descendants: true, read: ElementRef, isSignal: true }, { propertyName: "meshRef", first: true, predicate: ["mesh"], descendants: true, isSignal: true }], ngImport: i0, template: `
1181
+ <ngt-group #group>
1182
+ <ngt-group
1183
+ [matrix]="matrixL()"
1184
+ [matrixAutoUpdate]="false"
1185
+ (pointerdown)="onPointerDown($any($event))"
1186
+ (pointermove)="onPointerMove($any($event))"
1187
+ (pointerup)="onPointerUp($any($event))"
1188
+ (pointerout)="onPointerOut($any($event))"
1189
+ >
1190
+ @if (pivotControls.annotations()) {
1191
+ <ngts-html [options]="{ position: [0, position() / 2, 0] }">
1192
+ <div
1193
+ #annotation
1194
+ ngtsHTMLContent
1195
+ style="display: none; background: #151520; color: white; padding: 6px 8px; border-radius: 7px; white-space: nowrap;"
1196
+ [class]="pivotControls.annotationsClass()"
1197
+ ></div>
1198
+ </ngts-html>
1199
+ }
1200
+ <ngt-mesh #mesh [position]="[0, position(), 0]" [renderOrder]="500" [userData]="pivotControls.userData()">
1201
+ <ngt-sphere-geometry *args="[radius(), 12, 12]" />
1202
+ <ngt-mesh-basic-material
1203
+ [transparent]="true"
1204
+ [depthTest]="pivotControls.depthTest()"
1205
+ [color]="color()"
1206
+ [opacity]="pivotControls.opacity()"
1207
+ [polygonOffset]="true"
1208
+ [polygonOffsetFactor]="-10"
1209
+ />
1210
+ </ngt-mesh>
1211
+ </ngt-group>
1212
+ </ngt-group>
1213
+ `, isInline: true, dependencies: [{ kind: "component", type: NgtsHTML, selector: "ngts-html", inputs: ["options"] }, { kind: "component", type: NgtsHTMLContent, selector: "[ngtsHTMLContent]", inputs: ["ngtsHTMLContent"], outputs: ["occluded"] }, { kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1214
+ }
1215
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsScalingSphere, decorators: [{
1216
+ type: Component,
1217
+ args: [{
1218
+ selector: 'ngts-scaling-sphere',
1219
+ standalone: true,
1220
+ template: `
1221
+ <ngt-group #group>
1222
+ <ngt-group
1223
+ [matrix]="matrixL()"
1224
+ [matrixAutoUpdate]="false"
1225
+ (pointerdown)="onPointerDown($any($event))"
1226
+ (pointermove)="onPointerMove($any($event))"
1227
+ (pointerup)="onPointerUp($any($event))"
1228
+ (pointerout)="onPointerOut($any($event))"
1229
+ >
1230
+ @if (pivotControls.annotations()) {
1231
+ <ngts-html [options]="{ position: [0, position() / 2, 0] }">
1232
+ <div
1233
+ #annotation
1234
+ ngtsHTMLContent
1235
+ style="display: none; background: #151520; color: white; padding: 6px 8px; border-radius: 7px; white-space: nowrap;"
1236
+ [class]="pivotControls.annotationsClass()"
1237
+ ></div>
1238
+ </ngts-html>
1239
+ }
1240
+ <ngt-mesh #mesh [position]="[0, position(), 0]" [renderOrder]="500" [userData]="pivotControls.userData()">
1241
+ <ngt-sphere-geometry *args="[radius(), 12, 12]" />
1242
+ <ngt-mesh-basic-material
1243
+ [transparent]="true"
1244
+ [depthTest]="pivotControls.depthTest()"
1245
+ [color]="color()"
1246
+ [opacity]="pivotControls.opacity()"
1247
+ [polygonOffset]="true"
1248
+ [polygonOffsetFactor]="-10"
1249
+ />
1250
+ </ngt-mesh>
1251
+ </ngt-group>
1252
+ </ngt-group>
1253
+ `,
1254
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
1255
+ changeDetection: ChangeDetectionStrategy.OnPush,
1256
+ imports: [NgtsHTML, NgtsHTMLContent, NgtArgs],
1257
+ }]
1258
+ }], ctorParameters: () => [] });
1259
+
1260
+ const mL0 = new Matrix4();
1261
+ const mW0 = new Matrix4();
1262
+ const mP = new Matrix4();
1263
+ const mPInv = new Matrix4();
1264
+ const mW = new Matrix4();
1265
+ const mL = new Matrix4();
1266
+ const mL0Inv = new Matrix4();
1267
+ const mdL = new Matrix4();
1268
+ const mG = new Matrix4();
1269
+ const bb = new Box3();
1270
+ const bbObj = new Box3();
1271
+ const vCenter = new Vector3();
1272
+ const vSize = new Vector3();
1273
+ const vAnchorOffset = new Vector3();
1274
+ const vPosition = new Vector3();
1275
+ const vScale = new Vector3();
1276
+ const xDir = new Vector3(1, 0, 0);
1277
+ const yDir = new Vector3(0, 1, 0);
1278
+ const zDir = new Vector3(0, 0, 1);
1279
+ const defaultOptions$1 = {
1280
+ enabled: true,
1281
+ autoTransform: true,
1282
+ disableAxes: false,
1283
+ disableSliders: false,
1284
+ disableRotations: false,
1285
+ disableScaling: false,
1286
+ activeAxes: [true, true, true],
1287
+ offset: [0, 0, 0],
1288
+ rotation: [0, 0, 0],
1289
+ scale: 1,
1290
+ lineWidth: 4,
1291
+ fixed: false,
1292
+ depthTest: true,
1293
+ axisColors: ['#ff2060', '#20df80', '#2080ff'],
1294
+ hoveredColor: '#ffff40',
1295
+ annotations: false,
1296
+ opacity: 1,
1297
+ visible: true,
1298
+ };
1299
+ class NgtsPivotControls {
1300
+ constructor() {
1301
+ this.options = input(defaultOptions$1, { transform: mergeInputs(defaultOptions$1) });
1302
+ this.parameters = omit(this.options, [
1303
+ 'enabled',
1304
+ 'matrix',
1305
+ 'autoTransform',
1306
+ 'anchor',
1307
+ 'disableAxes',
1308
+ 'disableSliders',
1309
+ 'disableRotations',
1310
+ 'disableScaling',
1311
+ 'activeAxes',
1312
+ 'offset',
1313
+ 'rotation',
1314
+ 'scale',
1315
+ 'lineWidth',
1316
+ 'fixed',
1317
+ 'translationLimits',
1318
+ 'rotationLimits',
1319
+ 'scaleLimits',
1320
+ 'depthTest',
1321
+ 'axisColors',
1322
+ 'hoveredColor',
1323
+ 'annotations',
1324
+ 'annotationsClass',
1325
+ 'opacity',
1326
+ 'visible',
1327
+ 'userData',
1328
+ ]);
1329
+ this.dragStarted = output();
1330
+ this.dragEnded = output();
1331
+ this.dragged = output();
1332
+ this.matrix = pick(this.options, 'matrix');
1333
+ this.annotations = pick(this.options, 'annotations');
1334
+ this.annotationsClass = pick(this.options, 'annotationsClass');
1335
+ this.translationLimits = pick(this.options, 'translationLimits');
1336
+ this.rotationLimits = pick(this.options, 'rotationLimits');
1337
+ this.scaleLimits = pick(this.options, 'scaleLimits');
1338
+ this.autoTransform = pick(this.options, 'autoTransform');
1339
+ this.fixed = pick(this.options, 'fixed');
1340
+ this.hoveredColor = pick(this.options, 'hoveredColor');
1341
+ this.axisColors = pick(this.options, 'axisColors');
1342
+ this.lineWidth = pick(this.options, 'lineWidth');
1343
+ this.scale = pick(this.options, 'scale');
1344
+ this.userData = pick(this.options, 'userData');
1345
+ this.opacity = pick(this.options, 'opacity');
1346
+ this.depthTest = pick(this.options, 'depthTest');
1347
+ this.offset = pick(this.options, 'offset');
1348
+ this.rotation = pick(this.options, 'rotation');
1349
+ this.visible = pick(this.options, 'visible');
1350
+ this.enabled = pick(this.options, 'enabled');
1351
+ this.disableAxes = pick(this.options, 'disableAxes');
1352
+ this.disableSliders = pick(this.options, 'disableSliders');
1353
+ this.disableRotations = pick(this.options, 'disableRotations');
1354
+ this.disableScaling = pick(this.options, 'disableScaling');
1355
+ this.activeAxes = pick(this.options, 'activeAxes');
1356
+ this.xDir = xDir;
1357
+ this.yDir = yDir;
1358
+ this.zDir = zDir;
1359
+ this.parentRef = viewChild.required('parent');
1360
+ this.groupRef = viewChild.required('group');
1361
+ this.gizmoRef = viewChild.required('gizmo');
1362
+ this.childrenRef = viewChild.required('children');
1363
+ this.store = injectStore();
1364
+ this.invalidate = this.store.select('invalidate');
1365
+ this.translation = [0, 0, 0];
1366
+ this.anchor = pick(this.options, 'anchor');
1367
+ this.cameraScale = new Vector3(1, 1, 1);
1368
+ this.gizmoScale = new Vector3(1, 1, 1);
1369
+ extend({ Group });
1370
+ const autoEffect = injectAutoEffect();
1371
+ afterNextRender(() => {
1372
+ autoEffect(() => {
1373
+ const anchor = this.anchor();
1374
+ if (!anchor)
1375
+ return;
1376
+ const children = this.childrenRef().nativeElement;
1377
+ const localState = getLocalState(children);
1378
+ if (!localState)
1379
+ return;
1380
+ const [gizmo, offset, invalidate] = [
1381
+ this.gizmoRef().nativeElement,
1382
+ this.offset(),
1383
+ this.invalidate(),
1384
+ this.options(),
1385
+ localState.objects(),
1386
+ ];
1387
+ children.updateWorldMatrix(true, true);
1388
+ mPInv.copy(children.matrixWorld).invert();
1389
+ bb.makeEmpty();
1390
+ children.traverse((obj) => {
1391
+ if (!obj.geometry)
1392
+ return;
1393
+ if (!obj.geometry.boundingBox)
1394
+ obj.geometry.computeBoundingBox();
1395
+ mL.copy(obj.matrixWorld).premultiply(mPInv);
1396
+ const boundingBox = obj.geometry.boundingBox;
1397
+ if (boundingBox) {
1398
+ bbObj.copy(boundingBox);
1399
+ bbObj.applyMatrix4(mL);
1400
+ bb.union(bbObj);
1401
+ }
1402
+ });
1403
+ vCenter.copy(bb.max).add(bb.min).multiplyScalar(0.5);
1404
+ vSize.copy(bb.max).sub(bb.min).multiplyScalar(0.5);
1405
+ vAnchorOffset
1406
+ .copy(vSize)
1407
+ .multiply(new Vector3(...anchor))
1408
+ .add(vCenter);
1409
+ vPosition.set(...offset).add(vAnchorOffset);
1410
+ gizmo.position.copy(vPosition);
1411
+ invalidate();
1412
+ });
1413
+ });
1414
+ const vec = new Vector3();
1415
+ injectBeforeRender(({ camera, size, invalidate }) => {
1416
+ const [{ fixed, scale, matrix }, gizmo, group] = [
1417
+ this.options(),
1418
+ this.gizmoRef().nativeElement,
1419
+ this.groupRef().nativeElement,
1420
+ ];
1421
+ if (fixed) {
1422
+ const sf = calculateScaleFactor(gizmo.getWorldPosition(vec), scale, camera, size);
1423
+ this.cameraScale.setScalar(sf);
1424
+ }
1425
+ if (matrix && matrix instanceof Matrix4) {
1426
+ group.matrix = matrix;
1427
+ }
1428
+ // Update gizmo scale in accordance with matrix changes
1429
+ // Without this, there might be noticeable turbulence if scaling happens fast enough
1430
+ gizmo.updateWorldMatrix(true, true);
1431
+ mG.makeRotationFromEuler(gizmo.rotation).setPosition(gizmo.position).premultiply(group.matrixWorld);
1432
+ this.gizmoScale.setFromMatrixScale(mG);
1433
+ vScale.copy(this.cameraScale).divide(this.gizmoScale);
1434
+ if (Math.abs(gizmo.scale.x - vScale.x) > 1e-4 ||
1435
+ Math.abs(gizmo.scale.y - vScale.y) > 1e-4 ||
1436
+ Math.abs(gizmo.scale.z - vScale.z) > 1e-4) {
1437
+ gizmo.scale.copy(vScale);
1438
+ invalidate();
1439
+ }
1440
+ });
1441
+ }
1442
+ onDragStart(parameters) {
1443
+ const group = this.groupRef().nativeElement;
1444
+ mL0.copy(group.matrix);
1445
+ mW0.copy(group.matrixWorld);
1446
+ this.dragStarted.emit(parameters);
1447
+ this.store.snapshot.invalidate();
1448
+ }
1449
+ onDrag(mdW) {
1450
+ const [parent, group, autoTransform] = [
1451
+ this.parentRef().nativeElement,
1452
+ this.groupRef().nativeElement,
1453
+ this.autoTransform(),
1454
+ ];
1455
+ mP.copy(parent.matrixWorld);
1456
+ mPInv.copy(mP).invert();
1457
+ // After applying the delta
1458
+ mW.copy(mW0).premultiply(mdW);
1459
+ mL.copy(mW).premultiply(mPInv);
1460
+ mL0Inv.copy(mL0).invert();
1461
+ mdL.copy(mL).multiply(mL0Inv);
1462
+ if (autoTransform) {
1463
+ group.matrix.copy(mL);
1464
+ }
1465
+ this.dragged.emit({ l: mL, deltaL: mdL, w: mW, deltaW: mdW });
1466
+ this.store.snapshot.invalidate();
1467
+ }
1468
+ onDragEnd() {
1469
+ this.dragEnded.emit();
1470
+ this.store.snapshot.invalidate();
1471
+ }
1472
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsPivotControls, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1473
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: NgtsPivotControls, isStandalone: true, selector: "ngts-pivot-controls", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { dragStarted: "dragStarted", dragEnded: "dragEnded", dragged: "dragged" }, viewQueries: [{ propertyName: "parentRef", first: true, predicate: ["parent"], descendants: true, isSignal: true }, { propertyName: "groupRef", first: true, predicate: ["group"], descendants: true, isSignal: true }, { propertyName: "gizmoRef", first: true, predicate: ["gizmo"], descendants: true, isSignal: true }, { propertyName: "childrenRef", first: true, predicate: ["children"], descendants: true, isSignal: true }], ngImport: i0, template: `
1474
+ <ngt-group #parent>
1475
+ <ngt-group #group [matrix]="matrix()" [matrixAutoUpdate]="false" [parameters]="parameters()">
1476
+ <ngt-group #gizmo [visible]="visible()" [position]="offset()" [rotation]="rotation()">
1477
+ @if (enabled()) {
1478
+ @if (!disableAxes() && activeAxes()[0]) {
1479
+ <ngts-axis-arrow [axis]="0" [direction]="xDir" />
1480
+ }
1481
+ @if (!disableAxes() && activeAxes()[1]) {
1482
+ <ngts-axis-arrow [axis]="1" [direction]="yDir" />
1483
+ }
1484
+ @if (!disableAxes() && activeAxes()[2]) {
1485
+ <ngts-axis-arrow [axis]="2" [direction]="zDir" />
1486
+ }
1487
+
1488
+ @if (!disableSliders() && activeAxes()[0] && activeAxes()[1]) {
1489
+ <ngts-plane-slider [axis]="2" [dir1]="xDir" [dir2]="yDir" />
1490
+ }
1491
+ @if (!disableSliders() && activeAxes()[0] && activeAxes()[2]) {
1492
+ <ngts-plane-slider [axis]="1" [dir1]="zDir" [dir2]="xDir" />
1493
+ }
1494
+ @if (!disableSliders() && activeAxes()[2] && activeAxes()[1]) {
1495
+ <ngts-plane-slider [axis]="0" [dir1]="yDir" [dir2]="zDir" />
1496
+ }
1497
+
1498
+ @if (!disableRotations() && activeAxes()[0] && activeAxes()[1]) {
1499
+ <ngts-axis-rotator [axis]="2" [dir1]="xDir" [dir2]="yDir" />
1500
+ }
1501
+ @if (!disableRotations() && activeAxes()[0] && activeAxes()[2]) {
1502
+ <ngts-axis-rotator [axis]="1" [dir1]="zDir" [dir2]="xDir" />
1503
+ }
1504
+ @if (!disableRotations() && activeAxes()[2] && activeAxes()[1]) {
1505
+ <ngts-axis-rotator [axis]="0" [dir1]="yDir" [dir2]="zDir" />
1506
+ }
1507
+
1508
+ @if (!disableScaling() && activeAxes()[0]) {
1509
+ <ngts-scaling-sphere [axis]="0" [direction]="xDir" />
1510
+ }
1511
+ @if (!disableScaling() && activeAxes()[1]) {
1512
+ <ngts-scaling-sphere [axis]="1" [direction]="yDir" />
1513
+ }
1514
+ @if (!disableScaling() && activeAxes()[2]) {
1515
+ <ngts-scaling-sphere [axis]="2" [direction]="zDir" />
1516
+ }
1517
+ }
1518
+ </ngt-group>
1519
+ <ngt-group #children>
1520
+ <ng-content />
1521
+ </ngt-group>
1522
+ </ngt-group>
1523
+ </ngt-group>
1524
+ `, isInline: true, dependencies: [{ kind: "component", type: NgtsAxisArrow, selector: "ngts-axis-arrow", inputs: ["direction", "axis"] }, { kind: "component", type: NgtsPlaneSlider, selector: "ngts-plane-slider", inputs: ["dir1", "dir2", "axis"] }, { kind: "component", type: NgtsAxisRotator, selector: "ngts-axis-rotator", inputs: ["dir1", "dir2", "axis"] }, { kind: "component", type: NgtsScalingSphere, selector: "ngts-scaling-sphere", inputs: ["direction", "axis"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1525
+ }
1526
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsPivotControls, decorators: [{
1527
+ type: Component,
1528
+ args: [{
1529
+ selector: 'ngts-pivot-controls',
1530
+ standalone: true,
1531
+ template: `
1532
+ <ngt-group #parent>
1533
+ <ngt-group #group [matrix]="matrix()" [matrixAutoUpdate]="false" [parameters]="parameters()">
1534
+ <ngt-group #gizmo [visible]="visible()" [position]="offset()" [rotation]="rotation()">
1535
+ @if (enabled()) {
1536
+ @if (!disableAxes() && activeAxes()[0]) {
1537
+ <ngts-axis-arrow [axis]="0" [direction]="xDir" />
1538
+ }
1539
+ @if (!disableAxes() && activeAxes()[1]) {
1540
+ <ngts-axis-arrow [axis]="1" [direction]="yDir" />
1541
+ }
1542
+ @if (!disableAxes() && activeAxes()[2]) {
1543
+ <ngts-axis-arrow [axis]="2" [direction]="zDir" />
1544
+ }
1545
+
1546
+ @if (!disableSliders() && activeAxes()[0] && activeAxes()[1]) {
1547
+ <ngts-plane-slider [axis]="2" [dir1]="xDir" [dir2]="yDir" />
1548
+ }
1549
+ @if (!disableSliders() && activeAxes()[0] && activeAxes()[2]) {
1550
+ <ngts-plane-slider [axis]="1" [dir1]="zDir" [dir2]="xDir" />
1551
+ }
1552
+ @if (!disableSliders() && activeAxes()[2] && activeAxes()[1]) {
1553
+ <ngts-plane-slider [axis]="0" [dir1]="yDir" [dir2]="zDir" />
1554
+ }
1555
+
1556
+ @if (!disableRotations() && activeAxes()[0] && activeAxes()[1]) {
1557
+ <ngts-axis-rotator [axis]="2" [dir1]="xDir" [dir2]="yDir" />
1558
+ }
1559
+ @if (!disableRotations() && activeAxes()[0] && activeAxes()[2]) {
1560
+ <ngts-axis-rotator [axis]="1" [dir1]="zDir" [dir2]="xDir" />
1561
+ }
1562
+ @if (!disableRotations() && activeAxes()[2] && activeAxes()[1]) {
1563
+ <ngts-axis-rotator [axis]="0" [dir1]="yDir" [dir2]="zDir" />
1564
+ }
1565
+
1566
+ @if (!disableScaling() && activeAxes()[0]) {
1567
+ <ngts-scaling-sphere [axis]="0" [direction]="xDir" />
1568
+ }
1569
+ @if (!disableScaling() && activeAxes()[1]) {
1570
+ <ngts-scaling-sphere [axis]="1" [direction]="yDir" />
1571
+ }
1572
+ @if (!disableScaling() && activeAxes()[2]) {
1573
+ <ngts-scaling-sphere [axis]="2" [direction]="zDir" />
1574
+ }
1575
+ }
1576
+ </ngt-group>
1577
+ <ngt-group #children>
1578
+ <ng-content />
1579
+ </ngt-group>
1580
+ </ngt-group>
1581
+ </ngt-group>
1582
+ `,
1583
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
1584
+ changeDetection: ChangeDetectionStrategy.OnPush,
1585
+ imports: [NgtsAxisArrow, NgtsPlaneSlider, NgtsAxisRotator, NgtsScalingSphere],
1586
+ }]
1587
+ }], ctorParameters: () => [] });
1588
+
1589
+ const defaultOptions = {
1590
+ eps: 0.00001,
1591
+ horizontal: false,
1592
+ infinite: false,
1593
+ pages: 1,
1594
+ distance: 1,
1595
+ damping: 0.25,
1596
+ maxSpeed: Infinity,
1597
+ prepend: false,
1598
+ enabled: true,
1599
+ style: {},
1600
+ };
1601
+ class NgtsScrollControls {
1602
+ constructor() {
1603
+ this.progress = model(0);
1604
+ this.options = input(defaultOptions, { transform: mergeInputs(defaultOptions) });
1605
+ this.document = inject(DOCUMENT);
1606
+ this.store = injectStore();
1607
+ this.gl = this.store.select('gl');
1608
+ this.events = this.store.select('events');
1609
+ this.invalidate = this.store.select('invalidate');
1610
+ this.size = this.store.select('size');
1611
+ this.domElement = pick(this.gl, 'domElement');
1612
+ this.target = pick(this.domElement, 'parentNode');
1613
+ this._el = this.document.createElement('div');
1614
+ this._fill = this.document.createElement('div');
1615
+ this._fixed = this.document.createElement('div');
1616
+ this.style = pick(this.options, 'style');
1617
+ this.prepend = pick(this.options, 'prepend');
1618
+ this.enabled = pick(this.options, 'enabled');
1619
+ this.infinite = pick(this.options, 'infinite');
1620
+ this.maxSpeed = pick(this.options, 'maxSpeed');
1621
+ this.eps = pick(this.options, 'eps');
1622
+ this.horizontal = pick(this.options, 'horizontal');
1623
+ this.pages = pick(this.options, 'pages');
1624
+ this.distance = pick(this.options, 'distance');
1625
+ this.damping = pick(this.options, 'damping');
1626
+ this.scroll = 0;
1627
+ this.offset = 0;
1628
+ this.delta = 0;
1629
+ const autoEffect = injectAutoEffect();
1630
+ afterNextRender(() => {
1631
+ autoEffect(() => {
1632
+ const target = this.target();
1633
+ if (!target)
1634
+ return;
1635
+ const parent = target;
1636
+ const [pages, distance, horizontal, el, fill, fixed, style, prepend, domElement, events] = [
1637
+ this.pages(),
1638
+ this.distance(),
1639
+ this.horizontal(),
1640
+ this.el,
1641
+ this.fill,
1642
+ this.fixed,
1643
+ untracked(this.style),
1644
+ untracked(this.prepend),
1645
+ untracked(this.domElement),
1646
+ untracked(this.events),
1647
+ ];
1648
+ el.style.position = 'absolute';
1649
+ el.style.width = '100%';
1650
+ el.style.height = '100%';
1651
+ el.style[horizontal ? 'overflowX' : 'overflowY'] = 'auto';
1652
+ el.style[horizontal ? 'overflowY' : 'overflowX'] = 'hidden';
1653
+ el.style.top = '0px';
1654
+ el.style.left = '0px';
1655
+ for (const key in style) {
1656
+ el.style[key] = style[key];
1657
+ }
1658
+ fixed.style.position = 'sticky';
1659
+ fixed.style.top = '0px';
1660
+ fixed.style.left = '0px';
1661
+ fixed.style.width = '100%';
1662
+ fixed.style.height = '100%';
1663
+ fixed.style.overflow = 'hidden';
1664
+ el.appendChild(fixed);
1665
+ fill.style.height = horizontal ? '100%' : `${pages * distance * 100}%`;
1666
+ fill.style.width = horizontal ? `${pages * distance * 100}%` : '100%';
1667
+ fill.style.pointerEvents = 'none';
1668
+ el.appendChild(fill);
1669
+ if (prepend)
1670
+ parent.prepend(el);
1671
+ else
1672
+ parent.appendChild(el);
1673
+ // Init scroll one pixel in to allow upward/leftward scroll
1674
+ el[horizontal ? 'scrollLeft' : 'scrollTop'] = 1;
1675
+ const oldTarget = (events.connected || domElement);
1676
+ requestAnimationFrame(() => events.connect?.(el));
1677
+ const oldCompute = events.compute?.bind(events);
1678
+ this.store.snapshot.setEvents({
1679
+ compute(event, store) {
1680
+ const state = store.snapshot;
1681
+ // we are using boundingClientRect because we could not rely on target.offsetTop as canvas could be positioned anywhere in dom
1682
+ const { left, top } = parent.getBoundingClientRect();
1683
+ const offsetX = event.clientX - left;
1684
+ const offsetY = event.clientY - top;
1685
+ state.pointer.set((offsetX / state.size.width) * 2 - 1, -(offsetY / state.size.height) * 2 + 1);
1686
+ state.raycaster.setFromCamera(state.pointer, state.camera);
1687
+ },
1688
+ });
1689
+ return () => {
1690
+ parent.removeChild(el);
1691
+ this.store.snapshot.setEvents({ compute: oldCompute });
1692
+ events.connect?.(oldTarget);
1693
+ };
1694
+ });
1695
+ autoEffect(() => {
1696
+ const [el, events, size, infinite, invalidate, horizontal, enabled] = [
1697
+ this.el,
1698
+ this.events(),
1699
+ this.size(),
1700
+ this.infinite(),
1701
+ this.invalidate(),
1702
+ this.horizontal(),
1703
+ this.enabled(),
1704
+ ];
1705
+ if (events.connected !== el)
1706
+ return;
1707
+ const containerLength = size[horizontal ? 'width' : 'height'];
1708
+ const scrollLength = el[horizontal ? 'scrollWidth' : 'scrollHeight'];
1709
+ const scrollThreshold = scrollLength - containerLength;
1710
+ let current = 0;
1711
+ let disableScroll = true;
1712
+ let firstRun = true;
1713
+ const onScroll = () => {
1714
+ // Prevent first scroll because it is indirectly caused by the one pixel offset
1715
+ if (!enabled || firstRun)
1716
+ return;
1717
+ invalidate();
1718
+ current = el[horizontal ? 'scrollLeft' : 'scrollTop'];
1719
+ this.scroll = current / scrollThreshold;
1720
+ if (infinite) {
1721
+ if (!disableScroll) {
1722
+ if (current >= scrollThreshold) {
1723
+ const damp = 1 - this.offset;
1724
+ el[horizontal ? 'scrollLeft' : 'scrollTop'] = 1;
1725
+ this.scroll = this.offset = -damp;
1726
+ disableScroll = true;
1727
+ }
1728
+ else if (current <= 0) {
1729
+ const damp = 1 + this.offset;
1730
+ el[horizontal ? 'scrollLeft' : 'scrollTop'] = scrollLength;
1731
+ this.scroll = this.offset = damp;
1732
+ disableScroll = true;
1733
+ }
1734
+ }
1735
+ if (disableScroll)
1736
+ setTimeout(() => (disableScroll = false), 40);
1737
+ }
1738
+ untracked(() => {
1739
+ this.progress.set(this.scroll);
1740
+ });
1741
+ };
1742
+ el.addEventListener('scroll', onScroll, { passive: true });
1743
+ requestAnimationFrame(() => (firstRun = false));
1744
+ const onWheel = (e) => (el[horizontal ? 'scrollLeft' : 'scrollTop'] += e.deltaY / 2);
1745
+ if (horizontal)
1746
+ el.addEventListener('wheel', onWheel, { passive: true });
1747
+ return () => {
1748
+ el.removeEventListener('scroll', onScroll);
1749
+ if (horizontal)
1750
+ el.removeEventListener('wheel', onWheel);
1751
+ };
1752
+ });
1753
+ });
1754
+ let last = 0;
1755
+ injectBeforeRender(({ delta }) => {
1756
+ last = this.offset;
1757
+ easing.damp(this, 'offset', this.scroll, this.damping(), delta, this.maxSpeed(), undefined, this.eps());
1758
+ easing.damp(this, 'delta', Math.abs(last - this.offset), this.damping(), delta, this.maxSpeed(), undefined, this.eps());
1759
+ if (this.delta > this.eps())
1760
+ this.invalidate()();
1761
+ });
1762
+ }
1763
+ get el() {
1764
+ return this._el;
1765
+ }
1766
+ get fill() {
1767
+ return this._fill;
1768
+ }
1769
+ get fixed() {
1770
+ return this._fixed;
1771
+ }
1772
+ range(from, distance, margin = 0) {
1773
+ const start = from - margin;
1774
+ const end = start + distance + margin * 2;
1775
+ return this.offset < start ? 0 : this.offset > end ? 1 : (this.offset - start) / (end - start);
1776
+ }
1777
+ curve(from, distance, margin = 0) {
1778
+ return Math.sin(this.range(from, distance, margin) * Math.PI);
1779
+ }
1780
+ visible(from, distance, margin = 0) {
1781
+ const start = from - margin;
1782
+ const end = start + distance + margin * 2;
1783
+ return this.offset >= start && this.offset <= end;
1784
+ }
1785
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsScrollControls, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1786
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.0", type: NgtsScrollControls, isStandalone: true, selector: "ngts-scroll-controls", inputs: { progress: { classPropertyName: "progress", publicName: "progress", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { progress: "progressChange" }, ngImport: i0, template: `
1787
+ <ng-content />
1788
+ `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1789
+ }
1790
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsScrollControls, decorators: [{
1791
+ type: Component,
1792
+ args: [{
1793
+ selector: 'ngts-scroll-controls',
1794
+ standalone: true,
1795
+ template: `
1796
+ <ng-content />
1797
+ `,
1798
+ changeDetection: ChangeDetectionStrategy.OnPush,
1799
+ }]
1800
+ }], ctorParameters: () => [] });
1801
+ class NgtsScrollCanvas {
1802
+ constructor() {
1803
+ this.host = inject(ElementRef);
1804
+ this.scrollControls = inject(NgtsScrollControls);
1805
+ this.store = injectStore();
1806
+ this.viewport = this.store.select('viewport');
1807
+ injectBeforeRender(() => {
1808
+ const group = this.host.nativeElement;
1809
+ group.position.x = this.scrollControls.horizontal()
1810
+ ? -this.viewport().width * (this.scrollControls.pages() - 1) * this.scrollControls.offset
1811
+ : 0;
1812
+ group.position.y = this.scrollControls.horizontal()
1813
+ ? 0
1814
+ : this.viewport().height * (this.scrollControls.pages() - 1) * this.scrollControls.offset;
1815
+ });
1816
+ }
1817
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsScrollCanvas, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1818
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.0", type: NgtsScrollCanvas, isStandalone: true, selector: "ngt-group[ngtsScrollCanvas]", ngImport: i0 }); }
1819
+ }
1820
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsScrollCanvas, decorators: [{
1821
+ type: Directive,
1822
+ args: [{ selector: 'ngt-group[ngtsScrollCanvas]', standalone: true }]
1823
+ }], ctorParameters: () => [] });
1824
+ class NgtsScrollHtml extends NgtHTML {
1825
+ constructor() {
1826
+ super();
1827
+ this.scrollControls = inject(NgtsScrollControls);
1828
+ this.size = this.store.select('size');
1829
+ injectBeforeRender(() => {
1830
+ if (this.scrollControls.delta > this.scrollControls.eps()) {
1831
+ this.host.nativeElement.style.transform = `translate3d(${this.scrollControls.horizontal()
1832
+ ? -this.size().width * (this.scrollControls.pages() - 1) * this.scrollControls.offset
1833
+ : 0}px,${this.scrollControls.horizontal() ? 0 : this.size().height * (this.scrollControls.pages() - 1) * -this.scrollControls.offset}px,0)`;
1834
+ }
1835
+ });
1836
+ }
1837
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsScrollHtml, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1838
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.0", type: NgtsScrollHtml, isStandalone: true, selector: "div[ngtsScrollHTML]", host: { styleAttribute: "position: absolute; top: 0; left: 0; will-change: transform;" }, providers: [provideHTMLDomElement([NgtsScrollControls], (scrollControls) => scrollControls.fixed)], usesInheritance: true, ngImport: i0 }); }
1839
+ }
1840
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtsScrollHtml, decorators: [{
1841
+ type: Directive,
1842
+ args: [{
1843
+ selector: 'div[ngtsScrollHTML]',
1844
+ standalone: true,
1845
+ host: { style: 'position: absolute; top: 0; left: 0; will-change: transform;' },
1846
+ providers: [provideHTMLDomElement([NgtsScrollControls], (scrollControls) => scrollControls.fixed)],
1847
+ }]
1848
+ }], ctorParameters: () => [] });
182
1849
 
183
1850
  /**
184
1851
  * Generated bundle index. Do not edit.
185
1852
  */
186
1853
 
187
- export { NgtsOrbitControls };
1854
+ export { NgtsCameraControls, NgtsOrbitControls, NgtsPivotControls, NgtsScrollCanvas, NgtsScrollControls, NgtsScrollHtml };
188
1855
  //# sourceMappingURL=angular-three-soba-controls.mjs.map