gaesup-world 0.9.52 → 0.9.54

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 (318) hide show
  1. package/dist/gaesup/animation/actions.ts +161 -0
  2. package/dist/gaesup/camera/control/normal.ts +27 -0
  3. package/dist/gaesup/camera/control/orbit.ts +37 -0
  4. package/dist/gaesup/camera/index.tsx +29 -0
  5. package/dist/gaesup/camera/type.ts +14 -0
  6. package/dist/gaesup/component/active/airplane/index.tsx +17 -0
  7. package/dist/gaesup/component/active/airplane/{type.d.ts → type.ts} +2 -1
  8. package/dist/gaesup/component/active/character/index.tsx +35 -0
  9. package/dist/gaesup/component/active/character/type.ts +13 -0
  10. package/dist/gaesup/component/active/vehicle/index.tsx +17 -0
  11. package/dist/gaesup/component/active/vehicle/{type.d.ts → type.ts} +2 -1
  12. package/dist/gaesup/component/index.tsx +65 -0
  13. package/dist/gaesup/component/inner/airplane/index.tsx +21 -0
  14. package/dist/gaesup/component/inner/airplane/type.ts +8 -0
  15. package/dist/gaesup/component/inner/character/index.tsx +22 -0
  16. package/dist/gaesup/component/inner/character/{type.d.ts → type.ts} +10 -6
  17. package/dist/gaesup/component/inner/common/InnerGroupRef.tsx +56 -0
  18. package/dist/gaesup/component/inner/common/OuterGroupRef.tsx +19 -0
  19. package/dist/gaesup/component/inner/common/{RigidbodyRef.js → RigidbodyRef.tsx} +135 -58
  20. package/dist/gaesup/component/inner/common/calc.ts +16 -0
  21. package/dist/gaesup/component/inner/common/partsGroupRef.tsx +66 -0
  22. package/dist/gaesup/component/inner/common/setGroundRay.ts +19 -0
  23. package/dist/gaesup/component/inner/common/type.ts +66 -0
  24. package/dist/gaesup/component/inner/rider/index.tsx +79 -0
  25. package/dist/gaesup/component/inner/vehicle/collider.tsx +40 -0
  26. package/dist/gaesup/component/inner/vehicle/index.tsx +44 -0
  27. package/dist/gaesup/component/inner/vehicle/type.ts +8 -0
  28. package/dist/gaesup/component/inner/vehicle/wheels.tsx +124 -0
  29. package/dist/gaesup/component/passive/airplane/index.tsx +65 -0
  30. package/dist/gaesup/component/passive/airplane/type.ts +3 -0
  31. package/dist/gaesup/component/passive/character/index.tsx +49 -0
  32. package/dist/gaesup/component/passive/character/type.ts +6 -0
  33. package/dist/gaesup/component/passive/type.ts +51 -0
  34. package/dist/gaesup/component/passive/vehicle/index.tsx +45 -0
  35. package/dist/gaesup/component/passive/vehicle/type.ts +3 -0
  36. package/dist/gaesup/component/type.ts +16 -0
  37. package/dist/gaesup/controller/context/index.ts +55 -0
  38. package/dist/gaesup/controller/context/reducer.ts +18 -0
  39. package/dist/gaesup/controller/context/type.ts +42 -0
  40. package/dist/gaesup/controller/index.tsx +116 -0
  41. package/dist/gaesup/controller/initialize/callback/index.ts +88 -0
  42. package/dist/gaesup/controller/initialize/callback/type.ts +35 -0
  43. package/dist/gaesup/controller/initialize/index.ts +90 -0
  44. package/dist/gaesup/controller/type.ts +127 -0
  45. package/dist/gaesup/gaesupProps/index.tsx +65 -0
  46. package/dist/gaesup/hooks/useClicker/index.ts +38 -0
  47. package/dist/gaesup/hooks/useFocus/index.tsx +129 -0
  48. package/dist/gaesup/hooks/useGaesupAnimation/index.tsx +128 -0
  49. package/dist/gaesup/hooks/useGaesupController/index.ts +25 -0
  50. package/dist/gaesup/hooks/useGaesupGltf/index.tsx +78 -0
  51. package/dist/gaesup/hooks/useMovePoint/index.ts +34 -0
  52. package/dist/gaesup/hooks/usePushKey/index.ts +26 -0
  53. package/dist/gaesup/hooks/useRideable/index.tsx +121 -0
  54. package/dist/gaesup/hooks/useRideable/type.ts +20 -0
  55. package/dist/gaesup/hooks/useTeleport/index.tsx +21 -0
  56. package/dist/gaesup/hooks/useZoom/index.tsx +24 -0
  57. package/dist/gaesup/physics/airplane/damping.ts +10 -0
  58. package/dist/gaesup/physics/airplane/direction.ts +63 -0
  59. package/dist/gaesup/physics/airplane/gravity.ts +14 -0
  60. package/dist/gaesup/physics/airplane/impulse.ts +26 -0
  61. package/dist/gaesup/physics/airplane/index.tsx +16 -0
  62. package/dist/gaesup/physics/airplane/innerCalc.ts +27 -0
  63. package/dist/gaesup/physics/airplane/landing.ts +28 -0
  64. package/dist/gaesup/physics/character/direction.ts +64 -0
  65. package/dist/gaesup/physics/character/impulse.ts +35 -0
  66. package/dist/gaesup/physics/character/index.tsx +14 -0
  67. package/dist/gaesup/physics/character/innerCalc.ts +27 -0
  68. package/dist/gaesup/physics/character/queue.ts +52 -0
  69. package/dist/gaesup/physics/character/stop.ts +13 -0
  70. package/dist/gaesup/physics/check/ground.ts +28 -0
  71. package/dist/gaesup/physics/check/index.ts +14 -0
  72. package/dist/gaesup/physics/check/moving.ts +15 -0
  73. package/dist/gaesup/physics/check/push.ts +10 -0
  74. package/dist/gaesup/physics/check/riding.ts +12 -0
  75. package/dist/gaesup/physics/check/rotate.ts +13 -0
  76. package/dist/gaesup/physics/index.ts +80 -0
  77. package/dist/gaesup/physics/type.ts +57 -0
  78. package/dist/gaesup/physics/vehicle/damping.ts +12 -0
  79. package/dist/gaesup/physics/vehicle/direction.ts +27 -0
  80. package/dist/gaesup/physics/vehicle/impulse.ts +28 -0
  81. package/dist/gaesup/physics/vehicle/index.tsx +14 -0
  82. package/dist/gaesup/physics/vehicle/innerCalc.ts +17 -0
  83. package/dist/gaesup/physics/vehicle/landing.ts +28 -0
  84. package/dist/gaesup/tools/clicker/index.tsx +60 -0
  85. package/dist/gaesup/tools/gamepad/GamePadButton.tsx +47 -0
  86. package/dist/gaesup/tools/gamepad/index.tsx +51 -0
  87. package/dist/gaesup/tools/gamepad/style.css.ts +63 -0
  88. package/dist/gaesup/tools/gamepad/type.ts +17 -0
  89. package/dist/gaesup/tools/jumpPortal/index.tsx +24 -0
  90. package/dist/gaesup/tools/jumpPortal/style.css.ts +18 -0
  91. package/dist/gaesup/tools/jumpPortal/type.ts +8 -0
  92. package/dist/gaesup/tools/minimap/index.tsx +233 -0
  93. package/dist/gaesup/tools/minimap/style.css.ts +224 -0
  94. package/dist/gaesup/tools/minimap/type.ts +44 -0
  95. package/dist/gaesup/tools/rideable/index.tsx +80 -0
  96. package/dist/gaesup/tools/rideable/style.css.ts +19 -0
  97. package/dist/gaesup/tools/rideable/type.ts +26 -0
  98. package/dist/gaesup/tools/type.ts +3 -0
  99. package/dist/gaesup/utils/context.ts +5 -0
  100. package/dist/gaesup/utils/getTag.ts +7 -0
  101. package/dist/gaesup/utils/innerHtml.tsx +22 -0
  102. package/dist/gaesup/utils/ray.ts +23 -0
  103. package/dist/gaesup/utils/ref.ts +17 -0
  104. package/dist/gaesup/utils/type.ts +6 -0
  105. package/dist/gaesup/utils/vector.ts +65 -0
  106. package/dist/gaesup/world/context/index.ts +115 -0
  107. package/dist/gaesup/world/context/reducer.ts +18 -0
  108. package/dist/gaesup/world/context/type.ts +210 -0
  109. package/dist/gaesup/world/index.tsx +17 -0
  110. package/dist/gaesup/world/initalize/index.ts +42 -0
  111. package/dist/gaesup/world/type.ts +27 -0
  112. package/dist/{index.js → index.ts} +2 -0
  113. package/package.json +3 -3
  114. package/dist/gaesup/animation/actions.js +0 -104
  115. package/dist/gaesup/camera/control/normal.d.ts +0 -4
  116. package/dist/gaesup/camera/control/normal.js +0 -15
  117. package/dist/gaesup/camera/control/orbit.d.ts +0 -4
  118. package/dist/gaesup/camera/control/orbit.js +0 -22
  119. package/dist/gaesup/camera/index.d.ts +0 -2
  120. package/dist/gaesup/camera/index.js +0 -24
  121. package/dist/gaesup/camera/type.d.ts +0 -14
  122. package/dist/gaesup/camera/type.js +0 -1
  123. package/dist/gaesup/component/active/airplane/index.d.ts +0 -2
  124. package/dist/gaesup/component/active/airplane/index.js +0 -5
  125. package/dist/gaesup/component/active/airplane/type.js +0 -1
  126. package/dist/gaesup/component/active/character/index.js +0 -5
  127. package/dist/gaesup/component/active/character/type.js +0 -1
  128. package/dist/gaesup/component/active/vehicle/index.d.ts +0 -2
  129. package/dist/gaesup/component/active/vehicle/index.js +0 -5
  130. package/dist/gaesup/component/active/vehicle/type.js +0 -1
  131. package/dist/gaesup/component/index.d.ts +0 -5
  132. package/dist/gaesup/component/index.js +0 -16
  133. package/dist/gaesup/component/inner/airplane/index.d.ts +0 -2
  134. package/dist/gaesup/component/inner/airplane/index.js +0 -7
  135. package/dist/gaesup/component/inner/airplane/type.d.ts +0 -5
  136. package/dist/gaesup/component/inner/airplane/type.js +0 -1
  137. package/dist/gaesup/component/inner/character/index.d.ts +0 -2
  138. package/dist/gaesup/component/inner/character/index.js +0 -7
  139. package/dist/gaesup/component/inner/character/type.js +0 -1
  140. package/dist/gaesup/component/inner/common/InnerGroupRef.d.ts +0 -1
  141. package/dist/gaesup/component/inner/common/InnerGroupRef.js +0 -18
  142. package/dist/gaesup/component/inner/common/OuterGroupRef.d.ts +0 -1
  143. package/dist/gaesup/component/inner/common/OuterGroupRef.js +0 -5
  144. package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +0 -1
  145. package/dist/gaesup/component/inner/common/calc.d.ts +0 -6
  146. package/dist/gaesup/component/inner/common/calc.js +0 -15
  147. package/dist/gaesup/component/inner/common/partsGroupRef.d.ts +0 -10
  148. package/dist/gaesup/component/inner/common/partsGroupRef.js +0 -33
  149. package/dist/gaesup/component/inner/common/setGroundRay.d.ts +0 -2
  150. package/dist/gaesup/component/inner/common/setGroundRay.js +0 -13
  151. package/dist/gaesup/component/inner/common/type.js +0 -1
  152. package/dist/gaesup/component/inner/rider/index.d.ts +0 -10
  153. package/dist/gaesup/component/inner/rider/index.js +0 -32
  154. package/dist/gaesup/component/inner/vehicle/collider.d.ts +0 -2
  155. package/dist/gaesup/component/inner/vehicle/collider.js +0 -17
  156. package/dist/gaesup/component/inner/vehicle/index.d.ts +0 -2
  157. package/dist/gaesup/component/inner/vehicle/index.js +0 -10
  158. package/dist/gaesup/component/inner/vehicle/type.d.ts +0 -5
  159. package/dist/gaesup/component/inner/vehicle/type.js +0 -1
  160. package/dist/gaesup/component/inner/vehicle/wheels.d.ts +0 -8
  161. package/dist/gaesup/component/inner/vehicle/wheels.js +0 -56
  162. package/dist/gaesup/component/passive/airplane/index.d.ts +0 -2
  163. package/dist/gaesup/component/passive/airplane/index.js +0 -37
  164. package/dist/gaesup/component/passive/airplane/type.d.ts +0 -2
  165. package/dist/gaesup/component/passive/airplane/type.js +0 -1
  166. package/dist/gaesup/component/passive/character/index.d.ts +0 -2
  167. package/dist/gaesup/component/passive/character/index.js +0 -26
  168. package/dist/gaesup/component/passive/character/type.d.ts +0 -2
  169. package/dist/gaesup/component/passive/character/type.js +0 -1
  170. package/dist/gaesup/component/passive/type.js +0 -1
  171. package/dist/gaesup/component/passive/vehicle/index.d.ts +0 -2
  172. package/dist/gaesup/component/passive/vehicle/index.js +0 -21
  173. package/dist/gaesup/component/passive/vehicle/type.d.ts +0 -2
  174. package/dist/gaesup/component/passive/vehicle/type.js +0 -1
  175. package/dist/gaesup/component/type.d.ts +0 -18
  176. package/dist/gaesup/component/type.js +0 -1
  177. package/dist/gaesup/controller/context/index.d.ts +0 -46
  178. package/dist/gaesup/controller/context/index.js +0 -48
  179. package/dist/gaesup/controller/context/reducer.d.ts +0 -12
  180. package/dist/gaesup/controller/context/reducer.js +0 -10
  181. package/dist/gaesup/controller/context/type.d.ts +0 -39
  182. package/dist/gaesup/controller/context/type.js +0 -1
  183. package/dist/gaesup/controller/index.d.ts +0 -3
  184. package/dist/gaesup/controller/index.js +0 -58
  185. package/dist/gaesup/controller/initialize/callback/index.d.ts +0 -15
  186. package/dist/gaesup/controller/initialize/callback/index.js +0 -59
  187. package/dist/gaesup/controller/initialize/callback/type.d.ts +0 -24
  188. package/dist/gaesup/controller/initialize/callback/type.js +0 -1
  189. package/dist/gaesup/controller/initialize/index.d.ts +0 -8
  190. package/dist/gaesup/controller/initialize/index.js +0 -67
  191. package/dist/gaesup/controller/type.d.ts +0 -103
  192. package/dist/gaesup/controller/type.js +0 -1
  193. package/dist/gaesup/gaesupProps/index.js +0 -38
  194. package/dist/gaesup/hooks/useClicker/index.d.ts +0 -3
  195. package/dist/gaesup/hooks/useClicker/index.js +0 -28
  196. package/dist/gaesup/hooks/useFocus/index.d.ts +0 -23
  197. package/dist/gaesup/hooks/useFocus/index.js +0 -103
  198. package/dist/gaesup/hooks/useGaesupAnimation/index.d.ts +0 -10
  199. package/dist/gaesup/hooks/useGaesupAnimation/index.js +0 -95
  200. package/dist/gaesup/hooks/useGaesupController/index.js +0 -14
  201. package/dist/gaesup/hooks/useGaesupGltf/index.d.ts +0 -25
  202. package/dist/gaesup/hooks/useGaesupGltf/index.js +0 -61
  203. package/dist/gaesup/hooks/useMovePoint/index.d.ts +0 -3
  204. package/dist/gaesup/hooks/useMovePoint/index.js +0 -27
  205. package/dist/gaesup/hooks/usePushKey/index.d.ts +0 -3
  206. package/dist/gaesup/hooks/usePushKey/index.js +0 -18
  207. package/dist/gaesup/hooks/useRideable/index.d.ts +0 -19
  208. package/dist/gaesup/hooks/useRideable/index.js +0 -107
  209. package/dist/gaesup/hooks/useRideable/type.d.ts +0 -19
  210. package/dist/gaesup/hooks/useRideable/type.js +0 -1
  211. package/dist/gaesup/hooks/useTeleport/index.d.ts +0 -3
  212. package/dist/gaesup/hooks/useTeleport/index.js +0 -16
  213. package/dist/gaesup/hooks/useZoom/index.d.ts +0 -3
  214. package/dist/gaesup/hooks/useZoom/index.js +0 -18
  215. package/dist/gaesup/physics/airplane/damping.d.ts +0 -2
  216. package/dist/gaesup/physics/airplane/damping.js +0 -5
  217. package/dist/gaesup/physics/airplane/direction.d.ts +0 -2
  218. package/dist/gaesup/physics/airplane/direction.js +0 -46
  219. package/dist/gaesup/physics/airplane/gravity.d.ts +0 -2
  220. package/dist/gaesup/physics/airplane/gravity.js +0 -6
  221. package/dist/gaesup/physics/airplane/impulse.d.ts +0 -2
  222. package/dist/gaesup/physics/airplane/impulse.js +0 -17
  223. package/dist/gaesup/physics/airplane/index.d.ts +0 -2
  224. package/dist/gaesup/physics/airplane/index.js +0 -14
  225. package/dist/gaesup/physics/airplane/innerCalc.d.ts +0 -2
  226. package/dist/gaesup/physics/airplane/innerCalc.js +0 -16
  227. package/dist/gaesup/physics/airplane/landing.d.ts +0 -2
  228. package/dist/gaesup/physics/airplane/landing.js +0 -18
  229. package/dist/gaesup/physics/character/direction.d.ts +0 -5
  230. package/dist/gaesup/physics/character/direction.js +0 -48
  231. package/dist/gaesup/physics/character/impulse.d.ts +0 -2
  232. package/dist/gaesup/physics/character/impulse.js +0 -26
  233. package/dist/gaesup/physics/character/index.d.ts +0 -2
  234. package/dist/gaesup/physics/character/index.js +0 -12
  235. package/dist/gaesup/physics/character/innerCalc.d.ts +0 -2
  236. package/dist/gaesup/physics/character/innerCalc.js +0 -12
  237. package/dist/gaesup/physics/character/queue.d.ts +0 -2
  238. package/dist/gaesup/physics/character/queue.js +0 -48
  239. package/dist/gaesup/physics/character/stop.d.ts +0 -2
  240. package/dist/gaesup/physics/character/stop.js +0 -8
  241. package/dist/gaesup/physics/check/ground.d.ts +0 -2
  242. package/dist/gaesup/physics/check/ground.js +0 -23
  243. package/dist/gaesup/physics/check/index.d.ts +0 -2
  244. package/dist/gaesup/physics/check/index.js +0 -12
  245. package/dist/gaesup/physics/check/moving.d.ts +0 -2
  246. package/dist/gaesup/physics/check/moving.js +0 -11
  247. package/dist/gaesup/physics/check/push.d.ts +0 -2
  248. package/dist/gaesup/physics/check/push.js +0 -6
  249. package/dist/gaesup/physics/check/riding.d.ts +0 -2
  250. package/dist/gaesup/physics/check/riding.js +0 -7
  251. package/dist/gaesup/physics/check/rotate.d.ts +0 -2
  252. package/dist/gaesup/physics/check/rotate.js +0 -8
  253. package/dist/gaesup/physics/index.d.ts +0 -7
  254. package/dist/gaesup/physics/index.js +0 -66
  255. package/dist/gaesup/physics/type.d.ts +0 -42
  256. package/dist/gaesup/physics/type.js +0 -2
  257. package/dist/gaesup/physics/vehicle/damping.d.ts +0 -2
  258. package/dist/gaesup/physics/vehicle/damping.js +0 -6
  259. package/dist/gaesup/physics/vehicle/direction.d.ts +0 -3
  260. package/dist/gaesup/physics/vehicle/direction.js +0 -18
  261. package/dist/gaesup/physics/vehicle/impulse.d.ts +0 -2
  262. package/dist/gaesup/physics/vehicle/impulse.js +0 -18
  263. package/dist/gaesup/physics/vehicle/index.d.ts +0 -2
  264. package/dist/gaesup/physics/vehicle/index.js +0 -12
  265. package/dist/gaesup/physics/vehicle/innerCalc.d.ts +0 -2
  266. package/dist/gaesup/physics/vehicle/innerCalc.js +0 -7
  267. package/dist/gaesup/physics/vehicle/landing.d.ts +0 -2
  268. package/dist/gaesup/physics/vehicle/landing.js +0 -18
  269. package/dist/gaesup/tools/clicker/index.d.ts +0 -5
  270. package/dist/gaesup/tools/clicker/index.js +0 -22
  271. package/dist/gaesup/tools/gamepad/GamePadButton.d.ts +0 -8
  272. package/dist/gaesup/tools/gamepad/GamePadButton.js +0 -20
  273. package/dist/gaesup/tools/gamepad/index.d.ts +0 -6
  274. package/dist/gaesup/tools/gamepad/index.js +0 -30
  275. package/dist/gaesup/tools/gamepad/type.js +0 -1
  276. package/dist/gaesup/tools/jumpPortal/index.d.ts +0 -9
  277. package/dist/gaesup/tools/jumpPortal/index.js +0 -9
  278. package/dist/gaesup/tools/minimap/default.d.ts +0 -9
  279. package/dist/gaesup/tools/minimap/default.js +0 -9
  280. package/dist/gaesup/tools/minimap/index.d.ts +0 -2
  281. package/dist/gaesup/tools/minimap/index.js +0 -64
  282. package/dist/gaesup/tools/minimap/type.d.ts +0 -30
  283. package/dist/gaesup/tools/minimap/type.js +0 -1
  284. package/dist/gaesup/tools/rideable/index.d.ts +0 -3
  285. package/dist/gaesup/tools/rideable/index.js +0 -41
  286. package/dist/gaesup/tools/rideable/type.d.ts +0 -25
  287. package/dist/gaesup/tools/rideable/type.js +0 -1
  288. package/dist/gaesup/tools/type.d.ts +0 -2
  289. package/dist/gaesup/tools/type.js +0 -1
  290. package/dist/gaesup/utils/context.d.ts +0 -4
  291. package/dist/gaesup/utils/context.js +0 -3
  292. package/dist/gaesup/utils/getTag.d.ts +0 -2
  293. package/dist/gaesup/utils/getTag.js +0 -4
  294. package/dist/gaesup/utils/index.js +0 -3
  295. package/dist/gaesup/utils/innerHtml.d.ts +0 -4
  296. package/dist/gaesup/utils/innerHtml.js +0 -28
  297. package/dist/gaesup/utils/ray.d.ts +0 -6
  298. package/dist/gaesup/utils/ray.js +0 -6
  299. package/dist/gaesup/utils/ref.d.ts +0 -1
  300. package/dist/gaesup/utils/ref.js +0 -15
  301. package/dist/gaesup/utils/type.d.ts +0 -5
  302. package/dist/gaesup/utils/type.js +0 -1
  303. package/dist/gaesup/utils/vector.d.ts +0 -11
  304. package/dist/gaesup/utils/vector.js +0 -38
  305. package/dist/gaesup/world/context/index.d.ts +0 -4
  306. package/dist/gaesup/world/context/index.js +0 -109
  307. package/dist/gaesup/world/context/reducer.d.ts +0 -24
  308. package/dist/gaesup/world/context/reducer.js +0 -10
  309. package/dist/gaesup/world/context/type.d.ts +0 -182
  310. package/dist/gaesup/world/context/type.js +0 -1
  311. package/dist/gaesup/world/index.d.ts +0 -3
  312. package/dist/gaesup/world/index.js +0 -9
  313. package/dist/gaesup/world/initalize/index.d.ts +0 -4
  314. package/dist/gaesup/world/initalize/index.js +0 -25
  315. package/dist/gaesup/world/type.d.ts +0 -18
  316. package/dist/gaesup/world/type.js +0 -1
  317. package/dist/index.d.ts +0 -22
  318. /package/dist/gaesup/utils/{index.d.ts → index.ts} +0 -0
@@ -0,0 +1,161 @@
1
+ import { useFrame } from "@react-three/fiber";
2
+ import { Ref, useContext, useEffect } from "react";
3
+ import * as THREE from "three";
4
+ import {
5
+ AnimationAction,
6
+ AnimationClip,
7
+ AnimationMixer,
8
+ Object3D,
9
+ Object3DEventMap,
10
+ } from "three";
11
+ import { animationTagType, groundRayType } from "../controller/type";
12
+ import { useGaesupAnimation } from "../hooks/useGaesupAnimation";
13
+ import {
14
+ GaesupWorldContext,
15
+ GaesupWorldDispatchContext,
16
+ } from "../world/context";
17
+
18
+ export type Api<T extends AnimationClip> = {
19
+ ref: React.MutableRefObject<Object3D | undefined | null>;
20
+ clips: AnimationClip[];
21
+ mixer: AnimationMixer;
22
+ names: T["name"][];
23
+ actions: {
24
+ [key in T["name"]]: AnimationAction | null;
25
+ };
26
+ };
27
+
28
+ export type playActionsType = {
29
+ type: "character" | "vehicle" | "airplane";
30
+ currentAnimation?: string;
31
+ actions: actionsType;
32
+ animationRef: Ref<Object3D<Object3DEventMap>>;
33
+ isActive: boolean;
34
+ };
35
+
36
+ export type subscribeActionsType = {
37
+ type: "character" | "vehicle" | "airplane";
38
+ groundRay: groundRayType;
39
+ animations: AnimationClip[];
40
+ };
41
+
42
+ export type actionsType = {
43
+ [x: string]: THREE.AnimationAction | null;
44
+ };
45
+
46
+ export type playResultType = {
47
+ actions: actionsType;
48
+ ref: Ref<Object3D<Object3DEventMap>>;
49
+ };
50
+
51
+ export function subscribeActions({ type }: subscribeActionsType) {
52
+ const { states } = useContext(GaesupWorldContext);
53
+ const { subscribeAll } = useGaesupAnimation({ type });
54
+ // 초기 기본 애니메이션 등록
55
+ useEffect(() => {
56
+ subscribeAll([
57
+ {
58
+ tag: "walk",
59
+ condition: () => !states.isRunning && states.isMoving,
60
+ action: () => {},
61
+ animationName: "walk",
62
+ key: "walk",
63
+ },
64
+ {
65
+ tag: "run",
66
+ condition: () => states.isRunning,
67
+ action: () => {},
68
+ animationName: "run",
69
+ key: "run",
70
+ },
71
+ {
72
+ tag: "jump",
73
+ condition: () => states.isJumping,
74
+ action: () => {},
75
+ animationName: "jump",
76
+ key: "jump",
77
+ },
78
+
79
+ {
80
+ tag: "ride",
81
+ condition: () => states.isPush["keyR"],
82
+ action: () => {},
83
+ animationName: "ride",
84
+ key: "ride",
85
+ },
86
+ {
87
+ tag: "land",
88
+ condition: () => states.isLanding,
89
+ action: () => {},
90
+ animationName: "land",
91
+ key: "land",
92
+ },
93
+ {
94
+ tag: "fall",
95
+ condition: () => states.isFalling,
96
+ action: () => {},
97
+ animationName: "fall",
98
+ key: "fall",
99
+ },
100
+ ]);
101
+ }, []);
102
+ }
103
+
104
+ export default function playActions({
105
+ type,
106
+ actions,
107
+ animationRef,
108
+ currentAnimation,
109
+ isActive,
110
+ }: playActionsType) {
111
+ const { mode, animationState, block } = useContext(GaesupWorldContext);
112
+ const dispatch = useContext(GaesupWorldDispatchContext);
113
+ const { notify, store } = useGaesupAnimation({ type });
114
+
115
+ if (isActive) {
116
+ currentAnimation = animationState?.[type]?.current;
117
+ }
118
+
119
+ const play = (tag: keyof animationTagType) => {
120
+ animationState[type].current = tag;
121
+ const currentAnimation = store[tag];
122
+ if (currentAnimation?.action) {
123
+ currentAnimation.action();
124
+ }
125
+ dispatch({
126
+ type: "update",
127
+ payload: {
128
+ animationState: {
129
+ ...animationState,
130
+ },
131
+ },
132
+ });
133
+ };
134
+
135
+ useEffect(() => {
136
+ let animation = "idle";
137
+ if (block.animation) {
138
+ animation = "idle";
139
+ } else if (currentAnimation) {
140
+ animation = currentAnimation;
141
+ } else if (animationState[type].current) {
142
+ animation = animationState[type].current;
143
+ }
144
+ const action = actions[animation]?.reset().fadeIn(0.2).play();
145
+ return () => {
146
+ action?.fadeOut(0.2);
147
+ };
148
+ }, [currentAnimation, mode.type, block.animation, type]);
149
+
150
+ useFrame(() => {
151
+ if (isActive) {
152
+ const tag = notify() as keyof animationTagType;
153
+ play(tag);
154
+ }
155
+ });
156
+
157
+ return {
158
+ animationRef,
159
+ currentAnimation: animationState?.[type]?.current,
160
+ };
161
+ }
@@ -0,0 +1,27 @@
1
+ import { cameraPropType } from "../../physics/type";
2
+ import { V3 } from "../../utils/vector";
3
+ import { activeStateType, cameraOptionType } from "../../world/context/type";
4
+
5
+ export const makeNormalCameraPosition = (
6
+ activeState: activeStateType,
7
+ cameraOption: cameraOptionType
8
+ ) => {
9
+ const { XDistance, YDistance, ZDistance } = cameraOption;
10
+ const cameraPosition = activeState.position
11
+ .clone()
12
+ .add(V3(XDistance, YDistance, ZDistance));
13
+ return cameraPosition;
14
+ };
15
+ export default function normal(prop: cameraPropType) {
16
+ const {
17
+ state,
18
+ worldContext: { cameraOption },
19
+ controllerOptions: { lerp },
20
+ } = prop;
21
+ if (!state || !state.camera) return;
22
+ state.camera.position.lerp(
23
+ cameraOption.position.clone(),
24
+ lerp.cameraPosition
25
+ );
26
+ state.camera.lookAt(cameraOption.target);
27
+ }
@@ -0,0 +1,37 @@
1
+ import { quat } from "@react-three/rapier";
2
+ import { cameraPropType } from "../../physics/type";
3
+ import { V3 } from "../../utils/vector";
4
+ import { activeStateType, cameraOptionType } from "../../world/context/type";
5
+
6
+ export const makeOrbitCameraPosition = (
7
+ activeState: activeStateType,
8
+ cameraOption: cameraOptionType
9
+ ) => {
10
+ const { XDistance, YDistance, ZDistance } = cameraOption;
11
+ const cameraPosition = activeState.position.clone().add(
12
+ V3(Math.sin(activeState.euler.y), 1, Math.cos(activeState.euler.y))
13
+ .normalize()
14
+ .clone()
15
+ .multiply(V3(-XDistance, YDistance, -ZDistance))
16
+ );
17
+ return cameraPosition;
18
+ };
19
+
20
+ export default function orbit(prop: cameraPropType) {
21
+ const {
22
+ state,
23
+ worldContext: { activeState, cameraOption },
24
+ controllerOptions: { lerp },
25
+ } = prop;
26
+
27
+ if (!state || !state.camera) return;
28
+ const cameraPosition = makeOrbitCameraPosition(activeState, cameraOption);
29
+ state.camera.position.lerp(cameraPosition.clone(), lerp.cameraTurn);
30
+ state.camera.quaternion.copy(
31
+ activeState.quat
32
+ .clone()
33
+ .multiply(quat().setFromAxisAngle(V3(0, 1, 0), Math.PI))
34
+ );
35
+ state.camera.rotation.copy(activeState.euler);
36
+ state.camera.lookAt(activeState.position.clone());
37
+ }
@@ -0,0 +1,29 @@
1
+ import { useFrame } from "@react-three/fiber";
2
+ import { cameraPropType } from "../physics/type";
3
+ import normal, { makeNormalCameraPosition } from "./control/normal";
4
+ import orbit from "./control/orbit";
5
+
6
+ export default function Camera(prop: cameraPropType) {
7
+ useFrame((state) => {
8
+ prop.state = state;
9
+ if (!prop.worldContext.block.camera) {
10
+ if (prop.worldContext.mode.control === "orbit") {
11
+ orbit(prop);
12
+ } else if (prop.worldContext.mode.control === "normal") {
13
+ normal(prop);
14
+ }
15
+ }
16
+ });
17
+
18
+ // 포커스가 아닐 때 카메라 activeStae 따라가기
19
+ useFrame(() => {
20
+ if (!prop.worldContext.cameraOption.focus) {
21
+ prop.worldContext.cameraOption.target =
22
+ prop.worldContext.activeState.position;
23
+ prop.worldContext.cameraOption.position = makeNormalCameraPosition(
24
+ prop.worldContext.activeState,
25
+ prop.worldContext.cameraOption
26
+ );
27
+ }
28
+ });
29
+ }
@@ -0,0 +1,14 @@
1
+ import * as THREE from "three";
2
+ import {} from "three-stdlib";
3
+
4
+ export type cameraRayType = {
5
+ origin: THREE.Vector3;
6
+ hit: THREE.Raycaster;
7
+ rayCast: THREE.Raycaster | null;
8
+ length: number;
9
+ dir: THREE.Vector3;
10
+ position: THREE.Vector3;
11
+ intersects: THREE.Intersection<THREE.Mesh>[];
12
+ detected: THREE.Intersection<THREE.Mesh>[];
13
+ intersectObjectMap: { [uuid: string]: THREE.Mesh };
14
+ };
@@ -0,0 +1,17 @@
1
+ import { AirplaneInnerRef } from "../../inner/airplane";
2
+ import { activeAirplaneInnerType } from "./type";
3
+
4
+ export function AirplaneRef(props: activeAirplaneInnerType) {
5
+ return (
6
+ <AirplaneInnerRef
7
+ name={"airplane"}
8
+ isActive={true}
9
+ currentAnimation={"idle"}
10
+ componentType={"airplane"}
11
+ ridingUrl={props.ridingUrl}
12
+ {...props}
13
+ >
14
+ {props.children}
15
+ </AirplaneInnerRef>
16
+ );
17
+ }
@@ -1,3 +1,4 @@
1
1
  import { passiveAirplanePropsType } from "../../passive/airplane/type";
2
2
  import { innerRefType } from "../../passive/type";
3
- export declare type activeAirplaneInnerType = passiveAirplanePropsType & innerRefType;
3
+
4
+ export type activeAirplaneInnerType = passiveAirplanePropsType & innerRefType;
@@ -0,0 +1,35 @@
1
+ import { controllerInnerType, refsType } from "../../../controller/type";
2
+ import { urlsType } from "../../../world/context/type";
3
+ import { CharacterInnerRef } from "../../inner/character";
4
+
5
+ export function CharacterRef({
6
+ children,
7
+ props,
8
+ refs,
9
+ urls,
10
+ }: {
11
+ children: React.ReactNode;
12
+ props: controllerInnerType;
13
+ refs: refsType;
14
+ urls: urlsType;
15
+ }) {
16
+ return (
17
+ <CharacterInnerRef
18
+ url={urls.characterUrl}
19
+ isActive={true}
20
+ componentType="character"
21
+ rigidbodyType={"dynamic"}
22
+ controllerOptions={props.controllerOptions}
23
+ groundRay={props.groundRay}
24
+ onAnimate={props.onAnimate}
25
+ onFrame={props.onFrame}
26
+ onReady={props.onReady}
27
+ onDestory={props.onDestory}
28
+ rigidBodyProps={props.rigidBodyProps}
29
+ parts={props.parts}
30
+ {...refs}
31
+ >
32
+ {children}
33
+ </CharacterInnerRef>
34
+ );
35
+ }
@@ -0,0 +1,13 @@
1
+ import { RigidBodyTypeString } from "@react-three/rapier";
2
+ import * as THREE from "three";
3
+ import { controllerOptionsType } from "../../../controller/type";
4
+
5
+ export type activeCharacterPropsType = {
6
+ characterUrl: string;
7
+ position?: THREE.Vector3;
8
+ rotation?: THREE.Euler;
9
+ controllerOptions?: controllerOptionsType;
10
+ currentAnimation?: string;
11
+ children?: React.ReactNode;
12
+ rigidbodyType?: RigidBodyTypeString;
13
+ };
@@ -0,0 +1,17 @@
1
+ import { VehicleInnerRef } from "../../inner/vehicle";
2
+ import { activeVehicleInnerType } from "./type";
3
+
4
+ export function VehicleRef(props: activeVehicleInnerType) {
5
+ return (
6
+ <VehicleInnerRef
7
+ name={"vehicle"}
8
+ isActive={true}
9
+ currentAnimation={"idle"}
10
+ componentType={"vehicle"}
11
+ ridingUrl={props.ridingUrl}
12
+ {...props}
13
+ >
14
+ {props.children}
15
+ </VehicleInnerRef>
16
+ );
17
+ }
@@ -1,3 +1,4 @@
1
1
  import { innerRefType } from "../../passive/type";
2
2
  import { passiveVehiclePropsType } from "../../passive/vehicle/type";
3
- export declare type activeVehicleInnerType = passiveVehiclePropsType & innerRefType;
3
+
4
+ export type activeVehicleInnerType = passiveVehiclePropsType & innerRefType;
@@ -0,0 +1,65 @@
1
+ import { vec3 } from "@react-three/rapier";
2
+ import { useContext } from "react";
3
+ import { controllerInnerType, refsType } from "../controller/type";
4
+ import { GaesupWorldContext } from "../world/context";
5
+ import { AirplaneRef } from "./active/airplane";
6
+ import { CharacterRef } from "./active/character";
7
+ import { VehicleRef } from "./active/vehicle";
8
+
9
+ export function GaesupComponent({
10
+ props,
11
+ refs,
12
+ }: {
13
+ props: controllerInnerType;
14
+ refs: refsType;
15
+ }) {
16
+ const { mode, states, rideable, urls } = useContext(GaesupWorldContext);
17
+ const { enableRiding, isRiderOn, rideableId } = states;
18
+
19
+ return (
20
+ <>
21
+ {mode.type === "character" && (
22
+ <CharacterRef props={props} refs={refs} urls={urls}>
23
+ {props.children}
24
+ </CharacterRef>
25
+ )}
26
+ {mode.type === "vehicle" && (
27
+ <VehicleRef
28
+ controllerOptions={props.controllerOptions}
29
+ url={urls.vehicleUrl}
30
+ wheelUrl={urls.wheelUrl}
31
+ ridingUrl={urls.ridingUrl}
32
+ enableRiding={enableRiding}
33
+ isRiderOn={isRiderOn}
34
+ groundRay={props.groundRay}
35
+ offset={
36
+ rideableId && rideable[rideableId]
37
+ ? rideable[rideableId].offset
38
+ : vec3()
39
+ }
40
+ {...refs}
41
+ >
42
+ {props.children}
43
+ </VehicleRef>
44
+ )}
45
+ {mode.type === "airplane" && (
46
+ <AirplaneRef
47
+ controllerOptions={props.controllerOptions}
48
+ url={urls.airplaneUrl}
49
+ ridingUrl={urls.ridingUrl}
50
+ enableRiding={enableRiding}
51
+ isRiderOn={isRiderOn}
52
+ groundRay={props.groundRay}
53
+ offset={
54
+ rideableId && rideable[rideableId]
55
+ ? rideable[rideableId].offset
56
+ : vec3()
57
+ }
58
+ {...refs}
59
+ >
60
+ {props.children}
61
+ </AirplaneRef>
62
+ )}
63
+ </>
64
+ );
65
+ }
@@ -0,0 +1,21 @@
1
+ import { OuterGroupRef } from "../common/OuterGroupRef";
2
+ import { RigidBodyRef } from "../common/RigidbodyRef";
3
+ import { airplaneInnerType } from "./type";
4
+
5
+ export function AirplaneInnerRef(props: airplaneInnerType) {
6
+ const { rigidBodyRef, outerGroupRef } = props;
7
+
8
+ return (
9
+ <OuterGroupRef ref={outerGroupRef}>
10
+ <RigidBodyRef
11
+ ref={rigidBodyRef}
12
+ name={props.name}
13
+ componentType={"airplane"}
14
+ ridingUrl={props.ridingUrl}
15
+ {...props}
16
+ >
17
+ {props.children}
18
+ </RigidBodyRef>
19
+ </OuterGroupRef>
20
+ );
21
+ }
@@ -0,0 +1,8 @@
1
+ import { ridingType, rigidBodyRefType } from "../common/type";
2
+
3
+ // airplane 타입 정의
4
+ export type airplaneUrlType = {
5
+ wheelUrl?: string;
6
+ };
7
+
8
+ export type airplaneInnerType = rigidBodyRefType & ridingType & airplaneUrlType;
@@ -0,0 +1,22 @@
1
+ import { OuterGroupRef } from "../common/OuterGroupRef";
2
+ import { RigidBodyRef } from "../common/RigidbodyRef";
3
+ import { characterInnerType } from "./type";
4
+
5
+ export function CharacterInnerRef(props: characterInnerType) {
6
+ const { outerGroupRef } = props;
7
+ return (
8
+ <OuterGroupRef ref={outerGroupRef}>
9
+ <RigidBodyRef
10
+ name={"character"}
11
+ url={props.url}
12
+ controllerOptions={props.controllerOptions}
13
+ ref={props.rigidBodyRef}
14
+ groundRay={props.groundRay}
15
+ isNotColliding={props.isNotColliding}
16
+ {...props}
17
+ >
18
+ {props.children}
19
+ </RigidBodyRef>
20
+ </OuterGroupRef>
21
+ );
22
+ }
@@ -2,9 +2,13 @@ import { callbackType } from "../../../controller/initialize/callback/type";
2
2
  import { groundRayType, partsType } from "../../../controller/type";
3
3
  import { passiveCharacterPropsType } from "../../passive/character/type";
4
4
  import { componentTypeString, innerRefType } from "../../passive/type";
5
- export declare type characterInnerType = {
6
- componentType: componentTypeString;
7
- isActive?: boolean;
8
- groundRay: groundRayType;
9
- parts?: partsType;
10
- } & passiveCharacterPropsType & innerRefType & callbackType;
5
+
6
+ // 내부 정의
7
+ export type characterInnerType = {
8
+ componentType: componentTypeString;
9
+ isActive?: boolean;
10
+ groundRay: groundRayType;
11
+ parts?: partsType;
12
+ } & passiveCharacterPropsType &
13
+ innerRefType &
14
+ callbackType;
@@ -0,0 +1,56 @@
1
+ import { Ref, forwardRef } from "react";
2
+ import * as THREE from "three";
3
+ import RiderRef from "../rider";
4
+ import { InnerGroupRefType } from "./type";
5
+
6
+ export const InnerGroupRef = forwardRef(
7
+ (props: InnerGroupRefType, ref: Ref<THREE.Group>) => {
8
+ return (
9
+ <group receiveShadow castShadow ref={ref} userData={{ intangible: true }}>
10
+ {props.isRiderOn &&
11
+ props.enableRiding &&
12
+ props.isActive &&
13
+ props.ridingUrl && (
14
+ <RiderRef url={props.ridingUrl} offset={props.offset} />
15
+ )}
16
+
17
+ {props.children}
18
+ {props.objectNode && props.animationRef && (
19
+ <primitive
20
+ object={props.objectNode}
21
+ visible={false}
22
+ receiveShadow
23
+ castShadow
24
+ ref={props.animationRef}
25
+ />
26
+ )}
27
+
28
+ {Object.keys(props.nodes).map((name: string, key: number) => {
29
+ const node = props.nodes[name];
30
+ if (node instanceof THREE.SkinnedMesh) {
31
+ return (
32
+ <skinnedMesh
33
+ castShadow
34
+ receiveShadow
35
+ material={node.material}
36
+ geometry={node.geometry}
37
+ skeleton={node.skeleton}
38
+ key={key}
39
+ />
40
+ );
41
+ } else if (node instanceof THREE.Mesh) {
42
+ return (
43
+ <mesh
44
+ castShadow
45
+ receiveShadow
46
+ material={node.material}
47
+ geometry={node.geometry}
48
+ key={key}
49
+ />
50
+ );
51
+ }
52
+ })}
53
+ </group>
54
+ );
55
+ }
56
+ );
@@ -0,0 +1,19 @@
1
+ import { forwardRef, MutableRefObject, ReactNode } from "react";
2
+ import * as THREE from "three";
3
+
4
+ export const OuterGroupRef = forwardRef(
5
+ (
6
+ {
7
+ children,
8
+ }: {
9
+ children: ReactNode;
10
+ },
11
+ ref: MutableRefObject<THREE.Group>
12
+ ) => {
13
+ return (
14
+ <group ref={ref} userData={{ intangible: true }}>
15
+ {children}
16
+ </group>
17
+ );
18
+ }
19
+ );