gaesup-world 0.0.772 → 0.0.781
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/index.js +1 -2
- 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 +28 -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/character/type.js +1 -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 +2 -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 +0 -1
- package/dist/gaesup/controller/context/index.js +2 -3
- package/dist/gaesup/controller/debug/character.js +3 -3
- package/dist/gaesup/controller/index.js +2 -0
- 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 +1 -0
- package/dist/gaesup/physics/airplane/gravity.js +6 -4
- package/dist/gaesup/physics/character/direction.d.ts +0 -1
- package/dist/gaesup/physics/character/direction.js +18 -27
- 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/{currentSetting.js → innerCalc.js} +7 -3
- package/dist/gaesup/physics/check/slope.js +19 -11
- package/dist/gaesup/physics/type.d.ts +5 -1
- package/dist/gaesup/physics/vehicle/direction.js +2 -5
- package/dist/gaesup/physics/vehicle/turn.js +3 -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 +1 -0
- package/dist/gaesup/world/context/type.d.ts +1 -0
- package/dist/gaesup/world/initalize/collider/airplane.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/gaesup/component/passive/common/PassiveWrapperRef.d.ts +0 -10
- package/dist/gaesup/component/passive/common/PassiveWrapperRef.js +0 -8
- 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/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/{mutation → component/passive/airplane}/type.js +0 -0
|
@@ -25,8 +25,7 @@ export default function Camera(_a) {
|
|
|
25
25
|
var controllerContext = useContext(GaesupControllerContext);
|
|
26
26
|
var cameraMode = controllerContext.cameraMode, perspectiveCamera = controllerContext.perspectiveCamera, orthographicCamera = controllerContext.orthographicCamera;
|
|
27
27
|
var rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef;
|
|
28
|
-
var
|
|
29
|
-
var _b = useThree(), camera = _b.camera, scene = _b.scene;
|
|
28
|
+
var scene = useThree().scene;
|
|
30
29
|
var activeState = worldContext.activeState;
|
|
31
30
|
var intersectObjectMap = useMemo(function () { return ({}); }, []);
|
|
32
31
|
var cameraProp = __assign(__assign({}, prop), { control: control, controllerContext: controllerContext, worldContext: worldContext, intersectObjectMap: intersectObjectMap });
|
|
@@ -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,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 { 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
|
+
innerGroupRef.current.setRotationFromQuaternion(quat()
|
|
31
|
+
.setFromEuler(innerGroupRef.current.rotation.clone())
|
|
32
|
+
.slerp(quat().setFromEuler(euler), 0.1));
|
|
33
|
+
}
|
|
34
|
+
if (rigidBodyRef && rigidBodyRef.current) {
|
|
35
|
+
rigidBodyRef.current.setGravityScale(props.gravity, false);
|
|
36
|
+
}
|
|
23
37
|
});
|
|
24
|
-
return (_jsx(
|
|
38
|
+
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
39
|
}
|
|
@@ -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>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,6 @@ 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
|
-
return (_jsx(RigidBody, { colliders: false, ref: ref, userData: { intangible: true }, children: children }));
|
|
5
|
+
var children = _a.children, position = _a.position, rotation = _a.rotation;
|
|
6
|
+
return (_jsx(RigidBody, { colliders: false, ref: ref, position: position, rotation: rotation, userData: { intangible: true }, children: children }));
|
|
7
7
|
});
|
|
@@ -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<{
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Gltf } from "@react-three/drei";
|
|
3
3
|
import { CylinderCollider, RigidBody, useRevoluteJoint, } from "@react-three/rapier";
|
|
4
|
-
import { forwardRef } from "react";
|
|
4
|
+
import { forwardRef, useRef } from "react";
|
|
5
5
|
export var WheelRegidBodyRef = forwardRef(function (_a, ref) {
|
|
6
6
|
var props = _a.props;
|
|
7
|
-
var
|
|
8
|
-
useRevoluteJoint(bodyRef, wheel, [
|
|
9
|
-
|
|
7
|
+
var bodyRef = props.bodyRef, wheel = props.wheel, bodyAnchor = props.bodyAnchor, wheelAnchor = props.wheelAnchor, rotationAxis = props.rotationAxis, wheelPosition = props.wheelPosition, wheelSize = props.wheelSize, url = props.url;
|
|
8
|
+
useRevoluteJoint(bodyRef, wheel, [
|
|
9
|
+
bodyAnchor,
|
|
10
|
+
wheelAnchor,
|
|
11
|
+
rotationAxis,
|
|
12
|
+
[0, 0],
|
|
13
|
+
]);
|
|
14
|
+
var refs = useRef(null);
|
|
15
|
+
return (_jsxs(RigidBody, { position: wheelPosition, colliders: false, ref: ref, children: [_jsx(CylinderCollider, { args: [wheelSize.x / 2, wheelSize.y / 2], rotation: [0, 0, Math.PI / 2], ref: refs }), _jsx(Gltf, { src: url })] }));
|
|
10
16
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { RapierRigidBody } from "@react-three/rapier";
|
|
3
|
-
import { gaesupPassivePropsType } from "../../../hooks/useGaesupController";
|
|
4
3
|
export type useSetWheelType = {
|
|
5
4
|
wheelPositions: [number, number, number][];
|
|
6
5
|
};
|
|
7
|
-
export declare function Wheels({
|
|
8
|
-
|
|
6
|
+
export declare function Wheels({ vehicleSize, wheelSize, rigidBodyRef, url, }: {
|
|
7
|
+
vehicleSize: THREE.Vector3;
|
|
8
|
+
wheelSize: THREE.Vector3;
|
|
9
9
|
rigidBodyRef: React.MutableRefObject<RapierRigidBody>;
|
|
10
10
|
url: string;
|
|
11
11
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,11 +2,9 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { createRef, useRef } from "react";
|
|
3
3
|
import { WheelRegidBodyRef } from "./wheel";
|
|
4
4
|
export function Wheels(_a) {
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var X = (vehicleSizeX - wheelSizeX) / 2 + wheelOffset;
|
|
9
|
-
var Z = (vehicleSizeZ - 2 * wheelSizeZ) / 2 + wheelOffset;
|
|
5
|
+
var vehicleSize = _a.vehicleSize, wheelSize = _a.wheelSize, rigidBodyRef = _a.rigidBodyRef, url = _a.url;
|
|
6
|
+
var X = (vehicleSize.x - wheelSize.x) / 2 + 0.5;
|
|
7
|
+
var Z = (vehicleSize.z - 2 * wheelSize.z) / 2 + 0.5;
|
|
10
8
|
var wheelPositions = [
|
|
11
9
|
[-X, 0, Z],
|
|
12
10
|
[-X, 0, -Z],
|
|
@@ -19,7 +17,7 @@ export function Wheels(_a) {
|
|
|
19
17
|
bodyRef: rigidBodyRef,
|
|
20
18
|
wheel: wheelRefs.current[index],
|
|
21
19
|
bodyAnchor: wheelPosition,
|
|
22
|
-
|
|
20
|
+
wheelSize: wheelSize,
|
|
23
21
|
wheelAnchor: [0, 0, 0],
|
|
24
22
|
rotationAxis: [1, 0, 0],
|
|
25
23
|
url: url,
|
|
@@ -42,7 +42,7 @@ export var gaesupControllerDefault = {
|
|
|
42
42
|
maxSpeed: 60,
|
|
43
43
|
accelRatio: 2,
|
|
44
44
|
brakeRatio: 5,
|
|
45
|
-
buoyancy: 0.
|
|
45
|
+
buoyancy: 0.2,
|
|
46
46
|
linearDamping: 1,
|
|
47
47
|
},
|
|
48
48
|
vehicle: {
|
|
@@ -56,7 +56,7 @@ export var gaesupControllerDefault = {
|
|
|
56
56
|
walkSpeed: 4,
|
|
57
57
|
runSpeed: 10,
|
|
58
58
|
turnSpeed: 10,
|
|
59
|
-
jumpSpeed: 5,
|
|
59
|
+
jumpSpeed: 0.5,
|
|
60
60
|
linearDamping: 1,
|
|
61
61
|
},
|
|
62
62
|
callbacks: {
|
|
@@ -72,7 +72,6 @@ export var gaesupControllerDefault = {
|
|
|
72
72
|
innerGroupRef: null,
|
|
73
73
|
slopeRayOriginRef: null,
|
|
74
74
|
characterInnerRef: null,
|
|
75
|
-
jointRefs: null,
|
|
76
75
|
},
|
|
77
76
|
isRider: false,
|
|
78
77
|
};
|