gaesup-world 0.0.772 → 0.0.782
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/camera/control/normal.js +4 -2
- package/dist/gaesup/camera/control/orbit.js +7 -8
- package/dist/gaesup/camera/index.js +13 -23
- package/dist/gaesup/component/active/character/collider.js +2 -2
- package/dist/gaesup/component/active/character/index.js +1 -1
- package/dist/gaesup/component/active/common/RigidbodyRef.d.ts +3 -0
- package/dist/gaesup/component/active/common/RigidbodyRef.js +4 -0
- package/dist/gaesup/component/active/common/WrapperRef.js +1 -1
- package/dist/gaesup/component/active/vehicle/wheel.js +1 -1
- package/dist/gaesup/component/active/vehicle/wheels.js +2 -4
- package/dist/gaesup/component/index.d.ts +0 -2
- package/dist/gaesup/component/index.js +0 -7
- package/dist/gaesup/component/passive/airplane/collider.d.ts +1 -2
- package/dist/gaesup/component/passive/airplane/collider.js +2 -3
- package/dist/gaesup/component/passive/airplane/index.d.ts +2 -4
- package/dist/gaesup/component/passive/airplane/index.js +30 -14
- package/dist/gaesup/component/passive/airplane/type.d.ts +10 -0
- package/dist/gaesup/component/passive/character/collider.d.ts +2 -2
- package/dist/gaesup/component/passive/character/collider.js +2 -2
- package/dist/gaesup/component/passive/character/index.d.ts +2 -4
- package/dist/gaesup/component/passive/character/index.js +28 -14
- package/dist/gaesup/component/passive/character/type.d.ts +27 -0
- package/dist/gaesup/component/passive/common/InnerGroupRef.d.ts +2 -2
- package/dist/gaesup/component/passive/common/InnerGroupRef.js +3 -3
- package/dist/gaesup/component/passive/common/RigidbodyRef.d.ts +2 -0
- package/dist/gaesup/component/passive/common/RigidbodyRef.js +5 -2
- package/dist/gaesup/component/passive/vehicle/collider.d.ts +2 -3
- package/dist/gaesup/component/passive/vehicle/collider.js +2 -3
- package/dist/gaesup/component/passive/vehicle/index.d.ts +2 -4
- package/dist/gaesup/component/passive/vehicle/index.js +21 -16
- package/dist/gaesup/component/passive/vehicle/type.d.ts +19 -0
- package/dist/gaesup/component/passive/vehicle/type.js +1 -0
- package/dist/gaesup/component/passive/vehicle/wheel.d.ts +1 -2
- package/dist/gaesup/component/passive/vehicle/wheel.js +10 -4
- package/dist/gaesup/component/passive/vehicle/wheels.d.ts +3 -3
- package/dist/gaesup/component/passive/vehicle/wheels.js +4 -6
- package/dist/gaesup/component/type.d.ts +0 -1
- package/dist/gaesup/controller/context/index.d.ts +1 -23
- package/dist/gaesup/controller/context/index.js +6 -31
- package/dist/gaesup/controller/context/reducer.d.ts +0 -4
- package/dist/gaesup/controller/context/type.d.ts +0 -33
- package/dist/gaesup/controller/debug/character.js +3 -3
- package/dist/gaesup/controller/debug/index.js +1 -54
- package/dist/gaesup/controller/index.js +2 -5
- package/dist/gaesup/controller/initialize/index.d.ts +1 -3
- package/dist/gaesup/controller/initialize/index.js +3 -3
- package/dist/gaesup/controller/type.d.ts +2 -6
- package/dist/gaesup/gaesupProps/index.d.ts +1 -2
- package/dist/gaesup/gaesupProps/index.js +2 -23
- package/dist/gaesup/hooks/useGaesupController/index.d.ts +2 -1
- package/dist/gaesup/hooks/useGaesupController/index.js +0 -3
- package/dist/gaesup/index.d.ts +4 -1
- package/dist/gaesup/index.js +4 -1
- package/dist/gaesup/physics/airplane/direction.js +14 -11
- package/dist/gaesup/physics/airplane/gravity.js +6 -4
- package/dist/gaesup/physics/airplane/index.js +2 -4
- package/dist/gaesup/physics/airplane/innerCalc.d.ts +2 -0
- package/dist/gaesup/physics/airplane/{currentSetting.js → innerCalc.js} +6 -2
- package/dist/gaesup/physics/character/direction.d.ts +0 -1
- package/dist/gaesup/physics/character/direction.js +29 -38
- package/dist/gaesup/physics/character/impulse.js +37 -6
- package/dist/gaesup/physics/character/index.js +2 -12
- package/dist/gaesup/physics/character/innerCalc.d.ts +2 -0
- package/dist/gaesup/physics/character/innerCalc.js +31 -0
- package/dist/gaesup/physics/check/ground.d.ts +1 -1
- package/dist/gaesup/physics/check/ground.js +4 -2
- package/dist/gaesup/physics/check/moving.js +1 -2
- package/dist/gaesup/physics/check/slope.js +19 -11
- package/dist/gaesup/physics/type.d.ts +5 -1
- package/dist/gaesup/physics/vehicle/direction.d.ts +2 -0
- package/dist/gaesup/physics/vehicle/direction.js +30 -26
- package/dist/gaesup/physics/vehicle/impulse.js +1 -5
- package/dist/gaesup/physics/vehicle/index.js +2 -4
- package/dist/gaesup/physics/vehicle/innerCalc.d.ts +2 -0
- package/dist/gaesup/physics/{character/currentSetting.js → vehicle/innerCalc.js} +3 -2
- package/dist/gaesup/tools/gameboy/GameBoyButton.d.ts +3 -3
- package/dist/gaesup/tools/gameboy/GameBoyButton.js +3 -7
- package/dist/gaesup/tools/gameboy/index.d.ts +1 -0
- package/dist/gaesup/tools/gameboy/index.js +2 -3
- package/dist/gaesup/tools/gameboy/type.d.ts +2 -2
- package/dist/gaesup/tools/gamepad/GamePadButton.d.ts +4 -3
- package/dist/gaesup/tools/gamepad/GamePadButton.js +4 -7
- package/dist/gaesup/tools/gamepad/index.d.ts +1 -0
- package/dist/gaesup/tools/gamepad/index.js +5 -6
- package/dist/gaesup/tools/gamepad/type.d.ts +2 -2
- package/dist/gaesup/tools/index.d.ts +1 -1
- package/dist/gaesup/tools/index.js +1 -1
- package/dist/gaesup/tools/joystick/index.d.ts +1 -0
- package/dist/gaesup/tools/joystick/index.js +17 -12
- package/dist/gaesup/tools/joystick/type.d.ts +2 -2
- package/dist/gaesup/tools/jumpPortal/index.d.ts +3 -0
- package/dist/gaesup/tools/jumpPortal/index.js +11 -0
- package/dist/gaesup/tools/keyBoardToolTip/index.d.ts +1 -0
- package/dist/gaesup/tools/keyBoardToolTip/index.js +4 -6
- package/dist/gaesup/tools/keyBoardToolTip/type.d.ts +2 -2
- package/dist/gaesup/tools/minimap/index.d.ts +1 -0
- package/dist/gaesup/tools/minimap/index.js +13 -16
- package/dist/gaesup/tools/minimap/type.d.ts +2 -2
- package/dist/gaesup/utils/vector.d.ts +1 -0
- package/dist/gaesup/utils/vector.js +8 -0
- package/dist/gaesup/world/context/index.js +16 -1
- package/dist/gaesup/world/context/reducer.d.ts +1 -1
- package/dist/gaesup/world/context/type.d.ts +23 -5
- package/dist/gaesup/{controller → world}/debug/cameraOption.d.ts +20 -0
- package/dist/gaesup/{controller → world}/debug/cameraOption.js +20 -0
- package/dist/gaesup/world/debug/index.js +28 -4
- package/dist/gaesup/world/initalize/collider/airplane.js +1 -0
- package/dist/gaesup/world/initalize/index.d.ts +1 -1
- package/dist/gaesup/world/initalize/index.js +1 -1
- package/dist/gaesup/world/type.d.ts +2 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/package.json +6 -9
- package/dist/gaesup/camera/control/map.d.ts +0 -2
- package/dist/gaesup/camera/control/map.js +0 -5
- package/dist/gaesup/component/passive/common/PassiveWrapperRef.d.ts +0 -10
- package/dist/gaesup/component/passive/common/PassiveWrapperRef.js +0 -8
- package/dist/gaesup/controller/debug/orthographicCamera.d.ts +0 -17
- package/dist/gaesup/controller/debug/orthographicCamera.js +0 -17
- package/dist/gaesup/controller/debug/perspectiveCamera.d.ts +0 -12
- package/dist/gaesup/controller/debug/perspectiveCamera.js +0 -12
- package/dist/gaesup/mutation/airplane/index.d.ts +0 -2
- package/dist/gaesup/mutation/airplane/index.js +0 -6
- package/dist/gaesup/mutation/airplane/rotation.d.ts +0 -2
- package/dist/gaesup/mutation/airplane/rotation.js +0 -9
- package/dist/gaesup/mutation/character/index.d.ts +0 -2
- package/dist/gaesup/mutation/character/index.js +0 -8
- package/dist/gaesup/mutation/character/rotation.d.ts +0 -2
- package/dist/gaesup/mutation/character/rotation.js +0 -5
- package/dist/gaesup/mutation/common/stabilizing.d.ts +0 -2
- package/dist/gaesup/mutation/common/stabilizing.js +0 -4
- package/dist/gaesup/mutation/common/transition.d.ts +0 -2
- package/dist/gaesup/mutation/common/transition.js +0 -4
- package/dist/gaesup/mutation/index.d.ts +0 -7
- package/dist/gaesup/mutation/index.js +0 -35
- package/dist/gaesup/mutation/type.d.ts +0 -21
- package/dist/gaesup/mutation/vehicle/index.d.ts +0 -2
- package/dist/gaesup/mutation/vehicle/index.js +0 -6
- package/dist/gaesup/mutation/vehicle/rotation.d.ts +0 -2
- package/dist/gaesup/mutation/vehicle/rotation.js +0 -5
- package/dist/gaesup/physics/airplane/currentSetting.d.ts +0 -2
- package/dist/gaesup/physics/airplane/turn.d.ts +0 -2
- package/dist/gaesup/physics/airplane/turn.js +0 -5
- package/dist/gaesup/physics/character/accelaration.d.ts +0 -2
- package/dist/gaesup/physics/character/accelaration.js +0 -10
- package/dist/gaesup/physics/character/currentSetting.d.ts +0 -2
- package/dist/gaesup/physics/character/damping.d.ts +0 -2
- package/dist/gaesup/physics/character/damping.js +0 -4
- package/dist/gaesup/physics/character/jump.d.ts +0 -2
- package/dist/gaesup/physics/character/jump.js +0 -10
- package/dist/gaesup/physics/character/stabilizing.d.ts +0 -2
- package/dist/gaesup/physics/character/stabilizing.js +0 -4
- package/dist/gaesup/physics/character/turn.d.ts +0 -2
- package/dist/gaesup/physics/character/turn.js +0 -9
- package/dist/gaesup/physics/vehicle/currentSetting.d.ts +0 -2
- package/dist/gaesup/physics/vehicle/currentSetting.js +0 -23
- package/dist/gaesup/physics/vehicle/turn.d.ts +0 -2
- package/dist/gaesup/physics/vehicle/turn.js +0 -5
- package/dist/gaesup/styles.css.d.ts +0 -2
- package/dist/gaesup/styles.css.js +0 -24
- package/dist/gaesup/tools/gameboy/style.css.d.ts +0 -39
- package/dist/gaesup/tools/gameboy/style.css.js +0 -76
- package/dist/gaesup/tools/gamepad/style.css.d.ts +0 -15
- package/dist/gaesup/tools/gamepad/style.css.js +0 -68
- package/dist/gaesup/tools/joystick/style.css.d.ts +0 -2
- package/dist/gaesup/tools/joystick/style.css.js +0 -33
- package/dist/gaesup/tools/jumpPoint/index.d.ts +0 -3
- package/dist/gaesup/tools/jumpPoint/index.js +0 -22
- package/dist/gaesup/tools/jumpPoint/style.css.d.ts +0 -2
- package/dist/gaesup/tools/jumpPoint/style.css.js +0 -32
- package/dist/gaesup/tools/keyBoardToolTip/style.css.d.ts +0 -2
- package/dist/gaesup/tools/keyBoardToolTip/style.css.js +0 -26
- package/dist/gaesup/tools/minimap/style.css.d.ts +0 -41
- package/dist/gaesup/tools/minimap/style.css.js +0 -215
- package/dist/styles/constants/boxshadow.css.d.ts +0 -9
- package/dist/styles/constants/boxshadow.css.js +0 -9
- package/dist/styles/constants/constant.css.d.ts +0 -77
- package/dist/styles/constants/constant.css.js +0 -79
- package/dist/styles/constants/direction.css.d.ts +0 -160
- package/dist/styles/constants/direction.css.js +0 -166
- package/dist/styles/constants/flex.css.d.ts +0 -61
- package/dist/styles/constants/flex.css.js +0 -66
- package/dist/styles/constants/gradient.css.d.ts +0 -8
- package/dist/styles/constants/gradient.css.js +0 -8
- package/dist/styles/constants/grid.css.d.ts +0 -55
- package/dist/styles/constants/grid.css.js +0 -19
- package/dist/styles/constants/palette.css.d.ts +0 -77
- package/dist/styles/constants/palette.css.js +0 -80
- package/dist/styles/constants/translate.css.d.ts +0 -563
- package/dist/styles/constants/translate.css.js +0 -131
- package/dist/styles/global.css.js +0 -68
- package/dist/styles/index.d.ts +0 -2
- package/dist/styles/index.js +0 -2
- package/dist/styles/recipe/base.css.d.ts +0 -22
- package/dist/styles/recipe/base.css.js +0 -21
- package/dist/styles/recipe/button.css.d.ts +0 -61
- package/dist/styles/recipe/button.css.js +0 -107
- package/dist/styles/recipe/index.css.d.ts +0 -4167
- package/dist/styles/recipe/index.css.js +0 -110
- package/dist/styles/recipe/input.css.d.ts +0 -21
- package/dist/styles/recipe/input.css.js +0 -32
- package/dist/styles/sprinkles/color.css.d.ts +0 -764
- package/dist/styles/sprinkles/color.css.js +0 -60
- package/dist/styles/sprinkles/direction.css.d.ts +0 -1047
- package/dist/styles/sprinkles/direction.css.js +0 -35
- package/dist/styles/sprinkles/display.css.d.ts +0 -208
- package/dist/styles/sprinkles/display.css.js +0 -24
- package/dist/styles/sprinkles/fontSize.css.d.ts +0 -529
- package/dist/styles/sprinkles/fontSize.css.js +0 -31
- package/dist/styles/sprinkles/grid.css.d.ts +0 -462
- package/dist/styles/sprinkles/grid.css.js +0 -24
- package/dist/styles/sprinkles/index.css.d.ts +0 -368
- package/dist/styles/sprinkles/index.css.js +0 -11
- package/dist/styles/sprinkles/margin.css.d.ts +0 -2212
- package/dist/styles/sprinkles/margin.css.js +0 -39
- package/dist/styles/sprinkles/padding.css.d.ts +0 -2212
- package/dist/styles/sprinkles/padding.css.js +0 -39
- package/dist/styles/sprinkles/position.css.d.ts +0 -48
- package/dist/styles/sprinkles/position.css.js +0 -13
- package/dist/styles/sprinkles/size.css.d.ts +0 -43
- package/dist/styles/sprinkles/size.css.js +0 -32
- package/dist/styles/theme.css.d.ts +0 -62
- package/dist/styles/theme.css.js +0 -75
- /package/dist/gaesup/{mutation → component/passive/airplane}/type.js +0 -0
- /package/dist/{styles/global.css.d.ts → gaesup/component/passive/character/type.js} +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { V3 } from "../../utils/vector";
|
|
2
2
|
export default function normal(prop) {
|
|
3
|
-
var state = prop.state,
|
|
3
|
+
var state = prop.state, _a = prop.worldContext, activeState = _a.activeState, cameraOption = _a.cameraOption;
|
|
4
|
+
if (!state || !state.camera)
|
|
5
|
+
return;
|
|
4
6
|
var cameraPosition = activeState.position
|
|
5
7
|
.clone()
|
|
6
|
-
.add(V3(0,
|
|
8
|
+
.add(V3(0, cameraOption.YDistance, cameraOption.XZDistance));
|
|
7
9
|
state.camera.position.lerp(cameraPosition, 0.9);
|
|
8
10
|
state.camera.lookAt(activeState.position.clone());
|
|
9
11
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { quat } from "@react-three/rapier";
|
|
2
2
|
import { V3 } from "../../utils/vector";
|
|
3
3
|
export default function orbit(prop) {
|
|
4
|
-
var state = prop.state,
|
|
4
|
+
var state = prop.state, _a = prop.worldContext, activeState = _a.activeState, cameraOption = _a.cameraOption;
|
|
5
|
+
if (!state || !state.camera)
|
|
6
|
+
return;
|
|
5
7
|
var cameraPosition = activeState.position.clone().add(V3(Math.sin(activeState.euler.y), 0, Math.cos(activeState.euler.y))
|
|
6
8
|
.normalize()
|
|
7
9
|
.clone()
|
|
8
|
-
.multiplyScalar(
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
state.camera.position.lerp(cameraPosition, 0.9);
|
|
10
|
+
.multiplyScalar(-cameraOption.XZDistance)
|
|
11
|
+
.add(V3(0, cameraOption.YDistance, 0)));
|
|
12
|
+
state.camera.position.lerp(cameraPosition, 1);
|
|
12
13
|
state.camera.quaternion.copy(activeState.quat
|
|
13
14
|
.clone()
|
|
14
|
-
.multiply(
|
|
15
|
-
? quat().setFromAxisAngle(V3(0, 1, 0), Math.PI)
|
|
16
|
-
: quat()));
|
|
15
|
+
.multiply(quat().setFromAxisAngle(V3(0, 1, 0), Math.PI)));
|
|
17
16
|
state.camera.lookAt(activeState.position.clone());
|
|
18
17
|
}
|
|
@@ -9,25 +9,24 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx, Fragment as _Fragment
|
|
13
|
-
import {
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { CameraControls } from "@react-three/drei";
|
|
14
14
|
import { useFrame, useThree } from "@react-three/fiber";
|
|
15
|
-
import { useContext, useEffect, useMemo } from "react";
|
|
15
|
+
import { useContext, useEffect, useMemo, useRef } from "react";
|
|
16
16
|
import * as THREE from "three";
|
|
17
17
|
import { GaesupControllerContext } from "../controller/context";
|
|
18
18
|
import { GaesupWorldContext } from "../world/context";
|
|
19
|
-
import mapControl from "./control/map";
|
|
20
19
|
import normal from "./control/normal";
|
|
21
20
|
import orbit from "./control/orbit";
|
|
22
21
|
export default function Camera(_a) {
|
|
23
22
|
var refs = _a.refs, prop = _a.prop, control = _a.control;
|
|
24
23
|
var worldContext = useContext(GaesupWorldContext);
|
|
25
24
|
var controllerContext = useContext(GaesupControllerContext);
|
|
26
|
-
var
|
|
25
|
+
var mode = worldContext.mode, activeState = worldContext.activeState;
|
|
27
26
|
var rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef;
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
27
|
+
var scene = useThree().scene;
|
|
28
|
+
var state = useThree();
|
|
29
|
+
var cameraRef = useRef();
|
|
31
30
|
var intersectObjectMap = useMemo(function () { return ({}); }, []);
|
|
32
31
|
var cameraProp = __assign(__assign({}, prop), { control: control, controllerContext: controllerContext, worldContext: worldContext, intersectObjectMap: intersectObjectMap });
|
|
33
32
|
var getMeshs = function (object) {
|
|
@@ -50,23 +49,14 @@ export default function Camera(_a) {
|
|
|
50
49
|
!outerGroupRef ||
|
|
51
50
|
!outerGroupRef.current)
|
|
52
51
|
return null;
|
|
53
|
-
cameraProp.state = state;
|
|
54
52
|
cameraProp.delta = delta;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
else if (cameraMode.controlType === "normal") {
|
|
60
|
-
normal(cameraProp);
|
|
61
|
-
}
|
|
53
|
+
cameraProp.state = state;
|
|
54
|
+
if (mode.control === "orbit") {
|
|
55
|
+
orbit(cameraProp);
|
|
62
56
|
}
|
|
63
|
-
else if (
|
|
64
|
-
|
|
57
|
+
else if (mode.control === "normal") {
|
|
58
|
+
normal(cameraProp);
|
|
65
59
|
}
|
|
66
|
-
// const distV3 = camera.position.clone().sub(activeState.position);
|
|
67
|
-
// cameraRay.origin.copy(camera.position);
|
|
68
|
-
// cameraRay.dir.copy(distV3.negate().normalize());
|
|
69
|
-
// detector(cameraProp);
|
|
70
60
|
});
|
|
71
|
-
return (
|
|
61
|
+
return (_jsx(_Fragment, { children: _jsx(CameraControls, { ref: cameraRef }) }));
|
|
72
62
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { CapsuleCollider, useRapier } from "@react-three/rapier";
|
|
3
3
|
import { forwardRef, useContext } from "react";
|
|
4
4
|
import { getRayHit, useForwardRef } from "../../../utils";
|
|
@@ -20,5 +20,5 @@ export var CharacterCapsuleCollider = forwardRef(function (_a, ref) {
|
|
|
20
20
|
slopeRay.rayCast = new rapier.Ray(slopeRay.origin, slopeRay.dir);
|
|
21
21
|
slopeRay.length = collider.radius + 3;
|
|
22
22
|
slopeRay.rayCast = new rapier.Ray(slopeRay.origin, slopeRay.dir);
|
|
23
|
-
return (_jsx(
|
|
23
|
+
return (_jsx(CapsuleCollider, { ref: ref, args: [collider.height, collider.radius], position: [0, collider.height + collider.radius, 0] }));
|
|
24
24
|
});
|
|
@@ -8,7 +8,7 @@ import { WrapperRef } from "../common/WrapperRef";
|
|
|
8
8
|
export function CharacterRef(_a) {
|
|
9
9
|
var props = _a.props, refs = _a.refs;
|
|
10
10
|
initCallback(props);
|
|
11
|
-
var
|
|
11
|
+
var characterGltf = useContext(GaesupWorldContext).characterGltf;
|
|
12
12
|
var ref = playCharacterActions({
|
|
13
13
|
groundRay: props.groundRay,
|
|
14
14
|
}).ref;
|
|
@@ -2,6 +2,9 @@ import { RapierRigidBody } from "@react-three/rapier";
|
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import { controllerInnerType } from "../../../controller/type";
|
|
4
4
|
export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
} & import("react").RefAttributes<RapierRigidBody>>;
|
|
7
|
+
export declare const PassiveRigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
5
8
|
props: controllerInnerType;
|
|
6
9
|
children: ReactNode;
|
|
7
10
|
} & import("react").RefAttributes<RapierRigidBody>>;
|
|
@@ -13,6 +13,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import { RigidBody } from "@react-three/rapier";
|
|
14
14
|
import { forwardRef } from "react";
|
|
15
15
|
export var RigidBodyRef = forwardRef(function (_a, ref) {
|
|
16
|
+
var children = _a.children;
|
|
17
|
+
return (_jsx(RigidBody, { colliders: false, ref: ref, children: children }));
|
|
18
|
+
});
|
|
19
|
+
export var PassiveRigidBodyRef = forwardRef(function (_a, ref) {
|
|
16
20
|
var props = _a.props, children = _a.children;
|
|
17
21
|
return (_jsx(RigidBody, __assign({ colliders: false, ref: ref }, props.rigidBodyProps, { children: children })));
|
|
18
22
|
});
|
|
@@ -5,5 +5,5 @@ import { SlopeRayRef } from "../common/slopeRayRef";
|
|
|
5
5
|
import { RigidBodyRef } from "./RigidbodyRef";
|
|
6
6
|
export function WrapperRef(_a) {
|
|
7
7
|
var children = _a.children, outerChildren = _a.outerChildren, props = _a.props, refs = _a.refs, gltf = _a.gltf, animationRef = _a.animationRef;
|
|
8
|
-
return (_jsxs(OuterGroupRef, { ref: refs.outerGroupRef, props: props, children: [_jsxs(RigidBodyRef, { ref: refs.rigidBodyRef,
|
|
8
|
+
return (_jsxs(OuterGroupRef, { ref: refs.outerGroupRef, props: props, children: [_jsxs(RigidBodyRef, { ref: refs.rigidBodyRef, children: [_jsx(SlopeRayRef, { slopeRay: props.slopeRay, groundRay: props.groundRay, ref: refs.slopeRayOriginRef }), children, props.children, _jsx(InnerGroupRef, { props: props, gltf: gltf, ref: refs.innerGroupRef, animationRef: animationRef })] }), outerChildren] }));
|
|
9
9
|
}
|
|
@@ -9,5 +9,5 @@ export var WheelRegidBodyRef = forwardRef(function (_a, ref) {
|
|
|
9
9
|
var wheelSizeX = collider.wheelSizeX, wheelSizeY = collider.wheelSizeY;
|
|
10
10
|
useRevoluteJoint(bodyRef, wheel, [bodyAnchor, wheelAnchor, rotationAxis]);
|
|
11
11
|
var colliderRef = useRef(null);
|
|
12
|
-
return (_jsxs(RigidBody, {
|
|
12
|
+
return (_jsxs(RigidBody, { colliders: false, ref: ref, userData: { intangible: true }, args: [wheelSizeX / 2, wheelSizeY / 2], rotation: [0, 0, Math.PI / 2], children: [_jsx(CylinderCollider, { args: [wheelSizeX / 2, wheelSizeY / 2], rotation: [0, 0, Math.PI / 2], ref: colliderRef }), _jsx(Gltf, { src: url.wheelUrl })] }));
|
|
13
13
|
});
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { createRef, useContext, useRef } from "react";
|
|
3
|
-
import { GaesupControllerContext } from "../../../controller/context";
|
|
4
3
|
import { GaesupWorldContext } from "../../../world/context";
|
|
5
4
|
import { WheelRegidBodyRef } from "./wheel";
|
|
6
5
|
export function Wheels(_a) {
|
|
7
6
|
var props = _a.props;
|
|
8
7
|
var rigidBodyRef = props.rigidBodyRef;
|
|
9
|
-
var wheelOffset = useContext(GaesupControllerContext).vehicle.wheelOffset;
|
|
10
8
|
var collider = useContext(GaesupWorldContext).vehicleCollider;
|
|
11
9
|
var vehicleSizeX = collider.vehicleSizeX, vehicleSizeZ = collider.vehicleSizeZ, wheelSizeX = collider.wheelSizeX, wheelSizeZ = collider.wheelSizeZ;
|
|
12
|
-
var X = (vehicleSizeX - wheelSizeX) / 2 +
|
|
13
|
-
var Z = (vehicleSizeZ - 2 * wheelSizeZ) / 2 +
|
|
10
|
+
var X = (vehicleSizeX - wheelSizeX) / 2 + 0.5;
|
|
11
|
+
var Z = (vehicleSizeZ - 2 * wheelSizeZ) / 2 + 0.5;
|
|
14
12
|
var wheelPositions = [
|
|
15
13
|
[-X, 0, Z],
|
|
16
14
|
[-X, 0, -Z],
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { controllerInnerType, refsType } from "../controller/type";
|
|
2
|
-
import { gaesupPassivePropsType } from "../hooks/useGaesupController";
|
|
3
|
-
export declare function GaesupPassiveComponent(props: gaesupPassivePropsType): import("react/jsx-runtime").JSX.Element;
|
|
4
2
|
export declare function GaesupComponent({ props, refs, }: {
|
|
5
3
|
props: controllerInnerType;
|
|
6
4
|
refs: refsType;
|
|
@@ -5,13 +5,6 @@ import { GaesupWorldContext } from "../world/context";
|
|
|
5
5
|
import { AirplaneRef } from "./active/airplane";
|
|
6
6
|
import { CharacterRef } from "./active/character";
|
|
7
7
|
import { VehicleRef } from "./active/vehicle";
|
|
8
|
-
import { PassiveAirplane } from "./passive/airplane";
|
|
9
|
-
import { PassiveCharacter } from "./passive/character";
|
|
10
|
-
import { PassiveVehicle } from "./passive/vehicle";
|
|
11
|
-
export function GaesupPassiveComponent(props) {
|
|
12
|
-
var mode = props.mode;
|
|
13
|
-
return (_jsxs(_Fragment, { children: [mode.type === "character" && _jsx(PassiveCharacter, { props: props }), mode.type === "vehicle" && _jsx(PassiveVehicle, { props: props }), mode.type === "airplane" && _jsx(PassiveAirplane, { props: props })] }));
|
|
14
|
-
}
|
|
15
8
|
export function GaesupComponent(_a) {
|
|
16
9
|
var props = _a.props, refs = _a.refs;
|
|
17
10
|
var mode = useContext(GaesupWorldContext).mode;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Collider } from "@dimforge/rapier3d-compat";
|
|
3
|
-
import { airplaneColliderType } from "../../../world/context/type";
|
|
4
3
|
export declare const AirplaneCollider: import("react").ForwardRefExoticComponent<{
|
|
5
|
-
|
|
4
|
+
airplaneSize: THREE.Vector3;
|
|
6
5
|
} & import("react").RefAttributes<Collider>>;
|
|
@@ -2,7 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { CuboidCollider } from "@react-three/rapier";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
export var AirplaneCollider = forwardRef(function (_a, ref) {
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
return (_jsx(CuboidCollider, { ref: ref, args: [airplaneSizeX / 2, airplaneSizeY / 2, airplaneSizeZ / 2], position: [0, airplaneSizeY / 2, 0] }));
|
|
5
|
+
var airplaneSize = _a.airplaneSize;
|
|
6
|
+
return (_jsx(CuboidCollider, { ref: ref, args: [airplaneSize.x / 2, airplaneSize.y / 2, airplaneSize.z / 2], position: [0, airplaneSize.y / 2, 0] }));
|
|
8
7
|
});
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function PassiveAirplane(
|
|
3
|
-
props: gaesupPassivePropsType;
|
|
4
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { passiveAirplanePropsType } from "./type";
|
|
2
|
+
export declare function PassiveAirplane(props: passiveAirplanePropsType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,25 +1,41 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFrame } from "@react-three/fiber";
|
|
3
|
+
import { quat } from "@react-three/rapier";
|
|
4
|
+
import { useMemo, useRef } from "react";
|
|
5
|
+
import { InnerGroupRef } from "../common/InnerGroupRef";
|
|
6
|
+
import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
7
|
+
import { RigidBodyRef } from "../common/RigidbodyRef";
|
|
5
8
|
import { AirplaneCollider } from "./collider";
|
|
6
|
-
export function PassiveAirplane(
|
|
7
|
-
var _b;
|
|
8
|
-
var props = _a.props;
|
|
9
|
+
export function PassiveAirplane(props) {
|
|
9
10
|
var rigidBodyRef = useRef(null);
|
|
10
11
|
var outerGroupRef = useRef(null);
|
|
11
12
|
var innerGroupRef = useRef(null);
|
|
12
|
-
var
|
|
13
|
+
var colliderRef = useRef(null);
|
|
13
14
|
var refs = {
|
|
14
15
|
rigidBodyRef: rigidBodyRef,
|
|
15
16
|
outerGroupRef: outerGroupRef,
|
|
16
17
|
innerGroupRef: innerGroupRef,
|
|
17
|
-
|
|
18
|
+
colliderRef: colliderRef,
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
var _a = useMemo(function () {
|
|
21
|
+
return {
|
|
22
|
+
position: props.position,
|
|
23
|
+
euler: props.euler,
|
|
24
|
+
currentAnimation: props.currentAnimation,
|
|
25
|
+
airplaneUrl: props.airplaneUrl,
|
|
26
|
+
};
|
|
27
|
+
}, [props]), position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation, airplaneUrl = _a.airplaneUrl;
|
|
28
|
+
useFrame(function () {
|
|
29
|
+
if (innerGroupRef && innerGroupRef.current) {
|
|
30
|
+
var _euler = euler.clone();
|
|
31
|
+
_euler.y = 0;
|
|
32
|
+
innerGroupRef.current.setRotationFromQuaternion(quat()
|
|
33
|
+
.setFromEuler(innerGroupRef.current.rotation.clone())
|
|
34
|
+
.slerp(quat().setFromEuler(_euler), 0.2));
|
|
35
|
+
}
|
|
36
|
+
if (rigidBodyRef && rigidBodyRef.current) {
|
|
37
|
+
rigidBodyRef.current.setGravityScale(props.gravity, false);
|
|
38
|
+
}
|
|
23
39
|
});
|
|
24
|
-
return (_jsx(
|
|
40
|
+
return (_jsx(OuterGroupRef, { ref: refs.outerGroupRef, children: props.airplaneUrl && (_jsxs(RigidBodyRef, { ref: refs.rigidBodyRef, position: props.position, rotation: props.euler, children: [_jsx(InnerGroupRef, { currentAnimation: props.currentAnimation, ref: refs.innerGroupRef, url: props.airplaneUrl }), _jsx(AirplaneCollider, { airplaneSize: props.airplaneSize, ref: colliderRef })] })) }));
|
|
25
41
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type passiveAirplanePropsType = {
|
|
3
|
+
position: THREE.Vector3;
|
|
4
|
+
euler: THREE.Euler;
|
|
5
|
+
airplaneSize: THREE.Vector3;
|
|
6
|
+
airplaneUrl: string;
|
|
7
|
+
currentAnimation: string;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
gravity?: number;
|
|
10
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Collider } from "@dimforge/rapier3d-compat";
|
|
3
|
-
import { characterColliderType } from "../../../world/context/type";
|
|
4
3
|
export declare const CharacterCapsuleCollider: import("react").ForwardRefExoticComponent<{
|
|
5
|
-
|
|
4
|
+
height: number;
|
|
5
|
+
diameter: number;
|
|
6
6
|
} & import("react").RefAttributes<Collider>>;
|
|
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { CapsuleCollider } from "@react-three/rapier";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
export var CharacterCapsuleCollider = forwardRef(function (_a, ref) {
|
|
5
|
-
var
|
|
6
|
-
return (_jsx(CapsuleCollider, { ref: ref, args: [
|
|
5
|
+
var height = _a.height, diameter = _a.diameter;
|
|
6
|
+
return (_jsx(CapsuleCollider, { ref: ref, args: [height, diameter / 2], position: [0, height + diameter / 2, 0] }));
|
|
7
7
|
});
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function PassiveCharacter(
|
|
3
|
-
props: gaesupPassivePropsType;
|
|
4
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { passiveCharacterPropsType } from "./type";
|
|
2
|
+
export declare function PassiveCharacter(props: passiveCharacterPropsType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,25 +1,39 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFrame } from "@react-three/fiber";
|
|
3
|
+
import { quat } from "@react-three/rapier";
|
|
4
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
5
|
+
import { InnerGroupRef } from "../common/InnerGroupRef";
|
|
6
|
+
import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
7
|
+
import { RigidBodyRef } from "../common/RigidbodyRef";
|
|
5
8
|
import { CharacterCapsuleCollider } from "./collider";
|
|
6
|
-
export function PassiveCharacter(
|
|
7
|
-
var _b;
|
|
8
|
-
var props = _a.props;
|
|
9
|
+
export function PassiveCharacter(props) {
|
|
9
10
|
var rigidBodyRef = useRef(null);
|
|
10
11
|
var outerGroupRef = useRef(null);
|
|
11
12
|
var innerGroupRef = useRef(null);
|
|
12
|
-
var
|
|
13
|
+
var colliderRef = useRef(null);
|
|
13
14
|
var refs = {
|
|
14
15
|
rigidBodyRef: rigidBodyRef,
|
|
15
16
|
outerGroupRef: outerGroupRef,
|
|
16
17
|
innerGroupRef: innerGroupRef,
|
|
17
|
-
|
|
18
|
+
capsuleColliderRef: colliderRef,
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
var _a = useMemo(function () {
|
|
21
|
+
return {
|
|
22
|
+
position: props.position,
|
|
23
|
+
euler: props.euler,
|
|
24
|
+
currentAnimation: props.currentAnimation,
|
|
25
|
+
characterUrl: props.url.characterUrl,
|
|
26
|
+
};
|
|
27
|
+
}, [props]), position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation, characterUrl = _a.characterUrl;
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
if (rigidBodyRef || rigidBodyRef.current) {
|
|
30
|
+
rigidBodyRef.current.setEnabledRotations(false, false, false, false);
|
|
31
|
+
}
|
|
32
|
+
}, []);
|
|
33
|
+
useFrame(function (_, delta) {
|
|
34
|
+
if (innerGroupRef && innerGroupRef.current) {
|
|
35
|
+
innerGroupRef.current.quaternion.rotateTowards(quat().setFromEuler(euler), 10 * delta);
|
|
36
|
+
}
|
|
23
37
|
});
|
|
24
|
-
return (
|
|
38
|
+
return (_jsxs(OuterGroupRef, { ref: refs.outerGroupRef, children: [props.children, characterUrl && (_jsxs(RigidBodyRef, { ref: refs.rigidBodyRef, position: position, children: [_jsx(CharacterCapsuleCollider, { height: props.height, diameter: props.diameter, ref: colliderRef }), _jsx(InnerGroupRef, { currentAnimation: currentAnimation, ref: refs.innerGroupRef, url: characterUrl })] }))] }));
|
|
25
39
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { refsType } from "../../../controller/type";
|
|
3
|
+
import { activeStateType, characterColliderType, modeType, urlType } from "../../../world/context/type";
|
|
4
|
+
export type gaesupPassiveCharacterPropsType = {
|
|
5
|
+
state: activeStateType;
|
|
6
|
+
characterCollider?: characterColliderType;
|
|
7
|
+
mode: modeType;
|
|
8
|
+
url: urlType;
|
|
9
|
+
currentAnimation: string;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export type passiveCharacterPropsType = {
|
|
13
|
+
position: THREE.Vector3;
|
|
14
|
+
euler: THREE.Euler;
|
|
15
|
+
height: number;
|
|
16
|
+
diameter: number;
|
|
17
|
+
url: urlType;
|
|
18
|
+
currentAnimation: string;
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
};
|
|
21
|
+
export type mutateCharacterPropsType = {
|
|
22
|
+
position: THREE.Vector3;
|
|
23
|
+
euler: THREE.Euler;
|
|
24
|
+
height: number;
|
|
25
|
+
diameter: number;
|
|
26
|
+
delta?: number;
|
|
27
|
+
} & Partial<refsType>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import * as THREE from "three";
|
|
3
|
-
import { gaesupPassivePropsType } from "../../../hooks/useGaesupController";
|
|
4
3
|
export type InnerGroupRefType = {
|
|
5
|
-
|
|
4
|
+
currentAnimation: string;
|
|
6
5
|
url: string;
|
|
6
|
+
rotation?: THREE.Euler;
|
|
7
7
|
};
|
|
8
8
|
export declare const InnerGroupRef: import("react").ForwardRefExoticComponent<InnerGroupRefType & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;
|
|
@@ -6,16 +6,16 @@ import * as THREE from "three";
|
|
|
6
6
|
import { SkeletonUtils } from "three-stdlib";
|
|
7
7
|
import playPassiveActions from "../../../animation/passiveActions";
|
|
8
8
|
export var InnerGroupRef = forwardRef(function (_a, ref) {
|
|
9
|
-
var
|
|
9
|
+
var currentAnimation = _a.currentAnimation, url = _a.url, rotation = _a.rotation;
|
|
10
10
|
var _b = useGLTF(url), scene = _b.scene, animations = _b.animations;
|
|
11
11
|
var animationRef = playPassiveActions({
|
|
12
|
-
current:
|
|
12
|
+
current: currentAnimation,
|
|
13
13
|
animations: animations,
|
|
14
14
|
}).animationRef;
|
|
15
15
|
var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
|
|
16
16
|
var nodes = useGraph(clone).nodes;
|
|
17
17
|
var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
|
|
18
|
-
return (_jsx(Suspense, { fallback: null, children: _jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, userData: { intangible: true }, children: [objectNode && animationRef && (_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: animationRef })), Object.keys(nodes).map(function (name, key) {
|
|
18
|
+
return (_jsx(Suspense, { fallback: null, children: _jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, rotation: rotation, userData: { intangible: true }, children: [objectNode && animationRef && (_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: animationRef })), Object.keys(nodes).map(function (name, key) {
|
|
19
19
|
var node = nodes[name];
|
|
20
20
|
if (node instanceof THREE.SkinnedMesh) {
|
|
21
21
|
return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry, skeleton: node.skeleton, userData: { intangible: true } }, key));
|
|
@@ -2,4 +2,6 @@ import { 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
|
+
position?: THREE.Vector3;
|
|
6
|
+
rotation?: THREE.Euler;
|
|
5
7
|
} & import("react").RefAttributes<RapierRigidBody>>;
|
|
@@ -2,6 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
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;
|
|
6
|
-
|
|
5
|
+
var children = _a.children, position = _a.position, rotation = _a.rotation;
|
|
6
|
+
var _euler = rotation.clone();
|
|
7
|
+
_euler.x = 0;
|
|
8
|
+
_euler.z = 0;
|
|
9
|
+
return (_jsx(RigidBody, { colliders: false, ref: ref, position: position, rotation: _euler, userData: { intangible: true }, children: children }));
|
|
7
10
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Collider } from "@dimforge/rapier3d-compat";
|
|
3
|
-
import { urlType, vehicleColliderType } from "../../../world/context/type";
|
|
4
3
|
export declare const VehicleCollider: import("react").ForwardRefExoticComponent<{
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
vehicleSize: THREE.Vector3;
|
|
5
|
+
wheelSize: THREE.Vector3;
|
|
7
6
|
} & import("react").RefAttributes<Collider>>;
|
|
@@ -2,7 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { CuboidCollider } from "@react-three/rapier";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
export var VehicleCollider = forwardRef(function (_a, ref) {
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
return (_jsx(CuboidCollider, { ref: ref, args: [vehicleSizeX / 2, vehicleSizeY / 2, vehicleSizeZ / 2], position: [0, vehicleSizeY + url.wheelUrl ? collider.wheelSizeY : 0, 0] }));
|
|
5
|
+
var vehicleSize = _a.vehicleSize, wheelSize = _a.wheelSize;
|
|
6
|
+
return (_jsx(CuboidCollider, { ref: ref, args: [vehicleSize.x / 2, vehicleSize.y / 2, vehicleSize.z / 2], position: [0, vehicleSize.y + wheelSize.y || 0, 0] }));
|
|
8
7
|
});
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function PassiveVehicle(
|
|
3
|
-
props: gaesupPassivePropsType;
|
|
4
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { passiveVehiclePropsType } from "./type";
|
|
2
|
+
export declare function PassiveVehicle(props: passiveVehiclePropsType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CuboidCollider } from "@react-three/rapier";
|
|
3
|
+
import { useMemo, useRef } from "react";
|
|
4
|
+
import { InnerGroupRef } from "../common/InnerGroupRef";
|
|
5
|
+
import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
6
|
+
import { RigidBodyRef } from "../common/RigidbodyRef";
|
|
6
7
|
import { Wheels } from "./wheels";
|
|
7
|
-
export function PassiveVehicle(
|
|
8
|
-
var _b, _c, _d;
|
|
9
|
-
var props = _a.props;
|
|
8
|
+
export function PassiveVehicle(props) {
|
|
10
9
|
var rigidBodyRef = useRef(null);
|
|
11
10
|
var outerGroupRef = useRef(null);
|
|
12
11
|
var innerGroupRef = useRef(null);
|
|
13
|
-
var
|
|
12
|
+
var colliderRef = useRef(null);
|
|
14
13
|
var refs = {
|
|
15
14
|
rigidBodyRef: rigidBodyRef,
|
|
16
15
|
outerGroupRef: outerGroupRef,
|
|
17
16
|
innerGroupRef: innerGroupRef,
|
|
18
|
-
|
|
17
|
+
capsuleColliderRef: colliderRef,
|
|
19
18
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
var _a = useMemo(function () {
|
|
20
|
+
return {
|
|
21
|
+
position: props.position,
|
|
22
|
+
euler: props.euler,
|
|
23
|
+
vehicleSize: props.vehicleSize,
|
|
24
|
+
wheelSize: props.wheelSize,
|
|
25
|
+
currentAnimation: props.currentAnimation,
|
|
26
|
+
wheelUrl: props.url.wheelUrl,
|
|
27
|
+
vehicleUrl: props.url.vehicleUrl,
|
|
28
|
+
};
|
|
29
|
+
}, [props]), position = _a.position, euler = _a.euler, vehicleSize = _a.vehicleSize, wheelSize = _a.wheelSize, currentAnimation = _a.currentAnimation, wheelUrl = _a.wheelUrl, vehicleUrl = _a.vehicleUrl;
|
|
30
|
+
return (_jsxs(OuterGroupRef, { ref: refs.outerGroupRef, children: [props.children, vehicleUrl && (_jsxs(RigidBodyRef, { ref: refs.rigidBodyRef, position: position, rotation: euler, children: [_jsx(InnerGroupRef, { currentAnimation: currentAnimation, ref: refs.innerGroupRef, url: vehicleUrl }), _jsx(CuboidCollider, { ref: colliderRef, args: [vehicleSize.x / 2, vehicleSize.y / 2, vehicleSize.z / 2], position: [0, vehicleSize.y + wheelSize.y || 0, 0] })] })), wheelUrl && (_jsx(Wheels, { vehicleSize: vehicleSize, wheelSize: wheelSize, rigidBodyRef: rigidBodyRef, url: wheelUrl }))] }));
|
|
26
31
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { activeStateType, characterColliderType, modeType, urlType } from "../../../world/context/type";
|
|
3
|
+
export type gaesupPassiveCharacterPropsType = {
|
|
4
|
+
state: activeStateType;
|
|
5
|
+
characterCollider?: characterColliderType;
|
|
6
|
+
mode: modeType;
|
|
7
|
+
url: urlType;
|
|
8
|
+
currentAnimation: string;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
export type passiveVehiclePropsType = {
|
|
12
|
+
position: THREE.Vector3;
|
|
13
|
+
euler: THREE.Euler;
|
|
14
|
+
vehicleSize: THREE.Vector3;
|
|
15
|
+
wheelSize: THREE.Vector3;
|
|
16
|
+
url: urlType;
|
|
17
|
+
currentAnimation: string;
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RapierRigidBody } from "@react-three/rapier";
|
|
2
2
|
import { RefObject } from "react";
|
|
3
|
-
import { vehicleColliderType } from "../../../world/context/type";
|
|
4
3
|
export type wheelRegidBodyType = {
|
|
5
4
|
wheelPosition: [number, number, number];
|
|
6
5
|
bodyRef: RefObject<RapierRigidBody>;
|
|
@@ -8,7 +7,7 @@ export type wheelRegidBodyType = {
|
|
|
8
7
|
bodyAnchor: THREE.Vector3Tuple;
|
|
9
8
|
wheelAnchor: THREE.Vector3Tuple;
|
|
10
9
|
rotationAxis: THREE.Vector3Tuple;
|
|
11
|
-
|
|
10
|
+
wheelSize: THREE.Vector3;
|
|
12
11
|
url: string;
|
|
13
12
|
};
|
|
14
13
|
export declare const WheelRegidBodyRef: import("react").ForwardRefExoticComponent<{
|