gaesup-world 0.0.663 → 0.0.691
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 +59 -2
- package/dist/gaesup/animation/actions.js +8 -8
- package/dist/gaesup/camera/cameraCollisionDetecter.d.ts +2 -2
- package/dist/gaesup/camera/index.d.ts +2 -2
- package/dist/gaesup/component/Airplane.d.ts +3 -3
- package/dist/gaesup/component/Airplane.js +3 -3
- package/dist/gaesup/component/Character.d.ts +3 -3
- package/dist/gaesup/component/Character.js +3 -3
- package/dist/gaesup/component/Vehicle.d.ts +3 -3
- package/dist/gaesup/component/Vehicle.js +3 -3
- package/dist/gaesup/component/gltf/CharacterGltf.d.ts +2 -5
- package/dist/gaesup/component/gltf/CharacterGltf.js +5 -7
- package/dist/gaesup/component/gltf/WheelJoint.d.ts +3 -3
- package/dist/gaesup/component/gltf/WheelJoint.js +4 -3
- package/dist/gaesup/component/ref/airplane.d.ts +4 -4
- package/dist/gaesup/component/ref/airplane.js +7 -7
- package/dist/gaesup/component/ref/character.d.ts +4 -4
- package/dist/gaesup/component/ref/character.js +9 -9
- package/dist/gaesup/component/ref/vehicle.d.ts +3 -3
- package/dist/gaesup/component/ref/vehicle.js +7 -7
- package/dist/gaesup/controller/context/index.d.ts +36 -9
- package/dist/gaesup/controller/context/index.js +36 -8
- package/dist/gaesup/controller/context/reducer.d.ts +10 -8
- package/dist/gaesup/controller/context/type.d.ts +51 -32
- package/dist/gaesup/controller/debug/airplane.d.ts +71 -0
- package/dist/gaesup/controller/debug/airplane.js +71 -0
- package/dist/gaesup/controller/debug/cameraOption.d.ts +27 -0
- package/dist/gaesup/controller/debug/cameraOption.js +27 -0
- package/dist/gaesup/controller/debug/character.d.ts +27 -0
- package/dist/gaesup/controller/debug/character.js +27 -0
- package/dist/gaesup/controller/debug/index.d.ts +6 -0
- package/dist/gaesup/controller/debug/index.js +100 -0
- package/dist/gaesup/controller/debug/orthographicCamera.d.ts +17 -0
- package/dist/gaesup/controller/debug/orthographicCamera.js +17 -0
- package/dist/gaesup/controller/debug/perspectiveCamera.d.ts +12 -0
- package/dist/gaesup/controller/debug/perspectiveCamera.js +12 -0
- package/dist/gaesup/controller/debug/vehicle.d.ts +27 -0
- package/dist/gaesup/controller/debug/vehicle.js +27 -0
- package/dist/gaesup/controller/index.js +34 -17
- package/dist/gaesup/controller/initialize/index.d.ts +27 -0
- package/dist/gaesup/{initial/controller → controller/initialize}/index.js +8 -42
- package/dist/gaesup/controller/type.d.ts +17 -51
- package/dist/gaesup/gaesupProps/index.js +4 -6
- package/dist/gaesup/index.d.ts +1 -1
- package/dist/gaesup/index.js +1 -1
- package/dist/gaesup/initial/callback/index.d.ts +1 -1
- package/dist/gaesup/initial/callback/index.js +28 -21
- package/dist/gaesup/initial/callback/type.d.ts +3 -7
- package/dist/gaesup/initial/index.d.ts +0 -2
- package/dist/gaesup/initial/index.js +0 -2
- package/dist/gaesup/physics/airplane/damping.js +3 -2
- package/dist/gaesup/physics/airplane/direction.js +2 -2
- package/dist/gaesup/physics/airplane/gravity.js +3 -2
- package/dist/gaesup/physics/character/accelaration.js +1 -1
- package/dist/gaesup/physics/character/damping.js +2 -2
- package/dist/gaesup/physics/character/jump.js +1 -2
- package/dist/gaesup/physics/character/turn.js +1 -2
- package/dist/gaesup/physics/index.d.ts +2 -2
- package/dist/gaesup/physics/type.d.ts +8 -7
- package/dist/gaesup/physics/vehicle/damping.js +3 -3
- package/dist/gaesup/physics/vehicle/impulse.js +4 -6
- package/dist/gaesup/tools/gameboy/GameBoyButton.d.ts +3 -1
- package/dist/gaesup/tools/gameboy/GameBoyButton.js +3 -5
- package/dist/gaesup/tools/gameboy/index.d.ts +2 -1
- package/dist/gaesup/tools/gameboy/index.js +8 -6
- package/dist/gaesup/tools/gameboy/style.css.d.ts +0 -1
- package/dist/gaesup/tools/gameboy/style.css.js +3 -15
- package/dist/gaesup/tools/gameboy/type.d.ts +2 -5
- package/dist/gaesup/tools/gamepad/GamePadButton.d.ts +3 -1
- package/dist/gaesup/tools/gamepad/GamePadButton.js +4 -5
- package/dist/gaesup/tools/gamepad/index.d.ts +2 -1
- package/dist/gaesup/tools/gamepad/index.js +9 -9
- package/dist/gaesup/tools/gamepad/style.css.js +1 -1
- package/dist/gaesup/tools/gamepad/type.d.ts +4 -6
- package/dist/gaesup/tools/index.d.ts +5 -2
- package/dist/gaesup/tools/index.js +5 -42
- package/dist/gaesup/tools/joystick/default.d.ts +0 -4
- package/dist/gaesup/tools/joystick/default.js +0 -4
- package/dist/gaesup/tools/joystick/index.d.ts +2 -2
- package/dist/gaesup/tools/joystick/index.js +48 -29
- package/dist/gaesup/tools/joystick/style.css.d.ts +0 -1
- package/dist/gaesup/tools/joystick/style.css.js +0 -15
- package/dist/gaesup/tools/joystick/type.d.ts +2 -7
- package/dist/gaesup/tools/keyBoardToolTip/default.d.ts +0 -1
- package/dist/gaesup/tools/keyBoardToolTip/default.js +0 -1
- package/dist/gaesup/tools/keyBoardToolTip/index.d.ts +2 -1
- package/dist/gaesup/tools/keyBoardToolTip/index.js +18 -14
- package/dist/gaesup/tools/keyBoardToolTip/style.css.d.ts +0 -1
- package/dist/gaesup/tools/keyBoardToolTip/style.css.js +1 -21
- package/dist/gaesup/tools/keyBoardToolTip/type.d.ts +8 -5
- package/dist/gaesup/tools/minimap/default.d.ts +4 -3
- package/dist/gaesup/tools/minimap/default.js +4 -3
- package/dist/gaesup/tools/minimap/index.d.ts +2 -1
- package/dist/gaesup/tools/minimap/index.js +49 -41
- package/dist/gaesup/tools/minimap/style.css.d.ts +32 -0
- package/dist/gaesup/tools/minimap/style.css.js +99 -19
- package/dist/gaesup/tools/minimap/type.d.ts +7 -11
- package/dist/gaesup/tools/type.d.ts +2 -26
- package/dist/gaesup/utils/context.d.ts +2 -0
- package/dist/gaesup/utils/context.js +3 -0
- package/dist/gaesup/utils/debug.d.ts +29 -0
- package/dist/gaesup/utils/debug.js +36 -0
- package/dist/gaesup/utils/type.d.ts +5 -0
- package/dist/gaesup/utils/vector.d.ts +1 -0
- package/dist/gaesup/utils/vector.js +3 -0
- package/dist/gaesup/world/context/index.d.ts +5 -4
- package/dist/gaesup/world/context/index.js +0 -2
- package/dist/gaesup/world/context/reducer.d.ts +4 -4
- package/dist/gaesup/world/context/reducer.js +0 -3
- package/dist/gaesup/world/context/type.d.ts +4 -12
- package/dist/gaesup/world/debug/index.d.ts +2 -0
- package/dist/gaesup/world/debug/index.js +27 -0
- package/dist/gaesup/world/debug/mode.d.ts +10 -0
- package/dist/gaesup/world/debug/mode.js +10 -0
- package/dist/gaesup/world/index.d.ts +2 -2
- package/dist/gaesup/world/index.js +1 -1
- package/dist/gaesup/world/initalize/collider/airplane.js +24 -0
- package/dist/gaesup/{initial/gaesupWorld → world/initalize}/collider/character.js +10 -13
- package/dist/gaesup/world/initalize/collider/index.d.ts +2 -0
- package/dist/gaesup/{initial/gaesupWorld → world/initalize}/collider/index.js +2 -1
- package/dist/gaesup/world/initalize/collider/vehicle.js +34 -0
- package/dist/gaesup/world/initalize/index.d.ts +33 -0
- package/dist/gaesup/{initial/gaesupWorld → world/initalize}/index.js +6 -4
- package/dist/gaesup/world/initalize/type.d.ts +13 -0
- package/dist/gaesup/world/initalize/type.js +1 -0
- package/dist/gaesup/world/type.d.ts +17 -7
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/styles/index.d.ts +2 -0
- package/dist/styles/index.js +2 -0
- package/dist/styles/sprinkles/color.css.d.ts +21 -21
- package/dist/styles/sprinkles/index.css.d.ts +368 -1
- package/dist/styles/sprinkles/margin.css.d.ts +30 -30
- package/dist/styles/sprinkles/padding.css.d.ts +30 -30
- package/package.json +3 -3
- package/dist/gaesup/initial/controller/index.d.ts +0 -29
- package/dist/gaesup/initial/controller/initDebug.d.ts +0 -24
- package/dist/gaesup/initial/controller/initDebug.js +0 -110
- package/dist/gaesup/initial/gaesupWorld/collider/airplane.js +0 -25
- package/dist/gaesup/initial/gaesupWorld/collider/index.d.ts +0 -6
- package/dist/gaesup/initial/gaesupWorld/collider/vehicle.js +0 -40
- package/dist/gaesup/initial/gaesupWorld/index.d.ts +0 -33
- package/dist/gaesup/initial/gaesupWorld/type.d.ts +0 -28
- package/dist/gaesup/tools/context.d.ts +0 -4
- package/dist/gaesup/tools/context.js +0 -3
- package/dist/gaesup/tools/gameboy/default.d.ts +0 -3
- package/dist/gaesup/tools/gameboy/default.js +0 -3
- package/dist/gaesup/tools/reducer.d.ts +0 -11
- package/dist/gaesup/tools/reducer.js +0 -24
- package/dist/gaesup/tools/style.css.d.ts +0 -3
- package/dist/gaesup/tools/style.css.js +0 -31
- /package/dist/gaesup/{initial/gaesupWorld → utils}/type.js +0 -0
- /package/dist/gaesup/{initial/gaesupWorld → world/initalize}/collider/airplane.d.ts +0 -0
- /package/dist/gaesup/{initial/gaesupWorld → world/initalize}/collider/character.d.ts +0 -0
- /package/dist/gaesup/{initial/gaesupWorld → world/initalize}/collider/gltf.d.ts +0 -0
- /package/dist/gaesup/{initial/gaesupWorld → world/initalize}/collider/gltf.js +0 -0
- /package/dist/gaesup/{initial/gaesupWorld → world/initalize}/collider/vehicle.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
# Gaesup World
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/gaesup-world)
|
|
4
|
+
[](https://www.npmjs.com/package/gaesup-world)
|
|
5
|
+
|
|
3
6
|
Web 3D Character Controller and World Platform Library
|
|
4
7
|
|
|
5
|
-
[](https://codesandbox.io/p/github/jigglypop/gaesup-world-examples/master?workspaceId=e8ae627a-af61-415e-aa21-1fe5af422c86)
|
|
9
|
+
|
|
10
|
+
> click and watch code sandbox example!
|
|
7
11
|
|
|
8
12
|
---
|
|
9
13
|
|
|
@@ -11,6 +15,59 @@ Web 3D Character Controller and World Platform Library
|
|
|
11
15
|
|
|
12
16
|
Gaesup World is a library that uses @react/three-fiber, @react/three-drei, and rapier to provide control tools for characters, airplanes, cars, and more in a web 3D environment. This controller is designed to easily manage character movement, animation, and interaction. It allows for easy manipulation of characters or vehicles in a virtual world, and is also equipped with utilities like minimaps and joysticks.
|
|
13
17
|
|
|
18
|
+
## How to start
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
"use client";
|
|
22
|
+
|
|
23
|
+
import { Environment, KeyboardControls } from "@react-three/drei";
|
|
24
|
+
import { Canvas } from "@react-three/fiber";
|
|
25
|
+
import { Physics, RigidBody } from "@react-three/rapier";
|
|
26
|
+
|
|
27
|
+
import { GaesupController, GaesupWorld } from "gaesup-world";
|
|
28
|
+
|
|
29
|
+
export const keyboardMap = [
|
|
30
|
+
{ name: "forward", keys: ["ArrowUp", "KeyW"] },
|
|
31
|
+
{ name: "backward", keys: ["ArrowDown", "KeyS"] },
|
|
32
|
+
{ name: "leftward", keys: ["ArrowLeft", "KeyA"] },
|
|
33
|
+
{ name: "rightward", keys: ["ArrowRight", "KeyD"] },
|
|
34
|
+
{ name: "space", keys: ["Space"] },
|
|
35
|
+
{ name: "shift", keys: ["Shift"] },
|
|
36
|
+
{ name: "keyZ", keys: ["KeyZ"] },
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
export default function App() {
|
|
40
|
+
const CHARACTER_URL = "./gaesupyee.glb";
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<GaesupWorld
|
|
44
|
+
url={{
|
|
45
|
+
characterUrl: CHARACTER_URL,
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<Canvas shadows style={{ width: "100dvw", height: "100dvh" }}>
|
|
49
|
+
<Environment background preset="sunset" blur={0.8} />
|
|
50
|
+
<Physics>
|
|
51
|
+
<KeyboardControls map={keyboardMap}>
|
|
52
|
+
<GaesupController
|
|
53
|
+
groupProps={{
|
|
54
|
+
rotation: [0, Math.PI, 0],
|
|
55
|
+
}}
|
|
56
|
+
/>
|
|
57
|
+
</KeyboardControls>
|
|
58
|
+
<RigidBody type="fixed">
|
|
59
|
+
<mesh receiveShadow position={[0, 0, 0]}>
|
|
60
|
+
<boxGeometry args={[300, 5, 300]} />
|
|
61
|
+
<meshStandardMaterial />
|
|
62
|
+
</mesh>
|
|
63
|
+
</RigidBody>
|
|
64
|
+
</Physics>
|
|
65
|
+
</Canvas>
|
|
66
|
+
</GaesupWorld>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
14
71
|
### Features
|
|
15
72
|
|
|
16
73
|
- 3D character control based on React Three Fiber.
|
|
@@ -29,7 +29,7 @@ export default function playActions(_a) {
|
|
|
29
29
|
},
|
|
30
30
|
});
|
|
31
31
|
}, [control]);
|
|
32
|
-
var
|
|
32
|
+
var play = function (tag) {
|
|
33
33
|
characterAnimations.current = tag;
|
|
34
34
|
dispatch({
|
|
35
35
|
type: "update",
|
|
@@ -50,13 +50,13 @@ export default function playActions(_a) {
|
|
|
50
50
|
},
|
|
51
51
|
});
|
|
52
52
|
};
|
|
53
|
-
var resetAni = function () { return
|
|
54
|
-
var playIdle = function () { return
|
|
55
|
-
var playWalk = function () { return
|
|
56
|
-
var playRun = function () { return
|
|
57
|
-
var playJump = function () { return
|
|
58
|
-
var playFall = function () { return
|
|
59
|
-
var playRide = function () { return
|
|
53
|
+
var resetAni = function () { return play("idle"); };
|
|
54
|
+
var playIdle = function () { return play("idle"); };
|
|
55
|
+
var playWalk = function () { return play("walk"); };
|
|
56
|
+
var playRun = function () { return play("run"); };
|
|
57
|
+
var playJump = function () { return play("jump"); };
|
|
58
|
+
var playFall = function () { return play("fall"); };
|
|
59
|
+
var playRide = function () { return play("ride"); };
|
|
60
60
|
useEffect(function () {
|
|
61
61
|
return function () {
|
|
62
62
|
resetAni();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function cameraCollisionDetector(prop:
|
|
1
|
+
import { controllerInnerType } from "../controller/type";
|
|
2
|
+
export default function cameraCollisionDetector(prop: controllerInnerType): {
|
|
3
3
|
checkCollision: (delta: number) => void;
|
|
4
4
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { controllerInnerType, refsType } from "../controller/type";
|
|
2
2
|
export default function Camera({ refs, prop, control, }: {
|
|
3
3
|
refs: refsType;
|
|
4
|
-
prop:
|
|
4
|
+
prop: controllerInnerType;
|
|
5
5
|
control: {
|
|
6
6
|
[key: string]: boolean;
|
|
7
7
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function Airplane({
|
|
3
|
-
|
|
1
|
+
import { controllerInnerType, refsType } from "../controller/type";
|
|
2
|
+
export declare function Airplane({ props, refs, }: {
|
|
3
|
+
props: controllerInnerType;
|
|
4
4
|
refs: refsType;
|
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,9 +6,9 @@ import { CharacterInnerGroupRef } from "./gltf/CharacterGltf";
|
|
|
6
6
|
import { AirplaneCollider, AirplaneGroup, AirplaneRigidBody, } from "./ref/airplane";
|
|
7
7
|
import setInit from "./setInit";
|
|
8
8
|
export function Airplane(_a) {
|
|
9
|
-
var
|
|
9
|
+
var props = _a.props, refs = _a.refs;
|
|
10
10
|
var rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef, capsuleColliderRef = refs.capsuleColliderRef, innerGroupRef = refs.innerGroupRef, characterInnerRef = refs.characterInnerRef;
|
|
11
|
-
calculation(
|
|
11
|
+
calculation(props);
|
|
12
12
|
setInit(rigidBodyRef);
|
|
13
|
-
return (_jsx(_Fragment, { children: _jsx(AirplaneGroup, { ref: outerGroupRef,
|
|
13
|
+
return (_jsx(_Fragment, { children: _jsx(AirplaneGroup, { ref: outerGroupRef, props: props, children: _jsxs(AirplaneRigidBody, { ref: rigidBodyRef, props: props, children: [_jsx(AirplaneCollider, { prop: props, ref: capsuleColliderRef }), props.isRider && (_jsx(CharacterInnerGroupRef, { props: props, groundRay: props.groundRay, refs: refs, ref: characterInnerRef })), _jsx(AirplaneInnerGroupRef, { ref: innerGroupRef })] }) }) }));
|
|
14
14
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function Character({
|
|
3
|
-
|
|
1
|
+
import { controllerInnerType, refsType } from "../controller/type";
|
|
2
|
+
export declare function Character({ props, refs, }: {
|
|
3
|
+
props: controllerInnerType;
|
|
4
4
|
refs: refsType;
|
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,9 +5,9 @@ import { CharacterInnerGroupRef, InnerGroupRef } from "./gltf/CharacterGltf";
|
|
|
5
5
|
import { CharacterCapsuleCollider, CharacterGroup, CharacterRigidBody, CharacterSlopeRay, } from "./ref/character";
|
|
6
6
|
import setInit from "./setInit";
|
|
7
7
|
export function Character(_a) {
|
|
8
|
-
var
|
|
8
|
+
var props = _a.props, refs = _a.refs;
|
|
9
9
|
var capsuleColliderRef = refs.capsuleColliderRef, rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef, slopeRayOriginRef = refs.slopeRayOriginRef, characterInnerRef = refs.characterInnerRef, innerGroupRef = refs.innerGroupRef;
|
|
10
|
-
calculation(
|
|
10
|
+
calculation(props);
|
|
11
11
|
setInit(rigidBodyRef);
|
|
12
|
-
return (_jsxs(CharacterRigidBody, { ref: rigidBodyRef,
|
|
12
|
+
return (_jsxs(CharacterRigidBody, { ref: rigidBodyRef, props: props, children: [_jsx(CharacterCapsuleCollider, { props: props, ref: capsuleColliderRef }), _jsxs(CharacterGroup, { ref: outerGroupRef, props: props, children: [_jsx(CharacterSlopeRay, { slopeRay: props.slopeRay, groundRay: props.groundRay, ref: slopeRayOriginRef }), props.children, _jsx(InnerGroupRef, { ref: innerGroupRef }), _jsx(CharacterInnerGroupRef, { props: props, groundRay: props.groundRay, refs: refs, ref: characterInnerRef })] })] }));
|
|
13
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function Vehicle({
|
|
3
|
-
|
|
1
|
+
import { controllerInnerType, refsType } from "../controller/type";
|
|
2
|
+
export declare function Vehicle({ props, refs, }: {
|
|
3
|
+
props: controllerInnerType;
|
|
4
4
|
refs: refsType;
|
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,9 +7,9 @@ import { Wheels } from "./gltf/WheelJoint";
|
|
|
7
7
|
import { VehicleCollider, VehicleGroup, VehicleRigidBody } from "./ref/vehicle";
|
|
8
8
|
import setInit from "./setInit";
|
|
9
9
|
export function Vehicle(_a) {
|
|
10
|
-
var
|
|
10
|
+
var props = _a.props, refs = _a.refs;
|
|
11
11
|
var rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef, characterInnerRef = refs.characterInnerRef, innerGroupRef = refs.innerGroupRef;
|
|
12
|
-
calculation(
|
|
12
|
+
calculation(props);
|
|
13
13
|
setInit(rigidBodyRef);
|
|
14
|
-
return (_jsxs(VehicleGroup, { ref: outerGroupRef,
|
|
14
|
+
return (_jsxs(VehicleGroup, { ref: outerGroupRef, props: props, children: [_jsxs(VehicleRigidBody, { ref: rigidBodyRef, props: props, children: [_jsx(VehicleCollider, {}), props.isRider && (_jsx(CharacterInnerGroupRef, { props: props, groundRay: props.groundRay, refs: refs, ref: characterInnerRef })), _jsx(VehicleInnerGroupRef, { ref: innerGroupRef })] }), _jsx(Wheels, { props: props })] }));
|
|
15
15
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
import { groundRayType, propType, refsType } from "../../controller/type";
|
|
2
|
+
import { controllerInnerType, groundRayType, refsType } from "../../controller/type";
|
|
4
3
|
import { callbackType } from "../../initial/callback/type";
|
|
5
4
|
export type characterGltfType = {
|
|
6
|
-
|
|
7
|
-
groupProps?: GroupProps;
|
|
5
|
+
props: controllerInnerType;
|
|
8
6
|
groundRay: groundRayType;
|
|
9
7
|
refs: refsType;
|
|
10
8
|
callbacks?: callbackType;
|
|
11
|
-
isRider?: boolean;
|
|
12
9
|
};
|
|
13
10
|
export declare const InnerGroupRef: import("react").ForwardRefExoticComponent<import("react").RefAttributes<import("three").Group<import("three").Object3DEventMap>>>;
|
|
14
11
|
export declare const CharacterInnerGroupRef: import("react").ForwardRefExoticComponent<characterGltfType & import("react").RefAttributes<import("three").Group<import("three").Object3DEventMap>>>;
|
|
@@ -18,23 +18,21 @@ export var InnerGroupRef = forwardRef(function (_, ref) {
|
|
|
18
18
|
return _jsx("group", { ref: ref, visible: false });
|
|
19
19
|
});
|
|
20
20
|
export var CharacterInnerGroupRef = forwardRef(function (_a, ref) {
|
|
21
|
-
var
|
|
21
|
+
var props = _a.props, groundRay = _a.groundRay, refs = _a.refs;
|
|
22
22
|
var gltf = useContext(GaesupWorldContext).characterGltf;
|
|
23
23
|
var materials = gltf.materials, nodes = gltf.nodes;
|
|
24
24
|
var _b = useContext(GaesupWorldContext), characterCollider = _b.characterCollider, vehicleCollider = _b.vehicleCollider;
|
|
25
25
|
initCallback({
|
|
26
|
-
|
|
27
|
-
callbacks: callbacks,
|
|
28
|
-
outerGroupRef: refs.outerGroupRef,
|
|
26
|
+
props: props,
|
|
29
27
|
});
|
|
30
28
|
playActions({
|
|
31
29
|
outerGroupRef: refs.outerGroupRef,
|
|
32
30
|
groundRay: groundRay,
|
|
33
|
-
isRider: isRider,
|
|
31
|
+
isRider: props.isRider,
|
|
34
32
|
});
|
|
35
|
-
return (_jsx(_Fragment, { children: nodes && materials && (_jsxs("group", __assign({ receiveShadow: true, castShadow: true }, groupProps, { position: [
|
|
33
|
+
return (_jsx(_Fragment, { children: nodes && materials && (_jsxs("group", __assign({ receiveShadow: true, castShadow: true }, props.groupProps, { position: [
|
|
36
34
|
0,
|
|
37
|
-
isRider
|
|
35
|
+
props.isRider
|
|
38
36
|
? vehicleCollider.vehicleSizeY / 2
|
|
39
37
|
: -characterCollider.height,
|
|
40
38
|
0,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function Wheels({
|
|
3
|
-
|
|
1
|
+
import { controllerInnerType } from "../../controller/type";
|
|
2
|
+
export declare function Wheels({ props }: {
|
|
3
|
+
props: controllerInnerType;
|
|
4
4
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,12 @@
|
|
|
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";
|
|
3
4
|
import { GaesupWorldContext } from "../../world/context";
|
|
4
5
|
import { WheelRegidBodyRef } from "../ref/vehicle";
|
|
5
6
|
export function Wheels(_a) {
|
|
6
|
-
var
|
|
7
|
-
var rigidBodyRef =
|
|
8
|
-
var wheelOffset =
|
|
7
|
+
var props = _a.props;
|
|
8
|
+
var rigidBodyRef = props.rigidBodyRef;
|
|
9
|
+
var wheelOffset = useContext(GaesupControllerContext).vehicle.wheelOffset;
|
|
9
10
|
var collider = useContext(GaesupWorldContext).vehicleCollider;
|
|
10
11
|
var vehicleSizeX = collider.vehicleSizeX, vehicleSizeZ = collider.vehicleSizeZ, wheelSizeX = collider.wheelSizeX, wheelSizeZ = collider.wheelSizeZ;
|
|
11
12
|
var X = (vehicleSizeX + wheelSizeX) / 2 + wheelOffset;
|
|
@@ -2,15 +2,15 @@ import { Collider } from "@dimforge/rapier3d-compat";
|
|
|
2
2
|
import { RapierRigidBody } from "@react-three/rapier";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import * as THREE from "three";
|
|
5
|
-
import {
|
|
5
|
+
import { controllerInnerType, controllerType } from "../../controller/type";
|
|
6
6
|
export declare const AirplaneRigidBody: import("react").ForwardRefExoticComponent<{
|
|
7
|
-
|
|
7
|
+
props: controllerInnerType;
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
} & import("react").RefAttributes<RapierRigidBody>>;
|
|
10
10
|
export declare const AirplaneCollider: import("react").ForwardRefExoticComponent<{
|
|
11
|
-
prop:
|
|
11
|
+
prop: controllerInnerType;
|
|
12
12
|
} & import("react").RefAttributes<Collider>>;
|
|
13
13
|
export declare const AirplaneGroup: import("react").ForwardRefExoticComponent<{
|
|
14
|
-
|
|
14
|
+
props: controllerType;
|
|
15
15
|
children: ReactNode;
|
|
16
16
|
} & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;
|
|
@@ -16,11 +16,11 @@ import { getRayHit } from "../../utils/ray";
|
|
|
16
16
|
import { useForwardRef } from "../../utils/ref";
|
|
17
17
|
import { GaesupWorldContext } from "../../world/context";
|
|
18
18
|
export var AirplaneRigidBody = forwardRef(function (_a, ref) {
|
|
19
|
-
var
|
|
20
|
-
return (_jsxs(RigidBody, __assign({ colliders: false, ref: ref },
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
var props = _a.props, children = _a.children;
|
|
20
|
+
return (_jsxs(RigidBody, __assign({ colliders: false, ref: ref }, props.rigidBodyProps, { children: [props.debug && (_jsx("mesh", { visible: props.debug, children: _jsx("arrowHelper", { args: [
|
|
21
|
+
props.groundRay.dir,
|
|
22
|
+
props.groundRay.origin,
|
|
23
|
+
props.groundRay.length,
|
|
24
24
|
] }) })), children] })));
|
|
25
25
|
});
|
|
26
26
|
export var AirplaneCollider = forwardRef(function (_a, ref) {
|
|
@@ -41,6 +41,6 @@ export var AirplaneCollider = forwardRef(function (_a, ref) {
|
|
|
41
41
|
return (_jsx(CuboidCollider, { ref: ref, args: [airplaneSizeX / 2, airplaneSizeY / 2, airplaneSizeZ / 2], position: [0, airplaneSizeY / 2, 0] }));
|
|
42
42
|
});
|
|
43
43
|
export var AirplaneGroup = forwardRef(function (_a, ref) {
|
|
44
|
-
var
|
|
45
|
-
return (_jsx("group", __assign({ ref: ref, userData: { intangible: true } },
|
|
44
|
+
var props = _a.props, children = _a.children;
|
|
45
|
+
return (_jsx("group", __assign({ ref: ref, userData: { intangible: true } }, props.airplane, { children: children })));
|
|
46
46
|
});
|
|
@@ -2,16 +2,16 @@ import { Collider } from "@dimforge/rapier3d-compat";
|
|
|
2
2
|
import { RapierRigidBody } from "@react-three/rapier";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import * as THREE from "three";
|
|
5
|
-
import { controllerType, groundRayType,
|
|
5
|
+
import { controllerInnerType, controllerType, groundRayType, slopeRayType } from "../../controller/type";
|
|
6
6
|
export declare const CharacterRigidBody: import("react").ForwardRefExoticComponent<{
|
|
7
|
-
|
|
7
|
+
props: controllerInnerType;
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
} & import("react").RefAttributes<RapierRigidBody>>;
|
|
10
10
|
export declare const CharacterCapsuleCollider: import("react").ForwardRefExoticComponent<{
|
|
11
|
-
|
|
11
|
+
props: controllerInnerType;
|
|
12
12
|
} & import("react").RefAttributes<Collider>>;
|
|
13
13
|
export declare const CharacterGroup: import("react").ForwardRefExoticComponent<{
|
|
14
|
-
|
|
14
|
+
props: controllerType;
|
|
15
15
|
children: ReactNode;
|
|
16
16
|
} & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;
|
|
17
17
|
export declare const CharacterSlopeRay: import("react").ForwardRefExoticComponent<{
|
|
@@ -16,20 +16,20 @@ import { getRayHit } from "../../utils/ray";
|
|
|
16
16
|
import { useForwardRef } from "../../utils/ref";
|
|
17
17
|
import { GaesupWorldContext } from "../../world/context";
|
|
18
18
|
export var CharacterRigidBody = forwardRef(function (_a, ref) {
|
|
19
|
-
var
|
|
20
|
-
return (_jsxs(RigidBody, __assign({ colliders: false, canSleep: false, ref: ref },
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
var props = _a.props, children = _a.children;
|
|
20
|
+
return (_jsxs(RigidBody, __assign({ colliders: false, canSleep: false, ref: ref }, props.rigidBodyProps, { children: [props.debug && (_jsx("mesh", { visible: props.debug, children: _jsx("arrowHelper", { args: [
|
|
21
|
+
props.groundRay.dir,
|
|
22
|
+
props.groundRay.origin,
|
|
23
|
+
props.groundRay.length,
|
|
24
24
|
] }) })), children] })));
|
|
25
25
|
});
|
|
26
26
|
export var CharacterCapsuleCollider = forwardRef(function (_a, ref) {
|
|
27
27
|
var _b;
|
|
28
|
-
var
|
|
28
|
+
var props = _a.props;
|
|
29
29
|
var collider = useContext(GaesupWorldContext).characterCollider;
|
|
30
30
|
var colliderRef = useForwardRef(ref);
|
|
31
31
|
var rapier = useRapier().rapier;
|
|
32
|
-
var groundRay =
|
|
32
|
+
var groundRay = props.groundRay, slopeRay = props.slopeRay;
|
|
33
33
|
groundRay.length = collider.radius + 2;
|
|
34
34
|
groundRay.rayCast = new rapier.Ray(groundRay.origin, groundRay.dir);
|
|
35
35
|
groundRay.hit = getRayHit({
|
|
@@ -43,8 +43,8 @@ export var CharacterCapsuleCollider = forwardRef(function (_a, ref) {
|
|
|
43
43
|
return (_jsx(CapsuleCollider, { ref: ref, args: [collider.height, collider.radius] }));
|
|
44
44
|
});
|
|
45
45
|
export var CharacterGroup = forwardRef(function (_a, ref) {
|
|
46
|
-
var
|
|
47
|
-
return (_jsx("group", __assign({ ref: ref, userData: { intangible: true } },
|
|
46
|
+
var props = _a.props, children = _a.children;
|
|
47
|
+
return (_jsx("group", __assign({ ref: ref, userData: { intangible: true } }, props.character, { children: children })));
|
|
48
48
|
});
|
|
49
49
|
export var CharacterSlopeRay = forwardRef(function (_a, ref) {
|
|
50
50
|
var groundRay = _a.groundRay, slopeRay = _a.slopeRay;
|
|
@@ -2,14 +2,14 @@ import { Collider } from "@dimforge/rapier3d-compat";
|
|
|
2
2
|
import { RapierRigidBody } from "@react-three/rapier";
|
|
3
3
|
import { ReactNode, RefObject } from "react";
|
|
4
4
|
import * as THREE from "three";
|
|
5
|
-
import {
|
|
5
|
+
import { controllerInnerType, controllerType } from "../../controller/type";
|
|
6
6
|
export declare const VehicleRigidBody: import("react").ForwardRefExoticComponent<{
|
|
7
|
-
|
|
7
|
+
props: controllerInnerType;
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
} & import("react").RefAttributes<RapierRigidBody>>;
|
|
10
10
|
export declare const VehicleCollider: import("react").ForwardRefExoticComponent<import("react").RefAttributes<Collider>>;
|
|
11
11
|
export declare const VehicleGroup: import("react").ForwardRefExoticComponent<{
|
|
12
|
-
|
|
12
|
+
props: controllerType;
|
|
13
13
|
children: ReactNode;
|
|
14
14
|
} & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;
|
|
15
15
|
export type wheelRegidBodyType = {
|
|
@@ -16,11 +16,11 @@ import { forwardRef, useContext } from "react";
|
|
|
16
16
|
import { S3 } from "../../utils/constant";
|
|
17
17
|
import { GaesupWorldContext } from "../../world/context";
|
|
18
18
|
export var VehicleRigidBody = forwardRef(function (_a, ref) {
|
|
19
|
-
var
|
|
20
|
-
return (_jsxs(RigidBody, __assign({ colliders: false, ref: ref },
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
var props = _a.props, children = _a.children;
|
|
20
|
+
return (_jsxs(RigidBody, __assign({ colliders: false, ref: ref }, props.rigidBodyProps, { children: [props.debug && (_jsx("mesh", { visible: props.debug, children: _jsx("arrowHelper", { args: [
|
|
21
|
+
props.groundRay.dir,
|
|
22
|
+
props.groundRay.origin,
|
|
23
|
+
props.groundRay.length,
|
|
24
24
|
] }) })), children] })));
|
|
25
25
|
});
|
|
26
26
|
export var VehicleCollider = forwardRef(function (_, ref) {
|
|
@@ -29,8 +29,8 @@ export var VehicleCollider = forwardRef(function (_, ref) {
|
|
|
29
29
|
return (_jsx(CuboidCollider, { ref: ref, args: [vehicleSizeX / 2, vehicleSizeY / 2, vehicleSizeZ / 2], position: [0, vehicleSizeY / 2, 0] }));
|
|
30
30
|
});
|
|
31
31
|
export var VehicleGroup = forwardRef(function (_a, ref) {
|
|
32
|
-
var
|
|
33
|
-
return (_jsx("group", __assign({ ref: ref, userData: { intangible: true } },
|
|
32
|
+
var props = _a.props, children = _a.children;
|
|
33
|
+
return (_jsx("group", __assign({ ref: ref, userData: { intangible: true } }, props.vehicle, { children: children })));
|
|
34
34
|
});
|
|
35
35
|
export var WheelRegidBodyRef = forwardRef(function (_a, ref) {
|
|
36
36
|
var wheelPosition = _a.wheelPosition, wheelsUrl = _a.wheelsUrl, bodyRef = _a.bodyRef, wheel = _a.wheel, bodyAnchor = _a.bodyAnchor, wheelAnchor = _a.wheelAnchor, rotationAxis = _a.rotationAxis;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { dispatchType } from "../../
|
|
3
|
-
import { gaesupControllerType, orthographicCameraType, perspectiveCameraType } from "./type
|
|
2
|
+
import { dispatchType } from "../../utils/type";
|
|
3
|
+
import { gaesupControllerType, orthographicCameraType, perspectiveCameraType } from "./type";
|
|
4
4
|
export declare const gaesupControllerDefault: {
|
|
5
5
|
cameraMode: perspectiveCameraType | orthographicCameraType;
|
|
6
6
|
cameraOption: {
|
|
7
7
|
offset: import("three").Vector3;
|
|
8
|
+
initDistance: number;
|
|
9
|
+
maxDistance: number;
|
|
10
|
+
minDistance: number;
|
|
11
|
+
initDir: number;
|
|
12
|
+
collisionOff: number;
|
|
13
|
+
distance: number;
|
|
14
|
+
camFollow: number;
|
|
8
15
|
};
|
|
9
16
|
perspectiveCamera: {
|
|
10
17
|
isFront: boolean;
|
|
@@ -17,22 +24,42 @@ export declare const gaesupControllerDefault: {
|
|
|
17
24
|
far: number;
|
|
18
25
|
};
|
|
19
26
|
airplane: {
|
|
20
|
-
|
|
27
|
+
angleDelta: import("three").Vector3;
|
|
21
28
|
maxAngle: import("three").Vector3;
|
|
22
29
|
maxSpeed: number;
|
|
23
30
|
accelRatio: number;
|
|
31
|
+
brakeRatio: number;
|
|
32
|
+
buoyancy: number;
|
|
33
|
+
linearDamping: number;
|
|
24
34
|
};
|
|
25
35
|
vehicle: {
|
|
26
|
-
angleChange: import("three").Vector3;
|
|
27
|
-
maxAngle: import("three").Vector3;
|
|
28
36
|
maxSpeed: number;
|
|
29
37
|
accelRatio: number;
|
|
38
|
+
brakeRatio: number;
|
|
39
|
+
wheelOffset: number;
|
|
40
|
+
linearDamping: number;
|
|
30
41
|
};
|
|
31
42
|
character: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
walkSpeed: number;
|
|
44
|
+
runSpeed: number;
|
|
45
|
+
turnSpeed: number;
|
|
46
|
+
jumpSpeed: number;
|
|
47
|
+
linearDamping: number;
|
|
48
|
+
};
|
|
49
|
+
callbacks: {
|
|
50
|
+
onReady: () => void;
|
|
51
|
+
onFrame: () => void;
|
|
52
|
+
onDestory: () => void;
|
|
53
|
+
onAnimate: () => void;
|
|
54
|
+
};
|
|
55
|
+
refs: {
|
|
56
|
+
capsuleColliderRef: any;
|
|
57
|
+
rigidBodyRef: any;
|
|
58
|
+
outerGroupRef: any;
|
|
59
|
+
innerGroupRef: any;
|
|
60
|
+
slopeRayOriginRef: any;
|
|
61
|
+
characterInnerRef: any;
|
|
62
|
+
jointRefs: any;
|
|
36
63
|
};
|
|
37
64
|
isRider: boolean;
|
|
38
65
|
};
|
|
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { createContext } from "react";
|
|
13
|
-
import { V3 } from "../../utils/vector
|
|
13
|
+
import { V3 } from "../../utils/vector";
|
|
14
14
|
export var gaesupControllerDefault = {
|
|
15
15
|
cameraMode: {
|
|
16
16
|
cameraType: "perspective",
|
|
@@ -18,6 +18,13 @@ export var gaesupControllerDefault = {
|
|
|
18
18
|
},
|
|
19
19
|
cameraOption: {
|
|
20
20
|
offset: V3(-10, -10, -10),
|
|
21
|
+
initDistance: -5,
|
|
22
|
+
maxDistance: -7,
|
|
23
|
+
minDistance: -0.7,
|
|
24
|
+
initDir: 0,
|
|
25
|
+
collisionOff: 0.7,
|
|
26
|
+
distance: -1,
|
|
27
|
+
camFollow: 11,
|
|
21
28
|
},
|
|
22
29
|
perspectiveCamera: {
|
|
23
30
|
isFront: true,
|
|
@@ -30,22 +37,43 @@ export var gaesupControllerDefault = {
|
|
|
30
37
|
far: 1000,
|
|
31
38
|
},
|
|
32
39
|
airplane: {
|
|
33
|
-
|
|
40
|
+
angleDelta: V3(0.01, 0.005, 0.005),
|
|
34
41
|
maxAngle: V3(0.1, 0.1, 0.1),
|
|
35
42
|
maxSpeed: 60,
|
|
36
43
|
accelRatio: 2,
|
|
44
|
+
brakeRatio: 5,
|
|
45
|
+
buoyancy: 0.5,
|
|
46
|
+
linearDamping: 1,
|
|
37
47
|
},
|
|
38
48
|
vehicle: {
|
|
39
|
-
angleChange: V3(0.01, 0.005, 0.005),
|
|
40
|
-
maxAngle: V3(0.1, 0.1, 0.1),
|
|
41
49
|
maxSpeed: 60,
|
|
42
50
|
accelRatio: 2,
|
|
51
|
+
brakeRatio: 5,
|
|
52
|
+
wheelOffset: 0.1,
|
|
53
|
+
linearDamping: 0.5,
|
|
43
54
|
},
|
|
44
55
|
character: {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
// constant
|
|
57
|
+
walkSpeed: 4,
|
|
58
|
+
runSpeed: 10,
|
|
59
|
+
turnSpeed: 10,
|
|
60
|
+
jumpSpeed: 5,
|
|
61
|
+
linearDamping: 1,
|
|
62
|
+
},
|
|
63
|
+
callbacks: {
|
|
64
|
+
onReady: function () { },
|
|
65
|
+
onFrame: function () { },
|
|
66
|
+
onDestory: function () { },
|
|
67
|
+
onAnimate: function () { },
|
|
68
|
+
},
|
|
69
|
+
refs: {
|
|
70
|
+
capsuleColliderRef: null,
|
|
71
|
+
rigidBodyRef: null,
|
|
72
|
+
outerGroupRef: null,
|
|
73
|
+
innerGroupRef: null,
|
|
74
|
+
slopeRayOriginRef: null,
|
|
75
|
+
characterInnerRef: null,
|
|
76
|
+
jointRefs: null,
|
|
49
77
|
},
|
|
50
78
|
isRider: false,
|
|
51
79
|
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { gaesupControllerType } from "./type
|
|
1
|
+
import { gaesupControllerType } from "./type";
|
|
2
2
|
export declare function gaesupControllerReducer(props: gaesupControllerType, action: {
|
|
3
3
|
type: string;
|
|
4
|
-
payload?: gaesupControllerType
|
|
4
|
+
payload?: Partial<gaesupControllerType>;
|
|
5
5
|
}): {
|
|
6
|
-
cameraMode: import("./type
|
|
7
|
-
cameraOption: import("./type
|
|
8
|
-
perspectiveCamera: import("./type
|
|
6
|
+
cameraMode: import("./type").gaesupCameraPropType;
|
|
7
|
+
cameraOption: import("./type").cameraOptionType;
|
|
8
|
+
perspectiveCamera: import("./type").perspectiveCameraPropType;
|
|
9
9
|
orthographicCamera: import("@react-three/fiber").OrthographicCameraProps;
|
|
10
|
-
airplane: import("./type
|
|
11
|
-
vehicle: import("./type
|
|
12
|
-
character: import("./type
|
|
10
|
+
airplane: import("./type").airplaneType;
|
|
11
|
+
vehicle: import("./type").vehicleType;
|
|
12
|
+
character: import("./type").characterType;
|
|
13
13
|
isRider: boolean;
|
|
14
|
+
callbacks: import("../../initial/callback/type").callbackType;
|
|
15
|
+
refs: import("../type").refsType;
|
|
14
16
|
};
|