gaesup-world 0.5.21 → 0.5.22
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.
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useContext, useEffect } from "react";
|
|
2
|
+
import { V3 } from "../../utils";
|
|
3
|
+
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
|
|
4
|
+
export function useMovePoint() {
|
|
5
|
+
var _a = useContext(GaesupWorldContext), activeState = _a.activeState, clicker = _a.clicker, mode = _a.mode;
|
|
6
|
+
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
7
|
+
var moveClicker = function (e, isRun, type) {
|
|
8
|
+
if (mode.controller !== "clicker" || type !== "ground")
|
|
9
|
+
return;
|
|
10
|
+
var originPoint = activeState.position;
|
|
11
|
+
var newPosition = e.point;
|
|
12
|
+
var newAngle = Math.atan2(newPosition.z - originPoint.z, newPosition.x - originPoint.x);
|
|
13
|
+
var norm = Math.sqrt(Math.pow(newPosition.z - originPoint.z, 2) +
|
|
14
|
+
Math.pow(newPosition.x - originPoint.x, 2));
|
|
15
|
+
if (norm < 2)
|
|
16
|
+
return;
|
|
17
|
+
dispatch({
|
|
18
|
+
type: "update",
|
|
19
|
+
payload: {
|
|
20
|
+
clicker: {
|
|
21
|
+
point: V3(e.point.x, e.point.y, e.point.z),
|
|
22
|
+
angle: newAngle,
|
|
23
|
+
isOn: true,
|
|
24
|
+
isRun: isRun,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
// 거리 계산
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
var originPoint = activeState.position;
|
|
32
|
+
var newPosition = clicker.point;
|
|
33
|
+
var norm = Math.sqrt(Math.pow(newPosition.z - originPoint.z, 2) +
|
|
34
|
+
Math.pow(newPosition.x - originPoint.x, 2));
|
|
35
|
+
if (norm < 1) {
|
|
36
|
+
clicker.isOn = false;
|
|
37
|
+
dispatch({
|
|
38
|
+
type: "update",
|
|
39
|
+
payload: {
|
|
40
|
+
clicker: clicker,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, [activeState.position, clicker.point]);
|
|
45
|
+
return {
|
|
46
|
+
moveClicker: moveClicker,
|
|
47
|
+
};
|
|
48
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { useFocus } from "./gaesup/hooks/useFocus";
|
|
|
22
22
|
export { useGaesupAnimation } from "./gaesup/hooks/useGaesupAnimation";
|
|
23
23
|
export { useGaesupController } from "./gaesup/hooks/useGaesupController";
|
|
24
24
|
export * as useJoyStick from "./gaesup/hooks/useJoyStick";
|
|
25
|
+
export { useMovePoint } from "./gaesup/hooks/useMovePoint";
|
|
25
26
|
export { usePushKey } from "./gaesup/hooks/usePushKey";
|
|
26
27
|
export { useRideable } from "./gaesup/hooks/useRideable";
|
|
27
28
|
export { useTeleport } from "./gaesup/hooks/useTeleport";
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export { useFocus } from "./gaesup/hooks/useFocus";
|
|
|
22
22
|
export { useGaesupAnimation } from "./gaesup/hooks/useGaesupAnimation";
|
|
23
23
|
export { useGaesupController } from "./gaesup/hooks/useGaesupController";
|
|
24
24
|
export * as useJoyStick from "./gaesup/hooks/useJoyStick";
|
|
25
|
+
export { useMovePoint } from "./gaesup/hooks/useMovePoint";
|
|
25
26
|
export { usePushKey } from "./gaesup/hooks/usePushKey";
|
|
26
27
|
export { useRideable } from "./gaesup/hooks/useRideable";
|
|
27
28
|
export { useTeleport } from "./gaesup/hooks/useTeleport";
|
package/index.ts
CHANGED