gaesup-world 0.6.34 → 0.6.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gaesup/camera/control/normal.js +1 -4
- package/dist/gaesup/camera/index.js +1 -10
- package/dist/gaesup/component/index.js +6 -9
- package/dist/gaesup/hooks/useClicker/index.js +0 -1
- package/dist/gaesup/physics/airplane/direction.js +1 -1
- package/dist/gaesup/physics/airplane/gravity.d.ts +0 -12
- package/dist/gaesup/physics/airplane/gravity.js +1 -13
- package/dist/gaesup/physics/index.js +3 -1
- package/dist/gaesup/physics/type.d.ts +0 -2
- package/dist/gaesup/physics/vehicle/direction.js +1 -1
- package/package.json +1 -1
|
@@ -7,12 +7,9 @@ export var makeNormalCameraPosition = function (activeState, cameraOption) {
|
|
|
7
7
|
return cameraPosition;
|
|
8
8
|
};
|
|
9
9
|
export default function normal(prop) {
|
|
10
|
-
var
|
|
10
|
+
var state = prop.state, cameraOption = prop.worldContext.cameraOption;
|
|
11
11
|
if (!state || !state.camera)
|
|
12
12
|
return;
|
|
13
|
-
// const cameraPosition = activeState.position
|
|
14
|
-
// .clone()
|
|
15
|
-
// .add(V3(0, cameraOption.YDistance, cameraOption.ZDistance));
|
|
16
13
|
state.camera.position.lerp(cameraOption.position.clone(), 1);
|
|
17
14
|
state.camera.lookAt(cameraOption.target);
|
|
18
15
|
}
|
|
@@ -11,8 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { CameraControls } from "@react-three/drei";
|
|
14
|
-
import { useFrame
|
|
15
|
-
import { vec3 } from "@react-three/rapier";
|
|
14
|
+
import { useFrame } from "@react-three/fiber";
|
|
16
15
|
import { useContext, useEffect, useMemo, useRef } from "react";
|
|
17
16
|
import * as THREE from "three";
|
|
18
17
|
import { GaesupControllerContext } from "../controller/context";
|
|
@@ -25,17 +24,10 @@ export default function Camera(_a) {
|
|
|
25
24
|
var controllerContext = useContext(GaesupControllerContext);
|
|
26
25
|
var mode = worldContext.mode, cameraOption = worldContext.cameraOption, activeState = worldContext.activeState;
|
|
27
26
|
var rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef;
|
|
28
|
-
var camera = useThree().camera;
|
|
29
27
|
var cameraRef = useRef();
|
|
30
28
|
var intersectObjectMap = useMemo(function () { return ({}); }, []);
|
|
31
29
|
var cameraProp = __assign(__assign({}, prop), { control: control, controllerContext: controllerContext, worldContext: worldContext, intersectObjectMap: intersectObjectMap });
|
|
32
|
-
var position = useMemo(function () { return camera.position; }, []);
|
|
33
|
-
var dir = useMemo(function () { return vec3(); }, []);
|
|
34
30
|
cameraProp.cameraRay.rayCast = new THREE.Raycaster(cameraProp.cameraRay.origin, cameraProp.cameraRay.dir, 0, -cameraOption.maxDistance);
|
|
35
|
-
useEffect(function () {
|
|
36
|
-
cameraProp.cameraRay.origin.copy(position);
|
|
37
|
-
cameraProp.cameraRay.dir.copy(camera.getWorldDirection(dir));
|
|
38
|
-
}, [cameraProp]);
|
|
39
31
|
useFrame(function (state, delta) {
|
|
40
32
|
if (!rigidBodyRef ||
|
|
41
33
|
!rigidBodyRef.current ||
|
|
@@ -51,7 +43,6 @@ export default function Camera(_a) {
|
|
|
51
43
|
else if (mode.control === "normal") {
|
|
52
44
|
normal(cameraProp);
|
|
53
45
|
}
|
|
54
|
-
// detector(cameraProp);
|
|
55
46
|
}
|
|
56
47
|
});
|
|
57
48
|
// zoom
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { vec3 } from "@react-three/rapier";
|
|
3
|
-
import { useContext
|
|
3
|
+
import { useContext } from "react";
|
|
4
4
|
import calculation from "../physics";
|
|
5
5
|
import { GaesupWorldContext } from "../world/context";
|
|
6
6
|
import { AirplaneRef } from "./active/airplane";
|
|
@@ -11,12 +11,9 @@ export function GaesupComponent(_a) {
|
|
|
11
11
|
var _b = useContext(GaesupWorldContext), mode = _b.mode, states = _b.states, rideable = _b.rideable;
|
|
12
12
|
var enableRiding = states.enableRiding, isRiderOn = states.isRiderOn, rideableId = states.rideableId;
|
|
13
13
|
calculation(props);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
: vec3(), children: props.children }))] }));
|
|
20
|
-
}, [mode.type]);
|
|
21
|
-
return (_jsx(_Fragment, { children: MemorizeComponent }));
|
|
14
|
+
return (_jsxs(_Fragment, { children: [mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, { props: props, groundRay: props.groundRay, refs: refs, urls: urls, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
|
|
15
|
+
? rideable[rideableId].offset
|
|
16
|
+
: vec3(), children: props.children })), mode.type === "airplane" && (_jsx(AirplaneRef, { props: props, groundRay: props.groundRay, refs: refs, urls: urls, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
|
|
17
|
+
? rideable[rideableId].offset
|
|
18
|
+
: vec3(), children: props.children }))] }));
|
|
22
19
|
}
|
|
@@ -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 innerGroupRef = prop.innerGroupRef,
|
|
4
|
+
var innerGroupRef = prop.innerGroupRef, _a = prop.worldContext, joystick = _a.joystick, activeState = _a.activeState, control = _a.control, mode = _a.mode, airplane = prop.controllerContext.airplane, matchSizes = prop.matchSizes;
|
|
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
|
if (!matchSizes || !matchSizes["airplaneUrl"])
|
|
@@ -1,14 +1,2 @@
|
|
|
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
|
-
*/
|
|
14
2
|
export default function gravity(prop: calcPropType): void;
|
|
@@ -1,17 +1,5 @@
|
|
|
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
|
-
*/
|
|
13
1
|
export default function gravity(prop) {
|
|
14
|
-
var rigidBodyRef = prop.rigidBodyRef, activeState = prop.worldContext.activeState
|
|
2
|
+
var rigidBodyRef = prop.rigidBodyRef, activeState = prop.worldContext.activeState;
|
|
15
3
|
rigidBodyRef.current.setGravityScale(activeState.position.y < 10
|
|
16
4
|
? ((1 - 0.1) / (0 - 10)) * activeState.position.y + 1
|
|
17
5
|
: 0.1, false);
|
|
@@ -46,7 +46,9 @@ export default function calculation(prop) {
|
|
|
46
46
|
return null;
|
|
47
47
|
if (block.control)
|
|
48
48
|
return null;
|
|
49
|
-
var calcProp = __assign(__assign({}, prop), { state: state, delta: delta, worldContext: worldContext, controllerContext: controllerContext, dispatch: dispatch,
|
|
49
|
+
var calcProp = __assign(__assign({}, prop), { state: state, delta: delta, worldContext: worldContext, controllerContext: controllerContext, dispatch: dispatch,
|
|
50
|
+
// world,
|
|
51
|
+
matchSizes: getSizesByUrls(controllerContext === null || controllerContext === void 0 ? void 0 : controllerContext.urls) });
|
|
50
52
|
if (mode.type === "vehicle")
|
|
51
53
|
vehicleCalculation(calcProp);
|
|
52
54
|
else if (mode.type === "character")
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RootState } from "@react-three/fiber";
|
|
2
|
-
import { World } from "@dimforge/rapier3d-compat";
|
|
3
2
|
import * as THREE from "three";
|
|
4
3
|
import { gaesupControllerType } from "../controller/context/type";
|
|
5
4
|
import { controllerInnerType, refsType } from "../controller/type";
|
|
@@ -19,7 +18,6 @@ export type calcPropType = controllerInnerType & {
|
|
|
19
18
|
};
|
|
20
19
|
delta?: number;
|
|
21
20
|
dispatch?: dispatchType<gaesupWorldContextType>;
|
|
22
|
-
world: World;
|
|
23
21
|
};
|
|
24
22
|
export type intersectObjectMapType = {
|
|
25
23
|
[uuid: string]: THREE.Mesh;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { vec3 } from "@react-three/rapier";
|
|
2
2
|
import { V3 } from "../../utils/vector";
|
|
3
3
|
export function joystick(prop) {
|
|
4
|
-
var
|
|
4
|
+
var _a = prop.worldContext, activeState = _a.activeState, joystick = _a.joystick;
|
|
5
5
|
var zAxis = joystick.joyStickOrigin.isOn ? 1 : 0;
|
|
6
6
|
var front = vec3().set(zAxis, 0, zAxis);
|
|
7
7
|
if (joystick.joyStickOrigin.isCenter)
|