gaesup-world 0.0.1 → 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/index.html +1 -0
- package/package.json +3 -1
- package/src/gaesup/animation/actions.ts +1 -1
- package/src/gaesup/camera/control/normal.ts +2 -1
- package/src/gaesup/camera/control/orbit.ts +1 -1
- package/src/gaesup/camera/index.tsx +4 -4
- package/src/gaesup/component/Airplane.tsx +23 -17
- package/src/gaesup/component/Character.tsx +16 -6
- package/src/gaesup/component/Vehicle.tsx +20 -17
- package/src/gaesup/component/gltf/AirplaneGltf.tsx +1 -1
- package/src/gaesup/component/gltf/CharacterGltf.tsx +74 -59
- package/src/gaesup/component/gltf/VehicleGltf.tsx +5 -5
- package/src/gaesup/component/gltf/WheelJoint.tsx +1 -1
- package/src/gaesup/component/ref/airplane.tsx +26 -12
- package/src/gaesup/component/ref/character.tsx +18 -13
- package/src/gaesup/component/ref/vehicle.tsx +24 -47
- package/src/gaesup/component/setInit.ts +14 -0
- package/src/gaesup/{stores/context/controller → controller/context}/index.ts +22 -4
- package/src/gaesup/{stores/context/controller → controller/context}/type.ts +26 -1
- package/src/gaesup/controller/index.tsx +25 -5
- package/src/gaesup/controller/type.ts +13 -2
- 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 +17 -3
- package/src/gaesup/initial/gaesupWorld/collider/index.ts +1 -1
- package/src/gaesup/initial/gaesupWorld/index.ts +33 -32
- package/src/gaesup/initial/gaesupWorld/type.ts +11 -10
- package/src/gaesup/physics/airplane/damping.ts +2 -4
- package/src/gaesup/physics/airplane/direction.ts +56 -47
- package/src/gaesup/physics/airplane/impulse.ts +11 -5
- package/src/gaesup/physics/airplane/turn.ts +0 -1
- package/src/gaesup/physics/character/direction.ts +13 -13
- package/src/gaesup/physics/check/moving.ts +2 -3
- package/src/gaesup/physics/index.ts +9 -9
- package/src/gaesup/physics/type.ts +3 -9
- package/src/gaesup/physics/vehicle/damping.ts +5 -1
- package/src/gaesup/physics/vehicle/direction.ts +35 -14
- package/src/gaesup/physics/vehicle/impulse.ts +20 -3
- package/src/gaesup/tools/context.ts +6 -0
- package/src/gaesup/tools/gameboy/GameBoyButton.tsx +9 -1
- package/src/gaesup/tools/gameboy/default.ts +3 -0
- package/src/gaesup/tools/gameboy/index.tsx +11 -10
- package/src/gaesup/tools/gameboy/style.css.ts +20 -2
- package/src/gaesup/tools/gameboy/type.ts +8 -0
- 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 +21 -24
- 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} +12 -8
- package/src/gaesup/tools/joystick/index.tsx +113 -58
- package/src/gaesup/tools/joystick/style.css.ts +13 -4
- package/src/gaesup/tools/joystick/type.ts +32 -0
- package/src/gaesup/tools/jumpPoint/index.tsx +2 -2
- package/src/gaesup/tools/jumpPoint/style.css.ts +3 -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 +45 -14
- package/src/gaesup/tools/minimap/style.css.ts +1 -1
- 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/camera/control/normal copy.ts +0 -19
- package/src/gaesup/physics/airplane copy/currentSetting.ts +0 -20
- package/src/gaesup/physics/airplane copy/direction.ts +0 -52
- package/src/gaesup/physics/airplane copy/gravity.ts +0 -6
- package/src/gaesup/physics/airplane copy/impulse.ts +0 -28
- package/src/gaesup/physics/airplane copy/index.tsx +0 -14
- package/src/gaesup/physics/airplane copy/turn.ts +0 -9
- 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 -6
- package/src/gaesup/stores/airplane/type.ts +0 -4
- 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 -66
- package/src/gaesup/stores/control/type.ts +0 -11
- package/src/gaesup/stores/joystick/type.ts +0 -23
- 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/index.html
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gaesup-world",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://jigglypop.github.io/gaesup-world/",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
8
9
|
"prepare": "rm -rf dist && tsc",
|
|
9
10
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
10
11
|
"preview": "vite preview",
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
"@types/three": "^0.158.1",
|
|
26
27
|
"@types/uuid": "^9.0.6",
|
|
27
28
|
"@uiw/react-md-editor": "3.25.2",
|
|
29
|
+
"@use-gesture/react": "^10.3.0",
|
|
28
30
|
"@vanilla-extract/babel-plugin": "^1.2.0",
|
|
29
31
|
"@vanilla-extract/css": "^1.13.0",
|
|
30
32
|
"@vanilla-extract/css-utils": "^0.1.3",
|
|
@@ -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>;
|
|
@@ -10,6 +10,7 @@ export default function normal(prop: cameraPropType) {
|
|
|
10
10
|
const cameraPosition = activeState.position
|
|
11
11
|
.clone()
|
|
12
12
|
.add(V3(perspectiveCamera.XZDistance, perspectiveCamera.YDistance, 0));
|
|
13
|
+
|
|
13
14
|
state.camera.position.lerp(cameraPosition, 1);
|
|
14
|
-
state.camera.lookAt(activeState.position);
|
|
15
|
+
state.camera.lookAt(activeState.position.clone());
|
|
15
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,13 +7,13 @@ 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
|
-
import normal from "./control/normal
|
|
16
|
+
import normal from "./control/normal";
|
|
17
17
|
import orbit from "./control/orbit";
|
|
18
18
|
|
|
19
19
|
export default function Camera({
|
|
@@ -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 } = {};
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
import { propType, refsType } from "../controller/type";
|
|
4
4
|
import calculation from "../physics";
|
|
5
5
|
import { AirplaneInnerGroupRef } from "./gltf/AirplaneGltf";
|
|
6
|
+
import { CharacterInnerGroupRef } from "./gltf/CharacterGltf";
|
|
6
7
|
import {
|
|
7
8
|
AirplaneCollider,
|
|
8
9
|
AirplaneGroup,
|
|
9
10
|
AirplaneRigidBody,
|
|
10
11
|
} from "./ref/airplane";
|
|
12
|
+
import setInit from "./setInit";
|
|
11
13
|
|
|
12
14
|
export function Airplane({
|
|
13
15
|
controllerProps,
|
|
@@ -16,28 +18,32 @@ export function Airplane({
|
|
|
16
18
|
controllerProps: propType;
|
|
17
19
|
refs: refsType;
|
|
18
20
|
}) {
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
+
const {
|
|
22
|
+
rigidBodyRef,
|
|
23
|
+
outerGroupRef,
|
|
24
|
+
capsuleColliderRef,
|
|
25
|
+
innerGroupRef,
|
|
26
|
+
characterInnerRef,
|
|
27
|
+
} = refs;
|
|
21
28
|
calculation(controllerProps);
|
|
29
|
+
setInit(rigidBodyRef);
|
|
22
30
|
|
|
23
31
|
return (
|
|
24
32
|
<>
|
|
25
|
-
<AirplaneGroup ref={outerGroupRef}>
|
|
26
|
-
<AirplaneRigidBody
|
|
27
|
-
ref={rigidBodyRef}
|
|
28
|
-
groundRay={controllerProps.groundRay}
|
|
29
|
-
>
|
|
33
|
+
<AirplaneGroup ref={outerGroupRef} controllerProps={controllerProps}>
|
|
34
|
+
<AirplaneRigidBody ref={rigidBodyRef} controllerProps={controllerProps}>
|
|
30
35
|
<AirplaneCollider prop={controllerProps} ref={capsuleColliderRef} />
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
{controllerProps.isRider && (
|
|
37
|
+
<CharacterInnerGroupRef
|
|
38
|
+
prop={controllerProps}
|
|
39
|
+
groupProps={controllerProps.groupProps}
|
|
40
|
+
groundRay={controllerProps.groundRay}
|
|
41
|
+
refs={refs}
|
|
42
|
+
callbacks={controllerProps.callbacks}
|
|
43
|
+
isRider={controllerProps.isRider}
|
|
44
|
+
ref={characterInnerRef}
|
|
45
|
+
/>
|
|
46
|
+
)}
|
|
41
47
|
<AirplaneInnerGroupRef ref={innerGroupRef} />
|
|
42
48
|
</AirplaneRigidBody>
|
|
43
49
|
</AirplaneGroup>
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
import calculation from "../physics";
|
|
4
4
|
|
|
5
5
|
import { propType, refsType } from "../controller/type";
|
|
6
|
-
import
|
|
6
|
+
import { CharacterInnerGroupRef, InnerGroupRef } from "./gltf/CharacterGltf";
|
|
7
7
|
import {
|
|
8
8
|
CharacterCapsuleCollider,
|
|
9
9
|
CharacterGroup,
|
|
10
10
|
CharacterRigidBody,
|
|
11
11
|
CharacterSlopeRay,
|
|
12
12
|
} from "./ref/character";
|
|
13
|
+
import setInit from "./setInit";
|
|
13
14
|
|
|
14
15
|
export function Character({
|
|
15
16
|
controllerProps,
|
|
@@ -18,29 +19,38 @@ export function Character({
|
|
|
18
19
|
controllerProps: propType;
|
|
19
20
|
refs: refsType;
|
|
20
21
|
}) {
|
|
21
|
-
const {
|
|
22
|
-
|
|
22
|
+
const {
|
|
23
|
+
capsuleColliderRef,
|
|
24
|
+
rigidBodyRef,
|
|
25
|
+
outerGroupRef,
|
|
26
|
+
slopeRayOriginRef,
|
|
27
|
+
characterInnerRef,
|
|
28
|
+
innerGroupRef,
|
|
29
|
+
} = refs;
|
|
23
30
|
calculation(controllerProps);
|
|
24
|
-
|
|
31
|
+
setInit(rigidBodyRef);
|
|
25
32
|
return (
|
|
26
33
|
<CharacterRigidBody ref={rigidBodyRef} controllerProps={controllerProps}>
|
|
27
34
|
<CharacterCapsuleCollider
|
|
28
35
|
prop={controllerProps}
|
|
29
36
|
ref={capsuleColliderRef}
|
|
30
37
|
/>
|
|
31
|
-
<CharacterGroup ref={outerGroupRef}>
|
|
38
|
+
<CharacterGroup ref={outerGroupRef} controllerProps={controllerProps}>
|
|
32
39
|
<CharacterSlopeRay
|
|
33
40
|
slopeRay={controllerProps.slopeRay}
|
|
34
41
|
groundRay={controllerProps.groundRay}
|
|
35
42
|
ref={slopeRayOriginRef}
|
|
36
43
|
/>
|
|
37
44
|
{controllerProps.children}
|
|
38
|
-
<
|
|
45
|
+
<InnerGroupRef ref={innerGroupRef} />
|
|
46
|
+
<CharacterInnerGroupRef
|
|
39
47
|
prop={controllerProps}
|
|
40
48
|
groupProps={controllerProps.groupProps}
|
|
41
49
|
groundRay={controllerProps.groundRay}
|
|
42
50
|
refs={refs}
|
|
43
51
|
callbacks={controllerProps.callbacks}
|
|
52
|
+
ref={characterInnerRef}
|
|
53
|
+
isRider={false}
|
|
44
54
|
/>
|
|
45
55
|
</CharacterGroup>
|
|
46
56
|
</CharacterRigidBody>
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import { propType, refsType } from "../controller/type";
|
|
4
4
|
import calculation from "../physics";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import { CharacterInnerGroupRef } from "./gltf/CharacterGltf";
|
|
6
|
+
import { VehicleInnerGroupRef } from "./gltf/VehicleGltf";
|
|
7
7
|
import { Wheels } from "./gltf/WheelJoint";
|
|
8
8
|
import { VehicleCollider, VehicleGroup, VehicleRigidBody } from "./ref/vehicle";
|
|
9
|
+
import setInit from "./setInit";
|
|
9
10
|
|
|
10
11
|
export function Vehicle({
|
|
11
12
|
controllerProps,
|
|
@@ -14,25 +15,27 @@ export function Vehicle({
|
|
|
14
15
|
controllerProps: propType;
|
|
15
16
|
refs: refsType;
|
|
16
17
|
}) {
|
|
17
|
-
const { rigidBodyRef, outerGroupRef } =
|
|
18
|
+
const { rigidBodyRef, outerGroupRef, characterInnerRef, innerGroupRef } =
|
|
19
|
+
refs;
|
|
18
20
|
calculation(controllerProps);
|
|
21
|
+
setInit(rigidBodyRef);
|
|
19
22
|
|
|
20
23
|
return (
|
|
21
|
-
<VehicleGroup ref={outerGroupRef}>
|
|
22
|
-
<VehicleRigidBody
|
|
23
|
-
ref={rigidBodyRef}
|
|
24
|
-
groundRay={controllerProps.groundRay}
|
|
25
|
-
>
|
|
24
|
+
<VehicleGroup ref={outerGroupRef} controllerProps={controllerProps}>
|
|
25
|
+
<VehicleRigidBody ref={rigidBodyRef} controllerProps={controllerProps}>
|
|
26
26
|
<VehicleCollider />
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
{controllerProps.isRider && (
|
|
28
|
+
<CharacterInnerGroupRef
|
|
29
|
+
prop={controllerProps}
|
|
30
|
+
groupProps={controllerProps.groupProps}
|
|
31
|
+
groundRay={controllerProps.groundRay}
|
|
32
|
+
refs={refs}
|
|
33
|
+
callbacks={controllerProps.callbacks}
|
|
34
|
+
ref={characterInnerRef}
|
|
35
|
+
isRider={true}
|
|
36
|
+
/>
|
|
37
|
+
)}
|
|
38
|
+
<VehicleInnerGroupRef ref={innerGroupRef} />
|
|
36
39
|
</VehicleRigidBody>
|
|
37
40
|
<Wheels prop={controllerProps} />
|
|
38
41
|
</VehicleGroup>
|
|
@@ -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);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { GroupProps } from "@react-three/fiber";
|
|
2
|
-
import { useContext } from "react";
|
|
2
|
+
import { Ref, forwardRef, useContext } from "react";
|
|
3
3
|
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;
|
|
@@ -15,67 +15,82 @@ export type characterGltfType = {
|
|
|
15
15
|
isRider?: boolean;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
groundRay,
|
|
22
|
-
refs,
|
|
23
|
-
callbacks,
|
|
24
|
-
isRider,
|
|
25
|
-
}: characterGltfType) {
|
|
26
|
-
const { characterGltf: gltf } = useContext(GaesupWorldContext);
|
|
27
|
-
const { materials, nodes } = gltf;
|
|
28
|
-
const { characterCollider, vehicleCollider } = useContext(GaesupWorldContext);
|
|
18
|
+
export const InnerGroupRef = forwardRef((_, ref: Ref<THREE.Group>) => {
|
|
19
|
+
return <group ref={ref} visible={false} />;
|
|
20
|
+
});
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
export const CharacterInnerGroupRef = forwardRef(
|
|
23
|
+
(
|
|
24
|
+
{
|
|
25
|
+
prop,
|
|
26
|
+
groupProps,
|
|
27
|
+
groundRay,
|
|
28
|
+
refs,
|
|
29
|
+
callbacks,
|
|
30
|
+
isRider,
|
|
31
|
+
}: characterGltfType,
|
|
32
|
+
ref: Ref<THREE.Group>
|
|
33
|
+
) => {
|
|
34
|
+
const { characterGltf: gltf } = useContext(GaesupWorldContext);
|
|
35
|
+
const { materials, nodes } = gltf;
|
|
36
|
+
const { characterCollider, vehicleCollider } =
|
|
37
|
+
useContext(GaesupWorldContext);
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
initCallback({
|
|
40
|
+
prop,
|
|
41
|
+
callbacks,
|
|
42
|
+
outerGroupRef: refs.outerGroupRef,
|
|
43
|
+
});
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
>
|
|
53
|
-
{nodes &&
|
|
54
|
-
Object.values(nodes).find((node) => node.type === "Object3D") && (
|
|
55
|
-
<primitive
|
|
56
|
-
object={Object.values(nodes).find(
|
|
57
|
-
(node) => node.type === "Object3D"
|
|
58
|
-
)}
|
|
59
|
-
visible={false}
|
|
45
|
+
playActions({
|
|
46
|
+
outerGroupRef: refs.outerGroupRef,
|
|
47
|
+
groundRay: groundRay,
|
|
48
|
+
isRider,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<>
|
|
53
|
+
{nodes && materials && (
|
|
54
|
+
<group
|
|
60
55
|
receiveShadow
|
|
61
56
|
castShadow
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
{...groupProps}
|
|
58
|
+
position={[
|
|
59
|
+
0,
|
|
60
|
+
isRider
|
|
61
|
+
? vehicleCollider.vehicleSizeY / 2
|
|
62
|
+
: -characterCollider.height,
|
|
63
|
+
0,
|
|
64
|
+
]}
|
|
65
|
+
ref={ref}
|
|
66
|
+
>
|
|
67
|
+
{Object.values(nodes).find((node) => node.type === "Object3D") && (
|
|
68
|
+
<primitive
|
|
69
|
+
object={Object.values(nodes).find(
|
|
70
|
+
(node) => node.type === "Object3D"
|
|
71
|
+
)}
|
|
72
|
+
visible={false}
|
|
70
73
|
receiveShadow
|
|
71
|
-
|
|
72
|
-
geometry={nodes[name].geometry}
|
|
73
|
-
skeleton={(nodes[name] as THREE.SkinnedMesh).skeleton}
|
|
74
|
-
key={key}
|
|
74
|
+
castShadow
|
|
75
75
|
/>
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
)}
|
|
77
|
+
{Object.keys(nodes).map((name: string, key: number) => {
|
|
78
|
+
if (nodes[name].type === "SkinnedMesh") {
|
|
79
|
+
return (
|
|
80
|
+
<skinnedMesh
|
|
81
|
+
castShadow
|
|
82
|
+
receiveShadow
|
|
83
|
+
material={materials[name]}
|
|
84
|
+
geometry={nodes[name].geometry}
|
|
85
|
+
skeleton={(nodes[name] as THREE.SkinnedMesh).skeleton}
|
|
86
|
+
key={key}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
})}
|
|
91
|
+
</group>
|
|
92
|
+
)}
|
|
93
|
+
</>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { GaesupWorldContext } from "../../
|
|
1
|
+
import { Ref, forwardRef, useContext } from "react";
|
|
2
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export const VehicleInnerGroupRef = forwardRef((_, ref: Ref<THREE.Group>) => {
|
|
5
5
|
const { vehicleGltf: gltf } = useContext(GaesupWorldContext);
|
|
6
6
|
const { materials, nodes } = gltf;
|
|
7
7
|
return (
|
|
8
8
|
<>
|
|
9
9
|
{nodes && materials && (
|
|
10
|
-
<group receiveShadow castShadow rotation={[0, Math.PI, 0]}>
|
|
10
|
+
<group receiveShadow castShadow rotation={[0, Math.PI, 0]} ref={ref}>
|
|
11
11
|
{Object.keys(nodes).map((name: string, key: number) => {
|
|
12
12
|
if (
|
|
13
13
|
nodes[name].type === "Mesh" ||
|
|
@@ -28,4 +28,4 @@ export default function VehicleGltf() {
|
|
|
28
28
|
)}
|
|
29
29
|
</>
|
|
30
30
|
);
|
|
31
|
-
}
|
|
31
|
+
});
|
|
@@ -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 }) {
|
|
@@ -8,31 +8,39 @@ import {
|
|
|
8
8
|
} from "@react-three/rapier";
|
|
9
9
|
import { ReactNode, Ref, forwardRef, useContext } from "react";
|
|
10
10
|
import * as THREE from "three";
|
|
11
|
-
import { groundRayType, propType } from "../../controller/type";
|
|
12
|
-
import { GaesupWorldContext } from "../../stores/context/gaesupworld";
|
|
11
|
+
import { controllerType, groundRayType, propType } from "../../controller/type";
|
|
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
|
(
|
|
18
18
|
{
|
|
19
|
-
|
|
19
|
+
controllerProps,
|
|
20
20
|
children,
|
|
21
21
|
}: {
|
|
22
|
-
|
|
22
|
+
controllerProps: propType;
|
|
23
23
|
children: ReactNode;
|
|
24
24
|
},
|
|
25
25
|
ref: Ref<RapierRigidBody>
|
|
26
26
|
) => {
|
|
27
27
|
return (
|
|
28
|
-
<RigidBody
|
|
29
|
-
{
|
|
30
|
-
|
|
28
|
+
<RigidBody
|
|
29
|
+
colliders={false}
|
|
30
|
+
ref={ref}
|
|
31
|
+
{...controllerProps.rigidBodyProps}
|
|
32
|
+
>
|
|
33
|
+
{controllerProps.debug && (
|
|
34
|
+
<mesh visible={controllerProps.debug}>
|
|
31
35
|
<arrowHelper
|
|
32
|
-
args={[
|
|
36
|
+
args={[
|
|
37
|
+
controllerProps.groundRay.dir,
|
|
38
|
+
controllerProps.groundRay.origin,
|
|
39
|
+
controllerProps.groundRay.length,
|
|
40
|
+
]}
|
|
33
41
|
/>
|
|
34
42
|
</mesh>
|
|
35
|
-
)}
|
|
43
|
+
)}
|
|
36
44
|
{children}
|
|
37
45
|
</RigidBody>
|
|
38
46
|
);
|
|
@@ -43,10 +51,10 @@ export const AirplaneCollider = forwardRef(
|
|
|
43
51
|
({ prop }: { prop: propType }, ref: Ref<Collider>) => {
|
|
44
52
|
const { airplaneCollider: collider } = useContext(GaesupWorldContext);
|
|
45
53
|
const { airplaneSizeX, airplaneSizeY, airplaneSizeZ } = collider;
|
|
46
|
-
|
|
54
|
+
|
|
47
55
|
const colliderRef = useForwardRef<Collider>(ref);
|
|
48
56
|
const { rapier } = useRapier();
|
|
49
|
-
const { groundRay
|
|
57
|
+
const { groundRay } = prop;
|
|
50
58
|
groundRay.length = airplaneSizeY * 5 + 2;
|
|
51
59
|
groundRay.rayCast = new rapier.Ray(groundRay.origin, groundRay.dir);
|
|
52
60
|
groundRay.hit = getRayHit<groundRayType>({
|
|
@@ -68,14 +76,20 @@ export const AirplaneCollider = forwardRef(
|
|
|
68
76
|
export const AirplaneGroup = forwardRef(
|
|
69
77
|
(
|
|
70
78
|
{
|
|
79
|
+
controllerProps,
|
|
71
80
|
children,
|
|
72
81
|
}: {
|
|
82
|
+
controllerProps: controllerType;
|
|
73
83
|
children: ReactNode;
|
|
74
84
|
},
|
|
75
85
|
ref: Ref<THREE.Group>
|
|
76
86
|
) => {
|
|
77
87
|
return (
|
|
78
|
-
<group
|
|
88
|
+
<group
|
|
89
|
+
ref={ref}
|
|
90
|
+
userData={{ intangible: true }}
|
|
91
|
+
{...controllerProps.airplane}
|
|
92
|
+
>
|
|
79
93
|
{children}
|
|
80
94
|
</group>
|
|
81
95
|
);
|
|
@@ -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
|
(
|
|
@@ -25,7 +25,7 @@ export const CharacterRigidBody = forwardRef(
|
|
|
25
25
|
controllerProps,
|
|
26
26
|
children,
|
|
27
27
|
}: {
|
|
28
|
-
controllerProps:
|
|
28
|
+
controllerProps: propType;
|
|
29
29
|
children: ReactNode;
|
|
30
30
|
},
|
|
31
31
|
ref: Ref<RapierRigidBody>
|
|
@@ -35,20 +35,19 @@ export const CharacterRigidBody = forwardRef(
|
|
|
35
35
|
colliders={false}
|
|
36
36
|
canSleep={false}
|
|
37
37
|
ref={ref}
|
|
38
|
-
{...controllerProps}
|
|
38
|
+
{...controllerProps.rigidBodyProps}
|
|
39
39
|
>
|
|
40
|
-
{
|
|
41
|
-
<mesh
|
|
42
|
-
visible={options.debug}
|
|
43
|
-
userData={{
|
|
44
|
-
intangible: true,
|
|
45
|
-
}}
|
|
46
|
-
>
|
|
40
|
+
{controllerProps.debug && (
|
|
41
|
+
<mesh visible={controllerProps.debug}>
|
|
47
42
|
<arrowHelper
|
|
48
|
-
args={[
|
|
43
|
+
args={[
|
|
44
|
+
controllerProps.groundRay.dir,
|
|
45
|
+
controllerProps.groundRay.origin,
|
|
46
|
+
controllerProps.groundRay.length,
|
|
47
|
+
]}
|
|
49
48
|
/>
|
|
50
49
|
</mesh>
|
|
51
|
-
)}
|
|
50
|
+
)}
|
|
52
51
|
{children}
|
|
53
52
|
</RigidBody>
|
|
54
53
|
);
|
|
@@ -82,14 +81,20 @@ export const CharacterCapsuleCollider = forwardRef(
|
|
|
82
81
|
export const CharacterGroup = forwardRef(
|
|
83
82
|
(
|
|
84
83
|
{
|
|
84
|
+
controllerProps,
|
|
85
85
|
children,
|
|
86
86
|
}: {
|
|
87
|
+
controllerProps: controllerType;
|
|
87
88
|
children: ReactNode;
|
|
88
89
|
},
|
|
89
90
|
ref: Ref<THREE.Group>
|
|
90
91
|
) => {
|
|
91
92
|
return (
|
|
92
|
-
<group
|
|
93
|
+
<group
|
|
94
|
+
ref={ref}
|
|
95
|
+
userData={{ intangible: true }}
|
|
96
|
+
{...controllerProps.character}
|
|
97
|
+
>
|
|
93
98
|
{children}
|
|
94
99
|
</group>
|
|
95
100
|
);
|