gaesup-world 0.9.59 → 0.9.60

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 (117) hide show
  1. package/dist/gaesup/animation/actions.ts +121 -0
  2. package/dist/gaesup/animation/type.ts +43 -0
  3. package/dist/gaesup/camera/control/normal.ts +27 -0
  4. package/dist/gaesup/camera/control/orbit.ts +37 -0
  5. package/dist/gaesup/camera/index.tsx +29 -0
  6. package/dist/gaesup/camera/type.ts +14 -0
  7. package/dist/gaesup/component/active/airplane/index.tsx +17 -0
  8. package/dist/gaesup/component/active/airplane/type.ts +4 -0
  9. package/dist/gaesup/component/active/character/index.tsx +35 -0
  10. package/dist/gaesup/component/active/character/type.ts +13 -0
  11. package/dist/gaesup/component/active/vehicle/index.tsx +17 -0
  12. package/dist/gaesup/component/active/vehicle/type.ts +4 -0
  13. package/dist/gaesup/component/index.tsx +65 -0
  14. package/dist/gaesup/component/inner/airplane/index.tsx +21 -0
  15. package/dist/gaesup/component/inner/airplane/type.ts +8 -0
  16. package/dist/gaesup/component/inner/character/index.tsx +22 -0
  17. package/dist/gaesup/component/inner/character/type.ts +14 -0
  18. package/dist/gaesup/component/inner/common/InnerGroupRef.tsx +56 -0
  19. package/dist/gaesup/component/inner/common/OuterGroupRef.tsx +19 -0
  20. package/dist/gaesup/component/inner/common/RigidbodyRef.tsx +178 -0
  21. package/dist/gaesup/component/inner/common/calc.ts +16 -0
  22. package/dist/gaesup/component/inner/common/partsGroupRef.tsx +66 -0
  23. package/dist/gaesup/component/inner/common/setGroundRay.ts +24 -0
  24. package/dist/gaesup/component/inner/common/type.ts +66 -0
  25. package/dist/gaesup/component/inner/rider/index.tsx +79 -0
  26. package/dist/gaesup/component/inner/vehicle/collider.tsx +40 -0
  27. package/dist/gaesup/component/inner/vehicle/index.tsx +44 -0
  28. package/dist/gaesup/component/inner/vehicle/type.ts +8 -0
  29. package/dist/gaesup/component/inner/vehicle/wheels.tsx +124 -0
  30. package/dist/gaesup/component/passive/airplane/index.tsx +65 -0
  31. package/dist/gaesup/component/passive/airplane/type.ts +3 -0
  32. package/dist/gaesup/component/passive/character/index.tsx +49 -0
  33. package/dist/gaesup/component/passive/character/type.ts +6 -0
  34. package/dist/gaesup/component/passive/type.ts +51 -0
  35. package/dist/gaesup/component/passive/vehicle/index.tsx +45 -0
  36. package/dist/gaesup/component/passive/vehicle/type.ts +3 -0
  37. package/dist/gaesup/component/type.ts +16 -0
  38. package/dist/gaesup/controller/context/index.ts +55 -0
  39. package/dist/gaesup/controller/context/reducer.ts +18 -0
  40. package/dist/gaesup/controller/context/type.ts +42 -0
  41. package/dist/gaesup/controller/index.tsx +116 -0
  42. package/dist/gaesup/controller/initialize/callback/index.ts +88 -0
  43. package/dist/gaesup/controller/initialize/callback/type.ts +35 -0
  44. package/dist/gaesup/controller/initialize/index.ts +90 -0
  45. package/dist/gaesup/controller/type.ts +127 -0
  46. package/dist/gaesup/gaesupProps/index.tsx +65 -0
  47. package/dist/gaesup/hooks/useClicker/index.ts +38 -0
  48. package/dist/gaesup/hooks/useFocus/index.tsx +129 -0
  49. package/dist/gaesup/hooks/useGaesupAnimation/index.tsx +128 -0
  50. package/dist/gaesup/hooks/useGaesupController/index.ts +25 -0
  51. package/dist/gaesup/hooks/useGaesupGltf/index.tsx +78 -0
  52. package/dist/gaesup/hooks/useMovePoint/index.ts +34 -0
  53. package/dist/gaesup/hooks/usePushKey/index.ts +26 -0
  54. package/dist/gaesup/hooks/useRayHit/index.ts +25 -0
  55. package/dist/gaesup/hooks/useRideable/index.tsx +121 -0
  56. package/dist/gaesup/hooks/useRideable/type.ts +20 -0
  57. package/dist/gaesup/hooks/useTeleport/index.tsx +21 -0
  58. package/dist/gaesup/hooks/useZoom/index.tsx +24 -0
  59. package/dist/gaesup/physics/airplane/damping.ts +10 -0
  60. package/dist/gaesup/physics/airplane/direction.ts +63 -0
  61. package/dist/gaesup/physics/airplane/gravity.ts +14 -0
  62. package/dist/gaesup/physics/airplane/impulse.ts +26 -0
  63. package/dist/gaesup/physics/airplane/index.tsx +16 -0
  64. package/dist/gaesup/physics/airplane/innerCalc.ts +27 -0
  65. package/dist/gaesup/physics/airplane/landing.ts +28 -0
  66. package/dist/gaesup/physics/character/direction.ts +64 -0
  67. package/dist/gaesup/physics/character/impulse.ts +35 -0
  68. package/dist/gaesup/physics/character/index.tsx +14 -0
  69. package/dist/gaesup/physics/character/innerCalc.ts +27 -0
  70. package/dist/gaesup/physics/character/queue.ts +52 -0
  71. package/dist/gaesup/physics/character/stop.ts +13 -0
  72. package/dist/gaesup/physics/check/ground.ts +28 -0
  73. package/dist/gaesup/physics/check/index.ts +14 -0
  74. package/dist/gaesup/physics/check/moving.ts +15 -0
  75. package/dist/gaesup/physics/check/push.ts +10 -0
  76. package/dist/gaesup/physics/check/riding.ts +12 -0
  77. package/dist/gaesup/physics/check/rotate.ts +13 -0
  78. package/dist/gaesup/physics/index.ts +80 -0
  79. package/dist/gaesup/physics/type.ts +57 -0
  80. package/dist/gaesup/physics/vehicle/damping.ts +12 -0
  81. package/dist/gaesup/physics/vehicle/direction.ts +27 -0
  82. package/dist/gaesup/physics/vehicle/impulse.ts +28 -0
  83. package/dist/gaesup/physics/vehicle/index.tsx +14 -0
  84. package/dist/gaesup/physics/vehicle/innerCalc.ts +17 -0
  85. package/dist/gaesup/physics/vehicle/landing.ts +28 -0
  86. package/dist/gaesup/tools/clicker/index.tsx +60 -0
  87. package/dist/gaesup/tools/gamepad/GamePadButton.tsx +47 -0
  88. package/dist/gaesup/tools/gamepad/index.tsx +51 -0
  89. package/dist/gaesup/tools/gamepad/style.css.ts +54 -0
  90. package/dist/gaesup/tools/gamepad/type.ts +17 -0
  91. package/dist/gaesup/tools/minimap/index.tsx +231 -0
  92. package/dist/gaesup/tools/minimap/style.css.ts +205 -0
  93. package/dist/gaesup/tools/minimap/type.ts +44 -0
  94. package/dist/gaesup/tools/rideable/index.tsx +72 -0
  95. package/dist/gaesup/tools/rideable/type.ts +27 -0
  96. package/dist/gaesup/tools/shared.css.ts +44 -0
  97. package/dist/gaesup/tools/teleport/index.tsx +20 -0
  98. package/dist/gaesup/tools/teleport/style.css.ts +14 -0
  99. package/dist/gaesup/tools/teleport/type.ts +8 -0
  100. package/dist/gaesup/tools/type.ts +3 -0
  101. package/dist/gaesup/utils/context.ts +5 -0
  102. package/dist/gaesup/utils/getTag.ts +7 -0
  103. package/dist/gaesup/utils/index.ts +3 -0
  104. package/dist/gaesup/utils/innerHtml.tsx +22 -0
  105. package/dist/gaesup/utils/ray.ts +23 -0
  106. package/dist/gaesup/utils/ref.ts +17 -0
  107. package/dist/gaesup/utils/type.ts +6 -0
  108. package/dist/gaesup/utils/vector.ts +65 -0
  109. package/dist/gaesup/world/context/index.ts +115 -0
  110. package/dist/gaesup/world/context/reducer.ts +18 -0
  111. package/dist/gaesup/world/context/type.ts +210 -0
  112. package/dist/gaesup/world/index.tsx +17 -0
  113. package/dist/gaesup/world/initalize/index.ts +42 -0
  114. package/dist/gaesup/world/type.ts +27 -0
  115. package/dist/index.ts +24 -0
  116. package/package.json +3 -2
  117. package/index.py +0 -81
@@ -0,0 +1,121 @@
1
+ import { useFrame } from "@react-three/fiber";
2
+ import { useContext, useEffect } from "react";
3
+ import { animationTagType } from "../controller/type";
4
+ import { useGaesupAnimation } from "../hooks/useGaesupAnimation";
5
+ import {
6
+ GaesupWorldContext,
7
+ GaesupWorldDispatchContext,
8
+ } from "../world/context";
9
+ import { playActionsType, subscribeActionsType } from "./type";
10
+
11
+ export function subscribeActions({ type }: subscribeActionsType) {
12
+ const { states } = useContext(GaesupWorldContext);
13
+ const { subscribeAll } = useGaesupAnimation({ type });
14
+ // 초기 기본 애니메이션 등록
15
+ useEffect(() => {
16
+ subscribeAll([
17
+ {
18
+ tag: "walk",
19
+ condition: () => !states.isRunning && states.isMoving,
20
+ action: () => {},
21
+ animationName: "walk",
22
+ key: "walk",
23
+ },
24
+ {
25
+ tag: "run",
26
+ condition: () => states.isRunning,
27
+ action: () => {},
28
+ animationName: "run",
29
+ key: "run",
30
+ },
31
+ {
32
+ tag: "jump",
33
+ condition: () => states.isJumping,
34
+ action: () => {},
35
+ animationName: "jump",
36
+ key: "jump",
37
+ },
38
+
39
+ {
40
+ tag: "ride",
41
+ condition: () => states.isPush["keyR"],
42
+ action: () => {},
43
+ animationName: "ride",
44
+ key: "ride",
45
+ },
46
+ {
47
+ tag: "land",
48
+ condition: () => states.isLanding,
49
+ action: () => {},
50
+ animationName: "land",
51
+ key: "land",
52
+ },
53
+ {
54
+ tag: "fall",
55
+ condition: () => states.isFalling,
56
+ action: () => {},
57
+ animationName: "fall",
58
+ key: "fall",
59
+ },
60
+ ]);
61
+ }, []);
62
+ }
63
+
64
+ export default function playActions({
65
+ type,
66
+ actions,
67
+ animationRef,
68
+ currentAnimation,
69
+ isActive,
70
+ }: playActionsType) {
71
+ const { mode, animationState, block } = useContext(GaesupWorldContext);
72
+ const dispatch = useContext(GaesupWorldDispatchContext);
73
+ const { notify, store } = useGaesupAnimation({ type });
74
+
75
+ if (isActive) {
76
+ currentAnimation = animationState?.[type]?.current;
77
+ }
78
+
79
+ const play = (tag: keyof animationTagType) => {
80
+ animationState[type].current = tag;
81
+ const currentAnimation = store[tag];
82
+ if (currentAnimation?.action) {
83
+ currentAnimation.action();
84
+ }
85
+ dispatch({
86
+ type: "update",
87
+ payload: {
88
+ animationState: {
89
+ ...animationState,
90
+ },
91
+ },
92
+ });
93
+ };
94
+
95
+ useEffect(() => {
96
+ let animation = "idle";
97
+ if (block.animation) {
98
+ animation = "idle";
99
+ } else if (currentAnimation) {
100
+ animation = currentAnimation;
101
+ } else if (animationState[type].current) {
102
+ animation = animationState[type].current;
103
+ }
104
+ const action = actions[animation]?.reset().fadeIn(0.2).play();
105
+ return () => {
106
+ action?.fadeOut(0.2);
107
+ };
108
+ }, [currentAnimation, mode.type, block.animation, type]);
109
+
110
+ useFrame(() => {
111
+ if (isActive) {
112
+ const tag = notify() as keyof animationTagType;
113
+ play(tag);
114
+ }
115
+ });
116
+
117
+ return {
118
+ animationRef,
119
+ currentAnimation: animationState?.[type]?.current,
120
+ };
121
+ }
@@ -0,0 +1,43 @@
1
+ import { Ref } from "react";
2
+ import * as THREE from "three";
3
+ import {
4
+ AnimationAction,
5
+ AnimationClip,
6
+ AnimationMixer,
7
+ Object3D,
8
+ Object3DEventMap,
9
+ } from "three";
10
+ import { groundRayType } from "../controller/type";
11
+
12
+ export type Api<T extends AnimationClip> = {
13
+ ref: React.MutableRefObject<Object3D | undefined | null>;
14
+ clips: AnimationClip[];
15
+ mixer: AnimationMixer;
16
+ names: T["name"][];
17
+ actions: {
18
+ [key in T["name"]]: AnimationAction | null;
19
+ };
20
+ };
21
+
22
+ export type playActionsType = {
23
+ type: "character" | "vehicle" | "airplane";
24
+ currentAnimation?: string;
25
+ actions: actionsType;
26
+ animationRef: Ref<Object3D<Object3DEventMap>>;
27
+ isActive: boolean;
28
+ };
29
+
30
+ export type subscribeActionsType = {
31
+ type: "character" | "vehicle" | "airplane";
32
+ groundRay: groundRayType;
33
+ animations: AnimationClip[];
34
+ };
35
+
36
+ export type actionsType = {
37
+ [x: string]: THREE.AnimationAction | null;
38
+ };
39
+
40
+ export type playResultType = {
41
+ actions: actionsType;
42
+ ref: Ref<Object3D<Object3DEventMap>>;
43
+ };
@@ -0,0 +1,27 @@
1
+ import { cameraPropType } from "../../physics/type";
2
+ import { V3 } from "../../utils/vector";
3
+ import { activeStateType, cameraOptionType } from "../../world/context/type";
4
+
5
+ export const makeNormalCameraPosition = (
6
+ activeState: activeStateType,
7
+ cameraOption: cameraOptionType
8
+ ) => {
9
+ const { XDistance, YDistance, ZDistance } = cameraOption;
10
+ const cameraPosition = activeState.position
11
+ .clone()
12
+ .add(V3(XDistance, YDistance, ZDistance));
13
+ return cameraPosition;
14
+ };
15
+ export default function normal(prop: cameraPropType) {
16
+ const {
17
+ state,
18
+ worldContext: { cameraOption },
19
+ controllerOptions: { lerp },
20
+ } = prop;
21
+ if (!state || !state.camera) return;
22
+ state.camera.position.lerp(
23
+ cameraOption.position.clone(),
24
+ lerp.cameraPosition
25
+ );
26
+ state.camera.lookAt(cameraOption.target);
27
+ }
@@ -0,0 +1,37 @@
1
+ import { quat } from "@react-three/rapier";
2
+ import { cameraPropType } from "../../physics/type";
3
+ import { V3 } from "../../utils/vector";
4
+ import { activeStateType, cameraOptionType } from "../../world/context/type";
5
+
6
+ export const makeOrbitCameraPosition = (
7
+ activeState: activeStateType,
8
+ cameraOption: cameraOptionType
9
+ ) => {
10
+ const { XDistance, YDistance, ZDistance } = cameraOption;
11
+ const cameraPosition = activeState.position.clone().add(
12
+ V3(Math.sin(activeState.euler.y), 1, Math.cos(activeState.euler.y))
13
+ .normalize()
14
+ .clone()
15
+ .multiply(V3(-XDistance, YDistance, -ZDistance))
16
+ );
17
+ return cameraPosition;
18
+ };
19
+
20
+ export default function orbit(prop: cameraPropType) {
21
+ const {
22
+ state,
23
+ worldContext: { activeState, cameraOption },
24
+ controllerOptions: { lerp },
25
+ } = prop;
26
+
27
+ if (!state || !state.camera) return;
28
+ const cameraPosition = makeOrbitCameraPosition(activeState, cameraOption);
29
+ state.camera.position.lerp(cameraPosition.clone(), lerp.cameraTurn);
30
+ state.camera.quaternion.copy(
31
+ activeState.quat
32
+ .clone()
33
+ .multiply(quat().setFromAxisAngle(V3(0, 1, 0), Math.PI))
34
+ );
35
+ state.camera.rotation.copy(activeState.euler);
36
+ state.camera.lookAt(activeState.position.clone());
37
+ }
@@ -0,0 +1,29 @@
1
+ import { useFrame } from "@react-three/fiber";
2
+ import { cameraPropType } from "../physics/type";
3
+ import normal, { makeNormalCameraPosition } from "./control/normal";
4
+ import orbit from "./control/orbit";
5
+
6
+ export default function Camera(prop: cameraPropType) {
7
+ useFrame((state) => {
8
+ prop.state = state;
9
+ if (!prop.worldContext.block.camera) {
10
+ if (prop.worldContext.mode.control === "orbit") {
11
+ orbit(prop);
12
+ } else if (prop.worldContext.mode.control === "normal") {
13
+ normal(prop);
14
+ }
15
+ }
16
+ });
17
+
18
+ // 포커스가 아닐 때 카메라 activeStae 따라가기
19
+ useFrame(() => {
20
+ if (!prop.worldContext.cameraOption.focus) {
21
+ prop.worldContext.cameraOption.target =
22
+ prop.worldContext.activeState.position;
23
+ prop.worldContext.cameraOption.position = makeNormalCameraPosition(
24
+ prop.worldContext.activeState,
25
+ prop.worldContext.cameraOption
26
+ );
27
+ }
28
+ });
29
+ }
@@ -0,0 +1,14 @@
1
+ import * as THREE from "three";
2
+ import {} from "three-stdlib";
3
+
4
+ export type cameraRayType = {
5
+ origin: THREE.Vector3;
6
+ hit: THREE.Raycaster;
7
+ rayCast: THREE.Raycaster | null;
8
+ length: number;
9
+ dir: THREE.Vector3;
10
+ position: THREE.Vector3;
11
+ intersects: THREE.Intersection<THREE.Mesh>[];
12
+ detected: THREE.Intersection<THREE.Mesh>[];
13
+ intersectObjectMap: { [uuid: string]: THREE.Mesh };
14
+ };
@@ -0,0 +1,17 @@
1
+ import { AirplaneInnerRef } from "../../inner/airplane";
2
+ import { activeAirplaneInnerType } from "./type";
3
+
4
+ export function AirplaneRef(props: activeAirplaneInnerType) {
5
+ return (
6
+ <AirplaneInnerRef
7
+ name={"airplane"}
8
+ isActive={true}
9
+ currentAnimation={"idle"}
10
+ componentType={"airplane"}
11
+ ridingUrl={props.ridingUrl}
12
+ {...props}
13
+ >
14
+ {props.children}
15
+ </AirplaneInnerRef>
16
+ );
17
+ }
@@ -0,0 +1,4 @@
1
+ import { passiveAirplanePropsType } from "../../passive/airplane/type";
2
+ import { innerRefType } from "../../passive/type";
3
+
4
+ export type activeAirplaneInnerType = passiveAirplanePropsType & innerRefType;
@@ -0,0 +1,35 @@
1
+ import { controllerInnerType, refsType } from "../../../controller/type";
2
+ import { urlsType } from "../../../world/context/type";
3
+ import { CharacterInnerRef } from "../../inner/character";
4
+
5
+ export function CharacterRef({
6
+ children,
7
+ props,
8
+ refs,
9
+ urls,
10
+ }: {
11
+ children: React.ReactNode;
12
+ props: controllerInnerType;
13
+ refs: refsType;
14
+ urls: urlsType;
15
+ }) {
16
+ return (
17
+ <CharacterInnerRef
18
+ url={urls.characterUrl}
19
+ isActive={true}
20
+ componentType="character"
21
+ rigidbodyType={"dynamic"}
22
+ controllerOptions={props.controllerOptions}
23
+ groundRay={props.groundRay}
24
+ onAnimate={props.onAnimate}
25
+ onFrame={props.onFrame}
26
+ onReady={props.onReady}
27
+ onDestory={props.onDestory}
28
+ rigidBodyProps={props.rigidBodyProps}
29
+ parts={props.parts}
30
+ {...refs}
31
+ >
32
+ {children}
33
+ </CharacterInnerRef>
34
+ );
35
+ }
@@ -0,0 +1,13 @@
1
+ import { RigidBodyTypeString } from "@react-three/rapier";
2
+ import * as THREE from "three";
3
+ import { controllerOptionsType } from "../../../controller/type";
4
+
5
+ export type activeCharacterPropsType = {
6
+ characterUrl: string;
7
+ position?: THREE.Vector3;
8
+ rotation?: THREE.Euler;
9
+ controllerOptions?: controllerOptionsType;
10
+ currentAnimation?: string;
11
+ children?: React.ReactNode;
12
+ rigidbodyType?: RigidBodyTypeString;
13
+ };
@@ -0,0 +1,17 @@
1
+ import { VehicleInnerRef } from "../../inner/vehicle";
2
+ import { activeVehicleInnerType } from "./type";
3
+
4
+ export function VehicleRef(props: activeVehicleInnerType) {
5
+ return (
6
+ <VehicleInnerRef
7
+ name={"vehicle"}
8
+ isActive={true}
9
+ currentAnimation={"idle"}
10
+ componentType={"vehicle"}
11
+ ridingUrl={props.ridingUrl}
12
+ {...props}
13
+ >
14
+ {props.children}
15
+ </VehicleInnerRef>
16
+ );
17
+ }
@@ -0,0 +1,4 @@
1
+ import { innerRefType } from "../../passive/type";
2
+ import { passiveVehiclePropsType } from "../../passive/vehicle/type";
3
+
4
+ export type activeVehicleInnerType = passiveVehiclePropsType & innerRefType;
@@ -0,0 +1,65 @@
1
+ import { vec3 } from "@react-three/rapier";
2
+ import { useContext } from "react";
3
+ import { controllerInnerType, refsType } from "../controller/type";
4
+ import { GaesupWorldContext } from "../world/context";
5
+ import { AirplaneRef } from "./active/airplane";
6
+ import { CharacterRef } from "./active/character";
7
+ import { VehicleRef } from "./active/vehicle";
8
+
9
+ export function GaesupComponent({
10
+ props,
11
+ refs,
12
+ }: {
13
+ props: controllerInnerType;
14
+ refs: refsType;
15
+ }) {
16
+ const { mode, states, rideable, urls } = useContext(GaesupWorldContext);
17
+ const { enableRiding, isRiderOn, rideableId } = states;
18
+
19
+ return (
20
+ <>
21
+ {mode.type === "character" && (
22
+ <CharacterRef props={props} refs={refs} urls={urls}>
23
+ {props.children}
24
+ </CharacterRef>
25
+ )}
26
+ {mode.type === "vehicle" && (
27
+ <VehicleRef
28
+ controllerOptions={props.controllerOptions}
29
+ url={urls.vehicleUrl}
30
+ wheelUrl={urls.wheelUrl}
31
+ ridingUrl={urls.ridingUrl}
32
+ enableRiding={enableRiding}
33
+ isRiderOn={isRiderOn}
34
+ groundRay={props.groundRay}
35
+ offset={
36
+ rideableId && rideable[rideableId]
37
+ ? rideable[rideableId].offset
38
+ : vec3()
39
+ }
40
+ {...refs}
41
+ >
42
+ {props.children}
43
+ </VehicleRef>
44
+ )}
45
+ {mode.type === "airplane" && (
46
+ <AirplaneRef
47
+ controllerOptions={props.controllerOptions}
48
+ url={urls.airplaneUrl}
49
+ ridingUrl={urls.ridingUrl}
50
+ enableRiding={enableRiding}
51
+ isRiderOn={isRiderOn}
52
+ groundRay={props.groundRay}
53
+ offset={
54
+ rideableId && rideable[rideableId]
55
+ ? rideable[rideableId].offset
56
+ : vec3()
57
+ }
58
+ {...refs}
59
+ >
60
+ {props.children}
61
+ </AirplaneRef>
62
+ )}
63
+ </>
64
+ );
65
+ }
@@ -0,0 +1,21 @@
1
+ import { OuterGroupRef } from "../common/OuterGroupRef";
2
+ import { RigidBodyRef } from "../common/RigidbodyRef";
3
+ import { airplaneInnerType } from "./type";
4
+
5
+ export function AirplaneInnerRef(props: airplaneInnerType) {
6
+ const { rigidBodyRef, outerGroupRef } = props;
7
+
8
+ return (
9
+ <OuterGroupRef ref={outerGroupRef}>
10
+ <RigidBodyRef
11
+ ref={rigidBodyRef}
12
+ name={props.name}
13
+ componentType={"airplane"}
14
+ ridingUrl={props.ridingUrl}
15
+ {...props}
16
+ >
17
+ {props.children}
18
+ </RigidBodyRef>
19
+ </OuterGroupRef>
20
+ );
21
+ }
@@ -0,0 +1,8 @@
1
+ import { ridingType, rigidBodyRefType } from "../common/type";
2
+
3
+ // airplane 타입 정의
4
+ export type airplaneUrlType = {
5
+ wheelUrl?: string;
6
+ };
7
+
8
+ export type airplaneInnerType = rigidBodyRefType & ridingType & airplaneUrlType;
@@ -0,0 +1,22 @@
1
+ import { OuterGroupRef } from "../common/OuterGroupRef";
2
+ import { RigidBodyRef } from "../common/RigidbodyRef";
3
+ import { characterInnerType } from "./type";
4
+
5
+ export function CharacterInnerRef(props: characterInnerType) {
6
+ const { outerGroupRef } = props;
7
+ return (
8
+ <OuterGroupRef ref={outerGroupRef}>
9
+ <RigidBodyRef
10
+ name={"character"}
11
+ url={props.url}
12
+ controllerOptions={props.controllerOptions}
13
+ ref={props.rigidBodyRef}
14
+ groundRay={props.groundRay}
15
+ isNotColliding={props.isNotColliding}
16
+ {...props}
17
+ >
18
+ {props.children}
19
+ </RigidBodyRef>
20
+ </OuterGroupRef>
21
+ );
22
+ }
@@ -0,0 +1,14 @@
1
+ import { callbackType } from "../../../controller/initialize/callback/type";
2
+ import { groundRayType, partsType } from "../../../controller/type";
3
+ import { passiveCharacterPropsType } from "../../passive/character/type";
4
+ import { componentTypeString, innerRefType } from "../../passive/type";
5
+
6
+ // 내부 정의
7
+ export type characterInnerType = {
8
+ componentType: componentTypeString;
9
+ isActive?: boolean;
10
+ groundRay: groundRayType;
11
+ parts?: partsType;
12
+ } & passiveCharacterPropsType &
13
+ innerRefType &
14
+ callbackType;
@@ -0,0 +1,56 @@
1
+ import { Ref, forwardRef } from "react";
2
+ import * as THREE from "three";
3
+ import RiderRef from "../rider";
4
+ import { InnerGroupRefType } from "./type";
5
+
6
+ export const InnerGroupRef = forwardRef(
7
+ (props: InnerGroupRefType, ref: Ref<THREE.Group>) => {
8
+ return (
9
+ <group receiveShadow castShadow ref={ref} userData={{ intangible: true }}>
10
+ {props.isRiderOn &&
11
+ props.enableRiding &&
12
+ props.isActive &&
13
+ props.ridingUrl && (
14
+ <RiderRef url={props.ridingUrl} offset={props.offset} />
15
+ )}
16
+
17
+ {props.children}
18
+ {props.objectNode && props.animationRef && (
19
+ <primitive
20
+ object={props.objectNode}
21
+ visible={false}
22
+ receiveShadow
23
+ castShadow
24
+ ref={props.animationRef}
25
+ />
26
+ )}
27
+
28
+ {Object.keys(props.nodes).map((name: string, key: number) => {
29
+ const node = props.nodes[name];
30
+ if (node instanceof THREE.SkinnedMesh) {
31
+ return (
32
+ <skinnedMesh
33
+ castShadow
34
+ receiveShadow
35
+ material={node.material}
36
+ geometry={node.geometry}
37
+ skeleton={node.skeleton}
38
+ key={key}
39
+ />
40
+ );
41
+ } else if (node instanceof THREE.Mesh) {
42
+ return (
43
+ <mesh
44
+ castShadow
45
+ receiveShadow
46
+ material={node.material}
47
+ geometry={node.geometry}
48
+ key={key}
49
+ />
50
+ );
51
+ }
52
+ })}
53
+ </group>
54
+ );
55
+ }
56
+ );
@@ -0,0 +1,19 @@
1
+ import { forwardRef, MutableRefObject, ReactNode } from "react";
2
+ import * as THREE from "three";
3
+
4
+ export const OuterGroupRef = forwardRef(
5
+ (
6
+ {
7
+ children,
8
+ }: {
9
+ children: ReactNode;
10
+ },
11
+ ref: MutableRefObject<THREE.Group>
12
+ ) => {
13
+ return (
14
+ <group ref={ref} userData={{ intangible: true }}>
15
+ {children}
16
+ </group>
17
+ );
18
+ }
19
+ );