gaesup-world 0.0.2 → 0.0.3
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/package.json +1 -1
- package/src/gaesup/animation/actions.ts +1 -1
- package/src/gaesup/camera/control/normal.ts +1 -1
- package/src/gaesup/camera/control/orbit.ts +1 -1
- package/src/gaesup/camera/index.tsx +3 -3
- package/src/gaesup/component/gltf/AirplaneGltf.tsx +1 -1
- package/src/gaesup/component/gltf/CharacterGltf.tsx +1 -1
- package/src/gaesup/component/gltf/VehicleGltf.tsx +1 -1
- package/src/gaesup/component/gltf/WheelJoint.tsx +1 -1
- package/src/gaesup/component/ref/airplane.tsx +1 -1
- package/src/gaesup/component/ref/character.tsx +1 -1
- package/src/gaesup/component/ref/vehicle.tsx +1 -1
- package/src/gaesup/component/setInit.ts +2 -2
- package/src/gaesup/{stores/context/controller → controller/context}/index.ts +3 -2
- package/src/gaesup/{stores/context/controller → controller/context}/type.ts +22 -2
- package/src/gaesup/controller/index.tsx +4 -3
- package/src/gaesup/controller/type.ts +3 -5
- package/src/gaesup/gaesupProps/index.tsx +1 -1
- package/src/gaesup/initial/callback/index.ts +1 -1
- package/src/gaesup/initial/callback/type.ts +6 -4
- package/src/gaesup/initial/controller/index.ts +3 -2
- package/src/gaesup/initial/gaesupWorld/collider/index.ts +1 -1
- package/src/gaesup/initial/gaesupWorld/index.ts +33 -33
- package/src/gaesup/initial/gaesupWorld/type.ts +11 -14
- package/src/gaesup/physics/airplane/direction.ts +0 -2
- package/src/gaesup/physics/airplane/turn.ts +0 -1
- package/src/gaesup/physics/character/direction.ts +12 -11
- package/src/gaesup/physics/index.ts +5 -4
- package/src/gaesup/physics/type.ts +3 -6
- package/src/gaesup/tools/context.ts +6 -0
- package/src/gaesup/tools/gameboy/GameBoyButton.tsx +6 -4
- package/src/gaesup/{stores/gameboy/index.ts → tools/gameboy/default.ts} +1 -1
- package/src/gaesup/tools/gameboy/index.tsx +6 -4
- package/src/gaesup/tools/gameboy/style.css.ts +2 -2
- package/src/gaesup/tools/gamepad/GamePadButton.tsx +21 -4
- package/src/gaesup/tools/gamepad/default.ts +3 -0
- package/src/gaesup/tools/gamepad/index.tsx +18 -7
- package/src/gaesup/tools/gamepad/style.css.ts +62 -7
- package/src/gaesup/tools/gamepad/type.ts +9 -0
- package/src/gaesup/tools/index.tsx +64 -43
- package/src/gaesup/{stores/joystick/index.ts → tools/joystick/default.ts} +11 -9
- package/src/gaesup/tools/joystick/index.tsx +94 -63
- package/src/gaesup/tools/joystick/style.css.ts +11 -8
- package/src/gaesup/{stores → tools}/joystick/type.ts +8 -7
- package/src/gaesup/tools/jumpPoint/index.tsx +2 -2
- package/src/gaesup/tools/keyBoardToolTip/constant.ts +1 -17
- package/src/gaesup/tools/keyBoardToolTip/default.ts +14 -0
- package/src/gaesup/tools/keyBoardToolTip/index.tsx +27 -20
- package/src/gaesup/tools/keyBoardToolTip/type.ts +37 -0
- package/src/gaesup/{stores/minimap/index.ts → tools/minimap/default.ts} +4 -0
- package/src/gaesup/tools/minimap/index.tsx +23 -5
- package/src/gaesup/{stores → tools}/minimap/type.ts +6 -1
- package/src/gaesup/{stores/control → tools/pushKey}/index.ts +1 -8
- package/src/gaesup/tools/reducer.ts +21 -0
- package/src/gaesup/tools/type.ts +26 -0
- package/src/gaesup/world/context/index.ts +124 -0
- package/src/gaesup/{stores/context/gaesupworld → world/context}/reducer.ts +1 -1
- package/src/gaesup/world/context/type.ts +137 -0
- package/src/gaesup/world/index.tsx +1 -4
- package/src/gaesup/world/type.ts +1 -1
- package/src/gaesup/stores/active/index.ts +0 -19
- package/src/gaesup/stores/active/type.ts +0 -16
- package/src/gaesup/stores/airplane/index.ts +0 -22
- package/src/gaesup/stores/airplane/type.ts +0 -22
- package/src/gaesup/stores/animation/index.ts +0 -18
- package/src/gaesup/stores/animation/type.ts +0 -9
- package/src/gaesup/stores/collider/index.ts +0 -55
- package/src/gaesup/stores/context/gaesupworld/index.ts +0 -11
- package/src/gaesup/stores/context/gaesupworld/type.ts +0 -71
- package/src/gaesup/stores/control/type.ts +0 -11
- package/src/gaesup/stores/point/type.ts +0 -6
- package/src/gaesup/stores/states/index.tsx +0 -10
- package/src/gaesup/stores/states/type.ts +0 -10
- package/src/gaesup/stores/url/index.ts +0 -6
- package/src/gaesup/stores/url/type.ts +0 -6
- /package/src/gaesup/{stores/context/controller → controller/context}/reducer.ts +0 -0
- /package/src/gaesup/{stores → tools}/gameboy/type.ts +0 -0
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
name: string;
|
|
3
|
-
gridRow: string;
|
|
4
|
-
gridColumn: string;
|
|
5
|
-
code?: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type keyArrayItemType = {
|
|
9
|
-
code: string;
|
|
10
|
-
gridRow: string;
|
|
11
|
-
gridColumn: string;
|
|
12
|
-
name: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type keyBoardMapType = {
|
|
16
|
-
[name: string]: keyMapItemType;
|
|
17
|
-
};
|
|
1
|
+
import { keyBoardMapType } from "./type";
|
|
18
2
|
|
|
19
3
|
export const KeyboardF = {
|
|
20
4
|
ESC: { name: "ESC", gridRow: "1/2", gridColumn: "1/2" },
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const KeyboardMapDefault = [
|
|
2
|
+
{ name: "forward", keys: ["ArrowUp", "KeyW"] },
|
|
3
|
+
{ name: "backward", keys: ["ArrowDown", "KeyS"] },
|
|
4
|
+
{ name: "leftward", keys: ["ArrowLeft", "KeyA"] },
|
|
5
|
+
{ name: "rightward", keys: ["ArrowRight", "KeyD"] },
|
|
6
|
+
{ name: "jump", keys: ["Space"] },
|
|
7
|
+
{ name: "run", keys: ["Shift"] },
|
|
8
|
+
{ name: "greet", keys: ["KeyZ"] },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
export const keyboardToolTipDefault = {
|
|
12
|
+
on: true,
|
|
13
|
+
keyBoardMap: KeyboardMapDefault,
|
|
14
|
+
};
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
import { vars } from "../../../styles/theme.css";
|
|
4
|
-
import { GaesupWorldContext } from "../../
|
|
5
|
-
import {
|
|
4
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
5
|
+
import { GaesupToolsContext } from "../context";
|
|
6
|
+
import { KeyBoardAll } from "./constant";
|
|
6
7
|
import * as style from "./style.css";
|
|
8
|
+
import { keyArrayItemType } from "./type";
|
|
7
9
|
|
|
8
|
-
export default function KeyBoardToolTip({
|
|
9
|
-
keyboardMap,
|
|
10
|
-
}: {
|
|
11
|
-
keyboardMap: {
|
|
12
|
-
name: string;
|
|
13
|
-
keys: string[];
|
|
14
|
-
}[];
|
|
15
|
-
}) {
|
|
10
|
+
export default function KeyBoardToolTip() {
|
|
16
11
|
const worldContext = useContext(GaesupWorldContext);
|
|
12
|
+
const {
|
|
13
|
+
keyboardToolTip: {
|
|
14
|
+
keyBoardMap,
|
|
15
|
+
keyBoardToolTipStyle,
|
|
16
|
+
keyBoardToolTipInnerStyle,
|
|
17
|
+
keyCapStyle,
|
|
18
|
+
},
|
|
19
|
+
} = useContext(GaesupToolsContext);
|
|
17
20
|
const { animations } = worldContext;
|
|
18
21
|
|
|
19
22
|
const keyArray = Object.entries(KeyBoardAll).reduce<keyArrayItemType[]>(
|
|
20
23
|
(keyArray, cur) => {
|
|
21
24
|
const [key, value] = cur;
|
|
22
25
|
const { gridRow, gridColumn, name } = value;
|
|
26
|
+
|
|
23
27
|
const keyBoardItem: keyArrayItemType = {
|
|
24
28
|
code: value.code || key,
|
|
25
29
|
gridRow,
|
|
@@ -32,7 +36,7 @@ export default function KeyBoardToolTip({
|
|
|
32
36
|
[]
|
|
33
37
|
);
|
|
34
38
|
|
|
35
|
-
const codeToActionObj =
|
|
39
|
+
const codeToActionObj = keyBoardMap.reduce((maps, keyboardMapItem) => {
|
|
36
40
|
keyboardMapItem.keys.forEach((key) => {
|
|
37
41
|
maps[key] = keyboardMapItem.name;
|
|
38
42
|
});
|
|
@@ -40,8 +44,8 @@ export default function KeyBoardToolTip({
|
|
|
40
44
|
}, {});
|
|
41
45
|
|
|
42
46
|
return (
|
|
43
|
-
<div className={style.keyBoardToolTip}>
|
|
44
|
-
<div className={style.keyBoardTooInner}>
|
|
47
|
+
<div className={style.keyBoardToolTip} style={keyBoardToolTipStyle}>
|
|
48
|
+
<div className={style.keyBoardTooInner} style={keyBoardToolTipInnerStyle}>
|
|
45
49
|
{keyArray.map((item: keyArrayItemType, key: number) => {
|
|
46
50
|
let background = "rgba(0, 0, 0, 0.1)";
|
|
47
51
|
let boxShadow = "0 0 5px rgba(0, 0, 0, 0.2)";
|
|
@@ -66,13 +70,16 @@ export default function KeyBoardToolTip({
|
|
|
66
70
|
return (
|
|
67
71
|
<div
|
|
68
72
|
className={style.keyCap}
|
|
69
|
-
style={
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
style={{
|
|
74
|
+
...assignInlineVars({
|
|
75
|
+
background,
|
|
76
|
+
boxShadow,
|
|
77
|
+
color,
|
|
78
|
+
gridRow: item.gridRow,
|
|
79
|
+
gridColumn: item.gridColumn,
|
|
80
|
+
}),
|
|
81
|
+
...keyCapStyle,
|
|
82
|
+
}}
|
|
76
83
|
key={key}
|
|
77
84
|
>
|
|
78
85
|
{item.name}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
|
+
|
|
3
|
+
export type keyMapItemType = {
|
|
4
|
+
name: string;
|
|
5
|
+
gridRow: string;
|
|
6
|
+
gridColumn: string;
|
|
7
|
+
code?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type keyArrayItemType = {
|
|
11
|
+
code: string;
|
|
12
|
+
gridRow: string;
|
|
13
|
+
gridColumn: string;
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type keyboardMapItemType = {
|
|
18
|
+
name: string;
|
|
19
|
+
keys: string[];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type keyBoardMapType = {
|
|
23
|
+
[name: string]: keyMapItemType;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type keyBoardLabelType = {
|
|
27
|
+
[name: string]: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type keyBoardToolTipType = {
|
|
31
|
+
on?: boolean;
|
|
32
|
+
keyBoardLabel?: keyBoardLabelType;
|
|
33
|
+
keyBoardMap?: keyboardMapItemType[];
|
|
34
|
+
keyBoardToolTipStyle?: CSSProperties;
|
|
35
|
+
keyBoardToolTipInnerStyle?: CSSProperties;
|
|
36
|
+
keyCapStyle?: CSSProperties;
|
|
37
|
+
};
|
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
4
|
-
import { useCallback, useContext, useState } from "react";
|
|
5
|
-
|
|
4
|
+
import { useCallback, useContext, useEffect, useState } from "react";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
GaesupWorldContext,
|
|
8
|
+
GaesupWorldDispatchContext,
|
|
9
|
+
} from "../../world/context";
|
|
10
|
+
import { GaesupToolsContext } from "../context";
|
|
6
11
|
import * as style from "./style.css";
|
|
7
12
|
|
|
8
13
|
export default function MiniMap() {
|
|
9
|
-
const { minimap, activeState } = useContext(GaesupWorldContext);
|
|
14
|
+
const { minimap: minimapInner, activeState } = useContext(GaesupWorldContext);
|
|
15
|
+
const dispatch = useContext(GaesupWorldDispatchContext);
|
|
16
|
+
const { minimap } = useContext(GaesupToolsContext);
|
|
10
17
|
const [ratio, setRatio] = useState(minimap.ratio);
|
|
11
|
-
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
minimapInner.ratio = ratio;
|
|
21
|
+
dispatch({
|
|
22
|
+
type: "update",
|
|
23
|
+
payload: {
|
|
24
|
+
minimap: {
|
|
25
|
+
...minimapInner,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}, []);
|
|
12
30
|
|
|
13
31
|
const upRatio = useCallback(() => {
|
|
14
32
|
if (ratio >= 1) setRatio((prev) => prev - 0.1);
|
|
@@ -31,7 +49,7 @@ export default function MiniMap() {
|
|
|
31
49
|
>
|
|
32
50
|
<div className={style.minimapOuter} style={minimap.objectStyle || {}} />
|
|
33
51
|
<div className={style.minimapInner} style={minimap.innerStyle || {}}>
|
|
34
|
-
{Object.values(
|
|
52
|
+
{Object.values(minimapInner.props).map((obj, key) => {
|
|
35
53
|
return (
|
|
36
54
|
<div
|
|
37
55
|
key={key}
|
|
@@ -7,12 +7,17 @@ export type minimapPropsType = {
|
|
|
7
7
|
size: THREE.Vector3;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
export type
|
|
10
|
+
export type minimapInnerType = {
|
|
11
11
|
on: boolean;
|
|
12
12
|
ratio?: number;
|
|
13
13
|
props: {
|
|
14
14
|
[key: string]: minimapPropsType;
|
|
15
15
|
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type minimapType = {
|
|
19
|
+
on: boolean;
|
|
20
|
+
ratio?: number;
|
|
16
21
|
minimapStyle?: CSSProperties;
|
|
17
22
|
outerStyle?: CSSProperties;
|
|
18
23
|
innerStyle?: CSSProperties;
|
|
@@ -2,14 +2,7 @@ import { useContext } from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
GaesupWorldContext,
|
|
4
4
|
GaesupWorldDispatchContext,
|
|
5
|
-
} from "
|
|
6
|
-
|
|
7
|
-
export const controlDefault = {
|
|
8
|
-
forward: false,
|
|
9
|
-
backward: false,
|
|
10
|
-
leftward: false,
|
|
11
|
-
rightward: false,
|
|
12
|
-
};
|
|
5
|
+
} from "../../world/context";
|
|
13
6
|
|
|
14
7
|
export function usePushKey() {
|
|
15
8
|
const { control } = useContext(GaesupWorldContext);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { gaesupToolsPropType } from "./type";
|
|
2
|
+
|
|
3
|
+
export function gaesupToolsReducer(
|
|
4
|
+
props: gaesupToolsPropType,
|
|
5
|
+
action: {
|
|
6
|
+
type: string;
|
|
7
|
+
payload?: gaesupToolsPropType;
|
|
8
|
+
}
|
|
9
|
+
) {
|
|
10
|
+
switch (action.type) {
|
|
11
|
+
case "init": {
|
|
12
|
+
return { ...props };
|
|
13
|
+
}
|
|
14
|
+
case "update": {
|
|
15
|
+
return { ...props, ...action.payload };
|
|
16
|
+
}
|
|
17
|
+
default: {
|
|
18
|
+
throw Error("Unknown action: " + action.type);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Dispatch } from "react";
|
|
2
|
+
import { gameboyType } from "./gameboy/type";
|
|
3
|
+
import { gamepadType } from "./gamepad/type";
|
|
4
|
+
import { joyStickType } from "./joystick/type";
|
|
5
|
+
import { keyBoardToolTipType } from "./keyBoardToolTip/type";
|
|
6
|
+
import { minimapType } from "./minimap/type";
|
|
7
|
+
|
|
8
|
+
export type keyboardMapType = { name: string; keys: string[] }[];
|
|
9
|
+
export type gaesupToolsPropType = {
|
|
10
|
+
keyboardToolTip: keyBoardToolTipType;
|
|
11
|
+
joystick: joyStickType;
|
|
12
|
+
minimap: minimapType;
|
|
13
|
+
gameboy: gameboyType;
|
|
14
|
+
gamepad: gamepadType;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type dispatchType<T> = Dispatch<{
|
|
18
|
+
type: string;
|
|
19
|
+
payload?: Partial<T>;
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
export type gaesupToolsPartialPropType = Partial<gaesupToolsPropType>;
|
|
23
|
+
export type gaesupDisptachType = Dispatch<{
|
|
24
|
+
type: string;
|
|
25
|
+
payload?: Partial<gaesupToolsPropType>;
|
|
26
|
+
}>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { euler, quat, vec3 } from "@react-three/rapier";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
import { animationTagType } from "../../controller/type";
|
|
4
|
+
import { V3 } from "../../utils/vector";
|
|
5
|
+
import { dispatchType, gaesupWorldPropType } from "./type";
|
|
6
|
+
|
|
7
|
+
export const gaesupWorldDefault: gaesupWorldPropType = {
|
|
8
|
+
activeState: {
|
|
9
|
+
position: V3(0, 1, 5),
|
|
10
|
+
impulse: vec3(),
|
|
11
|
+
velocity: vec3(),
|
|
12
|
+
acceleration: vec3(),
|
|
13
|
+
quat: quat(),
|
|
14
|
+
euler: euler(),
|
|
15
|
+
dir: vec3(),
|
|
16
|
+
direction: vec3(),
|
|
17
|
+
axisX: V3(1, 0, 0),
|
|
18
|
+
axisY: V3(0, 1, 0),
|
|
19
|
+
axisZ: V3(0, 0, 1),
|
|
20
|
+
yaw: 0,
|
|
21
|
+
pitch: 0,
|
|
22
|
+
roll: 0,
|
|
23
|
+
},
|
|
24
|
+
characterCollider: {
|
|
25
|
+
halfHeight: 0.35,
|
|
26
|
+
height: 0.7,
|
|
27
|
+
radius: 0.3,
|
|
28
|
+
diameter: 0.6,
|
|
29
|
+
},
|
|
30
|
+
vehicleCollider: {
|
|
31
|
+
wheelSizeX: 0.5,
|
|
32
|
+
wheelSizeY: 0.5,
|
|
33
|
+
wheelSizeZ: 0.5,
|
|
34
|
+
vehicleSizeX: 1,
|
|
35
|
+
vehicleSizeY: 1,
|
|
36
|
+
vehicleSizeZ: 1,
|
|
37
|
+
vehicleX: 0.5,
|
|
38
|
+
vehicleY: 0.5,
|
|
39
|
+
vehicleZ: 0.5,
|
|
40
|
+
},
|
|
41
|
+
airplaneCollider: {
|
|
42
|
+
airplaneSizeX: 1,
|
|
43
|
+
airplaneSizeY: 1,
|
|
44
|
+
airplaneSizeZ: 1,
|
|
45
|
+
airplaneX: 0.5,
|
|
46
|
+
airplaneY: 0.5,
|
|
47
|
+
airplaneZ: 0.5,
|
|
48
|
+
},
|
|
49
|
+
mode: {
|
|
50
|
+
type: "character",
|
|
51
|
+
controller: "keyboard",
|
|
52
|
+
},
|
|
53
|
+
url: {
|
|
54
|
+
characterUrl: null,
|
|
55
|
+
vehicleUrl: null,
|
|
56
|
+
airplaneUrl: null,
|
|
57
|
+
wheelUrl: null,
|
|
58
|
+
},
|
|
59
|
+
characterGltf: null,
|
|
60
|
+
vehicleGltf: null,
|
|
61
|
+
wheelGltf: null,
|
|
62
|
+
airplaneGltf: null,
|
|
63
|
+
states: {
|
|
64
|
+
isMoving: false,
|
|
65
|
+
isNotMoving: false,
|
|
66
|
+
isOnTheGround: false,
|
|
67
|
+
isOnMoving: false,
|
|
68
|
+
isRotated: false,
|
|
69
|
+
isRunning: false,
|
|
70
|
+
isJumping: false,
|
|
71
|
+
isAnimationOuter: false,
|
|
72
|
+
},
|
|
73
|
+
debug: false,
|
|
74
|
+
minimap: {
|
|
75
|
+
on: true,
|
|
76
|
+
props: {},
|
|
77
|
+
},
|
|
78
|
+
joystick: {
|
|
79
|
+
on: true,
|
|
80
|
+
joyStickOrigin: {
|
|
81
|
+
x: 0,
|
|
82
|
+
y: 0,
|
|
83
|
+
angle: Math.PI / 2,
|
|
84
|
+
currentRadius: 0,
|
|
85
|
+
originRadius: 0,
|
|
86
|
+
isIn: true,
|
|
87
|
+
isOn: false,
|
|
88
|
+
isUp: true,
|
|
89
|
+
isCenter: true,
|
|
90
|
+
},
|
|
91
|
+
joyStickBall: {
|
|
92
|
+
top: "50%",
|
|
93
|
+
left: "50%",
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
control: {
|
|
97
|
+
forward: false,
|
|
98
|
+
backward: false,
|
|
99
|
+
leftward: false,
|
|
100
|
+
rightward: false,
|
|
101
|
+
},
|
|
102
|
+
points: [],
|
|
103
|
+
refs: null,
|
|
104
|
+
animations: {
|
|
105
|
+
current: "idle" as keyof animationTagType,
|
|
106
|
+
animationNames: {
|
|
107
|
+
idle: "idle",
|
|
108
|
+
walk: "walk",
|
|
109
|
+
run: "run",
|
|
110
|
+
accel: "accel",
|
|
111
|
+
break: "break",
|
|
112
|
+
ride: "ride",
|
|
113
|
+
jump: "jump",
|
|
114
|
+
jumpIdle: "jumpIdle",
|
|
115
|
+
jumpLand: "jumpLand",
|
|
116
|
+
fall: "fall",
|
|
117
|
+
},
|
|
118
|
+
keyControl: {},
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const GaesupWorldContext = createContext<gaesupWorldPropType>(null);
|
|
123
|
+
export const GaesupWorldDispatchContext =
|
|
124
|
+
createContext<dispatchType<gaesupWorldPropType>>(null);
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Dispatch } from "react";
|
|
2
|
+
import { GLTFResult } from "../../component/gltf/type";
|
|
3
|
+
import { actionsType, animationTagType, refsType } from "../../controller/type";
|
|
4
|
+
|
|
5
|
+
import { joyStickInnerType } from "../../tools/joystick/type";
|
|
6
|
+
import { minimapInnerType } from "../../tools/minimap/type";
|
|
7
|
+
|
|
8
|
+
export type controlType = {
|
|
9
|
+
forward: boolean;
|
|
10
|
+
backward: boolean;
|
|
11
|
+
leftward: boolean;
|
|
12
|
+
rightward: boolean;
|
|
13
|
+
[key: string]: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type keyControlType = {
|
|
17
|
+
[key: string]: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type pointType = {
|
|
21
|
+
text: string;
|
|
22
|
+
position: THREE.Vector3;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type pointsType = pointType[];
|
|
26
|
+
|
|
27
|
+
export type statesType = {
|
|
28
|
+
isMoving: boolean;
|
|
29
|
+
isNotMoving: boolean;
|
|
30
|
+
isOnTheGround: boolean;
|
|
31
|
+
isOnMoving: boolean;
|
|
32
|
+
isRotated: boolean;
|
|
33
|
+
isRunning: boolean;
|
|
34
|
+
isJumping: boolean;
|
|
35
|
+
isAnimationOuter: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type urlType = {
|
|
39
|
+
characterUrl?: string;
|
|
40
|
+
vehicleUrl?: string;
|
|
41
|
+
airplaneUrl?: string;
|
|
42
|
+
wheelUrl?: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type animationPropType = {
|
|
46
|
+
current: keyof animationTagType;
|
|
47
|
+
animationNames: actionsType;
|
|
48
|
+
keyControl: {
|
|
49
|
+
[key: string]: boolean;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type characterColliderType = {
|
|
54
|
+
halfHeight?: number;
|
|
55
|
+
height?: number;
|
|
56
|
+
radius?: number;
|
|
57
|
+
diameter?: number;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type vehicleColliderType = {
|
|
61
|
+
wheelSizeX?: number;
|
|
62
|
+
wheelSizeY?: number;
|
|
63
|
+
wheelSizeZ?: number;
|
|
64
|
+
vehicleSizeX?: number;
|
|
65
|
+
vehicleSizeY?: number;
|
|
66
|
+
vehicleSizeZ?: number;
|
|
67
|
+
vehicleX?: number;
|
|
68
|
+
vehicleY?: number;
|
|
69
|
+
vehicleZ?: number;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type airplaneColliderType = {
|
|
73
|
+
airplaneSizeX?: number;
|
|
74
|
+
airplaneSizeY?: number;
|
|
75
|
+
airplaneSizeZ?: number;
|
|
76
|
+
airplaneX?: number;
|
|
77
|
+
airplaneY?: number;
|
|
78
|
+
airplaneZ?: number;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type modeType = {
|
|
82
|
+
type?: "character" | "vehicle" | "airplane";
|
|
83
|
+
controller?: "gameboy" | "keyboard" | "joystick";
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type activeStateType = {
|
|
87
|
+
position: THREE.Vector3;
|
|
88
|
+
impulse: THREE.Vector3;
|
|
89
|
+
velocity: THREE.Vector3;
|
|
90
|
+
acceleration: THREE.Vector3;
|
|
91
|
+
quat: THREE.Quaternion;
|
|
92
|
+
euler: THREE.Euler;
|
|
93
|
+
direction: THREE.Vector3;
|
|
94
|
+
dir: THREE.Vector3;
|
|
95
|
+
axisX: THREE.Vector3;
|
|
96
|
+
axisY: THREE.Vector3;
|
|
97
|
+
axisZ: THREE.Vector3;
|
|
98
|
+
yaw: number;
|
|
99
|
+
pitch: number;
|
|
100
|
+
roll: number;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
type KeyboardControlsState<T extends string = string> = {
|
|
104
|
+
[K in T]: boolean;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type gaesupWorldPropType = {
|
|
108
|
+
activeState: activeStateType;
|
|
109
|
+
characterCollider: characterColliderType;
|
|
110
|
+
vehicleCollider: vehicleColliderType;
|
|
111
|
+
airplaneCollider: airplaneColliderType;
|
|
112
|
+
mode: modeType;
|
|
113
|
+
url: urlType;
|
|
114
|
+
characterGltf: GLTFResult;
|
|
115
|
+
vehicleGltf: GLTFResult;
|
|
116
|
+
wheelGltf: GLTFResult;
|
|
117
|
+
airplaneGltf: GLTFResult;
|
|
118
|
+
states: statesType;
|
|
119
|
+
debug: boolean;
|
|
120
|
+
minimap: minimapInnerType;
|
|
121
|
+
joystick: joyStickInnerType;
|
|
122
|
+
control: KeyboardControlsState<string>;
|
|
123
|
+
points: pointsType;
|
|
124
|
+
refs: refsType;
|
|
125
|
+
animations: animationPropType;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export type dispatchType<T> = Dispatch<{
|
|
129
|
+
type: string;
|
|
130
|
+
payload?: Partial<T>;
|
|
131
|
+
}>;
|
|
132
|
+
|
|
133
|
+
export type gaesupWorldPartialPropType = Partial<gaesupWorldPropType>;
|
|
134
|
+
export type gaesupDisptachType = Dispatch<{
|
|
135
|
+
type: string;
|
|
136
|
+
payload?: Partial<gaesupWorldPropType>;
|
|
137
|
+
}>;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import initGaesupWorld from "../initial/gaesupWorld";
|
|
2
2
|
import { initGaesupWorldPropsType } from "../initial/gaesupWorld/type";
|
|
3
|
-
import {
|
|
4
|
-
GaesupWorldContext,
|
|
5
|
-
GaesupWorldDispatchContext,
|
|
6
|
-
} from "../stores/context/gaesupworld";
|
|
3
|
+
import { GaesupWorldContext, GaesupWorldDispatchContext } from "./context";
|
|
7
4
|
|
|
8
5
|
export default function GaesupWorld(props: initGaesupWorldPropsType) {
|
|
9
6
|
const { gaesupProps } = initGaesupWorld(props);
|
package/src/gaesup/world/type.ts
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { euler, quat, vec3 } from "@react-three/rapier";
|
|
2
|
-
import { V3 } from "../../utils/vector";
|
|
3
|
-
|
|
4
|
-
export const activeStateDefault = {
|
|
5
|
-
position: V3(0, 2, 5),
|
|
6
|
-
impulse: vec3(),
|
|
7
|
-
velocity: vec3(),
|
|
8
|
-
acceleration: vec3(),
|
|
9
|
-
quat: quat(),
|
|
10
|
-
euler: euler(),
|
|
11
|
-
dir: vec3(),
|
|
12
|
-
direction: vec3(),
|
|
13
|
-
axisX: V3(1, 0, 0),
|
|
14
|
-
axisY: V3(0, 1, 0),
|
|
15
|
-
axisZ: V3(0, 0, 1),
|
|
16
|
-
yaw: 0,
|
|
17
|
-
pitch: 0,
|
|
18
|
-
roll: 0,
|
|
19
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export type activeStateType = {
|
|
2
|
-
position: THREE.Vector3;
|
|
3
|
-
impulse: THREE.Vector3;
|
|
4
|
-
velocity: THREE.Vector3;
|
|
5
|
-
acceleration: THREE.Vector3;
|
|
6
|
-
quat: THREE.Quaternion;
|
|
7
|
-
euler: THREE.Euler;
|
|
8
|
-
direction: THREE.Vector3;
|
|
9
|
-
dir: THREE.Vector3;
|
|
10
|
-
axisX: THREE.Vector3;
|
|
11
|
-
axisY: THREE.Vector3;
|
|
12
|
-
axisZ: THREE.Vector3;
|
|
13
|
-
yaw: number;
|
|
14
|
-
pitch: number;
|
|
15
|
-
roll: number;
|
|
16
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { V3 } from "../../utils/vector";
|
|
2
|
-
|
|
3
|
-
export const airplaneDefault = {
|
|
4
|
-
angleChange: V3(0.01, 0.005, 0.005),
|
|
5
|
-
maxAngle: V3(0.1, 0.1, 0.1),
|
|
6
|
-
maxSpeed: 60,
|
|
7
|
-
accelRatio: 2,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const vehicleDefault = {
|
|
11
|
-
angleChange: V3(0.01, 0.005, 0.005),
|
|
12
|
-
maxAngle: V3(0.1, 0.1, 0.1),
|
|
13
|
-
maxSpeed: 60,
|
|
14
|
-
accelRatio: 2,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const characterDefault = {
|
|
18
|
-
angleChange: V3(0.01, 0.005, 0.005),
|
|
19
|
-
maxAngle: V3(0.1, 0.1, 0.1),
|
|
20
|
-
maxSpeed: 60,
|
|
21
|
-
accelRatio: 2,
|
|
22
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { GroupProps } from "@react-three/fiber";
|
|
2
|
-
|
|
3
|
-
export interface airplaneType extends GroupProps {
|
|
4
|
-
angleChange?: THREE.Vector3;
|
|
5
|
-
maxAngle?: THREE.Vector3;
|
|
6
|
-
maxSpeed?: number;
|
|
7
|
-
accelRatio?: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface vehicleType extends GroupProps {
|
|
11
|
-
angleChange?: THREE.Vector3;
|
|
12
|
-
maxAngle?: THREE.Vector3;
|
|
13
|
-
maxSpeed?: number;
|
|
14
|
-
accelRatio?: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface characterType extends GroupProps {
|
|
18
|
-
angleChange?: THREE.Vector3;
|
|
19
|
-
maxAngle?: THREE.Vector3;
|
|
20
|
-
maxSpeed?: number;
|
|
21
|
-
accelRatio?: number;
|
|
22
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { animationTagType } from "../../controller/type";
|
|
2
|
-
|
|
3
|
-
export const animationDefault = {
|
|
4
|
-
current: "idle" as keyof animationTagType,
|
|
5
|
-
animationNames: {
|
|
6
|
-
idle: "idle",
|
|
7
|
-
walk: "walk",
|
|
8
|
-
run: "run",
|
|
9
|
-
accel: "accel",
|
|
10
|
-
break: "break",
|
|
11
|
-
ride: "ride",
|
|
12
|
-
jump: "jump",
|
|
13
|
-
jumpIdle: "jumpIdle",
|
|
14
|
-
jumpLand: "jumpLand",
|
|
15
|
-
fall: "fall",
|
|
16
|
-
},
|
|
17
|
-
keyControl: {},
|
|
18
|
-
};
|