gaesup-world 0.0.61 → 0.0.63
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/README.md +101 -25
- package/dist/examples/select/platform/ControlledInput.js +8 -19
- package/dist/examples/select/platform/DynamicPlatforms.js +7 -7
- package/dist/examples/select/platform/FloatMove.js +8 -8
- package/dist/examples/select/platform/RoughPlane.js +3 -3
- package/dist/examples/select/platform/Slopes.js +6 -8
- package/dist/examples/select/platform/style.css.js +1 -1
- package/dist/examples/select/src/index.js +44 -66
- package/dist/examples/select/src/keyboardMap/character.js +2 -2
- package/dist/examples/select/src/keyboardMap/vehicle.js +1 -1
- package/dist/examples/select/src/style.css.js +5 -5
- package/dist/src/gaesup/animation/actions.js +29 -42
- package/dist/src/gaesup/animation/index.d.ts +1 -1
- package/dist/src/gaesup/animation/index.js +1 -1
- package/dist/src/gaesup/camera/cameraCollisionDetecter.js +2 -2
- package/dist/src/gaesup/camera/control/map.js +2 -2
- package/dist/src/gaesup/camera/control/normal.js +2 -2
- package/dist/src/gaesup/camera/control/orbit.js +2 -2
- package/dist/src/gaesup/camera/index.js +19 -28
- package/dist/src/gaesup/component/Airplane.js +2 -3
- package/dist/src/gaesup/component/Character.js +2 -3
- package/dist/src/gaesup/component/Vehicle.js +2 -3
- package/dist/src/gaesup/component/gltf/AirplaneGltf.js +4 -4
- package/dist/src/gaesup/component/gltf/CharacterGltf.js +10 -22
- package/dist/src/gaesup/component/gltf/VehicleGltf.js +4 -4
- package/dist/src/gaesup/component/gltf/WheelJoint.js +10 -11
- package/dist/src/gaesup/component/gltf/index.d.ts +4 -4
- package/dist/src/gaesup/component/gltf/index.js +4 -4
- package/dist/src/gaesup/component/index.d.ts +4 -4
- package/dist/src/gaesup/component/index.js +4 -4
- package/dist/src/gaesup/component/ref/airplane.js +12 -26
- package/dist/src/gaesup/component/ref/character.js +12 -27
- package/dist/src/gaesup/component/ref/index.d.ts +3 -3
- package/dist/src/gaesup/component/ref/index.js +3 -3
- package/dist/src/gaesup/component/ref/vehicle.js +10 -24
- package/dist/src/gaesup/component/setInit.js +2 -2
- package/dist/src/gaesup/controller/context/index.js +3 -14
- package/dist/src/gaesup/controller/context/reducer.js +2 -13
- package/dist/src/gaesup/controller/index.js +23 -34
- package/dist/src/gaesup/gaesupProps/index.js +15 -36
- package/dist/src/gaesup/index.d.ts +7 -7
- package/dist/src/gaesup/index.js +7 -7
- package/dist/src/gaesup/initial/callback/index.js +16 -26
- package/dist/src/gaesup/initial/controller/index.js +22 -34
- package/dist/src/gaesup/initial/controller/initDebug.js +2 -13
- package/dist/src/gaesup/initial/gaesupWorld/collider/airplane.js +4 -5
- package/dist/src/gaesup/initial/gaesupWorld/collider/character.js +13 -14
- package/dist/src/gaesup/initial/gaesupWorld/collider/gltf.js +16 -17
- package/dist/src/gaesup/initial/gaesupWorld/collider/index.js +4 -4
- package/dist/src/gaesup/initial/gaesupWorld/collider/vehicle.js +4 -5
- package/dist/src/gaesup/initial/gaesupWorld/index.js +8 -19
- package/dist/src/gaesup/physics/airplane/currentSetting.js +2 -13
- package/dist/src/gaesup/physics/airplane/damping.js +1 -1
- package/dist/src/gaesup/physics/airplane/direction.js +16 -16
- package/dist/src/gaesup/physics/airplane/gravity.js +1 -1
- package/dist/src/gaesup/physics/airplane/impulse.js +4 -4
- package/dist/src/gaesup/physics/airplane/turn.js +1 -1
- package/dist/src/gaesup/physics/character/accelaration.js +4 -4
- package/dist/src/gaesup/physics/character/currentSetting.js +2 -13
- package/dist/src/gaesup/physics/character/damping.js +1 -1
- package/dist/src/gaesup/physics/character/direction.js +11 -13
- package/dist/src/gaesup/physics/character/impulse.js +5 -5
- package/dist/src/gaesup/physics/character/jump.js +3 -3
- package/dist/src/gaesup/physics/character/stabilizing.js +1 -1
- package/dist/src/gaesup/physics/character/turn.js +2 -2
- package/dist/src/gaesup/physics/check/ground.js +1 -1
- package/dist/src/gaesup/physics/check/moving.js +2 -2
- package/dist/src/gaesup/physics/check/rotate.js +1 -1
- package/dist/src/gaesup/physics/check/slope.js +3 -3
- package/dist/src/gaesup/physics/index.js +13 -19
- package/dist/src/gaesup/physics/vehicle/currentSetting.js +2 -13
- package/dist/src/gaesup/physics/vehicle/damping.js +3 -3
- package/dist/src/gaesup/physics/vehicle/direction.js +6 -6
- package/dist/src/gaesup/physics/vehicle/impulse.js +7 -7
- package/dist/src/gaesup/physics/vehicle/turn.js +1 -1
- package/dist/src/gaesup/styles.css.js +2 -2
- package/dist/src/gaesup/tools/context.js +2 -2
- package/dist/src/gaesup/tools/gameboy/GameBoyButton.js +8 -9
- package/dist/src/gaesup/tools/gameboy/default.js +1 -1
- package/dist/src/gaesup/tools/gameboy/index.js +3 -3
- package/dist/src/gaesup/tools/gameboy/style.css.js +3 -3
- package/dist/src/gaesup/tools/gamepad/GamePadButton.js +8 -9
- package/dist/src/gaesup/tools/gamepad/default.js +1 -1
- package/dist/src/gaesup/tools/gamepad/index.js +8 -10
- package/dist/src/gaesup/tools/gamepad/style.css.js +3 -3
- package/dist/src/gaesup/tools/index.js +7 -8
- package/dist/src/gaesup/tools/joystick/default.js +15 -26
- package/dist/src/gaesup/tools/joystick/index.js +108 -107
- package/dist/src/gaesup/tools/joystick/style.css.js +5 -5
- package/dist/src/gaesup/tools/jumpPoint/index.js +3 -3
- package/dist/src/gaesup/tools/jumpPoint/style.css.js +2 -2
- package/dist/src/gaesup/tools/keyBoardToolTip/constant.js +8 -19
- package/dist/src/gaesup/tools/keyBoardToolTip/default.js +2 -2
- package/dist/src/gaesup/tools/keyBoardToolTip/index.js +22 -33
- package/dist/src/gaesup/tools/keyBoardToolTip/style.css.js +3 -3
- package/dist/src/gaesup/tools/minimap/default.js +2 -2
- package/dist/src/gaesup/tools/minimap/index.js +18 -29
- package/dist/src/gaesup/tools/minimap/style.css.js +12 -12
- package/dist/src/gaesup/tools/pushKey/index.js +5 -16
- package/dist/src/gaesup/tools/reducer.js +2 -13
- package/dist/src/gaesup/tools/style.css.js +3 -3
- package/dist/src/gaesup/utils/constant.js +1 -1
- package/dist/src/gaesup/utils/ray.js +2 -3
- package/dist/src/gaesup/utils/ref.js +3 -4
- package/dist/src/gaesup/world/context/index.js +4 -4
- package/dist/src/gaesup/world/context/reducer.js +2 -13
- package/dist/src/gaesup/world/index.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/styles/constants/boxshadow.css.js +2 -2
- package/dist/src/styles/constants/constant.css.js +6 -6
- package/dist/src/styles/constants/direction.css.js +3 -3
- package/dist/src/styles/constants/flex.css.js +6 -6
- package/dist/src/styles/constants/gradient.css.js +1 -1
- package/dist/src/styles/constants/grid.css.js +4 -15
- package/dist/src/styles/constants/palette.css.js +26 -26
- package/dist/src/styles/constants/translate.css.js +4 -15
- package/dist/src/styles/recipe/base.css.js +6 -6
- package/dist/src/styles/recipe/button.css.js +4 -4
- package/dist/src/styles/recipe/index.css.js +20 -31
- package/dist/src/styles/recipe/input.css.js +1 -1
- package/dist/src/styles/sprinkles/color.css.js +4 -15
- package/dist/src/styles/sprinkles/direction.css.js +2 -13
- package/dist/src/styles/sprinkles/display.css.js +1 -1
- package/dist/src/styles/sprinkles/fontSize.css.js +2 -13
- package/dist/src/styles/sprinkles/grid.css.js +1 -1
- package/dist/src/styles/sprinkles/index.css.js +1 -1
- package/dist/src/styles/sprinkles/margin.css.js +2 -13
- package/dist/src/styles/sprinkles/padding.css.js +2 -13
- package/dist/src/styles/sprinkles/position.css.js +1 -1
- package/dist/src/styles/sprinkles/size.css.js +2 -13
- package/dist/src/styles/theme.css.js +4 -15
- package/index.ts +7 -1
- package/lib/index.ts +10 -0
- package/package.json +3 -13
- package/src/gaesup/animation/index.ts +1 -1
- package/src/gaesup/component/gltf/index.ts +4 -4
- package/src/gaesup/component/gltf/type.ts +1 -1
- package/src/gaesup/component/index.ts +4 -4
- package/src/gaesup/component/ref/index.ts +8 -3
- package/src/gaesup/index.ts +7 -7
- package/src/gaesup/initial/gaesupWorld/collider/gltf.ts +8 -2
- package/src/gaesup/tools/gamepad/index.tsx +1 -1
- package/src/gaesup/tools/joystick/index.tsx +358 -129
- package/src/gaesup/tools/joystick/style.css.ts +2 -2
- package/src/gaesup/world/context/index.ts +8 -8
- package/src/gaesup/world/context/type.ts +1 -1
- package/src/index.ts +7 -1
- package/tsconfig.json +4 -3
package/README.md
CHANGED
|
@@ -2,50 +2,126 @@
|
|
|
2
2
|
|
|
3
3
|
Web 3D Character Controller and World Platform Library
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/zustand)
|
|
6
|
+
[](https://www.npmjs.com/package/gaesup-world)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
@react-three/drei
|
|
9
|
-
three @types/three
|
|
10
|
-
@react-three/rapier
|
|
8
|
+
---
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
## introduction
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
Gaesup World is a library that uses @react/three-fiber, @react/three-drei, and rapier to provide control tools for characters, airplanes, cars, and more in a web 3D environment. This controller is designed to easily manage character movement, animation, and interaction. It allows for easy manipulation of characters or vehicles in a virtual world, and is also equipped with utilities like minimaps and joysticks.
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
### Features
|
|
17
15
|
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
16
|
+
- 3D character control based on React Three Fiber.
|
|
17
|
+
- Simple API for controlling character movement and animation.
|
|
18
|
+
- Extensible structure for various customizations.
|
|
19
|
+
- Lightweight library for fast loading and performance optimization.
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
### Installation
|
|
24
22
|
|
|
25
23
|
```bash
|
|
26
24
|
npm install @react-three/fiber @react-three/drei three @types/three @react-three/rapier gaesup-world
|
|
27
25
|
```
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
Or
|
|
30
28
|
|
|
31
29
|
```bash
|
|
32
30
|
yarn add @react-three/fiber @react-three/drei three @types/three @react-three/rapier gaesup-world
|
|
33
31
|
```
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
### Documentation
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
it is detailed usage methods and API documentation
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
- [how to contribute](#how-to-contribute)
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
### How to Contribute
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
2. 새로운 Feature 브랜치를 생성합니다 (`git checkout -b feature/AmazingFeature`).
|
|
45
|
-
3. 변경사항을 Commit합니다 (`git commit -m 'Add some AmazingFeature'`).
|
|
46
|
-
4. 브랜치에 Push합니다 (`git push origin feature/AmazingFeature`).
|
|
47
|
-
5. Pull Request를 생성합니다.
|
|
41
|
+
If you would like to contribute to this project, please follow these steps:
|
|
48
42
|
|
|
49
|
-
|
|
43
|
+
1. Fork the project.
|
|
44
|
+
2. Create a new Feature branch (`git checkout -b feature/AmazingFeature`).
|
|
45
|
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`).
|
|
46
|
+
4. Push to the branch (`git push origin feature/AmazingFeature`).
|
|
47
|
+
5. Create a Pull Request.
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
### License
|
|
50
|
+
|
|
51
|
+
This project is distributed under the MIT License.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Controller
|
|
56
|
+
|
|
57
|
+
#### [Controller](#controller)
|
|
58
|
+
|
|
59
|
+
- [Character](#character)
|
|
60
|
+
- [Vehicle](#vehicle)
|
|
61
|
+
- [Airplane](#airplane)
|
|
62
|
+
|
|
63
|
+
## Character
|
|
64
|
+
|
|
65
|
+
This is the character control in Gaesup World.
|
|
66
|
+
|
|
67
|
+
- Possible Camera Types
|
|
68
|
+
|
|
69
|
+
| Name | Camera | Control | Info |
|
|
70
|
+
| ------ | ------------------- | ------------- | --------------------------------------------------------------------------------------------- |
|
|
71
|
+
| Normal | Perspective Camera | Orbit Control | Positioned parallel to the Z-axis from the character's location and not affected by rotation. |
|
|
72
|
+
| Orbit | Perspective Camera | Orbit Control | Moves with the character and rotates according to the character's direction. |
|
|
73
|
+
| Map | Orthographic Camera | Map Control | A top-down control view. |
|
|
74
|
+
|
|
75
|
+
- Controller Tools
|
|
76
|
+
|
|
77
|
+
| Name | Info |
|
|
78
|
+
| -------- | ----------------------------------------------------------------------- |
|
|
79
|
+
| Keyboard | A standard keyboard tool. You can see where on the keyboard is clicked. |
|
|
80
|
+
| Joystick | A joystick implementation tool. It works on mobile devices. |
|
|
81
|
+
| Gameboy | A Gameboy implementation tool. It works on mobile devices. |
|
|
82
|
+
|
|
83
|
+
## Vehicle
|
|
84
|
+
|
|
85
|
+
This is the vehicle control in Gaesup World. Characters can board the vehicle.
|
|
86
|
+
|
|
87
|
+
- Possible Camera Types
|
|
88
|
+
|
|
89
|
+
| Name | Camera | Control | Info |
|
|
90
|
+
| ------ | ------------------- | ------------- | --------------------------------------------------------------------------------------------- |
|
|
91
|
+
| Normal | Perspective Camera | Orbit Control | Positioned parallel to the Z-axis from the character's location and not affected by rotation. |
|
|
92
|
+
| Orbit | Perspective Camera | Orbit Control | Moves with the character and rotates according to the character's direction. |
|
|
93
|
+
| Map | Orthographic Camera | Map Control | A top-down control view. |
|
|
94
|
+
|
|
95
|
+
- Controller Tools
|
|
96
|
+
|
|
97
|
+
| Name | Info |
|
|
98
|
+
| -------- | ----------------------------------------------------------------------- |
|
|
99
|
+
| Keyboard | A standard keyboard tool. You can see where on the keyboard is clicked. |
|
|
100
|
+
| Joystick | A joystick implementation tool. It works on mobile devices. |
|
|
101
|
+
| Gameboy | A Gameboy implementation tool. It works on mobile devices. |
|
|
102
|
+
|
|
103
|
+
## Airplane
|
|
104
|
+
|
|
105
|
+
This is the airplane control in Gaesup World. Characters can board the airplane.
|
|
106
|
+
|
|
107
|
+
- Possible Camera Types
|
|
108
|
+
|
|
109
|
+
| Name | Camera | Control | Info |
|
|
110
|
+
| ------ | ------------------- | ------------- | --------------------------------------------------------------------------------------------- |
|
|
111
|
+
| Normal | Perspective Camera | Orbit Control | Positioned parallel to the Z-axis from the character's location and not affected by rotation. |
|
|
112
|
+
| Orbit | Perspective Camera | Orbit Control | Moves with the character and rotates according to the character's direction. |
|
|
113
|
+
| Map | Orthographic Camera | Map Control | A top-down control view. |
|
|
114
|
+
|
|
115
|
+
- Controller Tools
|
|
116
|
+
|
|
117
|
+
| Name | Info |
|
|
118
|
+
| -------- | ----------------------------------------------------------------------- |
|
|
119
|
+
| Keyboard | A standard keyboard tool. You can see where on the keyboard is clicked. |
|
|
120
|
+
| Joystick | A joystick implementation tool. It works on mobile devices. |
|
|
121
|
+
| Gameboy | A Gameboy implementation tool. It works on mobile devices. |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Tools
|
|
126
|
+
|
|
127
|
+
#### [Tools](#tools)
|
|
@@ -1,14 +1,3 @@
|
|
|
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
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
2
|
var t = {};
|
|
14
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -23,18 +12,18 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
13
|
import { useEffect, useRef, useState } from "react";
|
|
25
14
|
import * as style from "./style.css";
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
useEffect(
|
|
31
|
-
|
|
15
|
+
export const ControlledInput = (props) => {
|
|
16
|
+
const { value, onChange } = props, rest = __rest(props, ["value", "onChange"]);
|
|
17
|
+
const [cursor, setCursor] = useState(null);
|
|
18
|
+
const ref = useRef(null);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const input = ref.current;
|
|
32
21
|
if (input)
|
|
33
22
|
input.setSelectionRange(cursor, cursor);
|
|
34
23
|
}, [ref, cursor, value]);
|
|
35
|
-
|
|
24
|
+
const handleChange = (e) => {
|
|
36
25
|
setCursor(e.target.selectionStart);
|
|
37
26
|
onChange && onChange(e);
|
|
38
27
|
};
|
|
39
|
-
return (_jsx("input",
|
|
28
|
+
return (_jsx("input", Object.assign({ ref: ref, value: value, onChange: handleChange }, rest, { className: style.input })));
|
|
40
29
|
};
|
|
@@ -7,12 +7,12 @@ import { useMemo, useRef } from "react";
|
|
|
7
7
|
import GaeSupProps from "../../../src/gaesup/gaesupProps";
|
|
8
8
|
import { Qt, V3 } from "../../../src/gaesup/utils/vector";
|
|
9
9
|
export default function DynamicPlatforms() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const sideMovePlatformRef = useRef(null);
|
|
11
|
+
const verticalMovePlatformRef = useRef(null);
|
|
12
|
+
const rotatePlatformRef = useRef(null);
|
|
13
|
+
const rotationDrumRef = useRef(null);
|
|
14
14
|
// Initializ animation settings
|
|
15
|
-
|
|
15
|
+
const dynamic = useMemo(() => {
|
|
16
16
|
return {
|
|
17
17
|
time: null,
|
|
18
18
|
X: V3(1, 0, 0),
|
|
@@ -20,10 +20,10 @@ export default function DynamicPlatforms() {
|
|
|
20
20
|
Qt: Qt(),
|
|
21
21
|
};
|
|
22
22
|
}, []);
|
|
23
|
-
useFrame(
|
|
23
|
+
useFrame((state) => {
|
|
24
24
|
var _a, _b, _c, _d, _e;
|
|
25
25
|
dynamic.time = state.clock.elapsedTime;
|
|
26
|
-
|
|
26
|
+
const { time, Qt, X, Y } = dynamic;
|
|
27
27
|
if (dynamic.time) {
|
|
28
28
|
// Move platform
|
|
29
29
|
(_a = sideMovePlatformRef.current) === null || _a === void 0 ? void 0 : _a.setNextKinematicTranslation({
|
|
@@ -5,10 +5,10 @@ import { useEffect, useMemo, useRef } from "react";
|
|
|
5
5
|
import GaeSupProps from "../../../src/gaesup/gaesupProps";
|
|
6
6
|
export default function FloatMove() {
|
|
7
7
|
// Preset
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const cuboidColliderRef = useRef(null);
|
|
9
|
+
const rigidBodyRef = useRef(null);
|
|
10
|
+
const { rapier, world } = useRapier();
|
|
11
|
+
const ray = useMemo(() => {
|
|
12
12
|
return {
|
|
13
13
|
origin: vec3(),
|
|
14
14
|
dir: vec3({ x: 0, y: -1, z: 0 }),
|
|
@@ -22,14 +22,14 @@ export default function FloatMove() {
|
|
|
22
22
|
};
|
|
23
23
|
}, []);
|
|
24
24
|
ray.rayCast = new rapier.Ray(ray.origin, ray.dir);
|
|
25
|
-
|
|
26
|
-
useEffect(
|
|
25
|
+
let movingDir = 1;
|
|
26
|
+
useEffect(() => {
|
|
27
27
|
if (rigidBodyRef.current) {
|
|
28
28
|
rigidBodyRef.current.setEnabledRotations(false, true, false, false);
|
|
29
29
|
rigidBodyRef.current.setEnabledTranslations(true, true, false, false);
|
|
30
30
|
}
|
|
31
31
|
}, []);
|
|
32
|
-
useFrame(
|
|
32
|
+
useFrame(() => {
|
|
33
33
|
// Ray cast for moving platform
|
|
34
34
|
if (rigidBodyRef.current && ray.rayCast && cuboidColliderRef.current) {
|
|
35
35
|
ray.origin.set(rigidBodyRef.current.translation().x, rigidBodyRef.current.translation().y, rigidBodyRef.current.translation().z);
|
|
@@ -51,7 +51,7 @@ export default function FloatMove() {
|
|
|
51
51
|
// Ray for moving platform
|
|
52
52
|
if (ray.hit && rigidBodyRef.current) {
|
|
53
53
|
if (ray.hit.collider.parent()) {
|
|
54
|
-
|
|
54
|
+
const floatingForceMove = 2.5 * (0.8 - ray.hit.toi) - rigidBodyRef.current.linvel().y * 0.15;
|
|
55
55
|
rigidBodyRef.current.applyImpulse(vec3().set(0, floatingForceMove, 0), true);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -7,9 +7,9 @@ import * as THREE from "three";
|
|
|
7
7
|
import GaeSupProps from "../../../src/gaesup/gaesupProps";
|
|
8
8
|
import { S3 } from "../../../src/gaesup/utils/constant";
|
|
9
9
|
export default function RoughPlane() {
|
|
10
|
-
|
|
11
|
-
useEffect(
|
|
12
|
-
roughPlane.scene.traverse(
|
|
10
|
+
const roughPlane = useGLTF(S3 + "/roughPlane.glb");
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
roughPlane.scene.traverse((child) => {
|
|
13
13
|
if (child instanceof THREE.Mesh &&
|
|
14
14
|
child.material instanceof THREE.MeshStandardMaterial) {
|
|
15
15
|
child.receiveShadow = true;
|
|
@@ -9,19 +9,17 @@ import { S3 } from "../../../src/gaesup/utils/constant";
|
|
|
9
9
|
import { ControlledInput } from "./ControlledInput";
|
|
10
10
|
export default function Slopes() {
|
|
11
11
|
// Load models
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
useEffect(
|
|
12
|
+
const slopes = useGLTF(S3 + "/slopes.glb");
|
|
13
|
+
const [angle, setAngle] = useState(25);
|
|
14
|
+
const rigidBodyRef = useRef(null);
|
|
15
|
+
useEffect(() => {
|
|
16
16
|
// Receive Shadows
|
|
17
|
-
slopes.scene.traverse(
|
|
17
|
+
slopes.scene.traverse((child) => {
|
|
18
18
|
if (child instanceof THREE.Mesh &&
|
|
19
19
|
child.material instanceof THREE.MeshStandardMaterial) {
|
|
20
20
|
child.receiveShadow = true;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
}, []);
|
|
24
|
-
return (_jsxs(GaeSupProps, { text: "Slopes", jumpPoint: true, position: [-15, -0.8, 15], children: [_jsx(RigidBody, { type: "fixed", colliders: "hull", ref: rigidBodyRef, rotation: [-(angle * Math.PI) / 180, 0, 0], children: _jsxs("mesh", { receiveShadow: true, castShadow: true, children: [_jsx("boxGeometry", { args: [10, 1, 10] }), _jsx("meshBasicMaterial", { transparent: true, opacity: 0.9 })] }) }), _jsx(Html, { zIndexRange: [1, 0], children: _jsx(ControlledInput, { type: angle, onChange:
|
|
25
|
-
return setAngle(e.target.value);
|
|
26
|
-
}, value: angle }) })] }));
|
|
24
|
+
return (_jsxs(GaeSupProps, { text: "Slopes", jumpPoint: true, position: [-15, -0.8, 15], children: [_jsx(RigidBody, { type: "fixed", colliders: "hull", ref: rigidBodyRef, rotation: [-(angle * Math.PI) / 180, 0, 0], children: _jsxs("mesh", { receiveShadow: true, castShadow: true, children: [_jsx("boxGeometry", { args: [10, 1, 10] }), _jsx("meshBasicMaterial", { transparent: true, opacity: 0.9 })] }) }), _jsx(Html, { zIndexRange: [1, 0], children: _jsx(ControlledInput, { type: angle, onChange: (e) => setAngle(e.target.value), value: angle }) })] }));
|
|
27
25
|
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
3
|
import { Environment, KeyboardControls } from "@react-three/drei";
|
|
15
4
|
import { Canvas } from "@react-three/fiber";
|
|
@@ -26,7 +15,7 @@ import RigidObjects from "../platform/RigidObjects";
|
|
|
26
15
|
import RoughPlane from "../platform/RoughPlane";
|
|
27
16
|
import * as style from "./style.css";
|
|
28
17
|
import { button } from "./style.css";
|
|
29
|
-
export
|
|
18
|
+
export const keyboardMap = [
|
|
30
19
|
{ name: "forward", keys: ["ArrowUp", "KeyW"] },
|
|
31
20
|
{ name: "backward", keys: ["ArrowDown", "KeyS"] },
|
|
32
21
|
{ name: "leftward", keys: ["ArrowLeft", "KeyA"] },
|
|
@@ -36,92 +25,81 @@ export var keyboardMap = [
|
|
|
36
25
|
{ name: "keyZ", keys: ["KeyZ"] },
|
|
37
26
|
];
|
|
38
27
|
export default function Selected() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
const CHARACTER_URL = "./gaesupyee.glb";
|
|
29
|
+
const AIRPLANE_URL = "./airplane.glb";
|
|
30
|
+
const VEHICLE_URL = S3 + "/kart2.glb";
|
|
31
|
+
const [mode, changeMode] = useState({
|
|
43
32
|
type: "character",
|
|
44
33
|
controller: isMobile ? "joystick" : "joystick",
|
|
45
|
-
})
|
|
46
|
-
|
|
34
|
+
});
|
|
35
|
+
const [camera, changeCamera] = useState({
|
|
47
36
|
cameraType: "perspective",
|
|
48
37
|
controlType: "orbit",
|
|
49
|
-
})
|
|
50
|
-
return (_jsxs(GaesupWorld, { debug: true, mode:
|
|
38
|
+
});
|
|
39
|
+
return (_jsxs(GaesupWorld, { debug: true, mode: Object.assign({}, mode), url: {
|
|
51
40
|
characterUrl: CHARACTER_URL,
|
|
52
41
|
vehicleUrl: VEHICLE_URL,
|
|
53
42
|
airplaneUrl: AIRPLANE_URL,
|
|
54
43
|
}, children: [_jsx(GaeSupTools, {}), _jsxs("div", { className: style.mainButtonContainer, children: [_jsx("button", { className: button({
|
|
55
44
|
selected: mode.type === "character",
|
|
56
|
-
}), onClick:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}); });
|
|
61
|
-
}, children: "CHARACTER" }), _jsx("button", { className: button({
|
|
45
|
+
}), onClick: () => changeMode((mode) => ({
|
|
46
|
+
type: "character",
|
|
47
|
+
controller: mode.controller,
|
|
48
|
+
})), children: "CHARACTER" }), _jsx("button", { className: button({
|
|
62
49
|
selected: mode.type === "vehicle",
|
|
63
|
-
}), onClick:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}); });
|
|
68
|
-
}, children: "VEHICLE" }), _jsx("button", { className: button({
|
|
50
|
+
}), onClick: () => changeMode((mode) => ({
|
|
51
|
+
type: "vehicle",
|
|
52
|
+
controller: mode.controller,
|
|
53
|
+
})), children: "VEHICLE" }), _jsx("button", { className: button({
|
|
69
54
|
selected: mode.type === "airplane",
|
|
70
|
-
}), onClick:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}); });
|
|
75
|
-
}, children: "AIRPLANE" }), _jsx("button", { className: button({
|
|
55
|
+
}), onClick: () => changeMode((mode) => ({
|
|
56
|
+
type: "airplane",
|
|
57
|
+
controller: mode.controller,
|
|
58
|
+
})), children: "AIRPLANE" }), _jsx("button", { className: button({
|
|
76
59
|
selected: camera.controlType === "normal",
|
|
77
|
-
}), onClick:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}); });
|
|
82
|
-
}, children: "NORMAL" }), _jsx("button", { className: button({
|
|
60
|
+
}), onClick: () => changeCamera(() => ({
|
|
61
|
+
cameraType: "perspective",
|
|
62
|
+
controlType: "normal",
|
|
63
|
+
})), children: "NORMAL" }), _jsx("button", { className: button({
|
|
83
64
|
selected: camera.controlType === "orbit" &&
|
|
84
65
|
camera.cameraType === "perspective",
|
|
85
|
-
}), onClick:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}); });
|
|
90
|
-
}, children: "ORBIT" }), _jsx("button", { className: button({
|
|
66
|
+
}), onClick: () => changeCamera(() => ({
|
|
67
|
+
cameraType: "perspective",
|
|
68
|
+
controlType: "orbit",
|
|
69
|
+
})), children: "ORBIT" }), _jsx("button", { className: button({
|
|
91
70
|
selected: camera.cameraType === "orthographic",
|
|
92
|
-
}), onClick:
|
|
93
|
-
changeCamera(
|
|
71
|
+
}), onClick: () => {
|
|
72
|
+
changeCamera(() => ({
|
|
94
73
|
cameraType: "orthographic",
|
|
95
74
|
controlType: "orbit",
|
|
96
|
-
})
|
|
75
|
+
}));
|
|
97
76
|
}, children: "MAP" }), !isMobile && (_jsx("button", { className: button({
|
|
98
77
|
selected: mode.controller === "keyboard",
|
|
99
|
-
}), onClick:
|
|
100
|
-
changeMode(
|
|
78
|
+
}), onClick: () => {
|
|
79
|
+
changeMode((mode) => ({
|
|
101
80
|
type: mode.type,
|
|
102
81
|
controller: "keyboard",
|
|
103
|
-
})
|
|
82
|
+
}));
|
|
104
83
|
}, children: "\uD0A4\uBCF4\uB4DC" })), _jsx("button", { className: button({
|
|
105
84
|
selected: mode.controller === "joystick",
|
|
106
|
-
}), onClick:
|
|
107
|
-
changeMode(
|
|
85
|
+
}), onClick: () => {
|
|
86
|
+
changeMode((mode) => ({
|
|
108
87
|
type: mode.type,
|
|
109
88
|
controller: "joystick",
|
|
110
|
-
})
|
|
89
|
+
}));
|
|
111
90
|
}, children: "\uC870\uC774\uC2A4\uD2F1" }), _jsx("button", { className: button({
|
|
112
91
|
selected: mode.controller === "gameboy",
|
|
113
|
-
}), onClick:
|
|
114
|
-
changeMode(
|
|
92
|
+
}), onClick: () => {
|
|
93
|
+
changeMode((mode) => ({
|
|
115
94
|
type: mode.type,
|
|
116
95
|
controller: "gameboy",
|
|
117
|
-
})
|
|
118
|
-
}, children: "\uAC8C\uC784\uBCF4\uC774" })] }), _jsxs(Canvas, { shadows: true, dpr: [1, 2], style: { width: "100dvw", height: "100dvh" }, children: [_jsx(Environment, { background: true, preset: "sunset", blur: 0.8 }), _jsx("directionalLight", { castShadow: true, "shadow-normalBias": 0.06, position: [20, 30, 10], intensity: 0.5, "shadow-mapSize": [1024, 1024], "shadow-camera-near": 1, "shadow-camera-far": 50, "shadow-camera-top": 50, "shadow-camera-right": 50, "shadow-camera-bottom": -50, "shadow-camera-left": -50 }), _jsx("ambientLight", { intensity: 0.5 }), _jsxs(Physics, { debug: true, children: [_jsx(KeyboardControls, { map: keyboardMap, children: _jsx(GaesupController, { isRider: mode.type === "vehicle" ? true : false, cameraMode:
|
|
96
|
+
}));
|
|
97
|
+
}, children: "\uAC8C\uC784\uBCF4\uC774" })] }), _jsxs(Canvas, { shadows: true, dpr: [1, 2], style: { width: "100dvw", height: "100dvh" }, children: [_jsx(Environment, { background: true, preset: "sunset", blur: 0.8 }), _jsx("directionalLight", { castShadow: true, "shadow-normalBias": 0.06, position: [20, 30, 10], intensity: 0.5, "shadow-mapSize": [1024, 1024], "shadow-camera-near": 1, "shadow-camera-far": 50, "shadow-camera-top": 50, "shadow-camera-right": 50, "shadow-camera-bottom": -50, "shadow-camera-left": -50 }), _jsx("ambientLight", { intensity: 0.5 }), _jsxs(Physics, { debug: true, children: [_jsx(KeyboardControls, { map: keyboardMap, children: _jsx(GaesupController, { isRider: mode.type === "vehicle" ? true : false, cameraMode: Object.assign({}, camera), orthographicCamera: {
|
|
119
98
|
zoom: 80,
|
|
120
99
|
}, groupProps: {
|
|
121
100
|
rotation: [0, Math.PI, 0],
|
|
122
|
-
}, onAnimate:
|
|
123
|
-
|
|
124
|
-
var keyZ = control.keyZ;
|
|
101
|
+
}, onAnimate: ({ control, states, playAnimation }) => {
|
|
102
|
+
const { keyZ } = control;
|
|
125
103
|
if (keyZ) {
|
|
126
104
|
states.isAnimationOuter = true;
|
|
127
105
|
playAnimation("greet");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const characterKeyboardMap = [
|
|
2
2
|
{ name: "forward", keys: ["ArrowUp", "KeyW"] },
|
|
3
3
|
{ name: "backward", keys: ["ArrowDown", "KeyS"] },
|
|
4
4
|
{ name: "leftward", keys: ["ArrowLeft", "KeyA"] },
|
|
@@ -7,7 +7,7 @@ export var characterKeyboardMap = [
|
|
|
7
7
|
{ name: "run", keys: ["Shift"] },
|
|
8
8
|
{ name: "greet", keys: ["KeyZ"] },
|
|
9
9
|
];
|
|
10
|
-
export
|
|
10
|
+
export const vehicleKeyboardMap = [
|
|
11
11
|
{ name: "forward", keys: ["ArrowUp", "KeyW"] },
|
|
12
12
|
{ name: "backward", keys: ["ArrowDown", "KeyS"] },
|
|
13
13
|
{ name: "leftward", keys: ["ArrowLeft", "KeyA"] },
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { fontFace, style } from "@vanilla-extract/css";
|
|
2
2
|
import { recipe } from "@vanilla-extract/recipes";
|
|
3
3
|
import { vars } from "../../../src/styles/theme.css";
|
|
4
|
-
|
|
4
|
+
const BlackHanSans = fontFace({
|
|
5
5
|
src: 'local("/public/fonts/BlackHanSans-Regular.ttf")',
|
|
6
6
|
});
|
|
7
|
-
export
|
|
7
|
+
export const blackHanSans = style({
|
|
8
8
|
fontFamily: BlackHanSans,
|
|
9
9
|
});
|
|
10
|
-
export
|
|
10
|
+
export const main = style([
|
|
11
11
|
{
|
|
12
12
|
display: "flex",
|
|
13
13
|
flexDirection: "column",
|
|
@@ -18,7 +18,7 @@ export var main = style([
|
|
|
18
18
|
fontFamily: blackHanSans,
|
|
19
19
|
},
|
|
20
20
|
]);
|
|
21
|
-
export
|
|
21
|
+
export const mainButtonContainer = style([
|
|
22
22
|
{
|
|
23
23
|
position: "fixed",
|
|
24
24
|
zIndex: 100,
|
|
@@ -30,7 +30,7 @@ export var mainButtonContainer = style([
|
|
|
30
30
|
gridTemplateRows: "repeat(3, 1fr)",
|
|
31
31
|
},
|
|
32
32
|
]);
|
|
33
|
-
export
|
|
33
|
+
export const button = recipe({
|
|
34
34
|
base: [
|
|
35
35
|
{
|
|
36
36
|
boxSizing: "border-box",
|