gaesup-world 0.2.52 → 0.3.1
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/animation/actions.d.ts +5 -0
- package/dist/gaesup/animation/actions.js +10 -0
- package/dist/gaesup/camera/control/normal.js +2 -1
- package/dist/gaesup/camera/index.js +21 -39
- package/dist/gaesup/component/inner/character/index.js +1 -1
- package/dist/gaesup/component/passive/character/index.d.ts +1 -0
- package/dist/gaesup/component/passive/character/index.js +2 -13
- package/dist/gaesup/gaesupProps/index.js +51 -7
- package/dist/gaesup/hooks/useClicker/index.d.ts +4 -0
- package/dist/gaesup/hooks/useClicker/index.js +50 -0
- package/dist/gaesup/hooks/useFocus/index.d.ts +7 -0
- package/dist/gaesup/hooks/useFocus/index.js +32 -0
- package/dist/gaesup/hooks/useZoom/index.d.ts +3 -0
- package/dist/gaesup/hooks/useZoom/index.js +18 -0
- package/dist/gaesup/physics/character/direction.d.ts +5 -6
- package/dist/gaesup/physics/character/direction.js +14 -7
- package/dist/gaesup/physics/check/moving.js +7 -1
- package/dist/gaesup/tools/clicker/index.d.ts +5 -0
- package/dist/gaesup/tools/clicker/index.js +8 -0
- package/dist/gaesup/utils/debug.d.ts +1 -1
- package/dist/gaesup/utils/innerHtml.d.ts +4 -0
- package/dist/gaesup/utils/innerHtml.js +41 -0
- package/dist/gaesup/world/context/index.js +9 -0
- package/dist/gaesup/world/context/reducer.d.ts +1 -0
- package/dist/gaesup/world/context/type.d.ts +11 -1
- package/dist/gaesup/world/initalize/index.d.ts +1 -0
- package/dist/gaesup/world/initalize/index.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +1 -1
|
@@ -42,3 +42,8 @@ export default function playActions({ type, animationResult, currentAnimation, }
|
|
|
42
42
|
animationRef: import("react").MutableRefObject<Object3D<Object3DEventMap>>;
|
|
43
43
|
currentAnimation: string;
|
|
44
44
|
};
|
|
45
|
+
export declare const setAnimation: ({ currentAnimation, actions, type, }: {
|
|
46
|
+
currentAnimation?: string;
|
|
47
|
+
actions?: actionsType;
|
|
48
|
+
type?: "character" | "vehicle" | "airplane";
|
|
49
|
+
}) => void;
|
|
@@ -101,3 +101,13 @@ export default function playActions(_a) {
|
|
|
101
101
|
currentAnimation: (_b = animationState === null || animationState === void 0 ? void 0 : animationState[type]) === null || _b === void 0 ? void 0 : _b.current,
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
+
export var setAnimation = function (_a) {
|
|
105
|
+
var currentAnimation = _a.currentAnimation, actions = _a.actions, type = _a.type;
|
|
106
|
+
useEffect(function () {
|
|
107
|
+
var _a;
|
|
108
|
+
var action = (_a = actions[currentAnimation]) === null || _a === void 0 ? void 0 : _a.reset().fadeIn(0.2).play();
|
|
109
|
+
return function () {
|
|
110
|
+
action === null || action === void 0 ? void 0 : action.fadeOut(0.2);
|
|
111
|
+
};
|
|
112
|
+
}, [currentAnimation, type]);
|
|
113
|
+
};
|
|
@@ -14,5 +14,6 @@ export default function normal(prop) {
|
|
|
14
14
|
.clone()
|
|
15
15
|
.add(V3(0, cameraOption.YDistance, cameraOption.ZDistance));
|
|
16
16
|
state.camera.position.lerp(cameraPosition, 1);
|
|
17
|
-
|
|
17
|
+
if (!cameraOption.target)
|
|
18
|
+
state.camera.lookAt(activeState.position.clone());
|
|
18
19
|
}
|
|
@@ -23,9 +23,9 @@ export default function Camera(_a) {
|
|
|
23
23
|
var refs = _a.refs, prop = _a.prop, control = _a.control;
|
|
24
24
|
var worldContext = useContext(GaesupWorldContext);
|
|
25
25
|
var controllerContext = useContext(GaesupControllerContext);
|
|
26
|
-
var mode = worldContext.mode, cameraOption = worldContext.cameraOption;
|
|
26
|
+
var mode = worldContext.mode, cameraOption = worldContext.cameraOption, activeState = worldContext.activeState;
|
|
27
27
|
var rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef;
|
|
28
|
-
var
|
|
28
|
+
var camera = useThree().camera;
|
|
29
29
|
var cameraRef = useRef();
|
|
30
30
|
var intersectObjectMap = useMemo(function () { return ({}); }, []);
|
|
31
31
|
var cameraProp = __assign(__assign({}, prop), { control: control, controllerContext: controllerContext, worldContext: worldContext, intersectObjectMap: intersectObjectMap });
|
|
@@ -70,42 +70,24 @@ export default function Camera(_a) {
|
|
|
70
70
|
// detector(cameraProp);
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// ),
|
|
93
|
-
// ]);
|
|
94
|
-
// } else if (mode.control === "normal") {
|
|
95
|
-
// await Promise.all([
|
|
96
|
-
// cameraRef.current.setPosition(0, position.y, position.z, true),
|
|
97
|
-
// camera.rotation.copy(worldContext.activeState.euler),
|
|
98
|
-
// cameraRef.current.setLookAt(
|
|
99
|
-
// 0,
|
|
100
|
-
// position.y,
|
|
101
|
-
// position.z,
|
|
102
|
-
// target.x,
|
|
103
|
-
// target.y,
|
|
104
|
-
// target.z,
|
|
105
|
-
// true
|
|
106
|
-
// ),
|
|
107
|
-
// ]);
|
|
108
|
-
// }
|
|
109
|
-
// };
|
|
73
|
+
// zoom
|
|
74
|
+
useEffect(function () {
|
|
75
|
+
if (cameraRef.current) {
|
|
76
|
+
cameraRef.current.zoomTo(worldContext.cameraOption.zoom, true);
|
|
77
|
+
}
|
|
78
|
+
}, [worldContext.cameraOption.zoom]);
|
|
79
|
+
// lookat
|
|
80
|
+
useEffect(function () {
|
|
81
|
+
if (cameraRef.current) {
|
|
82
|
+
var currentCamera = camera.position.clone();
|
|
83
|
+
if (cameraOption.focus) {
|
|
84
|
+
cameraRef.current.setLookAt(currentCamera.x, currentCamera.y, currentCamera.z, cameraOption.target.x, cameraOption.target.y, cameraOption.target.z, true);
|
|
85
|
+
// 포커스 품
|
|
86
|
+
}
|
|
87
|
+
else if (!cameraOption.focus) {
|
|
88
|
+
cameraRef.current.setLookAt(currentCamera.x, currentCamera.y, currentCamera.z, activeState.position.x, activeState.position.y, activeState.position.z, true);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, [cameraOption.focus]);
|
|
110
92
|
return _jsx(CameraControls, { ref: cameraRef });
|
|
111
93
|
}
|
|
@@ -24,5 +24,5 @@ export function CharacterInnerRef(_a) {
|
|
|
24
24
|
var outerGroupRef = refs.outerGroupRef, rigidBodyRef = refs.rigidBodyRef, colliderRef = refs.colliderRef, innerGroupRef = refs.innerGroupRef;
|
|
25
25
|
var size = useGltfAndSize({ url: urls.characterUrl }).size;
|
|
26
26
|
var collider = calcCharacterColliderProps(size);
|
|
27
|
-
return (_jsx(_Fragment, { children: collider && (
|
|
27
|
+
return (_jsx(_Fragment, { children: collider && (_jsx(OuterGroupRef, { ref: outerGroupRef, 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, children: children })] }) })) }));
|
|
28
28
|
}
|
|
@@ -5,6 +5,7 @@ export type passiveCharacterPropsType = {
|
|
|
5
5
|
euler: THREE.Euler;
|
|
6
6
|
urls: urlsType;
|
|
7
7
|
currentAnimation: string;
|
|
8
|
+
gravityScale?: number;
|
|
8
9
|
children?: React.ReactNode;
|
|
9
10
|
};
|
|
10
11
|
export declare function PassiveCharacter(props: passiveCharacterPropsType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useAnimations } from "@react-three/drei";
|
|
3
2
|
import { useFrame } from "@react-three/fiber";
|
|
4
3
|
import { quat } from "@react-three/rapier";
|
|
5
4
|
import { useEffect, useMemo, useRef } from "react";
|
|
6
|
-
import playActions from "../../../animation/actions";
|
|
7
|
-
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
8
5
|
import { CharacterInnerRef } from "../../inner/character";
|
|
9
6
|
export function PassiveCharacter(props) {
|
|
10
7
|
var rigidBodyRef = useRef(null);
|
|
@@ -21,10 +18,9 @@ export function PassiveCharacter(props) {
|
|
|
21
18
|
return {
|
|
22
19
|
position: props.position,
|
|
23
20
|
euler: props.euler,
|
|
24
|
-
currentAnimation: props.currentAnimation,
|
|
25
21
|
characterUrl: props.urls.characterUrl,
|
|
26
22
|
};
|
|
27
|
-
}, [props]), position = _a.position, euler = _a.euler
|
|
23
|
+
}, [props]), position = _a.position, euler = _a.euler;
|
|
28
24
|
useEffect(function () {
|
|
29
25
|
if (rigidBodyRef || rigidBodyRef.current) {
|
|
30
26
|
rigidBodyRef.current.setEnabledRotations(false, false, false, false);
|
|
@@ -35,12 +31,5 @@ export function PassiveCharacter(props) {
|
|
|
35
31
|
innerGroupRef.current.quaternion.rotateTowards(quat().setFromEuler(euler), 10 * delta);
|
|
36
32
|
}
|
|
37
33
|
});
|
|
38
|
-
|
|
39
|
-
var animationResult = useAnimations(gltf.animations);
|
|
40
|
-
var animationRef = playActions({
|
|
41
|
-
type: "character",
|
|
42
|
-
animationResult: animationResult,
|
|
43
|
-
currentAnimation: currentAnimation,
|
|
44
|
-
}).animationRef;
|
|
45
|
-
return (_jsx(CharacterInnerRef, { animationRef: animationRef, position: position, refs: refs, urls: props.urls, children: props.children }));
|
|
34
|
+
return (_jsx(CharacterInnerRef, { position: position, refs: refs, urls: props.urls, currentAnimation: props.currentAnimation, children: props.children }));
|
|
46
35
|
}
|
|
@@ -11,17 +11,59 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { vec3 } from "@react-three/rapier";
|
|
14
|
-
import { Suspense, useContext, useEffect,
|
|
14
|
+
import { Suspense, useContext, useEffect, useRef } from "react";
|
|
15
15
|
import * as THREE from "three";
|
|
16
|
-
import
|
|
16
|
+
import useClicker from "../hooks/useClicker";
|
|
17
|
+
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context";
|
|
17
18
|
export function GaeSupProps(_a) {
|
|
18
19
|
var _b = _a.type, type = _b === void 0 ? "normal" : _b, text = _a.text, position = _a.position, children = _a.children;
|
|
19
20
|
var groupRef = useRef(null);
|
|
20
|
-
var
|
|
21
|
+
var _c = useContext(GaesupWorldContext), minimap = _c.minimap, activeState = _c.activeState, clicker = _c.clicker;
|
|
21
22
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
// clicker
|
|
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]);
|
|
25
67
|
useEffect(function () {
|
|
26
68
|
if (groupRef.current) {
|
|
27
69
|
var box = new THREE.Box3().setFromObject(groupRef.current);
|
|
@@ -42,5 +84,7 @@ export function GaeSupProps(_a) {
|
|
|
42
84
|
});
|
|
43
85
|
}
|
|
44
86
|
}, []);
|
|
45
|
-
return _jsx(Suspense, { fallback: null, children:
|
|
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 }) }));
|
|
46
90
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useContext, useEffect } from "react";
|
|
2
|
+
import { V3 } from "../../utils";
|
|
3
|
+
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
|
|
4
|
+
export default function useClicker() {
|
|
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) {
|
|
8
|
+
if (mode.controller !== "clicker")
|
|
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 < 1)
|
|
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
|
+
if (mode.controller !== "clicker")
|
|
32
|
+
return;
|
|
33
|
+
var originPoint = activeState.position;
|
|
34
|
+
var newPosition = clicker.point;
|
|
35
|
+
var norm = Math.sqrt(Math.pow(newPosition.z - originPoint.z, 2) +
|
|
36
|
+
Math.pow(newPosition.x - originPoint.x, 2));
|
|
37
|
+
if (norm < 1) {
|
|
38
|
+
clicker.isOn = false;
|
|
39
|
+
dispatch({
|
|
40
|
+
type: "update",
|
|
41
|
+
payload: {
|
|
42
|
+
clicker: clicker,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}, [activeState.position, clicker.point]);
|
|
47
|
+
return {
|
|
48
|
+
moveClicker: moveClicker,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
|
|
3
|
+
export function useFocus() {
|
|
4
|
+
var cameraOption = useContext(GaesupWorldContext).cameraOption;
|
|
5
|
+
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
6
|
+
var open = function (_a) {
|
|
7
|
+
var zoom = _a.zoom, target = _a.target;
|
|
8
|
+
if (zoom)
|
|
9
|
+
cameraOption.zoom = zoom;
|
|
10
|
+
cameraOption.target = target;
|
|
11
|
+
cameraOption.focus = true;
|
|
12
|
+
dispatch({
|
|
13
|
+
type: "update",
|
|
14
|
+
payload: {
|
|
15
|
+
cameraOption: cameraOption,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
var close = function () {
|
|
20
|
+
cameraOption.focus = false;
|
|
21
|
+
dispatch({
|
|
22
|
+
type: "update",
|
|
23
|
+
payload: {
|
|
24
|
+
cameraOption: cameraOption,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
open: open,
|
|
30
|
+
close: close,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
|
|
3
|
+
export function useZoom() {
|
|
4
|
+
var cameraOption = useContext(GaesupWorldContext).cameraOption;
|
|
5
|
+
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
6
|
+
var zoom = function (zoom) {
|
|
7
|
+
cameraOption.zoom = zoom;
|
|
8
|
+
dispatch({
|
|
9
|
+
type: "update",
|
|
10
|
+
payload: {
|
|
11
|
+
cameraOption: cameraOption,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
zoom: zoom,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { RootState } from "@react-three/fiber";
|
|
2
1
|
import { joyStickInnerType } from "../../tools/joyStick/type";
|
|
3
|
-
import { activeStateType, modeType } from "../../world/context/type";
|
|
2
|
+
import { activeStateType, clickerType, modeType } from "../../world/context/type";
|
|
4
3
|
import { calcPropType } from "../type";
|
|
5
|
-
export declare function orbitDirection({ activeState, control, mode, joystick,
|
|
6
|
-
state: RootState;
|
|
4
|
+
export declare function orbitDirection({ activeState, control, mode, joystick, clicker, }: {
|
|
7
5
|
activeState: activeStateType;
|
|
8
6
|
mode: modeType;
|
|
9
7
|
joystick: joyStickInnerType;
|
|
8
|
+
clicker: clickerType;
|
|
10
9
|
control: {
|
|
11
10
|
[key: string]: boolean;
|
|
12
11
|
};
|
|
13
12
|
}): void;
|
|
14
|
-
export declare function normalDirection({ activeState, control, mode, joystick,
|
|
15
|
-
state: RootState;
|
|
13
|
+
export declare function normalDirection({ activeState, control, mode, joystick, clicker, }: {
|
|
16
14
|
activeState: activeStateType;
|
|
17
15
|
mode: modeType;
|
|
18
16
|
joystick: joyStickInnerType;
|
|
17
|
+
clicker: clickerType;
|
|
19
18
|
control: {
|
|
20
19
|
[key: string]: boolean;
|
|
21
20
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { V3, calcAngleByVector } from "../../utils/vector";
|
|
2
2
|
export function orbitDirection(_a) {
|
|
3
|
-
var activeState = _a.activeState, control = _a.control, mode = _a.mode, joystick = _a.joystick,
|
|
3
|
+
var activeState = _a.activeState, control = _a.control, mode = _a.mode, joystick = _a.joystick, clicker = _a.clicker;
|
|
4
4
|
var forward = control.forward, backward = control.backward, leftward = control.leftward, rightward = control.rightward;
|
|
5
5
|
var dirX = Number(leftward) - Number(rightward);
|
|
6
6
|
var dirZ = Number(forward) - Number(backward);
|
|
@@ -11,6 +11,10 @@ export function orbitDirection(_a) {
|
|
|
11
11
|
activeState.euler.y = Math.PI / 2 - joystick.joyStickOrigin.angle;
|
|
12
12
|
start = 1;
|
|
13
13
|
}
|
|
14
|
+
else if (mode.controller === "clicker") {
|
|
15
|
+
activeState.euler.y = Math.PI / 2 - clicker.angle;
|
|
16
|
+
start = 1;
|
|
17
|
+
}
|
|
14
18
|
else {
|
|
15
19
|
if (dirX === 0 && dirZ === 0)
|
|
16
20
|
return;
|
|
@@ -22,14 +26,17 @@ export function orbitDirection(_a) {
|
|
|
22
26
|
activeState.dir = activeState.direction.normalize();
|
|
23
27
|
}
|
|
24
28
|
export function normalDirection(_a) {
|
|
25
|
-
var activeState = _a.activeState, control = _a.control, mode = _a.mode, joystick = _a.joystick,
|
|
29
|
+
var activeState = _a.activeState, control = _a.control, mode = _a.mode, joystick = _a.joystick, clicker = _a.clicker;
|
|
26
30
|
var forward = control.forward, backward = control.backward, leftward = control.leftward, rightward = control.rightward;
|
|
27
|
-
var start = 0;
|
|
28
31
|
if (mode.controller === "joystick") {
|
|
29
32
|
if (joystick.joyStickOrigin.isCenter)
|
|
30
33
|
return;
|
|
31
34
|
activeState.euler.y = Math.PI / 2 - joystick.joyStickOrigin.angle;
|
|
32
|
-
|
|
35
|
+
activeState.dir.set(-Math.sin(activeState.euler.y), 0, -Math.cos(activeState.euler.y));
|
|
36
|
+
}
|
|
37
|
+
else if (mode.controller === "clicker") {
|
|
38
|
+
activeState.euler.y = Math.PI / 2 - clicker.angle;
|
|
39
|
+
activeState.dir.set(-Math.sin(activeState.euler.y), 0, -Math.cos(activeState.euler.y));
|
|
33
40
|
}
|
|
34
41
|
else {
|
|
35
42
|
// 일반 컨트롤
|
|
@@ -45,11 +52,11 @@ export function normalDirection(_a) {
|
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
54
|
export default function direction(prop) {
|
|
48
|
-
var state = prop.state, _a = prop.worldContext, joystick = _a.joystick, mode = _a.mode, activeState = _a.activeState, control = _a.control;
|
|
55
|
+
var state = prop.state, _a = prop.worldContext, joystick = _a.joystick, mode = _a.mode, activeState = _a.activeState, control = _a.control, clicker = _a.clicker;
|
|
49
56
|
if (mode.control === "normal") {
|
|
50
|
-
normalDirection({ activeState: activeState, control: control, mode: mode, joystick: joystick,
|
|
57
|
+
normalDirection({ activeState: activeState, control: control, mode: mode, joystick: joystick, clicker: clicker });
|
|
51
58
|
}
|
|
52
59
|
else if (mode.control === "orbit") {
|
|
53
|
-
orbitDirection({ activeState: activeState, control: control, mode: mode, joystick: joystick,
|
|
60
|
+
orbitDirection({ activeState: activeState, control: control, mode: mode, joystick: joystick, clicker: clicker });
|
|
54
61
|
}
|
|
55
62
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default function moving(prop) {
|
|
2
|
-
var _a = prop.worldContext, states = _a.states, joystick = _a.joystick, mode = _a.mode, control = _a.control;
|
|
2
|
+
var _a = prop.worldContext, states = _a.states, joystick = _a.joystick, mode = _a.mode, control = _a.control, clicker = _a.clicker;
|
|
3
3
|
var forward = control.forward, backward = control.backward, leftward = control.leftward, rightward = control.rightward, shift = control.shift, space = control.space;
|
|
4
4
|
if (mode.controller === "gameboy" || mode.controller === "keyboard") {
|
|
5
5
|
states.isMoving = forward || backward || leftward || rightward;
|
|
@@ -13,4 +13,10 @@ export default function moving(prop) {
|
|
|
13
13
|
states.isRunning = shift && states.isMoving;
|
|
14
14
|
states.isJumping = space;
|
|
15
15
|
}
|
|
16
|
+
else if (mode.controller === "clicker") {
|
|
17
|
+
states.isMoving = clicker.isOn;
|
|
18
|
+
states.isNotMoving = !clicker.isOn;
|
|
19
|
+
states.isRunning = (shift || clicker.isRun) && states.isMoving;
|
|
20
|
+
states.isJumping = space;
|
|
21
|
+
}
|
|
16
22
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsxs as _jsxs, Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
4
|
+
export function Clicker(_a) {
|
|
5
|
+
var onMarker = _a.onMarker, runMarker = _a.runMarker;
|
|
6
|
+
var _b = useContext(GaesupWorldContext), clicker = _b.clicker, mode = _b.mode;
|
|
7
|
+
return (_jsx(_Fragment, { children: mode.controller === "clicker" && (_jsxs("group", { position: clicker.point, children: [clicker.isOn && onMarker, clicker.isOn && clicker.isRun && runMarker] })) }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import { Html } from "@react-three/drei";
|
|
25
|
+
import { useFrame } from "@react-three/fiber";
|
|
26
|
+
import { useRef, useState } from "react";
|
|
27
|
+
import * as THREE from "three";
|
|
28
|
+
export function InnerHtml(_a) {
|
|
29
|
+
var children = _a.children, props = __rest(_a, ["children"]);
|
|
30
|
+
var ref = useRef();
|
|
31
|
+
var _b = useState(), isOccluded = _b[0], setOccluded = _b[1];
|
|
32
|
+
var _c = useState(), isInRange = _c[0], setInRange = _c[1];
|
|
33
|
+
var isVisible = isInRange && !isOccluded;
|
|
34
|
+
var vec = new THREE.Vector3();
|
|
35
|
+
useFrame(function (state) {
|
|
36
|
+
var range = state.camera.position.distanceTo(ref.current.getWorldPosition(vec)) <= 10;
|
|
37
|
+
if (range !== isInRange)
|
|
38
|
+
setInRange(range);
|
|
39
|
+
});
|
|
40
|
+
return (_jsx("group", { ref: ref, children: _jsx(Html, __assign({ transform: true, occlude: true }, props, { children: children })) }));
|
|
41
|
+
}
|
|
@@ -43,6 +43,12 @@ export var gaesupWorldDefault = {
|
|
|
43
43
|
minimap: {
|
|
44
44
|
props: {},
|
|
45
45
|
},
|
|
46
|
+
clicker: {
|
|
47
|
+
point: V3(0, 0, 0),
|
|
48
|
+
angle: Math.PI / 2,
|
|
49
|
+
isOn: false,
|
|
50
|
+
isRun: false,
|
|
51
|
+
},
|
|
46
52
|
joystick: {
|
|
47
53
|
joyStickOrigin: {
|
|
48
54
|
x: 0,
|
|
@@ -100,6 +106,9 @@ export var gaesupWorldDefault = {
|
|
|
100
106
|
XDistance: 20,
|
|
101
107
|
YDistance: 10,
|
|
102
108
|
ZDistance: 20,
|
|
109
|
+
zoom: 1,
|
|
110
|
+
target: null,
|
|
111
|
+
focus: false,
|
|
103
112
|
},
|
|
104
113
|
moveTo: null,
|
|
105
114
|
rideable: {},
|
|
@@ -17,6 +17,7 @@ export declare function gaesupWorldReducer(props: gaesupWorldContextType, action
|
|
|
17
17
|
animationState: import("./type").animationStateType;
|
|
18
18
|
keyBoardMap: import("../../tools/keyBoardToolTip/type").keyboardMapType;
|
|
19
19
|
cameraOption: import("./type").cameraOptionType;
|
|
20
|
+
clicker: import("./type").clickerType;
|
|
20
21
|
moveTo: (position: import("three").Vector3, target: import("three").Vector3) => Promise<void>;
|
|
21
22
|
rideable: {
|
|
22
23
|
[key: string]: import("./type").rideableType;
|
|
@@ -10,6 +10,9 @@ export type gaesupCameraOptionDebugType = {
|
|
|
10
10
|
XDistance?: number;
|
|
11
11
|
YDistance?: number;
|
|
12
12
|
ZDistance?: number;
|
|
13
|
+
zoom?: number;
|
|
14
|
+
target?: THREE.Vector3;
|
|
15
|
+
focus?: boolean;
|
|
13
16
|
};
|
|
14
17
|
export type cameraOptionType = {
|
|
15
18
|
offset?: THREE.Vector3;
|
|
@@ -77,7 +80,7 @@ export type animationStatePropType = {
|
|
|
77
80
|
};
|
|
78
81
|
export type modeType = {
|
|
79
82
|
type?: "character" | "vehicle" | "airplane";
|
|
80
|
-
controller?: "gameboy" | "keyboard" | "joystick";
|
|
83
|
+
controller?: "gameboy" | "keyboard" | "joystick" | "clicker";
|
|
81
84
|
control?: "normal" | "orbit";
|
|
82
85
|
};
|
|
83
86
|
export type activeStateType = {
|
|
@@ -91,6 +94,12 @@ export type activeStateType = {
|
|
|
91
94
|
direction: THREE.Vector3;
|
|
92
95
|
dir: THREE.Vector3;
|
|
93
96
|
};
|
|
97
|
+
export type clickerType = {
|
|
98
|
+
point: THREE.Vector3;
|
|
99
|
+
angle: number;
|
|
100
|
+
isOn: boolean;
|
|
101
|
+
isRun: boolean;
|
|
102
|
+
};
|
|
94
103
|
export type wheelStateType = {
|
|
95
104
|
position: THREE.Vector3;
|
|
96
105
|
rotation: THREE.Euler;
|
|
@@ -155,6 +164,7 @@ export type gaesupWorldContextType = {
|
|
|
155
164
|
animationState: animationStateType;
|
|
156
165
|
keyBoardMap: keyboardMapType;
|
|
157
166
|
cameraOption: cameraOptionType;
|
|
167
|
+
clicker: clickerType;
|
|
158
168
|
moveTo: (position: THREE.Vector3, target: THREE.Vector3) => Promise<void>;
|
|
159
169
|
rideable: {
|
|
160
170
|
[key: string]: rideableType;
|
|
@@ -17,6 +17,7 @@ export default function initGaesupWorld(props: gaesupWorldPropsType): {
|
|
|
17
17
|
animationState: import("../context/type").animationStateType;
|
|
18
18
|
keyBoardMap: import("../../tools/keyBoardToolTip/type").keyboardMapType;
|
|
19
19
|
cameraOption: import("../context/type").cameraOptionType;
|
|
20
|
+
clicker: import("../context/type").clickerType;
|
|
20
21
|
moveTo: (position: import("three").Vector3, target: import("three").Vector3) => Promise<void>;
|
|
21
22
|
rideable: {
|
|
22
23
|
[key: string]: import("../context/type").rideableType;
|
|
@@ -26,6 +26,7 @@ export default function initGaesupWorld(props) {
|
|
|
26
26
|
minimap: gaesupWorldDefault.minimap,
|
|
27
27
|
joystick: gaesupWorldDefault.joystick,
|
|
28
28
|
control: gaesupWorldDefault.control,
|
|
29
|
+
clicker: gaesupWorldDefault.clicker,
|
|
29
30
|
animationState: gaesupWorldDefault.animationState,
|
|
30
31
|
keyBoardMap: Object.assign(gaesupWorldDefault.keyBoardMap, props.keyBoardMap || {}),
|
|
31
32
|
moveTo: null,
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { PassiveCharacter } from "./gaesup/component/passive/character";
|
|
|
5
5
|
export { PassiveVehicle } from "./gaesup/component/passive/vehicle";
|
|
6
6
|
export { GaesupController } from "./gaesup/controller";
|
|
7
7
|
export { GaeSupProps } from "./gaesup/gaesupProps";
|
|
8
|
+
export { Clicker } from "./gaesup/tools/clicker";
|
|
8
9
|
export { GameBoy } from "./gaesup/tools/gameBoy";
|
|
9
10
|
export { GamePad } from "./gaesup/tools/gamePad";
|
|
10
11
|
export { JoyStick } from "./gaesup/tools/joyStick";
|
|
@@ -13,11 +14,14 @@ export { KeyBoardToolTip } from "./gaesup/tools/keyBoardToolTip";
|
|
|
13
14
|
export { MiniMap } from "./gaesup/tools/miniMap";
|
|
14
15
|
export { Rideable } from "./gaesup/tools/rideable";
|
|
15
16
|
export { ZoomButton } from "./gaesup/tools/zoomButton";
|
|
17
|
+
export { InnerHtml } from "./gaesup/utils/innerHtml";
|
|
16
18
|
export { Elr, Qt, V3, V30, V31 } from "./gaesup/utils/vector";
|
|
17
19
|
export { GaesupWorld } from "./gaesup/world";
|
|
20
|
+
export { useFocus } from "./gaesup/hooks/useFocus";
|
|
18
21
|
export { useGaesupAnimation } from "./gaesup/hooks/useGaesupAnimation";
|
|
19
22
|
export { useGaesupController } from "./gaesup/hooks/useGaesupController";
|
|
20
23
|
export * as useJoyStick from "./gaesup/hooks/useJoyStick";
|
|
21
24
|
export { usePushKey } from "./gaesup/hooks/usePushKey";
|
|
22
25
|
export { useRideable } from "./gaesup/hooks/useRideable";
|
|
23
26
|
export { useTeleport } from "./gaesup/hooks/useTeleport";
|
|
27
|
+
export { useZoom } from "./gaesup/hooks/useZoom";
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { PassiveCharacter } from "./gaesup/component/passive/character";
|
|
|
5
5
|
export { PassiveVehicle } from "./gaesup/component/passive/vehicle";
|
|
6
6
|
export { GaesupController } from "./gaesup/controller";
|
|
7
7
|
export { GaeSupProps } from "./gaesup/gaesupProps";
|
|
8
|
+
export { Clicker } from "./gaesup/tools/clicker";
|
|
8
9
|
export { GameBoy } from "./gaesup/tools/gameBoy";
|
|
9
10
|
export { GamePad } from "./gaesup/tools/gamePad";
|
|
10
11
|
export { JoyStick } from "./gaesup/tools/joyStick";
|
|
@@ -13,11 +14,14 @@ export { KeyBoardToolTip } from "./gaesup/tools/keyBoardToolTip";
|
|
|
13
14
|
export { MiniMap } from "./gaesup/tools/miniMap";
|
|
14
15
|
export { Rideable } from "./gaesup/tools/rideable";
|
|
15
16
|
export { ZoomButton } from "./gaesup/tools/zoomButton";
|
|
17
|
+
export { InnerHtml } from "./gaesup/utils/innerHtml";
|
|
16
18
|
export { Elr, Qt, V3, V30, V31 } from "./gaesup/utils/vector";
|
|
17
19
|
export { GaesupWorld } from "./gaesup/world";
|
|
20
|
+
export { useFocus } from "./gaesup/hooks/useFocus";
|
|
18
21
|
export { useGaesupAnimation } from "./gaesup/hooks/useGaesupAnimation";
|
|
19
22
|
export { useGaesupController } from "./gaesup/hooks/useGaesupController";
|
|
20
23
|
export * as useJoyStick from "./gaesup/hooks/useJoyStick";
|
|
21
24
|
export { usePushKey } from "./gaesup/hooks/usePushKey";
|
|
22
25
|
export { useRideable } from "./gaesup/hooks/useRideable";
|
|
23
26
|
export { useTeleport } from "./gaesup/hooks/useTeleport";
|
|
27
|
+
export { useZoom } from "./gaesup/hooks/useZoom";
|