gaesup-world 0.2.21 → 0.2.23
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/package.json +5 -2
- package/dist/gaesup/animation/actions.d.ts +0 -44
- package/dist/gaesup/animation/actions.js +0 -103
- package/dist/gaesup/camera/control/normal.d.ts +0 -4
- package/dist/gaesup/camera/control/normal.js +0 -18
- package/dist/gaesup/camera/control/orbit.d.ts +0 -4
- package/dist/gaesup/camera/control/orbit.js +0 -22
- package/dist/gaesup/camera/detector/index.d.ts +0 -2
- package/dist/gaesup/camera/detector/index.js +0 -25
- package/dist/gaesup/camera/index.d.ts +0 -8
- package/dist/gaesup/camera/index.js +0 -139
- package/dist/gaesup/camera/type.d.ts +0 -13
- package/dist/gaesup/camera/type.js +0 -1
- package/dist/gaesup/component/active/airplane/index.d.ts +0 -11
- package/dist/gaesup/component/active/airplane/index.js +0 -6
- package/dist/gaesup/component/active/character/index.d.ts +0 -7
- package/dist/gaesup/component/active/character/index.js +0 -34
- package/dist/gaesup/component/active/vehicle/index.d.ts +0 -12
- package/dist/gaesup/component/active/vehicle/index.js +0 -31
- package/dist/gaesup/component/index.d.ts +0 -7
- package/dist/gaesup/component/index.js +0 -19
- package/dist/gaesup/component/inner/airplane/index.d.ts +0 -2
- package/dist/gaesup/component/inner/airplane/index.js +0 -16
- package/dist/gaesup/component/inner/character/index.d.ts +0 -25
- package/dist/gaesup/component/inner/character/index.js +0 -28
- package/dist/gaesup/component/inner/common/InnerGroupRef.d.ts +0 -10
- package/dist/gaesup/component/inner/common/InnerGroupRef.js +0 -29
- package/dist/gaesup/component/inner/common/OuterGroupRef.d.ts +0 -4
- package/dist/gaesup/component/inner/common/OuterGroupRef.js +0 -6
- package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +0 -12
- package/dist/gaesup/component/inner/common/RigidbodyRef.js +0 -7
- package/dist/gaesup/component/inner/common/setGroundRay.d.ts +0 -9
- package/dist/gaesup/component/inner/common/setGroundRay.js +0 -14
- package/dist/gaesup/component/inner/common/type.d.ts +0 -20
- package/dist/gaesup/component/inner/common/type.js +0 -1
- package/dist/gaesup/component/inner/rider/index.d.ts +0 -11
- package/dist/gaesup/component/inner/rider/index.js +0 -31
- package/dist/gaesup/component/inner/vehicle/collider.d.ts +0 -10
- package/dist/gaesup/component/inner/vehicle/collider.js +0 -19
- package/dist/gaesup/component/inner/vehicle/index.d.ts +0 -2
- package/dist/gaesup/component/inner/vehicle/index.js +0 -17
- package/dist/gaesup/component/inner/vehicle/wheels.d.ts +0 -7
- package/dist/gaesup/component/inner/vehicle/wheels.js +0 -64
- package/dist/gaesup/component/passive/airplane/index.d.ts +0 -13
- package/dist/gaesup/component/passive/airplane/index.js +0 -40
- package/dist/gaesup/component/passive/character/index.d.ts +0 -10
- package/dist/gaesup/component/passive/character/index.js +0 -46
- package/dist/gaesup/component/passive/type.d.ts +0 -20
- package/dist/gaesup/component/passive/type.js +0 -1
- package/dist/gaesup/component/passive/vehicle/index.d.ts +0 -13
- package/dist/gaesup/component/passive/vehicle/index.js +0 -17
- package/dist/gaesup/component/type.d.ts +0 -17
- package/dist/gaesup/component/type.js +0 -1
- package/dist/gaesup/controller/context/index.d.ts +0 -49
- package/dist/gaesup/controller/context/index.js +0 -59
- package/dist/gaesup/controller/context/reducer.d.ts +0 -12
- package/dist/gaesup/controller/context/reducer.js +0 -21
- package/dist/gaesup/controller/context/type.d.ts +0 -38
- package/dist/gaesup/controller/context/type.js +0 -1
- package/dist/gaesup/controller/debug/airplane.d.ts +0 -71
- package/dist/gaesup/controller/debug/airplane.js +0 -71
- package/dist/gaesup/controller/debug/character.d.ts +0 -27
- package/dist/gaesup/controller/debug/character.js +0 -27
- package/dist/gaesup/controller/debug/index.d.ts +0 -6
- package/dist/gaesup/controller/debug/index.js +0 -49
- package/dist/gaesup/controller/debug/vehicle.d.ts +0 -27
- package/dist/gaesup/controller/debug/vehicle.js +0 -27
- package/dist/gaesup/controller/index.d.ts +0 -3
- package/dist/gaesup/controller/index.js +0 -74
- package/dist/gaesup/controller/initialize/callback/index.d.ts +0 -2
- package/dist/gaesup/controller/initialize/callback/index.js +0 -62
- package/dist/gaesup/controller/initialize/callback/type.d.ts +0 -27
- package/dist/gaesup/controller/initialize/callback/type.js +0 -1
- package/dist/gaesup/controller/initialize/index.d.ts +0 -10
- package/dist/gaesup/controller/initialize/index.js +0 -75
- package/dist/gaesup/controller/type.d.ts +0 -85
- package/dist/gaesup/controller/type.js +0 -1
- package/dist/gaesup/gaesupProps/index.d.ts +0 -7
- package/dist/gaesup/gaesupProps/index.js +0 -46
- package/dist/gaesup/hooks/useGaesupAnimation/index.d.ts +0 -10
- package/dist/gaesup/hooks/useGaesupAnimation/index.js +0 -95
- package/dist/gaesup/hooks/useGaesupController/index.d.ts +0 -10
- package/dist/gaesup/hooks/useGaesupController/index.js +0 -14
- package/dist/gaesup/hooks/useGaesupGltf/index.d.ts +0 -25
- package/dist/gaesup/hooks/useGaesupGltf/index.js +0 -73
- package/dist/gaesup/hooks/useJoyStick/index.d.ts +0 -39
- package/dist/gaesup/hooks/useJoyStick/index.js +0 -61
- package/dist/gaesup/hooks/usePushKey/index.d.ts +0 -3
- package/dist/gaesup/hooks/usePushKey/index.js +0 -29
- package/dist/gaesup/hooks/useRideable/index.d.ts +0 -28
- package/dist/gaesup/hooks/useRideable/index.js +0 -199
- package/dist/gaesup/hooks/useTeleport/index.d.ts +0 -3
- package/dist/gaesup/hooks/useTeleport/index.js +0 -12
- package/dist/gaesup/physics/airplane/damping.d.ts +0 -2
- package/dist/gaesup/physics/airplane/damping.js +0 -5
- package/dist/gaesup/physics/airplane/direction.d.ts +0 -2
- package/dist/gaesup/physics/airplane/direction.js +0 -65
- package/dist/gaesup/physics/airplane/gravity.d.ts +0 -14
- package/dist/gaesup/physics/airplane/gravity.js +0 -18
- package/dist/gaesup/physics/airplane/impulse.d.ts +0 -16
- package/dist/gaesup/physics/airplane/impulse.js +0 -31
- package/dist/gaesup/physics/airplane/index.d.ts +0 -2
- package/dist/gaesup/physics/airplane/index.js +0 -14
- package/dist/gaesup/physics/airplane/innerCalc.d.ts +0 -2
- package/dist/gaesup/physics/airplane/innerCalc.js +0 -27
- package/dist/gaesup/physics/airplane/landing.d.ts +0 -2
- package/dist/gaesup/physics/airplane/landing.js +0 -29
- package/dist/gaesup/physics/character/direction.d.ts +0 -23
- package/dist/gaesup/physics/character/direction.js +0 -55
- package/dist/gaesup/physics/character/impulse.d.ts +0 -2
- package/dist/gaesup/physics/character/impulse.js +0 -43
- package/dist/gaesup/physics/character/index.d.ts +0 -2
- package/dist/gaesup/physics/character/index.js +0 -8
- package/dist/gaesup/physics/character/innerCalc.d.ts +0 -2
- package/dist/gaesup/physics/character/innerCalc.js +0 -31
- package/dist/gaesup/physics/check/ground.d.ts +0 -2
- package/dist/gaesup/physics/check/ground.js +0 -15
- package/dist/gaesup/physics/check/index.d.ts +0 -2
- package/dist/gaesup/physics/check/index.js +0 -12
- package/dist/gaesup/physics/check/moving.d.ts +0 -2
- package/dist/gaesup/physics/check/moving.js +0 -16
- package/dist/gaesup/physics/check/push.d.ts +0 -2
- package/dist/gaesup/physics/check/push.js +0 -6
- package/dist/gaesup/physics/check/riding.d.ts +0 -2
- package/dist/gaesup/physics/check/riding.js +0 -7
- package/dist/gaesup/physics/check/rotate.d.ts +0 -2
- package/dist/gaesup/physics/check/rotate.js +0 -8
- package/dist/gaesup/physics/index.d.ts +0 -2
- package/dist/gaesup/physics/index.js +0 -58
- package/dist/gaesup/physics/type.d.ts +0 -36
- package/dist/gaesup/physics/type.js +0 -1
- package/dist/gaesup/physics/vehicle/damping.d.ts +0 -2
- package/dist/gaesup/physics/vehicle/damping.js +0 -6
- package/dist/gaesup/physics/vehicle/direction.d.ts +0 -4
- package/dist/gaesup/physics/vehicle/direction.js +0 -30
- package/dist/gaesup/physics/vehicle/impulse.d.ts +0 -16
- package/dist/gaesup/physics/vehicle/impulse.js +0 -40
- package/dist/gaesup/physics/vehicle/index.d.ts +0 -2
- package/dist/gaesup/physics/vehicle/index.js +0 -12
- package/dist/gaesup/physics/vehicle/innerCalc.d.ts +0 -2
- package/dist/gaesup/physics/vehicle/innerCalc.js +0 -24
- package/dist/gaesup/physics/vehicle/landing.d.ts +0 -2
- package/dist/gaesup/physics/vehicle/landing.js +0 -29
- package/dist/gaesup/tools/gameBoy/GameBoyButton.d.ts +0 -9
- package/dist/gaesup/tools/gameBoy/GameBoyButton.js +0 -16
- package/dist/gaesup/tools/gameBoy/index.d.ts +0 -8
- package/dist/gaesup/tools/gameBoy/index.js +0 -22
- package/dist/gaesup/tools/gameBoy/type.d.ts +0 -4
- package/dist/gaesup/tools/gameBoy/type.js +0 -1
- package/dist/gaesup/tools/gamePad/GamePadButton.d.ts +0 -8
- package/dist/gaesup/tools/gamePad/GamePadButton.js +0 -21
- package/dist/gaesup/tools/gamePad/index.d.ts +0 -6
- package/dist/gaesup/tools/gamePad/index.js +0 -32
- package/dist/gaesup/tools/gamePad/type.d.ts +0 -6
- package/dist/gaesup/tools/gamePad/type.js +0 -1
- package/dist/gaesup/tools/joyStick/index.d.ts +0 -6
- package/dist/gaesup/tools/joyStick/index.js +0 -169
- package/dist/gaesup/tools/joyStick/type.d.ts +0 -19
- package/dist/gaesup/tools/joyStick/type.js +0 -1
- package/dist/gaesup/tools/jumpPortal/index.d.ts +0 -16
- package/dist/gaesup/tools/jumpPortal/index.js +0 -18
- package/dist/gaesup/tools/keyBoardToolTip/constant.d.ts +0 -402
- package/dist/gaesup/tools/keyBoardToolTip/constant.js +0 -122
- package/dist/gaesup/tools/keyBoardToolTip/default.d.ts +0 -10
- package/dist/gaesup/tools/keyBoardToolTip/default.js +0 -12
- package/dist/gaesup/tools/keyBoardToolTip/index.d.ts +0 -3
- package/dist/gaesup/tools/keyBoardToolTip/index.js +0 -70
- package/dist/gaesup/tools/keyBoardToolTip/type.d.ts +0 -37
- package/dist/gaesup/tools/keyBoardToolTip/type.js +0 -1
- package/dist/gaesup/tools/miniMap/default.d.ts +0 -9
- package/dist/gaesup/tools/miniMap/default.js +0 -9
- package/dist/gaesup/tools/miniMap/index.d.ts +0 -3
- package/dist/gaesup/tools/miniMap/index.js +0 -72
- package/dist/gaesup/tools/miniMap/type.d.ts +0 -25
- package/dist/gaesup/tools/miniMap/type.js +0 -1
- package/dist/gaesup/tools/rideable/index.d.ts +0 -3
- package/dist/gaesup/tools/rideable/index.js +0 -79
- package/dist/gaesup/tools/type.d.ts +0 -2
- package/dist/gaesup/tools/type.js +0 -1
- package/dist/gaesup/tools/zoomButton/index.d.ts +0 -18
- package/dist/gaesup/tools/zoomButton/index.js +0 -146
- package/dist/gaesup/utils/context.d.ts +0 -2
- package/dist/gaesup/utils/context.js +0 -3
- package/dist/gaesup/utils/debug.d.ts +0 -29
- package/dist/gaesup/utils/debug.js +0 -36
- package/dist/gaesup/utils/index.d.ts +0 -3
- package/dist/gaesup/utils/index.js +0 -3
- package/dist/gaesup/utils/ray.d.ts +0 -7
- package/dist/gaesup/utils/ray.js +0 -6
- package/dist/gaesup/utils/ref.d.ts +0 -2
- package/dist/gaesup/utils/ref.js +0 -16
- package/dist/gaesup/utils/type.d.ts +0 -5
- package/dist/gaesup/utils/type.js +0 -1
- package/dist/gaesup/utils/vector.d.ts +0 -10
- package/dist/gaesup/utils/vector.js +0 -33
- package/dist/gaesup/world/context/index.d.ts +0 -6
- package/dist/gaesup/world/context/index.js +0 -117
- package/dist/gaesup/world/context/reducer.d.ts +0 -29
- package/dist/gaesup/world/context/reducer.js +0 -21
- package/dist/gaesup/world/context/type.d.ts +0 -169
- package/dist/gaesup/world/context/type.js +0 -1
- package/dist/gaesup/world/debug/cameraOption.d.ts +0 -47
- package/dist/gaesup/world/debug/cameraOption.js +0 -47
- package/dist/gaesup/world/debug/index.d.ts +0 -6
- package/dist/gaesup/world/debug/index.js +0 -32
- package/dist/gaesup/world/debug/mode.d.ts +0 -10
- package/dist/gaesup/world/debug/mode.js +0 -10
- package/dist/gaesup/world/index.d.ts +0 -3
- package/dist/gaesup/world/index.js +0 -9
- package/dist/gaesup/world/initalize/index.d.ts +0 -35
- package/dist/gaesup/world/initalize/index.js +0 -62
- package/dist/gaesup/world/type.d.ts +0 -19
- package/dist/gaesup/world/type.js +0 -1
- package/dist/index.d.ts +0 -23
- package/index.ts +0 -29
- package/yarn-error.log +0 -12152
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { vec3 } from "@react-three/rapier";
|
|
2
|
-
export default function checkOnTheGround(prop) {
|
|
3
|
-
var colliderRef = prop.colliderRef, groundRay = prop.groundRay, _a = prop.worldContext, states = _a.states, activeState = _a.activeState;
|
|
4
|
-
groundRay.origin.addVectors(activeState.position, vec3(groundRay.offset));
|
|
5
|
-
if (!groundRay.hit || !groundRay.rayCast || !colliderRef.current) {
|
|
6
|
-
states.isOnTheGround = false;
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (groundRay.hit.toi < groundRay.length + 0.5) {
|
|
10
|
-
states.isOnTheGround = true;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
states.isOnTheGround = false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import ground from "./ground";
|
|
2
|
-
import moving from "./moving";
|
|
3
|
-
import push from "./push";
|
|
4
|
-
import riding from "./riding";
|
|
5
|
-
import rotate from "./rotate";
|
|
6
|
-
export default function check(calcProp) {
|
|
7
|
-
ground(calcProp);
|
|
8
|
-
moving(calcProp);
|
|
9
|
-
rotate(calcProp);
|
|
10
|
-
push(calcProp);
|
|
11
|
-
riding(calcProp);
|
|
12
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export default function moving(prop) {
|
|
2
|
-
var _a = prop.worldContext, states = _a.states, joystick = _a.joystick, mode = _a.mode, control = _a.control;
|
|
3
|
-
var forward = control.forward, backward = control.backward, leftward = control.leftward, rightward = control.rightward, shift = control.shift, space = control.space;
|
|
4
|
-
if (mode.controller === "gameboy" || mode.controller === "keyboard") {
|
|
5
|
-
states.isMoving = forward || backward || leftward || rightward;
|
|
6
|
-
states.isNotMoving = !states.isMoving;
|
|
7
|
-
states.isRunning = shift && states.isMoving;
|
|
8
|
-
states.isJumping = space;
|
|
9
|
-
}
|
|
10
|
-
else if (mode.controller === "joystick") {
|
|
11
|
-
states.isMoving = joystick.joyStickOrigin.isOn;
|
|
12
|
-
states.isNotMoving = !joystick.joyStickOrigin.isOn;
|
|
13
|
-
states.isRunning = shift && states.isMoving;
|
|
14
|
-
states.isJumping = space;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export default function rotate(prop) {
|
|
2
|
-
var outerGroupRef = prop.outerGroupRef, _a = prop.worldContext, states = _a.states, activeState = _a.activeState;
|
|
3
|
-
if (states.isMoving && outerGroupRef && outerGroupRef.current) {
|
|
4
|
-
states.isRotated =
|
|
5
|
-
Math.sin(outerGroupRef.current.rotation.y).toFixed(3) ===
|
|
6
|
-
Math.sin(activeState.euler.y).toFixed(3);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { useFrame } from "@react-three/fiber";
|
|
13
|
-
import { useRapier } from "@react-three/rapier";
|
|
14
|
-
import { useContext, useEffect } from "react";
|
|
15
|
-
import { GaesupControllerContext } from "../controller/context";
|
|
16
|
-
import { useGaesupGltf } from "../hooks/useGaesupGltf";
|
|
17
|
-
import { V3 } from "../utils";
|
|
18
|
-
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context";
|
|
19
|
-
import airplaneCalculation from "./airplane";
|
|
20
|
-
import characterCalculation from "./character";
|
|
21
|
-
import check from "./check";
|
|
22
|
-
import vehicleCalculation from "./vehicle";
|
|
23
|
-
export default function calculation(prop) {
|
|
24
|
-
var world = useRapier().world;
|
|
25
|
-
var worldContext = useContext(GaesupWorldContext);
|
|
26
|
-
var controllerContext = useContext(GaesupControllerContext);
|
|
27
|
-
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
28
|
-
var mode = worldContext.mode, activeState = worldContext.activeState, block = worldContext.block;
|
|
29
|
-
var getSizesByUrls = useGaesupGltf().getSizesByUrls;
|
|
30
|
-
useEffect(function () {
|
|
31
|
-
var rigidBodyRef = prop.rigidBodyRef, innerGroupRef = prop.innerGroupRef;
|
|
32
|
-
if (rigidBodyRef.current && innerGroupRef.current) {
|
|
33
|
-
rigidBodyRef.current.lockRotations(false, true);
|
|
34
|
-
activeState.euler.set(0, 0, 0);
|
|
35
|
-
rigidBodyRef.current.setTranslation(activeState.position.clone().add(V3(0, 2, 0)), true);
|
|
36
|
-
}
|
|
37
|
-
}, [mode.type]);
|
|
38
|
-
useFrame(function (state, delta) {
|
|
39
|
-
var rigidBodyRef = prop.rigidBodyRef, outerGroupRef = prop.outerGroupRef, innerGroupRef = prop.innerGroupRef;
|
|
40
|
-
if (!rigidBodyRef ||
|
|
41
|
-
!rigidBodyRef.current ||
|
|
42
|
-
!outerGroupRef ||
|
|
43
|
-
!outerGroupRef.current ||
|
|
44
|
-
!innerGroupRef ||
|
|
45
|
-
!innerGroupRef.current)
|
|
46
|
-
return null;
|
|
47
|
-
if (block.control)
|
|
48
|
-
return null;
|
|
49
|
-
var calcProp = __assign(__assign({}, prop), { state: state, delta: delta, worldContext: worldContext, controllerContext: controllerContext, dispatch: dispatch, world: world, matchSizes: getSizesByUrls(controllerContext === null || controllerContext === void 0 ? void 0 : controllerContext.urls) });
|
|
50
|
-
if (mode.type === "vehicle")
|
|
51
|
-
vehicleCalculation(calcProp);
|
|
52
|
-
else if (mode.type === "character")
|
|
53
|
-
characterCalculation(calcProp);
|
|
54
|
-
else if (mode.type === "airplane")
|
|
55
|
-
airplaneCalculation(calcProp);
|
|
56
|
-
check(calcProp);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { RootState } from "@react-three/fiber";
|
|
2
|
-
import { World } from "@dimforge/rapier3d-compat";
|
|
3
|
-
import { gaesupControllerType } from "../controller/context/type";
|
|
4
|
-
import { controllerInnerType, refsType } from "../controller/type";
|
|
5
|
-
import { dispatchType } from "../utils/type";
|
|
6
|
-
import { gaesupWorldContextType, urlsType } from "../world/context/type";
|
|
7
|
-
export type SetAtom<Args extends unknown[], Result> = (...args: Args) => Result;
|
|
8
|
-
export type hidratePropType = {
|
|
9
|
-
position: THREE.Vector3;
|
|
10
|
-
euler: THREE.Euler;
|
|
11
|
-
} & Partial<refsType>;
|
|
12
|
-
export type calcPropType = controllerInnerType & {
|
|
13
|
-
state?: RootState;
|
|
14
|
-
worldContext?: gaesupWorldContextType;
|
|
15
|
-
controllerContext?: gaesupControllerType;
|
|
16
|
-
matchSizes?: {
|
|
17
|
-
[key in keyof urlsType]?: THREE.Vector3;
|
|
18
|
-
};
|
|
19
|
-
delta?: number;
|
|
20
|
-
dispatch?: dispatchType<gaesupWorldContextType>;
|
|
21
|
-
world: World;
|
|
22
|
-
};
|
|
23
|
-
export type intersectObjectMapType = {
|
|
24
|
-
[uuid: string]: THREE.Mesh;
|
|
25
|
-
};
|
|
26
|
-
export type cameraPropType = controllerInnerType & {
|
|
27
|
-
control: {
|
|
28
|
-
[key: string]: boolean;
|
|
29
|
-
};
|
|
30
|
-
state?: RootState;
|
|
31
|
-
worldContext?: gaesupWorldContextType;
|
|
32
|
-
controllerContext?: gaesupControllerType;
|
|
33
|
-
intersectObjectMap?: intersectObjectMapType;
|
|
34
|
-
delta?: number;
|
|
35
|
-
dist?: number;
|
|
36
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export default function damping(prop) {
|
|
2
|
-
var rigidBodyRef = prop.rigidBodyRef, control = prop.worldContext.control, vehicle = prop.controllerContext.vehicle;
|
|
3
|
-
var space = control.space;
|
|
4
|
-
var brakeRatio = vehicle.brakeRatio, linearDamping = vehicle.linearDamping;
|
|
5
|
-
rigidBodyRef.current.setLinearDamping(space ? brakeRatio : linearDamping);
|
|
6
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { vec3 } from "@react-three/rapier";
|
|
2
|
-
import { V3 } from "../../utils/vector";
|
|
3
|
-
export function joystick(prop) {
|
|
4
|
-
var state = prop.state, _a = prop.worldContext, activeState = _a.activeState, joystick = _a.joystick;
|
|
5
|
-
var zAxis = joystick.joyStickOrigin.isOn ? 1 : 0;
|
|
6
|
-
var front = vec3().set(zAxis, 0, zAxis);
|
|
7
|
-
if (joystick.joyStickOrigin.isCenter)
|
|
8
|
-
return front;
|
|
9
|
-
activeState.euler.y = Math.PI / 2 - joystick.joyStickOrigin.angle;
|
|
10
|
-
return front;
|
|
11
|
-
}
|
|
12
|
-
export function normal(prop) {
|
|
13
|
-
var _a = prop.worldContext, activeState = _a.activeState, control = _a.control;
|
|
14
|
-
var forward = control.forward, backward = control.backward, leftward = control.leftward, rightward = control.rightward;
|
|
15
|
-
var xAxis = Number(leftward) - Number(rightward);
|
|
16
|
-
var zAxis = Number(forward) - Number(backward);
|
|
17
|
-
var front = vec3().set(zAxis, 0, zAxis);
|
|
18
|
-
activeState.euler.y += xAxis * (Math.PI / 64);
|
|
19
|
-
return front;
|
|
20
|
-
}
|
|
21
|
-
export default function direction(prop) {
|
|
22
|
-
var _a = prop.worldContext, mode = _a.mode, activeState = _a.activeState;
|
|
23
|
-
var front = vec3();
|
|
24
|
-
if (mode.controller === "joystick")
|
|
25
|
-
front.copy(joystick(prop));
|
|
26
|
-
else
|
|
27
|
-
front.copy(normal(prop));
|
|
28
|
-
activeState.direction = front.multiply(V3(Math.sin(activeState.euler.y), 0, Math.cos(activeState.euler.y)));
|
|
29
|
-
activeState.dir = activeState.direction.normalize();
|
|
30
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { calcPropType } from "../type";
|
|
2
|
-
/**
|
|
3
|
-
* This function applies an impulse to a rigid body in the game world.
|
|
4
|
-
*
|
|
5
|
-
* @param {calcPropType} prop - An object containing properties necessary for applying the impulse.
|
|
6
|
-
* @param {object} prop.rigidBodyRef - A reference to the rigid body to which the impulse is applied.
|
|
7
|
-
* @param {object} prop.worldContext - An object representing the current state of the game world.
|
|
8
|
-
* @param {object} prop.controllerContext - An object containing controller-specific context data.
|
|
9
|
-
* @param {object} prop.controllerContext.vehicle - An object representing the vehicle controller context.
|
|
10
|
-
* @param {number} prop.controllerContext.vehicle.maxSpeed - The maximum speed of the vehicle.
|
|
11
|
-
*
|
|
12
|
-
* This function calculates the current speed of the rigid body and compares it to the maximum speed.
|
|
13
|
-
* If the current speed is greater than the maximum speed, no impulse is applied.
|
|
14
|
-
* Otherwise, an impulse is applied to the rigid body in the direction specified by `activeState.dir.
|
|
15
|
-
*/
|
|
16
|
-
export default function impulse(prop: calcPropType): void;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { vec3 } from "@react-three/rapier";
|
|
2
|
-
/**
|
|
3
|
-
* This function applies an impulse to a rigid body in the game world.
|
|
4
|
-
*
|
|
5
|
-
* @param {calcPropType} prop - An object containing properties necessary for applying the impulse.
|
|
6
|
-
* @param {object} prop.rigidBodyRef - A reference to the rigid body to which the impulse is applied.
|
|
7
|
-
* @param {object} prop.worldContext - An object representing the current state of the game world.
|
|
8
|
-
* @param {object} prop.controllerContext - An object containing controller-specific context data.
|
|
9
|
-
* @param {object} prop.controllerContext.vehicle - An object representing the vehicle controller context.
|
|
10
|
-
* @param {number} prop.controllerContext.vehicle.maxSpeed - The maximum speed of the vehicle.
|
|
11
|
-
*
|
|
12
|
-
* This function calculates the current speed of the rigid body and compares it to the maximum speed.
|
|
13
|
-
* If the current speed is greater than the maximum speed, no impulse is applied.
|
|
14
|
-
* Otherwise, an impulse is applied to the rigid body in the direction specified by `activeState.dir.
|
|
15
|
-
*/
|
|
16
|
-
export default function impulse(prop) {
|
|
17
|
-
var rigidBodyRef = prop.rigidBodyRef, _a = prop.worldContext, activeState = _a.activeState, control = _a.control, mode = _a.mode, joystick = _a.joystick, vehicle = prop.controllerContext.vehicle;
|
|
18
|
-
var shift = control.shift;
|
|
19
|
-
var maxSpeed = vehicle.maxSpeed, accelRatio = vehicle.accelRatio;
|
|
20
|
-
var velocity = rigidBodyRef.current.linvel();
|
|
21
|
-
// const V = vec3(velocity).length();
|
|
22
|
-
// a = v / t (t = 1) (approximate calculation)
|
|
23
|
-
var V = vec3(velocity).length();
|
|
24
|
-
if (V < maxSpeed) {
|
|
25
|
-
var M = rigidBodyRef.current.mass();
|
|
26
|
-
var speed = 1;
|
|
27
|
-
if (mode.controller === "joystick") {
|
|
28
|
-
if (!joystick.joyStickOrigin.isCenter)
|
|
29
|
-
speed = joystick.joyStickOrigin.isIn ? accelRatio : 1;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
speed = shift ? accelRatio : 1;
|
|
33
|
-
}
|
|
34
|
-
// impulse = mass * velocity
|
|
35
|
-
rigidBodyRef.current.applyImpulse(vec3()
|
|
36
|
-
.addScalar(speed)
|
|
37
|
-
.multiply(activeState.dir.clone().normalize())
|
|
38
|
-
.multiplyScalar(M), false);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import damping from "./damping";
|
|
2
|
-
import direction from "./direction";
|
|
3
|
-
import impulse from "./impulse";
|
|
4
|
-
import innerCalc from "./innerCalc";
|
|
5
|
-
import landing from "./landing";
|
|
6
|
-
export default function vehicleCalculation(calcProp) {
|
|
7
|
-
direction(calcProp);
|
|
8
|
-
impulse(calcProp);
|
|
9
|
-
damping(calcProp);
|
|
10
|
-
landing(calcProp);
|
|
11
|
-
innerCalc(calcProp);
|
|
12
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { quat, vec3 } from "@react-three/rapier";
|
|
13
|
-
export default function innerCalc(prop) {
|
|
14
|
-
var rigidBodyRef = prop.rigidBodyRef, activeState = prop.worldContext.activeState, dispatch = prop.dispatch;
|
|
15
|
-
activeState.position = vec3(rigidBodyRef.current.translation());
|
|
16
|
-
activeState.velocity = vec3(rigidBodyRef.current.linvel());
|
|
17
|
-
rigidBodyRef.current.setRotation(quat().setFromEuler(activeState.euler.clone()), false);
|
|
18
|
-
dispatch({
|
|
19
|
-
type: "update",
|
|
20
|
-
payload: {
|
|
21
|
-
activeState: __assign({}, activeState),
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
export default function landing(prop) {
|
|
13
|
-
var _a = prop.worldContext, states = _a.states, rideable = _a.rideable, mode = _a.mode, dispatch = prop.dispatch;
|
|
14
|
-
var isLanding = states.isLanding;
|
|
15
|
-
if (isLanding) {
|
|
16
|
-
rideable.objectType = null;
|
|
17
|
-
rideable.key = null;
|
|
18
|
-
mode.type = "character";
|
|
19
|
-
states.isLanding = false;
|
|
20
|
-
states.enableRiding = false;
|
|
21
|
-
}
|
|
22
|
-
dispatch({
|
|
23
|
-
type: "update",
|
|
24
|
-
payload: {
|
|
25
|
-
mode: __assign({}, mode),
|
|
26
|
-
rideable: __assign({}, rideable),
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CSSProperties } from "react";
|
|
2
|
-
import "./style.css";
|
|
3
|
-
export type gameBoyButtonType = {
|
|
4
|
-
tag: "up" | "down" | "left" | "right";
|
|
5
|
-
value: string;
|
|
6
|
-
icon: JSX.Element;
|
|
7
|
-
gameboyButtonStyle: CSSProperties;
|
|
8
|
-
};
|
|
9
|
-
export default function GameBoyButton({ tag, value, icon, gameboyButtonStyle, }: gameBoyButtonType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { usePushKey } from "../../hooks/usePushKey";
|
|
3
|
-
import "./style.css";
|
|
4
|
-
export default function GameBoyButton(_a) {
|
|
5
|
-
var tag = _a.tag, value = _a.value, icon = _a.icon, gameboyButtonStyle = _a.gameboyButtonStyle;
|
|
6
|
-
var pushKey = usePushKey().pushKey;
|
|
7
|
-
var onMouseDown = function () {
|
|
8
|
-
pushKey(value, true);
|
|
9
|
-
};
|
|
10
|
-
var onMouseLeave = function () {
|
|
11
|
-
pushKey(value, false);
|
|
12
|
-
};
|
|
13
|
-
return (_jsx("button", { className: "gameboy-button ".concat(tag), onMouseDown: function () { return onMouseDown(); }, onMouseUp: function () { return onMouseLeave(); }, onMouseLeave: function () { return onMouseLeave(); }, onContextMenu: function (e) {
|
|
14
|
-
e.preventDefault();
|
|
15
|
-
}, onPointerDown: function () { return onMouseDown(); }, onPointerUp: function () { return onMouseLeave(); }, style: gameboyButtonStyle, children: icon }));
|
|
16
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import "./style.css";
|
|
2
|
-
import { gameboyType } from "./type";
|
|
3
|
-
export declare const GameBoyDirections: {
|
|
4
|
-
tag: string;
|
|
5
|
-
value: string;
|
|
6
|
-
icon: import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
}[];
|
|
8
|
-
export declare function GameBoy(props: gameboyType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { GaesupWorldContext } from "../../world/context";
|
|
4
|
-
import GameBoyButton from "./GameBoyButton";
|
|
5
|
-
import "./style.css";
|
|
6
|
-
export var GameBoyDirections = [
|
|
7
|
-
{
|
|
8
|
-
tag: "up",
|
|
9
|
-
value: "forward",
|
|
10
|
-
icon: _jsx(_Fragment, {}),
|
|
11
|
-
},
|
|
12
|
-
{ tag: "down", value: "backward", icon: _jsx(_Fragment, {}) },
|
|
13
|
-
{ tag: "left", value: "leftward", icon: _jsx(_Fragment, {}) },
|
|
14
|
-
{ tag: "right", value: "rightward", icon: _jsx(_Fragment, {}) },
|
|
15
|
-
];
|
|
16
|
-
export function GameBoy(props) {
|
|
17
|
-
var mode = useContext(GaesupWorldContext).mode;
|
|
18
|
-
var gameboyStyle = props.gameboyStyle, gameboyButtonStyle = props.gameboyButtonStyle;
|
|
19
|
-
return (_jsx(_Fragment, { children: mode.controller === "gameboy" && (_jsx("div", { className: "gameboy", style: gameboyStyle, children: GameBoyDirections.map(function (item, key) {
|
|
20
|
-
return (_jsx(GameBoyButton, { tag: item.tag, value: item.value, icon: item.icon, gameboyButtonStyle: gameboyButtonStyle }, key));
|
|
21
|
-
}) })) }));
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CSSProperties } from "react";
|
|
2
|
-
import "./style.css";
|
|
3
|
-
export type gamePadButtonType = {
|
|
4
|
-
value: string;
|
|
5
|
-
name: string;
|
|
6
|
-
gamePadButtonStyle: CSSProperties;
|
|
7
|
-
};
|
|
8
|
-
export default function GamePadButton({ value, name, gamePadButtonStyle, }: gamePadButtonType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { usePushKey } from "../../hooks/usePushKey";
|
|
4
|
-
import "./style.css";
|
|
5
|
-
export default function GamePadButton(_a) {
|
|
6
|
-
var value = _a.value, name = _a.name, gamePadButtonStyle = _a.gamePadButtonStyle;
|
|
7
|
-
var _b = useState(false), isClicked = _b[0], setIsClicked = _b[1];
|
|
8
|
-
var pushKey = usePushKey().pushKey;
|
|
9
|
-
var onMouseDown = function () {
|
|
10
|
-
pushKey(value, true);
|
|
11
|
-
setIsClicked(true);
|
|
12
|
-
};
|
|
13
|
-
var onMouseLeave = function () {
|
|
14
|
-
pushKey(value, false);
|
|
15
|
-
setIsClicked(false);
|
|
16
|
-
};
|
|
17
|
-
return (_jsx("button", { className: "padButton ".concat(isClicked ? "isClicked" : ""), onMouseDown: function () { return onMouseDown(); }, onMouseUp: function () { return onMouseLeave(); }, onMouseLeave: function () { return onMouseLeave(); }, onContextMenu: function (e) {
|
|
18
|
-
e.preventDefault();
|
|
19
|
-
onMouseLeave();
|
|
20
|
-
}, onPointerDown: function () { return onMouseDown(); }, onPointerUp: function () { return onMouseLeave(); }, style: gamePadButtonStyle, children: name }));
|
|
21
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { GaesupWorldContext } from "../../world/context";
|
|
4
|
-
import GamePadButton from "./GamePadButton";
|
|
5
|
-
import "./style.css";
|
|
6
|
-
export var gamepadDefault = {
|
|
7
|
-
on: true,
|
|
8
|
-
};
|
|
9
|
-
export function GamePad(props) {
|
|
10
|
-
var gamePadStyle = props.gamePadStyle, gamePadButtonStyle = props.gamePadButtonStyle, label = props.label;
|
|
11
|
-
var _a = useContext(GaesupWorldContext), control = _a.control, mode = _a.mode;
|
|
12
|
-
var GamePadDirections = Object.keys(control)
|
|
13
|
-
.map(function (key) {
|
|
14
|
-
var name = (label === null || label === void 0 ? void 0 : label[key]) || key;
|
|
15
|
-
if (key !== "forward" &&
|
|
16
|
-
key !== "backward" &&
|
|
17
|
-
key !== "leftward" &&
|
|
18
|
-
key !== "rightward")
|
|
19
|
-
return {
|
|
20
|
-
tag: key,
|
|
21
|
-
value: key,
|
|
22
|
-
name: name,
|
|
23
|
-
};
|
|
24
|
-
})
|
|
25
|
-
.filter(function (item) { return item !== undefined; })
|
|
26
|
-
.filter(function (item) {
|
|
27
|
-
return !(item.tag === "run" && mode.controller === "joystick");
|
|
28
|
-
});
|
|
29
|
-
return (_jsx(_Fragment, { children: (mode.controller === "joystick" || mode.controller === "gameboy") && (_jsx("div", { className: "gamePad", style: gamePadStyle, children: GamePadDirections.map(function (item, key) {
|
|
30
|
-
return (_jsx(GamePadButton, { value: item.value, name: item.name, gamePadButtonStyle: gamePadButtonStyle }, key));
|
|
31
|
-
}) })) }));
|
|
32
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|