gaesup-world 0.0.783 → 0.1.0
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/README.md +24 -20
- package/dist/gaesup/animation/actions.d.ts +7 -4
- package/dist/gaesup/animation/actions.js +77 -75
- package/dist/gaesup/camera/control/normal.js +1 -1
- package/dist/gaesup/component/active/airplane/index.js +3 -4
- package/dist/gaesup/component/active/common/InnerGroupRef.js +5 -2
- package/dist/gaesup/component/active/common/RiderGroupRef.d.ts +7 -0
- package/dist/gaesup/component/active/common/RiderGroupRef.js +32 -0
- package/dist/gaesup/component/active/vehicle/index.js +3 -4
- package/dist/gaesup/component/index.js +1 -1
- package/dist/gaesup/component/passive/airplane/index.js +7 -7
- package/dist/gaesup/component/passive/airplane/type.d.ts +2 -0
- package/dist/gaesup/component/passive/common/RigidbodyRef.d.ts +2 -1
- package/dist/gaesup/component/passive/common/RigidbodyRef.js +3 -3
- package/dist/gaesup/component/passive/vehicle/index.js +7 -2
- package/dist/gaesup/component/passive/vehicle/type.d.ts +2 -0
- package/dist/gaesup/controller/index.d.ts +1 -0
- package/dist/gaesup/controller/index.js +7 -1
- package/dist/gaesup/controller/initialize/callback/index.js +3 -5
- package/dist/gaesup/controller/initialize/callback/type.d.ts +2 -1
- package/dist/gaesup/gaesupProps/index.d.ts +2 -1
- package/dist/gaesup/gaesupProps/index.js +7 -3
- package/dist/gaesup/hooks/useGaesupAnimation/index.d.ts +8 -0
- package/dist/gaesup/hooks/useGaesupAnimation/index.js +94 -0
- package/dist/gaesup/hooks/useRideable/index.d.ts +28 -0
- package/dist/gaesup/hooks/useRideable/index.js +198 -0
- package/dist/gaesup/hooks/useTeleport/index.d.ts +3 -0
- package/dist/gaesup/hooks/useTeleport/index.js +12 -0
- package/dist/gaesup/physics/airplane/direction.js +0 -1
- package/dist/gaesup/physics/airplane/index.js +2 -0
- package/dist/gaesup/physics/airplane/landing.d.ts +2 -0
- package/dist/gaesup/physics/airplane/landing.js +29 -0
- package/dist/gaesup/physics/check/index.js +4 -0
- package/dist/gaesup/physics/check/push.d.ts +2 -0
- package/dist/gaesup/physics/check/push.js +6 -0
- package/dist/gaesup/physics/check/riding.d.ts +2 -0
- package/dist/gaesup/physics/check/riding.js +7 -0
- package/dist/gaesup/physics/index.js +1 -1
- package/dist/gaesup/physics/vehicle/direction.js +0 -6
- package/dist/gaesup/physics/vehicle/index.js +2 -0
- package/dist/gaesup/physics/vehicle/landing.d.ts +2 -0
- package/dist/gaesup/physics/vehicle/landing.js +29 -0
- package/dist/gaesup/tools/jumpPortal/index.d.ts +1 -1
- package/dist/gaesup/tools/jumpPortal/index.js +6 -7
- package/dist/gaesup/tools/keyBoardToolTip/type.d.ts +2 -0
- package/dist/gaesup/tools/miniMap/index.js +22 -8
- package/dist/gaesup/tools/miniMap/type.d.ts +4 -1
- package/dist/gaesup/tools/rideable/index.d.ts +2 -8
- package/dist/gaesup/tools/rideable/index.js +37 -72
- package/dist/gaesup/tools/zoomButton/index.d.ts +7 -0
- package/dist/gaesup/tools/zoomButton/index.js +37 -13
- package/dist/gaesup/world/context/index.js +16 -12
- package/dist/gaesup/world/context/reducer.d.ts +3 -1
- package/dist/gaesup/world/context/type.d.ts +30 -5
- package/dist/gaesup/world/debug/index.js +1 -23
- package/dist/gaesup/world/initalize/index.d.ts +3 -1
- package/dist/gaesup/world/initalize/index.js +1 -1
- package/package.json +6 -5
- package/dist/gaesup/component/passive/vehicle/collider.d.ts +0 -6
- package/dist/gaesup/component/passive/vehicle/collider.js +0 -7
package/README.md
CHANGED
|
@@ -191,30 +191,32 @@ This is the airplane control in Gaesup World. Characters can board the airplane.
|
|
|
191
191
|
|
|
192
192
|
#### [gameboy](#gameboy)
|
|
193
193
|
|
|
194
|
-
|
|
194
|
+
1. JoyStick
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
- 가상 조이스틱 인터페이스를 제공하는 컴포넌트입니다. 모바일 환경에서 사용을 권장합니다
|
|
196
|
+
- This component provides a virtual joystick interface. It is recommended for use in mobile environments.
|
|
199
197
|
|
|
200
|
-
>
|
|
198
|
+
> Caution! Due to position fluctuation in mobile environments, it is recommended to use the scrollBlock option of GaesupWorld.
|
|
201
199
|
|
|
202
|
-
### (2)
|
|
200
|
+
### (2) Features
|
|
203
201
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
202
|
+
Joystick Interface for Mobile and Other Environments: Provides a joystick interface in environments like mobile.
|
|
203
|
+
Custom Appearance: Receives joyStickBallStyle and joyStickStyle properties for styling the joystick and its ball.
|
|
204
|
+
Responsive and Interactive: Supports mouse and mobile touch events to cater to various devices.
|
|
207
205
|
|
|
208
206
|
### (3) Props
|
|
209
207
|
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
joyStickBallStyle: Style of the joystick ball (React.CSSProperties object).
|
|
209
|
+
joyStickStyle: Style of the joystick container (React.CSSProperties object).
|
|
212
210
|
|
|
213
211
|
### (4) How To Use
|
|
214
212
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
213
|
+
- Include the JoyStick component in your `GaesupWorld` component tree.
|
|
214
|
+
|
|
215
|
+
> It is imperative to use it inside the GaesupWorld component
|
|
216
|
+
|
|
217
|
+
- The component responds to mouse and touch inputs to control movement.
|
|
218
|
+
|
|
219
|
+
- (Optional) Customize the necessary style using joyStickBallStyle and joyStickStyle.
|
|
218
220
|
|
|
219
221
|
### (5) Example
|
|
220
222
|
|
|
@@ -304,7 +306,7 @@ const MyComponent = () => {
|
|
|
304
306
|
- **커스텀 스타일링**: 미니맵 및 그 내부 요소들의 스타일을 사용자 정의할 수 있습니다.
|
|
305
307
|
- **마우스 휠 지원**: 마우스 휠을 사용하여 미니맵의 스케일을 조절할 수 있습니다.
|
|
306
308
|
|
|
307
|
-
|
|
309
|
+
### (3) 사용 방법
|
|
308
310
|
|
|
309
311
|
1. `MiniMap` 컴포넌트를 컴포넌트 트리에 포함시킵니다.
|
|
310
312
|
2. 필요한 스타일을 `minimapStyle`, `innerStyle`, `textStyle`, `objectStyle`, `avatarStyle`, `scaleStyle`, `directionStyle`, `plusMinusStyle` 속성을 통해 전달합니다.
|
|
@@ -408,7 +410,7 @@ const MyComponent = () => {
|
|
|
408
410
|
|
|
409
411
|
## 예제 코드
|
|
410
412
|
|
|
411
|
-
```
|
|
413
|
+
```tsx
|
|
412
414
|
import { GamePad } from "./GamePad";
|
|
413
415
|
import { GaesupWorldContext } from "../../world/context";
|
|
414
416
|
|
|
@@ -451,15 +453,17 @@ const MyComponent = () => {
|
|
|
451
453
|
|
|
452
454
|
## 예제 코드
|
|
453
455
|
|
|
454
|
-
```
|
|
456
|
+
```tsx
|
|
455
457
|
import { ZoomButton } from "./ZoomButton";
|
|
456
458
|
import * as THREE from "three";
|
|
457
459
|
|
|
458
460
|
const App = () => {
|
|
459
461
|
return (
|
|
460
|
-
<
|
|
461
|
-
|
|
462
|
-
|
|
462
|
+
<GaesupWorld>
|
|
463
|
+
{/* ... */}
|
|
464
|
+
<ZoomButton position={new THREE.Vector3(0, 0, 5)}>{children}</ZoomButton>
|
|
465
|
+
{/* ... */}
|
|
466
|
+
</GaesupWorld>
|
|
463
467
|
);
|
|
464
468
|
};
|
|
465
469
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ref } from "react";
|
|
2
2
|
import { Object3D, Object3DEventMap } from "three";
|
|
3
|
-
import {
|
|
3
|
+
import { groundRayType } from "../controller/type";
|
|
4
4
|
export type playActionsType = {
|
|
5
5
|
groundRay: groundRayType;
|
|
6
6
|
};
|
|
@@ -11,15 +11,18 @@ export type playResultType = {
|
|
|
11
11
|
actions: actionsType;
|
|
12
12
|
ref: Ref<Object3D<Object3DEventMap>>;
|
|
13
13
|
};
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function readyAnimation(): {
|
|
15
15
|
resultRef: {
|
|
16
16
|
character: playResultType;
|
|
17
17
|
vehicle: playResultType;
|
|
18
18
|
airplane: playResultType;
|
|
19
19
|
};
|
|
20
|
-
play: (tag: keyof animationTagType) => void;
|
|
21
|
-
setAnimationName: (actions: actionsType) => void;
|
|
22
20
|
};
|
|
23
21
|
export default function playCharacterActions({ groundRay }: playActionsType): {
|
|
24
22
|
ref: Ref<Object3D<Object3DEventMap>>;
|
|
23
|
+
resultRef: {
|
|
24
|
+
character: playResultType;
|
|
25
|
+
vehicle: playResultType;
|
|
26
|
+
airplane: playResultType;
|
|
27
|
+
};
|
|
25
28
|
};
|
|
@@ -12,26 +12,49 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { useAnimations, useKeyboardControls } from "@react-three/drei";
|
|
13
13
|
import { useFrame } from "@react-three/fiber";
|
|
14
14
|
import { useContext, useEffect } from "react";
|
|
15
|
+
import { useGaesupAnimation } from "../hooks/useGaesupAnimation";
|
|
15
16
|
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context";
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
// 캐릭터 등록, 애니메이션 이름 설정, 애니메이션 실행
|
|
18
|
+
export function readyAnimation() {
|
|
19
|
+
var _a = useContext(GaesupWorldContext), characterGltf = _a.characterGltf, vehicleGltf = _a.vehicleGltf, airplaneGltf = _a.airplaneGltf;
|
|
18
20
|
var resultRef = {
|
|
19
21
|
character: null,
|
|
20
22
|
vehicle: null,
|
|
21
23
|
airplane: null,
|
|
22
24
|
};
|
|
23
|
-
if (characterGltf && characterGltf.animations)
|
|
25
|
+
if (characterGltf && characterGltf.animations)
|
|
24
26
|
resultRef.character = useAnimations(characterGltf.animations);
|
|
25
|
-
|
|
26
|
-
if (vehicleGltf && vehicleGltf.animations) {
|
|
27
|
+
if (vehicleGltf && vehicleGltf.animations)
|
|
27
28
|
resultRef.vehicle = useAnimations(vehicleGltf.animations);
|
|
28
|
-
|
|
29
|
-
if (airplaneGltf && airplaneGltf.animations) {
|
|
29
|
+
if (airplaneGltf && airplaneGltf.animations)
|
|
30
30
|
resultRef.airplane = useAnimations(airplaneGltf.animations);
|
|
31
|
-
|
|
31
|
+
return {
|
|
32
|
+
resultRef: resultRef,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export default function playCharacterActions(_a) {
|
|
36
|
+
var groundRay = _a.groundRay;
|
|
37
|
+
var _b = useContext(GaesupWorldContext), states = _b.states, activeState = _b.activeState, animations = _b.animations, mode = _b.mode, characterGltf = _b.characterGltf, vehicleGltf = _b.vehicleGltf, airplaneGltf = _b.airplaneGltf;
|
|
32
38
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
39
|
+
var control = useKeyboardControls()[1]();
|
|
40
|
+
var _c = useGaesupAnimation(), subscribeAll = _c.subscribeAll, notify = _c.notify, store = _c.store;
|
|
41
|
+
var resultRef = {
|
|
42
|
+
character: null,
|
|
43
|
+
vehicle: null,
|
|
44
|
+
airplane: null,
|
|
45
|
+
};
|
|
46
|
+
if (characterGltf && characterGltf.animations)
|
|
47
|
+
resultRef.character = useAnimations(characterGltf.animations);
|
|
48
|
+
if (vehicleGltf && vehicleGltf.animations)
|
|
49
|
+
resultRef.vehicle = useAnimations(vehicleGltf.animations);
|
|
50
|
+
if (airplaneGltf && airplaneGltf.animations)
|
|
51
|
+
resultRef.airplane = useAnimations(airplaneGltf.animations);
|
|
33
52
|
var play = function (tag) {
|
|
34
53
|
animations.current = tag;
|
|
54
|
+
var currentAnimation = store[tag];
|
|
55
|
+
if (currentAnimation === null || currentAnimation === void 0 ? void 0 : currentAnimation.action) {
|
|
56
|
+
currentAnimation.action();
|
|
57
|
+
}
|
|
35
58
|
dispatch({
|
|
36
59
|
type: "update",
|
|
37
60
|
payload: {
|
|
@@ -39,39 +62,46 @@ export function usePlayActions() {
|
|
|
39
62
|
},
|
|
40
63
|
});
|
|
41
64
|
};
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
var _a;
|
|
45
|
-
return __assign(__assign({}, acc), (_a = {}, _a[cur] = cur, _a));
|
|
46
|
-
}, {}));
|
|
47
|
-
dispatch({
|
|
48
|
-
type: "update",
|
|
49
|
-
payload: {
|
|
50
|
-
animations: __assign({}, animations),
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
return { resultRef: resultRef, play: play, setAnimationName: setAnimationName };
|
|
55
|
-
}
|
|
56
|
-
export default function playCharacterActions(_a) {
|
|
57
|
-
var groundRay = _a.groundRay;
|
|
58
|
-
var _b = usePlayActions(), _c = _b.resultRef.character, actions = _c.actions, ref = _c.ref, play = _b.play, setAnimationName = _b.setAnimationName;
|
|
59
|
-
var _d = useContext(GaesupWorldContext), states = _d.states, activeState = _d.activeState, animations = _d.animations, mode = _d.mode;
|
|
60
|
-
var isNotMoving = states.isNotMoving, isMoving = states.isMoving, isJumping = states.isJumping, isRunning = states.isRunning, isAnimationOuter = states.isAnimationOuter, isOnTheGround = states.isOnTheGround;
|
|
61
|
-
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
62
|
-
var control = useKeyboardControls()[1]();
|
|
63
|
-
var resetAni = function () { return play("idle"); };
|
|
64
|
-
var playIdle = function () { return play("idle"); };
|
|
65
|
-
var playWalk = function () { return play("walk"); };
|
|
66
|
-
var playRun = function () { return play("run"); };
|
|
67
|
-
var playJump = function () { return play("jump"); };
|
|
68
|
-
var playFall = function () { return play("fall"); };
|
|
69
|
-
var playRide = function () { return play("ride"); };
|
|
70
|
-
var playLanding = function () { return play("land"); };
|
|
65
|
+
var _d = resultRef.character, actions = _d.actions, ref = _d.ref;
|
|
66
|
+
// 초기 기본 애니메이션 등록
|
|
71
67
|
useEffect(function () {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
subscribeAll([
|
|
69
|
+
{
|
|
70
|
+
tag: "walk",
|
|
71
|
+
condition: function () { return !states.isRunning && states.isMoving; },
|
|
72
|
+
action: function () { },
|
|
73
|
+
animationName: "walk",
|
|
74
|
+
key: "walk",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
tag: "run",
|
|
78
|
+
condition: function () { return states.isRunning; },
|
|
79
|
+
action: function () { },
|
|
80
|
+
animationName: "run",
|
|
81
|
+
key: "run",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
tag: "jump",
|
|
85
|
+
condition: function () { return states.isJumping; },
|
|
86
|
+
action: function () { },
|
|
87
|
+
animationName: "jump",
|
|
88
|
+
key: "jump",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
tag: "fall",
|
|
92
|
+
condition: function () { return groundRay.hit === null && activeState.velocity.y < 0; },
|
|
93
|
+
action: function () { },
|
|
94
|
+
animationName: "fall",
|
|
95
|
+
key: "fall",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
tag: "ride",
|
|
99
|
+
condition: function () { return states.isPush["keyR"]; },
|
|
100
|
+
action: function () { },
|
|
101
|
+
animationName: "ride",
|
|
102
|
+
key: "ride",
|
|
103
|
+
},
|
|
104
|
+
]);
|
|
75
105
|
}, []);
|
|
76
106
|
useEffect(function () {
|
|
77
107
|
animations.keyControl = control;
|
|
@@ -84,45 +114,17 @@ export default function playCharacterActions(_a) {
|
|
|
84
114
|
}, [control]);
|
|
85
115
|
useEffect(function () {
|
|
86
116
|
var _a;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
action_1 === null || action_1 === void 0 ? void 0 : action_1.fadeOut(0.2);
|
|
92
|
-
};
|
|
93
|
-
}
|
|
117
|
+
var action = (_a = actions[animations.current]) === null || _a === void 0 ? void 0 : _a.reset().fadeIn(0.2).play();
|
|
118
|
+
return function () {
|
|
119
|
+
action === null || action === void 0 ? void 0 : action.fadeOut(0.2);
|
|
120
|
+
};
|
|
94
121
|
}, [animations.current, mode.type]);
|
|
95
122
|
useFrame(function () {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (isJumping) {
|
|
99
|
-
playJump();
|
|
100
|
-
}
|
|
101
|
-
else if (isNotMoving) {
|
|
102
|
-
playIdle();
|
|
103
|
-
}
|
|
104
|
-
else if (isRunning) {
|
|
105
|
-
playRun();
|
|
106
|
-
}
|
|
107
|
-
else if (isMoving) {
|
|
108
|
-
playWalk();
|
|
109
|
-
}
|
|
110
|
-
// if (groundRay.hit) {
|
|
111
|
-
// if (!isJumping && !isOnTheGround) {
|
|
112
|
-
// if (groundRay.hit.toi < 5) {
|
|
113
|
-
// playLanding();
|
|
114
|
-
// } else {
|
|
115
|
-
// playFall();
|
|
116
|
-
// }
|
|
117
|
-
// }
|
|
118
|
-
// }
|
|
119
|
-
// if (groundRay.hit === null && activeState.velocity.y < 0) {
|
|
120
|
-
// playFall();
|
|
121
|
-
// }
|
|
122
|
-
}
|
|
123
|
-
}
|
|
123
|
+
var tag = notify();
|
|
124
|
+
play(tag);
|
|
124
125
|
});
|
|
125
126
|
return {
|
|
126
127
|
ref: ref,
|
|
128
|
+
resultRef: resultRef,
|
|
127
129
|
};
|
|
128
130
|
}
|
|
@@ -6,6 +6,6 @@ export default function normal(prop) {
|
|
|
6
6
|
var cameraPosition = activeState.position
|
|
7
7
|
.clone()
|
|
8
8
|
.add(V3(0, cameraOption.YDistance, cameraOption.XZDistance));
|
|
9
|
-
state.camera.position.lerp(cameraPosition,
|
|
9
|
+
state.camera.position.lerp(cameraPosition, 1);
|
|
10
10
|
state.camera.lookAt(activeState.position.clone());
|
|
11
11
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
import { GaesupWorldContext } from "../../../world/context";
|
|
4
|
-
import { InnerGroupRef } from "../common/InnerGroupRef";
|
|
5
4
|
import { WrapperRef } from "../common/WrapperRef";
|
|
6
5
|
import { AirplaneCollider } from "./collider";
|
|
7
6
|
export function AirplaneRef(_a) {
|
|
8
7
|
var props = _a.props, refs = _a.refs;
|
|
9
|
-
var
|
|
10
|
-
return (
|
|
8
|
+
var airplaneGltf = useContext(GaesupWorldContext).airplaneGltf;
|
|
9
|
+
return (_jsx(WrapperRef, { props: props, refs: refs, gltf: airplaneGltf, children: _jsx(AirplaneCollider, { props: props }) }));
|
|
11
10
|
}
|
|
@@ -10,17 +10,20 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { Suspense, forwardRef, useMemo } from "react";
|
|
13
|
+
import { Suspense, forwardRef, useContext, useMemo } from "react";
|
|
14
14
|
import { useGraph } from "@react-three/fiber";
|
|
15
15
|
import * as THREE from "three";
|
|
16
16
|
import { SkeletonUtils } from "three-stdlib";
|
|
17
|
+
import { GaesupWorldContext } from "../../../world/context";
|
|
18
|
+
import { RiderGroup } from "./RiderGroupRef";
|
|
17
19
|
export var InnerGroupRef = forwardRef(function (_a, ref) {
|
|
18
20
|
var props = _a.props, animationRef = _a.animationRef, gltf = _a.gltf;
|
|
21
|
+
var _b = useContext(GaesupWorldContext), mode = _b.mode, states = _b.states;
|
|
19
22
|
var scene = gltf.scene;
|
|
20
23
|
var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
|
|
21
24
|
var nodes = useGraph(clone).nodes;
|
|
22
25
|
var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
|
|
23
|
-
return (_jsx(Suspense, { children: _jsxs("group", __assign({ receiveShadow: true, castShadow: true }, props.groupProps, { ref: ref, children: [objectNode && animationRef && (_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: animationRef })), Object.keys(nodes).map(function (name, key) {
|
|
26
|
+
return (_jsx(Suspense, { fallback: null, children: _jsxs("group", __assign({ receiveShadow: true, castShadow: true }, props.groupProps, { ref: ref, children: [mode.type !== "character" && states.isRiderOn && (_jsx(RiderGroup, { props: props })), objectNode && animationRef && (_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: animationRef })), Object.keys(nodes).map(function (name, key) {
|
|
24
27
|
var node = nodes[name];
|
|
25
28
|
if (node instanceof THREE.SkinnedMesh) {
|
|
26
29
|
return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry, skeleton: node.skeleton }, key));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Ref } from "react";
|
|
2
|
+
import { controllerInnerType } from "../../../controller/type";
|
|
3
|
+
import * as THREE from "three";
|
|
4
|
+
export type RiderGroupRefType = {
|
|
5
|
+
props: controllerInnerType;
|
|
6
|
+
};
|
|
7
|
+
export declare const RiderGroup: ({ props }: RiderGroupRefType, ref: Ref<THREE.Group>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useMemo } from "react";
|
|
3
|
+
import { useGraph } from "@react-three/fiber";
|
|
4
|
+
import * as THREE from "three";
|
|
5
|
+
import { SkeletonUtils } from "three-stdlib";
|
|
6
|
+
import playPassiveActions from "../../../animation/passiveActions";
|
|
7
|
+
import { GaesupWorldContext } from "../../../world/context";
|
|
8
|
+
export var RiderGroup = function (_a, ref) {
|
|
9
|
+
var props = _a.props;
|
|
10
|
+
var _b = useContext(GaesupWorldContext), characterGltf = _b.characterGltf, states = _b.states, characterCollider = _b.characterCollider;
|
|
11
|
+
var characterAnimationRef = playPassiveActions({
|
|
12
|
+
current: "ride",
|
|
13
|
+
animations: characterGltf.animations,
|
|
14
|
+
}).animationRef;
|
|
15
|
+
var characterScene = characterGltf.scene;
|
|
16
|
+
var characterClone = useMemo(function () { return SkeletonUtils.clone(characterScene); }, [characterScene]);
|
|
17
|
+
var characterNodes = useGraph(characterClone).nodes;
|
|
18
|
+
var characterObjectNode = Object.values(characterNodes).find(function (node) { return node.type === "Object3D"; });
|
|
19
|
+
return (_jsx(_Fragment, { children: characterAnimationRef && (_jsxs("group", { position: [
|
|
20
|
+
(characterCollider === null || characterCollider === void 0 ? void 0 : characterCollider.riderOffsetX) || 0,
|
|
21
|
+
(characterCollider === null || characterCollider === void 0 ? void 0 : characterCollider.riderOffsetY) || 0,
|
|
22
|
+
(characterCollider === null || characterCollider === void 0 ? void 0 : characterCollider.riderOffsetZ) || 0,
|
|
23
|
+
], children: [characterObjectNode && (_jsx("primitive", { object: characterObjectNode, visible: false, receiveShadow: true, castShadow: true, ref: characterAnimationRef })), Object.keys(characterNodes).map(function (name, key) {
|
|
24
|
+
var characterNode = characterNodes[name];
|
|
25
|
+
if (characterNode instanceof THREE.SkinnedMesh) {
|
|
26
|
+
return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: characterNode.material, geometry: characterNode.geometry, skeleton: characterNode.skeleton }, key));
|
|
27
|
+
}
|
|
28
|
+
else if (characterNode instanceof THREE.Mesh) {
|
|
29
|
+
return (_jsx("mesh", { castShadow: true, receiveShadow: true, material: characterNode.material, geometry: characterNode.geometry }, key));
|
|
30
|
+
}
|
|
31
|
+
})] })) }));
|
|
32
|
+
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
import { GaesupWorldContext } from "../../../world/context";
|
|
4
|
-
import { InnerGroupRef } from "../common/InnerGroupRef";
|
|
5
4
|
import { WrapperRef } from "../common/WrapperRef";
|
|
6
5
|
import { VehicleCollider } from "./collider";
|
|
7
6
|
import { Wheels } from "./wheels";
|
|
8
7
|
export function VehicleRef(_a) {
|
|
9
8
|
var props = _a.props, refs = _a.refs;
|
|
10
|
-
var _b = useContext(GaesupWorldContext), url = _b.url,
|
|
11
|
-
return (
|
|
9
|
+
var _b = useContext(GaesupWorldContext), url = _b.url, vehicleGltf = _b.vehicleGltf;
|
|
10
|
+
return (_jsx(WrapperRef, { props: props, refs: refs, gltf: vehicleGltf, outerChildren: url.wheelUrl ? _jsx(Wheels, { props: props }) : _jsx(_Fragment, {}), children: _jsx(VehicleCollider, {}) }));
|
|
12
11
|
}
|
|
@@ -7,7 +7,7 @@ import { CharacterRef } from "./active/character";
|
|
|
7
7
|
import { VehicleRef } from "./active/vehicle";
|
|
8
8
|
export function GaesupComponent(_a) {
|
|
9
9
|
var props = _a.props, refs = _a.refs;
|
|
10
|
-
var
|
|
10
|
+
var mode = useContext(GaesupWorldContext).mode;
|
|
11
11
|
calculation(props);
|
|
12
12
|
return (_jsxs(_Fragment, { children: [mode.type === "character" && _jsx(CharacterRef, { props: props, refs: refs }), mode.type === "vehicle" && _jsx(VehicleRef, { props: props, refs: refs }), mode.type === "airplane" && _jsx(AirplaneRef, { props: props, refs: refs })] }));
|
|
13
13
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useFrame } from "@react-three/fiber";
|
|
3
|
-
import { quat } from "@react-three/rapier";
|
|
3
|
+
import { CuboidCollider, quat } from "@react-three/rapier";
|
|
4
4
|
import { useMemo, useRef } from "react";
|
|
5
5
|
import { InnerGroupRef } from "../common/InnerGroupRef";
|
|
6
6
|
import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
7
7
|
import { RigidBodyRef } from "../common/RigidbodyRef";
|
|
8
|
-
import { AirplaneCollider } from "./collider";
|
|
9
8
|
export function PassiveAirplane(props) {
|
|
10
9
|
var rigidBodyRef = useRef(null);
|
|
11
10
|
var outerGroupRef = useRef(null);
|
|
@@ -23,8 +22,9 @@ export function PassiveAirplane(props) {
|
|
|
23
22
|
euler: props.euler,
|
|
24
23
|
currentAnimation: props.currentAnimation,
|
|
25
24
|
airplaneUrl: props.airplaneUrl,
|
|
25
|
+
airplaneSize: props.airplaneSize,
|
|
26
26
|
};
|
|
27
|
-
}, [props]), position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation, airplaneUrl = _a.airplaneUrl;
|
|
27
|
+
}, [props]), position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation, airplaneUrl = _a.airplaneUrl, airplaneSize = _a.airplaneSize;
|
|
28
28
|
useFrame(function () {
|
|
29
29
|
if (innerGroupRef && innerGroupRef.current) {
|
|
30
30
|
var _euler = euler.clone();
|
|
@@ -33,9 +33,9 @@ export function PassiveAirplane(props) {
|
|
|
33
33
|
.setFromEuler(innerGroupRef.current.rotation.clone())
|
|
34
34
|
.slerp(quat().setFromEuler(_euler), 0.2));
|
|
35
35
|
}
|
|
36
|
-
if (rigidBodyRef && rigidBodyRef.current) {
|
|
37
|
-
|
|
38
|
-
}
|
|
36
|
+
// if (rigidBodyRef && rigidBodyRef.current) {
|
|
37
|
+
// rigidBodyRef.current.setGravityScale(props.gravity, false);
|
|
38
|
+
// }
|
|
39
39
|
});
|
|
40
|
-
return (
|
|
40
|
+
return (_jsxs(OuterGroupRef, { ref: refs.outerGroupRef, children: [props.children, airplaneUrl && (_jsxs(RigidBodyRef, { ref: refs.rigidBodyRef, position: position, rotation: euler, onCollisionEnter: props.onCollisionEnter, children: [_jsx(InnerGroupRef, { currentAnimation: currentAnimation, ref: refs.innerGroupRef, url: airplaneUrl }), _jsx(CuboidCollider, { ref: colliderRef, args: [airplaneSize.x / 2, airplaneSize.y / 2, airplaneSize.z / 2], position: [0, airplaneSize.y / 2, 0] })] }))] }));
|
|
41
41
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { CollisionEnterPayload } from "@react-three/rapier";
|
|
2
3
|
export type passiveAirplanePropsType = {
|
|
3
4
|
position: THREE.Vector3;
|
|
4
5
|
euler: THREE.Euler;
|
|
@@ -7,4 +8,5 @@ export type passiveAirplanePropsType = {
|
|
|
7
8
|
currentAnimation: string;
|
|
8
9
|
children?: React.ReactNode;
|
|
9
10
|
gravity?: number;
|
|
11
|
+
onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
|
|
10
12
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { RapierRigidBody } from "@react-three/rapier";
|
|
1
|
+
import { CollisionEnterPayload, RapierRigidBody } from "@react-three/rapier";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
position?: THREE.Vector3;
|
|
6
6
|
rotation?: THREE.Euler;
|
|
7
|
+
onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
|
|
7
8
|
} & import("react").RefAttributes<RapierRigidBody>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { RigidBody } from "@react-three/rapier";
|
|
2
|
+
import { RigidBody, } from "@react-three/rapier";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
export var RigidBodyRef = forwardRef(function (_a, ref) {
|
|
5
|
-
var children = _a.children, position = _a.position, rotation = _a.rotation;
|
|
5
|
+
var children = _a.children, position = _a.position, rotation = _a.rotation, onCollisionEnter = _a.onCollisionEnter;
|
|
6
6
|
var _euler = rotation.clone();
|
|
7
7
|
_euler.x = 0;
|
|
8
8
|
_euler.z = 0;
|
|
9
|
-
return (_jsx(RigidBody, { colliders: false, ref: ref, position: position, rotation: _euler, userData: { intangible: true }, children: children }));
|
|
9
|
+
return (_jsx(RigidBody, { colliders: false, ref: ref, position: position, rotation: _euler, userData: { intangible: true }, onCollisionEnter: onCollisionEnter, children: children }));
|
|
10
10
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { CuboidCollider } from "@react-three/rapier";
|
|
3
|
-
import { useMemo, useRef } from "react";
|
|
3
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
4
4
|
import { InnerGroupRef } from "../common/InnerGroupRef";
|
|
5
5
|
import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
6
6
|
import { RigidBodyRef } from "../common/RigidbodyRef";
|
|
@@ -27,5 +27,10 @@ export function PassiveVehicle(props) {
|
|
|
27
27
|
vehicleUrl: props.url.vehicleUrl,
|
|
28
28
|
};
|
|
29
29
|
}, [props]), position = _a.position, euler = _a.euler, vehicleSize = _a.vehicleSize, wheelSize = _a.wheelSize, currentAnimation = _a.currentAnimation, wheelUrl = _a.wheelUrl, vehicleUrl = _a.vehicleUrl;
|
|
30
|
-
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
if (rigidBodyRef.current) {
|
|
32
|
+
rigidBodyRef.current.lockRotations(true, true);
|
|
33
|
+
}
|
|
34
|
+
}, []);
|
|
35
|
+
return (_jsxs(OuterGroupRef, { ref: refs.outerGroupRef, children: [props.children, vehicleUrl && (_jsxs(RigidBodyRef, { ref: refs.rigidBodyRef, position: position, rotation: euler, onCollisionEnter: props.onCollisionEnter, children: [_jsx(InnerGroupRef, { currentAnimation: currentAnimation, ref: refs.innerGroupRef, url: vehicleUrl }), wheelUrl ? (_jsx(CuboidCollider, { ref: colliderRef, args: [vehicleSize.x / 2, vehicleSize.y / 2, vehicleSize.z / 2], position: [0, vehicleSize.y + wheelSize.y / 2, 0] })) : (_jsx(CuboidCollider, { ref: colliderRef, args: [vehicleSize.x / 2, vehicleSize.y / 2, vehicleSize.z / 2], position: [0, vehicleSize.y, 0] }))] })), wheelUrl && (_jsx(Wheels, { vehicleSize: vehicleSize, wheelSize: wheelSize, rigidBodyRef: rigidBodyRef, url: wheelUrl }))] }));
|
|
31
36
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { CollisionEnterPayload } from "@react-three/rapier";
|
|
2
3
|
import { activeStateType, characterColliderType, modeType, urlType } from "../../../world/context/type";
|
|
3
4
|
export type gaesupPassiveCharacterPropsType = {
|
|
4
5
|
state: activeStateType;
|
|
@@ -16,4 +17,5 @@ export type passiveVehiclePropsType = {
|
|
|
16
17
|
url: urlType;
|
|
17
18
|
currentAnimation: string;
|
|
18
19
|
children?: React.ReactNode;
|
|
20
|
+
onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
|
|
19
21
|
};
|
|
@@ -10,14 +10,20 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { useMemo, useReducer, useRef } from "react";
|
|
13
|
+
import { useContext, useMemo, useReducer, useRef } from "react";
|
|
14
14
|
import Camera from "../camera";
|
|
15
|
+
import { KeyboardControls } from "@react-three/drei";
|
|
15
16
|
import { GaesupComponent } from "../component";
|
|
17
|
+
import { GaesupWorldContext } from "../world/context";
|
|
16
18
|
import { GaesupControllerContext, GaesupControllerDispatchContext, gaesupControllerDefault, } from "./context";
|
|
17
19
|
import { gaesupControllerReducer } from "./context/reducer";
|
|
18
20
|
import initDebug from "./debug";
|
|
19
21
|
import initControllerProps from "./initialize";
|
|
20
22
|
export function GaesupController(props) {
|
|
23
|
+
var keyBoardMap = useContext(GaesupWorldContext).keyBoardMap;
|
|
24
|
+
return (_jsx(KeyboardControls, { map: keyBoardMap, children: _jsx(GaesupControllerInner, __assign({}, props, { children: props.children })) }));
|
|
25
|
+
}
|
|
26
|
+
export function GaesupControllerInner(props) {
|
|
21
27
|
var capsuleColliderRef = useRef(null);
|
|
22
28
|
var rigidBodyRef = useRef(null);
|
|
23
29
|
var outerGroupRef = useRef(null);
|
|
@@ -12,18 +12,19 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { useAnimations } from "@react-three/drei";
|
|
13
13
|
import { useFrame } from "@react-three/fiber";
|
|
14
14
|
import { useContext, useEffect } from "react";
|
|
15
|
+
import { useGaesupAnimation } from "../../../hooks/useGaesupAnimation";
|
|
15
16
|
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../../world/context";
|
|
16
17
|
export default function initCallback(props) {
|
|
17
18
|
var _a = useContext(GaesupWorldContext), characterGltf = _a.characterGltf, characterAnimations = _a.animations, activeState = _a.activeState, states = _a.states, control = _a.control;
|
|
18
19
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
19
20
|
var animations = characterGltf.animations;
|
|
20
21
|
var actions = useAnimations(animations, props.outerGroupRef).actions;
|
|
22
|
+
var subscribe = useGaesupAnimation().subscribe;
|
|
21
23
|
var playAnimation = function (tag, key) {
|
|
22
24
|
if (!(key in control))
|
|
23
25
|
return;
|
|
24
26
|
if (control[key]) {
|
|
25
27
|
characterAnimations.current = tag;
|
|
26
|
-
states.isAnimationOuter = true;
|
|
27
28
|
dispatch({
|
|
28
29
|
type: "update",
|
|
29
30
|
payload: {
|
|
@@ -31,11 +32,8 @@ export default function initCallback(props) {
|
|
|
31
32
|
},
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
|
-
else {
|
|
35
|
-
states.isAnimationOuter = false;
|
|
36
|
-
}
|
|
37
35
|
};
|
|
38
|
-
var controllerProp = __assign(__assign({}, props), { activeState: activeState, control: control, states: states });
|
|
36
|
+
var controllerProp = __assign(__assign({}, props), { activeState: activeState, control: control, states: states, subscribe: subscribe });
|
|
39
37
|
useEffect(function () {
|
|
40
38
|
if (props.onReady) {
|
|
41
39
|
props.onReady(controllerProp);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RootState } from "@react-three/fiber";
|
|
2
2
|
import { cameraRayType } from "../../../camera/type";
|
|
3
|
-
import { activeStateType, animationPropType, keyControlType, statesType } from "../../../world/context/type";
|
|
3
|
+
import { activeStateType, animationAtomType, animationPropType, keyControlType, statesType } from "../../../world/context/type";
|
|
4
4
|
import { actionsType, groundRayType, slopeRayType } from "../../type";
|
|
5
5
|
export type callbackPropType = {
|
|
6
6
|
activeState: activeStateType;
|
|
@@ -9,6 +9,7 @@ export type callbackPropType = {
|
|
|
9
9
|
groundRay: groundRayType;
|
|
10
10
|
cameraRay: cameraRayType;
|
|
11
11
|
control: keyControlType;
|
|
12
|
+
subscribe: (props: animationAtomType) => void;
|
|
12
13
|
};
|
|
13
14
|
export type onFramePropType = callbackPropType & RootState;
|
|
14
15
|
export type onAnimatePropType = onFramePropType & {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare function GaeSupProps({ text, position, children, }: {
|
|
2
|
+
export declare function GaeSupProps({ type, text, position, children, }: {
|
|
3
|
+
type?: "normal" | "ground";
|
|
3
4
|
text?: string;
|
|
4
5
|
position?: [number, number, number];
|
|
5
6
|
children: React.ReactNode;
|