gaesup-world 0.5.22 → 0.5.23
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as THREE from "three";
|
|
2
2
|
export declare function useMovePoint(): {
|
|
3
|
-
|
|
3
|
+
move: (position: THREE.Vector3, isRun: boolean) => void;
|
|
4
4
|
};
|
|
@@ -2,23 +2,20 @@ import { useContext, useEffect } from "react";
|
|
|
2
2
|
import { V3 } from "../../utils";
|
|
3
3
|
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
|
|
4
4
|
export function useMovePoint() {
|
|
5
|
-
var _a = useContext(GaesupWorldContext), activeState = _a.activeState, clicker = _a.clicker
|
|
5
|
+
var _a = useContext(GaesupWorldContext), activeState = _a.activeState, clicker = _a.clicker;
|
|
6
6
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
7
|
-
var
|
|
8
|
-
if (mode.controller !== "clicker" || type !== "ground")
|
|
9
|
-
return;
|
|
7
|
+
var move = function (position, isRun) {
|
|
10
8
|
var originPoint = activeState.position;
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
Math.pow(newPosition.x - originPoint.x, 2));
|
|
9
|
+
var newAngle = Math.atan2(position.z - originPoint.z, position.x - originPoint.x);
|
|
10
|
+
var norm = Math.sqrt(Math.pow(position.z - originPoint.z, 2) +
|
|
11
|
+
Math.pow(position.x - originPoint.x, 2));
|
|
15
12
|
if (norm < 2)
|
|
16
13
|
return;
|
|
17
14
|
dispatch({
|
|
18
15
|
type: "update",
|
|
19
16
|
payload: {
|
|
20
17
|
clicker: {
|
|
21
|
-
point: V3(
|
|
18
|
+
point: V3(position.x, 0, position.z),
|
|
22
19
|
angle: newAngle,
|
|
23
20
|
isOn: true,
|
|
24
21
|
isRun: isRun,
|
|
@@ -43,6 +40,6 @@ export function useMovePoint() {
|
|
|
43
40
|
}
|
|
44
41
|
}, [activeState.position, clicker.point]);
|
|
45
42
|
return {
|
|
46
|
-
|
|
43
|
+
move: move,
|
|
47
44
|
};
|
|
48
45
|
}
|