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.
Files changed (97) hide show
  1. package/index.html +1 -0
  2. package/package.json +3 -1
  3. package/src/gaesup/animation/actions.ts +1 -1
  4. package/src/gaesup/camera/control/normal.ts +2 -1
  5. package/src/gaesup/camera/control/orbit.ts +1 -1
  6. package/src/gaesup/camera/index.tsx +4 -4
  7. package/src/gaesup/component/Airplane.tsx +23 -17
  8. package/src/gaesup/component/Character.tsx +16 -6
  9. package/src/gaesup/component/Vehicle.tsx +20 -17
  10. package/src/gaesup/component/gltf/AirplaneGltf.tsx +1 -1
  11. package/src/gaesup/component/gltf/CharacterGltf.tsx +74 -59
  12. package/src/gaesup/component/gltf/VehicleGltf.tsx +5 -5
  13. package/src/gaesup/component/gltf/WheelJoint.tsx +1 -1
  14. package/src/gaesup/component/ref/airplane.tsx +26 -12
  15. package/src/gaesup/component/ref/character.tsx +18 -13
  16. package/src/gaesup/component/ref/vehicle.tsx +24 -47
  17. package/src/gaesup/component/setInit.ts +14 -0
  18. package/src/gaesup/{stores/context/controller → controller/context}/index.ts +22 -4
  19. package/src/gaesup/{stores/context/controller → controller/context}/type.ts +26 -1
  20. package/src/gaesup/controller/index.tsx +25 -5
  21. package/src/gaesup/controller/type.ts +13 -2
  22. package/src/gaesup/gaesupProps/index.tsx +1 -1
  23. package/src/gaesup/initial/callback/index.ts +1 -1
  24. package/src/gaesup/initial/callback/type.ts +6 -4
  25. package/src/gaesup/initial/controller/index.ts +17 -3
  26. package/src/gaesup/initial/gaesupWorld/collider/index.ts +1 -1
  27. package/src/gaesup/initial/gaesupWorld/index.ts +33 -32
  28. package/src/gaesup/initial/gaesupWorld/type.ts +11 -10
  29. package/src/gaesup/physics/airplane/damping.ts +2 -4
  30. package/src/gaesup/physics/airplane/direction.ts +56 -47
  31. package/src/gaesup/physics/airplane/impulse.ts +11 -5
  32. package/src/gaesup/physics/airplane/turn.ts +0 -1
  33. package/src/gaesup/physics/character/direction.ts +13 -13
  34. package/src/gaesup/physics/check/moving.ts +2 -3
  35. package/src/gaesup/physics/index.ts +9 -9
  36. package/src/gaesup/physics/type.ts +3 -9
  37. package/src/gaesup/physics/vehicle/damping.ts +5 -1
  38. package/src/gaesup/physics/vehicle/direction.ts +35 -14
  39. package/src/gaesup/physics/vehicle/impulse.ts +20 -3
  40. package/src/gaesup/tools/context.ts +6 -0
  41. package/src/gaesup/tools/gameboy/GameBoyButton.tsx +9 -1
  42. package/src/gaesup/tools/gameboy/default.ts +3 -0
  43. package/src/gaesup/tools/gameboy/index.tsx +11 -10
  44. package/src/gaesup/tools/gameboy/style.css.ts +20 -2
  45. package/src/gaesup/tools/gameboy/type.ts +8 -0
  46. package/src/gaesup/tools/gamepad/GamePadButton.tsx +21 -4
  47. package/src/gaesup/tools/gamepad/default.ts +3 -0
  48. package/src/gaesup/tools/gamepad/index.tsx +21 -24
  49. package/src/gaesup/tools/gamepad/style.css.ts +62 -7
  50. package/src/gaesup/tools/gamepad/type.ts +9 -0
  51. package/src/gaesup/tools/index.tsx +64 -43
  52. package/src/gaesup/{stores/joystick/index.ts → tools/joystick/default.ts} +12 -8
  53. package/src/gaesup/tools/joystick/index.tsx +113 -58
  54. package/src/gaesup/tools/joystick/style.css.ts +13 -4
  55. package/src/gaesup/tools/joystick/type.ts +32 -0
  56. package/src/gaesup/tools/jumpPoint/index.tsx +2 -2
  57. package/src/gaesup/tools/jumpPoint/style.css.ts +3 -2
  58. package/src/gaesup/tools/keyBoardToolTip/constant.ts +1 -17
  59. package/src/gaesup/tools/keyBoardToolTip/default.ts +14 -0
  60. package/src/gaesup/tools/keyBoardToolTip/index.tsx +27 -20
  61. package/src/gaesup/tools/keyBoardToolTip/type.ts +37 -0
  62. package/src/gaesup/{stores/minimap/index.ts → tools/minimap/default.ts} +4 -0
  63. package/src/gaesup/tools/minimap/index.tsx +45 -14
  64. package/src/gaesup/tools/minimap/style.css.ts +1 -1
  65. package/src/gaesup/{stores → tools}/minimap/type.ts +6 -1
  66. package/src/gaesup/{stores/control → tools/pushKey}/index.ts +1 -8
  67. package/src/gaesup/tools/reducer.ts +21 -0
  68. package/src/gaesup/tools/type.ts +26 -0
  69. package/src/gaesup/world/context/index.ts +124 -0
  70. package/src/gaesup/{stores/context/gaesupworld → world/context}/reducer.ts +1 -1
  71. package/src/gaesup/world/context/type.ts +137 -0
  72. package/src/gaesup/world/index.tsx +1 -4
  73. package/src/gaesup/world/type.ts +1 -1
  74. package/src/gaesup/camera/control/normal copy.ts +0 -19
  75. package/src/gaesup/physics/airplane copy/currentSetting.ts +0 -20
  76. package/src/gaesup/physics/airplane copy/direction.ts +0 -52
  77. package/src/gaesup/physics/airplane copy/gravity.ts +0 -6
  78. package/src/gaesup/physics/airplane copy/impulse.ts +0 -28
  79. package/src/gaesup/physics/airplane copy/index.tsx +0 -14
  80. package/src/gaesup/physics/airplane copy/turn.ts +0 -9
  81. package/src/gaesup/stores/active/index.ts +0 -19
  82. package/src/gaesup/stores/active/type.ts +0 -16
  83. package/src/gaesup/stores/airplane/index.ts +0 -6
  84. package/src/gaesup/stores/airplane/type.ts +0 -4
  85. package/src/gaesup/stores/animation/index.ts +0 -18
  86. package/src/gaesup/stores/animation/type.ts +0 -9
  87. package/src/gaesup/stores/collider/index.ts +0 -55
  88. package/src/gaesup/stores/context/gaesupworld/index.ts +0 -11
  89. package/src/gaesup/stores/context/gaesupworld/type.ts +0 -66
  90. package/src/gaesup/stores/control/type.ts +0 -11
  91. package/src/gaesup/stores/joystick/type.ts +0 -23
  92. package/src/gaesup/stores/point/type.ts +0 -6
  93. package/src/gaesup/stores/states/index.tsx +0 -10
  94. package/src/gaesup/stores/states/type.ts +0 -10
  95. package/src/gaesup/stores/url/index.ts +0 -6
  96. package/src/gaesup/stores/url/type.ts +0 -6
  97. /package/src/gaesup/{stores/context/controller → controller/context}/reducer.ts +0 -0
package/index.html CHANGED
@@ -8,6 +8,7 @@
8
8
  </head>
9
9
  <body>
10
10
  <div id="root"></div>
11
+
11
12
  <script type="module" src="/examples/select/main.tsx"></script>
12
13
  </body>
13
14
  </html>
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.0.1",
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 "../stores/context/gaesupworld";
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.2);
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 { GaesupControllerContext } from "../stores/context/controller";
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 copy";
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, camera } = useThree();
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 { rigidBodyRef, outerGroupRef, capsuleColliderRef, innerGroupRef } =
20
- refs;
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
- {/* <CharacterGltf
32
- gltf={characterGltf}
33
- prop={prop}
34
- url={props.url}
35
- character={props.character}
36
- groundRay={prop.groundRay}
37
- refs={refs}
38
- callbacks={callbacks}
39
- isRider={true}
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 CharacterGltf from "./gltf/CharacterGltf";
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 { capsuleColliderRef, rigidBodyRef, outerGroupRef, slopeRayOriginRef } =
22
- refs;
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
- <CharacterGltf
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 CharacterGltf from "./gltf/CharacterGltf";
6
- import VehicleGltf from "./gltf/VehicleGltf";
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 } = refs;
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
- <CharacterGltf
28
- prop={controllerProps}
29
- groupProps={controllerProps.groupProps}
30
- groundRay={controllerProps.groundRay}
31
- refs={refs}
32
- callbacks={controllerProps.callbacks}
33
- isRider={true}
34
- />
35
- <VehicleGltf />
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 "../../stores/context/gaesupworld";
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 "../../stores/context/gaesupworld";
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 default function CharacterGltf({
19
- prop,
20
- groupProps,
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
- initCallback({
31
- prop,
32
- callbacks,
33
- outerGroupRef: refs.outerGroupRef,
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
- playActions({
37
- outerGroupRef: refs.outerGroupRef,
38
- groundRay: groundRay,
39
- isRider,
40
- });
39
+ initCallback({
40
+ prop,
41
+ callbacks,
42
+ outerGroupRef: refs.outerGroupRef,
43
+ });
41
44
 
42
- return (
43
- <group
44
- receiveShadow
45
- castShadow
46
- {...groupProps}
47
- position={[
48
- 0,
49
- isRider ? vehicleCollider.vehicleSizeY / 2 : -characterCollider.height,
50
- 0,
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
- {nodes &&
65
- Object.keys(nodes).map((name: string, key: number) => {
66
- if (nodes[name].type === "SkinnedMesh") {
67
- return (
68
- <skinnedMesh
69
- castShadow
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
- material={materials[name]}
72
- geometry={nodes[name].geometry}
73
- skeleton={(nodes[name] as THREE.SkinnedMesh).skeleton}
74
- key={key}
74
+ castShadow
75
75
  />
76
- );
77
- }
78
- })}
79
- </group>
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 "../../stores/context/gaesupworld";
1
+ import { Ref, forwardRef, useContext } from "react";
2
+ import { GaesupWorldContext } from "../../world/context";
3
3
 
4
- export default function VehicleGltf() {
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 "../../stores/context/gaesupworld";
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
- groundRay,
19
+ controllerProps,
20
20
  children,
21
21
  }: {
22
- groundRay: groundRayType;
22
+ controllerProps: propType;
23
23
  children: ReactNode;
24
24
  },
25
25
  ref: Ref<RapierRigidBody>
26
26
  ) => {
27
27
  return (
28
- <RigidBody colliders={false} ref={ref}>
29
- {/* {options.debug && (
30
- <mesh visible={options.debug}>
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={[groundRay.dir, groundRay.origin, groundRay.length]}
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
- console.log(airplaneSizeY);
54
+
47
55
  const colliderRef = useForwardRef<Collider>(ref);
48
56
  const { rapier } = useRapier();
49
- const { groundRay, slopeRay } = prop;
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 ref={ref} userData={{ intangible: true }}>
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: controllerType;
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
- {/* {options.debug && (
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={[groundRay.dir, groundRay.origin, groundRay.length]}
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 ref={ref} userData={{ intangible: true }}>
93
+ <group
94
+ ref={ref}
95
+ userData={{ intangible: true }}
96
+ {...controllerProps.character}
97
+ >
93
98
  {children}
94
99
  </group>
95
100
  );