angular-three 0.0.2 → 0.0.4

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 (400) hide show
  1. package/attributes/README.md +3 -0
  2. package/attributes/index.d.ts +22 -0
  3. package/attributes/lib/buffer-attribute/buffer-attribute.d.ts +8 -0
  4. package/attributes/lib/color-attribute/color-attribute.d.ts +8 -0
  5. package/attributes/lib/float16-buffer-attribute/float16-buffer-attribute.d.ts +8 -0
  6. package/attributes/lib/float32-buffer-attribute/float32-buffer-attribute.d.ts +8 -0
  7. package/attributes/lib/float64-buffer-attribute/float64-buffer-attribute.d.ts +8 -0
  8. package/attributes/lib/fog-attribute/fog-attribute.d.ts +8 -0
  9. package/attributes/lib/fog-exp2-attribute/fog-exp2-attribute.d.ts +8 -0
  10. package/attributes/lib/instanced-buffer-attribute/instanced-buffer-attribute.d.ts +8 -0
  11. package/attributes/lib/int16-buffer-attribute/int16-buffer-attribute.d.ts +8 -0
  12. package/attributes/lib/int32-buffer-attribute/int32-buffer-attribute.d.ts +8 -0
  13. package/attributes/lib/int8-buffer-attribute/int8-buffer-attribute.d.ts +8 -0
  14. package/attributes/lib/interleaved-buffer-attribute/interleaved-buffer-attribute.d.ts +8 -0
  15. package/attributes/lib/matrix3-attribute/matrix3-attribute.d.ts +8 -0
  16. package/attributes/lib/matrix4-attribute/matrix4-attribute.d.ts +8 -0
  17. package/attributes/lib/uint16-buffer-attribute/uint16-buffer-attribute.d.ts +8 -0
  18. package/attributes/lib/uint32-buffer-attribute/uint32-buffer-attribute.d.ts +8 -0
  19. package/attributes/lib/uint8-buffer-attribute/uint8-buffer-attribute.d.ts +8 -0
  20. package/attributes/lib/uint8-clamped-buffer-attribute/uint8-clamped-buffer-attribute.d.ts +8 -0
  21. package/attributes/lib/value-attribute/value-attribute.d.ts +8 -0
  22. package/attributes/lib/vector2-attribute/vector2-attribute.d.ts +8 -0
  23. package/attributes/lib/vector3-attribute/vector3-attribute.d.ts +8 -0
  24. package/attributes/lib/vector4-attribute/vector4-attribute.d.ts +8 -0
  25. package/audios/README.md +3 -0
  26. package/audios/index.d.ts +3 -0
  27. package/audios/lib/audio/audio.d.ts +49 -0
  28. package/audios/lib/audio-listener/audio-listener.d.ts +35 -0
  29. package/audios/lib/positional-audio/positional-audio.d.ts +49 -0
  30. package/cameras/README.md +3 -0
  31. package/cameras/index.d.ts +5 -0
  32. package/cameras/lib/array-camera/array-camera.d.ts +56 -0
  33. package/cameras/lib/cube-camera/cube-camera.d.ts +36 -0
  34. package/cameras/lib/orthographic-camera/orthographic-camera.d.ts +54 -0
  35. package/cameras/lib/perspective-camera/perspective-camera.d.ts +55 -0
  36. package/cameras/lib/stereo-camera/stereo-camera.d.ts +42 -0
  37. package/esm2020/attributes/angular-three-attributes.mjs +5 -0
  38. package/esm2020/attributes/index.mjs +24 -0
  39. package/esm2020/attributes/lib/buffer-attribute/buffer-attribute.mjs +25 -0
  40. package/esm2020/attributes/lib/color-attribute/color-attribute.mjs +25 -0
  41. package/esm2020/attributes/lib/float16-buffer-attribute/float16-buffer-attribute.mjs +25 -0
  42. package/esm2020/attributes/lib/float32-buffer-attribute/float32-buffer-attribute.mjs +25 -0
  43. package/esm2020/attributes/lib/float64-buffer-attribute/float64-buffer-attribute.mjs +25 -0
  44. package/esm2020/attributes/lib/fog-attribute/fog-attribute.mjs +25 -0
  45. package/esm2020/attributes/lib/fog-exp2-attribute/fog-exp2-attribute.mjs +25 -0
  46. package/esm2020/attributes/lib/instanced-buffer-attribute/instanced-buffer-attribute.mjs +25 -0
  47. package/esm2020/attributes/lib/int16-buffer-attribute/int16-buffer-attribute.mjs +25 -0
  48. package/esm2020/attributes/lib/int32-buffer-attribute/int32-buffer-attribute.mjs +25 -0
  49. package/esm2020/attributes/lib/int8-buffer-attribute/int8-buffer-attribute.mjs +25 -0
  50. package/esm2020/attributes/lib/interleaved-buffer-attribute/interleaved-buffer-attribute.mjs +29 -0
  51. package/esm2020/attributes/lib/matrix3-attribute/matrix3-attribute.mjs +25 -0
  52. package/esm2020/attributes/lib/matrix4-attribute/matrix4-attribute.mjs +25 -0
  53. package/esm2020/attributes/lib/uint16-buffer-attribute/uint16-buffer-attribute.mjs +25 -0
  54. package/esm2020/attributes/lib/uint32-buffer-attribute/uint32-buffer-attribute.mjs +25 -0
  55. package/esm2020/attributes/lib/uint8-buffer-attribute/uint8-buffer-attribute.mjs +25 -0
  56. package/esm2020/attributes/lib/uint8-clamped-buffer-attribute/uint8-clamped-buffer-attribute.mjs +25 -0
  57. package/esm2020/attributes/lib/value-attribute/value-attribute.mjs +27 -0
  58. package/esm2020/attributes/lib/vector2-attribute/vector2-attribute.mjs +25 -0
  59. package/esm2020/attributes/lib/vector3-attribute/vector3-attribute.mjs +25 -0
  60. package/esm2020/attributes/lib/vector4-attribute/vector4-attribute.mjs +25 -0
  61. package/esm2020/audios/angular-three-audios.mjs +5 -0
  62. package/esm2020/audios/index.mjs +5 -0
  63. package/esm2020/audios/lib/audio/audio.mjs +68 -0
  64. package/esm2020/audios/lib/audio-listener/audio-listener.mjs +65 -0
  65. package/esm2020/audios/lib/positional-audio/positional-audio.mjs +68 -0
  66. package/esm2020/cameras/angular-three-cameras.mjs +5 -0
  67. package/esm2020/cameras/index.mjs +7 -0
  68. package/esm2020/cameras/lib/array-camera/array-camera.mjs +67 -0
  69. package/esm2020/cameras/lib/cube-camera/cube-camera.mjs +55 -0
  70. package/esm2020/cameras/lib/orthographic-camera/orthographic-camera.mjs +65 -0
  71. package/esm2020/cameras/lib/perspective-camera/perspective-camera.mjs +66 -0
  72. package/esm2020/cameras/lib/stereo-camera/stereo-camera.mjs +61 -0
  73. package/esm2020/geometries/angular-three-geometries.mjs +5 -0
  74. package/esm2020/geometries/index.mjs +25 -0
  75. package/esm2020/geometries/lib/box-geometry/box-geometry.mjs +25 -0
  76. package/esm2020/geometries/lib/buffer-geometry/buffer-geometry.mjs +25 -0
  77. package/esm2020/geometries/lib/capsule-geometry/capsule-geometry.mjs +25 -0
  78. package/esm2020/geometries/lib/circle-geometry/circle-geometry.mjs +25 -0
  79. package/esm2020/geometries/lib/cone-geometry/cone-geometry.mjs +25 -0
  80. package/esm2020/geometries/lib/cylinder-geometry/cylinder-geometry.mjs +25 -0
  81. package/esm2020/geometries/lib/dodecahedron-geometry/dodecahedron-geometry.mjs +25 -0
  82. package/esm2020/geometries/lib/edges-geometry/edges-geometry.mjs +25 -0
  83. package/esm2020/geometries/lib/extrude-geometry/extrude-geometry.mjs +25 -0
  84. package/esm2020/geometries/lib/icosahedron-geometry/icosahedron-geometry.mjs +25 -0
  85. package/esm2020/geometries/lib/instanced-buffer-geometry/instanced-buffer-geometry.mjs +25 -0
  86. package/esm2020/geometries/lib/lathe-geometry/lathe-geometry.mjs +25 -0
  87. package/esm2020/geometries/lib/octahedron-geometry/octahedron-geometry.mjs +25 -0
  88. package/esm2020/geometries/lib/plane-geometry/plane-geometry.mjs +25 -0
  89. package/esm2020/geometries/lib/polyhedron-geometry/polyhedron-geometry.mjs +25 -0
  90. package/esm2020/geometries/lib/ring-geometry/ring-geometry.mjs +25 -0
  91. package/esm2020/geometries/lib/shape-geometry/shape-geometry.mjs +25 -0
  92. package/esm2020/geometries/lib/sphere-geometry/sphere-geometry.mjs +25 -0
  93. package/esm2020/geometries/lib/tetrahedron-geometry/tetrahedron-geometry.mjs +25 -0
  94. package/esm2020/geometries/lib/torus-geometry/torus-geometry.mjs +25 -0
  95. package/esm2020/geometries/lib/torus-knot-geometry/torus-knot-geometry.mjs +25 -0
  96. package/esm2020/geometries/lib/tube-geometry/tube-geometry.mjs +25 -0
  97. package/esm2020/geometries/lib/wireframe-geometry/wireframe-geometry.mjs +25 -0
  98. package/esm2020/helpers/angular-three-helpers.mjs +5 -0
  99. package/esm2020/helpers/index.mjs +15 -0
  100. package/esm2020/helpers/lib/arrow-helper/arrow-helper.mjs +25 -0
  101. package/esm2020/helpers/lib/axes-helper/axes-helper.mjs +25 -0
  102. package/esm2020/helpers/lib/box-helper/box-helper.mjs +35 -0
  103. package/esm2020/helpers/lib/box3-helper/box3-helper.mjs +35 -0
  104. package/esm2020/helpers/lib/camera-helper/camera-helper.mjs +35 -0
  105. package/esm2020/helpers/lib/directional-light-helper/directional-light-helper.mjs +35 -0
  106. package/esm2020/helpers/lib/grid-helper/grid-helper.mjs +25 -0
  107. package/esm2020/helpers/lib/hemisphere-light-helper/hemisphere-light-helper.mjs +35 -0
  108. package/esm2020/helpers/lib/plane-helper/plane-helper.mjs +35 -0
  109. package/esm2020/helpers/lib/point-light-helper/point-light-helper.mjs +35 -0
  110. package/esm2020/helpers/lib/polar-grid-helper/polar-grid-helper.mjs +25 -0
  111. package/esm2020/helpers/lib/skeleton-helper/skeleton-helper.mjs +35 -0
  112. package/esm2020/helpers/lib/spot-light-helper/spot-light-helper.mjs +35 -0
  113. package/esm2020/index.mjs +39 -2
  114. package/esm2020/lib/canvas.mjs +229 -0
  115. package/esm2020/lib/di/resize.mjs +19 -0
  116. package/esm2020/lib/di/window.mjs +13 -0
  117. package/esm2020/lib/directives/args.mjs +30 -0
  118. package/esm2020/lib/directives/cursor.mjs +35 -0
  119. package/esm2020/lib/directives/repeat.mjs +20 -0
  120. package/esm2020/lib/events.mjs +53 -0
  121. package/esm2020/lib/instance.mjs +368 -0
  122. package/esm2020/lib/pipes/math.mjs +15 -0
  123. package/esm2020/lib/pipes/pi.mjs +14 -0
  124. package/esm2020/lib/pipes/radian.mjs +14 -0
  125. package/esm2020/lib/pipes/side.mjs +22 -0
  126. package/esm2020/lib/ref.mjs +15 -0
  127. package/esm2020/lib/services/loader.mjs +45 -0
  128. package/esm2020/lib/services/resize.mjs +127 -0
  129. package/esm2020/lib/stores/component-store.mjs +137 -0
  130. package/esm2020/lib/stores/store.mjs +433 -0
  131. package/esm2020/lib/types.mjs +2 -0
  132. package/esm2020/lib/utils/apply-props.mjs +135 -0
  133. package/esm2020/lib/utils/build-graph.mjs +15 -0
  134. package/esm2020/lib/utils/camera.mjs +28 -0
  135. package/esm2020/lib/utils/capitalize.mjs +4 -0
  136. package/esm2020/lib/utils/check-update.mjs +22 -0
  137. package/esm2020/lib/utils/events.mjs +353 -0
  138. package/esm2020/lib/utils/get-instance-local-state.mjs +6 -0
  139. package/esm2020/lib/utils/inject.mjs +18 -0
  140. package/esm2020/lib/utils/instance.mjs +35 -0
  141. package/esm2020/lib/utils/is.mjs +54 -0
  142. package/esm2020/lib/utils/loop.mjs +139 -0
  143. package/esm2020/lib/utils/make.mjs +30 -0
  144. package/esm2020/lib/utils/mutate.mjs +24 -0
  145. package/esm2020/lib/utils/proxy.mjs +99 -0
  146. package/esm2020/lib/utils/renderer.mjs +15 -0
  147. package/esm2020/lights/angular-three-lights.mjs +5 -0
  148. package/esm2020/lights/index.mjs +11 -0
  149. package/esm2020/lights/lib/ambient-light/ambient-light.mjs +58 -0
  150. package/esm2020/lights/lib/ambient-light-probe/ambient-light-probe.mjs +59 -0
  151. package/esm2020/lights/lib/directional-light/directional-light.mjs +59 -0
  152. package/esm2020/lights/lib/hemisphere-light/hemisphere-light.mjs +60 -0
  153. package/esm2020/lights/lib/hemisphere-light-probe/hemisphere-light-probe.mjs +61 -0
  154. package/esm2020/lights/lib/light-probe/light-probe.mjs +59 -0
  155. package/esm2020/lights/lib/point-light/point-light.mjs +61 -0
  156. package/esm2020/lights/lib/rect-area-light/rect-area-light.mjs +61 -0
  157. package/esm2020/lights/lib/spot-light/spot-light.mjs +64 -0
  158. package/esm2020/materials/angular-three-materials.mjs +5 -0
  159. package/esm2020/materials/index.mjs +19 -0
  160. package/esm2020/materials/lib/line-basic-material/line-basic-material.mjs +76 -0
  161. package/esm2020/materials/lib/line-dashed-material/line-dashed-material.mjs +79 -0
  162. package/esm2020/materials/lib/mesh-basic-material/mesh-basic-material.mjs +88 -0
  163. package/esm2020/materials/lib/mesh-depth-material/mesh-depth-material.mjs +79 -0
  164. package/esm2020/materials/lib/mesh-distance-material/mesh-distance-material.mjs +79 -0
  165. package/esm2020/materials/lib/mesh-lambert-material/mesh-lambert-material.mjs +99 -0
  166. package/esm2020/materials/lib/mesh-matcap-material/mesh-matcap-material.mjs +85 -0
  167. package/esm2020/materials/lib/mesh-normal-material/mesh-normal-material.mjs +82 -0
  168. package/esm2020/materials/lib/mesh-phong-material/mesh-phong-material.mjs +102 -0
  169. package/esm2020/materials/lib/mesh-physical-material/mesh-physical-material.mjs +118 -0
  170. package/esm2020/materials/lib/mesh-standard-material/mesh-standard-material.mjs +99 -0
  171. package/esm2020/materials/lib/mesh-toon-material/mesh-toon-material.mjs +95 -0
  172. package/esm2020/materials/lib/points-material/points-material.mjs +77 -0
  173. package/esm2020/materials/lib/raw-shader-material/raw-shader-material.mjs +82 -0
  174. package/esm2020/materials/lib/shader-material/shader-material.mjs +82 -0
  175. package/esm2020/materials/lib/shadow-material/shadow-material.mjs +73 -0
  176. package/esm2020/materials/lib/sprite-material/sprite-material.mjs +77 -0
  177. package/esm2020/objects/angular-three-objects.mjs +5 -0
  178. package/esm2020/objects/index.mjs +14 -0
  179. package/esm2020/objects/lib/bone/bone.mjs +54 -0
  180. package/esm2020/objects/lib/group/group.mjs +54 -0
  181. package/esm2020/objects/lib/instanced-mesh/instanced-mesh.mjs +63 -0
  182. package/esm2020/objects/lib/line/line.mjs +58 -0
  183. package/esm2020/objects/lib/line-loop/line-loop.mjs +58 -0
  184. package/esm2020/objects/lib/line-segments/line-segments.mjs +58 -0
  185. package/esm2020/objects/lib/lod/lod.mjs +56 -0
  186. package/esm2020/objects/lib/mesh/mesh.mjs +58 -0
  187. package/esm2020/objects/lib/points/points.mjs +58 -0
  188. package/esm2020/objects/lib/skeleton/skeleton.mjs +40 -0
  189. package/esm2020/objects/lib/skinned-mesh/skinned-mesh.mjs +62 -0
  190. package/esm2020/objects/lib/sprite/sprite.mjs +57 -0
  191. package/esm2020/primitives/angular-three-primitives.mjs +5 -0
  192. package/esm2020/primitives/index.mjs +3 -0
  193. package/esm2020/primitives/lib/object-primitive/object-primitive.mjs +54 -0
  194. package/esm2020/primitives/lib/primitive/primitive.mjs +37 -0
  195. package/esm2020/stats/angular-three-stats.mjs +5 -0
  196. package/esm2020/stats/index.mjs +2 -0
  197. package/esm2020/stats/lib/stats/stats.mjs +54 -0
  198. package/esm2020/textures/angular-three-textures.mjs +5 -0
  199. package/esm2020/textures/index.mjs +12 -0
  200. package/esm2020/textures/lib/canvas-texture/canvas-texture.mjs +25 -0
  201. package/esm2020/textures/lib/compressed-array-texture/compressed-array-texture.mjs +25 -0
  202. package/esm2020/textures/lib/compressed-texture/compressed-texture.mjs +25 -0
  203. package/esm2020/textures/lib/cube-texture/cube-texture.mjs +25 -0
  204. package/esm2020/textures/lib/data-array-texture/data-array-texture.mjs +25 -0
  205. package/esm2020/textures/lib/data-texture/data-texture.mjs +25 -0
  206. package/esm2020/textures/lib/data3-dtexture/data3-dtexture.mjs +25 -0
  207. package/esm2020/textures/lib/depth-texture/depth-texture.mjs +25 -0
  208. package/esm2020/textures/lib/framebuffer-texture/framebuffer-texture.mjs +25 -0
  209. package/esm2020/textures/lib/video-texture/video-texture.mjs +25 -0
  210. package/fesm2015/angular-three-attributes.mjs +462 -0
  211. package/fesm2015/angular-three-attributes.mjs.map +1 -0
  212. package/fesm2015/angular-three-audios.mjs +201 -0
  213. package/fesm2015/angular-three-audios.mjs.map +1 -0
  214. package/fesm2015/angular-three-cameras.mjs +304 -0
  215. package/fesm2015/angular-three-cameras.mjs.map +1 -0
  216. package/fesm2015/angular-three-geometries.mjs +475 -0
  217. package/fesm2015/angular-three-geometries.mjs.map +1 -0
  218. package/fesm2015/angular-three-helpers.mjs +365 -0
  219. package/fesm2015/angular-three-helpers.mjs.map +1 -0
  220. package/fesm2015/angular-three-lights.mjs +511 -0
  221. package/fesm2015/angular-three-lights.mjs.map +1 -0
  222. package/fesm2015/angular-three-materials.mjs +1402 -0
  223. package/fesm2015/angular-three-materials.mjs.map +1 -0
  224. package/fesm2015/angular-three-objects.mjs +630 -0
  225. package/fesm2015/angular-three-objects.mjs.map +1 -0
  226. package/fesm2015/angular-three-primitives.mjs +95 -0
  227. package/fesm2015/angular-three-primitives.mjs.map +1 -0
  228. package/fesm2015/angular-three-stats.mjs +62 -0
  229. package/fesm2015/angular-three-stats.mjs.map +1 -0
  230. package/fesm2015/angular-three-textures.mjs +215 -0
  231. package/fesm2015/angular-three-textures.mjs.map +1 -0
  232. package/fesm2015/angular-three.mjs +2448 -10
  233. package/fesm2015/angular-three.mjs.map +1 -1
  234. package/fesm2020/angular-three-attributes.mjs +462 -0
  235. package/fesm2020/angular-three-attributes.mjs.map +1 -0
  236. package/fesm2020/angular-three-audios.mjs +201 -0
  237. package/fesm2020/angular-three-audios.mjs.map +1 -0
  238. package/fesm2020/angular-three-cameras.mjs +304 -0
  239. package/fesm2020/angular-three-cameras.mjs.map +1 -0
  240. package/fesm2020/angular-three-geometries.mjs +475 -0
  241. package/fesm2020/angular-three-geometries.mjs.map +1 -0
  242. package/fesm2020/angular-three-helpers.mjs +365 -0
  243. package/fesm2020/angular-three-helpers.mjs.map +1 -0
  244. package/fesm2020/angular-three-lights.mjs +511 -0
  245. package/fesm2020/angular-three-lights.mjs.map +1 -0
  246. package/fesm2020/angular-three-materials.mjs +1402 -0
  247. package/fesm2020/angular-three-materials.mjs.map +1 -0
  248. package/fesm2020/angular-three-objects.mjs +630 -0
  249. package/fesm2020/angular-three-objects.mjs.map +1 -0
  250. package/fesm2020/angular-three-primitives.mjs +95 -0
  251. package/fesm2020/angular-three-primitives.mjs.map +1 -0
  252. package/fesm2020/angular-three-stats.mjs +62 -0
  253. package/fesm2020/angular-three-stats.mjs.map +1 -0
  254. package/fesm2020/angular-three-textures.mjs +215 -0
  255. package/fesm2020/angular-three-textures.mjs.map +1 -0
  256. package/fesm2020/angular-three.mjs +2462 -10
  257. package/fesm2020/angular-three.mjs.map +1 -1
  258. package/geometries/README.md +3 -0
  259. package/geometries/index.d.ts +23 -0
  260. package/geometries/lib/box-geometry/box-geometry.d.ts +8 -0
  261. package/geometries/lib/buffer-geometry/buffer-geometry.d.ts +8 -0
  262. package/geometries/lib/capsule-geometry/capsule-geometry.d.ts +8 -0
  263. package/geometries/lib/circle-geometry/circle-geometry.d.ts +8 -0
  264. package/geometries/lib/cone-geometry/cone-geometry.d.ts +8 -0
  265. package/geometries/lib/cylinder-geometry/cylinder-geometry.d.ts +8 -0
  266. package/geometries/lib/dodecahedron-geometry/dodecahedron-geometry.d.ts +8 -0
  267. package/geometries/lib/edges-geometry/edges-geometry.d.ts +8 -0
  268. package/geometries/lib/extrude-geometry/extrude-geometry.d.ts +8 -0
  269. package/geometries/lib/icosahedron-geometry/icosahedron-geometry.d.ts +8 -0
  270. package/geometries/lib/instanced-buffer-geometry/instanced-buffer-geometry.d.ts +8 -0
  271. package/geometries/lib/lathe-geometry/lathe-geometry.d.ts +8 -0
  272. package/geometries/lib/octahedron-geometry/octahedron-geometry.d.ts +8 -0
  273. package/geometries/lib/plane-geometry/plane-geometry.d.ts +8 -0
  274. package/geometries/lib/polyhedron-geometry/polyhedron-geometry.d.ts +8 -0
  275. package/geometries/lib/ring-geometry/ring-geometry.d.ts +8 -0
  276. package/geometries/lib/shape-geometry/shape-geometry.d.ts +8 -0
  277. package/geometries/lib/sphere-geometry/sphere-geometry.d.ts +8 -0
  278. package/geometries/lib/tetrahedron-geometry/tetrahedron-geometry.d.ts +8 -0
  279. package/geometries/lib/torus-geometry/torus-geometry.d.ts +8 -0
  280. package/geometries/lib/torus-knot-geometry/torus-knot-geometry.d.ts +8 -0
  281. package/geometries/lib/tube-geometry/tube-geometry.d.ts +8 -0
  282. package/geometries/lib/wireframe-geometry/wireframe-geometry.d.ts +8 -0
  283. package/helpers/README.md +3 -0
  284. package/helpers/index.d.ts +13 -0
  285. package/helpers/lib/arrow-helper/arrow-helper.d.ts +8 -0
  286. package/helpers/lib/axes-helper/axes-helper.d.ts +8 -0
  287. package/helpers/lib/box-helper/box-helper.d.ts +8 -0
  288. package/helpers/lib/box3-helper/box3-helper.d.ts +8 -0
  289. package/helpers/lib/camera-helper/camera-helper.d.ts +8 -0
  290. package/helpers/lib/directional-light-helper/directional-light-helper.d.ts +8 -0
  291. package/helpers/lib/grid-helper/grid-helper.d.ts +8 -0
  292. package/helpers/lib/hemisphere-light-helper/hemisphere-light-helper.d.ts +8 -0
  293. package/helpers/lib/plane-helper/plane-helper.d.ts +8 -0
  294. package/helpers/lib/point-light-helper/point-light-helper.d.ts +8 -0
  295. package/helpers/lib/polar-grid-helper/polar-grid-helper.d.ts +8 -0
  296. package/helpers/lib/skeleton-helper/skeleton-helper.d.ts +8 -0
  297. package/helpers/lib/spot-light-helper/spot-light-helper.d.ts +8 -0
  298. package/index.d.ts +38 -1
  299. package/lib/canvas.d.ts +46 -0
  300. package/lib/di/resize.d.ts +12 -0
  301. package/lib/di/window.d.ts +1 -0
  302. package/lib/directives/args.d.ts +19 -0
  303. package/lib/directives/cursor.d.ts +7 -0
  304. package/lib/directives/repeat.d.ts +7 -0
  305. package/lib/events.d.ts +2 -0
  306. package/lib/instance.d.ts +81 -0
  307. package/lib/pipes/math.d.ts +7 -0
  308. package/lib/pipes/pi.d.ts +7 -0
  309. package/lib/pipes/radian.d.ts +7 -0
  310. package/lib/pipes/side.d.ts +8 -0
  311. package/lib/ref.d.ts +5 -0
  312. package/lib/services/loader.d.ts +11 -0
  313. package/lib/services/resize.d.ts +19 -0
  314. package/lib/stores/component-store.d.ts +69 -0
  315. package/lib/stores/store.d.ts +32 -0
  316. package/lib/types.d.ts +358 -0
  317. package/lib/utils/apply-props.d.ts +6 -0
  318. package/lib/utils/build-graph.d.ts +3 -0
  319. package/lib/utils/camera.d.ts +4 -0
  320. package/lib/utils/capitalize.d.ts +1 -0
  321. package/lib/utils/check-update.d.ts +2 -0
  322. package/lib/utils/events.d.ts +6 -0
  323. package/lib/utils/get-instance-local-state.d.ts +2 -0
  324. package/lib/utils/inject.d.ts +9 -0
  325. package/lib/utils/instance.d.ts +4 -0
  326. package/lib/utils/is.d.ts +21 -0
  327. package/lib/utils/loop.d.ts +32 -0
  328. package/lib/utils/make.d.ts +4 -0
  329. package/lib/utils/mutate.d.ts +2 -0
  330. package/lib/utils/proxy.d.ts +7 -0
  331. package/lib/utils/renderer.d.ts +3 -0
  332. package/lights/README.md +3 -0
  333. package/lights/index.d.ts +9 -0
  334. package/lights/lib/ambient-light/ambient-light.d.ts +39 -0
  335. package/lights/lib/ambient-light-probe/ambient-light-probe.d.ts +40 -0
  336. package/lights/lib/directional-light/directional-light.d.ts +40 -0
  337. package/lights/lib/hemisphere-light/hemisphere-light.d.ts +41 -0
  338. package/lights/lib/hemisphere-light-probe/hemisphere-light-probe.d.ts +42 -0
  339. package/lights/lib/light-probe/light-probe.d.ts +40 -0
  340. package/lights/lib/point-light/point-light.d.ts +42 -0
  341. package/lights/lib/rect-area-light/rect-area-light.d.ts +42 -0
  342. package/lights/lib/spot-light/spot-light.d.ts +45 -0
  343. package/materials/README.md +3 -0
  344. package/materials/index.d.ts +17 -0
  345. package/materials/lib/line-basic-material/line-basic-material.d.ts +55 -0
  346. package/materials/lib/line-dashed-material/line-dashed-material.d.ts +58 -0
  347. package/materials/lib/mesh-basic-material/mesh-basic-material.d.ts +67 -0
  348. package/materials/lib/mesh-depth-material/mesh-depth-material.d.ts +58 -0
  349. package/materials/lib/mesh-distance-material/mesh-distance-material.d.ts +58 -0
  350. package/materials/lib/mesh-lambert-material/mesh-lambert-material.d.ts +78 -0
  351. package/materials/lib/mesh-matcap-material/mesh-matcap-material.d.ts +64 -0
  352. package/materials/lib/mesh-normal-material/mesh-normal-material.d.ts +61 -0
  353. package/materials/lib/mesh-phong-material/mesh-phong-material.d.ts +81 -0
  354. package/materials/lib/mesh-physical-material/mesh-physical-material.d.ts +97 -0
  355. package/materials/lib/mesh-standard-material/mesh-standard-material.d.ts +78 -0
  356. package/materials/lib/mesh-toon-material/mesh-toon-material.d.ts +74 -0
  357. package/materials/lib/points-material/points-material.d.ts +56 -0
  358. package/materials/lib/raw-shader-material/raw-shader-material.d.ts +68 -0
  359. package/materials/lib/shader-material/shader-material.d.ts +68 -0
  360. package/materials/lib/shadow-material/shadow-material.d.ts +52 -0
  361. package/materials/lib/sprite-material/sprite-material.d.ts +56 -0
  362. package/objects/README.md +3 -0
  363. package/objects/index.d.ts +12 -0
  364. package/objects/lib/bone/bone.d.ts +35 -0
  365. package/objects/lib/group/group.d.ts +35 -0
  366. package/objects/lib/instanced-mesh/instanced-mesh.d.ts +44 -0
  367. package/objects/lib/line/line.d.ts +41 -0
  368. package/objects/lib/line-loop/line-loop.d.ts +41 -0
  369. package/objects/lib/line-segments/line-segments.d.ts +41 -0
  370. package/objects/lib/lod/lod.d.ts +40 -0
  371. package/objects/lib/mesh/mesh.d.ts +41 -0
  372. package/objects/lib/points/points.d.ts +41 -0
  373. package/objects/lib/skeleton/skeleton.d.ts +16 -0
  374. package/objects/lib/skinned-mesh/skinned-mesh.d.ts +45 -0
  375. package/objects/lib/sprite/sprite.d.ts +38 -0
  376. package/package.json +93 -2
  377. package/primitives/README.md +3 -0
  378. package/primitives/index.d.ts +2 -0
  379. package/primitives/lib/object-primitive/object-primitive.d.ts +35 -0
  380. package/primitives/lib/primitive/primitive.d.ts +10 -0
  381. package/schematics/src/generators/init/generator.d.ts +1 -1
  382. package/schematics/src/generators/init/generator.js +4 -4
  383. package/schematics/src/generators/init/generator.js.map +1 -1
  384. package/stats/README.md +3 -0
  385. package/stats/index.d.ts +1 -0
  386. package/stats/lib/stats/stats.d.ts +16 -0
  387. package/textures/README.md +3 -0
  388. package/textures/index.d.ts +10 -0
  389. package/textures/lib/canvas-texture/canvas-texture.d.ts +8 -0
  390. package/textures/lib/compressed-array-texture/compressed-array-texture.d.ts +8 -0
  391. package/textures/lib/compressed-texture/compressed-texture.d.ts +8 -0
  392. package/textures/lib/cube-texture/cube-texture.d.ts +8 -0
  393. package/textures/lib/data-array-texture/data-array-texture.d.ts +8 -0
  394. package/textures/lib/data-texture/data-texture.d.ts +8 -0
  395. package/textures/lib/data3-dtexture/data3-dtexture.d.ts +8 -0
  396. package/textures/lib/depth-texture/depth-texture.d.ts +8 -0
  397. package/textures/lib/framebuffer-texture/framebuffer-texture.d.ts +8 -0
  398. package/textures/lib/video-texture/video-texture.d.ts +8 -0
  399. package/esm2020/lib/angular-three.module.mjs +0 -15
  400. package/lib/angular-three.module.d.ts +0 -7
@@ -1,22 +1,2460 @@
1
+ import { DOCUMENT, NgIf, NgTemplateOutlet, AsyncPipe, NgForOf } from '@angular/common';
1
2
  import * as i0 from '@angular/core';
2
- import { NgModule } from '@angular/core';
3
- import { CommonModule } from '@angular/common';
3
+ import { Injectable, InjectionToken, inject, NgZone, EventEmitter, Directive, Input, Output, ElementRef, Component, TemplateRef, ChangeDetectionStrategy, HostBinding, ViewChild, ContentChild, ViewContainerRef, Injector, Optional, Self, Inject, Pipe } from '@angular/core';
4
+ import * as THREE from 'three';
5
+ import { BehaviorSubject, filter, noop, tap, isObservable, combineLatest, Observable, Subject, pipe, debounceTime, takeUntil, fromEvent, share, ReplaySubject, from, retry, catchError, of, forkJoin, map, merge } from 'rxjs';
6
+ import { ComponentStore } from '@ngrx/component-store';
7
+ import { __rest } from 'tslib';
4
8
 
5
- class AngularThreeModule {
9
+ function getInstanceLocalState(obj) {
10
+ if (!obj)
11
+ return undefined;
12
+ return obj['__ngt__'];
6
13
  }
7
- AngularThreeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: AngularThreeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
8
- AngularThreeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.0", ngImport: i0, type: AngularThreeModule, imports: [CommonModule] });
9
- AngularThreeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: AngularThreeModule, imports: [CommonModule] });
10
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: AngularThreeModule, decorators: [{
11
- type: NgModule,
14
+
15
+ const idCache = {};
16
+ function makeId(event) {
17
+ if (event) {
18
+ return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
19
+ }
20
+ const newId = THREE.MathUtils.generateUUID();
21
+ // ensure not already used
22
+ if (!idCache[newId]) {
23
+ idCache[newId] = true;
24
+ return newId;
25
+ }
26
+ return makeId();
27
+ }
28
+ function makeDpr(dpr, window) {
29
+ const target = (window === null || window === void 0 ? void 0 : window.devicePixelRatio) || 1;
30
+ return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
31
+ }
32
+ function make(type, input) {
33
+ if (!input)
34
+ return new type();
35
+ if (input instanceof type) {
36
+ return input;
37
+ }
38
+ if (!Array.isArray(input)) {
39
+ input = typeof input === 'number' ? [input, input, input, input] : [input];
40
+ }
41
+ return new type(...input);
42
+ }
43
+
44
+ /**
45
+ * Release pointer captures.
46
+ * This is called by releasePointerCapture in the API, and when an object is removed.
47
+ */
48
+ function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
49
+ const captureData = captures.get(obj);
50
+ if (captureData) {
51
+ captures.delete(obj);
52
+ // If this was the last capturing object for this pointer
53
+ if (captures.size === 0) {
54
+ capturedMap.delete(pointerId);
55
+ captureData.target.releasePointerCapture(pointerId);
56
+ }
57
+ }
58
+ }
59
+ function removeInteractivity(stateFactory, object) {
60
+ const { internal } = stateFactory();
61
+ // Removes every trace of an object from the data store
62
+ internal.interaction = internal.interaction.filter((o) => o !== object);
63
+ internal.initialHits = internal.initialHits.filter((o) => o !== object);
64
+ internal.hovered.forEach((value, key) => {
65
+ if (value.eventObject === object || value.object === object) {
66
+ // Clear out intersects, they are outdated by now
67
+ internal.hovered.delete(key);
68
+ }
69
+ });
70
+ internal.capturedMap.forEach((captures, pointerId) => {
71
+ releaseInternalPointerCapture(internal.capturedMap, object, captures, pointerId);
72
+ });
73
+ }
74
+ function createEvents(stateFactory) {
75
+ /** Calculates delta */
76
+ function calculateDistance(event) {
77
+ const { internal } = stateFactory();
78
+ const dx = event.offsetX - internal.initialClick[0];
79
+ const dy = event.offsetY - internal.initialClick[1];
80
+ return Math.round(Math.sqrt(dx * dx + dy * dy));
81
+ }
82
+ /** Returns true if an instance has a valid pointer-event registered, this excludes scroll, clicks etc */
83
+ function filterPointerEvents(objects) {
84
+ return objects.filter((obj) => ['move', 'over', 'enter', 'out', 'leave'].some((name) => {
85
+ var _a;
86
+ const eventName = ('pointer' + name);
87
+ return (_a = getInstanceLocalState(obj)) === null || _a === void 0 ? void 0 : _a.handlers[eventName];
88
+ }));
89
+ }
90
+ function intersect(event, filter) {
91
+ var _a, _b, _c, _d;
92
+ const state = stateFactory();
93
+ const duplicates = new Set();
94
+ const intersections = [];
95
+ // Allow callers to eliminate event objects
96
+ const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
97
+ // Reset all raycaster cameras to undefined
98
+ for (let i = 0; i < eventsObjects.length; i++) {
99
+ const instanceState = (_a = getInstanceLocalState(eventsObjects[i])) === null || _a === void 0 ? void 0 : _a.stateFactory();
100
+ if (instanceState) {
101
+ instanceState.raycaster.camera = undefined;
102
+ }
103
+ }
104
+ if (!state.previousStateFactory) {
105
+ // Make sure root-level pointer and ray are set up
106
+ (_c = (_b = state.events).compute) === null || _c === void 0 ? void 0 : _c.call(_b, event, () => state);
107
+ }
108
+ function handleRaycast(obj) {
109
+ var _a, _b, _c;
110
+ const state = (_a = getInstanceLocalState(obj)) === null || _a === void 0 ? void 0 : _a.stateFactory();
111
+ // Skip event handling when noEvents is set, or when the raycasters camera is null
112
+ if (!state || !state.events.enabled || state.raycaster.camera === null)
113
+ return [];
114
+ // When the camera is undefined we have to call the event layers update function
115
+ if (state.raycaster.camera === undefined) {
116
+ (_c = (_b = state.events).compute) === null || _c === void 0 ? void 0 : _c.call(_b, event, () => state, state.previousStateFactory);
117
+ // If the camera is still undefined we have to skip this layer entirely
118
+ if (state.raycaster.camera === undefined)
119
+ state.raycaster.camera = null;
120
+ }
121
+ // Intersect object by object
122
+ return state.raycaster.camera ? state.raycaster.intersectObject(obj, true) : [];
123
+ }
124
+ // Collect events
125
+ let hits = eventsObjects
126
+ // Intersect objects
127
+ .flatMap(handleRaycast)
128
+ // Sort by event priority and distance
129
+ .sort((a, b) => {
130
+ var _a, _b;
131
+ const aState = (_a = getInstanceLocalState(a.object)) === null || _a === void 0 ? void 0 : _a.stateFactory();
132
+ const bState = (_b = getInstanceLocalState(b.object)) === null || _b === void 0 ? void 0 : _b.stateFactory();
133
+ if (!aState || !bState)
134
+ return 0;
135
+ return bState.events.priority - aState.events.priority || a.distance - b.distance;
136
+ })
137
+ // Filter out duplicates
138
+ .filter((item) => {
139
+ const id = makeId(item);
140
+ if (duplicates.has(id))
141
+ return false;
142
+ duplicates.add(id);
143
+ return true;
144
+ });
145
+ // https://github.com/mrdoob/three.js/issues/16031
146
+ // Allow custom userland intersect sort order, this likely only makes sense on the root filter
147
+ if (state.events.filter)
148
+ hits = state.events.filter(hits, () => state);
149
+ // Bubble up the events, find the event source (eventObject)
150
+ for (const hit of hits) {
151
+ let eventObject = hit.object;
152
+ // Bubble event up
153
+ while (eventObject) {
154
+ if ((_d = getInstanceLocalState(eventObject)) === null || _d === void 0 ? void 0 : _d.eventCount)
155
+ intersections.push(Object.assign(Object.assign({}, hit), { eventObject }));
156
+ eventObject = eventObject.parent;
157
+ }
158
+ }
159
+ // If the interaction is captured, make all capturing targets part of the intersect.
160
+ if ('pointerId' in event && state.internal.capturedMap.has(event.pointerId)) {
161
+ for (const captureData of state.internal.capturedMap.get(event.pointerId).values()) {
162
+ intersections.push(captureData.intersection);
163
+ }
164
+ }
165
+ return intersections;
166
+ }
167
+ /** Handles intersections by forwarding them to handlers */
168
+ function handleIntersects(intersections, event, delta, callback) {
169
+ var _a;
170
+ const rootState = stateFactory();
171
+ // If anything has been found, forward it to the event listeners
172
+ if (intersections.length) {
173
+ const localState = { stopped: false };
174
+ for (const hit of intersections) {
175
+ const state = ((_a = getInstanceLocalState(hit.object)) === null || _a === void 0 ? void 0 : _a.stateFactory()) || rootState;
176
+ const { raycaster, pointer, camera, internal } = state;
177
+ const unprojectedPoint = new THREE.Vector3(pointer.x, pointer.y, 0).unproject(camera);
178
+ const hasPointerCapture = (id) => { var _a, _b; return (_b = (_a = internal.capturedMap.get(id)) === null || _a === void 0 ? void 0 : _a.has(hit.eventObject)) !== null && _b !== void 0 ? _b : false; };
179
+ const setPointerCapture = (id) => {
180
+ const captureData = {
181
+ intersection: hit,
182
+ target: event.target,
183
+ };
184
+ if (internal.capturedMap.has(id)) {
185
+ // if the pointerId was previously captured, we add the hit to the
186
+ // event capturedMap.
187
+ internal.capturedMap.get(id).set(hit.eventObject, captureData);
188
+ }
189
+ else {
190
+ // if the pointerId was not previously captured, we create a map
191
+ // containing the hitObject, and the hit. hitObject is used for
192
+ // faster access.
193
+ internal.capturedMap.set(id, new Map([[hit.eventObject, captureData]]));
194
+ }
195
+ // Call the original event now
196
+ event.target.setPointerCapture(id);
197
+ };
198
+ const releasePointerCapture = (id) => {
199
+ const captures = internal.capturedMap.get(id);
200
+ if (captures) {
201
+ releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
202
+ }
203
+ };
204
+ // Add native event props
205
+ const extractEventProps = {};
206
+ // This iterates over the event's properties including the inherited ones. Native PointerEvents have most of their props as getters which are inherited, but polyfilled PointerEvents have them all as their own properties (i.e. not inherited). We can't use Object.keys() or Object.entries() as they only return "own" properties; nor Object.getPrototypeOf(event) as that *doesn't* return "own" properties, only inherited ones.
207
+ for (const prop in event) {
208
+ const property = event[prop];
209
+ // Only copy over atomics, leave functions alone as these should be
210
+ // called as event.nativeEvent.fn()
211
+ if (typeof property !== 'function')
212
+ extractEventProps[prop] = property;
213
+ }
214
+ const raycastEvent = Object.assign(Object.assign(Object.assign({}, hit), extractEventProps), { pointer,
215
+ intersections, stopped: localState.stopped, delta,
216
+ unprojectedPoint, ray: raycaster.ray, camera: camera,
217
+ // Hijack stopPropagation, which just sets a flag
218
+ stopPropagation() {
219
+ // https://github.com/pmndrs/react-three-fiber/issues/596
220
+ // Events are not allowed to stop propagation if the pointer has been captured
221
+ const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId);
222
+ // We only authorize stopPropagation...
223
+ if (
224
+ // ...if this pointer hasn't been captured
225
+ !capturesForPointer ||
226
+ // ... or if the hit object is capturing the pointer
227
+ capturesForPointer.has(hit.eventObject)) {
228
+ raycastEvent.stopped = localState.stopped = true;
229
+ // Propagation is stopped, remove all other hover records
230
+ // An event handler is only allowed to flush other handlers if it is hovered itself
231
+ if (internal.hovered.size &&
232
+ Array.from(internal.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
233
+ // Objects cannot flush out higher up objects that have already caught the event
234
+ const higher = intersections.slice(0, intersections.indexOf(hit));
235
+ cancelPointer([...higher, hit]);
236
+ }
237
+ }
238
+ },
239
+ // there should be a distinction between target and currentTarget
240
+ target: {
241
+ hasPointerCapture,
242
+ setPointerCapture,
243
+ releasePointerCapture,
244
+ }, currentTarget: {
245
+ hasPointerCapture,
246
+ setPointerCapture,
247
+ releasePointerCapture,
248
+ }, nativeEvent: event });
249
+ // Call subscribers
250
+ callback(raycastEvent);
251
+ // Event bubbling may be interrupted by stopPropagation
252
+ if (localState.stopped === true)
253
+ break;
254
+ }
255
+ }
256
+ return intersections;
257
+ }
258
+ function cancelPointer(intersections) {
259
+ var _a, _b;
260
+ const { internal } = stateFactory();
261
+ for (const hoveredObj of internal.hovered.values()) {
262
+ // When no objects were hit or the hovered object wasn't found underneath the cursor
263
+ // we call onPointerOut and delete the object from the hovered-elements map
264
+ if (!intersections.length ||
265
+ !intersections.find((hit) => hit.object === hoveredObj.object &&
266
+ hit.index === hoveredObj.index &&
267
+ hit.instanceId === hoveredObj.instanceId)) {
268
+ const eventObject = hoveredObj.eventObject;
269
+ const instance = getInstanceLocalState(eventObject);
270
+ const handlers = instance === null || instance === void 0 ? void 0 : instance.handlers;
271
+ internal.hovered.delete(makeId(hoveredObj));
272
+ if (instance === null || instance === void 0 ? void 0 : instance.eventCount) {
273
+ // Clear out intersects, they are outdated by now
274
+ const data = Object.assign(Object.assign({}, hoveredObj), { intersections });
275
+ (_a = handlers === null || handlers === void 0 ? void 0 : handlers.pointerout) === null || _a === void 0 ? void 0 : _a.call(handlers, data);
276
+ (_b = handlers === null || handlers === void 0 ? void 0 : handlers.pointerleave) === null || _b === void 0 ? void 0 : _b.call(handlers, data);
277
+ }
278
+ }
279
+ }
280
+ }
281
+ function pointerMissed(event, objects) {
282
+ var _a, _b;
283
+ for (let i = 0; i < objects.length; i++) {
284
+ const instance = getInstanceLocalState(objects[i]);
285
+ (_b = instance === null || instance === void 0 ? void 0 : (_a = instance.handlers).pointermissed) === null || _b === void 0 ? void 0 : _b.call(_a, event);
286
+ }
287
+ }
288
+ function handlePointer(name) {
289
+ // Deal with cancelation
290
+ switch (name) {
291
+ case 'pointerleave':
292
+ case 'pointercancel':
293
+ return () => cancelPointer([]);
294
+ case 'lostpointercapture':
295
+ return (event) => {
296
+ const { internal } = stateFactory();
297
+ if ('pointerId' in event && !internal.capturedMap.has(event.pointerId)) {
298
+ // If the object event interface had onLostPointerCapture, we'd call it here on every
299
+ // object that's getting removed.
300
+ internal.capturedMap.delete(event.pointerId);
301
+ cancelPointer([]);
302
+ }
303
+ };
304
+ }
305
+ // Any other pointer goes here ...
306
+ return function handleEvent(event) {
307
+ const { onPointerMissed, internal } = stateFactory();
308
+ // prepareRay(event)
309
+ internal.lastEvent = event;
310
+ // Get fresh intersects
311
+ const isPointerMove = name === 'pointermove';
312
+ const isClickEvent = name === 'click' || name === 'contextmenu' || name === 'dblclick';
313
+ const filter = isPointerMove ? filterPointerEvents : undefined;
314
+ // const hits = patchIntersects(intersect(filter), event)
315
+ const hits = intersect(event, filter);
316
+ const delta = isClickEvent ? calculateDistance(event) : 0;
317
+ // Save initial coordinates on pointer-down
318
+ if (name === 'pointerdown') {
319
+ internal.initialClick = [event.offsetX, event.offsetY];
320
+ internal.initialHits = hits.map((hit) => hit.eventObject);
321
+ }
322
+ // If a click yields no results, pass it back to the user as a miss
323
+ // Missed events have to come first in order to establish user-land side-effect clean up
324
+ if (isClickEvent && !hits.length) {
325
+ if (delta <= 2) {
326
+ pointerMissed(event, internal.interaction);
327
+ if (onPointerMissed)
328
+ onPointerMissed(event);
329
+ }
330
+ }
331
+ // Take care of unhover
332
+ if (isPointerMove)
333
+ cancelPointer(hits);
334
+ function onIntersect(data) {
335
+ var _a, _b, _c;
336
+ const eventObject = data.eventObject;
337
+ const instance = getInstanceLocalState(eventObject);
338
+ const handlers = instance === null || instance === void 0 ? void 0 : instance.handlers;
339
+ // Check presence of handlers
340
+ if (!(instance === null || instance === void 0 ? void 0 : instance.eventCount))
341
+ return;
342
+ if (isPointerMove) {
343
+ // Move event ...
344
+ if ((handlers === null || handlers === void 0 ? void 0 : handlers.pointerover) ||
345
+ (handlers === null || handlers === void 0 ? void 0 : handlers.pointerenter) ||
346
+ (handlers === null || handlers === void 0 ? void 0 : handlers.pointerout) ||
347
+ (handlers === null || handlers === void 0 ? void 0 : handlers.pointerleave)) {
348
+ // When enter or out is present take care of hover-state
349
+ const id = makeId(data);
350
+ const hoveredItem = internal.hovered.get(id);
351
+ if (!hoveredItem) {
352
+ // If the object wasn't previously hovered, book it and call its handler
353
+ internal.hovered.set(id, data);
354
+ (_a = handlers.pointerover) === null || _a === void 0 ? void 0 : _a.call(handlers, data);
355
+ (_b = handlers.pointerenter) === null || _b === void 0 ? void 0 : _b.call(handlers, data);
356
+ }
357
+ else if (hoveredItem.stopped) {
358
+ // If the object was previously hovered and stopped, we shouldn't allow other items to proceed
359
+ data.stopPropagation();
360
+ }
361
+ }
362
+ // Call mouse move
363
+ (_c = handlers === null || handlers === void 0 ? void 0 : handlers.pointermove) === null || _c === void 0 ? void 0 : _c.call(handlers, data);
364
+ }
365
+ else {
366
+ // All other events ...
367
+ const handler = handlers[name];
368
+ if (handler) {
369
+ // Forward all events back to their respective handlers with the exception of click events,
370
+ // which must use the initial target
371
+ if (!isClickEvent || internal.initialHits.includes(eventObject)) {
372
+ // Missed events have to come first
373
+ pointerMissed(event, internal.interaction.filter((object) => !internal.initialHits.includes(object)));
374
+ // Now call the handler
375
+ handler(data);
376
+ }
377
+ }
378
+ else {
379
+ // Trigger onPointerMissed on all elements that have pointer over/out handlers, but not click and weren't hit
380
+ if (isClickEvent && internal.initialHits.includes(eventObject)) {
381
+ pointerMissed(event, internal.interaction.filter((object) => !internal.initialHits.includes(object)));
382
+ }
383
+ }
384
+ }
385
+ }
386
+ handleIntersects(hits, event, delta, onIntersect);
387
+ };
388
+ }
389
+ return { handlePointer };
390
+ }
391
+
392
+ const DOM_EVENTS = {
393
+ click: false,
394
+ contextmenu: false,
395
+ dblclick: false,
396
+ wheel: false,
397
+ pointerdown: true,
398
+ pointerup: true,
399
+ pointerleave: true,
400
+ pointermove: true,
401
+ pointercancel: true,
402
+ lostpointercapture: true,
403
+ };
404
+ function createPointerEvents(stateFactory) {
405
+ const { handlePointer } = createEvents(stateFactory);
406
+ return {
407
+ priority: 1,
408
+ enabled: true,
409
+ compute: (event, rootFactory) => {
410
+ const state = rootFactory();
411
+ // https://github.com/pmndrs/react-three-fiber/pull/782
412
+ // Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
413
+ state.pointer.set((event.offsetX / state.size.width) * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
414
+ state.raycaster.setFromCamera(state.pointer, state.camera);
415
+ },
416
+ connected: undefined,
417
+ handlers: Object.keys(DOM_EVENTS).reduce((handlers, supportedEventName) => {
418
+ handlers[supportedEventName] = handlePointer(supportedEventName);
419
+ return handlers;
420
+ }, {}),
421
+ connect: (target) => {
422
+ var _a, _b, _c;
423
+ const state = stateFactory();
424
+ (_b = (_a = state.events).disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
425
+ state.setEvents({ connected: target });
426
+ Object.entries((_c = state.events.handlers) !== null && _c !== void 0 ? _c : {}).forEach(([eventName, eventHandler]) => {
427
+ const passive = DOM_EVENTS[eventName];
428
+ target.addEventListener(eventName, eventHandler, { passive });
429
+ });
430
+ },
431
+ disconnect: () => {
432
+ var _a;
433
+ const { events, setEvents } = stateFactory();
434
+ if (events.connected) {
435
+ Object.entries((_a = events.handlers) !== null && _a !== void 0 ? _a : {}).forEach(([eventName, eventHandler]) => {
436
+ if (events.connected instanceof HTMLElement) {
437
+ events.connected.removeEventListener(eventName, eventHandler);
438
+ }
439
+ });
440
+ setEvents({ connected: undefined });
441
+ }
442
+ },
443
+ };
444
+ }
445
+
446
+ class NgtRef extends BehaviorSubject {
447
+ constructor(value) {
448
+ super(value ? value : null);
449
+ }
450
+ set(valueOrFactory) {
451
+ if (typeof valueOrFactory === 'function') {
452
+ this.next(valueOrFactory(this.value));
453
+ }
454
+ else {
455
+ this.next(valueOrFactory);
456
+ }
457
+ }
458
+ }
459
+
460
+ const is = {
461
+ obj: (a) => a === Object(a) && !Array.isArray(a) && typeof a !== 'function',
462
+ material: (a) => !!a && a.isMaterial,
463
+ geometry: (a) => !!a && a.isBufferGeometry,
464
+ mesh: (a) => !!a && a.isMesh,
465
+ color: (a) => !!a && a.isColor,
466
+ orthographic: (a) => !!a && a.isOrthographicCamera,
467
+ perspective: (a) => !!a && a.isPerspectiveCamera,
468
+ camera: (a) => !!a && a.isCamera,
469
+ glRenderer: (a) => !!a && a instanceof THREE.WebGLRenderer,
470
+ scene: (a) => !!a && a.isScene,
471
+ object3d: (a) => !!a && a.isObject3D,
472
+ instance: (a) => !!a && !!a['__ngt__'],
473
+ ref: (a) => !!a && a instanceof NgtRef,
474
+ supportColorManagement: () => 'ColorManagement' in THREE,
475
+ canvas: (a) => a instanceof HTMLCanvasElement,
476
+ equ(a, b, { arrays = 'shallow', objects = 'reference', strict = true } = {}) {
477
+ // Wrong type or one of the two undefined, doesn't match
478
+ if (typeof a !== typeof b || !!a !== !!b)
479
+ return false;
480
+ // Atomic, just compare a against b
481
+ if (typeof a === 'string' || typeof a === 'number')
482
+ return a === b;
483
+ const isObj = is.obj(a);
484
+ if (isObj && objects === 'reference')
485
+ return a === b;
486
+ const isArr = Array.isArray(a);
487
+ if (isArr && arrays === 'reference')
488
+ return a === b;
489
+ // Array or Object, shallow compare first to see if it's a match
490
+ if ((isArr || isObj) && a === b)
491
+ return true;
492
+ // Last resort, go through keys
493
+ let i;
494
+ for (i in a)
495
+ if (!(i in b))
496
+ return false;
497
+ for (i in strict ? b : a)
498
+ if (a[i] !== b[i])
499
+ return false;
500
+ if (i === void 0) {
501
+ if (isArr && a.length === 0 && b.length === 0)
502
+ return true;
503
+ if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0)
504
+ return true;
505
+ if (a !== b)
506
+ return false;
507
+ }
508
+ return true;
509
+ },
510
+ };
511
+
512
+ /**
513
+ * a default Selector that consumers can quickly use for their selectors projector
514
+ */
515
+ const defaultProjector = () => ({});
516
+ /**
517
+ * A custom operator that skips the first undefined value but allows subsequent undefined values.
518
+ * NgRxComponentStore#select always emits the first value regardless of undefined or not after initialize
519
+ */
520
+ const skipFirstUndefined = () => filter((value, index) => index > 0 || value !== undefined);
521
+ /**
522
+ * An extended `tap` operator that accepts an `effectFn` which:
523
+ * - runs on every `next` notification from `source$`
524
+ * - can optionally return a `cleanUp` function that
525
+ * invokes from the 2nd `next` notification onward and on `unsubscribe` (destroyed)
526
+ *
527
+ *
528
+ * @example
529
+ * ```typescript
530
+ * source$.pipe(
531
+ * tapEffect((sourceValue) = {
532
+ * const cb = () => {
533
+ * doStuff(sourceValue);
534
+ * };
535
+ * addListener('event', cb);
536
+ *
537
+ * return () => {
538
+ * removeListener('event', cb);
539
+ * }
540
+ * })
541
+ * )
542
+ * ```
543
+ */
544
+ function tapEffect(effectFn) {
545
+ let cleanupFn = noop;
546
+ let firstRun = false;
547
+ let prev = undefined;
548
+ const teardown = (error) => {
549
+ return () => {
550
+ if (cleanupFn) {
551
+ cleanupFn({ prev, complete: true, error });
552
+ }
553
+ };
554
+ };
555
+ return tap({
556
+ next: (value) => {
557
+ if (cleanupFn && firstRun) {
558
+ cleanupFn({ prev, complete: false, error: false });
559
+ }
560
+ const cleanUpOrVoid = effectFn(value);
561
+ if (cleanUpOrVoid) {
562
+ cleanupFn = cleanUpOrVoid;
563
+ }
564
+ prev = value;
565
+ if (!firstRun) {
566
+ firstRun = true;
567
+ }
568
+ },
569
+ complete: teardown(false),
570
+ unsubscribe: teardown(false),
571
+ error: teardown(true),
572
+ });
573
+ }
574
+ class NgtComponentStore extends ComponentStore {
575
+ constructor() {
576
+ super({});
577
+ // exposing get since THREE is imperative at its core
578
+ // we need to imperatively get state sometimes for usages in Animation Loop
579
+ // we also bind "this" instance, so we don't have to bind it later
580
+ this.read = this.get.bind(this);
581
+ this.initialize();
582
+ }
583
+ /**
584
+ * A custom patchState that allows for:
585
+ * - Partial state updates and Observable of partial state updates like patchState
586
+ * - Pass a Record<string, ObservableInput> to update a specific key with an Observable.
587
+ * This is similar to `RxState.connect()` API
588
+ */
589
+ write(partialStateOrFactory) {
590
+ if (typeof partialStateOrFactory === 'function') {
591
+ return this.write(partialStateOrFactory(this.read()));
592
+ }
593
+ const partialState = partialStateOrFactory;
594
+ if (Object.keys(partialState).length === 0) {
595
+ return;
596
+ }
597
+ if (isObservable(partialState)) {
598
+ return this.patchState(partialState);
599
+ }
600
+ const entries = Object.entries(partialState);
601
+ const hasObservable = entries.some(([_, value]) => isObservable(value) && !is.ref(value));
602
+ if (!hasObservable) {
603
+ return this.patchState(partialState);
604
+ }
605
+ const [rawValues, observableValues] = entries.reduce((result, [key, value]) => {
606
+ if (isObservable(value)) {
607
+ result[1][key] = value;
608
+ }
609
+ else {
610
+ result[0][key] = value;
611
+ }
612
+ return result;
613
+ }, [{}, {}]);
614
+ if (Object.keys(rawValues).length > 0) {
615
+ this.patchState(rawValues);
616
+ }
617
+ if (Object.keys(observableValues).length > 0) {
618
+ this.patchState(combineLatest(observableValues));
619
+ }
620
+ }
621
+ initialize() {
622
+ return;
623
+ }
624
+ /**
625
+ * A utility class method to select a state on the template as Observable
626
+ * - This method always debounce the Observable
627
+ */
628
+ selectKey(key, skipFirst = false) {
629
+ return this.select((s) => s[key], { debounce: true }).pipe(skipFirst ? skipFirstUndefined() : (s) => s);
630
+ }
631
+ /**
632
+ * A utility class method to get a state on the template as imperative Value
633
+ */
634
+ readKey(key) {
635
+ return this.read((s) => s[key]);
636
+ }
637
+ }
638
+ NgtComponentStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtComponentStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
639
+ NgtComponentStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtComponentStore });
640
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtComponentStore, decorators: [{
641
+ type: Injectable
642
+ }], ctorParameters: function () { return []; } });
643
+
644
+ function createInjection(description, { defaultValueOrFactory, provideValueFactory, } = {}) {
645
+ const factory = (defaultValueOrFactory && typeof defaultValueOrFactory === 'function'
646
+ ? defaultValueOrFactory
647
+ : () => defaultValueOrFactory);
648
+ const injectionToken = new InjectionToken(description, { factory });
649
+ function injectFn(options = {}) {
650
+ return inject(injectionToken, options);
651
+ }
652
+ function provideFn(value) {
653
+ return {
654
+ provide: injectionToken,
655
+ useValue: provideValueFactory ? provideValueFactory(value) : value,
656
+ };
657
+ }
658
+ return [injectFn, provideFn, injectionToken];
659
+ }
660
+
661
+ const [injectWindow] = createInjection('window', {
662
+ defaultValueOrFactory: () => {
663
+ const { defaultView } = inject(DOCUMENT);
664
+ if (!defaultView) {
665
+ throw `window is not available!`;
666
+ }
667
+ return defaultView;
668
+ },
669
+ });
670
+
671
+ function checkNeedsUpdate(value) {
672
+ if (value !== null && is.obj(value) && 'needsUpdate' in value) {
673
+ value['needsUpdate'] = true;
674
+ if ('uniformsNeedUpdate' in value) {
675
+ value['uniformsNeedUpdate'] = true;
676
+ }
677
+ }
678
+ }
679
+ function checkUpdate(value) {
680
+ if (is.object3d(value)) {
681
+ value.updateMatrix();
682
+ }
683
+ else if (is.camera(value)) {
684
+ if (is.perspective(value) || is.orthographic(value)) {
685
+ value.updateProjectionMatrix();
686
+ }
687
+ value.updateMatrixWorld();
688
+ }
689
+ checkNeedsUpdate(value);
690
+ }
691
+
692
+ function invalidateInstance(instance) {
693
+ var _a;
694
+ const state = (_a = getInstanceLocalState(instance)) === null || _a === void 0 ? void 0 : _a.stateFactory();
695
+ if (state && state.internal.frames === 0)
696
+ state.invalidate();
697
+ checkUpdate(instance);
698
+ }
699
+ function prepare(instance, parentStateFactory, rootStateFactory, parentInstance, previousInstance, isPrimitive = false) {
700
+ var _a, _b, _c, _d;
701
+ const previousInstanceInternal = getInstanceLocalState(previousInstance === null || previousInstance === void 0 ? void 0 : previousInstance.value);
702
+ const parent = parentInstance
703
+ ? parentInstance
704
+ : previousInstanceInternal
705
+ ? previousInstanceInternal.parentRef
706
+ : undefined;
707
+ if (is.scene(instance)) {
708
+ applyProps(instance, { dispose: null });
709
+ }
710
+ return Object.assign(instance, {
711
+ __ngt__: {
712
+ stateFactory: parentStateFactory,
713
+ rootFactory: rootStateFactory,
714
+ isPrimitive: !isPrimitive ? previousInstanceInternal === null || previousInstanceInternal === void 0 ? void 0 : previousInstanceInternal.isPrimitive : isPrimitive,
715
+ eventCount: (_a = previousInstanceInternal === null || previousInstanceInternal === void 0 ? void 0 : previousInstanceInternal.eventCount) !== null && _a !== void 0 ? _a : 0,
716
+ handlers: (_b = previousInstanceInternal === null || previousInstanceInternal === void 0 ? void 0 : previousInstanceInternal.handlers) !== null && _b !== void 0 ? _b : {},
717
+ instancesRefs: (_c = previousInstanceInternal === null || previousInstanceInternal === void 0 ? void 0 : previousInstanceInternal.instancesRefs) !== null && _c !== void 0 ? _c : new NgtRef([]),
718
+ objectsRefs: (_d = previousInstanceInternal === null || previousInstanceInternal === void 0 ? void 0 : previousInstanceInternal.objectsRefs) !== null && _d !== void 0 ? _d : new NgtRef([]),
719
+ parentRef: parent ? (parent === instance || parent.value === instance ? null : parent) : null,
720
+ },
721
+ });
722
+ }
723
+
724
+ const DEFAULT = '__default';
725
+ function diffProps(instance, props, previousProps = {}, remove = false) {
726
+ const localState = getInstanceLocalState(instance) || {};
727
+ const propsEntries = Object.entries(props);
728
+ const changes = [];
729
+ // Catch removed props, prepend them, so they can be reset or removed
730
+ if (remove) {
731
+ const previousKeys = Object.keys(previousProps);
732
+ for (const previousKey of previousKeys) {
733
+ // @ts-ignore
734
+ if (!Object.hasOwn(props, previousKey)) {
735
+ propsEntries.unshift([previousKey, DEFAULT + 'remove']);
736
+ }
737
+ }
738
+ }
739
+ for (const [propKey, propValue] of propsEntries) {
740
+ if (is.equ(propValue, previousProps[propKey]))
741
+ continue;
742
+ changes.push([propKey, propValue]);
743
+ }
744
+ const memoized = Object.assign({}, props);
745
+ if (localState.memoized && localState.memoized['args']) {
746
+ memoized['args'] = localState.memoized['args'];
747
+ }
748
+ if (localState.memoized && localState.memoized['attach']) {
749
+ memoized['attach'] = localState.memoized['attach'] || localState.attach;
750
+ }
751
+ return { changes, memoized };
752
+ }
753
+ function applyProps(instance, props) {
754
+ var _a, _b, _c, _d;
755
+ // props is empty
756
+ if (!Object.keys(props).length)
757
+ return instance;
758
+ // Filter equals, events and reserved props
759
+ const localState = getInstanceLocalState(instance) || {};
760
+ const rootState = (_a = localState.stateFactory) === null || _a === void 0 ? void 0 : _a.call(localState);
761
+ const { changes, memoized } = diffProps(instance, props);
762
+ const instanceHandlers = localState.eventCount;
763
+ if (getInstanceLocalState(instance)) {
764
+ getInstanceLocalState(instance).memoized = memoized;
765
+ }
766
+ for (let i = 0; i < changes.length; i++) {
767
+ const key = changes[i][0];
768
+ const currentInstance = instance;
769
+ const targetProp = currentInstance[key];
770
+ let value = changes[i][1];
771
+ if (is.ref(value)) {
772
+ value = value.value;
773
+ }
774
+ if (value === DEFAULT + 'remove') {
775
+ if (targetProp && targetProp.constructor) {
776
+ // use the prop constructor to find the default it should be
777
+ value = new targetProp.constructor(...((_b = memoized['args']) !== null && _b !== void 0 ? _b : []));
778
+ }
779
+ else if (currentInstance.constructor) {
780
+ const dummyInstance = new currentInstance.constructor(...(((_d = (_c = getInstanceLocalState(currentInstance)) === null || _c === void 0 ? void 0 : _c.memoized) === null || _d === void 0 ? void 0 : _d['args']) || []));
781
+ value = dummyInstance[targetProp];
782
+ // destroy the instance
783
+ if (dummyInstance.dispose)
784
+ dummyInstance.dispose();
785
+ }
786
+ else {
787
+ value = 0;
788
+ }
789
+ }
790
+ // Special treatment for objects with support for set/copy, and layers
791
+ if (targetProp && targetProp['set'] && (targetProp['copy'] || targetProp instanceof THREE.Layers)) {
792
+ const isColor = targetProp instanceof THREE.Color;
793
+ // If value is an array
794
+ if (Array.isArray(value)) {
795
+ if (targetProp['fromArray'])
796
+ targetProp['fromArray'](value);
797
+ else
798
+ targetProp['set'](...value);
799
+ }
800
+ // Test again target.copy(class) next ...
801
+ else if (targetProp['copy'] &&
802
+ value &&
803
+ value.constructor &&
804
+ targetProp.constructor.name === value.constructor.name) {
805
+ targetProp['copy'](value);
806
+ if (!is.supportColorManagement() && !rootState.linear && isColor) {
807
+ targetProp['convertSRGBToLinear']();
808
+ }
809
+ }
810
+ // If nothing else fits, just set the single value, ignore undefined
811
+ // https://github.com/pmndrs/react-three-fiber/issues/274
812
+ else if (value !== undefined) {
813
+ const isColor = targetProp instanceof THREE.Color;
814
+ // Allow setting array scalars
815
+ if (!isColor && targetProp['setScalar'])
816
+ targetProp['setScalar'](value);
817
+ // Layers have no copy function, we must therefore copy the mask property
818
+ else if (targetProp instanceof THREE.Layers && value instanceof THREE.Layers)
819
+ targetProp.mask = value.mask;
820
+ // Otherwise just set ...
821
+ else
822
+ targetProp['set'](value);
823
+ // For versions of three which don't support THREE.ColorManagement,
824
+ // Auto-convert sRGB colors
825
+ // https://github.com/pmndrs/react-three-fiber/issues/344
826
+ if (!is.supportColorManagement() && !rootState.linear && isColor)
827
+ targetProp.convertSRGBToLinear();
828
+ }
829
+ // Else, just overwrite the value
830
+ }
831
+ else {
832
+ currentInstance[key] = value;
833
+ // Auto-convert sRGB textures, for now ...
834
+ // https://github.com/pmndrs/react-three-fiber/issues/344
835
+ if (!(rootState === null || rootState === void 0 ? void 0 : rootState.linear) && currentInstance[key] instanceof THREE.Texture) {
836
+ currentInstance[key]['encoding'] = THREE.sRGBEncoding;
837
+ }
838
+ }
839
+ checkNeedsUpdate(targetProp);
840
+ invalidateInstance(instance);
841
+ }
842
+ if (localState.parentRef &&
843
+ rootState.internal &&
844
+ instance['raycast'] &&
845
+ instanceHandlers !== localState.eventCount) {
846
+ // Pre-emptively remove the instance from the interaction manager
847
+ rootState.removeInteraction(instance['uuid']);
848
+ // Add the instance to the interaction manager only when it has handlers
849
+ if (localState.eventCount)
850
+ rootState.addInteraction(instance);
851
+ }
852
+ return instance;
853
+ }
854
+
855
+ function updateCamera(camera, size) {
856
+ // https://github.com/pmndrs/react-three-fiber/issues/92
857
+ // Do not mess with the camera if it belongs to the user
858
+ if (!camera.manual) {
859
+ if (is.orthographic(camera)) {
860
+ camera.left = size.width / -2;
861
+ camera.right = size.width / 2;
862
+ camera.top = size.height / 2;
863
+ camera.bottom = size.height / -2;
864
+ }
865
+ else {
866
+ camera.aspect = size.width / size.height;
867
+ }
868
+ camera.updateProjectionMatrix();
869
+ // https://github.com/pmndrs/react-three-fiber/issues/178
870
+ // Update matrix world since the renderer is a frame late
871
+ camera.updateMatrixWorld();
872
+ }
873
+ }
874
+ function createDefaultCamera(isOrthographic, size) {
875
+ if (isOrthographic) {
876
+ return new THREE.OrthographicCamera(0, 0, 0, 0, 0.1, 1000);
877
+ }
878
+ return new THREE.PerspectiveCamera(75, size.width / size.height, 0.1, 1000);
879
+ }
880
+
881
+ function createSubs(callback, subs) {
882
+ const sub = { callback };
883
+ subs.add(sub);
884
+ return () => void subs.delete(sub);
885
+ }
886
+ const globalEffects = new Set();
887
+ const globalAfterEffects = new Set();
888
+ const globalTailEffects = new Set();
889
+ /**
890
+ * Adds a global render callback which is called each frame.
891
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
892
+ */
893
+ const addEffect = (callback) => createSubs(callback, globalEffects);
894
+ /**
895
+ * Adds a global after-render callback which is called each frame.
896
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
897
+ */
898
+ const addAfterEffect = (callback) => createSubs(callback, globalAfterEffects);
899
+ /**
900
+ * Adds a global callback which is called when rendering stops.
901
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
902
+ */
903
+ const addTail = (callback) => createSubs(callback, globalTailEffects);
904
+ function run(effects, timestamp) {
905
+ if (!effects.size)
906
+ return;
907
+ for (const { callback } of effects.values()) {
908
+ callback(timestamp);
909
+ }
910
+ }
911
+ function flushGlobalEffects(type, timestamp) {
912
+ switch (type) {
913
+ case 'before':
914
+ return run(globalEffects, timestamp);
915
+ case 'after':
916
+ return run(globalAfterEffects, timestamp);
917
+ case 'tail':
918
+ return run(globalTailEffects, timestamp);
919
+ }
920
+ }
921
+ function render(timestamp, stateFactory, frame) {
922
+ const state = stateFactory();
923
+ // Run local effects
924
+ let delta = state.clock.getDelta();
925
+ // In frameloop='never' mode, clock times are updated using the provided timestamp
926
+ if (state.frameloop === 'never' && typeof timestamp === 'number') {
927
+ delta = timestamp - state.clock.elapsedTime;
928
+ state.clock.oldTime = state.clock.elapsedTime;
929
+ state.clock.elapsedTime = timestamp;
930
+ }
931
+ // Call subscribers (useFrame)
932
+ // subscribers = state.internal.subscribers;
933
+ for (let i = 0; i < state.internal.subscribers.length; i++) {
934
+ const subscriber = state.internal.subscribers[i];
935
+ const object = is.ref(subscriber.obj) ? subscriber.obj.value : subscriber.obj;
936
+ subscriber.callback(Object.assign(Object.assign({}, state), { delta, frame }), object);
937
+ }
938
+ // Render content
939
+ if (!state.internal.priority && state.gl.render)
940
+ state.gl.render(state.scene, state.camera);
941
+ // Decrease frame count
942
+ state.internal.frames = Math.max(0, state.internal.frames - 1);
943
+ return state.frameloop === 'always' ? 1 : state.internal.frames;
944
+ }
945
+ function createLoop(roots) {
946
+ let running = false;
947
+ let repeat;
948
+ let frame;
949
+ let state;
950
+ function loop(timestamp) {
951
+ var _a;
952
+ frame = requestAnimationFrame(loop);
953
+ running = true;
954
+ repeat = 0;
955
+ // Run effects
956
+ flushGlobalEffects('before', timestamp);
957
+ // Render all roots
958
+ for (const root of roots.values()) {
959
+ state = root();
960
+ // If the frameloop is invalidated, do not run another frame
961
+ if (state.internal.active &&
962
+ (state.frameloop === 'always' || state.internal.frames > 0) &&
963
+ !((_a = state.gl.xr) === null || _a === void 0 ? void 0 : _a.isPresenting)) {
964
+ repeat += render(timestamp, root);
965
+ }
966
+ }
967
+ // Run after-effects
968
+ flushGlobalEffects('after', timestamp);
969
+ // Stop the loop if nothing invalidates it
970
+ if (repeat === 0) {
971
+ // Tail call effects, they are called when rendering stops
972
+ flushGlobalEffects('tail', timestamp);
973
+ // Flag end of operation
974
+ running = false;
975
+ return cancelAnimationFrame(frame);
976
+ }
977
+ }
978
+ function invalidate(stateFactory, frames = 1) {
979
+ var _a;
980
+ const stateToInvalidate = stateFactory === null || stateFactory === void 0 ? void 0 : stateFactory();
981
+ if (!stateToInvalidate)
982
+ return roots.forEach((root) => invalidate(root, frames));
983
+ if (((_a = stateToInvalidate.gl.xr) === null || _a === void 0 ? void 0 : _a.isPresenting) ||
984
+ !stateToInvalidate.internal.active ||
985
+ stateToInvalidate.frameloop === 'never')
986
+ return;
987
+ // Increase frames, do not go higher than 60
988
+ stateToInvalidate.internal.frames = Math.min(60, stateToInvalidate.internal.frames + frames);
989
+ // If the render-loop isn't active, start it
990
+ if (!running) {
991
+ running = true;
992
+ requestAnimationFrame(loop);
993
+ }
994
+ }
995
+ function advance(timestamp, runGlobalEffects = true, stateFactory, frame) {
996
+ if (runGlobalEffects)
997
+ flushGlobalEffects('before', timestamp);
998
+ if (!stateFactory)
999
+ for (const root of roots.values())
1000
+ render(timestamp, root);
1001
+ else
1002
+ render(timestamp, stateFactory, frame);
1003
+ if (runGlobalEffects)
1004
+ flushGlobalEffects('after', timestamp);
1005
+ }
1006
+ return {
1007
+ loop,
1008
+ /**
1009
+ * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
1010
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
1011
+ */
1012
+ invalidate,
1013
+ /**
1014
+ * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
1015
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
1016
+ */
1017
+ advance,
1018
+ };
1019
+ }
1020
+
1021
+ function createRenderer(glOptions, canvasElement) {
1022
+ const customRenderer = (typeof glOptions === 'function' ? glOptions(canvasElement) : glOptions);
1023
+ if ((customRenderer === null || customRenderer === void 0 ? void 0 : customRenderer.render) != null) {
1024
+ return customRenderer;
1025
+ }
1026
+ return new THREE.WebGLRenderer(Object.assign({ powerPreference: 'high-performance', canvas: canvasElement, antialias: true, alpha: true }, (glOptions || {})));
1027
+ }
1028
+
1029
+ const rootStateMap = new Map();
1030
+ const { invalidate, advance } = createLoop(rootStateMap);
1031
+ const shallowLoose = { objects: 'shallow', strict: false };
1032
+ class NgtStore extends NgtComponentStore {
1033
+ constructor() {
1034
+ super(...arguments);
1035
+ this.parentStore = inject(NgtStore, { optional: true, skipSelf: true });
1036
+ this.zone = inject(NgZone);
1037
+ this.window = injectWindow();
1038
+ this.position = new THREE.Vector3();
1039
+ this.defaultTarget = new THREE.Vector3();
1040
+ this.tempTarget = new THREE.Vector3();
1041
+ this.resize = this.effect(($) => {
1042
+ let oldSize = this.read((s) => s.size);
1043
+ let oldDpr = this.read((s) => { var _a; return (_a = s.viewport) === null || _a === void 0 ? void 0 : _a.dpr; });
1044
+ return $.pipe(tap(() => {
1045
+ const { camera, size, viewport, gl } = this.read();
1046
+ // Resize camera and renderer on changes to size and pixelratio
1047
+ if (size !== oldSize || viewport.dpr !== oldDpr) {
1048
+ oldSize = size;
1049
+ oldDpr = viewport.dpr;
1050
+ // Update camera & renderer
1051
+ updateCamera(camera, size);
1052
+ gl.setPixelRatio(viewport.dpr);
1053
+ gl.setSize(size.width, size.height, size.updateStyle);
1054
+ }
1055
+ }));
1056
+ });
1057
+ this.invalidate = this.effect(tap(() => void this.read((s) => s.invalidate)()));
1058
+ this.isInit = false;
1059
+ this.isConfigured = false;
1060
+ this.addInteraction = (interaction) => {
1061
+ this.write((state) => (Object.assign(Object.assign({}, state), { internal: Object.assign(Object.assign({}, state.internal), { interaction: [...state.internal.interaction, interaction] }) })));
1062
+ };
1063
+ this.removeInteraction = (uuid) => {
1064
+ this.write((state) => (Object.assign(Object.assign({}, state), { internal: Object.assign(Object.assign({}, state.internal), { interaction: state.internal.interaction.filter((interaction) => interaction.uuid !== uuid) }) })));
1065
+ };
1066
+ this.setPerformanceCurrent = (current) => {
1067
+ this.write((s) => ({ performance: Object.assign(Object.assign({}, s.performance), { current }) }));
1068
+ };
1069
+ this.setEvents = (events) => {
1070
+ this.write((s) => ({ events: Object.assign(Object.assign({}, s.events), events) }));
1071
+ };
1072
+ this.setSize = (width, height, top, left, updateStyle) => {
1073
+ const camera = this.read((s) => s.camera);
1074
+ const size = { width, height, top: top || 0, left: left || 0, updateStyle };
1075
+ this.write((state) => ({
1076
+ size,
1077
+ viewport: Object.assign(Object.assign({}, state.viewport), this.getCurrentViewport(camera, this.defaultTarget, size)),
1078
+ }));
1079
+ };
1080
+ this.setCamera = (camera) => {
1081
+ this.write((s) => ({
1082
+ camera,
1083
+ viewport: Object.assign(Object.assign({}, s.viewport), this.getCurrentViewport(camera)),
1084
+ }));
1085
+ this.read((s) => s.cameraRef).set(camera);
1086
+ };
1087
+ this.setDpr = (dpr) => {
1088
+ const resolved = makeDpr(dpr, this.window);
1089
+ this.write((s) => ({
1090
+ viewport: Object.assign(Object.assign({}, s.viewport), { dpr: resolved, initialDpr: s.viewport.initialDpr || resolved }),
1091
+ }));
1092
+ };
1093
+ this.setFrameloop = (frameloop = 'always') => {
1094
+ const clock = this.read((s) => s.clock);
1095
+ // if frameloop === "never" clock.elapsedTime is updated using advance(timestamp)
1096
+ clock.stop();
1097
+ clock.elapsedTime = 0;
1098
+ if (frameloop !== 'never') {
1099
+ clock.start();
1100
+ clock.elapsedTime = 0;
1101
+ }
1102
+ this.write({ frameloop });
1103
+ };
1104
+ this.getCurrentViewport = (camera = this.read((s) => s.camera), target = this.defaultTarget, size = this.read((s) => s.size)) => {
1105
+ const { width, height, top, left } = size;
1106
+ const aspect = width / height;
1107
+ if (target instanceof THREE.Vector3)
1108
+ this.tempTarget.copy(target);
1109
+ else
1110
+ this.tempTarget.set(...target);
1111
+ const distance = camera.getWorldPosition(this.position).distanceTo(this.tempTarget);
1112
+ if (is.orthographic(camera)) {
1113
+ return {
1114
+ width: width / camera.zoom,
1115
+ height: height / camera.zoom,
1116
+ top,
1117
+ left,
1118
+ factor: 1,
1119
+ distance,
1120
+ aspect,
1121
+ };
1122
+ }
1123
+ const fov = (camera.fov * Math.PI) / 180; // convert vertical fov to radians
1124
+ const h = 2 * Math.tan(fov / 2) * distance; // visible height
1125
+ const w = h * (width / height);
1126
+ return {
1127
+ width: w,
1128
+ height: h,
1129
+ top,
1130
+ left,
1131
+ factor: width / w,
1132
+ distance,
1133
+ aspect,
1134
+ };
1135
+ };
1136
+ }
1137
+ get rootStateFactory() {
1138
+ let root = this.read((s) => s.previousStateFactory);
1139
+ while (root && root().previousStateFactory) {
1140
+ root = root().previousStateFactory;
1141
+ }
1142
+ return root || this.read;
1143
+ }
1144
+ init() {
1145
+ var _a, _b;
1146
+ if (!this.isInit) {
1147
+ const pointer = new THREE.Vector2();
1148
+ const scene = prepare(new THREE.Scene(), this.read, this.rootStateFactory, (_a = this.parentStore) === null || _a === void 0 ? void 0 : _a.get((s) => s.sceneRef));
1149
+ let performanceTimeout;
1150
+ this.write({
1151
+ ready: false,
1152
+ cameraRef: new NgtRef(),
1153
+ scene,
1154
+ sceneRef: new NgtRef(scene),
1155
+ events: { priority: 1, enabled: true, connected: false },
1156
+ invalidate: (frames = 1) => invalidate(this.read, frames),
1157
+ advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, this.read),
1158
+ legacy: false,
1159
+ linear: false,
1160
+ flat: false,
1161
+ controls: null,
1162
+ clock: new THREE.Clock(),
1163
+ pointer,
1164
+ frameloop: 'always',
1165
+ performance: {
1166
+ current: 1,
1167
+ min: 0.5,
1168
+ max: 1,
1169
+ debounce: 200,
1170
+ regress: () => {
1171
+ this.zone.runOutsideAngular(() => {
1172
+ const state = this.read();
1173
+ // Clear timeout
1174
+ if (performanceTimeout)
1175
+ clearTimeout(performanceTimeout);
1176
+ // Set lower bound performance
1177
+ if (state.performance.current !== state.performance.min)
1178
+ this.setPerformanceCurrent(state.performance.min);
1179
+ // Go back to upper bound performance after a while unless something regresses meanwhile
1180
+ performanceTimeout = setTimeout(() => { var _a; return this.setPerformanceCurrent(((_a = this.read((s) => s.performance)) === null || _a === void 0 ? void 0 : _a.max) || 1); }, state.performance.debounce);
1181
+ });
1182
+ },
1183
+ },
1184
+ size: { width: 0, height: 0, top: 0, left: 0, updateStyle: false },
1185
+ viewport: {
1186
+ initialDpr: 0,
1187
+ dpr: 0,
1188
+ width: 0,
1189
+ height: 0,
1190
+ top: 0,
1191
+ left: 0,
1192
+ aspect: 0,
1193
+ distance: 0,
1194
+ factor: 0,
1195
+ getCurrentViewport: this.getCurrentViewport,
1196
+ },
1197
+ previousStateFactory: (_b = this.parentStore) === null || _b === void 0 ? void 0 : _b.read.bind(this.parentStore),
1198
+ internal: {
1199
+ active: false,
1200
+ priority: 0,
1201
+ frames: 0,
1202
+ lastEvent: null,
1203
+ interaction: [],
1204
+ hovered: new Map(),
1205
+ capturedMap: new Map(),
1206
+ animations: new Map(),
1207
+ subscribers: [],
1208
+ initialClick: [0, 0],
1209
+ initialHits: [],
1210
+ subscribe: (callback, priority = 0, stateFactory = this.read, obj) => {
1211
+ const internal = this.read((s) => s.internal);
1212
+ // If this subscription was given a priority, it takes rendering into its own hands
1213
+ // For that reason we switch off automatic rendering and increase the manual flag
1214
+ // As long as this flag is positive there can be no internal rendering at all
1215
+ // because there could be multiple render subscriptions
1216
+ internal.priority = internal.priority + (priority > 0 ? 1 : 0);
1217
+ internal.subscribers.push({ priority, stateFactory, callback, obj });
1218
+ // Register subscriber and sort layers from lowest to highest, meaning,
1219
+ // highest priority renders last (on top of the other frames)
1220
+ internal.subscribers.sort((a, b) => (a.priority || 0) - (b.priority || 0));
1221
+ return () => {
1222
+ const internalOnCleanUp = this.read((s) => s.internal);
1223
+ if (internalOnCleanUp.subscribers) {
1224
+ // Decrease manual flag if this subscription had a priority
1225
+ internalOnCleanUp.priority = internalOnCleanUp.priority - (priority > 0 ? 1 : 0);
1226
+ // Remove subscriber from list
1227
+ internalOnCleanUp.subscribers = internalOnCleanUp.subscribers.filter((s) => s.callback !== callback);
1228
+ }
1229
+ };
1230
+ },
1231
+ },
1232
+ setPerformanceCurrent: this.setPerformanceCurrent,
1233
+ setEvents: this.setEvents,
1234
+ setFrameloop: this.setFrameloop,
1235
+ setSize: this.setSize,
1236
+ setDpr: this.setDpr,
1237
+ setCamera: this.setCamera,
1238
+ addInteraction: this.addInteraction,
1239
+ removeInteraction: this.removeInteraction,
1240
+ });
1241
+ this.isInit = true;
1242
+ }
1243
+ }
1244
+ configure(inputs, canvasElement) {
1245
+ var _a;
1246
+ const { gl: glOptions, size: sizeOptions, camera: cameraOptions, raycaster: raycasterOptions, events, orthographic, lookAt, shadows, linear, flat, legacy, dpr, frameloop, performance, } = inputs;
1247
+ const state = this.read();
1248
+ // Set up renderer (one time only!)
1249
+ let gl = state.gl;
1250
+ if (!state.gl) {
1251
+ this.write({ gl: (gl = createRenderer(glOptions, canvasElement)) });
1252
+ }
1253
+ // Set up raycaster (one time only!)
1254
+ let raycaster = state.raycaster;
1255
+ if (!raycaster) {
1256
+ this.write({ raycaster: (raycaster = new THREE.Raycaster()) });
1257
+ }
1258
+ // Set raycaster options
1259
+ const _b = raycasterOptions || {}, { params } = _b, options = __rest(_b, ["params"]);
1260
+ if (!is.equ(options, raycaster, shallowLoose)) {
1261
+ applyProps(raycaster, Object.assign({}, options));
1262
+ }
1263
+ if (!is.equ(params, raycaster.params, shallowLoose)) {
1264
+ applyProps(raycaster, {
1265
+ params: Object.assign(Object.assign({}, raycaster.params), (params || {})),
1266
+ });
1267
+ }
1268
+ // Create default camera (one time only!)
1269
+ if (!state.camera) {
1270
+ const isCamera = is.camera(cameraOptions);
1271
+ let camera = isCamera ? cameraOptions : createDefaultCamera(orthographic, state.size);
1272
+ if (!isCamera) {
1273
+ if (cameraOptions) {
1274
+ applyProps(camera, cameraOptions);
1275
+ }
1276
+ // Set position.z if position not passed in
1277
+ if (!(cameraOptions === null || cameraOptions === void 0 ? void 0 : cameraOptions.position)) {
1278
+ camera.position.z = 5;
1279
+ }
1280
+ // Always look at center or passed-in lookAt by default
1281
+ if (!(cameraOptions === null || cameraOptions === void 0 ? void 0 : cameraOptions.rotation)) {
1282
+ if (Array.isArray(lookAt)) {
1283
+ camera.lookAt(lookAt[0], lookAt[1], lookAt[2]);
1284
+ }
1285
+ else if (lookAt instanceof THREE.Vector3) {
1286
+ camera.lookAt(lookAt);
1287
+ }
1288
+ else {
1289
+ camera.lookAt(0, 0, 0);
1290
+ }
1291
+ }
1292
+ // Update projection matrix after applying props
1293
+ camera.updateProjectionMatrix();
1294
+ }
1295
+ if (!is.instance(camera)) {
1296
+ camera = prepare(camera, this.read, this.rootStateFactory, (_a = this.parentStore) === null || _a === void 0 ? void 0 : _a.get((s) => s.cameraRef));
1297
+ }
1298
+ this.write({ camera });
1299
+ this.read((s) => s.cameraRef).set(camera);
1300
+ }
1301
+ // Set up XR (one time only!)
1302
+ if (!state.xr) {
1303
+ // Handle frame behavior in WebXR
1304
+ const handleXRFrame = (timestamp, frame) => {
1305
+ const state = this.read();
1306
+ if (state.frameloop === 'never')
1307
+ return;
1308
+ advance(timestamp, true, this.read, frame);
1309
+ };
1310
+ // Toggle render switching on session
1311
+ const handleSessionChange = () => {
1312
+ const state = this.read();
1313
+ state.gl.xr.enabled = state.gl.xr.isPresenting;
1314
+ state.gl.xr.setAnimationLoop(state.gl.xr.isPresenting ? handleXRFrame : null);
1315
+ if (!state.gl.xr.isPresenting)
1316
+ invalidate(this.read);
1317
+ };
1318
+ // WebXR session manager
1319
+ const xr = {
1320
+ connect: () => {
1321
+ const gl = this.read((s) => s.gl);
1322
+ gl.xr.addEventListener('sessionstart', handleSessionChange);
1323
+ gl.xr.addEventListener('sessionend', handleSessionChange);
1324
+ },
1325
+ disconnect: () => {
1326
+ const gl = this.read((s) => s.gl);
1327
+ gl.xr.removeEventListener('sessionstart', handleSessionChange);
1328
+ gl.xr.removeEventListener('sessionend', handleSessionChange);
1329
+ },
1330
+ };
1331
+ // Subscribe to WebXR session events
1332
+ if (gl.xr)
1333
+ xr.connect();
1334
+ this.write({ xr });
1335
+ }
1336
+ // Set shadowmap
1337
+ if (gl.shadowMap) {
1338
+ const isBoolean = typeof shadows === 'boolean';
1339
+ if ((isBoolean && gl.shadowMap.enabled !== shadows) || !is.equ(shadows, gl.shadowMap, shallowLoose)) {
1340
+ const old = gl.shadowMap.enabled;
1341
+ gl.shadowMap.enabled = !!shadows;
1342
+ if (!isBoolean)
1343
+ Object.assign(gl.shadowMap, shadows);
1344
+ else
1345
+ gl.shadowMap.type = THREE.PCFSoftShadowMap;
1346
+ if (old !== gl.shadowMap.enabled)
1347
+ checkNeedsUpdate(gl.shadowMap);
1348
+ }
1349
+ }
1350
+ // Safely set color management if available.
1351
+ // Avoid accessing THREE.ColorManagement to play nice with older versions
1352
+ if (is.supportColorManagement()) {
1353
+ THREE.ColorManagement.legacyMode = state.legacy;
1354
+ }
1355
+ const outputEncoding = linear ? THREE.LinearEncoding : THREE.sRGBEncoding;
1356
+ const toneMapping = flat ? THREE.NoToneMapping : THREE.ACESFilmicToneMapping;
1357
+ if (gl.outputEncoding !== outputEncoding)
1358
+ gl.outputEncoding = outputEncoding;
1359
+ if (gl.toneMapping !== toneMapping)
1360
+ gl.toneMapping = toneMapping;
1361
+ // Update color management state
1362
+ if (state.legacy !== legacy)
1363
+ this.write({ legacy });
1364
+ if (state.linear !== linear)
1365
+ this.write({ linear });
1366
+ if (state.flat !== flat)
1367
+ this.write({ flat });
1368
+ // Set gl props
1369
+ gl.setClearAlpha(0);
1370
+ gl.setPixelRatio(makeDpr(state.viewport.dpr));
1371
+ gl.setSize(state.size.width, state.size.height, state.size.updateStyle);
1372
+ if (is.obj(glOptions) &&
1373
+ !(typeof glOptions === 'function') &&
1374
+ !is.glRenderer(glOptions) &&
1375
+ !is.equ(glOptions, gl, shallowLoose)) {
1376
+ applyProps(gl, glOptions);
1377
+ }
1378
+ // Store events internally
1379
+ if (events && !state.events.handlers) {
1380
+ this.write({ events: events(this.read) });
1381
+ }
1382
+ // Check pixelratio
1383
+ if (dpr && state.viewport.dpr !== makeDpr(dpr)) {
1384
+ state.setDpr(dpr);
1385
+ }
1386
+ // Check size, allow it to take on container bounds initially
1387
+ const size = computeInitialSize(canvasElement, sizeOptions);
1388
+ if (!is.equ(size, state.size, shallowLoose)) {
1389
+ state.setSize(size.width, size.height, size.top, size.left);
1390
+ }
1391
+ // Check frameloop
1392
+ if (state.frameloop !== frameloop)
1393
+ state.setFrameloop(frameloop);
1394
+ // Check performance
1395
+ if (performance && !is.equ(performance, state.performance, shallowLoose)) {
1396
+ this.write((state) => ({
1397
+ performance: Object.assign(Object.assign({}, state.performance), performance),
1398
+ }));
1399
+ }
1400
+ this.write({ ready: true });
1401
+ this.resize(this.select(this.select((s) => s.size), this.select((s) => s.viewport.dpr), defaultProjector, { debounce: true }));
1402
+ this.invalidate(this.select((s) => s, { debounce: true }));
1403
+ this.zone.run(() => {
1404
+ this.isConfigured = true;
1405
+ });
1406
+ }
1407
+ onReady(cb) {
1408
+ return this.effect(tapEffect(cb))(this.select((s) => s.ready).pipe(filter((ready) => ready)));
1409
+ }
1410
+ }
1411
+ NgtStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtStore, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1412
+ NgtStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtStore });
1413
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtStore, decorators: [{
1414
+ type: Injectable
1415
+ }] });
1416
+ function computeInitialSize(canvas, defaultSize) {
1417
+ if (defaultSize) {
1418
+ return defaultSize;
1419
+ }
1420
+ if (is.canvas(canvas) && canvas.parentElement) {
1421
+ const { width, height, top, left } = canvas.parentElement.getBoundingClientRect();
1422
+ return { width, height, top, left };
1423
+ }
1424
+ return { width: 0, height: 0, top: 0, left: 0 };
1425
+ }
1426
+
1427
+ function mutate(object, value, paths = []) {
1428
+ const [base, ...remaining] = paths;
1429
+ if (!base)
1430
+ return;
1431
+ if (remaining.length === 0) {
1432
+ applyProps(object, { [base]: value });
1433
+ }
1434
+ else {
1435
+ // assign an empty object in order to spread object if undefined
1436
+ assignEmpty(object, base);
1437
+ // recursion
1438
+ mutate(object[base], value, remaining);
1439
+ }
1440
+ }
1441
+ function assignEmpty(obj, base) {
1442
+ if (
1443
+ // @ts-ignore
1444
+ (!Object.hasOwn(obj, base) && Reflect && !!Reflect.has && !Reflect.has(obj, base)) ||
1445
+ obj[base] === undefined) {
1446
+ obj[base] = {};
1447
+ }
1448
+ }
1449
+
1450
+ const NGT_PROXY_INSTANCE = Symbol.for('__ngt__proxy__instance__');
1451
+ const NGT_INSTANCE_REF_FACTORY = new InjectionToken('NgtInstance[instanceRef] factory');
1452
+ function provideInstanceRef(ctor, factory) {
1453
+ return {
1454
+ provide: NGT_INSTANCE_REF_FACTORY,
1455
+ useFactory: (instance) => {
1456
+ if (factory) {
1457
+ return () => factory(instance);
1458
+ }
1459
+ return () => instance['instanceRef'] || instance['instance']['instanceRef'];
1460
+ },
1461
+ deps: [ctor],
1462
+ };
1463
+ }
1464
+ function injectInstanceRef(options = {}) {
1465
+ return inject(NGT_INSTANCE_REF_FACTORY, options);
1466
+ }
1467
+ function injectInstance(options = {}) {
1468
+ return inject(NgtInstance, options);
1469
+ }
1470
+ const supportedEvents = [
1471
+ 'click',
1472
+ 'contextmenu',
1473
+ 'dblclick',
1474
+ 'pointerup',
1475
+ 'pointerdown',
1476
+ 'pointerover',
1477
+ 'pointerout',
1478
+ 'pointerenter',
1479
+ 'pointerleave',
1480
+ 'pointermove',
1481
+ 'pointermissed',
1482
+ 'pointercancel',
1483
+ 'wheel',
1484
+ ];
1485
+ class NgtInstance extends NgtComponentStore {
1486
+ constructor() {
1487
+ super(...arguments);
1488
+ this.priority = 0;
1489
+ this.click = new EventEmitter();
1490
+ this.contextmenu = new EventEmitter();
1491
+ this.dblclick = new EventEmitter();
1492
+ this.pointerup = new EventEmitter();
1493
+ this.pointerdown = new EventEmitter();
1494
+ this.pointerover = new EventEmitter();
1495
+ this.pointerout = new EventEmitter();
1496
+ this.pointerenter = new EventEmitter();
1497
+ this.pointerleave = new EventEmitter();
1498
+ this.pointermove = new EventEmitter();
1499
+ this.pointermissed = new EventEmitter();
1500
+ this.pointercancel = new EventEmitter();
1501
+ this.wheel = new EventEmitter();
1502
+ this.zone = inject(NgZone);
1503
+ this.store = inject(NgtStore);
1504
+ this.parentRef = injectInstanceRef({ skipSelf: true, optional: true });
1505
+ this._isRaw = false;
1506
+ this.hasEmittedAlready = false;
1507
+ this.instanceReady = this.effect(tapEffect(() => {
1508
+ var _a, _b;
1509
+ this.handleEvents();
1510
+ let attachToParentSubscription;
1511
+ if (this.parentRef) {
1512
+ attachToParentSubscription = this.attachToParent(this.parent.pipe(filter((parent) => !!parent)));
1513
+ const { noAttach, skipWrapper } = this.read();
1514
+ if (!noAttach && !skipWrapper) {
1515
+ const parentInstanceNode = getInstanceLocalState((_b = (_a = getInstanceLocalState(this.instanceValue)) === null || _a === void 0 ? void 0 : _a.parentRef) === null || _b === void 0 ? void 0 : _b.value);
1516
+ if (parentInstanceNode) {
1517
+ const collections = is.object3d(this.instanceValue)
1518
+ ? parentInstanceNode.objectsRefs
1519
+ : parentInstanceNode.instancesRefs;
1520
+ collections.set((s) => [...s, this.instanceRef]);
1521
+ }
1522
+ }
1523
+ }
1524
+ let beforeRenderCleanUp;
1525
+ if (this.beforeRender && is.object3d(this.instanceValue) && is.object3d(this.proxyInstance)) {
1526
+ beforeRenderCleanUp = this.store
1527
+ .read((s) => s.internal)
1528
+ .subscribe((state, object) => this.beforeRender(state, object), this.priority, this.store.read, this.proxyInstance);
1529
+ }
1530
+ if (this.readyCallback)
1531
+ this.readyCallback(this.instanceValue);
1532
+ return () => {
1533
+ beforeRenderCleanUp === null || beforeRenderCleanUp === void 0 ? void 0 : beforeRenderCleanUp();
1534
+ attachToParentSubscription === null || attachToParentSubscription === void 0 ? void 0 : attachToParentSubscription.unsubscribe();
1535
+ };
1536
+ }));
1537
+ this.handleEvents = this.effect(tapEffect(() => {
1538
+ var _a;
1539
+ if (this.instanceValue && is.object3d(this.instanceValue)) {
1540
+ const observedEvents = supportedEvents.reduce((result, event) => {
1541
+ const controllerEvent = this[event].observed ? this[event] : null;
1542
+ if (controllerEvent) {
1543
+ result.handlers[event] = this.eventNameToHandler(controllerEvent);
1544
+ result.eventCount += 1;
1545
+ }
1546
+ return result;
1547
+ }, { handlers: {}, eventCount: 0 });
1548
+ // patch __ngt__ with events
1549
+ applyProps(this.__ngt__, observedEvents);
1550
+ // add as an interaction if there are events observed
1551
+ if (observedEvents.eventCount > 0) {
1552
+ (_a = getInstanceLocalState(this.instanceValue)) === null || _a === void 0 ? void 0 : _a.rootFactory().addInteraction(this.instanceValue);
1553
+ }
1554
+ }
1555
+ return () => {
1556
+ var _a;
1557
+ if (is.object3d(this.instanceValue) && this.__ngt__.eventCount > 0) {
1558
+ (_a = getInstanceLocalState(this.instanceValue)) === null || _a === void 0 ? void 0 : _a.rootFactory().removeInteraction(this.instanceValue.uuid);
1559
+ }
1560
+ };
1561
+ }));
1562
+ this.attachToParent = this.effect(tap(() => {
1563
+ var _a, _b, _c, _d;
1564
+ const attach = this.read((s) => s.attach);
1565
+ let parentInstanceRef = (_a = this.__ngt__) === null || _a === void 0 ? void 0 : _a.parentRef;
1566
+ // if no parentInstance, try re-run the factory due to late init
1567
+ if (!parentInstanceRef || !parentInstanceRef.value) {
1568
+ // return early if failed to retrieve
1569
+ if (!((_b = this.parent) === null || _b === void 0 ? void 0 : _b.value))
1570
+ return;
1571
+ // reassign on instance internal state
1572
+ if (this.__ngt__) {
1573
+ this.__ngt__.parentRef = this.parent;
1574
+ }
1575
+ parentInstanceRef = this.parent;
1576
+ }
1577
+ if (typeof attach === 'function') {
1578
+ const attachCleanUp = attach(parentInstanceRef, this.instanceRef, this.store.read);
1579
+ if (attachCleanUp) {
1580
+ this.__ngt__.attach = attachCleanUp;
1581
+ }
1582
+ }
1583
+ else {
1584
+ const propertyToAttach = [...attach];
1585
+ // if propertyToAttach is empty
1586
+ if (propertyToAttach.length === 0) {
1587
+ // this might be the case where we are attaching an object3D to the parent object3D
1588
+ if (is.object3d(this.instanceValue) &&
1589
+ is.object3d(this.proxyInstance) &&
1590
+ is.object3d((_c = this.parent) === null || _c === void 0 ? void 0 : _c.value)) {
1591
+ (_d = this.parent) === null || _d === void 0 ? void 0 : _d.value.add(this.proxyInstance);
1592
+ }
1593
+ }
1594
+ else {
1595
+ // array material handling
1596
+ if (propertyToAttach[0] === 'material' &&
1597
+ propertyToAttach[1] &&
1598
+ typeof Number(propertyToAttach[1]) === 'number' &&
1599
+ is.material(this.instanceValue)) {
1600
+ if (!Array.isArray(parentInstanceRef.value.material)) {
1601
+ parentInstanceRef.value.material = [];
1602
+ }
1603
+ }
1604
+ // retrieve the current value on the parentInstance, so we can reset it later
1605
+ if (this.__ngt__) {
1606
+ this.__ngt__.attachValue = propertyToAttach.reduce((value, property) => value[property], parentInstanceRef.value);
1607
+ }
1608
+ // attach the instance value on the parent
1609
+ mutate(parentInstanceRef.value, this.proxyInstance, propertyToAttach);
1610
+ }
1611
+ // validate on the instance
1612
+ invalidateInstance(this.instanceValue);
1613
+ // validate on the parent
1614
+ if (getInstanceLocalState(parentInstanceRef.value)) {
1615
+ invalidateInstance(parentInstanceRef.value);
1616
+ }
1617
+ // save the attach
1618
+ if (this.__ngt__) {
1619
+ this.__ngt__.attach = propertyToAttach;
1620
+ }
1621
+ this.write({ attach: propertyToAttach });
1622
+ }
1623
+ }));
1624
+ }
1625
+ set ref(instance) {
1626
+ this.write({ instanceRef: is.ref(instance) ? instance : new NgtRef(instance) });
1627
+ }
1628
+ set skipWrapper(skipWrapper) {
1629
+ this.write({ skipWrapper });
1630
+ this.write({ skipWrapperExplicit: true });
1631
+ }
1632
+ set skipInit(skipInit) {
1633
+ this.write({ skipInit });
1634
+ this.write({ skipInitExplicit: true });
1635
+ }
1636
+ set noAttach(noAttach) {
1637
+ this.write({ noAttach });
1638
+ this.write({ noAttachExplicit: true });
1639
+ }
1640
+ set attach(value) {
1641
+ if (value) {
1642
+ const attach = typeof value === 'function'
1643
+ ? value
1644
+ : Array.isArray(value)
1645
+ ? value.map((item) => (typeof item === 'number' ? item.toString() : item))
1646
+ : [value];
1647
+ this.write({ attach, attachExplicit: true });
1648
+ }
1649
+ }
1650
+ set isRaw(val) {
1651
+ this._isRaw = val;
1652
+ }
1653
+ initialize() {
1654
+ super.initialize();
1655
+ this.write({
1656
+ instanceRef: new NgtRef(null),
1657
+ attach: [],
1658
+ noAttach: false,
1659
+ skipWrapper: false,
1660
+ skipInit: false,
1661
+ });
1662
+ }
1663
+ ngOnInit() {
1664
+ this.zone.runOutsideAngular(() => {
1665
+ this.store.onReady(() => {
1666
+ this.instanceReady(this.instanceRef.pipe(filter((instance) => !!instance)));
1667
+ });
1668
+ });
1669
+ }
1670
+ get instanceRef() {
1671
+ return this.read((s) => s.instanceRef);
1672
+ }
1673
+ get instanceValue() {
1674
+ var _a;
1675
+ if (!this.instanceRef.value)
1676
+ return this.instanceRef.value;
1677
+ return this._isRaw ? (_a = this.instanceRef.value) === null || _a === void 0 ? void 0 : _a.valueOf() : this.instanceRef.value;
1678
+ }
1679
+ get proxyInstance() {
1680
+ var _a;
1681
+ return (_a = this.instanceValue) === null || _a === void 0 ? void 0 : _a[NGT_PROXY_INSTANCE];
1682
+ }
1683
+ get __ngt__() {
1684
+ return getInstanceLocalState(this._isRaw ? this.instanceRef.value : this.instanceValue);
1685
+ }
1686
+ get parent() {
1687
+ var _a;
1688
+ return (_a = this.parentRef) === null || _a === void 0 ? void 0 : _a.call(this);
1689
+ }
1690
+ ngOnDestroy() {
1691
+ this.zone.runOutsideAngular(() => {
1692
+ this.destroy();
1693
+ });
1694
+ super.ngOnDestroy();
1695
+ }
1696
+ destroy() {
1697
+ if (this.instanceValue) {
1698
+ if (is.object3d(this.instanceValue)) {
1699
+ const parentInstance = this.parent;
1700
+ if (parentInstance && is.object3d(parentInstance.value)) {
1701
+ removeInteractivity(this.__ngt__.stateFactory.bind(this.__ngt__), this.instanceValue);
1702
+ parentInstance.value.remove(this.instanceValue);
1703
+ invalidateInstance(parentInstance.value);
1704
+ }
1705
+ if (this.instanceValue.clear != null) {
1706
+ this.instanceValue.clear();
1707
+ }
1708
+ }
1709
+ else {
1710
+ if (this.__ngt__) {
1711
+ // non-scene objects
1712
+ const previousAttach = this.__ngt__.attach;
1713
+ if (previousAttach != null) {
1714
+ if (typeof previousAttach === 'function') {
1715
+ previousAttach();
1716
+ }
1717
+ else {
1718
+ const previousAttachValue = this.__ngt__.attachValue;
1719
+ if (this.__ngt__.parentRef && this.__ngt__.parentRef.value) {
1720
+ mutate(this.__ngt__.parentRef.value, previousAttachValue, previousAttach);
1721
+ }
1722
+ }
1723
+ if (this.__ngt__.parentRef && this.__ngt__.parentRef.value) {
1724
+ invalidateInstance(this.__ngt__.parentRef.value);
1725
+ }
1726
+ }
1727
+ }
1728
+ }
1729
+ const dispose = this.instanceValue['dispose'];
1730
+ if (dispose && typeof dispose === 'function') {
1731
+ dispose.apply(this.instanceValue);
1732
+ }
1733
+ }
1734
+ this.write({ attach: [] });
1735
+ this.instanceRef.complete();
1736
+ }
1737
+ eventNameToHandler(controllerEvent) {
1738
+ return (event) => {
1739
+ // go back into Angular Zone so that state updates on these events trigger CD
1740
+ this.zone.run(() => {
1741
+ controllerEvent.emit(event);
1742
+ });
1743
+ };
1744
+ }
1745
+ }
1746
+ NgtInstance.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtInstance, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1747
+ NgtInstance.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.0", type: NgtInstance, isStandalone: true, selector: "[ngtInstance]", inputs: { ref: "ref", skipWrapper: "skipWrapper", skipInit: "skipInit", noAttach: "noAttach", attach: "attach", priority: "priority", beforeRender: "beforeRender", readyCallback: "readyCallback", updateCallback: "updateCallback" }, outputs: { click: "click", contextmenu: "contextmenu", dblclick: "dblclick", pointerup: "pointerup", pointerdown: "pointerdown", pointerover: "pointerover", pointerout: "pointerout", pointerenter: "pointerenter", pointerleave: "pointerleave", pointermove: "pointermove", pointermissed: "pointermissed", pointercancel: "pointercancel", wheel: "wheel" }, exportAs: ["ngtInstance"], usesInheritance: true, ngImport: i0 });
1748
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtInstance, decorators: [{
1749
+ type: Directive,
1750
+ args: [{
1751
+ selector: '[ngtInstance]',
1752
+ exportAs: 'ngtInstance',
1753
+ standalone: true,
1754
+ }]
1755
+ }], propDecorators: { ref: [{
1756
+ type: Input
1757
+ }], skipWrapper: [{
1758
+ type: Input
1759
+ }], skipInit: [{
1760
+ type: Input
1761
+ }], noAttach: [{
1762
+ type: Input
1763
+ }], attach: [{
1764
+ type: Input
1765
+ }], priority: [{
1766
+ type: Input
1767
+ }], beforeRender: [{
1768
+ type: Input
1769
+ }], readyCallback: [{
1770
+ type: Input
1771
+ }], updateCallback: [{
1772
+ type: Input
1773
+ }], click: [{
1774
+ type: Output
1775
+ }], contextmenu: [{
1776
+ type: Output
1777
+ }], dblclick: [{
1778
+ type: Output
1779
+ }], pointerup: [{
1780
+ type: Output
1781
+ }], pointerdown: [{
1782
+ type: Output
1783
+ }], pointerover: [{
1784
+ type: Output
1785
+ }], pointerout: [{
1786
+ type: Output
1787
+ }], pointerenter: [{
1788
+ type: Output
1789
+ }], pointerleave: [{
1790
+ type: Output
1791
+ }], pointermove: [{
1792
+ type: Output
1793
+ }], pointermissed: [{
1794
+ type: Output
1795
+ }], pointercancel: [{
1796
+ type: Output
1797
+ }], wheel: [{
1798
+ type: Output
1799
+ }] } });
1800
+ const NGT_INSTANCE_INPUTS = [
1801
+ 'ref',
1802
+ 'attach',
1803
+ 'skipWrapper',
1804
+ 'skipInit',
1805
+ 'noAttach',
1806
+ 'beforeRender',
1807
+ 'priority',
1808
+ 'updateCallback',
1809
+ 'readyCallback',
1810
+ ];
1811
+ const NGT_INSTANCE_OUTPUTS = [...supportedEvents];
1812
+
1813
+ const defaultResizeOptions = {
1814
+ box: 'content-box',
1815
+ scroll: false,
1816
+ offsetSize: false,
1817
+ debounce: { scroll: 50, resize: 0 },
1818
+ };
1819
+ const [injectResizeOptions, provideResizeOptions] = createInjection('ngtResize Options', {
1820
+ defaultValueOrFactory: defaultResizeOptions,
1821
+ provideValueFactory: (value) => (Object.assign(Object.assign({}, defaultResizeOptions), value)),
1822
+ });
1823
+ const [injectResizeObserverSupport] = createInjection('Resize Observer API support', {
1824
+ defaultValueOrFactory: () => {
1825
+ const window = injectWindow();
1826
+ return 'ResizeObserver' in window && window['ResizeObserver'] != null;
1827
+ },
1828
+ });
1829
+
1830
+ class NgtResize extends Observable {
1831
+ constructor() {
1832
+ const { nativeElement } = inject(ElementRef);
1833
+ const zone = inject(NgZone);
1834
+ const document = inject(DOCUMENT);
1835
+ const window = injectWindow();
1836
+ const isSupport = injectResizeObserverSupport();
1837
+ const { box, offsetSize, scroll, debounce } = injectResizeOptions();
1838
+ let observer;
1839
+ let lastBounds;
1840
+ let lastEntries = [];
1841
+ const torndown$ = new Subject();
1842
+ const scrollContainers = findScrollContainers(nativeElement, document.body);
1843
+ // set actual debounce values early, so effects know if they should react accordingly
1844
+ const scrollDebounce = debounce ? (typeof debounce === 'number' ? debounce : debounce.scroll) : null;
1845
+ const resizeDebounce = debounce ? (typeof debounce === 'number' ? debounce : debounce.resize) : null;
1846
+ const debounceAndDestroy = (debounce) => {
1847
+ return pipe(debounceTime(debounce !== null && debounce !== void 0 ? debounce : 0), takeUntil(torndown$));
1848
+ };
1849
+ super((subscriber) => {
1850
+ if (!isSupport) {
1851
+ subscriber.error('ResizeObserver is not supported in your browser. Please use a polyfill');
1852
+ return;
1853
+ }
1854
+ zone.runOutsideAngular(() => {
1855
+ const callback = (entries) => {
1856
+ lastEntries = entries;
1857
+ const { left, top, width, height, bottom, right, x, y } = nativeElement.getBoundingClientRect();
1858
+ const size = {
1859
+ left,
1860
+ top,
1861
+ width,
1862
+ height,
1863
+ bottom,
1864
+ right,
1865
+ x,
1866
+ y,
1867
+ };
1868
+ if (nativeElement instanceof HTMLElement && offsetSize) {
1869
+ size.height = nativeElement.offsetHeight;
1870
+ size.width = nativeElement.offsetWidth;
1871
+ }
1872
+ Object.freeze(size);
1873
+ subscriber.next(Object.assign({ entries, dpr: window.devicePixelRatio }, size));
1874
+ if (!areBoundsEqual(lastBounds || {}, size)) {
1875
+ lastBounds = size;
1876
+ }
1877
+ };
1878
+ const boundEntriesCallback = () => {
1879
+ callback(lastEntries);
1880
+ };
1881
+ observer = new ResizeObserver(callback);
1882
+ observer.observe(nativeElement, { box });
1883
+ if (scroll) {
1884
+ if (scrollContainers) {
1885
+ scrollContainers.forEach((scrollContainer) => {
1886
+ fromEvent(scrollContainer, 'scroll', {
1887
+ capture: true,
1888
+ passive: true,
1889
+ })
1890
+ .pipe(debounceAndDestroy(scrollDebounce))
1891
+ .subscribe(boundEntriesCallback);
1892
+ });
1893
+ }
1894
+ fromEvent(window, 'scroll', {
1895
+ capture: true,
1896
+ passive: true,
1897
+ })
1898
+ .pipe(debounceAndDestroy(scrollDebounce))
1899
+ .subscribe(boundEntriesCallback);
1900
+ }
1901
+ fromEvent(window, 'resize').pipe(debounceAndDestroy(resizeDebounce)).subscribe(boundEntriesCallback);
1902
+ });
1903
+ return () => {
1904
+ if (observer) {
1905
+ observer.unobserve(nativeElement);
1906
+ observer.disconnect();
1907
+ }
1908
+ torndown$.next();
1909
+ torndown$.complete();
1910
+ };
1911
+ });
1912
+ return this.pipe(debounceTime(scrollDebounce || 0), share({
1913
+ connector: () => new ReplaySubject(1),
1914
+ resetOnRefCountZero: true,
1915
+ resetOnComplete: true,
1916
+ }));
1917
+ }
1918
+ }
1919
+ NgtResize.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtResize, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1920
+ NgtResize.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtResize });
1921
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtResize, decorators: [{
1922
+ type: Injectable
1923
+ }], ctorParameters: function () { return []; } });
1924
+ // Returns a list of scroll offsets
1925
+ function findScrollContainers(element, documentBody) {
1926
+ const result = [];
1927
+ if (!element || element === documentBody)
1928
+ return result;
1929
+ const { overflow, overflowX, overflowY } = window.getComputedStyle(element);
1930
+ if ([overflow, overflowX, overflowY].some((prop) => prop === 'auto' || prop === 'scroll'))
1931
+ result.push(element);
1932
+ return [...result, ...findScrollContainers(element.parentElement, documentBody)];
1933
+ }
1934
+ // Checks if element boundaries are equal
1935
+ const keys = [
1936
+ 'x',
1937
+ 'y',
1938
+ 'top',
1939
+ 'bottom',
1940
+ 'left',
1941
+ 'right',
1942
+ 'width',
1943
+ 'height',
1944
+ ];
1945
+ const areBoundsEqual = (a, b) => keys.every((key) => a[key] === b[key]);
1946
+
1947
+ function buildGraph(object) {
1948
+ const data = { nodes: {}, materials: {} };
1949
+ if (object) {
1950
+ object.traverse((obj) => {
1951
+ if (obj.name)
1952
+ data.nodes[obj.name] = obj;
1953
+ if ('material' in obj && !data.materials[obj.material.name]) {
1954
+ data.materials[obj.material.name] = obj
1955
+ .material;
1956
+ }
1957
+ });
1958
+ }
1959
+ return data;
1960
+ }
1961
+
1962
+ class NgtLoader {
1963
+ constructor() {
1964
+ this.cached = new Map();
1965
+ }
1966
+ use(loadConstructor, input, extensions, onProgress) {
1967
+ const urls = Array.isArray(input) ? input : [input];
1968
+ const loader = new loadConstructor();
1969
+ if (extensions) {
1970
+ extensions(loader);
1971
+ }
1972
+ const observables$ = urls.map((url) => {
1973
+ if (!this.cached.has(url)) {
1974
+ this.cached.set(url, from(loader.loadAsync(url, onProgress)).pipe(tap((data) => {
1975
+ if (data.scene) {
1976
+ Object.assign(data, buildGraph(data.scene));
1977
+ }
1978
+ }), retry(2), catchError((err) => {
1979
+ console.error(`[NgtLoader]: Error loading ${url}: ${err.message}`);
1980
+ return of(null);
1981
+ }), share({
1982
+ connector: () => new ReplaySubject(1),
1983
+ resetOnComplete: true,
1984
+ resetOnRefCountZero: true,
1985
+ resetOnError: true,
1986
+ })));
1987
+ }
1988
+ return this.cached.get(url);
1989
+ });
1990
+ return forkJoin(observables$).pipe(map((results) => (Array.isArray(input) ? results : results[0])));
1991
+ }
1992
+ destroy() {
1993
+ this.cached.clear();
1994
+ }
1995
+ }
1996
+ NgtLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtLoader, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1997
+ NgtLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtLoader, providedIn: 'root' });
1998
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtLoader, decorators: [{
1999
+ type: Injectable,
2000
+ args: [{ providedIn: 'root' }]
2001
+ }] });
2002
+
2003
+ class NgtCanvasContainer {
2004
+ constructor() {
2005
+ this.resize = inject(NgtResize);
2006
+ }
2007
+ }
2008
+ NgtCanvasContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtCanvasContainer, deps: [], target: i0.ɵɵFactoryTarget.Component });
2009
+ NgtCanvasContainer.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.0", type: NgtCanvasContainer, isStandalone: true, selector: "ngt-canvas-container", outputs: { resize: "resize" }, providers: [NgtResize], ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: [":host{display:block;height:100%;width:100%}\n"] });
2010
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtCanvasContainer, decorators: [{
2011
+ type: Component,
2012
+ args: [{ selector: 'ngt-canvas-container', standalone: true, template: '<ng-content></ng-content>', providers: [NgtResize], styles: [":host{display:block;height:100%;width:100%}\n"] }]
2013
+ }], propDecorators: { resize: [{
2014
+ type: Output
2015
+ }] } });
2016
+ class NgtCanvas extends NgtComponentStore {
2017
+ constructor() {
2018
+ super(...arguments);
2019
+ this.hostClass = true;
2020
+ this.created = new EventEmitter();
2021
+ this.canvasPointerMissed = new EventEmitter();
2022
+ this.zone = inject(NgZone);
2023
+ this.loader = inject(NgtLoader);
2024
+ this.store = inject(NgtStore, { self: true });
2025
+ this.host = inject(ElementRef);
2026
+ }
2027
+ get pointerEvents() {
2028
+ return this.read((s) => s.eventSource) !== this.host.nativeElement ? 'none' : 'auto';
2029
+ }
2030
+ set linear(linear) {
2031
+ this.write({ linear });
2032
+ }
2033
+ set legacy(legacy) {
2034
+ this.write({ legacy });
2035
+ }
2036
+ set flat(flat) {
2037
+ this.write({ flat });
2038
+ }
2039
+ set orthographic(orthographic) {
2040
+ this.write({ orthographic });
2041
+ }
2042
+ set frameloop(frameloop) {
2043
+ this.write({ frameloop });
2044
+ }
2045
+ set dpr(dpr) {
2046
+ this.write({ dpr });
2047
+ }
2048
+ set raycaster(raycaster) {
2049
+ this.write({ raycaster });
2050
+ }
2051
+ set shadows(shadows) {
2052
+ this.write({
2053
+ shadows: typeof shadows === 'object' ? shadows : shadows,
2054
+ });
2055
+ }
2056
+ set camera(camera) {
2057
+ this.write({ camera });
2058
+ }
2059
+ set gl(gl) {
2060
+ this.write({ gl });
2061
+ }
2062
+ set eventSource(eventSource) {
2063
+ this.write({ eventSource });
2064
+ }
2065
+ set eventPrefix(eventPrefix) {
2066
+ this.write({ eventPrefix });
2067
+ }
2068
+ set lookAt(lookAt) {
2069
+ this.write({ lookAt });
2070
+ }
2071
+ set performance(performance) {
2072
+ this.write({ performance });
2073
+ }
2074
+ get sceneRef() {
2075
+ return this.store.read((s) => s.sceneRef);
2076
+ }
2077
+ get isConfigured() {
2078
+ return this.store.isConfigured;
2079
+ }
2080
+ initialize() {
2081
+ super.initialize();
2082
+ this.write({
2083
+ shadows: false,
2084
+ linear: false,
2085
+ flat: false,
2086
+ legacy: false,
2087
+ orthographic: false,
2088
+ frameloop: 'always',
2089
+ dpr: [1, 2],
2090
+ events: createPointerEvents,
2091
+ });
2092
+ }
2093
+ ngOnInit() {
2094
+ this.zone.runOutsideAngular(() => {
2095
+ if (!this.eventSource) {
2096
+ this.eventSource = this.host.nativeElement;
2097
+ }
2098
+ if (this.canvasPointerMissed.observed) {
2099
+ // update pointerMissed event
2100
+ this.store.write({
2101
+ onPointerMissed: (event) => {
2102
+ // go back into angular zone
2103
+ this.zone.run(() => {
2104
+ this.canvasPointerMissed.emit(event);
2105
+ });
2106
+ },
2107
+ });
2108
+ }
2109
+ // set rootStateMap
2110
+ rootStateMap.set(this.glCanvas.nativeElement, this.store.read);
2111
+ // setup canvas state
2112
+ this.store.init();
2113
+ this.store.onReady(() => {
2114
+ var _a, _b;
2115
+ const state = this.store.read();
2116
+ const inputs = this.read();
2117
+ // canvas is ready
2118
+ this.store.write((s) => ({ internal: Object.assign(Object.assign({}, s.internal), { active: true }) }));
2119
+ // Connect to eventsource
2120
+ (_b = (_a = state.events).connect) === null || _b === void 0 ? void 0 : _b.call(_a, inputs.eventSource instanceof ElementRef ? inputs.eventSource.nativeElement : inputs.eventSource);
2121
+ // Set up compute function
2122
+ if (inputs.eventPrefix) {
2123
+ state.setEvents({
2124
+ compute: (event, stateGetter) => {
2125
+ const innerState = stateGetter();
2126
+ const x = event[(inputs.eventPrefix + 'X')];
2127
+ const y = event[(inputs.eventPrefix + 'Y')];
2128
+ innerState.pointer.set((x / innerState.size.width) * 2 - 1, -(y / innerState.size.height) * 2 + 1);
2129
+ innerState.raycaster.setFromCamera(innerState.pointer, innerState.camera);
2130
+ },
2131
+ });
2132
+ }
2133
+ if (this.created.observed) {
2134
+ this.zone.run(() => {
2135
+ requestAnimationFrame(() => {
2136
+ this.created.emit(this.store.read());
2137
+ });
2138
+ });
2139
+ }
2140
+ });
2141
+ });
2142
+ }
2143
+ onResize(resizeResult) {
2144
+ this.zone.runOutsideAngular(() => {
2145
+ const { width, height } = resizeResult;
2146
+ if (width > 0 && height > 0) {
2147
+ if (!this.store.isInit) {
2148
+ this.store.init();
2149
+ }
2150
+ this.store.configure(this.read(), this.glCanvas.nativeElement);
2151
+ }
2152
+ });
2153
+ }
2154
+ ngOnDestroy() {
2155
+ this.loader.destroy();
2156
+ super.ngOnDestroy();
2157
+ }
2158
+ }
2159
+ NgtCanvas.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtCanvas, deps: null, target: i0.ɵɵFactoryTarget.Component });
2160
+ NgtCanvas.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.0", type: NgtCanvas, isStandalone: true, selector: "ngt-canvas", inputs: { linear: "linear", legacy: "legacy", flat: "flat", orthographic: "orthographic", frameloop: "frameloop", dpr: "dpr", raycaster: "raycaster", shadows: "shadows", camera: "camera", gl: "gl", eventSource: "eventSource", eventPrefix: "eventPrefix", lookAt: "lookAt", performance: "performance" }, outputs: { created: "created", canvasPointerMissed: "canvasPointerMissed" }, host: { properties: { "class.ngt-canvas": "this.hostClass", "style.pointerEvents": "this.pointerEvents" } }, providers: [NgtStore, provideInstanceRef(NgtCanvas, (canvas) => canvas.sceneRef)], queries: [{ propertyName: "canvasContent", first: true, predicate: TemplateRef, descendants: true, static: true }], viewQueries: [{ propertyName: "glCanvas", first: true, predicate: ["glCanvas"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: `
2161
+ <ngt-canvas-container (resize)="onResize($event)">
2162
+ <canvas #glCanvas style="display: block">
2163
+ <ng-container *ngIf="isConfigured" [ngTemplateOutlet]="canvasContent"></ng-container>
2164
+ <ng-content></ng-content>
2165
+ </canvas>
2166
+ </ngt-canvas-container>
2167
+ `, isInline: true, styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden}\n"], dependencies: [{ kind: "component", type: NgtCanvasContainer, selector: "ngt-canvas-container", outputs: ["resize"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2168
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtCanvas, decorators: [{
2169
+ type: Component,
2170
+ args: [{ selector: 'ngt-canvas', standalone: true, template: `
2171
+ <ngt-canvas-container (resize)="onResize($event)">
2172
+ <canvas #glCanvas style="display: block">
2173
+ <ng-container *ngIf="isConfigured" [ngTemplateOutlet]="canvasContent"></ng-container>
2174
+ <ng-content></ng-content>
2175
+ </canvas>
2176
+ </ngt-canvas-container>
2177
+ `, changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgtCanvasContainer, NgIf, NgTemplateOutlet, AsyncPipe], providers: [NgtStore, provideInstanceRef(NgtCanvas, (canvas) => canvas.sceneRef)], styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden}\n"] }]
2178
+ }], propDecorators: { hostClass: [{
2179
+ type: HostBinding,
2180
+ args: ['class.ngt-canvas']
2181
+ }], pointerEvents: [{
2182
+ type: HostBinding,
2183
+ args: ['style.pointerEvents']
2184
+ }], linear: [{
2185
+ type: Input
2186
+ }], legacy: [{
2187
+ type: Input
2188
+ }], flat: [{
2189
+ type: Input
2190
+ }], orthographic: [{
2191
+ type: Input
2192
+ }], frameloop: [{
2193
+ type: Input
2194
+ }], dpr: [{
2195
+ type: Input
2196
+ }], raycaster: [{
2197
+ type: Input
2198
+ }], shadows: [{
2199
+ type: Input
2200
+ }], camera: [{
2201
+ type: Input
2202
+ }], gl: [{
2203
+ type: Input
2204
+ }], eventSource: [{
2205
+ type: Input
2206
+ }], eventPrefix: [{
2207
+ type: Input
2208
+ }], lookAt: [{
2209
+ type: Input
2210
+ }], performance: [{
2211
+ type: Input
2212
+ }], created: [{
2213
+ type: Output
2214
+ }], canvasPointerMissed: [{
2215
+ type: Output
2216
+ }], glCanvas: [{
2217
+ type: ViewChild,
2218
+ args: ['glCanvas', { static: true }]
2219
+ }], canvasContent: [{
2220
+ type: ContentChild,
2221
+ args: [TemplateRef, { static: true }]
2222
+ }] } });
2223
+
2224
+ const NGT_ARGS = new InjectionToken('NgtArgs');
2225
+ function injectArgs(options = {}) {
2226
+ return inject(NGT_ARGS, options);
2227
+ }
2228
+ class NgtArgs {
2229
+ constructor() {
2230
+ this.templateRef = inject(TemplateRef);
2231
+ this.vcr = inject(ViewContainerRef);
2232
+ }
2233
+ set args(args) {
2234
+ if (this.view) {
2235
+ this.view.destroy();
2236
+ }
2237
+ this.view = this.vcr.createEmbeddedView(this.templateRef, {}, { injector: Injector.create({ providers: [{ provide: NGT_ARGS, useValue: args }] }) });
2238
+ }
2239
+ }
2240
+ NgtArgs.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtArgs, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2241
+ NgtArgs.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.0", type: NgtArgs, isStandalone: true, selector: "[args]", inputs: { args: "args" }, ngImport: i0 });
2242
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtArgs, decorators: [{
2243
+ type: Directive,
2244
+ args: [{
2245
+ selector: '[args]',
2246
+ standalone: true,
2247
+ }]
2248
+ }], propDecorators: { args: [{
2249
+ type: Input
2250
+ }] } });
2251
+
2252
+ class NgtCursor {
2253
+ constructor(instance, document) {
2254
+ if (!instance)
2255
+ return;
2256
+ merge(instance.pointerover.pipe(map(() => true)), instance.pointerout.pipe(map(() => false)))
2257
+ .pipe(takeUntil(instance.destroy$))
2258
+ .subscribe((hovered) => {
2259
+ document.body.style.cursor = hovered ? 'pointer' : 'auto';
2260
+ });
2261
+ }
2262
+ }
2263
+ NgtCursor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtCursor, deps: [{ token: NgtInstance, optional: true, self: true }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Directive });
2264
+ NgtCursor.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.0", type: NgtCursor, isStandalone: true, selector: "[ngtCursor]", exportAs: ["ngtCursor"], ngImport: i0 });
2265
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtCursor, decorators: [{
2266
+ type: Directive,
2267
+ args: [{
2268
+ selector: '[ngtCursor]',
2269
+ standalone: true,
2270
+ exportAs: 'ngtCursor',
2271
+ }]
2272
+ }], ctorParameters: function () {
2273
+ return [{ type: NgtInstance, decorators: [{
2274
+ type: Optional
2275
+ }, {
2276
+ type: Self
2277
+ }] }, { type: Document, decorators: [{
2278
+ type: Inject,
2279
+ args: [DOCUMENT]
2280
+ }] }];
2281
+ } });
2282
+
2283
+ class NgtRepeat extends NgForOf {
2284
+ set ngForRepeat(count) {
2285
+ this.ngForOf = Number.isInteger(count) ? Array.from({ length: count }, (_, i) => i) : [];
2286
+ }
2287
+ }
2288
+ NgtRepeat.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtRepeat, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2289
+ NgtRepeat.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.0", type: NgtRepeat, isStandalone: true, selector: "[ngFor][ngForRepeat]", inputs: { ngForRepeat: "ngForRepeat" }, usesInheritance: true, ngImport: i0 });
2290
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtRepeat, decorators: [{
2291
+ type: Directive,
12
2292
  args: [{
13
- imports: [CommonModule],
2293
+ selector: '[ngFor][ngForRepeat]',
2294
+ standalone: true,
14
2295
  }]
2296
+ }], propDecorators: { ngForRepeat: [{
2297
+ type: Input
2298
+ }] } });
2299
+
2300
+ class NgtPiPipe {
2301
+ transform(value) {
2302
+ return value * Math.PI;
2303
+ }
2304
+ }
2305
+ NgtPiPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtPiPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2306
+ NgtPiPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.0.0", ngImport: i0, type: NgtPiPipe, isStandalone: true, name: "pi" });
2307
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtPiPipe, decorators: [{
2308
+ type: Pipe,
2309
+ args: [{ name: 'pi', standalone: true }]
2310
+ }] });
2311
+
2312
+ class NgtMathPipe {
2313
+ transform(value, keyOfMath) {
2314
+ const params = Array.isArray(value) ? value : [value];
2315
+ return Math[keyOfMath](...params);
2316
+ }
2317
+ }
2318
+ NgtMathPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtMathPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2319
+ NgtMathPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.0.0", ngImport: i0, type: NgtMathPipe, isStandalone: true, name: "math" });
2320
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtMathPipe, decorators: [{
2321
+ type: Pipe,
2322
+ args: [{ name: 'math', standalone: true }]
15
2323
  }] });
16
2324
 
2325
+ class NgtRadianPipe {
2326
+ transform(degree) {
2327
+ return (degree * Math.PI) / 180;
2328
+ }
2329
+ }
2330
+ NgtRadianPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtRadianPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2331
+ NgtRadianPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.0.0", ngImport: i0, type: NgtRadianPipe, isStandalone: true, name: "radian" });
2332
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtRadianPipe, decorators: [{
2333
+ type: Pipe,
2334
+ args: [{ name: 'radian', standalone: true }]
2335
+ }] });
2336
+
2337
+ class NgtSidePipe {
2338
+ transform(side) {
2339
+ switch (side) {
2340
+ case 'front':
2341
+ return THREE.FrontSide;
2342
+ case 'back':
2343
+ return THREE.BackSide;
2344
+ case 'double':
2345
+ return THREE.DoubleSide;
2346
+ }
2347
+ }
2348
+ }
2349
+ NgtSidePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtSidePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2350
+ NgtSidePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.0.0", ngImport: i0, type: NgtSidePipe, isStandalone: true, name: "side" });
2351
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgtSidePipe, decorators: [{
2352
+ type: Pipe,
2353
+ args: [{ name: 'side', standalone: true }]
2354
+ }] });
2355
+
2356
+ function capitalize(str) {
2357
+ return str.charAt(0).toUpperCase() + str.slice(1);
2358
+ }
2359
+
2360
+ function proxify(instance, proxifyOptions = {}) {
2361
+ const ngtInstance = injectInstance({ host: true });
2362
+ const store = inject(NgtStore);
2363
+ const zone = inject(NgZone);
2364
+ const parentInstance = injectInstanceRef({ skipSelf: true, optional: true });
2365
+ return zone.runOutsideAngular(() => {
2366
+ // prep the instance w/ local state
2367
+ instance = prepare(instance, store.read, store.rootStateFactory, parentInstance === null || parentInstance === void 0 ? void 0 : parentInstance(), ngtInstance.instanceValue ? ngtInstance.instanceRef : undefined, !!proxifyOptions.primitive);
2368
+ let storeReadySubscription;
2369
+ const newValueSubscriptionMap = new Map();
2370
+ function setProp(obj, prop, newValue) {
2371
+ const capitalizedProp = `set${capitalize(prop)}`;
2372
+ if (isObservable(newValue)) {
2373
+ const sub = newValue.subscribe((val) => {
2374
+ if (obj[capitalizedProp] && typeof obj[capitalizedProp] === 'function') {
2375
+ obj[capitalizedProp](val);
2376
+ }
2377
+ else {
2378
+ applyProps(obj, { [prop]: val });
2379
+ }
2380
+ ngtInstance.write({ [prop]: val });
2381
+ });
2382
+ return () => sub.unsubscribe();
2383
+ }
2384
+ if (obj[capitalizedProp] && typeof obj[capitalizedProp] === 'function') {
2385
+ obj[capitalizedProp](newValue);
2386
+ }
2387
+ else {
2388
+ applyProps(obj, { [prop]: newValue });
2389
+ }
2390
+ ngtInstance.write({ [prop]: newValue });
2391
+ return;
2392
+ }
2393
+ const handler = {
2394
+ get(target, p, receiver) {
2395
+ if (p === 'instanceRef')
2396
+ return ngtInstance.instanceRef;
2397
+ if (p === 'instance')
2398
+ return ngtInstance;
2399
+ if (p === NGT_PROXY_INSTANCE)
2400
+ return target;
2401
+ const capitalizedProp = `get${capitalize(p)}`;
2402
+ if (target[capitalizedProp] && typeof target[capitalizedProp] === 'function') {
2403
+ return target[capitalizedProp]();
2404
+ }
2405
+ return Reflect.get(target, p, receiver);
2406
+ },
2407
+ set(target, p, newValue, receiver) {
2408
+ const prop = p;
2409
+ if (storeReadySubscription)
2410
+ storeReadySubscription.unsubscribe();
2411
+ if (newValueSubscriptionMap.has(prop))
2412
+ newValueSubscriptionMap.get(prop)();
2413
+ // Angular sets this property
2414
+ if (p === '__ngContext__')
2415
+ return Reflect.set(target, p, newValue, receiver);
2416
+ return zone.runOutsideAngular(() => {
2417
+ // TODO: figure out what else we need to handle
2418
+ // we should handle if newValue is an Observable as well
2419
+ if (store.read((s) => s.ready)) {
2420
+ const cleanUp = setProp(instance, prop, newValue);
2421
+ if (cleanUp)
2422
+ newValueSubscriptionMap.set(prop, cleanUp);
2423
+ }
2424
+ else {
2425
+ storeReadySubscription = store.onReady(() => setProp(instance, prop, newValue));
2426
+ }
2427
+ // schedule updateCallback on next event loop
2428
+ queueMicrotask(() => {
2429
+ if (ngtInstance.updateCallback)
2430
+ ngtInstance.updateCallback(instance);
2431
+ });
2432
+ return true;
2433
+ });
2434
+ },
2435
+ };
2436
+ ngtInstance.effect(tapEffect(() => () => {
2437
+ if (storeReadySubscription)
2438
+ storeReadySubscription.unsubscribe();
2439
+ newValueSubscriptionMap.forEach((cleanUp) => cleanUp());
2440
+ }))();
2441
+ const proxied = new Proxy(instance, handler);
2442
+ if (proxifyOptions.attach)
2443
+ ngtInstance.attach = proxifyOptions.attach;
2444
+ if (proxifyOptions.created)
2445
+ proxifyOptions.created(proxied, store.read, ngtInstance);
2446
+ ngtInstance.instanceRef.set(proxied);
2447
+ return proxied;
2448
+ });
2449
+ }
2450
+
2451
+ /**
2452
+ * main exports
2453
+ */
2454
+
17
2455
  /**
18
2456
  * Generated bundle index. Do not edit.
19
2457
  */
20
2458
 
21
- export { AngularThreeModule };
2459
+ export { NGT_ARGS, NGT_INSTANCE_INPUTS, NGT_INSTANCE_OUTPUTS, NGT_INSTANCE_REF_FACTORY, NGT_PROXY_INSTANCE, NgtArgs, NgtCanvas, NgtCanvasContainer, NgtComponentStore, NgtCursor, NgtInstance, NgtLoader, NgtMathPipe, NgtPiPipe, NgtRadianPipe, NgtRepeat, NgtResize, NgtSidePipe, NgtStore, addAfterEffect, addEffect, addTail, createLoop, defaultProjector, defaultResizeOptions, flushGlobalEffects, injectArgs, injectInstance, injectInstanceRef, injectResizeObserverSupport, injectResizeOptions, provideInstanceRef, provideResizeOptions, proxify, rootStateMap, skipFirstUndefined, tapEffect };
22
2460
  //# sourceMappingURL=angular-three.mjs.map