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
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import { animationTagType, groundRayType } from "../controller/type";
|
|
|
5
5
|
import {
|
|
6
6
|
GaesupWorldContext,
|
|
7
7
|
GaesupWorldDispatchContext,
|
|
8
|
-
} from "../
|
|
8
|
+
} from "../world/context";
|
|
9
9
|
|
|
10
10
|
export type playActionsType = {
|
|
11
11
|
outerGroupRef: RefObject<THREE.Group>;
|
|
@@ -11,6 +11,6 @@ export default function normal(prop: cameraPropType) {
|
|
|
11
11
|
.clone()
|
|
12
12
|
.add(V3(perspectiveCamera.XZDistance, perspectiveCamera.YDistance, 0));
|
|
13
13
|
|
|
14
|
-
state.camera.position.lerp(cameraPosition,
|
|
14
|
+
state.camera.position.lerp(cameraPosition, 1);
|
|
15
15
|
state.camera.lookAt(activeState.position.clone());
|
|
16
16
|
}
|
|
@@ -17,7 +17,7 @@ export default function orbit(prop: cameraPropType) {
|
|
|
17
17
|
.add(V3(0, perspectiveCamera.YDistance, 0))
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
-
state.camera.position.lerp(cameraPosition, 0.
|
|
20
|
+
state.camera.position.lerp(cameraPosition, 0.5);
|
|
21
21
|
state.camera.quaternion.copy(
|
|
22
22
|
activeState.quat
|
|
23
23
|
.clone()
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
import { useFrame, useThree } from "@react-three/fiber";
|
|
8
8
|
import { useContext } from "react";
|
|
9
9
|
import * as THREE from "three";
|
|
10
|
+
import { GaesupControllerContext } from "../controller/context";
|
|
10
11
|
import { propType, refsType } from "../controller/type";
|
|
11
12
|
import { cameraPropType } from "../physics/type";
|
|
12
|
-
import {
|
|
13
|
-
import { GaesupWorldContext } from "../stores/context/gaesupworld";
|
|
13
|
+
import { GaesupWorldContext } from "../world/context";
|
|
14
14
|
import cameraCollisionDetector from "./cameraCollisionDetecter";
|
|
15
15
|
import mapControl from "./control/map";
|
|
16
16
|
import normal from "./control/normal";
|
|
@@ -34,7 +34,7 @@ export default function Camera({
|
|
|
34
34
|
const { rigidBodyRef, outerGroupRef } = refs;
|
|
35
35
|
const { cameraRay } = prop;
|
|
36
36
|
const { checkCollision } = cameraCollisionDetector(prop);
|
|
37
|
-
const { scene
|
|
37
|
+
const { scene } = useThree();
|
|
38
38
|
const { activeState } = worldContext;
|
|
39
39
|
|
|
40
40
|
const intersectObjectMap: { [uuid: string]: THREE.Object3D } = {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ref, forwardRef, useContext } from "react";
|
|
2
|
-
import { GaesupWorldContext } from "../../
|
|
2
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
3
3
|
|
|
4
4
|
export const AirplaneInnerGroupRef = forwardRef((_, ref: Ref<THREE.Group>) => {
|
|
5
5
|
const { airplaneGltf: gltf } = useContext(GaesupWorldContext);
|
|
@@ -4,7 +4,7 @@ import playActions from "../../animation/actions";
|
|
|
4
4
|
import { groundRayType, propType, refsType } from "../../controller/type";
|
|
5
5
|
import initCallback from "../../initial/callback";
|
|
6
6
|
import { callbackType } from "../../initial/callback/type";
|
|
7
|
-
import { GaesupWorldContext } from "../../
|
|
7
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
8
8
|
|
|
9
9
|
export type characterGltfType = {
|
|
10
10
|
prop: propType;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ref, forwardRef, useContext } from "react";
|
|
2
|
-
import { GaesupWorldContext } from "../../
|
|
2
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
3
3
|
|
|
4
4
|
export const VehicleInnerGroupRef = forwardRef((_, ref: Ref<THREE.Group>) => {
|
|
5
5
|
const { vehicleGltf: gltf } = useContext(GaesupWorldContext);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RapierRigidBody } from "@react-three/rapier";
|
|
2
2
|
import { createRef, useContext, useRef } from "react";
|
|
3
3
|
import { propType } from "../../controller/type";
|
|
4
|
-
import { GaesupWorldContext } from "../../
|
|
4
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
5
5
|
import { WheelRegidBodyRef } from "../ref/vehicle";
|
|
6
6
|
|
|
7
7
|
export function Wheels({ prop }: { prop: propType }) {
|
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
import { ReactNode, Ref, forwardRef, useContext } from "react";
|
|
10
10
|
import * as THREE from "three";
|
|
11
11
|
import { controllerType, groundRayType, propType } from "../../controller/type";
|
|
12
|
-
import { GaesupWorldContext } from "../../stores/context/gaesupworld";
|
|
13
12
|
import { getRayHit } from "../../utils/ray";
|
|
14
13
|
import { useForwardRef } from "../../utils/ref";
|
|
14
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
15
15
|
|
|
16
16
|
export const AirplaneRigidBody = forwardRef(
|
|
17
17
|
(
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
propType,
|
|
16
16
|
slopeRayType,
|
|
17
17
|
} from "../../controller/type";
|
|
18
|
-
import { GaesupWorldContext } from "../../stores/context/gaesupworld";
|
|
19
18
|
import { getRayHit } from "../../utils/ray";
|
|
20
19
|
import { useForwardRef } from "../../utils/ref";
|
|
20
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
21
21
|
|
|
22
22
|
export const CharacterRigidBody = forwardRef(
|
|
23
23
|
(
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
import { ReactNode, Ref, RefObject, forwardRef, useContext } from "react";
|
|
11
11
|
import * as THREE from "three";
|
|
12
12
|
import { controllerType, propType } from "../../controller/type";
|
|
13
|
-
import { GaesupWorldContext } from "../../stores/context/gaesupworld";
|
|
14
13
|
import { S3 } from "../../utils/constant";
|
|
14
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
15
15
|
|
|
16
16
|
export const VehicleRigidBody = forwardRef(
|
|
17
17
|
(
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { RapierRigidBody } from "@react-three/rapier";
|
|
2
2
|
import { RefObject, useContext, useEffect } from "react";
|
|
3
|
-
import { GaesupWorldContext } from "../stores/context/gaesupworld";
|
|
4
3
|
import { V3 } from "../utils/vector";
|
|
4
|
+
import { GaesupWorldContext } from "../world/context";
|
|
5
5
|
|
|
6
6
|
export default function setInit(rigidBodyRef: RefObject<RapierRigidBody>) {
|
|
7
7
|
const { activeState } = useContext(GaesupWorldContext);
|
|
8
8
|
useEffect(() => {
|
|
9
9
|
rigidBodyRef.current?.setTranslation(
|
|
10
|
-
activeState.position.add(V3(0,
|
|
10
|
+
activeState.position.add(V3(0, 1, 0)),
|
|
11
11
|
false
|
|
12
12
|
);
|
|
13
13
|
}, []);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
|
-
|
|
3
|
-
import { dispatchType } from "
|
|
2
|
+
|
|
3
|
+
import { dispatchType } from "../../tools/type";
|
|
4
|
+
import { V3 } from "../../utils/vector";
|
|
4
5
|
import {
|
|
5
6
|
gaesupControllerType,
|
|
6
7
|
orthographicCameraType,
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
import { OrthographicCameraProps } from "@react-three/fiber";
|
|
1
|
+
import { GroupProps, OrthographicCameraProps } from "@react-three/fiber";
|
|
2
2
|
import { Dispatch } from "react";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
export interface airplaneType extends GroupProps {
|
|
5
|
+
angleChange?: THREE.Vector3;
|
|
6
|
+
maxAngle?: THREE.Vector3;
|
|
7
|
+
maxSpeed?: number;
|
|
8
|
+
accelRatio?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface vehicleType extends GroupProps {
|
|
12
|
+
angleChange?: THREE.Vector3;
|
|
13
|
+
maxAngle?: THREE.Vector3;
|
|
14
|
+
maxSpeed?: number;
|
|
15
|
+
accelRatio?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface characterType extends GroupProps {
|
|
19
|
+
angleChange?: THREE.Vector3;
|
|
20
|
+
maxAngle?: THREE.Vector3;
|
|
21
|
+
maxSpeed?: number;
|
|
22
|
+
accelRatio?: number;
|
|
23
|
+
}
|
|
4
24
|
|
|
5
25
|
export type perspectiveCameraType = {
|
|
6
26
|
cameraType?: "perspective";
|
|
@@ -8,13 +8,14 @@ import { Airplane } from "../component/Airplane";
|
|
|
8
8
|
import { Character } from "../component/Character";
|
|
9
9
|
import { Vehicle } from "../component/Vehicle";
|
|
10
10
|
import initControllerProps from "../initial/controller";
|
|
11
|
+
|
|
12
|
+
import { GaesupWorldContext } from "../world/context";
|
|
11
13
|
import {
|
|
12
14
|
GaesupControllerContext,
|
|
13
15
|
GaesupControllerDispatchContext,
|
|
14
16
|
gaesupControllerDefault,
|
|
15
|
-
} from "
|
|
16
|
-
import { gaesupControllerReducer } from "
|
|
17
|
-
import { GaesupWorldContext } from "../stores/context/gaesupworld";
|
|
17
|
+
} from "./context";
|
|
18
|
+
import { gaesupControllerReducer } from "./context/reducer";
|
|
18
19
|
import { controllerType, propType, refsType } from "./type";
|
|
19
20
|
|
|
20
21
|
export default function GaesupController(props: controllerType) {
|
|
@@ -11,17 +11,15 @@ import * as THREE from "three";
|
|
|
11
11
|
import { cameraRayType } from "../camera/type";
|
|
12
12
|
import { callbackType } from "../initial/callback/type";
|
|
13
13
|
|
|
14
|
+
import { keyControlType } from "../world/context/type";
|
|
14
15
|
import {
|
|
15
16
|
airplaneType,
|
|
16
17
|
characterType,
|
|
17
|
-
vehicleType,
|
|
18
|
-
} from "../stores/airplane/type";
|
|
19
|
-
import {
|
|
20
18
|
gaesupCameraOptionType,
|
|
21
19
|
gaesupCameraPropType,
|
|
22
20
|
perspectiveCameraPropType,
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
vehicleType,
|
|
22
|
+
} from "./context/type";
|
|
25
23
|
|
|
26
24
|
export type constantType = {
|
|
27
25
|
jumpSpeed: number;
|
|
@@ -7,7 +7,7 @@ import { animationTagType } from "../../controller/type";
|
|
|
7
7
|
import {
|
|
8
8
|
GaesupWorldContext,
|
|
9
9
|
GaesupWorldDispatchContext,
|
|
10
|
-
} from "../../
|
|
10
|
+
} from "../../world/context";
|
|
11
11
|
import { callbackPropType, initCallbackType } from "./type";
|
|
12
12
|
|
|
13
13
|
export default function initCallback({
|
|
@@ -7,10 +7,12 @@ import {
|
|
|
7
7
|
propType,
|
|
8
8
|
slopeRayType,
|
|
9
9
|
} from "../../controller/type";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
import {
|
|
11
|
+
activeStateType,
|
|
12
|
+
animationPropType,
|
|
13
|
+
keyControlType,
|
|
14
|
+
statesType,
|
|
15
|
+
} from "../../world/context/type";
|
|
14
16
|
|
|
15
17
|
export type initCallbackType = {
|
|
16
18
|
prop: propType;
|
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
refsType,
|
|
10
10
|
slopeRayType,
|
|
11
11
|
} from "../../controller/type";
|
|
12
|
+
|
|
12
13
|
import {
|
|
13
14
|
GaesupWorldContext,
|
|
14
15
|
GaesupWorldDispatchContext,
|
|
15
|
-
} from "../../
|
|
16
|
-
import { keyControlType } from "../../
|
|
16
|
+
} from "../../world/context";
|
|
17
|
+
import { keyControlType } from "../../world/context/type";
|
|
17
18
|
import initDebug from "./initDebug";
|
|
18
19
|
|
|
19
20
|
export default function initControllerProps({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch } from "react";
|
|
2
|
-
import { gaesupWorldPropType } from "../../../
|
|
2
|
+
import { gaesupWorldPropType } from "../../../world/context/type";
|
|
3
3
|
import { innerColliderPropType } from "../type";
|
|
4
4
|
import { airplane } from "./airplane";
|
|
5
5
|
import { character } from "./character";
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { useMemo, useReducer } from "react";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
airplaneColliderDefault,
|
|
6
|
-
characterColliderDefault,
|
|
7
|
-
vehicleColliderDefault,
|
|
8
|
-
} from "../../stores/collider";
|
|
9
|
-
import { modeDefault } from "../../stores/context/gaesupworld";
|
|
10
|
-
import { gaesupReducer } from "../../stores/context/gaesupworld/reducer";
|
|
11
|
-
import { controlDefault } from "../../stores/control";
|
|
12
|
-
import { gameboyDefault } from "../../stores/gameboy";
|
|
13
|
-
import { joyStickDefault } from "../../stores/joystick";
|
|
14
|
-
import { minimapDefault } from "../../stores/minimap";
|
|
15
|
-
import { statesDefault } from "../../stores/states";
|
|
16
|
-
import { urlDefault } from "../../stores/url";
|
|
17
|
-
import { V3 } from "../../utils/vector";
|
|
1
|
+
import { useEffect, useMemo, useReducer } from "react";
|
|
2
|
+
|
|
3
|
+
import { gaesupWorldDefault } from "../../world/context";
|
|
4
|
+
import { gaesupWorldReducer } from "../../world/context/reducer";
|
|
18
5
|
import initColider from "./collider";
|
|
19
6
|
import { initGaesupWorldPropsType } from "./type";
|
|
20
7
|
|
|
21
8
|
export default function initGaesupWorld(props: initGaesupWorldPropsType) {
|
|
22
|
-
const [value, dispatch] = useReducer(
|
|
23
|
-
activeState:
|
|
24
|
-
...activeStateDefault,
|
|
25
|
-
...{ position: props.startPosition || V3(0, 2, 5) },
|
|
26
|
-
},
|
|
9
|
+
const [value, dispatch] = useReducer(gaesupWorldReducer, {
|
|
10
|
+
activeState: gaesupWorldDefault.activeState,
|
|
27
11
|
characterCollider: Object.assign(
|
|
28
|
-
|
|
12
|
+
gaesupWorldDefault.characterCollider,
|
|
29
13
|
props.characterCollider || {}
|
|
30
14
|
),
|
|
31
15
|
vehicleCollider: Object.assign(
|
|
32
|
-
|
|
16
|
+
gaesupWorldDefault.vehicleCollider,
|
|
33
17
|
props.vehicleCollider || {}
|
|
34
18
|
),
|
|
35
19
|
airplaneCollider: Object.assign(
|
|
36
|
-
|
|
20
|
+
gaesupWorldDefault.airplaneCollider,
|
|
37
21
|
props.airplaneCollider || {}
|
|
38
22
|
),
|
|
39
|
-
mode: Object.assign(
|
|
40
|
-
url: Object.assign(
|
|
23
|
+
mode: Object.assign(gaesupWorldDefault.mode, props.mode || {}),
|
|
24
|
+
url: Object.assign(gaesupWorldDefault.url, props.url || {}),
|
|
41
25
|
characterGltf: null,
|
|
42
26
|
vehicleGltf: null,
|
|
43
27
|
wheelGltf: null,
|
|
44
28
|
airplaneGltf: null,
|
|
45
|
-
states:
|
|
29
|
+
states: gaesupWorldDefault.states,
|
|
46
30
|
debug: false,
|
|
47
|
-
minimap:
|
|
48
|
-
joystick:
|
|
49
|
-
|
|
50
|
-
control: controlDefault,
|
|
31
|
+
minimap: gaesupWorldDefault.minimap,
|
|
32
|
+
joystick: gaesupWorldDefault.joystick,
|
|
33
|
+
control: gaesupWorldDefault.control,
|
|
51
34
|
points: [],
|
|
52
35
|
refs: null,
|
|
53
|
-
animations:
|
|
36
|
+
animations: gaesupWorldDefault.animations,
|
|
54
37
|
});
|
|
55
38
|
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const keyboard = props.keyBoardMap.reduce((maps, keyboardMapItem) => {
|
|
41
|
+
maps[keyboardMapItem.name] = false;
|
|
42
|
+
return maps;
|
|
43
|
+
}, {});
|
|
44
|
+
const assignedControl = Object.assign(value.control, keyboard);
|
|
45
|
+
|
|
46
|
+
dispatch({
|
|
47
|
+
type: "update",
|
|
48
|
+
payload: {
|
|
49
|
+
control: {
|
|
50
|
+
...assignedControl,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
56
|
const gaesupProps = useMemo(
|
|
57
57
|
() => ({ value, dispatch }),
|
|
58
58
|
[
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { Dispatch, ReactNode } from "react";
|
|
2
|
+
import { joyStickInnerType } from "../../tools/joystick/type";
|
|
3
|
+
import { minimapInnerType } from "../../tools/minimap/type";
|
|
4
|
+
import { keyboardMapType } from "../../tools/type";
|
|
2
5
|
import {
|
|
3
6
|
airplaneColliderType,
|
|
4
7
|
characterColliderType,
|
|
5
|
-
vehicleColliderType,
|
|
6
|
-
} from "../../stores/collider";
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
gaesupControllerPropType,
|
|
10
8
|
gaesupWorldPartialPropType,
|
|
11
9
|
gaesupWorldPropType,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import { urlType } from "../../stores/url/type";
|
|
10
|
+
modeType,
|
|
11
|
+
urlType,
|
|
12
|
+
vehicleColliderType,
|
|
13
|
+
} from "../../world/context/type";
|
|
17
14
|
import { getGltfResultType } from "./collider/gltf";
|
|
18
15
|
|
|
19
16
|
export type initGaesupWorldPropsType = {
|
|
@@ -24,11 +21,11 @@ export type initGaesupWorldPropsType = {
|
|
|
24
21
|
characterCollider?: characterColliderType;
|
|
25
22
|
vehicleCollider?: vehicleColliderType;
|
|
26
23
|
airplaneCollider?: airplaneColliderType;
|
|
27
|
-
mode?:
|
|
24
|
+
mode?: modeType;
|
|
28
25
|
debug?: boolean;
|
|
29
|
-
minimap?: Omit<
|
|
30
|
-
joystick?:
|
|
31
|
-
|
|
26
|
+
minimap?: Omit<minimapInnerType, "props">;
|
|
27
|
+
joystick?: joyStickInnerType;
|
|
28
|
+
keyBoardMap?: keyboardMapType;
|
|
32
29
|
};
|
|
33
30
|
|
|
34
31
|
export type innerColliderPropType = {
|
|
@@ -12,8 +12,6 @@ export default function direction(prop: calcPropType) {
|
|
|
12
12
|
const { forward, backward, leftward, rightward, shift, space } = control;
|
|
13
13
|
const { angleChange, maxAngle, accelRatio } = airplane;
|
|
14
14
|
|
|
15
|
-
console.log(Number(joystick.joyStickOrigin.isUp));
|
|
16
|
-
|
|
17
15
|
let boost = 0;
|
|
18
16
|
if (mode.controller === "joystick") {
|
|
19
17
|
boost = space
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { RootState } from "@react-three/fiber";
|
|
2
|
-
import { activeStateType } from "../../stores/active/type";
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
import { joyStickType } from "../../stores/joystick/type";
|
|
3
|
+
import { joyStickInnerType } from "../../tools/joystick/type";
|
|
6
4
|
import { V3 } from "../../utils/vector";
|
|
5
|
+
import { activeStateType, modeType } from "../../world/context/type";
|
|
7
6
|
import { calcPropType } from "../type";
|
|
8
7
|
|
|
9
8
|
export function joystickDirection() {}
|
|
@@ -17,8 +16,8 @@ export function orbitDirection({
|
|
|
17
16
|
}: {
|
|
18
17
|
state: RootState;
|
|
19
18
|
activeState: activeStateType;
|
|
20
|
-
mode:
|
|
21
|
-
joystick:
|
|
19
|
+
mode: modeType;
|
|
20
|
+
joystick: joyStickInnerType;
|
|
22
21
|
control: {
|
|
23
22
|
[key: string]: boolean;
|
|
24
23
|
};
|
|
@@ -26,8 +25,9 @@ export function orbitDirection({
|
|
|
26
25
|
const { forward, backward, leftward, rightward } = control;
|
|
27
26
|
let start = 0;
|
|
28
27
|
if (mode.controller === "joystick") {
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
if (!joystick.joyStickOrigin.isCenter)
|
|
29
|
+
activeState.euler.y =
|
|
30
|
+
-state.camera.rotation.y - joystick.joyStickOrigin.angle - Math.PI / 2;
|
|
31
31
|
start = joystick.joyStickOrigin.isOn ? 1 : 0;
|
|
32
32
|
} else {
|
|
33
33
|
activeState.euler.y +=
|
|
@@ -50,8 +50,8 @@ export function normalDirection({
|
|
|
50
50
|
}: {
|
|
51
51
|
state: RootState;
|
|
52
52
|
activeState: activeStateType;
|
|
53
|
-
mode:
|
|
54
|
-
joystick:
|
|
53
|
+
mode: modeType;
|
|
54
|
+
joystick: joyStickInnerType;
|
|
55
55
|
control: {
|
|
56
56
|
[key: string]: boolean;
|
|
57
57
|
};
|
|
@@ -59,8 +59,9 @@ export function normalDirection({
|
|
|
59
59
|
const { forward, backward, leftward, rightward } = control;
|
|
60
60
|
let start = 0;
|
|
61
61
|
if (mode.controller === "joystick") {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
if (!joystick.joyStickOrigin.isCenter)
|
|
63
|
+
activeState.euler.y =
|
|
64
|
+
-state.camera.rotation.y - joystick.joyStickOrigin.angle - Math.PI / 2;
|
|
64
65
|
start = joystick.joyStickOrigin.isOn ? 1 : 0;
|
|
65
66
|
} else {
|
|
66
67
|
if (forward) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { useFrame } from "@react-three/fiber";
|
|
2
|
-
|
|
3
1
|
import { useContext } from "react";
|
|
4
2
|
import { propType } from "../controller/type";
|
|
5
3
|
|
|
6
4
|
import { useRapier } from "@react-three/rapier";
|
|
7
|
-
import { GaesupControllerContext } from "../
|
|
5
|
+
import { GaesupControllerContext } from "../controller/context";
|
|
6
|
+
|
|
7
|
+
import { useFrame } from "@react-three/fiber";
|
|
8
8
|
import {
|
|
9
9
|
GaesupWorldContext,
|
|
10
10
|
GaesupWorldDispatchContext,
|
|
11
|
-
} from "../
|
|
11
|
+
} from "../world/context";
|
|
12
12
|
import airplaneCalculation from "./airplane";
|
|
13
13
|
import characterCalculation from "./character";
|
|
14
14
|
import check from "./check";
|
|
@@ -21,6 +21,7 @@ export default function calculation(prop: propType) {
|
|
|
21
21
|
const controllerContext = useContext(GaesupControllerContext);
|
|
22
22
|
const dispatch = useContext(GaesupWorldDispatchContext);
|
|
23
23
|
const { mode } = worldContext;
|
|
24
|
+
|
|
24
25
|
useFrame((state, delta) => {
|
|
25
26
|
const { rigidBodyRef, outerGroupRef, innerGroupRef } = prop;
|
|
26
27
|
if (
|
|
@@ -2,11 +2,8 @@ import { RootState } from "@react-three/fiber";
|
|
|
2
2
|
import { propType } from "../controller/type";
|
|
3
3
|
|
|
4
4
|
import { World } from "@dimforge/rapier3d-compat";
|
|
5
|
-
import { gaesupControllerType } from "../
|
|
6
|
-
import {
|
|
7
|
-
gaesupDisptachType,
|
|
8
|
-
gaesupWorldPropType,
|
|
9
|
-
} from "../stores/context/gaesupworld/type";
|
|
5
|
+
import { gaesupControllerType } from "../controller/context/type";
|
|
6
|
+
import { dispatchType, gaesupWorldPropType } from "../world/context/type";
|
|
10
7
|
|
|
11
8
|
export type SetAtom<Args extends unknown[], Result> = (...args: Args) => Result;
|
|
12
9
|
|
|
@@ -16,7 +13,7 @@ export type calcPropType = propType & {
|
|
|
16
13
|
worldContext?: gaesupWorldPropType;
|
|
17
14
|
controllerContext?: gaesupControllerType;
|
|
18
15
|
delta?: number;
|
|
19
|
-
dispatch?:
|
|
16
|
+
dispatch?: dispatchType<gaesupWorldPropType>;
|
|
20
17
|
world: World;
|
|
21
18
|
};
|
|
22
19
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
import { dispatchType, gaesupToolsPropType } from "./type";
|
|
3
|
+
|
|
4
|
+
export const GaesupToolsContext = createContext<gaesupToolsPropType>(null);
|
|
5
|
+
export const GaesupToolsDispatchContext =
|
|
6
|
+
createContext<dispatchType<gaesupToolsPropType>>(null);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { usePushKey } from "
|
|
2
|
+
import { GaesupToolsContext } from "../context";
|
|
3
|
+
import { usePushKey } from "../pushKey";
|
|
4
4
|
import * as style from "./style.css";
|
|
5
5
|
|
|
6
6
|
export type gameBoyButtonType = {
|
|
@@ -10,7 +10,9 @@ export type gameBoyButtonType = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export default function GameBoyButton({ tag, value, icon }: gameBoyButtonType) {
|
|
13
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
gameboy: { gameboyButtonStyle },
|
|
15
|
+
} = useContext(GaesupToolsContext);
|
|
14
16
|
|
|
15
17
|
const { pushKey } = usePushKey();
|
|
16
18
|
|
|
@@ -36,7 +38,7 @@ export default function GameBoyButton({ tag, value, icon }: gameBoyButtonType) {
|
|
|
36
38
|
}}
|
|
37
39
|
onPointerDown={() => onMouseDown()}
|
|
38
40
|
onPointerUp={() => onMouseLeave()}
|
|
39
|
-
style={
|
|
41
|
+
style={gameboyButtonStyle}
|
|
40
42
|
>
|
|
41
43
|
{icon}
|
|
42
44
|
</button>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { GaesupToolsContext } from "../context";
|
|
3
3
|
import GameBoyButton, { gameBoyButtonType } from "./GameBoyButton";
|
|
4
4
|
import * as style from "./style.css";
|
|
5
5
|
|
|
@@ -15,10 +15,12 @@ export const GameBoyDirections = [
|
|
|
15
15
|
];
|
|
16
16
|
|
|
17
17
|
export default function GameBoy() {
|
|
18
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
gameboy: { gameboyStyle, gameboyInnerStyle },
|
|
20
|
+
} = useContext(GaesupToolsContext);
|
|
19
21
|
return (
|
|
20
|
-
<div className={style.gameBoy} style={
|
|
21
|
-
<div className={style.gameBoyInner} style={
|
|
22
|
+
<div className={style.gameBoy} style={gameboyStyle}>
|
|
23
|
+
<div className={style.gameBoyInner} style={gameboyInnerStyle}>
|
|
22
24
|
{GameBoyDirections.map((item: gameBoyButtonType, key: number) => {
|
|
23
25
|
return (
|
|
24
26
|
<GameBoyButton
|
|
@@ -14,7 +14,7 @@ export const gameBoy = style([
|
|
|
14
14
|
south: true,
|
|
15
15
|
}),
|
|
16
16
|
flex({
|
|
17
|
-
column: "
|
|
17
|
+
column: "7",
|
|
18
18
|
}),
|
|
19
19
|
{
|
|
20
20
|
width: "100%",
|
|
@@ -26,7 +26,7 @@ export const gameBoyInner = style([
|
|
|
26
26
|
row: "center",
|
|
27
27
|
}),
|
|
28
28
|
{
|
|
29
|
-
margin: "
|
|
29
|
+
margin: "5rem",
|
|
30
30
|
padding: "1rem",
|
|
31
31
|
borderRadius: "50%",
|
|
32
32
|
gridTemplateColumns: "1fr 1fr 1fr",
|