gaesup-world 0.9.778 → 0.9.780

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 (130) hide show
  1. package/package.json +2 -2
  2. package/src/gaesup/animation/actions.ts +112 -0
  3. package/src/gaesup/animation/type.ts +37 -0
  4. package/src/gaesup/camera/control/normal.ts +27 -0
  5. package/src/gaesup/camera/control/orbit.ts +37 -0
  6. package/src/gaesup/camera/index.tsx +29 -0
  7. package/src/gaesup/camera/type.ts +14 -0
  8. package/src/gaesup/component/active/airplane/index.tsx +17 -0
  9. package/src/gaesup/component/active/airplane/type.ts +4 -0
  10. package/src/gaesup/component/active/character/index.tsx +35 -0
  11. package/src/gaesup/component/active/character/type.ts +13 -0
  12. package/src/gaesup/component/active/vehicle/index.tsx +17 -0
  13. package/src/gaesup/component/active/vehicle/type.ts +4 -0
  14. package/src/gaesup/component/index.tsx +65 -0
  15. package/src/gaesup/component/inner/airplane/index.tsx +21 -0
  16. package/src/gaesup/component/inner/airplane/type.ts +8 -0
  17. package/src/gaesup/component/inner/character/index.tsx +22 -0
  18. package/src/gaesup/component/inner/character/type.ts +14 -0
  19. package/src/gaesup/component/inner/common/InnerGroupRef.tsx +56 -0
  20. package/src/gaesup/component/inner/common/OuterGroupRef.tsx +19 -0
  21. package/src/gaesup/component/inner/common/RigidbodyRef.tsx +159 -0
  22. package/src/gaesup/component/inner/common/calc.ts +16 -0
  23. package/src/gaesup/component/inner/common/partsGroupRef.tsx +66 -0
  24. package/src/gaesup/component/inner/common/setGroundRay.ts +24 -0
  25. package/src/gaesup/component/inner/common/type.ts +66 -0
  26. package/src/gaesup/component/inner/rider/index.tsx +79 -0
  27. package/src/gaesup/component/inner/vehicle/collider.tsx +40 -0
  28. package/src/gaesup/component/inner/vehicle/index.tsx +44 -0
  29. package/src/gaesup/component/inner/vehicle/type.ts +8 -0
  30. package/src/gaesup/component/inner/vehicle/wheels.tsx +124 -0
  31. package/src/gaesup/component/passive/airplane/index.tsx +65 -0
  32. package/src/gaesup/component/passive/airplane/type.ts +3 -0
  33. package/src/gaesup/component/passive/character/index.tsx +49 -0
  34. package/src/gaesup/component/passive/character/type.ts +6 -0
  35. package/src/gaesup/component/passive/type.ts +51 -0
  36. package/src/gaesup/component/passive/vehicle/index.tsx +45 -0
  37. package/src/gaesup/component/passive/vehicle/type.ts +3 -0
  38. package/src/gaesup/component/type.ts +16 -0
  39. package/src/gaesup/controller/context/index.ts +55 -0
  40. package/src/gaesup/controller/context/reducer.ts +18 -0
  41. package/src/gaesup/controller/context/type.ts +42 -0
  42. package/src/gaesup/controller/index.tsx +116 -0
  43. package/src/gaesup/controller/initialize/callback/index.ts +88 -0
  44. package/src/gaesup/controller/initialize/callback/type.ts +35 -0
  45. package/src/gaesup/controller/initialize/index.ts +90 -0
  46. package/src/gaesup/controller/style.css +48 -0
  47. package/src/gaesup/controller/type.ts +127 -0
  48. package/src/gaesup/gaesupProps/index.tsx +65 -0
  49. package/src/gaesup/hooks/useClicker/index.ts +38 -0
  50. package/src/gaesup/hooks/useFocus/index.tsx +129 -0
  51. package/src/gaesup/hooks/useGaesupAnimation/index.tsx +128 -0
  52. package/src/gaesup/hooks/useGaesupController/index.ts +25 -0
  53. package/src/gaesup/hooks/useGaesupGltf/index.tsx +78 -0
  54. package/src/gaesup/hooks/useMovePoint/index.ts +34 -0
  55. package/src/gaesup/hooks/usePushKey/index.ts +26 -0
  56. package/src/gaesup/hooks/useRayHit/index.ts +24 -0
  57. package/src/gaesup/hooks/useRideable/index.tsx +121 -0
  58. package/src/gaesup/hooks/useRideable/type.ts +20 -0
  59. package/src/gaesup/hooks/useTeleport/index.tsx +21 -0
  60. package/src/gaesup/hooks/useZoom/index.tsx +24 -0
  61. package/src/gaesup/physics/airplane/damping.ts +10 -0
  62. package/src/gaesup/physics/airplane/direction.ts +63 -0
  63. package/src/gaesup/physics/airplane/gravity.ts +14 -0
  64. package/src/gaesup/physics/airplane/impulse.ts +26 -0
  65. package/src/gaesup/physics/airplane/index.tsx +16 -0
  66. package/src/gaesup/physics/airplane/innerCalc.ts +27 -0
  67. package/src/gaesup/physics/airplane/landing.ts +28 -0
  68. package/src/gaesup/physics/character/direction.ts +64 -0
  69. package/src/gaesup/physics/character/impulse.ts +35 -0
  70. package/src/gaesup/physics/character/index.tsx +14 -0
  71. package/src/gaesup/physics/character/innerCalc.ts +27 -0
  72. package/src/gaesup/physics/character/queue.ts +52 -0
  73. package/src/gaesup/physics/character/stop.ts +13 -0
  74. package/src/gaesup/physics/check/ground.ts +28 -0
  75. package/src/gaesup/physics/check/index.ts +14 -0
  76. package/src/gaesup/physics/check/moving.ts +15 -0
  77. package/src/gaesup/physics/check/push.ts +10 -0
  78. package/src/gaesup/physics/check/riding.ts +12 -0
  79. package/src/gaesup/physics/check/rotate.ts +13 -0
  80. package/src/gaesup/physics/index.ts +80 -0
  81. package/src/gaesup/physics/type.ts +57 -0
  82. package/src/gaesup/physics/vehicle/damping.ts +12 -0
  83. package/src/gaesup/physics/vehicle/direction.ts +27 -0
  84. package/src/gaesup/physics/vehicle/impulse.ts +28 -0
  85. package/src/gaesup/physics/vehicle/index.tsx +14 -0
  86. package/src/gaesup/physics/vehicle/innerCalc.ts +17 -0
  87. package/src/gaesup/physics/vehicle/landing.ts +28 -0
  88. package/src/gaesup/tools/clicker/index.tsx +60 -0
  89. package/src/gaesup/tools/gamepad/GamePadButton.tsx +47 -0
  90. package/src/gaesup/tools/gamepad/index.tsx +51 -0
  91. package/src/gaesup/tools/gamepad/style.css.ts +54 -0
  92. package/src/gaesup/tools/gamepad/type.ts +13 -0
  93. package/src/gaesup/tools/minimap/index.tsx +231 -0
  94. package/src/gaesup/tools/minimap/style.css.ts +205 -0
  95. package/src/gaesup/tools/minimap/type.ts +44 -0
  96. package/src/gaesup/tools/rideable/index.tsx +72 -0
  97. package/src/gaesup/tools/rideable/type.ts +27 -0
  98. package/src/gaesup/tools/shared.css.ts +44 -0
  99. package/src/gaesup/tools/teleport/index.tsx +20 -0
  100. package/src/gaesup/tools/teleport/style.css.ts +14 -0
  101. package/src/gaesup/tools/teleport/type.ts +8 -0
  102. package/src/gaesup/tools/type.ts +3 -0
  103. package/src/gaesup/utils/context.ts +5 -0
  104. package/src/gaesup/utils/getTag.ts +7 -0
  105. package/src/gaesup/utils/index.ts +3 -0
  106. package/src/gaesup/utils/innerHtml.tsx +22 -0
  107. package/src/gaesup/utils/ray.ts +22 -0
  108. package/src/gaesup/utils/ref.ts +17 -0
  109. package/src/gaesup/utils/type.ts +6 -0
  110. package/src/gaesup/utils/vector.ts +65 -0
  111. package/src/gaesup/world/context/index.ts +115 -0
  112. package/src/gaesup/world/context/reducer.ts +18 -0
  113. package/src/gaesup/world/context/type.ts +210 -0
  114. package/src/gaesup/world/index.tsx +17 -0
  115. package/src/gaesup/world/initalize/index.ts +42 -0
  116. package/src/gaesup/world/type.ts +27 -0
  117. package/src/index.ts +24 -0
  118. package/dist/draco/draco_decoder.wasm +0 -0
  119. package/dist/draco/draco_wasm_wrapper.js +0 -128
  120. package/dist/gaesup-world.cjs.js +0 -81
  121. package/dist/gaesup-world.es.js +0 -6246
  122. package/dist/gaesupworld.svg +0 -74
  123. package/dist/gltf/ally.glb +0 -0
  124. package/dist/gltf/ally_body.glb +0 -0
  125. package/dist/gltf/ally_cloth.glb +0 -0
  126. package/dist/gltf/ally_cloth_rabbit.glb +0 -0
  127. package/dist/gltf/ally_glass.glb +0 -0
  128. package/dist/gltf/ally_hat.glb +0 -0
  129. package/dist/sitemap.xml +0 -834
  130. package/dist/vercel.svg +0 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.9.778",
3
+ "version": "0.9.780",
4
4
  "type": "commonjs",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.d.ts",
@@ -46,7 +46,7 @@
46
46
  }
47
47
  },
48
48
  "files": [
49
- "dist",
49
+ "src",
50
50
  "README.md",
51
51
  "LICENSE.txt"
52
52
  ],
@@ -0,0 +1,112 @@
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 { GaesupWorldContext, GaesupWorldDispatchContext } from '../world/context'
6
+ import { playActionsType, subscribeActionsType } from './type'
7
+
8
+ export function subscribeActions({ type }: subscribeActionsType) {
9
+ const { states } = useContext(GaesupWorldContext)
10
+ const { subscribeAll } = useGaesupAnimation({ type })
11
+ // 초기 기본 애니메이션 등록
12
+ useEffect(() => {
13
+ subscribeAll([
14
+ {
15
+ tag: 'walk',
16
+ condition: () => !states.isRunning && states.isMoving,
17
+ action: () => {},
18
+ animationName: 'walk',
19
+ key: 'walk',
20
+ },
21
+ {
22
+ tag: 'run',
23
+ condition: () => states.isRunning,
24
+ action: () => {},
25
+ animationName: 'run',
26
+ key: 'run',
27
+ },
28
+ {
29
+ tag: 'jump',
30
+ condition: () => states.isJumping,
31
+ action: () => {},
32
+ animationName: 'jump',
33
+ key: 'jump',
34
+ },
35
+
36
+ {
37
+ tag: 'ride',
38
+ condition: () => states.isPush['keyR'],
39
+ action: () => {},
40
+ animationName: 'ride',
41
+ key: 'ride',
42
+ },
43
+ {
44
+ tag: 'land',
45
+ condition: () => states.isLanding,
46
+ action: () => {},
47
+ animationName: 'land',
48
+ key: 'land',
49
+ },
50
+ {
51
+ tag: 'fall',
52
+ condition: () => states.isFalling,
53
+ action: () => {},
54
+ animationName: 'fall',
55
+ key: 'fall',
56
+ },
57
+ ])
58
+ }, [])
59
+ }
60
+
61
+ export default function playActions({ type, actions, animationRef, currentAnimation, isActive }: playActionsType) {
62
+ const { mode, animationState, block } = useContext(GaesupWorldContext)
63
+ const dispatch = useContext(GaesupWorldDispatchContext)
64
+ const { notify, store } = useGaesupAnimation({ type })
65
+
66
+ if (isActive) {
67
+ currentAnimation = animationState?.[type]?.current
68
+ }
69
+
70
+ const play = (tag: keyof animationTagType) => {
71
+ animationState[type].current = tag
72
+ const currentAnimation = store[tag]
73
+ if (currentAnimation?.action) {
74
+ currentAnimation.action()
75
+ }
76
+ dispatch({
77
+ type: 'update',
78
+ payload: {
79
+ animationState: {
80
+ ...animationState,
81
+ },
82
+ },
83
+ })
84
+ }
85
+
86
+ useEffect(() => {
87
+ let animation = 'idle'
88
+ if (block.animation) {
89
+ animation = 'idle'
90
+ } else if (currentAnimation) {
91
+ animation = currentAnimation
92
+ } else if (animationState[type].current) {
93
+ animation = animationState[type].current
94
+ }
95
+ const action = actions[animation]?.reset().fadeIn(0.2).play()
96
+ return () => {
97
+ action?.fadeOut(0.2)
98
+ }
99
+ }, [currentAnimation, mode.type, block.animation, type])
100
+
101
+ useFrame(() => {
102
+ if (isActive) {
103
+ const tag = notify() as keyof animationTagType
104
+ play(tag)
105
+ }
106
+ })
107
+
108
+ return {
109
+ animationRef,
110
+ currentAnimation: animationState?.[type]?.current,
111
+ }
112
+ }
@@ -0,0 +1,37 @@
1
+ import { Ref } from 'react'
2
+ import * as THREE from 'three'
3
+ import { AnimationAction, AnimationClip, AnimationMixer, Object3D, Object3DEventMap } from 'three'
4
+ import { groundRayType } from '../controller/type'
5
+
6
+ export type Api<T extends AnimationClip> = {
7
+ ref: React.MutableRefObject<Object3D | undefined | null>
8
+ clips: AnimationClip[]
9
+ mixer: AnimationMixer
10
+ names: T['name'][]
11
+ actions: {
12
+ [key in T['name']]: AnimationAction | null
13
+ }
14
+ }
15
+
16
+ export type playActionsType = {
17
+ type: 'character' | 'vehicle' | 'airplane'
18
+ currentAnimation?: string
19
+ actions: actionsType
20
+ animationRef: Ref<Object3D<Object3DEventMap>>
21
+ isActive: boolean
22
+ }
23
+
24
+ export type subscribeActionsType = {
25
+ type: 'character' | 'vehicle' | 'airplane'
26
+ groundRay: groundRayType
27
+ animations: AnimationClip[]
28
+ }
29
+
30
+ export type actionsType = {
31
+ [x: string]: THREE.AnimationAction | null
32
+ }
33
+
34
+ export type playResultType = {
35
+ actions: actionsType
36
+ ref: Ref<Object3D<Object3DEventMap>>
37
+ }
@@ -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: any
12
+ ) => {
13
+ return (
14
+ <group ref={ref} userData={{ intangible: true }}>
15
+ {children}
16
+ </group>
17
+ )
18
+ }
19
+ )