gaesup-world 0.3.3 → 0.3.5
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.
- package/dist/gaesup/gaesupProps/index.js +2 -46
- package/dist/gaesup/hooks/useClicker/index.d.ts +1 -1
- package/dist/gaesup/hooks/useClicker/index.js +28 -12
- package/dist/gaesup/physics/character/direction.js +1 -1
- package/dist/gaesup/physics/index.js +1 -1
- package/dist/gaesup/tools/gamePad/GamePadButton.js +1 -1
- package/dist/gaesup/world/context/index.js +1 -1
- package/package.json +2 -1
|
@@ -18,52 +18,10 @@ import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/contex
|
|
|
18
18
|
export function GaeSupProps(_a) {
|
|
19
19
|
var _b = _a.type, type = _b === void 0 ? "normal" : _b, text = _a.text, position = _a.position, children = _a.children;
|
|
20
20
|
var groupRef = useRef(null);
|
|
21
|
-
var
|
|
21
|
+
var minimap = useContext(GaesupWorldContext).minimap;
|
|
22
22
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
23
23
|
// clicker
|
|
24
24
|
var moveClicker = useClicker().moveClicker;
|
|
25
|
-
// const moveClicker = (e: ThreeEvent<MouseEvent>) => {
|
|
26
|
-
// const originPoint = activeState.position;
|
|
27
|
-
// const newPosition = e.point;
|
|
28
|
-
// const newAngle = Math.atan2(
|
|
29
|
-
// newPosition.z - originPoint.z,
|
|
30
|
-
// newPosition.x - originPoint.x
|
|
31
|
-
// );
|
|
32
|
-
// const norm = Math.sqrt(
|
|
33
|
-
// Math.pow(newPosition.z - originPoint.z, 2) +
|
|
34
|
-
// Math.pow(newPosition.x - originPoint.x, 2)
|
|
35
|
-
// );
|
|
36
|
-
// if (norm < 1) return;
|
|
37
|
-
// dispatch({
|
|
38
|
-
// type: "update",
|
|
39
|
-
// payload: {
|
|
40
|
-
// clicker: {
|
|
41
|
-
// point: V3(e.point.x, e.point.y, e.point.z),
|
|
42
|
-
// angle: newAngle,
|
|
43
|
-
// isOn: true,
|
|
44
|
-
// },
|
|
45
|
-
// },
|
|
46
|
-
// });
|
|
47
|
-
// };
|
|
48
|
-
//
|
|
49
|
-
// // 거리 계산
|
|
50
|
-
// useEffect(() => {
|
|
51
|
-
// const originPoint = activeState.position;
|
|
52
|
-
// const newPosition = clicker.point;
|
|
53
|
-
// const norm = Math.sqrt(
|
|
54
|
-
// Math.pow(newPosition.z - originPoint.z, 2) +
|
|
55
|
-
// Math.pow(newPosition.x - originPoint.x, 2)
|
|
56
|
-
// );
|
|
57
|
-
// if (norm < 1) {
|
|
58
|
-
// clicker.isOn = false;
|
|
59
|
-
// dispatch({
|
|
60
|
-
// type: "update",
|
|
61
|
-
// payload: {
|
|
62
|
-
// clicker: clicker,
|
|
63
|
-
// },
|
|
64
|
-
// });
|
|
65
|
-
// }
|
|
66
|
-
// }, [activeState.position, clicker.point]);
|
|
67
25
|
useEffect(function () {
|
|
68
26
|
if (groupRef.current) {
|
|
69
27
|
var box = new THREE.Box3().setFromObject(groupRef.current);
|
|
@@ -84,7 +42,5 @@ export function GaeSupProps(_a) {
|
|
|
84
42
|
});
|
|
85
43
|
}
|
|
86
44
|
}, []);
|
|
87
|
-
return (_jsx(Suspense, { fallback: null, children: _jsx("group", { ref: groupRef, position: position,
|
|
88
|
-
// onClick={(e) => clickerPoint(e, activeState.position.clone())}
|
|
89
|
-
onPointerDown: function (e) { return moveClicker(e, false); }, onDoubleClick: function (e) { return moveClicker(e, true); }, children: children }) }));
|
|
45
|
+
return (_jsx(Suspense, { fallback: null, children: _jsx("group", { ref: groupRef, position: position, onPointerDown: function (e) { return moveClicker(e, false, type); }, onDoubleClick: function (e) { return moveClicker(e, true, type); }, children: children }) }));
|
|
90
46
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import _ from "lodash";
|
|
1
2
|
import { useContext, useEffect } from "react";
|
|
2
3
|
import { V3 } from "../../utils";
|
|
3
4
|
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
|
|
4
5
|
export default function useClicker() {
|
|
5
6
|
var _a = useContext(GaesupWorldContext), activeState = _a.activeState, clicker = _a.clicker, mode = _a.mode;
|
|
6
7
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
7
|
-
var moveClicker = function (e, isRun) {
|
|
8
|
-
if (mode.controller !== "clicker")
|
|
8
|
+
var moveClicker = function (e, isRun, type) {
|
|
9
|
+
if (mode.controller !== "clicker" || type !== "ground")
|
|
9
10
|
return;
|
|
10
11
|
var originPoint = activeState.position;
|
|
11
12
|
var newPosition = e.point;
|
|
@@ -14,18 +15,33 @@ export default function useClicker() {
|
|
|
14
15
|
Math.pow(newPosition.x - originPoint.x, 2));
|
|
15
16
|
if (norm < 1)
|
|
16
17
|
return;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
var dispatcher = _.debounce(function () {
|
|
19
|
+
dispatch({
|
|
20
|
+
type: "update",
|
|
21
|
+
payload: {
|
|
22
|
+
clicker: {
|
|
23
|
+
point: V3(e.point.x, e.point.y, e.point.z),
|
|
24
|
+
angle: newAngle,
|
|
25
|
+
isOn: true,
|
|
26
|
+
isRun: isRun,
|
|
27
|
+
},
|
|
25
28
|
},
|
|
26
|
-
}
|
|
27
|
-
});
|
|
29
|
+
});
|
|
30
|
+
}, 100);
|
|
31
|
+
dispatcher();
|
|
32
|
+
// dispatch({
|
|
33
|
+
// type: "update",
|
|
34
|
+
// payload: {
|
|
35
|
+
// clicker: {
|
|
36
|
+
// point: V3(e.point.x, e.point.y, e.point.z),
|
|
37
|
+
// angle: newAngle,
|
|
38
|
+
// isOn: true,
|
|
39
|
+
// isRun: isRun,
|
|
40
|
+
// },
|
|
41
|
+
// },
|
|
42
|
+
// });
|
|
28
43
|
};
|
|
44
|
+
// const moveClicker = _.throttle(moveClick, 100);
|
|
29
45
|
// 거리 계산
|
|
30
46
|
useEffect(function () {
|
|
31
47
|
if (mode.controller !== "clicker")
|
|
@@ -36,7 +36,7 @@ export function normalDirection(_a) {
|
|
|
36
36
|
}
|
|
37
37
|
else if (mode.controller === "clicker") {
|
|
38
38
|
activeState.euler.y = Math.PI / 2 - clicker.angle;
|
|
39
|
-
activeState.dir.set(-Math.sin(activeState.euler.y),
|
|
39
|
+
activeState.dir.set(-Math.sin(activeState.euler.y), 1, -Math.cos(activeState.euler.y));
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
42
|
// 일반 컨트롤
|
|
@@ -32,7 +32,7 @@ export default function calculation(prop) {
|
|
|
32
32
|
if (rigidBodyRef.current && innerGroupRef.current) {
|
|
33
33
|
rigidBodyRef.current.lockRotations(false, true);
|
|
34
34
|
activeState.euler.set(0, 0, 0);
|
|
35
|
-
rigidBodyRef.current.setTranslation(activeState.position.clone().add(V3(0,
|
|
35
|
+
rigidBodyRef.current.setTranslation(activeState.position.clone().add(V3(0, 5, 0)), true);
|
|
36
36
|
}
|
|
37
37
|
}, [mode.type]);
|
|
38
38
|
useFrame(function (state, delta) {
|
|
@@ -14,7 +14,7 @@ export default function GamePadButton(_a) {
|
|
|
14
14
|
pushKey(value, false);
|
|
15
15
|
setIsClicked(false);
|
|
16
16
|
};
|
|
17
|
-
return (_jsx("
|
|
17
|
+
return (_jsx("button", { className: "padButton ".concat(isClicked ? "isClicked" : ""), onMouseDown: function () { return onMouseDown(); }, onMouseUp: function () { return onMouseLeave(); }, onMouseLeave: function () { return onMouseLeave(); }, onContextMenu: function (e) {
|
|
18
18
|
e.preventDefault();
|
|
19
19
|
onMouseLeave();
|
|
20
20
|
}, onPointerDown: function () { return onMouseDown(); }, onPointerUp: function () { return onMouseLeave(); }, style: gamePadButtonStyle, children: name }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gaesup-world",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@types/three": "^0.161.2",
|
|
26
26
|
"gh-pages": "^6.1.1",
|
|
27
27
|
"leva": "0.9.35",
|
|
28
|
+
"lodash": "^4.17.21",
|
|
28
29
|
"node-fetch": "3.3.2",
|
|
29
30
|
"react": "^18.2.0",
|
|
30
31
|
"react-device-detect": "^2.2.3",
|