gaesup-world 0.0.1 → 0.0.2
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/camera/control/normal.ts +3 -2
- package/src/gaesup/camera/index.tsx +1 -1
- 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/CharacterGltf.tsx +73 -58
- package/src/gaesup/component/gltf/VehicleGltf.tsx +4 -4
- package/src/gaesup/component/ref/airplane.tsx +25 -11
- package/src/gaesup/component/ref/character.tsx +17 -12
- package/src/gaesup/component/ref/vehicle.tsx +23 -46
- package/src/gaesup/component/setInit.ts +14 -0
- package/src/gaesup/controller/index.tsx +21 -2
- package/src/gaesup/controller/type.ts +13 -0
- package/src/gaesup/initial/controller/index.ts +14 -1
- package/src/gaesup/initial/gaesupWorld/index.ts +3 -2
- package/src/gaesup/initial/gaesupWorld/type.ts +4 -0
- package/src/gaesup/physics/airplane/damping.ts +2 -4
- package/src/gaesup/physics/airplane/direction.ts +58 -47
- package/src/gaesup/physics/airplane/impulse.ts +11 -5
- package/src/gaesup/physics/character/direction.ts +1 -2
- package/src/gaesup/physics/check/moving.ts +2 -3
- package/src/gaesup/physics/index.ts +4 -5
- package/src/gaesup/physics/type.ts +0 -3
- 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/stores/airplane/index.ts +18 -2
- package/src/gaesup/stores/airplane/type.ts +22 -4
- package/src/gaesup/stores/context/controller/index.ts +19 -2
- package/src/gaesup/stores/context/controller/type.ts +5 -0
- package/src/gaesup/stores/context/gaesupworld/type.ts +9 -4
- package/src/gaesup/stores/gameboy/index.ts +3 -0
- package/src/gaesup/stores/gameboy/type.ts +8 -0
- package/src/gaesup/stores/joystick/index.ts +2 -0
- package/src/gaesup/stores/joystick/type.ts +11 -3
- package/src/gaesup/tools/gameboy/GameBoyButton.tsx +6 -0
- package/src/gaesup/tools/gameboy/index.tsx +9 -10
- package/src/gaesup/tools/gameboy/style.css.ts +18 -0
- package/src/gaesup/tools/gamepad/index.tsx +7 -21
- package/src/gaesup/tools/gamepad/style.css.ts +1 -1
- package/src/gaesup/tools/joystick/index.tsx +43 -19
- package/src/gaesup/tools/joystick/style.css.ts +8 -2
- package/src/gaesup/tools/jumpPoint/style.css.ts +3 -2
- package/src/gaesup/tools/minimap/index.tsx +24 -11
- package/src/gaesup/tools/minimap/style.css.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/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.2",
|
|
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",
|
|
@@ -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
|
-
|
|
14
|
-
state.camera.
|
|
13
|
+
|
|
14
|
+
state.camera.position.lerp(cameraPosition, 0.2);
|
|
15
|
+
state.camera.lookAt(activeState.position.clone());
|
|
15
16
|
}
|
|
@@ -13,7 +13,7 @@ import { GaesupControllerContext } from "../stores/context/controller";
|
|
|
13
13
|
import { GaesupWorldContext } from "../stores/context/gaesupworld";
|
|
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({
|
|
@@ -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 { 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";
|
|
@@ -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";
|
|
1
|
+
import { Ref, forwardRef, useContext } from "react";
|
|
2
2
|
import { GaesupWorldContext } from "../../stores/context/gaesupworld";
|
|
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
|
+
});
|
|
@@ -8,7 +8,7 @@ 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";
|
|
11
|
+
import { controllerType, groundRayType, propType } from "../../controller/type";
|
|
12
12
|
import { GaesupWorldContext } from "../../stores/context/gaesupworld";
|
|
13
13
|
import { getRayHit } from "../../utils/ray";
|
|
14
14
|
import { useForwardRef } from "../../utils/ref";
|
|
@@ -16,23 +16,31 @@ import { useForwardRef } from "../../utils/ref";
|
|
|
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
|
);
|
|
@@ -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
|
);
|
|
@@ -9,30 +9,38 @@ import {
|
|
|
9
9
|
} from "@react-three/rapier";
|
|
10
10
|
import { ReactNode, Ref, RefObject, forwardRef, useContext } from "react";
|
|
11
11
|
import * as THREE from "three";
|
|
12
|
-
import {
|
|
12
|
+
import { controllerType, propType } from "../../controller/type";
|
|
13
13
|
import { GaesupWorldContext } from "../../stores/context/gaesupworld";
|
|
14
14
|
import { S3 } from "../../utils/constant";
|
|
15
15
|
|
|
16
16
|
export const VehicleRigidBody = 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
|
);
|
|
@@ -54,14 +62,20 @@ export const VehicleCollider = forwardRef((_, ref: Ref<Collider>) => {
|
|
|
54
62
|
export const VehicleGroup = forwardRef(
|
|
55
63
|
(
|
|
56
64
|
{
|
|
65
|
+
controllerProps,
|
|
57
66
|
children,
|
|
58
67
|
}: {
|
|
68
|
+
controllerProps: controllerType;
|
|
59
69
|
children: ReactNode;
|
|
60
70
|
},
|
|
61
71
|
ref: Ref<THREE.Group>
|
|
62
72
|
) => {
|
|
63
73
|
return (
|
|
64
|
-
<group
|
|
74
|
+
<group
|
|
75
|
+
ref={ref}
|
|
76
|
+
userData={{ intangible: true }}
|
|
77
|
+
{...controllerProps.vehicle}
|
|
78
|
+
>
|
|
65
79
|
{children}
|
|
66
80
|
</group>
|
|
67
81
|
);
|
|
@@ -106,40 +120,3 @@ export const WheelRegidBodyRef = forwardRef(
|
|
|
106
120
|
);
|
|
107
121
|
}
|
|
108
122
|
);
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
// export const GaesupSlopeRay = forwardRef(
|
|
112
|
-
// (
|
|
113
|
-
// {
|
|
114
|
-
// groundRay,
|
|
115
|
-
// slopeRay,
|
|
116
|
-
// }: {
|
|
117
|
-
// groundRay: groundRayType;
|
|
118
|
-
// slopeRay: slopeRayType;
|
|
119
|
-
// },
|
|
120
|
-
// ref: Ref<THREE.Mesh>
|
|
121
|
-
// ) => {
|
|
122
|
-
// const options = useAtomValue(optionsAtom);
|
|
123
|
-
// return (
|
|
124
|
-
// <mesh
|
|
125
|
-
// position={[
|
|
126
|
-
// groundRay.offset.x,
|
|
127
|
-
// groundRay.offset.y,
|
|
128
|
-
// groundRay.offset.z + slopeRay.offset.z,
|
|
129
|
-
// ]}
|
|
130
|
-
// ref={ref}
|
|
131
|
-
// visible={false}
|
|
132
|
-
// userData={{ intangible: true }}
|
|
133
|
-
// >
|
|
134
|
-
// {options.debug && (
|
|
135
|
-
// <mesh>
|
|
136
|
-
// <arrowHelper
|
|
137
|
-
// args={[slopeRay.dir, slopeRay.origin, slopeRay.length, "#ff0000"]}
|
|
138
|
-
// />
|
|
139
|
-
// </mesh>
|
|
140
|
-
// )}
|
|
141
|
-
// <boxGeometry args={[0.15, 0.15, 0.15]} />
|
|
142
|
-
// </mesh>
|
|
143
|
-
// );
|
|
144
|
-
// }
|
|
145
|
-
// );
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RapierRigidBody } from "@react-three/rapier";
|
|
2
|
+
import { RefObject, useContext, useEffect } from "react";
|
|
3
|
+
import { GaesupWorldContext } from "../stores/context/gaesupworld";
|
|
4
|
+
import { V3 } from "../utils/vector";
|
|
5
|
+
|
|
6
|
+
export default function setInit(rigidBodyRef: RefObject<RapierRigidBody>) {
|
|
7
|
+
const { activeState } = useContext(GaesupWorldContext);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
rigidBodyRef.current?.setTranslation(
|
|
10
|
+
activeState.position.add(V3(0, 2, 0)),
|
|
11
|
+
false
|
|
12
|
+
);
|
|
13
|
+
}, []);
|
|
14
|
+
}
|