gaesup-world 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gaesup/animation/actions.d.ts +29 -13
- package/dist/gaesup/animation/actions.js +33 -60
- package/dist/gaesup/camera/index.js +1 -1
- package/dist/gaesup/component/active/airplane/index.d.ts +9 -3
- package/dist/gaesup/component/active/airplane/index.js +3 -7
- package/dist/gaesup/component/active/character/index.d.ts +3 -1
- package/dist/gaesup/component/active/character/index.js +29 -11
- package/dist/gaesup/component/active/vehicle/index.d.ts +10 -3
- package/dist/gaesup/component/active/vehicle/index.js +29 -9
- package/dist/gaesup/component/index.d.ts +3 -1
- package/dist/gaesup/component/index.js +9 -3
- package/dist/gaesup/component/inner/airplane/index.d.ts +2 -0
- package/dist/gaesup/component/inner/airplane/index.js +16 -0
- package/dist/gaesup/component/inner/character/index.d.ts +25 -0
- package/dist/gaesup/component/inner/character/index.js +28 -0
- package/dist/gaesup/component/{passive → inner}/common/InnerGroupRef.d.ts +2 -0
- package/dist/gaesup/component/{passive → inner}/common/InnerGroupRef.js +12 -10
- package/dist/gaesup/component/{passive → inner}/common/RigidbodyRef.d.ts +4 -0
- package/dist/gaesup/component/inner/common/RigidbodyRef.js +7 -0
- package/dist/gaesup/component/inner/common/setGroundRay.d.ts +9 -0
- package/dist/gaesup/component/inner/common/setGroundRay.js +14 -0
- package/dist/gaesup/component/inner/common/type.d.ts +20 -0
- package/dist/gaesup/component/inner/rider/index.d.ts +11 -0
- package/dist/gaesup/component/inner/rider/index.js +31 -0
- package/dist/gaesup/component/inner/vehicle/collider.d.ts +10 -0
- package/dist/gaesup/component/inner/vehicle/collider.js +19 -0
- package/dist/gaesup/component/inner/vehicle/index.d.ts +2 -0
- package/dist/gaesup/component/inner/vehicle/index.js +17 -0
- package/dist/gaesup/component/inner/vehicle/wheels.d.ts +7 -0
- package/dist/gaesup/component/inner/vehicle/wheels.js +64 -0
- package/dist/gaesup/component/passive/airplane/index.d.ts +12 -1
- package/dist/gaesup/component/passive/airplane/index.js +6 -9
- package/dist/gaesup/component/passive/character/index.d.ts +9 -1
- package/dist/gaesup/component/passive/character/index.js +16 -9
- package/dist/gaesup/component/passive/type.d.ts +1 -11
- package/dist/gaesup/component/passive/vehicle/index.d.ts +12 -1
- package/dist/gaesup/component/passive/vehicle/index.js +6 -25
- package/dist/gaesup/controller/context/index.d.ts +7 -3
- package/dist/gaesup/controller/context/index.js +7 -3
- package/dist/gaesup/controller/context/reducer.d.ts +1 -1
- package/dist/gaesup/controller/index.js +5 -8
- package/dist/gaesup/controller/initialize/callback/index.d.ts +1 -1
- package/dist/gaesup/controller/initialize/callback/index.js +61 -54
- package/dist/gaesup/controller/initialize/index.d.ts +1 -2
- package/dist/gaesup/controller/initialize/index.js +1 -14
- package/dist/gaesup/controller/type.d.ts +3 -6
- package/dist/gaesup/gaesupProps/index.js +1 -1
- package/dist/gaesup/hooks/useGaesupAnimation/index.d.ts +3 -1
- package/dist/gaesup/hooks/useGaesupAnimation/index.js +17 -16
- package/dist/gaesup/hooks/useGaesupController/index.d.ts +2 -5
- package/dist/gaesup/hooks/useGaesupController/index.js +4 -5
- package/dist/gaesup/hooks/useGaesupGltf/index.d.ts +25 -0
- package/dist/gaesup/hooks/useGaesupGltf/index.js +73 -0
- package/dist/gaesup/hooks/useRideable/index.js +36 -35
- package/dist/gaesup/physics/airplane/direction.d.ts +1 -1
- package/dist/gaesup/physics/airplane/direction.js +3 -1
- package/dist/gaesup/physics/airplane/gravity.js +1 -1
- package/dist/gaesup/physics/airplane/landing.js +1 -1
- package/dist/gaesup/physics/check/ground.js +3 -3
- package/dist/gaesup/physics/check/index.js +0 -2
- package/dist/gaesup/physics/check/riding.js +3 -3
- package/dist/gaesup/physics/index.js +8 -6
- package/dist/gaesup/physics/type.d.ts +4 -1
- package/dist/gaesup/physics/vehicle/impulse.js +0 -3
- package/dist/gaesup/physics/vehicle/innerCalc.js +1 -1
- package/dist/gaesup/physics/vehicle/landing.js +1 -1
- package/dist/gaesup/tools/keyBoardToolTip/index.js +3 -3
- package/dist/gaesup/tools/rideable/index.js +5 -6
- package/dist/gaesup/tools/zoomButton/index.js +5 -3
- package/dist/gaesup/world/context/index.js +27 -62
- package/dist/gaesup/world/context/reducer.d.ts +7 -12
- package/dist/gaesup/world/context/type.d.ts +36 -49
- package/dist/gaesup/world/debug/index.d.ts +6 -2
- package/dist/gaesup/world/initalize/index.d.ts +7 -12
- package/dist/gaesup/world/initalize/index.js +8 -15
- package/dist/gaesup/world/type.d.ts +3 -8
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +1 -1
- package/dist/gaesup/animation/index.d.ts +0 -1
- package/dist/gaesup/animation/index.js +0 -1
- package/dist/gaesup/animation/passiveActions.d.ts +0 -9
- package/dist/gaesup/animation/passiveActions.js +0 -16
- package/dist/gaesup/component/active/airplane/collider.d.ts +0 -6
- package/dist/gaesup/component/active/airplane/collider.js +0 -22
- package/dist/gaesup/component/active/character/collider.d.ts +0 -6
- package/dist/gaesup/component/active/character/collider.js +0 -24
- package/dist/gaesup/component/active/common/InnerGroupRef.d.ts +0 -10
- package/dist/gaesup/component/active/common/InnerGroupRef.js +0 -35
- package/dist/gaesup/component/active/common/OuterGroupRef.d.ts +0 -6
- package/dist/gaesup/component/active/common/OuterGroupRef.js +0 -17
- package/dist/gaesup/component/active/common/RiderGroupRef.d.ts +0 -7
- package/dist/gaesup/component/active/common/RiderGroupRef.js +0 -32
- package/dist/gaesup/component/active/common/RigidbodyRef.d.ts +0 -11
- package/dist/gaesup/component/active/common/RigidbodyRef.js +0 -22
- package/dist/gaesup/component/active/common/WrapperRef.d.ts +0 -13
- package/dist/gaesup/component/active/common/WrapperRef.js +0 -9
- package/dist/gaesup/component/active/common/slopeRayRef.d.ts +0 -6
- package/dist/gaesup/component/active/common/slopeRayRef.js +0 -10
- package/dist/gaesup/component/active/vehicle/collider.d.ts +0 -3
- package/dist/gaesup/component/active/vehicle/collider.js +0 -9
- package/dist/gaesup/component/active/vehicle/wheel.d.ts +0 -12
- package/dist/gaesup/component/active/vehicle/wheel.js +0 -13
- package/dist/gaesup/component/active/vehicle/wheels.d.ts +0 -7
- package/dist/gaesup/component/active/vehicle/wheels.js +0 -22
- package/dist/gaesup/component/passive/airplane/collider.d.ts +0 -5
- package/dist/gaesup/component/passive/airplane/collider.js +0 -7
- package/dist/gaesup/component/passive/airplane/type.d.ts +0 -12
- package/dist/gaesup/component/passive/character/collider.d.ts +0 -6
- package/dist/gaesup/component/passive/character/collider.js +0 -7
- package/dist/gaesup/component/passive/character/type.d.ts +0 -27
- package/dist/gaesup/component/passive/character/type.js +0 -1
- package/dist/gaesup/component/passive/common/RigidbodyRef.js +0 -10
- package/dist/gaesup/component/passive/vehicle/type.d.ts +0 -21
- package/dist/gaesup/component/passive/vehicle/type.js +0 -1
- package/dist/gaesup/component/passive/vehicle/wheel.d.ts +0 -15
- package/dist/gaesup/component/passive/vehicle/wheel.js +0 -16
- package/dist/gaesup/component/passive/vehicle/wheels.d.ts +0 -11
- package/dist/gaesup/component/passive/vehicle/wheels.js +0 -25
- package/dist/gaesup/physics/check/slope.d.ts +0 -2
- package/dist/gaesup/physics/check/slope.js +0 -30
- package/dist/gaesup/utils/gltf.d.ts +0 -7
- package/dist/gaesup/utils/gltf.js +0 -10
- package/dist/gaesup/world/initalize/collider/airplane.d.ts +0 -2
- package/dist/gaesup/world/initalize/collider/airplane.js +0 -25
- package/dist/gaesup/world/initalize/collider/character.d.ts +0 -2
- package/dist/gaesup/world/initalize/collider/character.js +0 -27
- package/dist/gaesup/world/initalize/collider/gltf.d.ts +0 -14
- package/dist/gaesup/world/initalize/collider/gltf.js +0 -54
- package/dist/gaesup/world/initalize/collider/index.d.ts +0 -2
- package/dist/gaesup/world/initalize/collider/index.js +0 -17
- package/dist/gaesup/world/initalize/collider/vehicle.d.ts +0 -2
- package/dist/gaesup/world/initalize/collider/vehicle.js +0 -55
- package/dist/gaesup/world/initalize/type.d.ts +0 -13
- package/dist/gaesup/world/initalize/type.js +0 -1
- /package/dist/gaesup/component/{passive → inner}/common/OuterGroupRef.d.ts +0 -0
- /package/dist/gaesup/component/{passive → inner}/common/OuterGroupRef.js +0 -0
- /package/dist/gaesup/component/{passive/airplane → inner/common}/type.js +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CuboidCollider } from "@react-three/rapier";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
5
|
+
export var VehicleWheelCollider = forwardRef(function (_a, ref) {
|
|
6
|
+
var urls = _a.urls, vehicleSize = _a.vehicleSize;
|
|
7
|
+
var wheelSize = useGltfAndSize({
|
|
8
|
+
url: urls.wheelUrl,
|
|
9
|
+
}).size;
|
|
10
|
+
return (_jsx(CuboidCollider, { ref: ref, args: [
|
|
11
|
+
vehicleSize.x / 2,
|
|
12
|
+
vehicleSize.y / 2 - wheelSize.y / 2,
|
|
13
|
+
vehicleSize.z / 2,
|
|
14
|
+
], position: [0, vehicleSize.y / 2 + wheelSize.y / 2, 0] }));
|
|
15
|
+
});
|
|
16
|
+
export var VehicleCollider = forwardRef(function (_a, ref) {
|
|
17
|
+
var vehicleSize = _a.vehicleSize;
|
|
18
|
+
return (_jsx(CuboidCollider, { ref: ref, args: [vehicleSize.x / 2, vehicleSize.y / 2, vehicleSize.z / 2], position: [0, vehicleSize.y / 2, 0] }));
|
|
19
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
3
|
+
import { InnerGroupRef } from "../common/InnerGroupRef";
|
|
4
|
+
import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
5
|
+
import { RigidBodyRef } from "../common/RigidbodyRef";
|
|
6
|
+
import RiderRef from "../rider";
|
|
7
|
+
import { VehicleCollider, VehicleWheelCollider } from "./collider";
|
|
8
|
+
import { WheelsRef } from "./wheels";
|
|
9
|
+
export function VehicleInnerRef(_a) {
|
|
10
|
+
var children = _a.children, refs = _a.refs, urls = _a.urls, isRiderOn = _a.isRiderOn, enableRiding = _a.enableRiding, offset = _a.offset, name = _a.name, position = _a.position, rotation = _a.rotation, userData = _a.userData, currentAnimation = _a.currentAnimation, onCollisionEnter = _a.onCollisionEnter;
|
|
11
|
+
var vehicleUrl = urls.vehicleUrl, wheelUrl = urls.wheelUrl;
|
|
12
|
+
var rigidBodyRef = refs.rigidBodyRef, innerGroupRef = refs.innerGroupRef, outerGroupRef = refs.outerGroupRef;
|
|
13
|
+
var vehicleSize = useGltfAndSize({
|
|
14
|
+
url: urls.vehicleUrl,
|
|
15
|
+
}).size;
|
|
16
|
+
return (_jsxs(OuterGroupRef, { ref: outerGroupRef, children: [vehicleUrl && rigidBodyRef && (_jsxs(RigidBodyRef, { ref: rigidBodyRef, name: name, position: position, rotation: rotation, userData: userData, onCollisionEnter: onCollisionEnter, children: [wheelUrl ? (_jsx(VehicleWheelCollider, { urls: urls, vehicleSize: vehicleSize })) : (_jsx(VehicleCollider, { vehicleSize: vehicleSize })), enableRiding && isRiderOn && urls.characterUrl && (_jsx(RiderRef, { urls: urls, offset: offset })), children, _jsx(InnerGroupRef, { type: "vehicle", url: vehicleUrl, currentAnimation: currentAnimation, ref: innerGroupRef })] })), wheelUrl && (_jsx(WheelsRef, { refs: refs, urls: urls, vehicleSize: vehicleSize }))] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { refsType } from "../../../controller/type";
|
|
2
|
+
import { urlsType } from "../../../world/context/type";
|
|
3
|
+
export declare function WheelsRef({ vehicleSize, refs, urls, }: {
|
|
4
|
+
vehicleSize: THREE.Vector3;
|
|
5
|
+
refs: Partial<refsType>;
|
|
6
|
+
urls: urlsType;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Gltf } from "@react-three/drei";
|
|
3
|
+
import { useFrame } from "@react-three/fiber";
|
|
4
|
+
import { CylinderCollider, RigidBody, useRevoluteJoint, } from "@react-three/rapier";
|
|
5
|
+
import { createRef, useContext, useRef } from "react";
|
|
6
|
+
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
7
|
+
import { GaesupWorldContext } from "../../../world/context";
|
|
8
|
+
var WheelJoint = function (_a) {
|
|
9
|
+
var body = _a.body, wheel = _a.wheel, bodyAnchor = _a.bodyAnchor, wheelAnchor = _a.wheelAnchor, rotationAxis = _a.rotationAxis;
|
|
10
|
+
var joint = useRevoluteJoint(body, wheel, [
|
|
11
|
+
bodyAnchor,
|
|
12
|
+
wheelAnchor,
|
|
13
|
+
rotationAxis,
|
|
14
|
+
]);
|
|
15
|
+
var activeState = useContext(GaesupWorldContext).activeState;
|
|
16
|
+
useFrame(function () {
|
|
17
|
+
if (joint.current) {
|
|
18
|
+
joint.current.configureMotorPosition(activeState.position.length(), 0.8, 0);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return null;
|
|
22
|
+
};
|
|
23
|
+
export function WheelsRef(_a) {
|
|
24
|
+
var vehicleSize = _a.vehicleSize, refs = _a.refs, urls = _a.urls;
|
|
25
|
+
var wheelUrl = urls.wheelUrl;
|
|
26
|
+
var rigidBodyRef = refs.rigidBodyRef;
|
|
27
|
+
var wheelSize = useGltfAndSize({
|
|
28
|
+
url: urls.wheelUrl,
|
|
29
|
+
}).size;
|
|
30
|
+
var X = (vehicleSize.x - wheelSize.x) / 2;
|
|
31
|
+
var Z = (vehicleSize.z - 2 * wheelSize.z) / 2;
|
|
32
|
+
var wheelPositions = [
|
|
33
|
+
[-X, 0, Z],
|
|
34
|
+
[-X, 0, -Z],
|
|
35
|
+
[X, 0, Z],
|
|
36
|
+
[X, 0, -Z],
|
|
37
|
+
];
|
|
38
|
+
var wheelRefs = useRef(wheelPositions.map(function () { return createRef(); }));
|
|
39
|
+
return (_jsxs(_Fragment, { children: [rigidBodyRef &&
|
|
40
|
+
wheelUrl &&
|
|
41
|
+
wheelRefs &&
|
|
42
|
+
wheelPositions.map(function (wheelPosition, index) {
|
|
43
|
+
if (!wheelRefs ||
|
|
44
|
+
!wheelRefs.current ||
|
|
45
|
+
!wheelRefs.current[index] ||
|
|
46
|
+
!wheelSize.x ||
|
|
47
|
+
!wheelSize.y)
|
|
48
|
+
return _jsx(_Fragment, {});
|
|
49
|
+
var wheelRef = wheelRefs.current[index];
|
|
50
|
+
return (_jsxs(RigidBody, { position: wheelPosition, colliders: false, type: "dynamic", ref: wheelRef, rotation: [0, 0, Math.PI / 2], children: [_jsx(CylinderCollider, { rotation: [0, 0, Math.PI / 2], args: [wheelSize.x / 2, wheelSize.y / 2] }), _jsx(Gltf, { src: wheelUrl })] }, index));
|
|
51
|
+
}), rigidBodyRef &&
|
|
52
|
+
wheelUrl &&
|
|
53
|
+
wheelRefs &&
|
|
54
|
+
wheelPositions.map(function (wheelPosition, index) {
|
|
55
|
+
if (!wheelRefs ||
|
|
56
|
+
!wheelRefs.current ||
|
|
57
|
+
!wheelRefs.current[index] ||
|
|
58
|
+
!wheelSize.x ||
|
|
59
|
+
!wheelSize.y)
|
|
60
|
+
return _jsx(_Fragment, {});
|
|
61
|
+
var wheelRef = wheelRefs.current[index];
|
|
62
|
+
return (_jsx(WheelJoint, { body: rigidBodyRef, wheel: wheelRef, bodyAnchor: wheelPosition, wheelAnchor: [0, 0, 0], rotationAxis: [1, 0, 0] }, index));
|
|
63
|
+
})] }));
|
|
64
|
+
}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CollisionEnterPayload } from "@react-three/rapier";
|
|
3
|
+
import { urlsType } from "../../../world/context/type";
|
|
4
|
+
export type passiveAirplanePropsType = {
|
|
5
|
+
position: THREE.Vector3;
|
|
6
|
+
euler: THREE.Euler;
|
|
7
|
+
urls: urlsType;
|
|
8
|
+
currentAnimation: string;
|
|
9
|
+
offset?: THREE.Vector3;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
|
|
12
|
+
};
|
|
2
13
|
export declare function PassiveAirplane(props: passiveAirplanePropsType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useFrame } from "@react-three/fiber";
|
|
3
|
-
import {
|
|
3
|
+
import { quat, } from "@react-three/rapier";
|
|
4
4
|
import { useMemo, useRef } from "react";
|
|
5
|
-
import {
|
|
6
|
-
import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
7
|
-
import { RigidBodyRef } from "../common/RigidbodyRef";
|
|
5
|
+
import { AirplaneInnerRef } from "../../inner/airplane";
|
|
8
6
|
export function PassiveAirplane(props) {
|
|
9
7
|
var rigidBodyRef = useRef(null);
|
|
10
8
|
var outerGroupRef = useRef(null);
|
|
@@ -21,10 +19,9 @@ export function PassiveAirplane(props) {
|
|
|
21
19
|
position: props.position,
|
|
22
20
|
euler: props.euler,
|
|
23
21
|
currentAnimation: props.currentAnimation,
|
|
24
|
-
|
|
25
|
-
airplaneSize: props.airplaneSize,
|
|
22
|
+
urls: props.urls,
|
|
26
23
|
};
|
|
27
|
-
}, [props]), position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation,
|
|
24
|
+
}, [props]), position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation, urls = _a.urls;
|
|
28
25
|
useFrame(function () {
|
|
29
26
|
if (innerGroupRef && innerGroupRef.current) {
|
|
30
27
|
var _euler = euler.clone();
|
|
@@ -39,5 +36,5 @@ export function PassiveAirplane(props) {
|
|
|
39
36
|
: 0.1, false);
|
|
40
37
|
}
|
|
41
38
|
});
|
|
42
|
-
return (
|
|
39
|
+
return (_jsx(AirplaneInnerRef, { refs: refs, urls: urls, position: position, rotation: euler, userData: { intangible: true }, onCollisionEnter: props.onCollisionEnter, currentAnimation: props.currentAnimation, children: props.children }));
|
|
43
40
|
}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { urlsType } from "../../../world/context/type";
|
|
3
|
+
export type passiveCharacterPropsType = {
|
|
4
|
+
position: THREE.Vector3;
|
|
5
|
+
euler: THREE.Euler;
|
|
6
|
+
urls: urlsType;
|
|
7
|
+
currentAnimation: string;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
};
|
|
2
10
|
export declare function PassiveCharacter(props: passiveCharacterPropsType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useAnimations } from "@react-three/drei";
|
|
2
3
|
import { useFrame } from "@react-three/fiber";
|
|
3
4
|
import { quat } from "@react-three/rapier";
|
|
4
5
|
import { useEffect, useMemo, useRef } from "react";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { CharacterCapsuleCollider } from "./collider";
|
|
6
|
+
import playActions from "../../../animation/actions";
|
|
7
|
+
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
8
|
+
import { CharacterInnerRef } from "../../inner/character";
|
|
9
9
|
export function PassiveCharacter(props) {
|
|
10
10
|
var rigidBodyRef = useRef(null);
|
|
11
11
|
var outerGroupRef = useRef(null);
|
|
@@ -15,16 +15,16 @@ export function PassiveCharacter(props) {
|
|
|
15
15
|
rigidBodyRef: rigidBodyRef,
|
|
16
16
|
outerGroupRef: outerGroupRef,
|
|
17
17
|
innerGroupRef: innerGroupRef,
|
|
18
|
-
|
|
18
|
+
colliderRef: colliderRef,
|
|
19
19
|
};
|
|
20
20
|
var _a = useMemo(function () {
|
|
21
21
|
return {
|
|
22
22
|
position: props.position,
|
|
23
23
|
euler: props.euler,
|
|
24
24
|
currentAnimation: props.currentAnimation,
|
|
25
|
-
characterUrl: props.
|
|
25
|
+
characterUrl: props.urls.characterUrl,
|
|
26
26
|
};
|
|
27
|
-
}, [props]), position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation
|
|
27
|
+
}, [props]), position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation;
|
|
28
28
|
useEffect(function () {
|
|
29
29
|
if (rigidBodyRef || rigidBodyRef.current) {
|
|
30
30
|
rigidBodyRef.current.setEnabledRotations(false, false, false, false);
|
|
@@ -35,5 +35,12 @@ export function PassiveCharacter(props) {
|
|
|
35
35
|
innerGroupRef.current.quaternion.rotateTowards(quat().setFromEuler(euler), 10 * delta);
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
-
|
|
38
|
+
var gltf = useGltfAndSize({ url: props.urls.characterUrl }).gltf;
|
|
39
|
+
var animationResult = useAnimations(gltf.animations);
|
|
40
|
+
var animationRef = playActions({
|
|
41
|
+
type: "character",
|
|
42
|
+
animationResult: animationResult,
|
|
43
|
+
currentAnimation: currentAnimation,
|
|
44
|
+
}).animationRef;
|
|
45
|
+
return (_jsx(CharacterInnerRef, { animationRef: animationRef, position: position, refs: refs, urls: props.urls, children: props.children }));
|
|
39
46
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { gaesupPassivePropsType } from "../../hooks/useGaesupController";
|
|
3
|
-
import { activeStateType,
|
|
2
|
+
import { activeStateType, modeType, wheelsStateType } from "../../world/context/type";
|
|
4
3
|
export type passiveComponentType = {
|
|
5
4
|
props: gaesupPassivePropsType;
|
|
6
5
|
};
|
|
@@ -19,12 +18,3 @@ export type passiveVehicleType = {
|
|
|
19
18
|
url: string;
|
|
20
19
|
wheelUrl?: string;
|
|
21
20
|
};
|
|
22
|
-
export type passiveVehicleInnerType = {
|
|
23
|
-
rigidBodyRef: React.MutableRefObject<THREE.Object3D | undefined>;
|
|
24
|
-
collider: vehicleColliderType;
|
|
25
|
-
wheelOffset: number;
|
|
26
|
-
};
|
|
27
|
-
export type passiveCharacterInnerType = {
|
|
28
|
-
rigidBodyRef: React.MutableRefObject<THREE.Object3D | undefined>;
|
|
29
|
-
collider: characterColliderType;
|
|
30
|
-
};
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CollisionEnterPayload } from "@react-three/rapier";
|
|
3
|
+
import { urlsType } from "../../../world/context/type";
|
|
4
|
+
export type passiveVehiclePropsType = {
|
|
5
|
+
position: THREE.Vector3;
|
|
6
|
+
euler: THREE.Euler;
|
|
7
|
+
urls: urlsType;
|
|
8
|
+
currentAnimation: string;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
offset?: THREE.Vector3;
|
|
11
|
+
onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
|
|
12
|
+
};
|
|
2
13
|
export declare function PassiveVehicle(props: passiveVehiclePropsType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { InnerGroupRef } from "../common/InnerGroupRef";
|
|
5
|
-
import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
6
|
-
import { RigidBodyRef } from "../common/RigidbodyRef";
|
|
7
|
-
import { Wheels } from "./wheels";
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { VehicleInnerRef } from "../../inner/vehicle";
|
|
8
4
|
export function PassiveVehicle(props) {
|
|
9
5
|
var rigidBodyRef = useRef(null);
|
|
10
6
|
var outerGroupRef = useRef(null);
|
|
@@ -14,23 +10,8 @@ export function PassiveVehicle(props) {
|
|
|
14
10
|
rigidBodyRef: rigidBodyRef,
|
|
15
11
|
outerGroupRef: outerGroupRef,
|
|
16
12
|
innerGroupRef: innerGroupRef,
|
|
17
|
-
|
|
13
|
+
colliderRef: colliderRef,
|
|
18
14
|
};
|
|
19
|
-
var
|
|
20
|
-
|
|
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
|
-
useEffect(function () {
|
|
31
|
-
if (rigidBodyRef.current) {
|
|
32
|
-
rigidBodyRef.current.lockRotations(true, true);
|
|
33
|
-
}
|
|
34
|
-
}, []);
|
|
35
|
-
return (_jsxs(OuterGroupRef, { ref: refs.outerGroupRef, children: [props.children, vehicleUrl && (_jsxs(RigidBodyRef, { ref: refs.rigidBodyRef, position: position, rotation: euler, onCollisionEnter: props.onCollisionEnter, children: [_jsx(InnerGroupRef, { currentAnimation: currentAnimation, ref: refs.innerGroupRef, url: vehicleUrl }), wheelUrl ? (_jsx(CuboidCollider, { ref: colliderRef, args: [vehicleSize.x / 2, vehicleSize.y / 2, vehicleSize.z / 2], position: [0, vehicleSize.y + wheelSize.y / 2, 0] })) : (_jsx(CuboidCollider, { ref: colliderRef, args: [vehicleSize.x / 2, vehicleSize.y / 2, vehicleSize.z / 2], position: [0, vehicleSize.y, 0] }))] })), wheelUrl && (_jsx(Wheels, { vehicleSize: vehicleSize, wheelSize: wheelSize, rigidBodyRef: rigidBodyRef, url: wheelUrl }))] }));
|
|
15
|
+
var position = props.position, euler = props.euler, currentAnimation = props.currentAnimation, urls = props.urls;
|
|
16
|
+
return (_jsx(VehicleInnerRef, { refs: refs, urls: urls, position: position, rotation: euler, userData: { intangible: true }, onCollisionEnter: props.onCollisionEnter, currentAnimation: currentAnimation, children: props.children }));
|
|
36
17
|
}
|
|
@@ -32,14 +32,18 @@ export declare const gaesupControllerDefault: {
|
|
|
32
32
|
onAnimate: () => void;
|
|
33
33
|
};
|
|
34
34
|
refs: {
|
|
35
|
-
|
|
35
|
+
colliderRef: any;
|
|
36
36
|
rigidBodyRef: any;
|
|
37
37
|
outerGroupRef: any;
|
|
38
38
|
innerGroupRef: any;
|
|
39
|
-
slopeRayOriginRef: any;
|
|
40
39
|
characterInnerRef: any;
|
|
41
40
|
};
|
|
42
|
-
|
|
41
|
+
urls: {
|
|
42
|
+
airplaneUrl: any;
|
|
43
|
+
vehicleUrl: any;
|
|
44
|
+
characterUrl: any;
|
|
45
|
+
wheelUrl: any;
|
|
46
|
+
};
|
|
43
47
|
};
|
|
44
48
|
export declare const GaesupControllerContext: import("react").Context<gaesupControllerType>;
|
|
45
49
|
export declare const GaesupControllerDispatchContext: import("react").Context<dispatchType<gaesupControllerType>>;
|
|
@@ -42,14 +42,18 @@ export var gaesupControllerDefault = {
|
|
|
42
42
|
onAnimate: function () { },
|
|
43
43
|
},
|
|
44
44
|
refs: {
|
|
45
|
-
|
|
45
|
+
colliderRef: null,
|
|
46
46
|
rigidBodyRef: null,
|
|
47
47
|
outerGroupRef: null,
|
|
48
48
|
innerGroupRef: null,
|
|
49
|
-
slopeRayOriginRef: null,
|
|
50
49
|
characterInnerRef: null,
|
|
51
50
|
},
|
|
52
|
-
|
|
51
|
+
urls: {
|
|
52
|
+
airplaneUrl: null,
|
|
53
|
+
vehicleUrl: null,
|
|
54
|
+
characterUrl: null,
|
|
55
|
+
wheelUrl: null,
|
|
56
|
+
},
|
|
53
57
|
};
|
|
54
58
|
export var GaesupControllerContext = createContext(__assign({}, gaesupControllerDefault));
|
|
55
59
|
export var GaesupControllerDispatchContext = createContext(null);
|
|
@@ -6,7 +6,7 @@ export declare function gaesupControllerReducer(props: gaesupControllerType, act
|
|
|
6
6
|
airplane: import("./type").airplaneType;
|
|
7
7
|
vehicle: import("./type").vehicleType;
|
|
8
8
|
character: import("./type").characterType;
|
|
9
|
-
|
|
9
|
+
urls: import("../../world/context/type").urlsType;
|
|
10
10
|
callbacks?: import("../initialize/callback/type").callbackType;
|
|
11
11
|
refs?: import("../type").refsType;
|
|
12
12
|
};
|
|
@@ -24,11 +24,10 @@ export function GaesupController(props) {
|
|
|
24
24
|
return (_jsx(KeyboardControls, { map: keyBoardMap, children: _jsx(GaesupControllerInner, __assign({}, props, { children: props.children })) }));
|
|
25
25
|
}
|
|
26
26
|
export function GaesupControllerInner(props) {
|
|
27
|
-
var
|
|
27
|
+
var colliderRef = useRef(null);
|
|
28
28
|
var rigidBodyRef = useRef(null);
|
|
29
29
|
var outerGroupRef = useRef(null);
|
|
30
30
|
var innerGroupRef = useRef(null);
|
|
31
|
-
var slopeRayOriginRef = useRef(null);
|
|
32
31
|
var characterInnerRef = useRef(null);
|
|
33
32
|
var passiveRigidBodyRef = useRef(null);
|
|
34
33
|
var _a = useReducer(gaesupControllerReducer, {
|
|
@@ -41,15 +40,14 @@ export function GaesupControllerInner(props) {
|
|
|
41
40
|
onDestory: props.onDestory,
|
|
42
41
|
onAnimate: props.onAnimate,
|
|
43
42
|
}),
|
|
43
|
+
urls: Object.assign(gaesupControllerDefault.urls, props.urls || {}),
|
|
44
44
|
refs: {
|
|
45
|
-
|
|
45
|
+
colliderRef: colliderRef,
|
|
46
46
|
rigidBodyRef: rigidBodyRef,
|
|
47
47
|
outerGroupRef: outerGroupRef,
|
|
48
48
|
innerGroupRef: innerGroupRef,
|
|
49
|
-
slopeRayOriginRef: slopeRayOriginRef,
|
|
50
49
|
characterInnerRef: characterInnerRef,
|
|
51
50
|
},
|
|
52
|
-
isRider: props.isRider !== null ? props.isRider : false,
|
|
53
51
|
}), controller = _a[0], controllerDispatch = _a[1];
|
|
54
52
|
var gaesupControl = useMemo(function () { return ({
|
|
55
53
|
value: controller,
|
|
@@ -57,11 +55,10 @@ export function GaesupControllerInner(props) {
|
|
|
57
55
|
}); }, [controller, controllerDispatch]);
|
|
58
56
|
var refs = useMemo(function () {
|
|
59
57
|
return {
|
|
60
|
-
|
|
58
|
+
colliderRef: colliderRef,
|
|
61
59
|
rigidBodyRef: rigidBodyRef,
|
|
62
60
|
outerGroupRef: outerGroupRef,
|
|
63
61
|
innerGroupRef: innerGroupRef,
|
|
64
|
-
slopeRayOriginRef: slopeRayOriginRef,
|
|
65
62
|
characterInnerRef: characterInnerRef,
|
|
66
63
|
passiveRigidBodyRef: passiveRigidBodyRef,
|
|
67
64
|
};
|
|
@@ -73,5 +70,5 @@ export function GaesupControllerInner(props) {
|
|
|
73
70
|
controllerContext: gaesupControl.value,
|
|
74
71
|
controllerDispatch: gaesupControl.dispatch,
|
|
75
72
|
});
|
|
76
|
-
return (_jsxs(GaesupControllerContext.Provider, { value: gaesupControl.value, children: [_jsx(Camera, { refs: refs, prop: prop, control: prop.keyControl }), _jsx(GaesupControllerDispatchContext.Provider, { value: gaesupControl.dispatch, children: _jsx(GaesupComponent, { props: prop, refs: refs }) })] }));
|
|
73
|
+
return (_jsxs(GaesupControllerContext.Provider, { value: gaesupControl.value, children: [_jsx(Camera, { refs: refs, prop: prop, control: prop.keyControl }), _jsx(GaesupControllerDispatchContext.Provider, { value: gaesupControl.dispatch, children: _jsx(GaesupComponent, { props: prop, refs: refs, urls: props.urls }) })] }));
|
|
77
74
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { controllerInnerType } from "../../type";
|
|
2
|
-
export default function initCallback(props: controllerInnerType): void;
|
|
2
|
+
export default function initCallback(props: controllerInnerType, type: "character" | "vehicle" | "airplane"): void;
|
|
@@ -1,55 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
useEffect(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}, []);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
export default function initCallback(props, type) {
|
|
2
|
+
// const {
|
|
3
|
+
// characterGltf,
|
|
4
|
+
// animations: characterAnimations,
|
|
5
|
+
// activeState,
|
|
6
|
+
// states,
|
|
7
|
+
// control,
|
|
8
|
+
// } = useContext(GaesupWorldContext);
|
|
9
|
+
// const dispatch = useContext(GaesupWorldDispatchContext);
|
|
10
|
+
// const { animations } = characterGltf;
|
|
11
|
+
// const { actions } = useAnimations(animations, props.outerGroupRef);
|
|
12
|
+
// const { subscribe } = useGaesupAnimation({ type });
|
|
13
|
+
//
|
|
14
|
+
// const playAnimation = (tag: keyof animationTagType, key: string) => {
|
|
15
|
+
// if (!(key in control)) return;
|
|
16
|
+
// if (control[key]) {
|
|
17
|
+
// characterAnimations.current = tag;
|
|
18
|
+
// dispatch({
|
|
19
|
+
// type: "update",
|
|
20
|
+
// payload: {
|
|
21
|
+
// animations: {
|
|
22
|
+
// ...characterAnimations,
|
|
23
|
+
// },
|
|
24
|
+
// },
|
|
25
|
+
// });
|
|
26
|
+
// }
|
|
27
|
+
// };
|
|
28
|
+
//
|
|
29
|
+
// const controllerProp: callbackPropType = {
|
|
30
|
+
// ...props,
|
|
31
|
+
// activeState,
|
|
32
|
+
// control,
|
|
33
|
+
// states,
|
|
34
|
+
// subscribe,
|
|
35
|
+
// };
|
|
36
|
+
//
|
|
37
|
+
// useEffect(() => {
|
|
38
|
+
// if (props.onReady) {
|
|
39
|
+
// props.onReady(controllerProp);
|
|
40
|
+
// }
|
|
41
|
+
// return () => {
|
|
42
|
+
// if (props.onDestory) {
|
|
43
|
+
// props.onDestory(controllerProp);
|
|
44
|
+
// }
|
|
45
|
+
// };
|
|
46
|
+
// }, []);
|
|
47
|
+
//
|
|
48
|
+
// useFrame((prop) => {
|
|
49
|
+
// if (props.onFrame) {
|
|
50
|
+
// props.onFrame({ ...controllerProp, ...prop });
|
|
51
|
+
// }
|
|
52
|
+
// if (props.onAnimate) {
|
|
53
|
+
// props.onAnimate({
|
|
54
|
+
// ...controllerProp,
|
|
55
|
+
// ...prop,
|
|
56
|
+
// actions,
|
|
57
|
+
// animation: characterAnimations,
|
|
58
|
+
// playAnimation,
|
|
59
|
+
// });
|
|
60
|
+
// }
|
|
61
|
+
// });
|
|
55
62
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { groundRayType, refsType
|
|
1
|
+
import { groundRayType, refsType } from "../../controller/type";
|
|
2
2
|
import { cameraRayType } from "../../camera/type";
|
|
3
3
|
import { keyControlType } from "../../world/context/type";
|
|
4
4
|
export default function initControllerProps({ refs }: {
|
|
5
5
|
refs: refsType;
|
|
6
6
|
}): {
|
|
7
|
-
slopeRay: slopeRayType;
|
|
8
7
|
groundRay: groundRayType;
|
|
9
8
|
cameraRay: cameraRayType;
|
|
10
9
|
keyControl: keyControlType;
|
|
@@ -37,25 +37,13 @@ export default function initControllerProps(_a) {
|
|
|
37
37
|
return {
|
|
38
38
|
origin: vec3(),
|
|
39
39
|
dir: vec3({ x: 0, y: -1, z: 0 }),
|
|
40
|
-
offset: vec3({ x: 0, y: -
|
|
40
|
+
offset: vec3({ x: 0, y: -1, z: 0 }),
|
|
41
41
|
hit: null,
|
|
42
42
|
parent: null,
|
|
43
43
|
rayCast: null,
|
|
44
44
|
length: 0.5,
|
|
45
45
|
};
|
|
46
46
|
}, []);
|
|
47
|
-
var slopeRay = useMemo(function () {
|
|
48
|
-
return {
|
|
49
|
-
current: vec3(),
|
|
50
|
-
origin: vec3(),
|
|
51
|
-
hit: null,
|
|
52
|
-
rayCast: null,
|
|
53
|
-
dir: vec3({ x: 0, y: -1, z: 0 }),
|
|
54
|
-
offset: vec3({ x: 0, y: 0, z: context.characterCollider.radius - 0.03 }),
|
|
55
|
-
length: context.characterCollider.radius + 3,
|
|
56
|
-
angle: 0,
|
|
57
|
-
};
|
|
58
|
-
}, []);
|
|
59
47
|
var cameraRay = useMemo(function () {
|
|
60
48
|
return {
|
|
61
49
|
origin: vec3(),
|
|
@@ -80,7 +68,6 @@ export default function initControllerProps(_a) {
|
|
|
80
68
|
}
|
|
81
69
|
}, []);
|
|
82
70
|
return {
|
|
83
|
-
slopeRay: slopeRay,
|
|
84
71
|
groundRay: groundRay,
|
|
85
72
|
cameraRay: cameraRay,
|
|
86
73
|
keyControl: keyControl,
|
|
@@ -4,7 +4,7 @@ import { RapierRigidBody, RigidBodyProps } from "@react-three/rapier";
|
|
|
4
4
|
import { ReactNode, RefObject } from "react";
|
|
5
5
|
import * as THREE from "three";
|
|
6
6
|
import { cameraRayType } from "../camera/type";
|
|
7
|
-
import { keyControlType } from "../world/context/type";
|
|
7
|
+
import { keyControlType, urlsType } from "../world/context/type";
|
|
8
8
|
import { airplaneType, characterType, vehicleType } from "./context/type";
|
|
9
9
|
import { callbackType } from "./initialize/callback/type";
|
|
10
10
|
export type optionsType = {
|
|
@@ -43,9 +43,7 @@ export type rayType = {
|
|
|
43
43
|
export type slopeRayType = Omit<rayType, "parent">;
|
|
44
44
|
export type groundRayType = Omit<rayType, "current" | "angle">;
|
|
45
45
|
export type controllerInnerType = {
|
|
46
|
-
isRider?: boolean;
|
|
47
46
|
name?: string;
|
|
48
|
-
slopeRay: slopeRayType;
|
|
49
47
|
groundRay: groundRayType;
|
|
50
48
|
cameraRay: cameraRayType;
|
|
51
49
|
keyControl: keyControlType;
|
|
@@ -66,18 +64,17 @@ export type actionsType = animationTagType & {
|
|
|
66
64
|
[key: string]: string;
|
|
67
65
|
};
|
|
68
66
|
export type refsType = {
|
|
69
|
-
|
|
67
|
+
colliderRef: RefObject<Collider>;
|
|
70
68
|
rigidBodyRef: RefObject<RapierRigidBody>;
|
|
71
69
|
outerGroupRef: RefObject<THREE.Group>;
|
|
72
70
|
innerGroupRef: RefObject<THREE.Group>;
|
|
73
|
-
slopeRayOriginRef: RefObject<THREE.Mesh>;
|
|
74
71
|
characterInnerRef: RefObject<THREE.Group>;
|
|
75
72
|
};
|
|
76
73
|
export type gaesupControllerContextPropType = {
|
|
77
74
|
airplane: airplaneType;
|
|
78
75
|
vehicle: vehicleType;
|
|
79
76
|
character: characterType;
|
|
80
|
-
|
|
77
|
+
urls: urlsType;
|
|
81
78
|
};
|
|
82
79
|
export interface controllerOtherPropType extends RigidBodyProps {
|
|
83
80
|
children?: ReactNode;
|
|
@@ -15,7 +15,7 @@ import { Suspense, useContext, useEffect, useMemo, useRef } from "react";
|
|
|
15
15
|
import * as THREE from "three";
|
|
16
16
|
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context/index.js";
|
|
17
17
|
export function GaeSupProps(_a) {
|
|
18
|
-
var
|
|
18
|
+
var _b = _a.type, type = _b === void 0 ? "normal" : _b, text = _a.text, position = _a.position, children = _a.children;
|
|
19
19
|
var groupRef = useRef(null);
|
|
20
20
|
var minimap = useContext(GaesupWorldContext).minimap;
|
|
21
21
|
var dispatch = useContext(GaesupWorldDispatchContext);
|