gaesup-world 0.6.58 → 0.6.61
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/dist/gaesup/animation/actions.d.ts +6 -19
- package/dist/gaesup/animation/actions.js +27 -33
- package/dist/gaesup/camera/control/orbit.js +1 -1
- package/dist/gaesup/camera/index.js +1 -33
- package/dist/gaesup/component/active/airplane/index.d.ts +2 -4
- package/dist/gaesup/component/active/airplane/index.js +2 -34
- package/dist/gaesup/component/active/character/index.js +2 -35
- package/dist/gaesup/component/active/vehicle/index.d.ts +2 -4
- package/dist/gaesup/component/active/vehicle/index.js +2 -34
- package/dist/gaesup/component/index.js +2 -4
- package/dist/gaesup/component/inner/airplane/index.d.ts +2 -2
- package/dist/gaesup/component/inner/airplane/index.js +15 -7
- package/dist/gaesup/component/inner/character/index.d.ts +2 -16
- package/dist/gaesup/component/inner/character/index.js +15 -10
- package/dist/gaesup/component/inner/character/type.d.ts +18 -0
- package/dist/gaesup/component/inner/character/type.js +1 -0
- package/dist/gaesup/component/inner/common/InnerGroupRef.d.ts +6 -5
- package/dist/gaesup/component/inner/common/InnerGroupRef.js +3 -31
- package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +10 -6
- package/dist/gaesup/component/inner/common/RigidbodyRef.js +85 -12
- package/dist/gaesup/component/inner/common/setGroundRay.d.ts +1 -8
- package/dist/gaesup/component/inner/common/setGroundRay.js +5 -0
- package/dist/gaesup/component/inner/common/type.d.ts +32 -2
- package/dist/gaesup/component/inner/rider/index.js +6 -4
- package/dist/gaesup/component/inner/vehicle/index.d.ts +2 -2
- package/dist/gaesup/component/inner/vehicle/index.js +16 -9
- package/dist/gaesup/component/inner/vehicle/type.d.ts +28 -0
- package/dist/gaesup/component/inner/vehicle/type.js +1 -0
- package/dist/gaesup/component/passive/airplane/index.d.ts +1 -14
- package/dist/gaesup/component/passive/airplane/index.js +15 -12
- package/dist/gaesup/component/passive/airplane/type.d.ts +16 -0
- package/dist/gaesup/component/passive/airplane/type.js +1 -0
- package/dist/gaesup/component/passive/character/index.js +1 -1
- package/dist/gaesup/component/passive/vehicle/index.d.ts +1 -14
- package/dist/gaesup/component/passive/vehicle/index.js +12 -2
- package/dist/gaesup/component/passive/vehicle/type.d.ts +16 -0
- package/dist/gaesup/component/passive/vehicle/type.js +1 -0
- package/dist/gaesup/controller/initialize/callback/index.d.ts +7 -4
- package/dist/gaesup/controller/initialize/callback/index.js +42 -22
- package/dist/gaesup/hooks/useGaesupAnimation/index.js +1 -1
- package/dist/gaesup/hooks/useRideable/index.d.ts +0 -8
- package/dist/gaesup/hooks/useRideable/index.js +0 -38
- package/dist/gaesup/physics/airplane/damping.d.ts +2 -2
- package/dist/gaesup/physics/airplane/direction.d.ts +2 -2
- package/dist/gaesup/physics/airplane/gravity.d.ts +2 -2
- package/dist/gaesup/physics/airplane/impulse.d.ts +2 -16
- package/dist/gaesup/physics/airplane/impulse.js +0 -14
- package/dist/gaesup/physics/airplane/index.d.ts +2 -2
- package/dist/gaesup/physics/airplane/innerCalc.d.ts +2 -2
- package/dist/gaesup/physics/airplane/landing.d.ts +2 -2
- package/dist/gaesup/physics/airplane/landing.js +0 -3
- package/dist/gaesup/physics/character/direction.d.ts +2 -2
- package/dist/gaesup/physics/character/impulse.d.ts +2 -2
- package/dist/gaesup/physics/character/index.d.ts +2 -2
- package/dist/gaesup/physics/character/innerCalc.d.ts +2 -2
- package/dist/gaesup/physics/character/innerCalc.js +8 -17
- package/dist/gaesup/physics/character/stop.d.ts +2 -2
- package/dist/gaesup/physics/check/ground.d.ts +2 -2
- package/dist/gaesup/physics/check/ground.js +13 -4
- package/dist/gaesup/physics/check/index.d.ts +2 -2
- package/dist/gaesup/physics/check/moving.d.ts +2 -2
- package/dist/gaesup/physics/check/moving.js +1 -3
- package/dist/gaesup/physics/check/push.d.ts +2 -2
- package/dist/gaesup/physics/check/riding.d.ts +2 -2
- package/dist/gaesup/physics/check/rotate.d.ts +2 -2
- package/dist/gaesup/physics/index.d.ts +7 -2
- package/dist/gaesup/physics/index.js +17 -15
- package/dist/gaesup/physics/type.d.ts +16 -4
- package/dist/gaesup/physics/type.js +1 -0
- package/dist/gaesup/physics/vehicle/damping.d.ts +2 -2
- package/dist/gaesup/physics/vehicle/direction.d.ts +4 -4
- package/dist/gaesup/physics/vehicle/impulse.d.ts +2 -2
- package/dist/gaesup/physics/vehicle/index.d.ts +2 -2
- package/dist/gaesup/physics/vehicle/innerCalc.d.ts +2 -2
- package/dist/gaesup/physics/vehicle/innerCalc.js +1 -18
- package/dist/gaesup/physics/vehicle/landing.d.ts +2 -2
- package/dist/gaesup/physics/vehicle/landing.js +0 -3
- package/dist/gaesup/tools/rideable/index.js +6 -5
- package/dist/gaesup/world/context/index.d.ts +2 -2
- package/dist/gaesup/world/context/index.js +2 -0
- package/dist/gaesup/world/context/reducer.d.ts +19 -19
- package/dist/gaesup/world/context/type.d.ts +2 -0
- package/dist/gaesup/world/debug/index.d.ts +1 -1
- package/dist/gaesup/world/initalize/index.d.ts +21 -19
- package/dist/gaesup/world/initalize/index.js +37 -5
- package/package.json +1 -1
|
@@ -13,8 +13,10 @@ export type Api<T extends AnimationClip> = {
|
|
|
13
13
|
};
|
|
14
14
|
export type playActionsType = {
|
|
15
15
|
type: "character" | "vehicle" | "airplane";
|
|
16
|
-
animationResult: Api<AnimationClip>;
|
|
17
16
|
currentAnimation?: string;
|
|
17
|
+
actions: actionsType;
|
|
18
|
+
animationRef: Ref<Object3D<Object3DEventMap>>;
|
|
19
|
+
isActive: boolean;
|
|
18
20
|
};
|
|
19
21
|
export type subscribeActionsType = {
|
|
20
22
|
type: "character" | "vehicle" | "airplane";
|
|
@@ -28,23 +30,8 @@ export type playResultType = {
|
|
|
28
30
|
actions: actionsType;
|
|
29
31
|
ref: Ref<Object3D<Object3DEventMap>>;
|
|
30
32
|
};
|
|
31
|
-
export declare function subscribeActions({ type
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
clips: THREE.AnimationClip[];
|
|
35
|
-
mixer: THREE.AnimationMixer;
|
|
36
|
-
names: string[];
|
|
37
|
-
actions: {
|
|
38
|
-
[x: string]: THREE.AnimationAction;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
export default function playActions({ type, animationResult, currentAnimation, }: playActionsType): {
|
|
43
|
-
animationRef: import("react").MutableRefObject<THREE.Object3D<THREE.Object3DEventMap>>;
|
|
33
|
+
export declare function subscribeActions({ type }: subscribeActionsType): void;
|
|
34
|
+
export default function playActions({ type, actions, animationRef, currentAnimation, isActive, }: playActionsType): {
|
|
35
|
+
animationRef: Ref<THREE.Object3D<THREE.Object3DEventMap>>;
|
|
44
36
|
currentAnimation: string;
|
|
45
37
|
};
|
|
46
|
-
export declare const setAnimation: ({ currentAnimation, actions, type, }: {
|
|
47
|
-
currentAnimation?: string;
|
|
48
|
-
actions?: actionsType;
|
|
49
|
-
type?: "character" | "vehicle" | "airplane";
|
|
50
|
-
}) => void;
|
|
@@ -9,16 +9,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { useAnimations } from "@react-three/drei";
|
|
13
12
|
import { useFrame } from "@react-three/fiber";
|
|
14
13
|
import { useContext, useEffect } from "react";
|
|
15
14
|
import { useGaesupAnimation } from "../hooks/useGaesupAnimation";
|
|
16
15
|
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context";
|
|
17
16
|
export function subscribeActions(_a) {
|
|
18
|
-
var type = _a.type
|
|
19
|
-
var
|
|
17
|
+
var type = _a.type;
|
|
18
|
+
var states = useContext(GaesupWorldContext).states;
|
|
20
19
|
var subscribeAll = useGaesupAnimation({ type: type }).subscribeAll;
|
|
21
|
-
var animationResult = useAnimations(animations);
|
|
22
20
|
// 초기 기본 애니메이션 등록
|
|
23
21
|
useEffect(function () {
|
|
24
22
|
subscribeAll([
|
|
@@ -43,13 +41,6 @@ export function subscribeActions(_a) {
|
|
|
43
41
|
animationName: "jump",
|
|
44
42
|
key: "jump",
|
|
45
43
|
},
|
|
46
|
-
{
|
|
47
|
-
tag: "fall",
|
|
48
|
-
condition: function () { return groundRay.hit === null && activeState.velocity.y < 0; },
|
|
49
|
-
action: function () { },
|
|
50
|
-
animationName: "fall",
|
|
51
|
-
key: "fall",
|
|
52
|
-
},
|
|
53
44
|
{
|
|
54
45
|
tag: "ride",
|
|
55
46
|
condition: function () { return states.isPush["keyR"]; },
|
|
@@ -57,19 +48,32 @@ export function subscribeActions(_a) {
|
|
|
57
48
|
animationName: "ride",
|
|
58
49
|
key: "ride",
|
|
59
50
|
},
|
|
51
|
+
{
|
|
52
|
+
tag: "land",
|
|
53
|
+
condition: function () { return states.isLanding; },
|
|
54
|
+
action: function () { },
|
|
55
|
+
animationName: "land",
|
|
56
|
+
key: "land",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
tag: "fall",
|
|
60
|
+
condition: function () { return states.isFalling; },
|
|
61
|
+
action: function () { },
|
|
62
|
+
animationName: "fall",
|
|
63
|
+
key: "fall",
|
|
64
|
+
},
|
|
60
65
|
]);
|
|
61
66
|
}, []);
|
|
62
|
-
return {
|
|
63
|
-
animationResult: animationResult,
|
|
64
|
-
};
|
|
65
67
|
}
|
|
66
68
|
export default function playActions(_a) {
|
|
67
|
-
var _b;
|
|
68
|
-
var type = _a.type,
|
|
69
|
-
var
|
|
69
|
+
var _b, _c;
|
|
70
|
+
var type = _a.type, actions = _a.actions, animationRef = _a.animationRef, currentAnimation = _a.currentAnimation, isActive = _a.isActive;
|
|
71
|
+
var _d = useContext(GaesupWorldContext), mode = _d.mode, animationState = _d.animationState, block = _d.block;
|
|
70
72
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
+
var _e = useGaesupAnimation({ type: type }), notify = _e.notify, store = _e.store;
|
|
74
|
+
if (isActive) {
|
|
75
|
+
currentAnimation = (_b = animationState === null || animationState === void 0 ? void 0 : animationState[type]) === null || _b === void 0 ? void 0 : _b.current;
|
|
76
|
+
}
|
|
73
77
|
var play = function (tag) {
|
|
74
78
|
animationState[type].current = tag;
|
|
75
79
|
var currentAnimation = store[tag];
|
|
@@ -99,25 +103,15 @@ export default function playActions(_a) {
|
|
|
99
103
|
return function () {
|
|
100
104
|
action === null || action === void 0 ? void 0 : action.fadeOut(0.2);
|
|
101
105
|
};
|
|
102
|
-
}, [currentAnimation, mode.type, block.animation]);
|
|
106
|
+
}, [currentAnimation, mode.type, block.animation, type]);
|
|
103
107
|
useFrame(function () {
|
|
104
|
-
if (
|
|
108
|
+
if (isActive) {
|
|
105
109
|
var tag = notify();
|
|
106
110
|
play(tag);
|
|
107
111
|
}
|
|
108
112
|
});
|
|
109
113
|
return {
|
|
110
|
-
animationRef:
|
|
111
|
-
currentAnimation: (
|
|
114
|
+
animationRef: animationRef,
|
|
115
|
+
currentAnimation: (_c = animationState === null || animationState === void 0 ? void 0 : animationState[type]) === null || _c === void 0 ? void 0 : _c.current,
|
|
112
116
|
};
|
|
113
117
|
}
|
|
114
|
-
export var setAnimation = function (_a) {
|
|
115
|
-
var currentAnimation = _a.currentAnimation, actions = _a.actions, type = _a.type;
|
|
116
|
-
useEffect(function () {
|
|
117
|
-
var _a;
|
|
118
|
-
var action = (_a = actions[currentAnimation]) === null || _a === void 0 ? void 0 : _a.reset().fadeIn(0.2).play();
|
|
119
|
-
return function () {
|
|
120
|
-
action === null || action === void 0 ? void 0 : action.fadeOut(0.2);
|
|
121
|
-
};
|
|
122
|
-
}, [currentAnimation, type]);
|
|
123
|
-
};
|
|
@@ -13,7 +13,7 @@ export default function orbit(prop) {
|
|
|
13
13
|
if (!state || !state.camera)
|
|
14
14
|
return;
|
|
15
15
|
var cameraPosition = makeOrbitCameraPosition(activeState, cameraOption);
|
|
16
|
-
state.camera.position.lerp(cameraPosition,
|
|
16
|
+
state.camera.position.lerp(cameraPosition.clone(), 0.2);
|
|
17
17
|
state.camera.quaternion.copy(activeState.quat
|
|
18
18
|
.clone()
|
|
19
19
|
.multiply(quat().setFromAxisAngle(V3(0, 1, 0), Math.PI)));
|
|
@@ -2,33 +2,7 @@ import { useFrame } from "@react-three/fiber";
|
|
|
2
2
|
import normal, { makeNormalCameraPosition } from "./control/normal";
|
|
3
3
|
import orbit from "./control/orbit";
|
|
4
4
|
export default function Camera(prop) {
|
|
5
|
-
|
|
6
|
-
// const controllerContext = useContext(GaesupControllerContext);
|
|
7
|
-
// const { mode, cameraOption, activeState } = worldContext;
|
|
8
|
-
// const cameraRef = useRef<CameraControls>();
|
|
9
|
-
// const intersectObjectMap: intersectObjectMapType = useMemo(() => ({}), []);
|
|
10
|
-
// const cameraProp: cameraPropType = {
|
|
11
|
-
// ...prop,
|
|
12
|
-
// // control,
|
|
13
|
-
// controllerContext,
|
|
14
|
-
// worldContext,
|
|
15
|
-
// // intersectObjectMap,
|
|
16
|
-
// };
|
|
17
|
-
// cameraProp.cameraRay.rayCast = new THREE.Raycaster(
|
|
18
|
-
// cameraProp.cameraRay.origin,
|
|
19
|
-
// cameraProp.cameraRay.dir,
|
|
20
|
-
// 0,
|
|
21
|
-
// -cameraOption.maxDistance
|
|
22
|
-
// );
|
|
23
|
-
useFrame(function (state, delta) {
|
|
24
|
-
// if (
|
|
25
|
-
// !rigidBodyRef ||
|
|
26
|
-
// !rigidBodyRef.current ||
|
|
27
|
-
// !outerGroupRef ||
|
|
28
|
-
// !outerGroupRef.current
|
|
29
|
-
// )
|
|
30
|
-
// return;
|
|
31
|
-
// cameraProp.delta = delta;
|
|
5
|
+
useFrame(function (state) {
|
|
32
6
|
prop.state = state;
|
|
33
7
|
if (!prop.worldContext.block.camera) {
|
|
34
8
|
if (prop.worldContext.mode.control === "orbit") {
|
|
@@ -39,12 +13,6 @@ export default function Camera(prop) {
|
|
|
39
13
|
}
|
|
40
14
|
}
|
|
41
15
|
});
|
|
42
|
-
// zoom
|
|
43
|
-
// useEffect(() => {
|
|
44
|
-
// if (cameraRef.current) {
|
|
45
|
-
// cameraRef.current.zoomTo(worldContext.cameraOption.zoom, true);
|
|
46
|
-
// }
|
|
47
|
-
// }, [worldContext.cameraOption.zoom]);
|
|
48
16
|
// 포커스가 아닐 때 카메라 activeStae 따라가기
|
|
49
17
|
useFrame(function () {
|
|
50
18
|
if (!prop.worldContext.cameraOption.focus) {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import * as THREE from "three";
|
|
3
|
-
import {
|
|
3
|
+
import { refsType } from "../../../controller/type";
|
|
4
4
|
import { urlsType } from "../../../world/context/type";
|
|
5
|
-
export declare function AirplaneRef({ children,
|
|
5
|
+
export declare function AirplaneRef({ children, enableRiding, isRiderOn, offset, refs, urls, }: {
|
|
6
6
|
children: ReactNode;
|
|
7
|
-
props: controllerInnerType;
|
|
8
|
-
groundRay: groundRayType;
|
|
9
7
|
enableRiding?: boolean;
|
|
10
8
|
isRiderOn?: boolean;
|
|
11
9
|
offset?: THREE.Vector3;
|
|
@@ -1,38 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { vec3 } from "@react-three/rapier";
|
|
3
|
-
import playActions, { subscribeActions } from "../../../animation/actions";
|
|
4
|
-
import initCallback from "../../../controller/initialize/callback";
|
|
5
|
-
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
6
2
|
import { AirplaneInnerRef } from "../../inner/airplane";
|
|
7
|
-
import { setGroundRay } from "../../inner/common/setGroundRay";
|
|
8
3
|
export function AirplaneRef(_a) {
|
|
9
|
-
var children = _a.children,
|
|
10
|
-
|
|
11
|
-
var _b = useGltfAndSize({ url: urls.vehicleUrl }), size = _b.size, gltf = _b.gltf;
|
|
12
|
-
groundRay.offset = vec3({
|
|
13
|
-
x: 0,
|
|
14
|
-
y: size.y * 5,
|
|
15
|
-
z: 0,
|
|
16
|
-
});
|
|
17
|
-
setGroundRay({
|
|
18
|
-
groundRay: groundRay,
|
|
19
|
-
length: size.y * 5,
|
|
20
|
-
colliderRef: colliderRef,
|
|
21
|
-
});
|
|
22
|
-
var animationResult = subscribeActions({
|
|
23
|
-
type: "airplane",
|
|
24
|
-
groundRay: groundRay,
|
|
25
|
-
animations: gltf.animations,
|
|
26
|
-
}).animationResult;
|
|
27
|
-
var currentAnimation = playActions({
|
|
28
|
-
type: "airplane",
|
|
29
|
-
animationResult: animationResult,
|
|
30
|
-
}).currentAnimation;
|
|
31
|
-
// callback
|
|
32
|
-
initCallback({
|
|
33
|
-
props: props,
|
|
34
|
-
animationResult: animationResult,
|
|
35
|
-
type: "airplane",
|
|
36
|
-
});
|
|
37
|
-
return (_jsx(AirplaneInnerRef, { refs: refs, urls: urls, isRiderOn: isRiderOn, enableRiding: enableRiding, offset: offset, currentAnimation: currentAnimation, children: children }));
|
|
4
|
+
var children = _a.children, enableRiding = _a.enableRiding, isRiderOn = _a.isRiderOn, offset = _a.offset, refs = _a.refs, urls = _a.urls;
|
|
5
|
+
return (_jsx(AirplaneInnerRef, { refs: refs, urls: urls, name: "airplane", isRiderOn: isRiderOn, enableRiding: enableRiding, offset: offset, outerGroupRef: refs.outerGroupRef, innerGroupRef: refs.innerGroupRef, rigidBodyRef: refs.rigidBodyRef, colliderRef: refs.colliderRef, isActive: true, currentAnimation: "idle", componentType: "airplane", children: children }));
|
|
38
6
|
}
|
|
@@ -1,39 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import playActions, { subscribeActions } from "../../../animation/actions";
|
|
4
|
-
import initCallback from "../../../controller/initialize/callback";
|
|
5
|
-
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
6
|
-
import { CharacterInnerRef, calcCharacterColliderProps, } from "../../inner/character";
|
|
7
|
-
import { setGroundRay } from "../../inner/common/setGroundRay";
|
|
2
|
+
import { CharacterInnerRef } from "../../inner/character";
|
|
8
3
|
export function CharacterRef(_a) {
|
|
9
4
|
var props = _a.props, refs = _a.refs, urls = _a.urls;
|
|
10
|
-
|
|
11
|
-
var _b = useGltfAndSize({ url: urls.characterUrl }), size = _b.size, gltf = _b.gltf;
|
|
12
|
-
var collider = calcCharacterColliderProps(size);
|
|
13
|
-
props.groundRay.offset = vec3({
|
|
14
|
-
x: 0,
|
|
15
|
-
y: (collider === null || collider === void 0 ? void 0 : collider.halfHeight) ? -(collider === null || collider === void 0 ? void 0 : collider.halfHeight) : -1,
|
|
16
|
-
z: 0,
|
|
17
|
-
});
|
|
18
|
-
setGroundRay({
|
|
19
|
-
groundRay: props.groundRay,
|
|
20
|
-
length: ((collider === null || collider === void 0 ? void 0 : collider.height) || 0) + 2,
|
|
21
|
-
colliderRef: colliderRef,
|
|
22
|
-
});
|
|
23
|
-
var animationResult = subscribeActions({
|
|
24
|
-
type: "character",
|
|
25
|
-
groundRay: props.groundRay,
|
|
26
|
-
animations: gltf.animations,
|
|
27
|
-
}).animationResult;
|
|
28
|
-
var _c = playActions({
|
|
29
|
-
type: "character",
|
|
30
|
-
animationResult: animationResult,
|
|
31
|
-
}), animationRef = _c.animationRef, currentAnimation = _c.currentAnimation;
|
|
32
|
-
// callback
|
|
33
|
-
initCallback({
|
|
34
|
-
props: props,
|
|
35
|
-
animationResult: animationResult,
|
|
36
|
-
type: "character",
|
|
37
|
-
});
|
|
38
|
-
return (_jsx(CharacterInnerRef, { animationRef: animationRef, refs: refs, urls: urls, currentAnimation: currentAnimation, children: props.children }));
|
|
5
|
+
return (_jsx(CharacterInnerRef, { refs: refs, urls: urls, outerGroupRef: refs.outerGroupRef, innerGroupRef: refs.innerGroupRef, rigidBodyRef: refs.rigidBodyRef, colliderRef: refs.colliderRef, isActive: true, componentType: "character", children: props.children }));
|
|
39
6
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import * as THREE from "three";
|
|
3
|
-
import {
|
|
3
|
+
import { refsType } from "../../../controller/type";
|
|
4
4
|
import { urlsType } from "../../../world/context/type";
|
|
5
|
-
export declare function VehicleRef({ children,
|
|
5
|
+
export declare function VehicleRef({ children, enableRiding, isRiderOn, offset, refs, urls, }: {
|
|
6
6
|
children: ReactNode;
|
|
7
|
-
props: controllerInnerType;
|
|
8
|
-
groundRay: groundRayType;
|
|
9
7
|
enableRiding?: boolean;
|
|
10
8
|
isRiderOn?: boolean;
|
|
11
9
|
offset?: THREE.Vector3;
|
|
@@ -1,38 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { vec3 } from "@react-three/rapier";
|
|
3
|
-
import playActions, { subscribeActions } from "../../../animation/actions";
|
|
4
|
-
import initCallback from "../../../controller/initialize/callback";
|
|
5
|
-
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
6
|
-
import { setGroundRay } from "../../inner/common/setGroundRay";
|
|
7
2
|
import { VehicleInnerRef } from "../../inner/vehicle";
|
|
8
3
|
export function VehicleRef(_a) {
|
|
9
|
-
var children = _a.children,
|
|
10
|
-
|
|
11
|
-
var _b = useGltfAndSize({ url: urls.vehicleUrl }), size = _b.size, gltf = _b.gltf;
|
|
12
|
-
groundRay.offset = vec3({
|
|
13
|
-
x: 0,
|
|
14
|
-
y: size.y * 3,
|
|
15
|
-
z: 0,
|
|
16
|
-
});
|
|
17
|
-
setGroundRay({
|
|
18
|
-
groundRay: groundRay,
|
|
19
|
-
length: size.y * 3,
|
|
20
|
-
colliderRef: colliderRef,
|
|
21
|
-
});
|
|
22
|
-
var animationResult = subscribeActions({
|
|
23
|
-
type: "vehicle",
|
|
24
|
-
groundRay: groundRay,
|
|
25
|
-
animations: gltf.animations,
|
|
26
|
-
}).animationResult;
|
|
27
|
-
var currentAnimation = playActions({
|
|
28
|
-
type: "vehicle",
|
|
29
|
-
animationResult: animationResult,
|
|
30
|
-
}).currentAnimation;
|
|
31
|
-
// callback
|
|
32
|
-
initCallback({
|
|
33
|
-
props: props,
|
|
34
|
-
animationResult: animationResult,
|
|
35
|
-
type: "vehicle",
|
|
36
|
-
});
|
|
37
|
-
return (_jsx(VehicleInnerRef, { refs: refs, urls: urls, isRiderOn: isRiderOn, enableRiding: enableRiding, offset: offset, currentAnimation: currentAnimation, children: children }));
|
|
4
|
+
var children = _a.children, enableRiding = _a.enableRiding, isRiderOn = _a.isRiderOn, offset = _a.offset, refs = _a.refs, urls = _a.urls;
|
|
5
|
+
return (_jsx(VehicleInnerRef, { refs: refs, urls: urls, name: "vehicle", isRiderOn: isRiderOn, enableRiding: enableRiding, offset: offset, outerGroupRef: refs.outerGroupRef, innerGroupRef: refs.innerGroupRef, rigidBodyRef: refs.rigidBodyRef, colliderRef: refs.colliderRef, isActive: true, currentAnimation: "idle", componentType: "vehicle", children: children }));
|
|
38
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { vec3 } from "@react-three/rapier";
|
|
3
3
|
import { useContext } from "react";
|
|
4
|
-
import calculation from "../physics";
|
|
5
4
|
import { GaesupWorldContext } from "../world/context";
|
|
6
5
|
import { AirplaneRef } from "./active/airplane";
|
|
7
6
|
import { CharacterRef } from "./active/character";
|
|
@@ -10,10 +9,9 @@ export function GaesupComponent(_a) {
|
|
|
10
9
|
var props = _a.props, refs = _a.refs, urls = _a.urls;
|
|
11
10
|
var _b = useContext(GaesupWorldContext), mode = _b.mode, states = _b.states, rideable = _b.rideable;
|
|
12
11
|
var enableRiding = states.enableRiding, isRiderOn = states.isRiderOn, rideableId = states.rideableId;
|
|
13
|
-
|
|
14
|
-
return (_jsxs(_Fragment, { children: [mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, { props: props, groundRay: props.groundRay, refs: refs, urls: urls, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
|
|
12
|
+
return (_jsxs(_Fragment, { children: [mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, { refs: refs, urls: urls, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
|
|
15
13
|
? rideable[rideableId].offset
|
|
16
|
-
: vec3(), children: props.children })), mode.type === "airplane" && (_jsx(AirplaneRef, {
|
|
14
|
+
: vec3(), children: props.children })), mode.type === "airplane" && (_jsx(AirplaneRef, { refs: refs, urls: urls, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
|
|
17
15
|
? rideable[rideableId].offset
|
|
18
16
|
: vec3(), children: props.children }))] }));
|
|
19
17
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function AirplaneInnerRef(
|
|
1
|
+
import { vehicleInnerType } from "../vehicle/type";
|
|
2
|
+
export declare function AirplaneInnerRef(props: vehicleInnerType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
13
|
import { CuboidCollider } from "@react-three/rapier";
|
|
3
14
|
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
4
|
-
import { InnerGroupRef } from "../common/InnerGroupRef";
|
|
5
15
|
import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
6
16
|
import { RigidBodyRef } from "../common/RigidbodyRef";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
var airplaneUrl = urls.airplaneUrl;
|
|
11
|
-
var rigidBodyRef = refs.rigidBodyRef, innerGroupRef = refs.innerGroupRef, outerGroupRef = refs.outerGroupRef;
|
|
17
|
+
export function AirplaneInnerRef(props) {
|
|
18
|
+
var airplaneUrl = props.urls.airplaneUrl;
|
|
19
|
+
var _a = props.refs, rigidBodyRef = _a.rigidBodyRef, innerGroupRef = _a.innerGroupRef, outerGroupRef = _a.outerGroupRef, colliderRef = _a.colliderRef;
|
|
12
20
|
var size = useGltfAndSize({
|
|
13
21
|
url: airplaneUrl,
|
|
14
22
|
}).size;
|
|
15
|
-
return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: airplaneUrl && (_jsxs(RigidBodyRef, { ref: rigidBodyRef, name: name,
|
|
23
|
+
return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: airplaneUrl && (_jsxs(RigidBodyRef, __assign({ ref: rigidBodyRef, name: props.name, url: props.urls.vehicleUrl, outerGroupRef: outerGroupRef, innerGroupRef: innerGroupRef, rigidBodyRef: rigidBodyRef, colliderRef: colliderRef, componentType: "vehicle" }, props, { children: [_jsx(CuboidCollider, { args: [size.x / 2, size.y / 2, size.z / 2], position: [0, size.y / 2, 0] }), props.children] }))) }));
|
|
16
24
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { refsType } from "../../../controller/type";
|
|
2
|
-
import { RigidBodyTypeString } from "@react-three/rapier";
|
|
3
|
-
import { ReactNode, Ref } from "react";
|
|
4
1
|
import * as THREE from "three";
|
|
5
|
-
import {
|
|
6
|
-
import { urlsType } from "../../../world/context/type";
|
|
2
|
+
import { characterInnerType } from "./type";
|
|
7
3
|
export declare const calcCharacterColliderProps: (characterSize: THREE.Vector3) => {
|
|
8
4
|
height: number;
|
|
9
5
|
halfHeight: number;
|
|
@@ -16,14 +12,4 @@ export type characterColliderType = {
|
|
|
16
12
|
radius: number;
|
|
17
13
|
diameter: number;
|
|
18
14
|
};
|
|
19
|
-
export declare function CharacterInnerRef(
|
|
20
|
-
children: ReactNode;
|
|
21
|
-
refs: Partial<refsType>;
|
|
22
|
-
urls: urlsType;
|
|
23
|
-
position?: THREE.Vector3;
|
|
24
|
-
euler?: THREE.Euler;
|
|
25
|
-
animationRef?: Ref<Object3D<Object3DEventMap>>;
|
|
26
|
-
currentAnimation?: string;
|
|
27
|
-
positionLerp?: number;
|
|
28
|
-
type?: RigidBodyTypeString;
|
|
29
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function CharacterInnerRef(props: characterInnerType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
13
|
import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
6
14
|
import { RigidBodyRef } from "../common/RigidbodyRef";
|
|
7
15
|
export var calcCharacterColliderProps = function (characterSize) {
|
|
@@ -19,10 +27,7 @@ export var calcCharacterColliderProps = function (characterSize) {
|
|
|
19
27
|
diameter: diameter,
|
|
20
28
|
};
|
|
21
29
|
};
|
|
22
|
-
export function CharacterInnerRef(
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
var size = useGltfAndSize({ url: urls.characterUrl }).size;
|
|
26
|
-
var collider = calcCharacterColliderProps(size);
|
|
27
|
-
return (_jsx(_Fragment, { children: collider && (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsxs(RigidBodyRef, { ref: rigidBodyRef, name: "character", position: position, positionLerp: positionLerp, rotation: euler, type: type, children: [_jsx(CapsuleCollider, { ref: colliderRef, args: [collider.height, collider.radius], position: [0, collider.height + collider.radius, 0] }), _jsx(InnerGroupRef, { type: "character", ref: innerGroupRef, url: urls.characterUrl, currentAnimation: currentAnimation, children: children })] }) })) }));
|
|
30
|
+
export function CharacterInnerRef(props) {
|
|
31
|
+
var _a = props.refs, outerGroupRef = _a.outerGroupRef, rigidBodyRef = _a.rigidBodyRef, colliderRef = _a.colliderRef, innerGroupRef = _a.innerGroupRef;
|
|
32
|
+
return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsx(RigidBodyRef, __assign({ ref: rigidBodyRef, name: "character", url: props.urls.characterUrl, outerGroupRef: outerGroupRef, innerGroupRef: innerGroupRef, rigidBodyRef: rigidBodyRef, colliderRef: colliderRef }, props, { children: props.children })) }));
|
|
28
33
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RigidBodyTypeString } from "@react-three/rapier";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import * as THREE from "three";
|
|
4
|
+
import { refsType } from "../../../controller/type";
|
|
5
|
+
import { propInnerType } from "../../../physics/type";
|
|
6
|
+
import { urlsType } from "../../../world/context/type";
|
|
7
|
+
export type characterInnerType = {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
refs: Partial<refsType>;
|
|
10
|
+
urls: urlsType;
|
|
11
|
+
position?: THREE.Vector3;
|
|
12
|
+
positionLerp?: number;
|
|
13
|
+
euler?: THREE.Euler;
|
|
14
|
+
type?: RigidBodyTypeString;
|
|
15
|
+
componentType: "character" | "vehicle" | "airplane";
|
|
16
|
+
currentAnimation?: string;
|
|
17
|
+
isActive?: boolean;
|
|
18
|
+
} & propInnerType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { MutableRefObject } from "react";
|
|
2
2
|
import * as THREE from "three";
|
|
3
3
|
export type InnerGroupRefType = {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
objectNode: THREE.Object3D;
|
|
6
|
+
animationRef: MutableRefObject<THREE.Object3D<THREE.Object3DEventMap>>;
|
|
7
|
+
nodes: {
|
|
8
|
+
[name: string]: THREE.Object3D<THREE.Object3DEventMap>;
|
|
9
|
+
};
|
|
9
10
|
};
|
|
10
11
|
export declare const InnerGroupRef: import("react").ForwardRefExoticComponent<InnerGroupRefType & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;
|
|
@@ -1,37 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { forwardRef, useContext, useMemo } from "react";
|
|
2
|
+
import { forwardRef } from "react";
|
|
4
3
|
import * as THREE from "three";
|
|
5
|
-
import { SkeletonUtils } from "three-stdlib";
|
|
6
|
-
import { useAnimations, useGLTF } from "@react-three/drei";
|
|
7
|
-
import playActions from "../../../animation/actions";
|
|
8
|
-
import Camera from "../../../camera";
|
|
9
|
-
import { GaesupControllerContext } from "../../../controller/context";
|
|
10
|
-
import { GaesupWorldContext } from "../../../world/context";
|
|
11
4
|
export var InnerGroupRef = forwardRef(function (_a, ref) {
|
|
12
|
-
var children = _a.children,
|
|
13
|
-
|
|
14
|
-
var animationResult = useAnimations(animations);
|
|
15
|
-
var animationRef = playActions({
|
|
16
|
-
type: type,
|
|
17
|
-
animationResult: animationResult,
|
|
18
|
-
currentAnimation: currentAnimation,
|
|
19
|
-
}).animationRef;
|
|
20
|
-
var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
|
|
21
|
-
var nodes = useGraph(clone).nodes;
|
|
22
|
-
var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
|
|
23
|
-
var worldContext = useContext(GaesupWorldContext);
|
|
24
|
-
var controllerContext = useContext(GaesupControllerContext);
|
|
25
|
-
var props = {
|
|
26
|
-
state: null,
|
|
27
|
-
worldContext: worldContext,
|
|
28
|
-
controllerContext: controllerContext,
|
|
29
|
-
};
|
|
30
|
-
useFrame(function (state, delta) {
|
|
31
|
-
props.state = state;
|
|
32
|
-
});
|
|
33
|
-
Camera(props);
|
|
34
|
-
return (_jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, rotation: rotation, userData: { intangible: true }, children: [children, objectNode && animationRef && (_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: animationRef })), Object.keys(nodes).map(function (name, key) {
|
|
5
|
+
var children = _a.children, objectNode = _a.objectNode, animationRef = _a.animationRef, nodes = _a.nodes;
|
|
6
|
+
return (_jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, userData: { intangible: true }, children: [children, objectNode && animationRef && (_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: animationRef })), Object.keys(nodes).map(function (name, key) {
|
|
35
7
|
var node = nodes[name];
|
|
36
8
|
if (node instanceof THREE.SkinnedMesh) {
|
|
37
9
|
return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry, skeleton: node.skeleton }, key));
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { RapierRigidBody } from "@react-three/rapier";
|
|
3
3
|
import * as THREE from "three";
|
|
4
4
|
export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
5
|
-
children: ReactNode;
|
|
5
|
+
children: import("react").ReactNode;
|
|
6
6
|
name?: string;
|
|
7
7
|
position?: THREE.Vector3;
|
|
8
8
|
rotation?: THREE.Euler;
|
|
9
9
|
userData?: {
|
|
10
10
|
intangible: boolean;
|
|
11
11
|
};
|
|
12
|
-
onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
|
|
12
|
+
onCollisionEnter?: (e: import("@react-three/rapier").CollisionEnterPayload) => Promise<void>;
|
|
13
13
|
positionLerp?: number;
|
|
14
|
-
type?: RigidBodyTypeString;
|
|
15
|
-
|
|
14
|
+
type?: import("@react-three/rapier").RigidBodyTypeString;
|
|
15
|
+
url: string;
|
|
16
|
+
isActive?: boolean;
|
|
17
|
+
currentAnimation?: string;
|
|
18
|
+
componentType: "vehicle" | "airplane" | "character";
|
|
19
|
+
} & import("../../../physics/type").propInnerType & import("react").RefAttributes<RapierRigidBody>>;
|