gaesup-world 0.0.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.
Files changed (146) hide show
  1. package/README.md +51 -0
  2. package/index.html +13 -0
  3. package/package.json +82 -0
  4. package/src/gaesup/animation/actions.ts +123 -0
  5. package/src/gaesup/camera/cameraCollisionDetecter.tsx +53 -0
  6. package/src/gaesup/camera/control/map.ts +10 -0
  7. package/src/gaesup/camera/control/normal copy.ts +19 -0
  8. package/src/gaesup/camera/control/normal.ts +15 -0
  9. package/src/gaesup/camera/control/orbit.ts +31 -0
  10. package/src/gaesup/camera/index.tsx +102 -0
  11. package/src/gaesup/camera/type.ts +17 -0
  12. package/src/gaesup/component/Airplane.tsx +46 -0
  13. package/src/gaesup/component/Character.tsx +48 -0
  14. package/src/gaesup/component/Vehicle.tsx +40 -0
  15. package/src/gaesup/component/gltf/AirplaneGltf.tsx +31 -0
  16. package/src/gaesup/component/gltf/CharacterGltf.tsx +81 -0
  17. package/src/gaesup/component/gltf/VehicleGltf.tsx +31 -0
  18. package/src/gaesup/component/gltf/WheelJoint.tsx +39 -0
  19. package/src/gaesup/component/gltf/type.ts +6 -0
  20. package/src/gaesup/component/ref/airplane.tsx +83 -0
  21. package/src/gaesup/component/ref/character.tsx +132 -0
  22. package/src/gaesup/component/ref/vehicle.tsx +145 -0
  23. package/src/gaesup/controller/index.tsx +103 -0
  24. package/src/gaesup/controller/type.ts +139 -0
  25. package/src/gaesup/gaesupProps/index.tsx +66 -0
  26. package/src/gaesup/initial/callback/index.ts +73 -0
  27. package/src/gaesup/initial/callback/type.ts +45 -0
  28. package/src/gaesup/initial/controller/index.ts +143 -0
  29. package/src/gaesup/initial/controller/initDebug.ts +102 -0
  30. package/src/gaesup/initial/gaesupWorld/collider/airplane.ts +26 -0
  31. package/src/gaesup/initial/gaesupWorld/collider/character.ts +32 -0
  32. package/src/gaesup/initial/gaesupWorld/collider/gltf.ts +91 -0
  33. package/src/gaesup/initial/gaesupWorld/collider/index.ts +26 -0
  34. package/src/gaesup/initial/gaesupWorld/collider/vehicle.ts +43 -0
  35. package/src/gaesup/initial/gaesupWorld/index.ts +82 -0
  36. package/src/gaesup/initial/gaesupWorld/type.ts +37 -0
  37. package/src/gaesup/physics/airplane/currentSetting.ts +20 -0
  38. package/src/gaesup/physics/airplane/damping.ts +8 -0
  39. package/src/gaesup/physics/airplane/direction.ts +70 -0
  40. package/src/gaesup/physics/airplane/gravity.ts +11 -0
  41. package/src/gaesup/physics/airplane/impulse.ts +22 -0
  42. package/src/gaesup/physics/airplane/index.tsx +16 -0
  43. package/src/gaesup/physics/airplane/turn.ts +12 -0
  44. package/src/gaesup/physics/airplane copy/currentSetting.ts +20 -0
  45. package/src/gaesup/physics/airplane copy/direction.ts +52 -0
  46. package/src/gaesup/physics/airplane copy/gravity.ts +6 -0
  47. package/src/gaesup/physics/airplane copy/impulse.ts +28 -0
  48. package/src/gaesup/physics/airplane copy/index.tsx +14 -0
  49. package/src/gaesup/physics/airplane copy/turn.ts +9 -0
  50. package/src/gaesup/physics/character/accelaration.ts +14 -0
  51. package/src/gaesup/physics/character/currentSetting.ts +20 -0
  52. package/src/gaesup/physics/character/damping.ts +6 -0
  53. package/src/gaesup/physics/character/direction.ts +104 -0
  54. package/src/gaesup/physics/character/impulse.ts +24 -0
  55. package/src/gaesup/physics/character/index.tsx +20 -0
  56. package/src/gaesup/physics/character/jump.ts +21 -0
  57. package/src/gaesup/physics/character/stabilizing.ts +6 -0
  58. package/src/gaesup/physics/character/turn.ts +17 -0
  59. package/src/gaesup/physics/check/ground.ts +19 -0
  60. package/src/gaesup/physics/check/index.ts +12 -0
  61. package/src/gaesup/physics/check/moving.ts +21 -0
  62. package/src/gaesup/physics/check/rotate.ts +13 -0
  63. package/src/gaesup/physics/check/slope.ts +50 -0
  64. package/src/gaesup/physics/index.ts +50 -0
  65. package/src/gaesup/physics/type.ts +35 -0
  66. package/src/gaesup/physics/vehicle/currentSetting.ts +20 -0
  67. package/src/gaesup/physics/vehicle/damping.ts +8 -0
  68. package/src/gaesup/physics/vehicle/direction.ts +27 -0
  69. package/src/gaesup/physics/vehicle/impulse.ts +22 -0
  70. package/src/gaesup/physics/vehicle/index.tsx +14 -0
  71. package/src/gaesup/physics/vehicle/turn.ts +11 -0
  72. package/src/gaesup/stores/active/index.ts +19 -0
  73. package/src/gaesup/stores/active/type.ts +16 -0
  74. package/src/gaesup/stores/airplane/index.ts +6 -0
  75. package/src/gaesup/stores/airplane/type.ts +4 -0
  76. package/src/gaesup/stores/animation/index.ts +18 -0
  77. package/src/gaesup/stores/animation/type.ts +9 -0
  78. package/src/gaesup/stores/collider/index.ts +55 -0
  79. package/src/gaesup/stores/context/controller/index.ts +36 -0
  80. package/src/gaesup/stores/context/controller/reducer.ts +18 -0
  81. package/src/gaesup/stores/context/controller/type.ts +38 -0
  82. package/src/gaesup/stores/context/gaesupworld/index.ts +11 -0
  83. package/src/gaesup/stores/context/gaesupworld/reducer.ts +21 -0
  84. package/src/gaesup/stores/context/gaesupworld/type.ts +66 -0
  85. package/src/gaesup/stores/control/index.ts +33 -0
  86. package/src/gaesup/stores/control/type.ts +11 -0
  87. package/src/gaesup/stores/joystick/index.ts +72 -0
  88. package/src/gaesup/stores/joystick/type.ts +23 -0
  89. package/src/gaesup/stores/minimap/index.ts +5 -0
  90. package/src/gaesup/stores/minimap/type.ts +22 -0
  91. package/src/gaesup/stores/point/type.ts +6 -0
  92. package/src/gaesup/stores/states/index.tsx +10 -0
  93. package/src/gaesup/stores/states/type.ts +10 -0
  94. package/src/gaesup/stores/url/index.ts +6 -0
  95. package/src/gaesup/stores/url/type.ts +6 -0
  96. package/src/gaesup/styles.css.ts +26 -0
  97. package/src/gaesup/tools/gameboy/GameBoyButton.tsx +38 -0
  98. package/src/gaesup/tools/gameboy/index.tsx +36 -0
  99. package/src/gaesup/tools/gameboy/style.css.ts +78 -0
  100. package/src/gaesup/tools/gamepad/GamePadButton.tsx +31 -0
  101. package/src/gaesup/tools/gamepad/index.tsx +55 -0
  102. package/src/gaesup/tools/gamepad/style.css.ts +16 -0
  103. package/src/gaesup/tools/index.tsx +61 -0
  104. package/src/gaesup/tools/joystick/index.tsx +145 -0
  105. package/src/gaesup/tools/joystick/style.css.ts +40 -0
  106. package/src/gaesup/tools/jumpPoint/index.tsx +27 -0
  107. package/src/gaesup/tools/jumpPoint/style.css.ts +33 -0
  108. package/src/gaesup/tools/keyBoardToolTip/constant.ts +144 -0
  109. package/src/gaesup/tools/keyBoardToolTip/index.tsx +85 -0
  110. package/src/gaesup/tools/keyBoardToolTip/style.css.ts +49 -0
  111. package/src/gaesup/tools/minimap/index.tsx +47 -0
  112. package/src/gaesup/tools/minimap/style.css.ts +144 -0
  113. package/src/gaesup/tools/style.css.ts +34 -0
  114. package/src/gaesup/utils/constant.ts +1 -0
  115. package/src/gaesup/utils/ray.ts +23 -0
  116. package/src/gaesup/utils/ref.ts +17 -0
  117. package/src/gaesup/utils/vector.ts +40 -0
  118. package/src/gaesup/world/index.tsx +17 -0
  119. package/src/gaesup/world/type.ts +10 -0
  120. package/src/styles/constants/boxshadow.css.ts +499 -0
  121. package/src/styles/constants/constant.css.ts +81 -0
  122. package/src/styles/constants/direction.css.ts +168 -0
  123. package/src/styles/constants/flex.css.ts +68 -0
  124. package/src/styles/constants/gradient.css.ts +10 -0
  125. package/src/styles/constants/grid.css.ts +37 -0
  126. package/src/styles/constants/palette.css.ts +324 -0
  127. package/src/styles/constants/translate.css.ts +129 -0
  128. package/src/styles/global.css.ts +91 -0
  129. package/src/styles/recipe/base.css.ts +31 -0
  130. package/src/styles/recipe/button.css.ts +109 -0
  131. package/src/styles/recipe/index.css.ts +134 -0
  132. package/src/styles/recipe/input.css.ts +33 -0
  133. package/src/styles/sprinkles/color.css.ts +62 -0
  134. package/src/styles/sprinkles/direction.css.ts +26 -0
  135. package/src/styles/sprinkles/display.css.ts +25 -0
  136. package/src/styles/sprinkles/fontSize.css.ts +25 -0
  137. package/src/styles/sprinkles/grid.css.ts +25 -0
  138. package/src/styles/sprinkles/index.css.ts +22 -0
  139. package/src/styles/sprinkles/margin.css.ts +30 -0
  140. package/src/styles/sprinkles/padding.css.ts +30 -0
  141. package/src/styles/sprinkles/position.css.ts +14 -0
  142. package/src/styles/sprinkles/size.css.ts +23 -0
  143. package/src/styles/theme.css.ts +98 -0
  144. package/tsconfig.json +27 -0
  145. package/tsconfig.node.json +10 -0
  146. package/vite.config.ts +9 -0
@@ -0,0 +1,16 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { mobileButton } from "../../../styles/recipe/button.css";
3
+ import { flex } from "../../../styles/recipe/index.css";
4
+
5
+ export const gamePad = style([
6
+ flex({
7
+ row: "center",
8
+ }),
9
+ {
10
+ width: "100%",
11
+ height: "100%",
12
+ zIndex: 10000,
13
+ },
14
+ ]);
15
+
16
+ export const gamePadButtonRecipe = style([mobileButton({})]);
@@ -0,0 +1,61 @@
1
+ "use client";
2
+
3
+ import { useContext, useEffect } from "react";
4
+
5
+ import {
6
+ GaesupWorldContext,
7
+ GaesupWorldDispatchContext,
8
+ } from "../stores/context/gaesupworld";
9
+ import GameBoy from "./gameboy";
10
+ import GamePad from "./gamepad";
11
+ import JoyStick from "./joystick";
12
+ import JumpPoint from "./jumpPoint";
13
+ import KeyBoardToolTip from "./keyBoardToolTip";
14
+ import MiniMap from "./minimap";
15
+ import * as style from "./style.css";
16
+ export default function GaeSupTools({
17
+ keyboardMap,
18
+ }: {
19
+ keyboardMap: { name: string; keys: string[] }[];
20
+ }) {
21
+ const { minimap, mode } = useContext(GaesupWorldContext);
22
+ const { control } = useContext(GaesupWorldContext);
23
+ const dispatch = useContext(GaesupWorldDispatchContext);
24
+ useEffect(() => {
25
+ const keyboard = keyboardMap.reduce((maps, keyboardMapItem) => {
26
+ maps[keyboardMapItem.name] = false;
27
+ return maps;
28
+ }, {});
29
+ const assignedControl = Object.assign(control, keyboard);
30
+
31
+ dispatch({
32
+ type: "update",
33
+ payload: {
34
+ control: {
35
+ ...assignedControl,
36
+ },
37
+ },
38
+ });
39
+ }, []);
40
+
41
+ return (
42
+ <>
43
+ <div className={style.footer}>
44
+ <div className={style.footerUpper}>
45
+ {(mode.controller === "joystick" ||
46
+ mode.controller === "gameboy") && <GamePad />}
47
+ </div>
48
+ <div className={style.footerLower}>
49
+ {mode.controller === "joystick" && <JoyStick />}
50
+ {mode.controller === "gameboy" && <GameBoy />}
51
+ {mode.controller === "keyboard" && (
52
+ <KeyBoardToolTip keyboardMap={keyboardMap} />
53
+ )}
54
+ {minimap.on && <MiniMap />}
55
+ </div>
56
+ </div>
57
+
58
+ <JumpPoint />
59
+ </>
60
+ );
61
+ }
@@ -0,0 +1,145 @@
1
+ import {
2
+ MouseEvent,
3
+ MouseEventHandler,
4
+ TouchEvent,
5
+ TouchEventHandler,
6
+ useCallback,
7
+ useRef,
8
+ useState,
9
+ } from "react";
10
+ import { vars } from "../../../styles/theme.css";
11
+ import useJoyStick from "../../stores/joystick";
12
+ import * as style from "./style.css";
13
+
14
+ export default function JoyStick() {
15
+ return (
16
+ <div className={style.joyStick}>
17
+ <JoyBall />
18
+ </div>
19
+ );
20
+ }
21
+
22
+ export function JoyBall() {
23
+ const outerRef = useRef<HTMLDivElement>(null);
24
+ const { joyStickBall, joyStickOrigin, setBall, setOrigin } = useJoyStick();
25
+ const [mouseDown, setMouseDown] = useState(false);
26
+ const [touchDown, setTouchDown] = useState(false);
27
+
28
+ const calcOriginBall = <T extends MouseEvent | TouchEvent>(
29
+ e: T,
30
+ X: number,
31
+ Y: number
32
+ ): T => {
33
+ const outer = e.target as HTMLDivElement;
34
+ const parent = outer.parentElement as HTMLDivElement;
35
+ const { top, left, bottom, right, width, height } =
36
+ parent.getBoundingClientRect();
37
+ if (top > Y || bottom < Y || left > X || right < X) return;
38
+ const normX = (joyStickOrigin.x - X) ** 2;
39
+ const normY = (joyStickOrigin.y - Y) ** 2;
40
+ const currentRadius = Math.sqrt(normX + normY);
41
+ const originRadius = Math.sqrt((width / 2) ** 2 + (height / 2) ** 2);
42
+
43
+ setOrigin({
44
+ x: left + width / 2,
45
+ y: bottom - height / 2,
46
+ angle: Math.atan2(Y - (bottom - height / 2), X - (left + width / 2)),
47
+ currentRadius,
48
+ originRadius,
49
+ isIn: currentRadius > originRadius / 2,
50
+ isOn: true,
51
+ });
52
+ setBall({
53
+ x: `${X}px`,
54
+ y: `${Y}px`,
55
+ position: "fixed",
56
+ background:
57
+ currentRadius > originRadius / 2
58
+ ? vars.gradient.lightGreen
59
+ : vars.gradient.green,
60
+ boxShadow: "0 0 10px rgba(99,251,215,1)",
61
+ });
62
+ };
63
+
64
+ const initialize = () => {
65
+ setOrigin({
66
+ x: 0,
67
+ y: 0,
68
+ angle: Math.PI / 2,
69
+ currentRadius: 0,
70
+ originRadius: 0,
71
+ isIn: true,
72
+ isOn: false,
73
+ });
74
+ setBall({
75
+ x: "50%",
76
+ y: "50%",
77
+ position: "absolute",
78
+ background: "rgba(0, 0, 0, 0.5)",
79
+ boxShadow: "0 0 10px rgba(0, 0, 0, 0.5)",
80
+ });
81
+ };
82
+
83
+ const handleMouseOver: MouseEventHandler = useCallback(
84
+ (e) => {
85
+ if (!mouseDown) return;
86
+ calcOriginBall<MouseEvent<Element>>(e, e.pageX, e.pageY);
87
+ },
88
+ [joyStickBall, joyStickOrigin, setBall, setOrigin, mouseDown]
89
+ );
90
+
91
+ const handleTouchMove: TouchEventHandler = useCallback(
92
+ (e) => {
93
+ if (!touchDown) return;
94
+ calcOriginBall<TouchEvent<Element>>(
95
+ e,
96
+ e.touches[0].pageX,
97
+ e.touches[0].pageY
98
+ );
99
+ },
100
+ [touchDown]
101
+ );
102
+
103
+ const handleTouchEnd = useCallback(() => {
104
+ return initialize();
105
+ }, [touchDown]);
106
+ const handleMouseOut = useCallback(() => {
107
+ return initialize();
108
+ }, [joyStickBall, joyStickOrigin, setBall, setOrigin, mouseDown]);
109
+
110
+ return (
111
+ <>
112
+ <div className={style.joyStick}>
113
+ <div
114
+ className={style.joyStickInner}
115
+ ref={outerRef}
116
+ onMouseDown={() => setMouseDown(true)}
117
+ onMouseUp={() => setMouseDown(false)}
118
+ onMouseMove={handleMouseOver}
119
+ onMouseLeave={() => {
120
+ setMouseDown(false);
121
+ handleMouseOut();
122
+ }}
123
+ onTouchStart={() => setTouchDown(true)}
124
+ onTouchEnd={() => {
125
+ setTouchDown(false);
126
+ handleTouchEnd();
127
+ }}
128
+ onTouchMove={handleTouchMove}
129
+ onTouchCancel={handleTouchEnd}
130
+ >
131
+ <div
132
+ className={`${style.joystickBall}`}
133
+ style={{
134
+ position: joyStickBall.position as "fixed" | "absolute",
135
+ background: joyStickBall.background,
136
+ boxShadow: joyStickBall.boxShadow,
137
+ top: joyStickBall.y,
138
+ left: joyStickBall.x,
139
+ }}
140
+ />
141
+ </div>
142
+ </div>
143
+ </>
144
+ );
145
+ }
@@ -0,0 +1,40 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { fixed, flex } from "../../../styles/recipe/index.css";
3
+
4
+ export const joyStick = style([
5
+ fixed({
6
+ south: true,
7
+ }),
8
+ flex({
9
+ column: "6",
10
+ }),
11
+ {
12
+ width: "100%",
13
+ },
14
+ ]);
15
+
16
+ export const joyStickInner = style([
17
+ flex({
18
+ row: "center",
19
+ }),
20
+ {
21
+ margin: "4rem",
22
+ padding: "6rem",
23
+ borderRadius: "50%",
24
+ background: "rgba(0, 0, 0, 0.5)",
25
+ boxShadow: "0 0 10px rgba(0, 0, 0, 0.5)",
26
+ },
27
+ ]);
28
+
29
+ export const joystickBall = style([
30
+ {
31
+ position: "fixed",
32
+ width: "5rem",
33
+ height: "5rem",
34
+ transform: "translate(-50%, -50%)",
35
+ borderRadius: "50%",
36
+ background: "rgba(0, 0, 0, 0.5)",
37
+ boxShadow: "0 0 10px rgba(0, 0, 0, 0.5)",
38
+ cursor: "pointer",
39
+ },
40
+ ]);
@@ -0,0 +1,27 @@
1
+ import { useContext } from "react";
2
+ import { GaesupWorldContext } from "../../stores/context/gaesupworld";
3
+ import { pointType } from "../../stores/point/type";
4
+ import * as style from "./style.css";
5
+
6
+ export default function JumpPoint() {
7
+ const { points, refs } = useContext(GaesupWorldContext);
8
+
9
+ return (
10
+ <div className={style.jumpPoints}>
11
+ {refs &&
12
+ points.map((obj: pointType, key: number) => {
13
+ return (
14
+ <div
15
+ key={key}
16
+ className={style.jumpPoint}
17
+ onClick={() => {
18
+ refs.rigidBodyRef?.current?.setTranslation(obj.position, true);
19
+ }}
20
+ >
21
+ {obj.text}
22
+ </div>
23
+ );
24
+ })}
25
+ </div>
26
+ );
27
+ }
@@ -0,0 +1,33 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { mobileButton } from "../../../styles/recipe/button.css";
3
+ import { fixed, flex } from "../../../styles/recipe/index.css";
4
+
5
+ export const jumpPoints = style([
6
+ fixed({
7
+ north_east: true,
8
+ }),
9
+ flex({
10
+ column: "center",
11
+ }),
12
+ {
13
+ margin: "1rem",
14
+ zIndex: 1000,
15
+ },
16
+ ]);
17
+
18
+ export const jumpPoint = style([
19
+ mobileButton({}),
20
+ flex({}),
21
+ {
22
+ margin: "1rem",
23
+ fontSize: "0.8rem",
24
+ borderRadius: "50%",
25
+ width: "5rem",
26
+ height: "5rem",
27
+ color: "white",
28
+ background: "rgba(0, 0, 0, 0.6)",
29
+ boxShadow: "0 0 5px 0 rgba(0, 0, 0, 0.6)",
30
+ transition: "all 0.2s ease-in",
31
+ cursor: "pointer",
32
+ },
33
+ ]);
@@ -0,0 +1,144 @@
1
+ export type keyMapItemType = {
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
+ };
18
+
19
+ export const KeyboardF = {
20
+ ESC: { name: "ESC", gridRow: "1/2", gridColumn: "1/2" },
21
+ F1: { name: "F1", gridRow: "1/2", gridColumn: "3/4" },
22
+ F2: { name: "F2", gridRow: "1/2", gridColumn: "4/5" },
23
+ F3: { name: "F3", gridRow: "1/2", gridColumn: "5/6" },
24
+ F4: { name: "F4", gridRow: "1/2", gridColumn: "6/7" },
25
+ F5: { name: "F5", gridRow: "1/2", gridColumn: "8/9" },
26
+ F6: { name: "F6", gridRow: "1/2", gridColumn: "9/10" },
27
+ F7: { name: "F7", gridRow: "1/2", gridColumn: "10/11" },
28
+ F8: { name: "F8", gridRow: "1/2", gridColumn: "11/12" },
29
+ F9: { name: "F9", gridRow: "1/2", gridColumn: "13/14" },
30
+ F10: { name: "F10", gridRow: "1/2", gridColumn: "14/15" },
31
+ F11: { name: "F11", gridRow: "1/2", gridColumn: "15/16" },
32
+ F12: { name: "F12", gridRow: "1/2", gridColumn: "16/17" },
33
+ };
34
+
35
+ export const KeyboardOne = {
36
+ Backquote: { name: "`", gridRow: "2/3", gridColumn: "1/3" },
37
+ Digit1: { name: "1", gridRow: "2/3", gridColumn: "3/4" },
38
+ Digit2: { name: "2", gridRow: "2/3", gridColumn: "4/5" },
39
+ Digit3: { name: "3", gridRow: "2/3", gridColumn: "5/6" },
40
+ Digit4: { name: "4", gridRow: "2/3", gridColumn: "6/7" },
41
+ Digit5: { name: "5", gridRow: "2/3", gridColumn: "7/8" },
42
+ Digit6: { name: "6", gridRow: "2/3", gridColumn: "8/9" },
43
+ Digit7: { name: "7", gridRow: "2/3", gridColumn: "9/10" },
44
+ Digit8: { name: "8", gridRow: "2/3", gridColumn: "10/11" },
45
+ Digit9: { name: "9", gridRow: "2/3", gridColumn: "11/12" },
46
+ Digit0: { name: "0", gridRow: "2/3", gridColumn: "12/13" },
47
+ Minus: { name: "-", gridRow: "2/3", gridColumn: "13/14" },
48
+ Equal: { name: "=", gridRow: "2/3", gridColumn: "14/15" },
49
+ Backspace: { name: "Backspace", gridRow: "2/3", gridColumn: "15/17" },
50
+ };
51
+
52
+ export const KeyboardTwo = {
53
+ Tab: { name: "Tab", gridRow: "3/4", gridColumn: "1/3" },
54
+ KeyQ: { name: "Q", gridRow: "3/4", gridColumn: "3/4" },
55
+ KeyW: { name: "W", gridRow: "3/4", gridColumn: "4/5" },
56
+ KeyE: { name: "E", gridRow: "3/4", gridColumn: "5/6" },
57
+ KeyR: { name: "R", gridRow: "3/4", gridColumn: "6/7" },
58
+ KeyT: { name: "T", gridRow: "3/4", gridColumn: "7/8" },
59
+ KeyY: { name: "Y", gridRow: "3/4", gridColumn: "8/9" },
60
+ KeyU: { name: "U", gridRow: "3/4", gridColumn: "9/10" },
61
+ KeyI: { name: "I", gridRow: "3/4", gridColumn: "10/11" },
62
+ KeyO: { name: "O", gridRow: "3/4", gridColumn: "11/12" },
63
+ KeyP: { name: "P", gridRow: "3/4", gridColumn: "12/13" },
64
+ BracketLeft: { name: "[", gridRow: "3/4", gridColumn: "13/14" },
65
+ BracketRight: { name: "]", gridRow: "3/4", gridColumn: "14/15" },
66
+ Backslash: { name: "\\", gridRow: "3/4", gridColumn: "15/17" },
67
+ };
68
+
69
+ export const KeyboardThree = {
70
+ CapsLock: { name: "CapsLock", gridRow: "4/5", gridColumn: "1/3" },
71
+ KeyA: { name: "A", gridRow: "4/5", gridColumn: "3/4" },
72
+ KeyS: { name: "S", gridRow: "4/5", gridColumn: "4/5" },
73
+ KeyD: { name: "D", gridRow: "4/5", gridColumn: "5/6" },
74
+ KeyF: { name: "F", gridRow: "4/5", gridColumn: "6/7" },
75
+ KeyG: { name: "G", gridRow: "4/5", gridColumn: "7/8" },
76
+ KeyH: { name: "H", gridRow: "4/5", gridColumn: "8/9" },
77
+ KeyJ: { name: "J", gridRow: "4/5", gridColumn: "9/10" },
78
+ KeyK: { name: "K", gridRow: "4/5", gridColumn: "10/11" },
79
+ KeyL: { name: "L", gridRow: "4/5", gridColumn: "11/12" },
80
+ Semicolon: { name: ";", gridRow: "4/5", gridColumn: "12/13" },
81
+ Quote: { name: "'", gridRow: "4/5", gridColumn: "13/14" },
82
+ Enter: { name: "Enter", gridRow: "4/5", gridColumn: "14/17" },
83
+ };
84
+
85
+ export const KeyboardFour = {
86
+ ShiftLeft: {
87
+ name: "Shift",
88
+ gridRow: "5/6",
89
+ gridColumn: "1/4",
90
+ code: "Shift",
91
+ },
92
+ KeyZ: { name: "Z", gridRow: "5/6", gridColumn: "4/5" },
93
+ KeyX: { name: "X", gridRow: "5/6", gridColumn: "5/6" },
94
+ KeyC: { name: "C", gridRow: "5/6", gridColumn: "6/7" },
95
+ KeyV: { name: "V", gridRow: "5/6", gridColumn: "7/8" },
96
+ KeyB: { name: "B", gridRow: "5/6", gridColumn: "8/9" },
97
+ KeyN: { name: "N", gridRow: "5/6", gridColumn: "9/10" },
98
+ KeyM: { name: "M", gridRow: "5/6", gridColumn: "10/11" },
99
+ Comma: { name: ",", gridRow: "5/6", gridColumn: "11/12" },
100
+ Period: { name: ".", gridRow: "5/6", gridColumn: "12/13" },
101
+ Slash: { name: "/", gridRow: "5/6", gridColumn: "13/14" },
102
+ ShiftRight: {
103
+ name: "Shift",
104
+ gridRow: "5/6",
105
+ gridColumn: "14/17",
106
+ code: "Shift",
107
+ },
108
+ };
109
+
110
+ export const KeyboardFive = {
111
+ ControlLeft: {
112
+ name: "Control",
113
+ gridRow: "6/7",
114
+ gridColumn: "1/3",
115
+ code: "Control",
116
+ },
117
+ Option: { name: "Option", gridRow: "6/7", gridColumn: "3/5" },
118
+ AltLeft: { name: "Alt", gridRow: "6/7", gridColumn: "5/7", code: "Alt" },
119
+ Space: { name: "Space", gridRow: "6/7", gridColumn: "7/13" },
120
+ AltRight: { name: "Alt", gridRow: "6/7", gridColumn: "13/15", code: "Alt" },
121
+ ControlRight: {
122
+ name: "Control",
123
+ gridRow: "6/7",
124
+ gridColumn: "15/17",
125
+ code: "Control",
126
+ },
127
+ };
128
+
129
+ export const KeyboardArrow = {
130
+ ArrowUp: { name: "Up", gridRow: "5/6", gridColumn: "19/20" },
131
+ ArrowLeft: { name: "Left", gridRow: "6/7", gridColumn: "18/19" },
132
+ ArrowDown: { name: "Down", gridRow: "6/7", gridColumn: "19/20" },
133
+ ArrowRight: { name: "Right", gridRow: "6/7", gridColumn: "20/21" },
134
+ };
135
+
136
+ export const KeyBoardAll: keyBoardMapType = {
137
+ ...KeyboardF,
138
+ ...KeyboardOne,
139
+ ...KeyboardTwo,
140
+ ...KeyboardThree,
141
+ ...KeyboardFour,
142
+ ...KeyboardFive,
143
+ ...KeyboardArrow,
144
+ };
@@ -0,0 +1,85 @@
1
+ import { assignInlineVars } from "@vanilla-extract/dynamic";
2
+ import { useContext } from "react";
3
+ import { vars } from "../../../styles/theme.css";
4
+ import { GaesupWorldContext } from "../../stores/context/gaesupworld";
5
+ import { KeyBoardAll, keyArrayItemType } from "./constant";
6
+ import * as style from "./style.css";
7
+
8
+ export default function KeyBoardToolTip({
9
+ keyboardMap,
10
+ }: {
11
+ keyboardMap: {
12
+ name: string;
13
+ keys: string[];
14
+ }[];
15
+ }) {
16
+ const worldContext = useContext(GaesupWorldContext);
17
+ const { animations } = worldContext;
18
+
19
+ const keyArray = Object.entries(KeyBoardAll).reduce<keyArrayItemType[]>(
20
+ (keyArray, cur) => {
21
+ const [key, value] = cur;
22
+ const { gridRow, gridColumn, name } = value;
23
+ const keyBoardItem: keyArrayItemType = {
24
+ code: value.code || key,
25
+ gridRow,
26
+ gridColumn,
27
+ name,
28
+ };
29
+ keyArray.push(keyBoardItem);
30
+ return keyArray;
31
+ },
32
+ []
33
+ );
34
+
35
+ const codeToActionObj = keyboardMap.reduce((maps, keyboardMapItem) => {
36
+ keyboardMapItem.keys.forEach((key) => {
37
+ maps[key] = keyboardMapItem.name;
38
+ });
39
+ return maps;
40
+ }, {});
41
+
42
+ return (
43
+ <div className={style.keyBoardToolTip}>
44
+ <div className={style.keyBoardTooInner}>
45
+ {keyArray.map((item: keyArrayItemType, key: number) => {
46
+ let background = "rgba(0, 0, 0, 0.1)";
47
+ let boxShadow = "0 0 5px rgba(0, 0, 0, 0.2)";
48
+
49
+ if (codeToActionObj[item.code]) {
50
+ if (animations.keyControl[codeToActionObj[item.code]]) {
51
+ background = `${vars.gradient.green}`;
52
+ boxShadow = `0 0 10px rgba(99,251,215,1)`;
53
+ } else {
54
+ background = "rgba(0, 0, 0, 0.6)";
55
+ boxShadow = "0 0 10px rgba(0, 0, 0, 0.6)";
56
+ }
57
+ }
58
+ let color = "white";
59
+ if (
60
+ codeToActionObj[item.code] &&
61
+ animations.keyControl[codeToActionObj[item.code]]
62
+ ) {
63
+ color = "black";
64
+ }
65
+
66
+ return (
67
+ <div
68
+ className={style.keyCap}
69
+ style={assignInlineVars({
70
+ background,
71
+ boxShadow,
72
+ color,
73
+ gridRow: item.gridRow,
74
+ gridColumn: item.gridColumn,
75
+ })}
76
+ key={key}
77
+ >
78
+ {item.name}
79
+ </div>
80
+ );
81
+ })}
82
+ </div>
83
+ </div>
84
+ );
85
+ }
@@ -0,0 +1,49 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { fixed, flex } from "../../../styles/recipe/index.css";
3
+ import { sprinkles } from "../../../styles/sprinkles/index.css";
4
+
5
+ export const keyBoardToolTip = style([
6
+ fixed({
7
+ south: true,
8
+ }),
9
+ sprinkles({
10
+ display: {
11
+ mobile: "none",
12
+ tablet: "none",
13
+ laptop: "flex",
14
+ desktop: "flex",
15
+ },
16
+ }),
17
+ flex({
18
+ column: "6",
19
+ }),
20
+ {
21
+ width: "100vw",
22
+ },
23
+ ]);
24
+
25
+ export const keyBoardTooInner = style([
26
+ flex({}),
27
+ {
28
+ display: "grid",
29
+ gridTemplateColumns: "repeat(20, 2.5rem)",
30
+ gridTemplateRows: "repeat(10, 2.5rem)",
31
+ gap: "0.5rem",
32
+ width: "40rem",
33
+ height: "20rem",
34
+ },
35
+ ]);
36
+
37
+ export const keyCap = style([
38
+ flex({}),
39
+ {
40
+ fontSize: "0.8rem",
41
+ borderRadius: "5px",
42
+ width: "100%",
43
+ height: "100%",
44
+ color: "white",
45
+ background: "rgba(0, 0, 0, 0.2)",
46
+ boxShadow: "0 0 5px 0 rgba(0, 0, 0, 0.2)",
47
+ transition: "all 0.2s ease-in",
48
+ },
49
+ ]);
@@ -0,0 +1,47 @@
1
+ "use client";
2
+
3
+ import { assignInlineVars } from "@vanilla-extract/dynamic";
4
+ import { useContext } from "react";
5
+ import { GaesupWorldContext } from "../../stores/context/gaesupworld";
6
+ import * as style from "./style.css";
7
+
8
+ export function MiniMapInner() {
9
+ const { minimap, activeState } = useContext(GaesupWorldContext);
10
+
11
+ return (
12
+ <div className={style.minimap} style={minimap.minimapStyle || {}}>
13
+ <div className={style.minimapOuter} style={minimap.objectStyle || {}} />
14
+ <div className={style.minimapInner} style={minimap.innerStyle || {}}>
15
+ {Object.values(minimap.props).map((obj, key) => {
16
+ return (
17
+ <div
18
+ key={key}
19
+ className={style.minimapObject}
20
+ style={{
21
+ ...assignInlineVars({
22
+ width: `${obj.size.x}rem`,
23
+ height: `${obj.size.z}rem`,
24
+ transform: `translate(${
25
+ -obj.center.x + activeState.position.x * minimap.ratio
26
+ }rem, ${
27
+ -obj.center.z + activeState.position.z * minimap.ratio
28
+ }rem)`,
29
+ }),
30
+ ...minimap.objectStyle,
31
+ }}
32
+ >
33
+ <div className={style.text} style={minimap.textStyle}>
34
+ {obj.text}
35
+ </div>
36
+ </div>
37
+ );
38
+ })}
39
+ <div className={style.avatar} style={minimap.avatarStyle} />
40
+ </div>
41
+ </div>
42
+ );
43
+ }
44
+
45
+ export default function MiniMap() {
46
+ return <MiniMapInner />;
47
+ }