gaesup-world 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +308 -247
- package/dist/gaesup/camera/control/normal.d.ts +2 -0
- package/dist/gaesup/camera/control/normal.js +8 -1
- package/dist/gaesup/camera/control/orbit.d.ts +1 -1
- package/dist/gaesup/camera/control/orbit.js +3 -2
- package/dist/gaesup/camera/index.js +14 -1
- package/dist/gaesup/component/active/vehicle/wheels.js +4 -2
- package/dist/gaesup/component/passive/airplane/index.js +5 -3
- package/dist/gaesup/physics/airplane/direction.js +1 -1
- package/dist/gaesup/physics/airplane/gravity.d.ts +12 -0
- package/dist/gaesup/physics/airplane/gravity.js +16 -10
- package/dist/gaesup/physics/airplane/impulse.d.ts +15 -1
- package/dist/gaesup/physics/airplane/impulse.js +24 -8
- package/dist/gaesup/physics/index.js +3 -2
- package/dist/gaesup/physics/vehicle/impulse.d.ts +15 -1
- package/dist/gaesup/physics/vehicle/impulse.js +35 -12
- package/dist/gaesup/tools/gamePad/GamePadButton.d.ts +3 -2
- package/dist/gaesup/tools/joyStick/index.d.ts +4 -1
- package/dist/gaesup/tools/joyStick/type.d.ts +0 -4
- package/dist/gaesup/tools/jumpPortal/index.d.ts +15 -2
- package/dist/gaesup/tools/jumpPortal/index.js +10 -2
- package/dist/gaesup/tools/miniMap/index.js +1 -1
- package/dist/gaesup/tools/zoomButton/index.d.ts +1 -0
- package/dist/gaesup/tools/zoomButton/index.js +25 -4
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/package.json +1 -1
- package/dist/gaesup/hooks/index.d.ts +0 -1
- package/dist/gaesup/hooks/index.js +0 -1
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { cameraPropType } from "../../physics/type";
|
|
2
|
+
import { activeStateType, cameraOptionType } from "../../world/context/type";
|
|
3
|
+
export declare const makeNormalCameraPosition: (activeState: activeStateType, cameraOption: cameraOptionType) => import("three").Vector3;
|
|
2
4
|
export default function normal(prop: cameraPropType): void;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { V3 } from "../../utils/vector";
|
|
2
|
+
export var makeNormalCameraPosition = function (activeState, cameraOption) {
|
|
3
|
+
var YDistance = cameraOption.YDistance, ZDistance = cameraOption.ZDistance;
|
|
4
|
+
var cameraPosition = activeState.position
|
|
5
|
+
.clone()
|
|
6
|
+
.add(V3(0, YDistance, ZDistance));
|
|
7
|
+
return cameraPosition;
|
|
8
|
+
};
|
|
2
9
|
export default function normal(prop) {
|
|
3
10
|
var state = prop.state, _a = prop.worldContext, activeState = _a.activeState, cameraOption = _a.cameraOption;
|
|
4
11
|
if (!state || !state.camera)
|
|
5
12
|
return;
|
|
6
13
|
var cameraPosition = activeState.position
|
|
7
14
|
.clone()
|
|
8
|
-
.add(V3(0, cameraOption.YDistance, cameraOption.
|
|
15
|
+
.add(V3(0, cameraOption.YDistance, cameraOption.ZDistance));
|
|
9
16
|
state.camera.position.lerp(cameraPosition, 1);
|
|
10
17
|
state.camera.lookAt(activeState.position.clone());
|
|
11
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { cameraPropType } from "../../physics/type";
|
|
2
2
|
import { activeStateType, cameraOptionType } from "../../world/context/type";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const makeOrbitCameraPosition: (activeState: activeStateType, cameraOption: cameraOptionType) => import("three").Vector3;
|
|
4
4
|
export default function orbit(prop: cameraPropType): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { quat } from "@react-three/rapier";
|
|
2
2
|
import { V3 } from "../../utils/vector";
|
|
3
|
-
export var
|
|
3
|
+
export var makeOrbitCameraPosition = function (activeState, cameraOption) {
|
|
4
4
|
var XDistance = cameraOption.XDistance, YDistance = cameraOption.YDistance, ZDistance = cameraOption.ZDistance;
|
|
5
5
|
var cameraPosition = activeState.position.clone().add(V3(Math.sin(activeState.euler.y), 1, Math.cos(activeState.euler.y))
|
|
6
6
|
.normalize()
|
|
@@ -12,10 +12,11 @@ export default function orbit(prop) {
|
|
|
12
12
|
var state = prop.state, _a = prop.worldContext, activeState = _a.activeState, cameraOption = _a.cameraOption;
|
|
13
13
|
if (!state || !state.camera)
|
|
14
14
|
return;
|
|
15
|
-
var cameraPosition =
|
|
15
|
+
var cameraPosition = makeOrbitCameraPosition(activeState, cameraOption);
|
|
16
16
|
state.camera.position.lerp(cameraPosition, 1);
|
|
17
17
|
state.camera.quaternion.copy(activeState.quat
|
|
18
18
|
.clone()
|
|
19
19
|
.multiply(quat().setFromAxisAngle(V3(0, 1, 0), Math.PI)));
|
|
20
|
+
state.camera.rotation.copy(activeState.euler);
|
|
20
21
|
state.camera.lookAt(activeState.position.clone());
|
|
21
22
|
}
|
|
@@ -112,13 +112,26 @@ export default function Camera(_a) {
|
|
|
112
112
|
switch (_a.label) {
|
|
113
113
|
case 0:
|
|
114
114
|
camera.position.copy(position);
|
|
115
|
+
if (!(mode.control === "orbit")) return [3 /*break*/, 2];
|
|
115
116
|
return [4 /*yield*/, Promise.all([
|
|
116
117
|
cameraRef.current.setPosition(position.x, position.y, position.z, true),
|
|
118
|
+
camera.rotation.copy(worldContext.activeState.euler),
|
|
117
119
|
cameraRef.current.setLookAt(position.x, position.y, position.z, target.x, target.y, target.z, true),
|
|
118
120
|
])];
|
|
119
121
|
case 1:
|
|
120
122
|
_a.sent();
|
|
121
|
-
return [
|
|
123
|
+
return [3 /*break*/, 4];
|
|
124
|
+
case 2:
|
|
125
|
+
if (!(mode.control === "normal")) return [3 /*break*/, 4];
|
|
126
|
+
return [4 /*yield*/, Promise.all([
|
|
127
|
+
cameraRef.current.setPosition(0, position.y, position.z, true),
|
|
128
|
+
camera.rotation.copy(worldContext.activeState.euler),
|
|
129
|
+
cameraRef.current.setLookAt(0, position.y, position.z, target.x, target.y, target.z, true),
|
|
130
|
+
])];
|
|
131
|
+
case 3:
|
|
132
|
+
_a.sent();
|
|
133
|
+
_a.label = 4;
|
|
134
|
+
case 4: return [2 /*return*/];
|
|
122
135
|
}
|
|
123
136
|
});
|
|
124
137
|
}); };
|
|
@@ -5,7 +5,7 @@ import { WheelRegidBodyRef } from "./wheel";
|
|
|
5
5
|
export function Wheels(_a) {
|
|
6
6
|
var props = _a.props;
|
|
7
7
|
var rigidBodyRef = props.rigidBodyRef;
|
|
8
|
-
var
|
|
8
|
+
var _b = useContext(GaesupWorldContext), collider = _b.vehicleCollider, activeState = _b.activeState;
|
|
9
9
|
var vehicleSizeX = collider.vehicleSizeX, vehicleSizeZ = collider.vehicleSizeZ, wheelSizeX = collider.wheelSizeX, wheelSizeZ = collider.wheelSizeZ;
|
|
10
10
|
var X = (vehicleSizeX - wheelSizeX) / 2 + 0.5;
|
|
11
11
|
var Z = (vehicleSizeZ - 2 * wheelSizeZ) / 2 + 0.5;
|
|
@@ -16,5 +16,7 @@ export function Wheels(_a) {
|
|
|
16
16
|
[X, 0, -Z],
|
|
17
17
|
];
|
|
18
18
|
var wheelRefs = useRef(wheelPositions.map(function () { return createRef(); }));
|
|
19
|
-
return (_jsx(_Fragment, { children: wheelPositions.map(function (wheelPosition, index) {
|
|
19
|
+
return (_jsx(_Fragment, { children: wheelPositions.map(function (wheelPosition, index) {
|
|
20
|
+
return (_jsx(WheelRegidBodyRef, { index: index, ref: wheelRefs.current[index], wheelPosition: wheelPosition, bodyRef: rigidBodyRef, wheel: wheelRefs.current[index], bodyAnchor: wheelPosition, wheelAnchor: [0, 0, 0], rotationAxis: [1, 0, 0] }, index));
|
|
21
|
+
}) }));
|
|
20
22
|
}
|
|
@@ -33,9 +33,11 @@ export function PassiveAirplane(props) {
|
|
|
33
33
|
.setFromEuler(innerGroupRef.current.rotation.clone())
|
|
34
34
|
.slerp(quat().setFromEuler(_euler), 0.2));
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
if (rigidBodyRef && rigidBodyRef.current) {
|
|
37
|
+
rigidBodyRef.current.setGravityScale(props.position.y < 10
|
|
38
|
+
? ((1 - 0.1) / (0 - 10)) * props.position.y + 1
|
|
39
|
+
: 0.1, false);
|
|
40
|
+
}
|
|
39
41
|
});
|
|
40
42
|
return (_jsxs(OuterGroupRef, { ref: refs.outerGroupRef, children: [props.children, airplaneUrl && (_jsxs(RigidBodyRef, { ref: refs.rigidBodyRef, position: position, rotation: euler, onCollisionEnter: props.onCollisionEnter, children: [_jsx(InnerGroupRef, { currentAnimation: currentAnimation, ref: refs.innerGroupRef, url: airplaneUrl }), _jsx(CuboidCollider, { ref: colliderRef, args: [airplaneSize.x / 2, airplaneSize.y / 2, airplaneSize.z / 2], position: [0, airplaneSize.y / 2, 0] })] }))] }));
|
|
41
43
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { quat } from "@react-three/rapier";
|
|
2
2
|
import { V3 } from "../../utils/vector";
|
|
3
3
|
export default function direction(prop) {
|
|
4
|
-
var
|
|
4
|
+
var innerGroupRef = prop.innerGroupRef, _a = prop.worldContext, joystick = _a.joystick, activeState = _a.activeState, control = _a.control, mode = _a.mode, airplane = prop.controllerContext.airplane;
|
|
5
5
|
var forward = control.forward, backward = control.backward, leftward = control.leftward, rightward = control.rightward, shift = control.shift, space = control.space;
|
|
6
6
|
var angleDelta = airplane.angleDelta, maxAngle = airplane.maxAngle, accelRatio = airplane.accelRatio;
|
|
7
7
|
var boost = 0;
|
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
import { calcPropType } from "../type";
|
|
2
|
+
/**
|
|
3
|
+
* This function calculates and sets gravity.
|
|
4
|
+
*
|
|
5
|
+
* @param {calcPropType} prop - An object containing properties necessary for gravity calculation.
|
|
6
|
+
* @param {object} prop.rigidBodyRef - A reference to the physical object where gravity is being set.
|
|
7
|
+
* @param {object} prop.worldContext - An object representing the current state of the game world.
|
|
8
|
+
* @param {number} prop.worldContext.activeState.position.y - The current Y-coordinate position.
|
|
9
|
+
*
|
|
10
|
+
* Gravity is calculated based on altitude and buoyancy. When altitude is less than 10, gravity is calculated as follows:
|
|
11
|
+
* Gravity = ((1 - buoyancy) / (0 - 10)) * current Y-coordinate + buoyancy
|
|
12
|
+
* Otherwise, gravity is set to 0.1.
|
|
13
|
+
*/
|
|
2
14
|
export default function gravity(prop: calcPropType): void;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function calculates and sets gravity.
|
|
3
|
+
*
|
|
4
|
+
* @param {calcPropType} prop - An object containing properties necessary for gravity calculation.
|
|
5
|
+
* @param {object} prop.rigidBodyRef - A reference to the physical object where gravity is being set.
|
|
6
|
+
* @param {object} prop.worldContext - An object representing the current state of the game world.
|
|
7
|
+
* @param {number} prop.worldContext.activeState.position.y - The current Y-coordinate position.
|
|
8
|
+
*
|
|
9
|
+
* Gravity is calculated based on altitude and buoyancy. When altitude is less than 10, gravity is calculated as follows:
|
|
10
|
+
* Gravity = ((1 - buoyancy) / (0 - 10)) * current Y-coordinate + buoyancy
|
|
11
|
+
* Otherwise, gravity is set to 0.1.
|
|
12
|
+
*/
|
|
1
13
|
export default function gravity(prop) {
|
|
2
|
-
var rigidBodyRef = prop.rigidBodyRef,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
rigidBodyRef.current.setGravityScale(airplaneCollider.gravity, false);
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
airplaneCollider.gravity = buoyancy;
|
|
10
|
-
rigidBodyRef.current.setGravityScale(airplaneCollider.gravity, false);
|
|
11
|
-
}
|
|
14
|
+
var rigidBodyRef = prop.rigidBodyRef, activeState = prop.worldContext.activeState;
|
|
15
|
+
rigidBodyRef.current.setGravityScale(activeState.position.y < 10
|
|
16
|
+
? ((1 - 0.1) / (0 - 10)) * activeState.position.y + 1
|
|
17
|
+
: 0.1, false);
|
|
12
18
|
}
|
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
import { calcPropType } from "../type";
|
|
2
|
-
|
|
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.airplane - An object representing the airplane controller context.
|
|
10
|
+
* @param {number} prop.controllerContext.airplane.maxSpeed - The maximum speed of the airplane.
|
|
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.direction`.
|
|
15
|
+
*/
|
|
16
|
+
export default function impulse(prop: calcPropType): void;
|
|
@@ -1,15 +1,31 @@
|
|
|
1
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.airplane - An object representing the airplane controller context.
|
|
10
|
+
* @param {number} prop.controllerContext.airplane.maxSpeed - The maximum speed of the airplane.
|
|
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.direction`.
|
|
15
|
+
*/
|
|
2
16
|
export default function impulse(prop) {
|
|
3
17
|
var rigidBodyRef = prop.rigidBodyRef, activeState = prop.worldContext.activeState, airplane = prop.controllerContext.airplane;
|
|
4
18
|
var maxSpeed = airplane.maxSpeed;
|
|
5
19
|
var velocity = rigidBodyRef.current.linvel();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
20
|
+
// a = v / t (t = 1) (approximate calculation)
|
|
21
|
+
var V = vec3(velocity).length();
|
|
22
|
+
if (V < maxSpeed) {
|
|
23
|
+
var M = rigidBodyRef.current.mass();
|
|
24
|
+
// impulse = mass * velocity
|
|
25
|
+
rigidBodyRef.current.applyImpulse(vec3({
|
|
26
|
+
x: activeState.direction.x,
|
|
27
|
+
y: activeState.direction.y,
|
|
28
|
+
z: activeState.direction.z,
|
|
29
|
+
}).multiplyScalar(M), false);
|
|
9
30
|
}
|
|
10
|
-
rigidBodyRef.current.applyImpulse(vec3({
|
|
11
|
-
x: activeState.direction.x,
|
|
12
|
-
y: activeState.direction.y,
|
|
13
|
-
z: activeState.direction.z,
|
|
14
|
-
}), false);
|
|
15
31
|
}
|
|
@@ -26,9 +26,10 @@ export default function calculation(prop) {
|
|
|
26
26
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
27
27
|
var mode = worldContext.mode, activeState = worldContext.activeState, controlBlock = worldContext.controlBlock;
|
|
28
28
|
useEffect(function () {
|
|
29
|
-
var rigidBodyRef = prop.rigidBodyRef;
|
|
30
|
-
if (rigidBodyRef.current) {
|
|
29
|
+
var rigidBodyRef = prop.rigidBodyRef, innerGroupRef = prop.innerGroupRef;
|
|
30
|
+
if (rigidBodyRef.current && innerGroupRef.current) {
|
|
31
31
|
rigidBodyRef.current.lockRotations(true, true);
|
|
32
|
+
activeState.euler.set(0, 0, 0);
|
|
32
33
|
rigidBodyRef.current.setTranslation(activeState.position.clone().add(V3(0, 2, 0)), true);
|
|
33
34
|
}
|
|
34
35
|
}, [mode.type]);
|
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
import { calcPropType } from "../type";
|
|
2
|
-
|
|
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,20 +1,43 @@
|
|
|
1
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
|
+
*/
|
|
2
16
|
export default function impulse(prop) {
|
|
3
17
|
var rigidBodyRef = prop.rigidBodyRef, _a = prop.worldContext, activeState = _a.activeState, control = _a.control, mode = _a.mode, joystick = _a.joystick, vehicle = prop.controllerContext.vehicle;
|
|
4
18
|
var shift = control.shift;
|
|
5
19
|
var maxSpeed = vehicle.maxSpeed, accelRatio = vehicle.accelRatio;
|
|
6
20
|
var velocity = rigidBodyRef.current.linvel();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
21
|
+
// const V = vec3(velocity).length();
|
|
22
|
+
// const currentSpeed = Math.sqrt(
|
|
23
|
+
// velocity.x ** 2 + velocity.y ** 2 + velocity.z ** 2
|
|
24
|
+
// );
|
|
25
|
+
// a = v / t (t = 1) (approximate calculation)
|
|
26
|
+
var V = vec3(velocity).length();
|
|
27
|
+
if (V < maxSpeed) {
|
|
28
|
+
var M = rigidBodyRef.current.mass();
|
|
29
|
+
var speed = 1;
|
|
30
|
+
if (mode.controller === "joystick") {
|
|
31
|
+
if (!joystick.joyStickOrigin.isCenter)
|
|
32
|
+
speed = joystick.joyStickOrigin.isIn ? accelRatio : 1;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
speed = shift ? accelRatio : 1;
|
|
36
|
+
}
|
|
37
|
+
// impulse = mass * velocity
|
|
38
|
+
rigidBodyRef.current.applyImpulse(vec3()
|
|
39
|
+
.addScalar(speed)
|
|
40
|
+
.multiply(activeState.dir.clone().normalize())
|
|
41
|
+
.multiplyScalar(M), false);
|
|
10
42
|
}
|
|
11
|
-
var speed = 1;
|
|
12
|
-
if (mode.controller === "joystick") {
|
|
13
|
-
if (!joystick.joyStickOrigin.isCenter)
|
|
14
|
-
speed = joystick.joyStickOrigin.isIn ? accelRatio : 1;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
speed = shift ? accelRatio : 1;
|
|
18
|
-
}
|
|
19
|
-
rigidBodyRef.current.applyImpulse(vec3().addScalar(speed).multiply(activeState.dir.clone().normalize()), false);
|
|
20
43
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
2
|
import "./style.css";
|
|
3
|
-
export
|
|
3
|
+
export type gamePadButtonType = {
|
|
4
4
|
value: string;
|
|
5
5
|
name: string;
|
|
6
6
|
gamePadButtonStyle: CSSProperties;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export default function GamePadButton({ value, name, gamePadButtonStyle, }: gamePadButtonType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
1
2
|
import "./style.css";
|
|
2
|
-
|
|
3
|
+
export type joyStickType = {
|
|
4
|
+
[key in "joyStickBallStyle" | "joyStickStyle"]?: CSSProperties;
|
|
5
|
+
};
|
|
3
6
|
export declare function JoyStick(props: joyStickType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CSSProperties } from "react";
|
|
2
1
|
export type joyStickBallType = {
|
|
3
2
|
left: string;
|
|
4
3
|
top: string;
|
|
@@ -18,6 +17,3 @@ export type joyStickInnerType = {
|
|
|
18
17
|
joyStickBall?: joyStickBallType;
|
|
19
18
|
joyStickOrigin?: joyStickOriginType;
|
|
20
19
|
};
|
|
21
|
-
export type joyStickType = {
|
|
22
|
-
[key in "joyStickBallStyle" | "joyStickStyle" | "joyBallStyle"]?: CSSProperties;
|
|
23
|
-
};
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
2
|
import "./style.css";
|
|
3
|
-
export
|
|
3
|
+
export type JumpPortalType = {
|
|
4
|
+
text?: string;
|
|
5
|
+
position: THREE.Vector3;
|
|
6
|
+
jumpPortalStyle?: CSSProperties;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* JumpPortal component represents a clickable portal that teleports the user to a specified location.
|
|
10
|
+
*
|
|
11
|
+
* @param {JumpPortalType} props - The props for the JumpPortal component.
|
|
12
|
+
* @param {string} props.text - (Optional) The text to display on the portal.
|
|
13
|
+
* @param {THREE.Vector3} props.position - The target position to teleport to.
|
|
14
|
+
* @param {CSSProperties} props.jumpPortalStyle - (Optional) CSS styles for the JumpPortal component.
|
|
15
|
+
*/
|
|
16
|
+
export declare function JumpPortal({ text, position, jumpPortalStyle, }: JumpPortalType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useTeleport } from "../../hooks/useTeleport";
|
|
3
3
|
import "./style.css";
|
|
4
|
+
/**
|
|
5
|
+
* JumpPortal component represents a clickable portal that teleports the user to a specified location.
|
|
6
|
+
*
|
|
7
|
+
* @param {JumpPortalType} props - The props for the JumpPortal component.
|
|
8
|
+
* @param {string} props.text - (Optional) The text to display on the portal.
|
|
9
|
+
* @param {THREE.Vector3} props.position - The target position to teleport to.
|
|
10
|
+
* @param {CSSProperties} props.jumpPortalStyle - (Optional) CSS styles for the JumpPortal component.
|
|
11
|
+
*/
|
|
4
12
|
export function JumpPortal(_a) {
|
|
5
|
-
var text = _a.text, position = _a.position,
|
|
13
|
+
var text = _a.text, position = _a.position, jumpPortalStyle = _a.jumpPortalStyle;
|
|
6
14
|
var Teleport = useTeleport().Teleport;
|
|
7
15
|
return (_jsx("div", { className: "jumpPortal", onClick: function () {
|
|
8
16
|
Teleport(position);
|
|
9
|
-
}, style:
|
|
17
|
+
}, style: jumpPortalStyle, children: text }));
|
|
10
18
|
}
|
|
@@ -19,7 +19,7 @@ import "./style.css";
|
|
|
19
19
|
export function MiniMap(props) {
|
|
20
20
|
var _a = useContext(GaesupWorldContext), minimap = _a.minimap, activeState = _a.activeState, mode = _a.mode;
|
|
21
21
|
var _b = useState(props.scale || minimapDefault.scale), scale = _b[0], setscale = _b[1];
|
|
22
|
-
var
|
|
22
|
+
var innerStyle = props.innerStyle, textStyle = props.textStyle, objectStyle = props.objectStyle, avatarStyle = props.avatarStyle, scaleStyle = props.scaleStyle, directionStyle = props.directionStyle, plusMinusStyle = props.plusMinusStyle;
|
|
23
23
|
var upscale = useCallback(function () {
|
|
24
24
|
var max = props.maxScale || minimapDefault.maxScale;
|
|
25
25
|
setscale(function (scale) { return Math.min(max, scale + 0.1); });
|
|
@@ -13,5 +13,6 @@ export declare function useZoom(): {
|
|
|
13
13
|
closeCamera: (position: THREE.Vector3) => Promise<void>;
|
|
14
14
|
isZoom: boolean;
|
|
15
15
|
setIsZoom: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
16
|
+
moveToCamera: () => Promise<void>;
|
|
16
17
|
};
|
|
17
18
|
export declare function ZoomButton(props: zoomButtonPropsType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -47,12 +47,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
};
|
|
48
48
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
49
|
import { useContext, useState } from "react";
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
50
|
+
import { makeNormalCameraPosition } from "../../camera/control/normal";
|
|
51
|
+
import { makeOrbitCameraPosition } from "../../camera/control/orbit";
|
|
52
|
+
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context/index";
|
|
52
53
|
import "./style.css";
|
|
53
54
|
export function useZoom() {
|
|
54
55
|
var _this = this;
|
|
55
|
-
var _a = useContext(GaesupWorldContext), moveTo = _a.moveTo, activeState = _a.activeState, cameraOption = _a.cameraOption;
|
|
56
|
+
var _a = useContext(GaesupWorldContext), moveTo = _a.moveTo, activeState = _a.activeState, cameraOption = _a.cameraOption, mode = _a.mode;
|
|
56
57
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
57
58
|
var _b = useState(true), isZoom = _b[0], setIsZoom = _b[1];
|
|
58
59
|
var closeCamera = function (position) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -81,6 +82,25 @@ export function useZoom() {
|
|
|
81
82
|
return [2 /*return*/];
|
|
82
83
|
});
|
|
83
84
|
}); };
|
|
85
|
+
var moveToCamera = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0:
|
|
89
|
+
if (!(mode.control === "orbit" && moveTo)) return [3 /*break*/, 2];
|
|
90
|
+
return [4 /*yield*/, moveTo(makeOrbitCameraPosition(activeState, cameraOption), activeState.position)];
|
|
91
|
+
case 1:
|
|
92
|
+
_a.sent();
|
|
93
|
+
return [3 /*break*/, 4];
|
|
94
|
+
case 2:
|
|
95
|
+
if (!(mode.control === "normal" && moveTo)) return [3 /*break*/, 4];
|
|
96
|
+
return [4 /*yield*/, moveTo(makeNormalCameraPosition(activeState, cameraOption), activeState.position)];
|
|
97
|
+
case 3:
|
|
98
|
+
_a.sent();
|
|
99
|
+
_a.label = 4;
|
|
100
|
+
case 4: return [2 /*return*/];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}); };
|
|
84
104
|
var setZoom = function (position, isZoom) { return __awaiter(_this, void 0, void 0, function () {
|
|
85
105
|
return __generator(this, function (_a) {
|
|
86
106
|
switch (_a.label) {
|
|
@@ -89,7 +109,7 @@ export function useZoom() {
|
|
|
89
109
|
return [4 /*yield*/, closeCamera(position)];
|
|
90
110
|
case 1:
|
|
91
111
|
_a.sent();
|
|
92
|
-
return [4 /*yield*/,
|
|
112
|
+
return [4 /*yield*/, moveToCamera()];
|
|
93
113
|
case 2:
|
|
94
114
|
_a.sent();
|
|
95
115
|
return [4 /*yield*/, openCamera()];
|
|
@@ -105,6 +125,7 @@ export function useZoom() {
|
|
|
105
125
|
closeCamera: closeCamera,
|
|
106
126
|
isZoom: isZoom,
|
|
107
127
|
setIsZoom: setIsZoom,
|
|
128
|
+
moveToCamera: moveToCamera,
|
|
108
129
|
};
|
|
109
130
|
}
|
|
110
131
|
export function ZoomButton(props) {
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export { PassiveCharacter } from "./gaesup/component/passive/character";
|
|
|
6
6
|
export { PassiveVehicle } from "./gaesup/component/passive/vehicle";
|
|
7
7
|
export { GaesupController } from "./gaesup/controller";
|
|
8
8
|
export { GaeSupProps } from "./gaesup/gaesupProps";
|
|
9
|
-
export { useGaesupController } from "./gaesup/hooks";
|
|
10
9
|
export { GameBoy } from "./gaesup/tools/gameBoy";
|
|
11
10
|
export { GamePad } from "./gaesup/tools/gamePad";
|
|
12
11
|
export { JoyStick } from "./gaesup/tools/joyStick";
|
|
@@ -17,3 +16,9 @@ export { Rideable } from "./gaesup/tools/rideable";
|
|
|
17
16
|
export { ZoomButton } from "./gaesup/tools/zoomButton";
|
|
18
17
|
export { Elr, Qt, V3, V30, V31 } from "./gaesup/utils/vector";
|
|
19
18
|
export { GaesupWorld } from "./gaesup/world";
|
|
19
|
+
export { useGaesupAnimation } from "./gaesup/hooks/useGaesupAnimation";
|
|
20
|
+
export { useGaesupController } from "./gaesup/hooks/useGaesupController";
|
|
21
|
+
export * as useJoyStick from "./gaesup/hooks/useJoyStick";
|
|
22
|
+
export { usePushKey } from "./gaesup/hooks/usePushKey";
|
|
23
|
+
export { useRideable } from "./gaesup/hooks/useRideable";
|
|
24
|
+
export { useTeleport } from "./gaesup/hooks/useTeleport";
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,6 @@ export { PassiveCharacter } from "./gaesup/component/passive/character";
|
|
|
6
6
|
export { PassiveVehicle } from "./gaesup/component/passive/vehicle";
|
|
7
7
|
export { GaesupController } from "./gaesup/controller";
|
|
8
8
|
export { GaeSupProps } from "./gaesup/gaesupProps";
|
|
9
|
-
export { useGaesupController } from "./gaesup/hooks";
|
|
10
9
|
export { GameBoy } from "./gaesup/tools/gameBoy";
|
|
11
10
|
export { GamePad } from "./gaesup/tools/gamePad";
|
|
12
11
|
export { JoyStick } from "./gaesup/tools/joyStick";
|
|
@@ -17,3 +16,9 @@ export { Rideable } from "./gaesup/tools/rideable";
|
|
|
17
16
|
export { ZoomButton } from "./gaesup/tools/zoomButton";
|
|
18
17
|
export { Elr, Qt, V3, V30, V31 } from "./gaesup/utils/vector";
|
|
19
18
|
export { GaesupWorld } from "./gaesup/world";
|
|
19
|
+
export { useGaesupAnimation } from "./gaesup/hooks/useGaesupAnimation";
|
|
20
|
+
export { useGaesupController } from "./gaesup/hooks/useGaesupController";
|
|
21
|
+
export * as useJoyStick from "./gaesup/hooks/useJoyStick";
|
|
22
|
+
export { usePushKey } from "./gaesup/hooks/usePushKey";
|
|
23
|
+
export { useRideable } from "./gaesup/hooks/useRideable";
|
|
24
|
+
export { useTeleport } from "./gaesup/hooks/useTeleport";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useGaesupController } from "./useGaesupController";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useGaesupController } from "./useGaesupController";
|