gaesup-world 0.2.34 → 0.2.36

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 (225) hide show
  1. package/package.json +1 -3
  2. package/dist/gaesup/animation/actions.d.ts +0 -44
  3. package/dist/gaesup/animation/actions.js +0 -103
  4. package/dist/gaesup/camera/control/normal.d.ts +0 -4
  5. package/dist/gaesup/camera/control/normal.js +0 -18
  6. package/dist/gaesup/camera/control/orbit.d.ts +0 -4
  7. package/dist/gaesup/camera/control/orbit.js +0 -22
  8. package/dist/gaesup/camera/detector/index.d.ts +0 -2
  9. package/dist/gaesup/camera/detector/index.js +0 -25
  10. package/dist/gaesup/camera/index.d.ts +0 -8
  11. package/dist/gaesup/camera/index.js +0 -110
  12. package/dist/gaesup/camera/type.d.ts +0 -13
  13. package/dist/gaesup/camera/type.js +0 -1
  14. package/dist/gaesup/component/active/airplane/index.d.ts +0 -11
  15. package/dist/gaesup/component/active/airplane/index.js +0 -6
  16. package/dist/gaesup/component/active/character/index.d.ts +0 -7
  17. package/dist/gaesup/component/active/character/index.js +0 -34
  18. package/dist/gaesup/component/active/vehicle/index.d.ts +0 -12
  19. package/dist/gaesup/component/active/vehicle/index.js +0 -31
  20. package/dist/gaesup/component/index.d.ts +0 -7
  21. package/dist/gaesup/component/index.js +0 -19
  22. package/dist/gaesup/component/inner/airplane/index.d.ts +0 -2
  23. package/dist/gaesup/component/inner/airplane/index.js +0 -16
  24. package/dist/gaesup/component/inner/character/index.d.ts +0 -25
  25. package/dist/gaesup/component/inner/character/index.js +0 -28
  26. package/dist/gaesup/component/inner/common/InnerGroupRef.d.ts +0 -10
  27. package/dist/gaesup/component/inner/common/InnerGroupRef.js +0 -29
  28. package/dist/gaesup/component/inner/common/OuterGroupRef.d.ts +0 -4
  29. package/dist/gaesup/component/inner/common/OuterGroupRef.js +0 -6
  30. package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +0 -12
  31. package/dist/gaesup/component/inner/common/RigidbodyRef.js +0 -7
  32. package/dist/gaesup/component/inner/common/setGroundRay.d.ts +0 -9
  33. package/dist/gaesup/component/inner/common/setGroundRay.js +0 -14
  34. package/dist/gaesup/component/inner/common/type.d.ts +0 -20
  35. package/dist/gaesup/component/inner/common/type.js +0 -1
  36. package/dist/gaesup/component/inner/rider/index.d.ts +0 -11
  37. package/dist/gaesup/component/inner/rider/index.js +0 -31
  38. package/dist/gaesup/component/inner/vehicle/collider.d.ts +0 -10
  39. package/dist/gaesup/component/inner/vehicle/collider.js +0 -19
  40. package/dist/gaesup/component/inner/vehicle/index.d.ts +0 -2
  41. package/dist/gaesup/component/inner/vehicle/index.js +0 -17
  42. package/dist/gaesup/component/inner/vehicle/wheels.d.ts +0 -7
  43. package/dist/gaesup/component/inner/vehicle/wheels.js +0 -64
  44. package/dist/gaesup/component/passive/airplane/index.d.ts +0 -13
  45. package/dist/gaesup/component/passive/airplane/index.js +0 -40
  46. package/dist/gaesup/component/passive/character/index.d.ts +0 -10
  47. package/dist/gaesup/component/passive/character/index.js +0 -46
  48. package/dist/gaesup/component/passive/type.d.ts +0 -20
  49. package/dist/gaesup/component/passive/type.js +0 -1
  50. package/dist/gaesup/component/passive/vehicle/index.d.ts +0 -13
  51. package/dist/gaesup/component/passive/vehicle/index.js +0 -17
  52. package/dist/gaesup/component/type.d.ts +0 -17
  53. package/dist/gaesup/component/type.js +0 -1
  54. package/dist/gaesup/controller/context/index.d.ts +0 -49
  55. package/dist/gaesup/controller/context/index.js +0 -59
  56. package/dist/gaesup/controller/context/reducer.d.ts +0 -12
  57. package/dist/gaesup/controller/context/reducer.js +0 -21
  58. package/dist/gaesup/controller/context/type.d.ts +0 -38
  59. package/dist/gaesup/controller/context/type.js +0 -1
  60. package/dist/gaesup/controller/debug/airplane.d.ts +0 -71
  61. package/dist/gaesup/controller/debug/airplane.js +0 -71
  62. package/dist/gaesup/controller/debug/character.d.ts +0 -27
  63. package/dist/gaesup/controller/debug/character.js +0 -27
  64. package/dist/gaesup/controller/debug/index.d.ts +0 -6
  65. package/dist/gaesup/controller/debug/index.js +0 -49
  66. package/dist/gaesup/controller/debug/vehicle.d.ts +0 -27
  67. package/dist/gaesup/controller/debug/vehicle.js +0 -27
  68. package/dist/gaesup/controller/index.d.ts +0 -3
  69. package/dist/gaesup/controller/index.js +0 -75
  70. package/dist/gaesup/controller/initialize/callback/index.d.ts +0 -2
  71. package/dist/gaesup/controller/initialize/callback/index.js +0 -62
  72. package/dist/gaesup/controller/initialize/callback/type.d.ts +0 -27
  73. package/dist/gaesup/controller/initialize/callback/type.js +0 -1
  74. package/dist/gaesup/controller/initialize/index.d.ts +0 -10
  75. package/dist/gaesup/controller/initialize/index.js +0 -75
  76. package/dist/gaesup/controller/style.css +0 -48
  77. package/dist/gaesup/controller/type.d.ts +0 -85
  78. package/dist/gaesup/controller/type.js +0 -1
  79. package/dist/gaesup/gaesupProps/index.d.ts +0 -7
  80. package/dist/gaesup/gaesupProps/index.js +0 -46
  81. package/dist/gaesup/hooks/useGaesupAnimation/index.d.ts +0 -10
  82. package/dist/gaesup/hooks/useGaesupAnimation/index.js +0 -95
  83. package/dist/gaesup/hooks/useGaesupController/index.d.ts +0 -10
  84. package/dist/gaesup/hooks/useGaesupController/index.js +0 -14
  85. package/dist/gaesup/hooks/useGaesupGltf/index.d.ts +0 -25
  86. package/dist/gaesup/hooks/useGaesupGltf/index.js +0 -73
  87. package/dist/gaesup/hooks/useJoyStick/index.d.ts +0 -39
  88. package/dist/gaesup/hooks/useJoyStick/index.js +0 -61
  89. package/dist/gaesup/hooks/usePushKey/index.d.ts +0 -3
  90. package/dist/gaesup/hooks/usePushKey/index.js +0 -29
  91. package/dist/gaesup/hooks/useRideable/index.d.ts +0 -28
  92. package/dist/gaesup/hooks/useRideable/index.js +0 -199
  93. package/dist/gaesup/hooks/useTeleport/index.d.ts +0 -3
  94. package/dist/gaesup/hooks/useTeleport/index.js +0 -12
  95. package/dist/gaesup/physics/airplane/damping.d.ts +0 -2
  96. package/dist/gaesup/physics/airplane/damping.js +0 -5
  97. package/dist/gaesup/physics/airplane/direction.d.ts +0 -2
  98. package/dist/gaesup/physics/airplane/direction.js +0 -65
  99. package/dist/gaesup/physics/airplane/gravity.d.ts +0 -14
  100. package/dist/gaesup/physics/airplane/gravity.js +0 -18
  101. package/dist/gaesup/physics/airplane/impulse.d.ts +0 -16
  102. package/dist/gaesup/physics/airplane/impulse.js +0 -31
  103. package/dist/gaesup/physics/airplane/index.d.ts +0 -2
  104. package/dist/gaesup/physics/airplane/index.js +0 -14
  105. package/dist/gaesup/physics/airplane/innerCalc.d.ts +0 -2
  106. package/dist/gaesup/physics/airplane/innerCalc.js +0 -27
  107. package/dist/gaesup/physics/airplane/landing.d.ts +0 -2
  108. package/dist/gaesup/physics/airplane/landing.js +0 -29
  109. package/dist/gaesup/physics/character/direction.d.ts +0 -23
  110. package/dist/gaesup/physics/character/direction.js +0 -55
  111. package/dist/gaesup/physics/character/impulse.d.ts +0 -2
  112. package/dist/gaesup/physics/character/impulse.js +0 -43
  113. package/dist/gaesup/physics/character/index.d.ts +0 -2
  114. package/dist/gaesup/physics/character/index.js +0 -8
  115. package/dist/gaesup/physics/character/innerCalc.d.ts +0 -2
  116. package/dist/gaesup/physics/character/innerCalc.js +0 -31
  117. package/dist/gaesup/physics/check/ground.d.ts +0 -2
  118. package/dist/gaesup/physics/check/ground.js +0 -15
  119. package/dist/gaesup/physics/check/index.d.ts +0 -2
  120. package/dist/gaesup/physics/check/index.js +0 -12
  121. package/dist/gaesup/physics/check/moving.d.ts +0 -2
  122. package/dist/gaesup/physics/check/moving.js +0 -16
  123. package/dist/gaesup/physics/check/push.d.ts +0 -2
  124. package/dist/gaesup/physics/check/push.js +0 -6
  125. package/dist/gaesup/physics/check/riding.d.ts +0 -2
  126. package/dist/gaesup/physics/check/riding.js +0 -7
  127. package/dist/gaesup/physics/check/rotate.d.ts +0 -2
  128. package/dist/gaesup/physics/check/rotate.js +0 -8
  129. package/dist/gaesup/physics/index.d.ts +0 -2
  130. package/dist/gaesup/physics/index.js +0 -58
  131. package/dist/gaesup/physics/type.d.ts +0 -36
  132. package/dist/gaesup/physics/type.js +0 -1
  133. package/dist/gaesup/physics/vehicle/damping.d.ts +0 -2
  134. package/dist/gaesup/physics/vehicle/damping.js +0 -6
  135. package/dist/gaesup/physics/vehicle/direction.d.ts +0 -4
  136. package/dist/gaesup/physics/vehicle/direction.js +0 -30
  137. package/dist/gaesup/physics/vehicle/impulse.d.ts +0 -16
  138. package/dist/gaesup/physics/vehicle/impulse.js +0 -40
  139. package/dist/gaesup/physics/vehicle/index.d.ts +0 -2
  140. package/dist/gaesup/physics/vehicle/index.js +0 -12
  141. package/dist/gaesup/physics/vehicle/innerCalc.d.ts +0 -2
  142. package/dist/gaesup/physics/vehicle/innerCalc.js +0 -24
  143. package/dist/gaesup/physics/vehicle/landing.d.ts +0 -2
  144. package/dist/gaesup/physics/vehicle/landing.js +0 -29
  145. package/dist/gaesup/tools/gameBoy/GameBoyButton.d.ts +0 -9
  146. package/dist/gaesup/tools/gameBoy/GameBoyButton.js +0 -16
  147. package/dist/gaesup/tools/gameBoy/index.d.ts +0 -8
  148. package/dist/gaesup/tools/gameBoy/index.js +0 -22
  149. package/dist/gaesup/tools/gameBoy/style.css +0 -92
  150. package/dist/gaesup/tools/gameBoy/type.d.ts +0 -4
  151. package/dist/gaesup/tools/gameBoy/type.js +0 -1
  152. package/dist/gaesup/tools/gamePad/GamePadButton.d.ts +0 -8
  153. package/dist/gaesup/tools/gamePad/GamePadButton.js +0 -21
  154. package/dist/gaesup/tools/gamePad/index.d.ts +0 -6
  155. package/dist/gaesup/tools/gamePad/index.js +0 -32
  156. package/dist/gaesup/tools/gamePad/style.css +0 -62
  157. package/dist/gaesup/tools/gamePad/type.d.ts +0 -6
  158. package/dist/gaesup/tools/gamePad/type.js +0 -1
  159. package/dist/gaesup/tools/joyStick/index.d.ts +0 -6
  160. package/dist/gaesup/tools/joyStick/index.js +0 -169
  161. package/dist/gaesup/tools/joyStick/style.css +0 -38
  162. package/dist/gaesup/tools/joyStick/type.d.ts +0 -19
  163. package/dist/gaesup/tools/joyStick/type.js +0 -1
  164. package/dist/gaesup/tools/jumpPortal/index.d.ts +0 -16
  165. package/dist/gaesup/tools/jumpPortal/index.js +0 -18
  166. package/dist/gaesup/tools/jumpPortal/style.css +0 -16
  167. package/dist/gaesup/tools/keyBoardToolTip/constant.d.ts +0 -402
  168. package/dist/gaesup/tools/keyBoardToolTip/constant.js +0 -122
  169. package/dist/gaesup/tools/keyBoardToolTip/default.d.ts +0 -10
  170. package/dist/gaesup/tools/keyBoardToolTip/default.js +0 -12
  171. package/dist/gaesup/tools/keyBoardToolTip/index.d.ts +0 -3
  172. package/dist/gaesup/tools/keyBoardToolTip/index.js +0 -70
  173. package/dist/gaesup/tools/keyBoardToolTip/style.css +0 -24
  174. package/dist/gaesup/tools/keyBoardToolTip/type.d.ts +0 -37
  175. package/dist/gaesup/tools/keyBoardToolTip/type.js +0 -1
  176. package/dist/gaesup/tools/miniMap/default.d.ts +0 -9
  177. package/dist/gaesup/tools/miniMap/default.js +0 -9
  178. package/dist/gaesup/tools/miniMap/index.d.ts +0 -3
  179. package/dist/gaesup/tools/miniMap/index.js +0 -72
  180. package/dist/gaesup/tools/miniMap/style.css +0 -228
  181. package/dist/gaesup/tools/miniMap/type.d.ts +0 -25
  182. package/dist/gaesup/tools/miniMap/type.js +0 -1
  183. package/dist/gaesup/tools/rideable/index.d.ts +0 -3
  184. package/dist/gaesup/tools/rideable/index.js +0 -79
  185. package/dist/gaesup/tools/rideable/style.css +0 -16
  186. package/dist/gaesup/tools/type.d.ts +0 -2
  187. package/dist/gaesup/tools/type.js +0 -1
  188. package/dist/gaesup/tools/zoomButton/index.d.ts +0 -18
  189. package/dist/gaesup/tools/zoomButton/index.js +0 -146
  190. package/dist/gaesup/tools/zoomButton/style.css +0 -16
  191. package/dist/gaesup/utils/context.d.ts +0 -2
  192. package/dist/gaesup/utils/context.js +0 -3
  193. package/dist/gaesup/utils/debug.d.ts +0 -29
  194. package/dist/gaesup/utils/debug.js +0 -36
  195. package/dist/gaesup/utils/index.d.ts +0 -3
  196. package/dist/gaesup/utils/index.js +0 -3
  197. package/dist/gaesup/utils/ray.d.ts +0 -7
  198. package/dist/gaesup/utils/ray.js +0 -6
  199. package/dist/gaesup/utils/ref.d.ts +0 -2
  200. package/dist/gaesup/utils/ref.js +0 -16
  201. package/dist/gaesup/utils/type.d.ts +0 -5
  202. package/dist/gaesup/utils/type.js +0 -1
  203. package/dist/gaesup/utils/vector.d.ts +0 -10
  204. package/dist/gaesup/utils/vector.js +0 -33
  205. package/dist/gaesup/world/context/index.d.ts +0 -6
  206. package/dist/gaesup/world/context/index.js +0 -117
  207. package/dist/gaesup/world/context/reducer.d.ts +0 -29
  208. package/dist/gaesup/world/context/reducer.js +0 -21
  209. package/dist/gaesup/world/context/type.d.ts +0 -169
  210. package/dist/gaesup/world/context/type.js +0 -1
  211. package/dist/gaesup/world/debug/cameraOption.d.ts +0 -47
  212. package/dist/gaesup/world/debug/cameraOption.js +0 -47
  213. package/dist/gaesup/world/debug/index.d.ts +0 -6
  214. package/dist/gaesup/world/debug/index.js +0 -32
  215. package/dist/gaesup/world/debug/mode.d.ts +0 -10
  216. package/dist/gaesup/world/debug/mode.js +0 -10
  217. package/dist/gaesup/world/index.d.ts +0 -3
  218. package/dist/gaesup/world/index.js +0 -10
  219. package/dist/gaesup/world/initalize/index.d.ts +0 -35
  220. package/dist/gaesup/world/initalize/index.js +0 -62
  221. package/dist/gaesup/world/style.css +0 -13
  222. package/dist/gaesup/world/type.d.ts +0 -19
  223. package/dist/gaesup/world/type.js +0 -1
  224. package/dist/index.d.ts +0 -23
  225. package/dist/index.js +0 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.2.34",
3
+ "version": "0.2.36",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,9 +12,7 @@
12
12
  "build": "vite build",
13
13
  "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
14
14
  "preview": "vite preview",
15
- "prepare": "rm -rf dist && mkdir dist && yarn clean && tsc -p tsconfig.build.json && yarn copy-files",
16
15
  "predeploy": "vite build",
17
- "prepublishOnly": "rm -rf dist/ && npm run build",
18
16
  "deploy": "gh-pages -d dist"
19
17
  },
20
18
  "dependencies": {
@@ -1,44 +0,0 @@
1
- import { Ref } from "react";
2
- import { AnimationAction, AnimationClip, AnimationMixer, Object3D, Object3DEventMap } from "three";
3
- import { groundRayType } from "../controller/type";
4
- export type Api<T extends AnimationClip> = {
5
- ref: React.MutableRefObject<Object3D | undefined | null>;
6
- clips: AnimationClip[];
7
- mixer: AnimationMixer;
8
- names: T["name"][];
9
- actions: {
10
- [key in T["name"]]: AnimationAction | null;
11
- };
12
- };
13
- export type playActionsType = {
14
- type: "character" | "vehicle" | "airplane";
15
- animationResult: Api<AnimationClip>;
16
- currentAnimation?: string;
17
- };
18
- export type subscribeActionsType = {
19
- type: "character" | "vehicle" | "airplane";
20
- groundRay: groundRayType;
21
- animations: AnimationClip[];
22
- };
23
- export type actionsType = {
24
- [x: string]: THREE.AnimationAction | null;
25
- };
26
- export type playResultType = {
27
- actions: actionsType;
28
- ref: Ref<Object3D<Object3DEventMap>>;
29
- };
30
- export declare function subscribeActions({ type, groundRay, animations, }: subscribeActionsType): {
31
- animationResult: {
32
- ref: import("react").MutableRefObject<Object3D<Object3DEventMap>>;
33
- clips: AnimationClip[];
34
- mixer: AnimationMixer;
35
- names: string[];
36
- actions: {
37
- [x: string]: AnimationAction;
38
- };
39
- };
40
- };
41
- export default function playActions({ type, animationResult, currentAnimation, }: playActionsType): {
42
- animationRef: import("react").MutableRefObject<Object3D<Object3DEventMap>>;
43
- currentAnimation: string;
44
- };
@@ -1,103 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { useAnimations } from "@react-three/drei";
13
- import { useFrame } from "@react-three/fiber";
14
- import { useContext, useEffect } from "react";
15
- import { useGaesupAnimation } from "../hooks/useGaesupAnimation";
16
- import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context";
17
- export function subscribeActions(_a) {
18
- var type = _a.type, groundRay = _a.groundRay, animations = _a.animations;
19
- var _b = useContext(GaesupWorldContext), states = _b.states, activeState = _b.activeState;
20
- var subscribeAll = useGaesupAnimation({ type: type }).subscribeAll;
21
- var animationResult = useAnimations(animations);
22
- // 초기 기본 애니메이션 등록
23
- useEffect(function () {
24
- subscribeAll([
25
- {
26
- tag: "walk",
27
- condition: function () { return !states.isRunning && states.isMoving; },
28
- action: function () { },
29
- animationName: "walk",
30
- key: "walk",
31
- },
32
- {
33
- tag: "run",
34
- condition: function () { return states.isRunning; },
35
- action: function () { },
36
- animationName: "run",
37
- key: "run",
38
- },
39
- {
40
- tag: "jump",
41
- condition: function () { return states.isJumping; },
42
- action: function () { },
43
- animationName: "jump",
44
- key: "jump",
45
- },
46
- {
47
- tag: "fall",
48
- condition: function () { return groundRay.hit === null && activeState.velocity.y < 0; },
49
- action: function () { },
50
- animationName: "fall",
51
- key: "fall",
52
- },
53
- {
54
- tag: "ride",
55
- condition: function () { return states.isPush["keyR"]; },
56
- action: function () { },
57
- animationName: "ride",
58
- key: "ride",
59
- },
60
- ]);
61
- }, []);
62
- return {
63
- animationResult: animationResult,
64
- };
65
- }
66
- export default function playActions(_a) {
67
- var _b;
68
- var type = _a.type, animationResult = _a.animationResult, currentAnimation = _a.currentAnimation;
69
- var _c = useContext(GaesupWorldContext), mode = _c.mode, animationState = _c.animationState;
70
- var dispatch = useContext(GaesupWorldDispatchContext);
71
- var _d = useGaesupAnimation({ type: type }), notify = _d.notify, store = _d.store;
72
- var actions = animationResult.actions, ref = animationResult.ref;
73
- var play = function (tag) {
74
- animationState[type].current = tag;
75
- var currentAnimation = store[tag];
76
- if (currentAnimation === null || currentAnimation === void 0 ? void 0 : currentAnimation.action) {
77
- currentAnimation.action();
78
- }
79
- dispatch({
80
- type: "update",
81
- payload: {
82
- animationState: __assign({}, animationState),
83
- },
84
- });
85
- };
86
- useEffect(function () {
87
- var _a;
88
- var action = (_a = actions[currentAnimation || animationState[type].current]) === null || _a === void 0 ? void 0 : _a.reset().fadeIn(0.2).play();
89
- return function () {
90
- action === null || action === void 0 ? void 0 : action.fadeOut(0.2);
91
- };
92
- }, [currentAnimation, mode.type]);
93
- useFrame(function () {
94
- if (!currentAnimation) {
95
- var tag = notify();
96
- play(tag);
97
- }
98
- });
99
- return {
100
- animationRef: ref,
101
- currentAnimation: (_b = animationState === null || animationState === void 0 ? void 0 : animationState[type]) === null || _b === void 0 ? void 0 : _b.current,
102
- };
103
- }
@@ -1,4 +0,0 @@
1
- import { cameraPropType } from "../../physics/type";
2
- import { activeStateType, cameraOptionType } from "../../world/context/type";
3
- export declare const makeNormalCameraPosition: (activeState: activeStateType, cameraOption: cameraOptionType) => import("three").Vector3;
4
- export default function normal(prop: cameraPropType): void;
@@ -1,18 +0,0 @@
1
- import { V3 } from "../../utils/vector";
2
- export var makeNormalCameraPosition = function (activeState, cameraOption) {
3
- var YDistance = cameraOption.YDistance, ZDistance = cameraOption.ZDistance;
4
- var cameraPosition = activeState.position
5
- .clone()
6
- .add(V3(0, YDistance, ZDistance));
7
- return cameraPosition;
8
- };
9
- export default function normal(prop) {
10
- var state = prop.state, _a = prop.worldContext, activeState = _a.activeState, cameraOption = _a.cameraOption;
11
- if (!state || !state.camera)
12
- return;
13
- var cameraPosition = activeState.position
14
- .clone()
15
- .add(V3(0, cameraOption.YDistance, cameraOption.ZDistance));
16
- state.camera.position.lerp(cameraPosition, 1);
17
- state.camera.lookAt(activeState.position.clone());
18
- }
@@ -1,4 +0,0 @@
1
- import { cameraPropType } from "../../physics/type";
2
- import { activeStateType, cameraOptionType } from "../../world/context/type";
3
- export declare const makeOrbitCameraPosition: (activeState: activeStateType, cameraOption: cameraOptionType) => import("three").Vector3;
4
- export default function orbit(prop: cameraPropType): void;
@@ -1,22 +0,0 @@
1
- import { quat } from "@react-three/rapier";
2
- import { V3 } from "../../utils/vector";
3
- export var makeOrbitCameraPosition = function (activeState, cameraOption) {
4
- var XDistance = cameraOption.XDistance, YDistance = cameraOption.YDistance, ZDistance = cameraOption.ZDistance;
5
- var cameraPosition = activeState.position.clone().add(V3(Math.sin(activeState.euler.y), 1, Math.cos(activeState.euler.y))
6
- .normalize()
7
- .clone()
8
- .multiply(V3(-XDistance, YDistance, -ZDistance)));
9
- return cameraPosition;
10
- };
11
- export default function orbit(prop) {
12
- var state = prop.state, _a = prop.worldContext, activeState = _a.activeState, cameraOption = _a.cameraOption;
13
- if (!state || !state.camera)
14
- return;
15
- var cameraPosition = makeOrbitCameraPosition(activeState, cameraOption);
16
- state.camera.position.lerp(cameraPosition, 1);
17
- state.camera.quaternion.copy(activeState.quat
18
- .clone()
19
- .multiply(quat().setFromAxisAngle(V3(0, 1, 0), Math.PI)));
20
- state.camera.rotation.copy(activeState.euler);
21
- state.camera.lookAt(activeState.position.clone());
22
- }
@@ -1,2 +0,0 @@
1
- import { cameraPropType } from "../../physics/type";
2
- export default function detector(cameraProp: cameraPropType): void;
@@ -1,25 +0,0 @@
1
- import * as THREE from "three";
2
- export default function detector(cameraProp) {
3
- var cameraRay = cameraProp.cameraRay, intersectObjectMap = cameraProp.intersectObjectMap;
4
- var intersects = cameraRay.rayCast.intersectObjects(Object.values(intersectObjectMap));
5
- var intersectId = {};
6
- intersects.map(function (_a) {
7
- var object = _a.object;
8
- if (object instanceof THREE.Mesh) {
9
- intersectId[object.uuid] = true;
10
- }
11
- });
12
- Object.values(intersectObjectMap).map(function (mesh) {
13
- if (mesh instanceof THREE.Mesh && mesh.material instanceof THREE.Material) {
14
- var material = mesh.material;
15
- if (intersectId[mesh.uuid]) {
16
- material.opacity = 0.2;
17
- material.transparent = true;
18
- }
19
- else {
20
- material.opacity = 1;
21
- material.transparent = false;
22
- }
23
- }
24
- });
25
- }
@@ -1,8 +0,0 @@
1
- import { controllerInnerType, refsType } from "../controller/type";
2
- export default function Camera({ refs, prop, control, }: {
3
- refs: refsType;
4
- prop: controllerInnerType;
5
- control: {
6
- [key: string]: boolean;
7
- };
8
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,110 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { CameraControls } from "@react-three/drei";
14
- import { useFrame, useThree } from "@react-three/fiber";
15
- import { vec3 } from "@react-three/rapier";
16
- import { useContext, useEffect, useMemo, useRef } from "react";
17
- import * as THREE from "three";
18
- import { GaesupControllerContext } from "../controller/context";
19
- import { GaesupWorldContext } from "../world/context";
20
- import normal from "./control/normal";
21
- import orbit from "./control/orbit";
22
- import detector from "./detector";
23
- export default function Camera(_a) {
24
- var refs = _a.refs, prop = _a.prop, control = _a.control;
25
- var worldContext = useContext(GaesupWorldContext);
26
- var controllerContext = useContext(GaesupControllerContext);
27
- var mode = worldContext.mode, cameraOption = worldContext.cameraOption;
28
- var rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef;
29
- var _b = useThree(), scene = _b.scene, camera = _b.camera;
30
- var cameraRef = useRef();
31
- var intersectObjectMap = useMemo(function () { return ({}); }, []);
32
- var cameraProp = __assign(__assign({}, prop), { control: control, controllerContext: controllerContext, worldContext: worldContext, intersectObjectMap: intersectObjectMap });
33
- var getMeshs = function (object) {
34
- if (object.userData && object.userData.intangible)
35
- return;
36
- if (object instanceof THREE.Mesh &&
37
- object.geometry.type !== "InstancedBufferGeometry") {
38
- intersectObjectMap[object.uuid] = object;
39
- }
40
- object.children.forEach(function (child) {
41
- getMeshs(child);
42
- });
43
- };
44
- useEffect(function () {
45
- scene.children.forEach(function (child) { return getMeshs(child); });
46
- }, []);
47
- var position = useMemo(function () { return camera.position; }, []);
48
- var dir = useMemo(function () { return vec3(); }, []);
49
- cameraProp.cameraRay.rayCast = new THREE.Raycaster(cameraProp.cameraRay.origin, cameraProp.cameraRay.dir, 0, -cameraOption.maxDistance);
50
- useEffect(function () {
51
- cameraProp.cameraRay.origin.copy(position);
52
- cameraProp.cameraRay.dir.copy(camera.getWorldDirection(dir));
53
- }, [cameraProp]);
54
- useFrame(function (state, delta) {
55
- if (!rigidBodyRef ||
56
- !rigidBodyRef.current ||
57
- !outerGroupRef ||
58
- !outerGroupRef.current)
59
- return;
60
- cameraProp.delta = delta;
61
- cameraProp.state = state;
62
- if (!worldContext.block.camera) {
63
- if (mode.control === "orbit") {
64
- orbit(cameraProp);
65
- }
66
- else if (mode.control === "normal") {
67
- normal(cameraProp);
68
- }
69
- detector(cameraProp);
70
- }
71
- });
72
- // // moveTo 함수 정의
73
- // worldContext.moveTo = async (
74
- // position: THREE.Vector3,
75
- // target: THREE.Vector3
76
- // ) => {
77
- // camera.position.copy(position);
78
- // if (mode.control === "orbit") {
79
- // await Promise.all([
80
- // cameraRef.current.setPosition(position.x, position.y, position.z, true),
81
- //
82
- // camera.rotation.copy(worldContext.activeState.euler),
83
- // cameraRef.current.setLookAt(
84
- // position.x,
85
- // position.y,
86
- // position.z,
87
- // target.x,
88
- // target.y,
89
- // target.z,
90
- // true
91
- // ),
92
- // ]);
93
- // } else if (mode.control === "normal") {
94
- // await Promise.all([
95
- // cameraRef.current.setPosition(0, position.y, position.z, true),
96
- // camera.rotation.copy(worldContext.activeState.euler),
97
- // cameraRef.current.setLookAt(
98
- // 0,
99
- // position.y,
100
- // position.z,
101
- // target.x,
102
- // target.y,
103
- // target.z,
104
- // true
105
- // ),
106
- // ]);
107
- // }
108
- // };
109
- return _jsx(CameraControls, { ref: cameraRef });
110
- }
@@ -1,13 +0,0 @@
1
- export type cameraRayType = {
2
- origin: THREE.Vector3;
3
- hit: THREE.Raycaster;
4
- rayCast: THREE.Raycaster | null;
5
- length: number;
6
- dir: THREE.Vector3;
7
- position: THREE.Vector3;
8
- intersects: THREE.Intersection<THREE.Mesh>[];
9
- detected: THREE.Intersection<THREE.Mesh>[];
10
- intersectObjectMap: {
11
- [uuid: string]: THREE.Mesh;
12
- };
13
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { refsType } from "../../../controller/type";
3
- import { urlsType } from "../../../world/context/type";
4
- export declare function AirplaneRef({ children, enableRiding, isRiderOn, offset, refs, urls, }: {
5
- children: ReactNode;
6
- enableRiding?: boolean;
7
- isRiderOn?: boolean;
8
- offset?: THREE.Vector3;
9
- refs: refsType;
10
- urls: urlsType;
11
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { AirplaneInnerRef } from "../../inner/airplane";
3
- export function AirplaneRef(_a) {
4
- var children = _a.children, enableRiding = _a.enableRiding, isRiderOn = _a.isRiderOn, offset = _a.offset, refs = _a.refs, urls = _a.urls;
5
- return (_jsx(AirplaneInnerRef, { refs: refs, urls: urls, isRiderOn: isRiderOn, enableRiding: enableRiding, offset: offset, children: children }));
6
- }
@@ -1,7 +0,0 @@
1
- import { controllerInnerType, refsType } from "../../../controller/type";
2
- import { urlsType } from "../../../world/context/type";
3
- export declare function CharacterRef({ props, refs, urls, }: {
4
- props: controllerInnerType;
5
- refs: refsType;
6
- urls: urlsType;
7
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,34 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { vec3 } from "@react-three/rapier";
3
- import playActions, { subscribeActions } from "../../../animation/actions";
4
- import initCallback from "../../../controller/initialize/callback";
5
- import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
6
- import { CharacterInnerRef, calcCharacterColliderProps, } from "../../inner/character";
7
- import { setGroundRay } from "../../inner/common/setGroundRay";
8
- export function CharacterRef(_a) {
9
- var props = _a.props, refs = _a.refs, urls = _a.urls;
10
- initCallback(props, "character");
11
- var colliderRef = refs.colliderRef;
12
- var _b = useGltfAndSize({ url: urls.characterUrl }), size = _b.size, gltf = _b.gltf;
13
- var collider = calcCharacterColliderProps(size);
14
- props.groundRay.offset = vec3({
15
- x: 0,
16
- y: (collider === null || collider === void 0 ? void 0 : collider.halfHeight) ? -(collider === null || collider === void 0 ? void 0 : collider.halfHeight) : -1,
17
- z: 0,
18
- });
19
- setGroundRay({
20
- groundRay: props.groundRay,
21
- length: (collider === null || collider === void 0 ? void 0 : collider.radius) || 0 + 2,
22
- colliderRef: colliderRef,
23
- });
24
- var animationResult = subscribeActions({
25
- type: "character",
26
- groundRay: props.groundRay,
27
- animations: gltf.animations,
28
- }).animationResult;
29
- var _c = playActions({
30
- type: "character",
31
- animationResult: animationResult,
32
- }), animationRef = _c.animationRef, currentAnimation = _c.currentAnimation;
33
- return (_jsx(CharacterInnerRef, { animationRef: animationRef, refs: refs, urls: urls, currentAnimation: currentAnimation, children: props.children }));
34
- }
@@ -1,12 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { groundRayType, refsType } from "../../../controller/type";
3
- import { urlsType } from "../../../world/context/type";
4
- export declare function VehicleRef({ children, groundRay, enableRiding, isRiderOn, offset, refs, urls, }: {
5
- children: ReactNode;
6
- groundRay: groundRayType;
7
- enableRiding?: boolean;
8
- isRiderOn?: boolean;
9
- offset?: THREE.Vector3;
10
- refs: refsType;
11
- urls: urlsType;
12
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,31 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { vec3 } from "@react-three/rapier";
3
- import playActions, { subscribeActions } from "../../../animation/actions";
4
- import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
5
- import { setGroundRay } from "../../inner/common/setGroundRay";
6
- import { VehicleInnerRef } from "../../inner/vehicle";
7
- export function VehicleRef(_a) {
8
- var children = _a.children, groundRay = _a.groundRay, enableRiding = _a.enableRiding, isRiderOn = _a.isRiderOn, offset = _a.offset, refs = _a.refs, urls = _a.urls;
9
- var colliderRef = refs.colliderRef;
10
- var _b = useGltfAndSize({ url: urls.vehicleUrl }), size = _b.size, gltf = _b.gltf;
11
- groundRay.offset = vec3({
12
- x: 0,
13
- y: size.y * 3,
14
- z: 0,
15
- });
16
- setGroundRay({
17
- groundRay: groundRay,
18
- length: size.y * 3,
19
- colliderRef: colliderRef,
20
- });
21
- var animationResult = subscribeActions({
22
- type: "vehicle",
23
- groundRay: groundRay,
24
- animations: gltf.animations,
25
- }).animationResult;
26
- var _c = playActions({
27
- type: "vehicle",
28
- animationResult: animationResult,
29
- }), animationRef = _c.animationRef, currentAnimation = _c.currentAnimation;
30
- return (_jsx(VehicleInnerRef, { refs: refs, urls: urls, isRiderOn: isRiderOn, enableRiding: enableRiding, offset: offset, currentAnimation: currentAnimation, children: children }));
31
- }
@@ -1,7 +0,0 @@
1
- import { controllerInnerType, refsType } from "../controller/type";
2
- import { urlsType } from "../world/context/type";
3
- export declare function GaesupComponent({ props, refs, urls, }: {
4
- props: controllerInnerType;
5
- refs: refsType;
6
- urls: urlsType;
7
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,19 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { vec3 } from "@react-three/rapier";
3
- import { useContext } from "react";
4
- import calculation from "../physics";
5
- import { GaesupWorldContext } from "../world/context";
6
- import { AirplaneRef } from "./active/airplane";
7
- import { CharacterRef } from "./active/character";
8
- import { VehicleRef } from "./active/vehicle";
9
- export function GaesupComponent(_a) {
10
- var props = _a.props, refs = _a.refs, urls = _a.urls;
11
- var _b = useContext(GaesupWorldContext), mode = _b.mode, states = _b.states, rideable = _b.rideable;
12
- var enableRiding = states.enableRiding, isRiderOn = states.isRiderOn, rideableId = states.rideableId;
13
- calculation(props);
14
- return (_jsxs(_Fragment, { children: [mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, { groundRay: props.groundRay, refs: refs, urls: urls, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
15
- ? rideable[rideableId].offset
16
- : vec3(), children: props.children })), mode.type === "airplane" && (_jsx(AirplaneRef, { refs: refs, urls: urls, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
17
- ? rideable[rideableId].offset
18
- : vec3(), children: props.children }))] }));
19
- }
@@ -1,2 +0,0 @@
1
- import { refPropsType } from "../common/type";
2
- export declare function AirplaneInnerRef({ children, refs, urls, isRiderOn, enableRiding, offset, name, position, rotation, userData, onCollisionEnter, }: refPropsType): import("react/jsx-runtime").JSX.Element;
@@ -1,16 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CuboidCollider } from "@react-three/rapier";
3
- import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
4
- import { InnerGroupRef } from "../common/InnerGroupRef";
5
- import { OuterGroupRef } from "../common/OuterGroupRef";
6
- import { RigidBodyRef } from "../common/RigidbodyRef";
7
- import RiderRef from "../rider";
8
- export function AirplaneInnerRef(_a) {
9
- var children = _a.children, refs = _a.refs, urls = _a.urls, isRiderOn = _a.isRiderOn, enableRiding = _a.enableRiding, offset = _a.offset, name = _a.name, position = _a.position, rotation = _a.rotation, userData = _a.userData, onCollisionEnter = _a.onCollisionEnter;
10
- var airplaneUrl = urls.airplaneUrl;
11
- var rigidBodyRef = refs.rigidBodyRef, innerGroupRef = refs.innerGroupRef, outerGroupRef = refs.outerGroupRef;
12
- var size = useGltfAndSize({
13
- url: airplaneUrl,
14
- }).size;
15
- return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: airplaneUrl && (_jsxs(RigidBodyRef, { ref: rigidBodyRef, name: name, position: position, rotation: rotation, userData: userData, onCollisionEnter: onCollisionEnter, children: [_jsx(CuboidCollider, { args: [size.x / 2, size.y / 2, size.z / 2], position: [0, size.y / 2, 0] }), children, _jsx(InnerGroupRef, { type: "airplane", url: airplaneUrl, currentAnimation: "idle", ref: innerGroupRef, children: enableRiding && isRiderOn && urls.characterUrl && (_jsx(RiderRef, { urls: urls, offset: offset })) })] })) }));
16
- }
@@ -1,25 +0,0 @@
1
- import { refsType } from "../../../controller/type";
2
- import { ReactNode, Ref } from "react";
3
- import { Object3D, Object3DEventMap } from "three";
4
- import { urlsType } from "../../../world/context/type";
5
- export declare const calcCharacterColliderProps: (characterSize: THREE.Vector3) => {
6
- height: number;
7
- halfHeight: number;
8
- radius: number;
9
- diameter: number;
10
- };
11
- export type characterColliderType = {
12
- height: number;
13
- halfHeight: number;
14
- radius: number;
15
- diameter: number;
16
- };
17
- export declare function CharacterInnerRef({ children, refs, urls, position, euler, currentAnimation, }: {
18
- children: ReactNode;
19
- refs: Partial<refsType>;
20
- urls: urlsType;
21
- position?: THREE.Vector3;
22
- euler?: THREE.Euler;
23
- animationRef?: Ref<Object3D<Object3DEventMap>>;
24
- currentAnimation?: string;
25
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,28 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { CapsuleCollider } from "@react-three/rapier";
3
- import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
4
- import { InnerGroupRef } from "../common/InnerGroupRef";
5
- import { OuterGroupRef } from "../common/OuterGroupRef";
6
- import { RigidBodyRef } from "../common/RigidbodyRef";
7
- export var calcCharacterColliderProps = function (characterSize) {
8
- if (!characterSize)
9
- return null;
10
- var heightPlusDiameter = characterSize.y / 2;
11
- var diameter = Math.max(characterSize.x, characterSize.z);
12
- var radius = diameter / 2;
13
- var height = heightPlusDiameter - radius;
14
- var halfHeight = height / 2;
15
- return {
16
- height: height,
17
- halfHeight: halfHeight,
18
- radius: radius,
19
- diameter: diameter,
20
- };
21
- };
22
- export function CharacterInnerRef(_a) {
23
- var children = _a.children, refs = _a.refs, urls = _a.urls, position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation;
24
- var outerGroupRef = refs.outerGroupRef, rigidBodyRef = refs.rigidBodyRef, colliderRef = refs.colliderRef, innerGroupRef = refs.innerGroupRef;
25
- var size = useGltfAndSize({ url: urls.characterUrl }).size;
26
- var collider = calcCharacterColliderProps(size);
27
- return (_jsx(_Fragment, { children: collider && (_jsxs(OuterGroupRef, { ref: outerGroupRef, children: [children, _jsxs(RigidBodyRef, { ref: rigidBodyRef, name: "character", position: position, rotation: euler, children: [_jsx(CapsuleCollider, { ref: colliderRef, args: [collider.height, collider.radius], position: [0, collider.height + collider.radius, 0] }), _jsx(InnerGroupRef, { type: "character", ref: innerGroupRef, url: urls.characterUrl, currentAnimation: currentAnimation })] })] })) }));
28
- }
@@ -1,10 +0,0 @@
1
- /// <reference types="react" />
2
- import * as THREE from "three";
3
- export type InnerGroupRefType = {
4
- children?: React.ReactNode;
5
- type: "character" | "vehicle" | "airplane";
6
- currentAnimation: string;
7
- url: string;
8
- rotation?: THREE.Euler;
9
- };
10
- export declare const InnerGroupRef: import("react").ForwardRefExoticComponent<InnerGroupRefType & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;
@@ -1,29 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useGraph } from "@react-three/fiber";
3
- import { Suspense, forwardRef, useMemo } from "react";
4
- import * as THREE from "three";
5
- import { SkeletonUtils } from "three-stdlib";
6
- import { useAnimations, useGLTF } from "@react-three/drei";
7
- import playActions from "../../../animation/actions";
8
- export var InnerGroupRef = forwardRef(function (_a, ref) {
9
- var children = _a.children, type = _a.type, currentAnimation = _a.currentAnimation, url = _a.url, rotation = _a.rotation;
10
- var _b = useGLTF(url), scene = _b.scene, animations = _b.animations;
11
- var animationResult = useAnimations(animations);
12
- var animationRef = playActions({
13
- type: type,
14
- animationResult: animationResult,
15
- currentAnimation: currentAnimation,
16
- }).animationRef;
17
- var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
18
- var nodes = useGraph(clone).nodes;
19
- var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
20
- return (_jsx(Suspense, { fallback: null, children: _jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, rotation: rotation, userData: { intangible: true }, children: [children, objectNode && animationRef && (_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: animationRef })), Object.keys(nodes).map(function (name, key) {
21
- var node = nodes[name];
22
- if (node instanceof THREE.SkinnedMesh) {
23
- return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry, skeleton: node.skeleton }, key));
24
- }
25
- else if (node instanceof THREE.Mesh) {
26
- return (_jsx("mesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry }, key));
27
- }
28
- })] }) }));
29
- });